@sanity/client 6.15.17 → 6.15.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "6.15.17",
3
+ "version": "6.15.18",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -126,7 +126,7 @@
126
126
  "@edge-runtime/vm": "^3.2.0",
127
127
  "@rollup/plugin-commonjs": "^25.0.7",
128
128
  "@rollup/plugin-node-resolve": "^15.2.3",
129
- "@sanity/pkg-utils": "^6.6.6",
129
+ "@sanity/pkg-utils": "^6.7.1",
130
130
  "@types/json-diff": "^1.0.3",
131
131
  "@types/node": "^20.8.8",
132
132
  "@typescript-eslint/eslint-plugin": "^7.7.0",
@@ -141,7 +141,7 @@
141
141
  "happy-dom": "^12.10.3",
142
142
  "json-diff": "^1.0.6",
143
143
  "ls-engines": "^0.9.1",
144
- "next": "^14.2.1",
144
+ "next": "^14.2.2",
145
145
  "nock": "^13.5.4",
146
146
  "prettier": "^3.2.5",
147
147
  "prettier-plugin-packagejson": "^2.5.0",
@@ -1,7 +1,7 @@
1
1
  import type {Middlewares} from 'get-it'
2
2
 
3
3
  import {defineHttpRequest} from './http/request'
4
- import type {ClientConfig, HttpRequest} from './types'
4
+ import type {Any, ClientConfig, HttpRequest} from './types'
5
5
 
6
6
  export * from './data/patch'
7
7
  export * from './data/transaction'
@@ -24,17 +24,19 @@ export default function defineCreateClientExports<
24
24
  ClassConstructor: new (httpRequest: HttpRequest, config: ClientConfigType) => SanityClientType,
25
25
  ) {
26
26
  // Set the http client to use for requests, and its environment specific middleware
27
- const httpRequest = defineHttpRequest(envMiddleware, {})
28
- const requester = httpRequest.defaultRequester
27
+ const defaultRequester = defineHttpRequest(envMiddleware)
29
28
 
30
29
  const createClient = (config: ClientConfigType) =>
31
30
  new ClassConstructor(
32
- defineHttpRequest(envMiddleware, {
33
- maxRetries: config.maxRetries,
34
- retryDelay: config.retryDelay,
35
- }),
31
+ (options, requester) =>
32
+ (requester || defaultRequester)({
33
+ maxRedirects: 0,
34
+ maxRetries: config.maxRetries,
35
+ retryDelay: config.retryDelay,
36
+ ...options,
37
+ } as Any),
36
38
  config,
37
39
  )
38
40
 
39
- return {requester, createClient}
41
+ return {requester: defaultRequester, createClient}
40
42
  }
@@ -1,8 +1,8 @@
1
- import {getIt, type Middlewares} from 'get-it'
1
+ import {getIt, type Middlewares, Requester} from 'get-it'
2
2
  import {jsonRequest, jsonResponse, observable, progress, retry} from 'get-it/middleware'
3
3
  import {Observable} from 'rxjs'
4
4
 
5
- import type {Any, HttpRequest, RequestOptions} from '../types'
5
+ import type {Any} from '../types'
6
6
  import {ClientError, ServerError} from './errors'
7
7
 
8
8
  const httpError = {
@@ -27,22 +27,9 @@ const printWarnings = {
27
27
  }
28
28
 
29
29
  /** @internal */
30
- export function defineHttpRequest(
31
- envMiddleware: Middlewares,
32
- {
33
- maxRetries = 5,
34
- retryDelay,
35
- }: {maxRetries?: number; retryDelay?: (attemptNumber: number) => number},
36
- ): HttpRequest {
37
- const request = getIt([
38
- maxRetries > 0
39
- ? retry({
40
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
- retryDelay: retryDelay as any, // This option is typed incorrectly in get-it.
42
- maxRetries,
43
- shouldRetry,
44
- })
45
- : {},
30
+ export function defineHttpRequest(envMiddleware: Middlewares): Requester {
31
+ return getIt([
32
+ retry({shouldRetry}),
46
33
  ...envMiddleware,
47
34
  printWarnings,
48
35
  jsonRequest(),
@@ -51,18 +38,13 @@ export function defineHttpRequest(
51
38
  httpError,
52
39
  observable({implementation: Observable}),
53
40
  ])
54
-
55
- function httpRequest(options: RequestOptions, requester = request) {
56
- return requester({maxRedirects: 0, ...options} as Any)
57
- }
58
-
59
- httpRequest.defaultRequester = request
60
-
61
- return httpRequest
62
41
  }
63
42
 
64
43
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
44
  function shouldRetry(err: any, attempt: number, options: any) {
45
+ // Allow opting out of retries
46
+ if (options.maxRetries === 0) return false
47
+
66
48
  // By default `retry.shouldRetry` doesn't retry on server errors so we add our own logic.
67
49
 
68
50
  const isSafe = options.method === 'GET' || options.method === 'HEAD'
package/src/types.ts CHANGED
@@ -293,7 +293,6 @@ export interface ErrorProps {
293
293
 
294
294
  /** @public */
295
295
  export type HttpRequest = {
296
- defaultRequester: Requester
297
296
  (options: RequestOptions, requester: Requester): ReturnType<Requester>
298
297
  }
299
298
 
@@ -2018,18 +2018,9 @@
2018
2018
  return (Array.isArray(warn) ? warn : [warn]).filter(Boolean).forEach((msg) => console.warn(msg)), res;
2019
2019
  }
2020
2020
  };
2021
- function defineHttpRequest(envMiddleware2, {
2022
- maxRetries = 5,
2023
- retryDelay
2024
- }) {
2025
- const request = getIt([
2026
- maxRetries > 0 ? retry({
2027
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2028
- retryDelay,
2029
- // This option is typed incorrectly in get-it.
2030
- maxRetries,
2031
- shouldRetry
2032
- }) : {},
2021
+ function defineHttpRequest(envMiddleware2) {
2022
+ return getIt([
2023
+ retry({ shouldRetry }),
2033
2024
  ...envMiddleware2,
2034
2025
  printWarnings,
2035
2026
  jsonRequest(),
@@ -2038,12 +2029,10 @@
2038
2029
  httpError,
2039
2030
  observable$1({ implementation: Observable })
2040
2031
  ]);
2041
- function httpRequest(options, requester2 = request) {
2042
- return requester2({ maxRedirects: 0, ...options });
2043
- }
2044
- return httpRequest.defaultRequester = request, httpRequest;
2045
2032
  }
2046
2033
  function shouldRetry(err, attempt, options) {
2034
+ if (options.maxRetries === 0)
2035
+ return !1;
2047
2036
  const isSafe = options.method === "GET" || options.method === "HEAD", isQuery = (options.uri || options.url).startsWith("/data/query"), isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
2048
2037
  return (isSafe || isQuery) && isRetriableResponse ? !0 : retry.shouldRetry(err, attempt, options);
2049
2038
  }
@@ -3361,10 +3350,13 @@ ${selectionOpts}`);
3361
3350
  _clientConfig2 = /* @__PURE__ */ new WeakMap(), _httpRequest2 = /* @__PURE__ */ new WeakMap();
3362
3351
  let SanityClient = _SanityClient;
3363
3352
  function defineCreateClientExports(envMiddleware2, ClassConstructor) {
3364
- return { requester: defineHttpRequest(envMiddleware2, {}).defaultRequester, createClient: (config) => new ClassConstructor(
3365
- defineHttpRequest(envMiddleware2, {
3353
+ const defaultRequester = defineHttpRequest(envMiddleware2);
3354
+ return { requester: defaultRequester, createClient: (config) => new ClassConstructor(
3355
+ (options, requester2) => (requester2 || defaultRequester)({
3356
+ maxRedirects: 0,
3366
3357
  maxRetries: config.maxRetries,
3367
- retryDelay: config.retryDelay
3358
+ retryDelay: config.retryDelay,
3359
+ ...options
3368
3360
  }),
3369
3361
  config
3370
3362
  ) };
@@ -4,9 +4,9 @@
4
4
  *
5
5
  * Copyright (c) 2014-2017, Jon Schlinkert.
6
6
  * Released under the MIT License.
7
- */;function M(e){return"[object Object]"===Object.prototype.toString.call(e)}const D=["boolean","string","number"];function F(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||R(t)||-1===D.indexOf(typeof t)&&!Array.isArray(t)&&!function(e){if(!1===M(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!(!1===M(r)||!1===r.hasOwnProperty("isPrototypeOf"))}(t)?e:Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})})}}}function q(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: ${e.message}`,e}}}let N={};typeof globalThis<"u"?N=globalThis:typeof window<"u"?N=window:typeof global<"u"?N=global:typeof self<"u"&&(N=self);var U=N;function W(e={}){const t=e.implementation||U.Observable;if(!t)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(e,r)=>new t((t=>(e.error.subscribe((e=>t.error(e))),e.progress.subscribe((e=>t.next(Object.assign({type:"progress"},e)))),e.response.subscribe((e=>{t.next(Object.assign({type:"response"},e)),t.complete()})),e.request.publish(r),()=>e.abort.publish())))}}class L{constructor(e){this.__CANCEL__=!0,this.message=e}toString(){return"Cancel"+(this.message?`: ${this.message}`:"")}}const H=class{constructor(e){if("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 L(e),t(this.reason))}))}};H.source=()=>{let e;return{token:new H((t=>{e=t})),cancel:e}};var z=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function B(e){return 100*Math.pow(2,e)+100*Math.random()}const J=(e={})=>(e=>{const t=e.maxRetries||5,r=e.retryDelay||B,n=e.shouldRetry;return{onError:(e,o)=>{const s=o.options,i=s.maxRetries||t,a=s.retryDelay||r,u=s.shouldRetry||n,c=s.attemptNumber||0;if(null!==(l=s.body)&&"object"==typeof l&&"function"==typeof l.pipe||!u(e,c,s)||c>=i)return e;var l;const f=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:c+1})});return setTimeout((()=>o.channels.request.publish(f)),a(c)),null}}})({shouldRetry:z,...e});J.shouldRetry=z;var G=function(e,t){return G=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])},G(e,t)};function V(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}G(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function Q(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))}function Y(e,t){var r,n,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function X(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 K(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 Z(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 ee(e){return this instanceof ee?(this.v=e,this):new ee(e)}function te(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),s=[];return n={},i("next"),i("throw"),i("return"),n[Symbol.asyncIterator]=function(){return this},n;function i(e){o[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||a(e,t)}))})}function a(e,t){try{(r=o[e](t)).value instanceof ee?Promise.resolve(r.value.v).then(u,c):l(s[0][2],r)}catch(e){l(s[0][3],e)}var r}function u(e){a("next",e)}function c(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function re(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=X(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,o,(t=e[r](t)).done,t.value)}))}}}function ne(e){return"function"==typeof e}function oe(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 se=oe((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 ie(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var ae=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=X(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 u=this.initialTeardown;if(ne(u))try{u()}catch(e){o=e instanceof se?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var l=X(c),f=l.next();!f.done;f=l.next()){var h=f.value;try{ce(h)}catch(e){o=null!=o?o:[],e instanceof se?o=Z(Z([],K(o)),K(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(o)throw new se(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)ce(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)&&ie(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&ie(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function ue(e){return e instanceof ae||e&&"closed"in e&&ne(e.remove)&&ne(e.add)&&ne(e.unsubscribe)}function ce(e){ne(e)?e():e.unsubscribe()}ae.EMPTY;var le={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},fe={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,Z([e,t],K(r)))},clearTimeout:function(e){var t=fe.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function he(e){fe.setTimeout((function(){throw e}))}function de(){}var pe=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,ue(t)&&t.add(r)):r.destination=we,r}return V(t,e),t.create=function(e,t,r){return new ve(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}(ae),ye=Function.prototype.bind;function me(e,t){return ye.call(e,t)}var ge=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){be(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){be(e)}else be(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){be(e)}},e}(),ve=function(e){function t(t,r,n){var o,s,i=e.call(this)||this;ne(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:i&&le.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&me(t.next,s),error:t.error&&me(t.error,s),complete:t.complete&&me(t.complete,s)}):o=t;return i.destination=new ge(o),i}return V(t,e),t}(pe);function be(e){he(e)}var we={closed:!0,next:de,error:function(e){throw e},complete:de},Ce="function"==typeof Symbol&&Symbol.observable||"@@observable";function Ee(e){return e}function xe(e){return 0===e.length?Ee:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var Se=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 pe||function(e){return e&&ne(e.next)&&ne(e.error)&&ne(e.complete)}(n)&&ue(n)?e:new ve(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=Te(t))((function(t,n){var o=new ve({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[Ce]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return xe(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Te(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 Te(e){var t;return null!==(t=null!=e?e:le.Promise)&&void 0!==t?t:Promise}function _e(e){return function(t){if(function(e){return ne(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 Oe(e,t,r,n,o){return new je(e,t,r,n,o)}var je=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 V(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}(pe);var $e=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function ke(e){return ne(null==e?void 0:e.then)}function Ae(e){return ne(e[Ce])}function Pe(e){return Symbol.asyncIterator&&ne(null==e?void 0:e[Symbol.asyncIterator])}function Ie(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var Re="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Me(e){return ne(null==e?void 0:e[Re])}function De(e){return te(this,arguments,(function(){var t,r,n;return Y(this,(function(o){switch(o.label){case 0:t=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,ee(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,ee(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,ee(n)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}function Fe(e){return ne(null==e?void 0:e.getReader)}function qe(e){if(e instanceof Se)return e;if(null!=e){if(Ae(e))return o=e,new Se((function(e){var t=o[Ce]();if(ne(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if($e(e))return n=e,new Se((function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()}));if(ke(e))return r=e,new Se((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,he)}));if(Pe(e))return Ne(e);if(Me(e))return t=e,new Se((function(e){var r,n;try{for(var o=X(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(e.next(i),e.closed)return}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}e.complete()}));if(Fe(e))return Ne(De(e))}var t,r,n,o;throw Ie(e)}function Ne(e){return new Se((function(t){(function(e,t){var r,n,o,s;return Q(this,void 0,void 0,(function(){var i,a;return Y(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),r=re(e),u.label=1;case 1:return[4,r.next()];case 2:if((n=u.sent()).done)return[3,4];if(i=n.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=u.sent(),o={error:a},[3,11];case 6:return u.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))})(e,t).catch((function(e){return t.error(e)}))}))}function Ue(e,t,r,n,o){void 0===n&&(n=0),void 0===o&&(o=!1);var s=t.schedule((function(){r(),o?e.add(this.schedule(null,n)):this.unsubscribe()}),n);if(e.add(s),!o)return s}function We(e,t){return void 0===t&&(t=0),_e((function(r,n){r.subscribe(Oe(n,(function(r){return Ue(n,e,(function(){return n.next(r)}),t)}),(function(){return Ue(n,e,(function(){return n.complete()}),t)}),(function(r){return Ue(n,e,(function(){return n.error(r)}),t)})))}))}function Le(e,t){return void 0===t&&(t=0),_e((function(r,n){n.add(e.schedule((function(){return r.subscribe(n)}),t))}))}function He(e,t){if(!e)throw new Error("Iterable cannot be null");return new Se((function(r){Ue(r,t,(function(){var n=e[Symbol.asyncIterator]();Ue(r,t,(function(){n.next().then((function(e){e.done?r.complete():r.next(e.value)}))}),0,!0)}))}))}function ze(e,t){if(null!=e){if(Ae(e))return function(e,t){return qe(e).pipe(Le(t),We(t))}(e,t);if($e(e))return function(e,t){return new Se((function(r){var n=0;return t.schedule((function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())}))}))}(e,t);if(ke(e))return function(e,t){return qe(e).pipe(Le(t),We(t))}(e,t);if(Pe(e))return He(e,t);if(Me(e))return function(e,t){return new Se((function(r){var n;return Ue(r,t,(function(){n=e[Re](),Ue(r,t,(function(){var e,t,o;try{t=(e=n.next()).value,o=e.done}catch(e){return void r.error(e)}o?r.complete():r.next(t)}),0,!0)})),function(){return ne(null==n?void 0:n.return)&&n.return()}}))}(e,t);if(Fe(e))return function(e,t){return He(De(e),t)}(e,t)}throw Ie(e)}function Be(e,t){return t?ze(e,t):qe(e)}var Je=oe((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Ge(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 Je)}})}))}function Ve(e,t){return _e((function(r,n){var o=0;r.subscribe(Oe(n,(function(r){n.next(e.call(t,r,o++))})))}))}var Qe=Array.isArray;function Ye(e){return Ve((function(t){return function(e,t){return Qe(t)?e.apply(void 0,Z([],K(t))):e(t)}(e,t)}))}function Xe(e,t,r){e?Ue(r,e,t):t()}var Ke=Array.isArray;function Ze(e,t){return _e((function(r,n){var o=0;r.subscribe(Oe(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function et(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return ne((t=e)[t.length-1])?e.pop():void 0;var t}(e);return r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return xe(e)}(et.apply(void 0,Z([],K(e))),Ye(r)):_e((function(t,r){var n,o,s;(n=Z([t],K(function(e){return 1===e.length&&Ke(e[0])?e[0]:e}(e))),void 0===s&&(s=Ee),function(e){Xe(o,(function(){for(var t=n.length,r=new Array(t),i=t,a=t,u=function(t){Xe(o,(function(){var u=Be(n[t],o),c=!1;u.subscribe(Oe(e,(function(n){r[t]=n,c||(c=!0,a--),a||e.next(s(r.slice()))}),(function(){--i||e.complete()})))}),e)},c=0;c<t;c++)u(c)}),e)})(r)}))}var tt={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},rt={0:8203,1:8204,2:8205,3:65279},nt=new Array(4).fill(String.fromCodePoint(rt[0])).join("");function ot(e,t,r="auto"){return!0===r||"auto"===r&&(function(e){return!!Number.isNaN(Number(e))&&!!Date.parse(e)}(e)||function(e){try{new URL(e,e.startsWith("/")?"https://acme.com":void 0)}catch{return!1}return!0}(e))?e:`${e}${function(e){let t=JSON.stringify(e);return`${nt}${Array.from(t).map((e=>{let r=e.charCodeAt(0);if(r>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${t} on character ${e} (${r})`);return Array.from(r.toString(4).padStart(4,"0")).map((e=>String.fromCodePoint(rt[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(rt).map((e=>e.reverse()))),Object.fromEntries(Object.entries(tt).map((e=>e.reverse())));var st=`${Object.values(tt).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,it=new RegExp(`[${st}]{4,}`,"gu");function at(e){try{return JSON.parse(JSON.stringify(e,((e,t)=>{return"string"!=typeof t?t:(r=t,{cleaned:r.replace(it,""),encoded:(null==(n=r.match(it))?void 0:n[0])||""}).cleaned;var r,n})))}catch{return e}}var ut=Object.defineProperty,ct=(e,t,r)=>(((e,t,r)=>{t in e?ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class lt extends Error{constructor(e){const t=ht(e);super(t.message),ct(this,"response"),ct(this,"statusCode",400),ct(this,"responseBody"),ct(this,"details"),Object.assign(this,t)}}class ft extends Error{constructor(e){const t=ht(e);super(t.message),ct(this,"response"),ct(this,"statusCode",500),ct(this,"responseBody"),ct(this,"details"),Object.assign(this,t)}}function ht(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:pt(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message=`${t.error} - ${t.message}`,r;if(function(e){return dt(e)&&dt(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- ${n.join("\n- ")}`:"";return e.length>5&&(o+=`\n...and ${e.length-5} more`),r.message=`${t.error.description}${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?` ${e.statusMessage}`:"";return`${e.method}-request to ${e.url} resulted in HTTP ${e.statusCode}${t}`}(e),r)}function dt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function pt(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const yt={onResponse:e=>{if(e.statusCode>=500)throw new ft(e);if(e.statusCode>=400)throw new lt(e);return e}},mt={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};function gt(e,{maxRetries:t=5,retryDelay:r}){const n=j([t>0?J({retryDelay:r,maxRetries:t,shouldRetry:vt}):{},...e,mt,F(),q(),{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"))}},yt,W({implementation:Se})]);function o(e,t=n){return t({maxRedirects:0,...e})}return o.defaultRequester=n,o}function vt(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)||J.shouldRetry(e,t,r)}function bt(e){if("string"==typeof e)return{id:e};if(Array.isArray(e))return{query:"*[_id in $ids]",params:{ids: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${t}`)}const wt=["image","file"],Ct=["before","after","replace"],Et=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")},xt=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},St=(e,t)=>{if("string"!=typeof t||!/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(t)||t.includes(".."))throw new Error(`${e}(): "${t}" is not a valid document ID`)},Tt=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);St(e,t._id)},_t=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},Ot=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};var jt,$t=Object.defineProperty,kt=(e,t,r)=>(((e,t,r)=>{t in e?$t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),At=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Pt=(e,t,r)=>(At(e,t,"read from private field"),r?r.call(e):t.get(e)),It=(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)},Rt=(e,t,r,n)=>(At(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Mt{constructor(e,t={}){kt(this,"selection"),kt(this,"operations"),this.selection=e,this.operations=t}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return xt("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===Ct.indexOf(e)){const e=Ct.map((e=>`"${e}"`)).join(", ");throw new Error(`${n} takes an "at"-argument which is one of: ${e}`)}if("string"!=typeof t)throw new Error(`${n} takes a "selector"-argument which must be a string`);if(!Array.isArray(r))throw new Error(`${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",`${e}[-1]`,t)}prepend(e,t){return this.insert("before",`${e}[0]`,t)}splice(e,t,r,n){const o=t<0?t-1:t,s=typeof r>"u"||-1===r?-1:Math.max(0,t+r),i=`${e}[${o}:${o<0&&s>=0?"":s}]`;return this.insert("replace",i,n||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...bt(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return xt(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)}}jt=new WeakMap;let Dt=class e extends Mt{constructor(e,t,r){super(e,t),It(this,jt,void 0),Rt(this,jt,r)}clone(){return new e(this.selection,{...this.operations},Pt(this,jt))}commit(e){if(!Pt(this,jt))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 Pt(this,jt).mutate({patch:this.serialize()},r)}};var Ft;Ft=new WeakMap;let qt=class e extends Mt{constructor(e,t,r){super(e,t),It(this,Ft,void 0),Rt(this,Ft,r)}clone(){return new e(this.selection,{...this.operations},Pt(this,Ft))}commit(e){if(!Pt(this,Ft))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 Pt(this,Ft).mutate({patch:this.serialize()},r)}};var Nt=Object.defineProperty,Ut=(e,t,r)=>(((e,t,r)=>{t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),Wt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Lt=(e,t,r)=>(Wt(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)},zt=(e,t,r,n)=>(Wt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);const Bt={returnDocuments:!1};class Jt{constructor(e=[],t){Ut(this,"operations"),Ut(this,"trxId"),this.operations=e,this.trxId=t}create(e){return xt("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return xt(t,e),Tt(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return xt(t,e),Tt(t,e),this._add({[t]:e})}delete(e){return St("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}}var Gt;Gt=new WeakMap;let Vt=class e extends Jt{constructor(e,t,r){super(e,r),Ht(this,Gt,void 0),zt(this,Gt,t)}clone(){return new e([...this.operations],Lt(this,Gt),this.trxId)}commit(e){if(!Lt(this,Gt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Lt(this,Gt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Bt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof qt)return this._add({patch:e.serialize()});if(r){const r=t(new qt(e,{},Lt(this,Gt)));if(!(r instanceof qt))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};var Qt;Qt=new WeakMap;let Yt=class e extends Jt{constructor(e,t,r){super(e,r),Ht(this,Qt,void 0),zt(this,Qt,t)}clone(){return new e([...this.operations],Lt(this,Qt),this.trxId)}commit(e){if(!Lt(this,Qt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Lt(this,Qt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Bt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof Dt)return this._add({patch:e.serialize()});if(r){const r=t(new Dt(e,{},Lt(this,Qt)));if(!(r instanceof Dt))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};function Xt(e){return"https://www.sanity.io/help/"+e}const Kt=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),Zt=Kt(["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."]),er=Kt(["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."]),tr=Kt(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${Xt("js-client-browser-token")} for more information and how to hide this warning.`]),rr=Kt(["Using the Sanity client without specifying an API version is deprecated.",`See ${Xt("js-client-api-version")}`]),nr=Kt(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),or={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},sr=["localhost","127.0.0.1","0.0.0.0"];const ir=function(e){switch(e){case"previewDrafts":case"published":case"raw":return;default:throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`")}},ar=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||or.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||rr();const n={...or,...r},o=n.useProjectHostname;if(typeof Promise>"u"){const e=Xt("js-client-promise-polyfill");throw new Error(`No native Promise-implementation found, polyfill needed - see ${e}`)}if(o&&!n.projectId)throw new Error("Configuration must contain `projectId`");if("string"==typeof n.perspective&&ir(n.perspective),"encodeSourceMap"in n)throw new Error("It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMap' is not supported in '@sanity/client'. Did you mean 'stega.enabled'?");if("encodeSourceMapAtPath"in n)throw new Error("It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMapAtPath' is not supported in '@sanity/client'. Did you mean 'stega.filter'?");if("boolean"!=typeof n.stega.enabled)throw new Error(`stega.enabled must be a boolean, received ${n.stega.enabled}`);if(n.stega.enabled&&void 0===n.stega.studioUrl)throw new Error("stega.studioUrl must be defined when stega.enabled is true");if(n.stega.enabled&&"string"!=typeof n.stega.studioUrl&&"function"!=typeof n.stega.studioUrl)throw new Error(`stega.studioUrl must be a string or a function, received ${n.stega.studioUrl}`);const s=typeof window<"u"&&window.location&&window.location.hostname,i=s&&(e=>-1!==sr.indexOf(e))(window.location.hostname);s&&i&&n.token&&!0!==n.ignoreBrowserTokenWarning?tr():typeof n.useCdn>"u"&&Zt(),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&&Et(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?Ot(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===or.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),u=a[0],c=a[1],l=n.isDefaultApi?"apicdn.sanity.io":c;return n.useProjectHostname?(n.url=`${u}://${n.projectId}.${c}/v${n.apiVersion}`,n.cdnUrl=`${u}://${n.projectId}.${l}/v${n.apiVersion}`):(n.url=`${n.apiHost}/v${n.apiVersion}`,n.cdnUrl=n.url),n},ur="X-Sanity-Project-ID";const cr=({query:e,params:t={},options:r={}})=>{const n=new URLSearchParams,{tag:o,returnQuery:s,...i}=r;o&&n.append("tag",o),n.append("query",e);for(const[e,r]of Object.entries(t))n.append(`$${e}`,JSON.stringify(r));for(const[e,t]of Object.entries(i))t&&n.append(e,`${t}`);return!1===s&&n.append("returnQuery","false"),`?${n}`},lr=(e={})=>{return{dryRun:e.dryRun,returnIds:!0,returnDocuments:(t=e.returnDocuments,r=!0,!1===t?void 0:typeof t>"u"?r:t),visibility:e.visibility||"sync",autoGenerateArrayKeys:e.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:e.skipCrossDatasetReferenceValidation};var t,r},fr=e=>"response"===e.type,hr=e=>e.body,dr=11264;function pr(e,t,r,n,o={},s={}){const i="stega"in s?{...r||{},..."boolean"==typeof s.stega?{enabled:s.stega}:s.stega||{}}:r,a=i.enabled?at(o):o,u=!1===s.filterResponse?e=>e:e=>e.result,{cache:c,next:l,...f}={useAbortSignal:typeof s.signal<"u",resultSourceMap:i.enabled?"withKeyArraySelector":s.resultSourceMap,...s,returnQuery:!1===s.filterResponse&&!1!==s.returnQuery},h=Cr(e,t,"query",{query:n,params:a},typeof c<"u"||typeof l<"u"?{...f,fetch:{cache:c,next:l}}:f);return i.enabled?h.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return et.apply(void 0,Z([],K(e)))}(Be(Promise.resolve().then((function(){return oo})).then((function(e){return e.a})).then((({stegaEncodeSourceMap:e})=>e)))),Ve((([e,t])=>{const r=t(e.result,e.resultSourceMap,i);return u({...e,result:r})}))):h.pipe(Ve(u))}function yr(e,t,r,n={}){return xr(e,t,{uri:Tr(e,"doc",r),json:!0,tag:n.tag}).pipe(Ze(fr),Ve((e=>e.body.documents&&e.body.documents[0])))}function mr(e,t,r,n={}){return xr(e,t,{uri:Tr(e,"doc",r.join(",")),json:!0,tag:n.tag}).pipe(Ze(fr),Ve((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 gr(e,t,r,n){return Tt("createIfNotExists",r),Er(e,t,r,"createIfNotExists",n)}function vr(e,t,r,n){return Tt("createOrReplace",r),Er(e,t,r,"createOrReplace",n)}function br(e,t,r,n){return Cr(e,t,"mutate",{mutations:[{delete:bt(r)}]},n)}function wr(e,t,r,n){let o;o=r instanceof qt||r instanceof Dt?{patch:r.serialize()}:r instanceof Vt||r instanceof Yt?r.serialize():r;return Cr(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function Cr(e,t,r,n,o={}){const s="mutate"===r,i="query"===r,a=s?"":cr(n),u=!s&&a.length<dr,c=u?a:"",l=o.returnFirst,{timeout:f,token:h,tag:d,headers:p,returnQuery:y}=o;return xr(e,t,{method:u?"GET":"POST",uri:Tr(e,r,c),json:!0,body:u?void 0:n,query:s&&lr(o),timeout:f,headers:p,token:h,tag:d,returnQuery:y,perspective:o.perspective,resultSourceMap:o.resultSourceMap,canUseCdn:i,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(Ze(fr),Ve(hr),Ve((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 Er(e,t,r,n,o={}){return Cr(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function xr(e,t,r){var n,o;const s=r.url||r.uri,i=e.config(),a=typeof r.canUseCdn>"u"?["GET","HEAD"].indexOf(r.method||"GET")>=0&&0===s.indexOf("/data/"):r.canUseCdn;let u=(null!=(n=r.useCdn)?n:i.useCdn)&&a;const c=r.tag&&i.requestTagPrefix?[i.requestTagPrefix,r.tag].join("."):r.tag||i.requestTagPrefix;if(c&&null!==r.tag&&(r.query={tag:Ot(c),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&0===s.indexOf("/data/query/")){const e=null!=(o=r.resultSourceMap)?o:i.resultSourceMap;void 0!==e&&!1!==e&&(r.query={resultSourceMap:e,...r.query});const t=r.perspective||i.perspective;"string"==typeof t&&"raw"!==t&&(ir(t),r.query={perspective:t,...r.query},"previewDrafts"===t&&u&&(u=!1,er())),!1===r.returnQuery&&(r.query={returnQuery:"false",...r.query})}const l=function(e,t={}){const r={},n=t.token||e.token;n&&(r.Authorization=`Bearer ${n}`),!t.useGlobalApi&&!e.useProjectHostname&&e.projectId&&(r[ur]=e.projectId);const o=!!(typeof t.withCredentials>"u"?e.token||e.withCredentials:t.withCredentials),s=typeof t.timeout>"u"?e.timeout:t.timeout;return Object.assign({},t,{headers:Object.assign({},r,t.headers||{}),timeout:typeof s>"u"?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})}(i,Object.assign({},r,{url:_r(e,s,u)})),f=new Se((e=>t(l,i.requester).subscribe(e)));return r.signal?f.pipe((h=r.signal,e=>new Se((t=>{const r=()=>t.error(function(e){var t,r;if(Or)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()}})))):f;var h}function Sr(e,t,r){return xr(e,t,r).pipe(Ze((e=>"response"===e.type)),Ve((e=>e.body)))}function Tr(e,t,r){const n=e.config(),o=`/${t}/${_t(n)}`;return`/data${r?`${o}/${r}`:o}`.replace(/\/($|\?)/,"$1")}function _r(e,t,r=!1){const{url:n,cdnUrl:o}=e.config();return`${r?o:n}/${t.replace(/^\//,"")}`}const Or=!!globalThis.DOMException;var jr,$r,kr,Ar,Pr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Ir=(e,t,r)=>(Pr(e,t,"read from private field"),r?r.call(e):t.get(e)),Rr=(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)},Mr=(e,t,r,n)=>(Pr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Dr{constructor(e,t){Rr(this,jr,void 0),Rr(this,$r,void 0),Mr(this,jr,e),Mr(this,$r,t)}upload(e,t,r){return qr(Ir(this,jr),Ir(this,$r),e,t,r)}}jr=new WeakMap,$r=new WeakMap;class Fr{constructor(e,t){Rr(this,kr,void 0),Rr(this,Ar,void 0),Mr(this,kr,e),Mr(this,Ar,t)}upload(e,t,r){return Ge(qr(Ir(this,kr),Ir(this,Ar),e,t,r).pipe(Ze((e=>"response"===e.type)),Ve((e=>e.body.document))))}}function qr(e,t,r,n,o={}){(e=>{if(-1===wt.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${wt.join(", ")}`)})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=_t(e.config()),a="image"===r?"images":"files",u=function(e,t){return typeof File>"u"||!(t instanceof File)?e:Object.assign({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e)}(o,n),{tag:c,label:l,title:f,description:h,creditLine:d,filename:p,source:y}=u,m={label:l,title:f,description:h,filename:p,meta:s,creditLine:d};return y&&(m.sourceId=y.id,m.sourceName=y.name,m.sourceUrl=y.url),xr(e,t,{tag:c,method:"POST",timeout:u.timeout||0,uri:`/assets/${a}/${i}`,headers:u.contentType?{"Content-Type":u.contentType}:{},query:m,body:n})}kr=new WeakMap,Ar=new WeakMap;const Nr=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],Ur={includeResult:!0};function Wr(e,t,r={}){const{url:n,token:o,withCredentials:s,requestTagPrefix:i}=this.config(),a=r.tag&&i?[i,r.tag].join("."):r.tag,u={...(f=r,h=Ur,Object.keys(h).concat(Object.keys(f)).reduce(((e,t)=>(e[t]=typeof f[t]>"u"?h[t]:f[t],e)),{})),tag:a},c=((e,t)=>t.reduce(((t,r)=>(typeof e[r]>"u"||(t[r]=e[r]),t)),{}))(u,Nr),l=`${n}${Tr(this,"listen",cr({query:e,params:t,options:{tag:a,...c}}))}`;var f,h;if(l.length>14800)return new Se((e=>e.error(new Error("Query too large for listener"))));const d=u.events?u.events:["mutation"],p=-1!==d.indexOf("reconnect"),y={};return(o||s)&&(y.withCredentials=!0),o&&(y.headers={Authorization:`Bearer ${o}`}),new Se((e=>{let t;c().then((e=>{t=e})).catch((t=>{e.error(t),h()}));let r,n=!1;function o(){n||(p&&e.next({type:"reconnect"}),!n&&t.readyState===t.CLOSED&&(u(),clearTimeout(r),r=setTimeout(f,100)))}function s(t){e.error(function(e){if(e instanceof Error)return e;const t=Lr(e);return t instanceof Error?t:new Error(function(e){return e.error?e.error.description?e.error.description:"string"==typeof e.error?e.error:JSON.stringify(e.error,null,2):e.message||"Unknown listener error"}(t))}(t))}function i(t){const r=Lr(t);return r instanceof Error?e.error(r):e.next(r)}function a(){n=!0,u(),e.complete()}function u(){t&&(t.removeEventListener("error",o),t.removeEventListener("channelError",s),t.removeEventListener("disconnect",a),d.forEach((e=>t.removeEventListener(e,i))),t.close())}async function c(){const{default:e}=await Promise.resolve().then((function(){return co})),t=new e(l,y);return t.addEventListener("error",o),t.addEventListener("channelError",s),t.addEventListener("disconnect",a),d.forEach((e=>t.addEventListener(e,i))),t}function f(){c().then((e=>{t=e})).catch((t=>{e.error(t),h()}))}function h(){n=!0,u()}return h}))}function Lr(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}var Hr,zr,Br,Jr,Gr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Vr=(e,t,r)=>(Gr(e,t,"read from private field"),r?r.call(e):t.get(e)),Qr=(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)},Yr=(e,t,r,n)=>(Gr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Xr{constructor(e,t){Qr(this,Hr,void 0),Qr(this,zr,void 0),Yr(this,Hr,e),Yr(this,zr,t)}create(e,t){return Zr(Vr(this,Hr),Vr(this,zr),"PUT",e,t)}edit(e,t){return Zr(Vr(this,Hr),Vr(this,zr),"PATCH",e,t)}delete(e){return Zr(Vr(this,Hr),Vr(this,zr),"DELETE",e)}list(){return Sr(Vr(this,Hr),Vr(this,zr),{uri:"/datasets",tag:null})}}Hr=new WeakMap,zr=new WeakMap;class Kr{constructor(e,t){Qr(this,Br,void 0),Qr(this,Jr,void 0),Yr(this,Br,e),Yr(this,Jr,t)}create(e,t){return Ge(Zr(Vr(this,Br),Vr(this,Jr),"PUT",e,t))}edit(e,t){return Ge(Zr(Vr(this,Br),Vr(this,Jr),"PATCH",e,t))}delete(e){return Ge(Zr(Vr(this,Br),Vr(this,Jr),"DELETE",e))}list(){return Ge(Sr(Vr(this,Br),Vr(this,Jr),{uri:"/datasets",tag:null}))}}function Zr(e,t,r,n,o){return Et(n),Sr(e,t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}Br=new WeakMap,Jr=new WeakMap;var en,tn,rn,nn,on=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},sn=(e,t,r)=>(on(e,t,"read from private field"),r?r.call(e):t.get(e)),an=(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)},un=(e,t,r,n)=>(on(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class cn{constructor(e,t){an(this,en,void 0),an(this,tn,void 0),un(this,en,e),un(this,tn,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Sr(sn(this,en),sn(this,tn),{uri:t})}getById(e){return Sr(sn(this,en),sn(this,tn),{uri:`/projects/${e}`})}}en=new WeakMap,tn=new WeakMap;class ln{constructor(e,t){an(this,rn,void 0),an(this,nn,void 0),un(this,rn,e),un(this,nn,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Ge(Sr(sn(this,rn),sn(this,nn),{uri:t}))}getById(e){return Ge(Sr(sn(this,rn),sn(this,nn),{uri:`/projects/${e}`}))}}rn=new WeakMap,nn=new WeakMap;var fn,hn,dn,pn,yn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},mn=(e,t,r)=>(yn(e,t,"read from private field"),r?r.call(e):t.get(e)),gn=(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)},vn=(e,t,r,n)=>(yn(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class bn{constructor(e,t){gn(this,fn,void 0),gn(this,hn,void 0),vn(this,fn,e),vn(this,hn,t)}getById(e){return Sr(mn(this,fn),mn(this,hn),{uri:`/users/${e}`})}}fn=new WeakMap,hn=new WeakMap;class wn{constructor(e,t){gn(this,dn,void 0),gn(this,pn,void 0),vn(this,dn,e),vn(this,pn,t)}getById(e){return Ge(Sr(mn(this,dn),mn(this,pn),{uri:`/users/${e}`}))}}dn=new WeakMap,pn=new WeakMap;var Cn,En,xn=Object.defineProperty,Sn=(e,t,r)=>(((e,t,r)=>{t in e?xn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),Tn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},_n=(e,t,r)=>(Tn(e,t,"read from private field"),r?r.call(e):t.get(e)),On=(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)},jn=(e,t,r,n)=>(Tn(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);Cn=new WeakMap,En=new WeakMap;let $n=class e{constructor(e,t=or){Sn(this,"assets"),Sn(this,"datasets"),Sn(this,"projects"),Sn(this,"users"),On(this,Cn,void 0),On(this,En,void 0),Sn(this,"listen",Wr),this.config(t),jn(this,En,e),this.assets=new Dr(this,_n(this,En)),this.datasets=new Xr(this,_n(this,En)),this.projects=new cn(this,_n(this,En)),this.users=new bn(this,_n(this,En))}clone(){return new e(_n(this,En),this.config())}config(e){if(void 0===e)return{..._n(this,Cn)};if(_n(this,Cn)&&!1===_n(this,Cn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return jn(this,Cn,ar(e,_n(this,Cn)||{})),this}withConfig(t){const r=this.config();return new e(_n(this,En),{...r,...t,stega:{...r.stega||{},..."boolean"==typeof(null==t?void 0:t.stega)?{enabled:t.stega}:(null==t?void 0:t.stega)||{}}})}fetch(e,t,r){return pr(this,_n(this,En),_n(this,Cn).stega,e,t,r)}getDocument(e,t){return yr(this,_n(this,En),e,t)}getDocuments(e,t){return mr(this,_n(this,En),e,t)}create(e,t){return Er(this,_n(this,En),e,"create",t)}createIfNotExists(e,t){return gr(this,_n(this,En),e,t)}createOrReplace(e,t){return vr(this,_n(this,En),e,t)}delete(e,t){return br(this,_n(this,En),e,t)}mutate(e,t){return wr(this,_n(this,En),e,t)}patch(e,t){return new Dt(e,t,this)}transaction(e){return new Yt(e,this)}request(e){return Sr(this,_n(this,En),e)}getUrl(e,t){return _r(this,e,t)}getDataUrl(e,t){return Tr(this,e,t)}};var kn,An;kn=new WeakMap,An=new WeakMap;let Pn=class e{constructor(e,t=or){Sn(this,"assets"),Sn(this,"datasets"),Sn(this,"projects"),Sn(this,"users"),Sn(this,"observable"),On(this,kn,void 0),On(this,An,void 0),Sn(this,"listen",Wr),this.config(t),jn(this,An,e),this.assets=new Fr(this,_n(this,An)),this.datasets=new Kr(this,_n(this,An)),this.projects=new ln(this,_n(this,An)),this.users=new wn(this,_n(this,An)),this.observable=new $n(e,t)}clone(){return new e(_n(this,An),this.config())}config(e){if(void 0===e)return{..._n(this,kn)};if(_n(this,kn)&&!1===_n(this,kn).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),jn(this,kn,ar(e,_n(this,kn)||{})),this}withConfig(t){const r=this.config();return new e(_n(this,An),{...r,...t,stega:{...r.stega||{},..."boolean"==typeof(null==t?void 0:t.stega)?{enabled:t.stega}:(null==t?void 0:t.stega)||{}}})}fetch(e,t,r){return Ge(pr(this,_n(this,An),_n(this,kn).stega,e,t,r))}getDocument(e,t){return Ge(yr(this,_n(this,An),e,t))}getDocuments(e,t){return Ge(mr(this,_n(this,An),e,t))}create(e,t){return Ge(Er(this,_n(this,An),e,"create",t))}createIfNotExists(e,t){return Ge(gr(this,_n(this,An),e,t))}createOrReplace(e,t){return Ge(vr(this,_n(this,An),e,t))}delete(e,t){return Ge(br(this,_n(this,An),e,t))}mutate(e,t){return Ge(wr(this,_n(this,An),e,t))}patch(e,t){return new qt(e,t,this)}transaction(e){return new Vt(e,this)}request(e){return Ge(Sr(this,_n(this,An),e))}dataRequest(e,t,r){return Ge(Cr(this,_n(this,An),e,t,r))}getUrl(e,t){return _r(this,e,t)}getDataUrl(e,t){return Tr(this,e,t)}};const In=(Nn=Pn,{requester:gt(qn=[],{}).defaultRequester,createClient:e=>new Nn(gt(qn,{maxRetries:e.maxRetries,retryDelay:e.retryDelay}),e)}),Rn=In.requester,Mn=In.createClient,Dn=(Fn=Mn,function(e){return nr(),Fn(e)});var Fn,qn,Nn;const Un=/_key\s*==\s*['"](.*)['"]/;function Wn(e){if(!Array.isArray(e))throw new Error("Path is not an array");return e.reduce(((e,t,r)=>{const n=typeof t;if("number"===n)return`${e}[${t}]`;if("string"===n)return`${e}${0===r?"":"."}${t}`;if(function(e){return"string"==typeof e?Un.test(e.trim()):"object"==typeof e&&"_key"in e}(t)&&t._key)return`${e}[_key=="${t._key}"]`;if(Array.isArray(t)){const[r,n]=t;return`${e}[${r}:${n}]`}throw new Error(`Unsupported path segment \`${JSON.stringify(t)}\``)}),"")}const Ln={"\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","\\":"\\\\"},Hn={"\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t","\\'":"'","\\\\":"\\"};function zn(e){const t=[],r=/\['(.*?)'\]|\[(\d+)\]|\[\?\(@\._key=='(.*?)'\)\]/g;let n;for(;null!==(n=r.exec(e));)if(void 0===n[1])if(void 0===n[2])if(void 0===n[3]);else{const e=n[3].replace(/\\(\\')/g,(e=>Hn[e]));t.push({_key:e,_index:-1})}else t.push(parseInt(n[2],10));else{const e=n[1].replace(/\\(\\|f|n|r|t|')/g,(e=>Hn[e]));t.push(e)}return t}function Bn(e){return e.map((e=>{if("string"==typeof e||"number"==typeof e)return e;if(""!==e._key)return{_key:e._key};if(-1!==e._index)return e._index;throw new Error(`invalid segment:${JSON.stringify(e)}`)}))}function Jn(e,t){if(null==t||!t.mappings)return;const r=function(e){return`$${e.map((e=>"string"==typeof e?`['${e.replace(/[\f\n\r\t'\\]/g,(e=>Ln[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>Ln[e]))}')]`:`[${e._index}]`)).join("")}`}(e.map((e=>{if("string"==typeof e||"number"==typeof e)return e;if(-1!==e._index)return e._index;throw new Error(`invalid segment:${JSON.stringify(e)}`)})));if(void 0!==t.mappings[r])return{mapping:t.mappings[r],matchedPath:r,pathSuffix:""};const n=Object.entries(t.mappings).filter((([e])=>r.startsWith(e))).sort((([e],[t])=>t.length-e.length));if(0==n.length)return;const[o,s]=n[0];return{mapping:s,matchedPath:o,pathSuffix:r.substring(o.length)}}function Gn(e){return"object"==typeof e&&null!==e}function Vn(e,t,r=[]){return function(e){return null!==e&&Array.isArray(e)}(e)?e.map(((e,n)=>{if(Gn(e)){const o=e._key;if("string"==typeof o)return Vn(e,t,r.concat({_key:o,_index:n}))}return Vn(e,t,r.concat(n))})):Gn(e)?Object.fromEntries(Object.entries(e).map((([e,n])=>[e,Vn(n,t,r.concat(e))]))):t(e,r)}function Qn(e,t,r){return Vn(e,((e,n)=>{if("string"!=typeof e)return e;const o=Jn(n,t);if(!o)return e;const{mapping:s,matchedPath:i}=o;if("value"!==s.type||"documentValue"!==s.source.type)return e;const a=t.documents[s.source.document],u=t.paths[s.source.path],c=zn(i),l=zn(u).concat(n.slice(c.length));return r({sourcePath:l,sourceDocument:a,resultPath:n,value:e})}))}const Yn="drafts.";function Xn(e){const{baseUrl:t,workspace:r="default",tool:n="default",id:o,type:s,path:i,projectId:a,dataset:u}=e;if(!t)throw new Error("baseUrl is required");if(!i)throw new Error("path is required");if(!o)throw new Error("id is required");if("/"!==t&&t.endsWith("/"))throw new Error("baseUrl must not end with a slash");const c="default"===r?void 0:r,l="default"===n?void 0:n,f=function(e){return e.startsWith(Yn)?e.slice(Yn.length):e}(o),h=Array.isArray(i)?Wn(Bn(i)):i,d=new URLSearchParams({baseUrl:t,id:f,type:s,path:h});c&&d.set("workspace",c),l&&d.set("tool",l),a&&d.set("projectId",a),u&&d.set("dataset",u),o.startsWith(Yn)&&d.set("isDraft","");const p=["/"===t?"":t];c&&p.push(c);const y=["mode=presentation",`id=${f}`,`type=${s}`,`path=${encodeURIComponent(h)}`];return l&&y.push(`tool=${l}`),p.push("intent","edit",`${y.join(";")}?${d}`),p.join("/")}const Kn=({sourcePath:e,resultPath:t,value:r})=>{if(/^\d{4}-\d{2}-\d{2}/.test(n=r)&&Date.parse(n)||function(e){try{new URL(e,e.startsWith("/")?"https://acme.com":void 0)}catch{return!1}return!0}(r))return!1;var n;const o=e.at(-1);return!("slug"===e.at(-2)&&"current"===o||"string"==typeof o&&o.startsWith("_")||"number"==typeof o&&"marks"===e.at(-2)||"href"===o&&"number"==typeof e.at(-2)&&"markDefs"===e.at(-3)||"style"===o||"listItem"===o||e.some((e=>"meta"===e||"metadata"===e||"openGraph"===e||"seo"===e))||eo(e)||eo(t)||"string"==typeof o&&Zn.has(o))},Zn=new Set(["color","colour","currency","email","format","gid","hex","href","hsl","hsla","icon","id","index","key","language","layout","link","linkAction","locale","lqip","page","path","ref","rgb","rgba","route","secret","slug","status","tag","template","theme","type","unit","url","username","variant","website"]);function eo(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function to(e,t,r){var n,o,s,i,a,u,c,l,f;const{filter:h,logger:d,enabled:p}=r;if(!p){const o="config.enabled must be true, don't call this function otherwise";throw null==(n=null==d?void 0:d.error)||n.call(d,`[@sanity/client]: ${o}`,{result:e,resultSourceMap:t,config:r}),new TypeError(o)}if(!t)return null==(o=null==d?void 0:d.error)||o.call(d,"[@sanity/client]: Missing Content Source Map from response body",{result:e,resultSourceMap:t,config:r}),e;if(!r.studioUrl){const n="config.studioUrl must be defined";throw null==(s=null==d?void 0:d.error)||s.call(d,`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}const y={encoded:[],skipped:[]},m=Qn(e,t,(({sourcePath:e,sourceDocument:t,resultPath:n,value:o})=>{if(!1===("function"==typeof h?h({sourcePath:e,resultPath:n,filterDefault:Kn,sourceDocument:t,value:o}):Kn({sourcePath:e,resultPath:n,filterDefault:Kn,sourceDocument:t,value:o})))return d&&y.skipped.push({path:ro(e),value:`${o.slice(0,20)}${o.length>20?"...":""}`,length:o.length}),o;d&&y.encoded.push({path:ro(e),value:`${o.slice(0,20)}${o.length>20?"...":""}`,length:o.length});const{baseUrl:s,workspace:i,tool:a}=function(e){let t="string"==typeof e?e:e.baseUrl;return"/"!==t&&(t=t.replace(/\/$/,"")),"string"==typeof e?{baseUrl:t}:{...e,baseUrl:t}}("function"==typeof r.studioUrl?r.studioUrl(t):r.studioUrl);if(!s)return o;const{_id:u,_type:c,_projectId:l,_dataset:f}=t;return ot(o,{origin:"sanity.io",href:Xn({baseUrl:s,workspace:i,tool:a,id:u,type:c,path:e,...!r.omitCrossDatasetReferenceData&&{dataset:f,projectId:l}})},!1)}));if(d){const e=y.skipped.length,t=y.encoded.length;if((e||t)&&(null==(i=(null==d?void 0:d.groupCollapsed)||d.log)||i("[@sanity/client]: Encoding source map into result"),null==(a=d.log)||a.call(d,`[@sanity/client]: Paths encoded: ${y.encoded.length}, skipped: ${y.skipped.length}`)),y.encoded.length>0&&(null==(u=null==d?void 0:d.log)||u.call(d,"[@sanity/client]: Table of encoded paths"),null==(c=(null==d?void 0:d.table)||d.log)||c(y.encoded)),y.skipped.length>0){const e=new Set;for(const{path:t}of y.skipped)e.add(t.replace(Un,"0").replace(/\[\d+\]/g,"[]"));null==(l=null==d?void 0:d.log)||l.call(d,"[@sanity/client]: List of skipped paths",[...e.values()])}(e||t)&&(null==(f=null==d?void 0:d.groupEnd)||f.call(d))}return m}function ro(e){return Wn(Bn(e))}var no=Object.freeze({__proto__:null,stegaEncodeSourceMap:to}),oo=Object.freeze({__proto__:null,a:no,e:Qn,s:to}),so="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function io(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ao={exports:{}};
7
+ */;function M(e){return"[object Object]"===Object.prototype.toString.call(e)}const D=["boolean","string","number"];function F(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||R(t)||-1===D.indexOf(typeof t)&&!Array.isArray(t)&&!function(e){if(!1===M(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!(!1===M(r)||!1===r.hasOwnProperty("isPrototypeOf"))}(t)?e:Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})})}}}function q(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: ${e.message}`,e}}}let N={};typeof globalThis<"u"?N=globalThis:typeof window<"u"?N=window:typeof global<"u"?N=global:typeof self<"u"&&(N=self);var U=N;function W(e={}){const t=e.implementation||U.Observable;if(!t)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:(e,r)=>new t((t=>(e.error.subscribe((e=>t.error(e))),e.progress.subscribe((e=>t.next(Object.assign({type:"progress"},e)))),e.response.subscribe((e=>{t.next(Object.assign({type:"response"},e)),t.complete()})),e.request.publish(r),()=>e.abort.publish())))}}class L{constructor(e){this.__CANCEL__=!0,this.message=e}toString(){return"Cancel"+(this.message?`: ${this.message}`:"")}}const H=class{constructor(e){if("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 L(e),t(this.reason))}))}};H.source=()=>{let e;return{token:new H((t=>{e=t})),cancel:e}};var z=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function B(e){return 100*Math.pow(2,e)+100*Math.random()}const J=(e={})=>(e=>{const t=e.maxRetries||5,r=e.retryDelay||B,n=e.shouldRetry;return{onError:(e,o)=>{const s=o.options,i=s.maxRetries||t,a=s.retryDelay||r,u=s.shouldRetry||n,c=s.attemptNumber||0;if(null!==(l=s.body)&&"object"==typeof l&&"function"==typeof l.pipe||!u(e,c,s)||c>=i)return e;var l;const f=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:c+1})});return setTimeout((()=>o.channels.request.publish(f)),a(c)),null}}})({shouldRetry:z,...e});J.shouldRetry=z;var G=function(e,t){return G=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])},G(e,t)};function V(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}G(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function Q(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))}function Y(e,t){var r,n,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function X(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 K(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 Z(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 ee(e){return this instanceof ee?(this.v=e,this):new ee(e)}function te(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),s=[];return n={},i("next"),i("throw"),i("return"),n[Symbol.asyncIterator]=function(){return this},n;function i(e){o[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||a(e,t)}))})}function a(e,t){try{(r=o[e](t)).value instanceof ee?Promise.resolve(r.value.v).then(u,c):l(s[0][2],r)}catch(e){l(s[0][3],e)}var r}function u(e){a("next",e)}function c(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function re(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=X(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,o,(t=e[r](t)).done,t.value)}))}}}function ne(e){return"function"==typeof e}function oe(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 se=oe((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 ie(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var ae=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=X(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 u=this.initialTeardown;if(ne(u))try{u()}catch(e){o=e instanceof se?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var l=X(c),f=l.next();!f.done;f=l.next()){var h=f.value;try{ce(h)}catch(e){o=null!=o?o:[],e instanceof se?o=Z(Z([],K(o)),K(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(o)throw new se(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)ce(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)&&ie(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&ie(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function ue(e){return e instanceof ae||e&&"closed"in e&&ne(e.remove)&&ne(e.add)&&ne(e.unsubscribe)}function ce(e){ne(e)?e():e.unsubscribe()}ae.EMPTY;var le={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},fe={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,Z([e,t],K(r)))},clearTimeout:function(e){var t=fe.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function he(e){fe.setTimeout((function(){throw e}))}function de(){}var pe=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,ue(t)&&t.add(r)):r.destination=we,r}return V(t,e),t.create=function(e,t,r){return new ve(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}(ae),ye=Function.prototype.bind;function me(e,t){return ye.call(e,t)}var ge=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){be(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){be(e)}else be(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){be(e)}},e}(),ve=function(e){function t(t,r,n){var o,s,i=e.call(this)||this;ne(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:i&&le.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&me(t.next,s),error:t.error&&me(t.error,s),complete:t.complete&&me(t.complete,s)}):o=t;return i.destination=new ge(o),i}return V(t,e),t}(pe);function be(e){he(e)}var we={closed:!0,next:de,error:function(e){throw e},complete:de},Ce="function"==typeof Symbol&&Symbol.observable||"@@observable";function Ee(e){return e}function xe(e){return 0===e.length?Ee:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var Se=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 pe||function(e){return e&&ne(e.next)&&ne(e.error)&&ne(e.complete)}(n)&&ue(n)?e:new ve(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=Te(t))((function(t,n){var o=new ve({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[Ce]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return xe(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Te(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 Te(e){var t;return null!==(t=null!=e?e:le.Promise)&&void 0!==t?t:Promise}function _e(e){return function(t){if(function(e){return ne(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 Oe(e,t,r,n,o){return new je(e,t,r,n,o)}var je=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 V(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}(pe);var $e=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function ke(e){return ne(null==e?void 0:e.then)}function Ae(e){return ne(e[Ce])}function Pe(e){return Symbol.asyncIterator&&ne(null==e?void 0:e[Symbol.asyncIterator])}function Ie(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var Re="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Me(e){return ne(null==e?void 0:e[Re])}function De(e){return te(this,arguments,(function(){var t,r,n;return Y(this,(function(o){switch(o.label){case 0:t=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,ee(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,ee(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,ee(n)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}function Fe(e){return ne(null==e?void 0:e.getReader)}function qe(e){if(e instanceof Se)return e;if(null!=e){if(Ae(e))return o=e,new Se((function(e){var t=o[Ce]();if(ne(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if($e(e))return n=e,new Se((function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()}));if(ke(e))return r=e,new Se((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,he)}));if(Pe(e))return Ne(e);if(Me(e))return t=e,new Se((function(e){var r,n;try{for(var o=X(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(e.next(i),e.closed)return}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}e.complete()}));if(Fe(e))return Ne(De(e))}var t,r,n,o;throw Ie(e)}function Ne(e){return new Se((function(t){(function(e,t){var r,n,o,s;return Q(this,void 0,void 0,(function(){var i,a;return Y(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),r=re(e),u.label=1;case 1:return[4,r.next()];case 2:if((n=u.sent()).done)return[3,4];if(i=n.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=u.sent(),o={error:a},[3,11];case 6:return u.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))})(e,t).catch((function(e){return t.error(e)}))}))}function Ue(e,t,r,n,o){void 0===n&&(n=0),void 0===o&&(o=!1);var s=t.schedule((function(){r(),o?e.add(this.schedule(null,n)):this.unsubscribe()}),n);if(e.add(s),!o)return s}function We(e,t){return void 0===t&&(t=0),_e((function(r,n){r.subscribe(Oe(n,(function(r){return Ue(n,e,(function(){return n.next(r)}),t)}),(function(){return Ue(n,e,(function(){return n.complete()}),t)}),(function(r){return Ue(n,e,(function(){return n.error(r)}),t)})))}))}function Le(e,t){return void 0===t&&(t=0),_e((function(r,n){n.add(e.schedule((function(){return r.subscribe(n)}),t))}))}function He(e,t){if(!e)throw new Error("Iterable cannot be null");return new Se((function(r){Ue(r,t,(function(){var n=e[Symbol.asyncIterator]();Ue(r,t,(function(){n.next().then((function(e){e.done?r.complete():r.next(e.value)}))}),0,!0)}))}))}function ze(e,t){if(null!=e){if(Ae(e))return function(e,t){return qe(e).pipe(Le(t),We(t))}(e,t);if($e(e))return function(e,t){return new Se((function(r){var n=0;return t.schedule((function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())}))}))}(e,t);if(ke(e))return function(e,t){return qe(e).pipe(Le(t),We(t))}(e,t);if(Pe(e))return He(e,t);if(Me(e))return function(e,t){return new Se((function(r){var n;return Ue(r,t,(function(){n=e[Re](),Ue(r,t,(function(){var e,t,o;try{t=(e=n.next()).value,o=e.done}catch(e){return void r.error(e)}o?r.complete():r.next(t)}),0,!0)})),function(){return ne(null==n?void 0:n.return)&&n.return()}}))}(e,t);if(Fe(e))return function(e,t){return He(De(e),t)}(e,t)}throw Ie(e)}function Be(e,t){return t?ze(e,t):qe(e)}var Je=oe((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Ge(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 Je)}})}))}function Ve(e,t){return _e((function(r,n){var o=0;r.subscribe(Oe(n,(function(r){n.next(e.call(t,r,o++))})))}))}var Qe=Array.isArray;function Ye(e){return Ve((function(t){return function(e,t){return Qe(t)?e.apply(void 0,Z([],K(t))):e(t)}(e,t)}))}function Xe(e,t,r){e?Ue(r,e,t):t()}var Ke=Array.isArray;function Ze(e,t){return _e((function(r,n){var o=0;r.subscribe(Oe(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function et(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return ne((t=e)[t.length-1])?e.pop():void 0;var t}(e);return r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return xe(e)}(et.apply(void 0,Z([],K(e))),Ye(r)):_e((function(t,r){var n,o,s;(n=Z([t],K(function(e){return 1===e.length&&Ke(e[0])?e[0]:e}(e))),void 0===s&&(s=Ee),function(e){Xe(o,(function(){for(var t=n.length,r=new Array(t),i=t,a=t,u=function(t){Xe(o,(function(){var u=Be(n[t],o),c=!1;u.subscribe(Oe(e,(function(n){r[t]=n,c||(c=!0,a--),a||e.next(s(r.slice()))}),(function(){--i||e.complete()})))}),e)},c=0;c<t;c++)u(c)}),e)})(r)}))}var tt={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},rt={0:8203,1:8204,2:8205,3:65279},nt=new Array(4).fill(String.fromCodePoint(rt[0])).join("");function ot(e,t,r="auto"){return!0===r||"auto"===r&&(function(e){return!!Number.isNaN(Number(e))&&!!Date.parse(e)}(e)||function(e){try{new URL(e,e.startsWith("/")?"https://acme.com":void 0)}catch{return!1}return!0}(e))?e:`${e}${function(e){let t=JSON.stringify(e);return`${nt}${Array.from(t).map((e=>{let r=e.charCodeAt(0);if(r>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${t} on character ${e} (${r})`);return Array.from(r.toString(4).padStart(4,"0")).map((e=>String.fromCodePoint(rt[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(rt).map((e=>e.reverse()))),Object.fromEntries(Object.entries(tt).map((e=>e.reverse())));var st=`${Object.values(tt).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,it=new RegExp(`[${st}]{4,}`,"gu");function at(e){try{return JSON.parse(JSON.stringify(e,((e,t)=>{return"string"!=typeof t?t:(r=t,{cleaned:r.replace(it,""),encoded:(null==(n=r.match(it))?void 0:n[0])||""}).cleaned;var r,n})))}catch{return e}}var ut=Object.defineProperty,ct=(e,t,r)=>(((e,t,r)=>{t in e?ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class lt extends Error{constructor(e){const t=ht(e);super(t.message),ct(this,"response"),ct(this,"statusCode",400),ct(this,"responseBody"),ct(this,"details"),Object.assign(this,t)}}class ft extends Error{constructor(e){const t=ht(e);super(t.message),ct(this,"response"),ct(this,"statusCode",500),ct(this,"responseBody"),ct(this,"details"),Object.assign(this,t)}}function ht(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:pt(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message=`${t.error} - ${t.message}`,r;if(function(e){return dt(e)&&dt(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- ${n.join("\n- ")}`:"";return e.length>5&&(o+=`\n...and ${e.length-5} more`),r.message=`${t.error.description}${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?` ${e.statusMessage}`:"";return`${e.method}-request to ${e.url} resulted in HTTP ${e.statusCode}${t}`}(e),r)}function dt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function pt(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const yt={onResponse:e=>{if(e.statusCode>=500)throw new ft(e);if(e.statusCode>=400)throw new lt(e);return e}},mt={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};function gt(e,t,r){if(0===r.maxRetries)return!1;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)||J.shouldRetry(e,t,r)}function vt(e){if("string"==typeof e)return{id:e};if(Array.isArray(e))return{query:"*[_id in $ids]",params:{ids: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${t}`)}const bt=["image","file"],wt=["before","after","replace"],Ct=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")},Et=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},xt=(e,t)=>{if("string"!=typeof t||!/^[a-z0-9_][a-z0-9_.-]{0,127}$/i.test(t)||t.includes(".."))throw new Error(`${e}(): "${t}" is not a valid document ID`)},St=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);xt(e,t._id)},Tt=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},_t=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};var Ot,jt=Object.defineProperty,$t=(e,t,r)=>(((e,t,r)=>{t in e?jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),kt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},At=(e,t,r)=>(kt(e,t,"read from private field"),r?r.call(e):t.get(e)),Pt=(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)},It=(e,t,r,n)=>(kt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Rt{constructor(e,t={}){$t(this,"selection"),$t(this,"operations"),this.selection=e,this.operations=t}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return Et("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===wt.indexOf(e)){const e=wt.map((e=>`"${e}"`)).join(", ");throw new Error(`${n} takes an "at"-argument which is one of: ${e}`)}if("string"!=typeof t)throw new Error(`${n} takes a "selector"-argument which must be a string`);if(!Array.isArray(r))throw new Error(`${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",`${e}[-1]`,t)}prepend(e,t){return this.insert("before",`${e}[0]`,t)}splice(e,t,r,n){const o=t<0?t-1:t,s=typeof r>"u"||-1===r?-1:Math.max(0,t+r),i=`${e}[${o}:${o<0&&s>=0?"":s}]`;return this.insert("replace",i,n||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...vt(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return Et(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)}}Ot=new WeakMap;let Mt=class e extends Rt{constructor(e,t,r){super(e,t),Pt(this,Ot,void 0),It(this,Ot,r)}clone(){return new e(this.selection,{...this.operations},At(this,Ot))}commit(e){if(!At(this,Ot))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 At(this,Ot).mutate({patch:this.serialize()},r)}};var Dt;Dt=new WeakMap;let Ft=class e extends Rt{constructor(e,t,r){super(e,t),Pt(this,Dt,void 0),It(this,Dt,r)}clone(){return new e(this.selection,{...this.operations},At(this,Dt))}commit(e){if(!At(this,Dt))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 At(this,Dt).mutate({patch:this.serialize()},r)}};var qt=Object.defineProperty,Nt=(e,t,r)=>(((e,t,r)=>{t in e?qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),Ut=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Wt=(e,t,r)=>(Ut(e,t,"read from private field"),r?r.call(e):t.get(e)),Lt=(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)},Ht=(e,t,r,n)=>(Ut(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);const zt={returnDocuments:!1};class Bt{constructor(e=[],t){Nt(this,"operations"),Nt(this,"trxId"),this.operations=e,this.trxId=t}create(e){return Et("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return Et(t,e),St(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return Et(t,e),St(t,e),this._add({[t]:e})}delete(e){return xt("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}}var Jt;Jt=new WeakMap;let Gt=class e extends Bt{constructor(e,t,r){super(e,r),Lt(this,Jt,void 0),Ht(this,Jt,t)}clone(){return new e([...this.operations],Wt(this,Jt),this.trxId)}commit(e){if(!Wt(this,Jt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Wt(this,Jt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},zt,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,Jt)));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}})}};var Vt;Vt=new WeakMap;let Qt=class e extends Bt{constructor(e,t,r){super(e,r),Lt(this,Vt,void 0),Ht(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},zt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof Mt)return this._add({patch:e.serialize()});if(r){const r=t(new Mt(e,{},Wt(this,Vt)));if(!(r instanceof Mt))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}};function Yt(e){return"https://www.sanity.io/help/"+e}const Xt=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),Kt=Xt(["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."]),Zt=Xt(["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."]),er=Xt(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${Yt("js-client-browser-token")} for more information and how to hide this warning.`]),tr=Xt(["Using the Sanity client without specifying an API version is deprecated.",`See ${Yt("js-client-api-version")}`]),rr=Xt(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),nr={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},or=["localhost","127.0.0.1","0.0.0.0"];const sr=function(e){switch(e){case"previewDrafts":case"published":case"raw":return;default:throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`")}},ir=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||nr.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||tr();const n={...nr,...r},o=n.useProjectHostname;if(typeof Promise>"u"){const e=Yt("js-client-promise-polyfill");throw new Error(`No native Promise-implementation found, polyfill needed - see ${e}`)}if(o&&!n.projectId)throw new Error("Configuration must contain `projectId`");if("string"==typeof n.perspective&&sr(n.perspective),"encodeSourceMap"in n)throw new Error("It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMap' is not supported in '@sanity/client'. Did you mean 'stega.enabled'?");if("encodeSourceMapAtPath"in n)throw new Error("It looks like you're using options meant for '@sanity/preview-kit/client'. 'encodeSourceMapAtPath' is not supported in '@sanity/client'. Did you mean 'stega.filter'?");if("boolean"!=typeof n.stega.enabled)throw new Error(`stega.enabled must be a boolean, received ${n.stega.enabled}`);if(n.stega.enabled&&void 0===n.stega.studioUrl)throw new Error("stega.studioUrl must be defined when stega.enabled is true");if(n.stega.enabled&&"string"!=typeof n.stega.studioUrl&&"function"!=typeof n.stega.studioUrl)throw new Error(`stega.studioUrl must be a string or a function, received ${n.stega.studioUrl}`);const s=typeof window<"u"&&window.location&&window.location.hostname,i=s&&(e=>-1!==or.indexOf(e))(window.location.hostname);s&&i&&n.token&&!0!==n.ignoreBrowserTokenWarning?er():typeof n.useCdn>"u"&&Kt(),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&&Ct(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?_t(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===nr.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),u=a[0],c=a[1],l=n.isDefaultApi?"apicdn.sanity.io":c;return n.useProjectHostname?(n.url=`${u}://${n.projectId}.${c}/v${n.apiVersion}`,n.cdnUrl=`${u}://${n.projectId}.${l}/v${n.apiVersion}`):(n.url=`${n.apiHost}/v${n.apiVersion}`,n.cdnUrl=n.url),n},ar="X-Sanity-Project-ID";const ur=({query:e,params:t={},options:r={}})=>{const n=new URLSearchParams,{tag:o,returnQuery:s,...i}=r;o&&n.append("tag",o),n.append("query",e);for(const[e,r]of Object.entries(t))n.append(`$${e}`,JSON.stringify(r));for(const[e,t]of Object.entries(i))t&&n.append(e,`${t}`);return!1===s&&n.append("returnQuery","false"),`?${n}`},cr=(e={})=>{return{dryRun:e.dryRun,returnIds:!0,returnDocuments:(t=e.returnDocuments,r=!0,!1===t?void 0:typeof t>"u"?r:t),visibility:e.visibility||"sync",autoGenerateArrayKeys:e.autoGenerateArrayKeys,skipCrossDatasetReferenceValidation:e.skipCrossDatasetReferenceValidation};var t,r},lr=e=>"response"===e.type,fr=e=>e.body,hr=11264;function dr(e,t,r,n,o={},s={}){const i="stega"in s?{...r||{},..."boolean"==typeof s.stega?{enabled:s.stega}:s.stega||{}}:r,a=i.enabled?at(o):o,u=!1===s.filterResponse?e=>e:e=>e.result,{cache:c,next:l,...f}={useAbortSignal:typeof s.signal<"u",resultSourceMap:i.enabled?"withKeyArraySelector":s.resultSourceMap,...s,returnQuery:!1===s.filterResponse&&!1!==s.returnQuery},h=wr(e,t,"query",{query:n,params:a},typeof c<"u"||typeof l<"u"?{...f,fetch:{cache:c,next:l}}:f);return i.enabled?h.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return et.apply(void 0,Z([],K(e)))}(Be(Promise.resolve().then((function(){return to})).then((function(e){return e.a})).then((({stegaEncodeSourceMap:e})=>e)))),Ve((([e,t])=>{const r=t(e.result,e.resultSourceMap,i);return u({...e,result:r})}))):h.pipe(Ve(u))}function pr(e,t,r,n={}){return Er(e,t,{uri:Sr(e,"doc",r),json:!0,tag:n.tag}).pipe(Ze(lr),Ve((e=>e.body.documents&&e.body.documents[0])))}function yr(e,t,r,n={}){return Er(e,t,{uri:Sr(e,"doc",r.join(",")),json:!0,tag:n.tag}).pipe(Ze(lr),Ve((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 mr(e,t,r,n){return St("createIfNotExists",r),Cr(e,t,r,"createIfNotExists",n)}function gr(e,t,r,n){return St("createOrReplace",r),Cr(e,t,r,"createOrReplace",n)}function vr(e,t,r,n){return wr(e,t,"mutate",{mutations:[{delete:vt(r)}]},n)}function br(e,t,r,n){let o;o=r instanceof Ft||r instanceof Mt?{patch:r.serialize()}:r instanceof Gt||r instanceof Qt?r.serialize():r;return wr(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function wr(e,t,r,n,o={}){const s="mutate"===r,i="query"===r,a=s?"":ur(n),u=!s&&a.length<hr,c=u?a:"",l=o.returnFirst,{timeout:f,token:h,tag:d,headers:p,returnQuery:y}=o;return Er(e,t,{method:u?"GET":"POST",uri:Sr(e,r,c),json:!0,body:u?void 0:n,query:s&&cr(o),timeout:f,headers:p,token:h,tag:d,returnQuery:y,perspective:o.perspective,resultSourceMap:o.resultSourceMap,canUseCdn:i,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(Ze(lr),Ve(fr),Ve((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 Cr(e,t,r,n,o={}){return wr(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function Er(e,t,r){var n,o;const s=r.url||r.uri,i=e.config(),a=typeof r.canUseCdn>"u"?["GET","HEAD"].indexOf(r.method||"GET")>=0&&0===s.indexOf("/data/"):r.canUseCdn;let u=(null!=(n=r.useCdn)?n:i.useCdn)&&a;const c=r.tag&&i.requestTagPrefix?[i.requestTagPrefix,r.tag].join("."):r.tag||i.requestTagPrefix;if(c&&null!==r.tag&&(r.query={tag:_t(c),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&0===s.indexOf("/data/query/")){const e=null!=(o=r.resultSourceMap)?o:i.resultSourceMap;void 0!==e&&!1!==e&&(r.query={resultSourceMap:e,...r.query});const t=r.perspective||i.perspective;"string"==typeof t&&"raw"!==t&&(sr(t),r.query={perspective:t,...r.query},"previewDrafts"===t&&u&&(u=!1,Zt())),!1===r.returnQuery&&(r.query={returnQuery:"false",...r.query})}const l=function(e,t={}){const r={},n=t.token||e.token;n&&(r.Authorization=`Bearer ${n}`),!t.useGlobalApi&&!e.useProjectHostname&&e.projectId&&(r[ar]=e.projectId);const o=!!(typeof t.withCredentials>"u"?e.token||e.withCredentials:t.withCredentials),s=typeof t.timeout>"u"?e.timeout:t.timeout;return Object.assign({},t,{headers:Object.assign({},r,t.headers||{}),timeout:typeof s>"u"?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})}(i,Object.assign({},r,{url:Tr(e,s,u)})),f=new Se((e=>t(l,i.requester).subscribe(e)));return r.signal?f.pipe((h=r.signal,e=>new Se((t=>{const r=()=>t.error(function(e){var t,r;if(_r)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()}})))):f;var h}function xr(e,t,r){return Er(e,t,r).pipe(Ze((e=>"response"===e.type)),Ve((e=>e.body)))}function Sr(e,t,r){const n=e.config(),o=`/${t}/${Tt(n)}`;return`/data${r?`${o}/${r}`:o}`.replace(/\/($|\?)/,"$1")}function Tr(e,t,r=!1){const{url:n,cdnUrl:o}=e.config();return`${r?o:n}/${t.replace(/^\//,"")}`}const _r=!!globalThis.DOMException;var Or,jr,$r,kr,Ar=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Pr=(e,t,r)=>(Ar(e,t,"read from private field"),r?r.call(e):t.get(e)),Ir=(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)},Rr=(e,t,r,n)=>(Ar(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Mr{constructor(e,t){Ir(this,Or,void 0),Ir(this,jr,void 0),Rr(this,Or,e),Rr(this,jr,t)}upload(e,t,r){return Fr(Pr(this,Or),Pr(this,jr),e,t,r)}}Or=new WeakMap,jr=new WeakMap;class Dr{constructor(e,t){Ir(this,$r,void 0),Ir(this,kr,void 0),Rr(this,$r,e),Rr(this,kr,t)}upload(e,t,r){return Ge(Fr(Pr(this,$r),Pr(this,kr),e,t,r).pipe(Ze((e=>"response"===e.type)),Ve((e=>e.body.document))))}}function Fr(e,t,r,n,o={}){(e=>{if(-1===bt.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${bt.join(", ")}`)})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=Tt(e.config()),a="image"===r?"images":"files",u=function(e,t){return typeof File>"u"||!(t instanceof File)?e:Object.assign({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e)}(o,n),{tag:c,label:l,title:f,description:h,creditLine:d,filename:p,source:y}=u,m={label:l,title:f,description:h,filename:p,meta:s,creditLine:d};return y&&(m.sourceId=y.id,m.sourceName=y.name,m.sourceUrl=y.url),Er(e,t,{tag:c,method:"POST",timeout:u.timeout||0,uri:`/assets/${a}/${i}`,headers:u.contentType?{"Content-Type":u.contentType}:{},query:m,body:n})}$r=new WeakMap,kr=new WeakMap;const qr=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],Nr={includeResult:!0};function Ur(e,t,r={}){const{url:n,token:o,withCredentials:s,requestTagPrefix:i}=this.config(),a=r.tag&&i?[i,r.tag].join("."):r.tag,u={...(f=r,h=Nr,Object.keys(h).concat(Object.keys(f)).reduce(((e,t)=>(e[t]=typeof f[t]>"u"?h[t]:f[t],e)),{})),tag:a},c=((e,t)=>t.reduce(((t,r)=>(typeof e[r]>"u"||(t[r]=e[r]),t)),{}))(u,qr),l=`${n}${Sr(this,"listen",ur({query:e,params:t,options:{tag:a,...c}}))}`;var f,h;if(l.length>14800)return new Se((e=>e.error(new Error("Query too large for listener"))));const d=u.events?u.events:["mutation"],p=-1!==d.indexOf("reconnect"),y={};return(o||s)&&(y.withCredentials=!0),o&&(y.headers={Authorization:`Bearer ${o}`}),new Se((e=>{let t;c().then((e=>{t=e})).catch((t=>{e.error(t),h()}));let r,n=!1;function o(){n||(p&&e.next({type:"reconnect"}),!n&&t.readyState===t.CLOSED&&(u(),clearTimeout(r),r=setTimeout(f,100)))}function s(t){e.error(function(e){if(e instanceof Error)return e;const t=Wr(e);return t instanceof Error?t:new Error(function(e){return e.error?e.error.description?e.error.description:"string"==typeof e.error?e.error:JSON.stringify(e.error,null,2):e.message||"Unknown listener error"}(t))}(t))}function i(t){const r=Wr(t);return r instanceof Error?e.error(r):e.next(r)}function a(){n=!0,u(),e.complete()}function u(){t&&(t.removeEventListener("error",o),t.removeEventListener("channelError",s),t.removeEventListener("disconnect",a),d.forEach((e=>t.removeEventListener(e,i))),t.close())}async function c(){const{default:e}=await Promise.resolve().then((function(){return io})),t=new e(l,y);return t.addEventListener("error",o),t.addEventListener("channelError",s),t.addEventListener("disconnect",a),d.forEach((e=>t.addEventListener(e,i))),t}function f(){c().then((e=>{t=e})).catch((t=>{e.error(t),h()}))}function h(){n=!0,u()}return h}))}function Wr(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}var Lr,Hr,zr,Br,Jr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Gr=(e,t,r)=>(Jr(e,t,"read from private field"),r?r.call(e):t.get(e)),Vr=(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)},Qr=(e,t,r,n)=>(Jr(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class Yr{constructor(e,t){Vr(this,Lr,void 0),Vr(this,Hr,void 0),Qr(this,Lr,e),Qr(this,Hr,t)}create(e,t){return Kr(Gr(this,Lr),Gr(this,Hr),"PUT",e,t)}edit(e,t){return Kr(Gr(this,Lr),Gr(this,Hr),"PATCH",e,t)}delete(e){return Kr(Gr(this,Lr),Gr(this,Hr),"DELETE",e)}list(){return xr(Gr(this,Lr),Gr(this,Hr),{uri:"/datasets",tag:null})}}Lr=new WeakMap,Hr=new WeakMap;class Xr{constructor(e,t){Vr(this,zr,void 0),Vr(this,Br,void 0),Qr(this,zr,e),Qr(this,Br,t)}create(e,t){return Ge(Kr(Gr(this,zr),Gr(this,Br),"PUT",e,t))}edit(e,t){return Ge(Kr(Gr(this,zr),Gr(this,Br),"PATCH",e,t))}delete(e){return Ge(Kr(Gr(this,zr),Gr(this,Br),"DELETE",e))}list(){return Ge(xr(Gr(this,zr),Gr(this,Br),{uri:"/datasets",tag:null}))}}function Kr(e,t,r,n,o){return Ct(n),xr(e,t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}zr=new WeakMap,Br=new WeakMap;var Zr,en,tn,rn,nn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},on=(e,t,r)=>(nn(e,t,"read from private field"),r?r.call(e):t.get(e)),sn=(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)},an=(e,t,r,n)=>(nn(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class un{constructor(e,t){sn(this,Zr,void 0),sn(this,en,void 0),an(this,Zr,e),an(this,en,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return xr(on(this,Zr),on(this,en),{uri:t})}getById(e){return xr(on(this,Zr),on(this,en),{uri:`/projects/${e}`})}}Zr=new WeakMap,en=new WeakMap;class cn{constructor(e,t){sn(this,tn,void 0),sn(this,rn,void 0),an(this,tn,e),an(this,rn,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Ge(xr(on(this,tn),on(this,rn),{uri:t}))}getById(e){return Ge(xr(on(this,tn),on(this,rn),{uri:`/projects/${e}`}))}}tn=new WeakMap,rn=new WeakMap;var ln,fn,hn,dn,pn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},yn=(e,t,r)=>(pn(e,t,"read from private field"),r?r.call(e):t.get(e)),mn=(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)},gn=(e,t,r,n)=>(pn(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);class vn{constructor(e,t){mn(this,ln,void 0),mn(this,fn,void 0),gn(this,ln,e),gn(this,fn,t)}getById(e){return xr(yn(this,ln),yn(this,fn),{uri:`/users/${e}`})}}ln=new WeakMap,fn=new WeakMap;class bn{constructor(e,t){mn(this,hn,void 0),mn(this,dn,void 0),gn(this,hn,e),gn(this,dn,t)}getById(e){return Ge(xr(yn(this,hn),yn(this,dn),{uri:`/users/${e}`}))}}hn=new WeakMap,dn=new WeakMap;var wn,Cn,En=Object.defineProperty,xn=(e,t,r)=>(((e,t,r)=>{t in e?En(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),Sn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Tn=(e,t,r)=>(Sn(e,t,"read from private field"),r?r.call(e):t.get(e)),_n=(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)},On=(e,t,r,n)=>(Sn(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);wn=new WeakMap,Cn=new WeakMap;let jn=class e{constructor(e,t=nr){xn(this,"assets"),xn(this,"datasets"),xn(this,"projects"),xn(this,"users"),_n(this,wn,void 0),_n(this,Cn,void 0),xn(this,"listen",Ur),this.config(t),On(this,Cn,e),this.assets=new Mr(this,Tn(this,Cn)),this.datasets=new Yr(this,Tn(this,Cn)),this.projects=new un(this,Tn(this,Cn)),this.users=new vn(this,Tn(this,Cn))}clone(){return new e(Tn(this,Cn),this.config())}config(e){if(void 0===e)return{...Tn(this,wn)};if(Tn(this,wn)&&!1===Tn(this,wn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return On(this,wn,ir(e,Tn(this,wn)||{})),this}withConfig(t){const r=this.config();return new e(Tn(this,Cn),{...r,...t,stega:{...r.stega||{},..."boolean"==typeof(null==t?void 0:t.stega)?{enabled:t.stega}:(null==t?void 0:t.stega)||{}}})}fetch(e,t,r){return dr(this,Tn(this,Cn),Tn(this,wn).stega,e,t,r)}getDocument(e,t){return pr(this,Tn(this,Cn),e,t)}getDocuments(e,t){return yr(this,Tn(this,Cn),e,t)}create(e,t){return Cr(this,Tn(this,Cn),e,"create",t)}createIfNotExists(e,t){return mr(this,Tn(this,Cn),e,t)}createOrReplace(e,t){return gr(this,Tn(this,Cn),e,t)}delete(e,t){return vr(this,Tn(this,Cn),e,t)}mutate(e,t){return br(this,Tn(this,Cn),e,t)}patch(e,t){return new Mt(e,t,this)}transaction(e){return new Qt(e,this)}request(e){return xr(this,Tn(this,Cn),e)}getUrl(e,t){return Tr(this,e,t)}getDataUrl(e,t){return Sr(this,e,t)}};var $n,kn;$n=new WeakMap,kn=new WeakMap;let An=class e{constructor(e,t=nr){xn(this,"assets"),xn(this,"datasets"),xn(this,"projects"),xn(this,"users"),xn(this,"observable"),_n(this,$n,void 0),_n(this,kn,void 0),xn(this,"listen",Ur),this.config(t),On(this,kn,e),this.assets=new Dr(this,Tn(this,kn)),this.datasets=new Xr(this,Tn(this,kn)),this.projects=new cn(this,Tn(this,kn)),this.users=new bn(this,Tn(this,kn)),this.observable=new jn(e,t)}clone(){return new e(Tn(this,kn),this.config())}config(e){if(void 0===e)return{...Tn(this,$n)};if(Tn(this,$n)&&!1===Tn(this,$n).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),On(this,$n,ir(e,Tn(this,$n)||{})),this}withConfig(t){const r=this.config();return new e(Tn(this,kn),{...r,...t,stega:{...r.stega||{},..."boolean"==typeof(null==t?void 0:t.stega)?{enabled:t.stega}:(null==t?void 0:t.stega)||{}}})}fetch(e,t,r){return Ge(dr(this,Tn(this,kn),Tn(this,$n).stega,e,t,r))}getDocument(e,t){return Ge(pr(this,Tn(this,kn),e,t))}getDocuments(e,t){return Ge(yr(this,Tn(this,kn),e,t))}create(e,t){return Ge(Cr(this,Tn(this,kn),e,"create",t))}createIfNotExists(e,t){return Ge(mr(this,Tn(this,kn),e,t))}createOrReplace(e,t){return Ge(gr(this,Tn(this,kn),e,t))}delete(e,t){return Ge(vr(this,Tn(this,kn),e,t))}mutate(e,t){return Ge(br(this,Tn(this,kn),e,t))}patch(e,t){return new Ft(e,t,this)}transaction(e){return new Gt(e,this)}request(e){return Ge(xr(this,Tn(this,kn),e))}dataRequest(e,t,r){return Ge(wr(this,Tn(this,kn),e,t,r))}getUrl(e,t){return Tr(this,e,t)}getDataUrl(e,t){return Sr(this,e,t)}};const Pn=function(e,t){const r=function(e){return j([J({shouldRetry:gt}),...e,mt,F(),q(),{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"))}},yt,W({implementation:Se})])}(e);return{requester:r,createClient:e=>new t(((t,n)=>(n||r)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,...t})),e)}}([],An),In=Pn.requester,Rn=Pn.createClient,Mn=(Dn=Rn,function(e){return rr(),Dn(e)});var Dn;const Fn=/_key\s*==\s*['"](.*)['"]/;function qn(e){if(!Array.isArray(e))throw new Error("Path is not an array");return e.reduce(((e,t,r)=>{const n=typeof t;if("number"===n)return`${e}[${t}]`;if("string"===n)return`${e}${0===r?"":"."}${t}`;if(function(e){return"string"==typeof e?Fn.test(e.trim()):"object"==typeof e&&"_key"in e}(t)&&t._key)return`${e}[_key=="${t._key}"]`;if(Array.isArray(t)){const[r,n]=t;return`${e}[${r}:${n}]`}throw new Error(`Unsupported path segment \`${JSON.stringify(t)}\``)}),"")}const Nn={"\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","\\":"\\\\"},Un={"\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t","\\'":"'","\\\\":"\\"};function Wn(e){const t=[],r=/\['(.*?)'\]|\[(\d+)\]|\[\?\(@\._key=='(.*?)'\)\]/g;let n;for(;null!==(n=r.exec(e));)if(void 0===n[1])if(void 0===n[2])if(void 0===n[3]);else{const e=n[3].replace(/\\(\\')/g,(e=>Un[e]));t.push({_key:e,_index:-1})}else t.push(parseInt(n[2],10));else{const e=n[1].replace(/\\(\\|f|n|r|t|')/g,(e=>Un[e]));t.push(e)}return t}function Ln(e){return e.map((e=>{if("string"==typeof e||"number"==typeof e)return e;if(""!==e._key)return{_key:e._key};if(-1!==e._index)return e._index;throw new Error(`invalid segment:${JSON.stringify(e)}`)}))}function Hn(e,t){if(null==t||!t.mappings)return;const r=function(e){return`$${e.map((e=>"string"==typeof e?`['${e.replace(/[\f\n\r\t'\\]/g,(e=>Nn[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>Nn[e]))}')]`:`[${e._index}]`)).join("")}`}(e.map((e=>{if("string"==typeof e||"number"==typeof e)return e;if(-1!==e._index)return e._index;throw new Error(`invalid segment:${JSON.stringify(e)}`)})));if(void 0!==t.mappings[r])return{mapping:t.mappings[r],matchedPath:r,pathSuffix:""};const n=Object.entries(t.mappings).filter((([e])=>r.startsWith(e))).sort((([e],[t])=>t.length-e.length));if(0==n.length)return;const[o,s]=n[0];return{mapping:s,matchedPath:o,pathSuffix:r.substring(o.length)}}function zn(e){return"object"==typeof e&&null!==e}function Bn(e,t,r=[]){return function(e){return null!==e&&Array.isArray(e)}(e)?e.map(((e,n)=>{if(zn(e)){const o=e._key;if("string"==typeof o)return Bn(e,t,r.concat({_key:o,_index:n}))}return Bn(e,t,r.concat(n))})):zn(e)?Object.fromEntries(Object.entries(e).map((([e,n])=>[e,Bn(n,t,r.concat(e))]))):t(e,r)}function Jn(e,t,r){return Bn(e,((e,n)=>{if("string"!=typeof e)return e;const o=Hn(n,t);if(!o)return e;const{mapping:s,matchedPath:i}=o;if("value"!==s.type||"documentValue"!==s.source.type)return e;const a=t.documents[s.source.document],u=t.paths[s.source.path],c=Wn(i),l=Wn(u).concat(n.slice(c.length));return r({sourcePath:l,sourceDocument:a,resultPath:n,value:e})}))}const Gn="drafts.";function Vn(e){const{baseUrl:t,workspace:r="default",tool:n="default",id:o,type:s,path:i,projectId:a,dataset:u}=e;if(!t)throw new Error("baseUrl is required");if(!i)throw new Error("path is required");if(!o)throw new Error("id is required");if("/"!==t&&t.endsWith("/"))throw new Error("baseUrl must not end with a slash");const c="default"===r?void 0:r,l="default"===n?void 0:n,f=function(e){return e.startsWith(Gn)?e.slice(Gn.length):e}(o),h=Array.isArray(i)?qn(Ln(i)):i,d=new URLSearchParams({baseUrl:t,id:f,type:s,path:h});c&&d.set("workspace",c),l&&d.set("tool",l),a&&d.set("projectId",a),u&&d.set("dataset",u),o.startsWith(Gn)&&d.set("isDraft","");const p=["/"===t?"":t];c&&p.push(c);const y=["mode=presentation",`id=${f}`,`type=${s}`,`path=${encodeURIComponent(h)}`];return l&&y.push(`tool=${l}`),p.push("intent","edit",`${y.join(";")}?${d}`),p.join("/")}const Qn=({sourcePath:e,resultPath:t,value:r})=>{if(/^\d{4}-\d{2}-\d{2}/.test(n=r)&&Date.parse(n)||function(e){try{new URL(e,e.startsWith("/")?"https://acme.com":void 0)}catch{return!1}return!0}(r))return!1;var n;const o=e.at(-1);return!("slug"===e.at(-2)&&"current"===o||"string"==typeof o&&o.startsWith("_")||"number"==typeof o&&"marks"===e.at(-2)||"href"===o&&"number"==typeof e.at(-2)&&"markDefs"===e.at(-3)||"style"===o||"listItem"===o||e.some((e=>"meta"===e||"metadata"===e||"openGraph"===e||"seo"===e))||Xn(e)||Xn(t)||"string"==typeof o&&Yn.has(o))},Yn=new Set(["color","colour","currency","email","format","gid","hex","href","hsl","hsla","icon","id","index","key","language","layout","link","linkAction","locale","lqip","page","path","ref","rgb","rgba","route","secret","slug","status","tag","template","theme","type","unit","url","username","variant","website"]);function Xn(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function Kn(e,t,r){var n,o,s,i,a,u,c,l,f;const{filter:h,logger:d,enabled:p}=r;if(!p){const o="config.enabled must be true, don't call this function otherwise";throw null==(n=null==d?void 0:d.error)||n.call(d,`[@sanity/client]: ${o}`,{result:e,resultSourceMap:t,config:r}),new TypeError(o)}if(!t)return null==(o=null==d?void 0:d.error)||o.call(d,"[@sanity/client]: Missing Content Source Map from response body",{result:e,resultSourceMap:t,config:r}),e;if(!r.studioUrl){const n="config.studioUrl must be defined";throw null==(s=null==d?void 0:d.error)||s.call(d,`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}const y={encoded:[],skipped:[]},m=Jn(e,t,(({sourcePath:e,sourceDocument:t,resultPath:n,value:o})=>{if(!1===("function"==typeof h?h({sourcePath:e,resultPath:n,filterDefault:Qn,sourceDocument:t,value:o}):Qn({sourcePath:e,resultPath:n,filterDefault:Qn,sourceDocument:t,value:o})))return d&&y.skipped.push({path:Zn(e),value:`${o.slice(0,20)}${o.length>20?"...":""}`,length:o.length}),o;d&&y.encoded.push({path:Zn(e),value:`${o.slice(0,20)}${o.length>20?"...":""}`,length:o.length});const{baseUrl:s,workspace:i,tool:a}=function(e){let t="string"==typeof e?e:e.baseUrl;return"/"!==t&&(t=t.replace(/\/$/,"")),"string"==typeof e?{baseUrl:t}:{...e,baseUrl:t}}("function"==typeof r.studioUrl?r.studioUrl(t):r.studioUrl);if(!s)return o;const{_id:u,_type:c,_projectId:l,_dataset:f}=t;return ot(o,{origin:"sanity.io",href:Vn({baseUrl:s,workspace:i,tool:a,id:u,type:c,path:e,...!r.omitCrossDatasetReferenceData&&{dataset:f,projectId:l}})},!1)}));if(d){const e=y.skipped.length,t=y.encoded.length;if((e||t)&&(null==(i=(null==d?void 0:d.groupCollapsed)||d.log)||i("[@sanity/client]: Encoding source map into result"),null==(a=d.log)||a.call(d,`[@sanity/client]: Paths encoded: ${y.encoded.length}, skipped: ${y.skipped.length}`)),y.encoded.length>0&&(null==(u=null==d?void 0:d.log)||u.call(d,"[@sanity/client]: Table of encoded paths"),null==(c=(null==d?void 0:d.table)||d.log)||c(y.encoded)),y.skipped.length>0){const e=new Set;for(const{path:t}of y.skipped)e.add(t.replace(Fn,"0").replace(/\[\d+\]/g,"[]"));null==(l=null==d?void 0:d.log)||l.call(d,"[@sanity/client]: List of skipped paths",[...e.values()])}(e||t)&&(null==(f=null==d?void 0:d.groupEnd)||f.call(d))}return m}function Zn(e){return qn(Ln(e))}var eo=Object.freeze({__proto__:null,stegaEncodeSourceMap:Kn}),to=Object.freeze({__proto__:null,a:eo,e:Jn,s:Kn}),ro="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function no(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oo={exports:{}};
8
8
  /** @license
9
9
  * eventsource.js
10
10
  * Available under MIT License (MIT)
11
11
  * https://github.com/Yaffle/EventSource/
12
- */!function(e,t){!function(r){var n=r.setTimeout,o=r.clearTimeout,s=r.XMLHttpRequest,i=r.XDomainRequest,a=r.ActiveXObject,u=r.EventSource,c=r.document,l=r.Promise,f=r.fetch,h=r.Response,d=r.TextDecoder,p=r.TextEncoder,y=r.AbortController;if("undefined"==typeof window||void 0===c||"readyState"in c||null!=c.body||(c.readyState="loading",window.addEventListener("load",(function(e){c.readyState="complete"}),!1)),null==s&&null!=a&&(s=function(){return new a("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==y){var m=f;f=function(e,t){var r=t.signal;return m(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then((function(e){var t=e.body.getReader();return r._reader=t,r._aborted&&r._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}}))},y=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function g(){this.bitsNeeded=0,this.codePoint=0}g.prototype.decode=function(e){function t(e,t,r){if(1===r)return e>=128>>t&&e<<t<=2047;if(2===r)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===r)return e>=65536>>t&&e<<t<=1114111;throw new Error}function r(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var n=65533,o="",s=this.bitsNeeded,i=this.codePoint,a=0;a<e.length;a+=1){var u=e[a];0!==s&&(u<128||u>191||!t(i<<6|63&u,s-6,r(s,i)))&&(s=0,i=n,o+=String.fromCharCode(i)),0===s?(u>=0&&u<=127?(s=0,i=u):u>=192&&u<=223?(s=6,i=31&u):u>=224&&u<=239?(s=12,i=15&u):u>=240&&u<=247?(s=18,i=7&u):(s=0,i=n),0===s||t(i,s,r(s,i))||(s=0,i=n)):(s-=6,i=i<<6|63&u),0===s&&(i<=65535?o+=String.fromCharCode(i):(o+=String.fromCharCode(55296+(i-65535-1>>10)),o+=String.fromCharCode(56320+(i-65535-1&1023))))}return this.bitsNeeded=s,this.codePoint=i,o};null!=d&&null!=p&&function(){try{return"test"===(new d).decode((new p).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(d=g);var v=function(){};function b(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=v,this.onload=v,this.onerror=v,this.onreadystatechange=v,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=v}function w(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function C(e){for(var t=Object.create(null),r=e.split("\r\n"),n=0;n<r.length;n+=1){var o=r[n].split(": "),s=o.shift(),i=o.join(": ");t[w(s)]=i}this._map=t}function E(){}function x(e){this._headers=e}function S(){}function T(){this._listeners=Object.create(null)}function _(e){n((function(){throw e}),0)}function O(e){this.type=e,this.target=void 0}function j(e,t){O.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function $(e,t){O.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function k(e,t){O.call(this,e),this.error=t.error}b.prototype.open=function(e,t){this._abort(!0);var r=this,i=this._xhr,a=1,u=0;this._abort=function(e){0!==r._sendTimeout&&(o(r._sendTimeout),r._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,i.onload=v,i.onerror=v,i.onabort=v,i.onprogress=v,i.onreadystatechange=v,i.abort(),0!==u&&(o(u),u=0),e||(r.readyState=4,r.onabort(null),r.onreadystatechange())),a=0};var c=function(){if(1===a){var e=0,t="",n=void 0;if("contentType"in i)e=200,t="OK",n=i.contentType;else try{e=i.status,t=i.statusText,n=i.getResponseHeader("Content-Type")}catch(r){e=0,t="",n=void 0}0!==e&&(a=2,r.readyState=2,r.status=e,r.statusText=t,r._contentType=n,r.onreadystatechange())}},l=function(){if(c(),2===a||3===a){a=3;var e="";try{e=i.responseText}catch(e){}r.readyState=3,r.responseText=e,r.onprogress()}},f=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:v}),l(),1===a||2===a||3===a){if(a=4,0!==u&&(o(u),u=0),r.readyState=4,"load"===e)r.onload(t);else if("error"===e)r.onerror(t);else{if("abort"!==e)throw new TypeError;r.onabort(t)}r.onreadystatechange()}},h=function(){u=n((function(){h()}),500),3===i.readyState&&l()};"onload"in i&&(i.onload=function(e){f("load",e)}),"onerror"in i&&(i.onerror=function(e){f("error",e)}),"onabort"in i&&(i.onabort=function(e){f("abort",e)}),"onprogress"in i&&(i.onprogress=l),"onreadystatechange"in i&&(i.onreadystatechange=function(e){!function(e){null!=i&&(4===i.readyState?"onload"in i&&"onerror"in i&&"onabort"in i||f(""===i.responseText?"error":"load",e):3===i.readyState?"onprogress"in i||l():2===i.readyState&&c())}(e)}),!("contentType"in i)&&"ontimeout"in s.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),i.open(e,t,!0),"readyState"in i&&(u=n((function(){h()}),0))},b.prototype.abort=function(){this._abort(!1)},b.prototype.getResponseHeader=function(e){return this._contentType},b.prototype.setRequestHeader=function(e,t){var r=this._xhr;"setRequestHeader"in r&&r.setRequestHeader(e,t)},b.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},b.prototype.send=function(){if("ontimeout"in s.prototype&&("sendAsBinary"in s.prototype||"mozAnon"in s.prototype)||null==c||null==c.readyState||"complete"===c.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=n((function(){t._sendTimeout=0,t.send()}),4)}},C.prototype.get=function(e){return this._map[w(e)]},null!=s&&null==s.HEADERS_RECEIVED&&(s.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,r,n,o,i,a){e.open("GET",o);var u=0;for(var c in e.onprogress=function(){var t=e.responseText.slice(u);u+=t.length,r(t)},e.onerror=function(e){e.preventDefault(),n(new Error("NetworkError"))},e.onload=function(){n(null)},e.onabort=function(){n(null)},e.onreadystatechange=function(){if(e.readyState===s.HEADERS_RECEIVED){var r=e.status,n=e.statusText,o=e.getResponseHeader("Content-Type"),i=e.getAllResponseHeaders();t(r,n,o,new C(i))}},e.withCredentials=i,a)Object.prototype.hasOwnProperty.call(a,c)&&e.setRequestHeader(c,a[c]);return e.send(),e},x.prototype.get=function(e){return this._headers.get(e)},S.prototype.open=function(e,t,r,n,o,s,i){var a=null,u=new y,c=u.signal,h=new d;return f(o,{headers:i,credentials:s?"include":"same-origin",signal:c,cache:"no-store"}).then((function(e){return a=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new x(e.headers)),new l((function(e,t){var n=function(){a.read().then((function(t){if(t.done)e(void 0);else{var o=h.decode(t.value,{stream:!0});r(o),n()}})).catch((function(e){t(e)}))};n()}))})).catch((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){n(e)})),{abort:function(){null!=a&&a.cancel(),u.abort()}}},T.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(null!=t)for(var r=t.length,n=0;n<r;n+=1){var o=t[n];try{"function"==typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(e){_(e)}}},T.prototype.addEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];null==n&&(n=[],r[e]=n);for(var o=!1,s=0;s<n.length;s+=1)n[s]===t&&(o=!0);o||n.push(t)},T.prototype.removeEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];if(null!=n){for(var o=[],s=0;s<n.length;s+=1)n[s]!==t&&o.push(n[s]);0===o.length?delete r[e]:r[e]=o}},j.prototype=Object.create(O.prototype),$.prototype=Object.create(O.prototype),k.prototype=Object.create(O.prototype);var A=-1,P=0,I=1,R=2,M=-1,D=0,F=1,q=2,N=3,U=/^text\/event\-stream(;.*)?$/i,W=function(e,t){var r=null==e?t:parseInt(e,10);return r!=r&&(r=t),L(r)},L=function(e){return Math.min(Math.max(e,1e3),18e6)},H=function(e,t,r){try{"function"==typeof t&&t.call(e,r)}catch(e){_(e)}};function z(e,t){T.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(e,t,r){t=String(t);var a=Boolean(r.withCredentials),u=r.lastEventIdQueryParameterName||"lastEventId",c=L(1e3),l=W(r.heartbeatTimeout,45e3),f="",h=c,d=!1,p=0,y=r.headers||{},m=r.Transport,g=B&&null==m?void 0:new b(null!=m?new m:null!=s&&"withCredentials"in s.prototype||null==i?new s:new i),v=null!=m&&"string"!=typeof m?new m:null==g?new S:new E,w=void 0,C=0,x=A,T="",_="",O="",z="",J=D,G=0,V=0,Q=function(t,r,n,o){if(x===P)if(200===t&&null!=n&&U.test(n)){x=I,d=Date.now(),h=c,e.readyState=I;var s=new $("open",{status:t,statusText:r,headers:o});e.dispatchEvent(s),H(e,e.onopen,s)}else{var i="";200!==t?(r&&(r=r.replace(/\s+/g," ")),i="EventSource's response has a status "+t+" "+r+" that is not 200. Aborting the connection."):i="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",K();s=new $("error",{status:t,statusText:r,headers:o});e.dispatchEvent(s),H(e,e.onerror,s),console.error(i)}},Y=function(t){if(x===I){for(var r=-1,s=0;s<t.length;s+=1){(u=t.charCodeAt(s))!=="\n".charCodeAt(0)&&u!=="\r".charCodeAt(0)||(r=s)}var i=(-1!==r?z:"")+t.slice(0,r+1);z=(-1===r?z:"")+t.slice(r+1),""!==t&&(d=Date.now(),p+=t.length);for(var a=0;a<i.length;a+=1){var u=i.charCodeAt(a);if(J===M&&u==="\n".charCodeAt(0))J=D;else if(J===M&&(J=D),u==="\r".charCodeAt(0)||u==="\n".charCodeAt(0)){if(J!==D){J===F&&(V=a+1);var y=i.slice(G,V-1),m=i.slice(V+(V<a&&i.charCodeAt(V)===" ".charCodeAt(0)?1:0),a);"data"===y?(T+="\n",T+=m):"id"===y?_=m:"event"===y?O=m:"retry"===y?(c=W(m,c),h=c):"heartbeatTimeout"===y&&(l=W(m,l),0!==C&&(o(C),C=n((function(){Z()}),l)))}if(J===D){if(""!==T){f=_,""===O&&(O="message");var g=new j(O,{data:T.slice(1),lastEventId:_});if(e.dispatchEvent(g),"open"===O?H(e,e.onopen,g):"message"===O?H(e,e.onmessage,g):"error"===O&&H(e,e.onerror,g),x===R)return}T="",O=""}J=u==="\r".charCodeAt(0)?M:D}else J===D&&(G=a,J=F),J===F?u===":".charCodeAt(0)&&(V=a+1,J=q):J===q&&(J=N)}}},X=function(t){if(x===I||x===P){x=A,0!==C&&(o(C),C=0),C=n((function(){Z()}),h),h=L(Math.min(16*c,2*h)),e.readyState=P;var r=new k("error",{error:t});e.dispatchEvent(r),H(e,e.onerror,r),null!=t&&console.error(t)}},K=function(){x=R,null!=w&&(w.abort(),w=void 0),0!==C&&(o(C),C=0),e.readyState=R},Z=function(){if(C=0,x===A){d=!1,p=0,C=n((function(){Z()}),l),x=P,T="",O="",_=f,z="",G=0,V=0,J=D;var r=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==f){var o=t.indexOf("?");r=-1===o?t:t.slice(0,o+1)+t.slice(o+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(e,t){return t===u?"":e})),r+=(-1===t.indexOf("?")?"?":"&")+u+"="+encodeURIComponent(f)}var s=e.withCredentials,i={Accept:"text/event-stream"},a=e.headers;if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(i[c]=a[c]);try{w=v.open(g,Q,Y,X,r,s,i)}catch(e){throw K(),e}}else if(d||null==w){var h=Math.max((d||Date.now())+l-Date.now(),1);d=!1,C=n((function(){Z()}),h)}else X(new Error("No activity within "+l+" milliseconds. "+(x===P?"No response received.":p+" chars received.")+" Reconnecting.")),null!=w&&(w.abort(),w=void 0)};e.url=t,e.readyState=P,e.withCredentials=a,e.headers=y,e._close=K,Z()}(this,e,t)}var B=null!=f&&null!=h&&"body"in h.prototype;z.prototype=Object.create(T.prototype),z.prototype.CONNECTING=P,z.prototype.OPEN=I,z.prototype.CLOSED=R,z.prototype.close=function(){this._close()},z.CONNECTING=P,z.OPEN=I,z.CLOSED=R,z.prototype.withCredentials=void 0;var J,G=u;null==s||null!=u&&"withCredentials"in u.prototype||(G=z),J=function(e){e.EventSourcePolyfill=z,e.NativeEventSource=u,e.EventSource=G}(t),void 0!==J&&(e.exports=J)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:so:globalThis)}(ao,ao.exports);var uo=io(ao.exports.EventSourcePolyfill),co=Object.freeze({__proto__:null,default:uo});e.BasePatch=Mt,e.BaseTransaction=Jt,e.ClientError=lt,e.ObservablePatch=Dt,e.ObservableSanityClient=$n,e.ObservableTransaction=Yt,e.Patch=qt,e.SanityClient=Pn,e.ServerError=ft,e.Transaction=Vt,e.createClient=Mn,e.default=Dn,e.requester=Rn,e.unstable__adapter=T,e.unstable__environment="browser",Object.defineProperty(e,"__esModule",{value:!0})}));
12
+ */!function(e,t){!function(r){var n=r.setTimeout,o=r.clearTimeout,s=r.XMLHttpRequest,i=r.XDomainRequest,a=r.ActiveXObject,u=r.EventSource,c=r.document,l=r.Promise,f=r.fetch,h=r.Response,d=r.TextDecoder,p=r.TextEncoder,y=r.AbortController;if("undefined"==typeof window||void 0===c||"readyState"in c||null!=c.body||(c.readyState="loading",window.addEventListener("load",(function(e){c.readyState="complete"}),!1)),null==s&&null!=a&&(s=function(){return new a("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==y){var m=f;f=function(e,t){var r=t.signal;return m(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then((function(e){var t=e.body.getReader();return r._reader=t,r._aborted&&r._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}}))},y=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function g(){this.bitsNeeded=0,this.codePoint=0}g.prototype.decode=function(e){function t(e,t,r){if(1===r)return e>=128>>t&&e<<t<=2047;if(2===r)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===r)return e>=65536>>t&&e<<t<=1114111;throw new Error}function r(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var n=65533,o="",s=this.bitsNeeded,i=this.codePoint,a=0;a<e.length;a+=1){var u=e[a];0!==s&&(u<128||u>191||!t(i<<6|63&u,s-6,r(s,i)))&&(s=0,i=n,o+=String.fromCharCode(i)),0===s?(u>=0&&u<=127?(s=0,i=u):u>=192&&u<=223?(s=6,i=31&u):u>=224&&u<=239?(s=12,i=15&u):u>=240&&u<=247?(s=18,i=7&u):(s=0,i=n),0===s||t(i,s,r(s,i))||(s=0,i=n)):(s-=6,i=i<<6|63&u),0===s&&(i<=65535?o+=String.fromCharCode(i):(o+=String.fromCharCode(55296+(i-65535-1>>10)),o+=String.fromCharCode(56320+(i-65535-1&1023))))}return this.bitsNeeded=s,this.codePoint=i,o};null!=d&&null!=p&&function(){try{return"test"===(new d).decode((new p).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(d=g);var v=function(){};function b(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=v,this.onload=v,this.onerror=v,this.onreadystatechange=v,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=v}function w(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function C(e){for(var t=Object.create(null),r=e.split("\r\n"),n=0;n<r.length;n+=1){var o=r[n].split(": "),s=o.shift(),i=o.join(": ");t[w(s)]=i}this._map=t}function E(){}function x(e){this._headers=e}function S(){}function T(){this._listeners=Object.create(null)}function _(e){n((function(){throw e}),0)}function O(e){this.type=e,this.target=void 0}function j(e,t){O.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function $(e,t){O.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function k(e,t){O.call(this,e),this.error=t.error}b.prototype.open=function(e,t){this._abort(!0);var r=this,i=this._xhr,a=1,u=0;this._abort=function(e){0!==r._sendTimeout&&(o(r._sendTimeout),r._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,i.onload=v,i.onerror=v,i.onabort=v,i.onprogress=v,i.onreadystatechange=v,i.abort(),0!==u&&(o(u),u=0),e||(r.readyState=4,r.onabort(null),r.onreadystatechange())),a=0};var c=function(){if(1===a){var e=0,t="",n=void 0;if("contentType"in i)e=200,t="OK",n=i.contentType;else try{e=i.status,t=i.statusText,n=i.getResponseHeader("Content-Type")}catch(r){e=0,t="",n=void 0}0!==e&&(a=2,r.readyState=2,r.status=e,r.statusText=t,r._contentType=n,r.onreadystatechange())}},l=function(){if(c(),2===a||3===a){a=3;var e="";try{e=i.responseText}catch(e){}r.readyState=3,r.responseText=e,r.onprogress()}},f=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:v}),l(),1===a||2===a||3===a){if(a=4,0!==u&&(o(u),u=0),r.readyState=4,"load"===e)r.onload(t);else if("error"===e)r.onerror(t);else{if("abort"!==e)throw new TypeError;r.onabort(t)}r.onreadystatechange()}},h=function(){u=n((function(){h()}),500),3===i.readyState&&l()};"onload"in i&&(i.onload=function(e){f("load",e)}),"onerror"in i&&(i.onerror=function(e){f("error",e)}),"onabort"in i&&(i.onabort=function(e){f("abort",e)}),"onprogress"in i&&(i.onprogress=l),"onreadystatechange"in i&&(i.onreadystatechange=function(e){!function(e){null!=i&&(4===i.readyState?"onload"in i&&"onerror"in i&&"onabort"in i||f(""===i.responseText?"error":"load",e):3===i.readyState?"onprogress"in i||l():2===i.readyState&&c())}(e)}),!("contentType"in i)&&"ontimeout"in s.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),i.open(e,t,!0),"readyState"in i&&(u=n((function(){h()}),0))},b.prototype.abort=function(){this._abort(!1)},b.prototype.getResponseHeader=function(e){return this._contentType},b.prototype.setRequestHeader=function(e,t){var r=this._xhr;"setRequestHeader"in r&&r.setRequestHeader(e,t)},b.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},b.prototype.send=function(){if("ontimeout"in s.prototype&&("sendAsBinary"in s.prototype||"mozAnon"in s.prototype)||null==c||null==c.readyState||"complete"===c.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=n((function(){t._sendTimeout=0,t.send()}),4)}},C.prototype.get=function(e){return this._map[w(e)]},null!=s&&null==s.HEADERS_RECEIVED&&(s.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,r,n,o,i,a){e.open("GET",o);var u=0;for(var c in e.onprogress=function(){var t=e.responseText.slice(u);u+=t.length,r(t)},e.onerror=function(e){e.preventDefault(),n(new Error("NetworkError"))},e.onload=function(){n(null)},e.onabort=function(){n(null)},e.onreadystatechange=function(){if(e.readyState===s.HEADERS_RECEIVED){var r=e.status,n=e.statusText,o=e.getResponseHeader("Content-Type"),i=e.getAllResponseHeaders();t(r,n,o,new C(i))}},e.withCredentials=i,a)Object.prototype.hasOwnProperty.call(a,c)&&e.setRequestHeader(c,a[c]);return e.send(),e},x.prototype.get=function(e){return this._headers.get(e)},S.prototype.open=function(e,t,r,n,o,s,i){var a=null,u=new y,c=u.signal,h=new d;return f(o,{headers:i,credentials:s?"include":"same-origin",signal:c,cache:"no-store"}).then((function(e){return a=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new x(e.headers)),new l((function(e,t){var n=function(){a.read().then((function(t){if(t.done)e(void 0);else{var o=h.decode(t.value,{stream:!0});r(o),n()}})).catch((function(e){t(e)}))};n()}))})).catch((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){n(e)})),{abort:function(){null!=a&&a.cancel(),u.abort()}}},T.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(null!=t)for(var r=t.length,n=0;n<r;n+=1){var o=t[n];try{"function"==typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(e){_(e)}}},T.prototype.addEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];null==n&&(n=[],r[e]=n);for(var o=!1,s=0;s<n.length;s+=1)n[s]===t&&(o=!0);o||n.push(t)},T.prototype.removeEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];if(null!=n){for(var o=[],s=0;s<n.length;s+=1)n[s]!==t&&o.push(n[s]);0===o.length?delete r[e]:r[e]=o}},j.prototype=Object.create(O.prototype),$.prototype=Object.create(O.prototype),k.prototype=Object.create(O.prototype);var A=-1,P=0,I=1,R=2,M=-1,D=0,F=1,q=2,N=3,U=/^text\/event\-stream(;.*)?$/i,W=function(e,t){var r=null==e?t:parseInt(e,10);return r!=r&&(r=t),L(r)},L=function(e){return Math.min(Math.max(e,1e3),18e6)},H=function(e,t,r){try{"function"==typeof t&&t.call(e,r)}catch(e){_(e)}};function z(e,t){T.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(e,t,r){t=String(t);var a=Boolean(r.withCredentials),u=r.lastEventIdQueryParameterName||"lastEventId",c=L(1e3),l=W(r.heartbeatTimeout,45e3),f="",h=c,d=!1,p=0,y=r.headers||{},m=r.Transport,g=B&&null==m?void 0:new b(null!=m?new m:null!=s&&"withCredentials"in s.prototype||null==i?new s:new i),v=null!=m&&"string"!=typeof m?new m:null==g?new S:new E,w=void 0,C=0,x=A,T="",_="",O="",z="",J=D,G=0,V=0,Q=function(t,r,n,o){if(x===P)if(200===t&&null!=n&&U.test(n)){x=I,d=Date.now(),h=c,e.readyState=I;var s=new $("open",{status:t,statusText:r,headers:o});e.dispatchEvent(s),H(e,e.onopen,s)}else{var i="";200!==t?(r&&(r=r.replace(/\s+/g," ")),i="EventSource's response has a status "+t+" "+r+" that is not 200. Aborting the connection."):i="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",K();s=new $("error",{status:t,statusText:r,headers:o});e.dispatchEvent(s),H(e,e.onerror,s),console.error(i)}},Y=function(t){if(x===I){for(var r=-1,s=0;s<t.length;s+=1){(u=t.charCodeAt(s))!=="\n".charCodeAt(0)&&u!=="\r".charCodeAt(0)||(r=s)}var i=(-1!==r?z:"")+t.slice(0,r+1);z=(-1===r?z:"")+t.slice(r+1),""!==t&&(d=Date.now(),p+=t.length);for(var a=0;a<i.length;a+=1){var u=i.charCodeAt(a);if(J===M&&u==="\n".charCodeAt(0))J=D;else if(J===M&&(J=D),u==="\r".charCodeAt(0)||u==="\n".charCodeAt(0)){if(J!==D){J===F&&(V=a+1);var y=i.slice(G,V-1),m=i.slice(V+(V<a&&i.charCodeAt(V)===" ".charCodeAt(0)?1:0),a);"data"===y?(T+="\n",T+=m):"id"===y?_=m:"event"===y?O=m:"retry"===y?(c=W(m,c),h=c):"heartbeatTimeout"===y&&(l=W(m,l),0!==C&&(o(C),C=n((function(){Z()}),l)))}if(J===D){if(""!==T){f=_,""===O&&(O="message");var g=new j(O,{data:T.slice(1),lastEventId:_});if(e.dispatchEvent(g),"open"===O?H(e,e.onopen,g):"message"===O?H(e,e.onmessage,g):"error"===O&&H(e,e.onerror,g),x===R)return}T="",O=""}J=u==="\r".charCodeAt(0)?M:D}else J===D&&(G=a,J=F),J===F?u===":".charCodeAt(0)&&(V=a+1,J=q):J===q&&(J=N)}}},X=function(t){if(x===I||x===P){x=A,0!==C&&(o(C),C=0),C=n((function(){Z()}),h),h=L(Math.min(16*c,2*h)),e.readyState=P;var r=new k("error",{error:t});e.dispatchEvent(r),H(e,e.onerror,r),null!=t&&console.error(t)}},K=function(){x=R,null!=w&&(w.abort(),w=void 0),0!==C&&(o(C),C=0),e.readyState=R},Z=function(){if(C=0,x===A){d=!1,p=0,C=n((function(){Z()}),l),x=P,T="",O="",_=f,z="",G=0,V=0,J=D;var r=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==f){var o=t.indexOf("?");r=-1===o?t:t.slice(0,o+1)+t.slice(o+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(e,t){return t===u?"":e})),r+=(-1===t.indexOf("?")?"?":"&")+u+"="+encodeURIComponent(f)}var s=e.withCredentials,i={Accept:"text/event-stream"},a=e.headers;if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(i[c]=a[c]);try{w=v.open(g,Q,Y,X,r,s,i)}catch(e){throw K(),e}}else if(d||null==w){var h=Math.max((d||Date.now())+l-Date.now(),1);d=!1,C=n((function(){Z()}),h)}else X(new Error("No activity within "+l+" milliseconds. "+(x===P?"No response received.":p+" chars received.")+" Reconnecting.")),null!=w&&(w.abort(),w=void 0)};e.url=t,e.readyState=P,e.withCredentials=a,e.headers=y,e._close=K,Z()}(this,e,t)}var B=null!=f&&null!=h&&"body"in h.prototype;z.prototype=Object.create(T.prototype),z.prototype.CONNECTING=P,z.prototype.OPEN=I,z.prototype.CLOSED=R,z.prototype.close=function(){this._close()},z.CONNECTING=P,z.OPEN=I,z.CLOSED=R,z.prototype.withCredentials=void 0;var J,G=u;null==s||null!=u&&"withCredentials"in u.prototype||(G=z),J=function(e){e.EventSourcePolyfill=z,e.NativeEventSource=u,e.EventSource=G}(t),void 0!==J&&(e.exports=J)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:ro:globalThis)}(oo,oo.exports);var so=no(oo.exports.EventSourcePolyfill),io=Object.freeze({__proto__:null,default:so});e.BasePatch=Rt,e.BaseTransaction=Bt,e.ClientError=lt,e.ObservablePatch=Mt,e.ObservableSanityClient=jn,e.ObservableTransaction=Qt,e.Patch=Ft,e.SanityClient=An,e.ServerError=ft,e.Transaction=Gt,e.createClient=Rn,e.default=Mn,e.requester=In,e.unstable__adapter=T,e.unstable__environment="browser",Object.defineProperty(e,"__esModule",{value:!0})}));