mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-30 16:02:54 +00:00
9ee816a919
According to the docs:
The Element.append() method inserts a set of Node objects or string
objects after the last child of the Element.
String objects are inserted as equivalent Text nodes.
When given a string we want to treat these as HTML
Also fix the storybook which hinted at this being a problem
(incorrectly fixed in 504eefcc1
)
Bug: T341318
Change-Id: I415c9821a6a37b45cf0f8a65f58a41bc7d0a042d
2 lines
46 KiB
JavaScript
2 lines
46 KiB
JavaScript
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="./src/index.js")}({"./node_modules/@babel/runtime/helpers/arrayLikeToArray.js":function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},"./node_modules/@babel/runtime/helpers/arrayWithHoles.js":function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},"./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js":function(e,t,n){var r=n("./node_modules/@babel/runtime/helpers/arrayLikeToArray.js");e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},"./node_modules/@babel/runtime/helpers/defineProperty.js":function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},"./node_modules/@babel/runtime/helpers/iterableToArray.js":function(e,t){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},"./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js":function(e,t){e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return i}},e.exports.__esModule=!0,e.exports.default=e.exports},"./node_modules/@babel/runtime/helpers/nonIterableRest.js":function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},"./node_modules/@babel/runtime/helpers/nonIterableSpread.js":function(e,t){e.exports=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.")},e.exports.__esModule=!0,e.exports.default=e.exports},"./node_modules/@babel/runtime/helpers/slicedToArray.js":function(e,t,n){var r=n("./node_modules/@babel/runtime/helpers/arrayWithHoles.js"),o=n("./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js"),i=n("./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js"),a=n("./node_modules/@babel/runtime/helpers/nonIterableRest.js");e.exports=function(e,t){return r(e)||o(e,t)||i(e,t)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},"./node_modules/@babel/runtime/helpers/toConsumableArray.js":function(e,t,n){var r=n("./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js"),o=n("./node_modules/@babel/runtime/helpers/iterableToArray.js"),i=n("./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js"),a=n("./node_modules/@babel/runtime/helpers/nonIterableSpread.js");e.exports=function(e){return r(e)||o(e)||i(e)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},"./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":function(e,t,n){var r=n("./node_modules/@babel/runtime/helpers/arrayLikeToArray.js");e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.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)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},"./node_modules/redux-thunk/dist/redux-thunk.min.js":function(e,t,n){e.exports=function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t){"use strict";function n(e){return function(t){var n=t.dispatch,r=t.getState;return function(t){return function(o){return"function"==typeof o?o(n,r,e):t(o)}}}}t.__esModule=!0;var r=n();r.withExtraArgument=n,t.default=r}])},"./node_modules/redux/dist/redux.min.js":function(e,t,n){(function(e,n){!function(t){"use strict";var r=function(e){var t,n=e.Symbol;return"function"==typeof n?n.observable?t=n.observable:(t=n("observable"),n.observable=t):t="@@observable",t}("undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==e?e:n),o=function(){return Math.random().toString(36).substring(7).split("").join(".")},i={INIT:"@@redux/INIT"+o(),REPLACE:"@@redux/REPLACE"+o(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+o()}};function a(e,t){var n=t&&t.type;return"Given "+(n&&'action "'+n+'"'||"an action")+', reducer "'+e+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.'}function s(e,t){return function(){return t(e.apply(this,arguments))}}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}t.createStore=function e(t,n,o){var a;if("function"==typeof n&&"function"==typeof o||"function"==typeof o&&"function"==typeof arguments[3])throw Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function");if("function"==typeof n&&void 0===o&&(o=n,n=void 0),void 0!==o){if("function"!=typeof o)throw Error("Expected the enhancer to be a function.");return o(e)(t,n)}if("function"!=typeof t)throw Error("Expected the reducer to be a function.");var s=t,u=n,c=[],l=c,p=!1;function d(){l===c&&(l=c.slice())}function f(){if(p)throw Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return u}function m(e){if("function"!=typeof e)throw Error("Expected the listener to be a function.");if(p)throw Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");var t=!0;return d(),l.push(e),function(){if(t){if(p)throw Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");t=!1,d();var n=l.indexOf(e);l.splice(n,1)}}}function w(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(p)throw Error("Reducers may not dispatch actions.");try{p=!0,u=s(u,e)}finally{p=!1}for(var t=c=l,n=0;t.length>n;n++)(0,t[n])();return e}return w({type:i.INIT}),(a={dispatch:w,subscribe:m,getState:f,replaceReducer:function(e){if("function"!=typeof e)throw Error("Expected the nextReducer to be a function.");s=e,w({type:i.REPLACE})}})[r]=function(){var e,t=m;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function n(){e.next&&e.next(f())}return n(),{unsubscribe:t(n)}}})[r]=function(){return this},e},a},t.combineReducers=function(e){for(var t=Object.keys(e),n={},r=0;t.length>r;r++){var o=t[r];"function"==typeof e[o]&&(n[o]=e[o])}var s,u=Object.keys(n);try{!function(e){Object.keys(e).forEach((function(t){var n=e[t];if(void 0===n(void 0,{type:i.INIT}))throw Error('Reducer "'+t+"\" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.");if(void 0===n(void 0,{type:i.PROBE_UNKNOWN_ACTION()}))throw Error('Reducer "'+t+"\" returned undefined when probed with a random type. Don't try to handle "+i.INIT+' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.')}))}(n)}catch(e){s=e}return function(e,t){if(void 0===e&&(e={}),s)throw s;for(var r=!1,o={},i=0;u.length>i;i++){var c=u[i],l=e[c],p=(0,n[c])(l,t);if(void 0===p){var d=a(c,t);throw Error(d)}o[c]=p,r=r||p!==l}return r?o:e}},t.bindActionCreators=function(e,t){if("function"==typeof e)return s(e,t);if("object"!=typeof e||null===e)throw Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":typeof e)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var n=Object.keys(e),r={},o=0;n.length>o;o++){var i=n[o],a=e[i];"function"==typeof a&&(r[i]=s(a,t))}return r},t.applyMiddleware=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return function(e){return function(){var n=e.apply(void 0,arguments),r=function(){throw Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},o={getState:n.getState,dispatch:function(){return r.apply(void 0,arguments)}},i=t.map((function(e){return e(o)}));return function(e){for(var t=1;arguments.length>t;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){u(e,t,n[t])}))}return e}({},n,{dispatch:r=c.apply(void 0,i)(n.dispatch)})}}},t.compose=c,t.__DO_NOT_USE__ActionTypes=i,Object.defineProperty(t,"__esModule",{value:!0})}(t)}).call(this,n("./node_modules/webpack/buildin/global.js"),n("./node_modules/webpack/buildin/module.js")(e))},"./node_modules/webpack/buildin/global.js":function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},"./node_modules/webpack/buildin/module.js":function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},"./src/canSaveToUserPreferences.js":function(e,t){e.exports=function(e){return!e.isAnon()&&e.isNamed()}},"./src/index.js":function(e,t,n){"use strict";n.r(t);var r={};n.r(r),n.d(r,"boot",(function(){return Fe})),n.d(r,"fetch",(function(){return Ue})),n.d(r,"linkDwell",(function(){return We})),n.d(r,"abandon",(function(){return Xe})),n.d(r,"linkClick",(function(){return Be})),n.d(r,"previewDwell",(function(){return Ve})),n.d(r,"previewShow",(function(){return Ke})),n.d(r,"pageviewLogged",(function(){return $e})),n.d(r,"showSettings",(function(){return ze})),n.d(r,"hideSettings",(function(){return Ze})),n.d(r,"saveSettings",(function(){return Je})),n.d(r,"statsvLogged",(function(){return Qe}));var o=n("./node_modules/@babel/runtime/helpers/defineProperty.js"),i=n.n(o),a=n("./node_modules/redux/dist/redux.min.js"),s=n("./node_modules/redux-thunk/dist/redux-thunk.min.js"),u=n.n(s),c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.devicePixelRatio;return e?e>1.5?2:e>1?1.5:1:1}(),l={BRACKETED_DEVICE_PIXEL_RATIO:c,THUMBNAIL_SIZE:320*Math.max(c,1.5),EXTRACT_LENGTH:525},p={TYPE_GENERIC:"generic",TYPE_PAGE:"page",TYPE_DISAMBIGUATION:"disambiguation",TYPE_REFERENCE:"reference"};function d(e,t,n,r,o,i,a,s){var u=function(e){if(null==e||0===e.length)return;return e}(o);return{title:e,url:t,languageCode:n,languageDirection:r,extract:u,type:function(e,t){if(void 0===t)return p.TYPE_GENERIC;switch(e){case p.TYPE_GENERIC:case p.TYPE_DISAMBIGUATION:case p.TYPE_PAGE:return e;default:return p.TYPE_PAGE}}(i,u),thumbnail:a,pageId:s}}function f(e,t){return d(e,t,"","",[],"")}var m=[];function w(e){var t=m.filter((function(t){return n=e,r=t.selector,n.matches(r);var n,r}));return t.length>0?t[t.length-1].name:null}var h=[];function g(e,t){h.push(t),m.push({name:e,selector:t})}function v(e,t){var n=e;return void 0===e||0===n.length?[]:n=function(e,t){var n=[],r="<bi-".concat(Math.random(),">"),o="<snip-".concat(Math.random(),">");t=t.replace(/\s+/g," ").trim();var i=mw.util.escapeRegExp(t),a=new RegExp("(^|\\s)(".concat(i,")(|$)"),"i");return(e=(e=(e=e.replace(/\s+/," ")).replace(a,"$1".concat(o).concat(r,"$2").concat(o,"$3"))).split(o)).forEach((function(e){if(0===e.indexOf(r)){var t=document.createElement("b");t.textContent=e.slice(r.length),n.push(t)}else n.push(document.createTextNode(e))})),n}(n,t)}function y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};return e.promise?e.promise({abort:t}):(e.abort=t,e)}var b={};function E(e,t){b[e]=t}function x(e){if(e.query&&e.query.pages&&e.query.pages.length)return e.query.pages[0];throw new Error("API response `query.pages` is empty.")}function T(e){var t=Object.assign({},e);return t.extract=v(e.extract,e.title),t}function P(e){return d(e.title,e.canonicalurl,e.pagelanguagehtmlcode,e.pagelanguagedir,e.extract,e.type,e.thumbnail,e.pageid)}function S(e,t,n){function r(n){var r=t.endpoint;return e({url:r+encodeURIComponent(n),headers:{Accept:'application/json; charset=utf-8; profile="'.concat("https://www.mediawiki.org/wiki/Specs/Summary/1.2.0",'"'),"Accept-Language":t.acceptLanguage}})}return{fetch:r,convertPageToModel:k,fetchPreviewForTitle:function(e){var o=e.getPrefixedDb(),i=r(o);return y(i.then((function(e){return(e=e||{}).title=e.title||o,e.extract=e.extract||"",k(e,t.THUMBNAIL_SIZE,n)})).catch((function(e,t,n){return Promise.reject("http",{xhr:e,textStatus:t,exception:n})})),(function(){return i.abort()}))}}}function _(e,t,n){var r=e.source.split("/"),o=r[r.length-1],i=function(e){return new RegExp(/\.(jpg|jpeg|png|gif)$/i).test(e)}(t.source)||void 0,a=o.indexOf("px-");if(-1===a)return i&&t;var s,u,c=o.slice(a+3);return e.width>e.height?(s=n,u=Math.floor(n/e.width*e.height)):(s=Math.floor(n/e.height*e.width),u=n),s>=t.width&&-1===c.indexOf(".svg")?i&&t:(r[r.length-1]="".concat(s,"px-").concat(c),{source:r.join("/"),width:s,height:u})}function k(e,t,n){return d(e.title,new mw.Title(e.title).getUrl(),e.lang,e.dir,n(e),e.type,e.thumbnail?_(e.thumbnail,e.originalimage,t):void 0,e.pageid)}function A(e){var t=e.extract_html,n=document.createElement("div");return n.innerHTML=t,0===t.length?[]:n.childNodes}function L(e){return v(e.extract,e.title)}function j(e){var t=new AbortController,n=t.signal;return y(fetch(e.url,{headers:e.headers,signal:n}).then((function(e){return e.json()})),(function(){t.abort()}))}function I(e){var t=Object.assign({},l,{acceptLanguage:e.get("wgPageContentLanguage")}),n=Object.assign({},t,{endpoint:e.get("wgPopupsRestGatewayEndpoint")});switch(e.get("wgPopupsGateway")){case"mwApiPlain":return function(e,t){function n(n){return e.get({action:"query",prop:"info|extracts|pageimages|revisions|info",formatversion:2,redirects:!0,exintro:mw.config.get("wgPopupsTextExtractsIntroOnly",!0),exchars:t.EXTRACT_LENGTH,explaintext:!0,exsectionformat:"plain",piprop:"thumbnail",pithumbsize:t.THUMBNAIL_SIZE,pilicense:"any",rvprop:"timestamp",inprop:"url",titles:n,smaxage:300,maxage:300,uselang:"content"},{headers:{"X-Analytics":"preview=1","Accept-Language":t.acceptLanguage}})}return{fetch:n,extractPageFromResponse:x,convertPageToModel:P,fetchPreviewForTitle:function(e){var t=n(e.getPrefixedDb());return y(t.then((function(e){return P(T(x(e)))})),(function(){return t.abort()}))},formatPlainTextExtract:T}}(new mw.Api,t);case"restbasePlain":return S(j,n,L);case"restbaseHTML":return S(j,n,A);default:throw new Error("Unknown gateway")}}function R(){return{fetchPreviewForTitle:function(e,t){var n=e.getFragment().replace(/ /g,"_"),r=function(e){var t="#".concat(CSS.escape(e));return document.querySelector("".concat(t," .mw-reference-text, ").concat(t," .reference-text"))}(n);if(!r||!r.textContent.trim()&&!r.children.length)return Promise.reject({textStatus:"abort",textContext:"Footnote not found or empty",xhr:{readyState:0}});var o,i,a,s,u={url:"#".concat(n),extract:r.innerHTML,type:p.TYPE_REFERENCE,referenceType:(o=r,i=["book","journal","news","note","web"],a=null,s=o.querySelectorAll("cite[class]"),Array.prototype.forEach.call(s,(function(e){if(!a)for(var t=e.className.split(/\s+/),n=t.length;n--;)if(-1!==i.indexOf(t[n]))return a=t[n],!1})),a),sourceElementId:t.parentNode.id};return y(Promise.resolve(u))}}}var C=n("./src/canSaveToUserPreferences.js");function O(e){return mw.html.escape(e)}var N={};function H(e){if(!N[e]){var t=document.createElement("div");t.innerHTML=e,N[e]=t.firstElementChild}return N[e].cloneNode(!0)}function M(e){var t=O(e.heading),n=O(e.saveLabel),r=O(e.closeLabel),o=O(e.helpText),i=O(e.okLabel),a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.map((function(e){var t=e.id,n=e.name,r=e.description,o=e.isChecked;return{id:O(t),name:O(n),description:r?O(r):"",isChecked:o}}))}(e.choices),s=document.createElement("div");return s.innerHTML="\n\t\t<section id='mwe-popups-settings'>\n\t\t\t<header>\n\t\t\t\t<div>\n\t\t\t\t\t<div class='mw-ui-icon mw-ui-icon-element mw-ui-icon-popups-close close'>".concat(r,"</div>\n\t\t\t\t</div>\n\t\t\t\t<h1>").concat(t,"</h1>\n\t\t\t\t<div>\n\t\t\t\t\t<button class='save mw-ui-button mw-ui-progressive'>").concat(n,"</button>\n\t\t\t\t\t<button class='okay mw-ui-button mw-ui-progressive' style='display:none;'>").concat(i,"</button>\n\t\t\t\t</div>\n\t\t\t</header>\n\t\t\t<main id='mwe-popups-settings-form'>\n\t\t\t\t<form>\n\t\t\t\t\t").concat(a.map((function(e){var t=e.id,n=e.name,r=e.description,o=e.isChecked;return'\n\t\t\t\t\t<p class="mw-ui-checkbox">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t'.concat(o?"checked":"","\n\t\t\t\t\t\t\tvalue='").concat(t,"'\n\t\t\t\t\t\t\ttype='checkbox'\n\t\t\t\t\t\t\tid='mwe-popups-settings-").concat(t,"'>\n\t\t\t\t\t\t<label for='mwe-popups-settings-").concat(t,"'>\n\t\t\t\t\t\t\t<span>").concat(n,"</span>\n\t\t\t\t\t\t\t").concat(r,"\n\t\t\t\t\t\t</label>\n\t\t\t\t\t</p>")})).join(""),"\n\t\t\t\t</form>\n\t\t\t</main>\n\t\t\t<div class='mwe-popups-settings-help' style='display:none;'>\n\t\t\t\t<div class=\"mw-ui-icon mw-ui-icon-element mw-ui-icon-footer\"></div>\n\t\t\t\t<p>").concat(o,"</p>\n\t\t\t</div>\n\t\t</section>\n\t").trim(),s.querySelector("section")}function D(e){var t,n;return function(r){return t||(t=function(e){var t=[{id:p.TYPE_PAGE,name:mw.msg("popups-settings-option-page"),description:mw.msg("popups-settings-option-page-description")},{id:p.TYPE_REFERENCE,name:mw.msg("popups-settings-option-reference"),description:mw.msg("popups-settings-option-reference-description")}];return e||t.splice(1,1),M({heading:mw.msg("popups-settings-title"),closeLabel:mw.msg("popups-settings-cancel"),saveLabel:mw.msg("popups-settings-save"),helpText:mw.msg("popups-settings-help"),okLabel:mw.msg("popups-settings-help-ok"),choices:t})}(e),(n=document.createElement("div")).classList.add("mwe-popups-overlay"),t.querySelector(".save").addEventListener("click",(function(){var e={};Array.prototype.forEach.call(t.querySelectorAll("input"),(function(t){e[t.value]=t.matches(":checked")})),r.saveSettings(e)})),t.querySelector(".close").addEventListener("click",r.hideSettings),t.querySelector(".okay").addEventListener("click",r.hideSettings)),{appendTo:function(e){e.appendChild(n),n.appendChild(t)},show:function(){n.style.display=""},hide:function(){n.style.display="none"},toggleHelp:function(e){!function(e,t){t?(q(e.querySelectorAll("main, .save, .close")),Y(e.querySelectorAll(".mwe-popups-settings-help, .okay"))):(Y(e.querySelectorAll("main, .save, .close")),q(e.querySelectorAll(".mwe-popups-settings-help, .okay")))}(t,e)},setEnabled:function(e){Object.keys(e).forEach((function(n){var r=t.querySelector("#mwe-popups-settings-".concat(n));r&&(r.checked=e[n])}))}}}}function q(e){Array.prototype.forEach.call(e,(function(e){e.style.display="none"}))}function Y(e){Array.prototype.forEach.call(e,(function(e){e.style.display=""}))}function F(e,t){var n;e.subscribe((function(){var r=e.getState();n!==r&&(t(n,r),n=r)}))}var G=n("./src/canSaveToUserPreferences.js");function U(e,t){if(e.dataset.title)return mw.Title.newFromText(e.dataset.title);if(function(e){return e.hash&&e.host===location.host&&e.pathname===location.pathname&&e.search===location.search}(e))try{return mw.Title.newFromText(t.get("wgPageName")+decodeURIComponent(e.hash))}catch(e){return null}return function(e,t){if(!e)return null;var n=mw.Title.newFromText(e);return n&&t.indexOf(n.namespace)>=0?n:null}(function(e,t){var n;try{n=new mw.Uri(e)}catch(e){return}if(n.host===location.hostname){var r,o=Object.keys(n.query).length;if(o)1===o&&"title"in n.query&&(r=n.query.title);else{var i=mw.util.escapeRegExp(t.get("wgArticlePath")).replace("\\$1","([^?#]+)"),a=new RegExp(i).exec(n.path);try{r=a&&decodeURIComponent(a[1])}catch(e){}}return r?"".concat(r).concat(n.fragment?"#".concat(n.fragment):""):void 0}}(e.href,t),t.get("wgContentNamespaces"))}function W(e){return new Promise((function(t){setTimeout((function(){t()}),e)}))}var X=n("./src/ui/pointer-mask.svg"),B=n.n(X),V={h:250,w:203},K={h:200,w:320};function $(e,t){var n=l.BRACKETED_DEVICE_PIXEL_RATIO;if(!e)return null;var r=e.width/n,o=e.height/n,i=e.height>e.width||r<K.w;if(i&&o<V.h&&e.height<V.h||e.source.indexOf("\\")>-1||e.source.indexOf("'")>-1||e.source.indexOf('"')>-1)return null;var a,s,u,c,p=r/o,d=p>.7&&p<1.3;i?(a=r>V.w?(r-V.w)/-2:V.w-r,s=o>V.h?(o-V.h)/-2:0,u=V.w,c=V.h,r<u&&(a=0,u=r)):(a=0,s=o>K.h?(o-K.h)/-2:0,u=K.w,c=o>K.h?K.h:o);var f,m,w=i&&r<V.w;return{el:t?(f=e.source,(m=document.createElement("img")).className="mwe-popups-thumbnail",m.src=f,m):function(e,t,n,r,o,i,a,s){var u="http://www.w3.org/2000/svg",c=document.createElementNS(u,"polyline"),l=-1===e.indexOf("not-tall")?[0,0,0,s]:[0,s-1,a,s-1];c.setAttribute("stroke","rgba(0,0,0,0.1)"),c.setAttribute("points",l.join(" ")),c.setAttribute("stroke-width",1);var p=document.createElementNS(u,"image");p.setAttributeNS("http://www.w3.org/1999/xlink","href",t),p.classList.add(e),z(p,{x:n,y:r,width:o,height:i});var d=document.createElementNS(u,"svg");return z(d,{xmlns:u,width:a,height:s}),d.appendChild(p),d.appendChild(c),d}(i?"mwe-popups-is-tall":"mwe-popups-is-not-tall",e.source,a,s,r,o,u,c),isTall:i||d,isNarrow:w,offset:w?V.w-r:0,width:r,height:o}}var z=function(e,t){Object.keys(t).forEach((function(n){e.setAttribute(n,t[n])}))};function Z(e,t){var n=H('\n\t<div class="mwe-popups" aria-hidden></div>\n');return n.className="mwe-popups mwe-popups-type-".concat(e),t.className="mwe-popups-container",n.appendChild(t),n}function J(e,t,n,r){var o=Z(e.type,H('\n\t<div class="mwe-popups-container">\n\t\t<div class="mw-ui-icon mw-ui-icon-element"></div>\n\t\t<strong class="mwe-popups-title"></strong>\n\t\t<a class="mwe-popups-extract">\n\t\t\t<span class="mwe-popups-message"></span>\n\t\t</a>\n\t\t<footer>\n\t\t\t<a class="mwe-popups-read-link"></a>\n\t\t</footer>\n\t</div>\n'));o.querySelector(".mw-ui-icon").classList.add("mw-ui-icon-preview-".concat(e.type)),o.querySelector(".mwe-popups-extract").setAttribute("href",e.url),o.querySelector(".mwe-popups-message").innerHTML=O(n);var i=o.querySelector(".mwe-popups-read-link");i.innerHTML=O(r),i.setAttribute("href",e.url);var a=o.querySelector(".mwe-popups-title");return t?a.innerHTML=O(e.title):a.remove(),o}var Q=!1,ee="event.ReferencePreviewsPopups";function te(){return Q}var ne=function(e,t){"string"==typeof t?e.insertAdjacentHTML("afterend",t):e.parentNode.appendChild(t),e.remove()};function re(e){var t=e.referenceType||"generic",n=mw.message("popups-refpreview-".concat(t));n.exists()||(n=mw.message("popups-refpreview-reference"));var r=Z(e.type,H('\n<div class="mwe-popups-container">\n <div class="mwe-popups-extract">\n <div class="mwe-popups-scroll">\n <strong class="mwe-popups-title">\n <span class="mw-ui-icon mw-ui-icon-element"></span>\n <span class="mwe-popups-title-placeholder"></span>\n </strong>\n <div class="mw-parser-output"></div>\n </div>\n <div class="mwe-popups-fade"></div>\n </div>\n\t<footer>\n\t\t<div class="mwe-popups-settings"></div>\n\t</footer>\n</div>'));ne(r.querySelector(".mwe-popups-title-placeholder"),O(n.text())),r.querySelector(".mwe-popups-title .mw-ui-icon").classList.add("mw-ui-icon-reference-".concat(t)),r.querySelector(".mw-parser-output").innerHTML=e.extract,Array.prototype.forEach.call(r.querySelectorAll('.mwe-popups-extract a[href][class~="external"]:not([target])'),(function(e){e.target="_blank",e.rel="".concat(e.rel?"".concat(e.rel," "):"","noopener")})),Array.prototype.forEach.call(r.querySelectorAll(".mw-collapsible"),(function(e){var t=document.createElement("div");t.classList.add("mwe-collapsible-placeholder");var n=document.createElement("span");n.classList.add("mw-ui-icon","mw-ui-icon-element","mw-ui-icon-infoFilled");var r=document.createElement("div");r.classList.add("mwe-collapsible-placeholder-label"),r.textContent=mw.msg("popups-refpreview-collapsible-placeholder"),t.appendChild(n),t.appendChild(r),ne(e,t)}));var o=function(e){e.classList.remove("headerSort"),e.removeAttribute("tabindex"),e.removeAttribute("title")};if(Array.prototype.forEach.call(r.querySelectorAll("table.sortable"),(function(e){e.classList.remove("sortable","jquery-tablesorter"),Array.prototype.forEach.call(e.querySelectorAll(".headerSort"),o)})),mw.config.get("wgPopupsReferencePreviewsBetaFeature"))r.querySelector(".mwe-popups-container").classList.add("footer-empty");else{var i=document.createElement("a");i.classList.add("mwe-popups-settings-icon");var a=document.createElement("span");a.classList.add("mw-ui-icon","mw-ui-icon-element","mw-ui-icon-small","mw-ui-icon-settings"),i.append(a),r.querySelector(".mwe-popups-settings").appendChild(i)}return te()&&r.querySelector(".mw-parser-output").addEventListener("click",(function(e){e.target.matches("a")&&mw.track(ee,{action:"clickedReferencePreviewsContentLink"})})),r.querySelector(".mwe-popups-scroll").addEventListener("scroll",(function(e){var t=e.target,n=t.scrollTop>=t.scrollHeight-t.clientHeight-1;if(te()&&(t.isOpenRecorded||(mw.track(ee,{action:"poppedOpen",scrollbarsPresent:t.scrollHeight>t.clientHeight}),t.isOpenRecorded=!0),t.scrollTop>0&&!t.isScrollRecorded&&(mw.track(ee,{action:"scrolled"}),t.isScrollRecorded=!0)),n||!t.isScrolling){var r=t.parentNode,o=t.scrollWidth>t.clientWidth,i=t.offsetHeight-t.clientHeight,a=t.scrollHeight>t.clientHeight,s=t.offsetWidth-t.clientWidth,u=r.querySelector(".mwe-popups-fade");u.style.bottom=o?"".concat(i,"px"):0,u.style.right=a?"".concat(s,"px"):0,t.isScrolling=!n,r.classList.toggle("mwe-popups-fade-out",t.isScrolling)}})),r}var oe=n("./node_modules/@babel/runtime/helpers/toConsumableArray.js"),ie=n.n(oe);function ae(e,t,n,r){var o=Z(e.type,H('\n<div>\n <a class="mwe-popups-discreet"></a>\n <a class="mwe-popups-extract"></a>\n <footer>\n <a class="mwe-popups-settings-icon">\n <span class="mw-ui-icon mw-ui-icon-element mw-ui-icon-small mw-ui-icon-settings"></span>\n </a>\n </footer>\n</div>\n\t')),i=o.querySelector(".mwe-popups-discreet"),a=o.querySelector(".mwe-popups-extract");if(a.setAttribute("href",e.url),i.setAttribute("href",e.url),a.setAttribute("dir",e.languageDirection),a.setAttribute("lang",e.languageCode),o.querySelector(".mwe-popups-settings-icon").setAttribute("title",r),t?o.querySelector(".mwe-popups-discreet").appendChild(t.el):i.remove(),e.extract){"string"==typeof e.extract?a.innerHTML=e.extract:a.append.apply(a,ie()(e.extract));var s=function(e){return e&&e.isNarrow?"".concat(215+e.offset,"px"):""}(t);n||(a.style.width=s,o.querySelector("footer").style.width=s)}return o}function se(){var e,t;pe()||(e=document.body,(t=document.createElement("div")).setAttribute("id","mwe-popups-svg"),t.innerHTML=B.a,e.appendChild(t))}function ue(e){var t=function(e){return(ce[e.type]||fe)(e)}(e);return{show:function(e,n,r){return function(e,t,n,r,o,i,a){var s=function(e,t,n,r){var o,i=!1,a=!1,s=t.pageY?he(t.pageY-t.scrollTop,t.clientRects,!1)+t.scrollTop+n:t.offset.top+t.height+8,u=t.clientY?t.clientY:s;o=t.pageX?t.width>28?t.pageX:t.offset.left+t.width/2:t.offset.left;o>t.windowWidth/2&&(o+=t.pageX?0:t.width,o-=e?450:320,i=!0);t.pageX&&(o+=i?18:-18);u>t.windowHeight/2&&(a=!0,s=t.offset.top,t.pageY&&(s=he(t.pageY-t.scrollTop,t.clientRects,!0)+t.scrollTop),s-=n);return{offset:{top:s,left:o},flippedX:"rtl"===r?!i:i,flippedY:a,dir:r}}(e.isTall,t,8,a);i.appendChild(e.el),function(e,t,n,r,o,i){var a=e.el,s=e.isTall,u=e.hasThumbnail,c=e.thumbnail,l=t.flippedY;if(!l&&!s&&u&&c.height<r&&!pe()){a.querySelector(".mwe-popups-extract").style.marginTop="".concat(c.height-o,"px")}a.classList.add.apply(a.classList,n),a.style.left="".concat(t.offset.left,"px"),a.style.top=l?"auto":"".concat(t.offset.top,"px"),a.style.bottom=l?"".concat(i-t.offset.top,"px"):"auto",u&&!pe()&&function(e,t){var n=e.el,r=e.isTall,o=e.thumbnail,i=t.flippedY,a=t.flippedX,s=t.dir,u=function(e,t,n){if(!e&&!t)return n?"mwe-popups-mask-flip":"mwe-popups-mask";if(e&&n)return t?"mwe-popups-landscape-mask-flip":"mwe-popups-landscape-mask";return}(r,i,a);if(u){var c={scaleX:1,translateX:r?Math.min(o.width-V.w,0):0};"rtl"===s&&(c.scaleX=-1,c.translateX=r?V.w:K.w),document.getElementById(u).setAttribute("transform","matrix(".concat(c.scaleX," 0 0 1 ").concat(c.translateX," 0)")),n.querySelector("image").setAttribute("clip-path","url(#".concat(u,")"))}}(e,t)}(e,s,function(e,t){var n=[];t.flippedY?n.push("mwe-popups-fade-in-down"):n.push("mwe-popups-fade-in-up");t.flippedY&&t.flippedX?n.push("flipped-x-y"):t.flippedY?n.push("flipped-y"):t.flippedX&&n.push("flipped-x");n.push(function(e,t){if((!e.hasThumbnail||e.isTall&&!t.flippedX)&&!t.flippedY)return!1;if(e.hasThumbnail&&(!e.isTall&&!t.flippedY||e.isTall&&t.flippedX))return!0;return!1}(e,t)?"mwe-popups-image-pointer":"mwe-popups-no-image-pointer"),e.isTall?n.push("mwe-popups-is-tall"):n.push("mwe-popups-is-not-tall");return n}(e,s),K.h,8,t.windowHeight),e.el.style.display="block",e.el.classList.contains("mwe-popups-type-reference")&&e.el.querySelector(".mwe-popups-scroll").dispatchEvent(new Event("scroll"));return W(200).then((function(){!function(e,t){e.el.addEventListener("mouseenter",t.previewDwell),e.el.addEventListener("mouseleave",t.previewAbandon),e.el.addEventListener("click",t.click);var n=e.el.querySelector(".mwe-popups-settings-icon");n&&(n.href=t.settingsUrl,n.addEventListener("click",(function(e){e.stopPropagation(),t.showSettings(e)})))}(e,r),r.previewShow(o)}))}(t,e,e.target,n,r,document.body,document.documentElement.getAttribute("dir"))},hide:function(){return function(e){var t=e.el.classList.contains("mwe-popups-fade-in-up")?"mwe-popups-fade-in-up":"mwe-popups-fade-in-down",n="mwe-popups-fade-in-up"===t?"mwe-popups-fade-out-down":"mwe-popups-fade-out-up";return e.el.classList.remove(t),e.el.classList.add(n),W(150).then((function(){e.el.remove()}))}(t)}}}var ce={};function le(e,t){ce[e]=t||de}function pe(){return window.CSS&&"function"==typeof CSS.supports&&CSS.supports("clip-path","polygon(1px 1px)")}function de(e){var t=$(e.thumbnail,pe()),n=null!==t;return{el:ae(e,t,pe(),mw.msg("popups-settings-icon-gear-title")),hasThumbnail:n,thumbnail:t,isTall:n&&t.isTall}}function fe(e){return{el:J(e,!1,mw.msg("popups-preview-no-preview"),mw.msg("popups-preview-footer-read")),hasThumbnail:!1,isTall:!1}}function me(e){return{el:J(e,!0,mw.msg("popups-preview-disambiguation"),mw.msg("popups-preview-disambiguation-link")),hasThumbnail:!1,isTall:!1}}function we(e){return{el:re(e),hasThumbnail:!1,isTall:!1}}function he(e,t,n){var r,o=null;return Array.prototype.slice.call(t).forEach((function(t){var i=Math.abs(e-t.top+e-t.bottom);(null===o||o>i)&&(o=i,r=n?Math.floor(t.top):Math.ceil(t.bottom))})),r}function ge(e,t){return t.split(".").reduce((function(e,t){return e&&e[t]}),e)}function ve(e,t,n,r){var o=ge(t,n);e&&ge(e,n)!==o&&r(o)}var ye={footerLink:function(e){var t;return function(n,r){void 0===t&&(t=function(){var e=document.createElement("li"),t=document.createElement("a");t.href="#",t.textContent=mw.message("popups-settings-enable").text(),e.appendChild(t),e.style.display="none";var n=document.querySelector("#footer-places, #f-list");if(!n){var r=document.querySelector("#footer li");r&&(n=r.parentNode)}return n&&n.appendChild(e),e}()).addEventListener("click",(function(t){t.preventDefault(),e.showSettings()})),r.settings.shouldShowFooterLink?t.style.display="":t.style.display="none"}},linkTitle:function(){var e;return function(t,n){var r,o=t&&t.preview.activeLink;o!==n.preview.activeLink&&((r=o)&&e&&(r.setAttribute("title",e),e=void 0),n.preview.enabled[n.preview.previewType]&&function(t){t&&!e&&(e=t.getAttribute("title"),t.setAttribute("title",""))}(n.preview.activeLink))}},pageviews:function(e,t){return function(n,r){var o,i;r.pageviews&&r.pageviews.pageview&&r.pageviews.page&&(o=r.pageviews.page,i=r.pageviews.pageview,t("event.VirtualPageView",{source_page_id:o.id,source_namespace:o.namespaceId,source_title:mw.Title.newFromText(o.title).getPrefixedDb(),source_url:o.url,page_id:i.page_id,page_namespace:i.page_namespace,page_title:mw.Title.newFromText(i.page_title).getPrefixedDb()}),e.pageviewLogged())}},render:function(e){var t;return function(n,r){r.preview.shouldShow&&!t?(t=ue(r.preview.fetchResponse)).show(r.preview.measures,e,r.preview.activeToken):!r.preview.shouldShow&&t&&(t.hide(),t=void 0)}},settings:function(e,t){var n;return function(r,o){r&&(!1===r.settings.shouldShow&&o.settings.shouldShow?(n||(n=t(e)).appendTo(document.body),n.setEnabled(o.preview.enabled),n.show()):r.settings.shouldShow&&!1===o.settings.shouldShow&&n.hide(),r.settings.showHelp!==o.settings.showHelp&&n.toggleHelp(o.settings.showHelp))}},statsv:function(e,t){return function(n,r){var o=r.statsv;o.action&&(t(o.action,o.data),e.statsvLogged())}},syncUserSettings:function(e){return function(t,n){ve(t,n,"preview.enabled."+p.TYPE_PAGE,e.storePagePreviewsEnabled),ve(t,n,"preview.enabled."+p.TYPE_REFERENCE,e.storeReferencePreviewsEnabled)}}},be=n("./node_modules/@babel/runtime/helpers/slicedToArray.js"),Ee=n.n(be),xe="BOOT",Te="LINK_DWELL",Pe="ABANDON_START",Se="ABANDON_END",_e="LINK_CLICK",ke="FETCH_START",Ae="FETCH_END",Le="FETCH_COMPLETE",je="FETCH_FAILED",Ie="FETCH_ABORTED",Re="PAGEVIEW_LOGGED",Ce="PREVIEW_DWELL",Oe="PREVIEW_SHOW",Ne="PREVIEW_SEEN",He="SETTINGS_SHOW",Me="SETTINGS_HIDE",De="SETTINGS_CHANGE",qe="STATSV_LOGGED";function Ye(e){return e.timestamp=mw.now(),e}function Fe(e,t,n,r,o){var i=r.get("wgUserEditCount");return{type:xe,initiallyEnabled:e,isNavPopupsEnabled:r.get("wgPopupsConflictsWithNavPopupGadget"),sessionToken:t.sessionId(),pageToken:t.getPageviewToken(),page:{url:o,title:r.get("wgTitle"),namespaceId:r.get("wgNamespaceNumber"),id:r.get("wgArticleId")},user:{isAnon:t.isAnon()||mw.user.isTemp(),editCount:i}}}function Ge(e){switch(e){case p.TYPE_PAGE:return 350;case p.TYPE_REFERENCE:return 150;default:return 0}}function Ue(e,t,n,r,o){var i=t.getPrefixedDb(),a=t.namespace;return function(s){var u=e.fetchPreviewForTitle(t,n);s(Ye({type:ke,el:n,title:i,namespaceId:a,promise:u}));var c=u.then((function(e){return s(Ye({type:Ae,el:n})),e})).catch((function(e,t){var o=new Error(e),i=t&&t.textStatus&&"abort"===t.textStatus?Ie:je;throw o.data=t,s({type:i,el:n,token:r}),o}));return Promise.all([c,W(Ge(o))]).then((function(e){var t=Ee()(e,1)[0];s({type:Le,el:n,result:t,token:r})})).catch((function(e){var o=e.data,a=!0;o&&o.xhr&&0===o.xhr.readyState&&(a=!("error"===o.textStatus&&""===o.exception||"abort"===o.textStatus));a&&s({type:Le,el:n,result:f(i,t.getUrl()),token:r})}))}}function We(e,t,n,r,o,i){var a=o(),s=e.getPrefixedDb(),u=e.namespace;return function(o,c){var l=W(150),p=Ye({type:Te,el:t,previewType:i,measures:n,token:a,title:s,namespaceId:u,promise:l});function d(){return c().preview.activeToken===a}return o(p),d()?l.then((function(){var n=c().preview.enabled[i];if((void 0===n||n)&&d())return o(Ue(r,e,t,a,i))})):Promise.resolve()}}function Xe(){return function(e,t){var n=t().preview,r=n.activeToken,o=n.promise;return r?(e(Ye({type:Pe,token:r})),"abort"in o&&o.abort(),W(300).then((function(){e({type:Se,token:r})}))):Promise.resolve()}}function Be(e){return Ye({type:_e,el:e})}function Ve(){return{type:Ce}}function Ke(e){return function(t,n){return t(Ye({type:Oe,token:e})),W(1e3).then((function(){var r=n().preview,o=r&&r.fetchResponse,i=r&&r.activeToken,a=o&&[p.TYPE_PAGE,p.TYPE_DISAMBIGUATION].indexOf(o.type)>-1;i&&i===e&&o&&a&&t({type:Ne,title:o.title,pageId:o.pageId,namespace:0})}))}}function $e(){return{type:Re}}function ze(){return{type:He}}function Ze(){return{type:Me}}function Je(e){return function(t,n){t({type:De,oldValue:n().preview.enabled,newValue:e})}}function Qe(){return{type:qe}}function et(e,t){var n,r=Object.prototype.hasOwnProperty,o={};for(var i in e)r.call(e,i)&&!r.call(t,i)&&(o[i]=e[i]);for(var a in t)if(r.call(t,a))if((n=t[a])&&n.constructor===Object){var s=e[a]?et({},e[a]):{};o[a]=et(s,t[a])}else o[a]=t[a];return o}var tt={pageviews:function(e,t){switch(void 0===e&&(e={pageview:void 0}),t.type){case xe:return et(e,{page:t.page});case Re:return et(e,{pageview:void 0});case Ne:return et(e,{pageview:{page_title:t.title,page_id:t.pageId,page_namespace:t.namespace}});default:return e}},preview:function(e,t){switch(void 0===e&&(e={enabled:{},activeLink:void 0,previewType:void 0,measures:void 0,activeToken:"",shouldShow:!1,isUserDwelling:!1,wasClicked:!1}),t.type){case xe:return et(e,{enabled:t.initiallyEnabled});case De:return et(e,{enabled:t.newValue});case Te:return t.el!==e.activeLink?et(e,{activeLink:t.el,previewType:t.previewType,measures:t.measures,activeToken:t.token,shouldShow:!1,isUserDwelling:!0,promise:t.promise}):et(e,{isUserDwelling:!0});case Ie:case Se:return t.token!==e.activeToken||e.isUserDwelling?e:et(e,{activeLink:void 0,previewType:void 0,activeToken:void 0,measures:void 0,fetchResponse:void 0,shouldShow:!1});case Ce:return et(e,{isUserDwelling:!0});case Pe:return et(e,{isUserDwelling:!1,wasClicked:!1});case ke:return et(e,{fetchResponse:void 0,promise:t.promise});case Le:if(t.token===e.activeToken)return et(e,{fetchResponse:t.result,shouldShow:e.isUserDwelling});default:return e}},settings:function(e,t){switch(void 0===e&&(e={shouldShow:!1,showHelp:!1,shouldShowFooterLink:!1}),t.type){case He:return et(e,{shouldShow:!0,showHelp:!1});case Me:return et(e,{shouldShow:!1,showHelp:!1});case De:var n=Object.keys(t.newValue),r=n.every((function(e){return t.oldValue[e]===t.newValue[e]})),o=n.some((function(e){return t.oldValue[e]&&!t.newValue[e]})),i=n.some((function(e){return!1===t.newValue[e]}));return et(e,r?{shouldShow:!1}:{shouldShow:o,showHelp:o,shouldShowFooterLink:i});case xe:var a=Object.keys(t.initiallyEnabled).some((function(e){return!1===t.initiallyEnabled[e]}));return et(e,{shouldShowFooterLink:t.user.isAnon&&a});default:return e}},statsv:function(e,t){switch(e=e||{},t.type){case ke:return et(e,{fetchStartedAt:t.timestamp});case Ae:return et(e,{action:"timing.PagePreviewsApiResponse",data:t.timestamp-e.fetchStartedAt});case je:return et(e,{action:"counter.PagePreviewsApiFailure",data:1});case Te:return et(e,{linkDwellStartedAt:t.timestamp});case Oe:return et(e,{action:"timing.PagePreviewsPreviewShow",data:t.timestamp-e.linkDwellStartedAt});case qe:return et(e,{action:null,data:null});default:return e}}};var nt=n("./src/canSaveToUserPreferences.js");var rt=[".extiw",".mw-selflink",".image",".new",".internal",".external",".mw-cite-backlink a",".oo-ui-buttonedElement-button",".ve-ce-surface a",".cancelLink a",".mw-selflink-fragment",'[href^="#"]'];function ot(e){return function(t){if(t.target!==document){var n,r,o=(n=t.target,r=h.join(", "),n.closest(r));if(null!==o){var i=U(o,mw.config);i&&e(o,i,t)}}}}!function(){var e,t,n;t=mw.config,n=parseInt(t.get("wgPopupsFlags"),10),t.set("wgPopupsConflictsWithNavPopupGadget",!!(1&n)),t.set("wgPopupsConflictsWithRefTooltipsGadget",!!(2&n)),t.set("wgPopupsReferencePreviews",!!(4&n)),t.set("wgPopupsReferencePreviewsBetaFeature",!!(8&n));var o,s,c=a.compose,l=mw.user.generateRandomSessionId,d=I(mw.config),f=R(),m=(s=mw.storage,{isPagePreviewsEnabled:function(){return"0"!==s.get("mwe-popups-enabled")},storePagePreviewsEnabled:function(e){e?s.remove("mwe-popups-enabled"):s.set("mwe-popups-enabled","0")},isReferencePreviewsEnabled:function(){return"0"!==s.get("mwe-popups-referencePreviews-enabled")},storeReferencePreviewsEnabled:function(e){e?s.remove("mwe-popups-referencePreviews-enabled"):s.set("mwe-popups-referencePreviews-enabled","0"),mw.track("event.ReferencePreviewsPopups",{action:e?"anonymousEnabled":"anonymousDisabled"})}}),v=function(e,t,n){return n.get("wgPopupsReferencePreviews")?n.get("wgPopupsConflictsWithRefTooltipsGadget")||"minerva"===n.get("skin")?null:nt(e)?!!n.get("wgPopupsReferencePreviews")||("1"===mw.user.options.get("popups-reference-previews")||null):t.isReferencePreviewsEnabled():null}(mw.user,m,mw.config),y=D(null!==v),x=(o=mw.experiments,{weightedBoolean:function(e,t,n){return"true"===o.getBucket({enabled:!0,name:e,buckets:{true:t,false:1-t}},n)}}),T=function(e,t,n){return function(e,t,n){var r=t.get("wgPopupsStatsvSamplingRate",0);return n.weightedBoolean("ext.Popups.statsv",r,e.sessionId())}(e,t,n)?mw.track:function(){}}(mw.user,mw.config,x),P=function(e){return e.get("wgPopupsVirtualPageViews")?mw.track:function(){}}(mw.config),S=(e={},i()(e,p.TYPE_PAGE,function(e,t,n){return n.get("wgPopupsConflictsWithNavPopupGadget")?null:G(e)?"1"===mw.user.options.get("popups")||null:t.isPagePreviewsEnabled()}(mw.user,m,mw.config)),i()(e,p.TYPE_REFERENCE,v),e);mw.config.get("debug")&&(c=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__||c);var _,k,A,L=a.createStore(a.combineReducers(tt),c(a.applyMiddleware(u.a))),j=a.bindActionCreators(r,L.dispatch),O=function(e,t){var n,r=function(){};if(C(e)){n=mw.Title.newFromText("Special:Preferences#mw-prefsection-rendering").getUrl()}else r=function(e){e.preventDefault(),t.showSettings()};return{settingsUrl:n,showSettings:r,previewDwell:t.previewDwell,previewAbandon:t.abandon,previewShow:t.previewShow,click:t.linkClick}}(mw.user,j);if(function(e,t,n,r,o,i,a){F(e,ye.footerLink(t)),F(e,ye.linkTitle()),F(e,ye.render(o)),F(e,ye.statsv(t,i)),F(e,ye.syncUserSettings(n)),F(e,ye.settings(t,r)),F(e,ye.pageviews(t,a))}(L,j,m,y,O,T,P),j.boot(S,mw.user,m,mw.config,window.location.href),mw.popups=function(e,t,n,r){return{isEnabled:function(){return e.getState().preview.enabled[p.TYPE_PAGE]},register:function(e){var o=e.type,i=e.selector,a=e.gateway,s=e.renderFn,u=e.subTypes,c=e.init;if(!o||!i||!a)throw new Error('Registration of Popups custom preview type "'.concat(o,'" failed: You must specify a type, a selector, and a gateway.'));t(o,i),r(o,a),n(o,s),u&&u.forEach((function(e){n(e.type,e.renderFn)})),"function"==typeof c&&c()}}}(L,g,le,E),null!==S[p.TYPE_PAGE]){var N=rt.join(", ");mw.popups.register({type:p.TYPE_PAGE,selector:"#mw-content-text a[href][title]:not(".concat(N,")"),gateway:d,renderFn:de,subTypes:[{type:p.TYPE_DISAMBIGUATION,renderFn:me}]})}(null!==S[p.TYPE_REFERENCE]&&mw.popups.register({type:p.TYPE_REFERENCE,selector:'#mw-content-text .reference a[ href*="#" ]',gateway:f,renderFn:we,init:function(){mw.config.get("wgPopupsReferencePreviews")&&navigator.sendBeacon&&mw.config.get("wgIsArticle")&&!Q&&(Q=!0,mw.track(ee,{action:"pageview"}))}}),h.length)?(se(),_=ot((function(e,t,n){var r=w(e),o=function(e){return b[e]}(r);if(o){var i=window.scrollY,a=e.getBoundingClientRect(),s={top:i+a.y,left:window.scrollX+a.x},u={pageX:n.pageX,pageY:n.pageY,clientY:n.clientY,width:e.offsetWidth,height:e.offsetHeight,offset:s,clientRects:e.getClientRects(),windowWidth:window.innerWidth,windowHeight:window.innerHeight,scrollTop:i};j.linkDwell(t,e,u,o,l,r)}})),k=ot((function(){j.abandon()})),A=ot((function(e){p.TYPE_PAGE===w(e)&&j.linkClick(e)})),document.addEventListener("mouseover",_),document.addEventListener("keyup",_),document.addEventListener("mouseout",k),document.addEventListener("blur",k),document.addEventListener("click",A)):mw.log.warn("ext.popups was loaded but everything is disabled")}(),window.Redux=a,window.ReduxThunk=s},"./src/ui/pointer-mask.svg":function(e,t){e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0"><defs><clipPath id="mwe-popups-mask"><path d="M0 8h10l8-8 8 8h974v992H0z"></path></clipPath><clipPath id="mwe-popups-mask-flip"><path d="M0 8h294l8-8 8 8h690v992H0z"></path></clipPath><clipPath id="mwe-popups-landscape-mask"><path d="M0 8h174l8-8 8 8h810v992H0z"></path></clipPath><clipPath id="mwe-popups-landscape-mask-flip"><path d="M0 0h1000v242H190l-8 8-8-8H0z"></path></clipPath></defs></svg>'}});
|
|
//# sourceMappingURL=index.js.map.json
|