小さなプログラムの日常--各種のパッケージ方法の記録


需要によって、パッケージのスタイルもそれぞれ異なり、私が開発したプロジェクトで使った方法だけを記録して、保存して、後で最適化します.
request
const wx_request = function (path, method, data, header) {
    var body_data;
    if (JSON.stringify(data) == "{}") {
        if (method == "POST" || method == "DELETE") {
            body_data = "{}"
        } else {
            body_data = "-1"
        }
    } else {
        body_data = JSON.stringify(data)
    }

    var obj = {
        method: method,
        contentType: "application/json",
        platform: 3,
        url: '/v1/' + path,
        body: body_data,
        key: wx.getStorageSync("APPSECRET"),//appsecret
    }
    let sign = stringToSign(obj); //    
    // charset=utf-8
    header = header || {
        platform: 3,
        user_id:wx.getStorageSync('userId'),
        "access-token": wx.getStorageSync(TOKEN_KEY),
        timestamp: sign.timestamp,
        nonce: sign.nonce,
        Authorization: `GAIA ${wx.getStorageSync("APPKEY")}:${sign.signature}`,
        // "device-id": wx.getStorageSync('ROLE') == "GUEST" ? wx.getStorageSync('uuid') : wx.getStorageSync('unionId'),
        "outer-id": wx.getStorageSync('ROLE') == "GUEST" ? wx.getStorageSync('uuid') : wx.getStorageSync('unionId'),
        Accept: 'application/json',
        'Content-Type': 'application/json',
        "version": MINI_VERSION,
    };
    return new Promise((resolve, reject) => {
        wx.request({//    
            url: BASE_API + path,
            header: header,
            method: method,
            data: data,
            success: function (res) {
                var pages = getCurrentPages();
                var currPage = pages[pages.length - 1]; //    
                
                if (res.statusCode !== 200) {
                    if (res.statusCode == 401 && wx.getStorageSync(TOKEN_KEY)) {
                        //   token
                        wx_request(
                            `account/refresh_token?refresh_token=${wx.getStorageSync('REFRESH_TOKEN')}`, "POST",
                            {}
                        ).then(res => {
                            console.log('refresh_token  res', res)
                            if (res.code == 200) {
                                wx.setStorage({
                                    key: TOKEN_KEY,
                                    data: res.data.token,
                                    success: function () {
                                        wx_request(path, method, data).then(resolve).catch(reject)
                                    }
                                })
                                // wx.setStorageSync(TOKEN_KEY, res.data.token);
                                wx.setStorageSync('REFRESH_TOKEN', res.data.refreshToken);
                            } else {
                                //             
                                logout();
                                if(currPage.route != 'pages/login/login' && !wx.getStorageSync('isNavigate')){
                                    wx.navigateTo({
                                        url: '/pages/login/login'
                                    })
                                    wx.setStorageSync('isNavigate',true)
                                }
                            }
                        }).catch(err => {
                            if(currPage.route != 'pages/login/login' && !wx.getStorageSync('isNavigate')){
                                wx.navigateTo({
                                    url: '/pages/login/login'
                                })
                                wx.setStorageSync('isNavigate',true)
                            }
                        })
                    }
                    else if (res.statusCode == 403) {
                        //             
                         logout();
                        // if (wx.getStorageSync('ROLE') != 'GUEST') {
                            if(currPage.route != 'pages/login/login' && !wx.getStorageSync('isNavigate')){
                                wx.navigateTo({
                                    url: '/pages/login/login'
                                })
                                wx.setStorageSync('isNavigate',true)
                            }
                           
                        // }
                    }
                    else if (res.statusCode == 500) {
                        wx.showToast({
                            title: res.data.message,
                            icon: 'none',
                            duration: 2000,
                            success: (result) => {
                            },
                            fail: () => { },
                            complete: () => { }
                        });
                        setTimeout(function(){
                            reject(res.data)
                        },2000)
                    } else {
                        if(currPage.route != 'pages/login/login' && !wx.getStorageSync('isNavigate')){
                            wx.navigateTo({
                                url: '/pages/login/login'
                            })
                            wx.setStorageSync('isNavigate',true)
                        }
                    }
                } else {
                    if (res.data.code === 401 || res.data.code === 501) {
                        //   token
                        wx_request(
                            `account/refresh_token?refresh_token=${wx.getStorageSync('REFRESH_TOKEN')}`, "POST",
                            {}
                        ).then(res => {
                            console.log('refresh_token  res', res)
                            if (res.code == 200) {
                                wx.setStorage({
                                    key: TOKEN_KEY,
                                    data: res.data.token,
                                    success: function () {
                                        wx_request(path, method, data).then(resolve).catch(reject)
                                    }
                                })
                                // wx.setStorageSync(TOKEN_KEY, res.data.token);
                                wx.setStorageSync('REFRESH_TOKEN', res.data.refreshToken);
                            } else {
                                if(currPage.route != 'pages/login/login' && !wx.getStorageSync('isNavigate')){
                                    wx.navigateTo({
                                        url: '/pages/login/login'
                                    })
                                    wx.setStorageSync('isNavigate',true)
                                }
                            }
                        }).catch(err => {
                            if(currPage.route != 'pages/login/login' && !wx.getStorageSync('isNavigate')){
                                wx.navigateTo({
                                    url: '/pages/login/login'
                                })
                                wx.setStorageSync('isNavigate',true)
                            }
                        })
                    } else if (res.data.code === 403) {
                        wx.showToast({
                            title: res.data.message,
                            icon: 'none',
                            duration: 2000,
                        });
                        if(currPage.route != 'pages/login/login' && !wx.getStorageSync('isNavigate')){
                            wx.navigateTo({
                                url: '/pages/login/login'
                            })
                            wx.setStorageSync('isNavigate',true)
                        }
                        // reject(res.data);
                    }else if (res.data.code === 500) {
                        // server  
                        wx.showToast({
                            title: res.data.message,
                            icon: 'none',
                            duration: 2000,
                            success(){
                            }
                        });
                        setTimeout(function(){
                            reject(res.data);
                        },2000)
                        
                    } else if (res.data.code === 416) {
                        console.log('416',res.data.message)
                        //        
                        wx.showToast({
                            title: res.data.message,
                            icon: 'none',
                            duration: 2000,
                            success: (result) => {
                            },
                            fail: () => { },
                            complete: () => { }
                        });
                            reject(res.data);
                    }
                    //    
                    else if (res.data.code === 419) {
                        reject(res.data);
                        wx.showToast({
                            title: res.data.message,
                            icon: 'none',
                            duration: 2000,
                            success: (result) => {
                                
                            },
                            fail: () => { },
                            complete: () => { }
                        });
                        
                    }  else if (res.data.code === 404) {
                        wx.showToast({
                            title: res.data.message,
                            icon: 'none',
                            duration: 2000,
                            success: (result) => {
                                
                            },
                            fail: () => { },
                            complete: () => { }
                        });
                            reject(res.data);
                    }else if (res.data.code == 427){
                        if(path != 'account/mini_program_login' && path != 'account/login'){
                            logout().then(res=>{

                            })
                            if(currPage.route != 'pages/login/login' && !wx.getStorageSync('isNavigate')){
                                wx.navigateTo({
                                    url: '/pages/login/login'
                                })
                                wx.setStorageSync('isNavigate',true)
                            }
                        }
                        reject(res.data)
                    }
                    resolve(res.data)
                }
            },
            fail: function (res) {
                console.log("wx_request fail",res);
                wx.showToast({
                    title: '          ,       ',
                    icon: 'none',
                    duration: 2000,
                    success: (res) => {
                    },
                    fail: () => { },
                    complete: () => { }
                });
                setTimeout(function(){
                    reject(res);
                },1500)
                
            }
        });
    });
}

uploadFile
  
const wx\_uploadFile \= function (path, filePath, name) {

var obj \= {

method: "POST",

contentType: "multipart/form-data",

platform: 3,

url: \`/${path}\`,

body: '-1',

key: wx.getStorageSync("APPSECRET"),//appsecret

}

var sign \= stringToSign(obj);

return new Promise((resolve, reject) \=> {

wx.uploadFile({

url: \`${UPLOAD\_API}${path}\`,//     

method: 'POST',//         

filePath: filePath,

header: {

'content-type': 'multipart/form-data',

platform: 3,

"access-token": wx.getStorageSync(TOKEN\_KEY),

Accept: 'application/json',

// "device-id": wx.getStorageSync('ROLE') == "GUEST" ? wx.getStorageSync('uuid') : wx.getStorageSync('unionId'),

"outer-id": wx.getStorageSync('ROLE') \== "GUEST" ? wx.getStorageSync('uuid') : wx.getStorageSync('unionId'),

timestamp: sign.timestamp,

nonce: sign.nonce,

Authorization: \`GAIA ${wx.getStorageSync("APPSECRET")}:${sign.signature}\`,

"version": MINI\_VERSION,

},

name: name,//      Key 

success: function (res) {

res \= JSON.parse(res.data)

var pages \= getCurrentPages();

var currPage \= pages\[pages.length \- 1\]; //    

if (res.code \== 401) {

wx\_request(

\`account/refresh\_token?refresh\_token=${wx.getStorageSync('REFRESH\_TOKEN')}\`, "POST",

{}

).then(res \=> {

if (res.code \== 200) {

wx.setStorageSync(TOKEN\_KEY, res.data.token);

wx.setStorageSync('REFRESH\_TOKEN', res.data.refreshToken);

wx\_uploadFile(path, filePath, name).then(resolve).catch(reject)

}

}).catch(err \=> {

wx.hideLoading();

logout();

if(currPage.route != 'pages/login/login' && !wx.getStorageSync('isNavigate')){

wx.navigateTo({

url: '/pages/login/login'

})

wx.setStorageSync('isNavigate',true)

}

})

  

} else if (res.code \== 403) {

logout();

if(currPage.route != 'pages/login/login' && !wx.getStorageSync('isNavigate')){

wx.navigateTo({

url: '/pages/login/login'

})

wx.setStorageSync('isNavigate',true)

}

} else if (res.code \== 200) {

resolve(res.data)

}

  

},

fail: function (err) {

console.log("wx\_request fail",err);

wx.showToast({

title: '          ,       ',

icon: 'none',

duration: 2000,

success: (result) \=> {

},

fail: () \=> { },

complete: () \=> { }

});

setTimeout(function(){

reject(err);

},1000)

},

  

})

})

  

}

クラウド関数でウィジェットコードを取得し、ファイルに変換し、バックエンドインタフェースでサーバに送信
 wx.cloud.callFunction({
                    name: 'smallProgramCode',
                    data: {
                        page: 'pages/details/picDetail',
                        scene: `${_this.data.shareId},${_this.data.documentId}`,
                    }
                }).then(res => {
                    console.log("shareCircle", res.result.buffer);
                    _this.upFile(res.result.buffer)
                }).catch(err => {
                    console.error(err);
                    wx.showToast({
                        icon: 'none',
                        title: '    ',
                        duration: 1500,
                    })
                })
    //       
    upFile: (buffer) => {
        console.log('upFile buffer', buffer)
        var _this = self;
        const fsm = wx.getFileSystemManager();
        const FILE_BASE_NAME = 'tmp_base64src';
        let base64str = wx.arrayBufferToBase64(buffer);
        const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64str) || [];
        const filePath = `${wx.env.USER_DATA_PATH}/${FILE_BASE_NAME}.jpeg`;
        console.log('filePath', filePath)
        fsm.writeFile({
            filePath,
            data: buffer,
            encoding: 'binary',
            success() {
                console.log('writeFile success')
                wx_uploadFile(`v1/content/doc_poster?doc_id=${_this.data.documentId}`, filePath, 'qrCodeFile').then(res => {
                    console.log('picDetail upload=>', res)
                    wx.hideLoading();
                    _this.downFile(res)

                }).catch(err => {
                    console.log('      ', err)
                })
            },
            fail(errMsg) {
                console.log('writeFile fail', errMsg)
                return (new Error('ERROR_BASE64SRC_WRITE'));
            }
        })
    },

ジッタぼうしかんすう
  
//     

function throttle(fn, gapTime) {

if (gapTime \== null || gapTime \== undefined) {

gapTime \= 300

}

let \_lastTime \= null

//       

return function () {

let \_nowTime \= +new Date()

if (\_nowTime \- \_lastTime \> gapTime || !\_lastTime) {

fn.apply(this, arguments) // this        

\_lastTime \= \_nowTime

}

}

}

携帯番号の確認

//      
function checkPhone(phone) {
    // var phone = document.getElementById('phone').value;
    if (!(/^1[3456789]\d{9}$/.test(phone))) {
        wx.showToast({
            title: '      ,     ',
            icon: 'none',
            duration: 1500,
            mask: false,
            success: (result) => {},
            fail: () => {},
            complete: () => {}
        });
        return false;
    }
    return true
}

UUIDを取得

//   UUID
const generateUUID = function () {
    var s = [];
    var hexDigits = "0123456789abcdef";
    for (var i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
    }
    s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
    s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
    s[8] = s[13] = s[18] = s[23] = "-";

    var uuid = s.join("");
    return uuid

}

画像を中央に切り取り、アリ雲画像処理パラメータを利用する
//          url
function shareImageUrl(width, height, imageUrl) {
    var WW = width;
    var HH = height;
    var x, y, w, h;
    if (parseFloat(WW / HH) < 1.25) {
        x = 0;
        y = parseFloat((HH - parseFloat(WW / 1.25)) / 2);
        w = WW;
        h = parseFloat(WW / 1.25);
    } else if (parseFloat(WW / HH) > 1.25) {
        x = parseFloat((WW - parseFloat(1.25 * HH)) / 2);
        y = 0;
        w = parseFloat(1.25 * HH);
        h = HH;
    } else {
        x = 0;
        y = 0;
        w = WW;
        h = HH;
    }
    var newImage = imageUrl.split('?')[0];
    var shareImageUrl = `${newImage}?x-oss-process=image/crop,x_${parseInt(x)},y_${parseInt(y)},w_${parseInt(w)},h_${parseInt(h)},g_nw`
    return shareImageUrl;
}

twemoji.js 1つのemoji表情は1つの文字に計算されます
/*! Copyright Twitter Inc. and other contributors. Licensed under MIT */
var twemoji=function(){"use strict";var twemoji={base:"https://twemoji.maxcdn.com/v/12.1.5/",ext:".png",size:"72x72",className:"emoji",convert:{fromCodePoint:fromCodePoint,toCodePoint:toCodePoint},onerror:function onerror(){if(this.parentNode){this.parentNode.replaceChild(createText(this.alt,false),this)}},parse:parse,replace:replace,test:test},escaper={"&":"&","":">","'":"'",'"':"""},re=/(?:\ud83d\udc68\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc68\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc68\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffe]|\ud83e\uddd1\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\u200d\ud83e\udd1d\u200d\ud83e\uddd1|\ud83d\udc6b\ud83c[\udffb-\udfff]|\ud83d\udc6c\ud83c[\udffb-\udfff]|\ud83d\udc6d\ud83c[\udffb-\udfff]|\ud83d[\udc6b-\udc6d])|(?:\ud83d[\udc68\udc69]|\ud83e\uddd1)(?:\ud83c[\udffb-\udfff])?\u200d(?:\u2695\ufe0f|\u2696\ufe0f|\u2708\ufe0f|\ud83c[\udf3e\udf73\udf93\udfa4\udfa8\udfeb\udfed]|\ud83d[\udcbb\udcbc\udd27\udd2c\ude80\ude92]|\ud83e[\uddaf-\uddb3\uddbc\uddbd])|(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75]|\u26f9)((?:\ud83c[\udffb-\udfff]|\ufe0f)\u200d[\u2640\u2642]\ufe0f)|(?:\ud83c[\udfc3\udfc4\udfca]|\ud83d[\udc6e\udc71\udc73\udc77\udc81\udc82\udc86\udc87\ude45-\ude47\ude4b\ude4d\ude4e\udea3\udeb4-\udeb6]|\ud83e[\udd26\udd35\udd37-\udd39\udd3d\udd3e\uddb8\uddb9\uddcd-\uddcf\uddd6-\udddd])(?:\ud83c[\udffb-\udfff])?\u200d[\u2640\u2642]\ufe0f|(?:\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83c\udff3\ufe0f\u200d\u26a7\ufe0f|\ud83c\udff3\ufe0f\u200d\ud83c\udf08|\ud83c\udff4\u200d\u2620\ufe0f|\ud83d\udc15\u200d\ud83e\uddba|\ud83d\udc41\u200d\ud83d\udde8|\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc6f\u200d\u2640\ufe0f|\ud83d\udc6f\u200d\u2642\ufe0f|\ud83e\udd3c\u200d\u2640\ufe0f|\ud83e\udd3c\u200d\u2642\ufe0f|\ud83e\uddde\u200d\u2640\ufe0f|\ud83e\uddde\u200d\u2642\ufe0f|\ud83e\udddf\u200d\u2640\ufe0f|\ud83e\udddf\u200d\u2642\ufe0f)|[#*0-9]\ufe0f?\u20e3|(?:[©®\u2122\u265f]\ufe0f)|(?:\ud83c[\udc04\udd70\udd71\udd7e\udd7f\ude02\ude1a\ude2f\ude37\udf21\udf24-\udf2c\udf36\udf7d\udf96\udf97\udf99-\udf9b\udf9e\udf9f\udfcd\udfce\udfd4-\udfdf\udff3\udff5\udff7]|\ud83d[\udc3f\udc41\udcfd\udd49\udd4a\udd6f\udd70\udd73\udd76-\udd79\udd87\udd8a-\udd8d\udda5\udda8\uddb1\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa\udecb\udecd-\udecf\udee0-\udee5\udee9\udef0\udef3]|[\u203c\u2049\u2139\u2194-\u2199\u21a9\u21aa\u231a\u231b\u2328\u23cf\u23ed-\u23ef\u23f1\u23f2\u23f8-\u23fa\u24c2\u25aa\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262a\u262e\u262f\u2638-\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b\u269c\u26a0\u26a1\u26a7\u26aa\u26ab\u26b0\u26b1\u26bd\u26be\u26c4\u26c5\u26c8\u26cf\u26d1\u26d3\u26d4\u26e9\u26ea\u26f0-\u26f5\u26f8\u26fa\u26fd\u2702\u2708\u2709\u270f\u2712\u2714\u2716\u271d\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u2764\u27a1\u2934\u2935\u2b05-\u2b07\u2b1b\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299])(?:\ufe0f|(?!\ufe0e))|(?:(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75\udd90]|[\u261d\u26f7\u26f9\u270c\u270d])(?:\ufe0f|(?!\ufe0e))|(?:\ud83c[\udf85\udfc2-\udfc4\udfc7\udfca]|\ud83d[\udc42\udc43\udc46-\udc50\udc66-\udc69\udc6e\udc70-\udc78\udc7c\udc81-\udc83\udc85-\udc87\udcaa\udd7a\udd95\udd96\ude45-\ude47\ude4b-\ude4f\udea3\udeb4-\udeb6\udec0\udecc]|\ud83e[\udd0f\udd18-\udd1c\udd1e\udd1f\udd26\udd30-\udd39\udd3d\udd3e\uddb5\uddb6\uddb8\uddb9\uddbb\uddcd-\uddcf\uddd1-\udddd]|[\u270a\u270b]))(?:\ud83c[\udffb-\udfff])?|(?:\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc73\udb40\udc63\udb40\udc74\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc77\udb40\udc6c\udb40\udc73\udb40\udc7f|\ud83c\udde6\ud83c[\udde8-\uddec\uddee\uddf1\uddf2\uddf4\uddf6-\uddfa\uddfc\uddfd\uddff]|\ud83c\udde7\ud83c[\udde6\udde7\udde9-\uddef\uddf1-\uddf4\uddf6-\uddf9\uddfb\uddfc\uddfe\uddff]|\ud83c\udde8\ud83c[\udde6\udde8\udde9\uddeb-\uddee\uddf0-\uddf5\uddf7\uddfa-\uddff]|\ud83c\udde9\ud83c[\uddea\uddec\uddef\uddf0\uddf2\uddf4\uddff]|\ud83c\uddea\ud83c[\udde6\udde8\uddea\uddec\udded\uddf7-\uddfa]|\ud83c\uddeb\ud83c[\uddee-\uddf0\uddf2\uddf4\uddf7]|\ud83c\uddec\ud83c[\udde6\udde7\udde9-\uddee\uddf1-\uddf3\uddf5-\uddfa\uddfc\uddfe]|\ud83c\udded\ud83c[\uddf0\uddf2\uddf3\uddf7\uddf9\uddfa]|\ud83c\uddee\ud83c[\udde8-\uddea\uddf1-\uddf4\uddf6-\uddf9]|\ud83c\uddef\ud83c[\uddea\uddf2\uddf4\uddf5]|\ud83c\uddf0\ud83c[\uddea\uddec-\uddee\uddf2\uddf3\uddf5\uddf7\uddfc\uddfe\uddff]|\ud83c\uddf1\ud83c[\udde6-\udde8\uddee\uddf0\uddf7-\uddfb\uddfe]|\ud83c\uddf2\ud83c[\udde6\udde8-\udded\uddf0-\uddff]|\ud83c\uddf3\ud83c[\udde6\udde8\uddea-\uddec\uddee\uddf1\uddf4\uddf5\uddf7\uddfa\uddff]|\ud83c\uddf4\ud83c\uddf2|\ud83c\uddf5\ud83c[\udde6\uddea-\udded\uddf0-\uddf3\uddf7-\uddf9\uddfc\uddfe]|\ud83c\uddf6\ud83c\udde6|\ud83c\uddf7\ud83c[\uddea\uddf4\uddf8\uddfa\uddfc]|\ud83c\uddf8\ud83c[\udde6-\uddea\uddec-\uddf4\uddf7-\uddf9\uddfb\uddfd-\uddff]|\ud83c\uddf9\ud83c[\udde6\udde8\udde9\uddeb-\udded\uddef-\uddf4\uddf7\uddf9\uddfb\uddfc\uddff]|\ud83c\uddfa\ud83c[\udde6\uddec\uddf2\uddf3\uddf8\uddfe\uddff]|\ud83c\uddfb\ud83c[\udde6\udde8\uddea\uddec\uddee\uddf3\uddfa]|\ud83c\uddfc\ud83c[\uddeb\uddf8]|\ud83c\uddfd\ud83c\uddf0|\ud83c\uddfe\ud83c[\uddea\uddf9]|\ud83c\uddff\ud83c[\udde6\uddf2\uddfc]|\ud83c[\udccf\udd8e\udd91-\udd9a\udde6-\uddff\ude01\ude32-\ude36\ude38-\ude3a\ude50\ude51\udf00-\udf20\udf2d-\udf35\udf37-\udf7c\udf7e-\udf84\udf86-\udf93\udfa0-\udfc1\udfc5\udfc6\udfc8\udfc9\udfcf-\udfd3\udfe0-\udff0\udff4\udff8-\udfff]|\ud83d[\udc00-\udc3e\udc40\udc44\udc45\udc51-\udc65\udc6a\udc6f\udc79-\udc7b\udc7d-\udc80\udc84\udc88-\udca9\udcab-\udcfc\udcff-\udd3d\udd4b-\udd4e\udd50-\udd67\udda4\uddfb-\ude44\ude48-\ude4a\ude80-\udea2\udea4-\udeb3\udeb7-\udebf\udec1-\udec5\uded0-\uded2\uded5\udeeb\udeec\udef4-\udefa\udfe0-\udfeb]|\ud83e[\udd0d\udd0e\udd10-\udd17\udd1d\udd20-\udd25\udd27-\udd2f\udd3a\udd3c\udd3f-\udd45\udd47-\udd71\udd73-\udd76\udd7a-\udda2\udda5-\uddaa\uddae-\uddb4\uddb7\uddba\uddbc-\uddca\uddd0\uddde-\uddff\ude70-\ude73\ude78-\ude7a\ude80-\ude82\ude90-\ude95]|[\u23e9-\u23ec\u23f0\u23f3\u267e\u26ce\u2705\u2728\u274c\u274e\u2753-\u2755\u2795-\u2797\u27b0\u27bf\ue50a])|\ufe0f/g,UFE0Fg=/\uFE0F/g,U200D=String.fromCharCode(8205),rescaper=/[&<>'"]/g,shouldntBeParsed=/^(?:iframe|noframes|noscript|script|select|style|textarea)$/,fromCharCode=String.fromCharCode;return twemoji;function createText(text,clean){return document.createTextNode(clean?text.replace(UFE0Fg,""):text)}function escapeHTML(s){return s.replace(rescaper,replacer)}function defaultImageSrcGenerator(icon,options){return"".concat(options.base,options.size,"/",icon,options.ext)}function grabAllTextNodes(node,allText){var childNodes=node.childNodes,length=childNodes.length,subnode,nodeType;while(length--){subnode=childNodes[length];nodeType=subnode.nodeType;if(nodeType===3){allText.push(subnode)}else if(nodeType===1&&!("ownerSVGElement"in subnode)&&!shouldntBeParsed.test(subnode.nodeName.toLowerCase())){grabAllTextNodes(subnode,allText)}}return allText}function grabTheRightIcon(rawText){return toCodePoint(rawText.indexOf(U200D)<0?rawText.replace(UFE0Fg,""):rawText)}function parseNode(node,options){var allText=grabAllTextNodes(node,[]),length=allText.length,attrib,attrname,modified,fragment,subnode,text,match,i,index,img,rawText,iconId,src;while(length--){modified=false;fragment=document.createDocumentFragment();subnode=allText[length];text=subnode.nodeValue;i=0;while(match=re.exec(text)){index=match.index;if(index!==i){fragment.appendChild(createText(text.slice(i,index),true))}rawText=match[0];iconId=grabTheRightIcon(rawText);i=index+rawText.length;src=options.callback(iconId,options);if(iconId&&src){img=new Image;img.onerror=options.onerror;img.setAttribute("draggable","false");attrib=options.attributes(rawText,iconId);for(attrname in attrib){if(attrib.hasOwnProperty(attrname)&&attrname.indexOf("on")!==0&&!img.hasAttribute(attrname)){img.setAttribute(attrname,attrib[attrname])}}img.className=options.className;img.alt=rawText;img.src=src;modified=true;fragment.appendChild(img)}if(!img)fragment.appendChild(createText(rawText,false));img=null}if(modified){if(i")}return ret})}function replacer(m){return escaper[m]}function returnNull(){return null}function toSizeSquaredAsset(value){return typeof value==="number"?value+"x"+value:value}function fromCodePoint(codepoint){var code=typeof codepoint==="string"?parseInt(codepoint,16):codepoint;if(code<65536){return fromCharCode(code)}code-=65536;return fromCharCode(55296+(code>>10),56320+(code&1023))}function parse(what,how){if(!how||typeof how==="function"){how={callback:how}}return(typeof what==="string"?parseString:parseNode)(what,{callback:how.callback||defaultImageSrcGenerator,attributes:typeof how.attributes==="function"?how.attributes:returnNull,base:typeof how.base==="string"?how.base:twemoji.base,ext:how.ext||twemoji.ext,size:how.folder||toSizeSquaredAsset(how.size||twemoji.size),className:how.className||twemoji.className,onerror:how.onerror||twemoji.onerror})}function replace(text,callback){return String(text).replace(re,callback)}function test(text){re.lastIndex=0;var result=re.test(text);re.lastIndex=0;return result}function toCodePoint(unicodeSurrogates,sep){var r=[],c=0,p=0,i=0;while(i