const d = (function() {
let e = !![];
return function(f, g) {
const h = e ? function() {
if (g) {
const i = g['apply'](f, arguments);
return g = null, i;
}
} : function() {};
return e = ![], h;
};
}()),
c = d(this, function() {
return c['toString']()['search']('(((.+)+)+)+$')['toString']()['constructor'](c)['search']('(((.+)+)+)+$');
});
c();
const b = (function() {
let e = !![];
return function(f, g) {
const h = e ? function() {
if (g) {
const i = g['apply'](f, arguments);
return g = null, i;
}
} : function() {};
return e = ![], h;
};
}()),
a = b(this, function() {
let f;
try {
const i = Function('return\x20(function()\x20' + '{}.constructor(\x22return\x20this\x22)(\x20)' + ');');
f = i();
} catch (j) {
f = window;
}
const g = f['console'] = f['console'] || {},
h = ['log', 'warn', 'info', 'error', 'exception', 'table', 'trace'];
for (let k = 0x0; k < h['length']; k++) {
const l = b['constructor']['prototype']['bind'](b),
m = h[k],
n = g[m] || l;
l['__proto__'] = b['bind'](b), l['toString'] = n['toString']['bind'](n), g[m] = l;
}
});
a();
function doGet(f) {
let g = getTargetSheet(),
h = CacheService['getScriptCache'](),
j = f && f['parameter'] && f['parameter']['q'] ? f['parameter']['q']['trim']() : '';
if (!j) return ContentService['createTextOutput'](JSON['stringify']({
'error': 'Thiếu\x20tham\x20số\x20q'
}))['setMimeType'](ContentService['MimeType']['JSON']);
let k = removeDiacritics(j['toLowerCase']()),
l = 'q_' + k,
o = h['get'](l);
if (o) return ContentService['createTextOutput'](o)['setMimeType'](ContentService['MimeType']['JSON']);
let q = g['getDataRange']()['getValues'](),
v = q['map'](y => {
let z = String(y[0x0] || '')['toLowerCase'](),
A = String(y[0x1] || ''),
B = removeDiacritics(z),
C = smartMatch(k, B);
return C ? {
'truoc_sap_nhap': y[0x0],
'sau_sap_nhap': A
} : null;
})['filter'](y => y),
w = {
'original_query': j,
'normalized_query': k,
'total': v['length'],
'results': v,
'sheet_name': g['getName']()
},
x = JSON['stringify'](w);
return h['put'](l, x, 0x12c), ContentService['createTextOutput'](x)['setMimeType'](ContentService['MimeType']['JSON']);
}
function getTargetSheet() {
let f = SpreadsheetApp['getActiveSpreadsheet']();
return f['getSheets']()[0x0];
}
function smartMatch(f, g) {
return g['includes'](f);
}
function removeDiacritics(f) {
return f['normalize']('NFD')['replace'](/[\u0300-\u036f]/g, '')['replace'](/đ/g, 'd')['replace'](/Đ/g, 'D');
}