/* This is a generated file. DO NOT EDIT. Copyright (C) 2010-2015 KO GmbH @licstart The code in this file 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. The code in this file 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 . As additional permission under GNU AGPL version 3 section 7, you may distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU AGPL normally required by section 4, provided you include this license notice and a URL through which recipients can access the Corresponding Source. As a special exception to the AGPL, any HTML file which merely makes function calls to this code, and for that purpose includes it in unmodified form by reference or in-line shall be deemed a separate work for copyright law purposes. In addition, the copyright holders of this code give you permission to combine this code with free software libraries that are released under the GNU LGPL. You may copy and distribute such a system following the terms of the GNU AGPL for this code and the LGPL for the libraries. If you modify this code, you may extend this exception to your version of the code, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. This license applies to this entire compilation. @licend @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ var webodf_version="0.5.7";function Runtime(){}Runtime.prototype.getVariable=function(f){};Runtime.prototype.toJson=function(f){};Runtime.prototype.fromJson=function(f){};Runtime.prototype.byteArrayFromString=function(f,l){};Runtime.prototype.byteArrayToString=function(f,l){};Runtime.prototype.read=function(f,l,a,c){};Runtime.prototype.readFile=function(f,l,a){};Runtime.prototype.readFileSync=function(f,l){};Runtime.prototype.loadXML=function(f,l){};Runtime.prototype.writeFile=function(f,l,a){}; Runtime.prototype.deleteFile=function(f,l){};Runtime.prototype.log=function(f,l){};Runtime.prototype.setTimeout=function(f,l){};Runtime.prototype.clearTimeout=function(f){};Runtime.prototype.libraryPaths=function(){};Runtime.prototype.currentDirectory=function(){};Runtime.prototype.setCurrentDirectory=function(f){};Runtime.prototype.type=function(){};Runtime.prototype.getDOMImplementation=function(){};Runtime.prototype.parseXML=function(f){};Runtime.prototype.exit=function(f){}; Runtime.prototype.getWindow=function(){};Runtime.prototype.requestAnimationFrame=function(f){};Runtime.prototype.cancelAnimationFrame=function(f){};Runtime.prototype.assert=function(f,l){};var IS_COMPILED_CODE=!0; Runtime.byteArrayToString=function(f,l){function a(a){var c="",b,n=a.length;for(b=0;bh?g.push(h):(b+=1,d=a[b],194<=h&&224>h?g.push((h&31)<<6|d&63):(b+=1,e=a[b],224<=h&&240>h?g.push((h&15)<<12|(d&63)<<6|e&63):(b+=1,s=a[b],240<=h&&245>h&&(h=(h&7)<<18|(d&63)<<12|(e&63)<<6|s&63,h-=65536,g.push((h>>10)+55296,(h&1023)+56320))))),1E3<=g.length&& (c+=String.fromCharCode.apply(null,g),g.length=0);return c+String.fromCharCode.apply(null,g)}var b;"utf8"===l?b=c(f):("binary"!==l&&this.log("Unsupported encoding: "+l),b=a(f));return b};Runtime.getVariable=function(f){try{return eval(f)}catch(l){}};Runtime.toJson=function(f){return JSON.stringify(f)};Runtime.fromJson=function(f){return JSON.parse(f)};Runtime.getFunctionName=function(f){return void 0===f.name?(f=/function\s+(\w+)/.exec(f))&&f[1]:f.name}; Runtime.assert=function(f,l){if(!f)throw this.log("alert","ASSERTION FAILED:\n"+l),Error(l);}; function BrowserRuntime(){function f(a){var g=a.length,h,d,e=0;for(h=0;hd&&(e+=1,h+=1);return e}function l(a,g,h){var d=a.length,e,s;g=new Uint8Array(new ArrayBuffer(g));h?(g[0]=239,g[1]=187,g[2]=191,s=3):s=0;for(h=0;he?(g[s]=e,s+=1):2048>e?(g[s]=192|e>>>6,g[s+1]=128|e&63,s+=2):55040>=e||57344<=e?(g[s]=224|e>>>12&15,g[s+1]=128|e>>>6&63,g[s+2]=128|e&63,s+=3):(h+=1,e=(e-55296<<10|a.charCodeAt(h)-56320)+65536, g[s]=240|e>>>18&7,g[s+1]=128|e>>>12&63,g[s+2]=128|e>>>6&63,g[s+3]=128|e&63,s+=4);return g}function a(a){var g=a.length,h=new Uint8Array(new ArrayBuffer(g)),d;for(d=0;dd.status||0===d.status?h(null):h("Status "+String(d.status)+": "+d.responseText||d.statusText):h("File "+c+" is empty."))};e=a.buffer&&!d.sendAsBinary?a.buffer:p.byteArrayToString(a,"binary");try{d.sendAsBinary?d.sendAsBinary(e):d.send(e)}catch(s){p.log("HUH? "+ s+" "+a),h(s.message)}};this.deleteFile=function(c,a){var h=new XMLHttpRequest;h.open("DELETE",c,!0);h.onreadystatechange=function(){4===h.readyState&&(200>h.status&&300<=h.status?a(h.responseText):a(null))};h.send(null)};this.loadXML=function(c,a){var h=new XMLHttpRequest;h.open("GET",c,!0);h.overrideMimeType&&h.overrideMimeType("text/xml");h.onreadystatechange=function(){4===h.readyState&&(0!==h.status||h.responseText?200===h.status||0===h.status?a(null,h.responseXML):a(h.responseText,null):a("File "+ c+" is empty.",null))};try{h.send(null)}catch(d){a(d.message,null)}};this.log=c;this.enableAlerts=!0;this.assert=Runtime.assert;this.setTimeout=function(a,c){return setTimeout(function(){a()},c)};this.clearTimeout=function(a){clearTimeout(a)};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(a){return(new DOMParser).parseFromString(a,"text/xml")};this.exit=function(a){c("Calling exit with code "+String(a)+", but exit() is not implemented.")};this.getWindow=function(){return window};this.requestAnimationFrame=function(a){var c=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,h=0;if(c)c.bind(window),h=c(a);else return setTimeout(a,15);return h};this.cancelAnimationFrame=function(a){var c=window.cancelAnimationFrame|| window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame;c?(c.bind(window),c(a)):clearTimeout(a)}} function NodeJSRuntime(){function f(a){var c=a.length,h,d=new Uint8Array(new ArrayBuffer(c));for(h=0;h").implementation} function RhinoRuntime(){var f=this,l={},a=l.javax.xml.parsers.DocumentBuilderFactory.newInstance(),c,b,k="";a.setValidating(!1);a.setNamespaceAware(!0);a.setExpandEntityReferences(!1);a.setSchema(null);b=l.org.xml.sax.EntityResolver({resolveEntity:function(a,c){var b=new l.java.io.FileReader(c);return new l.org.xml.sax.InputSource(b)}});c=a.newDocumentBuilder();c.setEntityResolver(b);this.byteArrayFromString=function(a,c){var b,g=a.length,h=new Uint8Array(new ArrayBuffer(g));for(b=0;b>>18],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>12&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>6&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e& 63];a===s+1?(e=d[a]<<4,m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>6],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e&63],m+="=="):a===s&&(e=d[a]<<10|d[a+1]<<2,m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>12],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>6&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e&63],m+="=");return m}function a(e){e=e.replace(/[^A-Za-z0-9+\/]+/g, "");var d=e.length,a=new Uint8Array(new ArrayBuffer(3*d)),s=e.length%4,c=0,b,H;for(b=0;b>16,a[c+1]=H>>8&255,a[c+2]=H&255,c+=3;d=3*d-[0,0,2,1][s];return a.subarray(0,d)}function c(e){var d,m,a=e.length,s=0,c=new Uint8Array(new ArrayBuffer(3*a));for(d=0;dm?c[s++]=m:(2048>m?c[s++]=192|m>>>6:(c[s++]=224|m>>>12&15,c[s++]=128|m>>>6&63),c[s++]=128|m&63);return c.subarray(0, s)}function b(e){var d,m,a,s,c=e.length,H=new Uint8Array(new ArrayBuffer(c)),b=0;for(d=0;dm?H[b++]=m:(d+=1,a=e[d],224>m?H[b++]=(m&31)<<6|a&63:(d+=1,s=e[d],H[b++]=(m&15)<<12|(a&63)<<6|s&63));return H.subarray(0,b)}function k(d){return l(f(d))}function q(d){return String.fromCharCode.apply(String,a(d))}function p(d){return b(f(d))}function n(d){d=b(d);for(var e="",m=0;me?H+=String.fromCharCode(e):(c+=1,a=d.charCodeAt(c)&255,224>e?H+=String.fromCharCode((e&31)<<6|a&63):(c+=1,s=d.charCodeAt(c)&255,H+=String.fromCharCode((e&15)<<12|(a&63)<<6|s&63)));return H}function h(d,e){function m(){var c=s+1E5;c>d.length&&(c=d.length);a+=g(d,s,c);s=c;c=s===d.length;e(a,c)&&!c&&runtime.setTimeout(m,0)}var a="",s=0;1E5>d.length?e(g(d,0,d.length),!0):("string"!==typeof d&&(d=d.slice()),m())}function d(d){return c(f(d))}function e(d){return String.fromCharCode.apply(String, c(d))}function s(d){return String.fromCharCode.apply(String,c(f(d)))}var m=function(d){var e={},m,a;m=0;for(a=d.length;mb-c&&(b=Math.max(2*b,c+a),a=new Uint8Array(new ArrayBuffer(b)),a.set(k),k=a)}var a=this,c=0,b=1024,k=new Uint8Array(new ArrayBuffer(b));this.appendByteArrayWriter=function(c){a.appendByteArray(c.getByteArray())};this.appendByteArray=function(a){var b=a.length;l(b);k.set(a,c);c+=b};this.appendArray=function(a){var b=a.length;l(b);k.set(a,c);c+=b};this.appendUInt16LE=function(c){a.appendArray([c&255,c>>8&255])};this.appendUInt32LE=function(c){a.appendArray([c& 255,c>>8&255,c>>16&255,c>>24&255])};this.appendString=function(c){a.appendByteArray(runtime.byteArrayFromString(c,f))};this.getLength=function(){return c};this.getByteArray=function(){var a=new Uint8Array(new ArrayBuffer(c));a.set(k.subarray(0,c));return a}};core.CSSUnits=function(){var f=this,l={"in":1,cm:2.54,mm:25.4,pt:72,pc:12,px:96};this.convert=function(a,c,b){return a*l[b]/l[c]};this.convertMeasure=function(a,c){var b,k;a&&c&&(b=parseFloat(a),k=a.replace(b.toString(),""),b=f.convert(b,k,c));return b};this.getUnits=function(a){return a.substr(a.length-2,a.length)}};(function(){function f(){var c,b,k,f,p,l,g,h,d;void 0===a&&(b=(c=runtime.getWindow())&&c.document,l=b.documentElement,g=b.body,a={rangeBCRIgnoresElementBCR:!1,unscaledRangeClientRects:!1,elementBCRIgnoresBodyScroll:!1},b&&(f=b.createElement("div"),f.style.position="absolute",f.style.left="-99999px",f.style.transform="scale(2)",f.style["-webkit-transform"]="scale(2)",p=b.createElement("div"),f.appendChild(p),g.appendChild(f),c=b.createRange(),c.selectNode(p),a.rangeBCRIgnoresElementBCR=0===c.getClientRects().length, p.appendChild(b.createTextNode("Rect transform test")),b=p.getBoundingClientRect(),k=c.getBoundingClientRect(),a.unscaledRangeClientRects=2=d.compareBoundaryPoints(Range.START_TO_START,e)&&0<=d.compareBoundaryPoints(Range.END_TO_END,e)}function k(d,e){return 0>=d.compareBoundaryPoints(Range.END_TO_START,e)&&0<=d.compareBoundaryPoints(Range.START_TO_END,e)}function q(d,e){var a=null;d.nodeType===Node.TEXT_NODE&&(0===d.length?(d.parentNode.removeChild(d),e.nodeType===Node.TEXT_NODE&&(a=e)):(e.nodeType===Node.TEXT_NODE&&(d.appendData(e.data),e.parentNode.removeChild(e)),a=d));return a} function p(d){for(var e=d.parentNode;d.firstChild;)e.insertBefore(d.firstChild,d);e.removeChild(d);return e}function n(d,e){var a=d.parentNode,c=d.firstChild,b=e(d),h;if(b===NodeFilter.FILTER_SKIP)return a;for(;c;)h=c.nextSibling,n(c,e),c=h;a&&b===NodeFilter.FILTER_REJECT&&p(d);return a}function g(d,e){return d===e||Boolean(d.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_CONTAINED_BY)}function h(d,e){return f().unscaledRangeClientRects?d:d/e}function d(e,m,a){Object.keys(m).forEach(function(c){var b= c.split(":"),h=b[1],g=a(b[0]),b=m[c],k=typeof b;"object"===k?Object.keys(b).length&&(c=g?e.getElementsByTagNameNS(g,h)[0]||e.ownerDocument.createElementNS(g,c):e.getElementsByTagName(h)[0]||e.ownerDocument.createElement(c),e.appendChild(c),d(c,b,a)):g&&(runtime.assert("number"===k||"string"===k,"attempting to map unsupported type '"+k+"' (key: "+c+")"),e.setAttributeNS(g,c,String(b)))})}var e=null;this.splitBoundaries=function(d){var e,b=[],h,g,k;if(d.startContainer.nodeType===Node.TEXT_NODE||d.endContainer.nodeType=== Node.TEXT_NODE){h=d.endContainer;g=d.endContainer.nodeType!==Node.TEXT_NODE?d.endOffset===d.endContainer.childNodes.length:!1;k=d.endOffset;e=d.endContainer;if(kf))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0l))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}};core.NodeFilterChain=function(f){var l=NodeFilter.FILTER_REJECT,a=NodeFilter.FILTER_ACCEPT;this.acceptNode=function(c){var b;for(b=0;b "+e.length),runtime.assert(0<=a,"Error in setPosition: "+a+" < 0"),a===e.length&&(h.nextSibling()?d=0:h.parentNode()?d=1:runtime.assert(!1,"Error in setUnfilteredPosition: position not valid."))):ac.windowBits&&(c.windowBits=-c.windowBits,0===c.windowBits&&(c.windowBits=-15));!(0<=c.windowBits&&16>c.windowBits)||a&&a.windowBits||(c.windowBits+=32);15c.windowBits&&0===(c.windowBits&15)&&(c.windowBits|=15);this.err=0;this.msg="";this.ended=!1;this.chunks= [];this.strm=new d;this.strm.avail_out=0;a=f.inflateInit2(this.strm,c.windowBits);if(a!==g.Z_OK)throw Error(h[a]);this.header=new e;f.inflateGetHeader(this.strm,this.header)};s.prototype.push=function(d,e){var a=this.strm,c=this.options.chunkSize,b,h,s,k,A;if(this.ended)return!1;h=e===~~e?e:!0===e?g.Z_FINISH:g.Z_NO_FLUSH;a.input="string"===typeof d?n.binstring2buf(d):d;a.next_in=0;a.avail_in=a.input.length;do{0===a.avail_out&&(a.output=new p.Buf8(c),a.next_out=0,a.avail_out=c);b=f.inflate(a,g.Z_NO_FLUSH); if(b!==g.Z_STREAM_END&&b!==g.Z_OK)return this.onEnd(b),this.ended=!0,!1;if(a.next_out&&(0===a.avail_out||b===g.Z_STREAM_END||0===a.avail_in&&h===g.Z_FINISH))if("string"===this.options.to)s=n.utf8border(a.output,a.next_out),k=a.next_out-s,A=n.buf2string(a.output,s),a.next_out=k,a.avail_out=c-k,k&&p.arraySet(a.output,a.output,s,k,0),this.onData(A);else this.onData(p.shrinkBuf(a.output,a.next_out))}while((0a&&(d.subarray&&n||!d.subarray&&p))return String.fromCharCode.apply(null,f.shrinkBuf(d,a));for(var c="",b=0;ba;a++)d[a]=252<=a?6:248<= a?5:240<=a?4:224<=a?3:192<=a?2:1;d[254]=d[254]=1;b.string2buf=function(d){var a,c,b,h,k,g=d.length,p=0;for(h=0;hc?1:2048>c?2:65536>c?3:4;a=new f.Buf8(p);for(h=k=0;kc?a[k++]=c:(2048>c?a[k++]=192|c>>>6:(65536>c?a[k++]=224|c>>>12:(a[k++]= 240|c>>>18,a[k++]=128|c>>>12&63),a[k++]=128|c>>>6&63),a[k++]=128|c&63);return a};b.buf2binstring=function(d){return k(d,d.length)};b.binstring2buf=function(d){for(var a=new f.Buf8(d.length),c=0,b=a.length;cg)q[h++]=g;else if(f=d[g],4g?q[h++]=g:(g-=65536,q[h++]= 55296|g>>10&1023,q[h++]=56320|g&1023)}return k(q,h)};b.utf8border=function(a,c){var b;c=c||a.length;c>a.length&&(c=a.length);for(b=c-1;0<=b&&128===(a[b]&192);)b--;return 0>b||0===b?c:b+d[a[b]]>c?b:c}},{"./common":2}],4:[function(a,c,b){c.exports=function(a,c,b,f){var g=a&65535|0;a=a>>>16&65535|0;for(var h=0;0!==b;){h=2E3b;b++){a=b;for(var k=0;8>k;k++)a=a&1?3988292384^a>>>1:a>>>1;c[b]=a}return c}();c.exports=function(a,c,b,g){b=g+b;for(a^= -1;g>>8^k[(a^c[g])&255];return a^-1}},{}],7:[function(a,c,b){c.exports=function(){this.os=this.xflags=this.time=this.text=0;this.extra=null;this.extra_len=0;this.comment=this.name="";this.hcrc=0;this.done=!1}},{}],8:[function(a,c,b){c.exports=function(a,c){var b,f,g,h,d,e,s,m,x,t,y,v,r,w,u,A,F,B,E,H,I,Q,N,z;b=a.state;f=a.next_in;N=a.input;g=f+(a.avail_in-5);h=a.next_out;z=a.output;d=h-(c-a.avail_out);e=h+(a.avail_out-257);s=b.dmax;m=b.wsize;x=b.whave;t=b.wnext;y=b.window;v=b.hold;r=b.bits; w=b.lencode;u=b.distcode;A=(1<r&&(v+=N[f++]<>>24;v>>>=E;r-=E;E=B>>>16&255;if(0===E)z[h++]=B&65535;else if(E&16){H=B&65535;if(E&=15)r>>=E,r-=E;15>r&&(v+=N[f++]<>>24;v>>>=E;r-=E;E=B>>>16&255;if(E&16){B&=65535;E&=15;rs){a.msg="invalid distance too far back"; b.mode=30;break a}v>>>=E;r-=E;E=h-d;if(B>E){E=B-E;if(E>x&&b.sane){a.msg="invalid distance too far back";b.mode=30;break a}I=0;Q=y;if(0===t){if(I+=m-E,E>3;f-=H;r-=H<<3;a.next_in=f;a.next_out=h;a.avail_in=f>>24&255)+(d>>>8&65280)+((d&65280)<<8)+((d&255)<<24)}function f(){this.mode=0;this.last=!1;this.wrap=0;this.havedict=!1;this.total=this.check=this.dmax=this.flags=0;this.head=null;this.wnext=this.whave=this.wsize=this.wbits=0;this.window=null;this.extra=this.offset=this.length=this.bits=this.hold=0;this.distcode=this.lencode=null;this.have=this.ndist=this.nlen=this.ncode=this.distbits=this.lenbits=0;this.next=null;this.lens=new d.Buf16(320);this.work= new d.Buf16(288);this.distdyn=this.lendyn=null;this.was=this.back=this.sane=0}function p(a){var e;if(!a||!a.state)return y;e=a.state;a.total_in=a.total_out=e.total=0;a.msg="";e.wrap&&(a.adler=e.wrap&1);e.mode=v;e.last=0;e.havedict=0;e.dmax=32768;e.head=null;e.hold=0;e.bits=0;e.lencode=e.lendyn=new d.Buf32(r);e.distcode=e.distdyn=new d.Buf32(w);e.sane=1;e.back=-1;return t}function n(d){var a;if(!d||!d.state)return y;a=d.state;a.wsize=0;a.whave=0;a.wnext=0;return p(d)}function g(d,a){var e,c;if(!d|| !d.state)return y;c=d.state;0>a?(e=0,a=-a):(e=(a>>4)+1,48>a&&(a&=15));if(a&&(8>a||15r;){if(0===p)break a;p--;n+=h[g++]<>>8&255;b.check=s(b.check,W,2,0);r=n=0;b.mode=2;break}b.flags=0;b.head&&(b.head.done=!1);if(!(b.wrap&1)||(((n&255)<<8)+(n>>8))%31){a.msg="incorrect header check";b.mode=30;break}if(8!==(n&15)){a.msg="unknown compression method";b.mode=30;break}n>>>=4;r-=4;O=(n&15)+8;if(0===b.wbits)b.wbits=O;else if(O>b.wbits){a.msg="invalid window size";b.mode=30;break}b.dmax=1<r;){if(0===p)break a;p--;n+=h[g++]<>8&1);b.flags&512&&(W[0]=n&255,W[1]=n>>>8&255,b.check=s(b.check,W,2,0));r=n=0;b.mode=3;case 3:for(;32>r;){if(0===p)break a;p--;n+=h[g++]<>>8&255,W[2]=n>>>16&255,W[3]=n>>>24&255,b.check=s(b.check,W,4,0));r=n=0;b.mode=4;case 4:for(;16>r;){if(0===p)break a;p--;n+=h[g++]<>8);b.flags&512&&(W[0]=n&255,W[1]=n>>>8&255,b.check=s(b.check,W,2,0));r=n=0;b.mode=5;case 5:if(b.flags&1024){for(;16>r;){if(0===p)break a;p--;n+=h[g++]<>>8&255,b.check=s(b.check,W,2,0));r=n=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(b.flags&1024&&(D=b.length,D>p&&(D=p),D&&(b.head&&(O=b.head.extra_len-b.length,b.head.extra||(b.head.extra=Array(b.head.extra_len)),d.arraySet(b.head.extra, h,g,D,O)),b.flags&512&&(b.check=s(b.check,h,D,g)),p-=D,g+=D,b.length-=D),b.length))break a;b.length=0;b.mode=7;case 7:if(b.flags&2048){if(0===p)break a;D=0;do O=h[g+D++],b.head&&O&&65536>b.length&&(b.head.name+=String.fromCharCode(O));while(O&&Db.length&&(b.head.comment+=String.fromCharCode(O));while(O&&D< p);b.flags&512&&(b.check=s(b.check,h,D,g));p-=D;g+=D;if(O)break a}else b.head&&(b.head.comment=null);b.mode=9;case 9:if(b.flags&512){for(;16>r;){if(0===p)break a;p--;n+=h[g++]<>9&1,b.head.done=!0);a.adler=b.check=0;b.mode=12;break;case 10:for(;32>r;){if(0===p)break a;p--;n+=h[g++]<>>=r&7;r-=r&7;b.mode=27;break}for(;3>r;){if(0===p)break a;p--;n+=h[g++]<>>=1;r-=1;switch(n&3){case 0:b.mode=14;break;case 1:D=b;if(u){O=void 0;A=new d.Buf32(512);F=new d.Buf32(32);for(O=0;144>O;)D.lens[O++]=8;for(;256>O;)D.lens[O++]=9;for(;280>O;)D.lens[O++]=7;for(;288>O;)D.lens[O++]=8;x(1,D.lens,0,288,A,0,D.work,{bits:9});for(O=0;32>O;)D.lens[O++]=5;x(2,D.lens, 0,32,F,0,D.work,{bits:5});u=!1}D.lencode=A;D.lenbits=9;D.distcode=F;D.distbits=5;b.mode=20;if(6===c){n>>>=2;r-=2;break a}break;case 2:b.mode=17;break;case 3:a.msg="invalid block type",b.mode=30}n>>>=2;r-=2;break;case 14:n>>>=r&7;for(r-=r&7;32>r;){if(0===p)break a;p--;n+=h[g++]<>>16^65535)){a.msg="invalid stored block lengths";b.mode=30;break}b.length=n&65535;r=n=0;b.mode=15;if(6===c)break a;case 15:b.mode=16;case 16:if(D=b.length){D>p&&(D=p);D>q&&(D=q);if(0===D)break a;d.arraySet(f, h,g,D,z);p-=D;g+=D;q-=D;z+=D;b.length-=D;break}b.mode=12;break;case 17:for(;14>r;){if(0===p)break a;p--;n+=h[g++]<>>=5;r-=5;b.ndist=(n&31)+1;n>>>=5;r-=5;b.ncode=(n&15)+4;n>>>=4;r-=4;if(286r;){if(0===p)break a;p--;n+=h[g++]<>>=3;r-=3}for(;19>b.have;)b.lens[P[b.have++]]=0;b.lencode=b.lendyn;b.lenbits=7; D={bits:b.lenbits};U=x(0,b.lens,0,19,b.lencode,0,b.work,D);b.lenbits=D.bits;if(U){a.msg="invalid code lengths set";b.mode=30;break}b.have=0;b.mode=19;case 19:for(;b.have>>24;V=D>>>16&255;$=D&65535;if(C<=r)break;if(0===p)break a;p--;n+=h[g++]<$)n>>>=C,r-=C,b.lens[b.have++]=$;else{if(16===$){for(D=C+2;r>>=C;r-=C;if(0===b.have){a.msg="invalid bit length repeat";b.mode=30;break}O= b.lens[b.have-1];D=3+(n&3);n>>>=2;r-=2}else if(17===$){for(D=C+3;r>>=C;r-=C;O=0;D=3+(n&7);n>>>=3;r-=3}else{for(D=C+7;r>>=C;r-=C;O=0;D=11+(n&127);n>>>=7;r-=7}if(b.have+D>b.nlen+b.ndist){a.msg="invalid bit length repeat";b.mode=30;break}for(;D--;)b.lens[b.have++]=O}}if(30===b.mode)break;if(0===b.lens[256]){a.msg="invalid code -- missing end-of-block";b.mode=30;break}b.lenbits=9;D={bits:b.lenbits};U=x(1,b.lens, 0,b.nlen,b.lencode,0,b.work,D);b.lenbits=D.bits;if(U){a.msg="invalid literal/lengths set";b.mode=30;break}b.distbits=6;b.distcode=b.distdyn;D={bits:b.distbits};U=x(2,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,D);b.distbits=D.bits;if(U){a.msg="invalid distances set";b.mode=30;break}b.mode=20;if(6===c)break a;case 20:b.mode=21;case 21:if(6<=p&&258<=q){a.next_out=z;a.avail_out=q;a.next_in=g;a.avail_in=p;b.hold=n;b.bits=r;m(a,T);z=a.next_out;f=a.output;q=a.avail_out;g=a.next_in;h=a.input;p=a.avail_in; n=b.hold;r=b.bits;12===b.mode&&(b.back=-1);break}for(b.back=0;;){D=b.lencode[n&(1<>>24;V=D>>>16&255;$=D&65535;if(C<=r)break;if(0===p)break a;p--;n+=h[g++]<>O)];C=D>>>24;V=D>>>16&255;$=D&65535;if(O+C<=r)break;if(0===p)break a;p--;n+=h[g++]<>>=O;r-=O;b.back+=O}n>>>=C;r-=C;b.back+=C;b.length=$;if(0===V){b.mode=26;break}if(V&32){b.back=-1;b.mode=12;break}if(V&64){a.msg="invalid literal/length code"; b.mode=30;break}b.extra=V&15;b.mode=22;case 22:if(b.extra){for(D=b.extra;r>>=b.extra;r-=b.extra;b.back+=b.extra}b.was=b.length;b.mode=23;case 23:for(;;){D=b.distcode[n&(1<>>24;V=D>>>16&255;$=D&65535;if(C<=r)break;if(0===p)break a;p--;n+=h[g++]<>O)];C=D>>>24;V=D>>>16&255;$=D&65535;if(O+C<=r)break;if(0===p)break a;p--;n+=h[g++]<>>=O;r-=O;b.back+=O}n>>>=C;r-=C;b.back+=C;if(V&64){a.msg="invalid distance code";b.mode=30;break}b.offset=$;b.extra=V&15;b.mode=24;case 24:if(b.extra){for(D=b.extra;r>>=b.extra;r-=b.extra;b.back+=b.extra}if(b.offset>b.dmax){a.msg="invalid distance too far back";b.mode=30;break}b.mode=25;case 25:if(0===q)break a;D=T-q;if(b.offset>D){D=b.offset-D;if(D>b.whave&&b.sane){a.msg="invalid distance too far back";b.mode=30;break}D> b.wnext?(D-=b.wnext,O=b.wsize-D):O=b.wnext-D;D>b.length&&(D=b.length);Z=b.window}else Z=f,O=z-b.offset,D=b.length;D>q&&(D=q);q-=D;b.length-=D;do f[z++]=Z[O++];while(--D);0===b.length&&(b.mode=21);break;case 26:if(0===q)break a;f[z++]=b.length;q--;b.mode=21;break;case 27:if(b.wrap){for(;32>r;){if(0===p)break a;p--;n|=h[g++]<r;){if(0===p)break a;p--;n+=h[g++]<b.mode&&(27>b.mode||4!==c))h=a.output,g=a.next_out,z=T-a.avail_out,q=a.state,null===q.window&&(q.wsize=1<=q.wsize?(d.arraySet(q.window,h,g-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(p=q.wsize-q.wnext,p>z&&(p=z),d.arraySet(q.window,h,g-z,p,q.wnext),(z-=p)?(d.arraySet(q.window,h,g-z,z,0),q.wnext=z,q.whave=q.wsize):(q.wnext+=p,q.wnext===q.wsize&&(q.wnext=0),q.whave=r;r++)G[r]=0;for(w=0;wA&&(F=A);if(0===A)return m[x++]=20971520,m[x++]=20971520,y.bits=1,0;for(u=1;u=r;r++)if(H<<=1,H-=G[r],0>H)return-1;if(0r;r++)B[r+1]=B[r]+G[r];for(w=0;wJ?(O=ba[T+t[w]],Z=Y[R+t[w]]):(O=96,Z=0);H=1<>E)+N]=D<<24|O<<16|Z|0;while(0!==N);for(H=1<>=1;0!==H?(Q&=H-1,Q+=H):Q=0;w++;if(0===--G[r]){if(r===A)break;r=d[b+t[w]]}if(r>F&&(Q&c)!==z){0===E&&(E=F);v+=u;B=r-E;for(H=1<=H)break;B++;H<<=1}I+=1<>>8^h;return b^-1}function b(a){return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&15, a>>5&63,(a&31)<<1)}function k(a){var d=a.getFullYear();return 1980>d?0:d-1980<<25|a.getMonth()+1<<21|a.getDate()<<16|a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}function q(d,e){var c,h,m,g,s,f,k,p=this;this.load=function(b){if(null!==p.data)b(null,p.data);else{var e=s+34+h+m+256;e+k>t&&(e=t-k);a(k,e,function(a,e){if(a||null===e)b(a,e);else a:{var c=e,h=new core.ByteArray(c),m=h.readUInt32LE(),k;if(67324752!==m)b("File entry signature is wrong."+m.toString()+" "+c.length.toString(),null); else{h.pos+=22;m=h.readUInt16LE();k=h.readUInt16LE();h.pos+=m+k;if(g){c=c.subarray(h.pos,h.pos+s);if(s!==c.length){b("The amount of compressed bytes read was "+c.length.toString()+" instead of "+s.toString()+" for "+p.filename+" in "+d+".",null);break a}c=v(c,f)}else c=c.subarray(h.pos,h.pos+f);f!==c.length?b("The amount of bytes read was "+c.length.toString()+" instead of "+f.toString()+" for "+p.filename+" in "+d+".",null):(p.data=c,b(null,c))}}})}};this.set=function(a,d,b,e){p.filename=a;p.data= d;p.compressed=b;p.date=e};this.error=null;e&&(c=e.readUInt32LE(),33639248!==c?this.error="Central directory entry has wrong signature at position "+(e.pos-4).toString()+' for file "'+d+'": '+e.data.length.toString():(e.pos+=6,g=e.readUInt16LE(),this.date=b(e.readUInt32LE()),e.readUInt32LE(),s=e.readUInt32LE(),f=e.readUInt32LE(),h=e.readUInt16LE(),m=e.readUInt16LE(),c=e.readUInt16LE(),e.pos+=8,k=e.readUInt32LE(),this.filename=runtime.byteArrayToString(e.data.subarray(e.pos,e.pos+h),"utf8"),this.data= null,e.pos+=h+m+c))}function p(d,b){if(22!==d.length)b("Central directory length should be 22.",r);else{var e=new core.ByteArray(d),c;c=e.readUInt32LE();101010256!==c?b("Central directory signature is wrong: "+c.toString(),r):(c=e.readUInt16LE(),0!==c?b("Zip files with non-zero disk numbers are not supported.",r):(c=e.readUInt16LE(),0!==c?b("Zip files with non-zero disk numbers are not supported.",r):(c=e.readUInt16LE(),y=e.readUInt16LE(),c!==y?b("Number of entries is inconsistent.",r):(c=e.readUInt32LE(), e=e.readUInt16LE(),e=t-22-c,a(e,t-e,function(a,d){if(a||null===d)b(a,r);else a:{var e=new core.ByteArray(d),c,h;m=[];for(c=0;ca.value||"%"===a.unit)?null:a}function E(a){return(a=F(a))&&"%"!==a.unit?null:a}function H(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 I(a,d){for(;0=d.value||"%"===d.unit)?null:d;return d||E(a)};this.parseFoLineHeight= function(a){return B(a)||E(a)};this.isTextContentContainingNode=H;this.getTextNodes=function(a,d){var b;b=G.getNodesInRange(a,function(a){var d=NodeFilter.FILTER_REJECT;a.nodeType===Node.TEXT_NODE?Boolean(k(a)&&(!p(a.textContent)||A(a,0)))&&(d=NodeFilter.FILTER_ACCEPT):H(a)&&(d=NodeFilter.FILTER_SKIP);return d},NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);d||I(a,b);return b};this.getTextElements=Q;this.getParagraphElements=function(a){var d;d=G.getNodesInRange(a,function(a){var d=NodeFilter.FILTER_REJECT; if(b(a))d=NodeFilter.FILTER_ACCEPT;else if(H(a)||n(a))d=NodeFilter.FILTER_SKIP;return d},NodeFilter.SHOW_ELEMENT);N(a.startContainer,d,b);return d};this.getImageElements=function(a){var d;d=G.getNodesInRange(a,function(a){var d=NodeFilter.FILTER_SKIP;f(a)&&(d=NodeFilter.FILTER_ACCEPT);return d},NodeFilter.SHOW_ELEMENT);N(a.startContainer,d,f);return d};this.getHyperlinkElements=function(a){var d=[],e=a.cloneRange();a.collapsed&&a.endContainer.nodeType===Node.ELEMENT_NODE&&(a=z(a.endContainer,a.endOffset), a.nodeType===Node.TEXT_NODE&&e.setEnd(a,1));Q(e,!0,!1).forEach(function(a){for(a=a.parentNode;!b(a);){if(c(a)&&-1===d.indexOf(a)){d.push(a);break}a=a.parentNode}});e.detach();return d};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 f=odf.OdfUtils,l=Node.TEXT_NODE,a=NodeFilter.FILTER_REJECT,c=NodeFilter.FILTER_ACCEPT,b=odf.Namespaces.textns;this.acceptNode=function(k){if(k.nodeType===l){if(!f.isGroupingElement(k.parentNode))return a}else if(k.namespaceURI===b&&"tracked-changes"===k.localName)return a;return c}};xmldom.LSSerializerFilter=function(){};xmldom.LSSerializerFilter.prototype.acceptNode=function(f){};odf.OdfNodeFilter=function(){this.acceptNode=function(f){return"http://www.w3.org/1999/xhtml"===f.namespaceURI?NodeFilter.FILTER_SKIP:f.namespaceURI&&f.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 f(a,d,b){return-1!==a&&(a=g&&b.push(l(a.substring(d,c)))):"["===a[c]&&(0>=g&&(d=c+1),g+=1),c+=1;return c};n=function(a,d,e){var g,m,f,k;for(g=0;g/g,">").replace(/'/g,"'").replace(/"/g,""")}function a(b,f){var q="",p=c.filter?c.filter.acceptNode(f):NodeFilter.FILTER_ACCEPT,n;if(p===NodeFilter.FILTER_ACCEPT&&f.nodeType===Node.ELEMENT_NODE){b.push();n=b.getQName(f);var g,h=f.attributes,d,e,s,m="",x;g="<"+n;d=h.length;for(e=0;e")}if(p===NodeFilter.FILTER_ACCEPT||p===NodeFilter.FILTER_SKIP){for(p=f.firstChild;p;)q+=a(b,p),p=p.nextSibling;f.nodeValue&&(q+=l(f.nodeValue))}n&&(q+="",b.pop());return q}var c=this;this.filter=null;this.writeToString=function(b,c){if(!b)return"";var q=new f(c);return a(q,b)}};(function(){function f(a){var b,e=p.length;for(b=0;be)break;m=m.nextSibling}a.insertBefore(b,m)}}}var b=new odf.StyleInfo,k=core.DomUtils,q=odf.Namespaces.stylens,p="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "), n=Date.now()+"_webodf_",g=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(a,b,e,c){var m=this;this.size=0;this.type=null;this.name=a;this.container=e;this.url=null;this.mimetype=b;this.onstatereadychange=this.document=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.data="";this.load=function(){null!==c&&(this.mimetype=b,c.loadAsDataURL(a,b,function(a,b){a&&runtime.log(a);m.url=b;if(m.onchange)m.onchange(m);if(m.onstatereadychange)m.onstatereadychange(m)}))}};odf.OdfPart.prototype.load=function(){}; odf.OdfPart.prototype.getUrl=function(){return this.data?"data:;base64,"+g.toBase64(this.data):null};odf.OdfContainer=function d(e,f){function m(a){for(var b=a.firstChild,d;b;)d=b.nextSibling,b.nodeType===Node.ELEMENT_NODE?m(b):b.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(b),b=d}function p(a){var b={},d,e,c=a.ownerDocument.createNodeIterator(a,NodeFilter.SHOW_ELEMENT,null,!1);for(a=c.nextNode();a;)"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&("annotation"=== a.localName?(d=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))&&(b.hasOwnProperty(d)?runtime.log("Warning: annotation name used more than once with : '"+d+"'"):b[d]=a):"annotation-end"===a.localName&&((d=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))?b.hasOwnProperty(d)?(e=b[d],e.annotationEndElement?runtime.log("Warning: annotation name used more than once with : '"+d+"'"):e.annotationEndElement= a):runtime.log("Warning: annotation end without an annotation start, name: '"+d+"'"):runtime.log("Warning: annotation end without a name found"))),a=c.nextNode()}function t(a,b){for(var d=a&&a.firstChild;d;)d.nodeType===Node.ELEMENT_NODE&&d.setAttributeNS("urn:webodf:names:scope","scope",b),d=d.nextSibling}function y(a,b){for(var d=U.rootElement.meta,d=d&&d.firstChild;d&&(d.namespaceURI!==a||d.localName!==b);)d=d.nextSibling;for(d=d&&d.firstChild;d&&d.nodeType!==Node.TEXT_NODE;)d=d.nextSibling;return d? d.data:null}function v(a){var b={},d;for(a=a.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&a.namespaceURI===q&&"font-face"===a.localName&&(d=a.getAttributeNS(q,"name"),b[d]=a),a=a.nextSibling;return b}function r(a,b){var d=null,e,c,m;if(a)for(d=a.cloneNode(!0),e=d.firstElementChild;e;)c=e.nextElementSibling,(m=e.getAttributeNS("urn:webodf:names:scope","scope"))&&m!==b&&d.removeChild(e),e=c;return d}function w(a,d){var e,c,m,g=null,f={};if(a)for(d.forEach(function(a){b.collectUsedFontFaces(f,a)}), g=a.cloneNode(!0),e=g.firstElementChild;e;)c=e.nextElementSibling,m=e.getAttributeNS(q,"name"),f[m]||g.removeChild(e),e=c;return g}function u(a){var b=U.rootElement.ownerDocument,d;if(a){m(a.documentElement);try{d=b.importNode(a.documentElement,!0)}catch(e){}}return d}function A(a){U.state=a;if(U.onchange)U.onchange(U);if(U.onstatereadychange)U.onstatereadychange(U)}function F(a){aa=null;U.rootElement=a;a.fontFaceDecls=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"); a.styles=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles");a.automaticStyles=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");a.masterStyles=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles");a.body=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");a.meta=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta");a.settings=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", "settings");a.scripts=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","scripts");p(a)}function B(a){var e=u(a),m=U.rootElement,g;e&&"document-styles"===e.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===e.namespaceURI?(m.fontFaceDecls=k.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),c(m,m.fontFaceDecls),g=k.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),m.styles=g||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0", "styles"),c(m,m.styles),g=k.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),m.automaticStyles=g||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),t(m.automaticStyles,"document-styles"),c(m,m.automaticStyles),e=k.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),m.masterStyles=e||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),c(m,m.masterStyles), b.prefixStyleNames(m.automaticStyles,n,m.masterStyles)):A(d.INVALID)}function E(a){a=u(a);var e,m,g,f;if(a&&"document-content"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI){e=U.rootElement;g=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");if(e.fontFaceDecls&&g){f=e.fontFaceDecls;var p,s,n,l,z={};m=v(f);l=v(g);for(g=g.firstElementChild;g;){p=g.nextElementSibling;if(g.namespaceURI===q&&"font-face"===g.localName)if(s=g.getAttributeNS(q, "name"),m.hasOwnProperty(s)){if(!g.isEqualNode(m[s])){n=s;for(var r=m,Q=l,x=0,Y=void 0,Y=n=n.replace(/\d+$/,"");r.hasOwnProperty(Y)||Q.hasOwnProperty(Y);)x+=1,Y=n+x;n=Y;g.setAttributeNS(q,"style:name",n);f.appendChild(g);m[n]=g;delete l[s];z[s]=n}}else f.appendChild(g),m[s]=g,delete l[s];g=p}f=z}else g&&(e.fontFaceDecls=g,c(e,g));m=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");t(m,"document-content");f&&b.changeFontFaceNames(m,f);if(e.automaticStyles&&m)for(f= m.firstChild;f;)e.automaticStyles.appendChild(f),f=m.firstChild;else m&&(e.automaticStyles=m,c(e,m));a=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");if(null===a)throw" tag is mising.";e.body=a;c(e,e.body)}else A(d.INVALID)}function H(a){a=u(a);var b;a&&"document-meta"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(b=U.rootElement,b.meta=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"), c(b,b.meta))}function I(a){a=u(a);var b;a&&"document-settings"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(b=U.rootElement,b.settings=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),c(b,b.settings))}function Q(a){a=u(a);var b;if(a&&"manifest"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===a.namespaceURI)for(b=U.rootElement,b.manifest=a,a=b.manifest.firstElementChild;a;)"file-entry"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"=== a.namespaceURI&&(P[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 N(a,b,d){a=k.getElementsByTagName(a,b);var e;for(e=0;e'}function G(){var a=new xmldom.LSSerializer,b=J("document-meta");a.filter=new odf.OdfNodeFilter;b+=a.writeToString(U.rootElement.meta,odf.Namespaces.namespaceMap);return b+""}function ba(a,b){var d=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");d.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",a);d.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:media-type",b);return d}function T(){var a=runtime.parseXML(''),b=a.documentElement,d=new xmldom.LSSerializer,e;for(e in P)P.hasOwnProperty(e)&&b.appendChild(ba(e,P[e]));d.filter=new odf.OdfNodeFilter;return'\n'+d.writeToString(a,odf.Namespaces.namespaceMap)}function D(){var a,d,e,c=odf.Namespaces.namespaceMap, m=new xmldom.LSSerializer,g=J("document-styles");d=r(U.rootElement.automaticStyles,"document-styles");e=U.rootElement.masterStyles.cloneNode(!0);a=w(U.rootElement.fontFaceDecls,[e,U.rootElement.styles,d]);b.removePrefixFromStyleNames(d,n,e);m.filter=new l(e,d);g+=m.writeToString(a,c);g+=m.writeToString(U.rootElement.styles,c);g+=m.writeToString(d,c);g+=m.writeToString(e,c);return g+""}function O(){var b,d,e=odf.Namespaces.namespaceMap,c=new xmldom.LSSerializer,m=J("document-content"); d=r(U.rootElement.automaticStyles,"document-content");b=w(U.rootElement.fontFaceDecls,[d]);c.filter=new a(U.rootElement.body,d);m+=c.writeToString(b,e);m+=c.writeToString(d,e);m+=c.writeToString(U.rootElement.body,e);return m+""}function Z(a,b){runtime.loadXML(a,function(a,e){if(a)b(a);else if(e){z(e);Y(e.documentElement);var c=u(e);c&&"document"===c.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===c.namespaceURI?(F(c),A(d.DONE)):A(d.INVALID)}else b("No DOM was loaded.")})} function C(a,b){var d;d=U.rootElement;var e=d.meta;e||(d.meta=e=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),c(d,e));d=e;a&&k.mapKeyValObjOntoNode(d,a,odf.Namespaces.lookupNamespaceURI);b&&k.removeKeyElementsFromNode(d,b,odf.Namespaces.lookupNamespaceURI)}function V(a,b){function e(a,b){var d;b||(b=a);d=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",b);f[a]=d;f.appendChild(d)}var c=new core.Zip("",null),m="application/vnd.oasis.opendocument."+ a+(!0===b?"-template":""),g=runtime.byteArrayFromString(m,"utf8"),f=U.rootElement,k=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",a);c.save("mimetype",g,!1,new Date);e("meta");e("settings");e("scripts");e("fontFaceDecls","font-face-decls");e("styles");e("automaticStyles","automatic-styles");e("masterStyles","master-styles");e("body");f.body.appendChild(k);P["/"]=m;P["settings.xml"]="text/xml";P["meta.xml"]="text/xml";P["styles.xml"]="text/xml";P["content.xml"]="text/xml"; A(d.DONE);return c}function $(){var a,b=new Date,d="";U.rootElement.settings&&U.rootElement.settings.firstElementChild&&(a=new xmldom.LSSerializer,d=J("document-settings"),a.filter=new odf.OdfNodeFilter,d+=a.writeToString(U.rootElement.settings,odf.Namespaces.namespaceMap),d+="");(a=d)?(a=runtime.byteArrayFromString(a,"utf8"),W.save("settings.xml",a,!0,b)):W.remove("settings.xml");d=runtime.getWindow();a="WebODF/"+webodf.Version;d&&(a=a+" "+d.navigator.userAgent);C({"meta:generator":a}, null);a=runtime.byteArrayFromString(G(),"utf8");W.save("meta.xml",a,!0,b);a=runtime.byteArrayFromString(D(),"utf8");W.save("styles.xml",a,!0,b);a=runtime.byteArrayFromString(O(),"utf8");W.save("content.xml",a,!0,b);a=runtime.byteArrayFromString(T(),"utf8");W.save("META-INF/manifest.xml",a,!0,b)}function ca(a,b){$();W.writeAs(a,function(a){b(a)})}var U=this,W,P={},aa,S="";this.onstatereadychange=f;this.state=this.onchange=null;this.getMetadata=y;this.setRootElement=F;this.getContentElement=function(){var a; aa||(a=U.rootElement.body,aa=k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","text")||k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","presentation")||k.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","spreadsheet"));if(!aa)throw"Could not find content element in .";return aa};this.getDocumentType=function(){var a=U.getContentElement();return a&&a.localName};this.isTemplate=function(){return"-template"===P["/"].substr(-9)}; this.setIsTemplate=function(a){var b=P["/"],d="-template"===b.substr(-9);a!==d&&(b=a?b+"-template":b.substr(0,b.length-9),P["/"]=b,a=runtime.byteArrayFromString(b,"utf8"),W.save("mimetype",a,!1,new Date))};this.getPart=function(a){return new odf.OdfPart(a,P[a],U,W)};this.getPartData=function(a,b){W.load(a,b)};this.setMetadata=C;this.incrementEditingCycles=function(){var a=y(odf.Namespaces.metans,"editing-cycles"),a=a?parseInt(a,10):0;isNaN(a)&&(a=0);C({"meta:editing-cycles":a+1},null);return a+1}; this.createByteArray=function(a,b){$();W.createByteArray(a,b)};this.saveAs=ca;this.save=function(a){ca(S,a)};this.getUrl=function(){return S};this.setBlob=function(a,b,d){d=g.convertBase64ToByteArray(d);W.save(a,d,!1,new Date);P.hasOwnProperty(a)&&runtime.log(a+" has been overwritten.");P[a]=b};this.removeBlob=function(a){var b=W.remove(a);runtime.assert(b,"file is not found: "+a);delete P[a]};this.state=d.LOADING;this.rootElement=function(a){var b=document.createElementNS(a.namespaceURI,a.localName), d;a=new a.Type;for(d in a)a.hasOwnProperty(d)&&(b[d]=a[d]);return b}({Type:odf.ODFDocumentElement,namespaceURI:odf.ODFDocumentElement.namespaceURI,localName:odf.ODFDocumentElement.localName});e===odf.OdfContainer.DocumentType.TEXT?W=V("text"):e===odf.OdfContainer.DocumentType.TEXT_TEMPLATE?W=V("text",!0):e===odf.OdfContainer.DocumentType.PRESENTATION?W=V("presentation"):e===odf.OdfContainer.DocumentType.PRESENTATION_TEMPLATE?W=V("presentation",!0):e===odf.OdfContainer.DocumentType.SPREADSHEET?W=V("spreadsheet"): e===odf.OdfContainer.DocumentType.SPREADSHEET_TEMPLATE?W=V("spreadsheet",!0):(S=e,W=new core.Zip(S,function(a,b){W=b;a?Z(S,function(b){a&&(W.error=a+"\n"+b,A(d.INVALID))}):R([{path:"styles.xml",handler:B},{path:"content.xml",handler:E},{path:"meta.xml",handler:H},{path:"settings.xml",handler:I},{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(f,l,a,c){function b(a){var b=a.annotationEndElement,e=h.createRange(),c=a.getAttributeNS(odf.Namespaces.officens,"name");b&&(e.setStart(a,a.childNodes.length),e.setEnd(b,0),a=d.getTextNodes(e,!1),a.forEach(function(a){var b;a:{for(b=a.parentNode;b.namespaceURI!==odf.Namespaces.officens||"body"!==b.localName;){if(b.namespaceURI===s&&"webodf-annotationHighlight"===b.className&&b.getAttribute("annotation")===c){b=!0;break a}b=b.parentNode}b=!1}b||(b=h.createElement("span"), b.className="webodf-annotationHighlight",b.setAttribute("annotation",c),a.parentNode.replaceChild(b,a),b.appendChild(a))}));e.detach()}function k(b){var d=f.getSizer();b?(a.style.display="inline-block",d.style.paddingRight=e.getComputedStyle(a).width):(a.style.display="none",d.style.paddingRight=0);f.refreshSize()}function q(){g.sort(function(a,b){return 0!==(a.compareDocumentPosition(b)&Node.DOCUMENT_POSITION_FOLLOWING)?-1:1})}function p(){var b;for(b=0;b=(k.getBoundingClientRect().top-s.bottom)/d?e.style.top=Math.abs(k.getBoundingClientRect().top-s.bottom)/d+20+"px":e.style.top="0px"):e.style.top="0px";h.style.left= c.getBoundingClientRect().width/d+"px";var c=h.style,k=h.getBoundingClientRect().left/d,p=h.getBoundingClientRect().top/d,s=e.getBoundingClientRect().left/d,n=e.getBoundingClientRect().top/d,q=0,l=0,q=s-k,q=q*q,l=n-p,l=l*l,k=Math.sqrt(q+l);c.width=k+"px";p=Math.asin((e.getBoundingClientRect().top-h.getBoundingClientRect().top)/(d*parseFloat(h.style.width)));h.style.transform="rotate("+p+"rad)";h.style.MozTransform="rotate("+p+"rad)";h.style.WebkitTransform="rotate("+p+"rad)";h.style.msTransform="rotate("+ p+"rad)"}}function n(a){var b=g.indexOf(a),d=a.parentNode.parentNode;"div"===d.localName&&(d.parentNode.insertBefore(a,d),d.parentNode.removeChild(d));a=a.getAttributeNS(odf.Namespaces.officens,"name");a=h.querySelectorAll('span.webodf-annotationHighlight[annotation="'+a+'"]');for(var e,d=0;dq||l.bottom>q)f.scrollTop=l.bottom-l.top<=q-b?f.scrollTop+(l.bottom-q):f.scrollTop+(l.top-b);l.leftk&&(f.scrollLeft=l.right-l.left<=k-c?f.scrollLeft+(l.right-k):f.scrollLeft-(c-l.left))}}};(function(){function f(a,k,q,p,n){var g,h=0,d;for(d in a)if(a.hasOwnProperty(d)){if(h===q){g=d;break}h+=1}g?k.getPartData(a[g].href,function(d,h){if(d)runtime.log(d);else if(h){var m="@font-face { font-family: "+(a[g].family||g)+"; src: url(data:application/x-font-ttf;charset=binary;base64,"+c.convertUTF8ArrayToBase64(h)+') format("truetype"); }';try{p.insertRule(m,p.cssRules.length)}catch(l){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(l)+"\nRule: "+m)}}else runtime.log("missing font data for "+ a[g].href);f(a,k,q+1,p,n)}):n&&n()}var l=xmldom.XPath,a=odf.OdfUtils,c=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(b,c){for(var q=b.rootElement.fontFaceDecls;c.cssRules.length;)c.deleteRule(c.cssRules.length-1);if(q){var p={},n,g,h,d;if(q)for(q=l.getODFElementsWithXPath(q,"style:font-face[svg:font-face-src]",odf.Namespaces.lookupNamespaceURI),n=0;n text|list-item:first-child > :not(text|list):first-child:before',w+="{",w+="counter-increment: "+r+" 0;",w+="}",f(a,w));for(;p.counterIdStack.length>=q;)p.counterIdStack.pop();p.counterIdStack.push(r);u=p.contentRules[q.toString()]||"";for(w=1;w<=q;w+=1)u=u.replace(w+"webodf-listLevel",p.counterIdStack[w-1]);w='text|list[webodfhelper|counter-id="'+l+'"] > text|list-item > :not(text|list):first-child:before'; w+="{";w+=u;w+="counter-increment: "+r+";";w+="}";f(a,w)}for(c=c.firstElementChild;c;)b(e,c,h,p),c=c.nextElementSibling}else p.continuedCounterIdStack=[]}var c=0,d="",e={};this.createCounterRules=function(a,d,f){var k=d.getAttributeNS(q,"id"),p=[];f&&(f=f.getAttributeNS("urn:webodf:names:helper","counter-id"),p=e[f].slice(0));a=new l(a,p);k?k="Y"+k:(c+=1,k="X"+c);b(k,d,0,a);e[k+"-level1-1"]=a.counterIdStack};this.initialiseCreatedCounters=function(){var b;b="office|document{"+("counter-reset: "+d+ ";");b+="}";f(a,b)}}var c=odf.Namespaces.fons,b=odf.Namespaces.stylens,k=odf.Namespaces.textns,q=odf.Namespaces.xmlns,p={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"};odf.ListStyleToCss=function(){function n(a){var b=s.parseLength(a);return b?e.convert(b.value,b.unit,"px"):(runtime.log("Could not parse value '"+a+"'."),0)}function g(a){return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function h(a,b){var d;a&&(d=a.getAttributeNS(k,"style-name"));return d===b}function d(d, e,c){e=e.getElementsByTagNameNS(k,"list");d=new a(d);var f,n,s,l,u,A,F={},B;for(B=0;B text|list-item > text|list",x-=1;x=t&&t.getAttributeNS(c,"text-align")||"left";switch(x){case "end":x="right";break;case "start":x="left"}"label-alignment"===I?(N=Q&&Q.getAttributeNS(c,"margin-left")||"0px",R=Q&&Q.getAttributeNS(c,"text-indent")||"0px",J=Q&&Q.getAttributeNS(k,"label-followed-by"),Q=n(N)):(N=t&&t.getAttributeNS(k,"space-before")||"0px",z=t&&t.getAttributeNS(k,"min-label-width")||"0px", Y=t&&t.getAttributeNS(k,"min-label-distance")||"0px",Q=n(N)+n(z));t=q+" > text|list-item";t+="{";t+="margin-left: "+Q+"px;";t+="}";f(h,t);t=q+" > text|list-item > text|list";t+="{";t+="margin-left: "+-Q+"px;";t+="}";f(h,t);t=q+" > text|list-item > :not(text|list):first-child:before";t+="{";t+="text-align: "+x+";";t+="display: inline-block;";"label-alignment"===I?(t+="margin-left: "+R+";","listtab"===J&&(t+="padding-right: 0.2cm;")):(t+="min-width: "+z+";",t+="margin-left: "+(0===parseFloat(z)?"": "-")+z+";",t+="padding-right: "+Y+";");t+="}";f(h,t)}e=e.nextElementSibling}});d(a,h,g)}}})();odf.LazyStyleProperties=function(f,l){var a={};this.value=function(c){var b;a.hasOwnProperty(c)?b=a[c]:(b=l[c](),void 0===b&&f&&(b=f.value(c)),a[c]=b);return b};this.reset=function(c){f=c;a={}}}; odf.StyleParseUtils=function(){function f(a){var c,b;a=(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;b=a&&a.unit;"px"===b?c=a.value:"cm"===b?c=96*(a.value/2.54):"mm"===b?c=96*(a.value/25.4):"in"===b?c=96*a.value:"pt"===b?c=a.value/0.75:"pc"===b&&(c=16*a.value);return c}var l=odf.Namespaces.stylens;this.parseLength=f;this.parsePositiveLengthOrPercent=function(a,c,b){var k;a&&(k=parseFloat(a.substr(0, a.indexOf("%"))),isNaN(k)&&(k=void 0));var q;void 0!==k?(b&&(q=b.value(c)),k=void 0===q?void 0:k*(q/100)):k=f(a);return k};this.getPropertiesElement=function(a,c,b){for(c=b?b.nextElementSibling:c.firstElementChild;null!==c&&(c.localName!==a||c.namespaceURI!==l);)c=c.nextElementSibling;return c};this.parseAttributeList=function(a){a&&(a=a.replace(/^\s*(.*?)\s*$/g,"$1"));return a&&0k.value&&(g="0.75pt"+m);m=g}else if(z.hasOwnProperty(c[1])){var g= a,f=c[0],k=c[1],p=R.parseLength(m),n=void 0,s=void 0,q=void 0,r=void 0,q=void 0;if(p&&"%"===p.unit){n=p.value/100;s=l(g.parentNode);for(r="0";s;){if(q=x.getDirectChild(s,h,"paragraph-properties"))if(q=R.parseLength(q.getAttributeNS(f,k))){if("%"!==q.unit){r=q.value*n+q.unit;break}n*=q.value/100}s=l(s)}m=r}}c[2]&&(d+=c[2]+":"+m+";")}return d}function c(a,b,d,e){return b+b+d+d+e+e}function b(a,d){var e=[a],c=d.derivedStyles;Object.keys(c).forEach(function(a){a=b(a,c[a]);e=e.concat(a)});return e}function k(a, d,e,c){function g(b,d){var e=[],c;b.forEach(function(a){h.forEach(function(b){e.push('draw|page[webodfhelper|page-style-name="'+b+'"] draw|frame[presentation|class="'+a+'"]')})});0v&&(b=v);for(d=Math.floor(b/a)*a;!e&&0<=d;)e=m[d],d-=a;for(e=e||y;e.nextBookmark&&e.nextBookmark.steps<= b;)c.check(),e=e.nextBookmark;runtime.assert(-1===b||e.steps<=b,"Bookmark @"+q(e)+" at step "+e.steps+" exceeds requested step of "+b);return e}function d(a){a.previousBookmark&&(a.previousBookmark.nextBookmark=a.nextBookmark);a.nextBookmark&&(a.nextBookmark.previousBookmark=a.previousBookmark)}function e(a){for(var b,d=null;!d&&a&&a!==l;)(b=n(a))&&(d=x[b])&&d.node!==a&&(runtime.log("Cloned node detected. Creating new bookmark"),d=null,a.removeAttributeNS(s,"nodeId")),a=a.parentNode;return d}var s= "urn:webodf:names:steps",m={},x={},t=core.DomUtils,y,v,r=Node.DOCUMENT_POSITION_FOLLOWING,w=Node.DOCUMENT_POSITION_PRECEDING,u;this.updateBookmark=function(e,c){var f,k=Math.ceil(e/a)*a,p,s,q;if(void 0!==v&&vp.steps)m[k]=s;u()};this.setToClosestStep=function(a,b){var d;u();d=h(a);d.setIteratorPosition(b); return d.steps};this.setToClosestDomPoint=function(a,b,d){var c,g;u();if(a===l&&0===b)c=y;else if(a===l&&b===l.childNodes.length)for(g in c=y,m)m.hasOwnProperty(g)&&(a=m[g],a.steps>c.steps&&(c=a));else if(c=e(a.childNodes.item(b)||a),!c)for(d.setUnfilteredPosition(a,b);!c&&d.previousNode();)c=e(d.getCurrentNode());c=c||y;void 0!==v&&c.steps>v&&(c=h(v));c.setIteratorPosition(d);return c.steps};this.damageCacheAfterStep=function(a){0>a&&(a=-1);void 0===v?v=a:ad)throw new RangeError("Requested steps is negative ("+d+")");for(c=q.setToClosestStep(d,l);cn.comparePoints(f,0,d,c),d=f,c=c?0:f.childNodes.length);l.setUnfilteredPosition(d,c);k(l,m)||l.setUnfilteredPosition(d,c);m=l.container();c=l.unfilteredDomOffset();d=q.setToClosestDomPoint(m,c,l);if(0>n.comparePoints(l.container(),l.unfilteredDomOffset(),m,c))return 0=g.textNode.length?null:g.textNode.splitText(g.offset));for(e=g.textNode;e!==d;){e=e.parentNode;s=e.cloneNode(!1);m&&s.appendChild(m);if(x)for(;x&&x.nextSibling;)s.appendChild(x.nextSibling);else for(;e.firstChild;)s.appendChild(e.firstChild);e.parentNode.insertBefore(s,e.nextSibling);x=e;m=s}q.isListItem(m)&&(m=m.childNodes.item(0));k?m.setAttributeNS(p,"text:style-name",k):m.removeAttributeNS(p,"style-name");0===g.textNode.length&& g.textNode.parentNode.removeChild(g.textNode);a.emit(ops.OdtDocument.signalStepsInserted,{position:c});t&&b&&(a.moveCursor(f,c+1,0),a.emit(ops.Document.signalCursorMoved,t));a.fixCursorPositions();a.getOdfCanvas().refreshSize();a.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:h,memberId:f,timeStamp:l});a.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:m,memberId:f,timeStamp:l});a.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph", memberid:f,timestamp:l,position:c,sourceParagraphPosition:a,paragraphStyleName:k,moveCursor:b}}};ops.OpUpdateMember=function(){function f(a){var b="//dc:creator[@editinfo:memberid='"+l+"']";a=xmldom.XPath.getODFElementsWithXPath(a.getRootNode(),b,function(a){return"editinfo"===a?"urn:webodf:names:editinfo":odf.Namespaces.lookupNamespaceURI(a)});for(b=0;b=g.width&&(g=null),f.detach();else if(l.isCharacterElement(b.container)||l.isCharacterFrame(b.container))g=c.getBoundingClientRect(b.container); return g}var l=odf.OdfUtils,a=new odf.StepUtils,c=core.DomUtils,b=core.StepDirection.NEXT,k=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT,q=gui.StepInfo.VisualDirection.RIGHT_TO_LEFT;this.getContentRect=f;this.moveToFilteredStep=function(a,c,g){function h(a,b){b.process(v,m,x)&&(a=!0,!t&&b.token&&(t=b.token));return a}var d=c===b,e,l,m,x,t,y=a.snapshot();e=!1;var v;do e=f(a),v={token:a.snapshot(),container:a.container,offset:a.offset,direction:c,visualDirection:c===b?k:q},l=a.nextStep()?f(a):null,a.restore(v.token), d?(m=e,x=l):(m=l,x=e),e=g.reduce(h,!1);while(!e&&a.advanceStep(c));e||g.forEach(function(a){!t&&a.token&&(t=a.token)});a.restore(t||y);return Boolean(t)}};gui.Caret=function(f,l,a,c){function b(){h.style.opacity="0"===h.style.opacity?"1":"0";w.trigger()}function k(){m.selectNodeContents(s);return m.getBoundingClientRect()}function q(){Object.keys(B).forEach(function(a){E[a]=B[a]})}function p(){if(!1===B.isShown||f.getSelectionType()!==ops.OdtCursor.RangeSelection||!c&&!f.getSelectedRange().collapsed)B.visibility="hidden",h.style.visibility="hidden",w.cancel();else if(B.visibility="visible",h.style.visibility="visible",!1===B.isFocused)h.style.opacity= "1",w.cancel();else{if(u||E.visibility!==B.visibility)h.style.opacity="1",w.cancel();w.trigger()}if(F||A){var a;a=f.getNode();var b,m,p=t.getBoundingClientRect(x.getSizer()),n=!1,s=0;a.removeAttributeNS("urn:webodf:names:cursor","caret-sizer-active");if(0a.height&&(a={top:a.top-(8-a.height)/2,height:8,right:a.right});g.style.height=a.height+"px";g.style.top=a.top+"px";g.style.left=a.right- a.width+"px";g.style.width=a.width?a.width+"px":"";e&&(a=runtime.getWindow().getComputedStyle(f.getNode(),null),a.font?e.style.font=a.font:(e.style.fontStyle=a.fontStyle,e.style.fontVariant=a.fontVariant,e.style.fontWeight=a.fontWeight,e.style.fontSize=a.fontSize,e.style.lineHeight=a.lineHeight,e.style.fontFamily=a.fontFamily))}B.isShown&&A&&l.scrollIntoView(h.getBoundingClientRect());E.isFocused!==B.isFocused&&d.markAsFocussed(B.isFocused);q();F=A=u=!1}function n(a){g.parentNode.removeChild(g);s.parentNode.removeChild(s); a()}var g,h,d,e,s,m,x=f.getDocument().getCanvas(),t=core.DomUtils,y=new gui.GuiStepUtils,v,r,w,u=!1,A=!1,F=!1,B={isFocused:!1,isShown:!0,visibility:"hidden"},E={isFocused:!B.isFocused,isShown:!B.isShown,visibility:"hidden"};this.handleUpdate=function(){F=!0;r.trigger()};this.refreshCursorBlinking=function(){u=!0;r.trigger()};this.setFocus=function(){B.isFocused=!0;r.trigger()};this.removeFocus=function(){B.isFocused=!1;r.trigger()};this.show=function(){B.isShown=!0;r.trigger()};this.hide=function(){B.isShown= !1;r.trigger()};this.setAvatarImageUrl=function(a){d.setImageUrl(a)};this.setColor=function(a){h.style.borderColor=a;d.setColor(a)};this.getCursor=function(){return f};this.getFocusElement=function(){return h};this.toggleHandleVisibility=function(){d.isVisible()?d.hide():d.show()};this.showHandle=function(){d.show()};this.hideHandle=function(){d.hide()};this.setOverlayElement=function(a){e=a;g.appendChild(a);F=!0;r.trigger()};this.ensureVisible=function(){A=!0;r.trigger()};this.getBoundingClientRect= function(){return t.getBoundingClientRect(g)};this.destroy=function(a){core.Async.destroyAll([r.destroy,w.destroy,d.destroy,n],a)};(function(){var e=f.getDocument(),c=[e.createRootFilter(f.getMemberId()),e.getPositionFilter()],k=e.getDOMDocument();m=k.createRange();s=k.createElement("span");s.className="webodf-caretSizer";s.textContent="|";f.getNode().appendChild(s);g=k.createElement("div");g.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",f.getMemberId());g.className="webodf-caretOverlay"; h=k.createElement("div");h.className="caret";g.appendChild(h);d=new gui.Avatar(g,a);x.getSizer().appendChild(g);v=e.createStepIterator(f.getNode(),0,c,e.getRootNode());r=core.Task.createRedrawTask(p);w=core.Task.createTimeoutTask(b,500);r.triggerImmediate()})()};odf.TextSerializer=function(){function f(c){var b="",k=l.filter?l.filter.acceptNode(c):NodeFilter.FILTER_ACCEPT,q=c.nodeType,p;if((k===NodeFilter.FILTER_ACCEPT||k===NodeFilter.FILTER_SKIP)&&a.isTextContentContainingNode(c))for(p=c.firstChild;p;)b+=f(p),p=p.nextSibling;k===NodeFilter.FILTER_ACCEPT&&(q===Node.ELEMENT_NODE&&a.isParagraph(c)?b+="\n":q===Node.TEXT_NODE&&c.textContent&&(b+=c.textContent));return b}var l=this,a=odf.OdfUtils;this.filter=null;this.writeToString=function(a){if(!a)return""; a=f(a);"\n"===a[a.length-1]&&(a=a.substr(0,a.length-1));return a}};gui.MimeDataExporter=function(){var f;this.exportRangeToDataTransfer=function(l,a){var c;c=a.startContainer.ownerDocument.createElement("span");c.appendChild(a.cloneContents());c=f.writeToString(c);try{l.setData("text/plain",c)}catch(b){l.setData("Text",c)}};f=new odf.TextSerializer;f.filter=new odf.OdfNodeFilter};gui.Clipboard=function(f){this.setDataFromRange=function(l,a){var c,b=l.clipboardData;c=runtime.getWindow();!b&&c&&(b=c.clipboardData);b?(c=!0,f.exportRangeToDataTransfer(b,a),l.preventDefault()):c=!1;return c}};gui.SessionContext=function(f,l){var a=f.getOdtDocument(),c=odf.OdfUtils;this.isLocalCursorWithinOwnAnnotation=function(){var b=a.getCursor(l),f;if(!b)return!1;f=b&&b.getNode();b=a.getMember(l).getProperties().fullName;return(f=c.getParentAnnotation(f,a.getRootNode()))&&c.getAnnotationCreator(f)===b?!0:!1}};gui.StyleSummary=function(f){function l(a,c){var p=a+"|"+c,l;b.hasOwnProperty(p)||(l=[],f.forEach(function(b){b=(b=b.styleProperties[a])&&b[c];-1===l.indexOf(b)&&l.push(b)}),b[p]=l);return b[p]}function a(a,b,c){return function(){var f=l(a,b);return c.length>=f.length&&f.every(function(a){return-1!==c.indexOf(a)})}}function c(a,b){var c=l(a,b);return 1===c.length?c[0]:void 0}var b={};this.getPropertyValues=l;this.getCommonValue=c;this.isBold=a("style:text-properties","fo:font-weight",["bold"]);this.isItalic= a("style:text-properties","fo:font-style",["italic"]);this.hasUnderline=a("style:text-properties","style:text-underline-style",["solid"]);this.hasStrikeThrough=a("style:text-properties","style:text-line-through-style",["solid"]);this.fontSize=function(){var a=c("style:text-properties","fo:font-size");return a&&parseFloat(a)};this.fontName=function(){return c("style:text-properties","style:font-name")};this.isAlignedLeft=a("style:paragraph-properties","fo:text-align",["left","start"]);this.isAlignedCenter= a("style:paragraph-properties","fo:text-align",["center"]);this.isAlignedRight=a("style:paragraph-properties","fo:text-align",["right","end"]);this.isAlignedJustified=a("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(f,l,a,c,b,k,q){function p(){return V.value().styleSummary}function n(){return V.value().enabledFeatures}function g(a){var b;a.collapsed?(b=a.startContainer,b.hasChildNodes()&&a.startOffseta.clientWidth||a.scrollHeight>a.clientHeight)&&b.push(new h(a)),a=a.parentNode;b.push(new g(r));return b}function v(){var a; m()||(a=y(B),t(),B.focus(),a.forEach(function(a){a.restore()}))}var r=runtime.getWindow(),w={beforecut:!0,beforepaste:!0,longpress:!0,drag:!0,dragstop:!0},u={mousedown:!0,mouseup:!0,focus:!0},A={},F={},B,E=f.getCanvas().getElement(),H=this,I={};this.addFilter=function(a,b){d(a,!0).filters.push(b)};this.removeFilter=function(a,b){var e=d(a,!0),c=e.filters.indexOf(b);-1!==c&&e.filters.splice(c,1)};this.subscribe=e;this.unsubscribe=s;this.hasFocus=m;this.focus=v;this.getEventTrap=function(){return B}; this.setEditing=function(a){var b=m();b&&B.blur();a?B.removeAttribute("readOnly"):B.setAttribute("readOnly","true");b&&v()};this.destroy=function(a){s("touchstart",n);Object.keys(I).forEach(function(a){c(parseInt(a,10))});I.length=0;Object.keys(A).forEach(function(a){A[a].destroy()});A={};s("mousedown",x);s("mouseup",t);s("contextmenu",t);Object.keys(F).forEach(function(a){F[a].destroy()});F={};B.parentNode.removeChild(B);a()};(function(){var b=f.getOdfCanvas().getSizer(),d=b.ownerDocument;runtime.assert(Boolean(r), "EventManager requires a window object to operate correctly");B=d.createElement("textarea");B.id="eventTrap";B.setAttribute("tabindex","-1");B.setAttribute("readOnly","true");B.setAttribute("rows","1");b.appendChild(B);e("mousedown",x);e("mouseup",t);e("contextmenu",t);A.longpress=new a("longpress",["touchstart","touchmove","touchend"],k);A.drag=new a("drag",["touchstart","touchmove","touchend"],q);A.dragstop=new a("dragstop",["drag","touchend"],p);e("touchstart",n)})()};gui.IOSSafariSupport=function(f){function l(){a.innerHeight!==a.outerHeight&&(c.style.display="none",runtime.requestAnimationFrame(function(){c.style.display="block"}))}var a=runtime.getWindow(),c=f.getEventTrap();this.destroy=function(a){f.unsubscribe("focus",l);c.removeAttribute("autocapitalize");c.style.WebkitTransform="";a()};f.subscribe("focus",l);c.setAttribute("autocapitalize","off");c.style.WebkitTransform="translateX(-10000px)"};gui.HyperlinkController=function(f,l,a,c){function b(){var b=!0;!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(b=a.isLocalCursorWithinOwnAnnotation());b!==g&&(g=b,n.emit(gui.HyperlinkController.enabledChanged,g))}function k(a){a.getMemberId()===c&&b()}var q=odf.OdfUtils,p=f.getOdtDocument(),n=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),g=!1;this.isEnabled=function(){return g};this.subscribe=function(a,b){n.subscribe(a,b)};this.unsubscribe=function(a,b){n.unsubscribe(a, b)};this.addHyperlink=function(a,b){if(g){var e=p.getCursorSelection(c),k=new ops.OpApplyHyperlink,m=[];if(0===e.length||b)b=b||a,k=new ops.OpInsertText,k.init({memberid:c,position:e.position,text:b}),e.length=b.length,m.push(k);k=new ops.OpApplyHyperlink;k.init({memberid:c,position:e.position,length:e.length,hyperlink:a});m.push(k);f.enqueue(m)}};this.removeHyperlinks=function(){if(g){var a=p.createPositionIterator(p.getRootNode()),b=p.getCursor(c).getSelectedRange(),e=q.getHyperlinkElements(b), k=b.collapsed&&1===e.length,m=p.getDOMDocument().createRange(),l=[],n,y;0!==e.length&&(e.forEach(function(a){m.selectNodeContents(a);n=p.convertDomToCursorRange({anchorNode:m.startContainer,anchorOffset:m.startOffset,focusNode:m.endContainer,focusOffset:m.endOffset});y=new ops.OpRemoveHyperlink;y.init({memberid:c,position:n.position,length:n.length});l.push(y)}),k||(k=e[0],-1===b.comparePoint(k,0)&&(m.setStart(k,0),m.setEnd(b.startContainer,b.startOffset),n=p.convertDomToCursorRange({anchorNode:m.startContainer, anchorOffset:m.startOffset,focusNode:m.endContainer,focusOffset:m.endOffset}),0k.width&&(q=k.width/l.width);l.height>k.height&&(r=k.height/l.height);k=Math.min(q,r);l={width:l.width*k,height:l.height* k}}k=l.width+"px";l=l.height+"px";var w=g.getOdfCanvas().odfContainer().rootElement.styles,q=a.toLowerCase(),r=p.hasOwnProperty(q)?p[q]:null,u,q=[];runtime.assert(null!==r,"Image type is not supported: "+a);r="Pictures/"+b.generateImageName()+r;u=new ops.OpSetBlob;u.init({memberid:c,filename:r,mimetype:a,content:e});q.push(u);d.getStyleElement("Graphics","graphic",[w])||(a=new ops.OpAddStyle,a.init({memberid:c,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"}}}),q.push(a));a=b.generateStyleName();e=new ops.OpAddStyle;e.init({memberid:c,styleName:a,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"}}});q.push(e);u=new ops.OpInsertImage;u.init({memberid:c,position:g.getCursorPosition(c), filename:r,frameWidth:k,frameHeight:l,frameStyleName:a,frameName:b.generateFrameName()});q.push(u);f.enqueue(q)}};this.destroy=function(a){g.unsubscribe(ops.Document.signalCursorMoved,q);l.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,k);a()};g.subscribe(ops.Document.signalCursorMoved,q);l.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,k);k()};gui.ImageController.enabledChanged="enabled/changed";gui.ImageSelector=function(f){function l(){var a=f.getSizer(),k=b.createElement("div");k.id="imageSelector";k.style.borderWidth="1px";a.appendChild(k);c.forEach(function(a){var c=b.createElement("div");c.className=a;k.appendChild(c)});return k}var a=odf.Namespaces.svgns,c="topLeft topRight bottomRight bottomLeft topMiddle rightMiddle bottomMiddle leftMiddle".split(" "),b=f.getElement().ownerDocument,k=!1;this.select=function(c){var p,n,g=b.getElementById("imageSelector");g||(g=l());k=!0;p=g.parentNode; n=c.getBoundingClientRect();var h=p.getBoundingClientRect(),d=f.getZoomLevel();p=(n.left-h.left)/d-1;n=(n.top-h.top)/d-1;g.style.display="block";g.style.left=p+"px";g.style.top=n+"px";g.style.width=c.getAttributeNS(a,"width");g.style.height=c.getAttributeNS(a,"height")};this.clearSelection=function(){var a;k&&(a=b.getElementById("imageSelector"))&&(a.style.display="none");k=!1};this.isSelectorElement=function(a){var c=b.getElementById("imageSelector");return c?a===c||a.parentNode===c:!1}};(function(){function f(f){function a(a){q=a.which&&String.fromCharCode(a.which)===k;k=void 0;return!1===q}function c(){q=!1}function b(a){k=a.data;q=!1}var k,q=!1;this.destroy=function(k){f.unsubscribe("textInput",c);f.unsubscribe("compositionend",b);f.removeFilter("keypress",a);k()};f.subscribe("textInput",c);f.subscribe("compositionend",b);f.addFilter("keypress",a)}gui.InputMethodEditor=function(l,a){function c(a){e&&(a?e.getNode().setAttributeNS(d,"composing","true"):(e.getNode().removeAttributeNS(d, "composing"),x.textContent=""))}function b(){y&&(y=!1,c(!1),r.emit(gui.InputMethodEditor.signalCompositionEnd,{data:v}),v="")}function k(){B||(B=!0,b(),e&&e.getSelectedRange().collapsed?s.value="":s.value=u.writeToString(e.getSelectedRange().cloneContents()),s.setSelectionRange(0,s.value.length),B=!1)}function q(){a.hasFocus()&&t.trigger()}function p(){w=void 0;t.cancel();c(!0);y||r.emit(gui.InputMethodEditor.signalCompositionStart,{data:""})}function n(a){a=w=a.data;y=!0;v+=a;t.trigger()}function g(a){a.data!== w&&(a=a.data,y=!0,v+=a,t.trigger());w=void 0}function h(){x.textContent=s.value}var d="urn:webodf:names:cursor",e=null,s=a.getEventTrap(),m=s.ownerDocument,x,t,y=!1,v="",r=new core.EventNotifier([gui.InputMethodEditor.signalCompositionStart,gui.InputMethodEditor.signalCompositionEnd]),w,u,A=[],F,B=!1;this.subscribe=r.subscribe;this.unsubscribe=r.unsubscribe;this.registerCursor=function(b){b.getMemberId()===l&&(e=b,e.getNode().appendChild(x),b.subscribe(ops.OdtCursor.signalCursorUpdated,q),a.subscribe("input", h),a.subscribe("compositionupdate",h))};this.removeCursor=function(b){e&&b===l&&(e.getNode().removeChild(x),e.unsubscribe(ops.OdtCursor.signalCursorUpdated,q),a.unsubscribe("input",h),a.unsubscribe("compositionupdate",h),e=null)};this.destroy=function(d){a.unsubscribe("compositionstart",p);a.unsubscribe("compositionend",n);a.unsubscribe("textInput",g);a.unsubscribe("keypress",b);a.unsubscribe("focus",k);core.Async.destroyAll(F,d)};(function(){u=new odf.TextSerializer;u.filter=new odf.OdfNodeFilter; a.subscribe("compositionstart",p);a.subscribe("compositionend",n);a.subscribe("textInput",g);a.subscribe("keypress",b);a.subscribe("focus",k);A.push(new f(a));F=A.map(function(a){return a.destroy});x=m.createElement("span");x.setAttribute("id","composer");t=core.Task.createTimeoutTask(k,1);F.push(t.destroy)})()};gui.InputMethodEditor.signalCompositionStart="input/compositionstart";gui.InputMethodEditor.signalCompositionEnd="input/compositionend"})();gui.MetadataController=function(f,l){function a(a){k.emit(gui.MetadataController.signalMetadataChanged,a)}function c(a){var b=-1===q.indexOf(a);b||runtime.log("Setting "+a+" is restricted.");return b}var b=f.getOdtDocument(),k=new core.EventNotifier([gui.MetadataController.signalMetadataChanged]),q=["dc:creator","dc:date","meta:editing-cycles","meta:editing-duration","meta:document-statistic"];this.setMetadata=function(a,b){var g={},h="",d;a&&Object.keys(a).filter(c).forEach(function(b){g[b]=a[b]}); b&&(h=b.filter(c).join(","));if(0b:!1}function a(a){null!==a&&!1===l(a)&&(b=Math.abs(a-f))}var c=this,b,k=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT;this.token=void 0;this.process=function(b,f,n){var g,h;b.visualDirection===k?(g=f&&f.right,h=n&&n.left):(g=f&&f.left,h=n&&n.right);if(l(g)||l(h))return!0;if(f||n)a(g),a(h),c.token=b.token;return!1}};gui.LineBoundaryScanner=function(){var f=this,l=null;this.token=void 0;this.process=function(a,c,b){var k;if(k=b)if(l){var q=l;k=Math.min(q.bottom-q.top,b.bottom-b.top);var p=Math.max(q.top,b.top),q=Math.min(q.bottom,b.bottom)-p;k=0.4>=(0b?a.previousSibling:a.nextSibling,d(g)===NodeFilter.FILTER_ACCEPT&&(e=g),a=a.parentNode;return e}function c(a,d){var e;return null===a?s.NO_NEIGHBOUR:q.isCharacterElement(a)?s.SPACE_CHAR:a.nodeType===b||q.isTextSpan(a)||q.isHyperlink(a)?(e=a.textContent.charAt(d()),n.test(e)?s.SPACE_CHAR:p.test(e)?s.PUNCTUATION_CHAR:s.WORD_CHAR):s.OTHER}var b=Node.TEXT_NODE,k=Node.ELEMENT_NODE, q=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]/, n=/\s/,g=core.PositionFilter.FilterResult.FILTER_ACCEPT,h=core.PositionFilter.FilterResult.FILTER_REJECT,d=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,e=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,s={NO_NEIGHBOUR:0,SPACE_CHAR:1,PUNCTUATION_CHAR:2,WORD_CHAR:3,OTHER:4};this.acceptPosition=function(b){var f=b.container(),p=b.leftNode(),n=b.rightNode(),q=b.unfilteredDomOffset,r=function(){return b.unfilteredDomOffset()-1};f.nodeType===k&&(null===n&&(n=a(f,1,b.getNodeFilter())),null===p&&(p= a(f,-1,b.getNodeFilter())));f!==n&&(q=function(){return 0});f!==p&&null!==p&&(r=function(){return p.textContent.length-1});f=c(p,r);n=c(n,q);return f===s.WORD_CHAR&&n===s.WORD_CHAR||f===s.PUNCTUATION_CHAR&&n===s.PUNCTUATION_CHAR||l===d&&f!==s.NO_NEIGHBOUR&&n===s.SPACE_CHAR||l===e&&f===s.SPACE_CHAR&&n!==s.NO_NEIGHBOUR?h:g}};odf.WordBoundaryFilter.IncludeWhitespace={None:0,TRAILING:1,LEADING:2};gui.SelectionController=function(f,l){function a(a){var b=a.spec();if(a.isEdit||b.memberid===l)F=void 0,B.cancel()}function c(){var a=t.getCursor(l).getNode();return t.createStepIterator(a,0,[r,u],t.getRootElement(a))}function b(a,b,d){d=new odf.WordBoundaryFilter(t,d);var e=t.getRootElement(a)||t.getRootNode(),c=t.createRootFilter(e);return t.createStepIterator(a,b,[r,c,d],e)}function k(a,b){return b?{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 q(a,b,d){var e=new ops.OpMoveCursor;e.init({memberid:l,position:a,length:b||0,selectionType:d});return e}function p(a,b,d){var e;e=t.getCursor(l);e=k(e.getSelectedRange(),e.hasForwardSelection());e.focusNode=a;e.focusOffset=b;d||(e.anchorNode=e.focusNode,e.anchorOffset=e.focusOffset);a=t.convertDomToCursorRange(e);f.enqueue([q(a.position,a.length)])}function n(a){var d;d=b(a.startContainer, a.startOffset,E);d.roundToPreviousStep()&&a.setStart(d.container(),d.offset());d=b(a.endContainer,a.endOffset,H);d.roundToNextStep()&&a.setEnd(d.container(),d.offset())}function g(a){var b=v.getParagraphElements(a),d=b[0],b=b[b.length-1];d&&a.setStart(d,0);b&&(v.isParagraph(a.endContainer)&&0===a.endOffset?a.setEndBefore(b):a.setEnd(b,b.childNodes.length))}function h(a,b,d,e){var c,f;e?(c=d.startContainer,f=d.startOffset):(c=d.endContainer,f=d.endOffset);y.containsNode(a,c)||(f=0>y.comparePoints(a, 0,c,f)?0:a.childNodes.length,c=a);a=t.createStepIterator(c,f,b,v.getParagraphElement(c)||a);a.roundToClosestStep()||runtime.assert(!1,"No step found in requested range");e?d.setStart(a.container(),a.offset()):d.setEnd(a.container(),a.offset())}function d(a,b){var d=c();d.advanceStep(a)&&p(d.container(),d.offset(),b)}function e(a,b){var d,e=F,f=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];void 0===e&&A&&(e=A());isNaN(e)||(d=c(),w.moveToFilteredStep(d,a,f)&&d.advanceStep(a)&&(f=[new gui.ClosestXOffsetScanner(e), new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner],w.moveToFilteredStep(d,a,f)&&(p(d.container(),d.offset(),b),F=e,B.restart())))}function s(a,b){var d=c(),e=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];w.moveToFilteredStep(d,a,e)&&p(d.container(),d.offset(),b)}function m(a,d){var e=t.getCursor(l),e=k(e.getSelectedRange(),e.hasForwardSelection()),e=b(e.focusNode,e.focusOffset,E);e.advanceStep(a)&&p(e.container(),e.offset(),d)}function x(a,b,d){var e=!1,c=t.getCursor(l), c=k(c.getSelectedRange(),c.hasForwardSelection()),e=t.getRootElement(c.focusNode);runtime.assert(Boolean(e),"SelectionController: Cursor outside root");c=t.createStepIterator(c.focusNode,c.focusOffset,[r,u],e);c.roundToClosestStep();c.advanceStep(a)&&(d=d(c.container()))&&(a===I?(c.setPosition(d,0),e=c.roundToNextStep()):(c.setPosition(d,d.childNodes.length),e=c.roundToPreviousStep()),e&&p(c.container(),c.offset(),b))}var t=f.getOdtDocument(),y=core.DomUtils,v=odf.OdfUtils,r=t.getPositionFilter(), w=new gui.GuiStepUtils,u=t.createRootFilter(l),A=null,F,B,E=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,H=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,I=core.StepDirection.PREVIOUS,Q=core.StepDirection.NEXT;this.selectionToRange=function(a){var b=0<=y.comparePoints(a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset),d=a.focusNode.ownerDocument.createRange();b?(d.setStart(a.anchorNode,a.anchorOffset),d.setEnd(a.focusNode,a.focusOffset)):(d.setStart(a.focusNode,a.focusOffset),d.setEnd(a.anchorNode, a.anchorOffset));return{range:d,hasForwardSelection:b}};this.rangeToSelection=k;this.selectImage=function(a){var b=t.getRootElement(a),d=t.createRootFilter(b),b=t.createStepIterator(a,0,[d,t.getPositionFilter()],b),e;b.roundToPreviousStep()||runtime.assert(!1,"No walkable position before frame");d=b.container();e=b.offset();b.setPosition(a,a.childNodes.length);b.roundToNextStep()||runtime.assert(!1,"No walkable position after frame");a=t.convertDomToCursorRange({anchorNode:d,anchorOffset:e,focusNode:b.container(), focusOffset:b.offset()});a=q(a.position,a.length,ops.OdtCursor.RegionSelection);f.enqueue([a])};this.expandToWordBoundaries=n;this.expandToParagraphBoundaries=g;this.selectRange=function(a,b,d){var e=t.getOdfCanvas().getElement(),c,m=[r];c=y.containsNode(e,a.startContainer);e=y.containsNode(e,a.endContainer);if(c||e)if(c&&e&&(2===d?n(a):3<=d&&g(a)),(d=b?t.getRootElement(a.startContainer):t.getRootElement(a.endContainer))||(d=t.getRootNode()),m.push(t.createRootFilter(d)),h(d,m,a,!0),h(d,m,a,!1),a= k(a,b),b=t.convertDomToCursorRange(a),a=t.getCursorSelection(l),b.position!==a.position||b.length!==a.length)a=q(b.position,b.length,ops.OdtCursor.RangeSelection),f.enqueue([a])};this.moveCursorToLeft=function(){d(I,!1);return!0};this.moveCursorToRight=function(){d(Q,!1);return!0};this.extendSelectionToLeft=function(){d(I,!0);return!0};this.extendSelectionToRight=function(){d(Q,!0);return!0};this.setCaretXPositionLocator=function(a){A=a};this.moveCursorUp=function(){e(I,!1);return!0};this.moveCursorDown= function(){e(Q,!1);return!0};this.extendSelectionUp=function(){e(I,!0);return!0};this.extendSelectionDown=function(){e(Q,!0);return!0};this.moveCursorBeforeWord=function(){m(I,!1);return!0};this.moveCursorPastWord=function(){m(Q,!1);return!0};this.extendSelectionBeforeWord=function(){m(I,!0);return!0};this.extendSelectionPastWord=function(){m(Q,!0);return!0};this.moveCursorToLineStart=function(){s(I,!1);return!0};this.moveCursorToLineEnd=function(){s(Q,!1);return!0};this.extendSelectionToLineStart= function(){s(I,!0);return!0};this.extendSelectionToLineEnd=function(){s(Q,!0);return!0};this.extendSelectionToParagraphStart=function(){x(I,!0,v.getParagraphElement);return!0};this.extendSelectionToParagraphEnd=function(){x(Q,!0,v.getParagraphElement);return!0};this.moveCursorToParagraphStart=function(){x(I,!1,v.getParagraphElement);return!0};this.moveCursorToParagraphEnd=function(){x(Q,!1,v.getParagraphElement);return!0};this.moveCursorToDocumentStart=function(){x(I,!1,t.getRootElement);return!0}; this.moveCursorToDocumentEnd=function(){x(Q,!1,t.getRootElement);return!0};this.extendSelectionToDocumentStart=function(){x(I,!0,t.getRootElement);return!0};this.extendSelectionToDocumentEnd=function(){x(Q,!0,t.getRootElement);return!0};this.extendSelectionToEntireDocument=function(){var a=t.getCursor(l),a=t.getRootElement(a.getNode()),b,d,e;runtime.assert(Boolean(a),"SelectionController: Cursor outside root");e=t.createStepIterator(a,0,[r,u],a);e.roundToClosestStep();b=e.container();d=e.offset(); e.setPosition(a,a.childNodes.length);e.roundToClosestStep();a=t.convertDomToCursorRange({anchorNode:b,anchorOffset:d,focusNode:e.container(),focusOffset:e.offset()});f.enqueue([q(a.position,a.length)]);return!0};this.destroy=function(b){t.unsubscribe(ops.OdtDocument.signalOperationStart,a);core.Async.destroyAll([B.destroy],b)};(function(){B=core.Task.createTimeoutTask(function(){F=void 0},2E3);t.subscribe(ops.OdtDocument.signalOperationStart,a)})()};gui.TextController=function(f,l,a,c,b,k){function q(){x=!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?a.isLocalCursorWithinOwnAnnotation():!0}function p(a){a.getMemberId()===c&&q()}function n(a,b,d){var c=[e.getPositionFilter()];d&&c.push(e.createRootFilter(a.startContainer));d=e.createStepIterator(a.startContainer,a.startOffset,c,b);d.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range start");b=e.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=e.convertDomPointToCursorStep(d.container(),d.offset()));return{position:b,length:a-b}}function g(a){var b,d,e,f=s.getParagraphElements(a),g=a.cloneRange(),h=[];b=f[0];1a.length&&(a.position+=a.length,a.length=-a.length);return a}function d(a){if(!x)return!1;var b,d=e.getCursor(c).getSelectedRange().cloneRange(), m=h(e.getCursorSelection(c)),k;if(0===m.length){m=void 0;b=e.getCursor(c).getNode();k=e.getRootElement(b);var l=[e.getPositionFilter(),e.createRootFilter(k)];k=e.createStepIterator(b,0,l,k);k.roundToClosestStep()&&(a?k.nextStep():k.previousStep())&&(m=h(e.convertDomToCursorRange({anchorNode:b,anchorOffset:0,focusNode:k.container(),focusOffset:k.offset()})),a?(d.setStart(b,0),d.setEnd(k.container(),k.offset())):(d.setStart(k.container(),k.offset()),d.setEnd(b,0)))}m&&f.enqueue(g(d));return void 0!== m}var e=f.getOdtDocument(),s=odf.OdfUtils,m=core.DomUtils,x=!1,t=odf.Namespaces.textns,y=core.StepDirection.NEXT;this.isEnabled=function(){return x};this.enqueueParagraphSplittingOps=function(){if(!x)return!1;var a=e.getCursor(c),b=a.getSelectedRange(),d=h(e.getCursorSelection(c)),m=[],a=s.getParagraphElement(a.getNode()),l=a.getAttributeNS(t,"style-name")||"";0e.left&&(e=w(c)))b.focusNode=e.container,b.focusOffset=e.offset,d&&(b.anchorNode=b.focusNode,b.anchorOffset=b.focusOffset)}else D.isImage(b.focusNode.firstChild)&&1===b.focusOffset&&D.isCharacterFrame(b.focusNode)&&(e=w(b.focusNode))&&(b.anchorNode=b.focusNode=e.container,b.anchorOffset=b.focusOffset=e.offset);b.anchorNode&&b.focusNode&&(b=X.selectionToRange(b),X.selectRange(b.range,b.hasForwardSelection,0===a.button?a.detail:0));L.focus()}function A(a){var b;if(b=q(a.clientX,a.clientY))a= b.container,b=b.offset,a={anchorNode:a,anchorOffset:b,focusNode:a,focusOffset:b},a=X.selectionToRange(a),X.selectRange(a.range,a.hasForwardSelection,2),L.focus()}function F(a){var b=k(a),d,e,f;ja.processRequests();ca&&(D.isImage(b)&&D.isCharacterFrame(b.parentNode)&&R.getSelection().isCollapsed?(X.selectImage(b.parentNode),L.focus()):la.isSelectorElement(b)?L.focus():W?(b=c.getSelectedRange(),e=b.collapsed,D.isImage(b.endContainer)&&0===b.endOffset&&D.isCharacterFrame(b.endContainer.parentNode)&& (f=b.endContainer.parentNode,f=w(f))&&(b.setEnd(f.container,f.offset),e&&b.collapse(!1)),X.selectRange(b,c.hasForwardSelection(),0===a.button?a.detail:0),L.focus()):ta?u(a):(d=T.cloneEvent(a),aa=runtime.setTimeout(function(){u(d)},0)),na=0,W=ca=!1)}function B(b){var d=J.getCursor(a).getSelectedRange();d.collapsed||O.exportRangeToDataTransfer(b.dataTransfer,d)}function E(){ca&&L.focus();na=0;W=ca=!1}function H(a){F(a)}function I(a){var b=k(a),d=null;"annotationRemoveButton"===b.className?(runtime.assert(ea, "Remove buttons are displayed on annotations while annotation editing is disabled in the controller."),d=b.parentNode.getElementsByTagNameNS(odf.Namespaces.officens,"annotation").item(0),ga.removeAnnotation(d),L.focus()):"webodf-draggable"!==b.getAttribute("class")&&F(a)}function Q(a){(a=a.data)&&(-1===a.indexOf("\n")?ha.insertText(a):pa.paste(a))}function N(a){return function(){a();return!0}}function z(b){return function(d){return J.getCursor(a).getSelectionType()===ops.OdtCursor.RangeSelection? b(d):!0}}function Y(a){L.unsubscribe("keydown",C.handleEvent);L.unsubscribe("keypress",V.handleEvent);L.unsubscribe("keyup",$.handleEvent);L.unsubscribe("copy",g);L.unsubscribe("mousedown",r);L.unsubscribe("mousemove",ja.trigger);L.unsubscribe("mouseup",I);L.unsubscribe("contextmenu",H);L.unsubscribe("dragstart",B);L.unsubscribe("dragend",E);L.unsubscribe("click",oa.handleClick);L.unsubscribe("longpress",A);L.unsubscribe("drag",t);L.unsubscribe("dragstop",y);J.unsubscribe(ops.OdtDocument.signalOperationEnd, fa.trigger);J.unsubscribe(ops.Document.signalCursorAdded,ka.registerCursor);J.unsubscribe(ops.Document.signalCursorRemoved,ka.removeCursor);J.unsubscribe(ops.OdtDocument.signalOperationEnd,e);a()}var R=runtime.getWindow(),J=l.getOdtDocument(),G=new gui.SessionConstraints,ba=new gui.SessionContext(l,a),T=core.DomUtils,D=odf.OdfUtils,O=new gui.MimeDataExporter,Z=new gui.Clipboard(O),C=new gui.KeyboardHandler,V=new gui.KeyboardHandler,$=new gui.KeyboardHandler,ca=!1,U=new odf.ObjectNameGenerator(J.getOdfCanvas().odfContainer(), a),W=!1,P=null,aa,S=null,L=new gui.EventManager(J),ea=b.annotationsEnabled,ga=new gui.AnnotationController(l,G,a),da=new gui.DirectFormattingController(l,G,ba,a,U,b.directTextStylingEnabled,b.directParagraphStylingEnabled),ha=new gui.TextController(l,G,ba,a,da.createCursorStyleOp,da.createParagraphStyleOps),ma=new gui.ImageController(l,G,ba,a,U),la=new gui.ImageSelector(J.getOdfCanvas()),ia=J.createPositionIterator(J.getRootNode()),ja,fa,pa=new gui.PasteController(l,G,ba,a),ka=new gui.InputMethodEditor(a, L),na=0,oa=new gui.HyperlinkClickHandler(J.getOdfCanvas().getElement,C,$),qa=new gui.HyperlinkController(l,G,ba,a),X=new gui.SelectionController(l,a),ua=new gui.MetadataController(l,a),K=gui.KeyboardHandler.Modifier,M=gui.KeyboardHandler.KeyCode,ra=-1!==R.navigator.appVersion.toLowerCase().indexOf("mac"),ta=-1!==["iPad","iPod","iPhone"].indexOf(R.navigator.platform),sa;runtime.assert(null!==R,"Expected to be run in an environment which has a global window, like a browser.");this.undo=m;this.redo= x;this.insertLocalCursor=function(){runtime.assert(void 0===l.getOdtDocument().getCursor(a),"Inserting local cursor a second time.");var b=new ops.OpAddCursor;b.init({memberid:a});l.enqueue([b]);L.focus()};this.removeLocalCursor=function(){runtime.assert(void 0!==l.getOdtDocument().getCursor(a),"Removing local cursor without inserting before.");var b=new ops.OpRemoveCursor;b.init({memberid:a});l.enqueue([b])};this.startEditing=function(){ka.subscribe(gui.InputMethodEditor.signalCompositionStart,ha.removeCurrentSelection); ka.subscribe(gui.InputMethodEditor.signalCompositionEnd,Q);L.subscribe("beforecut",n);L.subscribe("cut",p);L.subscribe("beforepaste",d);L.subscribe("paste",h);S&&S.initialize();L.setEditing(!0);oa.setModifier(ra?K.Meta:K.Ctrl);C.bind(M.Backspace,K.None,N(ha.removeTextByBackspaceKey),!0);C.bind(M.Delete,K.None,ha.removeTextByDeleteKey);C.bind(M.Tab,K.None,z(function(){ha.insertText("\t");return!0}));ra?(C.bind(M.Clear,K.None,ha.removeCurrentSelection),C.bind(M.B,K.Meta,z(da.toggleBold)),C.bind(M.I, K.Meta,z(da.toggleItalic)),C.bind(M.U,K.Meta,z(da.toggleUnderline)),C.bind(M.L,K.MetaShift,z(da.alignParagraphLeft)),C.bind(M.E,K.MetaShift,z(da.alignParagraphCenter)),C.bind(M.R,K.MetaShift,z(da.alignParagraphRight)),C.bind(M.J,K.MetaShift,z(da.alignParagraphJustified)),ea&&C.bind(M.C,K.MetaShift,ga.addAnnotation),C.bind(M.Z,K.Meta,m),C.bind(M.Z,K.MetaShift,x)):(C.bind(M.B,K.Ctrl,z(da.toggleBold)),C.bind(M.I,K.Ctrl,z(da.toggleItalic)),C.bind(M.U,K.Ctrl,z(da.toggleUnderline)),C.bind(M.L,K.CtrlShift, z(da.alignParagraphLeft)),C.bind(M.E,K.CtrlShift,z(da.alignParagraphCenter)),C.bind(M.R,K.CtrlShift,z(da.alignParagraphRight)),C.bind(M.J,K.CtrlShift,z(da.alignParagraphJustified)),ea&&C.bind(M.C,K.CtrlAlt,ga.addAnnotation),C.bind(M.Z,K.Ctrl,m),C.bind(M.Z,K.CtrlShift,x));V.setDefault(z(function(a){var b;b=null===a.which||void 0===a.which?String.fromCharCode(a.keyCode):0!==a.which&&0!==a.charCode?String.fromCharCode(a.which):null;return!b||a.altKey||a.ctrlKey||a.metaKey?!1:(ha.insertText(b),!0)})); V.bind(M.Enter,K.None,z(ha.enqueueParagraphSplittingOps))};this.endEditing=function(){ka.unsubscribe(gui.InputMethodEditor.signalCompositionStart,ha.removeCurrentSelection);ka.unsubscribe(gui.InputMethodEditor.signalCompositionEnd,Q);L.unsubscribe("cut",p);L.unsubscribe("beforecut",n);L.unsubscribe("paste",h);L.unsubscribe("beforepaste",d);L.setEditing(!1);oa.setModifier(K.None);C.bind(M.Backspace,K.None,function(){return!0},!0);C.unbind(M.Delete,K.None);C.unbind(M.Tab,K.None);ra?(C.unbind(M.Clear, K.None),C.unbind(M.B,K.Meta),C.unbind(M.I,K.Meta),C.unbind(M.U,K.Meta),C.unbind(M.L,K.MetaShift),C.unbind(M.E,K.MetaShift),C.unbind(M.R,K.MetaShift),C.unbind(M.J,K.MetaShift),ea&&C.unbind(M.C,K.MetaShift),C.unbind(M.Z,K.Meta),C.unbind(M.Z,K.MetaShift)):(C.unbind(M.B,K.Ctrl),C.unbind(M.I,K.Ctrl),C.unbind(M.U,K.Ctrl),C.unbind(M.L,K.CtrlShift),C.unbind(M.E,K.CtrlShift),C.unbind(M.R,K.CtrlShift),C.unbind(M.J,K.CtrlShift),ea&&C.unbind(M.C,K.CtrlAlt),C.unbind(M.Z,K.Ctrl),C.unbind(M.Z,K.CtrlShift));V.setDefault(null); V.unbind(M.Enter,K.None)};this.getInputMemberId=function(){return a};this.getSession=function(){return l};this.getSessionConstraints=function(){return G};this.setUndoManager=function(a){S&&S.unsubscribe(gui.UndoManager.signalUndoStackChanged,s);if(S=a)S.setDocument(J),S.setPlaybackFunction(l.enqueue),S.subscribe(gui.UndoManager.signalUndoStackChanged,s)};this.getUndoManager=function(){return S};this.getMetadataController=function(){return ua};this.getAnnotationController=function(){return ga};this.getDirectFormattingController= function(){return da};this.getHyperlinkClickHandler=function(){return oa};this.getHyperlinkController=function(){return qa};this.getImageController=function(){return ma};this.getSelectionController=function(){return X};this.getTextController=function(){return ha};this.getEventManager=function(){return L};this.getKeyboardHandlers=function(){return{keydown:C,keypress:V}};this.destroy=function(a){var b=[ja.destroy,fa.destroy,da.destroy,ka.destroy,L.destroy,oa.destroy,qa.destroy,ua.destroy,X.destroy, ha.destroy,Y];sa&&b.unshift(sa.destroy);runtime.clearTimeout(aa);core.Async.destroyAll(b,a)};ja=core.Task.createRedrawTask(v);fa=core.Task.createRedrawTask(function(){var b=J.getCursor(a);if(b&&b.getSelectionType()===ops.OdtCursor.RegionSelection&&(b=D.getImageElements(b.getSelectedRange())[0])){la.select(b.parentNode);return}la.clearSelection()});C.bind(M.Left,K.None,z(X.moveCursorToLeft));C.bind(M.Right,K.None,z(X.moveCursorToRight));C.bind(M.Up,K.None,z(X.moveCursorUp));C.bind(M.Down,K.None,z(X.moveCursorDown)); C.bind(M.Left,K.Shift,z(X.extendSelectionToLeft));C.bind(M.Right,K.Shift,z(X.extendSelectionToRight));C.bind(M.Up,K.Shift,z(X.extendSelectionUp));C.bind(M.Down,K.Shift,z(X.extendSelectionDown));C.bind(M.Home,K.None,z(X.moveCursorToLineStart));C.bind(M.End,K.None,z(X.moveCursorToLineEnd));C.bind(M.Home,K.Ctrl,z(X.moveCursorToDocumentStart));C.bind(M.End,K.Ctrl,z(X.moveCursorToDocumentEnd));C.bind(M.Home,K.Shift,z(X.extendSelectionToLineStart));C.bind(M.End,K.Shift,z(X.extendSelectionToLineEnd));C.bind(M.Up, K.CtrlShift,z(X.extendSelectionToParagraphStart));C.bind(M.Down,K.CtrlShift,z(X.extendSelectionToParagraphEnd));C.bind(M.Home,K.CtrlShift,z(X.extendSelectionToDocumentStart));C.bind(M.End,K.CtrlShift,z(X.extendSelectionToDocumentEnd));ra?(C.bind(M.Left,K.Alt,z(X.moveCursorBeforeWord)),C.bind(M.Right,K.Alt,z(X.moveCursorPastWord)),C.bind(M.Left,K.Meta,z(X.moveCursorToLineStart)),C.bind(M.Right,K.Meta,z(X.moveCursorToLineEnd)),C.bind(M.Home,K.Meta,z(X.moveCursorToDocumentStart)),C.bind(M.End,K.Meta, z(X.moveCursorToDocumentEnd)),C.bind(M.Left,K.AltShift,z(X.extendSelectionBeforeWord)),C.bind(M.Right,K.AltShift,z(X.extendSelectionPastWord)),C.bind(M.Left,K.MetaShift,z(X.extendSelectionToLineStart)),C.bind(M.Right,K.MetaShift,z(X.extendSelectionToLineEnd)),C.bind(M.Up,K.AltShift,z(X.extendSelectionToParagraphStart)),C.bind(M.Down,K.AltShift,z(X.extendSelectionToParagraphEnd)),C.bind(M.Up,K.MetaShift,z(X.extendSelectionToDocumentStart)),C.bind(M.Down,K.MetaShift,z(X.extendSelectionToDocumentEnd)), C.bind(M.A,K.Meta,z(X.extendSelectionToEntireDocument))):(C.bind(M.Left,K.Ctrl,z(X.moveCursorBeforeWord)),C.bind(M.Right,K.Ctrl,z(X.moveCursorPastWord)),C.bind(M.Left,K.CtrlShift,z(X.extendSelectionBeforeWord)),C.bind(M.Right,K.CtrlShift,z(X.extendSelectionPastWord)),C.bind(M.A,K.Ctrl,z(X.extendSelectionToEntireDocument)));ta&&(sa=new gui.IOSSafariSupport(L));L.subscribe("keydown",C.handleEvent);L.subscribe("keypress",V.handleEvent);L.subscribe("keyup",$.handleEvent);L.subscribe("copy",g);L.subscribe("mousedown", r);L.subscribe("mousemove",ja.trigger);L.subscribe("mouseup",I);L.subscribe("contextmenu",H);L.subscribe("dragstart",B);L.subscribe("dragend",E);L.subscribe("click",oa.handleClick);L.subscribe("longpress",A);L.subscribe("drag",t);L.subscribe("dragstop",y);J.subscribe(ops.OdtDocument.signalOperationEnd,fa.trigger);J.subscribe(ops.Document.signalCursorAdded,ka.registerCursor);J.subscribe(ops.Document.signalCursorRemoved,ka.removeCursor);J.subscribe(ops.OdtDocument.signalOperationEnd,e)}})();gui.CaretManager=function(f,l){function a(a){return k.hasOwnProperty(a)?k[a]:null}function c(){return Object.keys(k).map(function(a){return k[a]})}function b(a){var b=k[a];b&&(delete k[a],a===f.getInputMemberId()?(p.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,b.ensureVisible),p.unsubscribe(ops.Document.signalCursorMoved,b.refreshCursorBlinking),n.unsubscribe("compositionupdate",b.handleUpdate),n.unsubscribe("compositionend",b.handleUpdate),n.unsubscribe("focus",b.setFocus),n.unsubscribe("blur", b.removeFocus),q.removeEventListener("focus",b.show,!1),q.removeEventListener("blur",b.hide,!1)):p.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,b.handleUpdate),b.destroy(function(){}))}var k={},q=runtime.getWindow(),p=f.getSession().getOdtDocument(),n=f.getEventManager();this.registerCursor=function(a,b,d){var e=a.getMemberId();a=new gui.Caret(a,l,b,d);k[e]=a;e===f.getInputMemberId()?(runtime.log("Starting to track input on new cursor of "+e),p.subscribe(ops.OdtDocument.signalProcessingBatchEnd, a.ensureVisible),p.subscribe(ops.Document.signalCursorMoved,a.refreshCursorBlinking),n.subscribe("compositionupdate",a.handleUpdate),n.subscribe("compositionend",a.handleUpdate),n.subscribe("focus",a.setFocus),n.subscribe("blur",a.removeFocus),q.addEventListener("focus",a.show,!1),q.addEventListener("blur",a.hide,!1),a.setOverlayElement(n.getEventTrap())):p.subscribe(ops.OdtDocument.signalProcessingBatchEnd,a.handleUpdate);return a};this.getCaret=a;this.getCarets=c;this.destroy=function(a){var h= c().map(function(a){return a.destroy});f.getSelectionController().setCaretXPositionLocator(null);p.unsubscribe(ops.Document.signalCursorRemoved,b);k={};core.Async.destroyAll(h,a)};f.getSelectionController().setCaretXPositionLocator(function(){var b=a(f.getInputMemberId()),c;b&&(c=b.getBoundingClientRect());return c?c.right:void 0});p.subscribe(ops.Document.signalCursorRemoved,b)};gui.EditInfoHandle=function(f){var l=[],a,c=f.ownerDocument,b=c.documentElement.namespaceURI;this.setEdits=function(f){l=f;var q,p,n,g;core.DomUtils.removeAllChildNodes(a);for(f=0;fe?(p=a(1,0),n=a(0.5,1E4-e),g=a(0.2,2E4-e)):1E4<=e&&2E4>e?(p=a(0.5,0),g=a(0.2,2E4-e)):p=a(0.2,0)};this.getEdits=function(){return f.getEdits()};this.clearEdits= function(){f.clearEdits();k.setEdits([]);q.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&q.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return f};this.show=function(){q.style.display="block"};this.hide=function(){c.hideHandle();q.style.display="none"};this.showHandle=function(){k.show()};this.hideHandle=function(){k.hide()};this.destroy=function(a){runtime.clearTimeout(p);runtime.clearTimeout(n);runtime.clearTimeout(g);b.removeChild(q); k.destroy(function(b){b?a(b):f.destroy(a)})};(function(){var a=f.getOdtDocument().getDOMDocument();q=a.createElementNS(a.documentElement.namespaceURI,"div");q.setAttribute("class","editInfoMarker");q.onmouseover=function(){c.showHandle()};q.onmouseout=function(){c.hideHandle()};b=f.getNode();b.appendChild(q);k=new gui.EditInfoHandle(b);l||c.hide()})()};gui.HyperlinkTooltipView=function(f,l){var a=core.DomUtils,c=odf.OdfUtils,b=runtime.getWindow(),k,q,p;runtime.assert(null!==b,"Expected to be run in an environment which has a global window, like a browser.");this.showTooltip=function(n){var g=n.target||n.srcElement,h=f.getSizer(),d=f.getZoomLevel(),e;a:{for(;g;){if(c.isHyperlink(g))break a;if(c.isParagraph(g)||c.isInlineRoot(g))break;g=g.parentNode}g=null}if(g){a.containsNode(h,p)||h.appendChild(p);e=q;var s;switch(l()){case gui.KeyboardHandler.Modifier.Ctrl:s= runtime.tr("Ctrl-click to follow link");break;case gui.KeyboardHandler.Modifier.Meta:s=runtime.tr("\u2318-click to follow link");break;default:s=""}e.textContent=s;k.textContent=c.getHyperlinkTarget(g);p.style.display="block";e=b.innerWidth-p.offsetWidth-15;g=n.clientX>e?e:n.clientX+15;e=b.innerHeight-p.offsetHeight-10;n=n.clientY>e?e:n.clientY+10;h=h.getBoundingClientRect();g=(g-h.left)/d;n=(n-h.top)/d;p.style.left=g+"px";p.style.top=n+"px"}};this.hideTooltip=function(){p.style.display="none"};this.destroy= function(a){p.parentNode&&p.parentNode.removeChild(p);a()};(function(){var a=f.getElement().ownerDocument;k=a.createElement("span");q=a.createElement("span");k.className="webodf-hyperlinkTooltipLink";q.className="webodf-hyperlinkTooltipText";p=a.createElement("div");p.className="webodf-hyperlinkTooltip";p.appendChild(k);p.appendChild(q);f.getElement().appendChild(p)})()};gui.OdfFieldView=function(f){function l(){var a=odf.OdfSchema.getFields().map(function(a){return a.replace(":","|")}),c=a.join(",\n")+"\n{ background-color: #D0D0D0; }\n",a=a.map(function(a){return a+":empty::after"}).join(",\n")+"\n{ content:' '; white-space: pre; }\n";return c+"\n"+a}var a,c=f.getElement().ownerDocument;this.showFieldHighlight=function(){a.appendChild(c.createTextNode(l()))};this.hideFieldHighlight=function(){for(var b=a.sheet,c=b.cssRules;c.length;)b.deleteRule(c.length-1)};this.destroy= function(b){a.parentNode&&a.parentNode.removeChild(a);b()};a=function(){var a=c.getElementsByTagName("head").item(0),f=c.createElement("style"),l="";f.type="text/css";f.media="screen, print, handheld, projection";odf.Namespaces.forEachPrefix(function(a,b){l+="@namespace "+a+" url("+b+");\n"});f.appendChild(c.createTextNode(l));a.appendChild(f);return f}()};gui.ShadowCursor=function(f){var l=f.getDOMDocument().createRange(),a=!0;this.removeFromDocument=function(){};this.getMemberId=function(){return gui.ShadowCursor.ShadowCursorMemberId};this.getSelectedRange=function(){return l};this.setSelectedRange=function(c,b){l=c;a=!1!==b};this.hasForwardSelection=function(){return a};this.getDocument=function(){return f};this.getSelectionType=function(){return ops.OdtCursor.RangeSelection};l.setStart(f.getRootNode(),0)};gui.ShadowCursor.ShadowCursorMemberId="";gui.SelectionView=function(f){};gui.SelectionView.prototype.rerender=function(){};gui.SelectionView.prototype.show=function(){};gui.SelectionView.prototype.hide=function(){};gui.SelectionView.prototype.destroy=function(f){};gui.SelectionViewManager=function(f){function l(){return Object.keys(a).map(function(c){return a[c]})}var a={};this.getSelectionView=function(c){return a.hasOwnProperty(c)?a[c]:null};this.getSelectionViews=l;this.removeSelectionView=function(c){a.hasOwnProperty(c)&&(a[c].destroy(function(){}),delete a[c])};this.hideSelectionView=function(c){a.hasOwnProperty(c)&&a[c].hide()};this.showSelectionView=function(c){a.hasOwnProperty(c)&&a[c].show()};this.rerenderSelectionViews=function(){Object.keys(a).forEach(function(c){a[c].rerender()})}; this.registerCursor=function(c,b){var k=c.getMemberId(),l=new f(c);b?l.show():l.hide();return a[k]=l};this.destroy=function(a){function b(l,p){p?a(p):l .webodf-draggable"), a=gui.ShadowCursor.ShadowCursorMemberId,e(".webodf-selectionOverlay","{ fill: "+d+"; stroke: "+d+";}",""),e(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"))}function g(a){var b,d;for(d in u)u.hasOwnProperty(d)&&(b=u[d],a?b.show():b.hide())}function h(a){b.getCarets().forEach(function(b){a?b.showHandle():b.hideHandle()})}function d(a){var b=a.getMemberId();a=a.getProperties();n(b,a.fullName,a.color)}function e(d){var e=d.getMemberId(),c=a.getOdtDocument().getMember(e).getProperties(); b.registerCursor(d,H,I);k.registerCursor(d,!0);if(d=b.getCaret(e))d.setAvatarImageUrl(c.imageUrl),d.setColor(c.color);runtime.log("+++ View here +++ eagerly created an Caret for '"+e+"'! +++")}function s(a){a=a.getMemberId();var d=k.getSelectionView(l),e=k.getSelectionView(gui.ShadowCursor.ShadowCursorMemberId),c=b.getCaret(l);a===l?(e.hide(),d&&d.show(),c&&c.show()):a===gui.ShadowCursor.ShadowCursorMemberId&&(e.show(),d&&d.hide(),c&&c.hide())}function m(a){k.removeSelectionView(a)}function x(b){var d= b.paragraphElement,e=b.memberId;b=b.timeStamp;var c,f="",g=d.getElementsByTagNameNS(w,"editinfo").item(0);g?(f=g.getAttributeNS(w,"id"),c=u[f]):(f=Math.random().toString(),c=new ops.EditInfo(d,a.getOdtDocument()),c=new gui.EditInfoMarker(c,E),g=d.getElementsByTagNameNS(w,"editinfo").item(0),g.setAttributeNS(w,"id",f),u[f]=c);c.addEdit(e,new Date(b));B.trigger()}function t(){var b;r.hasChildNodes()&&core.DomUtils.removeAllChildNodes(r);!0===c.getState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN)&& (b=a.getOdtDocument().getMember(l))&&(b=b.getProperties().fullName,r.appendChild(document.createTextNode(".annotationWrapper:not([creator = '"+b+"']) .annotationRemoveButton { display: none; }")))}function y(a){var b=Object.keys(u).map(function(a){return u[a]});A.unsubscribe(ops.Document.signalMemberAdded,d);A.unsubscribe(ops.Document.signalMemberUpdated,d);A.unsubscribe(ops.Document.signalCursorAdded,e);A.unsubscribe(ops.Document.signalCursorRemoved,m);A.unsubscribe(ops.OdtDocument.signalParagraphChanged, x);A.unsubscribe(ops.Document.signalCursorMoved,s);A.unsubscribe(ops.OdtDocument.signalParagraphChanged,k.rerenderSelectionViews);A.unsubscribe(ops.OdtDocument.signalTableAdded,k.rerenderSelectionViews);A.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,k.rerenderSelectionViews);c.unsubscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN,t);A.unsubscribe(ops.Document.signalMemberAdded,t);A.unsubscribe(ops.Document.signalMemberUpdated,t);v.parentNode.removeChild(v);r.parentNode.removeChild(r); (function Y(d,e){e?a(e):da.length;b&&f(a);return b}function a(a,b){function c(g){a[g]===b&&f.push(g)}var f=[];a&&["style:parent-style-name","style:next-style-name"].forEach(c);return f}function c(a,b){function c(f){a[f]===b&&delete a[f]}a&&["style:parent-style-name","style:next-style-name"].forEach(c)}function b(a){var e={};Object.keys(a).forEach(function(c){e[c]="object"===typeof a[c]?b(a[c]):a[c]});return e}function k(a, b,c,f){var g,h=!1,k=!1,l,n=[];f&&f.attributes&&(n=f.attributes.split(","));a&&(c||0=e.position+e.length)){f=c?a:e;g=c?e:a;if(a.position!==e.position||a.length!==e.length)p=b(f),w=b(g);e=n(g.setProperties,null,f.setProperties,null,"style:text-properties");if(e.majorChanged||e.minorChanged)h=[],a=[],k=f.position+f.length,l=g.position+g.length,g.positionk?e.minorChanged&&(p=w,p.position=k,p.length=l-k,a.push(p),g.length=k-g.position):k>l&&e.majorChanged&&(p.position=l,p.length=k-l,h.push(p),f.length=l-f.position),f.setProperties&&q(f.setProperties)&&h.push(f),g.setProperties&&q(g.setProperties)&&a.push(g),c?(k=h,h=a):k=a}return{opSpecsA:k,opSpecsB:h}},InsertText:function(a,b){b.position<=a.position?a.position+=b.text.length:b.position<=a.position+a.length&& (a.length+=b.text.length);return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){var c=a.position,f=a.position+a.length;c>=b.sourceStartPosition&&(c-=1);f>=b.sourceStartPosition&&(f-=1);a.position=c;a.length=f-c;return{opSpecsA:[a],opSpecsB:[b]}},MoveCursor:g,RemoveCursor:g,RemoveMember:g,RemoveStyle:g,RemoveText:function(a,b){var c=a.position+a.length,f=b.position+b.length,g=[a],h=[b];f<=a.position?a.position-=b.length:b.positionb.position?a.position+=b.text.length:c?b.position+=a.text.length:a.position+=b.text.length; return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){a.position>=b.sourceStartPosition?a.position-=1:(a.positiona.position&&(b.position+=a.text.length);return{opSpecsA:[a], opSpecsB:[b]}},SplitParagraph:function(a,b){a.position=a.sourceStartPosition&&(g-=1);c>=a.sourceStartPosition&& (c-=1);0<=b.length?(b.position=g,b.length=c-g):(b.position=c,b.length=g-c);return{opSpecsA:[a],opSpecsB:[b]}},RemoveCursor:g,RemoveMember:g,RemoveStyle:g,RemoveText:function(a,b){b.position>=a.sourceStartPosition?b.position-=1:(b.positiona.sourceStartPosition)b.position-= 1;else if(b.position===a.destinationStartPosition||b.position===a.sourceStartPosition)b.position=a.destinationStartPosition,a.paragraphStyleName=b.styleName;return{opSpecsA:c,opSpecsB:f}},SplitParagraph:function(a,b){var c,f=[a],g=[b];b.position=a.destinationStartPosition&&b.position=a.sourceStartPosition&&(b.position-=1,b.sourceParagraphPosition-=1);return{opSpecsA:f,opSpecsB:g}},UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},MoveCursor:{MoveCursor:g,RemoveCursor:function(a, b){return{opSpecsA:a.memberid===b.memberid?[]:[a],opSpecsB:[b]}},RemoveMember:g,RemoveStyle:g,RemoveText:function(a,b){var c=l(a),g=a.position+a.length,h=b.position+b.length;h<=a.position?a.position-=b.length:b.positionc.position?a.position+=1:a.position===c.sourceParagraphPosition&&(c.paragraphStyleName=a.styleName,h=b(a),h.position=c.position+1,f.push(h));return{opSpecsA:f,opSpecsB:g}},UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},SplitParagraph:{SplitParagraph:function(a,b,c){var f,g;a.position