@tolgee/web
Advanced tools
Comparing version 4.10.0-rc.d26e1ca.0 to 4.10.0-rc.d9fac95.0
@@ -1,2 +0,2 @@ | ||
!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/invisible-observer"]={})}(this,(function(e){"use strict";var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)};function n(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function r(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function i(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function a(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}const u="data-tolgee-restricted",l="_tolgee",c="data-tolgee-key-only",f="__tolgee_dev_tools";function s(e,t){return{oldTextContent:e,keys:t}}var d={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"},v=function(e){var t=e.highlightColor,n=e.highlightWidth;return Object.freeze({initHighlighter:function(e,r){!function(e,r){r.highlight=function(){if(e.isConnected){var i=r.highlightEl;i||((i=document.createElement("div")).classList.add("_tolgee-highlighter"),Object.entries(d).forEach((function(e){var t=o(e,2),n=t[0],r=t[1];i.style[n]=r})),i.style.borderColor=t,r.highlightEl=i,document.body.appendChild(i));var a=e.getBoundingClientRect();i.style.borderWidth=n+"px",i.style.top=a.top-n+"px",i.style.left=a.left-n+"px",i.style.width=a.width+"px",i.style.height=a.height+"px"}}}(e,r),function(e,t){t.unhighlight=function(){var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,r)}})};function h(e,t){for(var n,r,o=null===document||void 0===document?void 0:document.evaluate(e,t,void 0,XPathResult.ANY_TYPE),i=[];r=null===(n=null==o?void 0:o.iterateNext)||void 0===n?void 0:n.call(o);)i.push(r);return i}function y(e){return e.textContent}function g(e,t){e.textContent=t}var p=function(e,t){var n,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?void 0:n.findIndex((function(e){var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return r&&o},m={capture:!0},w={capture:!0,passive:!0},b=function(e){var t,n,o=e.highlightKeys,i=e.elementStore,a=e.onClick,u=new Set,l=function(){var e,n=i.get(t);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),t=void 0)};function c(){var e,r=n;if(r&&x()){var o=document.elementFromPoint(r.x,r.y);o&&(e=b(o))}!function(e){var n;if(t!==e){l();var r=i.get(e);r&&(r.preventClean=!0,null===(n=r.highlight)||void 0===n||n.call(r),t=e)}}(e)}var s=function(e){var t;x()&&(t=e.target,!Boolean(E(t,(function(e){return e.id===f}))))&&(e.stopPropagation(),e.preventDefault())},d=function(e){var t;t={x:e.clientX,y:e.clientY},n=t,c()},v=function(){u=new Set,c()},h=function(e){var t=e.key;void 0!==t&&u.add(t),c()},y=function(e){u.delete(e.key),c()},g=function(){var e,n=i.get(t);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)},p=function(e){if(s(e),x()){var n=b(e.target);n&&n===t&&(a(e,n),l())}};function b(e){return E(e,(function(e){return i.get(e)}))}function E(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?E(e.parentElement,t):void 0}function x(){var e,t;try{for(var n=r(o),i=n.next();!i.done;i=n.next()){var a=i.value;if(!u.has(a))return!1}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return!0}return Object.freeze({run:function(){window.addEventListener("blur",v,m),window.addEventListener("keydown",h,m),window.addEventListener("keyup",y,m),window.addEventListener("mousemove",d,w),window.addEventListener("scroll",g,w),window.addEventListener("click",p,m),window.addEventListener("mouseenter",s,m),window.addEventListener("mouseover",s,m),window.addEventListener("mouseout",s,m),window.addEventListener("mouseleave",s,m),window.addEventListener("mousedown",s,m),window.addEventListener("mouseup",s,m)},stop:function(){window.removeEventListener("blur",v,m),window.removeEventListener("keydown",h,m),window.removeEventListener("keyup",y,m),window.removeEventListener("mousemove",d,w),window.removeEventListener("scroll",g,w),window.removeEventListener("click",p,m),window.removeEventListener("mouseenter",s,m),window.removeEventListener("mouseover",s,m),window.removeEventListener("mouseout",s,m),window.removeEventListener("mouseleave",s,m),window.removeEventListener("mousedown",s,m),window.removeEventListener("mouseup",s,m)}})},E=function(e,t){var c,f=(c=new Map,Object.freeze({set:function(e,t){c.set(e,t)},get:function(e){return e&&c.get(e)},remove:function(e){return c.delete(e)},forEachElement:function(e){c.forEach((function(t,n){return e(n,t)}))}})),s=v({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),d=b({highlightKeys:e.highlightKeys,elementStore:f,onClick:function(e,n){var r=f.get(n);t(e,{el:n,meta:r,keysAndDefaults:h(r)})}});function h(e){return function(e){return Array.from(e.nodes.values()).reduce((function(e,t){return i(i([],o(e),!1),o(t.keys.map((function(e){return{key:e.key,defaultValue:e.defaultValue,ns:e.ns}}))),!1)}),[])}(e)}return Object.freeze({register:function(t,n,r){if(!function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest("[".concat(u,"]"))}(t)){var o=t,i=f.get(o);i||(i={nodes:new Map},f.set(o,i),o.setAttribute(l,"true")),i.nodes.set(n,r),s.initHighlighter(o,i)}},forEachElement:f.forEachElement,findAll:function(e,t){var n=[];return f.forEachElement((function(o,i){var u,l;try{for(var c=r(i.nodes.values()),f=c.next();!f.done;f=c.next()){if(f.value.keys.find((function(n){return p({key:e,ns:a(t)},{key:n.key,ns:a(n.ns)})}))){n.push(i);break}}}catch(e){u={error:e}}finally{try{f&&!f.done&&(l=c.return)&&l.call(c)}finally{if(u)throw u.error}}})),n},refreshAll:function(){f.forEachElement((function(t,i){i.preventClean||(function(t){t.nodes=new Map(function(t){var i,a,u,l,c,f,s,d;return n(this,(function(n){switch(n.label){case 0:n.trys.push([0,5,6,7]),i=r(t.nodes.entries()),a=i.next(),n.label=1;case 1:return a.done?[3,4]:(u=o(a.value,2),l=u[0],c=u[1],function(e,t){if(e.contains(t))return!0;if(t instanceof Attr){var n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}(e.targetElement||document.body,l)?[4,[l,c]]:[3,3]);case 2:n.sent(),n.label=3;case 3:return a=i.next(),[3,1];case 4:return[3,7];case 5:return f=n.sent(),s={error:f},[3,7];case 6:try{a&&!a.done&&(d=i.return)&&d.call(i)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}(t))}(i),0===i.nodes.size&&function(e,t){var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||n.call(t));e.removeAttribute(l),f.remove(e)}(t,i))}))},run:function(e){e&&d.run()},stop:function(){d.stop()}})},x=function(e,t,n){var a=!1,u=function(e){return Object.freeze({getSuitableParent:function t(n){var 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.");return e.passToParent?Array.isArray(e.passToParent)&&-1===e.passToParent.findIndex((function(e){return r.tagName.toLowerCase()===e.toLowerCase()}))?r:"function"!=typeof e.passToParent||e.passToParent(r)?t(r):r:r}})}(t),l=function(e,t){var n=function(e){return h(t.getTextXPath(),e)},a=function(n){var a,u,l,c,f=[];try{for(var s=r(Object.entries(e.tagAttributes)),d=s.next();!d.done;d=s.next()){var v=o(d.value,2),y=v[0],g=v[1];try{for(var p=(l=void 0,r(g)),m=p.next();!m.done;m=p.next()){var w=m.value,b=h(t.getAttributeXPath({tag:y,attribute:w}),n);f=i(i([],o(f),!1),o(b),!1)}}catch(e){l={error:e}}finally{try{m&&!m.done&&(c=p.return)&&c.call(p)}finally{if(l)throw l.error}}}}catch(e){a={error:e}}finally{try{d&&!d.done&&(u=s.return)&&u.call(s)}finally{if(a)throw a.error}}return f};return Object.freeze({handleAttributes:a,handleChildList:function(e){var t=[];return(t=t.concat(a(e))).concat(n(e))},handleText:n})}(t,e),f=E(t,n);function d(t){var n,o;try{for(var i=r(t),a=i.next();!a.done;a=i.next()){var l=a.value,c=y(l),d=c?e.unwrap(c):null;if(d){var v=d.text,h=d.keys;g(l,v);var p=s(c,h),m=u.getSuitableParent(l);f.register(m,l,p)}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}}var v,p=function(e){h("./descendant-or-self::*[@".concat(c,"]"),e).forEach((function(e){var t=e.getAttributeNode(c),n=u.getSuitableParent(t);f.register(n,t,{oldTextContent:"",keys:[{key:y(t)}],keyAttributeOnly:!0})}))};return Object.freeze({run:function(e){var n=e.mouseHighlight;v||(v=new MutationObserver((function(e){var t,n;if(a)try{for(var o=r(e),i=o.next();!i.done;i=o.next()){var u=i.value,c=[];switch(u.type){case"characterData":c=l.handleText(u.target);break;case"childList":p(u.target),c=l.handleChildList(u.target);break;case"attributes":p(u.target),c=l.handleAttributes(u.target)}d(c),f.refreshAll()}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}})));var o=t.targetElement||document.body;a=!0,f.run(n),p(o),d(l.handleChildList(o)),v.observe(t.targetElement||document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0})},stop:function(){a=!1,f.stop(),v.disconnect()},wrap:e.wrap,unwrap:e.unwrap,forEachElement:f.forEachElement,highlight:function(e,t){var n=f.findAll(e,t);return n.forEach((function(e){var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight:function(){n.forEach((function(e){var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}}})};function k(){}function L(){}k.prototype.encode=function(e){for(var t=[],n=e.length,r=0;r<n;){var o=e.codePointAt(r),i=0,a=0;for(o<=127?(i=0,a=0):o<=2047?(i=6,a=192):o<=65535?(i=12,a=224):o<=2097151&&(i=18,a=240),t.push(a|o>>i),i-=6;i>=0;)t.push(128|o>>i&63),i-=6;r+=o>=65536?2:1}return t},L.prototype.decode=function(e){for(var t="",n=0;n<e.length;){var r=e[n],o=0,i=0;if(r<=127?(o=0,i=255&r):r<=223?(o=1,i=31&r):r<=239?(o=2,i=15&r):r<=244&&(o=3,i=7&r),e.length-n-o>0)for(var a=0;a<o;)i=i<<6|63&(r=e[n+a+1]),a+=1;else i=65533,o=e.length-n;t+=String.fromCodePoint(i),n+=o+1}return t};var A="undefined"==typeof TextEncoder?k:TextEncoder,O="undefined"==typeof TextDecoder?L:TextDecoder,C=["",""],T=RegExp("([".concat(C.join(""),"]{9})+"),"gu"),S=function(e){var t=function(e){return Array.from((new A).encode(e))}(e).map(Number),n=t.map((function(e){return function(e){var t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0"})).join("");return Array.from(n).map((function(e){return C[Number(e)]})).join("")},P=function(e){var t,n=Array.from(e).map((function(e){return C.indexOf(e)})).map(String).join("").match(/(.{9})/g),r=Uint8Array.from((null==n?void 0:n.map((function(e){return parseInt(e.slice(0,8),2)})))||[]);return t=r,(new O).decode(new Uint8Array(t))},j=function(){var e,t=(e=[],Object.freeze({valueToNumber:function(t){var n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:function(t){return e[t]}})),n=function(e){return JSON.parse(e)};return Object.freeze({unwrap:function(e){var i=[],a=function(e){var t,n=null===(t=e.match(T))||void 0===t?void 0:t.filter((function(e){return e.length>8}));return(null==n?void 0:n.map(P))||[]}(e);a.forEach((function(e){var a=o(function(e){var t,n,o=[];try{for(var i=r(e),a=i.next();!a.done;a=i.next()){var u=a.value;o.push(u.codePointAt(0))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return o}(e),1),u=a[0],l=t.numberToValue(u),c=n(l),f=c.k,s=c.d,d=c.n;i.push({key:f,defaultValue:s,ns:d})}));var u=function(e){return e.replace(T,"")}(e);return{text:u,keys:i}},wrap:function(e){var n=e.key,r=e.defaultValue,o=e.translation,i=function(e){var t={k:e.key,n:e.ns,d:e.defaultValue};return JSON.stringify(t)}({key:n,ns:e.ns,defaultValue:r}),a=t.valueToNumber(i),u=o||"",l=S(String.fromCodePoint(a));return"string"==typeof u?u+l:u},getTextXPath:function(){return"./descendant-or-self::text()[contains(., '".concat(C[0]).concat(C[0],"') or contains(., '").concat(C[1]).concat(C[0],"')]")},getAttributeXPath:function(e){var t=e.tag,n=e.attribute;return"descendant-or-self::".concat(t,"/@").concat(n,"[contains(., '").concat(C[0]).concat(C[0],"') or contains(., '").concat(C[1]).concat(C[0],"')]")}})};e.InvisibleObserver=function(){return function(e,n){return n.setObserver((function(e){var n=e.onClick,r=e.options,o=j(),i=x(o,r,n);return t(t({},i),{retranslate:function(){},outputNotFormattable:!1})})),e}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!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/invisible-observer"]={})}(this,(function(e){"use strict";var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)};function n(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function r(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function i(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function a(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}const u="data-tolgee-restricted",l="_tolgee",c="data-tolgee-key-only";function f(e,t){return{oldTextContent:e,keys:t}}var s={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"},d=function(e){var t=e.highlightColor,n=e.highlightWidth;return Object.freeze({initHighlighter:function(e,r){!function(e,r){r.highlight=function(){if(e.isConnected){var i=r.highlightEl;i||((i=document.createElement("div")).classList.add("_tolgee-highlighter"),Object.entries(s).forEach((function(e){var t=o(e,2),n=t[0],r=t[1];i.style[n]=r})),i.style.borderColor=t,r.highlightEl=i,document.body.appendChild(i));var a=e.getBoundingClientRect();i.style.borderWidth=n+"px",i.style.top=a.top-n+"px",i.style.left=a.left-n+"px",i.style.width=a.width+"px",i.style.height=a.height+"px"}}}(e,r),function(e,t){t.unhighlight=function(){var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,r)}})};function v(e,t){for(var n,r,o=null===document||void 0===document?void 0:document.evaluate(e,t,void 0,XPathResult.ANY_TYPE),i=[];r=null===(n=null==o?void 0:o.iterateNext)||void 0===n?void 0:n.call(o);)i.push(r);return i}function h(e){return e.textContent}function y(e,t){e.textContent=t}var g=function(e,t){var n,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?void 0:n.findIndex((function(e){var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return r&&o},p="__tolgee_dev_tools",m={capture:!0},w={capture:!0,passive:!0},b=function(e){var t,n,o=e.highlightKeys,i=e.elementStore,a=e.onClick,u=new Set,l=function(){var e,n=i.get(t);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),t=void 0)};function c(){var e,r=n;if(r&&x()){var o=document.elementFromPoint(r.x,r.y);o&&(e=b(o))}!function(e){var n;if(t!==e){l();var r=i.get(e);r&&(r.preventClean=!0,null===(n=r.highlight)||void 0===n||n.call(r),t=e)}}(e)}var f=function(e){var t;x()&&(t=e.target,!Boolean(E(t,(function(e){return e.id===p}))))&&(e.stopPropagation(),e.preventDefault())},s=function(e){var t;t={x:e.clientX,y:e.clientY},n=t,c()},d=function(){u=new Set,c()},v=function(e){var t=e.key;void 0!==t&&u.add(t),c()},h=function(e){u.delete(e.key),c()},y=function(){var e,n=i.get(t);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)},g=function(e){if(f(e),x()){var n=b(e.target);n&&n===t&&(a(e,n),l())}};function b(e){return E(e,(function(e){return i.get(e)}))}function E(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?E(e.parentElement,t):void 0}function x(){var e,t;try{for(var n=r(o),i=n.next();!i.done;i=n.next()){var a=i.value;if(!u.has(a))return!1}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return!0}return Object.freeze({run:function(){window.addEventListener("blur",d,m),window.addEventListener("keydown",v,m),window.addEventListener("keyup",h,m),window.addEventListener("mousemove",s,w),window.addEventListener("scroll",y,w),window.addEventListener("click",g,m),window.addEventListener("mouseenter",f,m),window.addEventListener("mouseover",f,m),window.addEventListener("mouseout",f,m),window.addEventListener("mouseleave",f,m),window.addEventListener("mousedown",f,m),window.addEventListener("mouseup",f,m)},stop:function(){window.removeEventListener("blur",d,m),window.removeEventListener("keydown",v,m),window.removeEventListener("keyup",h,m),window.removeEventListener("mousemove",s,w),window.removeEventListener("scroll",y,w),window.removeEventListener("click",g,m),window.removeEventListener("mouseenter",f,m),window.removeEventListener("mouseover",f,m),window.removeEventListener("mouseout",f,m),window.removeEventListener("mouseleave",f,m),window.removeEventListener("mousedown",f,m),window.removeEventListener("mouseup",f,m)}})},E=function(e,t){var c,f=(c=new Map,Object.freeze({set:function(e,t){c.set(e,t)},get:function(e){return e&&c.get(e)},remove:function(e){return c.delete(e)},forEachElement:function(e){c.forEach((function(t,n){return e(n,t)}))}})),s=d({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),v=b({highlightKeys:e.highlightKeys,elementStore:f,onClick:function(e,n){var r=f.get(n);t(e,{el:n,meta:r,keysAndDefaults:h(r)})}});function h(e){return function(e){return Array.from(e.nodes.values()).reduce((function(e,t){return i(i([],o(e),!1),o(t.keys.map((function(e){return{key:e.key,defaultValue:e.defaultValue,ns:e.ns}}))),!1)}),[])}(e)}return Object.freeze({register:function(t,n,r){if(!function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest("[".concat(u,"]"))}(t)){var o=t,i=f.get(o);i||(i={nodes:new Map},f.set(o,i),o.setAttribute(l,"true")),i.nodes.set(n,r),s.initHighlighter(o,i)}},forEachElement:f.forEachElement,findAll:function(e,t){var n=[];return f.forEachElement((function(o,i){var u,l;try{for(var c=r(i.nodes.values()),f=c.next();!f.done;f=c.next()){if(f.value.keys.find((function(n){return g({key:e,ns:a(t)},{key:n.key,ns:a(n.ns)})}))){n.push(i);break}}}catch(e){u={error:e}}finally{try{f&&!f.done&&(l=c.return)&&l.call(c)}finally{if(u)throw u.error}}})),n},refreshAll:function(){f.forEachElement((function(t,i){i.preventClean||(function(t){t.nodes=new Map(function(t){var i,a,u,l,c,f,s,d;return n(this,(function(n){switch(n.label){case 0:n.trys.push([0,5,6,7]),i=r(t.nodes.entries()),a=i.next(),n.label=1;case 1:return a.done?[3,4]:(u=o(a.value,2),l=u[0],c=u[1],function(e,t){if(e.contains(t))return!0;if(t instanceof Attr){var n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}(e.targetElement||document.body,l)?[4,[l,c]]:[3,3]);case 2:n.sent(),n.label=3;case 3:return a=i.next(),[3,1];case 4:return[3,7];case 5:return f=n.sent(),s={error:f},[3,7];case 6:try{a&&!a.done&&(d=i.return)&&d.call(i)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}(t))}(i),0===i.nodes.size&&function(e,t){var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||n.call(t));e.removeAttribute(l),f.remove(e)}(t,i))}))},run:function(e){e&&v.run()},stop:function(){v.stop()}})},x=function(e,t,n){var a=!1,u=function(e){return Object.freeze({getSuitableParent:function t(n){var 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.");return e.passToParent?Array.isArray(e.passToParent)&&-1===e.passToParent.findIndex((function(e){return r.tagName.toLowerCase()===e.toLowerCase()}))?r:"function"!=typeof e.passToParent||e.passToParent(r)?t(r):r:r}})}(t),l=function(e,t){var n=function(e){return v(t.getTextXPath(),e)},a=function(n){var a,u,l,c,f=[];try{for(var s=r(Object.entries(e.tagAttributes)),d=s.next();!d.done;d=s.next()){var h=o(d.value,2),y=h[0],g=h[1];try{for(var p=(l=void 0,r(g)),m=p.next();!m.done;m=p.next()){var w=m.value,b=v(t.getAttributeXPath({tag:y,attribute:w}),n);f=i(i([],o(f),!1),o(b),!1)}}catch(e){l={error:e}}finally{try{m&&!m.done&&(c=p.return)&&c.call(p)}finally{if(l)throw l.error}}}}catch(e){a={error:e}}finally{try{d&&!d.done&&(u=s.return)&&u.call(s)}finally{if(a)throw a.error}}return f};return Object.freeze({handleAttributes:a,handleChildList:function(e){var t=[];return(t=t.concat(a(e))).concat(n(e))},handleText:n})}(t,e),s=E(t,n);function d(t){var n,o;try{for(var i=r(t),a=i.next();!a.done;a=i.next()){var l=a.value,c=h(l),d=c?e.unwrap(c):null;if(d){var v=d.text,g=d.keys;y(l,v);var p=f(c,g),m=u.getSuitableParent(l);s.register(m,l,p)}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}}var g,p=function(e){v("./descendant-or-self::*[@".concat(c,"]"),e).forEach((function(e){var t=e.getAttributeNode(c),n=u.getSuitableParent(t);s.register(n,t,{oldTextContent:"",keys:[{key:h(t)}],keyAttributeOnly:!0})}))};return Object.freeze({run:function(e){var n=e.mouseHighlight;g||(g=new MutationObserver((function(e){var t,n;if(a)try{for(var o=r(e),i=o.next();!i.done;i=o.next()){var u=i.value,c=[];switch(u.type){case"characterData":c=l.handleText(u.target);break;case"childList":p(u.target),c=l.handleChildList(u.target);break;case"attributes":p(u.target),c=l.handleAttributes(u.target)}d(c),s.refreshAll()}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}})));var o=t.targetElement||document.body;a=!0,s.run(n),p(o),d(l.handleChildList(o)),g.observe(t.targetElement||document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0})},stop:function(){a=!1,s.stop(),g.disconnect()},wrap:e.wrap,unwrap:e.unwrap,forEachElement:s.forEachElement,highlight:function(e,t){var n=s.findAll(e,t);return n.forEach((function(e){var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight:function(){n.forEach((function(e){var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}}})};function k(){}function L(){}k.prototype.encode=function(e){for(var t=[],n=e.length,r=0;r<n;){var o=e.codePointAt(r),i=0,a=0;for(o<=127?(i=0,a=0):o<=2047?(i=6,a=192):o<=65535?(i=12,a=224):o<=2097151&&(i=18,a=240),t.push(a|o>>i),i-=6;i>=0;)t.push(128|o>>i&63),i-=6;r+=o>=65536?2:1}return t},L.prototype.decode=function(e){for(var t="",n=0;n<e.length;){var r=e[n],o=0,i=0;if(r<=127?(o=0,i=255&r):r<=223?(o=1,i=31&r):r<=239?(o=2,i=15&r):r<=244&&(o=3,i=7&r),e.length-n-o>0)for(var a=0;a<o;)i=i<<6|63&(r=e[n+a+1]),a+=1;else i=65533,o=e.length-n;t+=String.fromCodePoint(i),n+=o+1}return t};var A="undefined"==typeof TextEncoder?k:TextEncoder,O="undefined"==typeof TextDecoder?L:TextDecoder,C=["",""],T=RegExp("([".concat(C.join(""),"]{9})+"),"gu"),S=function(e){var t=function(e){return Array.from((new A).encode(e))}(e).map(Number),n=t.map((function(e){return function(e){var t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0"})).join("");return Array.from(n).map((function(e){return C[Number(e)]})).join("")},P=function(e){var t,n=Array.from(e).map((function(e){return C.indexOf(e)})).map(String).join("").match(/(.{9})/g),r=Uint8Array.from((null==n?void 0:n.map((function(e){return parseInt(e.slice(0,8),2)})))||[]);return t=r,(new O).decode(new Uint8Array(t))},j=function(){var e,t=(e=[],Object.freeze({valueToNumber:function(t){var n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:function(t){return e[t]}})),n=function(e){return JSON.parse(e)};return Object.freeze({unwrap:function(e){var i=[],a=function(e){var t,n=null===(t=e.match(T))||void 0===t?void 0:t.filter((function(e){return e.length>8}));return(null==n?void 0:n.map(P))||[]}(e);a.forEach((function(e){var a=o(function(e){var t,n,o=[];try{for(var i=r(e),a=i.next();!a.done;a=i.next()){var u=a.value;o.push(u.codePointAt(0))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return o}(e),1),u=a[0],l=t.numberToValue(u),c=n(l),f=c.k,s=c.d,d=c.n;i.push({key:f,defaultValue:s,ns:d})}));var u=function(e){return e.replace(T,"")}(e);return{text:u,keys:i}},wrap:function(e){var n=e.key,r=e.defaultValue,o=e.translation,i=function(e){var t={k:e.key,n:e.ns,d:e.defaultValue};return JSON.stringify(t)}({key:n,ns:e.ns,defaultValue:r}),a=t.valueToNumber(i),u=o||"",l=S(String.fromCodePoint(a));return"string"==typeof u?u+l:u},getTextXPath:function(){return"./descendant-or-self::text()[contains(., '".concat(C[0]).concat(C[0],"') or contains(., '").concat(C[1]).concat(C[0],"')]")},getAttributeXPath:function(e){var t=e.tag,n=e.attribute;return"descendant-or-self::".concat(t,"/@").concat(n,"[contains(., '").concat(C[0]).concat(C[0],"') or contains(., '").concat(C[1]).concat(C[0],"')]")}})};e.InvisibleObserver=function(){return function(e,n){return n.setObserver((function(e){var n=e.onClick,r=e.options,o=j(),i=x(o,r,n);return t(t({},i),{retranslate:function(){},outputNotFormattable:!1})})),e}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=tolgee-invisible-observer.umd.min.js.map |
@@ -1,2 +0,2 @@ | ||
!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/text-observer"]={})}(this,(function(e){"use strict";function t(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function n(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function r(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function o(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function i(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}const a="data-tolgee-restricted",u="_tolgee",l="data-tolgee-key-only",c="__tolgee_dev_tools";function f(e,t){return{oldTextContent:e,keys:t}}var s={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"},d=function(e){var t=e.highlightColor,n=e.highlightWidth;return Object.freeze({initHighlighter:function(e,o){!function(e,o){o.highlight=function(){if(e.isConnected){var i=o.highlightEl;i||((i=document.createElement("div")).classList.add("_tolgee-highlighter"),Object.entries(s).forEach((function(e){var t=r(e,2),n=t[0],o=t[1];i.style[n]=o})),i.style.borderColor=t,o.highlightEl=i,document.body.appendChild(i));var a=e.getBoundingClientRect();i.style.borderWidth=n+"px",i.style.top=a.top-n+"px",i.style.left=a.left-n+"px",i.style.width=a.width+"px",i.style.height=a.height+"px"}}}(e,o),function(e,t){t.unhighlight=function(){var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,o)}})};function v(e,t){for(var n,r,o=null===document||void 0===document?void 0:document.evaluate(e,t,void 0,XPathResult.ANY_TYPE),i=[];r=null===(n=null==o?void 0:o.iterateNext)||void 0===n?void 0:n.call(o);)i.push(r);return i}function h(e){return e.textContent}function y(e,t){e.textContent=t}var p=function(e,t){var n,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?void 0:n.findIndex((function(e){var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return r&&o},g={capture:!0},w={capture:!0,passive:!0},E=function(e){var t,r,o=e.highlightKeys,i=e.elementStore,a=e.onClick,u=new Set,l=function(){var e,n=i.get(t);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),t=void 0)};function f(){var e,n=r;if(n&&x()){var o=document.elementFromPoint(n.x,n.y);o&&(e=m(o))}!function(e){var n;if(t!==e){l();var r=i.get(e);r&&(r.preventClean=!0,null===(n=r.highlight)||void 0===n||n.call(r),t=e)}}(e)}var s=function(e){var t;x()&&(t=e.target,!Boolean(b(t,(function(e){return e.id===c}))))&&(e.stopPropagation(),e.preventDefault())},d=function(e){var t;t={x:e.clientX,y:e.clientY},r=t,f()},v=function(){u=new Set,f()},h=function(e){var t=e.key;void 0!==t&&u.add(t),f()},y=function(e){u.delete(e.key),f()},p=function(){var e,n=i.get(t);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)},E=function(e){if(s(e),x()){var n=m(e.target);n&&n===t&&(a(e,n),l())}};function m(e){return b(e,(function(e){return i.get(e)}))}function b(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?b(e.parentElement,t):void 0}function x(){var e,t;try{for(var r=n(o),i=r.next();!i.done;i=r.next()){var a=i.value;if(!u.has(a))return!1}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return!0}return Object.freeze({run:function(){window.addEventListener("blur",v,g),window.addEventListener("keydown",h,g),window.addEventListener("keyup",y,g),window.addEventListener("mousemove",d,w),window.addEventListener("scroll",p,w),window.addEventListener("click",E,g),window.addEventListener("mouseenter",s,g),window.addEventListener("mouseover",s,g),window.addEventListener("mouseout",s,g),window.addEventListener("mouseleave",s,g),window.addEventListener("mousedown",s,g),window.addEventListener("mouseup",s,g)},stop:function(){window.removeEventListener("blur",v,g),window.removeEventListener("keydown",h,g),window.removeEventListener("keyup",y,g),window.removeEventListener("mousemove",d,w),window.removeEventListener("scroll",p,w),window.removeEventListener("click",E,g),window.removeEventListener("mouseenter",s,g),window.removeEventListener("mouseover",s,g),window.removeEventListener("mouseout",s,g),window.removeEventListener("mouseleave",s,g),window.removeEventListener("mousedown",s,g),window.removeEventListener("mouseup",s,g)}})},m=function(e,l){var c,f=(c=new Map,Object.freeze({set:function(e,t){c.set(e,t)},get:function(e){return e&&c.get(e)},remove:function(e){return c.delete(e)},forEachElement:function(e){c.forEach((function(t,n){return e(n,t)}))}})),s=d({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),v=E({highlightKeys:e.highlightKeys,elementStore:f,onClick:function(e,t){var n=f.get(t);l(e,{el:t,meta:n,keysAndDefaults:h(n)})}});function h(e){return function(e){return Array.from(e.nodes.values()).reduce((function(e,t){return o(o([],r(e),!1),r(t.keys.map((function(e){return{key:e.key,defaultValue:e.defaultValue,ns:e.ns}}))),!1)}),[])}(e)}return Object.freeze({register:function(t,n,r){if(!function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest("[".concat(a,"]"))}(t)){var o=t,i=f.get(o);i||(i={nodes:new Map},f.set(o,i),o.setAttribute(u,"true")),i.nodes.set(n,r),s.initHighlighter(o,i)}},forEachElement:f.forEachElement,findAll:function(e,t){var r=[];return f.forEachElement((function(o,a){var u,l;try{for(var c=n(a.nodes.values()),f=c.next();!f.done;f=c.next()){if(f.value.keys.find((function(n){return p({key:e,ns:i(t)},{key:n.key,ns:i(n.ns)})}))){r.push(a);break}}}catch(e){u={error:e}}finally{try{f&&!f.done&&(l=c.return)&&l.call(c)}finally{if(u)throw u.error}}})),r},refreshAll:function(){f.forEachElement((function(o,i){i.preventClean||(function(o){o.nodes=new Map(function(o){var i,a,u,l,c,f,s,d;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),i=n(o.nodes.entries()),a=i.next(),t.label=1;case 1:return a.done?[3,4]:(u=r(a.value,2),l=u[0],c=u[1],function(e,t){if(e.contains(t))return!0;if(t instanceof Attr){var n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}(e.targetElement||document.body,l)?[4,[l,c]]:[3,3]);case 2:t.sent(),t.label=3;case 3:return a=i.next(),[3,1];case 4:return[3,7];case 5:return f=t.sent(),s={error:f},[3,7];case 6:try{a&&!a.done&&(d=i.return)&&d.call(i)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}(o))}(i),0===i.nodes.size&&function(e,t){var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||n.call(t));e.removeAttribute(u),f.remove(e)}(o,i))}))},run:function(e){e&&v.run()},stop:function(){v.stop()}})},b=function(e,t,i){var a=!1,u=function(e){return Object.freeze({getSuitableParent:function t(n){var 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.");return e.passToParent?Array.isArray(e.passToParent)&&-1===e.passToParent.findIndex((function(e){return r.tagName.toLowerCase()===e.toLowerCase()}))?r:"function"!=typeof e.passToParent||e.passToParent(r)?t(r):r:r}})}(t),c=function(e,t){var i=function(e){return v(t.getTextXPath(),e)},a=function(i){var a,u,l,c,f=[];try{for(var s=n(Object.entries(e.tagAttributes)),d=s.next();!d.done;d=s.next()){var h=r(d.value,2),y=h[0],p=h[1];try{for(var g=(l=void 0,n(p)),w=g.next();!w.done;w=g.next()){var E=w.value,m=v(t.getAttributeXPath({tag:y,attribute:E}),i);f=o(o([],r(f),!1),r(m),!1)}}catch(e){l={error:e}}finally{try{w&&!w.done&&(c=g.return)&&c.call(g)}finally{if(l)throw l.error}}}}catch(e){a={error:e}}finally{try{d&&!d.done&&(u=s.return)&&u.call(s)}finally{if(a)throw a.error}}return f};return Object.freeze({handleAttributes:a,handleChildList:function(e){var t=[];return(t=t.concat(a(e))).concat(i(e))},handleText:i})}(t,e),s=m(t,i);function d(t){var r,o;try{for(var i=n(t),a=i.next();!a.done;a=i.next()){var l=a.value,c=h(l),d=c?e.unwrap(c):null;if(d){var v=d.text,p=d.keys;y(l,v);var g=f(c,p),w=u.getSuitableParent(l);s.register(w,l,g)}}}catch(e){r={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}}var p,g=function(e){v("./descendant-or-self::*[@".concat(l,"]"),e).forEach((function(e){var t=e.getAttributeNode(l),n=u.getSuitableParent(t);s.register(n,t,{oldTextContent:"",keys:[{key:h(t)}],keyAttributeOnly:!0})}))};return Object.freeze({run:function(e){var r=e.mouseHighlight;p||(p=new MutationObserver((function(e){var t,r;if(a)try{for(var o=n(e),i=o.next();!i.done;i=o.next()){var u=i.value,l=[];switch(u.type){case"characterData":l=c.handleText(u.target);break;case"childList":g(u.target),l=c.handleChildList(u.target);break;case"attributes":g(u.target),l=c.handleAttributes(u.target)}d(l),s.refreshAll()}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}})));var o=t.targetElement||document.body;a=!0,s.run(r),g(o),d(c.handleChildList(o)),p.observe(t.targetElement||document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0})},stop:function(){a=!1,s.stop(),p.disconnect()},wrap:e.wrap,unwrap:e.unwrap,forEachElement:s.forEachElement,highlight:function(e,t){var n=s.findAll(e,t);return n.forEach((function(e){var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight:function(){n.forEach((function(e){var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}}})};function x(e,t){for(var n=0;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}var A=function(e){var t=e.inputPrefix,o=e.inputSuffix,i=e.translate;function a(e){var t=function(e){var t,r,o=!1,i="",a="",u="KEY",l={key:"",ns:void 0,params:{},defaultValue:void 0},c=function(e){l.ns||(l.ns=[]),l.ns.push(e)};try{for(var f=n(e),s=f.next();!s.done;s=f.next()){var d=s.value;"\\"!==d||o?o?(o=!1,i+=d):"KEY"!==u||","!==d?"KEY"!==u||"|"!==d?"NAMESPACE"!==u||"|"!==d?"NAMESPACE"!==u||","!==d?"KEY"!==u||":"!==d?"DEFAULT_VALUE"!==u||":"!==d?"PARAM_NAME"!==u||":"!==d?"PARAM_VALUE"!==u||","!==d?i+=d:(u="PARAM_NAME",l.params[a]=i,i=""):(u="PARAM_VALUE",a=i,i=""):(u="PARAM_NAME",l.defaultValue=i,i=""):(u="PARAM_NAME",l.key=i,i=""):(u="DEFAULT_VALUE",c(i),i=""):(u="NAMESPACE",c(i),i=""):(u="NAMESPACE",l.key=i,i=""):(u="DEFAULT_VALUE",l.key=i,i=""):o=!0}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=f.return)&&r.call(f)}finally{if(t)throw t.error}}return"KEY"===u&&(l.key=i),"DEFAULT_VALUE"===u&&(l.defaultValue=i),"PARAM_VALUE"===u&&(l.params[a]=i),"NAMESPACE"===u&&c(i),l}(e),r=t.key,o=t.params,a=t.defaultValue,u=t.ns;return{translated:i({key:r,params:o,defaultValue:a,ns:u,noWrap:!0}),key:r,params:o,defaultValue:a}}var u=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},l=function(e){return"string"==typeof e?e.replace(/[,:|\\]/gs,"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn('Parameters of type "'.concat(typeof e,'" are not supported in "text" wrapper mode.')),e)};return Object.freeze({wrap:function(e){var n=e.key,i=e.params,a=e.defaultValue,u=e.ns,c=Object.entries(i||{}).map((function(e){var t=r(e,2),n=t[0],o=t[1];return"".concat(l(n),":").concat(l(o))})).join(",");c=c.length?":".concat(c):"";var f=void 0!==a?",".concat(l(a)):"",s="string"==typeof u?[u]:u,d=(null==s?void 0:s.length)?"|".concat(s.map((function(e){return l(e)})).join("|")):"";return"".concat(t).concat(l(n)).concat(d).concat(f).concat(c).concat(o)},unwrap:function(e){for(var n,i,l,c=new RegExp((n=u(t),i=u(o),"(\\\\?)(".concat(n,"(.*?)").concat(i,")")),"gs"),f=[],s=!1,d=0,v="";null!==(l=c.exec(e));){var h=l[1],y=r(l,4),p=y[0];y[1];var g=y[2],w=y[3],E=l.index;if(v+=l.input.substr(d,E-d),d=E+p.length,"\\"===h){if(!x(E,e)){v+=g;continue}h=""}var m=a(w);f.push({key:m.key,params:m.params,defaultValue:m.defaultValue}),s=!0,v+=h+m.translated}return v+=e.substring(d),s?{text:v,keys:f}:{text:e,keys:[]}},getTextXPath:function(){return"./descendant-or-self::text()[contains(., '".concat(t,"') and contains(., '").concat(o,"')]")},getAttributeXPath:function(e){var n=e.tag,r=e.attribute;return"descendant-or-self::".concat(n,"/@").concat(r,"[contains(., '").concat(t,"') and contains(., '").concat(o,"')]")}})};e.TextObserver=function(){return function(e,t){return t.setObserver((function(e){var t=e.translate,o=e.onClick,i=e.options,a=A({inputPrefix:i.inputPrefix,inputSuffix:i.inputSuffix,translate:t}),u=b(a,i,o),l=u.wrap,c=u.unwrap,f=u.stop,s=u.forEachElement,d=u.highlight;return{wrap:l,unwrap:c,stop:f,run:u.run,retranslate:function(){s((function(e,t){var o,i;try{for(var u=n(t.nodes.entries()),l=u.next();!l.done;l=u.next()){var c=r(l.value,2),f=c[0],s=c[1];if(s.keyAttributeOnly)return;var d=a.unwrap(s.oldTextContent);d&&y(f,d.text)}}catch(e){o={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(o)throw o.error}}}))},highlight:d,outputNotFormattable:!0}})),e}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!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/text-observer"]={})}(this,(function(e){"use strict";function t(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function n(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function r(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function o(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function i(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}const a="data-tolgee-restricted",u="_tolgee",l="data-tolgee-key-only";function c(e,t){return{oldTextContent:e,keys:t}}var f={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"},s=function(e){var t=e.highlightColor,n=e.highlightWidth;return Object.freeze({initHighlighter:function(e,o){!function(e,o){o.highlight=function(){if(e.isConnected){var i=o.highlightEl;i||((i=document.createElement("div")).classList.add("_tolgee-highlighter"),Object.entries(f).forEach((function(e){var t=r(e,2),n=t[0],o=t[1];i.style[n]=o})),i.style.borderColor=t,o.highlightEl=i,document.body.appendChild(i));var a=e.getBoundingClientRect();i.style.borderWidth=n+"px",i.style.top=a.top-n+"px",i.style.left=a.left-n+"px",i.style.width=a.width+"px",i.style.height=a.height+"px"}}}(e,o),function(e,t){t.unhighlight=function(){var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,o)}})};function d(e,t){for(var n,r,o=null===document||void 0===document?void 0:document.evaluate(e,t,void 0,XPathResult.ANY_TYPE),i=[];r=null===(n=null==o?void 0:o.iterateNext)||void 0===n?void 0:n.call(o);)i.push(r);return i}function v(e){return e.textContent}function h(e,t){e.textContent=t}var y=function(e,t){var n,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?void 0:n.findIndex((function(e){var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return r&&o},p="__tolgee_dev_tools",g={capture:!0},w={capture:!0,passive:!0},E=function(e){var t,r,o=e.highlightKeys,i=e.elementStore,a=e.onClick,u=new Set,l=function(){var e,n=i.get(t);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),t=void 0)};function c(){var e,n=r;if(n&&x()){var o=document.elementFromPoint(n.x,n.y);o&&(e=m(o))}!function(e){var n;if(t!==e){l();var r=i.get(e);r&&(r.preventClean=!0,null===(n=r.highlight)||void 0===n||n.call(r),t=e)}}(e)}var f=function(e){var t;x()&&(t=e.target,!Boolean(b(t,(function(e){return e.id===p}))))&&(e.stopPropagation(),e.preventDefault())},s=function(e){var t;t={x:e.clientX,y:e.clientY},r=t,c()},d=function(){u=new Set,c()},v=function(e){var t=e.key;void 0!==t&&u.add(t),c()},h=function(e){u.delete(e.key),c()},y=function(){var e,n=i.get(t);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)},E=function(e){if(f(e),x()){var n=m(e.target);n&&n===t&&(a(e,n),l())}};function m(e){return b(e,(function(e){return i.get(e)}))}function b(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?b(e.parentElement,t):void 0}function x(){var e,t;try{for(var r=n(o),i=r.next();!i.done;i=r.next()){var a=i.value;if(!u.has(a))return!1}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return!0}return Object.freeze({run:function(){window.addEventListener("blur",d,g),window.addEventListener("keydown",v,g),window.addEventListener("keyup",h,g),window.addEventListener("mousemove",s,w),window.addEventListener("scroll",y,w),window.addEventListener("click",E,g),window.addEventListener("mouseenter",f,g),window.addEventListener("mouseover",f,g),window.addEventListener("mouseout",f,g),window.addEventListener("mouseleave",f,g),window.addEventListener("mousedown",f,g),window.addEventListener("mouseup",f,g)},stop:function(){window.removeEventListener("blur",d,g),window.removeEventListener("keydown",v,g),window.removeEventListener("keyup",h,g),window.removeEventListener("mousemove",s,w),window.removeEventListener("scroll",y,w),window.removeEventListener("click",E,g),window.removeEventListener("mouseenter",f,g),window.removeEventListener("mouseover",f,g),window.removeEventListener("mouseout",f,g),window.removeEventListener("mouseleave",f,g),window.removeEventListener("mousedown",f,g),window.removeEventListener("mouseup",f,g)}})},m=function(e,l){var c,f=(c=new Map,Object.freeze({set:function(e,t){c.set(e,t)},get:function(e){return e&&c.get(e)},remove:function(e){return c.delete(e)},forEachElement:function(e){c.forEach((function(t,n){return e(n,t)}))}})),d=s({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),v=E({highlightKeys:e.highlightKeys,elementStore:f,onClick:function(e,t){var n=f.get(t);l(e,{el:t,meta:n,keysAndDefaults:h(n)})}});function h(e){return function(e){return Array.from(e.nodes.values()).reduce((function(e,t){return o(o([],r(e),!1),r(t.keys.map((function(e){return{key:e.key,defaultValue:e.defaultValue,ns:e.ns}}))),!1)}),[])}(e)}return Object.freeze({register:function(t,n,r){if(!function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest("[".concat(a,"]"))}(t)){var o=t,i=f.get(o);i||(i={nodes:new Map},f.set(o,i),o.setAttribute(u,"true")),i.nodes.set(n,r),d.initHighlighter(o,i)}},forEachElement:f.forEachElement,findAll:function(e,t){var r=[];return f.forEachElement((function(o,a){var u,l;try{for(var c=n(a.nodes.values()),f=c.next();!f.done;f=c.next()){if(f.value.keys.find((function(n){return y({key:e,ns:i(t)},{key:n.key,ns:i(n.ns)})}))){r.push(a);break}}}catch(e){u={error:e}}finally{try{f&&!f.done&&(l=c.return)&&l.call(c)}finally{if(u)throw u.error}}})),r},refreshAll:function(){f.forEachElement((function(o,i){i.preventClean||(function(o){o.nodes=new Map(function(o){var i,a,u,l,c,f,s,d;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),i=n(o.nodes.entries()),a=i.next(),t.label=1;case 1:return a.done?[3,4]:(u=r(a.value,2),l=u[0],c=u[1],function(e,t){if(e.contains(t))return!0;if(t instanceof Attr){var n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}(e.targetElement||document.body,l)?[4,[l,c]]:[3,3]);case 2:t.sent(),t.label=3;case 3:return a=i.next(),[3,1];case 4:return[3,7];case 5:return f=t.sent(),s={error:f},[3,7];case 6:try{a&&!a.done&&(d=i.return)&&d.call(i)}finally{if(s)throw s.error}return[7];case 7:return[2]}}))}(o))}(i),0===i.nodes.size&&function(e,t){var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||n.call(t));e.removeAttribute(u),f.remove(e)}(o,i))}))},run:function(e){e&&v.run()},stop:function(){v.stop()}})},b=function(e,t,i){var a=!1,u=function(e){return Object.freeze({getSuitableParent:function t(n){var 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.");return e.passToParent?Array.isArray(e.passToParent)&&-1===e.passToParent.findIndex((function(e){return r.tagName.toLowerCase()===e.toLowerCase()}))?r:"function"!=typeof e.passToParent||e.passToParent(r)?t(r):r:r}})}(t),f=function(e,t){var i=function(e){return d(t.getTextXPath(),e)},a=function(i){var a,u,l,c,f=[];try{for(var s=n(Object.entries(e.tagAttributes)),v=s.next();!v.done;v=s.next()){var h=r(v.value,2),y=h[0],p=h[1];try{for(var g=(l=void 0,n(p)),w=g.next();!w.done;w=g.next()){var E=w.value,m=d(t.getAttributeXPath({tag:y,attribute:E}),i);f=o(o([],r(f),!1),r(m),!1)}}catch(e){l={error:e}}finally{try{w&&!w.done&&(c=g.return)&&c.call(g)}finally{if(l)throw l.error}}}}catch(e){a={error:e}}finally{try{v&&!v.done&&(u=s.return)&&u.call(s)}finally{if(a)throw a.error}}return f};return Object.freeze({handleAttributes:a,handleChildList:function(e){var t=[];return(t=t.concat(a(e))).concat(i(e))},handleText:i})}(t,e),s=m(t,i);function y(t){var r,o;try{for(var i=n(t),a=i.next();!a.done;a=i.next()){var l=a.value,f=v(l),d=f?e.unwrap(f):null;if(d){var y=d.text,p=d.keys;h(l,y);var g=c(f,p),w=u.getSuitableParent(l);s.register(w,l,g)}}}catch(e){r={error:e}}finally{try{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}}var p,g=function(e){d("./descendant-or-self::*[@".concat(l,"]"),e).forEach((function(e){var t=e.getAttributeNode(l),n=u.getSuitableParent(t);s.register(n,t,{oldTextContent:"",keys:[{key:v(t)}],keyAttributeOnly:!0})}))};return Object.freeze({run:function(e){var r=e.mouseHighlight;p||(p=new MutationObserver((function(e){var t,r;if(a)try{for(var o=n(e),i=o.next();!i.done;i=o.next()){var u=i.value,l=[];switch(u.type){case"characterData":l=f.handleText(u.target);break;case"childList":g(u.target),l=f.handleChildList(u.target);break;case"attributes":g(u.target),l=f.handleAttributes(u.target)}y(l),s.refreshAll()}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}})));var o=t.targetElement||document.body;a=!0,s.run(r),g(o),y(f.handleChildList(o)),p.observe(t.targetElement||document.body,{attributes:!0,childList:!0,subtree:!0,characterData:!0})},stop:function(){a=!1,s.stop(),p.disconnect()},wrap:e.wrap,unwrap:e.unwrap,forEachElement:s.forEachElement,highlight:function(e,t){var n=s.findAll(e,t);return n.forEach((function(e){var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight:function(){n.forEach((function(e){var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}}})};function x(e,t){for(var n=0;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}var A=function(e){var t=e.inputPrefix,o=e.inputSuffix,i=e.translate;function a(e){var t=function(e){var t,r,o=!1,i="",a="",u="KEY",l={key:"",ns:void 0,params:{},defaultValue:void 0},c=function(e){l.ns||(l.ns=[]),l.ns.push(e)};try{for(var f=n(e),s=f.next();!s.done;s=f.next()){var d=s.value;"\\"!==d||o?o?(o=!1,i+=d):"KEY"!==u||","!==d?"KEY"!==u||"|"!==d?"NAMESPACE"!==u||"|"!==d?"NAMESPACE"!==u||","!==d?"KEY"!==u||":"!==d?"DEFAULT_VALUE"!==u||":"!==d?"PARAM_NAME"!==u||":"!==d?"PARAM_VALUE"!==u||","!==d?i+=d:(u="PARAM_NAME",l.params[a]=i,i=""):(u="PARAM_VALUE",a=i,i=""):(u="PARAM_NAME",l.defaultValue=i,i=""):(u="PARAM_NAME",l.key=i,i=""):(u="DEFAULT_VALUE",c(i),i=""):(u="NAMESPACE",c(i),i=""):(u="NAMESPACE",l.key=i,i=""):(u="DEFAULT_VALUE",l.key=i,i=""):o=!0}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=f.return)&&r.call(f)}finally{if(t)throw t.error}}return"KEY"===u&&(l.key=i),"DEFAULT_VALUE"===u&&(l.defaultValue=i),"PARAM_VALUE"===u&&(l.params[a]=i),"NAMESPACE"===u&&c(i),l}(e),r=t.key,o=t.params,a=t.defaultValue,u=t.ns;return{translated:i({key:r,params:o,defaultValue:a,ns:u,noWrap:!0}),key:r,params:o,defaultValue:a}}var u=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},l=function(e){return"string"==typeof e?e.replace(/[,:|\\]/gs,"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn('Parameters of type "'.concat(typeof e,'" are not supported in "text" wrapper mode.')),e)};return Object.freeze({wrap:function(e){var n=e.key,i=e.params,a=e.defaultValue,u=e.ns,c=Object.entries(i||{}).map((function(e){var t=r(e,2),n=t[0],o=t[1];return"".concat(l(n),":").concat(l(o))})).join(",");c=c.length?":".concat(c):"";var f=void 0!==a?",".concat(l(a)):"",s="string"==typeof u?[u]:u,d=(null==s?void 0:s.length)?"|".concat(s.map((function(e){return l(e)})).join("|")):"";return"".concat(t).concat(l(n)).concat(d).concat(f).concat(c).concat(o)},unwrap:function(e){for(var n,i,l,c=new RegExp((n=u(t),i=u(o),"(\\\\?)(".concat(n,"(.*?)").concat(i,")")),"gs"),f=[],s=!1,d=0,v="";null!==(l=c.exec(e));){var h=l[1],y=r(l,4),p=y[0];y[1];var g=y[2],w=y[3],E=l.index;if(v+=l.input.substr(d,E-d),d=E+p.length,"\\"===h){if(!x(E,e)){v+=g;continue}h=""}var m=a(w);f.push({key:m.key,params:m.params,defaultValue:m.defaultValue}),s=!0,v+=h+m.translated}return v+=e.substring(d),s?{text:v,keys:f}:{text:e,keys:[]}},getTextXPath:function(){return"./descendant-or-self::text()[contains(., '".concat(t,"') and contains(., '").concat(o,"')]")},getAttributeXPath:function(e){var n=e.tag,r=e.attribute;return"descendant-or-self::".concat(n,"/@").concat(r,"[contains(., '").concat(t,"') and contains(., '").concat(o,"')]")}})};e.TextObserver=function(){return function(e,t){return t.setObserver((function(e){var t=e.translate,o=e.onClick,i=e.options,a=A({inputPrefix:i.inputPrefix,inputSuffix:i.inputSuffix,translate:t}),u=b(a,i,o),l=u.wrap,c=u.unwrap,f=u.stop,s=u.forEachElement,d=u.highlight;return{wrap:l,unwrap:c,stop:f,run:u.run,retranslate:function(){s((function(e,t){var o,i;try{for(var u=n(t.nodes.entries()),l=u.next();!l.done;l=u.next()){var c=r(l.value,2),f=c[0],s=c[1];if(s.keyAttributeOnly)return;var d=a.unwrap(s.oldTextContent);d&&h(f,d.text)}}catch(e){o={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(o)throw o.error}}}))},highlight:d,outputNotFormattable:!0}})),e}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=tolgee-text-observer.umd.min.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=()=>{let e=[];return Object.freeze({listen:n=>{const t=e=>{n(e)};return e.push(t),{unsubscribe:()=>{e=e.filter((e=>t!==e))}}},emit:n=>{e.forEach((e=>e({value:n})))}})};function n(e){return function(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}(e)||[]}function t(e,t){return"object"!=typeof(a=t)||Array.isArray(a)||null===a?n(t):n(null==t?void 0:t[e]);var a}function a(e){return Array.from(new Set(e))}function i(e,n){const t=e.get(n)||0;e.set(n,t+1)}function o(e,n){let t=e.get(n)||1;t-=1,t<=0?e.delete(n):e.set(n,t)}const r=e=>{const t=new Set,a=new Set,r=n=>{if(n.has(void 0)){const t=new Set(n.keys());return t.delete(void 0),e().forEach((e=>t.add(e))),t}return n};let s=[];const c=()=>{if(0===s.length)return;t.forEach((e=>{e({value:void 0})}));const e=new Set;let n=new Set;s.forEach((t=>{void 0===(null==t?void 0:t.ns)?e.add(void 0):t.ns.forEach((n=>e.add(n))),void 0===(null==t?void 0:t.key)?n=void 0:void 0!==n&&n.add(t.key)}));const i=Array.from(r(e).keys());(n||[void 0]).forEach((e=>{((e,n)=>{a.forEach((t=>{const a=r(t.namespaces),i=void 0===n||-1!==(null==n?void 0:n.findIndex((e=>a.has(e)))),o=void 0===e||t.keys.has(e)||0===t.keys.size;i&&o&&t.fn({value:void 0})}))})(e,i)})),s=[]};return Object.freeze({listenSome:e=>{const t={fn:n=>{e(n)},keys:new Map,namespaces:new Map};a.add(t);const r={unsubscribe:()=>{a.delete(t)},subscribeNs:e=>(n(e).forEach((e=>i(t.namespaces,e))),r),unsubscribeNs:e=>(n(e).forEach((e=>o(t.namespaces,e))),r),subscribeKey:e=>{const{key:a,ns:o}=e;return i(t.keys,a),n(o).forEach((e=>i(t.namespaces,e))),void 0===o&&i(t.namespaces,void 0),r},unsubscribeKey:e=>{const{key:a,ns:i}=e;return o(t.keys,a),n(i).forEach((e=>o(t.namespaces,e))),void 0===i&&o(t.namespaces,void 0),r}};return r},listen:e=>{t.add(e);return{unsubscribe:()=>{t.delete(e)}}},emit:(e,n)=>{s.push(e),n?Promise.resolve().then((()=>{c()})):c()}})},s=e=>{const n=new Map;return Object.entries(e).forEach((([e,t])=>{null!=t&&("object"!=typeof t?n.set(e,t):s(t).forEach(((t,a)=>{n.set(e+"."+a,t)})))})),n},c=e=>{const[n,t]=e.split(":");return{language:n,namespace:t||""}},u=({language:e,namespace:n})=>n?`${e}:${n}`:e,l=(e,t,a,i,o,r,l)=>{const g=new Map,d=new Map;let f={},v=0;function p(n,t,a){const i=u(n);d.set(i,{data:s(t),version:a}),e.emit(n)}function m(e,n){p(e,n,v)}function h(e,n=!1){const t=d.get(u(e));return t&&n?t.version===v:Boolean(t)}function b(e){var n;return null===(n=d.get(u(i(e))))||void 0===n?void 0:n.data}function y(e){let n;if(!n){const t=f[u(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n||(n=Promise.resolve({})),n}return Object.freeze({addStaticData:function(e){e&&(f=Object.assign(Object.assign({},f),e),Object.entries(e).forEach((([e,n])=>{if("function"!=typeof n){const t=c(e),a=d.get(e);a&&0!==a.version||p(t,n,0)}})))},invalidate:function(){g.clear(),v+=1},addRecord:m,exists:h,getRecord:b,getTranslation:function(e,n){var t;return null===(t=d.get(u(e)))||void 0===t?void 0:t.data.get(n)},getTranslationNs:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(u({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return i}return Array.from(new Set(e))},getTranslationFallback:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(u({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return n}},changeTranslation:function(n,t,a){var i;const o=null===(i=d.get(u(n)))||void 0===i?void 0:i.data;null==o||o.set(t,a),e.emit(Object.assign(Object.assign({},n),{key:t}))},isFetching:function(e){if(o())return!0;if(void 0===e)return g.size>0;const t=n(e);return Boolean(Array.from(g.keys()).find((e=>t.includes(c(e).namespace))))},isLoading:function(e,t){const a=n(t);return Boolean(o()||Array.from(g.keys()).find((n=>{const t=c(n);return(!a.length||a.includes(t.namespace))&&!h({namespace:t.namespace,language:e})})))},loadRecords:async function(e,n){const t=e.map((e=>{const t=i(e),o=u(t),r=g.get(o);if(r)return{new:!1,promise:r,keyObject:t,cacheKey:o};const s=function(e,n){var t;let i;return n&&(i=null===(t=a(e))||void 0===t?void 0:t.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),y(e))))),i||(i=y(e)),i}(t,n);return g.set(o,s),{new:!0,promise:s,keyObject:t,cacheKey:o}}));r.notify(),l.notify();const o=await Promise.all(t.map((e=>e.promise)));return t.forEach(((e,n)=>{const t=g.get(e.cacheKey)!==e.promise;if(e.new&&!t){g.delete(e.cacheKey);const t=o[n];t&&m(e.keyObject,t)}})),r.notify(),l.notify(),t.map((e=>b(e.keyObject)))},getAllRecords:function(){return Array.from(d.entries()).map((([e,n])=>Object.assign(Object.assign({},c(e)),{data:n.data})))}})};function g(e){return Boolean(e&&"function"==typeof e.then)}const d=(e,n)=>g(e)?Promise.resolve(e).then(n):n(e),f=e=>`Tolgee: You need to specify '${e}' option`,v=(e,t,a,i,o,r,s)=>{const c={ui:void 0,observer:void 0},u={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},l=async(e,{keysAndDefaults:t})=>{var a;const i=t.map((({key:e,ns:t,defaultValue:a})=>({key:e,defaultValue:a,ns:n(o({key:e,ns:t,defaultValue:a})),translation:r({key:e,ns:t})})));null===(a=u.ui)||void 0===a||a.handleElementClick(e,i)},f=(e,n)=>{var t,a;return(null===(a=null===(t=u.observer)||void 0===t?void 0:t.highlight)||void 0===a?void 0:a.call(t,e,n))||{unhighlight(){}}},v=e=>{const n=r(e);return p(Object.assign(Object.assign({},e),{translation:n,formatEnabled:!0}))},p=({key:n,translation:t,defaultValue:a,noWrap:i,params:o,orEmpty:r,ns:s,formatEnabled:c})=>{var l;const g=t||a;let d=g||(r?"":n);u.observer&&!i&&(d=u.observer.wrap({key:n,translation:d,defaultValue:a,params:o,ns:s}));const f=e(),v=c||!(null===(l=u.observer)||void 0===l?void 0:l.outputNotFormattable);if(g&&f&&v)for(const e of u.formatters)d=e.format({translation:d,language:f,params:o});return u.finalFormatter&&g&&f&&v&&(d=u.finalFormatter.format({translation:d,language:f,params:o})),d};return Object.freeze({setFinalFormatter:e=>{u.finalFormatter=e},addFormatter:e=>{e&&u.formatters.push(e)},formatTranslation:p,setObserver:e=>{c.observer=e},hasObserver:()=>Boolean(c.observer),setUi:e=>{c.ui=(null==e?void 0:e.UI)||e},hasUi:()=>Boolean(c.ui),addBackend:e=>{e&&u.backends.push(e)},setDevBackend:e=>{u.devBackend=e},getDevBackend:()=>u.devBackend,getBackendRecord:({language:e,namespace:n})=>{for(const t of u.backends){const a=t.getRecord({language:e,namespace:n});if(g(a))return null==a?void 0:a.catch((e=>(console.error(e),{})));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:n})=>{var a;return null===(a=u.devBackend)||void 0===a?void 0:a.getRecord({apiKey:t().apiKey,apiUrl:t().apiUrl,language:e,namespace:n})},setLanguageDetector:e=>{u.languageDetector=e},getLanguageDetector:()=>u.languageDetector,setLanguageStorage:e=>{u.languageStorage=e},getLanguageStorage:()=>u.languageStorage,getInitialLanguage:()=>{var e;const n=i(),t=null===(e=u.languageStorage)||void 0===e?void 0:e.getLanguage();return d(t,(e=>n&&!n.includes(e)||!e?(()=>{if(!u.languageDetector)return;const e=i();return u.languageDetector.getLanguage({availableLanguages:e})})():e))},setStoredLanguage:e=>{var n;null===(n=u.languageStorage)||void 0===n||n.setLanguage(e)},run:e=>{var n,i;!u.ui&&c.ui&&(u.ui=new c.ui({apiKey:t().apiKey,apiUrl:t().apiUrl,highlight:f,changeTranslation:s})),u.observer||(u.observer=null===(n=c.observer)||void 0===n?void 0:n.call(c,{translate:v,onClick:l,options:a()})),null===(i=u.observer)||void 0===i||i.run({mouseHighlight:e})},stop:()=>{var e;u.ui=void 0,null===(e=u.observer)||void 0===e||e.stop()},retranslate:()=>{var e;null===(e=u.observer)||void 0===e||e.retranslate()},highlight:f,wrap:e=>{var n;return u.observer?null===(n=u.observer)||void 0===n?void 0:n.wrap(e):e.translation},unwrap:e=>{var n;return u.observer?null===(n=u.observer)||void 0===n?void 0:n.unwrap(e):{text:e,keys:[]}}})},p=(e,n,t)=>{let a=e;return Object.freeze({init:function(e){a=e},notify:function(){const e=n();a!==e&&t(e),a=e}})},m={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"]},h=e=>Object.assign(Object.assign({},m),e),b={defaultNs:""},y=(e,n)=>{const t=Object.assign(Object.assign(Object.assign({},b),null==n?void 0:n.initialOptions),e),a=t.apiUrl;return t.apiUrl=a?a.replace(/\/+$/,""):a,{initialOptions:t,activeNamespaces:(null==n?void 0:n.activeNamespaces)||new Map,language:null==n?void 0:n.language,pendingLanguage:null==n?void 0:n.language,isInitialLoading:!1,isRunning:!1}};function L(e){var{ns:n,noWrap:t,orEmpty:a,params:i}=e,o=function(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(e);i<a.length;i++)n.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(t[a[i]]=e[a[i]])}return t}(e,["ns","noWrap","orEmpty","params"]);return{ns:n,noWrap:t,orEmpty:a,params:Object.assign(Object.assign({},o),i)}}const O=({options:i})=>{const o=(n=>{const t=e(),a=e(),i=e(),o=e(),s=e(),c=e(),u=r(n),l=e(),g=e();return c.listen((()=>u.emit())),a.listen((()=>u.emit())),l.listen((({value:e})=>{u.emit({ns:[e.namespace],key:e.key},!0)})),Object.freeze({onPendingLanguageChange:t,onLanguageChange:a,onKeyChange:i,onKeyUpdate:u,onLoadingChange:o,onFetchingChange:s,onInitialLoaded:c,onRunningChange:g,onCacheChange:l,on:(e,n)=>{switch(e){case"pendingLanguage":return t.listen(n);case"language":return a.listen(n);case"loading":return o.listen(n);case"fetching":return s.listen(n);case"initialLoad":return c.listen(n);case"running":return g.listen(n);case"cache":return l.listen(n);case"keyUpdate":return u.listen(n)}}})})((function(){return m.getFallbackNamespaces()})),s=p(!1,(()=>O.isFetching()),o.onFetchingChange.emit),u=p(!1,(()=>j()),o.onLoadingChange.emit),m=((e,i,o)=>{let r,s=y(),u=h();function l(){return s.language||s.initialOptions.language}function g(){return Object.assign(Object.assign({},s.initialOptions),r)}return Object.freeze({init:function(e){s=y(e,s)},isRunning:function(){return s.isRunning},setRunning:function(e){s.isRunning!==e&&(s.isRunning=e,o.emit(e))},isInitialLoading:function(){return s.isInitialLoading},setInitialLoading:function(e){s.isInitialLoading=e},getLanguage:l,setLanguage:function(n){s.language!==n&&(s.language=n,e.emit(n))},getPendingLanguage:function(){return s.pendingLanguage||l()},setPendingLanguage:function(e){s.pendingLanguage!==e&&(s.pendingLanguage=e,i.emit(e))},getInitialOptions:g,addActiveNs:function(e){n(e).forEach((e=>{const n=s.activeNamespaces.get(e);void 0!==n?s.activeNamespaces.set(e,n+1):s.activeNamespaces.set(e,1)}))},removeActiveNs:function(e){n(e).forEach((e=>{const n=s.activeNamespaces.get(e);void 0!==n&&n>1?s.activeNamespaces.set(e,n-1):s.activeNamespaces.delete(e)}))},getRequiredNamespaces:function(){return a([...s.initialOptions.ns||[s.initialOptions.defaultNs],...s.activeNamespaces.keys()])},getFallbackLangs:function(e){const n=e||l();return n?a([n,...t(n,s.initialOptions.fallbackLanguage)]):[]},getFallbackNamespaces:function(){const e=s.initialOptions.defaultNs;return a([..."string"==typeof e?[e]:[],...n(s.initialOptions.fallbackNs)])},getAvailableLanguages:function(){if(s.initialOptions.availableLanguages)return s.initialOptions.availableLanguages;if(s.initialOptions.staticData){const e=Object.keys(s.initialOptions.staticData).map((e=>c(e).language));return Array.from(new Set(e))}},withDefaultNs:function(e){return{namespace:void 0===e.namespace?g().defaultNs:e.namespace,language:e.language}},overrideCredentials:function(e){r=e},setObserverOptions:function(e){u=h(e)},getObserverOptions:function(){return u}})})(o.onLanguageChange,o.onPendingLanguageChange,o.onRunningChange),b=v(m.getLanguage,m.getInitialOptions,m.getObserverOptions,m.getAvailableLanguages,(function({key:e,ns:t}){const a=void 0!==t?n(t):m.getFallbackNamespaces(),i=m.getFallbackLangs();return O.getTranslationNs(a,i,e)}),N,w),O=l(o.onCacheChange,b.getBackendRecord,b.getBackendDevRecord,m.withDefaultNs,m.isInitialLoading,s,u);function w(e,n,t){const a=m.withDefaultNs(e),i=O.getTranslation(a,n);return O.changeTranslation(a,n,t),{revert:()=>{O.changeTranslation(a,n,i)}}}function k(e){m.init(e),O.addStaticData(m.getInitialOptions().staticData)}function j(e){return O.isLoading(m.getLanguage(),e)}function E(){return Boolean(m.getInitialOptions().apiKey&&m.getInitialOptions().apiUrl&&b.getDevBackend())}function R(e,t){const a=function(e,t){const a=m.getFallbackLangs(e),i=void 0!==t?n(t):m.getRequiredNamespaces(),o=[];return a.forEach((e=>{i.forEach((n=>{O.exists({language:e,namespace:n},!0)||o.push({language:e,namespace:n})}))})),o}(e,t);if(a.length)return d(I(a),(()=>{}))}function N({key:e,ns:t}){const a=void 0!==t?n(t):m.getFallbackNamespaces(),i=m.getFallbackLangs();return O.getTranslationFallback(a,i,e)}function D(){const e=d(function(){if(m.getLanguage())return;if(!m.getInitialOptions().defaultLanguage)throw new Error(f("defaultLanguage"));const e=b.getInitialLanguage();return d(e,(e=>{const n=e||m.getInitialOptions().defaultLanguage;n&&m.setLanguage(n)}))}(),(()=>R()));if(g(e))return m.setInitialLoading(!0),s.notify(),u.notify(),Promise.resolve(e).then((()=>{m.setInitialLoading(!1),s.notify(),u.notify(),o.onInitialLoaded.emit()}));o.onInitialLoaded.emit()}function I(e){return O.loadRecords(e,E())}i&&k(i),o.onKeyUpdate.listen((()=>{m.isRunning()&&b.retranslate()}));return Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},o),m),b),O),{init:k,changeLanguage:async function(e){m.getPendingLanguage()===e&&m.getLanguage()===e||(m.setPendingLanguage(e),m.isRunning()&&await R(e),e===m.getPendingLanguage()&&(m.setLanguage(e),b.setStoredLanguage(e)))},getTranslation:N,changeTranslation:w,addActiveNs:async function(e,n){n||m.addActiveNs(e),m.isRunning()&&await R(void 0,e)},loadRequiredRecords:R,loadRecords:I,loadRecord:async function(e){return(await I([e]))[0]},isLoading:j,isLoaded:function(e){const t=m.getLanguage();if(!t)return!1;const a=m.getFallbackLangs(t),i=void 0!==e?n(e):m.getRequiredNamespaces(),o=[];return a.forEach((e=>{i.forEach((n=>{O.exists({language:e,namespace:n})||o.push({language:e,namespace:n})}))})),0===o.length},t:(...e)=>{const n=((e,...n)=>{let t,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof n[0]?(a.defaultValue=n[0],t=n[1]):"object"==typeof n[0]&&(t=n[0])),t&&(a=Object.assign(Object.assign({},L(t)),a)),a})(...e),t=N(n);return b.formatTranslation(Object.assign(Object.assign({},n),{translation:t}))},isDev:E,run:function(){let e;return(()=>{const e=b.getLanguageDetector();if(e&&!m.getAvailableLanguages())throw new Error(f("availableLanguages"));if(!m.getLanguage()&&!m.getInitialOptions().defaultLanguage)throw e?new Error(f("defaultLanguage")):new Error(f("language"))})(),m.isRunning()||(E()&&O.invalidate(),m.setRunning(!0),b.run(E()),e=D()),Promise.resolve(e)},stop:function(){m.isRunning()&&(b.stop(),m.setRunning(!1))}}))},w=e=>{const n=O({options:e}),t=Object.freeze({setFinalFormatter:n.setFinalFormatter,addFormatter:n.addFormatter,setObserver:n.setObserver,hasObserver:n.hasObserver,setUi:n.setUi,hasUi:n.hasUi,setDevBackend:n.setDevBackend,addBackend:n.addBackend,setLanguageDetector:n.setLanguageDetector,setLanguageStorage:n.setLanguageStorage,overrideCredentials:n.overrideCredentials}),a=e=>{const t=n.isRunning();t&&n.stop(),e(),t&&n.run()},i=Object.freeze({on:n.on,onKeyUpdate:n.onKeyUpdate.listenSome,getLanguage:n.getLanguage,getPendingLanguage:n.getPendingLanguage,changeLanguage:n.changeLanguage,changeTranslation:n.changeTranslation,addActiveNs:n.addActiveNs,removeActiveNs:n.removeActiveNs,loadRecords:n.loadRecords,loadRecord:n.loadRecord,addStaticData:n.addStaticData,getRecord:n.getRecord,getAllRecords:n.getAllRecords,isLoaded:n.isLoaded,isInitialLoading:n.isInitialLoading,isLoading:n.isLoading,isFetching:n.isFetching,isRunning:n.isRunning,run:n.run,stop:n.stop,t:n.t,highlight:n.highlight,getInitialOptions:n.getInitialOptions,isDev:n.isDev,wrap:n.wrap,unwrap:n.unwrap,setObserverOptions:e=>(n.setObserverOptions(e),i),use:e=>(e&&a((()=>e(i,t))),i),init:e=>(a((()=>n.init(e))),i)});return i};function k(e,n,t,a){return new(t||(t=Promise))((function(i,o){function r(e){try{c(a.next(e))}catch(e){o(e)}}function s(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(r,s)}c((a=a.apply(e,n||[])).next())}))}function j(e,n){var t,a,i,o,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;r;)try{if(t=1,a&&(i=2&o[0]?a.return:o[0]?a.throw||((i=a.return)&&i.call(a),0):a.next)&&!(i=i.call(a,o[1])).done)return i;switch(a=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,a=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){r.label=o[1];break}if(6===o[0]&&r.label<i[1]){r.label=i[1],i=o;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(o);break}i[2]&&r.ops.pop(),r.trys.pop();continue}o=n.call(e,r)}catch(e){o=[6,e],a=0}finally{t=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function E(e){var n=this,t=e.message,a=e.recievingMessage,i=e.data,o=e.attempts,r=void 0===o?1:o,s=!1,c=function(){return new Promise((function(e,n){var o=function(e,n){var t=function(t){var a,i;e.includes(null===(a=t.data)||void 0===a?void 0:a.type)&&n(null===(i=t.data)||void 0===i?void 0:i.data)};return window.addEventListener("message",t,!1),{unsubscribe:function(){window.removeEventListener("message",t)}}}(a,(function(n){clearTimeout(r),s(),e(n)}));window.postMessage({type:t,data:i},window.origin);var r=setTimeout((function(){s(),n()}),300);function s(){o.unsubscribe()}}))};return{cancel:function(){return s=!0},promise:k(n,void 0,void 0,(function(){var e;return j(this,(function(n){switch(n.label){case 0:e=0,n.label=1;case 1:if(!(e<r))return[3,6];if(s)return[2,new Promise((function(){}))];n.label=2;case 2:return n.trys.push([2,4,,5]),[4,c()];case 3:return[2,n.sent()];case 4:return n.sent(),[3,5];case 5:return e++,[3,1];case 6:if(!s)throw"Didn't recieve ".concat(a.join(" or ")," in time.");return[2,new Promise((function(){}))]}}))}))}}var R=null;function N(e){var n;return R||(R=(n="https://unpkg.com/@tolgee/web@".concat(e||"latest","/dist/").concat("tolgee-in-context-tools.umd.min.js"),new Promise((function(e,t){var a=document.createElement("script");a.src=n,a.addEventListener("load",(function(){return e()})),a.addEventListener("error",(function(e){return t(e.error)})),document.body.appendChild(a)}))).then((function(){return window["@tolgee/in-context-tools"].InContextTools}))),R}function D(){var e=sessionStorage.getItem("__tolgee_apiKey")||void 0,n=sessionStorage.getItem("__tolgee_apiUrl")||void 0;if(e&&n)return{apiKey:e,apiUrl:n}}function I(){sessionStorage.removeItem("__tolgee_apiKey"),sessionStorage.removeItem("__tolgee_apiUrl")}var S=function(){return function(e){return e}};"undefined"!=typeof window&&(S=function(){return function(e){var n,t=(n=void 0,{update:function(e){return k(this,void 0,void 0,(function(){var t,a,i;return j(this,(function(o){return null==n||n(),t=E({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:e,attempts:4}),a=t.cancel,i=t.promise,n=a,[2,i]}))}))}});return e.on("running",(function(n){var a;n.value&&(a=function(){t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(I)},"loading"!==document.readyState?Promise.resolve().then((function(){a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))})),D()&&k(void 0,void 0,void 0,(function(){var e;return j(this,(function(n){switch(n.label){case 0:return[4,N("rc")];case 1:return e=n.sent(),[2,function(n){var t=D();return n.use(e(t)),n}]}}))})).then((function(n){e.use(n)})).catch((function(){console.error("Tolgee: Failed to load in-context tools")})),e}});exports.Tolgee=function(e){return w(e).use(S())},exports.TolgeeCore=w; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=()=>{let e=[];return Object.freeze({listen:n=>{const t=e=>{n(e)};return e.push(t),{unsubscribe:()=>{e=e.filter((e=>t!==e))}}},emit:n=>{e.forEach((e=>e({value:n})))}})};function n(e){return function(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}(e)||[]}function t(e,t){return"object"!=typeof(a=t)||Array.isArray(a)||null===a?n(t):n(null==t?void 0:t[e]);var a}function a(e){return Array.from(new Set(e))}function i(e,n){const t=e.get(n)||0;e.set(n,t+1)}function o(e,n){let t=e.get(n)||1;t-=1,t<=0?e.delete(n):e.set(n,t)}const r=e=>{const t=new Set,a=new Set,r=n=>{if(n.has(void 0)){const t=new Set(n.keys());return t.delete(void 0),e().forEach((e=>t.add(e))),t}return n};let s=[];const c=()=>{if(0===s.length)return;t.forEach((e=>{e({value:void 0})}));const e=new Set;let n=new Set;s.forEach((t=>{void 0===(null==t?void 0:t.ns)?e.add(void 0):t.ns.forEach((n=>e.add(n))),void 0===(null==t?void 0:t.key)?n=void 0:void 0!==n&&n.add(t.key)}));const i=Array.from(r(e).keys());(n||[void 0]).forEach((e=>{((e,n)=>{a.forEach((t=>{const a=r(t.namespaces),i=void 0===n||-1!==(null==n?void 0:n.findIndex((e=>a.has(e)))),o=void 0===e||t.keys.has(e)||0===t.keys.size;i&&o&&t.fn({value:void 0})}))})(e,i)})),s=[]};return Object.freeze({listenSome:e=>{const t={fn:n=>{e(n)},keys:new Map,namespaces:new Map};a.add(t);const r={unsubscribe:()=>{a.delete(t)},subscribeNs:e=>(n(e).forEach((e=>i(t.namespaces,e))),r),unsubscribeNs:e=>(n(e).forEach((e=>o(t.namespaces,e))),r),subscribeKey:e=>{const{key:a,ns:o}=e;return i(t.keys,a),n(o).forEach((e=>i(t.namespaces,e))),void 0===o&&i(t.namespaces,void 0),r},unsubscribeKey:e=>{const{key:a,ns:i}=e;return o(t.keys,a),n(i).forEach((e=>o(t.namespaces,e))),void 0===i&&o(t.namespaces,void 0),r}};return r},listen:e=>{t.add(e);return{unsubscribe:()=>{t.delete(e)}}},emit:(e,n)=>{s.push(e),n?Promise.resolve().then((()=>{c()})):c()}})},s=e=>{const n=new Map;return Object.entries(e).forEach((([e,t])=>{null!=t&&("object"!=typeof t?n.set(e,t):s(t).forEach(((t,a)=>{n.set(e+"."+a,t)})))})),n},c=e=>{const[n,t]=e.split(":");return{language:n,namespace:t||""}},u=({language:e,namespace:n})=>n?`${e}:${n}`:e,l=(e,t,a,i,o,r,l)=>{const g=new Map,d=new Map;let f={},v=0;function p(n,t,a){const i=u(n);d.set(i,{data:s(t),version:a}),e.emit(n)}function m(e,n){p(e,n,v)}function h(e,n=!1){const t=d.get(u(e));return t&&n?t.version===v:Boolean(t)}function b(e){var n;return null===(n=d.get(u(i(e))))||void 0===n?void 0:n.data}function y(e){let n;if(!n){const t=f[u(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n||(n=Promise.resolve({})),n}return Object.freeze({addStaticData:function(e){e&&(f=Object.assign(Object.assign({},f),e),Object.entries(e).forEach((([e,n])=>{if("function"!=typeof n){const t=c(e),a=d.get(e);a&&0!==a.version||p(t,n,0)}})))},invalidate:function(){g.clear(),v+=1},addRecord:m,exists:h,getRecord:b,getTranslation:function(e,n){var t;return null===(t=d.get(u(e)))||void 0===t?void 0:t.data.get(n)},getTranslationNs:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(u({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return i}return Array.from(new Set(e))},getTranslationFallback:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(u({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return n}},changeTranslation:function(n,t,a){var i;const o=null===(i=d.get(u(n)))||void 0===i?void 0:i.data;null==o||o.set(t,a),e.emit(Object.assign(Object.assign({},n),{key:t}))},isFetching:function(e){if(o())return!0;if(void 0===e)return g.size>0;const t=n(e);return Boolean(Array.from(g.keys()).find((e=>t.includes(c(e).namespace))))},isLoading:function(e,t){const a=n(t);return Boolean(o()||Array.from(g.keys()).find((n=>{const t=c(n);return(!a.length||a.includes(t.namespace))&&!h({namespace:t.namespace,language:e})})))},loadRecords:async function(e,n){const t=e.map((e=>{const t=i(e),o=u(t),r=g.get(o);if(r)return{new:!1,promise:r,keyObject:t,cacheKey:o};const s=function(e,n){var t;let i;return n&&(i=null===(t=a(e))||void 0===t?void 0:t.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),y(e))))),i||(i=y(e)),i}(t,n);return g.set(o,s),{new:!0,promise:s,keyObject:t,cacheKey:o}}));r.notify(),l.notify();const o=await Promise.all(t.map((e=>e.promise)));return t.forEach(((e,n)=>{const t=g.get(e.cacheKey)!==e.promise;if(e.new&&!t){g.delete(e.cacheKey);const t=o[n];t&&m(e.keyObject,t)}})),r.notify(),l.notify(),t.map((e=>b(e.keyObject)))},getAllRecords:function(){return Array.from(d.entries()).map((([e,n])=>Object.assign(Object.assign({},c(e)),{data:n.data})))}})};function g(e){return Boolean(e&&"function"==typeof e.then)}const d=(e,n)=>g(e)?Promise.resolve(e).then(n):n(e),f=e=>`Tolgee: You need to specify '${e}' option`,v=(e,t,a,i,o,r,s)=>{const c={ui:void 0,observer:void 0},u={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},l=async(e,{keysAndDefaults:t})=>{var a;const i=t.map((({key:e,ns:t,defaultValue:a})=>({key:e,defaultValue:a,ns:n(o({key:e,ns:t,defaultValue:a})),translation:r({key:e,ns:t})})));null===(a=u.ui)||void 0===a||a.handleElementClick(e,i)},f=(e,n)=>{var t,a;return(null===(a=null===(t=u.observer)||void 0===t?void 0:t.highlight)||void 0===a?void 0:a.call(t,e,n))||{unhighlight(){}}},v=e=>{const n=r(e);return p(Object.assign(Object.assign({},e),{translation:n,formatEnabled:!0}))},p=({key:n,translation:t,defaultValue:a,noWrap:i,params:o,orEmpty:r,ns:s,formatEnabled:c})=>{var l;const g=t||a;let d=g||(r?"":n);u.observer&&!i&&(d=u.observer.wrap({key:n,translation:d,defaultValue:a,params:o,ns:s}));const f=e(),v=c||!(null===(l=u.observer)||void 0===l?void 0:l.outputNotFormattable);if(g&&f&&v)for(const e of u.formatters)d=e.format({translation:d,language:f,params:o});return u.finalFormatter&&g&&f&&v&&(d=u.finalFormatter.format({translation:d,language:f,params:o})),d};return Object.freeze({setFinalFormatter:e=>{u.finalFormatter=e},addFormatter:e=>{e&&u.formatters.push(e)},formatTranslation:p,setObserver:e=>{c.observer=e},hasObserver:()=>Boolean(c.observer),setUi:e=>{c.ui=(null==e?void 0:e.UI)||e},hasUi:()=>Boolean(c.ui),addBackend:e=>{e&&u.backends.push(e)},setDevBackend:e=>{u.devBackend=e},getDevBackend:()=>u.devBackend,getBackendRecord:({language:e,namespace:n})=>{for(const t of u.backends){const a=t.getRecord({language:e,namespace:n});if(g(a))return null==a?void 0:a.catch((e=>(console.error(e),{})));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:n})=>{var a;return null===(a=u.devBackend)||void 0===a?void 0:a.getRecord({apiKey:t().apiKey,apiUrl:t().apiUrl,language:e,namespace:n})},setLanguageDetector:e=>{u.languageDetector=e},getLanguageDetector:()=>u.languageDetector,setLanguageStorage:e=>{u.languageStorage=e},getLanguageStorage:()=>u.languageStorage,getInitialLanguage:()=>{var e;const n=i(),t=null===(e=u.languageStorage)||void 0===e?void 0:e.getLanguage();return d(t,(e=>n&&!n.includes(e)||!e?(()=>{if(!u.languageDetector)return;const e=i();return u.languageDetector.getLanguage({availableLanguages:e})})():e))},setStoredLanguage:e=>{var n;null===(n=u.languageStorage)||void 0===n||n.setLanguage(e)},run:e=>{var n,i;!u.ui&&c.ui&&(u.ui=new c.ui({apiKey:t().apiKey,apiUrl:t().apiUrl,highlight:f,changeTranslation:s})),u.observer||(u.observer=null===(n=c.observer)||void 0===n?void 0:n.call(c,{translate:v,onClick:l,options:a()})),null===(i=u.observer)||void 0===i||i.run({mouseHighlight:e})},stop:()=>{var e;u.ui=void 0,null===(e=u.observer)||void 0===e||e.stop()},retranslate:()=>{var e;null===(e=u.observer)||void 0===e||e.retranslate()},highlight:f,wrap:e=>{var n;return u.observer?null===(n=u.observer)||void 0===n?void 0:n.wrap(e):e.translation},unwrap:e=>{var n;return u.observer?null===(n=u.observer)||void 0===n?void 0:n.unwrap(e):{text:e,keys:[]}}})},p=(e,n,t)=>{let a=e;return Object.freeze({init:function(e){a=e},notify:function(){const e=n();a!==e&&t(e),a=e}})},m={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"]},h=e=>Object.assign(Object.assign({},m),e),b={defaultNs:""},y=(e,n)=>{const t=Object.assign(Object.assign(Object.assign({},b),null==n?void 0:n.initialOptions),e),a=t.apiUrl;return t.apiUrl=a?a.replace(/\/+$/,""):a,{initialOptions:t,activeNamespaces:(null==n?void 0:n.activeNamespaces)||new Map,language:null==n?void 0:n.language,pendingLanguage:null==n?void 0:n.language,isInitialLoading:!1,isRunning:!1}};function L(e){var{ns:n,noWrap:t,orEmpty:a,params:i}=e,o=function(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(e);i<a.length;i++)n.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(t[a[i]]=e[a[i]])}return t}(e,["ns","noWrap","orEmpty","params"]);return{ns:n,noWrap:t,orEmpty:a,params:Object.assign(Object.assign({},o),i)}}const O=({options:i})=>{const o=(n=>{const t=e(),a=e(),i=e(),o=e(),s=e(),c=e(),u=r(n),l=e(),g=e();return c.listen((()=>u.emit())),a.listen((()=>u.emit())),l.listen((({value:e})=>{u.emit({ns:[e.namespace],key:e.key},!0)})),Object.freeze({onPendingLanguageChange:t,onLanguageChange:a,onKeyChange:i,onKeyUpdate:u,onLoadingChange:o,onFetchingChange:s,onInitialLoaded:c,onRunningChange:g,onCacheChange:l,on:(e,n)=>{switch(e){case"pendingLanguage":return t.listen(n);case"language":return a.listen(n);case"loading":return o.listen(n);case"fetching":return s.listen(n);case"initialLoad":return c.listen(n);case"running":return g.listen(n);case"cache":return l.listen(n);case"keyUpdate":return u.listen(n)}}})})((function(){return m.getFallbackNamespaces()})),s=p(!1,(()=>O.isFetching()),o.onFetchingChange.emit),u=p(!1,(()=>j()),o.onLoadingChange.emit),m=((e,i,o)=>{let r,s=y(),u=h();function l(){return s.language||s.initialOptions.language}function g(){return Object.assign(Object.assign({},s.initialOptions),r)}return Object.freeze({init:function(e){s=y(e,s)},isRunning:function(){return s.isRunning},setRunning:function(e){s.isRunning!==e&&(s.isRunning=e,o.emit(e))},isInitialLoading:function(){return s.isInitialLoading},setInitialLoading:function(e){s.isInitialLoading=e},getLanguage:l,setLanguage:function(n){s.language!==n&&(s.language=n,e.emit(n))},getPendingLanguage:function(){return s.pendingLanguage||l()},setPendingLanguage:function(e){s.pendingLanguage!==e&&(s.pendingLanguage=e,i.emit(e))},getInitialOptions:g,addActiveNs:function(e){n(e).forEach((e=>{const n=s.activeNamespaces.get(e);void 0!==n?s.activeNamespaces.set(e,n+1):s.activeNamespaces.set(e,1)}))},removeActiveNs:function(e){n(e).forEach((e=>{const n=s.activeNamespaces.get(e);void 0!==n&&n>1?s.activeNamespaces.set(e,n-1):s.activeNamespaces.delete(e)}))},getRequiredNamespaces:function(){return a([...s.initialOptions.ns||[s.initialOptions.defaultNs],...s.activeNamespaces.keys()])},getFallbackLangs:function(e){const n=e||l();return n?a([n,...t(n,s.initialOptions.fallbackLanguage)]):[]},getFallbackNamespaces:function(){const e=s.initialOptions.defaultNs;return a([..."string"==typeof e?[e]:[],...n(s.initialOptions.fallbackNs)])},getAvailableLanguages:function(){if(s.initialOptions.availableLanguages)return s.initialOptions.availableLanguages;if(s.initialOptions.staticData){const e=Object.keys(s.initialOptions.staticData).map((e=>c(e).language));return Array.from(new Set(e))}},withDefaultNs:function(e){return{namespace:void 0===e.namespace?g().defaultNs:e.namespace,language:e.language}},overrideCredentials:function(e){r=e},setObserverOptions:function(e){u=h(e)},getObserverOptions:function(){return u}})})(o.onLanguageChange,o.onPendingLanguageChange,o.onRunningChange),b=v(m.getLanguage,m.getInitialOptions,m.getObserverOptions,m.getAvailableLanguages,(function({key:e,ns:t}){const a=void 0!==t?n(t):m.getFallbackNamespaces(),i=m.getFallbackLangs();return O.getTranslationNs(a,i,e)}),N,w),O=l(o.onCacheChange,b.getBackendRecord,b.getBackendDevRecord,m.withDefaultNs,m.isInitialLoading,s,u);function w(e,n,t){const a=m.withDefaultNs(e),i=O.getTranslation(a,n);return O.changeTranslation(a,n,t),{revert:()=>{O.changeTranslation(a,n,i)}}}function k(e){m.init(e),O.addStaticData(m.getInitialOptions().staticData)}function j(e){return O.isLoading(m.getLanguage(),e)}function E(){return Boolean(m.getInitialOptions().apiKey&&m.getInitialOptions().apiUrl&&b.getDevBackend())}function R(e,t){const a=function(e,t){const a=m.getFallbackLangs(e),i=void 0!==t?n(t):m.getRequiredNamespaces(),o=[];return a.forEach((e=>{i.forEach((n=>{O.exists({language:e,namespace:n},!0)||o.push({language:e,namespace:n})}))})),o}(e,t);if(a.length)return d(I(a),(()=>{}))}function N({key:e,ns:t}){const a=void 0!==t?n(t):m.getFallbackNamespaces(),i=m.getFallbackLangs();return O.getTranslationFallback(a,i,e)}function D(){const e=d(function(){if(m.getLanguage())return;if(!m.getInitialOptions().defaultLanguage)throw new Error(f("defaultLanguage"));const e=b.getInitialLanguage();return d(e,(e=>{const n=e||m.getInitialOptions().defaultLanguage;n&&m.setLanguage(n)}))}(),(()=>R()));if(g(e))return m.setInitialLoading(!0),s.notify(),u.notify(),Promise.resolve(e).then((()=>{m.setInitialLoading(!1),s.notify(),u.notify(),o.onInitialLoaded.emit()}));o.onInitialLoaded.emit()}function I(e){return O.loadRecords(e,E())}i&&k(i),o.onKeyUpdate.listen((()=>{m.isRunning()&&b.retranslate()}));return Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},o),m),b),O),{init:k,changeLanguage:async function(e){m.getPendingLanguage()===e&&m.getLanguage()===e||(m.setPendingLanguage(e),m.isRunning()&&await R(e),e===m.getPendingLanguage()&&(m.setLanguage(e),b.setStoredLanguage(e)))},getTranslation:N,changeTranslation:w,addActiveNs:async function(e,n){n||m.addActiveNs(e),m.isRunning()&&await R(void 0,e)},loadRequiredRecords:R,loadRecords:I,loadRecord:async function(e){return(await I([e]))[0]},isLoading:j,isLoaded:function(e){const t=m.getLanguage();if(!t)return!1;const a=m.getFallbackLangs(t),i=void 0!==e?n(e):m.getRequiredNamespaces(),o=[];return a.forEach((e=>{i.forEach((n=>{O.exists({language:e,namespace:n})||o.push({language:e,namespace:n})}))})),0===o.length},t:(...e)=>{const n=((e,...n)=>{let t,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof n[0]?(a.defaultValue=n[0],t=n[1]):"object"==typeof n[0]&&(t=n[0])),t&&(a=Object.assign(Object.assign({},L(t)),a)),a})(...e),t=N(n);return b.formatTranslation(Object.assign(Object.assign({},n),{translation:t}))},isDev:E,run:function(){let e;return(()=>{const e=b.getLanguageDetector();if(e&&!m.getAvailableLanguages())throw new Error(f("availableLanguages"));if(!m.getLanguage()&&!m.getInitialOptions().defaultLanguage)throw e?new Error(f("defaultLanguage")):new Error(f("language"))})(),m.isRunning()||(E()&&O.invalidate(),m.setRunning(!0),b.run(E()),e=D()),Promise.resolve(e)},stop:function(){m.isRunning()&&(b.stop(),m.setRunning(!1))}}))},w=e=>{const n=O({options:e}),t=Object.freeze({setFinalFormatter:n.setFinalFormatter,addFormatter:n.addFormatter,setObserver:n.setObserver,hasObserver:n.hasObserver,setUi:n.setUi,hasUi:n.hasUi,setDevBackend:n.setDevBackend,addBackend:n.addBackend,setLanguageDetector:n.setLanguageDetector,setLanguageStorage:n.setLanguageStorage,overrideCredentials:n.overrideCredentials}),a=e=>{const t=n.isRunning();t&&n.stop(),e(),t&&n.run()},i=Object.freeze({on:n.on,onKeyUpdate:n.onKeyUpdate.listenSome,getLanguage:n.getLanguage,getPendingLanguage:n.getPendingLanguage,changeLanguage:n.changeLanguage,changeTranslation:n.changeTranslation,addActiveNs:n.addActiveNs,removeActiveNs:n.removeActiveNs,loadRecords:n.loadRecords,loadRecord:n.loadRecord,addStaticData:n.addStaticData,getRecord:n.getRecord,getAllRecords:n.getAllRecords,isLoaded:n.isLoaded,isInitialLoading:n.isInitialLoading,isLoading:n.isLoading,isFetching:n.isFetching,isRunning:n.isRunning,run:n.run,stop:n.stop,t:n.t,highlight:n.highlight,getInitialOptions:n.getInitialOptions,isDev:n.isDev,wrap:n.wrap,unwrap:n.unwrap,setObserverOptions:e=>(n.setObserverOptions(e),i),use:e=>(e&&a((()=>e(i,t))),i),init:e=>(a((()=>n.init(e))),i)});return i};function k(e,n,t,a){return new(t||(t=Promise))((function(i,o){function r(e){try{c(a.next(e))}catch(e){o(e)}}function s(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(r,s)}c((a=a.apply(e,n||[])).next())}))}function j(e,n){var t,a,i,o,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;r;)try{if(t=1,a&&(i=2&o[0]?a.return:o[0]?a.throw||((i=a.return)&&i.call(a),0):a.next)&&!(i=i.call(a,o[1])).done)return i;switch(a=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,a=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){r.label=o[1];break}if(6===o[0]&&r.label<i[1]){r.label=i[1],i=o;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(o);break}i[2]&&r.ops.pop(),r.trys.pop();continue}o=n.call(e,r)}catch(e){o=[6,e],a=0}finally{t=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function E(e){var n=this,t=e.message,a=e.recievingMessage,i=e.data,o=e.attempts,r=void 0===o?1:o,s=!1,c=function(){return new Promise((function(e,n){var o=function(e,n){var t=function(t){var a,i;e.includes(null===(a=t.data)||void 0===a?void 0:a.type)&&n(null===(i=t.data)||void 0===i?void 0:i.data)};return window.addEventListener("message",t,!1),{unsubscribe:function(){window.removeEventListener("message",t)}}}(a,(function(n){clearTimeout(r),s(),e(n)}));window.postMessage({type:t,data:i},window.origin);var r=setTimeout((function(){s(),n()}),300);function s(){o.unsubscribe()}}))};return{cancel:function(){return s=!0},promise:k(n,void 0,void 0,(function(){var e;return j(this,(function(n){switch(n.label){case 0:e=0,n.label=1;case 1:if(!(e<r))return[3,6];if(s)return[2,new Promise((function(){}))];n.label=2;case 2:return n.trys.push([2,4,,5]),[4,c()];case 3:return[2,n.sent()];case 4:return n.sent(),[3,5];case 5:return e++,[3,1];case 6:if(!s)throw"Didn't recieve ".concat(a.join(" or ")," in time.");return[2,new Promise((function(){}))]}}))}))}}var R=null;function N(e){var n;return R||(R=(n="".concat("https://cdn.jsdelivr.net/npm","/@tolgee/web@").concat(e||"latest","/dist/").concat("tolgee-in-context-tools.umd.min.js"),new Promise((function(e,t){var a=document.createElement("script");a.src=n,a.addEventListener("load",(function(){return e()})),a.addEventListener("error",(function(e){return t(e.error)})),document.body.appendChild(a)}))).then((function(){return window["@tolgee/in-context-tools"].InContextTools}))),R}function D(){var e=sessionStorage.getItem("__tolgee_apiKey")||void 0,n=sessionStorage.getItem("__tolgee_apiUrl")||void 0;if(e&&n)return{apiKey:e,apiUrl:n}}function I(){sessionStorage.removeItem("__tolgee_apiKey"),sessionStorage.removeItem("__tolgee_apiUrl")}var S=function(){return function(e){return e}};"undefined"!=typeof window&&(S=function(){return function(e){var n,t=(n=void 0,{update:function(e){return k(this,void 0,void 0,(function(){var t,a,i;return j(this,(function(o){return null==n||n(),t=E({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:e,attempts:4}),a=t.cancel,i=t.promise,n=a,[2,i]}))}))}});return e.on("running",(function(n){var a;n.value&&(a=function(){t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(I)},"loading"!==document.readyState?Promise.resolve().then((function(){a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))})),D()&&k(void 0,void 0,void 0,(function(){var e;return j(this,(function(n){switch(n.label){case 0:return[4,N("rc")];case 1:return e=n.sent(),[2,function(n){var t=D();return n.use(e(t)),n}]}}))})).then((function(n){e.use(n)})).catch((function(){console.error("Tolgee: Failed to load in-context tools")})),e}});exports.Tolgee=function(e){return w(e).use(S())},exports.TolgeeCore=w; | ||
//# sourceMappingURL=tolgee-web-tolgee.cjs.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["@tolgee/web-tolgee"]={})}(this,(function(e){"use strict";const n=()=>{let e=[];return Object.freeze({listen:n=>{const t=e=>{n(e)};return e.push(t),{unsubscribe:()=>{e=e.filter((e=>t!==e))}}},emit:n=>{e.forEach((e=>e({value:n})))}})};function t(e){return function(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}(e)||[]}function a(e,n){return"object"!=typeof(a=n)||Array.isArray(a)||null===a?t(n):t(null==n?void 0:n[e]);var a}function i(e){return Array.from(new Set(e))}function o(e,n){const t=e.get(n)||0;e.set(n,t+1)}function r(e,n){let t=e.get(n)||1;t-=1,t<=0?e.delete(n):e.set(n,t)}const s=e=>{const n=new Set,a=new Set,i=n=>{if(n.has(void 0)){const t=new Set(n.keys());return t.delete(void 0),e().forEach((e=>t.add(e))),t}return n};let s=[];const c=()=>{if(0===s.length)return;n.forEach((e=>{e({value:void 0})}));const e=new Set;let t=new Set;s.forEach((n=>{void 0===(null==n?void 0:n.ns)?e.add(void 0):n.ns.forEach((n=>e.add(n))),void 0===(null==n?void 0:n.key)?t=void 0:void 0!==t&&t.add(n.key)}));const o=Array.from(i(e).keys());(t||[void 0]).forEach((e=>{((e,n)=>{a.forEach((t=>{const a=i(t.namespaces),o=void 0===n||-1!==(null==n?void 0:n.findIndex((e=>a.has(e)))),r=void 0===e||t.keys.has(e)||0===t.keys.size;o&&r&&t.fn({value:void 0})}))})(e,o)})),s=[]};return Object.freeze({listenSome:e=>{const n={fn:n=>{e(n)},keys:new Map,namespaces:new Map};a.add(n);const i={unsubscribe:()=>{a.delete(n)},subscribeNs:e=>(t(e).forEach((e=>o(n.namespaces,e))),i),unsubscribeNs:e=>(t(e).forEach((e=>r(n.namespaces,e))),i),subscribeKey:e=>{const{key:a,ns:r}=e;return o(n.keys,a),t(r).forEach((e=>o(n.namespaces,e))),void 0===r&&o(n.namespaces,void 0),i},unsubscribeKey:e=>{const{key:a,ns:o}=e;return r(n.keys,a),t(o).forEach((e=>r(n.namespaces,e))),void 0===o&&r(n.namespaces,void 0),i}};return i},listen:e=>{n.add(e);return{unsubscribe:()=>{n.delete(e)}}},emit:(e,n)=>{s.push(e),n?Promise.resolve().then((()=>{c()})):c()}})},c=e=>{const n=new Map;return Object.entries(e).forEach((([e,t])=>{null!=t&&("object"!=typeof t?n.set(e,t):c(t).forEach(((t,a)=>{n.set(e+"."+a,t)})))})),n},u=e=>{const[n,t]=e.split(":");return{language:n,namespace:t||""}},l=({language:e,namespace:n})=>n?`${e}:${n}`:e,g=(e,n,a,i,o,r,s)=>{const g=new Map,d=new Map;let f={},v=0;function p(n,t,a){const i=l(n);d.set(i,{data:c(t),version:a}),e.emit(n)}function m(e,n){p(e,n,v)}function h(e,n=!1){const t=d.get(l(e));return t&&n?t.version===v:Boolean(t)}function b(e){var n;return null===(n=d.get(l(i(e))))||void 0===n?void 0:n.data}function y(e){let t;if(!t){const n=f[l(e)];"function"==typeof n&&(t=n())}return t||(t=n(e)),t||(t=Promise.resolve({})),t}return Object.freeze({addStaticData:function(e){e&&(f=Object.assign(Object.assign({},f),e),Object.entries(e).forEach((([e,n])=>{if("function"!=typeof n){const t=u(e),a=d.get(e);a&&0!==a.version||p(t,n,0)}})))},invalidate:function(){g.clear(),v+=1},addRecord:m,exists:h,getRecord:b,getTranslation:function(e,n){var t;return null===(t=d.get(l(e)))||void 0===t?void 0:t.data.get(n)},getTranslationNs:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(l({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return i}return Array.from(new Set(e))},getTranslationFallback:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(l({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return n}},changeTranslation:function(n,t,a){var i;const o=null===(i=d.get(l(n)))||void 0===i?void 0:i.data;null==o||o.set(t,a),e.emit(Object.assign(Object.assign({},n),{key:t}))},isFetching:function(e){if(o())return!0;if(void 0===e)return g.size>0;const n=t(e);return Boolean(Array.from(g.keys()).find((e=>n.includes(u(e).namespace))))},isLoading:function(e,n){const a=t(n);return Boolean(o()||Array.from(g.keys()).find((n=>{const t=u(n);return(!a.length||a.includes(t.namespace))&&!h({namespace:t.namespace,language:e})})))},loadRecords:async function(e,n){const t=e.map((e=>{const t=i(e),o=l(t),r=g.get(o);if(r)return{new:!1,promise:r,keyObject:t,cacheKey:o};const s=function(e,n){var t;let i;return n&&(i=null===(t=a(e))||void 0===t?void 0:t.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),y(e))))),i||(i=y(e)),i}(t,n);return g.set(o,s),{new:!0,promise:s,keyObject:t,cacheKey:o}}));r.notify(),s.notify();const o=await Promise.all(t.map((e=>e.promise)));return t.forEach(((e,n)=>{const t=g.get(e.cacheKey)!==e.promise;if(e.new&&!t){g.delete(e.cacheKey);const t=o[n];t&&m(e.keyObject,t)}})),r.notify(),s.notify(),t.map((e=>b(e.keyObject)))},getAllRecords:function(){return Array.from(d.entries()).map((([e,n])=>Object.assign(Object.assign({},u(e)),{data:n.data})))}})};function d(e){return Boolean(e&&"function"==typeof e.then)}const f=(e,n)=>d(e)?Promise.resolve(e).then(n):n(e),v=e=>`Tolgee: You need to specify '${e}' option`,p=(e,n,a,i,o,r,s)=>{const c={ui:void 0,observer:void 0},u={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},l=async(e,{keysAndDefaults:n})=>{var a;const i=n.map((({key:e,ns:n,defaultValue:a})=>({key:e,defaultValue:a,ns:t(o({key:e,ns:n,defaultValue:a})),translation:r({key:e,ns:n})})));null===(a=u.ui)||void 0===a||a.handleElementClick(e,i)},g=(e,n)=>{var t,a;return(null===(a=null===(t=u.observer)||void 0===t?void 0:t.highlight)||void 0===a?void 0:a.call(t,e,n))||{unhighlight(){}}},v=e=>{const n=r(e);return p(Object.assign(Object.assign({},e),{translation:n,formatEnabled:!0}))},p=({key:n,translation:t,defaultValue:a,noWrap:i,params:o,orEmpty:r,ns:s,formatEnabled:c})=>{var l;const g=t||a;let d=g||(r?"":n);u.observer&&!i&&(d=u.observer.wrap({key:n,translation:d,defaultValue:a,params:o,ns:s}));const f=e(),v=c||!(null===(l=u.observer)||void 0===l?void 0:l.outputNotFormattable);if(g&&f&&v)for(const e of u.formatters)d=e.format({translation:d,language:f,params:o});return u.finalFormatter&&g&&f&&v&&(d=u.finalFormatter.format({translation:d,language:f,params:o})),d};return Object.freeze({setFinalFormatter:e=>{u.finalFormatter=e},addFormatter:e=>{e&&u.formatters.push(e)},formatTranslation:p,setObserver:e=>{c.observer=e},hasObserver:()=>Boolean(c.observer),setUi:e=>{c.ui=(null==e?void 0:e.UI)||e},hasUi:()=>Boolean(c.ui),addBackend:e=>{e&&u.backends.push(e)},setDevBackend:e=>{u.devBackend=e},getDevBackend:()=>u.devBackend,getBackendRecord:({language:e,namespace:n})=>{for(const t of u.backends){const a=t.getRecord({language:e,namespace:n});if(d(a))return null==a?void 0:a.catch((e=>(console.error(e),{})));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:t})=>{var a;return null===(a=u.devBackend)||void 0===a?void 0:a.getRecord({apiKey:n().apiKey,apiUrl:n().apiUrl,language:e,namespace:t})},setLanguageDetector:e=>{u.languageDetector=e},getLanguageDetector:()=>u.languageDetector,setLanguageStorage:e=>{u.languageStorage=e},getLanguageStorage:()=>u.languageStorage,getInitialLanguage:()=>{var e;const n=i(),t=null===(e=u.languageStorage)||void 0===e?void 0:e.getLanguage();return f(t,(e=>n&&!n.includes(e)||!e?(()=>{if(!u.languageDetector)return;const e=i();return u.languageDetector.getLanguage({availableLanguages:e})})():e))},setStoredLanguage:e=>{var n;null===(n=u.languageStorage)||void 0===n||n.setLanguage(e)},run:e=>{var t,i;!u.ui&&c.ui&&(u.ui=new c.ui({apiKey:n().apiKey,apiUrl:n().apiUrl,highlight:g,changeTranslation:s})),u.observer||(u.observer=null===(t=c.observer)||void 0===t?void 0:t.call(c,{translate:v,onClick:l,options:a()})),null===(i=u.observer)||void 0===i||i.run({mouseHighlight:e})},stop:()=>{var e;u.ui=void 0,null===(e=u.observer)||void 0===e||e.stop()},retranslate:()=>{var e;null===(e=u.observer)||void 0===e||e.retranslate()},highlight:g,wrap:e=>{var n;return u.observer?null===(n=u.observer)||void 0===n?void 0:n.wrap(e):e.translation},unwrap:e=>{var n;return u.observer?null===(n=u.observer)||void 0===n?void 0:n.unwrap(e):{text:e,keys:[]}}})},m=(e,n,t)=>{let a=e;return Object.freeze({init:function(e){a=e},notify:function(){const e=n();a!==e&&t(e),a=e}})},h={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"]},b=e=>Object.assign(Object.assign({},h),e),y={defaultNs:""},L=(e,n)=>{const t=Object.assign(Object.assign(Object.assign({},y),null==n?void 0:n.initialOptions),e),a=t.apiUrl;return t.apiUrl=a?a.replace(/\/+$/,""):a,{initialOptions:t,activeNamespaces:(null==n?void 0:n.activeNamespaces)||new Map,language:null==n?void 0:n.language,pendingLanguage:null==n?void 0:n.language,isInitialLoading:!1,isRunning:!1}};function O(e){var{ns:n,noWrap:t,orEmpty:a,params:i}=e,o=function(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(e);i<a.length;i++)n.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(t[a[i]]=e[a[i]])}return t}(e,["ns","noWrap","orEmpty","params"]);return{ns:n,noWrap:t,orEmpty:a,params:Object.assign(Object.assign({},o),i)}}const w=({options:e})=>{const o=(e=>{const t=n(),a=n(),i=n(),o=n(),r=n(),c=n(),u=s(e),l=n(),g=n();return c.listen((()=>u.emit())),a.listen((()=>u.emit())),l.listen((({value:e})=>{u.emit({ns:[e.namespace],key:e.key},!0)})),Object.freeze({onPendingLanguageChange:t,onLanguageChange:a,onKeyChange:i,onKeyUpdate:u,onLoadingChange:o,onFetchingChange:r,onInitialLoaded:c,onRunningChange:g,onCacheChange:l,on:(e,n)=>{switch(e){case"pendingLanguage":return t.listen(n);case"language":return a.listen(n);case"loading":return o.listen(n);case"fetching":return r.listen(n);case"initialLoad":return c.listen(n);case"running":return g.listen(n);case"cache":return l.listen(n);case"keyUpdate":return u.listen(n)}}})})((function(){return l.getFallbackNamespaces()})),r=m(!1,(()=>y.isFetching()),o.onFetchingChange.emit),c=m(!1,(()=>j()),o.onLoadingChange.emit),l=((e,n,o)=>{let r,s=L(),c=b();function l(){return s.language||s.initialOptions.language}function g(){return Object.assign(Object.assign({},s.initialOptions),r)}return Object.freeze({init:function(e){s=L(e,s)},isRunning:function(){return s.isRunning},setRunning:function(e){s.isRunning!==e&&(s.isRunning=e,o.emit(e))},isInitialLoading:function(){return s.isInitialLoading},setInitialLoading:function(e){s.isInitialLoading=e},getLanguage:l,setLanguage:function(n){s.language!==n&&(s.language=n,e.emit(n))},getPendingLanguage:function(){return s.pendingLanguage||l()},setPendingLanguage:function(e){s.pendingLanguage!==e&&(s.pendingLanguage=e,n.emit(e))},getInitialOptions:g,addActiveNs:function(e){t(e).forEach((e=>{const n=s.activeNamespaces.get(e);void 0!==n?s.activeNamespaces.set(e,n+1):s.activeNamespaces.set(e,1)}))},removeActiveNs:function(e){t(e).forEach((e=>{const n=s.activeNamespaces.get(e);void 0!==n&&n>1?s.activeNamespaces.set(e,n-1):s.activeNamespaces.delete(e)}))},getRequiredNamespaces:function(){return i([...s.initialOptions.ns||[s.initialOptions.defaultNs],...s.activeNamespaces.keys()])},getFallbackLangs:function(e){const n=e||l();return n?i([n,...a(n,s.initialOptions.fallbackLanguage)]):[]},getFallbackNamespaces:function(){const e=s.initialOptions.defaultNs;return i([..."string"==typeof e?[e]:[],...t(s.initialOptions.fallbackNs)])},getAvailableLanguages:function(){if(s.initialOptions.availableLanguages)return s.initialOptions.availableLanguages;if(s.initialOptions.staticData){const e=Object.keys(s.initialOptions.staticData).map((e=>u(e).language));return Array.from(new Set(e))}},withDefaultNs:function(e){return{namespace:void 0===e.namespace?g().defaultNs:e.namespace,language:e.language}},overrideCredentials:function(e){r=e},setObserverOptions:function(e){c=b(e)},getObserverOptions:function(){return c}})})(o.onLanguageChange,o.onPendingLanguageChange,o.onRunningChange),h=p(l.getLanguage,l.getInitialOptions,l.getObserverOptions,l.getAvailableLanguages,(function({key:e,ns:n}){const a=void 0!==n?t(n):l.getFallbackNamespaces(),i=l.getFallbackLangs();return y.getTranslationNs(a,i,e)}),N,w),y=g(o.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,l.withDefaultNs,l.isInitialLoading,r,c);function w(e,n,t){const a=l.withDefaultNs(e),i=y.getTranslation(a,n);return y.changeTranslation(a,n,t),{revert:()=>{y.changeTranslation(a,n,i)}}}function k(e){l.init(e),y.addStaticData(l.getInitialOptions().staticData)}function j(e){return y.isLoading(l.getLanguage(),e)}function E(){return Boolean(l.getInitialOptions().apiKey&&l.getInitialOptions().apiUrl&&h.getDevBackend())}function R(e,n){const a=function(e,n){const a=l.getFallbackLangs(e),i=void 0!==n?t(n):l.getRequiredNamespaces(),o=[];return a.forEach((e=>{i.forEach((n=>{y.exists({language:e,namespace:n},!0)||o.push({language:e,namespace:n})}))})),o}(e,n);if(a.length)return f(I(a),(()=>{}))}function N({key:e,ns:n}){const a=void 0!==n?t(n):l.getFallbackNamespaces(),i=l.getFallbackLangs();return y.getTranslationFallback(a,i,e)}function D(){const e=f(function(){if(l.getLanguage())return;if(!l.getInitialOptions().defaultLanguage)throw new Error(v("defaultLanguage"));const e=h.getInitialLanguage();return f(e,(e=>{const n=e||l.getInitialOptions().defaultLanguage;n&&l.setLanguage(n)}))}(),(()=>R()));if(d(e))return l.setInitialLoading(!0),r.notify(),c.notify(),Promise.resolve(e).then((()=>{l.setInitialLoading(!1),r.notify(),c.notify(),o.onInitialLoaded.emit()}));o.onInitialLoaded.emit()}function I(e){return y.loadRecords(e,E())}e&&k(e),o.onKeyUpdate.listen((()=>{l.isRunning()&&h.retranslate()}));return Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},o),l),h),y),{init:k,changeLanguage:async function(e){l.getPendingLanguage()===e&&l.getLanguage()===e||(l.setPendingLanguage(e),l.isRunning()&&await R(e),e===l.getPendingLanguage()&&(l.setLanguage(e),h.setStoredLanguage(e)))},getTranslation:N,changeTranslation:w,addActiveNs:async function(e,n){n||l.addActiveNs(e),l.isRunning()&&await R(void 0,e)},loadRequiredRecords:R,loadRecords:I,loadRecord:async function(e){return(await I([e]))[0]},isLoading:j,isLoaded:function(e){const n=l.getLanguage();if(!n)return!1;const a=l.getFallbackLangs(n),i=void 0!==e?t(e):l.getRequiredNamespaces(),o=[];return a.forEach((e=>{i.forEach((n=>{y.exists({language:e,namespace:n})||o.push({language:e,namespace:n})}))})),0===o.length},t:(...e)=>{const n=((e,...n)=>{let t,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof n[0]?(a.defaultValue=n[0],t=n[1]):"object"==typeof n[0]&&(t=n[0])),t&&(a=Object.assign(Object.assign({},O(t)),a)),a})(...e),t=N(n);return h.formatTranslation(Object.assign(Object.assign({},n),{translation:t}))},isDev:E,run:function(){let e;return(()=>{const e=h.getLanguageDetector();if(e&&!l.getAvailableLanguages())throw new Error(v("availableLanguages"));if(!l.getLanguage()&&!l.getInitialOptions().defaultLanguage)throw e?new Error(v("defaultLanguage")):new Error(v("language"))})(),l.isRunning()||(E()&&y.invalidate(),l.setRunning(!0),h.run(E()),e=D()),Promise.resolve(e)},stop:function(){l.isRunning()&&(h.stop(),l.setRunning(!1))}}))},k=e=>{const n=w({options:e}),t=Object.freeze({setFinalFormatter:n.setFinalFormatter,addFormatter:n.addFormatter,setObserver:n.setObserver,hasObserver:n.hasObserver,setUi:n.setUi,hasUi:n.hasUi,setDevBackend:n.setDevBackend,addBackend:n.addBackend,setLanguageDetector:n.setLanguageDetector,setLanguageStorage:n.setLanguageStorage,overrideCredentials:n.overrideCredentials}),a=e=>{const t=n.isRunning();t&&n.stop(),e(),t&&n.run()},i=Object.freeze({on:n.on,onKeyUpdate:n.onKeyUpdate.listenSome,getLanguage:n.getLanguage,getPendingLanguage:n.getPendingLanguage,changeLanguage:n.changeLanguage,changeTranslation:n.changeTranslation,addActiveNs:n.addActiveNs,removeActiveNs:n.removeActiveNs,loadRecords:n.loadRecords,loadRecord:n.loadRecord,addStaticData:n.addStaticData,getRecord:n.getRecord,getAllRecords:n.getAllRecords,isLoaded:n.isLoaded,isInitialLoading:n.isInitialLoading,isLoading:n.isLoading,isFetching:n.isFetching,isRunning:n.isRunning,run:n.run,stop:n.stop,t:n.t,highlight:n.highlight,getInitialOptions:n.getInitialOptions,isDev:n.isDev,wrap:n.wrap,unwrap:n.unwrap,setObserverOptions:e=>(n.setObserverOptions(e),i),use:e=>(e&&a((()=>e(i,t))),i),init:e=>(a((()=>n.init(e))),i)});return i};function j(e,n,t,a){return new(t||(t=Promise))((function(i,o){function r(e){try{c(a.next(e))}catch(e){o(e)}}function s(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(r,s)}c((a=a.apply(e,n||[])).next())}))}function E(e,n){var t,a,i,o,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;r;)try{if(t=1,a&&(i=2&o[0]?a.return:o[0]?a.throw||((i=a.return)&&i.call(a),0):a.next)&&!(i=i.call(a,o[1])).done)return i;switch(a=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,a=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){r.label=o[1];break}if(6===o[0]&&r.label<i[1]){r.label=i[1],i=o;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(o);break}i[2]&&r.ops.pop(),r.trys.pop();continue}o=n.call(e,r)}catch(e){o=[6,e],a=0}finally{t=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function R(e){var n=this,t=e.message,a=e.recievingMessage,i=e.data,o=e.attempts,r=void 0===o?1:o,s=!1,c=function(){return new Promise((function(e,n){var o=function(e,n){var t=function(t){var a,i;e.includes(null===(a=t.data)||void 0===a?void 0:a.type)&&n(null===(i=t.data)||void 0===i?void 0:i.data)};return window.addEventListener("message",t,!1),{unsubscribe:function(){window.removeEventListener("message",t)}}}(a,(function(n){clearTimeout(r),s(),e(n)}));window.postMessage({type:t,data:i},window.origin);var r=setTimeout((function(){s(),n()}),300);function s(){o.unsubscribe()}}))};return{cancel:function(){return s=!0},promise:j(n,void 0,void 0,(function(){var e;return E(this,(function(n){switch(n.label){case 0:e=0,n.label=1;case 1:if(!(e<r))return[3,6];if(s)return[2,new Promise((function(){}))];n.label=2;case 2:return n.trys.push([2,4,,5]),[4,c()];case 3:return[2,n.sent()];case 4:return n.sent(),[3,5];case 5:return e++,[3,1];case 6:if(!s)throw"Didn't recieve ".concat(a.join(" or ")," in time.");return[2,new Promise((function(){}))]}}))}))}}var N=null;function D(e){var n;return N||(N=(n="https://unpkg.com/@tolgee/web@".concat(e||"latest","/dist/").concat("tolgee-in-context-tools.umd.min.js"),new Promise((function(e,t){var a=document.createElement("script");a.src=n,a.addEventListener("load",(function(){return e()})),a.addEventListener("error",(function(e){return t(e.error)})),document.body.appendChild(a)}))).then((function(){return window["@tolgee/in-context-tools"].InContextTools}))),N}var I="__tolgee_apiKey",S="__tolgee_apiUrl";function F(){var e=sessionStorage.getItem(I)||void 0,n=sessionStorage.getItem(S)||void 0;if(e&&n)return{apiKey:e,apiUrl:n}}function T(){sessionStorage.removeItem(I),sessionStorage.removeItem(S)}var A=function(){return function(e){return e}};"undefined"!=typeof window&&(A=function(){return function(e){var n,t=(n=void 0,{update:function(e){return j(this,void 0,void 0,(function(){var t,a,i;return E(this,(function(o){return null==n||n(),t=R({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:e,attempts:4}),a=t.cancel,i=t.promise,n=a,[2,i]}))}))}});return e.on("running",(function(n){var a;n.value&&(a=function(){t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(T)},"loading"!==document.readyState?Promise.resolve().then((function(){a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))})),F()&&j(void 0,void 0,void 0,(function(){var e;return E(this,(function(n){switch(n.label){case 0:return[4,D("rc")];case 1:return e=n.sent(),[2,function(n){var t=F();return n.use(e(t)),n}]}}))})).then((function(n){e.use(n)})).catch((function(){console.error("Tolgee: Failed to load in-context tools")})),e}});e.Tolgee=function(e){return k(e).use(A())},e.TolgeeCore=k,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["@tolgee/web-tolgee"]={})}(this,(function(e){"use strict";const n=()=>{let e=[];return Object.freeze({listen:n=>{const t=e=>{n(e)};return e.push(t),{unsubscribe:()=>{e=e.filter((e=>t!==e))}}},emit:n=>{e.forEach((e=>e({value:n})))}})};function t(e){return function(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}(e)||[]}function a(e,n){return"object"!=typeof(a=n)||Array.isArray(a)||null===a?t(n):t(null==n?void 0:n[e]);var a}function i(e){return Array.from(new Set(e))}function o(e,n){const t=e.get(n)||0;e.set(n,t+1)}function r(e,n){let t=e.get(n)||1;t-=1,t<=0?e.delete(n):e.set(n,t)}const s=e=>{const n=new Set,a=new Set,i=n=>{if(n.has(void 0)){const t=new Set(n.keys());return t.delete(void 0),e().forEach((e=>t.add(e))),t}return n};let s=[];const c=()=>{if(0===s.length)return;n.forEach((e=>{e({value:void 0})}));const e=new Set;let t=new Set;s.forEach((n=>{void 0===(null==n?void 0:n.ns)?e.add(void 0):n.ns.forEach((n=>e.add(n))),void 0===(null==n?void 0:n.key)?t=void 0:void 0!==t&&t.add(n.key)}));const o=Array.from(i(e).keys());(t||[void 0]).forEach((e=>{((e,n)=>{a.forEach((t=>{const a=i(t.namespaces),o=void 0===n||-1!==(null==n?void 0:n.findIndex((e=>a.has(e)))),r=void 0===e||t.keys.has(e)||0===t.keys.size;o&&r&&t.fn({value:void 0})}))})(e,o)})),s=[]};return Object.freeze({listenSome:e=>{const n={fn:n=>{e(n)},keys:new Map,namespaces:new Map};a.add(n);const i={unsubscribe:()=>{a.delete(n)},subscribeNs:e=>(t(e).forEach((e=>o(n.namespaces,e))),i),unsubscribeNs:e=>(t(e).forEach((e=>r(n.namespaces,e))),i),subscribeKey:e=>{const{key:a,ns:r}=e;return o(n.keys,a),t(r).forEach((e=>o(n.namespaces,e))),void 0===r&&o(n.namespaces,void 0),i},unsubscribeKey:e=>{const{key:a,ns:o}=e;return r(n.keys,a),t(o).forEach((e=>r(n.namespaces,e))),void 0===o&&r(n.namespaces,void 0),i}};return i},listen:e=>{n.add(e);return{unsubscribe:()=>{n.delete(e)}}},emit:(e,n)=>{s.push(e),n?Promise.resolve().then((()=>{c()})):c()}})},c=e=>{const n=new Map;return Object.entries(e).forEach((([e,t])=>{null!=t&&("object"!=typeof t?n.set(e,t):c(t).forEach(((t,a)=>{n.set(e+"."+a,t)})))})),n},u=e=>{const[n,t]=e.split(":");return{language:n,namespace:t||""}},l=({language:e,namespace:n})=>n?`${e}:${n}`:e,g=(e,n,a,i,o,r,s)=>{const g=new Map,d=new Map;let f={},v=0;function p(n,t,a){const i=l(n);d.set(i,{data:c(t),version:a}),e.emit(n)}function m(e,n){p(e,n,v)}function h(e,n=!1){const t=d.get(l(e));return t&&n?t.version===v:Boolean(t)}function b(e){var n;return null===(n=d.get(l(i(e))))||void 0===n?void 0:n.data}function y(e){let t;if(!t){const n=f[l(e)];"function"==typeof n&&(t=n())}return t||(t=n(e)),t||(t=Promise.resolve({})),t}return Object.freeze({addStaticData:function(e){e&&(f=Object.assign(Object.assign({},f),e),Object.entries(e).forEach((([e,n])=>{if("function"!=typeof n){const t=u(e),a=d.get(e);a&&0!==a.version||p(t,n,0)}})))},invalidate:function(){g.clear(),v+=1},addRecord:m,exists:h,getRecord:b,getTranslation:function(e,n){var t;return null===(t=d.get(l(e)))||void 0===t?void 0:t.data.get(n)},getTranslationNs:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(l({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return i}return Array.from(new Set(e))},getTranslationFallback:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(l({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return n}},changeTranslation:function(n,t,a){var i;const o=null===(i=d.get(l(n)))||void 0===i?void 0:i.data;null==o||o.set(t,a),e.emit(Object.assign(Object.assign({},n),{key:t}))},isFetching:function(e){if(o())return!0;if(void 0===e)return g.size>0;const n=t(e);return Boolean(Array.from(g.keys()).find((e=>n.includes(u(e).namespace))))},isLoading:function(e,n){const a=t(n);return Boolean(o()||Array.from(g.keys()).find((n=>{const t=u(n);return(!a.length||a.includes(t.namespace))&&!h({namespace:t.namespace,language:e})})))},loadRecords:async function(e,n){const t=e.map((e=>{const t=i(e),o=l(t),r=g.get(o);if(r)return{new:!1,promise:r,keyObject:t,cacheKey:o};const s=function(e,n){var t;let i;return n&&(i=null===(t=a(e))||void 0===t?void 0:t.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),y(e))))),i||(i=y(e)),i}(t,n);return g.set(o,s),{new:!0,promise:s,keyObject:t,cacheKey:o}}));r.notify(),s.notify();const o=await Promise.all(t.map((e=>e.promise)));return t.forEach(((e,n)=>{const t=g.get(e.cacheKey)!==e.promise;if(e.new&&!t){g.delete(e.cacheKey);const t=o[n];t&&m(e.keyObject,t)}})),r.notify(),s.notify(),t.map((e=>b(e.keyObject)))},getAllRecords:function(){return Array.from(d.entries()).map((([e,n])=>Object.assign(Object.assign({},u(e)),{data:n.data})))}})};function d(e){return Boolean(e&&"function"==typeof e.then)}const f=(e,n)=>d(e)?Promise.resolve(e).then(n):n(e),v=e=>`Tolgee: You need to specify '${e}' option`,p=(e,n,a,i,o,r,s)=>{const c={ui:void 0,observer:void 0},u={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},l=async(e,{keysAndDefaults:n})=>{var a;const i=n.map((({key:e,ns:n,defaultValue:a})=>({key:e,defaultValue:a,ns:t(o({key:e,ns:n,defaultValue:a})),translation:r({key:e,ns:n})})));null===(a=u.ui)||void 0===a||a.handleElementClick(e,i)},g=(e,n)=>{var t,a;return(null===(a=null===(t=u.observer)||void 0===t?void 0:t.highlight)||void 0===a?void 0:a.call(t,e,n))||{unhighlight(){}}},v=e=>{const n=r(e);return p(Object.assign(Object.assign({},e),{translation:n,formatEnabled:!0}))},p=({key:n,translation:t,defaultValue:a,noWrap:i,params:o,orEmpty:r,ns:s,formatEnabled:c})=>{var l;const g=t||a;let d=g||(r?"":n);u.observer&&!i&&(d=u.observer.wrap({key:n,translation:d,defaultValue:a,params:o,ns:s}));const f=e(),v=c||!(null===(l=u.observer)||void 0===l?void 0:l.outputNotFormattable);if(g&&f&&v)for(const e of u.formatters)d=e.format({translation:d,language:f,params:o});return u.finalFormatter&&g&&f&&v&&(d=u.finalFormatter.format({translation:d,language:f,params:o})),d};return Object.freeze({setFinalFormatter:e=>{u.finalFormatter=e},addFormatter:e=>{e&&u.formatters.push(e)},formatTranslation:p,setObserver:e=>{c.observer=e},hasObserver:()=>Boolean(c.observer),setUi:e=>{c.ui=(null==e?void 0:e.UI)||e},hasUi:()=>Boolean(c.ui),addBackend:e=>{e&&u.backends.push(e)},setDevBackend:e=>{u.devBackend=e},getDevBackend:()=>u.devBackend,getBackendRecord:({language:e,namespace:n})=>{for(const t of u.backends){const a=t.getRecord({language:e,namespace:n});if(d(a))return null==a?void 0:a.catch((e=>(console.error(e),{})));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:t})=>{var a;return null===(a=u.devBackend)||void 0===a?void 0:a.getRecord({apiKey:n().apiKey,apiUrl:n().apiUrl,language:e,namespace:t})},setLanguageDetector:e=>{u.languageDetector=e},getLanguageDetector:()=>u.languageDetector,setLanguageStorage:e=>{u.languageStorage=e},getLanguageStorage:()=>u.languageStorage,getInitialLanguage:()=>{var e;const n=i(),t=null===(e=u.languageStorage)||void 0===e?void 0:e.getLanguage();return f(t,(e=>n&&!n.includes(e)||!e?(()=>{if(!u.languageDetector)return;const e=i();return u.languageDetector.getLanguage({availableLanguages:e})})():e))},setStoredLanguage:e=>{var n;null===(n=u.languageStorage)||void 0===n||n.setLanguage(e)},run:e=>{var t,i;!u.ui&&c.ui&&(u.ui=new c.ui({apiKey:n().apiKey,apiUrl:n().apiUrl,highlight:g,changeTranslation:s})),u.observer||(u.observer=null===(t=c.observer)||void 0===t?void 0:t.call(c,{translate:v,onClick:l,options:a()})),null===(i=u.observer)||void 0===i||i.run({mouseHighlight:e})},stop:()=>{var e;u.ui=void 0,null===(e=u.observer)||void 0===e||e.stop()},retranslate:()=>{var e;null===(e=u.observer)||void 0===e||e.retranslate()},highlight:g,wrap:e=>{var n;return u.observer?null===(n=u.observer)||void 0===n?void 0:n.wrap(e):e.translation},unwrap:e=>{var n;return u.observer?null===(n=u.observer)||void 0===n?void 0:n.unwrap(e):{text:e,keys:[]}}})},m=(e,n,t)=>{let a=e;return Object.freeze({init:function(e){a=e},notify:function(){const e=n();a!==e&&t(e),a=e}})},h={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"]},b=e=>Object.assign(Object.assign({},h),e),y={defaultNs:""},L=(e,n)=>{const t=Object.assign(Object.assign(Object.assign({},y),null==n?void 0:n.initialOptions),e),a=t.apiUrl;return t.apiUrl=a?a.replace(/\/+$/,""):a,{initialOptions:t,activeNamespaces:(null==n?void 0:n.activeNamespaces)||new Map,language:null==n?void 0:n.language,pendingLanguage:null==n?void 0:n.language,isInitialLoading:!1,isRunning:!1}};function O(e){var{ns:n,noWrap:t,orEmpty:a,params:i}=e,o=function(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(e);i<a.length;i++)n.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(t[a[i]]=e[a[i]])}return t}(e,["ns","noWrap","orEmpty","params"]);return{ns:n,noWrap:t,orEmpty:a,params:Object.assign(Object.assign({},o),i)}}const w=({options:e})=>{const o=(e=>{const t=n(),a=n(),i=n(),o=n(),r=n(),c=n(),u=s(e),l=n(),g=n();return c.listen((()=>u.emit())),a.listen((()=>u.emit())),l.listen((({value:e})=>{u.emit({ns:[e.namespace],key:e.key},!0)})),Object.freeze({onPendingLanguageChange:t,onLanguageChange:a,onKeyChange:i,onKeyUpdate:u,onLoadingChange:o,onFetchingChange:r,onInitialLoaded:c,onRunningChange:g,onCacheChange:l,on:(e,n)=>{switch(e){case"pendingLanguage":return t.listen(n);case"language":return a.listen(n);case"loading":return o.listen(n);case"fetching":return r.listen(n);case"initialLoad":return c.listen(n);case"running":return g.listen(n);case"cache":return l.listen(n);case"keyUpdate":return u.listen(n)}}})})((function(){return l.getFallbackNamespaces()})),r=m(!1,(()=>y.isFetching()),o.onFetchingChange.emit),c=m(!1,(()=>j()),o.onLoadingChange.emit),l=((e,n,o)=>{let r,s=L(),c=b();function l(){return s.language||s.initialOptions.language}function g(){return Object.assign(Object.assign({},s.initialOptions),r)}return Object.freeze({init:function(e){s=L(e,s)},isRunning:function(){return s.isRunning},setRunning:function(e){s.isRunning!==e&&(s.isRunning=e,o.emit(e))},isInitialLoading:function(){return s.isInitialLoading},setInitialLoading:function(e){s.isInitialLoading=e},getLanguage:l,setLanguage:function(n){s.language!==n&&(s.language=n,e.emit(n))},getPendingLanguage:function(){return s.pendingLanguage||l()},setPendingLanguage:function(e){s.pendingLanguage!==e&&(s.pendingLanguage=e,n.emit(e))},getInitialOptions:g,addActiveNs:function(e){t(e).forEach((e=>{const n=s.activeNamespaces.get(e);void 0!==n?s.activeNamespaces.set(e,n+1):s.activeNamespaces.set(e,1)}))},removeActiveNs:function(e){t(e).forEach((e=>{const n=s.activeNamespaces.get(e);void 0!==n&&n>1?s.activeNamespaces.set(e,n-1):s.activeNamespaces.delete(e)}))},getRequiredNamespaces:function(){return i([...s.initialOptions.ns||[s.initialOptions.defaultNs],...s.activeNamespaces.keys()])},getFallbackLangs:function(e){const n=e||l();return n?i([n,...a(n,s.initialOptions.fallbackLanguage)]):[]},getFallbackNamespaces:function(){const e=s.initialOptions.defaultNs;return i([..."string"==typeof e?[e]:[],...t(s.initialOptions.fallbackNs)])},getAvailableLanguages:function(){if(s.initialOptions.availableLanguages)return s.initialOptions.availableLanguages;if(s.initialOptions.staticData){const e=Object.keys(s.initialOptions.staticData).map((e=>u(e).language));return Array.from(new Set(e))}},withDefaultNs:function(e){return{namespace:void 0===e.namespace?g().defaultNs:e.namespace,language:e.language}},overrideCredentials:function(e){r=e},setObserverOptions:function(e){c=b(e)},getObserverOptions:function(){return c}})})(o.onLanguageChange,o.onPendingLanguageChange,o.onRunningChange),h=p(l.getLanguage,l.getInitialOptions,l.getObserverOptions,l.getAvailableLanguages,(function({key:e,ns:n}){const a=void 0!==n?t(n):l.getFallbackNamespaces(),i=l.getFallbackLangs();return y.getTranslationNs(a,i,e)}),N,w),y=g(o.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,l.withDefaultNs,l.isInitialLoading,r,c);function w(e,n,t){const a=l.withDefaultNs(e),i=y.getTranslation(a,n);return y.changeTranslation(a,n,t),{revert:()=>{y.changeTranslation(a,n,i)}}}function k(e){l.init(e),y.addStaticData(l.getInitialOptions().staticData)}function j(e){return y.isLoading(l.getLanguage(),e)}function E(){return Boolean(l.getInitialOptions().apiKey&&l.getInitialOptions().apiUrl&&h.getDevBackend())}function R(e,n){const a=function(e,n){const a=l.getFallbackLangs(e),i=void 0!==n?t(n):l.getRequiredNamespaces(),o=[];return a.forEach((e=>{i.forEach((n=>{y.exists({language:e,namespace:n},!0)||o.push({language:e,namespace:n})}))})),o}(e,n);if(a.length)return f(I(a),(()=>{}))}function N({key:e,ns:n}){const a=void 0!==n?t(n):l.getFallbackNamespaces(),i=l.getFallbackLangs();return y.getTranslationFallback(a,i,e)}function D(){const e=f(function(){if(l.getLanguage())return;if(!l.getInitialOptions().defaultLanguage)throw new Error(v("defaultLanguage"));const e=h.getInitialLanguage();return f(e,(e=>{const n=e||l.getInitialOptions().defaultLanguage;n&&l.setLanguage(n)}))}(),(()=>R()));if(d(e))return l.setInitialLoading(!0),r.notify(),c.notify(),Promise.resolve(e).then((()=>{l.setInitialLoading(!1),r.notify(),c.notify(),o.onInitialLoaded.emit()}));o.onInitialLoaded.emit()}function I(e){return y.loadRecords(e,E())}e&&k(e),o.onKeyUpdate.listen((()=>{l.isRunning()&&h.retranslate()}));return Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},o),l),h),y),{init:k,changeLanguage:async function(e){l.getPendingLanguage()===e&&l.getLanguage()===e||(l.setPendingLanguage(e),l.isRunning()&&await R(e),e===l.getPendingLanguage()&&(l.setLanguage(e),h.setStoredLanguage(e)))},getTranslation:N,changeTranslation:w,addActiveNs:async function(e,n){n||l.addActiveNs(e),l.isRunning()&&await R(void 0,e)},loadRequiredRecords:R,loadRecords:I,loadRecord:async function(e){return(await I([e]))[0]},isLoading:j,isLoaded:function(e){const n=l.getLanguage();if(!n)return!1;const a=l.getFallbackLangs(n),i=void 0!==e?t(e):l.getRequiredNamespaces(),o=[];return a.forEach((e=>{i.forEach((n=>{y.exists({language:e,namespace:n})||o.push({language:e,namespace:n})}))})),0===o.length},t:(...e)=>{const n=((e,...n)=>{let t,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof n[0]?(a.defaultValue=n[0],t=n[1]):"object"==typeof n[0]&&(t=n[0])),t&&(a=Object.assign(Object.assign({},O(t)),a)),a})(...e),t=N(n);return h.formatTranslation(Object.assign(Object.assign({},n),{translation:t}))},isDev:E,run:function(){let e;return(()=>{const e=h.getLanguageDetector();if(e&&!l.getAvailableLanguages())throw new Error(v("availableLanguages"));if(!l.getLanguage()&&!l.getInitialOptions().defaultLanguage)throw e?new Error(v("defaultLanguage")):new Error(v("language"))})(),l.isRunning()||(E()&&y.invalidate(),l.setRunning(!0),h.run(E()),e=D()),Promise.resolve(e)},stop:function(){l.isRunning()&&(h.stop(),l.setRunning(!1))}}))},k=e=>{const n=w({options:e}),t=Object.freeze({setFinalFormatter:n.setFinalFormatter,addFormatter:n.addFormatter,setObserver:n.setObserver,hasObserver:n.hasObserver,setUi:n.setUi,hasUi:n.hasUi,setDevBackend:n.setDevBackend,addBackend:n.addBackend,setLanguageDetector:n.setLanguageDetector,setLanguageStorage:n.setLanguageStorage,overrideCredentials:n.overrideCredentials}),a=e=>{const t=n.isRunning();t&&n.stop(),e(),t&&n.run()},i=Object.freeze({on:n.on,onKeyUpdate:n.onKeyUpdate.listenSome,getLanguage:n.getLanguage,getPendingLanguage:n.getPendingLanguage,changeLanguage:n.changeLanguage,changeTranslation:n.changeTranslation,addActiveNs:n.addActiveNs,removeActiveNs:n.removeActiveNs,loadRecords:n.loadRecords,loadRecord:n.loadRecord,addStaticData:n.addStaticData,getRecord:n.getRecord,getAllRecords:n.getAllRecords,isLoaded:n.isLoaded,isInitialLoading:n.isInitialLoading,isLoading:n.isLoading,isFetching:n.isFetching,isRunning:n.isRunning,run:n.run,stop:n.stop,t:n.t,highlight:n.highlight,getInitialOptions:n.getInitialOptions,isDev:n.isDev,wrap:n.wrap,unwrap:n.unwrap,setObserverOptions:e=>(n.setObserverOptions(e),i),use:e=>(e&&a((()=>e(i,t))),i),init:e=>(a((()=>n.init(e))),i)});return i};function j(e,n,t,a){return new(t||(t=Promise))((function(i,o){function r(e){try{c(a.next(e))}catch(e){o(e)}}function s(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(r,s)}c((a=a.apply(e,n||[])).next())}))}function E(e,n){var t,a,i,o,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;r;)try{if(t=1,a&&(i=2&o[0]?a.return:o[0]?a.throw||((i=a.return)&&i.call(a),0):a.next)&&!(i=i.call(a,o[1])).done)return i;switch(a=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,a=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){r.label=o[1];break}if(6===o[0]&&r.label<i[1]){r.label=i[1],i=o;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(o);break}i[2]&&r.ops.pop(),r.trys.pop();continue}o=n.call(e,r)}catch(e){o=[6,e],a=0}finally{t=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function R(e){var n=this,t=e.message,a=e.recievingMessage,i=e.data,o=e.attempts,r=void 0===o?1:o,s=!1,c=function(){return new Promise((function(e,n){var o=function(e,n){var t=function(t){var a,i;e.includes(null===(a=t.data)||void 0===a?void 0:a.type)&&n(null===(i=t.data)||void 0===i?void 0:i.data)};return window.addEventListener("message",t,!1),{unsubscribe:function(){window.removeEventListener("message",t)}}}(a,(function(n){clearTimeout(r),s(),e(n)}));window.postMessage({type:t,data:i},window.origin);var r=setTimeout((function(){s(),n()}),300);function s(){o.unsubscribe()}}))};return{cancel:function(){return s=!0},promise:j(n,void 0,void 0,(function(){var e;return E(this,(function(n){switch(n.label){case 0:e=0,n.label=1;case 1:if(!(e<r))return[3,6];if(s)return[2,new Promise((function(){}))];n.label=2;case 2:return n.trys.push([2,4,,5]),[4,c()];case 3:return[2,n.sent()];case 4:return n.sent(),[3,5];case 5:return e++,[3,1];case 6:if(!s)throw"Didn't recieve ".concat(a.join(" or ")," in time.");return[2,new Promise((function(){}))]}}))}))}}var N=null;function D(e){var n;return N||(N=(n="".concat("https://cdn.jsdelivr.net/npm","/@tolgee/web@").concat(e||"latest","/dist/").concat("tolgee-in-context-tools.umd.min.js"),new Promise((function(e,t){var a=document.createElement("script");a.src=n,a.addEventListener("load",(function(){return e()})),a.addEventListener("error",(function(e){return t(e.error)})),document.body.appendChild(a)}))).then((function(){return window["@tolgee/in-context-tools"].InContextTools}))),N}var I="__tolgee_apiKey",S="__tolgee_apiUrl";function F(){var e=sessionStorage.getItem(I)||void 0,n=sessionStorage.getItem(S)||void 0;if(e&&n)return{apiKey:e,apiUrl:n}}function T(){sessionStorage.removeItem(I),sessionStorage.removeItem(S)}var A=function(){return function(e){return e}};"undefined"!=typeof window&&(A=function(){return function(e){var n,t=(n=void 0,{update:function(e){return j(this,void 0,void 0,(function(){var t,a,i;return E(this,(function(o){return null==n||n(),t=R({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:e,attempts:4}),a=t.cancel,i=t.promise,n=a,[2,i]}))}))}});return e.on("running",(function(n){var a;n.value&&(a=function(){t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(T)},"loading"!==document.readyState?Promise.resolve().then((function(){a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))})),F()&&j(void 0,void 0,void 0,(function(){var e;return E(this,(function(n){switch(n.label){case 0:return[4,D("rc")];case 1:return e=n.sent(),[2,function(n){var t=F();return n.use(e(t)),n}]}}))})).then((function(n){e.use(n)})).catch((function(){console.error("Tolgee: Failed to load in-context tools")})),e}});e.Tolgee=function(e){return k(e).use(A())},e.TolgeeCore=k,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=tolgee-web-tolgee.umd.min.js.map |
@@ -5,1 +5,2 @@ export * from './ContextUi'; | ||
export * from './typedIndex'; | ||
export { PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY, DEVTOOLS_ID, } from './constants'; |
{ | ||
"name": "@tolgee/web", | ||
"type": "module", | ||
"version": "4.10.0-rc.d26e1ca.0", | ||
"version": "4.10.0-rc.d9fac95.0", | ||
"description": "Tolgee for web", | ||
"main": "./dist/tolgee-web.cjs.js", | ||
"module": "./dist/tolgee-web.esm.mjs", | ||
"module": "./dist/tolgee-web.esm.js", | ||
"types": "./types/index.d.ts", | ||
@@ -31,3 +30,3 @@ "declaration": true, | ||
"dependencies": { | ||
"@tolgee/core": "^4.10.0-rc.d26e1ca.0" | ||
"@tolgee/core": "^4.10.0-rc.d9fac95.0" | ||
}, | ||
@@ -76,3 +75,3 @@ "devDependencies": { | ||
"require": "./dist/tolgee-web.cjs.js", | ||
"import": "./dist/tolgee-web.esm.mjs" | ||
"import": "./dist/tolgee-web.esm.js" | ||
}, | ||
@@ -90,3 +89,3 @@ "keywords": [ | ||
"homepage": "https://github.com/tolgee/tolgee-js#readme", | ||
"gitHead": "91c8672e0ef94597f994a61b802bfdf88f8d8bcb", | ||
"gitHead": "990ea6d89fdcd5abffceb250889edf4b08a9f42e", | ||
"publishConfig": { | ||
@@ -93,0 +92,0 @@ "access": "public" |
@@ -8,2 +8,4 @@ import type { InContextTools } from '../InContextTools'; | ||
const CDN_URL = 'https://cdn.jsdelivr.net/npm'; | ||
function injectScript(src: string) { | ||
@@ -24,5 +26,3 @@ return new Promise<void>((resolve, reject) => { | ||
injectPromise = injectScript( | ||
`https://unpkg.com/@tolgee/web@${ | ||
version || 'latest' | ||
}/dist/${IN_CONTEXT_FILE}` | ||
`${CDN_URL}/@tolgee/web@${version || 'latest'}/dist/${IN_CONTEXT_FILE}` | ||
).then(() => { | ||
@@ -29,0 +29,0 @@ // @ts-ignore |
@@ -5,1 +5,5 @@ export * from './ContextUi'; | ||
export * from './typedIndex'; | ||
export { | ||
PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY, | ||
DEVTOOLS_ID, | ||
} from './constants'; |
import { TolgeeElement } from '../../types'; | ||
import { DEVTOOLS_ID, ModifierKey } from '@tolgee/core'; | ||
import { ModifierKey } from '@tolgee/core'; | ||
import { DEVTOOLS_ID } from '../../constants'; | ||
import { ElementStoreType } from './ElementStore'; | ||
@@ -4,0 +5,0 @@ |
@@ -12,3 +12,3 @@ import { createElement } from 'react'; | ||
import { KeyContextMenu } from './KeyContextMenu/KeyContextMenu'; | ||
import { DEVTOOLS_ID } from './constants'; | ||
import { DEVTOOLS_ID } from '../constants'; | ||
@@ -15,0 +15,0 @@ export class UI implements UiInterface { |
import { | ||
MAX_LANGUAGES_SELECTED, | ||
PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY, | ||
} from '../constants'; | ||
} from '../../constants'; | ||
@@ -6,0 +6,0 @@ export function getPreferredLanguages(): string[] { |
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 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
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
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
33096118
103201
No