/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@vitest/snapshot@4.1.4/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import{parseErrorStacktrace}from"@vitest/utils/source-map";import{isObject,getCallLastIndex}from"@vitest/utils/helpers";import{positionToOffset,offsetToLineNumber,lineSplitRE}from"@vitest/utils/offset";import{plugins,format}from"@vitest/pretty-format";function getDefaultExportFromCjs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var hasRequiredNaturalCompare,naturalCompare$1={exports:{}};function requireNaturalCompare(){if(hasRequiredNaturalCompare)return naturalCompare$1.exports;hasRequiredNaturalCompare=1;
/*
	 * @version    1.4.0
	 * @date       2015-10-26
	 * @stability  3 - Stable
	 * @author     Lauri Rooden (https://github.com/litejs/natural-compare-lite)
	 * @license    MIT License
	 */
var t=function(t,e){var n,s,a=1,r=0,i=0,o=String.alphabet;function c(t,e,s){if(s){for(n=e;(s=c(t,n))<76&&s>65;)++n;return+t.slice(e-1,n)}return(s=o&&o.indexOf(t.charAt(e)))>-1?s+76:(s=t.charCodeAt(e)||0)<45||s>127?s:s<46?65:s<48?s-1:s<58?s+18:s<65?s-11:s<91?s+11:s<97?s-37:s<123?s+5:s-63}if((t+="")!=(e+=""))for(;a;)if(s=c(t,r++),a=c(e,i++),s<76&&a<76&&s>66&&a>66&&(s=c(t,r,r),a=c(e,i,r=n),i=n),s!=a)return s<a?-1:1;return 0};try{naturalCompare$1.exports=t}catch(e){String.naturalCompare=t}return naturalCompare$1.exports}var naturalCompareExports=requireNaturalCompare(),naturalCompare=getDefaultExportFromCjs(naturalCompareExports);const serialize$1=(t,e,n,s,a,r)=>{const i=t.getMockName(),o="vi.fn()"===i?"":` ${i}`;let c="";if(0!==t.mock.calls.length){const i=n+e.indent;c=` {${e.spacingOuter}${i}"calls": ${r(t.mock.calls,e,i,s,a)}${e.min?", ":","}${e.spacingOuter}${i}"results": ${r(t.mock.results,e,i,s,a)}${e.min?"":","}${e.spacingOuter}${n}}`}return`[MockFunction${o}]${c}`},test=t=>t&&!!t._isMockFunction,plugin={serialize:serialize$1,test:test},{DOMCollection:DOMCollection,DOMElement:DOMElement,Immutable:Immutable,ReactElement:ReactElement,ReactTestComponent:ReactTestComponent,AsymmetricMatcher:AsymmetricMatcher}=plugins;let PLUGINS=[ReactTestComponent,ReactElement,DOMElement,DOMCollection,Immutable,AsymmetricMatcher,plugin];function addSerializer(t){PLUGINS=[t].concat(PLUGINS)}function getSerializers(){return PLUGINS}function testNameToKey(t,e){return`${t} ${e}`}function keyToTestName(t){if(!/ \d+$/.test(t))throw new Error("Snapshot keys must end with a number.");return t.replace(/ \d+$/,"")}function getSnapshotData(t,e){const n=e.updateSnapshot,s=Object.create(null);let a="",r=!1;if(null!=t)try{a=t;new Function("exports",a)(s)}catch{}return"all"!==n&&"new"!==n||!a||(r=!0),{data:s,dirty:r}}function addExtraLineBreaks(t){return t.includes("\n")?`\n${t}\n`:t}function removeExtraLineBreaks(t){return t.length>2&&"\n"===t[0]&&t.endsWith("\n")?t.slice(1,-1):t}const escapeRegex=!0,printFunctionName=!1;function serialize(t,e=2,n={}){return normalizeNewlines(format(t,{escapeRegex:true,indent:e,plugins:getSerializers(),printFunctionName:false,...n}))}function escapeBacktickString(t){return t.replace(/`|\\|\$\{/g,"\\$&")}function printBacktickString(t){return`\`${escapeBacktickString(t)}\``}function normalizeNewlines(t){return t.replace(/\r\n|\r/g,"\n")}async function saveSnapshotFile(t,e,n){const s=Object.keys(e).sort(naturalCompare).map((t=>`exports[${printBacktickString(t)}] = ${printBacktickString(normalizeNewlines(e[t]))};`)),a=`${t.getHeader()}\n\n${s.join("\n\n")}\n`,r=await t.readSnapshotFile(n);null!=r&&r===a||await t.saveSnapshotFile(n,a)}function deepMergeArray(t=[],e=[]){const n=Array.from(t);return e.forEach(((e,s)=>{const a=n[s];Array.isArray(t[s])?n[s]=deepMergeArray(t[s],e):isObject(a)?n[s]=deepMergeSnapshot(t[s],e):n[s]=e})),n}function deepMergeSnapshot(t,e){if(isObject(t)&&isObject(e)){const n={...t};return Object.keys(e).forEach((s=>{isObject(e[s])&&!e[s].$$typeof?s in t?n[s]=deepMergeSnapshot(t[s],e[s]):Object.assign(n,{[s]:e[s]}):Array.isArray(e[s])?n[s]=deepMergeArray(t[s],e[s]):Object.assign(n,{[s]:e[s]})})),n}return Array.isArray(t)&&Array.isArray(e)?deepMergeArray(t,e):t}class DefaultMap extends Map{constructor(t,e){super(e),this.defaultFn=t}get(t){return this.has(t)||this.set(t,this.defaultFn(t)),super.get(t)}}class CounterMap extends DefaultMap{constructor(){super((()=>0))}_total;valueOf(){return this._total=this.total()}increment(t){void 0!==this._total&&this._total++,this.set(t,this.get(t)+1)}total(){if(void 0!==this._total)return this._total;let t=0;for(const e of this.values())t+=e;return t}}function memo(t){const e=new Map;return n=>(e.has(n)||e.set(n,t(n)),e.get(n))}async function saveInlineSnapshots(t,e){const n=(await import("magic-string")).default,s=new Set(e.map((t=>t.file)));await Promise.all(Array.from(s).map((async s=>{const a=e.filter((t=>t.file===s)),r=await t.readSnapshotFile(s);if(null==r)throw new Error(`cannot read ${s} when saving inline snapshot`);const i=new n(r);for(const t of a){replaceInlineSnap(r,i,positionToOffset(r,t.line,t.column),t.snapshot,t.assertionName)}const o=i.toString();o!==r&&await t.saveSnapshotFile(s,o)})))}const defaultStartObjectRegex=/(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\s\S]*\*\/\s*|\/\/.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))*\{/;function escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const buildStartObjectRegex=memo((t=>{const e=defaultStartObjectRegex.source.replace("toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot",escapeRegExp(t));return new RegExp(e)}));function replaceObjectSnap(t,e,n,s,a){let r=t.slice(n);const i=(a?buildStartObjectRegex(a):defaultStartObjectRegex).exec(r);if(!i)return!1;r=r.slice(i.index);let o=getCallLastIndex(r);if(null===o)return!1;o+=n+i.index;const c=getObjectShapeEndIndex(t,n+i.index+i[0].length),h=`, ${prepareSnapString(s,t,n)}`;return c===o?e.appendLeft(o,h):e.overwrite(c,o,h),!0}function getObjectShapeEndIndex(t,e){let n=1,s=0;for(;n!==s&&e<t.length;){const a=t[e++];"{"===a?n++:"}"===a&&s++}return e}function prepareSnapString(t,e,n){const s=offsetToLineNumber(e,n),a=e.split(lineSplitRE)[s-1].match(/^\s*/)[0]||"",r=a.includes("\t")?`${a}\t`:`${a}  `,i=t.trim().replace(/\\/g,"\\\\").split(/\n/g),o="`";return i.length<=1?`${o}${i.join("\n").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}${o}`:`${o}\n${i.map((t=>t?r+t:"")).join("\n").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}\n${a}${o}`}const defaultMethodNames=["toMatchInlineSnapshot","toThrowErrorMatchingInlineSnapshot"];function getCodeStartingAtIndex(t,e,n){for(const s of n){const n=e-s.length;if(n>=0&&t.slice(n,e)===s)return{code:t.slice(n),index:n}}return{code:t.slice(e),index:e}}const defaultStartRegex=/(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\s\S]*\*\/\s*|\/\/.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))*[\w$]*(['"`)])/,buildStartRegex=memo((t=>{const e=defaultStartRegex.source.replace("toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot",escapeRegExp(t));return new RegExp(e)}));function replaceInlineSnap(t,e,n,s,a){const r=a?[a]:defaultMethodNames,{code:i,index:o}=getCodeStartingAtIndex(t,n,r),c=(a?buildStartRegex(a):defaultStartRegex).exec(i),h=(a?new RegExp(escapeRegExp(a)):/toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot/).exec(i);if(!c||c.index!==h?.index)return replaceObjectSnap(t,e,o,s,a);const p=c[1],l=o+c.index+c[0].length,d=prepareSnapString(s,t,o);if(")"===p)return e.appendRight(l-1,d),!0;const u=new RegExp(`(?:^|[^\\\\])${p}`).exec(t.slice(l));if(!u)return!1;const m=l+u.index+u[0].length;return e.overwrite(l-1,m,d),!0}const INDENTATION_REGEX=/^([^\S\n]*)\S/m;function stripSnapshotIndentation(t){const e=t.match(INDENTATION_REGEX);if(!e||!e[1])return t;const n=e[1],s=t.split(/\n/g);if(s.length<=2)return t;if(""!==s[0].trim()||""!==s.at(-1)?.trim())return t;for(let e=1;e<s.length-1;e++)if(""!==s[e]){if(0!==s[e].indexOf(n))return t;s[e]=s[e].substring(n.length)}return s[s.length-1]="",t=s.join("\n")}async function saveRawSnapshots(t,e){await Promise.all(e.map((async e=>{e.readonly||await t.saveSnapshotFile(e.file,e.snapshot)})))}function isSameStackPosition(t,e){return t.file===e.file&&t.column===e.column&&t.line===e.line}class SnapshotState{_counters=new CounterMap;_dirty;_updateSnapshot;_snapshotData;_initialData;_inlineSnapshots;_inlineSnapshotStacks;_testIdToKeys=new DefaultMap((()=>[]));_rawSnapshots;_uncheckedKeys;_snapshotFormat;_environment;_fileExists;expand;_added=new CounterMap;_matched=new CounterMap;_unmatched=new CounterMap;_updated=new CounterMap;get added(){return this._added}set added(t){this._added._total=t}get matched(){return this._matched}set matched(t){this._matched._total=t}get unmatched(){return this._unmatched}set unmatched(t){this._unmatched._total=t}get updated(){return this._updated}set updated(t){this._updated._total=t}constructor(t,e,n,s){this.testFilePath=t,this.snapshotPath=e;const{data:a,dirty:r}=getSnapshotData(n,s);this._fileExists=null!=n,this._initialData={...a},this._snapshotData={...a},this._dirty=r,this._inlineSnapshots=[],this._inlineSnapshotStacks=[],this._rawSnapshots=[],this._uncheckedKeys=new Set(Object.keys(this._snapshotData)),this.expand=s.expand||!1,this._updateSnapshot=s.updateSnapshot,this._snapshotFormat={printBasicPrototype:!1,escapeString:!1,...s.snapshotFormat},this._environment=s.snapshotEnvironment}static async create(t,e){const n=await e.snapshotEnvironment.resolvePath(t),s=await e.snapshotEnvironment.readSnapshotFile(n);return new SnapshotState(t,n,s,e)}get snapshotUpdateState(){return this._updateSnapshot}get environment(){return this._environment}markSnapshotsAsCheckedForTest(t){this._uncheckedKeys.forEach((e=>{/ \d+$| > /.test(e.slice(t.length))&&this._uncheckedKeys.delete(e)}))}clearTest(t){this._inlineSnapshots=this._inlineSnapshots.filter((e=>e.testId!==t)),this._inlineSnapshotStacks=this._inlineSnapshotStacks.filter((e=>e.testId!==t));for(const e of this._testIdToKeys.get(t)){const t=keyToTestName(e),n=this._counters.get(t);n>0&&((e in this._snapshotData||e in this._initialData)&&(this._snapshotData[e]=this._initialData[e]),this._counters.set(t,n-1))}this._testIdToKeys.delete(t),this.added.delete(t),this.updated.delete(t),this.matched.delete(t),this.unmatched.delete(t)}_inferInlineSnapshotStack(t){const e=t.findIndex((t=>t.method.match(/__VITEST_(RESOLVES|REJECTS)__/)));if(-1!==e)return t[e+3];const n=t.findIndex((t=>t.method.match(/__VITEST_POLL_CHAIN__/)));if(-1!==n)return t[n+1];for(let e=0;e<t.length;e++){const n=t[e].method.match(/__INLINE_SNAPSHOT_OFFSET_(\d+)__/);if(n)return t[e+Number(n[1])]??null}const s=t.findIndex((t=>t.method.includes("__VITEST_EXTEND_ASSERTION__")));if(-1!==s)return t[s+3]??null;const a=t.findIndex((t=>t.method.includes("__INLINE_SNAPSHOT__")));return-1!==a?t[a+2]:null}_addSnapshot(t,e,n){this._dirty=!0,n.stack?this._inlineSnapshots.push({...n.stack,snapshot:e,testId:n.testId,assertionName:n.assertionName}):n.rawSnapshot?this._rawSnapshots.push({...n.rawSnapshot,snapshot:e}):this._snapshotData[t]=e}_resolveKey(t,e,n){this._counters.increment(e);const s=this._counters.get(e);return n||(n=testNameToKey(e,s)),this._testIdToKeys.get(t).push(n),{key:n,count:s}}_resolveInlineStack(t){const{testId:e,snapshot:n,assertionName:s,error:a}=t,r=parseErrorStacktrace(a,{ignoreStackEntries:[]}),i=this._inferInlineSnapshotStack(r);if(!i){const t=r.map((t=>`  ${t.file}:${t.line}:${t.column}${t.method?` (${t.method})`:""}`)).join("\n");throw new Error(`@vitest/snapshot: Couldn't infer stack frame for inline snapshot.\n${t}`)}const o=this.environment.processStackTrace?.(i)||i;o.column--;const c=this._inlineSnapshotStacks.filter((t=>isSameStackPosition(t,o)));if(c.length>0){this._inlineSnapshots=this._inlineSnapshots.filter((t=>!isSameStackPosition(t,o)));const t=c.find((t=>t.snapshot!==n));if(t)throw Object.assign(new Error(`${s} with different snapshots cannot be called at the same location`),{actual:n,expected:t.snapshot})}return this._inlineSnapshotStacks.push({...o,testId:e,snapshot:n}),o}_reconcile(t){return t.hasSnapshot&&"all"===this._updateSnapshot||!(t.hasSnapshot&&t.snapshotIsPersisted||"new"!==this._updateSnapshot&&"all"!==this._updateSnapshot)?("all"===this._updateSnapshot?t.pass?this.matched.increment(t.testId):(t.hasSnapshot?this.updated.increment(t.testId):this.added.increment(t.testId),this._addSnapshot(t.key,t.addValue,{stack:t.stack,testId:t.testId,rawSnapshot:t.rawSnapshot,assertionName:t.assertionName})):(this._addSnapshot(t.key,t.addValue,{stack:t.stack,testId:t.testId,rawSnapshot:t.rawSnapshot,assertionName:t.assertionName}),this.added.increment(t.testId)),{actual:"",count:t.count,expected:"",key:t.key,pass:!0}):t.pass?(this.matched.increment(t.testId),{actual:"",count:t.count,expected:"",key:t.key,pass:!0}):(this.unmatched.increment(t.testId),{actual:t.actualDisplay,count:t.count,expected:t.expectedDisplay,key:t.key,pass:!1})}async save(){const t=Object.keys(this._snapshotData).length,e=this._inlineSnapshots.length,n=this._rawSnapshots.length,s=!t&&!e&&!n,a={deleted:!1,saved:!1};return!this._dirty&&!this._uncheckedKeys.size||s?!t&&this._fileExists&&("all"===this._updateSnapshot&&(await this._environment.removeSnapshotFile(this.snapshotPath),this._fileExists=!1),a.deleted=!0):(t&&(await saveSnapshotFile(this._environment,this._snapshotData,this.snapshotPath),this._fileExists=!0),e&&await saveInlineSnapshots(this._environment,this._inlineSnapshots),n&&await saveRawSnapshots(this._environment,this._rawSnapshots),a.saved=!0),a}getUncheckedCount(){return this._uncheckedKeys.size||0}getUncheckedKeys(){return Array.from(this._uncheckedKeys)}removeUncheckedKeys(){"all"===this._updateSnapshot&&this._uncheckedKeys.size&&(this._dirty=!0,this._uncheckedKeys.forEach((t=>delete this._snapshotData[t])),this._uncheckedKeys.clear())}probeExpectedSnapshot(t){const e=this._counters.get(t.testName)+1,n=testNameToKey(t.testName,e);return{key:n,count:e,data:t?.isInline?t.inlineSnapshot:this._snapshotData[n],markAsChecked:()=>{this._counters.increment(t.testName),this._testIdToKeys.get(t.testId).push(n),this._uncheckedKeys.delete(n)}}}match({testId:t,testName:e,received:n,key:s,inlineSnapshot:a,isInline:r,error:i,rawSnapshot:o,assertionName:c}){const h=this._resolveKey(t,e,s);s=h.key;const p=h.count;r&&void 0!==this._snapshotData[s]||this._uncheckedKeys.delete(s);let l=o&&"string"==typeof n?n:serialize(n,void 0,this._snapshotFormat);o||(l=addExtraLineBreaks(l)),o&&o.content&&o.content.match(/\r\n/)&&!l.match(/\r\n/)&&(o.content=normalizeNewlines(o.content));const d=r?a:o?o.content:this._snapshotData[s],u=o?d:d?.trim(),m=u===(o?l:l.trim()),S=void 0!==d,f=r||this._fileExists||o&&null!=o.content;!m||r||o||(this._snapshotData[s]=l);const _=r?this._resolveInlineStack({testId:t,snapshot:l,assertionName:c||"toMatchInlineSnapshot",error:i||new Error("snapshot")}):void 0;return this._reconcile({testId:t,key:s,count:p,pass:m,hasSnapshot:S,snapshotIsPersisted:!!f,addValue:l,actualDisplay:o?l:removeExtraLineBreaks(l),expectedDisplay:void 0!==u?o?u:removeExtraLineBreaks(u):void 0,stack:_,rawSnapshot:o,assertionName:c})}processDomainSnapshot({testId:t,received:e,expectedSnapshot:n,matchResult:s,isInline:a,error:r,assertionName:i}){const o=a?this._resolveInlineStack({testId:t,snapshot:e,assertionName:i,error:r||new Error("STACK_TRACE_ERROR")}):void 0,c=s?.resolved??e,h=s?.expected??n.data;return this._reconcile({testId:t,key:n.key,count:n.count,pass:s?.pass??!1,hasSnapshot:!!n.data,snapshotIsPersisted:!!a||this._fileExists,addValue:c,actualDisplay:removeExtraLineBreaks(c),expectedDisplay:void 0!==h?removeExtraLineBreaks(h):void 0,stack:o,assertionName:i})}async pack(){const t={filepath:this.testFilePath,added:0,fileDeleted:!1,matched:0,unchecked:0,uncheckedKeys:[],unmatched:0,updated:0},e=this.getUncheckedCount(),n=this.getUncheckedKeys();e&&this.removeUncheckedKeys();const s=await this.save();return t.fileDeleted=s.deleted,t.added=this.added.total(),t.matched=this.matched.total(),t.unmatched=this.unmatched.total(),t.updated=this.updated.total(),t.unchecked=s.deleted?0:e,t.uncheckedKeys=Array.from(n),t}}function createMismatchError(t,e,n,s){const a=new Error(t);return Object.defineProperty(a,"actual",{value:n,enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,"expected",{value:s,enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,"diffOptions",{value:{expand:e}}),a}class SnapshotClient{snapshotStateMap=new Map;constructor(t={}){this.options=t}async setup(t,e){this.snapshotStateMap.has(t)||this.snapshotStateMap.set(t,await SnapshotState.create(t,e))}async finish(t){const e=this.getSnapshotState(t),n=await e.pack();return this.snapshotStateMap.delete(t),n}skipTest(t,e){this.getSnapshotState(t).markSnapshotsAsCheckedForTest(e)}clearTest(t,e){this.getSnapshotState(t).clearTest(e)}getSnapshotState(t){const e=this.snapshotStateMap.get(t);if(!e)throw new Error(`The snapshot state for '${t}' is not found. Did you call 'SnapshotClient.setup()'?`);return e}match(t){const{filepath:e,name:n,testId:s=n,message:a,isInline:r=!1,properties:i,inlineSnapshot:o,error:c,errorMessage:h,rawSnapshot:p,assertionName:l}=t;let{received:d}=t;if(!e)throw new Error("Snapshot cannot be used outside of test");const u=this.getSnapshotState(e),m=[n,...a?[a]:[]].join(" > "),S=u.probeExpectedSnapshot({testName:m,testId:s,isInline:r,inlineSnapshot:o});if("object"==typeof i){if("object"!=typeof d||!d)throw S.markAsChecked(),new Error("Received value must be an object when the matcher has properties");let t;try{t=this.options.isEqual?.(d,i)??!1}catch(t){throw S.markAsChecked(),t}if(!t)return S.markAsChecked(),{pass:!1,message:()=>h||"Snapshot properties mismatched",actual:d,expected:i};d=deepMergeSnapshot(d,i)}const{actual:f,expected:_,key:g,pass:k}=u.match({testId:s,testName:m,received:d,isInline:r,error:c,inlineSnapshot:o,rawSnapshot:p,assertionName:l});return{pass:k,message:()=>`Snapshot \`${g||"unknown"}\` mismatched`,actual:p?f:f?.trim(),expected:p?_:_?.trim()}}assert(t){const e=this.match(t);if(!e.pass){const n=this.getSnapshotState(t.filepath);throw createMismatchError(e.message(),n.expand,e.actual,e.expected)}}matchDomain(t){const{received:e,filepath:n,name:s,testId:a=s,message:r,adapter:i,isInline:o=!1,inlineSnapshot:c,error:h}=t;if(!n)throw new Error("Snapshot cannot be used outside of test");const p=i.capture(e),l=i.render(p),d=this.getSnapshotState(n),u=[s,...r?[r]:[]].join(" > "),m=d.probeExpectedSnapshot({testName:u,testId:a,isInline:o,inlineSnapshot:c});m.markAsChecked();const S=m.data?i.match(p,i.parseExpected(m.data)):void 0,{actual:f,expected:_,key:g,pass:k}=d.processDomainSnapshot({testId:a,received:l,expectedSnapshot:m,matchResult:S,isInline:o,error:h,assertionName:t.assertionName});return{pass:k,message:()=>`Snapshot \`${g}\` mismatched`,actual:f?.trim(),expected:_?.trim()}}async pollMatchDomain(t){const{poll:e,filepath:n,name:s,testId:a=s,message:r,adapter:i,isInline:o=!1,inlineSnapshot:c,error:h,timeout:p=1e3,interval:l=50}=t;if(!n)throw new Error("Snapshot cannot be used outside of test");const d=this.getSnapshotState(n),u=[s,...r?[r]:[]].join(" > "),m=d.probeExpectedSnapshot({testName:u,testId:a,isInline:o,inlineSnapshot:c}),S=m.data&&"all"!==d.snapshotUpdateState?i.parseExpected(m.data):void 0,f=p>0?new Promise((t=>setTimeout(t,p))):void 0,_=await getStableSnapshot({adapter:i,poll:e,interval:l,timedOut:f,match:S?t=>i.match(t,S).pass:void 0});if(m.markAsChecked(),!_?.rendered){if(_?.lastPollError)throw _.lastPollError;return{pass:!1,message:()=>"poll() did not produce a stable snapshot within the timeout"}}const g=m.data?i.match(_.captured,i.parseExpected(m.data)):void 0,{actual:k,expected:w,key:y,pass:x}=d.processDomainSnapshot({testId:a,received:_.rendered,expectedSnapshot:m,matchResult:g,isInline:o,error:h,assertionName:t.assertionName});return{pass:x,message:()=>`Snapshot \`${y}\` mismatched`,actual:k?.trim(),expected:w?.trim()}}async assertRaw(t){if(!t.rawSnapshot)throw new Error("Raw snapshot is required");const{filepath:e,rawSnapshot:n}=t;if(null==n.content){if(!e)throw new Error("Snapshot cannot be used outside of test");const s=this.getSnapshotState(e);t.filepath||=e,n.file=await s.environment.resolveRawPath(e,n.file),n.content=await s.environment.readSnapshotFile(n.file)??void 0}return this.assert(t)}clear(){this.snapshotStateMap.clear()}}async function getStableSnapshot({adapter:t,poll:e,interval:n,timedOut:s,match:a}){let r,i,o;for(;;){try{const n=await raceWith(Promise.resolve(e()),s);if(!n.ok)break;const i=t.capture(n.value),c=t.render(i);if(void 0!==r&&c===r){if(o={captured:i,rendered:c},!a||a(i))break}else r=c,o=void 0}catch(t){r=void 0,o=void 0,i=t}if(!(await raceWith(new Promise((t=>setTimeout(t,n))),s)).ok)break}return{...o,lastPollError:i}}function raceWith(t,e){const n=t.then((t=>({ok:!0,value:t})));return e?Promise.race([n,e.then((t=>({ok:!1,value:t})))]):n}export{SnapshotClient,SnapshotState,addSerializer,getSerializers,stripSnapshotIndentation};
//# sourceMappingURL=/sm/743ffef4159244c804d17a8721ad9dfb38bf30ed0a1efbbe491d53bb9b9f2d82.map