@sanity/client 6.18.1 → 6.18.2

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.
@@ -266,20 +266,20 @@ function resolveStudioBaseRoute(studioUrl) {
266
266
  return baseUrl !== "/" && (baseUrl = baseUrl.replace(/\/$/, "")), typeof studioUrl == "string" ? { baseUrl } : { ...studioUrl, baseUrl };
267
267
  }
268
268
  export {
269
- DRAFTS_PREFIX as D,
270
- get as a,
271
- resolveEditInfo as b,
272
- createEditUrl as c,
273
- studioPath as d,
274
- jsonPathToStudioPath as e,
275
- resolveStudioBaseRoute as f,
276
- getPublishedId as g,
277
- reKeySegment as h,
278
- jsonPath as j,
279
- parseJsonPath as p,
280
- resolveMapping as r,
281
- studioPathToJsonPath as s,
282
- toString as t,
283
- walkMap as w
269
+ DRAFTS_PREFIX,
270
+ createEditUrl,
271
+ get,
272
+ getPublishedId,
273
+ jsonPath,
274
+ jsonPathToStudioPath,
275
+ parseJsonPath,
276
+ reKeySegment,
277
+ resolveEditInfo,
278
+ resolveMapping,
279
+ resolveStudioBaseRoute,
280
+ studioPath,
281
+ studioPathToJsonPath,
282
+ toString,
283
+ walkMap
284
284
  };
285
285
  //# sourceMappingURL=resolveEditInfo.js.map
@@ -38,7 +38,7 @@ function stegaClean(result) {
38
38
  const vercelStegaCleanAll = stegaClean;
39
39
  export {
40
40
  C,
41
- stegaClean as s,
42
- vercelStegaCleanAll as v
41
+ stegaClean,
42
+ vercelStegaCleanAll
43
43
  };
44
44
  //# sourceMappingURL=stegaClean.js.map
@@ -326,8 +326,8 @@ var stegaEncodeSourceMap$1 = /* @__PURE__ */ Object.freeze({
326
326
  stegaEncodeSourceMap
327
327
  });
328
328
  export {
329
- stegaEncodeSourceMap$1 as a,
330
- encodeIntoResult as e,
331
- stegaEncodeSourceMap as s
329
+ encodeIntoResult,
330
+ stegaEncodeSourceMap,
331
+ stegaEncodeSourceMap$1
332
332
  };
333
333
  //# sourceMappingURL=stegaEncodeSourceMap.js.map
package/dist/csm.js CHANGED
@@ -1,5 +1,5 @@
1
- import { w as walkMap, r as resolveMapping, p as parseJsonPath, t as toString, D as DRAFTS_PREFIX, g as getPublishedId, a as get, j as jsonPath, s as studioPathToJsonPath, b as resolveEditInfo, c as createEditUrl } from "./_chunks-es/resolveEditInfo.js";
2
- import { e, d } from "./_chunks-es/resolveEditInfo.js";
1
+ import { walkMap, resolveMapping, parseJsonPath, toString, DRAFTS_PREFIX, getPublishedId, get, jsonPath, studioPathToJsonPath, resolveEditInfo, createEditUrl } from "./_chunks-es/resolveEditInfo.js";
2
+ import { jsonPathToStudioPath, studioPath } from "./_chunks-es/resolveEditInfo.js";
3
3
  const defaultUpdateFunction = (changed) => changed;
4
4
  function applySourceDocuments(result, resultSourceMap, getCachedDocument, updateFn = defaultUpdateFunction, perspective = "raw") {
5
5
  if (!resultSourceMap)
@@ -58,13 +58,13 @@ export {
58
58
  createEditUrl,
59
59
  getPublishedId,
60
60
  jsonPath,
61
- e as jsonPathToStudioPath,
61
+ jsonPathToStudioPath,
62
62
  parseJsonPath,
63
63
  resolveEditInfo,
64
64
  resolveEditUrl,
65
65
  resolveMapping,
66
66
  resolvedKeyedSourcePath,
67
- d as studioPath,
67
+ studioPath,
68
68
  studioPathToJsonPath,
69
69
  walkMap
70
70
  };
@@ -3,7 +3,7 @@ import { adapter, environment } from "get-it";
3
3
  import { retry, jsonRequest, jsonResponse, progress, observable } from "get-it/middleware";
4
4
  import { Observable, from, lastValueFrom } from "rxjs";
5
5
  import { combineLatestWith, map, filter } from "rxjs/operators";
6
- import { s as stegaClean } from "./_chunks-es/stegaClean.js";
6
+ import { stegaClean } from "./_chunks-es/stegaClean.js";
7
7
  var __defProp$3 = Object.defineProperty, __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$3 = (obj, key, value) => (__defNormalProp$3(obj, typeof key != "symbol" ? key + "" : key, value), value);
8
8
  class ClientError extends Error {
9
9
  constructor(res) {
@@ -622,7 +622,7 @@ function _fetch(client, httpRequest, _stega, query, _params = {}, options = {})
622
622
  combineLatestWith(
623
623
  from(
624
624
  import("./_chunks-es/stegaEncodeSourceMap.js").then(function(n) {
625
- return n.a;
625
+ return n.stegaEncodeSourceMap$1;
626
626
  }).then(
627
627
  ({ stegaEncodeSourceMap }) => stegaEncodeSourceMap
628
628
  )
package/dist/index.cjs CHANGED
@@ -1502,7 +1502,7 @@ function defineDeprecatedCreateClient(createClient2) {
1502
1502
  return printNoDefaultExport(), createClient2(config);
1503
1503
  };
1504
1504
  }
1505
- var name = "@sanity/client", version = "6.18.1";
1505
+ var name = "@sanity/client", version = "6.18.2";
1506
1506
  const middleware = [
1507
1507
  middleware$1.debug({ verbose: !0, namespace: "sanity:client" }),
1508
1508
  middleware$1.headers({ "User-Agent": `${name} ${version}` }),
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { adapter, environment } from "get-it";
3
3
  import { retry, jsonRequest, jsonResponse, progress, observable, debug, headers, agent } from "get-it/middleware";
4
4
  import { Observable, from, lastValueFrom } from "rxjs";
5
5
  import { combineLatestWith, map, filter } from "rxjs/operators";
6
- import { s as stegaClean } from "./_chunks-es/stegaClean.js";
6
+ import { stegaClean } from "./_chunks-es/stegaClean.js";
7
7
  var __defProp$3 = Object.defineProperty, __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __publicField$3 = (obj, key, value) => (__defNormalProp$3(obj, typeof key != "symbol" ? key + "" : key, value), value);
8
8
  class ClientError extends Error {
9
9
  constructor(res) {
@@ -622,7 +622,7 @@ function _fetch(client, httpRequest, _stega, query, _params = {}, options = {})
622
622
  combineLatestWith(
623
623
  from(
624
624
  import("./_chunks-es/stegaEncodeSourceMap.js").then(function(n) {
625
- return n.a;
625
+ return n.stegaEncodeSourceMap$1;
626
626
  }).then(
627
627
  ({ stegaEncodeSourceMap }) => stegaEncodeSourceMap
628
628
  )
@@ -1485,7 +1485,7 @@ function defineDeprecatedCreateClient(createClient2) {
1485
1485
  return printNoDefaultExport(), createClient2(config);
1486
1486
  };
1487
1487
  }
1488
- var name = "@sanity/client", version = "6.18.1";
1488
+ var name = "@sanity/client", version = "6.18.2";
1489
1489
  const middleware = [
1490
1490
  debug({ verbose: !0, namespace: "sanity:client" }),
1491
1491
  headers({ "User-Agent": `${name} ${version}` }),
@@ -1,7 +1,7 @@
1
1
  import { SanityClient, ObservableSanityClient, requester as requester$1, createClient as createClient$1 } from "@sanity/client";
2
2
  export * from "@sanity/client";
3
- import { e, s } from "./_chunks-es/stegaEncodeSourceMap.js";
4
- import { s as s2, v } from "./_chunks-es/stegaClean.js";
3
+ import { encodeIntoResult, stegaEncodeSourceMap } from "./_chunks-es/stegaEncodeSourceMap.js";
4
+ import { stegaClean, vercelStegaCleanAll } from "./_chunks-es/stegaClean.js";
5
5
  class SanityStegaClient extends SanityClient {
6
6
  }
7
7
  class ObservableSanityStegaClient extends ObservableSanityClient {
@@ -11,10 +11,10 @@ export {
11
11
  ObservableSanityStegaClient,
12
12
  SanityStegaClient,
13
13
  createClient,
14
- e as encodeIntoResult,
14
+ encodeIntoResult,
15
15
  requester,
16
- s2 as stegaClean,
17
- s as stegaEncodeSourceMap,
18
- v as vercelStegaCleanAll
16
+ stegaClean,
17
+ stegaEncodeSourceMap,
18
+ vercelStegaCleanAll
19
19
  };
20
20
  //# sourceMappingURL=stega.browser.js.map
package/dist/stega.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { SanityClient, ObservableSanityClient, requester as requester$1, createClient as createClient$1 } from "@sanity/client";
2
2
  export * from "@sanity/client";
3
- import { e, s } from "./_chunks-es/stegaEncodeSourceMap.js";
4
- import { s as s2, v } from "./_chunks-es/stegaClean.js";
3
+ import { encodeIntoResult, stegaEncodeSourceMap } from "./_chunks-es/stegaEncodeSourceMap.js";
4
+ import { stegaClean, vercelStegaCleanAll } from "./_chunks-es/stegaClean.js";
5
5
  class SanityStegaClient extends SanityClient {
6
6
  }
7
7
  class ObservableSanityStegaClient extends ObservableSanityClient {
@@ -11,10 +11,10 @@ export {
11
11
  ObservableSanityStegaClient,
12
12
  SanityStegaClient,
13
13
  createClient,
14
- e as encodeIntoResult,
14
+ encodeIntoResult,
15
15
  requester,
16
- s2 as stegaClean,
17
- s as stegaEncodeSourceMap,
18
- v as vercelStegaCleanAll
16
+ stegaClean,
17
+ stegaEncodeSourceMap,
18
+ vercelStegaCleanAll
19
19
  };
20
20
  //# sourceMappingURL=stega.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/client",
3
- "version": "6.18.1",
3
+ "version": "6.18.2",
4
4
  "description": "Client for retrieving, creating and patching data from Sanity.io",
5
5
  "keywords": [
6
6
  "sanity",
@@ -118,7 +118,7 @@
118
118
  },
119
119
  "dependencies": {
120
120
  "@sanity/eventsource": "^5.0.2",
121
- "get-it": "^8.4.29",
121
+ "get-it": "^8.4.30",
122
122
  "rxjs": "^7.0.0"
123
123
  },
124
124
  "devDependencies": {
@@ -126,11 +126,11 @@
126
126
  "@edge-runtime/vm": "^3.2.0",
127
127
  "@rollup/plugin-commonjs": "^25.0.7",
128
128
  "@rollup/plugin-node-resolve": "^15.2.3",
129
- "@sanity/pkg-utils": "^6.8.14",
129
+ "@sanity/pkg-utils": "^6.8.15",
130
130
  "@types/json-diff": "^1.0.3",
131
131
  "@types/node": "^20.8.8",
132
- "@typescript-eslint/eslint-plugin": "^7.8.0",
133
- "@typescript-eslint/parser": "^7.8.0",
132
+ "@typescript-eslint/eslint-plugin": "^7.9.0",
133
+ "@typescript-eslint/parser": "^7.9.0",
134
134
  "@vercel/stega": "0.1.2",
135
135
  "@vitest/coverage-v8": "1.6.0",
136
136
  "eslint": "^8.57.0",
@@ -423,8 +423,8 @@
423
423
  enumerable: !0,
424
424
  configurable: !1,
425
425
  get: () => enableOverride !== null ? enableOverride : (namespacesCache !== createDebug.namespaces && (namespacesCache = createDebug.namespaces, enabledCache = createDebug.enabled(namespace)), enabledCache),
426
- set: (v2) => {
427
- enableOverride = v2;
426
+ set: (v) => {
427
+ enableOverride = v;
428
428
  }
429
429
  }), typeof createDebug.init == "function" && createDebug.init(debug2), debug2;
430
430
  }
@@ -595,9 +595,9 @@
595
595
  }
596
596
  module.exports = common(exports);
597
597
  const { formatters } = module.exports;
598
- formatters.j = function(v2) {
598
+ formatters.j = function(v) {
599
599
  try {
600
- return JSON.stringify(v2);
600
+ return JSON.stringify(v);
601
601
  } catch (error) {
602
602
  return "[UnexpectedJSONParseError]: " + error.message;
603
603
  }
@@ -2434,7 +2434,7 @@ ${selectionOpts}`);
2434
2434
  combineLatestWith(
2435
2435
  from(
2436
2436
  Promise.resolve().then(function () { return stegaEncodeSourceMap$2; }).then(function(n) {
2437
- return n.a;
2437
+ return n.stegaEncodeSourceMap$1;
2438
2438
  }).then(
2439
2439
  ({ stegaEncodeSourceMap }) => stegaEncodeSourceMap
2440
2440
  )
@@ -3629,9 +3629,9 @@ ${selectionOpts}`);
3629
3629
 
3630
3630
  var stegaEncodeSourceMap$2 = /*#__PURE__*/Object.freeze({
3631
3631
  __proto__: null,
3632
- a: stegaEncodeSourceMap$1,
3633
- e: encodeIntoResult,
3634
- s: stegaEncodeSourceMap
3632
+ encodeIntoResult: encodeIntoResult,
3633
+ stegaEncodeSourceMap: stegaEncodeSourceMap,
3634
+ stegaEncodeSourceMap$1: stegaEncodeSourceMap$1
3635
3635
  });
3636
3636
 
3637
3637
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Copyright (c) 2014-2017, Jon Schlinkert.
6
6
  * Released under the MIT License.
7
- */;function q(e){return"[object Object]"===Object.prototype.toString.call(e)}const N=["boolean","string","number"];function U(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||F(t)||-1===N.indexOf(typeof t)&&!Array.isArray(t)&&!function(e){if(!1===q(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!(!1===q(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 L(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 W={};typeof globalThis<"u"?W=globalThis:typeof window<"u"?W=window:typeof global<"u"?W=global:typeof self<"u"&&(W=self);var z=W;function H(e={}){const t=e.implementation||z.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 B=Object.defineProperty,J=(e,t,r)=>(((e,t,r)=>{t in e?B(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class G{constructor(e){J(this,"__CANCEL__",!0),J(this,"message"),this.message=e}toString(){return"Cancel"+(this.message?`: ${this.message}`:"")}}const V=class{constructor(e){if(J(this,"promise"),J(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 G(e),t(this.reason))}))}};J(V,"source",(()=>{let e;return{token:new V((t=>{e=t})),cancel:e}}));var Q=(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 X=(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:Q,...e});X.shouldRetry=Q;var K=function(e,t){return K=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])},K(e,t)};function Z(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}K(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function ee(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 te(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 re(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 ne(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 oe(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 se(e){return this instanceof se?(this.v=e,this):new se(e)}function ie(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 se?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 ae(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=re(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 ue(e){return"function"==typeof e}function ce(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 le=ce((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 he(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var de=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=re(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(ue(u))try{u()}catch(e){o=e instanceof le?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var l=re(c),h=l.next();!h.done;h=l.next()){var d=h.value;try{pe(d)}catch(e){o=null!=o?o:[],e instanceof le?o=oe(oe([],ne(o)),ne(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 le(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)pe(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)&&he(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&he(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function fe(e){return e instanceof de||e&&"closed"in e&&ue(e.remove)&&ue(e.add)&&ue(e.unsubscribe)}function pe(e){ue(e)?e():e.unsubscribe()}de.EMPTY;var ye={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},me={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,oe([e,t],ne(r)))},clearTimeout:function(e){var t=me.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function ge(e){me.setTimeout((function(){throw e}))}function ve(){}var be=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,fe(t)&&t.add(r)):r.destination=Te,r}return Z(t,e),t.create=function(e,t,r){return new xe(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}(de),we=Function.prototype.bind;function Ce(e,t){return we.call(e,t)}var Ee=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){Se(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Se(e)}else Se(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Se(e)}},e}(),xe=function(e){function t(t,r,n){var o,s,i=e.call(this)||this;ue(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:i&&ye.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&Ce(t.next,s),error:t.error&&Ce(t.error,s),complete:t.complete&&Ce(t.complete,s)}):o=t;return i.destination=new Ee(o),i}return Z(t,e),t}(be);function Se(e){ge(e)}var Te={closed:!0,next:ve,error:function(e){throw e},complete:ve},_e="function"==typeof Symbol&&Symbol.observable||"@@observable";function Oe(e){return e}function je(e){return 0===e.length?Oe:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var $e=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 be||function(e){return e&&ue(e.next)&&ue(e.error)&&ue(e.complete)}(n)&&fe(n)?e:new xe(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=ke(t))((function(t,n){var o=new xe({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[_e]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return je(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=ke(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 ke(e){var t;return null!==(t=null!=e?e:ye.Promise)&&void 0!==t?t:Promise}function Ae(e){return function(t){if(function(e){return ue(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 Pe(e,t,r,n,o){return new Ie(e,t,r,n,o)}var Ie=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 Z(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}(be);var Re=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};var Me="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function De(e){if(e instanceof $e)return e;if(null!=e){if(function(e){return ue(e[_e])}(e))return s=e,new $e((function(e){var t=s[_e]();if(ue(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Re(e))return o=e,new $e((function(e){for(var t=0;t<o.length&&!e.closed;t++)e.next(o[t]);e.complete()}));if(ue(null==(n=e)?void 0:n.then))return r=e,new $e((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,ge)}));if(function(e){return Symbol.asyncIterator&&ue(null==e?void 0:e[Symbol.asyncIterator])}(e))return Fe(e);if(function(e){return ue(null==e?void 0:e[Me])}(e))return t=e,new $e((function(e){var r,n;try{for(var o=re(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 ue(null==e?void 0:e.getReader)}(e))return Fe(function(e){return ie(this,arguments,(function(){var t,r,n;return te(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,se(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,se(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,se(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 Fe(e){return new $e((function(t){(function(e,t){var r,n,o,s;return ee(this,void 0,void 0,(function(){var i,a;return te(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),r=ae(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 qe(e,t){return De(e)}var Ne=ce((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Ue(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 Ne)}})}))}function Le(e,t){return Ae((function(r,n){var o=0;r.subscribe(Pe(n,(function(r){n.next(e.call(t,r,o++))})))}))}var We=Array.isArray;function ze(e){return Le((function(t){return function(e,t){return We(t)?e.apply(void 0,oe([],ne(t))):e(t)}(e,t)}))}function He(e,t,r){t()}var Be=Array.isArray;function Je(e,t){return Ae((function(r,n){var o=0;r.subscribe(Pe(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function Ge(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return ue((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 je(e)}(Ge.apply(void 0,oe([],ne(e))),ze(r)):Ae((function(t,r){var n,o;(n=oe([t],ne(function(e){return 1===e.length&&Be(e[0])?e[0]:e}(e))),void 0===o&&(o=Oe),function(e){He(0,(function(){for(var t=n.length,r=new Array(t),s=t,i=t,a=function(t){He(0,(function(){var a=qe(n[t]),u=!1;a.subscribe(Pe(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 Ve={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},Qe={0:8203,1:8204,2:8205,3:65279},Ye=new Array(4).fill(String.fromCodePoint(Qe[0])).join("");function Xe(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(Qe[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(Qe).map((e=>e.reverse()))),Object.fromEntries(Object.entries(Ve).map((e=>e.reverse())));var Ke=`${Object.values(Ve).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,Ze=new RegExp(`[${Ke}]{4,}`,"gu");function et(e){return e&&JSON.parse(function(e){var t;return{cleaned:e.replace(Ze,""),encoded:(null==(t=e.match(Ze))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}var tt=Object.defineProperty,rt=(e,t,r)=>(((e,t,r)=>{t in e?tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class nt extends Error{constructor(e){const t=st(e);super(t.message),rt(this,"response"),rt(this,"statusCode",400),rt(this,"responseBody"),rt(this,"details"),Object.assign(this,t)}}class ot extends Error{constructor(e){const t=st(e);super(t.message),rt(this,"response"),rt(this,"statusCode",500),rt(this,"responseBody"),rt(this,"details"),Object.assign(this,t)}}function st(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:at(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message=`${t.error} - ${t.message}`,r;if(function(e){return it(e)&&it(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)){const e=t.error.items||[],n=e.slice(0,5).map((e=>{var t;return null==(t=e.error)?void 0:t.description})).filter(Boolean);let o=n.length?`:\n- ${n.join("\n- ")}`:"";return e.length>5&&(o+=`\n...and ${e.length-5} more`),r.message=`${t.error.description}${o}`,r.details=t.error,r}return t.error&&t.error.description?(r.message=t.error.description,r.details=t.error,r):(r.message=t.error||t.message||function(e){const t=e.statusMessage?` ${e.statusMessage}`:"";return`${e.method}-request to ${e.url} resulted in HTTP ${e.statusCode}${t}`}(e),r)}function it(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function at(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const ut={onResponse:e=>{if(e.statusCode>=500)throw new ot(e);if(e.statusCode>=400)throw new nt(e);return e}},ct={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};function lt(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)||X.shouldRetry(e,t,r)}function ht(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 dt=["image","file"],ft=["before","after","replace"],pt=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")},yt=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},mt=(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`)},gt=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);mt(e,t._id)},vt=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},bt=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 wt,Ct=Object.defineProperty,Et=(e,t,r)=>(((e,t,r)=>{t in e?Ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),xt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},St=(e,t,r)=>(xt(e,t,"read from private field"),r?r.call(e):t.get(e)),Tt=(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)},_t=(e,t,r,n)=>(xt(e,t,"write to private field"),t.set(e,r),r);class Ot{constructor(e,t={}){Et(this,"selection"),Et(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 yt("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===ft.indexOf(e)){const e=ft.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{...ht(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return yt(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)}}wt=new WeakMap;let jt=class e extends Ot{constructor(e,t,r){super(e,t),Tt(this,wt,void 0),_t(this,wt,r)}clone(){return new e(this.selection,{...this.operations},St(this,wt))}commit(e){if(!St(this,wt))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 St(this,wt).mutate({patch:this.serialize()},r)}};var $t;$t=new WeakMap;let kt=class e extends Ot{constructor(e,t,r){super(e,t),Tt(this,$t,void 0),_t(this,$t,r)}clone(){return new e(this.selection,{...this.operations},St(this,$t))}commit(e){if(!St(this,$t))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 St(this,$t).mutate({patch:this.serialize()},r)}};var At=Object.defineProperty,Pt=(e,t,r)=>(((e,t,r)=>{t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),It=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Rt=(e,t,r)=>(It(e,t,"read from private field"),r?r.call(e):t.get(e)),Mt=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Dt=(e,t,r,n)=>(It(e,t,"write to private field"),t.set(e,r),r);const Ft={returnDocuments:!1};class qt{constructor(e=[],t){Pt(this,"operations"),Pt(this,"trxId"),this.operations=e,this.trxId=t}create(e){return yt("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return yt(t,e),gt(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return yt(t,e),gt(t,e),this._add({[t]:e})}delete(e){return mt("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 Nt;Nt=new WeakMap;let Ut=class e extends qt{constructor(e,t,r){super(e,r),Mt(this,Nt,void 0),Dt(this,Nt,t)}clone(){return new e([...this.operations],Rt(this,Nt),this.trxId)}commit(e){if(!Rt(this,Nt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Rt(this,Nt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Ft,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof kt)return this._add({patch:e.serialize()});if(r){const r=t(new kt(e,{},Rt(this,Nt)));if(!(r instanceof kt))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 Lt;Lt=new WeakMap;let Wt=class e extends qt{constructor(e,t,r){super(e,r),Mt(this,Lt,void 0),Dt(this,Lt,t)}clone(){return new e([...this.operations],Rt(this,Lt),this.trxId)}commit(e){if(!Rt(this,Lt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Rt(this,Lt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Ft,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof jt)return this._add({patch:e.serialize()});if(r){const r=t(new jt(e,{},Rt(this,Lt)));if(!(r instanceof jt))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 zt(e){return"https://www.sanity.io/help/"+e}const Ht=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),Bt=Ht(["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."]),Jt=Ht(["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."]),Gt=Ht(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${zt("js-client-browser-token")} for more information and how to hide this warning.`]),Vt=Ht(["Using the Sanity client without specifying an API version is deprecated.",`See ${zt("js-client-api-version")}`]),Qt=Ht(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),Yt={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},Xt=["localhost","127.0.0.1","0.0.0.0"];const Kt=function(e){switch(e){case"previewDrafts":case"published":case"raw":return;default:throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`")}},Zt=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||Yt.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||Vt();const n={...Yt,...r},o=n.useProjectHostname;if(typeof Promise>"u"){const e=zt("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&&Kt(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!==Xt.indexOf(e))(window.location.hostname);s&&i&&n.token&&!0!==n.ignoreBrowserTokenWarning?Gt():typeof n.useCdn>"u"&&Bt(),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&&pt(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?bt(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===Yt.apiHost,n.useCdn=!1!==n.useCdn&&!n.withCredentials,function(e){if("1"===e||"X"===e)return;const t=new Date(e);if(!(/^\d{4}-\d{2}-\d{2}$/.test(e)&&t instanceof Date&&t.getTime()>0))throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`")}(n.apiVersion);const a=n.apiHost.split("://",2),u=a[0],c=a[1],l=n.isDefaultApi?"apicdn.sanity.io":c;return n.useProjectHostname?(n.url=`${u}://${n.projectId}.${c}/v${n.apiVersion}`,n.cdnUrl=`${u}://${n.projectId}.${l}/v${n.apiVersion}`):(n.url=`${n.apiHost}/v${n.apiVersion}`,n.cdnUrl=n.url),n},er="X-Sanity-Project-ID";const tr=({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}`},rr=(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},nr=e=>"response"===e.type,or=e=>e.body,sr=11264;function ir(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?et(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=fr(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 Ge.apply(void 0,oe([],ne(e)))}(qe(Promise.resolve().then((function(){return Zn})).then((function(e){return e.a})).then((({stegaEncodeSourceMap:e})=>e)))),Le((([e,t])=>{const r=t(e.result,e.resultSourceMap,i);return u({...e,result:r})}))):d.pipe(Le(u))}function ar(e,t,r,n={}){return yr(e,t,{uri:gr(e,"doc",r),json:!0,tag:n.tag}).pipe(Je(nr),Le((e=>e.body.documents&&e.body.documents[0])))}function ur(e,t,r,n={}){return yr(e,t,{uri:gr(e,"doc",r.join(",")),json:!0,tag:n.tag}).pipe(Je(nr),Le((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 cr(e,t,r,n){return gt("createIfNotExists",r),pr(e,t,r,"createIfNotExists",n)}function lr(e,t,r,n){return gt("createOrReplace",r),pr(e,t,r,"createOrReplace",n)}function hr(e,t,r,n){return fr(e,t,"mutate",{mutations:[{delete:ht(r)}]},n)}function dr(e,t,r,n){let o;o=r instanceof kt||r instanceof jt?{patch:r.serialize()}:r instanceof Ut||r instanceof Wt?r.serialize():r;return fr(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function fr(e,t,r,n,o={}){const s="mutate"===r,i="query"===r,a=s?"":tr(n),u=!s&&a.length<sr,c=u?a:"",l=o.returnFirst,{timeout:h,token:d,tag:f,headers:p,returnQuery:y,lastLiveEventId:m}=o;return yr(e,t,{method:u?"GET":"POST",uri:gr(e,r,c),json:!0,body:u?void 0:n,query:s&&rr(o),timeout:h,headers:p,token:d,tag:f,returnQuery:y,perspective:o.perspective,resultSourceMap:o.resultSourceMap,lastLiveEventId:Array.isArray(m)?m[0]:m,canUseCdn:i,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(Je(nr),Le(or),Le((e=>{if(!s)return e;const t=e.results||[];if(o.returnDocuments)return l?t[0]&&t[0].document:t.map((e=>e.document));const r=l?"documentId":"documentIds",n=l?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function pr(e,t,r,n,o={}){return fr(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function yr(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:bt(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&&(Kt(t),r.query={perspective:t,...r.query},"previewDrafts"===t&&u&&(u=!1,Jt())),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[er]=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:vr(e,s,u)})),h=new $e((e=>t(l,i.requester).subscribe(e)));return r.signal?h.pipe((d=r.signal,e=>new $e((t=>{const r=()=>t.error(function(e){var t,r;if(br)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 mr(e,t,r){return yr(e,t,r).pipe(Je((e=>"response"===e.type)),Le((e=>e.body)))}function gr(e,t,r){const n=e.config(),o=`/${t}/${vt(n)}`;return`/data${r?`${o}/${r}`:o}`.replace(/\/($|\?)/,"$1")}function vr(e,t,r=!1){const{url:n,cdnUrl:o}=e.config();return`${r?o:n}/${t.replace(/^\//,"")}`}const br=!!globalThis.DOMException;var wr,Cr,Er,xr,Sr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Tr=(e,t,r)=>(Sr(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)},Or=(e,t,r,n)=>(Sr(e,t,"write to private field"),t.set(e,r),r);class jr{constructor(e,t){_r(this,wr,void 0),_r(this,Cr,void 0),Or(this,wr,e),Or(this,Cr,t)}upload(e,t,r){return kr(Tr(this,wr),Tr(this,Cr),e,t,r)}}wr=new WeakMap,Cr=new WeakMap;class $r{constructor(e,t){_r(this,Er,void 0),_r(this,xr,void 0),Or(this,Er,e),Or(this,xr,t)}upload(e,t,r){return Ue(kr(Tr(this,Er),Tr(this,xr),e,t,r).pipe(Je((e=>"response"===e.type)),Le((e=>e.body.document))))}}function kr(e,t,r,n,o={}){(e=>{if(-1===dt.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${dt.join(", ")}`)})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=vt(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),yr(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})}Er=new WeakMap,xr=new WeakMap;const Ar=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],Pr={includeResult:!0};function Ir(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=Pr,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,Ar),l=`${n}${gr(this,"listen",tr({query:e,params:t,options:{tag:a,...c}}))}`;var h,d;if(l.length>14800)return new $e((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 $e((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=Rr(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=Rr(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 oo}));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 Rr(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}var Mr,Dr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Fr=(e,t,r)=>(Dr(e,t,"read from private field"),r?r.call(e):t.get(e));class qr{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,Mr,void 0),n=e,Dr(t=this,r=Mr,"write to private field"),r.set(t,n)}events(){const e=gr(Fr(this,Mr),"live/events"),t=new URL(Fr(this,Mr).getUrl(e,!1)),r=["restart","message"];return new $e((e=>{let n,o,s=!1,i=!1;function a(t){if(!s){if("data"in t){const r=Nr(t);e.error(new Error(r.message,{cause:r}))}n.readyState===n.CLOSED&&(c(),clearTimeout(o),o=setTimeout(l,100))}}function u(t){const r=Nr(t);return r instanceof Error?e.error(r):e.next(r)}function c(){if(n){n.removeEventListener("error",a);for(const e of r)n.removeEventListener(e,u);n.close()}}function l(){(async function(){const e=typeof EventSource>"u"?(await Promise.resolve().then((function(){return oo}))).default:EventSource;if(i)return;const n=new e(t.toString());n.addEventListener("error",a);for(const e of r)n.addEventListener(e,u);return n})().then((e=>{e&&(n=e,i&&c())})).catch((t=>{e.error(t),h()}))}function h(){s=!0,c(),i=!0}return l(),h}))}}function Nr(e){try{const t=e.data&&JSON.parse(e.data)||{};return{type:e.type,id:e.lastEventId,...t}}catch(e){return e}}Mr=new WeakMap;var Ur,Lr,Wr,zr,Hr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Br=(e,t,r)=>(Hr(e,t,"read from private field"),r?r.call(e):t.get(e)),Jr=(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)},Gr=(e,t,r,n)=>(Hr(e,t,"write to private field"),t.set(e,r),r);class Vr{constructor(e,t){Jr(this,Ur,void 0),Jr(this,Lr,void 0),Gr(this,Ur,e),Gr(this,Lr,t)}create(e,t){return Yr(Br(this,Ur),Br(this,Lr),"PUT",e,t)}edit(e,t){return Yr(Br(this,Ur),Br(this,Lr),"PATCH",e,t)}delete(e){return Yr(Br(this,Ur),Br(this,Lr),"DELETE",e)}list(){return mr(Br(this,Ur),Br(this,Lr),{uri:"/datasets",tag:null})}}Ur=new WeakMap,Lr=new WeakMap;class Qr{constructor(e,t){Jr(this,Wr,void 0),Jr(this,zr,void 0),Gr(this,Wr,e),Gr(this,zr,t)}create(e,t){return Ue(Yr(Br(this,Wr),Br(this,zr),"PUT",e,t))}edit(e,t){return Ue(Yr(Br(this,Wr),Br(this,zr),"PATCH",e,t))}delete(e){return Ue(Yr(Br(this,Wr),Br(this,zr),"DELETE",e))}list(){return Ue(mr(Br(this,Wr),Br(this,zr),{uri:"/datasets",tag:null}))}}function Yr(e,t,r,n,o){return pt(n),mr(e,t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}Wr=new WeakMap,zr=new WeakMap;var Xr,Kr,Zr,en,tn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},rn=(e,t,r)=>(tn(e,t,"read from private field"),r?r.call(e):t.get(e)),nn=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},on=(e,t,r,n)=>(tn(e,t,"write to private field"),t.set(e,r),r);class sn{constructor(e,t){nn(this,Xr,void 0),nn(this,Kr,void 0),on(this,Xr,e),on(this,Kr,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return mr(rn(this,Xr),rn(this,Kr),{uri:t})}getById(e){return mr(rn(this,Xr),rn(this,Kr),{uri:`/projects/${e}`})}}Xr=new WeakMap,Kr=new WeakMap;class an{constructor(e,t){nn(this,Zr,void 0),nn(this,en,void 0),on(this,Zr,e),on(this,en,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Ue(mr(rn(this,Zr),rn(this,en),{uri:t}))}getById(e){return Ue(mr(rn(this,Zr),rn(this,en),{uri:`/projects/${e}`}))}}Zr=new WeakMap,en=new WeakMap;var un,cn,ln,hn,dn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},fn=(e,t,r)=>(dn(e,t,"read from private field"),r?r.call(e):t.get(e)),pn=(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)},yn=(e,t,r,n)=>(dn(e,t,"write to private field"),t.set(e,r),r);class mn{constructor(e,t){pn(this,un,void 0),pn(this,cn,void 0),yn(this,un,e),yn(this,cn,t)}getById(e){return mr(fn(this,un),fn(this,cn),{uri:`/users/${e}`})}}un=new WeakMap,cn=new WeakMap;class gn{constructor(e,t){pn(this,ln,void 0),pn(this,hn,void 0),yn(this,ln,e),yn(this,hn,t)}getById(e){return Ue(mr(fn(this,ln),fn(this,hn),{uri:`/users/${e}`}))}}ln=new WeakMap,hn=new WeakMap;var vn,bn,wn=Object.defineProperty,Cn=(e,t,r)=>(((e,t,r)=>{t in e?wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),En=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},xn=(e,t,r)=>(En(e,t,"read from private field"),r?r.call(e):t.get(e)),Sn=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Tn=(e,t,r,n)=>(En(e,t,"write to private field"),t.set(e,r),r);vn=new WeakMap,bn=new WeakMap;let _n=class e{constructor(e,t=Yt){Cn(this,"assets"),Cn(this,"datasets"),Cn(this,"live"),Cn(this,"projects"),Cn(this,"users"),Sn(this,vn,void 0),Sn(this,bn,void 0),Cn(this,"listen",Ir),this.config(t),Tn(this,bn,e),this.assets=new jr(this,xn(this,bn)),this.datasets=new Vr(this,xn(this,bn)),this.live=new qr(this),this.projects=new sn(this,xn(this,bn)),this.users=new mn(this,xn(this,bn))}clone(){return new e(xn(this,bn),this.config())}config(e){if(void 0===e)return{...xn(this,vn)};if(xn(this,vn)&&!1===xn(this,vn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return Tn(this,vn,Zt(e,xn(this,vn)||{})),this}withConfig(t){const r=this.config();return new e(xn(this,bn),{...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 ir(this,xn(this,bn),xn(this,vn).stega,e,t,r)}getDocument(e,t){return ar(this,xn(this,bn),e,t)}getDocuments(e,t){return ur(this,xn(this,bn),e,t)}create(e,t){return pr(this,xn(this,bn),e,"create",t)}createIfNotExists(e,t){return cr(this,xn(this,bn),e,t)}createOrReplace(e,t){return lr(this,xn(this,bn),e,t)}delete(e,t){return hr(this,xn(this,bn),e,t)}mutate(e,t){return dr(this,xn(this,bn),e,t)}patch(e,t){return new jt(e,t,this)}transaction(e){return new Wt(e,this)}request(e){return mr(this,xn(this,bn),e)}getUrl(e,t){return vr(this,e,t)}getDataUrl(e,t){return gr(this,e,t)}};var On,jn;On=new WeakMap,jn=new WeakMap;let $n=class e{constructor(e,t=Yt){Cn(this,"assets"),Cn(this,"datasets"),Cn(this,"live"),Cn(this,"projects"),Cn(this,"users"),Cn(this,"observable"),Sn(this,On,void 0),Sn(this,jn,void 0),Cn(this,"listen",Ir),this.config(t),Tn(this,jn,e),this.assets=new $r(this,xn(this,jn)),this.datasets=new Qr(this,xn(this,jn)),this.live=new qr(this),this.projects=new an(this,xn(this,jn)),this.users=new gn(this,xn(this,jn)),this.observable=new _n(e,t)}clone(){return new e(xn(this,jn),this.config())}config(e){if(void 0===e)return{...xn(this,On)};if(xn(this,On)&&!1===xn(this,On).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),Tn(this,On,Zt(e,xn(this,On)||{})),this}withConfig(t){const r=this.config();return new e(xn(this,jn),{...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 Ue(ir(this,xn(this,jn),xn(this,On).stega,e,t,r))}getDocument(e,t){return Ue(ar(this,xn(this,jn),e,t))}getDocuments(e,t){return Ue(ur(this,xn(this,jn),e,t))}create(e,t){return Ue(pr(this,xn(this,jn),e,"create",t))}createIfNotExists(e,t){return Ue(cr(this,xn(this,jn),e,t))}createOrReplace(e,t){return Ue(lr(this,xn(this,jn),e,t))}delete(e,t){return Ue(hr(this,xn(this,jn),e,t))}mutate(e,t){return Ue(dr(this,xn(this,jn),e,t))}patch(e,t){return new kt(e,t,this)}transaction(e){return new Ut(e,this)}request(e){return Ue(mr(this,xn(this,jn),e))}dataRequest(e,t,r){return Ue(fr(this,xn(this,jn),e,t,r))}getUrl(e,t){return vr(this,e,t)}getDataUrl(e,t){return gr(this,e,t)}};const kn=function(e,t){const r=function(e){return A([X({shouldRetry:lt}),...e,ct,U(),L(),{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"))}},ut,H({implementation:$e})])}(e);return{requester:r,createClient:e=>new t(((t,n)=>(n||r)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,...t})),e)}}([],$n),An=kn.requester,Pn=kn.createClient,In=(Rn=Pn,function(e){return Qt(),Rn(e)});var Rn;const Mn=/_key\s*==\s*['"](.*)['"]/;function Dn(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?Mn.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 Fn={"\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","\\":"\\\\"},qn={"\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t","\\'":"'","\\\\":"\\"};function Nn(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=>qn[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=>qn[e]));t.push(e)}return t}function Un(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 Ln(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=>Fn[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>Fn[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 Wn(e){return"object"==typeof e&&null!==e}function zn(e,t,r=[]){return function(e){return null!==e&&Array.isArray(e)}(e)?e.map(((e,n)=>{if(Wn(e)){const o=e._key;if("string"==typeof o)return zn(e,t,r.concat({_key:o,_index:n}))}return zn(e,t,r.concat(n))})):Wn(e)?Object.fromEntries(Object.entries(e).map((([e,n])=>[e,zn(n,t,r.concat(e))]))):t(e,r)}function Hn(e,t,r){return zn(e,((e,n)=>{if("string"!=typeof e)return e;const o=Ln(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=Nn(i),l=Nn(u).concat(n.slice(c.length));return r({sourcePath:l,sourceDocument:a,resultPath:n,value:e})}))}const Bn="drafts.";function Jn(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(Bn)?e.slice(Bn.length):e}(o),d=Array.isArray(i)?Dn(Un(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(Bn)&&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 Gn=({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))||Qn(e)||Qn(t)||"string"==typeof o&&Vn.has(o))},Vn=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 Qn(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function Yn(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=Hn(e,t,(({sourcePath:e,sourceDocument:t,resultPath:n,value:o})=>{if(!1===("function"==typeof d?d({sourcePath:e,resultPath:n,filterDefault:Gn,sourceDocument:t,value:o}):Gn({sourcePath:e,resultPath:n,filterDefault:Gn,sourceDocument:t,value:o})))return f&&y.skipped.push({path:Xn(e),value:`${o.slice(0,20)}${o.length>20?"...":""}`,length:o.length}),o;f&&y.encoded.push({path:Xn(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 Xe(o,{origin:"sanity.io",href:Jn({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(Mn,"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 Xn(e){return Dn(Un(e))}var Kn=Object.freeze({__proto__:null,stegaEncodeSourceMap:Yn}),Zn=Object.freeze({__proto__:null,a:Kn,e:Hn,s:Yn}),eo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function to(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ro={exports:{}};
7
+ */;function q(e){return"[object Object]"===Object.prototype.toString.call(e)}const N=["boolean","string","number"];function U(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||F(t)||-1===N.indexOf(typeof t)&&!Array.isArray(t)&&!function(e){if(!1===q(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!(!1===q(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 L(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 W={};typeof globalThis<"u"?W=globalThis:typeof window<"u"?W=window:typeof global<"u"?W=global:typeof self<"u"&&(W=self);var z=W;function H(e={}){const t=e.implementation||z.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 B=Object.defineProperty,J=(e,t,r)=>(((e,t,r)=>{t in e?B(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class G{constructor(e){J(this,"__CANCEL__",!0),J(this,"message"),this.message=e}toString(){return"Cancel"+(this.message?`: ${this.message}`:"")}}const V=class{constructor(e){if(J(this,"promise"),J(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 G(e),t(this.reason))}))}};J(V,"source",(()=>{let e;return{token:new V((t=>{e=t})),cancel:e}}));var Q=(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 X=(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:Q,...e});X.shouldRetry=Q;var K=function(e,t){return K=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])},K(e,t)};function Z(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}K(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function ee(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 te(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 re(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 ne(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 oe(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 se(e){return this instanceof se?(this.v=e,this):new se(e)}function ie(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 se?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 ae(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=re(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 ue(e){return"function"==typeof e}function ce(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 le=ce((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 he(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var de=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=re(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(ue(u))try{u()}catch(e){o=e instanceof le?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var l=re(c),h=l.next();!h.done;h=l.next()){var d=h.value;try{pe(d)}catch(e){o=null!=o?o:[],e instanceof le?o=oe(oe([],ne(o)),ne(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 le(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)pe(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)&&he(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&he(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function fe(e){return e instanceof de||e&&"closed"in e&&ue(e.remove)&&ue(e.add)&&ue(e.unsubscribe)}function pe(e){ue(e)?e():e.unsubscribe()}de.EMPTY;var ye={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},me={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,oe([e,t],ne(r)))},clearTimeout:function(e){var t=me.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function ge(e){me.setTimeout((function(){throw e}))}function ve(){}var be=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,fe(t)&&t.add(r)):r.destination=Te,r}return Z(t,e),t.create=function(e,t,r){return new xe(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}(de),we=Function.prototype.bind;function Ce(e,t){return we.call(e,t)}var Ee=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){Se(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Se(e)}else Se(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Se(e)}},e}(),xe=function(e){function t(t,r,n){var o,s,i=e.call(this)||this;ue(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:i&&ye.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&Ce(t.next,s),error:t.error&&Ce(t.error,s),complete:t.complete&&Ce(t.complete,s)}):o=t;return i.destination=new Ee(o),i}return Z(t,e),t}(be);function Se(e){ge(e)}var Te={closed:!0,next:ve,error:function(e){throw e},complete:ve},_e="function"==typeof Symbol&&Symbol.observable||"@@observable";function Oe(e){return e}function je(e){return 0===e.length?Oe:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var $e=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 be||function(e){return e&&ue(e.next)&&ue(e.error)&&ue(e.complete)}(n)&&fe(n)?e:new xe(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=ke(t))((function(t,n){var o=new xe({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[_e]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return je(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=ke(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 ke(e){var t;return null!==(t=null!=e?e:ye.Promise)&&void 0!==t?t:Promise}function Ae(e){return function(t){if(function(e){return ue(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 Pe(e,t,r,n,o){return new Ie(e,t,r,n,o)}var Ie=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 Z(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}(be);var Re=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};var Me="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function De(e){if(e instanceof $e)return e;if(null!=e){if(function(e){return ue(e[_e])}(e))return s=e,new $e((function(e){var t=s[_e]();if(ue(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Re(e))return o=e,new $e((function(e){for(var t=0;t<o.length&&!e.closed;t++)e.next(o[t]);e.complete()}));if(ue(null==(n=e)?void 0:n.then))return r=e,new $e((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,ge)}));if(function(e){return Symbol.asyncIterator&&ue(null==e?void 0:e[Symbol.asyncIterator])}(e))return Fe(e);if(function(e){return ue(null==e?void 0:e[Me])}(e))return t=e,new $e((function(e){var r,n;try{for(var o=re(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 ue(null==e?void 0:e.getReader)}(e))return Fe(function(e){return ie(this,arguments,(function(){var t,r,n;return te(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,se(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,se(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,se(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 Fe(e){return new $e((function(t){(function(e,t){var r,n,o,s;return ee(this,void 0,void 0,(function(){var i,a;return te(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),r=ae(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 qe(e,t){return De(e)}var Ne=ce((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function Ue(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 Ne)}})}))}function Le(e,t){return Ae((function(r,n){var o=0;r.subscribe(Pe(n,(function(r){n.next(e.call(t,r,o++))})))}))}var We=Array.isArray;function ze(e){return Le((function(t){return function(e,t){return We(t)?e.apply(void 0,oe([],ne(t))):e(t)}(e,t)}))}function He(e,t,r){t()}var Be=Array.isArray;function Je(e,t){return Ae((function(r,n){var o=0;r.subscribe(Pe(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function Ge(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return ue((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 je(e)}(Ge.apply(void 0,oe([],ne(e))),ze(r)):Ae((function(t,r){var n,o;(n=oe([t],ne(function(e){return 1===e.length&&Be(e[0])?e[0]:e}(e))),void 0===o&&(o=Oe),function(e){He(0,(function(){for(var t=n.length,r=new Array(t),s=t,i=t,a=function(t){He(0,(function(){var a=qe(n[t]),u=!1;a.subscribe(Pe(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 Ve={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},Qe={0:8203,1:8204,2:8205,3:65279},Ye=new Array(4).fill(String.fromCodePoint(Qe[0])).join("");function Xe(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(Qe[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(Qe).map((e=>e.reverse()))),Object.fromEntries(Object.entries(Ve).map((e=>e.reverse())));var Ke=`${Object.values(Ve).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,Ze=new RegExp(`[${Ke}]{4,}`,"gu");function et(e){return e&&JSON.parse(function(e){var t;return{cleaned:e.replace(Ze,""),encoded:(null==(t=e.match(Ze))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}var tt=Object.defineProperty,rt=(e,t,r)=>(((e,t,r)=>{t in e?tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class nt extends Error{constructor(e){const t=st(e);super(t.message),rt(this,"response"),rt(this,"statusCode",400),rt(this,"responseBody"),rt(this,"details"),Object.assign(this,t)}}class ot extends Error{constructor(e){const t=st(e);super(t.message),rt(this,"response"),rt(this,"statusCode",500),rt(this,"responseBody"),rt(this,"details"),Object.assign(this,t)}}function st(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:at(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message=`${t.error} - ${t.message}`,r;if(function(e){return it(e)&&it(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)){const e=t.error.items||[],n=e.slice(0,5).map((e=>{var t;return null==(t=e.error)?void 0:t.description})).filter(Boolean);let o=n.length?`:\n- ${n.join("\n- ")}`:"";return e.length>5&&(o+=`\n...and ${e.length-5} more`),r.message=`${t.error.description}${o}`,r.details=t.error,r}return t.error&&t.error.description?(r.message=t.error.description,r.details=t.error,r):(r.message=t.error||t.message||function(e){const t=e.statusMessage?` ${e.statusMessage}`:"";return`${e.method}-request to ${e.url} resulted in HTTP ${e.statusCode}${t}`}(e),r)}function it(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function at(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}const ut={onResponse:e=>{if(e.statusCode>=500)throw new ot(e);if(e.statusCode>=400)throw new nt(e);return e}},ct={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};function lt(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)||X.shouldRetry(e,t,r)}function ht(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 dt=["image","file"],ft=["before","after","replace"],pt=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")},yt=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},mt=(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`)},gt=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);mt(e,t._id)},vt=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},bt=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 wt,Ct=Object.defineProperty,Et=(e,t,r)=>(((e,t,r)=>{t in e?Ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),xt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},St=(e,t,r)=>(xt(e,t,"read from private field"),r?r.call(e):t.get(e)),Tt=(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)},_t=(e,t,r,n)=>(xt(e,t,"write to private field"),t.set(e,r),r);class Ot{constructor(e,t={}){Et(this,"selection"),Et(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 yt("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===ft.indexOf(e)){const e=ft.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{...ht(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return yt(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)}}wt=new WeakMap;let jt=class e extends Ot{constructor(e,t,r){super(e,t),Tt(this,wt,void 0),_t(this,wt,r)}clone(){return new e(this.selection,{...this.operations},St(this,wt))}commit(e){if(!St(this,wt))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 St(this,wt).mutate({patch:this.serialize()},r)}};var $t;$t=new WeakMap;let kt=class e extends Ot{constructor(e,t,r){super(e,t),Tt(this,$t,void 0),_t(this,$t,r)}clone(){return new e(this.selection,{...this.operations},St(this,$t))}commit(e){if(!St(this,$t))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 St(this,$t).mutate({patch:this.serialize()},r)}};var At=Object.defineProperty,Pt=(e,t,r)=>(((e,t,r)=>{t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),It=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Rt=(e,t,r)=>(It(e,t,"read from private field"),r?r.call(e):t.get(e)),Mt=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Dt=(e,t,r,n)=>(It(e,t,"write to private field"),t.set(e,r),r);const Ft={returnDocuments:!1};class qt{constructor(e=[],t){Pt(this,"operations"),Pt(this,"trxId"),this.operations=e,this.trxId=t}create(e){return yt("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return yt(t,e),gt(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return yt(t,e),gt(t,e),this._add({[t]:e})}delete(e){return mt("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 Nt;Nt=new WeakMap;let Ut=class e extends qt{constructor(e,t,r){super(e,r),Mt(this,Nt,void 0),Dt(this,Nt,t)}clone(){return new e([...this.operations],Rt(this,Nt),this.trxId)}commit(e){if(!Rt(this,Nt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Rt(this,Nt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Ft,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof kt)return this._add({patch:e.serialize()});if(r){const r=t(new kt(e,{},Rt(this,Nt)));if(!(r instanceof kt))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 Lt;Lt=new WeakMap;let Wt=class e extends qt{constructor(e,t,r){super(e,r),Mt(this,Lt,void 0),Dt(this,Lt,t)}clone(){return new e([...this.operations],Rt(this,Lt),this.trxId)}commit(e){if(!Rt(this,Lt))throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return Rt(this,Lt).mutate(this.serialize(),Object.assign({transactionId:this.trxId},Ft,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof jt)return this._add({patch:e.serialize()});if(r){const r=t(new jt(e,{},Rt(this,Lt)));if(!(r instanceof jt))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 zt(e){return"https://www.sanity.io/help/"+e}const Ht=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),Bt=Ht(["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."]),Jt=Ht(["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."]),Gt=Ht(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${zt("js-client-browser-token")} for more information and how to hide this warning.`]),Vt=Ht(["Using the Sanity client without specifying an API version is deprecated.",`See ${zt("js-client-api-version")}`]),Qt=Ht(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),Yt={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},Xt=["localhost","127.0.0.1","0.0.0.0"];const Kt=function(e){switch(e){case"previewDrafts":case"published":case"raw":return;default:throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`")}},Zt=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||Yt.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||Vt();const n={...Yt,...r},o=n.useProjectHostname;if(typeof Promise>"u"){const e=zt("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&&Kt(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!==Xt.indexOf(e))(window.location.hostname);s&&i&&n.token&&!0!==n.ignoreBrowserTokenWarning?Gt():typeof n.useCdn>"u"&&Bt(),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&&pt(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?bt(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===Yt.apiHost,n.useCdn=!1!==n.useCdn&&!n.withCredentials,function(e){if("1"===e||"X"===e)return;const t=new Date(e);if(!(/^\d{4}-\d{2}-\d{2}$/.test(e)&&t instanceof Date&&t.getTime()>0))throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`")}(n.apiVersion);const a=n.apiHost.split("://",2),u=a[0],c=a[1],l=n.isDefaultApi?"apicdn.sanity.io":c;return n.useProjectHostname?(n.url=`${u}://${n.projectId}.${c}/v${n.apiVersion}`,n.cdnUrl=`${u}://${n.projectId}.${l}/v${n.apiVersion}`):(n.url=`${n.apiHost}/v${n.apiVersion}`,n.cdnUrl=n.url),n},er="X-Sanity-Project-ID";const tr=({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}`},rr=(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},nr=e=>"response"===e.type,or=e=>e.body,sr=11264;function ir(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?et(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=fr(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 Ge.apply(void 0,oe([],ne(e)))}(qe(Promise.resolve().then((function(){return Zn})).then((function(e){return e.stegaEncodeSourceMap$1})).then((({stegaEncodeSourceMap:e})=>e)))),Le((([e,t])=>{const r=t(e.result,e.resultSourceMap,i);return u({...e,result:r})}))):d.pipe(Le(u))}function ar(e,t,r,n={}){return yr(e,t,{uri:gr(e,"doc",r),json:!0,tag:n.tag}).pipe(Je(nr),Le((e=>e.body.documents&&e.body.documents[0])))}function ur(e,t,r,n={}){return yr(e,t,{uri:gr(e,"doc",r.join(",")),json:!0,tag:n.tag}).pipe(Je(nr),Le((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 cr(e,t,r,n){return gt("createIfNotExists",r),pr(e,t,r,"createIfNotExists",n)}function lr(e,t,r,n){return gt("createOrReplace",r),pr(e,t,r,"createOrReplace",n)}function hr(e,t,r,n){return fr(e,t,"mutate",{mutations:[{delete:ht(r)}]},n)}function dr(e,t,r,n){let o;o=r instanceof kt||r instanceof jt?{patch:r.serialize()}:r instanceof Ut||r instanceof Wt?r.serialize():r;return fr(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function fr(e,t,r,n,o={}){const s="mutate"===r,i="query"===r,a=s?"":tr(n),u=!s&&a.length<sr,c=u?a:"",l=o.returnFirst,{timeout:h,token:d,tag:f,headers:p,returnQuery:y,lastLiveEventId:m}=o;return yr(e,t,{method:u?"GET":"POST",uri:gr(e,r,c),json:!0,body:u?void 0:n,query:s&&rr(o),timeout:h,headers:p,token:d,tag:f,returnQuery:y,perspective:o.perspective,resultSourceMap:o.resultSourceMap,lastLiveEventId:Array.isArray(m)?m[0]:m,canUseCdn:i,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(Je(nr),Le(or),Le((e=>{if(!s)return e;const t=e.results||[];if(o.returnDocuments)return l?t[0]&&t[0].document:t.map((e=>e.document));const r=l?"documentId":"documentIds",n=l?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function pr(e,t,r,n,o={}){return fr(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function yr(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:bt(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&&(Kt(t),r.query={perspective:t,...r.query},"previewDrafts"===t&&u&&(u=!1,Jt())),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[er]=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:vr(e,s,u)})),h=new $e((e=>t(l,i.requester).subscribe(e)));return r.signal?h.pipe((d=r.signal,e=>new $e((t=>{const r=()=>t.error(function(e){var t,r;if(br)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 mr(e,t,r){return yr(e,t,r).pipe(Je((e=>"response"===e.type)),Le((e=>e.body)))}function gr(e,t,r){const n=e.config(),o=`/${t}/${vt(n)}`;return`/data${r?`${o}/${r}`:o}`.replace(/\/($|\?)/,"$1")}function vr(e,t,r=!1){const{url:n,cdnUrl:o}=e.config();return`${r?o:n}/${t.replace(/^\//,"")}`}const br=!!globalThis.DOMException;var wr,Cr,Er,xr,Sr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Tr=(e,t,r)=>(Sr(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)},Or=(e,t,r,n)=>(Sr(e,t,"write to private field"),t.set(e,r),r);class jr{constructor(e,t){_r(this,wr,void 0),_r(this,Cr,void 0),Or(this,wr,e),Or(this,Cr,t)}upload(e,t,r){return kr(Tr(this,wr),Tr(this,Cr),e,t,r)}}wr=new WeakMap,Cr=new WeakMap;class $r{constructor(e,t){_r(this,Er,void 0),_r(this,xr,void 0),Or(this,Er,e),Or(this,xr,t)}upload(e,t,r){return Ue(kr(Tr(this,Er),Tr(this,xr),e,t,r).pipe(Je((e=>"response"===e.type)),Le((e=>e.body.document))))}}function kr(e,t,r,n,o={}){(e=>{if(-1===dt.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${dt.join(", ")}`)})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=vt(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),yr(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})}Er=new WeakMap,xr=new WeakMap;const Ar=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],Pr={includeResult:!0};function Ir(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=Pr,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,Ar),l=`${n}${gr(this,"listen",tr({query:e,params:t,options:{tag:a,...c}}))}`;var h,d;if(l.length>14800)return new $e((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 $e((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=Rr(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=Rr(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 oo}));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 Rr(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}var Mr,Dr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Fr=(e,t,r)=>(Dr(e,t,"read from private field"),r?r.call(e):t.get(e));class qr{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,Mr,void 0),n=e,Dr(t=this,r=Mr,"write to private field"),r.set(t,n)}events(){const e=gr(Fr(this,Mr),"live/events"),t=new URL(Fr(this,Mr).getUrl(e,!1)),r=["restart","message"];return new $e((e=>{let n,o,s=!1,i=!1;function a(t){if(!s){if("data"in t){const r=Nr(t);e.error(new Error(r.message,{cause:r}))}n.readyState===n.CLOSED&&(c(),clearTimeout(o),o=setTimeout(l,100))}}function u(t){const r=Nr(t);return r instanceof Error?e.error(r):e.next(r)}function c(){if(n){n.removeEventListener("error",a);for(const e of r)n.removeEventListener(e,u);n.close()}}function l(){(async function(){const e=typeof EventSource>"u"?(await Promise.resolve().then((function(){return oo}))).default:EventSource;if(i)return;const n=new e(t.toString());n.addEventListener("error",a);for(const e of r)n.addEventListener(e,u);return n})().then((e=>{e&&(n=e,i&&c())})).catch((t=>{e.error(t),h()}))}function h(){s=!0,c(),i=!0}return l(),h}))}}function Nr(e){try{const t=e.data&&JSON.parse(e.data)||{};return{type:e.type,id:e.lastEventId,...t}}catch(e){return e}}Mr=new WeakMap;var Ur,Lr,Wr,zr,Hr=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Br=(e,t,r)=>(Hr(e,t,"read from private field"),r?r.call(e):t.get(e)),Jr=(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)},Gr=(e,t,r,n)=>(Hr(e,t,"write to private field"),t.set(e,r),r);class Vr{constructor(e,t){Jr(this,Ur,void 0),Jr(this,Lr,void 0),Gr(this,Ur,e),Gr(this,Lr,t)}create(e,t){return Yr(Br(this,Ur),Br(this,Lr),"PUT",e,t)}edit(e,t){return Yr(Br(this,Ur),Br(this,Lr),"PATCH",e,t)}delete(e){return Yr(Br(this,Ur),Br(this,Lr),"DELETE",e)}list(){return mr(Br(this,Ur),Br(this,Lr),{uri:"/datasets",tag:null})}}Ur=new WeakMap,Lr=new WeakMap;class Qr{constructor(e,t){Jr(this,Wr,void 0),Jr(this,zr,void 0),Gr(this,Wr,e),Gr(this,zr,t)}create(e,t){return Ue(Yr(Br(this,Wr),Br(this,zr),"PUT",e,t))}edit(e,t){return Ue(Yr(Br(this,Wr),Br(this,zr),"PATCH",e,t))}delete(e){return Ue(Yr(Br(this,Wr),Br(this,zr),"DELETE",e))}list(){return Ue(mr(Br(this,Wr),Br(this,zr),{uri:"/datasets",tag:null}))}}function Yr(e,t,r,n,o){return pt(n),mr(e,t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}Wr=new WeakMap,zr=new WeakMap;var Xr,Kr,Zr,en,tn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},rn=(e,t,r)=>(tn(e,t,"read from private field"),r?r.call(e):t.get(e)),nn=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},on=(e,t,r,n)=>(tn(e,t,"write to private field"),t.set(e,r),r);class sn{constructor(e,t){nn(this,Xr,void 0),nn(this,Kr,void 0),on(this,Xr,e),on(this,Kr,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return mr(rn(this,Xr),rn(this,Kr),{uri:t})}getById(e){return mr(rn(this,Xr),rn(this,Kr),{uri:`/projects/${e}`})}}Xr=new WeakMap,Kr=new WeakMap;class an{constructor(e,t){nn(this,Zr,void 0),nn(this,en,void 0),on(this,Zr,e),on(this,en,t)}list(e){const t=!1===(null==e?void 0:e.includeMembers)?"/projects?includeMembers=false":"/projects";return Ue(mr(rn(this,Zr),rn(this,en),{uri:t}))}getById(e){return Ue(mr(rn(this,Zr),rn(this,en),{uri:`/projects/${e}`}))}}Zr=new WeakMap,en=new WeakMap;var un,cn,ln,hn,dn=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},fn=(e,t,r)=>(dn(e,t,"read from private field"),r?r.call(e):t.get(e)),pn=(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)},yn=(e,t,r,n)=>(dn(e,t,"write to private field"),t.set(e,r),r);class mn{constructor(e,t){pn(this,un,void 0),pn(this,cn,void 0),yn(this,un,e),yn(this,cn,t)}getById(e){return mr(fn(this,un),fn(this,cn),{uri:`/users/${e}`})}}un=new WeakMap,cn=new WeakMap;class gn{constructor(e,t){pn(this,ln,void 0),pn(this,hn,void 0),yn(this,ln,e),yn(this,hn,t)}getById(e){return Ue(mr(fn(this,ln),fn(this,hn),{uri:`/users/${e}`}))}}ln=new WeakMap,hn=new WeakMap;var vn,bn,wn=Object.defineProperty,Cn=(e,t,r)=>(((e,t,r)=>{t in e?wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),En=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},xn=(e,t,r)=>(En(e,t,"read from private field"),r?r.call(e):t.get(e)),Sn=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Tn=(e,t,r,n)=>(En(e,t,"write to private field"),t.set(e,r),r);vn=new WeakMap,bn=new WeakMap;let _n=class e{constructor(e,t=Yt){Cn(this,"assets"),Cn(this,"datasets"),Cn(this,"live"),Cn(this,"projects"),Cn(this,"users"),Sn(this,vn,void 0),Sn(this,bn,void 0),Cn(this,"listen",Ir),this.config(t),Tn(this,bn,e),this.assets=new jr(this,xn(this,bn)),this.datasets=new Vr(this,xn(this,bn)),this.live=new qr(this),this.projects=new sn(this,xn(this,bn)),this.users=new mn(this,xn(this,bn))}clone(){return new e(xn(this,bn),this.config())}config(e){if(void 0===e)return{...xn(this,vn)};if(xn(this,vn)&&!1===xn(this,vn).allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return Tn(this,vn,Zt(e,xn(this,vn)||{})),this}withConfig(t){const r=this.config();return new e(xn(this,bn),{...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 ir(this,xn(this,bn),xn(this,vn).stega,e,t,r)}getDocument(e,t){return ar(this,xn(this,bn),e,t)}getDocuments(e,t){return ur(this,xn(this,bn),e,t)}create(e,t){return pr(this,xn(this,bn),e,"create",t)}createIfNotExists(e,t){return cr(this,xn(this,bn),e,t)}createOrReplace(e,t){return lr(this,xn(this,bn),e,t)}delete(e,t){return hr(this,xn(this,bn),e,t)}mutate(e,t){return dr(this,xn(this,bn),e,t)}patch(e,t){return new jt(e,t,this)}transaction(e){return new Wt(e,this)}request(e){return mr(this,xn(this,bn),e)}getUrl(e,t){return vr(this,e,t)}getDataUrl(e,t){return gr(this,e,t)}};var On,jn;On=new WeakMap,jn=new WeakMap;let $n=class e{constructor(e,t=Yt){Cn(this,"assets"),Cn(this,"datasets"),Cn(this,"live"),Cn(this,"projects"),Cn(this,"users"),Cn(this,"observable"),Sn(this,On,void 0),Sn(this,jn,void 0),Cn(this,"listen",Ir),this.config(t),Tn(this,jn,e),this.assets=new $r(this,xn(this,jn)),this.datasets=new Qr(this,xn(this,jn)),this.live=new qr(this),this.projects=new an(this,xn(this,jn)),this.users=new gn(this,xn(this,jn)),this.observable=new _n(e,t)}clone(){return new e(xn(this,jn),this.config())}config(e){if(void 0===e)return{...xn(this,On)};if(xn(this,On)&&!1===xn(this,On).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),Tn(this,On,Zt(e,xn(this,On)||{})),this}withConfig(t){const r=this.config();return new e(xn(this,jn),{...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 Ue(ir(this,xn(this,jn),xn(this,On).stega,e,t,r))}getDocument(e,t){return Ue(ar(this,xn(this,jn),e,t))}getDocuments(e,t){return Ue(ur(this,xn(this,jn),e,t))}create(e,t){return Ue(pr(this,xn(this,jn),e,"create",t))}createIfNotExists(e,t){return Ue(cr(this,xn(this,jn),e,t))}createOrReplace(e,t){return Ue(lr(this,xn(this,jn),e,t))}delete(e,t){return Ue(hr(this,xn(this,jn),e,t))}mutate(e,t){return Ue(dr(this,xn(this,jn),e,t))}patch(e,t){return new kt(e,t,this)}transaction(e){return new Ut(e,this)}request(e){return Ue(mr(this,xn(this,jn),e))}dataRequest(e,t,r){return Ue(fr(this,xn(this,jn),e,t,r))}getUrl(e,t){return vr(this,e,t)}getDataUrl(e,t){return gr(this,e,t)}};const kn=function(e,t){const r=function(e){return A([X({shouldRetry:lt}),...e,ct,U(),L(),{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"))}},ut,H({implementation:$e})])}(e);return{requester:r,createClient:e=>new t(((t,n)=>(n||r)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,...t})),e)}}([],$n),An=kn.requester,Pn=kn.createClient,In=(Rn=Pn,function(e){return Qt(),Rn(e)});var Rn;const Mn=/_key\s*==\s*['"](.*)['"]/;function Dn(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?Mn.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 Fn={"\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","\\":"\\\\"},qn={"\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t","\\'":"'","\\\\":"\\"};function Nn(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=>qn[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=>qn[e]));t.push(e)}return t}function Un(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 Ln(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=>Fn[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>Fn[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 Wn(e){return"object"==typeof e&&null!==e}function zn(e,t,r=[]){return function(e){return null!==e&&Array.isArray(e)}(e)?e.map(((e,n)=>{if(Wn(e)){const o=e._key;if("string"==typeof o)return zn(e,t,r.concat({_key:o,_index:n}))}return zn(e,t,r.concat(n))})):Wn(e)?Object.fromEntries(Object.entries(e).map((([e,n])=>[e,zn(n,t,r.concat(e))]))):t(e,r)}function Hn(e,t,r){return zn(e,((e,n)=>{if("string"!=typeof e)return e;const o=Ln(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=Nn(i),l=Nn(u).concat(n.slice(c.length));return r({sourcePath:l,sourceDocument:a,resultPath:n,value:e})}))}const Bn="drafts.";function Jn(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(Bn)?e.slice(Bn.length):e}(o),d=Array.isArray(i)?Dn(Un(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(Bn)&&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 Gn=({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))||Qn(e)||Qn(t)||"string"==typeof o&&Vn.has(o))},Vn=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 Qn(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function Yn(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=Hn(e,t,(({sourcePath:e,sourceDocument:t,resultPath:n,value:o})=>{if(!1===("function"==typeof d?d({sourcePath:e,resultPath:n,filterDefault:Gn,sourceDocument:t,value:o}):Gn({sourcePath:e,resultPath:n,filterDefault:Gn,sourceDocument:t,value:o})))return f&&y.skipped.push({path:Xn(e),value:`${o.slice(0,20)}${o.length>20?"...":""}`,length:o.length}),o;f&&y.encoded.push({path:Xn(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 Xe(o,{origin:"sanity.io",href:Jn({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(Mn,"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 Xn(e){return Dn(Un(e))}var Kn=Object.freeze({__proto__:null,stegaEncodeSourceMap:Yn}),Zn=Object.freeze({__proto__:null,encodeIntoResult:Hn,stegaEncodeSourceMap:Yn,stegaEncodeSourceMap$1:Kn}),eo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function to(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ro={exports:{}};
8
8
  /** @license
9
9
  * eventsource.js
10
10
  * Available under MIT License (MIT)