New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nhost/hasura-storage-js

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nhost/hasura-storage-js - npm Package Compare versions

Comparing version 2.2.5 to 2.2.6

11

package.json
{
"name": "@nhost/hasura-storage-js",
"version": "2.2.5",
"version": "2.2.6",
"description": "Hasura-storage client",

@@ -46,10 +46,11 @@ "license": "MIT",

"form-data": "^4.0.0",
"xstate": "^4.33.5"
"graphql": "16.8.1",
"xstate": "^4.38.3"
},
"devDependencies": {
"@types/uuid": "^9.0.1",
"@types/uuid": "^9.0.7",
"jpeg-js": "^0.4.4",
"pixelmatch": "^5.3.0",
"uuid": "^9.0.0",
"@nhost/docgen": "0.1.11"
"uuid": "^9.0.1",
"@nhost/docgen": "0.1.12"
},

@@ -56,0 +57,0 @@ "scripts": {

@@ -1,3 +0,3 @@

(function(X,ne){typeof exports=="object"&&typeof module!="undefined"?ne(exports):typeof define=="function"&&define.amd?define(["exports"],ne):(X=typeof globalThis!="undefined"?globalThis:X||self,ne(X["@nhost/hasura-storage-js"]={}))})(this,function(X){"use strict";var ne=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function at(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var $e={exports:{}};(function(t,e){(function(r){function n(a){var i=a&&a.Promise||r.Promise,o=a&&a.XMLHttpRequest||r.XMLHttpRequest;return function(){var u=Object.create(r,{fetch:{value:void 0,writable:!0}});return function(f,l){l(e)}(this,function(f){var l=typeof u!="undefined"&&u||typeof self!="undefined"&&self||typeof l!="undefined"&&l,v={searchParams:"URLSearchParams"in l,iterable:"Symbol"in l&&"iterator"in Symbol,blob:"FileReader"in l&&"Blob"in l&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in l,arrayBuffer:"ArrayBuffer"in l};function w(s){return s&&DataView.prototype.isPrototypeOf(s)}if(v.arrayBuffer)var h=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],d=ArrayBuffer.isView||function(s){return s&&h.indexOf(Object.prototype.toString.call(s))>-1};function y(s){if(typeof s!="string"&&(s=String(s)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(s)||s==="")throw new TypeError("Invalid character in header field name");return s.toLowerCase()}function m(s){return typeof s!="string"&&(s=String(s)),s}function E(s){var c={next:function(){var A=s.shift();return{done:A===void 0,value:A}}};return v.iterable&&(c[Symbol.iterator]=function(){return c}),c}function S(s){this.map={},s instanceof S?s.forEach(function(c,A){this.append(A,c)},this):Array.isArray(s)?s.forEach(function(c){this.append(c[0],c[1])},this):s&&Object.getOwnPropertyNames(s).forEach(function(c){this.append(c,s[c])},this)}S.prototype.append=function(s,c){s=y(s),c=m(c);var A=this.map[s];this.map[s]=A?A+", "+c:c},S.prototype.delete=function(s){delete this.map[y(s)]},S.prototype.get=function(s){return s=y(s),this.has(s)?this.map[s]:null},S.prototype.has=function(s){return this.map.hasOwnProperty(y(s))},S.prototype.set=function(s,c){this.map[y(s)]=m(c)},S.prototype.forEach=function(s,c){for(var A in this.map)this.map.hasOwnProperty(A)&&s.call(c,this.map[A],A,this)},S.prototype.keys=function(){var s=[];return this.forEach(function(c,A){s.push(A)}),E(s)},S.prototype.values=function(){var s=[];return this.forEach(function(c){s.push(c)}),E(s)},S.prototype.entries=function(){var s=[];return this.forEach(function(c,A){s.push([A,c])}),E(s)},v.iterable&&(S.prototype[Symbol.iterator]=S.prototype.entries);function g(s){if(s.bodyUsed)return i.reject(new TypeError("Already read"));s.bodyUsed=!0}function x(s){return new i(function(c,A){s.onload=function(){c(s.result)},s.onerror=function(){A(s.error)}})}function F(s){var c=new FileReader,A=x(c);return c.readAsArrayBuffer(s),A}function I(s){var c=new FileReader,A=x(c);return c.readAsText(s),A}function $(s){for(var c=new Uint8Array(s),A=new Array(c.length),U=0;U<c.length;U++)A[U]=String.fromCharCode(c[U]);return A.join("")}function k(s){if(s.slice)return s.slice(0);var c=new Uint8Array(s.byteLength);return c.set(new Uint8Array(s)),c.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(s){this.bodyUsed=this.bodyUsed,this._bodyInit=s,s?typeof s=="string"?this._bodyText=s:v.blob&&Blob.prototype.isPrototypeOf(s)?this._bodyBlob=s:v.formData&&FormData.prototype.isPrototypeOf(s)?this._bodyFormData=s:v.searchParams&&URLSearchParams.prototype.isPrototypeOf(s)?this._bodyText=s.toString():v.arrayBuffer&&v.blob&&w(s)?(this._bodyArrayBuffer=k(s.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):v.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(s)||d(s))?this._bodyArrayBuffer=k(s):this._bodyText=s=Object.prototype.toString.call(s):this._bodyText="",this.headers.get("content-type")||(typeof s=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):v.searchParams&&URLSearchParams.prototype.isPrototypeOf(s)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},v.blob&&(this.blob=function(){var s=g(this);if(s)return s;if(this._bodyBlob)return i.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return i.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return i.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var s=g(this);return s||(ArrayBuffer.isView(this._bodyArrayBuffer)?i.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):i.resolve(this._bodyArrayBuffer))}else return this.blob().then(F)}),this.text=function(){var s=g(this);if(s)return s;if(this._bodyBlob)return I(this._bodyBlob);if(this._bodyArrayBuffer)return i.resolve($(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return i.resolve(this._bodyText)},v.formData&&(this.formData=function(){return this.text().then(J)}),this.json=function(){return this.text().then(JSON.parse)},this}var z=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(s){var c=s.toUpperCase();return z.indexOf(c)>-1?c:s}function D(s,c){if(!(this instanceof D))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');c=c||{};var A=c.body;if(s instanceof D){if(s.bodyUsed)throw new TypeError("Already read");this.url=s.url,this.credentials=s.credentials,c.headers||(this.headers=new S(s.headers)),this.method=s.method,this.mode=s.mode,this.signal=s.signal,!A&&s._bodyInit!=null&&(A=s._bodyInit,s.bodyUsed=!0)}else this.url=String(s);if(this.credentials=c.credentials||this.credentials||"same-origin",(c.headers||!this.headers)&&(this.headers=new S(c.headers)),this.method=b(c.method||this.method||"GET"),this.mode=c.mode||this.mode||null,this.signal=c.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&A)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(A),(this.method==="GET"||this.method==="HEAD")&&(c.cache==="no-store"||c.cache==="no-cache")){var U=/([?&])_=[^&]*/;if(U.test(this.url))this.url=this.url.replace(U,"$1_="+new Date().getTime());else{var T=/\?/;this.url+=(T.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}D.prototype.clone=function(){return new D(this,{body:this._bodyInit})};function J(s){var c=new FormData;return s.trim().split("&").forEach(function(A){if(A){var U=A.split("="),T=U.shift().replace(/\+/g," "),j=U.join("=").replace(/\+/g," ");c.append(decodeURIComponent(T),decodeURIComponent(j))}}),c}function Y(s){var c=new S,A=s.replace(/\r?\n[\t ]+/g," ");return A.split("\r").map(function(U){return U.indexOf(`
`)===0?U.substr(1,U.length):U}).forEach(function(U){var T=U.split(":"),j=T.shift().trim();if(j){var ce=T.join(":").trim();c.append(j,ce)}}),c}B.call(D.prototype);function C(s,c){if(!(this instanceof C))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');c||(c={}),this.type="default",this.status=c.status===void 0?200:c.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in c?c.statusText:"",this.headers=new S(c.headers),this.url=c.url||"",this._initBody(s)}B.call(C.prototype),C.prototype.clone=function(){return new C(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new S(this.headers),url:this.url})},C.error=function(){var s=new C(null,{status:0,statusText:""});return s.type="error",s};var re=[301,302,303,307,308];C.redirect=function(s,c){if(re.indexOf(c)===-1)throw new RangeError("Invalid status code");return new C(null,{status:c,headers:{location:s}})},f.DOMException=l.DOMException;try{new f.DOMException}catch{f.DOMException=function(c,A){this.message=c,this.name=A;var U=Error(c);this.stack=U.stack},f.DOMException.prototype=Object.create(Error.prototype),f.DOMException.prototype.constructor=f.DOMException}function Ee(s,c){return new i(function(A,U){var T=new D(s,c);if(T.signal&&T.signal.aborted)return U(new f.DOMException("Aborted","AbortError"));var j=new o;function ce(){j.abort()}j.onload=function(){var H={status:j.status,statusText:j.statusText,headers:Y(j.getAllResponseHeaders()||"")};H.url="responseURL"in j?j.responseURL:H.headers.get("X-Request-URL");var Ce="response"in j?j.response:j.responseText;setTimeout(function(){A(new C(Ce,H))},0)},j.onerror=function(){setTimeout(function(){U(new TypeError("Network request failed"))},0)},j.ontimeout=function(){setTimeout(function(){U(new TypeError("Network request failed"))},0)},j.onabort=function(){setTimeout(function(){U(new f.DOMException("Aborted","AbortError"))},0)};function q(H){try{return H===""&&l.location.href?l.location.href:H}catch{return H}}j.open(T.method,q(T.url),!0),T.credentials==="include"?j.withCredentials=!0:T.credentials==="omit"&&(j.withCredentials=!1),"responseType"in j&&(v.blob?j.responseType="blob":v.arrayBuffer&&T.headers.get("Content-Type")&&T.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(j.responseType="arraybuffer")),c&&typeof c.headers=="object"&&!(c.headers instanceof S)?Object.getOwnPropertyNames(c.headers).forEach(function(H){j.setRequestHeader(H,m(c.headers[H]))}):T.headers.forEach(function(H,Ce){j.setRequestHeader(Ce,H)}),T.signal&&(T.signal.addEventListener("abort",ce),j.onreadystatechange=function(){j.readyState===4&&T.signal.removeEventListener("abort",ce)}),j.send(typeof T._bodyInit=="undefined"?null:T._bodyInit)})}Ee.polyfill=!0,l.fetch||(l.fetch=Ee,l.Headers=S,l.Request=D,l.Response=C),f.Headers=S,f.Request=D,f.Response=C,f.fetch=Ee,Object.defineProperty(f,"__esModule",{value:!0})}),{fetch:u.fetch,Headers:u.Headers,Request:u.Request,Response:u.Response,DOMException:u.DOMException}}()}t.exports=n})(typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:ne)})($e,$e.exports);var Kt=$e.exports;const ot=at(Kt);var Qt=typeof self=="object"?self.FormData:window.FormData;const He=at(Qt);let st=globalThis.fetch;const ke=async(t,e,{accessToken:r,name:n,fileId:a,bucketId:i,adminSecret:o,onUploadProgress:u,headers:f={}}={})=>{var w;const l={...f};i&&e.append("bucket-id",i),o&&(l["x-hasura-admin-secret"]=o),r&&(l.Authorization=`Bearer ${r}`);const v=`${t}/files`;if(typeof XMLHttpRequest=="undefined")try{e instanceof He&&(st=ot().fetch);const h=await st(v,{method:"POST",headers:l,body:e}),d=await h.json();return h.ok?{fileMetadata:d,error:null}:{error:{status:h.status,message:((w=d==null?void 0:d.error)==null?void 0:w.message)||h.statusText,error:h.statusText},fileMetadata:null}}catch(h){return{error:{status:0,message:h.message,error:h.message},fileMetadata:null}}return new Promise(h=>{let d=new XMLHttpRequest;d.responseType="json",d.onload=()=>{var y,m,E,S,g;return d.status<200||d.status>=300?h({fileMetadata:null,error:{error:(m=(y=d.response)==null?void 0:y.error)!=null?m:d.response,message:(g=(S=(E=d.response)==null?void 0:E.error)==null?void 0:S.message)!=null?g:d.response,status:d.status}}):h({fileMetadata:d.response,error:null})},d.onerror=()=>h({fileMetadata:null,error:{error:d.statusText,message:d.statusText,status:d.status}}),u&&d.upload.addEventListener("progress",u,!1),d.open("POST",v,!0),Object.entries(l).forEach(([y,m])=>{d.setRequestHeader(y,m)}),d.send(e)})};let Ae;typeof Ae=="undefined"&&(Ae=ot().fetch);class ut{constructor({url:e}){this.url=e}async uploadFormData({formData:e,headers:r,bucketId:n}){const{error:a,fileMetadata:i}=await ke(this.url,e,{accessToken:this.accessToken,adminSecret:this.adminSecret,bucketId:n,headers:r});return a?{fileMetadata:null,error:a}:i&&!("processedFiles"in i)?{fileMetadata:{processedFiles:[i]},error:null}:{fileMetadata:i,error:null}}async uploadFile({file:e,bucketId:r,id:n,name:a}){const i=typeof window=="undefined"?new He:new FormData;i.append("file[]",e),i.append("metadata[]",JSON.stringify({id:n,name:a}));const{error:o,fileMetadata:u}=await ke(this.url,i,{accessToken:this.accessToken,adminSecret:this.adminSecret,bucketId:r,fileId:n,name:a});return o?{fileMetadata:null,error:o}:u&&"processedFiles"in u?{fileMetadata:u.processedFiles[0],error:null}:{fileMetadata:u,error:null}}async getPresignedUrl(e){try{const{fileId:r}=e,n=await Ae(`${this.url}/files/${r}/presignedurl`,{method:"GET",headers:this.generateAuthHeaders()});if(!n.ok)throw new Error(await n.text());return{presignedUrl:await n.json(),error:null}}catch(r){return{presignedUrl:null,error:r}}}async delete(e){try{const{fileId:r}=e,n=await Ae(`${this.url}/files/${r}`,{method:"DELETE",headers:this.generateAuthHeaders()});if(!n.ok)throw new Error(await n.text());return{error:null}}catch(r){return{error:r}}}setAccessToken(e){return this.accessToken=e,this}setAdminSecret(e){return this.adminSecret=e,this}generateAuthHeaders(){if(!(!this.adminSecret&&!this.accessToken))return this.adminSecret?{"x-hasura-admin-secret":this.adminSecret}:{Authorization:`Bearer ${this.accessToken}`}}}function qe(t,e){if(!e||Object.keys(e).length===0)return t;const r=new URL(t),n=Object.entries(e).reduce((a,[i,o])=>({...a,[i.charAt(0)]:o}),{});return Object.entries(n).forEach(([a,i])=>{i&&r.searchParams.set(a,i)}),r.toString()}class Zt{constructor({url:e,adminSecret:r}){this.url=e,this.api=new ut({url:e}),this.setAdminSecret(r)}async upload(e){return"file"in e?this.api.uploadFile(e):this.api.uploadFormData(e)}getPublicUrl(e){const{fileId:r,...n}=e;return qe(`${this.url}/files/${r}`,n)}async getPresignedUrl(e){const{fileId:r,...n}=e,{presignedUrl:a,error:i}=await this.api.getPresignedUrl(e);if(i)return{presignedUrl:null,error:i};if(!a)return{presignedUrl:null,error:new Error("Invalid file id")};const o=qe(a.url,n);return{presignedUrl:{...a,url:o},error:null}}async delete(e){const{error:r}=await this.api.delete(e);return r?{error:r}:{error:null}}setAccessToken(e){return this.api.setAccessToken(e),this}setAdminSecret(e){return this.api.setAdminSecret(e),this}}/*! *****************************************************************************
(function(V,ee){typeof exports=="object"&&typeof module!="undefined"?ee(exports):typeof define=="function"&&define.amd?define(["exports"],ee):(V=typeof globalThis!="undefined"?globalThis:V||self,ee(V["@nhost/hasura-storage-js"]={}))})(this,function(V){"use strict";var ee=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ot(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ke={exports:{}};(function(t,e){(function(r){function n(a){var i=a&&a.Promise||r.Promise,o=a&&a.XMLHttpRequest||r.XMLHttpRequest;return function(){var u=Object.create(r,{fetch:{value:void 0,writable:!0}});return function(f,l){l(e)}(this,function(f){var l=typeof u!="undefined"&&u||typeof self!="undefined"&&self||typeof l!="undefined"&&l,p={searchParams:"URLSearchParams"in l,iterable:"Symbol"in l&&"iterator"in Symbol,blob:"FileReader"in l&&"Blob"in l&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in l,arrayBuffer:"ArrayBuffer"in l};function w(s){return s&&DataView.prototype.isPrototypeOf(s)}if(p.arrayBuffer)var d=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(s){return s&&d.indexOf(Object.prototype.toString.call(s))>-1};function m(s){if(typeof s!="string"&&(s=String(s)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(s)||s==="")throw new TypeError("Invalid character in header field name");return s.toLowerCase()}function g(s){return typeof s!="string"&&(s=String(s)),s}function E(s){var c={next:function(){var b=s.shift();return{done:b===void 0,value:b}}};return p.iterable&&(c[Symbol.iterator]=function(){return c}),c}function y(s){this.map={},s instanceof y?s.forEach(function(c,b){this.append(b,c)},this):Array.isArray(s)?s.forEach(function(c){this.append(c[0],c[1])},this):s&&Object.getOwnPropertyNames(s).forEach(function(c){this.append(c,s[c])},this)}y.prototype.append=function(s,c){s=m(s),c=g(c);var b=this.map[s];this.map[s]=b?b+", "+c:c},y.prototype.delete=function(s){delete this.map[m(s)]},y.prototype.get=function(s){return s=m(s),this.has(s)?this.map[s]:null},y.prototype.has=function(s){return this.map.hasOwnProperty(m(s))},y.prototype.set=function(s,c){this.map[m(s)]=g(c)},y.prototype.forEach=function(s,c){for(var b in this.map)this.map.hasOwnProperty(b)&&s.call(c,this.map[b],b,this)},y.prototype.keys=function(){var s=[];return this.forEach(function(c,b){s.push(b)}),E(s)},y.prototype.values=function(){var s=[];return this.forEach(function(c){s.push(c)}),E(s)},y.prototype.entries=function(){var s=[];return this.forEach(function(c,b){s.push([b,c])}),E(s)},p.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);function S(s){if(s.bodyUsed)return i.reject(new TypeError("Already read"));s.bodyUsed=!0}function x(s){return new i(function(c,b){s.onload=function(){c(s.result)},s.onerror=function(){b(s.error)}})}function P(s){var c=new FileReader,b=x(c);return c.readAsArrayBuffer(s),b}function G(s){var c=new FileReader,b=x(c);return c.readAsText(s),b}function F(s){for(var c=new Uint8Array(s),b=new Array(c.length),U=0;U<c.length;U++)b[U]=String.fromCharCode(c[U]);return b.join("")}function H(s){if(s.slice)return s.slice(0);var c=new Uint8Array(s.byteLength);return c.set(new Uint8Array(s)),c.buffer}function C(){return this.bodyUsed=!1,this._initBody=function(s){this.bodyUsed=this.bodyUsed,this._bodyInit=s,s?typeof s=="string"?this._bodyText=s:p.blob&&Blob.prototype.isPrototypeOf(s)?this._bodyBlob=s:p.formData&&FormData.prototype.isPrototypeOf(s)?this._bodyFormData=s:p.searchParams&&URLSearchParams.prototype.isPrototypeOf(s)?this._bodyText=s.toString():p.arrayBuffer&&p.blob&&w(s)?(this._bodyArrayBuffer=H(s.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):p.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(s)||h(s))?this._bodyArrayBuffer=H(s):this._bodyText=s=Object.prototype.toString.call(s):this._bodyText="",this.headers.get("content-type")||(typeof s=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):p.searchParams&&URLSearchParams.prototype.isPrototypeOf(s)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},p.blob&&(this.blob=function(){var s=S(this);if(s)return s;if(this._bodyBlob)return i.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return i.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return i.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var s=S(this);return s||(ArrayBuffer.isView(this._bodyArrayBuffer)?i.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):i.resolve(this._bodyArrayBuffer))}else return this.blob().then(P)}),this.text=function(){var s=S(this);if(s)return s;if(this._bodyBlob)return G(this._bodyBlob);if(this._bodyArrayBuffer)return i.resolve(F(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return i.resolve(this._bodyText)},p.formData&&(this.formData=function(){return this.text().then(N)}),this.json=function(){return this.text().then(JSON.parse)},this}var z=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function k(s){var c=s.toUpperCase();return z.indexOf(c)>-1?c:s}function A(s,c){if(!(this instanceof A))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');c=c||{};var b=c.body;if(s instanceof A){if(s.bodyUsed)throw new TypeError("Already read");this.url=s.url,this.credentials=s.credentials,c.headers||(this.headers=new y(s.headers)),this.method=s.method,this.mode=s.mode,this.signal=s.signal,!b&&s._bodyInit!=null&&(b=s._bodyInit,s.bodyUsed=!0)}else this.url=String(s);if(this.credentials=c.credentials||this.credentials||"same-origin",(c.headers||!this.headers)&&(this.headers=new y(c.headers)),this.method=k(c.method||this.method||"GET"),this.mode=c.mode||this.mode||null,this.signal=c.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&b)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(b),(this.method==="GET"||this.method==="HEAD")&&(c.cache==="no-store"||c.cache==="no-cache")){var U=/([?&])_=[^&]*/;if(U.test(this.url))this.url=this.url.replace(U,"$1_="+new Date().getTime());else{var O=/\?/;this.url+=(O.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}A.prototype.clone=function(){return new A(this,{body:this._bodyInit})};function N(s){var c=new FormData;return s.trim().split("&").forEach(function(b){if(b){var U=b.split("="),O=U.shift().replace(/\+/g," "),D=U.join("=").replace(/\+/g," ");c.append(decodeURIComponent(O),decodeURIComponent(D))}}),c}function q(s){var c=new y,b=s.replace(/\r?\n[\t ]+/g," ");return b.split("\r").map(function(U){return U.indexOf(`
`)===0?U.substr(1,U.length):U}).forEach(function(U){var O=U.split(":"),D=O.shift().trim();if(D){var ce=O.join(":").trim();c.append(D,ce)}}),c}C.call(A.prototype);function B(s,c){if(!(this instanceof B))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');c||(c={}),this.type="default",this.status=c.status===void 0?200:c.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in c?c.statusText:"",this.headers=new y(c.headers),this.url=c.url||"",this._initBody(s)}C.call(B.prototype),B.prototype.clone=function(){return new B(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},B.error=function(){var s=new B(null,{status:0,statusText:""});return s.type="error",s};var ne=[301,302,303,307,308];B.redirect=function(s,c){if(ne.indexOf(c)===-1)throw new RangeError("Invalid status code");return new B(null,{status:c,headers:{location:s}})},f.DOMException=l.DOMException;try{new f.DOMException}catch{f.DOMException=function(c,b){this.message=c,this.name=b;var U=Error(c);this.stack=U.stack},f.DOMException.prototype=Object.create(Error.prototype),f.DOMException.prototype.constructor=f.DOMException}function ie(s,c){return new i(function(b,U){var O=new A(s,c);if(O.signal&&O.signal.aborted)return U(new f.DOMException("Aborted","AbortError"));var D=new o;function ce(){D.abort()}D.onload=function(){var $={status:D.status,statusText:D.statusText,headers:q(D.getAllResponseHeaders()||"")};$.url="responseURL"in D?D.responseURL:$.headers.get("X-Request-URL");var Ce="response"in D?D.response:D.responseText;setTimeout(function(){b(new B(Ce,$))},0)},D.onerror=function(){setTimeout(function(){U(new TypeError("Network request failed"))},0)},D.ontimeout=function(){setTimeout(function(){U(new TypeError("Network request failed"))},0)},D.onabort=function(){setTimeout(function(){U(new f.DOMException("Aborted","AbortError"))},0)};function Y($){try{return $===""&&l.location.href?l.location.href:$}catch{return $}}D.open(O.method,Y(O.url),!0),O.credentials==="include"?D.withCredentials=!0:O.credentials==="omit"&&(D.withCredentials=!1),"responseType"in D&&(p.blob?D.responseType="blob":p.arrayBuffer&&O.headers.get("Content-Type")&&O.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(D.responseType="arraybuffer")),c&&typeof c.headers=="object"&&!(c.headers instanceof y)?Object.getOwnPropertyNames(c.headers).forEach(function($){D.setRequestHeader($,g(c.headers[$]))}):O.headers.forEach(function($,Ce){D.setRequestHeader(Ce,$)}),O.signal&&(O.signal.addEventListener("abort",ce),D.onreadystatechange=function(){D.readyState===4&&O.signal.removeEventListener("abort",ce)}),D.send(typeof O._bodyInit=="undefined"?null:O._bodyInit)})}ie.polyfill=!0,l.fetch||(l.fetch=ie,l.Headers=y,l.Request=A,l.Response=B),f.Headers=y,f.Request=A,f.Response=B,f.fetch=ie,Object.defineProperty(f,"__esModule",{value:!0})}),{fetch:u.fetch,Headers:u.Headers,Request:u.Request,Response:u.Response,DOMException:u.DOMException}}()}t.exports=n})(typeof globalThis!="undefined"?globalThis:typeof self!="undefined"?self:ee)})(ke,ke.exports);var Qt=ke.exports;const st=ot(Qt);var Zt=typeof self=="object"?self.FormData:window.FormData;const $e=ot(Zt);let ut=globalThis.fetch;const He=async(t,e,{accessToken:r,name:n,fileId:a,bucketId:i,adminSecret:o,onUploadProgress:u,headers:f={}}={})=>{var w;const l={...f};i&&e.append("bucket-id",i),o&&(l["x-hasura-admin-secret"]=o),r&&(l.Authorization=`Bearer ${r}`);const p=`${t}/files`;if(typeof XMLHttpRequest=="undefined")try{e instanceof $e&&(ut=st().fetch);const d=await ut(p,{method:"POST",headers:l,body:e}),h=await d.json();return d.ok?{fileMetadata:h,error:null}:{error:{status:d.status,message:((w=h==null?void 0:h.error)==null?void 0:w.message)||d.statusText,error:d.statusText},fileMetadata:null}}catch(d){return{error:{status:0,message:d.message,error:d.message},fileMetadata:null}}return new Promise(d=>{let h=new XMLHttpRequest;h.responseType="json",h.onload=()=>{var m,g,E,y,S;return h.status<200||h.status>=300?d({fileMetadata:null,error:{error:(g=(m=h.response)==null?void 0:m.error)!=null?g:h.response,message:(S=(y=(E=h.response)==null?void 0:E.error)==null?void 0:y.message)!=null?S:h.response,status:h.status}}):d({fileMetadata:h.response,error:null})},h.onerror=()=>d({fileMetadata:null,error:{error:h.statusText,message:h.statusText,status:h.status}}),u&&h.upload.addEventListener("progress",u,!1),h.open("POST",p,!0),Object.entries(l).forEach(([m,g])=>{h.setRequestHeader(m,g)}),h.send(e)})};let Ee;typeof Ee=="undefined"&&(Ee=st().fetch);class ft{constructor({url:e}){this.url=e}async uploadFormData({formData:e,headers:r,bucketId:n}){const{error:a,fileMetadata:i}=await He(this.url,e,{accessToken:this.accessToken,adminSecret:this.adminSecret,bucketId:n,headers:r});return a?{fileMetadata:null,error:a}:i&&!("processedFiles"in i)?{fileMetadata:{processedFiles:[i]},error:null}:{fileMetadata:i,error:null}}async uploadFile({file:e,bucketId:r,id:n,name:a}){const i=typeof window=="undefined"?new $e:new FormData;i.append("file[]",e),i.append("metadata[]",JSON.stringify({id:n,name:a}));const{error:o,fileMetadata:u}=await He(this.url,i,{accessToken:this.accessToken,adminSecret:this.adminSecret,bucketId:r,fileId:n,name:a});return o?{fileMetadata:null,error:o}:u&&"processedFiles"in u?{fileMetadata:u.processedFiles[0],error:null}:{fileMetadata:u,error:null}}async getPresignedUrl(e){try{const{fileId:r}=e,n=await Ee(`${this.url}/files/${r}/presignedurl`,{method:"GET",headers:this.generateAuthHeaders()});if(!n.ok)throw new Error(await n.text());return{presignedUrl:await n.json(),error:null}}catch(r){return{presignedUrl:null,error:r}}}async delete(e){try{const{fileId:r}=e,n=await Ee(`${this.url}/files/${r}`,{method:"DELETE",headers:this.generateAuthHeaders()});if(!n.ok)throw new Error(await n.text());return{error:null}}catch(r){return{error:r}}}setAccessToken(e){return this.accessToken=e,this}setAdminSecret(e){return this.adminSecret=e,this}generateAuthHeaders(){if(!(!this.adminSecret&&!this.accessToken))return this.adminSecret?{"x-hasura-admin-secret":this.adminSecret}:{Authorization:`Bearer ${this.accessToken}`}}}function qe(t,e){if(!e||Object.keys(e).length===0)return t;const r=new URL(t),n=Object.entries(e).reduce((a,[i,o])=>({...a,[i.charAt(0)]:o}),{});return Object.entries(n).forEach(([a,i])=>{i&&r.searchParams.set(a,i)}),r.toString()}class er{constructor({url:e,adminSecret:r}){this.url=e,this.api=new ft({url:e}),this.setAdminSecret(r)}async upload(e){return"file"in e?this.api.uploadFile(e):this.api.uploadFormData(e)}getPublicUrl(e){const{fileId:r,...n}=e;return qe(`${this.url}/files/${r}`,n)}async getPresignedUrl(e){const{fileId:r,...n}=e,{presignedUrl:a,error:i}=await this.api.getPresignedUrl(e);if(i)return{presignedUrl:null,error:i};if(!a)return{presignedUrl:null,error:new Error("Invalid file id")};const o=qe(a.url,n);return{presignedUrl:{...a,url:o},error:null}}async delete(e){const{error:r}=await this.api.delete(e);return r?{error:r}:{error:null}}setAccessToken(e){return this.api.setAccessToken(e),this}setAdminSecret(e){return this.api.setAdminSecret(e),this}}/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

@@ -15,5 +15,5 @@

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var p=function(){return p=Object.assign||function(e){for(var r,n=1,a=arguments.length;n<a;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},p.apply(this,arguments)};function Ge(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a<n.length;a++)e.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(t,n[a])&&(r[n[a]]=t[n[a]]);return r}function L(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function O(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),a,i=[],o;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)i.push(a.value)}catch(u){o={error:u}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i}function N(t,e,r){if(r||arguments.length===2)for(var n=0,a=e.length,i;n<a;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}var R;(function(t){t.Start="xstate.start",t.Stop="xstate.stop",t.Raise="xstate.raise",t.Send="xstate.send",t.Cancel="xstate.cancel",t.NullEvent="",t.Assign="xstate.assign",t.After="xstate.after",t.DoneState="done.state",t.DoneInvoke="done.invoke",t.Log="xstate.log",t.Init="xstate.init",t.Invoke="xstate.invoke",t.ErrorExecution="error.execution",t.ErrorCommunication="error.communication",t.ErrorPlatform="error.platform",t.ErrorCustom="xstate.error",t.Update="xstate.update",t.Pure="xstate.pure",t.Choose="xstate.choose"})(R||(R={}));var Q;(function(t){t.Parent="#_parent",t.Internal="#_internal"})(Q||(Q={}));var ze=R.Start,Xe=R.Stop,ae=R.Raise,de=R.Send,ft=R.Cancel,lt=R.NullEvent,xe=R.Assign,er=R.After,tr=R.DoneState,Ve=R.Log,ct=R.Init,Oe=R.Invoke,rr=R.ErrorExecution,nr=R.ErrorPlatform,dt=R.ErrorCustom,Je=R.Update,ht=R.Choose,pt=R.Pure;const ir=Object.freeze(Object.defineProperty({__proto__:null,after:er,assign:xe,cancel:ft,choose:ht,doneState:tr,error:dt,errorExecution:rr,errorPlatform:nr,init:ct,invoke:Oe,log:Ve,nullEvent:lt,pure:pt,raise:ae,send:de,start:ze,stop:Xe,update:Je},Symbol.toStringTag,{value:"Module"}));var vt=".",yt={},Ye="xstate.guard",ar="",V=process.env.NODE_ENV==="production",Te;function We(t,e,r){r===void 0&&(r=vt);var n=he(t,r),a=he(e,r);return P(a)?P(n)?a===n:!1:P(n)?n in a:Object.keys(n).every(function(i){return i in a?We(n[i],a[i]):!1})}function gt(t){try{return P(t)||typeof t=="number"?"".concat(t):t.type}catch{throw new Error("Events must be strings or objects with a string event.type property.")}}function Ke(t,e){try{return ve(t)?t:t.toString().split(e)}catch{throw new Error("'".concat(t,"' is not a valid state path."))}}function or(t){return typeof t=="object"&&"value"in t&&"context"in t&&"event"in t&&"_event"in t}function he(t,e){if(or(t))return t.value;if(ve(t))return Pe(t);if(typeof t!="string")return t;var r=Ke(t,e);return Pe(r)}function Pe(t){if(t.length===1)return t[0];for(var e={},r=e,n=0;n<t.length-1;n++)n===t.length-2?r[t[n]]=t[n+1]:(r[t[n]]={},r=r[t[n]]);return e}function pe(t,e){for(var r={},n=Object.keys(t),a=0;a<n.length;a++){var i=n[a];r[i]=e(t[i],i,t,a)}return r}function mt(t,e,r){var n,a,i={};try{for(var o=L(Object.keys(t)),u=o.next();!u.done;u=o.next()){var f=u.value,l=t[f];r(l)&&(i[f]=e(l,f,t))}}catch(v){n={error:v}}finally{try{u&&!u.done&&(a=o.return)&&a.call(o)}finally{if(n)throw n.error}}return i}var sr=function(t){return function(e){var r,n,a=e;try{for(var i=L(t),o=i.next();!o.done;o=i.next()){var u=o.value;a=a[u]}}catch(f){r={error:f}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return a}};function ur(t,e){return function(r){var n,a,i=r;try{for(var o=L(t),u=o.next();!u.done;u=o.next()){var f=u.value;i=i[e][f]}}catch(l){n={error:l}}finally{try{u&&!u.done&&(a=o.return)&&a.call(o)}finally{if(n)throw n.error}}return i}}function De(t){if(!t)return[[]];if(P(t))return[[t]];var e=M(Object.keys(t).map(function(r){var n=t[r];return typeof n!="string"&&(!n||!Object.keys(n).length)?[[r]]:De(t[r]).map(function(a){return[r].concat(a)})}));return e}function M(t){var e;return(e=[]).concat.apply(e,N([],O(t),!1))}function wt(t){return ve(t)?t:[t]}function W(t){return t===void 0?[]:wt(t)}function St(t,e,r){var n,a;if(_(t))return t(e,r.data);var i={};try{for(var o=L(Object.keys(t)),u=o.next();!u.done;u=o.next()){var f=u.value,l=t[f];_(l)?i[f]=l(e,r.data):i[f]=l}}catch(v){n={error:v}}finally{try{u&&!u.done&&(a=o.return)&&a.call(o)}finally{if(n)throw n.error}}return i}function fr(t){return/^(done|error)\./.test(t)}function lr(t,e){var r,n,a=O([[],[]],2),i=a[0],o=a[1];try{for(var u=L(t),f=u.next();!f.done;f=u.next()){var l=f.value;e(l)?i.push(l):o.push(l)}}catch(v){r={error:v}}finally{try{f&&!f.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}return[i,o]}function bt(t,e){return pe(t.states,function(r,n){if(r){var a=(P(e)?void 0:e[n])||(r?r.current:void 0);if(a)return{current:a,states:bt(r,a)}}})}function cr(t,e){return{current:e,states:bt(t,e)}}function Et(t,e,r,n){V||K(!!t,"Attempting to update undefined context");var a=t&&r.reduce(function(i,o){var u,f,l=o.assignment,v={state:n,action:o,_event:e},w={};if(_(l))w=l(i,e.data,v);else try{for(var h=L(Object.keys(l)),d=h.next();!d.done;d=h.next()){var y=d.value,m=l[y];w[y]=_(m)?m(i,e.data,v):m}}catch(E){u={error:E}}finally{try{d&&!d.done&&(f=h.return)&&f.call(h)}finally{if(u)throw u.error}}return Object.assign({},i,w)},t);return a}var K=function(){};V||(K=function(t,e){var r=t instanceof Error?t:void 0;if(!(!r&&t)&&console!==void 0){var n=["Warning: ".concat(e)];r&&n.push(r),console.warn.apply(console,n)}});function ve(t){return Array.isArray(t)}function _(t){return typeof t=="function"}function P(t){return typeof t=="string"}function At(t,e){if(t)return P(t)?{type:Ye,name:t,predicate:e?e[t]:void 0}:_(t)?{type:Ye,name:t.name,predicate:t}:t}var xt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();Te={},Te[xt]=function(){return this},Te[Symbol.observable]=function(){return this};function ie(t){return!!t&&"__xstatenode"in t}var dr=function(){var t=0;return function(){return t++,t.toString(16)}}();function Ot(t,e){return P(t)||typeof t=="number"?p({type:t},e):t}function ye(t,e){if(!P(t)&&"$$type"in t&&t.$$type==="scxml")return t;var r=Ot(t);return p({name:r.type,data:r,$$type:"scxml",type:"external"},e)}function oe(t,e){var r=wt(e).map(function(n){return typeof n=="undefined"||typeof n=="string"||ie(n)?{target:n,event:t}:p(p({},n),{event:t})});return r}function hr(t){if(!(t===void 0||t===ar))return W(t)}function Tt(t,e,r,n,a){var i=t.options.guards,o={state:a,cond:e,_event:n};if(e.type===Ye)return((i==null?void 0:i[e.name])||e.predicate)(r,n.data,o);var u=i==null?void 0:i[e.type];if(!u)throw new Error("Guard '".concat(e.type,"' is not implemented on machine '").concat(t.id,"'."));return u(r,n.data,o)}function pr(t){return typeof t=="string"?{type:t}:t}function je(t,e){return"".concat(t,":invocation[").concat(e,"]")}var Re=ye({type:ct});function Qe(t,e){return e&&e[t]||void 0}function se(t,e){var r;if(P(t)||typeof t=="number"){var n=Qe(t,e);_(n)?r={type:t,exec:n}:n?r=n:r={type:t,exec:void 0}}else if(_(t))r={type:t.name||t.toString(),exec:t};else{var n=Qe(t.type,e);if(_(n))r=p(p({},t),{exec:n});else if(n){var a=n.type||t.type;r=p(p(p({},n),t),{type:a})}else r=t}return r}var Z=function(t,e){if(!t)return[];var r=ve(t)?t:[t];return r.map(function(n){return se(n,e)})};function Ue(t){var e=se(t);return p(p({id:P(t)?t:e.id},e),{type:e.type})}function Pt(t){return P(t)?{type:ae,event:t}:ee(t,{to:Q.Internal})}function Dt(t){return{type:ae,_event:ye(t.event)}}function ee(t,e){return{to:e?e.to:void 0,type:de,event:_(t)?t:Ot(t),delay:e?e.delay:void 0,id:e&&e.id!==void 0?e.id:_(t)?t.name:gt(t)}}function jt(t,e,r,n){var a={_event:r},i=ye(_(t.event)?t.event(e,r.data,a):t.event),o;if(P(t.delay)){var u=n&&n[t.delay];o=_(u)?u(e,r.data,a):u}else o=_(t.delay)?t.delay(e,r.data,a):t.delay;var f=_(t.to)?t.to(e,r.data,a):t.to;return p(p({},t),{to:f,_event:i,event:i.data,delay:o})}function Ze(t,e){return ee(t,p(p({},e),{to:Q.Parent}))}function vr(t,e,r){return ee(e,p(p({},r),{to:t}))}function yr(){return Ze(Je)}function gr(t,e){return ee(t,p(p({},e),{to:function(r,n,a){var i=a._event;return i.origin}}))}var mr=function(t,e){return{context:t,event:e}};function wr(t,e){return t===void 0&&(t=mr),{type:Ve,label:e,expr:t}}var Rt=function(t,e,r){return p(p({},t),{value:P(t.expr)?t.expr:t.expr(e,r.data,{_event:r})})},Ut=function(t){return{type:ft,sendId:t}};function Nt(t){var e=Ue(t);return{type:R.Start,activity:e,exec:void 0}}function It(t){var e=_(t)?t:Ue(t);return{type:R.Stop,activity:e,exec:void 0}}function Lt(t,e,r){var n=_(t.activity)?t.activity(e,r.data):t.activity,a=typeof n=="string"?{id:n}:n,i={type:R.Stop,activity:a};return i}var Ft=function(t){return{type:xe,assignment:t}};function Sr(t){return typeof t=="object"&&"type"in t}function Mt(t,e){var r=e?"#".concat(e):"";return"".concat(R.After,"(").concat(t,")").concat(r)}function ge(t,e){var r="".concat(R.DoneState,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function _t(t,e){var r="".concat(R.DoneInvoke,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Bt(t,e){var r="".concat(R.ErrorPlatform,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function br(t){return{type:R.Pure,get:t}}function Er(t,e){if(!V&&(!t||typeof t=="function")){var r=t;t=function(){for(var n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];var i=typeof r=="function"?r.apply(void 0,N([],O(n),!1)):r;if(!i)throw new Error("Attempted to forward event to undefined actor. This risks an infinite loop in the sender.");return i}}return ee(function(n,a){return a},p(p({},e),{to:t}))}function Ar(t,e){return Ze(function(r,n,a){return{type:dt,data:_(t)?t(r,n,a):t}},p(p({},e),{to:Q.Parent}))}function xr(t){return{type:R.Choose,conds:t}}var Or=function(t){var e,r,n=[];try{for(var a=L(t),i=a.next();!i.done;i=a.next())for(var o=i.value,u=0;u<o.length;){if(o[u].type===xe){n.push(o[u]),o.splice(u,1);continue}u++}}catch(f){e={error:f}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return n};function Ne(t,e,r,n,a,i,o){o===void 0&&(o=!1);var u=o?[]:Or(a),f=u.length?Et(r,n,u,e):r,l=o?[r]:void 0,v=[];function w(y){var m;switch(y.type){case ae:return Dt(y);case de:var E=jt(y,f,n,t.options.delays);return V||K(!P(y.delay)||typeof E.delay=="number","No delay reference for delay expression '".concat(y.delay,"' was found on machine '").concat(t.id,"'")),i&&E.to!==Q.Internal&&v.push(E),E;case Ve:{var S=Rt(y,f,n);return i==null||i(S,f,n),S}case ht:{var g=y,x=(m=g.conds.find(function(Y){var C=At(Y.cond,t.options.guards);return!C||Tt(t,C,f,n,i?void 0:e)}))===null||m===void 0?void 0:m.actions;if(!x)return[];var F=O(Ne(t,e,f,n,[Z(W(x),t.options.actions)],i,o),2),I=F[0],$=F[1];return f=$,l==null||l.push(f),I}case pt:{var x=y.get(f,n.data);if(!x)return[];var k=O(Ne(t,e,f,n,[Z(W(x),t.options.actions)],i,o),2),B=k[0],z=k[1];return f=z,l==null||l.push(f),B}case Xe:{var S=Lt(y,f,n);return i==null||i(S,r,n),S}case xe:{f=Et(f,n,[y],i?void 0:e),l==null||l.push(f);break}default:var b=se(y,t.options.actions),D=b.exec;if(i)i(b,f,n);else if(D&&l){var J=l.length-1;b=p(p({},b),{exec:function(Y){for(var C=[],re=1;re<arguments.length;re++)C[re-1]=arguments[re];D.apply(void 0,N([l[J]],O(C),!1))}})}return b}}function h(y){var m,E,S=[];try{for(var g=L(y),x=g.next();!x.done;x=g.next()){var F=x.value,I=w(F);I&&(S=S.concat(I))}}catch($){m={error:$}}finally{try{x&&!x.done&&(E=g.return)&&E.call(g)}finally{if(m)throw m.error}}return v.forEach(function($){i($,f,n)}),v.length=0,S}var d=M(a.map(h));return[d,f]}const Tr=Object.freeze(Object.defineProperty({__proto__:null,actionTypes:ir,after:Mt,assign:Ft,cancel:Ut,choose:xr,done:ge,doneInvoke:_t,error:Bt,escalate:Ar,forwardTo:Er,getActionFunction:Qe,initEvent:Re,isActionObject:Sr,log:wr,pure:br,raise:Pt,resolveActions:Ne,resolveLog:Rt,resolveRaise:Dt,resolveSend:jt,resolveStop:Lt,respond:gr,send:ee,sendParent:Ze,sendTo:vr,sendUpdate:yr,start:Nt,stop:It,toActionObject:se,toActionObjects:Z,toActivityDefinition:Ue},Symbol.toStringTag,{value:"Module"}));var Ie=[],Pr=function(t,e){Ie.push(t);var r=e(t);return Ie.pop(),r},Dr=function(t){return t(Ie[Ie.length-1])};function Ct(t){var e;return e={id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},getSnapshot:function(){},toJSON:function(){return{id:t}}},e[xt]=function(){return this},e}function jr(t,e,r,n){var a,i=pr(t.src),o=(a=e==null?void 0:e.options.services)===null||a===void 0?void 0:a[i.type],u=t.data?St(t.data,r,n):void 0,f=o?$t(o,t.id,u):Ct(t.id);return f.meta=t,f}function $t(t,e,r){var n=Ct(e);if(n.deferred=!0,ie(t)){var a=n.state=Pr(void 0,function(){return(r?t.withContext(r):t).initialState});n.getSnapshot=function(){return a}}return n}var Le=function(t){return t.type==="atomic"||t.type==="final"};function Ht(t){return Object.keys(t.states).map(function(e){return t.states[e]})}function me(t){return Ht(t).filter(function(e){return e.type!=="history"})}function kt(t){var e=[t];return Le(t)?e:e.concat(M(me(t).map(kt)))}function we(t,e){var r,n,a,i,o,u,f,l,v=new Set(t),w=et(v),h=new Set(e);try{for(var d=L(h),y=d.next();!y.done;y=d.next())for(var m=y.value,E=m.parent;E&&!h.has(E);)h.add(E),E=E.parent}catch(z){r={error:z}}finally{try{y&&!y.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}var S=et(h);try{for(var g=L(h),x=g.next();!x.done;x=g.next()){var m=x.value;if(m.type==="compound"&&(!S.get(m)||!S.get(m).length))w.get(m)?w.get(m).forEach(function(b){return h.add(b)}):m.initialStateNodes.forEach(function(b){return h.add(b)});else if(m.type==="parallel")try{for(var F=(o=void 0,L(me(m))),I=F.next();!I.done;I=F.next()){var $=I.value;h.has($)||(h.add($),w.get($)?w.get($).forEach(function(b){return h.add(b)}):$.initialStateNodes.forEach(function(b){return h.add(b)}))}}catch(b){o={error:b}}finally{try{I&&!I.done&&(u=F.return)&&u.call(F)}finally{if(o)throw o.error}}}}catch(z){a={error:z}}finally{try{x&&!x.done&&(i=g.return)&&i.call(g)}finally{if(a)throw a.error}}try{for(var k=L(h),B=k.next();!B.done;B=k.next())for(var m=B.value,E=m.parent;E&&!h.has(E);)h.add(E),E=E.parent}catch(z){f={error:z}}finally{try{B&&!B.done&&(l=k.return)&&l.call(k)}finally{if(f)throw f.error}}return h}function qt(t,e){var r=e.get(t);if(!r)return{};if(t.type==="compound"){var n=r[0];if(n){if(Le(n))return n.key}else return{}}var a={};return r.forEach(function(i){a[i.key]=qt(i,e)}),a}function et(t){var e,r,n=new Map;try{for(var a=L(t),i=a.next();!i.done;i=a.next()){var o=i.value;n.has(o)||n.set(o,[]),o.parent&&(n.has(o.parent)||n.set(o.parent,[]),n.get(o.parent).push(o))}}catch(u){e={error:u}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return n}function Rr(t,e){var r=we([t],e);return qt(t,et(r))}function Se(t,e){return Array.isArray(t)?t.some(function(r){return r===e}):t instanceof Set?t.has(e):!1}function Ur(t){return N([],O(new Set(M(N([],O(t.map(function(e){return e.ownEvents})),!1)))),!1)}function Fe(t,e){return e.type==="compound"?me(e).some(function(r){return r.type==="final"&&Se(t,r)}):e.type==="parallel"?me(e).every(function(r){return Fe(t,r)}):!1}function Nr(t){return t===void 0&&(t=[]),t.reduce(function(e,r){return r.meta!==void 0&&(e[r.id]=r.meta),e},{})}function Gt(t){return new Set(M(t.map(function(e){return e.tags})))}function zt(t,e){if(t===e)return!0;if(t===void 0||e===void 0)return!1;if(P(t)||P(e))return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(function(a){return zt(t[a],e[a])})}var te=function(){function t(e){var r=this,n;this.actions=[],this.activities=yt,this.meta={},this.events=[],this.value=e.value,this.context=e.context,this._event=e._event,this._sessionid=e._sessionid,this.event=this._event.data,this.historyValue=e.historyValue,this.history=e.history,this.actions=e.actions||[],this.activities=e.activities||yt,this.meta=Nr(e.configuration),this.events=e.events||[],this.matches=this.matches.bind(this),this.toStrings=this.toStrings.bind(this),this.configuration=e.configuration,this.transitions=e.transitions,this.children=e.children,this.done=!!e.done,this.tags=(n=Array.isArray(e.tags)?new Set(e.tags):e.tags)!==null&&n!==void 0?n:new Set,this.machine=e.machine,Object.defineProperty(this,"nextEvents",{get:function(){return Ur(r.configuration)}})}return t.from=function(e,r){if(e instanceof t)return e.context!==r?new t({value:e.value,context:r,_event:e._event,_sessionid:null,historyValue:e.historyValue,history:e.history,actions:[],activities:e.activities,meta:{},events:[],configuration:[],transitions:[],children:{}}):e;var n=Re;return new t({value:e,context:r,_event:n,_sessionid:null,historyValue:void 0,history:void 0,actions:[],activities:void 0,meta:void 0,events:[],configuration:[],transitions:[],children:{}})},t.create=function(e){return new t(e)},t.inert=function(e,r){if(e instanceof t){if(!e.actions.length)return e;var n=Re;return new t({value:e.value,context:r,_event:n,_sessionid:null,historyValue:e.historyValue,history:e.history,activities:e.activities,configuration:e.configuration,transitions:[],children:{}})}return t.from(e,r)},t.prototype.toStrings=function(e,r){var n=this;if(e===void 0&&(e=this.value),r===void 0&&(r="."),P(e))return[e];var a=Object.keys(e);return a.concat.apply(a,N([],O(a.map(function(i){return n.toStrings(e[i],r).map(function(o){return i+r+o})})),!1))},t.prototype.toJSON=function(){var e=this;e.configuration,e.transitions;var r=e.tags;e.machine;var n=Ge(e,["configuration","transitions","tags","machine"]);return p(p({},n),{tags:Array.from(r)})},t.prototype.matches=function(e){return We(e,this.value)},t.prototype.hasTag=function(e){return this.tags.has(e)},t.prototype.can=function(e){var r;V&&K(!!this.machine,"state.can(...) used outside of a machine-created State object; this will always return false.");var n=(r=this.machine)===null||r===void 0?void 0:r.getTransitionData(this,e);return!!(n!=null&&n.transitions.length)&&n.transitions.some(function(a){return a.target!==void 0||a.actions.length})},t}(),Xt={sync:!1,autoForward:!1},Vt;(function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped"})(Vt||(Vt={}));var Ir=function(t){return P(t)?p(p({},Xt),{name:t}):p(p(p({},Xt),{name:dr()}),t)};function Lr(t,e){var r=Ir(e);return Dr(function(n){if(!V){var a=ie(t)||_(t);K(!!n||a,'Attempted to spawn an Actor (ID: "'.concat(ie(t)?t.id:"undefined",'") outside of a service. This will have no effect.'))}return n?n.spawn(t,r.name,r):$t(t,r.name)})}function Fr(t){if(typeof t=="string"){var e={type:t};return e.toString=function(){return t},e}return t}function Me(t){return p(p({type:Oe},t),{toJSON:function(){t.onDone,t.onError;var e=Ge(t,["onDone","onError"]);return p(p({},e),{type:Oe,src:Fr(t.src)})}})}var ue="",tt="#",be="*",fe={},le=function(t){return t[0]===tt},Mr=function(){return{actions:{},guards:{},services:{},activities:{},delays:{}}},_r=function(t,e,r){var n=r.slice(0,-1).some(function(i){return!("cond"in i)&&!("in"in i)&&(P(i.target)||ie(i.target))}),a=e===ue?"the transient event":"event '".concat(e,"'");K(!n,"One or more transitions for ".concat(a," on state '").concat(t.id,"' are unreachable. ")+"Make sure that the default transition is the last one defined.")},Br=function(){function t(e,r,n,a){n===void 0&&(n="context"in e?e.context:void 0);var i=this,o;this.config=e,this._context=n,this.order=-1,this.__xstatenode=!0,this.__cache={events:void 0,relativeValue:new Map,initialStateValue:void 0,initialState:void 0,on:void 0,transitions:void 0,candidates:{},delayedTransitions:void 0},this.idMap={},this.tags=[],this.options=Object.assign(Mr(),r),this.parent=a==null?void 0:a.parent,this.key=this.config.key||(a==null?void 0:a.key)||this.config.id||"(machine)",this.machine=this.parent?this.parent.machine:this,this.path=this.parent?this.parent.path.concat(this.key):[],this.delimiter=this.config.delimiter||(this.parent?this.parent.delimiter:vt),this.id=this.config.id||N([this.machine.key],O(this.path),!1).join(this.delimiter),this.version=this.parent?this.parent.version:this.config.version,this.type=this.config.type||(this.config.parallel?"parallel":this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.schema=this.parent?this.machine.schema:(o=this.config.schema)!==null&&o!==void 0?o:{},this.description=this.config.description,V||K(!("parallel"in this.config),'The "parallel" property is deprecated and will be removed in version 4.1. '.concat(this.config.parallel?"Replace with `type: 'parallel'`":"Use `type: '".concat(this.type,"'`")," in the config for state node '").concat(this.id,"' instead.")),this.initial=this.config.initial,this.states=this.config.states?pe(this.config.states,function(l,v){var w,h=new t(l,{},void 0,{parent:i,key:v});return Object.assign(i.idMap,p((w={},w[h.id]=h,w),h.idMap)),h}):fe;var u=0;function f(l){var v,w;l.order=u++;try{for(var h=L(Ht(l)),d=h.next();!d.done;d=h.next()){var y=d.value;f(y)}}catch(m){v={error:m}}finally{try{d&&!d.done&&(w=h.return)&&w.call(h)}finally{if(v)throw v.error}}}f(this),this.history=this.config.history===!0?"shallow":this.config.history||!1,this._transient=!!this.config.always||(this.config.on?Array.isArray(this.config.on)?this.config.on.some(function(l){var v=l.event;return v===ue}):ue in this.config.on:!1),this.strict=!!this.config.strict,this.onEntry=W(this.config.entry||this.config.onEntry).map(function(l){return se(l)}),this.onExit=W(this.config.exit||this.config.onExit).map(function(l){return se(l)}),this.meta=this.config.meta,this.doneData=this.type==="final"?this.config.data:void 0,this.invoke=W(this.config.invoke).map(function(l,v){var w,h;if(ie(l)){var d=je(i.id,v);return i.machine.options.services=p((w={},w[d]=l,w),i.machine.options.services),Me({src:d,id:d})}else if(P(l.src)){var d=l.id||je(i.id,v);return Me(p(p({},l),{id:d,src:l.src}))}else if(ie(l.src)||_(l.src)){var d=l.id||je(i.id,v);return i.machine.options.services=p((h={},h[d]=l.src,h),i.machine.options.services),Me(p(p({id:d},l),{src:d}))}else{var y=l.src;return Me(p(p({id:je(i.id,v)},l),{src:y}))}}),this.activities=W(this.config.activities).concat(this.invoke).map(function(l){return Ue(l)}),this.transition=this.transition.bind(this),this.tags=W(this.config.tags)}return t.prototype._init=function(){this.__cache.transitions||kt(this).forEach(function(e){return e.on})},t.prototype.withConfig=function(e,r){var n=this.options,a=n.actions,i=n.activities,o=n.guards,u=n.services,f=n.delays;return new t(this.config,{actions:p(p({},a),e.actions),activities:p(p({},i),e.activities),guards:p(p({},o),e.guards),services:p(p({},u),e.services),delays:p(p({},f),e.delays)},r!=null?r:this.context)},t.prototype.withContext=function(e){return new t(this.config,this.options,e)},Object.defineProperty(t.prototype,"context",{get:function(){return _(this._context)?this._context():this._context},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"definition",{get:function(){return{id:this.id,key:this.key,version:this.version,context:this.context,type:this.type,initial:this.initial,history:this.history,states:pe(this.states,function(e){return e.definition}),on:this.on,transitions:this.transitions,entry:this.onEntry,exit:this.onExit,activities:this.activities||[],meta:this.meta,order:this.order||-1,data:this.doneData,invoke:this.invoke,description:this.description,tags:this.tags}},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return this.definition},Object.defineProperty(t.prototype,"on",{get:function(){if(this.__cache.on)return this.__cache.on;var e=this.transitions;return this.__cache.on=e.reduce(function(r,n){return r[n.eventType]=r[n.eventType]||[],r[n.eventType].push(n),r},{})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),t.prototype.getCandidates=function(e){if(this.__cache.candidates[e])return this.__cache.candidates[e];var r=e===ue,n=this.transitions.filter(function(a){var i=a.eventType===e;return r?i:i||a.eventType===be});return this.__cache.candidates[e]=n,n},t.prototype.getDelayedTransitions=function(){var e=this,r=this.config.after;if(!r)return[];var n=function(i,o){var u=_(i)?"".concat(e.id,":delay[").concat(o,"]"):i,f=Mt(u,e.id);return e.onEntry.push(ee(f,{delay:i})),e.onExit.push(Ut(f)),f},a=ve(r)?r.map(function(i,o){var u=n(i.delay,o);return p(p({},i),{event:u})}):M(Object.keys(r).map(function(i,o){var u=r[i],f=P(u)?{target:u}:u,l=isNaN(+i)?i:+i,v=n(l,o);return W(f).map(function(w){return p(p({},w),{event:v,delay:l})})}));return a.map(function(i){var o=i.delay;return p(p({},e.formatTransition(i)),{delay:o})})},t.prototype.getStateNodes=function(e){var r,n=this;if(!e)return[];var a=e instanceof te?e.value:he(e,this.delimiter);if(P(a)){var i=this.getStateNode(a).initial;return i!==void 0?this.getStateNodes((r={},r[a]=i,r)):[this,this.states[a]]}var o=Object.keys(a),u=[this];return u.push.apply(u,N([],O(M(o.map(function(f){return n.getStateNode(f).getStateNodes(a[f])}))),!1)),u},t.prototype.handles=function(e){var r=gt(e);return this.events.includes(r)},t.prototype.resolveState=function(e){var r=e instanceof te?e:te.create(e),n=Array.from(we([],this.getStateNodes(r.value)));return new te(p(p({},r),{value:this.resolve(r.value),configuration:n,done:Fe(n,this),tags:Gt(n),machine:this.machine}))},t.prototype.transitionLeafNode=function(e,r,n){var a=this.getStateNode(e),i=a.next(r,n);return!i||!i.transitions.length?this.next(r,n):i},t.prototype.transitionCompoundNode=function(e,r,n){var a=Object.keys(e),i=this.getStateNode(a[0]),o=i._transition(e[a[0]],r,n);return!o||!o.transitions.length?this.next(r,n):o},t.prototype.transitionParallelNode=function(e,r,n){var a,i,o={};try{for(var u=L(Object.keys(e)),f=u.next();!f.done;f=u.next()){var l=f.value,v=e[l];if(v){var w=this.getStateNode(l),h=w._transition(v,r,n);h&&(o[l]=h)}}}catch(g){a={error:g}}finally{try{f&&!f.done&&(i=u.return)&&i.call(u)}finally{if(a)throw a.error}}var d=Object.keys(o).map(function(g){return o[g]}),y=M(d.map(function(g){return g.transitions})),m=d.some(function(g){return g.transitions.length>0});if(!m)return this.next(r,n);var E=M(d.map(function(g){return g.entrySet})),S=M(Object.keys(o).map(function(g){return o[g].configuration}));return{transitions:y,entrySet:E,exitSet:M(d.map(function(g){return g.exitSet})),configuration:S,source:r,actions:M(Object.keys(o).map(function(g){return o[g].actions}))}},t.prototype._transition=function(e,r,n){return P(e)?this.transitionLeafNode(e,r,n):Object.keys(e).length===1?this.transitionCompoundNode(e,r,n):this.transitionParallelNode(e,r,n)},t.prototype.getTransitionData=function(e,r){return this._transition(e.value,e,ye(r))},t.prototype.next=function(e,r){var n,a,i=this,o=r.name,u=[],f=[],l;try{for(var v=L(this.getCandidates(o)),w=v.next();!w.done;w=v.next()){var h=w.value,d=h.cond,y=h.in,m=e.context,E=y?P(y)&&le(y)?e.matches(he(this.getStateNodeById(y).path,this.delimiter)):We(he(y,this.delimiter),sr(this.path.slice(0,-2))(e.value)):!0,S=!1;try{S=!d||Tt(this.machine,d,m,r,e)}catch(I){throw new Error("Unable to evaluate guard '".concat(d.name||d.type,"' in transition for event '").concat(o,"' in state node '").concat(this.id,`':
`).concat(I.message))}if(S&&E){h.target!==void 0&&(f=h.target),u.push.apply(u,N([],O(h.actions),!1)),l=h;break}}}catch(I){n={error:I}}finally{try{w&&!w.done&&(a=v.return)&&a.call(v)}finally{if(n)throw n.error}}if(l){if(!f.length)return{transitions:[l],entrySet:[],exitSet:[],configuration:e.value?[this]:[],source:e,actions:u};var g=M(f.map(function(I){return i.getRelativeStateNodes(I,e.historyValue)})),x=!!l.internal,F=[];return x||f.forEach(function(I){F.push.apply(F,N([],O(i.getExternalReentryNodes(I)),!1))}),{transitions:[l],entrySet:F,exitSet:x?[]:[this],configuration:g,source:e,actions:u}}},t.prototype.getExternalReentryNodes=function(e){for(var r=[],n=O(e.order>this.order?[e,this]:[this,e],2),a=n[0],i=n[1];a&&a!==i;)r.push(a),a=a.parent;return a!==i?[]:(r.push(i),r)},t.prototype.getActions=function(e,r,n,a,i,o,u){var f,l,v,w,h=this,d=we([],o?this.getStateNodes(o.value):[this]);try{for(var y=L(e),m=y.next();!m.done;m=y.next()){var E=m.value;(!Se(d,E)||Se(n.entrySet,E.parent))&&n.entrySet.push(E)}}catch(b){f={error:b}}finally{try{m&&!m.done&&(l=y.return)&&l.call(y)}finally{if(f)throw f.error}}try{for(var S=L(d),g=S.next();!g.done;g=S.next()){var E=g.value;(!Se(e,E)||Se(n.exitSet,E.parent))&&n.exitSet.push(E)}}catch(b){v={error:b}}finally{try{g&&!g.done&&(w=S.return)&&w.call(S)}finally{if(v)throw v.error}}var x=M(n.entrySet.map(function(b){var D=[];if(b.type!=="final")return D;var J=b.parent;if(!J.parent)return D;D.push(ge(b.id,b.doneData),ge(J.id,b.doneData?St(b.doneData,a,i):void 0));var Y=J.parent;return Y.type==="parallel"&&me(Y).every(function(C){return Fe(n.configuration,C)})&&D.push(ge(Y.id)),D}));n.exitSet.sort(function(b,D){return D.order-b.order}),n.entrySet.sort(function(b,D){return b.order-D.order});var F=new Set(n.entrySet),I=new Set(n.exitSet),$=Array.from(F).map(function(b){var D=b.onEntry,J=b.activities.map(function(Y){return Nt(Y)});return Z(u?N(N([],O(D),!1),O(J),!1):N(N([],O(J),!1),O(D),!1),h.machine.options.actions)}).concat([x.map(Pt)]),k=Array.from(I).map(function(b){return Z(N(N([],O(b.onExit),!1),O(b.activities.map(function(D){return It(D)})),!1),h.machine.options.actions)}),B=k.concat([Z(n.actions,this.machine.options.actions)]).concat($);if(r){var z=Z(M(N([],O(e),!1).sort(function(b,D){return D.order-b.order}).map(function(b){return b.onExit})),this.machine.options.actions).filter(function(b){return b.type!==ae&&(b.type!==de||!!b.to&&b.to!==Q.Internal)});return B.concat([z])}return B},t.prototype.transition=function(e,r,n,a){e===void 0&&(e=this.initialState);var i=ye(r),o;if(e instanceof te)o=n===void 0?e:this.resolveState(te.from(e,n));else{var u=P(e)?this.resolve(Pe(this.getResolvedPath(e))):this.resolve(e),f=n!=null?n:this.machine.context;o=this.resolveState(te.from(u,f))}if(!V&&i.name===be)throw new Error("An event cannot have the wildcard type ('".concat(be,"')"));if(this.strict&&!this.events.includes(i.name)&&!fr(i.name))throw new Error("Machine '".concat(this.id,"' does not accept event '").concat(i.name,"'"));var l=this._transition(o.value,o,i)||{transitions:[],configuration:[],entrySet:[],exitSet:[],source:o,actions:[]},v=we([],this.getStateNodes(o.value)),w=l.configuration.length?we(v,l.configuration):v;return l.configuration=N([],O(w),!1),this.resolveTransition(l,o,o.context,a,i)},t.prototype.resolveRaisedTransition=function(e,r,n,a){var i,o=e.actions;return e=this.transition(e,r,void 0,a),e._event=n,e.event=n.data,(i=e.actions).unshift.apply(i,N([],O(o),!1)),e},t.prototype.resolveTransition=function(e,r,n,a,i){var o,u,f,l,v=this;i===void 0&&(i=Re);var w=e.configuration,h=!r||e.transitions.length>0,d=h?e.configuration:r?r.configuration:[],y=Fe(d,this),m=h?Rr(this.machine,w):void 0,E=r?r.historyValue?r.historyValue:e.source?this.machine.historyValue(r.value):void 0:void 0,S=this.getActions(new Set(d),y,e,n,i,r,a),g=r?p({},r.activities):{};try{for(var x=L(S),F=x.next();!F.done;F=x.next()){var I=F.value;try{for(var $=(f=void 0,L(I)),k=$.next();!k.done;k=$.next()){var B=k.value;B.type===ze?g[B.activity.id||B.activity.type]=B:B.type===Xe&&(g[B.activity.id||B.activity.type]=!1)}}catch(q){f={error:q}}finally{try{k&&!k.done&&(l=$.return)&&l.call($)}finally{if(f)throw f.error}}}}catch(q){o={error:q}}finally{try{F&&!F.done&&(u=x.return)&&u.call(x)}finally{if(o)throw o.error}}var z=O(Ne(this,r,n,i,S,a,this.machine.config.predictableActionArguments||this.machine.config.preserveActionOrder),2),b=z[0],D=z[1],J=O(lr(b,function(q){return q.type===ae||q.type===de&&q.to===Q.Internal}),2),Y=J[0],C=J[1],re=b.filter(function(q){var H;return q.type===ze&&((H=q.activity)===null||H===void 0?void 0:H.type)===Oe}),Ee=re.reduce(function(q,H){return q[H.activity.id]=jr(H.activity,v.machine,D,i),q},r?p({},r.children):{}),s=new te({value:m||r.value,context:D,_event:i,_sessionid:r?r._sessionid:null,historyValue:m?E?cr(E,m):void 0:r?r.historyValue:void 0,history:!m||e.source?r:void 0,actions:m?C:[],activities:m?g:r?r.activities:{},events:[],configuration:d,transitions:e.transitions,children:Ee,done:y,tags:Gt(d),machine:this}),c=n!==D;s.changed=i.name===Je||c;var A=s.history;A&&delete A.history;var U=!y&&(this._transient||w.some(function(q){return q._transient}));if(!h&&(!U||i.name===ue))return s;var T=s;if(!y)for(U&&(T=this.resolveRaisedTransition(T,{type:lt},i,a));Y.length;){var j=Y.shift();T=this.resolveRaisedTransition(T,j._event,i,a)}var ce=T.changed||(A?!!T.actions.length||c||typeof A.value!=typeof T.value||!zt(T.value,A.value):void 0);return T.changed=ce,T.history=A,T},t.prototype.getStateNode=function(e){if(le(e))return this.machine.getStateNodeById(e);if(!this.states)throw new Error("Unable to retrieve child state '".concat(e,"' from '").concat(this.id,"'; no child states exist."));var r=this.states[e];if(!r)throw new Error("Child state '".concat(e,"' does not exist on '").concat(this.id,"'"));return r},t.prototype.getStateNodeById=function(e){var r=le(e)?e.slice(tt.length):e;if(r===this.id)return this;var n=this.machine.idMap[r];if(!n)throw new Error("Child state node '#".concat(r,"' does not exist on machine '").concat(this.id,"'"));return n},t.prototype.getStateNodeByPath=function(e){if(typeof e=="string"&&le(e))try{return this.getStateNodeById(e.slice(1))}catch{}for(var r=Ke(e,this.delimiter).slice(),n=this;r.length;){var a=r.shift();if(!a.length)break;n=n.getStateNode(a)}return n},t.prototype.resolve=function(e){var r,n=this;if(!e)return this.initialStateValue||fe;switch(this.type){case"parallel":return pe(this.initialStateValue,function(i,o){return i?n.getStateNode(o).resolve(e[o]||i):fe});case"compound":if(P(e)){var a=this.getStateNode(e);return a.type==="parallel"||a.type==="compound"?(r={},r[e]=a.initialStateValue,r):e}return Object.keys(e).length?pe(e,function(i,o){return i?n.getStateNode(o).resolve(i):fe}):this.initialStateValue||{};default:return e||fe}},t.prototype.getResolvedPath=function(e){if(le(e)){var r=this.machine.idMap[e.slice(tt.length)];if(!r)throw new Error("Unable to find state node '".concat(e,"'"));return r.path}return Ke(e,this.delimiter)},Object.defineProperty(t.prototype,"initialStateValue",{get:function(){var e;if(this.__cache.initialStateValue)return this.__cache.initialStateValue;var r;if(this.type==="parallel")r=mt(this.states,function(n){return n.initialStateValue||fe},function(n){return n.type!=="history"});else if(this.initial!==void 0){if(!this.states[this.initial])throw new Error("Initial state '".concat(this.initial,"' not found on '").concat(this.key,"'"));r=Le(this.states[this.initial])?this.initial:(e={},e[this.initial]=this.states[this.initial].initialStateValue,e)}else r={};return this.__cache.initialStateValue=r,this.__cache.initialStateValue},enumerable:!1,configurable:!0}),t.prototype.getInitialState=function(e,r){this._init();var n=this.getStateNodes(e);return this.resolveTransition({configuration:n,entrySet:N([],O(n),!1),exitSet:[],transitions:[],source:void 0,actions:[]},void 0,r!=null?r:this.machine.context,void 0)},Object.defineProperty(t.prototype,"initialState",{get:function(){var e=this.initialStateValue;if(!e)throw new Error("Cannot retrieve initial state from simple state '".concat(this.id,"'."));return this.getInitialState(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){var e;if(this.type==="history"){var r=this.config;P(r.target)?e=le(r.target)?Pe(this.machine.getStateNodeById(r.target).path.slice(this.path.length-1)):r.target:e=r.target}return e},enumerable:!1,configurable:!0}),t.prototype.getRelativeStateNodes=function(e,r,n){return n===void 0&&(n=!0),n?e.type==="history"?e.resolveHistory(r):e.initialStateNodes:[e]},Object.defineProperty(t.prototype,"initialStateNodes",{get:function(){var e=this;if(Le(this))return[this];if(this.type==="compound"&&!this.initial)return V||K(!1,"Compound state node '".concat(this.id,"' has no initial state.")),[this];var r=De(this.initialStateValue);return M(r.map(function(n){return e.getFromRelativePath(n)}))},enumerable:!1,configurable:!0}),t.prototype.getFromRelativePath=function(e){if(!e.length)return[this];var r=O(e),n=r[0],a=r.slice(1);if(!this.states)throw new Error("Cannot retrieve subPath '".concat(n,"' from node with no states"));var i=this.getStateNode(n);if(i.type==="history")return i.resolveHistory();if(!this.states[n])throw new Error("Child state '".concat(n,"' does not exist on '").concat(this.id,"'"));return this.states[n].getFromRelativePath(a)},t.prototype.historyValue=function(e){if(Object.keys(this.states).length)return{current:e||this.initialStateValue,states:mt(this.states,function(r,n){if(!e)return r.historyValue();var a=P(e)?void 0:e[n];return r.historyValue(a||r.initialStateValue)},function(r){return!r.history})}},t.prototype.resolveHistory=function(e){var r=this;if(this.type!=="history")return[this];var n=this.parent;if(!e){var a=this.target;return a?M(De(a).map(function(o){return n.getFromRelativePath(o)})):n.initialStateNodes}var i=ur(n.path,"states")(e).current;return P(i)?[n.getStateNode(i)]:M(De(i).map(function(o){return r.history==="deep"?n.getFromRelativePath(o):[n.states[o[0]]]}))},Object.defineProperty(t.prototype,"stateIds",{get:function(){var e=this,r=M(Object.keys(this.states).map(function(n){return e.states[n].stateIds}));return[this.id].concat(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"events",{get:function(){var e,r,n,a;if(this.__cache.events)return this.__cache.events;var i=this.states,o=new Set(this.ownEvents);if(i)try{for(var u=L(Object.keys(i)),f=u.next();!f.done;f=u.next()){var l=f.value,v=i[l];if(v.states)try{for(var w=(n=void 0,L(v.events)),h=w.next();!h.done;h=w.next()){var d=h.value;o.add("".concat(d))}}catch(y){n={error:y}}finally{try{h&&!h.done&&(a=w.return)&&a.call(w)}finally{if(n)throw n.error}}}}catch(y){e={error:y}}finally{try{f&&!f.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return this.__cache.events=Array.from(o)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ownEvents",{get:function(){var e=new Set(this.transitions.filter(function(r){return!(!r.target&&!r.actions.length&&r.internal)}).map(function(r){return r.eventType}));return Array.from(e)},enumerable:!1,configurable:!0}),t.prototype.resolveTarget=function(e){var r=this;if(e!==void 0)return e.map(function(n){if(!P(n))return n;var a=n[0]===r.delimiter;if(a&&!r.parent)return r.getStateNodeByPath(n.slice(1));var i=a?r.key+n:n;if(r.parent)try{var o=r.parent.getStateNodeByPath(i);return o}catch(u){throw new Error("Invalid transition definition for state node '".concat(r.id,`':
`).concat(u.message))}else return r.getStateNodeByPath(i)})},t.prototype.formatTransition=function(e){var r=this,n=hr(e.target),a="internal"in e?e.internal:n?n.some(function(f){return P(f)&&f[0]===r.delimiter}):!0,i=this.machine.options.guards,o=this.resolveTarget(n),u=p(p({},e),{actions:Z(W(e.actions)),cond:At(e.cond,i),target:o,source:this,internal:a,eventType:e.event,toJSON:function(){return p(p({},u),{target:u.target?u.target.map(function(f){return"#".concat(f.id)}):void 0,source:"#".concat(r.id)})}});return u},t.prototype.formatTransitions=function(){var e,r,n=this,a;if(!this.config.on)a=[];else if(Array.isArray(this.config.on))a=this.config.on;else{var i=this.config.on,o=be,u=i[o],f=u===void 0?[]:u,l=Ge(i,[typeof o=="symbol"?o:o+""]);a=M(Object.keys(l).map(function(g){!V&&g===ue&&K(!1,"Empty string transition configs (e.g., `{ on: { '': ... }}`) for transient transitions are deprecated. Specify the transition in the `{ always: ... }` property instead. "+'Please check the `on` configuration for "#'.concat(n.id,'".'));var x=oe(g,l[g]);return V||_r(n,g,x),x}).concat(oe(be,f)))}var v=this.config.always?oe("",this.config.always):[],w=this.config.onDone?oe(String(ge(this.id)),this.config.onDone):[];V||K(!(this.config.onDone&&!this.parent),'Root nodes cannot have an ".onDone" transition. Please check the config of "'.concat(this.id,'".'));var h=M(this.invoke.map(function(g){var x=[];return g.onDone&&x.push.apply(x,N([],O(oe(String(_t(g.id)),g.onDone)),!1)),g.onError&&x.push.apply(x,N([],O(oe(String(Bt(g.id)),g.onError)),!1)),x})),d=this.after,y=M(N(N(N(N([],O(w),!1),O(h),!1),O(a),!1),O(v),!1).map(function(g){return W(g).map(function(x){return n.formatTransition(x)})}));try{for(var m=L(d),E=m.next();!E.done;E=m.next()){var S=E.value;y.push(S)}}catch(g){e={error:g}}finally{try{E&&!E.done&&(r=m.return)&&r.call(m)}finally{if(e)throw e.error}}return y},t}(),Jt=!1;function Yt(t,e){return!V&&!t.predictableActionArguments&&!Jt&&(Jt=!0,console.warn("It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html")),new Br(t,e)}var G=Ft,rt=ee;let nt;typeof nt=="undefined"&&(nt=He);const _e={progress:null,loaded:0,error:null,bucketId:void 0,file:void 0,id:void 0},Wt=()=>Yt({predictableActionArguments:!0,schema:{context:{},events:{}},tsTypes:{},context:{..._e},initial:"idle",on:{DESTROY:{actions:"sendDestroy",target:"stopped"}},states:{idle:{on:{ADD:{actions:"addFile"},UPLOAD:{cond:"hasFile",target:"uploading"}}},uploading:{entry:"resetProgress",on:{UPLOAD_PROGRESS:{actions:["incrementProgress","sendProgress"]},UPLOAD_DONE:"uploaded",UPLOAD_ERROR:"error",CANCEL:"idle"},invoke:{src:"uploadFile"}},uploaded:{entry:["setFileMetadata","sendDone"],on:{ADD:{actions:"addFile",target:"idle"},UPLOAD:{actions:"resetContext",target:"uploading"}}},error:{entry:["setError","sendError"],on:{ADD:{actions:"addFile",target:"idle"},UPLOAD:{actions:"resetContext",target:"uploading"}}},stopped:{type:"final"}}},{guards:{hasFile:(t,e)=>!!t.file||!!e.file},actions:{incrementProgress:G({loaded:(t,{loaded:e})=>e,progress:(t,{progress:e})=>e}),setFileMetadata:G({id:(t,{id:e})=>e,bucketId:(t,{bucketId:e})=>e,progress:t=>100}),setError:G({error:(t,{error:e})=>e}),sendProgress:()=>{},sendError:()=>{},sendDestroy:()=>{},sendDone:()=>{},resetProgress:G({progress:t=>null,loaded:t=>0}),resetContext:G(t=>_e),addFile:G({file:(t,{file:e})=>e,bucketId:(t,{bucketId:e})=>e,id:(t,{id:e})=>e})},services:{uploadFile:(t,e)=>r=>{const n=e.file||t.file,a=new nt;a.append("file[]",n);let i=0;return ke(e.url,a,{fileId:e.id||t.id,bucketId:e.bucketId||t.bucketId,accessToken:e.accessToken,adminSecret:e.adminSecret,name:e.name||n.name,onUploadProgress:o=>{const u=o.total?Math.round(o.loaded*n.size/o.total):0,f=u-i;i=u,r({type:"UPLOAD_PROGRESS",progress:o.total?Math.round(u*100/o.total):0,loaded:u,additions:f})}}).then(({fileMetadata:o,error:u})=>{if(u&&r({type:"UPLOAD_ERROR",error:u}),o&&!("processedFiles"in o)){const{id:f,bucketId:l}=o;r({type:"UPLOAD_DONE",id:f,bucketId:l})}if(o&&"processedFiles"in o){const{id:f,bucketId:l}=o.processedFiles[0];r({type:"UPLOAD_DONE",id:f,bucketId:l})}}),()=>{}}}}),{pure:it,sendParent:Be}=Tr,Cr=()=>Yt({id:"files-list",schema:{context:{},events:{}},tsTypes:{},predictableActionArguments:!0,context:{progress:null,files:[],loaded:0,total:0},initial:"idle",on:{UPLOAD:{cond:"hasFileToDownload",actions:"addItem",target:"uploading"},ADD:{actions:"addItem"},REMOVE:{actions:"removeItem"}},states:{idle:{entry:["resetProgress","resetLoaded","resetTotal"],on:{CLEAR:{actions:"clearList",target:"idle"}}},uploading:{entry:["upload","startProgress","resetLoaded","resetTotal"],on:{UPLOAD_PROGRESS:{actions:["incrementProgress"]},UPLOAD_DONE:[{cond:"isAllUploaded",target:"uploaded"},{cond:"isAllUploadedOrError",target:"error"}],UPLOAD_ERROR:[{cond:"isAllUploaded",target:"uploaded"},{cond:"isAllUploadedOrError",target:"error"}],CANCEL:{actions:"cancel",target:"idle"}}},uploaded:{entry:"setUploaded",on:{CLEAR:{actions:"clearList",target:"idle"}}},error:{on:{CLEAR:{actions:"clearList",target:"idle"}}}}},{guards:{hasFileToDownload:(t,e)=>t.files.some(r=>r.getSnapshot().matches("idle"))||!!e.files,isAllUploaded:t=>t.files.every(e=>{var r;return(r=e.getSnapshot())==null?void 0:r.matches("uploaded")}),isAllUploadedOrError:t=>t.files.every(e=>{const r=e.getSnapshot();return(r==null?void 0:r.matches("error"))||(r==null?void 0:r.matches("uploaded"))})},actions:{incrementProgress:G((t,e)=>{const r=t.loaded+e.additions,n=Math.round(r*100/t.total);return{...t,loaded:r,progress:n}}),setUploaded:G({progress:t=>100,loaded:({files:t})=>t.map(e=>e.getSnapshot()).filter(e=>e.matches("uploaded")).reduce((e,r)=>{var n;return e+((n=r.context.file)==null?void 0:n.size)},0)}),resetTotal:G({total:({files:t})=>t.map(e=>e.getSnapshot()).filter(e=>!e.matches("uploaded")).reduce((e,r)=>{var n;return e+((n=r.context.file)==null?void 0:n.size)},0)}),resetLoaded:G({loaded:t=>0}),startProgress:G({progress:t=>0}),resetProgress:G({progress:t=>null}),addItem:G((t,{files:e,bucketId:r})=>{const n=e?Array.isArray(e)?e:"item"in e?Array.from(e):[e]:[],a=t.total+n.reduce((o,u)=>o+u.size,0),i=Math.round(t.loaded*100/a);return{files:[...t.files,...n.map(o=>Lr(Wt().withConfig({actions:{sendProgress:Be((u,{additions:f})=>({type:"UPLOAD_PROGRESS",additions:f})),sendDone:Be("UPLOAD_DONE"),sendError:Be("UPLOAD_ERROR"),sendDestroy:Be("REMOVE")}}).withContext({..._e,file:o,bucketId:r}),{sync:!0}))],total:a,loaded:t.loaded,progress:i}}),removeItem:G({files:t=>t.files.filter(e=>{var n,a;const r=(n=e.getSnapshot())==null?void 0:n.matches("stopped");return r&&((a=e.stop)==null||a.call(e)),!r})}),clearList:it(t=>t.files.map(e=>rt({type:"DESTROY"},{to:e.id}))),upload:it((t,e)=>t.files.map(r=>rt(e,{to:r.id}))),cancel:it(t=>t.files.map(e=>rt({type:"CANCEL"},{to:e.id})))}}),$r=async(t,e)=>new Promise(r=>{e.send({type:"UPLOAD",...t}),e.subscribe(n=>{var a;n.matches("error")?r({error:n.context.error,isError:!0,isUploaded:!1}):n.matches("uploaded")&&r({error:null,isError:!1,isUploaded:!0,id:n.context.id,bucketId:n.context.id,name:(a=n.context.file)==null?void 0:a.name})})}),Hr=async(t,e)=>new Promise(r=>{e.send({type:"UPLOAD",...t,files:t.files}),e.onTransition(n=>{n.matches("error")?r({errors:n.context.files.filter(a=>{var i;return(i=a.getSnapshot())==null?void 0:i.context.error}),isError:!0,files:[]}):n.matches("uploaded")&&r({errors:[],isError:!1,files:n.context.files})})});X.HasuraStorageApi=ut,X.HasuraStorageClient=Zt,X.INITIAL_FILE_CONTEXT=_e,X.appendImageTransformationParameters=qe,X.createFileUploadMachine=Wt,X.createMultipleFilesUploadMachine=Cr,X.uploadFilePromise=$r,X.uploadMultipleFilesPromise=Hr,Object.defineProperty(X,Symbol.toStringTag,{value:"Module"})});
***************************************************************************** */var v=function(){return v=Object.assign||function(e){for(var r,n=1,a=arguments.length;n<a;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},v.apply(this,arguments)};function Ge(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(t);a<n.length;a++)e.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(t,n[a])&&(r[n[a]]=t[n[a]]);return r}function _(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function j(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),a,i=[],o;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)i.push(a.value)}catch(u){o={error:u}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i}function I(t,e,r){if(r||arguments.length===2)for(var n=0,a=e.length,i;n<a;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}var R;(function(t){t.Start="xstate.start",t.Stop="xstate.stop",t.Raise="xstate.raise",t.Send="xstate.send",t.Cancel="xstate.cancel",t.NullEvent="",t.Assign="xstate.assign",t.After="xstate.after",t.DoneState="done.state",t.DoneInvoke="done.invoke",t.Log="xstate.log",t.Init="xstate.init",t.Invoke="xstate.invoke",t.ErrorExecution="error.execution",t.ErrorCommunication="error.communication",t.ErrorPlatform="error.platform",t.ErrorCustom="xstate.error",t.Update="xstate.update",t.Pure="xstate.pure",t.Choose="xstate.choose"})(R||(R={}));var ae;(function(t){t.Parent="#_parent",t.Internal="#_internal"})(ae||(ae={}));var ze=R.Start,Xe=R.Stop,de=R.Raise,Ae=R.Send,lt=R.Cancel,ct=R.NullEvent,xe=R.Assign,tr=R.After,rr=R.DoneState,Ve=R.Log,dt=R.Init,Oe=R.Invoke,nr=R.ErrorExecution,ir=R.ErrorPlatform,ht=R.ErrorCustom,Je=R.Update,vt=R.Choose,pt=R.Pure;const ar=Object.freeze(Object.defineProperty({__proto__:null,after:tr,assign:xe,cancel:lt,choose:vt,doneState:rr,error:ht,errorExecution:nr,errorPlatform:ir,init:dt,invoke:Oe,log:Ve,nullEvent:ct,pure:pt,raise:de,send:Ae,start:ze,stop:Xe,update:Je},Symbol.toStringTag,{value:"Module"}));var yt=".",gt={},Ye="xstate.guard",or="",J=process.env.NODE_ENV==="production",Te;function We(t,e,r){r===void 0&&(r=yt);var n=he(t,r),a=he(e,r);return T(a)?T(n)?a===n:!1:T(n)?n in a:Object.keys(n).every(function(i){return i in a?We(n[i],a[i]):!1})}function mt(t){try{return T(t)||typeof t=="number"?"".concat(t):t.type}catch{throw new Error("Events must be strings or objects with a string event.type property.")}}function Ke(t,e){try{return pe(t)?t:t.toString().split(e)}catch{throw new Error("'".concat(t,"' is not a valid state path."))}}function sr(t){return typeof t=="object"&&"value"in t&&"context"in t&&"event"in t&&"_event"in t}function he(t,e){if(sr(t))return t.value;if(pe(t))return Pe(t);if(typeof t!="string")return t;var r=Ke(t,e);return Pe(r)}function Pe(t){if(t.length===1)return t[0];for(var e={},r=e,n=0;n<t.length-1;n++)n===t.length-2?r[t[n]]=t[n+1]:(r[t[n]]={},r=r[t[n]]);return e}function ve(t,e){for(var r={},n=Object.keys(t),a=0;a<n.length;a++){var i=n[a];r[i]=e(t[i],i,t,a)}return r}function wt(t,e,r){var n,a,i={};try{for(var o=_(Object.keys(t)),u=o.next();!u.done;u=o.next()){var f=u.value,l=t[f];r(l)&&(i[f]=e(l,f,t))}}catch(p){n={error:p}}finally{try{u&&!u.done&&(a=o.return)&&a.call(o)}finally{if(n)throw n.error}}return i}var ur=function(t){return function(e){var r,n,a=e;try{for(var i=_(t),o=i.next();!o.done;o=i.next()){var u=o.value;a=a[u]}}catch(f){r={error:f}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return a}};function fr(t,e){return function(r){var n,a,i=r;try{for(var o=_(t),u=o.next();!u.done;u=o.next()){var f=u.value;i=i[e][f]}}catch(l){n={error:l}}finally{try{u&&!u.done&&(a=o.return)&&a.call(o)}finally{if(n)throw n.error}}return i}}function De(t){if(!t)return[[]];if(T(t))return[[t]];var e=M(Object.keys(t).map(function(r){var n=t[r];return typeof n!="string"&&(!n||!Object.keys(n).length)?[[r]]:De(t[r]).map(function(a){return[r].concat(a)})}));return e}function M(t){var e;return(e=[]).concat.apply(e,I([],j(t),!1))}function bt(t){return pe(t)?t:[t]}function W(t){return t===void 0?[]:bt(t)}function St(t,e,r){var n,a;if(L(t))return t(e,r.data);var i={};try{for(var o=_(Object.keys(t)),u=o.next();!u.done;u=o.next()){var f=u.value,l=t[f];L(l)?i[f]=l(e,r.data):i[f]=l}}catch(p){n={error:p}}finally{try{u&&!u.done&&(a=o.return)&&a.call(o)}finally{if(n)throw n.error}}return i}function lr(t){return/^(done|error)\./.test(t)}function cr(t,e){var r,n,a=j([[],[]],2),i=a[0],o=a[1];try{for(var u=_(t),f=u.next();!f.done;f=u.next()){var l=f.value;e(l)?i.push(l):o.push(l)}}catch(p){r={error:p}}finally{try{f&&!f.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}return[i,o]}function Et(t,e){return ve(t.states,function(r,n){if(r){var a=(T(e)?void 0:e[n])||(r?r.current:void 0);if(a)return{current:a,states:Et(r,a)}}})}function dr(t,e){return{current:e,states:Et(t,e)}}function At(t,e,r,n){J||K(!!t,"Attempting to update undefined context");var a=t&&r.reduce(function(i,o){var u,f,l=o.assignment,p={state:n,action:o,_event:e},w={};if(L(l))w=l(i,e.data,p);else try{for(var d=_(Object.keys(l)),h=d.next();!h.done;h=d.next()){var m=h.value,g=l[m];w[m]=L(g)?g(i,e.data,p):g}}catch(E){u={error:E}}finally{try{h&&!h.done&&(f=d.return)&&f.call(d)}finally{if(u)throw u.error}}return Object.assign({},i,w)},t);return a}var K=function(){};J||(K=function(t,e){var r=t instanceof Error?t:void 0;if(!(!r&&t)&&console!==void 0){var n=["Warning: ".concat(e)];r&&n.push(r),console.warn.apply(console,n)}});function pe(t){return Array.isArray(t)}function L(t){return typeof t=="function"}function T(t){return typeof t=="string"}function xt(t,e){if(t)return T(t)?{type:Ye,name:t,predicate:e?e[t]:void 0}:L(t)?{type:Ye,name:t.name,predicate:t}:t}var Ot=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();Te={},Te[Ot]=function(){return this},Te[Symbol.observable]=function(){return this};function te(t){return!!t&&"__xstatenode"in t}var hr=function(){var t=0;return function(){return t++,t.toString(16)}}();function Qe(t,e){return T(t)||typeof t=="number"?v({type:t},e):t}function ye(t,e){if(!T(t)&&"$$type"in t&&t.$$type==="scxml")return t;var r=Qe(t);return v({name:r.type,data:r,$$type:"scxml",type:"external"},e)}function oe(t,e){var r=bt(e).map(function(n){return typeof n=="undefined"||typeof n=="string"||te(n)?{target:n,event:t}:v(v({},n),{event:t})});return r}function vr(t){if(!(t===void 0||t===or))return W(t)}function Tt(t,e,r,n,a){var i=t.options.guards,o={state:a,cond:e,_event:n};if(e.type===Ye)return((i==null?void 0:i[e.name])||e.predicate)(r,n.data,o);var u=i==null?void 0:i[e.type];if(!u)throw new Error("Guard '".concat(e.type,"' is not implemented on machine '").concat(t.id,"'."));return u(r,n.data,o)}function pr(t){return typeof t=="string"?{type:t}:t}function je(t,e){return"".concat(t,":invocation[").concat(e,"]")}function Pt(t){return(t.type===de||t.type===Ae&&t.to===ae.Internal)&&typeof t.delay!="number"}var Re=ye({type:dt});function Ze(t,e){return e&&e[t]||void 0}function se(t,e){var r;if(T(t)||typeof t=="number"){var n=Ze(t,e);L(n)?r={type:t,exec:n}:n?r=n:r={type:t,exec:void 0}}else if(L(t))r={type:t.name||t.toString(),exec:t};else{var n=Ze(t.type,e);if(L(n))r=v(v({},t),{exec:n});else if(n){var a=n.type||t.type;r=v(v(v({},n),t),{type:a})}else r=t}return r}var Q=function(t,e){if(!t)return[];var r=pe(t)?t:[t];return r.map(function(n){return se(n,e)})};function Ue(t){var e=se(t);return v(v({id:T(t)?t:e.id},e),{type:e.type})}function Dt(t,e){return{type:de,event:typeof t=="function"?t:Qe(t),delay:e?e.delay:void 0,id:e==null?void 0:e.id}}function jt(t,e,r,n){var a={_event:r},i=ye(L(t.event)?t.event(e,r.data,a):t.event),o;if(T(t.delay)){var u=n&&n[t.delay];o=L(u)?u(e,r.data,a):u}else o=L(t.delay)?t.delay(e,r.data,a):t.delay;return v(v({},t),{type:de,_event:i,delay:o})}function re(t,e){return{to:e?e.to:void 0,type:Ae,event:L(t)?t:Qe(t),delay:e?e.delay:void 0,id:e&&e.id!==void 0?e.id:L(t)?t.name:mt(t)}}function Rt(t,e,r,n){var a={_event:r},i=ye(L(t.event)?t.event(e,r.data,a):t.event),o;if(T(t.delay)){var u=n&&n[t.delay];o=L(u)?u(e,r.data,a):u}else o=L(t.delay)?t.delay(e,r.data,a):t.delay;var f=L(t.to)?t.to(e,r.data,a):t.to;return v(v({},t),{to:f,_event:i,event:i.data,delay:o})}function et(t,e){return re(t,v(v({},e),{to:ae.Parent}))}function yr(t,e,r){return re(e,v(v({},r),{to:t}))}function gr(){return et(Je)}function mr(t,e){return re(t,v(v({},e),{to:function(r,n,a){var i=a._event;return i.origin}}))}var wr=function(t,e){return{context:t,event:e}};function br(t,e){return t===void 0&&(t=wr),{type:Ve,label:e,expr:t}}var Ut=function(t,e,r){return v(v({},t),{value:T(t.expr)?t.expr:t.expr(e,r.data,{_event:r})})},Nt=function(t){return{type:lt,sendId:t}};function It(t){var e=Ue(t);return{type:R.Start,activity:e,exec:void 0}}function Lt(t){var e=L(t)?t:Ue(t);return{type:R.Stop,activity:e,exec:void 0}}function Ft(t,e,r){var n=L(t.activity)?t.activity(e,r.data):t.activity,a=typeof n=="string"?{id:n}:n,i={type:R.Stop,activity:a};return i}var _t=function(t){return{type:xe,assignment:t}};function Sr(t){return typeof t=="object"&&"type"in t}function Mt(t,e){var r=e?"#".concat(e):"";return"".concat(R.After,"(").concat(t,")").concat(r)}function ge(t,e){var r="".concat(R.DoneState,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Bt(t,e){var r="".concat(R.DoneInvoke,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Ct(t,e){var r="".concat(R.ErrorPlatform,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Er(t){return{type:R.Pure,get:t}}function Ar(t,e){if(!J&&(!t||typeof t=="function")){var r=t;t=function(){for(var n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];var i=typeof r=="function"?r.apply(void 0,I([],j(n),!1)):r;if(!i)throw new Error("Attempted to forward event to undefined actor. This risks an infinite loop in the sender.");return i}}return re(function(n,a){return a},v(v({},e),{to:t}))}function xr(t,e){return et(function(r,n,a){return{type:ht,data:L(t)?t(r,n,a):t}},v(v({},e),{to:ae.Parent}))}function Or(t){return{type:R.Choose,conds:t}}var Tr=function(t){var e,r,n=[];try{for(var a=_(t),i=a.next();!i.done;i=a.next())for(var o=i.value,u=0;u<o.actions.length;){if(o.actions[u].type===xe){n.push(o.actions[u]),o.actions.splice(u,1);continue}u++}}catch(f){e={error:f}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return n};function Ne(t,e,r,n,a,i,o){o===void 0&&(o=!1);var u=o?[]:Tr(a),f=u.length?At(r,n,u,e):r,l=o?[r]:void 0,p=[];function w(m,g){var E;switch(g.type){case de:{var y=jt(g,f,n,t.options.delays);return i&&typeof y.delay=="number"&&i(y,f,n),y}case Ae:var S=Rt(g,f,n,t.options.delays);if(!J){var x=g.delay;K(!T(x)||typeof S.delay=="number","No delay reference for delay expression '".concat(x,"' was found on machine '").concat(t.id,"'"))}return i&&S.to!==ae.Internal&&(m==="entry"?p.push(S):i(S,f,n)),S;case Ve:{var P=Ut(g,f,n);return i==null||i(P,f,n),P}case vt:{var G=g,F=(E=G.conds.find(function(s){var c=xt(s.cond,t.options.guards);return!c||Tt(t,c,f,n,i?void 0:e)}))===null||E===void 0?void 0:E.actions;if(!F)return[];var H=j(Ne(t,e,f,n,[{type:m,actions:Q(W(F),t.options.actions)}],i,o),2),C=H[0],z=H[1];return f=z,l==null||l.push(f),C}case pt:{var F=g.get(f,n.data);if(!F)return[];var k=j(Ne(t,e,f,n,[{type:m,actions:Q(W(F),t.options.actions)}],i,o),2),A=k[0],N=k[1];return f=N,l==null||l.push(f),A}case Xe:{var P=Ft(g,f,n);return i==null||i(P,r,n),P}case xe:{f=At(f,n,[g],i?void 0:e),l==null||l.push(f);break}default:var q=se(g,t.options.actions),B=q.exec;if(i)i(q,f,n);else if(B&&l){var ne=l.length-1,ie=v(v({},q),{exec:function(s){for(var c=[],b=1;b<arguments.length;b++)c[b-1]=arguments[b];B.apply(void 0,I([l[ne]],j(c),!1))}});q=ie}return q}}function d(m){var g,E,y=[];try{for(var S=_(m.actions),x=S.next();!x.done;x=S.next()){var P=x.value,G=w(m.type,P);G&&(y=y.concat(G))}}catch(F){g={error:F}}finally{try{x&&!x.done&&(E=S.return)&&E.call(S)}finally{if(g)throw g.error}}return p.forEach(function(F){i(F,f,n)}),p.length=0,y}var h=M(a.map(d));return[h,f]}const Pr=Object.freeze(Object.defineProperty({__proto__:null,actionTypes:ar,after:Mt,assign:_t,cancel:Nt,choose:Or,done:ge,doneInvoke:Bt,error:Ct,escalate:xr,forwardTo:Ar,getActionFunction:Ze,initEvent:Re,isActionObject:Sr,log:br,pure:Er,raise:Dt,resolveActions:Ne,resolveLog:Ut,resolveRaise:jt,resolveSend:Rt,resolveStop:Ft,respond:mr,send:re,sendParent:et,sendTo:yr,sendUpdate:gr,start:It,stop:Lt,toActionObject:se,toActionObjects:Q,toActivityDefinition:Ue},Symbol.toStringTag,{value:"Module"}));var Ie=[],Dr=function(t,e){Ie.push(t);var r=e(t);return Ie.pop(),r},jr=function(t){return t(Ie[Ie.length-1])};function kt(t){var e;return e={id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},getSnapshot:function(){},toJSON:function(){return{id:t}}},e[Ot]=function(){return this},e}function Rr(t,e,r,n){var a,i=pr(t.src),o=(a=e==null?void 0:e.options.services)===null||a===void 0?void 0:a[i.type],u=t.data?St(t.data,r,n):void 0,f=o?$t(o,t.id,u):kt(t.id);return f.meta=t,f}function $t(t,e,r){var n=kt(e);if(n.deferred=!0,te(t)){var a=n.state=Dr(void 0,function(){return(r?t.withContext(r):t).initialState});n.getSnapshot=function(){return a}}return n}var Le=function(t){return t.type==="atomic"||t.type==="final"};function Ht(t){return Object.keys(t.states).map(function(e){return t.states[e]})}function me(t){return Ht(t).filter(function(e){return e.type!=="history"})}function qt(t){var e=[t];return Le(t)?e:e.concat(M(me(t).map(qt)))}function we(t,e){var r,n,a,i,o,u,f,l,p=new Set(t),w=tt(p),d=new Set(e);try{for(var h=_(d),m=h.next();!m.done;m=h.next())for(var g=m.value,E=g.parent;E&&!d.has(E);)d.add(E),E=E.parent}catch(z){r={error:z}}finally{try{m&&!m.done&&(n=h.return)&&n.call(h)}finally{if(r)throw r.error}}var y=tt(d);try{for(var S=_(d),x=S.next();!x.done;x=S.next()){var g=x.value;if(g.type==="compound"&&(!y.get(g)||!y.get(g).length))w.get(g)?w.get(g).forEach(function(k){return d.add(k)}):g.initialStateNodes.forEach(function(k){return d.add(k)});else if(g.type==="parallel")try{for(var P=(o=void 0,_(me(g))),G=P.next();!G.done;G=P.next()){var F=G.value;d.has(F)||(d.add(F),w.get(F)?w.get(F).forEach(function(k){return d.add(k)}):F.initialStateNodes.forEach(function(k){return d.add(k)}))}}catch(k){o={error:k}}finally{try{G&&!G.done&&(u=P.return)&&u.call(P)}finally{if(o)throw o.error}}}}catch(z){a={error:z}}finally{try{x&&!x.done&&(i=S.return)&&i.call(S)}finally{if(a)throw a.error}}try{for(var H=_(d),C=H.next();!C.done;C=H.next())for(var g=C.value,E=g.parent;E&&!d.has(E);)d.add(E),E=E.parent}catch(z){f={error:z}}finally{try{C&&!C.done&&(l=H.return)&&l.call(H)}finally{if(f)throw f.error}}return d}function Gt(t,e){var r=e.get(t);if(!r)return{};if(t.type==="compound"){var n=r[0];if(n){if(Le(n))return n.key}else return{}}var a={};return r.forEach(function(i){a[i.key]=Gt(i,e)}),a}function tt(t){var e,r,n=new Map;try{for(var a=_(t),i=a.next();!i.done;i=a.next()){var o=i.value;n.has(o)||n.set(o,[]),o.parent&&(n.has(o.parent)||n.set(o.parent,[]),n.get(o.parent).push(o))}}catch(u){e={error:u}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return n}function Ur(t,e){var r=we([t],e);return Gt(t,tt(r))}function be(t,e){return Array.isArray(t)?t.some(function(r){return r===e}):t instanceof Set?t.has(e):!1}function Nr(t){return I([],j(new Set(M(I([],j(t.map(function(e){return e.ownEvents})),!1)))),!1)}function Fe(t,e){return e.type==="compound"?me(e).some(function(r){return r.type==="final"&&be(t,r)}):e.type==="parallel"?me(e).every(function(r){return Fe(t,r)}):!1}function Ir(t){return t===void 0&&(t=[]),t.reduce(function(e,r){return r.meta!==void 0&&(e[r.id]=r.meta),e},{})}function zt(t){return new Set(M(t.map(function(e){return e.tags})))}function Xt(t,e){if(t===e)return!0;if(t===void 0||e===void 0)return!1;if(T(t)||T(e))return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(function(a){return Xt(t[a],e[a])})}var Z=function(){function t(e){var r=this,n;this.actions=[],this.activities=gt,this.meta={},this.events=[],this.value=e.value,this.context=e.context,this._event=e._event,this._sessionid=e._sessionid,this.event=this._event.data,this.historyValue=e.historyValue,this.history=e.history,this.actions=e.actions||[],this.activities=e.activities||gt,this.meta=Ir(e.configuration),this.events=e.events||[],this.matches=this.matches.bind(this),this.toStrings=this.toStrings.bind(this),this.configuration=e.configuration,this.transitions=e.transitions,this.children=e.children,this.done=!!e.done,this.tags=(n=Array.isArray(e.tags)?new Set(e.tags):e.tags)!==null&&n!==void 0?n:new Set,this.machine=e.machine,Object.defineProperty(this,"nextEvents",{get:function(){return Nr(r.configuration)}})}return t.from=function(e,r){if(e instanceof t)return e.context!==r?new t({value:e.value,context:r,_event:e._event,_sessionid:null,historyValue:e.historyValue,history:e.history,actions:[],activities:e.activities,meta:{},events:[],configuration:[],transitions:[],children:{}}):e;var n=Re;return new t({value:e,context:r,_event:n,_sessionid:null,historyValue:void 0,history:void 0,actions:[],activities:void 0,meta:void 0,events:[],configuration:[],transitions:[],children:{}})},t.create=function(e){return new t(e)},t.inert=function(e,r){if(e instanceof t){if(!e.actions.length)return e;var n=Re;return new t({value:e.value,context:r,_event:n,_sessionid:null,historyValue:e.historyValue,history:e.history,activities:e.activities,configuration:e.configuration,transitions:[],children:{}})}return t.from(e,r)},t.prototype.toStrings=function(e,r){var n=this;if(e===void 0&&(e=this.value),r===void 0&&(r="."),T(e))return[e];var a=Object.keys(e);return a.concat.apply(a,I([],j(a.map(function(i){return n.toStrings(e[i],r).map(function(o){return i+r+o})})),!1))},t.prototype.toJSON=function(){var e=this;e.configuration,e.transitions;var r=e.tags;e.machine;var n=Ge(e,["configuration","transitions","tags","machine"]);return v(v({},n),{tags:Array.from(r)})},t.prototype.matches=function(e){return We(e,this.value)},t.prototype.hasTag=function(e){return this.tags.has(e)},t.prototype.can=function(e){var r;J&&K(!!this.machine,"state.can(...) used outside of a machine-created State object; this will always return false.");var n=(r=this.machine)===null||r===void 0?void 0:r.getTransitionData(this,e);return!!(n!=null&&n.transitions.length)&&n.transitions.some(function(a){return a.target!==void 0||a.actions.length})},t}(),Vt={sync:!1,autoForward:!1},Jt;(function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped"})(Jt||(Jt={}));var Lr=function(t){return T(t)?v(v({},Vt),{name:t}):v(v(v({},Vt),{name:hr()}),t)};function Fr(t,e){var r=Lr(e);return jr(function(n){if(!J){var a=te(t)||L(t);K(!!n||a,'Attempted to spawn an Actor (ID: "'.concat(te(t)?t.id:"undefined",'") outside of a service. This will have no effect.'))}return n?n.spawn(t,r.name,r):$t(t,r.name)})}function _r(t){if(typeof t=="string"){var e={type:t};return e.toString=function(){return t},e}return t}function _e(t){return v(v({type:Oe},t),{toJSON:function(){t.onDone,t.onError;var e=Ge(t,["onDone","onError"]);return v(v({},e),{type:Oe,src:_r(t.src)})}})}var ue="",rt="#",Se="*",fe={},le=function(t){return t[0]===rt},Mr=function(){return{actions:{},guards:{},services:{},activities:{},delays:{}}},Br=function(t,e,r){var n=r.slice(0,-1).some(function(i){return!("cond"in i)&&!("in"in i)&&(T(i.target)||te(i.target))}),a=e===ue?"the transient event":"event '".concat(e,"'");K(!n,"One or more transitions for ".concat(a," on state '").concat(t.id,"' are unreachable. ")+"Make sure that the default transition is the last one defined.")},Cr=function(){function t(e,r,n,a){n===void 0&&(n="context"in e?e.context:void 0);var i=this,o;this.config=e,this._context=n,this.order=-1,this.__xstatenode=!0,this.__cache={events:void 0,relativeValue:new Map,initialStateValue:void 0,initialState:void 0,on:void 0,transitions:void 0,candidates:{},delayedTransitions:void 0},this.idMap={},this.tags=[],this.options=Object.assign(Mr(),r),this.parent=a==null?void 0:a.parent,this.key=this.config.key||(a==null?void 0:a.key)||this.config.id||"(machine)",this.machine=this.parent?this.parent.machine:this,this.path=this.parent?this.parent.path.concat(this.key):[],this.delimiter=this.config.delimiter||(this.parent?this.parent.delimiter:yt),this.id=this.config.id||I([this.machine.key],j(this.path),!1).join(this.delimiter),this.version=this.parent?this.parent.version:this.config.version,this.type=this.config.type||(this.config.parallel?"parallel":this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.schema=this.parent?this.machine.schema:(o=this.config.schema)!==null&&o!==void 0?o:{},this.description=this.config.description,J||K(!("parallel"in this.config),'The "parallel" property is deprecated and will be removed in version 4.1. '.concat(this.config.parallel?"Replace with `type: 'parallel'`":"Use `type: '".concat(this.type,"'`")," in the config for state node '").concat(this.id,"' instead.")),this.initial=this.config.initial,this.states=this.config.states?ve(this.config.states,function(l,p){var w,d=new t(l,{},void 0,{parent:i,key:p});return Object.assign(i.idMap,v((w={},w[d.id]=d,w),d.idMap)),d}):fe;var u=0;function f(l){var p,w;l.order=u++;try{for(var d=_(Ht(l)),h=d.next();!h.done;h=d.next()){var m=h.value;f(m)}}catch(g){p={error:g}}finally{try{h&&!h.done&&(w=d.return)&&w.call(d)}finally{if(p)throw p.error}}}f(this),this.history=this.config.history===!0?"shallow":this.config.history||!1,this._transient=!!this.config.always||(this.config.on?Array.isArray(this.config.on)?this.config.on.some(function(l){var p=l.event;return p===ue}):ue in this.config.on:!1),this.strict=!!this.config.strict,this.onEntry=W(this.config.entry||this.config.onEntry).map(function(l){return se(l)}),this.onExit=W(this.config.exit||this.config.onExit).map(function(l){return se(l)}),this.meta=this.config.meta,this.doneData=this.type==="final"?this.config.data:void 0,this.invoke=W(this.config.invoke).map(function(l,p){var w,d;if(te(l)){var h=je(i.id,p);return i.machine.options.services=v((w={},w[h]=l,w),i.machine.options.services),_e({src:h,id:h})}else if(T(l.src)){var h=l.id||je(i.id,p);return _e(v(v({},l),{id:h,src:l.src}))}else if(te(l.src)||L(l.src)){var h=l.id||je(i.id,p);return i.machine.options.services=v((d={},d[h]=l.src,d),i.machine.options.services),_e(v(v({id:h},l),{src:h}))}else{var m=l.src;return _e(v(v({id:je(i.id,p)},l),{src:m}))}}),this.activities=W(this.config.activities).concat(this.invoke).map(function(l){return Ue(l)}),this.transition=this.transition.bind(this),this.tags=W(this.config.tags)}return t.prototype._init=function(){this.__cache.transitions||qt(this).forEach(function(e){return e.on})},t.prototype.withConfig=function(e,r){var n=this.options,a=n.actions,i=n.activities,o=n.guards,u=n.services,f=n.delays;return new t(this.config,{actions:v(v({},a),e.actions),activities:v(v({},i),e.activities),guards:v(v({},o),e.guards),services:v(v({},u),e.services),delays:v(v({},f),e.delays)},r!=null?r:this.context)},t.prototype.withContext=function(e){return new t(this.config,this.options,e)},Object.defineProperty(t.prototype,"context",{get:function(){return L(this._context)?this._context():this._context},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"definition",{get:function(){return{id:this.id,key:this.key,version:this.version,context:this.context,type:this.type,initial:this.initial,history:this.history,states:ve(this.states,function(e){return e.definition}),on:this.on,transitions:this.transitions,entry:this.onEntry,exit:this.onExit,activities:this.activities||[],meta:this.meta,order:this.order||-1,data:this.doneData,invoke:this.invoke,description:this.description,tags:this.tags}},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return this.definition},Object.defineProperty(t.prototype,"on",{get:function(){if(this.__cache.on)return this.__cache.on;var e=this.transitions;return this.__cache.on=e.reduce(function(r,n){return r[n.eventType]=r[n.eventType]||[],r[n.eventType].push(n),r},{})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),t.prototype.getCandidates=function(e){if(this.__cache.candidates[e])return this.__cache.candidates[e];var r=e===ue,n=this.transitions.filter(function(a){var i=a.eventType===e;return r?i:i||a.eventType===Se});return this.__cache.candidates[e]=n,n},t.prototype.getDelayedTransitions=function(){var e=this,r=this.config.after;if(!r)return[];var n=function(i,o){var u=L(i)?"".concat(e.id,":delay[").concat(o,"]"):i,f=Mt(u,e.id);return e.onEntry.push(re(f,{delay:i})),e.onExit.push(Nt(f)),f},a=pe(r)?r.map(function(i,o){var u=n(i.delay,o);return v(v({},i),{event:u})}):M(Object.keys(r).map(function(i,o){var u=r[i],f=T(u)?{target:u}:u,l=isNaN(+i)?i:+i,p=n(l,o);return W(f).map(function(w){return v(v({},w),{event:p,delay:l})})}));return a.map(function(i){var o=i.delay;return v(v({},e.formatTransition(i)),{delay:o})})},t.prototype.getStateNodes=function(e){var r,n=this;if(!e)return[];var a=e instanceof Z?e.value:he(e,this.delimiter);if(T(a)){var i=this.getStateNode(a).initial;return i!==void 0?this.getStateNodes((r={},r[a]=i,r)):[this,this.states[a]]}var o=Object.keys(a),u=[this];return u.push.apply(u,I([],j(M(o.map(function(f){return n.getStateNode(f).getStateNodes(a[f])}))),!1)),u},t.prototype.handles=function(e){var r=mt(e);return this.events.includes(r)},t.prototype.resolveState=function(e){var r=e instanceof Z?e:Z.create(e),n=Array.from(we([],this.getStateNodes(r.value)));return new Z(v(v({},r),{value:this.resolve(r.value),configuration:n,done:Fe(n,this),tags:zt(n),machine:this.machine}))},t.prototype.transitionLeafNode=function(e,r,n){var a=this.getStateNode(e),i=a.next(r,n);return!i||!i.transitions.length?this.next(r,n):i},t.prototype.transitionCompoundNode=function(e,r,n){var a=Object.keys(e),i=this.getStateNode(a[0]),o=i._transition(e[a[0]],r,n);return!o||!o.transitions.length?this.next(r,n):o},t.prototype.transitionParallelNode=function(e,r,n){var a,i,o={};try{for(var u=_(Object.keys(e)),f=u.next();!f.done;f=u.next()){var l=f.value,p=e[l];if(p){var w=this.getStateNode(l),d=w._transition(p,r,n);d&&(o[l]=d)}}}catch(y){a={error:y}}finally{try{f&&!f.done&&(i=u.return)&&i.call(u)}finally{if(a)throw a.error}}var h=Object.keys(o).map(function(y){return o[y]}),m=M(h.map(function(y){return y.transitions})),g=h.some(function(y){return y.transitions.length>0});if(!g)return this.next(r,n);var E=M(Object.keys(o).map(function(y){return o[y].configuration}));return{transitions:m,exitSet:M(h.map(function(y){return y.exitSet})),configuration:E,source:r,actions:M(Object.keys(o).map(function(y){return o[y].actions}))}},t.prototype._transition=function(e,r,n){return T(e)?this.transitionLeafNode(e,r,n):Object.keys(e).length===1?this.transitionCompoundNode(e,r,n):this.transitionParallelNode(e,r,n)},t.prototype.getTransitionData=function(e,r){return this._transition(e.value,e,ye(r))},t.prototype.next=function(e,r){var n,a,i=this,o=r.name,u=[],f=[],l;try{for(var p=_(this.getCandidates(o)),w=p.next();!w.done;w=p.next()){var d=w.value,h=d.cond,m=d.in,g=e.context,E=m?T(m)&&le(m)?e.matches(he(this.getStateNodeById(m).path,this.delimiter)):We(he(m,this.delimiter),ur(this.path.slice(0,-2))(e.value)):!0,y=!1;try{y=!h||Tt(this.machine,h,g,r,e)}catch(P){throw new Error("Unable to evaluate guard '".concat(h.name||h.type,"' in transition for event '").concat(o,"' in state node '").concat(this.id,`':
`).concat(P.message))}if(y&&E){d.target!==void 0&&(f=d.target),u.push.apply(u,I([],j(d.actions),!1)),l=d;break}}}catch(P){n={error:P}}finally{try{w&&!w.done&&(a=p.return)&&a.call(p)}finally{if(n)throw n.error}}if(l){if(!f.length)return{transitions:[l],exitSet:[],configuration:e.value?[this]:[],source:e,actions:u};var S=M(f.map(function(P){return i.getRelativeStateNodes(P,e.historyValue)})),x=!!l.internal;return{transitions:[l],exitSet:x?[]:M(f.map(function(P){return i.getPotentiallyReenteringNodes(P)})),configuration:S,source:e,actions:u}}},t.prototype.getPotentiallyReenteringNodes=function(e){if(this.order<e.order)return[this];for(var r=[],n=this,a=e;n&&n!==a;)r.push(n),n=n.parent;return n!==a?[]:(r.push(a),r)},t.prototype.getActions=function(e,r,n,a,i,o,u){var f,l,p,w,d=this,h=o?we([],this.getStateNodes(o.value)):[],m=new Set;try{for(var g=_(Array.from(e).sort(function(A,N){return A.order-N.order})),E=g.next();!E.done;E=g.next()){var y=E.value;(!be(h,y)||be(n.exitSet,y)||y.parent&&m.has(y.parent))&&m.add(y)}}catch(A){f={error:A}}finally{try{E&&!E.done&&(l=g.return)&&l.call(g)}finally{if(f)throw f.error}}try{for(var S=_(h),x=S.next();!x.done;x=S.next()){var y=x.value;(!be(e,y)||be(n.exitSet,y.parent))&&n.exitSet.push(y)}}catch(A){p={error:A}}finally{try{x&&!x.done&&(w=S.return)&&w.call(S)}finally{if(p)throw p.error}}n.exitSet.sort(function(A,N){return N.order-A.order});var P=Array.from(m).sort(function(A,N){return A.order-N.order}),G=new Set(n.exitSet),F=M(P.map(function(A){var N=[];if(A.type!=="final")return N;var q=A.parent;if(!q.parent)return N;N.push(ge(A.id,A.doneData),ge(q.id,A.doneData?St(A.doneData,a,i):void 0));var B=q.parent;return B.type==="parallel"&&me(B).every(function(ne){return Fe(n.configuration,ne)})&&N.push(ge(B.id)),N})),H=P.map(function(A){var N=A.onEntry,q=A.activities.map(function(B){return It(B)});return{type:"entry",actions:Q(u?I(I([],j(N),!1),j(q),!1):I(I([],j(q),!1),j(N),!1),d.machine.options.actions)}}).concat({type:"state_done",actions:F.map(function(A){return Dt(A)})}),C=Array.from(G).map(function(A){return{type:"exit",actions:Q(I(I([],j(A.onExit),!1),j(A.activities.map(function(N){return Lt(N)})),!1),d.machine.options.actions)}}),z=C.concat({type:"transition",actions:Q(n.actions,this.machine.options.actions)}).concat(H);if(r){var k=Q(M(I([],j(e),!1).sort(function(A,N){return N.order-A.order}).map(function(A){return A.onExit})),this.machine.options.actions).filter(function(A){return!Pt(A)});return z.concat({type:"stop",actions:k})}return z},t.prototype.transition=function(e,r,n,a){e===void 0&&(e=this.initialState);var i=ye(r),o;if(e instanceof Z)o=n===void 0?e:this.resolveState(Z.from(e,n));else{var u=T(e)?this.resolve(Pe(this.getResolvedPath(e))):this.resolve(e),f=n!=null?n:this.machine.context;o=this.resolveState(Z.from(u,f))}if(!J&&i.name===Se)throw new Error("An event cannot have the wildcard type ('".concat(Se,"')"));if(this.strict&&!this.events.includes(i.name)&&!lr(i.name))throw new Error("Machine '".concat(this.id,"' does not accept event '").concat(i.name,"'"));var l=this._transition(o.value,o,i)||{transitions:[],configuration:[],exitSet:[],source:o,actions:[]},p=we([],this.getStateNodes(o.value)),w=l.configuration.length?we(p,l.configuration):p;return l.configuration=I([],j(w),!1),this.resolveTransition(l,o,o.context,a,i)},t.prototype.resolveRaisedTransition=function(e,r,n,a){var i,o=e.actions;return e=this.transition(e,r,void 0,a),e._event=n,e.event=n.data,(i=e.actions).unshift.apply(i,I([],j(o),!1)),e},t.prototype.resolveTransition=function(e,r,n,a,i){var o,u,f,l,p=this;i===void 0&&(i=Re);var w=e.configuration,d=!r||e.transitions.length>0,h=d?e.configuration:r?r.configuration:[],m=Fe(h,this),g=d?Ur(this.machine,w):void 0,E=r?r.historyValue?r.historyValue:e.source?this.machine.historyValue(r.value):void 0:void 0,y=this.getActions(new Set(h),m,e,n,i,r,a),S=r?v({},r.activities):{};try{for(var x=_(y),P=x.next();!P.done;P=x.next()){var G=P.value;try{for(var F=(f=void 0,_(G.actions)),H=F.next();!H.done;H=F.next()){var C=H.value;C.type===ze?S[C.activity.id||C.activity.type]=C:C.type===Xe&&(S[C.activity.id||C.activity.type]=!1)}}catch(Y){f={error:Y}}finally{try{H&&!H.done&&(l=F.return)&&l.call(F)}finally{if(f)throw f.error}}}}catch(Y){o={error:Y}}finally{try{P&&!P.done&&(u=x.return)&&u.call(x)}finally{if(o)throw o.error}}var z=j(Ne(this,r,n,i,y,a,this.machine.config.predictableActionArguments||this.machine.config.preserveActionOrder),2),k=z[0],A=z[1],N=j(cr(k,Pt),2),q=N[0],B=N[1],ne=k.filter(function(Y){var $;return Y.type===ze&&(($=Y.activity)===null||$===void 0?void 0:$.type)===Oe}),ie=ne.reduce(function(Y,$){return Y[$.activity.id]=Rr($.activity,p.machine,A,i),Y},r?v({},r.children):{}),s=new Z({value:g||r.value,context:A,_event:i,_sessionid:r?r._sessionid:null,historyValue:g?E?dr(E,g):void 0:r?r.historyValue:void 0,history:!g||e.source?r:void 0,actions:g?B:[],activities:g?S:r?r.activities:{},events:[],configuration:h,transitions:e.transitions,children:ie,done:m,tags:zt(h),machine:this}),c=n!==A;s.changed=i.name===Je||c;var b=s.history;b&&delete b.history;var U=!m&&(this._transient||w.some(function(Y){return Y._transient}));if(!d&&(!U||i.name===ue))return s;var O=s;if(!m)for(U&&(O=this.resolveRaisedTransition(O,{type:ct},i,a));q.length;){var D=q.shift();O=this.resolveRaisedTransition(O,D._event,i,a)}var ce=O.changed||(b?!!O.actions.length||c||typeof b.value!=typeof O.value||!Xt(O.value,b.value):void 0);return O.changed=ce,O.history=b,O},t.prototype.getStateNode=function(e){if(le(e))return this.machine.getStateNodeById(e);if(!this.states)throw new Error("Unable to retrieve child state '".concat(e,"' from '").concat(this.id,"'; no child states exist."));var r=this.states[e];if(!r)throw new Error("Child state '".concat(e,"' does not exist on '").concat(this.id,"'"));return r},t.prototype.getStateNodeById=function(e){var r=le(e)?e.slice(rt.length):e;if(r===this.id)return this;var n=this.machine.idMap[r];if(!n)throw new Error("Child state node '#".concat(r,"' does not exist on machine '").concat(this.id,"'"));return n},t.prototype.getStateNodeByPath=function(e){if(typeof e=="string"&&le(e))try{return this.getStateNodeById(e.slice(1))}catch{}for(var r=Ke(e,this.delimiter).slice(),n=this;r.length;){var a=r.shift();if(!a.length)break;n=n.getStateNode(a)}return n},t.prototype.resolve=function(e){var r,n=this;if(!e)return this.initialStateValue||fe;switch(this.type){case"parallel":return ve(this.initialStateValue,function(i,o){return i?n.getStateNode(o).resolve(e[o]||i):fe});case"compound":if(T(e)){var a=this.getStateNode(e);return a.type==="parallel"||a.type==="compound"?(r={},r[e]=a.initialStateValue,r):e}return Object.keys(e).length?ve(e,function(i,o){return i?n.getStateNode(o).resolve(i):fe}):this.initialStateValue||{};default:return e||fe}},t.prototype.getResolvedPath=function(e){if(le(e)){var r=this.machine.idMap[e.slice(rt.length)];if(!r)throw new Error("Unable to find state node '".concat(e,"'"));return r.path}return Ke(e,this.delimiter)},Object.defineProperty(t.prototype,"initialStateValue",{get:function(){var e;if(this.__cache.initialStateValue)return this.__cache.initialStateValue;var r;if(this.type==="parallel")r=wt(this.states,function(n){return n.initialStateValue||fe},function(n){return n.type!=="history"});else if(this.initial!==void 0){if(!this.states[this.initial])throw new Error("Initial state '".concat(this.initial,"' not found on '").concat(this.key,"'"));r=Le(this.states[this.initial])?this.initial:(e={},e[this.initial]=this.states[this.initial].initialStateValue,e)}else r={};return this.__cache.initialStateValue=r,this.__cache.initialStateValue},enumerable:!1,configurable:!0}),t.prototype.getInitialState=function(e,r){this._init();var n=this.getStateNodes(e);return this.resolveTransition({configuration:n,exitSet:[],transitions:[],source:void 0,actions:[]},void 0,r!=null?r:this.machine.context,void 0)},Object.defineProperty(t.prototype,"initialState",{get:function(){var e=this.initialStateValue;if(!e)throw new Error("Cannot retrieve initial state from simple state '".concat(this.id,"'."));return this.getInitialState(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){var e;if(this.type==="history"){var r=this.config;T(r.target)?e=le(r.target)?Pe(this.machine.getStateNodeById(r.target).path.slice(this.path.length-1)):r.target:e=r.target}return e},enumerable:!1,configurable:!0}),t.prototype.getRelativeStateNodes=function(e,r,n){return n===void 0&&(n=!0),n?e.type==="history"?e.resolveHistory(r):e.initialStateNodes:[e]},Object.defineProperty(t.prototype,"initialStateNodes",{get:function(){var e=this;if(Le(this))return[this];if(this.type==="compound"&&!this.initial)return J||K(!1,"Compound state node '".concat(this.id,"' has no initial state.")),[this];var r=De(this.initialStateValue);return M(r.map(function(n){return e.getFromRelativePath(n)}))},enumerable:!1,configurable:!0}),t.prototype.getFromRelativePath=function(e){if(!e.length)return[this];var r=j(e),n=r[0],a=r.slice(1);if(!this.states)throw new Error("Cannot retrieve subPath '".concat(n,"' from node with no states"));var i=this.getStateNode(n);if(i.type==="history")return i.resolveHistory();if(!this.states[n])throw new Error("Child state '".concat(n,"' does not exist on '").concat(this.id,"'"));return this.states[n].getFromRelativePath(a)},t.prototype.historyValue=function(e){if(Object.keys(this.states).length)return{current:e||this.initialStateValue,states:wt(this.states,function(r,n){if(!e)return r.historyValue();var a=T(e)?void 0:e[n];return r.historyValue(a||r.initialStateValue)},function(r){return!r.history})}},t.prototype.resolveHistory=function(e){var r=this;if(this.type!=="history")return[this];var n=this.parent;if(!e){var a=this.target;return a?M(De(a).map(function(o){return n.getFromRelativePath(o)})):n.initialStateNodes}var i=fr(n.path,"states")(e).current;return T(i)?[n.getStateNode(i)]:M(De(i).map(function(o){return r.history==="deep"?n.getFromRelativePath(o):[n.states[o[0]]]}))},Object.defineProperty(t.prototype,"stateIds",{get:function(){var e=this,r=M(Object.keys(this.states).map(function(n){return e.states[n].stateIds}));return[this.id].concat(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"events",{get:function(){var e,r,n,a;if(this.__cache.events)return this.__cache.events;var i=this.states,o=new Set(this.ownEvents);if(i)try{for(var u=_(Object.keys(i)),f=u.next();!f.done;f=u.next()){var l=f.value,p=i[l];if(p.states)try{for(var w=(n=void 0,_(p.events)),d=w.next();!d.done;d=w.next()){var h=d.value;o.add("".concat(h))}}catch(m){n={error:m}}finally{try{d&&!d.done&&(a=w.return)&&a.call(w)}finally{if(n)throw n.error}}}}catch(m){e={error:m}}finally{try{f&&!f.done&&(r=u.return)&&r.call(u)}finally{if(e)throw e.error}}return this.__cache.events=Array.from(o)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ownEvents",{get:function(){var e=new Set(this.transitions.filter(function(r){return!(!r.target&&!r.actions.length&&r.internal)}).map(function(r){return r.eventType}));return Array.from(e)},enumerable:!1,configurable:!0}),t.prototype.resolveTarget=function(e){var r=this;if(e!==void 0)return e.map(function(n){if(!T(n))return n;var a=n[0]===r.delimiter;if(a&&!r.parent)return r.getStateNodeByPath(n.slice(1));var i=a?r.key+n:n;if(r.parent)try{var o=r.parent.getStateNodeByPath(i);return o}catch(u){throw new Error("Invalid transition definition for state node '".concat(r.id,`':
`).concat(u.message))}else return r.getStateNodeByPath(i)})},t.prototype.formatTransition=function(e){var r=this,n=vr(e.target),a="internal"in e?e.internal:n?n.some(function(f){return T(f)&&f[0]===r.delimiter}):!0,i=this.machine.options.guards,o=this.resolveTarget(n),u=v(v({},e),{actions:Q(W(e.actions)),cond:xt(e.cond,i),target:o,source:this,internal:a,eventType:e.event,toJSON:function(){return v(v({},u),{target:u.target?u.target.map(function(f){return"#".concat(f.id)}):void 0,source:"#".concat(r.id)})}});return u},t.prototype.formatTransitions=function(){var e,r,n=this,a;if(!this.config.on)a=[];else if(Array.isArray(this.config.on))a=this.config.on;else{var i=this.config.on,o=Se,u=i[o],f=u===void 0?[]:u,l=Ge(i,[typeof o=="symbol"?o:o+""]);a=M(Object.keys(l).map(function(S){!J&&S===ue&&K(!1,"Empty string transition configs (e.g., `{ on: { '': ... }}`) for transient transitions are deprecated. Specify the transition in the `{ always: ... }` property instead. "+'Please check the `on` configuration for "#'.concat(n.id,'".'));var x=oe(S,l[S]);return J||Br(n,S,x),x}).concat(oe(Se,f)))}var p=this.config.always?oe("",this.config.always):[],w=this.config.onDone?oe(String(ge(this.id)),this.config.onDone):[];J||K(!(this.config.onDone&&!this.parent),'Root nodes cannot have an ".onDone" transition. Please check the config of "'.concat(this.id,'".'));var d=M(this.invoke.map(function(S){var x=[];return S.onDone&&x.push.apply(x,I([],j(oe(String(Bt(S.id)),S.onDone)),!1)),S.onError&&x.push.apply(x,I([],j(oe(String(Ct(S.id)),S.onError)),!1)),x})),h=this.after,m=M(I(I(I(I([],j(w),!1),j(d),!1),j(a),!1),j(p),!1).map(function(S){return W(S).map(function(x){return n.formatTransition(x)})}));try{for(var g=_(h),E=g.next();!E.done;E=g.next()){var y=E.value;m.push(y)}}catch(S){e={error:S}}finally{try{E&&!E.done&&(r=g.return)&&r.call(g)}finally{if(e)throw e.error}}return m},t}(),Yt=!1;function Wt(t,e){return!J&&!("predictableActionArguments"in t)&&!Yt&&(Yt=!0,console.warn("It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html")),new Cr(t,e)}var X=_t,nt=re;let it;typeof it=="undefined"&&(it=$e);const Me={progress:null,loaded:0,error:null,bucketId:void 0,file:void 0,id:void 0},Kt=()=>Wt({predictableActionArguments:!0,schema:{context:{},events:{}},tsTypes:{},context:{...Me},initial:"idle",on:{DESTROY:{actions:"sendDestroy",target:"stopped"}},states:{idle:{on:{ADD:{actions:"addFile"},UPLOAD:{cond:"hasFile",target:"uploading"}}},uploading:{entry:"resetProgress",on:{UPLOAD_PROGRESS:{actions:["incrementProgress","sendProgress"]},UPLOAD_DONE:"uploaded",UPLOAD_ERROR:"error",CANCEL:"idle"},invoke:{src:"uploadFile"}},uploaded:{entry:["setFileMetadata","sendDone"],on:{ADD:{actions:"addFile",target:"idle"},UPLOAD:{actions:"resetContext",target:"uploading"}}},error:{entry:["setError","sendError"],on:{ADD:{actions:"addFile",target:"idle"},UPLOAD:{actions:"resetContext",target:"uploading"}}},stopped:{type:"final"}}},{guards:{hasFile:(t,e)=>!!t.file||!!e.file},actions:{incrementProgress:X({loaded:(t,{loaded:e})=>e,progress:(t,{progress:e})=>e}),setFileMetadata:X({id:(t,{id:e})=>e,bucketId:(t,{bucketId:e})=>e,progress:t=>100}),setError:X({error:(t,{error:e})=>e}),sendProgress:()=>{},sendError:()=>{},sendDestroy:()=>{},sendDone:()=>{},resetProgress:X({progress:t=>null,loaded:t=>0}),resetContext:X(t=>Me),addFile:X({file:(t,{file:e})=>e,bucketId:(t,{bucketId:e})=>e,id:(t,{id:e})=>e})},services:{uploadFile:(t,e)=>r=>{const n=e.file||t.file,a=new it;a.append("file[]",n);let i=0;return He(e.url,a,{fileId:e.id||t.id,bucketId:e.bucketId||t.bucketId,accessToken:e.accessToken,adminSecret:e.adminSecret,name:e.name||n.name,onUploadProgress:o=>{const u=o.total?Math.round(o.loaded*n.size/o.total):0,f=u-i;i=u,r({type:"UPLOAD_PROGRESS",progress:o.total?Math.round(u*100/o.total):0,loaded:u,additions:f})}}).then(({fileMetadata:o,error:u})=>{if(u&&r({type:"UPLOAD_ERROR",error:u}),o&&!("processedFiles"in o)){const{id:f,bucketId:l}=o;r({type:"UPLOAD_DONE",id:f,bucketId:l})}if(o&&"processedFiles"in o){const{id:f,bucketId:l}=o.processedFiles[0];r({type:"UPLOAD_DONE",id:f,bucketId:l})}}),()=>{}}}}),{pure:at,sendParent:Be}=Pr,kr=()=>Wt({id:"files-list",schema:{context:{},events:{}},tsTypes:{},predictableActionArguments:!0,context:{progress:null,files:[],loaded:0,total:0},initial:"idle",on:{UPLOAD:{cond:"hasFileToDownload",actions:"addItem",target:"uploading"},ADD:{actions:"addItem"},REMOVE:{actions:"removeItem"}},states:{idle:{entry:["resetProgress","resetLoaded","resetTotal"],on:{CLEAR:{actions:"clearList",target:"idle"}}},uploading:{entry:["upload","startProgress","resetLoaded","resetTotal"],on:{UPLOAD_PROGRESS:{actions:["incrementProgress"]},UPLOAD_DONE:[{cond:"isAllUploaded",target:"uploaded"},{cond:"isAllUploadedOrError",target:"error"}],UPLOAD_ERROR:[{cond:"isAllUploaded",target:"uploaded"},{cond:"isAllUploadedOrError",target:"error"}],CANCEL:{actions:"cancel",target:"idle"}}},uploaded:{entry:"setUploaded",on:{CLEAR:{actions:"clearList",target:"idle"}}},error:{on:{CLEAR:{actions:"clearList",target:"idle"}}}}},{guards:{hasFileToDownload:(t,e)=>t.files.some(r=>r.getSnapshot().matches("idle"))||!!e.files,isAllUploaded:t=>t.files.every(e=>{var r;return(r=e.getSnapshot())==null?void 0:r.matches("uploaded")}),isAllUploadedOrError:t=>t.files.every(e=>{const r=e.getSnapshot();return(r==null?void 0:r.matches("error"))||(r==null?void 0:r.matches("uploaded"))})},actions:{incrementProgress:X((t,e)=>{const r=t.loaded+e.additions,n=Math.round(r*100/t.total);return{...t,loaded:r,progress:n}}),setUploaded:X({progress:t=>100,loaded:({files:t})=>t.map(e=>e.getSnapshot()).filter(e=>e.matches("uploaded")).reduce((e,r)=>{var n;return e+((n=r.context.file)==null?void 0:n.size)},0)}),resetTotal:X({total:({files:t})=>t.map(e=>e.getSnapshot()).filter(e=>!e.matches("uploaded")).reduce((e,r)=>{var n;return e+((n=r.context.file)==null?void 0:n.size)},0)}),resetLoaded:X({loaded:t=>0}),startProgress:X({progress:t=>0}),resetProgress:X({progress:t=>null}),addItem:X((t,{files:e,bucketId:r})=>{const n=e?Array.isArray(e)?e:"item"in e?Array.from(e):[e]:[],a=t.total+n.reduce((o,u)=>o+u.size,0),i=Math.round(t.loaded*100/a);return{files:[...t.files,...n.map(o=>Fr(Kt().withConfig({actions:{sendProgress:Be((u,{additions:f})=>({type:"UPLOAD_PROGRESS",additions:f})),sendDone:Be("UPLOAD_DONE"),sendError:Be("UPLOAD_ERROR"),sendDestroy:Be("REMOVE")}}).withContext({...Me,file:o,bucketId:r}),{sync:!0}))],total:a,loaded:t.loaded,progress:i}}),removeItem:X({files:t=>t.files.filter(e=>{var n,a;const r=(n=e.getSnapshot())==null?void 0:n.matches("stopped");return r&&((a=e.stop)==null||a.call(e)),!r})}),clearList:at(t=>t.files.map(e=>nt({type:"DESTROY"},{to:e.id}))),upload:at((t,e)=>t.files.map(r=>nt(e,{to:r.id}))),cancel:at(t=>t.files.map(e=>nt({type:"CANCEL"},{to:e.id})))}}),$r=async(t,e)=>new Promise(r=>{e.send({type:"UPLOAD",...t}),e.subscribe(n=>{var a;n.matches("error")?r({error:n.context.error,isError:!0,isUploaded:!1}):n.matches("uploaded")&&r({error:null,isError:!1,isUploaded:!0,id:n.context.id,bucketId:n.context.id,name:(a=n.context.file)==null?void 0:a.name})})}),Hr=async(t,e)=>new Promise(r=>{e.send({type:"UPLOAD",...t,files:t.files}),e.onTransition(n=>{n.matches("error")?r({errors:n.context.files.filter(a=>{var i;return(i=a.getSnapshot())==null?void 0:i.context.error}),isError:!0,files:[]}):n.matches("uploaded")&&r({errors:[],isError:!1,files:n.context.files})})});V.HasuraStorageApi=ft,V.HasuraStorageClient=er,V.INITIAL_FILE_CONTEXT=Me,V.appendImageTransformationParameters=qe,V.createFileUploadMachine=Kt,V.createMultipleFilesUploadMachine=kr,V.uploadFilePromise=$r,V.uploadMultipleFilesPromise=Hr,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=hasura-storage-js.umd.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc