@saasquatch/component-boilerplate 1.6.6 → 1.6.7-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.
@@ -1,4 +1,4 @@
1
- import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgramContext as n,PROGRAM_CONTEXT_NAME as r,lazilyStartUserContext as a,USER_CONTEXT_NAME as o,userIdentityFromJwt as s,isDemo as i,setUserIdentity as d,getTenantAlias as c,getAppDomain as u,getEngagementMedium as l,getEnvironment as m,history as f}from"@saasquatch/component-environment";export{getEnvironmentSDK,isDemo,setProgramId,setUserIdentity}from"@saasquatch/component-environment";import{useDomContext as g,useDomContextState as p}from"@saasquatch/dom-context-hooks";import{parse as h,print as y}from"graphql";import v from"jwt-decode";import{useReducer as C,useCallback as w,useState as b,useEffect as I,useMemo as E,useRef as F}from"@saasquatch/universal-hooks";import P from"fast-memoize";import $ from"graphql-combine-query";import{GraphQLClient as M,gql as D}from"graphql-request";import{ClientError as S}from"graphql-request/dist/types";import{nanoid as k}from"nanoid";import{Subject as q}from"rxjs";import{bufferTime as A}from"rxjs/operators";import{equal as R}from"@wry/equality";import{useDomContext as x}from"@saasquatch/stencil-hooks";import{deepEqual as j}from"fast-equals";import V from"debounce";import{ContextProvider as W}from"dom-context";import N from"jsonpointer";const O={current:void 0};function U(){if(void 0===O.current)throw new Error("no implementation of useHost provided");return O.current()}function L(e){if(!e)throw new Error("Must supply an implementation");if("function"!=typeof e)throw new Error("implementation must be a function");O.current=e}function _(){e();const n=U();return g(n,t)}function H(){n();const e=U();return g(e,r)}function T(){var e,t;return null==(e=Q())||null==(t=e.managedIdentity)?void 0:t.sessionData}function J(){var e;return null==(e=Q())?void 0:e.jwt}function Q(){a();const e=U(),t=g(e,o),n=s(null==t?void 0:t.jwt);if(i()||!t||n)return t;d(void 0)}const z=c,G=u,B=l;var K=function(){return(K=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},Z=new Map,X=new Map,Y=!0,ee=!1;function te(e){return e.replace(/[\s,]+/g," ").trim()}function ne(e){var t,n,r,a=te(e);if(!Z.has(a)){var o=h(e,{experimentalFragmentVariables:ee});if(!o||"Document"!==o.kind)throw new Error("Not a valid GraphQL document.");Z.set(a,function(e){var t=new Set(e.definitions);t.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(n){var r=e[n];r&&"object"==typeof r&&t.add(r)})});var n=e.loc;return n&&(delete n.startToken,delete n.endToken),e}((t=o,n=new Set,r=[],t.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var t=e.name.value,a=te((s=e.loc).source.body.substring(s.start,s.end)),o=X.get(t);o&&!o.has(a)?Y&&console.warn("Warning: fragment with name "+t+" already exists.\ngraphql-tag enforces all fragment names across your application to be unique; read more about\nthis in the docs: http://dev.apollodata.com/core/fragments.html#unique-names"):o||X.set(t,o=new Set),o.add(a),n.has(a)||(n.add(a),r.push(e))}else r.push(e);var s}),K(K({},t),{definitions:r}))))}return Z.get(a)}function re(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];"string"==typeof e&&(e=[e]);var r=e[0];return t.forEach(function(t,n){r+=t&&"Document"===t.kind?t.loc.source.body:t,r+=e[n+1]}),ne(r)}var ae,oe=re;(ae=re||(re={})).gql=oe,ae.resetCaches=function(){Z.clear(),X.clear()},ae.disableFragmentWarnings=function(){Y=!1},ae.enableExperimentalFragmentVariables=function(){ee=!0},ae.disableExperimentalFragmentVariables=function(){ee=!1},re.default=re;var se=re;function ie(){return(ie=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}class de extends M{constructor(e,t){var n;super(e,t),n=this,this.subject=new q;const r=new q;this.subject.pipe(A(200,void 0,10)).subscribe(async function(e){if(!e.length)return;const{mergedQuery:t,mergedVariables:a,mergedQueryAddedEvents:o,unmergedQueryAddedEvents:s}=me(e);for(const e of s)r.next(e);if(o.length)try{const e=await n.superRequest(t,a);pe(e,o)}catch(e){if(e instanceof S){const{data:t,errors:n}=e.response;if(!t)return ye(o,e);const r=Object.keys(t);let a=[...o];for(const t of n){let n;t.path.find((o,s,i)=>{if(r.includes(o)){const d=le(o),c=a.findIndex(e=>e.id===d);if(-1===c)return!1;r.splice(s,1),n=a.splice(c,1)[0];const u=fe(e.response.data,n);i[s]=ue(i[s],d);const{query:l,variables:m}=n,f=ie({},e.response,{errors:[t],data:u,path:i}),g=new S(f,{query:"string"!=typeof l?y(l):l,variables:m});return he(n,g),!0}return!1})}pe(t,a)}else ye(o,e)}}),r.subscribe(async function(e){try{const{query:t,variables:r}=e,a=await n.superRequest(t,r);ge(a,e)}catch(t){he(e,t)}})}superRequest(e,t){return super.request(e,t)}request(e,t,n){return new Promise((r,a)=>{const o={query:e,variables:t,id:ce(),options:n,resolve:r,reject:a};this.subject.next(o)})}}const ce=()=>k().replace(/[-_]/g,""),ue=(e,t)=>e.replace(`_${t}`,""),le=e=>{const t=e.split("_");return t[t.length-1]},me=e=>{const t=[],n=[],{document:r,variables:a}=e.reduce((e,r)=>{const{query:a,variables:o,id:s,options:i}=r;if(null==i||!i.merge)return n.push(r),e;try{const i="string"==typeof a?h(a):a,d=i.definitions.find(e=>"FragmentDefinition"===e.kind),c="string"==typeof a?a:y(a),u=/@/.test(c);if(d||u)return n.push(r),e;const l=e=>((e,t)=>`${e}_${t}`)(e,s);return e=e.addN(i,[o],l,l),t.push(r),e}catch(t){return n.push(r),e}},$("BatchedQuery"));return{mergedQuery:r&&y(r),mergedVariables:a,mergedQueryAddedEvents:t,unmergedQueryAddedEvents:n}},fe=(e,t)=>{if(!e)return e;const n=Object.keys(e),{id:r}=t;return n.reduce((t,n)=>(n.endsWith(r)&&(t=ie({},t,{[ue(n,r)]:e[n]})),t),{})},ge=(e,t)=>{const{resolve:n}=t;n(e)},pe=(e,t)=>{for(const n of t){const t=fe(e,n);n.resolve(t)}},he=(e,t)=>{const{reject:n}=e;n(t)},ye=(e,t)=>{for(const n of e){const{reject:e}=n;e(t)}},ve="sq:graphql-client",Ce=P(function(e,t,n){return new de(e+"/api/v1/"+t+"/graphql",{headers:{Authorization:`Bearer ${n||""}`}})});function we(e,t){switch(t.type){case"loading":return{data:void 0,errors:void 0,loading:!0};case"data":return{data:t.payload,errors:void 0,loading:!1};case"errors":return{data:void 0,errors:t.payload,loading:!1}}}function be(e,t,n={merge:!0}){const r=function(){const e=J(),t=G(),n=z(),r=Ce(t,n,e),a=U(),o=g(a,"sq:graphql-client",{attempts:0});return null!=o?o:r}(),[a,o]=C(we,t);return[a,w(async function(t,a=!1){if(!r){const e=new Error("No GraphQL client found");return o({type:"errors",payload:e}),e}try{a||o({type:"loading"});const s=await r.request(e,t,n);return o({type:"data",payload:s}),s}catch(e){return o({type:"errors",payload:e}),e}},[r,e,o])]}const Ie={loading:!1,data:void 0,errors:void 0};function Ee(e){const[t,n]=be(e,Ie);return[n,t]}let Fe;const Pe=se(Fe||(Fe=(e=>e)`
1
+ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgramContext as n,PROGRAM_CONTEXT_NAME as r,lazilyStartUserContext as a,USER_CONTEXT_NAME as o,userIdentityFromJwt as s,isDemo as i,setUserIdentity as d,getTenantAlias as c,getAppDomain as u,getEngagementMedium as l,getEnvironment as m,history as f}from"@saasquatch/component-environment";export{getEnvironmentSDK,isDemo,setProgramId,setUserIdentity}from"@saasquatch/component-environment";import{useDomContext as g,useDomContextState as p}from"@saasquatch/dom-context-hooks";import{parse as h,print as y}from"graphql";import v from"jwt-decode";import{useReducer as C,useCallback as w,useState as b,useEffect as I,useMemo as E,useRef as F}from"@saasquatch/universal-hooks";import P from"fast-memoize";import $ from"graphql-combine-query";import{GraphQLClient as M,gql as D}from"graphql-request";import{ClientError as S}from"graphql-request/dist/types";import{nanoid as k}from"nanoid";import{Subject as q}from"rxjs";import{bufferTime as A}from"rxjs/operators";import{equal as R}from"@wry/equality";import{useDomContext as x}from"@saasquatch/stencil-hooks";import{deepEqual as j}from"fast-equals";import V from"debounce";import{ContextProvider as W}from"dom-context";import N from"jsonpointer";const O={current:void 0};function U(){if(void 0===O.current)throw new Error("no implementation of useHost provided");return O.current()}function L(e){if(!e)throw new Error("Must supply an implementation");if("function"!=typeof e)throw new Error("implementation must be a function");O.current=e}function _(){e();const n=U();return g(n,t)}function H(){n();const e=U();return g(e,r)}function T(){var e,t;return null==(e=Q())||null==(t=e.managedIdentity)?void 0:t.sessionData}function J(){var e;return null==(e=Q())?void 0:e.jwt}function Q(){a();const e=U(),t=g(e,o),n=s(null==t?void 0:t.jwt);if(i()||!t||n)return t;d(void 0)}const z=c,G=u,B=l;var K=function(){return(K=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},Z=new Map,X=new Map,Y=!0,ee=!1;function te(e){return e.replace(/[\s,]+/g," ").trim()}function ne(e){var t,n,r,a=te(e);if(!Z.has(a)){var o=h(e,{experimentalFragmentVariables:ee});if(!o||"Document"!==o.kind)throw new Error("Not a valid GraphQL document.");Z.set(a,function(e){var t=new Set(e.definitions);t.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(n){var r=e[n];r&&"object"==typeof r&&t.add(r)})});var n=e.loc;return n&&(delete n.startToken,delete n.endToken),e}((t=o,n=new Set,r=[],t.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var t=e.name.value,a=te((s=e.loc).source.body.substring(s.start,s.end)),o=X.get(t);o&&!o.has(a)?Y&&console.warn("Warning: fragment with name "+t+" already exists.\ngraphql-tag enforces all fragment names across your application to be unique; read more about\nthis in the docs: http://dev.apollodata.com/core/fragments.html#unique-names"):o||X.set(t,o=new Set),o.add(a),n.has(a)||(n.add(a),r.push(e))}else r.push(e);var s}),K(K({},t),{definitions:r}))))}return Z.get(a)}function re(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];"string"==typeof e&&(e=[e]);var r=e[0];return t.forEach(function(t,n){r+=t&&"Document"===t.kind?t.loc.source.body:t,r+=e[n+1]}),ne(r)}var ae,oe=re;(ae=re||(re={})).gql=oe,ae.resetCaches=function(){Z.clear(),X.clear()},ae.disableFragmentWarnings=function(){Y=!1},ae.enableExperimentalFragmentVariables=function(){ee=!0},ae.disableExperimentalFragmentVariables=function(){ee=!1},re.default=re;var se=re;function ie(){return(ie=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}class de extends M{constructor(e,t){var n;super(e,t),n=this,this.subject=new q;const r=new q;this.subject.pipe(A(200,void 0,10)).subscribe(async function(e){if(!e.length)return;const{mergedQuery:t,mergedVariables:a,mergedQueryAddedEvents:o,unmergedQueryAddedEvents:s}=me(e);for(const e of s)r.next(e);if(o.length)try{const e=await n.superRequest(t,a);pe(e,o)}catch(e){if(e instanceof S){const{data:t,errors:n}=e.response;if(!t)return ye(o,e);const r=Object.keys(t);let a=[...o];for(const t of n){let n;t.path.find((o,s,i)=>{if(r.includes(o)){const d=le(o),c=a.findIndex(e=>e.id===d);if(-1===c)return!1;r.splice(s,1),n=a.splice(c,1)[0];const u=fe(e.response.data,n);i[s]=ue(i[s],d);const{query:l,variables:m}=n,f=ie({},e.response,{errors:[t],data:u,path:i}),g=new S(f,{query:"string"!=typeof l?y(l):l,variables:m});return he(n,g),!0}return!1})}pe(t,a)}else ye(o,e)}}),r.subscribe(async function(e){try{const{query:t,variables:r}=e,a=await n.superRequest(t,r);ge(a,e)}catch(t){he(e,t)}})}superRequest(e,t){return super.request(e,t)}request(e,t,n){return new Promise((r,a)=>{const o={query:e,variables:t,id:ce(),options:n,resolve:r,reject:a};this.subject.next(o)})}}const ce=()=>k().replace(/[-_]/g,""),ue=(e,t)=>e.replace(`_${t}`,""),le=e=>{const t=e.split("_");return t[t.length-1]},me=e=>{const t=[],n=[],{document:r,variables:a}=e.reduce((e,r)=>{const{query:a,variables:o,id:s,options:i}=r;if(null==i||!i.batch)return n.push(r),e;try{const i="string"==typeof a?h(a):a,d=i.definitions.find(e=>"FragmentDefinition"===e.kind),c="string"==typeof a?a:y(a),u=/@/.test(c);if(d||u)return n.push(r),e;const l=e=>((e,t)=>`${e}_${t}`)(e,s);return e=e.addN(i,[o],l,l),t.push(r),e}catch(t){return n.push(r),e}},$("BatchedQuery"));return{mergedQuery:r&&y(r),mergedVariables:a,mergedQueryAddedEvents:t,unmergedQueryAddedEvents:n}},fe=(e,t)=>{if(!e)return e;const n=Object.keys(e),{id:r}=t;return n.reduce((t,n)=>(n.endsWith(r)&&(t=ie({},t,{[ue(n,r)]:e[n]})),t),{})},ge=(e,t)=>{const{resolve:n}=t;n(e)},pe=(e,t)=>{for(const n of t){const t=fe(e,n);n.resolve(t)}},he=(e,t)=>{const{reject:n}=e;n(t)},ye=(e,t)=>{for(const n of e){const{reject:e}=n;e(t)}},ve="sq:graphql-client",Ce=P(function(e,t,n){return new de(e+"/api/v1/"+t+"/graphql",{headers:{Authorization:`Bearer ${n||""}`}})});function we(e,t){switch(t.type){case"loading":return{data:void 0,errors:void 0,loading:!0};case"data":return{data:t.payload,errors:void 0,loading:!1};case"errors":return{data:void 0,errors:t.payload,loading:!1}}}function be(e,t,n={batch:!0}){const r=function(){const e=J(),t=G(),n=z(),r=Ce(t,n,e),a=U(),o=g(a,"sq:graphql-client",{attempts:0});return null!=o?o:r}(),[a,o]=C(we,t);return[a,w(async function(t,a=!1){if(!r){const e=new Error("No GraphQL client found");return o({type:"errors",payload:e}),e}try{a||o({type:"loading"});const s=await r.request(e,t,n);return o({type:"data",payload:s}),s}catch(e){return o({type:"errors",payload:e}),e}},[r,e,o])]}const Ie={loading:!1,data:void 0,errors:void 0};function Ee(e){const[t,n]=be(e,Ie);return[n,t]}let Fe;const Pe=se(Fe||(Fe=(e=>e)`
2
2
  mutation AuthenticateWithEmailAndPassword(
3
3
  $email: String!
4
4
  $password: String!
@@ -161,7 +161,7 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
161
161
  token
162
162
  }
163
163
  }
164
- `));function it(){const e=H(),t=m(),[n,{loading:r,data:a,errors:o}]=Ee(st);return[async r=>{const a=await n(r);if(!(a instanceof Error)&&a.authenticateManagedIdentityWithInstantAccess){if("APPROVED"!==await async function(e,t){try{var n;const r=await fetch(`${u()}/api/v1/${c()}/graphql`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({query:"\n query checkReferralFraudStatus($programId: ID) {\n viewer {\n ... on User {\n id\n instantAccessRewards(filter: { programId_eq: $programId }) {\n data {\n id\n pendingReasons\n cancelledReason\n }\n }\n }\n }\n }\n",variables:{programId:e}})});if(!r.ok)throw new Error("Failed to fetch locale");const a=await r.json();if(a.errors)throw new Error(JSON.stringify(a.errors,null,2));const o=(null==(n=a.data.viewer.instantAccessRewards)?void 0:n.data)||[];return o.some(e=>"SUSPECTED_FRAUD"===e.cancelledReason)?"DENIED":o.some(e=>{var t;return null==(t=e.pendingReasons)?void 0:t.includes("SUSPECTED_FRAUD")})?"PENDING_REVIEW":"APPROVED"}catch(e){return void console.error(e)}}(e,a.authenticateManagedIdentityWithInstantAccess.token))throw{name:"fraud_error",message:"Referral flagged as fraud."};{const e=a.authenticateManagedIdentityWithInstantAccess.email;if(d({jwt:a.authenticateManagedIdentityWithInstantAccess.token,id:e,accountId:e}),"SquatchJS2"===t){const t=new CustomEvent("sq:user-registration",{bubbles:!0,detail:{userId:e,accountId:e}});document.dispatchEvent(t)}}}return a},{loading:r,data:a,errors:o}]}function dt(e,t){const n=F();return n.current&&R(t,n.current.key)||(n.current={key:t,value:e()}),n.current.value}function ct(){return C(e=>e+1,0)}function ut(e){const t=Object.getOwnPropertyNames(e);for(const n of t){const t=e[n];t&&"object"==typeof t&&ut(t)}return Object.freeze(e)}const lt={loading:!0,data:void 0,errors:void 0};function mt(e,t,n,r={merge:!0}){const[a,o]=be(e,lt,r),[s,i]=ct();return dt(()=>{!n&&o(t)},[e,t,o,s,n]),He({skip:n,update:o,variables:t}),ut(ie({},a,{refetch:i}))}function ft(e){const t=U(),[n,r]=p(t,yt(e.namespace),e.initialValue);return p(t,vt(e.namespace),[n,r]),[n,r]}function gt(e){const t=x(vt(e)),n=x(yt(e));return t?[n,t[1]]:[void 0,void 0]}function pt(e){const t=x(vt(e));if(t)return t[1]}function ht(e){return x(yt(e))}function yt(e){return e+"-value"}function vt(e){return e+"-state"}function Ct(e){const t=U(),n=mt(e.query,e.variables||{},e.skip),[r,a]=p(t,yt(e.namespace),n);return I(()=>{j(n,r)||a(n)},[n,r]),n}function wt(e){return x(yt(e))||{data:null,loading:!0,refetch:()=>console.warn("component still loading")}}function bt(){const[,e]=ct();return I(()=>f.listen(()=>{e()}),[]),f.location}const It=f;function Et(e){const[t,n]=b({limit:e.limit,offset:e.offset}),{offset:r,limit:a}=t,o=(e,t)=>e*t,s=(e,t)=>Math.ceil(e/t)||0;return{limit:a,setLimit:e=>{const a=s(r,e),i=o(e,a);n(ie({},t,{limit:e,offset:i}))},offset:r,setCurrentPage:e=>{let t=o(e,a);n(e=>ie({},e,{offset:t}))},calculatePagination:function(e,t){const n=s(r,a),o=((e,t)=>Math.ceil(e/t)||0)(t,a),i=0===e?"0":e>1?`${r+1}-${r+e}`:`${r+1}`;return{currentPage:n,pageCount:o,rangeOnPage:i,pageProgress:`${i} of ${t}`}}}}function Ft(e,t,n,r={},a=!1){var o;const{limit:s,offset:i,setLimit:d,setCurrentPage:c,calculatePagination:u}=Et(n),l=ie({limit:s,offset:i},r),{loading:m,errors:f,data:g,refetch:p}=mt(e,l,a),h=t(g),{currentPage:y,pageCount:v,pageProgress:C}=u((null==h||null==(o=h.data)?void 0:o.length)||0,(null==h?void 0:h.totalCount)||0);return{envelope:h,states:{errors:f,loading:m,limit:s,currentPage:y,pageCount:v,pageProgress:C},callbacks:{refetch:p,setLimit:d,setCurrentPage:c}}}function Pt(e,t){return e===t}function $t(e,t,n){const r=n&&n.equalityFn||Pt,[a,o]=b(e),s=Mt(w(e=>o(e),[]),t,n),i=F(e);return I(()=>{r(i.current,e)||(s.callback(e),i.current=e)},[e,s,r]),[a,{cancel:s.cancel,flush:s.flush}]}function Mt(e,t=0,n={leading:!1}){const r=E(()=>V(e,t,n.leading),[e,t,n.leading]),{flush:a,clear:o}=r;return{flush:a,cancel:o,callback:r}}let Dt;const St=D(Dt||(Dt=(e=>e)`
164
+ `));function it(){const e=H(),t=m(),[n,{loading:r,data:a,errors:o}]=Ee(st);return[async r=>{const a=await n(r);if(!(a instanceof Error)&&a.authenticateManagedIdentityWithInstantAccess){if("APPROVED"!==await async function(e,t){try{var n;const r=await fetch(`${u()}/api/v1/${c()}/graphql`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({query:"\n query checkReferralFraudStatus($programId: ID) {\n viewer {\n ... on User {\n id\n instantAccessRewards(filter: { programId_eq: $programId }) {\n data {\n id\n pendingReasons\n cancelledReason\n }\n }\n }\n }\n }\n",variables:{programId:e}})});if(!r.ok)throw new Error("Failed to fetch locale");const a=await r.json();if(a.errors)throw new Error(JSON.stringify(a.errors,null,2));const o=(null==(n=a.data.viewer.instantAccessRewards)?void 0:n.data)||[];return o.some(e=>"SUSPECTED_FRAUD"===e.cancelledReason)?"DENIED":o.some(e=>{var t;return null==(t=e.pendingReasons)?void 0:t.includes("SUSPECTED_FRAUD")})?"PENDING_REVIEW":"APPROVED"}catch(e){return void console.error(e)}}(e,a.authenticateManagedIdentityWithInstantAccess.token))throw{name:"fraud_error",message:"Referral flagged as fraud."};{const e=a.authenticateManagedIdentityWithInstantAccess.email;if(d({jwt:a.authenticateManagedIdentityWithInstantAccess.token,id:e,accountId:e}),"SquatchJS2"===t){const t=new CustomEvent("sq:user-registration",{bubbles:!0,detail:{userId:e,accountId:e}});document.dispatchEvent(t)}}}return a},{loading:r,data:a,errors:o}]}function dt(e,t){const n=F();return n.current&&R(t,n.current.key)||(n.current={key:t,value:e()}),n.current.value}function ct(){return C(e=>e+1,0)}function ut(e){const t=Object.getOwnPropertyNames(e);for(const n of t){const t=e[n];t&&"object"==typeof t&&ut(t)}return Object.freeze(e)}const lt={loading:!0,data:void 0,errors:void 0};function mt(e,t,n,r={batch:!0}){const[a,o]=be(e,lt,r),[s,i]=ct();return dt(()=>{!n&&o(t)},[e,t,o,s,n]),He({skip:n,update:o,variables:t}),ut(ie({},a,{refetch:i}))}function ft(e){const t=U(),[n,r]=p(t,yt(e.namespace),e.initialValue);return p(t,vt(e.namespace),[n,r]),[n,r]}function gt(e){const t=x(vt(e)),n=x(yt(e));return t?[n,t[1]]:[void 0,void 0]}function pt(e){const t=x(vt(e));if(t)return t[1]}function ht(e){return x(yt(e))}function yt(e){return e+"-value"}function vt(e){return e+"-state"}function Ct(e){const t=U(),n=mt(e.query,e.variables||{},e.skip,ie({batch:!0},e.options||{})),[r,a]=p(t,yt(e.namespace),n);return I(()=>{j(n,r)||a(n)},[n,r]),n}function wt(e){return x(yt(e))||{data:null,loading:!0,refetch:()=>console.warn("component still loading")}}function bt(){const[,e]=ct();return I(()=>f.listen(()=>{e()}),[]),f.location}const It=f;function Et(e){const[t,n]=b({limit:e.limit,offset:e.offset}),{offset:r,limit:a}=t,o=(e,t)=>e*t,s=(e,t)=>Math.ceil(e/t)||0;return{limit:a,setLimit:e=>{const a=s(r,e),i=o(e,a);n(ie({},t,{limit:e,offset:i}))},offset:r,setCurrentPage:e=>{let t=o(e,a);n(e=>ie({},e,{offset:t}))},calculatePagination:function(e,t){const n=s(r,a),o=((e,t)=>Math.ceil(e/t)||0)(t,a),i=0===e?"0":e>1?`${r+1}-${r+e}`:`${r+1}`;return{currentPage:n,pageCount:o,rangeOnPage:i,pageProgress:`${i} of ${t}`}}}}function Ft(e,t,n,r={},a=!1){var o;const{limit:s,offset:i,setLimit:d,setCurrentPage:c,calculatePagination:u}=Et(n),l=ie({limit:s,offset:i},r),{loading:m,errors:f,data:g,refetch:p}=mt(e,l,a),h=t(g),{currentPage:y,pageCount:v,pageProgress:C}=u((null==h||null==(o=h.data)?void 0:o.length)||0,(null==h?void 0:h.totalCount)||0);return{envelope:h,states:{errors:f,loading:m,limit:s,currentPage:y,pageCount:v,pageProgress:C},callbacks:{refetch:p,setLimit:d,setCurrentPage:c}}}function Pt(e,t){return e===t}function $t(e,t,n){const r=n&&n.equalityFn||Pt,[a,o]=b(e),s=Mt(w(e=>o(e),[]),t,n),i=F(e);return I(()=>{r(i.current,e)||(s.callback(e),i.current=e)},[e,s,r]),[a,{cancel:s.cancel,flush:s.flush}]}function Mt(e,t=0,n={leading:!1}){const r=E(()=>V(e,t,n.leading),[e,t,n.leading]),{flush:a,clear:o}=r;return{flush:a,cancel:o,callback:r}}let Dt;const St=D(Dt||(Dt=(e=>e)`
165
165
  mutation ($eventMeta: UserAnalyticsEvent!) {
166
166
  createUserAnalyticsEvent(eventMeta: $eventMeta)
167
167
  }