@sanity/client 6.20.2 → 6.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "6.20.2",
3
+ "version": "6.21.1",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -122,8 +122,8 @@
122
122
  "rxjs": "^7.0.0"
123
123
  },
124
124
  "devDependencies": {
125
- "@edge-runtime/types": "^2.2.9",
126
- "@edge-runtime/vm": "^3.2.0",
125
+ "@edge-runtime/types": "^3.0.0",
126
+ "@edge-runtime/vm": "^4.0.0",
127
127
  "@rollup/plugin-commonjs": "^26.0.1",
128
128
  "@rollup/plugin-node-resolve": "^15.2.3",
129
129
  "@sanity/pkg-utils": "^6.9.3",
@@ -132,7 +132,7 @@
132
132
  "@typescript-eslint/eslint-plugin": "^7.13.1",
133
133
  "@typescript-eslint/parser": "^7.13.1",
134
134
  "@vercel/stega": "0.1.2",
135
- "@vitest/coverage-v8": "1.6.0",
135
+ "@vitest/coverage-v8": "2.0.2",
136
136
  "eslint": "^8.57.0",
137
137
  "eslint-config-prettier": "^9.1.0",
138
138
  "eslint-plugin-prettier": "^5.1.3",
@@ -150,7 +150,7 @@
150
150
  "sse-channel": "^4.0.0",
151
151
  "terser": "^5.31.1",
152
152
  "typescript": "5.4.5",
153
- "vitest": "1.6.0",
153
+ "vitest": "2.0.2",
154
154
  "vitest-github-actions-reporter": "0.11.1"
155
155
  },
156
156
  "engines": {
@@ -17,6 +17,7 @@ import type {
17
17
  BaseActionOptions,
18
18
  BaseMutationOptions,
19
19
  ClientConfig,
20
+ ClientReturn,
20
21
  FilteredResponseQueryOptions,
21
22
  FirstDocumentIdMutationOptions,
22
23
  FirstDocumentMutationOptions,
@@ -142,10 +143,11 @@ export class ObservableSanityClient {
142
143
  *
143
144
  * @param query - GROQ-query to perform
144
145
  */
145
- fetch<R = Any, Q extends QueryWithoutParams = QueryWithoutParams>(
146
- query: string,
147
- params?: Q | QueryWithoutParams,
148
- ): Observable<R>
146
+ fetch<
147
+ R = Any,
148
+ Q extends QueryWithoutParams = QueryWithoutParams,
149
+ const G extends string = string,
150
+ >(query: G, params?: Q | QueryWithoutParams): Observable<ClientReturn<G, R>>
149
151
  /**
150
152
  * Perform a GROQ-query against the configured dataset.
151
153
  *
@@ -153,11 +155,15 @@ export class ObservableSanityClient {
153
155
  * @param params - Optional query parameters
154
156
  * @param options - Optional request options
155
157
  */
156
- fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
157
- query: string,
158
+ fetch<
159
+ R = Any,
160
+ Q extends QueryWithoutParams | QueryParams = QueryParams,
161
+ const G extends string = string,
162
+ >(
163
+ query: G,
158
164
  params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
159
165
  options?: FilteredResponseQueryOptions,
160
- ): Observable<R>
166
+ ): Observable<ClientReturn<G, R>>
161
167
  /**
162
168
  * Perform a GROQ-query against the configured dataset.
163
169
  *
@@ -165,11 +171,15 @@ export class ObservableSanityClient {
165
171
  * @param params - Optional query parameters
166
172
  * @param options - Request options
167
173
  */
168
- fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
174
+ fetch<
175
+ R = Any,
176
+ Q extends QueryWithoutParams | QueryParams = QueryParams,
177
+ const G extends string = string,
178
+ >(
169
179
  query: string,
170
180
  params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
171
181
  options: UnfilteredResponseQueryOptions,
172
- ): Observable<RawQueryResponse<R>>
182
+ ): Observable<RawQueryResponse<ClientReturn<G, R>>>
173
183
  /**
174
184
  * Perform a GROQ-query against the configured dataset.
175
185
  *
@@ -177,13 +187,17 @@ export class ObservableSanityClient {
177
187
  * @param params - Optional query parameters
178
188
  * @param options - Request options
179
189
  */
180
- fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
181
- query: string,
190
+ fetch<
191
+ R = Any,
192
+ Q extends QueryWithoutParams | QueryParams = QueryParams,
193
+ const G extends string = string,
194
+ >(
195
+ query: G,
182
196
  params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
183
197
  options: UnfilteredResponseWithoutQuery,
184
- ): Observable<RawQuerylessQueryResponse<R>>
185
- fetch<R, Q>(
186
- query: string,
198
+ ): Observable<RawQuerylessQueryResponse<ClientReturn<G, R>>>
199
+ fetch<R, Q, const G extends string>(
200
+ query: G,
187
201
  params?: Q,
188
202
  options?: QueryOptions,
189
203
  ): Observable<RawQueryResponse<R> | R> {
@@ -808,10 +822,11 @@ export class SanityClient {
808
822
  *
809
823
  * @param query - GROQ-query to perform
810
824
  */
811
- fetch<R = Any, Q extends QueryWithoutParams = QueryWithoutParams>(
812
- query: string,
813
- params?: Q | QueryWithoutParams,
814
- ): Promise<R>
825
+ fetch<
826
+ R = Any,
827
+ Q extends QueryWithoutParams = QueryWithoutParams,
828
+ const G extends string = string,
829
+ >(query: G, params?: Q | QueryWithoutParams): Promise<ClientReturn<G, R>>
815
830
  /**
816
831
  * Perform a GROQ-query against the configured dataset.
817
832
  *
@@ -819,11 +834,15 @@ export class SanityClient {
819
834
  * @param params - Optional query parameters
820
835
  * @param options - Optional request options
821
836
  */
822
- fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
823
- query: string,
837
+ fetch<
838
+ R = Any,
839
+ Q extends QueryWithoutParams | QueryParams = QueryParams,
840
+ const G extends string = string,
841
+ >(
842
+ query: G,
824
843
  params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
825
844
  options?: FilteredResponseQueryOptions,
826
- ): Promise<R>
845
+ ): Promise<ClientReturn<G, R>>
827
846
  /**
828
847
  * Perform a GROQ-query against the configured dataset.
829
848
  *
@@ -831,11 +850,15 @@ export class SanityClient {
831
850
  * @param params - Optional query parameters
832
851
  * @param options - Request options
833
852
  */
834
- fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
835
- query: string,
853
+ fetch<
854
+ R = Any,
855
+ Q extends QueryWithoutParams | QueryParams = QueryParams,
856
+ const G extends string = string,
857
+ >(
858
+ query: G,
836
859
  params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
837
860
  options: UnfilteredResponseQueryOptions,
838
- ): Promise<RawQueryResponse<R>>
861
+ ): Promise<RawQueryResponse<ClientReturn<G, R>>>
839
862
  /**
840
863
  * Perform a GROQ-query against the configured dataset.
841
864
  *
@@ -843,14 +866,22 @@ export class SanityClient {
843
866
  * @param params - Optional query parameters
844
867
  * @param options - Request options
845
868
  */
846
- fetch<R = Any, Q extends QueryWithoutParams | QueryParams = QueryParams>(
847
- query: string,
869
+ fetch<
870
+ R = Any,
871
+ Q extends QueryWithoutParams | QueryParams = QueryParams,
872
+ const G extends string = string,
873
+ >(
874
+ query: G,
848
875
  params: Q extends QueryWithoutParams ? QueryWithoutParams : Q,
849
876
  options: UnfilteredResponseWithoutQuery,
850
- ): Promise<RawQuerylessQueryResponse<R>>
851
- fetch<R, Q>(query: string, params?: Q, options?: QueryOptions): Promise<RawQueryResponse<R> | R> {
877
+ ): Promise<RawQuerylessQueryResponse<ClientReturn<G, R>>>
878
+ fetch<R, Q, const G extends string>(
879
+ query: G,
880
+ params?: Q,
881
+ options?: QueryOptions,
882
+ ): Promise<RawQueryResponse<ClientReturn<G, R>> | ClientReturn<G, R>> {
852
883
  return lastValueFrom(
853
- dataMethods._fetch<R, Q>(
884
+ dataMethods._fetch<ClientReturn<G, R>, Q>(
854
885
  this,
855
886
  this.#httpRequest,
856
887
  this.#clientConfig.stega,
@@ -11,7 +11,7 @@ export const encodeQueryString = ({
11
11
  }) => {
12
12
  const searchParams = new URLSearchParams()
13
13
  // We generally want tag at the start of the query string
14
- const {tag, returnQuery, ...opts} = options
14
+ const {tag, includeMutations, returnQuery, ...opts} = options
15
15
  // We're using `append` instead of `set` to support React Native: https://github.com/facebook/react-native/blob/1982c4722fcc51aa87e34cf562672ee4aff540f1/packages/react-native/Libraries/Blob/URL.js#L86-L88
16
16
  if (tag) searchParams.append('tag', tag)
17
17
  searchParams.append('query', query)
@@ -29,5 +29,8 @@ export const encodeQueryString = ({
29
29
  // `returnQuery` is default `true`, so needs an explicit `false` handling
30
30
  if (returnQuery === false) searchParams.append('returnQuery', 'false')
31
31
 
32
+ // `includeMutations` is default `true`, so needs an explicit `false` handling
33
+ if (includeMutations === false) searchParams.append('includeMutations', 'false')
34
+
32
35
  return `?${searchParams}`
33
36
  }
@@ -15,6 +15,7 @@ const MAX_URL_LENGTH = 16000 - 1200
15
15
  const possibleOptions = [
16
16
  'includePreviousRevision',
17
17
  'includeResult',
18
+ 'includeMutations',
18
19
  'visibility',
19
20
  'effectFormat',
20
21
  'tag',
package/src/types.ts CHANGED
@@ -874,6 +874,13 @@ export interface ListenOptions {
874
874
  */
875
875
  includeResult?: boolean
876
876
 
877
+ /**
878
+ * Whether or not to include the mutations that was performed.
879
+ * If you do not need the mutations, set this to `false` to reduce bandwidth usage.
880
+ * @defaultValue `true`
881
+ */
882
+ includeMutations?: boolean
883
+
877
884
  /**
878
885
  * Whether or not to include the document as it looked before the mutation event.
879
886
  * The previous revision will be available on the `.previous` property of the events,
@@ -1236,6 +1243,15 @@ export interface LiveEventMessage {
1236
1243
  tags: SyncTag[]
1237
1244
  }
1238
1245
 
1246
+ /** @public */
1247
+ export interface SanityQueries {}
1248
+
1249
+ /** @public */
1250
+ export type ClientReturn<
1251
+ GroqString extends string,
1252
+ Fallback = Any,
1253
+ > = GroqString extends keyof SanityQueries ? SanityQueries[GroqString] : Fallback
1254
+
1239
1255
  export type {
1240
1256
  ContentSourceMapParsedPath,
1241
1257
  ContentSourceMapParsedPathKeyedSegment,
@@ -2401,13 +2401,13 @@ ${selectionOpts}`);
2401
2401
  params = {},
2402
2402
  options = {}
2403
2403
  }) => {
2404
- const searchParams = new URLSearchParams(), { tag, returnQuery, ...opts } = options;
2404
+ const searchParams = new URLSearchParams(), { tag, includeMutations, returnQuery, ...opts } = options;
2405
2405
  tag && searchParams.append("tag", tag), searchParams.append("query", query);
2406
2406
  for (const [key, value] of Object.entries(params))
2407
2407
  searchParams.append(`$${key}`, JSON.stringify(value));
2408
2408
  for (const [key, value] of Object.entries(opts))
2409
2409
  value && searchParams.append(key, `${value}`);
2410
- return returnQuery === !1 && searchParams.append("returnQuery", "false"), `?${searchParams}`;
2410
+ return returnQuery === !1 && searchParams.append("returnQuery", "false"), includeMutations === !1 && searchParams.append("includeMutations", "false"), `?${searchParams}`;
2411
2411
  }, excludeFalsey = (param, defValue) => param === !1 ? void 0 : typeof param > "u" ? defValue : param, getMutationQuery = (options = {}) => ({
2412
2412
  dryRun: options.dryRun,
2413
2413
  returnIds: !0,
@@ -2666,6 +2666,7 @@ ${selectionOpts}`);
2666
2666
  const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}), MAX_URL_LENGTH = 14800, possibleOptions = [
2667
2667
  "includePreviousRevision",
2668
2668
  "includeResult",
2669
+ "includeMutations",
2669
2670
  "visibility",
2670
2671
  "effectFormat",
2671
2672
  "tag"
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Copyright (c) 2014-2017, Jon Schlinkert.
6
6
  * Released under the MIT License.
7
- */;function N(e){return"[object Object]"===Object.prototype.toString.call(e)}const U=["boolean","string","number"];function L(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||q(t)||-1===U.indexOf(typeof t)&&!Array.isArray(t)&&!function(e){if(!1===N(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!(!1===N(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 W(e){return{onResponse:e=>{const r=e.headers["content-type"]||"",n=-1!==r.indexOf("application/json");return e.body&&r&&n?Object.assign({},e,{body:t(e.body)}):e},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 z={};typeof globalThis<"u"?z=globalThis:typeof window<"u"?z=window:typeof global<"u"?z=global:typeof self<"u"&&(z=self);var H=z;function B(e={}){const t=e.implementation||H.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())))}}var J=Object.defineProperty,G=(e,t,r)=>((e,t,r)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class V{constructor(e){G(this,"__CANCEL__",!0),G(this,"message"),this.message=e}toString(){return"Cancel"+(this.message?`: ${this.message}`:"")}}const Q=class{constructor(e){if(G(this,"promise"),G(this,"reason"),"function"!=typeof e)throw new TypeError("executor must be a function.");let t=null;this.promise=new Promise((e=>{t=e})),e((e=>{this.reason||(this.reason=new V(e),t(this.reason))}))}};G(Q,"source",(()=>{let e;return{token:new Q((t=>{e=t})),cancel:e}}));var X=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function Y(e){return 100*Math.pow(2,e)+100*Math.random()}const K=(e={})=>(e=>{const t=e.maxRetries||5,r=e.retryDelay||Y,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 h=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:c+1})});return setTimeout((()=>o.channels.request.publish(h)),a(c)),null}}})({shouldRetry:X,...e});K.shouldRetry=X;var Z=function(e,t){return Z=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])},Z(e,t)};function ee(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}Z(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function te(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 re(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 ne(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 oe(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 se(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 ie(e){return this instanceof ie?(this.v=e,this):new ie(e)}function ae(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 ie?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 ue(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=ne(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 ce(e){return"function"==typeof e}function le(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 he=le((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 de(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var fe=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=ne(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(ce(u))try{u()}catch(e){o=e instanceof he?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var l=ne(c),h=l.next();!h.done;h=l.next()){var d=h.value;try{ye(d)}catch(e){o=null!=o?o:[],e instanceof he?o=se(se([],oe(o)),oe(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(o)throw new he(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)ye(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)&&de(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&de(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function pe(e){return e instanceof fe||e&&"closed"in e&&ce(e.remove)&&ce(e.add)&&ce(e.unsubscribe)}function ye(e){ce(e)?e():e.unsubscribe()}fe.EMPTY;var me={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ge={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,se([e,t],oe(r)))},clearTimeout:function(e){var t=ge.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function ve(e){ge.setTimeout((function(){throw e}))}function be(){}var we=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,pe(t)&&t.add(r)):r.destination=_e,r}return ee(t,e),t.create=function(e,t,r){return new Se(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}(fe),Ce=Function.prototype.bind;function Ee(e,t){return Ce.call(e,t)}var xe=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){Te(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Te(e)}else Te(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Te(e)}},e}(),Se=function(e){function t(t,r,n){var o,s,i=e.call(this)||this;ce(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:i&&me.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&Ee(t.next,s),error:t.error&&Ee(t.error,s),complete:t.complete&&Ee(t.complete,s)}):o=t;return i.destination=new xe(o),i}return ee(t,e),t}(we);function Te(e){ve(e)}var _e={closed:!0,next:be,error:function(e){throw e},complete:be},Oe="function"==typeof Symbol&&Symbol.observable||"@@observable";function je(e){return e}function $e(e){return 0===e.length?je:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var ke=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 we||function(e){return e&&ce(e.next)&&ce(e.error)&&ce(e.complete)}(n)&&pe(n)?e:new Se(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=Ae(t))((function(t,n){var o=new Se({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[Oe]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return $e(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Ae(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 Ae(e){var t;return null!==(t=null!=e?e:me.Promise)&&void 0!==t?t:Promise}function Pe(e){return function(t){if(function(e){return ce(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 Ie(e,t,r,n,o){return new Re(e,t,r,n,o)}var Re=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 ee(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}(we);var Me=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};var De="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Fe(e){if(e instanceof ke)return e;if(null!=e){if(function(e){return ce(e[Oe])}(e))return s=e,new ke((function(e){var t=s[Oe]();if(ce(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Me(e))return o=e,new ke((function(e){for(var t=0;t<o.length&&!e.closed;t++)e.next(o[t]);e.complete()}));if(ce(null==(n=e)?void 0:n.then))return r=e,new ke((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,ve)}));if(function(e){return Symbol.asyncIterator&&ce(null==e?void 0:e[Symbol.asyncIterator])}(e))return qe(e);if(function(e){return ce(null==e?void 0:e[De])}(e))return t=e,new ke((function(e){var r,n;try{for(var o=ne(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(function(e){return ce(null==e?void 0:e.getReader)}(e))return qe(function(e){return ae(this,arguments,(function(){var t,r,n;return re(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,ie(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,ie(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,ie(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]}}))}))}(e))}var t,r,n,o,s;throw function(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.")}(e)}function qe(e){return new ke((function(t){(function(e,t){var r,n,o,s;return te(this,void 0,void 0,(function(){var i,a;return re(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),r=ue(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 Ne(e,t){return Fe(e)}var Ue=le((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Le(e,t){return new Promise((function(t,r){var n,o=!1;e.subscribe({next:function(e){n=e,o=!0},error:r,complete:function(){o?t(n):r(new Ue)}})}))}function We(e,t){return Pe((function(r,n){var o=0;r.subscribe(Ie(n,(function(r){n.next(e.call(t,r,o++))})))}))}var ze=Array.isArray;function He(e){return We((function(t){return function(e,t){return ze(t)?e.apply(void 0,se([],oe(t))):e(t)}(e,t)}))}function Be(e,t,r){t()}var Je=Array.isArray;function Ge(e,t){return Pe((function(r,n){var o=0;r.subscribe(Ie(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function Ve(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return ce((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 $e(e)}(Ve.apply(void 0,se([],oe(e))),He(r)):Pe((function(t,r){var n,o;(n=se([t],oe(function(e){return 1===e.length&&Je(e[0])?e[0]:e}(e))),void 0===o&&(o=je),function(e){Be(0,(function(){for(var t=n.length,r=new Array(t),s=t,i=t,a=function(t){Be(0,(function(){var a=Ne(n[t]),u=!1;a.subscribe(Ie(e,(function(n){r[t]=n,u||(u=!0,i--),i||e.next(o(r.slice()))}),(function(){--s||e.complete()})))}))},u=0;u<t;u++)a(u)}))})(r)}))}var Qe={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},Xe={0:8203,1:8204,2:8205,3:65279},Ye=new Array(4).fill(String.fromCodePoint(Xe[0])).join("");function Ke(e,t,r="auto"){return!0===r||"auto"===r&&(function(e){return!(!Number.isNaN(Number(e))||/[a-z]/i.test(e)&&!/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(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`${Ye}${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(Xe[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(Xe).map((e=>e.reverse()))),Object.fromEntries(Object.entries(Qe).map((e=>e.reverse())));var Ze=`${Object.values(Qe).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,et=new RegExp(`[${Ze}]{4,}`,"gu");function tt(e){return e&&JSON.parse(function(e){var t;return{cleaned:e.replace(et,""),encoded:(null==(t=e.match(et))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}var rt=Object.defineProperty,nt=(e,t,r)=>(((e,t,r)=>{t in e?rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class ot extends Error{constructor(e){const t=it(e);super(t.message),nt(this,"response"),nt(this,"statusCode",400),nt(this,"responseBody"),nt(this,"details"),Object.assign(this,t)}}class st extends Error{constructor(e){const t=it(e);super(t.message),nt(this,"response"),nt(this,"statusCode",500),nt(this,"responseBody"),nt(this,"details"),Object.assign(this,t)}}function it(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:ut(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message=`${t.error} - ${t.message}`,r;if(function(e){return at(e)&&at(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)||function(e){return at(e)&&at(e.error)&&"actionError"===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 at(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ut(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const ct={onResponse:e=>{if(e.statusCode>=500)throw new st(e);if(e.statusCode>=400)throw new ot(e);return e}},lt={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};function ht(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)||K.shouldRetry(e,t,r)}function dt(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 ft=["image","file"],pt=["before","after","replace"],yt=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")},mt=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},gt=(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`)},vt=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);gt(e,t._id)},bt=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},wt=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 Ct,Et=Object.defineProperty,xt=(e,t,r)=>(((e,t,r)=>{t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),St=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Tt=(e,t,r)=>(St(e,t,"read from private field"),r?r.call(e):t.get(e)),_t=(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)},Ot=(e,t,r,n)=>(St(e,t,"write to private field"),t.set(e,r),r);class jt{constructor(e,t={}){xt(this,"selection"),xt(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 mt("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===pt.indexOf(e)){const e=pt.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{...dt(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return mt(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)}}Ct=new WeakMap;let $t=class e extends jt{constructor(e,t,r){super(e,t),_t(this,Ct,void 0),Ot(this,Ct,r)}clone(){return new e(this.selection,{...this.operations},Tt(this,Ct))}commit(e){if(!Tt(this,Ct))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const t="string"==typeof this.selection,r=Object.assign({returnFirst:t,returnDocuments:!0},e);return Tt(this,Ct).mutate({patch:this.serialize()},r)}};var kt;kt=new WeakMap;let At=class e extends jt{constructor(e,t,r){super(e,t),_t(this,kt,void 0),Ot(this,kt,r)}clone(){return new e(this.selection,{...this.operations},Tt(this,kt))}commit(e){if(!Tt(this,kt))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 Tt(this,kt).mutate({patch:this.serialize()},r)}};var Pt=Object.defineProperty,It=(e,t,r)=>(((e,t,r)=>{t in e?Pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),Rt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Mt=(e,t,r)=>(Rt(e,t,"read from private field"),r?r.call(e):t.get(e)),Dt=(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)},Ft=(e,t,r,n)=>(Rt(e,t,"write to private field"),t.set(e,r),r);const qt={returnDocuments:!1};class Nt{constructor(e=[],t){It(this,"operations"),It(this,"trxId"),this.operations=e,this.trxId=t}create(e){return mt("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return mt(t,e),vt(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return mt(t,e),vt(t,e),this._add({[t]:e})}delete(e){return gt("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 Ut;Ut=new WeakMap;let Lt=class e extends Nt{constructor(e,t,r){super(e,r),Dt(this,Ut,void 0),Ft(this,Ut,t)}clone(){return new e([...this.operations],Mt(this,Ut),this.trxId)}commit(e){if(!Mt(this,Ut))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Mt(this,Ut).mutate(this.serialize(),Object.assign({transactionId:this.trxId},qt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof At)return this._add({patch:e.serialize()});if(r){const r=t(new At(e,{},Mt(this,Ut)));if(!(r instanceof At))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 Wt;Wt=new WeakMap;let zt=class e extends Nt{constructor(e,t,r){super(e,r),Dt(this,Wt,void 0),Ft(this,Wt,t)}clone(){return new e([...this.operations],Mt(this,Wt),this.trxId)}commit(e){if(!Mt(this,Wt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Mt(this,Wt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},qt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof $t)return this._add({patch:e.serialize()});if(r){const r=t(new $t(e,{},Mt(this,Wt)));if(!(r instanceof $t))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 Ht(e){return"https://www.sanity.io/help/"+e}const Bt=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),Jt=Bt(["Because you set `withCredentials` to true, we will override your `useCdn`","setting to be false since (cookie-based) credentials are never set on the CDN"]),Gt=Bt(["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."]),Vt=Bt(["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."]),Qt=Bt(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${Ht("js-client-browser-token")} for more information and how to hide this warning.`]),Xt=Bt(["Using the Sanity client without specifying an API version is deprecated.",`See ${Ht("js-client-api-version")}`]),Yt=Bt(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),Kt={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},Zt=["localhost","127.0.0.1","0.0.0.0"];const er=function(e){switch(e){case"previewDrafts":case"published":case"raw":return;default:throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`")}},tr=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||Kt.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||Xt();const n={...Kt,...r},o=n.useProjectHostname;if(typeof Promise>"u"){const e=Ht("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&&er(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!==Zt.indexOf(e))(window.location.hostname);s&&i&&n.token&&!0!==n.ignoreBrowserTokenWarning?Qt():typeof n.useCdn>"u"&&Gt(),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&&yt(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?wt(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===Kt.apiHost,!0===n.useCdn&&n.withCredentials&&Jt(),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},rr="X-Sanity-Project-ID";const nr=({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}`},or=(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},sr=e=>"response"===e.type,ir=e=>e.body,ar=11264;function ur(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?tt(o):o,u=!1===s.filterResponse?e=>e:e=>e.result,{cache:c,next:l,...h}={useAbortSignal:typeof s.signal<"u",resultSourceMap:i.enabled?"withKeyArraySelector":s.resultSourceMap,...s,returnQuery:!1===s.filterResponse&&!1!==s.returnQuery},d=mr(e,t,"query",{query:n,params:a},typeof c<"u"||typeof l<"u"?{...h,fetch:{cache:c,next:l}}:h);return i.enabled?d.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ve.apply(void 0,se([],oe(e)))}(Ne(Promise.resolve().then((function(){return no})).then((function(e){return e.stegaEncodeSourceMap$1})).then((({stegaEncodeSourceMap:e})=>e)))),We((([e,t])=>{const r=t(e.result,e.resultSourceMap,i);return u({...e,result:r})}))):d.pipe(We(u))}function cr(e,t,r,n={}){return vr(e,t,{uri:wr(e,"doc",r),json:!0,tag:n.tag}).pipe(Ge(sr),We((e=>e.body.documents&&e.body.documents[0])))}function lr(e,t,r,n={}){return vr(e,t,{uri:wr(e,"doc",r.join(",")),json:!0,tag:n.tag}).pipe(Ge(sr),We((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 hr(e,t,r,n){return vt("createIfNotExists",r),gr(e,t,r,"createIfNotExists",n)}function dr(e,t,r,n){return vt("createOrReplace",r),gr(e,t,r,"createOrReplace",n)}function fr(e,t,r,n){return mr(e,t,"mutate",{mutations:[{delete:dt(r)}]},n)}function pr(e,t,r,n){let o;o=r instanceof At||r instanceof $t?{patch:r.serialize()}:r instanceof Lt||r instanceof zt?r.serialize():r;return mr(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function yr(e,t,r,n){return mr(e,t,"actions",{actions:Array.isArray(r)?r:[r],transactionId:n&&n.transactionId||void 0,skipCrossDatasetReferenceValidation:n&&n.skipCrossDatasetReferenceValidation||void 0,dryRun:n&&n.dryRun||void 0},n)}function mr(e,t,r,n,o={}){const s="mutate"===r,i="actions"===r,a="query"===r,u=s||i?"":nr(n),c=!s&&!i&&u.length<ar,l=c?u:"",h=o.returnFirst,{timeout:d,token:f,tag:p,headers:y,returnQuery:m,lastLiveEventId:g}=o;return vr(e,t,{method:c?"GET":"POST",uri:wr(e,r,l),json:!0,body:c?void 0:n,query:s&&or(o),timeout:d,headers:y,token:f,tag:p,returnQuery:m,perspective:o.perspective,resultSourceMap:o.resultSourceMap,lastLiveEventId:Array.isArray(g)?g[0]:g,canUseCdn:a,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(Ge(sr),We(ir),We((e=>{if(!s)return e;const t=e.results||[];if(o.returnDocuments)return h?t[0]&&t[0].document:t.map((e=>e.document));const r=h?"documentId":"documentIds",n=h?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function gr(e,t,r,n,o={}){return mr(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function vr(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:wt(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&&(er(t),r.query={perspective:t,...r.query},"previewDrafts"===t&&u&&(u=!1,Vt())),r.lastLiveEventId&&(r.query={...r.query,lastLiveEventId:r.lastLiveEventId}),!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[rr]=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:Cr(e,s,u)})),h=new ke((e=>t(l,i.requester).subscribe(e)));return r.signal?h.pipe((d=r.signal,e=>new ke((t=>{const r=()=>t.error(function(e){var t,r;if(Er)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}(d));if(d&&d.aborted)return void r();const n=e.subscribe(t);return d.addEventListener("abort",r),()=>{d.removeEventListener("abort",r),n.unsubscribe()}})))):h;var d}function br(e,t,r){return vr(e,t,r).pipe(Ge((e=>"response"===e.type)),We((e=>e.body)))}function wr(e,t,r){const n=e.config(),o=`/${t}/${bt(n)}`;return`/data${r?`${o}/${r}`:o}`.replace(/\/($|\?)/,"$1")}function Cr(e,t,r=!1){const{url:n,cdnUrl:o}=e.config();return`${r?o:n}/${t.replace(/^\//,"")}`}const Er=!!globalThis.DOMException;var xr,Sr,Tr,_r,Or=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},jr=(e,t,r)=>(Or(e,t,"read from private field"),r?r.call(e):t.get(e)),$r=(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)},kr=(e,t,r,n)=>(Or(e,t,"write to private field"),t.set(e,r),r);class Ar{constructor(e,t){$r(this,xr,void 0),$r(this,Sr,void 0),kr(this,xr,e),kr(this,Sr,t)}upload(e,t,r){return Ir(jr(this,xr),jr(this,Sr),e,t,r)}}xr=new WeakMap,Sr=new WeakMap;class Pr{constructor(e,t){$r(this,Tr,void 0),$r(this,_r,void 0),kr(this,Tr,e),kr(this,_r,t)}upload(e,t,r){return Le(Ir(jr(this,Tr),jr(this,_r),e,t,r).pipe(Ge((e=>"response"===e.type)),We((e=>e.body.document))))}}function Ir(e,t,r,n,o={}){(e=>{if(-1===ft.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${ft.join(", ")}`)})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=bt(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:h,description:d,creditLine:f,filename:p,source:y}=u,m={label:l,title:h,description:d,filename:p,meta:s,creditLine:f};return y&&(m.sourceId=y.id,m.sourceName=y.name,m.sourceUrl=y.url),vr(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})}Tr=new WeakMap,_r=new WeakMap;const Rr=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],Mr={includeResult:!0};function Dr(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={...(h=r,d=Mr,Object.keys(d).concat(Object.keys(h)).reduce(((e,t)=>(e[t]=typeof h[t]>"u"?d[t]:h[t],e)),{})),tag:a},c=((e,t)=>t.reduce(((t,r)=>(typeof e[r]>"u"||(t[r]=e[r]),t)),{}))(u,Rr),l=`${n}${wr(this,"listen",nr({query:e,params:t,options:{tag:a,...c}}))}`;var h,d;if(l.length>14800)return new ke((e=>e.error(new Error("Query too large for listener"))));const f=u.events?u.events:["mutation"],p=-1!==f.indexOf("reconnect"),y={};return(o||s)&&(y.withCredentials=!0),o&&(y.headers={Authorization:`Bearer ${o}`}),new ke((e=>{let t,r,n=!1,o=!1;function s(){n||(p&&e.next({type:"reconnect"}),!n&&t.readyState===t.CLOSED&&(c(),clearTimeout(r),r=setTimeout(h,100)))}function i(t){e.error(function(e){if(e instanceof Error)return e;const t=Fr(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 a(t){const r=Fr(t);return r instanceof Error?e.error(r):e.next(r)}function u(){n=!0,c(),e.complete()}function c(){t&&(t.removeEventListener("error",s),t.removeEventListener("channelError",i),t.removeEventListener("disconnect",u),f.forEach((e=>t.removeEventListener(e,a))),t.close())}function h(){(async function(){const{default:e}=await Promise.resolve().then((function(){return uo}));if(o)return;const t=new e(l,y);return t.addEventListener("error",s),t.addEventListener("channelError",i),t.addEventListener("disconnect",u),f.forEach((e=>t.addEventListener(e,a))),t})().then((e=>{e&&(t=e,o&&c())})).catch((t=>{e.error(t),d()}))}function d(){n=!0,c(),o=!0}return h(),d}))}function Fr(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}var qr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Nr=(e,t,r)=>(qr(e,t,"read from private field"),r?r.call(e):t.get(e));const Ur="2021-03-26";var Lr;class Wr{constructor(e){var t,r,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)})(this,Lr,void 0),n=e,qr(t=this,r=Lr,"write to private field"),r.set(t,n)}events(){const e=Nr(this,Lr).config().apiVersion.replace(/^v/,"");if("X"!==e&&e<Ur)throw new Error(`The live events API requires API version ${Ur} or later. The current API version is ${e}. Please update your API version to use this feature.`);const t=wr(Nr(this,Lr),"live/events"),r=new URL(Nr(this,Lr).getUrl(t,!1)),n=["restart","message"];return new ke((e=>{let t,o,s=!1,i=!1;function a(r){if(!s){if("data"in r){const t=zr(r);e.error(new Error(t.message,{cause:t}))}t.readyState===t.CLOSED&&(c(),clearTimeout(o),o=setTimeout(l,100))}}function u(t){const r=zr(t);return r instanceof Error?e.error(r):e.next(r)}function c(){if(t){t.removeEventListener("error",a);for(const e of n)t.removeEventListener(e,u);t.close()}}function l(){(async function(){const e=typeof EventSource>"u"?(await Promise.resolve().then((function(){return uo}))).default:EventSource;if(i)return;const t=new e(r.toString());t.addEventListener("error",a);for(const e of n)t.addEventListener(e,u);return t})().then((e=>{e&&(t=e,i&&c())})).catch((t=>{e.error(t),h()}))}function h(){s=!0,c(),i=!0}return l(),h}))}}function zr(e){try{const t=e.data&&JSON.parse(e.data)||{};return{type:e.type,id:e.lastEventId,...t}}catch(e){return e}}Lr=new WeakMap;var Hr,Br,Jr,Gr,Vr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Qr=(e,t,r)=>(Vr(e,t,"read from private field"),r?r.call(e):t.get(e)),Xr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Yr=(e,t,r,n)=>(Vr(e,t,"write to private field"),t.set(e,r),r);class Kr{constructor(e,t){Xr(this,Hr,void 0),Xr(this,Br,void 0),Yr(this,Hr,e),Yr(this,Br,t)}create(e,t){return en(Qr(this,Hr),Qr(this,Br),"PUT",e,t)}edit(e,t){return en(Qr(this,Hr),Qr(this,Br),"PATCH",e,t)}delete(e){return en(Qr(this,Hr),Qr(this,Br),"DELETE",e)}list(){return br(Qr(this,Hr),Qr(this,Br),{uri:"/datasets",tag:null})}}Hr=new WeakMap,Br=new WeakMap;class Zr{constructor(e,t){Xr(this,Jr,void 0),Xr(this,Gr,void 0),Yr(this,Jr,e),Yr(this,Gr,t)}create(e,t){return Le(en(Qr(this,Jr),Qr(this,Gr),"PUT",e,t))}edit(e,t){return Le(en(Qr(this,Jr),Qr(this,Gr),"PATCH",e,t))}delete(e){return Le(en(Qr(this,Jr),Qr(this,Gr),"DELETE",e))}list(){return Le(br(Qr(this,Jr),Qr(this,Gr),{uri:"/datasets",tag:null}))}}function en(e,t,r,n,o){return yt(n),br(e,t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}Jr=new WeakMap,Gr=new WeakMap;var tn,rn,nn,on,sn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},an=(e,t,r)=>(sn(e,t,"read from private field"),r?r.call(e):t.get(e)),un=(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)},cn=(e,t,r,n)=>(sn(e,t,"write to private field"),t.set(e,r),r);class ln{constructor(e,t){un(this,tn,void 0),un(this,rn,void 0),cn(this,tn,e),cn(this,rn,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return br(an(this,tn),an(this,rn),{uri:t})}getById(e){return br(an(this,tn),an(this,rn),{uri:`/projects/${e}`})}}tn=new WeakMap,rn=new WeakMap;class hn{constructor(e,t){un(this,nn,void 0),un(this,on,void 0),cn(this,nn,e),cn(this,on,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Le(br(an(this,nn),an(this,on),{uri:t}))}getById(e){return Le(br(an(this,nn),an(this,on),{uri:`/projects/${e}`}))}}nn=new WeakMap,on=new WeakMap;var dn,fn,pn,yn,mn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},gn=(e,t,r)=>(mn(e,t,"read from private field"),r?r.call(e):t.get(e)),vn=(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)},bn=(e,t,r,n)=>(mn(e,t,"write to private field"),t.set(e,r),r);class wn{constructor(e,t){vn(this,dn,void 0),vn(this,fn,void 0),bn(this,dn,e),bn(this,fn,t)}getById(e){return br(gn(this,dn),gn(this,fn),{uri:`/users/${e}`})}}dn=new WeakMap,fn=new WeakMap;class Cn{constructor(e,t){vn(this,pn,void 0),vn(this,yn,void 0),bn(this,pn,e),bn(this,yn,t)}getById(e){return Le(br(gn(this,pn),gn(this,yn),{uri:`/users/${e}`}))}}pn=new WeakMap,yn=new WeakMap;var En,xn,Sn=Object.defineProperty,Tn=(e,t,r)=>(((e,t,r)=>{t in e?Sn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),_n=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},On=(e,t,r)=>(_n(e,t,"read from private field"),r?r.call(e):t.get(e)),jn=(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)},$n=(e,t,r,n)=>(_n(e,t,"write to private field"),t.set(e,r),r);En=new WeakMap,xn=new WeakMap;let kn=class e{constructor(e,t=Kt){Tn(this,"assets"),Tn(this,"datasets"),Tn(this,"live"),Tn(this,"projects"),Tn(this,"users"),jn(this,En,void 0),jn(this,xn,void 0),Tn(this,"listen",Dr),this.config(t),$n(this,xn,e),this.assets=new Ar(this,On(this,xn)),this.datasets=new Kr(this,On(this,xn)),this.live=new Wr(this),this.projects=new ln(this,On(this,xn)),this.users=new wn(this,On(this,xn))}clone(){return new e(On(this,xn),this.config())}config(e){if(void 0===e)return{...On(this,En)};if(On(this,En)&&!1===On(this,En).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return $n(this,En,tr(e,On(this,En)||{})),this}withConfig(t){const r=this.config();return new e(On(this,xn),{...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 ur(this,On(this,xn),On(this,En).stega,e,t,r)}getDocument(e,t){return cr(this,On(this,xn),e,t)}getDocuments(e,t){return lr(this,On(this,xn),e,t)}create(e,t){return gr(this,On(this,xn),e,"create",t)}createIfNotExists(e,t){return hr(this,On(this,xn),e,t)}createOrReplace(e,t){return dr(this,On(this,xn),e,t)}delete(e,t){return fr(this,On(this,xn),e,t)}mutate(e,t){return pr(this,On(this,xn),e,t)}patch(e,t){return new $t(e,t,this)}transaction(e){return new zt(e,this)}action(e,t){return yr(this,On(this,xn),e,t)}request(e){return br(this,On(this,xn),e)}getUrl(e,t){return Cr(this,e,t)}getDataUrl(e,t){return wr(this,e,t)}};var An,Pn;An=new WeakMap,Pn=new WeakMap;let In=class e{constructor(e,t=Kt){Tn(this,"assets"),Tn(this,"datasets"),Tn(this,"live"),Tn(this,"projects"),Tn(this,"users"),Tn(this,"observable"),jn(this,An,void 0),jn(this,Pn,void 0),Tn(this,"listen",Dr),this.config(t),$n(this,Pn,e),this.assets=new Pr(this,On(this,Pn)),this.datasets=new Zr(this,On(this,Pn)),this.live=new Wr(this),this.projects=new hn(this,On(this,Pn)),this.users=new Cn(this,On(this,Pn)),this.observable=new kn(e,t)}clone(){return new e(On(this,Pn),this.config())}config(e){if(void 0===e)return{...On(this,An)};if(On(this,An)&&!1===On(this,An).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),$n(this,An,tr(e,On(this,An)||{})),this}withConfig(t){const r=this.config();return new e(On(this,Pn),{...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 Le(ur(this,On(this,Pn),On(this,An).stega,e,t,r))}getDocument(e,t){return Le(cr(this,On(this,Pn),e,t))}getDocuments(e,t){return Le(lr(this,On(this,Pn),e,t))}create(e,t){return Le(gr(this,On(this,Pn),e,"create",t))}createIfNotExists(e,t){return Le(hr(this,On(this,Pn),e,t))}createOrReplace(e,t){return Le(dr(this,On(this,Pn),e,t))}delete(e,t){return Le(fr(this,On(this,Pn),e,t))}mutate(e,t){return Le(pr(this,On(this,Pn),e,t))}patch(e,t){return new At(e,t,this)}transaction(e){return new Lt(e,this)}action(e,t){return Le(yr(this,On(this,Pn),e,t))}request(e){return Le(br(this,On(this,Pn),e))}dataRequest(e,t,r){return Le(mr(this,On(this,Pn),e,t,r))}getUrl(e,t){return Cr(this,e,t)}getDataUrl(e,t){return wr(this,e,t)}};const Rn=function(e,t){const r=function(e){return P([K({shouldRetry:ht}),...e,lt,L(),W(),{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"))}},ct,B({implementation:ke})])}(e);return{requester:r,createClient:e=>new t(((t,n)=>(n||r)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,...t})),e)}}([],In),Mn=Rn.requester,Dn=Rn.createClient,Fn=(qn=Dn,function(e){return Yt(),qn(e)});var qn;const Nn=/_key\s*==\s*['"](.*)['"]/;function Un(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?Nn.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","'":"\\'","\\":"\\\\"},Wn={"\\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=>Wn[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=>Wn[e]));t.push(e)}return t}function Hn(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 Bn(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 Jn(e){return"object"==typeof e&&null!==e}function Gn(e,t,r=[]){return function(e){return null!==e&&Array.isArray(e)}(e)?e.map(((e,n)=>{if(Jn(e)){const o=e._key;if("string"==typeof o)return Gn(e,t,r.concat({_key:o,_index:n}))}return Gn(e,t,r.concat(n))})):Jn(e)?Object.fromEntries(Object.entries(e).map((([e,n])=>[e,Gn(n,t,r.concat(e))]))):t(e,r)}function Vn(e,t,r){return Gn(e,((e,n)=>{if("string"!=typeof e)return e;const o=Bn(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 Qn="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,h=function(e){return e.startsWith(Qn)?e.slice(Qn.length):e}(o),d=Array.isArray(i)?Un(Hn(i)):i,f=new URLSearchParams({baseUrl:t,id:h,type:s,path:d});c&&f.set("workspace",c),l&&f.set("tool",l),a&&f.set("projectId",a),u&&f.set("dataset",u),o.startsWith(Qn)&&f.set("isDraft","");const p=["/"===t?"":t];c&&p.push(c);const y=["mode=presentation",`id=${h}`,`type=${s}`,`path=${encodeURIComponent(d)}`];return l&&y.push(`tool=${l}`),p.push("intent","edit",`${y.join(";")}?${f}`),p.join("/")}const Yn=({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))||Zn(e)||Zn(t)||"string"==typeof o&&Kn.has(o))},Kn=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 Zn(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function eo(e,t,r){var n,o,s,i,a,u,c,l,h;const{filter:d,logger:f,enabled:p}=r;if(!p){const o="config.enabled must be true, don't call this function otherwise";throw null==(n=null==f?void 0:f.error)||n.call(f,`[@sanity/client]: ${o}`,{result:e,resultSourceMap:t,config:r}),new TypeError(o)}if(!t)return null==(o=null==f?void 0:f.error)||o.call(f,"[@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==f?void 0:f.error)||s.call(f,`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}const y={encoded:[],skipped:[]},m=Vn(e,t,(({sourcePath:e,sourceDocument:t,resultPath:n,value:o})=>{if(!1===("function"==typeof d?d({sourcePath:e,resultPath:n,filterDefault:Yn,sourceDocument:t,value:o}):Yn({sourcePath:e,resultPath:n,filterDefault:Yn,sourceDocument:t,value:o})))return f&&y.skipped.push({path:to(e),value:`${o.slice(0,20)}${o.length>20?"...":""}`,length:o.length}),o;f&&y.encoded.push({path:to(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:h}=t;return Ke(o,{origin:"sanity.io",href:Xn({baseUrl:s,workspace:i,tool:a,id:u,type:c,path:e,...!r.omitCrossDatasetReferenceData&&{dataset:h,projectId:l}})},!1)}));if(f){const e=y.skipped.length,t=y.encoded.length;if((e||t)&&(null==(i=(null==f?void 0:f.groupCollapsed)||f.log)||i("[@sanity/client]: Encoding source map into result"),null==(a=f.log)||a.call(f,`[@sanity/client]: Paths encoded: ${y.encoded.length}, skipped: ${y.skipped.length}`)),y.encoded.length>0&&(null==(u=null==f?void 0:f.log)||u.call(f,"[@sanity/client]: Table of encoded paths"),null==(c=(null==f?void 0:f.table)||f.log)||c(y.encoded)),y.skipped.length>0){const e=new Set;for(const{path:t}of y.skipped)e.add(t.replace(Nn,"0").replace(/\[\d+\]/g,"[]"));null==(l=null==f?void 0:f.log)||l.call(f,"[@sanity/client]: List of skipped paths",[...e.values()])}(e||t)&&(null==(h=null==f?void 0:f.groupEnd)||h.call(f))}return m}function to(e){return Un(Hn(e))}var ro=Object.freeze({__proto__:null,stegaEncodeSourceMap:eo}),no=Object.freeze({__proto__:null,encodeIntoResult:Vn,stegaEncodeSourceMap:eo,stegaEncodeSourceMap$1:ro}),oo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function so(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var io={exports:{}};
7
+ */;function N(e){return"[object Object]"===Object.prototype.toString.call(e)}const U=["boolean","string","number"];function L(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||q(t)||-1===U.indexOf(typeof t)&&!Array.isArray(t)&&!function(e){if(!1===N(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!(!1===N(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 W(e){return{onResponse:e=>{const r=e.headers["content-type"]||"",n=-1!==r.indexOf("application/json");return e.body&&r&&n?Object.assign({},e,{body:t(e.body)}):e},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 z={};typeof globalThis<"u"?z=globalThis:typeof window<"u"?z=window:typeof global<"u"?z=global:typeof self<"u"&&(z=self);var H=z;function B(e={}){const t=e.implementation||H.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())))}}var J=Object.defineProperty,G=(e,t,r)=>((e,t,r)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class V{constructor(e){G(this,"__CANCEL__",!0),G(this,"message"),this.message=e}toString(){return"Cancel"+(this.message?`: ${this.message}`:"")}}const Q=class{constructor(e){if(G(this,"promise"),G(this,"reason"),"function"!=typeof e)throw new TypeError("executor must be a function.");let t=null;this.promise=new Promise((e=>{t=e})),e((e=>{this.reason||(this.reason=new V(e),t(this.reason))}))}};G(Q,"source",(()=>{let e;return{token:new Q((t=>{e=t})),cancel:e}}));var X=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function Y(e){return 100*Math.pow(2,e)+100*Math.random()}const K=(e={})=>(e=>{const t=e.maxRetries||5,r=e.retryDelay||Y,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 h=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:c+1})});return setTimeout((()=>o.channels.request.publish(h)),a(c)),null}}})({shouldRetry:X,...e});K.shouldRetry=X;var Z=function(e,t){return Z=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])},Z(e,t)};function ee(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}Z(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function te(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 re(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 ne(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 oe(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 se(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 ie(e){return this instanceof ie?(this.v=e,this):new ie(e)}function ae(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 ie?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 ue(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=ne(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 ce(e){return"function"==typeof e}function le(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 he=le((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 de(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var fe=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=ne(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(ce(u))try{u()}catch(e){o=e instanceof he?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var l=ne(c),h=l.next();!h.done;h=l.next()){var d=h.value;try{ye(d)}catch(e){o=null!=o?o:[],e instanceof he?o=se(se([],oe(o)),oe(e.errors)):o.push(e)}}}catch(e){r={error:e}}finally{try{h&&!h.done&&(n=l.return)&&n.call(l)}finally{if(r)throw r.error}}}if(o)throw new he(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)ye(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)&&de(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&de(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function pe(e){return e instanceof fe||e&&"closed"in e&&ce(e.remove)&&ce(e.add)&&ce(e.unsubscribe)}function ye(e){ce(e)?e():e.unsubscribe()}fe.EMPTY;var me={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ge={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,se([e,t],oe(r)))},clearTimeout:function(e){var t=ge.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function ve(e){ge.setTimeout((function(){throw e}))}function be(){}var we=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,pe(t)&&t.add(r)):r.destination=_e,r}return ee(t,e),t.create=function(e,t,r){return new Se(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}(fe),Ce=Function.prototype.bind;function Ee(e,t){return Ce.call(e,t)}var xe=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){Te(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Te(e)}else Te(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Te(e)}},e}(),Se=function(e){function t(t,r,n){var o,s,i=e.call(this)||this;ce(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:i&&me.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&Ee(t.next,s),error:t.error&&Ee(t.error,s),complete:t.complete&&Ee(t.complete,s)}):o=t;return i.destination=new xe(o),i}return ee(t,e),t}(we);function Te(e){ve(e)}var _e={closed:!0,next:be,error:function(e){throw e},complete:be},Oe="function"==typeof Symbol&&Symbol.observable||"@@observable";function je(e){return e}function $e(e){return 0===e.length?je:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var ke=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 we||function(e){return e&&ce(e.next)&&ce(e.error)&&ce(e.complete)}(n)&&pe(n)?e:new Se(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=Ae(t))((function(t,n){var o=new Se({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[Oe]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return $e(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=Ae(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 Ae(e){var t;return null!==(t=null!=e?e:me.Promise)&&void 0!==t?t:Promise}function Pe(e){return function(t){if(function(e){return ce(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 Ie(e,t,r,n,o){return new Re(e,t,r,n,o)}var Re=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 ee(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}(we);var Me=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};var De="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Fe(e){if(e instanceof ke)return e;if(null!=e){if(function(e){return ce(e[Oe])}(e))return s=e,new ke((function(e){var t=s[Oe]();if(ce(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Me(e))return o=e,new ke((function(e){for(var t=0;t<o.length&&!e.closed;t++)e.next(o[t]);e.complete()}));if(ce(null==(n=e)?void 0:n.then))return r=e,new ke((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,ve)}));if(function(e){return Symbol.asyncIterator&&ce(null==e?void 0:e[Symbol.asyncIterator])}(e))return qe(e);if(function(e){return ce(null==e?void 0:e[De])}(e))return t=e,new ke((function(e){var r,n;try{for(var o=ne(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(function(e){return ce(null==e?void 0:e.getReader)}(e))return qe(function(e){return ae(this,arguments,(function(){var t,r,n;return re(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,ie(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,ie(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,ie(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]}}))}))}(e))}var t,r,n,o,s;throw function(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.")}(e)}function qe(e){return new ke((function(t){(function(e,t){var r,n,o,s;return te(this,void 0,void 0,(function(){var i,a;return re(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),r=ue(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 Ne(e,t){return Fe(e)}var Ue=le((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Le(e,t){return new Promise((function(t,r){var n,o=!1;e.subscribe({next:function(e){n=e,o=!0},error:r,complete:function(){o?t(n):r(new Ue)}})}))}function We(e,t){return Pe((function(r,n){var o=0;r.subscribe(Ie(n,(function(r){n.next(e.call(t,r,o++))})))}))}var ze=Array.isArray;function He(e){return We((function(t){return function(e,t){return ze(t)?e.apply(void 0,se([],oe(t))):e(t)}(e,t)}))}function Be(e,t,r){t()}var Je=Array.isArray;function Ge(e,t){return Pe((function(r,n){var o=0;r.subscribe(Ie(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function Ve(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return ce((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 $e(e)}(Ve.apply(void 0,se([],oe(e))),He(r)):Pe((function(t,r){var n,o;(n=se([t],oe(function(e){return 1===e.length&&Je(e[0])?e[0]:e}(e))),void 0===o&&(o=je),function(e){Be(0,(function(){for(var t=n.length,r=new Array(t),s=t,i=t,a=function(t){Be(0,(function(){var a=Ne(n[t]),u=!1;a.subscribe(Ie(e,(function(n){r[t]=n,u||(u=!0,i--),i||e.next(o(r.slice()))}),(function(){--s||e.complete()})))}))},u=0;u<t;u++)a(u)}))})(r)}))}var Qe={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},Xe={0:8203,1:8204,2:8205,3:65279},Ye=new Array(4).fill(String.fromCodePoint(Xe[0])).join("");function Ke(e,t,r="auto"){return!0===r||"auto"===r&&(function(e){return!(!Number.isNaN(Number(e))||/[a-z]/i.test(e)&&!/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(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`${Ye}${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(Xe[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(Xe).map((e=>e.reverse()))),Object.fromEntries(Object.entries(Qe).map((e=>e.reverse())));var Ze=`${Object.values(Qe).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,et=new RegExp(`[${Ze}]{4,}`,"gu");function tt(e){return e&&JSON.parse(function(e){var t;return{cleaned:e.replace(et,""),encoded:(null==(t=e.match(et))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}var rt=Object.defineProperty,nt=(e,t,r)=>(((e,t,r)=>{t in e?rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class ot extends Error{constructor(e){const t=it(e);super(t.message),nt(this,"response"),nt(this,"statusCode",400),nt(this,"responseBody"),nt(this,"details"),Object.assign(this,t)}}class st extends Error{constructor(e){const t=it(e);super(t.message),nt(this,"response"),nt(this,"statusCode",500),nt(this,"responseBody"),nt(this,"details"),Object.assign(this,t)}}function it(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:ut(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message=`${t.error} - ${t.message}`,r;if(function(e){return at(e)&&at(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)||function(e){return at(e)&&at(e.error)&&"actionError"===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 at(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ut(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const ct={onResponse:e=>{if(e.statusCode>=500)throw new st(e);if(e.statusCode>=400)throw new ot(e);return e}},lt={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};function ht(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)||K.shouldRetry(e,t,r)}function dt(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 ft=["image","file"],pt=["before","after","replace"],yt=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")},mt=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},gt=(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`)},vt=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);gt(e,t._id)},bt=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},wt=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 Ct,Et=Object.defineProperty,xt=(e,t,r)=>(((e,t,r)=>{t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),St=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Tt=(e,t,r)=>(St(e,t,"read from private field"),r?r.call(e):t.get(e)),_t=(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)},Ot=(e,t,r,n)=>(St(e,t,"write to private field"),t.set(e,r),r);class jt{constructor(e,t={}){xt(this,"selection"),xt(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 mt("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===pt.indexOf(e)){const e=pt.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{...dt(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return mt(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)}}Ct=new WeakMap;let $t=class e extends jt{constructor(e,t,r){super(e,t),_t(this,Ct,void 0),Ot(this,Ct,r)}clone(){return new e(this.selection,{...this.operations},Tt(this,Ct))}commit(e){if(!Tt(this,Ct))throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");const t="string"==typeof this.selection,r=Object.assign({returnFirst:t,returnDocuments:!0},e);return Tt(this,Ct).mutate({patch:this.serialize()},r)}};var kt;kt=new WeakMap;let At=class e extends jt{constructor(e,t,r){super(e,t),_t(this,kt,void 0),Ot(this,kt,r)}clone(){return new e(this.selection,{...this.operations},Tt(this,kt))}commit(e){if(!Tt(this,kt))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 Tt(this,kt).mutate({patch:this.serialize()},r)}};var Pt=Object.defineProperty,It=(e,t,r)=>(((e,t,r)=>{t in e?Pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),Rt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Mt=(e,t,r)=>(Rt(e,t,"read from private field"),r?r.call(e):t.get(e)),Dt=(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)},Ft=(e,t,r,n)=>(Rt(e,t,"write to private field"),t.set(e,r),r);const qt={returnDocuments:!1};class Nt{constructor(e=[],t){It(this,"operations"),It(this,"trxId"),this.operations=e,this.trxId=t}create(e){return mt("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return mt(t,e),vt(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return mt(t,e),vt(t,e),this._add({[t]:e})}delete(e){return gt("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 Ut;Ut=new WeakMap;let Lt=class e extends Nt{constructor(e,t,r){super(e,r),Dt(this,Ut,void 0),Ft(this,Ut,t)}clone(){return new e([...this.operations],Mt(this,Ut),this.trxId)}commit(e){if(!Mt(this,Ut))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Mt(this,Ut).mutate(this.serialize(),Object.assign({transactionId:this.trxId},qt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof At)return this._add({patch:e.serialize()});if(r){const r=t(new At(e,{},Mt(this,Ut)));if(!(r instanceof At))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 Wt;Wt=new WeakMap;let zt=class e extends Nt{constructor(e,t,r){super(e,r),Dt(this,Wt,void 0),Ft(this,Wt,t)}clone(){return new e([...this.operations],Mt(this,Wt),this.trxId)}commit(e){if(!Mt(this,Wt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Mt(this,Wt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},qt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof $t)return this._add({patch:e.serialize()});if(r){const r=t(new $t(e,{},Mt(this,Wt)));if(!(r instanceof $t))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 Ht(e){return"https://www.sanity.io/help/"+e}const Bt=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),Jt=Bt(["Because you set `withCredentials` to true, we will override your `useCdn`","setting to be false since (cookie-based) credentials are never set on the CDN"]),Gt=Bt(["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."]),Vt=Bt(["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."]),Qt=Bt(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${Ht("js-client-browser-token")} for more information and how to hide this warning.`]),Xt=Bt(["Using the Sanity client without specifying an API version is deprecated.",`See ${Ht("js-client-api-version")}`]),Yt=Bt(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),Kt={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},Zt=["localhost","127.0.0.1","0.0.0.0"];const er=function(e){switch(e){case"previewDrafts":case"published":case"raw":return;default:throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`")}},tr=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||Kt.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||Xt();const n={...Kt,...r},o=n.useProjectHostname;if(typeof Promise>"u"){const e=Ht("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&&er(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!==Zt.indexOf(e))(window.location.hostname);s&&i&&n.token&&!0!==n.ignoreBrowserTokenWarning?Qt():typeof n.useCdn>"u"&&Gt(),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&&yt(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?wt(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===Kt.apiHost,!0===n.useCdn&&n.withCredentials&&Jt(),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},rr="X-Sanity-Project-ID";const nr=({query:e,params:t={},options:r={}})=>{const n=new URLSearchParams,{tag:o,includeMutations:s,returnQuery:i,...a}=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(a))t&&n.append(e,`${t}`);return!1===i&&n.append("returnQuery","false"),!1===s&&n.append("includeMutations","false"),`?${n}`},or=(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},sr=e=>"response"===e.type,ir=e=>e.body,ar=11264;function ur(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?tt(o):o,u=!1===s.filterResponse?e=>e:e=>e.result,{cache:c,next:l,...h}={useAbortSignal:typeof s.signal<"u",resultSourceMap:i.enabled?"withKeyArraySelector":s.resultSourceMap,...s,returnQuery:!1===s.filterResponse&&!1!==s.returnQuery},d=mr(e,t,"query",{query:n,params:a},typeof c<"u"||typeof l<"u"?{...h,fetch:{cache:c,next:l}}:h);return i.enabled?d.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Ve.apply(void 0,se([],oe(e)))}(Ne(Promise.resolve().then((function(){return no})).then((function(e){return e.stegaEncodeSourceMap$1})).then((({stegaEncodeSourceMap:e})=>e)))),We((([e,t])=>{const r=t(e.result,e.resultSourceMap,i);return u({...e,result:r})}))):d.pipe(We(u))}function cr(e,t,r,n={}){return vr(e,t,{uri:wr(e,"doc",r),json:!0,tag:n.tag}).pipe(Ge(sr),We((e=>e.body.documents&&e.body.documents[0])))}function lr(e,t,r,n={}){return vr(e,t,{uri:wr(e,"doc",r.join(",")),json:!0,tag:n.tag}).pipe(Ge(sr),We((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 hr(e,t,r,n){return vt("createIfNotExists",r),gr(e,t,r,"createIfNotExists",n)}function dr(e,t,r,n){return vt("createOrReplace",r),gr(e,t,r,"createOrReplace",n)}function fr(e,t,r,n){return mr(e,t,"mutate",{mutations:[{delete:dt(r)}]},n)}function pr(e,t,r,n){let o;o=r instanceof At||r instanceof $t?{patch:r.serialize()}:r instanceof Lt||r instanceof zt?r.serialize():r;return mr(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function yr(e,t,r,n){return mr(e,t,"actions",{actions:Array.isArray(r)?r:[r],transactionId:n&&n.transactionId||void 0,skipCrossDatasetReferenceValidation:n&&n.skipCrossDatasetReferenceValidation||void 0,dryRun:n&&n.dryRun||void 0},n)}function mr(e,t,r,n,o={}){const s="mutate"===r,i="actions"===r,a="query"===r,u=s||i?"":nr(n),c=!s&&!i&&u.length<ar,l=c?u:"",h=o.returnFirst,{timeout:d,token:f,tag:p,headers:y,returnQuery:m,lastLiveEventId:g}=o;return vr(e,t,{method:c?"GET":"POST",uri:wr(e,r,l),json:!0,body:c?void 0:n,query:s&&or(o),timeout:d,headers:y,token:f,tag:p,returnQuery:m,perspective:o.perspective,resultSourceMap:o.resultSourceMap,lastLiveEventId:Array.isArray(g)?g[0]:g,canUseCdn:a,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(Ge(sr),We(ir),We((e=>{if(!s)return e;const t=e.results||[];if(o.returnDocuments)return h?t[0]&&t[0].document:t.map((e=>e.document));const r=h?"documentId":"documentIds",n=h?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function gr(e,t,r,n,o={}){return mr(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function vr(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:wt(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&&(er(t),r.query={perspective:t,...r.query},"previewDrafts"===t&&u&&(u=!1,Vt())),r.lastLiveEventId&&(r.query={...r.query,lastLiveEventId:r.lastLiveEventId}),!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[rr]=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:Cr(e,s,u)})),h=new ke((e=>t(l,i.requester).subscribe(e)));return r.signal?h.pipe((d=r.signal,e=>new ke((t=>{const r=()=>t.error(function(e){var t,r;if(Er)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}(d));if(d&&d.aborted)return void r();const n=e.subscribe(t);return d.addEventListener("abort",r),()=>{d.removeEventListener("abort",r),n.unsubscribe()}})))):h;var d}function br(e,t,r){return vr(e,t,r).pipe(Ge((e=>"response"===e.type)),We((e=>e.body)))}function wr(e,t,r){const n=e.config(),o=`/${t}/${bt(n)}`;return`/data${r?`${o}/${r}`:o}`.replace(/\/($|\?)/,"$1")}function Cr(e,t,r=!1){const{url:n,cdnUrl:o}=e.config();return`${r?o:n}/${t.replace(/^\//,"")}`}const Er=!!globalThis.DOMException;var xr,Sr,Tr,_r,Or=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},jr=(e,t,r)=>(Or(e,t,"read from private field"),r?r.call(e):t.get(e)),$r=(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)},kr=(e,t,r,n)=>(Or(e,t,"write to private field"),t.set(e,r),r);class Ar{constructor(e,t){$r(this,xr,void 0),$r(this,Sr,void 0),kr(this,xr,e),kr(this,Sr,t)}upload(e,t,r){return Ir(jr(this,xr),jr(this,Sr),e,t,r)}}xr=new WeakMap,Sr=new WeakMap;class Pr{constructor(e,t){$r(this,Tr,void 0),$r(this,_r,void 0),kr(this,Tr,e),kr(this,_r,t)}upload(e,t,r){return Le(Ir(jr(this,Tr),jr(this,_r),e,t,r).pipe(Ge((e=>"response"===e.type)),We((e=>e.body.document))))}}function Ir(e,t,r,n,o={}){(e=>{if(-1===ft.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${ft.join(", ")}`)})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=bt(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:h,description:d,creditLine:f,filename:p,source:y}=u,m={label:l,title:h,description:d,filename:p,meta:s,creditLine:f};return y&&(m.sourceId=y.id,m.sourceName=y.name,m.sourceUrl=y.url),vr(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})}Tr=new WeakMap,_r=new WeakMap;const Rr=["includePreviousRevision","includeResult","includeMutations","visibility","effectFormat","tag"],Mr={includeResult:!0};function Dr(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={...(h=r,d=Mr,Object.keys(d).concat(Object.keys(h)).reduce(((e,t)=>(e[t]=typeof h[t]>"u"?d[t]:h[t],e)),{})),tag:a},c=((e,t)=>t.reduce(((t,r)=>(typeof e[r]>"u"||(t[r]=e[r]),t)),{}))(u,Rr),l=`${n}${wr(this,"listen",nr({query:e,params:t,options:{tag:a,...c}}))}`;var h,d;if(l.length>14800)return new ke((e=>e.error(new Error("Query too large for listener"))));const f=u.events?u.events:["mutation"],p=-1!==f.indexOf("reconnect"),y={};return(o||s)&&(y.withCredentials=!0),o&&(y.headers={Authorization:`Bearer ${o}`}),new ke((e=>{let t,r,n=!1,o=!1;function s(){n||(p&&e.next({type:"reconnect"}),!n&&t.readyState===t.CLOSED&&(c(),clearTimeout(r),r=setTimeout(h,100)))}function i(t){e.error(function(e){if(e instanceof Error)return e;const t=Fr(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 a(t){const r=Fr(t);return r instanceof Error?e.error(r):e.next(r)}function u(){n=!0,c(),e.complete()}function c(){t&&(t.removeEventListener("error",s),t.removeEventListener("channelError",i),t.removeEventListener("disconnect",u),f.forEach((e=>t.removeEventListener(e,a))),t.close())}function h(){(async function(){const{default:e}=await Promise.resolve().then((function(){return uo}));if(o)return;const t=new e(l,y);return t.addEventListener("error",s),t.addEventListener("channelError",i),t.addEventListener("disconnect",u),f.forEach((e=>t.addEventListener(e,a))),t})().then((e=>{e&&(t=e,o&&c())})).catch((t=>{e.error(t),d()}))}function d(){n=!0,c(),o=!0}return h(),d}))}function Fr(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}var qr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Nr=(e,t,r)=>(qr(e,t,"read from private field"),r?r.call(e):t.get(e));const Ur="2021-03-26";var Lr;class Wr{constructor(e){var t,r,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)})(this,Lr,void 0),n=e,qr(t=this,r=Lr,"write to private field"),r.set(t,n)}events(){const e=Nr(this,Lr).config().apiVersion.replace(/^v/,"");if("X"!==e&&e<Ur)throw new Error(`The live events API requires API version ${Ur} or later. The current API version is ${e}. Please update your API version to use this feature.`);const t=wr(Nr(this,Lr),"live/events"),r=new URL(Nr(this,Lr).getUrl(t,!1)),n=["restart","message"];return new ke((e=>{let t,o,s=!1,i=!1;function a(r){if(!s){if("data"in r){const t=zr(r);e.error(new Error(t.message,{cause:t}))}t.readyState===t.CLOSED&&(c(),clearTimeout(o),o=setTimeout(l,100))}}function u(t){const r=zr(t);return r instanceof Error?e.error(r):e.next(r)}function c(){if(t){t.removeEventListener("error",a);for(const e of n)t.removeEventListener(e,u);t.close()}}function l(){(async function(){const e=typeof EventSource>"u"?(await Promise.resolve().then((function(){return uo}))).default:EventSource;if(i)return;const t=new e(r.toString());t.addEventListener("error",a);for(const e of n)t.addEventListener(e,u);return t})().then((e=>{e&&(t=e,i&&c())})).catch((t=>{e.error(t),h()}))}function h(){s=!0,c(),i=!0}return l(),h}))}}function zr(e){try{const t=e.data&&JSON.parse(e.data)||{};return{type:e.type,id:e.lastEventId,...t}}catch(e){return e}}Lr=new WeakMap;var Hr,Br,Jr,Gr,Vr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Qr=(e,t,r)=>(Vr(e,t,"read from private field"),r?r.call(e):t.get(e)),Xr=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Yr=(e,t,r,n)=>(Vr(e,t,"write to private field"),t.set(e,r),r);class Kr{constructor(e,t){Xr(this,Hr,void 0),Xr(this,Br,void 0),Yr(this,Hr,e),Yr(this,Br,t)}create(e,t){return en(Qr(this,Hr),Qr(this,Br),"PUT",e,t)}edit(e,t){return en(Qr(this,Hr),Qr(this,Br),"PATCH",e,t)}delete(e){return en(Qr(this,Hr),Qr(this,Br),"DELETE",e)}list(){return br(Qr(this,Hr),Qr(this,Br),{uri:"/datasets",tag:null})}}Hr=new WeakMap,Br=new WeakMap;class Zr{constructor(e,t){Xr(this,Jr,void 0),Xr(this,Gr,void 0),Yr(this,Jr,e),Yr(this,Gr,t)}create(e,t){return Le(en(Qr(this,Jr),Qr(this,Gr),"PUT",e,t))}edit(e,t){return Le(en(Qr(this,Jr),Qr(this,Gr),"PATCH",e,t))}delete(e){return Le(en(Qr(this,Jr),Qr(this,Gr),"DELETE",e))}list(){return Le(br(Qr(this,Jr),Qr(this,Gr),{uri:"/datasets",tag:null}))}}function en(e,t,r,n,o){return yt(n),br(e,t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}Jr=new WeakMap,Gr=new WeakMap;var tn,rn,nn,on,sn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},an=(e,t,r)=>(sn(e,t,"read from private field"),r?r.call(e):t.get(e)),un=(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)},cn=(e,t,r,n)=>(sn(e,t,"write to private field"),t.set(e,r),r);class ln{constructor(e,t){un(this,tn,void 0),un(this,rn,void 0),cn(this,tn,e),cn(this,rn,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return br(an(this,tn),an(this,rn),{uri:t})}getById(e){return br(an(this,tn),an(this,rn),{uri:`/projects/${e}`})}}tn=new WeakMap,rn=new WeakMap;class hn{constructor(e,t){un(this,nn,void 0),un(this,on,void 0),cn(this,nn,e),cn(this,on,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Le(br(an(this,nn),an(this,on),{uri:t}))}getById(e){return Le(br(an(this,nn),an(this,on),{uri:`/projects/${e}`}))}}nn=new WeakMap,on=new WeakMap;var dn,fn,pn,yn,mn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},gn=(e,t,r)=>(mn(e,t,"read from private field"),r?r.call(e):t.get(e)),vn=(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)},bn=(e,t,r,n)=>(mn(e,t,"write to private field"),t.set(e,r),r);class wn{constructor(e,t){vn(this,dn,void 0),vn(this,fn,void 0),bn(this,dn,e),bn(this,fn,t)}getById(e){return br(gn(this,dn),gn(this,fn),{uri:`/users/${e}`})}}dn=new WeakMap,fn=new WeakMap;class Cn{constructor(e,t){vn(this,pn,void 0),vn(this,yn,void 0),bn(this,pn,e),bn(this,yn,t)}getById(e){return Le(br(gn(this,pn),gn(this,yn),{uri:`/users/${e}`}))}}pn=new WeakMap,yn=new WeakMap;var En,xn,Sn=Object.defineProperty,Tn=(e,t,r)=>(((e,t,r)=>{t in e?Sn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),_n=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},On=(e,t,r)=>(_n(e,t,"read from private field"),r?r.call(e):t.get(e)),jn=(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)},$n=(e,t,r,n)=>(_n(e,t,"write to private field"),t.set(e,r),r);En=new WeakMap,xn=new WeakMap;let kn=class e{constructor(e,t=Kt){Tn(this,"assets"),Tn(this,"datasets"),Tn(this,"live"),Tn(this,"projects"),Tn(this,"users"),jn(this,En,void 0),jn(this,xn,void 0),Tn(this,"listen",Dr),this.config(t),$n(this,xn,e),this.assets=new Ar(this,On(this,xn)),this.datasets=new Kr(this,On(this,xn)),this.live=new Wr(this),this.projects=new ln(this,On(this,xn)),this.users=new wn(this,On(this,xn))}clone(){return new e(On(this,xn),this.config())}config(e){if(void 0===e)return{...On(this,En)};if(On(this,En)&&!1===On(this,En).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return $n(this,En,tr(e,On(this,En)||{})),this}withConfig(t){const r=this.config();return new e(On(this,xn),{...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 ur(this,On(this,xn),On(this,En).stega,e,t,r)}getDocument(e,t){return cr(this,On(this,xn),e,t)}getDocuments(e,t){return lr(this,On(this,xn),e,t)}create(e,t){return gr(this,On(this,xn),e,"create",t)}createIfNotExists(e,t){return hr(this,On(this,xn),e,t)}createOrReplace(e,t){return dr(this,On(this,xn),e,t)}delete(e,t){return fr(this,On(this,xn),e,t)}mutate(e,t){return pr(this,On(this,xn),e,t)}patch(e,t){return new $t(e,t,this)}transaction(e){return new zt(e,this)}action(e,t){return yr(this,On(this,xn),e,t)}request(e){return br(this,On(this,xn),e)}getUrl(e,t){return Cr(this,e,t)}getDataUrl(e,t){return wr(this,e,t)}};var An,Pn;An=new WeakMap,Pn=new WeakMap;let In=class e{constructor(e,t=Kt){Tn(this,"assets"),Tn(this,"datasets"),Tn(this,"live"),Tn(this,"projects"),Tn(this,"users"),Tn(this,"observable"),jn(this,An,void 0),jn(this,Pn,void 0),Tn(this,"listen",Dr),this.config(t),$n(this,Pn,e),this.assets=new Pr(this,On(this,Pn)),this.datasets=new Zr(this,On(this,Pn)),this.live=new Wr(this),this.projects=new hn(this,On(this,Pn)),this.users=new Cn(this,On(this,Pn)),this.observable=new kn(e,t)}clone(){return new e(On(this,Pn),this.config())}config(e){if(void 0===e)return{...On(this,An)};if(On(this,An)&&!1===On(this,An).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),$n(this,An,tr(e,On(this,An)||{})),this}withConfig(t){const r=this.config();return new e(On(this,Pn),{...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 Le(ur(this,On(this,Pn),On(this,An).stega,e,t,r))}getDocument(e,t){return Le(cr(this,On(this,Pn),e,t))}getDocuments(e,t){return Le(lr(this,On(this,Pn),e,t))}create(e,t){return Le(gr(this,On(this,Pn),e,"create",t))}createIfNotExists(e,t){return Le(hr(this,On(this,Pn),e,t))}createOrReplace(e,t){return Le(dr(this,On(this,Pn),e,t))}delete(e,t){return Le(fr(this,On(this,Pn),e,t))}mutate(e,t){return Le(pr(this,On(this,Pn),e,t))}patch(e,t){return new At(e,t,this)}transaction(e){return new Lt(e,this)}action(e,t){return Le(yr(this,On(this,Pn),e,t))}request(e){return Le(br(this,On(this,Pn),e))}dataRequest(e,t,r){return Le(mr(this,On(this,Pn),e,t,r))}getUrl(e,t){return Cr(this,e,t)}getDataUrl(e,t){return wr(this,e,t)}};const Rn=function(e,t){const r=function(e){return P([K({shouldRetry:ht}),...e,lt,L(),W(),{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"))}},ct,B({implementation:ke})])}(e);return{requester:r,createClient:e=>new t(((t,n)=>(n||r)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,...t})),e)}}([],In),Mn=Rn.requester,Dn=Rn.createClient,Fn=(qn=Dn,function(e){return Yt(),qn(e)});var qn;const Nn=/_key\s*==\s*['"](.*)['"]/;function Un(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?Nn.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","'":"\\'","\\":"\\\\"},Wn={"\\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=>Wn[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=>Wn[e]));t.push(e)}return t}function Hn(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 Bn(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 Jn(e){return"object"==typeof e&&null!==e}function Gn(e,t,r=[]){return function(e){return null!==e&&Array.isArray(e)}(e)?e.map(((e,n)=>{if(Jn(e)){const o=e._key;if("string"==typeof o)return Gn(e,t,r.concat({_key:o,_index:n}))}return Gn(e,t,r.concat(n))})):Jn(e)?Object.fromEntries(Object.entries(e).map((([e,n])=>[e,Gn(n,t,r.concat(e))]))):t(e,r)}function Vn(e,t,r){return Gn(e,((e,n)=>{if("string"!=typeof e)return e;const o=Bn(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 Qn="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,h=function(e){return e.startsWith(Qn)?e.slice(Qn.length):e}(o),d=Array.isArray(i)?Un(Hn(i)):i,f=new URLSearchParams({baseUrl:t,id:h,type:s,path:d});c&&f.set("workspace",c),l&&f.set("tool",l),a&&f.set("projectId",a),u&&f.set("dataset",u),o.startsWith(Qn)&&f.set("isDraft","");const p=["/"===t?"":t];c&&p.push(c);const y=["mode=presentation",`id=${h}`,`type=${s}`,`path=${encodeURIComponent(d)}`];return l&&y.push(`tool=${l}`),p.push("intent","edit",`${y.join(";")}?${f}`),p.join("/")}const Yn=({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))||Zn(e)||Zn(t)||"string"==typeof o&&Kn.has(o))},Kn=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 Zn(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function eo(e,t,r){var n,o,s,i,a,u,c,l,h;const{filter:d,logger:f,enabled:p}=r;if(!p){const o="config.enabled must be true, don't call this function otherwise";throw null==(n=null==f?void 0:f.error)||n.call(f,`[@sanity/client]: ${o}`,{result:e,resultSourceMap:t,config:r}),new TypeError(o)}if(!t)return null==(o=null==f?void 0:f.error)||o.call(f,"[@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==f?void 0:f.error)||s.call(f,`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}const y={encoded:[],skipped:[]},m=Vn(e,t,(({sourcePath:e,sourceDocument:t,resultPath:n,value:o})=>{if(!1===("function"==typeof d?d({sourcePath:e,resultPath:n,filterDefault:Yn,sourceDocument:t,value:o}):Yn({sourcePath:e,resultPath:n,filterDefault:Yn,sourceDocument:t,value:o})))return f&&y.skipped.push({path:to(e),value:`${o.slice(0,20)}${o.length>20?"...":""}`,length:o.length}),o;f&&y.encoded.push({path:to(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:h}=t;return Ke(o,{origin:"sanity.io",href:Xn({baseUrl:s,workspace:i,tool:a,id:u,type:c,path:e,...!r.omitCrossDatasetReferenceData&&{dataset:h,projectId:l}})},!1)}));if(f){const e=y.skipped.length,t=y.encoded.length;if((e||t)&&(null==(i=(null==f?void 0:f.groupCollapsed)||f.log)||i("[@sanity/client]: Encoding source map into result"),null==(a=f.log)||a.call(f,`[@sanity/client]: Paths encoded: ${y.encoded.length}, skipped: ${y.skipped.length}`)),y.encoded.length>0&&(null==(u=null==f?void 0:f.log)||u.call(f,"[@sanity/client]: Table of encoded paths"),null==(c=(null==f?void 0:f.table)||f.log)||c(y.encoded)),y.skipped.length>0){const e=new Set;for(const{path:t}of y.skipped)e.add(t.replace(Nn,"0").replace(/\[\d+\]/g,"[]"));null==(l=null==f?void 0:f.log)||l.call(f,"[@sanity/client]: List of skipped paths",[...e.values()])}(e||t)&&(null==(h=null==f?void 0:f.groupEnd)||h.call(f))}return m}function to(e){return Un(Hn(e))}var ro=Object.freeze({__proto__:null,stegaEncodeSourceMap:eo}),no=Object.freeze({__proto__:null,encodeIntoResult:Vn,stegaEncodeSourceMap:eo,stegaEncodeSourceMap$1:ro}),oo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function so(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var io={exports:{}};
8
8
  /** @license
9
9
  * eventsource.js
10
10
  * Available under MIT License (MIT)