!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).window=t.window||{})}(this,(function(t){"use strict";const e=(t,...o)=>{const i=o.length;for(let n=0;n{const n=Array.isArray(i)?[]:{};var s;t[o]||Object.assign(t,{[o]:n}),"object"==typeof(s=i)&&null!==s&&s.constructor===Object&&"[object Object]"===Object.prototype.toString.call(s)?Object.assign(t[o],e(n,i)):Array.isArray(i)?Object.assign(t,{[o]:[...i]}):Object.assign(t,{[o]:i})}))}return t},o=function(t,e){return t.split(".").reduce(((t,e)=>"object"==typeof t?t[e]:void 0),e)};class i{constructor(t={}){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),this.setOptions(t);for(const t of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))t.startsWith("on")&&"function"==typeof this[t]&&(this[t]=this[t].bind(this))}setOptions(t){this.options=t?e({},this.constructor.defaults,t):{};for(const[t,e]of Object.entries(this.option("on")||{}))this.on(t,e)}option(t,...e){let i=o(t,this.options);return i&&"function"==typeof i&&(i=i.call(this,this,...e)),i}optionFor(t,e,i,...n){let s=o(e,t);var a;"string"!=typeof(a=s)||isNaN(a)||isNaN(parseFloat(a))||(s=parseFloat(s)),"true"===s&&(s=!0),"false"===s&&(s=!1),s&&"function"==typeof s&&(s=s.call(this,this,t,...n));let r=o(e,this.options);return r&&"function"==typeof r?s=r.call(this,this,t,...n,s):void 0===s&&(s=r),void 0===s?i:s}cn(t){const e=this.options.classes;return e&&e[t]||""}localize(t,e=[]){t=String(t).replace(/\{\{(\w+).?(\w+)?\}\}/g,((t,e,o)=>{let i="";return o?i=this.option(`${e[0]+e.toLowerCase().substring(1)}.l10n.${o}`):e&&(i=this.option(`l10n.${e}`)),i||(i=t),i}));for(let o=0;oe))}on(t,e){let o=[];"string"==typeof t?o=t.split(" "):Array.isArray(t)&&(o=t),this.events||(this.events=new Map),o.forEach((t=>{let o=this.events.get(t);o||(this.events.set(t,[]),o=[]),o.includes(e)||o.push(e),this.events.set(t,o)}))}off(t,e){let o=[];"string"==typeof t?o=t.split(" "):Array.isArray(t)&&(o=t),o.forEach((t=>{const o=this.events.get(t);if(Array.isArray(o)){const t=o.indexOf(e);t>-1&&o.splice(t,1)}}))}emit(t,...e){[...this.events.get(t)||[]].forEach((t=>t(this,...e))),"*"!==t&&this.emit("*",t,...e)}}Object.defineProperty(i,"version",{enumerable:!0,configurable:!0,writable:!0,value:"5.0.36"}),Object.defineProperty(i,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{}});class n extends i{constructor(t,e){super(e),Object.defineProperty(this,"instance",{enumerable:!0,configurable:!0,writable:!0,value:t})}attach(){}detach(){}}const s=(t,e)=>{t&&(t=>`${t||""}`.split(" ").filter((t=>!!t)))(e).forEach((e=>{t.classList.add(e)}))},a={display:["zoomIn","zoomOut","toggle1to1","rotateCCW","rotateCW","flipX","flipY","reset","toggleFS"],items:{panLeft:{icon:'',change:{panX:-100}},panRight:{icon:'',change:{panX:100}},panUp:{icon:'',change:{panY:-100}},panDown:{icon:'',change:{panY:100}},zoomIn:{icon:'',action:"zoomIn"},zoomOut:{icon:'',action:"zoomOut"},toggle1to1:{icon:'',action:"toggleZoom"},toggleZoom:{icon:'',action:"toggleZoom"},iterateZoom:{icon:'',action:"iterateZoom"},rotateCCW:{icon:'',action:"rotateCCW"},rotateCW:{icon:'',action:"rotateCW"},flipX:{icon:'',action:"flipX"},flipY:{icon:'',action:"flipY"},fitX:{icon:'',action:"fitX"},fitY:{icon:'',action:"fitY"},reset:{icon:'',action:"reset"},toggleFS:{icon:'',action:"toggleFS"}},svgAttr:{tabindex:"-1",width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"}};class r extends n{constructor(){super(...arguments),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:null})}addItem(t){const e=this.instance,o=this.container,i=this.option("items")[t];if(!i||!o)return;const n=document.createElement("button");n.setAttribute("title",i.title||e.localize(`{{${t.toUpperCase()}}}`)),s(n,"f-button");const a=function(t){var e=(new DOMParser).parseFromString(t,"text/html").body;if(e.childElementCount>1){for(var o=document.createElement("div");e.firstChild;)o.appendChild(e.firstChild);return o}return e.firstChild}(e.localize(i.icon));if(a instanceof SVGElement)for(const[t,e]of Object.entries(this.option("svgAttr")))a.getAttribute(t)||a.setAttribute(t,String(e));n.appendChild(a),i.action&&(n.dataset.panzoomAction=i.action),i.change&&(n.dataset.panzoomChange=JSON.stringify(i.change)),i.click&&n.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),i&&"function"==typeof i.click&&i.click(e)})),o.appendChild(n)}createContainer(){if(this.container)return;const t=document.createElement("div");t.classList.add("f-panzoom__toolbar"),t.dataset.selectable="true",this.container=t;for(const t of this.option("display"))this.addItem(t);const e=this.instance.container;e.prepend(t),s(e,"has-toolbar")}removeContainer(){const t=this.container;t&&t.remove(),this.container=null,this.instance.container.classList.remove("has-toolbar")}attach(){this.createContainer()}detach(){this.removeContainer()}}Object.defineProperty(r,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:a}),t.Toolbar=r}));