@sanity/client 6.24.2 → 6.24.4

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.
@@ -1,6 +1,6 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SanityClient={})}(this,(function(e){"use strict";const t=!(typeof navigator>"u")&&"ReactNative"===navigator.product,r={timeout:t?6e4:12e4},n=function(e){const n={...r,..."string"==typeof e?{url:e}:e};if(n.timeout=s(n.timeout),n.query){const{url:e,searchParams:r}=function(e){const r=e.indexOf("?");if(-1===r)return{url:e,searchParams:new URLSearchParams};const n=e.slice(0,r),s=e.slice(r+1);if(!t)return{url:n,searchParams:new URLSearchParams(s)};if("function"!=typeof decodeURIComponent)throw new Error("Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined");const i=new URLSearchParams;for(const e of s.split("&")){const[t,r]=e.split("=");t&&i.append(o(t),o(r||""))}return{url:n,searchParams:i}}(n.url);for(const[t,o]of Object.entries(n.query)){if(void 0!==o)if(Array.isArray(o))for(const e of o)r.append(t,e);else r.append(t,o);const s=r.toString();s&&(n.url=`${e}?${s}`)}}return n.method=n.body&&!n.method?"POST":(n.method||"GET").toUpperCase(),n};function o(e){return decodeURIComponent(e.replace(/\+/g," "))}function s(e){if(!1===e||0===e)return!1;if(e.connect||e.socket)return e;const t=Number(e);return isNaN(t)?s(r.timeout):{connect:t,socket:t}}const i=/^https?:\/\//i,a=function(e){if(!i.test(e.url))throw new Error(`"${e.url}" is not a valid URL`)};function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const u=["request","response","progress","error","abort"],l=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function h(e,t){const r=[],o=l.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[n],validateOptions:[a]});function s(e){const r=u.reduce(((e,t)=>(e[t]=function(){const e=Object.create(null);let t=0;return{publish:function(t){for(const r in e)e[r](t)},subscribe:function(r){const n=t++;return e[n]=r,function(){delete e[n]}}}}(),e)),{}),n=(e=>function(t,r,...n){const o="onError"===t;let s=r;for(let r=0;r<e[t].length&&(s=(0,e[t][r])(s,...n),!o||s);r++);return s})(o),s=n("processOptions",e);n("validateOptions",s);const i={options:s,channels:r,applyMiddleware:n};let a;const c=r.request.subscribe((e=>{a=t(e,((t,o)=>((e,t,o)=>{let s=e,i=t;if(!s)try{i=n("onResponse",t,o)}catch(e){i=null,s=e}s=s&&n("onError",s,o),s?r.error.publish(s):i&&r.response.publish(i)})(t,o,e)))}));r.abort.subscribe((()=>{c(),a&&a.abort()}));const l=n("onReturn",r,i);return l===r&&r.request.publish(i),l}return s.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&o.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return l.forEach((t=>{e[t]&&o[t].push(e[t])})),r.push(e),s},s.clone=()=>h(r,t),e.forEach(s.use),s}var p=function(e){return e.replace(/^\s+|\s+$/g,"")},d=c((function(e){if(!e)return{};for(var t={},r=p(e).split("\n"),n=0;n<r.length;n++){var o=r[n],s=o.indexOf(":"),i=p(o.slice(0,s)).toLowerCase(),a=p(o.slice(s+1));typeof t[i]>"u"?t[i]=a:(c=t[i],"[object Array]"===Object.prototype.toString.call(c)?t[i].push(a):t[i]=[t[i],a])}var c;return t}));let f=class{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#n={};#o;#s={};#i;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#o=void 0}abort(){this.#o&&this.#o.abort()}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#n[e]=t}setInit(e,t=!0){this.#s=e,this.#i=t}send(e){const t="arraybuffer"!==this.responseType,r={...this.#s,method:this.#e,headers:this.#n,body:e};"function"==typeof AbortController&&this.#i&&(this.#o=new AbortController,typeof EventTarget<"u"&&this.#o.signal instanceof EventTarget&&(r.signal=this.#o.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.()})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.()}))}};const y="function"==typeof XMLHttpRequest?"xhr":"fetch",g="xhr"===y?XMLHttpRequest:f,m=(e,t)=>{const r=e.options,n=e.applyMiddleware("finalizeOptions",r),o={},s=e.applyMiddleware("interceptRequest",void 0,{adapter:y,context:e});if(s){const e=setTimeout(t,0,null,s);return{abort:()=>clearTimeout(e)}}let i=new g;i instanceof f&&"object"==typeof n.fetch&&i.setInit(n.fetch,n.useAbortSignal??!0);const a=n.headers,c=n.timeout;let u=!1,l=!1,h=!1;if(i.onerror=e=>{b(i instanceof f?e instanceof Error?e:new Error(`Request error while attempting to reach is ${n.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},i.ontimeout=e=>{b(new Error(`Request timeout while attempting to reach ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},i.onabort=()=>{m(!0),u=!0},i.onreadystatechange=()=>{c&&(m(),o.socket=setTimeout((()=>p("ESOCKETTIMEDOUT")),c.socket)),!u&&4===i.readyState&&0!==i.status&&function(){if(!(u||l||h)){if(0===i.status)return void b(new Error("Unknown XHR error"));m(),l=!0,t(null,{body:i.response||(""===i.responseType||"text"===i.responseType?i.responseText:""),url:n.url,method:n.method,headers:d(i.getAllResponseHeaders()),statusCode:i.status,statusMessage:i.statusText})}}()},i.open(n.method,n.url,!0),i.withCredentials=!!n.withCredentials,a&&i.setRequestHeader)for(const e in a)a.hasOwnProperty(e)&&i.setRequestHeader(e,a[e]);return n.rawBody&&(i.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:n,adapter:y,request:i,context:e}),i.send(n.body||null),c&&(o.connect=setTimeout((()=>p("ETIMEDOUT")),c.connect)),{abort:function(){u=!0,i&&i.abort()}};function p(t){h=!0,i.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${n.url}`:`Connection timed out on request to ${n.url}`);r.code=t,e.channels.error.publish(r)}function m(e){(e||u||i.readyState>=2&&o.connect)&&clearTimeout(o.connect),o.socket&&clearTimeout(o.socket)}function b(e){if(l)return;m(!0),l=!0,i=null;const r=e||new Error(`Network error while attempting to reach ${n.url}`);r.isNetworkError=!0,r.request=n,t(r)}},b=(e=[],t=m)=>h(e,t);var v,w,C={exports:{}};var E=function(e){function t(e){let n,o,s,i=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),s=o-(n||o);r.diff=s,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";i++;const s=t.formatters[o];if("function"==typeof s){const t=e[i];n=s.call(r,t),e.splice(i,1),i--}return n})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(o!==t.namespaces&&(o=t.namespaces,s=t.enabled(e)),s),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(typeof r>"u"?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=function(){if(w)return v;w=1;var e=1e3,t=60*e,r=60*t,n=24*r,o=7*n;function s(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}return v=function(i,a){a=a||{};var c,u,l=typeof i;if("string"===l&&i.length>0)return function(s){if(!((s=String(s)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(i){var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*o;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(i);if("number"===l&&isFinite(i))return a.long?(c=i,(u=Math.abs(c))>=n?s(c,u,n,"day"):u>=r?s(c,u,r,"hour"):u>=t?s(c,u,t,"minute"):u>=e?s(c,u,e,"second"):c+" ms"):function(o){var s=Math.abs(o);return s>=n?Math.round(o/n)+"d":s>=r?Math.round(o/r)+"h":s>=t?Math.round(o/t)+"m":s>=e?Math.round(o/e)+"s":o+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))}}(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!(!(typeof window<"u"&&window.process)||"renderer"!==window.process.type&&!window.process.__nwjs)||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=E(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(C,C.exports),c(C.exports);const x=typeof Buffer>"u"?()=>!1:e=>Buffer.isBuffer(e);function R(e){return"[object Object]"===Object.prototype.toString.call(e)}const S=["boolean","string","number"];function O(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||x(t)||-1===S.indexOf(typeof t)&&!Array.isArray(t)&&!function(e){if(!1===R(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!(!1===R(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 T(e){return{onResponse:r=>{const n=r.headers["content-type"]||"",o=e&&e.force||-1!==n.indexOf("application/json");return r.body&&n&&o?Object.assign({},r,{body:t(r.body)}):r},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message=`Failed to parsed response body as JSON: ${e.message}`,e}}}let _={};typeof globalThis<"u"?_=globalThis:typeof window<"u"?_=window:typeof global<"u"?_=global:typeof self<"u"&&(_=self);var q=_;function j(e={}){const t=e.implementation||q.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 A=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function $(e){return 100*Math.pow(2,e)+100*Math.random()}const I=(e={})=>(e=>{const t=e.maxRetries||5,r=e.retryDelay||$,n=e.shouldRetry;return{onError:(e,o)=>{const s=o.options,i=s.maxRetries||t,a=s.retryDelay||r,c=s.shouldRetry||n,u=s.attemptNumber||0;if(null!==(l=s.body)&&"object"==typeof l&&"function"==typeof l.pipe||!c(e,u,s)||u>=i)return e;var l;const h=Object.assign({},o,{options:Object.assign({},s,{attemptNumber:u+1})});return setTimeout((()=>o.channels.request.publish(h)),a(u)),null}}})({shouldRetry:A,...e});I.shouldRetry=A;var P=function(e,t){return P=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])},P(e,t)};function k(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}P(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function D(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((n=n.apply(e,t||[])).next())}))}function F(e,t){var r,n,o,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)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 s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}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,c])}}}function M(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 U(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 N(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 L(e){return this instanceof L?(this.v=e,this):new L(e)}function z(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),s=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,u)}})),n[Symbol.asyncIterator]=function(){return this},n;function i(e,t){o[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||a(e,t)}))},t&&(n[e]=t(n[e])))}function a(e,t){try{!function(e){e.value instanceof L?Promise.resolve(e.value.v).then(c,u):l(s[0][2],e)}(o[e](t))}catch(e){l(s[0][3],e)}}function c(e){a("next",e)}function u(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function H(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=M(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 B(e){return"function"==typeof e}function J(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 G=J((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 V(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var W=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=M(s),a=i.next();!a.done;a=i.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else s.remove(this);var c=this.initialTeardown;if(B(c))try{c()}catch(e){o=e instanceof G?e.errors:[e]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=M(u),h=l.next();!h.done;h=l.next()){var p=h.value;try{Q(p)}catch(e){o=null!=o?o:[],e instanceof G?o=N(N([],U(o)),U(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 G(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)Q(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)&&V(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&V(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function X(e){return e instanceof W||e&&"closed"in e&&B(e.remove)&&B(e.add)&&B(e.unsubscribe)}function Q(e){B(e)?e():e.unsubscribe()}W.EMPTY;var Y={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},K={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,N([e,t],U(r)))},clearTimeout:function(e){var t=K.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function Z(e){K.setTimeout((function(){throw e}))}function ee(){}var te=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,X(t)&&t.add(r)):r.destination=se,r}return k(t,e),t.create=function(e,t,r){return new ne(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}(W),re=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){oe(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){oe(e)}else oe(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){oe(e)}},e}(),ne=function(e){function t(t,r,n){var o,s=e.call(this)||this;return o=B(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,s.destination=new re(o),s}return k(t,e),t}(te);function oe(e){Z(e)}var se={closed:!0,next:ee,error:function(e){throw e},complete:ee},ie="function"==typeof Symbol&&Symbol.observable||"@@observable";function ae(e){return e}function ce(e){return 0===e.length?ae:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var ue=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 te||function(e){return e&&B(e.next)&&B(e.error)&&B(e.complete)}(n)&&X(n)?e:new ne(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=le(t))((function(t,n){var o=new ne({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[ie]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ce(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=le(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 le(e){var t;return null!==(t=null!=e?e:Y.Promise)&&void 0!==t?t:Promise}function he(e){return function(t){if(function(e){return B(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 de(e,t,r,n,o)}var de=function(e){function t(t,r,n,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return k(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(te);var fe="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function ye(e){if(e instanceof ue)return e;if(null!=e){if(function(e){return B(e[ie])}(e))return s=e,new ue((function(e){var t=s[ie]();if(B(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(function(e){return e&&"number"==typeof e.length&&"function"!=typeof e}(e))return o=e,new ue((function(e){for(var t=0;t<o.length&&!e.closed;t++)e.next(o[t]);e.complete()}));if(B(null==(n=e)?void 0:n.then))return r=e,new ue((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,Z)}));if(function(e){return Symbol.asyncIterator&&B(null==e?void 0:e[Symbol.asyncIterator])}(e))return ge(e);if(function(e){return B(null==e?void 0:e[fe])}(e))return t=e,new ue((function(e){var r,n;try{for(var o=M(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 B(null==e?void 0:e.getReader)}(e))return ge(function(e){return z(this,arguments,(function(){var t,r,n;return F(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,L(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,L(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,L(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 ge(e){return new ue((function(t){(function(e,t){var r,n,o,s;return D(this,void 0,void 0,(function(){var i,a;return F(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=H(e),c.label=1;case 1:return[4,r.next()];case 2:if((n=c.sent()).done)return[3,4];if(i=n.value,t.next(i),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),o={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(s=r.return)?[4,s.call(r)]:[3,8];case 7:c.sent(),c.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 me(e,t){return ye(e)}var be=J((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function ve(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 be)}})}))}function we(e,t){return he((function(r,n){var o=0;r.subscribe(pe(n,(function(r){n.next(e.call(t,r,o++))})))}))}var Ce=Array.isArray;function Ee(e){return we((function(t){return function(e,t){return Ce(t)?e.apply(void 0,N([],U(t))):e(t)}(e,t)}))}function xe(e,t,r){t()}var Re=Array.isArray;function Se(e,t){return he((function(r,n){var o=0;r.subscribe(pe(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function Oe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return B((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 ce(e)}(Oe.apply(void 0,N([],U(e))),Ee(r)):he((function(t,r){var n,o;(n=N([t],U(function(e){return 1===e.length&&Re(e[0])?e[0]:e}(e))),void 0===o&&(o=ae),function(e){xe(0,(function(){for(var t=n.length,r=new Array(t),s=t,i=t,a=function(t){xe(0,(function(){var a=me(n[t]),c=!1;a.subscribe(pe(e,(function(n){r[t]=n,c||(c=!0,i--),i||e.next(o(r.slice()))}),(function(){--s||e.complete()})))}))},c=0;c<t;c++)a(c)}))})(r)}))}var Te={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},_e={0:8203,1:8204,2:8205,3:65279},qe=new Array(4).fill(String.fromCodePoint(_e[0])).join("");function je(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`${qe}${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(_e[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(_e).map((e=>e.reverse()))),Object.fromEntries(Object.entries(Te).map((e=>e.reverse())));var Ae=`${Object.values(Te).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,$e=new RegExp(`[${Ae}]{4,}`,"gu");function Ie(e){return e&&JSON.parse(function(e){var t;return{cleaned:e.replace($e,""),encoded:(null==(t=e.match($e))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}class Pe extends Error{response;statusCode=400;responseBody;details;constructor(e){const t=De(e);super(t.message),Object.assign(this,t)}}class ke extends Error{response;statusCode=500;responseBody;details;constructor(e){const t=De(e);super(t.message),Object.assign(this,t)}}function De(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:Me(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message=`${t.error} - ${t.message}`,r;if(function(e){return Fe(e)&&Fe(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)||function(e){return Fe(e)&&Fe(e.error)&&"actionError"===e.error.type&&"string"==typeof e.error.description}(t)){const e=t.error.items||[],n=e.slice(0,5).map((e=>e.error?.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 Fe(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Me(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}class Ue extends Error{projectId;addOriginUrl;constructor({projectId:e}){super("CorsOriginError"),this.name="CorsOriginError",this.projectId=e;const t=new URL(`https://sanity.io/manage/project/${e}/api`);if(typeof location<"u"){const{origin:e}=location;t.searchParams.set("cors","add"),t.searchParams.set("origin",e),this.addOriginUrl=t,this.message=`The current origin is not allowed to connect to the Live Content API. Add it here: ${t}`}else this.message=`The current origin is not allowed to connect to the Live Content API. Change your configuration here: ${t}`}}const Ne={onResponse:e=>{if(e.statusCode>=500)throw new ke(e);if(e.statusCode>=400)throw new Pe(e);return e}},Le={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};function ze(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)||I.shouldRetry(e,t,r)}function He(e){return"https://www.sanity.io/help/"+e}const Be=["image","file"],Je=["before","after","replace"],Ge=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")},Ve=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},We=(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`)},Xe=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);We(e,t._id)},Qe=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},Ye=e=>{if("string"!=typeof e||!/^[a-z0-9._-]{1,75}$/i.test(e))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return e};const Ke=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),Ze=Ke(["Because you set `withCredentials` to true, we will override your `useCdn`","setting to be false since (cookie-based) credentials are never set on the CDN"]),et=Ke(["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."]),tt=Ke(["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."]),rt=Ke(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${He("js-client-browser-token")} for more information and how to hide this warning.`]),nt=Ke(["Using the Sanity client without specifying an API version is deprecated.",`See ${He("js-client-api-version")}`]),ot=Ke(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),st={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},it=["localhost","127.0.0.1","0.0.0.0"];function at(e){if(Array.isArray(e)){for(const t of e)if("published"!==t&&"drafts"!==t&&("string"!=typeof t||!t.startsWith("r")||"raw"===t))throw new TypeError("Invalid API perspective value, expected `published`, `drafts` or a valid release identifier string")}else switch(e){case"previewDrafts":case"drafts":case"published":case"raw":return;default:throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`")}}const ct=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||st.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||nt();const n={...st,...r},o=n.useProjectHostname;if(typeof Promise>"u"){const e=He("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(typeof n.perspective<"u"&&at(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!==it.indexOf(e))(window.location.hostname);s&&i&&n.token&&!0!==n.ignoreBrowserTokenWarning?rt():typeof n.useCdn>"u"&&et(),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&&Ge(n.dataset),"requestTagPrefix"in n&&(n.requestTagPrefix=n.requestTagPrefix?Ye(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===st.apiHost,!0===n.useCdn&&n.withCredentials&&Ze(),n.useCdn=!1!==n.useCdn&&!n.withCredentials,function(e){if("1"===e||"X"===e)return;const t=new Date(e);if(!(/^\d{4}-\d{2}-\d{2}$/.test(e)&&t instanceof Date&&t.getTime()>0))throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`")}(n.apiVersion);const a=n.apiHost.split("://",2),c=a[0],u=a[1],l=n.isDefaultApi?"apicdn.sanity.io":u;return n.useProjectHostname?(n.url=`${c}://${n.projectId}.${u}/v${n.apiVersion}`,n.cdnUrl=`${c}://${n.projectId}.${l}/v${n.apiVersion}`):(n.url=`${n.apiHost}/v${n.apiVersion}`,n.cdnUrl=n.url),n};function ut(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}`)}class lt{selection;operations;constructor(e,t={}){this.selection=e,this.operations=t}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return Ve("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===Je.indexOf(e)){const e=Je.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{...ut(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return Ve(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)}}class ht extends lt{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new ht(this.selection,{...this.operations},this.#a)}commit(e){if(!this.#a)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 this.#a.mutate({patch:this.serialize()},r)}}class pt extends lt{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new pt(this.selection,{...this.operations},this.#a)}commit(e){if(!this.#a)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 this.#a.mutate({patch:this.serialize()},r)}}const dt={returnDocuments:!1};class ft{operations;trxId;constructor(e=[],t){this.operations=e,this.trxId=t}create(e){return Ve("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return Ve(t,e),Xe(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return Ve(t,e),Xe(t,e),this._add({[t]:e})}delete(e){return We("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}}class yt extends ft{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new yt([...this.operations],this.#a,this.trxId)}commit(e){if(!this.#a)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.#a.mutate(this.serialize(),Object.assign({transactionId:this.trxId},dt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof pt)return this._add({patch:e.serialize()});if(r){const r=t(new pt(e,{},this.#a));if(!(r instanceof pt))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}}class gt extends ft{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new gt([...this.operations],this.#a,this.trxId)}commit(e){if(!this.#a)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.#a.mutate(this.serialize(),Object.assign({transactionId:this.trxId},dt,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof ht)return this._add({patch:e.serialize()});if(r){const r=t(new ht(e,{},this.#a));if(!(r instanceof ht))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}}const mt=({query:e,params:t={},options:r={}})=>{const n=new URLSearchParams,{tag:o,includeMutations:s,returnQuery:i,...a}=r;o&&n.append("tag",o),n.append("query",e);for(const[e,r]of Object.entries(t))n.append(`$${e}`,JSON.stringify(r));for(const[e,t]of Object.entries(a))t&&n.append(e,`${t}`);return!1===i&&n.append("returnQuery","false"),!1===s&&n.append("includeMutations","false"),`?${n}`},bt=(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},vt=e=>"response"===e.type,wt=e=>e.body;function Ct(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?Ie(o):o,c=!1===s.filterResponse?e=>e:e=>e.result,{cache:u,next:l,...h}={useAbortSignal:typeof s.signal<"u",resultSourceMap:i.enabled?"withKeyArraySelector":s.resultSourceMap,...s,returnQuery:!1===s.filterResponse&&!1!==s.returnQuery},p=qt(e,t,"query",{query:n,params:a},typeof u<"u"||typeof l<"u"?{...h,fetch:{cache:u,next:l}}:h);return i.enabled?p.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Oe.apply(void 0,N([],U(e)))}(me(Promise.resolve().then((function(){return Rr})).then((function(e){return e.stegaEncodeSourceMap$1})).then((({stegaEncodeSourceMap:e})=>e)))),we((([e,t])=>{const r=t(e.result,e.resultSourceMap,i);return c({...e,result:r})}))):p.pipe(we(c))}function Et(e,t,r,n={}){return At(e,t,{uri:It(e,"doc",r),json:!0,tag:n.tag,signal:n.signal}).pipe(Se(vt),we((e=>e.body.documents&&e.body.documents[0])))}function xt(e,t,r,n={}){return At(e,t,{uri:It(e,"doc",r.join(",")),json:!0,tag:n.tag,signal:n.signal}).pipe(Se(vt),we((e=>{const t=(n=e.body.documents||[],o=e=>e._id,n.reduce(((e,t)=>(e[o(t)]=t,e)),Object.create(null)));var n,o;return r.map((e=>t[e]||null))})))}function Rt(e,t,r,n){return Xe("createIfNotExists",r),jt(e,t,r,"createIfNotExists",n)}function St(e,t,r,n){return Xe("createOrReplace",r),jt(e,t,r,"createOrReplace",n)}function Ot(e,t,r,n){return qt(e,t,"mutate",{mutations:[{delete:ut(r)}]},n)}function Tt(e,t,r,n){let o;o=r instanceof pt||r instanceof ht?{patch:r.serialize()}:r instanceof yt||r instanceof gt?r.serialize():r;return qt(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function _t(e,t,r,n){return qt(e,t,"actions",{actions:Array.isArray(r)?r:[r],transactionId:n&&n.transactionId||void 0,skipCrossDatasetReferenceValidation:n&&n.skipCrossDatasetReferenceValidation||void 0,dryRun:n&&n.dryRun||void 0},n)}function qt(e,t,r,n,o={}){const s="mutate"===r,i="actions"===r,a="query"===r,c=s||i?"":mt(n),u=!s&&!i&&c.length<11264,l=u?c:"",h=o.returnFirst,{timeout:p,token:d,tag:f,headers:y,returnQuery:g,lastLiveEventId:m,cacheMode:b}=o;return At(e,t,{method:u?"GET":"POST",uri:It(e,r,l),json:!0,body:u?void 0:n,query:s&&bt(o),timeout:p,headers:y,token:d,tag:f,returnQuery:g,perspective:o.perspective,resultSourceMap:o.resultSourceMap,lastLiveEventId:Array.isArray(m)?m[0]:m,cacheMode:b,canUseCdn:a,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(Se(vt),we(wt),we((e=>{if(!s)return e;const t=e.results||[];if(o.returnDocuments)return h?t[0]&&t[0].document:t.map((e=>e.document));const r=h?"documentId":"documentIds",n=h?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function jt(e,t,r,n,o={}){return qt(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function At(e,t,r){const n=r.url||r.uri,o=e.config(),s=typeof r.canUseCdn>"u"?["GET","HEAD"].indexOf(r.method||"GET")>=0&&0===n.indexOf("/data/"):r.canUseCdn;let i=(r.useCdn??o.useCdn)&&s;const a=r.tag&&o.requestTagPrefix?[o.requestTagPrefix,r.tag].join("."):r.tag||o.requestTagPrefix;if(a&&null!==r.tag&&(r.query={tag:Ye(a),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&0===n.indexOf("/data/query/")){const e=r.resultSourceMap??o.resultSourceMap;void 0!==e&&!1!==e&&(r.query={resultSourceMap:e,...r.query});const t=r.perspective||o.perspective;typeof t<"u"&&(at(t),r.query={perspective:Array.isArray(t)?t.join(","):t,...r.query},"previewDrafts"===t&&i&&(i=!1,tt())),r.lastLiveEventId&&(r.query={...r.query,lastLiveEventId:r.lastLiveEventId}),!1===r.returnQuery&&(r.query={returnQuery:"false",...r.query}),i&&"noStale"==r.cacheMode&&(r.query={cacheMode:"noStale",...r.query})}const c=function(e,t={}){const r={},n=t.token||e.token;n&&(r.Authorization=`Bearer ${n}`),!t.useGlobalApi&&!e.useProjectHostname&&e.projectId&&(r["X-Sanity-Project-ID"]=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})}(o,Object.assign({},r,{url:Pt(e,n,i)})),u=new ue((e=>t(c,o.requester).subscribe(e)));return r.signal?u.pipe((l=r.signal,e=>new ue((t=>{const r=()=>t.error(function(e){if(kt)return new DOMException(e?.reason??"The operation was aborted.","AbortError");const t=new Error(e?.reason??"The operation was aborted.");return t.name="AbortError",t}(l));if(l&&l.aborted)return void r();const n=e.subscribe(t);return l.addEventListener("abort",r),()=>{l.removeEventListener("abort",r),n.unsubscribe()}})))):u;var l}function $t(e,t,r){return At(e,t,r).pipe(Se((e=>"response"===e.type)),we((e=>e.body)))}function It(e,t,r){const n=e.config(),o=`/${t}/${Qe(n)}`;return`/data${r?`${o}/${r}`:o}`.replace(/\/($|\?)/,"$1")}function Pt(e,t,r=!1){const{url:n,cdnUrl:o}=e.config();return`${r?o:n}/${t.replace(/^\//,"")}`}const kt=!!globalThis.DOMException;class Dt{#a;#c;constructor(e,t){this.#a=e,this.#c=t}upload(e,t,r){return Mt(this.#a,this.#c,e,t,r)}}class Ft{#a;#c;constructor(e,t){this.#a=e,this.#c=t}upload(e,t,r){return ve(Mt(this.#a,this.#c,e,t,r).pipe(Se((e=>"response"===e.type)),we((e=>e.body.document))))}}function Mt(e,t,r,n,o={}){(e=>{if(-1===Be.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${Be.join(", ")}`)})(r);let s=o.extract||void 0;s&&!s.length&&(s=["none"]);const i=Qe(e.config()),a="image"===r?"images":"files",c=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:u,label:l,title:h,description:p,creditLine:d,filename:f,source:y}=c,g={label:l,title:h,description:p,filename:f,meta:s,creditLine:d};return y&&(g.sourceId=y.id,g.sourceName=y.name,g.sourceUrl=y.url),At(e,t,{tag:u,method:"POST",timeout:c.timeout||0,uri:`/assets/${a}/${i}`,headers:c.contentType?{"Content-Type":c.contentType}:{},query:g,body:n})}const Ut=["includePreviousRevision","includeResult","includeMutations","visibility","effectFormat","tag"],Nt={includeResult:!0};function Lt(e,t,r={}){const{url:n,token:o,withCredentials:s,requestTagPrefix:i}=this.config(),a=r.tag&&i?[i,r.tag].join("."):r.tag,c={...(h=r,p=Nt,Object.keys(p).concat(Object.keys(h)).reduce(((e,t)=>(e[t]=typeof h[t]>"u"?p[t]:h[t],e)),{})),tag:a},u=((e,t)=>t.reduce(((t,r)=>(typeof e[r]>"u"||(t[r]=e[r]),t)),{}))(c,Ut),l=`${n}${It(this,"listen",mt({query:e,params:t,options:{tag:a,...u}}))}`;var h,p;if(l.length>14800)return new ue((e=>e.error(new Error("Query too large for listener"))));const d=c.events?c.events:["mutation"],f=-1!==d.indexOf("reconnect"),y={};return(o||s)&&(y.withCredentials=!0),o&&(y.headers={Authorization:`Bearer ${o}`}),new ue((e=>{let t,r,n=!1,o=!1;function s(){n||(f&&e.next({type:"reconnect"}),!n&&t.readyState===t.CLOSED&&(u(),clearTimeout(r),r=setTimeout(h,100)))}function i(t){e.error(function(e){if(e instanceof Error)return e;const t=zt(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=zt(t);return r instanceof Error?e.error(r):e.next(r)}function c(){n=!0,u(),e.complete()}function u(){t&&(t.removeEventListener("error",s),t.removeEventListener("channelError",i),t.removeEventListener("disconnect",c),d.forEach((e=>t.removeEventListener(e,a))),t.close())}function h(){(async function(){const{default:e}=await Promise.resolve().then((function(){return Pr}));if(o)return;const t=new e(l,y);return t.addEventListener("error",s),t.addEventListener("channelError",i),t.addEventListener("disconnect",c),d.forEach((e=>t.addEventListener(e,a))),t})().then((e=>{e&&(t=e,o&&u())})).catch((t=>{e.error(t),p()}))}function p(){n=!0,u(),o=!0}return h(),p}))}function zt(e){try{const t=e.data&&JSON.parse(e.data)||{};return Object.assign({type:e.type},t)}catch(e){return e}}const Ht="2021-03-26";class Bt{#a;constructor(e){this.#a=e}events({includeDrafts:e=!1,tag:t}={}){const{projectId:r,apiVersion:n,token:o,withCredentials:s,requestTagPrefix:i}=this.#a.config(),a=n.replace(/^v/,"");if("X"!==a&&a<Ht)throw new Error(`The live events API requires API version ${Ht} or later. The current API version is ${a}. Please update your API version to use this feature.`);if(e&&!o&&!s)throw new Error("The live events API requires a token or withCredentials when 'includeDrafts: true'. Please update your client configuration. The token should have the lowest possible access role.");if(e&&"X"!==a)throw new Error("The live events API requires API version X when 'includeDrafts: true'. This API is experimental and may change or even be removed.");const c=It(this.#a,"live/events"),u=new URL(this.#a.getUrl(c,!1)),l=t&&i?[i,t].join("."):t;l&&u.searchParams.set("tag",l),e&&u.searchParams.set("includeDrafts","true");const h=["restart","message","welcome","reconnect"],p={};return e&&o&&(p.headers={Authorization:`Bearer ${o}`}),e&&s&&(p.withCredentials=!0),new ue((e=>{let t,n,o=!1,s=!1;function i(r){if(!o){if("data"in r){const t=Jt(r);e.error(new Error(t.message,{cause:t}))}t.readyState===t.CLOSED&&(c(),clearTimeout(n),n=setTimeout(l,100))}}function a(t){const r=Jt(t);return r instanceof Error?e.error(r):e.next(r)}function c(){if(t){t.removeEventListener("error",i);for(const e of h)t.removeEventListener(e,a);t.close()}}function l(){(async function(){const e=typeof EventSource>"u"||p.headers||p.withCredentials?(await Promise.resolve().then((function(){return Pr}))).default:EventSource;if(s)return;try{if(await fetch(u,{method:"OPTIONS",mode:"cors",credentials:p.withCredentials?"include":"omit",headers:p.headers}),s)return}catch{throw new Ue({projectId:r})}const t=new e(u.toString(),p);t.addEventListener("error",i);for(const e of h)t.addEventListener(e,a);return t})().then((e=>{e&&(t=e,s&&c())})).catch((t=>{e.error(t),d()}))}function d(){o=!0,c(),s=!0}return l(),d}))}}function Jt(e){try{const t=e.data&&JSON.parse(e.data)||{};return{type:e.type,id:e.lastEventId,...t}}catch(e){return e}}class Gt{#a;#c;constructor(e,t){this.#a=e,this.#c=t}create(e,t){return Wt(this.#a,this.#c,"PUT",e,t)}edit(e,t){return Wt(this.#a,this.#c,"PATCH",e,t)}delete(e){return Wt(this.#a,this.#c,"DELETE",e)}list(){return $t(this.#a,this.#c,{uri:"/datasets",tag:null})}}class Vt{#a;#c;constructor(e,t){this.#a=e,this.#c=t}create(e,t){return ve(Wt(this.#a,this.#c,"PUT",e,t))}edit(e,t){return ve(Wt(this.#a,this.#c,"PATCH",e,t))}delete(e){return ve(Wt(this.#a,this.#c,"DELETE",e))}list(){return ve($t(this.#a,this.#c,{uri:"/datasets",tag:null}))}}function Wt(e,t,r,n,o){return Ge(n),$t(e,t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}class Xt{#a;#c;constructor(e,t){this.#a=e,this.#c=t}list(e){const t=!1===e?.includeMembers?"/projects?includeMembers=false":"/projects";return $t(this.#a,this.#c,{uri:t})}getById(e){return $t(this.#a,this.#c,{uri:`/projects/${e}`})}}class Qt{#a;#c;constructor(e,t){this.#a=e,this.#c=t}list(e){const t=!1===e?.includeMembers?"/projects?includeMembers=false":"/projects";return ve($t(this.#a,this.#c,{uri:t}))}getById(e){return ve($t(this.#a,this.#c,{uri:`/projects/${e}`}))}}class Yt{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getById(e){return $t(this.#a,this.#c,{uri:`/users/${e}`})}}class Kt{#a;#c;constructor(e,t){this.#a=e,this.#c=t}getById(e){return ve($t(this.#a,this.#c,{uri:`/users/${e}`}))}}class Zt{assets;datasets;live;projects;users;#u;#c;listen=Lt;constructor(e,t=st){this.config(t),this.#c=e,this.assets=new Dt(this,this.#c),this.datasets=new Gt(this,this.#c),this.live=new Bt(this),this.projects=new Xt(this,this.#c),this.users=new Yt(this,this.#c)}clone(){return new Zt(this.#c,this.config())}config(e){if(void 0===e)return{...this.#u};if(this.#u&&!1===this.#u.allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.#u=ct(e,this.#u||{}),this}withConfig(e){const t=this.config();return new Zt(this.#c,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return Ct(this,this.#c,this.#u.stega,e,t,r)}getDocument(e,t){return Et(this,this.#c,e,t)}getDocuments(e,t){return xt(this,this.#c,e,t)}create(e,t){return jt(this,this.#c,e,"create",t)}createIfNotExists(e,t){return Rt(this,this.#c,e,t)}createOrReplace(e,t){return St(this,this.#c,e,t)}delete(e,t){return Ot(this,this.#c,e,t)}mutate(e,t){return Tt(this,this.#c,e,t)}patch(e,t){return new ht(e,t,this)}transaction(e){return new gt(e,this)}action(e,t){return _t(this,this.#c,e,t)}request(e){return $t(this,this.#c,e)}getUrl(e,t){return Pt(this,e,t)}getDataUrl(e,t){return It(this,e,t)}}class er{assets;datasets;live;projects;users;observable;#u;#c;listen=Lt;constructor(e,t=st){this.config(t),this.#c=e,this.assets=new Ft(this,this.#c),this.datasets=new Vt(this,this.#c),this.live=new Bt(this),this.projects=new Qt(this,this.#c),this.users=new Kt(this,this.#c),this.observable=new Zt(e,t)}clone(){return new er(this.#c,this.config())}config(e){if(void 0===e)return{...this.#u};if(this.#u&&!1===this.#u.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),this.#u=ct(e,this.#u||{}),this}withConfig(e){const t=this.config();return new er(this.#c,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return ve(Ct(this,this.#c,this.#u.stega,e,t,r))}getDocument(e,t){return ve(Et(this,this.#c,e,t))}getDocuments(e,t){return ve(xt(this,this.#c,e,t))}create(e,t){return ve(jt(this,this.#c,e,"create",t))}createIfNotExists(e,t){return ve(Rt(this,this.#c,e,t))}createOrReplace(e,t){return ve(St(this,this.#c,e,t))}delete(e,t){return ve(Ot(this,this.#c,e,t))}mutate(e,t){return ve(Tt(this,this.#c,e,t))}patch(e,t){return new pt(e,t,this)}transaction(e){return new yt(e,this)}action(e,t){return ve(_t(this,this.#c,e,t))}request(e){return ve($t(this,this.#c,e))}dataRequest(e,t,r){return ve(qt(this,this.#c,e,t,r))}getUrl(e,t){return Pt(this,e,t)}getDataUrl(e,t){return It(this,e,t)}}const tr=function(e,t){const r=function(e){return b([I({shouldRetry:ze}),...e,Le,O(),T(),{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"))}},Ne,j({implementation:ue})])}(e);return{requester:r,createClient:e=>new t(((t,n)=>(n||r)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,...t})),e)}}([],er),rr=tr.requester,nr=tr.createClient,or=(sr=nr,function(e){return ot(),sr(e)});var sr;const ir=/_key\s*==\s*['"](.*)['"]/;function ar(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?ir.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 cr={"\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","\\":"\\\\"},ur={"\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t","\\'":"'","\\\\":"\\"};function lr(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=>ur[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=>ur[e]));t.push(e)}return t}function hr(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 pr(e,t){if(!t?.mappings)return;const r=function(e){return`$${e.map((e=>"string"==typeof e?`['${e.replace(/[\f\n\r\t'\\]/g,(e=>cr[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>cr[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 dr(e){return"object"==typeof e&&null!==e}function fr(e,t,r=[]){if(function(e){return null!==e&&Array.isArray(e)}(e))return e.map(((e,n)=>{if(dr(e)){const o=e._key;if("string"==typeof o)return fr(e,t,r.concat({_key:o,_index:n}))}return fr(e,t,r.concat(n))}));if(dr(e)){if("block"===e._type||"span"===e._type){const n={...e};return"block"===e._type?n.children=fr(e.children,t,r.concat("children")):"span"===e._type&&(n.text=fr(e.text,t,r.concat("text"))),n}return Object.fromEntries(Object.entries(e).map((([e,n])=>[e,fr(n,t,r.concat(e))])))}return t(e,r)}function yr(e,t,r){return fr(e,((e,n)=>{if("string"!=typeof e)return e;const o=pr(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],c=t.paths[s.source.path],u=lr(i),l=lr(c).concat(n.slice(u.length));return r({sourcePath:l,sourceDocument:a,resultPath:n,value:e})}))}const gr="drafts.";function mr(e){const{baseUrl:t,workspace:r="default",tool:n="default",id:o,type:s,path:i,projectId:a,dataset:c}=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 u="default"===r?void 0:r,l="default"===n?void 0:n,h=function(e){return e.startsWith(gr)?e.slice(7):e}(o),p=Array.isArray(i)?ar(hr(i)):i,d=new URLSearchParams({baseUrl:t,id:h,type:s,path:p});u&&d.set("workspace",u),l&&d.set("tool",l),a&&d.set("projectId",a),c&&d.set("dataset",c),o.startsWith(gr)&&d.set("isDraft","");const f=["/"===t?"":t];u&&f.push(u);const y=["mode=presentation",`id=${h}`,`type=${s}`,`path=${encodeURIComponent(p)}`];return l&&y.push(`tool=${l}`),f.push("intent","edit",`${y.join(";")}?${d}`),f.join("/")}const br=({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("_")||o.endsWith("Id"))||e.some((e=>"meta"===e||"metadata"===e||"openGraph"===e||"seo"===e))||wr(e)||wr(t)||"string"==typeof o&&vr.has(o))},vr=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","textTheme","unit","url","username","variant","website"]);function wr(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function Cr(e,t,r){const{filter:n,logger:o,enabled:s}=r;if(!s){const n="config.enabled must be true, don't call this function otherwise";throw o?.error?.(`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}if(!t)return o?.error?.("[@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 o?.error?.(`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}const i={encoded:[],skipped:[]},a=yr(e,t,(({sourcePath:e,sourceDocument:t,resultPath:s,value:a})=>{if(!1===("function"==typeof n?n({sourcePath:e,resultPath:s,filterDefault:br,sourceDocument:t,value:a}):br({sourcePath:e,resultPath:s,filterDefault:br,sourceDocument:t,value:a})))return o&&i.skipped.push({path:Er(e),value:`${a.slice(0,20)}${a.length>20?"...":""}`,length:a.length}),a;o&&i.encoded.push({path:Er(e),value:`${a.slice(0,20)}${a.length>20?"...":""}`,length:a.length});const{baseUrl:c,workspace:u,tool:l}=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(!c)return a;const{_id:h,_type:p,_projectId:d,_dataset:f}=t;return je(a,{origin:"sanity.io",href:mr({baseUrl:c,workspace:u,tool:l,id:h,type:p,path:e,...!r.omitCrossDatasetReferenceData&&{dataset:f,projectId:d}})},!1)}));if(o){const e=i.skipped.length,t=i.encoded.length;if((e||t)&&((o?.groupCollapsed||o.log)?.("[@sanity/client]: Encoding source map into result"),o.log?.(`[@sanity/client]: Paths encoded: ${i.encoded.length}, skipped: ${i.skipped.length}`)),i.encoded.length>0&&(o?.log?.("[@sanity/client]: Table of encoded paths"),(o?.table||o.log)?.(i.encoded)),i.skipped.length>0){const e=new Set;for(const{path:t}of i.skipped)e.add(t.replace(ir,"0").replace(/\[\d+\]/g,"[]"));o?.log?.("[@sanity/client]: List of skipped paths",[...e.values()])}(e||t)&&o?.groupEnd?.()}return a}function Er(e){return ar(hr(e))}var xr=Object.freeze({__proto__:null,stegaEncodeSourceMap:Cr}),Rr=Object.freeze({__proto__:null,encodeIntoResult:yr,stegaEncodeSourceMap:Cr,stegaEncodeSourceMap$1:xr});function Sr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Or,Tr,_r,qr={exports:{}},jr=qr.exports;
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SanityClient={})}(this,(function(e){"use strict";function t(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(e)}const r=!(typeof navigator>"u")&&"ReactNative"===navigator.product,n={timeout:r?6e4:12e4},o=function(e){const t={...n,..."string"==typeof e?{url:e}:e};if(t.timeout=s(t.timeout),t.query){const{url:e,searchParams:n}=function(e){const t=e.indexOf("?");if(-1===t)return{url:e,searchParams:new URLSearchParams};const n=e.slice(0,t),o=e.slice(t+1);if(!r)return{url:n,searchParams:new URLSearchParams(o)};if("function"!=typeof decodeURIComponent)throw new Error("Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined");const s=new URLSearchParams;for(const e of o.split("&")){const[t,r]=e.split("=");t&&s.append(i(t),i(r||""))}return{url:n,searchParams:s}}(t.url);for(const[r,o]of Object.entries(t.query)){if(void 0!==o)if(Array.isArray(o))for(const e of o)n.append(r,e);else n.append(r,o);const i=n.toString();i&&(t.url=`${e}?${i}`)}}return t.method=t.body&&!t.method?"POST":(t.method||"GET").toUpperCase(),t};function i(e){return decodeURIComponent(e.replace(/\+/g," "))}function s(e){if(!1===e||0===e)return!1;if(e.connect||e.socket)return e;const t=Number(e);return isNaN(t)?s(n.timeout):{connect:t,socket:t}}const a=/^https?:\/\//i,u=function(e){if(!a.test(e.url))throw new Error(`"${e.url}" is not a valid URL`)};function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const l=["request","response","progress","error","abort"],h=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function f(e,t){const r=[],n=h.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[o],validateOptions:[u]});function i(e){const r=l.reduce(((e,t)=>(e[t]=function(){const e=Object.create(null);let t=0;return{publish:function(t){for(const r in e)e[r](t)},subscribe:function(r){const n=t++;return e[n]=r,function(){delete e[n]}}}}(),e)),{}),o=(e=>function(t,r,...n){const o="onError"===t;let i=r;for(let r=0;r<e[t].length&&(i=(0,e[t][r])(i,...n),!o||i);r++);return i})(n),i=o("processOptions",e);o("validateOptions",i);const s={options:i,channels:r,applyMiddleware:o};let a;const u=r.request.subscribe((e=>{a=t(e,((t,n)=>((e,t,n)=>{let i=e,s=t;if(!i)try{s=o("onResponse",t,n)}catch(e){s=null,i=e}i=i&&o("onError",i,n),i?r.error.publish(i):s&&r.response.publish(s)})(t,n,e)))}));r.abort.subscribe((()=>{u(),a&&a.abort()}));const c=o("onReturn",r,s);return c===r&&r.request.publish(s),c}return i.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&n.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return h.forEach((t=>{e[t]&&n[t].push(e[t])})),r.push(e),i},i.clone=()=>f(r,t),e.forEach(i.use),i}var p,d,y=c(function(){if(d)return p;d=1;var e=function(e){return e.replace(/^\s+|\s+$/g,"")};return p=function(t){if(!t)return{};for(var r={},n=e(t).split("\n"),o=0;o<n.length;o++){var i=n[o],s=i.indexOf(":"),a=e(i.slice(0,s)).toLowerCase(),u=e(i.slice(s+1));typeof r[a]>"u"?r[a]=u:(c=r[a],"[object Array]"===Object.prototype.toString.call(c)?r[a].push(u):r[a]=[r[a],u])}var c;return r}}());let g=class{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#n={};#o;#i={};#s;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#o=void 0}abort(){this.#o&&this.#o.abort()}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#n[e]=t}setInit(e,t=!0){this.#i=e,this.#s=t}send(e){const t="arraybuffer"!==this.responseType,r={...this.#i,method:this.#e,headers:this.#n,body:e};"function"==typeof AbortController&&this.#s&&(this.#o=new AbortController,typeof EventTarget<"u"&&this.#o.signal instanceof EventTarget&&(r.signal=this.#o.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.()})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.()}))}};const v="function"==typeof XMLHttpRequest?"xhr":"fetch",b="xhr"===v?XMLHttpRequest:g,m=(e,t)=>{const r=e.options,n=e.applyMiddleware("finalizeOptions",r),o={},i=e.applyMiddleware("interceptRequest",void 0,{adapter:v,context:e});if(i){const e=setTimeout(t,0,null,i);return{abort:()=>clearTimeout(e)}}let s=new b;s instanceof g&&"object"==typeof n.fetch&&s.setInit(n.fetch,n.useAbortSignal??!0);const a=n.headers,u=n.timeout;let c=!1,l=!1,h=!1;if(s.onerror=e=>{d(s instanceof g?e instanceof Error?e:new Error(`Request error while attempting to reach is ${n.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},s.ontimeout=e=>{d(new Error(`Request timeout while attempting to reach ${n.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`))},s.onabort=()=>{p(!0),c=!0},s.onreadystatechange=()=>{u&&(p(),o.socket=setTimeout((()=>f("ESOCKETTIMEDOUT")),u.socket)),!c&&4===s.readyState&&0!==s.status&&function(){if(!(c||l||h)){if(0===s.status)return void d(new Error("Unknown XHR error"));p(),l=!0,t(null,{body:s.response||(""===s.responseType||"text"===s.responseType?s.responseText:""),url:n.url,method:n.method,headers:y(s.getAllResponseHeaders()),statusCode:s.status,statusMessage:s.statusText})}}()},s.open(n.method,n.url,!0),s.withCredentials=!!n.withCredentials,a&&s.setRequestHeader)for(const e in a)a.hasOwnProperty(e)&&s.setRequestHeader(e,a[e]);return n.rawBody&&(s.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:n,adapter:v,request:s,context:e}),s.send(n.body||null),u&&(o.connect=setTimeout((()=>f("ETIMEDOUT")),u.connect)),{abort:function(){c=!0,s&&s.abort()}};function f(t){h=!0,s.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${n.url}`:`Connection timed out on request to ${n.url}`);r.code=t,e.channels.error.publish(r)}function p(e){(e||c||s.readyState>=2&&o.connect)&&clearTimeout(o.connect),o.socket&&clearTimeout(o.socket)}function d(e){if(l)return;p(!0),l=!0,s=null;const r=e||new Error(`Network error while attempting to reach ${n.url}`);r.isNetworkError=!0,r.request=n,t(r)}},w=(e=[],t=m)=>f(e,t);var C,E,x,_,S,O={exports:{}};S||(S=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!(!(typeof window<"u"&&window.process)||"renderer"!==window.process.type&&!window.process.__nwjs)||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=(_?x:(_=1,x=function(e){function t(e){let n,o,i,s=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),i=o-(n||o);r.diff=i,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];n=i.call(r,t),e.splice(s,1),s--}return n})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(typeof r>"u"?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=function(){if(E)return C;E=1;var e=1e3,t=60*e,r=60*t,n=24*r,o=7*n;function i(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}return C=function(s,a){a=a||{};var u,c,l=typeof s;if("string"===l&&s.length>0)return function(i){if(!((i=String(i)).length>100)){var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(s){var a=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"weeks":case"week":case"w":return a*o;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}(s);if("number"===l&&isFinite(s))return a.long?(u=s,(c=Math.abs(u))>=n?i(u,c,n,"day"):c>=r?i(u,c,r,"hour"):c>=t?i(u,c,t,"minute"):c>=e?i(u,c,e,"second"):u+" ms"):function(o){var i=Math.abs(o);return i>=n?Math.round(o/n)+"d":i>=r?Math.round(o/r)+"h":i>=t?Math.round(o/t)+"m":i>=e?Math.round(o/e)+"s":o+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))}}(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}))(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(O,O.exports));const R=typeof Buffer>"u"?()=>!1:e=>Buffer.isBuffer(e);function T(e){return"[object Object]"===Object.prototype.toString.call(e)}const A=["boolean","string","number"];function j(){return{processOptions:e=>{const t=e.body;return!t||"function"==typeof t.pipe||R(t)||-1===A.indexOf(typeof t)&&!Array.isArray(t)&&!function(e){if(!1===T(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!(!1===T(r)||!1===r.hasOwnProperty("isPrototypeOf"))}(t)?e:Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})})}}}function q(e){return{onResponse:r=>{const n=r.headers["content-type"]||"",o=e&&e.force||-1!==n.indexOf("application/json");return r.body&&n&&o?Object.assign({},r,{body:t(r.body)}):r},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message=`Failed to parsed response body as JSON: ${e.message}`,e}}}let I={};typeof globalThis<"u"?I=globalThis:typeof window<"u"?I=window:typeof global<"u"?I=global:typeof self<"u"&&(I=self);var $=I;function P(e={}){const t=e.implementation||$.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 k=(e,t,r)=>("GET"===r.method||"HEAD"===r.method)&&(e.isNetworkError||!1);function D(e){return 100*Math.pow(2,e)+100*Math.random()}const F=(e={})=>(e=>{const t=e.maxRetries||5,r=e.retryDelay||D,n=e.shouldRetry;return{onError:(e,o)=>{const i=o.options,s=i.maxRetries||t,a=i.retryDelay||r,u=i.shouldRetry||n,c=i.attemptNumber||0;if(null!==(l=i.body)&&"object"==typeof l&&"function"==typeof l.pipe||!u(e,c,i)||c>=s)return e;var l;const h=Object.assign({},o,{options:Object.assign({},i,{attemptNumber:c+1})});return setTimeout((()=>o.channels.request.publish(h)),a(c)),null}}})({shouldRetry:k,...e});F.shouldRetry=k;var M=function(e,t){return M=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])},M(e,t)};function U(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}M(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function N(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(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(s,a)}u((n=n.apply(e,t||[])).next())}))}function z(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.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 L(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 H(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function B(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;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 J(e){return this instanceof J?(this.v=e,this):new J(e)}function G(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),i=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),n[Symbol.asyncIterator]=function(){return this},n;function s(e,t){o[e]&&(n[e]=function(t){return new Promise((function(r,n){i.push([e,t,r,n])>1||a(e,t)}))},t&&(n[e]=t(n[e])))}function a(e,t){try{!function(e){e.value instanceof J?Promise.resolve(e.value.v).then(u,c):l(i[0][2],e)}(o[e](t))}catch(e){l(i[0][3],e)}}function u(e){a("next",e)}function c(e){a("throw",e)}function l(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function V(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=L(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 W(e){return"function"==typeof e}function X(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 Q=X((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 Y(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var K=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 i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var s=L(i),a=s.next();!a.done;a=s.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}else i.remove(this);var u=this.initialTeardown;if(W(u))try{u()}catch(e){o=e instanceof Q?e.errors:[e]}var c=this._finalizers;if(c){this._finalizers=null;try{for(var l=L(c),h=l.next();!h.done;h=l.next()){var f=h.value;try{te(f)}catch(e){o=null!=o?o:[],e instanceof Q?o=B(B([],H(o)),H(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 Q(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)te(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)&&Y(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&Y(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),Z=K.EMPTY;function ee(e){return e instanceof K||e&&"closed"in e&&W(e.remove)&&W(e.add)&&W(e.unsubscribe)}function te(e){W(e)?e():e.unsubscribe()}var re={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ne={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,B([e,t],H(r)))},clearTimeout:function(e){var t=ne.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function oe(e){ne.setTimeout((function(){throw e}))}function ie(){}function se(e){e()}var ae=function(e){function t(t){var r=e.call(this)||this;return r.isStopped=!1,t?(r.destination=t,ee(t)&&t.add(r)):r.destination=he,r}return U(t,e),t.create=function(e,t,r){return new ce(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}(K),ue=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){le(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){le(e)}else le(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){le(e)}},e}(),ce=function(e){function t(t,r,n){var o,i=e.call(this)||this;return o=W(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,i.destination=new ue(o),i}return U(t,e),t}(ae);function le(e){oe(e)}var he={closed:!0,next:ie,error:function(e){throw e},complete:ie},fe="function"==typeof Symbol&&Symbol.observable||"@@observable";function pe(e){return e}function de(e){return 0===e.length?pe:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var ye=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,i=(n=e)&&n instanceof ae||function(e){return e&&W(e.next)&&W(e.error)&&W(e.complete)}(n)&&ee(n)?e:new ce(e,t,r);return se((function(){var e=o,t=e.operator,r=e.source;i.add(t?t.call(i,r):r?o._subscribe(i):o._trySubscribe(i))})),i},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=ge(t))((function(t,n){var o=new ce({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[fe]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return de(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=ge(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 ge(e){var t;return null!==(t=null!=e?e:re.Promise)&&void 0!==t?t:Promise}function ve(e){return function(t){if(function(e){return W(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 be(e,t,r,n,o){return new me(e,t,r,n,o)}var me=function(e){function t(t,r,n,o,i,s){var a=e.call(this,t)||this;return a.onFinalize=i,a.shouldUnsubscribe=s,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 U(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}(ae),we=X((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),Ce=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return U(t,e),t.prototype.lift=function(e){var t=new Ee(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new we},t.prototype.next=function(e){var t=this;se((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=L(t.currentObservers),i=o.next();!i.done;i=o.next()){i.value.next(e)}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;se((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;se((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,o=r.isStopped,i=r.observers;return n||o?Z:(this.currentObservers=null,i.push(e),new K((function(){t.currentObservers=null,Y(i,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,o=t.isStopped;r?e.error(n):o&&e.complete()},t.prototype.asObservable=function(){var e=new ye;return e.source=this,e},t.create=function(e,t){return new Ee(e,t)},t}(ye),Ee=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return U(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:Z},t}(Ce),xe={now:function(){return(xe.delegate||Date).now()},delegate:void 0},_e=function(e){function t(t,r,n){void 0===t&&(t=1/0),void 0===r&&(r=1/0),void 0===n&&(n=xe);var o=e.call(this)||this;return o._bufferSize=t,o._windowTime=r,o._timestampProvider=n,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,t),o._windowTime=Math.max(1,r),o}return U(t,e),t.prototype.next=function(t){var r=this,n=r.isStopped,o=r._buffer,i=r._infiniteTimeWindow,s=r._timestampProvider,a=r._windowTime;n||(o.push(t),!i&&o.push(s.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),r=this._infiniteTimeWindow,n=this._buffer.slice(),o=0;o<n.length&&!e.closed;o+=r?1:2)e.next(n[o]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,r=e._timestampProvider,n=e._buffer,o=e._infiniteTimeWindow,i=(o?1:2)*t;if(t<1/0&&i<n.length&&n.splice(0,n.length-i),!o){for(var s=r.now(),a=0,u=1;u<n.length&&n[u]<=s;u+=2)a=u;a&&n.splice(0,a+1)}},t}(Ce),Se=function(e){function t(t,r){return e.call(this)||this}return U(t,e),t.prototype.schedule=function(e,t){return this},t}(K),Oe=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setInterval.apply(void 0,B([e,t],H(r)))},Re=function(e){return clearInterval(e)},Te=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.scheduler=t,n.work=r,n.pending=!1,n}return U(t,e),t.prototype.schedule=function(e,t){var r;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var n=this.id,o=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(o,n,t)),this.pending=!0,this.delay=t,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(o,this.id,t),this},t.prototype.requestAsyncId=function(e,t,r){return void 0===r&&(r=0),Oe(e.flush.bind(e,this),r)},t.prototype.recycleAsyncId=function(e,t,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return t;null!=t&&Re(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(e,t);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var r,n=!1;try{this.work(e)}catch(e){n=!0,r=e||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Y(n,this),null!=t&&(this.id=this.recycleAsyncId(r,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(Se),Ae=function(){function e(t,r){void 0===r&&(r=e.now),this.schedulerActionCtor=t,this.now=r}return e.prototype.schedule=function(e,t,r){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},e.now=xe.now,e}(),je=new(function(e){function t(t,r){void 0===r&&(r=Ae.now);var n=e.call(this,t,r)||this;return n.actions=[],n._active=!1,n}return U(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var r;this._active=!0;do{if(r=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}},t}(Ae))(Te),qe=new ye((function(e){return e.complete()}));function Ie(e){return e[e.length-1]}function $e(e){return(t=Ie(e))&&W(t.schedule)?e.pop():void 0;var t}var Pe=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function ke(e){return W(null==e?void 0:e.then)}function De(e){return W(e[fe])}function Fe(e){return Symbol.asyncIterator&&W(null==e?void 0:e[Symbol.asyncIterator])}function Me(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var Ue="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function Ne(e){return W(null==e?void 0:e[Ue])}function ze(e){return G(this,arguments,(function(){var t,r,n;return z(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,J(t.read())];case 3:return r=o.sent(),n=r.value,r.done?[4,J(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,J(n)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}function Le(e){return W(null==e?void 0:e.getReader)}function He(e){if(e instanceof ye)return e;if(null!=e){if(De(e))return o=e,new ye((function(e){var t=o[fe]();if(W(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Pe(e))return n=e,new ye((function(e){for(var t=0;t<n.length&&!e.closed;t++)e.next(n[t]);e.complete()}));if(ke(e))return r=e,new ye((function(e){r.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,oe)}));if(Fe(e))return Be(e);if(Ne(e))return t=e,new ye((function(e){var r,n;try{for(var o=L(t),i=o.next();!i.done;i=o.next()){var s=i.value;if(e.next(s),e.closed)return}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}e.complete()}));if(Le(e))return Be(ze(e))}var t,r,n,o;throw Me(e)}function Be(e){return new ye((function(t){(function(e,t){var r,n,o,i;return N(this,void 0,void 0,(function(){var s,a;return z(this,(function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),r=V(e),u.label=1;case 1:return[4,r.next()];case 2:if((n=u.sent()).done)return[3,4];if(s=n.value,t.next(s),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&&(i=r.return)?[4,i.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 Je(e,t,r,n,o){void 0===n&&(n=0),void 0===o&&(o=!1);var i=t.schedule((function(){r(),o?e.add(this.schedule(null,n)):this.unsubscribe()}),n);if(e.add(i),!o)return i}function Ge(e,t){return void 0===t&&(t=0),ve((function(r,n){r.subscribe(be(n,(function(r){return Je(n,e,(function(){return n.next(r)}),t)}),(function(){return Je(n,e,(function(){return n.complete()}),t)}),(function(r){return Je(n,e,(function(){return n.error(r)}),t)})))}))}function Ve(e,t){return void 0===t&&(t=0),ve((function(r,n){n.add(e.schedule((function(){return r.subscribe(n)}),t))}))}function We(e,t){if(!e)throw new Error("Iterable cannot be null");return new ye((function(r){Je(r,t,(function(){var n=e[Symbol.asyncIterator]();Je(r,t,(function(){n.next().then((function(e){e.done?r.complete():r.next(e.value)}))}),0,!0)}))}))}function Xe(e,t){if(null!=e){if(De(e))return function(e,t){return He(e).pipe(Ve(t),Ge(t))}(e,t);if(Pe(e))return function(e,t){return new ye((function(r){var n=0;return t.schedule((function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())}))}))}(e,t);if(ke(e))return function(e,t){return He(e).pipe(Ve(t),Ge(t))}(e,t);if(Fe(e))return We(e,t);if(Ne(e))return function(e,t){return new ye((function(r){var n;return Je(r,t,(function(){n=e[Ue](),Je(r,t,(function(){var e,t,o;try{t=(e=n.next()).value,o=e.done}catch(e){return void r.error(e)}o?r.complete():r.next(t)}),0,!0)})),function(){return W(null==n?void 0:n.return)&&n.return()}}))}(e,t);if(Le(e))return function(e,t){return We(ze(e),t)}(e,t)}throw Me(e)}function Qe(e,t){return t?Xe(e,t):He(e)}function Ye(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Qe(e,$e(e))}function Ke(e,t){var r=W(e)?e:function(){return e};return new ye((function(e){return e.error(r())}))}var Ze=X((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}));function et(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 Ze)}})}))}function tt(e,t){return ve((function(r,n){var o=0;r.subscribe(be(n,(function(r){n.next(e.call(t,r,o++))})))}))}var rt=Array.isArray;function nt(e){return tt((function(t){return function(e,t){return rt(t)?e.apply(void 0,B([],H(t))):e(t)}(e,t)}))}function ot(e,t,r){t()}function it(e,t,r){return void 0===r&&(r=1/0),W(t)?it((function(r,n){return tt((function(e,o){return t(r,e,n,o)}))(He(e(r,n)))}),r):("number"==typeof t&&(r=t),ve((function(t,n){return function(e,t,r,n,o,i,s){var a=[],u=0,c=0,l=!1,h=function(){!l||a.length||u||t.complete()},f=function(e){u++;var o=!1;He(r(e,c++)).subscribe(be(t,(function(e){t.next(e)}),(function(){o=!0}),void 0,(function(){if(o)try{for(u--;a.length&&u<n;)e=void 0,e=a.shift(),s||f(e);h()}catch(e){t.error(e)}var e})))};return e.subscribe(be(t,(function(e){return u<n?f(e):a.push(e)}),(function(){l=!0,h()}))),function(){}}(t,n,e,r)})))}function st(){return it(pe,1)}function at(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return st()(Qe(e,$e(e)))}function ut(e){return new ye((function(t){He(e()).subscribe(t)}))}function ct(e,t,r){return void 0===r&&(r=je),new ye((function(t){var n,o=(n=e)instanceof Date&&!isNaN(n)?1e3-r.now():e;o<0&&(o=0);var i=0;return r.schedule((function(){t.closed||(t.next(i++),t.complete())}),o)}))}var lt=Array.isArray;function ht(e,t){return ve((function(r,n){var o=0;r.subscribe(be(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}function ft(e){return ve((function(t,r){var n,o=null,i=!1;o=t.subscribe(be(r,void 0,void 0,(function(s){n=He(e(s,ft(e)(t))),o?(o.unsubscribe(),o=null,n.subscribe(r)):i=!0}))),i&&(o.unsubscribe(),o=null,n.subscribe(r))}))}function pt(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=function(e){return W(Ie(e))?e.pop():void 0}(e);return r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return de(e)}(pt.apply(void 0,B([],H(e))),nt(r)):ve((function(t,r){var n,o,i;(n=B([t],H(function(e){return 1===e.length&&lt(e[0])?e[0]:e}(e))),void 0===i&&(i=pe),function(e){ot(0,(function(){for(var t=n.length,r=new Array(t),s=t,a=t,u=function(t){ot(0,(function(){var u=Qe(n[t],o),c=!1;u.subscribe(be(e,(function(n){r[t]=n,c||(c=!0,a--),a||e.next(i(r.slice()))}),(function(){--s||e.complete()})))}))},c=0;c<t;c++)u(c)}))})(r)}))}function dt(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(!0!==t){if(!1!==t){var o=new ce({next:function(){o.unsubscribe(),e()}});return He(t.apply(void 0,B([],H(r)))).subscribe(o)}}else e()}var yt={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},gt={0:8203,1:8204,2:8205,3:65279},vt=new Array(4).fill(String.fromCodePoint(gt[0])).join("");function bt(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`${vt}${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(gt[e]))).join("")})).join("")}`}(t)}`}Object.fromEntries(Object.entries(gt).map((e=>e.reverse()))),Object.fromEntries(Object.entries(yt).map((e=>e.reverse())));var mt=`${Object.values(yt).map((e=>`\\u{${e.toString(16)}}`)).join("")}`,wt=new RegExp(`[${mt}]{4,}`,"gu");function Ct(e){return e&&JSON.parse(function(e){var t;return{cleaned:e.replace(wt,""),encoded:(null==(t=e.match(wt))?void 0:t[0])||""}}(JSON.stringify(e)).cleaned)}class Et extends Error{response;statusCode=400;responseBody;details;constructor(e){const t=_t(e);super(t.message),Object.assign(this,t)}}class xt extends Error{response;statusCode=500;responseBody;details;constructor(e){const t=_t(e);super(t.message),Object.assign(this,t)}}function _t(e){const t=e.body,r={response:e,statusCode:e.statusCode,responseBody:Ot(t,e),message:"",details:void 0};if(t.error&&t.message)return r.message=`${t.error} - ${t.message}`,r;if(function(e){return St(e)&&St(e.error)&&"mutationError"===e.error.type&&"string"==typeof e.error.description}(t)||function(e){return St(e)&&St(e.error)&&"actionError"===e.error.type&&"string"==typeof e.error.description}(t)){const e=t.error.items||[],n=e.slice(0,5).map((e=>e.error?.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 St(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Ot(e,t){return-1!==(t.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(e,null,2):e}class Rt extends Error{projectId;addOriginUrl;constructor({projectId:e}){super("CorsOriginError"),this.name="CorsOriginError",this.projectId=e;const t=new URL(`https://sanity.io/manage/project/${e}/api`);if(typeof location<"u"){const{origin:e}=location;t.searchParams.set("cors","add"),t.searchParams.set("origin",e),this.addOriginUrl=t,this.message=`The current origin is not allowed to connect to the Live Content API. Add it here: ${t}`}else this.message=`The current origin is not allowed to connect to the Live Content API. Change your configuration here: ${t}`}}const Tt={onResponse:e=>{if(e.statusCode>=500)throw new xt(e);if(e.statusCode>=400)throw new Et(e);return e}},At={onResponse:e=>{const t=e.headers["x-sanity-warning"];return(Array.isArray(t)?t:[t]).filter(Boolean).forEach((e=>console.warn(e))),e}};function jt(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"),i=e.response&&(429===e.response.statusCode||502===e.response.statusCode||503===e.response.statusCode);return!(!n&&!o||!i)||F.shouldRetry(e,t,r)}function qt(e){return"https://www.sanity.io/help/"+e}const It=["image","file"],$t=["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")},kt=(e,t)=>{if(null===t||"object"!=typeof t||Array.isArray(t))throw new Error(`${e}() takes an object of properties`)},Dt=(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`)},Ft=(e,t)=>{if(!t._id)throw new Error(`${e}() requires that the document contains an ID ("_id" property)`);Dt(e,t._id)},Mt=e=>{if(!e.dataset)throw new Error("`dataset` must be provided to perform queries");return e.dataset||""},Ut=e=>{if("string"!=typeof e||!/^[a-z0-9._-]{1,75}$/i.test(e))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return e};const Nt=e=>function(e){let t,r=!1;return(...n)=>(r||(t=e(...n),r=!0),t)}(((...t)=>console.warn(e.join(" "),...t))),zt=Nt(["Because you set `withCredentials` to true, we will override your `useCdn`","setting to be false since (cookie-based) credentials are never set on the CDN"]),Lt=Nt(["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."]),Ht=Nt(["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."]),Bt=Nt(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.",`See ${qt("js-client-browser-token")} for more information and how to hide this warning.`]),Jt=Nt(["Using the Sanity client without specifying an API version is deprecated.",`See ${qt("js-client-api-version")}`]),Gt=Nt(["The default export of @sanity/client has been deprecated. Use the named export `createClient` instead."]),Vt={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,stega:{enabled:!1}},Wt=["localhost","127.0.0.1","0.0.0.0"];function Xt(e){if(Array.isArray(e)){for(const t of e)if("published"!==t&&"drafts"!==t&&("string"!=typeof t||!t.startsWith("r")||"raw"===t))throw new TypeError("Invalid API perspective value, expected `published`, `drafts` or a valid release identifier string")}else switch(e){case"previewDrafts":case"drafts":case"published":case"raw":return;default:throw new TypeError("Invalid API perspective string, expected `published`, `previewDrafts` or `raw`")}}const Qt=(e,t)=>{const r={...t,...e,stega:{..."boolean"==typeof t.stega?{enabled:t.stega}:t.stega||Vt.stega,..."boolean"==typeof e.stega?{enabled:e.stega}:e.stega||{}}};r.apiVersion||Jt();const n={...Vt,...r},o=n.useProjectHostname;if(typeof Promise>"u"){const e=qt("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(typeof n.perspective<"u"&&Xt(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 i=typeof window<"u"&&window.location&&window.location.hostname,s=i&&(e=>-1!==Wt.indexOf(e))(window.location.hostname);i&&s&&n.token&&!0!==n.ignoreBrowserTokenWarning?Bt():typeof n.useCdn>"u"&&Lt(),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?Ut(n.requestTagPrefix).replace(/\.+$/,""):void 0),n.apiVersion=`${n.apiVersion}`.replace(/^v/,""),n.isDefaultApi=n.apiHost===Vt.apiHost,!0===n.useCdn&&n.withCredentials&&zt(),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};class Yt extends Error{name="ConnectionFailedError"}class Kt extends Error{name="DisconnectError";reason;constructor(e,t,r={}){super(e,r),this.reason=t}}class Zt extends Error{name="ChannelError";data;constructor(e,t){super(e),this.data=t}}class er extends Error{name="MessageError";data;constructor(e,t,r={}){super(e,r),this.data=t}}class tr extends Error{name="MessageParseError"}const rr=["channelError","disconnect"];function nr(e,t){return ut((()=>{const t=e();return(r=t)&&(r instanceof ye||W(r.lift)&&W(r.subscribe))?t:Ye(t);var r})).pipe(it((e=>function(e,t){return new ye((r=>{const n=t.includes("open"),o=t.includes("reconnect");function i(t){if("data"in t){const[e,n]=or(t);r.error(e?new tr("Unable to parse EventSource error message",{cause:n}):new er((n?.data).message,n))}else e.readyState===e.CLOSED?r.error(new Yt("EventSource connection failed")):o&&r.next({type:"reconnect"})}function s(){r.next({type:"open"})}function a(e){const[t,n]=or(e);var o;t?r.error(new tr("Unable to parse EventSource message",{cause:t})):"channelError"!==e.type?"disconnect"!==e.type?r.next({type:e.type,id:e.lastEventId,...n.data?{data:n.data}:{}}):r.error(new Kt(`Server disconnected client: ${n.data?.reason||"unknown error"}`)):r.error(new Zt((o=n?.data,o.error?o.error.description?o.error.description:"string"==typeof o.error?o.error:JSON.stringify(o.error,null,2):o.message||"Unknown listener error"),n.data))}e.addEventListener("error",i),n&&e.addEventListener("open",s);const u=[...new Set([...rr,...t])].filter((e=>"error"!==e&&"open"!==e&&"reconnect"!==e));return u.forEach((t=>e.addEventListener(t,a))),()=>{e.removeEventListener("error",i),n&&e.removeEventListener("open",s),u.forEach((t=>e.removeEventListener(t,a))),e.close()}}))}(e,t))))}function or(e){try{const t="string"==typeof e.data&&JSON.parse(e.data);return[null,{type:e.type,id:e.lastEventId,...ir(t)?{}:{data:t}}]}catch(e){return[e,null]}}function ir(e){for(const t in e)return!1;return!0}function sr(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}`)}class ar{selection;operations;constructor(e,t={}){this.selection=e,this.operations=t}set(e){return this._assign("set",e)}setIfMissing(e){return this._assign("setIfMissing",e)}diffMatchPatch(e){return kt("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===$t.indexOf(e)){const e=$t.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,i=typeof r>"u"||-1===r?-1:Math.max(0,t+r),s=`${e}[${o}:${o<0&&i>=0?"":i}]`;return this.insert("replace",s,n||[])}ifRevisionId(e){return this.operations.ifRevisionID=e,this}serialize(){return{...sr(this.selection),...this.operations}}toJSON(){return this.serialize()}reset(){return this.operations={},this}_assign(e,t,r=!0){return kt(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)}}class ur extends ar{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new ur(this.selection,{...this.operations},this.#a)}commit(e){if(!this.#a)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 this.#a.mutate({patch:this.serialize()},r)}}class cr extends ar{#a;constructor(e,t,r){super(e,t),this.#a=r}clone(){return new cr(this.selection,{...this.operations},this.#a)}commit(e){if(!this.#a)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 this.#a.mutate({patch:this.serialize()},r)}}const lr={returnDocuments:!1};class hr{operations;trxId;constructor(e=[],t){this.operations=e,this.trxId=t}create(e){return kt("create",e),this._add({create:e})}createIfNotExists(e){const t="createIfNotExists";return kt(t,e),Ft(t,e),this._add({[t]:e})}createOrReplace(e){const t="createOrReplace";return kt(t,e),Ft(t,e),this._add({[t]:e})}delete(e){return Dt("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}}class fr extends hr{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new fr([...this.operations],this.#a,this.trxId)}commit(e){if(!this.#a)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.#a.mutate(this.serialize(),Object.assign({transactionId:this.trxId},lr,e||{}))}patch(e,t){const r="function"==typeof t,n="object"==typeof e&&("query"in e||"id"in e);if("string"!=typeof e&&e instanceof cr)return this._add({patch:e.serialize()});if(r){const r=t(new cr(e,{},this.#a));if(!(r instanceof cr))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}if(n){const r=new cr(e,t||{},this.#a);return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}}class pr extends hr{#a;constructor(e,t,r){super(e,r),this.#a=t}clone(){return new pr([...this.operations],this.#a,this.trxId)}commit(e){if(!this.#a)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.#a.mutate(this.serialize(),Object.assign({transactionId:this.trxId},lr,e||{}))}patch(e,t){const r="function"==typeof t;if("string"!=typeof e&&e instanceof ur)return this._add({patch:e.serialize()});if(r){const r=t(new ur(e,{},this.#a));if(!(r instanceof ur))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:{id:e,...t}})}}const dr=({query:e,params:t={},options:r={}})=>{const n=new URLSearchParams,{tag:o,includeMutations:i,returnQuery:s,...a}=r;o&&n.append("tag",o),n.append("query",e);for(const[e,r]of Object.entries(t))n.append(`$${e}`,JSON.stringify(r));for(const[e,t]of Object.entries(a))t&&n.append(e,`${t}`);return!1===s&&n.append("returnQuery","false"),!1===i&&n.append("includeMutations","false"),`?${n}`},yr=(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},gr=e=>"response"===e.type,vr=e=>e.body;function br(e,t,r,n,o={},i={}){const s="stega"in i?{...r||{},..."boolean"==typeof i.stega?{enabled:i.stega}:i.stega||{}}:r,a=s.enabled?Ct(o):o,u=!1===i.filterResponse?e=>e:e=>e.result,{cache:c,next:l,...h}={useAbortSignal:typeof i.signal<"u",resultSourceMap:s.enabled?"withKeyArraySelector":i.resultSourceMap,...i,returnQuery:!1===i.filterResponse&&!1!==i.returnQuery},f=Or(e,t,"query",{query:n,params:a},typeof c<"u"||typeof l<"u"?{...h,fetch:{cache:c,next:l}}:h);return s.enabled?f.pipe(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return pt.apply(void 0,B([],H(e)))}(Qe(Promise.resolve().then((function(){return Sn})).then((function(e){return e.stegaEncodeSourceMap$1})).then((({stegaEncodeSourceMap:e})=>e)))),tt((([e,t])=>{const r=t(e.result,e.resultSourceMap,s);return u({...e,result:r})}))):f.pipe(tt(u))}function mr(e,t,r,n={}){return Tr(e,t,{uri:jr(e,"doc",r),json:!0,tag:n.tag,signal:n.signal}).pipe(ht(gr),tt((e=>e.body.documents&&e.body.documents[0])))}function wr(e,t,r,n={}){return Tr(e,t,{uri:jr(e,"doc",r.join(",")),json:!0,tag:n.tag,signal:n.signal}).pipe(ht(gr),tt((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 Ft("createIfNotExists",r),Rr(e,t,r,"createIfNotExists",n)}function Er(e,t,r,n){return Ft("createOrReplace",r),Rr(e,t,r,"createOrReplace",n)}function xr(e,t,r,n){return Or(e,t,"mutate",{mutations:[{delete:sr(r)}]},n)}function _r(e,t,r,n){let o;o=r instanceof cr||r instanceof ur?{patch:r.serialize()}:r instanceof fr||r instanceof pr?r.serialize():r;return Or(e,t,"mutate",{mutations:Array.isArray(o)?o:[o],transactionId:n&&n.transactionId||void 0},n)}function Sr(e,t,r,n){return Or(e,t,"actions",{actions:Array.isArray(r)?r:[r],transactionId:n&&n.transactionId||void 0,skipCrossDatasetReferenceValidation:n&&n.skipCrossDatasetReferenceValidation||void 0,dryRun:n&&n.dryRun||void 0},n)}function Or(e,t,r,n,o={}){const i="mutate"===r,s="actions"===r,a="query"===r,u=i||s?"":dr(n),c=!i&&!s&&u.length<11264,l=c?u:"",h=o.returnFirst,{timeout:f,token:p,tag:d,headers:y,returnQuery:g,lastLiveEventId:v,cacheMode:b}=o;return Tr(e,t,{method:c?"GET":"POST",uri:jr(e,r,l),json:!0,body:c?void 0:n,query:i&&yr(o),timeout:f,headers:y,token:p,tag:d,returnQuery:g,perspective:o.perspective,resultSourceMap:o.resultSourceMap,lastLiveEventId:Array.isArray(v)?v[0]:v,cacheMode:b,canUseCdn:a,signal:o.signal,fetch:o.fetch,useAbortSignal:o.useAbortSignal,useCdn:o.useCdn}).pipe(ht(gr),tt(vr),tt((e=>{if(!i)return e;const t=e.results||[];if(o.returnDocuments)return h?t[0]&&t[0].document:t.map((e=>e.document));const r=h?"documentId":"documentIds",n=h?t[0]&&t[0].id:t.map((e=>e.id));return{transactionId:e.transactionId,results:t,[r]:n}})))}function Rr(e,t,r,n,o={}){return Or(e,t,"mutate",{mutations:[{[n]:r}]},Object.assign({returnFirst:!0,returnDocuments:!0},o))}function Tr(e,t,r){const n=r.url||r.uri,o=e.config(),i=typeof r.canUseCdn>"u"?["GET","HEAD"].indexOf(r.method||"GET")>=0&&0===n.indexOf("/data/"):r.canUseCdn;let s=(r.useCdn??o.useCdn)&&i;const a=r.tag&&o.requestTagPrefix?[o.requestTagPrefix,r.tag].join("."):r.tag||o.requestTagPrefix;if(a&&null!==r.tag&&(r.query={tag:Ut(a),...r.query}),["GET","HEAD","POST"].indexOf(r.method||"GET")>=0&&0===n.indexOf("/data/query/")){const e=r.resultSourceMap??o.resultSourceMap;void 0!==e&&!1!==e&&(r.query={resultSourceMap:e,...r.query});const t=r.perspective||o.perspective;typeof t<"u"&&(Xt(t),r.query={perspective:Array.isArray(t)?t.join(","):t,...r.query},"previewDrafts"===t&&s&&(s=!1,Ht())),r.lastLiveEventId&&(r.query={...r.query,lastLiveEventId:r.lastLiveEventId}),!1===r.returnQuery&&(r.query={returnQuery:"false",...r.query}),s&&"noStale"==r.cacheMode&&(r.query={cacheMode:"noStale",...r.query})}const u=function(e,t={}){const r={},n=t.token||e.token;n&&(r.Authorization=`Bearer ${n}`),!t.useGlobalApi&&!e.useProjectHostname&&e.projectId&&(r["X-Sanity-Project-ID"]=e.projectId);const o=!!(typeof t.withCredentials>"u"?e.token||e.withCredentials:t.withCredentials),i=typeof t.timeout>"u"?e.timeout:t.timeout;return Object.assign({},t,{headers:Object.assign({},r,t.headers||{}),timeout:typeof i>"u"?3e5:i,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})}(o,Object.assign({},r,{url:qr(e,n,s)})),c=new ye((e=>t(u,o.requester).subscribe(e)));return r.signal?c.pipe((l=r.signal,e=>new ye((t=>{const r=()=>t.error(function(e){if(Ir)return new DOMException(e?.reason??"The operation was aborted.","AbortError");const t=new Error(e?.reason??"The operation was aborted.");return t.name="AbortError",t}(l));if(l&&l.aborted)return void r();const n=e.subscribe(t);return l.addEventListener("abort",r),()=>{l.removeEventListener("abort",r),n.unsubscribe()}})))):c;var l}function Ar(e,t,r){return Tr(e,t,r).pipe(ht((e=>"response"===e.type)),tt((e=>e.body)))}function jr(e,t,r){const n=e.config(),o=`/${t}/${Mt(n)}`;return`/data${r?`${o}/${r}`:o}`.replace(/\/($|\?)/,"$1")}function qr(e,t,r=!1){const{url:n,cdnUrl:o}=e.config();return`${r?o:n}/${t.replace(/^\//,"")}`}const Ir=!!globalThis.DOMException;class $r{#a;#u;constructor(e,t){this.#a=e,this.#u=t}upload(e,t,r){return kr(this.#a,this.#u,e,t,r)}}class Pr{#a;#u;constructor(e,t){this.#a=e,this.#u=t}upload(e,t,r){return et(kr(this.#a,this.#u,e,t,r).pipe(ht((e=>"response"===e.type)),tt((e=>e.body.document))))}}function kr(e,t,r,n,o={}){(e=>{if(-1===It.indexOf(e))throw new Error(`Invalid asset type: ${e}. Must be one of ${It.join(", ")}`)})(r);let i=o.extract||void 0;i&&!i.length&&(i=["none"]);const s=Mt(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:f,creditLine:p,filename:d,source:y}=u,g={label:l,title:h,description:f,filename:d,meta:i,creditLine:p};return y&&(g.sourceId=y.id,g.sourceName=y.name,g.sourceUrl=y.url),Tr(e,t,{tag:c,method:"POST",timeout:u.timeout||0,uri:`/assets/${a}/${s}`,headers:u.contentType?{"Content-Type":u.contentType}:{},query:g,body:n})}const Dr=ut((()=>Promise.resolve().then((function(){return kn})))).pipe(tt((({default:e})=>e)),(Ur=1,function(e){void 0===e&&(e={});var t=e.connector,r=void 0===t?function(){return new Ce}:t,n=e.resetOnError,o=void 0===n||n,i=e.resetOnComplete,s=void 0===i||i,a=e.resetOnRefCountZero,u=void 0===a||a;return function(e){var t,n,i,a=0,c=!1,l=!1,h=function(){null==n||n.unsubscribe(),n=void 0},f=function(){h(),t=i=void 0,c=l=!1},p=function(){var e=t;f(),null==e||e.unsubscribe()};return ve((function(e,d){a++,l||c||h();var y=i=null!=i?i:r();d.add((function(){0!=--a||l||c||(n=dt(p,u))})),y.subscribe(d),!t&&a>0&&(t=new ce({next:function(e){return y.next(e)},error:function(e){l=!0,h(),n=dt(f,o,e),y.error(e)},complete:function(){c=!0,h(),n=dt(f,s),y.complete()}}),He(e).subscribe(t))}))(e)}}({connector:function(){return new _e(Ur,Fr,Mr)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1})));var Fr,Mr,Ur;function Nr(){return function(e){return e.pipe(ft(((e,t)=>e instanceof Yt?at(Ye({type:"reconnect"}),ct(1e3).pipe(it((()=>t)))):Ke((()=>e)))))}}const zr=["includePreviousRevision","includeResult","includeMutations","visibility","effectFormat","tag"],Lr={includeResult:!0};function Hr(e,t,r={}){const{url:n,token:o,withCredentials:i,requestTagPrefix:s}=this.config(),a=r.tag&&s?[s,r.tag].join("."):r.tag,u={...(h=r,f=Lr,Object.keys(f).concat(Object.keys(h)).reduce(((e,t)=>(e[t]=typeof h[t]>"u"?f[t]:h[t],e)),{})),tag:a},c=((e,t)=>t.reduce(((t,r)=>(typeof e[r]>"u"||(t[r]=e[r]),t)),{}))(u,zr),l=`${n}${jr(this,"listen",dr({query:e,params:t,options:{tag:a,...c}}))}`;var h,f;if(l.length>14800)return Ke((()=>new Error("Query too large for listener")));const p=u.events?u.events:["mutation"],d={};return(o||i)&&(d.withCredentials=!0),o&&(d.headers={Authorization:`Bearer ${o}`}),nr((()=>(typeof EventSource>"u"||d.headers?Dr:Ye(EventSource)).pipe(tt((e=>new e(l,d))))),p).pipe(Nr(),ht((e=>p.includes(e.type))),tt((e=>({type:e.type,..."data"in e?e.data:{}}))))}const Br="2021-03-26";class Jr{#a;constructor(e){this.#a=e}events({includeDrafts:e=!1,tag:t}={}){const{projectId:r,apiVersion:n,token:o,withCredentials:i,requestTagPrefix:s}=this.#a.config(),a=n.replace(/^v/,"");if("X"!==a&&a<Br)throw new Error(`The live events API requires API version ${Br} or later. The current API version is ${a}. Please update your API version to use this feature.`);if(e&&!o&&!i)throw new Error("The live events API requires a token or withCredentials when 'includeDrafts: true'. Please update your client configuration. The token should have the lowest possible access role.");if(e&&"X"!==a)throw new Error("The live events API requires API version X when 'includeDrafts: true'. This API is experimental and may change or even be removed.");const u=jr(this.#a,"live/events"),c=new URL(this.#a.getUrl(u,!1)),l=t&&s?[s,t].join("."):t;l&&c.searchParams.set("tag",l),e&&c.searchParams.set("includeDrafts","true");const h={};e&&o&&(h.headers={Authorization:`Bearer ${o}`}),e&&i&&(h.withCredentials=!0);const f=nr((()=>(typeof EventSource>"u"||h.headers?Dr:Ye(EventSource)).pipe(tt((e=>new e(c.href,h))))),["message","restart","welcome","reconnect"]).pipe(Nr(),tt((e=>{if("message"===e.type){const{data:t,...r}=e;return{...r,tags:t.tags}}return e}))),p=function(e,t){return new ye((r=>{const n=new AbortController,o=n.signal;return fetch(e,{...t,signal:n.signal}).then((e=>{r.next(e),r.complete()}),(e=>{o.aborted||r.error(e)})),()=>n.abort()}))}(c,{method:"OPTIONS",mode:"cors",credentials:h.withCredentials?"include":"omit",headers:h.headers}).pipe(it((()=>qe)),ft((()=>{throw new Rt({projectId:r})})));return at(p,f)}}class Gr{#a;#u;constructor(e,t){this.#a=e,this.#u=t}create(e,t){return Wr(this.#a,this.#u,"PUT",e,t)}edit(e,t){return Wr(this.#a,this.#u,"PATCH",e,t)}delete(e){return Wr(this.#a,this.#u,"DELETE",e)}list(){return Ar(this.#a,this.#u,{uri:"/datasets",tag:null})}}class Vr{#a;#u;constructor(e,t){this.#a=e,this.#u=t}create(e,t){return et(Wr(this.#a,this.#u,"PUT",e,t))}edit(e,t){return et(Wr(this.#a,this.#u,"PATCH",e,t))}delete(e){return et(Wr(this.#a,this.#u,"DELETE",e))}list(){return et(Ar(this.#a,this.#u,{uri:"/datasets",tag:null}))}}function Wr(e,t,r,n,o){return Pt(n),Ar(e,t,{method:r,uri:`/datasets/${n}`,body:o,tag:null})}class Xr{#a;#u;constructor(e,t){this.#a=e,this.#u=t}list(e){const t=!1===e?.includeMembers?"/projects?includeMembers=false":"/projects";return Ar(this.#a,this.#u,{uri:t})}getById(e){return Ar(this.#a,this.#u,{uri:`/projects/${e}`})}}class Qr{#a;#u;constructor(e,t){this.#a=e,this.#u=t}list(e){const t=!1===e?.includeMembers?"/projects?includeMembers=false":"/projects";return et(Ar(this.#a,this.#u,{uri:t}))}getById(e){return et(Ar(this.#a,this.#u,{uri:`/projects/${e}`}))}}class Yr{#a;#u;constructor(e,t){this.#a=e,this.#u=t}getById(e){return Ar(this.#a,this.#u,{uri:`/users/${e}`})}}class Kr{#a;#u;constructor(e,t){this.#a=e,this.#u=t}getById(e){return et(Ar(this.#a,this.#u,{uri:`/users/${e}`}))}}class Zr{assets;datasets;live;projects;users;#c;#u;listen=Hr;constructor(e,t=Vt){this.config(t),this.#u=e,this.assets=new $r(this,this.#u),this.datasets=new Gr(this,this.#u),this.live=new Jr(this),this.projects=new Xr(this,this.#u),this.users=new Yr(this,this.#u)}clone(){return new Zr(this.#u,this.config())}config(e){if(void 0===e)return{...this.#c};if(this.#c&&!1===this.#c.allowReconfigure)throw new Error("Existing client instance cannot be reconfigured - use `withConfig(newConfig)` to return a new client");return this.#c=Qt(e,this.#c||{}),this}withConfig(e){const t=this.config();return new Zr(this.#u,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return br(this,this.#u,this.#c.stega,e,t,r)}getDocument(e,t){return mr(this,this.#u,e,t)}getDocuments(e,t){return wr(this,this.#u,e,t)}create(e,t){return Rr(this,this.#u,e,"create",t)}createIfNotExists(e,t){return Cr(this,this.#u,e,t)}createOrReplace(e,t){return Er(this,this.#u,e,t)}delete(e,t){return xr(this,this.#u,e,t)}mutate(e,t){return _r(this,this.#u,e,t)}patch(e,t){return new ur(e,t,this)}transaction(e){return new pr(e,this)}action(e,t){return Sr(this,this.#u,e,t)}request(e){return Ar(this,this.#u,e)}getUrl(e,t){return qr(this,e,t)}getDataUrl(e,t){return jr(this,e,t)}}class en{assets;datasets;live;projects;users;observable;#c;#u;listen=Hr;constructor(e,t=Vt){this.config(t),this.#u=e,this.assets=new Pr(this,this.#u),this.datasets=new Vr(this,this.#u),this.live=new Jr(this),this.projects=new Qr(this,this.#u),this.users=new Kr(this,this.#u),this.observable=new Zr(e,t)}clone(){return new en(this.#u,this.config())}config(e){if(void 0===e)return{...this.#c};if(this.#c&&!1===this.#c.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),this.#c=Qt(e,this.#c||{}),this}withConfig(e){const t=this.config();return new en(this.#u,{...t,...e,stega:{...t.stega||{},..."boolean"==typeof e?.stega?{enabled:e.stega}:e?.stega||{}}})}fetch(e,t,r){return et(br(this,this.#u,this.#c.stega,e,t,r))}getDocument(e,t){return et(mr(this,this.#u,e,t))}getDocuments(e,t){return et(wr(this,this.#u,e,t))}create(e,t){return et(Rr(this,this.#u,e,"create",t))}createIfNotExists(e,t){return et(Cr(this,this.#u,e,t))}createOrReplace(e,t){return et(Er(this,this.#u,e,t))}delete(e,t){return et(xr(this,this.#u,e,t))}mutate(e,t){return et(_r(this,this.#u,e,t))}patch(e,t){return new cr(e,t,this)}transaction(e){return new fr(e,this)}action(e,t){return et(Sr(this,this.#u,e,t))}request(e){return et(Ar(this,this.#u,e))}dataRequest(e,t,r){return et(Or(this,this.#u,e,t,r))}getUrl(e,t){return qr(this,e,t)}getDataUrl(e,t){return jr(this,e,t)}}const tn=function(e,t){const r=function(e){return w([F({shouldRetry:jt}),...e,At,j(),q(),{onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,r=e.context;function n(e){return t=>{const n=t.lengthComputable?t.loaded/t.total*100:-1;r.channels.progress.publish({stage:e,percent:n,total:t.total,loaded:t.loaded,lengthComputable:t.lengthComputable})}}"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=n("upload")),"onprogress"in t&&(t.onprogress=n("download"))}},Tt,P({implementation:ye})])}(e);return{requester:r,createClient:e=>new t(((t,n)=>(n||r)({maxRedirects:0,maxRetries:e.maxRetries,retryDelay:e.retryDelay,...t})),e)}}([],en),rn=tn.requester,nn=tn.createClient,on=(sn=nn,function(e){return Gt(),sn(e)});var sn;const an=/_key\s*==\s*['"](.*)['"]/;function un(e){if(!Array.isArray(e))throw new Error("Path is not an array");return e.reduce(((e,t,r)=>{const n=typeof t;if("number"===n)return`${e}[${t}]`;if("string"===n)return`${e}${0===r?"":"."}${t}`;if(function(e){return"string"==typeof e?an.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 cn={"\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","'":"\\'","\\":"\\\\"},ln={"\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t","\\'":"'","\\\\":"\\"};function hn(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=>ln[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=>ln[e]));t.push(e)}return t}function fn(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 pn(e,t){if(!t?.mappings)return;const r=function(e){return`$${e.map((e=>"string"==typeof e?`['${e.replace(/[\f\n\r\t'\\]/g,(e=>cn[e]))}']`:"number"==typeof e?`[${e}]`:""!==e._key?`[?(@._key=='${e._key.replace(/['\\]/g,(e=>cn[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,i]=n[0];return{mapping:i,matchedPath:o,pathSuffix:r.substring(o.length)}}function dn(e){return"object"==typeof e&&null!==e}function yn(e,t,r=[]){if(function(e){return null!==e&&Array.isArray(e)}(e))return e.map(((e,n)=>{if(dn(e)){const o=e._key;if("string"==typeof o)return yn(e,t,r.concat({_key:o,_index:n}))}return yn(e,t,r.concat(n))}));if(dn(e)){if("block"===e._type||"span"===e._type){const n={...e};return"block"===e._type?n.children=yn(e.children,t,r.concat("children")):"span"===e._type&&(n.text=yn(e.text,t,r.concat("text"))),n}return Object.fromEntries(Object.entries(e).map((([e,n])=>[e,yn(n,t,r.concat(e))])))}return t(e,r)}function gn(e,t,r){return yn(e,((e,n)=>{if("string"!=typeof e)return e;const o=pn(n,t);if(!o)return e;const{mapping:i,matchedPath:s}=o;if("value"!==i.type||"documentValue"!==i.source.type)return e;const a=t.documents[i.source.document],u=t.paths[i.source.path],c=hn(s),l=hn(u).concat(n.slice(c.length));return r({sourcePath:l,sourceDocument:a,resultPath:n,value:e})}))}const vn="drafts.";function bn(e){const{baseUrl:t,workspace:r="default",tool:n="default",id:o,type:i,path:s,projectId:a,dataset:u}=e;if(!t)throw new Error("baseUrl is required");if(!s)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(vn)?e.slice(7):e}(o),f=Array.isArray(s)?un(fn(s)):s,p=new URLSearchParams({baseUrl:t,id:h,type:i,path:f});c&&p.set("workspace",c),l&&p.set("tool",l),a&&p.set("projectId",a),u&&p.set("dataset",u),o.startsWith(vn)&&p.set("isDraft","");const d=["/"===t?"":t];c&&d.push(c);const y=["mode=presentation",`id=${h}`,`type=${i}`,`path=${encodeURIComponent(f)}`];return l&&y.push(`tool=${l}`),d.push("intent","edit",`${y.join(";")}?${p}`),d.join("/")}const mn=({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("_")||o.endsWith("Id"))||e.some((e=>"meta"===e||"metadata"===e||"openGraph"===e||"seo"===e))||Cn(e)||Cn(t)||"string"==typeof o&&wn.has(o))},wn=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","textTheme","unit","url","username","variant","website"]);function Cn(e){return e.some((e=>"string"==typeof e&&null!==e.match(/type/i)))}function En(e,t,r){const{filter:n,logger:o,enabled:i}=r;if(!i){const n="config.enabled must be true, don't call this function otherwise";throw o?.error?.(`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}if(!t)return o?.error?.("[@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 o?.error?.(`[@sanity/client]: ${n}`,{result:e,resultSourceMap:t,config:r}),new TypeError(n)}const s={encoded:[],skipped:[]},a=gn(e,t,(({sourcePath:e,sourceDocument:t,resultPath:i,value:a})=>{if(!1===("function"==typeof n?n({sourcePath:e,resultPath:i,filterDefault:mn,sourceDocument:t,value:a}):mn({sourcePath:e,resultPath:i,filterDefault:mn,sourceDocument:t,value:a})))return o&&s.skipped.push({path:xn(e),value:`${a.slice(0,20)}${a.length>20?"...":""}`,length:a.length}),a;o&&s.encoded.push({path:xn(e),value:`${a.slice(0,20)}${a.length>20?"...":""}`,length:a.length});const{baseUrl:u,workspace:c,tool:l}=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(!u)return a;const{_id:h,_type:f,_projectId:p,_dataset:d}=t;return bt(a,{origin:"sanity.io",href:bn({baseUrl:u,workspace:c,tool:l,id:h,type:f,path:e,...!r.omitCrossDatasetReferenceData&&{dataset:d,projectId:p}})},!1)}));if(o){const e=s.skipped.length,t=s.encoded.length;if((e||t)&&((o?.groupCollapsed||o.log)?.("[@sanity/client]: Encoding source map into result"),o.log?.(`[@sanity/client]: Paths encoded: ${s.encoded.length}, skipped: ${s.skipped.length}`)),s.encoded.length>0&&(o?.log?.("[@sanity/client]: Table of encoded paths"),(o?.table||o.log)?.(s.encoded)),s.skipped.length>0){const e=new Set;for(const{path:t}of s.skipped)e.add(t.replace(an,"0").replace(/\[\d+\]/g,"[]"));o?.log?.("[@sanity/client]: List of skipped paths",[...e.values()])}(e||t)&&o?.groupEnd?.()}return a}function xn(e){return un(fn(e))}var _n=Object.freeze({__proto__:null,stegaEncodeSourceMap:En}),Sn=Object.freeze({__proto__:null,encodeIntoResult:gn,stegaEncodeSourceMap:En,stegaEncodeSourceMap$1:_n});function On(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Rn,Tn,An,jn={exports:{}},qn=jn.exports;
2
2
  /** @license
3
3
  * eventsource.js
4
4
  * Available under MIT License (MIT)
5
5
  * https://github.com/Yaffle/EventSource/
6
- */function Ar(){return Or||(Or=1,function(e,t){!function(r){var n=r.setTimeout,o=r.clearTimeout,s=r.XMLHttpRequest,i=r.XDomainRequest,a=r.ActiveXObject,c=r.EventSource,u=r.document,l=r.Promise,h=r.fetch,p=r.Response,d=r.TextDecoder,f=r.TextEncoder,y=r.AbortController;if("undefined"==typeof window||void 0===u||"readyState"in u||null!=u.body||(u.readyState="loading",window.addEventListener("load",(function(e){u.readyState="complete"}),!1)),null==s&&null!=a&&(s=function(){return new a("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==y){var g=h;h=function(e,t){var r=t.signal;return g(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then((function(e){var t=e.body.getReader();return r._reader=t,r._aborted&&r._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}}))},y=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function m(){this.bitsNeeded=0,this.codePoint=0}m.prototype.decode=function(e){function t(e,t,r){if(1===r)return e>=128>>t&&e<<t<=2047;if(2===r)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===r)return e>=65536>>t&&e<<t<=1114111;throw new Error}function r(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var n=65533,o="",s=this.bitsNeeded,i=this.codePoint,a=0;a<e.length;a+=1){var c=e[a];0!==s&&(c<128||c>191||!t(i<<6|63&c,s-6,r(s,i)))&&(s=0,i=n,o+=String.fromCharCode(i)),0===s?(c>=0&&c<=127?(s=0,i=c):c>=192&&c<=223?(s=6,i=31&c):c>=224&&c<=239?(s=12,i=15&c):c>=240&&c<=247?(s=18,i=7&c):(s=0,i=n),0===s||t(i,s,r(s,i))||(s=0,i=n)):(s-=6,i=i<<6|63&c),0===s&&(i<=65535?o+=String.fromCharCode(i):(o+=String.fromCharCode(55296+(i-65535-1>>10)),o+=String.fromCharCode(56320+(i-65535-1&1023))))}return this.bitsNeeded=s,this.codePoint=i,o};null!=d&&null!=f&&function(){try{return"test"===(new d).decode((new f).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(d=m);var b=function(){};function v(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=b,this.onload=b,this.onerror=b,this.onreadystatechange=b,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=b}function w(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function C(e){for(var t=Object.create(null),r=e.split("\r\n"),n=0;n<r.length;n+=1){var o=r[n].split(": "),s=o.shift(),i=o.join(": ");t[w(s)]=i}this._map=t}function E(){}function x(e){this._headers=e}function R(){}function S(){this._listeners=Object.create(null)}function O(e){n((function(){throw e}),0)}function T(e){this.type=e,this.target=void 0}function _(e,t){T.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function q(e,t){T.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function j(e,t){T.call(this,e),this.error=t.error}v.prototype.open=function(e,t){this._abort(!0);var r=this,i=this._xhr,a=1,c=0;this._abort=function(e){0!==r._sendTimeout&&(o(r._sendTimeout),r._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,i.onload=b,i.onerror=b,i.onabort=b,i.onprogress=b,i.onreadystatechange=b,i.abort(),0!==c&&(o(c),c=0),e||(r.readyState=4,r.onabort(null),r.onreadystatechange())),a=0};var u=function(){if(1===a){var e=0,t="",n=void 0;if("contentType"in i)e=200,t="OK",n=i.contentType;else try{e=i.status,t=i.statusText,n=i.getResponseHeader("Content-Type")}catch(r){e=0,t="",n=void 0}0!==e&&(a=2,r.readyState=2,r.status=e,r.statusText=t,r._contentType=n,r.onreadystatechange())}},l=function(){if(u(),2===a||3===a){a=3;var e="";try{e=i.responseText}catch(e){}r.readyState=3,r.responseText=e,r.onprogress()}},h=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:b}),l(),1===a||2===a||3===a){if(a=4,0!==c&&(o(c),c=0),r.readyState=4,"load"===e)r.onload(t);else if("error"===e)r.onerror(t);else{if("abort"!==e)throw new TypeError;r.onabort(t)}r.onreadystatechange()}},p=function(){c=n((function(){p()}),500),3===i.readyState&&l()};"onload"in i&&(i.onload=function(e){h("load",e)}),"onerror"in i&&(i.onerror=function(e){h("error",e)}),"onabort"in i&&(i.onabort=function(e){h("abort",e)}),"onprogress"in i&&(i.onprogress=l),"onreadystatechange"in i&&(i.onreadystatechange=function(e){!function(e){null!=i&&(4===i.readyState?"onload"in i&&"onerror"in i&&"onabort"in i||h(""===i.responseText?"error":"load",e):3===i.readyState?"onprogress"in i||l():2===i.readyState&&u())}(e)}),!("contentType"in i)&&"ontimeout"in s.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),i.open(e,t,!0),"readyState"in i&&(c=n((function(){p()}),0))},v.prototype.abort=function(){this._abort(!1)},v.prototype.getResponseHeader=function(e){return this._contentType},v.prototype.setRequestHeader=function(e,t){var r=this._xhr;"setRequestHeader"in r&&r.setRequestHeader(e,t)},v.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},v.prototype.send=function(){if("ontimeout"in s.prototype&&("sendAsBinary"in s.prototype||"mozAnon"in s.prototype)||null==u||null==u.readyState||"complete"===u.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=n((function(){t._sendTimeout=0,t.send()}),4)}},C.prototype.get=function(e){return this._map[w(e)]},null!=s&&null==s.HEADERS_RECEIVED&&(s.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,r,n,o,i,a){e.open("GET",o);var c=0;for(var u in e.onprogress=function(){var t=e.responseText.slice(c);c+=t.length,r(t)},e.onerror=function(e){e.preventDefault(),n(new Error("NetworkError"))},e.onload=function(){n(null)},e.onabort=function(){n(null)},e.onreadystatechange=function(){if(e.readyState===s.HEADERS_RECEIVED){var r=e.status,n=e.statusText,o=e.getResponseHeader("Content-Type"),i=e.getAllResponseHeaders();t(r,n,o,new C(i))}},e.withCredentials=i,a)Object.prototype.hasOwnProperty.call(a,u)&&e.setRequestHeader(u,a[u]);return e.send(),e},x.prototype.get=function(e){return this._headers.get(e)},R.prototype.open=function(e,t,r,n,o,s,i){var a=null,c=new y,u=c.signal,p=new d;return h(o,{headers:i,credentials:s?"include":"same-origin",signal:u,cache:"no-store"}).then((function(e){return a=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new x(e.headers)),new l((function(e,t){var n=function(){a.read().then((function(t){if(t.done)e(void 0);else{var o=p.decode(t.value,{stream:!0});r(o),n()}})).catch((function(e){t(e)}))};n()}))})).catch((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){n(e)})),{abort:function(){null!=a&&a.cancel(),c.abort()}}},S.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(null!=t)for(var r=t.length,n=0;n<r;n+=1){var o=t[n];try{"function"==typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(e){O(e)}}},S.prototype.addEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];null==n&&(n=[],r[e]=n);for(var o=!1,s=0;s<n.length;s+=1)n[s]===t&&(o=!0);o||n.push(t)},S.prototype.removeEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];if(null!=n){for(var o=[],s=0;s<n.length;s+=1)n[s]!==t&&o.push(n[s]);0===o.length?delete r[e]:r[e]=o}},_.prototype=Object.create(T.prototype),q.prototype=Object.create(T.prototype),j.prototype=Object.create(T.prototype);var A=-1,$=-1,I=/^text\/event\-stream(;.*)?$/i,P=function(e,t){var r=null==e?t:parseInt(e,10);return r!=r&&(r=t),k(r)},k=function(e){return Math.min(Math.max(e,1e3),18e6)},D=function(e,t,r){try{"function"==typeof t&&t.call(e,r)}catch(e){O(e)}};function F(e,t){S.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(e,t,r){t=String(t);var a=Boolean(r.withCredentials),c=r.lastEventIdQueryParameterName||"lastEventId",u=k(1e3),l=P(r.heartbeatTimeout,45e3),h="",p=u,d=!1,f=0,y=r.headers||{},g=r.Transport,m=M&&null==g?void 0:new v(null!=g?new g:null!=s&&"withCredentials"in s.prototype||null==i?new s:new i),b=null!=g&&"string"!=typeof g?new g:null==m?new R:new E,w=void 0,C=0,x=A,S="",O="",T="",F="",U=0,N=0,L=0,z=function(t,r,n,o){if(0===x)if(200===t&&null!=n&&I.test(n)){x=1,d=Date.now(),p=u,e.readyState=1;var s=new q("open",{status:t,statusText:r,headers:o});e.dispatchEvent(s),D(e,e.onopen,s)}else{var i="";200!==t?(r&&(r=r.replace(/\s+/g," ")),i="EventSource's response has a status "+t+" "+r+" that is not 200. Aborting the connection."):i="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",J();s=new q("error",{status:t,statusText:r,headers:o});e.dispatchEvent(s),D(e,e.onerror,s),console.error(i)}},H=function(t){if(1===x){for(var r=-1,s=0;s<t.length;s+=1){(c=t.charCodeAt(s))!=="\n".charCodeAt(0)&&c!=="\r".charCodeAt(0)||(r=s)}var i=(-1!==r?F:"")+t.slice(0,r+1);F=(-1===r?F:"")+t.slice(r+1),""!==t&&(d=Date.now(),f+=t.length);for(var a=0;a<i.length;a+=1){var c=i.charCodeAt(a);if(U===$&&c==="\n".charCodeAt(0))U=0;else if(U===$&&(U=0),c==="\r".charCodeAt(0)||c==="\n".charCodeAt(0)){if(0!==U){1===U&&(L=a+1);var y=i.slice(N,L-1),g=i.slice(L+(L<a&&i.charCodeAt(L)===" ".charCodeAt(0)?1:0),a);"data"===y?(S+="\n",S+=g):"id"===y?O=g:"event"===y?T=g:"retry"===y?(u=P(g,u),p=u):"heartbeatTimeout"===y&&(l=P(g,l),0!==C&&(o(C),C=n((function(){G()}),l)))}if(0===U){if(""!==S){h=O,""===T&&(T="message");var m=new _(T,{data:S.slice(1),lastEventId:O});if(e.dispatchEvent(m),"open"===T?D(e,e.onopen,m):"message"===T?D(e,e.onmessage,m):"error"===T&&D(e,e.onerror,m),2===x)return}S="",T=""}U=c==="\r".charCodeAt(0)?$:0}else 0===U&&(N=a,U=1),1===U?c===":".charCodeAt(0)&&(L=a+1,U=2):2===U&&(U=3)}}},B=function(t){if(1===x||0===x){x=A,0!==C&&(o(C),C=0),C=n((function(){G()}),p),p=k(Math.min(16*u,2*p)),e.readyState=0;var r=new j("error",{error:t});e.dispatchEvent(r),D(e,e.onerror,r),null!=t&&console.error(t)}},J=function(){x=2,null!=w&&(w.abort(),w=void 0),0!==C&&(o(C),C=0),e.readyState=2},G=function(){if(C=0,x===A){d=!1,f=0,C=n((function(){G()}),l),x=0,S="",T="",O=h,F="",N=0,L=0,U=0;var r=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==h){var o=t.indexOf("?");r=-1===o?t:t.slice(0,o+1)+t.slice(o+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(e,t){return t===c?"":e})),r+=(-1===t.indexOf("?")?"?":"&")+c+"="+encodeURIComponent(h)}var s=e.withCredentials,i={Accept:"text/event-stream"},a=e.headers;if(null!=a)for(var u in a)Object.prototype.hasOwnProperty.call(a,u)&&(i[u]=a[u]);try{w=b.open(m,z,H,B,r,s,i)}catch(e){throw J(),e}}else if(d||null==w){var p=Math.max((d||Date.now())+l-Date.now(),1);d=!1,C=n((function(){G()}),p)}else B(new Error("No activity within "+l+" milliseconds. "+(0===x?"No response received.":f+" chars received.")+" Reconnecting.")),null!=w&&(w.abort(),w=void 0)};e.url=t,e.readyState=0,e.withCredentials=a,e.headers=y,e._close=J,G()}(this,e,t)}var M=null!=h&&null!=p&&"body"in p.prototype;F.prototype=Object.create(S.prototype),F.prototype.CONNECTING=0,F.prototype.OPEN=1,F.prototype.CLOSED=2,F.prototype.close=function(){this._close()},F.CONNECTING=0,F.OPEN=1,F.CLOSED=2,F.prototype.withCredentials=void 0;var U=c;null==s||null!=c&&"withCredentials"in c.prototype||(U=F),function(){var r=function(e){e.EventSourcePolyfill=F,e.NativeEventSource=c,e.EventSource=U}(t);void 0!==r&&(e.exports=r)}()}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:jr:globalThis)}(qr,qr.exports)),qr.exports}function $r(){return _r?Tr:(_r=1,Tr=Ar().EventSourcePolyfill)}var Ir=Sr($r()),Pr=Object.freeze({__proto__:null,default:Ir});e.BasePatch=lt,e.BaseTransaction=ft,e.ClientError=Pe,e.CorsOriginError=Ue,e.ObservablePatch=ht,e.ObservableSanityClient=Zt,e.ObservableTransaction=gt,e.Patch=pt,e.SanityClient=er,e.ServerError=ke,e.Transaction=yt,e.createClient=nr,e.default=or,e.requester=rr,e.unstable__adapter=y,e.unstable__environment="browser",e.validateApiPerspective=at,Object.defineProperty(e,"__esModule",{value:!0})}));
6
+ */function In(){return Rn||(Rn=1,function(e,t){!function(r){var n=r.setTimeout,o=r.clearTimeout,i=r.XMLHttpRequest,s=r.XDomainRequest,a=r.ActiveXObject,u=r.EventSource,c=r.document,l=r.Promise,h=r.fetch,f=r.Response,p=r.TextDecoder,d=r.TextEncoder,y=r.AbortController;if("undefined"==typeof window||void 0===c||"readyState"in c||null!=c.body||(c.readyState="loading",window.addEventListener("load",(function(e){c.readyState="complete"}),!1)),null==i&&null!=a&&(i=function(){return new a("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(e){function t(){}return t.prototype=e,new t}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==y){var g=h;h=function(e,t){var r=t.signal;return g(e,{headers:t.headers,credentials:t.credentials,cache:t.cache}).then((function(e){var t=e.body.getReader();return r._reader=t,r._aborted&&r._reader.cancel(),{status:e.status,statusText:e.statusText,headers:e.headers,body:{getReader:function(){return t}}}}))},y=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function v(){this.bitsNeeded=0,this.codePoint=0}v.prototype.decode=function(e){function t(e,t,r){if(1===r)return e>=128>>t&&e<<t<=2047;if(2===r)return e>=2048>>t&&e<<t<=55295||e>=57344>>t&&e<<t<=65535;if(3===r)return e>=65536>>t&&e<<t<=1114111;throw new Error}function r(e,t){if(6===e)return t>>6>15?3:t>31?2:1;if(12===e)return t>15?3:2;if(18===e)return 3;throw new Error}for(var n=65533,o="",i=this.bitsNeeded,s=this.codePoint,a=0;a<e.length;a+=1){var u=e[a];0!==i&&(u<128||u>191||!t(s<<6|63&u,i-6,r(i,s)))&&(i=0,s=n,o+=String.fromCharCode(s)),0===i?(u>=0&&u<=127?(i=0,s=u):u>=192&&u<=223?(i=6,s=31&u):u>=224&&u<=239?(i=12,s=15&u):u>=240&&u<=247?(i=18,s=7&u):(i=0,s=n),0===i||t(s,i,r(i,s))||(i=0,s=n)):(i-=6,s=s<<6|63&u),0===i&&(s<=65535?o+=String.fromCharCode(s):(o+=String.fromCharCode(55296+(s-65535-1>>10)),o+=String.fromCharCode(56320+(s-65535-1&1023))))}return this.bitsNeeded=i,this.codePoint=s,o};null!=p&&null!=d&&function(){try{return"test"===(new p).decode((new d).encode("test"),{stream:!0})}catch(e){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+e)}return!1}()||(p=v);var b=function(){};function m(e){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=b,this.onload=b,this.onerror=b,this.onreadystatechange=b,this._contentType="",this._xhr=e,this._sendTimeout=0,this._abort=b}function w(e){return e.replace(/[A-Z]/g,(function(e){return String.fromCharCode(e.charCodeAt(0)+32)}))}function C(e){for(var t=Object.create(null),r=e.split("\r\n"),n=0;n<r.length;n+=1){var o=r[n].split(": "),i=o.shift(),s=o.join(": ");t[w(i)]=s}this._map=t}function E(){}function x(e){this._headers=e}function _(){}function S(){this._listeners=Object.create(null)}function O(e){n((function(){throw e}),0)}function R(e){this.type=e,this.target=void 0}function T(e,t){R.call(this,e),this.data=t.data,this.lastEventId=t.lastEventId}function A(e,t){R.call(this,e),this.status=t.status,this.statusText=t.statusText,this.headers=t.headers}function j(e,t){R.call(this,e),this.error=t.error}m.prototype.open=function(e,t){this._abort(!0);var r=this,s=this._xhr,a=1,u=0;this._abort=function(e){0!==r._sendTimeout&&(o(r._sendTimeout),r._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,s.onload=b,s.onerror=b,s.onabort=b,s.onprogress=b,s.onreadystatechange=b,s.abort(),0!==u&&(o(u),u=0),e||(r.readyState=4,r.onabort(null),r.onreadystatechange())),a=0};var c=function(){if(1===a){var e=0,t="",n=void 0;if("contentType"in s)e=200,t="OK",n=s.contentType;else try{e=s.status,t=s.statusText,n=s.getResponseHeader("Content-Type")}catch(r){e=0,t="",n=void 0}0!==e&&(a=2,r.readyState=2,r.status=e,r.statusText=t,r._contentType=n,r.onreadystatechange())}},l=function(){if(c(),2===a||3===a){a=3;var e="";try{e=s.responseText}catch(e){}r.readyState=3,r.responseText=e,r.onprogress()}},h=function(e,t){if(null!=t&&null!=t.preventDefault||(t={preventDefault:b}),l(),1===a||2===a||3===a){if(a=4,0!==u&&(o(u),u=0),r.readyState=4,"load"===e)r.onload(t);else if("error"===e)r.onerror(t);else{if("abort"!==e)throw new TypeError;r.onabort(t)}r.onreadystatechange()}},f=function(){u=n((function(){f()}),500),3===s.readyState&&l()};"onload"in s&&(s.onload=function(e){h("load",e)}),"onerror"in s&&(s.onerror=function(e){h("error",e)}),"onabort"in s&&(s.onabort=function(e){h("abort",e)}),"onprogress"in s&&(s.onprogress=l),"onreadystatechange"in s&&(s.onreadystatechange=function(e){!function(e){null!=s&&(4===s.readyState?"onload"in s&&"onerror"in s&&"onabort"in s||h(""===s.responseText?"error":"load",e):3===s.readyState?"onprogress"in s||l():2===s.readyState&&c())}(e)}),!("contentType"in s)&&"ontimeout"in i.prototype||(t+=(-1===t.indexOf("?")?"?":"&")+"padding=true"),s.open(e,t,!0),"readyState"in s&&(u=n((function(){f()}),0))},m.prototype.abort=function(){this._abort(!1)},m.prototype.getResponseHeader=function(e){return this._contentType},m.prototype.setRequestHeader=function(e,t){var r=this._xhr;"setRequestHeader"in r&&r.setRequestHeader(e,t)},m.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},m.prototype.send=function(){if("ontimeout"in i.prototype&&("sendAsBinary"in i.prototype||"mozAnon"in i.prototype)||null==c||null==c.readyState||"complete"===c.readyState){var e=this._xhr;"withCredentials"in e&&(e.withCredentials=this.withCredentials);try{e.send(void 0)}catch(e){throw e}}else{var t=this;t._sendTimeout=n((function(){t._sendTimeout=0,t.send()}),4)}},C.prototype.get=function(e){return this._map[w(e)]},null!=i&&null==i.HEADERS_RECEIVED&&(i.HEADERS_RECEIVED=2),E.prototype.open=function(e,t,r,n,o,s,a){e.open("GET",o);var u=0;for(var c in e.onprogress=function(){var t=e.responseText.slice(u);u+=t.length,r(t)},e.onerror=function(e){e.preventDefault(),n(new Error("NetworkError"))},e.onload=function(){n(null)},e.onabort=function(){n(null)},e.onreadystatechange=function(){if(e.readyState===i.HEADERS_RECEIVED){var r=e.status,n=e.statusText,o=e.getResponseHeader("Content-Type"),s=e.getAllResponseHeaders();t(r,n,o,new C(s))}},e.withCredentials=s,a)Object.prototype.hasOwnProperty.call(a,c)&&e.setRequestHeader(c,a[c]);return e.send(),e},x.prototype.get=function(e){return this._headers.get(e)},_.prototype.open=function(e,t,r,n,o,i,s){var a=null,u=new y,c=u.signal,f=new p;return h(o,{headers:s,credentials:i?"include":"same-origin",signal:c,cache:"no-store"}).then((function(e){return a=e.body.getReader(),t(e.status,e.statusText,e.headers.get("Content-Type"),new x(e.headers)),new l((function(e,t){var n=function(){a.read().then((function(t){if(t.done)e(void 0);else{var o=f.decode(t.value,{stream:!0});r(o),n()}})).catch((function(e){t(e)}))};n()}))})).catch((function(e){return"AbortError"===e.name?void 0:e})).then((function(e){n(e)})),{abort:function(){null!=a&&a.cancel(),u.abort()}}},S.prototype.dispatchEvent=function(e){e.target=this;var t=this._listeners[e.type];if(null!=t)for(var r=t.length,n=0;n<r;n+=1){var o=t[n];try{"function"==typeof o.handleEvent?o.handleEvent(e):o.call(this,e)}catch(e){O(e)}}},S.prototype.addEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];null==n&&(n=[],r[e]=n);for(var o=!1,i=0;i<n.length;i+=1)n[i]===t&&(o=!0);o||n.push(t)},S.prototype.removeEventListener=function(e,t){e=String(e);var r=this._listeners,n=r[e];if(null!=n){for(var o=[],i=0;i<n.length;i+=1)n[i]!==t&&o.push(n[i]);0===o.length?delete r[e]:r[e]=o}},T.prototype=Object.create(R.prototype),A.prototype=Object.create(R.prototype),j.prototype=Object.create(R.prototype);var q=-1,I=-1,$=/^text\/event\-stream(;.*)?$/i,P=function(e,t){var r=null==e?t:parseInt(e,10);return r!=r&&(r=t),k(r)},k=function(e){return Math.min(Math.max(e,1e3),18e6)},D=function(e,t,r){try{"function"==typeof t&&t.call(e,r)}catch(e){O(e)}};function F(e,t){S.call(this),t=t||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(e,t,r){t=String(t);var a=Boolean(r.withCredentials),u=r.lastEventIdQueryParameterName||"lastEventId",c=k(1e3),l=P(r.heartbeatTimeout,45e3),h="",f=c,p=!1,d=0,y=r.headers||{},g=r.Transport,v=M&&null==g?void 0:new m(null!=g?new g:null!=i&&"withCredentials"in i.prototype||null==s?new i:new s),b=null!=g&&"string"!=typeof g?new g:null==v?new _:new E,w=void 0,C=0,x=q,S="",O="",R="",F="",U=0,N=0,z=0,L=function(t,r,n,o){if(0===x)if(200===t&&null!=n&&$.test(n)){x=1,p=Date.now(),f=c,e.readyState=1;var i=new A("open",{status:t,statusText:r,headers:o});e.dispatchEvent(i),D(e,e.onopen,i)}else{var s="";200!==t?(r&&(r=r.replace(/\s+/g," ")),s="EventSource's response has a status "+t+" "+r+" that is not 200. Aborting the connection."):s="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",J();i=new A("error",{status:t,statusText:r,headers:o});e.dispatchEvent(i),D(e,e.onerror,i),console.error(s)}},H=function(t){if(1===x){for(var r=-1,i=0;i<t.length;i+=1){(u=t.charCodeAt(i))!=="\n".charCodeAt(0)&&u!=="\r".charCodeAt(0)||(r=i)}var s=(-1!==r?F:"")+t.slice(0,r+1);F=(-1===r?F:"")+t.slice(r+1),""!==t&&(p=Date.now(),d+=t.length);for(var a=0;a<s.length;a+=1){var u=s.charCodeAt(a);if(U===I&&u==="\n".charCodeAt(0))U=0;else if(U===I&&(U=0),u==="\r".charCodeAt(0)||u==="\n".charCodeAt(0)){if(0!==U){1===U&&(z=a+1);var y=s.slice(N,z-1),g=s.slice(z+(z<a&&s.charCodeAt(z)===" ".charCodeAt(0)?1:0),a);"data"===y?(S+="\n",S+=g):"id"===y?O=g:"event"===y?R=g:"retry"===y?(c=P(g,c),f=c):"heartbeatTimeout"===y&&(l=P(g,l),0!==C&&(o(C),C=n((function(){G()}),l)))}if(0===U){if(""!==S){h=O,""===R&&(R="message");var v=new T(R,{data:S.slice(1),lastEventId:O});if(e.dispatchEvent(v),"open"===R?D(e,e.onopen,v):"message"===R?D(e,e.onmessage,v):"error"===R&&D(e,e.onerror,v),2===x)return}S="",R=""}U=u==="\r".charCodeAt(0)?I:0}else 0===U&&(N=a,U=1),1===U?u===":".charCodeAt(0)&&(z=a+1,U=2):2===U&&(U=3)}}},B=function(t){if(1===x||0===x){x=q,0!==C&&(o(C),C=0),C=n((function(){G()}),f),f=k(Math.min(16*c,2*f)),e.readyState=0;var r=new j("error",{error:t});e.dispatchEvent(r),D(e,e.onerror,r),null!=t&&console.error(t)}},J=function(){x=2,null!=w&&(w.abort(),w=void 0),0!==C&&(o(C),C=0),e.readyState=2},G=function(){if(C=0,x===q){p=!1,d=0,C=n((function(){G()}),l),x=0,S="",R="",O=h,F="",N=0,z=0,U=0;var r=t;if("data:"!==t.slice(0,5)&&"blob:"!==t.slice(0,5)&&""!==h){var o=t.indexOf("?");r=-1===o?t:t.slice(0,o+1)+t.slice(o+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(e,t){return t===u?"":e})),r+=(-1===t.indexOf("?")?"?":"&")+u+"="+encodeURIComponent(h)}var i=e.withCredentials,s={Accept:"text/event-stream"},a=e.headers;if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(s[c]=a[c]);try{w=b.open(v,L,H,B,r,i,s)}catch(e){throw J(),e}}else if(p||null==w){var f=Math.max((p||Date.now())+l-Date.now(),1);p=!1,C=n((function(){G()}),f)}else B(new Error("No activity within "+l+" milliseconds. "+(0===x?"No response received.":d+" chars received.")+" Reconnecting.")),null!=w&&(w.abort(),w=void 0)};e.url=t,e.readyState=0,e.withCredentials=a,e.headers=y,e._close=J,G()}(this,e,t)}var M=null!=h&&null!=f&&"body"in f.prototype;F.prototype=Object.create(S.prototype),F.prototype.CONNECTING=0,F.prototype.OPEN=1,F.prototype.CLOSED=2,F.prototype.close=function(){this._close()},F.CONNECTING=0,F.OPEN=1,F.CLOSED=2,F.prototype.withCredentials=void 0;var U=u;null==i||null!=u&&"withCredentials"in u.prototype||(U=F),function(){var r=function(e){e.EventSourcePolyfill=F,e.NativeEventSource=u,e.EventSource=U}(t);void 0!==r&&(e.exports=r)}()}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:qn:globalThis)}(jn,jn.exports)),jn.exports}function $n(){return An?Tn:(An=1,Tn=In().EventSourcePolyfill)}var Pn=$n(),kn=t({__proto__:null,default:On(Pn)},[Pn]);e.BasePatch=ar,e.BaseTransaction=hr,e.ChannelError=Zt,e.ClientError=Et,e.ConnectionFailedError=Yt,e.CorsOriginError=Rt,e.DisconnectError=Kt,e.MessageError=er,e.MessageParseError=tr,e.ObservablePatch=ur,e.ObservableSanityClient=Zr,e.ObservableTransaction=pr,e.Patch=cr,e.SanityClient=en,e.ServerError=xt,e.Transaction=fr,e.connectEventSource=nr,e.createClient=nn,e.default=on,e.requester=rn,e.unstable__adapter=v,e.unstable__environment="browser",e.validateApiPerspective=Xt,Object.defineProperty(e,"__esModule",{value:!0})}));