recombee-js-api-client
Advanced tools
Comparing version 3.1.0 to 4.0.0
@@ -1,2 +0,2 @@ | ||
(function(e,t){'object'==typeof exports&&'object'==typeof module?module.exports=t():'function'==typeof define&&define.amd?define('recombee',[],t):'object'==typeof exports?exports.recombee=t():e.recombee=t()})('undefined'==typeof self?this:self,function(){return function(e){function t(r){if(a[r])return a[r].exports;var i=a[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var a={};return t.m=e,t.c=a,t.d=function(e,a,r){t.o(e,a)||Object.defineProperty(e,a,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var a=e&&e.__esModule?function(){return e['default']}:function(){return e};return t.d(a,'a',a),a},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p='',t(t.s=4)}([function(e,t){'use strict';t.Request=class{constructor(e,t,a){this.method=e,this.path=t,this.timeout=a}}},function(e,t){'use strict';class a extends Error{constructor(e){super(e),this.name=this.constructor.name,'function'==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error(e).stack}}t.ApiError=a},function(e,t,a){'use strict';const r=a(1);class i extends r.ApiError{constructor(e,t,a){super(a),this.request=e,this.statusCode=t}}t.ResponseError=i},function(e,t,a){'use strict';const r=a(1);class i extends r.ApiError{constructor(e){super(`Client did not get response within ${e.timeout} ms`),this.request=e}}t.TimeoutError=i},function(e,t,a){e.exports=a(5)},function(e,t,a){'use strict';t.ApiClient=a(6).ApiClient,t.ApiError=a(1).ApiError,t.ResponseError=a(2).ResponseError,t.TimeoutError=a(3).TimeoutError,t.MergeUsers=a(9).MergeUsers,t.AddDetailView=a(10).AddDetailView,t.AddPurchase=a(11).AddPurchase,t.AddRating=a(12).AddRating,t.AddCartAddition=a(13).AddCartAddition,t.AddBookmark=a(14).AddBookmark,t.SetViewPortion=a(15).SetViewPortion,t.RecommendItemsToUser=a(16).RecommendItemsToUser,t.RecommendItemsToItem=a(17).RecommendItemsToItem,t.RecommendNextItems=a(18).RecommendNextItems,t.SearchItems=a(19).SearchItems},function(e,t,a){'use strict';const r=a(7),i=a(8);t.ApiClient=class{constructor(e,t,a){this.databaseId=e,this.publicToken=t,this.options=a||{},this.baseUri=this.options.baseUri||'client-rapi.recombee.com',this.useHttps=!('useHttps'in this.options)||this.options.useHttps,this.async=!('async'in this.options)||this.options.async}send(e,t){var a=this;if(t===void 0&&window.Promise)return new Promise(function(t,r){a.send(e,function(e,a){e?r(e):t(a)})});var r=this._signUrl(e.path),s=(this.useHttps?'https://':'http://')+this.baseUri+r,o=new XMLHttpRequest;o.open('POST',s,this.async),o.setRequestHeader('Accept','application/json'),o.setRequestHeader('Content-Type','text/plain'),this.async&&(o.timeout=e.timeout),o.onreadystatechange=function(){if(4==this.readyState&&this.responseText)if(200==this.status){if(t)return t(null,JSON.parse(this.responseText));}else if(t)return t(new i.ResponseError(e,this.status,this.responseText))},o.ontimeout=function(){if(t)return t(new i.TimeoutError(e))},o.send(JSON.stringify(e.bodyParameters()))}_signUrl(e){let t='/'+this.databaseId+e;t+=(-1==e.indexOf('?')?'?':'&')+'frontend_timestamp='+parseInt(new Date().getTime()/1e3);let a=new r('SHA-1','TEXT');return a.setHMACKey(this.publicToken,'TEXT'),a.update(t),t+='&frontend_sign='+a.getHMAC('HEX'),t}}},function(e,r,i){'use strict';var s;(function(o){function n(i,e,s){var o,S,T,H,P,n,f,E,r,t=0,h=[],U=0,m=!1,c=[],I=[],x=!1,D=!1,g=-1;if(s=s||{},o=s.encoding||'UTF8',r=s.numRounds||1,r!==parseInt(r,10)||1>r)throw Error('numRounds must a integer >= 1');if('SHA-1'===i)P=512,n=A,f=K,H=160,E=function(e){return e.slice()};else if(0===i.lastIndexOf('SHA-',0)){if(n=function(e,t){return v(e,t,i)},f=function(t,r,s,o){var a,e;if('SHA-224'===i||'SHA-256'===i)a=(r+65>>>9<<4)+15,e=16;else if('SHA-384'===i||'SHA-512'===i)a=(r+129>>>10<<5)+31,e=32;else throw Error('Unexpected error in SHA-2 implementation');for(;t.length<=a;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=s,t[a]=4294967295&r,t[a-1]=0|r/4294967296,s=t.length,r=0;r<s;r+=e)o=v(t.slice(r,r+e),o,i);if('SHA-224'===i)t=[o[0],o[1],o[2],o[3],o[4],o[5],o[6]];else if('SHA-256'===i)t=o;else if('SHA-384'===i)t=[o[0].a,o[0].b,o[1].a,o[1].b,o[2].a,o[2].b,o[3].a,o[3].b,o[4].a,o[4].b,o[5].a,o[5].b];else if('SHA-512'===i)t=[o[0].a,o[0].b,o[1].a,o[1].b,o[2].a,o[2].b,o[3].a,o[3].b,o[4].a,o[4].b,o[5].a,o[5].b,o[6].a,o[6].b,o[7].a,o[7].b];else throw Error('Unexpected error in SHA-2 implementation');return t},E=function(e){return e.slice()},'SHA-224'===i)P=512,H=224;else if('SHA-256'===i)P=512,H=256;else if('SHA-384'===i)P=1024,H=384;else if('SHA-512'===i)P=1024,H=512;else throw Error('Chosen SHA variant is not supported');}else if(0===i.lastIndexOf('SHA3-',0)||0===i.lastIndexOf('SHAKE',0)){var Y=6;if(n=y,E=function(e){var t,a=[];for(t=0;5>t;t+=1)a[t]=e[t].slice();return a},g=1,'SHA3-224'===i)P=1152,H=224;else if('SHA3-256'===i)P=1088,H=256;else if('SHA3-384'===i)P=832,H=384;else if('SHA3-512'===i)P=576,H=512;else if('SHAKE128'===i)P=1344,H=-1,Y=31,D=!0;else if('SHAKE256'===i)P=1088,H=-1,Y=31,D=!0;else throw Error('Chosen SHA variant is not supported');f=function(t,r,i,a,s){i=P;var o,n=Y,e=[],d=i>>>5,m=0,u=r>>>5;for(o=0;o<u&&r>=i;o+=d)a=y(t.slice(o,o+d),a),r-=i;for(t=t.slice(o),r%=i;t.length<d;)t.push(0);for(o=r>>>3,t[o>>2]^=n<<8*(o%4),t[d-1]^=2147483648,a=y(t,a);32*e.length<s&&(t=a[m%5][0|m/5],e.push(t.b),!(32*e.length>=s));)e.push(t.a),m+=1,0==64*m%i&&(y(null,a),m=0);return e}}else throw Error('Chosen SHA variant is not supported');T=R(e,o,g),S=B(i),this.setHMACKey=function(r,s,a){var d;if(!0==m)throw Error('HMAC key already set');if(!0==x)throw Error('Cannot set HMAC key after calling update');if(!0==D)throw Error('SHAKE is not supported for HMAC');for(o=(a||{}).encoding||'UTF8',s=R(s,o,g)(r),r=s.binLen,s=s.value,d=P>>>3,a=d/4-1,d<r/8&&(s=f(s,r,0,B(i),H));s.length<=a;)s.push(0);for(r=0;r<=a;r+=1)c[r]=909522486^s[r],I[r]=1549556828^s[r];S=n(c,S),t=P,m=!0},this.update=function(r){var i,s,a,e=0,o=P>>>5;for(i=T(r,h,U),r=i.binLen,s=i.value,i=r>>>5,a=0;a<i;a+=o)e+P<=r&&(S=n(s.slice(a,a+o),S),e+=P);t+=e,h=s.slice(e>>>5),U=r%P,x=!0},this.getHash=function(s,o){var b,e,A,c;if(!0==m)throw Error('Cannot call getHash after setting HMAC key');if(A=C(o),!0==D){if(-1===A.shakeLen)throw Error('shakeLen must be specified in options');H=A.shakeLen}switch(s){case'HEX':b=function(e){return a(e,H,g,A)};break;case'B64':b=function(e){return d(e,H,g,A)};break;case'BYTES':b=function(e){return u(e,H,g)};break;case'ARRAYBUFFER':try{e=new ArrayBuffer(0)}catch(e){throw Error('ARRAYBUFFER not supported by this environment')}b=function(e){return p(e,H,g)};break;case'UINT8ARRAY':try{e=new Uint8Array(0)}catch(e){throw Error('UINT8ARRAY not supported by this environment')}b=function(e){return l(e,H,g)};break;default:throw Error('format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY');}for(c=f(h.slice(),U,t,E(S),H),e=1;e<r;e+=1)!0==D&&0!=H%32&&(c[c.length-1]&=16777215>>>24-H%32),c=f(c,H,0,B(i),H);return b(c)},this.getHMAC=function(r,s){var o,e,A,c;if(!1==m)throw Error('Cannot call getHMAC without first setting HMAC key');switch(A=C(s),r){case'HEX':o=function(e){return a(e,H,g,A)};break;case'B64':o=function(e){return d(e,H,g,A)};break;case'BYTES':o=function(e){return u(e,H,g)};break;case'ARRAYBUFFER':try{o=new ArrayBuffer(0)}catch(e){throw Error('ARRAYBUFFER not supported by this environment')}o=function(e){return p(e,H,g)};break;case'UINT8ARRAY':try{o=new Uint8Array(0)}catch(e){throw Error('UINT8ARRAY not supported by this environment')}o=function(e){return l(e,H,g)};break;default:throw Error('outputFormat must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY');}return e=f(h.slice(),U,t,E(S),H),c=n(I,B(i)),c=f(e,H,P,c,H),o(c)}}function I(e,t){this.a=e,this.b=t}function m(e,t,r,a){var i,s,o,n,d;for(t=t||[0],r=r||0,s=r>>>3,d=-1===a?3:0,i=0;i<e.length;i+=1)n=i+s,o=n>>>2,t.length<=o&&t.push(0),t[o]|=e[i]<<8*(d+n%4*a);return{value:t,binLen:8*e.length+r}}function a(t,a,r,e){var i='';a/=8;var s,o,n;for(n=-1===r?3:0,s=0;s<a;s+=1)o=t[s>>>2]>>>8*(n+s%4*r),i+='0123456789abcdef'.charAt(15&o>>>4)+'0123456789abcdef'.charAt(15&o);return e.outputUpper?i.toUpperCase():i}function d(t,a,r,e){var i,s,o,n,d='',c=a/8;for(n=-1===r?3:0,i=0;i<c;i+=3)for(s=i+1<c?t[i+1>>>2]:0,o=i+2<c?t[i+2>>>2]:0,o=(255&t[i>>>2]>>>8*(n+i%4*r))<<16|(255&s>>>8*(n+(i+1)%4*r))<<8|255&o>>>8*(n+(i+2)%4*r),s=0;4>s;s+=1)d+=8*i+6*s<=a?'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(63&o>>>6*(3-s)):e.b64Pad;return d}function u(t,a,r){var e='';a/=8;var i,s,o;for(o=-1===r?3:0,i=0;i<a;i+=1)s=255&t[i>>>2]>>>8*(o+i%4*r),e+=String.fromCharCode(s);return e}function p(t,a,r){a/=8;var e,i,s,o=new ArrayBuffer(a);for(s=new Uint8Array(o),i=-1===r?3:0,e=0;e<a;e+=1)s[e]=255&t[e>>>2]>>>8*(i+e%4*r);return o}function l(t,a,r){a/=8;var e,i,s=new Uint8Array(a);for(i=-1===r?3:0,e=0;e<a;e+=1)s[e]=255&t[e>>>2]>>>8*(i+e%4*r);return s}function C(e){var t={outputUpper:!1,b64Pad:'=',shakeLen:-1};if(e=e||{},t.outputUpper=e.outputUpper||!1,!0===e.hasOwnProperty('b64Pad')&&(t.b64Pad=e.b64Pad),!0===e.hasOwnProperty('shakeLen')){if(0!=e.shakeLen%8)throw Error('shakeLen must be a multiple of 8');t.shakeLen=e.shakeLen}if('boolean'!=typeof t.outputUpper)throw Error('Invalid outputUpper formatting option');if('string'!=typeof t.b64Pad)throw Error('Invalid b64Pad formatting option');return t}function R(t,i,s){switch(i){case'UTF8':case'UTF16BE':case'UTF16LE':break;default:throw Error('encoding must be UTF8, UTF16BE, or UTF16LE');}switch(t){case'HEX':t=function(e,t,r){var i,o,d,c,n,m,u=e.length;if(0!=u%2)throw Error('String of HEX type must be in byte increments');for(t=t||[0],r=r||0,n=r>>>3,m=-1===s?3:0,i=0;i<u;i+=2){if(o=parseInt(e.substr(i,2),16),isNaN(o))throw Error('String of HEX type contains invalid characters');for(c=(i>>>1)+n,d=c>>>2;t.length<=d;)t.push(0);t[d]|=o<<8*(m+c%4*s)}return{value:t,binLen:4*u+r}};break;case'TEXT':t=function(e,a,o){var c,m,l,b,n,A,u,r,t=0;if(a=a||[0],o=o||0,n=o>>>3,'UTF8'===i)for(r=-1===s?3:0,l=0;l<e.length;l+=1)for(c=e.charCodeAt(l),m=[],128>c?m.push(c):2048>c?(m.push(192|c>>>6),m.push(128|63&c)):55296>c||57344<=c?m.push(224|c>>>12,128|63&c>>>6,128|63&c):(l+=1,c=65536+((1023&c)<<10|1023&e.charCodeAt(l)),m.push(240|c>>>18,128|63&c>>>12,128|63&c>>>6,128|63&c)),b=0;b<m.length;b+=1){for(u=t+n,A=u>>>2;a.length<=A;)a.push(0);a[A]|=m[b]<<8*(r+u%4*s),t+=1}else if('UTF16BE'===i||'UTF16LE'===i)for(r=-1===s?2:0,m='UTF16LE'==i&&1!==s||'UTF16LE'!=i&&1===s,l=0;l<e.length;l+=1){for(c=e.charCodeAt(l),!0===m&&(b=255&c,c=b<<8|c>>>8),u=t+n,A=u>>>2;a.length<=A;)a.push(0);a[A]|=c<<8*(r+u%4*s),t+=2}return{value:a,binLen:8*t+o}};break;case'B64':t=function(e,i,o){var d,m,p,l,n,b,u,r,t=0;if(-1===e.search(/^[a-zA-Z0-9=+\/]+$/))throw Error('Invalid character in base-64 string');if(m=e.indexOf('='),e=e.replace(/\=/g,''),-1!==m&&m<e.length)throw Error('Invalid \'=\' found in base-64 string');for(i=i||[0],o=o||0,b=o>>>3,r=-1===s?3:0,m=0;m<e.length;m+=4){for(n=e.substr(m,4),p=l=0;p<n.length;p+=1)d='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.indexOf(n.charAt(p)),l|=d<<18-6*p;for(p=0;p<n.length-1;p+=1){for(u=t+b,d=u>>>2;i.length<=d;)i.push(0);i[d]|=(255&l>>>16-8*p)<<8*(r+u%4*s),t+=1}}return{value:i,binLen:8*t+o}};break;case'BYTES':t=function(e,t,r){var i,o,d,c,m,n;for(t=t||[0],r=r||0,d=r>>>3,n=-1===s?3:0,o=0;o<e.length;o+=1)i=e.charCodeAt(o),m=o+d,c=m>>>2,t.length<=c&&t.push(0),t[c]|=i<<8*(n+m%4*s);return{value:t,binLen:8*e.length+r}};break;case'ARRAYBUFFER':try{t=new ArrayBuffer(0)}catch(e){throw Error('ARRAYBUFFER not supported by this environment')}t=function(e,t,a){return m(new Uint8Array(e),t,a,s)};break;case'UINT8ARRAY':try{t=new Uint8Array(0)}catch(e){throw Error('UINT8ARRAY not supported by this environment')}t=function(e,t,a){return m(e,t,a,s)};break;default:throw Error('format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY');}return t}function S(e,t){return e<<t|e>>>32-t}function h(e,t){return 32<t?(t-=32,new I(e.b<<t|e.a>>>32-t,e.a<<t|e.b>>>32-t)):0===t?e:new I(e.a<<t|e.b>>>32-t,e.b<<t|e.a>>>32-t)}function b(e,t){return e>>>t|e<<32-t}function g(t,a){var r=null,r=new I(t.a,t.b);return r=32>=a?new I(r.a>>>a|4294967295&r.b<<32-a,r.b>>>a|4294967295&r.a<<32-a):new I(r.b>>>a-32|4294967295&r.a<<64-a,r.a>>>a-32|4294967295&r.b<<64-a)}function t(t,a){var r=null;return r=32>=a?new I(t.a>>>a,t.b>>>a|4294967295&t.a<<32-a):new I(0,t.a>>>a-32)}function T(t,r,i){return t&r^~t&i}function P(t,a,r){return new I(t.a&a.a^~t.a&r.a,t.b&a.b^~t.b&r.b)}function U(t,a,r){return t&a^t&r^a&r}function O(t,a,r){return new I(t.a&a.a^t.a&r.a^a.a&r.a,t.b&a.b^t.b&r.b^a.b&r.b)}function M(e){return b(e,2)^b(e,13)^b(e,22)}function N(t){var a=g(t,28),r=g(t,34);return t=g(t,39),new I(a.a^r.a^t.a,a.b^r.b^t.b)}function V(e){return b(e,6)^b(e,11)^b(e,25)}function j(t){var a=g(t,14),r=g(t,18);return t=g(t,41),new I(a.a^r.a^t.a,a.b^r.b^t.b)}function _(e){return b(e,7)^b(e,18)^e>>>3}function Q(a){var r=g(a,1),i=g(a,8);return a=t(a,7),new I(r.a^i.a^a.a,r.b^i.b^a.b)}function W(e){return b(e,17)^b(e,19)^e>>>10}function $(a){var r=g(a,19),i=g(a,61);return a=t(a,6),new I(r.a^i.a^a.a,r.b^i.b^a.b)}function ee(t,a){var r=(65535&t)+(65535&a);return(65535&(t>>>16)+(a>>>16)+(r>>>16))<<16|65535&r}function G(t,a,r,e){var i=(65535&t)+(65535&a)+(65535&r)+(65535&e);return(65535&(t>>>16)+(a>>>16)+(r>>>16)+(e>>>16)+(i>>>16))<<16|65535&i}function te(t,a,r,e,i){var s=(65535&t)+(65535&a)+(65535&r)+(65535&e)+(65535&i);return(65535&(t>>>16)+(a>>>16)+(r>>>16)+(e>>>16)+(i>>>16)+(s>>>16))<<16|65535&s}function H(t,a){var r,e,i;return r=(65535&t.b)+(65535&a.b),e=(t.b>>>16)+(a.b>>>16)+(r>>>16),i=(65535&e)<<16|65535&r,r=(65535&t.a)+(65535&a.a)+(e>>>16),e=(t.a>>>16)+(a.a>>>16)+(r>>>16),new I((65535&e)<<16|65535&r,i)}function ae(t,a,r,e){var i,s,o;return i=(65535&t.b)+(65535&a.b)+(65535&r.b)+(65535&e.b),s=(t.b>>>16)+(a.b>>>16)+(r.b>>>16)+(e.b>>>16)+(i>>>16),o=(65535&s)<<16|65535&i,i=(65535&t.a)+(65535&a.a)+(65535&r.a)+(65535&e.a)+(s>>>16),s=(t.a>>>16)+(a.a>>>16)+(r.a>>>16)+(e.a>>>16)+(i>>>16),new I((65535&s)<<16|65535&i,o)}function re(t,a,r,e,i){var s,o,n;return s=(65535&t.b)+(65535&a.b)+(65535&r.b)+(65535&e.b)+(65535&i.b),o=(t.b>>>16)+(a.b>>>16)+(r.b>>>16)+(e.b>>>16)+(i.b>>>16)+(s>>>16),n=(65535&o)<<16|65535&s,s=(65535&t.a)+(65535&a.a)+(65535&r.a)+(65535&e.a)+(65535&i.a)+(o>>>16),o=(t.a>>>16)+(a.a>>>16)+(r.a>>>16)+(e.a>>>16)+(i.a>>>16)+(s>>>16),new I((65535&o)<<16|65535&s,n)}function E(e,t){return new I(e.a^t.a,e.b^t.b)}function B(t){var a,e=[];if('SHA-1'===t)e=[1732584193,4023233417,2562383102,271733878,3285377520];else if(0===t.lastIndexOf('SHA-',0))switch(e=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],a=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],t){case'SHA-224':break;case'SHA-256':e=a;break;case'SHA-384':e=[new I(3418070365,e[0]),new I(1654270250,e[1]),new I(2438529370,e[2]),new I(355462360,e[3]),new I(1731405415,e[4]),new I(41048885895,e[5]),new I(3675008525,e[6]),new I(1203062813,e[7])];break;case'SHA-512':e=[new I(a[0],4089235720),new I(a[1],2227873595),new I(a[2],4271175723),new I(a[3],1595750129),new I(a[4],2917565137),new I(a[5],725511199),new I(a[6],4215389547),new I(a[7],327033209)];break;default:throw Error('Unknown SHA variant');}else if(0===t.lastIndexOf('SHA3-',0)||0===t.lastIndexOf('SHAKE',0))for(t=0;5>t;t+=1)e[t]=[new I(0,0),new I(0,0),new I(0,0),new I(0,0),new I(0,0)];else throw Error('No SHA variants supported');return e}function A(t,a){var r,i,s,o,n,d,m,u=[];for(r=a[0],i=a[1],s=a[2],o=a[3],n=a[4],m=0;80>m;m+=1)u[m]=16>m?t[m]:S(u[m-3]^u[m-8]^u[m-14]^u[m-16],1),d=20>m?te(S(r,5),i&s^~i&o,n,1518500249,u[m]):40>m?te(S(r,5),i^s^o,n,1859775393,u[m]):60>m?te(S(r,5),U(i,s,o),n,2400959708,u[m]):te(S(r,5),i^s^o,n,3395469782,u[m]),n=o,o=s,s=S(i,30),i=r,r=d;return a[0]=ee(r,a[0]),a[1]=ee(i,a[1]),a[2]=ee(s,a[2]),a[3]=ee(o,a[3]),a[4]=ee(n,a[4]),a}function K(t,a,r,e){var i;for(i=(a+65>>>9<<4)+15;t.length<=i;)t.push(0);for(t[a>>>5]|=128<<24-a%32,a+=r,t[i]=4294967295&a,t[i-1]=0|a/4294967296,a=t.length,i=0;i<a;i+=16)e=A(t.slice(i,i+16),e);return e}function v(a,i,s){var e,o,d,m,b,l,p,g,n,h,u,r,t,R,S,f,A,v,y,x,k,C,D,F=[];if('SHA-224'===s||'SHA-256'===s)h=64,r=1,C=Number,t=ee,R=G,S=te,f=_,A=W,v=M,y=V,k=U,x=T,D=L;else if('SHA-384'===s||'SHA-512'===s)h=80,r=2,C=I,t=H,R=ae,S=re,f=Q,A=$,v=N,y=j,k=O,x=P,D=c;else throw Error('Unexpected error in SHA-2 implementation');for(s=i[0],e=i[1],o=i[2],d=i[3],m=i[4],b=i[5],l=i[6],p=i[7],u=0;u<h;u+=1)16>u?(n=u*r,g=a.length<=n?0:a[n],n=a.length<=n+1?0:a[n+1],F[u]=new C(g,n)):F[u]=R(A(F[u-2]),F[u-7],f(F[u-15]),F[u-16]),g=S(p,y(m),x(m,b,l),D[u],F[u]),n=t(v(s),k(s,e,o)),p=l,l=b,b=m,m=t(d,g),d=o,o=e,e=s,s=t(g,n);return i[0]=t(s,i[0]),i[1]=t(e,i[1]),i[2]=t(o,i[2]),i[3]=t(d,i[3]),i[4]=t(m,i[4]),i[5]=t(b,i[5]),i[6]=t(l,i[6]),i[7]=t(p,i[7]),i}function y(t,a){var r,e,i,s,o=[],d=[];if(null!==t)for(e=0;e<t.length;e+=2)a[(e>>>1)%5][0|(e>>>1)/5]=E(a[(e>>>1)%5][0|(e>>>1)/5],new I(t[e+1],t[e]));for(r=0;24>r;r+=1){for(s=B('SHA3-'),e=0;5>e;e+=1){i=a[e][0];var c=a[e][1],m=a[e][2],u=a[e][3],n=a[e][4];o[e]=new I(i.a^c.a^m.a^u.a^n.a,i.b^c.b^m.b^u.b^n.b)}for(e=0;5>e;e+=1)d[e]=E(o[(e+4)%5],h(o[(e+1)%5],1));for(e=0;5>e;e+=1)for(i=0;5>i;i+=1)a[e][i]=E(a[e][i],d[e]);for(e=0;5>e;e+=1)for(i=0;5>i;i+=1)s[i][(2*e+3*i)%5]=h(a[e][i],f[e][i]);for(e=0;5>e;e+=1)for(i=0;5>i;i+=1)a[e][i]=E(s[e][i],new I(~s[(e+1)%5][i].a&s[(e+2)%5][i].a,~s[(e+1)%5][i].b&s[(e+2)%5][i].b));a[0][0]=E(a[0][0],x[r])}return a}var L,c,f,x;L=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],c=[new I(L[0],3609767458),new I(L[1],602891725),new I(L[2],3964484399),new I(L[3],2173295548),new I(L[4],4081628472),new I(L[5],3053834265),new I(L[6],2937671579),new I(L[7],3664609560),new I(L[8],2734883394),new I(L[9],1164996542),new I(L[10],1323610764),new I(L[11],3590304994),new I(L[12],4068182383),new I(L[13],991336113),new I(L[14],633803317),new I(L[15],3479774868),new I(L[16],2666613458),new I(L[17],944711139),new I(L[18],2341262773),new I(L[19],2007800933),new I(L[20],1495990901),new I(L[21],1856431235),new I(L[22],3175218132),new I(L[23],2198950837),new I(L[24],3999719339),new I(L[25],766784016),new I(L[26],2566594879),new I(L[27],3203337956),new I(L[28],1034457026),new I(L[29],2466948901),new I(L[30],3758326383),new I(L[31],168717936),new I(L[32],1188179964),new I(L[33],1546045734),new I(L[34],1522805485),new I(L[35],2643833823),new I(L[36],2343527390),new I(L[37],1014477480),new I(L[38],1206759142),new I(L[39],344077627),new I(L[40],1290863460),new I(L[41],3158454273),new I(L[42],3505952657),new I(L[43],106217008),new I(L[44],3606008344),new I(L[45],1432725776),new I(L[46],1467031594),new I(L[47],851169720),new I(L[48],3100823752),new I(L[49],1363258195),new I(L[50],3750685593),new I(L[51],3785050280),new I(L[52],3318307427),new I(L[53],3812723403),new I(L[54],2003034995),new I(L[55],3602036899),new I(L[56],1575990012),new I(L[57],1125592928),new I(L[58],2716904306),new I(L[59],442776044),new I(L[60],593698344),new I(L[61],3733110249),new I(L[62],2999351573),new I(L[63],3815920427),new I(3391569614,3928383900),new I(3515267271,566280711),new I(3940187606,3454069534),new I(4118630271,4000239992),new I(116418474,1914138554),new I(174292421,2731055270),new I(289380356,3203993006),new I(460393269,320620315),new I(685471733,587496836),new I(852142971,1086792851),new I(1017036298,365543100),new I(1126000580,2618297676),new I(1288033470,3409855158),new I(1501505948,4234509866),new I(1607167915,987167468),new I(1816402316,1246189591)],x=[new I(0,1),new I(0,32898),new I(2147483648,32906),new I(2147483648,2147516416),new I(0,32907),new I(0,2147483649),new I(2147483648,2147516545),new I(2147483648,32777),new I(0,138),new I(0,136),new I(0,2147516425),new I(0,2147483658),new I(0,2147516555),new I(2147483648,139),new I(2147483648,32905),new I(2147483648,32771),new I(2147483648,32770),new I(2147483648,128),new I(0,32778),new I(2147483648,2147483658),new I(2147483648,2147516545),new I(2147483648,32896),new I(0,2147483649),new I(2147483648,2147516424)],f=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]],(s=function(){return n}.call(r,i,r,e),!(s!==void 0&&(e.exports=s)))})(this)},function(e,t,a){'use strict';t.ApiError=a(1).ApiError,t.ResponseError=a(2).ResponseError,t.TimeoutError=a(3).TimeoutError},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a){super('PUT',`/users/${encodeURIComponent(e)}/merge/${encodeURIComponent(t)}`,3e4,!1),this.targetUserId=e,this.sourceUserId=t,a=a||{},this.cascadeCreate=a.cascadeCreate}bodyParameters(){let e={cascadeCreate:!(this.cascadeCreate!==void 0)||this.cascadeCreate};return e}}t.MergeUsers=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a){super('POST','/detailviews/',3e3,!1),this.userId=e,this.itemId=t,a=a||{},this.timestamp=a.timestamp,this.duration=a.duration,this.cascadeCreate=a.cascadeCreate,this.recommId=a.recommId,this.additionalData=a.additionalData}bodyParameters(){let e={};return e.userId=this.userId,e.itemId=this.itemId,void 0!==this.timestamp&&(e.timestamp=this.timestamp),void 0!==this.duration&&(e.duration=this.duration),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.recommId&&(e.recommId=this.recommId),void 0!==this.additionalData&&(e.additionalData=this.additionalData),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.AddDetailView=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a){super('POST','/purchases/',3e3,!1),this.userId=e,this.itemId=t,a=a||{},this.timestamp=a.timestamp,this.cascadeCreate=a.cascadeCreate,this.amount=a.amount,this.price=a.price,this.profit=a.profit,this.recommId=a.recommId,this.additionalData=a.additionalData}bodyParameters(){let e={};return e.userId=this.userId,e.itemId=this.itemId,void 0!==this.timestamp&&(e.timestamp=this.timestamp),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.amount&&(e.amount=this.amount),void 0!==this.price&&(e.price=this.price),void 0!==this.profit&&(e.profit=this.profit),void 0!==this.recommId&&(e.recommId=this.recommId),void 0!==this.additionalData&&(e.additionalData=this.additionalData),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.AddPurchase=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a,r){super('POST','/ratings/',3e3,!1),this.userId=e,this.itemId=t,this.rating=a,r=r||{},this.timestamp=r.timestamp,this.cascadeCreate=r.cascadeCreate,this.recommId=r.recommId,this.additionalData=r.additionalData}bodyParameters(){let e={};return e.userId=this.userId,e.itemId=this.itemId,e.rating=this.rating,void 0!==this.timestamp&&(e.timestamp=this.timestamp),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.recommId&&(e.recommId=this.recommId),void 0!==this.additionalData&&(e.additionalData=this.additionalData),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.AddRating=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a){super('POST','/cartadditions/',3e3,!1),this.userId=e,this.itemId=t,a=a||{},this.timestamp=a.timestamp,this.cascadeCreate=a.cascadeCreate,this.amount=a.amount,this.price=a.price,this.recommId=a.recommId,this.additionalData=a.additionalData}bodyParameters(){let e={};return e.userId=this.userId,e.itemId=this.itemId,void 0!==this.timestamp&&(e.timestamp=this.timestamp),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.amount&&(e.amount=this.amount),void 0!==this.price&&(e.price=this.price),void 0!==this.recommId&&(e.recommId=this.recommId),void 0!==this.additionalData&&(e.additionalData=this.additionalData),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.AddCartAddition=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a){super('POST','/bookmarks/',3e3,!1),this.userId=e,this.itemId=t,a=a||{},this.timestamp=a.timestamp,this.cascadeCreate=a.cascadeCreate,this.recommId=a.recommId,this.additionalData=a.additionalData}bodyParameters(){let e={};return e.userId=this.userId,e.itemId=this.itemId,void 0!==this.timestamp&&(e.timestamp=this.timestamp),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.recommId&&(e.recommId=this.recommId),void 0!==this.additionalData&&(e.additionalData=this.additionalData),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.AddBookmark=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a,r){super('POST','/viewportions/',3e3,!1),this.userId=e,this.itemId=t,this.portion=a,r=r||{},this.sessionId=r.sessionId,this.timestamp=r.timestamp,this.cascadeCreate=r.cascadeCreate,this.recommId=r.recommId,this.additionalData=r.additionalData}bodyParameters(){let e={};return e.userId=this.userId,e.itemId=this.itemId,e.portion=this.portion,void 0!==this.sessionId&&(e.sessionId=this.sessionId),void 0!==this.timestamp&&(e.timestamp=this.timestamp),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.recommId&&(e.recommId=this.recommId),void 0!==this.additionalData&&(e.additionalData=this.additionalData),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.SetViewPortion=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a){super('POST',`/recomms/users/${encodeURIComponent(e)}/items/`,9e3,!1),this.userId=e,this.count=t,a=a||{},this.scenario=a.scenario,this.cascadeCreate=a.cascadeCreate,this.returnProperties=a.returnProperties,this.includedProperties=a.includedProperties,this.filter=a.filter,this.booster=a.booster,this.logic=a.logic,this.diversity=a.diversity,this.minRelevance=a.minRelevance,this.rotationRate=a.rotationRate,this.rotationTime=a.rotationTime,this.expertSettings=a.expertSettings,this.returnAbGroup=a.returnAbGroup}bodyParameters(){let e={};return e.count=this.count,void 0!==this.scenario&&(e.scenario=this.scenario),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.returnProperties&&(e.returnProperties=this.returnProperties),void 0!==this.includedProperties&&(e.includedProperties=this.includedProperties),void 0!==this.filter&&(e.filter=this.filter),void 0!==this.booster&&(e.booster=this.booster),void 0!==this.logic&&(e.logic=this.logic),void 0!==this.diversity&&(e.diversity=this.diversity),void 0!==this.minRelevance&&(e.minRelevance=this.minRelevance),void 0!==this.rotationRate&&(e.rotationRate=this.rotationRate),void 0!==this.rotationTime&&(e.rotationTime=this.rotationTime),void 0!==this.expertSettings&&(e.expertSettings=this.expertSettings),void 0!==this.returnAbGroup&&(e.returnAbGroup=this.returnAbGroup),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.RecommendItemsToUser=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a,r){super('POST',`/recomms/items/${encodeURIComponent(e)}/items/`,9e3,!1),this.itemId=e,this.targetUserId=t,this.count=a,r=r||{},this.scenario=r.scenario,this.cascadeCreate=r.cascadeCreate,this.returnProperties=r.returnProperties,this.includedProperties=r.includedProperties,this.filter=r.filter,this.booster=r.booster,this.logic=r.logic,this.userImpact=r.userImpact,this.diversity=r.diversity,this.minRelevance=r.minRelevance,this.rotationRate=r.rotationRate,this.rotationTime=r.rotationTime,this.expertSettings=r.expertSettings,this.returnAbGroup=r.returnAbGroup}bodyParameters(){let e={};return e.targetUserId=this.targetUserId,e.count=this.count,void 0!==this.scenario&&(e.scenario=this.scenario),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.returnProperties&&(e.returnProperties=this.returnProperties),void 0!==this.includedProperties&&(e.includedProperties=this.includedProperties),void 0!==this.filter&&(e.filter=this.filter),void 0!==this.booster&&(e.booster=this.booster),void 0!==this.logic&&(e.logic=this.logic),void 0!==this.userImpact&&(e.userImpact=this.userImpact),void 0!==this.diversity&&(e.diversity=this.diversity),void 0!==this.minRelevance&&(e.minRelevance=this.minRelevance),void 0!==this.rotationRate&&(e.rotationRate=this.rotationRate),void 0!==this.rotationTime&&(e.rotationTime=this.rotationTime),void 0!==this.expertSettings&&(e.expertSettings=this.expertSettings),void 0!==this.returnAbGroup&&(e.returnAbGroup=this.returnAbGroup),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.RecommendItemsToItem=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t){super('POST',`/recomms/next/items/${encodeURIComponent(e)}`,9e3,!1),this.recommId=e,this.count=t}bodyParameters(){let e={count:this.count,cascadeCreate:!(this.cascadeCreate!==void 0)||this.cascadeCreate};return e}}t.RecommendNextItems=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a,r){super('POST',`/search/users/${encodeURIComponent(e)}/items/`,9e3,!1),this.userId=e,this.searchQuery=t,this.count=a,r=r||{},this.scenario=r.scenario,this.cascadeCreate=r.cascadeCreate,this.returnProperties=r.returnProperties,this.includedProperties=r.includedProperties,this.filter=r.filter,this.booster=r.booster,this.logic=r.logic,this.expertSettings=r.expertSettings,this.returnAbGroup=r.returnAbGroup}bodyParameters(){let e={};return e.searchQuery=this.searchQuery,e.count=this.count,void 0!==this.scenario&&(e.scenario=this.scenario),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.returnProperties&&(e.returnProperties=this.returnProperties),void 0!==this.includedProperties&&(e.includedProperties=this.includedProperties),void 0!==this.filter&&(e.filter=this.filter),void 0!==this.booster&&(e.booster=this.booster),void 0!==this.logic&&(e.logic=this.logic),void 0!==this.expertSettings&&(e.expertSettings=this.expertSettings),void 0!==this.returnAbGroup&&(e.returnAbGroup=this.returnAbGroup),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.SearchItems=i}])}); | ||
(function(e,t){'object'==typeof exports&&'object'==typeof module?module.exports=t():'function'==typeof define&&define.amd?define('recombee',[],t):'object'==typeof exports?exports.recombee=t():e.recombee=t()})('undefined'==typeof self?this:self,function(){return function(e){function t(r){if(a[r])return a[r].exports;var i=a[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var a={};return t.m=e,t.c=a,t.d=function(e,a,r){t.o(e,a)||Object.defineProperty(e,a,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var a=e&&e.__esModule?function(){return e['default']}:function(){return e};return t.d(a,'a',a),a},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p='',t(t.s=4)}([function(e,t){'use strict';t.Request=class{constructor(e,t,a){this.method=e,this.path=t,this.timeout=a}}},function(e,t){'use strict';class a extends Error{constructor(e){super(e),this.name=this.constructor.name,'function'==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error(e).stack}}t.ApiError=a},function(e,t,a){'use strict';const r=a(1);class i extends r.ApiError{constructor(e,t,a){super(a),this.request=e,this.statusCode=t}}t.ResponseError=i},function(e,t,a){'use strict';const r=a(1);class i extends r.ApiError{constructor(e){super(`Client did not get response within ${e.timeout} ms`),this.request=e}}t.TimeoutError=i},function(e,t,a){e.exports=a(5)},function(e,t,a){'use strict';t.ApiClient=a(6).ApiClient,t.ApiError=a(1).ApiError,t.ResponseError=a(2).ResponseError,t.TimeoutError=a(3).TimeoutError,t.MergeUsers=a(9).MergeUsers,t.AddDetailView=a(10).AddDetailView,t.AddPurchase=a(11).AddPurchase,t.AddRating=a(12).AddRating,t.AddCartAddition=a(13).AddCartAddition,t.AddBookmark=a(14).AddBookmark,t.SetViewPortion=a(15).SetViewPortion,t.RecommendItemsToUser=a(16).RecommendItemsToUser,t.RecommendItemsToItem=a(17).RecommendItemsToItem,t.RecommendNextItems=a(18).RecommendNextItems,t.SearchItems=a(19).SearchItems},function(e,t,a){'use strict';const r=a(7),i=a(8);t.ApiClient=class{constructor(e,t,a){this.databaseId=e,this.publicToken=t,this.options=a||{},this.baseUri=this._getBaseUri(),this.useHttps=!('useHttps'in this.options)||this.options.useHttps,this.async=!('async'in this.options)||this.options.async}_getRegionalBaseUri(e){const t={"ap-se":'client-rapi-ap-se.recombee.com',"ca-east":'client-rapi-ca-east.recombee.com',"eu-west":'client-rapi-eu-west.recombee.com',"us-west":'client-rapi-us-west.recombee.com'}[e.toLowerCase()];if(t===void 0)throw new Error(`Region "${e}" is unknown. You may need to update the version of the SDK.`);return t}_getBaseUri(){let e=this.options.baseUri;if(this.options.region){if(e)throw new Error('baseUri and region cannot be specified at the same time');e=this._getRegionalBaseUri(this.options.region)}return e||'client-rapi.recombee.com'}send(e,t){var a=this;if(t===void 0&&window.Promise)return new Promise(function(t,r){a.send(e,function(e,a){e?r(e):t(a)})});var r=this._signUrl(e.path),s=(this.useHttps?'https://':'http://')+this.baseUri+r,o=new XMLHttpRequest;o.open('POST',s,this.async),o.setRequestHeader('Accept','application/json'),o.setRequestHeader('Content-Type','text/plain'),this.async&&(o.timeout=e.timeout),o.onreadystatechange=function(){if(4==this.readyState&&this.responseText)if(200==this.status){if(t)return t(null,JSON.parse(this.responseText));}else if(t)return t(new i.ResponseError(e,this.status,this.responseText))},o.ontimeout=function(){if(t)return t(new i.TimeoutError(e))},o.send(JSON.stringify(e.bodyParameters()))}_signUrl(e){let t='/'+this.databaseId+e;t+=(-1==e.indexOf('?')?'?':'&')+'frontend_timestamp='+parseInt(new Date().getTime()/1e3);let a=new r('SHA-1','TEXT');return a.setHMACKey(this.publicToken,'TEXT'),a.update(t),t+='&frontend_sign='+a.getHMAC('HEX'),t}}},function(e,r,i){'use strict';var s;(function(o){function n(i,e,s){var o,S,T,H,P,n,f,U,r,t=0,h=[],E=0,m=!1,c=[],I=[],x=!1,D=!1,g=-1;if(s=s||{},o=s.encoding||'UTF8',r=s.numRounds||1,r!==parseInt(r,10)||1>r)throw Error('numRounds must a integer >= 1');if('SHA-1'===i)P=512,n=A,f=K,H=160,U=function(e){return e.slice()};else if(0===i.lastIndexOf('SHA-',0)){if(n=function(e,t){return v(e,t,i)},f=function(t,r,s,o){var a,e;if('SHA-224'===i||'SHA-256'===i)a=(r+65>>>9<<4)+15,e=16;else if('SHA-384'===i||'SHA-512'===i)a=(r+129>>>10<<5)+31,e=32;else throw Error('Unexpected error in SHA-2 implementation');for(;t.length<=a;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=s,t[a]=4294967295&r,t[a-1]=0|r/4294967296,s=t.length,r=0;r<s;r+=e)o=v(t.slice(r,r+e),o,i);if('SHA-224'===i)t=[o[0],o[1],o[2],o[3],o[4],o[5],o[6]];else if('SHA-256'===i)t=o;else if('SHA-384'===i)t=[o[0].a,o[0].b,o[1].a,o[1].b,o[2].a,o[2].b,o[3].a,o[3].b,o[4].a,o[4].b,o[5].a,o[5].b];else if('SHA-512'===i)t=[o[0].a,o[0].b,o[1].a,o[1].b,o[2].a,o[2].b,o[3].a,o[3].b,o[4].a,o[4].b,o[5].a,o[5].b,o[6].a,o[6].b,o[7].a,o[7].b];else throw Error('Unexpected error in SHA-2 implementation');return t},U=function(e){return e.slice()},'SHA-224'===i)P=512,H=224;else if('SHA-256'===i)P=512,H=256;else if('SHA-384'===i)P=1024,H=384;else if('SHA-512'===i)P=1024,H=512;else throw Error('Chosen SHA variant is not supported');}else if(0===i.lastIndexOf('SHA3-',0)||0===i.lastIndexOf('SHAKE',0)){var Y=6;if(n=y,U=function(e){var t,a=[];for(t=0;5>t;t+=1)a[t]=e[t].slice();return a},g=1,'SHA3-224'===i)P=1152,H=224;else if('SHA3-256'===i)P=1088,H=256;else if('SHA3-384'===i)P=832,H=384;else if('SHA3-512'===i)P=576,H=512;else if('SHAKE128'===i)P=1344,H=-1,Y=31,D=!0;else if('SHAKE256'===i)P=1088,H=-1,Y=31,D=!0;else throw Error('Chosen SHA variant is not supported');f=function(t,r,i,a,s){i=P;var o,n=Y,e=[],d=i>>>5,m=0,p=r>>>5;for(o=0;o<p&&r>=i;o+=d)a=y(t.slice(o,o+d),a),r-=i;for(t=t.slice(o),r%=i;t.length<d;)t.push(0);for(o=r>>>3,t[o>>2]^=n<<8*(o%4),t[d-1]^=2147483648,a=y(t,a);32*e.length<s&&(t=a[m%5][0|m/5],e.push(t.b),!(32*e.length>=s));)e.push(t.a),m+=1,0==64*m%i&&(y(null,a),m=0);return e}}else throw Error('Chosen SHA variant is not supported');T=R(e,o,g),S=B(i),this.setHMACKey=function(r,s,a){var d;if(!0==m)throw Error('HMAC key already set');if(!0==x)throw Error('Cannot set HMAC key after calling update');if(!0==D)throw Error('SHAKE is not supported for HMAC');for(o=(a||{}).encoding||'UTF8',s=R(s,o,g)(r),r=s.binLen,s=s.value,d=P>>>3,a=d/4-1,d<r/8&&(s=f(s,r,0,B(i),H));s.length<=a;)s.push(0);for(r=0;r<=a;r+=1)c[r]=909522486^s[r],I[r]=1549556828^s[r];S=n(c,S),t=P,m=!0},this.update=function(r){var i,s,a,e=0,o=P>>>5;for(i=T(r,h,E),r=i.binLen,s=i.value,i=r>>>5,a=0;a<i;a+=o)e+P<=r&&(S=n(s.slice(a,a+o),S),e+=P);t+=e,h=s.slice(e>>>5),E=r%P,x=!0},this.getHash=function(s,o){var b,e,A,c;if(!0==m)throw Error('Cannot call getHash after setting HMAC key');if(A=C(o),!0==D){if(-1===A.shakeLen)throw Error('shakeLen must be specified in options');H=A.shakeLen}switch(s){case'HEX':b=function(e){return a(e,H,g,A)};break;case'B64':b=function(e){return d(e,H,g,A)};break;case'BYTES':b=function(e){return p(e,H,g)};break;case'ARRAYBUFFER':try{e=new ArrayBuffer(0)}catch(e){throw Error('ARRAYBUFFER not supported by this environment')}b=function(e){return u(e,H,g)};break;case'UINT8ARRAY':try{e=new Uint8Array(0)}catch(e){throw Error('UINT8ARRAY not supported by this environment')}b=function(e){return l(e,H,g)};break;default:throw Error('format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY');}for(c=f(h.slice(),E,t,U(S),H),e=1;e<r;e+=1)!0==D&&0!=H%32&&(c[c.length-1]&=16777215>>>24-H%32),c=f(c,H,0,B(i),H);return b(c)},this.getHMAC=function(r,s){var o,e,A,c;if(!1==m)throw Error('Cannot call getHMAC without first setting HMAC key');switch(A=C(s),r){case'HEX':o=function(e){return a(e,H,g,A)};break;case'B64':o=function(e){return d(e,H,g,A)};break;case'BYTES':o=function(e){return p(e,H,g)};break;case'ARRAYBUFFER':try{o=new ArrayBuffer(0)}catch(e){throw Error('ARRAYBUFFER not supported by this environment')}o=function(e){return u(e,H,g)};break;case'UINT8ARRAY':try{o=new Uint8Array(0)}catch(e){throw Error('UINT8ARRAY not supported by this environment')}o=function(e){return l(e,H,g)};break;default:throw Error('outputFormat must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY');}return e=f(h.slice(),E,t,U(S),H),c=n(I,B(i)),c=f(e,H,P,c,H),o(c)}}function I(e,t){this.a=e,this.b=t}function m(e,t,r,a){var i,s,o,n,d;for(t=t||[0],r=r||0,s=r>>>3,d=-1===a?3:0,i=0;i<e.length;i+=1)n=i+s,o=n>>>2,t.length<=o&&t.push(0),t[o]|=e[i]<<8*(d+n%4*a);return{value:t,binLen:8*e.length+r}}function a(t,a,r,e){var i='';a/=8;var s,o,n;for(n=-1===r?3:0,s=0;s<a;s+=1)o=t[s>>>2]>>>8*(n+s%4*r),i+='0123456789abcdef'.charAt(15&o>>>4)+'0123456789abcdef'.charAt(15&o);return e.outputUpper?i.toUpperCase():i}function d(t,a,r,e){var i,s,o,n,d='',c=a/8;for(n=-1===r?3:0,i=0;i<c;i+=3)for(s=i+1<c?t[i+1>>>2]:0,o=i+2<c?t[i+2>>>2]:0,o=(255&t[i>>>2]>>>8*(n+i%4*r))<<16|(255&s>>>8*(n+(i+1)%4*r))<<8|255&o>>>8*(n+(i+2)%4*r),s=0;4>s;s+=1)d+=8*i+6*s<=a?'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(63&o>>>6*(3-s)):e.b64Pad;return d}function p(t,a,r){var e='';a/=8;var i,s,o;for(o=-1===r?3:0,i=0;i<a;i+=1)s=255&t[i>>>2]>>>8*(o+i%4*r),e+=String.fromCharCode(s);return e}function u(t,a,r){a/=8;var e,i,s,o=new ArrayBuffer(a);for(s=new Uint8Array(o),i=-1===r?3:0,e=0;e<a;e+=1)s[e]=255&t[e>>>2]>>>8*(i+e%4*r);return o}function l(t,a,r){a/=8;var e,i,s=new Uint8Array(a);for(i=-1===r?3:0,e=0;e<a;e+=1)s[e]=255&t[e>>>2]>>>8*(i+e%4*r);return s}function C(e){var t={outputUpper:!1,b64Pad:'=',shakeLen:-1};if(e=e||{},t.outputUpper=e.outputUpper||!1,!0===e.hasOwnProperty('b64Pad')&&(t.b64Pad=e.b64Pad),!0===e.hasOwnProperty('shakeLen')){if(0!=e.shakeLen%8)throw Error('shakeLen must be a multiple of 8');t.shakeLen=e.shakeLen}if('boolean'!=typeof t.outputUpper)throw Error('Invalid outputUpper formatting option');if('string'!=typeof t.b64Pad)throw Error('Invalid b64Pad formatting option');return t}function R(t,i,s){switch(i){case'UTF8':case'UTF16BE':case'UTF16LE':break;default:throw Error('encoding must be UTF8, UTF16BE, or UTF16LE');}switch(t){case'HEX':t=function(e,t,r){var i,o,d,c,n,m,p=e.length;if(0!=p%2)throw Error('String of HEX type must be in byte increments');for(t=t||[0],r=r||0,n=r>>>3,m=-1===s?3:0,i=0;i<p;i+=2){if(o=parseInt(e.substr(i,2),16),isNaN(o))throw Error('String of HEX type contains invalid characters');for(c=(i>>>1)+n,d=c>>>2;t.length<=d;)t.push(0);t[d]|=o<<8*(m+c%4*s)}return{value:t,binLen:4*p+r}};break;case'TEXT':t=function(e,a,o){var c,m,l,b,n,A,u,r,t=0;if(a=a||[0],o=o||0,n=o>>>3,'UTF8'===i)for(r=-1===s?3:0,l=0;l<e.length;l+=1)for(c=e.charCodeAt(l),m=[],128>c?m.push(c):2048>c?(m.push(192|c>>>6),m.push(128|63&c)):55296>c||57344<=c?m.push(224|c>>>12,128|63&c>>>6,128|63&c):(l+=1,c=65536+((1023&c)<<10|1023&e.charCodeAt(l)),m.push(240|c>>>18,128|63&c>>>12,128|63&c>>>6,128|63&c)),b=0;b<m.length;b+=1){for(u=t+n,A=u>>>2;a.length<=A;)a.push(0);a[A]|=m[b]<<8*(r+u%4*s),t+=1}else if('UTF16BE'===i||'UTF16LE'===i)for(r=-1===s?2:0,m='UTF16LE'==i&&1!==s||'UTF16LE'!=i&&1===s,l=0;l<e.length;l+=1){for(c=e.charCodeAt(l),!0===m&&(b=255&c,c=b<<8|c>>>8),u=t+n,A=u>>>2;a.length<=A;)a.push(0);a[A]|=c<<8*(r+u%4*s),t+=2}return{value:a,binLen:8*t+o}};break;case'B64':t=function(e,i,o){var d,m,p,l,n,b,u,r,t=0;if(-1===e.search(/^[a-zA-Z0-9=+\/]+$/))throw Error('Invalid character in base-64 string');if(m=e.indexOf('='),e=e.replace(/\=/g,''),-1!==m&&m<e.length)throw Error('Invalid \'=\' found in base-64 string');for(i=i||[0],o=o||0,b=o>>>3,r=-1===s?3:0,m=0;m<e.length;m+=4){for(n=e.substr(m,4),p=l=0;p<n.length;p+=1)d='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.indexOf(n.charAt(p)),l|=d<<18-6*p;for(p=0;p<n.length-1;p+=1){for(u=t+b,d=u>>>2;i.length<=d;)i.push(0);i[d]|=(255&l>>>16-8*p)<<8*(r+u%4*s),t+=1}}return{value:i,binLen:8*t+o}};break;case'BYTES':t=function(e,t,r){var i,o,d,c,m,n;for(t=t||[0],r=r||0,d=r>>>3,n=-1===s?3:0,o=0;o<e.length;o+=1)i=e.charCodeAt(o),m=o+d,c=m>>>2,t.length<=c&&t.push(0),t[c]|=i<<8*(n+m%4*s);return{value:t,binLen:8*e.length+r}};break;case'ARRAYBUFFER':try{t=new ArrayBuffer(0)}catch(e){throw Error('ARRAYBUFFER not supported by this environment')}t=function(e,t,a){return m(new Uint8Array(e),t,a,s)};break;case'UINT8ARRAY':try{t=new Uint8Array(0)}catch(e){throw Error('UINT8ARRAY not supported by this environment')}t=function(e,t,a){return m(e,t,a,s)};break;default:throw Error('format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY');}return t}function S(e,t){return e<<t|e>>>32-t}function h(e,t){return 32<t?(t-=32,new I(e.b<<t|e.a>>>32-t,e.a<<t|e.b>>>32-t)):0===t?e:new I(e.a<<t|e.b>>>32-t,e.b<<t|e.a>>>32-t)}function b(e,t){return e>>>t|e<<32-t}function g(t,a){var r=null,r=new I(t.a,t.b);return r=32>=a?new I(r.a>>>a|4294967295&r.b<<32-a,r.b>>>a|4294967295&r.a<<32-a):new I(r.b>>>a-32|4294967295&r.a<<64-a,r.a>>>a-32|4294967295&r.b<<64-a)}function t(t,a){var r=null;return r=32>=a?new I(t.a>>>a,t.b>>>a|4294967295&t.a<<32-a):new I(0,t.a>>>a-32)}function T(t,r,i){return t&r^~t&i}function P(t,a,r){return new I(t.a&a.a^~t.a&r.a,t.b&a.b^~t.b&r.b)}function U(t,a,r){return t&a^t&r^a&r}function O(t,a,r){return new I(t.a&a.a^t.a&r.a^a.a&r.a,t.b&a.b^t.b&r.b^a.b&r.b)}function M(e){return b(e,2)^b(e,13)^b(e,22)}function N(t){var a=g(t,28),r=g(t,34);return t=g(t,39),new I(a.a^r.a^t.a,a.b^r.b^t.b)}function V(e){return b(e,6)^b(e,11)^b(e,25)}function _(t){var a=g(t,14),r=g(t,18);return t=g(t,41),new I(a.a^r.a^t.a,a.b^r.b^t.b)}function j(e){return b(e,7)^b(e,18)^e>>>3}function Q(a){var r=g(a,1),i=g(a,8);return a=t(a,7),new I(r.a^i.a^a.a,r.b^i.b^a.b)}function W(e){return b(e,17)^b(e,19)^e>>>10}function $(a){var r=g(a,19),i=g(a,61);return a=t(a,6),new I(r.a^i.a^a.a,r.b^i.b^a.b)}function ee(t,a){var r=(65535&t)+(65535&a);return(65535&(t>>>16)+(a>>>16)+(r>>>16))<<16|65535&r}function G(t,a,r,e){var i=(65535&t)+(65535&a)+(65535&r)+(65535&e);return(65535&(t>>>16)+(a>>>16)+(r>>>16)+(e>>>16)+(i>>>16))<<16|65535&i}function te(t,a,r,e,i){var s=(65535&t)+(65535&a)+(65535&r)+(65535&e)+(65535&i);return(65535&(t>>>16)+(a>>>16)+(r>>>16)+(e>>>16)+(i>>>16)+(s>>>16))<<16|65535&s}function H(t,a){var r,e,i;return r=(65535&t.b)+(65535&a.b),e=(t.b>>>16)+(a.b>>>16)+(r>>>16),i=(65535&e)<<16|65535&r,r=(65535&t.a)+(65535&a.a)+(e>>>16),e=(t.a>>>16)+(a.a>>>16)+(r>>>16),new I((65535&e)<<16|65535&r,i)}function ae(t,a,r,e){var i,s,o;return i=(65535&t.b)+(65535&a.b)+(65535&r.b)+(65535&e.b),s=(t.b>>>16)+(a.b>>>16)+(r.b>>>16)+(e.b>>>16)+(i>>>16),o=(65535&s)<<16|65535&i,i=(65535&t.a)+(65535&a.a)+(65535&r.a)+(65535&e.a)+(s>>>16),s=(t.a>>>16)+(a.a>>>16)+(r.a>>>16)+(e.a>>>16)+(i>>>16),new I((65535&s)<<16|65535&i,o)}function re(t,a,r,e,i){var s,o,n;return s=(65535&t.b)+(65535&a.b)+(65535&r.b)+(65535&e.b)+(65535&i.b),o=(t.b>>>16)+(a.b>>>16)+(r.b>>>16)+(e.b>>>16)+(i.b>>>16)+(s>>>16),n=(65535&o)<<16|65535&s,s=(65535&t.a)+(65535&a.a)+(65535&r.a)+(65535&e.a)+(65535&i.a)+(o>>>16),o=(t.a>>>16)+(a.a>>>16)+(r.a>>>16)+(e.a>>>16)+(i.a>>>16)+(s>>>16),new I((65535&o)<<16|65535&s,n)}function E(e,t){return new I(e.a^t.a,e.b^t.b)}function B(t){var a,e=[];if('SHA-1'===t)e=[1732584193,4023233417,2562383102,271733878,3285377520];else if(0===t.lastIndexOf('SHA-',0))switch(e=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],a=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],t){case'SHA-224':break;case'SHA-256':e=a;break;case'SHA-384':e=[new I(3418070365,e[0]),new I(1654270250,e[1]),new I(2438529370,e[2]),new I(355462360,e[3]),new I(1731405415,e[4]),new I(41048885895,e[5]),new I(3675008525,e[6]),new I(1203062813,e[7])];break;case'SHA-512':e=[new I(a[0],4089235720),new I(a[1],2227873595),new I(a[2],4271175723),new I(a[3],1595750129),new I(a[4],2917565137),new I(a[5],725511199),new I(a[6],4215389547),new I(a[7],327033209)];break;default:throw Error('Unknown SHA variant');}else if(0===t.lastIndexOf('SHA3-',0)||0===t.lastIndexOf('SHAKE',0))for(t=0;5>t;t+=1)e[t]=[new I(0,0),new I(0,0),new I(0,0),new I(0,0),new I(0,0)];else throw Error('No SHA variants supported');return e}function A(t,a){var r,i,s,o,n,d,m,p=[];for(r=a[0],i=a[1],s=a[2],o=a[3],n=a[4],m=0;80>m;m+=1)p[m]=16>m?t[m]:S(p[m-3]^p[m-8]^p[m-14]^p[m-16],1),d=20>m?te(S(r,5),i&s^~i&o,n,1518500249,p[m]):40>m?te(S(r,5),i^s^o,n,1859775393,p[m]):60>m?te(S(r,5),U(i,s,o),n,2400959708,p[m]):te(S(r,5),i^s^o,n,3395469782,p[m]),n=o,o=s,s=S(i,30),i=r,r=d;return a[0]=ee(r,a[0]),a[1]=ee(i,a[1]),a[2]=ee(s,a[2]),a[3]=ee(o,a[3]),a[4]=ee(n,a[4]),a}function K(t,a,r,e){var i;for(i=(a+65>>>9<<4)+15;t.length<=i;)t.push(0);for(t[a>>>5]|=128<<24-a%32,a+=r,t[i]=4294967295&a,t[i-1]=0|a/4294967296,a=t.length,i=0;i<a;i+=16)e=A(t.slice(i,i+16),e);return e}function v(a,i,s){var e,o,d,m,b,l,p,g,n,h,u,r,t,R,S,f,A,v,y,x,k,C,D,F=[];if('SHA-224'===s||'SHA-256'===s)h=64,r=1,C=Number,t=ee,R=G,S=te,f=j,A=W,v=M,y=V,k=U,x=T,D=L;else if('SHA-384'===s||'SHA-512'===s)h=80,r=2,C=I,t=H,R=ae,S=re,f=Q,A=$,v=N,y=_,k=O,x=P,D=c;else throw Error('Unexpected error in SHA-2 implementation');for(s=i[0],e=i[1],o=i[2],d=i[3],m=i[4],b=i[5],l=i[6],p=i[7],u=0;u<h;u+=1)16>u?(n=u*r,g=a.length<=n?0:a[n],n=a.length<=n+1?0:a[n+1],F[u]=new C(g,n)):F[u]=R(A(F[u-2]),F[u-7],f(F[u-15]),F[u-16]),g=S(p,y(m),x(m,b,l),D[u],F[u]),n=t(v(s),k(s,e,o)),p=l,l=b,b=m,m=t(d,g),d=o,o=e,e=s,s=t(g,n);return i[0]=t(s,i[0]),i[1]=t(e,i[1]),i[2]=t(o,i[2]),i[3]=t(d,i[3]),i[4]=t(m,i[4]),i[5]=t(b,i[5]),i[6]=t(l,i[6]),i[7]=t(p,i[7]),i}function y(t,a){var r,e,i,s,o=[],d=[];if(null!==t)for(e=0;e<t.length;e+=2)a[(e>>>1)%5][0|(e>>>1)/5]=E(a[(e>>>1)%5][0|(e>>>1)/5],new I(t[e+1],t[e]));for(r=0;24>r;r+=1){for(s=B('SHA3-'),e=0;5>e;e+=1){i=a[e][0];var c=a[e][1],m=a[e][2],p=a[e][3],n=a[e][4];o[e]=new I(i.a^c.a^m.a^p.a^n.a,i.b^c.b^m.b^p.b^n.b)}for(e=0;5>e;e+=1)d[e]=E(o[(e+4)%5],h(o[(e+1)%5],1));for(e=0;5>e;e+=1)for(i=0;5>i;i+=1)a[e][i]=E(a[e][i],d[e]);for(e=0;5>e;e+=1)for(i=0;5>i;i+=1)s[i][(2*e+3*i)%5]=h(a[e][i],f[e][i]);for(e=0;5>e;e+=1)for(i=0;5>i;i+=1)a[e][i]=E(s[e][i],new I(~s[(e+1)%5][i].a&s[(e+2)%5][i].a,~s[(e+1)%5][i].b&s[(e+2)%5][i].b));a[0][0]=E(a[0][0],x[r])}return a}var L,c,f,x;L=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],c=[new I(L[0],3609767458),new I(L[1],602891725),new I(L[2],3964484399),new I(L[3],2173295548),new I(L[4],4081628472),new I(L[5],3053834265),new I(L[6],2937671579),new I(L[7],3664609560),new I(L[8],2734883394),new I(L[9],1164996542),new I(L[10],1323610764),new I(L[11],3590304994),new I(L[12],4068182383),new I(L[13],991336113),new I(L[14],633803317),new I(L[15],3479774868),new I(L[16],2666613458),new I(L[17],944711139),new I(L[18],2341262773),new I(L[19],2007800933),new I(L[20],1495990901),new I(L[21],1856431235),new I(L[22],3175218132),new I(L[23],2198950837),new I(L[24],3999719339),new I(L[25],766784016),new I(L[26],2566594879),new I(L[27],3203337956),new I(L[28],1034457026),new I(L[29],2466948901),new I(L[30],3758326383),new I(L[31],168717936),new I(L[32],1188179964),new I(L[33],1546045734),new I(L[34],1522805485),new I(L[35],2643833823),new I(L[36],2343527390),new I(L[37],1014477480),new I(L[38],1206759142),new I(L[39],344077627),new I(L[40],1290863460),new I(L[41],3158454273),new I(L[42],3505952657),new I(L[43],106217008),new I(L[44],3606008344),new I(L[45],1432725776),new I(L[46],1467031594),new I(L[47],851169720),new I(L[48],3100823752),new I(L[49],1363258195),new I(L[50],3750685593),new I(L[51],3785050280),new I(L[52],3318307427),new I(L[53],3812723403),new I(L[54],2003034995),new I(L[55],3602036899),new I(L[56],1575990012),new I(L[57],1125592928),new I(L[58],2716904306),new I(L[59],442776044),new I(L[60],593698344),new I(L[61],3733110249),new I(L[62],2999351573),new I(L[63],3815920427),new I(3391569614,3928383900),new I(3515267271,566280711),new I(3940187606,3454069534),new I(4118630271,4000239992),new I(116418474,1914138554),new I(174292421,2731055270),new I(289380356,3203993006),new I(460393269,320620315),new I(685471733,587496836),new I(852142971,1086792851),new I(1017036298,365543100),new I(1126000580,2618297676),new I(1288033470,3409855158),new I(1501505948,4234509866),new I(1607167915,987167468),new I(1816402316,1246189591)],x=[new I(0,1),new I(0,32898),new I(2147483648,32906),new I(2147483648,2147516416),new I(0,32907),new I(0,2147483649),new I(2147483648,2147516545),new I(2147483648,32777),new I(0,138),new I(0,136),new I(0,2147516425),new I(0,2147483658),new I(0,2147516555),new I(2147483648,139),new I(2147483648,32905),new I(2147483648,32771),new I(2147483648,32770),new I(2147483648,128),new I(0,32778),new I(2147483648,2147483658),new I(2147483648,2147516545),new I(2147483648,32896),new I(0,2147483649),new I(2147483648,2147516424)],f=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]],(s=function(){return n}.call(r,i,r,e),!(s!==void 0&&(e.exports=s)))})(this)},function(e,t,a){'use strict';t.ApiError=a(1).ApiError,t.ResponseError=a(2).ResponseError,t.TimeoutError=a(3).TimeoutError},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a){super('PUT',`/users/${encodeURIComponent(e)}/merge/${encodeURIComponent(t)}`,3e4,!1),this.targetUserId=e,this.sourceUserId=t,a=a||{},this.cascadeCreate=a.cascadeCreate}bodyParameters(){let e={cascadeCreate:!(this.cascadeCreate!==void 0)||this.cascadeCreate};return e}}t.MergeUsers=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a){super('POST','/detailviews/',3e3,!1),this.userId=e,this.itemId=t,a=a||{},this.timestamp=a.timestamp,this.duration=a.duration,this.cascadeCreate=a.cascadeCreate,this.recommId=a.recommId,this.additionalData=a.additionalData}bodyParameters(){let e={};return e.userId=this.userId,e.itemId=this.itemId,void 0!==this.timestamp&&(e.timestamp=this.timestamp),void 0!==this.duration&&(e.duration=this.duration),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.recommId&&(e.recommId=this.recommId),void 0!==this.additionalData&&(e.additionalData=this.additionalData),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.AddDetailView=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a){super('POST','/purchases/',3e3,!1),this.userId=e,this.itemId=t,a=a||{},this.timestamp=a.timestamp,this.cascadeCreate=a.cascadeCreate,this.amount=a.amount,this.price=a.price,this.profit=a.profit,this.recommId=a.recommId,this.additionalData=a.additionalData}bodyParameters(){let e={};return e.userId=this.userId,e.itemId=this.itemId,void 0!==this.timestamp&&(e.timestamp=this.timestamp),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.amount&&(e.amount=this.amount),void 0!==this.price&&(e.price=this.price),void 0!==this.profit&&(e.profit=this.profit),void 0!==this.recommId&&(e.recommId=this.recommId),void 0!==this.additionalData&&(e.additionalData=this.additionalData),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.AddPurchase=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a,r){super('POST','/ratings/',3e3,!1),this.userId=e,this.itemId=t,this.rating=a,r=r||{},this.timestamp=r.timestamp,this.cascadeCreate=r.cascadeCreate,this.recommId=r.recommId,this.additionalData=r.additionalData}bodyParameters(){let e={};return e.userId=this.userId,e.itemId=this.itemId,e.rating=this.rating,void 0!==this.timestamp&&(e.timestamp=this.timestamp),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.recommId&&(e.recommId=this.recommId),void 0!==this.additionalData&&(e.additionalData=this.additionalData),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.AddRating=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a){super('POST','/cartadditions/',3e3,!1),this.userId=e,this.itemId=t,a=a||{},this.timestamp=a.timestamp,this.cascadeCreate=a.cascadeCreate,this.amount=a.amount,this.price=a.price,this.recommId=a.recommId,this.additionalData=a.additionalData}bodyParameters(){let e={};return e.userId=this.userId,e.itemId=this.itemId,void 0!==this.timestamp&&(e.timestamp=this.timestamp),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.amount&&(e.amount=this.amount),void 0!==this.price&&(e.price=this.price),void 0!==this.recommId&&(e.recommId=this.recommId),void 0!==this.additionalData&&(e.additionalData=this.additionalData),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.AddCartAddition=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a){super('POST','/bookmarks/',3e3,!1),this.userId=e,this.itemId=t,a=a||{},this.timestamp=a.timestamp,this.cascadeCreate=a.cascadeCreate,this.recommId=a.recommId,this.additionalData=a.additionalData}bodyParameters(){let e={};return e.userId=this.userId,e.itemId=this.itemId,void 0!==this.timestamp&&(e.timestamp=this.timestamp),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.recommId&&(e.recommId=this.recommId),void 0!==this.additionalData&&(e.additionalData=this.additionalData),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.AddBookmark=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a,r){super('POST','/viewportions/',3e3,!1),this.userId=e,this.itemId=t,this.portion=a,r=r||{},this.sessionId=r.sessionId,this.timestamp=r.timestamp,this.cascadeCreate=r.cascadeCreate,this.recommId=r.recommId,this.additionalData=r.additionalData}bodyParameters(){let e={};return e.userId=this.userId,e.itemId=this.itemId,e.portion=this.portion,void 0!==this.sessionId&&(e.sessionId=this.sessionId),void 0!==this.timestamp&&(e.timestamp=this.timestamp),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.recommId&&(e.recommId=this.recommId),void 0!==this.additionalData&&(e.additionalData=this.additionalData),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.SetViewPortion=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a){super('POST',`/recomms/users/${encodeURIComponent(e)}/items/`,9e3,!1),this.userId=e,this.count=t,a=a||{},this.scenario=a.scenario,this.cascadeCreate=a.cascadeCreate,this.returnProperties=a.returnProperties,this.includedProperties=a.includedProperties,this.filter=a.filter,this.booster=a.booster,this.logic=a.logic,this.diversity=a.diversity,this.minRelevance=a.minRelevance,this.rotationRate=a.rotationRate,this.rotationTime=a.rotationTime,this.expertSettings=a.expertSettings,this.returnAbGroup=a.returnAbGroup}bodyParameters(){let e={};return e.count=this.count,void 0!==this.scenario&&(e.scenario=this.scenario),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.returnProperties&&(e.returnProperties=this.returnProperties),void 0!==this.includedProperties&&(e.includedProperties=this.includedProperties),void 0!==this.filter&&(e.filter=this.filter),void 0!==this.booster&&(e.booster=this.booster),void 0!==this.logic&&(e.logic=this.logic),void 0!==this.diversity&&(e.diversity=this.diversity),void 0!==this.minRelevance&&(e.minRelevance=this.minRelevance),void 0!==this.rotationRate&&(e.rotationRate=this.rotationRate),void 0!==this.rotationTime&&(e.rotationTime=this.rotationTime),void 0!==this.expertSettings&&(e.expertSettings=this.expertSettings),void 0!==this.returnAbGroup&&(e.returnAbGroup=this.returnAbGroup),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.RecommendItemsToUser=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a,r){super('POST',`/recomms/items/${encodeURIComponent(e)}/items/`,9e3,!1),this.itemId=e,this.targetUserId=t,this.count=a,r=r||{},this.scenario=r.scenario,this.cascadeCreate=r.cascadeCreate,this.returnProperties=r.returnProperties,this.includedProperties=r.includedProperties,this.filter=r.filter,this.booster=r.booster,this.logic=r.logic,this.userImpact=r.userImpact,this.diversity=r.diversity,this.minRelevance=r.minRelevance,this.rotationRate=r.rotationRate,this.rotationTime=r.rotationTime,this.expertSettings=r.expertSettings,this.returnAbGroup=r.returnAbGroup}bodyParameters(){let e={};return e.targetUserId=this.targetUserId,e.count=this.count,void 0!==this.scenario&&(e.scenario=this.scenario),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.returnProperties&&(e.returnProperties=this.returnProperties),void 0!==this.includedProperties&&(e.includedProperties=this.includedProperties),void 0!==this.filter&&(e.filter=this.filter),void 0!==this.booster&&(e.booster=this.booster),void 0!==this.logic&&(e.logic=this.logic),void 0!==this.userImpact&&(e.userImpact=this.userImpact),void 0!==this.diversity&&(e.diversity=this.diversity),void 0!==this.minRelevance&&(e.minRelevance=this.minRelevance),void 0!==this.rotationRate&&(e.rotationRate=this.rotationRate),void 0!==this.rotationTime&&(e.rotationTime=this.rotationTime),void 0!==this.expertSettings&&(e.expertSettings=this.expertSettings),void 0!==this.returnAbGroup&&(e.returnAbGroup=this.returnAbGroup),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.RecommendItemsToItem=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t){super('POST',`/recomms/next/items/${encodeURIComponent(e)}`,9e3,!1),this.recommId=e,this.count=t}bodyParameters(){let e={count:this.count,cascadeCreate:!(this.cascadeCreate!==void 0)||this.cascadeCreate};return e}}t.RecommendNextItems=i},function(e,t,a){'use strict';const r=a(0);class i extends r.Request{constructor(e,t,a,r){super('POST',`/search/users/${encodeURIComponent(e)}/items/`,9e3,!1),this.userId=e,this.searchQuery=t,this.count=a,r=r||{},this.scenario=r.scenario,this.cascadeCreate=r.cascadeCreate,this.returnProperties=r.returnProperties,this.includedProperties=r.includedProperties,this.filter=r.filter,this.booster=r.booster,this.logic=r.logic,this.expertSettings=r.expertSettings,this.returnAbGroup=r.returnAbGroup}bodyParameters(){let e={};return e.searchQuery=this.searchQuery,e.count=this.count,void 0!==this.scenario&&(e.scenario=this.scenario),void 0!==this.cascadeCreate&&(e.cascadeCreate=this.cascadeCreate),void 0!==this.returnProperties&&(e.returnProperties=this.returnProperties),void 0!==this.includedProperties&&(e.includedProperties=this.includedProperties),void 0!==this.filter&&(e.filter=this.filter),void 0!==this.booster&&(e.booster=this.booster),void 0!==this.logic&&(e.logic=this.logic),void 0!==this.expertSettings&&(e.expertSettings=this.expertSettings),void 0!==this.returnAbGroup&&(e.returnAbGroup=this.returnAbGroup),e.cascadeCreate=void 0===this.cascadeCreate||this.cascadeCreate,e}}t.SearchItems=i}])}); | ||
//# sourceMappingURL=recombee-api-client.min.js.map |
{ | ||
"name": "recombee-js-api-client", | ||
"version": "3.1.0", | ||
"version": "4.0.0", | ||
"description": "Client-side js library for easy use of the Recombee recommendation API", | ||
@@ -5,0 +5,0 @@ "browser": "./src/index.js", |
@@ -18,3 +18,3 @@ # Recombee API Client | ||
```js | ||
<script src="https://cdn.jsdelivr.net/gh/recombee/js-api-client@3.1.0/dist/recombee-api-client.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/gh/recombee/js-api-client@4.0.0/dist/recombee-api-client.min.js"></script> | ||
``` | ||
@@ -48,3 +48,3 @@ | ||
// Initialize client with name of your database and PUBLIC token | ||
var client = new recombee.ApiClient('name-of-your-db', '...db-public-token...'); | ||
var client = new recombee.ApiClient('name-of-your-db', '...db-public-token...', {region: 'us-west'}); | ||
@@ -194,3 +194,3 @@ //Interactions take Id of user and Id of item | ||
<script src="https://cdn.jsdelivr.net/gh/recombee/js-api-client@3.1.0/dist/recombee-api-client.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/gh/recombee/js-api-client@4.0.0/dist/recombee-api-client.min.js"></script> | ||
@@ -217,3 +217,3 @@ <script type="text/javascript"> | ||
// Initialize client | ||
var client = new recombee.ApiClient('js-client-example', 'dXx2Jw4VkkYQP1XU4JwBAqGezs8BNzwhogGIRjDHJi39Yj3i0tWyIZ0IhKKw5Ln7'); | ||
var client = new recombee.ApiClient('js-client-example', 'dXx2Jw4VkkYQP1XU4JwBAqGezs8BNzwhogGIRjDHJi39Yj3i0tWyIZ0IhKKw5Ln7', {region: 'eu-west'}); | ||
@@ -220,0 +220,0 @@ var itemId = 'product-270'; |
@@ -21,3 +21,3 @@ 'use strict'; | ||
this.options = options || {}; | ||
this.baseUri = this.options.baseUri || 'client-rapi.recombee.com'; | ||
this.baseUri = this._getBaseUri() | ||
this.useHttps = ('useHttps' in this.options) ? this.options.useHttps : true; | ||
@@ -27,2 +27,29 @@ this.async = ('async' in this.options) ? this.options.async : true; | ||
_getRegionalBaseUri(region) { | ||
const uri = { | ||
'ap-se': 'client-rapi-ap-se.recombee.com', | ||
'ca-east': 'client-rapi-ca-east.recombee.com', | ||
'eu-west': 'client-rapi-eu-west.recombee.com', | ||
'us-west': 'client-rapi-us-west.recombee.com' | ||
}[region.toLowerCase()]; | ||
if (uri === undefined) { | ||
throw new Error(`Region "${region}" is unknown. You may need to update the version of the SDK.`) | ||
} | ||
return uri; | ||
} | ||
_getBaseUri() { | ||
let baseUri = this.options.baseUri; | ||
if (this.options.region) { | ||
if (baseUri) { | ||
throw new Error('baseUri and region cannot be specified at the same time'); | ||
} | ||
baseUri = this._getRegionalBaseUri(this.options.region); | ||
} | ||
return baseUri || 'client-rapi.recombee.com'; | ||
} | ||
/** | ||
@@ -29,0 +56,0 @@ * Send the request to Recombee |
@@ -113,3 +113,3 @@ /* | ||
* - Type: number | ||
* - Description: **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items. Default: `0.1`. | ||
* - Description: **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items. Default: `0`. | ||
* - *rotationTime* | ||
@@ -116,0 +116,0 @@ * - Type: number |
function createClient() { | ||
return new recombee.ApiClient('tst-public-key', 'dIuCAwTeXn87m24HYE6uAIwSVzgEkTrQflrYlDBeIoeTIrhG1FVqj1v0h6u3nNSu'); | ||
return new recombee.ApiClient('tst-public-key', 'dIuCAwTeXn87m24HYE6uAIwSVzgEkTrQflrYlDBeIoeTIrhG1FVqj1v0h6u3nNSu', {region: 'eu-west'}); | ||
} | ||
@@ -4,0 +4,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1937244
90
3671