@sanity/client 6.6.0 → 6.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.browser.cjs +3 -2
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +3 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/data/dataMethods.ts +3 -2
- package/src/types.ts +1 -1
- package/umd/sanityClient.js +3 -2
- package/umd/sanityClient.min.js +1 -1
package/package.json
CHANGED
package/src/data/dataMethods.ts
CHANGED
|
@@ -323,8 +323,9 @@ export function _requestObservable<R>(
|
|
|
323
323
|
['GET', 'HEAD', 'POST'].indexOf(options.method || 'GET') >= 0 &&
|
|
324
324
|
uri.indexOf('/data/query/') === 0
|
|
325
325
|
) {
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
const resultSourceMap = options.resultSourceMap ?? config.resultSourceMap
|
|
327
|
+
if (resultSourceMap !== undefined && resultSourceMap !== false) {
|
|
328
|
+
options.query = {resultSourceMap, ...options.query}
|
|
328
329
|
}
|
|
329
330
|
const perspective = options.perspective || config.perspective
|
|
330
331
|
if (typeof perspective === 'string' && perspective !== 'raw') {
|
package/src/types.ts
CHANGED
|
@@ -84,7 +84,7 @@ export interface ClientConfig {
|
|
|
84
84
|
/**
|
|
85
85
|
* Adds a `resultSourceMap` key to the API response, with the type `ContentSourceMap`
|
|
86
86
|
*/
|
|
87
|
-
resultSourceMap?: boolean
|
|
87
|
+
resultSourceMap?: boolean | 'withKeyArraySelector'
|
|
88
88
|
/**
|
|
89
89
|
*@deprecated set `cache` and `next` options on `client.fetch` instead
|
|
90
90
|
*/
|
package/umd/sanityClient.js
CHANGED
|
@@ -3112,9 +3112,10 @@
|
|
|
3112
3112
|
};
|
|
3113
3113
|
}
|
|
3114
3114
|
if (["GET", "HEAD", "POST"].indexOf(options.method || "GET") >= 0 && uri.indexOf("/data/query/") === 0) {
|
|
3115
|
-
|
|
3115
|
+
const resultSourceMap = (_a = options.resultSourceMap) != null ? _a : config.resultSourceMap;
|
|
3116
|
+
if (resultSourceMap !== void 0 && resultSourceMap !== false) {
|
|
3116
3117
|
options.query = {
|
|
3117
|
-
resultSourceMap
|
|
3118
|
+
resultSourceMap,
|
|
3118
3119
|
...options.query
|
|
3119
3120
|
};
|
|
3120
3121
|
}
|
package/umd/sanityClient.min.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
6
6
|
* Released under the MIT License.
|
|
7
7
|
*/
|
|
8
|
-
function P(e){return"[object Object]"===Object.prototype.toString.call(e)}!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=I(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(M,M.exports);const D="undefined"==typeof Buffer?()=>!1:e=>Buffer.isBuffer(e),q=["boolean","string","number"];function N(){return{processOptions:e=>{const t=e.body;if(!t)return e;var r,n,o;return!("function"==typeof t.pipe)&&!D(t)&&(-1!==q.indexOf(typeof t)||Array.isArray(t)||!1!==P(r=t)&&(void 0===(n=r.constructor)||!1!==P(o=n.prototype)&&!1!==o.hasOwnProperty("isPrototypeOf")))?Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})}):e}}}function H(e){return{onResponse:r=>{const n=r.headers["content-type"]||"",o=e&&e.force||-1!==n.indexOf("application/json");return r.body&&n&&o?Object.assign({},r,{body:t(r.body)}):r},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message="Failed to parsed response body as JSON: ".concat(e.message),e}}}let W={};"undefined"!=typeof globalThis?W=globalThis:"undefined"!=typeof window?W=window:"undefined"!=typeof global?W=global:"undefined"!=typeof self&&(W=self);var z=W;function U(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).implementation||z.Observable;if(!e)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(t,r)=>new e((e=>(t.error.subscribe((t=>e.error(t))),t.progress.subscribe((t=>e.next(Object.assign({type:"progress"},t)))),t.response.subscribe((t=>{e.next(Object.assign({type:"response"},t)),e.complete()})),t.request.publish(r),()=>t.abort.publish())))}}var L=Object.defineProperty,B=(e,t,r)=>(((e,t,r)=>{t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class ${constructor(e){B(this,"__CANCEL__",!0),B(this,"message"),this.message=e}toString(){return"Cancel".concat(this.message?": ".concat(this.message):"")}}const G=class{constructor(e){if(B(this,"promise"),B(this,"reason"),"function"!=typeof e)throw new TypeError("executor must be a function.");let t=null;this.promise=new Promise((e=>{t=e})),e((e=>{this.reason||(this.reason=new $(e),t(this.reason))}))}};B(G,"source",(()=>{let e;return{token:new G((t=>{e=t})),cancel:e}}));var V=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function J(e){return 100*Math.pow(2,e)+100*Math.random()}const X=function(){return(e=>{const t=e.maxRetries||5,r=e.retryDelay||J,n=e.shouldRetry;return{onError:(e,o)=>{const s=o.options,i=s.maxRetries||t,a=s.shouldRetry||n,c=s.attemptNumber||0;if(null!==(u=s.body)&&"object"==typeof u&&"function"==typeof u.pipe)return e;var u;if(!a(e,c,s)||c>=i)return e;const l=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:c+1})});return setTimeout((()=>o.channels.request.publish(l)),r(c)),null}}})({shouldRetry:V,...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}})};X.shouldRetry=V;var Y=function(e,t){return Y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Y(e,t)};function K(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}Y(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function Z(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Q(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,s=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return i}function ee(e,t,r){if(r||2===arguments.length)for(var n,o=0,s=t.length;o<s;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function te(e){return"function"==typeof e}function re(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var ne=re((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function oe(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var se=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var i=Z(s),a=i.next();!a.done;a=i.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else s.remove(this);var c=this.initialTeardown;if(te(c))try{c()}catch(e){o=e instanceof ne?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=Z(u),h=l.next();!h.done;h=l.next()){var d=h.value;try{ae(d)}catch(e){o=null!=o?o:[],e instanceof ne?o=ee(ee([],Q(o)),Q(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(o)throw new ne(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)ae(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&oe(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&oe(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function ie(e){return e instanceof se||e&&"closed"in e&&te(e.remove)&&te(e.add)&&te(e.unsubscribe)}function ae(e){te(e)?e():e.unsubscribe()}se.EMPTY;var ce={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ue={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=ue.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,ee([e,t],Q(r))):setTimeout.apply(void 0,ee([e,t],Q(r)))},clearTimeout:function(e){var t=ue.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function le(){}var he=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,ie(t)&&t.add(r)):r.destination=ve,r}return K(t,e),t.create=function(e,t,r){return new ye(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(se),de=Function.prototype.bind;function pe(e,t){return de.call(e,t)}var fe=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){ge(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){ge(e)}else ge(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){ge(e)}},e}(),ye=function(e){function t(t,r,n){var o,s,i=e.call(this)||this;te(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:i&&ce.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&pe(t.next,s),error:t.error&&pe(t.error,s),complete:t.complete&&pe(t.complete,s)}):o=t;return i.destination=new fe(o),i}return K(t,e),t}(he);function ge(e){var t;t=e,ue.setTimeout((function(){throw t}))}var ve={closed:!0,next:le,error:function(e){throw e},complete:le},me="function"==typeof Symbol&&Symbol.observable||"@@observable";function we(e){return e}var be=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,s=(n=e)&&n instanceof he||function(e){return e&&te(e.next)&&te(e.error)&&te(e.complete)}(n)&&ie(n)?e:new ye(e,t,r);return function(){var e=o,t=e.operator,r=e.source;s.add(t?t.call(s,r):r?o._subscribe(s):o._trySubscribe(s))}(),s},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=Ce(t))((function(t,n){var o=new ye({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[me]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?we:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Ce(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function Ce(e){var t;return null!==(t=null!=e?e:ce.Promise)&&void 0!==t?t:Promise}function Ee(e){return function(t){if(function(e){return te(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function xe(e,t,r,n,o){return new Te(e,t,r,n,o)}var Te=function(e){function t(t,r,n,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return K(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(he),Oe=re((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Se(e,t){var r="object"==typeof t;return new Promise((function(n,o){var s,i=!1;e.subscribe({next:function(e){s=e,i=!0},error:o,complete:function(){i?n(s):r?n(t.defaultValue):o(new Oe)}})}))}function _e(e,t){return Ee((function(r,n){var o=0;r.subscribe(xe(n,(function(r){n.next(e.call(t,r,o++))})))}))}function je(e,t){return Ee((function(r,n){var o=0;r.subscribe(xe(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}var Ae=[];class ke extends Error{constructor(e){const t=Me(e);super(t.message),this.statusCode=400,Object.assign(this,t)}}class Re extends Error{constructor(e){const t=Me(e);super(t.message),this.statusCode=500,Object.assign(this,t)}}function Me(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:Ie(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message="".concat(t.error," - ").concat(t.message),r;if(function(e){return Fe(e)&&Fe(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)){const e=t.error.items||[],n=e.slice(0,5).map((e=>{var t;return null==(t=e.error)?void 0:t.description})).filter(Boolean);let o=n.length?":\n- ".concat(n.join("\n- ")):"";return e.length>5&&(o+="\n...and ".concat(e.length-5," more")),r.message="".concat(t.error.description).concat(o),r.details=t.error,r}return t.error&&t.error.description?(r.message=t.error.description,r.details=t.error,r):(r.message=t.error||t.message||function(e){const t=e.statusMessage?" ".concat(e.statusMessage):"";return"".concat(e.method,"-request to ").concat(e.url," resulted in HTTP ").concat(e.statusCode).concat(t)}(e),r)}function Fe(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Ie(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const Pe={onResponse:e=>{if(e.statusCode>=500)throw new Re(e);if(e.statusCode>=400)throw new ke(e);return e}},De={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};function qe(e,t){let{maxRetries:r=5,retryDelay:n}=t;const o=function(){return d(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],arguments.length>1&&void 0!==arguments[1]?arguments[1]:A)}([r>0?X({retryDelay:n,maxRetries:r,shouldRetry:Ne}):{},...e,De,N(),H(),{onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,r=e.context;function n(e){return t=>{const n=t.lengthComputable?t.loaded/t.total*100:-1;r.channels.progress.publish({stage:e,percent:n,total:t.total,loaded:t.loaded,lengthComputable:t.lengthComputable})}}"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=n("upload")),"onprogress"in t&&(t.onprogress=n("download"))}},Pe,U({implementation:be})]);function s(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:o)({maxRedirects:0,...e})}return s.defaultRequester=o,s}function Ne(e,t,r){const n="GET"===r.method||"HEAD"===r.method,o=(r.uri||r.url).startsWith("/data/query"),s=e.response&&(429===e.response.statusCode||502===e.response.statusCode||503===e.response.statusCode);return!(!n&&!o||!s)||X.shouldRetry(e,t,r)}function He(e){return"https://www.sanity.io/help/"+e}const We=["image","file"],ze=["before","after","replace"],Ue=e=>{if(!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(e))throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters")},Le=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error("".concat(e,"() takes an object of properties"))},Be=(e,t)=>{if("string"!=typeof t||!/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(t)||t.includes(".."))throw new Error("".concat(e,'(): "').concat(t,'" is not a valid document ID'))},$e=(e,t)=>{if(!t._id)throw new Error("".concat(e,'() requires that the document contains an ID ("_id" property)'));Be(e,t._id)},Ge=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},Ve=e=>{if("string"!=typeof e||!/^[a-z0-9._-]{1,75}$/i.test(e))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return e};const Je=e=>function(e){let t,r=!1;return function(){return r||(t=e(...arguments),r=!0),t}}((function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return console.warn(e.join(" "),...r)})),Xe=Je(["Since you haven't set a value for `useCdn`, we will deliver content using our","global, edge-cached API-CDN. If you wish to have content delivered faster, set","`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."]),Ye=Je(["The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.","The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."]),Ke=Je(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.","See ".concat(He("js-client-browser-token")," for more information and how to hide this warning.")]),Ze=Je(["Using the Sanity client without specifying an API version is deprecated.","See ".concat(He("js-client-api-version"))]),Qe=Je(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),et={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0},tt=["localhost","127.0.0.1","0.0.0.0"],rt=function(e){switch(e){case"previewDrafts":case"published":case"raw":return;default:throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`")}},nt=(e,t)=>{const r=Object.assign({},t,e);r.apiVersion||Ze();const n=Object.assign({},et,r),o=n.useProjectHostname;if("undefined"==typeof Promise){const e=He("js-client-promise-polyfill");throw new Error("No native Promise-implementation found, polyfill needed - see ".concat(e))}if(o&&!n.projectId)throw new Error("Configuration must contain `projectId`");if("string"==typeof n.perspective&&rt(n.perspective),"encodeSourceMapAtPath"in n||"encodeSourceMap"in n||"studioUrl"in n||"logger"in n)throw new Error("It looks like you're using options meant for '@sanity/preview-kit/client', such as 'encodeSourceMapAtPath', 'encodeSourceMap', 'studioUrl' and 'logger'. Make sure you're using the right import.");const s="undefined"!=typeof window&&window.location&&window.location.hostname,i=s&&(e=>-1!==tt.indexOf(e))(window.location.hostname);s&&i&&n.token&&!0!==n.ignoreBrowserTokenWarning?Ke():void 0===n.useCdn&&Xe(),o&&(e=>{if(!/^[-a-z0-9]+$/i.test(e))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")})(n.projectId),n.dataset&&Ue(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?Ve(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion="".concat(n.apiVersion).replace(/^v/,""),n.isDefaultApi=n.apiHost===et.apiHost,n.useCdn=!1!==n.useCdn&&!n.withCredentials,function(e){if("1"===e||"X"===e)return;const t=new Date(e);if(!(/^\d{4}-\d{2}-\d{2}$/.test(e)&&t instanceof Date&&t.getTime()>0))throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`")}(n.apiVersion);const a=n.apiHost.split("://",2),c=a[0],u=a[1],l=n.isDefaultApi?"apicdn.sanity.io":u;return n.useProjectHostname?(n.url="".concat(c,"://").concat(n.projectId,".").concat(u,"/v").concat(n.apiVersion),n.cdnUrl="".concat(c,"://").concat(n.projectId,".").concat(l,"/v").concat(n.apiVersion)):(n.url="".concat(n.apiHost,"/v").concat(n.apiVersion),n.cdnUrl=n.url),n},ot="X-Sanity-Project-ID";function st(e){if("string"==typeof e||Array.isArray(e))return{id:e};if("object"==typeof e&&null!==e&&"query"in e&&"string"==typeof e.query)return"params"in e&&"object"==typeof e.params&&null!==e.params?{query:e.query,params:e.params}:{query:e.query};const t=["* Document ID (<docId>)","* Array of document IDs","* Object containing `query`"].join("\n");throw new Error("Unknown selection - must be one of:\n\n".concat(t))}const it=e=>{let{query:t,params:r={},options:n={}}=e;const o=new URLSearchParams,{tag:s,...i}=n;s&&o.append("tag",s),o.append("query",t);for(const[e,t]of Object.entries(r))o.append("$".concat(e),JSON.stringify(t));for(const[e,t]of Object.entries(i))t&&o.append(e,"".concat(t));return"?".concat(o)};var at,ct,ut=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},lt=(e,t,r)=>(ut(e,t,"read from private field"),r?r.call(e):t.get(e)),ht=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},dt=(e,t,r,n)=>(ut(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class pt{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.selection=e,this.operations=t}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return Le("diffMatchPatch",e),this._assign("diffMatchPatch",e)}unset(e){if(!Array.isArray(e))throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");return this.operations=Object.assign({},this.operations,{unset:e}),this}inc(e){return this._assign("inc",e)}dec(e){return this._assign("dec",e)}insert(e,t,r){return((e,t,r)=>{const n="insert(at, selector, items)";if(-1===ze.indexOf(e)){const e=ze.map((e=>'"'.concat(e,'"'))).join(", ");throw new Error("".concat(n,' takes an "at"-argument which is one of: ').concat(e))}if("string"!=typeof t)throw new Error("".concat(n,' takes a "selector"-argument which must be a string'));if(!Array.isArray(r))throw new Error("".concat(n,' takes an "items"-argument which must be an array'))})(e,t,r),this._assign("insert",{[e]:t,items:r})}append(e,t){return this.insert("after","".concat(e,"[-1]"),t)}prepend(e,t){return this.insert("before","".concat(e,"[0]"),t)}splice(e,t,r,n){const o=t<0?t-1:t,s=void 0===r||-1===r?-1:Math.max(0,t+r),i=o<0&&s>=0?"":s,a="".concat(e,"[").concat(o,":").concat(i,"]");return this.insert("replace",a,n||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...st(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return Le(e,t),this.operations=Object.assign({},this.operations,{[e]:Object.assign({},r&&this.operations[e]||{},t)}),this}_set(e,t){return this._assign(e,t,!1)}}at=new WeakMap;let ft=class e extends pt{constructor(e,t,r){super(e,t),ht(this,at,void 0),dt(this,at,r)}clone(){return new e(this.selection,{...this.operations},lt(this,at))}commit(e){if(!lt(this,at))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const t="string"==typeof this.selection,r=Object.assign({returnFirst:t,returnDocuments:!0},e);return lt(this,at).mutate({patch:this.serialize()},r)}};ct=new WeakMap;let yt=class e extends pt{constructor(e,t,r){super(e,t),ht(this,ct,void 0),dt(this,ct,r)}clone(){return new e(this.selection,{...this.operations},lt(this,ct))}commit(e){if(!lt(this,ct))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const t="string"==typeof this.selection,r=Object.assign({returnFirst:t,returnDocuments:!0},e);return lt(this,ct).mutate({patch:this.serialize()},r)}};var gt,vt,mt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},wt=(e,t,r)=>(mt(e,t,"read from private field"),r?r.call(e):t.get(e)),bt=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Ct=(e,t,r,n)=>(mt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);const Et={returnDocuments:!1};class xt{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;this.operations=e,this.trxId=t}create(e){return Le("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return Le(t,e),$e(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return Le(t,e),$e(t,e),this._add({[t]:e})}delete(e){return Be("delete",e),this._add({delete:{id:e}})}transactionId(e){return e?(this.trxId=e,this):this.trxId}serialize(){return[...this.operations]}toJSON(){return this.serialize()}reset(){return this.operations=[],this}_add(e){return this.operations.push(e),this}}gt=new WeakMap;let Tt=class e extends xt{constructor(e,t,r){super(e,r),bt(this,gt,void 0),Ct(this,gt,t)}clone(){return new e([...this.operations],wt(this,gt),this.trxId)}commit(e){if(!wt(this,gt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return wt(this,gt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Et,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof yt)return this._add({patch:e.serialize()});if(r){const r=t(new yt(e,{},wt(this,gt)));if(!(r instanceof yt))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};vt=new WeakMap;let Ot=class e extends xt{constructor(e,t,r){super(e,r),bt(this,vt,void 0),Ct(this,vt,t)}clone(){return new e([...this.operations],wt(this,vt),this.trxId)}commit(e){if(!wt(this,vt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return wt(this,vt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Et,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof ft)return this._add({patch:e.serialize()});if(r){const r=t(new ft(e,{},wt(this,vt)));if(!(r instanceof ft))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};const St=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{dryRun:e.dryRun,returnIds:!0,returnDocuments:(t=e.returnDocuments,r=!0,!1===t?void 0:void 0===t?r:t),visibility:e.visibility||"sync",autoGenerateArrayKeys:e.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:e.skipCrossDatasetReferenceValidation};var t,r},_t=e=>"response"===e.type,jt=e=>e.body,At=11264;function kt(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s=!1===o.filterResponse?e=>e:e=>e.result,{cache:i,next:a,...c}={useAbortSignal:void 0!==o.signal,...o};return qt(e,t,"query",{query:r,params:n},void 0!==i||void 0!==a?{...c,fetch:{cache:i,next:a}}:c).pipe(_e(s))}function Rt(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Ht(e,t,{uri:zt(e,"doc",r),json:!0,tag:n.tag}).pipe(je(_t),_e((e=>e.body.documents&&e.body.documents[0])))}function Mt(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Ht(e,t,{uri:zt(e,"doc",r.join(",")),json:!0,tag:n.tag}).pipe(je(_t),_e((e=>{const t=(n=e.body.documents||[],o=e=>e._id,n.reduce(((e,t)=>(e[o(t)]=t,e)),Object.create(null)));var n,o;return r.map((e=>t[e]||null))})))}function Ft(e,t,r,n){return $e("createIfNotExists",r),Nt(e,t,r,"createIfNotExists",n)}function It(e,t,r,n){return $e("createOrReplace",r),Nt(e,t,r,"createOrReplace",n)}function Pt(e,t,r,n){return qt(e,t,"mutate",{mutations:[{delete:st(r)}]},n)}function Dt(e,t,r,n){let o;o=r instanceof yt||r instanceof ft?{patch:r.serialize()}:r instanceof Tt||r instanceof Ot?r.serialize():r;return qt(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function qt(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s="mutate"===r,i="query"===r,a=s?"":it(n),c=!s&&a.length<At,u=c?a:"",l=o.returnFirst,{timeout:h,token:d,tag:p,headers:f}=o;return Ht(e,t,{method:c?"GET":"POST",uri:zt(e,r,u),json:!0,body:c?void 0:n,query:s&&St(o),timeout:h,headers:f,token:d,tag:p,perspective:o.perspective,resultSourceMap:o.resultSourceMap,canUseCdn:i,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal}).pipe(je(_t),_e(jt),_e((e=>{if(!s)return e;const t=e.results||[];if(o.returnDocuments)return l?t[0]&&t[0].document:t.map((e=>e.document));const r=l?"documentId":"documentIds",n=l?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function Nt(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return qt(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function Ht(e,t,r){var n;const o=r.url||r.uri,s=e.config(),i=void 0===r.canUseCdn?["GET","HEAD"].indexOf(r.method||"GET")>=0&&0===o.indexOf("/data/"):r.canUseCdn;let a=s.useCdn&&i;const c=r.tag&&s.requestTagPrefix?[s.requestTagPrefix,r.tag].join("."):r.tag||s.requestTagPrefix;if(c&&null!==r.tag&&(r.query={tag:Ve(c),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&0===o.indexOf("/data/query/")){(null!=(n=r.resultSourceMap)?n:s.resultSourceMap)&&(r.query={resultSourceMap:!0,...r.query});const e=r.perspective||s.perspective;"string"==typeof e&&"raw"!==e&&(rt(e),r.query={perspective:e,...r.query},"previewDrafts"===e&&a&&(a=!1,Ye()))}const u=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r={},n=t.token||e.token;n&&(r.Authorization="Bearer ".concat(n)),t.useGlobalApi||e.useProjectHostname||!e.projectId||(r[ot]=e.projectId);const o=Boolean(void 0===t.withCredentials?e.token||e.withCredentials:t.withCredentials),s=void 0===t.timeout?e.timeout:t.timeout;return Object.assign({},t,{headers:Object.assign({},r,t.headers||{}),timeout:void 0===s?3e5:s,proxy:t.proxy||e.proxy,json:!0,withCredentials:o,fetch:"object"==typeof t.fetch&&"object"==typeof e.fetch?{...e.fetch,...t.fetch}:t.fetch||e.fetch})}(s,Object.assign({},r,{url:Ut(e,o,a)})),l=new be((e=>t(u,s.requester).subscribe(e)));return r.signal?l.pipe((h=r.signal,e=>new be((t=>{const r=()=>t.error(function(e){var t,r;if(Lt)return new DOMException(null!=(t=null==e?void 0:e.reason)?t:"The operation was aborted.","AbortError");const n=new Error(null!=(r=null==e?void 0:e.reason)?r:"The operation was aborted.");return n.name="AbortError",n}(h));if(h&&h.aborted)return void r();const n=e.subscribe(t);return h.addEventListener("abort",r),()=>{h.removeEventListener("abort",r),n.unsubscribe()}})))):l;var h}function Wt(e,t,r){return Ht(e,t,r).pipe(je((e=>"response"===e.type)),_e((e=>e.body)))}function zt(e,t,r){const n=e.config(),o=Ge(n),s="/".concat(t,"/").concat(o),i=r?"".concat(s,"/").concat(r):s;return"/data".concat(i).replace(/\/($|\?)/,"$1")}function Ut(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const{url:n,cdnUrl:o}=e.config();return"".concat(r?o:n,"/").concat(t.replace(/^\//,""))}const Lt=Boolean(globalThis.DOMException);var Bt,$t,Gt,Vt,Jt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Xt=(e,t,r)=>(Jt(e,t,"read from private field"),r?r.call(e):t.get(e)),Yt=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Kt=(e,t,r,n)=>(Jt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Zt{constructor(e,t){Yt(this,Bt,void 0),Yt(this,$t,void 0),Kt(this,Bt,e),Kt(this,$t,t)}upload(e,t,r){return er(Xt(this,Bt),Xt(this,$t),e,t,r)}}Bt=new WeakMap,$t=new WeakMap;class Qt{constructor(e,t){Yt(this,Gt,void 0),Yt(this,Vt,void 0),Kt(this,Gt,e),Kt(this,Vt,t)}upload(e,t,r){return Se(er(Xt(this,Gt),Xt(this,Vt),e,t,r).pipe(je((e=>"response"===e.type)),_e((e=>e.body.document))))}}function er(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};(e=>{if(-1===We.indexOf(e))throw new Error("Invalid asset type: ".concat(e,". Must be one of ").concat(We.join(", ")))})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=Ge(e.config()),a="image"===r?"images":"files",c=function(e,t){if("undefined"==typeof File||!(t instanceof File))return e;return Object.assign({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e)}(o,n),{tag:u,label:l,title:h,description:d,creditLine:p,filename:f,source:y}=c,g={label:l,title:h,description:d,filename:f,meta:s,creditLine:p};return y&&(g.sourceId=y.id,g.sourceName=y.name,g.sourceUrl=y.url),Ht(e,t,{tag:u,method:"POST",timeout:c.timeout||0,uri:"/assets/".concat(a,"/").concat(i),headers:c.contentType?{"Content-Type":c.contentType}:{},query:g,body:n})}Gt=new WeakMap,Vt=new WeakMap;var tr=(e,t)=>Object.keys(t).concat(Object.keys(e)).reduce(((r,n)=>(r[n]=void 0===e[n]?t[n]:e[n],r)),{});const rr=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],nr={includeResult:!0};function or(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{url:n,token:o,withCredentials:s,requestTagPrefix:i}=this.config(),a=r.tag&&i?[i,r.tag].join("."):r.tag,c={...tr(r,nr),tag:a},u=(l=c,rr.reduce(((e,t)=>(void 0===l[t]||(e[t]=l[t]),e)),{}));var l;const h=it({query:e,params:t,options:{tag:a,...u}}),d="".concat(n).concat(zt(this,"listen",h));if(d.length>14800)return new be((e=>e.error(new Error("Query too large for listener"))));const p=c.events?c.events:["mutation"],f=-1!==p.indexOf("reconnect"),y={};return(o||s)&&(y.withCredentials=!0),o&&(y.headers={Authorization:"Bearer ".concat(o)}),new be((e=>{let t,r;u().then((e=>{t=e})).catch((t=>{e.error(t),h()}));let n=!1;function o(){n||(f&&e.next({type:"reconnect"}),n||t.readyState===t.CLOSED&&(c(),clearTimeout(r),r=setTimeout(l,100)))}function s(t){e.error(function(e){if(e instanceof Error)return e;const t=sr(e);return t instanceof Error?t:new Error(function(e){if(!e.error)return e.message||"Unknown listener error";if(e.error.description)return e.error.description;return"string"==typeof e.error?e.error:JSON.stringify(e.error,null,2)}(t))}(t))}function i(t){const r=sr(t);return r instanceof Error?e.error(r):e.next(r)}function a(){n=!0,c(),e.complete()}function c(){t&&(t.removeEventListener("error",o),t.removeEventListener("channelError",s),t.removeEventListener("disconnect",a),p.forEach((e=>t.removeEventListener(e,i))),t.close())}async function u(){const{default:e}=await Promise.resolve().then((function(){return Kr})),t=new e(d,y);return t.addEventListener("error",o),t.addEventListener("channelError",s),t.addEventListener("disconnect",a),p.forEach((e=>t.addEventListener(e,i))),t}function l(){u().then((e=>{t=e})).catch((t=>{e.error(t),h()}))}function h(){n=!0,c()}return h}))}function sr(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}var ir,ar,cr,ur,lr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},hr=(e,t,r)=>(lr(e,t,"read from private field"),r?r.call(e):t.get(e)),dr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},pr=(e,t,r,n)=>(lr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class fr{constructor(e,t){dr(this,ir,void 0),dr(this,ar,void 0),pr(this,ir,e),pr(this,ar,t)}create(e,t){return gr(hr(this,ir),hr(this,ar),"PUT",e,t)}edit(e,t){return gr(hr(this,ir),hr(this,ar),"PATCH",e,t)}delete(e){return gr(hr(this,ir),hr(this,ar),"DELETE",e)}list(){return Wt(hr(this,ir),hr(this,ar),{uri:"/datasets",tag:null})}}ir=new WeakMap,ar=new WeakMap;class yr{constructor(e,t){dr(this,cr,void 0),dr(this,ur,void 0),pr(this,cr,e),pr(this,ur,t)}create(e,t){return Se(gr(hr(this,cr),hr(this,ur),"PUT",e,t))}edit(e,t){return Se(gr(hr(this,cr),hr(this,ur),"PATCH",e,t))}delete(e){return Se(gr(hr(this,cr),hr(this,ur),"DELETE",e))}list(){return Se(Wt(hr(this,cr),hr(this,ur),{uri:"/datasets",tag:null}))}}function gr(e,t,r,n,o){return Ue(n),Wt(e,t,{method:r,uri:"/datasets/".concat(n),body:o,tag:null})}cr=new WeakMap,ur=new WeakMap;var vr,mr,wr,br,Cr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Er=(e,t,r)=>(Cr(e,t,"read from private field"),r?r.call(e):t.get(e)),xr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Tr=(e,t,r,n)=>(Cr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Or{constructor(e,t){xr(this,vr,void 0),xr(this,mr,void 0),Tr(this,vr,e),Tr(this,mr,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Wt(Er(this,vr),Er(this,mr),{uri:t})}getById(e){return Wt(Er(this,vr),Er(this,mr),{uri:"/projects/".concat(e)})}}vr=new WeakMap,mr=new WeakMap;class Sr{constructor(e,t){xr(this,wr,void 0),xr(this,br,void 0),Tr(this,wr,e),Tr(this,br,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Se(Wt(Er(this,wr),Er(this,br),{uri:t}))}getById(e){return Se(Wt(Er(this,wr),Er(this,br),{uri:"/projects/".concat(e)}))}}wr=new WeakMap,br=new WeakMap;var _r,jr,Ar,kr,Rr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Mr=(e,t,r)=>(Rr(e,t,"read from private field"),r?r.call(e):t.get(e)),Fr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Ir=(e,t,r,n)=>(Rr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Pr{constructor(e,t){Fr(this,_r,void 0),Fr(this,jr,void 0),Ir(this,_r,e),Ir(this,jr,t)}getById(e){return Wt(Mr(this,_r),Mr(this,jr),{uri:"/users/".concat(e)})}}_r=new WeakMap,jr=new WeakMap;class Dr{constructor(e,t){Fr(this,Ar,void 0),Fr(this,kr,void 0),Ir(this,Ar,e),Ir(this,kr,t)}getById(e){return Se(Wt(Mr(this,Ar),Mr(this,kr),{uri:"/users/".concat(e)}))}}Ar=new WeakMap,kr=new WeakMap;var qr,Nr,Hr,Wr,zr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Ur=(e,t,r)=>(zr(e,t,"read from private field"),r?r.call(e):t.get(e)),Lr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Br=(e,t,r,n)=>(zr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);qr=new WeakMap,Nr=new WeakMap;let $r=class e{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et;Lr(this,qr,void 0),Lr(this,Nr,void 0),this.listen=or,this.config(t),Br(this,Nr,e),this.assets=new Zt(this,Ur(this,Nr)),this.datasets=new fr(this,Ur(this,Nr)),this.projects=new Or(this,Ur(this,Nr)),this.users=new Pr(this,Ur(this,Nr))}clone(){return new e(Ur(this,Nr),this.config())}config(e){if(void 0===e)return{...Ur(this,qr)};if(Ur(this,qr)&&!1===Ur(this,qr).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return Br(this,qr,nt(e,Ur(this,qr)||{})),this}withConfig(t){return new e(Ur(this,Nr),{...this.config(),...t})}fetch(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return kt(this,Ur(this,Nr),e,t,r)}getDocument(e,t){return Rt(this,Ur(this,Nr),e,t)}getDocuments(e,t){return Mt(this,Ur(this,Nr),e,t)}create(e,t){return Nt(this,Ur(this,Nr),e,"create",t)}createIfNotExists(e,t){return Ft(this,Ur(this,Nr),e,t)}createOrReplace(e,t){return It(this,Ur(this,Nr),e,t)}delete(e,t){return Pt(this,Ur(this,Nr),e,t)}mutate(e,t){return Dt(this,Ur(this,Nr),e,t)}patch(e,t){return new ft(e,t,this)}transaction(e){return new Ot(e,this)}request(e){return Wt(this,Ur(this,Nr),e)}getUrl(e,t){return Ut(this,e,t)}getDataUrl(e,t){return zt(this,e,t)}};Hr=new WeakMap,Wr=new WeakMap;let Gr=class e{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et;Lr(this,Hr,void 0),Lr(this,Wr,void 0),this.listen=or,this.config(t),Br(this,Wr,e),this.assets=new Qt(this,Ur(this,Wr)),this.datasets=new yr(this,Ur(this,Wr)),this.projects=new Sr(this,Ur(this,Wr)),this.users=new Dr(this,Ur(this,Wr)),this.observable=new $r(e,t)}clone(){return new e(Ur(this,Wr),this.config())}config(e){if(void 0===e)return{...Ur(this,Hr)};if(Ur(this,Hr)&&!1===Ur(this,Hr).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.observable&&this.observable.config(e),Br(this,Hr,nt(e,Ur(this,Hr)||{})),this}withConfig(t){return new e(Ur(this,Wr),{...this.config(),...t})}fetch(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Se(kt(this,Ur(this,Wr),e,t,r))}getDocument(e,t){return Se(Rt(this,Ur(this,Wr),e,t))}getDocuments(e,t){return Se(Mt(this,Ur(this,Wr),e,t))}create(e,t){return Se(Nt(this,Ur(this,Wr),e,"create",t))}createIfNotExists(e,t){return Se(Ft(this,Ur(this,Wr),e,t))}createOrReplace(e,t){return Se(It(this,Ur(this,Wr),e,t))}delete(e,t){return Se(Pt(this,Ur(this,Wr),e,t))}mutate(e,t){return Se(Dt(this,Ur(this,Wr),e,t))}patch(e,t){return new yt(e,t,this)}transaction(e){return new Tt(e,this)}request(e){return Se(Wt(this,Ur(this,Wr),e))}dataRequest(e,t,r){return Se(qt(this,Ur(this,Wr),e,t,r))}getUrl(e,t){return Ut(this,e,t)}getDataUrl(e,t){return zt(this,e,t)}};const Vr=qe(Ae,{}),Jr=Vr.defaultRequester;var Xr={exports:{}};
|
|
8
|
+
function P(e){return"[object Object]"===Object.prototype.toString.call(e)}!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=I(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(M,M.exports);const D="undefined"==typeof Buffer?()=>!1:e=>Buffer.isBuffer(e),q=["boolean","string","number"];function N(){return{processOptions:e=>{const t=e.body;if(!t)return e;var r,n,o;return!("function"==typeof t.pipe)&&!D(t)&&(-1!==q.indexOf(typeof t)||Array.isArray(t)||!1!==P(r=t)&&(void 0===(n=r.constructor)||!1!==P(o=n.prototype)&&!1!==o.hasOwnProperty("isPrototypeOf")))?Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})}):e}}}function H(e){return{onResponse:r=>{const n=r.headers["content-type"]||"",o=e&&e.force||-1!==n.indexOf("application/json");return r.body&&n&&o?Object.assign({},r,{body:t(r.body)}):r},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message="Failed to parsed response body as JSON: ".concat(e.message),e}}}let W={};"undefined"!=typeof globalThis?W=globalThis:"undefined"!=typeof window?W=window:"undefined"!=typeof global?W=global:"undefined"!=typeof self&&(W=self);var z=W;function U(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).implementation||z.Observable;if(!e)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(t,r)=>new e((e=>(t.error.subscribe((t=>e.error(t))),t.progress.subscribe((t=>e.next(Object.assign({type:"progress"},t)))),t.response.subscribe((t=>{e.next(Object.assign({type:"response"},t)),e.complete()})),t.request.publish(r),()=>t.abort.publish())))}}var L=Object.defineProperty,B=(e,t,r)=>(((e,t,r)=>{t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class ${constructor(e){B(this,"__CANCEL__",!0),B(this,"message"),this.message=e}toString(){return"Cancel".concat(this.message?": ".concat(this.message):"")}}const G=class{constructor(e){if(B(this,"promise"),B(this,"reason"),"function"!=typeof e)throw new TypeError("executor must be a function.");let t=null;this.promise=new Promise((e=>{t=e})),e((e=>{this.reason||(this.reason=new $(e),t(this.reason))}))}};B(G,"source",(()=>{let e;return{token:new G((t=>{e=t})),cancel:e}}));var V=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function J(e){return 100*Math.pow(2,e)+100*Math.random()}const X=function(){return(e=>{const t=e.maxRetries||5,r=e.retryDelay||J,n=e.shouldRetry;return{onError:(e,o)=>{const s=o.options,i=s.maxRetries||t,a=s.shouldRetry||n,c=s.attemptNumber||0;if(null!==(u=s.body)&&"object"==typeof u&&"function"==typeof u.pipe)return e;var u;if(!a(e,c,s)||c>=i)return e;const l=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:c+1})});return setTimeout((()=>o.channels.request.publish(l)),r(c)),null}}})({shouldRetry:V,...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}})};X.shouldRetry=V;var Y=function(e,t){return Y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},Y(e,t)};function K(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}Y(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function Z(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Q(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,s=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=s.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return i}function ee(e,t,r){if(r||2===arguments.length)for(var n,o=0,s=t.length;o<s;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function te(e){return"function"==typeof e}function re(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}"function"==typeof SuppressedError&&SuppressedError;var ne=re((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function oe(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var se=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var i=Z(s),a=i.next();!a.done;a=i.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else s.remove(this);var c=this.initialTeardown;if(te(c))try{c()}catch(e){o=e instanceof ne?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=Z(u),h=l.next();!h.done;h=l.next()){var d=h.value;try{ae(d)}catch(e){o=null!=o?o:[],e instanceof ne?o=ee(ee([],Q(o)),Q(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(o)throw new ne(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)ae(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&oe(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&oe(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function ie(e){return e instanceof se||e&&"closed"in e&&te(e.remove)&&te(e.add)&&te(e.unsubscribe)}function ae(e){te(e)?e():e.unsubscribe()}se.EMPTY;var ce={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ue={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=ue.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,ee([e,t],Q(r))):setTimeout.apply(void 0,ee([e,t],Q(r)))},clearTimeout:function(e){var t=ue.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function le(){}var he=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,ie(t)&&t.add(r)):r.destination=ve,r}return K(t,e),t.create=function(e,t,r){return new ye(e,t,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(se),de=Function.prototype.bind;function pe(e,t){return de.call(e,t)}var fe=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){ge(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){ge(e)}else ge(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){ge(e)}},e}(),ye=function(e){function t(t,r,n){var o,s,i=e.call(this)||this;te(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:i&&ce.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&pe(t.next,s),error:t.error&&pe(t.error,s),complete:t.complete&&pe(t.complete,s)}):o=t;return i.destination=new fe(o),i}return K(t,e),t}(he);function ge(e){var t;t=e,ue.setTimeout((function(){throw t}))}var ve={closed:!0,next:le,error:function(e){throw e},complete:le},me="function"==typeof Symbol&&Symbol.observable||"@@observable";function we(e){return e}var be=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var n,o=this,s=(n=e)&&n instanceof he||function(e){return e&&te(e.next)&&te(e.error)&&te(e.complete)}(n)&&ie(n)?e:new ye(e,t,r);return function(){var e=o,t=e.operator,r=e.source;s.add(t?t.call(s,r):r?o._subscribe(s):o._trySubscribe(s))}(),s},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=Ce(t))((function(t,n){var o=new ye({next:function(t){try{e(t)}catch(e){n(e),o.unsubscribe()}},error:n,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[me]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return(0===(e=t).length?we:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Ce(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function Ce(e){var t;return null!==(t=null!=e?e:ce.Promise)&&void 0!==t?t:Promise}function Ee(e){return function(t){if(function(e){return te(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}function xe(e,t,r,n,o){return new Te(e,t,r,n,o)}var Te=function(e){function t(t,r,n,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return K(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(he),Oe=re((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Se(e,t){var r="object"==typeof t;return new Promise((function(n,o){var s,i=!1;e.subscribe({next:function(e){s=e,i=!0},error:o,complete:function(){i?n(s):r?n(t.defaultValue):o(new Oe)}})}))}function _e(e,t){return Ee((function(r,n){var o=0;r.subscribe(xe(n,(function(r){n.next(e.call(t,r,o++))})))}))}function je(e,t){return Ee((function(r,n){var o=0;r.subscribe(xe(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}var Ae=[];class ke extends Error{constructor(e){const t=Me(e);super(t.message),this.statusCode=400,Object.assign(this,t)}}class Re extends Error{constructor(e){const t=Me(e);super(t.message),this.statusCode=500,Object.assign(this,t)}}function Me(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:Ie(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message="".concat(t.error," - ").concat(t.message),r;if(function(e){return Fe(e)&&Fe(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)){const e=t.error.items||[],n=e.slice(0,5).map((e=>{var t;return null==(t=e.error)?void 0:t.description})).filter(Boolean);let o=n.length?":\n- ".concat(n.join("\n- ")):"";return e.length>5&&(o+="\n...and ".concat(e.length-5," more")),r.message="".concat(t.error.description).concat(o),r.details=t.error,r}return t.error&&t.error.description?(r.message=t.error.description,r.details=t.error,r):(r.message=t.error||t.message||function(e){const t=e.statusMessage?" ".concat(e.statusMessage):"";return"".concat(e.method,"-request to ").concat(e.url," resulted in HTTP ").concat(e.statusCode).concat(t)}(e),r)}function Fe(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Ie(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const Pe={onResponse:e=>{if(e.statusCode>=500)throw new Re(e);if(e.statusCode>=400)throw new ke(e);return e}},De={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};function qe(e,t){let{maxRetries:r=5,retryDelay:n}=t;const o=function(){return d(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],arguments.length>1&&void 0!==arguments[1]?arguments[1]:A)}([r>0?X({retryDelay:n,maxRetries:r,shouldRetry:Ne}):{},...e,De,N(),H(),{onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,r=e.context;function n(e){return t=>{const n=t.lengthComputable?t.loaded/t.total*100:-1;r.channels.progress.publish({stage:e,percent:n,total:t.total,loaded:t.loaded,lengthComputable:t.lengthComputable})}}"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=n("upload")),"onprogress"in t&&(t.onprogress=n("download"))}},Pe,U({implementation:be})]);function s(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:o)({maxRedirects:0,...e})}return s.defaultRequester=o,s}function Ne(e,t,r){const n="GET"===r.method||"HEAD"===r.method,o=(r.uri||r.url).startsWith("/data/query"),s=e.response&&(429===e.response.statusCode||502===e.response.statusCode||503===e.response.statusCode);return!(!n&&!o||!s)||X.shouldRetry(e,t,r)}function He(e){return"https://www.sanity.io/help/"+e}const We=["image","file"],ze=["before","after","replace"],Ue=e=>{if(!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(e))throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters")},Le=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error("".concat(e,"() takes an object of properties"))},Be=(e,t)=>{if("string"!=typeof t||!/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(t)||t.includes(".."))throw new Error("".concat(e,'(): "').concat(t,'" is not a valid document ID'))},$e=(e,t)=>{if(!t._id)throw new Error("".concat(e,'() requires that the document contains an ID ("_id" property)'));Be(e,t._id)},Ge=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},Ve=e=>{if("string"!=typeof e||!/^[a-z0-9._-]{1,75}$/i.test(e))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return e};const Je=e=>function(e){let t,r=!1;return function(){return r||(t=e(...arguments),r=!0),t}}((function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return console.warn(e.join(" "),...r)})),Xe=Je(["Since you haven't set a value for `useCdn`, we will deliver content using our","global, edge-cached API-CDN. If you wish to have content delivered faster, set","`useCdn: false` to use the Live API. Note: You may incur higher costs using the live API."]),Ye=Je(["The Sanity client is configured with the `perspective` set to `previewDrafts`, which doesn't support the API-CDN.","The Live API will be used instead. Set `useCdn: false` in your configuration to hide this warning."]),Ke=Je(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.","See ".concat(He("js-client-browser-token")," for more information and how to hide this warning.")]),Ze=Je(["Using the Sanity client without specifying an API version is deprecated.","See ".concat(He("js-client-api-version"))]),Qe=Je(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),et={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0},tt=["localhost","127.0.0.1","0.0.0.0"],rt=function(e){switch(e){case"previewDrafts":case"published":case"raw":return;default:throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`")}},nt=(e,t)=>{const r=Object.assign({},t,e);r.apiVersion||Ze();const n=Object.assign({},et,r),o=n.useProjectHostname;if("undefined"==typeof Promise){const e=He("js-client-promise-polyfill");throw new Error("No native Promise-implementation found, polyfill needed - see ".concat(e))}if(o&&!n.projectId)throw new Error("Configuration must contain `projectId`");if("string"==typeof n.perspective&&rt(n.perspective),"encodeSourceMapAtPath"in n||"encodeSourceMap"in n||"studioUrl"in n||"logger"in n)throw new Error("It looks like you're using options meant for '@sanity/preview-kit/client', such as 'encodeSourceMapAtPath', 'encodeSourceMap', 'studioUrl' and 'logger'. Make sure you're using the right import.");const s="undefined"!=typeof window&&window.location&&window.location.hostname,i=s&&(e=>-1!==tt.indexOf(e))(window.location.hostname);s&&i&&n.token&&!0!==n.ignoreBrowserTokenWarning?Ke():void 0===n.useCdn&&Xe(),o&&(e=>{if(!/^[-a-z0-9]+$/i.test(e))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")})(n.projectId),n.dataset&&Ue(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?Ve(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion="".concat(n.apiVersion).replace(/^v/,""),n.isDefaultApi=n.apiHost===et.apiHost,n.useCdn=!1!==n.useCdn&&!n.withCredentials,function(e){if("1"===e||"X"===e)return;const t=new Date(e);if(!(/^\d{4}-\d{2}-\d{2}$/.test(e)&&t instanceof Date&&t.getTime()>0))throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`")}(n.apiVersion);const a=n.apiHost.split("://",2),c=a[0],u=a[1],l=n.isDefaultApi?"apicdn.sanity.io":u;return n.useProjectHostname?(n.url="".concat(c,"://").concat(n.projectId,".").concat(u,"/v").concat(n.apiVersion),n.cdnUrl="".concat(c,"://").concat(n.projectId,".").concat(l,"/v").concat(n.apiVersion)):(n.url="".concat(n.apiHost,"/v").concat(n.apiVersion),n.cdnUrl=n.url),n},ot="X-Sanity-Project-ID";function st(e){if("string"==typeof e||Array.isArray(e))return{id:e};if("object"==typeof e&&null!==e&&"query"in e&&"string"==typeof e.query)return"params"in e&&"object"==typeof e.params&&null!==e.params?{query:e.query,params:e.params}:{query:e.query};const t=["* Document ID (<docId>)","* Array of document IDs","* Object containing `query`"].join("\n");throw new Error("Unknown selection - must be one of:\n\n".concat(t))}const it=e=>{let{query:t,params:r={},options:n={}}=e;const o=new URLSearchParams,{tag:s,...i}=n;s&&o.append("tag",s),o.append("query",t);for(const[e,t]of Object.entries(r))o.append("$".concat(e),JSON.stringify(t));for(const[e,t]of Object.entries(i))t&&o.append(e,"".concat(t));return"?".concat(o)};var at,ct,ut=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},lt=(e,t,r)=>(ut(e,t,"read from private field"),r?r.call(e):t.get(e)),ht=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},dt=(e,t,r,n)=>(ut(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class pt{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.selection=e,this.operations=t}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return Le("diffMatchPatch",e),this._assign("diffMatchPatch",e)}unset(e){if(!Array.isArray(e))throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");return this.operations=Object.assign({},this.operations,{unset:e}),this}inc(e){return this._assign("inc",e)}dec(e){return this._assign("dec",e)}insert(e,t,r){return((e,t,r)=>{const n="insert(at, selector, items)";if(-1===ze.indexOf(e)){const e=ze.map((e=>'"'.concat(e,'"'))).join(", ");throw new Error("".concat(n,' takes an "at"-argument which is one of: ').concat(e))}if("string"!=typeof t)throw new Error("".concat(n,' takes a "selector"-argument which must be a string'));if(!Array.isArray(r))throw new Error("".concat(n,' takes an "items"-argument which must be an array'))})(e,t,r),this._assign("insert",{[e]:t,items:r})}append(e,t){return this.insert("after","".concat(e,"[-1]"),t)}prepend(e,t){return this.insert("before","".concat(e,"[0]"),t)}splice(e,t,r,n){const o=t<0?t-1:t,s=void 0===r||-1===r?-1:Math.max(0,t+r),i=o<0&&s>=0?"":s,a="".concat(e,"[").concat(o,":").concat(i,"]");return this.insert("replace",a,n||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...st(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return Le(e,t),this.operations=Object.assign({},this.operations,{[e]:Object.assign({},r&&this.operations[e]||{},t)}),this}_set(e,t){return this._assign(e,t,!1)}}at=new WeakMap;let ft=class e extends pt{constructor(e,t,r){super(e,t),ht(this,at,void 0),dt(this,at,r)}clone(){return new e(this.selection,{...this.operations},lt(this,at))}commit(e){if(!lt(this,at))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const t="string"==typeof this.selection,r=Object.assign({returnFirst:t,returnDocuments:!0},e);return lt(this,at).mutate({patch:this.serialize()},r)}};ct=new WeakMap;let yt=class e extends pt{constructor(e,t,r){super(e,t),ht(this,ct,void 0),dt(this,ct,r)}clone(){return new e(this.selection,{...this.operations},lt(this,ct))}commit(e){if(!lt(this,ct))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const t="string"==typeof this.selection,r=Object.assign({returnFirst:t,returnDocuments:!0},e);return lt(this,ct).mutate({patch:this.serialize()},r)}};var gt,vt,mt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},wt=(e,t,r)=>(mt(e,t,"read from private field"),r?r.call(e):t.get(e)),bt=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Ct=(e,t,r,n)=>(mt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);const Et={returnDocuments:!1};class xt{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;this.operations=e,this.trxId=t}create(e){return Le("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return Le(t,e),$e(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return Le(t,e),$e(t,e),this._add({[t]:e})}delete(e){return Be("delete",e),this._add({delete:{id:e}})}transactionId(e){return e?(this.trxId=e,this):this.trxId}serialize(){return[...this.operations]}toJSON(){return this.serialize()}reset(){return this.operations=[],this}_add(e){return this.operations.push(e),this}}gt=new WeakMap;let Tt=class e extends xt{constructor(e,t,r){super(e,r),bt(this,gt,void 0),Ct(this,gt,t)}clone(){return new e([...this.operations],wt(this,gt),this.trxId)}commit(e){if(!wt(this,gt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return wt(this,gt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Et,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof yt)return this._add({patch:e.serialize()});if(r){const r=t(new yt(e,{},wt(this,gt)));if(!(r instanceof yt))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};vt=new WeakMap;let Ot=class e extends xt{constructor(e,t,r){super(e,r),bt(this,vt,void 0),Ct(this,vt,t)}clone(){return new e([...this.operations],wt(this,vt),this.trxId)}commit(e){if(!wt(this,vt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return wt(this,vt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Et,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof ft)return this._add({patch:e.serialize()});if(r){const r=t(new ft(e,{},wt(this,vt)));if(!(r instanceof ft))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};const St=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{dryRun:e.dryRun,returnIds:!0,returnDocuments:(t=e.returnDocuments,r=!0,!1===t?void 0:void 0===t?r:t),visibility:e.visibility||"sync",autoGenerateArrayKeys:e.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:e.skipCrossDatasetReferenceValidation};var t,r},_t=e=>"response"===e.type,jt=e=>e.body,At=11264;function kt(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s=!1===o.filterResponse?e=>e:e=>e.result,{cache:i,next:a,...c}={useAbortSignal:void 0!==o.signal,...o};return qt(e,t,"query",{query:r,params:n},void 0!==i||void 0!==a?{...c,fetch:{cache:i,next:a}}:c).pipe(_e(s))}function Rt(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Ht(e,t,{uri:zt(e,"doc",r),json:!0,tag:n.tag}).pipe(je(_t),_e((e=>e.body.documents&&e.body.documents[0])))}function Mt(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Ht(e,t,{uri:zt(e,"doc",r.join(",")),json:!0,tag:n.tag}).pipe(je(_t),_e((e=>{const t=(n=e.body.documents||[],o=e=>e._id,n.reduce(((e,t)=>(e[o(t)]=t,e)),Object.create(null)));var n,o;return r.map((e=>t[e]||null))})))}function Ft(e,t,r,n){return $e("createIfNotExists",r),Nt(e,t,r,"createIfNotExists",n)}function It(e,t,r,n){return $e("createOrReplace",r),Nt(e,t,r,"createOrReplace",n)}function Pt(e,t,r,n){return qt(e,t,"mutate",{mutations:[{delete:st(r)}]},n)}function Dt(e,t,r,n){let o;o=r instanceof yt||r instanceof ft?{patch:r.serialize()}:r instanceof Tt||r instanceof Ot?r.serialize():r;return qt(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function qt(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const s="mutate"===r,i="query"===r,a=s?"":it(n),c=!s&&a.length<At,u=c?a:"",l=o.returnFirst,{timeout:h,token:d,tag:p,headers:f}=o;return Ht(e,t,{method:c?"GET":"POST",uri:zt(e,r,u),json:!0,body:c?void 0:n,query:s&&St(o),timeout:h,headers:f,token:d,tag:p,perspective:o.perspective,resultSourceMap:o.resultSourceMap,canUseCdn:i,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal}).pipe(je(_t),_e(jt),_e((e=>{if(!s)return e;const t=e.results||[];if(o.returnDocuments)return l?t[0]&&t[0].document:t.map((e=>e.document));const r=l?"documentId":"documentIds",n=l?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function Nt(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return qt(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function Ht(e,t,r){var n;const o=r.url||r.uri,s=e.config(),i=void 0===r.canUseCdn?["GET","HEAD"].indexOf(r.method||"GET")>=0&&0===o.indexOf("/data/"):r.canUseCdn;let a=s.useCdn&&i;const c=r.tag&&s.requestTagPrefix?[s.requestTagPrefix,r.tag].join("."):r.tag||s.requestTagPrefix;if(c&&null!==r.tag&&(r.query={tag:Ve(c),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&0===o.indexOf("/data/query/")){const e=null!=(n=r.resultSourceMap)?n:s.resultSourceMap;void 0!==e&&!1!==e&&(r.query={resultSourceMap:e,...r.query});const t=r.perspective||s.perspective;"string"==typeof t&&"raw"!==t&&(rt(t),r.query={perspective:t,...r.query},"previewDrafts"===t&&a&&(a=!1,Ye()))}const u=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r={},n=t.token||e.token;n&&(r.Authorization="Bearer ".concat(n)),t.useGlobalApi||e.useProjectHostname||!e.projectId||(r[ot]=e.projectId);const o=Boolean(void 0===t.withCredentials?e.token||e.withCredentials:t.withCredentials),s=void 0===t.timeout?e.timeout:t.timeout;return Object.assign({},t,{headers:Object.assign({},r,t.headers||{}),timeout:void 0===s?3e5:s,proxy:t.proxy||e.proxy,json:!0,withCredentials:o,fetch:"object"==typeof t.fetch&&"object"==typeof e.fetch?{...e.fetch,...t.fetch}:t.fetch||e.fetch})}(s,Object.assign({},r,{url:Ut(e,o,a)})),l=new be((e=>t(u,s.requester).subscribe(e)));return r.signal?l.pipe((h=r.signal,e=>new be((t=>{const r=()=>t.error(function(e){var t,r;if(Lt)return new DOMException(null!=(t=null==e?void 0:e.reason)?t:"The operation was aborted.","AbortError");const n=new Error(null!=(r=null==e?void 0:e.reason)?r:"The operation was aborted.");return n.name="AbortError",n}(h));if(h&&h.aborted)return void r();const n=e.subscribe(t);return h.addEventListener("abort",r),()=>{h.removeEventListener("abort",r),n.unsubscribe()}})))):l;var h}function Wt(e,t,r){return Ht(e,t,r).pipe(je((e=>"response"===e.type)),_e((e=>e.body)))}function zt(e,t,r){const n=e.config(),o=Ge(n),s="/".concat(t,"/").concat(o),i=r?"".concat(s,"/").concat(r):s;return"/data".concat(i).replace(/\/($|\?)/,"$1")}function Ut(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const{url:n,cdnUrl:o}=e.config();return"".concat(r?o:n,"/").concat(t.replace(/^\//,""))}const Lt=Boolean(globalThis.DOMException);var Bt,$t,Gt,Vt,Jt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Xt=(e,t,r)=>(Jt(e,t,"read from private field"),r?r.call(e):t.get(e)),Yt=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Kt=(e,t,r,n)=>(Jt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Zt{constructor(e,t){Yt(this,Bt,void 0),Yt(this,$t,void 0),Kt(this,Bt,e),Kt(this,$t,t)}upload(e,t,r){return er(Xt(this,Bt),Xt(this,$t),e,t,r)}}Bt=new WeakMap,$t=new WeakMap;class Qt{constructor(e,t){Yt(this,Gt,void 0),Yt(this,Vt,void 0),Kt(this,Gt,e),Kt(this,Vt,t)}upload(e,t,r){return Se(er(Xt(this,Gt),Xt(this,Vt),e,t,r).pipe(je((e=>"response"===e.type)),_e((e=>e.body.document))))}}function er(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};(e=>{if(-1===We.indexOf(e))throw new Error("Invalid asset type: ".concat(e,". Must be one of ").concat(We.join(", ")))})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=Ge(e.config()),a="image"===r?"images":"files",c=function(e,t){if("undefined"==typeof File||!(t instanceof File))return e;return Object.assign({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e)}(o,n),{tag:u,label:l,title:h,description:d,creditLine:p,filename:f,source:y}=c,g={label:l,title:h,description:d,filename:f,meta:s,creditLine:p};return y&&(g.sourceId=y.id,g.sourceName=y.name,g.sourceUrl=y.url),Ht(e,t,{tag:u,method:"POST",timeout:c.timeout||0,uri:"/assets/".concat(a,"/").concat(i),headers:c.contentType?{"Content-Type":c.contentType}:{},query:g,body:n})}Gt=new WeakMap,Vt=new WeakMap;var tr=(e,t)=>Object.keys(t).concat(Object.keys(e)).reduce(((r,n)=>(r[n]=void 0===e[n]?t[n]:e[n],r)),{});const rr=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],nr={includeResult:!0};function or(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{url:n,token:o,withCredentials:s,requestTagPrefix:i}=this.config(),a=r.tag&&i?[i,r.tag].join("."):r.tag,c={...tr(r,nr),tag:a},u=(l=c,rr.reduce(((e,t)=>(void 0===l[t]||(e[t]=l[t]),e)),{}));var l;const h=it({query:e,params:t,options:{tag:a,...u}}),d="".concat(n).concat(zt(this,"listen",h));if(d.length>14800)return new be((e=>e.error(new Error("Query too large for listener"))));const p=c.events?c.events:["mutation"],f=-1!==p.indexOf("reconnect"),y={};return(o||s)&&(y.withCredentials=!0),o&&(y.headers={Authorization:"Bearer ".concat(o)}),new be((e=>{let t,r;u().then((e=>{t=e})).catch((t=>{e.error(t),h()}));let n=!1;function o(){n||(f&&e.next({type:"reconnect"}),n||t.readyState===t.CLOSED&&(c(),clearTimeout(r),r=setTimeout(l,100)))}function s(t){e.error(function(e){if(e instanceof Error)return e;const t=sr(e);return t instanceof Error?t:new Error(function(e){if(!e.error)return e.message||"Unknown listener error";if(e.error.description)return e.error.description;return"string"==typeof e.error?e.error:JSON.stringify(e.error,null,2)}(t))}(t))}function i(t){const r=sr(t);return r instanceof Error?e.error(r):e.next(r)}function a(){n=!0,c(),e.complete()}function c(){t&&(t.removeEventListener("error",o),t.removeEventListener("channelError",s),t.removeEventListener("disconnect",a),p.forEach((e=>t.removeEventListener(e,i))),t.close())}async function u(){const{default:e}=await Promise.resolve().then((function(){return Kr})),t=new e(d,y);return t.addEventListener("error",o),t.addEventListener("channelError",s),t.addEventListener("disconnect",a),p.forEach((e=>t.addEventListener(e,i))),t}function l(){u().then((e=>{t=e})).catch((t=>{e.error(t),h()}))}function h(){n=!0,c()}return h}))}function sr(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}var ir,ar,cr,ur,lr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},hr=(e,t,r)=>(lr(e,t,"read from private field"),r?r.call(e):t.get(e)),dr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},pr=(e,t,r,n)=>(lr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class fr{constructor(e,t){dr(this,ir,void 0),dr(this,ar,void 0),pr(this,ir,e),pr(this,ar,t)}create(e,t){return gr(hr(this,ir),hr(this,ar),"PUT",e,t)}edit(e,t){return gr(hr(this,ir),hr(this,ar),"PATCH",e,t)}delete(e){return gr(hr(this,ir),hr(this,ar),"DELETE",e)}list(){return Wt(hr(this,ir),hr(this,ar),{uri:"/datasets",tag:null})}}ir=new WeakMap,ar=new WeakMap;class yr{constructor(e,t){dr(this,cr,void 0),dr(this,ur,void 0),pr(this,cr,e),pr(this,ur,t)}create(e,t){return Se(gr(hr(this,cr),hr(this,ur),"PUT",e,t))}edit(e,t){return Se(gr(hr(this,cr),hr(this,ur),"PATCH",e,t))}delete(e){return Se(gr(hr(this,cr),hr(this,ur),"DELETE",e))}list(){return Se(Wt(hr(this,cr),hr(this,ur),{uri:"/datasets",tag:null}))}}function gr(e,t,r,n,o){return Ue(n),Wt(e,t,{method:r,uri:"/datasets/".concat(n),body:o,tag:null})}cr=new WeakMap,ur=new WeakMap;var vr,mr,wr,br,Cr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Er=(e,t,r)=>(Cr(e,t,"read from private field"),r?r.call(e):t.get(e)),xr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Tr=(e,t,r,n)=>(Cr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Or{constructor(e,t){xr(this,vr,void 0),xr(this,mr,void 0),Tr(this,vr,e),Tr(this,mr,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Wt(Er(this,vr),Er(this,mr),{uri:t})}getById(e){return Wt(Er(this,vr),Er(this,mr),{uri:"/projects/".concat(e)})}}vr=new WeakMap,mr=new WeakMap;class Sr{constructor(e,t){xr(this,wr,void 0),xr(this,br,void 0),Tr(this,wr,e),Tr(this,br,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Se(Wt(Er(this,wr),Er(this,br),{uri:t}))}getById(e){return Se(Wt(Er(this,wr),Er(this,br),{uri:"/projects/".concat(e)}))}}wr=new WeakMap,br=new WeakMap;var _r,jr,Ar,kr,Rr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Mr=(e,t,r)=>(Rr(e,t,"read from private field"),r?r.call(e):t.get(e)),Fr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Ir=(e,t,r,n)=>(Rr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Pr{constructor(e,t){Fr(this,_r,void 0),Fr(this,jr,void 0),Ir(this,_r,e),Ir(this,jr,t)}getById(e){return Wt(Mr(this,_r),Mr(this,jr),{uri:"/users/".concat(e)})}}_r=new WeakMap,jr=new WeakMap;class Dr{constructor(e,t){Fr(this,Ar,void 0),Fr(this,kr,void 0),Ir(this,Ar,e),Ir(this,kr,t)}getById(e){return Se(Wt(Mr(this,Ar),Mr(this,kr),{uri:"/users/".concat(e)}))}}Ar=new WeakMap,kr=new WeakMap;var qr,Nr,Hr,Wr,zr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Ur=(e,t,r)=>(zr(e,t,"read from private field"),r?r.call(e):t.get(e)),Lr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Br=(e,t,r,n)=>(zr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);qr=new WeakMap,Nr=new WeakMap;let $r=class e{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et;Lr(this,qr,void 0),Lr(this,Nr,void 0),this.listen=or,this.config(t),Br(this,Nr,e),this.assets=new Zt(this,Ur(this,Nr)),this.datasets=new fr(this,Ur(this,Nr)),this.projects=new Or(this,Ur(this,Nr)),this.users=new Pr(this,Ur(this,Nr))}clone(){return new e(Ur(this,Nr),this.config())}config(e){if(void 0===e)return{...Ur(this,qr)};if(Ur(this,qr)&&!1===Ur(this,qr).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return Br(this,qr,nt(e,Ur(this,qr)||{})),this}withConfig(t){return new e(Ur(this,Nr),{...this.config(),...t})}fetch(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return kt(this,Ur(this,Nr),e,t,r)}getDocument(e,t){return Rt(this,Ur(this,Nr),e,t)}getDocuments(e,t){return Mt(this,Ur(this,Nr),e,t)}create(e,t){return Nt(this,Ur(this,Nr),e,"create",t)}createIfNotExists(e,t){return Ft(this,Ur(this,Nr),e,t)}createOrReplace(e,t){return It(this,Ur(this,Nr),e,t)}delete(e,t){return Pt(this,Ur(this,Nr),e,t)}mutate(e,t){return Dt(this,Ur(this,Nr),e,t)}patch(e,t){return new ft(e,t,this)}transaction(e){return new Ot(e,this)}request(e){return Wt(this,Ur(this,Nr),e)}getUrl(e,t){return Ut(this,e,t)}getDataUrl(e,t){return zt(this,e,t)}};Hr=new WeakMap,Wr=new WeakMap;let Gr=class e{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et;Lr(this,Hr,void 0),Lr(this,Wr,void 0),this.listen=or,this.config(t),Br(this,Wr,e),this.assets=new Qt(this,Ur(this,Wr)),this.datasets=new yr(this,Ur(this,Wr)),this.projects=new Sr(this,Ur(this,Wr)),this.users=new Dr(this,Ur(this,Wr)),this.observable=new $r(e,t)}clone(){return new e(Ur(this,Wr),this.config())}config(e){if(void 0===e)return{...Ur(this,Hr)};if(Ur(this,Hr)&&!1===Ur(this,Hr).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.observable&&this.observable.config(e),Br(this,Hr,nt(e,Ur(this,Hr)||{})),this}withConfig(t){return new e(Ur(this,Wr),{...this.config(),...t})}fetch(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Se(kt(this,Ur(this,Wr),e,t,r))}getDocument(e,t){return Se(Rt(this,Ur(this,Wr),e,t))}getDocuments(e,t){return Se(Mt(this,Ur(this,Wr),e,t))}create(e,t){return Se(Nt(this,Ur(this,Wr),e,"create",t))}createIfNotExists(e,t){return Se(Ft(this,Ur(this,Wr),e,t))}createOrReplace(e,t){return Se(It(this,Ur(this,Wr),e,t))}delete(e,t){return Se(Pt(this,Ur(this,Wr),e,t))}mutate(e,t){return Se(Dt(this,Ur(this,Wr),e,t))}patch(e,t){return new yt(e,t,this)}transaction(e){return new Tt(e,this)}request(e){return Se(Wt(this,Ur(this,Wr),e))}dataRequest(e,t,r){return Se(qt(this,Ur(this,Wr),e,t,r))}getUrl(e,t){return Ut(this,e,t)}getDataUrl(e,t){return zt(this,e,t)}};const Vr=qe(Ae,{}),Jr=Vr.defaultRequester;var Xr={exports:{}};
|
|
9
9
|
/** @license
|
|
10
10
|
* eventsource.js
|
|
11
11
|
* Available under MIT License (MIT)
|