@thirstie/thirstieservices 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,27 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 1.5.1 (2026-01-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * improved session reloading ([99e996c](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/99e996c48b2457fb254bb9a2b26500394b907cb5))
12
+ * update thirstieservices global name ([8974d09](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/8974d09703e05c68db0fde2db8a642967c94bd85))
13
+
14
+
15
+ ### Features
16
+
17
+ * add sandbox environment ([f0b55c5](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/f0b55c58304d9d28d704bee2b9c16a64ab6af5fe))
18
+ * allow restoring age gate settings ([2030773](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/2030773073df53b56a08a3dd5937afac63c87217))
19
+ * simplify saving session state ([fa0ba48](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/fa0ba48d29140961e7c035605a0bee82ac7f0b17))
20
+ * TH-5423 create new session in extreme case ([3de8b13](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/3de8b131deee45281c414ae00bd2cc44f2c475f7))
21
+ * update user actions ([2f8cf07](https://github.com/ThirstieAdmin/thirstiejs-monorepo/commit/2f8cf07f9bafbca4fd5d57435a37189541449ded))
22
+
23
+
24
+
25
+
26
+
6
27
  # 1.5.0 (2026-01-06)
7
28
 
8
29
 
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <coverage generated="1767721709570" clover="3.2.0">
3
- <project timestamp="1767721709570" name="All files">
2
+ <coverage generated="1768334503387" clover="3.2.0">
3
+ <project timestamp="1768334503387" name="All files">
4
4
  <metrics statements="123" coveredstatements="56" conditionals="91" coveredconditionals="58" methods="26" coveredmethods="13" elements="240" coveredelements="127" complexity="0" loc="123" ncloc="123" packages="2" files="3" classes="3"/>
5
5
  <package name="geoservice">
6
6
  <metrics statements="94" coveredstatements="40" conditionals="77" coveredconditionals="53" methods="21" coveredmethods="11"/>
@@ -9,7 +9,7 @@ var jumpToCode = (function init() {
9
9
  // We don't want to select elements that are direct descendants of another match
10
10
  var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
11
11
 
12
- // Selecter that finds elements on the page to which we can jump
12
+ // Selector that finds elements on the page to which we can jump
13
13
  var selector =
14
14
  fileListingElements.join(', ') +
15
15
  ', ' +
@@ -101,7 +101,7 @@
101
101
  <div class='footer quiet pad2 space-top1 center small'>
102
102
  Code coverage generated by
103
103
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
104
- at 2026-01-06T17:48:29.558Z
104
+ at 2026-01-13T20:01:43.375Z
105
105
  </div>
106
106
  <script src="../prettify.js"></script>
107
107
  <script>
@@ -766,7 +766,7 @@ export default GeoService;
766
766
  <div class='footer quiet pad2 space-top1 center small'>
767
767
  Code coverage generated by
768
768
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
769
- at 2026-01-06T17:48:29.558Z
769
+ at 2026-01-13T20:01:43.375Z
770
770
  </div>
771
771
  <script src="../prettify.js"></script>
772
772
  <script>
@@ -116,7 +116,7 @@
116
116
  <div class='footer quiet pad2 space-top1 center small'>
117
117
  Code coverage generated by
118
118
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
119
- at 2026-01-06T17:48:29.558Z
119
+ at 2026-01-13T20:01:43.375Z
120
120
  </div>
121
121
  <script src="prettify.js"></script>
122
122
  <script>
@@ -27,17 +27,31 @@ var addSorting = (function() {
27
27
  function onFilterInput() {
28
28
  const searchValue = document.getElementById('fileSearch').value;
29
29
  const rows = document.getElementsByTagName('tbody')[0].children;
30
+
31
+ // Try to create a RegExp from the searchValue. If it fails (invalid regex),
32
+ // it will be treated as a plain text search
33
+ let searchRegex;
34
+ try {
35
+ searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive
36
+ } catch (error) {
37
+ searchRegex = null;
38
+ }
39
+
30
40
  for (let i = 0; i < rows.length; i++) {
31
41
  const row = rows[i];
32
- if (
33
- row.textContent
34
- .toLowerCase()
35
- .includes(searchValue.toLowerCase())
36
- ) {
37
- row.style.display = '';
42
+ let isMatch = false;
43
+
44
+ if (searchRegex) {
45
+ // If a valid regex was created, use it for matching
46
+ isMatch = searchRegex.test(row.textContent);
38
47
  } else {
39
- row.style.display = 'none';
48
+ // Otherwise, fall back to the original plain text search
49
+ isMatch = row.textContent
50
+ .toLowerCase()
51
+ .includes(searchValue.toLowerCase());
40
52
  }
53
+
54
+ row.style.display = isMatch ? '' : 'none';
41
55
  }
42
56
  }
43
57
 
@@ -208,7 +208,7 @@ export async function <span class="fstat-no" title="function not covered" >apiRe
208
208
  <div class='footer quiet pad2 space-top1 center small'>
209
209
  Code coverage generated by
210
210
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
211
- at 2026-01-06T17:48:29.558Z
211
+ at 2026-01-13T20:01:43.375Z
212
212
  </div>
213
213
  <script src="../../prettify.js"></script>
214
214
  <script>
@@ -160,7 +160,7 @@ export {
160
160
  <div class='footer quiet pad2 space-top1 center small'>
161
161
  Code coverage generated by
162
162
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
163
- at 2026-01-06T17:48:29.558Z
163
+ at 2026-01-13T20:01:43.375Z
164
164
  </div>
165
165
  <script src="../../prettify.js"></script>
166
166
  <script>
@@ -116,7 +116,7 @@
116
116
  <div class='footer quiet pad2 space-top1 center small'>
117
117
  Code coverage generated by
118
118
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
119
- at 2026-01-06T17:48:29.558Z
119
+ at 2026-01-13T20:01:43.375Z
120
120
  </div>
121
121
  <script src="../../prettify.js"></script>
122
122
  <script>
package/dist/bundle.cjs CHANGED
@@ -806,7 +806,7 @@ function _has(prop, obj) {
806
806
  }
807
807
 
808
808
  // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
809
- function _objectIs(a, b) {
809
+ function _objectIs$1(a, b) {
810
810
  // SameValue algorithm
811
811
  if (a === b) {
812
812
  // Steps 1-5, 7-10
@@ -818,7 +818,7 @@ function _objectIs(a, b) {
818
818
  }
819
819
  }
820
820
 
821
- var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs;
821
+ var _objectIs = typeof Object.is === 'function' ? Object.is : _objectIs$1;
822
822
 
823
823
  var toString$1 = Object.prototype.toString;
824
824
 
@@ -978,7 +978,7 @@ function _uniqContentEquals(aIterator, bIterator, stackA, stackB) {
978
978
  }
979
979
 
980
980
  function _equals(a, b, stackA, stackB) {
981
- if (_objectIs$1(a, b)) {
981
+ if (_objectIs(a, b)) {
982
982
  return true;
983
983
  }
984
984
 
@@ -1009,14 +1009,14 @@ function _equals(a, b, stackA, stackB) {
1009
1009
  case 'Boolean':
1010
1010
  case 'Number':
1011
1011
  case 'String':
1012
- if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) {
1012
+ if (!(typeof a === typeof b && _objectIs(a.valueOf(), b.valueOf()))) {
1013
1013
  return false;
1014
1014
  }
1015
1015
 
1016
1016
  break;
1017
1017
 
1018
1018
  case 'Date':
1019
- if (!_objectIs$1(a.valueOf(), b.valueOf())) {
1019
+ if (!_objectIs(a.valueOf(), b.valueOf())) {
1020
1020
  return false;
1021
1021
  }
1022
1022
 
@@ -1 +1 @@
1
- var thirstieservices=function(t){"use strict";const e=t=>{let e="https://api.next.thirstie.com";switch(t?.toLowerCase()){case"prod":e="https://api.thirstie.com";break;case"sandbox":e="https://api.sandbox.thirstie.com"}return e};function n(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function r(t){return function e(r){return 0===arguments.length||n(r)?e:t.apply(this,arguments)}}function o(t){return function e(o,a){switch(arguments.length){case 0:return e;case 1:return n(o)?e:r((function(e){return t(o,e)}));default:return n(o)&&n(a)?e:n(o)?r((function(e){return t(e,a)})):n(a)?r((function(e){return t(o,e)})):t(o,a)}}}function a(t,e){switch(t){case 0:return function(){return e.apply(this,arguments)};case 1:return function(t){return e.apply(this,arguments)};case 2:return function(t,n){return e.apply(this,arguments)};case 3:return function(t,n,r){return e.apply(this,arguments)};case 4:return function(t,n,r,o){return e.apply(this,arguments)};case 5:return function(t,n,r,o,a){return e.apply(this,arguments)};case 6:return function(t,n,r,o,a,s){return e.apply(this,arguments)};case 7:return function(t,n,r,o,a,s,i){return e.apply(this,arguments)};case 8:return function(t,n,r,o,a,s,i,u){return e.apply(this,arguments)};case 9:return function(t,n,r,o,a,s,i,u,c){return e.apply(this,arguments)};case 10:return function(t,n,r,o,a,s,i,u,c,l){return e.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function s(t,e,r){return function(){for(var o=[],i=0,u=t,c=0,l=!1;c<e.length||i<arguments.length;){var p;c<e.length&&(!n(e[c])||i>=arguments.length)?p=e[c]:(p=arguments[i],i+=1),o[c]=p,n(p)?l=!0:u-=1,c+=1}return!l&&u<=0?r.apply(this,o):a(Math.max(0,u),s(t,o,r))}}var i=o((function(t,e){return 1===t?r(e):a(t,s(t,[],e))}));function u(t){return function e(a,s,i){switch(arguments.length){case 0:return e;case 1:return n(a)?e:o((function(e,n){return t(a,e,n)}));case 2:return n(a)&&n(s)?e:n(a)?o((function(e,n){return t(e,s,n)})):n(s)?o((function(e,n){return t(a,e,n)})):r((function(e){return t(a,s,e)}));default:return n(a)&&n(s)&&n(i)?e:n(a)&&n(s)?o((function(e,n){return t(e,n,i)})):n(a)&&n(i)?o((function(e,n){return t(e,s,n)})):n(s)&&n(i)?o((function(e,n){return t(a,e,n)})):n(a)?r((function(e){return t(e,s,i)})):n(s)?r((function(e){return t(a,e,i)})):n(i)?r((function(e){return t(a,s,e)})):t(a,s,i)}}}var c=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)};function l(t,e,n){return function(){if(0===arguments.length)return n();var r=arguments[arguments.length-1];if(!c(r)){for(var o=0;o<t.length;){if("function"==typeof r[t[o]])return r[t[o]].apply(r,Array.prototype.slice.call(arguments,0,-1));o+=1}if(function(t){return null!=t&&"function"==typeof t["@@transducer/step"]}(r))return e.apply(null,Array.prototype.slice.call(arguments,0,-1))(r)}return n.apply(this,arguments)}}var p=function(){return this.xf["@@transducer/init"]()},f=function(t){return this.xf["@@transducer/result"](t)};function h(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}function y(t,e,n){for(var r=0,o=n.length;r<o;){if(t(e,n[r]))return!0;r+=1}return!1}function d(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var g="function"==typeof Object.is?Object.is:function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e},m=Object.prototype.toString,v=function(){return"[object Arguments]"===m.call(arguments)?function(t){return"[object Arguments]"===m.call(t)}:function(t){return d("callee",t)}}(),b=!{toString:null}.propertyIsEnumerable("toString"),S=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],j=function(){return arguments.propertyIsEnumerable("length")}(),w=function(t,e){for(var n=0;n<t.length;){if(t[n]===e)return!0;n+=1}return!1},A="function"!=typeof Object.keys||j?r((function(t){if(Object(t)!==t)return[];var e,n,r=[],o=j&&v(t);for(e in t)!d(e,t)||o&&"length"===e||(r[r.length]=e);if(b)for(n=S.length-1;n>=0;)d(e=S[n],t)&&!w(r,e)&&(r[r.length]=e),n-=1;return r})):r((function(t){return Object(t)!==t?[]:Object.keys(t)})),k=r((function(t){return null===t?"Null":void 0===t?"Undefined":Object.prototype.toString.call(t).slice(8,-1)}));function _(t,e,n,r){var o=h(t);function a(t,e){return O(t,e,n.slice(),r.slice())}return!y((function(t,e){return!y(a,e,t)}),h(e),o)}function O(t,e,n,r){if(g(t,e))return!0;var o,a,s=k(t);if(s!==k(e))return!1;if("function"==typeof t["fantasy-land/equals"]||"function"==typeof e["fantasy-land/equals"])return"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e)&&"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t);if("function"==typeof t.equals||"function"==typeof e.equals)return"function"==typeof t.equals&&t.equals(e)&&"function"==typeof e.equals&&e.equals(t);switch(s){case"Arguments":case"Array":case"Object":if("function"==typeof t.constructor&&"Promise"===(o=t.constructor,null==(a=String(o).match(/^function (\w*)/))?"":a[1]))return t===e;break;case"Boolean":case"Number":case"String":if(typeof t!=typeof e||!g(t.valueOf(),e.valueOf()))return!1;break;case"Date":if(!g(t.valueOf(),e.valueOf()))return!1;break;case"Error":return t.name===e.name&&t.message===e.message;case"RegExp":if(t.source!==e.source||t.global!==e.global||t.ignoreCase!==e.ignoreCase||t.multiline!==e.multiline||t.sticky!==e.sticky||t.unicode!==e.unicode)return!1}for(var i=n.length-1;i>=0;){if(n[i]===t)return r[i]===e;i-=1}switch(s){case"Map":return t.size===e.size&&_(t.entries(),e.entries(),n.concat([t]),r.concat([e]));case"Set":return t.size===e.size&&_(t.values(),e.values(),n.concat([t]),r.concat([e]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var u=A(t);if(u.length!==A(e).length)return!1;var c=n.concat([t]),l=r.concat([e]);for(i=u.length-1;i>=0;){var p=u[i];if(!d(p,e)||!O(e[p],t[p],c,l))return!1;i-=1}return!0}var T=o((function(t,e){return O(t,e,[],[])}));function x(t,e){return function(t,e,n){var r,o;if("function"==typeof t.indexOf)switch(typeof e){case"number":if(0===e){for(r=1/e;n<t.length;){if(0===(o=t[n])&&1/o===r)return n;n+=1}return-1}if(e!=e){for(;n<t.length;){if("number"==typeof(o=t[n])&&o!=o)return n;n+=1}return-1}return t.indexOf(e,n);case"string":case"boolean":case"function":case"undefined":return t.indexOf(e,n);case"object":if(null===e)return t.indexOf(e,n)}for(;n<t.length;){if(T(t[n],e))return n;n+=1}return-1}(e,t,0)>=0}function R(t,e){for(var n=0,r=e.length,o=Array(r);n<r;)o[n]=t(e[n]),n+=1;return o}function U(t){return'"'+t.replace(/\\/g,"\\\\").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/\0/g,"\\0").replace(/"/g,'\\"')+'"'}var C=function(t){return(t<10?"0":"")+t},q="function"==typeof Date.prototype.toISOString?function(t){return t.toISOString()}:function(t){return t.getUTCFullYear()+"-"+C(t.getUTCMonth()+1)+"-"+C(t.getUTCDate())+"T"+C(t.getUTCHours())+":"+C(t.getUTCMinutes())+":"+C(t.getUTCSeconds())+"."+(t.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"};function N(t,e,n){for(var r=0,o=n.length;r<o;)e=t(e,n[r]),r+=1;return e}function E(t){return"[object Object]"===Object.prototype.toString.call(t)}var I=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=p,t.prototype["@@transducer/result"]=f,t.prototype["@@transducer/step"]=function(t,e){return this.f(e)?this.xf["@@transducer/step"](t,e):t},t}();function P(t){return function(e){return new I(t,e)}}var $=o(l(["fantasy-land/filter","filter"],P,(function(t,e){return E(e)?N((function(n,r){return t(e[r])&&(n[r]=e[r]),n}),{},A(e)):function(t,e){for(var n=0,r=e.length,o=[];n<r;)t(e[n])&&(o[o.length]=e[n]),n+=1;return o}(t,e)}))),B=o((function(t,e){return $((n=t,function(){return!n.apply(this,arguments)}),e);var n}));function F(t,e){var n=function(n){var r=e.concat([t]);return x(n,r)?"<Circular>":F(n,r)},r=function(t,e){return R((function(e){return U(e)+": "+n(t[e])}),e.slice().sort())};switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+R(n,t).join(", ")+"))";case"[object Array]":return"["+R(n,t).concat(r(t,B((function(t){return/^\d+$/.test(t)}),A(t)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof t?"new Boolean("+n(t.valueOf())+")":t.toString();case"[object Date]":return"new Date("+(isNaN(t.valueOf())?n(NaN):U(q(t)))+")";case"[object Map]":return"new Map("+n(Array.from(t))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof t?"new Number("+n(t.valueOf())+")":1/t==-1/0?"-0":t.toString(10);case"[object Set]":return"new Set("+n(Array.from(t).sort())+")";case"[object String]":return"object"==typeof t?"new String("+n(t.valueOf())+")":U(t);case"[object Undefined]":return"undefined";default:if("function"==typeof t.toString){var o=t.toString();if("[object Object]"!==o)return o}return"{"+r(t,A(t)).join(", ")+"}"}}var K=r((function(t){return F(t,[])})),M=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=p,t.prototype["@@transducer/result"]=f,t.prototype["@@transducer/step"]=function(t,e){return this.xf["@@transducer/step"](t,this.f(e))},t}(),z=o(l(["fantasy-land/map","map"],(function(t){return function(e){return new M(t,e)}}),(function(t,e){switch(Object.prototype.toString.call(e)){case"[object Function]":return i(e.length,(function(){return t.call(this,e.apply(this,arguments))}));case"[object Object]":return N((function(n,r){return n[r]=t(e[r]),n}),{},A(e));default:return R(t,e)}}))),D=Number.isInteger||function(t){return(t|0)===t};function G(t){return"[object String]"===Object.prototype.toString.call(t)}var L=o((function(t,e){var n=t<0?e.length+t:t;return G(e)?e.charAt(n):e[n]})),Z=o((function(t,e){if(null!=e)return D(t)?L(t,e):e[t]})),H=r((function(t){return!!c(t)||!!t&&("object"==typeof t&&(!G(t)&&(0===t.length||t.length>0&&(t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1)))))})),J="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function V(t,e,n){return function(r,o,a){if(H(a))return t(r,o,a);if(null==a)return o;if("function"==typeof a["fantasy-land/reduce"])return e(r,o,a,"fantasy-land/reduce");if(null!=a[J])return n(r,o,a[J]());if("function"==typeof a.next)return n(r,o,a);if("function"==typeof a.reduce)return e(r,o,a,"reduce");throw new TypeError("reduce: list must be array or iterable")}}function W(t,e,n){for(var r=0,o=n.length;r<o;){if((e=t["@@transducer/step"](e,n[r]))&&e["@@transducer/reduced"]){e=e["@@transducer/value"];break}r+=1}return t["@@transducer/result"](e)}var X=o((function(t,e){return a(t.length,(function(){return t.apply(e,arguments)}))}));function Y(t,e,n){for(var r=n.next();!r.done;){if((e=t["@@transducer/step"](e,r.value))&&e["@@transducer/reduced"]){e=e["@@transducer/value"];break}r=n.next()}return t["@@transducer/result"](e)}function Q(t,e,n,r){return t["@@transducer/result"](n[r](X(t["@@transducer/step"],t),e))}var tt=V(W,Q,Y),et=function(){function t(t){this.f=t}return t.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},t.prototype["@@transducer/result"]=function(t){return t},t.prototype["@@transducer/step"]=function(t,e){return this.f(t,e)},t}();var nt=u((function(t,e,n){return tt("function"==typeof t?new et(t):t,e,n)}));var rt=r((function(t){return null==t})),ot=u((function t(e,n,r){if(0===e.length)return n;var o=e[0];if(e.length>1){var a=!rt(r)&&d(o,r)&&"object"==typeof r[o]?r[o]:D(e[1])?[]:{};n=t(Array.prototype.slice.call(e,1),n,a)}return function(t,e,n){if(D(t)&&c(n)){var r=[].concat(n);return r[t]=e,r}var o={};for(var a in n)o[a]=n[a];return o[t]=e,o}(o,n,r)}));function at(t,e){return function(){return e.call(this,t.apply(this,arguments))}}function st(t,e){return function(){var n=arguments.length;if(0===n)return e();var r=arguments[n-1];return c(r)||"function"!=typeof r[t]?e.apply(this,arguments):r[t].apply(r,Array.prototype.slice.call(arguments,0,n-1))}}var it=r(st("tail",u(st("slice",(function(t,e,n){return Array.prototype.slice.call(n,t,e)})))(1,1/0)));function ut(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return a(arguments[0].length,nt(at,arguments[0],it(arguments)))}var ct=r((function(t){return G(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()}));function lt(){if(0===arguments.length)throw new Error("compose requires at least one argument");return ut.apply(this,ct(arguments))}var pt=r((function(t){return i(t.length,t)}));var ft=r((function(t){return null!=t&&"function"==typeof t["fantasy-land/empty"]?t["fantasy-land/empty"]():null!=t&&null!=t.constructor&&"function"==typeof t.constructor["fantasy-land/empty"]?t.constructor["fantasy-land/empty"]():null!=t&&"function"==typeof t.empty?t.empty():null!=t&&null!=t.constructor&&"function"==typeof t.constructor.empty?t.constructor.empty():c(t)?[]:G(t)?"":E(t)?{}:v(t)?function(){return arguments}():function(t){var e=Object.prototype.toString.call(t);return"[object Uint8ClampedArray]"===e||"[object Int8Array]"===e||"[object Uint8Array]"===e||"[object Int16Array]"===e||"[object Uint16Array]"===e||"[object Int32Array]"===e||"[object Uint32Array]"===e||"[object Float32Array]"===e||"[object Float64Array]"===e||"[object BigInt64Array]"===e||"[object BigUint64Array]"===e}(t)?t.constructor.from(""):void 0})),ht=function(){function t(t,e){this.xf=e,this.f=t,this.found=!1}return t.prototype["@@transducer/init"]=p,t.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,void 0)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){var n;return this.f(e)&&(this.found=!0,t=(n=this.xf["@@transducer/step"](t,e))&&n["@@transducer/reduced"]?n:{"@@transducer/value":n,"@@transducer/reduced":!0}),t},t}();function yt(t){return function(e){return new ht(t,e)}}var dt=o(l(["find"],yt,(function(t,e){for(var n=0,r=e.length;n<r;){if(t(e[n]))return e[n];n+=1}}))),gt=o(x),mt=o((function(t,e){return i(t+1,(function(){var n=arguments[t];if(null!=n&&function(t){var e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e||"[object GeneratorFunction]"===e||"[object AsyncGeneratorFunction]"===e}(n[e]))return n[e].apply(n,Array.prototype.slice.call(arguments,0,t));throw new TypeError(K(n)+' does not have a method named "'+e+'"')}))})),vt=r((function(t){return null!=t&&T(t,ft(t))})),bt=mt(1,"join"),St=o((function(t,e){return function(n){return function(r){return z((function(t){return e(t,r)}),n(t(r)))}}})),jt=o((function(t,e){return t.map((function(t){for(var n,r=e,o=0;o<t.length;){if(null==r)return;n=t[o],r=D(n)?L(n,r):r[n],o+=1}return r}))})),wt=o((function(t,e){return jt([t],e)[0]})),At=r((function(t){return St(wt(t),ot(t))})),kt=function(t){return{value:t,"fantasy-land/map":function(){return this}}},_t=o((function(t,e){return t(kt)(e).value}));const Ot=pt(((t,e,n,r)=>lt(Z(r),dt((t=>gt(n,t[e]))))(t))),Tt=At(["results","0","address_components"]),xt=t=>{const e=t.results?t.results[0]:t.result;if(!e||vt(e))return{};let n=null;n=t.results?_t(Tt)(t):e.address_components;const r=Ot(n,"types"),o=e.formatted_address,a=e.geometry&&e.geometry.location&&e.geometry.location.lat?e.geometry.location.lat:null,s=e.geometry&&e.geometry.location&&e.geometry.location.lng?e.geometry.location.lng:null,i=r("street_number","short_name")||"",u=r("route","long_name")||"",c=(i||u)&&`${i} ${u}`,l={state:r("administrative_area_level_1","short_name"),city:r("locality","short_name")||r("sublocality","short_name")||r("neighborhood","long_name")||r("administrative_area_level_3","long_name")||r("administrative_area_level_2","short_name"),street_1:c.trim(),country:r("country","short_name"),zipcode:r("postal_code","long_name"),latitude:a&&Number(a),longitude:s&&Number(s),formattedAddress:o};return $(Boolean)(l)};return t.GeoService=class{constructor(t){this.mapsKey=t}async geocode(t){const e=await fetch(`https://maps.googleapis.com/maps/api/geocode/json?address=${t}&key=${this.mapsKey}`),n=await e.json();return xt(n)}async geocodeZip(t){const e=await fetch(`https://maps.googleapis.com/maps/api/geocode/json?components=country:US|postal_code:${t}&key=${this.mapsKey}`),n=await e.json();return xt(n)}async reverseGeocode(t,e){const n=await fetch(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${t},${e}&key=${this.mapsKey}`),r=await n.json();return xt(r)}async geoLocate(){const t=`https://www.googleapis.com/geolocation/v1/geolocate?key=${this.mapsKey}`,e=await fetch(t,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"}}),n=await e.json(),{lat:r,lng:o}=n.location;return this.reverseGeocode(r,o)}async getLocationSuggestions(t){const{input:e,latitude:n,longitude:r,radius:o}=t,{requestCity:a,requestState:s,requestZipcode:i}=t,u=bt(",",$(Boolean,[n,r]));let{sessiontoken:c}=t;c||(c=crypto.randomUUID().replaceAll("-",""));const l=$(Boolean,{input:e,sessiontoken:c,location:u,radius:o,components:"country:US",types:"address",key:this.mapsKey});let p="";if(l){p=new URLSearchParams(l).toString()}const f=`https://maps.googleapis.com/maps/api/place/autocomplete/json?${p}`,h=await fetch(f,{method:"GET",headers:{Accept:"application/json"}}),y=await h.json();let d=[];if(y.predictions&&"OK"===y.status){const t={requestCity:a,requestState:s,requestZipcode:i};d=((t,e={})=>{const{requestCity:n,requestState:r,requestZipcode:o}=e,a=t=>({description:t.description,placeId:t.place_id});let s=null;return n||r||o||(s=t.map(a)),s=t.map((t=>{const e={description:t.description,place_id:t.place_id},a=t.terms.filter((t=>n&&t.value===n)).length>0?1:0,s=t.terms.filter((t=>r&&t.value===r)).length>0?1:0,i=t.terms.filter((t=>o&&t.value===o)).length>0?1:0;return e.score=a+s+i,e.stateMatch=!r||r&&s,e.zipCodeMatch=!o||o&&i,e})).filter((t=>!!t.stateMatch&&!!t.zipCodeMatch)).sort(((t,e)=>t.score===e.score?0:t.score<e.score?1:-1)).map(a),s})(y.predictions,t)}return{autocompletePredictions:d,sessiontoken:c}}async getPlaceId(t){const{placeId:e,sessiontoken:n}=t,r=$(Boolean,{place_id:e,sessiontoken:n,key:this.mapsKey});let o="";if(r){o=new URLSearchParams(r).toString()}const a=`https://maps.googleapis.com/maps/api/place/details/json?${o}`,s=await fetch(a),i=await s.json();return xt(i)}async getNavigatorPosition(){const t=t=>{console.error(t)};navigator.geolocation&&navigator.geolocation.getCurrentPosition((t=>{const e=t.coords.latitude,n=t.coords.longitude;return this.reverseGeocode(e,n)}),t)||t({message:"geolocation is not enabled."})}},t.ThirstieAPI=class{#t;#e;#n;#r;#o;constructor(t,n={}){const{env:r,initState:o}=n;this.#o=r,this.#r={sessionToken:null,application:null,applicationRef:null,sessionRef:null,userRef:null,user:{},message:null},this.#t=t,this.#e=e(r),this.#n=Object.seal(this.#r);const{sessionToken:a,application:s,applicationRef:i,sessionRef:u}=o||{};if(a&&s&&i&&u){const t={sessionToken:a,application:s,applicationRef:i,sessionRef:u};this.apiState=t}}get sessionToken(){return this.#n.sessionToken}get sessionRef(){return this.#n.sessionRef}get userRef(){return this.#n.userRef}get applicationRef(){return this.#n.applicationRef}get application(){return this.#n.application}get sessionState(){const{sessionToken:t,application:e,applicationRef:n,sessionRef:r,userRef:o}=this.#n;return{sessionToken:t,application:e,applicationRef:n,sessionRef:r,userRef:o}}get apiState(){return this.#n}set apiState(t){try{return Object.assign(this.#n,t)}catch(t){return console.error("set apiState",t),this.#n}}#a(t){const e={application:t.application_name,applicationRef:t.uuid,sessionToken:t.token,sessionRef:t.session_uuid};if(e.userRef=t.user?.id,t.user){const{birthday:n,email:r,prefix:o,guest:a,first_name:s,last_name:i,phone_number:u,last_login:c}=t.user;e.user={email:r,birthday:n,prefix:o,firstName:s,lastName:i,phoneNumber:u,guest:a,lastLogin:c}}this.apiState=e}#s(t){this.apiState=this.#r,console.error("session error",t)}async getNewSession(t={},e=!0){const{email:n,password:r}=t,o={basicAuth:e};n&&r&&(o.data={email:n,password:r});const a=await this.apiCaller("POST","/a/v2/sessions",o);return a&&a.ok&&a.data?a.data:{code:a.status,message:a.message||"unknown error",response:a}}async validateSession(t){if(t&&(this.apiState={sessionToken:t}),!this.sessionToken)return{};const e=await this.apiCaller("GET","/a/v2/sessions");return e&&e.ok&&e.data?e.data:await this.getNewSession()}async fetchSession(t=null,e=!1){let n={};return n=!this.sessionToken&&!t||e?await this.getNewSession():await this.validateSession(t),n.token?this.#a(n):this.#s(n),this.apiState}async loginUser(t){const{email:e,password:n}=t,r=!this.sessionToken;if(!e||!n)throw new Error("Invalid credential payload");const o=await this.getNewSession(t,r);if(o.token)this.#a(o);else{this.#s(o);const{response:t}=o,{data:e}=t;e?.message&&(this.apiState.message=e?.message)}return this.apiState}async createUser(t,e=null){const n={},{email:r,password:o}=t,{birthday:a,prefix:s,firstName:i,lastName:u,phoneNumber:c,guestCheck:l,emailOptIn:p}=t,f={email:r,birthday:a,prefix:s,first_name:i,last_name:u,phone_number:c,guest_check:!!l};p&&(f.aux_data={thirstieaccess_email_opt_in:p});const h=!this.sessionToken;r&&o?f.password=o:f.guest=!0,n.data=f,n.basicAuth=h;const y=await this.apiCaller("POST","/a/v2/users",n,e);return y.data.token?this.#a(y.data):this.#s(y),this.apiState}async apiCaller(t,n,r={},o=null){const{data:a,params:s,basicAuth:i,isFormData:u,isTemplate:c,isPayment:l,isCSV:p}=r,{sessionRef:f,application:h,applicationRef:y,userRef:d}=this.apiState;if(!this.sessionToken&&!i)throw new Error("Invalid Authorization");const g={Authorization:this.sessionToken&&!i?`Bearer ${this.sessionToken}`:`Basic ${btoa(this.#t)}`,Accept:"application/json"};u||(g["Content-Type"]="application/json"),p&&(g.Accept="text/csv",delete g["Content-Type"]);const m={method:t,headers:g};["POST","PUT","PATCH"].includes(t)&&a&&(m.body=u?a:JSON.stringify(a));const v=e(this.#o);let b=v;l&&(b="https://api.thirstie.com"===v?"https://merchant-payments.thirstie.cloud":"https://merchant-payments.next.thirstie.cloud"),c&&(b=(t=>"https://api.thirstie.com"===t?"https://templates.thirstie.cloud":"https://staging.templates.thirstie.cloud")(v));const{requestUrl:S,queryString:j}=function(t,e,n=null){let r="";n&&(r="?"+new URLSearchParams(n).toString());return{requestUrl:`${t}${e}${r}`,queryString:r}}(b,n,s),w={environment:this.#o,sessionRef:f,application:h,applicationRef:y,userRef:d,data:a,queryString:j,url:n,baseUrl:b};try{const t=await async function(t,e){const n={ok:null,status:null,statusText:null,data:{}};try{const r=await fetch(t,e);let o={};const a=r.headers;return a&&a.get("content-type")?.indexOf("application/json")>-1&&parseInt(a.get("content-length"))>0&&(o=await r.json()),Object.assign(n,{ok:r.ok,status:r.status,statusText:r.statusText,data:o,url:t})}catch(e){return console.error("apiRequest error: ",e),Object.assign(n,{ok:!1,status:500,statusText:"ERROR",data:{message:"Network error",error:e},url:t})}}(S,m);if(t)return!t.ok&&o&&o({code:t.status,message:t.statusText||"unknown error",response:t,telemetryContext:w}),p?{ok:t.ok,status:t.status,statusText:t.statusText,url:t.url,data:await t.text()}:t}catch(t){return o&&o({code:500,message:"unknown error",error:t,telemetryContext:w}),t}}},t}({});
1
+ var thirstieservices=function(t){"use strict";const e=t=>{let e="https://api.next.thirstie.com";switch(t?.toLowerCase()){case"prod":e="https://api.thirstie.com";break;case"sandbox":e="https://api.sandbox.thirstie.com"}return e};function n(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function r(t){return function e(r){return 0===arguments.length||n(r)?e:t.apply(this,arguments)}}function o(t){return function e(o,a){switch(arguments.length){case 0:return e;case 1:return n(o)?e:r(function(e){return t(o,e)});default:return n(o)&&n(a)?e:n(o)?r(function(e){return t(e,a)}):n(a)?r(function(e){return t(o,e)}):t(o,a)}}}function a(t,e){switch(t){case 0:return function(){return e.apply(this,arguments)};case 1:return function(t){return e.apply(this,arguments)};case 2:return function(t,n){return e.apply(this,arguments)};case 3:return function(t,n,r){return e.apply(this,arguments)};case 4:return function(t,n,r,o){return e.apply(this,arguments)};case 5:return function(t,n,r,o,a){return e.apply(this,arguments)};case 6:return function(t,n,r,o,a,s){return e.apply(this,arguments)};case 7:return function(t,n,r,o,a,s,i){return e.apply(this,arguments)};case 8:return function(t,n,r,o,a,s,i,u){return e.apply(this,arguments)};case 9:return function(t,n,r,o,a,s,i,u,c){return e.apply(this,arguments)};case 10:return function(t,n,r,o,a,s,i,u,c,l){return e.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function s(t,e,r){return function(){for(var o=[],i=0,u=t,c=0,l=!1;c<e.length||i<arguments.length;){var p;c<e.length&&(!n(e[c])||i>=arguments.length)?p=e[c]:(p=arguments[i],i+=1),o[c]=p,n(p)?l=!0:u-=1,c+=1}return!l&&u<=0?r.apply(this,o):a(Math.max(0,u),s(t,o,r))}}var i=o(function(t,e){return 1===t?r(e):a(t,s(t,[],e))});function u(t){return function e(a,s,i){switch(arguments.length){case 0:return e;case 1:return n(a)?e:o(function(e,n){return t(a,e,n)});case 2:return n(a)&&n(s)?e:n(a)?o(function(e,n){return t(e,s,n)}):n(s)?o(function(e,n){return t(a,e,n)}):r(function(e){return t(a,s,e)});default:return n(a)&&n(s)&&n(i)?e:n(a)&&n(s)?o(function(e,n){return t(e,n,i)}):n(a)&&n(i)?o(function(e,n){return t(e,s,n)}):n(s)&&n(i)?o(function(e,n){return t(a,e,n)}):n(a)?r(function(e){return t(e,s,i)}):n(s)?r(function(e){return t(a,e,i)}):n(i)?r(function(e){return t(a,s,e)}):t(a,s,i)}}}var c=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)};function l(t,e,n){return function(){if(0===arguments.length)return n();var r=arguments[arguments.length-1];if(!c(r)){for(var o=0;o<t.length;){if("function"==typeof r[t[o]])return r[t[o]].apply(r,Array.prototype.slice.call(arguments,0,-1));o+=1}if(function(t){return null!=t&&"function"==typeof t["@@transducer/step"]}(r))return e.apply(null,Array.prototype.slice.call(arguments,0,-1))(r)}return n.apply(this,arguments)}}var p=function(){return this.xf["@@transducer/init"]()},f=function(t){return this.xf["@@transducer/result"](t)};function h(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}function y(t,e,n){for(var r=0,o=n.length;r<o;){if(t(e,n[r]))return!0;r+=1}return!1}function d(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var g="function"==typeof Object.is?Object.is:function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e},m=Object.prototype.toString,v=function(){return"[object Arguments]"===m.call(arguments)?function(t){return"[object Arguments]"===m.call(t)}:function(t){return d("callee",t)}}(),b=!{toString:null}.propertyIsEnumerable("toString"),S=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],j=function(){return arguments.propertyIsEnumerable("length")}(),w=function(t,e){for(var n=0;n<t.length;){if(t[n]===e)return!0;n+=1}return!1},A="function"!=typeof Object.keys||j?r(function(t){if(Object(t)!==t)return[];var e,n,r=[],o=j&&v(t);for(e in t)!d(e,t)||o&&"length"===e||(r[r.length]=e);if(b)for(n=S.length-1;n>=0;)d(e=S[n],t)&&!w(r,e)&&(r[r.length]=e),n-=1;return r}):r(function(t){return Object(t)!==t?[]:Object.keys(t)}),k=r(function(t){return null===t?"Null":void 0===t?"Undefined":Object.prototype.toString.call(t).slice(8,-1)});function _(t,e,n,r){var o=h(t);function a(t,e){return O(t,e,n.slice(),r.slice())}return!y(function(t,e){return!y(a,e,t)},h(e),o)}function O(t,e,n,r){if(g(t,e))return!0;var o,a,s=k(t);if(s!==k(e))return!1;if("function"==typeof t["fantasy-land/equals"]||"function"==typeof e["fantasy-land/equals"])return"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e)&&"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t);if("function"==typeof t.equals||"function"==typeof e.equals)return"function"==typeof t.equals&&t.equals(e)&&"function"==typeof e.equals&&e.equals(t);switch(s){case"Arguments":case"Array":case"Object":if("function"==typeof t.constructor&&"Promise"===(o=t.constructor,null==(a=String(o).match(/^function (\w*)/))?"":a[1]))return t===e;break;case"Boolean":case"Number":case"String":if(typeof t!=typeof e||!g(t.valueOf(),e.valueOf()))return!1;break;case"Date":if(!g(t.valueOf(),e.valueOf()))return!1;break;case"Error":return t.name===e.name&&t.message===e.message;case"RegExp":if(t.source!==e.source||t.global!==e.global||t.ignoreCase!==e.ignoreCase||t.multiline!==e.multiline||t.sticky!==e.sticky||t.unicode!==e.unicode)return!1}for(var i=n.length-1;i>=0;){if(n[i]===t)return r[i]===e;i-=1}switch(s){case"Map":return t.size===e.size&&_(t.entries(),e.entries(),n.concat([t]),r.concat([e]));case"Set":return t.size===e.size&&_(t.values(),e.values(),n.concat([t]),r.concat([e]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var u=A(t);if(u.length!==A(e).length)return!1;var c=n.concat([t]),l=r.concat([e]);for(i=u.length-1;i>=0;){var p=u[i];if(!d(p,e)||!O(e[p],t[p],c,l))return!1;i-=1}return!0}var T=o(function(t,e){return O(t,e,[],[])});function x(t,e){return function(t,e,n){var r,o;if("function"==typeof t.indexOf)switch(typeof e){case"number":if(0===e){for(r=1/e;n<t.length;){if(0===(o=t[n])&&1/o===r)return n;n+=1}return-1}if(e!=e){for(;n<t.length;){if("number"==typeof(o=t[n])&&o!=o)return n;n+=1}return-1}return t.indexOf(e,n);case"string":case"boolean":case"function":case"undefined":return t.indexOf(e,n);case"object":if(null===e)return t.indexOf(e,n)}for(;n<t.length;){if(T(t[n],e))return n;n+=1}return-1}(e,t,0)>=0}function R(t,e){for(var n=0,r=e.length,o=Array(r);n<r;)o[n]=t(e[n]),n+=1;return o}function U(t){return'"'+t.replace(/\\/g,"\\\\").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/\0/g,"\\0").replace(/"/g,'\\"')+'"'}var C=function(t){return(t<10?"0":"")+t},q="function"==typeof Date.prototype.toISOString?function(t){return t.toISOString()}:function(t){return t.getUTCFullYear()+"-"+C(t.getUTCMonth()+1)+"-"+C(t.getUTCDate())+"T"+C(t.getUTCHours())+":"+C(t.getUTCMinutes())+":"+C(t.getUTCSeconds())+"."+(t.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"};function N(t,e,n){for(var r=0,o=n.length;r<o;)e=t(e,n[r]),r+=1;return e}function E(t){return"[object Object]"===Object.prototype.toString.call(t)}var I=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=p,t.prototype["@@transducer/result"]=f,t.prototype["@@transducer/step"]=function(t,e){return this.f(e)?this.xf["@@transducer/step"](t,e):t},t}();function P(t){return function(e){return new I(t,e)}}var $=o(l(["fantasy-land/filter","filter"],P,function(t,e){return E(e)?N(function(n,r){return t(e[r])&&(n[r]=e[r]),n},{},A(e)):function(t,e){for(var n=0,r=e.length,o=[];n<r;)t(e[n])&&(o[o.length]=e[n]),n+=1;return o}(t,e)})),B=o(function(t,e){return $((n=t,function(){return!n.apply(this,arguments)}),e);var n});function F(t,e){var n=function(n){var r=e.concat([t]);return x(n,r)?"<Circular>":F(n,r)},r=function(t,e){return R(function(e){return U(e)+": "+n(t[e])},e.slice().sort())};switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+R(n,t).join(", ")+"))";case"[object Array]":return"["+R(n,t).concat(r(t,B(function(t){return/^\d+$/.test(t)},A(t)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof t?"new Boolean("+n(t.valueOf())+")":t.toString();case"[object Date]":return"new Date("+(isNaN(t.valueOf())?n(NaN):U(q(t)))+")";case"[object Map]":return"new Map("+n(Array.from(t))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof t?"new Number("+n(t.valueOf())+")":1/t==-1/0?"-0":t.toString(10);case"[object Set]":return"new Set("+n(Array.from(t).sort())+")";case"[object String]":return"object"==typeof t?"new String("+n(t.valueOf())+")":U(t);case"[object Undefined]":return"undefined";default:if("function"==typeof t.toString){var o=t.toString();if("[object Object]"!==o)return o}return"{"+r(t,A(t)).join(", ")+"}"}}var K=r(function(t){return F(t,[])}),M=function(){function t(t,e){this.xf=e,this.f=t}return t.prototype["@@transducer/init"]=p,t.prototype["@@transducer/result"]=f,t.prototype["@@transducer/step"]=function(t,e){return this.xf["@@transducer/step"](t,this.f(e))},t}(),z=o(l(["fantasy-land/map","map"],function(t){return function(e){return new M(t,e)}},function(t,e){switch(Object.prototype.toString.call(e)){case"[object Function]":return i(e.length,function(){return t.call(this,e.apply(this,arguments))});case"[object Object]":return N(function(n,r){return n[r]=t(e[r]),n},{},A(e));default:return R(t,e)}})),D=Number.isInteger||function(t){return(t|0)===t};function G(t){return"[object String]"===Object.prototype.toString.call(t)}var L=o(function(t,e){var n=t<0?e.length+t:t;return G(e)?e.charAt(n):e[n]}),Z=o(function(t,e){if(null!=e)return D(t)?L(t,e):e[t]}),H=r(function(t){return!!c(t)||!!t&&("object"==typeof t&&(!G(t)&&(0===t.length||t.length>0&&(t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1)))))}),J="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function V(t,e,n){return function(r,o,a){if(H(a))return t(r,o,a);if(null==a)return o;if("function"==typeof a["fantasy-land/reduce"])return e(r,o,a,"fantasy-land/reduce");if(null!=a[J])return n(r,o,a[J]());if("function"==typeof a.next)return n(r,o,a);if("function"==typeof a.reduce)return e(r,o,a,"reduce");throw new TypeError("reduce: list must be array or iterable")}}function W(t,e,n){for(var r=0,o=n.length;r<o;){if((e=t["@@transducer/step"](e,n[r]))&&e["@@transducer/reduced"]){e=e["@@transducer/value"];break}r+=1}return t["@@transducer/result"](e)}var X=o(function(t,e){return a(t.length,function(){return t.apply(e,arguments)})});function Y(t,e,n){for(var r=n.next();!r.done;){if((e=t["@@transducer/step"](e,r.value))&&e["@@transducer/reduced"]){e=e["@@transducer/value"];break}r=n.next()}return t["@@transducer/result"](e)}function Q(t,e,n,r){return t["@@transducer/result"](n[r](X(t["@@transducer/step"],t),e))}var tt=V(W,Q,Y),et=function(){function t(t){this.f=t}return t.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},t.prototype["@@transducer/result"]=function(t){return t},t.prototype["@@transducer/step"]=function(t,e){return this.f(t,e)},t}();var nt=u(function(t,e,n){return tt("function"==typeof t?new et(t):t,e,n)});var rt=r(function(t){return null==t}),ot=u(function t(e,n,r){if(0===e.length)return n;var o=e[0];if(e.length>1){var a=!rt(r)&&d(o,r)&&"object"==typeof r[o]?r[o]:D(e[1])?[]:{};n=t(Array.prototype.slice.call(e,1),n,a)}return function(t,e,n){if(D(t)&&c(n)){var r=[].concat(n);return r[t]=e,r}var o={};for(var a in n)o[a]=n[a];return o[t]=e,o}(o,n,r)});function at(t,e){return function(){return e.call(this,t.apply(this,arguments))}}function st(t,e){return function(){var n=arguments.length;if(0===n)return e();var r=arguments[n-1];return c(r)||"function"!=typeof r[t]?e.apply(this,arguments):r[t].apply(r,Array.prototype.slice.call(arguments,0,n-1))}}var it=r(st("tail",u(st("slice",function(t,e,n){return Array.prototype.slice.call(n,t,e)}))(1,1/0)));function ut(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return a(arguments[0].length,nt(at,arguments[0],it(arguments)))}var ct=r(function(t){return G(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()});function lt(){if(0===arguments.length)throw new Error("compose requires at least one argument");return ut.apply(this,ct(arguments))}var pt=r(function(t){return i(t.length,t)});var ft=r(function(t){return null!=t&&"function"==typeof t["fantasy-land/empty"]?t["fantasy-land/empty"]():null!=t&&null!=t.constructor&&"function"==typeof t.constructor["fantasy-land/empty"]?t.constructor["fantasy-land/empty"]():null!=t&&"function"==typeof t.empty?t.empty():null!=t&&null!=t.constructor&&"function"==typeof t.constructor.empty?t.constructor.empty():c(t)?[]:G(t)?"":E(t)?{}:v(t)?function(){return arguments}():function(t){var e=Object.prototype.toString.call(t);return"[object Uint8ClampedArray]"===e||"[object Int8Array]"===e||"[object Uint8Array]"===e||"[object Int16Array]"===e||"[object Uint16Array]"===e||"[object Int32Array]"===e||"[object Uint32Array]"===e||"[object Float32Array]"===e||"[object Float64Array]"===e||"[object BigInt64Array]"===e||"[object BigUint64Array]"===e}(t)?t.constructor.from(""):void 0}),ht=function(){function t(t,e){this.xf=e,this.f=t,this.found=!1}return t.prototype["@@transducer/init"]=p,t.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,void 0)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,e){var n;return this.f(e)&&(this.found=!0,t=(n=this.xf["@@transducer/step"](t,e))&&n["@@transducer/reduced"]?n:{"@@transducer/value":n,"@@transducer/reduced":!0}),t},t}();function yt(t){return function(e){return new ht(t,e)}}var dt=o(l(["find"],yt,function(t,e){for(var n=0,r=e.length;n<r;){if(t(e[n]))return e[n];n+=1}})),gt=o(x),mt=o(function(t,e){return i(t+1,function(){var n=arguments[t];if(null!=n&&function(t){var e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e||"[object GeneratorFunction]"===e||"[object AsyncGeneratorFunction]"===e}(n[e]))return n[e].apply(n,Array.prototype.slice.call(arguments,0,t));throw new TypeError(K(n)+' does not have a method named "'+e+'"')})}),vt=r(function(t){return null!=t&&T(t,ft(t))}),bt=mt(1,"join"),St=o(function(t,e){return function(n){return function(r){return z(function(t){return e(t,r)},n(t(r)))}}}),jt=o(function(t,e){return t.map(function(t){for(var n,r=e,o=0;o<t.length;){if(null==r)return;n=t[o],r=D(n)?L(n,r):r[n],o+=1}return r})}),wt=o(function(t,e){return jt([t],e)[0]}),At=r(function(t){return St(wt(t),ot(t))}),kt=function(t){return{value:t,"fantasy-land/map":function(){return this}}},_t=o(function(t,e){return t(kt)(e).value});const Ot=pt((t,e,n,r)=>lt(Z(r),dt(t=>gt(n,t[e])))(t)),Tt=At(["results","0","address_components"]),xt=t=>{const e=t.results?t.results[0]:t.result;if(!e||vt(e))return{};let n=null;n=t.results?_t(Tt)(t):e.address_components;const r=Ot(n,"types"),o=e.formatted_address,a=e.geometry&&e.geometry.location&&e.geometry.location.lat?e.geometry.location.lat:null,s=e.geometry&&e.geometry.location&&e.geometry.location.lng?e.geometry.location.lng:null,i=r("street_number","short_name")||"",u=r("route","long_name")||"",c=(i||u)&&`${i} ${u}`,l={state:r("administrative_area_level_1","short_name"),city:r("locality","short_name")||r("sublocality","short_name")||r("neighborhood","long_name")||r("administrative_area_level_3","long_name")||r("administrative_area_level_2","short_name"),street_1:c.trim(),country:r("country","short_name"),zipcode:r("postal_code","long_name"),latitude:a&&Number(a),longitude:s&&Number(s),formattedAddress:o};return $(Boolean)(l)};return t.GeoService=class{constructor(t){this.mapsKey=t}async geocode(t){const e=await fetch(`https://maps.googleapis.com/maps/api/geocode/json?address=${t}&key=${this.mapsKey}`),n=await e.json();return xt(n)}async geocodeZip(t){const e=await fetch(`https://maps.googleapis.com/maps/api/geocode/json?components=country:US|postal_code:${t}&key=${this.mapsKey}`),n=await e.json();return xt(n)}async reverseGeocode(t,e){const n=await fetch(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${t},${e}&key=${this.mapsKey}`),r=await n.json();return xt(r)}async geoLocate(){const t=`https://www.googleapis.com/geolocation/v1/geolocate?key=${this.mapsKey}`,e=await fetch(t,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"}}),n=await e.json(),{lat:r,lng:o}=n.location;return this.reverseGeocode(r,o)}async getLocationSuggestions(t){const{input:e,latitude:n,longitude:r,radius:o}=t,{requestCity:a,requestState:s,requestZipcode:i}=t,u=bt(",",$(Boolean,[n,r]));let{sessiontoken:c}=t;c||(c=crypto.randomUUID().replaceAll("-",""));const l=$(Boolean,{input:e,sessiontoken:c,location:u,radius:o,components:"country:US",types:"address",key:this.mapsKey});let p="";if(l){p=new URLSearchParams(l).toString()}const f=`https://maps.googleapis.com/maps/api/place/autocomplete/json?${p}`,h=await fetch(f,{method:"GET",headers:{Accept:"application/json"}}),y=await h.json();let d=[];if(y.predictions&&"OK"===y.status){const t={requestCity:a,requestState:s,requestZipcode:i};d=((t,e={})=>{const{requestCity:n,requestState:r,requestZipcode:o}=e,a=t=>({description:t.description,placeId:t.place_id});let s=null;return n||r||o||(s=t.map(a)),s=t.map(t=>{const e={description:t.description,place_id:t.place_id},a=t.terms.filter(t=>n&&t.value===n).length>0?1:0,s=t.terms.filter(t=>r&&t.value===r).length>0?1:0,i=t.terms.filter(t=>o&&t.value===o).length>0?1:0;return e.score=a+s+i,e.stateMatch=!r||r&&s,e.zipCodeMatch=!o||o&&i,e}).filter(t=>!!t.stateMatch&&!!t.zipCodeMatch).sort((t,e)=>t.score===e.score?0:t.score<e.score?1:-1).map(a),s})(y.predictions,t)}return{autocompletePredictions:d,sessiontoken:c}}async getPlaceId(t){const{placeId:e,sessiontoken:n}=t,r=$(Boolean,{place_id:e,sessiontoken:n,key:this.mapsKey});let o="";if(r){o=new URLSearchParams(r).toString()}const a=`https://maps.googleapis.com/maps/api/place/details/json?${o}`,s=await fetch(a),i=await s.json();return xt(i)}async getNavigatorPosition(){const t=t=>{console.error(t)};navigator.geolocation&&navigator.geolocation.getCurrentPosition(t=>{const e=t.coords.latitude,n=t.coords.longitude;return this.reverseGeocode(e,n)},t)||t({message:"geolocation is not enabled."})}},t.ThirstieAPI=class{#t;#e;#n;#r;#o;constructor(t,n={}){const{env:r,initState:o}=n;this.#o=r,this.#r={sessionToken:null,application:null,applicationRef:null,sessionRef:null,userRef:null,user:{},message:null},this.#t=t,this.#e=e(r),this.#n=Object.seal(this.#r);const{sessionToken:a,application:s,applicationRef:i,sessionRef:u}=o||{};if(a&&s&&i&&u){const t={sessionToken:a,application:s,applicationRef:i,sessionRef:u};this.apiState=t}}get sessionToken(){return this.#n.sessionToken}get sessionRef(){return this.#n.sessionRef}get userRef(){return this.#n.userRef}get applicationRef(){return this.#n.applicationRef}get application(){return this.#n.application}get sessionState(){const{sessionToken:t,application:e,applicationRef:n,sessionRef:r,userRef:o}=this.#n;return{sessionToken:t,application:e,applicationRef:n,sessionRef:r,userRef:o}}get apiState(){return this.#n}set apiState(t){try{return Object.assign(this.#n,t)}catch(t){return console.error("set apiState",t),this.#n}}#a(t){const e={application:t.application_name,applicationRef:t.uuid,sessionToken:t.token,sessionRef:t.session_uuid};if(e.userRef=t.user?.id,t.user){const{birthday:n,email:r,prefix:o,guest:a,first_name:s,last_name:i,phone_number:u,last_login:c}=t.user;e.user={email:r,birthday:n,prefix:o,firstName:s,lastName:i,phoneNumber:u,guest:a,lastLogin:c}}this.apiState=e}#s(t){this.apiState=this.#r,console.error("session error",t)}async getNewSession(t={},e=!0){const{email:n,password:r}=t,o={basicAuth:e};n&&r&&(o.data={email:n,password:r});const a=await this.apiCaller("POST","/a/v2/sessions",o);return a&&a.ok&&a.data?a.data:{code:a.status,message:a.message||"unknown error",response:a}}async validateSession(t){if(t&&(this.apiState={sessionToken:t}),!this.sessionToken)return{};const e=await this.apiCaller("GET","/a/v2/sessions");return e&&e.ok&&e.data?e.data:await this.getNewSession()}async fetchSession(t=null,e=!1){let n={};return n=!this.sessionToken&&!t||e?await this.getNewSession():await this.validateSession(t),n.token?this.#a(n):this.#s(n),this.apiState}async loginUser(t){const{email:e,password:n}=t,r=!this.sessionToken;if(!e||!n)throw new Error("Invalid credential payload");const o=await this.getNewSession(t,r);if(o.token)this.#a(o);else{this.#s(o);const{response:t}=o,{data:e}=t;e?.message&&(this.apiState.message=e?.message)}return this.apiState}async createUser(t,e=null){const n={},{email:r,password:o}=t,{birthday:a,prefix:s,firstName:i,lastName:u,phoneNumber:c,guestCheck:l,emailOptIn:p}=t,f={email:r,birthday:a,prefix:s,first_name:i,last_name:u,phone_number:c,guest_check:!!l};p&&(f.aux_data={thirstieaccess_email_opt_in:p});const h=!this.sessionToken;r&&o?f.password=o:f.guest=!0,n.data=f,n.basicAuth=h;const y=await this.apiCaller("POST","/a/v2/users",n,e);return y.data.token?this.#a(y.data):this.#s(y),this.apiState}async apiCaller(t,n,r={},o=null){const{data:a,params:s,basicAuth:i,isFormData:u,isTemplate:c,isPayment:l,isCSV:p}=r,{sessionRef:f,application:h,applicationRef:y,userRef:d}=this.apiState;if(!this.sessionToken&&!i)throw new Error("Invalid Authorization");const g={Authorization:this.sessionToken&&!i?`Bearer ${this.sessionToken}`:`Basic ${btoa(this.#t)}`,Accept:"application/json"};u||(g["Content-Type"]="application/json"),p&&(g.Accept="text/csv",delete g["Content-Type"]);const m={method:t,headers:g};["POST","PUT","PATCH"].includes(t)&&a&&(m.body=u?a:JSON.stringify(a));const v=e(this.#o);let b=v;l&&(b="https://api.thirstie.com"===v?"https://merchant-payments.thirstie.cloud":"https://merchant-payments.next.thirstie.cloud"),c&&(b=(t=>"https://api.thirstie.com"===t?"https://templates.thirstie.cloud":"https://staging.templates.thirstie.cloud")(v));const{requestUrl:S,queryString:j}=function(t,e,n=null){let r="";n&&(r="?"+new URLSearchParams(n).toString());return{requestUrl:`${t}${e}${r}`,queryString:r}}(b,n,s),w={environment:this.#o,sessionRef:f,application:h,applicationRef:y,userRef:d,data:a,queryString:j,url:n,baseUrl:b};try{const t=await async function(t,e){const n={ok:null,status:null,statusText:null,data:{}};try{const r=await fetch(t,e);let o={};const a=r.headers;return a&&a.get("content-type")?.indexOf("application/json")>-1&&parseInt(a.get("content-length"))>0&&(o=await r.json()),Object.assign(n,{ok:r.ok,status:r.status,statusText:r.statusText,data:o,url:t})}catch(e){return console.error("apiRequest error: ",e),Object.assign(n,{ok:!1,status:500,statusText:"ERROR",data:{message:"Network error",error:e},url:t})}}(S,m);if(t)return!t.ok&&o&&o({code:t.status,message:t.statusText||"unknown error",response:t,telemetryContext:w}),p?{ok:t.ok,status:t.status,statusText:t.statusText,url:t.url,data:await t.text()}:t}catch(t){return o&&o({code:500,message:"unknown error",error:t,telemetryContext:w}),t}}},t}({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thirstie/thirstieservices",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Service layer for Thirstie ecommerce API",
5
5
  "author": "Thirstie, Inc. <technology@thirstie.com>",
6
6
  "license": "MIT",
@@ -33,5 +33,5 @@
33
33
  "testEnvironment": "jsdom",
34
34
  "transform": {}
35
35
  },
36
- "gitHead": "9e88a4a2783c8c56191ab1bd1812552ddc64fda4"
36
+ "gitHead": "7a603c3eab3b23e23e4dce93bed63c39b4ce6fcf"
37
37
  }