@tolgee/web
Advanced tools
Comparing version 5.22.1-prerelease.d00c62d8.0 to 5.23.0
@@ -1,2 +0,2 @@ | ||
var e;import{getFallback as t,TolgeeCore as n}from"@tolgee/core";export*from"@tolgee/core";function r(e,t){for(var n=0;n<t.length;n++){const r=t[n];if("string"!=typeof r&&!Array.isArray(r))for(const t in r)if("default"!==t&&!(t in e)){const n=Object.getOwnPropertyDescriptor(r,t);n&&Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const o="__tolgee_dev_tools",i="__tolgee_preferredLanguages",a="data-tolgee-key-only",s="data-tolgee-restricted",u="_tolgee",l="_tolgee-highlighter";function c(){var e,t;return void 0===(null==(t=null==(e=globalThis.window)?void 0:e.document)?void 0:t.createElement)}function d(e){if(c())throw new Error(`${e}: Can't run on the server`)}function f(e,t){return{oldTextContent:e,keys:t}}const g={position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function p({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,r){!function(n,r){r.highlight=()=>{if(!n.isConnected)return;let o=r.highlightEl;o||(o=document.createElement("div"),o.classList.add(l),Object.entries(g).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,r.highlightEl=o,document.body.appendChild(o));const i=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=i.top-t+"px",o.style.left=i.left-t+"px",o.style.width=i.width+"px",o.style.height=i.height+"px"}}(n,r),function(e,t){t.unhighlight=()=>{var e;null==(e=t.highlightEl)||e.remove(),t.highlightEl=void 0}}(0,r)}})}function h(e){return e.textContent}function m(e,t){e.textContent=t}function y(e,t){var n;const r=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null==(n=e.ns)?void 0:n.findIndex((e=>{var n;return null==(n=t.ns)?void 0:n.includes(e)})));return r&&o}const v={capture:!0},E={capture:!0,passive:!0},b=new Map([["Control","ctrlKey"],["Alt","altKey"],["Meta","metaKey"],["Shift","shiftKey"]]);function w({highlightKeys:e,elementStore:t,onClick:n,options:r}){var i,a;const s=new Set;let u,l,c=[];const d=(null==(i=r.targetElement)?void 0:i.getRootNode())||document,f=(null==(a=r.targetElement)?void 0:a.ownerDocument)||document;function g(){var e;const n=t.get(u);n&&(n.preventClean=!1,null==(e=n.unhighlight)||e.call(n),u=void 0)}function p(){const e=l;let n;if(e&&O()){n=function(e){for(const n of e){const e=k(n,(e=>t.get(e)));if(void 0!==e)return e||void 0}}(d.elementsFromPoint(e.x,e.y)||[])}!function(e){var n;if(u!==e){g();const r=t.get(e);r&&(r.preventClean=!0,null==(n=r.highlight)||n.call(r),u=e)}}(n)}function h(e){l=e,p()}function m(e){for(const[t,n]of b.entries())s.has(t)&&!e[n]?s.delete(t):!s.has(t)&&e[n]&&s.add(t)}function y(e){var t;m(e),O()&&(t=e.target,!Boolean(k(t,(e=>e.id===o))))&&(e.stopPropagation(),e.preventDefault())}function w(e){m(e),h({x:e.clientX,y:e.clientY})}function A(e){m(e),p()}function T(e){m(e),p()}function N(){var e;const n=t.get(u);null==(e=null==n?void 0:n.highlight)||e.call(n)}function x(e){y(e),m(e),h({x:e.clientX,y:e.clientY}),O()&&u&&(n(e,u),g())}function L(e,t,n){f.addEventListener(e,t,n),c.push([e,t,n])}function k(e,t){return e.id===o?null:t(e)?e:(null==e?void 0:e.parentElement)?k(e.parentElement,t):void 0}function O(){for(const t of e)if(!s.has(t))return!1;return!0}return Object.freeze({stop(){!function(){for(const e of c)f.removeEventListener(...e);c=[]}()},run(){L("keydown",A,v),L("keyup",T,v),L("mousemove",w,E),L("scroll",N,E),L("click",x,v),L("mouseenter",y,v),L("mouseover",y,v),L("mouseout",y,v),L("mouseleave",y,v),L("mousedown",y,v),L("mouseup",y,v)}})}function A(e,n,r){const o=p({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),i=w({highlightKeys:e.highlightKeys,elementStore:n,onClick(e,t){const o=n.get(t);r({event:e,keysAndDefaults:c(o)})},options:e});function l(e,t){var r;t.highlightEl&&(null==(r=t.unhighlight)||r.call(t)),e.removeAttribute(u),n.remove(e)}function c(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({register(t,r,i){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${s}]`)}(t))return;const a=t;let l=n.get(a);l||(l=function(e){return{element:e,nodes:new Map}}(a),n.set(a,l),a.setAttribute(u,"true")),l.nodes.set(r,i),o.initHighlighter(a,l)},forEachElement:n.forEachElement,cleanupLingeringKeyAttributes(){n.forEachElement(((e,t)=>{if(!t.preventClean){for(const[e]of t.nodes)if(e.nodeType===Node.ATTRIBUTE_NODE){const n=e;n.name===a&&null===n.ownerElement&&t.nodes.delete(n)}0===t.nodes.size&&l(e,t)}}))},cleanupRemovedNodes(e){n.forEachElement(((t,n)=>{n.preventClean||(e.has(t)||function(e,t){for(const[n]of e.nodes)t.has(n)&&e.nodes.delete(n)}(n,e),(e.has(t)||0===n.nodes.size)&&l(t,n))}))},findAll(e,r){const o=[];return n.forEachElement(((n,i)=>{for(const n of i.nodes.values()){if(n.keys.find((n=>y({key:e,ns:t(r)},{key:n.key,ns:t(n.ns)})))){o.push(i);break}}})),o},run(e){e&&i.run()},stop(){i.stop(),n.forEachElement(((e,t)=>{var n;t.highlightEl&&(null==(n=t.unhighlight)||n.call(t))}))}})}function T(){let e,n=!1;const r=function(){const e=new Map;return Object.freeze({set(t,n){e.set(t,n)},get:t=>t&&e.get(t),remove:t=>e.delete(t),forEachElement(t){e.forEach(((e,n)=>t(n,e)))}})}();function o({mouseHighlight:e,options:t,wrapper:o,onClick:i}){if(c())return{stop(){n=!1},wrapper:o};const s=function(e){const t=Object.freeze({getSuitableParent(n){const r=function(e){return e.parentElement?e.parentElement:e.ownerElement&&e.ownerElement||void 0}(n);if(void 0===r)throw console.error(n),new Error("No suitable parent found for node above.");if(!e.passToParent)return r;if(Array.isArray(e.passToParent)){const t=e=>r.tagName.toLowerCase()===e.toLowerCase();if(-1===e.passToParent.findIndex(t))return r}return"function"!=typeof e.passToParent||e.passToParent(r)?t.getSuitableParent(r):r}});return t}(t),u=function(e,t){const n=Object.freeze({handleAttributes(n,r=!0){const o=[],i=Object.fromEntries(Object.entries(e.tagAttributes).map((([e,t])=>[e.toUpperCase(),t])));if(n.nodeType===Node.ELEMENT_NODE){const e=n;let r=i[e.tagName.toUpperCase()]??[];"*"in i&&(r=r.concat(i["*"])),o.push(...r.filter((t=>e.hasAttribute(t))).map((t=>e.getAttributeNode(t))).filter((e=>t.testAttribute(e))))}if(r){const e=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,(e=>{var t,n;return(null==(t=i[e.tagName.toUpperCase()])?void 0:t.some((t=>e.hasAttribute(t))))||(null==(n=i["*"])?void 0:n.some((t=>e.hasAttribute(t))))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}));for(;e.nextNode();){const n=e.currentNode;let r=i[n.tagName.toUpperCase()]??[];"*"in i&&(r=r.concat(i["*"])),o.push(...r.filter((e=>n.hasAttribute(e))).map((e=>n.getAttributeNode(e))).filter((e=>t.testAttribute(e))))}}return o},handleChildList(e){const t=[];return t.push(...e.flatMap((e=>n.handleAttributes(e,!0)))),t.push(...e.flatMap((e=>n.handleText(e)))),t},handleText(e){if(e.nodeType===Node.TEXT_NODE)return t.testTextNode(e)?[e]:[];const n=[],r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,(e=>t.testTextNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;r.nextNode();)n.push(r.currentNode);return n}});return n}(t,o),l=A(t,r,i);function d(e){for(const t of e){const e=h(t),n=e?o.unwrap(e):null;if(n){const{text:r,keys:o}=n;m(t,r);const i=f(e,o),a=s.getSuitableParent(t);l.register(a,t,i)}}}function g(e){const t=s.getSuitableParent(e);l.register(t,e,{oldTextContent:"",keys:[{key:h(e)}],keyAttributeOnly:!0})}function p(e,t){if(e.nodeType===Node.ATTRIBUTE_NODE){const t=e;if(t.name===a)return void g(t)}if(e.nodeType===Node.ELEMENT_NODE){const t=e.getAttributeNode(a);t&&g(t)}if(!t)return;const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,(e=>e.hasAttribute(a)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;n.nextNode();){g(n.currentNode.getAttributeNode(a))}}const y=new MutationObserver((e=>{if(!n)return;const t=e.filter((e=>"childList"===e.type)).flatMap((e=>Array.from(e.removedNodes))),r=new Set(t);for(const e of t){if(e.nodeType===Node.ELEMENT_NODE)for(let t=0;t<e.attributes.length;t++)r.add(e.attributes[t]);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);for(;t.nextNode();){const e=t.currentNode;if(e.nodeType===Node.ELEMENT_NODE){const t=e;for(let e=0;e<t.attributes.length;e++)r.add(t.attributes[e])}r.add(e)}}r.size>0&&l.cleanupRemovedNodes(r),e.some((e=>"attributes"===e.type&&e.attributeName===a))&&l.cleanupLingeringKeyAttributes();const o=new Set;for(const t of e)switch(t.type){case"characterData":u.handleText(t.target).forEach((e=>o.add(e)));break;case"childList":p(t.target,!0),t.addedNodes.length>0&&u.handleChildList(Array.from(t.addedNodes)).forEach((e=>o.add(e))),t.removedNodes.length>0&&u.handleChildList(Array.from(t.removedNodes)).forEach((e=>o.delete(e)));break;case"attributes":t.attributeName===a&&p(t.target,!1),u.handleAttributes(t.target,!1).forEach((e=>o.add(e)))}d([...o])})),v=t.targetElement||document.body;n=!0,l.run(e),p(v,!0),d(u.handleChildList([v]));const E=new Set;return E.add(a),Object.values(t.tagAttributes).forEach((e=>e.forEach((e=>E.add(e.toLowerCase()))))),y.observe(v,{attributes:!0,attributeFilter:[...E],childList:!0,subtree:!0,characterData:!0}),{stop(){n=!1,l.stop(),y.disconnect()},elementRegistry:l,wrapper:o}}return Object.freeze({run(t){e=o(t)},stop(){null==e||e.stop()},forEachElement(t){var n,r;null==(r=null==(n=null==e?void 0:e.elementRegistry)?void 0:n.forEachElement)||r.call(n,t)},highlight(t,n){var r;const o=(null==(r=null==e?void 0:e.elementRegistry)?void 0:r.findAll(t,n))||[];return o.forEach((e=>{var t;return null==(t=e.highlight)?void 0:t.call(e)})),{unhighlight(){o.forEach((e=>{var t;return null==(t=e.unhighlight)?void 0:t.call(e)}))}}},findPositions(n,r){var o;const i=(null==(o=null==e?void 0:e.elementRegistry)?void 0:o.findAll(n,r))||[],a=[];return i.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),i.forEach((e=>{const o=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{y({key:n,ns:t(r)},{key:e.key,ns:t(e.ns)})&&a.push({position:{x:o.x,y:o.y,width:o.width,height:o.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),a},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}var N="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},x={};!function(e){function t(e){for(var t=0,n=Math.min(65536,e.length+1),r=new Uint16Array(n),o=[],i=0;;){var a=t<e.length;if(!a||i>=n-1){var s=r.subarray(0,i);if(o.push(String.fromCharCode.apply(null,s)),!a)return o.join("");e=e.subarray(t),t=0,i=0}var u=e[t++];if(0==(128&u))r[i++]=u;else if(192==(224&u)){var l=63&e[t++];r[i++]=(31&u)<<6|l}else if(224==(240&u)){l=63&e[t++];var c=63&e[t++];r[i++]=(31&u)<<12|l<<6|c}else if(240==(248&u)){var d=(7&u)<<18|(l=63&e[t++])<<12|(c=63&e[t++])<<6|63&e[t++];d>65535&&(d-=65536,r[i++]=d>>>10&1023|55296,d=56320|1023&d),r[i++]=d}}}var n="Failed to ",r=function(e,t,r){if(e)throw new Error("".concat(n).concat(t,": the '").concat(r,"' option is unsupported."))},o="function"==typeof Buffer&&Buffer.from,i=o?function(e){return Buffer.from(e)}:function(e){for(var t=0,n=e.length,r=0,o=Math.max(32,n+(n>>>1)+7),i=new Uint8Array(o>>>3<<3);t<n;){var a=e.charCodeAt(t++);if(a>=55296&&a<=56319){if(t<n){var s=e.charCodeAt(t);56320==(64512&s)&&(++t,a=((1023&a)<<10)+(1023&s)+65536)}if(a>=55296&&a<=56319)continue}if(r+4>i.length){o+=8,o=(o*=1+t/e.length*2)>>>3<<3;var u=new Uint8Array(o);u.set(i),i=u}if(0!=(4294967168&a)){if(0==(4294965248&a))i[r++]=a>>>6&31|192;else if(0==(4294901760&a))i[r++]=a>>>12&15|224,i[r++]=a>>>6&63|128;else{if(0!=(4292870144&a))continue;i[r++]=a>>>18&7|240,i[r++]=a>>>12&63|128,i[r++]=a>>>6&63|128}i[r++]=63&a|128}else i[r++]=a}return i.slice?i.slice(0,r):i.subarray(0,r)};function a(){this.encoding="utf-8"}a.prototype.encode=function(e,t){return r(t&&t.stream,"encode","stream"),i(e)};var s=!o&&"function"==typeof Blob&&"function"==typeof URL&&"function"==typeof URL.createObjectURL,u=["utf-8","utf8","unicode-1-1-utf-8"],l=t;o?l=function(e,t){return(e instanceof Buffer?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)).toString(t)}:s&&(l=function(e){try{return function(e){var t;try{var n=new Blob([e],{type:"text/plain;charset=UTF-8"});t=URL.createObjectURL(n);var r=new XMLHttpRequest;return r.open("GET",t,!1),r.send(),r.responseText}finally{t&&URL.revokeObjectURL(t)}}(e)}catch(n){return t(e)}});var c="construct 'TextDecoder'",d="".concat(n," ").concat(c,": the ");function f(e,t){if(r(t&&t.fatal,c,"fatal"),e=e||"utf-8",!(o?Buffer.isEncoding(e):-1!==u.indexOf(e.toLowerCase())))throw new RangeError("".concat(d," encoding label provided ('").concat(e,"') is invalid."));this.encoding=e,this.fatal=!1,this.ignoreBOM=!1}f.prototype.decode=function(e,t){var n;return r(t&&t.stream,"decode","stream"),n=e instanceof Uint8Array?e:e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer):new Uint8Array(e),l(n,this.encoding)},e.TextEncoder=e.TextEncoder||a,e.TextDecoder=e.TextDecoder||f}("undefined"!=typeof window?window:N);const L=r({__proto__:null,default:x},[x]);null==(e=console.assert)||e.call(console,L);const k=["",""],O=RegExp(`([${k.join("")}]{9})+`,"gu");function _(e){const t=function(e){return Array.from((new TextEncoder).encode(e))}(e).map(Number),n=t.map((e=>function(e){const t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0")).join("");return Array.from(n).map((e=>k[Number(e)])).join("")}function C(e){const t=Array.from(e).map((e=>k.indexOf(e))).map(String).join("").match(/(.{9})/g),n=Uint8Array.from((null==t?void 0:t.map((e=>parseInt(e.slice(0,8),2))))||[]);return r=n,(new TextDecoder).decode(new Uint8Array(r));var r}function P({fullKeyEncode:e}){const t=function(){const e=[];return Object.freeze({valueToNumber(t){let n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:t=>e[t]})}();function n(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}return Object.freeze({unwrap(e){const n=[],r=function(e){var t;const n=null==(t=e.match(O))?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(C))||[]}(e);r.forEach((e=>{const r=function(e){if(e.length<=4){const[n]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(e);return t.numberToValue(n)}return e}(e),o=function(e){try{return JSON.parse(e||"{}")}catch(e){return void console.error(e)}}(r);if(o){const{k:e,d:t,n:r}=o;n.push({key:e,defaultValue:t,ns:r})}}));const o=function(e){return e.replace(O,"")}(e);return{text:o,keys:n}},wrap({key:r,defaultValue:o,translation:i,ns:a}){let s;if(e){s=_(n({key:r,ns:a}))}else{const e=n({key:r,ns:a,defaultValue:o}),i=t.valueToNumber(e);s=_(String.fromCodePoint(i))}const u=i||"";return"string"==typeof u?u+s:u},testTextNode(e){var t,n;return((null==(t=e.textContent)?void 0:t.includes(`${k[0]}${k[0]}`))||(null==(n=e.textContent)?void 0:n.includes(`${k[1]}${k[0]}`)))??!1},testAttribute:e=>e.value.includes(`${k[0]}${k[0]}`)||e.value.includes(`${k[1]}${k[0]}`)})}function S(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function U({inputPrefix:e,inputSuffix:t,translate:n}){function r(e){const{key:t,params:r,defaultValue:o,ns:i}=function(e){let t=!1,n="",r="",o="KEY";const i={key:"",ns:void 0,params:{},defaultValue:void 0},a=e=>{i.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",i.params[r]=n,n=""):(o="PARAM_VALUE",r=n,n=""):(o="PARAM_NAME",i.defaultValue=n,n=""):(o="PARAM_NAME",i.key=n,n=""):(o="DEFAULT_VALUE",a(n),n=""):(o="NAMESPACE",i.key=n,n=""):(o="DEFAULT_VALUE",i.key=n,n=""):t=!0;return"KEY"===o&&(i.key=n),"DEFAULT_VALUE"===o&&(i.defaultValue=n),"PARAM_VALUE"===o&&(i.params[r]=n),"NAMESPACE"===o&&a(n),i}(e);return{translated:n({key:t,params:r,defaultValue:o,ns:i,noWrap:!0}),key:t,params:r,defaultValue:o,ns:i}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function i(e){return"string"==typeof e?e.replace(/[,:|\\]/gs,"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(`Parameters of type "${typeof e}" are not supported in "text" wrapper mode.`),e)}return Object.freeze({wrap({key:n,params:r,defaultValue:o,ns:a}){let s=Object.entries(r||{}).map((([e,t])=>`${i(e)}:${i(t)}`)).join(",");s=s.length?`:${s}`:"";const u=void 0!==o?`,${i(o)}`:"",l="string"==typeof a?[a]:a,c=(null==l?void 0:l.length)?`|${l.map((e=>i(e))).join("|")}`:"";return`${e}${i(n)}${c}${u}${s}${t}`},unwrap(n){const i=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),a=[];let s,u=!1,l=0,c="";for(;null!==(s=i.exec(n));){let e=s[1];const[t,o,i,d]=s,{index:f,input:g}=s;if(c+=g.substr(l,f-l),l=f+t.length,"\\"===e){if(!S(f,n)){c+=i;continue}e=""}const p=r(d);a.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),u=!0,c+=e+p.translated}return c+=n.substring(l),u?{text:c,keys:a}:{text:n,keys:[]}},testTextNode(n){var r,o;return((null==(r=n.textContent)?void 0:r.includes(e))&&(null==(o=n.textContent)?void 0:o.includes(t)))??!1},testAttribute:n=>n.value.includes(e)&&n.value.includes(t)})}const $=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=T();return Object.freeze({...e,run(t){const n=U({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run({...t,wrapper:n})},retranslate(){e.forEachElement(((t,n)=>{for(const[t,r]of n.nodes.entries()){if(r.keyAttributeOnly)return;const n=e.unwrap(r.oldTextContent);n&&m(t,n.text)}}))},outputNotFormattable:!0})})):t.setObserver((()=>{const e=T();return Object.freeze({...e,run(t){const n=P({fullKeyEncode:t.options.fullKeyEncode});e.run({...t,wrapper:n})},retranslate(){},outputNotFormattable:!1})})),e),j="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function M(e){const t=j.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function R(e){const t=(e=e.toUpperCase()).length;let n=0,r=0,o=0;const i=new Uint8Array(5*t/8|0);for(let a=0;a<t;a++)r=r<<5|M(e[a]),n+=5,n>=8&&(i[o++]=r>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let r="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),r+=String.fromCharCode.apply(null,t.subarray(e,e+o));return r}(i.buffer)}function D(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=R(n).split("_");return Number(e)}}catch{console.warn("Tolgee: Api key can't be parsed")}}const I=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:r,projectId:o,fetch:i}){const a=D(t)??o;let s=void 0!==a?`${e}/v2/projects/${a}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(r&&(s+=`?ns=${r}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return i(s,{headers:{"X-API-Key":t||"","Content-Type":"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>e[n]));throw new Error(e.statusText)}))}}),e);function F({message:e,recievingMessage:t,data:n,attempts:r=1,timeout:o=300}){let i=!1;const a=()=>new Promise(((r,i)=>{const a=function(e,t){const n=n=>{var r,o;e.includes(null==(r=n.data)?void 0:r.type)&&t(null==(o=n.data)?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(s),u(),r(e)}));window.postMessage({type:e,data:n},window.origin);const s=setTimeout((function(){u(),i()}),o);function u(){a.unsubscribe()}}));return{cancel(){i=!0},promise:(async()=>{for(let e=0;e<r;e++){if(i)return new Promise((()=>{}));try{return await a()}catch(e){continue}}if(!i)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}let K=null;function V(e){var t;return K||(K=(t=`https://cdn.jsdelivr.net/npm/@tolgee/web@${e}/dist/tolgee-in-context-tools.umd.min.js`,new Promise(((e,n)=>{const r=document.createElement("script");r.src=t,r.addEventListener("load",(()=>e())),r.addEventListener("error",(e=>n(e.error))),document.head.appendChild(r)}))).then((()=>window["@tolgee/in-context-tools"].InContextTools))),K}const z="__tolgee_apiKey",B="__tolgee_apiUrl";function W(){const e=sessionStorage.getItem(z)||void 0,t=sessionStorage.getItem(B)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Y(){sessionStorage.removeItem(z),sessionStorage.removeItem(B)}let H=()=>e=>e;(()=>{if("undefined"==typeof window)return!1;try{return"undefined"!=typeof sessionStorage&&sessionStorage}catch(e){return console.error("sessionStorage not available",e),!1}})()&&(H=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:r}=F({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:t,attempts:4});return e=n,r}}}();e.on("running",(({value:n})=>{var r;n&&(r=()=>{t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(Y)},"loading"!==document.readyState?Promise.resolve().then((()=>{r()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",r))}));return W()&&(async()=>{const e=await V("5.22.1-prerelease.d00c62d8.0");return t=>{const n=W();return t.addPlugin(e({credentials:n})),t}})().then((t=>{e.addPlugin(t)})).catch((e=>{console.error("Tolgee: Failed to load in-context tools"),console.error(e)})),e});const G="__tolgee_currentLanguage";const X=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(d("LanguageStorage"),localStorage.getItem(G)||void 0),setLanguage(e){d("LanguageStorage"),localStorage.setItem(G,e)}}),e);const J=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){d("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const r=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=r(window.navigator.language);return e.find((e=>r(e)===o))||void 0}}),e);function q(e){return e.endsWith("/")?e.slice(0,-1):e}const Q={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${q(n)}/${e}/${t}.json`:`${q(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};const Z=e=>(t,n)=>(n.addBackend(function(e){const{prefix:t,getPath:n,getData:r,headers:o,...i}={...Q,...e,headers:{...Q.headers,...null==e?void 0:e.headers}};return{getRecord:({namespace:e,language:a,fetch:s})=>s(n({namespace:e,language:a,prefix:t}),{headers:o,...i}).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return r(e)}))}}(e)),t);function ee(){return n().use(H())}const te=()=>e=>e;export{Z as BackendFetch,H as BrowserExtensionPlugin,o as DEVTOOLS_ID,I as DevBackend,te as DevTools,J as LanguageDetector,X as LanguageStorage,$ as ObserverPlugin,i as PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY,u as TOLGEE_ATTRIBUTE_NAME,s as TOLGEE_RESTRICT_ATTRIBUTE,a as TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE,ee as Tolgee,D as getProjectIdFromApiKey}; | ||
var e;function t(e,t){for(var n=0;n<t.length;n++){const a=t[n];if("string"!=typeof a&&!Array.isArray(a))for(const t in a)if("default"!==t&&!(t in e)){const n=Object.getOwnPropertyDescriptor(a,t);n&&Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>a[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function n(e){return Boolean(e&&"function"==typeof e.then)}function a(e,t){return n(e)?Promise.resolve(e).then(t):t(e)}function o(e,t,a){function o(n){const a=t(n);throw e.emit(a),console.error(a),a}try{const e=a();return n(e)?e.catch(o):e}catch(e){o(e)}}function r(e){const t=(Array.isArray(e)?e:[e]).map((e=>`'${e}'`)),n=t.slice(-2).join(" or ");return`Tolgee: You need to specify ${[...t.slice(0,-2),n].join(", ")} option`}function i(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function s(e){return i(e)||[]}function l(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?s(t):s(null==t?void 0:t[e]);var n}function c(e){return Array.from(new Set(e))}function u(e){return e?e.replace(/\/+$/,""):e}const g=(e,t)=>fetch(e,t),d=(e=g)=>(t,n)=>e(t,Object.assign(Object.assign({},n),{headers:Object.assign({"X-Tolgee-SDK-Type":"JS","X-Tolgee-SDK-Version":"5.23.0"},null==n?void 0:n.headers)}));function f(e){let t=[];return Object.freeze({listen(e){const n=t=>{e(t)};return t.push(n),{unsubscribe(){t=t.filter((e=>n!==e))}}},emit(n){e()&&t.forEach((e=>e({value:n})))}})}function p(e,t,n){const a=new Set,o=new Set;let r=[];function i(){if(0===r.length)return;const e=r;r=[],a.forEach((e=>{e({value:void 0})}));let n=new Set;e.forEach((e=>{void 0===e?n=void 0:void 0!==n&&e.forEach((e=>n.add(e)))}));!function(e){const n=new Set(t());o.forEach((t=>{(void 0===e||-1!==(null==e?void 0:e.findIndex((e=>n.has(e)||t.namespaces.has(e)))))&&t.fn({value:void 0})}))}(n?Array.from(n.keys()):void 0)}return Object.freeze({emit(t,n){e()&&(r.push(t),n?setTimeout(i,0):i())},listen(e){a.add(e);return{unsubscribe:()=>{a.delete(e)}}},listenSome(e){const t={fn:t=>{e(t)},namespaces:new Set};o.add(t);const a={unsubscribe:()=>{o.delete(t)},subscribeNs:e=>(s(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}class h extends Error{constructor(e,t,n=!1){const{language:a,namespace:o}=e;super(`Tolgee: Failed to fetch record for "${a}"${o&&` and "${o}"`}`),this.cause=t,this.isDev=n,this.name="RecordFetchError",this.language=a,this.namespace=o}}class v extends Error{constructor(e,t){super(e),this.cause=t,this.name="LanguageDetectorError"}}class m extends Error{constructor(e,t){super(e),this.cause=t,this.name="LanguageStorageError"}}const y=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):y(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},b=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},E=({language:e,namespace:t})=>t?`${e}:${t}`:e;function L(e,t,a,o,r,i,l){const u=new Map,g=new Map;let d={},f=0;function p(t,n,a){const o=E(t);g.set(o,{data:y(n),version:a}),e.onCacheChange.emit(t)}function v(a){let o;if(!o){const e=d[E(a)];"function"==typeof e&&(o=e())}return o||(o=t(a)),n(o)?null==o?void 0:o.catch((t=>{const n=new h(a,t);throw e.onError.emit(n),console.error(n),n})):o}const m=Object.freeze({addStaticData(e){e&&(d=Object.assign(Object.assign({},d),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=b(e),a=g.get(e);a&&0!==a.version||p(n,t,0)}})))},invalidate(){u.clear(),f+=1},addRecord(e,t){p(e,t,f)},exists(e,t=!1){const n=g.get(E(e));return n&&t?n.version===f:Boolean(n)},getRecord(e){var t;return null===(t=g.get(E(o(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=g.get(E(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=g.get(E({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return c(e)},getTranslationFallback(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=g.get(E({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var o;const r=null===(o=g.get(E(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.onCacheChange.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(r())return!0;if(void 0===e)return u.size>0;const t=s(e);return Boolean(Array.from(u.keys()).find((e=>t.includes(b(e).namespace))))},isLoading(e,t){const n=s(t);return Boolean(r()||Array.from(u.keys()).find((t=>{const a=b(t);return(!n.length||n.includes(a.namespace))&&!m.exists({namespace:a.namespace,language:e})})))},async loadRecords(t,n){const r=t.map((t=>{const r=o(t),i=E(r),s=u.get(i);if(s)return{new:!1,promise:s,keyObject:r,cacheKey:i};const l=function(t,n){var o;let r;return n&&(r=null===(o=a(t))||void 0===o?void 0:o.catch((n=>{const a=new h(t,n,!0);return e.onError.emit(a),console.warn(a),v(t)}))),r||(r=v(t)),r}(r,n)||Promise.resolve(void 0);return u.set(i,l),{new:!0,promise:l,keyObject:r,cacheKey:i}}));i.notify(),l.notify();const s=await Promise.all(r.map((e=>e.promise)));return r.forEach(((e,t)=>{const n=u.get(e.cacheKey)!==e.promise;if(e.new&&!n){u.delete(e.cacheKey);const n=s[t];n?m.addRecord(e.keyObject,n):m.getRecord(e.keyObject)||m.addRecord(e.keyObject,{})}})),i.notify(),l.notify(),r.map((e=>m.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(g.entries()).map((([e,t])=>Object.assign(Object.assign({},b(e)),{data:t.data})))});return m}function w(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}const O="invalid",A={defaultNs:"",observerOptions:{tagAttributes:{textarea:["placeholder"],input:["value","placeholder"],img:["alt"],"*":["aria-label","title"]},restrictedElements:["script","style"],highlightKeys:["Alt"],highlightColor:"rgb(255, 0, 0)",highlightWidth:5,inputPrefix:"%-%tolgee:",inputSuffix:"%-%",passToParent:["option","optgroup"],fullKeyEncode:!1},observerType:"invisible",onFormatError:O,apiUrl:"https://app.tolgee.io",fetch:d(),onTranslationMissing:({key:e})=>e},k=(...e)=>{let t={};return e.forEach((e=>{t=Object.assign(Object.assign(Object.assign({},t),e),{observerOptions:Object.assign(Object.assign({},t.observerOptions),null==e?void 0:e.observerOptions)})})),t};function N(e,t){const n=k(A,null==t?void 0:t.initialOptions,e);return n.apiUrl=u(n.apiUrl),(null==e?void 0:e.fetch)&&(n.fetch=d(e.fetch)),{initialOptions:n,activeNamespaces:(null==t?void 0:t.activeNamespaces)||new Map,language:null==t?void 0:t.language,pendingLanguage:null==t?void 0:t.language,isInitialLoading:!1,isRunning:!1}}function T(e,t,n,r,i,s,l,c){const u={ui:void 0},g={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},d=async({keysAndDefaults:e,target:t})=>{var n;const a=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,fallbackNamespaces:r(t),namespace:i({key:e,ns:t})[0],translation:s({key:e,ns:t})})));null===(n=g.ui)||void 0===n||n.handleElementClick(a,t)},f=(e,t)=>{var n;return(null===(n=g.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function p(e){const t=s({key:e.key,ns:e.ns});return x.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function h(){return{fetch:t().fetch}}function y(e){g.observer=null==e?void 0:e()}function b(){return Boolean(g.observer)}function E(e){e&&g.formatters.push(e)}function L(e){g.finalFormatter=e}function A(e){u.ui=e}function k(){return Boolean(u.ui)}function N(e){g.languageStorage=e}function T(e){g.languageDetector=e}function j(e){e&&g.backends.push(e)}function C(e){g.devBackend=e}const x=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:L,addFormatter:E,setObserver:y,hasObserver:b,setUi:A,hasUi:k,setDevBackend:C,addBackend:j,setLanguageDetector:T,setLanguageStorage:N}))},findPositions:f,run(){var e,n;const{apiKey:a,apiUrl:o,projectId:r,observerOptions:i}=t();g.ui=null===(e=u.ui)||void 0===e?void 0:e.call(u,{apiKey:a,apiUrl:o,projectId:r,highlight:x.highlight,changeTranslation:l,findPositions:f,onPermanentChange:e=>c.onPermanentChange.emit(e)}),null===(n=g.observer)||void 0===n||n.run({mouseHighlight:!0,options:i,translate:p,onClick:d})},stop(){var e;g.ui=void 0,null===(e=g.observer)||void 0===e||e.stop()},getLanguageStorage:()=>g.languageStorage,getInitialLanguage(){const e=n();return a(o(c.onError,(e=>new m("Tolgee: Failed to load language",e)),(()=>{var e;return null===(e=g.languageStorage)||void 0===e?void 0:e.getLanguage(h())})),(t=>e&&!e.includes(t)||!t?function(){if(!g.languageDetector)return;const e=n();return o(c.onError,(e=>new v("Tolgee: Failed to detect language",e)),(()=>{var t;return null===(t=g.languageDetector)||void 0===t?void 0:t.getLanguage(Object.assign({availableLanguages:e},h()))}))}():t))},setStoredLanguage:e=>o(c.onError,(e=>new m("Tolgee: Failed to store language",e)),(()=>{var t;return null===(t=g.languageStorage)||void 0===t?void 0:t.setLanguage(e,h())})),getDevBackend:()=>g.devBackend,getBackendRecord:({language:e,namespace:t})=>{for(const n of g.backends){const a=n.getRecord(Object.assign({language:e,namespace:t},h()));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:n})=>{var a;const{apiKey:o,apiUrl:r,projectId:i}=t();return null===(a=g.devBackend)||void 0===a?void 0:a.getRecord(Object.assign({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:n},h()))},getLanguageDetector:()=>g.languageDetector,retranslate(){var e;null===(e=g.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,a;return(null===(a=null===(n=g.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return g.observer?null===(t=g.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return g.observer?null===(t=g.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(x.getDevBackend()),formatTranslation(n){var a,{formatEnabled:o}=n,r=w(n,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:c,params:u,ns:d,orEmpty:f}=r,p=null!=s?s:l;let h="";null==s&&(h=t().onTranslationMissing(r));let v=null!=p?p:f?"":h;const m=e(),y=o||!(null===(a=g.observer)||void 0===a?void 0:a.outputNotFormattable),b=e=>g.observer&&!c?g.observer.wrap({key:i,translation:e,defaultValue:l,params:u,ns:d}):e;v=b(v);try{if(p&&m&&y)for(const e of g.formatters)v=e.format({translation:v,language:m,params:u});g.finalFormatter&&p&&m&&y&&(v=g.finalFormatter.format({translation:v,language:m,params:u}))}catch(e){console.error(e);const n=("string"==typeof(E=e)?E:"string"==typeof(null==E?void 0:E.message)?E.message:void 0)||O,a=t().onFormatError,o=typeof a;v="string"===o?a:"function"===o?a(n,r):O,v=b(v)}var E;return v}});return x}const j=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const C=(e,...t)=>{let n,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof t[0]?(a.defaultValue=t[0],n=t[1]):"object"==typeof t[0]&&(n=t[0])),n&&(a=Object.assign(Object.assign({},function(e){var{ns:t,noWrap:n,orEmpty:a,params:o,language:r}=e,i=w(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:r};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function x({options:e}){const t=function(e,t){let n=!0;function a(){return n}const o=Object.freeze({onPendingLanguageChange:f(a),onLanguageChange:f(a),onLoadingChange:f(a),onFetchingChange:f(a),onInitialLoaded:f(a),onRunningChange:f(a),onCacheChange:f(a),onUpdate:p(a,e,t),onPermanentChange:f(a),onError:f(a),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.onPendingLanguageChange.listen(t);case"language":return o.onLanguageChange.listen(t);case"loading":return o.onLoadingChange.listen(t);case"fetching":return o.onFetchingChange.listen(t);case"initialLoad":return o.onInitialLoaded.listen(t);case"running":return o.onRunningChange.listen(t);case"cache":return o.onCacheChange.listen(t);case"update":return o.onUpdate.listen(t);case"permanentChange":return o.onPermanentChange.listen(t);case"error":return o.onError.listen(t)}}});return o.onInitialLoaded.listen((()=>o.onUpdate.emit())),o.onLanguageChange.listen((()=>o.onUpdate.emit())),o.onCacheChange.listen((({value:e})=>o.onUpdate.emit([e.namespace],!0))),o}(m,y),o=j(!1,(()=>h.isFetching()),t.onFetchingChange.emit),i=j(!1,(()=>S.isLoading()),t.onLoadingChange.emit),g=function(e,t,n){let a,o=N();const r=Object.freeze({init(e){o=N(e,o)},isRunning:()=>o.isRunning,setRunning(e){o.isRunning!==e&&(o.isRunning=e,n.emit(e))},isInitialLoading:()=>o.isInitialLoading,setInitialLoading(e){o.isInitialLoading=e},getLanguage:()=>o.language||o.initialOptions.language,setLanguage(t){o.language!==t&&(o.language=t,e.emit(t))},getPendingLanguage:()=>o.pendingLanguage||r.getLanguage(),setPendingLanguage(e){o.pendingLanguage!==e&&(o.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},o.initialOptions),a),addActiveNs(e){s(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t?o.activeNamespaces.set(e,t+1):o.activeNamespaces.set(e,1)}))},removeActiveNs(e){s(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t&&t>1?o.activeNamespaces.set(e,t-1):o.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>c([...o.initialOptions.ns||[o.initialOptions.defaultNs],...s(o.initialOptions.fallbackNs),...o.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||r.getLanguage();return t?c([t,...l(t,o.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>s(o.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?o.initialOptions.defaultNs:e,getAvailableLanguages(){if(o.initialOptions.availableLanguages)return o.initialOptions.availableLanguages;if(o.initialOptions.staticData){const e=Object.keys(o.initialOptions.staticData).map((e=>b(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?r.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:u(e.apiUrl)}):void 0}});return r}(t.onLanguageChange,t.onPendingLanguageChange,t.onRunningChange),d=T(g.getLanguage,g.getInitialOptions,g.getAvailableLanguages,E,x,R,O,t),h=L(t,d.getBackendRecord,d.getBackendDevRecord,g.withDefaultNs,g.isInitialLoading,o,i);let v;function m(){return g.getFallbackNs()}function y(e){return g.getDefaultNs(e)}function E(e){return[...s(y(e)),...m()]}function w(e){return[...s(null!=e?e:y()),...g.getRequiredNamespaces()]}function O(e,t,n){const a=g.withDefaultNs(e),o=h.getTranslation(a,t);return h.changeTranslation(a,t,n),{revert(){h.changeTranslation(a,t,o)}}}function A(e){g.init(e),h.addStaticData(g.getInitialOptions().staticData)}function k(e,t){const n=function(e,t){const n=g.getFallbackLangs(e),a=w(t),o=[];return n.forEach((e=>{a.forEach((t=>{h.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}(e,t);if(n.length)return a(S.loadRecords(n),(()=>{}))}function x({key:e,ns:t}){const n=g.getFallbackLangs(),a=E(null!=t?t:void 0);return h.getTranslationNs(a,n,e)}function R({key:e,ns:t,language:n}){const a=E(null!=t?t:void 0),o=g.getFallbackLangs(n);return h.getTranslationFallback(a,o,e)}function P(){const e=a(function(){if(g.getLanguage())return;return a(d.getInitialLanguage(),(e=>{const t=e||g.getInitialOptions().defaultLanguage;t&&g.setLanguage(t)}))}(),(()=>k()));if(n(e))return g.setInitialLoading(!0),o.notify(),i.notify(),Promise.resolve(e).then((()=>{g.setInitialLoading(!1),o.notify(),i.notify(),t.onInitialLoaded.emit()}));t.onInitialLoaded.emit()}e&&A(e),t.onUpdate.listen((()=>{g.isRunning()&&d.retranslate()}));const S=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),g),d),h),{init:A,getTranslation:R,changeTranslation:O,getTranslationNs:x,getDefaultAndFallbackNs:E,findPositions:d.findPositions,async changeLanguage(e){g.getPendingLanguage()===e&&g.getLanguage()===e||(g.setPendingLanguage(e),g.isRunning()&&await k(e),e===g.getPendingLanguage()&&(g.setLanguage(e),await d.setStoredLanguage(e)))},async addActiveNs(e,t){t||g.addActiveNs(e),g.isRunning()&&await k(void 0,e)},loadRecords:e=>h.loadRecords(e,S.isDev()),loadRecord:async e=>(await S.loadRecords([e]))[0],isLoading:e=>h.isLoading(g.getLanguage(),e),isLoaded(e){const t=g.getLanguage();if(!t)return!1;const n=g.getFallbackLangs(t),a=w(e),o=[];return n.forEach((e=>{a.forEach((t=>{h.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=C(...e),n=R(t);return d.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(g.getInitialOptions().apiKey&&g.getInitialOptions().apiUrl),run:()=>(function(){if((d.getLanguageDetector()||d.getLanguageStorage())&&!g.getAvailableLanguages())throw new Error(r("availableLanguages"));if(!g.getLanguage()&&!g.getInitialOptions().defaultLanguage)throw new Error(r(["defaultLanguage","language"]))}(),g.isRunning()||(g.setRunning(!0),d.run(),v=P()),Promise.resolve(v)),stop(){g.isRunning()&&(d.stop(),g.setRunning(!1))}}));return S}const R=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=k(e.options,n),t),init(t){const n=function(e){const t=x({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),t.isDev()&&t.invalidate(),n&&t.run()}t.isDev()&&t.invalidate();const a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmitterActive:t.setEmitterActive,getLanguage:t.getLanguage,getPendingLanguage:t.getPendingLanguage,changeLanguage:t.changeLanguage,changeTranslation:t.changeTranslation,addActiveNs:t.addActiveNs,removeActiveNs:t.removeActiveNs,loadRecords:t.loadRecords,loadRecord:t.loadRecord,addStaticData:t.addStaticData,getRecord:t.getRecord,getAllRecords:t.getAllRecords,isLoaded:t.isLoaded,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,findPositions:t.findPositions,getInitialOptions:t.getInitialOptions,isDev:t.isDev,wrap:t.wrap,unwrap:t.unwrap,overrideCredentials(e){n((()=>t.overrideCredentials(e)))},addPlugin(e){e&&n((()=>t.addPlugin(a,e)))},updateOptions(e){e&&n((()=>t.init(e)))}});return a}(k(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},P=0,S=1,D=2;class I extends Error{constructor(e,t,n){let a;a=e===P?"Empty parameter":e===S?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function U(e){return/\s/.test(e)}const F=0,_=1,$=2,M=3,K=4,B=new Set([$,_,F]),V="'",z=new Set(["{","}",V]),W=e=>/[0-9a-zA-Z_]/.test(e);function Y(e,t){const[n,a]=function(e){let t=F,n="",a="",o="";const r=[],i=[];let s=0;function l(t){throw new I(t,s,e)}const c=()=>{r.push(n),n=""},u=()=>{""===a&&l(P),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case F:o===V?(n+=o,t=_):"{"===o?(c(),t=M):(n+=o,t=F);break;case _:z.has(o)?(n=n.slice(0,-1)+o,t=$):(n+=o,t=F);break;case $:o===V?t=F:(n+=o,t=$);break;case M:"}"===o?(u(),t=F):U(o)?""!==a&&(u(),t=K):(W(o)||l(S),a+=o,t=M);break;case K:"}"==o?t=F:U(o)?t=K:l(S)}return B.has(t)||l(D),c(),[r,i]}(e),o=[n[0]];for(let r=1;r<n.length;r++){const i=null==t?void 0:t[a[r-1]];if(void 0===i)throw new Error(`Missing parameter "${a[r-1]}" in "${e}"`);o.push(String(i)),o.push(n[r])}return o.join("")}const H=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>Y(e,t)}),e),X="__tolgee_dev_tools",G="__tolgee_preferredLanguages",J="data-tolgee-key-only",q="data-tolgee-restricted",Z="_tolgee",Q="_tolgee-highlighter";function ee(){var e,t;return void 0===(null==(t=null==(e=globalThis.window)?void 0:e.document)?void 0:t.createElement)}function te(e){if(ee())throw new Error(`${e}: Can't run on the server`)}function ne(e,t){return{oldTextContent:e,keys:t}}const ae={position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function oe({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(Q),Object.entries(ae).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const r=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=r.top-t+"px",o.style.left=r.left-t+"px",o.style.width=r.width+"px",o.style.height=r.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null==(e=t.highlightEl)||e.remove(),t.highlightEl=void 0}}(0,a)}})}function re(e){return e.textContent}function ie(e,t){e.textContent=t}function se(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null==(n=e.ns)?void 0:n.findIndex((e=>{var n;return null==(n=t.ns)?void 0:n.includes(e)})));return a&&o}const le={capture:!0},ce={capture:!0,passive:!0},ue=new Map([["Control","ctrlKey"],["Alt","altKey"],["Meta","metaKey"],["Shift","shiftKey"]]);function ge({highlightKeys:e,elementStore:t,onClick:n,options:a}){var o,r;const i=new Set;let s,l,c=[];const u=(null==(o=a.targetElement)?void 0:o.getRootNode())||document,g=(null==(r=a.targetElement)?void 0:r.ownerDocument)||document;function d(){var e;const n=t.get(s);n&&(n.preventClean=!1,null==(e=n.unhighlight)||e.call(n),s=void 0)}function f(){const e=l;let n;if(e&&A()){n=function(e){for(const n of e){const e=O(n,(e=>t.get(e)));if(void 0!==e)return e||void 0}}(u.elementsFromPoint(e.x,e.y)||[])}!function(e){var n;if(s!==e){d();const a=t.get(e);a&&(a.preventClean=!0,null==(n=a.highlight)||n.call(a),s=e)}}(n)}function p(e){l=e,f()}function h(e){for(const[t,n]of ue.entries())i.has(t)&&!e[n]?i.delete(t):!i.has(t)&&e[n]&&i.add(t)}function v(e){var t;h(e),A()&&(t=e.target,!Boolean(O(t,(e=>e.id===X))))&&(e.stopPropagation(),e.preventDefault())}function m(e){h(e),p({x:e.clientX,y:e.clientY})}function y(e){h(e),f()}function b(e){h(e),f()}function E(){var e;const n=t.get(s);null==(e=null==n?void 0:n.highlight)||e.call(n)}function L(e){v(e),h(e),p({x:e.clientX,y:e.clientY}),A()&&s&&(n(s),d())}function w(e,t,n){g.addEventListener(e,t,n),c.push([e,t,n])}function O(e,t){return e.id===X?null:t(e)?e:(null==e?void 0:e.parentElement)?O(e.parentElement,t):void 0}function A(){for(const t of e)if(!i.has(t))return!1;return!0}return Object.freeze({stop(){!function(){for(const e of c)g.removeEventListener(...e);c=[]}()},run(){w("keydown",y,le),w("keyup",b,le),w("mousemove",m,ce),w("scroll",E,ce),w("click",L,le),w("mouseenter",v,le),w("mouseover",v,le),w("mouseout",v,le),w("mouseleave",v,le),w("mousedown",v,le),w("mouseup",v,le)}})}function de(e,t,n){const a=oe({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),o=ge({highlightKeys:e.highlightKeys,elementStore:t,onClick(e){const a=t.get(e);n({target:e,keysAndDefaults:s(a)})},options:e});function r(e,n){var a;n.highlightEl&&(null==(a=n.unhighlight)||a.call(n)),e.removeAttribute(Z),t.remove(e)}function s(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({register(n,o,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${q}]`)}(n))return;const i=n;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(Z,"true")),s.nodes.set(o,r),a.initHighlighter(i,s)},forEachElement:t.forEachElement,cleanupLingeringKeyAttributes(){t.forEachElement(((e,t)=>{if(!t.preventClean){for(const[e]of t.nodes)if(e.nodeType===Node.ATTRIBUTE_NODE){const n=e;n.name===J&&null===n.ownerElement&&t.nodes.delete(n)}0===t.nodes.size&&r(e,t)}}))},cleanupRemovedNodes(e){t.forEachElement(((t,n)=>{n.preventClean||(e.has(t)||function(e,t){for(const[n]of e.nodes)t.has(n)&&e.nodes.delete(n)}(n,e),(e.has(t)||0===n.nodes.size)&&r(t,n))}))},findAll(e,n){const a=[];return t.forEachElement(((t,o)=>{for(const t of o.nodes.values()){if(t.keys.find((t=>se({key:e,ns:i(n)},{key:t.key,ns:i(t.ns)})))){a.push(o);break}}})),a},run(e){e&&o.run()},stop(){o.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null==(n=t.unhighlight)||n.call(t))}))}})}function fe(){let e,t=!1;const n=function(){const e=new Map;return Object.freeze({set(t,n){e.set(t,n)},get:t=>t&&e.get(t),remove:t=>e.delete(t),forEachElement(t){e.forEach(((e,n)=>t(n,e)))}})}();function a({mouseHighlight:e,options:a,wrapper:o,onClick:r}){if(ee())return{stop(){t=!1},wrapper:o};const i=function(e){const t=Object.freeze({getSuitableParent(n){const a=function(e){return e.parentElement?e.parentElement:e.ownerElement&&e.ownerElement||void 0}(n);if(void 0===a)throw console.error(n),new Error("No suitable parent found for node above.");if(!e.passToParent)return a;if(Array.isArray(e.passToParent)){const t=e=>a.tagName.toLowerCase()===e.toLowerCase();if(-1===e.passToParent.findIndex(t))return a}return"function"!=typeof e.passToParent||e.passToParent(a)?t.getSuitableParent(a):a}});return t}(a),s=function(e,t){const n=Object.freeze({handleAttributes(n,a=!0){const o=[],r=Object.fromEntries(Object.entries(e.tagAttributes).map((([e,t])=>[e.toUpperCase(),t])));if(n.nodeType===Node.ELEMENT_NODE){const e=n;let a=r[e.tagName.toUpperCase()]??[];"*"in r&&(a=a.concat(r["*"])),o.push(...a.filter((t=>e.hasAttribute(t))).map((t=>e.getAttributeNode(t))).filter((e=>t.testAttribute(e))))}if(a){const e=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,(e=>{var t,n;return(null==(t=r[e.tagName.toUpperCase()])?void 0:t.some((t=>e.hasAttribute(t))))||(null==(n=r["*"])?void 0:n.some((t=>e.hasAttribute(t))))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}));for(;e.nextNode();){const n=e.currentNode;let a=r[n.tagName.toUpperCase()]??[];"*"in r&&(a=a.concat(r["*"])),o.push(...a.filter((e=>n.hasAttribute(e))).map((e=>n.getAttributeNode(e))).filter((e=>t.testAttribute(e))))}}return o},handleChildList(e){const t=[];return t.push(...e.flatMap((e=>n.handleAttributes(e,!0)))),t.push(...e.flatMap((e=>n.handleText(e)))),t},handleText(e){if(e.nodeType===Node.TEXT_NODE)return t.testTextNode(e)?[e]:[];const n=[],a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,(e=>t.testTextNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;a.nextNode();)n.push(a.currentNode);return n}});return n}(a,o),l=de(a,n,r);function c(e){for(const t of e){const e=re(t),n=e?o.unwrap(e):null;if(n){const{text:a,keys:o}=n;ie(t,a);const r=ne(e,o),s=i.getSuitableParent(t);l.register(s,t,r)}}}function u(e){const t=i.getSuitableParent(e);l.register(t,e,{oldTextContent:"",keys:[{key:re(e)}],keyAttributeOnly:!0})}function g(e,t){if(e.nodeType===Node.ATTRIBUTE_NODE){const t=e;if(t.name===J)return void u(t)}if(e.nodeType===Node.ELEMENT_NODE){const t=e.getAttributeNode(J);t&&u(t)}if(!t)return;const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,(e=>e.hasAttribute(J)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;n.nextNode();){u(n.currentNode.getAttributeNode(J))}}const d=new MutationObserver((e=>{if(!t)return;const n=e.filter((e=>"childList"===e.type)).flatMap((e=>Array.from(e.removedNodes))),a=new Set(n);for(const e of n){if(e.nodeType===Node.ELEMENT_NODE)for(let t=0;t<e.attributes.length;t++)a.add(e.attributes[t]);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);for(;t.nextNode();){const e=t.currentNode;if(e.nodeType===Node.ELEMENT_NODE){const t=e;for(let e=0;e<t.attributes.length;e++)a.add(t.attributes[e])}a.add(e)}}a.size>0&&l.cleanupRemovedNodes(a),e.some((e=>"attributes"===e.type&&e.attributeName===J))&&l.cleanupLingeringKeyAttributes();const o=new Set;for(const t of e)switch(t.type){case"characterData":s.handleText(t.target).forEach((e=>o.add(e)));break;case"childList":g(t.target,!0),t.addedNodes.length>0&&s.handleChildList(Array.from(t.addedNodes)).forEach((e=>o.add(e))),t.removedNodes.length>0&&s.handleChildList(Array.from(t.removedNodes)).forEach((e=>o.delete(e)));break;case"attributes":t.attributeName===J&&g(t.target,!1),s.handleAttributes(t.target,!1).forEach((e=>o.add(e)))}c([...o])})),f=a.targetElement||document.body;t=!0,l.run(e),g(f,!0),c(s.handleChildList([f]));const p=new Set;return p.add(J),Object.values(a.tagAttributes).forEach((e=>e.forEach((e=>p.add(e.toLowerCase()))))),d.observe(f,{attributes:!0,attributeFilter:[...p],childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),d.disconnect()},elementRegistry:l,wrapper:o}}return Object.freeze({run(t){e=a(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null==(a=null==(n=null==e?void 0:e.elementRegistry)?void 0:n.forEachElement)||a.call(n,t)},highlight(t,n){var a;const o=(null==(a=null==e?void 0:e.elementRegistry)?void 0:a.findAll(t,n))||[];return o.forEach((e=>{var t;return null==(t=e.highlight)?void 0:t.call(e)})),{unhighlight(){o.forEach((e=>{var t;return null==(t=e.unhighlight)?void 0:t.call(e)}))}}},findPositions(t,n){var a;const o=(null==(a=null==e?void 0:e.elementRegistry)?void 0:a.findAll(t,n))||[],r=[];return o.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),o.forEach((e=>{const a=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{se({key:t,ns:i(n)},{key:e.key,ns:i(e.ns)})&&r.push({position:{x:a.x,y:a.y,width:a.width,height:a.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),r},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}var pe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},he={};!function(e){function t(e){for(var t=0,n=Math.min(65536,e.length+1),a=new Uint16Array(n),o=[],r=0;;){var i=t<e.length;if(!i||r>=n-1){var s=a.subarray(0,r);if(o.push(String.fromCharCode.apply(null,s)),!i)return o.join("");e=e.subarray(t),t=0,r=0}var l=e[t++];if(0==(128&l))a[r++]=l;else if(192==(224&l)){var c=63&e[t++];a[r++]=(31&l)<<6|c}else if(224==(240&l)){c=63&e[t++];var u=63&e[t++];a[r++]=(31&l)<<12|c<<6|u}else if(240==(248&l)){var g=(7&l)<<18|(c=63&e[t++])<<12|(u=63&e[t++])<<6|63&e[t++];g>65535&&(g-=65536,a[r++]=g>>>10&1023|55296,g=56320|1023&g),a[r++]=g}}}var n="Failed to ",a=function(e,t,a){if(e)throw new Error("".concat(n).concat(t,": the '").concat(a,"' option is unsupported."))},o="function"==typeof Buffer&&Buffer.from,r=o?function(e){return Buffer.from(e)}:function(e){for(var t=0,n=e.length,a=0,o=Math.max(32,n+(n>>>1)+7),r=new Uint8Array(o>>>3<<3);t<n;){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319){if(t<n){var s=e.charCodeAt(t);56320==(64512&s)&&(++t,i=((1023&i)<<10)+(1023&s)+65536)}if(i>=55296&&i<=56319)continue}if(a+4>r.length){o+=8,o=(o*=1+t/e.length*2)>>>3<<3;var l=new Uint8Array(o);l.set(r),r=l}if(0!=(4294967168&i)){if(0==(4294965248&i))r[a++]=i>>>6&31|192;else if(0==(4294901760&i))r[a++]=i>>>12&15|224,r[a++]=i>>>6&63|128;else{if(0!=(4292870144&i))continue;r[a++]=i>>>18&7|240,r[a++]=i>>>12&63|128,r[a++]=i>>>6&63|128}r[a++]=63&i|128}else r[a++]=i}return r.slice?r.slice(0,a):r.subarray(0,a)};function i(){this.encoding="utf-8"}i.prototype.encode=function(e,t){return a(t&&t.stream,"encode","stream"),r(e)};var s=!o&&"function"==typeof Blob&&"function"==typeof URL&&"function"==typeof URL.createObjectURL,l=["utf-8","utf8","unicode-1-1-utf-8"],c=t;o?c=function(e,t){return(e instanceof Buffer?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)).toString(t)}:s&&(c=function(e){try{return function(e){var t;try{var n=new Blob([e],{type:"text/plain;charset=UTF-8"});t=URL.createObjectURL(n);var a=new XMLHttpRequest;return a.open("GET",t,!1),a.send(),a.responseText}finally{t&&URL.revokeObjectURL(t)}}(e)}catch(n){return t(e)}});var u="construct 'TextDecoder'",g="".concat(n," ").concat(u,": the ");function d(e,t){if(a(t&&t.fatal,u,"fatal"),e=e||"utf-8",!(o?Buffer.isEncoding(e):-1!==l.indexOf(e.toLowerCase())))throw new RangeError("".concat(g," encoding label provided ('").concat(e,"') is invalid."));this.encoding=e,this.fatal=!1,this.ignoreBOM=!1}d.prototype.decode=function(e,t){var n;return a(t&&t.stream,"decode","stream"),n=e instanceof Uint8Array?e:e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer):new Uint8Array(e),c(n,this.encoding)},e.TextEncoder=e.TextEncoder||i,e.TextDecoder=e.TextDecoder||d}("undefined"!=typeof window?window:pe);const ve=t({__proto__:null,default:he},[he]);null==(e=console.assert)||e.call(console,ve);const me=["",""],ye=RegExp(`([${me.join("")}]{9})+`,"gu");function be(e){const t=function(e){return Array.from((new TextEncoder).encode(e))}(e).map(Number),n=t.map((e=>function(e){const t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0")).join("");return Array.from(n).map((e=>me[Number(e)])).join("")}function Ee(e){const t=Array.from(e).map((e=>me.indexOf(e))).map(String).join("").match(/(.{9})/g),n=Uint8Array.from((null==t?void 0:t.map((e=>parseInt(e.slice(0,8),2))))||[]);return a=n,(new TextDecoder).decode(new Uint8Array(a));var a}function Le({fullKeyEncode:e}){const t=function(){const e=[];return Object.freeze({valueToNumber(t){let n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:t=>e[t]})}();function n(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}return Object.freeze({unwrap(e){const n=[],a=function(e){var t;const n=null==(t=e.match(ye))?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(Ee))||[]}(e);a.forEach((e=>{const a=function(e){if(e.length<=4){const[n]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(e);return t.numberToValue(n)}return e}(e),o=function(e){try{return JSON.parse(e||"{}")}catch(e){return void console.error(e)}}(a);if(o){const{k:e,d:t,n:a}=o;n.push({key:e,defaultValue:t,ns:a})}}));const o=function(e){return e.replace(ye,"")}(e);return{text:o,keys:n}},wrap({key:a,defaultValue:o,translation:r,ns:i}){let s;if(e){s=be(n({key:a,ns:i}))}else{const e=n({key:a,ns:i,defaultValue:o}),r=t.valueToNumber(e);s=be(String.fromCodePoint(r))}const l=r||"";return"string"==typeof l?l+s:l},testTextNode(e){var t,n;return((null==(t=e.textContent)?void 0:t.includes(`${me[0]}${me[0]}`))||(null==(n=e.textContent)?void 0:n.includes(`${me[1]}${me[0]}`)))??!1},testAttribute:e=>e.value.includes(`${me[0]}${me[0]}`)||e.value.includes(`${me[1]}${me[0]}`)})}function we(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function Oe({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:o,ns:r}=function(e){let t=!1,n="",a="",o="KEY";const r={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{r.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",r.params[a]=n,n=""):(o="PARAM_VALUE",a=n,n=""):(o="PARAM_NAME",r.defaultValue=n,n=""):(o="PARAM_NAME",r.key=n,n=""):(o="DEFAULT_VALUE",i(n),n=""):(o="NAMESPACE",r.key=n,n=""):(o="DEFAULT_VALUE",r.key=n,n=""):t=!0;return"KEY"===o&&(r.key=n),"DEFAULT_VALUE"===o&&(r.defaultValue=n),"PARAM_VALUE"===o&&(r.params[a]=n),"NAMESPACE"===o&&i(n),r}(e);return{translated:n({key:t,params:a,defaultValue:o,ns:r,noWrap:!0}),key:t,params:a,defaultValue:o,ns:r}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e){return"string"==typeof e?e.replace(/[,:|\\]/gs,"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(`Parameters of type "${typeof e}" are not supported in "text" wrapper mode.`),e)}return Object.freeze({wrap({key:n,params:a,defaultValue:o,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${r(e)}:${r(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==o?`,${r(o)}`:"",c="string"==typeof i?[i]:i,u=(null==c?void 0:c.length)?`|${c.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${u}${l}${s}${t}`},unwrap(n){const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,l=!1,c=0,u="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(u+=f.substr(c,d-c),c=d+t.length,"\\"===e){if(!we(d,n)){u+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,u+=e+p.translated}return u+=n.substring(c),l?{text:u,keys:i}:{text:n,keys:[]}},testTextNode(n){var a,o;return((null==(a=n.textContent)?void 0:a.includes(e))&&(null==(o=n.textContent)?void 0:o.includes(t)))??!1},testAttribute:n=>n.value.includes(e)&&n.value.includes(t)})}const Ae=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=fe();return Object.freeze({...e,run(t){const n=Oe({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run({...t,wrapper:n})},retranslate(){e.forEachElement(((t,n)=>{for(const[t,a]of n.nodes.entries()){if(a.keyAttributeOnly)return;const n=e.unwrap(a.oldTextContent);n&&ie(t,n.text)}}))},outputNotFormattable:!0})})):t.setObserver((()=>{const e=fe();return Object.freeze({...e,run(t){const n=Le({fullKeyEncode:t.options.fullKeyEncode});e.run({...t,wrapper:n})},retranslate(){},outputNotFormattable:!1})})),e),ke="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Ne(e){const t=ke.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function Te(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|Ne(e[i]),n+=5,n>=8&&(r[o++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+o));return a}(r.buffer)}function je(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=Te(n).split("_");return Number(e)}}catch{console.warn("Tolgee: Api key can't be parsed")}}const Ce=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o,fetch:r}){const i=je(t)??o;let s=void 0!==i?`${e}/v2/projects/${i}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(s+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return r(s,{headers:{"X-API-Key":t||"","Content-Type":"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>e[n]));throw new Error(e.statusText)}))}}),e);function xe({message:e,recievingMessage:t,data:n,attempts:a=1,timeout:o=300}){let r=!1;const i=()=>new Promise(((a,r)=>{const i=function(e,t){const n=n=>{var a,o;e.includes(null==(a=n.data)?void 0:a.type)&&t(null==(o=n.data)?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(s),l(),a(e)}));window.postMessage({type:e,data:n},window.origin);const s=setTimeout((function(){l(),r()}),o);function l(){i.unsubscribe()}}));return{cancel(){r=!0},promise:(async()=>{for(let e=0;e<a;e++){if(r)return new Promise((()=>{}));try{return await i()}catch(e){continue}}if(!r)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}let Re=null;function Pe(e){var t;return Re||(Re=(t=`https://cdn.jsdelivr.net/npm/@tolgee/web@${e}/dist/tolgee-in-context-tools.umd.min.js`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.head.appendChild(a)}))).then((()=>window["@tolgee/in-context-tools"].InContextTools))),Re}const Se="__tolgee_apiKey",De="__tolgee_apiUrl";function Ie(){const e=sessionStorage.getItem(Se)||void 0,t=sessionStorage.getItem(De)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Ue(){sessionStorage.removeItem(Se),sessionStorage.removeItem(De)}let Fe=()=>e=>e;(()=>{if("undefined"==typeof window)return!1;try{return"undefined"!=typeof sessionStorage&&sessionStorage}catch(e){return console.error("sessionStorage not available",e),!1}})()&&(Fe=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=xe({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:t,attempts:4});return e=n,a}}}();e.on("running",(({value:n})=>{var a;n&&(a=()=>{t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(Ue)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Ie()&&(async()=>{const e=await Pe("5.23.0");return t=>{const n=Ie();return t.addPlugin(e({credentials:n})),t}})().then((t=>{e.addPlugin(t)})).catch((e=>{console.error("Tolgee: Failed to load in-context tools"),console.error(e)})),e});const _e="__tolgee_currentLanguage";const $e=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(te("LanguageStorage"),localStorage.getItem(_e)||void 0),setLanguage(e){te("LanguageStorage"),localStorage.setItem(_e,e)}}),e);const Me=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){te("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=a(window.navigator.language);return e.find((e=>a(e)===o))||void 0}}),e);function Ke(e){return e.endsWith("/")?e.slice(0,-1):e}const Be={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${Ke(n)}/${e}/${t}.json`:`${Ke(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};const Ve=e=>(t,n)=>(n.addBackend(function(e){const{prefix:t,getPath:n,getData:a,headers:o,...r}={...Be,...e,headers:{...Be.headers,...null==e?void 0:e.headers}};return{getRecord:({namespace:e,language:i,fetch:s})=>s(n({namespace:e,language:i,prefix:t}),{headers:o,...r}).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return a(e)}))}}(e)),t);function ze(){return R().use(Fe())}const We=()=>e=>e;export{Ve as BackendFetch,Fe as BrowserExtensionPlugin,X as DEVTOOLS_ID,Ce as DevBackend,We as DevTools,H as FormatSimple,Me as LanguageDetector,v as LanguageDetectorError,$e as LanguageStorage,m as LanguageStorageError,Ae as ObserverPlugin,G as PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY,h as RecordFetchError,Z as TOLGEE_ATTRIBUTE_NAME,q as TOLGEE_RESTRICT_ATTRIBUTE,J as TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE,ze as Tolgee,R as TolgeeCore,d as createFetchFunction,i as getFallback,s as getFallbackArray,je as getProjectIdFromApiKey,C as getTranslateProps}; | ||
//# sourceMappingURL=tolgee-web.production.esm.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tolgee/core")):"function"==typeof define&&define.amd?define(["exports","@tolgee/core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@tolgee/web"]={},e["@tolgee/core"])}(this,(function(e,t){"use strict";var n;function r(e,t){for(var n=0;n<t.length;n++){const r=t[n];if("string"!=typeof r&&!Array.isArray(r))for(const t in r)if("default"!==t&&!(t in e)){const n=Object.getOwnPropertyDescriptor(r,t);n&&Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const o="__tolgee_dev_tools",i="data-tolgee-key-only",a="data-tolgee-restricted",s="_tolgee",l="_tolgee-highlighter";function u(){var e,t;return void 0===(null==(t=null==(e=globalThis.window)?void 0:e.document)?void 0:t.createElement)}function c(e){if(u())throw new Error(`${e}: Can't run on the server`)}function d(e,t){return{oldTextContent:e,keys:t}}const f={position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function g({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,r){!function(n,r){r.highlight=()=>{if(!n.isConnected)return;let o=r.highlightEl;o||(o=document.createElement("div"),o.classList.add(l),Object.entries(f).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,r.highlightEl=o,document.body.appendChild(o));const i=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=i.top-t+"px",o.style.left=i.left-t+"px",o.style.width=i.width+"px",o.style.height=i.height+"px"}}(n,r),function(e,t){t.unhighlight=()=>{var e;null==(e=t.highlightEl)||e.remove(),t.highlightEl=void 0}}(0,r)}})}function p(e){return e.textContent}function h(e,t){e.textContent=t}function m(e,t){var n;const r=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null==(n=e.ns)?void 0:n.findIndex((e=>{var n;return null==(n=t.ns)?void 0:n.includes(e)})));return r&&o}const y={capture:!0},E={capture:!0,passive:!0},v=new Map([["Control","ctrlKey"],["Alt","altKey"],["Meta","metaKey"],["Shift","shiftKey"]]);function b({highlightKeys:e,elementStore:t,onClick:n,options:r}){var i,a;const s=new Set;let l,u,c=[];const d=(null==(i=r.targetElement)?void 0:i.getRootNode())||document,f=(null==(a=r.targetElement)?void 0:a.ownerDocument)||document;function g(){var e;const n=t.get(l);n&&(n.preventClean=!1,null==(e=n.unhighlight)||e.call(n),l=void 0)}function p(){const e=u;let n;if(e&&O()){n=function(e){for(const n of e){const e=k(n,(e=>t.get(e)));if(void 0!==e)return e||void 0}}(d.elementsFromPoint(e.x,e.y)||[])}!function(e){var n;if(l!==e){g();const r=t.get(e);r&&(r.preventClean=!0,null==(n=r.highlight)||n.call(r),l=e)}}(n)}function h(e){u=e,p()}function m(e){for(const[t,n]of v.entries())s.has(t)&&!e[n]?s.delete(t):!s.has(t)&&e[n]&&s.add(t)}function b(e){var t;m(e),O()&&(t=e.target,!Boolean(k(t,(e=>e.id===o))))&&(e.stopPropagation(),e.preventDefault())}function A(e){m(e),h({x:e.clientX,y:e.clientY})}function T(e){m(e),p()}function w(e){m(e),p()}function N(){var e;const n=t.get(l);null==(e=null==n?void 0:n.highlight)||e.call(n)}function L(e){b(e),m(e),h({x:e.clientX,y:e.clientY}),O()&&l&&(n(e,l),g())}function x(e,t,n){f.addEventListener(e,t,n),c.push([e,t,n])}function k(e,t){return e.id===o?null:t(e)?e:(null==e?void 0:e.parentElement)?k(e.parentElement,t):void 0}function O(){for(const t of e)if(!s.has(t))return!1;return!0}return Object.freeze({stop(){!function(){for(const e of c)f.removeEventListener(...e);c=[]}()},run(){x("keydown",T,y),x("keyup",w,y),x("mousemove",A,E),x("scroll",N,E),x("click",L,y),x("mouseenter",b,y),x("mouseover",b,y),x("mouseout",b,y),x("mouseleave",b,y),x("mousedown",b,y),x("mouseup",b,y)}})}function A(e,n,r){const o=g({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),l=b({highlightKeys:e.highlightKeys,elementStore:n,onClick(e,t){const o=n.get(t);r({event:e,keysAndDefaults:c(o)})},options:e});function u(e,t){var r;t.highlightEl&&(null==(r=t.unhighlight)||r.call(t)),e.removeAttribute(s),n.remove(e)}function c(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({register(t,r,i){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${a}]`)}(t))return;const l=t;let u=n.get(l);u||(u=function(e){return{element:e,nodes:new Map}}(l),n.set(l,u),l.setAttribute(s,"true")),u.nodes.set(r,i),o.initHighlighter(l,u)},forEachElement:n.forEachElement,cleanupLingeringKeyAttributes(){n.forEachElement(((e,t)=>{if(!t.preventClean){for(const[e]of t.nodes)if(e.nodeType===Node.ATTRIBUTE_NODE){const n=e;n.name===i&&null===n.ownerElement&&t.nodes.delete(n)}0===t.nodes.size&&u(e,t)}}))},cleanupRemovedNodes(e){n.forEachElement(((t,n)=>{n.preventClean||(e.has(t)||function(e,t){for(const[n]of e.nodes)t.has(n)&&e.nodes.delete(n)}(n,e),(e.has(t)||0===n.nodes.size)&&u(t,n))}))},findAll(e,r){const o=[];return n.forEachElement(((n,i)=>{for(const n of i.nodes.values()){if(n.keys.find((n=>m({key:e,ns:t.getFallback(r)},{key:n.key,ns:t.getFallback(n.ns)})))){o.push(i);break}}})),o},run(e){e&&l.run()},stop(){l.stop(),n.forEachElement(((e,t)=>{var n;t.highlightEl&&(null==(n=t.unhighlight)||n.call(t))}))}})}function T(){let e,n=!1;const r=function(){const e=new Map;return Object.freeze({set(t,n){e.set(t,n)},get:t=>t&&e.get(t),remove:t=>e.delete(t),forEachElement(t){e.forEach(((e,n)=>t(n,e)))}})}();function o({mouseHighlight:e,options:t,wrapper:o,onClick:a}){if(u())return{stop(){n=!1},wrapper:o};const s=function(e){const t=Object.freeze({getSuitableParent(n){const r=function(e){return e.parentElement?e.parentElement:e.ownerElement&&e.ownerElement||void 0}(n);if(void 0===r)throw console.error(n),new Error("No suitable parent found for node above.");if(!e.passToParent)return r;if(Array.isArray(e.passToParent)){const t=e=>r.tagName.toLowerCase()===e.toLowerCase();if(-1===e.passToParent.findIndex(t))return r}return"function"!=typeof e.passToParent||e.passToParent(r)?t.getSuitableParent(r):r}});return t}(t),l=function(e,t){const n=Object.freeze({handleAttributes(n,r=!0){const o=[],i=Object.fromEntries(Object.entries(e.tagAttributes).map((([e,t])=>[e.toUpperCase(),t])));if(n.nodeType===Node.ELEMENT_NODE){const e=n;let r=i[e.tagName.toUpperCase()]??[];"*"in i&&(r=r.concat(i["*"])),o.push(...r.filter((t=>e.hasAttribute(t))).map((t=>e.getAttributeNode(t))).filter((e=>t.testAttribute(e))))}if(r){const e=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,(e=>{var t,n;return(null==(t=i[e.tagName.toUpperCase()])?void 0:t.some((t=>e.hasAttribute(t))))||(null==(n=i["*"])?void 0:n.some((t=>e.hasAttribute(t))))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}));for(;e.nextNode();){const n=e.currentNode;let r=i[n.tagName.toUpperCase()]??[];"*"in i&&(r=r.concat(i["*"])),o.push(...r.filter((e=>n.hasAttribute(e))).map((e=>n.getAttributeNode(e))).filter((e=>t.testAttribute(e))))}}return o},handleChildList(e){const t=[];return t.push(...e.flatMap((e=>n.handleAttributes(e,!0)))),t.push(...e.flatMap((e=>n.handleText(e)))),t},handleText(e){if(e.nodeType===Node.TEXT_NODE)return t.testTextNode(e)?[e]:[];const n=[],r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,(e=>t.testTextNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;r.nextNode();)n.push(r.currentNode);return n}});return n}(t,o),c=A(t,r,a);function f(e){for(const t of e){const e=p(t),n=e?o.unwrap(e):null;if(n){const{text:r,keys:o}=n;h(t,r);const i=d(e,o),a=s.getSuitableParent(t);c.register(a,t,i)}}}function g(e){const t=s.getSuitableParent(e);c.register(t,e,{oldTextContent:"",keys:[{key:p(e)}],keyAttributeOnly:!0})}function m(e,t){if(e.nodeType===Node.ATTRIBUTE_NODE){const t=e;if(t.name===i)return void g(t)}if(e.nodeType===Node.ELEMENT_NODE){const t=e.getAttributeNode(i);t&&g(t)}if(!t)return;const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,(e=>e.hasAttribute(i)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;n.nextNode();){g(n.currentNode.getAttributeNode(i))}}const y=new MutationObserver((e=>{if(!n)return;const t=e.filter((e=>"childList"===e.type)).flatMap((e=>Array.from(e.removedNodes))),r=new Set(t);for(const e of t){if(e.nodeType===Node.ELEMENT_NODE)for(let t=0;t<e.attributes.length;t++)r.add(e.attributes[t]);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);for(;t.nextNode();){const e=t.currentNode;if(e.nodeType===Node.ELEMENT_NODE){const t=e;for(let e=0;e<t.attributes.length;e++)r.add(t.attributes[e])}r.add(e)}}r.size>0&&c.cleanupRemovedNodes(r),e.some((e=>"attributes"===e.type&&e.attributeName===i))&&c.cleanupLingeringKeyAttributes();const o=new Set;for(const t of e)switch(t.type){case"characterData":l.handleText(t.target).forEach((e=>o.add(e)));break;case"childList":m(t.target,!0),t.addedNodes.length>0&&l.handleChildList(Array.from(t.addedNodes)).forEach((e=>o.add(e))),t.removedNodes.length>0&&l.handleChildList(Array.from(t.removedNodes)).forEach((e=>o.delete(e)));break;case"attributes":t.attributeName===i&&m(t.target,!1),l.handleAttributes(t.target,!1).forEach((e=>o.add(e)))}f([...o])})),E=t.targetElement||document.body;n=!0,c.run(e),m(E,!0),f(l.handleChildList([E]));const v=new Set;return v.add(i),Object.values(t.tagAttributes).forEach((e=>e.forEach((e=>v.add(e.toLowerCase()))))),y.observe(E,{attributes:!0,attributeFilter:[...v],childList:!0,subtree:!0,characterData:!0}),{stop(){n=!1,c.stop(),y.disconnect()},elementRegistry:c,wrapper:o}}return Object.freeze({run(t){e=o(t)},stop(){null==e||e.stop()},forEachElement(t){var n,r;null==(r=null==(n=null==e?void 0:e.elementRegistry)?void 0:n.forEachElement)||r.call(n,t)},highlight(t,n){var r;const o=(null==(r=null==e?void 0:e.elementRegistry)?void 0:r.findAll(t,n))||[];return o.forEach((e=>{var t;return null==(t=e.highlight)?void 0:t.call(e)})),{unhighlight(){o.forEach((e=>{var t;return null==(t=e.unhighlight)?void 0:t.call(e)}))}}},findPositions(n,r){var o;const i=(null==(o=null==e?void 0:e.elementRegistry)?void 0:o.findAll(n,r))||[],a=[];return i.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),i.forEach((e=>{const o=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{m({key:n,ns:t.getFallback(r)},{key:e.key,ns:t.getFallback(e.ns)})&&a.push({position:{x:o.x,y:o.y,width:o.width,height:o.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),a},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}var w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},N={};!function(e){function t(e){for(var t=0,n=Math.min(65536,e.length+1),r=new Uint16Array(n),o=[],i=0;;){var a=t<e.length;if(!a||i>=n-1){var s=r.subarray(0,i);if(o.push(String.fromCharCode.apply(null,s)),!a)return o.join("");e=e.subarray(t),t=0,i=0}var l=e[t++];if(0==(128&l))r[i++]=l;else if(192==(224&l)){var u=63&e[t++];r[i++]=(31&l)<<6|u}else if(224==(240&l)){u=63&e[t++];var c=63&e[t++];r[i++]=(31&l)<<12|u<<6|c}else if(240==(248&l)){var d=(7&l)<<18|(u=63&e[t++])<<12|(c=63&e[t++])<<6|63&e[t++];d>65535&&(d-=65536,r[i++]=d>>>10&1023|55296,d=56320|1023&d),r[i++]=d}}}var n="Failed to ",r=function(e,t,r){if(e)throw new Error("".concat(n).concat(t,": the '").concat(r,"' option is unsupported."))},o="function"==typeof Buffer&&Buffer.from,i=o?function(e){return Buffer.from(e)}:function(e){for(var t=0,n=e.length,r=0,o=Math.max(32,n+(n>>>1)+7),i=new Uint8Array(o>>>3<<3);t<n;){var a=e.charCodeAt(t++);if(a>=55296&&a<=56319){if(t<n){var s=e.charCodeAt(t);56320==(64512&s)&&(++t,a=((1023&a)<<10)+(1023&s)+65536)}if(a>=55296&&a<=56319)continue}if(r+4>i.length){o+=8,o=(o*=1+t/e.length*2)>>>3<<3;var l=new Uint8Array(o);l.set(i),i=l}if(0!=(4294967168&a)){if(0==(4294965248&a))i[r++]=a>>>6&31|192;else if(0==(4294901760&a))i[r++]=a>>>12&15|224,i[r++]=a>>>6&63|128;else{if(0!=(4292870144&a))continue;i[r++]=a>>>18&7|240,i[r++]=a>>>12&63|128,i[r++]=a>>>6&63|128}i[r++]=63&a|128}else i[r++]=a}return i.slice?i.slice(0,r):i.subarray(0,r)};function a(){this.encoding="utf-8"}a.prototype.encode=function(e,t){return r(t&&t.stream,"encode","stream"),i(e)};var s=!o&&"function"==typeof Blob&&"function"==typeof URL&&"function"==typeof URL.createObjectURL,l=["utf-8","utf8","unicode-1-1-utf-8"],u=t;o?u=function(e,t){return(e instanceof Buffer?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)).toString(t)}:s&&(u=function(e){try{return function(e){var t;try{var n=new Blob([e],{type:"text/plain;charset=UTF-8"});t=URL.createObjectURL(n);var r=new XMLHttpRequest;return r.open("GET",t,!1),r.send(),r.responseText}finally{t&&URL.revokeObjectURL(t)}}(e)}catch(n){return t(e)}});var c="construct 'TextDecoder'",d="".concat(n," ").concat(c,": the ");function f(e,t){if(r(t&&t.fatal,c,"fatal"),e=e||"utf-8",!(o?Buffer.isEncoding(e):-1!==l.indexOf(e.toLowerCase())))throw new RangeError("".concat(d," encoding label provided ('").concat(e,"') is invalid."));this.encoding=e,this.fatal=!1,this.ignoreBOM=!1}f.prototype.decode=function(e,t){var n;return r(t&&t.stream,"decode","stream"),n=e instanceof Uint8Array?e:e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer):new Uint8Array(e),u(n,this.encoding)},e.TextEncoder=e.TextEncoder||a,e.TextDecoder=e.TextDecoder||f}("undefined"!=typeof window?window:w);const L=r({__proto__:null,default:N},[N]);null==(n=console.assert)||n.call(console,L);const x=["",""],k=RegExp(`([${x.join("")}]{9})+`,"gu");function O(e){const t=function(e){return Array.from((new TextEncoder).encode(e))}(e).map(Number),n=t.map((e=>function(e){const t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0")).join("");return Array.from(n).map((e=>x[Number(e)])).join("")}function _(e){const t=Array.from(e).map((e=>x.indexOf(e))).map(String).join("").match(/(.{9})/g),n=Uint8Array.from((null==t?void 0:t.map((e=>parseInt(e.slice(0,8),2))))||[]);return r=n,(new TextDecoder).decode(new Uint8Array(r));var r}function P({fullKeyEncode:e}){const t=function(){const e=[];return Object.freeze({valueToNumber(t){let n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:t=>e[t]})}();function n(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}return Object.freeze({unwrap(e){const n=[],r=function(e){var t;const n=null==(t=e.match(k))?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(_))||[]}(e);r.forEach((e=>{const r=function(e){if(e.length<=4){const[n]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(e);return t.numberToValue(n)}return e}(e),o=function(e){try{return JSON.parse(e||"{}")}catch(e){return void console.error(e)}}(r);if(o){const{k:e,d:t,n:r}=o;n.push({key:e,defaultValue:t,ns:r})}}));const o=function(e){return e.replace(k,"")}(e);return{text:o,keys:n}},wrap({key:r,defaultValue:o,translation:i,ns:a}){let s;if(e){s=O(n({key:r,ns:a}))}else{const e=n({key:r,ns:a,defaultValue:o}),i=t.valueToNumber(e);s=O(String.fromCodePoint(i))}const l=i||"";return"string"==typeof l?l+s:l},testTextNode(e){var t,n;return((null==(t=e.textContent)?void 0:t.includes(`${x[0]}${x[0]}`))||(null==(n=e.textContent)?void 0:n.includes(`${x[1]}${x[0]}`)))??!1},testAttribute:e=>e.value.includes(`${x[0]}${x[0]}`)||e.value.includes(`${x[1]}${x[0]}`)})}function C(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function S({inputPrefix:e,inputSuffix:t,translate:n}){function r(e){const{key:t,params:r,defaultValue:o,ns:i}=function(e){let t=!1,n="",r="",o="KEY";const i={key:"",ns:void 0,params:{},defaultValue:void 0},a=e=>{i.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",i.params[r]=n,n=""):(o="PARAM_VALUE",r=n,n=""):(o="PARAM_NAME",i.defaultValue=n,n=""):(o="PARAM_NAME",i.key=n,n=""):(o="DEFAULT_VALUE",a(n),n=""):(o="NAMESPACE",i.key=n,n=""):(o="DEFAULT_VALUE",i.key=n,n=""):t=!0;return"KEY"===o&&(i.key=n),"DEFAULT_VALUE"===o&&(i.defaultValue=n),"PARAM_VALUE"===o&&(i.params[r]=n),"NAMESPACE"===o&&a(n),i}(e);return{translated:n({key:t,params:r,defaultValue:o,ns:i,noWrap:!0}),key:t,params:r,defaultValue:o,ns:i}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function i(e){return"string"==typeof e?e.replace(/[,:|\\]/gs,"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(`Parameters of type "${typeof e}" are not supported in "text" wrapper mode.`),e)}return Object.freeze({wrap({key:n,params:r,defaultValue:o,ns:a}){let s=Object.entries(r||{}).map((([e,t])=>`${i(e)}:${i(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==o?`,${i(o)}`:"",u="string"==typeof a?[a]:a,c=(null==u?void 0:u.length)?`|${u.map((e=>i(e))).join("|")}`:"";return`${e}${i(n)}${c}${l}${s}${t}`},unwrap(n){const i=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),a=[];let s,l=!1,u=0,c="";for(;null!==(s=i.exec(n));){let e=s[1];const[t,o,i,d]=s,{index:f,input:g}=s;if(c+=g.substr(u,f-u),u=f+t.length,"\\"===e){if(!C(f,n)){c+=i;continue}e=""}const p=r(d);a.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,c+=e+p.translated}return c+=n.substring(u),l?{text:c,keys:a}:{text:n,keys:[]}},testTextNode(n){var r,o;return((null==(r=n.textContent)?void 0:r.includes(e))&&(null==(o=n.textContent)?void 0:o.includes(t)))??!1},testAttribute:n=>n.value.includes(e)&&n.value.includes(t)})}const R="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function j(e){const t=R.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function U(e){const t=(e=e.toUpperCase()).length;let n=0,r=0,o=0;const i=new Uint8Array(5*t/8|0);for(let a=0;a<t;a++)r=r<<5|j(e[a]),n+=5,n>=8&&(i[o++]=r>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let r="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),r+=String.fromCharCode.apply(null,t.subarray(e,e+o));return r}(i.buffer)}function $(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=U(n).split("_");return Number(e)}}catch{console.warn("Tolgee: Api key can't be parsed")}}function D({message:e,recievingMessage:t,data:n,attempts:r=1,timeout:o=300}){let i=!1;const a=()=>new Promise(((r,i)=>{const a=function(e,t){const n=n=>{var r,o;e.includes(null==(r=n.data)?void 0:r.type)&&t(null==(o=n.data)?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(s),l(),r(e)}));window.postMessage({type:e,data:n},window.origin);const s=setTimeout((function(){l(),i()}),o);function l(){a.unsubscribe()}}));return{cancel(){i=!0},promise:(async()=>{for(let e=0;e<r;e++){if(i)return new Promise((()=>{}));try{return await a()}catch(e){continue}}if(!i)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}let M=null;function I(e){var t;return M||(M=(t=`https://cdn.jsdelivr.net/npm/@tolgee/web@${e}/dist/tolgee-in-context-tools.umd.min.js`,new Promise(((e,n)=>{const r=document.createElement("script");r.src=t,r.addEventListener("load",(()=>e())),r.addEventListener("error",(e=>n(e.error))),document.head.appendChild(r)}))).then((()=>window["@tolgee/in-context-tools"].InContextTools))),M}const F="__tolgee_apiKey",K="__tolgee_apiUrl";function V(){const e=sessionStorage.getItem(F)||void 0,t=sessionStorage.getItem(K)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function B(){sessionStorage.removeItem(F),sessionStorage.removeItem(K)}e.BrowserExtensionPlugin=()=>e=>e;(()=>{if("undefined"==typeof window)return!1;try{return"undefined"!=typeof sessionStorage&&sessionStorage}catch(e){return console.error("sessionStorage not available",e),!1}})()&&(e.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:r}=D({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:t,attempts:4});return e=n,r}}}();e.on("running",(({value:n})=>{var r;n&&(r=()=>{t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(B)},"loading"!==document.readyState?Promise.resolve().then((()=>{r()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",r))}));return V()&&(async()=>{const e=await I("5.22.1-prerelease.d00c62d8.0");return t=>{const n=V();return t.addPlugin(e({credentials:n})),t}})().then((t=>{e.addPlugin(t)})).catch((e=>{console.error("Tolgee: Failed to load in-context tools"),console.error(e)})),e});const z="__tolgee_currentLanguage";function W(e){return e.endsWith("/")?e.slice(0,-1):e}const G={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${W(n)}/${e}/${t}.json`:`${W(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};e.BackendFetch=e=>(t,n)=>(n.addBackend(function(e){const{prefix:t,getPath:n,getData:r,headers:o,...i}={...G,...e,headers:{...G.headers,...null==e?void 0:e.headers}};return{getRecord:({namespace:e,language:a,fetch:s})=>s(n({namespace:e,language:a,prefix:t}),{headers:o,...i}).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return r(e)}))}}(e)),t),e.DEVTOOLS_ID=o,e.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:r,projectId:o,fetch:i}){const a=$(t)??o;let s=void 0!==a?`${e}/v2/projects/${a}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(r&&(s+=`?ns=${r}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return i(s,{headers:{"X-API-Key":t||"","Content-Type":"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>e[n]));throw new Error(e.statusText)}))}}),e),e.DevTools=()=>e=>e,e.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){c("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const r=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=r(window.navigator.language);return e.find((e=>r(e)===o))||void 0}}),e),e.LanguageStorage=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(c("LanguageStorage"),localStorage.getItem(z)||void 0),setLanguage(e){c("LanguageStorage"),localStorage.setItem(z,e)}}),e),e.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=T();return Object.freeze({...e,run(t){const n=S({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run({...t,wrapper:n})},retranslate(){e.forEachElement(((t,n)=>{for(const[t,r]of n.nodes.entries()){if(r.keyAttributeOnly)return;const n=e.unwrap(r.oldTextContent);n&&h(t,n.text)}}))},outputNotFormattable:!0})})):t.setObserver((()=>{const e=T();return Object.freeze({...e,run(t){const n=P({fullKeyEncode:t.options.fullKeyEncode});e.run({...t,wrapper:n})},retranslate(){},outputNotFormattable:!1})})),e),e.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",e.TOLGEE_ATTRIBUTE_NAME=s,e.TOLGEE_RESTRICT_ATTRIBUTE=a,e.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=i,e.Tolgee=function(){return t.TolgeeCore().use(e.BrowserExtensionPlugin())},e.getProjectIdFromApiKey=$,Object.keys(t).forEach((n=>{"default"===n||Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:()=>t[n]})})),Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@tolgee/web"]={})}(this,(function(e){"use strict";var t;function n(e,t){for(var n=0;n<t.length;n++){const a=t[n];if("string"!=typeof a&&!Array.isArray(a))for(const t in a)if("default"!==t&&!(t in e)){const n=Object.getOwnPropertyDescriptor(a,t);n&&Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>a[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function a(e){return Boolean(e&&"function"==typeof e.then)}function o(e,t){return a(e)?Promise.resolve(e).then(t):t(e)}function r(e,t,n){function o(n){const a=t(n);throw e.emit(a),console.error(a),a}try{const e=n();return a(e)?e.catch(o):e}catch(e){o(e)}}function i(e){const t=(Array.isArray(e)?e:[e]).map((e=>`'${e}'`)),n=t.slice(-2).join(" or ");return`Tolgee: You need to specify ${[...t.slice(0,-2),n].join(", ")} option`}function s(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function l(e){return s(e)||[]}function u(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?l(t):l(null==t?void 0:t[e]);var n}function c(e){return Array.from(new Set(e))}function g(e){return e?e.replace(/\/+$/,""):e}const d=(e,t)=>fetch(e,t),f=(e=d)=>(t,n)=>e(t,Object.assign(Object.assign({},n),{headers:Object.assign({"X-Tolgee-SDK-Type":"JS","X-Tolgee-SDK-Version":"5.23.0"},null==n?void 0:n.headers)}));function p(e){let t=[];return Object.freeze({listen(e){const n=t=>{e(t)};return t.push(n),{unsubscribe(){t=t.filter((e=>n!==e))}}},emit(n){e()&&t.forEach((e=>e({value:n})))}})}function h(e,t,n){const a=new Set,o=new Set;let r=[];function i(){if(0===r.length)return;const e=r;r=[],a.forEach((e=>{e({value:void 0})}));let n=new Set;e.forEach((e=>{void 0===e?n=void 0:void 0!==n&&e.forEach((e=>n.add(e)))}));!function(e){const n=new Set(t());o.forEach((t=>{(void 0===e||-1!==(null==e?void 0:e.findIndex((e=>n.has(e)||t.namespaces.has(e)))))&&t.fn({value:void 0})}))}(n?Array.from(n.keys()):void 0)}return Object.freeze({emit(t,n){e()&&(r.push(t),n?setTimeout(i,0):i())},listen(e){a.add(e);return{unsubscribe:()=>{a.delete(e)}}},listenSome(e){const t={fn:t=>{e(t)},namespaces:new Set};o.add(t);const a={unsubscribe:()=>{o.delete(t)},subscribeNs:e=>(l(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}class v extends Error{constructor(e,t,n=!1){const{language:a,namespace:o}=e;super(`Tolgee: Failed to fetch record for "${a}"${o&&` and "${o}"`}`),this.cause=t,this.isDev=n,this.name="RecordFetchError",this.language=a,this.namespace=o}}class m extends Error{constructor(e,t){super(e),this.cause=t,this.name="LanguageDetectorError"}}class y extends Error{constructor(e,t){super(e),this.cause=t,this.name="LanguageStorageError"}}const b=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):b(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},E=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},L=({language:e,namespace:t})=>t?`${e}:${t}`:e;function O(e,t,n,o,r,i,s){const u=new Map,g=new Map;let d={},f=0;function p(t,n,a){const o=L(t);g.set(o,{data:b(n),version:a}),e.onCacheChange.emit(t)}function h(n){let o;if(!o){const e=d[L(n)];"function"==typeof e&&(o=e())}return o||(o=t(n)),a(o)?null==o?void 0:o.catch((t=>{const a=new v(n,t);throw e.onError.emit(a),console.error(a),a})):o}const m=Object.freeze({addStaticData(e){e&&(d=Object.assign(Object.assign({},d),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=E(e),a=g.get(e);a&&0!==a.version||p(n,t,0)}})))},invalidate(){u.clear(),f+=1},addRecord(e,t){p(e,t,f)},exists(e,t=!1){const n=g.get(L(e));return n&&t?n.version===f:Boolean(n)},getRecord(e){var t;return null===(t=g.get(L(o(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=g.get(L(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=g.get(L({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return c(e)},getTranslationFallback(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=g.get(L({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var o;const r=null===(o=g.get(L(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.onCacheChange.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(r())return!0;if(void 0===e)return u.size>0;const t=l(e);return Boolean(Array.from(u.keys()).find((e=>t.includes(E(e).namespace))))},isLoading(e,t){const n=l(t);return Boolean(r()||Array.from(u.keys()).find((t=>{const a=E(t);return(!n.length||n.includes(a.namespace))&&!m.exists({namespace:a.namespace,language:e})})))},async loadRecords(t,a){const r=t.map((t=>{const r=o(t),i=L(r),s=u.get(i);if(s)return{new:!1,promise:s,keyObject:r,cacheKey:i};const l=function(t,a){var o;let r;return a&&(r=null===(o=n(t))||void 0===o?void 0:o.catch((n=>{const a=new v(t,n,!0);return e.onError.emit(a),console.warn(a),h(t)}))),r||(r=h(t)),r}(r,a)||Promise.resolve(void 0);return u.set(i,l),{new:!0,promise:l,keyObject:r,cacheKey:i}}));i.notify(),s.notify();const l=await Promise.all(r.map((e=>e.promise)));return r.forEach(((e,t)=>{const n=u.get(e.cacheKey)!==e.promise;if(e.new&&!n){u.delete(e.cacheKey);const n=l[t];n?m.addRecord(e.keyObject,n):m.getRecord(e.keyObject)||m.addRecord(e.keyObject,{})}})),i.notify(),s.notify(),r.map((e=>m.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(g.entries()).map((([e,t])=>Object.assign(Object.assign({},E(e)),{data:t.data})))});return m}function w(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}const A="invalid",T={defaultNs:"",observerOptions:{tagAttributes:{textarea:["placeholder"],input:["value","placeholder"],img:["alt"],"*":["aria-label","title"]},restrictedElements:["script","style"],highlightKeys:["Alt"],highlightColor:"rgb(255, 0, 0)",highlightWidth:5,inputPrefix:"%-%tolgee:",inputSuffix:"%-%",passToParent:["option","optgroup"],fullKeyEncode:!1},observerType:"invisible",onFormatError:A,apiUrl:"https://app.tolgee.io",fetch:f(),onTranslationMissing:({key:e})=>e},k=(...e)=>{let t={};return e.forEach((e=>{t=Object.assign(Object.assign(Object.assign({},t),e),{observerOptions:Object.assign(Object.assign({},t.observerOptions),null==e?void 0:e.observerOptions)})})),t};function N(e,t){const n=k(T,null==t?void 0:t.initialOptions,e);return n.apiUrl=g(n.apiUrl),(null==e?void 0:e.fetch)&&(n.fetch=f(e.fetch)),{initialOptions:n,activeNamespaces:(null==t?void 0:t.activeNamespaces)||new Map,language:null==t?void 0:t.language,pendingLanguage:null==t?void 0:t.language,isInitialLoading:!1,isRunning:!1}}function j(e,t,n,a,i,s,l,u){const c={ui:void 0},g={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},d=async({keysAndDefaults:e,target:t})=>{var n;const o=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,fallbackNamespaces:a(t),namespace:i({key:e,ns:t})[0],translation:s({key:e,ns:t})})));null===(n=g.ui)||void 0===n||n.handleElementClick(o,t)},f=(e,t)=>{var n;return(null===(n=g.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function p(e){const t=s({key:e.key,ns:e.ns});return C.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function h(){return{fetch:t().fetch}}function v(e){g.observer=null==e?void 0:e()}function b(){return Boolean(g.observer)}function E(e){e&&g.formatters.push(e)}function L(e){g.finalFormatter=e}function O(e){c.ui=e}function T(){return Boolean(c.ui)}function k(e){g.languageStorage=e}function N(e){g.languageDetector=e}function j(e){e&&g.backends.push(e)}function x(e){g.devBackend=e}const C=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:L,addFormatter:E,setObserver:v,hasObserver:b,setUi:O,hasUi:T,setDevBackend:x,addBackend:j,setLanguageDetector:N,setLanguageStorage:k}))},findPositions:f,run(){var e,n;const{apiKey:a,apiUrl:o,projectId:r,observerOptions:i}=t();g.ui=null===(e=c.ui)||void 0===e?void 0:e.call(c,{apiKey:a,apiUrl:o,projectId:r,highlight:C.highlight,changeTranslation:l,findPositions:f,onPermanentChange:e=>u.onPermanentChange.emit(e)}),null===(n=g.observer)||void 0===n||n.run({mouseHighlight:!0,options:i,translate:p,onClick:d})},stop(){var e;g.ui=void 0,null===(e=g.observer)||void 0===e||e.stop()},getLanguageStorage:()=>g.languageStorage,getInitialLanguage(){const e=n();return o(r(u.onError,(e=>new y("Tolgee: Failed to load language",e)),(()=>{var e;return null===(e=g.languageStorage)||void 0===e?void 0:e.getLanguage(h())})),(t=>e&&!e.includes(t)||!t?function(){if(!g.languageDetector)return;const e=n();return r(u.onError,(e=>new m("Tolgee: Failed to detect language",e)),(()=>{var t;return null===(t=g.languageDetector)||void 0===t?void 0:t.getLanguage(Object.assign({availableLanguages:e},h()))}))}():t))},setStoredLanguage:e=>r(u.onError,(e=>new y("Tolgee: Failed to store language",e)),(()=>{var t;return null===(t=g.languageStorage)||void 0===t?void 0:t.setLanguage(e,h())})),getDevBackend:()=>g.devBackend,getBackendRecord:({language:e,namespace:t})=>{for(const n of g.backends){const a=n.getRecord(Object.assign({language:e,namespace:t},h()));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:n})=>{var a;const{apiKey:o,apiUrl:r,projectId:i}=t();return null===(a=g.devBackend)||void 0===a?void 0:a.getRecord(Object.assign({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:n},h()))},getLanguageDetector:()=>g.languageDetector,retranslate(){var e;null===(e=g.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,a;return(null===(a=null===(n=g.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return g.observer?null===(t=g.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return g.observer?null===(t=g.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(C.getDevBackend()),formatTranslation(n){var a,{formatEnabled:o}=n,r=w(n,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:u,params:c,ns:d,orEmpty:f}=r,p=null!=s?s:l;let h="";null==s&&(h=t().onTranslationMissing(r));let v=null!=p?p:f?"":h;const m=e(),y=o||!(null===(a=g.observer)||void 0===a?void 0:a.outputNotFormattable),b=e=>g.observer&&!u?g.observer.wrap({key:i,translation:e,defaultValue:l,params:c,ns:d}):e;v=b(v);try{if(p&&m&&y)for(const e of g.formatters)v=e.format({translation:v,language:m,params:c});g.finalFormatter&&p&&m&&y&&(v=g.finalFormatter.format({translation:v,language:m,params:c}))}catch(e){console.error(e);const n=("string"==typeof(E=e)?E:"string"==typeof(null==E?void 0:E.message)?E.message:void 0)||A,a=t().onFormatError,o=typeof a;v="string"===o?a:"function"===o?a(n,r):A,v=b(v)}var E;return v}});return C}const x=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const C=(e,...t)=>{let n,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof t[0]?(a.defaultValue=t[0],n=t[1]):"object"==typeof t[0]&&(n=t[0])),n&&(a=Object.assign(Object.assign({},function(e){var{ns:t,noWrap:n,orEmpty:a,params:o,language:r}=e,i=w(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:r};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function R({options:e}){const t=function(e,t){let n=!0;function a(){return n}const o=Object.freeze({onPendingLanguageChange:p(a),onLanguageChange:p(a),onLoadingChange:p(a),onFetchingChange:p(a),onInitialLoaded:p(a),onRunningChange:p(a),onCacheChange:p(a),onUpdate:h(a,e,t),onPermanentChange:p(a),onError:p(a),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.onPendingLanguageChange.listen(t);case"language":return o.onLanguageChange.listen(t);case"loading":return o.onLoadingChange.listen(t);case"fetching":return o.onFetchingChange.listen(t);case"initialLoad":return o.onInitialLoaded.listen(t);case"running":return o.onRunningChange.listen(t);case"cache":return o.onCacheChange.listen(t);case"update":return o.onUpdate.listen(t);case"permanentChange":return o.onPermanentChange.listen(t);case"error":return o.onError.listen(t)}}});return o.onInitialLoaded.listen((()=>o.onUpdate.emit())),o.onLanguageChange.listen((()=>o.onUpdate.emit())),o.onCacheChange.listen((({value:e})=>o.onUpdate.emit([e.namespace],!0))),o}(m,y),n=x(!1,(()=>f.isFetching()),t.onFetchingChange.emit),r=x(!1,(()=>S.isLoading()),t.onLoadingChange.emit),s=function(e,t,n){let a,o=N();const r=Object.freeze({init(e){o=N(e,o)},isRunning:()=>o.isRunning,setRunning(e){o.isRunning!==e&&(o.isRunning=e,n.emit(e))},isInitialLoading:()=>o.isInitialLoading,setInitialLoading(e){o.isInitialLoading=e},getLanguage:()=>o.language||o.initialOptions.language,setLanguage(t){o.language!==t&&(o.language=t,e.emit(t))},getPendingLanguage:()=>o.pendingLanguage||r.getLanguage(),setPendingLanguage(e){o.pendingLanguage!==e&&(o.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},o.initialOptions),a),addActiveNs(e){l(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t?o.activeNamespaces.set(e,t+1):o.activeNamespaces.set(e,1)}))},removeActiveNs(e){l(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t&&t>1?o.activeNamespaces.set(e,t-1):o.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>c([...o.initialOptions.ns||[o.initialOptions.defaultNs],...l(o.initialOptions.fallbackNs),...o.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||r.getLanguage();return t?c([t,...u(t,o.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>l(o.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?o.initialOptions.defaultNs:e,getAvailableLanguages(){if(o.initialOptions.availableLanguages)return o.initialOptions.availableLanguages;if(o.initialOptions.staticData){const e=Object.keys(o.initialOptions.staticData).map((e=>E(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?r.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:g(e.apiUrl)}):void 0}});return r}(t.onLanguageChange,t.onPendingLanguageChange,t.onRunningChange),d=j(s.getLanguage,s.getInitialOptions,s.getAvailableLanguages,b,k,R,w,t),f=O(t,d.getBackendRecord,d.getBackendDevRecord,s.withDefaultNs,s.isInitialLoading,n,r);let v;function m(){return s.getFallbackNs()}function y(e){return s.getDefaultNs(e)}function b(e){return[...l(y(e)),...m()]}function L(e){return[...l(null!=e?e:y()),...s.getRequiredNamespaces()]}function w(e,t,n){const a=s.withDefaultNs(e),o=f.getTranslation(a,t);return f.changeTranslation(a,t,n),{revert(){f.changeTranslation(a,t,o)}}}function A(e){s.init(e),f.addStaticData(s.getInitialOptions().staticData)}function T(e,t){const n=function(e,t){const n=s.getFallbackLangs(e),a=L(t),o=[];return n.forEach((e=>{a.forEach((t=>{f.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}(e,t);if(n.length)return o(S.loadRecords(n),(()=>{}))}function k({key:e,ns:t}){const n=s.getFallbackLangs(),a=b(null!=t?t:void 0);return f.getTranslationNs(a,n,e)}function R({key:e,ns:t,language:n}){const a=b(null!=t?t:void 0),o=s.getFallbackLangs(n);return f.getTranslationFallback(a,o,e)}function P(){const e=o(function(){if(s.getLanguage())return;return o(d.getInitialLanguage(),(e=>{const t=e||s.getInitialOptions().defaultLanguage;t&&s.setLanguage(t)}))}(),(()=>T()));if(a(e))return s.setInitialLoading(!0),n.notify(),r.notify(),Promise.resolve(e).then((()=>{s.setInitialLoading(!1),n.notify(),r.notify(),t.onInitialLoaded.emit()}));t.onInitialLoaded.emit()}e&&A(e),t.onUpdate.listen((()=>{s.isRunning()&&d.retranslate()}));const S=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),s),d),f),{init:A,getTranslation:R,changeTranslation:w,getTranslationNs:k,getDefaultAndFallbackNs:b,findPositions:d.findPositions,async changeLanguage(e){s.getPendingLanguage()===e&&s.getLanguage()===e||(s.setPendingLanguage(e),s.isRunning()&&await T(e),e===s.getPendingLanguage()&&(s.setLanguage(e),await d.setStoredLanguage(e)))},async addActiveNs(e,t){t||s.addActiveNs(e),s.isRunning()&&await T(void 0,e)},loadRecords:e=>f.loadRecords(e,S.isDev()),loadRecord:async e=>(await S.loadRecords([e]))[0],isLoading:e=>f.isLoading(s.getLanguage(),e),isLoaded(e){const t=s.getLanguage();if(!t)return!1;const n=s.getFallbackLangs(t),a=L(e),o=[];return n.forEach((e=>{a.forEach((t=>{f.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=C(...e),n=R(t);return d.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(s.getInitialOptions().apiKey&&s.getInitialOptions().apiUrl),run:()=>(function(){if((d.getLanguageDetector()||d.getLanguageStorage())&&!s.getAvailableLanguages())throw new Error(i("availableLanguages"));if(!s.getLanguage()&&!s.getInitialOptions().defaultLanguage)throw new Error(i(["defaultLanguage","language"]))}(),s.isRunning()||(s.setRunning(!0),d.run(),v=P()),Promise.resolve(v)),stop(){s.isRunning()&&(d.stop(),s.setRunning(!1))}}));return S}const P=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=k(e.options,n),t),init(t){const n=function(e){const t=R({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),t.isDev()&&t.invalidate(),n&&t.run()}t.isDev()&&t.invalidate();const a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmitterActive:t.setEmitterActive,getLanguage:t.getLanguage,getPendingLanguage:t.getPendingLanguage,changeLanguage:t.changeLanguage,changeTranslation:t.changeTranslation,addActiveNs:t.addActiveNs,removeActiveNs:t.removeActiveNs,loadRecords:t.loadRecords,loadRecord:t.loadRecord,addStaticData:t.addStaticData,getRecord:t.getRecord,getAllRecords:t.getAllRecords,isLoaded:t.isLoaded,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,findPositions:t.findPositions,getInitialOptions:t.getInitialOptions,isDev:t.isDev,wrap:t.wrap,unwrap:t.unwrap,overrideCredentials(e){n((()=>t.overrideCredentials(e)))},addPlugin(e){e&&n((()=>t.addPlugin(a,e)))},updateOptions(e){e&&n((()=>t.init(e)))}});return a}(k(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},S=0,D=1,_=2;class I extends Error{constructor(e,t,n){let a;a=e===S?"Empty parameter":e===D?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function F(e){return/\s/.test(e)}const U=0,$=1,M=2,B=3,K=4,V=new Set([M,$,U]),z="'",W=new Set(["{","}",z]),G=e=>/[0-9a-zA-Z_]/.test(e);function Y(e,t){const[n,a]=function(e){let t=U,n="",a="",o="";const r=[],i=[];let s=0;function l(t){throw new I(t,s,e)}const u=()=>{r.push(n),n=""},c=()=>{""===a&&l(S),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case U:o===z?(n+=o,t=$):"{"===o?(u(),t=B):(n+=o,t=U);break;case $:W.has(o)?(n=n.slice(0,-1)+o,t=M):(n+=o,t=U);break;case M:o===z?t=U:(n+=o,t=M);break;case B:"}"===o?(c(),t=U):F(o)?""!==a&&(c(),t=K):(G(o)||l(D),a+=o,t=B);break;case K:"}"==o?t=U:F(o)?t=K:l(D)}return V.has(t)||l(_),u(),[r,i]}(e),o=[n[0]];for(let r=1;r<n.length;r++){const i=null==t?void 0:t[a[r-1]];if(void 0===i)throw new Error(`Missing parameter "${a[r-1]}" in "${e}"`);o.push(String(i)),o.push(n[r])}return o.join("")}const H="__tolgee_dev_tools",X="data-tolgee-key-only",J="data-tolgee-restricted",q="_tolgee",Z="_tolgee-highlighter";function Q(){var e,t;return void 0===(null==(t=null==(e=globalThis.window)?void 0:e.document)?void 0:t.createElement)}function ee(e){if(Q())throw new Error(`${e}: Can't run on the server`)}function te(e,t){return{oldTextContent:e,keys:t}}const ne={position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function ae({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(Z),Object.entries(ne).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const r=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=r.top-t+"px",o.style.left=r.left-t+"px",o.style.width=r.width+"px",o.style.height=r.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null==(e=t.highlightEl)||e.remove(),t.highlightEl=void 0}}(0,a)}})}function oe(e){return e.textContent}function re(e,t){e.textContent=t}function ie(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null==(n=e.ns)?void 0:n.findIndex((e=>{var n;return null==(n=t.ns)?void 0:n.includes(e)})));return a&&o}const se={capture:!0},le={capture:!0,passive:!0},ue=new Map([["Control","ctrlKey"],["Alt","altKey"],["Meta","metaKey"],["Shift","shiftKey"]]);function ce({highlightKeys:e,elementStore:t,onClick:n,options:a}){var o,r;const i=new Set;let s,l,u=[];const c=(null==(o=a.targetElement)?void 0:o.getRootNode())||document,g=(null==(r=a.targetElement)?void 0:r.ownerDocument)||document;function d(){var e;const n=t.get(s);n&&(n.preventClean=!1,null==(e=n.unhighlight)||e.call(n),s=void 0)}function f(){const e=l;let n;if(e&&A()){n=function(e){for(const n of e){const e=w(n,(e=>t.get(e)));if(void 0!==e)return e||void 0}}(c.elementsFromPoint(e.x,e.y)||[])}!function(e){var n;if(s!==e){d();const a=t.get(e);a&&(a.preventClean=!0,null==(n=a.highlight)||n.call(a),s=e)}}(n)}function p(e){l=e,f()}function h(e){for(const[t,n]of ue.entries())i.has(t)&&!e[n]?i.delete(t):!i.has(t)&&e[n]&&i.add(t)}function v(e){var t;h(e),A()&&(t=e.target,!Boolean(w(t,(e=>e.id===H))))&&(e.stopPropagation(),e.preventDefault())}function m(e){h(e),p({x:e.clientX,y:e.clientY})}function y(e){h(e),f()}function b(e){h(e),f()}function E(){var e;const n=t.get(s);null==(e=null==n?void 0:n.highlight)||e.call(n)}function L(e){v(e),h(e),p({x:e.clientX,y:e.clientY}),A()&&s&&(n(s),d())}function O(e,t,n){g.addEventListener(e,t,n),u.push([e,t,n])}function w(e,t){return e.id===H?null:t(e)?e:(null==e?void 0:e.parentElement)?w(e.parentElement,t):void 0}function A(){for(const t of e)if(!i.has(t))return!1;return!0}return Object.freeze({stop(){!function(){for(const e of u)g.removeEventListener(...e);u=[]}()},run(){O("keydown",y,se),O("keyup",b,se),O("mousemove",m,le),O("scroll",E,le),O("click",L,se),O("mouseenter",v,se),O("mouseover",v,se),O("mouseout",v,se),O("mouseleave",v,se),O("mousedown",v,se),O("mouseup",v,se)}})}function ge(e,t,n){const a=ae({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),o=ce({highlightKeys:e.highlightKeys,elementStore:t,onClick(e){const a=t.get(e);n({target:e,keysAndDefaults:i(a)})},options:e});function r(e,n){var a;n.highlightEl&&(null==(a=n.unhighlight)||a.call(n)),e.removeAttribute(q),t.remove(e)}function i(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({register(n,o,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${J}]`)}(n))return;const i=n;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(q,"true")),s.nodes.set(o,r),a.initHighlighter(i,s)},forEachElement:t.forEachElement,cleanupLingeringKeyAttributes(){t.forEachElement(((e,t)=>{if(!t.preventClean){for(const[e]of t.nodes)if(e.nodeType===Node.ATTRIBUTE_NODE){const n=e;n.name===X&&null===n.ownerElement&&t.nodes.delete(n)}0===t.nodes.size&&r(e,t)}}))},cleanupRemovedNodes(e){t.forEachElement(((t,n)=>{n.preventClean||(e.has(t)||function(e,t){for(const[n]of e.nodes)t.has(n)&&e.nodes.delete(n)}(n,e),(e.has(t)||0===n.nodes.size)&&r(t,n))}))},findAll(e,n){const a=[];return t.forEachElement(((t,o)=>{for(const t of o.nodes.values()){if(t.keys.find((t=>ie({key:e,ns:s(n)},{key:t.key,ns:s(t.ns)})))){a.push(o);break}}})),a},run(e){e&&o.run()},stop(){o.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null==(n=t.unhighlight)||n.call(t))}))}})}function de(){let e,t=!1;const n=function(){const e=new Map;return Object.freeze({set(t,n){e.set(t,n)},get:t=>t&&e.get(t),remove:t=>e.delete(t),forEachElement(t){e.forEach(((e,n)=>t(n,e)))}})}();function a({mouseHighlight:e,options:a,wrapper:o,onClick:r}){if(Q())return{stop(){t=!1},wrapper:o};const i=function(e){const t=Object.freeze({getSuitableParent(n){const a=function(e){return e.parentElement?e.parentElement:e.ownerElement&&e.ownerElement||void 0}(n);if(void 0===a)throw console.error(n),new Error("No suitable parent found for node above.");if(!e.passToParent)return a;if(Array.isArray(e.passToParent)){const t=e=>a.tagName.toLowerCase()===e.toLowerCase();if(-1===e.passToParent.findIndex(t))return a}return"function"!=typeof e.passToParent||e.passToParent(a)?t.getSuitableParent(a):a}});return t}(a),s=function(e,t){const n=Object.freeze({handleAttributes(n,a=!0){const o=[],r=Object.fromEntries(Object.entries(e.tagAttributes).map((([e,t])=>[e.toUpperCase(),t])));if(n.nodeType===Node.ELEMENT_NODE){const e=n;let a=r[e.tagName.toUpperCase()]??[];"*"in r&&(a=a.concat(r["*"])),o.push(...a.filter((t=>e.hasAttribute(t))).map((t=>e.getAttributeNode(t))).filter((e=>t.testAttribute(e))))}if(a){const e=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,(e=>{var t,n;return(null==(t=r[e.tagName.toUpperCase()])?void 0:t.some((t=>e.hasAttribute(t))))||(null==(n=r["*"])?void 0:n.some((t=>e.hasAttribute(t))))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}));for(;e.nextNode();){const n=e.currentNode;let a=r[n.tagName.toUpperCase()]??[];"*"in r&&(a=a.concat(r["*"])),o.push(...a.filter((e=>n.hasAttribute(e))).map((e=>n.getAttributeNode(e))).filter((e=>t.testAttribute(e))))}}return o},handleChildList(e){const t=[];return t.push(...e.flatMap((e=>n.handleAttributes(e,!0)))),t.push(...e.flatMap((e=>n.handleText(e)))),t},handleText(e){if(e.nodeType===Node.TEXT_NODE)return t.testTextNode(e)?[e]:[];const n=[],a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,(e=>t.testTextNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;a.nextNode();)n.push(a.currentNode);return n}});return n}(a,o),l=ge(a,n,r);function u(e){for(const t of e){const e=oe(t),n=e?o.unwrap(e):null;if(n){const{text:a,keys:o}=n;re(t,a);const r=te(e,o),s=i.getSuitableParent(t);l.register(s,t,r)}}}function c(e){const t=i.getSuitableParent(e);l.register(t,e,{oldTextContent:"",keys:[{key:oe(e)}],keyAttributeOnly:!0})}function g(e,t){if(e.nodeType===Node.ATTRIBUTE_NODE){const t=e;if(t.name===X)return void c(t)}if(e.nodeType===Node.ELEMENT_NODE){const t=e.getAttributeNode(X);t&&c(t)}if(!t)return;const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,(e=>e.hasAttribute(X)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP));for(;n.nextNode();){c(n.currentNode.getAttributeNode(X))}}const d=new MutationObserver((e=>{if(!t)return;const n=e.filter((e=>"childList"===e.type)).flatMap((e=>Array.from(e.removedNodes))),a=new Set(n);for(const e of n){if(e.nodeType===Node.ELEMENT_NODE)for(let t=0;t<e.attributes.length;t++)a.add(e.attributes[t]);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);for(;t.nextNode();){const e=t.currentNode;if(e.nodeType===Node.ELEMENT_NODE){const t=e;for(let e=0;e<t.attributes.length;e++)a.add(t.attributes[e])}a.add(e)}}a.size>0&&l.cleanupRemovedNodes(a),e.some((e=>"attributes"===e.type&&e.attributeName===X))&&l.cleanupLingeringKeyAttributes();const o=new Set;for(const t of e)switch(t.type){case"characterData":s.handleText(t.target).forEach((e=>o.add(e)));break;case"childList":g(t.target,!0),t.addedNodes.length>0&&s.handleChildList(Array.from(t.addedNodes)).forEach((e=>o.add(e))),t.removedNodes.length>0&&s.handleChildList(Array.from(t.removedNodes)).forEach((e=>o.delete(e)));break;case"attributes":t.attributeName===X&&g(t.target,!1),s.handleAttributes(t.target,!1).forEach((e=>o.add(e)))}u([...o])})),f=a.targetElement||document.body;t=!0,l.run(e),g(f,!0),u(s.handleChildList([f]));const p=new Set;return p.add(X),Object.values(a.tagAttributes).forEach((e=>e.forEach((e=>p.add(e.toLowerCase()))))),d.observe(f,{attributes:!0,attributeFilter:[...p],childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),d.disconnect()},elementRegistry:l,wrapper:o}}return Object.freeze({run(t){e=a(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null==(a=null==(n=null==e?void 0:e.elementRegistry)?void 0:n.forEachElement)||a.call(n,t)},highlight(t,n){var a;const o=(null==(a=null==e?void 0:e.elementRegistry)?void 0:a.findAll(t,n))||[];return o.forEach((e=>{var t;return null==(t=e.highlight)?void 0:t.call(e)})),{unhighlight(){o.forEach((e=>{var t;return null==(t=e.unhighlight)?void 0:t.call(e)}))}}},findPositions(t,n){var a;const o=(null==(a=null==e?void 0:e.elementRegistry)?void 0:a.findAll(t,n))||[],r=[];return o.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),o.forEach((e=>{const a=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{ie({key:t,ns:s(n)},{key:e.key,ns:s(e.ns)})&&r.push({position:{x:a.x,y:a.y,width:a.width,height:a.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),r},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}var fe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},pe={};!function(e){function t(e){for(var t=0,n=Math.min(65536,e.length+1),a=new Uint16Array(n),o=[],r=0;;){var i=t<e.length;if(!i||r>=n-1){var s=a.subarray(0,r);if(o.push(String.fromCharCode.apply(null,s)),!i)return o.join("");e=e.subarray(t),t=0,r=0}var l=e[t++];if(0==(128&l))a[r++]=l;else if(192==(224&l)){var u=63&e[t++];a[r++]=(31&l)<<6|u}else if(224==(240&l)){u=63&e[t++];var c=63&e[t++];a[r++]=(31&l)<<12|u<<6|c}else if(240==(248&l)){var g=(7&l)<<18|(u=63&e[t++])<<12|(c=63&e[t++])<<6|63&e[t++];g>65535&&(g-=65536,a[r++]=g>>>10&1023|55296,g=56320|1023&g),a[r++]=g}}}var n="Failed to ",a=function(e,t,a){if(e)throw new Error("".concat(n).concat(t,": the '").concat(a,"' option is unsupported."))},o="function"==typeof Buffer&&Buffer.from,r=o?function(e){return Buffer.from(e)}:function(e){for(var t=0,n=e.length,a=0,o=Math.max(32,n+(n>>>1)+7),r=new Uint8Array(o>>>3<<3);t<n;){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319){if(t<n){var s=e.charCodeAt(t);56320==(64512&s)&&(++t,i=((1023&i)<<10)+(1023&s)+65536)}if(i>=55296&&i<=56319)continue}if(a+4>r.length){o+=8,o=(o*=1+t/e.length*2)>>>3<<3;var l=new Uint8Array(o);l.set(r),r=l}if(0!=(4294967168&i)){if(0==(4294965248&i))r[a++]=i>>>6&31|192;else if(0==(4294901760&i))r[a++]=i>>>12&15|224,r[a++]=i>>>6&63|128;else{if(0!=(4292870144&i))continue;r[a++]=i>>>18&7|240,r[a++]=i>>>12&63|128,r[a++]=i>>>6&63|128}r[a++]=63&i|128}else r[a++]=i}return r.slice?r.slice(0,a):r.subarray(0,a)};function i(){this.encoding="utf-8"}i.prototype.encode=function(e,t){return a(t&&t.stream,"encode","stream"),r(e)};var s=!o&&"function"==typeof Blob&&"function"==typeof URL&&"function"==typeof URL.createObjectURL,l=["utf-8","utf8","unicode-1-1-utf-8"],u=t;o?u=function(e,t){return(e instanceof Buffer?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)).toString(t)}:s&&(u=function(e){try{return function(e){var t;try{var n=new Blob([e],{type:"text/plain;charset=UTF-8"});t=URL.createObjectURL(n);var a=new XMLHttpRequest;return a.open("GET",t,!1),a.send(),a.responseText}finally{t&&URL.revokeObjectURL(t)}}(e)}catch(n){return t(e)}});var c="construct 'TextDecoder'",g="".concat(n," ").concat(c,": the ");function d(e,t){if(a(t&&t.fatal,c,"fatal"),e=e||"utf-8",!(o?Buffer.isEncoding(e):-1!==l.indexOf(e.toLowerCase())))throw new RangeError("".concat(g," encoding label provided ('").concat(e,"') is invalid."));this.encoding=e,this.fatal=!1,this.ignoreBOM=!1}d.prototype.decode=function(e,t){var n;return a(t&&t.stream,"decode","stream"),n=e instanceof Uint8Array?e:e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer):new Uint8Array(e),u(n,this.encoding)},e.TextEncoder=e.TextEncoder||i,e.TextDecoder=e.TextDecoder||d}("undefined"!=typeof window?window:fe);const he=n({__proto__:null,default:pe},[pe]);null==(t=console.assert)||t.call(console,he);const ve=["",""],me=RegExp(`([${ve.join("")}]{9})+`,"gu");function ye(e){const t=function(e){return Array.from((new TextEncoder).encode(e))}(e).map(Number),n=t.map((e=>function(e){const t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0")).join("");return Array.from(n).map((e=>ve[Number(e)])).join("")}function be(e){const t=Array.from(e).map((e=>ve.indexOf(e))).map(String).join("").match(/(.{9})/g),n=Uint8Array.from((null==t?void 0:t.map((e=>parseInt(e.slice(0,8),2))))||[]);return a=n,(new TextDecoder).decode(new Uint8Array(a));var a}function Ee({fullKeyEncode:e}){const t=function(){const e=[];return Object.freeze({valueToNumber(t){let n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:t=>e[t]})}();function n(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}return Object.freeze({unwrap(e){const n=[],a=function(e){var t;const n=null==(t=e.match(me))?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(be))||[]}(e);a.forEach((e=>{const a=function(e){if(e.length<=4){const[n]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(e);return t.numberToValue(n)}return e}(e),o=function(e){try{return JSON.parse(e||"{}")}catch(e){return void console.error(e)}}(a);if(o){const{k:e,d:t,n:a}=o;n.push({key:e,defaultValue:t,ns:a})}}));const o=function(e){return e.replace(me,"")}(e);return{text:o,keys:n}},wrap({key:a,defaultValue:o,translation:r,ns:i}){let s;if(e){s=ye(n({key:a,ns:i}))}else{const e=n({key:a,ns:i,defaultValue:o}),r=t.valueToNumber(e);s=ye(String.fromCodePoint(r))}const l=r||"";return"string"==typeof l?l+s:l},testTextNode(e){var t,n;return((null==(t=e.textContent)?void 0:t.includes(`${ve[0]}${ve[0]}`))||(null==(n=e.textContent)?void 0:n.includes(`${ve[1]}${ve[0]}`)))??!1},testAttribute:e=>e.value.includes(`${ve[0]}${ve[0]}`)||e.value.includes(`${ve[1]}${ve[0]}`)})}function Le(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function Oe({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:o,ns:r}=function(e){let t=!1,n="",a="",o="KEY";const r={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{r.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",r.params[a]=n,n=""):(o="PARAM_VALUE",a=n,n=""):(o="PARAM_NAME",r.defaultValue=n,n=""):(o="PARAM_NAME",r.key=n,n=""):(o="DEFAULT_VALUE",i(n),n=""):(o="NAMESPACE",r.key=n,n=""):(o="DEFAULT_VALUE",r.key=n,n=""):t=!0;return"KEY"===o&&(r.key=n),"DEFAULT_VALUE"===o&&(r.defaultValue=n),"PARAM_VALUE"===o&&(r.params[a]=n),"NAMESPACE"===o&&i(n),r}(e);return{translated:n({key:t,params:a,defaultValue:o,ns:r,noWrap:!0}),key:t,params:a,defaultValue:o,ns:r}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e){return"string"==typeof e?e.replace(/[,:|\\]/gs,"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(`Parameters of type "${typeof e}" are not supported in "text" wrapper mode.`),e)}return Object.freeze({wrap({key:n,params:a,defaultValue:o,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${r(e)}:${r(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==o?`,${r(o)}`:"",u="string"==typeof i?[i]:i,c=(null==u?void 0:u.length)?`|${u.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${c}${l}${s}${t}`},unwrap(n){const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,l=!1,u=0,c="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(c+=f.substr(u,d-u),u=d+t.length,"\\"===e){if(!Le(d,n)){c+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,c+=e+p.translated}return c+=n.substring(u),l?{text:c,keys:i}:{text:n,keys:[]}},testTextNode(n){var a,o;return((null==(a=n.textContent)?void 0:a.includes(e))&&(null==(o=n.textContent)?void 0:o.includes(t)))??!1},testAttribute:n=>n.value.includes(e)&&n.value.includes(t)})}const we="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Ae(e){const t=we.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function Te(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|Ae(e[i]),n+=5,n>=8&&(r[o++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+o));return a}(r.buffer)}function ke(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=Te(n).split("_");return Number(e)}}catch{console.warn("Tolgee: Api key can't be parsed")}}function Ne({message:e,recievingMessage:t,data:n,attempts:a=1,timeout:o=300}){let r=!1;const i=()=>new Promise(((a,r)=>{const i=function(e,t){const n=n=>{var a,o;e.includes(null==(a=n.data)?void 0:a.type)&&t(null==(o=n.data)?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(s),l(),a(e)}));window.postMessage({type:e,data:n},window.origin);const s=setTimeout((function(){l(),r()}),o);function l(){i.unsubscribe()}}));return{cancel(){r=!0},promise:(async()=>{for(let e=0;e<a;e++){if(r)return new Promise((()=>{}));try{return await i()}catch(e){continue}}if(!r)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}let je=null;function xe(e){var t;return je||(je=(t=`https://cdn.jsdelivr.net/npm/@tolgee/web@${e}/dist/tolgee-in-context-tools.umd.min.js`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.head.appendChild(a)}))).then((()=>window["@tolgee/in-context-tools"].InContextTools))),je}const Ce="__tolgee_apiKey",Re="__tolgee_apiUrl";function Pe(){const e=sessionStorage.getItem(Ce)||void 0,t=sessionStorage.getItem(Re)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Se(){sessionStorage.removeItem(Ce),sessionStorage.removeItem(Re)}e.BrowserExtensionPlugin=()=>e=>e;(()=>{if("undefined"==typeof window)return!1;try{return"undefined"!=typeof sessionStorage&&sessionStorage}catch(e){return console.error("sessionStorage not available",e),!1}})()&&(e.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=Ne({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:t,attempts:4});return e=n,a}}}();e.on("running",(({value:n})=>{var a;n&&(a=()=>{t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(Se)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Pe()&&(async()=>{const e=await xe("5.23.0");return t=>{const n=Pe();return t.addPlugin(e({credentials:n})),t}})().then((t=>{e.addPlugin(t)})).catch((e=>{console.error("Tolgee: Failed to load in-context tools"),console.error(e)})),e});const De="__tolgee_currentLanguage";function _e(e){return e.endsWith("/")?e.slice(0,-1):e}const Ie={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${_e(n)}/${e}/${t}.json`:`${_e(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};e.BackendFetch=e=>(t,n)=>(n.addBackend(function(e){const{prefix:t,getPath:n,getData:a,headers:o,...r}={...Ie,...e,headers:{...Ie.headers,...null==e?void 0:e.headers}};return{getRecord:({namespace:e,language:i,fetch:s})=>s(n({namespace:e,language:i,prefix:t}),{headers:o,...r}).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return a(e)}))}}(e)),t),e.DEVTOOLS_ID=H,e.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o,fetch:r}){const i=ke(t)??o;let s=void 0!==i?`${e}/v2/projects/${i}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(s+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return r(s,{headers:{"X-API-Key":t||"","Content-Type":"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>e[n]));throw new Error(e.statusText)}))}}),e),e.DevTools=()=>e=>e,e.FormatSimple=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>Y(e,t)}),e),e.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){ee("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=a(window.navigator.language);return e.find((e=>a(e)===o))||void 0}}),e),e.LanguageDetectorError=m,e.LanguageStorage=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(ee("LanguageStorage"),localStorage.getItem(De)||void 0),setLanguage(e){ee("LanguageStorage"),localStorage.setItem(De,e)}}),e),e.LanguageStorageError=y,e.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=de();return Object.freeze({...e,run(t){const n=Oe({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run({...t,wrapper:n})},retranslate(){e.forEachElement(((t,n)=>{for(const[t,a]of n.nodes.entries()){if(a.keyAttributeOnly)return;const n=e.unwrap(a.oldTextContent);n&&re(t,n.text)}}))},outputNotFormattable:!0})})):t.setObserver((()=>{const e=de();return Object.freeze({...e,run(t){const n=Ee({fullKeyEncode:t.options.fullKeyEncode});e.run({...t,wrapper:n})},retranslate(){},outputNotFormattable:!1})})),e),e.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",e.RecordFetchError=v,e.TOLGEE_ATTRIBUTE_NAME=q,e.TOLGEE_RESTRICT_ATTRIBUTE=J,e.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=X,e.Tolgee=function(){return P().use(e.BrowserExtensionPlugin())},e.TolgeeCore=P,e.createFetchFunction=f,e.getFallback=s,e.getFallbackArray=l,e.getProjectIdFromApiKey=ke,e.getTranslateProps=C,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})})); | ||
//# sourceMappingURL=tolgee-web.production.umd.min.js.map |
@@ -7,3 +7,3 @@ import { ModifierKey, ObserverOptionsInternal } from '@tolgee/core'; | ||
elementStore: ElementStoreType; | ||
onClick: (event: MouseEvent, el: TolgeeElement) => void; | ||
onClick: (el: TolgeeElement) => void; | ||
options: ObserverOptionsInternal; | ||
@@ -10,0 +10,0 @@ }; |
import React from 'react'; | ||
export interface KeyContextMenuParams { | ||
openEvent: MouseEvent; | ||
export interface KeyContextMenuProps { | ||
target: HTMLElement; | ||
keys: Map<string, string | undefined>; | ||
onSelect: (key: string | undefined) => void; | ||
} | ||
export type KeyContextMenuState = Partial<KeyContextMenuParams> & { | ||
export type KeyContextMenuState = Partial<KeyContextMenuProps> & { | ||
opened: boolean; | ||
}; | ||
export declare class KeyContextMenu extends React.Component { | ||
state: KeyContextMenuState & { | ||
opened: boolean; | ||
}; | ||
show(params: KeyContextMenuParams): Promise<void>; | ||
type Props = { | ||
initialState: KeyContextMenuProps; | ||
}; | ||
export declare class KeyContextMenu extends React.Component<Props, KeyContextMenuState> { | ||
state: KeyContextMenuState; | ||
constructor(props: Props); | ||
keyDown: (e: KeyboardEvent) => void; | ||
@@ -20,1 +21,2 @@ componentDidMount(): void; | ||
} | ||
export {}; |
@@ -14,3 +14,2 @@ /// <reference types="react" /> | ||
defaultValue: string; | ||
open: boolean; | ||
onClose: () => void; | ||
@@ -40,3 +39,2 @@ uiProps: UiProps; | ||
readonly input: string; | ||
readonly open: boolean; | ||
readonly fallbackNamespaces: string[]; | ||
@@ -43,0 +41,0 @@ readonly selectedNs: string; |
@@ -1,25 +0,13 @@ | ||
import * as React from 'react'; | ||
import type { UiProps } from '@tolgee/core'; | ||
export type ComponentDependencies = UiProps; | ||
export type Props = UiProps; | ||
type State = { | ||
export type KeyData = { | ||
key: null | string; | ||
defaultValue: undefined | string; | ||
dialogOpened: boolean; | ||
fallbackNamespaces: string[]; | ||
namespace: string; | ||
}; | ||
export declare class KeyDialog extends React.Component<Props, State> { | ||
state: { | ||
key: any; | ||
defaultValue: any; | ||
dialogOpened: boolean; | ||
fallbackNamespaces: any[]; | ||
namespace: string; | ||
}; | ||
constructor(props: Props); | ||
translationEdit(key: string, defaultValue: string | undefined, fallbackNamespaces: string[], namespace: string): void; | ||
render: () => import("react/jsx-runtime").JSX.Element; | ||
private onClose; | ||
} | ||
export {}; | ||
export type Props = { | ||
uiProps: UiProps; | ||
keyData: KeyData; | ||
}; | ||
export declare const KeyDialog: ({ uiProps, keyData }: Props) => import("react/jsx-runtime").JSX.Element; |
{ | ||
"name": "@tolgee/web", | ||
"version": "5.22.1-prerelease.d00c62d8.0", | ||
"version": "5.23.0", | ||
"description": "Tolgee for web", | ||
@@ -13,8 +13,6 @@ "declaration": true, | ||
"import": "./dist/tolgee-web.production.esm.js", | ||
"require": "./dist/tolgee-web.production.umd.cjs", | ||
"module": "./dist/tolgee-web.production.umd.cjs" | ||
"require": "./dist/tolgee-web.production.umd.cjs" | ||
}, | ||
"import": "./dist/tolgee-web.development.esm.js", | ||
"require": "./index.cjs", | ||
"module": "./dist/tolgee-web.production.umd.cjs", | ||
"types": "./types/index.d.ts" | ||
@@ -25,3 +23,2 @@ }, | ||
"require": "./dist/tolgee-in-context-tools.umd.cjs", | ||
"module": "./dist/tolgee-web.production.umd.cjs", | ||
"types": "./types/tools.d.ts" | ||
@@ -33,3 +30,3 @@ }, | ||
"dev": "vite", | ||
"develop": "concurrently \"tsc --project tsconfig.prod.json --watch\" \"vite build --watch\"", | ||
"develop": "concurrently --raw \"tsc --watch --preserveWatchOutput --project tsconfig.prod.json\" \"vite build --watch\"", | ||
"build": "tsc --project tsconfig.prod.json && vite build && vite build --config vite.config.production.ts && vite build --config vite.config.tools.ts", | ||
@@ -54,3 +51,3 @@ "test": "jest --collect-coverage", | ||
"dependencies": { | ||
"@tolgee/core": "5.22.1-prerelease.d00c62d8.0" | ||
"@tolgee/core": "5.23.0" | ||
}, | ||
@@ -105,3 +102,3 @@ "devDependencies": { | ||
"homepage": "https://github.com/tolgee/tolgee-js#readme", | ||
"gitHead": "59bae11f3ce4e153b4c798e62f968d8ceb06acfa", | ||
"gitHead": "8583a512984d3fa33a670123fbbb4f9c7ef4d517", | ||
"publishConfig": { | ||
@@ -108,0 +105,0 @@ "access": "public" |
189
README.md
@@ -1,30 +0,177 @@ | ||
# React + TypeScript + Vite | ||
<!-- This file was generated using pnpm generate-readmes script | ||
Don't edit this file. Edit the README.md.njk. Macros can be found in readmeMacros/macros.njk | ||
--> | ||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
Currently, two official plugins are available: | ||
<h1 align="center" style="border-bottom: none"> | ||
<b> | ||
<a href="https://tolgee.io">Tolgee JS Web</a><br> | ||
</b> | ||
The base of Tolgee JS integrations for Web platform | ||
<br> | ||
</h1> | ||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
<div align="center"> | ||
## Expanding the ESLint configuration | ||
[![Logo](https://user-images.githubusercontent.com/18496315/188628892-33fcc282-26f1-4035-8105-95952bd93de9.svg)](https://tolgee.io) | ||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: | ||
Tolgee is an open-source alternative to Crowdin, Phrase, or Lokalise with its very own revolutionary integrations. | ||
- Configure the top-level `parserOptions` property like this: | ||
![test workflow](https://github.com/tolgee/tolgee-js/actions/workflows/test.yml/badge.svg) | ||
```js | ||
export default { | ||
// other rules... | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
project: ['./tsconfig.json', './tsconfig.node.json'], | ||
tsconfigRootDir: __dirname, | ||
}, | ||
} | ||
![@tolgee/web version](https://img.shields.io/npm/v/@tolgee/web?label=@tolgee/web) | ||
![types typescript](https://img.shields.io/badge/Types-Typescript-blue) | ||
![typescript](https://img.shields.io/github/languages/top/tolgee/tolgee-js) | ||
![licence](https://img.shields.io/github/license/tolgee/tolgee-js) | ||
[![github stars](https://img.shields.io/github/stars/tolgee/tolgee-js?style=social&label=Tolgee%20JS)](https://github.com/tolgee/tolgee-js) | ||
[![github stars](https://img.shields.io/github/stars/tolgee/server?style=social&label=Tolgee%20Server)](https://github.com/tolgee/server) | ||
[![Github discussions](https://img.shields.io/github/discussions/tolgee/tolgee-platform)](https://github.com/tolgee/tolgee-platform/discussions) | ||
</div> | ||
<div align="center"> | ||
[<img src="https://img.shields.io/badge/-Facebook-424549?style=social&logo=facebook" height=25 />](https://www.facebook.com/Tolgee.i18n) | ||
[<img src="https://img.shields.io/badge/-Twitter-424549?style=social&logo=twitter" height=25 />](https://twitter.com/Tolgee_i18n) | ||
[<img src="https://img.shields.io/badge/-Linkedin-424549?style=social&logo=linkedin" height=25 />](https://www.linkedin.com/company/tolgee) | ||
**Become part of the family. Join [slack channel <img src="https://img.shields.io/badge/-Tolgee Comunity-424549?style=social&logo=slack" height=25 />](https://join.slack.com/t/tolgeecommunity/shared_invite/zt-195isb5u8-_RcSRgVJfvgsPpOBIok~IQ)** | ||
</div> | ||
## What is Tolgee JS Web? | ||
It's the core library of Tolgee JS integrations containing the parts supporting the web platform. | ||
For more information about Tolgee JS integrations, visit the [docs](https://tolgee.io/js-sdk/5.0.0-alpha.1/). | ||
## Quick links | ||
- [Tolgee JS SDK docs](https://tolgee.io/js-sdk) | ||
- [Tolgee Website](https://tolgee.io) | ||
- Product (Learn more about the great features) | ||
- [Dev tools](https://tolgee.io/features/dev-tools) | ||
- [Translation assistance](https://tolgee.io/features/translation-assistance) | ||
- [Collaboration](https://tolgee.io/features/collaboration) | ||
- Integrations (Learn how to integrate Tolgee with your favorite technology) | ||
- [React](https://tolgee.io/integrations/react) | ||
- [Angular](https://tolgee.io/integrations/angular) | ||
- [Vue](https://tolgee.io/integrations/vue) | ||
- [Svelte](https://tolgee.io/integrations/svelte) | ||
- [Next.js](https://tolgee.io/integrations/next) | ||
- [More...](https://tolgee.io/integrations/all) | ||
- [Tolgee platform docs](https://tolgee.io/platform) | ||
## Installation | ||
``` | ||
npm install @tolgee/web | ||
``` | ||
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` | ||
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` | ||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list | ||
## Usage | ||
First, create a Tolgee instance and run it. | ||
```ts | ||
import { Tolgee, DevTools, FormatSimple } from "@tolgee/web"; | ||
const tg = Tolgee() | ||
.use(DevTools()) | ||
.use(FormatSimple()) | ||
.init({ | ||
apiKey: "your_api_key", | ||
apiUrl: "https://app.tolgee.io", | ||
}) | ||
tg.run(); | ||
``` | ||
Then, use it to translate your strings. | ||
```ts | ||
tg.onLangLoaded.subscribe(() => { | ||
document.title = tg.translate("hello_world"); | ||
}); | ||
``` | ||
## Why to use Tolgee? | ||
Because it saves a lot of time, you would spend on localization tasks without it. Because it enables you to provide perfectly translated software. | ||
### Features | ||
- All-in-one localization solution for your JS application 🙌 | ||
- Out-of-box in-context localization 🎉 | ||
- Automated screenshot generation 📷 | ||
- Translation management platform 🎈 | ||
- Open-source 🔥 | ||
![Frame 47](https://user-images.githubusercontent.com/18496315/188637819-ac4eb02d-7859-4ca8-9807-27818a52782d.png) | ||
Read more on the [Tolgee website](https://tolgee.io) | ||
## Development | ||
We welcome your PRs. | ||
To develop the package locally: | ||
1. Clone [the repository](https://github.com/tolgee/tolgee-js) | ||
1. Install the packages in the repository root | ||
``` | ||
pnpm install | ||
``` | ||
1. Run web or any integration development script | ||
``` | ||
pnpm develop:react | ||
``` | ||
or | ||
``` | ||
pnpm develop:web | ||
``` | ||
This runs the development suite of this monorepo for the specific integration. The changes in each dependency package are | ||
automatically built and propagated to the test application, which you can open and play within the browser. | ||
### Testing | ||
To run Jest tests of this package, execute | ||
``` | ||
npm run test | ||
``` | ||
In the `/packages/core` directory. | ||
### End-to-end (e2e) testing | ||
Each integration is end-to-end tested via cypress. The tests are defined in `/e2e/cypress/e2e` directory. | ||
To run the e2e tests, simply run the following: | ||
``` | ||
pnpm run e2e run <integration> | ||
``` | ||
E.g. | ||
``` | ||
pnpm run e2e run web | ||
``` | ||
To open and play with e2e tests, run: | ||
``` | ||
pnpm run e2e open <integration> | ||
``` | ||
## Contributors | ||
<a href="https://github.com/tolgee/tolgee-platform/graphs/contributors"> | ||
<img alt="contributors" src="https://contrib.rocks/image?repo=tolgee/tolgee-js"/> | ||
</a> | ||
@@ -5,9 +5,13 @@ import { TolgeeEvent, TolgeeInstance } from '@tolgee/core'; | ||
const tolgee = Tolgee() | ||
export const secrets = { | ||
apiUrl: import.meta.env.VITE_APP_TOLGEE_API_URL, | ||
apiKey: import.meta.env.VITE_APP_TOLGEE_API_KEY, | ||
}; | ||
export const tolgee = Tolgee() | ||
.use(DevTools()) | ||
.use(BackendFetch()) | ||
.init({ | ||
...secrets, | ||
availableLanguages: ['en', 'cs', 'fr', 'de'], | ||
apiUrl: import.meta.env.VITE_APP_TOLGEE_API_URL, | ||
apiKey: import.meta.env.VITE_APP_TOLGEE_API_KEY, | ||
defaultLanguage: 'en', | ||
@@ -14,0 +18,0 @@ }); |
import { TolgeePlugin, UiMiddleware } from '@tolgee/core'; | ||
import { isSSR } from './tools/isSSR'; | ||
import { UI } from './ui/index'; | ||
import { InContextUi } from './ui/InContextUi'; | ||
@@ -9,3 +9,3 @@ export const ContextUi = (): TolgeePlugin => (tolgee, tools) => { | ||
if (!isSSR()) { | ||
ui = (props) => new UI(props); | ||
ui = (props) => InContextUi(props); | ||
} | ||
@@ -12,0 +12,0 @@ tools.setUi(ui); |
@@ -28,6 +28,6 @@ import { NsFallback, getFallback, ObserverOptionsInternal } from '@tolgee/core'; | ||
elementStore, | ||
onClick(event, el) { | ||
onClick(el) { | ||
const meta = elementStore.get(el)!; | ||
onClick({ | ||
event, | ||
target: el as HTMLElement, | ||
keysAndDefaults: getKeysAndDefaults(meta), | ||
@@ -34,0 +34,0 @@ }); |
@@ -23,3 +23,3 @@ import { ModifierKey, ObserverOptionsInternal } from '@tolgee/core'; | ||
elementStore: ElementStoreType; | ||
onClick: (event: MouseEvent, el: TolgeeElement) => void; | ||
onClick: (el: TolgeeElement) => void; | ||
options: ObserverOptionsInternal; | ||
@@ -140,3 +140,3 @@ }; | ||
if (areKeysDown() && highlighted) { | ||
onClick(e, highlighted); | ||
onClick(highlighted); | ||
unhighlight(); | ||
@@ -143,0 +143,0 @@ } |
import '@testing-library/jest-dom'; | ||
import { getRootElement } from '../getRootElement'; | ||
import { UI } from '../index'; | ||
import { InContextUi } from '../InContextUi'; | ||
import { sleep } from '../tools/sleep'; | ||
@@ -15,3 +15,3 @@ | ||
test('it selects the key', async () => { | ||
const ui = new UI({ | ||
const ui = InContextUi({ | ||
apiKey: 'test', | ||
@@ -25,9 +25,3 @@ apiUrl: 'test', | ||
}); | ||
const mouseEvent = new MouseEvent('click'); | ||
Object.defineProperty(mouseEvent, 'target', { | ||
writable: false, | ||
value: document.body, | ||
}); | ||
const keys = new Map([ | ||
@@ -38,3 +32,3 @@ ['key 1', 'Key 1'], | ||
// open context menu and wait for select | ||
const resultPromise = ui.getKey({ openEvent: mouseEvent, keys: keys }); | ||
const resultPromise = ui.getKey({ target: document.body, keys: keys }); | ||
@@ -41,0 +35,0 @@ await sleep(10); |
@@ -42,3 +42,2 @@ import { useEffect, useMemo, useState } from 'react'; | ||
defaultValue: string; | ||
open: boolean; | ||
onClose: () => void; | ||
@@ -409,3 +408,4 @@ uiProps: UiProps; | ||
selectedLanguages && | ||
translationsForm | ||
translationsForm && | ||
keyData | ||
) { | ||
@@ -421,6 +421,3 @@ const baseLanguageDefinition = availableLanguages.find((l) => l.base); | ||
if ( | ||
!translationsForm[baseLanguageDefinition.tag!] && | ||
!wasBaseTranslationProvided | ||
) { | ||
if (!wasBaseTranslationProvided) { | ||
setTranslation( | ||
@@ -442,2 +439,3 @@ baseLanguageDefinition.tag!, | ||
props.defaultValue, | ||
keyData, | ||
]); | ||
@@ -468,3 +466,2 @@ | ||
input: props.keyName, | ||
open: props.open, | ||
fallbackNamespaces: props.fallbackNamespaces, | ||
@@ -471,0 +468,0 @@ selectedNs, |
@@ -10,3 +10,2 @@ { | ||
"require": "./../dist/tolgee-in-context-tools.umd.cjs", | ||
"module": "./../dist/tolgee-in-context-tools.umd.cjs", | ||
"types": "./../types/tools.d.ts" | ||
@@ -13,0 +12,0 @@ }, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
44086401
259966
0
178
2
250
12
+ Added@tolgee/core@5.23.0(transitive)
- Removed@tolgee/core@5.22.1-prerelease.d00c62d8.0(transitive)
Updated@tolgee/core@5.23.0