svgedit-pl 7.3.7 → 7.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor/Editor.js +1 -1
- package/dist/editor/Editor.js.map +1 -1
- package/dist/editor/extensions/ext-storage/ext-storage.js +1 -1
- package/dist/editor/extensions/ext-storage/ext-storage.js.map +1 -1
- package/dist/editor/iife-Editor.js +1 -1
- package/dist/editor/iife-Editor.js.map +1 -1
- package/dist/editor/xdomain-Editor.js +1 -1
- package/dist/editor/xdomain-Editor.js.map +1 -1
- package/docs/jsdoc/BottomPanel.html +1 -1
- package/docs/jsdoc/ConfigObj.js.html +11 -11
- package/docs/jsdoc/Dropdown.html +1 -1
- package/docs/jsdoc/Editor.js.html +1 -1
- package/docs/jsdoc/EditorStartup.html +1 -1
- package/docs/jsdoc/EditorStartup.js.html +1 -1
- package/docs/jsdoc/ElixMenuButton.html +1 -1
- package/docs/jsdoc/ElixNumberSpinBox.html +1 -1
- package/docs/jsdoc/ExplorerButton.html +1 -1
- package/docs/jsdoc/FlyingButton.html +1 -1
- package/docs/jsdoc/LayersPanel.html +1 -1
- package/docs/jsdoc/LeftPanel.html +1 -1
- package/docs/jsdoc/MainMenu.html +1 -1
- package/docs/jsdoc/MainMenu.js.html +12 -12
- package/docs/jsdoc/NumberSpinBox.html +1 -1
- package/docs/jsdoc/PaintBox.html +1 -1
- package/docs/jsdoc/PlainNumberSpinBox.html +1 -1
- package/docs/jsdoc/Rulers.html +1 -1
- package/docs/jsdoc/Rulers.js.html +1 -1
- package/docs/jsdoc/SEInput.html +1 -1
- package/docs/jsdoc/SEPalette.html +1 -1
- package/docs/jsdoc/SESpinInput.html +1 -1
- package/docs/jsdoc/SeCMenuDialog.html +1 -1
- package/docs/jsdoc/SeCMenuLayerDialog.html +1 -1
- package/docs/jsdoc/SeColorPicker.html +1 -1
- package/docs/jsdoc/SeEditPrefsDialog.html +1 -1
- package/docs/jsdoc/SeExportDialog.html +1 -1
- package/docs/jsdoc/SeImgPropDialog.html +1 -1
- package/docs/jsdoc/SeList.html +1 -1
- package/docs/jsdoc/SeMenu.html +1 -1
- package/docs/jsdoc/SeMenuItem.html +1 -1
- package/docs/jsdoc/SePlainAlertDialog.html +1 -1
- package/docs/jsdoc/SePlainBorderButton.html +1 -1
- package/docs/jsdoc/SePromptDialog.html +1 -1
- package/docs/jsdoc/SeStorageDialog.html +1 -1
- package/docs/jsdoc/SeSvgSourceEditorDialog.html +1 -1
- package/docs/jsdoc/SeText.html +1 -1
- package/docs/jsdoc/ToolButton.html +1 -1
- package/docs/jsdoc/TopPanel.html +1 -1
- package/docs/jsdoc/components_PaintBox.js.html +1 -1
- package/docs/jsdoc/components_jgraduate_ColorValuePicker.js.html +1 -1
- package/docs/jsdoc/components_jgraduate_Slider.js.html +1 -1
- package/docs/jsdoc/components_jgraduate_jQuery.jGraduate.js.html +1 -1
- package/docs/jsdoc/components_jgraduate_jQuery.jPicker.js.html +1 -1
- package/docs/jsdoc/components_seButton.js.html +1 -1
- package/docs/jsdoc/components_seColorPicker.js.html +1 -1
- package/docs/jsdoc/components_seDropdown.js.html +1 -1
- package/docs/jsdoc/components_seExplorerButton.js.html +1 -1
- package/docs/jsdoc/components_seFlyingButton.js.html +1 -1
- package/docs/jsdoc/components_seInput.js.html +1 -1
- package/docs/jsdoc/components_seList.js.html +1 -1
- package/docs/jsdoc/components_seListItem.js.html +1 -1
- package/docs/jsdoc/components_seMenu.js.html +1 -1
- package/docs/jsdoc/components_seMenuItem.js.html +1 -1
- package/docs/jsdoc/components_sePalette.js.html +1 -1
- package/docs/jsdoc/components_sePlainBorderButton.js.html +1 -1
- package/docs/jsdoc/components_sePlainMenuButton.js.html +1 -1
- package/docs/jsdoc/components_seSelect.js.html +1 -1
- package/docs/jsdoc/components_seSpinInput.js.html +1 -1
- package/docs/jsdoc/components_seText.js.html +1 -1
- package/docs/jsdoc/components_seZoom.js.html +1 -1
- package/docs/jsdoc/configObj.html +1 -1
- package/docs/jsdoc/contextmenu.js.html +1 -1
- package/docs/jsdoc/dialogs_SePlainAlertDialog.js.html +1 -1
- package/docs/jsdoc/dialogs_cmenuDialog.js.html +1 -1
- package/docs/jsdoc/dialogs_cmenuLayersDialog.js.html +1 -1
- package/docs/jsdoc/dialogs_editorPreferencesDialog.js.html +1 -1
- package/docs/jsdoc/dialogs_exportDialog.js.html +1 -1
- package/docs/jsdoc/dialogs_imagePropertiesDialog.js.html +1 -1
- package/docs/jsdoc/dialogs_se-elix_define_NumberSpinBox.js.html +1 -1
- package/docs/jsdoc/dialogs_se-elix_src_base_NumberSpinBox.js.html +1 -1
- package/docs/jsdoc/dialogs_se-elix_src_plain_PlainNumberSpinBox.js.html +1 -1
- package/docs/jsdoc/dialogs_sePromptDialog.js.html +1 -1
- package/docs/jsdoc/dialogs_svgSourceDialog.js.html +1 -1
- package/docs/jsdoc/extensions_ext-connector_ext-connector.js.html +1 -1
- package/docs/jsdoc/extensions_ext-eyedropper_ext-eyedropper.js.html +1 -1
- package/docs/jsdoc/extensions_ext-grid_ext-grid.js.html +1 -1
- package/docs/jsdoc/extensions_ext-helloworld_ext-helloworld.js.html +1 -1
- package/docs/jsdoc/extensions_ext-layer_view_ext-layer_view.js.html +1 -1
- package/docs/jsdoc/extensions_ext-markers_ext-markers.js.html +1 -1
- package/docs/jsdoc/extensions_ext-opensave_ext-opensave.js.html +1 -1
- package/docs/jsdoc/extensions_ext-overview_window_ext-overview_window.js.html +1 -1
- package/docs/jsdoc/extensions_ext-panning_ext-panning.js.html +1 -1
- package/docs/jsdoc/extensions_ext-polystar_ext-polystar.js.html +1 -1
- package/docs/jsdoc/extensions_ext-shapes_ext-shapes.js.html +1 -1
- package/docs/jsdoc/extensions_ext-storage_ext-storage.js.html +22 -7
- package/docs/jsdoc/extensions_ext-storage_storageDialog.js.html +8 -8
- package/docs/jsdoc/external-JamilihArray.html +1 -1
- package/docs/jsdoc/external-Math.html +1 -1
- package/docs/jsdoc/external-Window.html +1 -1
- package/docs/jsdoc/external-jQuery.fn.$.fn.jPicker.defaults.html +1 -1
- package/docs/jsdoc/external-jQuery.fn.exports.jPickerMethod.html +1 -1
- package/docs/jsdoc/external-jQuery.fn.html +1 -1
- package/docs/jsdoc/external-jQuery.fn.jGraduateDefaults.html +1 -1
- package/docs/jsdoc/external-jQuery.fn.jGraduateDefaults.images.html +1 -1
- package/docs/jsdoc/external-jQuery.fn.jGraduateDefaults.window.html +1 -1
- package/docs/jsdoc/external-jQuery.html +1 -1
- package/docs/jsdoc/external-jQuery.jGraduate.Paint.html +1 -1
- package/docs/jsdoc/external-jQuery.jGraduate.html +1 -1
- package/docs/jsdoc/external-jQuery.jPicker.Color.html +1 -1
- package/docs/jsdoc/external-jQuery.jPicker.ColorMethods.html +1 -1
- package/docs/jsdoc/external-jQuery.jPicker.html +1 -1
- package/docs/jsdoc/global.html +1 -1
- package/docs/jsdoc/index.html +1 -1
- package/docs/jsdoc/locale.js.html +1 -1
- package/docs/jsdoc/module-SVGEditor-Editor.html +1 -1
- package/docs/jsdoc/module-SVGEditor.Config.html +1 -1
- package/docs/jsdoc/module-SVGEditor.Prefs.html +1 -1
- package/docs/jsdoc/module-SVGEditor.html +1 -1
- package/docs/jsdoc/module-SVGthis.CustomHandler.html +1 -1
- package/docs/jsdoc/module-contextmenu.html +1 -1
- package/docs/jsdoc/module-jGraduate.html +1 -1
- package/docs/jsdoc/module-jPicker.html +1 -1
- package/docs/jsdoc/module-jPicker.module.exports.html +1 -1
- package/docs/jsdoc/module-locale.LocaleEditorInit.html +1 -1
- package/docs/jsdoc/module-locale.html +1 -1
- package/docs/jsdoc/module.exports.html +1 -1
- package/docs/jsdoc/module.exports_module.exports.html +1 -1
- package/docs/jsdoc/panels_BottomPanel.js.html +1 -1
- package/docs/jsdoc/panels_LayersPanel.js.html +1 -1
- package/docs/jsdoc/panels_LeftPanel.js.html +1 -1
- package/docs/jsdoc/panels_TopPanel.js.html +1 -1
- package/docs/jsdoc/tutorial-CanvasAPI.html +1 -1
- package/docs/jsdoc/tutorial-ConfigOptions.html +1 -1
- package/docs/jsdoc/tutorial-Editor.html +1 -1
- package/docs/jsdoc/tutorial-EditorAPI.html +1 -1
- package/docs/jsdoc/tutorial-Events.html +1 -1
- package/docs/jsdoc/tutorial-ExtensionDocs.html +1 -1
- package/docs/jsdoc/tutorial-FrequentlyAskedQuestions.html +1 -1
- package/docs/jsdoc/tutorial-LocaleDocs.html +1 -1
- package/docs/jsdoc/typedefs.js.html +1 -1
- package/package.json +1 -1
- package/src/editor/ConfigObj.js +10 -10
- package/src/editor/MainMenu.js +11 -11
- package/src/editor/extensions/ext-storage/ext-storage.js +21 -6
- package/src/editor/extensions/ext-storage/storageDialog.js +7 -7
|
@@ -19,5 +19,5 @@ const e=document.createElement("template");e.innerHTML='<style>\n #dialog_con
|
|
|
19
19
|
* @todo We might provide control of storage settings through the UI besides the
|
|
20
20
|
* initial (or URL-forced) dialog. *
|
|
21
21
|
*/
|
|
22
|
-
const removeStoragePrefCookie=()=>{expireCookie("svgeditstore")},expireCookie=e=>{document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT"},replaceStoragePrompt=e=>{e=e?"storagePrompt="+e:"";const t=top.location;t.href.includes("storagePrompt=")?t.href=t.href.replace(/([&?])storagePrompt=[^&]*(&?)/,(function(t,o,n){return(e?o:"")+e+(!e&&n?o:n||"")})):t.href+=(t.href.includes("?")?"&":"?")+e};var t={name:"storage",init(){const e=this,{svgCanvas:t,storage:o}=e,{noStorageOnLoad:n,forceStorage:r,canvasName:
|
|
22
|
+
const removeStoragePrefCookie=()=>{expireCookie("svgeditstore")},expireCookie=e=>{document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT"},replaceStoragePrompt=e=>{e=e?"storagePrompt="+e:"";const t=top.location;t.href.includes("storagePrompt=")?t.href=t.href.replace(/([&?])storagePrompt=[^&]*(&?)/,(function(t,o,n){return(e?o:"")+e+(!e&&n?o:n||"")})):t.href+=(t.href.includes("?")?"&":"?")+e};var t={name:"storage",init(){const e=this,{svgCanvas:t,storage:o}=e,{noStorageOnLoad:n,forceStorage:r,canvasName:s}=e.configObj.curConfig;if(o&&(r||!n&&/(?:^|;\s*)svgeditstore=prefsAndContent/.test(document.cookie))){const t="svgedit-"+s,n=o.getItem(t);if(n){e.loadFromString(n);const r=o.getItem(`title-${t}`)??"bez_tytulu.svg";e.topPanel.updateTitle(r),e.layersPanel.populateLayers()}}const i=document.createElement("se-storage-dialog");i.setAttribute("id","se-storage-dialog"),e.$container.append(i),i.init(e.i18next),i.addEventListener("change",(t=>{if(i.setAttribute("dialog","close"),"ok"===t?.detail?.trigger){if("noPrefsOrContent"!==t?.detail?.select){const e=new URL(top.location).searchParams.get("storagePrompt");if(document.cookie="svgeditstore="+encodeURIComponent(t.detail.select)+"; expires=Fri, 31 Dec 9999 23:59:59 GMT","true"===e&&t?.detail?.checkbox)return void replaceStoragePrompt()}else if(removeStoragePrefCookie(),e.configObj.curConfig.emptyStorageOnDecline&&t?.detail?.checkbox&&(setSvgContentStorage(""),Object.keys(e.curPrefs).forEach((t=>{t="svg-edit-"+t,e.storage&&e.storage.removeItem(t),expireCookie(t)}))),t?.detail?.select&&t?.detail?.checkbox)return void replaceStoragePrompt("false")}else"cancel"===t?.detail?.trigger&&removeStoragePrefCookie();setupBeforeUnloadListener(),e.storagePromptState="closed",e.updateCanvas(!0)}));const setSvgContentStorage=t=>{const n=`svgedit-${e.configObj.curConfig.canvasName}`;t?(o.setItem(n,t),o.setItem(`title-${n}`,e.title)):(o.removeItem(n),o.removeItem(`${n}-title`))},setupBeforeUnloadListener=()=>{window.addEventListener("beforeunload",(function(){if(!/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/.test(document.cookie))return;/(?:^|;\s*)svgeditstore=prefsAndContent/.test(document.cookie)&&setSvgContentStorage(t.getSvgString()),e.setConfig({no_save_warning:!0});const{curPrefs:n}=e.configObj;Object.entries(n).forEach((e=>{let[t,n]=e;t="svg-edit-"+t,void 0!==n&&(o?o.setItem(t,n):window.widget?window.widget.setPreferenceForKey(n,t):(n=encodeURIComponent(n),document.cookie=encodeURIComponent(t)+"="+n+"; expires=Fri, 31 Dec 9999 23:59:59 GMT"))}))}))};let a=!1;return{name:"storage",callback(){const t=new URL(top.location).searchParams.get("storagePrompt");if(!a)if(a=!0,r||"true"!==t&&("false"===t||/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/.test(document.cookie)))n&&!r||setupBeforeUnloadListener();else{e.storagePromptState="waiting";document.getElementById("se-storage-dialog").dispatchEvent(new CustomEvent("change",{detail:{trigger:"ok",select:"prefsOnly",checkbox:!0}}))}}}}};export{t as default};
|
|
23
23
|
//# sourceMappingURL=ext-storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ext-storage.js","sources":["../../../../src/editor/extensions/ext-storage/storageDialog.js","../../../../src/editor/extensions/ext-storage/ext-storage.js"],"sourcesContent":["/* globals svgEditor */\nimport storageDialogHTML from './storageDialog.html'\n\nconst template = document.createElement('template')\ntemplate.innerHTML = storageDialogHTML\n/**\n * @class SeStorageDialog\n */\nexport class SeStorageDialog extends HTMLElement {\n /**\n * @function constructor\n */\n constructor () {\n super()\n // create the shadowDom and insert the template\n this._shadowRoot = this.attachShadow({ mode: 'open' })\n this._shadowRoot.append(template.content.cloneNode(true))\n this.$dialog = this._shadowRoot.querySelector('#dialog_box')\n this.$storage = this._shadowRoot.querySelector('#js-storage')\n this.$okBtn = this._shadowRoot.querySelector('#storage_ok')\n this.$cancelBtn = this._shadowRoot.querySelector('#storage_cancel')\n this.$storageInput = this._shadowRoot.querySelector('#se-storage-pref')\n this.$rememberInput = this._shadowRoot.querySelector('#se-remember')\n }\n\n /**\n * @function init\n * @param {any} name\n * @returns {void}\n */\n init (i18next) {\n this.setAttribute('common-ok', i18next.t('common.ok'))\n this.setAttribute('common-cancel', i18next.t('common.cancel'))\n this.setAttribute('notify-editor_pref_msg', i18next.t('notification.editorPreferencesMsg'))\n this.setAttribute('properties-prefs_and_content', i18next.t('properties.prefs_and_content'))\n this.setAttribute('properties-prefs_only', i18next.t('properties.prefs_only'))\n this.setAttribute('properties-no_prefs_or_content', i18next.t('properties.no_prefs_or_content'))\n this.setAttribute('tools-remember_this_choice', i18next.t('tools.remember_this_choice'))\n this.setAttribute('tools-remember_this_choice_title', i18next.t('tools.remember_this_choice_title'))\n }\n\n /**\n * @function observedAttributes\n * @returns {any} observed\n */\n static get observedAttributes () {\n return ['dialog', 'storage', 'common-ok', 'common-cancel', 'notify-editor_pref_msg', 'properties-prefs_and_content', 'tools-remember_this_choice', 'tools-remember_this_choice_title', 'properties-prefs_only', 'properties-no_prefs_or_content']\n }\n\n /**\n * @function attributeChangedCallback\n * @param {string} name\n * @param {string} oldValue\n * @param {string} newValue\n * @returns {void}\n */\n attributeChangedCallback (name, oldValue, newValue) {\n let node\n switch (name) {\n case 'dialog':\n if (newValue === 'open') {\n this.$dialog.open()\n } else {\n this.$dialog.close()\n }\n break\n case 'storage':\n if (newValue === 'true') {\n this.$storageInput.options[0].disabled = false\n } else {\n this.$storageInput.options[0].disabled = true\n }\n break\n case 'common-ok':\n this.$okBtn.textContent = newValue\n break\n case 'common-cancel':\n this.$cancelBtn.textContent = newValue\n break\n case 'notify-editor_pref_msg':\n node = this._shadowRoot.querySelector('#notificationNote')\n node.textContent = newValue\n break\n case 'properties-prefs_and_content':\n node = this._shadowRoot.querySelector('#prefsAndContent')\n node.textContent = newValue\n break\n case 'properties-prefs_only':\n node = this._shadowRoot.querySelector('#prefsOnly')\n node.textContent = newValue\n break\n case 'properties-no_prefs_or_content':\n node = this._shadowRoot.querySelector('#noPrefsOrContent')\n node.textContent = newValue\n break\n case 'tools-remember_this_choice':\n node = this._shadowRoot.querySelector('#se-remember-title')\n node.prepend(newValue)\n break\n case 'tools-remember_this_choice_title':\n node = this._shadowRoot.querySelector('#se-remember-title')\n node.setAttribute('title', newValue)\n break\n default:\n // super.attributeChangedCallback(name, oldValue, newValue);\n break\n }\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get dialog () {\n return this.getAttribute('dialog')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set dialog (value) {\n this.setAttribute('dialog', value)\n }\n\n /**\n * @function connectedCallback\n * @returns {void}\n */\n connectedCallback () {\n const onSubmitHandler = (e, action) => {\n const triggerEvent = new CustomEvent('change',\n {\n detail: {\n trigger: action,\n select: this.$storageInput.value,\n checkbox: this.$rememberInput.checked\n }\n })\n this.dispatchEvent(triggerEvent)\n }\n svgEditor.$click(this.$okBtn, (evt) => onSubmitHandler(evt, 'ok'))\n svgEditor.$click(this.$cancelBtn, (evt) => onSubmitHandler(evt, 'cancel'))\n }\n}\n\n// Register\ncustomElements.define('se-storage-dialog', SeStorageDialog)\n","/**\n * @file ext-storage.js\n *\n * This extension allows automatic saving of the SVG canvas contents upon\n * page unload (which can later be automatically retrieved upon future\n * editor loads).\n *\n * The functionality was originally part of the SVG Editor, but moved to a\n * separate extension to make the setting behavior optional, and adapted\n * to inform the user of its setting of local data.\n *\n * @license MIT\n *\n * @copyright 2010 Brett Zamir\n * @todo Revisit on whether to use `svgEditor.pref` over directly setting\n * `curConfig` in all extensions for a more public API (not only for `extPath`\n * and `imagePath`, but other currently used config in the extensions)\n * @todo We might provide control of storage settings through the UI besides the\n * initial (or URL-forced) dialog. *\n */\nimport './storageDialog.js'\n\n/**\n * Expire the storage cookie.\n * @returns {void}\n */\nconst removeStoragePrefCookie = () => {\n expireCookie('svgeditstore')\n}\n/**\n * Set the cookie to expire.\n * @param {string} cookie\n * @returns {void}\n */\nconst expireCookie = cookie => {\n document.cookie =\n encodeURIComponent(cookie) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT'\n}\n\n/**\n * Replace `storagePrompt` parameter within URL.\n * @param {string} val\n * @returns {void}\n * @todo Replace the string manipulation with `searchParams.set`\n */\nconst replaceStoragePrompt = val => {\n val = val ? 'storagePrompt=' + val : ''\n const loc = top.location // Allow this to work with the embedded editor as well\n if (loc.href.includes('storagePrompt=')) {\n loc.href = loc.href.replace(/([&?])storagePrompt=[^&]*(&?)/, function (\n n0,\n n1,\n amp\n ) {\n return (val ? n1 : '') + val + (!val && amp ? n1 : amp || '')\n })\n } else {\n loc.href += (loc.href.includes('?') ? '&' : '?') + val\n }\n}\n\nexport default {\n name: 'storage',\n init() {\n const svgEditor = this\n const { svgCanvas, storage } = svgEditor\n\n // We could empty any already-set data for users when they decline storage,\n // but it would be a risk for users who wanted to store but accidentally\n // said \"no\"; instead, we'll let those who already set it, delete it themselves;\n // to change, set the \"emptyStorageOnDecline\" config setting to true\n // in svgedit-config-iife.js/svgedit-config-es.js.\n const {\n // When the code in svg-editor.js prevents local storage on load per\n // user request, we also prevent storing on unload here so as to\n // avoid third-party sites making XSRF requests or providing links\n // which would cause the user's local storage not to load and then\n // upon page unload (such as the user closing the window), the storage\n // would thereby be set with an empty value, erasing any of the\n // user's prior work. To change this behavior so that no use of storage\n // or adding of new storage takes place regardless of settings, set\n // the \"noStorageOnLoad\" config setting to true in svgedit-config-*.js.\n noStorageOnLoad,\n forceStorage,\n canvasName\n } = svgEditor.configObj.curConfig\n\n // LOAD STORAGE CONTENT IF ANY\n if (\n storage && // Cookies do not have enough available memory to hold large documents\n (forceStorage ||\n (!noStorageOnLoad &&\n /(?:^|;\\s*)svgeditstore=prefsAndContent/.test(document.cookie)))\n ) {\n const key = 'svgedit-' + canvasName\n const cached = storage.getItem(key)\n if (cached) {\n svgEditor.loadFromString(cached)\n const name = storage.getItem(`title-${key}`) ?? 'bez_tytulu.svg'\n svgEditor.topPanel.updateTitle(name)\n svgEditor.layersPanel.populateLayers()\n }\n }\n\n // storageDialog added to DOM\n const storageBox = document.createElement('se-storage-dialog')\n storageBox.setAttribute('id', 'se-storage-dialog')\n svgEditor.$container.append(storageBox)\n storageBox.init(svgEditor.i18next)\n\n // manage the change in the storageDialog\n\n storageBox.addEventListener('change', e => {\n storageBox.setAttribute('dialog', 'close')\n if (e?.detail?.trigger === 'ok') {\n if (e?.detail?.select !== 'noPrefsOrContent') {\n const storagePrompt = new URL(top.location).searchParams.get(\n 'storagePrompt'\n )\n document.cookie =\n 'svgeditstore=' +\n encodeURIComponent(e.detail.select) +\n '; expires=Fri, 31 Dec 9999 23:59:59 GMT'\n if (storagePrompt === 'true' && e?.detail?.checkbox) {\n replaceStoragePrompt()\n return\n }\n } else {\n removeStoragePrefCookie()\n if (\n svgEditor.configObj.curConfig.emptyStorageOnDecline &&\n e?.detail?.checkbox\n ) {\n setSvgContentStorage('')\n Object.keys(svgEditor.curPrefs).forEach(name => {\n name = 'svg-edit-' + name\n if (svgEditor.storage) {\n svgEditor.storage.removeItem(name)\n }\n expireCookie(name)\n })\n }\n if (e?.detail?.select && e?.detail?.checkbox) {\n replaceStoragePrompt('false')\n return\n }\n }\n } else if (e?.detail?.trigger === 'cancel') {\n removeStoragePrefCookie()\n }\n setupBeforeUnloadListener()\n svgEditor.storagePromptState = 'closed'\n svgEditor.updateCanvas(true)\n })\n\n /**\n * Sets SVG content as a string with \"svgedit-\" and the current\n * canvas name as namespace.\n * @param {string} svgString\n * @returns {void}\n */\n const setSvgContentStorage = svgString => {\n const name = `svgedit-${svgEditor.configObj.curConfig.canvasName}`\n if (!svgString) {\n storage.removeItem(name)\n storage.removeItem(`${name}-title`)\n } else {\n storage.setItem(name, svgString)\n storage.setItem(`title-${name}`, svgEditor.title)\n }\n }\n\n /**\n * Listen for unloading: If and only if opted in by the user, set the content\n * document and preferences into storage:\n * 1. Prevent save warnings (since we're automatically saving unsaved\n * content into storage)\n * 2. Use localStorage to set SVG contents (potentially too large to allow in cookies)\n * 3. Use localStorage (where available) or cookies to set preferences.\n * @returns {void}\n */\n const setupBeforeUnloadListener = () => {\n return;\n window.addEventListener('beforeunload', function () {\n // Don't save anything unless the user opted in to storage\n if (\n !/(?:^|;\\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/.test(\n document.cookie\n )\n ) {\n return\n }\n if (/(?:^|;\\s*)svgeditstore=prefsAndContent/.test(document.cookie)) {\n setSvgContentStorage(svgCanvas.getSvgString())\n }\n\n svgEditor.setConfig({ no_save_warning: true }) // No need for explicit saving at all once storage is on\n\n const { curPrefs } = svgEditor.configObj\n\n Object.entries(curPrefs).forEach(([key, val]) => {\n const store = val !== undefined\n key = 'svg-edit-' + key\n if (!store) {\n return\n }\n if (storage) {\n storage.setItem(key, val)\n } else if (window.widget) {\n window.widget.setPreferenceForKey(val, key)\n } else {\n val = encodeURIComponent(val)\n document.cookie =\n encodeURIComponent(key) +\n '=' +\n val +\n '; expires=Fri, 31 Dec 9999 23:59:59 GMT'\n }\n })\n })\n }\n\n let loaded = false\n return {\n name: 'storage',\n callback() {\n // Prevent from showing storage dialog\n return;\n const storagePrompt = new URL(top.location).searchParams.get(\n 'storagePrompt'\n )\n // No need to run this one-time dialog again just because the user\n // changes the language\n if (loaded) {\n return\n }\n loaded = true\n\n // Note that the following can load even if \"noStorageOnLoad\" is\n // set to false; to avoid any chance of storage, avoid this\n // extension! (and to avoid using any prior storage, set the\n // config option \"noStorageOnLoad\" to true).\n if (\n !forceStorage &&\n // If the URL has been explicitly set to always prompt the\n // user (e.g., so one can be pointed to a URL where one\n // can alter one's settings, say to prevent future storage)...\n (storagePrompt === 'true' ||\n // ...or...if the URL at least doesn't explicitly prevent a\n // storage prompt (as we use for users who\n // don't want to set cookies at all but who don't want\n // continual prompts about it)...\n (storagePrompt !== 'false' &&\n // ...and this user hasn't previously indicated a desire for storage\n !/(?:^|;\\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/.test(\n document.cookie\n )))\n // ...then show the storage prompt.\n ) {\n const options = Boolean(storage)\n // Open select-with-checkbox dialog\n // From svg-editor.js\n svgEditor.storagePromptState = 'waiting'\n const $storageDialog = document.getElementById('se-storage-dialog')\n $storageDialog.setAttribute('dialog', 'open')\n $storageDialog.setAttribute('storage', options)\n } else if (!noStorageOnLoad || forceStorage) {\n setupBeforeUnloadListener()\n }\n }\n }\n }\n}\n"],"names":["template","document","createElement","innerHTML","SeStorageDialog","HTMLElement","constructor","super","this","_shadowRoot","attachShadow","mode","append","content","cloneNode","$dialog","querySelector","$storage","$okBtn","$cancelBtn","$storageInput","$rememberInput","init","i18next","setAttribute","t","observedAttributes","attributeChangedCallback","name","oldValue","newValue","node","open","close","options","disabled","textContent","prepend","dialog","getAttribute","value","connectedCallback","onSubmitHandler","e","action","triggerEvent","CustomEvent","detail","trigger","select","checkbox","checked","dispatchEvent","svgEditor","$click","evt","customElements","define","removeStoragePrefCookie","expireCookie","cookie","encodeURIComponent","replaceStoragePrompt","val","loc","top","location","href","includes","replace","n0","n1","amp","extStorage","svgCanvas","storage","noStorageOnLoad","forceStorage","canvasName","configObj","curConfig","test","key","cached","getItem","loadFromString","topPanel","updateTitle","layersPanel","populateLayers","storageBox","$container","addEventListener","storagePrompt","URL","searchParams","get","emptyStorageOnDecline","setSvgContentStorage","Object","keys","curPrefs","forEach","removeItem","setupBeforeUnloadListener","storagePromptState","updateCanvas","svgString","callback"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"ext-storage.js","sources":["../../../../src/editor/extensions/ext-storage/storageDialog.js","../../../../src/editor/extensions/ext-storage/ext-storage.js"],"sourcesContent":["/* globals svgEditor */\nimport storageDialogHTML from './storageDialog.html'\n\nconst template = document.createElement('template')\ntemplate.innerHTML = storageDialogHTML\n/**\n * @class SeStorageDialog\n */\nexport class SeStorageDialog extends HTMLElement {\n /**\n * @function constructor\n */\n constructor() {\n super()\n // create the shadowDom and insert the template\n this._shadowRoot = this.attachShadow({ mode: 'open' })\n this._shadowRoot.append(template.content.cloneNode(true))\n this.$dialog = this._shadowRoot.querySelector('#dialog_box')\n this.$storage = this._shadowRoot.querySelector('#js-storage')\n this.$okBtn = this._shadowRoot.querySelector('#storage_ok')\n this.$cancelBtn = this._shadowRoot.querySelector('#storage_cancel')\n this.$storageInput = this._shadowRoot.querySelector('#se-storage-pref')\n this.$rememberInput = this._shadowRoot.querySelector('#se-remember')\n }\n\n /**\n * @function init\n * @param {any} name\n * @returns {void}\n */\n init(i18next) {\n this.setAttribute('common-ok', i18next.t('common.ok'))\n this.setAttribute('common-cancel', i18next.t('common.cancel'))\n this.setAttribute('notify-editor_pref_msg', i18next.t('notification.editorPreferencesMsg'))\n this.setAttribute('properties-prefs_and_content', i18next.t('properties.prefs_and_content'))\n this.setAttribute('properties-prefs_only', i18next.t('properties.prefs_only'))\n this.setAttribute('properties-no_prefs_or_content', i18next.t('properties.no_prefs_or_content'))\n this.setAttribute('tools-remember_this_choice', i18next.t('tools.remember_this_choice'))\n this.setAttribute('tools-remember_this_choice_title', i18next.t('tools.remember_this_choice_title'))\n }\n\n /**\n * @function observedAttributes\n * @returns {any} observed\n */\n static get observedAttributes() {\n return ['dialog', 'storage', 'common-ok', 'common-cancel', 'notify-editor_pref_msg', 'properties-prefs_and_content', 'tools-remember_this_choice', 'tools-remember_this_choice_title', 'properties-prefs_only', 'properties-no_prefs_or_content']\n }\n\n /**\n * @function attributeChangedCallback\n * @param {string} name\n * @param {string} oldValue\n * @param {string} newValue\n * @returns {void}\n */\n attributeChangedCallback(name, oldValue, newValue) {\n let node\n switch (name) {\n case 'dialog':\n if (newValue === 'open') {\n this.$dialog.open()\n } else {\n this.$dialog.close()\n }\n break\n case 'storage':\n if (newValue === 'true') {\n this.$storageInput.options[0].disabled = false\n } else {\n this.$storageInput.options[0].disabled = true\n }\n break\n case 'common-ok':\n this.$okBtn.textContent = newValue\n break\n case 'common-cancel':\n this.$cancelBtn.textContent = newValue\n break\n case 'notify-editor_pref_msg':\n node = this._shadowRoot.querySelector('#notificationNote')\n node.textContent = newValue\n break\n case 'properties-prefs_and_content':\n node = this._shadowRoot.querySelector('#prefsAndContent')\n node.textContent = newValue\n break\n case 'properties-prefs_only':\n node = this._shadowRoot.querySelector('#prefsOnly')\n node.textContent = newValue\n break\n case 'properties-no_prefs_or_content':\n node = this._shadowRoot.querySelector('#noPrefsOrContent')\n node.textContent = newValue\n break\n case 'tools-remember_this_choice':\n node = this._shadowRoot.querySelector('#se-remember-title')\n node.prepend(newValue)\n break\n case 'tools-remember_this_choice_title':\n node = this._shadowRoot.querySelector('#se-remember-title')\n node.setAttribute('title', newValue)\n break\n default:\n // super.attributeChangedCallback(name, oldValue, newValue);\n break\n }\n }\n\n /**\n * @function get\n * @returns {any}\n */\n get dialog() {\n return this.getAttribute('dialog')\n }\n\n /**\n * @function set\n * @returns {void}\n */\n set dialog(value) {\n this.setAttribute('dialog', value)\n }\n\n /**\n * @function connectedCallback\n * @returns {void}\n */\n connectedCallback() {\n const onSubmitHandler = (e, action) => {\n const triggerEvent = new CustomEvent('change',\n {\n detail: {\n trigger: action,\n select: this.$storageInput.value,\n checkbox: this.$rememberInput.checked\n }\n })\n this.dispatchEvent(triggerEvent)\n }\n svgEditor.$click(this.$okBtn, (evt) => onSubmitHandler(evt, 'ok'))\n svgEditor.$click(this.$cancelBtn, (evt) => onSubmitHandler(evt, 'cancel'))\n }\n}\n\n// Register\ncustomElements.define('se-storage-dialog', SeStorageDialog)\n","/**\n * @file ext-storage.js\n *\n * This extension allows automatic saving of the SVG canvas contents upon\n * page unload (which can later be automatically retrieved upon future\n * editor loads).\n *\n * The functionality was originally part of the SVG Editor, but moved to a\n * separate extension to make the setting behavior optional, and adapted\n * to inform the user of its setting of local data.\n *\n * @license MIT\n *\n * @copyright 2010 Brett Zamir\n * @todo Revisit on whether to use `svgEditor.pref` over directly setting\n * `curConfig` in all extensions for a more public API (not only for `extPath`\n * and `imagePath`, but other currently used config in the extensions)\n * @todo We might provide control of storage settings through the UI besides the\n * initial (or URL-forced) dialog. *\n */\nimport './storageDialog.js'\n\n/**\n * Expire the storage cookie.\n * @returns {void}\n */\nconst removeStoragePrefCookie = () => {\n expireCookie('svgeditstore')\n}\n/**\n * Set the cookie to expire.\n * @param {string} cookie\n * @returns {void}\n */\nconst expireCookie = cookie => {\n document.cookie =\n encodeURIComponent(cookie) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT'\n}\n\n/**\n * Replace `storagePrompt` parameter within URL.\n * @param {string} val\n * @returns {void}\n * @todo Replace the string manipulation with `searchParams.set`\n */\nconst replaceStoragePrompt = val => {\n val = val ? 'storagePrompt=' + val : ''\n const loc = top.location // Allow this to work with the embedded editor as well\n if (loc.href.includes('storagePrompt=')) {\n loc.href = loc.href.replace(/([&?])storagePrompt=[^&]*(&?)/, function (\n n0,\n n1,\n amp\n ) {\n return (val ? n1 : '') + val + (!val && amp ? n1 : amp || '')\n })\n } else {\n loc.href += (loc.href.includes('?') ? '&' : '?') + val\n }\n}\n\nexport default {\n name: 'storage',\n init() {\n const svgEditor = this\n const { svgCanvas, storage } = svgEditor\n\n // We could empty any already-set data for users when they decline storage,\n // but it would be a risk for users who wanted to store but accidentally\n // said \"no\"; instead, we'll let those who already set it, delete it themselves;\n // to change, set the \"emptyStorageOnDecline\" config setting to true\n // in svgedit-config-iife.js/svgedit-config-es.js.\n const {\n // When the code in svg-editor.js prevents local storage on load per\n // user request, we also prevent storing on unload here so as to\n // avoid third-party sites making XSRF requests or providing links\n // which would cause the user's local storage not to load and then\n // upon page unload (such as the user closing the window), the storage\n // would thereby be set with an empty value, erasing any of the\n // user's prior work. To change this behavior so that no use of storage\n // or adding of new storage takes place regardless of settings, set\n // the \"noStorageOnLoad\" config setting to true in svgedit-config-*.js.\n noStorageOnLoad,\n forceStorage,\n canvasName\n } = svgEditor.configObj.curConfig\n\n // LOAD STORAGE CONTENT IF ANY\n if (\n storage && // Cookies do not have enough available memory to hold large documents\n (forceStorage ||\n (!noStorageOnLoad &&\n /(?:^|;\\s*)svgeditstore=prefsAndContent/.test(document.cookie)))\n ) {\n const key = 'svgedit-' + canvasName\n const cached = storage.getItem(key)\n if (cached) {\n svgEditor.loadFromString(cached)\n const name = storage.getItem(`title-${key}`) ?? 'bez_tytulu.svg'\n svgEditor.topPanel.updateTitle(name)\n svgEditor.layersPanel.populateLayers()\n }\n }\n\n // storageDialog added to DOM\n const storageBox = document.createElement('se-storage-dialog')\n storageBox.setAttribute('id', 'se-storage-dialog')\n svgEditor.$container.append(storageBox)\n storageBox.init(svgEditor.i18next)\n\n // manage the change in the storageDialog\n\n storageBox.addEventListener('change', e => {\n storageBox.setAttribute('dialog', 'close')\n if (e?.detail?.trigger === 'ok') {\n if (e?.detail?.select !== 'noPrefsOrContent') {\n const storagePrompt = new URL(top.location).searchParams.get(\n 'storagePrompt'\n )\n document.cookie =\n 'svgeditstore=' +\n encodeURIComponent(e.detail.select) +\n '; expires=Fri, 31 Dec 9999 23:59:59 GMT'\n if (storagePrompt === 'true' && e?.detail?.checkbox) {\n replaceStoragePrompt()\n return\n }\n } else {\n removeStoragePrefCookie()\n if (\n svgEditor.configObj.curConfig.emptyStorageOnDecline &&\n e?.detail?.checkbox\n ) {\n setSvgContentStorage('')\n Object.keys(svgEditor.curPrefs).forEach(name => {\n name = 'svg-edit-' + name\n if (svgEditor.storage) {\n svgEditor.storage.removeItem(name)\n }\n expireCookie(name)\n })\n }\n if (e?.detail?.select && e?.detail?.checkbox) {\n replaceStoragePrompt('false')\n return\n }\n }\n } else if (e?.detail?.trigger === 'cancel') {\n removeStoragePrefCookie()\n }\n setupBeforeUnloadListener()\n svgEditor.storagePromptState = 'closed'\n svgEditor.updateCanvas(true)\n })\n\n /**\n * Sets SVG content as a string with \"svgedit-\" and the current\n * canvas name as namespace.\n * @param {string} svgString\n * @returns {void}\n */\n const setSvgContentStorage = svgString => {\n const name = `svgedit-${svgEditor.configObj.curConfig.canvasName}`\n if (!svgString) {\n storage.removeItem(name)\n storage.removeItem(`${name}-title`)\n } else {\n storage.setItem(name, svgString)\n storage.setItem(`title-${name}`, svgEditor.title)\n }\n }\n\n /**\n * Listen for unloading: If and only if opted in by the user, set the content\n * document and preferences into storage:\n * 1. Prevent save warnings (since we're automatically saving unsaved\n * content into storage)\n * 2. Use localStorage to set SVG contents (potentially too large to allow in cookies)\n * 3. Use localStorage (where available) or cookies to set preferences.\n * @returns {void}\n */\n const setupBeforeUnloadListener = () => {\n window.addEventListener('beforeunload', function () {\n // Don't save anything unless the user opted in to storage\n if (\n !/(?:^|;\\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/.test(\n document.cookie\n )\n ) {\n return\n }\n if (/(?:^|;\\s*)svgeditstore=prefsAndContent/.test(document.cookie)) {\n setSvgContentStorage(svgCanvas.getSvgString())\n }\n\n svgEditor.setConfig({ no_save_warning: true }) // No need for explicit saving at all once storage is on\n\n const { curPrefs } = svgEditor.configObj\n\n Object.entries(curPrefs).forEach(([key, val]) => {\n const store = val !== undefined\n key = 'svg-edit-' + key\n if (!store) {\n return\n }\n if (storage) {\n storage.setItem(key, val)\n } else if (window.widget) {\n window.widget.setPreferenceForKey(val, key)\n } else {\n val = encodeURIComponent(val)\n document.cookie =\n encodeURIComponent(key) +\n '=' +\n val +\n '; expires=Fri, 31 Dec 9999 23:59:59 GMT'\n }\n })\n })\n }\n\n let loaded = false\n return {\n name: 'storage',\n callback() {\n const storagePrompt = new URL(top.location).searchParams.get(\n 'storagePrompt'\n )\n // No need to run this one-time dialog again just because the user\n // changes the language\n if (loaded) {\n return\n }\n loaded = true\n\n // Note that the following can load even if \"noStorageOnLoad\" is\n // set to false; to avoid any chance of storage, avoid this\n // extension! (and to avoid using any prior storage, set the\n // config option \"noStorageOnLoad\" to true).\n if (\n !forceStorage &&\n // If the URL has been explicitly set to always prompt the\n // user (e.g., so one can be pointed to a URL where one\n // can alter one's settings, say to prevent future storage)...\n (storagePrompt === 'true' ||\n // ...or...if the URL at least doesn't explicitly prevent a\n // storage prompt (as we use for users who\n // don't want to set cookies at all but who don't want\n // continual prompts about it)...\n (storagePrompt !== 'false' &&\n // ...and this user hasn't previously indicated a desire for storage\n !/(?:^|;\\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/.test(\n document.cookie\n )))\n // ...then show the storage prompt.\n ) {\n const options = Boolean(storage)\n // Open select-with-checkbox dialog\n // From svg-editor.js\n svgEditor.storagePromptState = 'waiting'\n const $storageDialog = document.getElementById('se-storage-dialog');\n\n const forceSavePreferencesLocally = true;\n\n if (forceSavePreferencesLocally) {\n $storageDialog.dispatchEvent(\n new CustomEvent(\n 'change',\n {\n detail: {\n \"trigger\": \"ok\",\n \"select\": \"prefsOnly\",\n \"checkbox\": true\n }\n }\n )\n )\n } else {\n $storageDialog.setAttribute('dialog', 'open');\n $storageDialog.setAttribute('storage', options);\n }\n } else if (!noStorageOnLoad || forceStorage) {\n setupBeforeUnloadListener()\n }\n }\n }\n }\n}\n"],"names":["template","document","createElement","innerHTML","SeStorageDialog","HTMLElement","constructor","super","this","_shadowRoot","attachShadow","mode","append","content","cloneNode","$dialog","querySelector","$storage","$okBtn","$cancelBtn","$storageInput","$rememberInput","init","i18next","setAttribute","t","observedAttributes","attributeChangedCallback","name","oldValue","newValue","node","open","close","options","disabled","textContent","prepend","dialog","getAttribute","value","connectedCallback","onSubmitHandler","e","action","triggerEvent","CustomEvent","detail","trigger","select","checkbox","checked","dispatchEvent","svgEditor","$click","evt","customElements","define","removeStoragePrefCookie","expireCookie","cookie","encodeURIComponent","replaceStoragePrompt","val","loc","top","location","href","includes","replace","n0","n1","amp","extStorage","svgCanvas","storage","noStorageOnLoad","forceStorage","canvasName","configObj","curConfig","test","key","cached","getItem","loadFromString","topPanel","updateTitle","layersPanel","populateLayers","storageBox","$container","addEventListener","storagePrompt","URL","searchParams","get","emptyStorageOnDecline","setSvgContentStorage","Object","keys","curPrefs","forEach","removeItem","setupBeforeUnloadListener","storagePromptState","updateCanvas","svgString","setItem","title","window","getSvgString","setConfig","no_save_warning","entries","_ref","undefined","widget","setPreferenceForKey","loaded","callback","getElementById"],"mappings":"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"}
|
|
@@ -1040,7 +1040,7 @@ var V_=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,
|
|
|
1040
1040
|
* @module contextmenu
|
|
1041
1041
|
* @license Apache-2.0
|
|
1042
1042
|
* @author Adam Bender
|
|
1043
|
-
*/let Om={};const injectExtendedContextMenuItemsIntoDom=function(){Object.values(Om).forEach((Tr=>{!function(Tr){Object.keys(Om).length||document.getElementById("cmenu_canvas").appendChild("<li class='separator'>");const Ur=Tr.shortcut||"";document.getElementById("cmenu_canvas").appendChild(`\n <li class='disabled'><a href='#${Tr.id}'>${Tr.label}<span class='shortcut'>${Ur}</span></a></li>`)}(Tr)}))};const{$id:Qm,getTypeMap:Vm}=SvgCanvas;class Rulers{constructor(Tr){this.rulerIntervals=[];for(let Tr=.1;Tr<1e5;Tr*=10)this.rulerIntervals.push(Tr),this.rulerIntervals.push(2*Tr),this.rulerIntervals.push(5*Tr);this.svgCanvas=Tr.svgCanvas,this.editor=Tr;const Ur=document.createElement("template");Ur.innerHTML='<style>\n /* Rulers\n——————————————————————————————————————*/\n\n #ruler_corner {\n background: var(--ruler-color);\n grid-area: corner;\n width: 15px;\n height: 15px;\n overflow: hidden;\n }\n\n #ruler_x {\n background: var(--ruler-color);\n grid-area: rulerX;\n height: 15px;\n border-bottom: 1px solid;\n border-left: 1px solid #777;\n overflow: hidden;\n }\n\n #ruler_y {\n background: var(--ruler-color);\n grid-area: rulerY;\n width: 15px;\n border-right: 1px solid;\n border-top: 1px solid #777;\n overflow: hidden;\n }\n\n #ruler_x canvas {\n float: left;\n }\n</style>\n<div id="ruler_corner"></div>\n<div id="ruler_x">\n <div>\n <canvas height="15"></canvas>\n </div>\n</div>\n<div id="ruler_y">\n <div>\n <canvas width="15"></canvas>\n </div>\n</div>',this.editor.$svgEditor.append(Ur.content.cloneNode(!0));const{$id:Rr}=SvgCanvas;this.rulerX=Rr("ruler_x"),this.rulerY=Rr("ruler_y"),this.rulerCorner=Rr("ruler_corner")}display(Tr){Tr?(this.rulerX.style.removeProperty("display"),this.rulerY.style.removeProperty("display"),this.rulerCorner.style.removeProperty("display")):(this.rulerX.style.display="none",this.rulerY.style.display="none",this.rulerCorner.style.display="none")}manageScroll(){this.rulerX&&(this.rulerX.scrollLeft=this.editor.workarea.scrollLeft),this.rulerY&&(this.rulerY.scrollTop=this.editor.workarea.scrollTop)}updateRulers(Tr,Ur){let Rr,Qr;Ur||(Ur=this.svgCanvas.getZoom()),Tr||(Tr=document.getElementById("svgcanvas"));const Vr=3e4,Gr=this.svgCanvas.getSvgContent(),Dr=Vm()[this.editor.configObj.curConfig.baseUnit];for(Rr=0;Rr<2;Rr++){const Hr=0===Rr,zr=Hr?"x":"y",Kr=Hr?"width":"height",$r=Number(Gr.getAttribute(zr)),Wr=Qm("ruler_"+zr).querySelector("canvas"),Xr=Wr.cloneNode(!0);Wr.replaceWith(Xr);const Yr=Xr;let Zr;"width"===Kr?Zr=parseFloat(getComputedStyle(Tr,null).width.replace("px","")):"height"===Kr&&(Zr=parseFloat(getComputedStyle(Tr,null).height.replace("px","")));const Jr=Zr;Yr.parentNode.style[Kr]=Jr+"px";let en,tn,rn,nn=Yr.getContext("2d");nn.fillStyle="rgb(200,0,0)",nn.fillRect(0,0,Yr.width,Yr.height);const on=Array.prototype.filter.call(Xr.parentNode.children,(function(Tr){return Tr!==Xr}));if(Array.from(on).forEach((function(Tr){Tr.remove()})),Zr>=Vr){let Tr;for(rn=Number.parseInt(Zr/Vr)+1,en=[],en[0]=nn,Qr=1;Qr<rn;Qr++)Yr[Kr]=Vr,Tr=Yr.cloneNode(!0),Yr.parentNode.append(Tr),en[Qr]=Tr.getContext("2d");Tr[Kr]=Zr%Vr,Zr=Vr}Yr[Kr]=Zr;const an=Dr*Ur,sn=50/an;let cn=1;for(Qr=0;Qr<this.rulerIntervals.length&&(tn=this.rulerIntervals[Qr],cn=tn,!(sn<=tn));Qr++);const An=cn*an;nn.font="9px sans-serif";let un=$r/an%cn*an,dn=un-An,pn=0;for(;un<Jr;){dn+=An;const Tr=Math.round(un)+.5;let Ur;if(Hr?(nn.moveTo(Tr,15),nn.lineTo(Tr,0)):(nn.moveTo(15,Tr),nn.lineTo(0,Tr)),tn=(dn-$r)/an,cn>=1)Ur=Math.round(tn);else{const Tr=String(cn).split(".")[1].length;Ur=tn.toFixed(Tr)}if(0!==Ur&&1e3!==Ur&&Ur%1e3==0&&(Ur=Ur/1e3+"K"),Hr)nn.fillText(Ur,un+2,8);else{const Tr=String(Ur).split("");for(Qr=0;Qr<Tr.length;Qr++)nn.fillText(Tr[Qr],1,un+9+9*Qr)}const Rr=An/10;for(Qr=1;Qr<10;Qr++){let Tr=Math.round(un+Rr*Qr)+.5;if(en&&Tr>Zr){if(pn++,nn.stroke(),pn>=rn){Qr=10,un=Jr;continue}nn=en[pn],un-=Vr,Tr=Math.round(un+Rr*Qr)+.5}const Ur=Qr%2?12:10;Hr?(nn.moveTo(Tr,15),nn.lineTo(Tr,Ur)):(nn.moveTo(15,Tr),nn.lineTo(Ur,Tr))}un+=An}nn.strokeStyle="#000",nn.stroke()}}}const{$id:Gm,$qq:Dm,$click:Hm,convertUnit:zm}=SvgCanvas;class EditorStartup{constructor(Tr){this.extensionsAdded=!1,this.messageQueue=[],this.$container=Tr??Gm("svg_editor")}async init(){"localStorage"in window&&(this.storage=window.localStorage),this.configObj.load();const{i18next:Tr}=await putLocale(this.configObj.pref("lang"),this.goodLangs);this.i18next=Tr,await Promise.resolve().then((function(){return wm})),await Promise.resolve().then((function(){return Um}));try{const Tr=document.createElement("template");Tr.innerHTML='<div class="svg_editor">\n <div id="workarea">\n <div id="svgcanvas"></div>\n </div>\n</div>',this.$container.append(Tr.content.cloneNode(!0)),this.$svgEditor=Dm(".svg_editor"),this.$svgEditor.style.visibility="hidden",this.workarea=Gm("workarea");const Ur=document.createElement("se-img-prop-dialog");Ur.setAttribute("id","se-img-prop"),this.$container.append(Ur),Ur.init(this.i18next);const Rr=document.createElement("se-edit-prefs-dialog");Rr.setAttribute("id","se-edit-prefs"),this.$container.append(Rr),Rr.init(this.i18next);const Qr=document.createElement("se-cmenu_canvas-dialog");Qr.setAttribute("id","se-cmenu_canvas"),this.$container.append(Qr),Qr.init(this.i18next);const Vr=document.createElement("se-alert-dialog");Vr.setAttribute("id","se-alert-dialog"),this.$container.append(Vr);const Gr=document.createElement("se-prompt-dialog");Gr.setAttribute("id","se-prompt-dialog"),this.$container.append(Gr);const Dr=document.createElement("se-export-dialog");Dr.setAttribute("id","se-export-dialog"),this.$container.append(Dr),Dr.init(this.i18next)}catch(Tr){console.error(Tr)}this.svgCanvas=new SvgCanvas(Gm("svgcanvas"),this.configObj.curConfig),this.modeEvent=this.svgCanvas.modeEvent,document.addEventListener("modeChange",(Tr=>this.modeListener(Tr))),this.enableToolCancel=!0,this.leftPanel.init(),this.bottomPanel.init(),this.topPanel.init(),this.layersPanel.init(),this.mainMenu.init(),this.svgCanvas,this.canvMenu=Gm("se-cmenu_canvas"),this.exportWindow=null,this.defaultImageURL=`${this.configObj.curConfig.imgPath}/logo.svg`;this.uiContext="toolbars",(()=>{const Tr=window.opener||window.parent;if(Tr)try{const Ur=new Tr.CustomEvent("svgEditorReady",{bubbles:!0,cancelable:!0});Tr.document.documentElement.dispatchEvent(Ur)}catch(Tr){}})(),this.rulers=new Rulers(this),this.layersPanel.populateLayers(),this.selectedElement=null,this.multiselected=!1;const Ur=Gm("cur_context_panel");Hm(Ur,(Tr=>{const Ur=Tr.target;return Ur.hasAttribute("data-root")?this.svgCanvas.leaveContext():this.svgCanvas.setContext(Ur.textContent),this.svgCanvas.clearSelection(),!1})),this.svgCanvas.bind("selected",this.selectedChanged.bind(this)),this.svgCanvas.bind("transition",this.elementTransition.bind(this)),this.svgCanvas.bind("changed",this.elementChanged.bind(this)),this.svgCanvas.bind("exported",this.exportHandler.bind(this)),this.svgCanvas.bind("exportedPDF",function(Tr,Ur){if(!Ur.output)return;const{exportWindowName:Rr}=Ur;Rr&&(this.exportWindow=window.open("",this.exportWindowName)),this.exportWindow&&!this.exportWindow.closed?this.exportWindow.location.href=Ur.output:seAlert(this.i18next.t("notification.popupWindowBlocked"))}.bind(this)),this.svgCanvas.bind("zoomed",this.zoomChanged.bind(this)),this.svgCanvas.bind("zoomDone",this.zoomDone.bind(this)),this.svgCanvas.bind("updateCanvas",function(Tr,Ur){let{center:Rr,newCtr:Qr}=Ur;this.updateCanvas(Rr,Qr)}.bind(this)),this.svgCanvas.bind("contextset",this.contextChanged.bind(this)),this.svgCanvas.bind("extension_added",this.extAdded.bind(this)),this.svgCanvas.bind("elementRenamed",this.elementRenamed.bind(this)),this.svgCanvas.bind("beforeClear",this.beforeClear.bind(this)),this.svgCanvas.bind("afterClear",this.afterClear.bind(this)),this.svgCanvas.textActions.setInputElem(Gm("text")),this.setBackground(this.configObj.pref("bkgd_color"),this.configObj.pref("bkgd_url"));const Rr=this.svgCanvas.getResolution();"px"!==this.configObj.curConfig.baseUnit&&(Rr.w=zm(Rr.w)+this.configObj.curConfig.baseUnit,Rr.h=zm(Rr.h)+this.configObj.curConfig.baseUnit),Gm("se-img-prop").setAttribute("dialog","close"),Gm("se-img-prop").setAttribute("title",this.svgCanvas.getDocumentTitle()),Gm("se-img-prop").setAttribute("width",Rr.w),Gm("se-img-prop").setAttribute("height",Rr.h),Gm("se-img-prop").setAttribute("save",this.configObj.pref("img_save"));const Qr=document.querySelectorAll("select");Array.from(Qr).forEach((function(Tr){Tr.addEventListener("change",(function(Tr){Tr.currentTarget.blur()}))}));let Vr=!1;Gm("selLayerNames").addEventListener("change",(Tr=>{const Ur=Tr.detail.value,Rr=this.i18next.t("notification.QmoveElemsToLayer").replace("%s",Ur),moveToLayer=Tr=>{Vr=!0,this.svgCanvas.moveSelectedToLayer(Ur),this.svgCanvas.clearSelection(),this.layersPanel.populateLayers()};if(Ur)if(Vr)moveToLayer();else{if(!seConfirm(Rr))return;moveToLayer()}})),Gm("tool_font_family").addEventListener("change",(Tr=>{this.svgCanvas.setFontFamily(Tr.detail.value)})),Gm("seg_type").addEventListener("change",(Tr=>{this.svgCanvas.setSegType(Tr.detail.value)}));const addListenerMulti=(Tr,Ur,Rr)=>{Ur.split(" ").forEach((Ur=>Tr.addEventListener(Ur,Rr,!1)))};addListenerMulti(Gm("text"),"keyup input",(Tr=>{this.svgCanvas.setTextContent(Tr.currentTarget.value)})),Gm("link_url").addEventListener("change",(Tr=>{Tr.currentTarget.value.length?this.svgCanvas.setLinkURL(Tr.currentTarget.value):this.svgCanvas.removeHyperlink()})),Gm("g_title").addEventListener("change",(Tr=>{this.svgCanvas.setGroupTitle(Tr.currentTarget.value)}));let Gr,Dr=null,Hr=null,zr=!1,Kr=!1,$r="select";Gm("svgcanvas").addEventListener("mouseup",(Tr=>!1===zr||(this.workarea.scrollLeft-=Tr.clientX-Dr,this.workarea.scrollTop-=Tr.clientY-Hr,Dr=Tr.clientX,Hr=Tr.clientY,"mouseup"===Tr.type&&(zr=!1),!1))),Gm("svgcanvas").addEventListener("mousemove",(Tr=>!1===zr||(this.workarea.scrollLeft-=Tr.clientX-Dr,this.workarea.scrollTop-=Tr.clientY-Hr,Dr=Tr.clientX,Hr=Tr.clientY,"mouseup"===Tr.type&&(zr=!1),!1))),Gm("svgcanvas").addEventListener("mousedown",(Tr=>(this.enableToolCancel=!1,1!==Tr.button&&!0!==Kr||(Tr.preventDefault(),zr=!0,$r=this.svgCanvas.getMode(),this.svgCanvas.setMode("ext-panning"),this.workarea.style.cursor="grab",Dr=Tr.clientX,Hr=Tr.clientY,!1)))),this.$container.addEventListener("wheel",(Tr=>{Tr.ctrlKey&&Tr.preventDefault()})),window.addEventListener("mouseup",(Tr=>{this.enableToolCancel=!0,1===Tr.button&&this.svgCanvas.setMode($r??"select"),zr=!1})),this.workarea.addEventListener("dblclick",(Tr=>{"ext-panning"===this.svgCanvas.getMode()&&this.leftPanel.clickSelect()})),document.addEventListener("keydown",(Tr=>{"BODY"===Tr.target.nodeName&&("space"===Tr.code.toLowerCase()?(this.svgCanvas.spaceKey=Kr=!0,Tr.preventDefault()):"shift"===Tr.key.toLowerCase()&&"zoom"===this.svgCanvas.getMode()&&(this.workarea.style.cursor="crosshair",Tr.preventDefault()))})),document.addEventListener("keyup",(Tr=>{"BODY"===Tr.target.nodeName&&("space"===Tr.code.toLowerCase()?(this.svgCanvas.spaceKey=Kr=!1,this.svgCanvas.setMode("ext-panning"===$r?"select":$r??"select"),Tr.preventDefault()):"shift"===Tr.key.toLowerCase()&&"zoom"===this.svgCanvas.getMode()&&(this.workarea.style.cursor="crosshair",Tr.preventDefault()))})),this.setPanning=Tr=>{this.svgCanvas.spaceKey=Kr=Tr};const unfocus=()=>{Gr.blur()},Wr=this.$svgEditor.querySelectorAll("button, select, input:not(#text)"),Xr=this;Array.prototype.forEach.call(Wr,(function(Tr){Tr.addEventListener("focus",(Tr=>{Gr=Tr.currentTarget,Xr.uiContext="toolbars",Xr.workarea.addEventListener("mousedown",unfocus)})),Tr.addEventListener("blur",(()=>{Xr.uiContext="canvas",Xr.workarea.removeEventListener("mousedown",unfocus),"textedit"===Xr.svgCanvas.getMode()&&Gm("text").focus()}))}));const Yr={width:function getWidth(){return Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth,document.documentElement.clientWidth)}(),height:function getHeight(){return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.documentElement.clientHeight)}()};window.addEventListener("resize",(()=>{Object.entries(Yr).forEach((Tr=>{let[Ur,Rr]=Tr;const Qr="width"===Ur?window.innerWidth-15:window.innerHeight;this.workarea["scroll"+("width"===Ur?"Left":"Top")]-=(Qr-Rr)/2,Yr[Ur]=Qr}))})),this.workarea.addEventListener("scroll",(()=>{this.rulers.manageScroll()})),Gm("stroke_width").value=this.configObj.curConfig.initStroke.width,Gm("opacity").value=100*this.configObj.curConfig.initOpacity;const Zr=document.getElementsByClassName("push_button");Array.from(Zr).forEach((function(Tr){Tr.addEventListener("mousedown",(function(Tr){Tr.currentTarget.classList.contains("disabled")||(Tr.currentTarget.classList.add("push_button_pressed"),Tr.currentTarget.classList.remove("push_button"))})),Tr.addEventListener("mouseout",(function(Tr){Tr.currentTarget.classList.add("push_button"),Tr.currentTarget.classList.remove("push_button_pressed")})),Tr.addEventListener("mouseup",(function(Tr){Tr.currentTarget.classList.add("push_button"),Tr.currentTarget.classList.remove("push_button_pressed")}))})),this.layersPanel.populateLayers();addListenerMulti(window,"load resize",(()=>{this.workarea.style.lineHeight=this.workarea.style.height}));const Jr=document.querySelectorAll("input");Array.from(Jr).forEach((function(Tr){Tr.setAttribute("autocomplete","off")}));const en=document.querySelectorAll("select");Array.from(en).forEach((function(Tr){Tr.setAttribute("autocomplete","off")})),Gm("se-svg-editor-dialog").addEventListener("change",function(Tr){"click"===Tr?.detail?.copy?this.cancelOverlays(Tr):"dynamic"===Tr?.detail?.dialog?this.toggleDynamicOutput(Tr):"closed"===Tr?.detail?.dialog?this.hideSourceEditor():this.saveSourceEditor(Tr)}.bind(this)),Gm("se-cmenu_canvas").addEventListener("change",function(Tr){const Ur=Tr?.detail?.trigger;switch(Ur){case"delete":this.svgCanvas.deleteSelectedElements();break;case"cut":this.cutSelected();break;case"copy":this.copySelected();break;case"paste":this.svgCanvas.pasteElements();break;case"paste_in_place":this.svgCanvas.pasteElements("in_place");break;case"group":case"group_elements":this.svgCanvas.groupSelectedElements();break;case"ungroup":this.svgCanvas.ungroupSelectedElement();break;case"move_front":this.svgCanvas.moveToTopSelectedElement();break;case"move_up":this.moveUpDownSelected("Up");break;case"move_down":this.moveUpDownSelected("Down");break;case"move_back":this.svgCanvas.moveToBottomSelectedElement();break;default:Boolean(Om[Ur])&&function(Tr){return Om[Tr].action}(Ur).call()}}.bind(this)),this.ready(function(){const Tr=Gm(`tool_${this.configObj.curConfig.initTool}`),Ur=Gm(this.configObj.curConfig.initTool),Rr=Gm("tool_select"),Qr=Gm("se-edit-prefs");Tr?Tr.click():Ur?Ur.click():Rr.click(),this.configObj.curConfig.wireframe&&Gm("tool_wireframe").click(),this.configObj.curConfig.showRulers?this.rulers.display(!0):this.rulers.display(!1),this.configObj.curConfig.showRulers&&Qr.setAttribute("showrulers",!0),this.configObj.curConfig.baseUnit&&Qr.setAttribute("baseunit",this.configObj.curConfig.baseUnit),this.configObj.curConfig.gridSnapping&&Qr.setAttribute("gridsnappingon",!0),this.configObj.curConfig.snappingStep&&Qr.setAttribute("gridsnappingstep",this.configObj.curConfig.snappingStep),this.configObj.curConfig.gridColor&&Qr.setAttribute("gridcolor",this.configObj.curConfig.gridColor),this.configObj.curConfig.dynamicOutput&&Qr.setAttribute("dynamicoutput",!0)}.bind(this)),Gm("zoom").value=(100*this.svgCanvas.getZoom()).toFixed(1),this.canvMenu.setAttribute("disableallmenu",!0),this.canvMenu.setAttribute("enablemenuitems","#delete,#cut,#copy"),this.enableOrDisableClipboard(),window.addEventListener("storage",function(Tr){"svgedit_clipboard"===Tr.key&&this.enableOrDisableClipboard()}.bind(this)),window.addEventListener("beforeunload",function(Tr){}.bind(this)),this.workarea.addEventListener("dragenter",this.onDragEnter),this.workarea.addEventListener("dragover",this.onDragOver),this.workarea.addEventListener("dragleave",this.onDragLeave),this.updateCanvas(!0),this.extAndLocaleFunc(),this.ready((()=>{injectExtendedContextMenuItemsIntoDom()})),await this.runCallbacks()}async extAndLocaleFunc(){this.$svgEditor.style.visibility="visible";try{await Promise.all(this.configObj.curConfig.extensions.map((async Tr=>{try{const Ur=this.configObj.curConfig.extPath,Rr=await import(`${Ur}/${encodeURIComponent(Tr)}/${encodeURIComponent(Tr)}.js`),{name:Qr=Tr,init:Vr}=Rr.default;return this.addExtension(Qr,Vr&&Vr.bind(this),{langParam:"en"})}catch(Ur){return void console.error("Extension failed to load: "+Tr+"; ",Ur)}}))),await Promise.all(this.configObj.curConfig.userExtensions.map((async Tr=>{let{pathName:Ur,config:Rr}=Tr;try{const Tr=await import(encodeURI(Ur)),{name:Qr,init:Vr}=Tr.default;return this.addExtension(Qr,Vr&&Vr.bind(this,Rr),{})}catch(Tr){return void console.error("Extension failed to load: "+Ur+"; ",Tr)}}))),this.svgCanvas.bind("extensions_added",((Tr,Ur)=>{this.extensionsAdded=!0,this.setAll(),"ignore"===this.storagePromptState&&this.updateCanvas(!0),this.messageQueue.forEach((Tr=>{this.svgCanvas.call("message",Tr)}))})),this.svgCanvas.call("extensions_added")}catch(Tr){console.error(Tr)}}modeListener(Tr){const Ur=this.svgCanvas.getMode();this.setCursorStyle(Ur)}setCursorStyle(Tr){let Ur="auto";switch(Tr){case"ext-panning":Ur="grab";break;case"zoom":case"shapelib":Ur="crosshair";break;case"circle":case"ellipse":case"rect":case"square":case"star":case"polygon":Ur=`url("./images/cursors/${Tr}_cursor.svg"), crosshair`;break;case"text":Ur="text";break;default:Ur="auto"}this.workarea.style.cursor=Ur}cancelTool(){const Tr=this.svgCanvas.getMode();["zoom","rect","square","circle","ellipse","line","text","star","polygon","shapelib","image"].includes(Tr)&&this.leftPanel.clickSelect()}}const{$id:Km,$qa:$m,$click:Wm}=SvgCanvas;class LeftPanel{constructor(Tr){this.editor=Tr}updateLeftPanel(Tr){return!Tr.disabled&&($m("#tools_left *[pressed]").forEach((Tr=>{Tr.pressed=!1})),Km(Tr).pressed=!0,!0)}clickSelect(){this.updateLeftPanel("tool_select")&&this.editor.svgCanvas.setMode("select")}clickFHPath(){this.updateLeftPanel("tool_fhpath")&&this.editor.svgCanvas.setMode("fhpath")}clickLine(){this.updateLeftPanel("tool_line")&&this.editor.svgCanvas.setMode("line")}clickSquare(){this.updateLeftPanel("tool_square")&&this.editor.svgCanvas.setMode("square")}clickRect(){this.updateLeftPanel("tool_rect")&&this.editor.svgCanvas.setMode("rect")}clickFHRect(){this.updateLeftPanel("tool_fhrect")&&this.editor.svgCanvas.setMode("fhrect")}clickCircle(){this.updateLeftPanel("tool_circle")&&this.editor.svgCanvas.setMode("circle")}clickEllipse(){this.updateLeftPanel("tool_ellipse")&&this.editor.svgCanvas.setMode("ellipse")}clickFHEllipse(){this.updateLeftPanel("tool_fhellipse")&&this.editor.svgCanvas.setMode("fhellipse")}clickImage(){this.updateLeftPanel("tool_image")&&this.editor.svgCanvas.setMode("image")}clickZoom(){this.updateLeftPanel("tool_zoom")&&(this.editor.svgCanvas.setMode("zoom"),this.editor.workarea.style.cursor=this.editor.zoomInIcon)}dblclickZoom(){this.updateLeftPanel("tool_zoom")&&(this.editor.zoomImage(),this.clickSelect())}clickText(){this.updateLeftPanel("tool_text")&&this.editor.svgCanvas.setMode("text")}clickPath(){this.updateLeftPanel("tool_path")&&this.editor.svgCanvas.setMode("path")}add(Tr,Ur){Wm(Km(Tr),(()=>{this.updateLeftPanel(Tr)&&Ur()}))}init(){const Tr=document.createElement("template");Tr.innerHTML='<div id="tools_left">\n <se-button id="tool_select" title="tools.mode_select" src="select.svg"></se-button>\n <se-button id="tool_zoom" title="tools.mode_zoom" src="zoom.svg" shortcut="Z"></se-button>\n <se-button id="tool_fhpath" title="tools.mode_fhpath" src="pencil.svg" shortcut="Q"></se-button>\n <se-button id="tool_line" title="tools.mode_line" src="pen.svg" shortcut="L"></se-button>\n <se-button id="tool_path" title="tools.mode_path" src="path.svg" shortcut="P"></se-button>\n <se-flyingbutton id="tools_rect" title="tools.square_rect_tool">\n <se-button id="tool_rect" title="tools.mode_rect" src="rect.svg" shortcut="R"></se-button>\n <se-button id="tool_square" title="tools.mode_square" src="square.svg"></se-button>\n <se-button id="tool_fhrect" title="tools.mode_fhrect" src="fh_rect.svg"></se-button>\n </se-flyingbutton>\n <se-flyingbutton id="tools_ellipse" title="tools.ellipse_circle_tool">\n <se-button id="tool_ellipse" title="tools.mode_ellipse" src="ellipse.svg" shortcut="E"></se-button>\n <se-button id="tool_circle" title="tools.mode_circle" src="circle.svg"></se-button>\n <se-button id="tool_fhellipse" title="tools.mode_fhellipse" src="fh_ellipse.svg"></se-button>\n </se-flyingbutton>\n <se-button id="tool_text" title="tools.mode_text" src="text.svg" shortcut="T"></se-button>\n <se-button id="tool_image" title="tools.mode_image" src="image.svg"></se-button>\n</div>',this.editor.$svgEditor.append(Tr.content.cloneNode(!0)),Wm(Km("tool_select"),this.clickSelect.bind(this)),Wm(Km("tool_fhpath"),this.clickFHPath.bind(this)),Wm(Km("tool_text"),this.clickText.bind(this)),Wm(Km("tool_image"),this.clickImage.bind(this)),Wm(Km("tool_zoom"),this.clickZoom.bind(this)),Km("tool_zoom").addEventListener("dblclick",this.dblclickZoom.bind(this)),Wm(Km("tool_path"),this.clickPath.bind(this)),Wm(Km("tool_line"),this.clickLine.bind(this)),Wm(Km("tool_rect"),this.clickRect.bind(this)),Wm(Km("tool_square"),this.clickSquare.bind(this)),Wm(Km("tool_fhrect"),this.clickFHRect.bind(this)),Wm(Km("tool_ellipse"),this.clickEllipse.bind(this)),Wm(Km("tool_circle"),this.clickCircle.bind(this)),Wm(Km("tool_fhellipse"),this.clickFHEllipse.bind(this))}}const{$qa:Xm,$id:Ym,$click:Zm,isValidUnit:Jm,getTypeMap:ef,convertUnit:tf}=SvgCanvas;class TopPanel{constructor(Tr){this.editor=Tr}displayTool(Tr){Xm(`.${Tr}`).map((Tr=>Tr.style.removeProperty("display")))}hideTool(Tr){Xm(`.${Tr}`).forEach((Tr=>{Tr.style.display="none"}))}get selectedElement(){return this.editor.selectedElement}get multiselected(){return this.editor.multiselected}get path(){return this.editor.svgCanvas.pathActions}setStrokeOpt(Tr,Ur){const{id:Rr}=Tr,Qr=Rr.split("_"),[Vr,Gr]=Qr;Ur&&this.svgCanvas.setStrokeAttr("stroke-"+Vr,Gr),Tr.classList.add("current");const Dr=Array.prototype.filter.call(Tr.parentNode.children,(function(Ur){return Ur!==Tr}));Array.from(Dr).forEach((function(Tr){Tr.classList.remove("current")}))}update(){let Tr,Ur;if(Xm("#title_panel > p")[0].textContent=this.editor.title,this.selectedElement)switch(this.selectedElement.tagName){case"use":case"image":case"foreignObject":break;case"g":case"a":{const Rr=this.selectedElement.getElementsByTagName("*");let Qr=null;for(Tr=0,Ur=Rr.length;Tr<Ur;Tr++){const Ur=Rr[Tr].getAttribute("stroke-width");0===Tr?Qr=Ur:Qr!==Ur&&(Qr=null)}Ym("stroke_width").value=null===Qr?"":Qr,this.editor.bottomPanel.updateColorpickers(!1);break}default:{this.editor.bottomPanel.updateColorpickers(!1),Ym("stroke_width").value=this.selectedElement.getAttribute("stroke-width")||1,Ym("stroke_style").value=this.selectedElement.getAttribute("stroke-dasharray")||"none",Ym("stroke_style").setAttribute("value",Ym("stroke_style").value);let Tr=this.selectedElement.getAttribute("stroke-linejoin")||"miter";Ym("linejoin_"+Tr)&&(this.setStrokeOpt(Ym("linejoin_"+Tr)),Ym("stroke_linejoin").setAttribute("value",Tr)),Tr=this.selectedElement.getAttribute("stroke-linecap")||"butt",Ym("linecap_"+Tr)&&(this.setStrokeOpt(Ym("linecap_"+Tr)),Ym("stroke_linecap").setAttribute("value",Tr))}}if(this.selectedElement){const Tr=100*(this.selectedElement.getAttribute("opacity")||1);Ym("opacity").value=Tr,Ym("elem_id").value=this.selectedElement.id,Ym("elem_class").value=this.selectedElement.getAttribute("class")??""}this.editor.bottomPanel.updateToolButtonState()}promptImgURL(){let{cancelDeletes:Tr=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Ur=this.editor.svgCanvas.getHref(this.editor.selectedElement);Ur=Ur.startsWith("data:")?"":Ur;const Rr=prompt(this.editor.i18next.t("notification.enterNewImgURL"),Ur);Rr?this.setImageURL(Rr):Tr&&this.editor.svgCanvas.deleteSelectedElements()}updateContextPanel(){let Tr=this.editor.selectedElement;Tr?.parentNode||(Tr=null);const Ur=this.editor.svgCanvas.getCurrentDrawing().getCurrentLayerName(),Rr=this.editor.svgCanvas.getMode(),Qr="px"!==this.editor.configObj.curConfig.baseUnit?this.editor.configObj.curConfig.baseUnit:null,Vr="pathedit"===Rr,Gr=document.getElementById("se-cmenu_canvas");if(this.hideTool("selected_panel"),this.hideTool("multiselected_panel"),this.hideTool("g_panel"),this.hideTool("rect_panel"),this.hideTool("circle_panel"),this.hideTool("ellipse_panel"),this.hideTool("line_panel"),this.hideTool("text_panel"),this.hideTool("image_panel"),this.hideTool("container_panel"),this.hideTool("use_panel"),this.hideTool("a_panel"),this.hideTool("xy_panel"),Tr){const Ur=Tr.nodeName,Dr=this.editor.svgCanvas.getRotationAngle(Tr);Ym("angle").value=Dr;const Hr=10*this.editor.svgCanvas.getBlur(Tr);if(Ym("blur").value=Hr,this.editor.svgCanvas.addedNew&&"image"===Ur&&"image"===this.editor.svgCanvas.getMode()&&!this.editor.svgCanvas.getHref(Tr).startsWith("data:")&&this.promptImgURL({cancelDeletes:!0}),Vr||"pathedit"===Rr){const Tr=this.path.getNodePoint();if(Ym("tool_add_subpath").pressed=!1,this.path.canDeleteNodes?Ym("tool_node_delete").classList.remove("disabled"):Ym("tool_node_delete").classList.add("disabled"),Tr){const Ur=Ym("seg_type");Qr&&(Tr.x=tf(Tr.x),Tr.y=tf(Tr.y)),Ym("path_node_x").value=Tr.x,Ym("path_node_y").value=Tr.y,Tr.type?(Ur.value=Tr.type,Ur.removeAttribute("disabled")):(Ur.value=4,Ur.setAttribute("disabled","disabled"))}return}if(this.displayTool("selected_panel"),["line","circle","ellipse","polygon"].includes(Ur))this.hideTool("xy_panel");else{let Rr,Vr;if(["g","polyline","path"].includes(Ur)){const Ur=this.editor.svgCanvas.getStrokedBBox([Tr]);Ur&&({x:Rr,y:Vr}=Ur)}else Rr=Tr.getAttribute("x"),Vr=Tr.getAttribute("y");Qr&&(Rr=tf(Rr),Vr=tf(Vr));const updateValue=(Tr,Ur)=>{const Rr=Ym(Tr).value;parseFloat(Rr)!==Ur&&(Ym(Tr).value=Ur)};updateValue("selected_x",Rr),updateValue("selected_y",Vr),this.displayTool("xy_panel")}["image","text","path","g","use"].includes(Ur)?this.hideTool("tool_topath"):this.displayTool("tool_topath"),"path"===Ur?this.displayTool("tool_reorient"):this.hideTool("tool_reorient"),Ym("tool_reorient").disabled=0===Dr;const zr={g:[],a:[],rect:["rx","width","height"],image:["width","height"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:[],use:[]},{tagName:Kr}=Tr;let $r=null;if("a"===Kr&&($r=this.editor.svgCanvas.getHref(Tr),this.displayTool("g_panel")),Tr.parentNode){const Ur=Array.prototype.filter.call(Tr.parentNode.children,(function(Ur){return Ur!==Tr}));"a"!==Tr.parentNode.tagName||Ur.length||(this.displayTool("a_panel"),$r=this.editor.svgCanvas.getHref(Tr.parentNode))}if($r?(this.displayTool("tool_make_link"),this.displayTool("tool_make_link_multi"),Ym("link_url").value=$r):(this.hideTool("tool_make_link"),this.hideTool("tool_make_link_multi")),zr[Kr]){const Ur=zr[Kr];if(this.displayTool(Kr+"_panel"),Ur.forEach((Ur=>{let Rr=Tr.getAttribute(Ur);if("px"!==this.editor.configObj.curConfig.baseUnit&&Tr[Ur]){const Qr=Tr[Ur].baseVal.value;Rr=tf(Qr)}Ym(`${Kr}_${Ur}`).value=Rr||0})),"text"===Kr)this.displayTool("text_panel"),Ym("tool_italic").pressed=this.editor.svgCanvas.getItalic(),Ym("tool_bold").pressed=this.editor.svgCanvas.getBold(),Ym("tool_text_decoration_underline").pressed=this.editor.svgCanvas.hasTextDecoration("underline"),Ym("tool_text_decoration_linethrough").pressed=this.editor.svgCanvas.hasTextDecoration("line-through"),Ym("tool_text_decoration_overline").pressed=this.editor.svgCanvas.hasTextDecoration("overline"),Ym("tool_font_family").value=Tr.getAttribute("font-family"),Ym("tool_text_anchor").setAttribute("value",Tr.getAttribute("text-anchor")),Ym("font_size").value=Tr.getAttribute("font-size"),Ym("tool_letter_spacing").value=Tr.getAttribute("letter-spacing")??0,Ym("tool_word_spacing").value=Tr.getAttribute("word-spacing")??0,Ym("tool_text_length").value=Tr.getAttribute("textLength")??0,Ym("tool_length_adjust").value=Tr.getAttribute("lengthAdjust")??0,Ym("text").value=Tr.textContent,this.editor.svgCanvas.addedNew&&setTimeout((()=>{Ym("text").focus(),Ym("text").select()}),100);else if("image"===Kr&&"image"===this.editor.svgCanvas.getMode())this.editor.svgCanvas.setImageURL(this.editor.svgCanvas.getHref(Tr));else if("g"===Kr||"use"===Kr){this.displayTool("container_panel");const Tr=this.editor.svgCanvas.getTitle();Ym("g_title").value=Tr,Ym("g_title").disabled="use"===Kr}}Gr.setAttribute(("g"===Kr?"en":"dis")+"ablemenuitems","#ungroup"),Gr.setAttribute(("g"!==Kr&&this.multiselected?"en":"dis")+"ablemenuitems","#group")}else if(this.multiselected){this.editor.svgCanvas.getSelectedElements().every((Tr=>"text"===Tr.tagName))&&this.displayTool("text_panel"),this.displayTool("multiselected_panel"),Gr.setAttribute("enablemenuitems","#group"),Gr.setAttribute("disablemenuitems","#ungroup")}else Gr.setAttribute("disablemenuitems","#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");if(Ym("tool_undo").disabled=0===this.editor.svgCanvas.undoMgr.getUndoStackSize(),Ym("tool_redo").disabled=0===this.editor.svgCanvas.undoMgr.getRedoStackSize(),this.editor.svgCanvas.addedNew=!1,Tr&&!Vr||this.multiselected){Ym("selLayerNames").removeAttribute("disabled"),Ym("selLayerNames").value=Ur,Ym("selLayerNames").setAttribute("value",Ur);document.getElementById("se-cmenu_canvas").setAttribute("enablemenuitems","#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}else Ym("selLayerNames").setAttribute("disabled","disabled")}showSourceEditor(Tr,Ur){const Rr=document.getElementById("se-svg-editor-dialog");if("open"===Rr.getAttribute("dialog"))return;const Qr=this.editor.svgCanvas.getSvgString();Rr.setAttribute("dialog","open"),Rr.setAttribute("value",Qr),Rr.setAttribute("copysec",Boolean(Ur)),Rr.setAttribute("applysec",!Ur)}clickWireframe(){Ym("tool_wireframe").pressed=!Ym("tool_wireframe").pressed,this.editor.workarea.classList.toggle("wireframe");const Tr=Ym("wireframe_rules");if(Tr)for(;Tr.firstChild;)Tr.removeChild(Tr.firstChild);else{const Tr=document.createElement("style");Tr.setAttribute("id","wireframe_rules"),document.getElementsByTagName("head")[0].appendChild(Tr)}this.editor.updateWireFrame()}clickUndo(){const{undoMgr:Tr,textActions:Ur}=this.editor.svgCanvas;Tr.getUndoStackSize()>0&&(Tr.undo(),this.editor.layersPanel.populateLayers(),"textedit"===this.editor.svgCanvas.getMode()&&Ur.clear())}clickRedo(){const{undoMgr:Tr}=this.editor.svgCanvas;Tr.getRedoStackSize()>0&&(Tr.redo(),this.editor.layersPanel.populateLayers())}changeRectRadius(Tr){this.editor.svgCanvas.setRectRadius(Tr.target.value)}changeFontSize(Tr){this.editor.svgCanvas.setFontSize(Tr.target.value)}changeRotationAngle(Tr){this.editor.svgCanvas.setRotationAngle(Tr.target.value),0===Number.parseInt(Tr.target.value)?Ym("tool_reorient").classList.add("disabled"):Ym("tool_reorient").classList.remove("disabled")}changeBlur(Tr){this.editor.svgCanvas.setBlur(Tr.target.value/10,!0)}clickGroup(){this.editor.multiselected?this.editor.svgCanvas.groupSelectedElements():this.editor.selectedElement&&this.editor.svgCanvas.ungroupSelectedElement()}clickClone(){this.editor.svgCanvas.cloneSelectedElements(20,20)}clickAlignEle(Tr){this.editor.svgCanvas.alignSelectedElements(Tr.detail.value,"page")}clickAlign(Tr){let Ur=Ym("tool_align_relative").value;""===Ur&&(Ur="selected"),this.editor.svgCanvas.alignSelectedElements(Tr,Ur)}attrChanger(Tr){const Ur=Tr.target.getAttribute("data-attr");let Rr=Tr.target.value;if(!Jm(Ur,Rr,this.selectedElement))return Tr.target.value=this.selectedElement.getAttribute(Ur),alert(this.editor.i18next.t("notification.invalidAttrValGiven")),!1;if("id"!==Ur&&"class"!==Ur)if(isNaN(Rr))Rr=this.editor.svgCanvas.convertToNum(Ur,Rr);else if("px"!==this.editor.configObj.curConfig.baseUnit){const Tr=ef();(this.editor.selectedElement[Ur]||"pathedit"===this.editor.svgCanvas.getMode()||"x"===Ur||"y"===Ur)&&(Rr*=Tr[this.editor.configObj.curConfig.baseUnit])}return this.editor.svgCanvas.changeSelectedAttribute(Ur,Rr),!0}convertToPath(){this.editor.selectedElement&&this.editor.svgCanvas.convertToPath()}reorientPath(){this.editor.selectedElement&&this.path.reorient()}makeHyperlink(){if(this.editor.selectedElement||this.multiselected){const Tr=prompt(this.editor.i18next.t("notification.enterNewLinkURL"),"http://");Tr&&this.editor.svgCanvas.makeHyperlink(Tr)}}linkControlPoints(){Ym("tool_node_link").pressed=!Ym("tool_node_link").pressed;const Tr=!!Ym("tool_node_link").pressed;this.path.linkControlPoints(Tr)}clonePathNode(){this.path.getNodePoint()&&this.path.clonePathNode()}deletePathNode(){this.path.getNodePoint()&&this.path.deletePathNode()}addSubPath(){const Tr=Ym("tool_add_subpath"),Ur=!Tr.classList.contains("pressed");Tr.pressed=Ur,this.path.addSubPath(Ur)}opencloseSubPath(){this.path.opencloseSubPath()}deleteSelected(){(this.editor.selectedElement||this.editor.multiselected)&&this.editor.svgCanvas.deleteSelectedElements()}moveToTopSelected(){this.editor.selectedElement&&this.editor.svgCanvas.moveToTopSelectedElement()}moveToBottomSelected(){this.editor.selectedElement&&this.editor.svgCanvas.moveToBottomSelectedElement()}get anyTextSelected(){return this.editor.svgCanvas.getSelectedElements().filter((Tr=>"text"===Tr.tagName)).length>0}clickBold(){if(this.anyTextSelected)return this.editor.svgCanvas.setBold(!this.editor.svgCanvas.getBold()),this.updateContextPanel(),!1}clickItalic(){if(this.anyTextSelected)return this.editor.svgCanvas.setItalic(!this.editor.svgCanvas.getItalic()),this.updateContextPanel(),!1}clickTextDecoration(Tr){return this.editor.svgCanvas.hasTextDecoration(Tr)?this.editor.svgCanvas.removeTextDecoration(Tr):this.editor.svgCanvas.addTextDecoration(Tr),this.updateContextPanel(),!1}clickTextAnchor(Tr){return this.editor.svgCanvas.setTextAnchor(Tr.detail.value),!1}changeLetterSpacing(Tr){this.editor.svgCanvas.setLetterSpacing(Tr.target.value)}changeWordSpacing(Tr){this.editor.svgCanvas.setWordSpacing(Tr.target.value)}changeTextLength(Tr){this.editor.svgCanvas.setTextLength(Tr.target.value)}changeLengthAdjust(Tr){this.editor.svgCanvas.setLengthAdjust(Tr.detail.value)}setImageURL(Tr){const{editor:Ur}=this;if(Tr||(Tr=Ur.defaultImageURL),Ur.svgCanvas.setImageURL(Tr),Ym("image_url").value=Tr,Tr.startsWith("data:"))this.hideTool("image_url");else{Ur.svgCanvas.embedImage(Tr).then((()=>{Ur.svgCanvas.setMode("select"),Ur.svgCanvas.selectOnly(Ur.svgCanvas.getSelectedElements(),!0)}),(Tr=>{console.error("error =",Tr),seAlert(Ur.i18next.t("tools.no_embed")),Ur.svgCanvas.deleteSelectedElements()})),this.displayTool("image_url")}}updateTitle(Tr){Tr&&(this.editor.title=Tr);const Ur=Xm("#title_panel > p")[0];Ur&&(Ur.textContent=this.editor.title)}togglePathEditMode(Tr,Ur){Tr?this.displayTool("path_node_panel"):this.hideTool("path_node_panel"),Tr?(Ym("tool_path").pressed=!1,Ym("tool_select").pressed=!0,Ym("tool_select").setAttribute("src","select_node.svg"),this.editor.multiselected=!1,Ur.length&&(this.editor.selectedElement=Ur[0])):setTimeout((()=>{Ym("tool_select").setAttribute("src","select.svg")}),1e3)}init(){const Tr=document.createElement("template"),{i18next:Ur}=this.editor;Tr.innerHTML='<div id="tools_top">\n <div id="title_panel">\n <p>bez_tytulu.svg</p>\n </div> \x3c!-- title panel --\x3e\n <div id="editor_panel">\n <div class="tool_sep"></div>\n <se-button id="tool_source" title="tools.tool_source" shortcut="U" src="source.svg"></se-button>\n <se-button id="tool_wireframe" title="tools.wireframe_mode" shortcut="F" src="wireframe.svg"></se-button>\n </div> \x3c!-- editor_panel --\x3e\n <div id="history_panel">\n <div class="tool_sep"></div>\n <se-button id="tool_undo" title="tools.undo" shortcut="ctrl+Z" src="undo.svg" disabled="disabled"></se-button>\n <se-button id="tool_redo" title="tools.redo" shortcut="ctrl+Y" src="redo.svg" disabled="disabled"></se-button>\n </div> \x3c!-- history_panel --\x3e\n \x3c!-- Buttons when a single element is selected --\x3e\n <div class="selected_panel">\n <div class="tool_sep"></div>\n <se-button id="tool_clone" title="tools.clone" shortcut="D" src="clone.svg"></se-button>\n <se-button id="tool_delete" title="tools.del" shortcut="Delete/Backspace" src="delete.svg"></se-button>\n </div>\n <div class="selected_panel">\n <div class="tool_sep"></div>\n <se-button id="tool_move_top" title="tools.move_top" shortcut="Ctrl+Shift+]" src="move_top.svg"></se-button>\n <se-button id="tool_move_bottom" title="tools.move_bottom" shortcut="Ctrl+Shift+[" src="move_bottom.svg">\n </se-button>\n </div>\n <div class="selected_panel">\n <se-button id="tool_topath" title="tools.to_path" src="to_path.svg"></se-button>\n <se-button id="tool_reorient" title="tools.reorient_path" src="reorient.svg"></se-button>\n <se-button id="tool_make_link" title="tools.make_link" src="globe_link.svg"></se-button>\n </div>\n <div class="selected_panel">\n <div class="tool_sep"></div>\n <se-input id="elem_id" data-attr="id" size="10" label="properties.id_label" title="properties.id"></se-input>\n </div>\n <div class="selected_panel">\n <se-input id="elem_class" data-attr="class" size="10" label="properties.class_label" title="properties.class">\n </se-input>\n <se-spin-input size="3" id="angle" min="-180" max="180" step="5" src="angle.svg" title="properties.angle">\n </se-spin-input>\n <se-spin-input size="2" id="blur" min="0" max="100" step="5" src="blur.svg" title="properties.blur"></se-spin-input>\n <se-list id="tool_position" title="tools.align_to_page" label="" width="22px" height="22px">\n <se-list-item id="tool_posleft" value="l" title="tools.align_left" src="align_left.svg" img-height="22px">\n </se-list-item>\n <se-list-item id="tool_poscenter" value="c" title="tools.align_center" src="align_center.svg" img-height="22px"></se-list-item>\n <se-list-item id="tool_posright" value="r" title="tools.align_right" src="align_right.svg" img-height="22px"></se-list-item>\n <se-list-item id="tool_postop" value="t" title="tools.align_top" src="align_top.svg" img-height="22px">\n </se-list-item>\n <se-list-item id="tool_posmiddle" value="m" title="tools.align_middle" src="align_middle.svg" img-height="22px"></se-list-item>\n <se-list-item id="tool_posbottom" value="b" src="align_bottom.svg" title="tools.align_bottom" img-height="22px"></se-list-item>\n <se-list-item id="tool_poshoriz" value="dh" src="align_distrib_horiz.svg" title="tools.align_distrib_horiz" img-height="22px"></se-list-item>\n <se-list-item id="tool_posverti" value="dv" src="align_distrib_verti.svg" title="tools.align_distrib_verti" img-height="22px"></se-list-item>\n </se-list>\n </div>\n <div class="xy_panel">\n <se-spin-input id="selected_x" data-attr="x" size="4" type="text" label="properties.x_label" title="properties.pos_x">\n </se-spin-input>\n <se-spin-input id="selected_y" data-attr="y" size="4" type="text" label="properties.y_label" title="properties.pos_y">\n </se-spin-input>\n </div>\n \x3c!-- Buttons when multiple elements are selected --\x3e\n <div class="multiselected_panel">\n <div class="tool_sep"></div>\n <se-button id="tool_clone_multi" title="tools.clone" shortcut="C" src="clone.svg"></se-button>\n <se-button id="tool_delete_multi" title="tools.del" shortcut="Delete/Backspace" src="delete.svg"></se-button>\n </div>\n <div class="multiselected_panel">\n <div class="tool_sep"></div>\n <se-button id="tool_group_elements" title="tools.group_elements" shortcut="G" src="group_elements.svg">\n </se-button>\n <se-button id="tool_make_link_multi" title="tools.make_link" src="globe_link.svg"></se-button>\n <se-button id="tool_align_left" title="tools.align_left" src="align_left.svg"></se-button>\n <se-button id="tool_align_center" title="tools.align_center" src="align_center.svg"></se-button>\n <se-button id="tool_align_right" title="tools.align_right" src="align_right.svg"></se-button>\n <se-button id="tool_align_top" title="tools.align_top" src="align_top.svg"></se-button>\n <se-button id="tool_align_middle" title="tools.align_middle" src="align_middle.svg"></se-button>\n <se-button id="tool_align_bottom" title="tools.align_bottom" src="align_bottom.svg"></se-button>\n <se-button id="tool_align_distrib_horiz" title="tools.align_distrib_horiz" src="align_distrib_horiz.svg"></se-button>\n <se-button id="tool_align_distrib_verti" title="tools.align_distrib_verti" src="align_distrib_verti.svg"></se-button>\n <se-select id="tool_align_relative" label="tools.relativeTo" options="tools.selected_objects,tools.largest_object,tools.smallest_object,tools.page" values="selected::largest::smallest::page">\n \n </se-select>\n </div> \x3c!-- multiselected_panel --\x3e\n <div class="rect_panel">\n <se-spin-input id="rect_width" data-attr="width" size="4" label="properties.w_label" title="properties.rect_width"></se-spin-input>\n <se-spin-input id="rect_height" data-attr="height" size="4" label="properties.h_label" title="properties.rect_height"></se-spin-input>\n <se-spin-input id="rect_rx" min="0" max="1000" step="1" size="3" title="properties.corner_radius" data-attr="Corner Radius" src="c_radius.svg"></se-spin-input>\n </div> \x3c!-- rect_panel --\x3e\n <div class="image_panel">\n <se-spin-input id="image_width" data-attr="width" size="4" type="text" label="properties.w_label" title="properties.image_width"></se-spin-input>\n <se-spin-input id="image_height" data-attr="height" size="4" type="text" label="properties.h_label" title="properties.image_height"></se-spin-input>\n </div>\n <div class="image_panel">\n <se-input id="image_url" data-attr="image_url" size="15" label="properties.image_url"></se-input>\n </div>\n <div class="circle_panel">\n <se-spin-input id="circle_cx" data-attr="cx" size="4" label="properties.cx_label"></se-spin-input>\n <se-spin-input id="circle_cy" data-attr="cy" size="4" label="properties.cy_label"></se-spin-input>\n </div>\n <div class="circle_panel">\n <se-spin-input id="circle_r" data-attr="r" size="4" label="properties.r_label"></se-spin-input>\n </div>\n <div class="ellipse_panel">\n <se-spin-input id="ellipse_cx" data-attr="cx" size="4" title="properties.ellipse_cx" label="properties.cx_label"></se-spin-input>\n <se-spin-input id="ellipse_cy" data-attr="cy" size="4" title="properties.ellipse_cy" label="properties.cy_label"></se-spin-input>\n </div>\n <div class="ellipse_panel">\n <se-spin-input id="ellipse_rx" data-attr="rx" size="4" title="properties.ellipse_rx" label="properties.rx_label"></se-spin-input>\n <se-spin-input id="ellipse_ry" data-attr="ry" size="4" title="properties.ellipse_ry" label="properties.ry_label"></se-spin-input>\n </div>\n <div class="line_panel">\n <se-spin-input id="line_x1" data-attr="x1" size="4" title="properties.line_x1" label="properties.x1_label">\n </se-spin-input>\n <se-spin-input id="line_y1" data-attr="y1" size="4" title="properties.line_y1" label="properties.y1_label">\n </se-spin-input>\n <se-spin-input id="line_x2" data-attr="x2" size="4" title="properties.line_x2" label="properties.x2_label">\n </se-spin-input>\n <se-spin-input id="line_y2" data-attr="y2" size="4" title="properties.line_y2" label="properties.y2_label">\n </se-spin-input>\n </div>\n <div class="text_panel">\n \x3c!-- Text styles --\x3e\n <se-button id="tool_bold" title="properties.bold" src="bold.svg" shortcut="B"></se-button>\n <se-button id="tool_italic" title="properties.italic" src="italic.svg" shortcut="I"></se-button>\n <se-button id="tool_text_decoration_underline" title="properties.text_decoration_underline" src="text_decoration_underline.svg"></se-button>\n <se-button id="tool_text_decoration_linethrough" title="properties.text_decoration_linethrough" src="text_decoration_linethrough.svg"></se-button>\n <se-button id="tool_text_decoration_overline" title="properties.text_decoration_overline" src="text_decoration_overline.svg"></se-button>\n\n \x3c!-- Font Size--\x3e\n <se-select id="tool_font_family" label="properties.font_family_label" options="properties.serif,properties.sans_serif,properties.cursive,properties.fantasy,properties.monospace,properties.courier,properties.helvetica,properties.times" values="Serif::Sans-serif::Cursive::Fantasy::Monospace::Courier::Helvetica::Times"></se-select>\n <se-spin-input size="2" id="font_size" min="1" max="1000" step="1" title="properties.font_size" src="fontsize.svg"></se-spin-input>\n\n \x3c!-- Text Anchor --\x3e\n <se-list id="tool_text_anchor" label="" width="22px" height="22px">\n <se-list-item id="tool_text_anchor_start" value="start" title="properties.text_anchor_start" src="anchor_start.svg" img-height="25px"></se-list-item>\n <se-list-item id="tool_text_anchor_middle" value="middle" title="properties.text_anchor_middle" src="anchor_middle.svg" img-height="25px"></se-list-item>\n <se-list-item id="tool_text_anchor_end" value="end" title="properties.text_anchor_end" src="anchor_end.svg" img-height="25px"></se-list-item>\n </se-list>\n\n \x3c!-- Letter Spacing --\x3e\n <se-spin-input size="2" id="tool_letter_spacing" min="0" max="100" step="1" title="properties.text_letter_spacing" src="letter_spacing.svg"></se-spin-input>\n\n \x3c!-- Word Spacing --\x3e\n <se-spin-input size="2" id="tool_word_spacing" min="0" max="1000" step="1" title="properties.text_word_spacing" src="word_spacing.svg"></se-spin-input>\n\n \x3c!-- Text Length --\x3e\n <se-spin-input size="2" id="tool_text_length" min="0" max="1000" step="1" title="properties.text_length" src="text_length.svg"></se-spin-input>\n\n \x3c!-- Length Adjust --\x3e\n <se-select id="tool_length_adjust" label="properties.text_length_adjust" options="properties.text_length_adjust_spacing,properties.text_length_adjust_spacing_and_glyphs" values="spacing::spacingAndGlyphs"></se-select>\n </div>\n \x3c!-- Not visible, but still used --\x3e\n <input id="text" type="text" size="35">\n <div class="container_panel">\n <div class="tool_sep"></div>\n <se-input id="g_title" data-attr="title" size="8" label="properties.label"></se-input>\n </div> \x3c!-- container_panel --\x3e\n <div class="use_panel">\n <se-button id="tool_unlink_use" title="tools.tool_unlink_use" src="unlink_use.svg"></se-button>\n </div> \x3c!-- use_panel --\x3e\n <div class="g_panel">\n <se-button id="tool_ungroup" title="tools.ungroup" src="ungroup.svg"></se-button>\n </div> \x3c!-- g_panel --\x3e\n \x3c!-- For anchor elements --\x3e\n <div class="a_panel">\n <label id="tool_link_url">\n <span id="linkLabel" class="icon_label"></span>\n <input id="link_url" type="text" size="35">\n </label>\n </div> \x3c!-- a_panel --\x3e\n <div class="path_node_panel">\n <div class="tool_sep"></div>\n <se-button id="tool_node_link" title="tools.node_link" src="tool_node_link.svg" pressed></se-button>\n <div class="tool_sep"></div>\n <se-spin-input id="path_node_x" data-attr="x" size="4" title="properties.node_x" label="properties.x_label">\n </se-spin-input>\n <se-spin-input id="path_node_y" data-attr="y" size="4" title="properties.node_y" label="properties.y_label">\n </se-spin-input>\n <se-select id="seg_type" title="properties.seg_type" label="" options="properties.straight_segments,properties.curve_segments" values="4::6"></se-select>\n <se-button id="tool_node_clone" title="tools.node_clone" src="tool_node_clone.svg"></se-button>\n <se-button id="tool_node_delete" title="tools.node_delete" src="tool_node_delete.svg"></se-button>\n <se-button id="tool_openclose_path" title="tools.openclose_path" src="tool_openclose_path.svg"></se-button>\n <se-button id="tool_add_subpath" title="tools.add_subpath" src="tool_add_subpath.svg"></se-button>\n </div> \x3c!-- path_node_panel --\x3e\n <div id="cur_context_panel"></div>\n</div>',this.editor.$svgEditor.append(Tr.content.cloneNode(!0));const Rr=document.createElement("se-svg-source-editor-dialog");Rr.setAttribute("id","se-svg-editor-dialog"),this.editor.$container.append(Rr),this.updateTitle(),Rr.init(Ur),Ym("tool_link_url").setAttribute("title",Ur.t("tools.set_link_url")),Zm(Ym("tool_source"),this.showSourceEditor.bind(this)),Zm(Ym("tool_wireframe"),this.clickWireframe.bind(this)),Zm(Ym("tool_undo"),this.clickUndo.bind(this)),Zm(Ym("tool_redo"),this.clickRedo.bind(this)),Zm(Ym("tool_clone"),this.clickClone.bind(this)),Zm(Ym("tool_clone_multi"),this.clickClone.bind(this)),Zm(Ym("tool_delete"),this.deleteSelected.bind(this)),Zm(Ym("tool_delete_multi"),this.deleteSelected.bind(this)),Zm(Ym("tool_move_top"),this.moveToTopSelected.bind(this)),Zm(Ym("tool_move_bottom"),this.moveToBottomSelected.bind(this)),Zm(Ym("tool_topath"),this.convertToPath.bind(this)),Zm(Ym("tool_make_link"),this.makeHyperlink.bind(this)),Zm(Ym("tool_make_link_multi"),this.makeHyperlink.bind(this)),Zm(Ym("tool_reorient"),this.reorientPath.bind(this)),Zm(Ym("tool_group_elements"),this.clickGroup.bind(this)),Ym("tool_position").addEventListener("change",(Tr=>this.clickAlignEle.bind(this)(Tr))),Zm(Ym("tool_align_left"),(()=>this.clickAlign.bind(this)("left"))),Zm(Ym("tool_align_right"),(()=>this.clickAlign.bind(this)("right"))),Zm(Ym("tool_align_center"),(()=>this.clickAlign.bind(this)("center"))),Zm(Ym("tool_align_top"),(()=>this.clickAlign.bind(this)("top"))),Zm(Ym("tool_align_bottom"),(()=>this.clickAlign.bind(this)("bottom"))),Zm(Ym("tool_align_middle"),(()=>this.clickAlign.bind(this)("middle"))),Zm(Ym("tool_align_distrib_horiz"),(()=>this.clickAlign.bind(this)("distrib_horiz"))),Zm(Ym("tool_align_distrib_verti"),(()=>this.clickAlign.bind(this)("distrib_verti"))),Zm(Ym("tool_node_clone"),this.clonePathNode.bind(this)),Zm(Ym("tool_node_delete"),this.deletePathNode.bind(this)),Zm(Ym("tool_openclose_path"),this.opencloseSubPath.bind(this)),Zm(Ym("tool_add_subpath"),this.addSubPath.bind(this)),Zm(Ym("tool_node_link"),this.linkControlPoints.bind(this)),Ym("angle").addEventListener("change",this.changeRotationAngle.bind(this)),Ym("blur").addEventListener("change",this.changeBlur.bind(this)),Ym("rect_rx").addEventListener("change",this.changeRectRadius.bind(this)),Ym("font_size").addEventListener("change",this.changeFontSize.bind(this)),Zm(Ym("tool_ungroup"),this.clickGroup.bind(this)),Zm(Ym("tool_bold"),this.clickBold.bind(this)),Zm(Ym("tool_italic"),this.clickItalic.bind(this)),Zm(Ym("tool_text_decoration_underline"),(()=>this.clickTextDecoration.bind(this)("underline"))),Zm(Ym("tool_text_decoration_linethrough"),(()=>this.clickTextDecoration.bind(this)("line-through"))),Zm(Ym("tool_text_decoration_overline"),(()=>this.clickTextDecoration.bind(this)("overline"))),Ym("tool_text_anchor").addEventListener("change",(Tr=>this.clickTextAnchor.bind(this)(Tr))),Ym("tool_letter_spacing").addEventListener("change",this.changeLetterSpacing.bind(this)),Ym("tool_word_spacing").addEventListener("change",this.changeWordSpacing.bind(this)),Ym("tool_text_length").addEventListener("change",this.changeTextLength.bind(this)),Ym("tool_length_adjust").addEventListener("change",(Tr=>this.changeLengthAdjust.bind(this)(Tr))),Zm(Ym("tool_unlink_use"),this.clickGroup.bind(this)),Ym("image_url").addEventListener("change",(Tr=>{this.setImageURL(Tr.currentTarget.value)})),["elem_id","elem_class","circle_cx","circle_cy","circle_r","ellipse_cx","ellipse_cy","ellipse_rx","ellipse_ry","selected_x","selected_y","rect_width","rect_height","line_x1","line_x2","line_y1","line_y2","image_width","image_height","path_node_x","path_node_y"].forEach((Tr=>Ym(Tr).addEventListener("change",this.attrChanger.bind(this))))}}const{$id:rf}=SvgCanvas;class BottomPanel{constructor(Tr){this.editor=Tr}get selectedElement(){return this.editor.selectedElement}get multiselected(){return this.editor.multiselected}changeStrokeWidth(Tr){let Ur=Tr.target.value;0===Ur&&this.editor.selectedElement&&["line","polyline"].includes(this.editor.selectedElement.nodeName)&&(Ur=1),this.editor.svgCanvas.setStrokeWidth(Ur)}changeZoom(Tr){switch(Tr){case"canvas":case"selection":case"layer":case"content":this.editor.zoomChanged(window,Tr);break;default:{const Ur=Number(Tr)>.1?.01*Number(Tr):.1,Rr=this.editor.svgCanvas.getZoom(),{workarea:Qr}=this.editor;this.editor.zoomChanged(window,{width:0,height:0,x:(Qr.scrollLeft+parseFloat(getComputedStyle(Qr,null).width.replace("px",""))/2)/Rr,y:(Qr.scrollTop+parseFloat(getComputedStyle(Qr,null).height.replace("px",""))/2)/Rr,zoom:Ur},!0)}}}updateToolButtonState(){const Tr="none"===this.editor.svgCanvas.getColor("fill"),Ur="none"===this.editor.svgCanvas.getColor("stroke"),Rr=["tool_fhpath","tool_line"],Qr=["tools_rect","tools_ellipse","tool_text","tool_path"];Ur?Rr.forEach((Tr=>{rf(Tr).pressed&&this.editor.leftPanel.clickSelect(),rf(Tr).disabled=!0})):Rr.forEach((Tr=>{rf(Tr).disabled=!1})),Ur&&Tr?Qr.forEach((Tr=>{rf(Tr).pressed&&this.editor.leftPanel.clickSelect(),rf(Tr).disabled=!0})):Qr.forEach((Tr=>{rf(Tr).disabled=!1})),this.editor.svgCanvas.runExtensions("toolButtonStateUpdate",{nofill:Tr,nostroke:Ur})}handleColorPicker(Tr,Ur){const{paint:Rr}=Ur.detail;this.editor.svgCanvas.setPaint(Tr,Rr),this.updateToolButtonState()}handleStrokeAttr(Tr,Ur){this.editor.svgCanvas.setStrokeAttr(Tr,Ur.detail.value)}handleOpacity(Tr){const Ur=Number.parseInt(Tr.currentTarget.value.split("%")[0]);this.editor.svgCanvas.setOpacity(Ur/100)}handlePalette(Tr){Tr.preventDefault();const{picker:Ur,color:Rr}=Tr.detail,Qr="none"===Rr?new _m.Paint:new _m.Paint({alpha:100,solidColor:Rr.substr(1)});"fill"===Ur?rf("fill_color").setPaint(Qr):rf("stroke_color").setPaint(Qr),this.editor.svgCanvas.setColor(Ur,Rr),"none"!==Rr&&1!==this.editor.svgCanvas.getPaintOpacity(Ur)&&this.editor.svgCanvas.setPaintOpacity(Ur,1),this.updateToolButtonState()}init(){const Tr=document.createElement("template"),{i18next:Ur}=this.editor;Tr.innerHTML='<div id="tools_bottom">\n \x3c!-- Zoom buttons --\x3e\n <se-zoom id="zoom" src="zoom.svg" title="Change zoom level" inputsize="40px">\n <se-text value="1000" text="1000%"></se-text>\n <se-text value="400" text="400%"></se-text>\n <se-text value="200" text="200%"></se-text>\n <se-text value="100" text="100%"></se-text>\n <se-text value="50" text="50%"></se-text>\n <se-text value="25" text="25%"></se-text>\n <se-text value="canvas" text="tools.fit_to_canvas"></se-text>\n <se-text value="selection" text="tools.fit_to_sel"></se-text>\n <se-text value="layer" text="tools.fit_to_layer_content"></se-text>\n <se-text value="content" text="tools.fit_to_all"></se-text>\n </se-zoom>\n <se-colorpicker id="fill_color" src="fill.svg" label="properties.fill_color" type="fill"></se-colorpicker>\n <se-colorpicker id="stroke_color" src="stroke.svg" label="properties.stroke_color" type="stroke"></se-colorpicker>\n <se-spin-input id="stroke_width" min="0" max="99" step="1" title="properties.stroke_width" label=""></se-spin-input>\n <se-select id="stroke_style" title="properties.stroke_style" label="" width="22px" height="22px" options="—,...,- -,- .,- .." values="none::2,2::5,5::5,2,2,2::5,2,2,2,2,2"> \n </se-select>\n <se-list id="stroke_linejoin" title="properties.linejoin_miter" label="" width="22px" height="22px">\n <se-list-item id="linejoin_miter" value="miter" src="linejoin_miter.svg" title="properties.linejoin_miter" img-height="22px"></se-list-item>\n <se-list-item id="linejoin_round" value="round" src="linejoin_round.svg" title="properties.linejoin_round" img-height="22px"></se-list-item>\n <se-list-item id="linejoin_bevel" value="bevel" src="linejoin_bevel.svg" title="properties.linejoin_bevel" img-height="22px"></se-list-item>\n </se-list>\n <se-list id="stroke_linecap" title="properties.linecap_butt" label="" width="22px" height="22px">\n <se-list-item id="linecap_butt" value="butt" src="linecap_butt.svg" title="properties.linecap_butt" img-height="22px"></se-list-item>\n <se-list-item id="linecap_square" value="square" src="linecap_square.svg" title="properties.linecap_square" img-height="22px"></se-list-item>\n <se-list-item id="linecap_round" value="round" src="linecap_round.svg" title="properties.linecap_round" img-height="22px"></se-list-item>\n </se-list>\n <se-spin-input size="3" id="opacity" min="0" max="100" step="5" title="properties.opacity" src="opacity.svg"></se-spin-input>\n <se-palette id="palette"></se-palette>\n </div>',this.editor.$svgEditor.append(Tr.content.cloneNode(!0)),rf("palette").addEventListener("change",this.handlePalette.bind(this)),rf("palette").init(Ur);const{curConfig:Rr}=this.editor.configObj;rf("fill_color").setPaint(new _m.Paint({alpha:100,solidColor:Rr.initFill.color})),rf("stroke_color").setPaint(new _m.Paint({alpha:100,solidColor:Rr.initStroke.color})),rf("zoom").addEventListener("change",(Tr=>this.changeZoom.bind(this)(Tr.detail.value))),rf("stroke_color").addEventListener("change",(Tr=>this.handleColorPicker.bind(this)("stroke",Tr))),rf("fill_color").addEventListener("change",(Tr=>this.handleColorPicker.bind(this)("fill",Tr))),rf("stroke_width").addEventListener("change",this.changeStrokeWidth.bind(this)),rf("stroke_style").addEventListener("change",(Tr=>this.handleStrokeAttr.bind(this)("stroke-dasharray",Tr))),rf("stroke_linejoin").addEventListener("change",(Tr=>this.handleStrokeAttr.bind(this)("stroke-linejoin",Tr))),rf("stroke_linecap").addEventListener("change",(Tr=>this.handleStrokeAttr.bind(this)("stroke-linecap",Tr))),rf("opacity").addEventListener("change",this.handleOpacity.bind(this)),rf("fill_color").init(Ur),rf("stroke_color").init(Ur)}updateColorpickers(Tr){rf("fill_color").update(this.editor.svgCanvas,this.editor.selectedElement,Tr),rf("stroke_color").update(this.editor.svgCanvas,this.editor.selectedElement,Tr)}}const{$id:nf,$click:of}=SvgCanvas;class LayersPanel{constructor(Tr){this.updateContextPanel=Tr.topPanel.updateContextPanel.bind(Tr.topPanel),this.editor=Tr}lmenuFunc(Tr){const Ur=Tr?.detail?.trigger;switch(Ur){case"dupe":this.cloneLayer();break;case"delete":this.deleteLayer();break;case"merge_down":this.mergeLayer();break;case"merge_all":this.editor.svgCanvas.mergeAllLayers(),this.updateContextPanel(),this.populateLayers()}}init(){const Tr=document.createElement("template"),{i18next:Ur}=this.editor;Tr.innerHTML='<div id="sidepanels">\n <se-text id="sidepanel_handle" title="ui.panel_action" text="ui.panel"></se-text>\n <div id="sidepanel_content">\n <div id="layerpanel">\n <se-text id="layersLabel" text="layers.layers"></se-text>\n <fieldset id="layerbuttons">\n <se-button id="layer_new" title="layers.new" size="small" src="new.svg"></se-button>\n <se-button id="layer_delete" title="layers.del" size="small" src="delete.svg"></se-button>\n <se-button id="layer_rename" title="layers.rename" size="small" src="text.svg"></se-button>\n <se-button id="layer_up" title="layers.move_up" size="small" src="go_up.svg"></se-button>\n <se-button id="layer_down" title="layers.move_down" size="small" src="go_down.svg"></se-button>\n <se-button id="layer_moreopts" title="common.more_opts" size="small" src="context_menu.svg">\n </se-button>\n </fieldset>\n <table id="layerlist">\n <tr class="layer">\n <td class="layervis"></td>\n <td class="layername">Layer 1</td>\n </tr>\n </table>\n <se-select id="selLayerNames" title="layers.move_selected" label="layers.move_elems_to" options="Layer 1" values="layer1" value="layer1" disabled="disabled">\n </se-select>\n </div>\n </div>\n</div>',this.editor.$svgEditor.append(Tr.content.cloneNode(!0));const Rr=document.createElement("se-cmenu-layers");Rr.setAttribute("id","se-cmenu-layers-more"),Rr.value="layer_moreopts",Rr.setAttribute("leftclick",!0),this.editor.$container.append(Rr),Rr.init(Ur);const Qr=document.createElement("se-cmenu-layers");Qr.setAttribute("id","se-cmenu-layers-list"),Qr.value="layerlist",Qr.setAttribute("leftclick",!1),this.editor.$container.append(Qr),Qr.init(Ur),of(nf("layer_new"),this.newLayer.bind(this)),of(nf("layer_delete"),this.deleteLayer.bind(this)),of(nf("layer_up"),(()=>this.moveLayer.bind(this)(-1))),of(nf("layer_down"),(()=>this.moveLayer.bind(this)(1))),of(nf("layer_rename"),this.layerRename.bind(this)),nf("se-cmenu-layers-more").addEventListener("change",this.lmenuFunc.bind(this)),nf("se-cmenu-layers-list").addEventListener("change",(Tr=>{this.lmenuFunc(Tr)})),of(nf("sidepanel_handle"),(()=>this.toggleSidePanel())),this.toggleSidePanel(this.editor.configObj.curConfig.showlayers)}toggleSidePanel(Tr){void 0===Tr?this.editor.$svgEditor.classList.toggle("open"):Tr?this.editor.$svgEditor.classList.add("open"):this.editor.$svgEditor.classList.remove("open")}newLayer(){let Tr,Ur=this.editor.svgCanvas.getCurrentDrawing().getNumLayers();do{Tr=this.editor.i18next.t("layers.layer")+" "+ ++Ur}while(this.editor.svgCanvas.getCurrentDrawing().hasLayer(Tr));const Rr=prompt(this.editor.i18next.t("notification.enterUniqueLayerName"),Tr);Rr&&(this.editor.svgCanvas.getCurrentDrawing().hasLayer(Rr)?alert(this.editor.i18next.t("notification.dupeLayerName")):(this.editor.svgCanvas.createLayer(Rr),this.updateContextPanel(),this.populateLayers()))}deleteLayer(){if(this.editor.svgCanvas.deleteCurrentLayer()){this.updateContextPanel(),this.populateLayers();const Tr=document.querySelectorAll("#layerlist tr.layer");Array.prototype.forEach.call(Tr,(function(Tr){Tr.classList.remove("layersel")})),document.querySelector("#layerlist tr.layer").classList.add("layersel")}}cloneLayer(){const Tr=this.editor.svgCanvas.getCurrentDrawing().getCurrentLayerName()+" copy",Ur=prompt(this.editor.i18next.t("notification.enterUniqueLayerName"),Tr);Ur&&(this.editor.svgCanvas.getCurrentDrawing().hasLayer(Ur)?alert(this.editor.i18next.t("notification.dupeLayerName")):(this.editor.svgCanvas.cloneLayer(Ur),this.updateContextPanel(),this.populateLayers()))}index(Tr){return Tr?Array.from(document.querySelector("#layerlist tbody").children).indexOf(Tr):-1}mergeLayer(){this.index(document.querySelector("#layerlist tr.layersel"))-1!=this.editor.svgCanvas.getCurrentDrawing().getNumLayers()-1&&(this.editor.svgCanvas.mergeLayer(),this.updateContextPanel(),this.populateLayers())}moveLayer(Tr){const Ur=this.editor.svgCanvas.indexCurrentLayer();-1!==Ur&&(this.editor.svgCanvas.setCurrentLayerPosition(Ur-Tr),this.populateLayers())}layerRename(){const Tr=document.querySelector("#layerlist tr.layersel td.layername"),Ur=Tr?Tr.textContent:"",Rr=prompt(this.editor.i18next.t("notification.enterNewLayerName"),"");Rr&&(Ur===Rr||this.editor.svgCanvas.getCurrentDrawing().hasLayer(Rr)?alert(this.editor.i18next.t("notification.layerHasThatName")):(this.editor.svgCanvas.renameCurrentLayer(Rr),this.populateLayers()))}toggleHighlightLayer(Tr){let Ur;const Rr=[],Qr=this.editor.svgCanvas.getCurrentDrawing().getNumLayers();for(Ur=0;Ur<Qr;Ur++)Rr[Ur]=this.editor.svgCanvas.getCurrentDrawing().getLayerName(Ur);Tr?Rr.forEach((Ur=>{Ur!==Tr&&this.editor.svgCanvas.getCurrentDrawing().setLayerOpacity(Ur,.5)})):Rr.forEach((Tr=>{this.editor.svgCanvas.getCurrentDrawing().setLayerOpacity(Tr,1)}))}populateLayers(){this.editor.svgCanvas.clearSelection();const Tr=this,Ur=nf("layerlist").querySelector("tbody");for(;Ur.firstChild;)Ur.removeChild(Ur.firstChild);nf("selLayerNames").setAttribute("options","");const Rr=this.editor.svgCanvas.getCurrentDrawing(),Qr=Rr.getCurrentLayerName();let Vr=this.editor.svgCanvas.getCurrentDrawing().getNumLayers(),Gr="",Dr="";for(;Vr--;){const Tr=Rr.getLayerName(Vr),Hr=document.createElement("tr");Hr.className=Tr===Qr?"layer layersel":"layer";const zr=document.createElement("td");zr.className=Rr.getLayerVisibility(Tr)?"layervis":"layerinvis layervis";const Kr=document.createElement("img");Kr.src="./images/eye.svg",Kr.style.width="14px",Kr.style.width="14px",zr.appendChild(Kr);const $r=document.createElement("td");$r.className="layername",$r.textContent=Tr,Hr.appendChild(zr),Hr.appendChild($r),Ur.appendChild(Hr),Gr=Gr?Gr+"::"+Tr:Tr,Dr=Dr?Dr+","+Tr:Tr}nf("selLayerNames").setAttribute("options",Dr),nf("selLayerNames").setAttribute("values",Gr);const Hr=nf("layerlist").querySelectorAll("td.layername");Array.from(Hr).forEach((function(Ur){Ur.addEventListener("mouseup",(function(Ur){const Rr=nf("layerlist").querySelectorAll("tr.layer");Array.from(Rr).forEach((function(Tr){Tr.classList.remove("layersel")})),Ur.currentTarget.parentNode.classList.add("layersel"),Tr.editor.svgCanvas.setCurrentLayer(Ur.currentTarget.textContent),Tr.editor.svgCanvas.runExtensions("layersChanged"),Ur.preventDefault()})),Ur.addEventListener("mouseup",(Ur=>{Tr.toggleHighlightLayer(Ur.currentTarget.textContent)})),Ur.addEventListener("mouseout",(Ur=>{Tr.toggleHighlightLayer()}))}));const zr=nf("layerlist").querySelectorAll("td.layervis");Array.from(zr).forEach((function(Ur){of(Ur,(function(Ur){const Rr=Ur.currentTarget.parentNode.querySelector("td.layername"),Qr=Rr?Rr.textContent:"",Vr=Ur.currentTarget.classList.contains("layerinvis");Tr.editor.svgCanvas.setLayerVisibility(Qr,Vr),Ur.currentTarget.classList.toggle("layerinvis"),Tr.editor.svgCanvas.runExtensions("layerVisChanged")}))}));let Kr=5-nf("layerlist").querySelectorAll("tr.layer").length;for(;Kr-- >0;){const Tr=document.createElement("tr");Tr.innerHTML='<td style="color:white">_</td><td/>',Ur.append(Tr)}Tr.editor.svgCanvas.runExtensions("layersChanged")}}const{$id:af,$click:sf,convertUnit:lf,isValidUnit:cf}=SvgCanvas;class MainMenu{constructor(Tr){this.editor=Tr,this.editor.exportWindowCt=0}hideDocProperties(){const Tr=af("se-img-prop");Tr.setAttribute("dialog","close"),Tr.setAttribute("save",this.editor.configObj.pref("img_save")),this.editor.docprops=!1}hidePreferences(){af("se-edit-prefs").setAttribute("dialog","close"),this.editor.configObj.preferences=!1}saveDocProperties(Tr){const{title:Ur,w:Rr,h:Qr,save:Vr}=Tr.detail;return this.editor.svgCanvas.setDocumentTitle(Ur),("fit"===Rr||cf("width",Rr))&&("fit"===Qr||cf("height",Qr))?this.editor.svgCanvas.setResolution(Rr,Qr)?(this.editor.configObj.pref("img_save",Vr),this.editor.updateCanvas(),this.hideDocProperties(),!0):(seAlert(this.editor.i18next.t("notification.noContentToFitTo")),!1):(seAlert(this.editor.i18next.t("notification.invalidAttrValGiven")),!1)}async savePreferences(Tr){const{lang:Ur,bgcolor:Rr,bgurl:Qr,gridsnappingon:Vr,gridsnappingstep:Gr,gridcolor:Dr,showrulers:Hr,baseunit:zr}=Tr.detail;this.editor.setBackground(Rr,Qr),Ur&&Ur!==this.editor.configObj.pref("lang")&&(this.editor.configObj.pref("lang",Ur),seAlert("Changing the language needs reload")),this.editor.configObj.curConfig.gridSnapping=Vr,this.editor.configObj.curConfig.snappingStep=Gr,this.editor.configObj.curConfig.gridColor=Dr,this.editor.configObj.curConfig.showRulers=Hr,this.editor.configObj.curConfig.showRulers&&this.editor.rulers.updateRulers(),this.editor.configObj.curConfig.baseUnit=zr,this.editor.svgCanvas.setConfig(this.editor.configObj.curConfig),this.editor.updateCanvas(),this.hidePreferences()}async clickExport(Tr){if("ok"!==Tr?.detail?.trigger||void 0===Tr?.detail?.imgType)return;const Ur=Tr?.detail?.imgType,Rr=Tr?.detail?.quality?Tr?.detail?.quality/100:1;const openExportWindow=()=>{"new"===this.editor.configObj.curConfig.exportWindowType&&this.editor.exportWindowCt++,this.editor.exportWindowName=this.editor.configObj.curConfig.canvasName+this.editor.exportWindowCt},Qr=Rm;"PDF"===Ur?(this.editor.customExportPDF||Qr||openExportWindow(),this.editor.svgCanvas.exportPDF(undefined)):(this.editor.customExportImage||openExportWindow(),await this.editor.svgCanvas.rasterExport(Ur,Rr,this.editor.exportWindowName))}showDocProperties(){if(this.editor.docprops)return;this.editor.docprops=!0;const Tr=af("se-img-prop"),Ur=this.editor.svgCanvas.getResolution();"px"!==this.editor.configObj.curConfig.baseUnit&&(Ur.w=lf(Ur.w)+this.editor.configObj.curConfig.baseUnit,Ur.h=lf(Ur.h)+this.editor.configObj.curConfig.baseUnit),Tr.setAttribute("save",this.editor.configObj.pref("img_save")),Tr.setAttribute("width",Ur.w),Tr.setAttribute("height",Ur.h),Tr.setAttribute("title",this.editor.svgCanvas.getDocumentTitle()),Tr.setAttribute("dialog","open")}showPreferences(){if(this.editor.configObj.preferences)return;this.editor.configObj.preferences=!0;const Tr=af("se-edit-prefs"),Ur=this.editor.configObj.curPrefs.bkgd_color,Rr=this.editor.configObj.pref("bkgd_url");Rr&&Tr.setAttribute("bgurl",Rr),Tr.setAttribute("gridsnappingon",this.editor.configObj.curConfig.gridSnapping),Tr.setAttribute("gridsnappingstep",this.editor.configObj.curConfig.snappingStep),Tr.setAttribute("gridcolor",this.editor.configObj.curConfig.gridColor),Tr.setAttribute("canvasbg",Ur),Tr.setAttribute("dialog","open")}openHomePage(){window.open("https://github.com/SVG-Edit/svgedit","_blank")}init(){const Tr=document.createElement("template");Tr.innerHTML='\n <se-menu id="main_button" label="SVG-Edit" src="logo.svg" alt="logo">\n <se-menu-item id="tool_export" label="tools.export_img" src="export.svg"></se-menu-item>\n <se-menu-item id="tool_docprops" label="tools.docprops" shortcut="shift+D" src="docprop.svg"></se-menu-item>\n <se-menu-item id="tool_editor_prefs" label="config.editor_prefs" src="editPref.svg"></se-menu-item>\n <se-menu-item id="tool_editor_homepage" label="tools.editor_homepage" src="logo.svg"></se-menu-item>\n </se-menu>',this.editor.$svgEditor.append(Tr.content.cloneNode(!0)),sf(af("tool_export"),(function(){document.getElementById("se-export-dialog").setAttribute("dialog","open")})),af("se-export-dialog").addEventListener("change",this.clickExport.bind(this)),af("tool_docprops").addEventListener("click",this.showDocProperties.bind(this)),af("tool_editor_prefs").addEventListener("click",this.showPreferences.bind(this)),af("tool_editor_homepage").addEventListener("click",this.openHomePage.bind(this)),af("se-img-prop").addEventListener("change",function(Tr){"closed"===Tr.detail.dialog?this.hideDocProperties():this.saveDocProperties(Tr)}.bind(this)),af("se-edit-prefs").addEventListener("change",function(Tr){"closed"===Tr.detail.dialog?this.hidePreferences():this.savePreferences(Tr)}.bind(this))}}
|
|
1043
|
+
*/let Om={};const injectExtendedContextMenuItemsIntoDom=function(){Object.values(Om).forEach((Tr=>{!function(Tr){Object.keys(Om).length||document.getElementById("cmenu_canvas").appendChild("<li class='separator'>");const Ur=Tr.shortcut||"";document.getElementById("cmenu_canvas").appendChild(`\n <li class='disabled'><a href='#${Tr.id}'>${Tr.label}<span class='shortcut'>${Ur}</span></a></li>`)}(Tr)}))};const{$id:Qm,getTypeMap:Vm}=SvgCanvas;class Rulers{constructor(Tr){this.rulerIntervals=[];for(let Tr=.1;Tr<1e5;Tr*=10)this.rulerIntervals.push(Tr),this.rulerIntervals.push(2*Tr),this.rulerIntervals.push(5*Tr);this.svgCanvas=Tr.svgCanvas,this.editor=Tr;const Ur=document.createElement("template");Ur.innerHTML='<style>\n /* Rulers\n——————————————————————————————————————*/\n\n #ruler_corner {\n background: var(--ruler-color);\n grid-area: corner;\n width: 15px;\n height: 15px;\n overflow: hidden;\n }\n\n #ruler_x {\n background: var(--ruler-color);\n grid-area: rulerX;\n height: 15px;\n border-bottom: 1px solid;\n border-left: 1px solid #777;\n overflow: hidden;\n }\n\n #ruler_y {\n background: var(--ruler-color);\n grid-area: rulerY;\n width: 15px;\n border-right: 1px solid;\n border-top: 1px solid #777;\n overflow: hidden;\n }\n\n #ruler_x canvas {\n float: left;\n }\n</style>\n<div id="ruler_corner"></div>\n<div id="ruler_x">\n <div>\n <canvas height="15"></canvas>\n </div>\n</div>\n<div id="ruler_y">\n <div>\n <canvas width="15"></canvas>\n </div>\n</div>',this.editor.$svgEditor.append(Ur.content.cloneNode(!0));const{$id:Rr}=SvgCanvas;this.rulerX=Rr("ruler_x"),this.rulerY=Rr("ruler_y"),this.rulerCorner=Rr("ruler_corner")}display(Tr){Tr?(this.rulerX.style.removeProperty("display"),this.rulerY.style.removeProperty("display"),this.rulerCorner.style.removeProperty("display")):(this.rulerX.style.display="none",this.rulerY.style.display="none",this.rulerCorner.style.display="none")}manageScroll(){this.rulerX&&(this.rulerX.scrollLeft=this.editor.workarea.scrollLeft),this.rulerY&&(this.rulerY.scrollTop=this.editor.workarea.scrollTop)}updateRulers(Tr,Ur){let Rr,Qr;Ur||(Ur=this.svgCanvas.getZoom()),Tr||(Tr=document.getElementById("svgcanvas"));const Vr=3e4,Gr=this.svgCanvas.getSvgContent(),Dr=Vm()[this.editor.configObj.curConfig.baseUnit];for(Rr=0;Rr<2;Rr++){const Hr=0===Rr,zr=Hr?"x":"y",Kr=Hr?"width":"height",$r=Number(Gr.getAttribute(zr)),Wr=Qm("ruler_"+zr).querySelector("canvas"),Xr=Wr.cloneNode(!0);Wr.replaceWith(Xr);const Yr=Xr;let Zr;"width"===Kr?Zr=parseFloat(getComputedStyle(Tr,null).width.replace("px","")):"height"===Kr&&(Zr=parseFloat(getComputedStyle(Tr,null).height.replace("px","")));const Jr=Zr;Yr.parentNode.style[Kr]=Jr+"px";let en,tn,rn,nn=Yr.getContext("2d");nn.fillStyle="rgb(200,0,0)",nn.fillRect(0,0,Yr.width,Yr.height);const on=Array.prototype.filter.call(Xr.parentNode.children,(function(Tr){return Tr!==Xr}));if(Array.from(on).forEach((function(Tr){Tr.remove()})),Zr>=Vr){let Tr;for(rn=Number.parseInt(Zr/Vr)+1,en=[],en[0]=nn,Qr=1;Qr<rn;Qr++)Yr[Kr]=Vr,Tr=Yr.cloneNode(!0),Yr.parentNode.append(Tr),en[Qr]=Tr.getContext("2d");Tr[Kr]=Zr%Vr,Zr=Vr}Yr[Kr]=Zr;const an=Dr*Ur,sn=50/an;let cn=1;for(Qr=0;Qr<this.rulerIntervals.length&&(tn=this.rulerIntervals[Qr],cn=tn,!(sn<=tn));Qr++);const An=cn*an;nn.font="9px sans-serif";let un=$r/an%cn*an,dn=un-An,pn=0;for(;un<Jr;){dn+=An;const Tr=Math.round(un)+.5;let Ur;if(Hr?(nn.moveTo(Tr,15),nn.lineTo(Tr,0)):(nn.moveTo(15,Tr),nn.lineTo(0,Tr)),tn=(dn-$r)/an,cn>=1)Ur=Math.round(tn);else{const Tr=String(cn).split(".")[1].length;Ur=tn.toFixed(Tr)}if(0!==Ur&&1e3!==Ur&&Ur%1e3==0&&(Ur=Ur/1e3+"K"),Hr)nn.fillText(Ur,un+2,8);else{const Tr=String(Ur).split("");for(Qr=0;Qr<Tr.length;Qr++)nn.fillText(Tr[Qr],1,un+9+9*Qr)}const Rr=An/10;for(Qr=1;Qr<10;Qr++){let Tr=Math.round(un+Rr*Qr)+.5;if(en&&Tr>Zr){if(pn++,nn.stroke(),pn>=rn){Qr=10,un=Jr;continue}nn=en[pn],un-=Vr,Tr=Math.round(un+Rr*Qr)+.5}const Ur=Qr%2?12:10;Hr?(nn.moveTo(Tr,15),nn.lineTo(Tr,Ur)):(nn.moveTo(15,Tr),nn.lineTo(Ur,Tr))}un+=An}nn.strokeStyle="#000",nn.stroke()}}}const{$id:Gm,$qq:Dm,$click:Hm,convertUnit:zm}=SvgCanvas;class EditorStartup{constructor(Tr){this.extensionsAdded=!1,this.messageQueue=[],this.$container=Tr??Gm("svg_editor")}async init(){"localStorage"in window&&(this.storage=window.localStorage),this.configObj.load();const{i18next:Tr}=await putLocale(this.configObj.pref("lang"),this.goodLangs);this.i18next=Tr,await Promise.resolve().then((function(){return wm})),await Promise.resolve().then((function(){return Um}));try{const Tr=document.createElement("template");Tr.innerHTML='<div class="svg_editor">\n <div id="workarea">\n <div id="svgcanvas"></div>\n </div>\n</div>',this.$container.append(Tr.content.cloneNode(!0)),this.$svgEditor=Dm(".svg_editor"),this.$svgEditor.style.visibility="hidden",this.workarea=Gm("workarea");const Ur=document.createElement("se-img-prop-dialog");Ur.setAttribute("id","se-img-prop"),this.$container.append(Ur),Ur.init(this.i18next);const Rr=document.createElement("se-edit-prefs-dialog");Rr.setAttribute("id","se-edit-prefs"),this.$container.append(Rr),Rr.init(this.i18next);const Qr=document.createElement("se-cmenu_canvas-dialog");Qr.setAttribute("id","se-cmenu_canvas"),this.$container.append(Qr),Qr.init(this.i18next);const Vr=document.createElement("se-alert-dialog");Vr.setAttribute("id","se-alert-dialog"),this.$container.append(Vr);const Gr=document.createElement("se-prompt-dialog");Gr.setAttribute("id","se-prompt-dialog"),this.$container.append(Gr);const Dr=document.createElement("se-export-dialog");Dr.setAttribute("id","se-export-dialog"),this.$container.append(Dr),Dr.init(this.i18next)}catch(Tr){console.error(Tr)}this.svgCanvas=new SvgCanvas(Gm("svgcanvas"),this.configObj.curConfig),this.modeEvent=this.svgCanvas.modeEvent,document.addEventListener("modeChange",(Tr=>this.modeListener(Tr))),this.enableToolCancel=!0,this.leftPanel.init(),this.bottomPanel.init(),this.topPanel.init(),this.layersPanel.init(),this.mainMenu.init(),this.svgCanvas,this.canvMenu=Gm("se-cmenu_canvas"),this.exportWindow=null,this.defaultImageURL=`${this.configObj.curConfig.imgPath}/logo.svg`;this.uiContext="toolbars",(()=>{const Tr=window.opener||window.parent;if(Tr)try{const Ur=new Tr.CustomEvent("svgEditorReady",{bubbles:!0,cancelable:!0});Tr.document.documentElement.dispatchEvent(Ur)}catch(Tr){}})(),this.rulers=new Rulers(this),this.layersPanel.populateLayers(),this.selectedElement=null,this.multiselected=!1;const Ur=Gm("cur_context_panel");Hm(Ur,(Tr=>{const Ur=Tr.target;return Ur.hasAttribute("data-root")?this.svgCanvas.leaveContext():this.svgCanvas.setContext(Ur.textContent),this.svgCanvas.clearSelection(),!1})),this.svgCanvas.bind("selected",this.selectedChanged.bind(this)),this.svgCanvas.bind("transition",this.elementTransition.bind(this)),this.svgCanvas.bind("changed",this.elementChanged.bind(this)),this.svgCanvas.bind("exported",this.exportHandler.bind(this)),this.svgCanvas.bind("exportedPDF",function(Tr,Ur){if(!Ur.output)return;const{exportWindowName:Rr}=Ur;Rr&&(this.exportWindow=window.open("",this.exportWindowName)),this.exportWindow&&!this.exportWindow.closed?this.exportWindow.location.href=Ur.output:seAlert(this.i18next.t("notification.popupWindowBlocked"))}.bind(this)),this.svgCanvas.bind("zoomed",this.zoomChanged.bind(this)),this.svgCanvas.bind("zoomDone",this.zoomDone.bind(this)),this.svgCanvas.bind("updateCanvas",function(Tr,Ur){let{center:Rr,newCtr:Qr}=Ur;this.updateCanvas(Rr,Qr)}.bind(this)),this.svgCanvas.bind("contextset",this.contextChanged.bind(this)),this.svgCanvas.bind("extension_added",this.extAdded.bind(this)),this.svgCanvas.bind("elementRenamed",this.elementRenamed.bind(this)),this.svgCanvas.bind("beforeClear",this.beforeClear.bind(this)),this.svgCanvas.bind("afterClear",this.afterClear.bind(this)),this.svgCanvas.textActions.setInputElem(Gm("text")),this.setBackground(this.configObj.pref("bkgd_color"),this.configObj.pref("bkgd_url"));const Rr=this.svgCanvas.getResolution();"px"!==this.configObj.curConfig.baseUnit&&(Rr.w=zm(Rr.w)+this.configObj.curConfig.baseUnit,Rr.h=zm(Rr.h)+this.configObj.curConfig.baseUnit),Gm("se-img-prop").setAttribute("dialog","close"),Gm("se-img-prop").setAttribute("title",this.svgCanvas.getDocumentTitle()),Gm("se-img-prop").setAttribute("width",Rr.w),Gm("se-img-prop").setAttribute("height",Rr.h),Gm("se-img-prop").setAttribute("save",this.configObj.pref("img_save"));const Qr=document.querySelectorAll("select");Array.from(Qr).forEach((function(Tr){Tr.addEventListener("change",(function(Tr){Tr.currentTarget.blur()}))}));let Vr=!1;Gm("selLayerNames").addEventListener("change",(Tr=>{const Ur=Tr.detail.value,Rr=this.i18next.t("notification.QmoveElemsToLayer").replace("%s",Ur),moveToLayer=Tr=>{Vr=!0,this.svgCanvas.moveSelectedToLayer(Ur),this.svgCanvas.clearSelection(),this.layersPanel.populateLayers()};if(Ur)if(Vr)moveToLayer();else{if(!seConfirm(Rr))return;moveToLayer()}})),Gm("tool_font_family").addEventListener("change",(Tr=>{this.svgCanvas.setFontFamily(Tr.detail.value)})),Gm("seg_type").addEventListener("change",(Tr=>{this.svgCanvas.setSegType(Tr.detail.value)}));const addListenerMulti=(Tr,Ur,Rr)=>{Ur.split(" ").forEach((Ur=>Tr.addEventListener(Ur,Rr,!1)))};addListenerMulti(Gm("text"),"keyup input",(Tr=>{this.svgCanvas.setTextContent(Tr.currentTarget.value)})),Gm("link_url").addEventListener("change",(Tr=>{Tr.currentTarget.value.length?this.svgCanvas.setLinkURL(Tr.currentTarget.value):this.svgCanvas.removeHyperlink()})),Gm("g_title").addEventListener("change",(Tr=>{this.svgCanvas.setGroupTitle(Tr.currentTarget.value)}));let Gr,Dr=null,Hr=null,zr=!1,Kr=!1,$r="select";Gm("svgcanvas").addEventListener("mouseup",(Tr=>!1===zr||(this.workarea.scrollLeft-=Tr.clientX-Dr,this.workarea.scrollTop-=Tr.clientY-Hr,Dr=Tr.clientX,Hr=Tr.clientY,"mouseup"===Tr.type&&(zr=!1),!1))),Gm("svgcanvas").addEventListener("mousemove",(Tr=>!1===zr||(this.workarea.scrollLeft-=Tr.clientX-Dr,this.workarea.scrollTop-=Tr.clientY-Hr,Dr=Tr.clientX,Hr=Tr.clientY,"mouseup"===Tr.type&&(zr=!1),!1))),Gm("svgcanvas").addEventListener("mousedown",(Tr=>(this.enableToolCancel=!1,1!==Tr.button&&!0!==Kr||(Tr.preventDefault(),zr=!0,$r=this.svgCanvas.getMode(),this.svgCanvas.setMode("ext-panning"),this.workarea.style.cursor="grab",Dr=Tr.clientX,Hr=Tr.clientY,!1)))),this.$container.addEventListener("wheel",(Tr=>{Tr.ctrlKey&&Tr.preventDefault()})),window.addEventListener("mouseup",(Tr=>{this.enableToolCancel=!0,1===Tr.button&&this.svgCanvas.setMode($r??"select"),zr=!1})),this.workarea.addEventListener("dblclick",(Tr=>{"ext-panning"===this.svgCanvas.getMode()&&this.leftPanel.clickSelect()})),document.addEventListener("keydown",(Tr=>{"BODY"===Tr.target.nodeName&&("space"===Tr.code.toLowerCase()?(this.svgCanvas.spaceKey=Kr=!0,Tr.preventDefault()):"shift"===Tr.key.toLowerCase()&&"zoom"===this.svgCanvas.getMode()&&(this.workarea.style.cursor="crosshair",Tr.preventDefault()))})),document.addEventListener("keyup",(Tr=>{"BODY"===Tr.target.nodeName&&("space"===Tr.code.toLowerCase()?(this.svgCanvas.spaceKey=Kr=!1,this.svgCanvas.setMode("ext-panning"===$r?"select":$r??"select"),Tr.preventDefault()):"shift"===Tr.key.toLowerCase()&&"zoom"===this.svgCanvas.getMode()&&(this.workarea.style.cursor="crosshair",Tr.preventDefault()))})),this.setPanning=Tr=>{this.svgCanvas.spaceKey=Kr=Tr};const unfocus=()=>{Gr.blur()},Wr=this.$svgEditor.querySelectorAll("button, select, input:not(#text)"),Xr=this;Array.prototype.forEach.call(Wr,(function(Tr){Tr.addEventListener("focus",(Tr=>{Gr=Tr.currentTarget,Xr.uiContext="toolbars",Xr.workarea.addEventListener("mousedown",unfocus)})),Tr.addEventListener("blur",(()=>{Xr.uiContext="canvas",Xr.workarea.removeEventListener("mousedown",unfocus),"textedit"===Xr.svgCanvas.getMode()&&Gm("text").focus()}))}));const Yr={width:function getWidth(){return Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth,document.documentElement.clientWidth)}(),height:function getHeight(){return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.documentElement.clientHeight)}()};window.addEventListener("resize",(()=>{Object.entries(Yr).forEach((Tr=>{let[Ur,Rr]=Tr;const Qr="width"===Ur?window.innerWidth-15:window.innerHeight;this.workarea["scroll"+("width"===Ur?"Left":"Top")]-=(Qr-Rr)/2,Yr[Ur]=Qr}))})),this.workarea.addEventListener("scroll",(()=>{this.rulers.manageScroll()})),Gm("stroke_width").value=this.configObj.curConfig.initStroke.width,Gm("opacity").value=100*this.configObj.curConfig.initOpacity;const Zr=document.getElementsByClassName("push_button");Array.from(Zr).forEach((function(Tr){Tr.addEventListener("mousedown",(function(Tr){Tr.currentTarget.classList.contains("disabled")||(Tr.currentTarget.classList.add("push_button_pressed"),Tr.currentTarget.classList.remove("push_button"))})),Tr.addEventListener("mouseout",(function(Tr){Tr.currentTarget.classList.add("push_button"),Tr.currentTarget.classList.remove("push_button_pressed")})),Tr.addEventListener("mouseup",(function(Tr){Tr.currentTarget.classList.add("push_button"),Tr.currentTarget.classList.remove("push_button_pressed")}))})),this.layersPanel.populateLayers();addListenerMulti(window,"load resize",(()=>{this.workarea.style.lineHeight=this.workarea.style.height}));const Jr=document.querySelectorAll("input");Array.from(Jr).forEach((function(Tr){Tr.setAttribute("autocomplete","off")}));const en=document.querySelectorAll("select");Array.from(en).forEach((function(Tr){Tr.setAttribute("autocomplete","off")})),Gm("se-svg-editor-dialog").addEventListener("change",function(Tr){"click"===Tr?.detail?.copy?this.cancelOverlays(Tr):"dynamic"===Tr?.detail?.dialog?this.toggleDynamicOutput(Tr):"closed"===Tr?.detail?.dialog?this.hideSourceEditor():this.saveSourceEditor(Tr)}.bind(this)),Gm("se-cmenu_canvas").addEventListener("change",function(Tr){const Ur=Tr?.detail?.trigger;switch(Ur){case"delete":this.svgCanvas.deleteSelectedElements();break;case"cut":this.cutSelected();break;case"copy":this.copySelected();break;case"paste":this.svgCanvas.pasteElements();break;case"paste_in_place":this.svgCanvas.pasteElements("in_place");break;case"group":case"group_elements":this.svgCanvas.groupSelectedElements();break;case"ungroup":this.svgCanvas.ungroupSelectedElement();break;case"move_front":this.svgCanvas.moveToTopSelectedElement();break;case"move_up":this.moveUpDownSelected("Up");break;case"move_down":this.moveUpDownSelected("Down");break;case"move_back":this.svgCanvas.moveToBottomSelectedElement();break;default:Boolean(Om[Ur])&&function(Tr){return Om[Tr].action}(Ur).call()}}.bind(this)),this.ready(function(){const Tr=Gm(`tool_${this.configObj.curConfig.initTool}`),Ur=Gm(this.configObj.curConfig.initTool),Rr=Gm("tool_select"),Qr=Gm("se-edit-prefs");Tr?Tr.click():Ur?Ur.click():Rr.click(),this.configObj.curConfig.wireframe&&Gm("tool_wireframe").click(),this.configObj.curConfig.showRulers?this.rulers.display(!0):this.rulers.display(!1),this.configObj.curConfig.showRulers&&Qr.setAttribute("showrulers",!0),this.configObj.curConfig.baseUnit&&Qr.setAttribute("baseunit",this.configObj.curConfig.baseUnit),this.configObj.curConfig.gridSnapping&&Qr.setAttribute("gridsnappingon",!0),this.configObj.curConfig.snappingStep&&Qr.setAttribute("gridsnappingstep",this.configObj.curConfig.snappingStep),this.configObj.curConfig.gridColor&&Qr.setAttribute("gridcolor",this.configObj.curConfig.gridColor),this.configObj.curConfig.dynamicOutput&&Qr.setAttribute("dynamicoutput",!0)}.bind(this)),Gm("zoom").value=(100*this.svgCanvas.getZoom()).toFixed(1),this.canvMenu.setAttribute("disableallmenu",!0),this.canvMenu.setAttribute("enablemenuitems","#delete,#cut,#copy"),this.enableOrDisableClipboard(),window.addEventListener("storage",function(Tr){"svgedit_clipboard"===Tr.key&&this.enableOrDisableClipboard()}.bind(this)),window.addEventListener("beforeunload",function(Tr){}.bind(this)),this.workarea.addEventListener("dragenter",this.onDragEnter),this.workarea.addEventListener("dragover",this.onDragOver),this.workarea.addEventListener("dragleave",this.onDragLeave),this.updateCanvas(!0),this.extAndLocaleFunc(),this.ready((()=>{injectExtendedContextMenuItemsIntoDom()})),await this.runCallbacks()}async extAndLocaleFunc(){this.$svgEditor.style.visibility="visible";try{await Promise.all(this.configObj.curConfig.extensions.map((async Tr=>{try{const Ur=this.configObj.curConfig.extPath,Rr=await import(`${Ur}/${encodeURIComponent(Tr)}/${encodeURIComponent(Tr)}.js`),{name:Qr=Tr,init:Vr}=Rr.default;return this.addExtension(Qr,Vr&&Vr.bind(this),{langParam:"en"})}catch(Ur){return void console.error("Extension failed to load: "+Tr+"; ",Ur)}}))),await Promise.all(this.configObj.curConfig.userExtensions.map((async Tr=>{let{pathName:Ur,config:Rr}=Tr;try{const Tr=await import(encodeURI(Ur)),{name:Qr,init:Vr}=Tr.default;return this.addExtension(Qr,Vr&&Vr.bind(this,Rr),{})}catch(Tr){return void console.error("Extension failed to load: "+Ur+"; ",Tr)}}))),this.svgCanvas.bind("extensions_added",((Tr,Ur)=>{this.extensionsAdded=!0,this.setAll(),"ignore"===this.storagePromptState&&this.updateCanvas(!0),this.messageQueue.forEach((Tr=>{this.svgCanvas.call("message",Tr)}))})),this.svgCanvas.call("extensions_added")}catch(Tr){console.error(Tr)}}modeListener(Tr){const Ur=this.svgCanvas.getMode();this.setCursorStyle(Ur)}setCursorStyle(Tr){let Ur="auto";switch(Tr){case"ext-panning":Ur="grab";break;case"zoom":case"shapelib":Ur="crosshair";break;case"circle":case"ellipse":case"rect":case"square":case"star":case"polygon":Ur=`url("./images/cursors/${Tr}_cursor.svg"), crosshair`;break;case"text":Ur="text";break;default:Ur="auto"}this.workarea.style.cursor=Ur}cancelTool(){const Tr=this.svgCanvas.getMode();["zoom","rect","square","circle","ellipse","line","text","star","polygon","shapelib","image"].includes(Tr)&&this.leftPanel.clickSelect()}}const{$id:Km,$qa:$m,$click:Wm}=SvgCanvas;class LeftPanel{constructor(Tr){this.editor=Tr}updateLeftPanel(Tr){return!Tr.disabled&&($m("#tools_left *[pressed]").forEach((Tr=>{Tr.pressed=!1})),Km(Tr).pressed=!0,!0)}clickSelect(){this.updateLeftPanel("tool_select")&&this.editor.svgCanvas.setMode("select")}clickFHPath(){this.updateLeftPanel("tool_fhpath")&&this.editor.svgCanvas.setMode("fhpath")}clickLine(){this.updateLeftPanel("tool_line")&&this.editor.svgCanvas.setMode("line")}clickSquare(){this.updateLeftPanel("tool_square")&&this.editor.svgCanvas.setMode("square")}clickRect(){this.updateLeftPanel("tool_rect")&&this.editor.svgCanvas.setMode("rect")}clickFHRect(){this.updateLeftPanel("tool_fhrect")&&this.editor.svgCanvas.setMode("fhrect")}clickCircle(){this.updateLeftPanel("tool_circle")&&this.editor.svgCanvas.setMode("circle")}clickEllipse(){this.updateLeftPanel("tool_ellipse")&&this.editor.svgCanvas.setMode("ellipse")}clickFHEllipse(){this.updateLeftPanel("tool_fhellipse")&&this.editor.svgCanvas.setMode("fhellipse")}clickImage(){this.updateLeftPanel("tool_image")&&this.editor.svgCanvas.setMode("image")}clickZoom(){this.updateLeftPanel("tool_zoom")&&(this.editor.svgCanvas.setMode("zoom"),this.editor.workarea.style.cursor=this.editor.zoomInIcon)}dblclickZoom(){this.updateLeftPanel("tool_zoom")&&(this.editor.zoomImage(),this.clickSelect())}clickText(){this.updateLeftPanel("tool_text")&&this.editor.svgCanvas.setMode("text")}clickPath(){this.updateLeftPanel("tool_path")&&this.editor.svgCanvas.setMode("path")}add(Tr,Ur){Wm(Km(Tr),(()=>{this.updateLeftPanel(Tr)&&Ur()}))}init(){const Tr=document.createElement("template");Tr.innerHTML='<div id="tools_left">\n <se-button id="tool_select" title="tools.mode_select" src="select.svg"></se-button>\n <se-button id="tool_zoom" title="tools.mode_zoom" src="zoom.svg" shortcut="Z"></se-button>\n <se-button id="tool_fhpath" title="tools.mode_fhpath" src="pencil.svg" shortcut="Q"></se-button>\n <se-button id="tool_line" title="tools.mode_line" src="pen.svg" shortcut="L"></se-button>\n <se-button id="tool_path" title="tools.mode_path" src="path.svg" shortcut="P"></se-button>\n <se-flyingbutton id="tools_rect" title="tools.square_rect_tool">\n <se-button id="tool_rect" title="tools.mode_rect" src="rect.svg" shortcut="R"></se-button>\n <se-button id="tool_square" title="tools.mode_square" src="square.svg"></se-button>\n <se-button id="tool_fhrect" title="tools.mode_fhrect" src="fh_rect.svg"></se-button>\n </se-flyingbutton>\n <se-flyingbutton id="tools_ellipse" title="tools.ellipse_circle_tool">\n <se-button id="tool_ellipse" title="tools.mode_ellipse" src="ellipse.svg" shortcut="E"></se-button>\n <se-button id="tool_circle" title="tools.mode_circle" src="circle.svg"></se-button>\n <se-button id="tool_fhellipse" title="tools.mode_fhellipse" src="fh_ellipse.svg"></se-button>\n </se-flyingbutton>\n <se-button id="tool_text" title="tools.mode_text" src="text.svg" shortcut="T"></se-button>\n <se-button id="tool_image" title="tools.mode_image" src="image.svg"></se-button>\n</div>',this.editor.$svgEditor.append(Tr.content.cloneNode(!0)),Wm(Km("tool_select"),this.clickSelect.bind(this)),Wm(Km("tool_fhpath"),this.clickFHPath.bind(this)),Wm(Km("tool_text"),this.clickText.bind(this)),Wm(Km("tool_image"),this.clickImage.bind(this)),Wm(Km("tool_zoom"),this.clickZoom.bind(this)),Km("tool_zoom").addEventListener("dblclick",this.dblclickZoom.bind(this)),Wm(Km("tool_path"),this.clickPath.bind(this)),Wm(Km("tool_line"),this.clickLine.bind(this)),Wm(Km("tool_rect"),this.clickRect.bind(this)),Wm(Km("tool_square"),this.clickSquare.bind(this)),Wm(Km("tool_fhrect"),this.clickFHRect.bind(this)),Wm(Km("tool_ellipse"),this.clickEllipse.bind(this)),Wm(Km("tool_circle"),this.clickCircle.bind(this)),Wm(Km("tool_fhellipse"),this.clickFHEllipse.bind(this))}}const{$qa:Xm,$id:Ym,$click:Zm,isValidUnit:Jm,getTypeMap:ef,convertUnit:tf}=SvgCanvas;class TopPanel{constructor(Tr){this.editor=Tr}displayTool(Tr){Xm(`.${Tr}`).map((Tr=>Tr.style.removeProperty("display")))}hideTool(Tr){Xm(`.${Tr}`).forEach((Tr=>{Tr.style.display="none"}))}get selectedElement(){return this.editor.selectedElement}get multiselected(){return this.editor.multiselected}get path(){return this.editor.svgCanvas.pathActions}setStrokeOpt(Tr,Ur){const{id:Rr}=Tr,Qr=Rr.split("_"),[Vr,Gr]=Qr;Ur&&this.svgCanvas.setStrokeAttr("stroke-"+Vr,Gr),Tr.classList.add("current");const Dr=Array.prototype.filter.call(Tr.parentNode.children,(function(Ur){return Ur!==Tr}));Array.from(Dr).forEach((function(Tr){Tr.classList.remove("current")}))}update(){let Tr,Ur;if(Xm("#title_panel > p")[0].textContent=this.editor.title,this.selectedElement)switch(this.selectedElement.tagName){case"use":case"image":case"foreignObject":break;case"g":case"a":{const Rr=this.selectedElement.getElementsByTagName("*");let Qr=null;for(Tr=0,Ur=Rr.length;Tr<Ur;Tr++){const Ur=Rr[Tr].getAttribute("stroke-width");0===Tr?Qr=Ur:Qr!==Ur&&(Qr=null)}Ym("stroke_width").value=null===Qr?"":Qr,this.editor.bottomPanel.updateColorpickers(!1);break}default:{this.editor.bottomPanel.updateColorpickers(!1),Ym("stroke_width").value=this.selectedElement.getAttribute("stroke-width")||1,Ym("stroke_style").value=this.selectedElement.getAttribute("stroke-dasharray")||"none",Ym("stroke_style").setAttribute("value",Ym("stroke_style").value);let Tr=this.selectedElement.getAttribute("stroke-linejoin")||"miter";Ym("linejoin_"+Tr)&&(this.setStrokeOpt(Ym("linejoin_"+Tr)),Ym("stroke_linejoin").setAttribute("value",Tr)),Tr=this.selectedElement.getAttribute("stroke-linecap")||"butt",Ym("linecap_"+Tr)&&(this.setStrokeOpt(Ym("linecap_"+Tr)),Ym("stroke_linecap").setAttribute("value",Tr))}}if(this.selectedElement){const Tr=100*(this.selectedElement.getAttribute("opacity")||1);Ym("opacity").value=Tr,Ym("elem_id").value=this.selectedElement.id,Ym("elem_class").value=this.selectedElement.getAttribute("class")??""}this.editor.bottomPanel.updateToolButtonState()}promptImgURL(){let{cancelDeletes:Tr=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Ur=this.editor.svgCanvas.getHref(this.editor.selectedElement);Ur=Ur.startsWith("data:")?"":Ur;const Rr=prompt(this.editor.i18next.t("notification.enterNewImgURL"),Ur);Rr?this.setImageURL(Rr):Tr&&this.editor.svgCanvas.deleteSelectedElements()}updateContextPanel(){let Tr=this.editor.selectedElement;Tr?.parentNode||(Tr=null);const Ur=this.editor.svgCanvas.getCurrentDrawing().getCurrentLayerName(),Rr=this.editor.svgCanvas.getMode(),Qr="px"!==this.editor.configObj.curConfig.baseUnit?this.editor.configObj.curConfig.baseUnit:null,Vr="pathedit"===Rr,Gr=document.getElementById("se-cmenu_canvas");if(this.hideTool("selected_panel"),this.hideTool("multiselected_panel"),this.hideTool("g_panel"),this.hideTool("rect_panel"),this.hideTool("circle_panel"),this.hideTool("ellipse_panel"),this.hideTool("line_panel"),this.hideTool("text_panel"),this.hideTool("image_panel"),this.hideTool("container_panel"),this.hideTool("use_panel"),this.hideTool("a_panel"),this.hideTool("xy_panel"),Tr){const Ur=Tr.nodeName,Dr=this.editor.svgCanvas.getRotationAngle(Tr);Ym("angle").value=Dr;const Hr=10*this.editor.svgCanvas.getBlur(Tr);if(Ym("blur").value=Hr,this.editor.svgCanvas.addedNew&&"image"===Ur&&"image"===this.editor.svgCanvas.getMode()&&!this.editor.svgCanvas.getHref(Tr).startsWith("data:")&&this.promptImgURL({cancelDeletes:!0}),Vr||"pathedit"===Rr){const Tr=this.path.getNodePoint();if(Ym("tool_add_subpath").pressed=!1,this.path.canDeleteNodes?Ym("tool_node_delete").classList.remove("disabled"):Ym("tool_node_delete").classList.add("disabled"),Tr){const Ur=Ym("seg_type");Qr&&(Tr.x=tf(Tr.x),Tr.y=tf(Tr.y)),Ym("path_node_x").value=Tr.x,Ym("path_node_y").value=Tr.y,Tr.type?(Ur.value=Tr.type,Ur.removeAttribute("disabled")):(Ur.value=4,Ur.setAttribute("disabled","disabled"))}return}if(this.displayTool("selected_panel"),["line","circle","ellipse","polygon"].includes(Ur))this.hideTool("xy_panel");else{let Rr,Vr;if(["g","polyline","path"].includes(Ur)){const Ur=this.editor.svgCanvas.getStrokedBBox([Tr]);Ur&&({x:Rr,y:Vr}=Ur)}else Rr=Tr.getAttribute("x"),Vr=Tr.getAttribute("y");Qr&&(Rr=tf(Rr),Vr=tf(Vr));const updateValue=(Tr,Ur)=>{const Rr=Ym(Tr).value;parseFloat(Rr)!==Ur&&(Ym(Tr).value=Ur)};updateValue("selected_x",Rr),updateValue("selected_y",Vr),this.displayTool("xy_panel")}["image","text","path","g","use"].includes(Ur)?this.hideTool("tool_topath"):this.displayTool("tool_topath"),"path"===Ur?this.displayTool("tool_reorient"):this.hideTool("tool_reorient"),Ym("tool_reorient").disabled=0===Dr;const zr={g:[],a:[],rect:["rx","width","height"],image:["width","height"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:[],use:[]},{tagName:Kr}=Tr;let $r=null;if("a"===Kr&&($r=this.editor.svgCanvas.getHref(Tr),this.displayTool("g_panel")),Tr.parentNode){const Ur=Array.prototype.filter.call(Tr.parentNode.children,(function(Ur){return Ur!==Tr}));"a"!==Tr.parentNode.tagName||Ur.length||(this.displayTool("a_panel"),$r=this.editor.svgCanvas.getHref(Tr.parentNode))}if($r?(this.displayTool("tool_make_link"),this.displayTool("tool_make_link_multi"),Ym("link_url").value=$r):(this.hideTool("tool_make_link"),this.hideTool("tool_make_link_multi")),zr[Kr]){const Ur=zr[Kr];if(this.displayTool(Kr+"_panel"),Ur.forEach((Ur=>{let Rr=Tr.getAttribute(Ur);if("px"!==this.editor.configObj.curConfig.baseUnit&&Tr[Ur]){const Qr=Tr[Ur].baseVal.value;Rr=tf(Qr)}Ym(`${Kr}_${Ur}`).value=Rr||0})),"text"===Kr)this.displayTool("text_panel"),Ym("tool_italic").pressed=this.editor.svgCanvas.getItalic(),Ym("tool_bold").pressed=this.editor.svgCanvas.getBold(),Ym("tool_text_decoration_underline").pressed=this.editor.svgCanvas.hasTextDecoration("underline"),Ym("tool_text_decoration_linethrough").pressed=this.editor.svgCanvas.hasTextDecoration("line-through"),Ym("tool_text_decoration_overline").pressed=this.editor.svgCanvas.hasTextDecoration("overline"),Ym("tool_font_family").value=Tr.getAttribute("font-family"),Ym("tool_text_anchor").setAttribute("value",Tr.getAttribute("text-anchor")),Ym("font_size").value=Tr.getAttribute("font-size"),Ym("tool_letter_spacing").value=Tr.getAttribute("letter-spacing")??0,Ym("tool_word_spacing").value=Tr.getAttribute("word-spacing")??0,Ym("tool_text_length").value=Tr.getAttribute("textLength")??0,Ym("tool_length_adjust").value=Tr.getAttribute("lengthAdjust")??0,Ym("text").value=Tr.textContent,this.editor.svgCanvas.addedNew&&setTimeout((()=>{Ym("text").focus(),Ym("text").select()}),100);else if("image"===Kr&&"image"===this.editor.svgCanvas.getMode())this.editor.svgCanvas.setImageURL(this.editor.svgCanvas.getHref(Tr));else if("g"===Kr||"use"===Kr){this.displayTool("container_panel");const Tr=this.editor.svgCanvas.getTitle();Ym("g_title").value=Tr,Ym("g_title").disabled="use"===Kr}}Gr.setAttribute(("g"===Kr?"en":"dis")+"ablemenuitems","#ungroup"),Gr.setAttribute(("g"!==Kr&&this.multiselected?"en":"dis")+"ablemenuitems","#group")}else if(this.multiselected){this.editor.svgCanvas.getSelectedElements().every((Tr=>"text"===Tr.tagName))&&this.displayTool("text_panel"),this.displayTool("multiselected_panel"),Gr.setAttribute("enablemenuitems","#group"),Gr.setAttribute("disablemenuitems","#ungroup")}else Gr.setAttribute("disablemenuitems","#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");if(Ym("tool_undo").disabled=0===this.editor.svgCanvas.undoMgr.getUndoStackSize(),Ym("tool_redo").disabled=0===this.editor.svgCanvas.undoMgr.getRedoStackSize(),this.editor.svgCanvas.addedNew=!1,Tr&&!Vr||this.multiselected){Ym("selLayerNames").removeAttribute("disabled"),Ym("selLayerNames").value=Ur,Ym("selLayerNames").setAttribute("value",Ur);document.getElementById("se-cmenu_canvas").setAttribute("enablemenuitems","#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")}else Ym("selLayerNames").setAttribute("disabled","disabled")}showSourceEditor(Tr,Ur){const Rr=document.getElementById("se-svg-editor-dialog");if("open"===Rr.getAttribute("dialog"))return;const Qr=this.editor.svgCanvas.getSvgString();Rr.setAttribute("dialog","open"),Rr.setAttribute("value",Qr),Rr.setAttribute("copysec",Boolean(Ur)),Rr.setAttribute("applysec",!Ur)}clickWireframe(){Ym("tool_wireframe").pressed=!Ym("tool_wireframe").pressed,this.editor.workarea.classList.toggle("wireframe");const Tr=Ym("wireframe_rules");if(Tr)for(;Tr.firstChild;)Tr.removeChild(Tr.firstChild);else{const Tr=document.createElement("style");Tr.setAttribute("id","wireframe_rules"),document.getElementsByTagName("head")[0].appendChild(Tr)}this.editor.updateWireFrame()}clickUndo(){const{undoMgr:Tr,textActions:Ur}=this.editor.svgCanvas;Tr.getUndoStackSize()>0&&(Tr.undo(),this.editor.layersPanel.populateLayers(),"textedit"===this.editor.svgCanvas.getMode()&&Ur.clear())}clickRedo(){const{undoMgr:Tr}=this.editor.svgCanvas;Tr.getRedoStackSize()>0&&(Tr.redo(),this.editor.layersPanel.populateLayers())}changeRectRadius(Tr){this.editor.svgCanvas.setRectRadius(Tr.target.value)}changeFontSize(Tr){this.editor.svgCanvas.setFontSize(Tr.target.value)}changeRotationAngle(Tr){this.editor.svgCanvas.setRotationAngle(Tr.target.value),0===Number.parseInt(Tr.target.value)?Ym("tool_reorient").classList.add("disabled"):Ym("tool_reorient").classList.remove("disabled")}changeBlur(Tr){this.editor.svgCanvas.setBlur(Tr.target.value/10,!0)}clickGroup(){this.editor.multiselected?this.editor.svgCanvas.groupSelectedElements():this.editor.selectedElement&&this.editor.svgCanvas.ungroupSelectedElement()}clickClone(){this.editor.svgCanvas.cloneSelectedElements(20,20)}clickAlignEle(Tr){this.editor.svgCanvas.alignSelectedElements(Tr.detail.value,"page")}clickAlign(Tr){let Ur=Ym("tool_align_relative").value;""===Ur&&(Ur="selected"),this.editor.svgCanvas.alignSelectedElements(Tr,Ur)}attrChanger(Tr){const Ur=Tr.target.getAttribute("data-attr");let Rr=Tr.target.value;if(!Jm(Ur,Rr,this.selectedElement))return Tr.target.value=this.selectedElement.getAttribute(Ur),alert(this.editor.i18next.t("notification.invalidAttrValGiven")),!1;if("id"!==Ur&&"class"!==Ur)if(isNaN(Rr))Rr=this.editor.svgCanvas.convertToNum(Ur,Rr);else if("px"!==this.editor.configObj.curConfig.baseUnit){const Tr=ef();(this.editor.selectedElement[Ur]||"pathedit"===this.editor.svgCanvas.getMode()||"x"===Ur||"y"===Ur)&&(Rr*=Tr[this.editor.configObj.curConfig.baseUnit])}return this.editor.svgCanvas.changeSelectedAttribute(Ur,Rr),!0}convertToPath(){this.editor.selectedElement&&this.editor.svgCanvas.convertToPath()}reorientPath(){this.editor.selectedElement&&this.path.reorient()}makeHyperlink(){if(this.editor.selectedElement||this.multiselected){const Tr=prompt(this.editor.i18next.t("notification.enterNewLinkURL"),"http://");Tr&&this.editor.svgCanvas.makeHyperlink(Tr)}}linkControlPoints(){Ym("tool_node_link").pressed=!Ym("tool_node_link").pressed;const Tr=!!Ym("tool_node_link").pressed;this.path.linkControlPoints(Tr)}clonePathNode(){this.path.getNodePoint()&&this.path.clonePathNode()}deletePathNode(){this.path.getNodePoint()&&this.path.deletePathNode()}addSubPath(){const Tr=Ym("tool_add_subpath"),Ur=!Tr.classList.contains("pressed");Tr.pressed=Ur,this.path.addSubPath(Ur)}opencloseSubPath(){this.path.opencloseSubPath()}deleteSelected(){(this.editor.selectedElement||this.editor.multiselected)&&this.editor.svgCanvas.deleteSelectedElements()}moveToTopSelected(){this.editor.selectedElement&&this.editor.svgCanvas.moveToTopSelectedElement()}moveToBottomSelected(){this.editor.selectedElement&&this.editor.svgCanvas.moveToBottomSelectedElement()}get anyTextSelected(){return this.editor.svgCanvas.getSelectedElements().filter((Tr=>"text"===Tr.tagName)).length>0}clickBold(){if(this.anyTextSelected)return this.editor.svgCanvas.setBold(!this.editor.svgCanvas.getBold()),this.updateContextPanel(),!1}clickItalic(){if(this.anyTextSelected)return this.editor.svgCanvas.setItalic(!this.editor.svgCanvas.getItalic()),this.updateContextPanel(),!1}clickTextDecoration(Tr){return this.editor.svgCanvas.hasTextDecoration(Tr)?this.editor.svgCanvas.removeTextDecoration(Tr):this.editor.svgCanvas.addTextDecoration(Tr),this.updateContextPanel(),!1}clickTextAnchor(Tr){return this.editor.svgCanvas.setTextAnchor(Tr.detail.value),!1}changeLetterSpacing(Tr){this.editor.svgCanvas.setLetterSpacing(Tr.target.value)}changeWordSpacing(Tr){this.editor.svgCanvas.setWordSpacing(Tr.target.value)}changeTextLength(Tr){this.editor.svgCanvas.setTextLength(Tr.target.value)}changeLengthAdjust(Tr){this.editor.svgCanvas.setLengthAdjust(Tr.detail.value)}setImageURL(Tr){const{editor:Ur}=this;if(Tr||(Tr=Ur.defaultImageURL),Ur.svgCanvas.setImageURL(Tr),Ym("image_url").value=Tr,Tr.startsWith("data:"))this.hideTool("image_url");else{Ur.svgCanvas.embedImage(Tr).then((()=>{Ur.svgCanvas.setMode("select"),Ur.svgCanvas.selectOnly(Ur.svgCanvas.getSelectedElements(),!0)}),(Tr=>{console.error("error =",Tr),seAlert(Ur.i18next.t("tools.no_embed")),Ur.svgCanvas.deleteSelectedElements()})),this.displayTool("image_url")}}updateTitle(Tr){Tr&&(this.editor.title=Tr);const Ur=Xm("#title_panel > p")[0];Ur&&(Ur.textContent=this.editor.title)}togglePathEditMode(Tr,Ur){Tr?this.displayTool("path_node_panel"):this.hideTool("path_node_panel"),Tr?(Ym("tool_path").pressed=!1,Ym("tool_select").pressed=!0,Ym("tool_select").setAttribute("src","select_node.svg"),this.editor.multiselected=!1,Ur.length&&(this.editor.selectedElement=Ur[0])):setTimeout((()=>{Ym("tool_select").setAttribute("src","select.svg")}),1e3)}init(){const Tr=document.createElement("template"),{i18next:Ur}=this.editor;Tr.innerHTML='<div id="tools_top">\n <div id="title_panel">\n <p>bez_tytulu.svg</p>\n </div> \x3c!-- title panel --\x3e\n <div id="editor_panel">\n <div class="tool_sep"></div>\n <se-button id="tool_source" title="tools.tool_source" shortcut="U" src="source.svg"></se-button>\n <se-button id="tool_wireframe" title="tools.wireframe_mode" shortcut="F" src="wireframe.svg"></se-button>\n </div> \x3c!-- editor_panel --\x3e\n <div id="history_panel">\n <div class="tool_sep"></div>\n <se-button id="tool_undo" title="tools.undo" shortcut="ctrl+Z" src="undo.svg" disabled="disabled"></se-button>\n <se-button id="tool_redo" title="tools.redo" shortcut="ctrl+Y" src="redo.svg" disabled="disabled"></se-button>\n </div> \x3c!-- history_panel --\x3e\n \x3c!-- Buttons when a single element is selected --\x3e\n <div class="selected_panel">\n <div class="tool_sep"></div>\n <se-button id="tool_clone" title="tools.clone" shortcut="D" src="clone.svg"></se-button>\n <se-button id="tool_delete" title="tools.del" shortcut="Delete/Backspace" src="delete.svg"></se-button>\n </div>\n <div class="selected_panel">\n <div class="tool_sep"></div>\n <se-button id="tool_move_top" title="tools.move_top" shortcut="Ctrl+Shift+]" src="move_top.svg"></se-button>\n <se-button id="tool_move_bottom" title="tools.move_bottom" shortcut="Ctrl+Shift+[" src="move_bottom.svg">\n </se-button>\n </div>\n <div class="selected_panel">\n <se-button id="tool_topath" title="tools.to_path" src="to_path.svg"></se-button>\n <se-button id="tool_reorient" title="tools.reorient_path" src="reorient.svg"></se-button>\n <se-button id="tool_make_link" title="tools.make_link" src="globe_link.svg"></se-button>\n </div>\n <div class="selected_panel">\n <div class="tool_sep"></div>\n <se-input id="elem_id" data-attr="id" size="10" label="properties.id_label" title="properties.id"></se-input>\n </div>\n <div class="selected_panel">\n <se-input id="elem_class" data-attr="class" size="10" label="properties.class_label" title="properties.class">\n </se-input>\n <se-spin-input size="3" id="angle" min="-180" max="180" step="5" src="angle.svg" title="properties.angle">\n </se-spin-input>\n <se-spin-input size="2" id="blur" min="0" max="100" step="5" src="blur.svg" title="properties.blur"></se-spin-input>\n <se-list id="tool_position" title="tools.align_to_page" label="" width="22px" height="22px">\n <se-list-item id="tool_posleft" value="l" title="tools.align_left" src="align_left.svg" img-height="22px">\n </se-list-item>\n <se-list-item id="tool_poscenter" value="c" title="tools.align_center" src="align_center.svg" img-height="22px"></se-list-item>\n <se-list-item id="tool_posright" value="r" title="tools.align_right" src="align_right.svg" img-height="22px"></se-list-item>\n <se-list-item id="tool_postop" value="t" title="tools.align_top" src="align_top.svg" img-height="22px">\n </se-list-item>\n <se-list-item id="tool_posmiddle" value="m" title="tools.align_middle" src="align_middle.svg" img-height="22px"></se-list-item>\n <se-list-item id="tool_posbottom" value="b" src="align_bottom.svg" title="tools.align_bottom" img-height="22px"></se-list-item>\n <se-list-item id="tool_poshoriz" value="dh" src="align_distrib_horiz.svg" title="tools.align_distrib_horiz" img-height="22px"></se-list-item>\n <se-list-item id="tool_posverti" value="dv" src="align_distrib_verti.svg" title="tools.align_distrib_verti" img-height="22px"></se-list-item>\n </se-list>\n </div>\n <div class="xy_panel">\n <se-spin-input id="selected_x" data-attr="x" size="4" type="text" label="properties.x_label" title="properties.pos_x">\n </se-spin-input>\n <se-spin-input id="selected_y" data-attr="y" size="4" type="text" label="properties.y_label" title="properties.pos_y">\n </se-spin-input>\n </div>\n \x3c!-- Buttons when multiple elements are selected --\x3e\n <div class="multiselected_panel">\n <div class="tool_sep"></div>\n <se-button id="tool_clone_multi" title="tools.clone" shortcut="C" src="clone.svg"></se-button>\n <se-button id="tool_delete_multi" title="tools.del" shortcut="Delete/Backspace" src="delete.svg"></se-button>\n </div>\n <div class="multiselected_panel">\n <div class="tool_sep"></div>\n <se-button id="tool_group_elements" title="tools.group_elements" shortcut="G" src="group_elements.svg">\n </se-button>\n <se-button id="tool_make_link_multi" title="tools.make_link" src="globe_link.svg"></se-button>\n <se-button id="tool_align_left" title="tools.align_left" src="align_left.svg"></se-button>\n <se-button id="tool_align_center" title="tools.align_center" src="align_center.svg"></se-button>\n <se-button id="tool_align_right" title="tools.align_right" src="align_right.svg"></se-button>\n <se-button id="tool_align_top" title="tools.align_top" src="align_top.svg"></se-button>\n <se-button id="tool_align_middle" title="tools.align_middle" src="align_middle.svg"></se-button>\n <se-button id="tool_align_bottom" title="tools.align_bottom" src="align_bottom.svg"></se-button>\n <se-button id="tool_align_distrib_horiz" title="tools.align_distrib_horiz" src="align_distrib_horiz.svg"></se-button>\n <se-button id="tool_align_distrib_verti" title="tools.align_distrib_verti" src="align_distrib_verti.svg"></se-button>\n <se-select id="tool_align_relative" label="tools.relativeTo" options="tools.selected_objects,tools.largest_object,tools.smallest_object,tools.page" values="selected::largest::smallest::page">\n \n </se-select>\n </div> \x3c!-- multiselected_panel --\x3e\n <div class="rect_panel">\n <se-spin-input id="rect_width" data-attr="width" size="4" label="properties.w_label" title="properties.rect_width"></se-spin-input>\n <se-spin-input id="rect_height" data-attr="height" size="4" label="properties.h_label" title="properties.rect_height"></se-spin-input>\n <se-spin-input id="rect_rx" min="0" max="1000" step="1" size="3" title="properties.corner_radius" data-attr="Corner Radius" src="c_radius.svg"></se-spin-input>\n </div> \x3c!-- rect_panel --\x3e\n <div class="image_panel">\n <se-spin-input id="image_width" data-attr="width" size="4" type="text" label="properties.w_label" title="properties.image_width"></se-spin-input>\n <se-spin-input id="image_height" data-attr="height" size="4" type="text" label="properties.h_label" title="properties.image_height"></se-spin-input>\n </div>\n <div class="image_panel">\n <se-input id="image_url" data-attr="image_url" size="15" label="properties.image_url"></se-input>\n </div>\n <div class="circle_panel">\n <se-spin-input id="circle_cx" data-attr="cx" size="4" label="properties.cx_label"></se-spin-input>\n <se-spin-input id="circle_cy" data-attr="cy" size="4" label="properties.cy_label"></se-spin-input>\n </div>\n <div class="circle_panel">\n <se-spin-input id="circle_r" data-attr="r" size="4" label="properties.r_label"></se-spin-input>\n </div>\n <div class="ellipse_panel">\n <se-spin-input id="ellipse_cx" data-attr="cx" size="4" title="properties.ellipse_cx" label="properties.cx_label"></se-spin-input>\n <se-spin-input id="ellipse_cy" data-attr="cy" size="4" title="properties.ellipse_cy" label="properties.cy_label"></se-spin-input>\n </div>\n <div class="ellipse_panel">\n <se-spin-input id="ellipse_rx" data-attr="rx" size="4" title="properties.ellipse_rx" label="properties.rx_label"></se-spin-input>\n <se-spin-input id="ellipse_ry" data-attr="ry" size="4" title="properties.ellipse_ry" label="properties.ry_label"></se-spin-input>\n </div>\n <div class="line_panel">\n <se-spin-input id="line_x1" data-attr="x1" size="4" title="properties.line_x1" label="properties.x1_label">\n </se-spin-input>\n <se-spin-input id="line_y1" data-attr="y1" size="4" title="properties.line_y1" label="properties.y1_label">\n </se-spin-input>\n <se-spin-input id="line_x2" data-attr="x2" size="4" title="properties.line_x2" label="properties.x2_label">\n </se-spin-input>\n <se-spin-input id="line_y2" data-attr="y2" size="4" title="properties.line_y2" label="properties.y2_label">\n </se-spin-input>\n </div>\n <div class="text_panel">\n \x3c!-- Text styles --\x3e\n <se-button id="tool_bold" title="properties.bold" src="bold.svg" shortcut="B"></se-button>\n <se-button id="tool_italic" title="properties.italic" src="italic.svg" shortcut="I"></se-button>\n <se-button id="tool_text_decoration_underline" title="properties.text_decoration_underline" src="text_decoration_underline.svg"></se-button>\n <se-button id="tool_text_decoration_linethrough" title="properties.text_decoration_linethrough" src="text_decoration_linethrough.svg"></se-button>\n <se-button id="tool_text_decoration_overline" title="properties.text_decoration_overline" src="text_decoration_overline.svg"></se-button>\n\n \x3c!-- Font Size--\x3e\n <se-select id="tool_font_family" label="properties.font_family_label" options="properties.serif,properties.sans_serif,properties.cursive,properties.fantasy,properties.monospace,properties.courier,properties.helvetica,properties.times" values="Serif::Sans-serif::Cursive::Fantasy::Monospace::Courier::Helvetica::Times"></se-select>\n <se-spin-input size="2" id="font_size" min="1" max="1000" step="1" title="properties.font_size" src="fontsize.svg"></se-spin-input>\n\n \x3c!-- Text Anchor --\x3e\n <se-list id="tool_text_anchor" label="" width="22px" height="22px">\n <se-list-item id="tool_text_anchor_start" value="start" title="properties.text_anchor_start" src="anchor_start.svg" img-height="25px"></se-list-item>\n <se-list-item id="tool_text_anchor_middle" value="middle" title="properties.text_anchor_middle" src="anchor_middle.svg" img-height="25px"></se-list-item>\n <se-list-item id="tool_text_anchor_end" value="end" title="properties.text_anchor_end" src="anchor_end.svg" img-height="25px"></se-list-item>\n </se-list>\n\n \x3c!-- Letter Spacing --\x3e\n <se-spin-input size="2" id="tool_letter_spacing" min="0" max="100" step="1" title="properties.text_letter_spacing" src="letter_spacing.svg"></se-spin-input>\n\n \x3c!-- Word Spacing --\x3e\n <se-spin-input size="2" id="tool_word_spacing" min="0" max="1000" step="1" title="properties.text_word_spacing" src="word_spacing.svg"></se-spin-input>\n\n \x3c!-- Text Length --\x3e\n <se-spin-input size="2" id="tool_text_length" min="0" max="1000" step="1" title="properties.text_length" src="text_length.svg"></se-spin-input>\n\n \x3c!-- Length Adjust --\x3e\n <se-select id="tool_length_adjust" label="properties.text_length_adjust" options="properties.text_length_adjust_spacing,properties.text_length_adjust_spacing_and_glyphs" values="spacing::spacingAndGlyphs"></se-select>\n </div>\n \x3c!-- Not visible, but still used --\x3e\n <input id="text" type="text" size="35">\n <div class="container_panel">\n <div class="tool_sep"></div>\n <se-input id="g_title" data-attr="title" size="8" label="properties.label"></se-input>\n </div> \x3c!-- container_panel --\x3e\n <div class="use_panel">\n <se-button id="tool_unlink_use" title="tools.tool_unlink_use" src="unlink_use.svg"></se-button>\n </div> \x3c!-- use_panel --\x3e\n <div class="g_panel">\n <se-button id="tool_ungroup" title="tools.ungroup" src="ungroup.svg"></se-button>\n </div> \x3c!-- g_panel --\x3e\n \x3c!-- For anchor elements --\x3e\n <div class="a_panel">\n <label id="tool_link_url">\n <span id="linkLabel" class="icon_label"></span>\n <input id="link_url" type="text" size="35">\n </label>\n </div> \x3c!-- a_panel --\x3e\n <div class="path_node_panel">\n <div class="tool_sep"></div>\n <se-button id="tool_node_link" title="tools.node_link" src="tool_node_link.svg" pressed></se-button>\n <div class="tool_sep"></div>\n <se-spin-input id="path_node_x" data-attr="x" size="4" title="properties.node_x" label="properties.x_label">\n </se-spin-input>\n <se-spin-input id="path_node_y" data-attr="y" size="4" title="properties.node_y" label="properties.y_label">\n </se-spin-input>\n <se-select id="seg_type" title="properties.seg_type" label="" options="properties.straight_segments,properties.curve_segments" values="4::6"></se-select>\n <se-button id="tool_node_clone" title="tools.node_clone" src="tool_node_clone.svg"></se-button>\n <se-button id="tool_node_delete" title="tools.node_delete" src="tool_node_delete.svg"></se-button>\n <se-button id="tool_openclose_path" title="tools.openclose_path" src="tool_openclose_path.svg"></se-button>\n <se-button id="tool_add_subpath" title="tools.add_subpath" src="tool_add_subpath.svg"></se-button>\n </div> \x3c!-- path_node_panel --\x3e\n <div id="cur_context_panel"></div>\n</div>',this.editor.$svgEditor.append(Tr.content.cloneNode(!0));const Rr=document.createElement("se-svg-source-editor-dialog");Rr.setAttribute("id","se-svg-editor-dialog"),this.editor.$container.append(Rr),this.updateTitle(),Rr.init(Ur),Ym("tool_link_url").setAttribute("title",Ur.t("tools.set_link_url")),Zm(Ym("tool_source"),this.showSourceEditor.bind(this)),Zm(Ym("tool_wireframe"),this.clickWireframe.bind(this)),Zm(Ym("tool_undo"),this.clickUndo.bind(this)),Zm(Ym("tool_redo"),this.clickRedo.bind(this)),Zm(Ym("tool_clone"),this.clickClone.bind(this)),Zm(Ym("tool_clone_multi"),this.clickClone.bind(this)),Zm(Ym("tool_delete"),this.deleteSelected.bind(this)),Zm(Ym("tool_delete_multi"),this.deleteSelected.bind(this)),Zm(Ym("tool_move_top"),this.moveToTopSelected.bind(this)),Zm(Ym("tool_move_bottom"),this.moveToBottomSelected.bind(this)),Zm(Ym("tool_topath"),this.convertToPath.bind(this)),Zm(Ym("tool_make_link"),this.makeHyperlink.bind(this)),Zm(Ym("tool_make_link_multi"),this.makeHyperlink.bind(this)),Zm(Ym("tool_reorient"),this.reorientPath.bind(this)),Zm(Ym("tool_group_elements"),this.clickGroup.bind(this)),Ym("tool_position").addEventListener("change",(Tr=>this.clickAlignEle.bind(this)(Tr))),Zm(Ym("tool_align_left"),(()=>this.clickAlign.bind(this)("left"))),Zm(Ym("tool_align_right"),(()=>this.clickAlign.bind(this)("right"))),Zm(Ym("tool_align_center"),(()=>this.clickAlign.bind(this)("center"))),Zm(Ym("tool_align_top"),(()=>this.clickAlign.bind(this)("top"))),Zm(Ym("tool_align_bottom"),(()=>this.clickAlign.bind(this)("bottom"))),Zm(Ym("tool_align_middle"),(()=>this.clickAlign.bind(this)("middle"))),Zm(Ym("tool_align_distrib_horiz"),(()=>this.clickAlign.bind(this)("distrib_horiz"))),Zm(Ym("tool_align_distrib_verti"),(()=>this.clickAlign.bind(this)("distrib_verti"))),Zm(Ym("tool_node_clone"),this.clonePathNode.bind(this)),Zm(Ym("tool_node_delete"),this.deletePathNode.bind(this)),Zm(Ym("tool_openclose_path"),this.opencloseSubPath.bind(this)),Zm(Ym("tool_add_subpath"),this.addSubPath.bind(this)),Zm(Ym("tool_node_link"),this.linkControlPoints.bind(this)),Ym("angle").addEventListener("change",this.changeRotationAngle.bind(this)),Ym("blur").addEventListener("change",this.changeBlur.bind(this)),Ym("rect_rx").addEventListener("change",this.changeRectRadius.bind(this)),Ym("font_size").addEventListener("change",this.changeFontSize.bind(this)),Zm(Ym("tool_ungroup"),this.clickGroup.bind(this)),Zm(Ym("tool_bold"),this.clickBold.bind(this)),Zm(Ym("tool_italic"),this.clickItalic.bind(this)),Zm(Ym("tool_text_decoration_underline"),(()=>this.clickTextDecoration.bind(this)("underline"))),Zm(Ym("tool_text_decoration_linethrough"),(()=>this.clickTextDecoration.bind(this)("line-through"))),Zm(Ym("tool_text_decoration_overline"),(()=>this.clickTextDecoration.bind(this)("overline"))),Ym("tool_text_anchor").addEventListener("change",(Tr=>this.clickTextAnchor.bind(this)(Tr))),Ym("tool_letter_spacing").addEventListener("change",this.changeLetterSpacing.bind(this)),Ym("tool_word_spacing").addEventListener("change",this.changeWordSpacing.bind(this)),Ym("tool_text_length").addEventListener("change",this.changeTextLength.bind(this)),Ym("tool_length_adjust").addEventListener("change",(Tr=>this.changeLengthAdjust.bind(this)(Tr))),Zm(Ym("tool_unlink_use"),this.clickGroup.bind(this)),Ym("image_url").addEventListener("change",(Tr=>{this.setImageURL(Tr.currentTarget.value)})),["elem_id","elem_class","circle_cx","circle_cy","circle_r","ellipse_cx","ellipse_cy","ellipse_rx","ellipse_ry","selected_x","selected_y","rect_width","rect_height","line_x1","line_x2","line_y1","line_y2","image_width","image_height","path_node_x","path_node_y"].forEach((Tr=>Ym(Tr).addEventListener("change",this.attrChanger.bind(this))))}}const{$id:rf}=SvgCanvas;class BottomPanel{constructor(Tr){this.editor=Tr}get selectedElement(){return this.editor.selectedElement}get multiselected(){return this.editor.multiselected}changeStrokeWidth(Tr){let Ur=Tr.target.value;0===Ur&&this.editor.selectedElement&&["line","polyline"].includes(this.editor.selectedElement.nodeName)&&(Ur=1),this.editor.svgCanvas.setStrokeWidth(Ur)}changeZoom(Tr){switch(Tr){case"canvas":case"selection":case"layer":case"content":this.editor.zoomChanged(window,Tr);break;default:{const Ur=Number(Tr)>.1?.01*Number(Tr):.1,Rr=this.editor.svgCanvas.getZoom(),{workarea:Qr}=this.editor;this.editor.zoomChanged(window,{width:0,height:0,x:(Qr.scrollLeft+parseFloat(getComputedStyle(Qr,null).width.replace("px",""))/2)/Rr,y:(Qr.scrollTop+parseFloat(getComputedStyle(Qr,null).height.replace("px",""))/2)/Rr,zoom:Ur},!0)}}}updateToolButtonState(){const Tr="none"===this.editor.svgCanvas.getColor("fill"),Ur="none"===this.editor.svgCanvas.getColor("stroke"),Rr=["tool_fhpath","tool_line"],Qr=["tools_rect","tools_ellipse","tool_text","tool_path"];Ur?Rr.forEach((Tr=>{rf(Tr).pressed&&this.editor.leftPanel.clickSelect(),rf(Tr).disabled=!0})):Rr.forEach((Tr=>{rf(Tr).disabled=!1})),Ur&&Tr?Qr.forEach((Tr=>{rf(Tr).pressed&&this.editor.leftPanel.clickSelect(),rf(Tr).disabled=!0})):Qr.forEach((Tr=>{rf(Tr).disabled=!1})),this.editor.svgCanvas.runExtensions("toolButtonStateUpdate",{nofill:Tr,nostroke:Ur})}handleColorPicker(Tr,Ur){const{paint:Rr}=Ur.detail;this.editor.svgCanvas.setPaint(Tr,Rr),this.updateToolButtonState()}handleStrokeAttr(Tr,Ur){this.editor.svgCanvas.setStrokeAttr(Tr,Ur.detail.value)}handleOpacity(Tr){const Ur=Number.parseInt(Tr.currentTarget.value.split("%")[0]);this.editor.svgCanvas.setOpacity(Ur/100)}handlePalette(Tr){Tr.preventDefault();const{picker:Ur,color:Rr}=Tr.detail,Qr="none"===Rr?new _m.Paint:new _m.Paint({alpha:100,solidColor:Rr.substr(1)});"fill"===Ur?rf("fill_color").setPaint(Qr):rf("stroke_color").setPaint(Qr),this.editor.svgCanvas.setColor(Ur,Rr),"none"!==Rr&&1!==this.editor.svgCanvas.getPaintOpacity(Ur)&&this.editor.svgCanvas.setPaintOpacity(Ur,1),this.updateToolButtonState()}init(){const Tr=document.createElement("template"),{i18next:Ur}=this.editor;Tr.innerHTML='<div id="tools_bottom">\n \x3c!-- Zoom buttons --\x3e\n <se-zoom id="zoom" src="zoom.svg" title="Change zoom level" inputsize="40px">\n <se-text value="1000" text="1000%"></se-text>\n <se-text value="400" text="400%"></se-text>\n <se-text value="200" text="200%"></se-text>\n <se-text value="100" text="100%"></se-text>\n <se-text value="50" text="50%"></se-text>\n <se-text value="25" text="25%"></se-text>\n <se-text value="canvas" text="tools.fit_to_canvas"></se-text>\n <se-text value="selection" text="tools.fit_to_sel"></se-text>\n <se-text value="layer" text="tools.fit_to_layer_content"></se-text>\n <se-text value="content" text="tools.fit_to_all"></se-text>\n </se-zoom>\n <se-colorpicker id="fill_color" src="fill.svg" label="properties.fill_color" type="fill"></se-colorpicker>\n <se-colorpicker id="stroke_color" src="stroke.svg" label="properties.stroke_color" type="stroke"></se-colorpicker>\n <se-spin-input id="stroke_width" min="0" max="99" step="1" title="properties.stroke_width" label=""></se-spin-input>\n <se-select id="stroke_style" title="properties.stroke_style" label="" width="22px" height="22px" options="—,...,- -,- .,- .." values="none::2,2::5,5::5,2,2,2::5,2,2,2,2,2"> \n </se-select>\n <se-list id="stroke_linejoin" title="properties.linejoin_miter" label="" width="22px" height="22px">\n <se-list-item id="linejoin_miter" value="miter" src="linejoin_miter.svg" title="properties.linejoin_miter" img-height="22px"></se-list-item>\n <se-list-item id="linejoin_round" value="round" src="linejoin_round.svg" title="properties.linejoin_round" img-height="22px"></se-list-item>\n <se-list-item id="linejoin_bevel" value="bevel" src="linejoin_bevel.svg" title="properties.linejoin_bevel" img-height="22px"></se-list-item>\n </se-list>\n <se-list id="stroke_linecap" title="properties.linecap_butt" label="" width="22px" height="22px">\n <se-list-item id="linecap_butt" value="butt" src="linecap_butt.svg" title="properties.linecap_butt" img-height="22px"></se-list-item>\n <se-list-item id="linecap_square" value="square" src="linecap_square.svg" title="properties.linecap_square" img-height="22px"></se-list-item>\n <se-list-item id="linecap_round" value="round" src="linecap_round.svg" title="properties.linecap_round" img-height="22px"></se-list-item>\n </se-list>\n <se-spin-input size="3" id="opacity" min="0" max="100" step="5" title="properties.opacity" src="opacity.svg"></se-spin-input>\n <se-palette id="palette"></se-palette>\n </div>',this.editor.$svgEditor.append(Tr.content.cloneNode(!0)),rf("palette").addEventListener("change",this.handlePalette.bind(this)),rf("palette").init(Ur);const{curConfig:Rr}=this.editor.configObj;rf("fill_color").setPaint(new _m.Paint({alpha:100,solidColor:Rr.initFill.color})),rf("stroke_color").setPaint(new _m.Paint({alpha:100,solidColor:Rr.initStroke.color})),rf("zoom").addEventListener("change",(Tr=>this.changeZoom.bind(this)(Tr.detail.value))),rf("stroke_color").addEventListener("change",(Tr=>this.handleColorPicker.bind(this)("stroke",Tr))),rf("fill_color").addEventListener("change",(Tr=>this.handleColorPicker.bind(this)("fill",Tr))),rf("stroke_width").addEventListener("change",this.changeStrokeWidth.bind(this)),rf("stroke_style").addEventListener("change",(Tr=>this.handleStrokeAttr.bind(this)("stroke-dasharray",Tr))),rf("stroke_linejoin").addEventListener("change",(Tr=>this.handleStrokeAttr.bind(this)("stroke-linejoin",Tr))),rf("stroke_linecap").addEventListener("change",(Tr=>this.handleStrokeAttr.bind(this)("stroke-linecap",Tr))),rf("opacity").addEventListener("change",this.handleOpacity.bind(this)),rf("fill_color").init(Ur),rf("stroke_color").init(Ur)}updateColorpickers(Tr){rf("fill_color").update(this.editor.svgCanvas,this.editor.selectedElement,Tr),rf("stroke_color").update(this.editor.svgCanvas,this.editor.selectedElement,Tr)}}const{$id:nf,$click:of}=SvgCanvas;class LayersPanel{constructor(Tr){this.updateContextPanel=Tr.topPanel.updateContextPanel.bind(Tr.topPanel),this.editor=Tr}lmenuFunc(Tr){const Ur=Tr?.detail?.trigger;switch(Ur){case"dupe":this.cloneLayer();break;case"delete":this.deleteLayer();break;case"merge_down":this.mergeLayer();break;case"merge_all":this.editor.svgCanvas.mergeAllLayers(),this.updateContextPanel(),this.populateLayers()}}init(){const Tr=document.createElement("template"),{i18next:Ur}=this.editor;Tr.innerHTML='<div id="sidepanels">\n <se-text id="sidepanel_handle" title="ui.panel_action" text="ui.panel"></se-text>\n <div id="sidepanel_content">\n <div id="layerpanel">\n <se-text id="layersLabel" text="layers.layers"></se-text>\n <fieldset id="layerbuttons">\n <se-button id="layer_new" title="layers.new" size="small" src="new.svg"></se-button>\n <se-button id="layer_delete" title="layers.del" size="small" src="delete.svg"></se-button>\n <se-button id="layer_rename" title="layers.rename" size="small" src="text.svg"></se-button>\n <se-button id="layer_up" title="layers.move_up" size="small" src="go_up.svg"></se-button>\n <se-button id="layer_down" title="layers.move_down" size="small" src="go_down.svg"></se-button>\n <se-button id="layer_moreopts" title="common.more_opts" size="small" src="context_menu.svg">\n </se-button>\n </fieldset>\n <table id="layerlist">\n <tr class="layer">\n <td class="layervis"></td>\n <td class="layername">Layer 1</td>\n </tr>\n </table>\n <se-select id="selLayerNames" title="layers.move_selected" label="layers.move_elems_to" options="Layer 1" values="layer1" value="layer1" disabled="disabled">\n </se-select>\n </div>\n </div>\n</div>',this.editor.$svgEditor.append(Tr.content.cloneNode(!0));const Rr=document.createElement("se-cmenu-layers");Rr.setAttribute("id","se-cmenu-layers-more"),Rr.value="layer_moreopts",Rr.setAttribute("leftclick",!0),this.editor.$container.append(Rr),Rr.init(Ur);const Qr=document.createElement("se-cmenu-layers");Qr.setAttribute("id","se-cmenu-layers-list"),Qr.value="layerlist",Qr.setAttribute("leftclick",!1),this.editor.$container.append(Qr),Qr.init(Ur),of(nf("layer_new"),this.newLayer.bind(this)),of(nf("layer_delete"),this.deleteLayer.bind(this)),of(nf("layer_up"),(()=>this.moveLayer.bind(this)(-1))),of(nf("layer_down"),(()=>this.moveLayer.bind(this)(1))),of(nf("layer_rename"),this.layerRename.bind(this)),nf("se-cmenu-layers-more").addEventListener("change",this.lmenuFunc.bind(this)),nf("se-cmenu-layers-list").addEventListener("change",(Tr=>{this.lmenuFunc(Tr)})),of(nf("sidepanel_handle"),(()=>this.toggleSidePanel())),this.toggleSidePanel(this.editor.configObj.curConfig.showlayers)}toggleSidePanel(Tr){void 0===Tr?this.editor.$svgEditor.classList.toggle("open"):Tr?this.editor.$svgEditor.classList.add("open"):this.editor.$svgEditor.classList.remove("open")}newLayer(){let Tr,Ur=this.editor.svgCanvas.getCurrentDrawing().getNumLayers();do{Tr=this.editor.i18next.t("layers.layer")+" "+ ++Ur}while(this.editor.svgCanvas.getCurrentDrawing().hasLayer(Tr));const Rr=prompt(this.editor.i18next.t("notification.enterUniqueLayerName"),Tr);Rr&&(this.editor.svgCanvas.getCurrentDrawing().hasLayer(Rr)?alert(this.editor.i18next.t("notification.dupeLayerName")):(this.editor.svgCanvas.createLayer(Rr),this.updateContextPanel(),this.populateLayers()))}deleteLayer(){if(this.editor.svgCanvas.deleteCurrentLayer()){this.updateContextPanel(),this.populateLayers();const Tr=document.querySelectorAll("#layerlist tr.layer");Array.prototype.forEach.call(Tr,(function(Tr){Tr.classList.remove("layersel")})),document.querySelector("#layerlist tr.layer").classList.add("layersel")}}cloneLayer(){const Tr=this.editor.svgCanvas.getCurrentDrawing().getCurrentLayerName()+" copy",Ur=prompt(this.editor.i18next.t("notification.enterUniqueLayerName"),Tr);Ur&&(this.editor.svgCanvas.getCurrentDrawing().hasLayer(Ur)?alert(this.editor.i18next.t("notification.dupeLayerName")):(this.editor.svgCanvas.cloneLayer(Ur),this.updateContextPanel(),this.populateLayers()))}index(Tr){return Tr?Array.from(document.querySelector("#layerlist tbody").children).indexOf(Tr):-1}mergeLayer(){this.index(document.querySelector("#layerlist tr.layersel"))-1!=this.editor.svgCanvas.getCurrentDrawing().getNumLayers()-1&&(this.editor.svgCanvas.mergeLayer(),this.updateContextPanel(),this.populateLayers())}moveLayer(Tr){const Ur=this.editor.svgCanvas.indexCurrentLayer();-1!==Ur&&(this.editor.svgCanvas.setCurrentLayerPosition(Ur-Tr),this.populateLayers())}layerRename(){const Tr=document.querySelector("#layerlist tr.layersel td.layername"),Ur=Tr?Tr.textContent:"",Rr=prompt(this.editor.i18next.t("notification.enterNewLayerName"),"");Rr&&(Ur===Rr||this.editor.svgCanvas.getCurrentDrawing().hasLayer(Rr)?alert(this.editor.i18next.t("notification.layerHasThatName")):(this.editor.svgCanvas.renameCurrentLayer(Rr),this.populateLayers()))}toggleHighlightLayer(Tr){let Ur;const Rr=[],Qr=this.editor.svgCanvas.getCurrentDrawing().getNumLayers();for(Ur=0;Ur<Qr;Ur++)Rr[Ur]=this.editor.svgCanvas.getCurrentDrawing().getLayerName(Ur);Tr?Rr.forEach((Ur=>{Ur!==Tr&&this.editor.svgCanvas.getCurrentDrawing().setLayerOpacity(Ur,.5)})):Rr.forEach((Tr=>{this.editor.svgCanvas.getCurrentDrawing().setLayerOpacity(Tr,1)}))}populateLayers(){this.editor.svgCanvas.clearSelection();const Tr=this,Ur=nf("layerlist").querySelector("tbody");for(;Ur.firstChild;)Ur.removeChild(Ur.firstChild);nf("selLayerNames").setAttribute("options","");const Rr=this.editor.svgCanvas.getCurrentDrawing(),Qr=Rr.getCurrentLayerName();let Vr=this.editor.svgCanvas.getCurrentDrawing().getNumLayers(),Gr="",Dr="";for(;Vr--;){const Tr=Rr.getLayerName(Vr),Hr=document.createElement("tr");Hr.className=Tr===Qr?"layer layersel":"layer";const zr=document.createElement("td");zr.className=Rr.getLayerVisibility(Tr)?"layervis":"layerinvis layervis";const Kr=document.createElement("img");Kr.src="./images/eye.svg",Kr.style.width="14px",Kr.style.width="14px",zr.appendChild(Kr);const $r=document.createElement("td");$r.className="layername",$r.textContent=Tr,Hr.appendChild(zr),Hr.appendChild($r),Ur.appendChild(Hr),Gr=Gr?Gr+"::"+Tr:Tr,Dr=Dr?Dr+","+Tr:Tr}nf("selLayerNames").setAttribute("options",Dr),nf("selLayerNames").setAttribute("values",Gr);const Hr=nf("layerlist").querySelectorAll("td.layername");Array.from(Hr).forEach((function(Ur){Ur.addEventListener("mouseup",(function(Ur){const Rr=nf("layerlist").querySelectorAll("tr.layer");Array.from(Rr).forEach((function(Tr){Tr.classList.remove("layersel")})),Ur.currentTarget.parentNode.classList.add("layersel"),Tr.editor.svgCanvas.setCurrentLayer(Ur.currentTarget.textContent),Tr.editor.svgCanvas.runExtensions("layersChanged"),Ur.preventDefault()})),Ur.addEventListener("mouseup",(Ur=>{Tr.toggleHighlightLayer(Ur.currentTarget.textContent)})),Ur.addEventListener("mouseout",(Ur=>{Tr.toggleHighlightLayer()}))}));const zr=nf("layerlist").querySelectorAll("td.layervis");Array.from(zr).forEach((function(Ur){of(Ur,(function(Ur){const Rr=Ur.currentTarget.parentNode.querySelector("td.layername"),Qr=Rr?Rr.textContent:"",Vr=Ur.currentTarget.classList.contains("layerinvis");Tr.editor.svgCanvas.setLayerVisibility(Qr,Vr),Ur.currentTarget.classList.toggle("layerinvis"),Tr.editor.svgCanvas.runExtensions("layerVisChanged")}))}));let Kr=5-nf("layerlist").querySelectorAll("tr.layer").length;for(;Kr-- >0;){const Tr=document.createElement("tr");Tr.innerHTML='<td style="color:white">_</td><td/>',Ur.append(Tr)}Tr.editor.svgCanvas.runExtensions("layersChanged")}}const{$id:af,$click:sf,convertUnit:lf,isValidUnit:cf}=SvgCanvas;class MainMenu{constructor(Tr){this.editor=Tr,this.editor.exportWindowCt=0}hideDocProperties(){const Tr=af("se-img-prop");Tr.setAttribute("dialog","close"),Tr.setAttribute("save",this.editor.configObj.pref("img_save")),this.editor.docprops=!1}hidePreferences(){af("se-edit-prefs").setAttribute("dialog","close"),this.editor.configObj.preferences=!1}saveDocProperties(Tr){const{title:Ur,w:Rr,h:Qr,save:Vr}=Tr.detail;return this.editor.svgCanvas.setDocumentTitle(Ur),("fit"===Rr||cf("width",Rr))&&("fit"===Qr||cf("height",Qr))?this.editor.svgCanvas.setResolution(Rr,Qr)?(this.editor.configObj.pref("img_save",Vr),this.editor.updateCanvas(),this.hideDocProperties(),!0):(seAlert(this.editor.i18next.t("notification.noContentToFitTo")),!1):(seAlert(this.editor.i18next.t("notification.invalidAttrValGiven")),!1)}async savePreferences(Tr){const{lang:Ur,bgcolor:Rr,bgurl:Qr,gridsnappingon:Vr,gridsnappingstep:Gr,gridcolor:Dr,showrulers:Hr,baseunit:zr}=Tr.detail;this.editor.setBackground(Rr,Qr),Ur&&Ur!==this.editor.configObj.pref("lang")&&this.editor.configObj.pref("lang",Ur),this.editor.configObj.curConfig.gridSnapping=Vr,this.editor.configObj.curConfig.snappingStep=Gr,this.editor.configObj.curConfig.gridColor=Dr,this.editor.configObj.curConfig.showRulers=Hr,this.editor.configObj.curConfig.showRulers&&this.editor.rulers.updateRulers(),this.editor.configObj.curConfig.baseUnit=zr,this.editor.svgCanvas.setConfig(this.editor.configObj.curConfig),this.editor.updateCanvas(),this.hidePreferences()}async clickExport(Tr){if("ok"!==Tr?.detail?.trigger||void 0===Tr?.detail?.imgType)return;const Ur=Tr?.detail?.imgType,Rr=Tr?.detail?.quality?Tr?.detail?.quality/100:1;const openExportWindow=()=>{"new"===this.editor.configObj.curConfig.exportWindowType&&this.editor.exportWindowCt++,this.editor.exportWindowName=this.editor.configObj.curConfig.canvasName+this.editor.exportWindowCt},Qr=Rm;"PDF"===Ur?(this.editor.customExportPDF||Qr||openExportWindow(),this.editor.svgCanvas.exportPDF(undefined)):(this.editor.customExportImage||openExportWindow(),await this.editor.svgCanvas.rasterExport(Ur,Rr,this.editor.exportWindowName))}showDocProperties(){if(this.editor.docprops)return;this.editor.docprops=!0;const Tr=af("se-img-prop"),Ur=this.editor.svgCanvas.getResolution();"px"!==this.editor.configObj.curConfig.baseUnit&&(Ur.w=lf(Ur.w)+this.editor.configObj.curConfig.baseUnit,Ur.h=lf(Ur.h)+this.editor.configObj.curConfig.baseUnit),Tr.setAttribute("save",this.editor.configObj.pref("img_save")),Tr.setAttribute("width",Ur.w),Tr.setAttribute("height",Ur.h),Tr.setAttribute("title",this.editor.svgCanvas.getDocumentTitle()),Tr.setAttribute("dialog","open")}showPreferences(){if(this.editor.configObj.preferences)return;this.editor.configObj.preferences=!0;const Tr=af("se-edit-prefs"),Ur=this.editor.configObj.curPrefs.bkgd_color,Rr=this.editor.configObj.pref("bkgd_url");Rr&&Tr.setAttribute("bgurl",Rr),Tr.setAttribute("gridsnappingon",this.editor.configObj.curConfig.gridSnapping),Tr.setAttribute("gridsnappingstep",this.editor.configObj.curConfig.snappingStep),Tr.setAttribute("gridcolor",this.editor.configObj.curConfig.gridColor),Tr.setAttribute("canvasbg",Ur),Tr.setAttribute("dialog","open")}openHomePage(){window.open("https://github.com/SVG-Edit/svgedit","_blank")}init(){const Tr=document.createElement("template");Tr.innerHTML='\n <se-menu id="main_button" label="SVG-Edit" src="logo.svg" alt="logo">\n <se-menu-item id="tool_export" label="tools.export_img" src="export.svg"></se-menu-item>\n <se-menu-item id="tool_docprops" label="tools.docprops" shortcut="shift+D" src="docprop.svg"></se-menu-item>\n <se-menu-item id="tool_editor_prefs" label="config.editor_prefs" src="editPref.svg"></se-menu-item>\n <se-menu-item id="tool_editor_homepage" label="tools.editor_homepage" src="logo.svg"></se-menu-item>\n </se-menu>',this.editor.$svgEditor.append(Tr.content.cloneNode(!0)),sf(af("tool_export"),(function(){document.getElementById("se-export-dialog").setAttribute("dialog","open")})),af("se-export-dialog").addEventListener("change",this.clickExport.bind(this)),af("tool_docprops").addEventListener("click",this.showDocProperties.bind(this)),af("tool_editor_prefs").addEventListener("click",this.showPreferences.bind(this)),af("tool_editor_homepage").addEventListener("click",this.openHomePage.bind(this)),af("se-img-prop").addEventListener("change",function(Tr){"closed"===Tr.detail.dialog?this.hideDocProperties():this.saveDocProperties(Tr)}.bind(this)),af("se-edit-prefs").addEventListener("change",function(Tr){"closed"===Tr.detail.dialog?this.hidePreferences():this.savePreferences(Tr)}.bind(this))}}
|
|
1044
1044
|
/**
|
|
1045
1045
|
* The main module for the visual SVG this.
|
|
1046
1046
|
*
|