diff --git a/OpenPage/README.md b/OpenPage/README.md index d9dfca7..b0c808a 100644 --- a/OpenPage/README.md +++ b/OpenPage/README.md @@ -11,4 +11,8 @@ * Save documents as ODF format so that it can be compatible with desktop applications like Open Office **Credit:** -OpenPage is heavily based on the WebODF javascript library: https://webodf.org \ No newline at end of file +OpenPage is heavily based on the WebODF javascript library: https://webodf.org + + +## Change logs +- v.0.1.3-a adapt the code to the new AntOS API \ No newline at end of file diff --git a/OpenPage/assets/blank.odt b/OpenPage/assets/blank.odt index 90a6000..34face2 100644 Binary files a/OpenPage/assets/blank.odt and b/OpenPage/assets/blank.odt differ diff --git a/OpenPage/assets/scheme.html b/OpenPage/assets/scheme.html index 3f16689..d3c7590 100644 --- a/OpenPage/assets/scheme.html +++ b/OpenPage/assets/scheme.html @@ -22,7 +22,7 @@
- +
diff --git a/OpenPage/build/debug/blank.odt b/OpenPage/build/debug/blank.odt index 90a6000..34face2 100644 Binary files a/OpenPage/build/debug/blank.odt and b/OpenPage/build/debug/blank.odt differ diff --git a/OpenPage/build/debug/main.css b/OpenPage/build/debug/main.css index 2dc7edf..9482ded 100644 --- a/OpenPage/build/debug/main.css +++ b/OpenPage/build/debug/main.css @@ -8,10 +8,16 @@ afx-app-window[data-id="OpenPage"] div[data-id="container"] padding-top: 10px; padding-bottom: 10px; text-align: center; - background-color: #f2f1f0; + /*background-color: #f2f1f0;*/ /*position: relative;*/ } - +afx-app-window[data-id="OpenPage"] office|body, office|document { + background-color: white; + color: black; + background-image: none; + user-select: text; + overflow: visible; +} /* @media screen, print, handheld, projection { @@ -37,7 +43,8 @@ afx-app-window[data-id="OpenPage"] div[data-id="odfcanvas"] { cursor: text; margin:auto; - box-shadow: 1px 1px 3px 3px #9f9F9F; + /*box-shadow: 1px 1px 3px 3px #9f9F9F;*/ + border: 1px solid #2c2c2c; /*added*/ transform-origin: top center; -webkit-transform-origin: top center; @@ -48,24 +55,28 @@ afx-app-window[data-id="OpenPage"] div[data-id="odfcanvas"] afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] { - background-color: #f5f5f5; + /*background-color: #f5f5f5; border: 1px solid #eaeaea; - box-shadow: 3px 3px 3px #9f9F9F; + box-shadow: 3px 3px 3px #9f9F9F;*/ } afx-app-window[data-id="OpenPage"] afx-hbox[data-id="status-bar"] { - background-color: #f5f5f5; + /*background-color: #f5f5f5; border: 1px solid #eaeaea; - box-shadow: -3px -3px 3px #9f9F9F; + box-shadow: -3px -3px 3px #9f9F9F;*/ } afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button button, afx-app-window[data-id="OpenPage"] afx-button[data-id="btzoomfix"] button { - border: 1px solid #f5f5f5; - background-color: transparent; + /*border: 1px solid #f5f5f5; + background-color: transparent;*/ width:100%; height: 100%; } +afx-app-window[data-id="OpenPage"] button.selected { + color:chocolate; +} + afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button button:hover, afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button button.btactive, afx-app-window[data-id="OpenPage"] afx-button[data-id="btzoomfix"] button:hover { border: 1px solid #759DC0; diff --git a/OpenPage/build/debug/main.js b/OpenPage/build/debug/main.js index df39f39..1af1e8d 100644 --- a/OpenPage/build/debug/main.js +++ b/OpenPage/build/debug/main.js @@ -1,1289 +1,4 @@ -(function() { - void 0; - var FormatDialog, HyperLinkDialog, OpenPage; - - OpenPage = class OpenPage extends this.OS.GUI.BaseApplication { - constructor(args) { - super("OpenPage", args); - } - - main() { - var me; - // load session class - //if not OpenPage.EditorSession - // require ["webodf/editor/EditorSession"], (ES) -> - // OpenPage.EditorSession = ES - me = this; - this.eventSubscriptions = new core.EventSubscriptions(); - this.initToolbox(); - this.userid = `${this.systemsetting.user.username}@${this.pid}`; - //file = "home://welcome.odt" - //file = "#{@_api.handler.get}/home://welcome.odt" - //@canvas.load file - //odfContainer = new odf.OdfContainer file, (c) -> - // me.canvas.setOdfContainer c, false - this.currentStyle = ""; - if (this.args && this.args.length > 0) { - this.open(this.args[0]); - } else { - this.newdoc(); - } - this.resource = { - fonts: [], - formats: [] - }; - this.bindKey("ALT-N", function() { - return me.actionFile(`${me.name}-New`); - }); - this.bindKey("ALT-O", function() { - return me.actionFile(`${me.name}-Open`); - }); - this.bindKey("CTRL-S", function() { - return me.actionFile(`${me.name}-Save`); - }); - return this.bindKey("ALT-W", function() { - return me.actionFile(`${me.name}-Saveas`); - }); - } - - menu() { - var me, menu; - me = this; - menu = [ - { - text: "__(File)", - child: [ - { - 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" - } - ], - onmenuselect: function(e) { - return me.actionFile(e.item.data.dataid); - } - } - ]; - return menu; - } - - actionFile(e) { - var me, saveas; - me = this; - saveas = function() { - return me.openDialog("FileDiaLog", function(d, n, p) { - me.currfile.setPath(`${d}/${n}`); - return me.save(); - }, __("Save as"), { - file: me.currfile - }); - }; - switch (e) { - case `${this.name}-Open`: - return this.openDialog("FileDiaLog", function(d, f, p) { - return me.open(p); - }, __("Open file"), { - mimes: me.meta().mimes - }); - case `${this.name}-Save`: - if (this.currfile.basename) { - //@currfile.cache = @editor.value() - return this.save(); - } - return saveas(); - case `${this.name}-Saveas`: - return saveas(); - case `${this.name}-New`: - return this.newdoc(); - } - } - - newdoc() { - var blank; - blank = `${this.meta().path}/blank.odt`; - return this.open(blank, true); - } - - open(p, b) { - var me; - me = this; - return this.pathAsDataURL(p).then(function(r) { - var OdfContainer; - if (me.editorSession) { - me.closeDocument(); - } - me.initCanvas(); - return OdfContainer = new odf.OdfContainer(r.data, function(c) { - me.canvas.setOdfContainer(c, false); - if (b) { - return me.currfile = "Untitled".asFileHandler(); - } - if (me.currfile) { - me.currfile.setPath(p); - } else { - me.currfile = p.asFileHandler(); - } - me.scheme.set("apptitle", me.currfile.basename); - return me.notify(__("File {0} opened", p)); - }); - }).catch(function(e) { - return me.error(__("Problem read file {0}", e)); - }); - } - - save() { - var container, me; - me = this; - if (!this.editorSession) { - return; - } - container = this.canvas.odfContainer(); - if (!container) { - return this.error(__("No document container found")); - } - return container.createByteArray(function(ba) { - // create blob - me.currfile.cache = new Blob([ba], { - type: "application/vnd.oasis.opendocument.text" - }); - return me.currfile.write("application/vnd.oasis.opendocument.text", function(r) { - if (r.error) { - return me.error(__("Cannot save file: {0}", r.error)); - } - me.notify(__("File {0} saved", me.currfile.basename)); - me.scheme.set("apptitle", me.currfile.basename); - me.currfile.dirty = false; - return me.editorFocus(); - }); - }, function(err) { - return this.error(__("Cannot create byte array from container: {0}", err || "")); - }); - } - - initToolbox() { - var el, fn, me, name, ref; - me = this; - 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") - }; - fn = function(name, el) { - var act; - if (name === "fonts" || name === "styles") { - act = "onlistselect"; - } else if (name === "fontsize" || name === "zoom") { - act = "onchange"; - } else { - act = "onbtclick"; - } - return el.set(act, function(e) { - if (!me.directFormattingCtl) { - return; - } - if (!me[name]) { - return; - } - me[name](e); - return me.editorFocus(); - }); - }; - ref = this.basictool; - for (name in ref) { - el = ref[name]; - fn(name, el); - } - (this.find("btzoomfix")).set("onbtclick", function(e) { - return me.zoom(100); - }); - return this.basictool.zoom.set("onchanging", function(e) { - var zlb; - zlb = me.find("lbzoom"); - return zlb.set("text", Math.floor(e) + "%"); - }); - } - - initCanvas() { - var el, me; - el = this.find("odfcanvas"); - me = this; - el.setAttribute("translate", "no"); - el.classList.add("notranslate"); - this.canvas = new odf.OdfCanvas(el); - this.documentChanged = function(e) { - if (me.currfile.dirty) { - return; - } - me.currfile.dirty = true; - return me.scheme.set("apptitle", me.currfile.basename + "*"); - }; - //console.log e - this.metaChanged = function(e) { - if (me.currfile.dirty) { - return; - } - me.currfile.dirty = true; - return me.scheme.set("apptitle", me.currfile.basename + "*"); - }; - //console.log e - this.textStylingChanged = function(e) { - return me.updateToolbar(e); - }; - this.paragrahStyleChanged = function(e) { - var i, item, items, j, len, v; - if (e.type !== "style") { - return; - } - items = me.basictool.styles.get("items"); - for (i = j = 0, len = items.length; j < len; i = ++j) { - v = items[i]; - if (v.name === e.styleName) { - item = i; - } - } - me.currentStyle = e.styleName; - return me.basictool.styles.set("selected", item); - }; - this.styleAdded = function(e) { - var dtext, item, items, j, len, stylens, v; - if (e.family !== 'paragraph') { - return; - } - items = me.basictool.styles.get("items"); - for (j = 0, len = items.length; j < len; j++) { - v = items[j]; - if (v.name === e.name) { - item = v; - } - } - if (item) { - return; - } - stylens = "urn:oasis:names:tc:opendocument:xmlns:style:1.0"; - el = me.editorSession.getParagraphStyleElement(e.name); - dtext = el.getAttributeNS(stylens, 'display-name'); - return me.basictool.styles.push({ - text: dtext, - name: e.name - }, true); - }; - //me.resource.formats.push {text: dtext, name:e.name} - this.updateSlider = function(v) { - var value, zlb; - value = Math.floor(v * 100); - me.basictool.zoom.set("value", value); - zlb = me.find("lbzoom"); - return zlb.set("text", value + "%"); - }; - //me.canvas.enableAnnotations true, true - return this.canvas.addListener("statereadychange", function() { - var op, viewOptions; - me.session = new ops.Session(me.canvas); - viewOptions = { - editInfoMarkersInitiallyVisible: false, - caretAvatarsInitiallyVisible: false, - caretBlinksOnRangeSelect: true - }; - me.editorSession = new OpenPage.EditorSession(me.session, me.userid, { - viewOptions: viewOptions, - directTextStylingEnabled: true, - directParagraphStylingEnabled: true, - paragraphStyleSelectingEnabled: true, - paragraphStyleEditingEnabled: true, - imageEditingEnabled: true, - hyperlinkEditingEnabled: true, - annotationsEnabled: true, - zoomingEnabled: true, - reviewModeEnabled: false - }); - me.initFontList(me.editorSession.getDeclaredFonts()); - me.initStyles(me.editorSession.getAvailableParagraphStyles()); - //fix annotation problem on canvas - //console.log $("office:body").css "background-color", "red" - // basic format - me.directFormattingCtl = me.editorSession.sessionController.getDirectFormattingController(); - me.directFormattingCtl.subscribe(gui.DirectFormattingController.textStylingChanged, me.textStylingChanged); - me.directFormattingCtl.subscribe(gui.DirectFormattingController.paragraphStylingChanged, me.textStylingChanged); - me.editorSession.subscribe(OpenPage.EditorSession.signalParagraphChanged, me.paragrahStyleChanged); - - // hyper link controller - me.hyperlinkController = me.editorSession.sessionController.getHyperlinkController(); - me.eventSubscriptions.addFrameSubscription(me.editorSession, OpenPage.EditorSession.signalCursorMoved, function() { - return me.updateHyperlinkButtons(); - }); - me.eventSubscriptions.addFrameSubscription(me.editorSession, OpenPage.EditorSession.signalParagraphChanged, function() { - return me.updateHyperlinkButtons(); - }); - me.eventSubscriptions.addFrameSubscription(me.editorSession, OpenPage.EditorSession.signalParagraphStyleModified, function() { - return me.updateHyperlinkButtons(); - }); - - //annotation controller - me.annotationController = me.editorSession.sessionController.getAnnotationController(); - - //image controller - me.imageController = me.editorSession.sessionController.getImageController(); - //imageController.subscribe(gui.ImageController.enabledChanged, enableButtons) - - //text controller - me.textController = me.editorSession.sessionController.getTextController(); - - // zoom controller - me.zoomHelper = me.editorSession.getOdfCanvas().getZoomHelper(); - me.zoomHelper.subscribe(gui.ZoomHelper.signalZoomChanged, me.updateSlider); - me.updateSlider(me.zoomHelper.getZoomLevel()); - - // format controller - me.editorSession.subscribe(OpenPage.EditorSession.signalCommonStyleCreated, me.styleAdded); - me.editorSession.sessionController.setUndoManager(new gui.TrivialUndoManager()); - me.editorSession.sessionController.getUndoManager().subscribe(gui.UndoManager.signalDocumentModifiedChanged, me.documentChanged); - me.editorSession.sessionController.getMetadataController().subscribe(gui.MetadataController.signalMetadataChanged, me.metaChanged); - op = new ops.OpAddMember(); - op.init({ - memberid: me.userid, - setProperties: { - "fullName": me.userid, - "color": "blue" - } - }); - me.session.enqueue([op]); - me.editorSession.sessionController.insertLocalCursor(); - return me.editorSession.sessionController.startEditing(); - }); - } - - //console.log me.editorSession.getDeclaredFonts() - - initFontList(list) { - var j, l, len, len1, v; - for (j = 0, len = list.length; j < len; j++) { - v = list[j]; - v.text = v.name; - } - for (l = 0, len1 = list.length; l < len1; l++) { - v = list[l]; - this.resource.fonts.push({ - text: v.text, - name: v.family - }); - } - return this.basictool.fonts.set("items", list); - } - - initStyles(list) { - var j, l, len, len1, v; - list.unshift({ - name: "", - displayName: 'Default style' - }); - for (j = 0, len = list.length; j < len; j++) { - v = list[j]; - v.text = v.displayName; - } - for (l = 0, len1 = list.length; l < len1; l++) { - v = list[l]; - this.resource.formats.push({ - text: v.text, - name: v.name - }); - } - return this.basictool.styles.set("items", list); - } - - updateToolbar(changes) { - if (changes.hasOwnProperty('isBold')) { - // basic style - this.basictool.bold.set("selected", changes.isBold); - } - if (changes.hasOwnProperty('isItalic')) { - this.basictool.italic.set("selected", changes.isItalic); - } - if (changes.hasOwnProperty('hasUnderline')) { - this.basictool.underline.set("selected", changes.hasUnderline); - } - if (changes.hasOwnProperty('hasStrikeThrough')) { - this.basictool.strike.set("selected", changes.hasStrikeThrough); - } - if (changes.hasOwnProperty("fontSize")) { - this.basictool.fontsize.set("value", changes.fontSize); - } - if (changes.hasOwnProperty("fontName")) { - this.selectFont(changes.fontName); - } - if (changes.hasOwnProperty("isAlignedLeft")) { - //pharagraph style - this.basictool.al.set("selected", changes.isAlignedLeft); - } - if (changes.hasOwnProperty("isAlignedRight")) { - this.basictool.ar.set("selected", changes.isAlignedRight); - } - if (changes.hasOwnProperty("isAlignedCenter")) { - this.basictool.ac.set("selected", changes.isAlignedCenter); - } - if (changes.hasOwnProperty("isAlignedJustified")) { - return this.basictool.aj.set("selected", changes.isAlignedJustified); - } - } - - updateHyperlinkButtons(e) { - var selectedLinks; - selectedLinks = this.editorSession.getSelectedHyperlinks(); - return this.basictool.unlink.set("enable", selectedLinks.length > 0); - } - - selectFont(name) { - var i, item, items, j, len, v; - items = this.basictool.fonts.get("items"); - for (i = j = 0, len = items.length; j < len; i = ++j) { - v = items[i]; - if (v.name === name) { - item = i; - } - } - return this.basictool.fonts.set("selected", item); - } - - editorFocus() { - return this.editorSession.sessionController.getEventManager().focus(); - } - - bold(e) { - //console.log @, e - return this.directFormattingCtl.setBold(!this.basictool.bold.get("selected")); - } - - italic(e) { - return this.directFormattingCtl.setItalic(!this.basictool.italic.get("selected")); - } - - underline(e) { - return this.directFormattingCtl.setHasUnderline(!this.basictool.underline.get("selected")); - } - - strike(e) { - return this.directFormattingCtl.setHasStrikethrough(!this.basictool.strike.get("selected")); - } - - fonts(e) { - return this.directFormattingCtl.setFontName(e.data.name); - } - - fontsize(e) { - return this.directFormattingCtl.setFontSize(e); - } - - al(e) { - return this.directFormattingCtl.alignParagraphLeft(); - } - - ar(e) { - return this.directFormattingCtl.alignParagraphRight(); - } - - ac(e) { - return this.directFormattingCtl.alignParagraphCenter(); - } - - note(e) { - return this.annotationController.addAnnotation(); - } - - aj(e) { - return this.directFormattingCtl.alignParagraphJustified(); - } - - indent(e) { - return this.directFormattingCtl.indent(); - } - - outdent(e) { - return this.directFormattingCtl.outdent(); - } - - link(e) { - var data, linkTarget, linksInSelection, me, selection, textSerializer; - // get the link first - me = this; - textSerializer = new odf.TextSerializer(); - selection = this.editorSession.getSelectedRange(); - linksInSelection = this.editorSession.getSelectedHyperlinks(); - linkTarget = linksInSelection[0] ? odf.OdfUtils.getHyperlinkTarget(linksInSelection[0]) : "http://"; - data = { - link: linkTarget, - text: "", - readonly: true, - action: "new" - }; - if (selection && selection.collapsed && linksInSelection.length === 1) { - // selection is collapsed within a single link - // text in this case is read only - data.text = textSerializer.writeToString(linksInSelection[0]); - data.action = "edit"; - } else if (selection && !selection.collapsed) { - // user select part of link or a block of text - // user convert a selection to a link - data.text = textSerializer.writeToString(selection.cloneContents()); - } else { - data.readonly = false; - } - return this.openDialog(new HyperLinkDialog(), function(d) { - var selectedLinkRange, selectionController; - selectionController = me.editorSession.sessionController.getSelectionController(); - if (d.readonly) { - // edit the existing link - if (d.action === "edit") { - selectedLinkRange = selection.cloneRange(); - selectedLinkRange.selectNode(linksInSelection[0]); - selectionController.selectRange(selectedLinkRange, true); - } - me.hyperlinkController.removeHyperlinks(); - return me.hyperlinkController.addHyperlink(d.link); - } else { - me.hyperlinkController.addHyperlink(d.link, d.text); - linksInSelection = me.editorSession.getSelectedHyperlinks(); - selectedLinkRange = selection.cloneRange(); - selectedLinkRange.selectNode(linksInSelection[0]); - return selectionController.selectRange(selectedLinkRange, true); - } - }, "__(Insert/edit link)", data); - } - - unlink(e) { - return this.hyperlinkController.removeHyperlinks(); - } - - undo(e) { - return this.editorSession.undo(); - } - - redo(e) { - return this.editorSession.redo(); - } - - pathAsDataURL(p) { - return new Promise(function(resolve, error) { - var fp; - fp = p.asFileHandler(); - return fp.read(function(data) { - var blob, reader; - blob = new Blob([data], { - type: fp.info.mime - }); - reader = new FileReader(); - reader.onloadend = function() { - if (reader.readyState !== 2) { - return error(p); - } - return resolve({ - data: reader.result, - fp: fp - }); - }; - return reader.readAsDataURL(blob); - }, "binary"); - }); - } - - /* - if not isText - - else - fp.read (data) -> - * convert to base64 - b64 = btoa data - dataurl = "data:#{fp.info.mime};base64," + b64 - resolve { reader: {result: dataurl}, fp:fp } - */ - image(e) { - var me; - me = this; - return this.openDialog("FileDiaLog", function(d, n, p) { - return me.pathAsDataURL(p).then(function(r) { - var hiddenImage; - hiddenImage = new Image(); - hiddenImage.style.position = "absolute"; - hiddenImage.style.left = "-99999px"; - document.body.appendChild(hiddenImage); - hiddenImage.onload = function() { - var content; - content = r.data.substring(r.data.indexOf(",") + 1); - //insert image - me.textController.removeCurrentSelection(); - me.imageController.insertImage(r.fp.info.mime, content, hiddenImage.width, hiddenImage.height); - return document.body.removeChild(hiddenImage); - }; - return hiddenImage.src = r.data; - }).catch(function() { - return me.error(__("Couldnt load image {0}", p)); - }); - }, __("Select image file"), { - mimes: ["image/.*"] - }); - } - - styles(e) { - if (e.data.name === this.currentStyle) { - return; - } - return this.editorSession.setCurrentParagraphStyle(e.data.name); - } - - zoom(e) { - //console.log "zooming", e - if (!this.zoomHelper) { - return; - } - return this.zoomHelper.setZoomLevel(e / 100.0); - } - - format(e) { - return this.openDialog(new FormatDialog(), function(d) {}, __("Add/Modify paragraph format"), this.resource); - } - - closeDocument(f) { - var me, op; - // finish editing - if (!(this.editorSession && this.session)) { - return; - } - me = this; - this.eventSubscriptions.unsubscribeAll(); - this.editorSession.sessionController.endEditing(); - this.editorSession.sessionController.removeLocalCursor(); - // remove user - op = new ops.OpRemoveMember(); - op.init({ - memberid: this.userid - }); - this.session.enqueue([op]); - // close the session - return this.session.close(function(e) { - if (e) { - return me.error(__("Cannot close session {0}", e)); - } - me.editorSession.sessionController.getMetadataController().unsubscribe(gui.MetadataController.signalMetadataChanged, me.metaChanged); - me.editorSession.sessionController.getUndoManager().unsubscribe(gui.UndoManager.signalDocumentModifiedChanged, me.documentChanged); - me.directFormattingCtl.unsubscribe(gui.DirectFormattingController.textStylingChanged, me.textStylingChanged); - me.directFormattingCtl.unsubscribe(gui.DirectFormattingController.paragraphStylingChanged, me.textStylingChanged); - me.editorSession.unsubscribe(OpenPage.EditorSession.signalParagraphChanged, me.paragrahStyleChanged); - me.zoomHelper.unsubscribe(gui.ZoomHelper.signalZoomChanged, me.updateSlider); - me.editorSession.unsubscribe(OpenPage.EditorSession.signalCommonStyleCreated, me.styleAdded); - // destry editorSession - return me.editorSession.destroy(function(e) { - if (e) { - return me.error(__("Cannot destroy editor session {0}", e)); - } - me.editorSession = void 0; - // destroy session - return me.session.destroy(function(e) { - if (e) { - return me.error(__("Cannot destroy document session {0}", e)); - } - core.Async.destroyAll([me.canvas.destroy], function(e) { - if (e) { - return me.error(__("Cannot destroy canvas {0}", e)); - } - me.notify("Document closed"); - if (f) { - return f(); - } - }); - me.session = void 0; - me.annotationController = void 0; - me.directFormattingCtl = void 0; - me.textController = void 0; - me.imageController = void 0; - me.ZoomHelper = void 0; - me.metaChanged = void 0; - me.documentChanged = void 0; - me.textStylingChanged = void 0; - me.paragrahStyleChanged = void 0; - me.updateSlider = void 0; - me.styleAdded = void 0; - me.basictool.fonts.set("selected", -1); - return me.basictool.styles.set("selected", -1); - }); - }); - }); - } - - - cleanup(e) { - var me; - me = this; - if (this.editorSession) { - e.preventDefault(); - return me.closeDocument(function() { - return me.quit(); - }); - } - } - - }; - - this.OS.register("OpenPage", OpenPage); - - HyperLinkDialog = class HyperLinkDialog extends this.OS.GUI.BasicDialog { - constructor() { - super("HyperLinkDialog", { - tags: [ - { - tag: "afx-label", - att: 'text="__(Text)" data-height="23" class="header"' - }, - { - tag: "input", - att: 'data-height="30"' - }, - { - tag: "afx-label", - att: 'text="__(Link)" data-height="23" class="header"' - }, - { - tag: "input", - att: 'data-height="30"' - }, - { - tag: "div", - att: ' data-height="5"' - } - ], - width: 350, - height: 150, - resizable: false, - buttons: [ - { - label: "Ok", - onclick: function(d) { - var data; - data = { - text: (d.find("content1")).value, - link: (d.find("content3")).value, - readonly: d.data.readonly, - action: d.data.action - }; - if (d.handler) { - d.handler(data); - } - return d.quit(); - } - }, - { - label: "__(Cancel)", - onclick: function(d) { - return d.quit(); - } - } - ], - filldata: function(d) { - if (!d.data) { - return; - } - (d.find("content1")).value = d.data.text; - (d.find("content3")).value = d.data.link; - return $(d.find("content1")).prop('disabled', d.data.readonly); - } - }); - } - - }; - - FormatDialog = class FormatDialog extends this.OS.GUI.BaseDialog { - constructor() { - super("FormatDialog"); - } - - init() { - return this._gui.htmlToScheme(FormatDialog.scheme, this, this.host); - } - - 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"); - return this.initUIEvent(); - } - - //@previewStyle() - initStyleObject() { - // init the format object - 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: false, - italic: false, - underline: false, - color: void 0, - bgcolor: void 0 - }, - font: { - family: void 0, - size: 12 - } - }; - } - - initUIEvent() { - var k, me, ref, ref1, ref2, ref3, set, v; - me = this; - set = function(e, o, k, f) { - return me.ui[o][k].set(e, function(r) { - var v; - v = r; - if (f) { - v = f(r); - } - me.currentStyle[o][k] = v; - return me.previewStyle(); - }); - }; - ref = this.ui.aligment; - for (k in ref) { - v = ref[k]; - set("onchange", "aligment", k, (function(e) { - return e.data; - })); - } - ref1 = this.ui.spacing; - for (k in ref1) { - v = ref1[k]; - set("onchange", "spacing", k); - } - ref2 = this.ui.padding; - for (k in ref2) { - v = ref2[k]; - set("onchange", "padding", k); - } - ref3 = this.ui.style; - for (k in ref3) { - v = ref3[k]; - if (k !== "color" && k !== "bgcolor") { - set("onchange", "style", k, (function(e) { - return e.data; - })); - } - } - set("onchange", "font", "size"); - $(this.ui.style.color).click(function(e) { - return me.openDialog("ColorPickerDialog", function(d) { - me.currentStyle.style.color = d; - return me.previewStyle(); - }); - }); - $(this.ui.style.bgcolor).click(function(e) { - return me.openDialog("ColorPickerDialog", function(d) { - me.currentStyle.style.bgcolor = d; - return me.previewStyle(); - }); - }); - if (this.data && this.data.fonts) { - //font - this.ui.font.family.set("items", this.data.fonts); - } - set("onlistselect", "font", "family", (function(e) { - return e.data; - })); - //format list - this.ui.formats.set("selected", -1); - if (this.data && this.data.formats) { - this.ui.formats.set("items", this.data.formats); - } - this.ui.formats.set("onlistselect", function(e) { - return me.fromODFStyleFormat(e.data); - }); - this.ui.formats.set("selected", 0); - (this.find("btok")).set("onbtclick", function(e) { - return me.saveCurrentStyle(); - }); - (this.find("btx")).set("onbtclick", function(e) { - return me.quit(); - }); - return (this.find("bt-clone")).set("onbtclick", function(e) { - return me.clone(); - }); - } - - clone() { - var me, selected; - me = this; - selected = this.ui.formats.get("selected"); - if (!selected) { - return; - } - return this.openDialog("PromptDialog", function(d) { - var newstyle; - if (!(d && d.trim() !== "")) { - return me.notify(__("Abort: no style name is specified")); - } - newstyle = me.parent.editorSession.cloneParagraphStyle(selected.name, d); - me.ui.formats.push({ - text: d, - name: newstyle - }); - me.ui.formats.set("selected", (me.ui.formats.get('count')) - 1); - return me.notify(__("New style: {0} added", newstyle)); - }, __("Clone style: {0}", selected.text), { - label: __("New style name:") - }); - } - - saveCurrentStyle() { - var odfs, selected; - selected = this.ui.formats.get("selected"); - if (!selected) { - return; - } - odfs = { - "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(selected.name, odfs); - return this.notify(__("Paragraph format [{0}] is saved", selected.text)); - } - - fromODFStyleFormat(odfs) { - var cssUnits, findFont, me, style; - me = this; - this.initStyleObject(); - cssUnits = new core.CSSUnits(); - findFont = function(name) { - var item, items, j, len, v; - items = me.ui.font.family.get("items"); - for (j = 0, len = items.length; j < len; j++) { - v = items[j]; - if (v.text === name) { - item = v; - } - } - if (!item) { - return void 0; - } - return item; - }; - // spacing - style = this.parent.editorSession.getParagraphStyleAttributes(odfs.name)['style:paragraph-properties']; - if (style) { - this.currentStyle.spacing.top = cssUnits.convertMeasure(style['fo:margin-top'], 'mm') || 0; - this.currentStyle.spacing.left = cssUnits.convertMeasure(style['fo:margin-left'], 'mm') || 0; - this.currentStyle.spacing.right = cssUnits.convertMeasure(style['fo:margin-right'], 'mm') || 0; - this.currentStyle.spacing.bottom = cssUnits.convertMeasure(style['fo:margin-bottom'], 'mm') || 0; - this.currentStyle.padding.top = cssUnits.convertMeasure(style['fo:padding-top'], 'mm') || 0; - this.currentStyle.padding.left = cssUnits.convertMeasure(style['fo:padding-left'], 'mm') || 0; - this.currentStyle.padding.right = cssUnits.convertMeasure(style['fo:padding-right'], 'mm') || 0; - this.currentStyle.padding.bottom = cssUnits.convertMeasure(style['fo:padding-bottom'], 'mm') || 0; - this.currentStyle.spacing.lineheight = cssUnits.convertMeasure(style['fo:line-height'], 'mm') || 4.2; // 1em = 4,2175176mm - if (style['fo:text-align']) { - this.currentStyle.aligment[style['fo:text-align']] = true; - } - } - style = this.parent.editorSession.getParagraphStyleAttributes(odfs.name)['style:text-properties']; - if (style) { - this.currentStyle.style.bold = style['fo:font-weight'] === 'bold'; - this.currentStyle.style.italic = style['fo:font-style'] === 'italic'; - if (style['style:text-underline-style'] && style['style:text-underline-style'] !== 'none') { - this.currentStyle.style.underline = true; - } - this.currentStyle.font.size = parseFloat(style['fo:font-size']); - this.currentStyle.font.family = findFont(style['style:font-name']); - if (style['fo:color']) { - this.currentStyle.style.color = { - hex: style['fo:color'] - }; - } - if (style['fo:background-color']) { - this.currentStyle.style.bgcolor = { - hex: style['fo:background-color'] - }; - } - } - return this.previewStyle(); - } - - previewStyle() { - var el, i, item, items, j, len, v; - //console.log "previewing" - // reset ui - this.ui.aligment.left.set("swon", this.currentStyle.aligment.left); - this.ui.aligment.right.set("swon", this.currentStyle.aligment.right); - this.ui.aligment.center.set("swon", this.currentStyle.aligment.center); - this.ui.aligment.justify.set("swon", this.currentStyle.aligment.justify); - this.ui.spacing.left.set("value", this.currentStyle.spacing.left); - this.ui.spacing.right.set("value", this.currentStyle.spacing.right); - this.ui.spacing.top.set("value", this.currentStyle.spacing.top); - this.ui.spacing.bottom.set("value", this.currentStyle.spacing.bottom); - this.ui.spacing.lineheight.set("value", this.currentStyle.spacing.lineheight); - this.ui.padding.left.set("value", this.currentStyle.padding.left); - this.ui.padding.right.set("value", this.currentStyle.padding.right); - this.ui.padding.top.set("value", this.currentStyle.padding.top); - this.ui.padding.bottom.set("value", this.currentStyle.padding.bottom); - this.ui.style.bold.set("swon", this.currentStyle.style.bold); - this.ui.style.italic.set("swon", this.currentStyle.style.italic); - this.ui.style.underline.set("swon", this.currentStyle.style.underline); - this.ui.font.size.set("value", this.currentStyle.font.size); - - //console.log @currentStyle - if (this.currentStyle.font.family) { - items = this.ui.font.family.get("items"); - for (i = j = 0, len = items.length; j < len; i = ++j) { - v = items[i]; - if (v.text === this.currentStyle.font.family.text) { - item = i; - } - } - if (item >= 0) { - this.ui.font.family.set("selected", item); - } - } - $(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 : "white"); - // set the preview css - el = $(this.preview); - el.css("text-align", this.currentStyle.aligment.selected ? this.currentStyle.aligment.selected : "left"); - el.css("margin-left", this.currentStyle.spacing.left + "mm"); - el.css("margin-right", this.currentStyle.spacing.right + "mm"); - el.css("margin-top", this.currentStyle.spacing.top + "mm"); - el.css("margin-bottom", this.currentStyle.spacing.bottom + "mm"); - el.css("padding-left", this.currentStyle.padding.left + "mm"); - el.css("padding-right", this.currentStyle.padding.right + "mm"); - el.css("padding-top", this.currentStyle.padding.top + "mm"); - el.css("padding-bottom", this.currentStyle.padding.bottom + "mm"); - el.css("font-weight", "normal").css("font-style", "normal").css("text-decoration", "none").css("line-height", "normal"); - if (this.currentStyle.style.bold) { - el.css("font-weight", "bold"); - } - if (this.currentStyle.style.italic) { - el.css("font-style", "italic"); - } - if (this.currentStyle.style.underline) { - el.css("text-decoration", "underline"); - } - el.css("color", this.currentStyle.style.color ? this.currentStyle.style.color.hex : "#000000"); - el.css("background-color", this.currentStyle.style.bgcolor ? this.currentStyle.style.bgcolor.hex : "transparent"); - el.css("font-size", this.currentStyle.font.size + "pt"); - if (this.currentStyle.font.family) { - el.css("font-family", this.currentStyle.font.family.name); - } - if (this.currentStyle.spacing.lineheight > 0) { - return el.css("line-height", this.currentStyle.spacing.lineheight + "mm"); - } - } - - }; - - FormatDialog.scheme = ` - -
- -
- -
- -
-
- - -
- - - - - - - - -
-
-
- -
- -
- - -
- - -
- - -
- - -
-
-
- -
- -
- - -
- - -
- - -
- - -
-
- -
- -
- -
- - - - - - - -
-
- -
-
-
-
- -
- -
- -
- - -
- - -
-
-
- -
- -
-
-

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

-
-
-
- -
- -
- -
- -
-
-
-
`; - -}).call(this); - +(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. @@ -1326,672 +41,8 @@ @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ -var webodf_version="0.5.9";function Runtime(){}Runtime.prototype.getVariable=function(g){};Runtime.prototype.toJson=function(g){};Runtime.prototype.fromJson=function(g){};Runtime.prototype.byteArrayFromString=function(g,k){};Runtime.prototype.byteArrayToString=function(g,k){};Runtime.prototype.read=function(g,k,d,b){};Runtime.prototype.readFile=function(g,k,d){};Runtime.prototype.readFileSync=function(g,k){};Runtime.prototype.loadXML=function(g,k){};Runtime.prototype.writeFile=function(g,k,d){}; -Runtime.prototype.deleteFile=function(g,k){};Runtime.prototype.log=function(g,k){};Runtime.prototype.setTimeout=function(g,k){};Runtime.prototype.clearTimeout=function(g){};Runtime.prototype.libraryPaths=function(){};Runtime.prototype.currentDirectory=function(){};Runtime.prototype.setCurrentDirectory=function(g){};Runtime.prototype.type=function(){};Runtime.prototype.getDOMImplementation=function(){};Runtime.prototype.parseXML=function(g){};Runtime.prototype.exit=function(g){}; -Runtime.prototype.getWindow=function(){};Runtime.prototype.requestAnimationFrame=function(g){};Runtime.prototype.cancelAnimationFrame=function(g){};Runtime.prototype.assert=function(g,k){};var IS_COMPILED_CODE=!0; -Runtime.byteArrayToString=function(g,k){function d(b){var d="",r,q=b.length;for(r=0;rl?e.push(l):(r+=1,a=b[r],194<=l&&224>l?e.push((l&31)<<6|a&63):(r+=1,c=b[r],224<=l&&240>l?e.push((l&15)<<12|(a&63)<<6|c&63):(r+=1,m=b[r],240<=l&&245>l&&(l=(l&7)<<18|(a&63)<<12|(c&63)<<6|m&63,l-=65536,e.push((l>>10)+55296,(l&1023)+56320))))),1E3<=e.length&& -(d+=String.fromCharCode.apply(null,e),e.length=0);return d+String.fromCharCode.apply(null,e)}var f;"utf8"===k?f=b(g):("binary"!==k&&this.log("Unsupported encoding: "+k),f=d(g));return f};Runtime.getVariable=function(g){try{return eval(g)}catch(k){}};Runtime.toJson=function(g){return JSON.stringify(g)};Runtime.fromJson=function(g){return JSON.parse(g)};Runtime.getFunctionName=function(g){return void 0===g.name?(g=/function\s+(\w+)/.exec(g))&&g[1]:g.name}; -Runtime.assert=function(g,k){if(!g)throw this.log("alert","ASSERTION FAILED:\n"+k),Error(k);}; -function BrowserRuntime(){function g(b){var e=b.length,l,a,c=0;for(l=0;la&&(c+=1,l+=1);return c}function k(b,e,l){var a=b.length,c,m;e=new Uint8Array(new ArrayBuffer(e));l?(e[0]=239,e[1]=187,e[2]=191,m=3):m=0;for(l=0;lc?(e[m]=c,m+=1):2048>c?(e[m]=192|c>>>6,e[m+1]=128|c&63,m+=2):55040>=c||57344<=c?(e[m]=224|c>>>12&15,e[m+1]=128|c>>>6&63,e[m+2]=128|c&63,m+=3):(l+=1,c=(c-55296<<10|b.charCodeAt(l)-56320)+65536, -e[m]=240|c>>>18&7,e[m+1]=128|c>>>12&63,e[m+2]=128|c>>>6&63,e[m+3]=128|c&63,m+=4);return e}function d(b){var e=b.length,l=new Uint8Array(new ArrayBuffer(e)),a;for(a=0;aa.status||0===a.status?l(null):l("Status "+String(a.status)+": "+a.responseText||a.statusText):l("File "+b+" is empty."))};c=e.buffer&&!a.sendAsBinary?e.buffer:r.byteArrayToString(e,"binary");try{a.sendAsBinary?a.sendAsBinary(c):a.send(c)}catch(m){r.log("HUH? "+ -m+" "+e),l(m.message)}};this.deleteFile=function(b,e){var l=new XMLHttpRequest;l.open("DELETE",b,!0);l.onreadystatechange=function(){4===l.readyState&&(200>l.status&&300<=l.status?e(l.responseText):e(null))};l.send(null)};this.loadXML=function(b,e){var l=new XMLHttpRequest;l.open("GET",b,!0);l.overrideMimeType&&l.overrideMimeType("text/xml");l.onreadystatechange=function(){4===l.readyState&&(0!==l.status||l.responseText?200===l.status||0===l.status?e(null,l.responseXML):e(l.responseText,null):e("File "+ -b+" is empty.",null))};try{l.send(null)}catch(a){e(a.message,null)}};this.log=b;this.enableAlerts=!0;this.assert=Runtime.assert;this.setTimeout=function(b,e){return setTimeout(function(){b()},e)};this.clearTimeout=function(b){clearTimeout(b)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.currentDirectory=function(){return""};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){return window.document.implementation};this.parseXML= -function(b){return(new DOMParser).parseFromString(b,"text/xml")};this.exit=function(d){b("Calling exit with code "+String(d)+", but exit() is not implemented.")};this.getWindow=function(){return window};this.requestAnimationFrame=function(b){var e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,l=0;if(e)e.bind(window),l=e(b);else return setTimeout(b,15);return l};this.cancelAnimationFrame=function(b){var e=window.cancelAnimationFrame|| -window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame;e?(e.bind(window),e(b)):clearTimeout(b)}} -function NodeJSRuntime(){function g(b){var e=b.length,l,a=new Uint8Array(new ArrayBuffer(e));for(l=0;l").implementation} -function RhinoRuntime(){var g=this,k={},d=k.javax.xml.parsers.DocumentBuilderFactory.newInstance(),b,f,n="";d.setValidating(!1);d.setNamespaceAware(!0);d.setExpandEntityReferences(!1);d.setSchema(null);f=k.org.xml.sax.EntityResolver({resolveEntity:function(b,d){var f=new k.java.io.FileReader(d);return new k.org.xml.sax.InputSource(f)}});b=d.newDocumentBuilder();b.setEntityResolver(f);this.byteArrayFromString=function(b,d){var f,e=b.length,l=new Uint8Array(new ArrayBuffer(e));for(f=0;f>>18],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>12&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>6&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c& -63];h===b+1?(c=a[h]<<4,m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>6],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c&63],m+="=="):h===b&&(c=a[h]<<10|a[h+1]<<2,m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>12],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c>>>6&63],m+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[c&63],m+="=");return m}function d(a){a=a.replace(/[^A-Za-z0-9+\/]+/g, -"");var c=a.length,m=new Uint8Array(new ArrayBuffer(3*c)),b=a.length%4,d=0,l,e;for(l=0;l>16,m[d+1]=e>>8&255,m[d+2]=e&255,d+=3;c=3*c-[0,0,2,1][b];return m.subarray(0,c)}function b(a){var c,m,h=a.length,b=0,d=new Uint8Array(new ArrayBuffer(3*h));for(c=0;cm?d[b++]=m:(2048>m?d[b++]=192|m>>>6:(d[b++]=224|m>>>12&15,d[b++]=128|m>>>6&63),d[b++]=128|m&63);return d.subarray(0, -b)}function f(a){var c,m,h,b,d=a.length,l=new Uint8Array(new ArrayBuffer(d)),e=0;for(c=0;cm?l[e++]=m:(c+=1,h=a[c],224>m?l[e++]=(m&31)<<6|h&63:(c+=1,b=a[c],l[e++]=(m&15)<<12|(h&63)<<6|b&63));return l.subarray(0,e)}function n(a){return k(g(a))}function p(a){return String.fromCharCode.apply(String,d(a))}function r(a){return f(g(a))}function q(a){a=f(a);for(var c="",m=0;mc?l+=String.fromCharCode(c):(d+=1,h=a.charCodeAt(d)&255,224>c?l+=String.fromCharCode((c&31)<<6|h&63):(d+=1,b=a.charCodeAt(d)&255,l+=String.fromCharCode((c&15)<<12|(h&63)<<6|b&63)));return l}function l(a,c){function m(){var d=b+1E5;d>a.length&&(d=a.length);h+=e(a,b,d);b=d;d=b===a.length;c(h,d)&&!d&&runtime.setTimeout(m,0)}var h="",b=0;1E5>a.length?c(e(a,0,a.length),!0):("string"!==typeof a&&(a=a.slice()),m())}function a(a){return b(g(a))}function c(a){return String.fromCharCode.apply(String, -b(a))}function m(a){return String.fromCharCode.apply(String,b(g(a)))}var h=function(a){var c={},m,h;m=0;for(h=a.length;m=a.compareBoundaryPoints(Range.START_TO_START,c)&&0<=a.compareBoundaryPoints(Range.END_TO_END,c)}function n(a,c){return 0>=a.compareBoundaryPoints(Range.END_TO_START,c)&&0<=a.compareBoundaryPoints(Range.START_TO_END,c)}function p(a,c){var b=null;a.nodeType===Node.TEXT_NODE&&(0===a.length?(a.parentNode.removeChild(a),c.nodeType===Node.TEXT_NODE&&(b=c)):(c.nodeType===Node.TEXT_NODE&&(a.appendData(c.data),c.parentNode.removeChild(c)),b=a));return b} -function r(a){for(var c=a.parentNode;a.firstChild;)c.insertBefore(a.firstChild,a);c.removeChild(a);return c}function q(a,c){var b=a.parentNode,d=a.firstChild,l=c(a),e;if(l===NodeFilter.FILTER_SKIP)return b;for(;d;)e=d.nextSibling,q(d,c),d=e;b&&l===NodeFilter.FILTER_REJECT&&r(a);return b}function e(a,c){return a===c||Boolean(a.compareDocumentPosition(c)&Node.DOCUMENT_POSITION_CONTAINED_BY)}function l(a,c){return g().unscaledRangeClientRects?a:a/c}function a(c,h,b){Object.keys(h).forEach(function(d){var l= -d.split(":"),e=l[1],f=b(l[0]),l=h[d],n=typeof l;"object"===n?Object.keys(l).length&&(d=f?c.getElementsByTagNameNS(f,e)[0]||c.ownerDocument.createElementNS(f,d):c.getElementsByTagName(e)[0]||c.ownerDocument.createElement(d),c.appendChild(d),a(d,l,b)):f&&(runtime.assert("number"===n||"string"===n,"attempting to map unsupported type '"+n+"' (key: "+d+")"),c.setAttributeNS(f,d,String(l)))})}var c=null;this.splitBoundaries=function(a){var c,d=[],l,e,f;if(a.startContainer.nodeType===Node.TEXT_NODE||a.endContainer.nodeType=== -Node.TEXT_NODE){l=a.endContainer;e=a.endContainer.nodeType!==Node.TEXT_NODE?a.endOffset===a.endContainer.childNodes.length:!1;f=a.endOffset;c=a.endContainer;if(fg))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0k))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}};core.NodeFilterChain=function(g){var k=NodeFilter.FILTER_REJECT,d=NodeFilter.FILTER_ACCEPT;this.acceptNode=function(b){var f;for(f=0;f "+c.length),runtime.assert(0<=b,"Error in setPosition: "+b+" < 0"),b===c.length&&(l.nextSibling()?a=0:l.parentNode()?a=1:runtime.assert(!1,"Error in setUnfilteredPosition: position not valid."))):ba.value||"%"===a.unit)?null:a}function L(a){return(a=I(a))&&"%"!==a.unit?null:a}function E(a){switch(a.namespaceURI){case odf.Namespaces.drawns:case odf.Namespaces.svgns:case odf.Namespaces.dr3dns:return!1;case odf.Namespaces.textns:switch(a.localName){case "note-body":case "ruby-text":return!1}break;case odf.Namespaces.officens:switch(a.localName){case "annotation":case "binary-data":case "event-listeners":return!1}break;default:switch(a.localName){case "cursor":case "editinfo":return!1}}return!0} -function N(a){return Boolean(n(a)&&(!r(a.textContent)||A(a,0)))}function O(a,c){for(;0=c.value||"%"===c.unit)?null:c;return c||L(a)};this.parseFoLineHeight= -function(a){return K(a)||L(a)};this.isTextContentContainingNode=E;this.getTextNodes=function(a,c){var b;b=aa.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_REJECT;a.nodeType===Node.TEXT_NODE?N(a)&&(c=NodeFilter.FILTER_ACCEPT):E(a)&&(c=NodeFilter.FILTER_SKIP);return c},NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);c||O(a,b);return b};this.getTextElements=D;this.getParagraphElements=function(a){var c;c=aa.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_REJECT;if(f(a))c=NodeFilter.FILTER_ACCEPT; -else if(E(a)||q(a))c=NodeFilter.FILTER_SKIP;return c},NodeFilter.SHOW_ELEMENT);V(a.startContainer,c,f);return c};this.getImageElements=function(a){var c;c=aa.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_SKIP;g(a)&&(c=NodeFilter.FILTER_ACCEPT);return c},NodeFilter.SHOW_ELEMENT);V(a.startContainer,c,g);return c};this.getHyperlinkElements=function(a){var c=[],d=a.cloneRange();a.collapsed&&a.endContainer.nodeType===Node.ELEMENT_NODE&&(a=W(a.endContainer,a.endOffset),a.nodeType===Node.TEXT_NODE&& -d.setEnd(a,1));D(d,!0,!1).forEach(function(a){for(a=a.parentNode;!f(a);){if(b(a)&&-1===c.indexOf(a)){c.push(a);break}a=a.parentNode}});d.detach();return c};this.getNormalizedFontFamilyName=function(a){/^(["'])(?:.|[\n\r])*?\1$/.test(a)||(a=a.replace(/^[ \t\r\n\f]*((?:.|[\n\r])*?)[ \t\r\n\f]*$/,"$1"),/[ \t\r\n\f]/.test(a)&&(a="'"+a.replace(/[ \t\r\n\f]+/g," ")+"'"));return a}};odf.OdfUtils=new odf.OdfUtilsImpl; -gui.OdfTextBodyNodeFilter=function(){var g=odf.OdfUtils,k=Node.TEXT_NODE,d=NodeFilter.FILTER_REJECT,b=NodeFilter.FILTER_ACCEPT,f=odf.Namespaces.textns;this.acceptNode=function(n){if(n.nodeType===k){if(!g.isGroupingElement(n.parentNode))return d}else if(n.namespaceURI===f&&"tracked-changes"===n.localName)return d;return b}};xmldom.LSSerializerFilter=function(){};xmldom.LSSerializerFilter.prototype.acceptNode=function(g){}; -odf.OdfNodeFilter=function(){this.acceptNode=function(g){return"http://www.w3.org/1999/xhtml"===g.namespaceURI?NodeFilter.FILTER_SKIP:g.namespaceURI&&g.namespaceURI.match(/^urn:webodf:/)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}};xmldom.XPathIterator=function(){};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){}; -function createXPathSingleton(){function g(b,a,c){return-1!==b&&(b=e&&c.push(k(b.substring(a,d)))):"["===b[d]&&(0>=e&&(a=d+1),e+=1),d+=1;return d};q=function(d,a,c){var m,h,e,n;for(m=0;m/g,">").replace(/'/g,"'").replace(/"/g,""")}function d(f,n){var g="",r=b.filter?b.filter.acceptNode(n):NodeFilter.FILTER_ACCEPT,q;if(r===NodeFilter.FILTER_ACCEPT&&n.nodeType===Node.ELEMENT_NODE){f.push();q=f.getQName(n);var e,l=n.attributes,a,c,m,h="",y;e="<"+q;a=l.length;for(c=0;c")}if(r===NodeFilter.FILTER_ACCEPT||r===NodeFilter.FILTER_SKIP){for(r=n.firstChild;r;)g+=d(f,r),r=r.nextSibling;n.nodeValue&&(g+=k(n.nodeValue))}q&&(g+="",f.pop());return g}var b=this;this.filter=null;this.writeToString=function(b,n){if(!b)return"";var k=new g(n);return d(k,b)}}; -(function(){function g(b){var a,c=r.length;for(a=0;ac)break;h=h.nextSibling}b.insertBefore(a,h)}}}var f=new odf.StyleInfo,n=core.DomUtils,p=odf.Namespaces.stylens,r="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "), -q=Date.now()+"_webodf_",e=new core.Base64;odf.ODFElement=function(){};odf.ODFDocumentElement=function(){};odf.ODFDocumentElement.prototype=new odf.ODFElement;odf.ODFDocumentElement.prototype.constructor=odf.ODFDocumentElement;odf.ODFDocumentElement.prototype.fontFaceDecls=null;odf.ODFDocumentElement.prototype.manifest=null;odf.ODFDocumentElement.prototype.settings=null;odf.ODFDocumentElement.namespaceURI="urn:oasis:names:tc:opendocument:xmlns:office:1.0";odf.ODFDocumentElement.localName="document"; -odf.AnnotationElement=function(){};odf.OdfPart=function(b,a,c,d){var h=this;this.size=0;this.type=null;this.name=b;this.container=c;this.url=null;this.mimetype=a;this.onstatereadychange=this.document=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.data="";this.load=function(){null!==d&&(this.mimetype=a,d.loadAsDataURL(b,a,function(a,c){a&&runtime.log(a);h.url=c;if(h.onchange)h.onchange(h);if(h.onstatereadychange)h.onstatereadychange(h)}))}};odf.OdfPart.prototype.load=function(){}; -odf.OdfPart.prototype.getUrl=function(){return this.data?"data:;base64,"+e.toBase64(this.data):null};odf.OdfContainer=function a(c,m){function h(a){for(var c=a.firstChild,b;c;)b=c.nextSibling,c.nodeType===Node.ELEMENT_NODE?h(c):c.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(c),c=b}function g(a){var c={},b,d,h=a.ownerDocument.createNodeIterator(a,NodeFilter.SHOW_ELEMENT,null,!1);for(a=h.nextNode();a;)"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&("annotation"=== -a.localName?(b=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))&&(c.hasOwnProperty(b)?runtime.log("Warning: annotation name used more than once with : '"+b+"'"):c[b]=a):"annotation-end"===a.localName&&((b=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))?c.hasOwnProperty(b)?(d=c[b],d.annotationEndElement?runtime.log("Warning: annotation name used more than once with : '"+b+"'"):d.annotationEndElement= -a):runtime.log("Warning: annotation end without an annotation start, name: '"+b+"'"):runtime.log("Warning: annotation end without a name found"))),a=h.nextNode()}function r(a,c){for(var b=a&&a.firstChild;b;)b.nodeType===Node.ELEMENT_NODE&&b.setAttributeNS("urn:webodf:names:scope","scope",c),b=b.nextSibling}function z(a,c){for(var b=B.rootElement.meta,b=b&&b.firstChild;b&&(b.namespaceURI!==a||b.localName!==c);)b=b.nextSibling;for(b=b&&b.firstChild;b&&b.nodeType!==Node.TEXT_NODE;)b=b.nextSibling;return b? -b.data:null}function w(a){var c={},b;for(a=a.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&a.namespaceURI===p&&"font-face"===a.localName&&(b=a.getAttributeNS(p,"name"),c[b]=a),a=a.nextSibling;return c}function v(a,c){var b=null,d,h,e;if(a)for(b=a.cloneNode(!0),d=b.firstElementChild;d;)h=d.nextElementSibling,(e=d.getAttributeNS("urn:webodf:names:scope","scope"))&&e!==c&&b.removeChild(d),d=h;return b}function u(a,c){var b,d,h,e=null,m={};if(a)for(c.forEach(function(a){f.collectUsedFontFaces(m,a)}), -e=a.cloneNode(!0),b=e.firstElementChild;b;)d=b.nextElementSibling,h=b.getAttributeNS(p,"name"),m[h]||e.removeChild(b),b=d;return e}function t(a){var c=B.rootElement.ownerDocument,b;if(a){h(a.documentElement);try{b=c.importNode(a.documentElement,!0)}catch(d){}}return b}function A(a){B.state=a;if(B.onchange)B.onchange(B);if(B.onstatereadychange)B.onstatereadychange(B)}function I(a){Q=null;B.rootElement=a;a.fontFaceDecls=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"); -a.styles=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles");a.automaticStyles=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");a.masterStyles=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles");a.body=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");a.meta=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta");a.settings=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", -"settings");a.scripts=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","scripts");g(a)}function K(c){var d=t(c),h=B.rootElement,e;d&&"document-styles"===d.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===d.namespaceURI?(h.fontFaceDecls=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),b(h,h.fontFaceDecls),e=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),h.styles=e||c.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0", -"styles"),b(h,h.styles),e=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),h.automaticStyles=e||c.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),r(h.automaticStyles,"document-styles"),b(h,h.automaticStyles),d=n.getDirectChild(d,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),h.masterStyles=d||c.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),b(h,h.masterStyles), -f.prefixStyleNames(h.automaticStyles,q,h.masterStyles)):A(a.INVALID)}function L(c){c=t(c);var d,h,e,m;if(c&&"document-content"===c.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===c.namespaceURI){d=B.rootElement;e=n.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");if(d.fontFaceDecls&&e){m=d.fontFaceDecls;var g,k,O,q,D={};h=w(m);q=w(e);for(e=e.firstElementChild;e;){g=e.nextElementSibling;if(e.namespaceURI===p&&"font-face"===e.localName)if(k=e.getAttributeNS(p, -"name"),h.hasOwnProperty(k)){if(!e.isEqualNode(h[k])){O=k;for(var y=h,E=q,u=0,W=void 0,W=O=O.replace(/\d+$/,"");y.hasOwnProperty(W)||E.hasOwnProperty(W);)u+=1,W=O+u;O=W;e.setAttributeNS(p,"style:name",O);m.appendChild(e);h[O]=e;delete q[k];D[k]=O}}else m.appendChild(e),h[k]=e,delete q[k];e=g}m=D}else e&&(d.fontFaceDecls=e,b(d,e));h=n.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");r(h,"document-content");m&&f.changeFontFaceNames(h,m);if(d.automaticStyles&&h)for(m= -h.firstChild;m;)d.automaticStyles.appendChild(m),m=h.firstChild;else h&&(d.automaticStyles=h,b(d,h));c=n.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");if(null===c)throw" tag is mising.";d.body=c;b(d,d.body)}else A(a.INVALID)}function E(a){a=t(a);var c;a&&"document-meta"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(c=B.rootElement,c.meta=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"), -b(c,c.meta))}function N(a){a=t(a);var c;a&&"document-settings"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(c=B.rootElement,c.settings=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),b(c,c.settings))}function O(a){a=t(a);var c;if(a&&"manifest"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===a.namespaceURI)for(c=B.rootElement,c.manifest=a,a=c.manifest.firstElementChild;a;)"file-entry"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"=== -a.namespaceURI&&(M[a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","full-path")]=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","media-type")),a=a.nextElementSibling}function D(a,c,b){a=n.getElementsByTagName(a,c);var d;for(d=0;d'}function P(){var a=new xmldom.LSSerializer,c=R("document-meta");a.filter=new odf.OdfNodeFilter;c+=a.writeToString(B.rootElement.meta,odf.Namespaces.namespaceMap);return c+""}function aa(a,c){var b=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");b.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",a);b.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", -"manifest:media-type",c);return b}function S(){var a=runtime.parseXML(''),c=a.documentElement,b=new xmldom.LSSerializer,d;for(d in M)M.hasOwnProperty(d)&&c.appendChild(aa(d,M[d]));b.filter=new odf.OdfNodeFilter;return'\n'+b.writeToString(a,odf.Namespaces.namespaceMap)}function fa(){var a,c,b,d=odf.Namespaces.namespaceMap, -h=new xmldom.LSSerializer,e=R("document-styles");c=v(B.rootElement.automaticStyles,"document-styles");b=B.rootElement.masterStyles.cloneNode(!0);a=u(B.rootElement.fontFaceDecls,[b,B.rootElement.styles,c]);f.removePrefixFromStyleNames(c,q,b);h.filter=new k(b,c);e+=h.writeToString(a,d);e+=h.writeToString(B.rootElement.styles,d);e+=h.writeToString(c,d);e+=h.writeToString(b,d);return e+""}function ha(){var a,c,b=odf.Namespaces.namespaceMap,h=new xmldom.LSSerializer,e=R("document-content"); -c=v(B.rootElement.automaticStyles,"document-content");a=u(B.rootElement.fontFaceDecls,[c]);h.filter=new d(B.rootElement.body,c);e+=h.writeToString(a,b);e+=h.writeToString(c,b);e+=h.writeToString(B.rootElement.body,b);return e+""}function C(c,b){runtime.loadXML(c,function(c,d){if(c)b(c);else if(d){V(d);W(d.documentElement);var h=t(d);h&&"document"===h.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===h.namespaceURI?(I(h),A(a.DONE)):A(a.INVALID)}else b("No DOM was loaded.")})} -function Z(a,c){var d;d=B.rootElement;var h=d.meta;h||(d.meta=h=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),b(d,h));d=h;a&&n.mapKeyValObjOntoNode(d,a,odf.Namespaces.lookupNamespaceURI);c&&n.removeKeyElementsFromNode(d,c,odf.Namespaces.lookupNamespaceURI)}function ba(c,b){function d(a,c){var b;c||(c=a);b=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",c);f[a]=b;f.appendChild(b)}var h=new core.Zip("",null),e="application/vnd.oasis.opendocument."+ -c+(!0===b?"-template":""),m=runtime.byteArrayFromString(e,"utf8"),f=B.rootElement,g=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",c);h.save("mimetype",m,!1,new Date);d("meta");d("settings");d("scripts");d("fontFaceDecls","font-face-decls");d("styles");d("automaticStyles","automatic-styles");d("masterStyles","master-styles");d("body");f.body.appendChild(g);M["/"]=e;M["settings.xml"]="text/xml";M["meta.xml"]="text/xml";M["styles.xml"]="text/xml";M["content.xml"]="text/xml"; -A(a.DONE);return h}function U(){var a,c=new Date,b="";B.rootElement.settings&&B.rootElement.settings.firstElementChild&&(a=new xmldom.LSSerializer,b=R("document-settings"),a.filter=new odf.OdfNodeFilter,b+=a.writeToString(B.rootElement.settings,odf.Namespaces.namespaceMap),b+="");(a=b)?(a=runtime.byteArrayFromString(a,"utf8"),Y.save("settings.xml",a,!0,c)):Y.remove("settings.xml");b=runtime.getWindow();a="WebODF/"+webodf.Version;b&&(a=a+" "+b.navigator.userAgent);Z({"meta:generator":a}, -null);a=runtime.byteArrayFromString(P(),"utf8");Y.save("meta.xml",a,!0,c);a=runtime.byteArrayFromString(fa(),"utf8");Y.save("styles.xml",a,!0,c);a=runtime.byteArrayFromString(ha(),"utf8");Y.save("content.xml",a,!0,c);a=runtime.byteArrayFromString(S(),"utf8");Y.save("META-INF/manifest.xml",a,!0,c)}function ga(a,c){U();Y.writeAs(a,function(a){c(a)})}var B=this,Y,M={},Q,F="";this.onstatereadychange=m;this.state=this.onchange=null;this.getMetadata=z;this.setRootElement=I;this.getContentElement=function(){var a; -Q||(a=B.rootElement.body,Q=n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","text")||n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","presentation")||n.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","spreadsheet"));if(!Q)throw"Could not find content element in .";return Q};this.getDocumentType=function(){var a=B.getContentElement();return a&&a.localName};this.isTemplate=function(){return"-template"===M["/"].substr(-9)}; -this.setIsTemplate=function(a){var c=M["/"],b="-template"===c.substr(-9);a!==b&&(c=a?c+"-template":c.substr(0,c.length-9),M["/"]=c,a=runtime.byteArrayFromString(c,"utf8"),Y.save("mimetype",a,!1,new Date))};this.getPart=function(a){return new odf.OdfPart(a,M[a],B,Y)};this.getPartData=function(a,c){Y.load(a,c)};this.setMetadata=Z;this.incrementEditingCycles=function(){var a=z(odf.Namespaces.metans,"editing-cycles"),a=a?parseInt(a,10):0;isNaN(a)&&(a=0);Z({"meta:editing-cycles":a+1},null);return a+1}; -this.createByteArray=function(a,c){U();Y.createByteArray(a,c)};this.saveAs=ga;this.save=function(a){ga(F,a)};this.getUrl=function(){return F};this.setBlob=function(a,c,b){b=e.convertBase64ToByteArray(b);Y.save(a,b,!1,new Date);M.hasOwnProperty(a)&&runtime.log(a+" has been overwritten.");M[a]=c};this.removeBlob=function(a){var c=Y.remove(a);runtime.assert(c,"file is not found: "+a);delete M[a]};this.state=a.LOADING;this.rootElement=function(a){var c=document.createElementNS(a.namespaceURI,a.localName), -b;a=new a.Type;for(b in a)a.hasOwnProperty(b)&&(c[b]=a[b]);return c}({Type:odf.ODFDocumentElement,namespaceURI:odf.ODFDocumentElement.namespaceURI,localName:odf.ODFDocumentElement.localName});c===odf.OdfContainer.DocumentType.TEXT?Y=ba("text"):c===odf.OdfContainer.DocumentType.TEXT_TEMPLATE?Y=ba("text",!0):c===odf.OdfContainer.DocumentType.PRESENTATION?Y=ba("presentation"):c===odf.OdfContainer.DocumentType.PRESENTATION_TEMPLATE?Y=ba("presentation",!0):c===odf.OdfContainer.DocumentType.SPREADSHEET? -Y=ba("spreadsheet"):c===odf.OdfContainer.DocumentType.SPREADSHEET_TEMPLATE?Y=ba("spreadsheet",!0):(F=c,Y=new core.Zip(F,function(c,b){Y=b;c?C(F,function(b){c&&(Y.error=c+"\n"+b,A(a.INVALID))}):J([{path:"styles.xml",handler:K},{path:"content.xml",handler:L},{path:"meta.xml",handler:E},{path:"settings.xml",handler:N},{path:"META-INF/manifest.xml",handler:O}])}))};odf.OdfContainer.EMPTY=0;odf.OdfContainer.LOADING=1;odf.OdfContainer.DONE=2;odf.OdfContainer.INVALID=3;odf.OdfContainer.SAVING=4;odf.OdfContainer.MODIFIED= -5;odf.OdfContainer.getContainer=function(a){return new odf.OdfContainer(a,null)}})();odf.OdfContainer.DocumentType={TEXT:1,TEXT_TEMPLATE:2,PRESENTATION:3,PRESENTATION_TEMPLATE:4,SPREADSHEET:5,SPREADSHEET_TEMPLATE:6};gui.AnnotatableCanvas=function(){};gui.AnnotatableCanvas.prototype.refreshSize=function(){};gui.AnnotatableCanvas.prototype.getZoomLevel=function(){};gui.AnnotatableCanvas.prototype.getSizer=function(){}; -gui.AnnotationViewManager=function(g,k,d,b){function f(c){var b=c.annotationEndElement,d=l.createRange(),e=c.getAttributeNS(odf.Namespaces.officens,"name");b&&(d.setStart(c,c.childNodes.length),d.setEnd(b,0),c=a.getTextNodes(d,!1),c.forEach(function(a){var c;a:{for(c=a.parentNode;c.namespaceURI!==odf.Namespaces.officens||"body"!==c.localName;){if("http://www.w3.org/1999/xhtml"===c.namespaceURI&&"webodf-annotationHighlight"===c.className&&c.getAttribute("annotation")===e){c=!0;break a}c=c.parentNode}c= -!1}c||(c=l.createElement("span"),c.className="webodf-annotationHighlight",c.setAttribute("annotation",e),a.parentNode.replaceChild(c,a),c.appendChild(a))}));d.detach()}function n(a){var b=g.getSizer();a?(d.style.display="inline-block",b.style.paddingRight=c.getComputedStyle(d).width):(d.style.display="none",b.style.paddingRight=0);g.refreshSize()}function p(){e.sort(function(a,c){return 0!==(a.compareDocumentPosition(c)&Node.DOCUMENT_POSITION_FOLLOWING)?-1:1})}function r(){var a;for(a=0;a=(n.getBoundingClientRect().top-r.bottom)/c?b.style.top=Math.abs(n.getBoundingClientRect().top-r.bottom)/c+20+"px":b.style.top="0px"): -b.style.top="0px";l.style.left=f.getBoundingClientRect().width/c+"px";var f=l.style,n=l.getBoundingClientRect().left/c,k=l.getBoundingClientRect().top/c,r=b.getBoundingClientRect().left/c,p=b.getBoundingClientRect().top/c,q=0,I=0,q=r-n,q=q*q,I=p-k,I=I*I,n=Math.sqrt(q+I);f.width=n+"px";k=Math.asin((b.getBoundingClientRect().top-l.getBoundingClientRect().top)/(c*parseFloat(l.style.width)));l.style.transform="rotate("+k+"rad)";l.style.MozTransform="rotate("+k+"rad)";l.style.WebkitTransform="rotate("+ -k+"rad)";l.style.msTransform="rotate("+k+"rad)"}}function q(a){var c=e.indexOf(a),b=a.parentNode.parentNode;"div"===b.localName&&(b.parentNode.insertBefore(a,b),b.parentNode.removeChild(b));a=a.getAttributeNS(odf.Namespaces.officens,"name");a=l.querySelectorAll('span.webodf-annotationHighlight[annotation="'+a+'"]');for(var d,b=0;bp||k.bottom>p)g.scrollTop=k.bottom-k.top<=p-f?g.scrollTop+(k.bottom-p):g.scrollTop+(k.top-f);k.leftn&&(g.scrollLeft=k.right-k.left<=n-b?g.scrollLeft+(k.right-n):g.scrollLeft-(b-k.left))}}}; -(function(){function g(d,n,k,r,q){var e,l=0,a;for(a in d)if(d.hasOwnProperty(a)){if(l===k){e=a;break}l+=1}e?n.getPartData(d[e].href,function(a,m){if(a)runtime.log(a);else if(m){var h="@font-face { font-family: "+(d[e].family||e)+"; src: url(data:application/x-font-ttf;charset=binary;base64,"+b.convertUTF8ArrayToBase64(m)+') format("truetype"); }';try{r.insertRule(h,r.cssRules.length)}catch(l){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(l)+"\nRule: "+h)}}else runtime.log("missing font data for "+ -d[e].href);g(d,n,k+1,r,q)}):q&&q()}var k=xmldom.XPath,d=odf.OdfUtils,b=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(b,n){for(var p=b.rootElement.fontFaceDecls;n.cssRules.length;)n.deleteRule(n.cssRules.length-1);if(p){var r={},q,e,l,a;if(p)for(p=k.getODFElementsWithXPath(p,"style:font-face[svg:font-face-src]",odf.Namespaces.lookupNamespaceURI),q=0;q text|list-item:first-child > :not(text|list):first-child:before',u+="{",u+="counter-increment: "+p+" 0;",u+="}",g(b,u));for(;l.counterIdStack.length>=k;)l.counterIdStack.pop();l.counterIdStack.push(p);t=l.contentRules[k.toString()]||"";for(u=1;u<=k;u+=1)t=t.replace(u+"webodf-listLevel",l.counterIdStack[u-1]);u='text|list[webodfhelper|counter-id="'+r+'"] > text|list-item > :not(text|list):first-child:before'; -u+="{";u+=t;u+="counter-increment: "+p+";";u+="}";g(b,u)}for(h=h.firstElementChild;h;)d(c,h,f,l),h=h.nextElementSibling}else l.continuedCounterIdStack=[]}var f=0,a="",c={};this.createCounterRules=function(a,b,n){var g=b.getAttributeNS(p,"id"),r=[];n&&(n=n.getAttributeNS("urn:webodf:names:helper","counter-id"),r=c[n].slice(0));a=new k(a,r);g?g="Y"+g:(f+=1,g="X"+f);d(g,b,0,a);c[g+"-level1-1"]=a.counterIdStack};this.initialiseCreatedCounters=function(){var c;c="office|document{"+("counter-reset: "+a+ -";");c+="}";g(b,c)}}var b=odf.Namespaces.fons,f=odf.Namespaces.stylens,n=odf.Namespaces.textns,p=odf.Namespaces.xmlns,r={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"};odf.ListStyleToCss=function(){function k(a){var b=m.parseLength(a);return b?c.convert(b.value,b.unit,"px"):(runtime.log("Could not parse value '"+a+"'."),0)}function e(a){return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function l(a,c){var b;a&&(b=a.getAttributeNS(n,"style-name"));return b===c}function a(a, -c,b){c=c.getElementsByTagNameNS(n,"list");a=new d(a);var m,g,k,q,t,A,I={},K;for(K=0;K text|list-item > text|list",--x;x=E&&E.getAttributeNS(b,"text-align")||"left";switch(x){case "end":x="right";break;case "start":x="left"}"label-alignment"===N?(D=O&&O.getAttributeNS(b,"margin-left")||"0px",J=O&&O.getAttributeNS(b,"text-indent")||"0px",R=O&&O.getAttributeNS(n,"label-followed-by"),O=k(D)):(D=E&&E.getAttributeNS(n,"space-before")||"0px",V=E&&E.getAttributeNS(n,"min-label-width")||"0px", -W=E&&E.getAttributeNS(n,"min-label-distance")||"0px",O=k(D)+k(V));E=p+" > text|list-item";E+="{";E+="margin-left: "+O+"px;";E+="}";g(e,E);E=p+" > text|list-item > text|list";E+="{";E+="margin-left: "+-O+"px;";E+="}";g(e,E);E=p+" > text|list-item > :not(text|list):first-child:before";E+="{";E+="text-align: "+x+";";E+="display: inline-block;";"label-alignment"===N?(E+="margin-left: "+J+";","listtab"===R&&(E+="padding-right: 0.2cm;")):(E+="min-width: "+V+";",E+="margin-left: "+(0===parseFloat(V)?"": -"-")+V+";",E+="padding-right: "+W+";");E+="}";g(e,E)}d=d.nextElementSibling}});a(c,e,m)}}})();odf.LazyStyleProperties=function(g,k){var d={};this.value=function(b){var f;d.hasOwnProperty(b)?f=d[b]:(f=k[b](),void 0===f&&g&&(f=g.value(b)),d[b]=f);return f};this.reset=function(b){g=b;d={}}}; -odf.StyleParseUtils=function(){function g(d){var b,f;d=(d=/(-?[0-9]*[0-9][0-9]*(\.[0-9]*)?|0+\.[0-9]*[1-9][0-9]*|\.[0-9]*[1-9][0-9]*)((cm)|(mm)|(in)|(pt)|(pc)|(px))/.exec(d))?{value:parseFloat(d[1]),unit:d[3]}:null;f=d&&d.unit;"px"===f?b=d.value:"cm"===f?b=d.value/2.54*96:"mm"===f?b=d.value/25.4*96:"in"===f?b=96*d.value:"pt"===f?b=d.value/.75:"pc"===f&&(b=16*d.value);return b}var k=odf.Namespaces.stylens;this.parseLength=g;this.parsePositiveLengthOrPercent=function(d,b,f){var n;d&&(n=parseFloat(d.substr(0, -d.indexOf("%"))),isNaN(n)&&(n=void 0));var k;void 0!==n?(f&&(k=f.value(b)),n=void 0===k?void 0:k/100*n):n=g(d);return n};this.getPropertiesElement=function(d,b,f){for(b=f?f.nextElementSibling:b.firstElementChild;null!==b&&(b.localName!==d||b.namespaceURI!==k);)b=b.nextElementSibling;return b};this.parseAttributeList=function(d){d&&(d=d.replace(/^\s*(.*?)\s*$/g,"$1"));return d&&0n.value&&(m="0.75pt"+h);h=m}else if(V.hasOwnProperty(e[1])){var m= -a,f=e[0],n=e[1],g=J.parseLength(h),r=void 0,p=void 0,q=void 0,O=void 0,q=void 0;if(g&&"%"===g.unit){r=g.value/100;p=k(m.parentNode);for(O="0";p;){if(q=y.getDirectChild(p,l,"paragraph-properties"))if(q=J.parseLength(q.getAttributeNS(f,n))){if("%"!==q.unit){O=q.value*r+q.unit;break}r*=q.value/100}p=k(p)}h=O}}e[2]&&(b+=e[2]+":"+h+";")}return b}function b(a,c,b,d){return c+c+b+b+d+d}function f(a,c){var b=[a],d=c.derivedStyles;Object.keys(d).forEach(function(a){a=f(a,d[a]);b=b.concat(a)});return b}function n(a, -c,b,d){function e(c,b){var d=[],h;c.forEach(function(a){m.forEach(function(c){d.push('draw|page[webodfhelper|page-style-name="'+c+'"] draw|frame[presentation|class="'+a+'"]')})});0 -z&&(a=z);for(c=Math.floor(a/d)*d;!b&&0<=c;)b=m[c],c-=d;for(b=b||x;b.nextBookmark&&b.nextBookmark.steps<=a;)e.check(),b=b.nextBookmark;runtime.assert(-1===a||b.steps<=a,"Bookmark @"+p(b)+" at step "+b.steps+" exceeds requested step of "+a);return b}function a(a){a.previousBookmark&&(a.previousBookmark.nextBookmark=a.nextBookmark);a.nextBookmark&&(a.nextBookmark.previousBookmark=a.previousBookmark)}function c(a){for(var c,b=null;!b&&a&&a!==k;)(c=q(a))&&(b=h[c])&&b.node!==a&&(runtime.log("Cloned node detected. Creating new bookmark"), -b=null,a.removeAttributeNS("urn:webodf:names:steps","nodeId")),a=a.parentNode;return b}var m={},h={},y=core.DomUtils,x,z,w=Node.DOCUMENT_POSITION_FOLLOWING,v=Node.DOCUMENT_POSITION_PRECEDING;this.updateBookmark=function(c,b){var g,n=Math.ceil(c/d)*d,p,v,E;if(void 0!==z&&zp.steps)m[n]=v;r()};this.setToClosestStep=function(a,c){var b;r();b=l(a);b.setIteratorPosition(c); -return b.steps};this.setToClosestDomPoint=function(a,b,d){var e,h;r();if(a===k&&0===b)e=x;else if(a===k&&b===k.childNodes.length)for(h in e=x,m)m.hasOwnProperty(h)&&(a=m[h],a.steps>e.steps&&(e=a));else if(e=c(a.childNodes.item(b)||a),!e)for(d.setUnfilteredPosition(a,b);!e&&d.previousNode();)e=c(d.getCurrentNode());e=e||x;void 0!==z&&e.steps>z&&(e=l(z));e.setIteratorPosition(d);return e.steps};this.damageCacheAfterStep=function(a){0>a&&(a=-1);void 0===z?z=a:aa)throw new RangeError("Requested steps is negative ("+a+")");for(b=p.setToClosestStep(a,k);bq.comparePoints(g,0,a,b),a=g,b=b?0:g.childNodes.length);k.setUnfilteredPosition(a,b);n(k,h)||k.setUnfilteredPosition(a,b);h=k.container();b=k.unfilteredDomOffset();a=p.setToClosestDomPoint(h,b,k);if(0>q.comparePoints(k.container(),k.unfilteredDomOffset(),h,b))return 0=e.textNode.length?null:e.textNode.splitText(e.offset));for(c=e.textNode;c!==a;){c=c.parentNode;m=c.cloneNode(!1);h&&m.appendChild(h);if(y)for(;y&&y.nextSibling;)m.appendChild(y.nextSibling);else for(;c.firstChild;)m.appendChild(c.firstChild);c.parentNode.insertBefore(m,c.nextSibling);y=c;h=m}p.isListItem(h)&&(h=h.childNodes.item(0));n?h.setAttributeNS(r,"text:style-name",n):h.removeAttributeNS(r,"style-name");0===e.textNode.length&& -e.textNode.parentNode.removeChild(e.textNode);d.emit(ops.OdtDocument.signalStepsInserted,{position:b});x&&f&&(d.moveCursor(g,b+1,0),d.emit(ops.Document.signalCursorMoved,x));d.fixCursorPositions();d.getOdfCanvas().refreshSize();d.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:l,memberId:g,timeStamp:k});d.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:h,memberId:g,timeStamp:k});d.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph", -memberid:g,timestamp:k,position:b,sourceParagraphPosition:d,paragraphStyleName:n,moveCursor:f}}}; -ops.OpUpdateMember=function(){function g(d){var f="//dc:creator[@editinfo:memberid='"+k+"']";d=xmldom.XPath.getODFElementsWithXPath(d.getRootNode(),f,function(b){return"editinfo"===b?"urn:webodf:names:editinfo":odf.Namespaces.lookupNamespaceURI(b)});for(f=0;f=e.width&&(e=null),g.detach();else if(k.isCharacterElement(f.container)||k.isCharacterFrame(f.container))e=b.getBoundingClientRect(f.container); -return e}var k=odf.OdfUtils,d=new odf.StepUtils,b=core.DomUtils,f=core.StepDirection.NEXT,n=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT,p=gui.StepInfo.VisualDirection.RIGHT_TO_LEFT;this.getContentRect=g;this.moveToFilteredStep=function(b,d,e){function l(a,b){b.process(w,h,k)&&(a=!0,!x&&b.token&&(x=b.token));return a}var a=d===f,c,m,h,k,x,z=b.snapshot();c=!1;var w;do c=g(b),w={token:b.snapshot(),container:b.container,offset:b.offset,direction:d,visualDirection:d===f?n:p},m=b.nextStep()?g(b):null,b.restore(w.token), -a?(h=c,k=m):(h=m,k=c),c=e.reduce(l,!1);while(!c&&b.advanceStep(d));c||e.forEach(function(a){!x&&a.token&&(x=a.token)});b.restore(x||z);return Boolean(x)}}; -gui.Caret=function(g,k,d,b){function f(){a.style.opacity="0"===a.style.opacity?"1":"0";t.trigger()}function n(){y.selectNodeContents(h);return y.getBoundingClientRect()}function p(a){return E[a]!==L[a]}function r(){Object.keys(L).forEach(function(a){E[a]=L[a]})}function q(){if(!1===L.isShown||g.getSelectionType()!==ops.OdtCursor.RangeSelection||!b&&!g.getSelectedRange().collapsed)L.visibility="hidden",a.style.visibility="hidden",t.cancel();else if(L.visibility="visible",a.style.visibility="visible", -!1===L.isFocused)a.style.opacity="1",t.cancel();else{if(A||p("visibility"))a.style.opacity="1",t.cancel();t.trigger()}if(K||I){var d;d=g.getNode();var e,h,f=z.getBoundingClientRect(x.getSizer()),q=!1,y=0;d.removeAttributeNS("urn:webodf:names:cursor","caret-sizer-active");if(0d.height&&(d={top:d.top-(8-d.height)/2,height:8,right:d.right});l.style.height=d.height+"px";l.style.top=d.top+"px"; -l.style.left=d.right-d.width+"px";l.style.width=d.width?d.width+"px":"";m&&(d=runtime.getWindow().getComputedStyle(g.getNode(),null),d.font?m.style.font=d.font:(m.style.fontStyle=d.fontStyle,m.style.fontVariant=d.fontVariant,m.style.fontWeight=d.fontWeight,m.style.fontSize=d.fontSize,m.style.lineHeight=d.lineHeight,m.style.fontFamily=d.fontFamily))}L.isShown&&I&&k.scrollIntoView(a.getBoundingClientRect());p("isFocused")&&c.markAsFocussed(L.isFocused);r();K=I=A=!1}function e(a){l.parentNode.removeChild(l); -h.parentNode.removeChild(h);a()}var l,a,c,m,h,y,x=g.getDocument().getCanvas(),z=core.DomUtils,w=new gui.GuiStepUtils,v,u,t,A=!1,I=!1,K=!1,L={isFocused:!1,isShown:!0,visibility:"hidden"},E={isFocused:!L.isFocused,isShown:!L.isShown,visibility:"hidden"};this.handleUpdate=function(){K=!0;u.trigger()};this.refreshCursorBlinking=function(){A=!0;u.trigger()};this.setFocus=function(){L.isFocused=!0;u.trigger()};this.removeFocus=function(){L.isFocused=!1;u.trigger()};this.show=function(){L.isShown=!0;u.trigger()}; -this.hide=function(){L.isShown=!1;u.trigger()};this.setAvatarImageUrl=function(a){c.setImageUrl(a)};this.setColor=function(b){a.style.borderColor=b;c.setColor(b)};this.getCursor=function(){return g};this.getFocusElement=function(){return a};this.toggleHandleVisibility=function(){c.isVisible()?c.hide():c.show()};this.showHandle=function(){c.show()};this.hideHandle=function(){c.hide()};this.setOverlayElement=function(a){m=a;l.appendChild(a);K=!0;u.trigger()};this.ensureVisible=function(){I=!0;u.trigger()}; -this.getBoundingClientRect=function(){return z.getBoundingClientRect(l)};this.destroy=function(a){core.Async.destroyAll([u.destroy,t.destroy,c.destroy,e],a)};(function(){var b=g.getDocument(),e=[b.createRootFilter(g.getMemberId()),b.getPositionFilter()],m=b.getDOMDocument();y=m.createRange();h=m.createElement("span");h.className="webodf-caretSizer";h.textContent="|";g.getNode().appendChild(h);l=m.createElement("div");l.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",g.getMemberId()); -l.className="webodf-caretOverlay";a=m.createElement("div");a.className="caret";l.appendChild(a);c=new gui.Avatar(l,d);x.getSizer().appendChild(l);v=b.createStepIterator(g.getNode(),0,e,b.getRootNode());u=core.Task.createRedrawTask(q);t=core.Task.createTimeoutTask(f,500);u.triggerImmediate()})()}; -odf.TextSerializer=function(){function g(b){var f="",n=k.filter?k.filter.acceptNode(b):NodeFilter.FILTER_ACCEPT,p=b.nodeType,r;if((n===NodeFilter.FILTER_ACCEPT||n===NodeFilter.FILTER_SKIP)&&d.isTextContentContainingNode(b))for(r=b.firstChild;r;)f+=g(r),r=r.nextSibling;n===NodeFilter.FILTER_ACCEPT&&(p===Node.ELEMENT_NODE&&d.isParagraph(b)?f+="\n":p===Node.TEXT_NODE&&b.textContent&&(f+=b.textContent));return f}var k=this,d=odf.OdfUtils;this.filter=null;this.writeToString=function(b){if(!b)return""; -b=g(b);"\n"===b[b.length-1]&&(b=b.substr(0,b.length-1));return b}};gui.MimeDataExporter=function(){var g;this.exportRangeToDataTransfer=function(k,d){var b;b=d.startContainer.ownerDocument.createElement("span");b.appendChild(d.cloneContents());b=g.writeToString(b);try{k.setData("text/plain",b)}catch(f){k.setData("Text",b)}};g=new odf.TextSerializer;g.filter=new odf.OdfNodeFilter}; -gui.Clipboard=function(g){this.setDataFromRange=function(k,d){var b,f=k.clipboardData;b=runtime.getWindow();!f&&b&&(f=b.clipboardData);f?(b=!0,g.exportRangeToDataTransfer(f,d),k.preventDefault()):b=!1;return b}}; -gui.SessionContext=function(g,k){var d=g.getOdtDocument(),b=odf.OdfUtils;this.isLocalCursorWithinOwnAnnotation=function(){var f=d.getCursor(k),g;if(!f)return!1;g=f&&f.getNode();f=d.getMember(k).getProperties().fullName;return(g=b.getParentAnnotation(g,d.getRootNode()))&&b.getAnnotationCreator(g)===f?!0:!1}}; -gui.StyleSummary=function(g){function k(b,d){var k=b+"|"+d,q;f.hasOwnProperty(k)||(q=[],g.forEach(function(e){e=(e=e.styleProperties[b])&&e[d];-1===q.indexOf(e)&&q.push(e)}),f[k]=q);return f[k]}function d(b,d,f){return function(){var g=k(b,d);return f.length>=g.length&&g.every(function(b){return-1!==f.indexOf(b)})}}function b(b,d){var f=k(b,d);return 1===f.length?f[0]:void 0}var f={};this.getPropertyValues=k;this.getCommonValue=b;this.isBold=d("style:text-properties","fo:font-weight",["bold"]);this.isItalic= -d("style:text-properties","fo:font-style",["italic"]);this.hasUnderline=d("style:text-properties","style:text-underline-style",["solid"]);this.hasStrikeThrough=d("style:text-properties","style:text-line-through-style",["solid"]);this.fontSize=function(){var d=b("style:text-properties","fo:font-size");return d&&parseFloat(d)};this.fontName=function(){return b("style:text-properties","style:font-name")};this.isAlignedLeft=d("style:paragraph-properties","fo:text-align",["left","start"]);this.isAlignedCenter= -d("style:paragraph-properties","fo:text-align",["center"]);this.isAlignedRight=d("style:paragraph-properties","fo:text-align",["right","end"]);this.isAlignedJustified=d("style:paragraph-properties","fo:text-align",["justify"]);this.text={isBold:this.isBold,isItalic:this.isItalic,hasUnderline:this.hasUnderline,hasStrikeThrough:this.hasStrikeThrough,fontSize:this.fontSize,fontName:this.fontName};this.paragraph={isAlignedLeft:this.isAlignedLeft,isAlignedCenter:this.isAlignedCenter,isAlignedRight:this.isAlignedRight, -isAlignedJustified:this.isAlignedJustified}}; -gui.DirectFormattingController=function(g,k,d,b,f,n,p){function r(){return U.value().styleSummary}function q(){return U.value().enabledFeatures}function e(a){var b;a.collapsed?(b=a.startContainer,b.hasChildNodes()&&a.startOffseta.clientWidth||a.scrollHeight>a.clientHeight)&&c.push(new l(a)),a=a.parentNode;c.push(new e(v));return c}function w(){var a; -h()||(a=z(K),x(),K.focus(),a.forEach(function(a){a.restore()}))}var v=runtime.getWindow(),u={beforecut:!0,beforepaste:!0,longpress:!0,drag:!0,dragstop:!0},t={mousedown:!0,mouseup:!0,focus:!0},A={},I={},K,L=g.getCanvas().getElement(),E=this,N={};this.addFilter=function(c,b){a(c,!0).filters.push(b)};this.removeFilter=function(c,b){var d=a(c,!0),e=d.filters.indexOf(b);-1!==e&&d.filters.splice(e,1)};this.subscribe=c;this.unsubscribe=m;this.hasFocus=h;this.focus=w;this.getEventTrap=function(){return K}; -this.setEditing=function(a){var c=h();c&&K.blur();a?K.removeAttribute("readOnly"):K.setAttribute("readOnly","true");c&&w()};this.destroy=function(a){m("touchstart",q);Object.keys(N).forEach(function(a){b(parseInt(a,10))});N.length=0;Object.keys(A).forEach(function(a){A[a].destroy()});A={};m("mousedown",y);m("mouseup",x);m("contextmenu",x);Object.keys(I).forEach(function(a){I[a].destroy()});I={};K.parentNode.removeChild(K);a()};(function(){var a=g.getOdfCanvas().getSizer(),b=a.ownerDocument;runtime.assert(Boolean(v), -"EventManager requires a window object to operate correctly");K=b.createElement("textarea");K.id="eventTrap";K.setAttribute("tabindex","-1");K.setAttribute("readOnly","true");K.setAttribute("rows","1");a.appendChild(K);c("mousedown",y);c("mouseup",x);c("contextmenu",x);A.longpress=new d("longpress",["touchstart","touchmove","touchend"],n);A.drag=new d("drag",["touchstart","touchmove","touchend"],p);A.dragstop=new d("dragstop",["drag","touchend"],r);c("touchstart",q)})()}; -gui.IOSSafariSupport=function(g){function k(){d.innerHeight!==d.outerHeight&&(b.style.display="none",runtime.requestAnimationFrame(function(){b.style.display="block"}))}var d=runtime.getWindow(),b=g.getEventTrap();this.destroy=function(d){g.unsubscribe("focus",k);b.removeAttribute("autocapitalize");b.style.WebkitTransform="";d()};g.subscribe("focus",k);b.setAttribute("autocapitalize","off");b.style.WebkitTransform="translateX(-10000px)"}; -gui.HyperlinkController=function(g,k,d,b){function f(){var b=!0;!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(b=d.isLocalCursorWithinOwnAnnotation());b!==e&&(e=b,q.emit(gui.HyperlinkController.enabledChanged,e))}function n(d){d.getMemberId()===b&&f()}var p=odf.OdfUtils,r=g.getOdtDocument(),q=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),e=!1;this.isEnabled=function(){return e};this.subscribe=function(b,a){q.subscribe(b,a)};this.unsubscribe=function(b,a){q.unsubscribe(b, -a)};this.addHyperlink=function(d,a){if(e){var c=r.getCursorSelection(b),f=new ops.OpApplyHyperlink,h=[];if(0===c.length||a)a=a||d,f=new ops.OpInsertText,f.init({memberid:b,position:c.position,text:a}),c.length=a.length,h.push(f);f=new ops.OpApplyHyperlink;f.init({memberid:b,position:c.position,length:c.length,hyperlink:d});h.push(f);g.enqueue(h)}};this.removeHyperlinks=function(){if(e){var d=r.createPositionIterator(r.getRootNode()),a=r.getCursor(b).getSelectedRange(),c=p.getHyperlinkElements(a), -f=a.collapsed&&1===c.length,h=r.getDOMDocument().createRange(),k=[],n,q;0!==c.length&&(c.forEach(function(a){h.selectNodeContents(a);n=r.convertDomToCursorRange({anchorNode:h.startContainer,anchorOffset:h.startOffset,focusNode:h.endContainer,focusOffset:h.endOffset});q=new ops.OpRemoveHyperlink;q.init({memberid:b,position:n.position,length:n.length});k.push(q)}),f||(f=c[0],-1===a.comparePoint(f,0)&&(h.setStart(f,0),h.setEnd(a.startContainer,a.startOffset),n=r.convertDomToCursorRange({anchorNode:h.startContainer, -anchorOffset:h.startOffset,focusNode:h.endContainer,focusOffset:h.endOffset}),0k.width&&(v=k.width/n.width);n.height>k.height&&(u=k.height/n.height);k=Math.min(v,u);n= -{width:n.width*k,height:n.height*k}}k=p.convert(n.width,"px","cm")+"cm";p=p.convert(n.height,"px","cm")+"cm";u=e.getOdfCanvas().odfContainer().rootElement.styles;n=c.toLowerCase();var v=r.hasOwnProperty(n)?r[n]:null,t;n=[];runtime.assert(null!==v,"Image type is not supported: "+c);v="Pictures/"+f.generateImageName()+v;t=new ops.OpSetBlob;t.init({memberid:b,filename:v,mimetype:c,content:d});n.push(t);a.getStyleElement("Graphics","graphic",[u])||(c=new ops.OpAddStyle,c.init({memberid:b,styleName:"Graphics", -styleFamily:"graphic",isAutomaticStyle:!1,setProperties:{"style:graphic-properties":{"text:anchor-type":"paragraph","svg:x":"0cm","svg:y":"0cm","style:wrap":"dynamic","style:number-wrapped-paragraphs":"no-limit","style:wrap-contour":"false","style:vertical-pos":"top","style:vertical-rel":"paragraph","style:horizontal-pos":"center","style:horizontal-rel":"paragraph"}}}),n.push(c));c=f.generateStyleName();d=new ops.OpAddStyle;d.init({memberid:b,styleName:c,styleFamily:"graphic",isAutomaticStyle:!0, -setProperties:{"style:parent-style-name":"Graphics","style:graphic-properties":{"style:vertical-pos":"top","style:vertical-rel":"baseline","style:horizontal-pos":"center","style:horizontal-rel":"paragraph","fo:background-color":"transparent","style:background-transparency":"100%","style:shadow":"none","style:mirror":"none","fo:clip":"rect(0cm, 0cm, 0cm, 0cm)","draw:luminance":"0%","draw:contrast":"0%","draw:red":"0%","draw:green":"0%","draw:blue":"0%","draw:gamma":"100%","draw:color-inversion":"false", -"draw:image-opacity":"100%","draw:color-mode":"standard"}}});n.push(d);t=new ops.OpInsertImage;t.init({memberid:b,position:e.getCursorPosition(b),filename:v,frameWidth:k,frameHeight:p,frameStyleName:c,frameName:f.generateFrameName()});n.push(t);g.enqueue(n)}};this.destroy=function(a){e.unsubscribe(ops.Document.signalCursorMoved,p);k.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,n);a()};e.subscribe(ops.Document.signalCursorMoved,p);k.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,n);n()}; -gui.ImageController.enabledChanged="enabled/changed"; -gui.ImageSelector=function(g){function k(){var d=g.getSizer(),k=f.createElement("div");k.id="imageSelector";k.style.borderWidth="1px";d.appendChild(k);b.forEach(function(b){var d=f.createElement("div");d.className=b;k.appendChild(d)});return k}var d=odf.Namespaces.svgns,b="topLeft topRight bottomRight bottomLeft topMiddle rightMiddle bottomMiddle leftMiddle".split(" "),f=g.getElement().ownerDocument,n=!1;this.select=function(b){var r,q,e=f.getElementById("imageSelector");e||(e=k());n=!0;r=e.parentNode; -q=b.getBoundingClientRect();var l=r.getBoundingClientRect(),a=g.getZoomLevel();r=(q.left-l.left)/a-1;q=(q.top-l.top)/a-1;e.style.display="block";e.style.left=r+"px";e.style.top=q+"px";e.style.width=b.getAttributeNS(d,"width");e.style.height=b.getAttributeNS(d,"height")};this.clearSelection=function(){var b;n&&(b=f.getElementById("imageSelector"))&&(b.style.display="none");n=!1};this.isSelectorElement=function(b){var d=f.getElementById("imageSelector");return d?b===d||b.parentNode===d:!1}}; -(function(){function g(g){function d(b){p=b.which&&String.fromCharCode(b.which)===n;n=void 0;return!1===p}function b(){p=!1}function f(b){n=b.data;p=!1}var n,p=!1;this.destroy=function(n){g.unsubscribe("textInput",b);g.unsubscribe("compositionend",f);g.removeFilter("keypress",d);n()};g.subscribe("textInput",b);g.subscribe("compositionend",f);g.addFilter("keypress",d)}gui.InputMethodEditor=function(k,d){function b(c){a&&(c?a.getNode().setAttributeNS("urn:webodf:names:cursor","composing","true"):(a.getNode().removeAttributeNS("urn:webodf:names:cursor", -"composing"),h.textContent=""))}function f(){x&&(x=!1,b(!1),w.emit(gui.InputMethodEditor.signalCompositionEnd,{data:z}),z="")}function n(){I||(I=!0,f(),a&&a.getSelectedRange().collapsed?c.value="":c.value=u.writeToString(a.getSelectedRange().cloneContents()),c.setSelectionRange(0,c.value.length),I=!1)}function p(){d.hasFocus()&&y.trigger()}function r(){v=void 0;y.cancel();b(!0);x||w.emit(gui.InputMethodEditor.signalCompositionStart,{data:""})}function q(a){a=v=a.data;x=!0;z+=a;y.trigger()}function e(a){a.data!== -v&&(a=a.data,x=!0,z+=a,y.trigger());v=void 0}function l(){h.textContent=c.value}var a=null,c=d.getEventTrap(),m=c.ownerDocument,h,y,x=!1,z="",w=new core.EventNotifier([gui.InputMethodEditor.signalCompositionStart,gui.InputMethodEditor.signalCompositionEnd]),v,u,t=[],A,I=!1;this.subscribe=w.subscribe;this.unsubscribe=w.unsubscribe;this.registerCursor=function(c){c.getMemberId()===k&&(a=c,a.getNode().appendChild(h),c.subscribe(ops.OdtCursor.signalCursorUpdated,p),d.subscribe("input",l),d.subscribe("compositionupdate", -l))};this.removeCursor=function(c){a&&c===k&&(a.getNode().removeChild(h),a.unsubscribe(ops.OdtCursor.signalCursorUpdated,p),d.unsubscribe("input",l),d.unsubscribe("compositionupdate",l),a=null)};this.destroy=function(a){d.unsubscribe("compositionstart",r);d.unsubscribe("compositionend",q);d.unsubscribe("textInput",e);d.unsubscribe("keypress",f);d.unsubscribe("focus",n);core.Async.destroyAll(A,a)};(function(){u=new odf.TextSerializer;u.filter=new odf.OdfNodeFilter;d.subscribe("compositionstart",r); -d.subscribe("compositionend",q);d.subscribe("textInput",e);d.subscribe("keypress",f);d.subscribe("focus",n);t.push(new g(d));A=t.map(function(a){return a.destroy});h=m.createElement("span");h.setAttribute("id","composer");y=core.Task.createTimeoutTask(n,1);A.push(y.destroy)})()};gui.InputMethodEditor.signalCompositionStart="input/compositionstart";gui.InputMethodEditor.signalCompositionEnd="input/compositionend"})(); -gui.MetadataController=function(g,k){function d(b){n.emit(gui.MetadataController.signalMetadataChanged,b)}function b(b){var d=-1===p.indexOf(b);d||runtime.log("Setting "+b+" is restricted.");return d}var f=g.getOdtDocument(),n=new core.EventNotifier([gui.MetadataController.signalMetadataChanged]),p=["dc:creator","dc:date","meta:editing-cycles","meta:editing-duration","meta:document-statistic"];this.setMetadata=function(d,f){var e={},l="",a;d&&Object.keys(d).filter(b).forEach(function(a){e[a]=d[a]}); -f&&(l=f.filter(b).join(","));if(0f:!1}function d(b){null!==b&&!1===k(b)&&(f=Math.abs(b-g))}var b=this,f,n=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT;this.token=void 0;this.process=function(f,g,q){var e,l;f.visualDirection===n?(e=g&&g.right,l=q&&q.left):(e=g&&g.left,l=q&&q.right);if(k(e)||k(l))return!0;if(g||q)d(e),d(l),b.token=f.token;return!1}}; -gui.LineBoundaryScanner=function(){var g=this,k=null;this.token=void 0;this.process=function(d,b,f){var n;if(n=f)if(k){var p=k;n=Math.min(p.bottom-p.top,f.bottom-f.top);var r=Math.max(p.top,f.top),p=Math.min(p.bottom,f.bottom)-r;n=.4>=(0b?a.previousSibling:a.nextSibling,c(f)===NodeFilter.FILTER_ACCEPT&&(d=f),a=a.parentNode;return d}function b(a,b){var c;return null===a?m.NO_NEIGHBOUR:p.isCharacterElement(a)?m.SPACE_CHAR:a.nodeType===f||p.isTextSpan(a)||p.isHyperlink(a)?(c=a.textContent.charAt(b()),q.test(c)?m.SPACE_CHAR:r.test(c)?m.PUNCTUATION_CHAR:m.WORD_CHAR):m.OTHER}var f=Node.TEXT_NODE,n=Node.ELEMENT_NODE, -p=odf.OdfUtils,r=/[!-#%-*,-\/:-;?-@\[-\]_{}\u00a1\u00ab\u00b7\u00bb\u00bf;\u00b7\u055a-\u055f\u0589-\u058a\u05be\u05c0\u05c3\u05c6\u05f3-\u05f4\u0609-\u060a\u060c-\u060d\u061b\u061e-\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0964-\u0965\u0970\u0df4\u0e4f\u0e5a-\u0e5b\u0f04-\u0f12\u0f3a-\u0f3d\u0f85\u0fd0-\u0fd4\u104a-\u104f\u10fb\u1361-\u1368\u166d-\u166e\u169b-\u169c\u16eb-\u16ed\u1735-\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u180a\u1944-\u1945\u19de-\u19df\u1a1e-\u1a1f\u1b5a-\u1b60\u1c3b-\u1c3f\u1c7e-\u1c7f\u2000-\u206e\u207d-\u207e\u208d-\u208e\u3008-\u3009\u2768-\u2775\u27c5-\u27c6\u27e6-\u27ef\u2983-\u2998\u29d8-\u29db\u29fc-\u29fd\u2cf9-\u2cfc\u2cfe-\u2cff\u2e00-\u2e7e\u3000-\u303f\u30a0\u30fb\ua60d-\ua60f\ua673\ua67e\ua874-\ua877\ua8ce-\ua8cf\ua92e-\ua92f\ua95f\uaa5c-\uaa5f\ufd3e-\ufd3f\ufe10-\ufe19\ufe30-\ufe52\ufe54-\ufe61\ufe63\ufe68\ufe6a-\ufe6b\uff01-\uff03\uff05-\uff0a\uff0c-\uff0f\uff1a-\uff1b\uff1f-\uff20\uff3b-\uff3d\uff3f\uff5b\uff5d\uff5f-\uff65]|\ud800[\udd00-\udd01\udf9f\udfd0]|\ud802[\udd1f\udd3f\ude50-\ude58]|\ud809[\udc00-\udc7e]/, -q=/\s/,e=core.PositionFilter.FilterResult.FILTER_ACCEPT,l=core.PositionFilter.FilterResult.FILTER_REJECT,a=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,c=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,m={NO_NEIGHBOUR:0,SPACE_CHAR:1,PUNCTUATION_CHAR:2,WORD_CHAR:3,OTHER:4};this.acceptPosition=function(f){var g=f.container(),p=f.leftNode(),r=f.rightNode(),q=f.unfilteredDomOffset,v=function(){return f.unfilteredDomOffset()-1};g.nodeType===n&&(null===r&&(r=d(g,1,f.getNodeFilter())),null===p&&(p= -d(g,-1,f.getNodeFilter())));g!==r&&(q=function(){return 0});g!==p&&null!==p&&(v=function(){return p.textContent.length-1});g=b(p,v);r=b(r,q);return g===m.WORD_CHAR&&r===m.WORD_CHAR||g===m.PUNCTUATION_CHAR&&r===m.PUNCTUATION_CHAR||k===a&&g!==m.NO_NEIGHBOUR&&r===m.SPACE_CHAR||k===c&&g===m.SPACE_CHAR&&r!==m.NO_NEIGHBOUR?l:e}};odf.WordBoundaryFilter.IncludeWhitespace={None:0,TRAILING:1,LEADING:2}; -gui.SelectionController=function(g,k){function d(a){var b=a.spec();if(a.isEdit||b.memberid===k)I=void 0,K.cancel()}function b(){var a=x.getCursor(k).getNode();return x.createStepIterator(a,0,[v,t],x.getRootElement(a))}function f(a,b,c){c=new odf.WordBoundaryFilter(x,c);var d=x.getRootElement(a)||x.getRootNode(),e=x.createRootFilter(d);return x.createStepIterator(a,b,[v,e,c],d)}function n(a,b){return b?{anchorNode:a.startContainer,anchorOffset:a.startOffset,focusNode:a.endContainer,focusOffset:a.endOffset}: -{anchorNode:a.endContainer,anchorOffset:a.endOffset,focusNode:a.startContainer,focusOffset:a.startOffset}}function p(a,b,c){var d=new ops.OpMoveCursor;d.init({memberid:k,position:a,length:b||0,selectionType:c});return d}function r(a,b,c){var d;d=x.getCursor(k);d=n(d.getSelectedRange(),d.hasForwardSelection());d.focusNode=a;d.focusOffset=b;c||(d.anchorNode=d.focusNode,d.anchorOffset=d.focusOffset);a=x.convertDomToCursorRange(d);g.enqueue([p(a.position,a.length)])}function q(a){var b;b=f(a.startContainer, -a.startOffset,L);b.roundToPreviousStep()&&a.setStart(b.container(),b.offset());b=f(a.endContainer,a.endOffset,E);b.roundToNextStep()&&a.setEnd(b.container(),b.offset())}function e(a){var b=w.getParagraphElements(a),c=b[0],b=b[b.length-1];c&&a.setStart(c,0);b&&(w.isParagraph(a.endContainer)&&0===a.endOffset?a.setEndBefore(b):a.setEnd(b,b.childNodes.length))}function l(a,b,c,d){var e,f;d?(e=c.startContainer,f=c.startOffset):(e=c.endContainer,f=c.endOffset);z.containsNode(a,e)||(f=0>z.comparePoints(a, -0,e,f)?0:a.childNodes.length,e=a);a=x.createStepIterator(e,f,b,w.getParagraphElement(e)||a);a.roundToClosestStep()||runtime.assert(!1,"No step found in requested range");d?c.setStart(a.container(),a.offset()):c.setEnd(a.container(),a.offset())}function a(a,c){var d=b();d.advanceStep(a)&&r(d.container(),d.offset(),c)}function c(a,c){var d,e=I,f=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];void 0===e&&A&&(e=A());isNaN(e)||(d=b(),u.moveToFilteredStep(d,a,f)&&d.advanceStep(a)&&(f=[new gui.ClosestXOffsetScanner(e), -new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner],u.moveToFilteredStep(d,a,f)&&(r(d.container(),d.offset(),c),I=e,K.restart())))}function m(a,c){var d=b(),e=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];u.moveToFilteredStep(d,a,e)&&r(d.container(),d.offset(),c)}function h(a,b){var c=x.getCursor(k),c=n(c.getSelectedRange(),c.hasForwardSelection()),c=f(c.focusNode,c.focusOffset,L);c.advanceStep(a)&&r(c.container(),c.offset(),b)}function y(a,b,c){var d=!1,e=x.getCursor(k), -e=n(e.getSelectedRange(),e.hasForwardSelection()),d=x.getRootElement(e.focusNode);runtime.assert(Boolean(d),"SelectionController: Cursor outside root");e=x.createStepIterator(e.focusNode,e.focusOffset,[v,t],d);e.roundToClosestStep();e.advanceStep(a)&&(c=c(e.container()))&&(a===N?(e.setPosition(c,0),d=e.roundToNextStep()):(e.setPosition(c,c.childNodes.length),d=e.roundToPreviousStep()),d&&r(e.container(),e.offset(),b))}var x=g.getOdtDocument(),z=core.DomUtils,w=odf.OdfUtils,v=x.getPositionFilter(), -u=new gui.GuiStepUtils,t=x.createRootFilter(k),A=null,I,K,L=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,E=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,N=core.StepDirection.PREVIOUS,O=core.StepDirection.NEXT;this.selectionToRange=function(a){var b=0<=z.comparePoints(a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset),c=a.focusNode.ownerDocument.createRange();b?(c.setStart(a.anchorNode,a.anchorOffset),c.setEnd(a.focusNode,a.focusOffset)):(c.setStart(a.focusNode,a.focusOffset),c.setEnd(a.anchorNode, -a.anchorOffset));return{range:c,hasForwardSelection:b}};this.rangeToSelection=n;this.selectImage=function(a){var c=x.getRootElement(a),b=x.createRootFilter(c),c=x.createStepIterator(a,0,[b,x.getPositionFilter()],c),d;c.roundToPreviousStep()||runtime.assert(!1,"No walkable position before frame");b=c.container();d=c.offset();c.setPosition(a,a.childNodes.length);c.roundToNextStep()||runtime.assert(!1,"No walkable position after frame");a=x.convertDomToCursorRange({anchorNode:b,anchorOffset:d,focusNode:c.container(), -focusOffset:c.offset()});a=p(a.position,a.length,ops.OdtCursor.RegionSelection);g.enqueue([a])};this.expandToWordBoundaries=q;this.expandToParagraphBoundaries=e;this.selectRange=function(a,c,b){var d=x.getOdfCanvas().getElement(),f,h=[v];f=z.containsNode(d,a.startContainer);d=z.containsNode(d,a.endContainer);if(f||d)if(f&&d&&(2===b?q(a):3<=b&&e(a)),(b=c?x.getRootElement(a.startContainer):x.getRootElement(a.endContainer))||(b=x.getRootNode()),h.push(x.createRootFilter(b)),l(b,h,a,!0),l(b,h,a,!1),a= -n(a,c),c=x.convertDomToCursorRange(a),a=x.getCursorSelection(k),c.position!==a.position||c.length!==a.length)a=p(c.position,c.length,ops.OdtCursor.RangeSelection),g.enqueue([a])};this.moveCursorToLeft=function(){a(N,!1);return!0};this.moveCursorToRight=function(){a(O,!1);return!0};this.extendSelectionToLeft=function(){a(N,!0);return!0};this.extendSelectionToRight=function(){a(O,!0);return!0};this.setCaretXPositionLocator=function(a){A=a};this.moveCursorUp=function(){c(N,!1);return!0};this.moveCursorDown= -function(){c(O,!1);return!0};this.extendSelectionUp=function(){c(N,!0);return!0};this.extendSelectionDown=function(){c(O,!0);return!0};this.moveCursorBeforeWord=function(){h(N,!1);return!0};this.moveCursorPastWord=function(){h(O,!1);return!0};this.extendSelectionBeforeWord=function(){h(N,!0);return!0};this.extendSelectionPastWord=function(){h(O,!0);return!0};this.moveCursorToLineStart=function(){m(N,!1);return!0};this.moveCursorToLineEnd=function(){m(O,!1);return!0};this.extendSelectionToLineStart= -function(){m(N,!0);return!0};this.extendSelectionToLineEnd=function(){m(O,!0);return!0};this.extendSelectionToParagraphStart=function(){y(N,!0,w.getParagraphElement);return!0};this.extendSelectionToParagraphEnd=function(){y(O,!0,w.getParagraphElement);return!0};this.moveCursorToParagraphStart=function(){y(N,!1,w.getParagraphElement);return!0};this.moveCursorToParagraphEnd=function(){y(O,!1,w.getParagraphElement);return!0};this.moveCursorToDocumentStart=function(){y(N,!1,x.getRootElement);return!0}; -this.moveCursorToDocumentEnd=function(){y(O,!1,x.getRootElement);return!0};this.extendSelectionToDocumentStart=function(){y(N,!0,x.getRootElement);return!0};this.extendSelectionToDocumentEnd=function(){y(O,!0,x.getRootElement);return!0};this.extendSelectionToEntireDocument=function(){var a=x.getCursor(k),a=x.getRootElement(a.getNode()),c,b,d;runtime.assert(Boolean(a),"SelectionController: Cursor outside root");d=x.createStepIterator(a,0,[v,t],a);d.roundToClosestStep();c=d.container();b=d.offset(); -d.setPosition(a,a.childNodes.length);d.roundToClosestStep();a=x.convertDomToCursorRange({anchorNode:c,anchorOffset:b,focusNode:d.container(),focusOffset:d.offset()});g.enqueue([p(a.position,a.length)]);return!0};this.destroy=function(a){x.unsubscribe(ops.OdtDocument.signalOperationStart,d);core.Async.destroyAll([K.destroy],a)};(function(){K=core.Task.createTimeoutTask(function(){I=void 0},2E3);x.subscribe(ops.OdtDocument.signalOperationStart,d)})()}; -gui.TextController=function(g,k,d,b,f,n){function p(){y=!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?d.isLocalCursorWithinOwnAnnotation():!0}function r(a){a.getMemberId()===b&&p()}function q(a,b,d){var e=[c.getPositionFilter()];d&&e.push(c.createRootFilter(a.startContainer));d=c.createStepIterator(a.startContainer,a.startOffset,e,b);d.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range start");b=c.convertDomPointToCursorStep(d.container(),d.offset()); -a.collapsed?a=b:(d.setPosition(a.endContainer,a.endOffset),d.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range end"),a=c.convertDomPointToCursorStep(d.container(),d.offset()));return{position:b,length:a-b}}function e(a){var c,d,e,f=m.getParagraphElements(a),g=a.cloneRange(),l=[];c=f[0];1a.length&&(a.position+=a.length,a.length=-a.length);return a}function a(a){if(!y)return!1;var d,f=c.getCursor(b).getSelectedRange().cloneRange(), -h=l(c.getCursorSelection(b)),m;if(0===h.length){h=void 0;d=c.getCursor(b).getNode();m=c.getRootElement(d);var k=[c.getPositionFilter(),c.createRootFilter(m)];m=c.createStepIterator(d,0,k,m);m.roundToClosestStep()&&(a?m.nextStep():m.previousStep())&&(h=l(c.convertDomToCursorRange({anchorNode:d,anchorOffset:0,focusNode:m.container(),focusOffset:m.offset()})),a?(f.setStart(d,0),f.setEnd(m.container(),m.offset())):(f.setStart(m.container(),m.offset()),f.setEnd(d,0)))}h&&g.enqueue(e(f));return void 0!== -h}var c=g.getOdtDocument(),m=odf.OdfUtils,h=core.DomUtils,y=!1,x=odf.Namespaces.textns,z=core.StepDirection.NEXT;this.isEnabled=function(){return y};this.enqueueParagraphSplittingOps=function(){if(!y)return!1;var a=c.getCursor(b),d=a.getSelectedRange(),f=l(c.getCursorSelection(b)),h=[],a=m.getParagraphElement(a.getNode()),k=a.getAttributeNS(x,"style-name")||"";0d.left&&(d=v(e)))c.focusNode=d.container,c.focusOffset=d.offset, -b&&(c.anchorNode=c.focusNode,c.anchorOffset=c.focusOffset)}else S.isImage(c.focusNode.firstChild)&&1===c.focusOffset&&S.isCharacterFrame(c.focusNode)&&(d=v(c.focusNode))&&(c.anchorNode=c.focusNode=d.container,c.anchorOffset=c.focusOffset=d.offset);c.anchorNode&&c.focusNode&&(c=T.selectionToRange(c),T.selectRange(c.range,c.hasForwardSelection,0===a.button?a.detail:0));F.focus()}function t(a){var c;if(c=n(a.clientX,a.clientY))a=c.container,c=c.offset,a={anchorNode:a,anchorOffset:c,focusNode:a,focusOffset:c}, -a=T.selectionToRange(a),T.selectRange(a.range,a.hasForwardSelection,2),F.focus()}function A(a){var c=a.target||a.srcElement||null,d,e,f;ma.processRequests();U&&(S.isImage(c)&&S.isCharacterFrame(c.parentNode)&&W.getSelection().isCollapsed?(T.selectImage(c.parentNode),F.focus()):la.isSelectorElement(c)?F.focus():B?(c=b.getSelectedRange(),e=c.collapsed,S.isImage(c.endContainer)&&0===c.endOffset&&S.isCharacterFrame(c.endContainer.parentNode)&&(f=c.endContainer.parentNode,f=v(f))&&(c.setEnd(f.container, -f.offset),e&&c.collapse(!1)),T.selectRange(c,b.hasForwardSelection(),0===a.button?a.detail:0),F.focus()):ua?u(a):(d=aa.cloneEvent(a),M=runtime.setTimeout(function(){u(d)},0)),oa=0,B=U=!1)}function I(a){var c=J.getCursor(d).getSelectedRange();c.collapsed||fa.exportRangeToDataTransfer(a.dataTransfer,c)}function K(){U&&F.focus();oa=0;B=U=!1}function L(a){A(a)}function E(a){var c=a.target||a.srcElement||null,b=null;"annotationRemoveButton"===c.className?(runtime.assert(ja,"Remove buttons are displayed on annotations while annotation editing is disabled in the controller."), -b=c.parentNode.getElementsByTagNameNS(odf.Namespaces.officens,"annotation").item(0),ca.removeAnnotation(b),F.focus()):"webodf-draggable"!==c.getAttribute("class")&&A(a)}function N(a){(a=a.data)&&(-1===a.indexOf("\n")?da.insertText(a):ea.paste(a))}function O(a){return function(){a();return!0}}function D(a){return function(c){return J.getCursor(d).getSelectionType()===ops.OdtCursor.RangeSelection?a(c):!0}}function V(c){F.unsubscribe("keydown",C.handleEvent);F.unsubscribe("keypress",Z.handleEvent);F.unsubscribe("keyup", -ba.handleEvent);F.unsubscribe("copy",q);F.unsubscribe("mousedown",w);F.unsubscribe("mousemove",ma.trigger);F.unsubscribe("mouseup",E);F.unsubscribe("contextmenu",L);F.unsubscribe("dragstart",I);F.unsubscribe("dragend",K);F.unsubscribe("click",pa.handleClick);F.unsubscribe("longpress",t);F.unsubscribe("drag",y);F.unsubscribe("dragstop",x);J.unsubscribe(ops.OdtDocument.signalOperationEnd,na.trigger);J.unsubscribe(ops.Document.signalCursorAdded,ka.registerCursor);J.unsubscribe(ops.Document.signalCursorRemoved, -ka.removeCursor);J.unsubscribe(ops.OdtDocument.signalOperationEnd,a);c()}var W=runtime.getWindow(),J=k.getOdtDocument(),R=new gui.SessionConstraints,P=new gui.SessionContext(k,d),aa=core.DomUtils,S=odf.OdfUtils,fa=new gui.MimeDataExporter,ha=new gui.Clipboard(fa),C=new gui.KeyboardHandler,Z=new gui.KeyboardHandler,ba=new gui.KeyboardHandler,U=!1,ga=new odf.ObjectNameGenerator(J.getOdfCanvas().odfContainer(),d),B=!1,Y=null,M,Q=null,F=new gui.EventManager(J),ja=f.annotationsEnabled,ca=new gui.AnnotationController(k, -R,d),X=new gui.DirectFormattingController(k,R,P,d,ga,f.directTextStylingEnabled,f.directParagraphStylingEnabled),da=new gui.TextController(k,R,P,d,X.createCursorStyleOp,X.createParagraphStyleOps),qa=new gui.ImageController(k,R,P,d,ga),la=new gui.ImageSelector(J.getOdfCanvas()),ia=J.createPositionIterator(J.getRootNode()),ma,na,ea=new gui.PasteController(k,R,P,d),ka=new gui.InputMethodEditor(d,F),oa=0,pa=new gui.HyperlinkClickHandler(J.getOdfCanvas().getElement,C,ba),ta=new gui.HyperlinkController(k, -R,P,d),T=new gui.SelectionController(k,d),va=new gui.MetadataController(k,d),G=gui.KeyboardHandler.Modifier,H=gui.KeyboardHandler.KeyCode,ra=-1!==W.navigator.appVersion.toLowerCase().indexOf("mac"),ua=-1!==["iPad","iPod","iPhone"].indexOf(W.navigator.platform),sa;runtime.assert(null!==W,"Expected to be run in an environment which has a global window, like a browser.");this.undo=m;this.redo=h;this.insertLocalCursor=function(){runtime.assert(void 0===k.getOdtDocument().getCursor(d),"Inserting local cursor a second time."); -var a=new ops.OpAddCursor;a.init({memberid:d});k.enqueue([a]);F.focus()};this.removeLocalCursor=function(){runtime.assert(void 0!==k.getOdtDocument().getCursor(d),"Removing local cursor without inserting before.");var a=new ops.OpRemoveCursor;a.init({memberid:d});k.enqueue([a])};this.startEditing=function(){ka.subscribe(gui.InputMethodEditor.signalCompositionStart,da.removeCurrentSelection);ka.subscribe(gui.InputMethodEditor.signalCompositionEnd,N);F.subscribe("beforecut",r);F.subscribe("cut",p); -F.subscribe("beforepaste",l);F.subscribe("paste",e);Q&&Q.initialize();F.setEditing(!0);pa.setModifier(ra?G.Meta:G.Ctrl);C.bind(H.Backspace,G.None,O(da.removeTextByBackspaceKey),!0);C.bind(H.Delete,G.None,da.removeTextByDeleteKey);C.bind(H.Tab,G.None,D(function(){da.insertText("\t");return!0}));ra?(C.bind(H.Clear,G.None,da.removeCurrentSelection),C.bind(H.B,G.Meta,D(X.toggleBold)),C.bind(H.I,G.Meta,D(X.toggleItalic)),C.bind(H.U,G.Meta,D(X.toggleUnderline)),C.bind(H.L,G.MetaShift,D(X.alignParagraphLeft)), -C.bind(H.E,G.MetaShift,D(X.alignParagraphCenter)),C.bind(H.R,G.MetaShift,D(X.alignParagraphRight)),C.bind(H.J,G.MetaShift,D(X.alignParagraphJustified)),ja&&C.bind(H.C,G.MetaShift,ca.addAnnotation),C.bind(H.Z,G.Meta,m),C.bind(H.Z,G.MetaShift,h)):(C.bind(H.B,G.Ctrl,D(X.toggleBold)),C.bind(H.I,G.Ctrl,D(X.toggleItalic)),C.bind(H.U,G.Ctrl,D(X.toggleUnderline)),C.bind(H.L,G.CtrlShift,D(X.alignParagraphLeft)),C.bind(H.E,G.CtrlShift,D(X.alignParagraphCenter)),C.bind(H.R,G.CtrlShift,D(X.alignParagraphRight)), -C.bind(H.J,G.CtrlShift,D(X.alignParagraphJustified)),ja&&C.bind(H.C,G.CtrlAlt,ca.addAnnotation),C.bind(H.Z,G.Ctrl,m),C.bind(H.Z,G.CtrlShift,h));Z.setDefault(D(function(a){var c;c=null===a.which||void 0===a.which?String.fromCharCode(a.keyCode):0!==a.which&&0!==a.charCode?String.fromCharCode(a.which):null;return!c||a.altKey||a.ctrlKey||a.metaKey?!1:(da.insertText(c),!0)}));Z.bind(H.Enter,G.None,D(da.enqueueParagraphSplittingOps))};this.endEditing=function(){ka.unsubscribe(gui.InputMethodEditor.signalCompositionStart, -da.removeCurrentSelection);ka.unsubscribe(gui.InputMethodEditor.signalCompositionEnd,N);F.unsubscribe("cut",p);F.unsubscribe("beforecut",r);F.unsubscribe("paste",e);F.unsubscribe("beforepaste",l);F.setEditing(!1);pa.setModifier(G.None);C.bind(H.Backspace,G.None,function(){return!0},!0);C.unbind(H.Delete,G.None);C.unbind(H.Tab,G.None);ra?(C.unbind(H.Clear,G.None),C.unbind(H.B,G.Meta),C.unbind(H.I,G.Meta),C.unbind(H.U,G.Meta),C.unbind(H.L,G.MetaShift),C.unbind(H.E,G.MetaShift),C.unbind(H.R,G.MetaShift), -C.unbind(H.J,G.MetaShift),ja&&C.unbind(H.C,G.MetaShift),C.unbind(H.Z,G.Meta),C.unbind(H.Z,G.MetaShift)):(C.unbind(H.B,G.Ctrl),C.unbind(H.I,G.Ctrl),C.unbind(H.U,G.Ctrl),C.unbind(H.L,G.CtrlShift),C.unbind(H.E,G.CtrlShift),C.unbind(H.R,G.CtrlShift),C.unbind(H.J,G.CtrlShift),ja&&C.unbind(H.C,G.CtrlAlt),C.unbind(H.Z,G.Ctrl),C.unbind(H.Z,G.CtrlShift));Z.setDefault(null);Z.unbind(H.Enter,G.None)};this.getInputMemberId=function(){return d};this.getSession=function(){return k};this.getSessionConstraints=function(){return R}; -this.setUndoManager=function(a){Q&&Q.unsubscribe(gui.UndoManager.signalUndoStackChanged,c);if(Q=a)Q.setDocument(J),Q.setPlaybackFunction(k.enqueue),Q.subscribe(gui.UndoManager.signalUndoStackChanged,c)};this.getUndoManager=function(){return Q};this.getMetadataController=function(){return va};this.getAnnotationController=function(){return ca};this.getDirectFormattingController=function(){return X};this.getHyperlinkClickHandler=function(){return pa};this.getHyperlinkController=function(){return ta}; -this.getImageController=function(){return qa};this.getSelectionController=function(){return T};this.getTextController=function(){return da};this.getEventManager=function(){return F};this.getKeyboardHandlers=function(){return{keydown:C,keypress:Z}};this.destroy=function(a){var c=[ma.destroy,na.destroy,X.destroy,ka.destroy,F.destroy,pa.destroy,ta.destroy,va.destroy,T.destroy,da.destroy,V];sa&&c.unshift(sa.destroy);runtime.clearTimeout(M);core.Async.destroyAll(c,a)};ma=core.Task.createRedrawTask(z); -na=core.Task.createRedrawTask(function(){var a=J.getCursor(d);if(a&&a.getSelectionType()===ops.OdtCursor.RegionSelection&&(a=S.getImageElements(a.getSelectedRange())[0])){la.select(a.parentNode);return}la.clearSelection()});C.bind(H.Left,G.None,D(T.moveCursorToLeft));C.bind(H.Right,G.None,D(T.moveCursorToRight));C.bind(H.Up,G.None,D(T.moveCursorUp));C.bind(H.Down,G.None,D(T.moveCursorDown));C.bind(H.Left,G.Shift,D(T.extendSelectionToLeft));C.bind(H.Right,G.Shift,D(T.extendSelectionToRight));C.bind(H.Up, -G.Shift,D(T.extendSelectionUp));C.bind(H.Down,G.Shift,D(T.extendSelectionDown));C.bind(H.Home,G.None,D(T.moveCursorToLineStart));C.bind(H.End,G.None,D(T.moveCursorToLineEnd));C.bind(H.Home,G.Ctrl,D(T.moveCursorToDocumentStart));C.bind(H.End,G.Ctrl,D(T.moveCursorToDocumentEnd));C.bind(H.Home,G.Shift,D(T.extendSelectionToLineStart));C.bind(H.End,G.Shift,D(T.extendSelectionToLineEnd));C.bind(H.Up,G.CtrlShift,D(T.extendSelectionToParagraphStart));C.bind(H.Down,G.CtrlShift,D(T.extendSelectionToParagraphEnd)); -C.bind(H.Home,G.CtrlShift,D(T.extendSelectionToDocumentStart));C.bind(H.End,G.CtrlShift,D(T.extendSelectionToDocumentEnd));ra?(C.bind(H.Left,G.Alt,D(T.moveCursorBeforeWord)),C.bind(H.Right,G.Alt,D(T.moveCursorPastWord)),C.bind(H.Left,G.Meta,D(T.moveCursorToLineStart)),C.bind(H.Right,G.Meta,D(T.moveCursorToLineEnd)),C.bind(H.Home,G.Meta,D(T.moveCursorToDocumentStart)),C.bind(H.End,G.Meta,D(T.moveCursorToDocumentEnd)),C.bind(H.Left,G.AltShift,D(T.extendSelectionBeforeWord)),C.bind(H.Right,G.AltShift, -D(T.extendSelectionPastWord)),C.bind(H.Left,G.MetaShift,D(T.extendSelectionToLineStart)),C.bind(H.Right,G.MetaShift,D(T.extendSelectionToLineEnd)),C.bind(H.Up,G.AltShift,D(T.extendSelectionToParagraphStart)),C.bind(H.Down,G.AltShift,D(T.extendSelectionToParagraphEnd)),C.bind(H.Up,G.MetaShift,D(T.extendSelectionToDocumentStart)),C.bind(H.Down,G.MetaShift,D(T.extendSelectionToDocumentEnd)),C.bind(H.A,G.Meta,D(T.extendSelectionToEntireDocument))):(C.bind(H.Left,G.Ctrl,D(T.moveCursorBeforeWord)),C.bind(H.Right, -G.Ctrl,D(T.moveCursorPastWord)),C.bind(H.Left,G.CtrlShift,D(T.extendSelectionBeforeWord)),C.bind(H.Right,G.CtrlShift,D(T.extendSelectionPastWord)),C.bind(H.A,G.Ctrl,D(T.extendSelectionToEntireDocument)));ua&&(sa=new gui.IOSSafariSupport(F));F.subscribe("keydown",C.handleEvent);F.subscribe("keypress",Z.handleEvent);F.subscribe("keyup",ba.handleEvent);F.subscribe("copy",q);F.subscribe("mousedown",w);F.subscribe("mousemove",ma.trigger);F.subscribe("mouseup",E);F.subscribe("contextmenu",L);F.subscribe("dragstart", -I);F.subscribe("dragend",K);F.subscribe("click",pa.handleClick);F.subscribe("longpress",t);F.subscribe("drag",y);F.subscribe("dragstop",x);J.subscribe(ops.OdtDocument.signalOperationEnd,na.trigger);J.subscribe(ops.Document.signalCursorAdded,ka.registerCursor);J.subscribe(ops.Document.signalCursorRemoved,ka.removeCursor);J.subscribe(ops.OdtDocument.signalOperationEnd,a)}})(); -gui.CaretManager=function(g,k){function d(b){return n.hasOwnProperty(b)?n[b]:null}function b(){return Object.keys(n).map(function(b){return n[b]})}function f(b){var d=n[b];d&&(delete n[b],b===g.getInputMemberId()?(r.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,d.ensureVisible),r.unsubscribe(ops.Document.signalCursorMoved,d.refreshCursorBlinking),q.unsubscribe("compositionupdate",d.handleUpdate),q.unsubscribe("compositionend",d.handleUpdate),q.unsubscribe("focus",d.setFocus),q.unsubscribe("blur", -d.removeFocus),p.removeEventListener("focus",d.show,!1),p.removeEventListener("blur",d.hide,!1)):r.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,d.handleUpdate),d.destroy(function(){}))}var n={},p=runtime.getWindow(),r=g.getSession().getOdtDocument(),q=g.getEventManager();this.registerCursor=function(b,d,a){var c=b.getMemberId();b=new gui.Caret(b,k,d,a);n[c]=b;c===g.getInputMemberId()?(runtime.log("Starting to track input on new cursor of "+c),r.subscribe(ops.OdtDocument.signalProcessingBatchEnd, -b.ensureVisible),r.subscribe(ops.Document.signalCursorMoved,b.refreshCursorBlinking),q.subscribe("compositionupdate",b.handleUpdate),q.subscribe("compositionend",b.handleUpdate),q.subscribe("focus",b.setFocus),q.subscribe("blur",b.removeFocus),p.addEventListener("focus",b.show,!1),p.addEventListener("blur",b.hide,!1),b.setOverlayElement(q.getEventTrap())):r.subscribe(ops.OdtDocument.signalProcessingBatchEnd,b.handleUpdate);return b};this.getCaret=d;this.getCarets=b;this.destroy=function(d){var l= -b().map(function(a){return a.destroy});g.getSelectionController().setCaretXPositionLocator(null);r.unsubscribe(ops.Document.signalCursorRemoved,f);n={};core.Async.destroyAll(l,d)};g.getSelectionController().setCaretXPositionLocator(function(){var b=d(g.getInputMemberId()),f;b&&(f=b.getBoundingClientRect());return f?f.right:void 0});r.subscribe(ops.Document.signalCursorRemoved,f)}; -gui.EditInfoHandle=function(g){var k=[],d,b=g.ownerDocument,f=b.documentElement.namespaceURI;this.setEdits=function(g){k=g;var p,r,q,e;core.DomUtils.removeAllChildNodes(d);for(g=0;gc?(r=d(1,0),q=d(.5,1E4-c),e=d(.2,2E4-c)):1E4<=c&&2E4>c?(r=d(.5,0),e=d(.2,2E4-c)):r=d(.2,0)};this.getEdits=function(){return g.getEdits()};this.clearEdits=function(){g.clearEdits(); -n.setEdits([]);p.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&p.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return g};this.show=function(){p.style.display="block"};this.hide=function(){b.hideHandle();p.style.display="none"};this.showHandle=function(){n.show()};this.hideHandle=function(){n.hide()};this.destroy=function(b){runtime.clearTimeout(r);runtime.clearTimeout(q);runtime.clearTimeout(e);f.removeChild(p);n.destroy(function(a){a? -b(a):g.destroy(b)})};(function(){var d=g.getOdtDocument().getDOMDocument();p=d.createElementNS(d.documentElement.namespaceURI,"div");p.setAttribute("class","editInfoMarker");p.onmouseover=function(){b.showHandle()};p.onmouseout=function(){b.hideHandle()};f=g.getNode();f.appendChild(p);n=new gui.EditInfoHandle(f);k||b.hide()})()}; -gui.HyperlinkTooltipView=function(g,k){var d=core.DomUtils,b=odf.OdfUtils,f=runtime.getWindow(),n,p,r;runtime.assert(null!==f,"Expected to be run in an environment which has a global window, like a browser.");this.showTooltip=function(q){var e=q.target||q.srcElement,l=g.getSizer(),a=g.getZoomLevel(),c;a:{for(;e;){if(b.isHyperlink(e))break a;if(b.isParagraph(e)||b.isInlineRoot(e))break;e=e.parentNode}e=null}if(e){d.containsNode(l,r)||l.appendChild(r);c=p;var m;switch(k()){case gui.KeyboardHandler.Modifier.Ctrl:m= -runtime.tr("Ctrl-click to follow link");break;case gui.KeyboardHandler.Modifier.Meta:m=runtime.tr("\u2318-click to follow link");break;default:m=""}c.textContent=m;n.textContent=b.getHyperlinkTarget(e);r.style.display="block";c=f.innerWidth-r.offsetWidth-15;e=q.clientX>c?c:q.clientX+15;c=f.innerHeight-r.offsetHeight-10;q=q.clientY>c?c:q.clientY+10;l=l.getBoundingClientRect();e=(e-l.left)/a;q=(q-l.top)/a;r.style.left=e+"px";r.style.top=q+"px"}};this.hideTooltip=function(){r.style.display="none"};this.destroy= -function(b){r.parentNode&&r.parentNode.removeChild(r);b()};(function(){var b=g.getElement().ownerDocument;n=b.createElement("span");p=b.createElement("span");n.className="webodf-hyperlinkTooltipLink";p.className="webodf-hyperlinkTooltipText";r=b.createElement("div");r.className="webodf-hyperlinkTooltip";r.appendChild(n);r.appendChild(p);g.getElement().appendChild(r)})()}; -gui.OdfFieldView=function(g){function k(){var b=odf.OdfSchema.getFields().map(function(b){return b.replace(":","|")}),d=b.join(",\n")+"\n{ background-color: #D0D0D0; }\n",b=b.map(function(b){return b+":empty::after"}).join(",\n")+"\n{ content:' '; white-space: pre; }\n";return d+"\n"+b}var d,b=g.getElement().ownerDocument;this.showFieldHighlight=function(){d.appendChild(b.createTextNode(k()))};this.hideFieldHighlight=function(){for(var b=d.sheet,g=b.cssRules;g.length;)b.deleteRule(g.length-1)};this.destroy= -function(b){d.parentNode&&d.parentNode.removeChild(d);b()};d=function(){var d=b.getElementsByTagName("head").item(0),g=b.createElement("style"),k="";g.type="text/css";g.media="screen, print, handheld, projection";odf.Namespaces.forEachPrefix(function(b,d){k+="@namespace "+b+" url("+d+");\n"});g.appendChild(b.createTextNode(k));d.appendChild(g);return g}()}; -gui.ShadowCursor=function(g){var k=g.getDOMDocument().createRange(),d=!0;this.removeFromDocument=function(){};this.getMemberId=function(){return gui.ShadowCursor.ShadowCursorMemberId};this.getSelectedRange=function(){return k};this.setSelectedRange=function(b,f){k=b;d=!1!==f};this.hasForwardSelection=function(){return d};this.getDocument=function(){return g};this.getSelectionType=function(){return ops.OdtCursor.RangeSelection};k.setStart(g.getRootNode(),0)};gui.ShadowCursor.ShadowCursorMemberId=""; -gui.SelectionView=function(g){};gui.SelectionView.prototype.rerender=function(){};gui.SelectionView.prototype.show=function(){};gui.SelectionView.prototype.hide=function(){};gui.SelectionView.prototype.destroy=function(g){}; -gui.SelectionViewManager=function(g){function k(){return Object.keys(d).map(function(b){return d[b]})}var d={};this.getSelectionView=function(b){return d.hasOwnProperty(b)?d[b]:null};this.getSelectionViews=k;this.removeSelectionView=function(b){d.hasOwnProperty(b)&&(d[b].destroy(function(){}),delete d[b])};this.hideSelectionView=function(b){d.hasOwnProperty(b)&&d[b].hide()};this.showSelectionView=function(b){d.hasOwnProperty(b)&&d[b].show()};this.rerenderSelectionViews=function(){Object.keys(d).forEach(function(b){d[b].rerender()})}; -this.registerCursor=function(b,f){var k=b.getMemberId(),p=new g(b);f?p.show():p.hide();return d[k]=p};this.destroy=function(b){function d(k,r){r?b(r):k .webodf-draggable"),a=gui.ShadowCursor.ShadowCursorMemberId,e(".webodf-selectionOverlay","{ fill: "+b+"; stroke: "+b+";}",""),e(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"))}function l(a){var c,b;for(b in t)t.hasOwnProperty(b)&&(c=t[b],a?c.show():c.hide())}function a(a){n.getCarets().forEach(function(c){a?c.showHandle():c.hideHandle()})}function c(a){var c=a.getMemberId();a=a.getProperties();e(c,a.fullName,a.color)}function m(a){var c= -a.getMemberId(),d=b.getOdtDocument().getMember(c).getProperties();n.registerCursor(a,E,N);p.registerCursor(a,!0);if(a=n.getCaret(c))a.setAvatarImageUrl(d.imageUrl),a.setColor(d.color);runtime.log("+++ View here +++ eagerly created an Caret for '"+c+"'! +++")}function h(a){a=a.getMemberId();var c=p.getSelectionView(d),b=p.getSelectionView(gui.ShadowCursor.ShadowCursorMemberId),e=n.getCaret(d);a===d?(b.hide(),c&&c.show(),e&&e.show()):a===gui.ShadowCursor.ShadowCursorMemberId&&(b.show(),c&&c.hide(), -e&&e.hide())}function y(a){p.removeSelectionView(a)}function x(a){var c=a.paragraphElement,d=a.memberId;a=a.timeStamp;var e,f="",h=c.getElementsByTagNameNS("urn:webodf:names:editinfo","editinfo").item(0);h?(f=h.getAttributeNS("urn:webodf:names:editinfo","id"),e=t[f]):(f=Math.random().toString(),e=new ops.EditInfo(c,b.getOdtDocument()),e=new gui.EditInfoMarker(e,L),h=c.getElementsByTagNameNS("urn:webodf:names:editinfo","editinfo").item(0),h.setAttributeNS("urn:webodf:names:editinfo","id",f),t[f]=e); -e.addEdit(d,new Date(a));K.trigger()}function z(){var a;u.hasChildNodes()&&core.DomUtils.removeAllChildNodes(u);!0===f.getState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN)&&(a=b.getOdtDocument().getMember(d))&&(a=a.getProperties().fullName,u.appendChild(document.createTextNode(".annotationWrapper:not([creator = '"+a+"']) .annotationRemoveButton { display: none; }")))}function w(a){var b=Object.keys(t).map(function(a){return t[a]});A.unsubscribe(ops.Document.signalMemberAdded,c);A.unsubscribe(ops.Document.signalMemberUpdated, -c);A.unsubscribe(ops.Document.signalCursorAdded,m);A.unsubscribe(ops.Document.signalCursorRemoved,y);A.unsubscribe(ops.OdtDocument.signalParagraphChanged,x);A.unsubscribe(ops.Document.signalCursorMoved,h);A.unsubscribe(ops.OdtDocument.signalParagraphChanged,p.rerenderSelectionViews);A.unsubscribe(ops.OdtDocument.signalTableAdded,p.rerenderSelectionViews);A.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,p.rerenderSelectionViews);f.unsubscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN, -z);A.unsubscribe(ops.Document.signalMemberAdded,z);A.unsubscribe(ops.Document.signalMemberUpdated,z);v.parentNode.removeChild(v);u.parentNode.removeChild(u);(function W(c,d){d?a(d):ca.length;c&&g(a);return c}function d(a,c){function b(e){a[e]===c&&d.push(e)}var d=[];a&&["style:parent-style-name","style:next-style-name"].forEach(b);return d}function b(a,c){function b(d){a[d]===c&&delete a[d]}a&&["style:parent-style-name","style:next-style-name"].forEach(b)}function f(a){var c={};Object.keys(a).forEach(function(b){c[b]="object"===typeof a[b]?f(a[b]):a[b]});return c}function n(a, -c,b,d){var e,f=!1,g=!1,k,l=[];d&&d.attributes&&(l=d.attributes.split(","));a&&(b||0=a.length?0:a.length-e.length)):void 0!==a.length&&(e=a.position+a.length,d<=e?a.length-=c.length:b=c.position+c.length)){d=b?a:c;e=b?c:a;if(a.position!==c.position||a.length!==c.length)n=f(d),r=f(e);c=q(e.setProperties,null,d.setProperties, -null,"style:text-properties");if(c.majorChanged||c.minorChanged)g=[],a=[],k=d.position+d.length,l=e.position+e.length,e.positionk?c.minorChanged&&(n=r,n.position=k,n.length=l-k,a.push(n),e.length=k-e.position):k>l&&c.majorChanged&&(n.position=l, -n.length=k-l,g.push(n),d.length=l-d.position),d.setProperties&&p(d.setProperties)&&g.push(d),e.setProperties&&p(e.setProperties)&&a.push(e),b?(k=g,g=a):k=a}return{opSpecsA:k,opSpecsB:g}},InsertText:function(a,c){c.position<=a.position?a.position+=c.text.length:c.position<=a.position+a.length&&(a.length+=c.text.length);return{opSpecsA:[a],opSpecsB:[c]}},MergeParagraph:function(a,c){var b=a.position,d=a.position+a.length;b>=c.sourceStartPosition&&--b;d>=c.sourceStartPosition&&--d;a.position=b;a.length= -d-b;return{opSpecsA:[a],opSpecsB:[c]}},MoveCursor:e,RemoveAnnotation:function(a,b){var d=a.position,e=a.position+a.length,f=b.position+b.length,g=[a],k=[b];b.position<=d&&e<=f?g=[]:(fb.position?a.position+=b.text.length:d?b.position+=a.text.length:a.position+= -b.text.length;return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){a.position>=b.sourceStartPosition?--a.position:(a.positiona.position&&(b.position+=a.text.length);return{opSpecsA:[a],opSpecsB:[b]}},SplitParagraph:function(a,b){a.position=a.sourceStartPosition&&--f;d>=a.sourceStartPosition&&--d;0<=b.length?(b.position=f,b.length=d-f):(b.position=d,b.length=f-d);return{opSpecsA:[a],opSpecsB:[b]}},RemoveAnnotation:function(a,b){var d=b.position+b.length,e=[a],f=[b];b.position<=a.destinationStartPosition&&a.sourceStartPosition<=d?(e=[],--b.length):a.sourceStartPosition=a.sourceStartPosition?--b.position:(b.positiona.sourceStartPosition)--b.position;else if(b.position===a.destinationStartPosition||b.position===a.sourceStartPosition)b.position=a.destinationStartPosition,a.paragraphStyleName=b.styleName;return{opSpecsA:d,opSpecsB:e}},SplitParagraph:function(a,b){var d,e=[a],f=[b];b.position=a.destinationStartPosition&&b.position=a.sourceStartPosition&&(--b.position,--b.sourceParagraphPosition);return{opSpecsA:e,opSpecsB:f}},UpdateMember:e,UpdateMetadata:e, -UpdateParagraphStyle:e},MoveCursor:{MoveCursor:e,RemoveAnnotation:function(a,b){var d=k(a),e=a.position+a.length,f=b.position+b.length;b.position<=a.position&&e<=f?(a.position=b.position-1,a.length=0):(fb.position?a.position+= -1:a.position===b.sourceParagraphPosition&&(b.paragraphStyleName=a.styleName,g=f(a),g.position=b.position+1,d.push(g));return{opSpecsA:d,opSpecsB:e}},UpdateMember:e,UpdateMetadata:e,UpdateParagraphStyle:e},SplitParagraph:{SplitParagraph:function(a,b,d){var e,f;a.positionn&&(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>2;enc2=(chr1&3)<<4|chr2>>4;enc3=(chr2&15)<<2|chr3>> -6;enc4=chr3&63;if(isNaN(chr2))enc3=enc4=64;else if(isNaN(chr3))enc4=64;output=output+_keyStr.charAt(enc1)+_keyStr.charAt(enc2)+_keyStr.charAt(enc3)+_keyStr.charAt(enc4)}return output};exports.decode=function(input,utf8){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64)output=output+String.fromCharCode(chr2);if(enc4!=64)output=output+String.fromCharCode(chr3)}return output}},{}],2:[function(_dereq_,module,exports){function CompressedObject(){this.compressedSize=0;this.uncompressedSize=0;this.crc32=0;this.compressionMethod=null;this.compressedContent=null}CompressedObject.prototype={getContent:function(){return null},getCompressedContent:function(){return null}}; -module.exports=CompressedObject},{}],3:[function(_dereq_,module,exports){exports.STORE={magic:"\x00\x00",compress:function(content){return content},uncompress:function(content){return content},compressInputType:null,uncompressInputType:null};exports.DEFLATE=_dereq_("./flate")},{"./flate":8}],4:[function(_dereq_,module,exports){var utils=_dereq_("./utils");var table=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021, -3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527, -1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856, -1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626, -1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692, -2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614, -3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];module.exports=function crc32(input,crc){if(typeof input==="undefined"||!input.length)return 0;var isArray=utils.getTypeOf(input)!=="string";if(typeof crc=="undefined")crc=0;var x=0;var y=0;var b=0;crc=crc^-1;for(var i=0,iTop=input.length;i>>8^x}return crc^-1}},{"./utils":21}],5:[function(_dereq_,module,exports){var utils=_dereq_("./utils"); -function DataReader(data){this.data=null;this.length=0;this.index=0}DataReader.prototype={checkOffset:function(offset){this.checkIndex(this.index+offset)},checkIndex:function(newIndex){if(this.length=this.index;i--)result=(result<<8)+this.byteAt(i);this.index+=size;return result},readString:function(size){return utils.transformTo("string",this.readData(size))},readData:function(size){},lastIndexOfSignature:function(sig){},readDate:function(){var dostime=this.readInt(4);return new Date((dostime>>25&127)+1980,(dostime>>21&15)-1,dostime>>16&31,dostime>>11&31,dostime>>5&63,(dostime&31)<<1)}};module.exports=DataReader},{"./utils":21}],6:[function(_dereq_, -module,exports){exports.base64=false;exports.binary=false;exports.dir=false;exports.createFolders=false;exports.date=null;exports.compression=null;exports.comment=null},{}],7:[function(_dereq_,module,exports){var utils=_dereq_("./utils");exports.string2binary=function(str){return utils.string2binary(str)};exports.string2Uint8Array=function(str){return utils.transformTo("uint8array",str)};exports.uint8Array2String=function(array){return utils.transformTo("string",array)};exports.string2Blob=function(str){var buffer= -utils.transformTo("arraybuffer",str);return utils.arrayBuffer2Blob(buffer)};exports.arrayBuffer2Blob=function(buffer){return utils.arrayBuffer2Blob(buffer)};exports.transformTo=function(outputType,input){return utils.transformTo(outputType,input)};exports.getTypeOf=function(input){return utils.getTypeOf(input)};exports.checkSupport=function(type){return utils.checkSupport(type)};exports.MAX_VALUE_16BITS=utils.MAX_VALUE_16BITS;exports.MAX_VALUE_32BITS=utils.MAX_VALUE_32BITS;exports.pretty=function(str){return utils.pretty(str)}; -exports.findCompression=function(compressionMethod){return utils.findCompression(compressionMethod)};exports.isRegExp=function(object){return utils.isRegExp(object)}},{"./utils":21}],8:[function(_dereq_,module,exports){var USE_TYPEDARRAY=typeof Uint8Array!=="undefined"&&typeof Uint16Array!=="undefined"&&typeof Uint32Array!=="undefined";var pako=_dereq_("pako");exports.uncompressInputType=USE_TYPEDARRAY?"uint8array":"array";exports.compressInputType=USE_TYPEDARRAY?"uint8array":"array";exports.magic= -"\b\x00";exports.compress=function(input){return pako.deflateRaw(input)};exports.uncompress=function(input){return pako.inflateRaw(input)}},{"pako":24}],9:[function(_dereq_,module,exports){var base64=_dereq_("./base64");function JSZip(data,options){if(!(this instanceof JSZip))return new JSZip(data,options);this.files={};this.comment=null;this.root="";if(data)this.load(data,options);this.clone=function(){var newObj=new JSZip;for(var i in this)if(typeof this[i]!=="function")newObj[i]=this[i];return newObj}} -JSZip.prototype=_dereq_("./object");JSZip.prototype.load=_dereq_("./load");JSZip.support=_dereq_("./support");JSZip.defaults=_dereq_("./defaults");JSZip.utils=_dereq_("./deprecatedPublicUtils");JSZip.base64={encode:function(input){return base64.encode(input)},decode:function(input){return base64.decode(input)}};JSZip.compressions=_dereq_("./compressions");module.exports=JSZip},{"./base64":1,"./compressions":3,"./defaults":6,"./deprecatedPublicUtils":7,"./load":10,"./object":13,"./support":17}],10:[function(_dereq_, -module,exports){var base64=_dereq_("./base64");var ZipEntries=_dereq_("./zipEntries");module.exports=function(data,options){var files,zipEntries,i,input;options=options||{};if(options.base64)data=base64.decode(data);zipEntries=new ZipEntries(data,options);files=zipEntries.files;for(i=0;i>>8}return hex};var extend=function(){var result={},i,attr;for(i=0;i0?path.substring(0,lastSlash):""};var folderAdd=function(name,createFolders){if(name.slice(-1)!="/")name+="/";createFolders=typeof createFolders!=="undefined"?createFolders:false;if(!this.files[name])fileAdd.call(this,name,null,{dir:true,createFolders:createFolders});return this.files[name]};var generateCompressedObjectFrom=function(file,compression){var result=new CompressedObject,content;if(file._data instanceof -CompressedObject){result.uncompressedSize=file._data.uncompressedSize;result.crc32=file._data.crc32;if(result.uncompressedSize===0||file.dir){compression=compressions["STORE"];result.compressedContent="";result.crc32=0}else if(file._data.compressionMethod===compression.magic)result.compressedContent=file._data.getCompressedContent();else{content=file._data.getContent();result.compressedContent=compression.compress(utils.transformTo(compression.compressInputType,content))}}else{content=getBinaryData(file); -if(!content||content.length===0||file.dir){compression=compressions["STORE"];content=""}result.uncompressedSize=content.length;result.crc32=crc32(content);result.compressedContent=compression.compress(utils.transformTo(compression.compressInputType,content))}result.compressedSize=result.compressedContent.length;result.compressionMethod=compression.magic;return result};var generateZipParts=function(name,file,compressedObject,offset){var data=compressedObject.compressedContent,utfEncodedFileName=utils.transformTo("string", -utf8.utf8encode(file.name)),comment=file.comment||"",utfEncodedComment=utils.transformTo("string",utf8.utf8encode(comment)),useUTF8ForFileName=utfEncodedFileName.length!==file.name.length,useUTF8ForComment=utfEncodedComment.length!==comment.length,o=file.options,dosTime,dosDate,extraFields="",unicodePathExtraField="",unicodeCommentExtraField="",dir,date;if(file._initialMetadata.dir!==file.dir)dir=file.dir;else dir=o.dir;if(file._initialMetadata.date!==file.date)date=file.date;else date=o.date;dosTime= -date.getHours();dosTime=dosTime<<6;dosTime=dosTime|date.getMinutes();dosTime=dosTime<<5;dosTime=dosTime|date.getSeconds()/2;dosDate=date.getFullYear()-1980;dosDate=dosDate<<4;dosDate=dosDate|date.getMonth()+1;dosDate=dosDate<<5;dosDate=dosDate|date.getDate();if(useUTF8ForFileName){unicodePathExtraField=decToHex(1,1)+decToHex(crc32(utfEncodedFileName),4)+utfEncodedFileName;extraFields+="up"+decToHex(unicodePathExtraField.length,2)+unicodePathExtraField}if(useUTF8ForComment){unicodeCommentExtraField= -decToHex(1,1)+decToHex(this.crc32(utfEncodedComment),4)+utfEncodedComment;extraFields+="uc"+decToHex(unicodeCommentExtraField.length,2)+unicodeCommentExtraField}var header="";header+="\n\x00";header+=useUTF8ForFileName||useUTF8ForComment?"\x00\b":"\x00\x00";header+=compressedObject.compressionMethod;header+=decToHex(dosTime,2);header+=decToHex(dosDate,2);header+=decToHex(compressedObject.crc32,4);header+=decToHex(compressedObject.compressedSize,4);header+=decToHex(compressedObject.uncompressedSize, -4);header+=decToHex(utfEncodedFileName.length,2);header+=decToHex(extraFields.length,2);var fileRecord=signature.LOCAL_FILE_HEADER+header+utfEncodedFileName+extraFields;var dirRecord=signature.CENTRAL_FILE_HEADER+"\u0014\x00"+header+decToHex(utfEncodedComment.length,2)+"\x00\x00"+"\x00\x00"+(dir===true?"\u0010\x00\x00\x00":"\x00\x00\x00\x00")+decToHex(offset,4)+utfEncodedFileName+extraFields+utfEncodedComment;return{fileRecord:fileRecord,dirRecord:dirRecord,compressedObject:compressedObject}};var out= -{load:function(stream,options){throw new Error("Load method is not defined. Is the file jszip-load.js included ?");},filter:function(search){var result=[],filename,relativePath,file,fileClone;for(filename in this.files){if(!this.files.hasOwnProperty(filename))continue;file=this.files[filename];fileClone=new ZipObject(file.name,file._data,extend(file.options));relativePath=filename.slice(this.root.length,filename.length);if(filename.slice(0,this.root.length)===this.root&&search(relativePath,fileClone))result.push(fileClone)}return result}, -file:function(name,data,o){if(arguments.length===1)if(utils.isRegExp(name)){var regexp=name;return this.filter(function(relativePath,file){return!file.dir&®exp.test(relativePath)})}else return this.filter(function(relativePath,file){return!file.dir&&relativePath===name})[0]||null;else{name=this.root+name;fileAdd.call(this,name,data,o)}return this},folder:function(arg){if(!arg)return this;if(utils.isRegExp(arg))return this.filter(function(relativePath,file){return file.dir&&arg.test(relativePath)}); -var name=this.root+arg;var newFolder=folderAdd.call(this,name);var ret=this.clone();ret.root=newFolder.name;return ret},remove:function(name){name=this.root+name;var file=this.files[name];if(!file){if(name.slice(-1)!="/")name+="/";file=this.files[name]}if(file&&!file.dir)delete this.files[name];else{var kids=this.filter(function(relativePath,file){return file.name.slice(0,name.length)===name});for(var i=0;i=0;--i)if(this.data[i]===sig0&&this.data[i+1]===sig1&&this.data[i+2]===sig2&&this.data[i+3]===sig3)return i;return-1};Uint8ArrayReader.prototype.readData=function(size){this.checkOffset(size);if(size===0)return new Uint8Array(0);var result=this.data.subarray(this.index, -this.index+size);this.index+=size;return result};module.exports=Uint8ArrayReader},{"./dataReader":5}],19:[function(_dereq_,module,exports){var utils=_dereq_("./utils");var Uint8ArrayWriter=function(length){this.data=new Uint8Array(length);this.index=0};Uint8ArrayWriter.prototype={append:function(input){if(input.length!==0){input=utils.transformTo("uint8array",input);this.data.set(input,this.index);this.index+=input.length}},finalize:function(){return this.data}};module.exports=Uint8ArrayWriter},{"./utils":21}], -20:[function(_dereq_,module,exports){var utils=_dereq_("./utils");var support=_dereq_("./support");var nodeBuffer=_dereq_("./nodeBuffer");var _utf8len=new Array(256);for(var i=0;i<256;i++)_utf8len[i]=i>=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;_utf8len[254]=_utf8len[254]=1;var string2buf=function(str){var buf,c,c2,m_pos,i,str_len=str.length,buf_len=0;for(m_pos=0;m_pos>>6;buf[i++]=128|c&63}else if(c<65536){buf[i++]=224|c>>>12;buf[i++]=128|c>>>6&63;buf[i++]=128|c&63}else{buf[i++]= -240|c>>>18;buf[i++]=128|c>>>12&63;buf[i++]=128|c>>>6&63;buf[i++]=128|c&63}}return buf};var utf8border=function(buf,max){var pos;max=max||buf.length;if(max>buf.length)max=buf.length;pos=max-1;while(pos>=0&&(buf[pos]&192)===128)pos--;if(pos<0)return max;if(pos===0)return max;return pos+_utf8len[buf[pos]]>max?pos:max};var buf2string=function(buf){var str,i,out,c,c_len;var len=buf.length;var utf16buf=new Array(len*2);for(out=0,i=0;i4){utf16buf[out++]=65533;i+=c_len-1;continue}c&=c_len===2?31:c_len===3?15:7;while(c_len>1&&i1){utf16buf[out++]=65533;continue}if(c<65536)utf16buf[out++]=c;else{c-=65536;utf16buf[out++]=55296|c>>10&1023;utf16buf[out++]=56320|c&1023}}if(utf16buf.length!==out)if(utf16buf.subarray)utf16buf=utf16buf.subarray(0,out);else utf16buf.length=out;return utils.applyFromCharCode(utf16buf)};exports.utf8encode=function utf8encode(str){if(support.nodebuffer)return nodeBuffer(str, -"utf-8");return string2buf(str)};exports.utf8decode=function utf8decode(buf){if(support.nodebuffer)return utils.transformTo("nodebuffer",buf).toString("utf-8");buf=utils.transformTo(support.uint8array?"uint8array":"array",buf);var result=[],k=0,len=buf.length,chunk=65536;while(k1)try{if(type==="array"||type==="nodebuffer")result.push(String.fromCharCode.apply(null,array.slice(k,Math.min(k+chunk,len))));else result.push(String.fromCharCode.apply(null, -array.subarray(k,Math.min(k+chunk,len))));k+=chunk}catch(e){chunk=Math.floor(chunk/2)}return result.join("")}exports.applyFromCharCode=arrayLikeToString;function arrayLikeToArrayLike(arrayFrom,arrayTo){for(var i=0;i1)throw new Error("Multi-volumes zip are not supported");},readLocalFiles:function(){var i,file;for(i=0;i0)opt.windowBits=-opt.windowBits;else if(opt.gzip&&opt.windowBits>0&&opt.windowBits<16)opt.windowBits+=16;this.err=0;this.msg="";this.ended=false;this.chunks=[];this.strm=new zstream;this.strm.avail_out=0;var status=zlib_deflate.deflateInit2(this.strm,opt.level,opt.method,opt.windowBits,opt.memLevel,opt.strategy);if(status!==Z_OK)throw new Error(msg[status]); -if(opt.header)zlib_deflate.deflateSetHeader(this.strm,opt.header)};Deflate.prototype.push=function(data,mode){var strm=this.strm;var chunkSize=this.options.chunkSize;var status,_mode;if(this.ended)return false;_mode=mode===~~mode?mode:mode===true?Z_FINISH:Z_NO_FLUSH;if(typeof data==="string")strm.input=strings.string2buf(data);else strm.input=data;strm.next_in=0;strm.avail_in=strm.input.length;do{if(strm.avail_out===0){strm.output=new utils.Buf8(chunkSize);strm.next_out=0;strm.avail_out=chunkSize}status= -zlib_deflate.deflate(strm,_mode);if(status!==Z_STREAM_END&&status!==Z_OK){this.onEnd(status);this.ended=true;return false}if(strm.avail_out===0||strm.avail_in===0&&_mode===Z_FINISH)if(this.options.to==="string")this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output,strm.next_out)));else this.onData(utils.shrinkBuf(strm.output,strm.next_out))}while((strm.avail_in>0||strm.avail_out===0)&&status!==Z_STREAM_END);if(_mode===Z_FINISH){status=zlib_deflate.deflateEnd(this.strm);this.onEnd(status); -this.ended=true;return status===Z_OK}return true};Deflate.prototype.onData=function(chunk){this.chunks.push(chunk)};Deflate.prototype.onEnd=function(status){if(status===Z_OK)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=utils.flattenChunks(this.chunks);this.chunks=[];this.err=status;this.msg=this.strm.msg};function deflate(input,options){var deflator=new Deflate(options);deflator.push(input,true);if(deflator.err)throw deflator.msg;return deflator.result}function deflateRaw(input, -options){options=options||{};options.raw=true;return deflate(input,options)}function gzip(input,options){options=options||{};options.gzip=true;return deflate(input,options)}exports.Deflate=Deflate;exports.deflate=deflate;exports.deflateRaw=deflateRaw;exports.gzip=gzip},{"./utils/common":27,"./utils/strings":28,"./zlib/deflate.js":32,"./zlib/messages":37,"./zlib/zstream":39}],26:[function(_dereq_,module,exports){var zlib_inflate=_dereq_("./zlib/inflate.js");var utils=_dereq_("./utils/common");var strings= -_dereq_("./utils/strings");var c=_dereq_("./zlib/constants");var msg=_dereq_("./zlib/messages");var zstream=_dereq_("./zlib/zstream");var gzheader=_dereq_("./zlib/gzheader");var Inflate=function(options){this.options=utils.assign({chunkSize:16384,windowBits:0,to:""},options||{});var opt=this.options;if(opt.raw&&opt.windowBits>=0&&opt.windowBits<16){opt.windowBits=-opt.windowBits;if(opt.windowBits===0)opt.windowBits=-15}if(opt.windowBits>=0&&opt.windowBits<16&&!(options&&options.windowBits))opt.windowBits+= -32;if(opt.windowBits>15&&opt.windowBits<48)if((opt.windowBits&15)===0)opt.windowBits|=15;this.err=0;this.msg="";this.ended=false;this.chunks=[];this.strm=new zstream;this.strm.avail_out=0;var status=zlib_inflate.inflateInit2(this.strm,opt.windowBits);if(status!==c.Z_OK)throw new Error(msg[status]);this.header=new gzheader;zlib_inflate.inflateGetHeader(this.strm,this.header)};Inflate.prototype.push=function(data,mode){var strm=this.strm;var chunkSize=this.options.chunkSize;var status,_mode;var next_out_utf8, -tail,utf8str;if(this.ended)return false;_mode=mode===~~mode?mode:mode===true?c.Z_FINISH:c.Z_NO_FLUSH;if(typeof data==="string")strm.input=strings.binstring2buf(data);else strm.input=data;strm.next_in=0;strm.avail_in=strm.input.length;do{if(strm.avail_out===0){strm.output=new utils.Buf8(chunkSize);strm.next_out=0;strm.avail_out=chunkSize}status=zlib_inflate.inflate(strm,c.Z_NO_FLUSH);if(status!==c.Z_STREAM_END&&status!==c.Z_OK){this.onEnd(status);this.ended=true;return false}if(strm.next_out)if(strm.avail_out=== -0||status===c.Z_STREAM_END||strm.avail_in===0&&_mode===c.Z_FINISH)if(this.options.to==="string"){next_out_utf8=strings.utf8border(strm.output,strm.next_out);tail=strm.next_out-next_out_utf8;utf8str=strings.buf2string(strm.output,next_out_utf8);strm.next_out=tail;strm.avail_out=chunkSize-tail;if(tail)utils.arraySet(strm.output,strm.output,next_out_utf8,tail,0);this.onData(utf8str)}else this.onData(utils.shrinkBuf(strm.output,strm.next_out))}while(strm.avail_in>0&&status!==c.Z_STREAM_END);if(status=== -c.Z_STREAM_END)_mode=c.Z_FINISH;if(_mode===c.Z_FINISH){status=zlib_inflate.inflateEnd(this.strm);this.onEnd(status);this.ended=true;return status===c.Z_OK}return true};Inflate.prototype.onData=function(chunk){this.chunks.push(chunk)};Inflate.prototype.onEnd=function(status){if(status===c.Z_OK)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=utils.flattenChunks(this.chunks);this.chunks=[];this.err=status;this.msg=this.strm.msg};function inflate(input,options){var inflator= -new Inflate(options);inflator.push(input,true);if(inflator.err)throw inflator.msg;return inflator.result}function inflateRaw(input,options){options=options||{};options.raw=true;return inflate(input,options)}exports.Inflate=Inflate;exports.inflate=inflate;exports.inflateRaw=inflateRaw;exports.ungzip=inflate},{"./utils/common":27,"./utils/strings":28,"./zlib/constants":30,"./zlib/gzheader":33,"./zlib/inflate.js":35,"./zlib/messages":37,"./zlib/zstream":39}],27:[function(_dereq_,module,exports){var TYPED_OK= -typeof Uint8Array!=="undefined"&&typeof Uint16Array!=="undefined"&&typeof Int32Array!=="undefined";exports.assign=function(obj){var sources=Array.prototype.slice.call(arguments,1);while(sources.length){var source=sources.shift();if(!source)continue;if(typeof source!=="object")throw new TypeError(source+"must be non-object");for(var p in source)if(source.hasOwnProperty(p))obj[p]=source[p]}return obj};exports.shrinkBuf=function(buf,size){if(buf.length===size)return buf;if(buf.subarray)return buf.subarray(0, -size);buf.length=size;return buf};var fnTyped={arraySet:function(dest,src,src_offs,len,dest_offs){if(src.subarray&&dest.subarray){dest.set(src.subarray(src_offs,src_offs+len),dest_offs);return}for(var i=0;i=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;_utf8len[254]=_utf8len[254]=1;exports.string2buf=function(str){var buf,c,c2,m_pos,i,str_len=str.length,buf_len=0;for(m_pos=0;m_pos>>6;buf[i++]=128|c&63}else if(c<65536){buf[i++]=224|c>>>12;buf[i++]= -128|c>>>6&63;buf[i++]=128|c&63}else{buf[i++]=240|c>>>18;buf[i++]=128|c>>>12&63;buf[i++]=128|c>>>6&63;buf[i++]=128|c&63}}return buf};function buf2binstring(buf,len){if(len<65537)if(buf.subarray&&STR_APPLY_UIA_OK||!buf.subarray&&STR_APPLY_OK)return String.fromCharCode.apply(null,utils.shrinkBuf(buf,len));var result="";for(var i=0;i4){utf16buf[out++]=65533;i+=c_len-1;continue}c&=c_len===2?31:c_len===3?15:7;while(c_len>1&&i1){utf16buf[out++]=65533;continue}if(c<65536)utf16buf[out++]= -c;else{c-=65536;utf16buf[out++]=55296|c>>10&1023;utf16buf[out++]=56320|c&1023}}return buf2binstring(utf16buf,out)};exports.utf8border=function(buf,max){var pos;max=max||buf.length;if(max>buf.length)max=buf.length;pos=max-1;while(pos>=0&&(buf[pos]&192)===128)pos--;if(pos<0)return max;if(pos===0)return max;return pos+_utf8len[buf[pos]]>max?pos:max}},{"./common":27}],29:[function(_dereq_,module,exports){function adler32(adler,buf,len,pos){var s1=adler&65535|0,s2=adler>>>16&65535|0,n=0;while(len!==0){n= -len>2E3?2E3:len;len-=n;do{s1=s1+buf[pos++]|0;s2=s2+s1|0}while(--n);s1%=65521;s2%=65521}return s1|s2<<16|0}module.exports=adler32},{}],30:[function(_dereq_,module,exports){module.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4, -Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],31:[function(_dereq_,module,exports){function makeTable(){var c,table=[];for(var n=0;n<256;n++){c=n;for(var k=0;k<8;k++)c=c&1?3988292384^c>>>1:c>>>1;table[n]=c}return table}var crcTable=makeTable();function crc32(crc,buf,len,pos){var t=crcTable,end=pos+len;crc=crc^-1;for(var i=pos;i>>8^t[(crc^buf[i])&255];return crc^-1}module.exports=crc32},{}],32:[function(_dereq_,module,exports){var utils=_dereq_("../utils/common"); -var trees=_dereq_("./trees");var adler32=_dereq_("./adler32");var crc32=_dereq_("./crc32");var msg=_dereq_("./messages");var Z_NO_FLUSH=0;var Z_PARTIAL_FLUSH=1;var Z_FULL_FLUSH=3;var Z_FINISH=4;var Z_BLOCK=5;var Z_OK=0;var Z_STREAM_END=1;var Z_STREAM_ERROR=-2;var Z_DATA_ERROR=-3;var Z_BUF_ERROR=-5;var Z_DEFAULT_COMPRESSION=-1;var Z_FILTERED=1;var Z_HUFFMAN_ONLY=2;var Z_RLE=3;var Z_FIXED=4;var Z_DEFAULT_STRATEGY=0;var Z_UNKNOWN=2;var Z_DEFLATED=8;var MAX_MEM_LEVEL=9;var MAX_WBITS=15;var DEF_MEM_LEVEL= -8;var LENGTH_CODES=29;var LITERALS=256;var L_CODES=LITERALS+1+LENGTH_CODES;var D_CODES=30;var BL_CODES=19;var HEAP_SIZE=2*L_CODES+1;var MAX_BITS=15;var MIN_MATCH=3;var MAX_MATCH=258;var MIN_LOOKAHEAD=MAX_MATCH+MIN_MATCH+1;var PRESET_DICT=32;var INIT_STATE=42;var EXTRA_STATE=69;var NAME_STATE=73;var COMMENT_STATE=91;var HCRC_STATE=103;var BUSY_STATE=113;var FINISH_STATE=666;var BS_NEED_MORE=1;var BS_BLOCK_DONE=2;var BS_FINISH_STARTED=3;var BS_FINISH_DONE=4;var OS_CODE=3;function err(strm,errorCode){strm.msg= -msg[errorCode];return errorCode}function rank(f){return(f<<1)-(f>4?9:0)}function zero(buf){var len=buf.length;while(--len>=0)buf[len]=0}function flush_pending(strm){var s=strm.state;var len=s.pending;if(len>strm.avail_out)len=strm.avail_out;if(len===0)return;utils.arraySet(strm.output,s.pending_buf,s.pending_out,len,strm.next_out);strm.next_out+=len;s.pending_out+=len;strm.total_out+=len;strm.avail_out-=len;s.pending-=len;if(s.pending===0)s.pending_out=0}function flush_block_only(s,last){trees._tr_flush_block(s, -s.block_start>=0?s.block_start:-1,s.strstart-s.block_start,last);s.block_start=s.strstart;flush_pending(s.strm)}function put_byte(s,b){s.pending_buf[s.pending++]=b}function putShortMSB(s,b){s.pending_buf[s.pending++]=b>>>8&255;s.pending_buf[s.pending++]=b&255}function read_buf(strm,buf,start,size){var len=strm.avail_in;if(len>size)len=size;if(len===0)return 0;strm.avail_in-=len;utils.arraySet(buf,strm.input,strm.next_in,len,start);if(strm.state.wrap===1)strm.adler=adler32(strm.adler,buf,len,start); -else if(strm.state.wrap===2)strm.adler=crc32(strm.adler,buf,len,start);strm.next_in+=len;strm.total_in+=len;return len}function longest_match(s,cur_match){var chain_length=s.max_chain_length;var scan=s.strstart;var match;var len;var best_len=s.prev_length;var nice_match=s.nice_match;var limit=s.strstart>s.w_size-MIN_LOOKAHEAD?s.strstart-(s.w_size-MIN_LOOKAHEAD):0;var _win=s.window;var wmask=s.w_mask;var prev=s.prev;var strend=s.strstart+MAX_MATCH;var scan_end1=_win[scan+best_len-1];var scan_end=_win[scan+ -best_len];if(s.prev_length>=s.good_match)chain_length>>=2;if(nice_match>s.lookahead)nice_match=s.lookahead;do{match=cur_match;if(_win[match+best_len]!==scan_end||_win[match+best_len-1]!==scan_end1||_win[match]!==_win[scan]||_win[++match]!==_win[scan+1])continue;scan+=2;match++;do;while(_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]=== -_win[++match]&&scanbest_len){s.match_start=cur_match;best_len=len;if(len>=nice_match)break;scan_end1=_win[scan+best_len-1];scan_end=_win[scan+best_len]}}while((cur_match=prev[cur_match&wmask])>limit&&--chain_length!==0);if(best_len<=s.lookahead)return best_len;return s.lookahead}function fill_window(s){var _w_size=s.w_size;var p,n,m,more,str;do{more=s.window_size-s.lookahead-s.strstart;if(s.strstart>=_w_size+(_w_size-MIN_LOOKAHEAD)){utils.arraySet(s.window, -s.window,_w_size,_w_size,0);s.match_start-=_w_size;s.strstart-=_w_size;s.block_start-=_w_size;n=s.hash_size;p=n;do{m=s.head[--p];s.head[p]=m>=_w_size?m-_w_size:0}while(--n);n=_w_size;p=n;do{m=s.prev[--p];s.prev[p]=m>=_w_size?m-_w_size:0}while(--n);more+=_w_size}if(s.strm.avail_in===0)break;n=read_buf(s.strm,s.window,s.strstart+s.lookahead,more);s.lookahead+=n;if(s.lookahead+s.insert>=MIN_MATCH){str=s.strstart-s.insert;s.ins_h=s.window[str];s.ins_h=(s.ins_h<s.pending_buf_size-5)max_block_size=s.pending_buf_size-5;for(;;){if(s.lookahead<=1){fill_window(s);if(s.lookahead===0&&flush===Z_NO_FLUSH)return BS_NEED_MORE;if(s.lookahead=== -0)break}s.strstart+=s.lookahead;s.lookahead=0;var max_start=s.block_start+max_block_size;if(s.strstart===0||s.strstart>=max_start){s.lookahead=s.strstart-max_start;s.strstart=max_start;flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}if(s.strstart-s.block_start>=s.w_size-MIN_LOOKAHEAD){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}}s.insert=0;if(flush===Z_FINISH){flush_block_only(s,true);if(s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.strstart> -s.block_start){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}return BS_NEED_MORE}function deflate_fast(s,flush){var hash_head;var bflush;for(;;){if(s.lookahead=MIN_MATCH){s.ins_h=(s.ins_h<=MIN_MATCH){bflush=trees._tr_tally(s,s.strstart-s.match_start,s.match_length-MIN_MATCH);s.lookahead-=s.match_length;if(s.match_length<=s.max_lazy_match&&s.lookahead>=MIN_MATCH){s.match_length--;do{s.strstart++;s.ins_h=(s.ins_h<=MIN_MATCH){s.ins_h=(s.ins_h<4096))s.match_length=MIN_MATCH-1}if(s.prev_length>=MIN_MATCH&&s.match_length<=s.prev_length){max_insert=s.strstart+s.lookahead-MIN_MATCH;bflush=trees._tr_tally(s,s.strstart-1-s.prev_match,s.prev_length- -MIN_MATCH);s.lookahead-=s.prev_length-1;s.prev_length-=2;do if(++s.strstart<=max_insert){s.ins_h=(s.ins_h<=MIN_MATCH&&s.strstart>0){scan=s.strstart-1;prev=_win[scan];if(prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]){strend=s.strstart+MAX_MATCH;do;while(prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&& -prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&scans.lookahead)s.match_length=s.lookahead}}if(s.match_length>=MIN_MATCH){bflush=trees._tr_tally(s,1,s.match_length-MIN_MATCH);s.lookahead-=s.match_length;s.strstart+=s.match_length;s.match_length=0}else{bflush=trees._tr_tally(s,0,s.window[s.strstart]);s.lookahead--;s.strstart++}if(bflush){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}}s.insert= -0;if(flush===Z_FINISH){flush_block_only(s,true);if(s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.last_lit){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}return BS_BLOCK_DONE}function deflate_huff(s,flush){var bflush;for(;;){if(s.lookahead===0){fill_window(s);if(s.lookahead===0){if(flush===Z_NO_FLUSH)return BS_NEED_MORE;break}}s.match_length=0;bflush=trees._tr_tally(s,0,s.window[s.strstart]);s.lookahead--;s.strstart++;if(bflush){flush_block_only(s, -false);if(s.strm.avail_out===0)return BS_NEED_MORE}}s.insert=0;if(flush===Z_FINISH){flush_block_only(s,true);if(s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.last_lit){flush_block_only(s,false);if(s.strm.avail_out===0)return BS_NEED_MORE}return BS_BLOCK_DONE}var Config=function(good_length,max_lazy,nice_length,max_chain,func){this.good_length=good_length;this.max_lazy=max_lazy;this.nice_length=nice_length;this.max_chain=max_chain;this.func=func};var configuration_table; -configuration_table=[new Config(0,0,0,0,deflate_stored),new Config(4,4,8,4,deflate_fast),new Config(4,5,16,8,deflate_fast),new Config(4,6,32,32,deflate_fast),new Config(4,4,16,16,deflate_slow),new Config(8,16,32,32,deflate_slow),new Config(8,16,128,128,deflate_slow),new Config(8,32,128,256,deflate_slow),new Config(32,128,258,1024,deflate_slow),new Config(32,258,258,4096,deflate_slow)];function lm_init(s){s.window_size=2*s.w_size;zero(s.head);s.max_lazy_match=configuration_table[s.level].max_lazy; -s.good_match=configuration_table[s.level].good_length;s.nice_match=configuration_table[s.level].nice_length;s.max_chain_length=configuration_table[s.level].max_chain;s.strstart=0;s.block_start=0;s.lookahead=0;s.insert=0;s.match_length=s.prev_length=MIN_MATCH-1;s.match_available=0;s.ins_h=0}function DeflateState(){this.strm=null;this.status=0;this.pending_buf=null;this.pending_buf_size=0;this.pending_out=0;this.pending=0;this.wrap=0;this.gzhead=null;this.gzindex=0;this.method=Z_DEFLATED;this.last_flush= --1;this.w_size=0;this.w_bits=0;this.w_mask=0;this.window=null;this.window_size=0;this.prev=null;this.head=null;this.ins_h=0;this.hash_size=0;this.hash_bits=0;this.hash_mask=0;this.hash_shift=0;this.block_start=0;this.match_length=0;this.prev_match=0;this.match_available=0;this.strstart=0;this.match_start=0;this.lookahead=0;this.prev_length=0;this.max_chain_length=0;this.max_lazy_match=0;this.level=0;this.strategy=0;this.good_match=0;this.nice_match=0;this.dyn_ltree=new utils.Buf16(HEAP_SIZE*2);this.dyn_dtree= -new utils.Buf16((2*D_CODES+1)*2);this.bl_tree=new utils.Buf16((2*BL_CODES+1)*2);zero(this.dyn_ltree);zero(this.dyn_dtree);zero(this.bl_tree);this.l_desc=null;this.d_desc=null;this.bl_desc=null;this.bl_count=new utils.Buf16(MAX_BITS+1);this.heap=new utils.Buf16(2*L_CODES+1);zero(this.heap);this.heap_len=0;this.heap_max=0;this.depth=new utils.Buf16(2*L_CODES+1);zero(this.depth);this.l_buf=0;this.lit_bufsize=0;this.last_lit=0;this.d_buf=0;this.opt_len=0;this.static_len=0;this.matches=0;this.insert=0; -this.bi_buf=0;this.bi_valid=0}function deflateResetKeep(strm){var s;if(!strm||!strm.state)return err(strm,Z_STREAM_ERROR);strm.total_in=strm.total_out=0;strm.data_type=Z_UNKNOWN;s=strm.state;s.pending=0;s.pending_out=0;if(s.wrap<0)s.wrap=-s.wrap;s.status=s.wrap?INIT_STATE:BUSY_STATE;strm.adler=s.wrap===2?0:1;s.last_flush=Z_NO_FLUSH;trees._tr_init(s);return Z_OK}function deflateReset(strm){var ret=deflateResetKeep(strm);if(ret===Z_OK)lm_init(strm.state);return ret}function deflateSetHeader(strm,head){if(!strm|| -!strm.state)return Z_STREAM_ERROR;if(strm.state.wrap!==2)return Z_STREAM_ERROR;strm.state.gzhead=head;return Z_OK}function deflateInit2(strm,level,method,windowBits,memLevel,strategy){if(!strm)return Z_STREAM_ERROR;var wrap=1;if(level===Z_DEFAULT_COMPRESSION)level=6;if(windowBits<0){wrap=0;windowBits=-windowBits}else if(windowBits>15){wrap=2;windowBits-=16}if(memLevel<1||memLevel>MAX_MEM_LEVEL||method!==Z_DEFLATED||windowBits<8||windowBits>15||level<0||level>9||strategy<0||strategy>Z_FIXED)return err(strm, -Z_STREAM_ERROR);if(windowBits===8)windowBits=9;var s=new DeflateState;strm.state=s;s.strm=strm;s.wrap=wrap;s.gzhead=null;s.w_bits=windowBits;s.w_size=1<>1;s.l_buf=(1+2)*s.lit_bufsize;s.level=level;s.strategy=strategy;s.method=method;return deflateReset(strm)}function deflateInit(strm,level){return deflateInit2(strm,level,Z_DEFLATED,MAX_WBITS,DEF_MEM_LEVEL,Z_DEFAULT_STRATEGY)}function deflate(strm,flush){var old_flush,s;var beg,val;if(!strm||!strm.state||flush>Z_BLOCK||flush<0)return strm?err(strm,Z_STREAM_ERROR):Z_STREAM_ERROR;s=strm.state;if(!strm.output||!strm.input&&strm.avail_in!==0||s.status===FINISH_STATE&&flush!==Z_FINISH)return err(strm, -strm.avail_out===0?Z_BUF_ERROR:Z_STREAM_ERROR);s.strm=strm;old_flush=s.last_flush;s.last_flush=flush;if(s.status===INIT_STATE)if(s.wrap===2){strm.adler=0;put_byte(s,31);put_byte(s,139);put_byte(s,8);if(!s.gzhead){put_byte(s,0);put_byte(s,0);put_byte(s,0);put_byte(s,0);put_byte(s,0);put_byte(s,s.level===9?2:s.strategy>=Z_HUFFMAN_ONLY||s.level<2?4:0);put_byte(s,OS_CODE);s.status=BUSY_STATE}else{put_byte(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(!s.gzhead.extra?0:4)+(!s.gzhead.name?0:8)+(!s.gzhead.comment? -0:16));put_byte(s,s.gzhead.time&255);put_byte(s,s.gzhead.time>>8&255);put_byte(s,s.gzhead.time>>16&255);put_byte(s,s.gzhead.time>>24&255);put_byte(s,s.level===9?2:s.strategy>=Z_HUFFMAN_ONLY||s.level<2?4:0);put_byte(s,s.gzhead.os&255);if(s.gzhead.extra&&s.gzhead.extra.length){put_byte(s,s.gzhead.extra.length&255);put_byte(s,s.gzhead.extra.length>>8&255)}if(s.gzhead.hcrc)strm.adler=crc32(strm.adler,s.pending_buf,s.pending,0);s.gzindex=0;s.status=EXTRA_STATE}}else{var header=Z_DEFLATED+(s.w_bits-8<< -4)<<8;var level_flags=-1;if(s.strategy>=Z_HUFFMAN_ONLY||s.level<2)level_flags=0;else if(s.level<6)level_flags=1;else if(s.level===6)level_flags=2;else level_flags=3;header|=level_flags<<6;if(s.strstart!==0)header|=PRESET_DICT;header+=31-header%31;s.status=BUSY_STATE;putShortMSB(s,header);if(s.strstart!==0){putShortMSB(s,strm.adler>>>16);putShortMSB(s,strm.adler&65535)}strm.adler=1}if(s.status===EXTRA_STATE)if(s.gzhead.extra){beg=s.pending;while(s.gzindex<(s.gzhead.extra.length&65535)){if(s.pending=== -s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);flush_pending(strm);beg=s.pending;if(s.pending===s.pending_buf_size)break}put_byte(s,s.gzhead.extra[s.gzindex]&255);s.gzindex++}if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(s.gzindex===s.gzhead.extra.length){s.gzindex=0;s.status=NAME_STATE}}else s.status=NAME_STATE;if(s.status===NAME_STATE)if(s.gzhead.name){beg=s.pending;do{if(s.pending=== -s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);flush_pending(strm);beg=s.pending;if(s.pending===s.pending_buf_size){val=1;break}}if(s.gzindexbeg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(val===0){s.gzindex=0;s.status=COMMENT_STATE}}else s.status=COMMENT_STATE;if(s.status===COMMENT_STATE)if(s.gzhead.comment){beg= -s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);flush_pending(strm);beg=s.pending;if(s.pending===s.pending_buf_size){val=1;break}}if(s.gzindexbeg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(val===0)s.status=HCRC_STATE}else s.status=HCRC_STATE;if(s.status=== -HCRC_STATE)if(s.gzhead.hcrc){if(s.pending+2>s.pending_buf_size)flush_pending(strm);if(s.pending+2<=s.pending_buf_size){put_byte(s,strm.adler&255);put_byte(s,strm.adler>>8&255);strm.adler=0;s.status=BUSY_STATE}}else s.status=BUSY_STATE;if(s.pending!==0){flush_pending(strm);if(strm.avail_out===0){s.last_flush=-1;return Z_OK}}else if(strm.avail_in===0&&rank(flush)<=rank(old_flush)&&flush!==Z_FINISH)return err(strm,Z_BUF_ERROR);if(s.status===FINISH_STATE&&strm.avail_in!==0)return err(strm,Z_BUF_ERROR); -if(strm.avail_in!==0||s.lookahead!==0||flush!==Z_NO_FLUSH&&s.status!==FINISH_STATE){var bstate=s.strategy===Z_HUFFMAN_ONLY?deflate_huff(s,flush):s.strategy===Z_RLE?deflate_rle(s,flush):configuration_table[s.level].func(s,flush);if(bstate===BS_FINISH_STARTED||bstate===BS_FINISH_DONE)s.status=FINISH_STATE;if(bstate===BS_NEED_MORE||bstate===BS_FINISH_STARTED){if(strm.avail_out===0)s.last_flush=-1;return Z_OK}if(bstate===BS_BLOCK_DONE){if(flush===Z_PARTIAL_FLUSH)trees._tr_align(s);else if(flush!==Z_BLOCK){trees._tr_stored_block(s, -0,0,false);if(flush===Z_FULL_FLUSH){zero(s.head);if(s.lookahead===0){s.strstart=0;s.block_start=0;s.insert=0}}}flush_pending(strm);if(strm.avail_out===0){s.last_flush=-1;return Z_OK}}}if(flush!==Z_FINISH)return Z_OK;if(s.wrap<=0)return Z_STREAM_END;if(s.wrap===2){put_byte(s,strm.adler&255);put_byte(s,strm.adler>>8&255);put_byte(s,strm.adler>>16&255);put_byte(s,strm.adler>>24&255);put_byte(s,strm.total_in&255);put_byte(s,strm.total_in>>8&255);put_byte(s,strm.total_in>>16&255);put_byte(s,strm.total_in>> -24&255)}else{putShortMSB(s,strm.adler>>>16);putShortMSB(s,strm.adler&65535)}flush_pending(strm);if(s.wrap>0)s.wrap=-s.wrap;return s.pending!==0?Z_OK:Z_STREAM_END}function deflateEnd(strm){var status;if(!strm||!strm.state)return Z_STREAM_ERROR;status=strm.state.status;if(status!==INIT_STATE&&status!==EXTRA_STATE&&status!==NAME_STATE&&status!==COMMENT_STATE&&status!==HCRC_STATE&&status!==BUSY_STATE&&status!==FINISH_STATE)return err(strm,Z_STREAM_ERROR);strm.state=null;return status===BUSY_STATE?err(strm, -Z_DATA_ERROR):Z_OK}exports.deflateInit=deflateInit;exports.deflateInit2=deflateInit2;exports.deflateReset=deflateReset;exports.deflateResetKeep=deflateResetKeep;exports.deflateSetHeader=deflateSetHeader;exports.deflate=deflate;exports.deflateEnd=deflateEnd;exports.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":27,"./adler32":29,"./crc32":31,"./messages":37,"./trees":38}],33:[function(_dereq_,module,exports){function GZheader(){this.text=0;this.time=0;this.xflags=0;this.os=0; -this.extra=null;this.extra_len=0;this.name="";this.comment="";this.hcrc=0;this.done=false}module.exports=GZheader},{}],34:[function(_dereq_,module,exports){var BAD=30;var TYPE=12;module.exports=function inflate_fast(strm,start){var state;var _in;var last;var _out;var beg;var end;var dmax;var wsize;var whave;var wnext;var window;var hold;var bits;var lcode;var dcode;var lmask;var dmask;var here;var op;var len;var dist;var from;var from_source;var input,output;state=strm.state;_in=strm.next_in;input= -strm.input;last=_in+(strm.avail_in-5);_out=strm.next_out;output=strm.output;beg=_out-(start-strm.avail_out);end=_out+(strm.avail_out-257);dmax=state.dmax;wsize=state.wsize;whave=state.whave;wnext=state.wnext;window=state.window;hold=state.hold;bits=state.bits;lcode=state.lencode;dcode=state.distcode;lmask=(1<>>24;hold>>>=op; -bits-=op;op=here>>>16&255;if(op===0)output[_out++]=here&65535;else if(op&16){len=here&65535;op&=15;if(op){if(bits>>=op;bits-=op}if(bits<15){hold+=input[_in++]<>>24;hold>>>=op;bits-=op;op=here>>>16&255;if(op&16){dist=here&65535;op&=15;if(bitsdmax){strm.msg="invalid distance too far back";state.mode=BAD;break top}hold>>>=op;bits-=op;op=_out-beg;if(dist>op){op=dist-op;if(op>whave)if(state.sane){strm.msg="invalid distance too far back";state.mode=BAD;break top}from=0;from_source=window;if(wnext===0){from+=wsize-op;if(op2){output[_out++]=from_source[from++];output[_out++]=from_source[from++];output[_out++]=from_source[from++];len-=3}if(len){output[_out++]=from_source[from++];if(len>1)output[_out++]=from_source[from++]}}else{from=_out-dist;do{output[_out++]=output[from++];output[_out++]= -output[from++];output[_out++]=output[from++];len-=3}while(len>2);if(len){output[_out++]=output[from++];if(len>1)output[_out++]=output[from++]}}}else if((op&64)===0){here=dcode[(here&65535)+(hold&(1<>3;_in-=len;bits-=len<<3;hold&=(1<>>24&255)+(q>>>8&65280)+((q&65280)<<8)+((q&255)<<24)}function InflateState(){this.mode=0;this.last=false;this.wrap=0;this.havedict=false;this.flags=0;this.dmax=0;this.check=0;this.total=0;this.head=null;this.wbits=0;this.wsize=0;this.whave=0;this.wnext=0;this.window=null;this.hold=0;this.bits=0;this.length=0;this.offset= -0;this.extra=0;this.lencode=null;this.distcode=null;this.lenbits=0;this.distbits=0;this.ncode=0;this.nlen=0;this.ndist=0;this.have=0;this.next=null;this.lens=new utils.Buf16(320);this.work=new utils.Buf16(288);this.lendyn=null;this.distdyn=null;this.sane=0;this.back=0;this.was=0}function inflateResetKeep(strm){var state;if(!strm||!strm.state)return Z_STREAM_ERROR;state=strm.state;strm.total_in=strm.total_out=state.total=0;strm.msg="";if(state.wrap)strm.adler=state.wrap&1;state.mode=HEAD;state.last= -0;state.havedict=0;state.dmax=32768;state.head=null;state.hold=0;state.bits=0;state.lencode=state.lendyn=new utils.Buf32(ENOUGH_LENS);state.distcode=state.distdyn=new utils.Buf32(ENOUGH_DISTS);state.sane=1;state.back=-1;return Z_OK}function inflateReset(strm){var state;if(!strm||!strm.state)return Z_STREAM_ERROR;state=strm.state;state.wsize=0;state.whave=0;state.wnext=0;return inflateResetKeep(strm)}function inflateReset2(strm,windowBits){var wrap;var state;if(!strm||!strm.state)return Z_STREAM_ERROR; -state=strm.state;if(windowBits<0){wrap=0;windowBits=-windowBits}else{wrap=(windowBits>>4)+1;if(windowBits<48)windowBits&=15}if(windowBits&&(windowBits<8||windowBits>15))return Z_STREAM_ERROR;if(state.window!==null&&state.wbits!==windowBits)state.window=null;state.wrap=wrap;state.wbits=windowBits;return inflateReset(strm)}function inflateInit2(strm,windowBits){var ret;var state;if(!strm)return Z_STREAM_ERROR;state=new InflateState;strm.state=state;state.window=null;ret=inflateReset2(strm,windowBits); -if(ret!==Z_OK)strm.state=null;return ret}function inflateInit(strm){return inflateInit2(strm,DEF_WBITS)}var virgin=true;var lenfix,distfix;function fixedtables(state){if(virgin){var sym;lenfix=new utils.Buf32(512);distfix=new utils.Buf32(32);sym=0;while(sym<144)state.lens[sym++]=8;while(sym<256)state.lens[sym++]=9;while(sym<280)state.lens[sym++]=7;while(sym<288)state.lens[sym++]=8;inflate_table(LENS,state.lens,0,288,lenfix,0,state.work,{bits:9});sym=0;while(sym<32)state.lens[sym++]=5;inflate_table(DISTS, -state.lens,0,32,distfix,0,state.work,{bits:5});virgin=false}state.lencode=lenfix;state.lenbits=9;state.distcode=distfix;state.distbits=5}function updatewindow(strm,src,end,copy){var dist;var state=strm.state;if(state.window===null){state.wsize=1<=state.wsize){utils.arraySet(state.window,src,end-state.wsize,state.wsize,0);state.wnext=0;state.whave=state.wsize}else{dist=state.wsize-state.wnext;if(dist>copy)dist= -copy;utils.arraySet(state.window,src,end-copy,dist,state.wnext);copy-=dist;if(copy){utils.arraySet(state.window,src,end-copy,copy,0);state.wnext=copy;state.whave=state.wsize}else{state.wnext+=dist;if(state.wnext===state.wsize)state.wnext=0;if(state.whave>>8&255;state.check=crc32(state.check,hbuf,2,0);hold=0;bits=0;state.mode=FLAGS;break}state.flags=0;if(state.head)state.head.done=false;if(!(state.wrap&1)||(((hold&255)<<8)+(hold>>8))%31){strm.msg="incorrect header check";state.mode=BAD;break}if((hold&15)!==Z_DEFLATED){strm.msg="unknown compression method";state.mode= -BAD;break}hold>>>=4;bits-=4;len=(hold&15)+8;if(state.wbits===0)state.wbits=len;else if(len>state.wbits){strm.msg="invalid window size";state.mode=BAD;break}state.dmax=1<>8&1;if(state.flags&512){hbuf[0]=hold&255;hbuf[1]=hold>>>8&255;state.check=crc32(state.check,hbuf,2,0)}hold=0;bits=0;state.mode=TIME;case TIME:while(bits<32){if(have===0)break inf_leave;have--;hold+=input[next++]<>>8&255;hbuf[2]=hold>>>16&255;hbuf[3]=hold>>>24&255;state.check=crc32(state.check,hbuf,4,0)}hold=0;bits=0;state.mode=OS;case OS:while(bits< -16){if(have===0)break inf_leave;have--;hold+=input[next++]<>8}if(state.flags&512){hbuf[0]=hold&255;hbuf[1]=hold>>>8&255;state.check=crc32(state.check,hbuf,2,0)}hold=0;bits=0;state.mode=EXLEN;case EXLEN:if(state.flags&1024){while(bits<16){if(have===0)break inf_leave;have--;hold+=input[next++]<>>8&255;state.check= -crc32(state.check,hbuf,2,0)}hold=0;bits=0}else if(state.head)state.head.extra=null;state.mode=EXTRA;case EXTRA:if(state.flags&1024){copy=state.length;if(copy>have)copy=have;if(copy){if(state.head){len=state.head.extra_len-state.length;if(!state.head.extra)state.head.extra=new Array(state.head.extra_len);utils.arraySet(state.head.extra,input,next,copy,len)}if(state.flags&512)state.check=crc32(state.check,input,copy,next);have-=copy;next+=copy;state.length-=copy}if(state.length)break inf_leave}state.length= -0;state.mode=NAME;case NAME:if(state.flags&2048){if(have===0)break inf_leave;copy=0;do{len=input[next+copy++];if(state.head&&len&&state.length<65536)state.head.name+=String.fromCharCode(len)}while(len&©>9&1;state.head.done=true}strm.adler=state.check=0;state.mode=TYPE;break;case DICTID:while(bits<32){if(have===0)break inf_leave;have--;hold+=input[next++]<>>=bits&7;bits-=bits&7;state.mode=CHECK;break}while(bits<3){if(have===0)break inf_leave;have--;hold+=input[next++]<>>=1;bits-=1;switch(hold&3){case 0:state.mode=STORED;break;case 1:fixedtables(state);state.mode=LEN_;if(flush===Z_TREES){hold>>>=2;bits-=2;break inf_leave}break;case 2:state.mode=TABLE;break;case 3:strm.msg="invalid block type";state.mode=BAD}hold>>>=2;bits-=2;break;case STORED:hold>>>=bits&7;bits-=bits&7;while(bits< -32){if(have===0)break inf_leave;have--;hold+=input[next++]<>>16^65535)){strm.msg="invalid stored block lengths";state.mode=BAD;break}state.length=hold&65535;hold=0;bits=0;state.mode=COPY_;if(flush===Z_TREES)break inf_leave;case COPY_:state.mode=COPY;case COPY:copy=state.length;if(copy){if(copy>have)copy=have;if(copy>left)copy=left;if(copy===0)break inf_leave;utils.arraySet(output,input,next,copy,put);have-=copy;next+=copy;left-=copy;put+=copy;state.length-=copy; -break}state.mode=TYPE;break;case TABLE:while(bits<14){if(have===0)break inf_leave;have--;hold+=input[next++]<>>=5;bits-=5;state.ndist=(hold&31)+1;hold>>>=5;bits-=5;state.ncode=(hold&15)+4;hold>>>=4;bits-=4;if(state.nlen>286||state.ndist>30){strm.msg="too many length or distance symbols";state.mode=BAD;break}state.have=0;state.mode=LENLENS;case LENLENS:while(state.have>>=3;bits-=3}while(state.have<19)state.lens[order[state.have++]]=0;state.lencode=state.lendyn;state.lenbits=7;opts={bits:state.lenbits};ret=inflate_table(CODES,state.lens,0,19,state.lencode,0,state.work,opts);state.lenbits=opts.bits;if(ret){strm.msg="invalid code lengths set";state.mode=BAD;break}state.have=0;state.mode=CODELENS;case CODELENS:while(state.have>>24;here_op=here>>>16&255;here_val=here&65535;if(here_bits<=bits)break;if(have===0)break inf_leave;have--;hold+=input[next++]<>>=here_bits;bits-=here_bits;state.lens[state.have++]=here_val}else{if(here_val===16){n=here_bits+2;while(bits>>=here_bits;bits-=here_bits;if(state.have===0){strm.msg="invalid bit length repeat";state.mode=BAD;break}len=state.lens[state.have-1];copy=3+(hold& -3);hold>>>=2;bits-=2}else if(here_val===17){n=here_bits+3;while(bits>>=here_bits;bits-=here_bits;len=0;copy=3+(hold&7);hold>>>=3;bits-=3}else{n=here_bits+7;while(bits>>=here_bits;bits-=here_bits;len=0;copy=11+(hold&127);hold>>>=7;bits-=7}if(state.have+copy>state.nlen+state.ndist){strm.msg="invalid bit length repeat";state.mode=BAD;break}while(copy--)state.lens[state.have++]= -len}}if(state.mode===BAD)break;if(state.lens[256]===0){strm.msg="invalid code -- missing end-of-block";state.mode=BAD;break}state.lenbits=9;opts={bits:state.lenbits};ret=inflate_table(LENS,state.lens,0,state.nlen,state.lencode,0,state.work,opts);state.lenbits=opts.bits;if(ret){strm.msg="invalid literal/lengths set";state.mode=BAD;break}state.distbits=6;state.distcode=state.distdyn;opts={bits:state.distbits};ret=inflate_table(DISTS,state.lens,state.nlen,state.ndist,state.distcode,0,state.work,opts); -state.distbits=opts.bits;if(ret){strm.msg="invalid distances set";state.mode=BAD;break}state.mode=LEN_;if(flush===Z_TREES)break inf_leave;case LEN_:state.mode=LEN;case LEN:if(have>=6&&left>=258){strm.next_out=put;strm.avail_out=left;strm.next_in=next;strm.avail_in=have;state.hold=hold;state.bits=bits;inflate_fast(strm,_out);put=strm.next_out;output=strm.output;left=strm.avail_out;next=strm.next_in;input=strm.input;have=strm.avail_in;hold=state.hold;bits=state.bits;if(state.mode===TYPE)state.back= --1;break}state.back=0;for(;;){here=state.lencode[hold&(1<>>24;here_op=here>>>16&255;here_val=here&65535;if(here_bits<=bits)break;if(have===0)break inf_leave;have--;hold+=input[next++]<>last_bits)];here_bits=here>>>24;here_op=here>>>16&255;here_val=here&65535;if(last_bits+here_bits<=bits)break;if(have=== -0)break inf_leave;have--;hold+=input[next++]<>>=last_bits;bits-=last_bits;state.back+=last_bits}hold>>>=here_bits;bits-=here_bits;state.back+=here_bits;state.length=here_val;if(here_op===0){state.mode=LIT;break}if(here_op&32){state.back=-1;state.mode=TYPE;break}if(here_op&64){strm.msg="invalid literal/length code";state.mode=BAD;break}state.extra=here_op&15;state.mode=LENEXT;case LENEXT:if(state.extra){n=state.extra;while(bits>>=state.extra;bits-=state.extra;state.back+=state.extra}state.was=state.length;state.mode=DIST;case DIST:for(;;){here=state.distcode[hold&(1<>>24;here_op=here>>>16&255;here_val=here&65535;if(here_bits<=bits)break;if(have===0)break inf_leave;have--;hold+=input[next++]<>last_bits)];here_bits=here>>>24;here_op=here>>>16&255;here_val=here&65535;if(last_bits+here_bits<=bits)break;if(have===0)break inf_leave;have--;hold+=input[next++]<>>=last_bits;bits-=last_bits;state.back+=last_bits}hold>>>=here_bits;bits-=here_bits;state.back+=here_bits;if(here_op&64){strm.msg="invalid distance code";state.mode=BAD;break}state.offset=here_val;state.extra=here_op&15;state.mode=DISTEXT;case DISTEXT:if(state.extra){n=state.extra;while(bits>>=state.extra;bits-=state.extra;state.back+=state.extra}if(state.offset>state.dmax){strm.msg="invalid distance too far back";state.mode=BAD;break}state.mode=MATCH;case MATCH:if(left===0)break inf_leave;copy=_out-left;if(state.offset>copy){copy=state.offset-copy;if(copy>state.whave)if(state.sane){strm.msg="invalid distance too far back";state.mode=BAD;break}if(copy>state.wnext){copy-=state.wnext; -from=state.wsize-copy}else from=state.wnext-copy;if(copy>state.length)copy=state.length;from_source=state.window}else{from_source=output;from=put-state.offset;copy=state.length}if(copy>left)copy=left;left-=copy;state.length-=copy;do output[put++]=from_source[from++];while(--copy);if(state.length===0)state.mode=LEN;break;case LIT:if(left===0)break inf_leave;output[put++]=state.length;left--;state.mode=LEN;break;case CHECK:if(state.wrap){while(bits<32){if(have===0)break inf_leave;have--;hold|=input[next++]<< -bits;bits+=8}_out-=left;strm.total_out+=_out;state.total+=_out;if(_out)strm.adler=state.check=state.flags?crc32(state.check,output,_out,put-_out):adler32(state.check,output,_out,put-_out);_out=left;if((state.flags?hold:ZSWAP32(hold))!==state.check){strm.msg="incorrect data check";state.mode=BAD;break}hold=0;bits=0}state.mode=LENGTH;case LENGTH:if(state.wrap&&state.flags){while(bits<32){if(have===0)break inf_leave;have--;hold+=input[next++]<=1;max--)if(count[max]!==0)break;if(root>max)root=max;if(max===0){table[table_index++]=1<<24|64<<16|0;table[table_index++]= -1<<24|64<<16|0;opts.bits=1;return 0}for(min=1;min0&&(type===CODES||max!==1))return-1;offs[1]=0;for(len=1;lenENOUGH_LENS||type===DISTS&&used>ENOUGH_DISTS)return 1;var i=0;for(;;){i++;here_bits=len-drop;if(work[sym]end){here_op=extra[extra_index+work[sym]];here_val=base[base_index+work[sym]]}else{here_op=32+64;here_val=0}incr=1<>drop)+fill]= -here_bits<<24|here_op<<16|here_val|0}while(fill!==0);incr=1<>=1;if(incr!==0){huff&=incr-1;huff+=incr}else huff=0;sym++;if(--count[len]===0){if(len===max)break;len=lens[lens_index+work[sym]]}if(len>root&&(huff&mask)!==low){if(drop===0)drop=root;next+=min;curr=len-drop;left=1<ENOUGH_LENS||type===DISTS&&used>ENOUGH_DISTS)return 1;low=huff&mask;table[low]=root<< -24|curr<<16|next-table_index|0}}if(huff!==0)table[next+huff]=len-drop<<24|64<<16|0;opts.bits=root;return 0}},{"../utils/common":27}],37:[function(_dereq_,module,exports){module.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],38:[function(_dereq_,module,exports){var utils=_dereq_("../utils/common");var Z_FIXED=4;var Z_BINARY=0;var Z_TEXT=1;var Z_UNKNOWN=2;function zero(buf){var len= -buf.length;while(--len>=0)buf[len]=0}var STORED_BLOCK=0;var STATIC_TREES=1;var DYN_TREES=2;var MIN_MATCH=3;var MAX_MATCH=258;var LENGTH_CODES=29;var LITERALS=256;var L_CODES=LITERALS+1+LENGTH_CODES;var D_CODES=30;var BL_CODES=19;var HEAP_SIZE=2*L_CODES+1;var MAX_BITS=15;var Buf_size=16;var MAX_BL_BITS=7;var END_BLOCK=256;var REP_3_6=16;var REPZ_3_10=17;var REPZ_11_138=18;var extra_lbits=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0];var extra_dbits=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7, -7,8,8,9,9,10,10,11,11,12,12,13,13];var extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];var bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];var DIST_CODE_LEN=512;var static_ltree=new Array((L_CODES+2)*2);zero(static_ltree);var static_dtree=new Array(D_CODES*2);zero(static_dtree);var _dist_code=new Array(DIST_CODE_LEN);zero(_dist_code);var _length_code=new Array(MAX_MATCH-MIN_MATCH+1);zero(_length_code);var base_length=new Array(LENGTH_CODES);zero(base_length);var base_dist=new Array(D_CODES); -zero(base_dist);var StaticTreeDesc=function(static_tree,extra_bits,extra_base,elems,max_length){this.static_tree=static_tree;this.extra_bits=extra_bits;this.extra_base=extra_base;this.elems=elems;this.max_length=max_length;this.has_stree=static_tree&&static_tree.length};var static_l_desc;var static_d_desc;var static_bl_desc;var TreeDesc=function(dyn_tree,stat_desc){this.dyn_tree=dyn_tree;this.max_code=0;this.stat_desc=stat_desc};function d_code(dist){return dist<256?_dist_code[dist]:_dist_code[256+ -(dist>>>7)]}function put_short(s,w){s.pending_buf[s.pending++]=w&255;s.pending_buf[s.pending++]=w>>>8&255}function send_bits(s,value,length){if(s.bi_valid>Buf_size-length){s.bi_buf|=value<>Buf_size-s.bi_valid;s.bi_valid+=length-Buf_size}else{s.bi_buf|=value<>>=1;res<<=1}while(--len>0); -return res>>>1}function bi_flush(s){if(s.bi_valid===16){put_short(s,s.bi_buf);s.bi_buf=0;s.bi_valid=0}else if(s.bi_valid>=8){s.pending_buf[s.pending++]=s.bi_buf&255;s.bi_buf>>=8;s.bi_valid-=8}}function gen_bitlen(s,desc){var tree=desc.dyn_tree;var max_code=desc.max_code;var stree=desc.stat_desc.static_tree;var has_stree=desc.stat_desc.has_stree;var extra=desc.stat_desc.extra_bits;var base=desc.stat_desc.extra_base;var max_length=desc.stat_desc.max_length;var h;var n,m;var bits;var xbits;var f;var overflow= -0;for(bits=0;bits<=MAX_BITS;bits++)s.bl_count[bits]=0;tree[s.heap[s.heap_max]*2+1]=0;for(h=s.heap_max+1;hmax_length){bits=max_length;overflow++}tree[n*2+1]=bits;if(n>max_code)continue;s.bl_count[bits]++;xbits=0;if(n>=base)xbits=extra[n-base];f=tree[n*2];s.opt_len+=f*(bits+xbits);if(has_stree)s.static_len+=f*(stree[n*2+1]+xbits)}if(overflow===0)return;do{bits=max_length-1;while(s.bl_count[bits]===0)bits--;s.bl_count[bits]--;s.bl_count[bits+ -1]+=2;s.bl_count[max_length]--;overflow-=2}while(overflow>0);for(bits=max_length;bits!==0;bits--){n=s.bl_count[bits];while(n!==0){m=s.heap[--h];if(m>max_code)continue;if(tree[m*2+1]!==bits){s.opt_len+=(bits-tree[m*2+1])*tree[m*2];tree[m*2+1]=bits}n--}}}function gen_codes(tree,max_code,bl_count){var next_code=new Array(MAX_BITS+1);var code=0;var bits;var n;for(bits=1;bits<=MAX_BITS;bits++)next_code[bits]=code=code+bl_count[bits-1]<<1;for(n=0;n<=max_code;n++){var len=tree[n*2+1];if(len===0)continue; -tree[n*2]=bi_reverse(next_code[len]++,len)}}function tr_static_init(){var n;var bits;var length;var code;var dist;var bl_count=new Array(MAX_BITS+1);length=0;for(code=0;code>=7;for(;code8)put_short(s,s.bi_buf);else if(s.bi_valid>0)s.pending_buf[s.pending++]= -s.bi_buf;s.bi_buf=0;s.bi_valid=0}function copy_block(s,buf,len,header){bi_windup(s);if(header){put_short(s,len);put_short(s,~len)}utils.arraySet(s.pending_buf,s.window,buf,len,s.pending);s.pending+=len}function smaller(tree,n,m,depth){var _n2=n*2;var _m2=m*2;return tree[_n2]>1;n>=1;n--)pqdownheap(s,tree,n);node=elems;do{n=s.heap[1];s.heap[1]=s.heap[s.heap_len--];pqdownheap(s,tree,1);m=s.heap[1];s.heap[--s.heap_max]=n;s.heap[--s.heap_max]=m;tree[node*2]=tree[n*2]+tree[m*2];s.depth[node]=(s.depth[n]>=s.depth[m]?s.depth[n]:s.depth[m])+1;tree[n*2+1]=tree[m*2+1]=node;s.heap[1]=node++;pqdownheap(s,tree,1)}while(s.heap_len>=2);s.heap[--s.heap_max]=s.heap[1];gen_bitlen(s, -desc);gen_codes(tree,max_code,s.bl_count)}function scan_tree(s,tree,max_code){var n;var prevlen=-1;var curlen;var nextlen=tree[0*2+1];var count=0;var max_count=7;var min_count=4;if(nextlen===0){max_count=138;min_count=3}tree[(max_code+1)*2+1]=65535;for(n=0;n<=max_code;n++){curlen=nextlen;nextlen=tree[(n+1)*2+1];if(++count=3;max_blindex--)if(s.bl_tree[bl_order[max_blindex]*2+1]!==0)break;s.opt_len+=3*(max_blindex+1)+5+5+4;return max_blindex}function send_all_trees(s,lcodes,dcodes,blcodes){var rank;send_bits(s,lcodes-257,5);send_bits(s,dcodes-1,5);send_bits(s,blcodes-4,4);for(rank=0;rank>>=1)if(black_mask&1&&s.dyn_ltree[n*2]!==0)return Z_BINARY;if(s.dyn_ltree[9*2]!==0||s.dyn_ltree[10*2]!==0||s.dyn_ltree[13*2]!==0)return Z_TEXT;for(n=32;n0){if(s.strm.data_type===Z_UNKNOWN)s.strm.data_type= -detect_data_type(s);build_tree(s,s.l_desc);build_tree(s,s.d_desc);max_blindex=build_bl_tree(s);opt_lenb=s.opt_len+3+7>>>3;static_lenb=s.static_len+3+7>>>3;if(static_lenb<=opt_lenb)opt_lenb=static_lenb}else opt_lenb=static_lenb=stored_len+5;if(stored_len+4<=opt_lenb&&buf!==-1)_tr_stored_block(s,buf,stored_len,last);else if(s.strategy===Z_FIXED||static_lenb===opt_lenb){send_bits(s,(STATIC_TREES<<1)+(last?1:0),3);compress_block(s,static_ltree,static_dtree)}else{send_bits(s,(DYN_TREES<<1)+(last?1:0), -3);send_all_trees(s,s.l_desc.max_code+1,s.d_desc.max_code+1,max_blindex+1);compress_block(s,s.dyn_ltree,s.dyn_dtree)}init_block(s);if(last)bi_windup(s)}function _tr_tally(s,dist,lc){s.pending_buf[s.d_buf+s.last_lit*2]=dist>>>8&255;s.pending_buf[s.d_buf+s.last_lit*2+1]=dist&255;s.pending_buf[s.l_buf+s.last_lit]=lc&255;s.last_lit++;if(dist===0)s.dyn_ltree[lc*2]++;else{s.matches++;dist--;s.dyn_ltree[(_length_code[lc]+LITERALS+1)*2]++;s.dyn_dtree[d_code(dist)*2]++}return s.last_lit===s.lit_bufsize-1} -exports._tr_init=_tr_init;exports._tr_stored_block=_tr_stored_block;exports._tr_flush_block=_tr_flush_block;exports._tr_tally=_tr_tally;exports._tr_align=_tr_align},{"../utils/common":27}],39:[function(_dereq_,module,exports){function ZStream(){this.input=null;this.next_in=0;this.avail_in=0;this.total_in=0;this.output=null;this.next_out=0;this.avail_out=0;this.total_out=0;this.msg="";this.state=null;this.data_type=2;this.adler=0}module.exports=ZStream},{}]},{},[9])(9)}); - +*/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 * @@ -2244,641 +78,4 @@ exports._tr_init=_tr_init;exports._tr_stored_block=_tr_stored_block;exports._tr_ * @source: http://www.webodf.org/ * @source: https://github.com/kogmbh/WebODF/ */ - -/*global runtime, define, document, core, odf, gui, ops*/ - -/*define("webodf/editor/EditorSession", [ - "dojo/text!resources/fonts/fonts.css" -],*/ -this.OS.APP.OpenPage.EditorSession = (function (fontsCSS) { // fontsCSS is retrieved as a string, using dojo's text retrieval AMD plugin - "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"); - - /** - * Instantiate a new editor session attached to an existing operation session - * @constructor - * @implements {core.EventSource} - * @param {!ops.Session} session - * @param {!string} localMemberId - * @param {{viewOptions:gui.SessionViewOptions,directParagraphStylingEnabled:boolean,annotationsEnabled:boolean}} config - */ - var EditorSession = function EditorSession(session, localMemberId, config) { - var self = this, - currentParagraphNode = null, - currentCommonStyleName = null, - currentStyleName = null, - caretManager, - selectionViewManager, - hyperlinkTooltipView, - odtDocument = session.getOdtDocument(), - textns = odf.Namespaces.textns, - fontStyles = document.createElement('style'), - formatting = odtDocument.getFormatting(), - domUtils = core.DomUtils, - odfUtils = odf.OdfUtils, - odfFieldView, - eventNotifier = new core.EventNotifier([ - EditorSession.signalMemberAdded, - EditorSession.signalMemberUpdated, - EditorSession.signalMemberRemoved, - EditorSession.signalCursorAdded, - EditorSession.signalCursorMoved, - EditorSession.signalCursorRemoved, - EditorSession.signalParagraphChanged, - EditorSession.signalCommonStyleCreated, - EditorSession.signalCommonStyleDeleted, - EditorSession.signalParagraphStyleModified, - EditorSession.signalUndoStackChanged]), - shadowCursor = new gui.ShadowCursor(odtDocument), - sessionConstraints, - /**@const*/ - NEXT = core.StepDirection.NEXT; - - /** - * @return {Array.} - */ - function getAvailableFonts() { - var availableFonts, regex, matches; - - availableFonts = {}; - - /*jslint regexp: true*/ - regex = /font-family *: *(?:\'([^']*)\'|\"([^"]*)\")/gm; - /*jslint regexp: false*/ - matches = regex.exec(fontsCSS); - - while (matches) { - availableFonts[matches[1] || matches[2]] = 1; - matches = regex.exec(fontsCSS); - } - availableFonts = Object.keys(availableFonts); - - return availableFonts; - } - - function checkParagraphStyleName() { - var newStyleName, - newCommonStyleName; - - newStyleName = currentParagraphNode.getAttributeNS(textns, 'style-name'); - - if (newStyleName !== currentStyleName) { - currentStyleName = newStyleName; - // check if common style is still the same - newCommonStyleName = formatting.getFirstCommonParentStyleNameOrSelf(newStyleName); - if (!newCommonStyleName) { - // Default style, empty-string name - currentCommonStyleName = newStyleName = currentStyleName = ""; - self.emit(EditorSession.signalParagraphChanged, { - type: 'style', - node: currentParagraphNode, - styleName: currentCommonStyleName - }); - return; - } - // a common style - if (newCommonStyleName !== currentCommonStyleName) { - currentCommonStyleName = newCommonStyleName; - self.emit(EditorSession.signalParagraphChanged, { - type: 'style', - node: currentParagraphNode, - styleName: currentCommonStyleName - }); - } - } - } - /** - * Creates a NCName from the passed string - * @param {!string} name - * @return {!string} - */ - function createNCName(name) { - var letter, - result = "", - i; - - // encode - for (i = 0; i < name.length; i += 1) { - letter = name[i]; - // simple approach, can be improved to not skip other allowed chars - if (letter.match(/[a-zA-Z0-9.-_]/) !== null) { - result += letter; - } else { - result += "_" + letter.charCodeAt(0).toString(16) + "_"; - } - } - // ensure leading char is from proper range - if (result.match(/^[a-zA-Z_]/) === null) { - result = "_" + result; - } - - return result; - } - - function uniqueParagraphStyleNCName(name) { - var result, - i = 0, - ncMemberId = createNCName(localMemberId), - ncName = createNCName(name); - - // create default paragraph style - // localMemberId is used to avoid id conflicts with ids created by other members - result = ncName + "_" + ncMemberId; - // then loop until result is really unique - while (formatting.hasParagraphStyle(result)) { - result = ncName + "_" + i + "_" + ncMemberId; - i += 1; - } - - return result; - } - - function trackCursor(cursor) { - var node; - - node = odfUtils.getParagraphElement(cursor.getNode()); - if (!node) { - return; - } - currentParagraphNode = node; - checkParagraphStyleName(); - } - - function trackCurrentParagraph(info) { - var cursor = odtDocument.getCursor(localMemberId), - range = cursor && cursor.getSelectedRange(), - paragraphRange = odtDocument.getDOMDocument().createRange(); - paragraphRange.selectNode(info.paragraphElement); - if ((range && domUtils.rangesIntersect(range, paragraphRange)) || info.paragraphElement === currentParagraphNode) { - self.emit(EditorSession.signalParagraphChanged, info); - checkParagraphStyleName(); - } - paragraphRange.detach(); - } - - function onMemberAdded(member) { - self.emit(EditorSession.signalMemberAdded, member.getMemberId()); - } - - function onMemberUpdated(member) { - self.emit(EditorSession.signalMemberUpdated, member.getMemberId()); - } - - function onMemberRemoved(memberId) { - self.emit(EditorSession.signalMemberRemoved, memberId); - } - - function onCursorAdded(cursor) { - self.emit(EditorSession.signalCursorAdded, cursor.getMemberId()); - trackCursor(cursor); - } - - function onCursorRemoved(memberId) { - self.emit(EditorSession.signalCursorRemoved, memberId); - } - - function onCursorMoved(cursor) { - // Emit 'cursorMoved' only when *I* am moving the cursor, not the other users - if (cursor.getMemberId() === localMemberId) { - self.emit(EditorSession.signalCursorMoved, cursor); - trackCursor(cursor); - } - } - - function onStyleCreated(newStyleName) { - self.emit(EditorSession.signalCommonStyleCreated, newStyleName); - } - - function onStyleDeleted(styleName) { - self.emit(EditorSession.signalCommonStyleDeleted, styleName); - } - - function onParagraphStyleModified(styleName) { - self.emit(EditorSession.signalParagraphStyleModified, styleName); - } - - /** - * Call all subscribers for the given event with the specified argument - * @param {!string} eventid - * @param {Object} args - */ - this.emit = function (eventid, args) { - eventNotifier.emit(eventid, args); - }; - - /** - * Subscribe to a given event with a callback - * @param {!string} eventid - * @param {!Function} cb - */ - this.subscribe = function (eventid, cb) { - eventNotifier.subscribe(eventid, cb); - }; - - /** - * @param {!string} eventid - * @param {!Function} cb - * @return {undefined} - */ - this.unsubscribe = function (eventid, cb) { - eventNotifier.unsubscribe(eventid, cb); - }; - - this.getCursorPosition = function () { - return odtDocument.getCursorPosition(localMemberId); - }; - - this.getCursorSelection = function () { - return odtDocument.getCursorSelection(localMemberId); - }; - - this.getOdfCanvas = function () { - return odtDocument.getOdfCanvas(); - }; - - this.getCurrentParagraph = function () { - return currentParagraphNode; - }; - - this.getAvailableParagraphStyles = function () { - return formatting.getAvailableParagraphStyles(); - }; - - this.getCurrentParagraphStyle = function () { - return currentCommonStyleName; - }; - - /** - * Applies the paragraph style with the given - * style name to all the paragraphs within - * the cursor selection. - * @param {!string} styleName - * @return {undefined} - */ - this.setCurrentParagraphStyle = function (styleName) { - var range = odtDocument.getCursor(localMemberId).getSelectedRange(), - paragraphs = odfUtils.getParagraphElements(range), - opQueue = []; - - paragraphs.forEach(function (paragraph) { - var paragraphStartPoint = odtDocument.convertDomPointToCursorStep(paragraph, 0, NEXT), - paragraphStyleName = paragraph.getAttributeNS(odf.Namespaces.textns, "style-name"), - opSetParagraphStyle; - - if (paragraphStyleName !== styleName) { - opSetParagraphStyle = new ops.OpSetParagraphStyle(); - opSetParagraphStyle.init({ - memberid: localMemberId, - styleName: styleName, - position: paragraphStartPoint - }); - opQueue.push(opSetParagraphStyle); - } - }); - - if (opQueue.length > 0) { - session.enqueue(opQueue); - } - }; - - this.insertTable = function (initialRows, initialColumns, tableStyleName, tableColumnStyleName, tableCellStyleMatrix) { - var op = new ops.OpInsertTable(); - op.init({ - memberid: localMemberId, - position: self.getCursorPosition(), - initialRows: initialRows, - initialColumns: initialColumns, - tableStyleName: tableStyleName, - tableColumnStyleName: tableColumnStyleName, - tableCellStyleMatrix: tableCellStyleMatrix - }); - session.enqueue([op]); - }; - - /** - * Takes a style name and returns the corresponding paragraph style - * element. If the style name is an empty string, the default style - * is returned. - * @param {!string} styleName - * @return {?Element} - */ - function getParagraphStyleElement(styleName) { - return (styleName === "") - ? formatting.getDefaultStyleElement('paragraph') - : formatting.getStyleElement(styleName, 'paragraph'); - } - - this.getParagraphStyleElement = getParagraphStyleElement; - - /** - * Returns if the style is used anywhere in the document - * @param {!Element} styleElement - * @return {boolean} - */ - this.isStyleUsed = function (styleElement) { - return formatting.isStyleUsed(styleElement); - }; - - /** - * Returns the attributes of a given paragraph style name - * (with inheritance). If the name is an empty string, - * the attributes of the default style are returned. - * @param {!string} styleName - * @return {?odf.Formatting.StyleData} - */ - this.getParagraphStyleAttributes = function (styleName) { - var styleNode = getParagraphStyleElement(styleName), - includeSystemDefault = styleName === ""; - - if (styleNode) { - return formatting.getInheritedStyleAttributes(styleNode, includeSystemDefault); - } - - return null; - }; - - /** - * Creates and enqueues a paragraph-style cloning operation. - * Returns the created id for the new style. - * @param {!string} styleName id of the style to update - * @param {!{paragraphProperties,textProperties}} setProperties properties which are set - * @param {!{paragraphPropertyNames,textPropertyNames}=} removedProperties properties which are removed - * @return {undefined} - */ - this.updateParagraphStyle = function (styleName, setProperties, removedProperties) { - var op; - op = new ops.OpUpdateParagraphStyle(); - op.init({ - memberid: localMemberId, - styleName: styleName, - setProperties: setProperties, - removedProperties: (!removedProperties) ? {} : removedProperties - }); - session.enqueue([op]); - }; - - /** - * Creates and enqueues a paragraph-style cloning operation. - * Returns the created id for the new style. - * @param {!string} styleName id of the style to clone - * @param {!string} newStyleDisplayName display name of the new style - * @return {!string} - */ - this.cloneParagraphStyle = function (styleName, newStyleDisplayName) { - var newStyleName = uniqueParagraphStyleNCName(newStyleDisplayName), - styleNode = getParagraphStyleElement(styleName), - op, setProperties, attributes, i; - - setProperties = formatting.getStyleAttributes(styleNode); - // copy any attributes directly on the style - attributes = styleNode.attributes; - for (i = 0; i < attributes.length; i += 1) { - // skip... - // * style:display-name -> not copied, set to new string below - // * style:name -> not copied, set from op by styleName property - // * style:family -> "paragraph" always, set by op - if (!/^(style:display-name|style:name|style:family)/.test(attributes[i].name)) { - setProperties[attributes[i].name] = attributes[i].value; - } - } - - setProperties['style:display-name'] = newStyleDisplayName; - - op = new ops.OpAddStyle(); - op.init({ - memberid: localMemberId, - styleName: newStyleName, - styleFamily: 'paragraph', - setProperties: setProperties - }); - session.enqueue([op]); - - return newStyleName; - }; - - this.deleteStyle = function (styleName) { - var op; - op = new ops.OpRemoveStyle(); - op.init({ - memberid: localMemberId, - styleName: styleName, - styleFamily: 'paragraph' - }); - session.enqueue([op]); - }; - - /** - * Returns an array of the declared fonts in the ODF document, - * with 'duplicates' like Arial1, Arial2, etc removed. The alphabetically - * first font name for any given family is kept. - * The elements of the array are objects containing the font's name and - * the family. - * @return {Array.} - */ - this.getDeclaredFonts = function () { - var fontMap = formatting.getFontMap(), - usedFamilies = [], - array = [], - sortedNames, - key, - value, - i; - - // Sort all the keys in the font map alphabetically - sortedNames = Object.keys(fontMap); - sortedNames.sort(); - - for (i = 0; i < sortedNames.length; i += 1) { - key = sortedNames[i]; - value = fontMap[key]; - - // Use the font declaration only if the family is not already used. - // Therefore we are able to discard the alphabetic successors of the first - // font name. - if (usedFamilies.indexOf(value) === -1) { - array.push({ - name: key, - family: value - }); - if (value) { - usedFamilies.push(value); - } - } - } - - return array; - }; - - this.getSelectedHyperlinks = function () { - var cursor = odtDocument.getCursor(localMemberId); - // no own cursor yet/currently added? - if (!cursor) { - return []; - } - return odfUtils.getHyperlinkElements(cursor.getSelectedRange()); - }; - - this.getSelectedRange = function () { - var cursor = odtDocument.getCursor(localMemberId); - return cursor && cursor.getSelectedRange(); - }; - - function undoStackModified(e) { - self.emit(EditorSession.signalUndoStackChanged, e); - } - - this.undo = function () { - self.sessionController.undo(); - }; - - this.redo = function () { - self.sessionController.redo(); - }; - - /** - * @param {!string} memberId - * @return {?ops.Member} - */ - this.getMember = function (memberId) { - return odtDocument.getMember(memberId); - }; - - /** - * @param {!function(!Object=)} callback passing an error object in case of error - * @return {undefined} - */ - function destroy(callback) { - var head = document.getElementsByTagName('head')[0], - eventManager = self.sessionController.getEventManager(); - - head.removeChild(fontStyles); - - odtDocument.unsubscribe(ops.Document.signalMemberAdded, onMemberAdded); - odtDocument.unsubscribe(ops.Document.signalMemberUpdated, onMemberUpdated); - odtDocument.unsubscribe(ops.Document.signalMemberRemoved, onMemberRemoved); - odtDocument.unsubscribe(ops.Document.signalCursorAdded, onCursorAdded); - odtDocument.unsubscribe(ops.Document.signalCursorRemoved, onCursorRemoved); - odtDocument.unsubscribe(ops.Document.signalCursorMoved, onCursorMoved); - odtDocument.unsubscribe(ops.OdtDocument.signalCommonStyleCreated, onStyleCreated); - odtDocument.unsubscribe(ops.OdtDocument.signalCommonStyleDeleted, onStyleDeleted); - odtDocument.unsubscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified); - odtDocument.unsubscribe(ops.OdtDocument.signalParagraphChanged, trackCurrentParagraph); - odtDocument.unsubscribe(ops.OdtDocument.signalUndoStackChanged, undoStackModified); - - eventManager.unsubscribe("mousemove", hyperlinkTooltipView.showTooltip); - eventManager.unsubscribe("mouseout", hyperlinkTooltipView.hideTooltip); - delete self.sessionView; - delete self.sessionController; - callback(); - } - - /** - * @param {!function(!Error=)} callback passing an error object in case of error - * @return {undefined} - */ - this.destroy = function(callback) { - var cleanup = [ - self.sessionView.destroy, - caretManager.destroy, - selectionViewManager.destroy, - self.sessionController.destroy, - hyperlinkTooltipView.destroy, - odfFieldView.destroy, - destroy - ]; - - core.Async.destroyAll(cleanup, callback); - }; - - function init() { - var head = document.getElementsByTagName('head')[0], - odfCanvas = session.getOdtDocument().getOdfCanvas(), - eventManager; - - // TODO: fonts.css should be rather done by odfCanvas, or? - fontStyles.type = 'text/css'; - fontStyles.media = 'screen, print, handheld, projection'; - fontStyles.appendChild(document.createTextNode(fontsCSS)); - head.appendChild(fontStyles); - - odfFieldView = new gui.OdfFieldView(odfCanvas); - odfFieldView.showFieldHighlight(); - self.sessionController = new gui.SessionController(session, localMemberId, shadowCursor, { - annotationsEnabled: config.annotationsEnabled, - directTextStylingEnabled: config.directTextStylingEnabled, - directParagraphStylingEnabled: config.directParagraphStylingEnabled - }); - sessionConstraints = self.sessionController.getSessionConstraints(); - - eventManager = self.sessionController.getEventManager(); - hyperlinkTooltipView = new gui.HyperlinkTooltipView(odfCanvas, - self.sessionController.getHyperlinkClickHandler().getModifier); - eventManager.subscribe("mousemove", hyperlinkTooltipView.showTooltip); - eventManager.subscribe("mouseout", hyperlinkTooltipView.hideTooltip); - - caretManager = new gui.CaretManager(self.sessionController, odfCanvas.getViewport()); - selectionViewManager = new gui.SelectionViewManager(gui.SvgSelectionView); - self.sessionView = new gui.SessionView(config.viewOptions, localMemberId, session, sessionConstraints, caretManager, selectionViewManager); - self.availableFonts = getAvailableFonts(); - selectionViewManager.registerCursor(shadowCursor, true); - - // Session Constraints can be applied once the controllers are instantiated. - if (config.reviewModeEnabled) { - // Disallow deleting other authors' annotations. - sessionConstraints.setState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN, true); - sessionConstraints.setState(gui.CommonConstraints.EDIT.REVIEW_MODE, true); - } - - // Custom signals, that make sense in the Editor context. We do not want to expose webodf's ops signals to random bits of the editor UI. - odtDocument.subscribe(ops.Document.signalMemberAdded, onMemberAdded); - odtDocument.subscribe(ops.Document.signalMemberUpdated, onMemberUpdated); - odtDocument.subscribe(ops.Document.signalMemberRemoved, onMemberRemoved); - odtDocument.subscribe(ops.Document.signalCursorAdded, onCursorAdded); - odtDocument.subscribe(ops.Document.signalCursorRemoved, onCursorRemoved); - odtDocument.subscribe(ops.Document.signalCursorMoved, onCursorMoved); - odtDocument.subscribe(ops.OdtDocument.signalCommonStyleCreated, onStyleCreated); - odtDocument.subscribe(ops.OdtDocument.signalCommonStyleDeleted, onStyleDeleted); - odtDocument.subscribe(ops.OdtDocument.signalParagraphStyleModified, onParagraphStyleModified); - odtDocument.subscribe(ops.OdtDocument.signalParagraphChanged, trackCurrentParagraph); - odtDocument.subscribe(ops.OdtDocument.signalUndoStackChanged, undoStackModified); - } - - init(); - }; - - /**@const*/EditorSession.signalMemberAdded = "memberAdded"; - /**@const*/EditorSession.signalMemberUpdated = "memberUpdated"; - /**@const*/EditorSession.signalMemberRemoved = "memberRemoved"; - /**@const*/EditorSession.signalCursorAdded = "cursorAdded"; - /**@const*/EditorSession.signalCursorRemoved = "cursorRemoved"; - /**@const*/EditorSession.signalCursorMoved = "cursorMoved"; - /**@const*/EditorSession.signalParagraphChanged = "paragraphChanged"; - /**@const*/EditorSession.signalCommonStyleCreated = "styleCreated"; - /**@const*/EditorSession.signalCommonStyleDeleted = "styleDeleted"; - /**@const*/EditorSession.signalParagraphStyleModified = "paragraphStyleModified"; - /**@const*/EditorSession.signalUndoStackChanged = "signalUndoStackChanged"; - - return EditorSession; -})(""); - +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
- +
diff --git a/OpenPage/build/release/OpenPage.zip b/OpenPage/build/release/OpenPage.zip new file mode 100644 index 0000000..9c51df2 Binary files /dev/null and b/OpenPage/build/release/OpenPage.zip differ diff --git a/OpenPage/coffees/dialogs.coffee b/OpenPage/coffees/dialogs.coffee index e8f155b..eca18c1 100644 --- a/OpenPage/coffees/dialogs.coffee +++ b/OpenPage/coffees/dialogs.coffee @@ -1,43 +1,60 @@ class HyperLinkDialog extends this.OS.GUI.BasicDialog constructor: () -> - super "HyperLinkDialog", { - tags: [ - { tag: "afx-label", att: 'text="__(Text)" data-height="23" class="header"' }, - { tag: "input", att: 'data-height="30"' }, - { tag: "afx-label", att: 'text="__(Link)" data-height="23" class="header"' }, - { tag: "input", att: 'data-height="30"' }, - { tag: "div", att: ' data-height="5"' } - ], - width: 350, - height: 150, - resizable: false, - buttons: [ - { - label: "Ok", onclick: (d) -> - data = - text: (d.find "content1").value, - link: (d.find "content3").value, - readonly: d.data.readonly, - action: d.data.action - d.handler data if d.handler - d.quit() - }, - { label: "__(Cancel)", onclick: (d) -> d.quit() } - ], - filldata: (d) -> - return unless d.data - (d.find "content1").value = d.data.text - (d.find "content3").value = d.data.link - $(d.find "content1").prop('disabled', d.data.readonly) - } - -class FormatDialog extends this.OS.GUI.BaseDialog - constructor: () -> - super "FormatDialog" - init: () -> - @_gui.htmlToScheme FormatDialog.scheme, @, @host + super "HyperLinkDialog", HyperLinkDialog.scheme + main: () -> + super.main() + txtText = @find "txtText" + txtLink = @find "txtLink" + if @data and @data.data + txtText.value = @data.data.text + txtLink.value = @data.data.link + $(txtText).prop('disabled', @data.data.readonly) + + @find("btnCancel").onbtclick = (e) => + @quit() + + @find("btnOk").onbtclick = (e) => + data = + text: txtText.value, + link: txtLink.value, + readonly: @data.data.readonly, + action: @data.data.action + @handle data if @handle + @quit() + +HyperLinkDialog.scheme = """ + + + +
+ +
+ + + + +
+ +
+ + +
+ + +
+ + + +""" + +class FormatDialog extends this.OS.GUI.BasicDialog + constructor: () -> + super "FormatDialog", FormatDialog.scheme + + main: () -> + super.main() @ui = aligment: left:@find("swleft"), @@ -99,64 +116,68 @@ class FormatDialog extends this.OS.GUI.BaseDialog size: 12 initUIEvent: () -> - me = @ - set = (e, o, k ,f) -> - me.ui[o][k].set e, (r) -> + + set = (e, o, k ,f) => + @ui[o][k][e] = (r) => v = r v = f r if f - me.currentStyle[o][k] = v - me.previewStyle() + @currentStyle[o][k] = v + @previewStyle() for k,v of @ui.aligment - set "onchange", "aligment", k, ((e) -> e.data) + set "onswchange", "aligment", k, ((e) => e.data) for k,v of @ui.spacing - set "onchange", "spacing", k + set "onvaluechange", "spacing", k, ((e) => e.data) for k,v of @ui.padding - set "onchange", "padding", k + set "onvaluechange", "padding", k, ((e) => e.data) for k,v of @ui.style - set "onchange", "style", k, ((e) -> e.data) if k isnt "color" and k isnt "bgcolor" - set "onchange", "font", "size" - $(@ui.style.color).click (e) -> - me.openDialog "ColorPickerDialog", (d) -> - me.currentStyle.style.color = d - me.previewStyle() - $(@ui.style.bgcolor).click (e) -> - me.openDialog "ColorPickerDialog", (d) -> - me.currentStyle.style.bgcolor = d - me.previewStyle() + set "onswchange", "style", k, ((e) => e.data) if k isnt "color" and k isnt "bgcolor" + set "onvaluechange", "font", "size" + $(@ui.style.color).click (e) => + @openDialog "ColorPickerDialog" + .then (d) => + @currentStyle.style.color = d + @previewStyle() + $(@ui.style.bgcolor).click (e) => + @openDialog "ColorPickerDialog" + .then (d) => + @currentStyle.style.bgcolor = d + @previewStyle() #font - @ui.font.family.set "items", @data.fonts if @data and @data.fonts - set "onlistselect", "font", "family", ( (e) -> e.data) + @ui.font.family.data = @data.data.fonts if @data.data and @data.data.fonts + set "onlistselect", "font", "family", ( (e) => e.data.item.data) #format list - @ui.formats.set "selected", -1 - @ui.formats.set "items", @data.formats if @data and @data.formats - @ui.formats.set "onlistselect", (e) -> - me.fromODFStyleFormat e.data - @ui.formats.set "selected", 0 - (@find "btok").set "onbtclick", (e) -> - me.saveCurrentStyle() + @ui.formats.selected = -1 + @ui.formats.data = @data.data.formats if @data.data and @data.data.formats + @ui.formats.onlistselect = (e) => + @fromODFStyleFormat e.data.item.data + @ui.formats.selected = 0 + (@find "btok").onbtclick = (e) => + @saveCurrentStyle() - (@find "btx").set "onbtclick", (e) -> - me.quit() + (@find "btx").onbtclick = (e) => + @quit() - (@find "bt-clone").set "onbtclick", (e) -> - me.clone() + (@find "bt-clone").onbtclick = (e) => + @clone() clone: ()-> - me = @ - selected = @ui.formats.get "selected" + + selected = @ui.formats.selectedItem return unless selected - @openDialog "PromptDialog", (d) -> - return me.notify __("Abort: no style name is specified") unless d and d.trim() isnt "" - newstyle = me.parent.editorSession.cloneParagraphStyle selected.name, d - me.ui.formats.push { text:d, name: newstyle } - me.ui.formats.set "selected", ((me.ui.formats.get 'count') - 1) - me.notify __("New style: {0} added", newstyle) - , __("Clone style: {0}", selected.text), { label: __("New style name:") } + selected = selected.data + @openDialog "PromptDialog", { title: __("Clone style: {0}", selected.text), label: __("New style name:") } + .then (d) => + return @notify __("Abort: no style name is specified") unless d and d.trim() isnt "" + newstyle = @parent.editorSession.cloneParagraphStyle selected.name, d + @ui.formats.push { text:d, name: newstyle } + @ui.formats.selected = (@ui.formats.data.length - 1) + @notify __("New style: {0} added", newstyle) saveCurrentStyle: () -> - selected = @ui.formats.get "selected" + selected = @ui.formats.selectedItem return unless selected + selected = selected.data odfs = "style:paragraph-properties": "fo:margin-top": @currentStyle.spacing.top + "mm" @@ -181,11 +202,11 @@ class FormatDialog extends this.OS.GUI.BaseDialog @notify __("Paragraph format [{0}] is saved", selected.text) fromODFStyleFormat: (odfs) -> - me = @ + @initStyleObject() cssUnits = new core.CSSUnits() - findFont = (name) -> - items = me.ui.font.family.get "items" + findFont = (name) => + items = @ui.font.family.data item = v for v in items when v.text is name return undefined unless item return item @@ -216,34 +237,34 @@ class FormatDialog extends this.OS.GUI.BaseDialog previewStyle: () -> #console.log "previewing" # reset ui - @ui.aligment.left.set "swon", @currentStyle.aligment.left - @ui.aligment.right.set "swon", @currentStyle.aligment.right - @ui.aligment.center.set "swon", @currentStyle.aligment.center - @ui.aligment.justify.set "swon", @currentStyle.aligment.justify - @ui.spacing.left.set "value", @currentStyle.spacing.left - @ui.spacing.right.set "value", @currentStyle.spacing.right - @ui.spacing.top.set "value", @currentStyle.spacing.top - @ui.spacing.bottom.set "value", @currentStyle.spacing.bottom - @ui.spacing.lineheight.set "value", @currentStyle.spacing.lineheight + @ui.aligment.left.swon = @currentStyle.aligment.left + @ui.aligment.right.swon = @currentStyle.aligment.right + @ui.aligment.center.swon = @currentStyle.aligment.center + @ui.aligment.justify.swon = @currentStyle.aligment.justify + @ui.spacing.left.value = @currentStyle.spacing.left + @ui.spacing.right.value = @currentStyle.spacing.right + @ui.spacing.top.value = @currentStyle.spacing.top + @ui.spacing.bottom.value = @currentStyle.spacing.bottom + @ui.spacing.lineheight.value = @currentStyle.spacing.lineheight - @ui.padding.left.set "value", @currentStyle.padding.left - @ui.padding.right.set "value", @currentStyle.padding.right - @ui.padding.top.set "value", @currentStyle.padding.top - @ui.padding.bottom.set "value", @currentStyle.padding.bottom + @ui.padding.left.value = @currentStyle.padding.left + @ui.padding.right.value = @currentStyle.padding.right + @ui.padding.top.value = @currentStyle.padding.top + @ui.padding.bottom.value = @currentStyle.padding.bottom - @ui.style.bold.set "swon", @currentStyle.style.bold - @ui.style.italic.set "swon", @currentStyle.style.italic - @ui.style.underline.set "swon", @currentStyle.style.underline - @ui.font.size.set "value", @currentStyle.font.size + @ui.style.bold.swon = @currentStyle.style.bold + @ui.style.italic.swon = @currentStyle.style.italic + @ui.style.underline.swon = @currentStyle.style.underline + @ui.font.size.value = @currentStyle.font.size #console.log @currentStyle if @currentStyle.font.family - items = @ui.font.family.get "items" + items = @ui.font.family.data item = i for v, i in items when v.text is @currentStyle.font.family.text - @ui.font.family.set "selected", item if item >= 0 + @ui.font.family.selected = item if item >= 0 $(@ui.style.color).css "background-color", if @currentStyle.style.color then @currentStyle.style.color.hex else "#000000" - $(@ui.style.bgcolor).css "background-color", if @currentStyle.style.bgcolor then @currentStyle.style.bgcolor.hex else "white" + $(@ui.style.bgcolor).css "background-color", if @currentStyle.style.bgcolor then @currentStyle.style.bgcolor.hex else "transparent" # set the preview css el = $ @preview el.css "text-align", if @currentStyle.aligment.selected then @currentStyle.aligment.selected else "left" @@ -301,16 +322,16 @@ FormatDialog.scheme = """
- +
- +
- +
- +
@@ -319,16 +340,16 @@ FormatDialog.scheme = """
- +
- +
- +
- +
@@ -358,7 +379,7 @@ FormatDialog.scheme = """
- +
@@ -369,7 +390,7 @@ FormatDialog.scheme = """
-
+

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

diff --git a/OpenPage/coffees/main.coffee b/OpenPage/coffees/main.coffee index 4a11b9c..4bc4ffd 100644 --- a/OpenPage/coffees/main.coffee +++ b/OpenPage/coffees/main.coffee @@ -1,4 +1,4 @@ -class OpenPage extends this.OS.GUI.BaseApplication +class OpenPage extends this.OS.application.BaseApplication constructor: ( args ) -> super "OpenPage", args @@ -7,52 +7,55 @@ class OpenPage extends this.OS.GUI.BaseApplication #if not OpenPage.EditorSession # require ["webodf/editor/EditorSession"], (ES) -> # OpenPage.EditorSession = ES - me =@ + @eventSubscriptions = new core.EventSubscriptions() @initToolbox() @userid = "#{@systemsetting.user.username}@#{@pid}" - #file = "home://welcome.odt" + #file = "home://welco@odt" #file = "#{@_api.handler.get}/home://welcome.odt" #@canvas.load file #odfContainer = new odf.OdfContainer file, (c) -> - # me.canvas.setOdfContainer c, false + # @canvas.setOdfContainer c, false @currentStyle = "" - if @args and @args.length > 0 then @open @args[0] else @newdoc() + if @args and @args.length > 0 then @open @args[0].path else @newdoc() @resource = fonts: [] formats: [] - @bindKey "ALT-N", () -> me.actionFile "#{me.name}-New" - @bindKey "ALT-O", () -> me.actionFile "#{me.name}-Open" - @bindKey "CTRL-S", () -> me.actionFile "#{me.name}-Save" - @bindKey "ALT-W", () -> me.actionFile "#{me.name}-Saveas" + @bindKey "ALT-N", () => @actionFile "#{@name}-New" + @bindKey "ALT-O", () => @actionFile "#{@name}-Open" + @bindKey "CTRL-S", () => @actionFile "#{@name}-Save" + @bindKey "ALT-W", () => @actionFile "#{@name}-Saveas" menu: () -> - me = @ + menu = [{ text: "__(File)", - child: [ + nodes: [ { text: "__(New)", dataid: "#{@name}-New", shortcut: "A-N" }, { text: "__(Open)", dataid: "#{@name}-Open", shortcut: "A-O" }, { text: "__(Save)", dataid: "#{@name}-Save", shortcut: "C-S" }, { text: "__(Save as)", dataid: "#{@name}-Saveas", shortcut: "A-W" } ], - onmenuselect: (e) -> me.actionFile e.item.data.dataid + onchildselect: (e) => @actionFile e.data.item.data.dataid }] menu actionFile: (e) -> - me = @ - saveas = () -> - me.openDialog "FileDiaLog", (d, n, p) -> - me.currfile.setPath "#{d}/#{n}" - me.save() - , __("Save as"), { file: me.currfile } + + saveas = () => + @openDialog "FileDialog", { title: __("Save as"), file: @currfile } + .then (f) => + d = f.file.path.asFileHandle() + d = d.parent() if f.file.type is "file" + @currfile.setPath "#{d.path}/#{f.name}" + @save() switch e when "#{@name}-Open" - @openDialog "FileDiaLog", ( d, f , p) -> - me.open p - , __("Open file"), { mimes: me.meta().mimes } + @openDialog "FileDialog", { title: __("Open file"), mimes: @meta().mimes } + .then (f) => + @open f.file.path + when "#{@name}-Save" #@currfile.cache = @editor.value() return @save() if @currfile.basename @@ -68,39 +71,41 @@ class OpenPage extends this.OS.GUI.BaseApplication @open blank, true open: (p,b) -> - me = @ + @pathAsDataURL(p) - .then (r) -> - me.closeDocument() if me.editorSession - me.initCanvas() - OdfContainer = new odf.OdfContainer r.data, (c) -> - me.canvas.setOdfContainer c, false - return me.currfile = "Untitled".asFileHandler() if b - if me.currfile then me.currfile.setPath p else me.currfile = p.asFileHandler() - me.scheme.set "apptitle", me.currfile.basename - me.notify __("File {0} opened", p) - .catch (e) -> - me.error __("Problem read file {0}", e) + .then (r) => + @closeDocument() if @editorSession + @initCanvas() + OdfContainer = new odf.OdfContainer r.data, (c) => + @canvas.setOdfContainer c, false + return @currfile = "Untitled".asFileHandle() if b + if @currfile then @currfile.setPath p else @currfile = p.asFileHandle() + @scheme.apptitle = @currfile.basename + @notify __("File {0} opened", p) + .catch (e) => + @error __("Problem read file {0}", e.toString()), e save: () -> - me = @ + return unless @editorSession container = @canvas.odfContainer() return @error __("No document container found") unless container - container.createByteArray (ba) -> + container.createByteArray (ba) => # create blob - me.currfile.cache = new Blob [ba], { type: "application/vnd.oasis.opendocument.text" } - me.currfile.write "application/vnd.oasis.opendocument.text", (r) -> - return me.error __("Cannot save file: {0}", r.error) if r.error - me.notify __("File {0} saved", me.currfile.basename) - me.scheme.set "apptitle", me.currfile.basename - me.currfile.dirty = false - me.editorFocus() - , (err) -> - @error __("Cannot create byte array from container: {0}", err|| "") + @currfile.cache = new Blob [ba], { type: "application/vnd.oasis.opendocument.text" } + @currfile.write "application/vnd.oasis.opendocument.text" + .then (r) => + @notify __("File {0} saved", @currfile.basename) + @scheme.apptitle = @currfile.basename + @currfile.dirty = false + @editorFocus() + .catch (e) => + @error __("Cannot save file: {0}", e.toString()), e + , (err) => + @error __("Cannot create byte array from container: {0}", err.toString() || ""), err initToolbox: () -> - me = @ + @basictool = undo: @find("btundo"), redo: @find("btredo"), @@ -124,76 +129,77 @@ class OpenPage extends this.OS.GUI.BaseApplication zoom: @find("slzoom") format: @find("btformat") - fn = (name, el) -> + fn = (name, el) => if name is "fonts" or name is "styles" act = "onlistselect" else if name is "fontsize" or name is "zoom" - act = "onchange" + act = "onvaluechange" else act = "onbtclick" - el.set act, (e) -> - return unless me.directFormattingCtl - return unless me[name] - me[name](e) - me.editorFocus() + el[act] = (e) => + return unless @directFormattingCtl + return unless @[name] + @[name](e) + @editorFocus() for name, el of @basictool fn name, el - (@find "btzoomfix").set "onbtclick", (e) -> me.zoom 100 - @basictool.zoom.set "onchanging", (e) -> - zlb = me.find "lbzoom" - zlb.set "text", Math.floor(e) + "%" + (@find "btzoomfix").onbtclick = (e) => @zoom { data: 100 } + @basictool.zoom.onvaluechanging = (e) => + zlb = @find "lbzoom" + zlb.text = Math.floor(e.data) + "%" initCanvas: () -> el = @find "odfcanvas" - me = @ + el.setAttribute "translate", "no" el.classList.add "notranslate" @canvas = new odf.OdfCanvas(el) - @documentChanged = (e) -> - return if me.currfile.dirty - me.currfile.dirty = true - me.scheme.set "apptitle", me.currfile.basename + "*" + @documentChanged = (e) => + return if @currfile.dirty + @currfile.dirty = true + @scheme.apptitle = @currfile.basename + "*" #console.log e - @metaChanged = (e) -> - return if me.currfile.dirty - me.currfile.dirty = true - me.scheme.set "apptitle", me.currfile.basename + "*" + @metaChanged = (e) => + return if @currfile.dirty + @currfile.dirty = true + @scheme.apptitle = @currfile.basename + "*" #console.log e - @textStylingChanged = (e) -> - me.updateToolbar e - @paragrahStyleChanged = (e) -> + @textStylingChanged = (e) => + @updateToolbar e + @paragrahStyleChanged = (e) => return unless e.type is "style" - items = me.basictool.styles.get "items" + items = @basictool.styles.data item = i for v, i in items when v.name is e.styleName - me.currentStyle = e.styleName - me.basictool.styles.set "selected", item + return unless item isnt undefined + @currentStyle = e.styleName + @basictool.styles.selected = item - @styleAdded = (e) -> + @styleAdded = (e) => return unless e.family is 'paragraph' - items = me.basictool.styles.get "items" + items = @basictool.styles.data item = v for v in items when v.name is e.name return if item stylens = "urn:oasis:names:tc:opendocument:xmlns:style:1.0" - el = me.editorSession.getParagraphStyleElement e.name + el = @editorSession.getParagraphStyleElement e.name dtext = el.getAttributeNS stylens, 'display-name' - me.basictool.styles.push { text: dtext , name: e.name }, true - #me.resource.formats.push {text: dtext, name:e.name} + @basictool.styles.push { text: dtext , name: e.name }, true + #@resource.formats.push {text: dtext, name:e.name} - @updateSlider = (v) -> + @updateSlider = (v) => value = Math.floor v*100 - me.basictool.zoom.set "value", value - zlb = me.find "lbzoom" - zlb.set "text", value+"%" - #me.canvas.enableAnnotations true, true - @canvas.addListener "statereadychange", ()-> - me.session = new ops.Session(me.canvas) + @basictool.zoom.value = value + zlb = @find "lbzoom" + zlb.text = value + "%" + @canvas.enableAnnotations true, true + @canvas.addListener "statereadychange", ()=> + @session = new ops.Session(@canvas) viewOptions = editInfoMarkersInitiallyVisible: false, caretAvatarsInitiallyVisible: false, caretBlinksOnRangeSelect: true - me.editorSession = new OpenPage.EditorSession(me.session,me.userid, { + @editorSession = new OpenPage.EditorSession(@session,@userid, { viewOptions: viewOptions, directTextStylingEnabled: true, directParagraphStylingEnabled: true, @@ -205,112 +211,121 @@ class OpenPage extends this.OS.GUI.BaseApplication zoomingEnabled: true, reviewModeEnabled: false }) - me.initFontList me.editorSession.getDeclaredFonts() - me.initStyles me.editorSession.getAvailableParagraphStyles() + @initFontList @editorSession.getDeclaredFonts() + @initStyles @editorSession.getAvailableParagraphStyles() #fix annotation problem on canvas #console.log $("office:body").css "background-color", "red" # basic format - me.directFormattingCtl = me.editorSession.sessionController.getDirectFormattingController() - me.directFormattingCtl.subscribe gui.DirectFormattingController.textStylingChanged, me.textStylingChanged - me.directFormattingCtl.subscribe gui.DirectFormattingController.paragraphStylingChanged, me.textStylingChanged - me.editorSession.subscribe OpenPage.EditorSession.signalParagraphChanged, me.paragrahStyleChanged + @directFormattingCtl = @editorSession.sessionController.getDirectFormattingController() + @directFormattingCtl.subscribe gui.DirectFormattingController.textStylingChanged, @textStylingChanged + @directFormattingCtl.subscribe gui.DirectFormattingController.paragraphStylingChanged, @textStylingChanged + @editorSession.subscribe OpenPage.EditorSession.signalParagraphChanged, @paragrahStyleChanged # hyper link controller - me.hyperlinkController = me.editorSession.sessionController.getHyperlinkController() - me.eventSubscriptions.addFrameSubscription me.editorSession, OpenPage.EditorSession.signalCursorMoved, ()-> me.updateHyperlinkButtons() - me.eventSubscriptions.addFrameSubscription me.editorSession, OpenPage.EditorSession.signalParagraphChanged, ()-> me.updateHyperlinkButtons() - me.eventSubscriptions.addFrameSubscription me.editorSession, OpenPage.EditorSession.signalParagraphStyleModified, ()-> me.updateHyperlinkButtons() + @hyperlinkController = @editorSession.sessionController.getHyperlinkController() + @eventSubscriptions.addFrameSubscription @editorSession, OpenPage.EditorSession.signalCursorMoved, ()=> @updateHyperlinkButtons() + @eventSubscriptions.addFrameSubscription @editorSession, OpenPage.EditorSession.signalParagraphChanged, ()=> @updateHyperlinkButtons() + @eventSubscriptions.addFrameSubscription @editorSession, OpenPage.EditorSession.signalParagraphStyleModified, ()=> @updateHyperlinkButtons() #annotation controller - me.annotationController = me.editorSession.sessionController.getAnnotationController() + @annotationController = @editorSession.sessionController.getAnnotationController() #image controller - me.imageController = me.editorSession.sessionController.getImageController() + @imageController = @editorSession.sessionController.getImageController() #imageController.subscribe(gui.ImageController.enabledChanged, enableButtons) #text controller - me.textController = me.editorSession.sessionController.getTextController() + @textController = @editorSession.sessionController.getTextController() # zoom controller - me.zoomHelper = me.editorSession.getOdfCanvas().getZoomHelper() - me.zoomHelper.subscribe gui.ZoomHelper.signalZoomChanged, me.updateSlider - me.updateSlider me.zoomHelper.getZoomLevel() + @zoomHelper = @editorSession.getOdfCanvas().getZoomHelper() + @zoomHelper.subscribe gui.ZoomHelper.signalZoomChanged, @updateSlider + @updateSlider @zoomHelper.getZoomLevel() # format controller - me.editorSession.subscribe OpenPage.EditorSession.signalCommonStyleCreated, me.styleAdded + @editorSession.subscribe OpenPage.EditorSession.signalCommonStyleCreated, @styleAdded - me.editorSession.sessionController.setUndoManager new gui.TrivialUndoManager() - me.editorSession.sessionController.getUndoManager().subscribe gui.UndoManager.signalDocumentModifiedChanged, me.documentChanged - me.editorSession.sessionController.getMetadataController().subscribe gui.MetadataController.signalMetadataChanged, me.metaChanged + @editorSession.sessionController.setUndoManager new gui.TrivialUndoManager() + @editorSession.sessionController.getUndoManager().subscribe gui.UndoManager.signalDocumentModifiedChanged, @documentChanged + @editorSession.sessionController.getMetadataController().subscribe gui.MetadataController.signalMetadataChanged, @metaChanged op = new ops.OpAddMember() op.init { - memberid: me.userid, + memberid: @userid, setProperties:{ - "fullName": me.userid, + "fullName": @userid, "color": "blue" } } - me.session.enqueue([op]) - me.editorSession.sessionController.insertLocalCursor() - me.editorSession.sessionController.startEditing() - #console.log me.editorSession.getDeclaredFonts() + @session.enqueue([op]) + @editorSession.sessionController.insertLocalCursor() + @editorSession.sessionController.startEditing() + @fontsize {data: @basictool.fontsize.value} + #console.log @editorSession.getDeclaredFonts() # initFontList: (list) -> v.text = v.name for v in list + @resource.fonts = [] @resource.fonts.push { text: v.text, name: v.family } for v in list - @basictool.fonts.set "items", list + @basictool.fonts.data = list initStyles: (list) -> list.unshift {name:"", displayName: 'Default style' } v.text = v.displayName for v in list @resource.formats.push { text: v.text, name: v.name } for v in list - @basictool.styles.set "items", list + @basictool.styles.data = list updateToolbar: (changes) -> # basic style - (@basictool.bold.set "selected", changes.isBold) if changes.hasOwnProperty 'isBold' - (@basictool.italic.set "selected", changes.isItalic) if changes.hasOwnProperty 'isItalic' - (@basictool.underline.set "selected", changes.hasUnderline) if changes.hasOwnProperty 'hasUnderline' - (@basictool.strike.set "selected", changes.hasStrikeThrough) if changes.hasOwnProperty 'hasStrikeThrough' - (@basictool.fontsize.set "value", changes.fontSize) if changes.hasOwnProperty "fontSize" + (@basictool.bold.selected = changes.isBold) if changes.hasOwnProperty 'isBold' + (@basictool.italic.selected = changes.isItalic) if changes.hasOwnProperty 'isItalic' + (@basictool.underline.selected = changes.hasUnderline) if changes.hasOwnProperty 'hasUnderline' + (@basictool.strike.selected = changes.hasStrikeThrough) if changes.hasOwnProperty 'hasStrikeThrough' + if changes.hasOwnProperty "fontSize" + size = changes.fontSize + size = 12 if size is undefined + if @basictool.fontsize.value isnt size + @basictool.fontsize.value = size + @selectFont changes.fontName if changes.hasOwnProperty "fontName" #pharagraph style - @basictool.al.set "selected", changes.isAlignedLeft if changes.hasOwnProperty "isAlignedLeft" - @basictool.ar.set "selected", changes.isAlignedRight if changes.hasOwnProperty "isAlignedRight" - @basictool.ac.set "selected", changes.isAlignedCenter if changes.hasOwnProperty "isAlignedCenter" - @basictool.aj.set "selected", changes.isAlignedJustified if changes.hasOwnProperty "isAlignedJustified" + @basictool.al.selected = changes.isAlignedLeft if changes.hasOwnProperty "isAlignedLeft" + @basictool.ar.selected = changes.isAlignedRight if changes.hasOwnProperty "isAlignedRight" + @basictool.ac.selected = changes.isAlignedCenter if changes.hasOwnProperty "isAlignedCenter" + @basictool.aj.selected = changes.isAlignedJustified if changes.hasOwnProperty "isAlignedJustified" updateHyperlinkButtons: (e) -> selectedLinks = @editorSession.getSelectedHyperlinks() - @basictool.unlink.set "enable", selectedLinks.length > 0 + @basictool.unlink.enable = selectedLinks.length > 0 selectFont: (name) -> - items = @basictool.fonts.get "items" + items = @basictool.fonts.data item = i for v, i in items when v.name is name - @basictool.fonts.set "selected", item + return unless item isnt undefined + @basictool.fonts.selected = item editorFocus: () -> @editorSession.sessionController.getEventManager().focus() bold: (e) -> #console.log @, e - @directFormattingCtl.setBold (not @basictool.bold.get "selected") + @directFormattingCtl.setBold (not @basictool.bold.selected) italic: (e) -> - @directFormattingCtl.setItalic (not @basictool.italic.get "selected") + @directFormattingCtl.setItalic (not @basictool.italic.selected) underline: (e) -> - @directFormattingCtl.setHasUnderline (not @basictool.underline.get "selected") + @directFormattingCtl.setHasUnderline (not @basictool.underline.selected) strike: (e) -> - @directFormattingCtl.setHasStrikethrough (not @basictool.strike.get "selected") + @directFormattingCtl.setHasStrikethrough (not @basictool.strike.selected) fonts: (e) -> - @directFormattingCtl.setFontName e.data.name + @directFormattingCtl.setFontName e.data.item.data.name fontsize: (e) -> - @directFormattingCtl.setFontSize e + # present the value change from enter infinity loop + @directFormattingCtl.setFontSize e.data al: (e) -> @directFormattingCtl.alignParagraphLeft() @@ -335,7 +350,7 @@ class OpenPage extends this.OS.GUI.BaseApplication link: (e) -> # get the link first - me = @ + textSerializer = new odf.TextSerializer() selection = @editorSession.getSelectedRange() linksInSelection = @editorSession.getSelectedHyperlinks() @@ -356,23 +371,23 @@ class OpenPage extends this.OS.GUI.BaseApplication data.text = textSerializer.writeToString selection.cloneContents() else data.readonly = false - @openDialog new HyperLinkDialog(), (d) -> - selectionController = me.editorSession.sessionController.getSelectionController() + @openDialog new HyperLinkDialog(), {title: "__(Insert/edit link)", data: data} + .then (d) => + selectionController = @editorSession.sessionController.getSelectionController() if d.readonly # edit the existing link if d.action is "edit" selectedLinkRange = selection.cloneRange() selectedLinkRange.selectNode(linksInSelection[0]) selectionController.selectRange(selectedLinkRange, true) - me.hyperlinkController.removeHyperlinks() - me.hyperlinkController.addHyperlink d.link + @hyperlinkController.removeHyperlinks() + @hyperlinkController.addHyperlink d.link else - me.hyperlinkController.addHyperlink d.link, d.text - linksInSelection = me.editorSession.getSelectedHyperlinks() + @hyperlinkController.addHyperlink d.link, d.text + linksInSelection = @editorSession.getSelectedHyperlinks() selectedLinkRange = selection.cloneRange() selectedLinkRange.selectNode(linksInSelection[0]) selectionController.selectRange(selectedLinkRange, true) - , "__(Insert/edit link)", data unlink: (e) -> @hyperlinkController.removeHyperlinks() @@ -384,21 +399,22 @@ class OpenPage extends this.OS.GUI.BaseApplication @editorSession.redo() pathAsDataURL: (p) -> - return new Promise (resolve, error) -> - fp = p.asFileHandler() - fp.read (data) -> + return new Promise (resolve, error) => + fp = p.asFileHandle() + fp.read("binary").then (data) => blob = new Blob [data], { type: fp.info.mime } reader = new FileReader() - reader.onloadend = () -> - return error(p) if reader.readyState isnt 2 + reader.onloadend = () => + return error(@throwe __("Unable to load file {0}", p)) if reader.readyState isnt 2 resolve {data: reader.result, fp: fp } reader.readAsDataURL blob - , "binary" + .catch (e) => error __e e + ### if not isText else - fp.read (data) -> + fp.read (data) => # convert to base64 b64 = btoa data dataurl = "data:#{fp.info.mime};base64," + b64 @@ -406,43 +422,44 @@ class OpenPage extends this.OS.GUI.BaseApplication ### image: (e) -> - me = @ - @openDialog "FileDiaLog", (d, n, p) -> - me.pathAsDataURL(p) - .then (r) -> + + @openDialog "FileDialog", { title: __("Select image file"), mimes: ["image/.*"] } + .then (f) => + p = f.file.path + @pathAsDataURL(p) + .then (r) => hiddenImage = new Image() hiddenImage.style.position = "absolute" hiddenImage.style.left = "-99999px" document.body.appendChild hiddenImage - hiddenImage.onload = () -> + hiddenImage.onload = () => content = r.data.substring(r.data.indexOf(",") + 1) #insert image - me.textController.removeCurrentSelection() - me.imageController.insertImage r.fp.info.mime, content, hiddenImage.width, hiddenImage.height + @textController.removeCurrentSelection() + @imageController.insertImage r.fp.info.mime, content, hiddenImage.width, hiddenImage.height document.body.removeChild hiddenImage hiddenImage.src = r.data - .catch () -> - me.error __("Couldnt load image {0}", p) - , __("Select image file"), { mimes: ["image/.*"] } + .catch (e) => + @error __("Couldnt load image {0}", p), e styles: (e) -> - return if e.data.name is @currentStyle - @editorSession.setCurrentParagraphStyle e.data.name + return if e.data.item.data.name is @currentStyle + @editorSession.setCurrentParagraphStyle e.data.item.data.name zoom: (e) -> #console.log "zooming", e return unless @zoomHelper - @zoomHelper.setZoomLevel e/100.0 + @zoomHelper.setZoomLevel e.data/100.0 format: (e) -> - @openDialog new FormatDialog(), (d) -> + @openDialog new FormatDialog(), { title: __("Add/Modify paragraph format"), data: @resource } + .then (d) => return - , __("Add/Modify paragraph format"), @resource closeDocument: (f) -> # finish editing return unless @editorSession and @session - me = @ + @eventSubscriptions.unsubscribeAll() @editorSession.sessionController.endEditing() @editorSession.sessionController.removeLocalCursor() @@ -453,49 +470,49 @@ class OpenPage extends this.OS.GUI.BaseApplication } @session.enqueue [op] # close the session - @session.close (e) -> - return me.error __("Cannot close session {0}", e) if e - me.editorSession.sessionController.getMetadataController().unsubscribe gui.MetadataController.signalMetadataChanged, me.metaChanged - me.editorSession.sessionController.getUndoManager().unsubscribe gui.UndoManager.signalDocumentModifiedChanged, me.documentChanged - me.directFormattingCtl.unsubscribe gui.DirectFormattingController.textStylingChanged, me.textStylingChanged - me.directFormattingCtl.unsubscribe gui.DirectFormattingController.paragraphStylingChanged, me.textStylingChanged - me.editorSession.unsubscribe OpenPage.EditorSession.signalParagraphChanged, me.paragrahStyleChanged - me.zoomHelper.unsubscribe gui.ZoomHelper.signalZoomChanged, me.updateSlider - me.editorSession.unsubscribe OpenPage.EditorSession.signalCommonStyleCreated, me.styleAdded + @session.close (e) => + return @error __("Cannot close session {0}", e.toString()), e if e + @editorSession.sessionController.getMetadataController().unsubscribe gui.MetadataController.signalMetadataChanged, @metaChanged + @editorSession.sessionController.getUndoManager().unsubscribe gui.UndoManager.signalDocumentModifiedChanged, @documentChanged + @directFormattingCtl.unsubscribe gui.DirectFormattingController.textStylingChanged, @textStylingChanged + @directFormattingCtl.unsubscribe gui.DirectFormattingController.paragraphStylingChanged, @textStylingChanged + @editorSession.unsubscribe OpenPage.EditorSession.signalParagraphChanged, @paragrahStyleChanged + @zoomHelper.unsubscribe gui.ZoomHelper.signalZoomChanged, @updateSlider + @editorSession.unsubscribe OpenPage.EditorSession.signalCommonStyleCreated, @styleAdded # destry editorSession - me.editorSession.destroy (e) -> - return me.error __("Cannot destroy editor session {0}", e) if e - me.editorSession = undefined + @editorSession.destroy (e) => + return @error __("Cannot destroy editor session {0}", e.toString()), e if e + @editorSession = undefined # destroy session - me.session.destroy (e) -> - return me.error __("Cannot destroy document session {0}", e) if e - core.Async.destroyAll [me.canvas.destroy], (e) -> - return me.error __("Cannot destroy canvas {0}", e) if e - me.notify "Document closed" + @session.destroy (e) => + return @error __("Cannot destroy document session {0}", e.toString()), e if e + core.Async.destroyAll [@canvas.destroy], (e) => + return @error __("Cannot destroy canvas {0}", e.toString()), e if e + @notify "Document closed" f() if f - me.session = undefined - me.annotationController = undefined - me.directFormattingCtl = undefined - me.textController = undefined - me.imageController = undefined - me.ZoomHelper = undefined - me.metaChanged = undefined - me.documentChanged = undefined - me.textStylingChanged = undefined - me.paragrahStyleChanged = undefined - me.updateSlider = undefined - me.styleAdded = undefined - me.basictool.fonts.set "selected", -1 - me.basictool.styles.set "selected", -1 + @session = undefined + @annotationController = undefined + @directFormattingCtl = undefined + @textController = undefined + @imageController = undefined + @ZoomHelper = undefined + @metaChanged = undefined + @documentChanged = undefined + @textStylingChanged = undefined + @paragrahStyleChanged = undefined + @updateSlider = undefined + @styleAdded = undefined + @basictool.fonts.selected = -1 + @basictool.styles.selected = -1 # cleanup: (e) -> - me = @ + if @editorSession e.preventDefault() - me.closeDocument ()-> - me.quit() + @closeDocument ()=> + @quit() this.OS.register "OpenPage", OpenPage \ No newline at end of file diff --git a/OpenPage/css/main.css b/OpenPage/css/main.css index ef56663..4a1247c 100644 --- a/OpenPage/css/main.css +++ b/OpenPage/css/main.css @@ -7,10 +7,16 @@ afx-app-window[data-id="OpenPage"] div[data-id="container"] padding-top: 10px; padding-bottom: 10px; text-align: center; - background-color: #f2f1f0; + /*background-color: #f2f1f0;*/ /*position: relative;*/ } - +afx-app-window[data-id="OpenPage"] office|body, office|document { + background-color: white; + color: black; + background-image: none; + user-select: text; + overflow: visible; +} /* @media screen, print, handheld, projection { @@ -36,7 +42,8 @@ afx-app-window[data-id="OpenPage"] div[data-id="odfcanvas"] { cursor: text; margin:auto; - box-shadow: 1px 1px 3px 3px #9f9F9F; + /*box-shadow: 1px 1px 3px 3px #9f9F9F;*/ + border: 1px solid #2c2c2c; /*added*/ transform-origin: top center; -webkit-transform-origin: top center; @@ -47,24 +54,28 @@ afx-app-window[data-id="OpenPage"] div[data-id="odfcanvas"] afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] { - background-color: #f5f5f5; + /*background-color: #f5f5f5; border: 1px solid #eaeaea; - box-shadow: 3px 3px 3px #9f9F9F; + box-shadow: 3px 3px 3px #9f9F9F;*/ } afx-app-window[data-id="OpenPage"] afx-hbox[data-id="status-bar"] { - background-color: #f5f5f5; + /*background-color: #f5f5f5; border: 1px solid #eaeaea; - box-shadow: -3px -3px 3px #9f9F9F; + box-shadow: -3px -3px 3px #9f9F9F;*/ } afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button button, afx-app-window[data-id="OpenPage"] afx-button[data-id="btzoomfix"] button { - border: 1px solid #f5f5f5; - background-color: transparent; + /*border: 1px solid #f5f5f5; + background-color: transparent;*/ width:100%; height: 100%; } +afx-app-window[data-id="OpenPage"] button.selected { + color:chocolate; +} + afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button button:hover, afx-app-window[data-id="OpenPage"] afx-hbox[data-id="toolbox"] afx-button button.btactive, afx-app-window[data-id="OpenPage"] afx-button[data-id="btzoomfix"] button:hover { border: 1px solid #759DC0; diff --git a/OpenPage/javascripts/EditorSession.js b/OpenPage/javascripts/EditorSession.js index c1b544e..34dca01 100644 --- a/OpenPage/javascripts/EditorSession.js +++ b/OpenPage/javascripts/EditorSession.js @@ -27,7 +27,7 @@ /*define("webodf/editor/EditorSession", [ "dojo/text!resources/fonts/fonts.css" ],*/ -this.OS.APP.OpenPage.EditorSession = (function (fontsCSS) { // fontsCSS is retrieved as a string, using dojo's text retrieval AMD plugin +this.OS.application.OpenPage.EditorSession = (function (fontsCSS) { // fontsCSS is retrieved as a string, using dojo's text retrieval AMD plugin "use strict"; runtime.loadClass("core.Async"); diff --git a/OpenPage/package.json b/OpenPage/package.json index 8408503..c67ada6 100644 --- a/OpenPage/package.json +++ b/OpenPage/package.json @@ -6,7 +6,7 @@ "author": "Xuan Sang LE", "email": "xsang.le@gmail.com" }, - "version":"0.0.2-a", + "version":"0.1.3-a", "category":"Other", "icon":"icon.png", "mimes":["application/vnd.oasis.opendocument.text"] diff --git a/packages.json b/packages.json index 516ad4b..7a56ea7 100644 --- a/packages.json +++ b/packages.json @@ -80,6 +80,15 @@ "version": "0.0.6-a", "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/MarkOn/build/release/MarkOn.zip" }, + { + "pkgname": "OpenPage", + "name": "OpenPage", + "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/OpenPage/README.md", + "category": "Other", + "author": "Xuan Sang LE", + "version": "0.1.3-a", + "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/OpenPage/build/release/OpenPage.zip" + }, { "pkgname": "Preview", "name": "Preview",