1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[570],{53010:function(e){e.exports=function equal(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;if(Array.isArray(e)){if((r=e.length)!=t.length)return!1;for(n=r;0!=n--;)if(!equal(e[n],t[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((r=(o=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(n=r;0!=n--;)if(!Object.prototype.hasOwnProperty.call(t,o[n]))return!1;for(n=r;0!=n--;){var r,n,o,i=o[n];if(!equal(e[i],t[i]))return!1}return!0}return e!=e&&t!=t}},2570:function(e,t,r){r.r(t),r.d(t,{default:function(){return v}});var n,o=r(57437),i=r(15266),a=r(53010),s=r(18180),c=r(85347);function throttle(e,t,r){var n,o=r||{},i=o.noTrailing,a=void 0!==i&&i,s=o.noLeading,c=void 0!==s&&s,u=o.debounceMode,l=void 0===u?void 0:u,d=!1,f=0;function clearExistingTimeout(){n&&clearTimeout(n)}function cancel(e){var t=(e||{}).upcomingOnly;clearExistingTimeout(),d=!(void 0!==t&&t)}function wrapper(){for(var r=arguments.length,o=Array(r),i=0;i<r;i++)o[i]=arguments[i];var s=this,u=Date.now()-f;function exec(){f=Date.now(),t.apply(s,o)}function clear(){n=void 0}!d&&(c||!l||n||exec(),clearExistingTimeout(),void 0===l&&u>e?c?(f=Date.now(),a||(n=setTimeout(l?clear:exec,e))):exec():!0!==a&&(n=setTimeout(l?clear:exec,void 0===l?e-u:e)))}return wrapper.cancel=cancel,wrapper}var u=r(58853);function isDraft(e){return e._id.startsWith("drafts.")}function getPublishedId(e){return isDraft(e)?e._id.slice(7):e._id}let isNativeBrowserEventSource=e=>"undefined"!=typeof window&&e.addEventListener===window.EventSource.prototype.addEventListener,isPolyfillEventSource=e=>!isNativeBrowserEventSource(e),addEventSourceListener=(e,t,r)=>{isPolyfillEventSource(e)?e.addEventListener(t,r):e.addEventListener(t,r,!1)},encodeQueryString=e=>{let{query:t,params:r={},options:n={}}=e,o=new URLSearchParams,{tag:i,...a}=n;for(let[e,n]of(i&&o.set("tag",i),o.set("query",t),Object.entries(r)))o.set("$".concat(e),JSON.stringify(n));for(let[e,t]of Object.entries(a))t&&o.set(e,"".concat(t));return"?".concat(o)};function listen(e,t,r){let{projectId:n,dataset:o,token:i,includeTypes:a,requestTagPrefix:s}=t,c=s?{tag:s,effectFormat:"mendoza"}:{effectFormat:"mendoza"},u=encodeQueryString(Array.isArray(a)&&a.length>0?{query:"*[_type in $includeTypes]",params:{includeTypes:a},options:c}:{query:"*",options:c}),l="https://".concat(n,".api.sanity.io/v1/data/listen/").concat(o).concat(u),d=new e(l,{withCredentials:!0,headers:i?{Authorization:"Bearer ".concat(i)}:void 0});return addEventSourceListener(d,"welcome",r.open),addEventSourceListener(d,"mutation",getMutationParser(r.next)),addEventSourceListener(d,"channelError",e=>{let t;d.close();try{t=JSON.parse(e.data)}catch(e){r.error(Error("Unknown error parsing listener message"));return}r.error(Error(t.message||t.error||"Listener returned HTTP ".concat(t.statusCode)))}),addEventSourceListener(d,"error",e=>{let t="undefined"!=typeof window&&window.location.origin,n=isErrorLike(e)?" (".concat(e.message,")"):"";r.error(Error("Error establishing listener - check that the project ID and dataset are correct".concat(t?", and that the CORS-origin (".concat(t,") is allowed"):"").concat(n)))}),{unsubscribe:()=>Promise.resolve(d.close())}}function getMutationParser(e){return t=>{let r;try{r=JSON.parse(t.data)}catch(e){return}e(r)}}function isErrorLike(e){return"object"==typeof e&&null!==e&&"message"in e}function applyPatchWithoutRev(e,t){let r={...e};return delete r._rev,(0,u.a)(r,t)}function compareString(e,t){return e>t?1:e<t?-1:0}function noop(){return Promise.resolve()}function getSyncingDataset(e,t,r){let n,o,i,a,s,c,{getDocuments:u,EventSource:l}=r,{projectId:d,dataset:f,listen:p,overlayDrafts:h,documentLimit:m,token:v,includeTypes:g,requestTagPrefix:y}=e,onUpdate=e=>{n=void 0,i=void 0,o=void 0;let r=h?overlay(e):e;r.sort((e,t)=>
1compareString(e._id,t._id)),t(r)},w=h?e=>{let{_ref:t}=e,r=b.get("drafts.".concat(t))||b.get(t);return r?isDraft(r)?Promise.resolve(pretendThatItsPublished(r)):Promise.resolve({...r,_originalId:r._id}):Promise.resolve(r)}:e=>{let{_ref:t}=e;return Promise.resolve(b.get(t))};if(!p){let e=u({projectId:d,dataset:f,documentLimit:m,token:v,includeTypes:g,requestTagPrefix:y}).then(onUpdate).then(noop);return{unsubscribe:noop,loaded:e,dereference:w}}let b=new Map,S=[],E=new Promise((e,t)=>{s=e,c=t}),onOpen=async()=>{let e=await u({projectId:d,dataset:f,documentLimit:m,token:v,includeTypes:g,requestTagPrefix:y});(a=applyBufferedMutations(e,S)).forEach(e=>b.set(e._id,e)),onUpdate(a),s()},P=listen(l,e,{next:e=>{a?(applyMutation(e),scheduleUpdate(a,e)):S.push(e)},open:onOpen,error:e=>c(e)}),scheduleUpdate=(e,t)=>{clearTimeout(i),o!==t.transactionId&&n?(onUpdate(n),o=void 0):(o=t.transactionId,n=e.slice()),i=setTimeout(onUpdate,25,e.slice())},applyMutation=e=>{if(!e.effects||e.documentId.startsWith("_."))return;let t=b.get(e.documentId)||null;replaceDocument(e.documentId,applyPatchWithoutRev(t,e.effects.apply))},replaceDocument=(e,t)=>{let r=b.get(e),n=a||[],o=r?n.indexOf(r):-1;-1===o&&t?(n.push(t),b.set(e,t)):t?(n.splice(o,1,t),b.set(e,t)):(n.splice(o,1),b.delete(e))};return{unsubscribe:P.unsubscribe,loaded:E,dereference:w}}function applyBufferedMutations(e,t){let r=new Map;return t.forEach(e=>{let t=r.get(e.documentId)||[];t.push(e),r.set(e.documentId,t)}),r.forEach((t,r)=>{let n=e.find(e=>e._id===r);if(!n){console.warn("Received mutation for missing document %s",r);return}let o=!1,i=n;t.forEach(e=>{(o=o||e.previousRev===n._rev)&&e.effects&&(i=applyPatchWithoutRev(i,e.effects.apply))}),e.splice(e.indexOf(n),1,i)}),e}function overlay(e){let t=new Map;return e.forEach(e=>{let r=t.get(getPublishedId(e));e._id.startsWith("drafts.")?t.set(getPublishedId(e),pretendThatItsPublished(e)):r||t.set(e._id,{...e,_originalId:e._id})}),Array.from(t.values())}function pretendThatItsPublished(e){return{...e,_id:getPublishedId(e),_originalId:e._id}}var l=Object.freeze,d=Object.defineProperty,__template=(e,t)=>
1l(d(e,"raw",{value:l(t||e.slice())}));function groqStore$1(e,t){let r,o=[],i=throttle(e.subscriptionThrottleMs||50,executeAllSubscriptions),u=[];async function loadDataset(){r||(r=getSyncingDataset(e,e=>{o=e,i()},t)),await r.loaded}async function query(e,t){await loadDataset();let n=(0,c.Qc)(e,{params:t}),i=await (0,c.ku)(n,{dataset:o,params:t,dereference:r.dereference});return i.get()}async function getDocument(e){return await loadDataset(),query((0,s.Z)(n||(n=__template(["*[_id == $id][0]"]))),{id:e})}async function getDocuments(e){await loadDataset();let t=e.map(e=>'*[_id == "'.concat(e,'"][0]')).join(",\n");return query("[".concat(t,"]"))}function executeQuerySubscription(e){return query(e.query,e.params).then(t=>{"previousResult"in e&&a(e.previousResult,t)||(e.previousResult=t,e.callback(void 0,t))}).catch(t=>{e.callback(t)})}function executeAllSubscriptions(){u.forEach(executeQuerySubscription)}return{query,getDocument,getDocuments,subscribe:function(t,r,n){if(!e.listen)throw Error("Cannot use `subscribe()` without `listen: true`");let o={query:t,params:r,callback:n};u.push(o);let i=!1;return executeQuerySubscription(o),{unsubscribe:()=>(i||(i=!0,u.splice(u.indexOf(o),1)),Promise.resolve())}},close:function(){return i.cancel(),r?r.unsubscribe():Promise.resolve()}}}let getDocuments=async function(e){let t,r,{projectId:n,dataset:o,token:i,documentLimit:a,includeTypes:s=[],requestTagPrefix:c}=e,u=new URL("https://".concat(n,".api.sanity.io/v1/data/export/").concat(o));c&&u.searchParams.set("tag",c),s.length>0&&u.searchParams.set("types",null==s?void 0:s.join(","));let l=await fetch(u,{credentials:"include",headers:i?{Authorization:"Bearer ".concat(i)}:void 0});if(200!==l.status)throw Error("Error streaming dataset: ".concat(getError(await l.json())));let d=getDocumentStream(l.body),f=d.getReader(),p=[];do{if(isStreamError(r=(t=await f.read()).value))throw Error("Error streaming dataset: ".concat(r.error));if(r&&isRelevantDocument(r)&&p.push(r),a&&p.length>a)throw f.cancel("Reached document limit"),Error("Error streaming dataset: Reached limit of ".concat(a," documents. Try using the includeTypes option to reduce the amount of documents, or increase the limit."))}while(!t.done);return p};function getDocumentStream(e){let t;if(!e)throw Error("Failed to read body from response");let r=!1;function cancel(){r=!0,t&&t.cancel()}return new ReadableStream({start(n){t=e.getReader();let o=new TextDecoder,i="";async function processResult(e){if(e.done){if(r)return;if(0===(i=i.trim()).length){n.close();return}n.enqueue(JSON.parse(i)),n.close();return}i+=o.decode(e.value,{stream:!0});let a=i.split("\n");for(let e=0;e<a.length-1;++e){let t=a[e].trim();if(0!==t.length)try{n.enqueue(JSON.parse(t))}catch(e){n.error(e),cancel();return}}if(i=a[a.length-1],t)try{processResult(await t.read())}catch(e){n.error(e)}}t.read().then(processResult).catch(e=>n.error(e))},cancel})}function isStreamError(e){return!!e&&"error"in e&&"object"==typeof e.error&&null!==e.error&&"description"in e.error&&"string"==typeof e.error.description&&!("_id"in e)}function getError(e){return"object"==typeof e&&"error"in e&&"message"in e?e.message||e.error:"<unknown error>"}function isRelevantDocument(e){return!e._id.startsWith("_.")}function assertEnvSupport(){let e=["EventSource","ReadableStream","fetch"].filter(e=>!(e in window));if(e.length>0)throw Error("Browser not supported. Missing browser APIs: ".concat(e.join(", ")))}function groqStore(e){var t;assertEnvSupport();let r=null!=(t=e.EventSource)?t:window.EventSource;if(e.token){if(!e.EventSource)throw Error("When the `token` option is used the `EventSource` option must also be provided.");if(e.EventSource===window.EventSource)throw Error("When the `token` option is used the `EventSource` option must also be provided. EventSource cannot be `window.EventSource`, as it does not support passing a token.")}return groqStore$1(e,{EventSource:r,getDocuments})}var f=r(2265),p=r(11595);let h=(0,f.memo)(function(e){let{children:t,logger:r,...n}=e,[a]=(0,f.useState)(()=>new Set),[s,c]=(0,p.tT)(a),[u]=(0,f.useState)(()=>new Map),[l]=(0,f.useState)(()=>groqStore({EventSource:e.token?i:void 0,listen:!0,overlayDrafts:!0,documentLimit:p.pm,subscriptionThrottleMs:1,...n})),d=(0,f.useMemo)(()=>n.listen?"Updates are applied in real-time. The cache is set to max ".concat(n.documentLimit||p.pm," documents."):"Updates require a manual refresh. The cache is set to max ".concat(n.documentLimit||p.pm," documents."),[n.documentLimit,n.listen]);(0,f.useEffect)(()=>{r&&r.log("[@sanity/preview-kit]: With the current configuration you can expect that: ".concat(d))},[r,d]);let[h,m]=(0,f.useState)(null);if(h)throw h;let[v]=(0,f.useState)(()=>function(e,t,r){let o=(0,p.nW)(t,r);return u.has(o)||u.set(o,e),{subscribe:e=>{if(a.has(o)||l.query(t,r).then(t=>
1{a.has(o)||(u.set(o,t),a.add(o),c(),e())},m),!n.listen)return()=>{};let i=l.subscribe(t,r,(t,r)=>{t?m(t):a.has(o)&&(u.set(o,r),e())});return()=>i.unsubscribe()},getSnapshot:()=>u.get(o)}});return(0,o.jsx)(p.iS.Provider,{value:v,children:(0,o.jsx)(p.Ts.Provider,{value:s,children:(0,o.jsx)(p.T_.Provider,{value:!0,children:t})})})}),m=(0,f.memo)(function(e){var t;let{children:r,client:n,cache:i,logger:a}=e,{projectId:s,dataset:c,token:u,perspective:l="previewDrafts",requestTagPrefix:d}=(0,f.useMemo)(()=>n.config(),[n]);return(0,o.jsx)(h,{projectId:s,dataset:c,token:u,logger:a,listen:null==(t=null==i?void 0:i.listen)||t,documentLimit:null==i?void 0:i.maxDocuments,overlayDrafts:"previewDrafts"===l,includeTypes:null==i?void 0:i.includeTypes,requestTagPrefix:d,children:r})});m.displayName="GroqStoreProvider";var v=m}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.