@saasquatch/component-boilerplate 1.3.0 → 1.3.1-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 +112 -112
- package/README.md +7 -7
- package/dist/hooks/graphql/Refresh.d.ts +11 -0
- package/dist/hooks/graphql/useBaseQuery.d.ts +1 -1
- package/dist/hooks/useDebounce.d.ts +1 -1
- package/dist/hooks/useDeepEffect.d.ts +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +14 -14
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +59 -59
- package/dist/hooks/graphql/useCustomQuery.d.ts +0 -30
package/dist/index.modern.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProvider as t}from"dom-context";import n from"jwt-decode";import{equal as r}from"@wry/equality";import{parse as a,print as o}from"graphql";import{useReducer as i,useCallback as s,useEffect as d,useRef as u,useState as c,useMemo as l}from"@saasquatch/universal-hooks";import m from"fast-memoize";import{Subject as f}from"rxjs";import{bufferTime as g}from"rxjs/operators";import{nanoid as p}from"nanoid";import{ClientError as h}from"graphql-request/dist/types";import{GraphQLClient as y,gql as w}from"graphql-request";import v from"graphql-combine-query";import{createMemoryHistory as C,createBrowserHistory as b}from"history";import I from"debounce";import F from"jsonpointer";const q={current:void 0};function S(){if(void 0===q.current)throw new Error("no implementation of useHost provided");return q.current()}function E(e){if(!e)throw new Error("Must supply an implementation");if("function"!=typeof e)throw new Error("implementation must be a function");q.current=e}function P(){var e;window.squatchProgramId||(window.squatchProgramId=new t({element:document.documentElement,initialState:(null==(e=window.widgetIdent)?void 0:e.programId)||void 0,contextName:"sq:program-id"}).start())}function M(){P();const t=S();return e(t,"sq:program-id")}function D(e){P(),window.squatchProgramId.context=e}function $(){var e,t;return window.SquatchAndroid?{type:"SquatchAndroid",android:window.SquatchAndroid,widgetIdent:window.widgetIdent}:window.SquatchPortal?{type:"SquatchPortal",env:window.SquatchPortal}:window.SquatchAdmin?{type:"SquatchAdmin",adminSDK:window.SquatchAdmin}:window.widgetIdent&&"demo"!==(null==(e=window.widgetIdent)?void 0:e.env)?{type:"SquatchJS2",api:null==(t=window.frameElement)?void 0:t.squatchJsApi,widgetIdent:window.widgetIdent}:{type:"None"}}function A(){const e=$();return"None"===e.type||"SquatchAdmin"===e.type}function k(){const e=$();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return e.widgetIdent.tenantAlias;case"SquatchAdmin":case"None":return"demo";case"SquatchPortal":return e.env.tenantAlias}}function j(){var e;const t=$();switch(t.type){case"SquatchAndroid":case"SquatchJS2":return t.widgetIdent.appDomain;case"SquatchPortal":return(null==(e=t.env)?void 0:e.appDomain)||"https://app.referralsaasquatch.com";case"SquatchAdmin":case"None":return"https://app.referralsaasquatch.com"}}function x(){const e=$();switch(e.type){case"SquatchJS2":return e.widgetIdent.engagementMedium||"EMBED";case"SquatchAndroid":case"SquatchPortal":case"SquatchAdmin":case"None":return"EMBED"}}function R(){return function(){const e=navigator.language,t=null==e?void 0:e.split("-");return t&&1!==t.length?`${t[0]}_${t[1].toUpperCase()}`:e}()}function V(){return(V=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)}var N=1e3,O=60*N,H=60*O,W=24*H,U=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*n;case"weeks":case"week":case"w":return 6048e5*n;case"days":case"day":case"d":return n*W;case"hours":case"hour":case"hrs":case"hr":case"h":return n*H;case"minutes":case"minute":case"mins":case"min":case"m":return n*O;case"seconds":case"second":case"secs":case"sec":case"s":return n*N;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);return t>=W?J(e,t,W,"day"):t>=H?J(e,t,H,"hour"):t>=O?J(e,t,O,"minute"):t>=N?J(e,t,N,"second"):e+" ms"}(e):function(e){var t=Math.abs(e);return t>=W?Math.round(e/W)+"d":t>=H?Math.round(e/H)+"h":t>=O?Math.round(e/O)+"m":t>=N?Math.round(e/N)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function J(e,t,n,r){var a=t>=1.5*n;return Math.round(e/n)+" "+r+(a?"s":"")}var L,_=(function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,a=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(a=r))}),t.splice(a,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=function(e){function t(e){let r,a=null;function o(...e){if(!o.enabled)return;const n=o,a=Number(new Date);n.diff=a-(r||a),n.prev=r,n.curr=a,r=a,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,a)=>{if("%%"===r)return"%";i++;const o=t.formatters[a];return"function"==typeof o&&(r=o.call(n,e[i]),e.splice(i,1),i--),r}),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=n,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===a?t.enabled(e):a,set:e=>{a=e}}),"function"==typeof t.init&&t.init(o),o}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),a=r.length;for(n=0;n<a;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=U,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(L={exports:{}},L.exports),L.exports);const Q=_("sq:user-identity");function T(){window.squatchUserIdentity||(window.squatchUserIdentity=new t({element:document.documentElement,initialState:G(),contextName:"sq:user-identity"}).start())}function z(e){if(e)try{const t=n(e),r=t.exp;let a,o;if(function(e){return e.sub&&/.*:.*@.*:users/.test(e.sub)}(t)){const e=t.sub.match(/(.*):(.*)@(.*):users/);o=atob(e[1]),a=atob(e[2])}else(function(e){return e.user&&e.user.id&&e.user.accountId})(t)&&(o=t.user.accountId,a=t.user.id);if(!a||!o)return;if(r&&Date.now()>=1e3*r)return;return{id:a,accountId:o,jwt:e}}catch(e){return}}function G(){const e=$();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return{id:e.widgetIdent.userId,accountId:e.widgetIdent.accountId,jwt:e.widgetIdent.token};case"SquatchPortal":const t=new URLSearchParams(document.location.search);if(t.has("jwt"))return z(t.get("jwt"));const n=localStorage.getItem("sq:user-identity");if(!n)return;try{const e=JSON.parse(n),t=z(e.jwt);return t?V({},e,t):void 0}catch(e){return}case"SquatchAdmin":case"None":return}}function B(e){T();const t=window.squatchUserIdentity;r(t.context,e)||(t.context=e),e&&"SquatchPortal"===$().type?localStorage.setItem("sq:user-identity",JSON.stringify(e)):e||(Q("Deleting user from localStorage"),localStorage.removeItem("sq:user-identity"))}function K(){var e;return null==(e=Z())?void 0:e.jwt}function Z(){T();const t=S(),n=e(t,"sq:user-identity"),r=z(null==n?void 0:n.jwt);if(!n||r)return n;B(void 0)}var X=function(){return(X=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)},Y=new Map,ee=new Map,te=!0,ne=!1;function re(e){return e.replace(/[\s,]+/g," ").trim()}function ae(e){var t,n,r,o=re(e);if(!Y.has(o)){var i=a(e,{experimentalFragmentVariables:ne});if(!i||"Document"!==i.kind)throw new Error("Not a valid GraphQL document.");Y.set(o,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=i,n=new Set,r=[],t.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var t=e.name.value,a=re((i=e.loc).source.body.substring(i.start,i.end)),o=ee.get(t);o&&!o.has(a)?te&&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||ee.set(t,o=new Set),o.add(a),n.has(a)||(n.add(a),r.push(e))}else r.push(e);var i}),X(X({},t),{definitions:r}))))}return Y.get(o)}function oe(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]}),ae(r)}var ie,se=oe;(ie=oe||(oe={})).gql=se,ie.resetCaches=function(){Y.clear(),ee.clear()},ie.disableFragmentWarnings=function(){te=!1},ie.enableExperimentalFragmentVariables=function(){ne=!0},ie.disableExperimentalFragmentVariables=function(){ne=!1},oe.default=oe;var de=oe;class ue extends y{constructor(e,t){var n;super(e,t),n=this,this.subject=new f;const r=new f;this.subject.pipe(g(200,void 0,10)).subscribe(async function(e){if(!e.length)return;const{mergedQuery:t,mergedVariables:a,mergedQueryAddedEvents:i,unmergedQueryAddedEvents:s}=fe(e);for(const e of s)r.next(e);if(i.length)try{const e=await n.superRequest(t,a);he(e,i)}catch(e){if(e instanceof h){const{data:t,errors:n}=e.response;if(!t)return we(i,e);const r=Object.keys(t);let a=[...i];for(const t of n){let n;t.path.find((i,s,d)=>{if(r.includes(i)){const u=me(i),c=a.findIndex(e=>e.id===u);if(-1===c)return!1;r.splice(s,1),n=a.splice(c,1)[0];const l=ge(e.response.data,n);d[s]=le(d[s],u);const{query:m,variables:f}=n,g=V({},e.response,{errors:[t],data:l,path:d}),p=new h(g,{query:"string"!=typeof m?o(m):m,variables:f});return ye(n,p),!0}return!1})}he(t,a)}else we(i,e)}}),r.subscribe(async function(e){try{const{query:t,variables:r}=e,a=await n.superRequest(t,r);pe(a,e)}catch(t){ye(e,t)}})}superRequest(e,t){return super.request(e,t)}request(e,t){return new Promise((n,r)=>{const a={query:e,variables:t,id:ce(),resolve:n,reject:r};this.subject.next(a)})}}const ce=()=>p().replace(/[-_]/g,""),le=(e,t)=>e.replace(`_${t}`,""),me=e=>{const t=e.split("_");return t[t.length-1]},fe=e=>{const t=[],n=[],{document:r,variables:i}=e.reduce((e,r)=>{const{query:i,variables:s,id:d}=r;try{const u="string"==typeof i?a(i):i,c=u.definitions.find(e=>"FragmentDefinition"===e.kind),l="string"==typeof i?i:o(i),m=/@/.test(l);if(c||m)return n.push(r),e;const f=e=>((e,t)=>`${e}_${t}`)(e,d);return e=e.addN(u,[s],f,f),t.push(r),e}catch(t){return n.push(r),e}},v("BatchedQuery"));return{mergedQuery:r&&o(r),mergedVariables:i,mergedQueryAddedEvents:t,unmergedQueryAddedEvents:n}},ge=(e,t)=>{if(!e)return e;const n=Object.keys(e),{id:r}=t;return n.reduce((t,n)=>(n.endsWith(r)&&(t=V({},t,{[le(n,r)]:e[n]})),t),{})},pe=(e,t)=>{const{resolve:n}=t;n(e)},he=(e,t)=>{for(const n of t){const t=ge(e,n);n.resolve(t)}},ye=(e,t)=>{const{reject:n}=e;n(t)},we=(e,t)=>{for(const n of e){const{reject:e}=n;e(t)}},ve="sq:graphql-client",Ce=m(function(e,t,n){return new ue(e+"/api/v1/"+t+"/graphql",{headers:{Authorization:`Bearer ${n||""}`}})});function be(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 Ie(t,n){const r=function(){const t=K(),n=j(),r=k(),a=Ce(n,r,t),o=S(),i=e(o,"sq:graphql-client",{attempts:0});return null!=i?i:a}(),[a,o]=i(be,n);return[a,s(async function(e){if(r)try{o({type:"loading"});const n=await r.request(t,e);o({type:"data",payload:n})}catch(e){o({type:"errors",payload:e})}else o({type:"errors",payload:new Error("No GraphQL client found")})},[r,t,o])]}const Fe={loading:!1,data:void 0,errors:void 0};function qe(e){const[t,n]=Ie(e,Fe);return[n,t]}let Se;const Ee=de(Se||(Se=(e=>e)`
|
|
1
|
+
import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProvider as t}from"dom-context";import n from"jwt-decode";import{equal as r}from"@wry/equality";import{parse as a,print as o}from"graphql";import{useReducer as i,useCallback as s,useEffect as u,useMemo as c,useRef as d,useState as l}from"@saasquatch/universal-hooks";import m from"fast-memoize";import{Subject as f}from"rxjs";import{bufferTime as g}from"rxjs/operators";import{nanoid as p}from"nanoid";import{ClientError as h}from"graphql-request/dist/types";import{GraphQLClient as y,gql as v}from"graphql-request";import w from"graphql-combine-query";import{createMemoryHistory as C,createBrowserHistory as b}from"history";import I from"debounce";import F from"jsonpointer";const q={current:void 0};function S(){if(void 0===q.current)throw new Error("no implementation of useHost provided");return q.current()}function E(e){if(!e)throw new Error("Must supply an implementation");if("function"!=typeof e)throw new Error("implementation must be a function");q.current=e}function P(){var e;window.squatchProgramId||(window.squatchProgramId=new t({element:document.documentElement,initialState:(null==(e=window.widgetIdent)?void 0:e.programId)||void 0,contextName:"sq:program-id"}).start())}function M(){P();const t=S();return e(t,"sq:program-id")}function D(e){P(),window.squatchProgramId.context=e}function $(){var e,t;return window.SquatchAndroid?{type:"SquatchAndroid",android:window.SquatchAndroid,widgetIdent:window.widgetIdent}:window.SquatchPortal?{type:"SquatchPortal",env:window.SquatchPortal}:window.SquatchAdmin?{type:"SquatchAdmin",adminSDK:window.SquatchAdmin}:window.widgetIdent&&"demo"!==(null==(e=window.widgetIdent)?void 0:e.env)?{type:"SquatchJS2",api:null==(t=window.frameElement)?void 0:t.squatchJsApi,widgetIdent:window.widgetIdent}:{type:"None"}}function A(){const e=$();return"None"===e.type||"SquatchAdmin"===e.type}function k(){const e=$();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return e.widgetIdent.tenantAlias;case"SquatchAdmin":case"None":return"demo";case"SquatchPortal":return e.env.tenantAlias}}function j(){var e;const t=$();switch(t.type){case"SquatchAndroid":case"SquatchJS2":return t.widgetIdent.appDomain;case"SquatchPortal":return(null==(e=t.env)?void 0:e.appDomain)||"https://app.referralsaasquatch.com";case"SquatchAdmin":case"None":return"https://app.referralsaasquatch.com"}}function x(){const e=$();switch(e.type){case"SquatchJS2":return e.widgetIdent.engagementMedium||"EMBED";case"SquatchAndroid":case"SquatchPortal":case"SquatchAdmin":case"None":return"EMBED"}}function R(){return function(){const e=navigator.language,t=null==e?void 0:e.split("-");return t&&1!==t.length?`${t[0]}_${t[1].toUpperCase()}`:e}()}function V(){return(V=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)}var N=1e3,O=60*N,H=60*O,W=24*H,L=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*n;case"weeks":case"week":case"w":return 6048e5*n;case"days":case"day":case"d":return n*W;case"hours":case"hour":case"hrs":case"hr":case"h":return n*H;case"minutes":case"minute":case"mins":case"min":case"m":return n*O;case"seconds":case"second":case"secs":case"sec":case"s":return n*N;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);return t>=W?U(e,t,W,"day"):t>=H?U(e,t,H,"hour"):t>=O?U(e,t,O,"minute"):t>=N?U(e,t,N,"second"):e+" ms"}(e):function(e){var t=Math.abs(e);return t>=W?Math.round(e/W)+"d":t>=H?Math.round(e/H)+"h":t>=O?Math.round(e/O)+"m":t>=N?Math.round(e/N)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function U(e,t,n,r){var a=t>=1.5*n;return Math.round(e/n)+" "+r+(a?"s":"")}var J,_=(function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,a=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(a=r))}),t.splice(a,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=function(e){function t(e){let r,a=null;function o(...e){if(!o.enabled)return;const n=o,a=Number(new Date);n.diff=a-(r||a),n.prev=r,n.curr=a,r=a,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,a)=>{if("%%"===r)return"%";i++;const o=t.formatters[a];return"function"==typeof o&&(r=o.call(n,e[i]),e.splice(i,1),i--),r}),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=n,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===a?t.enabled(e):a,set:e=>{a=e}}),"function"==typeof t.init&&t.init(o),o}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),a=r.length;for(n=0;n<a;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=L,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(J={exports:{}},J.exports),J.exports);const Q=_("sq:user-identity");function T(){window.squatchUserIdentity||(window.squatchUserIdentity=new t({element:document.documentElement,initialState:G(),contextName:"sq:user-identity"}).start())}function z(e){if(e)try{const t=n(e),r=t.exp;let a,o;if(function(e){return e.sub&&/.*:.*@.*:users/.test(e.sub)}(t)){const e=t.sub.match(/(.*):(.*)@(.*):users/);o=atob(e[1]),a=atob(e[2])}else(function(e){return e.user&&e.user.id&&e.user.accountId})(t)&&(o=t.user.accountId,a=t.user.id);if(!a||!o)return;if(r&&Date.now()>=1e3*r)return;return{id:a,accountId:o,jwt:e}}catch(e){return}}function G(){const e=$();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return{id:e.widgetIdent.userId,accountId:e.widgetIdent.accountId,jwt:e.widgetIdent.token};case"SquatchPortal":const t=new URLSearchParams(document.location.search);if(t.has("jwt"))return z(t.get("jwt"));const n=localStorage.getItem("sq:user-identity");if(!n)return;try{const e=JSON.parse(n),t=z(e.jwt);return t?V({},e,t):void 0}catch(e){return}case"SquatchAdmin":case"None":return}}function B(e){T();const t=window.squatchUserIdentity;r(t.context,e)||(t.context=e),e&&"SquatchPortal"===$().type?localStorage.setItem("sq:user-identity",JSON.stringify(e)):e||(Q("Deleting user from localStorage"),localStorage.removeItem("sq:user-identity"))}function K(){var e;return null==(e=Z())?void 0:e.jwt}function Z(){T();const t=S(),n=e(t,"sq:user-identity"),r=z(null==n?void 0:n.jwt);if(!n||r)return n;B(void 0)}var X=function(){return(X=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)},Y=new Map,ee=new Map,te=!0,ne=!1;function re(e){return e.replace(/[\s,]+/g," ").trim()}function ae(e){var t,n,r,o=re(e);if(!Y.has(o)){var i=a(e,{experimentalFragmentVariables:ne});if(!i||"Document"!==i.kind)throw new Error("Not a valid GraphQL document.");Y.set(o,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=i,n=new Set,r=[],t.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var t=e.name.value,a=re((i=e.loc).source.body.substring(i.start,i.end)),o=ee.get(t);o&&!o.has(a)?te&&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||ee.set(t,o=new Set),o.add(a),n.has(a)||(n.add(a),r.push(e))}else r.push(e);var i}),X(X({},t),{definitions:r}))))}return Y.get(o)}function oe(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]}),ae(r)}var ie,se=oe;(ie=oe||(oe={})).gql=se,ie.resetCaches=function(){Y.clear(),ee.clear()},ie.disableFragmentWarnings=function(){te=!1},ie.enableExperimentalFragmentVariables=function(){ne=!0},ie.disableExperimentalFragmentVariables=function(){ne=!1},oe.default=oe;var ue=oe;class ce extends y{constructor(e,t){var n;super(e,t),n=this,this.subject=new f;const r=new f;this.subject.pipe(g(200,void 0,10)).subscribe(async function(e){if(!e.length)return;const{mergedQuery:t,mergedVariables:a,mergedQueryAddedEvents:i,unmergedQueryAddedEvents:s}=fe(e);for(const e of s)r.next(e);if(i.length)try{const e=await n.superRequest(t,a);he(e,i)}catch(e){if(e instanceof h){const{data:t,errors:n}=e.response;if(!t)return ve(i,e);const r=Object.keys(t);let a=[...i];for(const t of n){let n;t.path.find((i,s,u)=>{if(r.includes(i)){const c=me(i),d=a.findIndex(e=>e.id===c);if(-1===d)return!1;r.splice(s,1),n=a.splice(d,1)[0];const l=ge(e.response.data,n);u[s]=le(u[s],c);const{query:m,variables:f}=n,g=V({},e.response,{errors:[t],data:l,path:u}),p=new h(g,{query:"string"!=typeof m?o(m):m,variables:f});return ye(n,p),!0}return!1})}he(t,a)}else ve(i,e)}}),r.subscribe(async function(e){try{const{query:t,variables:r}=e,a=await n.superRequest(t,r);pe(a,e)}catch(t){ye(e,t)}})}superRequest(e,t){return super.request(e,t)}request(e,t){return new Promise((n,r)=>{const a={query:e,variables:t,id:de(),resolve:n,reject:r};this.subject.next(a)})}}const de=()=>p().replace(/[-_]/g,""),le=(e,t)=>e.replace(`_${t}`,""),me=e=>{const t=e.split("_");return t[t.length-1]},fe=e=>{const t=[],n=[],{document:r,variables:i}=e.reduce((e,r)=>{const{query:i,variables:s,id:u}=r;try{const c="string"==typeof i?a(i):i,d=c.definitions.find(e=>"FragmentDefinition"===e.kind),l="string"==typeof i?i:o(i),m=/@/.test(l);if(d||m)return n.push(r),e;const f=e=>((e,t)=>`${e}_${t}`)(e,u);return e=e.addN(c,[s],f,f),t.push(r),e}catch(t){return n.push(r),e}},w("BatchedQuery"));return{mergedQuery:r&&o(r),mergedVariables:i,mergedQueryAddedEvents:t,unmergedQueryAddedEvents:n}},ge=(e,t)=>{if(!e)return e;const n=Object.keys(e),{id:r}=t;return n.reduce((t,n)=>(n.endsWith(r)&&(t=V({},t,{[le(n,r)]:e[n]})),t),{})},pe=(e,t)=>{const{resolve:n}=t;n(e)},he=(e,t)=>{for(const n of t){const t=ge(e,n);n.resolve(t)}},ye=(e,t)=>{const{reject:n}=e;n(t)},ve=(e,t)=>{for(const n of e){const{reject:e}=n;e(t)}},we="sq:graphql-client",Ce=m(function(e,t,n){return new ce(e+"/api/v1/"+t+"/graphql",{headers:{Authorization:`Bearer ${n||""}`}})});function be(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 Ie(t,n){const r=function(){const t=K(),n=j(),r=k(),a=Ce(n,r,t),o=S(),i=e(o,"sq:graphql-client",{attempts:0});return null!=i?i:a}(),[a,o]=i(be,n);return[a,s(async function(e,n=!1){if(r)try{n||o({type:"loading"});const a=await r.request(t,e);o({type:"data",payload:a})}catch(e){o({type:"errors",payload:e})}else o({type:"errors",payload:new Error("No GraphQL client found")})},[r,t,o])]}const Fe={loading:!1,data:void 0,errors:void 0};function qe(e){const[t,n]=Ie(e,Fe);return[n,t]}let Se;const Ee=ue(Se||(Se=(e=>e)`
|
|
2
2
|
mutation AuthenticateWithEmailAndPassword(
|
|
3
3
|
$email: String!
|
|
4
4
|
$password: String!
|
|
@@ -15,7 +15,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
|
|
|
15
15
|
sessionData
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
`));function Pe(){const[e,{loading:t,data:r,errors:a}]=qe(Ee);return
|
|
18
|
+
`));function Pe(){const[e,{loading:t,data:r,errors:a}]=qe(Ee);return u(()=>{if(null!=r&&r.authenticateManagedIdentityWithEmailAndPassword){const{authenticateManagedIdentityWithEmailAndPassword:e}=r,t=e.token,{user:a}=n(t);B({jwt:t,id:a.id,accountId:a.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==r?void 0:r.authenticateManagedIdentityWithEmailAndPassword]),[e,{loading:t,data:r,errors:a}]}let Me;const De=ue(Me||(Me=(e=>e)`
|
|
19
19
|
mutation RegisterWithEmailAndPassword(
|
|
20
20
|
$email: String!
|
|
21
21
|
$password: String!
|
|
@@ -36,7 +36,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
|
|
|
36
36
|
sessionData
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
`));function $e(){const[e,{loading:t,data:r,errors:a}]=qe(De);return
|
|
39
|
+
`));function $e(){const[e,{loading:t,data:r,errors:a}]=qe(De);return u(()=>{if(null!=r&&r.registerManagedIdentityWithEmailAndPassword){const{registerManagedIdentityWithEmailAndPassword:e}=r,t=e.token,{user:a}=n(t);B({jwt:t,id:a.id,accountId:a.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==r?void 0:r.registerManagedIdentityWithEmailAndPassword]),[e,{loading:t,data:r,errors:a}]}let Ae;const ke=ue(Ae||(Ae=(e=>e)`
|
|
40
40
|
mutation ChangePassword($password: String!) {
|
|
41
41
|
changeManagedIdentityPassword(
|
|
42
42
|
changeManagedIdentityPasswordInput: { password: $password }
|
|
@@ -44,7 +44,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
|
|
|
44
44
|
success
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`));function je(){const[e,{loading:t,data:n,errors:r}]=qe(ke);return[e,{loading:t,data:n,errors:r}]}let xe;const Re=
|
|
47
|
+
`));function je(){const[e,{loading:t,data:n,errors:r}]=qe(ke);return[e,{loading:t,data:n,errors:r}]}let xe;const Re=ue(xe||(xe=(e=>e)`
|
|
48
48
|
mutation ResetPassword($oobCode: String!, $password: String!) {
|
|
49
49
|
resetManagedIdentityPassword(
|
|
50
50
|
resetManagedIdentityPasswordInput: {
|
|
@@ -58,7 +58,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
|
|
|
58
58
|
sessionData
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
`));function Ve(){const[e,{loading:t,data:r,errors:a}]=qe(Re);return
|
|
61
|
+
`));function Ve(){const[e,{loading:t,data:r,errors:a}]=qe(Re);return u(()=>{if(null!=r&&r.resetManagedIdentityPassword){const{resetManagedIdentityPassword:e}=r,t=e.token,{user:a}=n(t);B({jwt:t,id:a.id,accountId:a.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==r?void 0:r.resetManagedIdentityPassword]),[e,{loading:t,data:r,errors:a}]}let Ne;const Oe=ue(Ne||(Ne=(e=>e)`
|
|
62
62
|
mutation VerifyPasswordResetCode($oobCode: String!) {
|
|
63
63
|
verifyManagedIdentityPasswordResetCode(
|
|
64
64
|
verifyManagedIdentityPasswordResetCodeInput: { oobCode: $oobCode }
|
|
@@ -66,7 +66,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
|
|
|
66
66
|
success
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
`));function He(){return qe(Oe)}const
|
|
69
|
+
`));function He(){return qe(Oe)}function We(){const e=S();return{refresh:s(()=>{e.dispatchEvent(new CustomEvent("sq:refresh",{bubbles:!0,composed:!0,cancelable:!0,detail:{}}))},[e])}}function Le({skip:e=!1,update:t,variables:n,query:a}){u(()=>{const r=r=>{!e&&t(n,!0)};return document.addEventListener("sq:refresh",r),()=>document.removeEventListener("sq:refresh",r)},function(e){const t=d(e),n=d(0);return r(e,t.current)||(t.current=e,n.current+=1),c(()=>t.current,[n.current])}([a,n,t,e]))}const Ue={loading:!1,data:void 0,errors:void 0},Je=Symbol();function _e(e){const[t,n]=Ie(e,Ue),r=d(Je);return Le({skip:r.current===Je,update:n,variables:r.current,query:e}),[n,V({},t,{refetch:e=>{r.current=e,n(e)}})]}let Qe;const Te=ue(Qe||(Qe=(e=>e)`
|
|
70
70
|
query ManagedIdentity {
|
|
71
71
|
managedIdentity {
|
|
72
72
|
email
|
|
@@ -74,7 +74,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
|
|
|
74
74
|
sessionData
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
`));function
|
|
77
|
+
`));function ze(){const e=Z(),[t,{loading:n,data:r,errors:a,refetch:o}]=_e(Te);return u(()=>{if(null!=r&&r.managedIdentity){const{managedIdentity:t}=r;B(V({},e,{managedIdentity:t}))}},[null==r?void 0:r.managedIdentity]),[s(()=>t({}),[t]),{loading:n,data:r,errors:a,refetch:o}]}let Ge;const Be=ue(Ge||(Ge=(e=>e)`
|
|
78
78
|
mutation VerifyEmail($oobCode: String!) {
|
|
79
79
|
verifyManagedIdentityEmail(
|
|
80
80
|
verifyManagedIdentityEmailInput: { oobCode: $oobCode }
|
|
@@ -82,7 +82,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
|
|
|
82
82
|
success
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
`));function
|
|
85
|
+
`));function Ke(){var e;const[t]=ze(),[n,{loading:r,data:a,errors:o}]=qe(Be);return u(()=>{var e;null!=a&&null!=(e=a.verifyManagedIdentityEmail)&&e.success&&t()},[null==a||null==(e=a.verifyManagedIdentityEmail)?void 0:e.success]),[n,{loading:r,data:a,errors:o}]}let Ze;const Xe=ue(Ze||(Ze=(e=>e)`
|
|
86
86
|
mutation RequestPasswordResetEmail(
|
|
87
87
|
$email: String!
|
|
88
88
|
$urlParams: RSJsonNode
|
|
@@ -98,7 +98,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
|
|
|
98
98
|
success
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
`));function
|
|
101
|
+
`));function Ye(){return qe(Xe)}let et;const tt=ue(et||(et=(e=>e)`
|
|
102
102
|
mutation RequestVerificationEmail(
|
|
103
103
|
$email: String!
|
|
104
104
|
$urlParams: RSJsonNode
|
|
@@ -114,11 +114,11 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
|
|
|
114
114
|
success
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
`));function
|
|
117
|
+
`));function nt(){return qe(tt)}function rt(e,t){const n=d();return n.current&&r(t,n.current.key)||(n.current={key:t,value:e()}),n.current.value}function at(){return i(e=>e+1,0)}function ot(e){const t=Object.getOwnPropertyNames(e);for(const n of t){const t=e[n];t&&"object"==typeof t&&ot(t)}return Object.freeze(e)}const it={loading:!0,data:void 0,errors:void 0};function st(e,t,n){const[r,a]=Ie(e,it),[o,i]=at();return rt(()=>{!n&&a(t)},[e,t,a,o,n]),Le({skip:n,update:a,variables:t,query:e}),ot(V({},r,{refetch:i}))}function ut(){return window.squatchHistory=window.squatchHistory||function(){switch($().type){case"SquatchPortal":return b();default:return C()}}(),window.squatchHistory}const ct={createHref:(...e)=>ut().createHref(...e),push:(...e)=>ut().push(...e),replace:(...e)=>ut().replace(...e),go:(...e)=>ut().go(...e),back:()=>ut().back(),forward:(...e)=>ut().forward(...e)};function dt(){const[,e]=at();return u(()=>ut().listen(()=>{e()}),[]),ut().location}function lt(e){const[t,n]=l({limit:e.limit,offset:e.offset}),{offset:r,limit:a}=t,o=(e,t)=>e*t,i=(e,t)=>Math.ceil(e/t)||0;return{limit:a,setLimit:e=>{const a=i(r,e),s=o(e,a);n(V({},t,{limit:e,offset:s}))},offset:r,setCurrentPage:e=>{let t=o(e,a);n(e=>V({},e,{offset:t}))},calculatePagination:function(e,t){const n=i(r,a),o=((e,t)=>Math.ceil(e/t)||0)(t,a),s=0===e?"0":e>1?`${r+1}-${r+e}`:`${r+1}`;return{currentPage:n,pageCount:o,rangeOnPage:s,pageProgress:`${s} of ${t}`}}}}function mt(e,t,n,r={},a=!1){var o;const{limit:i,offset:s,setLimit:u,setCurrentPage:c,calculatePagination:d}=lt(n),l=V({limit:i,offset:s},r),{loading:m,errors:f,data:g,refetch:p}=st(e,l,a),h=t(g),{currentPage:y,pageCount:v,pageProgress:w}=d((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:i,currentPage:y,pageCount:v,pageProgress:w},callbacks:{refetch:p,setLimit:u,setCurrentPage:c}}}function ft(e,t){return e===t}function gt(e,t,n){const r=n&&n.equalityFn||ft,[a,o]=l(e),i=pt(s(e=>o(e),[]),t,n),c=d(e);return u(()=>{r(c.current,e)||(i.callback(e),c.current=e)},[e,i,r]),[a,{cancel:i.cancel,flush:i.flush}]}function pt(e,t=0,n={leading:!1}){const r=c(()=>I(e,t,n.leading),[e,t,n.leading]),{flush:a,clear:o}=r;return{flush:a,cancel:o,callback:r}}let ht;const yt=v(ht||(ht=(e=>e)`
|
|
118
118
|
mutation ($eventMeta: UserAnalyticsEvent!) {
|
|
119
119
|
createUserAnalyticsEvent(eventMeta: $eventMeta)
|
|
120
120
|
}
|
|
121
|
-
`));function
|
|
121
|
+
`));function vt(){const e=x(),t=Z(),n=M(),[r]=qe(yt);return t?a=>{r({eventMeta:{id:t.id,accountId:t.accountId,programId:n,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:e,shareMedium:a}}})}:()=>{}}let wt,Ct,bt,It=e=>e;const Ft=_("sq:useForm"),qt=v(wt||(wt=It`
|
|
122
122
|
query ($key: String!) {
|
|
123
123
|
form(key: $key) {
|
|
124
124
|
schema
|
|
@@ -129,7 +129,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
`)),
|
|
132
|
+
`)),St=v(Ct||(Ct=It`
|
|
133
133
|
mutation ($formSubmissionInput: FormSubmissionInput!) {
|
|
134
134
|
submitForm(formSubmissionInput: $formSubmissionInput) {
|
|
135
135
|
success
|
|
@@ -159,7 +159,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
`)),
|
|
162
|
+
`)),Et=v(bt||(bt=It`
|
|
163
163
|
query ($formValidationInput: FormValidationInput!) {
|
|
164
164
|
validateForm(formValidationInput: $formValidationInput) {
|
|
165
165
|
valid
|
|
@@ -189,5 +189,5 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
`));function
|
|
192
|
+
`));function Pt(e){var t,n,r,a;const{formKey:o,formRef:s,autoSubmit:c=!1}=e,[d,{data:l,loading:m}]=_e(qt),[f,g]=qe(St),[p,h]=_e(Et),y={enabled:!1,validating:!1,valid:!0,validationMessage:"",error:"",disabledMessage:"",formData:{},validationData:h,submitData:g},[v,w]=i((e,t)=>V({},e,t),y),{enabled:C,disabledMessage:b,validating:I,valid:q,error:S,formData:E}=v;async function P(e){await p({formValidationInput:{key:o,formData:e}})}return rt(()=>{Ft("submitData useEffect",g),w({submitData:g})},[g]),rt(()=>{Ft("validationData useEffect",h),w({validationData:h})},[h]),u(()=>{!m&&l&&function(){var t,n,r,a,o;w({enabled:null==l||null==(t=l.form.initialData)?void 0:t.isEnabled,disabledMessage:null==l||null==(n=l.form)||null==(r=n.initialData)?void 0:r.isEnabledErrorMessage});const i=s;if(!i)return;const u=null==l||null==(a=l.form)||null==(o=a.initialData)?void 0:o.initialData;void 0!==e.setInitialData?e.setInitialData(i,u):async function(e,t){const n=e.elements,r=new FormData(e);Ft({htmlForm:e,formContent:r}),null==r||r.forEach((e,r)=>{Ft({value:e,key:r,inputs:n});const a=n.namedItem(r);try{"checkbox"==a.type?a.checked=F.get(t,r):a.value=F.get(t,r)||""}catch(e){Ft("no initialData found for key",r)}})}(i,u)}()},[m]),u(()=>{var e,t,n,r,a,i;v.validationData&&(w({validating:!1,valid:(null==(e=v.validationData)||null==(t=e.data)||null==(n=t.validateForm)?void 0:n.valid)||!1}),c&&null!=(r=v.validationData)&&null!=(a=r.data)&&null!=(i=a.validateForm)&&i.valid&&f({formSubmissionInput:{key:o,formData:E}}))},[null==(t=v.validationData)||null==(n=t.data)||null==(r=n.validateForm)?void 0:r.valid]),{states:{enabled:C,disabledMessage:b,loadingForm:m,validating:I,valid:q,error:S,validationData:v.validationData,submitData:v.submitData},data:{formKey:o,schema:null==l||null==(a=l.form)?void 0:a.schema},callbacks:{getForm:d,handleSubmit:async function(e){e.preventDefault(),w({validating:!0});const t=e.target;Ft("submit form",t);const n=new FormData(t);let r={};for(var a of n.entries())F.set(r,a[0],a[1]);w({formData:r}),await P(r)},validateForm:P,submitForm:async function(e){await f({formSubmissionInput:{key:o,formData:e}})},setFormState:w,getValidationErrors:function(){var e,t,n,r;const a=null==h||null==(e=h.data)||null==(t=e.validateForm)||null==(n=t.results[0])||null==(r=n.result)?void 0:r.errors;function o(e){return null==a?void 0:a.filter(t=>t.instanceLocation.substring(1).startsWith(`${e}`))}return{getErrorAtPath:function(e){return null==a?void 0:a.filter(t=>t.instanceLocation.substring(1)===e)},getSubErrorsAtPath:o,hasSubErrors:e=>{var t;return(null==(t=o(e))?void 0:t.length)>0}}},getSubmissionErrors:function(){var e;if(!v.submitData)return[];const t=null==(e=v.submitData.data)?void 0:e.submitForm.results;return(null==t?void 0:t.map(e=>{var t,n,r,a,o,i,s;const u=null==(t=e.result)||null==(n=t.results)?void 0:n.flatMap(e=>!e.success&&e.message).filter(e=>e),c=null==(r=e.result)||null==(a=r.results)?void 0:a.flatMap(e=>!e.success&&{error:e.error,errorType:e.errorType,errorCode:e.errorCode}).filter(({error:e})=>e);return{integration:null==(o=e.formHandler)||null==(i=o.integration)?void 0:i.name,formHandler:null==(s=e.formHandler)?void 0:s.name,messages:u,errors:c}}))||[]}}}}export{ce as BatchedGraphQLClient,we as GRAPHQL_CONTEXT,$ as getEnvironmentSDK,A as isDemo,Ce as memoizedGraphQLClient,ct as navigation,D as setProgramId,E as setUseHostImplementation,B as setUserIdentity,j as useAppDomain,Pe as useAuthenticateWithEmailAndPasswordMutation,je as useChangePasswordMutation,dt as useCurrentPage,gt as useDebounce,pt as useDebouncedCallback,x as useEngagementMedium,Pt as useForm,S as useHost,_e as useLazyQuery,R as useLocale,ze as useManagedIdentityQuery,qe as useMutation,mt as usePaginatedQuery,lt as usePagination,M as useProgramId,st as useQuery,We as useRefreshDispatcher,$e as useRegisterWithEmailAndPasswordMutation,Ye as useRequestPasswordResetEmailMutation,nt as useRequestVerificationEmailMutation,Ve as useResetPasswordMutation,vt as useShareEvent,k as useTenantAlias,at as useTick,K as useToken,Z as useUserIdentity,Ke as useVerifyEmailMutation,He as useVerifyPasswordResetCodeMutation};
|
|
193
193
|
//# sourceMappingURL=index.modern.js.map
|