vendor: 5,031 bytes, lines 1-2
1/*! For license information please see deepl.js.LICENSE.txt */ 2(()=>{function e(){var n,a,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function l(e,r,o,i){var l=r&&r.prototype instanceof c?r:c,u=Object.create(l.prototype);return t(u,"_invoke",function(e,t,r){var o,i,l,c=0,u=r||[],d=!1,f={p:0,n:0,v:n,a:p,f:p.bind(n,4),d:function(e,t){return o=e,i=0,l=n,f.n=t,s}};function p(e,t){for(i=e,l=t,a=0;!d&&c&&!r&&a<u.length;a++){var r,o=u[a],p=f.p,h=o[2];e>3?(r=h===t)&&(l=o[(i=o[4])?5:(i=3,3)],o[4]=o[5]=n):o[0]<=p&&((r=e<2&&p<o[1])?(i=0,f.v=t,f.n=o[1]):p<h&&(r=e<3||o[0]>t||t>h)&&(o[4]=e,o[5]=t,f.n=h,i=0))}if(r||e>1)return s;throw d=!0,t}return function(r,u,h){if(c>1)throw TypeError("Generator is already running");for(d&&1===u&&p(u,h),i=u,l=h;(a=i<2?n:l)||!d;){o||(i?i<3?(i>1&&(f.n=-1),p(i,l)):f.n=l:f.v=l);try{if(c=2,o){if(i||(r="next"),a=o[r]){if(!(a=a.call(o,l)))throw TypeError("iterator result is not an object");if(!a.done)return a;l=a.value,i<2&&(i=0)}else 1===i&&(a=o.return)&&a.call(o),i<2&&(l=TypeError("The iterator does not provide a '"+r+"' method"),i=1);o=n}else if((a=(d=f.n<0)?l:e.call(t,f))!==s)break}catch(e){o=n,i=1,l=e}finally{c=1}}return{value:a,done:d}}}(e,o,i),!0),u}var s={};function c(){}function u(){}function d(){}a=Object.getPrototypeOf;var f=[][o]?a(a([][o]())):(t(a={},o,function(){return this}),a),p=d.prototype=c.prototype=Object.create(f);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,t(e,i,"GeneratorFunction")),e.prototype=Object.create(p),e}return u.prototype=d,t(p,"constructor",d),t(d,"constructor",u),u.displayName="GeneratorFunction",t(d,i,"GeneratorFunction"),t(p),t(p,i,"Generator"),t(p,o,function(){return this}),t(p,"toString",function(){return"[object Generator]"}),(e=function(){return{w:l,m:h}})()}function t(e,n,a,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}t=function(e,n,a,r){function i(n,a){t(e,n,function(e){return this._invoke(n,a,e)})}n?o?o(e,n,{value:a,enumerable:!r,configurable:!r,writable:!r}):e[n]=a:(i("next",0),i("throw",1),i("return",2))},t(e,n,a,r)}function n(e,t,n,a,r,o,i){try{var l=e[o](i),s=l.value}catch(e){return void n(e)}l.done?t(s):Promise.resolve(s).then(a,r)}function a(e){return function(){var t=this,a=arguments;return new Promise(function(r,o){var i=e.apply(t,a);function l(e){n(i,r,o,l,s,"next",e)}function s(e){n(i,r,o,l,s,"throw",e)}l(void 0)})}}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function o(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}function l(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,s(a.key),a)}}function s(e){var t=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,t||"default");if("object"!=r(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==r(t)?t:t+""}var c='a, address, b, blockquote, button, caption, code, dd, details, div, dt, em, figcaption, h1, h2, h3, h4, h5, h6, i, input[type="button"], input[type="reset"], input[type="submit"], label, legend, li, mark, p, pre, small, span, strong, summary, t, td, textarea, th, time',u=["alt","aria-label","placeholder","title"],d=function(){return t=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.debug=!1,this.originalTextMap=new Map,this.attributeTextMap=new Map,this.variablesTextMap=new Map,this.originalVariables=new Map,this.targetLang=null,this.abortController=null,this.selectElements=[],this.translatableVariables={wp_variables:["search_labels","sr_only_label"]},this.handleContentUpdated=this.handleContentUpdated.bind(this),this.handleSelectChange=this.handleSelectChange.bind(this),document.addEventListener("acato-deepl:content-change",function(e){var t=new CustomEvent("acato-deepl:content-updated",{detail:{element:null}});document.dispatchEvent(t)})},n=[{key:"log",value:function(){if(this.debug){for(var e,t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];
2(e=console).log.apply(e,["[Acato DeepL]"].concat(n))}}},{key:"isUrl",value:function(e){return/^https?:\/\//.test(e)||/:\/\//.test(e)}},{key:"wrapBareTextNodes",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body,t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null),n=function(){var e=t.currentNode;if(!e.matches(c))return 0;if(e.closest("#wpadminbar"))return 0;var n=Array.from(e.childNodes).filter(function(e){return e.nodeType===Node.TEXT_NODE&&e.textContent.trim().length>0});null==n||n.forEach(function(t){var n;if("T"!==(null===(n=t.parentElement)||void 0===n?void 0:n.tagName)&&1!==e.childNodes.length){var a=t.textContent,r=a.trim(),o=a!==r&&/^\s/.test(a),i=a!==r&&/\s$/.test(a),l=document.createElement("t");if(l.textContent=r,t.parentNode.insertBefore(l,t),i){var s=document.createTextNode(" ");t.parentNode.insertBefore(s,t)}if(o){var c=document.createTextNode(" ");t.parentNode.insertBefore(c,l)}t.parentNode.removeChild(t)}})};t.nextNode();)n()}},{key:"insertStyles",value:function(){var e=document.createElement("style");e.textContent="\n t {\n pointer-events: none;\n background: transparent;\n color: inherit;\n }\n ",document.head.appendChild(e)}},{key:"processObjectRecursively",value:function(e,t){var n,a=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],l=!1;return null===(n=Object.keys(e))||void 0===n||n.forEach(function(n){var s=e[n],c=[].concat(o(i),[n]);if(!n.toLowerCase().includes("nonce")&&!n.toLowerCase().includes("rest"))if("object"!==r(s)||null===s||Array.isArray(s)){if("string"==typeof s&&s.trim().length>0){if(a.isUrl(s))return;var u=s.trim().replace(/\s\s+/g," ");if(a.variablesTextMap.get(u)){var d=a.variablesTextMap.get(u);d?d.some(function(e){return e.windowVarName===t&&JSON.stringify(e.path)===JSON.stringify(c)})||d.push({windowVarName:t,path:c}):a.variablesTextMap.set(u,[{windowVarName:t,path:c}])}else a.variablesTextMap.set(u,[{windowVarName:t,path:c}]),l=!0}}else{var f=a.processObjectRecursively(s,t,c);l=l||f}}),l}},{key:"saveJavaScriptVariables",value:function(){var e=this,t=!1;return Object.keys(this.translatableVariables).forEach(function(n){var a=window[n];if(a){e.originalVariables.has(n)||e.originalVariables.set(n,JSON.parse(JSON.stringify(a)));var o=e.translatableVariables[n];null==o||o.forEach(function(o){var i=a[o];if(i)if("object"!==r(i)||Array.isArray(i)){if("string"==typeof i&&i.trim().length>0){if(o.toLowerCase().includes("nonce")||e.isUrl(i))return;var l=i.trim().replace(/\s\s+/g," ");if(e.variablesTextMap.get(l)){var s=e.variablesTextMap.get(l);s&&(s.some(function(e){return e.windowVarName===n&&JSON.stringify(e.path)===JSON.stringify([o])})||s.push({windowVarName:n,path:[o]}))}else e.variablesTextMap.set(l,[{windowVarName:n,path:[o]}]),t=!0}}else{var c=e.processObjectRecursively(i,n,[o]);t=t||c}})}}),t}},{key:"saveOriginalText",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;this.wrapBareTextNodes(t);var n=t===document.body?document.querySelectorAll(c):t.querySelectorAll(c),a=u.map(function(e){return"[".concat(e,"]")}).join(", "),r=t===document.body?document.querySelectorAll(a):t.querySelectorAll(a),i=new Set([].concat(o(n),o(r)));if(0===i.size)return!1;var l=!1;return i.forEach(function(t){if(t instanceof HTMLElement){if(t.closest("#wpadminbar"))return;var n=Array.from(t.childNodes).filter(function(e){return e.nodeType===Node.TEXT_NODE||e.nodeType===Node.ELEMENT_NODE&&"BR"===e.nodeName}).map(function(e){var t;return null===(t=e.textContent)||void 0===t?void 0:t.trim()}).join(" ").trim();if(n&&n.length>2){var a=n.replace(/\s\s+/g," ");if(e.originalTextMap.get(a)){var r=e.originalTextMap.get(a);r&&!r.includes(t)&&r.push(t)}else"true"!==t.dataset.deeplTranslated&&(e.originalTextMap.set(a,[t]),l=!0)}u.forEach(function(n){var a=t.getAttribute(n);if(a&&a.trim().length>2){var r=a.trim().replace(/\s\s+/g," "),o="".concat(r);if(e.originalTextMap.get(o)){var i=e.attributeTextMap.get(o);i&&(i.some(function(e){return e.element===t&&e.attribute===n})||i.push({element:t,attribute:n}))}else"true"!==t.dataset["deepl".concat(n.replace(/-./g,function(e){return e[1].toUpperCase()}),"Translated")]&&(e.attributeTextMap.set(o,[{element:t,attribute:n}]),l=!0)}})}}),l}},{key:"handleSelectChange",value:function(e){var t,n,a,r=e.target,o=r.value;
2this.selectElements.forEach(function(e){e!==r&&(e.value=o)});var i=(null===(t=window.AcatoDeepL)||void 0===t||null===(t=t.default_language)||void 0===t?void 0:t.iso_alpha2)||(null===(n=r.options[0])||void 0===n?void 0:n.value),l=r.options[r.selectedIndex],s=(null==l||null===(a=l.dataset)||void 0===a?void 0:a.dir)||"ltr",c=o===i;c?(window.sessionStorage.removeItem("AcatoDeepLSelectedLanguage"),this.revertToOriginalText(),this.setDirection(s)):(window.sessionStorage.setItem("AcatoDeepLSelectedLanguage",o),this.targetLang=o,this.translatePage()),this.updateUrlForLanguage(o,c)}},{key:"isTranslated",value:function(e){return"true"===e.dataset.deeplTranslated}},{key:"revertToOriginalText",value:function(){if(this.originalTextMap.forEach(function(e,t){return e.forEach(function(e){e.textContent=t,e.dataset.deeplTranslated="false"})}),this.attributeTextMap.forEach(function(e,t){return e.forEach(function(e){var n=e.element,a=e.attribute;n.setAttribute(a,t),n.dataset["deepl".concat(a.replace(/-./g,function(e){return e[1].toUpperCase()}),"Translated")]="false"})}),this.originalVariables.size>
20){this.originalVariables.forEach(function(e,t){window[t]&&(window[t]=JSON.parse(JSON.stringify(e)))});var e=new CustomEvent("acato-deepl:variables-translated");document.dispatchEvent(e)}}},{key:"translatePage",value:(d=a(e().m(function t(){var n,a,r,o;return e().w(function(e){for(;;)switch(e.n){case 0:return n=Array.from(this.originalTextMap.keys()),a=Array.from(this.attributeTextMap.keys()),r=Array.from(this.variablesTextMap.keys()),o=[].concat(n,a,r),e.n=1,this.translateText(o,this.targetLang);case 1:return e.a(2)}},t,this)})),function(){return d.apply(this,arguments)})},{key:"translateText",value:(s=a(e().m(function t(n,a){var r,o,i,l,s,c,u,d;return e().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=window.AcatoDeepL,o=r.rest_endpoint,i=r.rest_nonce,this.abortController&&this.abortController.abort(),this.abortController=new AbortController,l={"Content-Type":"application/json","X-DeepL-Nonce":i},e.p=1,e.n=2,fetch(o,{method:"POST",headers:l,credentials:"include",signal:this.abortController.signal,body:JSON.stringify({text:n,target_lang:a})});case 2:if((c=e.v).ok){e.n=3;break}throw new Error("Request failed with status: ".concat(c.status));case 3:return e.n=4,c.json();case 4:u=e.v,document.documentElement.lang=a,this.applyTranslations(u.data||[]),this.setDirection((null==u||null===(s=u.lang)||void 0===s?void 0:s.dir)||"ltr"),e.n=6;break;case 5:e.p=5,"AbortError"!==(d=e.v).name&&console.error(d);case 6:return e.a(2)}},t,this,[[1,5]])})),function(e,t){return s.apply(this,arguments)})},{key:"applyTranslations",value:function(e){var t=this;if(null==e||e.forEach(function(e){var n=t.originalTextMap.get(e.text);n&&n.forEach(function(t){t.textContent=null==e?void 0:e.translation,t.dataset.deeplTranslated="true"});var a=t.attributeTextMap.get(e.text);a&&a.forEach(function(t){var n=t.element,a=t.attribute;n.setAttribute(a,null==e?void 0:e.translation),n.dataset["deepl".concat(a.replace(/-./g,function(e){return e[1].toUpperCase()}),"Translated")]="true"});var r=t.variablesTextMap.get(e.text);r&&r.forEach(function(n){var a=n.windowVarName,r=n.path,o=window[a];if(o){for(var i=o,l=0;l<r.length-1;l++){if(void 0===i[r[l]])return;i=i[r[l]]}var s=r[r.length-1];i&&s&&(t.log("Translating ".concat(a,".").concat(r.join("."),': "').concat(e.text,'" -> "').concat(null==e?void 0:e.translation,'"')),i[s]=null==e?void 0:e.translation)}})}),this.variablesTextMap.size>0){var n=new CustomEvent("acato-deepl:variables-translated");document.dispatchEvent(n),this.log("Dispatched acato-deepl:variables-translated event")}}},{key:"setDirection",value:function(e){document.documentElement.dir=e,this.log("Set document direction to ".concat(e))}},{key:"initializeSelect",value:function(){var e=this;this.selectElements=Array.from(document.querySelectorAll(".acato-deepl-translate-select")),0!==this.selectElements.length?this.selectElements.forEach(function(t){t.addEventListener("change",e.handleSelectChange);var n=window.sessionStorage.getItem("AcatoDeepLSelectedLanguage");n&&(t.value=n)}):this.log("No translate select elements found with class 'acato-deepl-translate-select'")}},{key:"handleContentUpdated",value:function(e){var t,n=null==e||null===(t=e.detail)||void 0===t?void 0:t.element;(n?this.saveOriginalText(n):this.saveOriginalText(document.body))&&this.targetLang&&this.translatePage()}},{key:"getLanguageFromUrl",value:function(){var e,t=new URLSearchParams(window.location.search).get("lang");if(!t||0===this.selectElements.length)return null;var n=t.toUpperCase().trim(),a=Array.from((null===(e=this.selectElements[0])||void 0===e?void 0:e.options)||[]).map(function(e){return e.value}).filter(function(e){return e});if(0===a.length)return null;var r=a.find(function(e){return e.toUpperCase()===n});if(r)return this.log("URL language parameter matched exactly: ".concat(t," -> ").concat(r)),r;var o=n.split("-")[0],i=a.find(function(e){return e.toUpperCase().split("-")[0]===o});return i?(this.log("URL language parameter matched variant: ".concat(t," -> ").concat(i)),i):(this.log("URL language parameter not found: ".concat(t)),null)}},{key:"addLangToUrl",value:function(e){if(window.history&&window.history.replaceState){var t=new URLSearchParams(window.location.search);t.set("lang",e);var n=t.toString(),a=window.location.pathname+(n?"?"+n:"")+window.location.hash;window.history.replaceState({},"",a),this.log("Added/updated lang parameter in URL: ".concat(a))}else console.log("Could not update URL with lang parameter because History API is not supported in this browser.")}},{key:"removeLangFromUrl",value:function(){if(window.history&&window.history.replaceState){var e=new URLSearchParams(window.location.search);if(e.has("lang")){e.delete("lang");var t=e.toString(),n=window.location.pathname+(t?"?"+t:"")+window.location.hash;window.history.replaceState({},"",n),this.log("Removed lang parameter from URL: ".concat(n))}}}},{key:"updateUrlForLanguage",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=(null===(t=window.AcatoDeepL)||void 0===t?void 0:t.url_handling)||"leave";n?"add"!==a&&"remove"!==a||this.removeLangFromUrl():(console.log(a),"add"===a?this.addLangToUrl(e):"remove"===a&&this.removeLangFromUrl())}},{key:"init",value:function(){var e,t=document.body;if("true"!==t.dataset.acatoDeeplInitialized){t.dataset.acatoDeeplInitialized="true",this.initializeSelect(),this.insertStyles(),this.saveOriginalText(),this.saveJavaScript
2Variables();var n=null===(e=this.selectElements[0])||void 0===e||null===(e=e.options[0])||void 0===e?void 0:e.value,a=this.getLanguageFromUrl(),r=window.sessionStorage.getItem("AcatoDeepLSelectedLanguage"),o=null;a&&a!==n?(o=a,window.sessionStorage.setItem("AcatoDeepLSelectedLanguage",a),this.selectElements.forEach(function(e){e.value=a}),this.updateUrlForLanguage(a,!1)):r&&r!==n&&(o=r,this.updateUrlForLanguage(r,!1)),o&&(this.targetLang=o,this.translatePage()),document.addEventListener("acato-deepl:content-updated",this.handleContentUpdated,!0)}}}],n&&l(t.prototype,n),i&&l(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,n,i,s,d}();"loading"===document.readyState?document.addEventListener("DOMContentLoaded",function(){(new d).init()}):(new d).init()})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.