{"version":3,"file":"ikiHTj9b.js","sources":["../../../../composables/createContext.ts","../../../../components/ErrorContext.vue"],"sourcesContent":["import { type InjectionKey, inject, provide } from 'vue';\r\n\r\n/**\r\n * @param providerComponentName - The name(s) of the component(s) providing the context.\r\n *\r\n * There are situations where context can come from multiple components. In such cases, you might need to give an array of component names to provide your context, instead of just a single string.\r\n *\r\n * @param contextName The description for injection key symbol.\r\n */\r\nexport function createContext(\r\n providerComponentName: string | string[],\r\n contextName?: string,\r\n) {\r\n const symbolDescription =\r\n typeof providerComponentName === 'string' && !contextName\r\n ? `${providerComponentName}Context`\r\n : contextName;\r\n\r\n const injectionKey: InjectionKey = Symbol(symbolDescription);\r\n\r\n /**\r\n * @param fallback The context value to return if the injection fails.\r\n *\r\n * @throws When context injection failed and no fallback is specified.\r\n * This happens when the component injecting the context is not a child of the root component providing the context.\r\n */\r\n const injectContext = (\r\n fallback?: T,\r\n ): T extends null ? ContextValue | null : ContextValue => {\r\n const context = inject(injectionKey, fallback);\r\n if (context) return context;\r\n\r\n if (context === null) return context as any;\r\n\r\n throw new Error(\r\n `Injection \\`${injectionKey.toString()}\\` not found. Component must be used within ${\r\n Array.isArray(providerComponentName)\r\n ? `one of the following components: ${providerComponentName.join(', ')}`\r\n : `\\`${providerComponentName}\\``\r\n }`,\r\n );\r\n };\r\n\r\n const provideContext = (contextValue: ContextValue) => {\r\n provide(injectionKey, contextValue);\r\n return contextValue;\r\n };\r\n\r\n return [injectContext, provideContext] as const;\r\n}\r\n","\r\n\r\n\r\n\r\n\r\n"],"names":["createContext","providerComponentName","contextName","symbolDescription","injectionKey","fallback","context","inject","contextValue","provide","injectErrorContextInternal","provideErrorContext","injectErrorContext","toRef","highlightError","ref","firstTimeSeeing","triggerErrorsHighlight","onUnmounted"],"mappings":"2EASgB,SAAAA,EACdC,EACAC,EACA,CACM,MAAAC,EAEA,GAAGF,CAAqB,UAGxBG,EAAkD,OAAOD,CAAiB,EA8BzE,MAAA,CArBLE,GACwD,CAClD,MAAAC,EAAUC,EAAOH,EAAcC,CAAQ,EAGzC,GAFAC,GAEAA,IAAY,KAAa,OAAAA,EAE7B,MAAM,IAAI,MACR,eAAeF,EAAa,SAAU,CAAA,+CACpC,MAAM,QAAQH,CAAqB,EAC/B,oCAAoCA,EAAsB,KAAK,IAAI,CAAC,GACpE,KAAKA,CAAqB,IAChC,EAAA,CACF,EAGsBO,IACtBC,EAAQL,EAAcI,CAAY,EAC3BA,EAG4B,CACvC,CC3CO,KAAM,CAACE,EAA4BC,CAAmB,EAC3DX,EAA4B,cAAc,EAC/BY,EAAqB,IAChCF,EAA2B,CAAE,eAAgBG,EAAM,EAAK,EAAG,uBAAwB,IAAM,CAAC,EAAG,sCAIzF,MAAAC,EAAiBC,EAAI,EAAK,EAC1BC,EAAkBD,EAAI,EAAI,EAEhC,SAASE,GAAyB,CAC5B,GAAAD,EAAgB,OAASF,EAAe,MAAO,CAC7CE,EAAgB,QAClBA,EAAgB,MAAQ,IAG1B,MACF,CAEAF,EAAe,MAAQ,GACvB,WAAW,IAAM,CACfA,EAAe,MAAQ,IACtB,GAAK,CACV,CAEoB,OAAAH,EAAA,CAClB,eAAAG,EACA,uBAAAG,CAAA,CACD,EAEDC,EAAY,IAAM,CAChBJ,EAAe,MAAQ,EAAA,CACxB"}