(function(){var e,t,n;n=class n extends this.OS.application.BaseApplication{constructor(e){super("OpenPage",e)}main(){return this.eventSubscriptions=new core.EventSubscriptions,this.initToolbox(),this.userid=`${this.systemsetting.user.username}@${this.pid}`,this.currentStyle="",this.args&&this.args.length>0?this.open(this.args[0].path):this.newdoc(),this.resource={fonts:[],formats:[]},this.bindKey("ALT-N",()=>this.actionFile(this.name+"-New")),this.bindKey("ALT-O",()=>this.actionFile(this.name+"-Open")),this.bindKey("CTRL-S",()=>this.actionFile(this.name+"-Save")),this.bindKey("ALT-W",()=>this.actionFile(this.name+"-Saveas"))}menu(){return[{text:"__(File)",nodes:[{text:"__(New)",dataid:this.name+"-New",shortcut:"A-N"},{text:"__(Open)",dataid:this.name+"-Open",shortcut:"A-O"},{text:"__(Save)",dataid:this.name+"-Save",shortcut:"C-S"},{text:"__(Save as)",dataid:this.name+"-Saveas",shortcut:"A-W"}],onchildselect:e=>this.actionFile(e.data.item.data.dataid)}]}actionFile(e){var t;switch(t=()=>this.openDialog("FileDialog",{title:__("Save as"),file:this.currfile}).then(e=>{var t;return t=e.file.path.asFileHandle(),"file"===e.file.type&&(t=t.parent()),this.currfile.setPath(`${t.path}/${e.name}`),this.save()}),e){case this.name+"-Open":return this.openDialog("FileDialog",{title:__("Open file"),mimes:this.meta().mimes}).then(e=>this.open(e.file.path));case this.name+"-Save":return this.currfile.basename?this.save():t();case this.name+"-Saveas":return t();case this.name+"-New":return this.newdoc()}}newdoc(){var e;return e=this.meta().path+"/blank.odt",this.open(e,!0)}open(e,t){return this.pathAsDataURL(e).then(n=>(this.editorSession&&this.closeDocument(),this.initCanvas(),new odf.OdfContainer(n.data,n=>(this.canvas.setOdfContainer(n,!1),t?this.currfile="Untitled".asFileHandle():(this.currfile?this.currfile.setPath(e):this.currfile=e.asFileHandle(),this.scheme.apptitle=this.currfile.basename,this.notify(__("File {0} opened",e))))))).catch(e=>this.error(__("Problem read file {0}",e.toString()),e))}save(){var e;if(this.editorSession)return(e=this.canvas.odfContainer())?e.createByteArray(e=>(this.currfile.cache=new Blob([e],{type:"application/vnd.oasis.opendocument.text"}),this.currfile.write("application/vnd.oasis.opendocument.text").then(e=>(this.notify(__("File {0} saved",this.currfile.basename)),this.scheme.apptitle=this.currfile.basename,this.currfile.dirty=!1,this.editorFocus())).catch(e=>this.error(__("Cannot save file: {0}",e.toString()),e))),e=>this.error(__("Cannot create byte array from container: {0}",e.toString()||""),e)):this.error(__("No document container found"))}initToolbox(){var e,t,n;for(t in this.basictool={undo:this.find("btundo"),redo:this.find("btredo"),bold:this.find("btbold"),italic:this.find("btitalic"),underline:this.find("btunderline"),strike:this.find("btstrike"),note:this.find("btnote"),link:this.find("btlink"),unlink:this.find("btunlink"),image:this.find("btimage"),ac:this.find("btac"),al:this.find("btal"),ar:this.find("btar"),aj:this.find("btaj"),indent:this.find("btindent"),outdent:this.find("btoutdent"),fonts:this.find("font-list"),fontsize:this.find("font-size"),styles:this.find("format-list"),zoom:this.find("slzoom"),format:this.find("btformat")},e=(e,t)=>t["fonts"===e||"styles"===e?"onlistselect":"fontsize"===e||"zoom"===e?"onvaluechange":"onbtclick"]=t=>{if(this.directFormattingCtl&&this[e])return this[e](t),this.editorFocus()},n=this.basictool)e(t,n[t]);return this.find("btzoomfix").onbtclick=e=>this.zoom({data:100}),this.basictool.zoom.onvaluechanging=e=>this.find("lbzoom").text=Math.floor(e.data)+"%"}initCanvas(){var e;return(e=this.find("odfcanvas")).setAttribute("translate","no"),e.classList.add("notranslate"),this.canvas=new odf.OdfCanvas(e),this.documentChanged=e=>{if(!this.currfile.dirty)return this.currfile.dirty=!0,this.scheme.apptitle=this.currfile.basename+"*"},this.metaChanged=e=>{if(!this.currfile.dirty)return this.currfile.dirty=!0,this.scheme.apptitle=this.currfile.basename+"*"},this.textStylingChanged=e=>this.updateToolbar(e),this.paragrahStyleChanged=e=>{var t,n,i,o,r;if("style"===e.type){for(t=o=0,r=(i=this.basictool.styles.data).length;o{var n,i,o,r,a,s;if("paragraph"===t.family){for(r=0,a=(o=this.basictool.styles.data).length;r{var t;return t=Math.floor(100*e),this.basictool.zoom.value=t,this.find("lbzoom").text=t+"%"},this.canvas.enableAnnotations(!0,!0),this.canvas.addListener("statereadychange",()=>{var e,t;return this.session=new ops.Session(this.canvas),t={editInfoMarkersInitiallyVisible:!1,caretAvatarsInitiallyVisible:!1,caretBlinksOnRangeSelect:!0},this.editorSession=new n.EditorSession(this.session,this.userid,{viewOptions:t,directTextStylingEnabled:!0,directParagraphStylingEnabled:!0,paragraphStyleSelectingEnabled:!0,paragraphStyleEditingEnabled:!0,imageEditingEnabled:!0,hyperlinkEditingEnabled:!0,annotationsEnabled:!0,zoomingEnabled:!0,reviewModeEnabled:!1}),this.initFontList(this.editorSession.getDeclaredFonts()),this.initStyles(this.editorSession.getAvailableParagraphStyles()),this.directFormattingCtl=this.editorSession.sessionController.getDirectFormattingController(),this.directFormattingCtl.subscribe(gui.DirectFormattingController.textStylingChanged,this.textStylingChanged),this.directFormattingCtl.subscribe(gui.DirectFormattingController.paragraphStylingChanged,this.textStylingChanged),this.editorSession.subscribe(n.EditorSession.signalParagraphChanged,this.paragrahStyleChanged),this.hyperlinkController=this.editorSession.sessionController.getHyperlinkController(),this.eventSubscriptions.addFrameSubscription(this.editorSession,n.EditorSession.signalCursorMoved,()=>this.updateHyperlinkButtons()),this.eventSubscriptions.addFrameSubscription(this.editorSession,n.EditorSession.signalParagraphChanged,()=>this.updateHyperlinkButtons()),this.eventSubscriptions.addFrameSubscription(this.editorSession,n.EditorSession.signalParagraphStyleModified,()=>this.updateHyperlinkButtons()),this.annotationController=this.editorSession.sessionController.getAnnotationController(),this.imageController=this.editorSession.sessionController.getImageController(),this.textController=this.editorSession.sessionController.getTextController(),this.zoomHelper=this.editorSession.getOdfCanvas().getZoomHelper(),this.zoomHelper.subscribe(gui.ZoomHelper.signalZoomChanged,this.updateSlider),this.updateSlider(this.zoomHelper.getZoomLevel()),this.editorSession.subscribe(n.EditorSession.signalCommonStyleCreated,this.styleAdded),this.editorSession.sessionController.setUndoManager(new gui.TrivialUndoManager),this.editorSession.sessionController.getUndoManager().subscribe(gui.UndoManager.signalDocumentModifiedChanged,this.documentChanged),this.editorSession.sessionController.getMetadataController().subscribe(gui.MetadataController.signalMetadataChanged,this.metaChanged),(e=new ops.OpAddMember).init({memberid:this.userid,setProperties:{fullName:this.userid,color:"blue"}}),this.session.enqueue([e]),this.editorSession.sessionController.insertLocalCursor(),this.editorSession.sessionController.startEditing(),this.fontsize({data:this.basictool.fontsize.value})})}initFontList(e){var t,n,i,o,r;for(t=0,i=e.length;t0}selectFont(e){var t,n,i,o,r;for(t=o=0,r=(i=this.basictool.fonts.data).length;o{var t,n;return n=this.editorSession.sessionController.getSelectionController(),e.readonly?("edit"===e.action&&((t=o.cloneRange()).selectNode(i[0]),n.selectRange(t,!0)),this.hyperlinkController.removeHyperlinks(),this.hyperlinkController.addHyperlink(e.link)):(this.hyperlinkController.addHyperlink(e.link,e.text),i=this.editorSession.getSelectedHyperlinks(),(t=o.cloneRange()).selectNode(i[0]),n.selectRange(t,!0))})}unlink(e){return this.hyperlinkController.removeHyperlinks()}undo(e){return this.editorSession.undo()}redo(e){return this.editorSession.redo()}pathAsDataURL(e){return new Promise((t,n)=>{var i;return(i=e.asFileHandle()).read("binary").then(o=>{var r,a;return r=new Blob([o],{type:i.info.mime}),(a=new FileReader).onloadend=()=>2!==a.readyState?n(this.throwe(__("Unable to load file {0}",e))):t({data:a.result,fp:i}),a.readAsDataURL(r)}).catch(e=>n(__e(e)))})}image(e){return this.openDialog("FileDialog",{title:__("Select image file"),mimes:["image/.*"]}).then(e=>{var t;return t=e.file.path,this.pathAsDataURL(t).then(e=>{var t;return(t=new Image).style.position="absolute",t.style.left="-99999px",document.body.appendChild(t),t.onload=()=>{var n;return n=e.data.substring(e.data.indexOf(",")+1),this.textController.removeCurrentSelection(),this.imageController.insertImage(e.fp.info.mime,n,t.width,t.height),document.body.removeChild(t)},t.src=e.data}).catch(e=>this.error(__("Couldnt load image {0}",t),e))})}styles(e){if(e.data.item.data.name!==this.currentStyle)return this.editorSession.setCurrentParagraphStyle(e.data.item.data.name)}zoom(e){if(this.zoomHelper)return this.zoomHelper.setZoomLevel(e.data/100)}format(t){return this.openDialog(new e,{title:__("Add/Modify paragraph format"),data:this.resource}).then(e=>{})}closeDocument(e){var t;if(this.editorSession&&this.session)return this.eventSubscriptions.unsubscribeAll(),this.editorSession.sessionController.endEditing(),this.editorSession.sessionController.removeLocalCursor(),(t=new ops.OpRemoveMember).init({memberid:this.userid}),this.session.enqueue([t]),this.session.close(t=>t?this.error(__("Cannot close session {0}",t.toString()),t):(this.editorSession.sessionController.getMetadataController().unsubscribe(gui.MetadataController.signalMetadataChanged,this.metaChanged),this.editorSession.sessionController.getUndoManager().unsubscribe(gui.UndoManager.signalDocumentModifiedChanged,this.documentChanged),this.directFormattingCtl.unsubscribe(gui.DirectFormattingController.textStylingChanged,this.textStylingChanged),this.directFormattingCtl.unsubscribe(gui.DirectFormattingController.paragraphStylingChanged,this.textStylingChanged),this.editorSession.unsubscribe(n.EditorSession.signalParagraphChanged,this.paragrahStyleChanged),this.zoomHelper.unsubscribe(gui.ZoomHelper.signalZoomChanged,this.updateSlider),this.editorSession.unsubscribe(n.EditorSession.signalCommonStyleCreated,this.styleAdded),this.editorSession.destroy(t=>t?this.error(__("Cannot destroy editor session {0}",t.toString()),t):(this.editorSession=void 0,this.session.destroy(t=>t?this.error(__("Cannot destroy document session {0}",t.toString()),t):(core.Async.destroyAll([this.canvas.destroy],t=>t?this.error(__("Cannot destroy canvas {0}",t.toString()),t):(this.notify("Document closed"),e?e():void 0)),this.session=void 0,this.annotationController=void 0,this.directFormattingCtl=void 0,this.textController=void 0,this.imageController=void 0,this.ZoomHelper=void 0,this.metaChanged=void 0,this.documentChanged=void 0,this.textStylingChanged=void 0,this.paragrahStyleChanged=void 0,this.updateSlider=void 0,this.styleAdded=void 0,this.basictool.fonts.selected=-1,this.basictool.styles.selected=-1))))))}cleanup(e){if(this.editorSession)return e.preventDefault(),this.closeDocument(()=>this.quit())}},this.OS.register("OpenPage",n),(t=class e extends this.OS.GUI.BasicDialog{constructor(){super("HyperLinkDialog",e.scheme)}main(){var e,t;return super.main(),t=this.find("txtText"),e=this.find("txtLink"),this.data&&this.data.data&&(t.value=this.data.data.text,e.value=this.data.data.link,$(t).prop("disabled",this.data.data.readonly)),this.find("btnCancel").onbtclick=e=>this.quit(),this.find("btnOk").onbtclick=n=>{var i;return i={text:t.value,link:e.value,readonly:this.data.data.readonly,action:this.data.data.action},this.handle&&this.handle(i),this.quit()}}}).scheme='\n \n \n
\n \n
\n \n \n \n \n
\n \n
\n \n \n
\n \n \n
\n \n \n',(e=class e extends this.OS.GUI.BasicDialog{constructor(){super("FormatDialog",e.scheme)}main(){return super.main(),this.ui={aligment:{left:this.find("swleft"),right:this.find("swright"),center:this.find("swcenter"),justify:this.find("swjustify")},spacing:{left:this.find("spnleft"),right:this.find("spnright"),top:this.find("spntop"),bottom:this.find("spnbottom"),lineheight:this.find("spnlheight")},padding:{left:this.find("pspnleft"),right:this.find("pspnright"),top:this.find("pspntop"),bottom:this.find("pspnbottom")},style:{bold:this.find("swbold"),italic:this.find("switalic"),underline:this.find("swunderline"),color:this.find("txtcolor"),bgcolor:this.find("bgcolor")},font:{family:this.find("lstfont"),size:this.find("spnfsize")},formats:this.find("lstformats")},this.initStyleObject(),this.preview=$(this.find("preview")).find("p")[0],$(this.preview).css("padding","0").css("margin","0"),this.initUIEvent()}initStyleObject(){return this.currentStyle={aligment:this._api.switcher("left","right","center","justify"),spacing:{left:0,top:0,right:0,bottom:0,lineheight:0},padding:{left:0,top:0,right:0,bottom:0},style:{bold:!1,italic:!1,underline:!1,color:void 0,bgcolor:void 0},font:{family:void 0,size:12}}}initUIEvent(){var e,t,n,i,o,r;for(e in r=(e,t,n,i)=>this.ui[t][n][e]=e=>{var o;return o=e,i&&(o=i(e)),this.currentStyle[t][n]=o,this.previewStyle()},t=this.ui.aligment)t[e],r("onswchange","aligment",e,e=>e.data);for(e in n=this.ui.spacing)n[e],r("onvaluechange","spacing",e,e=>e.data);for(e in i=this.ui.padding)i[e],r("onvaluechange","padding",e,e=>e.data);for(e in o=this.ui.style)o[e],"color"!==e&&"bgcolor"!==e&&r("onswchange","style",e,e=>e.data);return r("onvaluechange","font","size"),$(this.ui.style.color).click(e=>this.openDialog("ColorPickerDialog").then(e=>(this.currentStyle.style.color=e,this.previewStyle()))),$(this.ui.style.bgcolor).click(e=>this.openDialog("ColorPickerDialog").then(e=>(this.currentStyle.style.bgcolor=e,this.previewStyle()))),this.data.data&&this.data.data.fonts&&(this.ui.font.family.data=this.data.data.fonts),r("onlistselect","font","family",e=>e.data.item.data),this.ui.formats.selected=-1,this.data.data&&this.data.data.formats&&(this.ui.formats.data=this.data.data.formats),this.ui.formats.onlistselect=e=>this.fromODFStyleFormat(e.data.item.data),this.ui.formats.selected=0,this.find("btok").onbtclick=e=>this.saveCurrentStyle(),this.find("btx").onbtclick=e=>this.quit(),this.find("bt-clone").onbtclick=e=>this.clone()}clone(){var e;if(e=this.ui.formats.selectedItem)return e=e.data,this.openDialog("PromptDialog",{title:__("Clone style: {0}",e.text),label:__("New style name:")}).then(t=>{var n;return t&&""!==t.trim()?(n=this.parent.editorSession.cloneParagraphStyle(e.name,t),this.ui.formats.push({text:t,name:n}),this.ui.formats.selected=this.ui.formats.data.length-1,this.notify(__("New style: {0} added",n))):this.notify(__("Abort: no style name is specified"))})}saveCurrentStyle(){var e,t;if(t=this.ui.formats.selectedItem)return t=t.data,e={"style:paragraph-properties":{"fo:margin-top":this.currentStyle.spacing.top+"mm","fo:margin-left":this.currentStyle.spacing.left+"mm","fo:margin-bottom":this.currentStyle.spacing.bottom+"mm","fo:margin-right":this.currentStyle.spacing.right+"mm","fo:padding-top":this.currentStyle.padding.top+"mm","fo:padding-left":this.currentStyle.padding.left+"mm","fo:padding-bottom":this.currentStyle.padding.bottom+"mm","fo:padding-right":this.currentStyle.padding.right+"mm","fo:line-height":this.currentStyle.spacing.lineheight>0?this.currentStyle.spacing.lineheight+"mm":"normal","fo:text-align":this.currentStyle.aligment.selected||"left"},"style:text-properties":{"fo:font-weight":this.currentStyle.style.bold?"bold":"normal","fo:font-style":this.currentStyle.style.italic?"italic":"normal","style:text-underline-style":this.currentStyle.style.underline?"solid":"none","fo:font-size":this.currentStyle.font.size+"pt","fo:font-name":this.currentStyle.font.family.text,"fo:color":this.currentStyle.style.color?this.currentStyle.style.color.hex:"#000000","fo:background-color":this.currentStyle.style.bgcolor?this.currentStyle.style.bgcolor.hex:"transparent"}},this.parent.editorSession.updateParagraphStyle(t.name,e),this.notify(__("Paragraph format [{0}] is saved",t.text))}fromODFStyleFormat(e){var t,n,i;return this.initStyleObject(),t=new core.CSSUnits,n=e=>{var t,n,i,o,r;for(i=0,o=(n=this.ui.font.family.data).length;i=0&&(this.ui.font.family.selected=n)}if($(this.ui.style.color).css("background-color",this.currentStyle.style.color?this.currentStyle.style.color.hex:"#000000"),$(this.ui.style.bgcolor).css("background-color",this.currentStyle.style.bgcolor?this.currentStyle.style.bgcolor.hex:"transparent"),(e=$(this.preview)).css("text-align",this.currentStyle.aligment.selected?this.currentStyle.aligment.selected:"left"),e.css("margin-left",this.currentStyle.spacing.left+"mm"),e.css("margin-right",this.currentStyle.spacing.right+"mm"),e.css("margin-top",this.currentStyle.spacing.top+"mm"),e.css("margin-bottom",this.currentStyle.spacing.bottom+"mm"),e.css("padding-left",this.currentStyle.padding.left+"mm"),e.css("padding-right",this.currentStyle.padding.right+"mm"),e.css("padding-top",this.currentStyle.padding.top+"mm"),e.css("padding-bottom",this.currentStyle.padding.bottom+"mm"),e.css("font-weight","normal").css("font-style","normal").css("text-decoration","none").css("line-height","normal"),this.currentStyle.style.bold&&e.css("font-weight","bold"),this.currentStyle.style.italic&&e.css("font-style","italic"),this.currentStyle.style.underline&&e.css("text-decoration","underline"),e.css("color",this.currentStyle.style.color?this.currentStyle.style.color.hex:"#000000"),e.css("background-color",this.currentStyle.style.bgcolor?this.currentStyle.style.bgcolor.hex:"transparent"),e.css("font-size",this.currentStyle.font.size+"pt"),this.currentStyle.font.family&&e.css("font-family",this.currentStyle.font.family.name),this.currentStyle.spacing.lineheight>0)return e.css("line-height",this.currentStyle.spacing.lineheight+"mm")}}).scheme='\n \n
\n \n
\n \n
\n \n
\n
\n \n \n
\n \n \n \n \n \n \n \n \n
\n
\n
\n \n
\n \n
\n \n \n
\n \n \n
\n \n \n
\n \n \n
\n
\n
\n \n
\n \n
\n \n \n
\n \n \n
\n \n \n
\n \n \n
\n
\n \n
\n \n
\n \n
\n \n \n \n \n \n \n \n
\n
\n \n
\n
\n
\n
\n \n
\n \n
\n \n
\n \n \n
\n \n \n
\n
\n
\n \n
\n \n
\n
\n

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce laoreet diam vestibulum massa malesuada quis dignissim libero blandit. Duis sit amet volutpat nisl.

\n
\n
\n
\n \n
\n \n
\n \n
\n \n
\n
\n
\n
'}).call(this); /* 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.9";function Runtime(){}Runtime.prototype.getVariable=function(e){},Runtime.prototype.toJson=function(e){},Runtime.prototype.fromJson=function(e){},Runtime.prototype.byteArrayFromString=function(e,t){},Runtime.prototype.byteArrayToString=function(e,t){},Runtime.prototype.read=function(e,t,n,i){},Runtime.prototype.readFile=function(e,t,n){},Runtime.prototype.readFileSync=function(e,t){},Runtime.prototype.loadXML=function(e,t){},Runtime.prototype.writeFile=function(e,t,n){},Runtime.prototype.deleteFile=function(e,t){},Runtime.prototype.log=function(e,t){},Runtime.prototype.setTimeout=function(e,t){},Runtime.prototype.clearTimeout=function(e){},Runtime.prototype.libraryPaths=function(){},Runtime.prototype.currentDirectory=function(){},Runtime.prototype.setCurrentDirectory=function(e){},Runtime.prototype.type=function(){},Runtime.prototype.getDOMImplementation=function(){},Runtime.prototype.parseXML=function(e){},Runtime.prototype.exit=function(e){},Runtime.prototype.getWindow=function(){},Runtime.prototype.requestAnimationFrame=function(e){},Runtime.prototype.cancelAnimationFrame=function(e){},Runtime.prototype.assert=function(e,t){};var IS_COMPILED_CODE=!0;function BrowserRuntime(){function e(e){var t,n,i=e.length,o=0;for(t=0;tn&&(o+=1,t+=1);return o}function t(e,t,n){var i,o,r=e.length;for(t=new Uint8Array(new ArrayBuffer(t)),n?(t[0]=239,t[1]=187,t[2]=191,o=3):o=0,n=0;n(i=e.charCodeAt(n))?(t[o]=i,o+=1):2048>i?(t[o]=192|i>>>6,t[o+1]=128|63&i,o+=2):55040>=i||57344<=i?(t[o]=224|i>>>12&15,t[o+1]=128|i>>>6&63,t[o+2]=128|63&i,o+=3):(n+=1,i=65536+(i-55296<<10|e.charCodeAt(n)-56320),t[o]=240|i>>>18&7,t[o+1]=128|i>>>12&63,t[o+2]=128|i>>>6&63,t[o+3]=128|63&i,o+=4);return t}function n(e){var t,n=e.length,i=new Uint8Array(new ArrayBuffer(n));for(t=0;to.status||0===o.status?n(null):n("Status "+String(o.status)+": "+o.responseText||o.statusText):n("File "+e+" is empty."))},i=t.buffer&&!o.sendAsBinary?t.buffer:s.byteArrayToString(t,"binary");try{o.sendAsBinary?o.sendAsBinary(i):o.send(i)}catch(e){s.log("HUH? "+e+" "+t),n(e.message)}},this.deleteFile=function(e,t){var n=new XMLHttpRequest;n.open("DELETE",e,!0),n.onreadystatechange=function(){4===n.readyState&&(200>n.status&&300<=n.status?t(n.responseText):t(null))},n.send(null)},this.loadXML=function(e,t){var n=new XMLHttpRequest;n.open("GET",e,!0),n.overrideMimeType&&n.overrideMimeType("text/xml"),n.onreadystatechange=function(){4===n.readyState&&(0!==n.status||n.responseText?200===n.status||0===n.status?t(null,n.responseXML):t(n.responseText,null):t("File "+e+" is empty.",null))};try{n.send(null)}catch(e){t(e.message,null)}},this.log=i,this.enableAlerts=!0,this.assert=Runtime.assert,this.setTimeout=function(e,t){return setTimeout((function(){e()}),t)},this.clearTimeout=function(e){clearTimeout(e)},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(e){return(new DOMParser).parseFromString(e,"text/xml")},this.exit=function(e){i("Calling exit with code "+String(e)+", but exit() is not implemented.")},this.getWindow=function(){return window},this.requestAnimationFrame=function(e){var t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame;return t?(t.bind(window),t(e)):setTimeout(e,15)},this.cancelAnimationFrame=function(e){var t=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame;t?(t.bind(window),t(e)):clearTimeout(e)}}function NodeJSRuntime(){function e(e){var t,n=e.length,i=new Uint8Array(new ArrayBuffer(n));for(t=0;t").implementation}function RhinoRuntime(){var e,t,n=this,i={},o=i.javax.xml.parsers.DocumentBuilderFactory.newInstance(),r="";o.setValidating(!1),o.setNamespaceAware(!0),o.setExpandEntityReferences(!1),o.setSchema(null),t=i.org.xml.sax.EntityResolver({resolveEntity:function(e,t){var n=new i.java.io.FileReader(t);return new i.org.xml.sax.InputSource(n)}}),(e=o.newDocumentBuilder()).setEntityResolver(t),this.byteArrayFromString=function(e,t){var n,i=e.length,o=new Uint8Array(new ArrayBuffer(i));for(n=0;n(n=e[t])?l.push(n):(i=e[t+=1],194<=n&&224>n?l.push((31&n)<<6|63&i):(o=e[t+=1],224<=n&&240>n?l.push((15&n)<<12|(63&i)<<6|63&o):(r=e[t+=1],240<=n&&245>n&&(n=(7&n)<<18|(63&i)<<12|(63&o)<<6|63&r,n-=65536,l.push(55296+(n>>10),56320+(1023&n)))))),1e3<=l.length&&(a+=String.fromCharCode.apply(null,l),l.length=0);return a+String.fromCharCode.apply(null,l)}(e):("binary"!==t&&this.log("Unsupported encoding: "+t),n=function(e){var t,n="",i=e.length;for(t=0;t>>18],i+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[t>>>12&63],i+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[t>>>6&63],i+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[63&t];return n===o+1?(i+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(t=e[n]<<4)>>>6],i+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[63&t],i+="=="):n===o&&(i+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(t=e[n]<<10|e[n+1]<<2)>>>12],i+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[t>>>6&63],i+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[63&t],i+="="),i}function n(e){var t,n,i=(e=e.replace(/[^A-Za-z0-9+\/]+/g,"")).length,o=new Uint8Array(new ArrayBuffer(3*i)),r=e.length%4,a=0;for(t=0;t>16,o[a+1]=n>>8&255,o[a+2]=255&n,a+=3;return i=3*i-[0,0,2,1][r],o.subarray(0,i)}function i(e){var t,n,i=e.length,o=0,r=new Uint8Array(new ArrayBuffer(3*i));for(t=0;t(n=e[t])?r[o++]=n:(2048>n?r[o++]=192|n>>>6:(r[o++]=224|n>>>12&15,r[o++]=128|n>>>6&63),r[o++]=128|63&n);return r.subarray(0,o)}function o(e){var t,n,i,o,r=e.length,a=new Uint8Array(new ArrayBuffer(r)),s=0;for(t=0;t(n=e[t])?a[s++]=n:(i=e[t+=1],224>n?a[s++]=(31&n)<<6|63&i:(o=e[t+=1],a[s++]=(15&n)<<12|(63&i)<<6|63&o));return a.subarray(0,s)}function r(n){return t(e(n))}function a(e){return String.fromCharCode.apply(String,n(e))}function s(t){return o(e(t))}function l(e){e=o(e);for(var t="",n=0;n(t=255&e.charCodeAt(r))?a+=String.fromCharCode(t):(r+=1,i=255&e.charCodeAt(r),224>t?a+=String.fromCharCode((31&t)<<6|63&i):(r+=1,o=255&e.charCodeAt(r),a+=String.fromCharCode((15&t)<<12|(63&i)<<6|63&o)));return a}function d(e,t){var n="",i=0;1e5>e.length?t(u(e,0,e.length),!0):("string"!=typeof e&&(e=e.slice()),function o(){var r=i+1e5;r>e.length&&(r=e.length),n+=u(e,i,r),r=(i=r)===e.length,t(n,r)&&!r&&runtime.setTimeout(o,0)}())}function c(t){return i(e(t))}function f(e){return String.fromCharCode.apply(String,i(e))}function p(t){return String.fromCharCode.apply(String,i(e(t)))}var h,m,g,b,y=function(e){var t,n,i={};for(t=0,n=e.length;t=--a&&i.push(t(e.substring(n,o))):"["===e[o]&&(0>=a&&(n=o+1),a+=1),o+=1;return o},l=function(e,t,n){var r,l,u,d;for(r=0;r=e.compareBoundaryPoints(Range.START_TO_START,t)&&0<=e.compareBoundaryPoints(Range.END_TO_END,t)}function o(e,t){return 0>=e.compareBoundaryPoints(Range.END_TO_START,t)&&0<=e.compareBoundaryPoints(Range.START_TO_END,t)}function r(e,t){var n=null;return e.nodeType===Node.TEXT_NODE&&(0===e.length?(e.parentNode.removeChild(e),t.nodeType===Node.TEXT_NODE&&(n=t)):(t.nodeType===Node.TEXT_NODE&&(e.appendData(t.data),t.parentNode.removeChild(t)),n=e)),n}function a(e){for(var t=e.parentNode;e.firstChild;)t.insertBefore(e.firstChild,e);return t.removeChild(e),t}function s(e,t){return e===t||Boolean(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY)}function l(t,n){return e().unscaledRangeClientRects?t:t/n}var u=null;this.splitBoundaries=function(e){var t,i,o,r,a=[];if(e.startContainer.nodeType===Node.TEXT_NODE||e.endContainer.nodeType===Node.TEXT_NODE){if(i=e.endContainer,o=e.endContainer.nodeType!==Node.TEXT_NODE&&e.endOffset===e.endContainer.childNodes.length,(r=e.endOffset)<(t=e.endContainer).childNodes.length)for(t=t.childNodes.item(r),r=0;t.firstChild;)t=t.firstChild;else for(;t.lastChild;)r=(t=t.lastChild).nodeType===Node.TEXT_NODE?t.textContent.length:t.childNodes.length;if(t===i&&(i=null),e.setEnd(t,r),r=e.endContainer,0!==e.endOffset&&r.nodeType===Node.TEXT_NODE&&(t=r,e.endOffset!==t.length&&(a.push(t.splitText(e.endOffset)),a.push(t))),r=e.startContainer,0!==e.startOffset&&r.nodeType===Node.TEXT_NODE&&(t=r,e.startOffset!==t.length&&(r=t.splitText(e.startOffset),a.push(t),a.push(r),e.setStart(r,0))),null!==i){for(r=e.endContainer;r.parentNode&&r.parentNode!==i;)r=r.parentNode;o=o?i.childNodes.length:n(r,i),e.setEnd(i,o)}}return a},this.containsRange=i,this.rangesIntersect=o,this.rangeIntersection=function(e,t){var n;return o(e,t)&&(n=e.cloneRange(),-1===e.compareBoundaryPoints(Range.START_TO_START,t)&&n.setStart(t.startContainer,t.startOffset),1===e.compareBoundaryPoints(Range.END_TO_END,t)&&n.setEnd(t.endContainer,t.endOffset)),n},this.getNodesInRange=function(e,t,n){var i,o,r=[],a=(a=e.commonAncestorContainer).nodeType===Node.TEXT_NODE?a.parentNode:a;if(n=e.startContainer.ownerDocument.createTreeWalker(a,n,t,!1),e.endContainer.childNodes[e.endOffset-1]?(i=e.endContainer.childNodes[e.endOffset-1],o=Node.DOCUMENT_POSITION_PRECEDING|Node.DOCUMENT_POSITION_CONTAINED_BY):(i=e.endContainer,o=Node.DOCUMENT_POSITION_PRECEDING),e.startContainer.childNodes[e.startOffset])e=e.startContainer.childNodes[e.startOffset],n.currentNode=e;else{var s=e.startContainer;e.startOffset===(s.nodeType===Node.TEXT_NODE?s.length:s.childNodes.length)?(e=e.startContainer,n.currentNode=e,n.lastChild(),e=n.nextNode()):(e=e.startContainer,n.currentNode=e)}if(e){if((e=n.currentNode)!==a)for(e=e.parentNode;e&&e!==a;)t(e)===NodeFilter.FILTER_REJECT&&(n.currentNode=e),e=e.parentNode;switch(t(e=n.currentNode)){case NodeFilter.FILTER_REJECT:for(e=n.nextSibling();!e&&n.parentNode();)e=n.nextSibling();break;case NodeFilter.FILTER_SKIP:e=n.nextNode()}for(;e&&(0===(t=i.compareDocumentPosition(e))||0!=(t&o));)r.push(e),e=n.nextNode()}return r},this.normalizeTextNodes=function(e){e&&e.nextSibling&&(e=r(e,e.nextSibling)),e&&e.previousSibling&&r(e.previousSibling,e)},this.rangeContainsNode=function(e,t){var n,o=t.ownerDocument.createRange(),r=t.ownerDocument.createRange();return o.setStart(e.startContainer,e.startOffset),o.setEnd(e.endContainer,e.endOffset),r.selectNodeContents(t),n=i(o,r),o.detach(),r.detach(),n},this.mergeIntoParent=a,this.removeUnwantedNodes=function e(t,n){var i,o=t.parentNode,r=t.firstChild,s=n(t);if(s===NodeFilter.FILTER_SKIP)return o;for(;r;)i=r.nextSibling,e(r,n),r=i;return o&&s===NodeFilter.FILTER_REJECT&&a(t),o},this.removeAllChildNodes=function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},this.getElementsByTagNameNS=function(e,t,n){var i=[];for(e=e.getElementsByTagNameNS(t,n),i.length=n=e.length,t=0;te)throw runtime.log("alert","watchdog timeout"),"timeout!";if(0t)throw runtime.log("alert","watchdog loop overflow"),"loop overflow"}},core.NodeFilterChain=function(e){var t=NodeFilter.FILTER_REJECT,n=NodeFilter.FILTER_ACCEPT;this.acceptNode=function(i){var o;for(o=0;o "+e.length),runtime.assert(0<=t,"Error in setPosition: "+t+" < 0"),t===e.length&&(s.nextSibling()?l=0:s.parentNode()?l=1:runtime.assert(!1,"Error in setUnfilteredPosition: position not valid."))):te.value||"%"===e.unit)?null:e}function w(e){return(e=N(e))&&"%"!==e.unit?null:e}function E(e){switch(e.namespaceURI){case odf.Namespaces.drawns:case odf.Namespaces.svgns:case odf.Namespaces.dr3dns:return!1;case odf.Namespaces.textns:switch(e.localName){case"note-body":case"ruby-text":return!1}break;case odf.Namespaces.officens:switch(e.localName){case"annotation":case"binary-data":case"event-listeners":return!1}break;default:switch(e.localName){case"cursor":case"editinfo":return!1}}return!0}function T(e){return Boolean(r(e)&&(!s(e.textContent)||C(e,0)))}function O(e,t){for(;0=t.value||"%"===t.unit)?null:t)||w(e)},this.parseFoLineHeight=function(e){return x(e)||w(e)},this.isTextContentContainingNode=E,this.getTextNodes=function(e,t){var n;return n=k.getNodesInRange(e,(function(e){var t=NodeFilter.FILTER_REJECT;return e.nodeType===Node.TEXT_NODE?T(e)&&(t=NodeFilter.FILTER_ACCEPT):E(e)&&(t=NodeFilter.FILTER_SKIP),t}),NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),t||O(e,n),n},this.getTextElements=A,this.getParagraphElements=function(e){var t;return t=k.getNodesInRange(e,(function(e){var t=NodeFilter.FILTER_REJECT;return o(e)?t=NodeFilter.FILTER_ACCEPT:(E(e)||l(e))&&(t=NodeFilter.FILTER_SKIP),t}),NodeFilter.SHOW_ELEMENT),R(e.startContainer,t,o),t},this.getImageElements=function(t){var n;return n=k.getNodesInRange(t,(function(t){var n=NodeFilter.FILTER_SKIP;return e(t)&&(n=NodeFilter.FILTER_ACCEPT),n}),NodeFilter.SHOW_ELEMENT),R(t.startContainer,n,e),n},this.getHyperlinkElements=function(e){var t=[],n=e.cloneRange();return e.collapsed&&e.endContainer.nodeType===Node.ELEMENT_NODE&&(e=function(e,t){var n=e;if(t/g,">").replace(/'/g,"'").replace(/"/g,""")}function n(e,o){var r,a="",s=i.filter?i.filter.acceptNode(o):NodeFilter.FILTER_ACCEPT;if(s===NodeFilter.FILTER_ACCEPT&&o.nodeType===Node.ELEMENT_NODE){e.push(),r=e.getQName(o);var l,u,d,c,f=o.attributes,p="";for(l="<"+r,u=f.length,d=0;d")}if(s===NodeFilter.FILTER_ACCEPT||s===NodeFilter.FILTER_SKIP){for(s=o.firstChild;s;)a+=n(e,s),s=s.nextSibling;o.nodeValue&&(a+=t(o.nodeValue))}return r&&(a+="",e.pop()),a}var i=this;this.filter=null,this.writeToString=function(t,i){return t?n(new e(i),t):""}},function(){function e(e){var t,n=s.length;for(t=0;to);)r=r.nextSibling;t.insertBefore(n,r)}}}var o=new odf.StyleInfo,r=core.DomUtils,a=odf.Namespaces.stylens,s="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "),l=Date.now()+"_webodf_",u=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(e,t,n,i){var o=this;this.size=0,this.type=null,this.name=e,this.container=n,this.url=null,this.mimetype=t,this.onstatereadychange=this.document=null,this.EMPTY=0,this.LOADING=1,this.DONE=2,this.state=this.EMPTY,this.data="",this.load=function(){null!==i&&(this.mimetype=t,i.loadAsDataURL(e,t,(function(e,t){e&&runtime.log(e),o.url=t,o.onchange&&o.onchange(o),o.onstatereadychange&&o.onstatereadychange(o)})))}},odf.OdfPart.prototype.load=function(){},odf.OdfPart.prototype.getUrl=function(){return this.data?"data:;base64,"+u.toBase64(this.data):null},odf.OdfContainer=function e(s,d){function c(e){var t,n,i={},o=e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_ELEMENT,null,!1);for(e=o.nextNode();e;)"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===e.namespaceURI&&("annotation"===e.localName?(t=e.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))&&(i.hasOwnProperty(t)?runtime.log("Warning: annotation name used more than once with : '"+t+"'"):i[t]=e):"annotation-end"===e.localName&&((t=e.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))?i.hasOwnProperty(t)?(n=i[t]).annotationEndElement?runtime.log("Warning: annotation name used more than once with : '"+t+"'"):n.annotationEndElement=e:runtime.log("Warning: annotation end without an annotation start, name: '"+t+"'"):runtime.log("Warning: annotation end without a name found"))),e=o.nextNode()}function f(e,t){for(var n=e&&e.firstChild;n;)n.nodeType===Node.ELEMENT_NODE&&n.setAttributeNS("urn:webodf:names:scope","scope",t),n=n.nextSibling}function p(e,t){for(var n=(n=M.rootElement.meta)&&n.firstChild;n&&(n.namespaceURI!==e||n.localName!==t);)n=n.nextSibling;for(n=n&&n.firstChild;n&&n.nodeType!==Node.TEXT_NODE;)n=n.nextSibling;return n?n.data:null}function h(e){var t={};for(e=e.firstChild;e;)e.nodeType===Node.ELEMENT_NODE&&e.namespaceURI===a&&"font-face"===e.localName&&(t[e.getAttributeNS(a,"name")]=e),e=e.nextSibling;return t}function m(e,t){var n,i,o,r=null;if(e)for(n=(r=e.cloneNode(!0)).firstElementChild;n;)i=n.nextElementSibling,(o=n.getAttributeNS("urn:webodf:names:scope","scope"))&&o!==t&&r.removeChild(n),n=i;return r}function g(e,t){var n,i,r,s=null,l={};if(e)for(t.forEach((function(e){o.collectUsedFontFaces(l,e)})),n=(s=e.cloneNode(!0)).firstElementChild;n;)i=n.nextElementSibling,r=n.getAttributeNS(a,"name"),l[r]||s.removeChild(n),n=i;return s}function b(e){var t,n=M.rootElement.ownerDocument;if(e){!function e(t){for(var n,i=t.firstChild;i;)n=i.nextSibling,i.nodeType===Node.ELEMENT_NODE?e(i):i.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&t.removeChild(i),i=n}(e.documentElement);try{t=n.importNode(e.documentElement,!0)}catch(e){}}return t}function y(e){M.state=e,M.onchange&&M.onchange(M),M.onstatereadychange&&M.onstatereadychange(M)}function v(e){F=null,M.rootElement=e,e.fontFaceDecls=r.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),e.styles=r.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),e.automaticStyles=r.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),e.masterStyles=r.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),e.body=r.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body"),e.meta=r.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),e.settings=r.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),e.scripts=r.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","scripts"),c(e)}function S(t){var n,a=b(t),s=M.rootElement;a&&"document-styles"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI?(s.fontFaceDecls=r.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),i(s,s.fontFaceDecls),n=r.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),s.styles=n||t.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),i(s,s.styles),n=r.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),s.automaticStyles=n||t.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),f(s.automaticStyles,"document-styles"),i(s,s.automaticStyles),a=r.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),s.masterStyles=a||t.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),i(s,s.masterStyles),o.prefixStyleNames(s.automaticStyles,l,s.masterStyles)):y(e.INVALID)}function C(t){var n,s,l,u;if((t=b(t))&&"document-content"===t.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===t.namespaceURI){if(n=M.rootElement,l=r.getDirectChild(t,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),n.fontFaceDecls&&l){var d,c,p,m,g={};for(s=h(u=n.fontFaceDecls),m=h(l),l=l.firstElementChild;l;){if(d=l.nextElementSibling,l.namespaceURI===a&&"font-face"===l.localName)if(c=l.getAttributeNS(a,"name"),s.hasOwnProperty(c)){if(!l.isEqualNode(s[c])){var v=s,S=m,C=0,N=void 0;for(N=p=(p=c).replace(/\d+$/,"");v.hasOwnProperty(N)||S.hasOwnProperty(N);)N=p+(C+=1);p=N,l.setAttributeNS(a,"style:name",p),u.appendChild(l),s[p]=l,delete m[c],g[c]=p}}else u.appendChild(l),s[c]=l,delete m[c];l=d}u=g}else l&&(n.fontFaceDecls=l,i(n,l));if(f(s=r.getDirectChild(t,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),"document-content"),u&&o.changeFontFaceNames(s,u),n.automaticStyles&&s)for(u=s.firstChild;u;)n.automaticStyles.appendChild(u),u=s.firstChild;else s&&(n.automaticStyles=s,i(n,s));if(null===(t=r.getDirectChild(t,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body")))throw" tag is mising.";n.body=t,i(n,n.body)}else y(e.INVALID)}function N(e){var t;(e=b(e))&&"document-meta"===e.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===e.namespaceURI&&((t=M.rootElement).meta=r.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),i(t,t.meta))}function x(e){var t;(e=b(e))&&"document-settings"===e.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===e.namespaceURI&&((t=M.rootElement).settings=r.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),i(t,t.settings))}function w(e){var t;if((e=b(e))&&"manifest"===e.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===e.namespaceURI)for((t=M.rootElement).manifest=e,e=t.manifest.firstElementChild;e;)"file-entry"===e.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===e.namespaceURI&&(B[e.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","full-path")]=e.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","media-type")),e=e.nextElementSibling}function E(e,t,n){var i;for(e=r.getElementsByTagName(e,t),i=0;i'}function R(e,t){var n=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");return n.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",e),n.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:media-type",t),n}function _(e,t){var n,o=(n=M.rootElement).meta;o||(n.meta=o=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),i(n,o)),n=o,e&&r.mapKeyValObjOntoNode(n,e,odf.Namespaces.lookupNamespaceURI),t&&r.removeKeyElementsFromNode(n,t,odf.Namespaces.lookupNamespaceURI)}function P(t,n){function i(e,t){var n;t||(t=e),n=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",t),s[e]=n,s.appendChild(n)}var o=new core.Zip("",null),r="application/vnd.oasis.opendocument."+t+(!0===n?"-template":""),a=runtime.byteArrayFromString(r,"utf8"),s=M.rootElement,l=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",t);return o.save("mimetype",a,!1,new Date),i("meta"),i("settings"),i("scripts"),i("fontFaceDecls","font-face-decls"),i("styles"),i("automaticStyles","automatic-styles"),i("masterStyles","master-styles"),i("body"),s.body.appendChild(l),B["/"]=r,B["settings.xml"]="text/xml",B["meta.xml"]="text/xml",B["styles.xml"]="text/xml",B["content.xml"]="text/xml",y(e.DONE),o}function D(){var e,i=new Date,r="";M.rootElement.settings&&M.rootElement.settings.firstElementChild&&(e=new xmldom.LSSerializer,r=A("document-settings"),e.filter=new odf.OdfNodeFilter,r+=e.writeToString(M.rootElement.settings,odf.Namespaces.namespaceMap),r+=""),(e=r)?(e=runtime.byteArrayFromString(e,"utf8"),I.save("settings.xml",e,!0,i)):I.remove("settings.xml"),r=runtime.getWindow(),e="WebODF/"+webodf.Version,r&&(e=e+" "+r.navigator.userAgent),_({"meta:generator":e},null),e=runtime.byteArrayFromString(function(){var e=new xmldom.LSSerializer,t=A("document-meta");return e.filter=new odf.OdfNodeFilter,(t+=e.writeToString(M.rootElement.meta,odf.Namespaces.namespaceMap))+""}(),"utf8"),I.save("meta.xml",e,!0,i),e=runtime.byteArrayFromString(function(){var e,n,i,r=odf.Namespaces.namespaceMap,a=new xmldom.LSSerializer,s=A("document-styles");return n=m(M.rootElement.automaticStyles,"document-styles"),i=M.rootElement.masterStyles.cloneNode(!0),e=g(M.rootElement.fontFaceDecls,[i,M.rootElement.styles,n]),o.removePrefixFromStyleNames(n,l,i),a.filter=new t(i,n),s+=a.writeToString(e,r),s+=a.writeToString(M.rootElement.styles,r),s+=a.writeToString(n,r),(s+=a.writeToString(i,r))+""}(),"utf8"),I.save("styles.xml",e,!0,i),e=runtime.byteArrayFromString(function(){var e,t,i=odf.Namespaces.namespaceMap,o=new xmldom.LSSerializer,r=A("document-content");return t=m(M.rootElement.automaticStyles,"document-content"),e=g(M.rootElement.fontFaceDecls,[t]),o.filter=new n(M.rootElement.body,t),r+=o.writeToString(e,i),r+=o.writeToString(t,i),(r+=o.writeToString(M.rootElement.body,i))+""}(),"utf8"),I.save("content.xml",e,!0,i),e=runtime.byteArrayFromString(function(){var e,t=runtime.parseXML(''),n=t.documentElement,i=new xmldom.LSSerializer;for(e in B)B.hasOwnProperty(e)&&n.appendChild(R(e,B[e]));return i.filter=new odf.OdfNodeFilter,'\n'+i.writeToString(t,odf.Namespaces.namespaceMap)}(),"utf8"),I.save("META-INF/manifest.xml",e,!0,i)}function k(e,t){D(),I.writeAs(e,(function(e){t(e)}))}var I,F,M=this,B={},U="";this.onstatereadychange=d,this.state=this.onchange=null,this.getMetadata=p,this.setRootElement=v,this.getContentElement=function(){var e;if(F||(e=M.rootElement.body,F=r.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","text")||r.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","presentation")||r.getDirectChild(e,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","spreadsheet")),!F)throw"Could not find content element in .";return F},this.getDocumentType=function(){var e=M.getContentElement();return e&&e.localName},this.isTemplate=function(){return"-template"===B["/"].substr(-9)},this.setIsTemplate=function(e){var t=B["/"];e!==("-template"===t.substr(-9))&&(t=e?t+"-template":t.substr(0,t.length-9),B["/"]=t,e=runtime.byteArrayFromString(t,"utf8"),I.save("mimetype",e,!1,new Date))},this.getPart=function(e){return new odf.OdfPart(e,B[e],M,I)},this.getPartData=function(e,t){I.load(e,t)},this.setMetadata=_,this.incrementEditingCycles=function(){var e=(e=p(odf.Namespaces.metans,"editing-cycles"))?parseInt(e,10):0;return isNaN(e)&&(e=0),_({"meta:editing-cycles":e+1},null),e+1},this.createByteArray=function(e,t){D(),I.createByteArray(e,t)},this.saveAs=k,this.save=function(e){k(U,e)},this.getUrl=function(){return U},this.setBlob=function(e,t,n){n=u.convertBase64ToByteArray(n),I.save(e,n,!1,new Date),B.hasOwnProperty(e)&&runtime.log(e+" has been overwritten."),B[e]=t},this.removeBlob=function(e){var t=I.remove(e);runtime.assert(t,"file is not found: "+e),delete B[e]},this.state=e.LOADING,this.rootElement=function(e){var t,n=document.createElementNS(e.namespaceURI,e.localName);for(t in e=new e.Type)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}({Type:odf.ODFDocumentElement,namespaceURI:odf.ODFDocumentElement.namespaceURI,localName:odf.ODFDocumentElement.localName}),s===odf.OdfContainer.DocumentType.TEXT?I=P("text"):s===odf.OdfContainer.DocumentType.TEXT_TEMPLATE?I=P("text",!0):s===odf.OdfContainer.DocumentType.PRESENTATION?I=P("presentation"):s===odf.OdfContainer.DocumentType.PRESENTATION_TEMPLATE?I=P("presentation",!0):s===odf.OdfContainer.DocumentType.SPREADSHEET?I=P("spreadsheet"):s===odf.OdfContainer.DocumentType.SPREADSHEET_TEMPLATE?I=P("spreadsheet",!0):(U=s,I=new core.Zip(U,(function(t,n){I=n,t?function(t,n){runtime.loadXML(t,(function(t,i){if(t)n(t);else if(i){T(i),O(i.documentElement);var o=b(i);o&&"document"===o.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===o.namespaceURI?(v(o),y(e.DONE)):y(e.INVALID)}else n("No DOM was loaded.")}))}(U,(function(n){t&&(I.error=t+"\n"+n,y(e.INVALID))})):function t(n){var i=n.shift();i?I.loadAsDOM(i.path,(function(o,r){r&&(T(r),O(r.documentElement)),i.handler(r),M.state===e.INVALID?o?runtime.log("ERROR: Unable to load "+i.path+" - "+o):runtime.log("ERROR: Unable to load "+i.path):(o&&runtime.log("DEBUG: Unable to load "+i.path+" - "+o),t(n))})):(c(M.rootElement),y(e.DONE))}([{path:"styles.xml",handler:S},{path:"content.xml",handler:C},{path:"meta.xml",handler:N},{path:"settings.xml",handler:x},{path:"META-INF/manifest.xml",handler:w}])})))},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(e){return new odf.OdfContainer(e,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(e,t,n,i){function o(e){var t=e.annotationEndElement,n=u.createRange(),i=e.getAttributeNS(odf.Namespaces.officens,"name");t&&(n.setStart(e,e.childNodes.length),n.setEnd(t,0),(e=d.getTextNodes(n,!1)).forEach((function(e){var t;e:{for(t=e.parentNode;t.namespaceURI!==odf.Namespaces.officens||"body"!==t.localName;){if("http://www.w3.org/1999/xhtml"===t.namespaceURI&&"webodf-annotationHighlight"===t.className&&t.getAttribute("annotation")===i){t=!0;break e}t=t.parentNode}t=!1}t||((t=u.createElement("span")).className="webodf-annotationHighlight",t.setAttribute("annotation",i),e.parentNode.replaceChild(t,e),t.appendChild(e))}))),n.detach()}function r(t){var i=e.getSizer();t?(n.style.display="inline-block",i.style.paddingRight=c.getComputedStyle(n).width):(n.style.display="none",i.style.paddingRight=0),e.refreshSize()}function a(){var t;for(t=0;t=(r.getBoundingClientRect().top-s.bottom)/u?i.style.top=Math.abs(r.getBoundingClientRect().top-s.bottom)/u+20+"px":i.style.top="0px"):i.style.top="0px",o.style.left=d.getBoundingClientRect().width/u+"px";var d=o.style,c=(r=o.getBoundingClientRect().left/u,a=o.getBoundingClientRect().top/u,0),f=0;c=(c=(s=i.getBoundingClientRect().left/u)-r)*c,f=(f=i.getBoundingClientRect().top/u-a)*f,r=Math.sqrt(c+f),d.width=r+"px",a=Math.asin((i.getBoundingClientRect().top-o.getBoundingClientRect().top)/(u*parseFloat(o.style.width))),o.style.transform="rotate("+a+"rad)",o.style.MozTransform="rotate("+a+"rad)",o.style.WebkitTransform="rotate("+a+"rad)",o.style.msTransform="rotate("+a+"rad)"}}function s(e){var t=l.indexOf(e);"div"===(i=e.parentNode.parentNode).localName&&(i.parentNode.insertBefore(e,i),i.parentNode.removeChild(i)),e=e.getAttributeNS(odf.Namespaces.officens,"name"),e=u.querySelectorAll('span.webodf-annotationHighlight[annotation="'+e+'"]');for(var n,i=0;ia||t.bottom>a)&&(e.scrollTop=t.bottom-t.top<=a-o?e.scrollTop+(t.bottom-a):e.scrollTop+(t.top-o)),t.leftr&&(e.scrollLeft=t.right-t.left<=r-i?e.scrollLeft+(t.right-r):e.scrollLeft-(i-t.left)))}},function(){function e(t,n,o,r,a){var s,l,u=0;for(l in t)if(t.hasOwnProperty(l)){if(u===o){s=l;break}u+=1}s?n.getPartData(t[s].href,(function(l,u){if(l)runtime.log(l);else if(u){var d="@font-face { font-family: "+(t[s].family||s)+"; src: url(data:application/x-font-ttf;charset=binary;base64,"+i.convertUTF8ArrayToBase64(u)+') format("truetype"); }';try{r.insertRule(d,r.cssRules.length)}catch(e){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(e)+"\nRule: "+d)}}else runtime.log("missing font data for "+t[s].href);e(t,n,o+1,r,a)})):a&&a()}var t=xmldom.XPath,n=odf.OdfUtils,i=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(i,o){for(var r=i.rootElement.fontFaceDecls;o.cssRules.length;)o.deleteRule(o.cssRules.length-1);if(r){var a,s,l,u,d={};if(r)for(r=t.getODFElementsWithXPath(r,"style:font-face[svg:font-face-src]",odf.Namespaces.lookupNamespaceURI),a=0;a text|list-item:first-child > :not(text|list):first-child:before',f+="{",f+="counter-increment: "+(c=d)+" 0;",e(n,f+="}"));l.counterIdStack.length>=u;)l.counterIdStack.pop();for(l.counterIdStack.push(c),p=l.contentRules[u.toString()]||"",f=1;f<=u;f+=1)p=p.replace(f+"webodf-listLevel",l.counterIdStack[f-1]);f='text|list[webodfhelper|counter-id="'+d+'"] > text|list-item > :not(text|list):first-child:before',f+="{",f+=p,f+="counter-increment: "+c+";",e(n,f+="}")}for(o=o.firstElementChild;o;)i(t,o,a,l),o=o.nextElementSibling}else l.continuedCounterIdStack=[]}var o=0,s="",l={};this.createCounterRules=function(e,n,r){var s=n.getAttributeNS(a,"id"),u=[];r&&(r=r.getAttributeNS("urn:webodf:names:helper","counter-id"),u=l[r].slice(0)),e=new t(e,u),i(s=s?"Y"+s:"X"+(o+=1),n,0,e),l[s+"-level1-1"]=e.counterIdStack},this.initialiseCreatedCounters=function(){var t;t="office|document{counter-reset: "+s+";",e(n,t+="}")}}var i=odf.Namespaces.fons,o=odf.Namespaces.stylens,r=odf.Namespaces.textns,a=odf.Namespaces.xmlns,s={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"};odf.ListStyleToCss=function(){function t(e){var t=f.parseLength(e);return t?c.convert(t.value,t.unit,"px"):(runtime.log("Could not parse value '"+e+"'."),0)}function l(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function u(e,t){var n;return e&&(n=e.getAttributeNS(r,"style-name")),n===t}function d(e,t,i){t=t.getElementsByTagNameNS(r,"list"),e=new n(e);var d,c,f,p,h,m,g,b={};for(g=0;g text|list-item > text|list",--p;switch(p=h&&h.getAttributeNS(i,"text-align")||"left"){case"end":p="right";break;case"start":p="left"}"label-alignment"===m?(b=g&&g.getAttributeNS(i,"margin-left")||"0px",S=g&&g.getAttributeNS(i,"text-indent")||"0px",C=g&&g.getAttributeNS(r,"label-followed-by"),g=t(b)):(b=h&&h.getAttributeNS(r,"space-before")||"0px",y=h&&h.getAttributeNS(r,"min-label-width")||"0px",v=h&&h.getAttributeNS(r,"min-label-distance")||"0px",g=t(b)+t(y)),h=c+" > text|list-item",h+="{",h+="margin-left: "+g+"px;",e(u,h+="}"),h=c+" > text|list-item > text|list",h+="{",h+="margin-left: "+-g+"px;",e(u,h+="}"),h=c+" > text|list-item > :not(text|list):first-child:before",h+="{",h+="text-align: "+p+";",h+="display: inline-block;","label-alignment"===m?(h+="margin-left: "+S+";","listtab"===C&&(h+="padding-right: 0.2cm;")):(h+="min-width: "+y+";",h+="margin-left: "+(0===parseFloat(y)?"":"-")+y+";",h+="padding-right: "+v+";"),e(u,h+="}")}s=s.nextElementSibling}})),d(n,s,l)}}}(),odf.LazyStyleProperties=function(e,t){var n={};this.value=function(i){var o;return n.hasOwnProperty(i)?o=n[i]:(void 0===(o=t[i]())&&e&&(o=e.value(i)),n[i]=o),o},this.reset=function(t){e=t,n={}}},odf.StyleParseUtils=function(){function e(e){var t,n;return"px"===(n=(e=(e=/(-?[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(e))?{value:parseFloat(e[1]),unit:e[3]}:null)&&e.unit)?t=e.value:"cm"===n?t=e.value/2.54*96:"mm"===n?t=e.value/25.4*96:"in"===n?t=96*e.value:"pt"===n?t=e.value/.75:"pc"===n&&(t=16*e.value),t}var t=odf.Namespaces.stylens;this.parseLength=e,this.parsePositiveLengthOrPercent=function(t,n,i){var o,r;return t&&(o=parseFloat(t.substr(0,t.indexOf("%"))),isNaN(o)&&(o=void 0)),void 0!==o?(i&&(r=i.value(n)),o=void 0===r?void 0:r/100*o):o=e(t),o},this.getPropertiesElement=function(e,n,i){for(n=i?i.nextElementSibling:n.firstElementChild;null!==n&&(n.localName!==e||n.namespaceURI!==t);)n=n.nextElementSibling;return n},this.parseAttributeList=function(e){return e&&(e=e.replace(/^\s*(.*?)\s*$/g,"$1")),e&&0l.value&&(s="0.75pt"+r),r=s}else if(P.hasOwnProperty(o[1])){s=e;var u=o[0],d=(l=o[1],k.parseLength(r)),f=void 0,p=void 0,h=void 0,m=void 0;if(h=void 0,d&&"%"===d.unit){for(f=d.value/100,p=t(s.parentNode),m="0";p;){if((h=g.getDirectChild(p,c,"paragraph-properties"))&&(h=k.parseLength(h.getAttributeNS(u,l)))){if("%"!==h.unit){m=h.value*f+h.unit;break}f*=h.value/100}p=t(p)}r=m}}o[2]&&(a+=o[2]+":"+r+";")}return a}function i(e,t,n,i){return t+t+n+n+i+i}function o(a,f,y,v){var _,P;if("page"===f){var I,M,B,U=v.element,L="";if(M=I="",y=g.getDirectChild(U,c,"page-layout-properties"))if(B=U.getAttributeNS(c,"name"),L+=n(y,A),(I=g.getDirectChild(y,c,"background-image"))&&(M=I.getAttributeNS(h,"href"))&&(L=L+"background-image: url('odfkit:"+M+"');"+n(I,C)),"presentation"===r)for(U=(U=g.getDirectChild(U.parentNode.parentNode,d,"master-styles"))&&U.firstElementChild;U;)U.namespaceURI===c&&"master-page"===U.localName&&U.getAttributeNS(c,"page-layout-name")===B&&(I='draw|page[draw|master-page-name="'+(M=U.getAttributeNS(c,"name"))+'"] {'+L+"}",M='office|body, draw|page[draw|master-page-name="'+M+'"] {'+n(y,R)+" }",a.insertRule(I,a.cssRules.length),a.insertRule(M,a.cssRules.length)),U=U.nextElementSibling;else"text"===r&&(I="office|text {"+L+"}",M="office|body {width: "+y.getAttributeNS(u,"page-width")+";}",a.insertRule(I,a.cssRules.length),a.insertRule(M,a.cssRules.length))}else{if(L=e(f,y,v).join(","),B="",U=g.getDirectChild(v.element,c,"text-properties")){var z=U,H=P="";switch(I="",M=1,U=""+n(z,S),"solid"===(_=z.getAttributeNS(c,"text-underline-style"))&&(P+=" underline"),"solid"===(_=z.getAttributeNS(c,"text-line-through-style"))&&(P+=" line-through"),P.length&&(U=U+"text-decoration:"+P+";\ntext-decoration-line:"+P+";\n",U+="-moz-text-decoration-line:"+P+";\n"),_=z.getAttributeNS(c,"text-line-through-type")){case"double":H+=" double";break;case"single":H+=" single"}if(H&&(U+="text-decoration-style:"+H+";\n",U+="-moz-text-decoration-style:"+H+";\n"),(P=z.getAttributeNS(c,"font-name")||z.getAttributeNS(u,"font-family"))&&(U+="font-family: "+((_=D[P])||P)+";"),(_=z.getAttributeNS(c,"text-position"))&&(U+="vertical-align: "+(_=(P=b.parseAttributeList(_))[0])+"\n; ",(P=P[1])&&(M=parseFloat(P)/100)),z.hasAttributeNS(u,"font-size")||1!==M){for(z=z.parentNode;z;){if(_=(_=g.getDirectChild(z,c,"text-properties"))?k.parseFoFontSize(_.getAttributeNS(u,"font-size")):null){if("%"!==_.unit){I="font-size: "+_.value*M+_.unit+";";break}M*=_.value/100}z=t(z)}I||(I="font-size: "+parseFloat(s)*M+F.getUnits(s)+";")}B+=U+=I}(U=g.getDirectChild(v.element,c,"paragraph-properties"))&&(U=""+n(I=U,N),(M=g.getDirectChild(I,c,"background-image"))&&(z=M.getAttributeNS(h,"href"))&&(U=U+"background-image: url('odfkit:"+z+"');"+n(M,C)),(I=I.getAttributeNS(u,"line-height"))&&"normal"!==I&&(U="%"!==(I=k.parseFoLineHeight(I)).unit?U+"line-height: "+I.value+I.unit+";":U+"line-height: "+I.value/100+";"),B+=U),(U=g.getDirectChild(v.element,c,"graphic-properties"))&&(U=""+n(z=U,x),I=z.getAttributeNS(l,"opacity"),M=z.getAttributeNS(l,"fill"),z=z.getAttributeNS(l,"fill-color"),"solid"===M||"hatch"===M?z&&"none"!==z?(I=isNaN(parseFloat(I))?1:parseFloat(I)/100,M=z.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,i),(z=(M=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(M))?{r:parseInt(M[1],16),g:parseInt(M[2],16),b:parseInt(M[3],16)}:null)&&(U+="background-color: rgba("+z.r+","+z.g+","+z.b+","+I+");")):U+="background: none;":"none"===M&&(U+="background: none;"),B+=U),(U=g.getDirectChild(v.element,c,"drawing-page-properties"))&&(M=""+n(I=U,x),"true"===I.getAttributeNS(m,"background-visible")&&(M+="background: none;"),B+=M,function(e,t,n,i){function o(t,n){var i,o=[];t.forEach((function(e){r.forEach((function(t){o.push('draw|page[webodfhelper|page-style-name="'+t+'"] draw|frame[presentation|class="'+e+'"]')}))})),0h&&(e=h),t=Math.floor(e/n)*n;!i&&0<=t;)i=m[t],t-=n;for(i=i||p;i.nextBookmark&&i.nextBookmark.steps<=e;)o.check(),i=i.nextBookmark;return runtime.assert(-1===e||i.steps<=e,"Bookmark @"+a(i)+" at step "+i.steps+" exceeds requested step of "+e),i}function c(e){e.previousBookmark&&(e.previousBookmark.nextBookmark=e.nextBookmark),e.nextBookmark&&(e.nextBookmark.previousBookmark=e.previousBookmark)}function f(e){for(var n,i=null;!i&&e&&e!==t;)(n=l(e))&&(i=g[n])&&i.node!==e&&(runtime.log("Cloned node detected. Creating new bookmark"),i=null,e.removeAttributeNS("urn:webodf:names:steps","nodeId")),e=e.parentNode;return i}var p,h,m={},g={},b=core.DomUtils,y=Node.DOCUMENT_POSITION_FOLLOWING,v=Node.DOCUMENT_POSITION_PRECEDING;this.updateBookmark=function(e,i){var r,a,f,v,S=Math.ceil(e/n)*n;if(void 0!==h&&ha.steps)&&(m[S]=f),s()},this.setToClosestStep=function(e,t){var n;return s(),(n=d(e)).setIteratorPosition(t),n.steps},this.setToClosestDomPoint=function(e,n,i){var o,r;if(s(),e===t&&0===n)o=p;else if(e===t&&n===t.childNodes.length)for(r in o=p,m)m.hasOwnProperty(r)&&(e=m[r]).steps>o.steps&&(o=e);else if(!(o=f(e.childNodes.item(n)||e)))for(i.setUnfilteredPosition(e,n);!o&&i.previousNode();)o=f(i.getCurrentNode());return o=o||p,void 0!==h&&o.steps>h&&(o=d(h)),o.setIteratorPosition(i),o.steps},this.damageCacheAfterStep=function(e){0>e&&(e=-1),(void 0===h||ee)throw new RangeError("Requested steps is negative ("+e+")");for(i=a.setToClosestStep(e,t);il.comparePoints(e,0,i,s),i=e,s=s?0:e.childNodes.length),t.setUnfilteredPosition(i,s),r(t,d)||t.setUnfilteredPosition(i,s),d=t.container(),s=t.unfilteredDomOffset(),i=a.setToClosestDomPoint(d,s,t),0>l.comparePoints(t.container(),t.unfilteredDomOffset(),d,s))return 0=l.textNode.length?null:l.textNode.splitText(l.offset)),c=l.textNode;c!==d;){if(f=(c=c.parentNode).cloneNode(!1),p&&f.appendChild(p),h)for(;h&&h.nextSibling;)f.appendChild(h.nextSibling);else for(;c.firstChild;)f.appendChild(c.firstChild);c.parentNode.insertBefore(f,c.nextSibling),h=c,p=f}return a.isListItem(p)&&(p=p.childNodes.item(0)),r?p.setAttributeNS(s,"text:style-name",r):p.removeAttributeNS(s,"style-name"),0===l.textNode.length&&l.textNode.parentNode.removeChild(l.textNode),n.emit(ops.OdtDocument.signalStepsInserted,{position:i}),m&&o&&(n.moveCursor(e,i+1,0),n.emit(ops.Document.signalCursorMoved,m)),n.fixCursorPositions(),n.getOdfCanvas().refreshSize(),n.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:u,memberId:e,timeStamp:t}),n.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:p,memberId:e,timeStamp:t}),n.getOdfCanvas().rerenderAnnotations(),!0},this.spec=function(){return{optype:"SplitParagraph",memberid:e,timestamp:t,position:i,sourceParagraphPosition:n,paragraphStyleName:r,moveCursor:o}}},ops.OpUpdateMember=function(){var e,t,n,i;this.init=function(o){e=o.memberid,t=parseInt(o.timestamp,10),n=o.setProperties,i=o.removedProperties},this.isEdit=!1,this.group=void 0,this.execute=function(t){var o=t.getMember(e);return!!o&&(i&&o.removeProperties(i),n&&(o.setProperties(n),n.fullName&&function(t){var i="//dc:creator[@editinfo:memberid='"+e+"']";for(t=xmldom.XPath.getODFElementsWithXPath(t.getRootNode(),i,(function(e){return"editinfo"===e?"urn:webodf:names:editinfo":odf.Namespaces.lookupNamespaceURI(e)})),i=0;i=r.width&&(r=null),o.detach()):(t.isCharacterElement(e.container)||t.isCharacterFrame(e.container))&&(r=i.getBoundingClientRect(e.container))),r}var t=odf.OdfUtils,n=new odf.StepUtils,i=core.DomUtils,o=core.StepDirection.NEXT,r=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT,a=gui.StepInfo.VisualDirection.RIGHT_TO_LEFT;this.getContentRect=e,this.moveToFilteredStep=function(t,n,i){function s(e,t){return t.process(p,d,c)&&(e=!0,!f&&t.token&&(f=t.token)),e}var l,u,d,c,f,p,h=n===o,m=t.snapshot();l=!1;do{l=e(t),p={token:t.snapshot(),container:t.container,offset:t.offset,direction:n,visualDirection:n===o?r:a},u=t.nextStep()?e(t):null,t.restore(p.token),h?(d=l,c=u):(d=u,c=l),l=i.reduce(s,!1)}while(!l&&t.advanceStep(n));return l||i.forEach((function(e){!f&&e.token&&(f=e.token)})),t.restore(f||m),Boolean(f)}},gui.Caret=function(e,t,n,i){function o(){d.style.opacity="0"===d.style.opacity?"1":"0",b.trigger()}function r(){return h.selectNodeContents(p),h.getBoundingClientRect()}function a(e){return E[e]!==w[e]}function s(){if(!1===w.isShown||e.getSelectionType()!==ops.OdtCursor.RangeSelection||!i&&!e.getSelectedRange().collapsed?(w.visibility="hidden",d.style.visibility="hidden",b.cancel()):(w.visibility="visible",d.style.visibility="visible",!1===w.isFocused?(d.style.opacity="1",b.cancel()):((C||a("visibility"))&&(d.style.opacity="1",b.cancel()),b.trigger())),x||N){var n;n=e.getNode();var o,s,l=v.getBoundingClientRect(y.getSizer()),p=!1,h=0;if(n.removeAttributeNS("urn:webodf:names:cursor","caret-sizer-active"),0(n={top:(s=v.translateRect(s,l,y.getZoomLevel())).top,height:s.height,right:p?s.left:s.right,width:v.adaptRangeDifferenceToZoomLevel(h,y.getZoomLevel())}).height&&(n={top:n.top-(8-n.height)/2,height:8,right:n.right}),u.style.height=n.height+"px",u.style.top=n.top+"px",u.style.left=n.right-n.width+"px",u.style.width=n.width?n.width+"px":"",f&&((n=runtime.getWindow().getComputedStyle(e.getNode(),null)).font?f.style.font=n.font:(f.style.fontStyle=n.fontStyle,f.style.fontVariant=n.fontVariant,f.style.fontWeight=n.fontWeight,f.style.fontSize=n.fontSize,f.style.lineHeight=n.lineHeight,f.style.fontFamily=n.fontFamily))}w.isShown&&N&&t.scrollIntoView(d.getBoundingClientRect()),a("isFocused")&&c.markAsFocussed(w.isFocused),Object.keys(w).forEach((function(e){E[e]=w[e]})),x=N=C=!1}function l(e){u.parentNode.removeChild(u),p.parentNode.removeChild(p),e()}var u,d,c,f,p,h,m,g,b,y=e.getDocument().getCanvas(),v=core.DomUtils,S=new gui.GuiStepUtils,C=!1,N=!1,x=!1,w={isFocused:!1,isShown:!0,visibility:"hidden"},E={isFocused:!w.isFocused,isShown:!w.isShown,visibility:"hidden"};this.handleUpdate=function(){x=!0,g.trigger()},this.refreshCursorBlinking=function(){C=!0,g.trigger()},this.setFocus=function(){w.isFocused=!0,g.trigger()},this.removeFocus=function(){w.isFocused=!1,g.trigger()},this.show=function(){w.isShown=!0,g.trigger()},this.hide=function(){w.isShown=!1,g.trigger()},this.setAvatarImageUrl=function(e){c.setImageUrl(e)},this.setColor=function(e){d.style.borderColor=e,c.setColor(e)},this.getCursor=function(){return e},this.getFocusElement=function(){return d},this.toggleHandleVisibility=function(){c.isVisible()?c.hide():c.show()},this.showHandle=function(){c.show()},this.hideHandle=function(){c.hide()},this.setOverlayElement=function(e){f=e,u.appendChild(e),x=!0,g.trigger()},this.ensureVisible=function(){N=!0,g.trigger()},this.getBoundingClientRect=function(){return v.getBoundingClientRect(u)},this.destroy=function(e){core.Async.destroyAll([g.destroy,b.destroy,c.destroy,l],e)},function(){var t=e.getDocument(),i=[t.createRootFilter(e.getMemberId()),t.getPositionFilter()],r=t.getDOMDocument();h=r.createRange(),(p=r.createElement("span")).className="webodf-caretSizer",p.textContent="|",e.getNode().appendChild(p),(u=r.createElement("div")).setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",e.getMemberId()),u.className="webodf-caretOverlay",(d=r.createElement("div")).className="caret",u.appendChild(d),c=new gui.Avatar(u,n),y.getSizer().appendChild(u),m=t.createStepIterator(e.getNode(),0,i,t.getRootNode()),g=core.Task.createRedrawTask(s),b=core.Task.createTimeoutTask(o,500),g.triggerImmediate()}()},odf.TextSerializer=function(){var e=this,t=odf.OdfUtils;this.filter=null,this.writeToString=function(n){return n?("\n"===(n=function n(i){var o,r="",a=e.filter?e.filter.acceptNode(i):NodeFilter.FILTER_ACCEPT,s=i.nodeType;if((a===NodeFilter.FILTER_ACCEPT||a===NodeFilter.FILTER_SKIP)&&t.isTextContentContainingNode(i))for(o=i.firstChild;o;)r+=n(o),o=o.nextSibling;return a===NodeFilter.FILTER_ACCEPT&&(s===Node.ELEMENT_NODE&&t.isParagraph(i)?r+="\n":s===Node.TEXT_NODE&&i.textContent&&(r+=i.textContent)),r}(n))[n.length-1]&&(n=n.substr(0,n.length-1)),n):""}},gui.MimeDataExporter=function(){var e;this.exportRangeToDataTransfer=function(t,n){var i;(i=n.startContainer.ownerDocument.createElement("span")).appendChild(n.cloneContents()),i=e.writeToString(i);try{t.setData("text/plain",i)}catch(e){t.setData("Text",i)}},(e=new odf.TextSerializer).filter=new odf.OdfNodeFilter},gui.Clipboard=function(e){this.setDataFromRange=function(t,n){var i,o=t.clipboardData;return i=runtime.getWindow(),!o&&i&&(o=i.clipboardData),o?(i=!0,e.exportRangeToDataTransfer(o,n),t.preventDefault()):i=!1,i}},gui.SessionContext=function(e,t){var n=e.getOdtDocument(),i=odf.OdfUtils;this.isLocalCursorWithinOwnAnnotation=function(){var e,o=n.getCursor(t);return!(!o||(e=o&&o.getNode(),o=n.getMember(t).getProperties().fullName,!(e=i.getParentAnnotation(e,n.getRootNode()))||i.getAnnotationCreator(e)!==o))}},gui.StyleSummary=function(e){function t(t,n){var i,r=t+"|"+n;return o.hasOwnProperty(r)||(i=[],e.forEach((function(e){e=(e=e.styleProperties[t])&&e[n],-1===i.indexOf(e)&&i.push(e)})),o[r]=i),o[r]}function n(e,n,i){return function(){var o=t(e,n);return i.length>=o.length&&o.every((function(e){return-1!==i.indexOf(e)}))}}function i(e,n){var i=t(e,n);return 1===i.length?i[0]:void 0}var o={};this.getPropertyValues=t,this.getCommonValue=i,this.isBold=n("style:text-properties","fo:font-weight",["bold"]),this.isItalic=n("style:text-properties","fo:font-style",["italic"]),this.hasUnderline=n("style:text-properties","style:text-underline-style",["solid"]),this.hasStrikeThrough=n("style:text-properties","style:text-line-through-style",["solid"]),this.fontSize=function(){var e=i("style:text-properties","fo:font-size");return e&&parseFloat(e)},this.fontName=function(){return i("style:text-properties","style:font-name")},this.isAlignedLeft=n("style:paragraph-properties","fo:text-align",["left","start"]),this.isAlignedCenter=n("style:paragraph-properties","fo:text-align",["center"]),this.isAlignedRight=n("style:paragraph-properties","fo:text-align",["right","end"]),this.isAlignedJustified=n("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(e,t,n,i,o,r,a){function s(){return D.value().styleSummary}function l(){return D.value().enabledFeatures}function u(e){var t;return e.collapsed?((t=e.startContainer).hasChildNodes()&&e.startOffsete.clientWidth||e.scrollHeight>e.clientHeight)&&t.push(new u(e)),e=e.parentNode;return t.push(new l(y)),t}(b),m(),b.focus(),e.forEach((function(e){e.restore()})))}var b,y=runtime.getWindow(),v={beforecut:!0,beforepaste:!0,longpress:!0,drag:!0,dragstop:!0},S={mousedown:!0,mouseup:!0,focus:!0},C={},N={},x=e.getCanvas().getElement(),w=this,E={};this.addFilter=function(e,t){d(e,!0).filters.push(t)},this.removeFilter=function(e,t){var n=d(e,!0),i=n.filters.indexOf(t);-1!==i&&n.filters.splice(i,1)},this.subscribe=c,this.unsubscribe=f,this.hasFocus=p,this.focus=g,this.getEventTrap=function(){return b},this.setEditing=function(e){var t=p();t&&b.blur(),e?b.removeAttribute("readOnly"):b.setAttribute("readOnly","true"),t&&g()},this.destroy=function(e){f("touchstart",s),Object.keys(E).forEach((function(e){i(parseInt(e,10))})),E.length=0,Object.keys(C).forEach((function(e){C[e].destroy()})),C={},f("mousedown",h),f("mouseup",m),f("contextmenu",m),Object.keys(N).forEach((function(e){N[e].destroy()})),N={},b.parentNode.removeChild(b),e()},function(){var t=e.getOdfCanvas().getSizer(),i=t.ownerDocument;runtime.assert(Boolean(y),"EventManager requires a window object to operate correctly"),(b=i.createElement("textarea")).id="eventTrap",b.setAttribute("tabindex","-1"),b.setAttribute("readOnly","true"),b.setAttribute("rows","1"),t.appendChild(b),c("mousedown",h),c("mouseup",m),c("contextmenu",m),C.longpress=new n("longpress",["touchstart","touchmove","touchend"],o),C.drag=new n("drag",["touchstart","touchmove","touchend"],r),C.dragstop=new n("dragstop",["drag","touchend"],a),c("touchstart",s)}()},gui.IOSSafariSupport=function(e){function t(){n.innerHeight!==n.outerHeight&&(i.style.display="none",runtime.requestAnimationFrame((function(){i.style.display="block"})))}var n=runtime.getWindow(),i=e.getEventTrap();this.destroy=function(n){e.unsubscribe("focus",t),i.removeAttribute("autocapitalize"),i.style.WebkitTransform="",n()},e.subscribe("focus",t),i.setAttribute("autocapitalize","off"),i.style.WebkitTransform="translateX(-10000px)"},gui.HyperlinkController=function(e,t,n,i){function o(){var e=!0;!0===t.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(e=n.isLocalCursorWithinOwnAnnotation()),e!==u&&(u=e,l.emit(gui.HyperlinkController.enabledChanged,u))}function r(e){e.getMemberId()===i&&o()}var a=odf.OdfUtils,s=e.getOdtDocument(),l=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),u=!1;this.isEnabled=function(){return u},this.subscribe=function(e,t){l.subscribe(e,t)},this.unsubscribe=function(e,t){l.unsubscribe(e,t)},this.addHyperlink=function(t,n){if(u){var o=s.getCursorSelection(i),r=new ops.OpApplyHyperlink,a=[];(0===o.length||n)&&(n=n||t,(r=new ops.OpInsertText).init({memberid:i,position:o.position,text:n}),o.length=n.length,a.push(r)),(r=new ops.OpApplyHyperlink).init({memberid:i,position:o.position,length:o.length,hyperlink:t}),a.push(r),e.enqueue(a)}},this.removeHyperlinks=function(){if(u){var t,n,o=s.createPositionIterator(s.getRootNode()),r=s.getCursor(i).getSelectedRange(),l=a.getHyperlinkElements(r),d=r.collapsed&&1===l.length,c=s.getDOMDocument().createRange(),f=[];0!==l.length&&(l.forEach((function(e){c.selectNodeContents(e),t=s.convertDomToCursorRange({anchorNode:c.startContainer,anchorOffset:c.startOffset,focusNode:c.endContainer,focusOffset:c.endOffset}),(n=new ops.OpRemoveHyperlink).init({memberid:i,position:t.position,length:t.length}),f.push(n)})),d||(d=l[0],-1===r.comparePoint(d,0)&&(c.setStart(d,0),c.setEnd(r.startContainer,r.startOffset),0<(t=s.convertDomToCursorRange({anchorNode:c.startContainer,anchorOffset:c.startOffset,focusNode:c.endContainer,focusOffset:c.endOffset})).length&&((n=new ops.OpApplyHyperlink).init({memberid:i,position:t.position,length:t.length,hyperlink:a.getHyperlinkTarget(d)}),f.push(n))),l=l[l.length-1],o.moveToEndOfNode(l),o=o.unfilteredDomOffset(),1===r.comparePoint(l,o)&&(c.setStart(r.endContainer,r.endOffset),c.setEnd(l,o),0<(t=s.convertDomToCursorRange({anchorNode:c.startContainer,anchorOffset:c.startOffset,focusNode:c.endContainer,focusOffset:c.endOffset})).length&&((n=new ops.OpApplyHyperlink).init({memberid:i,position:t.position,length:t.length,hyperlink:a.getHyperlinkTarget(l)}),f.push(n)))),e.enqueue(f),c.detach())}},this.destroy=function(e){s.unsubscribe(ops.Document.signalCursorMoved,r),t.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,o),e()},s.subscribe(ops.Document.signalCursorMoved,r),t.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,o),o()},gui.HyperlinkController.enabledChanged="enabled/changed",gui.ImageController=function(e,t,n,i,o){function r(){var e=!0;!0===t.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(e=n.isLocalCursorWithinOwnAnnotation()),e!==p&&(p=e,f.emit(gui.ImageController.enabledChanged,p))}function a(e){e.getMemberId()===i&&r()}var s={"image/gif":".gif","image/jpeg":".jpg","image/png":".png"},l=odf.Namespaces.textns,u=e.getOdtDocument(),d=odf.OdfUtils,c=u.getFormatting(),f=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),p=!1;this.isEnabled=function(){return p},this.subscribe=function(e,t){f.subscribe(e,t)},this.unsubscribe=function(e,t){f.unsubscribe(e,t)},this.insertImage=function(t,n,r,a){if(p){var f,h=new core.CSSUnits;if(runtime.assert(0r.width&&(m=r.width/a.width),a.height>r.height&&(g=r.height/a.height),r=Math.min(m,g),a={width:a.width*r,height:a.height*r}}r=h.convert(a.width,"px","cm")+"cm",h=h.convert(a.height,"px","cm")+"cm",g=u.getOdfCanvas().odfContainer().rootElement.styles,a=t.toLowerCase(),m=s.hasOwnProperty(a)?s[a]:null,a=[],runtime.assert(null!==m,"Image type is not supported: "+t),m="Pictures/"+o.generateImageName()+m,(f=new ops.OpSetBlob).init({memberid:i,filename:m,mimetype:t,content:n}),a.push(f),c.getStyleElement("Graphics","graphic",[g])||((t=new ops.OpAddStyle).init({memberid:i,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"}}}),a.push(t)),t=o.generateStyleName(),(n=new ops.OpAddStyle).init({memberid:i,styleName:t,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"}}}),a.push(n),(f=new ops.OpInsertImage).init({memberid:i,position:u.getCursorPosition(i),filename:m,frameWidth:r,frameHeight:h,frameStyleName:t,frameName:o.generateFrameName()}),a.push(f),e.enqueue(a)}},this.destroy=function(e){u.unsubscribe(ops.Document.signalCursorMoved,a),t.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,r),e()},u.subscribe(ops.Document.signalCursorMoved,a),t.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,r),r()},gui.ImageController.enabledChanged="enabled/changed",gui.ImageSelector=function(e){function t(){var t=e.getSizer(),n=o.createElement("div");return n.id="imageSelector",n.style.borderWidth="1px",t.appendChild(n),i.forEach((function(e){var t=o.createElement("div");t.className=e,n.appendChild(t)})),n}var n=odf.Namespaces.svgns,i="topLeft topRight bottomRight bottomLeft topMiddle rightMiddle bottomMiddle leftMiddle".split(" "),o=e.getElement().ownerDocument,r=!1;this.select=function(i){var a,s,l=o.getElementById("imageSelector");l||(l=t()),r=!0,a=l.parentNode,s=i.getBoundingClientRect();var u=a.getBoundingClientRect(),d=e.getZoomLevel();a=(s.left-u.left)/d-1,s=(s.top-u.top)/d-1,l.style.display="block",l.style.left=a+"px",l.style.top=s+"px",l.style.width=i.getAttributeNS(n,"width"),l.style.height=i.getAttributeNS(n,"height")},this.clearSelection=function(){var e;r&&(e=o.getElementById("imageSelector"))&&(e.style.display="none"),r=!1},this.isSelectorElement=function(e){var t=o.getElementById("imageSelector");return!!t&&(e===t||e.parentNode===t)}},function(){function e(e){function t(e){return r=e.which&&String.fromCharCode(e.which)===o,o=void 0,!1===r}function n(){r=!1}function i(e){o=e.data,r=!1}var o,r=!1;this.destroy=function(o){e.unsubscribe("textInput",n),e.unsubscribe("compositionend",i),e.removeFilter("keypress",t),o()},e.subscribe("textInput",n),e.subscribe("compositionend",i),e.addFilter("keypress",t)}gui.InputMethodEditor=function(t,n){function i(e){g&&(e?g.getNode().setAttributeNS("urn:webodf:names:cursor","composing","true"):(g.getNode().removeAttributeNS("urn:webodf:names:cursor","composing"),c.textContent=""))}function o(){v&&(v=!1,i(!1),C.emit(gui.InputMethodEditor.signalCompositionEnd,{data:S}),S="")}function r(){x||(x=!0,o(),g&&g.getSelectedRange().collapsed?b.value="":b.value=h.writeToString(g.getSelectedRange().cloneContents()),b.setSelectionRange(0,b.value.length),x=!1)}function a(){n.hasFocus()&&f.trigger()}function s(){p=void 0,f.cancel(),i(!0),v||C.emit(gui.InputMethodEditor.signalCompositionStart,{data:""})}function l(e){e=p=e.data,v=!0,S+=e,f.trigger()}function u(e){e.data!==p&&(e=e.data,v=!0,S+=e,f.trigger()),p=void 0}function d(){c.textContent=b.value}var c,f,p,h,m,g=null,b=n.getEventTrap(),y=b.ownerDocument,v=!1,S="",C=new core.EventNotifier([gui.InputMethodEditor.signalCompositionStart,gui.InputMethodEditor.signalCompositionEnd]),N=[],x=!1;this.subscribe=C.subscribe,this.unsubscribe=C.unsubscribe,this.registerCursor=function(e){e.getMemberId()===t&&((g=e).getNode().appendChild(c),e.subscribe(ops.OdtCursor.signalCursorUpdated,a),n.subscribe("input",d),n.subscribe("compositionupdate",d))},this.removeCursor=function(e){g&&e===t&&(g.getNode().removeChild(c),g.unsubscribe(ops.OdtCursor.signalCursorUpdated,a),n.unsubscribe("input",d),n.unsubscribe("compositionupdate",d),g=null)},this.destroy=function(e){n.unsubscribe("compositionstart",s),n.unsubscribe("compositionend",l),n.unsubscribe("textInput",u),n.unsubscribe("keypress",o),n.unsubscribe("focus",r),core.Async.destroyAll(m,e)},(h=new odf.TextSerializer).filter=new odf.OdfNodeFilter,n.subscribe("compositionstart",s),n.subscribe("compositionend",l),n.subscribe("textInput",u),n.subscribe("keypress",o),n.subscribe("focus",r),N.push(new e(n)),m=N.map((function(e){return e.destroy})),(c=y.createElement("span")).setAttribute("id","composer"),f=core.Task.createTimeoutTask(r,1),m.push(f.destroy)},gui.InputMethodEditor.signalCompositionStart="input/compositionstart",gui.InputMethodEditor.signalCompositionEnd="input/compositionend"}(),gui.MetadataController=function(e,t){function n(e){r.emit(gui.MetadataController.signalMetadataChanged,e)}function i(e){var t=-1===a.indexOf(e);return t||runtime.log("Setting "+e+" is restricted."),t}var o=e.getOdtDocument(),r=new core.EventNotifier([gui.MetadataController.signalMetadataChanged]),a=["dc:creator","dc:date","meta:editing-cycles","meta:editing-duration","meta:document-statistic"];this.setMetadata=function(n,o){var r,a={},s="";n&&Object.keys(n).filter(i).forEach((function(e){a[e]=n[e]})),o&&(s=o.filter(i).join(",")),(0i}function n(n){null!==n&&!1===t(n)&&(i=Math.abs(n-e))}var i,o=this,r=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT;this.token=void 0,this.process=function(e,i,a){var s,l;return e.visualDirection===r?(s=i&&i.right,l=a&&a.left):(s=i&&i.left,l=a&&a.right),!(!t(s)&&!t(l)&&((i||a)&&(n(s),n(l),o.token=e.token),1))}},gui.LineBoundaryScanner=function(){var e=this,t=null;this.token=void 0,this.process=function(n,i,o){var r;if(r=o)if(t){var a=t;r=Math.min(a.bottom-a.top,o.bottom-o.top);var s=Math.max(a.top,o.top);a=Math.min(a.bottom,o.bottom)-s,r=.4>=(0n?t.previousSibling:t.nextSibling)===NodeFilter.FILTER_ACCEPT&&(r=o),t=t.parentNode;return r}function i(e,t){var n;return null===e?p.NO_NEIGHBOUR:a.isCharacterElement(e)?p.SPACE_CHAR:e.nodeType===o||a.isTextSpan(e)||a.isHyperlink(e)?(n=e.textContent.charAt(t()),l.test(n)?p.SPACE_CHAR:s.test(n)?p.PUNCTUATION_CHAR:p.WORD_CHAR):p.OTHER}var o=Node.TEXT_NODE,r=Node.ELEMENT_NODE,a=odf.OdfUtils,s=/[!-#%-*,-\/:-;?-@\[-\]_{}\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]/,l=/\s/,u=core.PositionFilter.FilterResult.FILTER_ACCEPT,d=core.PositionFilter.FilterResult.FILTER_REJECT,c=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,f=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,p={NO_NEIGHBOUR:0,SPACE_CHAR:1,PUNCTUATION_CHAR:2,WORD_CHAR:3,OTHER:4};this.acceptPosition=function(e){var o=e.container(),a=e.leftNode(),s=e.rightNode(),l=e.unfilteredDomOffset,h=function(){return e.unfilteredDomOffset()-1};return o.nodeType===r&&(null===s&&(s=n(o,1,e.getNodeFilter())),null===a&&(a=n(o,-1,e.getNodeFilter()))),o!==s&&(l=function(){return 0}),o!==a&&null!==a&&(h=function(){return a.textContent.length-1}),o=i(a,h),s=i(s,l),o===p.WORD_CHAR&&s===p.WORD_CHAR||o===p.PUNCTUATION_CHAR&&s===p.PUNCTUATION_CHAR||t===c&&o!==p.NO_NEIGHBOUR&&s===p.SPACE_CHAR||t===f&&o===p.SPACE_CHAR&&s!==p.NO_NEIGHBOUR?d:u}},odf.WordBoundaryFilter.IncludeWhitespace={None:0,TRAILING:1,LEADING:2},gui.SelectionController=function(e,t){function n(e){var n=e.spec();(e.isEdit||n.memberid===t)&&(g=void 0,b.cancel())}function i(){var e=y.getCursor(t).getNode();return y.createStepIterator(e,0,[C,x],y.getRootElement(e))}function o(e,t,n){n=new odf.WordBoundaryFilter(y,n);var i=y.getRootElement(e)||y.getRootNode(),o=y.createRootFilter(i);return y.createStepIterator(e,t,[C,o,n],i)}function r(e,t){return t?{anchorNode:e.startContainer,anchorOffset:e.startOffset,focusNode:e.endContainer,focusOffset:e.endOffset}:{anchorNode:e.endContainer,anchorOffset:e.endOffset,focusNode:e.startContainer,focusOffset:e.startOffset}}function a(e,n,i){var o=new ops.OpMoveCursor;return o.init({memberid:t,position:e,length:n||0,selectionType:i}),o}function s(n,i,o){var s;(s=r((s=y.getCursor(t)).getSelectedRange(),s.hasForwardSelection())).focusNode=n,s.focusOffset=i,o||(s.anchorNode=s.focusNode,s.anchorOffset=s.focusOffset),n=y.convertDomToCursorRange(s),e.enqueue([a(n.position,n.length)])}function l(e){var t;(t=o(e.startContainer,e.startOffset,E)).roundToPreviousStep()&&e.setStart(t.container(),t.offset()),(t=o(e.endContainer,e.endOffset,T)).roundToNextStep()&&e.setEnd(t.container(),t.offset())}function u(e){var t=(n=S.getParagraphElements(e))[0],n=n[n.length-1];t&&e.setStart(t,0),n&&(S.isParagraph(e.endContainer)&&0===e.endOffset?e.setEndBefore(n):e.setEnd(n,n.childNodes.length))}function d(e,t,n,i){var o,r;i?(o=n.startContainer,r=n.startOffset):(o=n.endContainer,r=n.endOffset),v.containsNode(e,o)||(r=0>v.comparePoints(e,0,o,r)?0:e.childNodes.length,o=e),(e=y.createStepIterator(o,r,t,S.getParagraphElement(o)||e)).roundToClosestStep()||runtime.assert(!1,"No step found in requested range"),i?n.setStart(e.container(),e.offset()):n.setEnd(e.container(),e.offset())}function c(e,t){var n=i();n.advanceStep(e)&&s(n.container(),n.offset(),t)}function f(e,t){var n,o=g,r=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];void 0===o&&w&&(o=w()),isNaN(o)||(n=i(),N.moveToFilteredStep(n,e,r)&&n.advanceStep(e)&&(r=[new gui.ClosestXOffsetScanner(o),new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner],N.moveToFilteredStep(n,e,r)&&(s(n.container(),n.offset(),t),g=o,b.restart())))}function p(e,t){var n=i(),o=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];N.moveToFilteredStep(n,e,o)&&s(n.container(),n.offset(),t)}function h(e,n){var i;(i=o((i=r((i=y.getCursor(t)).getSelectedRange(),i.hasForwardSelection())).focusNode,i.focusOffset,E)).advanceStep(e)&&s(i.container(),i.offset(),n)}function m(e,n,i){var o=!1,a=r((a=y.getCursor(t)).getSelectedRange(),a.hasForwardSelection());o=y.getRootElement(a.focusNode),runtime.assert(Boolean(o),"SelectionController: Cursor outside root"),(a=y.createStepIterator(a.focusNode,a.focusOffset,[C,x],o)).roundToClosestStep(),a.advanceStep(e)&&(i=i(a.container()))&&(e===O?(a.setPosition(i,0),o=a.roundToNextStep()):(a.setPosition(i,i.childNodes.length),o=a.roundToPreviousStep()),o&&s(a.container(),a.offset(),n))}var g,b,y=e.getOdtDocument(),v=core.DomUtils,S=odf.OdfUtils,C=y.getPositionFilter(),N=new gui.GuiStepUtils,x=y.createRootFilter(t),w=null,E=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,T=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,O=core.StepDirection.PREVIOUS,A=core.StepDirection.NEXT;this.selectionToRange=function(e){var t=0<=v.comparePoints(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset),n=e.focusNode.ownerDocument.createRange();return t?(n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset)):(n.setStart(e.focusNode,e.focusOffset),n.setEnd(e.anchorNode,e.anchorOffset)),{range:n,hasForwardSelection:t}},this.rangeToSelection=r,this.selectImage=function(t){var n,i=y.getRootElement(t),o=y.createRootFilter(i);(i=y.createStepIterator(t,0,[o,y.getPositionFilter()],i)).roundToPreviousStep()||runtime.assert(!1,"No walkable position before frame"),o=i.container(),n=i.offset(),i.setPosition(t,t.childNodes.length),i.roundToNextStep()||runtime.assert(!1,"No walkable position after frame"),t=a((t=y.convertDomToCursorRange({anchorNode:o,anchorOffset:n,focusNode:i.container(),focusOffset:i.offset()})).position,t.length,ops.OdtCursor.RegionSelection),e.enqueue([t])},this.expandToWordBoundaries=l,this.expandToParagraphBoundaries=u,this.selectRange=function(n,i,o){var s,c=y.getOdfCanvas().getElement(),f=[C];s=v.containsNode(c,n.startContainer),c=v.containsNode(c,n.endContainer),(s||c)&&(s&&c&&(2===o?l(n):3<=o&&u(n)),(o=i?y.getRootElement(n.startContainer):y.getRootElement(n.endContainer))||(o=y.getRootNode()),f.push(y.createRootFilter(o)),d(o,f,n,!0),d(o,f,n,!1),n=r(n,i),i=y.convertDomToCursorRange(n),n=y.getCursorSelection(t),(i.position!==n.position||i.length!==n.length)&&(n=a(i.position,i.length,ops.OdtCursor.RangeSelection),e.enqueue([n])))},this.moveCursorToLeft=function(){return c(O,!1),!0},this.moveCursorToRight=function(){return c(A,!1),!0},this.extendSelectionToLeft=function(){return c(O,!0),!0},this.extendSelectionToRight=function(){return c(A,!0),!0},this.setCaretXPositionLocator=function(e){w=e},this.moveCursorUp=function(){return f(O,!1),!0},this.moveCursorDown=function(){return f(A,!1),!0},this.extendSelectionUp=function(){return f(O,!0),!0},this.extendSelectionDown=function(){return f(A,!0),!0},this.moveCursorBeforeWord=function(){return h(O,!1),!0},this.moveCursorPastWord=function(){return h(A,!1),!0},this.extendSelectionBeforeWord=function(){return h(O,!0),!0},this.extendSelectionPastWord=function(){return h(A,!0),!0},this.moveCursorToLineStart=function(){return p(O,!1),!0},this.moveCursorToLineEnd=function(){return p(A,!1),!0},this.extendSelectionToLineStart=function(){return p(O,!0),!0},this.extendSelectionToLineEnd=function(){return p(A,!0),!0},this.extendSelectionToParagraphStart=function(){return m(O,!0,S.getParagraphElement),!0},this.extendSelectionToParagraphEnd=function(){return m(A,!0,S.getParagraphElement),!0},this.moveCursorToParagraphStart=function(){return m(O,!1,S.getParagraphElement),!0},this.moveCursorToParagraphEnd=function(){return m(A,!1,S.getParagraphElement),!0},this.moveCursorToDocumentStart=function(){return m(O,!1,y.getRootElement),!0},this.moveCursorToDocumentEnd=function(){return m(A,!1,y.getRootElement),!0},this.extendSelectionToDocumentStart=function(){return m(O,!0,y.getRootElement),!0},this.extendSelectionToDocumentEnd=function(){return m(A,!0,y.getRootElement),!0},this.extendSelectionToEntireDocument=function(){var n,i,o,r=y.getCursor(t);return r=y.getRootElement(r.getNode()),runtime.assert(Boolean(r),"SelectionController: Cursor outside root"),(o=y.createStepIterator(r,0,[C,x],r)).roundToClosestStep(),n=o.container(),i=o.offset(),o.setPosition(r,r.childNodes.length),o.roundToClosestStep(),r=y.convertDomToCursorRange({anchorNode:n,anchorOffset:i,focusNode:o.container(),focusOffset:o.offset()}),e.enqueue([a(r.position,r.length)]),!0},this.destroy=function(e){y.unsubscribe(ops.OdtDocument.signalOperationStart,n),core.Async.destroyAll([b.destroy],e)},b=core.Task.createTimeoutTask((function(){g=void 0}),2e3),y.subscribe(ops.OdtDocument.signalOperationStart,n)},gui.TextController=function(e,t,n,i,o,r){function a(){m=!0!==t.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)||n.isLocalCursorWithinOwnAnnotation()}function s(e){e.getMemberId()===i&&a()}function l(e,t,n){var i=[f.getPositionFilter()];return n&&i.push(f.createRootFilter(e.startContainer)),(n=f.createStepIterator(e.startContainer,e.startOffset,i,t)).roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range start"),t=f.convertDomPointToCursorStep(n.container(),n.offset()),e.collapsed?e=t:(n.setPosition(e.endContainer,e.endOffset),n.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range end"),e=f.convertDomPointToCursorStep(n.container(),n.offset())),{position:t,length:e-t}}function u(e){var t,n,o,r=p.getParagraphElements(e),a=e.cloneRange(),s=[];return t=r[0],1e.length&&(e.position+=e.length,e.length=-e.length),e}function c(t){if(!m)return!1;var n,o,r=f.getCursor(i).getSelectedRange().cloneRange(),a=d(f.getCursorSelection(i));if(0===a.length){a=void 0,n=f.getCursor(i).getNode(),o=f.getRootElement(n);var s=[f.getPositionFilter(),f.createRootFilter(o)];(o=f.createStepIterator(n,0,s,o)).roundToClosestStep()&&(t?o.nextStep():o.previousStep())&&(a=d(f.convertDomToCursorRange({anchorNode:n,anchorOffset:0,focusNode:o.container(),focusOffset:o.offset()})),t?(r.setStart(n,0),r.setEnd(o.container(),o.offset())):(r.setStart(o.container(),o.offset()),r.setEnd(n,0)))}return a&&e.enqueue(u(r)),void 0!==a}var f=e.getOdtDocument(),p=odf.OdfUtils,h=core.DomUtils,m=!1,g=odf.Namespaces.textns,b=core.StepDirection.NEXT;this.isEnabled=function(){return m},this.enqueueParagraphSplittingOps=function(){if(!m)return!1;var t,n=(t=f.getCursor(i)).getSelectedRange(),o=d(f.getCursorSelection(i)),a=[],s=(t=p.getParagraphElement(t.getNode())).getAttributeNS(g,"style-name")||"";return 0n.left&&(n=v(i))&&(t.focusNode=n.container,t.focusOffset=n.offset,o&&(t.anchorNode=t.focusNode,t.anchorOffset=t.focusOffset))):L.isImage(t.focusNode.firstChild)&&1===t.focusOffset&&L.isCharacterFrame(t.focusNode)&&(n=v(t.focusNode))&&(t.anchorNode=t.focusNode=n.container,t.anchorOffset=t.focusOffset=n.offset),t.anchorNode&&t.focusNode&&(t=ue.selectionToRange(t),ue.selectRange(t.range,t.hasForwardSelection,0===e.button?e.detail:0)),G.focus()}function C(e){var t;(t=r(e.clientX,e.clientY))&&(e={anchorNode:e=t.container,anchorOffset:t=t.offset,focusNode:e,focusOffset:t},e=ue.selectionToRange(e),ue.selectRange(e.range,e.hasForwardSelection,2),G.focus())}function N(e){var t,n,o,r=e.target||e.srcElement||null;P.processRequests(),V&&(L.isImage(r)&&L.isCharacterFrame(r.parentNode)&&I.getSelection().isCollapsed?(ue.selectImage(r.parentNode),G.focus()):ne.isSelectorElement(r)?G.focus():q?(n=(r=i.getSelectedRange()).collapsed,L.isImage(r.endContainer)&&0===r.endOffset&&L.isCharacterFrame(r.endContainer.parentNode)&&(o=v(o=r.endContainer.parentNode))&&(r.setEnd(o.container,o.offset),n&&r.collapse(!1)),ue.selectRange(r,i.hasForwardSelection(),0===e.button?e.detail:0),G.focus()):he?S(e):(t=U.cloneEvent(e),_=runtime.setTimeout((function(){S(t)}),0)),ae=0,q=V=!1)}function x(e){var t=F.getCursor(n).getSelectedRange();t.collapsed||z.exportRangeToDataTransfer(e.dataTransfer,t)}function w(){V&&G.focus(),ae=0,q=V=!1}function E(e){N(e)}function T(e){var t=e.target||e.srcElement||null,n=null;"annotationRemoveButton"===t.className?(runtime.assert(Y,"Remove buttons are displayed on annotations while annotation editing is disabled in the controller."),n=t.parentNode.getElementsByTagNameNS(odf.Namespaces.officens,"annotation").item(0),$.removeAnnotation(n),G.focus()):"webodf-draggable"!==t.getAttribute("class")&&N(e)}function O(e){(e=e.data)&&(-1===e.indexOf("\n")?ee.insertText(e):oe.paste(e))}function A(e){return function(t){return F.getCursor(n).getSelectionType()!==ops.OdtCursor.RangeSelection||e(t)}}function R(e){G.unsubscribe("keydown",W.handleEvent),G.unsubscribe("keypress",j.handleEvent),G.unsubscribe("keyup",X.handleEvent),G.unsubscribe("copy",l),G.unsubscribe("mousedown",y),G.unsubscribe("mousemove",P.trigger),G.unsubscribe("mouseup",T),G.unsubscribe("contextmenu",E),G.unsubscribe("dragstart",x),G.unsubscribe("dragend",w),G.unsubscribe("click",se.handleClick),G.unsubscribe("longpress",C),G.unsubscribe("drag",m),G.unsubscribe("dragstop",g),F.unsubscribe(ops.OdtDocument.signalOperationEnd,D.trigger),F.unsubscribe(ops.Document.signalCursorAdded,re.registerCursor),F.unsubscribe(ops.Document.signalCursorRemoved,re.removeCursor),F.unsubscribe(ops.OdtDocument.signalOperationEnd,c),e()}var _,P,D,k,I=runtime.getWindow(),F=t.getOdtDocument(),M=new gui.SessionConstraints,B=new gui.SessionContext(t,n),U=core.DomUtils,L=odf.OdfUtils,z=new gui.MimeDataExporter,H=new gui.Clipboard(z),W=new gui.KeyboardHandler,j=new gui.KeyboardHandler,X=new gui.KeyboardHandler,V=!1,Z=new odf.ObjectNameGenerator(F.getOdfCanvas().odfContainer(),n),q=!1,K=null,J=null,G=new gui.EventManager(F),Y=o.annotationsEnabled,$=new gui.AnnotationController(t,M,n),Q=new gui.DirectFormattingController(t,M,B,n,Z,o.directTextStylingEnabled,o.directParagraphStylingEnabled),ee=new gui.TextController(t,M,B,n,Q.createCursorStyleOp,Q.createParagraphStyleOps),te=new gui.ImageController(t,M,B,n,Z),ne=new gui.ImageSelector(F.getOdfCanvas()),ie=F.createPositionIterator(F.getRootNode()),oe=new gui.PasteController(t,M,B,n),re=new gui.InputMethodEditor(n,G),ae=0,se=new gui.HyperlinkClickHandler(F.getOdfCanvas().getElement,W,X),le=new gui.HyperlinkController(t,M,B,n),ue=new gui.SelectionController(t,n),de=new gui.MetadataController(t,n),ce=gui.KeyboardHandler.Modifier,fe=gui.KeyboardHandler.KeyCode,pe=-1!==I.navigator.appVersion.toLowerCase().indexOf("mac"),he=-1!==["iPad","iPod","iPhone"].indexOf(I.navigator.platform);runtime.assert(null!==I,"Expected to be run in an environment which has a global window, like a browser."),this.undo=p,this.redo=h,this.insertLocalCursor=function(){runtime.assert(void 0===t.getOdtDocument().getCursor(n),"Inserting local cursor a second time.");var e=new ops.OpAddCursor;e.init({memberid:n}),t.enqueue([e]),G.focus()},this.removeLocalCursor=function(){runtime.assert(void 0!==t.getOdtDocument().getCursor(n),"Removing local cursor without inserting before.");var e=new ops.OpRemoveCursor;e.init({memberid:n}),t.enqueue([e])},this.startEditing=function(){re.subscribe(gui.InputMethodEditor.signalCompositionStart,ee.removeCurrentSelection),re.subscribe(gui.InputMethodEditor.signalCompositionEnd,O),G.subscribe("beforecut",s),G.subscribe("cut",a),G.subscribe("beforepaste",d),G.subscribe("paste",u),J&&J.initialize(),G.setEditing(!0),se.setModifier(pe?ce.Meta:ce.Ctrl),W.bind(fe.Backspace,ce.None,function(e){return function(){return e(),!0}}(ee.removeTextByBackspaceKey),!0),W.bind(fe.Delete,ce.None,ee.removeTextByDeleteKey),W.bind(fe.Tab,ce.None,A((function(){return ee.insertText("\t"),!0}))),pe?(W.bind(fe.Clear,ce.None,ee.removeCurrentSelection),W.bind(fe.B,ce.Meta,A(Q.toggleBold)),W.bind(fe.I,ce.Meta,A(Q.toggleItalic)),W.bind(fe.U,ce.Meta,A(Q.toggleUnderline)),W.bind(fe.L,ce.MetaShift,A(Q.alignParagraphLeft)),W.bind(fe.E,ce.MetaShift,A(Q.alignParagraphCenter)),W.bind(fe.R,ce.MetaShift,A(Q.alignParagraphRight)),W.bind(fe.J,ce.MetaShift,A(Q.alignParagraphJustified)),Y&&W.bind(fe.C,ce.MetaShift,$.addAnnotation),W.bind(fe.Z,ce.Meta,p),W.bind(fe.Z,ce.MetaShift,h)):(W.bind(fe.B,ce.Ctrl,A(Q.toggleBold)),W.bind(fe.I,ce.Ctrl,A(Q.toggleItalic)),W.bind(fe.U,ce.Ctrl,A(Q.toggleUnderline)),W.bind(fe.L,ce.CtrlShift,A(Q.alignParagraphLeft)),W.bind(fe.E,ce.CtrlShift,A(Q.alignParagraphCenter)),W.bind(fe.R,ce.CtrlShift,A(Q.alignParagraphRight)),W.bind(fe.J,ce.CtrlShift,A(Q.alignParagraphJustified)),Y&&W.bind(fe.C,ce.CtrlAlt,$.addAnnotation),W.bind(fe.Z,ce.Ctrl,p),W.bind(fe.Z,ce.CtrlShift,h)),j.setDefault(A((function(e){var t;return!(!(t=null===e.which||void 0===e.which?String.fromCharCode(e.keyCode):0!==e.which&&0!==e.charCode?String.fromCharCode(e.which):null)||e.altKey||e.ctrlKey||e.metaKey||(ee.insertText(t),0))}))),j.bind(fe.Enter,ce.None,A(ee.enqueueParagraphSplittingOps))},this.endEditing=function(){re.unsubscribe(gui.InputMethodEditor.signalCompositionStart,ee.removeCurrentSelection),re.unsubscribe(gui.InputMethodEditor.signalCompositionEnd,O),G.unsubscribe("cut",a),G.unsubscribe("beforecut",s),G.unsubscribe("paste",u),G.unsubscribe("beforepaste",d),G.setEditing(!1),se.setModifier(ce.None),W.bind(fe.Backspace,ce.None,(function(){return!0}),!0),W.unbind(fe.Delete,ce.None),W.unbind(fe.Tab,ce.None),pe?(W.unbind(fe.Clear,ce.None),W.unbind(fe.B,ce.Meta),W.unbind(fe.I,ce.Meta),W.unbind(fe.U,ce.Meta),W.unbind(fe.L,ce.MetaShift),W.unbind(fe.E,ce.MetaShift),W.unbind(fe.R,ce.MetaShift),W.unbind(fe.J,ce.MetaShift),Y&&W.unbind(fe.C,ce.MetaShift),W.unbind(fe.Z,ce.Meta),W.unbind(fe.Z,ce.MetaShift)):(W.unbind(fe.B,ce.Ctrl),W.unbind(fe.I,ce.Ctrl),W.unbind(fe.U,ce.Ctrl),W.unbind(fe.L,ce.CtrlShift),W.unbind(fe.E,ce.CtrlShift),W.unbind(fe.R,ce.CtrlShift),W.unbind(fe.J,ce.CtrlShift),Y&&W.unbind(fe.C,ce.CtrlAlt),W.unbind(fe.Z,ce.Ctrl),W.unbind(fe.Z,ce.CtrlShift)),j.setDefault(null),j.unbind(fe.Enter,ce.None)},this.getInputMemberId=function(){return n},this.getSession=function(){return t},this.getSessionConstraints=function(){return M},this.setUndoManager=function(e){J&&J.unsubscribe(gui.UndoManager.signalUndoStackChanged,f),(J=e)&&(J.setDocument(F),J.setPlaybackFunction(t.enqueue),J.subscribe(gui.UndoManager.signalUndoStackChanged,f))},this.getUndoManager=function(){return J},this.getMetadataController=function(){return de},this.getAnnotationController=function(){return $},this.getDirectFormattingController=function(){return Q},this.getHyperlinkClickHandler=function(){return se},this.getHyperlinkController=function(){return le},this.getImageController=function(){return te},this.getSelectionController=function(){return ue},this.getTextController=function(){return ee},this.getEventManager=function(){return G},this.getKeyboardHandlers=function(){return{keydown:W,keypress:j}},this.destroy=function(e){var t=[P.destroy,D.destroy,Q.destroy,re.destroy,G.destroy,se.destroy,le.destroy,de.destroy,ue.destroy,ee.destroy,R];k&&t.unshift(k.destroy),runtime.clearTimeout(_),core.Async.destroyAll(t,e)},P=core.Task.createRedrawTask(b),D=core.Task.createRedrawTask((function(){var e=F.getCursor(n);e&&e.getSelectionType()===ops.OdtCursor.RegionSelection&&(e=L.getImageElements(e.getSelectedRange())[0])?ne.select(e.parentNode):ne.clearSelection()})),W.bind(fe.Left,ce.None,A(ue.moveCursorToLeft)),W.bind(fe.Right,ce.None,A(ue.moveCursorToRight)),W.bind(fe.Up,ce.None,A(ue.moveCursorUp)),W.bind(fe.Down,ce.None,A(ue.moveCursorDown)),W.bind(fe.Left,ce.Shift,A(ue.extendSelectionToLeft)),W.bind(fe.Right,ce.Shift,A(ue.extendSelectionToRight)),W.bind(fe.Up,ce.Shift,A(ue.extendSelectionUp)),W.bind(fe.Down,ce.Shift,A(ue.extendSelectionDown)),W.bind(fe.Home,ce.None,A(ue.moveCursorToLineStart)),W.bind(fe.End,ce.None,A(ue.moveCursorToLineEnd)),W.bind(fe.Home,ce.Ctrl,A(ue.moveCursorToDocumentStart)),W.bind(fe.End,ce.Ctrl,A(ue.moveCursorToDocumentEnd)),W.bind(fe.Home,ce.Shift,A(ue.extendSelectionToLineStart)),W.bind(fe.End,ce.Shift,A(ue.extendSelectionToLineEnd)),W.bind(fe.Up,ce.CtrlShift,A(ue.extendSelectionToParagraphStart)),W.bind(fe.Down,ce.CtrlShift,A(ue.extendSelectionToParagraphEnd)),W.bind(fe.Home,ce.CtrlShift,A(ue.extendSelectionToDocumentStart)),W.bind(fe.End,ce.CtrlShift,A(ue.extendSelectionToDocumentEnd)),pe?(W.bind(fe.Left,ce.Alt,A(ue.moveCursorBeforeWord)),W.bind(fe.Right,ce.Alt,A(ue.moveCursorPastWord)),W.bind(fe.Left,ce.Meta,A(ue.moveCursorToLineStart)),W.bind(fe.Right,ce.Meta,A(ue.moveCursorToLineEnd)),W.bind(fe.Home,ce.Meta,A(ue.moveCursorToDocumentStart)),W.bind(fe.End,ce.Meta,A(ue.moveCursorToDocumentEnd)),W.bind(fe.Left,ce.AltShift,A(ue.extendSelectionBeforeWord)),W.bind(fe.Right,ce.AltShift,A(ue.extendSelectionPastWord)),W.bind(fe.Left,ce.MetaShift,A(ue.extendSelectionToLineStart)),W.bind(fe.Right,ce.MetaShift,A(ue.extendSelectionToLineEnd)),W.bind(fe.Up,ce.AltShift,A(ue.extendSelectionToParagraphStart)),W.bind(fe.Down,ce.AltShift,A(ue.extendSelectionToParagraphEnd)),W.bind(fe.Up,ce.MetaShift,A(ue.extendSelectionToDocumentStart)),W.bind(fe.Down,ce.MetaShift,A(ue.extendSelectionToDocumentEnd)),W.bind(fe.A,ce.Meta,A(ue.extendSelectionToEntireDocument))):(W.bind(fe.Left,ce.Ctrl,A(ue.moveCursorBeforeWord)),W.bind(fe.Right,ce.Ctrl,A(ue.moveCursorPastWord)),W.bind(fe.Left,ce.CtrlShift,A(ue.extendSelectionBeforeWord)),W.bind(fe.Right,ce.CtrlShift,A(ue.extendSelectionPastWord)),W.bind(fe.A,ce.Ctrl,A(ue.extendSelectionToEntireDocument))),he&&(k=new gui.IOSSafariSupport(G)),G.subscribe("keydown",W.handleEvent),G.subscribe("keypress",j.handleEvent),G.subscribe("keyup",X.handleEvent),G.subscribe("copy",l),G.subscribe("mousedown",y),G.subscribe("mousemove",P.trigger),G.subscribe("mouseup",T),G.subscribe("contextmenu",E),G.subscribe("dragstart",x),G.subscribe("dragend",w),G.subscribe("click",se.handleClick),G.subscribe("longpress",C),G.subscribe("drag",m),G.subscribe("dragstop",g),F.subscribe(ops.OdtDocument.signalOperationEnd,D.trigger),F.subscribe(ops.Document.signalCursorAdded,re.registerCursor),F.subscribe(ops.Document.signalCursorRemoved,re.removeCursor),F.subscribe(ops.OdtDocument.signalOperationEnd,c)}}(),gui.CaretManager=function(e,t){function n(e){return r.hasOwnProperty(e)?r[e]:null}function i(){return Object.keys(r).map((function(e){return r[e]}))}function o(t){var n=r[t];n&&(delete r[t],t===e.getInputMemberId()?(s.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,n.ensureVisible),s.unsubscribe(ops.Document.signalCursorMoved,n.refreshCursorBlinking),l.unsubscribe("compositionupdate",n.handleUpdate),l.unsubscribe("compositionend",n.handleUpdate),l.unsubscribe("focus",n.setFocus),l.unsubscribe("blur",n.removeFocus),a.removeEventListener("focus",n.show,!1),a.removeEventListener("blur",n.hide,!1)):s.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,n.handleUpdate),n.destroy((function(){})))}var r={},a=runtime.getWindow(),s=e.getSession().getOdtDocument(),l=e.getEventManager();this.registerCursor=function(n,i,o){var u=n.getMemberId();return n=new gui.Caret(n,t,i,o),r[u]=n,u===e.getInputMemberId()?(runtime.log("Starting to track input on new cursor of "+u),s.subscribe(ops.OdtDocument.signalProcessingBatchEnd,n.ensureVisible),s.subscribe(ops.Document.signalCursorMoved,n.refreshCursorBlinking),l.subscribe("compositionupdate",n.handleUpdate),l.subscribe("compositionend",n.handleUpdate),l.subscribe("focus",n.setFocus),l.subscribe("blur",n.removeFocus),a.addEventListener("focus",n.show,!1),a.addEventListener("blur",n.hide,!1),n.setOverlayElement(l.getEventTrap())):s.subscribe(ops.OdtDocument.signalProcessingBatchEnd,n.handleUpdate),n},this.getCaret=n,this.getCarets=i,this.destroy=function(t){var n=i().map((function(e){return e.destroy}));e.getSelectionController().setCaretXPositionLocator(null),s.unsubscribe(ops.Document.signalCursorRemoved,o),r={},core.Async.destroyAll(n,t)},e.getSelectionController().setCaretXPositionLocator((function(){var t,i=n(e.getInputMemberId());return i&&(t=i.getBoundingClientRect()),t?t.right:void 0})),s.subscribe(ops.Document.signalCursorRemoved,o)},gui.EditInfoHandle=function(e){var t,n=[],i=e.ownerDocument,o=i.documentElement.namespaceURI;this.setEdits=function(e){var r,a,s,l;for(n=e,core.DomUtils.removeAllChildNodes(t),e=0;eu?(a=n(1,0),s=n(.5,1e4-u),l=n(.2,2e4-u)):1e4<=u&&2e4>u?(a=n(.5,0),l=n(.2,2e4-u)):a=n(.2,0)},this.getEdits=function(){return e.getEdits()},this.clearEdits=function(){e.clearEdits(),o.setEdits([]),r.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&r.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")},this.getEditInfo=function(){return e},this.show=function(){r.style.display="block"},this.hide=function(){u.hideHandle(),r.style.display="none"},this.showHandle=function(){o.show()},this.hideHandle=function(){o.hide()},this.destroy=function(t){runtime.clearTimeout(a),runtime.clearTimeout(s),runtime.clearTimeout(l),i.removeChild(r),o.destroy((function(n){n?t(n):e.destroy(t)}))},function(){var n=e.getOdtDocument().getDOMDocument();(r=n.createElementNS(n.documentElement.namespaceURI,"div")).setAttribute("class","editInfoMarker"),r.onmouseover=function(){u.showHandle()},r.onmouseout=function(){u.hideHandle()},(i=e.getNode()).appendChild(r),o=new gui.EditInfoHandle(i),t||u.hide()}()},gui.HyperlinkTooltipView=function(e,t){var n,i,o,r=core.DomUtils,a=odf.OdfUtils,s=runtime.getWindow();runtime.assert(null!==s,"Expected to be run in an environment which has a global window, like a browser."),this.showTooltip=function(l){var u,d=l.target||l.srcElement,c=e.getSizer(),f=e.getZoomLevel();e:{for(;d;){if(a.isHyperlink(d))break e;if(a.isParagraph(d)||a.isInlineRoot(d))break;d=d.parentNode}d=null}if(d){var p;switch(r.containsNode(c,o)||c.appendChild(o),u=i,t()){case gui.KeyboardHandler.Modifier.Ctrl:p=runtime.tr("Ctrl-click to follow link");break;case gui.KeyboardHandler.Modifier.Meta:p=runtime.tr("⌘-click to follow link");break;default:p=""}u.textContent=p,n.textContent=a.getHyperlinkTarget(d),o.style.display="block",u=s.innerWidth-o.offsetWidth-15,d=l.clientX>u?u:l.clientX+15,u=s.innerHeight-o.offsetHeight-10,l=l.clientY>u?u:l.clientY+10,d=(d-(c=c.getBoundingClientRect()).left)/f,l=(l-c.top)/f,o.style.left=d+"px",o.style.top=l+"px"}},this.hideTooltip=function(){o.style.display="none"},this.destroy=function(e){o.parentNode&&o.parentNode.removeChild(o),e()},function(){var t=e.getElement().ownerDocument;n=t.createElement("span"),i=t.createElement("span"),n.className="webodf-hyperlinkTooltipLink",i.className="webodf-hyperlinkTooltipText",(o=t.createElement("div")).className="webodf-hyperlinkTooltip",o.appendChild(n),o.appendChild(i),e.getElement().appendChild(o)}()},gui.OdfFieldView=function(e){var t,n=e.getElement().ownerDocument;this.showFieldHighlight=function(){t.appendChild(n.createTextNode(function(){var e;return(e=odf.OdfSchema.getFields().map((function(e){return e.replace(":","|")}))).join(",\n")+"\n{ background-color: #D0D0D0; }\n\n"+e.map((function(e){return e+":empty::after"})).join(",\n")+"\n{ content:' '; white-space: pre; }\n"}()))},this.hideFieldHighlight=function(){for(var e=t.sheet,n=e.cssRules;n.length;)e.deleteRule(n.length-1)},this.destroy=function(e){t.parentNode&&t.parentNode.removeChild(t),e()},t=function(){var e=n.getElementsByTagName("head").item(0),t=n.createElement("style"),i="";return t.type="text/css",t.media="screen, print, handheld, projection",odf.Namespaces.forEachPrefix((function(e,t){i+="@namespace "+e+" url("+t+");\n"})),t.appendChild(n.createTextNode(i)),e.appendChild(t),t}()},gui.ShadowCursor=function(e){var t=e.getDOMDocument().createRange(),n=!0;this.removeFromDocument=function(){},this.getMemberId=function(){return gui.ShadowCursor.ShadowCursorMemberId},this.getSelectedRange=function(){return t},this.setSelectedRange=function(e,i){t=e,n=!1!==i},this.hasForwardSelection=function(){return n},this.getDocument=function(){return e},this.getSelectionType=function(){return ops.OdtCursor.RangeSelection},t.setStart(e.getRootNode(),0)},gui.ShadowCursor.ShadowCursorMemberId="",gui.SelectionView=function(e){},gui.SelectionView.prototype.rerender=function(){},gui.SelectionView.prototype.show=function(){},gui.SelectionView.prototype.hide=function(){},gui.SelectionView.prototype.destroy=function(e){},gui.SelectionViewManager=function(e){function t(){return Object.keys(n).map((function(e){return n[e]}))}var n={};this.getSelectionView=function(e){return n.hasOwnProperty(e)?n[e]:null},this.getSelectionViews=t,this.removeSelectionView=function(e){n.hasOwnProperty(e)&&(n[e].destroy((function(){})),delete n[e])},this.hideSelectionView=function(e){n.hasOwnProperty(e)&&n[e].hide()},this.showSelectionView=function(e){n.hasOwnProperty(e)&&n[e].show()},this.rerenderSelectionViews=function(){Object.keys(n).forEach((function(e){n[e].rerender()}))},this.registerCursor=function(t,i){var o=t.getMemberId(),r=new e(t);return i?r.show():r.hide(),n[o]=r},this.destroy=function(e){var n=t();!function t(i,o){o?e(o):i .webodf-draggable"),e=gui.ShadowCursor.ShadowCursorMemberId,o(".webodf-selectionOverlay","{ fill: "+i+"; stroke: "+i+";}",""),o(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"))}(e.getMemberId(),(e=e.getProperties()).fullName,e.color)}function f(e){var t=e.getMemberId(),n=i.getOdtDocument().getMember(t).getProperties();r.registerCursor(e,E,T),a.registerCursor(e,!0),(e=r.getCaret(t))&&(e.setAvatarImageUrl(n.imageUrl),e.setColor(n.color)),runtime.log("+++ View here +++ eagerly created an Caret for '"+t+"'! +++")}function p(e){e=e.getMemberId();var t=a.getSelectionView(n),i=a.getSelectionView(gui.ShadowCursor.ShadowCursorMemberId),o=r.getCaret(n);e===n?(i.hide(),t&&t.show(),o&&o.show()):e===gui.ShadowCursor.ShadowCursorMemberId&&(i.show(),t&&t.hide(),o&&o.hide())}function h(e){a.removeSelectionView(e)}function m(e){var t=e.paragraphElement,n=e.memberId;e=e.timeStamp;var o,r="",a=t.getElementsByTagNameNS("urn:webodf:names:editinfo","editinfo").item(0);a?(r=a.getAttributeNS("urn:webodf:names:editinfo","id"),o=x[r]):(r=Math.random().toString(),o=new ops.EditInfo(t,i.getOdtDocument()),o=new gui.EditInfoMarker(o,w),(a=t.getElementsByTagNameNS("urn:webodf:names:editinfo","editinfo").item(0)).setAttributeNS("urn:webodf:names:editinfo","id",r),x[r]=o),o.addEdit(n,new Date(e)),N.trigger()}function g(){var e;v.hasChildNodes()&&core.DomUtils.removeAllChildNodes(v),!0===o.getState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN)&&(e=i.getOdtDocument().getMember(n))&&(e=e.getProperties().fullName,v.appendChild(document.createTextNode(".annotationWrapper:not([creator = '"+e+"']) .annotationRemoveButton { display: none; }")))}function b(e){var t=Object.keys(x).map((function(e){return x[e]}));S.unsubscribe(ops.Document.signalMemberAdded,c),S.unsubscribe(ops.Document.signalMemberUpdated,c),S.unsubscribe(ops.Document.signalCursorAdded,f),S.unsubscribe(ops.Document.signalCursorRemoved,h),S.unsubscribe(ops.OdtDocument.signalParagraphChanged,m),S.unsubscribe(ops.Document.signalCursorMoved,p),S.unsubscribe(ops.OdtDocument.signalParagraphChanged,a.rerenderSelectionViews),S.unsubscribe(ops.OdtDocument.signalTableAdded,a.rerenderSelectionViews),S.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,a.rerenderSelectionViews),o.unsubscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN,g),S.unsubscribe(ops.Document.signalMemberAdded,g),S.unsubscribe(ops.Document.signalMemberUpdated,g),y.parentNode.removeChild(y),v.parentNode.removeChild(v),function n(i,o){o?e(o):it.length;return n&&e(t),n}function n(e,t){var n=[];return e&&["style:parent-style-name","style:next-style-name"].forEach((function(i){e[i]===t&&n.push(i)})),n}function i(e,t){e&&["style:parent-style-name","style:next-style-name"].forEach((function(n){e[n]===t&&delete e[n]}))}function o(e){var t={};return Object.keys(e).forEach((function(n){t[n]="object"==typeof e[n]?o(e[n]):e[n]})),t}function r(e,t,n,i){var o,r,a=!1,s=!1,l=[];if(i&&i.attributes&&(l=i.attributes.split(",")),e&&(n||0=e.length?0:e.length-n.length)):void 0!==e.length&&(o<=(n=e.position+e.length)?e.length-=t.length:i=t.position+t.length||(i=n?e:t,r=n?t:e,e.position===t.position&&e.length===t.length||(c=o(i),f=o(r)),((t=l(r.setProperties,null,i.setProperties,null,"style:text-properties")).majorChanged||t.minorChanged)&&(s=[],e=[],u=i.position+i.length,d=r.position+r.length,r.positionu?t.minorChanged&&((c=f).position=u,c.length=d-u,e.push(c),r.length=u-r.position):u>d&&t.majorChanged&&(c.position=d,c.length=u-d,s.push(c),i.length=d-i.position),i.setProperties&&a(i.setProperties)&&s.push(i),r.setProperties&&a(r.setProperties)&&e.push(r),n?(u=s,s=e):u=e)),{opSpecsA:u,opSpecsB:s}},InsertText:function(e,t){return t.position<=e.position?e.position+=t.text.length:t.position<=e.position+e.length&&(e.length+=t.text.length),{opSpecsA:[e],opSpecsB:[t]}},MergeParagraph:function(e,t){var n=e.position,i=e.position+e.length;return n>=t.sourceStartPosition&&--n,i>=t.sourceStartPosition&&--i,e.position=n,e.length=i-n,{opSpecsA:[e],opSpecsB:[t]}},MoveCursor:u,RemoveAnnotation:function(e,t){var n=e.position,i=e.position+e.length,o=t.position+t.length,r=[e],a=[t];return t.position<=n&&i<=o?r=[]:(ot.position?e.position+=t.text.length:n?t.position+=e.text.length:e.position+=t.text.length,{opSpecsA:[e],opSpecsB:[t]}},MergeParagraph:function(e,t){return e.position>=t.sourceStartPosition?--e.position:(e.positione.position&&(t.position+=e.text.length),{opSpecsA:[e],opSpecsB:[t]}},SplitParagraph:function(e,t){return e.position=e.sourceStartPosition&&--o,n>=e.sourceStartPosition&&--n,0<=t.length?(t.position=o,t.length=n-o):(t.position=n,t.length=o-n),{opSpecsA:[e],opSpecsB:[t]}},RemoveAnnotation:function(e,t){var n=t.position+t.length,i=[e],o=[t];return t.position<=e.destinationStartPosition&&e.sourceStartPosition<=n?(i=[],--t.length):e.sourceStartPosition=e.sourceStartPosition?--t.position:(t.positione.sourceStartPosition?--t.position:t.position!==e.destinationStartPosition&&t.position!==e.sourceStartPosition||(t.position=e.destinationStartPosition,e.paragraphStyleName=t.styleName),{opSpecsA:n,opSpecsB:i}},SplitParagraph:function(e,t){var n,i=[e],o=[t];return t.position=e.destinationStartPosition&&t.position=e.sourceStartPosition&&(--t.position,--t.sourceParagraphPosition),{opSpecsA:i,opSpecsB:o}},UpdateMember:u,UpdateMetadata:u,UpdateParagraphStyle:u},MoveCursor:{MoveCursor:u,RemoveAnnotation:function(n,i){var o=t(n),r=n.position+n.length,a=i.position+i.length;return i.position<=n.position&&r<=a?(n.position=i.position-1,n.length=0):(at.position?e.position+=1:e.position===t.sourceParagraphPosition&&(t.paragraphStyleName=e.styleName,(n=o(e)).position=t.position+1,i.push(n)),{opSpecsA:i,opSpecsB:r}},UpdateMember:u,UpdateMetadata:u,UpdateParagraphStyle:u},SplitParagraph:{SplitParagraph:function(e,t,n){var i,o;return e.position (c) 2009-2014 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/master/LICENSE @licend */globalScope="undefined"!=typeof window?window:"undefined"!=typeof global?global:{},(globalScope.externs||(globalScope.externs={})).JSZip=function e(t,n,i){function o(a,s){if(!n[a]){if(!t[a]){var l="function"==typeof require&&require;if(!s&&l)return l(a,!0);if(r)return r(a,!0);throw new Error("Cannot find module '"+a+"'")}var u=n[a]={exports:{}};t[a][0].call(u.exports,(function(e){return o(t[a][1][e]||e)}),u,u.exports,e,t,n,i)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a>2,s=(3&n)<<4|(o=e.charCodeAt(c++))>>4,l=(15&o)<<2|(r=e.charCodeAt(c++))>>6,u=63&r,isNaN(o)?l=u=64:isNaN(r)&&(u=64),d=d+i.charAt(a)+i.charAt(s)+i.charAt(l)+i.charAt(u);return d},n.decode=function(e,t){var n,o,r,a,s,l,u="",d=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");d>4,o=(15&a)<<4|(s=i.indexOf(e.charAt(d++)))>>2,r=(3&s)<<6|(l=i.indexOf(e.charAt(d++))),u+=String.fromCharCode(n),64!=s&&(u+=String.fromCharCode(o)),64!=l&&(u+=String.fromCharCode(r));return u}},{}],2:[function(e,t,n){function i(){this.compressedSize=0,this.uncompressedSize=0,this.crc32=0,this.compressionMethod=null,this.compressedContent=null}i.prototype={getContent:function(){return null},getCompressedContent:function(){return null}},t.exports=i},{}],3:[function(e,t,n){n.STORE={magic:"\0\0",compress:function(e){return e},uncompress:function(e){return e},compressInputType:null,uncompressInputType:null},n.DEFLATE=e("./flate")},{"./flate":8}],4:[function(e,t,n){var i=e("./utils"),o=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];t.exports=function(e,t){if(void 0===e||!e.length)return 0;var n="string"!==i.getTypeOf(e);void 0===t&&(t=0);var r=0;t^=-1;for(var a=0,s=e.length;a>>8^o[255&(t^r)];return-1^t}},{"./utils":21}],5:[function(e,t,n){var i=e("./utils");function o(e){this.data=null,this.length=0,this.index=0}o.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return i.transformTo("string",this.readData(e))},readData:function(e){},lastIndexOfSignature:function(e){},readDate:function(){var e=this.readInt(4);return new Date(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1)}},t.exports=o},{"./utils":21}],6:[function(e,t,n){n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!1,n.date=null,n.compression=null,n.comment=null},{}],7:[function(e,t,n){var i=e("./utils");n.string2binary=function(e){return i.string2binary(e)},n.string2Uint8Array=function(e){return i.transformTo("uint8array",e)},n.uint8Array2String=function(e){return i.transformTo("string",e)},n.string2Blob=function(e){var t=i.transformTo("arraybuffer",e);return i.arrayBuffer2Blob(t)},n.arrayBuffer2Blob=function(e){return i.arrayBuffer2Blob(e)},n.transformTo=function(e,t){return i.transformTo(e,t)},n.getTypeOf=function(e){return i.getTypeOf(e)},n.checkSupport=function(e){return i.checkSupport(e)},n.MAX_VALUE_16BITS=i.MAX_VALUE_16BITS,n.MAX_VALUE_32BITS=i.MAX_VALUE_32BITS,n.pretty=function(e){return i.pretty(e)},n.findCompression=function(e){return i.findCompression(e)},n.isRegExp=function(e){return i.isRegExp(e)}},{"./utils":21}],8:[function(e,t,n){var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,o=e("pako");n.uncompressInputType=i?"uint8array":"array",n.compressInputType=i?"uint8array":"array",n.magic="\b\0",n.compress=function(e){return o.deflateRaw(e)},n.uncompress=function(e){return o.inflateRaw(e)}},{pako:24}],9:[function(e,t,n){var i=e("./base64");function o(e,t){if(!(this instanceof o))return new o(e,t);this.files={},this.comment=null,this.root="",e&&this.load(e,t),this.clone=function(){var e=new o;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e}}o.prototype=e("./object"),o.prototype.load=e("./load"),o.support=e("./support"),o.defaults=e("./defaults"),o.utils=e("./deprecatedPublicUtils"),o.base64={encode:function(e){return i.encode(e)},decode:function(e){return i.decode(e)}},o.compressions=e("./compressions"),t.exports=o},{"./base64":1,"./compressions":3,"./defaults":6,"./deprecatedPublicUtils":7,"./load":10,"./object":13,"./support":17}],10:[function(e,t,n){var i=e("./base64"),o=e("./zipEntries");t.exports=function(e,t){var n,r,a,s;for((t=t||{}).base64&&(e=i.decode(e)),n=(r=new o(e,t)).files,a=0;a>>=8;return i},S=function(){var e,t,n={};for(e=0;e0?e.substring(0,t):""},x=function(e,t){return"/"!=e.slice(-1)&&(e+="/"),t=void 0!==t&&t,this.files[e]||C.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]},w=function(e,t){var n,i=new d;return e._data instanceof d?(i.uncompressedSize=e._data.uncompressedSize,i.crc32=e._data.crc32,0===i.uncompressedSize||e.dir?(t=u.STORE,i.compressedContent="",i.crc32=0):e._data.compressionMethod===t.magic?i.compressedContent=e._data.getCompressedContent():(n=e._data.getContent(),i.compressedContent=t.compress(o.transformTo(t.compressInputType,n)))):((n=g(e))&&0!==n.length&&!e.dir||(t=u.STORE,n=""),i.uncompressedSize=n.length,i.crc32=r(n),i.compressedContent=t.compress(o.transformTo(t.compressInputType,n))),i.compressedSize=i.compressedContent.length,i.compressionMethod=t.magic,i},E=function(e,t,n,i){n.compressedContent;var s,l,u,d,c=o.transformTo("string",f.utf8encode(t.name)),p=t.comment||"",h=o.transformTo("string",f.utf8encode(p)),m=c.length!==t.name.length,g=h.length!==p.length,b=t.options,y="",S="",C="";u=t._initialMetadata.dir!==t.dir?t.dir:b.dir,s=(d=t._initialMetadata.date!==t.date?t.date:b.date).getHours(),s<<=6,s|=d.getMinutes(),s<<=5,s|=d.getSeconds()/2,l=d.getFullYear()-1980,l<<=4,l|=d.getMonth()+1,l<<=5,l|=d.getDate(),m&&(S=v(1,1)+v(r(c),4)+c,y+="up"+v(S.length,2)+S),g&&(C=v(1,1)+v(this.crc32(h),4)+h,y+="uc"+v(C.length,2)+C);var N="";return N+="\n\0",N+=m||g?"\0\b":"\0\0",N+=n.compressionMethod,N+=v(s,2),N+=v(l,2),N+=v(n.crc32,4),N+=v(n.compressedSize,4),N+=v(n.uncompressedSize,4),N+=v(c.length,2),N+=v(y.length,2),{fileRecord:a.LOCAL_FILE_HEADER+N+c+y,dirRecord:a.CENTRAL_FILE_HEADER+"\0"+N+v(h.length,2)+"\0\0\0\0"+(!0===u?"\0\0\0":"\0\0\0\0")+v(i,4)+c+y+h,compressedObject:n}},T={load:function(e,t){throw new Error("Load method is not defined. Is the file jszip-load.js included ?")},filter:function(e){var t,n,i,o,r=[];for(t in this.files)this.files.hasOwnProperty(t)&&(i=this.files[t],o=new y(i.name,i._data,S(i.options)),n=t.slice(this.root.length,t.length),t.slice(0,this.root.length)===this.root&&e(n,o)&&r.push(o));return r},file:function(e,t,n){if(1===arguments.length){if(o.isRegExp(e)){var i=e;return this.filter((function(e,t){return!t.dir&&i.test(e)}))}return this.filter((function(t,n){return!n.dir&&t===e}))[0]||null}return e=this.root+e,C.call(this,e,t,n),this},folder:function(e){if(!e)return this;if(o.isRegExp(e))return this.filter((function(t,n){return n.dir&&e.test(t)}));var t=this.root+e,n=x.call(this,t),i=this.clone();return i.root=n.name,i},remove:function(e){e=this.root+e;var t=this.files[e];if(t||("/"!=e.slice(-1)&&(e+="/"),t=this.files[e]),t&&!t.dir)delete this.files[e];else for(var n=this.filter((function(t,n){return n.name.slice(0,e.length)===e})),i=0;i=0;--r)if(this.data[r]===t&&this.data[r+1]===n&&this.data[r+2]===i&&this.data[r+3]===o)return r;return-1},o.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.index,this.index+e);return this.index+=e,t},t.exports=o},{"./dataReader":5}],19:[function(e,t,n){var i=e("./utils"),o=function(e){this.data=new Uint8Array(e),this.index=0};o.prototype={append:function(e){0!==e.length&&(e=i.transformTo("uint8array",e),this.data.set(e,this.index),this.index+=e.length)},finalize:function(){return this.data}},t.exports=o},{"./utils":21}],20:[function(e,t,n){for(var i=e("./utils"),o=e("./support"),r=e("./nodeBuffer"),a=new Array(256),s=0;s<256;s++)a[s]=s>=252?6:s>=248?5:s>=240?4:s>=224?3:s>=192?2:1;a[254]=a[254]=1;var l=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+a[e[n]]>t?n:t},u=function(e){var t,n,o,r,s=e.length,l=new Array(2*s);for(n=0,t=0;t4)l[n++]=65533,t+=r-1;else{for(o&=2===r?31:3===r?15:7;r>1&&t1?l[n++]=65533:o<65536?l[n++]=o:(o-=65536,l[n++]=55296|o>>10&1023,l[n++]=56320|1023&o)}return l.length!==n&&(l.subarray?l=l.subarray(0,n):l.length=n),i.applyFromCharCode(l)};n.utf8encode=function(e){return o.nodebuffer?r(e,"utf-8"):function(e){var t,n,i,r,a,s=e.length,l=0;for(r=0;r>>6,t[a++]=128|63&n):n<65536?(t[a++]=224|n>>>12,t[a++]=128|n>>>6&63,t[a++]=128|63&n):(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63,t[a++]=128|n>>>6&63,t[a++]=128|63&n);return t}(e)},n.utf8decode=function(e){if(o.nodebuffer)return i.transformTo("nodebuffer",e).toString("utf-8");for(var t=[],n=0,r=(e=i.transformTo(o.uint8array?"uint8array":"array",e)).length;n1;)try{"array"===a||"nodebuffer"===a?i.push(String.fromCharCode.apply(null,e.slice(s,Math.min(s+t,o)))):i.push(String.fromCharCode.apply(null,e.subarray(s,Math.min(s+t,o)))),s+=t}catch(e){t=Math.floor(t/2)}return i.join("")}function u(e,t){for(var n=0;n1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;var n=i.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==n)throw new Error(a[n]);t.header&&i.deflateSetHeader(this.strm,t.header)};function u(e,t){var n=new l(t);if(n.push(e,!0),n.err)throw n.msg;return n.result}l.prototype.push=function(e,t){var n,a,s=this.strm,l=this.options.chunkSize;if(this.ended)return!1;a=t===~~t?t:!0===t?4:0,s.input="string"==typeof e?r.string2buf(e):e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new o.Buf8(l),s.next_out=0,s.avail_out=l),1!==(n=i.deflate(s,a))&&0!==n)return this.onEnd(n),this.ended=!0,!1;(0===s.avail_out||0===s.avail_in&&4===a)&&("string"===this.options.to?this.onData(r.buf2binstring(o.shrinkBuf(s.output,s.next_out))):this.onData(o.shrinkBuf(s.output,s.next_out)))}while((s.avail_in>0||0===s.avail_out)&&1!==n);return 4!==a||(n=i.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,0===n)},l.prototype.onData=function(e){this.chunks.push(e)},l.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Deflate=l,n.deflate=u,n.deflateRaw=function(e,t){return(t=t||{}).raw=!0,u(e,t)},n.gzip=function(e,t){return(t=t||{}).gzip=!0,u(e,t)}},{"./utils/common":27,"./utils/strings":28,"./zlib/deflate.js":32,"./zlib/messages":37,"./zlib/zstream":39}],26:[function(e,t,n){var i=e("./zlib/inflate.js"),o=e("./utils/common"),r=e("./utils/strings"),a=e("./zlib/constants"),s=e("./zlib/messages"),l=e("./zlib/zstream"),u=e("./zlib/gzheader"),d=function(e){this.options=o.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var n=i.inflateInit2(this.strm,t.windowBits);if(n!==a.Z_OK)throw new Error(s[n]);this.header=new u,i.inflateGetHeader(this.strm,this.header)};function c(e,t){var n=new d(t);if(n.push(e,!0),n.err)throw n.msg;return n.result}d.prototype.push=function(e,t){var n,s,l,u,d,c=this.strm,f=this.options.chunkSize;if(this.ended)return!1;s=t===~~t?t:!0===t?a.Z_FINISH:a.Z_NO_FLUSH,c.input="string"==typeof e?r.binstring2buf(e):e,c.next_in=0,c.avail_in=c.input.length;do{if(0===c.avail_out&&(c.output=new o.Buf8(f),c.next_out=0,c.avail_out=f),(n=i.inflate(c,a.Z_NO_FLUSH))!==a.Z_STREAM_END&&n!==a.Z_OK)return this.onEnd(n),this.ended=!0,!1;c.next_out&&(0===c.avail_out||n===a.Z_STREAM_END||0===c.avail_in&&s===a.Z_FINISH)&&("string"===this.options.to?(l=r.utf8border(c.output,c.next_out),u=c.next_out-l,d=r.buf2string(c.output,l),c.next_out=u,c.avail_out=f-u,u&&o.arraySet(c.output,c.output,l,u,0),this.onData(d)):this.onData(o.shrinkBuf(c.output,c.next_out)))}while(c.avail_in>0&&n!==a.Z_STREAM_END);return n===a.Z_STREAM_END&&(s=a.Z_FINISH),s!==a.Z_FINISH||(n=i.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===a.Z_OK)},d.prototype.onData=function(e){this.chunks.push(e)},d.prototype.onEnd=function(e){e===a.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Inflate=d,n.inflate=c,n.inflateRaw=function(e,t){return(t=t||{}).raw=!0,c(e,t)},n.ungzip=c},{"./utils/common":27,"./utils/strings":28,"./zlib/constants":30,"./zlib/gzheader":33,"./zlib/inflate.js":35,"./zlib/messages":37,"./zlib/zstream":39}],27:[function(e,t,n){var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;n.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var o={arraySet:function(e,t,n,i,o){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+i),o);else for(var r=0;r=252?6:s>=248?5:s>=240?4:s>=224?3:s>=192?2:1;function l(e,t){if(t<65537&&(e.subarray&&r||!e.subarray&&o))return String.fromCharCode.apply(null,i.shrinkBuf(e,t));for(var n="",a=0;a>>6,t[a++]=128|63&n):n<65536?(t[a++]=224|n>>>12,t[a++]=128|n>>>6&63,t[a++]=128|63&n):(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63,t[a++]=128|n>>>6&63,t[a++]=128|63&n);return t},n.buf2binstring=function(e){return l(e,e.length)},n.binstring2buf=function(e){for(var t=new i.Buf8(e.length),n=0,o=t.length;n4)u[i++]=65533,n+=r-1;else{for(o&=2===r?31:3===r?15:7;r>1&&n1?u[i++]=65533:o<65536?u[i++]=o:(o-=65536,u[i++]=55296|o>>10&1023,u[i++]=56320|1023&o)}return l(u,i)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+a[e[n]]>t?n:t}},{"./common":27}],29:[function(e,t,n){t.exports=function(e,t,n,i){for(var o=65535&e|0,r=e>>>16&65535|0,a=0;0!==n;){n-=a=n>2e3?2e3:n;do{r=r+(o=o+t[i++]|0)|0}while(--a);o%=65521,r%=65521}return o|r<<16|0}},{}],30:[function(e,t,n){t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],31:[function(e,t,n){var i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,o){var r=i,a=o+n;e^=-1;for(var s=o;s>>8^r[255&(e^t[s])];return-1^e}},{}],32:[function(e,t,n){var i=e("../utils/common"),o=e("./trees"),r=e("./adler32"),a=e("./crc32"),s=e("./messages");function l(e,t){return e.msg=s[t],t}function u(e){return(e<<1)-(e>4?9:0)}function d(e){for(var t=e.length;--t>=0;)e[t]=0}function c(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function f(e,t){o._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,c(e.strm)}function p(e,t){e.pending_buf[e.pending++]=t}function h(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function m(e,t){var n,i,o=e.max_chain_length,r=e.strstart,a=e.prev_length,s=e.nice_match,l=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,u=e.window,d=e.w_mask,c=e.prev,f=e.strstart+258,p=u[r+a-1],h=u[r+a];e.prev_length>=e.good_match&&(o>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(n=t)+a]===h&&u[n+a-1]===p&&u[n]===u[r]&&u[++n]===u[r+1]){r+=2,n++;do{}while(u[++r]===u[++n]&&u[++r]===u[++n]&&u[++r]===u[++n]&&u[++r]===u[++n]&&u[++r]===u[++n]&&u[++r]===u[++n]&&u[++r]===u[++n]&&u[++r]===u[++n]&&ra){if(e.match_start=t,a=i,i>=s)break;p=u[r+a-1],h=u[r+a]}}}while((t=c[t&d])>l&&0!=--o);return a<=e.lookahead?a:e.lookahead}function g(e){var t,n,o,s,l,u,d,c,f,p,h=e.w_size;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=h+(h-262)){i.arraySet(e.window,e.window,h,h,0),e.match_start-=h,e.strstart-=h,e.block_start-=h,t=n=e.hash_size;do{o=e.head[--t],e.head[t]=o>=h?o-h:0}while(--n);t=n=h;do{o=e.prev[--t],e.prev[t]=o>=h?o-h:0}while(--n);s+=h}if(0===e.strm.avail_in)break;if(u=e.strm,d=e.window,c=e.strstart+e.lookahead,f=s,p=void 0,(p=u.avail_in)>f&&(p=f),n=0===p?0:(u.avail_in-=p,i.arraySet(d,u.input,u.next_in,p,c),1===u.state.wrap?u.adler=r(u.adler,d,p,c):2===u.state.wrap&&(u.adler=a(u.adler,d,p,c)),u.next_in+=p,u.total_in+=p,p),e.lookahead+=n,e.lookahead+e.insert>=3)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3)if(i=o._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,i=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=(e.ins_h<15&&(s=2,o-=16),r<1||r>9||8!==n||o<8||o>15||t<0||t>9||a<0||a>4)return l(e,-2);8===o&&(o=9);var u=new C;return e.state=u,u.strm=e,u.wrap=s,u.gzhead=null,u.w_bits=o,u.w_size=1<>1,u.l_buf=3*u.lit_bufsize,u.level=t,u.strategy=a,u.method=n,x(e)}v=[new S(0,0,0,0,(function(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(g(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+n;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,f(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(f(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(f(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(f(e,!1),e.strm.avail_out),1)})),new S(4,4,8,4,b),new S(4,5,16,8,b),new S(4,6,32,32,b),new S(4,4,16,16,y),new S(8,16,32,32,y),new S(8,16,128,128,y),new S(8,32,128,256,y),new S(32,128,258,1024,y),new S(32,258,258,4096,y)],n.deflateInit=function(e,t){return w(e,t,8,15,8,0)},n.deflateInit2=w,n.deflateReset=x,n.deflateResetKeep=N,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?-2:(e.state.gzhead=t,0):-2},n.deflate=function(e,t){var n,i,r,s;if(!e||!e.state||t>5||t<0)return e?l(e,-2):-2;if(i=e.state,!e.output||!e.input&&0!==e.avail_in||666===i.status&&4!==t)return l(e,0===e.avail_out?-5:-2);if(i.strm=e,n=i.last_flush,i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,p(i,31),p(i,139),p(i,8),i.gzhead?(p(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),p(i,255&i.gzhead.time),p(i,i.gzhead.time>>8&255),p(i,i.gzhead.time>>16&255),p(i,i.gzhead.time>>24&255),p(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),p(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(p(i,255&i.gzhead.extra.length),p(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=a(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(p(i,0),p(i,0),p(i,0),p(i,0),p(i,0),p(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),p(i,3),i.status=113);else{var m=8+(i.w_bits-8<<4)<<8;m|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(m|=32),m+=31-m%31,i.status=113,h(i,m),0!==i.strstart&&(h(i,e.adler>>>16),h(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(e.adler=a(e.adler,i.pending_buf,i.pending-r,r)),c(e),r=i.pending,i.pending!==i.pending_buf_size));)p(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=a(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=a(e.adler,i.pending_buf,i.pending-r,r)),c(e),r=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindexr&&(e.adler=a(e.adler,i.pending_buf,i.pending-r,r)),0===s&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=a(e.adler,i.pending_buf,i.pending-r,r)),c(e),r=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindexr&&(e.adler=a(e.adler,i.pending_buf,i.pending-r,r)),0===s&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&c(e),i.pending+2<=i.pending_buf_size&&(p(i,255&e.adler),p(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(c(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&u(t)<=u(n)&&4!==t)return l(e,-5);if(666===i.status&&0!==e.avail_in)return l(e,-5);if(0!==e.avail_in||0!==i.lookahead||0!==t&&666!==i.status){var b=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(g(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(f(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(f(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(f(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var n,i,r,a,s=e.window;;){if(e.lookahead<=258){if(g(e),e.lookahead<=258&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=s[r=e.strstart-1])===s[++r]&&i===s[++r]&&i===s[++r]){a=e.strstart+258;do{}while(i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&i===s[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=o._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(f(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(f(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(f(e,!1),0===e.strm.avail_out)?1:2}(i,t):v[i.level].func(i,t);if(3!==b&&4!==b||(i.status=666),1===b||3===b)return 0===e.avail_out&&(i.last_flush=-1),0;if(2===b&&(1===t?o._tr_align(i):5!==t&&(o._tr_stored_block(i,0,0,!1),3===t&&(d(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),c(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(p(i,255&e.adler),p(i,e.adler>>8&255),p(i,e.adler>>16&255),p(i,e.adler>>24&255),p(i,255&e.total_in),p(i,e.total_in>>8&255),p(i,e.total_in>>16&255),p(i,e.total_in>>24&255)):(h(i,e.adler>>>16),h(i,65535&e.adler)),c(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)},n.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?l(e,-2):(e.state=null,113===t?l(e,-3):0):-2},n.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":27,"./adler32":29,"./crc32":31,"./messages":37,"./trees":38}],33:[function(e,t,n){t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],34:[function(e,t,n){t.exports=function(e,t){var n,i,o,r,a,s,l,u,d,c,f,p,h,m,g,b,y,v,S,C,N,x,w,E,T;n=e.state,i=e.next_in,E=e.input,o=i+(e.avail_in-5),r=e.next_out,T=e.output,a=r-(t-e.avail_out),s=r+(e.avail_out-257),l=n.dmax,u=n.wsize,d=n.whave,c=n.wnext,f=n.window,p=n.hold,h=n.bits,m=n.lencode,g=n.distcode,b=(1<>>=S=v>>>24,h-=S,0==(S=v>>>16&255))T[r++]=65535&v;else{if(!(16&S)){if(0==(64&S)){v=m[(65535&v)+(p&(1<>>=S,h-=S),h<15&&(p+=E[i++]<>>=S=v>>>24,h-=S,!(16&(S=v>>>16&255))){if(0==(64&S)){v=g[(65535&v)+(p&(1<l){e.msg="invalid distance too far back",n.mode=30;break e}if(p>>>=S,h-=S,N>(S=r-a)){if((S=N-S)>d&&n.sane){e.msg="invalid distance too far back",n.mode=30;break e}if(x=0,w=f,0===c){if(x+=u-S,S2;)T[r++]=w[x++],T[r++]=w[x++],T[r++]=w[x++],C-=3;C&&(T[r++]=w[x++],C>1&&(T[r++]=w[x++]))}else{x=r-N;do{T[r++]=T[x++],T[r++]=T[x++],T[r++]=T[x++],C-=3}while(C>2);C&&(T[r++]=T[x++],C>1&&(T[r++]=T[x++]))}break}}break}}while(i>3,p&=(1<<(h-=C<<3))-1,e.next_in=i,e.next_out=r,e.avail_in=i>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function d(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new i.Buf32(852),t.distcode=t.distdyn=new i.Buf32(592),t.sane=1,t.back=-1,0):-2}function c(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,d(e)):-2}function f(e,t){var n,i;return e&&e.state?(i=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?-2:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,c(e))):-2}function p(e,t){var n,i;return e?(i=new u,e.state=i,i.window=null,0!==(n=f(e,t))&&(e.state=null),n):-2}var h,m,g=!0;function b(e){if(g){var t;for(h=new i.Buf32(512),m=new i.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(s(1,e.lens,0,288,h,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;s(2,e.lens,0,32,m,0,e.work,{bits:5}),g=!1}e.lencode=h,e.lenbits=9,e.distcode=m,e.distbits=5}n.inflateReset=c,n.inflateReset2=f,n.inflateResetKeep=d,n.inflateInit=function(e){return p(e,15)},n.inflateInit2=p,n.inflate=function(e,t){var n,u,d,c,f,p,h,m,g,y,v,S,C,N,x,w,E,T,O,A,R,_,P,D,k=0,I=new i.Buf8(4),F=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return-2;12===(n=e.state).mode&&(n.mode=13),f=e.next_out,d=e.output,h=e.avail_out,c=e.next_in,u=e.input,p=e.avail_in,m=n.hold,g=n.bits,y=p,v=h,_=0;e:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;g<16;){if(0===p)break e;p--,m+=u[c++]<>>8&255,n.check=r(n.check,I,2,0),m=0,g=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&m)<<8)+(m>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&m)){e.msg="unknown compression method",n.mode=30;break}if(g-=4,R=8+(15&(m>>>=4)),0===n.wbits)n.wbits=R;else if(R>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(I[0]=255&m,I[1]=m>>>8&255,n.check=r(n.check,I,2,0)),m=0,g=0,n.mode=3;case 3:for(;g<32;){if(0===p)break e;p--,m+=u[c++]<>>8&255,I[2]=m>>>16&255,I[3]=m>>>24&255,n.check=r(n.check,I,4,0)),m=0,g=0,n.mode=4;case 4:for(;g<16;){if(0===p)break e;p--,m+=u[c++]<>8),512&n.flags&&(I[0]=255&m,I[1]=m>>>8&255,n.check=r(n.check,I,2,0)),m=0,g=0,n.mode=5;case 5:if(1024&n.flags){for(;g<16;){if(0===p)break e;p--,m+=u[c++]<>>8&255,n.check=r(n.check,I,2,0)),m=0,g=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&((S=n.length)>p&&(S=p),S&&(n.head&&(R=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),i.arraySet(n.head.extra,u,c,S,R)),512&n.flags&&(n.check=r(n.check,u,S,c)),p-=S,c+=S,n.length-=S),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===p)break e;S=0;do{R=u[c+S++],n.head&&R&&n.length<65536&&(n.head.name+=String.fromCharCode(R))}while(R&&S>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;g<32;){if(0===p)break e;p--,m+=u[c++]<>>=7&g,g-=7&g,n.mode=27;break}for(;g<3;){if(0===p)break e;p--,m+=u[c++]<>>=1)){case 0:n.mode=14;break;case 1:if(b(n),n.mode=20,6===t){m>>>=2,g-=2;break e}break;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}m>>>=2,g-=2;break;case 14:for(m>>>=7&g,g-=7&g;g<32;){if(0===p)break e;p--,m+=u[c++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&m,m=0,g=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(S=n.length){if(S>p&&(S=p),S>h&&(S=h),0===S)break e;i.arraySet(d,u,c,S,f),p-=S,c+=S,h-=S,f+=S,n.length-=S;break}n.mode=12;break;case 17:for(;g<14;){if(0===p)break e;p--,m+=u[c++]<>>=5,g-=5,n.ndist=1+(31&m),m>>>=5,g-=5,n.ncode=4+(15&m),m>>>=4,g-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have>>=3,g-=3}for(;n.have<19;)n.lens[F[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,P={bits:n.lenbits},_=s(0,n.lens,0,19,n.lencode,0,n.work,P),n.lenbits=P.bits,_){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,E=65535&k,!((x=k>>>24)<=g);){if(0===p)break e;p--,m+=u[c++]<>>=x,g-=x,n.lens[n.have++]=E;else{if(16===E){for(D=x+2;g>>=x,g-=x,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}R=n.lens[n.have-1],S=3+(3&m),m>>>=2,g-=2}else if(17===E){for(D=x+3;g>>=x)),m>>>=3,g-=3}else{for(D=x+7;g>>=x)),m>>>=7,g-=7}if(n.have+S>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;S--;)n.lens[n.have++]=R}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,P={bits:n.lenbits},_=s(1,n.lens,0,n.nlen,n.lencode,0,n.work,P),n.lenbits=P.bits,_){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,P={bits:n.distbits},_=s(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,P),n.distbits=P.bits,_){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(p>=6&&h>=258){e.next_out=f,e.avail_out=h,e.next_in=c,e.avail_in=p,n.hold=m,n.bits=g,a(e,v),f=e.next_out,d=e.output,h=e.avail_out,c=e.next_in,u=e.input,p=e.avail_in,m=n.hold,g=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;w=(k=n.lencode[m&(1<>>16&255,E=65535&k,!((x=k>>>24)<=g);){if(0===p)break e;p--,m+=u[c++]<>T)])>>>16&255,E=65535&k,!(T+(x=k>>>24)<=g);){if(0===p)break e;p--,m+=u[c++]<>>=T,g-=T,n.back+=T}if(m>>>=x,g-=x,n.back+=x,n.length=E,0===w){n.mode=26;break}if(32&w){n.back=-1,n.mode=12;break}if(64&w){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&w,n.mode=22;case 22:if(n.extra){for(D=n.extra;g>>=n.extra,g-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;w=(k=n.distcode[m&(1<>>16&255,E=65535&k,!((x=k>>>24)<=g);){if(0===p)break e;p--,m+=u[c++]<>T)])>>>16&255,E=65535&k,!(T+(x=k>>>24)<=g);){if(0===p)break e;p--,m+=u[c++]<>>=T,g-=T,n.back+=T}if(m>>>=x,g-=x,n.back+=x,64&w){e.msg="invalid distance code",n.mode=30;break}n.offset=E,n.extra=15&w,n.mode=24;case 24:if(n.extra){for(D=n.extra;g>>=n.extra,g-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===h)break e;if(S=v-h,n.offset>S){if((S=n.offset-S)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}S>n.wnext?(S-=n.wnext,C=n.wsize-S):C=n.wnext-S,S>n.length&&(S=n.length),N=n.window}else N=d,C=f-n.offset,S=n.length;S>h&&(S=h),h-=S,n.length-=S;do{d[f++]=N[C++]}while(--S);0===n.length&&(n.mode=21);break;case 26:if(0===h)break e;d[f++]=n.length,h--,n.mode=21;break;case 27:if(n.wrap){for(;g<32;){if(0===p)break e;p--,m|=u[c++]<=a.wsize?(i.arraySet(a.window,t,n-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((r=a.wsize-a.wnext)>o&&(r=o),i.arraySet(a.window,t,n-o,r,a.wnext),(o-=r)?(i.arraySet(a.window,t,n-o,o,0),a.wnext=o,a.whave=a.wsize):(a.wnext+=r,a.wnext===a.wsize&&(a.wnext=0),a.whave=1&&0===F[T];T--);if(O>T&&(O=T),0===T)return u[d++]=20971520,u[d++]=20971520,f.bits=1,0;for(E=1;E0&&(0===e||1!==T))return-1;for(M[1]=0,x=1;x<15;x++)M[x+1]=M[x]+F[x];for(w=0;w852||2===e&&P>592)return 1;for(;;){v=x-R,c[w]y?(S=B[U+c[w]],C=k[I+c[w]]):(S=96,C=0),p=1<>R)+(h-=p)]=v<<24|S<<16|C|0}while(0!==h);for(p=1<>=1;if(0!==p?(D&=p-1,D+=p):D=0,w++,0==--F[x]){if(x===T)break;x=t[n+c[w]]}if(x>O&&(D&g)!==m){for(0===R&&(R=O),b+=E,_=1<<(A=x-R);A+R852||2===e&&P>592)return 1;u[m=D&g]=O<<24|A<<16|b-d|0}}return 0!==D&&(u[b+D]=x-R<<24|64<<16|0),f.bits=O,0}},{"../utils/common":27}],37:[function(e,t,n){t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],38:[function(e,t,n){var i=e("../utils/common");function o(e){for(var t=e.length;--t>=0;)e[t]=0}var r=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],a=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],l=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],u=new Array(576);o(u);var d=new Array(60);o(d);var c=new Array(512);o(c);var f=new Array(256);o(f);var p=new Array(29);o(p);var h=new Array(30);o(h);var m,g,b,y=function(e,t,n,i,o){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=o,this.has_stree=e&&e.length},v=function(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t};function S(e){return e<256?c[e]:c[256+(e>>>7)]}function C(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function N(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<>>=1,n<<=1}while(--t>0);return n>>>1}function E(e,t,n){var i,o,r=new Array(16),a=0;for(i=1;i<=15;i++)r[i]=a=a+n[i-1]<<1;for(o=0;o<=t;o++){var s=e[2*o+1];0!==s&&(e[2*o]=w(r[s]++,s))}}function T(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function O(e){e.bi_valid>8?C(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function A(e,t,n,i){var o=2*t,r=2*n;return e[o]>1;n>=1;n--)R(e,r,n);o=l;do{n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],R(e,r,1),i=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=i,r[2*o]=r[2*n]+r[2*i],e.depth[o]=(e.depth[n]>=e.depth[i]?e.depth[n]:e.depth[i])+1,r[2*n+1]=r[2*i+1]=o,e.heap[1]=o++,R(e,r,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,i,o,r,a,s,l=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,c=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,h=t.stat_desc.max_length,m=0;for(r=0;r<=15;r++)e.bl_count[r]=0;for(l[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)(r=l[2*l[2*(i=e.heap[n])+1]+1]+1)>h&&(r=h,m++),l[2*i+1]=r,i>u||(e.bl_count[r]++,a=0,i>=p&&(a=f[i-p]),s=l[2*i],e.opt_len+=s*(r+a),c&&(e.static_len+=s*(d[2*i+1]+a)));if(0!==m){do{for(r=h-1;0===e.bl_count[r];)r--;e.bl_count[r]--,e.bl_count[r+1]+=2,e.bl_count[h]--,m-=2}while(m>0);for(r=h;0!==r;r--)for(i=e.bl_count[r];0!==i;)(o=e.heap[--n])>u||(l[2*o+1]!==r&&(e.opt_len+=(r-l[2*o+1])*l[2*o],l[2*o+1]=r),i--)}}(e,t),E(r,u,e.bl_count)}function D(e,t,n){var i,o,r=-1,a=t[1],s=0,l=7,u=4;for(0===a&&(l=138,u=3),t[2*(n+1)+1]=65535,i=0;i<=n;i++)o=a,a=t[2*(i+1)+1],++s>=7;i<30;i++)for(h[i]=o<<7,e=0;e<1<0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),P(e,e.l_desc),P(e,e.d_desc),a=function(e){var t;for(D(e,e.dyn_ltree,e.l_desc.max_code),D(e,e.dyn_dtree,e.d_desc.max_code),P(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*l[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),o=e.opt_len+3+7>>>3,(r=e.static_len+3+7>>>3)<=o&&(o=r)):o=r=n+5,n+4<=o&&-1!==t?F(e,t,n,i):4===e.strategy||r===o?(N(e,2+(i?1:0),3),_(e,u,d)):(N(e,4+(i?1:0),3),function(e,t,n,i){var o;for(N(e,t-257,5),N(e,n-1,5),N(e,i-4,4),o=0;o>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(f[n]+256+1)]++,e.dyn_dtree[2*S(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){N(e,2,3),x(e,256,u),function(e){16===e.bi_valid?(C(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":27}],39:[function(e,t,n){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}]},{},[9])(9), /** * Copyright (C) 2013 KO GmbH * * @licstart * This file is part of WebODF. * * WebODF is free software: you can redistribute it and/or modify it * under the terms of the GNU Affero General Public License (GNU AGPL) * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * WebODF is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with WebODF. If not, see . * @licend * * @source: http://www.webodf.org/ * @source: https://github.com/kogmbh/WebODF/ */ this.OS.application.OpenPage.EditorSession=function(e){"use strict";runtime.loadClass("core.Async"),runtime.loadClass("core.DomUtils"),runtime.loadClass("odf.OdfUtils"),runtime.loadClass("ops.OdtDocument"),runtime.loadClass("ops.OdtStepsTranslator"),runtime.loadClass("ops.Session"),runtime.loadClass("odf.Namespaces"),runtime.loadClass("odf.OdfCanvas"),runtime.loadClass("odf.OdfUtils"),runtime.loadClass("gui.CaretManager"),runtime.loadClass("gui.Caret"),runtime.loadClass("gui.OdfFieldView"),runtime.loadClass("gui.SessionController"),runtime.loadClass("gui.SessionView"),runtime.loadClass("gui.HyperlinkTooltipView"),runtime.loadClass("gui.TrivialUndoManager"),runtime.loadClass("gui.SvgSelectionView"),runtime.loadClass("gui.SelectionViewManager"),runtime.loadClass("core.EventNotifier"),runtime.loadClass("gui.ShadowCursor"),runtime.loadClass("gui.CommonConstraints");var t=function e(t,n,i){var o,r,a,s,l,u,d,c,f=this,p=null,h=null,m=null,g=t.getOdtDocument(),b=odf.Namespaces.textns,y=document.createElement("style"),v=g.getFormatting(),S=core.DomUtils,C=odf.OdfUtils,N=new core.EventNotifier([e.signalMemberAdded,e.signalMemberUpdated,e.signalMemberRemoved,e.signalCursorAdded,e.signalCursorMoved,e.signalCursorRemoved,e.signalParagraphChanged,e.signalCommonStyleCreated,e.signalCommonStyleDeleted,e.signalParagraphStyleModified,e.signalUndoStackChanged]),x=new gui.ShadowCursor(g),w=core.StepDirection.NEXT;function E(){var t,n;if((t=p.getAttributeNS(b,"style-name"))!==m){if(m=t,!(n=v.getFirstCommonParentStyleNameOrSelf(t)))return h=t=m="",void f.emit(e.signalParagraphChanged,{type:"style",node:p,styleName:h});n!==h&&(h=n,f.emit(e.signalParagraphChanged,{type:"style",node:p,styleName:h}))}}function T(e){var t,n,i="";for(n=0;n0&&t.enqueue(r)},this.insertTable=function(e,i,o,r,a){var s=new ops.OpInsertTable;s.init({memberid:n,position:f.getCursorPosition(),initialRows:e,initialColumns:i,tableStyleName:o,tableColumnStyleName:r,tableCellStyleMatrix:a}),t.enqueue([s])},this.getParagraphStyleElement=U,this.isStyleUsed=function(e){return v.isStyleUsed(e)},this.getParagraphStyleAttributes=function(e){var t=U(e),n=""===e;return t?v.getInheritedStyleAttributes(t,n):null},this.updateParagraphStyle=function(e,i,o){var r;(r=new ops.OpUpdateParagraphStyle).init({memberid:n,styleName:e,setProperties:i,removedProperties:o||{}}),t.enqueue([r])},this.cloneParagraphStyle=function(e,i){var o,r,a,s,l=function(e){var t,i=0,o=T(n),r=T(e);for(t=r+"_"+o;v.hasParagraphStyle(t);)t=r+"_"+i+"_"+o,i+=1;return t}(i),u=U(e);for(r=v.getStyleAttributes(u),a=u.attributes,s=0;s