var__create=Object.create;var__defProp=Object.defineProperty;var__getOwnPropDesc=Object.getOwnPropertyDescriptor;var__getOwnPropNames=Object.getOwnPropertyNames;var__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var__require=(x2=>typeofrequire<"u"?require:typeofProxy<"u"?newProxy(x2,{get:(a,b2)=>(typeofrequire<"u"?require:a)[b2]}):x2)(function(x2){if(typeofrequire<"u")returnrequire.apply(this,arguments);throwError('Dynamic require of "'+x2+'" is not supported')});var__commonJS=(cb,mod)=>function(){returnmod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var__export=(target,all)=>{for(varname2inall)__defProp(target,name2,{get:all[name2],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeoffrom=="object"||typeoffrom=="function")for(letkey2of__getOwnPropNames(from))!__hasOwnProp.call(to,key2)&&key2!==except&&__defProp(to,key2,{get:()=>from[key2],enumerable:!(desc=__getOwnPropDesc(from,key2))||desc.enumerable});returnto};var__toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod));varrequire_memoizerific=__commonJS({"../../node_modules/memoizerific/memoizerific.js"(exports,module){"use strict";(function(f3){if(typeofexports=="object"&&typeofmodule<"u")module.exports=f3();elseif(typeofdefine=="function"&&define.amd)define([],f3);else{varg;typeofwindow<"u"?g=window:typeofglobal<"u"?g=global:typeofself<"u"?g=self:g=this,g.memoizerific=f3()}})(function(){vardefine2,module2,exports2;returnfunctione(t,n,r){functions(o2,u2){if(!n[o2]){if(!t[o2]){vara=typeof__require=="function"&&__require;if(!u2&&a)returna(o2,!0);if(i)returni(o2,!0);varf3=newError("Cannot find module '"+o2+"'");throwf3.code="MODULE_NOT_FOUND",f3}varl=n[o2]={exports:{}};t[o2][0].call(l.exports,function(e2){varn2=t[o2][1][e2];returns(n2||e2)},l,l.exports,e,t,n,r)}returnn[o2].exports}for(vari=typeof__require=="function"&&__require,o=0;o<r.length;o++)s(r[o]);returns}({1:[function(_dereq_,module3,exports3){module3.exports=function(forceSimilar){if(typeofMap!="function"||forceSimilar){varSimilar=_dereq_("./similar");returnnewSimilar}elsereturnnewMap}},{"./similar":2}],2:[function(_dereq_,module3,exports3){functionSimilar(){returnthis.list=[],this.lastItem=void0,this.size=0,this}Similar.prototype.get=function(key2){varindex;if(this.lastItem&&this.isEqual(this.lastItem.key,key2))returnthis.lastItem.val;if(index=this.indexOf(key2),index>=0)returnthis.lastItem=this.list[index],this.list[index].val},Similar.prototype.set=function(key2,val){varindex;returnthis.lastItem&&this.isEqual(this.lastItem.key,key2)?(this.lastItem.val=val,this):(index=this.indexOf(key2),index>=0?(this.lastItem=this.list[index],this.list[index].val=val,this):(this.lastItem={key:key2,val},this.list.push(this.lastItem),this.size++,this))},Similar.prototype.delete=function(key2){varindex;if(this.lastItem&&this.isEqual(this.lastItem.key,key2)&&(this.lastItem=void0),index=this.indexOf(key2),index>=0)returnthis.size--,this.list.splice(index,1)[0]},Similar.prototype.has=function(key2){varindex;returnthis.lastItem&&this.isEqual(this.lastItem.key,key2)?!0:(index=this.indexOf(key2),index>=0?(this.lastItem=this.list[index],!0):!1)},Similar.prototype.forEach=function(callback,thisArg){vari;for(i=0;i<this.size;i++)callback.call(thisArg||this,this.list[i].val,this.list[i].key,this)},Similar.prototype.indexOf=function(key2){vari;for(i=0;i<this.size;i++)if(this.isEqual(this.list[i].key,key2))returni;return-1},Similar.prototype.isEqual=function(val1,val2){returnval1===val2||val1!==val1&&val2!==val2},module3.exports=Similar},{}],3:[function(_dereq_,module3,exports3){varMapOrSimilar=_dereq_("map-or-similar");module3.exports=function(limit){varcache=newMapOrSimilar(!1),lru=[];returnfunction(fn){varmemoizerific=function(){varcurrentCache=cache,newMap,fnResult,argsLengthMinusOne=arguments.length-1,lruPath=Array(argsLengthMinusOne+1
Seehttps://github.com/storybookjs/storybook/blob/next/MIGRATION.md#hoisted-csf-annotations for details and codemod.
`,deprecatedStoryAnnotationWarning=(0,import_util_deprecate.default)(()=>{},deprecatedStoryAnnotation);function normalizeStory(key2,storyAnnotations,meta){let storyObject=storyAnnotations,userStoryFn=typeof storyAnnotations=="function"?storyAnnotations:null,{story}=storyObject;story&&(logger.debug("deprecated story",story),deprecatedStoryAnnotationWarning());let exportName=M(key2),name2=typeof storyObject!="function"&&storyObject.name||storyObject.storyName||story?.name||exportName,decorators=[...normalizeArrays(storyObject.decorators),...normalizeArrays(story?.decorators)],parameters={...story?.parameters,...storyObject.parameters},args2={...story?.args,...storyObject.args},argTypes={...story?.argTypes,...storyObject.argTypes},loaders=[...normalizeArrays(storyObject.loaders),...normalizeArrays(story?.loaders)],{render,play,tags=[]}=storyObject,id=parameters.__id||N(meta.id,exportName);return{moduleExport:storyAnnotations,id,name:name2,tags,decorators,parameters,args:args2,argTypes:normalizeInputTypes(argTypes),loaders,...render&&{render},...userStoryFn&&{userStoryFn},...play&&{play}}}function normalizeComponentAnnotations(defaultExport,title=defaultExport.title,importPath){let{id,argTypes}=defaultExport;return{id:L(id||title),...defaultExport,title,...argTypes&&{argTypes:normalizeInputTypes(argTypes)},parameters:{fileName:importPath,...defaultExport.parameters}}}var checkGlobals=parameters=>{let{globals,globalTypes}=parameters;(globals||globalTypes)&&logger.error("Global args/argTypes can only be set globally",JSON.stringify({globals,globalTypes}))},checkStorySort=parameters=>{let{options:options2}=parameters;options2?.storySort&&logger.error("The storySort option parameter can only be set globally")},checkDisallowedParameters=parameters=>{parameters&&(checkGlobals(parameters),checkStorySort(parameters))},checkSubcomponents=meta=>{meta.subcomponents&&deprecate(esm_default`The\`subcomponents\` annotation is deprecated.
`):err}return{v:4,entries:sortedV7.reduce((acc,s)=>(acc[s.id]=this.entries[s.id],acc),{})}}clearFilenameExports(fileName){this.csfExports[fileName]&&(Object.entries(this.entries).forEach(([id,{importPath}])=>{importPath===fileName&&delete this.entries[id]}),this.csfExports[fileName]={})}addStoriesFromExports(fileName,fileExports){if(fileName.match(/\.mdx$/)&&!fileName.match(/\.stories\.mdx$/)&&scope.FEATURES?.storyStoreV7MdxErrors!==!1)throw new Error(dedent`
Cannotindex\`.mdx\` file (\`${fileName}\`) in \`storyStoreV7: false\` mode.
Thelegacystorystoredoesnotsupportnew-style\`.mdx\` files. If the file above
excludeitfromyour\`stories\` glob, or add <Meta isTemplate /> to it.
Ifyouwantedtoindexthefile,you'llneedtonameit\`stories.mdx\` and stick to the
legacy(6.x)MDXAPI,orusethenewstore.`);if(this.csfExports[fileName]===fileExports)return;this.clearFilenameExports(fileName);let{default:defaultExport,__namedExportsOrder,...namedExports}=fileExports,{id:componentId,title,tags:componentTags=[]}=defaultExport||{},specifiers=(scope.STORIES||[]).map(specifier=>({...specifier,importPathMatcher:new RegExp(specifier.importPathMatcher)}));if(title=userOrAutoTitle(fileName,specifiers,title),!title){logger.info(`Unexpecteddefaultexportwithouttitlein'${fileName}':${JSON.stringify(fileExports.default)}`);return}this.csfExports[fileName]={...fileExports,default:{...defaultExport,title}};let sortedExports=namedExports;Array.isArray(__namedExportsOrder)&&(sortedExports={},__namedExportsOrder.forEach(name2=>{let namedExport=namedExports[name2];namedExport&&(sortedExports[name2]=namedExport)}));let storyExports=Object.entries(sortedExports).filter(([key2])=>G(key2,defaultExport)),docsOptions=scope.DOCS_OPTIONS||{},{autodocs}=docsOptions,componentAutodocs=componentTags.includes(AUTODOCS_TAG),autodocsOptedIn=autodocs===!0||autodocs==="tag"&&componentAutodocs;if(storyExports.length&&(componentTags.includes(STORIES_MDX_TAG)||autodocsOptedIn)){let name2=docsOptions.defaultName,docsId=N(componentId||title,name2);this.entries[docsId]={type:"docs",id:docsId,title,name:name2,importPath:fileName,...componentId&&{componentId},tags:[...componentTags,"docs",...autodocsOptedIn&&!componentAutodocs?[AUTODOCS_TAG]:[]],storiesImports:[]}}storyExports.forEach(([key2,storyExport])=>{let exportName=M(key2),id=storyExport.parameters?.__id||N(componentId||title,exportName),name2=typeof storyExport!="function"&&storyExport.name||storyExport.storyName||storyExport.story?.name||exportName;storyExport.parameters?.docsOnly||(this.entries[id]={type:"story",id,name:name2,title,importPath:fileName,...componentId&&{componentId},tags:[...storyExport.tags||componentTags,"story"]})})}},warningAlternatives={addDecorator:"Instead, use `exportconstdecorators=[];` in your `preview.js`.",addParameters:"Instead, use `exportconstparameters={};` in your `preview.js`.",addLoader:"Instead, use `exportconstloaders=[];` in your `preview.js`.",addArgs:"",addArgTypes:"",addArgsEnhancer:"",addArgTypesEnhancer:"",addStepRunner:"",getGlobalRender:"",setGlobalRender:""},checkMethod=method=>{if(scope.FEATURES?.storyStoreV7)throw new Error(dedent`Youcannotuse\`${method}\` with the new Story Store.
${warningAlternatives[method]}`);if(!scope.__STORYBOOK_CLIENT_API__)throw new Error(`SingletonclientAPInotyetinitialized,cannotcall\`${method}\`.`)},addDecorator=decorator=>{checkMethod("addDecorator"),scope.__STORYBOOK_CLIENT_API__?.addDecorator(decorator)},addParameters=parameters=>{checkMethod("addParameters"),scope.__STORYBOOK_CLIENT_API__?.addParameters(parameters)},addLoader=loader=>{checkMethod("addLoader"),scope.__STORYBOOK_CLIENT_API__?.addLoader(loader)},addArgs=args2=>{checkMethod("addArgs"),scope.__STORYBOOK_CLIENT_API__?.addArgs(args2)},addArgTypes=argTypes=>{checkMethod("addArgTypes"),scope.__STORYBOOK_CLIENT_API__?.addArgTypes(argTypes)},addArgsEnhancer=enhancer=>{checkMethod("addArgsEnhancer"),scope.__STORYBOOK_CLIENT_API__?.addArgsEnhancer(enhancer)},addArgTypesEnhancer=enhancer=>{checkMethod("addArgTypesEnhancer"),scope.__STORYBOOK_CLIENT_API__?.addArgTypesEnhancer(enhancer)},addStepRunner=stepRunner=>{checkMethod("addStepRunner"),scope.__STORYBOOK_CLIENT_API__?.addStepRunner(stepRunner)},setGlobalRender=render=>{checkMethod("setGlobalRender"),scope.__STORYBOOK_CLIENT_API__&&(scope.__STORYBOOK_CLIENT_API__.facade.projectAnnotations.render=render)},invalidStoryTypes=newSet(["string","number","boolean","symbol"]),ClientApi=class{constructor({storyStore}={}){this.lastFileName=0,this.addDecorator=decorator=>{this.facade.projectAnnotations.decorators?.push(decorator)},this.addParameters=({globals,globalTypes,...parameters})=>{this.facade.projectAnnotations.parameters=combineParameters(this.facade.projectAnnotations.parameters,parameters),globals&&(this.facade.projectAnnotations.globals={...this.facade.projectAnnotations.globals,...globals}),globalTypes&&(this.facade.projectAnnotations.globalTypes={...this.facade.projectAnnotations.globalTypes,...normalizeInputTypes(globalTypes)})},this.addStepRunner=stepRunner=>{this.facade.projectAnnotations.runStep=composeStepRunners([this.facade.projectAnnotations.runStep,stepRunner].filter(Boolean))},this.addLoader=loader=>{this.facade.projectAnnotations.loaders?.push(loader)},this.addArgs=args2=>{this.facade.projectAnnotations.args={...this.facade.projectAnnotations.args,...args2}},this.addArgTypes=argTypes=>{this.facade.projectAnnotations.argTypes={...this.facade.projectAnnotations.argTypes,...normalizeInputTypes(argTypes)}},this.addArgsEnhancer=enhancer=>{this.facade.projectAnnotations.argsEnhancers?.push(enhancer)},this.addArgTypesEnhancer=enhancer=>{this.facade.projectAnnotations.argTypesEnhancers?.push(enhancer)},this._addedExports={},this.storiesOf=(kind,m2)=>{if(!kind&&typeofkind!="string")thrownewError("Invalid or missing kind provided for stories, should be a string");if(m2||logger.warn(`Missing 'module' parameter for story with a kind of '${kind}'. It will break your HMR`),m2){letproto=Object.getPrototypeOf(m2);proto.exports&&proto.exports.default&&logger.error(`Illegal mix of CSF default export and storiesOf calls in a single file: ${proto.i}`)}letbaseFilename=m2&&m2.id?`${m2.id}`:(this.lastFileName++).toString(),fileName=baseFilename,i=1;for(;this._addedExports[fileName];)i+=1,fileName=`${baseFilename}-${i}`;m2&&m2.hot&&m2.hot.accept&&(m2.hot.accept(),m2.hot.dispose(()=>{this.facade.clearFilenameExports(fileName),deletethis._addedExports[fileName],setTimeout(()=>{this._loadAddedExports(),this.onImportFnChanged?.({importFn:this.importFn.bind(this)})},0)}));lethasAdded=!1,api={kind:kind.toString(),add:()=>api,addDecorator:()=>api,addLoader:()=>api,addParameters:()=>api};Object.keys(this.addons).forEach(name2=>{letaddon=this.addons[name2];api[name2]=(...args2)=>(addon.apply(api,args2),api)});letmeta={id:L(kind),title:kind,decorators:[],loaders:[],parameters:{}};this._addedExports[fileName]={default:meta};letcounter=0;returnapi.add=(storyName,storyFn,parameters={})=>{if(hasAdded=!0,typeofstoryName!="string")thrownewError(`Invalid or missing storyName provided for a "${kind}" story.`);if(!storyFn||Array.isArray(storyFn)||invalidStoryTypes.has(typeofstoryFn))thrownewError(`Cannot load story "${storyName}" in "${kind}" due to invali
Readmorehere:https://github.com/storybookjs/storybook/blob/master/MIGRATION.md#can-no-longer-add-decoratorsparameters-after-stories`);return meta.decorators?.push(decorator),api},api.addLoader=loader=>{if(hasAdded)throw new Error("You cannot add a loader after the first story for a kind.");return meta.loaders?.push(loader),api},api.addParameters=({component,args:args2,argTypes,tags,...parameters})=>{if(hasAdded)throw new Error(`You cannot add parameters after the first story for a kind.
Readmorehere:https://github.com/storybookjs/storybook/blob/master/MIGRATION.md#can-no-longer-add-decoratorsparameters-after-stories`);return meta.parameters=combineParameters(meta.parameters,parameters),component&&(meta.component=component),args2&&(meta.args={...meta.args,...args2}),argTypes&&(meta.argTypes={...meta.argTypes,...argTypes}),tags&&(meta.tags=tags),api},api},this.raw=()=>this.storyStore?.raw(),this.facade=new StoryStoreFacade,this.addons={},this.storyStore=storyStore}importFn(path){return this.facade.importFn(path)}getStoryIndex(){if(!this.storyStore)throw new Error("Cannot get story index before setting storyStore");return this.facade.getStoryIndex(this.storyStore)}_loadAddedExports(){Object.entries(this._addedExports).forEach(([fileName,fileExports])=>this.facade.addStoriesFromExports(fileName,fileExports))}get _storyStore(){return this.storyStore}},getQueryParams=()=>{let{document:document4}=scope;return document4&&document4.location&&document4.location.search?(0,import_qs2.parse)(document4.location.search,{ignoreQueryPrefix:!0}):{}},getQueryParam=key2=>getQueryParams()[key2];var import_synchronous_promise3=__toESM(require_synchronous_promise(),1);var import_qs3=__toESM(require_lib(),1),import_isPlainObject2=__toESM(require_isPlainObject(),1),require_entities=__commonJS3({"../../node_modules/ansi-to-html/node_modules/entities/lib/maps/entities.json"(exports,module){module.exports={Aacute:"\xC1",aacute:"\xE1",Abreve:"\u0102",abreve:"\u0103",ac:"\u223E",acd:"\u223F",acE:"\u223E\u0333",Acirc:"\xC2",acirc:"\xE2",acute:"\xB4",Acy:"\u0410",acy:"\u0430",AElig:"\xC6",aelig:"\xE6",af:"\u2061",Afr:"\u{1D504}",afr:"\u{1D51E}",Agrave:"\xC0",agrave:"\xE0",alefsym:"\u2135",aleph:"\u2135",Alpha:"\u0391",alpha:"\u03B1",Amacr:"\u0100",amacr:"\u0101",amalg:"\u2A3F",amp:"&",AMP:"&",andand:"\u2A55",And:"\u2A53",and:"\u2227",andd:"\u2A5C",andslope:"\u2A58",andv:"\u2A5A",ang:"\u2220",ange:"\u29A4",angle:"\u2220",angmsdaa:"\u29A8",angmsdab:"\u29A9",angmsdac:"\u29AA",angmsdad:"\u29AB",angmsdae:"\u29AC",angmsdaf:"\u29AD",angmsdag:"\u29AE",angmsdah:"\u29AF",angmsd:"\u2221",angrt:"\u221F",angrtvb:"\u22BE",angrtvbd:"\u299D",angsph:"\u2222",angst:"\xC5",angzarr:"\u237C",Aogon:"\u0104",aogon:"\u0105",Aopf:"\u{1D538}",aopf:"\u{1D552}",apacir:"\u2A6F",ap:"\u2248",apE:"\u2A70",ape:"\u224A",apid:"\u224B",apos:"'",ApplyFunction:"\u2061",approx:"\u2248",approxeq:"\u224A",Aring:"\xC5",aring:"\xE5",Ascr:"\u{1D49C}",ascr:"\u{1D4B6}",Assign:"\u2254",ast:"*",asymp:"\u2248",asympeq:"\u224D",Atilde:"\xC3",atilde:"\xE3",Auml:"\xC4",auml:"\xE4",awconint:"\u2233",awint:"\u2A11",backcong:"\u224C",backepsilon:"\u03F6",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",Backslash:"\u2216",Barv:"\u2AE7",barvee:"\u22BD",barwed:"\u2305",Barwed:"\u2306",barwedge:"\u2305",bbrk:"\u23B5",bbrktbrk:"\u23B6",bcong:"\u224C",Bcy:"\u0411",bcy:"\u0431",bdquo:"\u201E",becaus:"\u2235",because:"\u2235",Because:"\u2235",bemptyv:"\u29B0",bepsi:"\u03F6",bernou:"\u212C",Bernoullis:"\u212C",Beta:"\u0392",beta:"\u03B2",beth:"\u2136",between:"\u226C",Bfr:"\u{1D505}",bfr:"\u{1D51F}",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",bkarow:"\u290D",blacklozenge:"\u29EB",blacksquare:"\u25AA",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20E5",bnequiv:"\u2261\u20E5",bNot:"\u2AED",bnot:"\u2310",Bopf:"\u{1D539}",bopf:"\u{1D553}",bot:"\u22A5",bottom:"\u22A5",bowtie:"\u22C8",boxbox:"\u29C9",boxdl:"\u2510",boxdL:"\u2555",boxDl:"\u2556",boxDL:"\u2557",boxdr:"\u250C",boxdR:"\u2552",boxDr:"\u2553",boxDR:"\u2554",boxh:"\u2500",boxH:"\u2550",boxhd:"\u252C",boxHd:"\u2564",boxhD:"\u2565",boxHD:"\u2566",boxhu:"\u2534",boxHu:"\u2567",boxhU:"\u2568",boxHU:"\u2569",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",boxul:"\u2518",boxuL:"\u255B",boxUl:"\u255C",boxU
`);return projectAnnotations}).catch(err=>{throw this.renderPreviewEntryError("Error reading preview.js:",err),err})}initializeWithProjectAnnotations(projectAnnotations){this.storyStore.setProjectAnnotations(projectAnnotations),this.setInitialGlobals();let storyIndexPromise;if(scope.FEATURES?.storyStoreV7)storyIndexPromise=this.getStoryIndexFromServer();else{if(!this.getStoryIndex)throw new Error("No `getStoryIndex` passed defined in v6 mode");storyIndexPromise=import_synchronous_promise3.SynchronousPromise.resolve().then(this.getStoryIndex)}return storyIndexPromise.then(storyIndex=>this.initializeWithStoryIndex(storyIndex)).catch(err=>{throw this.renderPreviewEntryError("Error loading story index:",err),err})}async setInitialGlobals(){this.emitGlobals()}emitGlobals(){if(!this.storyStore.globals||!this.storyStore.projectAnnotations)throw new Error("Cannot emit before initialization");let payload={globals:this.storyStore.globals.get()||{},globalTypes:this.storyStore.projectAnnotations.globalTypes||{}};this.channel.emit(SET_GLOBALS,payload)}async getStoryIndexFromServer(){let result2=await fetch(STORY_INDEX_PATH);if(result2.status===200)return result2.json();throw new Error(await result2.text())}initializeWithStoryIndex(storyIndex){if(!this.importFn)throw new Error("Cannot call initializeWithStoryIndex before initialization");return this.storyStore.initialize({storyIndex,importFn:this.importFn,cache:!scope.FEATURES?.storyStoreV7})}async onGetProjectAnnotationsChanged({getProjectAnnotations}){delete this.previewEntryError;let projectAnnotations=await this.getProjectAnnotationsOrRenderError(getProjectAnnotations);if(!this.storyStore.projectAnnotations){await this.initializeWithProjectAnnotations(projectAnnotations);return}await this.storyStore.setProjectAnnotations(projectAnnotations),this.emitGlobals()}async onStoryIndexChanged(){if(delete this.previewEntryError,!!this.storyStore.projectAnnotations)try{let storyIndex=await this.getStoryIndexFromServer();this.storyStore.storyIndex||await this.initializeWithStoryIndex(storyIndex),await this.onStoriesChanged({storyIndex})}catch(err){throw this.renderPreviewEntryError("Error loading story index:",err),err}}async onStoriesChanged({importFn,storyIndex}){await this.storyStore.onStoriesChanged({importFn,storyIndex})}async onUpdateGlobals({globals}){if(!this.storyStore.globals)throw new Error("Cannot call onUpdateGlobals before initialization");this.storyStore.globals.update(globals),await Promise.all(this.storyRenders.map(r=>r.rerender())),this.channel.emit(GLOBALS_UPDATED,{globals:this.storyStore.globals.get(),initialGlobals:this.storyStore.globals.initialGlobals})}async onUpdateArgs({storyId,updatedArgs}){this.storyStore.args.update(storyId,updatedArgs),await Promise.all(this.storyRenders.filter(r=>r.id===storyId&&!r.renderOptions.forceInitialArgs).map(r=>r.rerender())),this.channel.emit(STORY_ARGS_UPDATED,{storyId,args:this.storyStore.args.get(storyId)})}async onResetArgs({storyId,argNames}){let story=this.storyRenders.find(r=>r.id===storyId)?.story||await this.storyStore.loadStory({storyId}),updatedArgs=(argNames||[...new Set([...Object.keys(story.initialArgs),...Object.keys(this.storyStore.args.get(storyId))])]).reduce((acc,argName)=>(acc[argName]=story.initialArgs[argName],acc),{});await this.onUpdateArgs({storyId,updatedArgs})}async onForceReRender(){await Promise.all(this.storyRenders.map(r=>r.rerender()))}async onForceRemount({storyId}){await Promise.all(this.storyRenders.filter(r=>r.id===storyId).map(r=>r.remount()))}renderStoryToElement(story,element,callbacks,options2){if(!this.renderToCanvas)throw new Error("Cannot call renderStoryToElement before initialization");let render=new StoryRender(this.channel,this.storyStore,this.renderToCanvas,callbacks,story.id,"docs",options2,story);return render.renderToElement(element),this.storyRenders.push(render),async()=>{await this.teardownRender(render)}}async teardownRender(render,{viewModeChanged}={}){this.storyRenders=this.storyRenders.filter(r=>r!==render),await render?.teardown?.({viewModeChanged})}async extract(op
Doyouhaveanerrorinyour\`preview.js\`? Check your Storybook's browser console for errors.`);returnscope.FEATURES?.storyStoreV7&&awaitthis.storyStore.cacheAllCSFFiles(),this.storyStore.extract(options2)}renderPreviewEntryError(reason,err){this.previewEntryError=err,logger.error(reason),logger.error(err),this.channel.emit(CONFIG_ERROR,err)}},DocsContext=class{constructor(channel,store,renderStoryToElement,csfFiles){this.channel=channel,this.store=store,this.renderStoryToElement=renderStoryToElement,this.storyIdByName=storyName=>{letstoryId=this.nameToStoryId.get(storyName);if(storyId)returnstoryId;thrownewError(`No story found with that name: ${storyName}`)},this.componentStories=()=>this.componentStoriesValue,this.storyById=storyId=>{if(!storyId){if(!this.primaryStory)thrownewError("No primary story defined for docs entry. Did you forget to use `<Meta>`?");returnthis.primaryStory}letcsfFile=this.storyIdToCSFFile.get(storyId);if(!csfFile)thrownewError(`Called \`storyById\` for story that was never loaded: ${storyId}`);returnthis.store.storyFromCSFFile({storyId,csfFile})},this.getStoryContext=story=>({...this.store.getStoryContext(story),viewMode:"docs"}),this.loadStory=id=>this.store.loadStory({storyId:id}),this.storyIdToCSFFile=newMap,this.exportToStory=newMap,this.exportsToCSFFile=newMap,this.nameToStoryId=newMap,this.componentStoriesValue=[],csfFiles.forEach((csfFile,index)=>{this.referenceCSFFile(csfFile)})}referenceCSFFile(csfFile){this.exportsToCSFFile.set(csfFile.moduleExports,csfFile),this.exportsToCSFFile.set(csfFile.moduleExports.default,csfFile),this.store.componentStoriesFromCSFFile({csfFile}).forEach(story=>{letannotation=csfFile.stories[story.id];this.storyIdToCSFFile.set(annotation.id,csfFile),this.exportToStory.set(annotation.moduleExport,story)})}attachCSFFile(csfFile){if(!this.exportsToCSFFile.has(csfFile.moduleExports))thrownewError("Cannot attach a CSF file that has not been referenced");this.attachedCSFFile=csfFile,this.store.componentStoriesFromCSFFile({csfFile}).forEach(story=>{this.nameToStoryId.set(story.name,story.id),this.componentStoriesValue.push(story),this.primaryStory||(this.primaryStory=story)})}referenceMeta(metaExports,attach){letresolved=this.resolveModuleExport(metaExports);if(resolved.type!=="meta")thrownewError("<Meta of={} /> must reference a CSF file module export or meta export. Did you mistakenly reference your component instead of your CSF file?");attach&&this.attachCSFFile(resolved.csfFile)}getprojectAnnotations(){let{projectAnnotations}=this.store;if(!projectAnnotations)thrownewError("Can't get projectAnnotations from DocsContext before they are initialized");returnprojectAnnotations}resolveAttachedModuleExportType(moduleExportType){if(moduleExportType==="story"){if(!this.primaryStory)thrownewError("No primary story attached to this docs file, did you forget to use <Meta of={} />?");return{type:"story",story:this.primaryStory}}if(!this.attachedCSFFile)thrownewError("No CSF file attached to this docs file, did you forget to use <Meta of={} />?");if(moduleExportType==="meta")return{type:"meta",csfFile:this.attachedCSFFile};let{component}=this.attachedCSFFile.meta;if(!component)thrownewError("Attached CSF file does not defined a component, did you forget to export one?");return{type:"component",component}}resolveModuleExport(moduleExportOrType){letcsfFile=this.exportsToCSFFile.get(moduleExportOrType);if(csfFile)return{type:"meta",csfFile};letstory=this.exportToStory.get(moduleExportOrType);returnstory?{type:"story",story}:{type:"component",component:moduleExportOrType}}resolveOf(moduleExportOrType,validTypes=[]){letresolved;if(["component","meta","story"].includes(moduleExportOrType)){lettype=moduleExportOrType;resolved=this.resolveAttachedModuleExportType(type)}elseresolved=this.resolveModuleExport(moduleExportOrType);if(validTypes.length&&!validTypes.includes(resolved.type)){letprettyType=resolved.type==="component"?"component or unknown":resolved.type;thrownewError(esm_default`Invalid value passed to the 'of' prop. The valu
-Didyoupassastory,CSFfileormetatothe'of'propthatisnotindexed,ie.isnottargetedbythe'stories'globsinthemainconfiguration?`)}switch(resolved.type){case"component":return{...resolved,projectAnnotations:this.projectAnnotations};case"meta":return{...resolved,preparedMeta:this.store.preparedMetaFromCSFFile({csfFile:resolved.csfFile})};case"story":default:return resolved}}},CsfDocsRender=class{constructor(channel,store,entry,callbacks){this.channel=channel,this.store=store,this.entry=entry,this.callbacks=callbacks,this.type="docs",this.subtype="csf",this.torndown=!1,this.disableKeyListeners=!1,this.preparing=!1,this.id=entry.id}isPreparing(){return this.preparing}async prepare(){this.preparing=!0;let{entryExports,csfFiles=[]}=await this.store.loadEntry(this.id);if(this.torndown)throw PREPARE_ABORTED;let{importPath,title}=this.entry,primaryCsfFile=this.store.processCSFFileWithCache(entryExports,importPath,title),primaryStoryId=Object.keys(primaryCsfFile.stories)[0];this.story=this.store.storyFromCSFFile({storyId:primaryStoryId,csfFile:primaryCsfFile}),this.csfFiles=[primaryCsfFile,...csfFiles],this.preparing=!1}isEqual(other){return!!(this.id===other.id&&this.story&&this.story===other.story)}docsContext(renderStoryToElement){if(!this.csfFiles)throw new Error("Cannot render docs before preparing");let docsContext=new DocsContext(this.channel,this.store,renderStoryToElement,this.csfFiles);return this.csfFiles.forEach(csfFile=>docsContext.attachCSFFile(csfFile)),docsContext}async renderToElement(canvasElement,renderStoryToElement){if(!this.story||!this.csfFiles)throw new Error("Cannot render docs before preparing");let docsContext=this.docsContext(renderStoryToElement),{docs:docsParameter}=this.story.parameters||{};if(!docsParameter)throw new Error("Cannot render a story in viewMode=docs if `@storybook/addon-docs` is not installed");let renderer=await docsParameter.renderer(),{render}=renderer,renderDocs=async()=>{try{await render(docsContext,docsParameter,canvasElement),this.channel.emit(DOCS_RENDERED,this.id)}catch(err){this.callbacks.showException(err)}};return this.rerender=async()=>renderDocs(),this.teardownRender=async({viewModeChanged})=>{!viewModeChanged||!canvasElement||renderer.unmount(canvasElement)},renderDocs()}async teardown({viewModeChanged}={}){this.teardownRender?.({viewModeChanged}),this.torndown=!0}},MdxDocsRender=class{constructor(channel,store,entry,callbacks){this.channel=channel,this.store=store,this.entry=entry,this.callbacks=callbacks,this.type="docs",this.subtype="mdx",this.torndown=!1,this.disableKeyListeners=!1,this.preparing=!1,this.id=entry.id}isPreparing(){return this.preparing}async prepare(){this.preparing=!0;let{entryExports,csfFiles=[]}=await this.store.loadEntry(this.id);if(this.torndown)throw PREPARE_ABORTED;this.csfFiles=csfFiles,this.exports=entryExports,this.preparing=!1}isEqual(other){return!!(this.id===other.id&&this.exports&&this.exports===other.exports)}docsContext(renderStoryToElement){if(!this.csfFiles)throw new Error("Cannot render docs before preparing");return new DocsContext(this.channel,this.store,renderStoryToElement,this.csfFiles)}async renderToElement(canvasElement,renderStoryToElement){if(!this.exports||!this.csfFiles||!this.store.projectAnnotations)throw new Error("Cannot render docs before preparing");let docsContext=this.docsContext(renderStoryToElement),{docs}=this.store.projectAnnotations.parameters||{};if(!docs)throw new Error("Cannot render a story in viewMode=docs if `@storybook/addon-docs` is not installed");let docsParameter={...docs,page:this.exports.default},renderer=await docs.renderer(),{render}=renderer,renderDocs=async()=>{try{await render(docsContext,docsParameter,canvasElement),this.channel.emit(DOCS_RENDERED,this.id)}catch(err){this.callbacks.showException(err)}};return this.rerender=async()=>renderDocs(),this.teardownRender=async({viewModeChanged}={})=>{!viewModeChanged||!canvasElement||(renderer.unmount(canvasElement),this.torndown=!0)},renderDocs()}async teardown({viewModeChanged}={}){this.teardownRender?.({viewModeChan
`));return}let{id:storyId,type:viewMode}=entry;this.selectionStore.setSelection({storyId,viewMode}),this.channel.emit(STORY_SPECIFIED,this.selectionStore.selection),this.channel.emit(CURRENT_STORY_WAS_SET,this.selectionStore.selection),await this.renderSelection({persistedArgs:args2})}async onGetProjectAnnotationsChanged({getProjectAnnotations}){await super.onGetProjectAnnotationsChanged({getProjectAnnotations}),this.selectionStore.selection&&this.renderSelection()}async onStoriesChanged({importFn,storyIndex}){await super.onStoriesChanged({importFn,storyIndex}),scope.FEATURES?.storyStoreV7||this.channel.emit(SET_INDEX,await this.storyStore.getSetIndexPayload()),this.selectionStore.selection?await this.renderSelection():await this.selectSpecifiedStory()}onKeydown(event){if(!this.storyRenders.find(r=>r.disableKeyListeners)&&!focusInInput(event)){let{altKey,ctrlKey,metaKey,shiftKey,key:key2,code,keyCode}=event;this.channel.emit(PREVIEW_KEYDOWN,{event:{altKey,ctrlKey,metaKey,shiftKey,key:key2,code,keyCode}})}}async onSetCurrentStory(selection){this.selectionStore.setSelection({viewMode:"story",...selection}),await this.storyStore.initializationPromise,this.channel.emit(CURRENT_STORY_WAS_SET,this.selectionStore.selection),this.renderSelection()}onUpdateQueryParams(queryParams){this.selectionStore.setQueryParams(queryParams)}async onUpdateGlobals({globals}){super.onUpdateGlobals({globals}),(this.currentRender instanceof MdxDocsRender||this.currentRender instanceof CsfDocsRender)&&await this.currentRender.rerender?.()}async onUpdateArgs({storyId,updatedArgs}){super.onUpdateArgs({storyId,updatedArgs})}async onPreloadStories({ids}){await Promise.allSettled(ids.map(id=>this.storyStore.loadEntry(id)))}async renderSelection({persistedArgs}={}){let{renderToCanvas}=this;if(!renderToCanvas)throw new Error("Cannot call renderSelection before initialization");let{selection}=this.selectionStore;if(!selection)throw new Error("Cannot call renderSelection as no selection was made");let{storyId}=selection,entry;try{entry=await this.storyStore.storyIdToEntry(storyId)}catch(err){this.currentRender&&await this.teardownRender(this.currentRender),this.renderStoryLoadingException(storyId,err);return}let storyIdChanged=this.currentSelection?.storyId!==storyId,viewModeChanged=this.currentRender?.type!==entry.type;entry.type==="story"?this.view.showPreparingStory({immediate:viewModeChanged}):this.view.showPreparingDocs({immediate:viewModeChanged}),this.currentRender?.isPreparing()&&await this.teardownRender(this.currentRender);let render;entry.type==="story"?render=new StoryRender(this.channel,this.storyStore,(...args2)=>(this.view.showStoryDuringRender(),renderToCanvas(...args2)),this.mainStoryCallbacks(storyId),storyId,"story"):isMdxEntry(entry)?render=new MdxDocsRender(this.channel,this.storyStore,entry,this.mainStoryCallbacks(storyId)):render=new CsfDocsRender(this.channel,this.storyStore,entry,this.mainStoryCallbacks(storyId));let lastSelection=this.currentSelection;this.currentSelection=selection;let lastRender=this.currentRender;this.currentRender=render;try{await render.prepare()}catch(err){err!==PREPARE_ABORTED&&(lastRender&&await this.teardownRender(lastRender),this.renderStoryLoadingException(storyId,err));return}let implementationChanged=!storyIdChanged&&lastRender&&!render.isEqual(lastRender);if(persistedArgs&&isStoryRender(render)){if(!render.story)throw new Error("Render has not been prepared!");this.storyStore.args.updateFromPersisted(render.story,persistedArgs)}if(lastRender&&!lastRender.torndown&&!storyIdChanged&&!implementationChanged&&!viewModeChanged){this.currentRender=lastRender,this.channel.emit(STORY_UNCHANGED,storyId),this.view.showMain();return}if(lastRender&&await this.teardownRender(lastRender,{viewModeChanged}),lastSelection&&(storyIdChanged||viewModeChanged)&&this.channel.emit(STORY_CHANGED,storyId),isStoryRender(render)){if(!render.story)throw new Error("Render has not been prepared!");let{parameters,initialArgs,argTypes,unmappedArgs}=this.storyStore.getStoryContext(render.story);scope.FEATURES?.storyStoreV7&
Doyouhaveanerrorinyour\`preview.js\`? Check your Storybook's browser console for errors.`);returnscope.FEATURES?.storyStoreV7&&awaitthis.storyStore.cacheAllCSFFiles(),this.storyStore.extract(options2)}mainStoryCallbacks(storyId){return{showMain:()=>this.view.showMain(),showError:err=>this.renderError(storyId,err),showException:err=>this.renderException(storyId,err)}}renderPreviewEntryError(reason,err){super.renderPreviewEntryError(reason,err),this.view.showErrorDisplay(err)}renderMissingStory(){this.view.showNoPreview(),this.channel.emit(STORY_MISSING)}renderStoryLoadingException(storySpecifier,err){logger.error(err),this.view.showErrorDisplay(err),this.channel.emit(STORY_MISSING,storySpecifier)}renderException(storyId,error){let{name:name2="Error",message=String(error),stack}=error;this.channel.emit(STORY_THREW_EXCEPTION,{name:name2,message,stack}),this.channel.emit(STORY_RENDER_PHASE_CHANGED,{newPhase:"errored",storyId}),error.message?.startsWith("ignoredException")||(this.view.showErrorDisplay(error),logger.error(`Error rendering story '${storyId}':`),logger.error(error))}renderError(storyId,{title,description}){logger.error(`Error rendering story ${title}: ${description}`),this.channel.emit(STORY_ERRORED,{title,description}),this.channel.emit(STORY_RENDER_PHASE_CHANGED,{newPhase:"errored",storyId}),this.view.showErrorDisplay({message:title,stack:description})}},VALIDATION_REGEXP=/^[a-zA-Z0-9 _-]*$/,NUMBER_REGEXP=/^-?[0-9]+(\.[0-9]+)?$/,HEX_REGEXP=/^#([a-f0-9]{3,4}|[a-f0-9]{6}|[a-f0-9]{8})$/i,COLOR_REGEXP=/^(rgba?|hsla?)\(([0-9]{1,3}),\s?([0-9]{1,3})%?,\s?([0-9]{1,3})%?,?\s?([0-9](\.[0-9]{1,2})?)?\)$/i,validateArgs=(key2="",value2)=>key2===null||key2===""||!VALIDATION_REGEXP.test(key2)?!1:value2==null||value2instanceofDate||typeofvalue2=="number"||typeofvalue2=="boolean"?!0:typeofvalue2=="string"?VALIDATION_REGEXP.test(value2)||NUMBER_REGEXP.test(value2)||HEX_REGEXP.test(value2)||COLOR_REGEXP.test(value2):Array.isArray(value2)?value2.every(v2=>validateArgs(key2,v2)):(0,import_isPlainObject2.default)(value2)?Object.entries(value2).every(([k,v2])=>validateArgs(k,v2)):!1,QS_OPTIONS={delimiter:";",allowDots:!0,allowSparse:!0,decoder(str,defaultDecoder,charset,type){if(type==="value"&&str.startsWith("!")){if(str==="!undefined")return;if(str==="!null")returnnull;if(str==="!true")return!0;if(str==="!false")return!1;if(str.startsWith("!date(")&&str.endsWith(")"))returnnewDate(str.slice(6,-1));if(str.startsWith("!hex(")&&str.endsWith(")"))return`#${str.slice(5,-1)}`;letcolor=str.slice(1).match(COLOR_REGEXP);if(color)returnstr.startsWith("!rgba")?`${color[1]}(${color[2]}, ${color[3]}, ${color[4]}, ${color[5]})`:str.startsWith("!hsla")?`${color[1]}(${color[2]}, ${color[3]}%, ${color[4]}%, ${color[5]})`:str.startsWith("!rgb")?`${color[1]}(${color[2]}, ${color[3]}, ${color[4]})`:`${color[1]}(${color[2]}, ${color[3]}%, ${color[4]}%)`}returntype==="value"&&NUMBER_REGEXP.test(str)?Number(str):defaultDecoder(str,defaultDecoder,charset)}},parseArgsParam=argsString=>{letparts=argsString.split(";").map(part=>part.replace("=","~").replace(":","="));returnObject.entries(import_qs3.default.parse(parts.join(";"),QS_OPTIONS)).reduce((acc,[key2,value2])=>validateArgs(key2,value2)?Object.assign(acc,{[key2]:value2}):(once.warn(dedent`