/*

 This is a generated file. DO NOT EDIT.

 Copyright (C) 2010-2015 KO GmbH <copyright@kogmbh.com>

 @licstart
 This file is the compiled version of the WebODF library.

 WebODF is free software: you can redistribute it and/or modify it
 under the terms of the GNU Affero General Public License (GNU AGPL)
 as published by the Free Software Foundation, either version 3 of
 the License, or (at your option) any later version.

 WebODF is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with WebODF.  If not, see <http://www.gnu.org/licenses/>.
 @licend

 @source: http://www.webodf.org/
 @source: https://github.com/kogmbh/WebODF/
 @source: https://github.com/erseco/webodf/commit/ca87b66392979290b1ba002e5ae2d2ab80312afa
*/
var webodf_version="0.0.0-buildca87b663";function Runtime(){}Runtime.prototype.getVariable=function(g){};Runtime.prototype.toJson=function(g){};Runtime.prototype.fromJson=function(g){};Runtime.prototype.byteArrayFromString=function(g,l){};Runtime.prototype.byteArrayToString=function(g,l){};Runtime.prototype.read=function(g,l,d,b){};Runtime.prototype.readFile=function(g,l,d){};Runtime.prototype.readFileSync=function(g,l){};Runtime.prototype.loadXML=function(g,l){};
Runtime.prototype.writeFile=function(g,l,d){};Runtime.prototype.deleteFile=function(g,l){};Runtime.prototype.log=function(g,l){};Runtime.prototype.setTimeout=function(g,l){};Runtime.prototype.clearTimeout=function(g){};Runtime.prototype.libraryPaths=function(){};Runtime.prototype.currentDirectory=function(){};Runtime.prototype.setCurrentDirectory=function(g){};Runtime.prototype.type=function(){};Runtime.prototype.getDOMImplementation=function(){};Runtime.prototype.parseXML=function(g){};
Runtime.prototype.exit=function(g){};Runtime.prototype.getWindow=function(){};Runtime.prototype.requestAnimationFrame=function(g){};Runtime.prototype.cancelAnimationFrame=function(g){};Runtime.prototype.assert=function(g,l){};var IS_COMPILED_CODE=!0;
Runtime.byteArrayToString=function(g,l){function d(b){var d="",p,q=b.length;for(p=0;p<q;p+=1)d+=String.fromCharCode(b[p]&255);return d}function b(b){var d="",p,q=b.length,f=[],m,a,c,e;for(p=3<=q&&239===b[0]&&187===b[1]&&191===b[2]?3:0;p<q;p+=1)m=b[p],128>m?f.push(m):(p+=1,a=b[p],194<=m&&224>m?f.push((m&31)<<6|a&63):(p+=1,c=b[p],224<=m&&240>m?f.push((m&15)<<12|(a&63)<<6|c&63):(p+=1,e=b[p],240<=m&&245>m&&(m=(m&7)<<18|(a&63)<<12|(c&63)<<6|e&63,m-=65536,f.push((m>>10)+55296,(m&1023)+56320))))),1E3<=f.length&&
(d+=String.fromCharCode.apply(null,f),f.length=0);return d+String.fromCharCode.apply(null,f)}var h;"utf8"===l?h=b(g):("binary"!==l&&this.log("Unsupported encoding: "+l),h=d(g));return h};Runtime.getVariable=function(g){try{return eval(g)}catch(l){}};Runtime.toJson=function(g){return JSON.stringify(g)};Runtime.fromJson=function(g){return JSON.parse(g)};Runtime.getFunctionName=function(g){return void 0===g.name?(g=/function\s+(\w+)/.exec(g))&&g[1]:g.name};
Runtime.assert=function(g,l){if(!g)throw this.log("alert","ASSERTION FAILED:\n"+l),Error(l);};
function BrowserRuntime(){function g(b){var f=b.length,m,a,c=0;for(m=0;m<f;m+=1)a=b.charCodeAt(m),c+=1+(128<a)+(2048<a),55040<a&&57344>a&&(c+=1,m+=1);return c}function l(b,f,m){var a=b.length,c,e;f=new Uint8Array(new ArrayBuffer(f));m?(f[0]=239,f[1]=187,f[2]=191,e=3):e=0;for(m=0;m<a;m+=1)c=b.charCodeAt(m),128>c?(f[e]=c,e+=1):2048>c?(f[e]=192|c>>>6,f[e+1]=128|c&63,e+=2):55040>=c||57344<=c?(f[e]=224|c>>>12&15,f[e+1]=128|c>>>6&63,f[e+2]=128|c&63,e+=3):(m+=1,c=(c-55296<<10|b.charCodeAt(m)-56320)+65536,
f[e]=240|c>>>18&7,f[e+1]=128|c>>>12&63,f[e+2]=128|c>>>6&63,f[e+3]=128|c&63,e+=4);return f}function d(b){var f=b.length,m=new Uint8Array(new ArrayBuffer(f)),a;for(a=0;a<f;a+=1)m[a]=b.charCodeAt(a)&255;return m}function b(b,f){var m;void 0!==f?m=b:f=b;console.log(f);p.enableAlerts&&"alert"===m&&alert(f)}function h(b,f,m){if(0!==m.status||m.responseText)if(200===m.status||0===m.status){if(m.response&&"string"!==typeof m.response)"binary"===f?(m=m.response,m=new Uint8Array(m)):m=String(m.response);else if("binary"===
f)if(null!==m.responseBody&&"undefined"!==String(typeof VBArray)){m=(new VBArray(m.responseBody)).toArray();var a=m.length;f=new Uint8Array(new ArrayBuffer(a));for(b=0;b<a;b+=1)f[b]=m[b];m=f}else{(b=m.getResponseHeader("Content-Length"))&&(b=parseInt(b,10));if(b&&b!==m.responseText.length)a:{a=m.responseText;f=!1;var c=g(a);if("number"===typeof b){if(b!==c&&b!==c+3){a=void 0;break a}f=c+3===b;c=b}a=l(a,c,f)}void 0===a&&(a=d(m.responseText));m=a}else m=m.responseText;m={err:null,data:m}}else m={err:m.responseText||
m.statusText,data:null};else m={err:"File "+b+" is empty.",data:null};return m}function n(b,f,m){var a=new XMLHttpRequest;a.open("GET",b,m);a.overrideMimeType&&("binary"!==f?a.overrideMimeType("text/plain; charset="+f):a.overrideMimeType("text/plain; charset=x-user-defined"));return a}function r(b,f,m){var a=n(b,f,!0);a.onreadystatechange=function(){var c;4===a.readyState&&(c=h(b,f,a),m(c.err,c.data))};try{a.send(null)}catch(c){m(c.message,null)}}var p=this;this.byteArrayFromString=function(b,f){var m;
"utf8"===f?m=l(b,g(b),!1):("binary"!==f&&p.log("unknown encoding: "+f),m=d(b));return m};this.byteArrayToString=Runtime.byteArrayToString;this.getVariable=Runtime.getVariable;this.fromJson=Runtime.fromJson;this.toJson=Runtime.toJson;this.readFile=r;this.read=function(b,f,m,a){r(b,"binary",function(c,e){var k=null;if(e){if("string"===typeof e)throw"This should not happen.";k=e.subarray(f,f+m)}a(c,k)})};this.readFileSync=function(b,f){var m=n(b,f,!1),a;try{m.send(null);a=h(b,f,m);if(a.err)throw a.err;
if(null===a.data)throw"No data read from "+b+".";}catch(c){throw c;}return a.data};this.writeFile=function(b,f,m){var a=new XMLHttpRequest,c;a.open("PUT",b,!0);a.onreadystatechange=function(){4===a.readyState&&(0!==a.status||a.responseText?200<=a.status&&300>a.status||0===a.status?m(null):m("Status "+String(a.status)+": "+a.responseText||a.statusText):m("File "+b+" is empty."))};c=f.buffer&&!a.sendAsBinary?f.buffer:p.byteArrayToString(f,"binary");try{a.sendAsBinary?a.sendAsBinary(c):a.send(c)}catch(e){p.log("HUH? "+
e+" "+f),m(e.message)}};this.deleteFile=function(b,f){var m=new XMLHttpRequest;m.open("DELETE",b,!0);m.onreadystatechange=function(){4===m.readyState&&(200>m.status&&300<=m.status?f(m.responseText):f(null))};m.send(null)};this.loadXML=function(b,f){var m=new XMLHttpRequest;m.open("GET",b,!0);m.overrideMimeType&&m.overrideMimeType("text/xml");m.onreadystatechange=function(){4===m.readyState&&(0!==m.status||m.responseText?200===m.status||0===m.status?f(null,m.responseXML):f(m.responseText,null):f("File "+
b+" is empty.",null))};try{m.send(null)}catch(a){f(a.message,null)}};this.log=b;this.enableAlerts=!0;this.assert=Runtime.assert;this.setTimeout=function(b,f){return setTimeout(function(){b()},f)};this.clearTimeout=function(b){clearTimeout(b)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.currentDirectory=function(){return""};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){return window.document.implementation};this.parseXML=
function(b){return(new DOMParser).parseFromString(b,"text/xml")};this.exit=function(d){b("Calling exit with code "+String(d)+", but exit() is not implemented.")};this.getWindow=function(){return window};this.requestAnimationFrame=function(b){var f=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame;if(f)f.bind(window),b=f(b);else return setTimeout(b,15);return b};this.cancelAnimationFrame=function(b){var f=window.cancelAnimationFrame||
window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame;f?(f.bind(window),f(b)):clearTimeout(b)}}
function NodeJSRuntime(){function g(b){var f=b.length,m,a=new Uint8Array(new ArrayBuffer(f));for(m=0;m<f;m+=1)a[m]=b[m];return a}function l(d,f,m){function a(a,e){if(a)return m(a,null);if(!e)return m("No data for "+d+".",null);if("string"===typeof e)return m(a,e);m(a,g(e))}d=h.resolve(n,d);"binary"!==f?b.readFile(d,f,a):b.readFile(d,null,a)}var d=this,b=require("fs"),h=require("path"),n="",r,p;this.byteArrayFromString=function(b,f){var m=new Buffer(b,f),a,c=m.length,e=new Uint8Array(new ArrayBuffer(c));
for(a=0;a<c;a+=1)e[a]=m[a];return e};this.byteArrayToString=Runtime.byteArrayToString;this.getVariable=Runtime.getVariable;this.fromJson=Runtime.fromJson;this.toJson=Runtime.toJson;this.readFile=l;this.loadXML=function(b,f){l(b,"utf-8",function(m,a){if(m)return f(m,null);if(!a)return f("No data for "+b+".",null);f(null,d.parseXML(a))})};this.writeFile=function(d,f,m){f=new Buffer(f);d=h.resolve(n,d);b.writeFile(d,f,"binary",function(a){m(a||null)})};this.deleteFile=function(d,f){d=h.resolve(n,d);
b.unlink(d,f)};this.read=function(d,f,m,a){d=h.resolve(n,d);b.open(d,"r+",666,function(c,e){if(c)a(c,null);else{var k=new Buffer(m);b.read(e,k,0,m,f,function(c){b.close(e);a(c,g(k))})}})};this.readFileSync=function(d,f){var m=b.readFileSync(d,"binary"===f?null:f);if(null===m)throw"File "+d+" could not be read.";return"binary"===f?g(m):m};this.log=function(b,d){var m;void 0!==d?m=b:d=b;"alert"===m&&process.stderr.write("\n!!!!! ALERT !!!!!\n");process.stderr.write(d+"\n");"alert"===m&&process.stderr.write("!!!!! ALERT !!!!!\n")};
this.assert=Runtime.assert;this.setTimeout=function(b,d){return setTimeout(function(){b()},d)};this.clearTimeout=function(b){clearTimeout(b)};this.libraryPaths=function(){return[__dirname]};this.setCurrentDirectory=function(b){n=b};this.currentDirectory=function(){return n};this.type=function(){return"NodeJSRuntime"};this.getDOMImplementation=function(){return p};this.parseXML=function(b){return r.parseFromString(b,"text/xml")};this.exit=process.exit;this.getWindow=function(){return null};this.requestAnimationFrame=
function(b){return setTimeout(b,15)};this.cancelAnimationFrame=function(b){clearTimeout(b)};r=new (require("xmldom").DOMParser);p=d.parseXML("<a/>").implementation}
function RhinoRuntime(){var g=this,l={},d=l.javax.xml.parsers.DocumentBuilderFactory.newInstance(),b,h,n="";d.setValidating(!1);d.setNamespaceAware(!0);d.setExpandEntityReferences(!1);d.setSchema(null);h=l.org.xml.sax.EntityResolver({resolveEntity:function(b,d){var p=new l.java.io.FileReader(d);return new l.org.xml.sax.InputSource(p)}});b=d.newDocumentBuilder();b.setEntityResolver(h);this.byteArrayFromString=function(b,d){var p,f=b.length,m=new Uint8Array(new ArrayBuffer(f));for(p=0;p<f;p+=1)m[p]=
b.charCodeAt(p)&255;return m};this.byteArrayToString=Runtime.byteArrayToString;this.getVariable=Runtime.getVariable;this.fromJson=Runtime.fromJson;this.toJson=Runtime.toJson;this.loadXML=function(d,p){var h=new l.java.io.File(d),f=null;try{f=b.parse(h)}catch(m){return print(m),p(m,null)}p(null,f)};this.readFile=function(b,d,h){n&&(b=n+"/"+b);var f=new l.java.io.File(b),m="binary"===d?"latin1":d;f.isFile()?((b=readFile(b,m))&&"binary"===d&&(b=g.byteArrayFromString(b,"binary")),h(null,b)):h(b+" is not a file.",
null)};this.writeFile=function(b,d,h){n&&(b=n+"/"+b);b=new l.java.io.FileOutputStream(b);var f,m=d.length;for(f=0;f<m;f+=1)b.write(d[f]);b.close();h(null)};this.deleteFile=function(b,d){n&&(b=n+"/"+b);var h=new l.java.io.File(b),f=new l.java.io.File(b+Math.random());h.rename(f)?(f.deleteOnExit(),d(null)):d("Could not delete "+b)};this.read=function(b,d,h,f){n&&(b=n+"/"+b);var m;m=b;var a="binary";(new l.java.io.File(m)).isFile()?("binary"===a&&(a="latin1"),m=readFile(m,a)):m=null;m?f(null,this.byteArrayFromString(m.substring(d,
d+h),"binary")):f("Cannot read "+b,null)};this.readFileSync=function(b,d){if(!d)return"";var h=readFile(b,d);if(null===h)throw"File could not be read.";return h};this.log=function(b,d){var h;void 0!==d?h=b:d=b;"alert"===h&&print("\n!!!!! ALERT !!!!!");print(d);"alert"===h&&print("!!!!! ALERT !!!!!")};this.assert=Runtime.assert;this.setTimeout=function(b){b();return 0};this.clearTimeout=function(){};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(b){n=b};this.currentDirectory=
function(){return n};this.type=function(){return"RhinoRuntime"};this.getDOMImplementation=function(){return b.getDOMImplementation()};this.parseXML=function(d){d=new l.java.io.StringReader(d);d=new l.org.xml.sax.InputSource(d);return b.parse(d)};this.exit=quit;this.getWindow=function(){return null};this.requestAnimationFrame=function(b){b();return 0};this.cancelAnimationFrame=function(){}}
Runtime.create=function(){return"undefined"!==String(typeof window)?new BrowserRuntime:"undefined"!==String(typeof require)?new NodeJSRuntime:new RhinoRuntime};var runtime=Runtime.create(),core={},gui={},xmldom={},odf={},ops={},webodf={};(function(){webodf.Version="undefined"!==String(typeof webodf_version)?webodf_version:"From Source"})();
(function(){function g(b,d,h){var f=b+"/manifest.json",m,a;runtime.log("Loading manifest: "+f);try{m=runtime.readFileSync(f,"utf-8")}catch(c){if(h)runtime.log("No loadable manifest found.");else throw console.log(String(c)),c;return}h=JSON.parse(m);for(a in h)h.hasOwnProperty(a)&&(d[a]={dir:b,deps:h[a]})}function l(b,d,h){function f(e){if(!c[e]&&!h(e)){if(a[e])throw"Circular dependency detected for "+e+".";a[e]=!0;if(!d[e])throw"Missing dependency information for class "+e+".";var k=d[e],b=k.deps,
n,p=b.length;for(n=0;n<p;n+=1)f(b[n]);a[e]=!1;c[e]=!0;m.push(k.dir+"/"+e.replace(".","/")+".js")}}var m=[],a={},c={};b.forEach(f);return m}function d(b){var d,h;for(d=0;d<b.length;d+=1)h=runtime.readFileSync(b[d],"utf-8"),h+="\n//# sourceURL="+b[d],eval(h)}function b(b){b=b.split(".");var d,h=n,f=b.length;for(d=0;d<f;d+=1){if(!h.hasOwnProperty(b[d]))return!1;h=h[b[d]]}return!0}var h,n={core:core,gui:gui,xmldom:xmldom,odf:odf,ops:ops};runtime.loadClasses=function(n,p){if(IS_COMPILED_CODE||0===n.length)return p&&
p();var r;if(!(r=h)){r=[];var f=runtime.libraryPaths(),m;runtime.currentDirectory()&&-1===f.indexOf(runtime.currentDirectory())&&g(runtime.currentDirectory(),r,!0);for(m=0;m<f.length;m+=1)g(f[m],r)}h=r;n=l(n,h,b);if(0===n.length)return p&&p();if("BrowserRuntime"===runtime.type()&&p){r=n;f=document.currentScript||document.documentElement.lastChild;m=document.createDocumentFragment();var a,c;for(c=0;c<r.length;c+=1)a=document.createElement("script"),a.type="text/javascript",a.charset="utf-8",a.async=
!1,a.setAttribute("src",r[c]),m.appendChild(a);p&&(a.onload=p);f.parentNode.insertBefore(m,f)}else d(n),p&&p()};runtime.loadClass=function(b,d){runtime.loadClasses([b],d)}})();(function(){var g=function(g){return g};runtime.getTranslator=function(){return g};runtime.setTranslator=function(l){g=l};runtime.tr=function(l){var d=g(l);return d&&"string"===String(typeof d)?d:l}})();
(function(g){function l(d){if(d.length){var b=d[0];runtime.readFile(b,"utf8",function(h,n){function g(){var b=eval(l);b&&runtime.exit(b)}var p="",p=b.lastIndexOf("/"),l=n,p=-1!==p?b.substring(0,p):".";runtime.setCurrentDirectory(p);h?(runtime.log(h),runtime.exit(1)):null===l?(runtime.log("No code found for "+b),runtime.exit(1)):g.apply(null,d)})}}g=g?Array.prototype.slice.call(g):[];"NodeJSRuntime"===runtime.type()?l(process.argv.slice(2)):"RhinoRuntime"===runtime.type()?l(g):l(g.slice(1))})("undefined"!==
String(typeof arguments)&&arguments);(function(){core.Async=function(){return{forEach:function(g,l,d){function b(b){r!==n&&(b?(r=n,d(b)):(r+=1,r===n&&d(null)))}var h,n=g.length,r=0;for(h=0;h<n;h+=1)l(g[h],b)},destroyAll:function(g,l){function d(b,h){if(h)l(h);else if(b<g.length)g[b](function(h){d(b+1,h)});else l()}d(0,void 0)}}}()})();
function makeBase64(){function g(a){var c,e=a.length,k=new Uint8Array(new ArrayBuffer(e));for(c=0;c<e;c+=1)k[c]=a.charCodeAt(c)&255;return k}function l(a){var c,e="",k,b=a.length-2;for(k=0;k<b;k+=3)c=a[k]<<16|a[k+1]<<8|a[k+2],e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>18],e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>12&63],e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>6&63],e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c&
63];k===b+1?(c=a[k]<<4,e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>6],e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c&63],e+="=="):k===b&&(c=a[k]<<10|a[k+1]<<2,e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>12],e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>6&63],e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c&63],e+="=");return e}function d(a){a=a.replace(/[^A-Za-z0-9+\/]+/g,
"");var c=a.length,e=new Uint8Array(new ArrayBuffer(3*c)),b=a.length%4,d=0,m,f;for(m=0;m<c;m+=4)f=(k[a.charAt(m)]||0)<<18|(k[a.charAt(m+1)]||0)<<12|(k[a.charAt(m+2)]||0)<<6|(k[a.charAt(m+3)]||0),e[d]=f>>16,e[d+1]=f>>8&255,e[d+2]=f&255,d+=3;c=3*c-[0,0,2,1][b];return e.subarray(0,c)}function b(a){var c,e,k=a.length,b=0,d=new Uint8Array(new ArrayBuffer(3*k));for(c=0;c<k;c+=1)e=a[c],128>e?d[b++]=e:(2048>e?d[b++]=192|e>>>6:(d[b++]=224|e>>>12&15,d[b++]=128|e>>>6&63),d[b++]=128|e&63);return d.subarray(0,
b)}function h(a){var c,e,k,b,d=a.length,m=new Uint8Array(new ArrayBuffer(d)),f=0;for(c=0;c<d;c+=1)e=a[c],128>e?m[f++]=e:(c+=1,k=a[c],224>e?m[f++]=(e&31)<<6|k&63:(c+=1,b=a[c],m[f++]=(e&15)<<12|(k&63)<<6|b&63));return m.subarray(0,f)}function n(a){return l(g(a))}function r(a){return String.fromCharCode.apply(String,d(a))}function p(a){return h(g(a))}function q(a){a=h(a);for(var c="",e=0;e<a.length;)c+=String.fromCharCode.apply(String,a.subarray(e,e+45E3)),e+=45E3;return c}function f(a,c,e){var k,b,
d,m="";for(d=c;d<e;d+=1)c=a.charCodeAt(d)&255,128>c?m+=String.fromCharCode(c):(d+=1,k=a.charCodeAt(d)&255,224>c?m+=String.fromCharCode((c&31)<<6|k&63):(d+=1,b=a.charCodeAt(d)&255,m+=String.fromCharCode((c&15)<<12|(k&63)<<6|b&63)));return m}function m(a,c){function e(){var d=b+1E5;d>a.length&&(d=a.length);k+=f(a,b,d);b=d;d=b===a.length;c(k,d)&&!d&&runtime.setTimeout(e,0)}var k="",b=0;1E5>a.length?c(f(a,0,a.length),!0):("string"!==typeof a&&(a=a.slice()),e())}function a(a){return b(g(a))}function c(a){return String.fromCharCode.apply(String,
b(a))}function e(a){return String.fromCharCode.apply(String,b(g(a)))}var k=function(a){var c={},e,k;e=0;for(k=a.length;e<k;e+=1)c[a.charAt(e)]=e;return c}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),x,u,y=runtime.getWindow(),w,z;y&&y.btoa?(w=y.btoa,x=function(a){return w(e(a))}):(w=n,x=function(c){return l(a(c))});y&&y.atob?(z=y.atob,u=function(a){a=z(a);return f(a,0,a.length)}):(z=r,u=function(a){return q(d(a))});core.Base64=function(){this.convertByteArrayToBase64=this.convertUTF8ArrayToBase64=
l;this.convertBase64ToByteArray=this.convertBase64ToUTF8Array=d;this.convertUTF16ArrayToByteArray=this.convertUTF16ArrayToUTF8Array=b;this.convertByteArrayToUTF16Array=this.convertUTF8ArrayToUTF16Array=h;this.convertUTF8StringToBase64=n;this.convertBase64ToUTF8String=r;this.convertUTF8StringToUTF16Array=p;this.convertByteArrayToUTF16String=this.convertUTF8ArrayToUTF16String=q;this.convertUTF8StringToUTF16String=m;this.convertUTF16StringToByteArray=this.convertUTF16StringToUTF8Array=a;this.convertUTF16ArrayToUTF8String=
c;this.convertUTF16StringToUTF8String=e;this.convertUTF16StringToBase64=x;this.convertBase64ToUTF16String=u;this.fromBase64=r;this.toBase64=n;this.atob=z;this.btoa=w;this.utob=e;this.btou=m;this.encode=x;this.encodeURI=function(a){return x(a).replace(/[+\/]/g,function(a){return"+"===a?"-":"_"}).replace(/\\=+$/,"")};this.decode=function(a){return u(a.replace(/[\-_]/g,function(a){return"-"===a?"+":"/"}))};return this};return core.Base64}core.Base64=makeBase64();
core.CSSUnits=function(){var g=this,l={"in":1,cm:2.54,mm:25.4,pt:72,pc:12,px:96};this.convert=function(d,b,h){return d*l[h]/l[b]};this.convertMeasure=function(d,b){var h,n;d&&b&&(h=parseFloat(d),n=d.replace(h.toString(),""),h=g.convert(h,n,b));return h};this.getUnits=function(d){return d.substr(d.length-2,d.length)}};
(function(){function g(){var b,h,n,g,p,l,f,m,a;void 0===d&&(h=(b=runtime.getWindow())&&b.document,l=h.documentElement,f=h.body,d={rangeBCRIgnoresElementBCR:!1,unscaledRangeClientRects:!1,elementBCRIgnoresBodyScroll:!1},h&&(g=h.createElement("div"),g.style.position="absolute",g.style.left="-99999px",g.style.transform="scale(2)",g.style["-webkit-transform"]="scale(2)",p=h.createElement("div"),g.appendChild(p),f.appendChild(g),b=h.createRange(),b.selectNode(p),d.rangeBCRIgnoresElementBCR=0===b.getClientRects().length,
p.appendChild(h.createTextNode("Rect transform test")),h=p.getBoundingClientRect(),n=b.getBoundingClientRect(),d.unscaledRangeClientRects=2<Math.abs(h.height-n.height),g.style.transform="",g.style["-webkit-transform"]="",h=l.style.overflow,n=f.style.overflow,m=f.style.height,a=f.scrollTop,l.style.overflow="visible",f.style.overflow="visible",f.style.height="200%",f.scrollTop=f.scrollHeight,d.elementBCRIgnoresBodyScroll=b.getBoundingClientRect().top!==p.getBoundingClientRect().top,f.scrollTop=a,f.style.height=
m,f.style.overflow=n,l.style.overflow=h,b.detach(),f.removeChild(g),b=Object.keys(d).map(function(a){return a+":"+String(d[a])}).join(", "),runtime.log("Detected browser quirks - "+b)));return d}function l(b,d,n){for(b=b?b.firstElementChild:null;b;){if(b.localName===n&&b.namespaceURI===d)return b;b=b.nextElementSibling}return null}var d;core.DomUtilsImpl=function(){function b(a,c){for(var e=0,k;a.parentNode!==c;)runtime.assert(null!==a.parentNode,"parent is null"),a=a.parentNode;for(k=c.firstChild;k!==
a;)e+=1,k=k.nextSibling;return e}function d(a,c){return 0>=a.compareBoundaryPoints(Range.START_TO_START,c)&&0<=a.compareBoundaryPoints(Range.END_TO_END,c)}function n(a,c){return 0>=a.compareBoundaryPoints(Range.END_TO_START,c)&&0<=a.compareBoundaryPoints(Range.START_TO_END,c)}function r(a,c){var e=null;a.nodeType===Node.TEXT_NODE&&(0===a.length?(a.parentNode.removeChild(a),c.nodeType===Node.TEXT_NODE&&(e=c)):(c.nodeType===Node.TEXT_NODE&&(a.appendData(c.data),c.parentNode.removeChild(c)),e=a));return e}
function p(a){for(var c=a.parentNode;a.firstChild;)c.insertBefore(a.firstChild,a);c.removeChild(a);return c}function q(a,c){var e=a.parentNode,k=a.firstChild,b=c(a),d;if(b===NodeFilter.FILTER_SKIP)return e;for(;k;)d=k.nextSibling,q(k,c),k=d;e&&b===NodeFilter.FILTER_REJECT&&p(a);return e}function f(a,c){return a===c||!!(a.compareDocumentPosition(c)&Node.DOCUMENT_POSITION_CONTAINED_BY)}function m(a,c){return g().unscaledRangeClientRects?a:a/c}function a(c,k,b){Object.keys(k).forEach(function(e){var d=
e.split(":"),m=d[1],f=b(d[0]),d=k[e],h=typeof d;"object"===h?Object.keys(d).length&&(e=f?c.getElementsByTagNameNS(f,m)[0]||c.ownerDocument.createElementNS(f,e):c.getElementsByTagName(m)[0]||c.ownerDocument.createElement(e),c.appendChild(e),a(e,d,b)):f&&(runtime.assert("number"===h||"string"===h,"attempting to map unsupported type '"+h+"' (key: "+e+")"),c.setAttributeNS(f,e,String(d)))})}var c=null;this.splitBoundaries=function(a){var c,e=[],d,m,f;if(a.startContainer.nodeType===Node.TEXT_NODE||a.endContainer.nodeType===
Node.TEXT_NODE){d=a.endContainer;m=a.endContainer.nodeType!==Node.TEXT_NODE?a.endOffset===a.endContainer.childNodes.length:!1;f=a.endOffset;c=a.endContainer;if(f<c.childNodes.length)for(c=c.childNodes.item(f),f=0;c.firstChild;)c=c.firstChild;else for(;c.lastChild;)c=c.lastChild,f=c.nodeType===Node.TEXT_NODE?c.textContent.length:c.childNodes.length;c===d&&(d=null);a.setEnd(c,f);f=a.endContainer;0!==a.endOffset&&f.nodeType===Node.TEXT_NODE&&(c=f,a.endOffset!==c.length&&(e.push(c.splitText(a.endOffset)),
e.push(c)));f=a.startContainer;0!==a.startOffset&&f.nodeType===Node.TEXT_NODE&&(c=f,a.startOffset!==c.length&&(f=c.splitText(a.startOffset),e.push(c),e.push(f),a.setStart(f,0)));if(null!==d){for(f=a.endContainer;f.parentNode&&f.parentNode!==d;)f=f.parentNode;m=m?d.childNodes.length:b(f,d);a.setEnd(d,m)}}return e};this.containsRange=d;this.rangesIntersect=n;this.rangeIntersection=function(a,c){var e;n(a,c)&&(e=a.cloneRange(),-1===a.compareBoundaryPoints(Range.START_TO_START,c)&&e.setStart(c.startContainer,
c.startOffset),1===a.compareBoundaryPoints(Range.END_TO_END,c)&&e.setEnd(c.endContainer,c.endOffset));return e};this.getNodesInRange=function(a,c,b){var e=[],k=a.commonAncestorContainer,k=k.nodeType===Node.TEXT_NODE?k.parentNode:k;b=a.startContainer.ownerDocument.createTreeWalker(k,b,c,!1);var d,m;a.endContainer.childNodes[a.endOffset-1]?(d=a.endContainer.childNodes[a.endOffset-1],m=Node.DOCUMENT_POSITION_PRECEDING|Node.DOCUMENT_POSITION_CONTAINED_BY):(d=a.endContainer,m=Node.DOCUMENT_POSITION_PRECEDING);
if(a.startContainer.childNodes[a.startOffset])a=a.startContainer.childNodes[a.startOffset],b.currentNode=a;else{var f=a.startContainer;a.startOffset===(f.nodeType===Node.TEXT_NODE?f.length:f.childNodes.length)?(a=a.startContainer,b.currentNode=a,b.lastChild(),a=b.nextNode()):(a=a.startContainer,b.currentNode=a)}if(a){a=b.currentNode;if(a!==k)for(a=a.parentNode;a&&a!==k;)c(a)===NodeFilter.FILTER_REJECT&&(b.currentNode=a),a=a.parentNode;a=b.currentNode;switch(c(a)){case NodeFilter.FILTER_REJECT:for(a=
b.nextSibling();!a&&b.parentNode();)a=b.nextSibling();break;case NodeFilter.FILTER_SKIP:a=b.nextNode()}for(;a;){c=d.compareDocumentPosition(a);if(0!==c&&0===(c&m))break;e.push(a);a=b.nextNode()}}return e};this.normalizeTextNodes=function(a){a&&a.nextSibling&&(a=r(a,a.nextSibling));a&&a.previousSibling&&r(a.previousSibling,a)};this.rangeContainsNode=function(a,c){var b=c.ownerDocument.createRange(),e=c.ownerDocument.createRange(),k;b.setStart(a.startContainer,a.startOffset);b.setEnd(a.endContainer,
a.endOffset);e.selectNodeContents(c);k=d(b,e);b.detach();e.detach();return k};this.mergeIntoParent=p;this.removeUnwantedNodes=q;this.removeAllChildNodes=function(a){for(;a.firstChild;)a.removeChild(a.firstChild)};this.getElementsByTagNameNS=function(a,c,b){var e=[];a=a.getElementsByTagNameNS(c,b);e.length=b=a.length;for(c=0;c<b;c+=1)e[c]=a.item(c);return e};this.getElementsByTagName=function(a,c){var b=[],e,k,d;e=a.getElementsByTagName(c);b.length=d=e.length;for(k=0;k<d;k+=1)b[k]=e.item(k);return b};
this.containsNode=function(a,c){return a===c||a.contains(c)};this.comparePoints=function(a,c,d,m){if(a===d)return m-c;var e=a.compareDocumentPosition(d);2===e?e=-1:4===e?e=1:10===e?(c=b(a,d),e=c<m?1:-1):(m=b(d,a),e=m<c?-1:1);return e};this.adaptRangeDifferenceToZoomLevel=m;this.translateRect=function(a,c,b){return{top:m(a.top-c.top,b),left:m(a.left-c.left,b),bottom:m(a.bottom-c.top,b),right:m(a.right-c.left,b),width:m(a.width,b),height:m(a.height,b)}};this.getBoundingClientRect=function(a){var b=
a.ownerDocument,e=g(),d=b.body;if((!1===e.unscaledRangeClientRects||e.rangeBCRIgnoresElementBCR)&&a.nodeType===Node.ELEMENT_NODE)return a=a.getBoundingClientRect(),e.elementBCRIgnoresBodyScroll?{left:a.left+d.scrollLeft,right:a.right+d.scrollLeft,top:a.top+d.scrollTop,bottom:a.bottom+d.scrollTop,width:a.width,height:a.height}:a;var m;c?m=c:c=m=b.createRange();e=m;e.selectNode(a);return e.getBoundingClientRect()};this.mapKeyValObjOntoNode=function(a,c,b){Object.keys(c).forEach(function(e){var k=e.split(":"),
d=k[1],k=b(k[0]),m=c[e];k?(d=a.getElementsByTagNameNS(k,d)[0],d||(d=a.ownerDocument.createElementNS(k,e),a.appendChild(d)),d.textContent=m):runtime.log("Key ignored: "+e)})};this.removeKeyElementsFromNode=function(a,c,b){c.forEach(function(c){var e=c.split(":"),k=e[1];(e=b(e[0]))?(k=a.getElementsByTagNameNS(e,k)[0])?k.parentNode.removeChild(k):runtime.log("Element for "+c+" not found."):runtime.log("Property Name ignored: "+c)})};this.getKeyValRepresentationOfNode=function(a,c){for(var b={},e=a.firstElementChild,
k;e;){if(k=c(e.namespaceURI))b[k+":"+e.localName]=e.textContent;e=e.nextElementSibling}return b};this.mapObjOntoNode=a;this.cloneEvent=function(a){var c=Object.create(null);Object.keys(a.constructor.prototype).forEach(function(b){c[b]=a[b]});c.prototype=a.constructor.prototype;return c};this.getDirectChild=l;(function(a){var c,b;b=runtime.getWindow();null!==b&&(c=b.navigator.appVersion.toLowerCase(),b=-1===c.indexOf("chrome")&&(-1!==c.indexOf("applewebkit")||-1!==c.indexOf("safari")),c=-1!==c.indexOf("msie")||
-1!==c.indexOf("trident"),b||c)&&(a.containsNode=f)})(this)};core.DomUtils=new core.DomUtilsImpl})();
core.Cursor=function(g,l){function d(a){a.parentNode&&(p.push(a.previousSibling),p.push(a.nextSibling),a.parentNode.removeChild(a))}function b(a,c,b){if(c.nodeType===Node.TEXT_NODE){runtime.assert(!!c,"putCursorIntoTextNode: invalid container");var e=c.parentNode;runtime.assert(!!e,"putCursorIntoTextNode: container without parent");runtime.assert(0<=b&&b<=c.length,"putCursorIntoTextNode: offset is out of bounds");0===b?e.insertBefore(a,c):(b!==c.length&&c.splitText(b),e.insertBefore(a,c.nextSibling))}else c.nodeType===
Node.ELEMENT_NODE&&c.insertBefore(a,c.childNodes.item(b));p.push(a.previousSibling);p.push(a.nextSibling)}var h=g.createElementNS("urn:webodf:names:cursor","cursor"),n=g.createElementNS("urn:webodf:names:cursor","anchor"),r,p=[],q=g.createRange(),f,m=core.DomUtils;this.getNode=function(){return h};this.getAnchorNode=function(){return n.parentNode?n:h};this.getSelectedRange=function(){f?(q.setStartBefore(h),q.collapse(!0)):(q.setStartAfter(r?n:h),q.setEndBefore(r?h:n));return q};this.setSelectedRange=
function(a,c){q&&q!==a&&q.detach();q=a;r=!1!==c;(f=a.collapsed)?(d(n),d(h),b(h,a.startContainer,a.startOffset)):(d(n),d(h),b(r?h:n,a.endContainer,a.endOffset),b(r?n:h,a.startContainer,a.startOffset));p.forEach(m.normalizeTextNodes);p.length=0};this.hasForwardSelection=function(){return r};this.remove=function(){d(h);p.forEach(m.normalizeTextNodes);p.length=0};h.setAttributeNS("urn:webodf:names:cursor","memberId",l);n.setAttributeNS("urn:webodf:names:cursor","memberId",l)};core.Destroyable=function(){};
core.Destroyable.prototype.destroy=function(g){};core.EventSource=function(){};core.EventSource.prototype.subscribe=function(g,l){};core.EventSource.prototype.unsubscribe=function(g,l){};
core.EventNotifier=function(g){function l(b){runtime.assert(!d.hasOwnProperty(b),'Duplicated event ids: "'+b+'" registered more than once.');d[b]=[]}var d={};this.emit=function(b,h){var n,g;runtime.assert(d.hasOwnProperty(b),'unknown event fired "'+b+'"');g=d[b];for(n=0;n<g.length;n+=1)g[n](h)};this.subscribe=function(b,h){runtime.assert(d.hasOwnProperty(b),'tried to subscribe to unknown event "'+b+'"');d[b].push(h)};this.unsubscribe=function(b,h){var n;runtime.assert(d.hasOwnProperty(b),'tried to unsubscribe from unknown event "'+
b+'"');n=d[b].indexOf(h);runtime.assert(-1!==n,'tried to unsubscribe unknown callback from event "'+b+'"');-1!==n&&d[b].splice(n,1)};this.register=l;g&&g.forEach(l)};
core.ScheduledTask=function(g,l,d){function b(){r&&(d(n),r=!1)}function h(){b();g.apply(void 0,p);p=null}var n,r=!1,p=[],q=!1;this.trigger=function(){runtime.assert(!1===q,"Can't trigger destroyed ScheduledTask instance");p=Array.prototype.slice.call(arguments);r||(r=!0,n=l(h))};this.triggerImmediate=function(){runtime.assert(!1===q,"Can't trigger destroyed ScheduledTask instance");p=Array.prototype.slice.call(arguments);h()};this.processRequests=function(){r&&h()};this.cancel=b;this.restart=function(){runtime.assert(!1===
q,"Can't trigger destroyed ScheduledTask instance");b();r=!0;n=l(h)};this.destroy=function(d){b();q=!0;d()}};
(function(){var g;core.Task={};core.Task.SUPPRESS_MANUAL_PROCESSING=!1;core.Task.processTasks=function(){core.Task.SUPPRESS_MANUAL_PROCESSING||g.performRedraw()};core.Task.createRedrawTask=function(l){return new core.ScheduledTask(l,g.requestRedrawTask,g.cancelRedrawTask)};core.Task.createTimeoutTask=function(g,d){return new core.ScheduledTask(g,function(b){return runtime.setTimeout(b,d)},runtime.clearTimeout)};g=new function(){var g={};this.requestRedrawTask=function(d){var b=runtime.requestAnimationFrame(function(){d();
delete g[b]});g[b]=d;return b};this.performRedraw=function(){Object.keys(g).forEach(function(d){g[d]();runtime.cancelAnimationFrame(parseInt(d,10))});g={}};this.cancelRedrawTask=function(d){runtime.cancelAnimationFrame(d);delete g[d]}}})();
core.EventSubscriptions=function(){function g(b,h,g){b.subscribe(h,g);d.push({eventSource:b,eventid:h,callback:g})}function l(){var g=[];d.forEach(function(b){b.eventSource.unsubscribe(b.eventid,b.callback)});d.length=0;Object.keys(h).forEach(function(b){h[b].forEach(function(b){g.push(b.task.destroy)});delete h[b]});core.Async.destroyAll(g,function(){});b=new core.EventNotifier}var d=[],b=new core.EventNotifier,h={},n=0;this.addSubscription=g;this.addFrameSubscription=function(d,p,l){var f,m,a,c;
h.hasOwnProperty(p)||(h[p]=[]);a=h[p];for(c=0;c<a.length;c+=1)if(a[c].eventSource===d){f=a[c];break}f||(m="s"+n,n+=1,b.register(m),f={frameEventId:m,eventSource:d,task:core.Task.createRedrawTask(function(){b.emit(m,void 0)})},a.push(f),g(d,p,f.task.trigger));b.subscribe(f.frameEventId,l)};this.unsubscribeAll=l;this.destroy=function(b){l();b()}};core.LazyProperty=function(g){var l,d=!1;this.value=function(){d||(l=g(),d=!0);return l};this.reset=function(){d=!1}};
core.LoopWatchDog=function(g,l){var d=Date.now(),b=0;this.check=function(){var h;if(g&&(h=Date.now(),h-d>g))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0<l&&(b+=1,b>l))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}};core.NodeFilterChain=function(g){var l=NodeFilter.FILTER_REJECT,d=NodeFilter.FILTER_ACCEPT;this.acceptNode=function(b){var h;for(h=0;h<g.length;h+=1)if(g[h].acceptNode(b)===l)return l;return d}};
core.PositionIterator=function(g,l,d,b){function h(){this.acceptNode=function(a){return!a||a.nodeType===e&&0===a.length?u:x}}function n(a){this.acceptNode=function(c){return!c||c.nodeType===e&&0===c.length?u:a.acceptNode(c)}}function r(){var c=m.currentNode,b=c.nodeType;a=b===e?c.length-1:b===k?1:0}function p(){if(null===m.previousSibling()){if(!m.parentNode()||m.currentNode===g)return m.firstChild(),!1;a=0}else r();return!0}function q(){var b=m.currentNode,d;d=c(b);if(b!==g)for(b=b.parentNode;b&&
b!==g;)c(b)===u&&(m.currentNode=b,d=u),b=b.parentNode;d===u?(a=m.currentNode.nodeType===e?b.length:1,b=f.nextPosition()):b=d===x?!0:f.nextPosition();b&&runtime.assert(c(m.currentNode)===x,"moveToAcceptedNode did not result in walker being on an accepted node");return b}var f=this,m,a,c,e=Node.TEXT_NODE,k=Node.ELEMENT_NODE,x=NodeFilter.FILTER_ACCEPT,u=NodeFilter.FILTER_REJECT;this.nextPosition=function(){var c=m.currentNode,b=c.nodeType;if(c===g)return!1;if(0===a&&b===k)null===m.firstChild()&&(a=1);
else if(b===e&&a+1<c.length)a+=1;else if(null!==m.nextSibling())a=0;else if(m.parentNode())a=1;else return!1;return!0};this.previousPosition=function(){var c=!0,b=m.currentNode;0===a?c=p():b.nodeType===e?--a:null!==m.lastChild()?r():b===g?c=!1:a=0;return c};this.previousNode=p;this.container=function(){var c=m.currentNode,b=c.nodeType;0===a&&b!==e&&(c=c.parentNode);return c};this.rightNode=function(){var b=m.currentNode,d=b.nodeType;if(d===e&&a===b.length)for(b=b.nextSibling;b&&c(b)!==x;)b=b.nextSibling;
else d===k&&1===a&&(b=null);return b};this.leftNode=function(){var b=m.currentNode;if(0===a)for(b=b.previousSibling;b&&c(b)!==x;)b=b.previousSibling;else if(b.nodeType===k)for(b=b.lastChild;b&&c(b)!==x;)b=b.previousSibling;return b};this.getCurrentNode=function(){return m.currentNode};this.unfilteredDomOffset=function(){if(m.currentNode.nodeType===e)return a;for(var c=0,b=m.currentNode,b=1===a?b.lastChild:b.previousSibling;b;)c+=1,b=b.previousSibling;return c};this.getPreviousSibling=function(){var a=
m.currentNode,c=m.previousSibling();m.currentNode=a;return c};this.getNextSibling=function(){var a=m.currentNode,c=m.nextSibling();m.currentNode=a;return c};this.setPositionBeforeElement=function(c){runtime.assert(!!c,"setPositionBeforeElement called without element");m.currentNode=c;a=0;return q()};this.setUnfilteredPosition=function(c,b){runtime.assert(!!c,"PositionIterator.setUnfilteredPosition called without container");m.currentNode=c;c.nodeType===e?(a=b,runtime.assert(b<=c.length,"Error in setPosition: "+
b+" > "+c.length),runtime.assert(0<=b,"Error in setPosition: "+b+" < 0"),b===c.length&&(m.nextSibling()?a=0:m.parentNode()?a=1:runtime.assert(!1,"Error in setUnfilteredPosition: position not valid."))):b<c.childNodes.length?(m.currentNode=c.childNodes.item(b),a=0):a=1;return q()};this.moveToEnd=function(){m.currentNode=g;a=1};this.moveToEndOfNode=function(c){c.nodeType===e?f.setUnfilteredPosition(c,c.length):(m.currentNode=c,a=1)};this.isBeforeNode=function(){return 0===a};this.getNodeFilter=function(){return c};
c=(d?new n(d):new h).acceptNode;c.acceptNode=c;l=l||NodeFilter.SHOW_ALL;runtime.assert(g.nodeType!==Node.TEXT_NODE,"Internet Explorer doesn't allow tree walker roots to be text nodes");m=g.ownerDocument.createTreeWalker(g,l,c,b);a=0;null===m.firstChild()&&(a=1)};core.PositionFilter=function(){};core.PositionFilter.FilterResult={FILTER_ACCEPT:1,FILTER_REJECT:2,FILTER_SKIP:3};core.PositionFilter.prototype.acceptPosition=function(g){};
core.PositionFilterChain=function(){var g=[],l=core.PositionFilter.FilterResult.FILTER_ACCEPT,d=core.PositionFilter.FilterResult.FILTER_REJECT;this.acceptPosition=function(b){var h;for(h=0;h<g.length;h+=1)if(g[h].acceptPosition(b)===d)return d;return l};this.addFilter=function(b){g.push(b)}};core.StepDirection={PREVIOUS:1,NEXT:2};
core.StepIterator=function(g,l){function d(){a=null;e=c=void 0}function b(){void 0===e&&(e=g.acceptPosition(l)===f);return e}function h(a,c){d();return l.setUnfilteredPosition(a,c)}function n(){a||(a=l.container());return a}function r(){void 0===c&&(c=l.unfilteredDomOffset());return c}function p(){for(d();l.nextPosition();)if(d(),b())return!0;return!1}function q(){for(d();l.previousPosition();)if(d(),b())return!0;return!1}var f=core.PositionFilter.FilterResult.FILTER_ACCEPT,m=core.StepDirection.NEXT,
a,c,e;this.isStep=b;this.setPosition=h;this.container=n;this.offset=r;this.nextStep=p;this.previousStep=q;this.advanceStep=function(a){return a===m?p():q()};this.roundToClosestStep=function(){var a,c,e=b();e||(a=n(),c=r(),e=q(),e||(h(a,c),e=p()));return e};this.roundToPreviousStep=function(){var a=b();a||(a=q());return a};this.roundToNextStep=function(){var a=b();a||(a=p());return a};this.leftNode=function(){return l.leftNode()};this.snapshot=function(){return new core.StepIterator.StepSnapshot(n(),
r())};this.restore=function(a){h(a.container,a.offset)}};core.StepIterator.StepSnapshot=function(g,l){this.container=g;this.offset=l};
core.Utils=function(){function g(l,d){if(d&&Array.isArray(d)){l=l||[];if(!Array.isArray(l))throw"Destination is not an array.";l=l.concat(d.map(function(b){return g(null,b)}))}else if(d&&"object"===typeof d){l=l||{};if("object"!==typeof l)throw"Destination is not an object.";Object.keys(d).forEach(function(b){l[b]=g(l[b],d[b])})}else l=d;return l}this.hashString=function(g){var d=0,b,h;b=0;for(h=g.length;b<h;b+=1)d=(d<<5)-d+g.charCodeAt(b),d|=0;return d};this.mergeObjects=function(l,d){Object.keys(d).forEach(function(b){l[b]=
g(l[b],d[b])});return l}};
core.Zip=function(g,l){function d(b,d){var a=p.file(b);a?d(null,a.asUint8Array()):d(b+" not found.",null)}function b(b,m){d(b,function(a,c){if(a||null===c)return m(a,null);var b=runtime.byteArrayToString(c,"utf8");m(null,b)})}function h(b,d){try{b(p.generate({type:"uint8array",compression:"STORE"}))}catch(a){d(a.message)}}function n(b,d){h(function(a){runtime.writeFile(b,a,d)},d)}var r=this,p,q=new core.Base64;this.load=d;this.save=function(b,d,a,c){p.file(b,d,{date:c,compression:a?"DEFLATE":"STORE"})};
this.remove=function(b){var d=null!==p.file(b);p.remove(b);return d};this.write=function(b){n(g,b)};this.writeAs=n;this.createByteArray=h;this.loadContentXmlAsFragments=function(d,m){b(d,function(a,c){if(a)return m.rootElementReady(a);m.rootElementReady(null,c,!0)})};this.loadAsString=b;this.loadAsDOM=function(d,m){b(d,function(a,c){if(a||null===c)m(a,null);else{var b=(new DOMParser).parseFromString(c,"text/xml");m(null,b)}})};this.loadAsDataURL=function(b,m,a){d(b,function(c,b){if(c||!b)return a(c,
null);var d=0,e;m||(m=80===b[1]&&78===b[2]&&71===b[3]?"image/png":255===b[0]&&216===b[1]&&255===b[2]?"image/jpeg":71===b[0]&&73===b[1]&&70===b[2]?"image/gif":"");for(e="data:"+m+";base64,";d<b.length;)e+=q.convertUTF8ArrayToBase64(b.subarray(d,Math.min(d+45E3,b.length))),d+=45E3;a(null,e)})};this.getEntries=function(){return Object.keys(p.files).map(function(b){return{filename:b,date:p.files[b].date}})};p=new externs.JSZip;null!==l&&runtime.readFile(g,"binary",function(b,d){"string"===typeof d&&(b=
"file was read as a string. Should be Uint8Array.");if(b||!d||0===d.length)l("File '"+g+"' cannot be read. Err: "+(b||"[none]"),r);else try{p.load(d,{checkCRC32:!1}),l(null,r)}catch(a){l(a.message,r)}})};core.SimpleClientRect=null;gui.CommonConstraints={EDIT:{ANNOTATIONS:{ONLY_DELETE_OWN:"onlyDeleteOwn"},REVIEW_MODE:"reviewMode"}};
gui.SessionConstraints=function(){function g(b){l.hasOwnProperty(b)||(l[b]=!1,d.register(b))}var l={},d=new core.EventNotifier;this.registerConstraint=g;this.subscribe=function(b,h){g(b);d.subscribe(b,h)};this.unsubscribe=function(b,h){d.unsubscribe(b,h)};this.setState=function(b,h){runtime.assert(!0===l.hasOwnProperty(b),"No such constraint");l[b]!==h&&(l[b]=h,d.emit(b,h))};this.getState=function(b){runtime.assert(!0===l.hasOwnProperty(b),"No such constraint");return l[b]}};
gui.BlacklistNamespaceNodeFilter=function(g){var l={},d=NodeFilter.FILTER_REJECT,b=NodeFilter.FILTER_ACCEPT;this.acceptNode=function(h){return!h||l.hasOwnProperty(h.namespaceURI)?d:b};(function(){g.forEach(function(b){l[b]=!0})})()};
odf.Namespaces={namespaceMap:{config:"urn:oasis:names:tc:opendocument:xmlns:config:1.0",db:"urn:oasis:names:tc:opendocument:xmlns:database:1.0",dc:"http://purl.org/dc/elements/1.1/",dr3d:"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0",draw:"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0",chart:"urn:oasis:names:tc:opendocument:xmlns:chart:1.0",fo:"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0",form:"urn:oasis:names:tc:opendocument:xmlns:form:1.0",math:"http://www.w3.org/1998/Math/MathML",
meta:"urn:oasis:names:tc:opendocument:xmlns:meta:1.0",number:"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0",office:"urn:oasis:names:tc:opendocument:xmlns:office:1.0",presentation:"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0",style:"urn:oasis:names:tc:opendocument:xmlns:style:1.0",svg:"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0",table:"urn:oasis:names:tc:opendocument:xmlns:table:1.0",text:"urn:oasis:names:tc:opendocument:xmlns:text:1.0",xforms:"http://www.w3.org/2002/xforms",
xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},prefixMap:{},configns:"urn:oasis:names:tc:opendocument:xmlns:config:1.0",dbns:"urn:oasis:names:tc:opendocument:xmlns:database:1.0",dcns:"http://purl.org/dc/elements/1.1/",dr3dns:"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0",drawns:"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0",chartns:"urn:oasis:names:tc:opendocument:xmlns:chart:1.0",fons:"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0",formns:"urn:oasis:names:tc:opendocument:xmlns:form:1.0",
mathns:"http://www.w3.org/1998/Math/MathML",metans:"urn:oasis:names:tc:opendocument:xmlns:meta:1.0",numberns:"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0",officens:"urn:oasis:names:tc:opendocument:xmlns:office:1.0",presentationns:"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0",stylens:"urn:oasis:names:tc:opendocument:xmlns:style:1.0",svgns:"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0",tablens:"urn:oasis:names:tc:opendocument:xmlns:table:1.0",textns:"urn:oasis:names:tc:opendocument:xmlns:text:1.0",
xformsns:"http://www.w3.org/2002/xforms",xlinkns:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/XML/1998/namespace"};(function(){var g=odf.Namespaces.namespaceMap,l=odf.Namespaces.prefixMap,d;for(d in g)g.hasOwnProperty(d)&&(l[g[d]]=d)})();odf.Namespaces.forEachPrefix=function(g){var l=odf.Namespaces.namespaceMap,d;for(d in l)l.hasOwnProperty(d)&&g(d,l[d])};
odf.Namespaces.lookupNamespaceURI=function(g){var l=null;odf.Namespaces.namespaceMap.hasOwnProperty(g)&&(l=odf.Namespaces.namespaceMap[g]);return l};odf.Namespaces.lookupPrefix=function(g){var l=odf.Namespaces.prefixMap;return l.hasOwnProperty(g)?l[g]:null};odf.Namespaces.lookupNamespaceURI.lookupNamespaceURI=odf.Namespaces.lookupNamespaceURI;
(function(){odf.OdfSchemaImpl=function(){var g=[["config:config-item","uncategorized"],["form:item","object"],["form:option","uncategorized"],["math:math","field"],["meta:user-defined","uncategorized"],["number:currency-symbol","uncategorized"],["number:embedded-text","uncategorized"],["number:text","uncategorized"],["presentation:date-time-decl","uncategorized"],["presentation:footer-decl","uncategorized"],["presentation:header-decl","uncategorized"],["svg:desc","text"],["svg:title","text"],["table:desc",
"uncategorized"],["table:title","uncategorized"],["text:a","text"],["text:author-initials","field"],["text:author-name","field"],["text:bibliography-mark","field"],["text:bookmark-ref","field"],["text:chapter","field"],["text:character-count","field"],["text:conditional-text","field"],["text:creation-date","field"],["text:creation-time","field"],["text:creator","field"],["text:database-display","field"],["text:database-name","field"],["text:database-row-number","field"],["text:date","field"],["text:dde-connection",
"field"],["text:description","field"],["text:editing-cycles","field"],["text:editing-duration","field"],["text:execute-macro","uncategorized"],["text:expression","uncategorized"],["text:file-name","field"],["text:h","text"],["text:hidden-paragraph","text"],["text:hidden-text","text"],["text:image-count","field"],["text:index-entry-span","uncategorized"],["text:index-title-template","uncategorized"],["text:initial-creator","field"],["text:keywords","field"],["text:linenumbering-separator","style"],
["text:measure","uncategorized"],["text:meta","uncategorized"],["text:meta-field","uncategorized"],["text:modification-date","field"],["text:modification-time","field"],["text:note-citation","field"],["text:note-continuation-notice-backward","style"],["text:note-continuation-notice-forward","style"],["text:note-ref","field"],["text:object-count","field"],["text:p","text"],["text:page-continuation","uncategorized"],["text:page-count","field"],["text:page-number","field"],["text:page-variable-get",
"field"],["text:page-variable-set","field"],["text:paragraph-count","field"],["text:placeholder","field"],["text:print-date","field"],["text:print-time","field"],["text:printed-by","field"],["text:reference-ref","field"],["text:ruby-base","text"],["text:ruby-text","text"],["text:script","text"],["text:sender-city","field"],["text:sender-company","field"],["text:sender-country","field"],["text:sender-email","field"],["text:sender-fax","field"],["text:sender-firstname","field"],["text:sender-initials",
"field"],["text:sender-lastname","field"],["text:sender-phone-private","field"],["text:sender-phone-work","field"],["text:sender-position","field"],["text:sender-postal-code","field"],["text:sender-state-or-province","field"],["text:sender-street","field"],["text:sender-title","field"],["text:sequence","uncategorized"],["text:sequence-ref","uncategorized"],["text:sheet-name","uncategorized"],["text:span","text"],["text:subject","field"],["text:table-count","field"],["text:table-formula","deprecated"],
["text:template-name","uncategorized"],["text:text-input","field"],["text:time","field"],["text:title","field"],["text:user-defined","field"],["text:user-field-get","field"],["text:user-field-input","field"],["text:variable-get","field"],["text:variable-input","field"],["text:variable-set","field"],["text:word-count","field"],["xforms:model","uncategorized"]],l={};this.isTextContainer=function(d,b){return"text"===l[d+":"+b]};this.isField=function(d,b){return"field"===l[d+":"+b]};this.getFields=function(){return g.filter(function(d){return"field"===
d[1]}).map(function(d){return d[0]})};(function(){g.forEach(function(d){var b=d[1],h=d[0].split(":");d=h[0];var h=h[1],g=odf.Namespaces.lookupNamespaceURI(d);g?l[g+":"+h]=b:runtime.log("DEBUG: OdfSchema - unknown prefix '"+d+"'")})})()};odf.OdfSchema=new odf.OdfSchemaImpl})();
odf.OdfUtilsImpl=function(){function g(a){return"image"===(a&&a.localName)&&a.namespaceURI===T}function l(a){return null!==a&&a.nodeType===Node.ELEMENT_NODE&&"frame"===a.localName&&a.namespaceURI===T&&"as-char"===a.getAttributeNS(N,"anchor-type")}function d(a){var c;(c="annotation"===(a&&a.localName)&&a.namespaceURI===odf.Namespaces.officens)||(c="div"===(a&&a.localName)&&"annotationWrapper"===a.className);return c}function b(a){return"a"===(a&&a.localName)&&a.namespaceURI===N}function h(a){var c=
a&&a.localName;return("p"===c||"h"===c)&&a.namespaceURI===N}function n(a,c){for(a&&void 0!==c&&!h(a)&&a.childNodes.item(c)&&(a=a.childNodes.item(c));a&&!h(a);)a=a.parentNode;return a}function r(a,c){for(;a&&a!==c;){if(a.namespaceURI===odf.Namespaces.officens&&"annotation"===a.localName)return a;a=a.parentNode}return null}function p(a){return/^[ \t\r\n]+$/.test(a)}function q(a){if(null===a||a.nodeType!==Node.ELEMENT_NODE)return!1;var c=a.localName;return ea.isTextContainer(a.namespaceURI,c)||"span"===
c&&"webodf-annotationHighlight"===a.className}function f(a){return null===a||a.nodeType!==Node.ELEMENT_NODE?!1:ea.isField(a.namespaceURI,a.localName)}function m(a){var c=a&&a.localName,b=!1;c&&(a=a.namespaceURI,a===N&&(b="s"===c||"tab"===c||"line-break"===c));return b}function a(a){return m(a)||f(a)||l(a)||d(a)}function c(a){var c=a&&a.localName,b=!1;c&&(a=a.namespaceURI,a===N&&(b="s"===c));return b}function e(a){return-1!==O.indexOf(a.namespaceURI)}function k(a){if(m(a)||f(a))return!1;if(q(a.parentNode)&&
a.nodeType===Node.TEXT_NODE)return 0===a.textContent.length;for(a=a.firstChild;a;){if(e(a)||!k(a))return!1;a=a.nextSibling}return!0}function x(a){for(;null!==a.firstChild&&q(a);)a=a.firstChild;return a}function u(a){for(;null!==a.lastChild&&q(a);)a=a.lastChild;return a}function y(a){for(;!h(a)&&null===a.previousSibling;)a=a.parentNode;return h(a)?null:u(a.previousSibling)}function w(a){for(;!h(a)&&null===a.nextSibling;)a=a.parentNode;return h(a)?null:x(a.nextSibling)}function z(b){for(var d=!1;b;)if(b.nodeType===
Node.TEXT_NODE)if(0===b.length)b=y(b);else return!p(b.data.substr(b.length-1,1));else a(b)?(d=!1===c(b),b=null):b=y(b);return d}function t(c){var b=!1,d;for(c=c&&x(c);c;){d=c.nodeType===Node.TEXT_NODE?c.length:0;if(0<d&&!p(c.data)){b=!0;break}if(a(c)){b=!0;break}c=w(c)}return b}function v(a,c){return p(a.data.substr(c))?!t(w(a)):!1}function B(c,b){var d=c.data,e;if(!p(d[b])||a(c.parentNode))return!1;0<b?p(d[b-1])||(e=!0):z(y(c))&&(e=!0);return!0===e?v(c,b)?!1:!0:!1}function J(a){return(a=/(-?[0-9]*[0-9][0-9]*(\.[0-9]*)?|0+\.[0-9]*[1-9][0-9]*|\.[0-9]*[1-9][0-9]*)((cm)|(mm)|(in)|(pt)|(pc)|(px)|(%))/.exec(a))?
{value:parseFloat(a[1]),unit:a[3]}:null}function H(a){return(a=J(a))&&(0>a.value||"%"===a.unit)?null:a}function K(a){return(a=J(a))&&"%"!==a.unit?null:a}function U(a){switch(a.namespaceURI){case odf.Namespaces.drawns:case odf.Namespaces.svgns:case odf.Namespaces.dr3dns:return!1;case odf.Namespaces.textns:switch(a.localName){case "note-body":case "ruby-text":return!1}break;case odf.Namespaces.officens:switch(a.localName){case "annotation":case "binary-data":case "event-listeners":return!1}break;default:switch(a.localName){case "cursor":case "editinfo":return!1}}return!0}
function L(a){return!(!n(a)||p(a.textContent)&&!B(a,0))}function Q(a,c){for(;0<c.length&&!aa.rangeContainsNode(a,c[0]);)c.shift();for(;0<c.length&&!aa.rangeContainsNode(a,c[c.length-1]);)c.pop()}function C(c,b,e){var k;k=aa.getNodesInRange(c,function(c){var b=NodeFilter.FILTER_REJECT;if(m(c.parentNode)||f(c.parentNode)||d(c))b=NodeFilter.FILTER_REJECT;else if(c.nodeType===Node.TEXT_NODE){if(e||L(c))b=NodeFilter.FILTER_ACCEPT}else if(a(c))b=NodeFilter.FILTER_ACCEPT;else if(U(c)||q(c))b=NodeFilter.FILTER_SKIP;
return b},NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);b||Q(c,k);return k}function V(a,c,b){for(;a;){if(b(a)){c[0]!==a&&c.unshift(a);break}if(d(a))break;a=a.parentNode}}function M(a,c){var b=a;if(c<b.childNodes.length-1)b=b.childNodes[c+1];else{for(;!b.nextSibling;)b=b.parentNode;b=b.nextSibling}for(;b.firstChild;)b=b.firstChild;return b}var N=odf.Namespaces.textns,T=odf.Namespaces.drawns,F=odf.Namespaces.xlinkns,aa=core.DomUtils,O=[odf.Namespaces.dbns,odf.Namespaces.dcns,odf.Namespaces.dr3dns,odf.Namespaces.drawns,
odf.Namespaces.chartns,odf.Namespaces.formns,odf.Namespaces.numberns,odf.Namespaces.officens,odf.Namespaces.presentationns,odf.Namespaces.stylens,odf.Namespaces.svgns,odf.Namespaces.tablens,odf.Namespaces.textns],ea=odf.OdfSchema;this.isImage=g;this.isCharacterFrame=l;this.isInlineRoot=d;this.isTextSpan=function(a){return"span"===(a&&a.localName)&&a.namespaceURI===N};this.isHyperlink=b;this.getHyperlinkTarget=function(a){return a.getAttributeNS(F,"href")||""};this.isParagraph=h;this.getParagraphElement=
n;this.getParentAnnotation=r;this.isWithinAnnotation=function(a,c){return!!r(a,c)};this.getAnnotationCreator=function(a){return a.getElementsByTagNameNS(odf.Namespaces.dcns,"creator")[0].textContent};this.isListItem=function(a){return"list-item"===(a&&a.localName)&&a.namespaceURI===N};this.isLineBreak=function(a){return"line-break"===(a&&a.localName)&&a.namespaceURI===N};this.isODFWhitespace=p;this.isGroupingElement=q;this.isFieldElement=f;this.isCharacterElement=m;this.isAnchoredAsCharacterElement=
a;this.isSpaceElement=c;this.isODFNode=e;this.hasNoODFContent=k;this.firstChild=x;this.lastChild=u;this.previousNode=y;this.nextNode=w;this.scanLeftForNonSpace=z;this.lookLeftForCharacter=function(c){var b,d=b=0;c.nodeType===Node.TEXT_NODE&&(d=c.length);0<d?(b=c.data,b=p(b.substr(d-1,1))?1===d?z(y(c))?2:0:p(b.substr(d-2,1))?0:2:1):a(c)&&(b=1);return b};this.lookRightForCharacter=function(c){var b=!1,d=0;c&&c.nodeType===Node.TEXT_NODE&&(d=c.length);0<d?b=!p(c.data.substr(0,1)):a(c)&&(b=!0);return b};
this.scanLeftForAnyCharacter=function(c){var b=!1,d;for(c=c&&u(c);c;){d=c.nodeType===Node.TEXT_NODE?c.length:0;if(0<d&&!p(c.data)){b=!0;break}if(a(c)){b=!0;break}c=y(c)}return b};this.scanRightForAnyCharacter=t;this.isTrailingWhitespace=v;this.isSignificantWhitespace=B;this.isDowngradableSpaceElement=function(a){return c(a)?z(y(a))&&t(w(a)):!1};this.parseLength=J;this.parseNonNegativeLength=H;this.parseFoFontSize=function(a){var c;c=(c=J(a))&&(0>=c.value||"%"===c.unit)?null:c;return c||K(a)};this.parseFoLineHeight=
function(a){return H(a)||K(a)};this.isTextContentContainingNode=U;this.getTextNodes=function(a,c){var b;b=aa.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_REJECT;a.nodeType===Node.TEXT_NODE?L(a)&&(c=NodeFilter.FILTER_ACCEPT):U(a)&&(c=NodeFilter.FILTER_SKIP);return c},NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);c||Q(a,b);return b};this.getTextElements=C;this.getParagraphElements=function(a){var c;c=aa.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_REJECT;if(h(a))c=NodeFilter.FILTER_ACCEPT;
else if(U(a)||q(a))c=NodeFilter.FILTER_SKIP;return c},NodeFilter.SHOW_ELEMENT);V(a.startContainer,c,h);return c};this.getImageElements=function(a){var c;c=aa.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_SKIP;g(a)&&(c=NodeFilter.FILTER_ACCEPT);return c},NodeFilter.SHOW_ELEMENT);V(a.startContainer,c,g);return c};this.getHyperlinkElements=function(a){var c=[],d=a.cloneRange();a.collapsed&&a.endContainer.nodeType===Node.ELEMENT_NODE&&(a=M(a.endContainer,a.endOffset),a.nodeType===Node.TEXT_NODE&&
d.setEnd(a,1));C(d,!0,!1).forEach(function(a){for(a=a.parentNode;!h(a);){if(b(a)&&-1===c.indexOf(a)){c.push(a);break}a=a.parentNode}});d.detach();return c};this.getNormalizedFontFamilyName=function(a){/^(["'])(?:.|[\n\r])*?\1$/.test(a)||(a=a.replace(/^[ \t\r\n\f]*((?:.|[\n\r])*?)[ \t\r\n\f]*$/,"$1"),/[ \t\r\n\f]/.test(a)&&(a="'"+a.replace(/[ \t\r\n\f]+/g," ")+"'"));return a}};odf.OdfUtils=new odf.OdfUtilsImpl;
gui.OdfTextBodyNodeFilter=function(){var g=odf.OdfUtils,l=Node.TEXT_NODE,d=NodeFilter.FILTER_REJECT,b=NodeFilter.FILTER_ACCEPT,h=odf.Namespaces.textns;this.acceptNode=function(n){if(n.nodeType===l){if(!g.isGroupingElement(n.parentNode))return d}else if(n.namespaceURI===h&&"tracked-changes"===n.localName)return d;return b}};xmldom.LSSerializerFilter=function(){};xmldom.LSSerializerFilter.prototype.acceptNode=function(g){};
odf.OdfNodeFilter=function(){this.acceptNode=function(g){return"http://www.w3.org/1999/xhtml"===g.namespaceURI?NodeFilter.FILTER_SKIP:g.namespaceURI&&g.namespaceURI.match(/^urn:webodf:/)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}};xmldom.XPathIterator=function(){};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){};
function createXPathSingleton(){function g(b,a,c){return-1!==b&&(b<a||-1===a)&&(b<c||-1===c)}function l(b){for(var a=[],c=0,d=b.length,k;c<d;){var m=b,h=d,n=a,p,l=[],r=m.indexOf("[",c),q=m.indexOf("/",c),B=m.indexOf("=",c);g(q,r,B)?(p=m.substring(c,q),c=q+1):g(r,q,B)?(p=m.substring(c,r),c=f(m,r,l)):g(B,q,r)?(p=m.substring(c,B),c=B):(p=m.substring(c,h),c=h);n.push({location:p,predicates:l});if(c<d&&"="===b[c]){k=b.substring(c+1,d);if(2<k.length&&("'"===k[0]||'"'===k[0]))k=k.slice(1,k.length-1);else try{k=
parseInt(k,10)}catch(J){}c=d}}return{steps:a,value:k}}function d(){var b=null,a=!1;this.setNode=function(a){b=a};this.reset=function(){a=!1};this.next=function(){var c=a?null:b;a=!0;return c}}function b(b,a,c){this.reset=function(){b.reset()};this.next=function(){for(var d=b.next();d;){d.nodeType===Node.ELEMENT_NODE&&(d=d.getAttributeNodeNS(a,c));if(d)break;d=b.next()}return d}}function h(b,a){var c=b.next(),d=null;this.reset=function(){b.reset();c=b.next();d=null};this.next=function(){for(;c;){if(d)if(a&&
d.firstChild)d=d.firstChild;else{for(;!d.nextSibling&&d!==c;)d=d.parentNode;d===c?c=b.next():d=d.nextSibling}else{do(d=c.firstChild)||(c=b.next());while(c&&!d)}if(d&&d.nodeType===Node.ELEMENT_NODE)return d}return null}}function n(b,a){this.reset=function(){b.reset()};this.next=function(){for(var c=b.next();c&&!a(c);)c=b.next();return c}}function r(b,a,c){a=a.split(":",2);var d=c(a[0]),k=a[1];return new n(b,function(a){return a.localName===k&&a.namespaceURI===d})}function p(b,a,c){var e=new d,k=q(e,
a,c),m=a.value;return void 0===m?new n(b,function(a){e.setNode(a);k.reset();return null!==k.next()}):new n(b,function(a){e.setNode(a);k.reset();return(a=k.next())?a.nodeValue===m:!1})}var q,f;f=function(b,a,c){for(var d=a,k=b.length,m=0;d<k;)"]"===b[d]?(--m,0>=m&&c.push(l(b.substring(a,d)))):"["===b[d]&&(0>=m&&(a=d+1),m+=1),d+=1;return d};q=function(d,a,c){var e,k,f,m;for(e=0;e<a.steps.length;e+=1){f=a.steps[e];k=f.location;if(""===k)d=new h(d,!1);else if("@"===k[0]){k=k.substr(1).split(":",2);m=
c(k[0]);if(!m)throw"No namespace associated with the prefix "+k[0];d=new b(d,m,k[1])}else"."!==k&&(d=new h(d,!1),-1!==k.indexOf(":")&&(d=r(d,k,c)));for(k=0;k<f.predicates.length;k+=1)m=f.predicates[k],d=p(d,m,c)}return d};return{getODFElementsWithXPath:function(b,a,c){var e=b.ownerDocument,k=[];if(e&&"function"===typeof e.evaluate)for(c=e.evaluate(a,b,c,XPathResult.UNORDERED_NODE_ITERATOR_TYPE,null),b=c.iterateNext();null!==b;)b.nodeType===Node.ELEMENT_NODE&&k.push(b),b=c.iterateNext();else{k=new d;
k.setNode(b);b=l(a);k=q(k,b,c);b=[];for(c=k.next();c;)b.push(c),c=k.next();k=b}return k}}}xmldom.XPath=createXPathSingleton();
odf.StyleInfo=function(){function g(a,c){var b,d,e,k,f,m=0;if(b=H[a.localName])if(e=b[a.namespaceURI])m=e.length;for(b=0;b<m;b+=1)d=e[b],k=d.ns,f=d.localname,(d=a.getAttributeNS(k,f))&&a.setAttributeNS(k,B[k]+f,c+d);for(e=a.firstElementChild;e;)g(e,c),e=e.nextElementSibling}function l(a,c){var b,d,e,k,f,m=0;if(b=H[a.localName])if(e=b[a.namespaceURI])m=e.length;for(b=0;b<m;b+=1)if(d=e[b],k=d.ns,f=d.localname,d=a.getAttributeNS(k,f))d=d.replace(c,""),a.setAttributeNS(k,B[k]+f,d);for(e=a.firstElementChild;e;)l(e,
c),e=e.nextElementSibling}function d(a,c){var b,d,e,k,f,m=0;if(b=H[a.localName])if(e=b[a.namespaceURI])m=e.length;for(b=0;b<m;b+=1)if(k=e[b],d=k.ns,f=k.localname,d=a.getAttributeNS(d,f))c=c||{},k=k.keyname,c.hasOwnProperty(k)?c[k][d]=1:(f={},f[d]=1,c[k]=f);return c}function b(a,c){var e,k;d(a,c);for(e=a.firstChild;e;)e.nodeType===Node.ELEMENT_NODE&&(k=e,b(k,c)),e=e.nextSibling}function h(a,c,b){this.key=a;this.name=c;this.family=b;this.requires={}}function n(a,c,b){var d=a+'"'+c,e=b[d];e||(e=b[d]=
new h(d,a,c));return e}function r(a,c,b){var d,e,k,f,m,h=0;d=a.getAttributeNS(z,"name");f=a.getAttributeNS(z,"family");d&&f&&(c=n(d,f,b));if(c){if(d=H[a.localName])if(k=d[a.namespaceURI])h=k.length;for(d=0;d<h;d+=1)if(f=k[d],e=f.ns,m=f.localname,e=a.getAttributeNS(e,m))f=f.keyname,f=n(e,f,b),c.requires[f.key]=f}for(a=a.firstElementChild;a;)r(a,c,b),a=a.nextElementSibling;return b}function p(a,c){var b=c[a.family];b||(b=c[a.family]={});b[a.name]=1;Object.keys(a.requires).forEach(function(b){p(a.requires[b],
c)})}function q(a,c){var b=r(a,null,{});Object.keys(b).forEach(function(a){a=b[a];var d=c[a.family];d&&d.hasOwnProperty(a.name)&&p(a,c)})}function f(a,c){function b(c){(c=k.getAttributeNS(z,c))&&(a[c]=!0)}var d=["font-name","font-name-asian","font-name-complex"],e,k;for(e=c&&c.firstElementChild;e;)k=e,d.forEach(b),f(a,k),e=e.nextElementSibling}function m(a,c){function b(a){var b=k.getAttributeNS(z,a);b&&c.hasOwnProperty(b)&&k.setAttributeNS(z,"style:"+a,c[b])}var d=["font-name","font-name-asian",
"font-name-complex"],e,k;for(e=a&&a.firstElementChild;e;)k=e,d.forEach(b),m(k,c),e=e.nextElementSibling}var a=odf.Namespaces.chartns,c=odf.Namespaces.dbns,e=odf.Namespaces.dr3dns,k=odf.Namespaces.drawns,x=odf.Namespaces.formns,u=odf.Namespaces.numberns,y=odf.Namespaces.officens,w=odf.Namespaces.presentationns,z=odf.Namespaces.stylens,t=odf.Namespaces.tablens,v=odf.Namespaces.textns,B={"urn:oasis:names:tc:opendocument:xmlns:chart:1.0":"chart:","urn:oasis:names:tc:opendocument:xmlns:database:1.0":"db:",
"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0":"dr3d:","urn:oasis:names:tc:opendocument:xmlns:drawing:1.0":"draw:","urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0":"fo:","urn:oasis:names:tc:opendocument:xmlns:form:1.0":"form:","urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0":"number:","urn:oasis:names:tc:opendocument:xmlns:office:1.0":"office:","urn:oasis:names:tc:opendocument:xmlns:presentation:1.0":"presentation:","urn:oasis:names:tc:opendocument:xmlns:style:1.0":"style:","urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0":"svg:",
"urn:oasis:names:tc:opendocument:xmlns:table:1.0":"table:","urn:oasis:names:tc:opendocument:xmlns:text:1.0":"chart:","http://www.w3.org/XML/1998/namespace":"xml:"},J={text:[{ens:z,en:"tab-stop",ans:z,a:"leader-text-style"},{ens:z,en:"drop-cap",ans:z,a:"style-name"},{ens:v,en:"notes-configuration",ans:v,a:"citation-body-style-name"},{ens:v,en:"notes-configuration",ans:v,a:"citation-style-name"},{ens:v,en:"a",ans:v,a:"style-name"},{ens:v,en:"alphabetical-index",ans:v,a:"style-name"},{ens:v,en:"linenumbering-configuration",
ans:v,a:"style-name"},{ens:v,en:"list-level-style-number",ans:v,a:"style-name"},{ens:v,en:"ruby-text",ans:v,a:"style-name"},{ens:v,en:"span",ans:v,a:"style-name"},{ens:v,en:"a",ans:v,a:"visited-style-name"},{ens:z,en:"text-properties",ans:z,a:"text-line-through-text-style"},{ens:v,en:"alphabetical-index-source",ans:v,a:"main-entry-style-name"},{ens:v,en:"index-entry-bibliography",ans:v,a:"style-name"},{ens:v,en:"index-entry-chapter",ans:v,a:"style-name"},{ens:v,en:"index-entry-link-end",ans:v,a:"style-name"},
{ens:v,en:"index-entry-link-start",ans:v,a:"style-name"},{ens:v,en:"index-entry-page-number",ans:v,a:"style-name"},{ens:v,en:"index-entry-span",ans:v,a:"style-name"},{ens:v,en:"index-entry-tab-stop",ans:v,a:"style-name"},{ens:v,en:"index-entry-text",ans:v,a:"style-name"},{ens:v,en:"index-title-template",ans:v,a:"style-name"},{ens:v,en:"list-level-style-bullet",ans:v,a:"style-name"},{ens:v,en:"outline-level-style",ans:v,a:"style-name"}],paragraph:[{ens:k,en:"caption",ans:k,a:"text-style-name"},{ens:k,
en:"circle",ans:k,a:"text-style-name"},{ens:k,en:"connector",ans:k,a:"text-style-name"},{ens:k,en:"control",ans:k,a:"text-style-name"},{ens:k,en:"custom-shape",ans:k,a:"text-style-name"},{ens:k,en:"ellipse",ans:k,a:"text-style-name"},{ens:k,en:"frame",ans:k,a:"text-style-name"},{ens:k,en:"line",ans:k,a:"text-style-name"},{ens:k,en:"measure",ans:k,a:"text-style-name"},{ens:k,en:"path",ans:k,a:"text-style-name"},{ens:k,en:"polygon",ans:k,a:"text-style-name"},{ens:k,en:"polyline",ans:k,a:"text-style-name"},
{ens:k,en:"rect",ans:k,a:"text-style-name"},{ens:k,en:"regular-polygon",ans:k,a:"text-style-name"},{ens:y,en:"annotation",ans:k,a:"text-style-name"},{ens:x,en:"column",ans:x,a:"text-style-name"},{ens:z,en:"style",ans:z,a:"next-style-name"},{ens:t,en:"body",ans:t,a:"paragraph-style-name"},{ens:t,en:"even-columns",ans:t,a:"paragraph-style-name"},{ens:t,en:"even-rows",ans:t,a:"paragraph-style-name"},{ens:t,en:"first-column",ans:t,a:"paragraph-style-name"},{ens:t,en:"first-row",ans:t,a:"paragraph-style-name"},
{ens:t,en:"last-column",ans:t,a:"paragraph-style-name"},{ens:t,en:"last-row",ans:t,a:"paragraph-style-name"},{ens:t,en:"odd-columns",ans:t,a:"paragraph-style-name"},{ens:t,en:"odd-rows",ans:t,a:"paragraph-style-name"},{ens:v,en:"notes-configuration",ans:v,a:"default-style-name"},{ens:v,en:"alphabetical-index-entry-template",ans:v,a:"style-name"},{ens:v,en:"bibliography-entry-template",ans:v,a:"style-name"},{ens:v,en:"h",ans:v,a:"style-name"},{ens:v,en:"illustration-index-entry-template",ans:v,a:"style-name"},
{ens:v,en:"index-source-style",ans:v,a:"style-name"},{ens:v,en:"object-index-entry-template",ans:v,a:"style-name"},{ens:v,en:"p",ans:v,a:"style-name"},{ens:v,en:"table-index-entry-template",ans:v,a:"style-name"},{ens:v,en:"table-of-content-entry-template",ans:v,a:"style-name"},{ens:v,en:"table-index-entry-template",ans:v,a:"style-name"},{ens:v,en:"user-index-entry-template",ans:v,a:"style-name"},{ens:z,en:"page-layout-properties",ans:z,a:"register-truth-ref-style-name"}],chart:[{ens:a,en:"axis",ans:a,
a:"style-name"},{ens:a,en:"chart",ans:a,a:"style-name"},{ens:a,en:"data-label",ans:a,a:"style-name"},{ens:a,en:"data-point",ans:a,a:"style-name"},{ens:a,en:"equation",ans:a,a:"style-name"},{ens:a,en:"error-indicator",ans:a,a:"style-name"},{ens:a,en:"floor",ans:a,a:"style-name"},{ens:a,en:"footer",ans:a,a:"style-name"},{ens:a,en:"grid",ans:a,a:"style-name"},{ens:a,en:"legend",ans:a,a:"style-name"},{ens:a,en:"mean-value",ans:a,a:"style-name"},{ens:a,en:"plot-area",ans:a,a:"style-name"},{ens:a,en:"regression-curve",
ans:a,a:"style-name"},{ens:a,en:"series",ans:a,a:"style-name"},{ens:a,en:"stock-gain-marker",ans:a,a:"style-name"},{ens:a,en:"stock-loss-marker",ans:a,a:"style-name"},{ens:a,en:"stock-range-line",ans:a,a:"style-name"},{ens:a,en:"subtitle",ans:a,a:"style-name"},{ens:a,en:"title",ans:a,a:"style-name"},{ens:a,en:"wall",ans:a,a:"style-name"}],section:[{ens:v,en:"alphabetical-index",ans:v,a:"style-name"},{ens:v,en:"bibliography",ans:v,a:"style-name"},{ens:v,en:"illustration-index",ans:v,a:"style-name"},
{ens:v,en:"index-title",ans:v,a:"style-name"},{ens:v,en:"object-index",ans:v,a:"style-name"},{ens:v,en:"section",ans:v,a:"style-name"},{ens:v,en:"table-of-content",ans:v,a:"style-name"},{ens:v,en:"table-index",ans:v,a:"style-name"},{ens:v,en:"user-index",ans:v,a:"style-name"}],ruby:[{ens:v,en:"ruby",ans:v,a:"style-name"}],table:[{ens:c,en:"query",ans:c,a:"style-name"},{ens:c,en:"table-representation",ans:c,a:"style-name"},{ens:t,en:"background",ans:t,a:"style-name"},{ens:t,en:"table",ans:t,a:"style-name"}],
"table-column":[{ens:c,en:"column",ans:c,a:"style-name"},{ens:t,en:"table-column",ans:t,a:"style-name"}],"table-row":[{ens:c,en:"query",ans:c,a:"default-row-style-name"},{ens:c,en:"table-representation",ans:c,a:"default-row-style-name"},{ens:t,en:"table-row",ans:t,a:"style-name"}],"table-cell":[{ens:c,en:"column",ans:c,a:"default-cell-style-name"},{ens:t,en:"table-column",ans:t,a:"default-cell-style-name"},{ens:t,en:"table-row",ans:t,a:"default-cell-style-name"},{ens:t,en:"body",ans:t,a:"style-name"},
{ens:t,en:"covered-table-cell",ans:t,a:"style-name"},{ens:t,en:"even-columns",ans:t,a:"style-name"},{ens:t,en:"covered-table-cell",ans:t,a:"style-name"},{ens:t,en:"even-columns",ans:t,a:"style-name"},{ens:t,en:"even-rows",ans:t,a:"style-name"},{ens:t,en:"first-column",ans:t,a:"style-name"},{ens:t,en:"first-row",ans:t,a:"style-name"},{ens:t,en:"last-column",ans:t,a:"style-name"},{ens:t,en:"last-row",ans:t,a:"style-name"},{ens:t,en:"odd-columns",ans:t,a:"style-name"},{ens:t,en:"odd-rows",ans:t,a:"style-name"},
{ens:t,en:"table-cell",ans:t,a:"style-name"}],graphic:[{ens:e,en:"cube",ans:k,a:"style-name"},{ens:e,en:"extrude",ans:k,a:"style-name"},{ens:e,en:"rotate",ans:k,a:"style-name"},{ens:e,en:"scene",ans:k,a:"style-name"},{ens:e,en:"sphere",ans:k,a:"style-name"},{ens:k,en:"caption",ans:k,a:"style-name"},{ens:k,en:"circle",ans:k,a:"style-name"},{ens:k,en:"connector",ans:k,a:"style-name"},{ens:k,en:"control",ans:k,a:"style-name"},{ens:k,en:"custom-shape",ans:k,a:"style-name"},{ens:k,en:"ellipse",ans:k,a:"style-name"},
{ens:k,en:"frame",ans:k,a:"style-name"},{ens:k,en:"g",ans:k,a:"style-name"},{ens:k,en:"line",ans:k,a:"style-name"},{ens:k,en:"measure",ans:k,a:"style-name"},{ens:k,en:"page-thumbnail",ans:k,a:"style-name"},{ens:k,en:"path",ans:k,a:"style-name"},{ens:k,en:"polygon",ans:k,a:"style-name"},{ens:k,en:"polyline",ans:k,a:"style-name"},{ens:k,en:"rect",ans:k,a:"style-name"},{ens:k,en:"regular-polygon",ans:k,a:"style-name"},{ens:y,en:"annotation",ans:k,a:"style-name"}],presentation:[{ens:e,en:"cube",ans:w,
a:"style-name"},{ens:e,en:"extrude",ans:w,a:"style-name"},{ens:e,en:"rotate",ans:w,a:"style-name"},{ens:e,en:"scene",ans:w,a:"style-name"},{ens:e,en:"sphere",ans:w,a:"style-name"},{ens:k,en:"caption",ans:w,a:"style-name"},{ens:k,en:"circle",ans:w,a:"style-name"},{ens:k,en:"connector",ans:w,a:"style-name"},{ens:k,en:"control",ans:w,a:"style-name"},{ens:k,en:"custom-shape",ans:w,a:"style-name"},{ens:k,en:"ellipse",ans:w,a:"style-name"},{ens:k,en:"frame",ans:w,a:"style-name"},{ens:k,en:"g",ans:w,a:"style-name"},
{ens:k,en:"line",ans:w,a:"style-name"},{ens:k,en:"measure",ans:w,a:"style-name"},{ens:k,en:"page-thumbnail",ans:w,a:"style-name"},{ens:k,en:"path",ans:w,a:"style-name"},{ens:k,en:"polygon",ans:w,a:"style-name"},{ens:k,en:"polyline",ans:w,a:"style-name"},{ens:k,en:"rect",ans:w,a:"style-name"},{ens:k,en:"regular-polygon",ans:w,a:"style-name"},{ens:y,en:"annotation",ans:w,a:"style-name"}],"drawing-page":[{ens:k,en:"page",ans:k,a:"style-name"},{ens:w,en:"notes",ans:k,a:"style-name"},{ens:z,en:"handout-master",
ans:k,a:"style-name"},{ens:z,en:"master-page",ans:k,a:"style-name"}],"list-style":[{ens:v,en:"list",ans:v,a:"style-name"},{ens:v,en:"numbered-paragraph",ans:v,a:"style-name"},{ens:v,en:"list-item",ans:v,a:"style-override"},{ens:z,en:"style",ans:z,a:"list-style-name"}],data:[{ens:z,en:"style",ans:z,a:"data-style-name"},{ens:z,en:"style",ans:z,a:"percentage-data-style-name"},{ens:w,en:"date-time-decl",ans:z,a:"data-style-name"},{ens:v,en:"creation-date",ans:z,a:"data-style-name"},{ens:v,en:"creation-time",
ans:z,a:"data-style-name"},{ens:v,en:"database-display",ans:z,a:"data-style-name"},{ens:v,en:"date",ans:z,a:"data-style-name"},{ens:v,en:"editing-duration",ans:z,a:"data-style-name"},{ens:v,en:"expression",ans:z,a:"data-style-name"},{ens:v,en:"meta-field",ans:z,a:"data-style-name"},{ens:v,en:"modification-date",ans:z,a:"data-style-name"},{ens:v,en:"modification-time",ans:z,a:"data-style-name"},{ens:v,en:"print-date",ans:z,a:"data-style-name"},{ens:v,en:"print-time",ans:z,a:"data-style-name"},{ens:v,
en:"table-formula",ans:z,a:"data-style-name"},{ens:v,en:"time",ans:z,a:"data-style-name"},{ens:v,en:"user-defined",ans:z,a:"data-style-name"},{ens:v,en:"user-field-get",ans:z,a:"data-style-name"},{ens:v,en:"user-field-input",ans:z,a:"data-style-name"},{ens:v,en:"variable-get",ans:z,a:"data-style-name"},{ens:v,en:"variable-input",ans:z,a:"data-style-name"},{ens:v,en:"variable-set",ans:z,a:"data-style-name"}],"page-layout":[{ens:w,en:"notes",ans:z,a:"page-layout-name"},{ens:z,en:"handout-master",ans:z,
a:"page-layout-name"},{ens:z,en:"master-page",ans:z,a:"page-layout-name"}]},H,K=xmldom.XPath;this.collectUsedFontFaces=f;this.changeFontFaceNames=m;this.UsedStyleList=function(a,c){var d={};this.uses=function(a){var c=a.localName,b=a.getAttributeNS(k,"name")||a.getAttributeNS(z,"name");a="style"===c?a.getAttributeNS(z,"family"):a.namespaceURI===u?"data":c;return(a=d[a])?0<a[b]:!1};b(a,d);c&&q(c,d)};this.getStyleName=function(a,c){var b,d,e=H[c.localName];if(e&&(e=e[c.namespaceURI]))for(d=0;d<e.length;d+=
1)if(e[d].keyname===a&&(e=e[d],c.hasAttributeNS(e.ns,e.localname))){b=c.getAttributeNS(e.ns,e.localname);break}return b};this.hasDerivedStyles=function(a,c,b){var d=b.getAttributeNS(z,"name");b=b.getAttributeNS(z,"family");return K.getODFElementsWithXPath(a,'//style:*[@style:parent-style-name="'+d+'"][@style:family="'+b+'"]',c).length?!0:!1};this.prefixStyleNames=function(a,c,b){var d;if(a){for(d=a.firstChild;d;){if(d.nodeType===Node.ELEMENT_NODE){var e=d,f=c,m=e.getAttributeNS(k,"name"),h=void 0;
m?h=k:(m=e.getAttributeNS(z,"name"))&&(h=z);h&&e.setAttributeNS(h,B[h]+"name",f+m)}d=d.nextSibling}g(a,c);b&&g(b,c)}};this.removePrefixFromStyleNames=function(a,c,b){var d=new RegExp("^"+c);if(a){for(c=a.firstChild;c;){if(c.nodeType===Node.ELEMENT_NODE){var e=c,f=d,m=e.getAttributeNS(k,"name"),h=void 0;m?h=k:(m=e.getAttributeNS(z,"name"))&&(h=z);h&&(m=m.replace(f,""),e.setAttributeNS(h,B[h]+"name",m))}c=c.nextSibling}l(a,d);b&&l(b,d)}};this.determineStylesForNode=d;H=function(){var a,c,b,d,e,k={},
f,m,h,g;for(b in J)if(J.hasOwnProperty(b))for(d=J[b],c=d.length,a=0;a<c;a+=1)e=d[a],h=e.en,g=e.ens,k.hasOwnProperty(h)?f=k[h]:k[h]=f={},f.hasOwnProperty(g)?m=f[g]:f[g]=m=[],m.push({ns:e.ans,localname:e.a,keyname:b});return k}()};"function"!==typeof Object.create&&(Object.create=function(g){var l=function(){};l.prototype=g;return new l});
xmldom.LSSerializer=function(){function g(b){var d=b||{},h=function(b){var a={},c;for(c in b)b.hasOwnProperty(c)&&(a[b[c]]=c);return a}(b),g=[d],l=[h],f=0;this.push=function(){f+=1;d=g[f]=Object.create(d);h=l[f]=Object.create(h)};this.pop=function(){g.pop();l.pop();--f;d=g[f];h=l[f]};this.getLocalNamespaceDefinitions=function(){return h};this.getQName=function(b){var a=b.namespaceURI,c=0,e;if(!a)return b.localName;if(e=h[a])return e+":"+b.localName;do{e||!b.prefix?(e="ns"+c,c+=1):e=b.prefix;if(d[e]===
a)break;if(!d[e]){d[e]=a;h[a]=e;break}e=null}while(null===e);return e+":"+b.localName}}function l(b){return b.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;")}function d(h,g){var n="",p=b.filter?b.filter.acceptNode(g):NodeFilter.FILTER_ACCEPT,q;if(p===NodeFilter.FILTER_ACCEPT&&g.nodeType===Node.ELEMENT_NODE){h.push();q=h.getQName(g);var f,m=g.attributes,a,c,e,k="",x;f="<"+q;a=m.length;for(c=0;c<a;c+=1)e=m.item(c),"http://www.w3.org/2000/xmlns/"!==
e.namespaceURI&&(x=b.filter?b.filter.acceptNode(e):NodeFilter.FILTER_ACCEPT,x===NodeFilter.FILTER_ACCEPT&&(x=h.getQName(e),e="string"===typeof e.value?l(e.value):e.value,k+=" "+(x+'="'+e+'"')));a=h.getLocalNamespaceDefinitions();for(c in a)a.hasOwnProperty(c)&&((m=a[c])?"xmlns"!==m&&(f+=" xmlns:"+a[c]+'="'+c+'"'):f+=' xmlns="'+c+'"');n+=f+(k+">")}if(p===NodeFilter.FILTER_ACCEPT||p===NodeFilter.FILTER_SKIP){for(p=g.firstChild;p;)n+=d(h,p),p=p.nextSibling;g.nodeValue&&(n+=l(g.nodeValue))}q&&(n+="</"+
q+">",h.pop());return n}var b=this;this.filter=null;this.writeToString=function(b,n){if(!b)return"";var h=new g(n);return d(h,b)}};
(function(){function g(b){var a,c=p.length;for(a=0;a<c;a+=1)if("urn:oasis:names:tc:opendocument:xmlns:office:1.0"===b.namespaceURI&&b.localName===p[a])return a;return-1}function l(b,a){var c=new h.UsedStyleList(b,a),d=new odf.OdfNodeFilter;this.acceptNode=function(b){var e=d.acceptNode(b);e===NodeFilter.FILTER_ACCEPT&&b.parentNode===a&&b.nodeType===Node.ELEMENT_NODE&&(e=c.uses(b)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT);return e}}function d(b,a){var c=new l(b,a);this.acceptNode=function(a){var b=
c.acceptNode(a);b!==NodeFilter.FILTER_ACCEPT||!a.parentNode||a.parentNode.namespaceURI!==odf.Namespaces.textns||"s"!==a.parentNode.localName&&"tab"!==a.parentNode.localName||(b=NodeFilter.FILTER_REJECT);return b}}function b(b,a){if(a){var c=g(a),d,k=b.firstChild;if(-1!==c){for(;k;){d=g(k);if(-1!==d&&d>c)break;k=k.nextSibling}b.insertBefore(a,k)}}}var h=new odf.StyleInfo,n=core.DomUtils,r=odf.Namespaces.stylens,p="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "),
q=Date.now()+"_webodf_",f=new core.Base64;odf.ODFElement=function(){};odf.ODFDocumentElement=function(){};odf.ODFDocumentElement.prototype=new odf.ODFElement;odf.ODFDocumentElement.prototype.constructor=odf.ODFDocumentElement;odf.ODFDocumentElement.prototype.fontFaceDecls=null;odf.ODFDocumentElement.prototype.manifest=null;odf.ODFDocumentElement.prototype.settings=null;odf.ODFDocumentElement.namespaceURI="urn:oasis:names:tc:opendocument:xmlns:office:1.0";odf.ODFDocumentElement.localName="document";
odf.AnnotationElement=function(){};odf.OdfPart=function(b,a,c,d){var e=this;this.size=0;this.type=null;this.name=b;this.container=c;this.url=null;this.mimetype=a;this.onstatereadychange=this.document=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.data="";this.load=function(){null!==d&&(this.mimetype=a,d.loadAsDataURL(b,a,function(a,c){a&&runtime.log(a);e.url=c;if(e.onchange)e.onchange(e);if(e.onstatereadychange)e.onstatereadychange(e)}))}};odf.OdfPart.prototype.load=function(){};
odf.OdfPart.prototype.getUrl=function(){return this.data?"data:;base64,"+f.toBase64(this.data):null};odf.OdfContainer=function a(c,e){function k(a){for(var c=a.firstChild,b;c;)b=c.nextSibling,c.nodeType===Node.ELEMENT_NODE?k(c):c.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(c),c=b}function g(a){var c={},b,d,e=a.ownerDocument.createNodeIterator(a,NodeFilter.SHOW_ELEMENT,null,!1);for(a=e.nextNode();a;)"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&("annotation"===
a.localName?(b=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))&&(c.hasOwnProperty(b)?runtime.log("Warning: annotation name used more than once with <office:annotation/>: '"+b+"'"):c[b]=a):"annotation-end"===a.localName&&((b=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))?c.hasOwnProperty(b)?(d=c[b],d.annotationEndElement?runtime.log("Warning: annotation name used more than once with <office:annotation-end/>: '"+b+"'"):d.annotationEndElement=
a):runtime.log("Warning: annotation end without an annotation start, name: '"+b+"'"):runtime.log("Warning: annotation end without a name found"))),a=e.nextNode()}function p(a,c){for(var b=a&&a.firstChild;b;)b.nodeType===Node.ELEMENT_NODE&&b.setAttributeNS("urn:webodf:names:scope","scope",c),b=b.nextSibling}function y(a,c){for(var b=D.rootElement.meta,b=b&&b.firstChild;b&&(b.namespaceURI!==a||b.localName!==c);)b=b.nextSibling;for(b=b&&b.firstChild;b&&b.nodeType!==Node.TEXT_NODE;)b=b.nextSibling;return b?
b.data:null}function w(a){var c={},b;for(a=a.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&a.namespaceURI===r&&"font-face"===a.localName&&(b=a.getAttributeNS(r,"name"),c[b]=a),a=a.nextSibling;return c}function z(a,c){var b=null,d,e,k;if(a)for(b=a.cloneNode(!0),d=b.firstElementChild;d;)e=d.nextElementSibling,(k=d.getAttributeNS("urn:webodf:names:scope","scope"))&&k!==c&&b.removeChild(d),d=e;return b}function t(a,c){var b,d,e,k=null,f={};if(a)for(c.forEach(function(a){h.collectUsedFontFaces(f,a)}),
k=a.cloneNode(!0),b=k.firstElementChild;b;)d=b.nextElementSibling,e=b.getAttributeNS(r,"name"),f[e]||k.removeChild(b),b=d;return k}function v(a){var c=D.rootElement.ownerDocument,b;if(a){k(a.documentElement);try{b=c.importNode(a.documentElement,!0)}catch(da){}}return b}function B(a){D.state=a;if(D.onchange)D.onchange(D);if(D.onstatereadychange)D.onstatereadychange(D)}function J(a){P=null;D.rootElement=a;a.fontFaceDecls=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");
a.styles=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles");a.automaticStyles=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");a.masterStyles=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles");a.body=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");a.meta=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta");a.settings=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0",
"settings");a.scripts=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","scripts");g(a)}function H(c){var d=v(c),e=D.rootElement,k;d&&"document-styles"===d.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===d.namespaceURI?(e.fontFaceDecls=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),b(e,e.fontFaceDecls),k=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),e.styles=k||c.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",
"styles"),b(e,e.styles),k=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),e.automaticStyles=k||c.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),p(e.automaticStyles,"document-styles"),b(e,e.automaticStyles),d=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),e.masterStyles=d||c.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),b(e,e.masterStyles),
h.prefixStyleNames(e.automaticStyles,q,e.masterStyles)):B(a.INVALID)}function K(c){c=v(c);var d,e,k,f;if(c&&"document-content"===c.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===c.namespaceURI){d=D.rootElement;k=n.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");if(d.fontFaceDecls&&k){f=d.fontFaceDecls;var g,l,Q,q,C={};e=w(f);q=w(k);for(k=k.firstElementChild;k;){g=k.nextElementSibling;if(k.namespaceURI===r&&"font-face"===k.localName)if(l=k.getAttributeNS(r,
"name"),e.hasOwnProperty(l)){if(!k.isEqualNode(e[l])){Q=l;var x=e,U=q,u=0,M;for(M=Q=Q.replace(/\d+$/,"");x.hasOwnProperty(M)||U.hasOwnProperty(M);)u+=1,M=Q+u;Q=M;k.setAttributeNS(r,"style:name",Q);f.appendChild(k);e[Q]=k;delete q[l];C[l]=Q}}else f.appendChild(k),e[l]=k,delete q[l];k=g}f=C}else k&&(d.fontFaceDecls=k,b(d,k));e=n.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");p(e,"document-content");f&&h.changeFontFaceNames(e,f);if(d.automaticStyles&&e)for(f=
e.firstChild;f;)d.automaticStyles.appendChild(f),f=e.firstChild;else e&&(d.automaticStyles=e,b(d,e));c=n.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");if(null===c)throw"<office:body/> tag is mising.";d.body=c;b(d,d.body)}else B(a.INVALID)}function U(a){a=v(a);var c;a&&"document-meta"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(c=D.rootElement,c.meta=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),
b(c,c.meta))}function L(a){a=v(a);var c;a&&"document-settings"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(c=D.rootElement,c.settings=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),b(c,c.settings))}function Q(a){a=v(a);var c;if(a&&"manifest"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===a.namespaceURI)for(c=D.rootElement,c.manifest=a,a=c.manifest.firstElementChild;a;)"file-entry"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===
a.namespaceURI&&(W[a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","full-path")]=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","media-type")),a=a.nextElementSibling}function C(a,c,b){a=n.getElementsByTagName(a,c);var d;for(d=0;d<a.length;d+=1)c=a[d],b.hasOwnProperty(c.namespaceURI)||c.parentNode.removeChild(c)}function V(a){C(a,"script",{"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:office:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:table:1.0":!0,
"urn:oasis:names:tc:opendocument:xmlns:text:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0":!0});C(a,"style",{"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:style:1.0":!0})}function M(a){var c=a.firstElementChild,b=[],d,e,k,f=a.attributes,h=f.length;for(d=0;d<h;d+=1)k=f.item(d),e=k.localName.substr(0,2).toLowerCase(),null===k.namespaceURI&&"on"===e&&b.push(k);h=b.length;for(d=
0;d<h;d+=1)a.removeAttributeNode(b[d]);for(;c;)M(c),c=c.nextElementSibling}function N(c){var b=c.shift();b?Y.loadAsDOM(b.path,function(d,e){e&&(V(e),M(e.documentElement));b.handler(e);D.state===a.INVALID?d?runtime.log("ERROR: Unable to load "+b.path+" - "+d):runtime.log("ERROR: Unable to load "+b.path):(d&&runtime.log("DEBUG: Unable to load "+b.path+" - "+d),N(c))}):(g(D.rootElement),B(a.DONE))}function T(a){var c="";odf.Namespaces.forEachPrefix(function(a,b){c+=" xmlns:"+a+'="'+b+'"'});return'<?xml version="1.0" encoding="UTF-8"?><office:'+
a+" "+c+' office:version="1.2">'}function F(){var a=new xmldom.LSSerializer,c=T("document-meta");a.filter=new odf.OdfNodeFilter;c+=a.writeToString(D.rootElement.meta,odf.Namespaces.namespaceMap);return c+"</office:document-meta>"}function aa(a,c){var b=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");b.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",a);b.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0",
"manifest:media-type",c);return b}function O(){var a=runtime.parseXML('<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2"></manifest:manifest>'),c=a.documentElement,b=new xmldom.LSSerializer,d;for(d in W)W.hasOwnProperty(d)&&c.appendChild(aa(d,W[d]));b.filter=new odf.OdfNodeFilter;return'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'+b.writeToString(a,odf.Namespaces.namespaceMap)}function ea(){var a,c,b,d=odf.Namespaces.namespaceMap,
e=new xmldom.LSSerializer,k=T("document-styles");c=z(D.rootElement.automaticStyles,"document-styles");b=D.rootElement.masterStyles.cloneNode(!0);a=t(D.rootElement.fontFaceDecls,[b,D.rootElement.styles,c]);h.removePrefixFromStyleNames(c,q,b);e.filter=new l(b,c);k+=e.writeToString(a,d);k+=e.writeToString(D.rootElement.styles,d);k+=e.writeToString(c,d);k+=e.writeToString(b,d);return k+"</office:document-styles>"}function ba(){var a,c,b=odf.Namespaces.namespaceMap,e=new xmldom.LSSerializer,k=T("document-content");
c=z(D.rootElement.automaticStyles,"document-content");a=t(D.rootElement.fontFaceDecls,[c]);e.filter=new d(D.rootElement.body,c);k+=e.writeToString(a,b);k+=e.writeToString(c,b);k+=e.writeToString(D.rootElement.body,b);return k+"</office:document-content>"}function A(c,b){runtime.loadXML(c,function(c,d){if(c)b(c);else if(d){V(d);M(d.documentElement);var e=v(d);e&&"document"===e.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===e.namespaceURI?(J(e),B(a.DONE)):B(a.INVALID)}else b("No DOM was loaded.")})}
function X(a,c){var d;d=D.rootElement;var e=d.meta;e||(d.meta=e=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),b(d,e));d=e;a&&n.mapKeyValObjOntoNode(d,a,odf.Namespaces.lookupNamespaceURI);c&&n.removeKeyElementsFromNode(d,c,odf.Namespaces.lookupNamespaceURI)}function ca(c,b){function d(a,c){var b;c||(c=a);b=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",c);h[a]=b;h.appendChild(b)}var e=new core.Zip("",null),k="application/vnd.oasis.opendocument."+
c+(!0===b?"-template":""),f=runtime.byteArrayFromString(k,"utf8"),h=D.rootElement,g=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",c);e.save("mimetype",f,!1,new Date);d("meta");d("settings");d("scripts");d("fontFaceDecls","font-face-decls");d("styles");d("automaticStyles","automatic-styles");d("masterStyles","master-styles");d("body");h.body.appendChild(g);W["/"]=k;W["settings.xml"]="text/xml";W["meta.xml"]="text/xml";W["styles.xml"]="text/xml";W["content.xml"]="text/xml";
B(a.DONE);return e}function S(){var a,c=new Date;if(W["settings.xml"]){a=new xmldom.LSSerializer;var b=T("document-settings");D.rootElement.settings&&D.rootElement.settings.firstElementChild&&(a.filter=new odf.OdfNodeFilter,b+=a.writeToString(D.rootElement.settings,odf.Namespaces.namespaceMap));a=runtime.byteArrayFromString(b+"</office:document-settings>","utf8");Y.save("settings.xml",a,!0,c)}else Y.remove("settings.xml");b=runtime.getWindow();a="WebODF/"+webodf.Version;b&&(a=a+" "+b.navigator.userAgent);
X({"meta:generator":a},null);a=runtime.byteArrayFromString(F(),"utf8");Y.save("meta.xml",a,!0,c);a=runtime.byteArrayFromString(ea(),"utf8");Y.save("styles.xml",a,!0,c);a=runtime.byteArrayFromString(ba(),"utf8");Y.save("content.xml",a,!0,c);a=runtime.byteArrayFromString(O(),"utf8");Y.save("META-INF/manifest.xml",a,!0,c)}function ga(a,c){S();Y.writeAs(a,function(a){c(a)})}var D=this,Y,W={},P,I="";this.onstatereadychange=e;this.state=this.onchange=null;this.getMetadata=y;this.setRootElement=J;this.getContentElement=
function(){var a;P||(a=D.rootElement.body,P=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","text")||n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","presentation")||n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","spreadsheet"));if(!P)throw"Could not find content element in <office:body/>.";return P};this.getDocumentType=function(){var a=D.getContentElement();return a&&a.localName};this.isTemplate=function(){return"-template"===W["/"].substr(-9)};
this.setIsTemplate=function(a){var c=W["/"],b="-template"===c.substr(-9);a!==b&&(c=a?c+"-template":c.substr(0,c.length-9),W["/"]=c,a=runtime.byteArrayFromString(c,"utf8"),Y.save("mimetype",a,!1,new Date))};this.getPart=function(a){return new odf.OdfPart(a,W[a],D,Y)};this.getPartData=function(a,c){Y.load(a,c)};this.setMetadata=X;this.incrementEditingCycles=function(){var a=y(odf.Namespaces.metans,"editing-cycles"),a=a?parseInt(a,10):0;isNaN(a)&&(a=0);X({"meta:editing-cycles":a+1},null);return a+1};
this.createByteArray=function(a,c){S();Y.createByteArray(a,c)};this.saveAs=ga;this.save=function(a){ga(I,a)};this.getUrl=function(){return I};this.setBlob=function(a,c,b){b=f.convertBase64ToByteArray(b);Y.save(a,b,!1,new Date);W.hasOwnProperty(a)&&runtime.log(a+" has been overwritten.");W[a]=c};this.removeBlob=function(a){var c=Y.remove(a);runtime.assert(c,"file is not found: "+a);delete W[a]};this.state=a.LOADING;this.rootElement=function(a){var c=document.createElementNS(a.namespaceURI,a.localName),
b;a=new a.Type;for(b in a)a.hasOwnProperty(b)&&(c[b]=a[b]);return c}({Type:odf.ODFDocumentElement,namespaceURI:odf.ODFDocumentElement.namespaceURI,localName:odf.ODFDocumentElement.localName});c===odf.OdfContainer.DocumentType.TEXT?Y=ca("text"):c===odf.OdfContainer.DocumentType.TEXT_TEMPLATE?Y=ca("text",!0):c===odf.OdfContainer.DocumentType.PRESENTATION?Y=ca("presentation"):c===odf.OdfContainer.DocumentType.PRESENTATION_TEMPLATE?Y=ca("presentation",!0):c===odf.OdfContainer.DocumentType.SPREADSHEET?
Y=ca("spreadsheet"):c===odf.OdfContainer.DocumentType.SPREADSHEET_TEMPLATE?Y=ca("spreadsheet",!0):(I=c,Y=new core.Zip(I,function(c,b){Y=b;c?A(I,function(b){c&&(Y.error=c+"\n"+b,B(a.INVALID))}):N([{path:"styles.xml",handler:H},{path:"content.xml",handler:K},{path:"meta.xml",handler:U},{path:"settings.xml",handler:L},{path:"META-INF/manifest.xml",handler:Q}])}))};odf.OdfContainer.EMPTY=0;odf.OdfContainer.LOADING=1;odf.OdfContainer.DONE=2;odf.OdfContainer.INVALID=3;odf.OdfContainer.SAVING=4;odf.OdfContainer.MODIFIED=
5;odf.OdfContainer.getContainer=function(a){return new odf.OdfContainer(a,null)}})();odf.OdfContainer.DocumentType={TEXT:1,TEXT_TEMPLATE:2,PRESENTATION:3,PRESENTATION_TEMPLATE:4,SPREADSHEET:5,SPREADSHEET_TEMPLATE:6};gui.AnnotatableCanvas=function(){};gui.AnnotatableCanvas.prototype.refreshSize=function(){};gui.AnnotatableCanvas.prototype.getZoomLevel=function(){};gui.AnnotatableCanvas.prototype.getSizer=function(){};
gui.AnnotationViewManager=function(g,l,d,b){function h(c){var b=c.annotationEndElement,d=m.createRange(),e=c.getAttributeNS(odf.Namespaces.officens,"name");b&&(d.setStart(c,c.childNodes.length),d.setEnd(b,0),c=a.getTextNodes(d,!1),c.forEach(function(a){var c;a:{for(c=a.parentNode;c.namespaceURI!==odf.Namespaces.officens||"body"!==c.localName;){if("http://www.w3.org/1999/xhtml"===c.namespaceURI&&"webodf-annotationHighlight"===c.className&&c.getAttribute("annotation")===e){c=!0;break a}c=c.parentNode}c=
!1}c||(c=m.createElement("span"),c.className="webodf-annotationHighlight",c.setAttribute("annotation",e),a.parentNode.replaceChild(c,a),c.appendChild(a))}));d.detach()}function n(a){var b=g.getSizer();a?(d.style.display="inline-block",b.style.paddingRight=c.getComputedStyle(d).width):(d.style.display="none",b.style.paddingRight=0);g.refreshSize()}function r(){f.sort(function(a,c){return 0!==(a.compareDocumentPosition(c)&Node.DOCUMENT_POSITION_FOLLOWING)?-1:1})}function p(){var a;for(a=0;a<f.length;a+=
1){var c=f[a],b=c.parentNode,h=b.nextElementSibling,m=h.nextElementSibling,n=b.parentNode,l=f[f.indexOf(c)-1],c=g.getZoomLevel();b.style.left=(d.getBoundingClientRect().left-n.getBoundingClientRect().left)/c+"px";b.style.width=d.getBoundingClientRect().width/c+"px";h.style.width=parseFloat(b.style.left)-30+"px";l?(l=l.parentNode.getBoundingClientRect(),20>=(n.getBoundingClientRect().top-l.bottom)/c?b.style.top=Math.abs(n.getBoundingClientRect().top-l.bottom)/c+20+"px":b.style.top="0px"):b.style.top=
"0px";m.style.left=h.getBoundingClientRect().width/c+"px";var h=m.style,p=m.getBoundingClientRect().left/c,n=m.getBoundingClientRect().top/c,r=b.getBoundingClientRect().left/c,l=b.getBoundingClientRect().top/c,p=r-p,n=l-n;h.width=Math.sqrt(p*p+n*n)+"px";b=Math.asin((b.getBoundingClientRect().top-m.getBoundingClientRect().top)/(c*parseFloat(m.style.width)));m.style.transform="rotate("+b+"rad)";m.style.MozTransform="rotate("+b+"rad)";m.style.WebkitTransform="rotate("+b+"rad)";m.style.msTransform="rotate("+
b+"rad)"}}function q(a){var c=f.indexOf(a),b=a.parentNode.parentNode;"div"===b.localName&&(b.parentNode.insertBefore(a,b),b.parentNode.removeChild(b));a=a.getAttributeNS(odf.Namespaces.officens,"name");a=m.querySelectorAll('span.webodf-annotationHighlight[annotation="'+a+'"]');for(var d,b=0;b<a.length;b+=1){for(d=a.item(b);d.firstChild;)d.parentNode.insertBefore(d.firstChild,d);d.parentNode.removeChild(d)}-1!==c&&f.splice(c,1);0===f.length&&n(!1)}var f=[],m=l.ownerDocument,a=odf.OdfUtils,c=runtime.getWindow();
runtime.assert(!!c,"Expected to be run in an environment which has a global window, like a browser.");this.rerenderAnnotations=p;this.rehighlightAnnotations=function(){f.forEach(function(a){h(a)})};this.getMinimumHeightForAnnotationPane=function(){return"none"!==d.style.display&&0<f.length?(f[f.length-1].parentNode.getBoundingClientRect().bottom-d.getBoundingClientRect().top)/g.getZoomLevel()+"px":null};this.addAnnotations=function(c){0!==c.length&&(n(!0),c.forEach(function(c){f.push(c);var d=m.createElement("div"),
e=m.createElement("div"),k=m.createElement("div"),g=m.createElement("div"),n;d.className="annotationWrapper";d.setAttribute("creator",a.getAnnotationCreator(c));c.parentNode.insertBefore(d,c);e.className="annotationNote";e.appendChild(c);b&&(n=m.createElement("div"),n.className="annotationRemoveButton",e.appendChild(n));k.className="annotationConnector horizontal";g.className="annotationConnector angular";d.appendChild(e);d.appendChild(k);d.appendChild(g);c.annotationEndElement&&h(c)}),r(),p())};
this.forgetAnnotation=q;this.forgetAnnotations=function(){for(;f.length;)q(f[0])}};gui.Viewport=function(){};gui.Viewport.prototype.scrollIntoView=function(g,l){};
gui.SingleScrollViewport=function(g){this.scrollIntoView=function(l,d){var b,h,n,r;r=g.offsetHeight-g.clientHeight;n=g.offsetWidth-g.clientWidth;var p=g.getBoundingClientRect();if(l&&p){b=p.left+5;h=p.top+5;n=p.right-(n+5);r=p.bottom-(r+5);if(d||l.top<h)g.scrollTop-=h-l.top;else if(l.top>r||l.bottom>r)g.scrollTop=l.bottom-l.top<=r-h?g.scrollTop+(l.bottom-r):g.scrollTop+(l.top-h);l.left<b?g.scrollLeft-=b-l.left:l.right>n&&(g.scrollLeft=l.right-l.left<=n-b?g.scrollLeft+(l.right-n):g.scrollLeft-(b-l.left))}}};
(function(){function g(d,n,l,p,q){var f,m=0,a;for(a in d)if(d.hasOwnProperty(a)){if(m===l){f=a;break}m+=1}f?n.getPartData(d[f].href,function(a,e){if(a)runtime.log(a);else if(e){var c="@font-face { font-family: "+(d[f].family||f)+"; src: url(data:application/x-font-ttf;charset=binary;base64,"+b.convertUTF8ArrayToBase64(e)+') format("truetype"); }';try{p.insertRule(c,p.cssRules.length)}catch(x){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(x)+"\nRule: "+c)}}else runtime.log("missing font data for "+
d[f].href);g(d,n,l+1,p,q)}):q&&q()}var l=xmldom.XPath,d=odf.OdfUtils,b=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(b,n){for(var h=b.rootElement.fontFaceDecls;n.cssRules.length;)n.deleteRule(n.cssRules.length-1);if(h){var p={},q,f,m,a;if(h)for(h=l.getODFElementsWithXPath(h,"style:font-face[svg:font-face-src]",odf.Namespaces.lookupNamespaceURI),q=0;q<h.length;q+=1)f=h[q],m=f.getAttributeNS(odf.Namespaces.stylens,"name"),a=d.getNormalizedFontFamilyName(f.getAttributeNS(odf.Namespaces.svgns,
"font-family")),f=l.getODFElementsWithXPath(f,"svg:font-face-src/svg:font-face-uri",odf.Namespaces.lookupNamespaceURI),0<f.length&&(f=f[0].getAttributeNS(odf.Namespaces.xlinkns,"href"),p[m]={href:f,family:a});g(p,b,0,n)}}}})();
odf.Formatting=function(){function g(a){return(a=B[a])?t.mergeObjects({},a):{}}function l(){for(var c=a.rootElement.fontFaceDecls,b={},d,f,c=c&&c.firstElementChild;c;){if(d=c.getAttributeNS(k,"name"))if((f=c.getAttributeNS(e,"font-family"))||0<c.getElementsByTagNameNS(e,"font-face-uri").length)b[d]=f;c=c.nextElementSibling}return b}function d(c){for(var b=a.rootElement.styles.firstElementChild;b;){if(b.namespaceURI===k&&"default-style"===b.localName&&b.getAttributeNS(k,"family")===c)return b;b=b.nextElementSibling}return null}
function b(c,b,d){var e,f,m;d=d||[a.rootElement.automaticStyles,a.rootElement.styles];for(m=0;m<d.length;m+=1)for(e=d[m],e=e.firstElementChild;e;){f=e.getAttributeNS(k,"name");if(e.namespaceURI===k&&"style"===e.localName&&e.getAttributeNS(k,"family")===b&&f===c||"list-style"===b&&e.namespaceURI===x&&"list-style"===e.localName&&f===c||"data"===b&&e.namespaceURI===u&&f===c)return e;e=e.nextElementSibling}return null}function h(a){for(var c,b,d,e,f={},m=a.firstElementChild;m;){if(m.namespaceURI===k)for(d=
f[m.nodeName]={},b=m.attributes,c=0;c<b.length;c+=1)e=b.item(c),d[e.name]=e.value;m=m.nextElementSibling}b=a.attributes;for(c=0;c<b.length;c+=1)e=b.item(c),f[e.name]=e.value;return f}function n(c,e){for(var f=a.rootElement.styles,m,n={},l=c.getAttributeNS(k,"family"),p=c;p;)m=h(p),n=t.mergeObjects(m,n),p=(m=p.getAttributeNS(k,"parent-style-name"))?b(m,l,[f]):null;if(p=d(l))m=h(p),n=t.mergeObjects(m,n);!1!==e&&(m=g(l),n=t.mergeObjects(m,n));return n}function r(b,d){function e(a){Object.keys(a).forEach(function(c){Object.keys(a[c]).forEach(function(a){h+=
"|"+c+":"+a+"|"})})}for(var k=b.nodeType===Node.TEXT_NODE?b.parentNode:b,f,m=[],h="",g=!1;k&&!w.isInlineRoot(k)&&k.parentNode!==a.rootElement;)!g&&w.isGroupingElement(k)&&(g=!0),(f=c.determineStylesForNode(k))&&m.push(f),k=k.parentNode;g&&(m.forEach(e),d&&(d[h]=m));return g?m:void 0}function p(c){var d={orderedStyles:[],styleProperties:{}};c.forEach(function(c){Object.keys(c).forEach(function(e){var f=Object.keys(c[e])[0],m={name:f,family:e,displayName:void 0,isCommonStyle:!1},h;(h=b(f,e))?(e=n(h),
d.styleProperties=t.mergeObjects(e,d.styleProperties),m.displayName=h.getAttributeNS(k,"display-name")||void 0,m.isCommonStyle=h.parentNode===a.rootElement.styles):runtime.log("No style element found for '"+f+"' of family '"+e+"'");d.orderedStyles.push(m)})});return d}function q(a,c){var b={},d=[];c||(c={});a.forEach(function(a){r(a,b)});Object.keys(b).forEach(function(a){c[a]||(c[a]=p(b[a]));d.push(c[a])});return d}function f(c){for(var b=a.rootElement.masterStyles.firstElementChild;b&&(b.namespaceURI!==
k||"master-page"!==b.localName||b.getAttributeNS(k,"name")!==c);)b=b.nextElementSibling;return b}function m(a,c){var b;a&&(b=v.convertMeasure(a,"px"));void 0===b&&c&&(b=v.convertMeasure(c,"px"));return b}var a,c=new odf.StyleInfo,e=odf.Namespaces.svgns,k=odf.Namespaces.stylens,x=odf.Namespaces.textns,u=odf.Namespaces.numberns,y=odf.Namespaces.fons,w=odf.OdfUtils,z=core.DomUtils,t=new core.Utils,v=new core.CSSUnits,B={paragraph:{"style:paragraph-properties":{"fo:text-align":"left"}}};this.getSystemDefaultStyleAttributes=
g;this.setOdfContainer=function(c){a=c};this.getFontMap=l;this.getAvailableParagraphStyles=function(){for(var c=a.rootElement.styles,b,d,e=[],c=c&&c.firstElementChild;c;)"style"===c.localName&&c.namespaceURI===k&&(b=c.getAttributeNS(k,"family"),"paragraph"===b&&(b=c.getAttributeNS(k,"name"),d=c.getAttributeNS(k,"display-name")||b,b&&d&&e.push({name:b,displayName:d}))),c=c.nextElementSibling;return e};this.isStyleUsed=function(b){var d,e=a.rootElement;d=c.hasDerivedStyles(e,odf.Namespaces.lookupNamespaceURI,
b);b=(new c.UsedStyleList(e.styles)).uses(b)||(new c.UsedStyleList(e.automaticStyles)).uses(b)||(new c.UsedStyleList(e.body)).uses(b);return d||b};this.getDefaultStyleElement=d;this.getStyleElement=b;this.getStyleAttributes=h;this.getInheritedStyleAttributes=n;this.getFirstCommonParentStyleNameOrSelf=function(c){var d=a.rootElement.styles,e;if(e=b(c,"paragraph",[a.rootElement.automaticStyles]))if(c=e.getAttributeNS(k,"parent-style-name"),!c)return null;return(e=b(c,"paragraph",[d]))?c:null};this.hasParagraphStyle=
function(a){return!!b(a,"paragraph")};this.getAppliedStyles=q;this.getAppliedStylesForElement=function(a,c){return q([a],c)[0]};this.updateStyle=function(c,b){var d,f;z.mapObjOntoNode(c,b,odf.Namespaces.lookupNamespaceURI);(d=(d=b["style:text-properties"])&&d["style:font-name"])&&!l().hasOwnProperty(d)&&(f=c.ownerDocument.createElementNS(k,"style:font-face"),f.setAttributeNS(k,"style:name",d),f.setAttributeNS(e,"svg:font-family",d),a.rootElement.fontFaceDecls.appendChild(f))};this.createDerivedStyleObject=
function(c,d,e){var k=b(c,d);runtime.assert(!!k,"No style element found for '"+c+"' of family '"+d+"'");c=k.parentNode===a.rootElement.styles?{"style:parent-style-name":c}:h(k);c["style:family"]=d;t.mergeObjects(c,e);return c};this.getDefaultTabStopDistance=function(){for(var a=d("paragraph"),a=a&&a.firstElementChild,c;a;)a.namespaceURI===k&&"paragraph-properties"===a.localName&&(c=a.getAttributeNS(k,"tab-stop-distance")),a=a.nextElementSibling;c||(c="1.25cm");return w.parseNonNegativeLength(c)};
this.getMasterPageElement=f;this.getContentSize=function(c,d){var e,h,g,n,l,p,r,q,x,t;a:{h=b(c,d);runtime.assert("paragraph"===d||"table"===d,"styleFamily must be either paragraph or table");if(h){if(h=h.getAttributeNS(k,"master-page-name"))(e=f(h))||runtime.log("WARN: No master page definition found for "+h);e||(e=f("Standard"));e||(e=a.rootElement.masterStyles.getElementsByTagNameNS(k,"master-page")[0])||runtime.log("WARN: Document has no master pages defined");if(e)for(h=e.getAttributeNS(k,"page-layout-name"),
g=a.rootElement.automaticStyles.getElementsByTagNameNS(k,"page-layout"),n=0;n<g.length;n+=1)if(e=g.item(n),e.getAttributeNS(k,"name")===h)break a}e=null}e||(e=z.getDirectChild(a.rootElement.styles,k,"default-page-layout"));(e=z.getDirectChild(e,k,"page-layout-properties"))?("landscape"===e.getAttributeNS(k,"print-orientation")?(h="29.7cm",g="21.001cm"):(h="21.001cm",g="29.7cm"),h=m(e.getAttributeNS(y,"page-width"),h),g=m(e.getAttributeNS(y,"page-height"),g),n=m(e.getAttributeNS(y,"margin")),void 0===
n?(n=m(e.getAttributeNS(y,"margin-left"),"2cm"),l=m(e.getAttributeNS(y,"margin-right"),"2cm"),p=m(e.getAttributeNS(y,"margin-top"),"2cm"),r=m(e.getAttributeNS(y,"margin-bottom"),"2cm")):n=l=p=r=n,q=m(e.getAttributeNS(y,"padding")),void 0===q?(q=m(e.getAttributeNS(y,"padding-left"),"0cm"),x=m(e.getAttributeNS(y,"padding-right"),"0cm"),t=m(e.getAttributeNS(y,"padding-top"),"0cm"),e=m(e.getAttributeNS(y,"padding-bottom"),"0cm")):q=x=t=e=q):(h=m("21.001cm"),g=m("29.7cm"),n=l=p=r=n=m("2cm"),q=x=t=e=q=
m("0cm"));return{width:h-n-l-q-x,height:g-p-r-t-e}}};
(function(){var g=odf.Namespaces.stylens,l=odf.Namespaces.textns,d={graphic:"draw","drawing-page":"draw",paragraph:"text",presentation:"presentation",ruby:"text",section:"text",table:"table","table-cell":"table","table-column":"table","table-row":"table",text:"text",list:"text",page:"office"};odf.StyleTreeNode=function(b){this.derivedStyles={};this.element=b};odf.StyleTree=function(b,h){function n(b){var a,c,d,k={};if(!b)return k;for(b=b.firstElementChild;b;){if(c=b.namespaceURI!==g||"style"!==b.localName&&
"default-style"!==b.localName?b.namespaceURI===l&&"list-style"===b.localName?"list":b.namespaceURI!==g||"page-layout"!==b.localName&&"default-page-layout"!==b.localName?void 0:"page":b.getAttributeNS(g,"family"))(a=b.getAttributeNS(g,"name"))||(a=""),k.hasOwnProperty(c)?d=k[c]:k[c]=d={},d[a]=b;b=b.nextElementSibling}return k}function r(b,a){if(b.hasOwnProperty(a))return b[a];var c=null,d=Object.keys(b),k;for(k=0;k<d.length&&!(c=r(b[d[k]].derivedStyles,a));k+=1);return c}function p(b,a,c){var d,k,
f;if(!a.hasOwnProperty(b))return null;d=new odf.StyleTreeNode(a[b]);k=d.element.getAttributeNS(g,"parent-style-name");f=null;k&&(f=r(c,k)||p(k,a,c));f?f.derivedStyles[b]=d:c[b]=d;delete a[b];return d}function q(b,a){b&&Object.keys(b).forEach(function(c){p(c,b,a)})}var f={};this.getStyleTree=function(){return f};(function(){var m,a,c;a=n(b);c=n(h);Object.keys(d).forEach(function(b){m=f[b]={};q(a[b],m);q(c[b],m)})})()}})();
(function(){function g(b,d){try{b.insertRule(d,b.cssRules.length)}catch(m){runtime.log("cannot load rule: "+d+" - "+m)}}function l(b,d){this.listCounterCount=0;this.contentRules=b;this.counterIdStack=[];this.continuedCounterIdStack=d}function d(b){function d(c,k,f,h){var e=k.namespaceURI===n&&"list"===k.localName,m=k.namespaceURI===n&&"list-item"===k.localName;if(e||m){if(e){var e=f+=1,l,p,r;h.listCounterCount+=1;m=c+"-level"+e+"-"+h.listCounterCount;k.setAttributeNS("urn:webodf:names:helper","counter-id",
m);l=h.continuedCounterIdStack.shift();l||(l=m,a+=m+" 1 ",p='text|list[webodfhelper|counter-id="'+m+'"] > text|list-item:first-child > :not(text|list):first-child:before{',p+="counter-increment: "+l+" 0;",p+="}",g(b,p));for(;h.counterIdStack.length>=e;)h.counterIdStack.pop();h.counterIdStack.push(l);r=h.contentRules[e.toString()]||"";for(p=1;p<=e;p+=1)r=r.replace(p+"webodf-listLevel",h.counterIdStack[p-1]);p='text|list[webodfhelper|counter-id="'+m+'"] > text|list-item > :not(text|list):first-child:before{';
p+=r;p+="counter-increment: "+l+";";p+="}";g(b,p)}for(k=k.firstElementChild;k;)d(c,k,f,h),k=k.nextElementSibling}else h.continuedCounterIdStack=[]}var h=0,a="",c={};this.createCounterRules=function(a,b,f){var e=b.getAttributeNS(r,"id"),k=[];f&&(f=f.getAttributeNS("urn:webodf:names:helper","counter-id"),k=c[f].slice(0));a=new l(a,k);e?e="Y"+e:(h+=1,e="X"+h);d(e,b,0,a);c[e+"-level1-1"]=a.counterIdStack};this.initialiseCreatedCounters=function(){g(b,"office|document{"+("counter-reset: "+a+";")+"}")}}
var b=odf.Namespaces.fons,h=odf.Namespaces.stylens,n=odf.Namespaces.textns,r=odf.Namespaces.xmlns,p={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"};odf.ListStyleToCss=function(){function l(a){var b=e.parseLength(a);return b?c.convert(b.value,b.unit,"px"):(runtime.log("Could not parse value '"+a+"'."),0)}function f(a){return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function m(a,c){var b;a&&(b=a.getAttributeNS(n,"style-name"));return b===c}function a(a,c,b){c=c.getElementsByTagNameNS(n,
"list");a=new d(a);var e,k,g,l,q,x,u={},H;for(H=0;H<c.length;H+=1)if(e=c.item(H),x=e.getAttributeNS(n,"style-name")){g=e.getAttributeNS(n,"continue-numbering");l=e.getAttributeNS(n,"continue-list");(q=e.getAttributeNS(r,"id"))&&(u[q]=e);q=b[x].element.firstElementChild;for(var K,U={};q;){K=(K=q.getAttributeNS(n,"level"))&&parseInt(K,10);var L=q,Q="",C,V=void 0;if("list-level-style-number"===L.localName){var M=L,Q=M.getAttributeNS(h,"num-format");C=M.getAttributeNS(h,"num-suffix")||"";var N=M.getAttributeNS(h,
"num-prefix")||"",T="",F=M.getAttributeNS(n,"level"),M=M.getAttributeNS(n,"display-levels");N&&(T+='"'+f(N)+'"\n');if(p.hasOwnProperty(Q))for(F=F?parseInt(F,10):1,M=M?parseInt(M,10):1;0<M;)T+=" counter("+(F-M+1)+"webodf-listLevel,"+p[Q]+")",1<M&&(T+='"."'),--M;else T=Q?T+(' "'+Q+'"'):T+' ""';Q="content:"+T+' "'+f(C)+'"'}else"list-level-style-image"===L.localName?Q="content: none":"list-level-style-bullet"===L.localName&&(Q=L.getAttributeNS(n,"bullet-char"),Q='content: "'+f(Q)+'"');if(L=L.getElementsByTagNameNS(h,
"list-level-properties")[0])C=L.getAttributeNS(n,"list-level-position-and-space-mode"),"label-alignment"===C&&((L=L.getElementsByTagNameNS(h,"list-level-label-alignment")[0])&&(V=L.getAttributeNS(n,"label-followed-by")),"space"===V&&(Q+=' "\\a0"'));U[K]="\n"+Q+";\n";q=q.nextElementSibling}q=U;g&&!l&&m(k,x)?a.createCounterRules(q,e,k):l&&m(u[l],x)?a.createCounterRules(q,e,u[l]):a.createCounterRules(q,e);k=e}a.initialiseCreatedCounters()}var c=new core.CSSUnits,e=odf.OdfUtils;this.applyListStyles=function(c,
d,e){var k,f;(k=d.list)&&Object.keys(k).forEach(function(a){f=k[a];for(var d=f.element.firstElementChild;d;){if(d.namespaceURI===n){var e=c,m=d,p='text|list[text|style-name="'+a+'"]',r=m.getAttributeNS(n,"level"),q,x,u,Q=void 0,C=void 0,V=void 0,M=void 0,m=(q=m.getElementsByTagNameNS(h,"list-level-properties")[0])&&q.getAttributeNS(n,"list-level-position-and-space-mode");x=q&&q.getElementsByTagNameNS(h,"list-level-label-alignment")[0];for(r=r&&parseInt(r,10);1<r;)p+=" > text|list-item > text|list",
--r;r=q&&q.getAttributeNS(b,"text-align")||"left";switch(r){case "end":r="right";break;case "start":r="left"}"label-alignment"===m?(u=x&&x.getAttributeNS(b,"margin-left")||"0px",V=x&&x.getAttributeNS(b,"text-indent")||"0px",M=x&&x.getAttributeNS(n,"label-followed-by"),x=l(u)):(u=q&&q.getAttributeNS(n,"space-before")||"0px",Q=q&&q.getAttributeNS(n,"min-label-width")||"0px",C=q&&q.getAttributeNS(n,"min-label-distance")||"0px",x=l(u)+l(Q));q=p+" > text|list-item{";q+="margin-left: "+x+"px;";q+="}";g(e,
q);q=p+" > text|list-item > text|list{";q+="margin-left: "+-x+"px;";q+="}";g(e,q);q=p+" > text|list-item > :not(text|list):first-child:before{";q+="text-align: "+r+";";q+="display: inline-block;";"label-alignment"===m?(q+="margin-left: "+V+";","listtab"===M&&(q+="padding-right: 0.2cm;")):(q+="min-width: "+Q+";",q+="margin-left: "+(0===parseFloat(Q)?"":"-")+Q+";",q+="padding-right: "+C+";");q+="}";g(e,q)}d=d.nextElementSibling}});a(c,e,k)}}})();
odf.LazyStyleProperties=function(g,l){var d={};this.value=function(b){var h;d.hasOwnProperty(b)?h=d[b]:(h=l[b](),void 0===h&&g&&(h=g.value(b)),d[b]=h);return h};this.reset=function(b){g=b;d={}}};
odf.StyleParseUtils=function(){function g(d){var b,h;d=(d=/(-?[0-9]*[0-9][0-9]*(\.[0-9]*)?|0+\.[0-9]*[1-9][0-9]*|\.[0-9]*[1-9][0-9]*)((cm)|(mm)|(in)|(pt)|(pc)|(px))/.exec(d))?{value:parseFloat(d[1]),unit:d[3]}:null;h=d&&d.unit;"px"===h?b=d.value:"cm"===h?b=d.value/2.54*96:"mm"===h?b=d.value/25.4*96:"in"===h?b=96*d.value:"pt"===h?b=d.value/.75:"pc"===h&&(b=16*d.value);return b}var l=odf.Namespaces.stylens;this.parseLength=g;this.parsePositiveLengthOrPercent=function(d,b,h){var n;d&&(n=parseFloat(d.substr(0,
d.indexOf("%"))),isNaN(n)&&(n=void 0));var l;void 0!==n?(h&&(l=h.value(b)),n=void 0===l?void 0:l/100*n):n=g(d);return n};this.getPropertiesElement=function(d,b,h){for(b=h?h.nextElementSibling:b.firstElementChild;null!==b&&(b.localName!==d||b.namespaceURI!==l);)b=b.nextElementSibling;return b};this.parseAttributeList=function(d){d&&(d=d.replace(/^\s*(.*?)\s*$/g,"$1"));return d&&0<d.length?d.split(/\s+/):[]}};
odf.Style2CSS=function(){function g(a,c,b){var d=[];b=b.derivedStyles;var e;var k=y[a],f;void 0===k?c=null:(f=c?"["+k+'|style-name="'+c+'"]':"","presentation"===k&&(k="draw",f=c?'[presentation|style-name="'+c+'"]':""),c=k+"|"+w[a].join(f+","+k+"|")+f);null!==c&&d.push(c);for(e in b)b.hasOwnProperty(e)&&(c=g(a,e,b[e]),d=d.concat(c));return d}function l(a){var c;if("default-style"===a.localName)return null;c=a.getAttributeNS(m,"parent-style-name");a=a.getAttributeNS(m,"family");return O.getODFElementsWithXPath(F,
c?"//style:*[@style:name='"+c+"'][@style:family='"+a+"']":"//style:default-style[@style:family='"+a+"']",odf.Namespaces.lookupNamespaceURI)[0]}function d(a,c){var b="",d,e,k;for(d=0;d<c.length;d+=1)if(e=c[d],k=a.getAttributeNS(e[0],e[1])){k=k.trim();if(C.hasOwnProperty(e[1])){var f=k;k=f.indexOf(" ");var h;-1!==k?(h=f.substring(0,k),k=f.substring(k)):(h=f,k="");(h=N.parseLength(h))&&"pt"===h.unit&&.75>h.value&&(f="0.75pt"+k);k=f}else if(V.hasOwnProperty(e[1])){var g=a,f=e[0];h=e[1];var n=N.parseLength(k),
p;if(n&&"%"===n.unit){k=n.value/100;g=l(g.parentNode);for(n="0";g;){if(p=x.getDirectChild(g,m,"paragraph-properties"))if(p=N.parseLength(p.getAttributeNS(f,h))){if("%"!==p.unit){n=p.value*k+p.unit;break}k*=p.value/100}g=l(g)}k=n}}e[2]&&(b+=e[2]+":"+k+";")}return b}function b(a,c,b,d){return c+c+b+b+d+d}function h(a,c){var b=[a],d=c.derivedStyles;Object.keys(d).forEach(function(a){a=h(a,d[a]);b=b.concat(a)});return b}function n(a,c,b,d){function e(c,b){var d=[],e;c.forEach(function(a){f.forEach(function(c){d.push('draw|page[webodfhelper|page-style-name="'+
c+'"] draw|frame[presentation|class="'+a+'"]')})});0<d.length&&(e=d.join(",")+"{visibility:"+b+";}",a.insertRule(e,a.cssRules.length))}var f=h(c,d),m=[],g=[];["page-number","date-time","header","footer"].forEach(function(a){var c;c=b.getAttributeNS(k,"display-"+a);"true"===c?m.push(a):"false"===c&&g.push(a)});e(m,"visible");e(g,"hidden")}function r(a,h,C,V){var y,w;if("page"===h){var D=V.element,A="",F,P;C=x.getDirectChild(D,m,"page-layout-properties");var I;if(C)if(I=D.getAttributeNS(m,"name"),A+=
d(C,L),(F=x.getDirectChild(C,m,"background-image"))&&(P=F.getAttributeNS(e,"href"))&&(A=A+("background-image: url('odfkit:"+P+"');")+d(F,t)),"presentation"===T)for(F=(D=x.getDirectChild(D.parentNode.parentNode,f,"master-styles"))&&D.firstElementChild;F;)F.namespaceURI===m&&"master-page"===F.localName&&F.getAttributeNS(m,"page-layout-name")===I&&(P=F.getAttributeNS(m,"name"),D='draw|page[draw|master-page-name="'+P+'"] {'+A+"}",P='office|body, draw|page[draw|master-page-name="'+P+'"] {'+d(C,Q)+" }",
a.insertRule(D,a.cssRules.length),a.insertRule(P,a.cssRules.length)),F=F.nextElementSibling;else"text"===T&&(D="office|text {"+A+"}",P="office|body {width: "+C.getAttributeNS(q,"page-width")+";}",a.insertRule(D,a.cssRules.length),a.insertRule(P,a.cssRules.length))}else{A=g(h,C,V).join(",");I="";if(D=x.getDirectChild(V.element,m,"text-properties")){var O=D,ba=w="";F="";P=1;D=""+d(O,z);y=O.getAttributeNS(m,"text-underline-style");"solid"===y&&(w+=" underline");y=O.getAttributeNS(m,"text-line-through-style");
"solid"===y&&(w+=" line-through");w.length&&(D=D+("text-decoration:"+w+";\n")+("text-decoration-line:"+w+";\n")+("-moz-text-decoration-line:"+w+";\n"));y=O.getAttributeNS(m,"text-line-through-type");switch(y){case "double":ba+=" double";break;case "single":ba+=" single"}ba&&(D=D+("text-decoration-style:"+ba+";\n")+("-moz-text-decoration-style:"+ba+";\n"));if(w=O.getAttributeNS(m,"font-name")||O.getAttributeNS(q,"font-family"))y=M[w],D+="font-family: "+(y||w)+";";if(y=O.getAttributeNS(m,"text-position"))w=
u.parseAttributeList(y),y=w[0],w=w[1],D+="vertical-align: "+y+"\n; ",w&&(P=parseFloat(w)/100);if(O.hasAttributeNS(q,"font-size")||1!==P){for(O=O.parentNode;O;){if(y=(y=x.getDirectChild(O,m,"text-properties"))?N.parseFoFontSize(y.getAttributeNS(q,"font-size")):null){if("%"!==y.unit){F="font-size: "+y.value*P+y.unit+";";break}P*=y.value/100}O=l(O)}F||(F="font-size: "+parseFloat(aa)*P+ea.getUnits(aa)+";")}D+=F;I+=D}if(D=x.getDirectChild(V.element,m,"paragraph-properties"))F=D,D=""+d(F,v),(P=x.getDirectChild(F,
m,"background-image"))&&(O=P.getAttributeNS(e,"href"))&&(D=D+("background-image: url('odfkit:"+O+"');")+d(P,t)),(F=F.getAttributeNS(q,"line-height"))&&"normal"!==F&&(F=N.parseFoLineHeight(F),D="%"!==F.unit?D+("line-height: "+F.value+F.unit+";"):D+("line-height: "+F.value/100+";")),I+=D;if(D=x.getDirectChild(V.element,m,"graphic-properties"))O=D,D=""+d(O,B),F=O.getAttributeNS(p,"opacity"),P=O.getAttributeNS(p,"fill"),O=O.getAttributeNS(p,"fill-color"),"solid"===P||"hatch"===P?O&&"none"!==O?(F=isNaN(parseFloat(F))?
1:parseFloat(F)/100,P=O.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,b),(O=(P=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(P))?{r:parseInt(P[1],16),g:parseInt(P[2],16),b:parseInt(P[3],16)}:null)&&(D+="background-color: rgba("+O.r+","+O.g+","+O.b+","+F+");")):D+="background: none;":"none"===P&&(D+="background: none;"),I+=D;if(D=x.getDirectChild(V.element,m,"drawing-page-properties"))F=D,P=""+d(F,B),"true"===F.getAttributeNS(k,"background-visible")&&(P+="background: none;"),I+=P,n(a,C,D,V);(D=x.getDirectChild(V.element,
m,"table-cell-properties"))&&(I+=""+d(D,J));(D=x.getDirectChild(V.element,m,"table-row-properties"))&&(I+=""+d(D,K));(D=x.getDirectChild(V.element,m,"table-column-properties"))&&(I+=""+d(D,H));if(D=x.getDirectChild(V.element,m,"table-properties"))C=I,I=""+d(D,U),D=D.getAttributeNS(c,"border-model"),"collapsing"===D?I+="border-collapse:collapse;":"separating"===D&&(I+="border-collapse:separate;"),I=C+I;0!==I.length&&a.insertRule(A+"{"+I+"}",a.cssRules.length)}for(var X in V.derivedStyles)V.derivedStyles.hasOwnProperty(X)&&
r(a,h,X,V.derivedStyles[X])}var p=odf.Namespaces.drawns,q=odf.Namespaces.fons,f=odf.Namespaces.officens,m=odf.Namespaces.stylens,a=odf.Namespaces.svgns,c=odf.Namespaces.tablens,e=odf.Namespaces.xlinkns,k=odf.Namespaces.presentationns,x=core.DomUtils,u=new odf.StyleParseUtils,y={graphic:"draw","drawing-page":"draw",paragraph:"text",presentation:"presentation",ruby:"text",section:"text",table:"table","table-cell":"table","table-column":"table","table-row":"table",text:"text",list:"text",page:"office"},
w={graphic:"circle connected control custom-shape ellipse frame g line measure page page-thumbnail path polygon polyline rect regular-polygon".split(" "),paragraph:"alphabetical-index-entry-template h illustration-index-entry-template index-source-style object-index-entry-template p table-index-entry-template table-of-content-entry-template user-index-entry-template".split(" "),presentation:"caption circle connector control custom-shape ellipse frame g line measure page-thumbnail path polygon polyline rect regular-polygon".split(" "),
"drawing-page":"caption circle connector control page custom-shape ellipse frame g line measure page-thumbnail path polygon polyline rect regular-polygon".split(" "),ruby:["ruby","ruby-text"],section:"alphabetical-index bibliography illustration-index index-title object-index section table-of-content table-index user-index".split(" "),table:["background","table"],"table-cell":"body covered-table-cell even-columns even-rows first-column first-row last-column last-row odd-columns odd-rows table-cell".split(" "),
"table-column":["table-column"],"table-row":["table-row"],text:"a index-entry-chapter index-entry-link-end index-entry-link-start index-entry-page-number index-entry-span index-entry-tab-stop index-entry-text index-title-template linenumbering-configuration list-level-style-number list-level-style-bullet outline-level-style span".split(" "),list:["list-item"]},z=[[q,"color","color"],[q,"background-color","background-color"],[q,"font-weight","font-weight"],[q,"font-style","font-style"],[q,"font-variant",
"font-variant"],[q,"letter-spacing","letter-spacing"],[q,"text-transform","text-transform"],[q,"text-shadow","text-shadow"]],t=[[m,"repeat","background-repeat"]],v=[[q,"background-color","background-color"],[q,"text-align","text-align"],[q,"text-indent","text-indent"],[q,"padding","padding"],[q,"padding-left","padding-left"],[q,"padding-right","padding-right"],[q,"padding-top","padding-top"],[q,"padding-bottom","padding-bottom"],[q,"border-left","border-left"],[q,"border-right","border-right"],[q,
"border-top","border-top"],[q,"border-bottom","border-bottom"],[q,"margin","margin"],[q,"margin-left","margin-left"],[q,"margin-right","margin-right"],[q,"margin-top","margin-top"],[q,"margin-bottom","margin-bottom"],[q,"border","border"]],B=[[q,"background-color","background-color"],[q,"min-height","min-height"],[p,"stroke","border"],[a,"stroke-color","border-color"],[a,"stroke-width","border-width"],[q,"border","border"],[q,"border-left","border-left"],[q,"border-right","border-right"],[q,"border-top",
"border-top"],[q,"border-bottom","border-bottom"]],J=[[q,"background-color","background-color"],[q,"border-left","border-left"],[q,"border-right","border-right"],[q,"border-top","border-top"],[q,"border-bottom","border-bottom"],[q,"border","border"]],H=[[m,"column-width","width"]],K=[[m,"row-height","height"],[q,"keep-together",null]],U=[[m,"width","width"],[q,"margin-left","margin-left"],[q,"margin-right","margin-right"],[q,"margin-top","margin-top"],[q,"margin-bottom","margin-bottom"]],L=[[q,"background-color",
"background-color"],[q,"padding","padding"],[q,"padding-left","padding-left"],[q,"padding-right","padding-right"],[q,"padding-top","padding-top"],[q,"padding-bottom","padding-bottom"],[q,"border","border"],[q,"border-left","border-left"],[q,"border-right","border-right"],[q,"border-top","border-top"],[q,"border-bottom","border-bottom"],[q,"margin","margin"],[q,"margin-left","margin-left"],[q,"margin-right","margin-right"],[q,"margin-top","margin-top"],[q,"margin-bottom","margin-bottom"]],Q=[[q,"page-width",
"width"],[q,"page-height","height"]],C={border:!0,"border-left":!0,"border-right":!0,"border-top":!0,"border-bottom":!0,"stroke-width":!0},V={margin:!0,"margin-left":!0,"margin-right":!0,"margin-top":!0,"margin-bottom":!0},M={},N=odf.OdfUtils,T,F,aa,O=xmldom.XPath,ea=new core.CSSUnits;this.style2css=function(a,c,b,d,e){function k(a,c){f="@namespace "+a+" url("+c+");";try{b.insertRule(f,b.cssRules.length)}catch(ha){}}var f,h,m;for(F=c;b.cssRules.length;)b.deleteRule(b.cssRules.length-1);odf.Namespaces.forEachPrefix(k);
k("webodfhelper","urn:webodf:names:helper");M=d;T=a;aa=runtime.getWindow().getComputedStyle(document.body,null).getPropertyValue("font-size")||"12pt";for(m in y)if(y.hasOwnProperty(m))for(h in a=e[m],a)a.hasOwnProperty(h)&&r(b,m,h,a[h])}};
(function(){function g(l,d){var b=this;this.getDistance=function(d){var h=b.x-d.x;d=b.y-d.y;return Math.sqrt(h*h+d*d)};this.getCenter=function(d){return new g((b.x+d.x)/2,(b.y+d.y)/2)};b.x=l;b.y=d}gui.ZoomHelper=function(){function l(a,b,d,e){a=e?"translate3d("+a+"px, "+b+"px, 0) scale3d("+d+", "+d+", 1)":"translate("+a+"px, "+b+"px) scale("+d+")";c.style.WebkitTransform=a;c.style.MozTransform=a;c.style.msTransform=a;c.style.OTransform=a;c.style.transform=a}function d(a){a?l(-e.x,-e.y,u,!0):(l(0,
0,u,!0),l(0,0,u,!1))}function b(a){if(w&&J){var c=w.style.overflow,b=w.classList.contains("webodf-customScrollbars");a&&b||!a&&!b||(a?(w.classList.add("webodf-customScrollbars"),w.style.overflow="hidden",runtime.requestAnimationFrame(function(){w.style.overflow=c})):w.classList.remove("webodf-customScrollbars"))}}function h(){l(-e.x,-e.y,u,!0);w.scrollLeft=0;w.scrollTop=0;H=z.style.overflow;z.style.overflow="visible";b(!1)}function n(){l(0,0,u,!0);w.scrollLeft=e.x;w.scrollTop=e.y;z.style.overflow=
H||"";b(!0)}function r(a){return new g(a.pageX-c.offsetLeft,a.pageY-c.offsetTop)}function p(a){k&&(e.x-=a.x-k.x,e.y-=a.y-k.y,e=new g(Math.min(Math.max(e.x,c.offsetLeft),(c.offsetLeft+c.offsetWidth)*u-w.clientWidth),Math.min(Math.max(e.y,c.offsetTop),(c.offsetTop+c.offsetHeight)*u-w.clientHeight)));k=a}function q(a){var c=a.touches.length,b=0<c?r(a.touches[0]):null;a=1<c?r(a.touches[1]):null;b&&a?(x=b.getDistance(a),y=u,k=b.getCenter(a),h(),B=v.PINCH):b&&(k=b,B=v.SCROLL)}function f(a){var b=a.touches.length,
k=0<b?r(a.touches[0]):null,b=1<b?r(a.touches[1]):null;if(k&&b)if(a.preventDefault(),B===v.SCROLL)B=v.PINCH,h(),x=k.getDistance(b);else{a=k.getCenter(b);k=k.getDistance(b)/x;p(a);var b=u,f=Math.min(4,c.offsetParent.clientWidth/c.offsetWidth);u=y*k;u=Math.min(Math.max(u,f),4);k=u/b;e.x+=(k-1)*(a.x+e.x);e.y+=(k-1)*(a.y+e.y);d(!0)}else k&&(B===v.PINCH?(B=v.SCROLL,n()):p(k))}function m(){B===v.PINCH&&(t.emit(gui.ZoomHelper.signalZoomChanged,u),n(),d(!1));B=v.NONE}function a(){w&&(w.removeEventListener("touchstart",
q,!1),w.removeEventListener("touchmove",f,!1),w.removeEventListener("touchend",m,!1))}var c,e,k,x,u,y,w,z,t=new core.EventNotifier([gui.ZoomHelper.signalZoomChanged]),v={NONE:0,SCROLL:1,PINCH:2},B=v.NONE,J=runtime.getWindow().hasOwnProperty("ontouchstart"),H="";this.subscribe=function(a,c){t.subscribe(a,c)};this.unsubscribe=function(a,c){t.unsubscribe(a,c)};this.getZoomLevel=function(){return u};this.setZoomLevel=function(a){c&&(u=a,d(!1),t.emit(gui.ZoomHelper.signalZoomChanged,u))};this.destroy=
function(c){a();b(!1);c()};this.setZoomableElement=function(e){a();c=e;w=c.offsetParent;z=c.parentNode;d(!1);w&&(w.addEventListener("touchstart",q,!1),w.addEventListener("touchmove",f,!1),w.addEventListener("touchend",m,!1));b(!0)};y=u=1;e=new g(0,0)};gui.ZoomHelper.signalZoomChanged="zoomChanged"})();ops.Canvas=function(){};ops.Canvas.prototype.getZoomLevel=function(){};ops.Canvas.prototype.getElement=function(){};ops.Canvas.prototype.getSizer=function(){};ops.Canvas.prototype.getZoomHelper=function(){};
(function(){function g(){function a(d){b=!0;runtime.setTimeout(function(){try{d()}catch(N){runtime.log(String(N)+"\n"+N.stack)}b=!1;0<c.length&&a(c.pop())},10)}var c=[],b=!1;this.clearQueue=function(){c.length=0};this.addToQueue=function(d){if(0===c.length&&!b)return a(d);c.push(d)}}function l(a){function c(){for(;0<b.cssRules.length;)b.deleteRule(0);b.insertRule("#shadowContent draw|page {display:none;}",0);b.insertRule("office|presentation draw|page {display:none;}",1);b.insertRule("#shadowContent draw|page:nth-of-type("+
d+") {display:block;}",2);b.insertRule("office|presentation draw|page:nth-of-type("+d+") {display:block;}",3)}var b=a.sheet,d=1;this.showFirstPage=function(){d=1;c()};this.showNextPage=function(){d+=1;c()};this.showPreviousPage=function(){1<d&&(--d,c())};this.showPage=function(a){0<a&&(d=a,c())};this.css=a;this.destroy=function(c){a.parentNode.removeChild(a);c()}}function d(a){a=a.sheet;for(var c=a.cssRules;c.length;)a.deleteRule(c.length-1)}function b(a,c,b){var d=new odf.Style2CSS,e=new odf.ListStyleToCss;
b=b.sheet;var k=(new odf.StyleTree(a.rootElement.styles,a.rootElement.automaticStyles)).getStyleTree();d.style2css(a.getDocumentType(),a.rootElement,b,c.getFontMap(),k);e.applyListStyles(b,k,a.rootElement.body)}function h(a,c){(new odf.FontLoader).loadFonts(a,c.sheet)}function n(a,c,b){var d=null;a=a.rootElement.body.getElementsByTagNameNS(K,b+"-decl");b=c.getAttributeNS(K,"use-"+b+"-name");var e;if(b&&0<a.length)for(c=0;c<a.length;c+=1)if(e=a[c],e.getAttributeNS(K,"name")===b){d=e.textContent;break}return d}
function r(a,c,b,d){var e=a.ownerDocument;c=L.getElementsByTagNameNS(a,c,b);for(a=0;a<c.length;a+=1)L.removeAllChildNodes(c[a]),d&&(b=c[a],b.appendChild(e.createTextNode(d)))}function p(a,c,b){c.setAttributeNS("urn:webodf:names:helper","styleid",a);var d,e=c.getAttributeNS(J,"anchor-type"),k=c.getAttributeNS(v,"x"),f=c.getAttributeNS(v,"y"),h=c.getAttributeNS(v,"width"),m=c.getAttributeNS(v,"height"),g=c.getAttributeNS(w,"min-height"),n=c.getAttributeNS(w,"min-width");if("as-char"===e)d="display: inline-block;";
else if(e||k||f)d="position: absolute;";else if(h||m||g||n)d="display: block;";k&&(d+="left: "+k+";");f&&(d+="top: "+f+";");h&&(d+="width: "+h+";");m&&(d+="height: "+m+";");g&&(d+="min-height: "+g+";");n&&(d+="min-width: "+n+";");d&&(d="draw|"+c.localName+'[webodfhelper|styleid="'+a+'"] {'+d+"}",b.insertRule(d,b.cssRules.length))}function q(a){for(a=a.firstChild;a;){if(a.namespaceURI===z&&"binary-data"===a.localName)return"data:image/png;base64,"+a.textContent.replace(/[\r\n\s]/g,"");a=a.nextSibling}return""}
function f(a,c,b,d){function e(c){c&&(c='draw|image[webodfhelper|styleid="'+a+'"] {'+("background-image: url("+c+");")+"}",d.insertRule(c,d.cssRules.length))}function k(a){e(a.url)}b.setAttributeNS("urn:webodf:names:helper","styleid",a);var f=b.getAttributeNS(H,"href"),h;if(f)try{h=c.getPart(f),h.onchange=k,h.load()}catch(O){runtime.log("slight problem: "+String(O))}else f=q(b),e(f)}function m(a){var c=a.ownerDocument;L.getElementsByTagNameNS(a,J,"line-break").forEach(function(a){a.hasChildNodes()||
a.appendChild(c.createElement("br"))})}function a(a){var c=a.ownerDocument;L.getElementsByTagNameNS(a,J,"s").forEach(function(a){var b,d;L.removeAllChildNodes(a);a.appendChild(c.createTextNode(" "));d=parseInt(a.getAttributeNS(J,"c"),10);if(1<d)for(a.removeAttributeNS(J,"c"),b=1;b<d;b+=1)a.parentNode.insertBefore(a.cloneNode(!0),a)})}function c(a){L.getElementsByTagNameNS(a,J,"tab").forEach(function(a){a.textContent="\t"})}function e(a,c){function b(a,b){var d=h.documentElement.namespaceURI;"video/"===
b.substr(0,6)?(e=h.createElementNS(d,"video"),e.setAttribute("controls","controls"),k=h.createElementNS(d,"source"),a&&k.setAttribute("src",a),k.setAttribute("type",b),e.appendChild(k),c.parentNode.appendChild(e)):c.innerHtml="Unrecognised Plugin"}function d(a){b(a.url,a.mimetype)}var e,k,f,h=c.ownerDocument,m;if(f=c.getAttributeNS(H,"href"))try{m=a.getPart(f),m.onchange=d,m.load()}catch(ea){runtime.log("slight problem: "+String(ea))}else runtime.log("using MP4 data fallback"),f=q(c),b(f,"video/mp4")}
function k(a){var c=a.getElementsByTagName("head")[0],b,d;for(d=c.firstElementChild;d&&("style"!==d.localName||!d.hasAttribute("webodfcss"));)d=d.nextElementSibling;if(d)return a=parseInt(d.getAttribute("webodfcss"),10),d.setAttribute("webodfcss",a+1),d;"string"===String(typeof webodf_css)?b=webodf_css:(d="webodf.css",runtime.currentDirectory&&(d=runtime.currentDirectory(),0<d.length&&"/"!==d.substr(-1)&&(d+="/"),d+="../webodf.css"),b=runtime.readFileSync(d,"utf-8"));d=a.createElementNS(c.namespaceURI,
"style");d.setAttribute("media","screen, print, handheld, projection");d.setAttribute("type","text/css");d.setAttribute("webodfcss","1");d.appendChild(a.createTextNode(b));c.appendChild(d);return d}function x(a){var c=parseInt(a.getAttribute("webodfcss"),10);1===c?a.parentNode.removeChild(a):a.setAttribute("count",c-1)}function u(a){var c=a.getElementsByTagName("head")[0],b=a.createElementNS(c.namespaceURI,"style"),d="";b.setAttribute("type","text/css");b.setAttribute("media","screen, print, handheld, projection");
odf.Namespaces.forEachPrefix(function(a,c){d+="@namespace "+a+" url("+c+");\n"});d+="@namespace webodfhelper url(urn:webodf:names:helper);\n";b.appendChild(a.createTextNode(d));c.appendChild(b);return b}var y=odf.Namespaces.drawns,w=odf.Namespaces.fons,z=odf.Namespaces.officens,t=odf.Namespaces.stylens,v=odf.Namespaces.svgns,B=odf.Namespaces.tablens,J=odf.Namespaces.textns,H=odf.Namespaces.xlinkns,K=odf.Namespaces.presentationns,U=xmldom.XPath,L=core.DomUtils;odf.OdfCanvas=function(q,C){function Q(a,
c,b){function d(a,c,b,d){na.addToQueue(function(){f(a,c,b,d)})}var e,k;e=c.getElementsByTagNameNS(y,"image");for(c=0;c<e.length;c+=1)k=e.item(c),d("image"+String(c),a,k,b)}function v(a,c){function b(a,c){na.addToQueue(function(){e(a,c)})}var d,k,f;k=c.getElementsByTagNameNS(y,"plugin");for(d=0;d<k.length;d+=1)f=k.item(d),b(a,f)}function w(){var a;a=S.firstChild;var c=fa.getZoomLevel();a&&(S.style.WebkitTransformOrigin="0% 0%",S.style.MozTransformOrigin="0% 0%",S.style.msTransformOrigin="0% 0%",S.style.OTransformOrigin=
"0% 0%",S.style.transformOrigin="0% 0%",W&&((a=W.getMinimumHeightForAnnotationPane())?S.style.minHeight=a:S.style.removeProperty("min-height")),q.style.width=Math.round(c*S.offsetWidth)+"px",q.style.height=Math.round(c*S.offsetHeight)+"px",q.style.display="inline-block")}function H(b,d){var e=ja.sheet;L.removeAllChildNodes(q);S=ba.createElementNS(q.namespaceURI,"div");S.style.display="inline-block";S.style.background="white";S.style.setProperty("float","left","important");S.appendChild(d);q.appendChild(S);
ga=ba.createElementNS(q.namespaceURI,"div");ga.id="annotationsPane";Z=ba.createElementNS(q.namespaceURI,"div");Z.id="shadowContent";Z.style.position="absolute";Z.style.top=0;Z.style.left=0;b.getContentElement().appendChild(Z);var k=d.body,f,h=[],g;for(f=k.firstElementChild;f&&f!==k;)if(f.namespaceURI===y&&(h[h.length]=f),f.firstElementChild)f=f.firstElementChild;else{for(;f&&f!==k&&!f.nextElementSibling;)f=f.parentNode;f&&f.nextElementSibling&&(f=f.nextElementSibling)}for(g=0;g<h.length;g+=1)f=h[g],
p("frame"+String(g),f,e);h=U.getODFElementsWithXPath(k,".//*[*[@text:anchor-type='paragraph']]",odf.Namespaces.lookupNamespaceURI);for(f=0;f<h.length;f+=1)k=h[f],k.setAttributeNS&&k.setAttributeNS("urn:webodf:names:helper","containsparagraphanchor",!0);k=X;f=Z;var l,x,C,u,M,w;g=b.rootElement.ownerDocument;if((h=d.body.firstElementChild)&&h.namespaceURI===z&&("presentation"===h.localName||"drawing"===h.localName))for(h=h.firstElementChild;h;){if(l=(l=h.getAttributeNS(y,"master-page-name"))?k.getMasterPageElement(l):
null){x=h.getAttributeNS("urn:webodf:names:helper","styleid");C=g.createElementNS(y,"draw:page");w=l.firstElementChild;for(M=0;w;)"true"!==w.getAttributeNS(K,"placeholder")&&(u=w.cloneNode(!0),C.appendChild(u)),w=w.nextElementSibling,M+=1;var V=L.getElementsByTagNameNS(C,y,"frame");for(M=0;M<V.length;M+=1)u=V[M],(w=u.getAttributeNS(K,"class"))&&!/^(date-time|footer|header|page-number)$/.test(w)&&u.parentNode.removeChild(u);u=L.getElementsByTagNameNS(C,y,"*");for(M=0;M<u.length;M+=1)p(x+"_"+M,u[M],
e);f.appendChild(C);M=String(f.getElementsByTagNameNS(y,"page").length);r(C,J,"page-number",M);r(C,K,"header",n(b,h,"header"));r(C,K,"footer",n(b,h,"footer"));p(x,C,e);C.setAttributeNS("urn:webodf:names:helper","page-style-name",h.getAttributeNS(y,"style-name"));C.setAttributeNS(y,"draw:master-page-name",l.getAttributeNS(t,"name"))}h=h.nextElementSibling}k=q.namespaceURI;h=L.getElementsByTagNameNS(d.body,B,"table-cell");for(f=0;f<h.length;f+=1)g=h[f],g.hasAttributeNS(B,"number-columns-spanned")&&
g.setAttributeNS(k,"colspan",g.getAttributeNS(B,"number-columns-spanned")),g.hasAttributeNS(B,"number-rows-spanned")&&g.setAttributeNS(k,"rowspan",g.getAttributeNS(B,"number-rows-spanned"));m(d.body);a(d.body);c(d.body);Q(b,d.body,e);v(b,d.body);S.insertBefore(Z,S.firstChild);fa.setZoomableElement(S)}function F(a){D?(ga.parentNode||S.appendChild(ga),W&&W.forgetAnnotations(),W=new gui.AnnotationViewManager(ea,a.body,ga,Y),a=L.getElementsByTagNameNS(a.body,z,"annotation"),W.addAnnotations(a),w()):ga.parentNode&&
(S.removeChild(ga),W.forgetAnnotations(),w())}function aa(a){function c(){d(I);d(ha);d(ja);L.removeAllChildNodes(q);q.style.display="inline-block";var c=A.rootElement;q.ownerDocument.importNode(c,!0);X.setOdfContainer(A);h(A,I);b(A,X,ha);H(A,c);F(c);a||na.addToQueue(function(){var a=[A];if(da.hasOwnProperty("statereadychange")){var c=da.statereadychange,b;for(b=0;b<c.length;b+=1)c[b].apply(null,a)}})}A.state===odf.OdfContainer.DONE?c():(runtime.log("WARNING: refreshOdf called but ODF was not DONE."),
qa=runtime.setTimeout(function R(){A.state===odf.OdfContainer.DONE?c():(runtime.log("will be back later..."),qa=runtime.setTimeout(R,500))},100))}function O(a){na.clearQueue();L.removeAllChildNodes(q);q.appendChild(q.ownerDocument.createTextNode(runtime.tr("Loading")+a+"..."));q.removeAttribute("style");A=new odf.OdfContainer(a,function(a){A=a;aa(!1)})}runtime.assert(null!==q&&void 0!==q,"odf.OdfCanvas constructor needs DOM element");runtime.assert(null!==q.ownerDocument&&void 0!==q.ownerDocument,
"odf.OdfCanvas constructor needs DOM");var ea=this,ba=q.ownerDocument,A,X=new odf.Formatting,ca,S=null,ga=null,D=!1,Y=!1,W=null,P,I,ha,ja,Z,da={},qa,la,ia=!1,ma=!1,na=new g,fa=new gui.ZoomHelper,ka=C||new gui.SingleScrollViewport(q.parentNode);this.refreshCSS=function(){ia=!0;la.trigger()};this.refreshSize=function(){la.trigger()};this.odfContainer=function(){return A};this.setOdfContainer=function(a,c){A=a;aa(!0===c)};this.load=this.load=O;this.save=function(a){A.save(a)};this.addListener=function(a,
c){switch(a){case "click":q.addEventListener?q.addEventListener(a,c,!1):q.attachEvent?q.attachEvent("on"+a,c):q["on"+a]=c;break;default:var b;b=da.hasOwnProperty(a)?da[a]:da[a]=[];c&&-1===b.indexOf(c)&&b.push(c)}};this.getFormatting=function(){return X};this.getAnnotationViewManager=function(){return W};this.refreshAnnotations=function(){F(A.rootElement)};this.rerenderAnnotations=function(){W&&(ma=!0,la.trigger())};this.getSizer=function(){return S};this.enableAnnotations=function(a,c){a!==D&&(D=
a,Y=c,A&&F(A.rootElement))};this.addAnnotation=function(a){W&&(W.addAnnotations([a]),w())};this.forgetAnnotation=function(a){W&&(W.forgetAnnotation(a),w())};this.getZoomHelper=function(){return fa};this.setZoomLevel=function(a){fa.setZoomLevel(a)};this.getZoomLevel=function(){return fa.getZoomLevel()};this.fitToContainingElement=function(a,c){var b=fa.getZoomLevel(),d=q.offsetHeight/b,b=a/(q.offsetWidth/b);c/d<b&&(b=c/d);fa.setZoomLevel(b)};this.fitToWidth=function(a){var c=q.offsetWidth/fa.getZoomLevel();
fa.setZoomLevel(a/c)};this.fitSmart=function(a,c){var b,d;d=fa.getZoomLevel();b=q.offsetWidth/d;d=q.offsetHeight/d;b=a/b;void 0!==c&&c/d<b&&(b=c/d);fa.setZoomLevel(Math.min(1,b))};this.fitToHeight=function(a){var c=q.offsetHeight/fa.getZoomLevel();fa.setZoomLevel(a/c)};this.showFirstPage=function(){ca.showFirstPage()};this.showNextPage=function(){ca.showNextPage()};this.showPreviousPage=function(){ca.showPreviousPage()};this.showPage=function(a){ca.showPage(a);w()};this.getElement=function(){return q};
this.getViewport=function(){return ka};this.addCssForFrameWithImage=function(a){var c=a.getAttributeNS(y,"name"),b=a.firstElementChild;p(c,a,ja.sheet);b&&f(c+"img",A,b,ja.sheet)};this.destroy=function(a){var c=ba.getElementsByTagName("head")[0],b=[ca.destroy,la.destroy];runtime.clearTimeout(qa);ga&&ga.parentNode&&ga.parentNode.removeChild(ga);fa.destroy(function(){S&&(q.removeChild(S),S=null)});x(P);c.removeChild(I);c.removeChild(ha);c.removeChild(ja);core.Async.destroyAll(b,a)};P=k(ba);ca=new l(u(ba));
I=u(ba);ha=u(ba);ja=u(ba);la=core.Task.createRedrawTask(function(){ia&&(b(A,X,ha),ia=!1);ma&&(W&&W.rerenderAnnotations(),ma=!1);w()});fa.subscribe(gui.ZoomHelper.signalZoomChanged,w)}})();
odf.StepUtils=function(){this.getContentBounds=function(g){var l=g.container(),d,b;runtime.assert(g.isStep(),"Step iterator must be on a step");l.nodeType===Node.TEXT_NODE&&0<g.offset()?d=g.offset():(l=g.leftNode())&&l.nodeType===Node.TEXT_NODE&&(d=l.length);l&&(l.nodeType===Node.TEXT_NODE?(runtime.assert(0<d,"Empty text node found"),b={container:l,startOffset:d-1,endOffset:d}):b={container:l,startOffset:0,endOffset:l.childNodes.length});return b}};ops.MemberProperties=function(){};
ops.Member=function(g,l){var d=new ops.MemberProperties;this.getMemberId=function(){return g};this.getProperties=function(){return d};this.setProperties=function(b){Object.keys(b).forEach(function(h){d[h]=b[h]})};this.removeProperties=function(b){Object.keys(b).forEach(function(b){"fullName"!==b&&"color"!==b&&"imageUrl"!==b&&d.hasOwnProperty(b)&&delete d[b]})};runtime.assert(!!g,"No memberId was supplied!");l.fullName||(l.fullName=runtime.tr("Unknown Author"));l.color||(l.color="black");l.imageUrl||
(l.imageUrl="avatar-joe.png");d=l};ops.Document=function(){};ops.Document.prototype.getMemberIds=function(){};ops.Document.prototype.removeCursor=function(g){};ops.Document.prototype.getDocumentElement=function(){};ops.Document.prototype.getRootNode=function(){};ops.Document.prototype.getDOMDocument=function(){};ops.Document.prototype.cloneDocumentElement=function(){};ops.Document.prototype.setDocumentElement=function(g){};ops.Document.prototype.subscribe=function(g,l){};
ops.Document.prototype.unsubscribe=function(g,l){};ops.Document.prototype.getCanvas=function(){};ops.Document.prototype.createRootFilter=function(g){};ops.Document.prototype.createPositionIterator=function(g){};ops.Document.prototype.hasCursor=function(g){};ops.Document.signalCursorAdded="cursor/added";ops.Document.signalCursorRemoved="cursor/removed";ops.Document.signalCursorMoved="cursor/moved";ops.Document.signalMemberAdded="member/added";ops.Document.signalMemberUpdated="member/updated";
ops.Document.signalMemberRemoved="member/removed";
ops.OdtCursor=function(g,l){var d=this,b={},h,n,r=new core.EventNotifier([ops.OdtCursor.signalCursorUpdated]);this.removeFromDocument=function(){n.remove()};this.subscribe=function(b,d){r.subscribe(b,d)};this.unsubscribe=function(b,d){r.unsubscribe(b,d)};this.getMemberId=function(){return g};this.getNode=function(){return n.getNode()};this.getAnchorNode=function(){return n.getAnchorNode()};this.getSelectedRange=function(){return n.getSelectedRange()};this.setSelectedRange=function(b,h){n.setSelectedRange(b,
h);r.emit(ops.OdtCursor.signalCursorUpdated,d)};this.hasForwardSelection=function(){return n.hasForwardSelection()};this.getDocument=function(){return l};this.getSelectionType=function(){return h};this.setSelectionType=function(d){b.hasOwnProperty(d)?h=d:runtime.log("Invalid selection type: "+d)};this.resetSelectionType=function(){d.setSelectionType(ops.OdtCursor.RangeSelection)};n=new core.Cursor(l.getDOMDocument(),g);b[ops.OdtCursor.RangeSelection]=!0;b[ops.OdtCursor.RegionSelection]=!0;d.resetSelectionType()};
ops.OdtCursor.RangeSelection="Range";ops.OdtCursor.RegionSelection="Region";ops.OdtCursor.signalCursorUpdated="cursorUpdated";
(function(){var g=0;ops.StepsCache=function(l,d,b){function h(a,c){var d=this;this.nodeId=a;this.steps=-1;this.node=c;this.previousBookmark=this.nextBookmark=null;this.setIteratorPosition=function(a){a.setPositionBeforeElement(c);b(d.steps,a)}}function n(a,c,d){var e=this;this.nodeId=a;this.steps=c;this.node=d;this.previousBookmark=this.nextBookmark=null;this.setIteratorPosition=function(a){a.setUnfilteredPosition(d,0);b(e.steps,a)}}function r(a,c){var b="["+a.nodeId;c&&(b+=" => "+c.nodeId);return b+
"]"}function p(){if(!0===ops.StepsCache.ENABLE_CACHE_VERIFICATION){for(var a=u,c,b,d,k=new core.LoopWatchDog(0,1E5),f={};a;){k.check();(c=a.previousBookmark)?runtime.assert(c.nextBookmark===a,"Broken bookmark link to previous @"+r(c,a)):(runtime.assert(a===u,"Broken bookmark link @"+r(a)),runtime.assert(void 0===y||u===u||u.steps<=y,"Base point is damaged @"+r(a)));(b=a.nextBookmark)&&runtime.assert(b.previousBookmark===a,"Broken bookmark link to next @"+r(a,b));if(void 0===y||a===u||a.steps<=y)runtime.assert(x.containsNode(l,
a.node),"Disconnected node is being reported as undamaged @"+r(a)),c&&(d=a.node.compareDocumentPosition(c.node),runtime.assert(0===d||0!==(d&z),"Bookmark order with previous does not reflect DOM order @"+r(c,a))),b&&x.containsNode(l,b.node)&&(d=a.node.compareDocumentPosition(b.node),runtime.assert(0===d||0!==(d&w),"Bookmark order with next does not reflect DOM order @"+r(a,b)));a=a.nextBookmark}Object.keys(e).forEach(function(a){var c=e[a];(void 0===y||a<=y)&&runtime.assert(c.steps<=a,"Bookmark step of "+
c.steps+" exceeds cached step lookup for "+a+" @"+r(c));runtime.assert(!1===f.hasOwnProperty(c.nodeId),"Bookmark "+r(c)+" appears twice in cached step lookup at steps "+f[c.nodeId]+" and "+a);f[c.nodeId]=a})}}function q(a){var c="";a.nodeType===Node.ELEMENT_NODE&&(c=a.getAttributeNS("urn:webodf:names:steps","nodeId")||"");return c}function f(a){var c=g.toString();a.setAttributeNS("urn:webodf:names:steps","nodeId",c);g+=1;return c}function m(a){var c,b,k=new core.LoopWatchDog(0,1E4);void 0!==y&&a>
y&&(a=y);for(c=Math.floor(a/d)*d;!b&&0<=c;)b=e[c],c-=d;for(b=b||u;b.nextBookmark&&b.nextBookmark.steps<=a;)k.check(),b=b.nextBookmark;runtime.assert(-1===a||b.steps<=a,"Bookmark @"+r(b)+" at step "+b.steps+" exceeds requested step of "+a);return b}function a(a){a.previousBookmark&&(a.previousBookmark.nextBookmark=a.nextBookmark);a.nextBookmark&&(a.nextBookmark.previousBookmark=a.previousBookmark)}function c(a){for(var c,b=null;!b&&a&&a!==l;)(c=q(a))&&(b=k[c])&&b.node!==a&&(runtime.log("Cloned node detected. Creating new bookmark"),
b=null,a.removeAttributeNS("urn:webodf:names:steps","nodeId")),a=a.parentNode;return b}var e={},k={},x=core.DomUtils,u,y,w=Node.DOCUMENT_POSITION_FOLLOWING,z=Node.DOCUMENT_POSITION_PRECEDING;this.updateBookmark=function(c,b){var g,n=Math.ceil(c/d)*d,r,t,U;if(void 0!==y&&y<c){r=m(y);for(t=r.nextBookmark;t&&t.steps<=c;)g=t.nextBookmark,U=Math.ceil(t.steps/d)*d,e[U]===t&&delete e[U],x.containsNode(l,t.node)?t.steps=c+1:(a(t),delete k[t.nodeId]),t=g;y=c}else r=m(c);t=q(b)||f(b);g=k[t];g?g.node!==b&&(runtime.log("Cloned node detected. Creating new bookmark"),
t=f(b),g=k[t]=new h(t,b)):g=k[t]=new h(t,b);t=g;t.steps!==c&&(g=Math.ceil(t.steps/d)*d,g!==n&&e[g]===t&&delete e[g],t.steps=c);if(r!==t&&r.nextBookmark!==t){if(r.steps===t.steps)for(;0!==(t.node.compareDocumentPosition(r.node)&w)&&r!==u;)r=r.previousBookmark;r!==t&&r.nextBookmark!==t&&(a(t),g=r.nextBookmark,t.nextBookmark=r.nextBookmark,t.previousBookmark=r,r.nextBookmark=t,g&&(g.previousBookmark=t))}r=e[n];if(!r||t.steps>r.steps)e[n]=t;p()};this.setToClosestStep=function(a,c){var b;p();b=m(a);b.setIteratorPosition(c);
return b.steps};this.setToClosestDomPoint=function(a,b,d){var k,f;p();if(a===l&&0===b)k=u;else if(a===l&&b===l.childNodes.length)for(f in k=u,e)e.hasOwnProperty(f)&&(a=e[f],a.steps>k.steps&&(k=a));else if(k=c(a.childNodes.item(b)||a),!k)for(d.setUnfilteredPosition(a,b);!k&&d.previousNode();)k=c(d.getCurrentNode());k=k||u;void 0!==y&&k.steps>y&&(k=m(y));k.setIteratorPosition(d);return k.steps};this.damageCacheAfterStep=function(a){0>a&&(a=-1);void 0===y?y=a:a<y&&(y=a);p()};(function(){var a=q(l)||
f(l);u=new n(a,0,l)})()};ops.StepsCache.ENABLE_CACHE_VERIFICATION=!1;ops.StepsCache.Bookmark=function(){};ops.StepsCache.Bookmark.prototype.setIteratorPosition=function(g){}})();
(function(){ops.OdtStepsTranslator=function(g,l,d,b){function h(a,b,d){var c=b.getCurrentNode();b.isBeforeNode()&&p.isParagraph(c)&&(d||(a+=1),r.updateBookmark(a,c))}function n(c,b){if(!b||d.acceptPosition(c)===f)return!0;for(;c.previousPosition();)if(d.acceptPosition(c)===f){if(b(m,c.container(),c.unfilteredDomOffset()))return!0;break}for(;c.nextPosition();)if(d.acceptPosition(c)===f){if(b(a,c.container(),c.unfilteredDomOffset()))return!0;break}return!1}var r,p=odf.OdfUtils,q=core.DomUtils,f=core.PositionFilter.FilterResult.FILTER_ACCEPT,
m=core.StepDirection.PREVIOUS,a=core.StepDirection.NEXT;this.convertStepsToDomPoint=function(a){var c,b;if(isNaN(a))throw new TypeError("Requested steps is not numeric ("+a+")");if(0>a)throw new RangeError("Requested steps is negative ("+a+")");for(c=r.setToClosestStep(a,l);c<a&&l.nextPosition();)(b=d.acceptPosition(l)===f)&&(c+=1),h(c,l,b);if(c!==a)throw new RangeError("Requested steps ("+a+") exceeds available steps ("+c+")");return{node:l.container(),offset:l.unfilteredDomOffset()}};this.convertDomPointToSteps=
function(a,b,k){var c;q.containsNode(g,a)||(b=0>q.comparePoints(g,0,a,b),a=g,b=b?0:g.childNodes.length);l.setUnfilteredPosition(a,b);n(l,k)||l.setUnfilteredPosition(a,b);k=l.container();b=l.unfilteredDomOffset();a=r.setToClosestDomPoint(k,b,l);if(0>q.comparePoints(l.container(),l.unfilteredDomOffset(),k,b))return 0<a?a-1:a;for(;(l.container()!==k||l.unfilteredDomOffset()!==b)&&l.nextPosition();)(c=d.acceptPosition(l)===f)&&(a+=1),h(a,l,c);return a+0};this.prime=function(){var a,b;for(a=r.setToClosestStep(0,
l);l.nextPosition();)(b=d.acceptPosition(l)===f)&&(a+=1),h(a,l,b)};this.handleStepsInserted=function(a){r.damageCacheAfterStep(a.position)};this.handleStepsRemoved=function(a){r.damageCacheAfterStep(a.position-1)};r=new ops.StepsCache(g,b,function(a,b){do{if(d.acceptPosition(b)===f){h(a,b,!0);break}h(a-1,b,!1)}while(b.nextPosition())})}})();ops.Operation=function(){};ops.Operation.prototype.init=function(g){};ops.Operation.prototype.execute=function(g){};ops.Operation.prototype.spec=function(){};
ops.TextPositionFilter=function(){function g(b,d){for(;b&&d(b)!==n;)b=b.previousSibling;return b}function l(b,h,f,m){var a;if(h){if(d.isInlineRoot(h)&&d.isGroupingElement(f))return r;m=d.lookLeftForCharacter(h);if(1===m||2===m&&(d.scanRightForAnyCharacter(f)||d.scanRightForAnyCharacter(d.nextNode(b))))return n}else if(d.isGroupingElement(b)&&d.isInlineRoot(g(b.previousSibling,m)))return n;m=null===h&&d.isParagraph(b);a=d.lookRightForCharacter(f);if(m)return a?n:d.scanRightForAnyCharacter(f)?r:n;if(!a)return r;
h=h||d.previousNode(b);return d.scanLeftForAnyCharacter(h)?r:n}var d=odf.OdfUtils,b=Node.ELEMENT_NODE,h=Node.TEXT_NODE,n=core.PositionFilter.FilterResult.FILTER_ACCEPT,r=core.PositionFilter.FilterResult.FILTER_REJECT;this.acceptPosition=function(g){var p=g.container(),f=p.nodeType,m,a,c;if(f!==b&&f!==h)return r;if(f===h){f=g.unfilteredDomOffset();m=p.data;runtime.assert(f!==m.length,"Unexpected offset.");if(0<f){g=m[f-1];if(!d.isODFWhitespace(g))return n;if(1<f)if(g=m[f-2],!d.isODFWhitespace(g))c=
n;else{if(!d.isODFWhitespace(m.substr(0,f)))return r}else a=d.previousNode(p),d.scanLeftForNonSpace(a)&&(c=n);if(c===n)return d.isTrailingWhitespace(p,f)?r:n;g=m[f];return d.isODFWhitespace(g)?r:d.scanLeftForAnyCharacter(d.previousNode(p))?r:n}a=g.leftNode();c=p;p=p.parentNode;c=l(p,a,c,g.getNodeFilter())}else d.isGroupingElement(p)?(a=g.leftNode(),c=g.rightNode(),c=l(p,a,c,g.getNodeFilter())):c=r;return c}};
function RootFilter(g,l,d){var b=core.PositionFilter.FilterResult.FILTER_ACCEPT,h=core.PositionFilter.FilterResult.FILTER_REJECT;this.acceptPosition=function(n){n=n.container();var r;r="string"===typeof g?l[g].getNode():g;return d(n)===d(r)?b:h}}
ops.OdtDocument=function(g){function l(a){return new core.PositionIterator(a,B,K,!1)}function d(){var a=g.odfContainer().getContentElement(),c=a&&a.localName;runtime.assert("text"===c,"Unsupported content element type '"+c+"' for OdtDocument");return a}function b(){return a.getDocumentElement().ownerDocument}function h(a){for(;a&&!(a.namespaceURI===odf.Namespaces.officens&&"text"===a.localName||a.namespaceURI===odf.Namespaces.officens&&"annotation"===a.localName);)a=a.parentNode;return a}function n(a,
c,b,d){d=l(d);var e;1===b.length?e=b[0]:(e=new core.PositionFilterChain,b.forEach(e.addFilter));b=new core.StepIterator(e,d);b.setPosition(a,c);return b}function r(a){var c=l(d());a=t.convertStepsToDomPoint(a);c.setUnfilteredPosition(a.node,a.offset);return c}function p(a){return a===w}function q(c){var b=c.spec(),d=b.memberid,e=(new Date(b.timestamp)).toISOString(),b=g.odfContainer();c.isEdit&&(d=a.getMember(d).getProperties().fullName,b.setMetadata({"dc:creator":d,"dc:date":e},null),d={setProperties:{"dc:creator":d,
"dc:date":e},removedProperties:[]},v||(d.setProperties["meta:editing-cycles"]=b.incrementEditingCycles(),b.setMetadata(null,["meta:editing-duration","meta:document-statistic"])),v=c,a.emit(ops.OdtDocument.signalMetadataUpdated,d))}function f(a){var b,d=[],f,h=2;runtime.assert(a.isStep(),"positionIterator is not at a step");do{if(b=c.getContentBounds(a))if(b=b.container,e.isDowngradableSpaceElement(b)){for(f=b.lastChild;b.firstChild;)d.push(b.firstChild),b.parentNode.insertBefore(b.firstChild,b);b.parentNode.removeChild(b);
a.setPosition(f,f.nodeType===Node.TEXT_NODE?f.length:f.childNodes.length);a.roundToPreviousStep()}--h}while(0<h&&a.nextStep());d.forEach(k.normalizeTextNodes)}function m(a,c,b){a=a.childNodes.item(c)||a;return(a=e.getParagraphElement(a))&&k.containsNode(b,a)?a:b}var a=this,c,e=odf.OdfUtils,k=core.DomUtils,x={},u={},y=new core.EventNotifier([ops.Document.signalMemberAdded,ops.Document.signalMemberUpdated,ops.Document.signalMemberRemoved,ops.Document.signalCursorAdded,ops.Document.signalCursorRemoved,
ops.Document.signalCursorMoved,ops.OdtDocument.signalParagraphChanged,ops.OdtDocument.signalParagraphStyleModified,ops.OdtDocument.signalCommonStyleCreated,ops.OdtDocument.signalCommonStyleDeleted,ops.OdtDocument.signalTableAdded,ops.OdtDocument.signalOperationStart,ops.OdtDocument.signalOperationEnd,ops.OdtDocument.signalProcessingBatchStart,ops.OdtDocument.signalProcessingBatchEnd,ops.OdtDocument.signalUndoStackChanged,ops.OdtDocument.signalStepsInserted,ops.OdtDocument.signalStepsRemoved,ops.OdtDocument.signalMetadataUpdated,
ops.OdtDocument.signalAnnotationAdded]),w=core.StepDirection.NEXT,z,t,v,B=NodeFilter.SHOW_ALL,J=new gui.BlacklistNamespaceNodeFilter(["urn:webodf:names:cursor","urn:webodf:names:editinfo"]),H=new gui.OdfTextBodyNodeFilter,K=new core.NodeFilterChain([J,H]);this.createPositionIterator=l;this.getDocumentElement=function(){return g.odfContainer().rootElement};this.cloneDocumentElement=function(){var c=a.getDocumentElement(),b=g.getAnnotationViewManager();b&&b.forgetAnnotations();c=c.cloneNode(!0);g.refreshAnnotations();
a.fixCursorPositions();return c};this.setDocumentElement=function(a){var c=g.odfContainer();y.unsubscribe(ops.OdtDocument.signalStepsInserted,t.handleStepsInserted);y.unsubscribe(ops.OdtDocument.signalStepsRemoved,t.handleStepsRemoved);c.setRootElement(a);g.setOdfContainer(c,!0);g.refreshCSS();a=d();t=new ops.OdtStepsTranslator(a,l(a),z,500);y.subscribe(ops.OdtDocument.signalStepsInserted,t.handleStepsInserted);y.subscribe(ops.OdtDocument.signalStepsRemoved,t.handleStepsRemoved)};this.getDOMDocument=
b;this.getRootElement=h;this.createStepIterator=n;this.getIteratorAtPosition=r;this.convertCursorStepToDomPoint=function(a){return t.convertStepsToDomPoint(a)};this.convertDomPointToCursorStep=function(a,c,b){var d;b===w&&(d=p);return t.convertDomPointToSteps(a,c,d)};this.convertDomToCursorRange=function(a){var c;c=t.convertDomPointToSteps(a.anchorNode,a.anchorOffset);a=a.anchorNode===a.focusNode&&a.anchorOffset===a.focusOffset?c:t.convertDomPointToSteps(a.focusNode,a.focusOffset);return{position:c,
length:a-c}};this.convertCursorToDomRange=function(a,c){var d=b().createRange(),e,k;e=t.convertStepsToDomPoint(a);c?(k=t.convertStepsToDomPoint(a+c),0<c?(d.setStart(e.node,e.offset),d.setEnd(k.node,k.offset)):(d.setStart(k.node,k.offset),d.setEnd(e.node,e.offset))):d.setStart(e.node,e.offset);return d};this.upgradeWhitespacesAtPosition=function(a){var b=r(a),b=new core.StepIterator(z,b),d,k=2;runtime.assert(b.isStep(),"positionIterator is not at a step (requested step: "+a+")");do{if(d=c.getContentBounds(b))if(a=
d.container,d=d.startOffset,a.nodeType===Node.TEXT_NODE&&e.isSignificantWhitespace(a,d)){runtime.assert(" "===a.data[d],"upgradeWhitespaceToElement: textNode.data[offset] should be a literal space");var f=a.ownerDocument.createElementNS(odf.Namespaces.textns,"text:s"),h=a.parentNode,g=a;f.appendChild(a.ownerDocument.createTextNode(" "));1===a.length?h.replaceChild(f,a):(a.deleteData(d,1),0<d&&(d<a.length&&a.splitText(d),g=a.nextSibling),h.insertBefore(f,g));a=f;b.setPosition(a,a.childNodes.length);
b.roundToPreviousStep()}--k}while(0<k&&b.nextStep())};this.downgradeWhitespaces=f;this.downgradeWhitespacesAtPosition=function(a){a=r(a);a=new core.StepIterator(z,a);f(a)};this.getTextNodeAtStep=function(c,d){var e=r(c),k=e.container(),f,h;k.nodeType===Node.TEXT_NODE?(f=k,h=e.unfilteredDomOffset(),0<f.length&&(0<h&&(f=f.splitText(h)),f.parentNode.insertBefore(b().createTextNode(""),f),f=f.previousSibling,h=0)):(f=b().createTextNode(""),h=0,k.insertBefore(f,e.rightNode()));if(d){if(x[d]&&a.getCursorPosition(d)===
c){for(e=x[d].getNode();e.nextSibling&&"cursor"===e.nextSibling.localName;)e.parentNode.insertBefore(e.nextSibling,e);0<f.length&&f.nextSibling!==e&&(f=b().createTextNode(""),h=0);e.parentNode.insertBefore(f,e)}}else for(;f.nextSibling&&"cursor"===f.nextSibling.localName;)f.parentNode.insertBefore(f.nextSibling,f);for(;f.previousSibling&&f.previousSibling.nodeType===Node.TEXT_NODE;)e=f.previousSibling,e.appendData(f.data),h=e.length,f=e,f.parentNode.removeChild(f.nextSibling);for(;f.nextSibling&&
f.nextSibling.nodeType===Node.TEXT_NODE;)e=f.nextSibling,f.appendData(e.data),f.parentNode.removeChild(e);return{textNode:f,offset:h}};this.fixCursorPositions=function(){Object.keys(x).forEach(function(c){var b=x[c],d=h(b.getNode()),e=a.createRootFilter(d),k,f,g,l=!1;g=b.getSelectedRange();k=m(g.startContainer,g.startOffset,d);f=n(g.startContainer,g.startOffset,[z,e],k);g.collapsed?d=f:(k=m(g.endContainer,g.endOffset,d),d=n(g.endContainer,g.endOffset,[z,e],k));f.isStep()&&d.isStep()?f.container()!==
d.container()||f.offset()!==d.offset()||g.collapsed&&b.getAnchorNode()===b.getNode()||(l=!0,g.setStart(f.container(),f.offset()),g.collapse(!0)):(l=!0,runtime.assert(f.roundToClosestStep(),"No walkable step found for cursor owned by "+c),g.setStart(f.container(),f.offset()),runtime.assert(d.roundToClosestStep(),"No walkable step found for cursor owned by "+c),g.setEnd(d.container(),d.offset()));l&&(b.setSelectedRange(g,b.hasForwardSelection()),a.emit(ops.Document.signalCursorMoved,b))})};this.getCursorPosition=
function(a){return(a=x[a])?t.convertDomPointToSteps(a.getNode(),0):0};this.getCursorSelection=function(a){a=x[a];var c=0,b=0;a&&(c=t.convertDomPointToSteps(a.getNode(),0),b=t.convertDomPointToSteps(a.getAnchorNode(),0));return{position:b,length:c-b}};this.getPositionFilter=function(){return z};this.getOdfCanvas=function(){return g};this.getCanvas=function(){return g};this.getRootNode=d;this.addMember=function(a){runtime.assert(void 0===u[a.getMemberId()],"This member already exists");u[a.getMemberId()]=
a};this.getMember=function(a){return u.hasOwnProperty(a)?u[a]:null};this.removeMember=function(a){delete u[a]};this.getCursor=function(a){return x[a]};this.hasCursor=function(a){return x.hasOwnProperty(a)};this.getMemberIds=function(){return Object.keys(u)};this.addCursor=function(c){runtime.assert(!!c,"OdtDocument::addCursor without cursor");var b=c.getMemberId(),d=a.convertCursorToDomRange(0,0);runtime.assert("string"===typeof b,"OdtDocument::addCursor has cursor without memberid");runtime.assert(!x[b],
"OdtDocument::addCursor is adding a duplicate cursor with memberid "+b);c.setSelectedRange(d,!0);x[b]=c};this.removeCursor=function(c){var b=x[c];return b?(b.removeFromDocument(),delete x[c],a.emit(ops.Document.signalCursorRemoved,c),!0):!1};this.moveCursor=function(c,b,d,e){c=x[c];b=a.convertCursorToDomRange(b,d);c&&(c.setSelectedRange(b,0<=d),c.setSelectionType(e||ops.OdtCursor.RangeSelection))};this.getFormatting=function(){return g.getFormatting()};this.emit=function(a,c){y.emit(a,c)};this.subscribe=
function(a,c){y.subscribe(a,c)};this.unsubscribe=function(a,c){y.unsubscribe(a,c)};this.createRootFilter=function(a){return new RootFilter(a,x,h)};this.close=function(a){a()};this.destroy=function(a){a()};(function(){var a=d();z=new ops.TextPositionFilter;c=new odf.StepUtils;t=new ops.OdtStepsTranslator(a,l(a),z,500);y.subscribe(ops.OdtDocument.signalStepsInserted,t.handleStepsInserted);y.subscribe(ops.OdtDocument.signalStepsRemoved,t.handleStepsRemoved);y.subscribe(ops.OdtDocument.signalOperationEnd,
q);y.subscribe(ops.OdtDocument.signalProcessingBatchEnd,core.Task.processTasks)})()};ops.OdtDocument.signalParagraphChanged="paragraph/changed";ops.OdtDocument.signalTableAdded="table/added";ops.OdtDocument.signalCommonStyleCreated="style/created";ops.OdtDocument.signalCommonStyleDeleted="style/deleted";ops.OdtDocument.signalParagraphStyleModified="paragraphstyle/modified";ops.OdtDocument.signalOperationStart="operation/start";ops.OdtDocument.signalOperationEnd="operation/end";
ops.OdtDocument.signalProcessingBatchStart="router/batchstart";ops.OdtDocument.signalProcessingBatchEnd="router/batchend";ops.OdtDocument.signalUndoStackChanged="undo/changed";ops.OdtDocument.signalStepsInserted="steps/inserted";ops.OdtDocument.signalStepsRemoved="steps/removed";ops.OdtDocument.signalMetadataUpdated="metadata/updated";ops.OdtDocument.signalAnnotationAdded="annotation/added";
ops.OpAddAnnotation=function(){function g(b,d,f){var h=b.getTextNodeAtStep(f,l);h&&(b=h.textNode,f=b.parentNode,h.offset!==b.length&&b.splitText(h.offset),f.insertBefore(d,b.nextSibling),0===b.length&&f.removeChild(b))}var l,d,b,h,n,r;this.init=function(g){l=g.memberid;d=parseInt(g.timestamp,10);b=parseInt(g.position,10);h=void 0!==g.length?parseInt(g.length,10)||0:void 0;n=g.name};this.isEdit=!0;this.group=void 0;this.execute=function(p){var q=p.getCursor(l),f,m;r=p.getDOMDocument();var a=new Date(d),
c,e,k;c=r.createElementNS(odf.Namespaces.officens,"office:annotation");c.setAttributeNS(odf.Namespaces.officens,"office:name",n);f=r.createElementNS(odf.Namespaces.dcns,"dc:creator");f.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",l);f.textContent=p.getMember(l).getProperties().fullName;m=r.createElementNS(odf.Namespaces.dcns,"dc:date");m.appendChild(r.createTextNode(a.toISOString()));a=r.createElementNS(odf.Namespaces.textns,"text:list");e=r.createElementNS(odf.Namespaces.textns,
"text:list-item");k=r.createElementNS(odf.Namespaces.textns,"text:p");e.appendChild(k);a.appendChild(e);c.appendChild(f);c.appendChild(m);c.appendChild(a);void 0!==h&&(f=r.createElementNS(odf.Namespaces.officens,"office:annotation-end"),f.setAttributeNS(odf.Namespaces.officens,"office:name",n),c.annotationEndElement=f,g(p,f,b+h));g(p,c,b);p.emit(ops.OdtDocument.signalStepsInserted,{position:b});q&&(f=r.createRange(),m=c.getElementsByTagNameNS(odf.Namespaces.textns,"p")[0],f.selectNodeContents(m),
q.setSelectedRange(f,!1),q.setSelectionType(ops.OdtCursor.RangeSelection),p.emit(ops.Document.signalCursorMoved,q));p.getOdfCanvas().addAnnotation(c);p.fixCursorPositions();p.emit(ops.OdtDocument.signalAnnotationAdded,{memberId:l,annotation:c});return!0};this.spec=function(){return{optype:"AddAnnotation",memberid:l,timestamp:d,position:b,length:h,name:n}}};
ops.OpAddCursor=function(){var g,l;this.init=function(d){g=d.memberid;l=d.timestamp};this.isEdit=!1;this.group=void 0;this.execute=function(d){var b=d.getCursor(g);if(b)return!1;b=new ops.OdtCursor(g,d);d.addCursor(b);d.emit(ops.Document.signalCursorAdded,b);return!0};this.spec=function(){return{optype:"AddCursor",memberid:g,timestamp:l}}};
ops.OpAddMember=function(){var g,l,d;this.init=function(b){g=b.memberid;l=parseInt(b.timestamp,10);d=b.setProperties};this.isEdit=!1;this.group=void 0;this.execute=function(b){var h;if(b.getMember(g))return!1;h=new ops.Member(g,d);b.addMember(h);b.emit(ops.Document.signalMemberAdded,h);return!0};this.spec=function(){return{optype:"AddMember",memberid:g,timestamp:l,setProperties:d}}};
ops.OpAddStyle=function(){var g,l,d,b,h,n,r=odf.Namespaces.stylens;this.init=function(p){g=p.memberid;l=p.timestamp;d=p.styleName;b=p.styleFamily;h="true"===p.isAutomaticStyle||!0===p.isAutomaticStyle;n=p.setProperties};this.isEdit=!0;this.group=void 0;this.execute=function(g){var l=g.getOdfCanvas().odfContainer(),f=g.getFormatting(),m=g.getDOMDocument().createElementNS(r,"style:style");if(!m)return!1;n&&f.updateStyle(m,n);m.setAttributeNS(r,"style:family",b);m.setAttributeNS(r,"style:name",d);h?
l.rootElement.automaticStyles.appendChild(m):l.rootElement.styles.appendChild(m);g.getOdfCanvas().refreshCSS();h||g.emit(ops.OdtDocument.signalCommonStyleCreated,{name:d,family:b});return!0};this.spec=function(){return{optype:"AddStyle",memberid:g,timestamp:l,styleName:d,styleFamily:b,isAutomaticStyle:h,setProperties:n}}};
odf.ObjectNameGenerator=function(g,l){function d(a,c){var b={};this.generateName=function(){var d=c(),e=0,k;do k=a+e,e+=1;while(b[k]||d[k]);b[k]=!0;return k}}function b(){var a={};[g.rootElement.automaticStyles,g.rootElement.styles].forEach(function(c){for(c=c.firstElementChild;c;)c.namespaceURI===h&&"style"===c.localName&&(a[c.getAttributeNS(h,"name")]=!0),c=c.nextElementSibling});return a}var h=odf.Namespaces.stylens,n=odf.Namespaces.drawns,r=odf.Namespaces.xlinkns,p=(new core.Utils).hashString(l),
q=null,f=null,m=null,a={},c={};this.generateStyleName=function(){null===q&&(q=new d("auto"+p+"_",function(){return b()}));return q.generateName()};this.generateFrameName=function(){var c,b,h;if(null===f){b=g.rootElement.body.getElementsByTagNameNS(n,"frame");for(c=0;c<b.length;c+=1)h=b.item(c),a[h.getAttributeNS(n,"name")]=!0;f=new d("fr"+p+"_",function(){return a})}return f.generateName()};this.generateImageName=function(){var a,b,f;if(null===m){f=g.rootElement.body.getElementsByTagNameNS(n,"image");
for(a=0;a<f.length;a+=1)b=f.item(a),b=b.getAttributeNS(r,"href"),b=b.substring(9,b.lastIndexOf(".")),c[b]=!0;m=new d("img"+p+"_",function(){return c})}return m.generateName()}};
odf.TextStyleApplicator=function(g,l,d){function b(b){function d(a,b){return"object"===typeof a&&"object"===typeof b?Object.keys(a).every(function(c){return d(a[c],b[c])}):a===b}var a={};this.isStyleApplied=function(c){c=l.getAppliedStylesForElement(c,a).styleProperties;return d(b,c)}}function h(b){var f={};this.applyStyleToContainer=function(a){var c;c=a.getAttributeNS(p,"style-name");var e=a.ownerDocument;c=c||"";if(!f.hasOwnProperty(c)){var k=c,h;h=c?l.createDerivedStyleObject(c,"text",b):b;e=
e.createElementNS(q,"style:style");l.updateStyle(e,h);e.setAttributeNS(q,"style:name",g.generateStyleName());e.setAttributeNS(q,"style:family","text");e.setAttributeNS("urn:webodf:names:scope","scope","document-content");d.appendChild(e);f[k]=e}c=f[c].getAttributeNS(q,"name");a.setAttributeNS(p,"text:style-name",c)}}function n(b,d){var a=b.ownerDocument,c=b.parentNode,e,k,f,h=new core.LoopWatchDog(1E4);k=[];k.push(b);for(f=b.nextSibling;f&&r.rangeContainsNode(d,f);)h.check(),k.push(f),f=f.nextSibling;
"span"!==c.localName||c.namespaceURI!==p?(e=a.createElementNS(p,"text:span"),c.insertBefore(e,b),a=!1):(b.previousSibling&&!r.rangeContainsNode(d,c.firstChild)?(e=c.cloneNode(!1),c.parentNode.insertBefore(e,c.nextSibling)):e=c,a=!0);k.forEach(function(a){a.parentNode!==e&&e.appendChild(a)});if(f&&a)for(k=e.cloneNode(!1),e.parentNode.insertBefore(k,e.nextSibling);f;)h.check(),a=f.nextSibling,k.appendChild(f),f=a;return e}var r=core.DomUtils,p=odf.Namespaces.textns,q=odf.Namespaces.stylens;this.applyStyle=
function(d,g,a){var c={},e,k,f,m;runtime.assert(a&&a.hasOwnProperty("style:text-properties"),"applyStyle without any text properties");c["style:text-properties"]=a["style:text-properties"];f=new h(c);m=new b(c);d.forEach(function(a){e=m.isStyleApplied(a);!1===e&&(k=n(a,g),f.applyStyleToContainer(k))})}};
ops.OpApplyDirectStyling=function(){function g(b,d,h){var a=b.getOdfCanvas().odfContainer(),c=p.splitBoundaries(d),e=r.getTextNodes(d,!1);(new odf.TextStyleApplicator(new odf.ObjectNameGenerator(a,l),b.getFormatting(),a.rootElement.automaticStyles)).applyStyle(e,d,h);c.forEach(p.normalizeTextNodes)}var l,d,b,h,n,r=odf.OdfUtils,p=core.DomUtils;this.init=function(g){l=g.memberid;d=g.timestamp;b=parseInt(g.position,10);h=parseInt(g.length,10);n=g.setProperties};this.isEdit=!0;this.group=void 0;this.execute=
function(p){var f=p.convertCursorToDomRange(b,h),m=r.getParagraphElements(f);g(p,f,n);f.detach();p.getOdfCanvas().refreshCSS();p.fixCursorPositions();m.forEach(function(a){p.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:a,memberId:l,timeStamp:d})});p.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"ApplyDirectStyling",memberid:l,timestamp:d,position:b,length:h,setProperties:n}}};
ops.OpApplyHyperlink=function(){function g(b){for(;b;){if(p.isHyperlink(b))return!0;b=b.parentNode}return!1}var l,d,b,h,n,r=core.DomUtils,p=odf.OdfUtils;this.init=function(g){l=g.memberid;d=g.timestamp;b=g.position;h=g.length;n=g.hyperlink};this.isEdit=!0;this.group=void 0;this.execute=function(q){var f=q.getDOMDocument(),m=q.convertCursorToDomRange(b,h),a=r.splitBoundaries(m),c=[],e=p.getTextNodes(m,!1);if(0===e.length)return!1;e.forEach(function(a){var b=p.getParagraphElement(a);runtime.assert(!1===
g(a),"The given range should not contain any link.");var d=n,e=f.createElementNS(odf.Namespaces.textns,"text:a");e.setAttributeNS(odf.Namespaces.xlinkns,"xlink:type","simple");e.setAttributeNS(odf.Namespaces.xlinkns,"xlink:href",d);a.parentNode.insertBefore(e,a);e.appendChild(a);null!==b&&-1===c.indexOf(b)&&c.push(b)});a.forEach(r.normalizeTextNodes);m.detach();q.fixCursorPositions();q.getOdfCanvas().refreshSize();q.getOdfCanvas().rerenderAnnotations();c.forEach(function(a){q.emit(ops.OdtDocument.signalParagraphChanged,
{paragraphElement:a,memberId:l,timeStamp:d})});return!0};this.spec=function(){return{optype:"ApplyHyperlink",memberid:l,timestamp:d,position:b,length:h,hyperlink:n}}};
ops.OpInsertImage=function(){var g,l,d,b,h,n,r,p,q=odf.Namespaces.drawns,f=odf.Namespaces.svgns,m=odf.Namespaces.textns,a=odf.Namespaces.xlinkns,c=odf.OdfUtils;this.init=function(a){g=a.memberid;l=a.timestamp;d=a.position;b=a.filename;h=a.frameWidth;n=a.frameHeight;r=a.frameStyleName;p=a.frameName};this.isEdit=!0;this.group=void 0;this.execute=function(e){var k=e.getOdfCanvas(),x=e.getTextNodeAtStep(d,g),u,y;if(!x)return!1;u=x.textNode;y=c.getParagraphElement(u);var x=x.offset!==u.length?u.splitText(x.offset):
u.nextSibling,w=e.getDOMDocument(),z=w.createElementNS(q,"draw:image"),w=w.createElementNS(q,"draw:frame");z.setAttributeNS(a,"xlink:href",b);z.setAttributeNS(a,"xlink:type","simple");z.setAttributeNS(a,"xlink:show","embed");z.setAttributeNS(a,"xlink:actuate","onLoad");w.setAttributeNS(q,"draw:style-name",r);w.setAttributeNS(q,"draw:name",p);w.setAttributeNS(m,"text:anchor-type","as-char");w.setAttributeNS(f,"svg:width",h);w.setAttributeNS(f,"svg:height",n);w.appendChild(z);u.parentNode.insertBefore(w,
x);e.emit(ops.OdtDocument.signalStepsInserted,{position:d});0===u.length&&u.parentNode.removeChild(u);k.addCssForFrameWithImage(w);k.refreshCSS();e.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:y,memberId:g,timeStamp:l});k.rerenderAnnotations();return!0};this.spec=function(){return{optype:"InsertImage",memberid:g,timestamp:l,filename:b,position:d,frameWidth:h,frameHeight:n,frameStyleName:r,frameName:p}}};
ops.OpInsertTable=function(){function g(a,c){var d;if(1===f.length)d=f[0];else if(3===f.length)switch(a){case 0:d=f[0];break;case b-1:d=f[2];break;default:d=f[1]}else d=f[a];if(1===d.length)return d[0];if(3===d.length)switch(c){case 0:return d[0];case h-1:return d[2];default:return d[1]}return d[c]}var l,d,b,h,n,r,p,q,f,m=odf.OdfUtils;this.init=function(a){l=a.memberid;d=a.timestamp;n=a.position;b=a.initialRows;h=a.initialColumns;r=a.tableName;p=a.tableStyleName;q=a.tableColumnStyleName;f=a.tableCellStyleMatrix};
this.isEdit=!0;this.group=void 0;this.execute=function(a){var c=a.getTextNodeAtStep(n),e=a.getRootNode();if(c){var k=a.getDOMDocument(),f=k.createElementNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:table"),u=k.createElementNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:table-column"),y,w,z,t;p&&f.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:style-name",p);r&&f.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:name",r);u.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0",
"table:number-columns-repeated",h);q&&u.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:style-name",q);f.appendChild(u);for(z=0;z<b;z+=1){u=k.createElementNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:table-row");for(t=0;t<h;t+=1)y=k.createElementNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:table-cell"),(w=g(z,t))&&y.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:style-name",w),w=k.createElementNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0",
"text:p"),y.appendChild(w),u.appendChild(y);f.appendChild(u)}c=m.getParagraphElement(c.textNode);e.insertBefore(f,c.nextSibling);a.emit(ops.OdtDocument.signalStepsInserted,{position:n});a.getOdfCanvas().refreshSize();a.emit(ops.OdtDocument.signalTableAdded,{tableElement:f,memberId:l,timeStamp:d});a.getOdfCanvas().rerenderAnnotations();return!0}return!1};this.spec=function(){return{optype:"InsertTable",memberid:l,timestamp:d,position:n,initialRows:b,initialColumns:h,tableName:r,tableStyleName:p,tableColumnStyleName:q,
tableCellStyleMatrix:f}}};
ops.OpInsertText=function(){function g(b){return"\t"!==b&&r.isODFWhitespace(b)}var l,d,b,h,n,r=odf.OdfUtils;this.init=function(g){l=g.memberid;d=g.timestamp;b=g.position;n=g.text;h="true"===g.moveCursor||!0===g.moveCursor};this.isEdit=!0;this.group=void 0;this.execute=function(p){var q,f,m,a,c=p.getDOMDocument(),e,k=0,x,u=p.getCursor(l),y;p.upgradeWhitespacesAtPosition(b);if(q=p.getTextNodeAtStep(b)){f=q.textNode;a=f.nextSibling;m=f.parentNode;e=r.getParagraphElement(f);for(y=0;y<n.length;y+=1){if(!(x=
"\t"===n[y])){x=n;var w=y;x=g(x[w])&&(0===w||w===x.length-1||g(x[w-1]))}x&&(0===k?(q.offset!==f.length&&(a=f.splitText(q.offset)),0<y&&f.appendData(n.substring(0,y))):k<y&&m.insertBefore(c.createTextNode(n.substring(k,y)),a),k=y+1,"\t"===n[y]?(x=c.createElementNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:tab"),x.appendChild(c.createTextNode("\t"))):(" "!==n[y]&&runtime.log("WARN: InsertText operation contains non-tab, non-space whitespace character (character code "+n.charCodeAt(y)+")"),
x=c.createElementNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:s"),x.appendChild(c.createTextNode(" "))),m.insertBefore(x,a))}0===k?f.insertData(q.offset,n):k<n.length&&m.insertBefore(c.createTextNode(n.substring(k)),a);q=f.parentNode;m=f.nextSibling;q.removeChild(f);q.insertBefore(f,m);0===f.length&&f.parentNode.removeChild(f);p.emit(ops.OdtDocument.signalStepsInserted,{position:b});u&&h&&(p.moveCursor(l,b+n.length,0),p.emit(ops.Document.signalCursorMoved,u));p.downgradeWhitespacesAtPosition(b);
p.downgradeWhitespacesAtPosition(b+n.length);p.getOdfCanvas().refreshSize();p.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:e,memberId:l,timeStamp:d});p.getOdfCanvas().rerenderAnnotations();return!0}return!1};this.spec=function(){return{optype:"InsertText",memberid:l,timestamp:d,position:b,text:n,moveCursor:h}}};
odf.CollapsingRules=function(g){function l(d){return b.isODFNode(d)||"br"===d.localName&&b.isLineBreak(d.parentNode)||d.nodeType===Node.TEXT_NODE&&b.isODFNode(d.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function d(n){var r;n.nodeType===Node.TEXT_NODE?(r=n.parentNode,r.removeChild(n)):r=h.removeUnwantedNodes(n,l);if(n=r)n=r,n=!b.isParagraph(n)&&n!==g&&b.hasNoODFContent(n);return n?d(r):r}var b=odf.OdfUtils,h=core.DomUtils;this.mergeChildrenIntoParent=d};
ops.OpMergeParagraph=function(){function g(a){return odf.OdfUtils.isInlineRoot(a)?NodeFilter.FILTER_SKIP:m.isGroupingElement(a)&&m.hasNoODFContent(a)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function l(a){if(a.nodeType===Node.TEXT_NODE){if(0===a.length)return runtime.log("WARN: Empty text node found during merge operation"),!0;if(m.isODFWhitespace(a.data)&&!1===m.isSignificantWhitespace(a,0))return!0;a="#text"}else a=(a.prefix?a.prefix+":":"")+a.localName;runtime.log("WARN: Unexpected text element found near paragraph boundary ["+
a+"]");return!1}function d(c){c.collapsed||(a.splitBoundaries(c),m.getTextElements(c,!1,!0).filter(l).forEach(function(a){a.parentNode.removeChild(a)}))}function b(a,c,b){a=a.convertCursorStepToDomPoint(c);var d=m.getParagraphElement(a.node,a.offset);runtime.assert(!!d,"Paragraph not found at step "+c);b&&b.setPosition(a.node,a.offset);return d}var h,n,r,p,q,f,m=odf.OdfUtils,a=core.DomUtils,c=odf.Namespaces.textns;this.init=function(a){h=a.memberid;n=a.timestamp;r=a.moveCursor;p=a.paragraphStyleName;
q=parseInt(a.sourceStartPosition,10);f=parseInt(a.destinationStartPosition,10)};this.isEdit=!0;this.group=void 0;this.execute=function(e){var k,m,l=e.getCursor(h);k=e.getRootNode();var y=new odf.CollapsingRules(k),w=e.createStepIterator(k,0,[e.getPositionFilter()],k),z;runtime.assert(f<q,"Destination paragraph ("+f+") must be before source paragraph ("+q+")");m=b(e,f);k=b(e,q,w);w.previousStep();runtime.assert(a.containsNode(m,w.container()),"Destination paragraph must be adjacent to the source paragraph");
z=m.ownerDocument.createRange();w.setPosition(m,m.childNodes.length);w.roundToPreviousStep();z.setStart(w.container(),w.offset());z.setEnd(m,m.childNodes.length);d(z);z=m.childNodes.length;var t=k.ownerDocument.createRange();w.setPosition(k,0);w.roundToNextStep();t.setStart(k,0);t.setEnd(w.container(),w.offset());d(t);for(t=k.firstChild;t;)"editinfo"===t.localName?k.removeChild(t):(m.appendChild(t),a.removeUnwantedNodes(t,g)),t=k.firstChild;runtime.assert(0===k.childNodes.length,"Source paragraph should be empty before it is removed");
y.mergeChildrenIntoParent(k);e.emit(ops.OdtDocument.signalStepsRemoved,{position:q-1});w.setPosition(m,z);w.roundToClosestStep();w.previousStep()||w.roundToNextStep();e.downgradeWhitespaces(w);p?m.setAttributeNS(c,"text:style-name",p):m.removeAttributeNS(c,"style-name");l&&r&&(e.moveCursor(h,q-1,0),e.emit(ops.Document.signalCursorMoved,l));e.fixCursorPositions();e.getOdfCanvas().refreshSize();e.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:m,memberId:h,timeStamp:n});e.getOdfCanvas().rerenderAnnotations();
return!0};this.spec=function(){return{optype:"MergeParagraph",memberid:h,timestamp:n,moveCursor:r,paragraphStyleName:p,sourceStartPosition:q,destinationStartPosition:f}}};
ops.OpMoveCursor=function(){var g,l,d,b,h;this.init=function(n){g=n.memberid;l=n.timestamp;d=n.position;b=n.length||0;h=n.selectionType||ops.OdtCursor.RangeSelection};this.isEdit=!1;this.group=void 0;this.execute=function(n){var l=n.getCursor(g),p;if(!l)return!1;p=n.convertCursorToDomRange(d,b);l.setSelectedRange(p,0<=b);l.setSelectionType(h);n.emit(ops.Document.signalCursorMoved,l);return!0};this.spec=function(){return{optype:"MoveCursor",memberid:g,timestamp:l,position:d,length:b,selectionType:h}}};
ops.OpRemoveAnnotation=function(){var g,l,d,b,h=core.DomUtils;this.init=function(h){g=h.memberid;l=h.timestamp;d=parseInt(h.position,10);b=parseInt(h.length,10)};this.isEdit=!0;this.group=void 0;this.execute=function(b){function g(b){n.parentNode.insertBefore(b,n)}for(var l=b.getIteratorAtPosition(d).container(),n;l.namespaceURI!==odf.Namespaces.officens||"annotation"!==l.localName;)l=l.parentNode;if(null===l)return!1;n=l;l=n.annotationEndElement;b.getOdfCanvas().forgetAnnotation(n);h.getElementsByTagNameNS(n,
"urn:webodf:names:cursor","cursor").forEach(g);h.getElementsByTagNameNS(n,"urn:webodf:names:cursor","anchor").forEach(g);n.parentNode.removeChild(n);l&&l.parentNode.removeChild(l);b.emit(ops.OdtDocument.signalStepsRemoved,{position:0<d?d-1:d});b.getOdfCanvas().rerenderAnnotations();b.fixCursorPositions();return!0};this.spec=function(){return{optype:"RemoveAnnotation",memberid:g,timestamp:l,position:d,length:b}}};
ops.OpRemoveBlob=function(){var g,l,d;this.init=function(b){g=b.memberid;l=b.timestamp;d=b.filename};this.isEdit=!0;this.group=void 0;this.execute=function(b){b.getOdfCanvas().odfContainer().removeBlob(d);return!0};this.spec=function(){return{optype:"RemoveBlob",memberid:g,timestamp:l,filename:d}}};
ops.OpRemoveCursor=function(){var g,l;this.init=function(d){g=d.memberid;l=d.timestamp};this.isEdit=!1;this.group=void 0;this.execute=function(d){return d.removeCursor(g)?!0:!1};this.spec=function(){return{optype:"RemoveCursor",memberid:g,timestamp:l}}};
ops.OpRemoveHyperlink=function(){var g,l,d,b,h=core.DomUtils,n=odf.OdfUtils;this.init=function(h){g=h.memberid;l=h.timestamp;d=h.position;b=h.length};this.isEdit=!0;this.group=void 0;this.execute=function(r){var p=r.convertCursorToDomRange(d,b),q=n.getHyperlinkElements(p);runtime.assert(1===q.length,"The given range should only contain a single link.");q=h.mergeIntoParent(q[0]);p.detach();r.fixCursorPositions();r.getOdfCanvas().refreshSize();r.getOdfCanvas().rerenderAnnotations();r.emit(ops.OdtDocument.signalParagraphChanged,
{paragraphElement:n.getParagraphElement(q),memberId:g,timeStamp:l});return!0};this.spec=function(){return{optype:"RemoveHyperlink",memberid:g,timestamp:l,position:d,length:b}}};ops.OpRemoveMember=function(){var g,l;this.init=function(d){g=d.memberid;l=parseInt(d.timestamp,10)};this.isEdit=!1;this.group=void 0;this.execute=function(d){if(!d.getMember(g))return!1;d.removeMember(g);d.emit(ops.Document.signalMemberRemoved,g);return!0};this.spec=function(){return{optype:"RemoveMember",memberid:g,timestamp:l}}};
ops.OpRemoveStyle=function(){var g,l,d,b;this.init=function(h){g=h.memberid;l=h.timestamp;d=h.styleName;b=h.styleFamily};this.isEdit=!0;this.group=void 0;this.execute=function(h){var g=h.getFormatting().getStyleElement(d,b);if(!g)return!1;g.parentNode.removeChild(g);h.getOdfCanvas().refreshCSS();h.emit(ops.OdtDocument.signalCommonStyleDeleted,{name:d,family:b});return!0};this.spec=function(){return{optype:"RemoveStyle",memberid:g,timestamp:l,styleName:d,styleFamily:b}}};
ops.OpRemoveText=function(){var g,l,d,b,h=odf.OdfUtils,n=core.DomUtils;this.init=function(h){runtime.assert(0<=h.length,"OpRemoveText only supports positive lengths");g=h.memberid;l=h.timestamp;d=parseInt(h.position,10);b=parseInt(h.length,10)};this.isEdit=!0;this.group=void 0;this.execute=function(r){var p,q,f,m=r.getCursor(g),a=new odf.CollapsingRules(r.getRootNode());r.upgradeWhitespacesAtPosition(d);r.upgradeWhitespacesAtPosition(d+b);p=r.convertCursorToDomRange(d,b);n.splitBoundaries(p);q=h.getTextElements(p,
!1,!0);f=h.getParagraphElement(p.startContainer,p.startOffset);runtime.assert(void 0!==f,"Attempting to remove text outside a paragraph element");p.detach();q.forEach(function(c){c.parentNode?(runtime.assert(n.containsNode(f,c),"RemoveText only supports removing elements within the same paragraph"),a.mergeChildrenIntoParent(c)):runtime.log("WARN: text element has already been removed from it's container")});r.emit(ops.OdtDocument.signalStepsRemoved,{position:d});r.downgradeWhitespacesAtPosition(d);
r.fixCursorPositions();r.getOdfCanvas().refreshSize();r.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:f,memberId:g,timeStamp:l});m&&(m.resetSelectionType(),r.emit(ops.Document.signalCursorMoved,m));r.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"RemoveText",memberid:g,timestamp:l,position:d,length:b}}};
ops.OpSetBlob=function(){var g,l,d,b,h;this.init=function(n){g=n.memberid;l=n.timestamp;d=n.filename;b=n.mimetype;h=n.content};this.isEdit=!0;this.group=void 0;this.execute=function(g){g.getOdfCanvas().odfContainer().setBlob(d,b,h);return!0};this.spec=function(){return{optype:"SetBlob",memberid:g,timestamp:l,filename:d,mimetype:b,content:h}}};
ops.OpSetParagraphStyle=function(){function g(b,d,h){var f=[b.getPositionFilter()],g=h.container();h=h.unfilteredDomOffset();return!1===b.createStepIterator(g,h,f,d).previousStep()}var l,d,b,h,n=odf.OdfUtils;this.init=function(g){l=g.memberid;d=g.timestamp;b=g.position;h=g.styleName};this.isEdit=!0;this.group=void 0;this.execute=function(r){var p,q;p=r.getIteratorAtPosition(b);return(q=n.getParagraphElement(p.container()))?(runtime.assert(g(r,q,p),"SetParagraphStyle position should be the first position in the paragraph"),
h?q.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:style-name",h):q.removeAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","style-name"),r.getOdfCanvas().refreshSize(),r.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:q,timeStamp:d,memberId:l}),r.getOdfCanvas().rerenderAnnotations(),!0):!1};this.spec=function(){return{optype:"SetParagraphStyle",memberid:l,timestamp:d,position:b,styleName:h}}};
ops.OpSplitParagraph=function(){var g,l,d,b,h,n,r=odf.OdfUtils,p=odf.Namespaces.textns;this.init=function(p){g=p.memberid;l=p.timestamp;b=p.position;d=p.sourceParagraphPosition;n=p.paragraphStyleName;h="true"===p.moveCursor||!0===p.moveCursor};this.isEdit=!0;this.group=void 0;this.execute=function(d){var f,m,a,c,e,k,q,u=d.getCursor(g);d.upgradeWhitespacesAtPosition(b);f=d.getTextNodeAtStep(b);if(!f)return!1;m=r.getParagraphElement(f.textNode);if(!m)return!1;a=r.isListItem(m.parentNode)?m.parentNode:
m;0===f.offset?(q=f.textNode.previousSibling,k=null):(q=f.textNode,k=f.offset>=f.textNode.length?null:f.textNode.splitText(f.offset));for(c=f.textNode;c!==a;){c=c.parentNode;e=c.cloneNode(!1);k&&e.appendChild(k);if(q)for(;q&&q.nextSibling;)e.appendChild(q.nextSibling);else for(;c.firstChild;)e.appendChild(c.firstChild);c.parentNode.insertBefore(e,c.nextSibling);q=c;k=e}r.isListItem(k)&&(k=k.childNodes.item(0));n?k.setAttributeNS(p,"text:style-name",n):k.removeAttributeNS(p,"style-name");0===f.textNode.length&&
f.textNode.parentNode.removeChild(f.textNode);d.emit(ops.OdtDocument.signalStepsInserted,{position:b});u&&h&&(d.moveCursor(g,b+1,0),d.emit(ops.Document.signalCursorMoved,u));d.fixCursorPositions();d.getOdfCanvas().refreshSize();d.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:m,memberId:g,timeStamp:l});d.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:k,memberId:g,timeStamp:l});d.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph",
memberid:g,timestamp:l,position:b,sourceParagraphPosition:d,paragraphStyleName:n,moveCursor:h}}};
ops.OpUpdateMember=function(){function g(d){var h="//dc:creator[@editinfo:memberid='"+l+"']";d=xmldom.XPath.getODFElementsWithXPath(d.getRootNode(),h,function(b){return"editinfo"===b?"urn:webodf:names:editinfo":odf.Namespaces.lookupNamespaceURI(b)});for(h=0;h<d.length;h+=1)d[h].textContent=b.fullName}var l,d,b,h;this.init=function(g){l=g.memberid;d=parseInt(g.timestamp,10);b=g.setProperties;h=g.removedProperties};this.isEdit=!1;this.group=void 0;this.execute=function(d){var n=d.getMember(l);if(!n)return!1;
h&&n.removeProperties(h);b&&(n.setProperties(b),b.fullName&&g(d));d.emit(ops.Document.signalMemberUpdated,n);return!0};this.spec=function(){return{optype:"UpdateMember",memberid:l,timestamp:d,setProperties:b,removedProperties:h}}};
ops.OpUpdateMetadata=function(){var g,l,d,b;this.init=function(h){g=h.memberid;l=parseInt(h.timestamp,10);d=h.setProperties;b=h.removedProperties};this.isEdit=!0;this.group=void 0;this.execute=function(h){var g=h.getOdfCanvas().odfContainer(),l=null;b&&(l=b.attributes.split(","));g.setMetadata(d,l);h.emit(ops.OdtDocument.signalMetadataUpdated,{setProperties:null!==d?d:{},removedProperties:null!==l?l:[]});return!0};this.spec=function(){return{optype:"UpdateMetadata",memberid:g,timestamp:l,setProperties:d,
removedProperties:b}}};
ops.OpUpdateParagraphStyle=function(){function g(b,d){var f,h,a=d?d.split(","):[];for(f=0;f<a.length;f+=1)h=a[f].split(":"),b.removeAttributeNS(odf.Namespaces.lookupNamespaceURI(h[0]),h[1])}var l,d,b,h,n,r=odf.Namespaces.stylens;this.init=function(g){l=g.memberid;d=g.timestamp;b=g.styleName;h=g.setProperties;n=g.removedProperties};this.isEdit=!0;this.group=void 0;this.execute=function(d){var l=d.getFormatting(),f,m,a;return(f=""!==b?l.getStyleElement(b,"paragraph"):l.getDefaultStyleElement("paragraph"))?(m=
f.getElementsByTagNameNS(r,"paragraph-properties").item(0),a=f.getElementsByTagNameNS(r,"text-properties").item(0),h&&l.updateStyle(f,h),n&&(l=n["style:paragraph-properties"],m&&l&&(g(m,l.attributes),0===m.attributes.length&&f.removeChild(m)),l=n["style:text-properties"],a&&l&&(g(a,l.attributes),0===a.attributes.length&&f.removeChild(a)),g(f,n.attributes)),d.getOdfCanvas().refreshCSS(),d.emit(ops.OdtDocument.signalParagraphStyleModified,b),d.getOdfCanvas().rerenderAnnotations(),!0):!1};this.spec=
function(){return{optype:"UpdateParagraphStyle",memberid:l,timestamp:d,styleName:b,setProperties:h,removedProperties:n}}};
ops.OperationFactory=function(){function g(d){return function(b){return new d}}var l;this.register=function(d,b){l[d]=b};this.create=function(d){var b=null,h=l[d.optype];h&&(b=h(d),b.init(d));return b};l={AddMember:g(ops.OpAddMember),UpdateMember:g(ops.OpUpdateMember),RemoveMember:g(ops.OpRemoveMember),AddCursor:g(ops.OpAddCursor),ApplyDirectStyling:g(ops.OpApplyDirectStyling),SetBlob:g(ops.OpSetBlob),RemoveBlob:g(ops.OpRemoveBlob),InsertImage:g(ops.OpInsertImage),InsertTable:g(ops.OpInsertTable),
InsertText:g(ops.OpInsertText),RemoveText:g(ops.OpRemoveText),MergeParagraph:g(ops.OpMergeParagraph),SplitParagraph:g(ops.OpSplitParagraph),SetParagraphStyle:g(ops.OpSetParagraphStyle),UpdateParagraphStyle:g(ops.OpUpdateParagraphStyle),AddStyle:g(ops.OpAddStyle),RemoveStyle:g(ops.OpRemoveStyle),MoveCursor:g(ops.OpMoveCursor),RemoveCursor:g(ops.OpRemoveCursor),AddAnnotation:g(ops.OpAddAnnotation),RemoveAnnotation:g(ops.OpRemoveAnnotation),UpdateMetadata:g(ops.OpUpdateMetadata),ApplyHyperlink:g(ops.OpApplyHyperlink),
RemoveHyperlink:g(ops.OpRemoveHyperlink)}};ops.OperationRouter=function(){};ops.OperationRouter.prototype.setOperationFactory=function(g){};ops.OperationRouter.prototype.setPlaybackFunction=function(g){};ops.OperationRouter.prototype.push=function(g){};ops.OperationRouter.prototype.close=function(g){};ops.OperationRouter.prototype.subscribe=function(g,l){};ops.OperationRouter.prototype.unsubscribe=function(g,l){};ops.OperationRouter.prototype.hasLocalUnsyncedOps=function(){};
ops.OperationRouter.prototype.hasSessionHostConnection=function(){};ops.OperationRouter.signalProcessingBatchStart="router/batchstart";ops.OperationRouter.signalProcessingBatchEnd="router/batchend";
ops.TrivialOperationRouter=function(){var g=new core.EventNotifier([ops.OperationRouter.signalProcessingBatchStart,ops.OperationRouter.signalProcessingBatchEnd]),l,d,b=0;this.setOperationFactory=function(b){l=b};this.setPlaybackFunction=function(b){d=b};this.push=function(h){b+=1;g.emit(ops.OperationRouter.signalProcessingBatchStart,{});h.forEach(function(h){h=h.spec();h.timestamp=Date.now();h=l.create(h);h.group="g"+b;d(h)});g.emit(ops.OperationRouter.signalProcessingBatchEnd,{})};this.close=function(b){b()};
this.subscribe=function(b,d){g.subscribe(b,d)};this.unsubscribe=function(b,d){g.unsubscribe(b,d)};this.hasLocalUnsyncedOps=function(){return!1};this.hasSessionHostConnection=function(){return!0}};
ops.Session=function(g){function l(b){h.emit(ops.OdtDocument.signalProcessingBatchStart,b)}function d(b){h.emit(ops.OdtDocument.signalProcessingBatchEnd,b)}var b=new ops.OperationFactory,h=new ops.OdtDocument(g),n=null;this.setOperationFactory=function(d){b=d;n&&n.setOperationFactory(b)};this.setOperationRouter=function(g){n&&(n.unsubscribe(ops.OperationRouter.signalProcessingBatchStart,l),n.unsubscribe(ops.OperationRouter.signalProcessingBatchEnd,d));n=g;n.subscribe(ops.OperationRouter.signalProcessingBatchStart,
l);n.subscribe(ops.OperationRouter.signalProcessingBatchEnd,d);g.setPlaybackFunction(function(b){h.emit(ops.OdtDocument.signalOperationStart,b);return b.execute(h)?(h.emit(ops.OdtDocument.signalOperationEnd,b),!0):!1});g.setOperationFactory(b)};this.getOperationFactory=function(){return b};this.getOdtDocument=function(){return h};this.enqueue=function(b){n.push(b)};this.close=function(b){n.close(function(d){d?b(d):h.close(b)})};this.destroy=function(b){h.destroy(b)};this.setOperationRouter(new ops.TrivialOperationRouter)};
gui.AnnotationController=function(g,l,d){function b(){var a=p.getCursor(d),a=a&&a.getNode(),b=!1;a&&(b=!m.isWithinAnnotation(a,p.getRootNode()));b!==q&&(q=b,f.emit(gui.AnnotationController.annotatableChanged,q))}function h(a){a.getMemberId()===d&&b()}function n(a){a===d&&b()}function r(a){a.getMemberId()===d&&b()}var p=g.getOdtDocument(),q=!1,f=new core.EventNotifier([gui.AnnotationController.annotatableChanged]),m=odf.OdfUtils,a=core.StepDirection.NEXT;this.isAnnotatable=function(){return q};this.addAnnotation=
function(){var a=new ops.OpAddAnnotation,b=p.getCursorSelection(d),f=b.length,b=b.position;q&&(0===f?f=void 0:(b=0<=f?b:b+f,f=Math.abs(f)),a.init({memberid:d,position:b,length:f,name:d+Date.now()}),g.enqueue([a]))};this.removeAnnotation=function(c){var b,f;b=p.getMember(d).getProperties().fullName;if(!0!==l.getState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN)||b===m.getAnnotationCreator(c))b=p.convertDomPointToCursorStep(c,0,a),f=p.convertDomPointToCursorStep(c,c.childNodes.length),c=
new ops.OpRemoveAnnotation,c.init({memberid:d,position:b,length:f-b}),f=new ops.OpMoveCursor,f.init({memberid:d,position:0<b?b-1:b,length:0}),g.enqueue([c,f])};this.subscribe=function(a,b){f.subscribe(a,b)};this.unsubscribe=function(a,b){f.unsubscribe(a,b)};this.destroy=function(a){p.unsubscribe(ops.Document.signalCursorAdded,h);p.unsubscribe(ops.Document.signalCursorRemoved,n);p.unsubscribe(ops.Document.signalCursorMoved,r);a()};l.registerConstraint(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN);
p.subscribe(ops.Document.signalCursorAdded,h);p.subscribe(ops.Document.signalCursorRemoved,n);p.subscribe(ops.Document.signalCursorMoved,r);b()};gui.AnnotationController.annotatableChanged="annotatable/changed";
gui.Avatar=function(g,l){var d=this,b,h,n;this.setColor=function(b){h.style.borderColor=b};this.setImageUrl=function(b){d.isVisible()?h.src=b:n=b};this.isVisible=function(){return"block"===b.style.display};this.show=function(){n&&(h.src=n,n=void 0);b.style.display="block"};this.hide=function(){b.style.display="none"};this.markAsFocussed=function(d){d?b.classList.add("active"):b.classList.remove("active")};this.destroy=function(d){g.removeChild(b);d()};(function(){var d=g.ownerDocument;b=d.createElement("div");
h=d.createElement("img");b.appendChild(h);b.style.display=l?"block":"none";b.className="handle";g.appendChild(b)})()};gui.StepInfo=function(){};gui.StepInfo.VisualDirection={LEFT_TO_RIGHT:0,RIGHT_TO_LEFT:1};gui.StepInfo.prototype.container=function(){};gui.StepInfo.prototype.offset=function(){};gui.VisualStepScanner=function(){};gui.VisualStepScanner.prototype.process=function(g,l,d){};
gui.GuiStepUtils=function(){function g(h){h=d.getContentBounds(h);var g,f=null;if(h)if(h.container.nodeType===Node.TEXT_NODE)g=h.container.ownerDocument.createRange(),g.setStart(h.container,h.startOffset),g.setEnd(h.container,h.endOffset),(f=0<g.getClientRects().length?g.getBoundingClientRect():null)&&" "===h.container.data.substring(h.startOffset,h.endOffset)&&1>=f.width&&(f=null),g.detach();else if(l.isCharacterElement(h.container)||l.isCharacterFrame(h.container))f=b.getBoundingClientRect(h.container);
return f}var l=odf.OdfUtils,d=new odf.StepUtils,b=core.DomUtils,h=core.StepDirection.NEXT,n=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT,r=gui.StepInfo.VisualDirection.RIGHT_TO_LEFT;this.getContentRect=g;this.moveToFilteredStep=function(b,d,f){function m(a,b){b.process(w,k,l)&&(a=!0,!p&&b.token&&(p=b.token));return a}var a=d===h,c,e,k,l,p,q=b.snapshot();c=!1;var w;do c=g(b),w={token:b.snapshot(),container:b.container,offset:b.offset,direction:d,visualDirection:d===h?n:r},e=b.nextStep()?g(b):null,b.restore(w.token),
a?(k=c,l=e):(k=e,l=c),c=f.reduce(m,!1);while(!c&&b.advanceStep(d));c||f.forEach(function(a){!p&&a.token&&(p=a.token)});b.restore(p||q);return!!p}};
gui.Caret=function(g,l,d,b){function h(){a.style.opacity="0"===a.style.opacity?"1":"0";v.trigger()}function n(){x.selectNodeContents(k);return x.getBoundingClientRect()}function r(a){return U[a]!==K[a]}function p(){Object.keys(K).forEach(function(a){U[a]=K[a]})}function q(){if(!1===K.isShown||g.getSelectionType()!==ops.OdtCursor.RangeSelection||!b&&!g.getSelectedRange().collapsed)K.visibility="hidden",a.style.visibility="hidden",v.cancel();else if(K.visibility="visible",a.style.visibility="visible",
!1===K.isFocused)a.style.opacity="1",v.cancel();else{if(B||r("visibility"))a.style.opacity="1",v.cancel();v.trigger()}if(H||J){var d;d=g.getNode();var f,k,h=y.getBoundingClientRect(u.getSizer()),q=!1,x=0;d.removeAttributeNS("urn:webodf:names:cursor","caret-sizer-active");if(0<d.getClientRects().length)k=n(),x=k.left-y.getBoundingClientRect(d).left,q=!0;else if(z.setPosition(d,0),k=w.getContentRect(z),!k&&z.nextStep()&&(f=w.getContentRect(z))&&(k=f,q=!0),k||(d.setAttributeNS("urn:webodf:names:cursor",
"caret-sizer-active","true"),k=n(),q=!0),!k)for(runtime.log("WARN: No suitable client rectangle found for visual caret for "+g.getMemberId());d;){if(0<d.getClientRects().length){k=y.getBoundingClientRect(d);q=!0;break}d=d.parentNode}k=y.translateRect(k,h,u.getZoomLevel());d={top:k.top,height:k.height,right:q?k.left:k.right,width:y.adaptRangeDifferenceToZoomLevel(x,u.getZoomLevel())};8>d.height&&(d={top:d.top-(8-d.height)/2,height:8,right:d.right});m.style.height=d.height+"px";m.style.top=d.top+"px";
m.style.left=d.right-d.width+"px";m.style.width=d.width?d.width+"px":"";e&&(d=runtime.getWindow().getComputedStyle(g.getNode(),null),d.font?e.style.font=d.font:(e.style.fontStyle=d.fontStyle,e.style.fontVariant=d.fontVariant,e.style.fontWeight=d.fontWeight,e.style.fontSize=d.fontSize,e.style.lineHeight=d.lineHeight,e.style.fontFamily=d.fontFamily))}K.isShown&&J&&l.scrollIntoView(a.getBoundingClientRect());r("isFocused")&&c.markAsFocussed(K.isFocused);p();H=J=B=!1}function f(a){m.parentNode.removeChild(m);
k.parentNode.removeChild(k);a()}var m,a,c,e,k,x,u=g.getDocument().getCanvas(),y=core.DomUtils,w=new gui.GuiStepUtils,z,t,v,B=!1,J=!1,H=!1,K={isFocused:!1,isShown:!0,visibility:"hidden"},U={isFocused:!K.isFocused,isShown:!K.isShown,visibility:"hidden"};this.handleUpdate=function(){H=!0;t.trigger()};this.refreshCursorBlinking=function(){B=!0;t.trigger()};this.setFocus=function(){K.isFocused=!0;t.trigger()};this.removeFocus=function(){K.isFocused=!1;t.trigger()};this.show=function(){K.isShown=!0;t.trigger()};
this.hide=function(){K.isShown=!1;t.trigger()};this.setAvatarImageUrl=function(a){c.setImageUrl(a)};this.setColor=function(b){a.style.borderColor=b;c.setColor(b)};this.getCursor=function(){return g};this.getFocusElement=function(){return a};this.toggleHandleVisibility=function(){c.isVisible()?c.hide():c.show()};this.showHandle=function(){c.show()};this.hideHandle=function(){c.hide()};this.setOverlayElement=function(a){e=a;m.appendChild(a);H=!0;t.trigger()};this.ensureVisible=function(){J=!0;t.trigger()};
this.getBoundingClientRect=function(){return y.getBoundingClientRect(m)};this.destroy=function(a){core.Async.destroyAll([t.destroy,v.destroy,c.destroy,f],a)};(function(){var b=g.getDocument(),e=[b.createRootFilter(g.getMemberId()),b.getPositionFilter()],f=b.getDOMDocument();x=f.createRange();k=f.createElement("span");k.className="webodf-caretSizer";k.textContent="|";g.getNode().appendChild(k);m=f.createElement("div");m.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",g.getMemberId());
m.className="webodf-caretOverlay";a=f.createElement("div");a.className="caret";m.appendChild(a);c=new gui.Avatar(m,d);u.getSizer().appendChild(m);z=b.createStepIterator(g.getNode(),0,e,b.getRootNode());t=core.Task.createRedrawTask(q);v=core.Task.createTimeoutTask(h,500);t.triggerImmediate()})()};
odf.TextSerializer=function(){function g(b){var h="",n=l.filter?l.filter.acceptNode(b):NodeFilter.FILTER_ACCEPT,r=b.nodeType,p;if((n===NodeFilter.FILTER_ACCEPT||n===NodeFilter.FILTER_SKIP)&&d.isTextContentContainingNode(b))for(p=b.firstChild;p;)h+=g(p),p=p.nextSibling;n===NodeFilter.FILTER_ACCEPT&&(r===Node.ELEMENT_NODE&&d.isParagraph(b)?h+="\n":r===Node.TEXT_NODE&&b.textContent&&(h+=b.textContent));return h}var l=this,d=odf.OdfUtils;this.filter=null;this.writeToString=function(b){if(!b)return"";
b=g(b);"\n"===b[b.length-1]&&(b=b.substr(0,b.length-1));return b}};gui.MimeDataExporter=function(){var g;this.exportRangeToDataTransfer=function(l,d){var b;b=d.startContainer.ownerDocument.createElement("span");b.appendChild(d.cloneContents());b=g.writeToString(b);try{l.setData("text/plain",b)}catch(h){l.setData("Text",b)}};g=new odf.TextSerializer;g.filter=new odf.OdfNodeFilter};
gui.Clipboard=function(g){this.setDataFromRange=function(l,d){var b,h=l.clipboardData;b=runtime.getWindow();!h&&b&&(h=b.clipboardData);h?(b=!0,g.exportRangeToDataTransfer(h,d),l.preventDefault()):b=!1;return b}};
gui.SessionContext=function(g,l){var d=g.getOdtDocument(),b=odf.OdfUtils;this.isLocalCursorWithinOwnAnnotation=function(){var h=d.getCursor(l),g;if(!h)return!1;g=h&&h.getNode();h=d.getMember(l).getProperties().fullName;return(g=b.getParentAnnotation(g,d.getRootNode()))&&b.getAnnotationCreator(g)===h?!0:!1}};
gui.StyleSummary=function(g){function l(b,d){var l=b+"|"+d,n;h.hasOwnProperty(l)||(n=[],g.forEach(function(f){f=(f=f.styleProperties[b])&&f[d];-1===n.indexOf(f)&&n.push(f)}),h[l]=n);return h[l]}function d(b,d,h){return function(){var g=l(b,d);return h.length>=g.length&&g.every(function(b){return-1!==h.indexOf(b)})}}function b(b,d){var h=l(b,d);return 1===h.length?h[0]:void 0}var h={};this.getPropertyValues=l;this.getCommonValue=b;this.isBold=d("style:text-properties","fo:font-weight",["bold"]);this.isItalic=
d("style:text-properties","fo:font-style",["italic"]);this.hasUnderline=d("style:text-properties","style:text-underline-style",["solid"]);this.hasStrikeThrough=d("style:text-properties","style:text-line-through-style",["solid"]);this.fontSize=function(){var d=b("style:text-properties","fo:font-size");return d&&parseFloat(d)};this.fontName=function(){return b("style:text-properties","style:font-name")};this.isAlignedLeft=d("style:paragraph-properties","fo:text-align",["left","start"]);this.isAlignedCenter=
d("style:paragraph-properties","fo:text-align",["center"]);this.isAlignedRight=d("style:paragraph-properties","fo:text-align",["right","end"]);this.isAlignedJustified=d("style:paragraph-properties","fo:text-align",["justify"]);this.text={isBold:this.isBold,isItalic:this.isItalic,hasUnderline:this.hasUnderline,hasStrikeThrough:this.hasStrikeThrough,fontSize:this.fontSize,fontName:this.fontName};this.paragraph={isAlignedLeft:this.isAlignedLeft,isAlignedCenter:this.isAlignedCenter,isAlignedRight:this.isAlignedRight,
isAlignedJustified:this.isAlignedJustified}};
gui.DirectFormattingController=function(g,l,d,b,h,n,r){function p(){return S.value().styleSummary}function q(){return S.value().enabledFeatures}function f(a){var b;a.collapsed?(b=a.startContainer,b.hasChildNodes()&&a.startOffset<b.childNodes.length&&(b=b.childNodes.item(a.startOffset)),a=[b]):a=O.getTextElements(a,!0,!1);return a}function m(){var a=F.getCursor(b),c=a&&a.getSelectedRange(),e;e=[];var k=!0,h={directTextStyling:!0,directParagraphStyling:!0};c&&(e=f(c),0===e.length&&(e=[c.startContainer,
c.endContainer],k=!1),e=F.getFormatting().getAppliedStyles(e));void 0!==e[0]&&X&&(e[0].styleProperties=aa.mergeObjects(e[0].styleProperties,X));!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(h.directTextStyling=h.directParagraphStyling=d.isLocalCursorWithinOwnAnnotation());h.directTextStyling&&(h.directTextStyling=k&&void 0!==a&&a.getSelectionType()===ops.OdtCursor.RangeSelection);return{enabledFeatures:h,appliedStyles:e,styleSummary:new gui.StyleSummary(e)}}function a(a,b){var c={};Object.keys(a).forEach(function(d){var e=
a[d](),f=b[d]();e!==f&&(c[d]=f)});return c}function c(){var b,c;c=ca.styleSummary;var d=S.value(),e=d.styleSummary,f=ca.enabledFeatures,k=d.enabledFeatures;b=a(c.text,e.text);c=a(c.paragraph,e.paragraph);f=!(k.directTextStyling===f.directTextStyling&&k.directParagraphStyling===f.directParagraphStyling);ca=d;f&&ea.emit(gui.DirectFormattingController.enabledChanged,k);0<Object.keys(b).length&&ea.emit(gui.DirectFormattingController.textStylingChanged,b);0<Object.keys(c).length&&ea.emit(gui.DirectFormattingController.paragraphStylingChanged,
c)}function e(){S.reset();c()}function k(a){("string"===typeof a?a:a.getMemberId())===b&&S.reset()}function x(){S.reset()}function u(a){var c=F.getCursor(b);a=a.paragraphElement;c&&O.getParagraphElement(c.getNode())===a&&S.reset()}function y(a,b){b(!a());return!0}function w(a){if(q().directTextStyling){var c=F.getCursorSelection(b),d={"style:text-properties":a};0!==c.length?(a=new ops.OpApplyDirectStyling,a.init({memberid:b,position:c.position,length:c.length,setProperties:d}),g.enqueue([a])):(X=
aa.mergeObjects(X||{},d),S.reset())}}function z(a,b){var c={};c[a]=b;w(c)}function t(a){a=a.spec();X&&a.memberid===b&&"SplitParagraph"!==a.optype&&(X=null,S.reset())}function v(a){z("fo:font-weight",a?"bold":"normal")}function B(a){z("fo:font-style",a?"italic":"normal")}function J(a){z("style:text-underline-style",a?"solid":"none")}function H(a){z("style:text-line-through-style",a?"solid":"none")}function K(a){if(q().directParagraphStyling){var c=F.getCursor(b).getSelectedRange(),c=O.getParagraphElements(c),
d=F.getFormatting(),e=[],f={},k;c.forEach(function(c){var g=F.convertDomPointToCursorStep(c,0,A),m=c.getAttributeNS(odf.Namespaces.textns,"style-name"),l;c=m?f.hasOwnProperty(m)?f[m]:void 0:k;c||(c=h.generateStyleName(),m?(f[m]=c,l=d.createDerivedStyleObject(m,"paragraph",{})):(k=c,l={}),l=a(l),m=new ops.OpAddStyle,m.init({memberid:b,styleName:c.toString(),styleFamily:"paragraph",isAutomaticStyle:!0,setProperties:l}),e.push(m));m=new ops.OpSetParagraphStyle;m.init({memberid:b,styleName:c.toString(),
position:g});e.push(m)});g.enqueue(e)}}function U(a){K(function(b){return aa.mergeObjects(b,a)})}function L(a){U({"style:paragraph-properties":{"fo:text-align":a}})}function Q(a,b){var c=F.getFormatting().getDefaultTabStopDistance(),d=b["style:paragraph-properties"],e;d&&(d=d["fo:margin-left"],e=O.parseLength(d));return aa.mergeObjects(b,{"style:paragraph-properties":{"fo:margin-left":e&&e.unit===c.unit?e.value+a*c.value+e.unit:a*c.value+c.unit}})}function C(a,b){var c=f(a),c=0===c.length?[a.startContainer]:
c,c=F.getFormatting().getAppliedStyles(c),d=0<c.length?c[0].styleProperties:void 0,e=F.getFormatting().getAppliedStylesForElement(b).styleProperties;if(!d||"text"!==d["style:family"]||!d["style:text-properties"])return!1;if(!e||!e["style:text-properties"])return!0;d=d["style:text-properties"];e=e["style:text-properties"];return!Object.keys(d).every(function(a){return d[a]===e[a]})}function V(){}function M(){return!1}function N(){return!1}var T=this,F=g.getOdtDocument(),aa=new core.Utils,O=odf.OdfUtils,
ea=new core.EventNotifier([gui.DirectFormattingController.enabledChanged,gui.DirectFormattingController.textStylingChanged,gui.DirectFormattingController.paragraphStylingChanged]),ba=odf.Namespaces.textns,A=core.StepDirection.NEXT,X=null,ca,S;this.enabledFeatures=q;this.formatTextSelection=w;this.createCursorStyleOp=function(a,c,d){var e=null,f=X;d&&(f=(d=S.value().appliedStyles[0])&&d.styleProperties);f&&f["style:text-properties"]&&(e=new ops.OpApplyDirectStyling,e.init({memberid:b,position:a,length:c,
setProperties:{"style:text-properties":f["style:text-properties"]}}),X=null,S.reset());return e};this.setBold=v;this.setItalic=B;this.setHasUnderline=J;this.setHasStrikethrough=H;this.setFontSize=function(a){z("fo:font-size",a+"pt")};this.setFontName=function(a){z("style:font-name",a)};this.getAppliedStyles=function(){return S.value().appliedStyles};this.toggleBold=y.bind(T,function(){return p().isBold()},v);this.toggleItalic=y.bind(T,function(){return p().isItalic()},B);this.toggleUnderline=y.bind(T,
function(){return p().hasUnderline()},J);this.toggleStrikethrough=y.bind(T,function(){return p().hasStrikeThrough()},H);this.isBold=function(){return p().isBold()};this.isItalic=function(){return p().isItalic()};this.hasUnderline=function(){return p().hasUnderline()};this.hasStrikeThrough=function(){return p().hasStrikeThrough()};this.fontSize=function(){return p().fontSize()};this.fontName=function(){return p().fontName()};this.isAlignedLeft=function(){return p().isAlignedLeft()};this.isAlignedCenter=
function(){return p().isAlignedCenter()};this.isAlignedRight=function(){return p().isAlignedRight()};this.isAlignedJustified=function(){return p().isAlignedJustified()};this.alignParagraphLeft=function(){L("left");return!0};this.alignParagraphCenter=function(){L("center");return!0};this.alignParagraphRight=function(){L("right");return!0};this.alignParagraphJustified=function(){L("justify");return!0};this.indent=function(){K(Q.bind(null,1));return!0};this.outdent=function(){K(Q.bind(null,-1));return!0};
this.createParagraphStyleOps=function(a){if(!q().directParagraphStyling)return[];var c=F.getCursor(b),d=c.getSelectedRange(),e=[],f,k;c.hasForwardSelection()?(f=c.getAnchorNode(),k=c.getNode()):(f=c.getNode(),k=c.getAnchorNode());c=O.getParagraphElement(k);runtime.assert(!!c,"DirectFormattingController: Cursor outside paragraph");var g=c,m=[F.getPositionFilter(),F.createRootFilter(b)];if(!1!==F.createStepIterator(d.endContainer,d.endOffset,m,g).nextStep())return e;k!==f&&(c=O.getParagraphElement(f));
if(!X&&!C(d,c))return e;d=(d=S.value().appliedStyles[0])&&d.styleProperties;if(!d)return e;if(c=c.getAttributeNS(ba,"style-name"))d={"style:text-properties":d["style:text-properties"]},d=F.getFormatting().createDerivedStyleObject(c,"paragraph",d);f=h.generateStyleName();c=new ops.OpAddStyle;c.init({memberid:b,styleName:f,styleFamily:"paragraph",isAutomaticStyle:!0,setProperties:d});e.push(c);c=new ops.OpSetParagraphStyle;c.init({memberid:b,styleName:f,position:a});e.push(c);return e};this.subscribe=
function(a,c){ea.subscribe(a,c)};this.unsubscribe=function(a,c){ea.unsubscribe(a,c)};this.destroy=function(a){F.unsubscribe(ops.Document.signalCursorAdded,k);F.unsubscribe(ops.Document.signalCursorRemoved,k);F.unsubscribe(ops.Document.signalCursorMoved,k);F.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,x);F.unsubscribe(ops.OdtDocument.signalParagraphChanged,u);F.unsubscribe(ops.OdtDocument.signalOperationEnd,t);F.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,c);l.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,
e);a()};(function(){F.subscribe(ops.Document.signalCursorAdded,k);F.subscribe(ops.Document.signalCursorRemoved,k);F.subscribe(ops.Document.signalCursorMoved,k);F.subscribe(ops.OdtDocument.signalParagraphStyleModified,x);F.subscribe(ops.OdtDocument.signalParagraphChanged,u);F.subscribe(ops.OdtDocument.signalOperationEnd,t);F.subscribe(ops.OdtDocument.signalProcessingBatchEnd,c);l.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,e);S=new core.LazyProperty(m);ca=S.value();n||(T.formatTextSelection=V,
T.setBold=V,T.setItalic=V,T.setHasUnderline=V,T.setHasStrikethrough=V,T.setFontSize=V,T.setFontName=V,T.toggleBold=N,T.toggleItalic=N,T.toggleUnderline=N,T.toggleStrikethrough=N);r||(T.alignParagraphCenter=M,T.alignParagraphJustified=M,T.alignParagraphLeft=M,T.alignParagraphRight=M,T.createParagraphStyleOps=function(){return[]},T.indent=M,T.outdent=M)})()};gui.DirectFormattingController.enabledChanged="enabled/changed";gui.DirectFormattingController.textStylingChanged="textStyling/changed";
gui.DirectFormattingController.paragraphStylingChanged="paragraphStyling/changed";gui.DirectFormattingController.SelectionInfo=function(){};
gui.KeyboardHandler=function(){function g(b,d){d||(d=l.None);switch(b){case gui.KeyboardHandler.KeyCode.LeftMeta:case gui.KeyboardHandler.KeyCode.RightMeta:case gui.KeyboardHandler.KeyCode.MetaInMozilla:d|=l.Meta;break;case gui.KeyboardHandler.KeyCode.Ctrl:d|=l.Ctrl;break;case gui.KeyboardHandler.KeyCode.Alt:d|=l.Alt;break;case gui.KeyboardHandler.KeyCode.Shift:d|=l.Shift}return b+":"+d}var l=gui.KeyboardHandler.Modifier,d=null,b={};this.setDefault=function(b){d=b};this.bind=function(d,l,r,p){d=g(d,
l);runtime.assert(p||!1===b.hasOwnProperty(d),"tried to overwrite the callback handler of key combo: "+d);b[d]=r};this.unbind=function(d,l){var h=g(d,l);delete b[h]};this.reset=function(){d=null;b={}};this.handleEvent=function(h){var n=h.keyCode,r=l.None;h.metaKey&&(r|=l.Meta);h.ctrlKey&&(r|=l.Ctrl);h.altKey&&(r|=l.Alt);h.shiftKey&&(r|=l.Shift);n=g(n,r);n=b[n];r=!1;n?r=n():null!==d&&(r=d(h));r&&(h.preventDefault?h.preventDefault():h.returnValue=!1)}};
gui.KeyboardHandler.Modifier={None:0,Meta:1,Ctrl:2,Alt:4,CtrlAlt:6,Shift:8,MetaShift:9,CtrlShift:10,AltShift:12};gui.KeyboardHandler.KeyCode={Backspace:8,Tab:9,Clear:12,Enter:13,Shift:16,Ctrl:17,Alt:18,End:35,Home:36,Left:37,Up:38,Right:39,Down:40,Delete:46,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,LeftMeta:91,RightMeta:93,MetaInMozilla:224};
gui.HyperlinkClickHandler=function(g,l,d){function b(){var a=g();runtime.assert(!!a.classList,"Document container has no classList element");a.classList.remove("webodf-inactiveLinks")}function h(){var a=g();runtime.assert(!!a.classList,"Document container has no classList element");a.classList.add("webodf-inactiveLinks")}function n(){a.removeEventListener("focus",h,!1);e.forEach(function(a){l.unbind(a.keyCode,a.modifier);d.unbind(a.keyCode,a.modifier)});e.length=0}function r(c){n();if(c!==p.None){a.addEventListener("focus",
h,!1);switch(c){case p.Ctrl:e.push({keyCode:q.Ctrl,modifier:p.None});break;case p.Meta:e.push({keyCode:q.LeftMeta,modifier:p.None}),e.push({keyCode:q.RightMeta,modifier:p.None}),e.push({keyCode:q.MetaInMozilla,modifier:p.None})}e.forEach(function(a){l.bind(a.keyCode,a.modifier,b);d.bind(a.keyCode,a.modifier,h)})}}var p=gui.KeyboardHandler.Modifier,q=gui.KeyboardHandler.KeyCode,f=xmldom.XPath,m=odf.OdfUtils,a=runtime.getWindow(),c=p.None,e=[];runtime.assert(null!==a,"Expected to be run in an environment which has a global window, like a browser.");
this.handleClick=function(b){var d=b.target||b.srcElement,e,k;b.ctrlKey?e=p.Ctrl:b.metaKey&&(e=p.Meta);if(c===p.None||c===e){a:{for(;null!==d;){if(m.isHyperlink(d))break a;if(m.isParagraph(d))break;d=d.parentNode}d=null}d&&(d=m.getHyperlinkTarget(d),""!==d&&("#"===d[0]?(d=d.substring(1),e=g(),k=f.getODFElementsWithXPath(e,"//text:bookmark-start[@text:name='"+d+"']",odf.Namespaces.lookupNamespaceURI),0===k.length&&(k=f.getODFElementsWithXPath(e,"//text:bookmark[@text:name='"+d+"']",odf.Namespaces.lookupNamespaceURI)),
0<k.length&&k[0].scrollIntoView(!0)):/^\s*(javascript|data):/.test(d)?runtime.log("WARN:","potentially malicious URL ignored"):a.open(d),b.preventDefault?b.preventDefault():b.returnValue=!1))}};this.setModifier=function(a){c!==a&&(runtime.assert(a===p.None||a===p.Ctrl||a===p.Meta,"Unsupported KeyboardHandler.Modifier value: "+a),c=a,c!==p.None?h():b(),r(c))};this.getModifier=function(){return c};this.destroy=function(a){h();n();a()}};
gui.EventManager=function(g){function l(a){function c(a,c,b){var d,e=!1;d="on"+c;a.attachEvent&&(a.attachEvent(d,b),e=!0);!e&&a.addEventListener&&(a.addEventListener(c,b,!1),e=!0);e&&!t[c]||!a.hasOwnProperty(d)||(a[d]=b)}function b(a,c,b){var d="on"+c;a.detachEvent&&a.detachEvent(d,b);a.removeEventListener&&a.removeEventListener(c,b,!1);a[d]===b&&(a[d]=null)}function d(c){if(-1===f.indexOf(c)){f.push(c);if(e.filters.every(function(a){return a(c)}))try{k.emit(a,c)}catch(O){runtime.log("Error occurred while processing "+
a+":\n"+O.message+"\n"+O.stack)}runtime.setTimeout(function(){f.splice(f.indexOf(c),1)},0)}}var e=this,f=[],k=new core.EventNotifier([a]);this.filters=[];this.subscribe=function(c){k.subscribe(a,c)};this.unsubscribe=function(c){k.unsubscribe(a,c)};this.destroy=function(){b(z,a,d);b(H,a,d);b(K,a,d)};v[a]&&c(z,a,d);c(H,a,d);c(K,a,d)}function d(a,c,b){function d(c){b(c,e,function(c){c.type=a;f.emit(a,c)})}var e={},f=new core.EventNotifier([a]);this.subscribe=function(c){f.subscribe(a,c)};this.unsubscribe=
function(c){f.unsubscribe(a,c)};this.destroy=function(){c.forEach(function(a){U.unsubscribe(a,d)})};(function(){c.forEach(function(a){U.subscribe(a,d)})})()}function b(a){runtime.clearTimeout(a);delete L[a]}function h(a,c){var d=runtime.setTimeout(function(){a();b(d)},c);L[d]=!0;return d}function n(a,c,d){var e=a.touches.length,f=a.touches[0],k=c.timer;"touchmove"===a.type||"touchend"===a.type?k&&b(k):"touchstart"===a.type&&(1!==e?runtime.clearTimeout(k):k=h(function(){d({clientX:f.clientX,clientY:f.clientY,
pageX:f.pageX,pageY:f.pageY,target:a.target||a.srcElement||null,detail:1})},400));c.timer=k}function r(a,c,b){var d=a.touches[0],e=a.target||a.srcElement||null,f=c.target;1!==a.touches.length||"touchend"===a.type?f=null:"touchstart"===a.type&&"webodf-draggable"===e.getAttribute("class")?f=e:"touchmove"===a.type&&f&&(a.preventDefault(),a.stopPropagation(),b({clientX:d.clientX,clientY:d.clientY,pageX:d.pageX,pageY:d.pageY,target:f,detail:1}));c.target=f}function p(a,c,b){var d=a.target||a.srcElement||
null,e=c.dragging;"drag"===a.type?e=!0:"touchend"===a.type&&e&&(e=!1,a=a.changedTouches[0],b({clientX:a.clientX,clientY:a.clientY,pageX:a.pageX,pageY:a.pageY,target:d,detail:1}));c.dragging=e}function q(){K.classList.add("webodf-touchEnabled");U.unsubscribe("touchstart",q)}function f(a){var c=a.scrollX,b=a.scrollY;this.restore=function(){a.scrollX===c&&a.scrollY===b||a.scrollTo(c,b)}}function m(a){var c=a.scrollTop,b=a.scrollLeft;this.restore=function(){if(a.scrollTop!==c||a.scrollLeft!==b)a.scrollTop=
c,a.scrollLeft=b}}function a(a,c){var b=J[a]||B[a]||null;!b&&c&&(b=J[a]=new l(a));return b}function c(c,b){a(c,!0).subscribe(b)}function e(c,b){var d=a(c,!1);d&&d.unsubscribe(b)}function k(){return g.getDOMDocument().activeElement===H}function x(){k()&&H.blur();H.setAttribute("disabled","true")}function u(){H.removeAttribute("disabled")}function y(a){for(var c=[];a;)(a.scrollWidth>a.clientWidth||a.scrollHeight>a.clientHeight)&&c.push(new m(a)),a=a.parentNode;c.push(new f(z));return c}function w(){var a;
k()||(a=y(H),u(),H.focus(),a.forEach(function(a){a.restore()}))}var z=runtime.getWindow(),t={beforecut:!0,beforepaste:!0,longpress:!0,drag:!0,dragstop:!0},v={mousedown:!0,mouseup:!0,focus:!0},B={},J={},H,K=g.getCanvas().getElement(),U=this,L={};this.addFilter=function(c,b){a(c,!0).filters.push(b)};this.removeFilter=function(c,b){var d=a(c,!0),e=d.filters.indexOf(b);-1!==e&&d.filters.splice(e,1)};this.subscribe=c;this.unsubscribe=e;this.hasFocus=k;this.focus=w;this.getEventTrap=function(){return H};
this.setEditing=function(a){var c=k();c&&H.blur();a?H.removeAttribute("readOnly"):H.setAttribute("readOnly","true");c&&w()};this.destroy=function(a){e("touchstart",q);Object.keys(L).forEach(function(a){b(parseInt(a,10))});L.length=0;Object.keys(B).forEach(function(a){B[a].destroy()});B={};e("mousedown",x);e("mouseup",u);e("contextmenu",u);Object.keys(J).forEach(function(a){J[a].destroy()});J={};H.parentNode.removeChild(H);a()};(function(){var a=g.getOdfCanvas().getSizer(),b=a.ownerDocument;runtime.assert(!!z,
"EventManager requires a window object to operate correctly");H=b.createElement("textarea");H.id="eventTrap";H.setAttribute("tabindex","-1");H.setAttribute("readOnly","true");H.setAttribute("rows","1");a.appendChild(H);c("mousedown",x);c("mouseup",u);c("contextmenu",u);B.longpress=new d("longpress",["touchstart","touchmove","touchend"],n);B.drag=new d("drag",["touchstart","touchmove","touchend"],r);B.dragstop=new d("dragstop",["drag","touchend"],p);c("touchstart",q)})()};
gui.IOSSafariSupport=function(g){function l(){d.innerHeight!==d.outerHeight&&(b.style.display="none",runtime.requestAnimationFrame(function(){b.style.display="block"}))}var d=runtime.getWindow(),b=g.getEventTrap();this.destroy=function(d){g.unsubscribe("focus",l);b.removeAttribute("autocapitalize");b.style.WebkitTransform="";d()};g.subscribe("focus",l);b.setAttribute("autocapitalize","off");b.style.WebkitTransform="translateX(-10000px)"};
gui.HyperlinkController=function(g,l,d,b){function h(){var b=!0;!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(b=d.isLocalCursorWithinOwnAnnotation());b!==f&&(f=b,q.emit(gui.HyperlinkController.enabledChanged,f))}function n(d){d.getMemberId()===b&&h()}var r=odf.OdfUtils,p=g.getOdtDocument(),q=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),f=!1;this.isEnabled=function(){return f};this.subscribe=function(b,a){q.subscribe(b,a)};this.unsubscribe=function(b,a){q.unsubscribe(b,
a)};this.addHyperlink=function(d,a){if(f){var c=p.getCursorSelection(b),e;new ops.OpApplyHyperlink;var k=[];if(0===c.length||a)a=a||d,e=new ops.OpInsertText,e.init({memberid:b,position:c.position,text:a}),c.length=a.length,k.push(e);e=new ops.OpApplyHyperlink;e.init({memberid:b,position:c.position,length:c.length,hyperlink:d});k.push(e);g.enqueue(k)}};this.removeHyperlinks=function(){if(f){var d=p.createPositionIterator(p.getRootNode()),a=p.getCursor(b).getSelectedRange(),c=r.getHyperlinkElements(a),
e=a.collapsed&&1===c.length,k=p.getDOMDocument().createRange(),h=[],l,n;0!==c.length&&(c.forEach(function(a){k.selectNodeContents(a);l=p.convertDomToCursorRange({anchorNode:k.startContainer,anchorOffset:k.startOffset,focusNode:k.endContainer,focusOffset:k.endOffset});n=new ops.OpRemoveHyperlink;n.init({memberid:b,position:l.position,length:l.length});h.push(n)}),e||(e=c[0],-1===a.comparePoint(e,0)&&(k.setStart(e,0),k.setEnd(a.startContainer,a.startOffset),l=p.convertDomToCursorRange({anchorNode:k.startContainer,
anchorOffset:k.startOffset,focusNode:k.endContainer,focusOffset:k.endOffset}),0<l.length&&(n=new ops.OpApplyHyperlink,n.init({memberid:b,position:l.position,length:l.length,hyperlink:r.getHyperlinkTarget(e)}),h.push(n))),c=c[c.length-1],d.moveToEndOfNode(c),d=d.unfilteredDomOffset(),1===a.comparePoint(c,d)&&(k.setStart(a.endContainer,a.endOffset),k.setEnd(c,d),l=p.convertDomToCursorRange({anchorNode:k.startContainer,anchorOffset:k.startOffset,focusNode:k.endContainer,focusOffset:k.endOffset}),0<l.length&&
(n=new ops.OpApplyHyperlink,n.init({memberid:b,position:l.position,length:l.length,hyperlink:r.getHyperlinkTarget(c)}),h.push(n)))),g.enqueue(h),k.detach())}};this.destroy=function(b){p.unsubscribe(ops.Document.signalCursorMoved,n);l.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,h);b()};p.subscribe(ops.Document.signalCursorMoved,n);l.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,h);h()};gui.HyperlinkController.enabledChanged="enabled/changed";
gui.ImageController=function(g,l,d,b,h){function n(){var a=!0;!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(a=d.isLocalCursorWithinOwnAnnotation());a!==e&&(e=a,c.emit(gui.ImageController.enabledChanged,e))}function r(a){a.getMemberId()===b&&n()}var p={"image/gif":".gif","image/jpeg":".jpg","image/png":".png"},q=odf.Namespaces.textns,f=g.getOdtDocument(),m=odf.OdfUtils,a=f.getFormatting(),c=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),e=!1;this.isEnabled=function(){return e};
this.subscribe=function(a,b){c.subscribe(a,b)};this.unsubscribe=function(a,b){c.unsubscribe(a,b)};this.insertImage=function(c,d,l,n){if(e){var k=new core.CSSUnits;runtime.assert(0<l&&0<n,"Both width and height of the image should be greater than 0px.");n={width:l,height:n};if(l=m.getParagraphElement(f.getCursor(b).getNode()).getAttributeNS(q,"style-name")){l=a.getContentSize(l,"paragraph");var r=1,x=1;n.width>l.width&&(r=l.width/n.width);n.height>l.height&&(x=l.height/n.height);l=Math.min(r,x);n=
{width:n.width*l,height:n.height*l}}l=k.convert(n.width,"px","cm")+"cm";k=k.convert(n.height,"px","cm")+"cm";x=f.getOdfCanvas().odfContainer().rootElement.styles;n=c.toLowerCase();var r=p.hasOwnProperty(n)?p[n]:null,u;n=[];runtime.assert(null!==r,"Image type is not supported: "+c);r="Pictures/"+h.generateImageName()+r;u=new ops.OpSetBlob;u.init({memberid:b,filename:r,mimetype:c,content:d});n.push(u);a.getStyleElement("Graphics","graphic",[x])||(c=new ops.OpAddStyle,c.init({memberid:b,styleName:"Graphics",
styleFamily:"graphic",isAutomaticStyle:!1,setProperties:{"style:graphic-properties":{"text:anchor-type":"paragraph","svg:x":"0cm","svg:y":"0cm","style:wrap":"dynamic","style:number-wrapped-paragraphs":"no-limit","style:wrap-contour":"false","style:vertical-pos":"top","style:vertical-rel":"paragraph","style:horizontal-pos":"center","style:horizontal-rel":"paragraph"}}}),n.push(c));c=h.generateStyleName();d=new ops.OpAddStyle;d.init({memberid:b,styleName:c,styleFamily:"graphic",isAutomaticStyle:!0,
setProperties:{"style:parent-style-name":"Graphics","style:graphic-properties":{"style:vertical-pos":"top","style:vertical-rel":"baseline","style:horizontal-pos":"center","style:horizontal-rel":"paragraph","fo:background-color":"transparent","style:background-transparency":"100%","style:shadow":"none","style:mirror":"none","fo:clip":"rect(0cm, 0cm, 0cm, 0cm)","draw:luminance":"0%","draw:contrast":"0%","draw:red":"0%","draw:green":"0%","draw:blue":"0%","draw:gamma":"100%","draw:color-inversion":"false",
"draw:image-opacity":"100%","draw:color-mode":"standard"}}});n.push(d);u=new ops.OpInsertImage;u.init({memberid:b,position:f.getCursorPosition(b),filename:r,frameWidth:l,frameHeight:k,frameStyleName:c,frameName:h.generateFrameName()});n.push(u);g.enqueue(n)}};this.destroy=function(a){f.unsubscribe(ops.Document.signalCursorMoved,r);l.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,n);a()};f.subscribe(ops.Document.signalCursorMoved,r);l.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,n);n()};
gui.ImageController.enabledChanged="enabled/changed";
gui.ImageSelector=function(g){function l(){var d=g.getSizer(),l=h.createElement("div");l.id="imageSelector";l.style.borderWidth="1px";d.appendChild(l);b.forEach(function(b){var d=h.createElement("div");d.className=b;l.appendChild(d)});return l}var d=odf.Namespaces.svgns,b="topLeft topRight bottomRight bottomLeft topMiddle rightMiddle bottomMiddle leftMiddle".split(" "),h=g.getElement().ownerDocument,n=!1;this.select=function(b){var p,r,f=h.getElementById("imageSelector");f||(f=l());n=!0;p=f.parentNode;
r=b.getBoundingClientRect();var m=p.getBoundingClientRect(),a=g.getZoomLevel();p=(r.left-m.left)/a-1;r=(r.top-m.top)/a-1;f.style.display="block";f.style.left=p+"px";f.style.top=r+"px";f.style.width=b.getAttributeNS(d,"width");f.style.height=b.getAttributeNS(d,"height")};this.clearSelection=function(){var b;n&&(b=h.getElementById("imageSelector"))&&(b.style.display="none");n=!1};this.isSelectorElement=function(b){var d=h.getElementById("imageSelector");return d?b===d||b.parentNode===d:!1}};
(function(){function g(g){function d(b){r=b.which&&String.fromCharCode(b.which)===l;l=void 0;return!1===r}function b(){r=!1}function h(b){l=b.data;r=!1}var l,r=!1;this.destroy=function(l){g.unsubscribe("textInput",b);g.unsubscribe("compositionend",h);g.removeFilter("keypress",d);l()};g.subscribe("textInput",b);g.subscribe("compositionend",h);g.addFilter("keypress",d)}gui.InputMethodEditor=function(l,d){function b(c){a&&(c?a.getNode().setAttributeNS("urn:webodf:names:cursor","composing","true"):(a.getNode().removeAttributeNS("urn:webodf:names:cursor",
"composing"),k.textContent=""))}function h(){u&&(u=!1,b(!1),w.emit(gui.InputMethodEditor.signalCompositionEnd,{data:y}),y="")}function n(){J||(J=!0,h(),a&&a.getSelectedRange().collapsed?c.value="":c.value=t.writeToString(a.getSelectedRange().cloneContents()),c.setSelectionRange(0,c.value.length),J=!1)}function r(){d.hasFocus()&&x.trigger()}function p(){z=void 0;x.cancel();b(!0);u||w.emit(gui.InputMethodEditor.signalCompositionStart,{data:""})}function q(a){a=z=a.data;u=!0;y+=a;x.trigger()}function f(a){a.data!==
z&&(a=a.data,u=!0,y+=a,x.trigger());z=void 0}function m(){k.textContent=c.value}var a=null,c=d.getEventTrap(),e=c.ownerDocument,k,x,u=!1,y="",w=new core.EventNotifier([gui.InputMethodEditor.signalCompositionStart,gui.InputMethodEditor.signalCompositionEnd]),z,t,v=[],B,J=!1;this.subscribe=w.subscribe;this.unsubscribe=w.unsubscribe;this.registerCursor=function(c){c.getMemberId()===l&&(a=c,a.getNode().appendChild(k),c.subscribe(ops.OdtCursor.signalCursorUpdated,r),d.subscribe("input",m),d.subscribe("compositionupdate",
m))};this.removeCursor=function(c){a&&c===l&&(a.getNode().removeChild(k),a.unsubscribe(ops.OdtCursor.signalCursorUpdated,r),d.unsubscribe("input",m),d.unsubscribe("compositionupdate",m),a=null)};this.destroy=function(a){d.unsubscribe("compositionstart",p);d.unsubscribe("compositionend",q);d.unsubscribe("textInput",f);d.unsubscribe("keypress",h);d.unsubscribe("focus",n);core.Async.destroyAll(B,a)};(function(){t=new odf.TextSerializer;t.filter=new odf.OdfNodeFilter;d.subscribe("compositionstart",p);
d.subscribe("compositionend",q);d.subscribe("textInput",f);d.subscribe("keypress",h);d.subscribe("focus",n);v.push(new g(d));B=v.map(function(a){return a.destroy});k=e.createElement("span");k.setAttribute("id","composer");x=core.Task.createTimeoutTask(n,1);B.push(x.destroy)})()};gui.InputMethodEditor.signalCompositionStart="input/compositionstart";gui.InputMethodEditor.signalCompositionEnd="input/compositionend"})();
gui.MetadataController=function(g,l){function d(b){n.emit(gui.MetadataController.signalMetadataChanged,b)}function b(b){var d=-1===r.indexOf(b);d||runtime.log("Setting "+b+" is restricted.");return d}var h=g.getOdtDocument(),n=new core.EventNotifier([gui.MetadataController.signalMetadataChanged]),r=["dc:creator","dc:date","meta:editing-cycles","meta:editing-duration","meta:document-statistic"];this.setMetadata=function(d,h){var f={},m="",a;d&&Object.keys(d).filter(b).forEach(function(a){f[a]=d[a]});
h&&(m=h.filter(b).join(","));if(0<m.length||0<Object.keys(f).length)a=new ops.OpUpdateMetadata,a.init({memberid:l,setProperties:f,removedProperties:0<m.length?{attributes:m}:null}),g.enqueue([a])};this.getMetadata=function(b){var d;runtime.assert("string"===typeof b,"Property must be a string");d=b.split(":");runtime.assert(2===d.length,"Property must be a namespace-prefixed string");b=odf.Namespaces.lookupNamespaceURI(d[0]);runtime.assert(!!b,"Prefix must be for an ODF namespace.");return h.getOdfCanvas().odfContainer().getMetadata(b,
d[1])};this.subscribe=function(b,d){n.subscribe(b,d)};this.unsubscribe=function(b,d){n.unsubscribe(b,d)};this.destroy=function(b){h.unsubscribe(ops.OdtDocument.signalMetadataUpdated,d);b()};h.subscribe(ops.OdtDocument.signalMetadataUpdated,d)};gui.MetadataController.signalMetadataChanged="metadata/changed";
gui.PasteController=function(g,l,d,b){function h(){p=!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?d.isLocalCursorWithinOwnAnnotation():!0}function n(a){a.getMemberId()===b&&h()}var r=g.getOdtDocument(),p=!1,q=odf.Namespaces.textns,f=core.StepDirection.NEXT,m=odf.OdfUtils;this.isEnabled=function(){return p};this.paste=function(a){if(p){var c=r.getCursorPosition(b),d=r.getCursor(b).getNode(),d=m.getParagraphElement(d),k=d.getAttributeNS(q,"style-name")||"",h=c,l=[],n=r.convertDomPointToCursorStep(d,
0,f);a.replace(/\r/g,"").split("\n").forEach(function(a){var c=new ops.OpInsertText,d=new ops.OpSplitParagraph;c.init({memberid:b,position:h,text:a,moveCursor:!0});l.push(c);h+=a.length;d.init({memberid:b,position:h,paragraphStyleName:k,sourceParagraphPosition:n,moveCursor:!0});l.push(d);n=h+=1});l.pop();g.enqueue(l)}};this.destroy=function(a){r.unsubscribe(ops.Document.signalCursorMoved,n);l.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,h);a()};r.subscribe(ops.Document.signalCursorMoved,n);
l.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,h);h()};gui.ClosestXOffsetScanner=function(g){function l(b){return null!==b&&void 0!==h?Math.abs(b-g)>h:!1}function d(b){null!==b&&!1===l(b)&&(h=Math.abs(b-g))}var b=this,h,n=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT;this.token=void 0;this.process=function(h,g,q){var f,m;h.visualDirection===n?(f=g&&g.right,m=q&&q.left):(f=g&&g.left,m=q&&q.right);if(l(f)||l(m))return!0;if(g||q)d(f),d(m),b.token=h.token;return!1}};
gui.LineBoundaryScanner=function(){var g=this,l=null;this.token=void 0;this.process=function(d,b,h){var n;if(n=h)if(l){n=Math.min(l.bottom-l.top,h.bottom-h.top);var r=Math.max(l.top,h.top),p=Math.min(l.bottom,h.bottom);n=.4>=(0<n?(p-r)/n:0)}else n=!1;!b||h&&!n||(g.token=d.token);if(n)return!0;l=(d=l)&&b?{left:Math.min(d.left,b.left),right:Math.max(d.right,b.right),top:Math.min(d.top,b.top),bottom:Math.min(d.bottom,b.bottom)}:d||b;return!1}};
gui.ParagraphBoundaryScanner=function(){var g=this,l=!1,d,b=odf.OdfUtils;this.token=void 0;this.process=function(h){var n=b.getParagraphElement(h.container());l||(d=n,l=!0);if(d!==n)return!0;g.token=h.token;return!1}};
odf.WordBoundaryFilter=function(g,l){function d(a,c,b){for(var d=null,e=g.getRootNode(),f;a!==e&&null!==a&&null===d;)f=0>c?a.previousSibling:a.nextSibling,b(f)===NodeFilter.FILTER_ACCEPT&&(d=f),a=a.parentNode;return d}function b(a,c){var b;return null===a?e.NO_NEIGHBOUR:r.isCharacterElement(a)?e.SPACE_CHAR:a.nodeType===h||r.isTextSpan(a)||r.isHyperlink(a)?(b=a.textContent.charAt(c()),q.test(b)?e.SPACE_CHAR:p.test(b)?e.PUNCTUATION_CHAR:e.WORD_CHAR):e.OTHER}var h=Node.TEXT_NODE,n=Node.ELEMENT_NODE,
r=odf.OdfUtils,p=/[!-#%-*,-\/:-;?-@\[-\]_{}\u00a1\u00ab\u00b7\u00bb\u00bf;\u00b7\u055a-\u055f\u0589-\u058a\u05be\u05c0\u05c3\u05c6\u05f3-\u05f4\u0609-\u060a\u060c-\u060d\u061b\u061e-\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0964-\u0965\u0970\u0df4\u0e4f\u0e5a-\u0e5b\u0f04-\u0f12\u0f3a-\u0f3d\u0f85\u0fd0-\u0fd4\u104a-\u104f\u10fb\u1361-\u1368\u166d-\u166e\u169b-\u169c\u16eb-\u16ed\u1735-\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u180a\u1944-\u1945\u19de-\u19df\u1a1e-\u1a1f\u1b5a-\u1b60\u1c3b-\u1c3f\u1c7e-\u1c7f\u2000-\u206e\u207d-\u207e\u208d-\u208e\u3008-\u3009\u2768-\u2775\u27c5-\u27c6\u27e6-\u27ef\u2983-\u2998\u29d8-\u29db\u29fc-\u29fd\u2cf9-\u2cfc\u2cfe-\u2cff\u2e00-\u2e7e\u3000-\u303f\u30a0\u30fb\ua60d-\ua60f\ua673\ua67e\ua874-\ua877\ua8ce-\ua8cf\ua92e-\ua92f\ua95f\uaa5c-\uaa5f\ufd3e-\ufd3f\ufe10-\ufe19\ufe30-\ufe52\ufe54-\ufe61\ufe63\ufe68\ufe6a-\ufe6b\uff01-\uff03\uff05-\uff0a\uff0c-\uff0f\uff1a-\uff1b\uff1f-\uff20\uff3b-\uff3d\uff3f\uff5b\uff5d\uff5f-\uff65]|\ud800[\udd00-\udd01\udf9f\udfd0]|\ud802[\udd1f\udd3f\ude50-\ude58]|\ud809[\udc00-\udc7e]/,
q=/\s/,f=core.PositionFilter.FilterResult.FILTER_ACCEPT,m=core.PositionFilter.FilterResult.FILTER_REJECT,a=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,c=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,e={NO_NEIGHBOUR:0,SPACE_CHAR:1,PUNCTUATION_CHAR:2,WORD_CHAR:3,OTHER:4};this.acceptPosition=function(k){var h=k.container(),g=k.leftNode(),p=k.rightNode(),r=k.unfilteredDomOffset,q=function(){return k.unfilteredDomOffset()-1};h.nodeType===n&&(null===p&&(p=d(h,1,k.getNodeFilter())),null===g&&(g=
d(h,-1,k.getNodeFilter())));h!==p&&(r=function(){return 0});h!==g&&null!==g&&(q=function(){return g.textContent.length-1});h=b(g,q);p=b(p,r);return h===e.WORD_CHAR&&p===e.WORD_CHAR||h===e.PUNCTUATION_CHAR&&p===e.PUNCTUATION_CHAR||l===a&&h!==e.NO_NEIGHBOUR&&p===e.SPACE_CHAR||l===c&&h===e.SPACE_CHAR&&p!==e.NO_NEIGHBOUR?m:f}};odf.WordBoundaryFilter.IncludeWhitespace={None:0,TRAILING:1,LEADING:2};
gui.SelectionController=function(g,l){function d(a){var c=a.spec();if(a.isEdit||c.memberid===l)J=void 0,H.cancel()}function b(){var a=u.getCursor(l).getNode();return u.createStepIterator(a,0,[z,v],u.getRootElement(a))}function h(a,c,b){b=new odf.WordBoundaryFilter(u,b);var d=u.getRootElement(a)||u.getRootNode(),e=u.createRootFilter(d);return u.createStepIterator(a,c,[z,e,b],d)}function n(a,c){return c?{anchorNode:a.startContainer,anchorOffset:a.startOffset,focusNode:a.endContainer,focusOffset:a.endOffset}:
{anchorNode:a.endContainer,anchorOffset:a.endOffset,focusNode:a.startContainer,focusOffset:a.startOffset}}function r(a,c,b){var d=new ops.OpMoveCursor;d.init({memberid:l,position:a,length:c||0,selectionType:b});return d}function p(a,c,b){var d;d=u.getCursor(l);d=n(d.getSelectedRange(),d.hasForwardSelection());d.focusNode=a;d.focusOffset=c;b||(d.anchorNode=d.focusNode,d.anchorOffset=d.focusOffset);a=u.convertDomToCursorRange(d);g.enqueue([r(a.position,a.length)])}function q(a){var c;c=h(a.startContainer,
a.startOffset,K);c.roundToPreviousStep()&&a.setStart(c.container(),c.offset());c=h(a.endContainer,a.endOffset,U);c.roundToNextStep()&&a.setEnd(c.container(),c.offset())}function f(a){var c=w.getParagraphElements(a),b=c[0],c=c[c.length-1];b&&a.setStart(b,0);c&&(w.isParagraph(a.endContainer)&&0===a.endOffset?a.setEndBefore(c):a.setEnd(c,c.childNodes.length))}function m(a,c,b,d){var e,f;d?(e=b.startContainer,f=b.startOffset):(e=b.endContainer,f=b.endOffset);y.containsNode(a,e)||(f=0>y.comparePoints(a,
0,e,f)?0:a.childNodes.length,e=a);a=u.createStepIterator(e,f,c,w.getParagraphElement(e)||a);a.roundToClosestStep()||runtime.assert(!1,"No step found in requested range");d?b.setStart(a.container(),a.offset()):b.setEnd(a.container(),a.offset())}function a(a,c){var d=b();d.advanceStep(a)&&p(d.container(),d.offset(),c)}function c(a,c){var d,e=J,f=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];void 0===e&&B&&(e=B());isNaN(e)||(d=b(),t.moveToFilteredStep(d,a,f)&&d.advanceStep(a)&&(f=[new gui.ClosestXOffsetScanner(e),
new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner],t.moveToFilteredStep(d,a,f)&&(p(d.container(),d.offset(),c),J=e,H.restart())))}function e(a,c){var d=b(),e=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];t.moveToFilteredStep(d,a,e)&&p(d.container(),d.offset(),c)}function k(a,c){var b=u.getCursor(l),b=n(b.getSelectedRange(),b.hasForwardSelection()),b=h(b.focusNode,b.focusOffset,K);b.advanceStep(a)&&p(b.container(),b.offset(),c)}function x(a,c,b){var d=u.getCursor(l),d=n(d.getSelectedRange(),
d.hasForwardSelection()),e=u.getRootElement(d.focusNode);runtime.assert(!!e,"SelectionController: Cursor outside root");d=u.createStepIterator(d.focusNode,d.focusOffset,[z,v],e);d.roundToClosestStep();d.advanceStep(a)&&(b=b(d.container()))&&(a===L?(d.setPosition(b,0),a=d.roundToNextStep()):(d.setPosition(b,b.childNodes.length),a=d.roundToPreviousStep()),a&&p(d.container(),d.offset(),c))}var u=g.getOdtDocument(),y=core.DomUtils,w=odf.OdfUtils,z=u.getPositionFilter(),t=new gui.GuiStepUtils,v=u.createRootFilter(l),
B=null,J,H,K=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,U=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,L=core.StepDirection.PREVIOUS,Q=core.StepDirection.NEXT;this.selectionToRange=function(a){var c=0<=y.comparePoints(a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset),b=a.focusNode.ownerDocument.createRange();c?(b.setStart(a.anchorNode,a.anchorOffset),b.setEnd(a.focusNode,a.focusOffset)):(b.setStart(a.focusNode,a.focusOffset),b.setEnd(a.anchorNode,a.anchorOffset));return{range:b,hasForwardSelection:c}};
this.rangeToSelection=n;this.selectImage=function(a){var c=u.getRootElement(a),b=u.createRootFilter(c),c=u.createStepIterator(a,0,[b,u.getPositionFilter()],c),d;c.roundToPreviousStep()||runtime.assert(!1,"No walkable position before frame");b=c.container();d=c.offset();c.setPosition(a,a.childNodes.length);c.roundToNextStep()||runtime.assert(!1,"No walkable position after frame");a=u.convertDomToCursorRange({anchorNode:b,anchorOffset:d,focusNode:c.container(),focusOffset:c.offset()});a=r(a.position,
a.length,ops.OdtCursor.RegionSelection);g.enqueue([a])};this.expandToWordBoundaries=q;this.expandToParagraphBoundaries=f;this.selectRange=function(a,c,b){var d=u.getOdfCanvas().getElement(),e,k=[z];e=y.containsNode(d,a.startContainer);d=y.containsNode(d,a.endContainer);if(e||d)if(e&&d&&(2===b?q(a):3<=b&&f(a)),(b=c?u.getRootElement(a.startContainer):u.getRootElement(a.endContainer))||(b=u.getRootNode()),k.push(u.createRootFilter(b)),m(b,k,a,!0),m(b,k,a,!1),a=n(a,c),c=u.convertDomToCursorRange(a),a=
u.getCursorSelection(l),c.position!==a.position||c.length!==a.length)a=r(c.position,c.length,ops.OdtCursor.RangeSelection),g.enqueue([a])};this.moveCursorToLeft=function(){a(L,!1);return!0};this.moveCursorToRight=function(){a(Q,!1);return!0};this.extendSelectionToLeft=function(){a(L,!0);return!0};this.extendSelectionToRight=function(){a(Q,!0);return!0};this.setCaretXPositionLocator=function(a){B=a};this.moveCursorUp=function(){c(L,!1);return!0};this.moveCursorDown=function(){c(Q,!1);return!0};this.extendSelectionUp=
function(){c(L,!0);return!0};this.extendSelectionDown=function(){c(Q,!0);return!0};this.moveCursorBeforeWord=function(){k(L,!1);return!0};this.moveCursorPastWord=function(){k(Q,!1);return!0};this.extendSelectionBeforeWord=function(){k(L,!0);return!0};this.extendSelectionPastWord=function(){k(Q,!0);return!0};this.moveCursorToLineStart=function(){e(L,!1);return!0};this.moveCursorToLineEnd=function(){e(Q,!1);return!0};this.extendSelectionToLineStart=function(){e(L,!0);return!0};this.extendSelectionToLineEnd=
function(){e(Q,!0);return!0};this.extendSelectionToParagraphStart=function(){x(L,!0,w.getParagraphElement);return!0};this.extendSelectionToParagraphEnd=function(){x(Q,!0,w.getParagraphElement);return!0};this.moveCursorToParagraphStart=function(){x(L,!1,w.getParagraphElement);return!0};this.moveCursorToParagraphEnd=function(){x(Q,!1,w.getParagraphElement);return!0};this.moveCursorToDocumentStart=function(){x(L,!1,u.getRootElement);return!0};this.moveCursorToDocumentEnd=function(){x(Q,!1,u.getRootElement);
return!0};this.extendSelectionToDocumentStart=function(){x(L,!0,u.getRootElement);return!0};this.extendSelectionToDocumentEnd=function(){x(Q,!0,u.getRootElement);return!0};this.extendSelectionToEntireDocument=function(){var a=u.getCursor(l),a=u.getRootElement(a.getNode()),c,b,d;runtime.assert(!!a,"SelectionController: Cursor outside root");d=u.createStepIterator(a,0,[z,v],a);d.roundToClosestStep();c=d.container();b=d.offset();d.setPosition(a,a.childNodes.length);d.roundToClosestStep();a=u.convertDomToCursorRange({anchorNode:c,
anchorOffset:b,focusNode:d.container(),focusOffset:d.offset()});g.enqueue([r(a.position,a.length)]);return!0};this.destroy=function(a){u.unsubscribe(ops.OdtDocument.signalOperationStart,d);core.Async.destroyAll([H.destroy],a)};(function(){H=core.Task.createTimeoutTask(function(){J=void 0},2E3);u.subscribe(ops.OdtDocument.signalOperationStart,d)})()};
gui.TextController=function(g,l,d,b,h,n){function r(){x=!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?d.isLocalCursorWithinOwnAnnotation():!0}function p(a){a.getMemberId()===b&&r()}function q(a,b,d){var e=[c.getPositionFilter()];d&&e.push(c.createRootFilter(a.startContainer));d=c.createStepIterator(a.startContainer,a.startOffset,e,b);d.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range start");b=c.convertDomPointToCursorStep(d.container(),d.offset());
a.collapsed?a=b:(d.setPosition(a.endContainer,a.endOffset),d.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range end"),a=c.convertDomPointToCursorStep(d.container(),d.offset()));return{position:b,length:a-b}}function f(a){var c,d,f,h=e.getParagraphElements(a),g=a.cloneRange(),l=[];c=h[0];1<h.length&&(e.hasNoODFContent(c)&&(c=h[h.length-1]),d=c.getAttributeNS(odf.Namespaces.textns,"style-name")||"");h.forEach(function(c,e){var h,m;g.setStart(c,0);g.collapse(!0);
h=q(g,c,!1).position;0<e&&(m=new ops.OpMergeParagraph,m.init({memberid:b,paragraphStyleName:d,destinationStartPosition:f,sourceStartPosition:h,moveCursor:1===e}),l.unshift(m));f=h;g.selectNodeContents(c);if(h=k.rangeIntersection(g,a))h=q(h,c,!0),0<h.length&&(m=new ops.OpRemoveText,m.init({memberid:b,position:h.position,length:h.length}),l.unshift(m))});return l}function m(a){0>a.length&&(a.position+=a.length,a.length=-a.length);return a}function a(a){if(!x)return!1;var d,e=c.getCursor(b).getSelectedRange().cloneRange(),
k=m(c.getCursorSelection(b)),h;if(0===k.length){k=void 0;d=c.getCursor(b).getNode();h=c.getRootElement(d);var l=[c.getPositionFilter(),c.createRootFilter(h)];h=c.createStepIterator(d,0,l,h);h.roundToClosestStep()&&(a?h.nextStep():h.previousStep())&&(k=m(c.convertDomToCursorRange({anchorNode:d,anchorOffset:0,focusNode:h.container(),focusOffset:h.offset()})),a?(e.setStart(d,0),e.setEnd(h.container(),h.offset())):(e.setStart(h.container(),h.offset()),e.setEnd(d,0)))}k&&g.enqueue(f(e));return void 0!==
k}var c=g.getOdtDocument(),e=odf.OdfUtils,k=core.DomUtils,x=!1,u=odf.Namespaces.textns,y=core.StepDirection.NEXT;this.isEnabled=function(){return x};this.enqueueParagraphSplittingOps=function(){if(!x)return!1;var a=c.getCursor(b),d=a.getSelectedRange(),h=m(c.getCursorSelection(b)),k=[],a=e.getParagraphElement(a.getNode()),l=a.getAttributeNS(u,"style-name")||"";0<h.length&&(k=k.concat(f(d)));d=new ops.OpSplitParagraph;d.init({memberid:b,position:h.position,paragraphStyleName:l,sourceParagraphPosition:c.convertDomPointToCursorStep(a,
0,y),moveCursor:!0});k.push(d);n&&(h=n(h.position+1),k=k.concat(h));g.enqueue(k);return!0};this.removeTextByBackspaceKey=function(){return a(!1)};this.removeTextByDeleteKey=function(){return a(!0)};this.removeCurrentSelection=function(){if(!x)return!1;var a=c.getCursor(b).getSelectedRange();g.enqueue(f(a));return!0};this.insertText=function(a){if(x){var d=c.getCursor(b).getSelectedRange(),e=m(c.getCursorSelection(b)),k=[],l=!1;0<e.length&&(k=k.concat(f(d)),l=!0);d=new ops.OpInsertText;d.init({memberid:b,
position:e.position,text:a,moveCursor:!0});k.push(d);h&&(a=h(e.position,a.length,l))&&k.push(a);g.enqueue(k)}};this.destroy=function(a){c.unsubscribe(ops.Document.signalCursorMoved,p);l.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,r);a()};c.subscribe(ops.Document.signalCursorMoved,p);l.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,r);r()};gui.UndoManager=function(){};gui.UndoManager.prototype.subscribe=function(g,l){};gui.UndoManager.prototype.unsubscribe=function(g,l){};
gui.UndoManager.prototype.setDocument=function(g){};gui.UndoManager.prototype.setInitialState=function(){};gui.UndoManager.prototype.initialize=function(){};gui.UndoManager.prototype.purgeInitialState=function(){};gui.UndoManager.prototype.setPlaybackFunction=function(g){};gui.UndoManager.prototype.hasUndoStates=function(){};gui.UndoManager.prototype.hasRedoStates=function(){};gui.UndoManager.prototype.moveForward=function(g){};gui.UndoManager.prototype.moveBackward=function(g){};
gui.UndoManager.prototype.onOperationExecuted=function(g){};gui.UndoManager.prototype.isDocumentModified=function(){};gui.UndoManager.prototype.setDocumentModified=function(g){};gui.UndoManager.signalUndoStackChanged="undoStackChanged";gui.UndoManager.signalUndoStateCreated="undoStateCreated";gui.UndoManager.signalUndoStateModified="undoStateModified";gui.UndoManager.signalDocumentModifiedChanged="documentModifiedChanged";
gui.SessionControllerOptions=function(){this.annotationsEnabled=this.directParagraphStylingEnabled=this.directTextStylingEnabled=!1};
(function(){var g=core.PositionFilter.FilterResult.FILTER_ACCEPT;gui.SessionController=function(l,d,b,h){function n(a,c){var b=N.getDOMDocument(),d=null;b.caretRangeFromPoint?(b=b.caretRangeFromPoint(a,c),d={container:b.startContainer,offset:b.startOffset}):b.caretPositionFromPoint&&(b=b.caretPositionFromPoint(a,c))&&b.offsetNode&&(d={container:b.offsetNode,offset:b.offset});return d}function r(a){var c=N.getCursor(d).getSelectedRange();c.collapsed?a.preventDefault():ba.setDataFromRange(a,c)?da.removeCurrentSelection():
runtime.log("Cut operation failed")}function p(){return!1!==N.getCursor(d).getSelectedRange().collapsed}function q(a){var c=N.getCursor(d).getSelectedRange();c.collapsed?a.preventDefault():ba.setDataFromRange(a,c)||runtime.log("Copy operation failed")}function f(a){var c;M.clipboardData&&M.clipboardData.getData?c=M.clipboardData.getData("Text"):a.clipboardData&&a.clipboardData.getData&&(c=a.clipboardData.getData("text/plain"));c&&(da.removeCurrentSelection(),fa.paste(c));a.preventDefault?a.preventDefault():
a.returnValue=!1}function m(){return!1}function a(a){if(P)P.onOperationExecuted(a)}function c(a){N.emit(ops.OdtDocument.signalUndoStackChanged,a)}function e(){var a;return P?(a=I.hasFocus(),P.moveBackward(1),a&&I.focus(),!0):!1}function k(){var a;return P?(a=I.hasFocus(),P.moveForward(1),a&&I.focus(),!0):!1}function x(a){var c=N.getCursor(d).getSelectedRange(),e=(a.target||a.srcElement||null).getAttribute("end");c&&e&&(a=n(a.clientX,a.clientY))&&(ia.setUnfilteredPosition(a.container,a.offset),Y.acceptPosition(ia)===
g&&(c=c.cloneRange(),"left"===e?c.setStart(ia.container(),ia.unfilteredDomOffset()):c.setEnd(ia.container(),ia.unfilteredDomOffset()),b.setSelectedRange(c,"right"===e),N.emit(ops.Document.signalCursorMoved,b)))}function u(){R.selectRange(b.getSelectedRange(),b.hasForwardSelection(),1)}function y(){var a=M.getSelection(),c=0<a.rangeCount&&R.selectionToRange(a);S&&c&&(D=!0,la.clearSelection(),ia.setUnfilteredPosition(a.focusNode,a.focusOffset),Y.acceptPosition(ia)===g&&(2===oa?R.expandToWordBoundaries(c.range):
3<=oa&&R.expandToParagraphBoundaries(c.range),b.setSelectedRange(c.range,c.hasForwardSelection),N.emit(ops.Document.signalCursorMoved,b)))}function w(a){var c=a.target||a.srcElement||null,b=N.getCursor(d);if(S=null!==c&&aa.containsNode(N.getOdfCanvas().getElement(),c))D=!1,c=N.getRootElement(c)||N.getRootNode(),Y=N.createRootFilter(c),oa=0===a.button?a.detail:0,b&&a.shiftKey?M.getSelection().collapse(b.getAnchorNode(),0):(a=M.getSelection(),c=b.getSelectedRange(),a.extend?b.hasForwardSelection()?
(a.collapse(c.startContainer,c.startOffset),a.extend(c.endContainer,c.endOffset)):(a.collapse(c.endContainer,c.endOffset),a.extend(c.startContainer,c.startOffset)):(a.removeAllRanges(),a.addRange(c.cloneRange()))),1<oa&&y()}function z(a){var c=N.getRootElement(a),b=N.createRootFilter(c),c=N.createStepIterator(a,0,[b,N.getPositionFilter()],c);c.setPosition(a,a.childNodes.length);return c.roundToNextStep()?{container:c.container(),offset:c.offset()}:null}function t(a){var c;c=(c=M.getSelection())?{anchorNode:c.anchorNode,
anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}:null;var b=M.getSelection().isCollapsed,d,e;c.anchorNode||c.focusNode||!(d=n(a.clientX,a.clientY))||(c.anchorNode=d.container,c.anchorOffset=d.offset,c.focusNode=c.anchorNode,c.focusOffset=c.anchorOffset);if(O.isImage(c.focusNode)&&0===c.focusOffset&&O.isCharacterFrame(c.focusNode.parentNode)){if(e=c.focusNode.parentNode,d=e.getBoundingClientRect(),a.clientX>d.left&&(d=z(e)))c.focusNode=d.container,c.focusOffset=d.offset,
b&&(c.anchorNode=c.focusNode,c.anchorOffset=c.focusOffset)}else O.isImage(c.focusNode.firstChild)&&1===c.focusOffset&&O.isCharacterFrame(c.focusNode)&&(d=z(c.focusNode))&&(c.anchorNode=c.focusNode=d.container,c.anchorOffset=c.focusOffset=d.offset);c.anchorNode&&c.focusNode&&(c=R.selectionToRange(c),R.selectRange(c.range,c.hasForwardSelection,0===a.button?a.detail:0));I.focus()}function v(a){var c;if(c=n(a.clientX,a.clientY))a=c.container,c=c.offset,a={anchorNode:a,anchorOffset:c,focusNode:a,focusOffset:c},
a=R.selectionToRange(a),R.selectRange(a.range,a.hasForwardSelection,2),I.focus()}function B(a){var c=a.target||a.srcElement||null,d,e,f;ma.processRequests();S&&(O.isImage(c)&&O.isCharacterFrame(c.parentNode)&&M.getSelection().isCollapsed?(R.selectImage(c.parentNode),I.focus()):la.isSelectorElement(c)?I.focus():D?(c=b.getSelectedRange(),e=c.collapsed,O.isImage(c.endContainer)&&0===c.endOffset&&O.isCharacterFrame(c.endContainer.parentNode)&&(f=c.endContainer.parentNode,f=z(f))&&(c.setEnd(f.container,
f.offset),e&&c.collapse(!1)),R.selectRange(c,b.hasForwardSelection(),0===a.button?a.detail:0),I.focus()):ua?t(a):(d=aa.cloneEvent(a),W=runtime.setTimeout(function(){t(d)},0)),oa=0,D=S=!1)}function J(a){var c=N.getCursor(d).getSelectedRange();c.collapsed||ea.exportRangeToDataTransfer(a.dataTransfer,c)}function H(){S&&I.focus();oa=0;D=S=!1}function K(a){B(a)}function U(a){var c=a.target||a.srcElement||null;"annotationRemoveButton"===c.className?(runtime.assert(ha,"Remove buttons are displayed on annotations while annotation editing is disabled in the controller."),
a=c.parentNode.getElementsByTagNameNS(odf.Namespaces.officens,"annotation").item(0),ja.removeAnnotation(a),I.focus()):"webodf-draggable"!==c.getAttribute("class")&&B(a)}function L(a){(a=a.data)&&(-1===a.indexOf("\n")?da.insertText(a):fa.paste(a))}function Q(a){return function(){a();return!0}}function C(a){return function(c){return N.getCursor(d).getSelectionType()===ops.OdtCursor.RangeSelection?a(c):!0}}function V(c){I.unsubscribe("keydown",A.handleEvent);I.unsubscribe("keypress",X.handleEvent);I.unsubscribe("keyup",
ca.handleEvent);I.unsubscribe("copy",q);I.unsubscribe("mousedown",w);I.unsubscribe("mousemove",ma.trigger);I.unsubscribe("mouseup",U);I.unsubscribe("contextmenu",K);I.unsubscribe("dragstart",J);I.unsubscribe("dragend",H);I.unsubscribe("click",pa.handleClick);I.unsubscribe("longpress",v);I.unsubscribe("drag",x);I.unsubscribe("dragstop",u);N.unsubscribe(ops.OdtDocument.signalOperationEnd,na.trigger);N.unsubscribe(ops.Document.signalCursorAdded,ka.registerCursor);N.unsubscribe(ops.Document.signalCursorRemoved,
ka.removeCursor);N.unsubscribe(ops.OdtDocument.signalOperationEnd,a);c()}var M=runtime.getWindow(),N=l.getOdtDocument(),T=new gui.SessionConstraints,F=new gui.SessionContext(l,d),aa=core.DomUtils,O=odf.OdfUtils,ea=new gui.MimeDataExporter,ba=new gui.Clipboard(ea),A=new gui.KeyboardHandler,X=new gui.KeyboardHandler,ca=new gui.KeyboardHandler,S=!1,ga=new odf.ObjectNameGenerator(N.getOdfCanvas().odfContainer(),d),D=!1,Y=null,W,P=null,I=new gui.EventManager(N),ha=h.annotationsEnabled,ja=new gui.AnnotationController(l,
T,d),Z=new gui.DirectFormattingController(l,T,F,d,ga,h.directTextStylingEnabled,h.directParagraphStylingEnabled),da=new gui.TextController(l,T,F,d,Z.createCursorStyleOp,Z.createParagraphStyleOps),qa=new gui.ImageController(l,T,F,d,ga),la=new gui.ImageSelector(N.getOdfCanvas()),ia=N.createPositionIterator(N.getRootNode()),ma,na,fa=new gui.PasteController(l,T,F,d),ka=new gui.InputMethodEditor(d,I),oa=0,pa=new gui.HyperlinkClickHandler(N.getOdfCanvas().getElement,A,ca),ta=new gui.HyperlinkController(l,
T,F,d),R=new gui.SelectionController(l,d),va=new gui.MetadataController(l,d),E=gui.KeyboardHandler.Modifier,G=gui.KeyboardHandler.KeyCode,ra=-1!==M.navigator.appVersion.toLowerCase().indexOf("mac"),ua=-1!==["iPad","iPod","iPhone"].indexOf(M.navigator.platform),sa;runtime.assert(null!==M,"Expected to be run in an environment which has a global window, like a browser.");this.undo=e;this.redo=k;this.insertLocalCursor=function(){runtime.assert(void 0===l.getOdtDocument().getCursor(d),"Inserting local cursor a second time.");
var a=new ops.OpAddCursor;a.init({memberid:d});l.enqueue([a]);I.focus()};this.removeLocalCursor=function(){runtime.assert(void 0!==l.getOdtDocument().getCursor(d),"Removing local cursor without inserting before.");var a=new ops.OpRemoveCursor;a.init({memberid:d});l.enqueue([a])};this.startEditing=function(){ka.subscribe(gui.InputMethodEditor.signalCompositionStart,da.removeCurrentSelection);ka.subscribe(gui.InputMethodEditor.signalCompositionEnd,L);I.subscribe("beforecut",p);I.subscribe("cut",r);
I.subscribe("beforepaste",m);I.subscribe("paste",f);P&&P.initialize();I.setEditing(!0);pa.setModifier(ra?E.Meta:E.Ctrl);A.bind(G.Backspace,E.None,Q(da.removeTextByBackspaceKey),!0);A.bind(G.Delete,E.None,da.removeTextByDeleteKey);A.bind(G.Tab,E.None,C(function(){da.insertText("\t");return!0}));ra?(A.bind(G.Clear,E.None,da.removeCurrentSelection),A.bind(G.B,E.Meta,C(Z.toggleBold)),A.bind(G.I,E.Meta,C(Z.toggleItalic)),A.bind(G.U,E.Meta,C(Z.toggleUnderline)),A.bind(G.L,E.MetaShift,C(Z.alignParagraphLeft)),
A.bind(G.E,E.MetaShift,C(Z.alignParagraphCenter)),A.bind(G.R,E.MetaShift,C(Z.alignParagraphRight)),A.bind(G.J,E.MetaShift,C(Z.alignParagraphJustified)),ha&&A.bind(G.C,E.MetaShift,ja.addAnnotation),A.bind(G.Z,E.Meta,e),A.bind(G.Z,E.MetaShift,k)):(A.bind(G.B,E.Ctrl,C(Z.toggleBold)),A.bind(G.I,E.Ctrl,C(Z.toggleItalic)),A.bind(G.U,E.Ctrl,C(Z.toggleUnderline)),A.bind(G.L,E.CtrlShift,C(Z.alignParagraphLeft)),A.bind(G.E,E.CtrlShift,C(Z.alignParagraphCenter)),A.bind(G.R,E.CtrlShift,C(Z.alignParagraphRight)),
A.bind(G.J,E.CtrlShift,C(Z.alignParagraphJustified)),ha&&A.bind(G.C,E.CtrlAlt,ja.addAnnotation),A.bind(G.Z,E.Ctrl,e),A.bind(G.Z,E.CtrlShift,k));X.setDefault(C(function(a){var c;c=null===a.which||void 0===a.which?String.fromCharCode(a.keyCode):0!==a.which&&0!==a.charCode?String.fromCharCode(a.which):null;return!c||a.altKey||a.ctrlKey||a.metaKey?!1:(da.insertText(c),!0)}));X.bind(G.Enter,E.None,C(da.enqueueParagraphSplittingOps))};this.endEditing=function(){ka.unsubscribe(gui.InputMethodEditor.signalCompositionStart,
da.removeCurrentSelection);ka.unsubscribe(gui.InputMethodEditor.signalCompositionEnd,L);I.unsubscribe("cut",r);I.unsubscribe("beforecut",p);I.unsubscribe("paste",f);I.unsubscribe("beforepaste",m);I.setEditing(!1);pa.setModifier(E.None);A.bind(G.Backspace,E.None,function(){return!0},!0);A.unbind(G.Delete,E.None);A.unbind(G.Tab,E.None);ra?(A.unbind(G.Clear,E.None),A.unbind(G.B,E.Meta),A.unbind(G.I,E.Meta),A.unbind(G.U,E.Meta),A.unbind(G.L,E.MetaShift),A.unbind(G.E,E.MetaShift),A.unbind(G.R,E.MetaShift),
A.unbind(G.J,E.MetaShift),ha&&A.unbind(G.C,E.MetaShift),A.unbind(G.Z,E.Meta),A.unbind(G.Z,E.MetaShift)):(A.unbind(G.B,E.Ctrl),A.unbind(G.I,E.Ctrl),A.unbind(G.U,E.Ctrl),A.unbind(G.L,E.CtrlShift),A.unbind(G.E,E.CtrlShift),A.unbind(G.R,E.CtrlShift),A.unbind(G.J,E.CtrlShift),ha&&A.unbind(G.C,E.CtrlAlt),A.unbind(G.Z,E.Ctrl),A.unbind(G.Z,E.CtrlShift));X.setDefault(null);X.unbind(G.Enter,E.None)};this.getInputMemberId=function(){return d};this.getSession=function(){return l};this.getSessionConstraints=function(){return T};
this.setUndoManager=function(a){P&&P.unsubscribe(gui.UndoManager.signalUndoStackChanged,c);if(P=a)P.setDocument(N),P.setPlaybackFunction(l.enqueue),P.subscribe(gui.UndoManager.signalUndoStackChanged,c)};this.getUndoManager=function(){return P};this.getMetadataController=function(){return va};this.getAnnotationController=function(){return ja};this.getDirectFormattingController=function(){return Z};this.getHyperlinkClickHandler=function(){return pa};this.getHyperlinkController=function(){return ta};
this.getImageController=function(){return qa};this.getSelectionController=function(){return R};this.getTextController=function(){return da};this.getEventManager=function(){return I};this.getKeyboardHandlers=function(){return{keydown:A,keypress:X}};this.destroy=function(a){var c=[ma.destroy,na.destroy,Z.destroy,ka.destroy,I.destroy,pa.destroy,ta.destroy,va.destroy,R.destroy,da.destroy,V];sa&&c.unshift(sa.destroy);runtime.clearTimeout(W);core.Async.destroyAll(c,a)};ma=core.Task.createRedrawTask(y);
na=core.Task.createRedrawTask(function(){var a=N.getCursor(d);if(a&&a.getSelectionType()===ops.OdtCursor.RegionSelection&&(a=O.getImageElements(a.getSelectedRange())[0])){la.select(a.parentNode);return}la.clearSelection()});A.bind(G.Left,E.None,C(R.moveCursorToLeft));A.bind(G.Right,E.None,C(R.moveCursorToRight));A.bind(G.Up,E.None,C(R.moveCursorUp));A.bind(G.Down,E.None,C(R.moveCursorDown));A.bind(G.Left,E.Shift,C(R.extendSelectionToLeft));A.bind(G.Right,E.Shift,C(R.extendSelectionToRight));A.bind(G.Up,
E.Shift,C(R.extendSelectionUp));A.bind(G.Down,E.Shift,C(R.extendSelectionDown));A.bind(G.Home,E.None,C(R.moveCursorToLineStart));A.bind(G.End,E.None,C(R.moveCursorToLineEnd));A.bind(G.Home,E.Ctrl,C(R.moveCursorToDocumentStart));A.bind(G.End,E.Ctrl,C(R.moveCursorToDocumentEnd));A.bind(G.Home,E.Shift,C(R.extendSelectionToLineStart));A.bind(G.End,E.Shift,C(R.extendSelectionToLineEnd));A.bind(G.Up,E.CtrlShift,C(R.extendSelectionToParagraphStart));A.bind(G.Down,E.CtrlShift,C(R.extendSelectionToParagraphEnd));
A.bind(G.Home,E.CtrlShift,C(R.extendSelectionToDocumentStart));A.bind(G.End,E.CtrlShift,C(R.extendSelectionToDocumentEnd));ra?(A.bind(G.Left,E.Alt,C(R.moveCursorBeforeWord)),A.bind(G.Right,E.Alt,C(R.moveCursorPastWord)),A.bind(G.Left,E.Meta,C(R.moveCursorToLineStart)),A.bind(G.Right,E.Meta,C(R.moveCursorToLineEnd)),A.bind(G.Home,E.Meta,C(R.moveCursorToDocumentStart)),A.bind(G.End,E.Meta,C(R.moveCursorToDocumentEnd)),A.bind(G.Left,E.AltShift,C(R.extendSelectionBeforeWord)),A.bind(G.Right,E.AltShift,
C(R.extendSelectionPastWord)),A.bind(G.Left,E.MetaShift,C(R.extendSelectionToLineStart)),A.bind(G.Right,E.MetaShift,C(R.extendSelectionToLineEnd)),A.bind(G.Up,E.AltShift,C(R.extendSelectionToParagraphStart)),A.bind(G.Down,E.AltShift,C(R.extendSelectionToParagraphEnd)),A.bind(G.Up,E.MetaShift,C(R.extendSelectionToDocumentStart)),A.bind(G.Down,E.MetaShift,C(R.extendSelectionToDocumentEnd)),A.bind(G.A,E.Meta,C(R.extendSelectionToEntireDocument))):(A.bind(G.Left,E.Ctrl,C(R.moveCursorBeforeWord)),A.bind(G.Right,
E.Ctrl,C(R.moveCursorPastWord)),A.bind(G.Left,E.CtrlShift,C(R.extendSelectionBeforeWord)),A.bind(G.Right,E.CtrlShift,C(R.extendSelectionPastWord)),A.bind(G.A,E.Ctrl,C(R.extendSelectionToEntireDocument)));ua&&(sa=new gui.IOSSafariSupport(I));I.subscribe("keydown",A.handleEvent);I.subscribe("keypress",X.handleEvent);I.subscribe("keyup",ca.handleEvent);I.subscribe("copy",q);I.subscribe("mousedown",w);I.subscribe("mousemove",ma.trigger);I.subscribe("mouseup",U);I.subscribe("contextmenu",K);I.subscribe("dragstart",
J);I.subscribe("dragend",H);I.subscribe("click",pa.handleClick);I.subscribe("longpress",v);I.subscribe("drag",x);I.subscribe("dragstop",u);N.subscribe(ops.OdtDocument.signalOperationEnd,na.trigger);N.subscribe(ops.Document.signalCursorAdded,ka.registerCursor);N.subscribe(ops.Document.signalCursorRemoved,ka.removeCursor);N.subscribe(ops.OdtDocument.signalOperationEnd,a)}})();
gui.CaretManager=function(g,l){function d(b){return n.hasOwnProperty(b)?n[b]:null}function b(){return Object.keys(n).map(function(b){return n[b]})}function h(b){var d=n[b];d&&(delete n[b],b===g.getInputMemberId()?(p.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,d.ensureVisible),p.unsubscribe(ops.Document.signalCursorMoved,d.refreshCursorBlinking),q.unsubscribe("compositionupdate",d.handleUpdate),q.unsubscribe("compositionend",d.handleUpdate),q.unsubscribe("focus",d.setFocus),q.unsubscribe("blur",
d.removeFocus),r.removeEventListener("focus",d.show,!1),r.removeEventListener("blur",d.hide,!1)):p.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,d.handleUpdate),d.destroy(function(){}))}var n={},r=runtime.getWindow(),p=g.getSession().getOdtDocument(),q=g.getEventManager();this.registerCursor=function(b,d,a){var c=b.getMemberId();b=new gui.Caret(b,l,d,a);n[c]=b;c===g.getInputMemberId()?(runtime.log("Starting to track input on new cursor of "+c),p.subscribe(ops.OdtDocument.signalProcessingBatchEnd,
b.ensureVisible),p.subscribe(ops.Document.signalCursorMoved,b.refreshCursorBlinking),q.subscribe("compositionupdate",b.handleUpdate),q.subscribe("compositionend",b.handleUpdate),q.subscribe("focus",b.setFocus),q.subscribe("blur",b.removeFocus),r.addEventListener("focus",b.show,!1),r.addEventListener("blur",b.hide,!1),b.setOverlayElement(q.getEventTrap())):p.subscribe(ops.OdtDocument.signalProcessingBatchEnd,b.handleUpdate);return b};this.getCaret=d;this.getCarets=b;this.destroy=function(d){var f=
b().map(function(a){return a.destroy});g.getSelectionController().setCaretXPositionLocator(null);p.unsubscribe(ops.Document.signalCursorRemoved,h);n={};core.Async.destroyAll(f,d)};g.getSelectionController().setCaretXPositionLocator(function(){var b=d(g.getInputMemberId()),h;b&&(h=b.getBoundingClientRect());return h?h.right:void 0});p.subscribe(ops.Document.signalCursorRemoved,h)};
gui.EditInfoHandle=function(g){var l=[],d,b=g.ownerDocument,h=b.documentElement.namespaceURI;this.setEdits=function(g){l=g;var n,p,q,f;core.DomUtils.removeAllChildNodes(d);for(g=0;g<l.length;g+=1)n=b.createElementNS(h,"div"),n.className="editInfo",p=b.createElementNS(h,"span"),p.className="editInfoColor",p.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",l[g].memberid),q=b.createElementNS(h,"span"),q.className="editInfoAuthor",q.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",
l[g].memberid),f=b.createElementNS(h,"span"),f.className="editInfoTime",f.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",l[g].memberid),f.appendChild(b.createTextNode(l[g].time.toString())),n.appendChild(p),n.appendChild(q),n.appendChild(f),d.appendChild(n)};this.show=function(){d.style.display="block"};this.hide=function(){d.style.display="none"};this.destroy=function(b){g.removeChild(d);b()};d=b.createElementNS(h,"div");d.setAttribute("class","editInfoHandle");d.style.display="none";
g.appendChild(d)};
ops.EditInfo=function(g,l){function d(){var b=[],d;for(d in h)h.hasOwnProperty(d)&&b.push({memberid:d,time:h[d].time});b.sort(function(b,d){return b.time-d.time});return b}var b,h={};this.getNode=function(){return b};this.getOdtDocument=function(){return l};this.getEdits=function(){return h};this.getSortedEdits=function(){return d()};this.addEdit=function(b,d){h[b]={time:d}};this.clearEdits=function(){h={}};this.destroy=function(d){g.parentNode&&g.removeChild(b);d()};b=l.getDOMDocument().createElementNS("urn:webodf:names:editinfo","editinfo");
g.insertBefore(b,g.firstChild)};
gui.EditInfoMarker=function(g,l){function d(b,a){return runtime.setTimeout(function(){r.style.opacity=b},a)}var b=this,h,n,r,p,q,f;this.addEdit=function(b,a){var c=Date.now()-a;g.addEdit(b,a);n.setEdits(g.getSortedEdits());r.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",b);runtime.clearTimeout(q);runtime.clearTimeout(f);1E4>c?(p=d(1,0),q=d(.5,1E4-c),f=d(.2,2E4-c)):1E4<=c&&2E4>c?(p=d(.5,0),f=d(.2,2E4-c)):p=d(.2,0)};this.getEdits=function(){return g.getEdits()};this.clearEdits=function(){g.clearEdits();
n.setEdits([]);r.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&r.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return g};this.show=function(){r.style.display="block"};this.hide=function(){b.hideHandle();r.style.display="none"};this.showHandle=function(){n.show()};this.hideHandle=function(){n.hide()};this.destroy=function(b){runtime.clearTimeout(p);runtime.clearTimeout(q);runtime.clearTimeout(f);h.removeChild(r);n.destroy(function(a){a?
b(a):g.destroy(b)})};(function(){var d=g.getOdtDocument().getDOMDocument();r=d.createElementNS(d.documentElement.namespaceURI,"div");r.setAttribute("class","editInfoMarker");r.onmouseover=function(){b.showHandle()};r.onmouseout=function(){b.hideHandle()};h=g.getNode();h.appendChild(r);n=new gui.EditInfoHandle(h);l||b.hide()})()};
gui.HyperlinkTooltipView=function(g,l){var d=core.DomUtils,b=odf.OdfUtils,h=runtime.getWindow(),n,r,p;runtime.assert(null!==h,"Expected to be run in an environment which has a global window, like a browser.");this.showTooltip=function(q){var f=q.target||q.srcElement,m=g.getSizer(),a=g.getZoomLevel(),c;a:{for(;f;){if(b.isHyperlink(f))break a;if(b.isParagraph(f)||b.isInlineRoot(f))break;f=f.parentNode}f=null}if(f){d.containsNode(m,p)||m.appendChild(p);c=r;var e;switch(l()){case gui.KeyboardHandler.Modifier.Ctrl:e=
runtime.tr("Ctrl-click to follow link");break;case gui.KeyboardHandler.Modifier.Meta:e=runtime.tr("\u2318-click to follow link");break;default:e=""}c.textContent=e;n.textContent=b.getHyperlinkTarget(f);p.style.display="block";c=h.innerWidth-p.offsetWidth-15;f=q.clientX>c?c:q.clientX+15;c=h.innerHeight-p.offsetHeight-10;q=q.clientY>c?c:q.clientY+10;m=m.getBoundingClientRect();f=(f-m.left)/a;q=(q-m.top)/a;p.style.left=f+"px";p.style.top=q+"px"}};this.hideTooltip=function(){p.style.display="none"};this.destroy=
function(b){p.parentNode&&p.parentNode.removeChild(p);b()};(function(){var b=g.getElement().ownerDocument;n=b.createElement("span");r=b.createElement("span");n.className="webodf-hyperlinkTooltipLink";r.className="webodf-hyperlinkTooltipText";p=b.createElement("div");p.className="webodf-hyperlinkTooltip";p.appendChild(n);p.appendChild(r);g.getElement().appendChild(p)})()};
gui.OdfFieldView=function(g){function l(){var b=odf.OdfSchema.getFields().map(function(b){return b.replace(":","|")}),d=b.join(",\n")+"\n{ background-color: #D0D0D0; }\n",b=b.map(function(b){return b+":empty::after"}).join(",\n")+"\n{ content:' '; white-space: pre; }\n";return d+"\n"+b}var d,b=g.getElement().ownerDocument;this.showFieldHighlight=function(){d.appendChild(b.createTextNode(l()))};this.hideFieldHighlight=function(){for(var b=d.sheet,g=b.cssRules;g.length;)b.deleteRule(g.length-1)};this.destroy=
function(b){d.parentNode&&d.parentNode.removeChild(d);b()};d=function(){var d=b.getElementsByTagName("head").item(0),g=b.createElement("style"),l="";g.type="text/css";g.media="screen, print, handheld, projection";odf.Namespaces.forEachPrefix(function(b,d){l+="@namespace "+b+" url("+d+");\n"});g.appendChild(b.createTextNode(l));d.appendChild(g);return g}()};
gui.ShadowCursor=function(g){var l=g.getDOMDocument().createRange(),d=!0;this.removeFromDocument=function(){};this.getMemberId=function(){return gui.ShadowCursor.ShadowCursorMemberId};this.getSelectedRange=function(){return l};this.setSelectedRange=function(b,h){l=b;d=!1!==h};this.hasForwardSelection=function(){return d};this.getDocument=function(){return g};this.getSelectionType=function(){return ops.OdtCursor.RangeSelection};l.setStart(g.getRootNode(),0)};gui.ShadowCursor.ShadowCursorMemberId="";
gui.SelectionView=function(g){};gui.SelectionView.prototype.rerender=function(){};gui.SelectionView.prototype.show=function(){};gui.SelectionView.prototype.hide=function(){};gui.SelectionView.prototype.destroy=function(g){};
gui.SelectionViewManager=function(g){function l(){return Object.keys(d).map(function(b){return d[b]})}var d={};this.getSelectionView=function(b){return d.hasOwnProperty(b)?d[b]:null};this.getSelectionViews=l;this.removeSelectionView=function(b){d.hasOwnProperty(b)&&(d[b].destroy(function(){}),delete d[b])};this.hideSelectionView=function(b){d.hasOwnProperty(b)&&d[b].hide()};this.showSelectionView=function(b){d.hasOwnProperty(b)&&d[b].show()};this.rerenderSelectionViews=function(){Object.keys(d).forEach(function(b){d[b].rerender()})};
this.registerCursor=function(b,h){var l=b.getMemberId(),r=new g(b);h?r.show():r.hide();return d[l]=r};this.destroy=function(b){function d(h,l){l?b(l):h<g.length?g[h].destroy(function(b){d(h+1,b)}):b()}var g=l();d(0,void 0)}};gui.SessionViewOptions=function(){this.caretBlinksOnRangeSelect=this.caretAvatarsInitiallyVisible=this.editInfoMarkersInitiallyVisible=!0};
(function(){function g(g,d){return void 0!==g?!!g:d}gui.SessionView=function(l,d,b,h,n,r){function p(a){a.memberId===d&&J.getViewport().scrollIntoView(a.annotation.getBoundingClientRect())}function q(){var a=document.getElementsByTagName("head").item(0),c=document.createElement("style");c.type="text/css";c.media="screen, print, handheld, projection";a.appendChild(c);return c}function f(a,c,b){function e(c,b,d){b=c+'[editinfo|memberid="'+a+'"]'+d+b;a:{var e=z.firstChild;for(c=c+'[editinfo|memberid="'+
a+'"]'+d+"{";e;){if(e.nodeType===Node.TEXT_NODE&&0===e.data.indexOf(c)){c=e;break a}e=e.nextSibling}c=null}c?c.data=b:z.appendChild(document.createTextNode(b))}e("div.editInfoMarker","{ background-color: "+b+"; }","");e("span.editInfoColor","{ background-color: "+b+"; }","");e("span.editInfoAuthor",'{ content: "'+c+'"; }',":before");e("dc|creator","{ background-color: "+b+"; }","");e(".webodf-selectionOverlay","{ fill: "+b+"; stroke: "+b+";}","");a===d&&(e(".webodf-touchEnabled .webodf-selectionOverlay",
"{ display: block; }"," > .webodf-draggable"),a=gui.ShadowCursor.ShadowCursorMemberId,e(".webodf-selectionOverlay","{ fill: "+b+"; stroke: "+b+";}",""),e(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"))}function m(a){var c,b;for(b in v)v.hasOwnProperty(b)&&(c=v[b],a?c.show():c.hide())}function a(a){n.getCarets().forEach(function(c){a?c.showHandle():c.hideHandle()})}function c(a){var c=a.getMemberId();a=a.getProperties();f(c,a.fullName,a.color)}function e(a){var c=
a.getMemberId(),d=b.getOdtDocument().getMember(c).getProperties();n.registerCursor(a,U,L);r.registerCursor(a,!0);if(a=n.getCaret(c))a.setAvatarImageUrl(d.imageUrl),a.setColor(d.color);runtime.log("+++ View here +++ eagerly created an Caret for '"+c+"'! +++")}function k(a){a=a.getMemberId();var c=r.getSelectionView(d),b=r.getSelectionView(gui.ShadowCursor.ShadowCursorMemberId),e=n.getCaret(d);a===d?(b.hide(),c&&c.show(),e&&e.show()):a===gui.ShadowCursor.ShadowCursorMemberId&&(b.show(),c&&c.hide(),
e&&e.hide())}function x(a){r.removeSelectionView(a)}function u(a){var c=a.paragraphElement,d=a.memberId;a=a.timeStamp;var e,f,k=c.getElementsByTagNameNS("urn:webodf:names:editinfo","editinfo").item(0);k?(f=k.getAttributeNS("urn:webodf:names:editinfo","id"),e=v[f]):(f=Math.random().toString(),e=new ops.EditInfo(c,b.getOdtDocument()),e=new gui.EditInfoMarker(e,K),k=c.getElementsByTagNameNS("urn:webodf:names:editinfo","editinfo").item(0),k.setAttributeNS("urn:webodf:names:editinfo","id",f),v[f]=e);e.addEdit(d,
new Date(a));H.trigger()}function y(){var a;t.hasChildNodes()&&core.DomUtils.removeAllChildNodes(t);!0===h.getState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN)&&(a=b.getOdtDocument().getMember(d))&&(a=a.getProperties().fullName,t.appendChild(document.createTextNode(".annotationWrapper:not([creator = '"+a+"']) .annotationRemoveButton { display: none; }")))}function w(a){var b=Object.keys(v).map(function(a){return v[a]});B.unsubscribe(ops.Document.signalMemberAdded,c);B.unsubscribe(ops.Document.signalMemberUpdated,
c);B.unsubscribe(ops.Document.signalCursorAdded,e);B.unsubscribe(ops.Document.signalCursorRemoved,x);B.unsubscribe(ops.OdtDocument.signalParagraphChanged,u);B.unsubscribe(ops.Document.signalCursorMoved,k);B.unsubscribe(ops.OdtDocument.signalParagraphChanged,r.rerenderSelectionViews);B.unsubscribe(ops.OdtDocument.signalTableAdded,r.rerenderSelectionViews);B.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,r.rerenderSelectionViews);h.unsubscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN,
y);B.unsubscribe(ops.Document.signalMemberAdded,y);B.unsubscribe(ops.Document.signalMemberUpdated,y);z.parentNode.removeChild(z);t.parentNode.removeChild(t);(function M(c,d){d?a(d):c<b.length?b[c].destroy(function(a){M(c+1,a)}):a()})(0,void 0)}var z,t,v={},B,J,H,K=g(l.editInfoMarkersInitiallyVisible,!0),U=g(l.caretAvatarsInitiallyVisible,!0),L=g(l.caretBlinksOnRangeSelect,!0);this.showEditInfoMarkers=function(){K||(K=!0,m(K))};this.hideEditInfoMarkers=function(){K&&(K=!1,m(K))};this.showCaretAvatars=
function(){U||(U=!0,a(U))};this.hideCaretAvatars=function(){U&&(U=!1,a(U))};this.getSession=function(){return b};this.getCaret=function(a){return n.getCaret(a)};this.destroy=function(a){var c=[H.destroy,w];B.unsubscribe(ops.OdtDocument.signalAnnotationAdded,p);core.Async.destroyAll(c,a)};B=b.getOdtDocument();J=B.getOdfCanvas();B.subscribe(ops.OdtDocument.signalAnnotationAdded,p);B.subscribe(ops.Document.signalMemberAdded,c);B.subscribe(ops.Document.signalMemberUpdated,c);B.subscribe(ops.Document.signalCursorAdded,
e);B.subscribe(ops.Document.signalCursorRemoved,x);B.subscribe(ops.OdtDocument.signalParagraphChanged,u);B.subscribe(ops.Document.signalCursorMoved,k);B.subscribe(ops.OdtDocument.signalParagraphChanged,r.rerenderSelectionViews);B.subscribe(ops.OdtDocument.signalTableAdded,r.rerenderSelectionViews);B.subscribe(ops.OdtDocument.signalParagraphStyleModified,r.rerenderSelectionViews);h.subscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN,y);B.subscribe(ops.Document.signalMemberAdded,y);B.subscribe(ops.Document.signalMemberUpdated,
y);z=q();z.appendChild(document.createTextNode("@namespace editinfo url(urn:webodf:names:editinfo);"));z.appendChild(document.createTextNode("@namespace dc url(http://purl.org/dc/elements/1.1/);"));t=q();y();H=core.Task.createRedrawTask(function(){var a=J.getAnnotationViewManager();a&&(a.rehighlightAnnotations(),B.fixCursorPositions())})}})();
gui.SvgSelectionView=function(g){function l(){var a=c.getRootNode();e!==a&&(e=a,k=c.getCanvas().getSizer(),k.appendChild(u),u.setAttribute("class","webodf-selectionOverlay"),w.setAttribute("class","webodf-draggable"),z.setAttribute("class","webodf-draggable"),w.setAttribute("end","left"),z.setAttribute("end","right"),w.setAttribute("r",8),z.setAttribute("r",8),u.appendChild(y),u.appendChild(w),u.appendChild(z))}function d(a){a=a.getBoundingClientRect();return!(!a||0===a.height)}function b(a){var c=
t.getTextElements(a,!0,!1),b=a.cloneRange(),e=a.cloneRange();a=a.cloneRange();if(!c.length)return null;var f;a:{f=0;var k=c[f],h=b.startContainer===k?b.startOffset:0,g=h;b.setStart(k,h);for(b.setEnd(k,g);!d(b);){if(k.nodeType===Node.ELEMENT_NODE&&g<k.childNodes.length)g=k.childNodes.length;else if(k.nodeType===Node.TEXT_NODE&&g<k.length)g+=1;else if(c[f])k=c[f],f+=1,h=g=0;else{f=!1;break a}b.setStart(k,h);b.setEnd(k,g)}f=!0}if(!f)return null;a:{f=c.length-1;k=c[f];g=h=e.endContainer===k?e.endOffset:
k.nodeType===Node.TEXT_NODE?k.length:k.childNodes.length;e.setStart(k,h);for(e.setEnd(k,g);!d(e);){if(k.nodeType===Node.ELEMENT_NODE&&0<h)h=0;else if(k.nodeType===Node.TEXT_NODE&&0<h)--h;else if(c[f])k=c[f],--f,h=g=k.length||k.childNodes.length;else{c=!1;break a}e.setStart(k,h);e.setEnd(k,g)}c=!0}if(!c)return null;a.setStart(b.startContainer,b.startOffset);a.setEnd(e.endContainer,e.endOffset);return{firstRange:b,lastRange:e,fillerRange:a}}function h(a,c){var b={};b.top=Math.min(a.top,c.top);b.left=
Math.min(a.left,c.left);b.right=Math.max(a.right,c.right);b.bottom=Math.max(a.bottom,c.bottom);b.width=b.right-b.left;b.height=b.bottom-b.top;return b}function n(a,c){c&&0<c.width&&0<c.height&&(a=a?h(a,c):c);return a}function r(a){function b(a){H.setUnfilteredPosition(a,0);return w.acceptNode(a)===K&&u.acceptPosition(H)===K?K:U}function d(a){var c=null;b(a)===K&&(c=v.getBoundingClientRect(a));return c}var e=a.commonAncestorContainer,f=a.startContainer,k=a.endContainer,h=a.startOffset,g=a.endOffset,
l,m,p=null,r,q=x.createRange(),u,w=new odf.OdfNodeFilter,y;if(f===e||k===e)return q=a.cloneRange(),p=q.getBoundingClientRect(),q.detach(),p;for(a=f;a.parentNode!==e;)a=a.parentNode;for(m=k;m.parentNode!==e;)m=m.parentNode;u=c.createRootFilter(f);for(e=a.nextSibling;e&&e!==m;)r=d(e),p=n(p,r),e=e.nextSibling;if(t.isParagraph(a))p=n(p,v.getBoundingClientRect(a));else if(a.nodeType===Node.TEXT_NODE)e=a,q.setStart(e,h),q.setEnd(e,e===m?g:e.length),r=q.getBoundingClientRect(),p=n(p,r);else for(y=x.createTreeWalker(a,
NodeFilter.SHOW_TEXT,b,!1),e=y.currentNode=f;e&&e!==k;)q.setStart(e,h),q.setEnd(e,e.length),r=q.getBoundingClientRect(),p=n(p,r),l=e,h=0,e=y.nextNode();l||(l=f);if(t.isParagraph(m))p=n(p,v.getBoundingClientRect(m));else if(m.nodeType===Node.TEXT_NODE)e=m,q.setStart(e,e===a?h:0),q.setEnd(e,g),r=q.getBoundingClientRect(),p=n(p,r);else for(y=x.createTreeWalker(m,NodeFilter.SHOW_TEXT,b,!1),e=y.currentNode=k;e&&e!==l;)if(q.setStart(e,0),q.setEnd(e,g),r=q.getBoundingClientRect(),p=n(p,r),e=y.previousNode())g=
e.length;return p}function p(a,c){var b=a.getBoundingClientRect(),d={width:0};d.top=b.top;d.bottom=b.bottom;d.height=b.height;d.left=d.right=c?b.right:b.left;return d}function q(){var a=g.getSelectedRange(),c;if(c=J&&g.getSelectionType()===ops.OdtCursor.RangeSelection&&!a.collapsed){l();var d=v.getBoundingClientRect(k),e=B.getZoomLevel(),a=b(a),f,m,n,q,x,t;if(a){c=a.firstRange;f=a.lastRange;m=a.fillerRange;n=v.translateRect(p(c,!1),d,e);x=v.translateRect(p(f,!0),d,e);q=(q=r(m))?v.translateRect(q,
d,e):h(n,x);t=q.left;q=n.left+Math.max(0,q.width-(n.left-q.left));d=Math.min(n.top,x.top);e=x.top+x.height;t=[{x:n.left,y:d+n.height},{x:n.left,y:d},{x:q,y:d},{x:q,y:e-x.height},{x:x.right,y:e-x.height},{x:x.right,y:e},{x:t,y:e},{x:t,y:d+n.height},{x:n.left,y:d+n.height}];q="";var H;for(H=0;H<t.length;H+=1)q+=t[H].x+","+t[H].y+" ";y.setAttribute("points",q);w.setAttribute("cx",n.left);w.setAttribute("cy",d+n.height/2);z.setAttribute("cx",x.right);z.setAttribute("cy",e-x.height/2);c.detach();f.detach();
m.detach()}c=!!a}u.style.display=c?"block":"none"}function f(a){J&&a===g&&L.trigger()}function m(a){a=8/a;w.setAttribute("r",a);z.setAttribute("r",a)}function a(a){k.removeChild(u);k.classList.remove("webodf-virtualSelections");g.getDocument().unsubscribe(ops.Document.signalCursorMoved,f);B.unsubscribe(gui.ZoomHelper.signalZoomChanged,m);a()}var c=g.getDocument(),e,k,x=c.getDOMDocument(),u=x.createElementNS("http://www.w3.org/2000/svg","svg"),y=x.createElementNS("http://www.w3.org/2000/svg","polygon"),
w=x.createElementNS("http://www.w3.org/2000/svg","circle"),z=x.createElementNS("http://www.w3.org/2000/svg","circle"),t=odf.OdfUtils,v=core.DomUtils,B=c.getCanvas().getZoomHelper(),J=!0,H=g.getDocument().createPositionIterator(c.getRootNode()),K=NodeFilter.FILTER_ACCEPT,U=NodeFilter.FILTER_REJECT,L;this.rerender=function(){J&&L.trigger()};this.show=function(){J=!0;L.trigger()};this.hide=function(){J=!1;L.trigger()};this.destroy=function(c){core.Async.destroyAll([L.destroy,a],c)};(function(){var a=
g.getMemberId();L=core.Task.createRedrawTask(q);l();u.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",a);k.classList.add("webodf-virtualSelections");g.getDocument().subscribe(ops.Document.signalCursorMoved,f);B.subscribe(gui.ZoomHelper.signalZoomChanged,m);m(B.getZoomLevel())})()};
gui.UndoStateRules=function(){function g(b,d){var h=b.length;this.previous=function(){for(--h;0<=h;--h)if(d(b[h]))return b[h];return null}}function l(b){b=b.spec();var d;b.hasOwnProperty("position")&&(d=b.position);return d}function d(b){return b.isEdit}function b(b,d,g){if(!g)return g=l(b)-l(d),0===g||1===Math.abs(g);b=l(b);d=l(d);g=l(g);return b-d===d-g}this.isEditOperation=d;this.isPartOfOperationSet=function(h,l){var n=void 0!==h.group,p;if(!h.isEdit||0===l.length)return!0;p=l[l.length-1];if(n&&
h.group===p.group)return!0;a:switch(h.spec().optype){case "RemoveText":case "InsertText":p=!0;break a;default:p=!1}if(p&&l.some(d)){if(n){var q;n=h.spec().optype;p=new g(l,d);var f=p.previous(),m=null,a,c;runtime.assert(!!f,"No edit operations found in state");c=f.group;runtime.assert(void 0!==c,"Operation has no group");for(a=1;f&&f.group===c;){if(n===f.spec().optype){q=f;break}f=p.previous()}if(q){for(f=p.previous();f;){if(f.group!==c){if(2===a)break;c=f.group;a+=1}if(n===f.spec().optype){m=f;break}f=
p.previous()}q=b(h,q,m)}else q=!1;return q}q=h.spec().optype;n=new g(l,d);p=n.previous();runtime.assert(!!p,"No edit operations found in state");q=q===p.spec().optype?b(h,p,n.previous()):!1;return q}return!1}};
(function(){function g(b,d){this.mainId=void 0!==b?b:-1;this.subId=void 0!==d?d:-1}function l(b,h,l){function n(d,a){return d+(b.isEditOperation(a)?1:0)}var p,q,f;this.addOperation=function(d){b.isEditOperation(d)&&(f+=1);q.push(d)};this.isNextStateId=function(b){return b.mainId===p&&b.subId===f};this.getNextStateId=function(){return new g(p,f)};this.getOperations=function(){return q};p=d+=1;q=h||[];f=h&&l?h.reduce(n,0):0}var d=0;gui.TrivialUndoManager=function(b){function d(){return!0!==t.isNextStateId(z)}
function n(a){a=a.getOperations();0<a.length&&(K=!0,y(a),K=!1)}function r(){J.emit(gui.UndoManager.signalUndoStackChanged,{undoAvailable:e.hasUndoStates(),redoAvailable:e.hasRedoStates()})}function p(a){var c=d();a!==c&&J.emit(gui.UndoManager.signalDocumentModifiedChanged,c)}function q(){t!==u&&t!==v[v.length-1]&&v.push(t)}function f(a){var c=a.previousSibling||a.nextSibling;a.parentNode.removeChild(a);k.normalizeTextNodes(c)}function m(a){return Object.keys(a).map(function(c){return a[c]})}function a(a){function c(a){var c=
a.spec();if(e[c.memberid])switch(c.optype){case "AddCursor":b[c.memberid]||(b[c.memberid]=a,delete e[c.memberid],--f);break;case "MoveCursor":d[c.memberid]||(d[c.memberid]=a)}}var b={},d={},e={},f,k;k=a.pop();w.getMemberIds().forEach(function(a){e[a]=!0});for(f=Object.keys(e).length;k&&0<f;)k=k.getOperations(),k.reverse(),k.forEach(c),k=a.pop();return new l(H,m(b).concat(m(d)))}function c(){var c=d(),b=x=w.cloneDocumentElement();k.getElementsByTagNameNS(b,"urn:webodf:names:cursor","cursor").forEach(f);
k.getElementsByTagNameNS(b,"urn:webodf:names:cursor","anchor").forEach(f);q();t=u=a([u].concat(v));v.length=0;B.length=0;c||(z=t.getNextStateId());r();p(c)}var e=this,k=core.DomUtils,x,u,y,w,z,t,v=[],B=[],J=new core.EventNotifier([gui.UndoManager.signalUndoStackChanged,gui.UndoManager.signalUndoStateCreated,gui.UndoManager.signalUndoStateModified,gui.UndoManager.signalDocumentModifiedChanged,gui.TrivialUndoManager.signalDocumentRootReplaced]),H=b||new gui.UndoStateRules,K=!1;this.subscribe=function(a,
c){J.subscribe(a,c)};this.unsubscribe=function(a,c){J.unsubscribe(a,c)};this.isDocumentModified=d;this.setDocumentModified=function(a){d()!==a&&(z=a?new g:t.getNextStateId(),J.emit(gui.UndoManager.signalDocumentModifiedChanged,a))};this.hasUndoStates=function(){return 0<v.length};this.hasRedoStates=function(){return 0<B.length};this.setDocument=function(a){w=a};this.purgeInitialState=function(){var a=d();v.length=0;B.length=0;t=u=new l(H);z=t.getNextStateId();x=null;r();p(a)};this.setInitialState=
c;this.initialize=function(){x||c()};this.setPlaybackFunction=function(a){y=a};this.onOperationExecuted=function(a){if(!K){var c=d();H.isEditOperation(a)&&(t===u||0<B.length)||!H.isPartOfOperationSet(a,t.getOperations())?(B.length=0,q(),t=new l(H,[a],!0),v.push(t),J.emit(gui.UndoManager.signalUndoStateCreated,{operations:t.getOperations()}),r()):(t.addOperation(a),J.emit(gui.UndoManager.signalUndoStateModified,{operations:t.getOperations()}));p(c)}};this.moveForward=function(a){for(var c=0,b=d(),
e;a&&B.length;)e=B.pop(),v.push(e),n(e),--a,c+=1;c&&(t=v[v.length-1],r(),p(b));return c};this.moveBackward=function(a){for(var c=0,b=d();a&&v.length;)B.push(v.pop()),--a,c+=1;c&&(w.getMemberIds().forEach(function(a){w.hasCursor(a)&&w.removeCursor(a)}),w.setDocumentElement(x.cloneNode(!0)),J.emit(gui.TrivialUndoManager.signalDocumentRootReplaced,{}),n(u),v.forEach(n),t=v[v.length-1]||u,r(),p(b));return c};t=u=new l(H);z=t.getNextStateId()};gui.TrivialUndoManager.signalDocumentRootReplaced="documentRootReplaced"})();
odf.GraphicProperties=function(g,l,d){var b=this,h=odf.Namespaces.stylens,n=odf.Namespaces.svgns;this.verticalPos=function(){return b.data.value("verticalPos")};this.verticalRel=function(){return b.data.value("verticalRel")};this.horizontalPos=function(){return b.data.value("horizontalPos")};this.horizontalRel=function(){return b.data.value("horizontalRel")};this.strokeWidth=function(){return b.data.value("strokeWidth")};b.data=new odf.LazyStyleProperties(void 0===d?void 0:d.data,{verticalPos:function(){var b=
g.getAttributeNS(h,"vertical-pos");return""===b?void 0:b},verticalRel:function(){var b=g.getAttributeNS(h,"vertical-rel");return""===b?void 0:b},horizontalPos:function(){var b=g.getAttributeNS(h,"horizontal-pos");return""===b?void 0:b},horizontalRel:function(){var b=g.getAttributeNS(h,"horizontal-rel");return""===b?void 0:b},strokeWidth:function(){var b=g.getAttributeNS(n,"stroke-width");return l.parseLength(b)}})};
odf.ComputedGraphicProperties=function(){var g;this.setGraphicProperties=function(l){g=l};this.verticalPos=function(){return g&&g.verticalPos()||"from-top"};this.verticalRel=function(){return g&&g.verticalRel()||"page"};this.horizontalPos=function(){return g&&g.horizontalPos()||"from-left"};this.horizontalRel=function(){return g&&g.horizontalRel()||"page"}};
odf.PageLayoutProperties=function(g,l,d){var b=this,h=odf.Namespaces.fons;this.pageHeight=function(){return b.data.value("pageHeight")||1123};this.pageWidth=function(){return b.data.value("pageWidth")||794};b.data=new odf.LazyStyleProperties(void 0===d?void 0:d.data,{pageHeight:function(){var b;g&&(b=g.getAttributeNS(h,"page-height"),b=l.parseLength(b));return b},pageWidth:function(){var b;g&&(b=g.getAttributeNS(h,"page-width"),b=l.parseLength(b));return b}})};
odf.PageLayout=function(g,l,d){var b=null;g&&(b=l.getPropertiesElement("page-layout-properties",g));this.pageLayout=new odf.PageLayoutProperties(b,l,d&&d.pageLayout)};odf.PageLayoutCache=function(){};odf.PageLayoutCache.prototype.getPageLayout=function(g){};odf.PageLayoutCache.prototype.getDefaultPageLayout=function(){};
odf.ParagraphProperties=function(g,l,d){var b=this,h=odf.Namespaces.fons;this.marginTop=function(){return b.data.value("marginTop")};b.data=new odf.LazyStyleProperties(void 0===d?void 0:d.data,{marginTop:function(){var b=g.getAttributeNS(h,"margin-top");return l.parsePositiveLengthOrPercent(b,"marginTop",d&&d.data)}})};
odf.ComputedParagraphProperties=function(){var g={},l=[];this.setStyleChain=function(d){l=d;g={}};this.marginTop=function(){var d,b;if(g.hasOwnProperty("marginTop"))d=g.marginTop;else{for(b=0;void 0===d&&b<l.length;b+=1)d=l[b].marginTop();g.marginTop=d}return d||0}};
odf.TextProperties=function(g,l,d){var b=this,h=odf.Namespaces.fons;this.fontSize=function(){return b.data.value("fontSize")};b.data=new odf.LazyStyleProperties(void 0===d?void 0:d.data,{fontSize:function(){var b=g.getAttributeNS(h,"font-size");return l.parsePositiveLengthOrPercent(b,"fontSize",d&&d.data)}})};
odf.ComputedTextProperties=function(){var g={},l=[];this.setStyleChain=function(d){l=d;g={}};this.fontSize=function(){var d,b;if(g.hasOwnProperty("fontSize"))d=g.fontSize;else{for(b=0;void 0===d&&b<l.length;b+=1)d=l[b].fontSize();g.fontSize=d}return d||12}};odf.MasterPage=function(g,l){var d;g?(d=g.getAttributeNS(odf.Namespaces.stylens,"page-layout-name"),this.pageLayout=l.getPageLayout(d)):this.pageLayout=l.getDefaultPageLayout()};odf.MasterPageCache=function(){};
odf.MasterPageCache.prototype.getMasterPage=function(g){};
odf.StylePileEntry=function(g,l,d,b){this.masterPage=function(){var b=g.getAttributeNS(odf.Namespaces.stylens,"master-page-name"),l=null;b&&(l=d.getMasterPage(b));return l};(function(d){var h=g.getAttributeNS(odf.Namespaces.stylens,"family"),r=null;if("graphic"===h||"chart"===h)d.graphic=void 0===b?void 0:b.graphic,r=l.getPropertiesElement("graphic-properties",g,r),null!==r&&(d.graphic=new odf.GraphicProperties(r,l,d.graphic));if("paragraph"===h||"table-cell"===h||"graphic"===h||"presentation"===
h||"chart"===h)d.paragraph=void 0===b?void 0:b.paragraph,r=l.getPropertiesElement("paragraph-properties",g,r),null!==r&&(d.paragraph=new odf.ParagraphProperties(r,l,d.paragraph));if("text"===h||"paragraph"===h||"table-cell"===h||"graphic"===h||"presentation"===h||"chart"===h)d.text=void 0===b?void 0:b.text,r=l.getPropertiesElement("text-properties",g,r),null!==r&&(d.text=new odf.TextProperties(r,l,d.text))})(this)};
odf.StylePile=function(g,l){function d(d,a){var c,e;d.hasAttributeNS(b,"parent-style-name")&&(e=d.getAttributeNS(b,"parent-style-name"),-1===a.indexOf(e)&&(c=f(e,a)));return new odf.StylePileEntry(d,g,l,c)}var b=odf.Namespaces.stylens,h={},n={},r,p={},q={},f;f=function(b,a){var c=p[b],e;!c&&(e=h[b])&&(a.push(b),c=d(e,a),p[b]=c);return c};this.getStyle=function(b){var a=q[b]||p[b],c,e=[];a||(c=n[b],c||(c=h[b])&&e.push(b),c&&(a=d(c,e)));return a};this.addCommonStyle=function(d){var a;d.hasAttributeNS(b,
"name")&&(a=d.getAttributeNS(b,"name"),h.hasOwnProperty(a)||(h[a]=d))};this.addAutomaticStyle=function(d){var a;d.hasAttributeNS(b,"name")&&(a=d.getAttributeNS(b,"name"),n.hasOwnProperty(a)||(n[a]=d))};this.setDefaultStyle=function(b){void 0===r&&(r=d(b,[]))};this.getDefaultStyle=function(){return r}};odf.ComputedGraphicStyle=function(){this.text=new odf.ComputedTextProperties;this.paragraph=new odf.ComputedParagraphProperties;this.graphic=new odf.ComputedGraphicProperties};
odf.ComputedParagraphStyle=function(){this.text=new odf.ComputedTextProperties;this.paragraph=new odf.ComputedParagraphProperties};odf.ComputedTextStyle=function(){this.text=new odf.ComputedTextProperties};
odf.StyleCache=function(g){function l(a,c,b,d){c=b.getAttributeNS(c,"class-names");var e;if(c)for(c=c.split(" "),e=0;e<c.length;e+=1)if(b=c[e])d.push(a),d.push(b)}function d(a,c){var b=u.getStyleName("paragraph",a);void 0!==b&&(c.push("paragraph"),c.push(b));a.namespaceURI!==k||"h"!==a.localName&&"p"!==a.localName||l("paragraph",k,a,c);return c}function b(a,c,b){var d=[],e,f,k,g;for(e=0;e<a.length;e+=2)k=a[e],g=a[e+1],k=p[k],g=k.getStyle(g),void 0!==g&&(g=g[c],void 0!==g&&g!==f&&(d.push(g),f=g));
k=p[b];if(g=k.getDefaultStyle())g=g[c],void 0!==g&&g!==f&&d.push(g);return d}function h(a,c){var b=u.getStyleName("text",a),e=a.parentNode;void 0!==b&&(c.push("text"),c.push(b));"span"===a.localName&&a.namespaceURI===k&&l("text",k,a,c);if(!e||e===g)return c;e.namespaceURI!==k||"p"!==e.localName&&"h"!==e.localName?h(e,c):d(e,c);return c}function n(a){a=a.getAttributeNS(x,"family");return p[a]}var r=this,p,q,f,m,a,c,e,k=odf.Namespaces.textns,x=odf.Namespaces.stylens,u=new odf.StyleInfo,y=new odf.StyleParseUtils,
w,z,t,v,B,J;this.getComputedGraphicStyle=function(a){var c=[];a=u.getStyleName("graphic",a);void 0!==a&&(c.push("graphic"),c.push(a));a=c.join("/");var d=m[a];runtime.assert(0===c.length%2,"Invalid style chain.");void 0===d&&(d=new odf.ComputedGraphicStyle,d.graphic.setGraphicProperties(b(c,"graphic","graphic")[0]),d.text.setStyleChain(b(c,"text","graphic")),d.paragraph.setStyleChain(b(c,"paragraph","graphic")),m[a]=d);return d};this.getComputedParagraphStyle=function(a){a=d(a,[]);var c=a.join("/"),
e=f[c];runtime.assert(0===a.length%2,"Invalid style chain.");void 0===e&&(e=new odf.ComputedParagraphStyle,e.text.setStyleChain(b(a,"text","paragraph")),e.paragraph.setStyleChain(b(a,"paragraph","paragraph")),f[c]=e);return e};this.getComputedTextStyle=function(a){a=h(a,[]);var c=a.join("/"),d=q[c];runtime.assert(0===a.length%2,"Invalid style chain.");void 0===d&&(d=new odf.ComputedTextStyle,d.text.setStyleChain(b(a,"text","text")),q[c]=d);return d};this.getPageLayout=function(a){var c=J[a];c||((c=
B[a])?(c=new odf.PageLayout(c,y,v),J[a]=c):c=v);return c};this.getDefaultPageLayout=function(){return v};this.getMasterPage=function(a){var c=z[a];void 0===c&&((c=w[a])?(c=new odf.MasterPage(c,r),z[a]=c):c=null);return c};this.getDefaultMasterPage=function(){return t};this.update=function(){var b,d,k=null,h=null;q={};f={};m={};w={};z={};J={};B={};a=new odf.StylePile(y,r);c=new odf.StylePile(y,r);e=new odf.StylePile(y,r);p={text:a,paragraph:c,graphic:e};for(b=g.styles.firstElementChild;b;)b.namespaceURI===
x&&((d=n(b))?"style"===b.localName?d.addCommonStyle(b):"default-style"===b.localName&&d.setDefaultStyle(b):"default-page-layout"===b.localName&&(k=b)),b=b.nextElementSibling;v=new odf.PageLayout(k,y);for(b=g.automaticStyles.firstElementChild;b;)b.namespaceURI===x&&((d=n(b))&&"style"===b.localName?d.addAutomaticStyle(b):"page-layout"===b.localName&&(B[b.getAttributeNS(x,"name")]=b)),b=b.nextElementSibling;for(b=g.masterStyles.firstElementChild;b;)b.namespaceURI===x&&"master-page"===b.localName&&(h=
h||b,d=b,k=d.getAttributeNS(x,"name"),0<k.length&&!w.hasOwnProperty(k)&&(w[k]=d)),b=b.nextElementSibling;t=new odf.MasterPage(h,r)}};
ops.OperationTransformMatrix=function(){function g(a){a.position+=a.length;a.length*=-1}function l(a){var c=0>a.length;c&&g(a);return c}function d(a,c){function b(b){a[b]===c&&d.push(b)}var d=[];a&&["style:parent-style-name","style:next-style-name"].forEach(b);return d}function b(a,c){function b(b){a[b]===c&&delete a[b]}a&&["style:parent-style-name","style:next-style-name"].forEach(b)}function h(a){var c={};Object.keys(a).forEach(function(b){c[b]="object"===typeof a[b]?h(a[b]):a[b]});return c}function n(a,
c,b,d){var e,f=!1,k=!1,g,h=[];d&&d.attributes&&(h=d.attributes.split(","));a&&(b||0<h.length)&&Object.keys(a).forEach(function(c){var d=a[c],e;"object"!==typeof d&&(b&&(e=b[c]),void 0!==e?(delete a[c],k=!0,e===d&&(delete b[c],f=!0)):-1!==h.indexOf(c)&&(delete a[c],k=!0))});if(c&&c.attributes&&(b||0<h.length)){g=c.attributes.split(",");for(d=0;d<g.length;d+=1)if(e=g[d],b&&void 0!==b[e]||h&&-1!==h.indexOf(e))g.splice(d,1),--d,k=!0;0<g.length?c.attributes=g.join(","):delete c.attributes}return{majorChanged:f,
minorChanged:k}}function r(a){for(var c in a)if(a.hasOwnProperty(c))return!0;return!1}function p(a){for(var c in a)if(a.hasOwnProperty(c)&&("attributes"!==c||0<a.attributes.length))return!0;return!1}function q(a,c,b,d,f){var e=a?a[f]:null,k=c?c[f]:null,g=b?b[f]:null,h=d?d[f]:null,l;l=n(e,k,g,h);e&&!r(e)&&delete a[f];k&&!p(k)&&delete c[f];g&&!r(g)&&delete b[f];h&&!p(h)&&delete d[f];return l}function f(a,c){return{opSpecsA:[a],opSpecsB:[c]}}var m;m={AddAnnotation:{AddAnnotation:function(a,c,b){var d;
a.position<c.position?(d=a,b=c):c.position<a.position?(d=c,b=a):(d=b?a:c,b=b?c:a);b.position<d.position+d.length&&(d.length+=2);b.position+=2;return{opSpecsA:[a],opSpecsB:[c]}},AddCursor:f,AddMember:f,AddStyle:f,ApplyDirectStyling:function(a,c){a.position<=c.position?c.position+=2:a.position<=c.position+c.length&&(c.length+=2);return{opSpecsA:[a],opSpecsB:[c]}},InsertText:function(a,c){c.position<=a.position?a.position+=c.text.length:(void 0!==a.length&&c.position<=a.position+a.length&&(a.length+=
c.text.length),c.position+=2);return{opSpecsA:[a],opSpecsB:[c]}},MergeParagraph:function(a,c){c.sourceStartPosition<=a.position?--a.position:(void 0!==a.length&&c.sourceStartPosition<=a.position+a.length&&--a.length,c.sourceStartPosition+=2,a.position<c.destinationStartPosition&&(c.destinationStartPosition+=2));return{opSpecsA:[a],opSpecsB:[c]}},MoveCursor:function(a,c){var b=l(c);a.position<c.position?c.position+=2:a.position<c.position+c.length&&(c.length+=2);b&&g(c);return{opSpecsA:[a],opSpecsB:[c]}},
RemoveAnnotation:function(a,c){a.position<c.position?(c.position<a.position+a.length&&(a.length-=c.length+2),c.position+=2):a.position-=c.length+2;return{opSpecsA:[a],opSpecsB:[c]}},RemoveCursor:f,RemoveMember:f,RemoveStyle:f,RemoveText:function(a,c){var b=c.position,d=c.position+c.length,f,g=[a],h=[c];a.position<=c.position?c.position+=2:a.position<d&&(c.length=a.position-c.position,f={optype:"RemoveText",memberid:c.memberid,timestamp:c.timestamp,position:a.position+2,length:d-a.position},h.unshift(f));
c.position+c.length<=a.position?(a.position-=c.length,void 0!==a.length&&f&&(a.length=f.length>=a.length?0:a.length-f.length)):void 0!==a.length&&(f=a.position+a.length,d<=f?a.length-=c.length:b<f&&(a.length=b-a.position));return{opSpecsA:g,opSpecsB:h}},SetParagraphStyle:function(a,c){a.position<c.position&&(c.position+=2);return{opSpecsA:[a],opSpecsB:[c]}},SplitParagraph:function(a,c){a.position<c.sourceParagraphPosition&&(c.sourceParagraphPosition+=2);c.position<=a.position?a.position+=1:(void 0!==
a.length&&c.position<=a.position+a.length&&(a.length+=1),c.position+=2);return{opSpecsA:[a],opSpecsB:[c]}},UpdateMember:f,UpdateMetadata:f,UpdateParagraphStyle:f},AddCursor:{AddCursor:f,AddMember:f,AddStyle:f,ApplyDirectStyling:f,InsertText:f,MergeParagraph:f,MoveCursor:f,RemoveAnnotation:f,RemoveCursor:f,RemoveMember:f,RemoveStyle:f,RemoveText:f,SetParagraphStyle:f,SplitParagraph:f,UpdateMember:f,UpdateMetadata:f,UpdateParagraphStyle:f},AddMember:{AddStyle:f,ApplyDirectStyling:f,InsertText:f,MergeParagraph:f,
MoveCursor:f,RemoveAnnotation:f,RemoveCursor:f,RemoveStyle:f,RemoveText:f,SetParagraphStyle:f,SplitParagraph:f,UpdateMetadata:f,UpdateParagraphStyle:f},AddStyle:{AddStyle:f,ApplyDirectStyling:f,InsertText:f,MergeParagraph:f,MoveCursor:f,RemoveAnnotation:f,RemoveCursor:f,RemoveMember:f,RemoveStyle:function(a,c){var e,f=[a],g=[c];a.styleFamily===c.styleFamily&&(e=d(a.setProperties,c.styleName),0<e.length&&(e={optype:"UpdateParagraphStyle",memberid:c.memberid,timestamp:c.timestamp,styleName:a.styleName,
removedProperties:{attributes:e.join(",")}},g.unshift(e)),b(a.setProperties,c.styleName));return{opSpecsA:f,opSpecsB:g}},RemoveText:f,SetParagraphStyle:f,SplitParagraph:f,UpdateMember:f,UpdateMetadata:f,UpdateParagraphStyle:f},ApplyDirectStyling:{ApplyDirectStyling:function(a,c,b){var d,e,f,g,l,m,n,p;g=[a];f=[c];if(!(a.position+a.length<=c.position||a.position>=c.position+c.length)){d=b?a:c;e=b?c:a;if(a.position!==c.position||a.length!==c.length)m=h(d),n=h(e);c=q(e.setProperties,null,d.setProperties,
null,"style:text-properties");if(c.majorChanged||c.minorChanged)f=[],a=[],g=d.position+d.length,l=e.position+e.length,e.position<d.position?c.minorChanged&&(p=h(n),p.length=d.position-e.position,a.push(p),e.position=d.position,e.length=l-e.position):d.position<e.position&&c.majorChanged&&(p=h(m),p.length=e.position-d.position,f.push(p),d.position=e.position,d.length=g-d.position),l>g?c.minorChanged&&(m=n,m.position=g,m.length=l-g,a.push(m),e.length=g-e.position):g>l&&c.majorChanged&&(m.position=l,
m.length=g-l,f.push(m),d.length=l-d.position),d.setProperties&&r(d.setProperties)&&f.push(d),e.setProperties&&r(e.setProperties)&&a.push(e),b?(g=f,f=a):g=a}return{opSpecsA:g,opSpecsB:f}},InsertText:function(a,c){c.position<=a.position?a.position+=c.text.length:c.position<=a.position+a.length&&(a.length+=c.text.length);return{opSpecsA:[a],opSpecsB:[c]}},MergeParagraph:function(a,c){var b=a.position,d=a.position+a.length;b>=c.sourceStartPosition&&--b;d>=c.sourceStartPosition&&--d;a.position=b;a.length=
d-b;return{opSpecsA:[a],opSpecsB:[c]}},MoveCursor:f,RemoveAnnotation:function(a,c){var b=a.position,d=a.position+a.length,f=c.position+c.length,g=[a],h=[c];c.position<=b&&d<=f?g=[]:(f<b&&(b-=c.length+2),f<d&&(d-=c.length+2),a.position=b,a.length=d-b);return{opSpecsA:g,opSpecsB:h}},RemoveCursor:f,RemoveMember:f,RemoveStyle:f,RemoveText:function(a,c){var b=a.position+a.length,d=c.position+c.length,f=[a],g=[c];d<=a.position?a.position-=c.length:c.position<b&&(a.position<c.position?a.length=d<b?a.length-
c.length:c.position-a.position:(a.position=c.position,d<b?a.length=b-d:f=[]));return{opSpecsA:f,opSpecsB:g}},SetParagraphStyle:f,SplitParagraph:function(a,c){c.position<a.position?a.position+=1:c.position<a.position+a.length&&(a.length+=1);return{opSpecsA:[a],opSpecsB:[c]}},UpdateMember:f,UpdateMetadata:f,UpdateParagraphStyle:f},InsertText:{InsertText:function(a,c,b){a.position<c.position?c.position+=a.text.length:a.position>c.position?a.position+=c.text.length:b?c.position+=a.text.length:a.position+=
c.text.length;return{opSpecsA:[a],opSpecsB:[c]}},MergeParagraph:function(a,b){a.position>=b.sourceStartPosition?--a.position:(a.position<b.sourceStartPosition&&(b.sourceStartPosition+=a.text.length),a.position<b.destinationStartPosition&&(b.destinationStartPosition+=a.text.length));return{opSpecsA:[a],opSpecsB:[b]}},MoveCursor:function(a,b){var c=l(b);a.position<b.position?b.position+=a.text.length:a.position<b.position+b.length&&(b.length+=a.text.length);c&&g(b);return{opSpecsA:[a],opSpecsB:[b]}},
RemoveAnnotation:function(a,b){var c=a.position,d=b.position+b.length,f=[a],g=[b];b.position<=c&&c<=d?(f=[],b.length+=a.text.length):d<a.position?a.position-=b.length+2:b.position+=a.text.length;return{opSpecsA:f,opSpecsB:g}},RemoveCursor:f,RemoveMember:f,RemoveStyle:f,RemoveText:function(a,b){var c;c=b.position+b.length;var d=[a],f=[b];c<=a.position?a.position-=b.length:a.position<=b.position?b.position+=a.text.length:(b.length=a.position-b.position,c={optype:"RemoveText",memberid:b.memberid,timestamp:b.timestamp,
position:a.position+a.text.length,length:c-a.position},f.unshift(c),a.position=b.position);return{opSpecsA:d,opSpecsB:f}},SetParagraphStyle:function(a,b){b.position>a.position&&(b.position+=a.text.length);return{opSpecsA:[a],opSpecsB:[b]}},SplitParagraph:function(a,b){a.position<b.sourceParagraphPosition&&(b.sourceParagraphPosition+=a.text.length);a.position<=b.position?b.position+=a.text.length:a.position+=1;return{opSpecsA:[a],opSpecsB:[b]}},UpdateMember:f,UpdateMetadata:f,UpdateParagraphStyle:f},
MergeParagraph:{MergeParagraph:function(a,b,d){var c=[a],e=[b],f;a.destinationStartPosition===b.destinationStartPosition?(c=[],e=[],a.moveCursor&&(f={optype:"MoveCursor",memberid:a.memberid,timestamp:a.timestamp,position:a.sourceStartPosition-1},c.push(f)),b.moveCursor&&(f={optype:"MoveCursor",memberid:b.memberid,timestamp:b.timestamp,position:b.sourceStartPosition-1},e.push(f)),a=d?a:b,a={optype:"SetParagraphStyle",memberid:a.memberid,timestamp:a.timestamp,position:a.destinationStartPosition,styleName:a.paragraphStyleName},
d?c.push(a):e.push(a)):b.sourceStartPosition===a.destinationStartPosition?(a.destinationStartPosition=b.destinationStartPosition,--a.sourceStartPosition,a.paragraphStyleName=b.paragraphStyleName):a.sourceStartPosition===b.destinationStartPosition?(b.destinationStartPosition=a.destinationStartPosition,--b.sourceStartPosition,b.paragraphStyleName=a.paragraphStyleName):a.destinationStartPosition<b.destinationStartPosition?(--b.destinationStartPosition,--b.sourceStartPosition):(--a.destinationStartPosition,
--a.sourceStartPosition);return{opSpecsA:c,opSpecsB:e}},MoveCursor:function(a,b){var c=b.position,d=b.position+b.length,f=Math.min(c,d),c=Math.max(c,d);f>=a.sourceStartPosition&&--f;c>=a.sourceStartPosition&&--c;0<=b.length?(b.position=f,b.length=c-f):(b.position=c,b.length=f-c);return{opSpecsA:[a],opSpecsB:[b]}},RemoveAnnotation:function(a,b){var c=b.position+b.length,d=[a],f=[b];b.position<=a.destinationStartPosition&&a.sourceStartPosition<=c?(d=[],--b.length):a.sourceStartPosition<b.position?--b.position:
(c<a.destinationStartPosition&&(a.destinationStartPosition-=b.length+2),c<a.sourceStartPosition&&(a.sourceStartPosition-=b.length+2));return{opSpecsA:d,opSpecsB:f}},RemoveCursor:f,RemoveMember:f,RemoveStyle:f,RemoveText:function(a,b){b.position>=a.sourceStartPosition?--b.position:(b.position<a.destinationStartPosition&&(a.destinationStartPosition-=b.length),b.position<a.sourceStartPosition&&(a.sourceStartPosition-=b.length));return{opSpecsA:[a],opSpecsB:[b]}},SetParagraphStyle:function(a,b){var c=
[a],d=[b];if(b.position>a.sourceStartPosition)--b.position;else if(b.position===a.destinationStartPosition||b.position===a.sourceStartPosition)b.position=a.destinationStartPosition,a.paragraphStyleName=b.styleName;return{opSpecsA:c,opSpecsB:d}},SplitParagraph:function(a,b){var c,d=[a],f=[b];b.position<a.destinationStartPosition?(a.destinationStartPosition+=1,a.sourceStartPosition+=1):b.position>=a.destinationStartPosition&&b.position<a.sourceStartPosition?(b.paragraphStyleName=a.paragraphStyleName,
c={optype:"SetParagraphStyle",memberid:a.memberid,timestamp:a.timestamp,position:a.destinationStartPosition,styleName:a.paragraphStyleName},d.push(c),b.position===a.sourceStartPosition-1&&a.moveCursor&&(c={optype:"MoveCursor",memberid:a.memberid,timestamp:a.timestamp,position:b.position,length:0},d.push(c)),a.destinationStartPosition=b.position+1,a.sourceStartPosition+=1):b.position>=a.sourceStartPosition&&(--b.position,--b.sourceParagraphPosition);return{opSpecsA:d,opSpecsB:f}},UpdateMember:f,UpdateMetadata:f,
UpdateParagraphStyle:f},MoveCursor:{MoveCursor:f,RemoveAnnotation:function(a,b){var c=l(a),d=a.position+a.length,f=b.position+b.length;b.position<=a.position&&d<=f?(a.position=b.position-1,a.length=0):(f<a.position?a.position-=b.length+2:f<d&&(a.length-=b.length+2),c&&g(a));return{opSpecsA:[a],opSpecsB:[b]}},RemoveCursor:function(a,b){return{opSpecsA:a.memberid===b.memberid?[]:[a],opSpecsB:[b]}},RemoveMember:f,RemoveStyle:f,RemoveText:function(a,b){var c=l(a),d=a.position+a.length,f=b.position+b.length;
f<=a.position?a.position-=b.length:b.position<d&&(a.position<b.position?a.length=f<d?a.length-b.length:b.position-a.position:(a.position=b.position,a.length=f<d?d-f:0));c&&g(a);return{opSpecsA:[a],opSpecsB:[b]}},SetParagraphStyle:f,SplitParagraph:function(a,b){var c=l(a);b.position<a.position?a.position+=1:b.position<a.position+a.length&&(a.length+=1);c&&g(a);return{opSpecsA:[a],opSpecsB:[b]}},UpdateMember:f,UpdateMetadata:f,UpdateParagraphStyle:f},RemoveAnnotation:{RemoveAnnotation:function(a,b){var c=
[a],d=[b];a.position===b.position&&a.length===b.length?(c=[],d=[]):a.position<b.position?b.position-=a.length+2:a.position-=b.length+2;return{opSpecsA:c,opSpecsB:d}},RemoveCursor:f,RemoveMember:f,RemoveStyle:f,RemoveText:function(a,b){var c=a.position+a.length,d=b.position+b.length,f=[a],g=[b];a.position<=b.position&&d<=c?(g=[],a.length-=b.length):d<a.position?a.position-=b.length:b.position<a.position?(a.position=b.position+1,b.length-=a.length+2):b.position-=a.length+2;return{opSpecsA:f,opSpecsB:g}},
SetParagraphStyle:function(a,b){var c=b.position,d=a.position+a.length,f=[a],g=[b];a.position<=c&&c<=d?g=[]:d<c&&(b.position-=a.length+2);return{opSpecsA:f,opSpecsB:g}},SplitParagraph:function(a,b){var c=b.position,d=a.position+a.length,f=[a],g=[b];a.position<=c&&c<=d?(g=[],a.length+=1):(d<b.sourceParagraphPosition&&(b.sourceParagraphPosition-=a.length+2),d<c?b.position-=a.length+2:a.position+=1);return{opSpecsA:f,opSpecsB:g}},UpdateMember:f,UpdateMetadata:f,UpdateParagraphStyle:f},RemoveCursor:{RemoveCursor:function(a,
b){var c=a.memberid===b.memberid;return{opSpecsA:c?[]:[a],opSpecsB:c?[]:[b]}},RemoveMember:f,RemoveStyle:f,RemoveText:f,SetParagraphStyle:f,SplitParagraph:f,UpdateMember:f,UpdateMetadata:f,UpdateParagraphStyle:f},RemoveMember:{RemoveStyle:f,RemoveText:f,SetParagraphStyle:f,SplitParagraph:f,UpdateMetadata:f,UpdateParagraphStyle:f},RemoveStyle:{RemoveStyle:function(a,b){var c=a.styleName===b.styleName&&a.styleFamily===b.styleFamily;return{opSpecsA:c?[]:[a],opSpecsB:c?[]:[b]}},RemoveText:f,SetParagraphStyle:function(a,
b){var c,d=[a],f=[b];"paragraph"===a.styleFamily&&a.styleName===b.styleName&&(c={optype:"SetParagraphStyle",memberid:a.memberid,timestamp:a.timestamp,position:b.position,styleName:""},d.unshift(c),b.styleName="");return{opSpecsA:d,opSpecsB:f}},SplitParagraph:f,UpdateMember:f,UpdateMetadata:f,UpdateParagraphStyle:function(a,c){var e,f=[a],g=[c];"paragraph"===a.styleFamily&&(e=d(c.setProperties,a.styleName),0<e.length&&(e={optype:"UpdateParagraphStyle",memberid:a.memberid,timestamp:a.timestamp,styleName:c.styleName,
removedProperties:{attributes:e.join(",")}},f.unshift(e)),a.styleName===c.styleName?g=[]:b(c.setProperties,a.styleName));return{opSpecsA:f,opSpecsB:g}}},RemoveText:{RemoveText:function(a,b){var c=a.position+a.length,d=b.position+b.length,f=[a],g=[b];d<=a.position?a.position-=b.length:c<=b.position?b.position-=a.length:b.position<c&&(a.position<b.position?(a.length=d<c?a.length-b.length:b.position-a.position,c<d?(b.position=a.position,b.length=d-c):g=[]):(c<d?b.length-=a.length:b.position<a.position?
b.length=a.position-b.position:g=[],d<c?(a.position=b.position,a.length=c-d):f=[]));return{opSpecsA:f,opSpecsB:g}},SetParagraphStyle:function(a,b){a.position<b.position&&(b.position-=a.length);return{opSpecsA:[a],opSpecsB:[b]}},SplitParagraph:function(a,b){var c=a.position+a.length,d=[a],f=[b];b.position<=a.position?a.position+=1:b.position<c&&(a.length=b.position-a.position,c={optype:"RemoveText",memberid:a.memberid,timestamp:a.timestamp,position:b.position+1,length:c-b.position},d.unshift(c));a.position+
a.length<=b.position?b.position-=a.length:a.position<b.position&&(b.position=a.position);a.position+a.length<b.sourceParagraphPosition&&(b.sourceParagraphPosition-=a.length);return{opSpecsA:d,opSpecsB:f}},UpdateMember:f,UpdateMetadata:f,UpdateParagraphStyle:f},SetParagraphStyle:{SetParagraphStyle:function(a,b,d){a.position===b.position&&(d?b.styleName=a.styleName:a.styleName=b.styleName);return{opSpecsA:[a],opSpecsB:[b]}},SplitParagraph:function(a,b){var c=[a],d=[b],f;a.position>b.position?a.position+=
1:a.position===b.sourceParagraphPosition&&(b.paragraphStyleName=a.styleName,f=h(a),f.position=b.position+1,c.push(f));return{opSpecsA:c,opSpecsB:d}},UpdateMember:f,UpdateMetadata:f,UpdateParagraphStyle:f},SplitParagraph:{SplitParagraph:function(a,b,d){var c,e;a.position<b.position?c=!0:b.position<a.position?e=!0:a.position===b.position&&(d?c=!0:e=!0);c?(b.position+=1,b.sourceParagraphPosition=a.position<b.sourceParagraphPosition?b.sourceParagraphPosition+1:a.position+1):e&&(a.position+=1,a.sourceParagraphPosition=
b.position<b.sourceParagraphPosition?a.sourceParagraphPosition+1:b.position+1);return{opSpecsA:[a],opSpecsB:[b]}},UpdateMember:f,UpdateMetadata:f,UpdateParagraphStyle:f},UpdateMember:{UpdateMetadata:f,UpdateParagraphStyle:f},UpdateMetadata:{UpdateMetadata:function(a,b,d){var c,e=[a],f=[b];c=d?a:b;a=d?b:a;n(a.setProperties||null,a.removedProperties||null,c.setProperties||null,c.removedProperties||null);c.setProperties&&r(c.setProperties)||c.removedProperties&&p(c.removedProperties)||(d?e=[]:f=[]);
a.setProperties&&r(a.setProperties)||a.removedProperties&&p(a.removedProperties)||(d?f=[]:e=[]);return{opSpecsA:e,opSpecsB:f}},UpdateParagraphStyle:f},UpdateParagraphStyle:{UpdateParagraphStyle:function(a,b,d){var c,e=[a],f=[b];a.styleName===b.styleName&&(c=d?a:b,a=d?b:a,q(a.setProperties,a.removedProperties,c.setProperties,c.removedProperties,"style:paragraph-properties"),q(a.setProperties,a.removedProperties,c.setProperties,c.removedProperties,"style:text-properties"),n(a.setProperties||null,a.removedProperties||
null,c.setProperties||null,c.removedProperties||null),c.setProperties&&r(c.setProperties)||c.removedProperties&&p(c.removedProperties)||(d?e=[]:f=[]),a.setProperties&&r(a.setProperties)||a.removedProperties&&p(a.removedProperties)||(d?f=[]:e=[]));return{opSpecsA:e,opSpecsB:f}}}};this.passUnchanged=f;this.extendTransformations=function(a){Object.keys(a).forEach(function(b){var c=a[b],d,f=m.hasOwnProperty(b);runtime.log((f?"Extending":"Adding")+" map for optypeA: "+b);f||(m[b]={});d=m[b];Object.keys(c).forEach(function(a){var e=
d.hasOwnProperty(a);runtime.assert(b<=a,"Wrong order:"+b+", "+a);runtime.log("  "+(e?"Overwriting":"Adding")+" entry for optypeB: "+a);d[a]=c[a]})})};this.transformOpspecVsOpspec=function(a,b){var c=a.optype<=b.optype,d;runtime.log("Crosstransforming:");runtime.log(runtime.toJson(a));runtime.log(runtime.toJson(b));c||(d=a,a=b,b=d);(d=(d=m[a.optype])&&d[b.optype])?(d=d(a,b,!c),c||null===d||(d={opSpecsA:d.opSpecsB,opSpecsB:d.opSpecsA})):d=null;runtime.log("result:");d?(runtime.log(runtime.toJson(d.opSpecsA)),
runtime.log(runtime.toJson(d.opSpecsB))):runtime.log("null");return d}};
ops.OperationTransformer=function(){function g(d,b){for(var h,n,r=[],p=[];0<d.length&&b;){h=d.shift();h=l.transformOpspecVsOpspec(h,b);if(!h)return null;r=r.concat(h.opSpecsA);if(0===h.opSpecsB.length){r=r.concat(d);b=null;break}for(;1<h.opSpecsB.length;){n=g(d,h.opSpecsB.shift());if(!n)return null;p=p.concat(n.opSpecsB);d=n.opSpecsA}b=h.opSpecsB.pop()}b&&p.push(b);return{opSpecsA:r,opSpecsB:p}}var l=new ops.OperationTransformMatrix;this.getOperationTransformMatrix=function(){return l};this.transform=
function(d,b){for(var h,l=[];0<b.length;){h=g(d,b.shift());if(!h)return null;d=h.opSpecsA;l=l.concat(h.opSpecsB)}return{opSpecsA:d,opSpecsB:l}}};var webodf_css='@namespace draw url(urn:oasis:names:tc:opendocument:xmlns:drawing:1.0);@namespace fo url(urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0);@namespace office url(urn:oasis:names:tc:opendocument:xmlns:office:1.0);@namespace presentation url(urn:oasis:names:tc:opendocument:xmlns:presentation:1.0);@namespace style url(urn:oasis:names:tc:opendocument:xmlns:style:1.0);@namespace svg url(urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0);@namespace table url(urn:oasis:names:tc:opendocument:xmlns:table:1.0);@namespace text url(urn:oasis:names:tc:opendocument:xmlns:text:1.0);@namespace webodfhelper url(urn:webodf:names:helper);@namespace cursor url(urn:webodf:names:cursor);@namespace editinfo url(urn:webodf:names:editinfo);@namespace annotation url(urn:webodf:names:annotation);@namespace dc url(http://purl.org/dc/elements/1.1/);@namespace svgns url(http://www.w3.org/2000/svg);office|document > *, office|document-content > * {display: none;}office|body, office|document {display: inline-block;position: relative;}text|p, text|h {display: block;padding: 0;margin: 0;line-height: normal;position: relative;}text|p::after, text|h::after {content: "\\200B";white-space: pre;}*[webodfhelper|containsparagraphanchor] {position: relative;}text|s {white-space: pre;}text|tab {display: inline;white-space: pre;}text|tracked-changes {display: none;}office|binary-data {display: none;}office|text {display: block;text-align: left;overflow: visible;word-wrap: break-word;}office|text::selection {background: transparent;}.webodf-virtualSelections *::selection {background: transparent;}.webodf-virtualSelections *::-moz-selection {background: transparent;}office|text * draw|text-box {display: block;border: 1px solid #d3d3d3;}office|text draw|frame {z-index: 1;}office|spreadsheet {display: block;border-collapse: collapse;empty-cells: show;font-family: sans-serif;font-size: 10pt;text-align: left;page-break-inside: avoid;overflow: hidden;}office|presentation {display: inline-block;text-align: left;}#shadowContent {display: inline-block;text-align: left;}draw|page {display: block;position: relative;overflow: hidden;}presentation|notes, presentation|footer-decl, presentation|date-time-decl {display: none;}@media print {draw|page {border: 1pt solid black;page-break-inside: avoid;}presentation|notes {}}office|spreadsheet text|p {border: 0px;padding: 1px;margin: 0px;}office|spreadsheet table|table {margin: 3px;}office|spreadsheet table|table:after {}office|spreadsheet table|table-row {counter-increment: row;}office|spreadsheet table|table-row:before {width: 3em;background: #cccccc;border: 1px solid black;text-align: center;content: counter(row);display: table-cell;}office|spreadsheet table|table-cell {border: 1px solid #cccccc;}table|table {display: table;}draw|frame table|table {width: 100%;height: 100%;background: white;}table|table-header-rows {display: table-header-group;}table|table-row {display: table-row;}table|table-column {display: table-column;}table|table-cell {width: 0.889in;display: table-cell;word-break: break-all;}draw|frame {display: block;}draw|image {display: block;width: 100%;height: 100%;top: 0px;left: 0px;background-repeat: no-repeat;background-size: 100% 100%;-moz-background-size: 100% 100%;}draw|frame > draw|image:nth-of-type(n+2) {display: none;}text|list:before {display: none;content:"";}text|list {display: block;}text|list-item {display: block;}text|number {display:none;}text|a {color: blue;text-decoration: underline;cursor: pointer;}.webodf-inactiveLinks text|a {cursor: text;}text|note-citation {vertical-align: super;font-size: smaller;}text|note-body {display: none;}text|note:hover text|note-citation {background: #dddddd;}text|note:hover text|note-body {display: block;left:1em;max-width: 80%;position: absolute;background: #ffffaa;}text|bibliography-source {display: none;}svg|title, svg|desc {display: none;}video {width: 100%;height: 100%}cursor|anchor {display: none;}cursor|cursor {display: none;}.webodf-caretOverlay {position: absolute;top: 5%;height: 1em;z-index: 10;padding-left: 1px;pointer-events: none;}.webodf-caretOverlay .caret {position: absolute;border-left: 2px solid black;top: 0;bottom: 0;right: 0;}.webodf-caretOverlay .handle {position: absolute;margin-top: 5px;padding-top: 3px;margin-left: auto;margin-right: auto;width: 64px;height: 68px;border-radius: 5px;opacity: 0.3;text-align: center;background-color: black;box-shadow: 0px 0px 5px rgb(90, 90, 90);border: 1px solid black;top: -85px;right: -32px;}.webodf-caretOverlay .handle > img {box-shadow: 0px 0px 5px rgb(90, 90, 90) inset;background-color: rgb(200, 200, 200);border-radius: 5px;border: 2px solid;height: 60px;width: 60px;display: block;margin: auto;}.webodf-caretOverlay .handle.active {opacity: 0.8;}.webodf-caretOverlay .handle:after {content: " ";position: absolute;width: 0px;height: 0px;border-style: solid;border-width: 8.7px 5px 0 5px;border-color: black transparent transparent transparent;top: 100%;left: 43%;}.webodf-caretSizer {display: inline-block;width: 0;visibility: hidden;}#eventTrap {display: block;position: absolute;bottom: 0;left: 0;outline: none;opacity: 0;color: rgba(255, 255, 255, 0);pointer-events: none;white-space: pre;overflow: hidden;}cursor|cursor > #composer {text-decoration: underline;}cursor|cursor[cursor|caret-sizer-active="true"],cursor|cursor[cursor|composing="true"] {display: inline;}editinfo|editinfo {display: inline-block;}.editInfoMarker {position: absolute;width: 10px;height: 100%;left: -20px;opacity: 0.8;top: 0;border-radius: 5px;background-color: transparent;box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);}.editInfoMarker:hover {box-shadow: 0px 0px 8px rgba(0, 0, 0, 1);}.editInfoHandle {position: absolute;background-color: black;padding: 5px;border-radius: 5px;opacity: 0.8;box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);bottom: 100%;margin-bottom: 10px;z-index: 3;left: -25px;}.editInfoHandle:after {content: " ";position: absolute;width: 0px;height: 0px;border-style: solid;border-width: 8.7px 5px 0 5px;border-color: black transparent transparent transparent;top: 100%;left: 5px;}.editInfo {font-family: sans-serif;font-weight: normal;font-style: normal;text-decoration: none;color: white;width: 100%;height: 12pt;}.editInfoColor {float: left;width: 10pt;height: 10pt;border: 1px solid white;}.editInfoAuthor {float: left;margin-left: 5pt;font-size: 10pt;text-align: left;height: 12pt;line-height: 12pt;}.editInfoTime {float: right;margin-left: 30pt;font-size: 8pt;font-style: italic;color: yellow;height: 12pt;line-height: 12pt;}.annotationWrapper {display: inline;position: relative;}.annotationRemoveButton:before {content: "\u00d7";color: white;padding: 5px;line-height: 1em;}.annotationRemoveButton {width: 20px;height: 20px;border-radius: 10px;background-color: black;box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);position: absolute;top: -10px;left: -10px;z-index: 3;text-align: center;font-family: sans-serif;font-style: normal;font-weight: normal;text-decoration: none;font-size: 15px;}.annotationRemoveButton:hover {cursor: pointer;box-shadow: 0px 0px 5px rgba(0, 0, 0, 1);}.annotationNote {width: 4cm;position: absolute;display: inline;z-index: 10;top: 0;}.annotationNote > office|annotation {display: block;text-align: left;}.annotationConnector {position: absolute;display: inline;top: 0;z-index: 2;border-top: 1px dashed brown;}.annotationConnector.angular {-moz-transform-origin: left top;-webkit-transform-origin: left top;-ms-transform-origin: left top;transform-origin: left top;}.annotationConnector.horizontal {left: 0;}.annotationConnector.horizontal:before {content: "";display: inline;position: absolute;width: 0px;height: 0px;border-style: solid;border-width: 8.7px 5px 0 5px;border-color: brown transparent transparent transparent;top: -1px;left: -5px;}office|annotation {width: 100%;height: 100%;display: none;background: rgb(198, 238, 184);background: -moz-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);background: -webkit-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);background: -o-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);background: -ms-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);background: linear-gradient(180deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);box-shadow: 0 3px 4px -3px #ccc;}office|annotation > dc|creator {display: block;font-size: 10pt;font-weight: normal;font-style: normal;font-family: sans-serif;color: white;background-color: brown;padding: 4px;}office|annotation > dc|date {display: block;font-size: 10pt;font-weight: normal;font-style: normal;font-family: sans-serif;border: 4px solid transparent;color: black;}office|annotation > text|list {display: block;padding: 5px;}office|annotation text|p {font-size: 10pt;color: black;font-weight: normal;font-style: normal;text-decoration: none;font-family: sans-serif;}#annotationsPane {background-color: #EAEAEA;width: 4cm;height: 100%;display: none;position: absolute;outline: 1px solid #ccc;}.webodf-annotationHighlight {background-color: yellow;position: relative;}.webodf-selectionOverlay {position: absolute;pointer-events: none;top: 0;left: 0;top: 0;left: 0;width: 100%;height: 100%;z-index: 15;}.webodf-selectionOverlay > polygon {fill-opacity: 0.3;stroke-opacity: 0.8;stroke-width: 1;fill-rule: evenodd;}.webodf-selectionOverlay > .webodf-draggable {fill-opacity: 0.8;stroke-opacity: 0;stroke-width: 8;pointer-events: all;display: none;-moz-transform-origin: center center;-webkit-transform-origin: center center;-ms-transform-origin: center center;transform-origin: center center;}#imageSelector {display: none;position: absolute;border-style: solid;border-color: black;}#imageSelector > div {width: 5px;height: 5px;display: block;position: absolute;border: 1px solid black;background-color: #ffffff;}#imageSelector > .topLeft {top: -4px;left: -4px;}#imageSelector > .topRight {top: -4px;right: -4px;}#imageSelector > .bottomRight {right: -4px;bottom: -4px;}#imageSelector > .bottomLeft {bottom: -4px;left: -4px;}#imageSelector > .topMiddle {top: -4px;left: 50%;margin-left: -2.5px;}#imageSelector > .rightMiddle {top: 50%;right: -4px;margin-top: -2.5px;}#imageSelector > .bottomMiddle {bottom: -4px;left: 50%;margin-left: -2.5px;}#imageSelector > .leftMiddle {top: 50%;left: -4px;margin-top: -2.5px;}div.webodf-customScrollbars::-webkit-scrollbar{width: 8px;height: 8px;background-color: transparent;}div.webodf-customScrollbars::-webkit-scrollbar-track{background-color: transparent;}div.webodf-customScrollbars::-webkit-scrollbar-thumb{background-color: #444;border-radius: 4px;}.webodf-hyperlinkTooltip {display: none;color: white;background-color: black;border-radius: 5px;box-shadow: 2px 2px 5px gray;padding: 3px;position: absolute;max-width: 210px;text-align: left;word-break: break-all;z-index: 16;}.webodf-hyperlinkTooltipText {display: block;font-weight: bold;}';/*

 @licstart
JSZip - A Javascript class for generating and reading zip files
<http://stuartk.com/jszip>

(c) 2009-2014 Stuart Knightley <stuart [at] stuartk.com>
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown.

JSZip uses the library pako released under the MIT license :
https://github.com/nodeca/pako/blob/master/LICENSE
 @licend
*/
!function(e){var globalScope=typeof window!=="undefined"?window:typeof global!=="undefined"?global:{},externs=globalScope.externs||(globalScope.externs={});externs.JSZip=e()}(function(){var define,module,exports;if(define||module||exports)console.log("");return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'");}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=
t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(_dereq_,module,exports){var _keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";exports.encode=function(input,utf8){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;while(i<input.length){chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=(chr1&3)<<
4|chr2>>4;enc3=(chr2&15)<<2|chr3>>6;enc4=chr3&63;if(isNaN(chr2))enc3=enc4=64;else if(isNaN(chr3))enc4=64;output=output+_keyStr.charAt(enc1)+_keyStr.charAt(enc2)+_keyStr.charAt(enc3)+_keyStr.charAt(enc4)}return output};exports.decode=function(input,utf8){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i<input.length){enc1=_keyStr.indexOf(input.charAt(i++));enc2=_keyStr.indexOf(input.charAt(i++));enc3=_keyStr.indexOf(input.charAt(i++));
enc4=_keyStr.indexOf(input.charAt(i++));chr1=enc1<<2|enc2>>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64)output=output+String.fromCharCode(chr2);if(enc4!=64)output=output+String.fromCharCode(chr3)}return output}},{}],2:[function(_dereq_,module,exports){function CompressedObject(){this.compressedSize=0;this.uncompressedSize=0;this.crc32=0;this.compressionMethod=null;this.compressedContent=null}CompressedObject.prototype={getContent:function(){return null},
getCompressedContent:function(){return null}};module.exports=CompressedObject},{}],3:[function(_dereq_,module,exports){exports.STORE={magic:"\x00\x00",compress:function(content){return content},uncompress:function(content){return content},compressInputType:null,uncompressInputType:null};exports.DEFLATE=_dereq_("./flate")},{"./flate":8}],4:[function(_dereq_,module,exports){var utils=_dereq_("./utils");var table=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,
2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,
671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,
3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,
426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,
3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,
3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];module.exports=function crc32(input,crc){if(typeof input==="undefined"||!input.length)return 0;var isArray=utils.getTypeOf(input)!=="string";if(typeof crc=="undefined")crc=0;var x=0;var y=0;var b=0;crc=crc^-1;for(var i=0,iTop=input.length;i<iTop;i++){b=isArray?input[i]:input.charCodeAt(i);y=(crc^b)&255;x=table[y];crc=crc>>>8^x}return crc^-1}},{"./utils":21}],5:[function(_dereq_,
module,exports){var utils=_dereq_("./utils");function DataReader(data){this.data=null;this.length=0;this.index=0}DataReader.prototype={checkOffset:function(offset){this.checkIndex(this.index+offset)},checkIndex:function(newIndex){if(this.length<newIndex||newIndex<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+newIndex+"). Corrupted zip ?");},setIndex:function(newIndex){this.checkIndex(newIndex);this.index=newIndex},skip:function(n){this.setIndex(this.index+
n)},byteAt:function(i){},readInt:function(size){var result=0,i;this.checkOffset(size);for(i=this.index+size-1;i>=this.index;i--)result=(result<<8)+this.byteAt(i);this.index+=size;return result},readString:function(size){return utils.transformTo("string",this.readData(size))},readData:function(size){},lastIndexOfSignature:function(sig){},readDate:function(){var dostime=this.readInt(4);return new Date((dostime>>25&127)+1980,(dostime>>21&15)-1,dostime>>16&31,dostime>>11&31,dostime>>5&63,(dostime&31)<<
1)}};module.exports=DataReader},{"./utils":21}],6:[function(_dereq_,module,exports){exports.base64=false;exports.binary=false;exports.dir=false;exports.createFolders=false;exports.date=null;exports.compression=null;exports.comment=null},{}],7:[function(_dereq_,module,exports){var utils=_dereq_("./utils");exports.string2binary=function(str){return utils.string2binary(str)};exports.string2Uint8Array=function(str){return utils.transformTo("uint8array",str)};exports.uint8Array2String=function(array){return utils.transformTo("string",
array)};exports.string2Blob=function(str){var buffer=utils.transformTo("arraybuffer",str);return utils.arrayBuffer2Blob(buffer)};exports.arrayBuffer2Blob=function(buffer){return utils.arrayBuffer2Blob(buffer)};exports.transformTo=function(outputType,input){return utils.transformTo(outputType,input)};exports.getTypeOf=function(input){return utils.getTypeOf(input)};exports.checkSupport=function(type){return utils.checkSupport(type)};exports.MAX_VALUE_16BITS=utils.MAX_VALUE_16BITS;exports.MAX_VALUE_32BITS=
utils.MAX_VALUE_32BITS;exports.pretty=function(str){return utils.pretty(str)};exports.findCompression=function(compressionMethod){return utils.findCompression(compressionMethod)};exports.isRegExp=function(object){return utils.isRegExp(object)}},{"./utils":21}],8:[function(_dereq_,module,exports){var USE_TYPEDARRAY=typeof Uint8Array!=="undefined"&&typeof Uint16Array!=="undefined"&&typeof Uint32Array!=="undefined";var pako=_dereq_("pako");exports.uncompressInputType=USE_TYPEDARRAY?"uint8array":"array";
exports.compressInputType=USE_TYPEDARRAY?"uint8array":"array";exports.magic="\b\x00";exports.compress=function(input){return pako.deflateRaw(input)};exports.uncompress=function(input){return pako.inflateRaw(input)}},{"pako":24}],9:[function(_dereq_,module,exports){var base64=_dereq_("./base64");function JSZip(data,options){if(!(this instanceof JSZip))return new JSZip(data,options);this.files={};this.comment=null;this.root="";if(data)this.load(data,options);this.clone=function(){var newObj=new JSZip;
for(var i in this)if(typeof this[i]!=="function")newObj[i]=this[i];return newObj}}JSZip.prototype=_dereq_("./object");JSZip.prototype.load=_dereq_("./load");JSZip.support=_dereq_("./support");JSZip.defaults=_dereq_("./defaults");JSZip.utils=_dereq_("./deprecatedPublicUtils");JSZip.base64={encode:function(input){return base64.encode(input)},decode:function(input){return base64.decode(input)}};JSZip.compressions=_dereq_("./compressions");module.exports=JSZip},{"./base64":1,"./compressions":3,"./defaults":6,
"./deprecatedPublicUtils":7,"./load":10,"./object":13,"./support":17}],10:[function(_dereq_,module,exports){var base64=_dereq_("./base64");var ZipEntries=_dereq_("./zipEntries");module.exports=function(data,options){var files,zipEntries,i,input;options=options||{};if(options.base64)data=base64.decode(data);zipEntries=new ZipEntries(data,options);files=zipEntries.files;for(i=0;i<files.length;i++){input=files[i];this.file(input.fileName,input.decompressed,{binary:true,optimizedBinaryString:true,date:input.date,
dir:input.dir,comment:input.fileComment.length?input.fileComment:null,createFolders:options.createFolders})}if(zipEntries.zipComment.length)this.comment=zipEntries.zipComment;return this}},{"./base64":1,"./zipEntries":22}],11:[function(_dereq_,module,exports){(function(Buffer){module.exports=function(data,encoding){return new Buffer(data,encoding)};module.exports.test=function(b){return Buffer.isBuffer(b)}}).call(this,typeof Buffer!=="undefined"?Buffer:undefined)},{}],12:[function(_dereq_,module,
exports){var Uint8ArrayReader=_dereq_("./uint8ArrayReader");function NodeBufferReader(data){this.data=data;this.length=this.data.length;this.index=0}NodeBufferReader.prototype=new Uint8ArrayReader;NodeBufferReader.prototype.readData=function(size){this.checkOffset(size);var result=this.data.slice(this.index,this.index+size);this.index+=size;return result};module.exports=NodeBufferReader},{"./uint8ArrayReader":18}],13:[function(_dereq_,module,exports){var support=_dereq_("./support");var utils=_dereq_("./utils");
var crc32=_dereq_("./crc32");var signature=_dereq_("./signature");var defaults=_dereq_("./defaults");var base64=_dereq_("./base64");var compressions=_dereq_("./compressions");var CompressedObject=_dereq_("./compressedObject");var nodeBuffer=_dereq_("./nodeBuffer");var utf8=_dereq_("./utf8");var StringWriter=_dereq_("./stringWriter");var Uint8ArrayWriter=_dereq_("./uint8ArrayWriter");var getRawData=function(file){if(file._data instanceof CompressedObject){file._data=file._data.getContent();file.options.binary=
true;file.options.base64=false;if(utils.getTypeOf(file._data)==="uint8array"){var copy=file._data;file._data=new Uint8Array(copy.length);if(copy.length!==0)file._data.set(copy,0)}}return file._data};var getBinaryData=function(file){var result=getRawData(file),type=utils.getTypeOf(result);if(type==="string"){if(!file.options.binary)if(support.nodebuffer)return nodeBuffer(result,"utf-8");return file.asBinary()}return result};var dataToString=function(asUTF8){var result=getRawData(this);if(result===
null||typeof result==="undefined")return"";if(this.options.base64)result=base64.decode(result);if(asUTF8&&this.options.binary)result=out.utf8decode(result);else result=utils.transformTo("string",result);if(!asUTF8&&!this.options.binary)result=utils.transformTo("string",out.utf8encode(result));return result};var ZipObject=function(name,data,options){this.name=name;this.dir=options.dir;this.date=options.date;this.comment=options.comment;this._data=data;this.options=options;this._initialMetadata={dir:options.dir,
date:options.date}};ZipObject.prototype={asText:function(){return dataToString.call(this,true)},asBinary:function(){return dataToString.call(this,false)},asNodeBuffer:function(){var result=getBinaryData(this);return utils.transformTo("nodebuffer",result)},asUint8Array:function(){var result=getBinaryData(this);return utils.transformTo("uint8array",result)},asArrayBuffer:function(){return this.asUint8Array().buffer}};var decToHex=function(dec,bytes){var hex="",i;for(i=0;i<bytes;i++){hex+=String.fromCharCode(dec&
255);dec=dec>>>8}return hex};var extend=function(){var result={},i,attr;for(i=0;i<arguments.length;i++)for(attr in arguments[i])if(arguments[i].hasOwnProperty(attr)&&typeof result[attr]==="undefined")result[attr]=arguments[i][attr];return result};var prepareFileAttrs=function(o){o=o||{};if(o.base64===true&&(o.binary===null||o.binary===undefined))o.binary=true;o=extend(o,defaults);o.date=o.date||new Date;if(o.compression!==null)o.compression=o.compression.toUpperCase();return o};var fileAdd=function(name,
data,o){var dataType=utils.getTypeOf(data),parent;o=prepareFileAttrs(o);if(o.createFolders&&(parent=parentFolder(name)))folderAdd.call(this,parent,true);if(o.dir||data===null||typeof data==="undefined"){o.base64=false;o.binary=false;data=null}else if(dataType==="string"){if(o.binary&&!o.base64)if(o.optimizedBinaryString!==true)data=utils.string2binary(data)}else{o.base64=false;o.binary=true;if(!dataType&&!(data instanceof CompressedObject))throw new Error("The data of '"+name+"' is in an unsupported format !");
if(dataType==="arraybuffer")data=utils.transformTo("uint8array",data)}var object=new ZipObject(name,data,o);this.files[name]=object;return object};var parentFolder=function(path){if(path.slice(-1)=="/")path=path.substring(0,path.length-1);var lastSlash=path.lastIndexOf("/");return lastSlash>0?path.substring(0,lastSlash):""};var folderAdd=function(name,createFolders){if(name.slice(-1)!="/")name+="/";createFolders=typeof createFolders!=="undefined"?createFolders:false;if(!this.files[name])fileAdd.call(this,
name,null,{dir:true,createFolders:createFolders});return this.files[name]};var generateCompressedObjectFrom=function(file,compression){var result=new CompressedObject,content;if(file._data instanceof CompressedObject){result.uncompressedSize=file._data.uncompressedSize;result.crc32=file._data.crc32;if(result.uncompressedSize===0||file.dir){compression=compressions["STORE"];result.compressedContent="";result.crc32=0}else if(file._data.compressionMethod===compression.magic)result.compressedContent=
file._data.getCompressedContent();else{content=file._data.getContent();result.compressedContent=compression.compress(utils.transformTo(compression.compressInputType,content))}}else{content=getBinaryData(file);if(!content||content.length===0||file.dir){compression=compressions["STORE"];content=""}result.uncompressedSize=content.length;result.crc32=crc32(content);result.compressedContent=compression.compress(utils.transformTo(compression.compressInputType,content))}result.compressedSize=result.compressedContent.length;
result.compressionMethod=compression.magic;return result};var generateZipParts=function(name,file,compressedObject,offset){var utfEncodedFileName=utils.transformTo("string",utf8.utf8encode(file.name)),comment=file.comment||"",utfEncodedComment=utils.transformTo("string",utf8.utf8encode(comment)),useUTF8ForFileName=utfEncodedFileName.length!==file.name.length,useUTF8ForComment=utfEncodedComment.length!==comment.length,o=file.options,dosTime,dosDate,extraFields="",unicodePathExtraField="",unicodeCommentExtraField=
"",dir,date;if(file._initialMetadata.dir!==file.dir)dir=file.dir;else dir=o.dir;if(file._initialMetadata.date!==file.date)date=file.date;else date=o.date;dosTime=date.getHours();dosTime=dosTime<<6;dosTime=dosTime|date.getMinutes();dosTime=dosTime<<5;dosTime=dosTime|date.getSeconds()/2;dosDate=date.getFullYear()-1980;dosDate=dosDate<<4;dosDate=dosDate|date.getMonth()+1;dosDate=dosDate<<5;dosDate=dosDate|date.getDate();if(useUTF8ForFileName){unicodePathExtraField=decToHex(1,1)+decToHex(crc32(utfEncodedFileName),
4)+utfEncodedFileName;extraFields+="up"+decToHex(unicodePathExtraField.length,2)+unicodePathExtraField}if(useUTF8ForComment){unicodeCommentExtraField=decToHex(1,1)+decToHex(this.crc32(utfEncodedComment),4)+utfEncodedComment;extraFields+="uc"+decToHex(unicodeCommentExtraField.length,2)+unicodeCommentExtraField}var header="";header+="\n\x00";header+=useUTF8ForFileName||useUTF8ForComment?"\x00\b":"\x00\x00";header+=compressedObject.compressionMethod;header+=decToHex(dosTime,2);header+=decToHex(dosDate,
2);header+=decToHex(compressedObject.crc32,4);header+=decToHex(compressedObject.compressedSize,4);header+=decToHex(compressedObject.uncompressedSize,4);header+=decToHex(utfEncodedFileName.length,2);header+=decToHex(extraFields.length,2);var fileRecord=signature.LOCAL_FILE_HEADER+header+utfEncodedFileName+extraFields;var dirRecord=signature.CENTRAL_FILE_HEADER+"\u0014\x00"+header+decToHex(utfEncodedComment.length,2)+"\x00\x00"+"\x00\x00"+(dir===true?"\u0010\x00\x00\x00":"\x00\x00\x00\x00")+decToHex(offset,
4)+utfEncodedFileName+extraFields+utfEncodedComment;return{fileRecord:fileRecord,dirRecord:dirRecord,compressedObject:compressedObject}};var out={load:function(stream,options){throw new Error("Load method is not defined. Is the file jszip-load.js included ?");},filter:function(search){var result=[],filename,relativePath,file,fileClone;for(filename in this.files){if(!this.files.hasOwnProperty(filename))continue;file=this.files[filename];fileClone=new ZipObject(file.name,file._data,extend(file.options));
relativePath=filename.slice(this.root.length,filename.length);if(filename.slice(0,this.root.length)===this.root&&search(relativePath,fileClone))result.push(fileClone)}return result},file:function(name,data,o){if(arguments.length===1)if(utils.isRegExp(name)){var regexp=name;return this.filter(function(relativePath,file){return!file.dir&&regexp.test(relativePath)})}else return this.filter(function(relativePath,file){return!file.dir&&relativePath===name})[0]||null;else{name=this.root+name;fileAdd.call(this,
name,data,o)}return this},folder:function(arg){if(!arg)return this;if(utils.isRegExp(arg))return this.filter(function(relativePath,file){return file.dir&&arg.test(relativePath)});var name=this.root+arg;var newFolder=folderAdd.call(this,name);var ret=this.clone();ret.root=newFolder.name;return ret},remove:function(name){name=this.root+name;var file=this.files[name];if(!file){if(name.slice(-1)!="/")name+="/";file=this.files[name]}if(file&&!file.dir)delete this.files[name];else{var kids=this.filter(function(relativePath,
file){return file.name.slice(0,name.length)===name});for(var i=0;i<kids.length;i++)delete this.files[kids[i].name]}return this},generate:function(options){options=extend(options||{},{base64:true,compression:"STORE",type:"base64",comment:null});utils.checkSupport(options.type);var zipData=[],localDirLength=0,centralDirLength=0,writer,i,utfEncodedComment=utils.transformTo("string",this.utf8encode(options.comment||this.comment||""));for(var name in this.files){if(!this.files.hasOwnProperty(name))continue;
var file=this.files[name];var compressionName=file.options.compression||options.compression.toUpperCase();var compression=compressions[compressionName];if(!compression)throw new Error(compressionName+" is not a valid compression method !");var compressedObject=generateCompressedObjectFrom.call(this,file,compression);var zipPart=generateZipParts.call(this,name,file,compressedObject,localDirLength);localDirLength+=zipPart.fileRecord.length+compressedObject.compressedSize;centralDirLength+=zipPart.dirRecord.length;
zipData.push(zipPart)}var dirEnd="";dirEnd=signature.CENTRAL_DIRECTORY_END+"\x00\x00"+"\x00\x00"+decToHex(zipData.length,2)+decToHex(zipData.length,2)+decToHex(centralDirLength,4)+decToHex(localDirLength,4)+decToHex(utfEncodedComment.length,2)+utfEncodedComment;var typeName=options.type.toLowerCase();if(typeName==="uint8array"||typeName==="arraybuffer"||typeName==="blob"||typeName==="nodebuffer")writer=new Uint8ArrayWriter(localDirLength+centralDirLength+dirEnd.length);else writer=new StringWriter(localDirLength+
centralDirLength+dirEnd.length);for(i=0;i<zipData.length;i++){writer.append(zipData[i].fileRecord);writer.append(zipData[i].compressedObject.compressedContent)}for(i=0;i<zipData.length;i++)writer.append(zipData[i].dirRecord);writer.append(dirEnd);var zip=writer.finalize();switch(options.type.toLowerCase()){case "uint8array":case "arraybuffer":case "nodebuffer":return utils.transformTo(options.type.toLowerCase(),zip);case "blob":return utils.arrayBuffer2Blob(utils.transformTo("arraybuffer",zip));case "base64":return options.base64?
base64.encode(zip):zip;default:return zip}},crc32:function(input,crc){return crc32(input,crc)},utf8encode:function(string){return utils.transformTo("string",utf8.utf8encode(string))},utf8decode:function(input){return utf8.utf8decode(input)}};module.exports=out},{"./base64":1,"./compressedObject":2,"./compressions":3,"./crc32":4,"./defaults":6,"./nodeBuffer":11,"./signature":14,"./stringWriter":16,"./support":17,"./uint8ArrayWriter":19,"./utf8":20,"./utils":21}],14:[function(_dereq_,module,exports){exports.LOCAL_FILE_HEADER=
"PK\u0003\u0004";exports.CENTRAL_FILE_HEADER="PK\u0001\u0002";exports.CENTRAL_DIRECTORY_END="PK\u0005\u0006";exports.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\u0006\u0007";exports.ZIP64_CENTRAL_DIRECTORY_END="PK\u0006\u0006";exports.DATA_DESCRIPTOR="PK\u0007\b"},{}],15:[function(_dereq_,module,exports){var DataReader=_dereq_("./dataReader");var utils=_dereq_("./utils");function StringReader(data,optimizedBinaryString){this.data=data;if(!optimizedBinaryString)this.data=utils.string2binary(this.data);this.length=
this.data.length;this.index=0}StringReader.prototype=new DataReader;StringReader.prototype.byteAt=function(i){return this.data.charCodeAt(i)};StringReader.prototype.lastIndexOfSignature=function(sig){return this.data.lastIndexOf(sig)};StringReader.prototype.readData=function(size){this.checkOffset(size);var result=this.data.slice(this.index,this.index+size);this.index+=size;return result};module.exports=StringReader},{"./dataReader":5,"./utils":21}],16:[function(_dereq_,module,exports){var utils=
_dereq_("./utils");var StringWriter=function(){this.data=[]};StringWriter.prototype={append:function(input){input=utils.transformTo("string",input);this.data.push(input)},finalize:function(){return this.data.join("")}};module.exports=StringWriter},{"./utils":21}],17:[function(_dereq_,module,exports){(function(Buffer){exports.base64=true;exports.array=true;exports.string=true;exports.arraybuffer=typeof ArrayBuffer!=="undefined"&&typeof Uint8Array!=="undefined";exports.nodebuffer=typeof Buffer!=="undefined";
exports.uint8array=typeof Uint8Array!=="undefined";if(typeof ArrayBuffer==="undefined")exports.blob=false;else{var buffer=new ArrayBuffer(0);try{exports.blob=(new Blob([buffer],{type:"application/zip"})).size===0}catch(e$0){try{var Builder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;var builder=new Builder;builder.append(buffer);exports.blob=builder.getBlob("application/zip").size===0}catch(e){exports.blob=false}}}}).call(this,typeof Buffer!=="undefined"?
Buffer:undefined)},{}],18:[function(_dereq_,module,exports){var DataReader=_dereq_("./dataReader");function Uint8ArrayReader(data){if(data){this.data=data;this.length=this.data.length;this.index=0}}Uint8ArrayReader.prototype=new DataReader;Uint8ArrayReader.prototype.byteAt=function(i){return this.data[i]};Uint8ArrayReader.prototype.lastIndexOfSignature=function(sig){var sig0=sig.charCodeAt(0),sig1=sig.charCodeAt(1),sig2=sig.charCodeAt(2),sig3=sig.charCodeAt(3);for(var i=this.length-4;i>=0;--i)if(this.data[i]===
sig0&&this.data[i+1]===sig1&&this.data[i+2]===sig2&&this.data[i+3]===sig3)return i;return-1};Uint8ArrayReader.prototype.readData=function(size){this.checkOffset(size);if(size===0)return new Uint8Array(0);var result=this.data.subarray(this.index,this.index+size);this.index+=size;return result};module.exports=Uint8ArrayReader},{"./dataReader":5}],19:[function(_dereq_,module,exports){var utils=_dereq_("./utils");var Uint8ArrayWriter=function(length){this.data=new Uint8Array(length);this.index=0};Uint8ArrayWriter.prototype=
{append:function(input){if(input.length!==0){input=utils.transformTo("uint8array",input);this.data.set(input,this.index);this.index+=input.length}},finalize:function(){return this.data}};module.exports=Uint8ArrayWriter},{"./utils":21}],20:[function(_dereq_,module,exports){var utils=_dereq_("./utils");var support=_dereq_("./support");var nodeBuffer=_dereq_("./nodeBuffer");var _utf8len=new Array(256);for(var i=0;i<256;i++)_utf8len[i]=i>=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;_utf8len[254]=_utf8len[254]=
1;var string2buf=function(str){var buf,c,c2,m_pos,i,str_len=str.length,buf_len=0;for(m_pos=0;m_pos<str_len;m_pos++){c=str.charCodeAt(m_pos);if((c&64512)===55296&&m_pos+1<str_len){c2=str.charCodeAt(m_pos+1);if((c2&64512)===56320){c=65536+(c-55296<<10)+(c2-56320);m_pos++}}buf_len+=c<128?1:c<2048?2:c<65536?3:4}if(support.uint8array)buf=new Uint8Array(buf_len);else buf=new Array(buf_len);for(i=0,m_pos=0;i<buf_len;m_pos++){c=str.charCodeAt(m_pos);if((c&64512)===55296&&m_pos+1<str_len){c2=str.charCodeAt(m_pos+
1);if((c2&64512)===56320){c=65536+(c-55296<<10)+(c2-56320);m_pos++}}if(c<128)buf[i++]=c;else if(c<2048){buf[i++]=192|c>>>6;buf[i++]=128|c&63}else if(c<65536){buf[i++]=224|c>>>12;buf[i++]=128|c>>>6&63;buf[i++]=128|c&63}else{buf[i++]=240|c>>>18;buf[i++]=128|c>>>12&63;buf[i++]=128|c>>>6&63;buf[i++]=128|c&63}}return buf};var utf8border=function(buf,max){var pos;max=max||buf.length;if(max>buf.length)max=buf.length;pos=max-1;while(pos>=0&&(buf[pos]&192)===128)pos--;if(pos<0)return max;if(pos===0)return max;
return pos+_utf8len[buf[pos]]>max?pos:max};var buf2string=function(buf){var i,out,c,c_len;var len=buf.length;var utf16buf=new Array(len*2);for(out=0,i=0;i<len;){c=buf[i++];if(c<128){utf16buf[out++]=c;continue}c_len=_utf8len[c];if(c_len>4){utf16buf[out++]=65533;i+=c_len-1;continue}c&=c_len===2?31:c_len===3?15:7;while(c_len>1&&i<len){c=c<<6|buf[i++]&63;c_len--}if(c_len>1){utf16buf[out++]=65533;continue}if(c<65536)utf16buf[out++]=c;else{c-=65536;utf16buf[out++]=55296|c>>10&1023;utf16buf[out++]=56320|
c&1023}}if(utf16buf.length!==out)if(utf16buf.subarray)utf16buf=utf16buf.subarray(0,out);else utf16buf.length=out;return utils.applyFromCharCode(utf16buf)};exports.utf8encode=function utf8encode(str){if(support.nodebuffer)return nodeBuffer(str,"utf-8");return string2buf(str)};exports.utf8decode=function utf8decode(buf){if(support.nodebuffer)return utils.transformTo("nodebuffer",buf).toString("utf-8");buf=utils.transformTo(support.uint8array?"uint8array":"array",buf);var result=[],k=0,len=buf.length,
chunk=65536;while(k<len){var nextBoundary=utf8border(buf,Math.min(k+chunk,len));if(support.uint8array)result.push(buf2string(buf.subarray(k,nextBoundary)));else result.push(buf2string(buf.slice(k,nextBoundary)));k=nextBoundary}return result.join("")}},{"./nodeBuffer":11,"./support":17,"./utils":21}],21:[function(_dereq_,module,exports){var support=_dereq_("./support");var compressions=_dereq_("./compressions");var nodeBuffer=_dereq_("./nodeBuffer");exports.string2binary=function(str){var result="";
for(var i=0;i<str.length;i++)result+=String.fromCharCode(str.charCodeAt(i)&255);return result};exports.arrayBuffer2Blob=function(buffer){exports.checkSupport("blob");try{return new Blob([buffer],{type:"application/zip"})}catch(e$1){try{var Builder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;var builder=new Builder;builder.append(buffer);return builder.getBlob("application/zip")}catch(e){throw new Error("Bug : can't construct the Blob.");}}};function identity(input){return input}
function stringToArrayLike(str,array){for(var i=0;i<str.length;++i)array[i]=str.charCodeAt(i)&255;return array}function arrayLikeToString(array){var chunk=65536;var result=[],len=array.length,type=exports.getTypeOf(array),k=0,canUseApply=true;try{switch(type){case "uint8array":String.fromCharCode.apply(null,new Uint8Array(0));break;case "nodebuffer":String.fromCharCode.apply(null,nodeBuffer(0));break}}catch(e){canUseApply=false}if(!canUseApply){var resultStr="";for(var i=0;i<array.length;i++)resultStr+=
String.fromCharCode(array[i]);return resultStr}while(k<len&&chunk>1)try{if(type==="array"||type==="nodebuffer")result.push(String.fromCharCode.apply(null,array.slice(k,Math.min(k+chunk,len))));else result.push(String.fromCharCode.apply(null,array.subarray(k,Math.min(k+chunk,len))));k+=chunk}catch(e$2){chunk=Math.floor(chunk/2)}return result.join("")}exports.applyFromCharCode=arrayLikeToString;function arrayLikeToArrayLike(arrayFrom,arrayTo){for(var i=0;i<arrayFrom.length;i++)arrayTo[i]=arrayFrom[i];
return arrayTo}var transform={};transform["string"]={"string":identity,"array":function(input){return stringToArrayLike(input,new Array(input.length))},"arraybuffer":function(input){return transform["string"]["uint8array"](input).buffer},"uint8array":function(input){return stringToArrayLike(input,new Uint8Array(input.length))},"nodebuffer":function(input){return stringToArrayLike(input,nodeBuffer(input.length))}};transform["array"]={"string":arrayLikeToString,"array":identity,"arraybuffer":function(input){return(new Uint8Array(input)).buffer},
"uint8array":function(input){return new Uint8Array(input)},"nodebuffer":function(input){return nodeBuffer(input)}};transform["arraybuffer"]={"string":function(input){return arrayLikeToString(new Uint8Array(input))},"array":function(input){return arrayLikeToArrayLike(new Uint8Array(input),new Array(input.byteLength))},"arraybuffer":identity,"uint8array":function(input){return new Uint8Array(input)},"nodebuffer":function(input){return nodeBuffer(new Uint8Array(input))}};transform["uint8array"]={"string":arrayLikeToString,
"array":function(input){return arrayLikeToArrayLike(input,new Array(input.length))},"arraybuffer":function(input){return input.buffer},"uint8array":identity,"nodebuffer":function(input){return nodeBuffer(input)}};transform["nodebuffer"]={"string":arrayLikeToString,"array":function(input){return arrayLikeToArrayLike(input,new Array(input.length))},"arraybuffer":function(input){return transform["nodebuffer"]["uint8array"](input).buffer},"uint8array":function(input){return arrayLikeToArrayLike(input,
new Uint8Array(input.length))},"nodebuffer":identity};exports.transformTo=function(outputType,input){if(!input)input="";if(!outputType)return input;exports.checkSupport(outputType);var inputType=exports.getTypeOf(input);var result=transform[inputType][outputType](input);return result};exports.getTypeOf=function(input){if(typeof input==="string")return"string";if(Object.prototype.toString.call(input)==="[object Array]")return"array";if(support.nodebuffer&&nodeBuffer.test(input))return"nodebuffer";
if(support.uint8array&&input instanceof Uint8Array)return"uint8array";if(support.arraybuffer&&input instanceof ArrayBuffer)return"arraybuffer"};exports.checkSupport=function(type){var supported=support[type.toLowerCase()];if(!supported)throw new Error(type+" is not supported by this browser");};exports.MAX_VALUE_16BITS=65535;exports.MAX_VALUE_32BITS=-1;exports.pretty=function(str){var res="",code,i;for(i=0;i<(str||"").length;i++){code=str.charCodeAt(i);res+="\\x"+(code<16?"0":"")+code.toString(16).toUpperCase()}return res};
exports.findCompression=function(compressionMethod){for(var method in compressions){if(!compressions.hasOwnProperty(method))continue;if(compressions[method].magic===compressionMethod)return compressions[method]}return null};exports.isRegExp=function(object){return Object.prototype.toString.call(object)==="[object RegExp]"}},{"./compressions":3,"./nodeBuffer":11,"./support":17}],22:[function(_dereq_,module,exports){var StringReader=_dereq_("./stringReader");var NodeBufferReader=_dereq_("./nodeBufferReader");
var Uint8ArrayReader=_dereq_("./uint8ArrayReader");var utils=_dereq_("./utils");var sig=_dereq_("./signature");var ZipEntry=_dereq_("./zipEntry");var support=_dereq_("./support");var jszipProto=_dereq_("./object");function ZipEntries(data,loadOptions){this.files=[];this.loadOptions=loadOptions;if(data)this.load(data)}ZipEntries.prototype={checkSignature:function(expectedSignature){var signature=this.reader.readString(4);if(signature!==expectedSignature)throw new Error("Corrupted zip or bug : unexpected signature "+
"("+utils.pretty(signature)+", expected "+utils.pretty(expectedSignature)+")");},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2);this.diskWithCentralDirStart=this.reader.readInt(2);this.centralDirRecordsOnThisDisk=this.reader.readInt(2);this.centralDirRecords=this.reader.readInt(2);this.centralDirSize=this.reader.readInt(4);this.centralDirOffset=this.reader.readInt(4);this.zipCommentLength=this.reader.readInt(2);this.zipComment=this.reader.readString(this.zipCommentLength);
this.zipComment=jszipProto.utf8decode(this.zipComment)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8);this.versionMadeBy=this.reader.readString(2);this.versionNeeded=this.reader.readInt(2);this.diskNumber=this.reader.readInt(4);this.diskWithCentralDirStart=this.reader.readInt(4);this.centralDirRecordsOnThisDisk=this.reader.readInt(8);this.centralDirRecords=this.reader.readInt(8);this.centralDirSize=this.reader.readInt(8);this.centralDirOffset=this.reader.readInt(8);
this.zip64ExtensibleData={};var extraDataSize=this.zip64EndOfCentralSize-44,index=0,extraFieldId,extraFieldLength,extraFieldValue;while(index<extraDataSize){extraFieldId=this.reader.readInt(2);extraFieldLength=this.reader.readInt(4);extraFieldValue=this.reader.readString(extraFieldLength);this.zip64ExtensibleData[extraFieldId]={id:extraFieldId,length:extraFieldLength,value:extraFieldValue}}},readBlockZip64EndOfCentralLocator:function(){this.diskWithZip64CentralDirStart=this.reader.readInt(4);this.relativeOffsetEndOfZip64CentralDir=
this.reader.readInt(8);this.disksCount=this.reader.readInt(4);if(this.disksCount>1)throw new Error("Multi-volumes zip are not supported");},readLocalFiles:function(){var i,file;for(i=0;i<this.files.length;i++){file=this.files[i];this.reader.setIndex(file.localHeaderOffset);this.checkSignature(sig.LOCAL_FILE_HEADER);file.readLocalPart(this.reader);file.handleUTF8()}},readCentralDir:function(){var file;this.reader.setIndex(this.centralDirOffset);while(this.reader.readString(4)===sig.CENTRAL_FILE_HEADER){file=
new ZipEntry({zip64:this.zip64},this.loadOptions);file.readCentralPart(this.reader);this.files.push(file)}},readEndOfCentral:function(){var offset=this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);if(offset===-1)throw new Error("Corrupted zip : can't find end of central directory");this.reader.setIndex(offset);this.checkSignature(sig.CENTRAL_DIRECTORY_END);this.readBlockEndOfCentral();if(this.diskNumber===utils.MAX_VALUE_16BITS||this.diskWithCentralDirStart===utils.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===
utils.MAX_VALUE_16BITS||this.centralDirRecords===utils.MAX_VALUE_16BITS||this.centralDirSize===utils.MAX_VALUE_32BITS||this.centralDirOffset===utils.MAX_VALUE_32BITS){this.zip64=true;offset=this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);if(offset===-1)throw new Error("Corrupted zip : can't find the ZIP64 end of central directory locator");this.reader.setIndex(offset);this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);this.readBlockZip64EndOfCentralLocator();this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir);
this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);this.readBlockZip64EndOfCentral()}},prepareReader:function(data){var type=utils.getTypeOf(data);if(type==="string"&&!support.uint8array)this.reader=new StringReader(data,this.loadOptions.optimizedBinaryString);else if(type==="nodebuffer")this.reader=new NodeBufferReader(data);else this.reader=new Uint8ArrayReader(utils.transformTo("uint8array",data))},load:function(data){this.prepareReader(data);this.readEndOfCentral();this.readCentralDir();this.readLocalFiles()}};
module.exports=ZipEntries},{"./nodeBufferReader":12,"./object":13,"./signature":14,"./stringReader":15,"./support":17,"./uint8ArrayReader":18,"./utils":21,"./zipEntry":23}],23:[function(_dereq_,module,exports){var StringReader=_dereq_("./stringReader");var utils=_dereq_("./utils");var CompressedObject=_dereq_("./compressedObject");var jszipProto=_dereq_("./object");function ZipEntry(options,loadOptions){this.options=options;this.loadOptions=loadOptions}ZipEntry.prototype={isEncrypted:function(){return(this.bitFlag&
1)===1},useUTF8:function(){return(this.bitFlag&2048)===2048},prepareCompressedContent:function(reader,from,length){return function(){var previousIndex=reader.index;reader.setIndex(from);var compressedFileData=reader.readData(length);reader.setIndex(previousIndex);return compressedFileData}},prepareContent:function(reader,from,length,compression,uncompressedSize){return function(){var compressedFileData=utils.transformTo(compression.uncompressInputType,this.getCompressedContent());var uncompressedFileData=
compression.uncompress(compressedFileData);if(uncompressedFileData.length!==uncompressedSize)throw new Error("Bug : uncompressed data size mismatch");return uncompressedFileData}},readLocalPart:function(reader){var compression,localExtraFieldsLength;reader.skip(22);this.fileNameLength=reader.readInt(2);localExtraFieldsLength=reader.readInt(2);this.fileName=reader.readString(this.fileNameLength);reader.skip(localExtraFieldsLength);if(this.compressedSize==-1||this.uncompressedSize==-1)throw new Error("Bug or corrupted zip : didn't get enough informations from the central directory "+
"(compressedSize == -1 || uncompressedSize == -1)");compression=utils.findCompression(this.compressionMethod);if(compression===null)throw new Error("Corrupted zip : compression "+utils.pretty(this.compressionMethod)+" unknown (inner file : "+this.fileName+")");this.decompressed=new CompressedObject;this.decompressed.compressedSize=this.compressedSize;this.decompressed.uncompressedSize=this.uncompressedSize;this.decompressed.crc32=this.crc32;this.decompressed.compressionMethod=this.compressionMethod;
this.decompressed.getCompressedContent=this.prepareCompressedContent(reader,reader.index,this.compressedSize,compression);this.decompressed.getContent=this.prepareContent(reader,reader.index,this.compressedSize,compression,this.uncompressedSize);if(this.loadOptions.checkCRC32){this.decompressed=utils.transformTo("string",this.decompressed.getContent());if(jszipProto.crc32(this.decompressed)!==this.crc32)throw new Error("Corrupted zip : CRC32 mismatch");}},readCentralPart:function(reader){this.versionMadeBy=
reader.readString(2);this.versionNeeded=reader.readInt(2);this.bitFlag=reader.readInt(2);this.compressionMethod=reader.readString(2);this.date=reader.readDate();this.crc32=reader.readInt(4);this.compressedSize=reader.readInt(4);this.uncompressedSize=reader.readInt(4);this.fileNameLength=reader.readInt(2);this.extraFieldsLength=reader.readInt(2);this.fileCommentLength=reader.readInt(2);this.diskNumberStart=reader.readInt(2);this.internalFileAttributes=reader.readInt(2);this.externalFileAttributes=
reader.readInt(4);this.localHeaderOffset=reader.readInt(4);if(this.isEncrypted())throw new Error("Encrypted zip are not supported");this.fileName=reader.readString(this.fileNameLength);this.readExtraFields(reader);this.parseZIP64ExtraField(reader);this.fileComment=reader.readString(this.fileCommentLength);this.dir=this.externalFileAttributes&16?true:false},parseZIP64ExtraField:function(reader){if(!this.extraFields[1])return;var extraReader=new StringReader(this.extraFields[1].value);if(this.uncompressedSize===
utils.MAX_VALUE_32BITS)this.uncompressedSize=extraReader.readInt(8);if(this.compressedSize===utils.MAX_VALUE_32BITS)this.compressedSize=extraReader.readInt(8);if(this.localHeaderOffset===utils.MAX_VALUE_32BITS)this.localHeaderOffset=extraReader.readInt(8);if(this.diskNumberStart===utils.MAX_VALUE_32BITS)this.diskNumberStart=extraReader.readInt(4)},readExtraFields:function(reader){var start=reader.index,extraFieldId,extraFieldLength,extraFieldValue;this.extraFields=this.extraFields||{};while(reader.index<
start+this.extraFieldsLength){extraFieldId=reader.readInt(2);extraFieldLength=reader.readInt(2);extraFieldValue=reader.readString(extraFieldLength);this.extraFields[extraFieldId]={id:extraFieldId,length:extraFieldLength,value:extraFieldValue}}},handleUTF8:function(){if(this.useUTF8()){this.fileName=jszipProto.utf8decode(this.fileName);this.fileComment=jszipProto.utf8decode(this.fileComment)}else{var upath=this.findExtraFieldUnicodePath();if(upath!==null)this.fileName=upath;var ucomment=this.findExtraFieldUnicodeComment();
if(ucomment!==null)this.fileComment=ucomment}},findExtraFieldUnicodePath:function(){var upathField=this.extraFields[28789];if(upathField){var extraReader=new StringReader(upathField.value);if(extraReader.readInt(1)!==1)return null;if(jszipProto.crc32(this.fileName)!==extraReader.readInt(4))return null;return jszipProto.utf8decode(extraReader.readString(upathField.length-5))}return null},findExtraFieldUnicodeComment:function(){var ucommentField=this.extraFields[25461];if(ucommentField){var extraReader=
new StringReader(ucommentField.value);if(extraReader.readInt(1)!==1)return null;if(jszipProto.crc32(this.fileComment)!==extraReader.readInt(4))return null;return jszipProto.utf8decode(extraReader.readString(ucommentField.length-5))}return null}};module.exports=ZipEntry},{"./compressedObject":2,"./object":13,"./stringReader":15,"./utils":21}],24:[function(_dereq_,module,exports){var assign=_dereq_("./lib/utils/common").assign;var deflate=_dereq_("./lib/deflate");var inflate=_dereq_("./lib/inflate");
var constants=_dereq_("./lib/zlib/constants");var pako={};assign(pako,deflate,inflate,constants);module.exports=pako},{"./lib/deflate":25,"./lib/inflate":26,"./lib/utils/common":27,"./lib/zlib/constants":30}],25:[function(_dereq_,module,exports){var zlib_deflate=_dereq_("./zlib/deflate.js");var utils=_dereq_("./utils/common");var strings=_dereq_("./utils/strings");var msg=_dereq_("./zlib/messages");var zstream=_dereq_("./zlib/zstream");var Z_NO_FLUSH=0;var Z_FINISH=4;var Z_OK=0;var Z_STREAM_END=1;
var Z_DEFAULT_COMPRESSION=-1;var Z_DEFAULT_STRATEGY=0;var Z_DEFLATED=8;var Deflate=function(options){this.options=utils.assign({level:Z_DEFAULT_COMPRESSION,method:Z_DEFLATED,chunkSize:16384,windowBits:15,memLevel:8,strategy:Z_DEFAULT_STRATEGY,to:""},options||{});var opt=this.options;if(opt.raw&&opt.windowBits>0)opt.windowBits=-opt.windowBits;else if(opt.gzip&&opt.windowBits>0&&opt.windowBits<16)opt.windowBits+=16;this.err=0;this.msg="";this.ended=false;this.chunks=[];this.strm=new zstream;this.strm.avail_out=
0;var status=zlib_deflate.deflateInit2(this.strm,opt.level,opt.method,opt.windowBits,opt.memLevel,opt.strategy);if(status!==Z_OK)throw new Error(msg[status]);if(opt.header)zlib_deflate.deflateSetHeader(this.strm,opt.header)};Deflate.prototype.push=function(data,mode){var strm=this.strm;var chunkSize=this.options.chunkSize;var status,_mode;if(this.ended)return false;_mode=mode===~~mode?mode:mode===true?Z_FINISH:Z_NO_FLUSH;if(typeof data==="string")strm.input=strings.string2buf(data);else strm.input=
data;strm.next_in=0;strm.avail_in=strm.input.length;do{if(strm.avail_out===0){strm.output=new utils.Buf8(chunkSize);strm.next_out=0;strm.avail_out=chunkSize}status=zlib_deflate.deflate(strm,_mode);if(status!==Z_STREAM_END&&status!==Z_OK){this.onEnd(status);this.ended=true;return false}if(strm.avail_out===0||strm.avail_in===0&&_mode===Z_FINISH)if(this.options.to==="string")this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output,strm.next_out)));else this.onData(utils.shrinkBuf(strm.output,strm.next_out))}while((strm.avail_in>
0||strm.avail_out===0)&&status!==Z_STREAM_END);if(_mode===Z_FINISH){status=zlib_deflate.deflateEnd(this.strm);this.onEnd(status);this.ended=true;return status===Z_OK}return true};Deflate.prototype.onData=function(chunk){this.chunks.push(chunk)};Deflate.prototype.onEnd=function(status){if(status===Z_OK)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=utils.flattenChunks(this.chunks);this.chunks=[];this.err=status;this.msg=this.strm.msg};function deflate(input,options){var deflator=
new Deflate(options);deflator.push(input,true);if(deflator.err)throw deflator.msg;return deflator.result}function deflateRaw(input,options){options=options||{};options.raw=true;return deflate(input,options)}function gzip(input,options){options=options||{};options.gzip=true;return deflate(input,options)}exports.Deflate=Deflate;exports.deflate=deflate;exports.deflateRaw=deflateRaw;exports.gzip=gzip},{"./utils/common":27,"./utils/strings":28,"./zlib/deflate.js":32,"./zlib/messages":37,"./zlib/zstream":39}],
26:[function(_dereq_,module,exports){var zlib_inflate=_dereq_("./zlib/inflate.js");var utils=_dereq_("./utils/common");var strings=_dereq_("./utils/strings");var c=_dereq_("./zlib/constants");var msg=_dereq_("./zlib/messages");var zstream=_dereq_("./zlib/zstream");var gzheader=_dereq_("./zlib/gzheader");var Inflate=function(options){this.options=utils.assign({chunkSize:16384,windowBits:0,to:""},options||{});var opt=this.options;if(opt.raw&&opt.windowBits>=0&&opt.windowBits<16){opt.windowBits=-opt.windowBits;
if(opt.windowBits===0)opt.windowBits=-15}if(opt.windowBits>=0&&opt.windowBits<16&&!(options&&options.windowBits))opt.windowBits+=32;if(opt.windowBits>15&&opt.windowBits<48)if((opt.windowBits&15)===0)opt.windowBits|=15;this.err=0;this.msg="";this.ended=false;this.chunks=[];this.strm=new zstream;this.strm.avail_out=0;var status=zlib_inflate.inflateInit2(this.strm,opt.windowBits);if(status!==c.Z_OK)throw new Error(msg[status]);this.header=new gzheader;zlib_inflate.inflateGetHeader(this.strm,this.header)};
Inflate.prototype.push=function(data,mode){var strm=this.strm;var chunkSize=this.options.chunkSize;var status,_mode;var next_out_utf8,tail,utf8str;if(this.ended)return false;_mode=mode===~~mode?mode:mode===true?c.Z_FINISH:c.Z_NO_FLUSH;if(typeof data==="string")strm.input=strings.binstring2buf(data);else strm.input=data;strm.next_in=0;strm.avail_in=strm.input.length;do{if(strm.avail_out===0){strm.output=new utils.Buf8(chunkSize);strm.next_out=0;strm.avail_out=chunkSize}status=zlib_inflate.inflate(strm,
c.Z_NO_FLUSH);if(status!==c.Z_STREAM_END&&status!==c.Z_OK){this.onEnd(status);this.ended=true;return false}if(strm.next_out)if(strm.avail_out===0||status===c.Z_STREAM_END||strm.avail_in===0&&_mode===c.Z_FINISH)if(this.options.to==="string"){next_out_utf8=strings.utf8border(strm.output,strm.next_out);tail=strm.next_out-next_out_utf8;utf8str=strings.buf2string(strm.output,next_out_utf8);strm.next_out=tail;strm.avail_out=chunkSize-tail;if(tail)utils.arraySet(strm.output,strm.output,next_out_utf8,tail,
0);this.onData(utf8str)}else this.onData(utils.shrinkBuf(strm.output,strm.next_out))}while(strm.avail_in>0&&status!==c.Z_STREAM_END);if(status===c.Z_STREAM_END)_mode=c.Z_FINISH;if(_mode===c.Z_FINISH){status=zlib_inflate.inflateEnd(this.strm);this.onEnd(status);this.ended=true;return status===c.Z_OK}return true};Inflate.prototype.onData=function(chunk){this.chunks.push(chunk)};Inflate.prototype.onEnd=function(status){if(status===c.Z_OK)if(this.options.to==="string")this.result=this.chunks.join("");
else this.result=utils.flattenChunks(this.chunks);this.chunks=[];this.err=status;this.msg=this.strm.msg};function inflate(input,options){var inflator=new Inflate(options);inflator.push(input,true);if(inflator.err)throw inflator.msg;return inflator.result}function inflateRaw(input,options){options=options||{};options.raw=true;return inflate(input,options)}exports.Inflate=Inflate;exports.inflate=inflate;exports.inflateRaw=inflateRaw;exports.ungzip=inflate},{"./utils/common":27,"./utils/strings":28,
"./zlib/constants":30,"./zlib/gzheader":33,"./zlib/inflate.js":35,"./zlib/messages":37,"./zlib/zstream":39}],27:[function(_dereq_,module,exports){var TYPED_OK=typeof Uint8Array!=="undefined"&&typeof Uint16Array!=="undefined"&&typeof Int32Array!=="undefined";exports.assign=function(obj){var sources=Array.prototype.slice.call(arguments,1);while(sources.length){var source=sources.shift();if(!source)continue;if(typeof source!=="object")throw new TypeError(source+"must be non-object");for(var p in source)if(source.hasOwnProperty(p))obj[p]=
source[p]}return obj};exports.shrinkBuf=function(buf,size){if(buf.length===size)return buf;if(buf.subarray)return buf.subarray(0,size);buf.length=size;return buf};var fnTyped={arraySet:function(dest,src,src_offs,len,dest_offs){if(src.subarray&&dest.subarray){dest.set(src.subarray(src_offs,src_offs+len),dest_offs);return}for(var i=0;i<len;i++)dest[dest_offs+i]=src[src_offs+i]},flattenChunks:function(chunks){var i,l,len,pos,chunk,result;len=0;for(i=0,l=chunks.length;i<l;i++)len+=chunks[i].length;result=
new Uint8Array(len);pos=0;for(i=0,l=chunks.length;i<l;i++){chunk=chunks[i];result.set(chunk,pos);pos+=chunk.length}return result}};var fnUntyped={arraySet:function(dest,src,src_offs,len,dest_offs){for(var i=0;i<len;i++)dest[dest_offs+i]=src[src_offs+i]},flattenChunks:function(chunks){return[].concat.apply([],chunks)}};exports.setTyped=function(on){if(on){exports.Buf8=Uint8Array;exports.Buf16=Uint16Array;exports.Buf32=Int32Array;exports.assign(exports,fnTyped)}else{exports.Buf8=Array;exports.Buf16=
Array;exports.Buf32=Array;exports.assign(exports,fnUntyped)}};exports.setTyped(TYPED_OK)},{}],28:[function(_dereq_,module,exports){var utils=_dereq_("./common");var STR_APPLY_OK=true;var STR_APPLY_UIA_OK=true;try{String.fromCharCode.apply(null,[0])}catch(__){STR_APPLY_OK=false}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(__$3){STR_APPLY_UIA_OK=false}var _utf8len=new utils.Buf8(256);for(var i=0;i<256;i++)_utf8len[i]=i>=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;_utf8len[254]=_utf8len[254]=
1;exports.string2buf=function(str){var buf,c,c2,m_pos,i,str_len=str.length,buf_len=0;for(m_pos=0;m_pos<str_len;m_pos++){c=str.charCodeAt(m_pos);if((c&64512)===55296&&m_pos+1<str_len){c2=str.charCodeAt(m_pos+1);if((c2&64512)===56320){c=65536+(c-55296<<10)+(c2-56320);m_pos++}}buf_len+=c<128?1:c<2048?2:c<65536?3:4}buf=new utils.Buf8(buf_len);for(i=0,m_pos=0;i<buf_len;m_pos++){c=str.charCodeAt(m_pos);if((c&64512)===55296&&m_pos+1<str_len){c2=str.charCodeAt(m_pos+1);if((c2&64512)===56320){c=65536+(c-55296<<
10)+(c2-56320);m_pos++}}if(c<128)buf[i++]=c;else if(c<2048){buf[i++]=192|c>>>6;buf[i++]=128|c&63}else if(c<65536){buf[i++]=224|c>>>12;buf[i++]=128|c>>>6&63;buf[i++]=128|c&63}else{buf[i++]=240|c>>>18;buf[i++]=128|c>>>12&63;buf[i++]=128|c>>>6&63;buf[i++]=128|c&63}}return buf};function buf2binstring(buf,len){if(len<65537)if(buf.subarray&&STR_APPLY_UIA_OK||!buf.subarray&&STR_APPLY_OK)return String.fromCharCode.apply(null,utils.shrinkBuf(buf,len));var result="";for(var i=0;i<len;i++)result+=String.fromCharCode(buf[i]);
return result}exports.buf2binstring=function(buf){return buf2binstring(buf,buf.length)};exports.binstring2buf=function(str){var buf=new utils.Buf8(str.length);for(var i=0,len=buf.length;i<len;i++)buf[i]=str.charCodeAt(i);return buf};exports.buf2string=function(buf,max){var i,out,c,c_len;var len=max||buf.length;var utf16buf=new Array(len*2);for(out=0,i=0;i<len;){c=buf[i++];if(c<128){utf16buf[out++]=c;continue}c_len=_utf8len[c];if(c_len>4){utf16buf[out++]=65533;i+=c_len-1;continue}c&=c_len===2?31:c_len===
3?15:7;while(c_len>1&&i<len){c=c<<6|buf[i++]&63;c_len--}if(c_len>1){utf16buf[out++]=65533;continue}if(c<65536)utf16buf[out++]=c;else{c-=65536;utf16buf[out++]=55296|c>>10&1023;utf16buf[out++]=56320|c&1023}}return buf2binstring(utf16buf,out)};exports.utf8border=function(buf,max){var pos;max=max||buf.length;if(max>buf.length)max=buf.length;pos=max-1;while(pos>=0&&(buf[pos]&192)===128)pos--;if(pos<0)return max;if(pos===0)return max;return pos+_utf8len[buf[pos]]>max?pos:max}},{"./common":27}],29:[function(_dereq_,
module,exports){function adler32(adler,buf,len,pos){var s1=adler&65535|0,s2=adler>>>16&65535|0,n=0;while(len!==0){n=len>2E3?2E3:len;len-=n;do{s1=s1+buf[pos++]|0;s2=s2+s1|0}while(--n);s1%=65521;s2%=65521}return s1|s2<<16|0}module.exports=adler32},{}],30:[function(_dereq_,module,exports){module.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,
Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],31:[function(_dereq_,module,exports){function makeTable(){var c,table=[];for(var n=0;n<256;n++){c=n;for(var k=0;k<8;k++)c=c&1?3988292384^c>>>1:c>>>1;table[n]=c}return table}var crcTable=makeTable();function crc32(crc,buf,len,pos){var t=crcTable,end=pos+len;crc=crc^-1;for(var i=pos;i<end;i++)crc=crc>>>8^t[(crc^buf[i])&255];
return crc^-1}module.exports=crc32},{}],32:[function(_dereq_,module,exports){var utils=_dereq_("../utils/common");var trees=_dereq_("./trees");var adler32=_dereq_("./adler32");var crc32=_dereq_("./crc32");var msg=_dereq_("./messages");var Z_NO_FLUSH=0;var Z_PARTIAL_FLUSH=1;var Z_FULL_FLUSH=3;var Z_FINISH=4;var Z_BLOCK=5;var Z_OK=0;var Z_STREAM_END=1;var Z_STREAM_ERROR=-2;var Z_DATA_ERROR=-3;var Z_BUF_ERROR=-5;var Z_DEFAULT_COMPRESSION=-1;var Z_FILTERED=1;var Z_HUFFMAN_ONLY=2;var Z_RLE=3;var Z_FIXED=
4;var Z_DEFAULT_STRATEGY=0;var Z_UNKNOWN=2;var Z_DEFLATED=8;var MAX_MEM_LEVEL=9;var MAX_WBITS=15;var DEF_MEM_LEVEL=8;var LENGTH_CODES=29;var LITERALS=256;var L_CODES=LITERALS+1+LENGTH_CODES;var D_CODES=30;var BL_CODES=19;var HEAP_SIZE=2*L_CODES+1;var MAX_BITS=15;var MIN_MATCH=3;var MAX_MATCH=258;var MIN_LOOKAHEAD=MAX_MATCH+MIN_MATCH+1;var PRESET_DICT=32;var INIT_STATE=42;var EXTRA_STATE=69;var NAME_STATE=73;var COMMENT_STATE=91;var HCRC_STATE=103;var BUSY_STATE=113;var FINISH_STATE=666;var BS_NEED_MORE=
1;var BS_BLOCK_DONE=2;var BS_FINISH_STARTED=3;var BS_FINISH_DONE=4;var OS_CODE=3;function err(strm,errorCode){strm.msg=msg[errorCode];return errorCode}function rank(f){return(f<<1)-(f>4?9:0)}function zero(buf){var len=buf.length;while(--len>=0)buf[len]=0}function flush_pending(strm){var s=strm.state;var len=s.pending;if(len>strm.avail_out)len=strm.avail_out;if(len===0)return;utils.arraySet(strm.output,s.pending_buf,s.pending_out,len,strm.next_out);strm.next_out+=len;s.pending_out+=len;strm.total_out+=
len;strm.avail_out-=len;s.pending-=len;if(s.pending===0)s.pending_out=0}function flush_block_only(s,last){trees._tr_flush_block(s,s.block_start>=0?s.block_start:-1,s.strstart-s.block_start,last);s.block_start=s.strstart;flush_pending(s.strm)}function put_byte(s,b){s.pending_buf[s.pending++]=b}function putShortMSB(s,b){s.pending_buf[s.pending++]=b>>>8&255;s.pending_buf[s.pending++]=b&255}function read_buf(strm,buf,start,size){var len=strm.avail_in;if(len>size)len=size;if(len===0)return 0;strm.avail_in-=
len;utils.arraySet(buf,strm.input,strm.next_in,len,start);if(strm.state.wrap===1)strm.adler=adler32(strm.adler,buf,len,start);else if(strm.state.wrap===2)strm.adler=crc32(strm.adler,buf,len,start);strm.next_in+=len;strm.total_in+=len;return len}function longest_match(s,cur_match){var chain_length=s.max_chain_length;var scan=s.strstart;var match;var len;var best_len=s.prev_length;var nice_match=s.nice_match;var limit=s.strstart>s.w_size-MIN_LOOKAHEAD?s.strstart-(s.w_size-MIN_LOOKAHEAD):0;var _win=
s.window;var wmask=s.w_mask;var prev=s.prev;var strend=s.strstart+MAX_MATCH;var scan_end1=_win[scan+best_len-1];var scan_end=_win[scan+best_len];if(s.prev_length>=s.good_match)chain_length>>=2;if(nice_match>s.lookahead)nice_match=s.lookahead;do{match=cur_match;if(_win[match+best_len]!==scan_end||_win[match+best_len-1]!==scan_end1||_win[match]!==_win[scan]||_win[++match]!==_win[scan+1])continue;scan+=2;match++;do;while(_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&
_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&scan<strend);len=MAX_MATCH-(strend-scan);scan=strend-MAX_MATCH;if(len>best_len){s.match_start=cur_match;best_len=len;if(len>=nice_match)break;scan_end1=_win[scan+best_len-1];scan_end=_win[scan+best_len]}}while((cur_match=prev[cur_match&wmask])>limit&&--chain_length!==0);if(best_len<=s.lookahead)return best_len;return s.lookahead}function fill_window(s){var _w_size=
s.w_size;var p,n,m,more,str;do{more=s.window_size-s.lookahead-s.strstart;if(s.strstart>=_w_size+(_w_size-MIN_LOOKAHEAD)){utils.arraySet(s.window,s.window,_w_size,_w_size,0);s.match_start-=_w_size;s.strstart-=_w_size;s.block_start-=_w_size;n=s.hash_size;p=n;do{m=s.head[--p];s.head[p]=m>=_w_size?m-_w_size:0}while(--n);n=_w_size;p=n;do{m=s.prev[--p];s.prev[p]=m>=_w_size?m-_w_size:0}while(--n);more+=_w_size}if(s.strm.avail_in===0)break;n=read_buf(s.strm,s.window,s.strstart+s.lookahead,more);s.lookahead+=
n;if(s.lookahead+s.insert>=MIN_MATCH){str=s.strstart-s.insert;s.ins_h=s.window[str];s.ins_h=(s.ins_h<<s.hash_shift^s.window[str+1])&s.hash_mask;while(s.insert){s.ins_h=(s.ins_h<<s.hash_shift^s.window[str+MIN_MATCH-1])&s.hash_mask;s.prev[str&s.w_mask]=s.head[s.ins_h];s.head[s.ins_h]=str;str++;s.insert--;if(s.lookahead+s.insert<MIN_MATCH)break}}}while(s.lookahead<MIN_LOOKAHEAD&&s.strm.avail_in!==0)}function deflate_stored(s,flush){var max_block_size=65535;if(max_block_size>s.pending_buf_size-5)max_block_size=
s.pending_buf_size-5;for(;;){if(s.lookahead<=1){fill_window(s);if(s.lookahead===0&&flush===Z_NO_FLUSH)return BS_NEED_MORE;if(s.lookahead===0)break}s.strstart+=s.lookahead;s.lookahead=0;var max_start=s.block_start+max_block_size;if(s.strstart===0||s.strstart>=max_start){s.lookahead=s.strstart-max_start;s.strstart=max_start;flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}if(s.strstart-s.block_start>=s.w_size-MIN_LOOKAHEAD){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}}s.insert=
0;if(flush===Z_FINISH){flush_block_only(s,true);if(s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.strstart>s.block_start){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}return BS_NEED_MORE}function deflate_fast(s,flush){var hash_head;var bflush;for(;;){if(s.lookahead<MIN_LOOKAHEAD){fill_window(s);if(s.lookahead<MIN_LOOKAHEAD&&flush===Z_NO_FLUSH)return BS_NEED_MORE;if(s.lookahead===0)break}hash_head=0;if(s.lookahead>=MIN_MATCH){s.ins_h=(s.ins_h<<s.hash_shift^
s.window[s.strstart+MIN_MATCH-1])&s.hash_mask;hash_head=s.prev[s.strstart&s.w_mask]=s.head[s.ins_h];s.head[s.ins_h]=s.strstart}if(hash_head!==0&&s.strstart-hash_head<=s.w_size-MIN_LOOKAHEAD)s.match_length=longest_match(s,hash_head);if(s.match_length>=MIN_MATCH){bflush=trees._tr_tally(s,s.strstart-s.match_start,s.match_length-MIN_MATCH);s.lookahead-=s.match_length;if(s.match_length<=s.max_lazy_match&&s.lookahead>=MIN_MATCH){s.match_length--;do{s.strstart++;s.ins_h=(s.ins_h<<s.hash_shift^s.window[s.strstart+
MIN_MATCH-1])&s.hash_mask;hash_head=s.prev[s.strstart&s.w_mask]=s.head[s.ins_h];s.head[s.ins_h]=s.strstart}while(--s.match_length!==0);s.strstart++}else{s.strstart+=s.match_length;s.match_length=0;s.ins_h=s.window[s.strstart];s.ins_h=(s.ins_h<<s.hash_shift^s.window[s.strstart+1])&s.hash_mask}}else{bflush=trees._tr_tally(s,0,s.window[s.strstart]);s.lookahead--;s.strstart++}if(bflush){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}}s.insert=s.strstart<MIN_MATCH-1?s.strstart:MIN_MATCH-
1;if(flush===Z_FINISH){flush_block_only(s,true);if(s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.last_lit){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}return BS_BLOCK_DONE}function deflate_slow(s,flush){var hash_head;var bflush;var max_insert;for(;;){if(s.lookahead<MIN_LOOKAHEAD){fill_window(s);if(s.lookahead<MIN_LOOKAHEAD&&flush===Z_NO_FLUSH)return BS_NEED_MORE;if(s.lookahead===0)break}hash_head=0;if(s.lookahead>=MIN_MATCH){s.ins_h=(s.ins_h<<s.hash_shift^
s.window[s.strstart+MIN_MATCH-1])&s.hash_mask;hash_head=s.prev[s.strstart&s.w_mask]=s.head[s.ins_h];s.head[s.ins_h]=s.strstart}s.prev_length=s.match_length;s.prev_match=s.match_start;s.match_length=MIN_MATCH-1;if(hash_head!==0&&s.prev_length<s.max_lazy_match&&s.strstart-hash_head<=s.w_size-MIN_LOOKAHEAD){s.match_length=longest_match(s,hash_head);if(s.match_length<=5&&(s.strategy===Z_FILTERED||s.match_length===MIN_MATCH&&s.strstart-s.match_start>4096))s.match_length=MIN_MATCH-1}if(s.prev_length>=MIN_MATCH&&
s.match_length<=s.prev_length){max_insert=s.strstart+s.lookahead-MIN_MATCH;bflush=trees._tr_tally(s,s.strstart-1-s.prev_match,s.prev_length-MIN_MATCH);s.lookahead-=s.prev_length-1;s.prev_length-=2;do if(++s.strstart<=max_insert){s.ins_h=(s.ins_h<<s.hash_shift^s.window[s.strstart+MIN_MATCH-1])&s.hash_mask;hash_head=s.prev[s.strstart&s.w_mask]=s.head[s.ins_h];s.head[s.ins_h]=s.strstart}while(--s.prev_length!==0);s.match_available=0;s.match_length=MIN_MATCH-1;s.strstart++;if(bflush){flush_block_only(s,
false);if(s.strm.avail_out===0)return BS_NEED_MORE}}else if(s.match_available){bflush=trees._tr_tally(s,0,s.window[s.strstart-1]);if(bflush)flush_block_only(s,false);s.strstart++;s.lookahead--;if(s.strm.avail_out===0)return BS_NEED_MORE}else{s.match_available=1;s.strstart++;s.lookahead--}}if(s.match_available){bflush=trees._tr_tally(s,0,s.window[s.strstart-1]);s.match_available=0}s.insert=s.strstart<MIN_MATCH-1?s.strstart:MIN_MATCH-1;if(flush===Z_FINISH){flush_block_only(s,true);if(s.strm.avail_out===
0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.last_lit){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}return BS_BLOCK_DONE}function deflate_rle(s,flush){var bflush;var prev;var scan,strend;var _win=s.window;for(;;){if(s.lookahead<=MAX_MATCH){fill_window(s);if(s.lookahead<=MAX_MATCH&&flush===Z_NO_FLUSH)return BS_NEED_MORE;if(s.lookahead===0)break}s.match_length=0;if(s.lookahead>=MIN_MATCH&&s.strstart>0){scan=s.strstart-1;prev=_win[scan];if(prev===_win[++scan]&&prev===
_win[++scan]&&prev===_win[++scan]){strend=s.strstart+MAX_MATCH;do;while(prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&scan<strend);s.match_length=MAX_MATCH-(strend-scan);if(s.match_length>s.lookahead)s.match_length=s.lookahead}}if(s.match_length>=MIN_MATCH){bflush=trees._tr_tally(s,1,s.match_length-MIN_MATCH);s.lookahead-=s.match_length;s.strstart+=s.match_length;s.match_length=
0}else{bflush=trees._tr_tally(s,0,s.window[s.strstart]);s.lookahead--;s.strstart++}if(bflush){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}}s.insert=0;if(flush===Z_FINISH){flush_block_only(s,true);if(s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.last_lit){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}return BS_BLOCK_DONE}function deflate_huff(s,flush){var bflush;for(;;){if(s.lookahead===0){fill_window(s);if(s.lookahead===
0){if(flush===Z_NO_FLUSH)return BS_NEED_MORE;break}}s.match_length=0;bflush=trees._tr_tally(s,0,s.window[s.strstart]);s.lookahead--;s.strstart++;if(bflush){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}}s.insert=0;if(flush===Z_FINISH){flush_block_only(s,true);if(s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.last_lit){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}return BS_BLOCK_DONE}var Config=function(good_length,max_lazy,
nice_length,max_chain,func){this.good_length=good_length;this.max_lazy=max_lazy;this.nice_length=nice_length;this.max_chain=max_chain;this.func=func};var configuration_table;configuration_table=[new Config(0,0,0,0,deflate_stored),new Config(4,4,8,4,deflate_fast),new Config(4,5,16,8,deflate_fast),new Config(4,6,32,32,deflate_fast),new Config(4,4,16,16,deflate_slow),new Config(8,16,32,32,deflate_slow),new Config(8,16,128,128,deflate_slow),new Config(8,32,128,256,deflate_slow),new Config(32,128,258,
1024,deflate_slow),new Config(32,258,258,4096,deflate_slow)];function lm_init(s){s.window_size=2*s.w_size;zero(s.head);s.max_lazy_match=configuration_table[s.level].max_lazy;s.good_match=configuration_table[s.level].good_length;s.nice_match=configuration_table[s.level].nice_length;s.max_chain_length=configuration_table[s.level].max_chain;s.strstart=0;s.block_start=0;s.lookahead=0;s.insert=0;s.match_length=s.prev_length=MIN_MATCH-1;s.match_available=0;s.ins_h=0}function DeflateState(){this.strm=null;
this.status=0;this.pending_buf=null;this.pending_buf_size=0;this.pending_out=0;this.pending=0;this.wrap=0;this.gzhead=null;this.gzindex=0;this.method=Z_DEFLATED;this.last_flush=-1;this.w_size=0;this.w_bits=0;this.w_mask=0;this.window=null;this.window_size=0;this.prev=null;this.head=null;this.ins_h=0;this.hash_size=0;this.hash_bits=0;this.hash_mask=0;this.hash_shift=0;this.block_start=0;this.match_length=0;this.prev_match=0;this.match_available=0;this.strstart=0;this.match_start=0;this.lookahead=0;
this.prev_length=0;this.max_chain_length=0;this.max_lazy_match=0;this.level=0;this.strategy=0;this.good_match=0;this.nice_match=0;this.dyn_ltree=new utils.Buf16(HEAP_SIZE*2);this.dyn_dtree=new utils.Buf16((2*D_CODES+1)*2);this.bl_tree=new utils.Buf16((2*BL_CODES+1)*2);zero(this.dyn_ltree);zero(this.dyn_dtree);zero(this.bl_tree);this.l_desc=null;this.d_desc=null;this.bl_desc=null;this.bl_count=new utils.Buf16(MAX_BITS+1);this.heap=new utils.Buf16(2*L_CODES+1);zero(this.heap);this.heap_len=0;this.heap_max=
0;this.depth=new utils.Buf16(2*L_CODES+1);zero(this.depth);this.l_buf=0;this.lit_bufsize=0;this.last_lit=0;this.d_buf=0;this.opt_len=0;this.static_len=0;this.matches=0;this.insert=0;this.bi_buf=0;this.bi_valid=0}function deflateResetKeep(strm){var s;if(!strm||!strm.state)return err(strm,Z_STREAM_ERROR);strm.total_in=strm.total_out=0;strm.data_type=Z_UNKNOWN;s=strm.state;s.pending=0;s.pending_out=0;if(s.wrap<0)s.wrap=-s.wrap;s.status=s.wrap?INIT_STATE:BUSY_STATE;strm.adler=s.wrap===2?0:1;s.last_flush=
Z_NO_FLUSH;trees._tr_init(s);return Z_OK}function deflateReset(strm){var ret=deflateResetKeep(strm);if(ret===Z_OK)lm_init(strm.state);return ret}function deflateSetHeader(strm,head){if(!strm||!strm.state)return Z_STREAM_ERROR;if(strm.state.wrap!==2)return Z_STREAM_ERROR;strm.state.gzhead=head;return Z_OK}function deflateInit2(strm,level,method,windowBits,memLevel,strategy){if(!strm)return Z_STREAM_ERROR;var wrap=1;if(level===Z_DEFAULT_COMPRESSION)level=6;if(windowBits<0){wrap=0;windowBits=-windowBits}else if(windowBits>
15){wrap=2;windowBits-=16}if(memLevel<1||memLevel>MAX_MEM_LEVEL||method!==Z_DEFLATED||windowBits<8||windowBits>15||level<0||level>9||strategy<0||strategy>Z_FIXED)return err(strm,Z_STREAM_ERROR);if(windowBits===8)windowBits=9;var s=new DeflateState;strm.state=s;s.strm=strm;s.wrap=wrap;s.gzhead=null;s.w_bits=windowBits;s.w_size=1<<s.w_bits;s.w_mask=s.w_size-1;s.hash_bits=memLevel+7;s.hash_size=1<<s.hash_bits;s.hash_mask=s.hash_size-1;s.hash_shift=~~((s.hash_bits+MIN_MATCH-1)/MIN_MATCH);s.window=new utils.Buf8(s.w_size*
2);s.head=new utils.Buf16(s.hash_size);s.prev=new utils.Buf16(s.w_size);s.lit_bufsize=1<<memLevel+6;s.pending_buf_size=s.lit_bufsize*4;s.pending_buf=new utils.Buf8(s.pending_buf_size);s.d_buf=s.lit_bufsize>>1;s.l_buf=(1+2)*s.lit_bufsize;s.level=level;s.strategy=strategy;s.method=method;return deflateReset(strm)}function deflateInit(strm,level){return deflateInit2(strm,level,Z_DEFLATED,MAX_WBITS,DEF_MEM_LEVEL,Z_DEFAULT_STRATEGY)}function deflate(strm,flush){var old_flush,s;var beg,val;if(!strm||!strm.state||
flush>Z_BLOCK||flush<0)return strm?err(strm,Z_STREAM_ERROR):Z_STREAM_ERROR;s=strm.state;if(!strm.output||!strm.input&&strm.avail_in!==0||s.status===FINISH_STATE&&flush!==Z_FINISH)return err(strm,strm.avail_out===0?Z_BUF_ERROR:Z_STREAM_ERROR);s.strm=strm;old_flush=s.last_flush;s.last_flush=flush;if(s.status===INIT_STATE)if(s.wrap===2){strm.adler=0;put_byte(s,31);put_byte(s,139);put_byte(s,8);if(!s.gzhead){put_byte(s,0);put_byte(s,0);put_byte(s,0);put_byte(s,0);put_byte(s,0);put_byte(s,s.level===9?
2:s.strategy>=Z_HUFFMAN_ONLY||s.level<2?4:0);put_byte(s,OS_CODE);s.status=BUSY_STATE}else{put_byte(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(!s.gzhead.extra?0:4)+(!s.gzhead.name?0:8)+(!s.gzhead.comment?0:16));put_byte(s,s.gzhead.time&255);put_byte(s,s.gzhead.time>>8&255);put_byte(s,s.gzhead.time>>16&255);put_byte(s,s.gzhead.time>>24&255);put_byte(s,s.level===9?2:s.strategy>=Z_HUFFMAN_ONLY||s.level<2?4:0);put_byte(s,s.gzhead.os&255);if(s.gzhead.extra&&s.gzhead.extra.length){put_byte(s,s.gzhead.extra.length&
255);put_byte(s,s.gzhead.extra.length>>8&255)}if(s.gzhead.hcrc)strm.adler=crc32(strm.adler,s.pending_buf,s.pending,0);s.gzindex=0;s.status=EXTRA_STATE}}else{var header=Z_DEFLATED+(s.w_bits-8<<4)<<8;var level_flags=-1;if(s.strategy>=Z_HUFFMAN_ONLY||s.level<2)level_flags=0;else if(s.level<6)level_flags=1;else if(s.level===6)level_flags=2;else level_flags=3;header|=level_flags<<6;if(s.strstart!==0)header|=PRESET_DICT;header+=31-header%31;s.status=BUSY_STATE;putShortMSB(s,header);if(s.strstart!==0){putShortMSB(s,
strm.adler>>>16);putShortMSB(s,strm.adler&65535)}strm.adler=1}if(s.status===EXTRA_STATE)if(s.gzhead.extra){beg=s.pending;while(s.gzindex<(s.gzhead.extra.length&65535)){if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);flush_pending(strm);beg=s.pending;if(s.pending===s.pending_buf_size)break}put_byte(s,s.gzhead.extra[s.gzindex]&255);s.gzindex++}if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-
beg,beg);if(s.gzindex===s.gzhead.extra.length){s.gzindex=0;s.status=NAME_STATE}}else s.status=NAME_STATE;if(s.status===NAME_STATE)if(s.gzhead.name){beg=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);flush_pending(strm);beg=s.pending;if(s.pending===s.pending_buf_size){val=1;break}}if(s.gzindex<s.gzhead.name.length)val=s.gzhead.name.charCodeAt(s.gzindex++)&255;else val=0;put_byte(s,val)}while(val!==0);if(s.gzhead.hcrc&&
s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(val===0){s.gzindex=0;s.status=COMMENT_STATE}}else s.status=COMMENT_STATE;if(s.status===COMMENT_STATE)if(s.gzhead.comment){beg=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);flush_pending(strm);beg=s.pending;if(s.pending===s.pending_buf_size){val=1;break}}if(s.gzindex<s.gzhead.comment.length)val=s.gzhead.comment.charCodeAt(s.gzindex++)&
255;else val=0;put_byte(s,val)}while(val!==0);if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(val===0)s.status=HCRC_STATE}else s.status=HCRC_STATE;if(s.status===HCRC_STATE)if(s.gzhead.hcrc){if(s.pending+2>s.pending_buf_size)flush_pending(strm);if(s.pending+2<=s.pending_buf_size){put_byte(s,strm.adler&255);put_byte(s,strm.adler>>8&255);strm.adler=0;s.status=BUSY_STATE}}else s.status=BUSY_STATE;if(s.pending!==0){flush_pending(strm);if(strm.avail_out===
0){s.last_flush=-1;return Z_OK}}else if(strm.avail_in===0&&rank(flush)<=rank(old_flush)&&flush!==Z_FINISH)return err(strm,Z_BUF_ERROR);if(s.status===FINISH_STATE&&strm.avail_in!==0)return err(strm,Z_BUF_ERROR);if(strm.avail_in!==0||s.lookahead!==0||flush!==Z_NO_FLUSH&&s.status!==FINISH_STATE){var bstate=s.strategy===Z_HUFFMAN_ONLY?deflate_huff(s,flush):s.strategy===Z_RLE?deflate_rle(s,flush):configuration_table[s.level].func(s,flush);if(bstate===BS_FINISH_STARTED||bstate===BS_FINISH_DONE)s.status=
FINISH_STATE;if(bstate===BS_NEED_MORE||bstate===BS_FINISH_STARTED){if(strm.avail_out===0)s.last_flush=-1;return Z_OK}if(bstate===BS_BLOCK_DONE){if(flush===Z_PARTIAL_FLUSH)trees._tr_align(s);else if(flush!==Z_BLOCK){trees._tr_stored_block(s,0,0,false);if(flush===Z_FULL_FLUSH){zero(s.head);if(s.lookahead===0){s.strstart=0;s.block_start=0;s.insert=0}}}flush_pending(strm);if(strm.avail_out===0){s.last_flush=-1;return Z_OK}}}if(flush!==Z_FINISH)return Z_OK;if(s.wrap<=0)return Z_STREAM_END;if(s.wrap===
2){put_byte(s,strm.adler&255);put_byte(s,strm.adler>>8&255);put_byte(s,strm.adler>>16&255);put_byte(s,strm.adler>>24&255);put_byte(s,strm.total_in&255);put_byte(s,strm.total_in>>8&255);put_byte(s,strm.total_in>>16&255);put_byte(s,strm.total_in>>24&255)}else{putShortMSB(s,strm.adler>>>16);putShortMSB(s,strm.adler&65535)}flush_pending(strm);if(s.wrap>0)s.wrap=-s.wrap;return s.pending!==0?Z_OK:Z_STREAM_END}function deflateEnd(strm){var status;if(!strm||!strm.state)return Z_STREAM_ERROR;status=strm.state.status;
if(status!==INIT_STATE&&status!==EXTRA_STATE&&status!==NAME_STATE&&status!==COMMENT_STATE&&status!==HCRC_STATE&&status!==BUSY_STATE&&status!==FINISH_STATE)return err(strm,Z_STREAM_ERROR);strm.state=null;return status===BUSY_STATE?err(strm,Z_DATA_ERROR):Z_OK}exports.deflateInit=deflateInit;exports.deflateInit2=deflateInit2;exports.deflateReset=deflateReset;exports.deflateResetKeep=deflateResetKeep;exports.deflateSetHeader=deflateSetHeader;exports.deflate=deflate;exports.deflateEnd=deflateEnd;exports.deflateInfo=
"pako deflate (from Nodeca project)"},{"../utils/common":27,"./adler32":29,"./crc32":31,"./messages":37,"./trees":38}],33:[function(_dereq_,module,exports){function GZheader(){this.text=0;this.time=0;this.xflags=0;this.os=0;this.extra=null;this.extra_len=0;this.name="";this.comment="";this.hcrc=0;this.done=false}module.exports=GZheader},{}],34:[function(_dereq_,module,exports){var BAD=30;var TYPE=12;module.exports=function inflate_fast(strm,start){var state;var _in;var last;var _out;var beg;var end;
var dmax;var wsize;var whave;var wnext;var window;var hold;var bits;var lcode;var dcode;var lmask;var dmask;var here;var op;var len;var dist;var from;var from_source;var input,output;state=strm.state;_in=strm.next_in;input=strm.input;last=_in+(strm.avail_in-5);_out=strm.next_out;output=strm.output;beg=_out-(start-strm.avail_out);end=_out+(strm.avail_out-257);dmax=state.dmax;wsize=state.wsize;whave=state.whave;wnext=state.wnext;window=state.window;hold=state.hold;bits=state.bits;lcode=state.lencode;
dcode=state.distcode;lmask=(1<<state.lenbits)-1;dmask=(1<<state.distbits)-1;top:do{if(bits<15){hold+=input[_in++]<<bits;bits+=8;hold+=input[_in++]<<bits;bits+=8}here=lcode[hold&lmask];dolen:for(;;){op=here>>>24;hold>>>=op;bits-=op;op=here>>>16&255;if(op===0)output[_out++]=here&65535;else if(op&16){len=here&65535;op&=15;if(op){if(bits<op){hold+=input[_in++]<<bits;bits+=8}len+=hold&(1<<op)-1;hold>>>=op;bits-=op}if(bits<15){hold+=input[_in++]<<bits;bits+=8;hold+=input[_in++]<<bits;bits+=8}here=dcode[hold&
dmask];dodist:for(;;){op=here>>>24;hold>>>=op;bits-=op;op=here>>>16&255;if(op&16){dist=here&65535;op&=15;if(bits<op){hold+=input[_in++]<<bits;bits+=8;if(bits<op){hold+=input[_in++]<<bits;bits+=8}}dist+=hold&(1<<op)-1;if(dist>dmax){strm.msg="invalid distance too far back";state.mode=BAD;break top}hold>>>=op;bits-=op;op=_out-beg;if(dist>op){op=dist-op;if(op>whave)if(state.sane){strm.msg="invalid distance too far back";state.mode=BAD;break top}from=0;from_source=window;if(wnext===0){from+=wsize-op;if(op<
len){len-=op;do output[_out++]=window[from++];while(--op);from=_out-dist;from_source=output}}else if(wnext<op){from+=wsize+wnext-op;op-=wnext;if(op<len){len-=op;do output[_out++]=window[from++];while(--op);from=0;if(wnext<len){op=wnext;len-=op;do output[_out++]=window[from++];while(--op);from=_out-dist;from_source=output}}}else{from+=wnext-op;if(op<len){len-=op;do output[_out++]=window[from++];while(--op);from=_out-dist;from_source=output}}while(len>2){output[_out++]=from_source[from++];output[_out++]=
from_source[from++];output[_out++]=from_source[from++];len-=3}if(len){output[_out++]=from_source[from++];if(len>1)output[_out++]=from_source[from++]}}else{from=_out-dist;do{output[_out++]=output[from++];output[_out++]=output[from++];output[_out++]=output[from++];len-=3}while(len>2);if(len){output[_out++]=output[from++];if(len>1)output[_out++]=output[from++]}}}else if((op&64)===0){here=dcode[(here&65535)+(hold&(1<<op)-1)];continue dodist}else{strm.msg="invalid distance code";state.mode=BAD;break top}break}}else if((op&
64)===0){here=lcode[(here&65535)+(hold&(1<<op)-1)];continue dolen}else if(op&32){state.mode=TYPE;break top}else{strm.msg="invalid literal/length code";state.mode=BAD;break top}break}}while(_in<last&&_out<end);len=bits>>3;_in-=len;bits-=len<<3;hold&=(1<<bits)-1;strm.next_in=_in;strm.next_out=_out;strm.avail_in=_in<last?5+(last-_in):5-(_in-last);strm.avail_out=_out<end?257+(end-_out):257-(_out-end);state.hold=hold;state.bits=bits;return}},{}],35:[function(_dereq_,module,exports){var utils=_dereq_("../utils/common");
var adler32=_dereq_("./adler32");var crc32=_dereq_("./crc32");var inflate_fast=_dereq_("./inffast");var inflate_table=_dereq_("./inftrees");var CODES=0;var LENS=1;var DISTS=2;var Z_FINISH=4;var Z_BLOCK=5;var Z_TREES=6;var Z_OK=0;var Z_STREAM_END=1;var Z_NEED_DICT=2;var Z_STREAM_ERROR=-2;var Z_DATA_ERROR=-3;var Z_MEM_ERROR=-4;var Z_BUF_ERROR=-5;var Z_DEFLATED=8;var HEAD=1;var FLAGS=2;var TIME=3;var OS=4;var EXLEN=5;var EXTRA=6;var NAME=7;var COMMENT=8;var HCRC=9;var DICTID=10;var DICT=11;var TYPE=
12;var TYPEDO=13;var STORED=14;var COPY_=15;var COPY=16;var TABLE=17;var LENLENS=18;var CODELENS=19;var LEN_=20;var LEN=21;var LENEXT=22;var DIST=23;var DISTEXT=24;var MATCH=25;var LIT=26;var CHECK=27;var LENGTH=28;var DONE=29;var BAD=30;var MEM=31;var SYNC=32;var ENOUGH_LENS=852;var ENOUGH_DISTS=592;var MAX_WBITS=15;var DEF_WBITS=MAX_WBITS;function ZSWAP32(q){return(q>>>24&255)+(q>>>8&65280)+((q&65280)<<8)+((q&255)<<24)}function InflateState(){this.mode=0;this.last=false;this.wrap=0;this.havedict=
false;this.flags=0;this.dmax=0;this.check=0;this.total=0;this.head=null;this.wbits=0;this.wsize=0;this.whave=0;this.wnext=0;this.window=null;this.hold=0;this.bits=0;this.length=0;this.offset=0;this.extra=0;this.lencode=null;this.distcode=null;this.lenbits=0;this.distbits=0;this.ncode=0;this.nlen=0;this.ndist=0;this.have=0;this.next=null;this.lens=new utils.Buf16(320);this.work=new utils.Buf16(288);this.lendyn=null;this.distdyn=null;this.sane=0;this.back=0;this.was=0}function inflateResetKeep(strm){var state;
if(!strm||!strm.state)return Z_STREAM_ERROR;state=strm.state;strm.total_in=strm.total_out=state.total=0;strm.msg="";if(state.wrap)strm.adler=state.wrap&1;state.mode=HEAD;state.last=0;state.havedict=0;state.dmax=32768;state.head=null;state.hold=0;state.bits=0;state.lencode=state.lendyn=new utils.Buf32(ENOUGH_LENS);state.distcode=state.distdyn=new utils.Buf32(ENOUGH_DISTS);state.sane=1;state.back=-1;return Z_OK}function inflateReset(strm){var state;if(!strm||!strm.state)return Z_STREAM_ERROR;state=
strm.state;state.wsize=0;state.whave=0;state.wnext=0;return inflateResetKeep(strm)}function inflateReset2(strm,windowBits){var wrap;var state;if(!strm||!strm.state)return Z_STREAM_ERROR;state=strm.state;if(windowBits<0){wrap=0;windowBits=-windowBits}else{wrap=(windowBits>>4)+1;if(windowBits<48)windowBits&=15}if(windowBits&&(windowBits<8||windowBits>15))return Z_STREAM_ERROR;if(state.window!==null&&state.wbits!==windowBits)state.window=null;state.wrap=wrap;state.wbits=windowBits;return inflateReset(strm)}
function inflateInit2(strm,windowBits){var ret;var state;if(!strm)return Z_STREAM_ERROR;state=new InflateState;strm.state=state;state.window=null;ret=inflateReset2(strm,windowBits);if(ret!==Z_OK)strm.state=null;return ret}function inflateInit(strm){return inflateInit2(strm,DEF_WBITS)}var virgin=true;var lenfix,distfix;function fixedtables(state){if(virgin){var sym;lenfix=new utils.Buf32(512);distfix=new utils.Buf32(32);sym=0;while(sym<144)state.lens[sym++]=8;while(sym<256)state.lens[sym++]=9;while(sym<
280)state.lens[sym++]=7;while(sym<288)state.lens[sym++]=8;inflate_table(LENS,state.lens,0,288,lenfix,0,state.work,{bits:9});sym=0;while(sym<32)state.lens[sym++]=5;inflate_table(DISTS,state.lens,0,32,distfix,0,state.work,{bits:5});virgin=false}state.lencode=lenfix;state.lenbits=9;state.distcode=distfix;state.distbits=5}function updatewindow(strm,src,end,copy){var dist;var state=strm.state;if(state.window===null){state.wsize=1<<state.wbits;state.wnext=0;state.whave=0;state.window=new utils.Buf8(state.wsize)}if(copy>=
state.wsize){utils.arraySet(state.window,src,end-state.wsize,state.wsize,0);state.wnext=0;state.whave=state.wsize}else{dist=state.wsize-state.wnext;if(dist>copy)dist=copy;utils.arraySet(state.window,src,end-copy,dist,state.wnext);copy-=dist;if(copy){utils.arraySet(state.window,src,end-copy,copy,0);state.wnext=copy;state.whave=state.wsize}else{state.wnext+=dist;if(state.wnext===state.wsize)state.wnext=0;if(state.whave<state.wsize)state.whave+=dist}}return 0}function inflate(strm,flush){var state;var input,
output;var next;var put;var have,left;var hold;var bits;var _in,_out;var copy;var from;var from_source;var here=0;var here_bits,here_op,here_val;var last_bits,last_op,last_val;var len;var ret;var hbuf=new utils.Buf8(4);var opts;var n;var order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!strm||!strm.state||!strm.output||!strm.input&&strm.avail_in!==0)return Z_STREAM_ERROR;state=strm.state;if(state.mode===TYPE)state.mode=TYPEDO;put=strm.next_out;output=strm.output;left=strm.avail_out;next=
strm.next_in;input=strm.input;have=strm.avail_in;hold=state.hold;bits=state.bits;_in=have;_out=left;ret=Z_OK;inf_leave:for(;;)switch(state.mode){case HEAD:if(state.wrap===0){state.mode=TYPEDO;break}while(bits<16){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}if(state.wrap&2&&hold===35615){state.check=0;hbuf[0]=hold&255;hbuf[1]=hold>>>8&255;state.check=crc32(state.check,hbuf,2,0);hold=0;bits=0;state.mode=FLAGS;break}state.flags=0;if(state.head)state.head.done=false;if(!(state.wrap&
1)||(((hold&255)<<8)+(hold>>8))%31){strm.msg="incorrect header check";state.mode=BAD;break}if((hold&15)!==Z_DEFLATED){strm.msg="unknown compression method";state.mode=BAD;break}hold>>>=4;bits-=4;len=(hold&15)+8;if(state.wbits===0)state.wbits=len;else if(len>state.wbits){strm.msg="invalid window size";state.mode=BAD;break}state.dmax=1<<len;strm.adler=state.check=1;state.mode=hold&512?DICTID:TYPE;hold=0;bits=0;break;case FLAGS:while(bits<16){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;
bits+=8}state.flags=hold;if((state.flags&255)!==Z_DEFLATED){strm.msg="unknown compression method";state.mode=BAD;break}if(state.flags&57344){strm.msg="unknown header flags set";state.mode=BAD;break}if(state.head)state.head.text=hold>>8&1;if(state.flags&512){hbuf[0]=hold&255;hbuf[1]=hold>>>8&255;state.check=crc32(state.check,hbuf,2,0)}hold=0;bits=0;state.mode=TIME;case TIME:while(bits<32){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}if(state.head)state.head.time=hold;if(state.flags&
512){hbuf[0]=hold&255;hbuf[1]=hold>>>8&255;hbuf[2]=hold>>>16&255;hbuf[3]=hold>>>24&255;state.check=crc32(state.check,hbuf,4,0)}hold=0;bits=0;state.mode=OS;case OS:while(bits<16){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}if(state.head){state.head.xflags=hold&255;state.head.os=hold>>8}if(state.flags&512){hbuf[0]=hold&255;hbuf[1]=hold>>>8&255;state.check=crc32(state.check,hbuf,2,0)}hold=0;bits=0;state.mode=EXLEN;case EXLEN:if(state.flags&1024){while(bits<16){if(have===0)break inf_leave;
have--;hold+=input[next++]<<bits;bits+=8}state.length=hold;if(state.head)state.head.extra_len=hold;if(state.flags&512){hbuf[0]=hold&255;hbuf[1]=hold>>>8&255;state.check=crc32(state.check,hbuf,2,0)}hold=0;bits=0}else if(state.head)state.head.extra=null;state.mode=EXTRA;case EXTRA:if(state.flags&1024){copy=state.length;if(copy>have)copy=have;if(copy){if(state.head){len=state.head.extra_len-state.length;if(!state.head.extra)state.head.extra=new Array(state.head.extra_len);utils.arraySet(state.head.extra,
input,next,copy,len)}if(state.flags&512)state.check=crc32(state.check,input,copy,next);have-=copy;next+=copy;state.length-=copy}if(state.length)break inf_leave}state.length=0;state.mode=NAME;case NAME:if(state.flags&2048){if(have===0)break inf_leave;copy=0;do{len=input[next+copy++];if(state.head&&len&&state.length<65536)state.head.name+=String.fromCharCode(len)}while(len&&copy<have);if(state.flags&512)state.check=crc32(state.check,input,copy,next);have-=copy;next+=copy;if(len)break inf_leave}else if(state.head)state.head.name=
null;state.length=0;state.mode=COMMENT;case COMMENT:if(state.flags&4096){if(have===0)break inf_leave;copy=0;do{len=input[next+copy++];if(state.head&&len&&state.length<65536)state.head.comment+=String.fromCharCode(len)}while(len&&copy<have);if(state.flags&512)state.check=crc32(state.check,input,copy,next);have-=copy;next+=copy;if(len)break inf_leave}else if(state.head)state.head.comment=null;state.mode=HCRC;case HCRC:if(state.flags&512){while(bits<16){if(have===0)break inf_leave;have--;hold+=input[next++]<<
bits;bits+=8}if(hold!==(state.check&65535)){strm.msg="header crc mismatch";state.mode=BAD;break}hold=0;bits=0}if(state.head){state.head.hcrc=state.flags>>9&1;state.head.done=true}strm.adler=state.check=0;state.mode=TYPE;break;case DICTID:while(bits<32){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}strm.adler=state.check=ZSWAP32(hold);hold=0;bits=0;state.mode=DICT;case DICT:if(state.havedict===0){strm.next_out=put;strm.avail_out=left;strm.next_in=next;strm.avail_in=have;state.hold=
hold;state.bits=bits;return Z_NEED_DICT}strm.adler=state.check=1;state.mode=TYPE;case TYPE:if(flush===Z_BLOCK||flush===Z_TREES)break inf_leave;case TYPEDO:if(state.last){hold>>>=bits&7;bits-=bits&7;state.mode=CHECK;break}while(bits<3){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}state.last=hold&1;hold>>>=1;bits-=1;switch(hold&3){case 0:state.mode=STORED;break;case 1:fixedtables(state);state.mode=LEN_;if(flush===Z_TREES){hold>>>=2;bits-=2;break inf_leave}break;case 2:state.mode=
TABLE;break;case 3:strm.msg="invalid block type";state.mode=BAD}hold>>>=2;bits-=2;break;case STORED:hold>>>=bits&7;bits-=bits&7;while(bits<32){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}if((hold&65535)!==(hold>>>16^65535)){strm.msg="invalid stored block lengths";state.mode=BAD;break}state.length=hold&65535;hold=0;bits=0;state.mode=COPY_;if(flush===Z_TREES)break inf_leave;case COPY_:state.mode=COPY;case COPY:copy=state.length;if(copy){if(copy>have)copy=have;if(copy>left)copy=
left;if(copy===0)break inf_leave;utils.arraySet(output,input,next,copy,put);have-=copy;next+=copy;left-=copy;put+=copy;state.length-=copy;break}state.mode=TYPE;break;case TABLE:while(bits<14){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}state.nlen=(hold&31)+257;hold>>>=5;bits-=5;state.ndist=(hold&31)+1;hold>>>=5;bits-=5;state.ncode=(hold&15)+4;hold>>>=4;bits-=4;if(state.nlen>286||state.ndist>30){strm.msg="too many length or distance symbols";state.mode=BAD;break}state.have=
0;state.mode=LENLENS;case LENLENS:while(state.have<state.ncode){while(bits<3){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}state.lens[order[state.have++]]=hold&7;hold>>>=3;bits-=3}while(state.have<19)state.lens[order[state.have++]]=0;state.lencode=state.lendyn;state.lenbits=7;opts={bits:state.lenbits};ret=inflate_table(CODES,state.lens,0,19,state.lencode,0,state.work,opts);state.lenbits=opts.bits;if(ret){strm.msg="invalid code lengths set";state.mode=BAD;break}state.have=0;
state.mode=CODELENS;case CODELENS:while(state.have<state.nlen+state.ndist){for(;;){here=state.lencode[hold&(1<<state.lenbits)-1];here_bits=here>>>24;here_op=here>>>16&255;here_val=here&65535;if(here_bits<=bits)break;if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}if(here_val<16){hold>>>=here_bits;bits-=here_bits;state.lens[state.have++]=here_val}else{if(here_val===16){n=here_bits+2;while(bits<n){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}hold>>>=here_bits;
bits-=here_bits;if(state.have===0){strm.msg="invalid bit length repeat";state.mode=BAD;break}len=state.lens[state.have-1];copy=3+(hold&3);hold>>>=2;bits-=2}else if(here_val===17){n=here_bits+3;while(bits<n){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}hold>>>=here_bits;bits-=here_bits;len=0;copy=3+(hold&7);hold>>>=3;bits-=3}else{n=here_bits+7;while(bits<n){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}hold>>>=here_bits;bits-=here_bits;len=0;copy=11+(hold&
127);hold>>>=7;bits-=7}if(state.have+copy>state.nlen+state.ndist){strm.msg="invalid bit length repeat";state.mode=BAD;break}while(copy--)state.lens[state.have++]=len}}if(state.mode===BAD)break;if(state.lens[256]===0){strm.msg="invalid code -- missing end-of-block";state.mode=BAD;break}state.lenbits=9;opts={bits:state.lenbits};ret=inflate_table(LENS,state.lens,0,state.nlen,state.lencode,0,state.work,opts);state.lenbits=opts.bits;if(ret){strm.msg="invalid literal/lengths set";state.mode=BAD;break}state.distbits=
6;state.distcode=state.distdyn;opts={bits:state.distbits};ret=inflate_table(DISTS,state.lens,state.nlen,state.ndist,state.distcode,0,state.work,opts);state.distbits=opts.bits;if(ret){strm.msg="invalid distances set";state.mode=BAD;break}state.mode=LEN_;if(flush===Z_TREES)break inf_leave;case LEN_:state.mode=LEN;case LEN:if(have>=6&&left>=258){strm.next_out=put;strm.avail_out=left;strm.next_in=next;strm.avail_in=have;state.hold=hold;state.bits=bits;inflate_fast(strm,_out);put=strm.next_out;output=
strm.output;left=strm.avail_out;next=strm.next_in;input=strm.input;have=strm.avail_in;hold=state.hold;bits=state.bits;if(state.mode===TYPE)state.back=-1;break}state.back=0;for(;;){here=state.lencode[hold&(1<<state.lenbits)-1];here_bits=here>>>24;here_op=here>>>16&255;here_val=here&65535;if(here_bits<=bits)break;if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}if(here_op&&(here_op&240)===0){last_bits=here_bits;last_op=here_op;last_val=here_val;for(;;){here=state.lencode[last_val+
((hold&(1<<last_bits+last_op)-1)>>last_bits)];here_bits=here>>>24;here_op=here>>>16&255;here_val=here&65535;if(last_bits+here_bits<=bits)break;if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}hold>>>=last_bits;bits-=last_bits;state.back+=last_bits}hold>>>=here_bits;bits-=here_bits;state.back+=here_bits;state.length=here_val;if(here_op===0){state.mode=LIT;break}if(here_op&32){state.back=-1;state.mode=TYPE;break}if(here_op&64){strm.msg="invalid literal/length code";state.mode=BAD;
break}state.extra=here_op&15;state.mode=LENEXT;case LENEXT:if(state.extra){n=state.extra;while(bits<n){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}state.length+=hold&(1<<state.extra)-1;hold>>>=state.extra;bits-=state.extra;state.back+=state.extra}state.was=state.length;state.mode=DIST;case DIST:for(;;){here=state.distcode[hold&(1<<state.distbits)-1];here_bits=here>>>24;here_op=here>>>16&255;here_val=here&65535;if(here_bits<=bits)break;if(have===0)break inf_leave;have--;hold+=
input[next++]<<bits;bits+=8}if((here_op&240)===0){last_bits=here_bits;last_op=here_op;last_val=here_val;for(;;){here=state.distcode[last_val+((hold&(1<<last_bits+last_op)-1)>>last_bits)];here_bits=here>>>24;here_op=here>>>16&255;here_val=here&65535;if(last_bits+here_bits<=bits)break;if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}hold>>>=last_bits;bits-=last_bits;state.back+=last_bits}hold>>>=here_bits;bits-=here_bits;state.back+=here_bits;if(here_op&64){strm.msg="invalid distance code";
state.mode=BAD;break}state.offset=here_val;state.extra=here_op&15;state.mode=DISTEXT;case DISTEXT:if(state.extra){n=state.extra;while(bits<n){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}state.offset+=hold&(1<<state.extra)-1;hold>>>=state.extra;bits-=state.extra;state.back+=state.extra}if(state.offset>state.dmax){strm.msg="invalid distance too far back";state.mode=BAD;break}state.mode=MATCH;case MATCH:if(left===0)break inf_leave;copy=_out-left;if(state.offset>copy){copy=state.offset-
copy;if(copy>state.whave)if(state.sane){strm.msg="invalid distance too far back";state.mode=BAD;break}if(copy>state.wnext){copy-=state.wnext;from=state.wsize-copy}else from=state.wnext-copy;if(copy>state.length)copy=state.length;from_source=state.window}else{from_source=output;from=put-state.offset;copy=state.length}if(copy>left)copy=left;left-=copy;state.length-=copy;do output[put++]=from_source[from++];while(--copy);if(state.length===0)state.mode=LEN;break;case LIT:if(left===0)break inf_leave;output[put++]=
state.length;left--;state.mode=LEN;break;case CHECK:if(state.wrap){while(bits<32){if(have===0)break inf_leave;have--;hold|=input[next++]<<bits;bits+=8}_out-=left;strm.total_out+=_out;state.total+=_out;if(_out)strm.adler=state.check=state.flags?crc32(state.check,output,_out,put-_out):adler32(state.check,output,_out,put-_out);_out=left;if((state.flags?hold:ZSWAP32(hold))!==state.check){strm.msg="incorrect data check";state.mode=BAD;break}hold=0;bits=0}state.mode=LENGTH;case LENGTH:if(state.wrap&&state.flags){while(bits<
32){if(have===0)break inf_leave;have--;hold+=input[next++]<<bits;bits+=8}if(hold!==(state.total&4294967295)){strm.msg="incorrect length check";state.mode=BAD;break}hold=0;bits=0}state.mode=DONE;case DONE:ret=Z_STREAM_END;break inf_leave;case BAD:ret=Z_DATA_ERROR;break inf_leave;case MEM:return Z_MEM_ERROR;case SYNC:default:return Z_STREAM_ERROR}strm.next_out=put;strm.avail_out=left;strm.next_in=next;strm.avail_in=have;state.hold=hold;state.bits=bits;if(state.wsize||_out!==strm.avail_out&&state.mode<
BAD&&(state.mode<CHECK||flush!==Z_FINISH))if(updatewindow(strm,strm.output,strm.next_out,_out-strm.avail_out)){state.mode=MEM;return Z_MEM_ERROR}_in-=strm.avail_in;_out-=strm.avail_out;strm.total_in+=_in;strm.total_out+=_out;state.total+=_out;if(state.wrap&&_out)strm.adler=state.check=state.flags?crc32(state.check,output,_out,strm.next_out-_out):adler32(state.check,output,_out,strm.next_out-_out);strm.data_type=state.bits+(state.last?64:0)+(state.mode===TYPE?128:0)+(state.mode===LEN_||state.mode===
COPY_?256:0);if((_in===0&&_out===0||flush===Z_FINISH)&&ret===Z_OK)ret=Z_BUF_ERROR;return ret}function inflateEnd(strm){if(!strm||!strm.state)return Z_STREAM_ERROR;var state=strm.state;if(state.window)state.window=null;strm.state=null;return Z_OK}function inflateGetHeader(strm,head){var state;if(!strm||!strm.state)return Z_STREAM_ERROR;state=strm.state;if((state.wrap&2)===0)return Z_STREAM_ERROR;state.head=head;head.done=false;return Z_OK}exports.inflateReset=inflateReset;exports.inflateReset2=inflateReset2;
exports.inflateResetKeep=inflateResetKeep;exports.inflateInit=inflateInit;exports.inflateInit2=inflateInit2;exports.inflate=inflate;exports.inflateEnd=inflateEnd;exports.inflateGetHeader=inflateGetHeader;exports.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":27,"./adler32":29,"./crc32":31,"./inffast":34,"./inftrees":36}],36:[function(_dereq_,module,exports){var utils=_dereq_("../utils/common");var MAXBITS=15;var ENOUGH_LENS=852;var ENOUGH_DISTS=592;var CODES=0;var LENS=1;var DISTS=
2;var lbase=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0];var lext=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78];var dbase=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0];var dext=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];module.exports=function inflate_table(type,lens,lens_index,
codes,table,table_index,work,opts){var bits=opts.bits;var len=0;var sym=0;var min=0,max=0;var root=0;var curr=0;var drop=0;var left=0;var used=0;var huff=0;var incr;var fill;var low;var mask;var next;var base=null;var base_index=0;var end;var count=new utils.Buf16(MAXBITS+1);var offs=new utils.Buf16(MAXBITS+1);var extra=null;var extra_index=0;var here_bits,here_op,here_val;for(len=0;len<=MAXBITS;len++)count[len]=0;for(sym=0;sym<codes;sym++)count[lens[lens_index+sym]]++;root=bits;for(max=MAXBITS;max>=
1;max--)if(count[max]!==0)break;if(root>max)root=max;if(max===0){table[table_index++]=1<<24|64<<16|0;table[table_index++]=1<<24|64<<16|0;opts.bits=1;return 0}for(min=1;min<max;min++)if(count[min]!==0)break;if(root<min)root=min;left=1;for(len=1;len<=MAXBITS;len++){left<<=1;left-=count[len];if(left<0)return-1}if(left>0&&(type===CODES||max!==1))return-1;offs[1]=0;for(len=1;len<MAXBITS;len++)offs[len+1]=offs[len]+count[len];for(sym=0;sym<codes;sym++)if(lens[lens_index+sym]!==0)work[offs[lens[lens_index+
sym]]++]=sym;if(type===CODES){base=extra=work;end=19}else if(type===LENS){base=lbase;base_index-=257;extra=lext;extra_index-=257;end=256}else{base=dbase;extra=dext;end=-1}huff=0;sym=0;len=min;next=table_index;curr=root;drop=0;low=-1;used=1<<root;mask=used-1;if(type===LENS&&used>ENOUGH_LENS||type===DISTS&&used>ENOUGH_DISTS)return 1;var i=0;for(;;){i++;here_bits=len-drop;if(work[sym]<end){here_op=0;here_val=work[sym]}else if(work[sym]>end){here_op=extra[extra_index+work[sym]];here_val=base[base_index+
work[sym]]}else{here_op=32+64;here_val=0}incr=1<<len-drop;fill=1<<curr;min=fill;do{fill-=incr;table[next+(huff>>drop)+fill]=here_bits<<24|here_op<<16|here_val|0}while(fill!==0);incr=1<<len-1;while(huff&incr)incr>>=1;if(incr!==0){huff&=incr-1;huff+=incr}else huff=0;sym++;if(--count[len]===0){if(len===max)break;len=lens[lens_index+work[sym]]}if(len>root&&(huff&mask)!==low){if(drop===0)drop=root;next+=min;curr=len-drop;left=1<<curr;while(curr+drop<max){left-=count[curr+drop];if(left<=0)break;curr++;
left<<=1}used+=1<<curr;if(type===LENS&&used>ENOUGH_LENS||type===DISTS&&used>ENOUGH_DISTS)return 1;low=huff&mask;table[low]=root<<24|curr<<16|next-table_index|0}}if(huff!==0)table[next+huff]=len-drop<<24|64<<16|0;opts.bits=root;return 0}},{"../utils/common":27}],37:[function(_dereq_,module,exports){module.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],38:[function(_dereq_,
module,exports){var utils=_dereq_("../utils/common");var Z_FIXED=4;var Z_BINARY=0;var Z_TEXT=1;var Z_UNKNOWN=2;function zero(buf){var len=buf.length;while(--len>=0)buf[len]=0}var STORED_BLOCK=0;var STATIC_TREES=1;var DYN_TREES=2;var MIN_MATCH=3;var MAX_MATCH=258;var LENGTH_CODES=29;var LITERALS=256;var L_CODES=LITERALS+1+LENGTH_CODES;var D_CODES=30;var BL_CODES=19;var HEAP_SIZE=2*L_CODES+1;var MAX_BITS=15;var Buf_size=16;var MAX_BL_BITS=7;var END_BLOCK=256;var REP_3_6=16;var REPZ_3_10=17;var REPZ_11_138=
18;var extra_lbits=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0];var extra_dbits=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];var extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];var bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];var DIST_CODE_LEN=512;var static_ltree=new Array((L_CODES+2)*2);zero(static_ltree);var static_dtree=new Array(D_CODES*2);zero(static_dtree);var _dist_code=new Array(DIST_CODE_LEN);zero(_dist_code);var _length_code=new Array(MAX_MATCH-
MIN_MATCH+1);zero(_length_code);var base_length=new Array(LENGTH_CODES);zero(base_length);var base_dist=new Array(D_CODES);zero(base_dist);var StaticTreeDesc=function(static_tree,extra_bits,extra_base,elems,max_length){this.static_tree=static_tree;this.extra_bits=extra_bits;this.extra_base=extra_base;this.elems=elems;this.max_length=max_length;this.has_stree=static_tree&&static_tree.length};var static_l_desc;var static_d_desc;var static_bl_desc;var TreeDesc=function(dyn_tree,stat_desc){this.dyn_tree=
dyn_tree;this.max_code=0;this.stat_desc=stat_desc};function d_code(dist){return dist<256?_dist_code[dist]:_dist_code[256+(dist>>>7)]}function put_short(s,w){s.pending_buf[s.pending++]=w&255;s.pending_buf[s.pending++]=w>>>8&255}function send_bits(s,value,length){if(s.bi_valid>Buf_size-length){s.bi_buf|=value<<s.bi_valid&65535;put_short(s,s.bi_buf);s.bi_buf=value>>Buf_size-s.bi_valid;s.bi_valid+=length-Buf_size}else{s.bi_buf|=value<<s.bi_valid&65535;s.bi_valid+=length}}function send_code(s,c,tree){send_bits(s,
tree[c*2],tree[c*2+1])}function bi_reverse(code,len){var res=0;do{res|=code&1;code>>>=1;res<<=1}while(--len>0);return res>>>1}function bi_flush(s){if(s.bi_valid===16){put_short(s,s.bi_buf);s.bi_buf=0;s.bi_valid=0}else if(s.bi_valid>=8){s.pending_buf[s.pending++]=s.bi_buf&255;s.bi_buf>>=8;s.bi_valid-=8}}function gen_bitlen(s,desc){var tree=desc.dyn_tree;var max_code=desc.max_code;var stree=desc.stat_desc.static_tree;var has_stree=desc.stat_desc.has_stree;var extra=desc.stat_desc.extra_bits;var base=
desc.stat_desc.extra_base;var max_length=desc.stat_desc.max_length;var h;var n,m;var bits;var xbits;var f;var overflow=0;for(bits=0;bits<=MAX_BITS;bits++)s.bl_count[bits]=0;tree[s.heap[s.heap_max]*2+1]=0;for(h=s.heap_max+1;h<HEAP_SIZE;h++){n=s.heap[h];bits=tree[tree[n*2+1]*2+1]+1;if(bits>max_length){bits=max_length;overflow++}tree[n*2+1]=bits;if(n>max_code)continue;s.bl_count[bits]++;xbits=0;if(n>=base)xbits=extra[n-base];f=tree[n*2];s.opt_len+=f*(bits+xbits);if(has_stree)s.static_len+=f*(stree[n*
2+1]+xbits)}if(overflow===0)return;do{bits=max_length-1;while(s.bl_count[bits]===0)bits--;s.bl_count[bits]--;s.bl_count[bits+1]+=2;s.bl_count[max_length]--;overflow-=2}while(overflow>0);for(bits=max_length;bits!==0;bits--){n=s.bl_count[bits];while(n!==0){m=s.heap[--h];if(m>max_code)continue;if(tree[m*2+1]!==bits){s.opt_len+=(bits-tree[m*2+1])*tree[m*2];tree[m*2+1]=bits}n--}}}function gen_codes(tree,max_code,bl_count){var next_code=new Array(MAX_BITS+1);var code=0;var bits;var n;for(bits=1;bits<=MAX_BITS;bits++)next_code[bits]=
code=code+bl_count[bits-1]<<1;for(n=0;n<=max_code;n++){var len=tree[n*2+1];if(len===0)continue;tree[n*2]=bi_reverse(next_code[len]++,len)}}function tr_static_init(){var n;var bits;var length;var code;var dist;var bl_count=new Array(MAX_BITS+1);length=0;for(code=0;code<LENGTH_CODES-1;code++){base_length[code]=length;for(n=0;n<1<<extra_lbits[code];n++)_length_code[length++]=code}_length_code[length-1]=code;dist=0;for(code=0;code<16;code++){base_dist[code]=dist;for(n=0;n<1<<extra_dbits[code];n++)_dist_code[dist++]=
code}dist>>=7;for(;code<D_CODES;code++){base_dist[code]=dist<<7;for(n=0;n<1<<extra_dbits[code]-7;n++)_dist_code[256+dist++]=code}for(bits=0;bits<=MAX_BITS;bits++)bl_count[bits]=0;n=0;while(n<=143){static_ltree[n*2+1]=8;n++;bl_count[8]++}while(n<=255){static_ltree[n*2+1]=9;n++;bl_count[9]++}while(n<=279){static_ltree[n*2+1]=7;n++;bl_count[7]++}while(n<=287){static_ltree[n*2+1]=8;n++;bl_count[8]++}gen_codes(static_ltree,L_CODES+1,bl_count);for(n=0;n<D_CODES;n++){static_dtree[n*2+1]=5;static_dtree[n*
2]=bi_reverse(n,5)}static_l_desc=new StaticTreeDesc(static_ltree,extra_lbits,LITERALS+1,L_CODES,MAX_BITS);static_d_desc=new StaticTreeDesc(static_dtree,extra_dbits,0,D_CODES,MAX_BITS);static_bl_desc=new StaticTreeDesc(new Array(0),extra_blbits,0,BL_CODES,MAX_BL_BITS)}function init_block(s){var n;for(n=0;n<L_CODES;n++)s.dyn_ltree[n*2]=0;for(n=0;n<D_CODES;n++)s.dyn_dtree[n*2]=0;for(n=0;n<BL_CODES;n++)s.bl_tree[n*2]=0;s.dyn_ltree[END_BLOCK*2]=1;s.opt_len=s.static_len=0;s.last_lit=s.matches=0}function bi_windup(s){if(s.bi_valid>
8)put_short(s,s.bi_buf);else if(s.bi_valid>0)s.pending_buf[s.pending++]=s.bi_buf;s.bi_buf=0;s.bi_valid=0}function copy_block(s,buf,len,header){bi_windup(s);if(header){put_short(s,len);put_short(s,~len)}utils.arraySet(s.pending_buf,s.window,buf,len,s.pending);s.pending+=len}function smaller(tree,n,m,depth){var _n2=n*2;var _m2=m*2;return tree[_n2]<tree[_m2]||tree[_n2]===tree[_m2]&&depth[n]<=depth[m]}function pqdownheap(s,tree,k){var v=s.heap[k];var j=k<<1;while(j<=s.heap_len){if(j<s.heap_len&&smaller(tree,
s.heap[j+1],s.heap[j],s.depth))j++;if(smaller(tree,v,s.heap[j],s.depth))break;s.heap[k]=s.heap[j];k=j;j<<=1}s.heap[k]=v}function compress_block(s,ltree,dtree){var dist;var lc;var lx=0;var code;var extra;if(s.last_lit!==0){do{dist=s.pending_buf[s.d_buf+lx*2]<<8|s.pending_buf[s.d_buf+lx*2+1];lc=s.pending_buf[s.l_buf+lx];lx++;if(dist===0)send_code(s,lc,ltree);else{code=_length_code[lc];send_code(s,code+LITERALS+1,ltree);extra=extra_lbits[code];if(extra!==0){lc-=base_length[code];send_bits(s,lc,extra)}dist--;
code=d_code(dist);send_code(s,code,dtree);extra=extra_dbits[code];if(extra!==0){dist-=base_dist[code];send_bits(s,dist,extra)}}}while(lx<s.last_lit)}send_code(s,END_BLOCK,ltree)}function build_tree(s,desc){var tree=desc.dyn_tree;var stree=desc.stat_desc.static_tree;var has_stree=desc.stat_desc.has_stree;var elems=desc.stat_desc.elems;var n,m;var max_code=-1;var node;s.heap_len=0;s.heap_max=HEAP_SIZE;for(n=0;n<elems;n++)if(tree[n*2]!==0){s.heap[++s.heap_len]=max_code=n;s.depth[n]=0}else tree[n*2+1]=
0;while(s.heap_len<2){node=s.heap[++s.heap_len]=max_code<2?++max_code:0;tree[node*2]=1;s.depth[node]=0;s.opt_len--;if(has_stree)s.static_len-=stree[node*2+1]}desc.max_code=max_code;for(n=s.heap_len>>1;n>=1;n--)pqdownheap(s,tree,n);node=elems;do{n=s.heap[1];s.heap[1]=s.heap[s.heap_len--];pqdownheap(s,tree,1);m=s.heap[1];s.heap[--s.heap_max]=n;s.heap[--s.heap_max]=m;tree[node*2]=tree[n*2]+tree[m*2];s.depth[node]=(s.depth[n]>=s.depth[m]?s.depth[n]:s.depth[m])+1;tree[n*2+1]=tree[m*2+1]=node;s.heap[1]=
node++;pqdownheap(s,tree,1)}while(s.heap_len>=2);s.heap[--s.heap_max]=s.heap[1];gen_bitlen(s,desc);gen_codes(tree,max_code,s.bl_count)}function scan_tree(s,tree,max_code){var n;var prevlen=-1;var curlen;var nextlen=tree[0*2+1];var count=0;var max_count=7;var min_count=4;if(nextlen===0){max_count=138;min_count=3}tree[(max_code+1)*2+1]=65535;for(n=0;n<=max_code;n++){curlen=nextlen;nextlen=tree[(n+1)*2+1];if(++count<max_count&&curlen===nextlen)continue;else if(count<min_count)s.bl_tree[curlen*2]+=count;
else if(curlen!==0){if(curlen!==prevlen)s.bl_tree[curlen*2]++;s.bl_tree[REP_3_6*2]++}else if(count<=10)s.bl_tree[REPZ_3_10*2]++;else s.bl_tree[REPZ_11_138*2]++;count=0;prevlen=curlen;if(nextlen===0){max_count=138;min_count=3}else if(curlen===nextlen){max_count=6;min_count=3}else{max_count=7;min_count=4}}}function send_tree(s,tree,max_code){var n;var prevlen=-1;var curlen;var nextlen=tree[0*2+1];var count=0;var max_count=7;var min_count=4;if(nextlen===0){max_count=138;min_count=3}for(n=0;n<=max_code;n++){curlen=
nextlen;nextlen=tree[(n+1)*2+1];if(++count<max_count&&curlen===nextlen)continue;else if(count<min_count){do send_code(s,curlen,s.bl_tree);while(--count!==0)}else if(curlen!==0){if(curlen!==prevlen){send_code(s,curlen,s.bl_tree);count--}send_code(s,REP_3_6,s.bl_tree);send_bits(s,count-3,2)}else if(count<=10){send_code(s,REPZ_3_10,s.bl_tree);send_bits(s,count-3,3)}else{send_code(s,REPZ_11_138,s.bl_tree);send_bits(s,count-11,7)}count=0;prevlen=curlen;if(nextlen===0){max_count=138;min_count=3}else if(curlen===
nextlen){max_count=6;min_count=3}else{max_count=7;min_count=4}}}function build_bl_tree(s){var max_blindex;scan_tree(s,s.dyn_ltree,s.l_desc.max_code);scan_tree(s,s.dyn_dtree,s.d_desc.max_code);build_tree(s,s.bl_desc);for(max_blindex=BL_CODES-1;max_blindex>=3;max_blindex--)if(s.bl_tree[bl_order[max_blindex]*2+1]!==0)break;s.opt_len+=3*(max_blindex+1)+5+5+4;return max_blindex}function send_all_trees(s,lcodes,dcodes,blcodes){var rank;send_bits(s,lcodes-257,5);send_bits(s,dcodes-1,5);send_bits(s,blcodes-
4,4);for(rank=0;rank<blcodes;rank++)send_bits(s,s.bl_tree[bl_order[rank]*2+1],3);send_tree(s,s.dyn_ltree,lcodes-1);send_tree(s,s.dyn_dtree,dcodes-1)}function detect_data_type(s){var black_mask=4093624447;var n;for(n=0;n<=31;n++,black_mask>>>=1)if(black_mask&1&&s.dyn_ltree[n*2]!==0)return Z_BINARY;if(s.dyn_ltree[9*2]!==0||s.dyn_ltree[10*2]!==0||s.dyn_ltree[13*2]!==0)return Z_TEXT;for(n=32;n<LITERALS;n++)if(s.dyn_ltree[n*2]!==0)return Z_TEXT;return Z_BINARY}var static_init_done=false;function _tr_init(s){if(!static_init_done){tr_static_init();
static_init_done=true}s.l_desc=new TreeDesc(s.dyn_ltree,static_l_desc);s.d_desc=new TreeDesc(s.dyn_dtree,static_d_desc);s.bl_desc=new TreeDesc(s.bl_tree,static_bl_desc);s.bi_buf=0;s.bi_valid=0;init_block(s)}function _tr_stored_block(s,buf,stored_len,last){send_bits(s,(STORED_BLOCK<<1)+(last?1:0),3);copy_block(s,buf,stored_len,true)}function _tr_align(s){send_bits(s,STATIC_TREES<<1,3);send_code(s,END_BLOCK,static_ltree);bi_flush(s)}function _tr_flush_block(s,buf,stored_len,last){var opt_lenb,static_lenb;
var max_blindex=0;if(s.level>0){if(s.strm.data_type===Z_UNKNOWN)s.strm.data_type=detect_data_type(s);build_tree(s,s.l_desc);build_tree(s,s.d_desc);max_blindex=build_bl_tree(s);opt_lenb=s.opt_len+3+7>>>3;static_lenb=s.static_len+3+7>>>3;if(static_lenb<=opt_lenb)opt_lenb=static_lenb}else opt_lenb=static_lenb=stored_len+5;if(stored_len+4<=opt_lenb&&buf!==-1)_tr_stored_block(s,buf,stored_len,last);else if(s.strategy===Z_FIXED||static_lenb===opt_lenb){send_bits(s,(STATIC_TREES<<1)+(last?1:0),3);compress_block(s,
static_ltree,static_dtree)}else{send_bits(s,(DYN_TREES<<1)+(last?1:0),3);send_all_trees(s,s.l_desc.max_code+1,s.d_desc.max_code+1,max_blindex+1);compress_block(s,s.dyn_ltree,s.dyn_dtree)}init_block(s);if(last)bi_windup(s)}function _tr_tally(s,dist,lc){s.pending_buf[s.d_buf+s.last_lit*2]=dist>>>8&255;s.pending_buf[s.d_buf+s.last_lit*2+1]=dist&255;s.pending_buf[s.l_buf+s.last_lit]=lc&255;s.last_lit++;if(dist===0)s.dyn_ltree[lc*2]++;else{s.matches++;dist--;s.dyn_ltree[(_length_code[lc]+LITERALS+1)*2]++;
s.dyn_dtree[d_code(dist)*2]++}return s.last_lit===s.lit_bufsize-1}exports._tr_init=_tr_init;exports._tr_stored_block=_tr_stored_block;exports._tr_flush_block=_tr_flush_block;exports._tr_tally=_tr_tally;exports._tr_align=_tr_align},{"../utils/common":27}],39:[function(_dereq_,module,exports){function ZStream(){this.input=null;this.next_in=0;this.avail_in=0;this.total_in=0;this.output=null;this.next_out=0;this.avail_out=0;this.total_out=0;this.msg="";this.state=null;this.data_type=2;this.adler=0}module.exports=
ZStream},{}]},{},[9])(9)});
/*
 * grommunio addition: expand repeated table elements for display.
 *
 * ODF collapses runs of identical columns, rows and cells into a single
 * element carrying table:number-columns/rows-repeated. WebODF renders the
 * ODF DOM directly through CSS tables, where such an element occupies one
 * grid slot, so everything after a collapsed run shifts. Expand the runs
 * into real clones, bounded like the xlsx preview; filler runs behind the
 * last cell with content stay collapsed.
 */
(function () {
    "use strict";
    var tablens = "urn:oasis:names:tc:opendocument:xmlns:table:1.0",
        officens = "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
        drawns = "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0",
        helperns = "urn:webodf:names:helper",
        MAX_COLS = 256,
        MAX_ROWS = 5000,
        MAX_CELLS = 200000;

    function isTableElement(node, name) {
        return node.namespaceURI === tablens && node.localName === name;
    }

    function isCell(node) {
        return node.namespaceURI === tablens &&
            ("table-cell" === node.localName || "covered-table-cell" === node.localName);
    }

    function repeatCount(element, name) {
        var value = element.getAttributeNS(tablens, name),
            count = value ? parseInt(value, 10) : 1;
        return (isNaN(count) || count < 1) ? 1 : count;
    }

    // Expand a run into `allowed` singular clones; any remainder stays
    // collapsed in one trailing element, so the rendered width of a capped
    // run does not depend on how the producer fragmented it.
    function expand(element, name, total, allowed) {
        var parent = element.parentNode,
            clone,
            i,
            added = 0;
        if (total > allowed) {
            clone = element.cloneNode(true);
            clone.setAttributeNS(tablens, "table:" + name, String(total - allowed));
            parent.insertBefore(clone, element.nextSibling);
            added += 1;
        }
        element.removeAttributeNS(tablens, name);
        for (i = 1; i < allowed; i += 1) {
            parent.insertBefore(element.cloneNode(true), element.nextSibling);
            added += 1;
        }
        return added;
    }

    // matching descendants in document order, nested tables excluded
    function gather(root, match) {
        var list = [];
        (function walk(node) {
            var child = node.firstElementChild;
            while (child) {
                if (!isTableElement(child, "table")) {
                    if (match(child)) {
                        list.push(child);
                    }
                    walk(child);
                }
                child = child.nextElementSibling;
            }
        }(root));
        return list;
    }

    // Cells with a style, text or drawing content matter for the layout;
    // padding cells holding only empty paragraphs do not.
    function isSignificant(cell) {
        return cell.hasAttributeNS(tablens, "style-name") ||
            /\S/.test(cell.textContent) ||
            cell.getElementsByTagNameNS(drawns, "*").length > 0;
    }

    function isSpreadsheetTable(table) {
        var node = table.parentNode;
        while (node && node.nodeType === 1) {
            if (node.namespaceURI === officens && node.localName === "spreadsheet") {
                return true;
            }
            node = node.parentNode;
        }
        return false;
    }

    function expandTable(table, budget) {
        var rows = gather(table, function (node) {
                return isTableElement(node, "table-row");
            }),
            columns = gather(table, function (node) {
                return isTableElement(node, "table-column");
            }),
            lastContentRow = -1,
            usedColumns = 1,
            hasGutter = false,
            columnBound,
            position,
            allowed,
            count,
            gutter,
            i;

        rows.forEach(function (row, index) {
            var width = 0,
                end = 0;
            Array.prototype.forEach.call(row.children, function (cell) {
                if (!isCell(cell)) {
                    return;
                }
                end += repeatCount(cell, "number-columns-repeated");
                if (isSignificant(cell)) {
                    width = end;
                }
            });
            if (width > 0) {
                lastContentRow = index;
                if (width > usedColumns) {
                    usedColumns = width;
                }
            }
        });
        if (usedColumns > MAX_COLS) {
            usedColumns = MAX_COLS;
        }

        rows.forEach(function (row, index) {
            var cells,
                last = -1,
                pos = 0,
                j;
            if (index > lastContentRow) {
                return;
            }
            cells = Array.prototype.filter.call(row.children, isCell);
            cells.forEach(function (cell, k) {
                if (isSignificant(cell)) {
                    last = k;
                }
            });
            for (j = 0; j <= last; j += 1) {
                count = repeatCount(cells[j], "number-columns-repeated");
                if (count > 1) {
                    allowed = Math.min(count, MAX_COLS - pos, budget.cells);
                    if (allowed >= 1) {
                        budget.cells -=
                            expand(cells[j], "number-columns-repeated", count, allowed);
                    }
                }
                pos += count;
            }
        });

        position = 0;
        for (i = 0; i <= lastContentRow; i += 1) {
            count = repeatCount(rows[i], "number-rows-repeated");
            if (count > 1) {
                allowed = Math.min(count, MAX_ROWS - position,
                    Math.floor(budget.cells / Math.max(1, rows[i].children.length)));
                if (allowed >= 1) {
                    budget.cells -= expand(rows[i], "number-rows-repeated", count, allowed) *
                        rows[i].children.length;
                }
            }
            position += count;
        }

        // WebODF's CSS prepends a row-number gutter cell to spreadsheet rows,
        // which consumes the first table-column box; prepend a definition for
        // it so the declared widths land on the right columns.
        if (columns.length && isSpreadsheetTable(table)) {
            if (columns[0].hasAttributeNS(helperns, "gutter")) {
                hasGutter = true;
            } else {
                gutter = table.ownerDocument.createElementNS(tablens, "table:table-column");
                gutter.setAttributeNS(helperns, "helper:gutter", "1");
                columns[0].parentNode.insertBefore(gutter, columns[0]);
                columns.unshift(gutter);
                hasGutter = true;
            }
        }
        columnBound = usedColumns + (hasGutter ? 1 : 0);
        position = 0;
        columns.forEach(function (column) {
            count = repeatCount(column, "number-columns-repeated");
            if (count > 1 && position < columnBound) {
                expand(column, "number-columns-repeated",
                    count, Math.min(count, columnBound - position));
            }
            position += count;
        });
    }

    // WebODF's CSS has no display rules for covered cells or the column
    // group wrappers; as inline elements a run of covered cells collapses
    // into one anonymous cell and wrapped column definitions size nothing.
    function ensureCss(doc) {
        var style;
        if (!doc.head || doc.getElementById("grommunioOdfRepeatCss")) {
            return;
        }
        style = doc.createElement("style");
        style.id = "grommunioOdfRepeatCss";
        style.setAttribute("type", "text/css");
        style.appendChild(doc.createTextNode(
            "@namespace grmtable url(\"" + tablens + "\");\n" +
            "grmtable|covered-table-cell { display: table-cell; }\n" +
            "grmtable|table-columns, grmtable|table-header-columns" +
            " { display: table-column-group; }\n"
        ));
        doc.head.appendChild(style);
    }

    function expandRepeatedElements(container) {
        var root = container.rootElement,
            budget = { cells: MAX_CELLS },
            body,
            tables;
        if (container.state !== odf.OdfContainer.DONE || !root) {
            return;
        }
        body = root.body || root.getElementsByTagNameNS(officens, "body")[0];
        if (!body) {
            return;
        }
        ensureCss(body.ownerDocument);
        // nested tables first, so row clones carry expanded copies
        tables = Array.prototype.slice.call(
            body.getElementsByTagNameNS(tablens, "table")
        ).reverse();
        tables.forEach(function (table) {
            expandTable(table, budget);
        });
    }

    var OdfCanvasOriginal = odf.OdfCanvas;
    odf.OdfCanvas = function (element, viewport) {
        OdfCanvasOriginal.apply(this, arguments);
        // runs before the listeners of the embedding page
        this.addListener("statereadychange", function (container) {
            try {
                expandRepeatedElements(container);
            } catch (e) {
                runtime.log("Expanding repeated table elements failed: " + e.message);
            }
        });
    };
}());
