@storyblok/vue 9.0.0 → 9.0.1

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.
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  <p align="center">
13
13
  <a href="https://npmjs.com/package/@storyblok/vue">
14
- <img src="https://img.shields.io/npm/v/@storyblok/vue/latest.svg?style=flat-square" alt="Storyblok Vue" />
14
+ <img src="https://img.shields.io/npm/v/@storyblok/vue/latest.svg?style=flat-square" alt="Storyblok Vue SDK" />
15
15
  </a>
16
16
  <a href="https://npmjs.com/package/@storyblok/vue" rel="nofollow">
17
17
  <img src="https://img.shields.io/npm/dt/@storyblok/vue.svg?style=flat-square" alt="npm">
@@ -30,443 +30,46 @@
30
30
  </a>
31
31
  </p>
32
32
 
33
- > **Note**
34
- > This plugin is for Vue 3. [Check out the docs for Vue 2 version](https://github.com/storyblok/storyblok-vue-2).
33
+ ## Features
35
34
 
36
- ## Kickstart a new project
35
+ - Fetch content from the Content Delivery API
36
+ - Connect frontend components with the Visual Editor via StoryblokBridge
37
+ - Render rich text content by providing a built-in component and composable
37
38
 
38
- Are you eager to dive into coding? **[Follow these steps to kickstart a new project with Storyblok and Vue](https://www.storyblok.com/technologies?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue#vue)**, and get started in just a few minutes!
39
+ ## Documentation
39
40
 
40
- ## 5-minute Tutorial
41
+ For complete documentation, please visit [package reference](https://www.storyblok.com/docs/packages/storyblok-vue)
41
42
 
42
- Are you looking for a hands-on, step-by-step tutorial? The **[Vue 5-minute Tutorial](https://www.storyblok.com/tp/add-a-headless-CMS-to-vuejs-in-5-minutes?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue)** has you covered! It provides comprehensive instructions on how to set up a Storyblok space and connect it to your Vue project.
43
-
44
- ## Installation
45
-
46
- Install `@storyblok/vue`
47
-
48
- ```bash
49
- npm install @storyblok/vue
50
- # yarn add @storyblok/vue
51
- ```
52
-
53
- > **Warning**
54
- > This SDK uses the Fetch API under the hood. If your environment doesn't support it, you need to install a polyfill like [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch). More info on [storyblok-js-client docs](https://github.com/storyblok/storyblok-js-client#fetch-use-polyfill-if-needed---version-5).
55
-
56
- Register the plugin on your application (usually in `main.js`), add the `apiPlugin` and add the [access token](https://www.storyblok.com/docs/api/content-delivery/v2/getting-started/authentication?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue) of your Storyblok space:
57
-
58
- ```js
59
- import { createApp } from "vue";
60
- import { StoryblokVue, apiPlugin } from "@storyblok/vue";
61
- import App from "./App.vue";
62
-
63
- const app = createApp(App);
64
-
65
- app.use(StoryblokVue, {
66
- accessToken: "YOUR_ACCESS_TOKEN",
67
- use: [apiPlugin],
68
- });
69
- ```
70
-
71
- That's it! All the features are enabled for you: the _Api Client_ for interacting with [Storyblok CDN API](https://www.storyblok.com/docs/api/content-delivery/v2/getting-started/introduction?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue), and _Storyblok Bridge_ for [real-time visual editing experience](https://www.storyblok.com/docs/guide/essentials/visual-editor?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue).
72
-
73
- > **Note**
74
- > You can enable/disable some of these features if you don't need them, so you save some KB. Please read the "Features and API" section.
75
-
76
- #### From a CDN
77
-
78
- Install the file from the CDN and access the methods via `window.storyblokVue`:
79
-
80
- ```html
81
- <script src="https://unpkg.com/@storyblok/vue"></script>
82
- ```
83
-
84
- ## Getting started
85
-
86
- `@storyblok/vue` does three actions when you initialize it:
87
-
88
- - Provides a `storyblokApi` object in your app, which is an instance of [storyblok-js-client](https://github.com/storyblok/storyblok-js-client)
89
- - Loads [Storyblok Bridge](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue) for real-time visual updates
90
- - Provides a `v-editable` directive to link editable components to the Storyblok Visual Editor
91
-
92
- ### Short Form
93
-
94
- Load globally the Vue components you want to link to Storyblok in your _main.js_ file:
95
-
96
- ```js
97
- import Page from "./components/Page.vue";
98
- import Teaser from "./components/Teaser.vue";
99
-
100
- app.use(StoryblokVue, {
101
- accessToken: "<your-token>",
102
- use: [apiPlugin],
103
- });
104
-
105
- app.component("Page", Page);
106
- app.component("Teaser", Teaser);
107
- ```
108
-
109
- The simplest way is by using the `useStoryblok` one-liner composable. Where you need to pass as first parameter the `slug`, while the second and third parameters, `apiOptions` and `bridgeOptions` respectively, are optional:
110
-
111
- > **Note**
112
- > The `resolveRelations` and `resolveLinks` from `bridgeOptions` can be excluded if you're already defining them as `resolve_relations` and `resolve_links` in `apiOptions`, we will add them by default. But you will always be able to overwrite them.
113
-
114
- ```html
115
- <script setup>
116
- import { useStoryblok } from "@storyblok/vue";
117
- const { story, fetchState } = useStoryblok(
118
- "path-to-story",
119
- { version: "draft", resolve_relations: "Article.author" }, // API Options
120
- { resolveRelations: ["Article.author"], resolveLinks: "url" } // Bridge Options
121
- );
122
- </script>
123
-
124
- <template>
125
- <StoryblokComponent v-if="story" :blok="story.content" />
126
- </template>
127
- ```
128
-
129
- Check the available [apiOptions](https://www.storyblok.com/docs/api/content-delivery/v2/stories/retrieve-a-single-story?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue) in our API docs and [bridgeOptions](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue) passed to the Storyblok Bridge.
130
-
131
- ### Long Form
132
-
133
- #### 1. Fetching Content
134
-
135
- Inject `storyblokApi` when using Composition API:
136
-
137
- ```html
138
- <template>
139
- <div>
140
- <p v-for="story in stories" :key="story.id">{{ story.name }}</p>
141
- </div>
142
- </template>
143
-
144
- <script setup>
145
- import { useStoryblokApi } from "@storyblok/vue";
146
-
147
- const storyblokApi = useStoryblokApi();
148
- const { data } = await storyblokApi.get(
149
- "cdn/stories/home",
150
- { version: "draft", resolve_relations: "Article.author" } // API Options
151
- );
152
- </script>
153
- ```
154
-
155
- > **Note**
156
- > You can skip using `apiPlugin` if you prefer your own method or function to fetch your data.
157
-
158
- #### 2. Listen to Storyblok Visual Editor events
159
-
160
- Use `useStoryBridge` to get the new story every time is triggered a `change` event from the Visual Editor. You need to pass the story id as first param, and a callback function as second param to update the new story:
161
-
162
- ```html
163
- <script setup>
164
- import { onMounted } from "vue";
165
- import { useStoryblokBridge, useStoryblokApi } from "@storyblok/vue";
166
-
167
- const storyblokApi = useStoryblokApi();
168
- const { data } = await storyblokApi.get(
169
- "cdn/stories/home",
170
- { version: "draft", resolve_relations: "Article.author" } // API Options
171
- );
172
- const state = reactive({ story: data.story });
173
-
174
- onMounted(() => {
175
- useStoryblokBridge(state.story.id, story => (state.story = story));
176
- });
177
- </script>
178
- ```
179
-
180
- You can pass [Bridge options](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue) as a third parameter as well:
181
-
182
- ```js
183
- useStoryblokBridge(
184
- state.story.id,
185
- (story) => (state.story = story),
186
- {
187
- resolveRelations: ["Article.author"],
188
- resolveLinks: "url",
189
- } // Bridge Options
190
- );
191
- ```
192
-
193
- #### 3. Link your components to Storyblok Visual Editor
194
-
195
- For every component you've defined in your Storyblok space, add the `v-editable` directive with the blok content:
196
-
197
- ```html
198
- <template>
199
- <div v-editable="blok"><!-- ... --></div>
200
- </template>
201
- ```
202
-
203
- Where `blok` is the actual blok data coming from [Storblok's Content Delivery API](https://www.storyblok.com/docs/api/content-delivery?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue).
204
-
205
- Check out the [playground](/../../tree/next/playground) for a full example.
206
-
207
- ## Features and API
208
-
209
- You can **choose the features to use** when you initialize the plugin. In that way, you can improve Web Performance by optimizing your page load and save some bytes.
210
-
211
- ### useStoryblok(pathToStory, apiOptions = {}, bridgeOptions = {})
212
-
213
- This example of `useStoryblok`:
214
-
215
- ```html
216
- <script setup>
217
- import { useStoryblok } from "@storyblok/vue";
218
- const story = await useStoryblok(
219
- "blog",
220
- { version: "draft", resolve_relations: "Article.author" }, // API Options
221
- { resolveRelations: ["Article.author"], resolveLinks: "url" } // Bridge Options
222
- );
223
- </script>
224
- ```
225
-
226
- Is equivalent to the following, using `useStoryblokBridge` and `useStoryblokApi`:
227
-
228
- ```html
229
- <script setup>
230
- import { onMounted } from "vue";
231
- import { useStoryblokBridge, useStoryblokApi } from "@storyblok/vue";
232
-
233
- const storyblokApi = useStoryblokApi();
234
- const { data } = await storyblokApi.get(
235
- "cdn/stories/blog",
236
- { version: "draft", resolve_relations: "Article.author" }, // API Options
237
- );
238
- const state = reactive({ story: data.story });
239
-
240
- onMounted(() => {
241
- useStoryblokBridge(
242
- state.story.id,
243
- story => (state.story = story),
244
- { resolveRelations: ["Article.author"], resolveLinks: "url" } // Bridge Options
245
- );
246
- });
247
- </script>
248
- ```
249
-
250
- Check the available [apiOptions](https://www.storyblok.com/docs/api/content-delivery/v2/stories/retrieve-a-single-story?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue) (passed to `storyblok-js-client`) and [bridgeOptions](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue) (passed to the Storyblok Bridge).
251
-
252
- ### Storyblok API
253
-
254
- You can use an `apiOptions` object. This is passed down to the [storyblok-js-client config object](https://github.com/storyblok/storyblok-js-client#class-storyblok).
255
-
256
- ```js
257
- app.use(StoryblokVue, {
258
- accessToken: "<your-token>",
259
- apiOptions: {
260
- // storyblok-js-client config object
261
- cache: { type: "memory" },
262
- },
263
- use: [apiPlugin],
264
- });
265
- ```
266
-
267
- If you prefer to use your own fetch method, just remove the `apiPlugin` and `storyblok-js-client` won't be added to your application.
268
-
269
- ```js
270
- app.use(StoryblokVue);
271
- ```
272
-
273
- ## Region parameter
274
-
275
- Possible values:
276
-
277
- - `eu` (default): For spaces created in the EU
278
- - `us`: For spaces created in the US
279
- - `ap`: For spaces created in Australia
280
- - `ca`: For spaces created in Canada
281
- - `cn`: For spaces created in China
282
-
283
- Full example for a space created in the US:
284
-
285
- ```js
286
- app.use(StoryblokVue, {
287
- accessToken: "<your-token>",
288
- use: [apiPlugin],
289
- apiOptions: {
290
- region: "us",
291
- },
292
- });
293
- ```
294
-
295
- > **Important**
296
- > For spaces created in the United States or China, the `region` parameter **must** be specified.
297
-
298
- ## Storyblok Bridge
299
-
300
- You can conditionally load it by using the `bridge` option. Very useful if you want to disable it in production:
301
-
302
- ```js
303
- app.use(StoryblokVue, {
304
- bridge: process.env.NODE_ENV !== "production",
305
- });
306
- ```
307
-
308
- In case you need it, you have still access to the raw `window.StoryblokBridge`:
309
-
310
- ```js
311
- const sbBridge = new window.StoryblokBridge(options);
312
-
313
- sbBridge.on(["input", "published", "change"], (event) => {
314
- // ...
315
- });
316
- ```
317
-
318
- ## Using Fallback components
319
-
320
- By default, `@storyblok/vue` show a `console.error` if a component is not implemented. Setting `enableFallbackComponent` to `true` bypasses that behavior, rendering a fallback component in the frontend instead.
321
-
322
- ```js
323
- app.use(StoryblokVue, {
324
- // ...
325
- enableFallbackComponent: true,
326
- });
327
- ```
328
-
329
- You can also create and use a custom fallback component by setting `customFallbackComponent: "MyCustomFallback"`.
330
-
331
- ```js
332
- import MyCustomFallback from "./components/MyCustomFallback.vue";
333
-
334
- app.use(StoryblokVue, {
335
- // ...
336
- enableFallbackComponent: true,
337
- customFallbackComponent: "MyCustomFallback",
338
- });
339
-
340
- app.component("MyCustomFallback", MyCustomFallback);
341
- ```
342
-
343
- ## Rendering Rich Text
344
-
345
- You can render rich text fields by using the `StoryblokRichText` component:
346
-
347
- ```html
348
- <script setup>
349
- import { StoryblokRichText } from "@storyblok/vue";
350
- </script>
351
-
352
- <template>
353
- <StoryblokRichText :doc="blok.articleContent" />
354
- </template>
355
- ```
356
-
357
- Or you can have more control by using the `useStoryblokRichText` composable:
358
-
359
- ```html
360
- <script setup>
361
- import { useStoryblokRichText } from "@storyblok/vue";
362
- const { render } = useStoryblokRichText({
363
- // options like resolvers
364
- });
365
-
366
- const root = () => render(blok.articleContent);
367
- </script>
368
-
369
- <template>
370
- <root />
371
- </template>
372
- ```
373
-
374
- For more incredible options you can pass to the `useStoryblokRichText`, please consult the [Full options](https://github.com/storyblok/richtext?tab=readme-ov-file#options) documentation.
375
-
376
- ### Overriding the default resolvers
377
-
378
- You can override the default resolvers by passing a `resolver` prop to the `StoryblokRichText` component, for example, to use vue-router links or add a custom codeblok component: :
379
-
380
- ```html
381
- <script setup>
382
- import { type VNode, h } from "vue";
383
- import { StoryblokRichText, BlockTypes, MarkTypes, type StoryblokRichTextNode } from "@storyblok/vue";
384
- import { RouterLink } from "vue-router";
385
- import CodeBlok from "./components/CodeBlok.vue";
386
-
387
- const resolvers = {
388
- // RouterLink example:
389
- [MarkTypes.LINK]: (node: StoryblokRichTextNode<VNode>) => {
390
- return node.attrs?.linktype === 'STORY'
391
- ? h(RouterLink, {
392
- to: node.attrs?.href,
393
- target: node.attrs?.target,
394
- }, node.text)
395
- : h('a', {
396
- href: node.attrs?.href,
397
- target: node.attrs?.target,
398
- }, node.text)
399
- },
400
- // Custom code block component example:
401
- [BlockTypes.CODE_BLOCK]: (node: Node) => {
402
- return h(CodeBlock, {
403
- class: node?.attrs?.class,
404
- }, node.children)
405
- },
406
- }
407
- </script>
43
+ ## Contributing
408
44
 
409
- <template>
410
- <StoryblokRichText :doc="blok.articleContent" :resolvers="resolvers" />
411
- </template>
412
- ```
45
+ If you'd like to contribute, please refer to the [contributing guidelines](CONTRIBUTING.md).
413
46
 
414
- If you want to use the `useStoryblokRichText` composable, you can pass the `resolvers` via the options object:
47
+ ## Community
415
48
 
416
- ```html
417
- <script setup>
418
- import { type VNode, h } from "vue";
419
- import { useStoryblokRichText, BlockTypes, MarkTypes, type StoryblokRichTextNode } from "@storyblok/vue";
420
- import { RouterLink } from "vue-router";
49
+ For help, discussion about best practices, or any other conversation that would benefit from being searchable:
421
50
 
422
- const resolvers = {
423
- // RouterLink example:
424
- [MarkTypes.LINK]: (node: StoryblokRichTextNode<VNode>) => {
425
- return node.attrs?.linktype === 'STORY'
426
- ? h(RouterLink, {
427
- to: node.attrs?.href,
428
- target: node.attrs?.target,
429
- }, node.text)
430
- : h('a', {
431
- href: node.attrs?.href,
432
- target: node.attrs?.target,
433
- }, node.text)
434
- },
435
- }
51
+ - [Discuss Storyblok on Github Discussions](https://github.com/storyblok/storyblok/discussions)
436
52
 
437
- const { render } = useStoryblokRichText({
438
- resolvers,
439
- })
440
- const root = () => render(blok.articleContent);
441
- </script>
53
+ For community support, chatting with other users, please visit:
442
54
 
443
- <template>
444
- <root />
445
- </template>
446
- ```
55
+ - [Discuss Storyblok on Discord](https://discord.gg/jKrbAMz)
447
56
 
448
- ## Compatibility
57
+ ## Support
449
58
 
450
- This plugin is for Vue 3. Thus, it supports the [same browsers as Vue 3](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0038-vue3-ie11-support.md). In short: all modern browsers, dropping IE support.
59
+ For bugs or feature requests, please [submit an issue](https://github.com/storyblok/storyblok-vue/issues/new/choose).
451
60
 
452
- ## The Storyblok JavaScript SDK Ecosystem
61
+ > [!IMPORTANT]
62
+ > Please search existing issues before submitting a new one. Issues without a minimal reproducible example will be closed. [Why reproductions are Required](https://antfu.me/posts/why-reproductions-are-required).
453
63
 
454
- ![A visual representation of the Storyblok JavaScript SDK Ecosystem](https://a.storyblok.com/f/88751/2400x1350/be4a4a4180/sdk-ecosystem.png/m/1200x0)
64
+ ### I can't share my company project code
455
65
 
456
- ## Further Resources
66
+ We understand that you might not be able to share your company's project code. Please provide a minimal reproducible example that demonstrates the issue by using tools like [Stackblitz](https://stackblitz.com) or a link to a Github Repo lease make sure you include a README file with the instructions to build and run the project, important not to include any access token, password or personal information of any kind.
457
67
 
458
- - [Quick Start](https://www.storyblok.com/technologies?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue)
459
- - [API Documentation](https://www.storyblok.com/docs/api?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue)
460
- - [Developer Tutorials](https://www.storyblok.com/tutorials?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue)
461
- - [Developer Guides](https://www.storyblok.com/docs/guide/introduction?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue)
462
- - [FAQs](https://www.storyblok.com/faqs?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue)
68
+ ### Feedback
463
69
 
464
- ## Support
70
+ If you have a question, please ask in the [Discuss Storyblok on Discord](https://discord.gg/jKrbAMz) channel.
465
71
 
466
- - Bugs or Feature Requests? [Submit an issue](/../../issues/new).
467
- - Do you have questions about Storyblok or you need help? [Join our Discord Community](https://discord.gg/jKrbAMz).
468
72
 
469
- ## Contributing
73
+ ## License
470
74
 
471
- Please see our [contributing guidelines](https://github.com/storyblok/.github/blob/master/contributing.md) and our [code of conduct](https://www.storyblok.com/trust-center?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-vue#code-of-conduct).
472
- This project use [semantic-release](https://semantic-release.gitbook.io/semantic-release/) for generate new versions by using commit messages and we use the Angular Convention to naming the commits. Check [this question](https://semantic-release.gitbook.io/semantic-release/support/faq#how-can-i-change-the-type-of-commits-that-trigger-a-release) about it in semantic-release FAQ.
75
+ [License](/LICENSE)
@@ -4,5 +4,5 @@
4
4
  * description: SDK to integrate Storyblok into your project using Vue.
5
5
  * author: Storyblok
6
6
  */
7
- (function(v,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],f):(v=typeof globalThis<"u"?globalThis:v||self,f(v.storyblokVue={},v.Vue))})(this,function(v,f){"use strict";function Z(s,e){if(!e)return{src:s,attrs:{}};let t=0,o=0;const r={},n=[];function i(c,u,m,y,A){typeof c!="number"||c<=u||c>=m?console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase()+y.slice(1)} value must be a number between ${u} and ${m} (inclusive)`):A.push(`${y}(${c})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(r.width=e.width,t=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(r.height=e.height,o=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(r.loading=e.loading),e.class&&(r.class=e.class),e.filters){const{filters:c}=e||{},{blur:u,brightness:m,fill:y,format:A,grayscale:L,quality:S,rotate:O}=c||{};u&&i(u,0,100,"blur",n),S&&i(S,0,100,"quality",n),m&&i(m,0,100,"brightness",n),y&&n.push(`fill(${y})`),L&&n.push("grayscale()"),O&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${O})`),A&&["webp","png","jpeg"].includes(A)&&n.push(`format(${A})`)}e.srcset&&(r.srcset=e.srcset.map(c=>{if(typeof c=="number")return`${s}/m/${c}x0/${n.length>0?`filters:${n.join(":")}`:""} ${c}w`;if(Array.isArray(c)&&c.length===2){const[u,m]=c;return`${s}/m/${u}x${m}/${n.length>0?`filters:${n.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(r.sizes=e.sizes.join(", "))}let l=`${s}/m/`;return t>0&&o>0&&(l=`${l}${t}x${o}/`),n.length>0&&(l=`${l}filters:${n.join(":")}`),{src:l,attrs:r}}var k=(s=>(s.DOCUMENT="doc",s.HEADING="heading",s.PARAGRAPH="paragraph",s.QUOTE="blockquote",s.OL_LIST="ordered_list",s.UL_LIST="bullet_list",s.LIST_ITEM="list_item",s.CODE_BLOCK="code_block",s.HR="horizontal_rule",s.BR="hard_break",s.IMAGE="image",s.EMOJI="emoji",s.COMPONENT="blok",s.TABLE="table",s.TABLE_ROW="tableRow",s.TABLE_CELL="tableCell",s.TABLE_HEADER="tableHeader",s))(k||{}),$=(s=>(s.BOLD="bold",s.STRONG="strong",s.STRIKE="strike",s.UNDERLINE="underline",s.ITALIC="italic",s.CODE="code",s.LINK="link",s.ANCHOR="anchor",s.STYLED="styled",s.SUPERSCRIPT="superscript",s.SUBSCRIPT="subscript",s.TEXT_STYLE="textStyle",s.HIGHLIGHT="highlight",s))($||{}),x=(s=>(s.TEXT="text",s))(x||{}),C=(s=>(s.URL="url",s.STORY="story",s.ASSET="asset",s.EMAIL="email",s))(C||{});const ee=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],te=(s={})=>Object.keys(s).map(e=>`${e}="${s[e]}"`).join(" "),se=(s={})=>Object.keys(s).map(e=>`${e}: ${s[e]}`).join("; ");function re(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const j=s=>Object.fromEntries(Object.entries(s).filter(([e,t])=>t!==void 0));function F(s,e={},t){const o=te(e),r=o?`${s} ${o}`:s,n=Array.isArray(t)?t.join(""):t||"";if(s){if(ee.includes(s))return`<${r}>`}else return n;return`<${r}>${n}</${s}>`}function D(s={}){const e=new Map,{renderFn:t=F,textFn:o=re,resolvers:r={},optimizeImages:n=!1,keyedResolvers:i=!1}=s,l=t!==F,c=()=>({render:(a,h={},d)=>{if(i&&a){const p=e.get(a)||0;e.set(a,p+1),h.key=`${a}-${p}`}return t(a,h,d)}}),u=a=>(h,d)=>{const p=h.attrs||{};return d.render(a,p,h.children||null)},m=(a,h)=>{const{src:d,alt:p,title:g,srcset:w,sizes:_}=a.attrs||{};let T=d,R={};if(n){const{src:He,attrs:Ue}=Z(d,n);T=He,R=Ue}const Be={src:T,alt:p,title:g,srcset:w,sizes:_,...R};return h.render("img",j(Be))},y=(a,h)=>{const{level:d,...p}=a.attrs||{};return h.render(`h${d}`,p,a.children)},A=(a,h)=>{var d,p,g,w;const _=h.render("img",{src:(d=a.attrs)==null?void 0:d.fallbackImage,alt:(p=a.attrs)==null?void 0:p.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return h.render("span",{"data-type":"emoji","data-name":(g=a.attrs)==null?void 0:g.name,"data-emoji":(w=a.attrs)==null?void 0:w.emoji},_)},L=(a,h)=>h.render("pre",a.attrs||{},h.render("code",{},a.children||"")),S=(a,h=!1)=>({text:d,attrs:p},g)=>{const{class:w,id:_,...T}=p||{},R=h?{class:w,id:_,style:se(T)||void 0}:p||{};return g.render(a,j(R),d)},O=a=>M(a),Le=a=>{const{marks:h,...d}=a;if("text"in a){if(h)return h.reduce((g,w)=>O({...w,text:g}),O({...d,children:d.children}));const p=a.attrs||{};if(i){const g=e.get("txt")||0;e.set("txt",g+1),p.key=`txt-${g}`}return o(d.text,p)}return""},Q=(a,h)=>{const{linktype:d,href:p,anchor:g,...w}=a.attrs||{};let _="";switch(d){case C.ASSET:case C.URL:_=p;break;case C.EMAIL:_=`mailto:${p}`;break;case C.STORY:_=p,g&&(_=`${_}#${g}`);break;default:_=p;break}const T={...w};return _&&(T.href=_),h.render("a",T,a.text)},Oe=(a,h)=>{var d,p;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.render("span",{blok:(d=a==null?void 0:a.attrs)==null?void 0:d.body[0],id:(p=a.attrs)==null?void 0:p.id,style:"display: none"})},je=(a,h)=>{const d={},p=h.render("tbody",{},a.children);return h.render("table",d,p)},Pe=(a,h)=>{const d={};return h.render("tr",d,a.children)},Ne=(a,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:w,..._}=a.attrs||{},T={..._};d>1&&(T.colspan=d),p>1&&(T.rowspan=p);const R=[];return g&&R.push(`width: ${g}px;`),w&&R.push(`background-color: ${w};`),R.length>0&&(T.style=R.join(" ")),h.render("td",j(T),a.children)},xe=(a,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:w,..._}=a.attrs||{},T={..._};d>1&&(T.colspan=d),p>1&&(T.rowspan=p);const R=[];return g&&R.push(`width: ${g}px;`),w&&R.push(`background-color: ${w};`),R.length>0&&(T.style=R.join(" ")),h.render("th",j(T),a.children)},De=new Map([[k.DOCUMENT,u("")],[k.HEADING,y],[k.PARAGRAPH,u("p")],[k.UL_LIST,u("ul")],[k.OL_LIST,u("ol")],[k.LIST_ITEM,u("li")],[k.IMAGE,m],[k.EMOJI,A],[k.CODE_BLOCK,L],[k.HR,u("hr")],[k.BR,u("br")],[k.QUOTE,u("blockquote")],[k.COMPONENT,Oe],[x.TEXT,Le],[$.LINK,Q],[$.ANCHOR,Q],[$.STYLED,S("span",!0)],[$.BOLD,S("strong")],[$.TEXT_STYLE,S("span",!0)],[$.ITALIC,S("em")],[$.UNDERLINE,S("u")],[$.STRIKE,S("s")],[$.CODE,S("code")],[$.SUPERSCRIPT,S("sup")],[$.SUBSCRIPT,S("sub")],[$.HIGHLIGHT,S("mark")],[k.TABLE,je],[k.TABLE_ROW,Pe],[k.TABLE_CELL,Ne],[k.TABLE_HEADER,xe],...Object.entries(r).map(([a,h])=>[a,h])]);function N(a){const h=De.get(a.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${a.type}`),"";const d=c();if(a.type==="text")return h(a,d);const p=a.content?a.content.map(M):void 0;return h({...a,children:p},d)}function M(a){return a.type==="doc"?l?a.content.map(N):a.content.map(N).join(""):Array.isArray(a)?a.map(N):N(a)}return{render:M}}let V=!1;const z=[],oe=s=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}V?r():z.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const o=document.createElement("script");o.async=!0,o.src=s,o.id="storyblok-javascript-bridge",o.onerror=r=>t(r),o.onload=r=>{z.forEach(n=>n()),V=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(o)});var ne=Object.defineProperty,ie=(s,e,t)=>e in s?ne(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,b=(s,e,t)=>ie(s,typeof e!="symbol"?e+"":e,t);class ae extends Error{constructor(e){super(e),this.name="AbortError"}}function le(s,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const o=[];let r=[],n=0,i=!1;const l=async()=>{n++;const u=o.shift();if(u)try{const y=await s(...u.args);u.resolve(y)}catch(y){u.reject(y)}const m=setTimeout(()=>{n--,o.length>0&&l(),r=r.filter(y=>y!==m)},t);r.includes(m)||r.push(m)},c=(...u)=>i?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((m,y)=>{o.push({resolve:m,reject:y,args:u}),n<e&&l()});return c.abort=()=>{i=!0,r.forEach(clearTimeout),r=[],o.forEach(u=>u.reject(()=>new ae("Throttle function aborted"))),o.length=0},c}const ce=(s="")=>s.includes("/cdn/"),ue=(s,e=25,t=1)=>({...s,per_page:e,page:t}),he=s=>new Promise(e=>setTimeout(e,s)),de=(s=0,e)=>Array.from({length:s},e),pe=(s=0,e=s)=>{const t=Math.abs(e-s)||0,o=s<e?1:-1;return de(t,(r,n)=>n*o+s)},fe=async(s,e)=>Promise.all(s.map(e)),me=(s=[],e)=>s.map(e).reduce((t,o)=>[...t,...o],[]),B=(s,e,t)=>{const o=[];for(const r in s){if(!Object.prototype.hasOwnProperty.call(s,r))continue;const n=s[r];if(n==null)continue;const i=t?"":encodeURIComponent(r);let l;typeof n=="object"?l=B(n,e?e+encodeURIComponent(`[${i}]`):i,Array.isArray(n)):l=`${e?e+encodeURIComponent(`[${i}]`):i}=${encodeURIComponent(n)}`,o.push(l)}return o.join("&")},q=s=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[s]??e.eu};class ye{constructor(e){b(this,"baseURL"),b(this,"timeout"),b(this,"headers"),b(this,"responseInterceptor"),b(this,"fetch"),b(this,"ejectInterceptor"),b(this,"url"),b(this,"parameters"),b(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],o={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(r=>{o.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return o.headers={...t},o.status=e.status,o.statusText=e.statusText,o}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,o=null;e==="get"?t=`${this.baseURL}${this.url}?${B(this.parameters)}`:o=JSON.stringify(this.parameters);const r=new URL(t),n=new AbortController,{signal:i}=n;let l;this.timeout&&(l=setTimeout(()=>n.abort(),this.timeout));try{const c=await this.fetch(`${r}`,{method:e,headers:this.headers,body:o,signal:i,...this.fetchOptions});this.timeout&&clearTimeout(l);const u=await this._responseHandler(c);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(u)):this._statusHandler(u)}catch(c){return{message:c}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((o,r)=>{if(t.test(`${e.status}`))return o(e);const n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};r(n)})}}const G="SB-Agent",H={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"},be={DRAFT:"draft"};let P={};const E={};class ke{constructor(e,t){b(this,"client"),b(this,"maxRetries"),b(this,"retriesDelay"),b(this,"throttle"),b(this,"accessToken"),b(this,"cache"),b(this,"resolveCounter"),b(this,"relations"),b(this,"links"),b(this,"version"),b(this,"richTextResolver"),b(this,"resolveNestedRelations"),b(this,"stringifiedStoriesCache"),b(this,"inlineAssets");let o=e.endpoint||t;if(!o){const i=e.https===!1?"http":"https";e.oauthToken?o=`${i}://${q(e.region)}/v1`:o=`${i}://${q(e.region)}/v2`}const r=new Headers;r.set("Content-Type","application/json"),r.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([i,l])=>{r.set(i,l)}),r.has(G)||(r.set(G,H.defaultAgentName),r.set(H.defaultAgentVersion,H.packageVersion));let n=5;e.oauthToken&&(r.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=le(this.throttledRequest.bind(this),n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||be.DRAFT,this.inlineAssets=e.inlineAssets||!1,this.client=new ye({baseURL:o,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=E[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return ce(e)?this.parseParams(t):t}makeRequest(e,t,o,r,n){const i=this.factoryParamOptions(e,ue(t,o,r));return this.cacheResponse(e,i,void 0,n)}get(e,t={},o){t||(t={});const r=`/${e}`;t.version=t.version||this.version;const n=this.factoryParamOptions(r,t);return this.cacheResponse(r,n,void 0,o)}async getAll(e,t={},o,r){const n=(t==null?void 0:t.per_page)||25,i=`/${e}`.replace(/\/$/,""),l=o??i.substring(i.lastIndexOf("/")+1);t.version=t.version||this.version;const c=1,u=await this.makeRequest(i,t,n,c,r),m=u.total?Math.ceil(u.total/n):1,y=await fe(pe(c,m),A=>this.makeRequest(i,t,n,A+1,r));return me([u,...y],A=>Object.values(A.data[l]))}post(e,t={},o){const r=`/${e}`;return this.throttle("post",r,t,o)}put(e,t={},o){const r=`/${e}`;return this.throttle("put",r,t,o)}delete(e,t={},o){t||(t={});const r=`/${e}`;return this.throttle("delete",r,t,o)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},o){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,o)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,o){const r=e[t];r&&r.fieldtype==="multilink"&&r.linktype==="story"&&typeof r.id=="string"&&this.links[o][r.id]?r.story=this._cleanCopy(this.links[o][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[o][r.uuid]&&(r.story=this._cleanCopy(this.links[o][r.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,o){const r=e[t];typeof r=="string"?e[t]=this.getStoryReference(o,r):Array.isArray(r)&&(e[t]=r.map(n=>this.getStoryReference(o,n)).filter(Boolean))}_insertRelations(e,t,o,r){if(Array.isArray(o)?o.find(i=>i.endsWith(`.${t}`)):o.endsWith(`.${t}`)){this._resolveField(e,t,r);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(o)?o.includes(n):o===n)&&this._resolveField(e,t,r)}iterateTree(e,t,o){const r=(n,i="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((l,c)=>r(l,`${i}[${c}]`));else if(typeof n=="object")for(const l in n){const c=i?`${i}.${l}`:l;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,l,t,o),this._insertLinks(n,l,o)),r(n[l],c)}}};r(e.content)}async resolveLinks(e,t,o){let r=[];if(e.link_uuids){const n=e.link_uuids.length,i=[],l=50;for(let c=0;c<n;c+=l){const u=Math.min(n,c+l);i.push(e.link_uuids.slice(c,u))}for(let c=0;c<i.length;c++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[c].join(",")})).data.stories.forEach(u=>{r.push(u)})}else r=e.links;r.forEach(n=>{this.links[o][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,o){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length,i=[],l=50;for(let c=0;c<n;c+=l){const u=Math.min(n,c+l);i.push(e.rel_uuids.slice(c,u))}for(let c=0;c<i.length;c++)(await this.getStories({per_page:l,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:i[c].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(u=>{r.push(u)});r.length>0&&(e.rels=r,delete e.rel_uuids)}else r=e.rels;r&&r.length>0&&r.forEach(n=>{this.relations[o][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,o){var r,n;let i=[];if(this.links[o]={},this.relations[o]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(i=t.resolve_relations.split(",")),await this.resolveRelations(e,t,o)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((r=e.links)!=null&&r.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,o),this.resolveNestedRelations)for(const l in this.relations[o])this.iterateTree(this.relations[o][l],i,o);e.story?this.iterateTree(e.story,i,o):e.stories.forEach(l=>{this.iterateTree(l,i,o)}),this.stringifiedStoriesCache={},delete this.links[o],delete this.relations[o]}async cacheResponse(e,t,o,r){const n=B({url:e,params:t}),i=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const l=await i.get(n);if(l)return Promise.resolve(l)}return new Promise(async(l,c)=>{var u;try{const m=await this.throttle("get",e,t,r);if(m.status!==200)return c(m);let y={data:m.data,headers:m.headers};if((u=m.headers)!=null&&u["per-page"]&&(y=Object.assign({},y,{perPage:m.headers["per-page"]?Number.parseInt(m.headers["per-page"]):0,total:m.headers["per-page"]?Number.parseInt(m.headers.total):0})),y.data.story||y.data.stories){const L=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${L}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await i.set(n,y);const A=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&(A&&E[t.token]&&E[t.token]!==y.data.cv&&await this.flushCache(),E[t.token]=y.data.cv),l(y)}catch(m){if(m.response&&m.status===429&&(o=typeof o>"u"?0:o+1,o<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await he(this.retriesDelay),this.cacheResponse(e,t,o).then(l).catch(c);c(m)}})}throttledRequest(e,t,o,r){return this.client.setFetchOptions(r),this.client[e](t,o)}cacheVersions(){return E}cacheVersion(){return E[this.accessToken]}setCacheVersion(e){this.accessToken&&(E[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(E[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(P[e])},getAll(){return Promise.resolve(P)},set(e,t){return P[e]=t,Promise.resolve(void 0)},flush(){return P={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=o=>{if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>t(n));let r={...o};r.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(r={...r,...e.data.assets.find(n=>n.id===r.id)});for(const n in r)typeof r[n]=="object"&&(r[n]=t(r[n]));return r};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(o=>(o.content=t(o.content),o))),e}}const ge=(s={})=>{const{apiOptions:e}=s;if(!e||!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new ke(e)}},ve=s=>{if(typeof s!="object"||typeof s._editable>"u")return{};try{const e=JSON.parse(s._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let J="https://app.storyblok.com/f/storyblok-v2-latest.js";const K=(s,e,t={})=>{var o;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((o=window.location)==null?void 0:o.href).searchParams.get("_storyblok"),i=n!==null&&+n===s;if(!(!r||!i)){if(!s){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],l=>{var c;l&&(l.action==="input"&&((c=l.story)==null?void 0:c.id)===s?e(l.story):(l.action==="change"||l.action==="published")&&l.storyId===s&&window.location.reload())})})}},_e=(s={})=>{var e,t;const{bridge:o,accessToken:r,use:n=[],apiOptions:i={},bridgeUrl:l}=s;i.accessToken=i.accessToken||r;const c={bridge:o,apiOptions:i};let u={};n.forEach(y=>{u={...u,...y(c)}}),l&&(J=l);const m=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return o!==!1&&m&&oe(J),u};function Te(s,e){return D(e).render(s)}const U=f.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(s,{expose:e}){const t=s,o=f.ref();e({value:o});const r=typeof f.resolveDynamicComponent(t.blok.component)!="string",n=f.inject("VueSDKOptions"),i=f.ref(t.blok.component);return!r&&n&&(n.enableFallbackComponent?(i.value=n.customFallbackComponent??"FallbackComponent",typeof f.resolveDynamicComponent(i.value)=="string"&&console.error(`Is the Fallback component "${i.value}" registered properly?`)):console.error(`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`)),(l,c)=>(f.openBlock(),f.createBlock(f.resolveDynamicComponent(i.value),f.mergeProps({ref_key:"blokRef",ref:o},{...l.$props,...l.$attrs}),null,16))}}),we=s=>{var e,t;return f.h(U,{blok:(e=s==null?void 0:s.attrs)==null?void 0:e.body[0],id:(t=s.attrs)==null?void 0:t.id},s.children)};function Y(s){const e={renderFn:f.h,textFn:f.createTextVNode,keyedResolvers:!0,resolvers:{[k.COMPONENT]:we,...s.resolvers}};return D(e)}const W=f.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(s){const e=s,t=f.ref(),o=()=>t.value;return f.watch([()=>e.doc,()=>e.resolvers],([r,n])=>{const{render:i}=Y({resolvers:n??{}});t.value=i(r)},{immediate:!0,deep:!0}),(r,n)=>(f.openBlock(),f.createBlock(o))}}),$e={beforeMount(s,e){if(e.value){const t=ve(e.value);Object.keys(t).length>0&&(s.setAttribute("data-blok-c",t["data-blok-c"]),s.setAttribute("data-blok-uid",t["data-blok-uid"]),s.classList.add("storyblok__outline"))}}},X=s=>{console.error(`You can't use ${s} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
8
- `)};let I=null;const Re=()=>(I||X("useStoryblokApi"),I),Ae=async(s,e={},t={})=>{const o=f.ref(null);if(t.resolveRelations=t.resolveRelations??e.resolve_relations,t.resolveLinks=t.resolveLinks??e.resolve_links,f.onMounted(()=>{o.value&&o.value.id&&K(o.value.id,r=>o.value=r,t)}),I){const{data:r}=await I.get(`cdn/stories/${s}`,e);o.value=r.story}else X("useStoryblok");return o},Se={install(s,e={}){s.directive("editable",$e),s.component("StoryblokComponent",U),s.component("StoryblokRichText",W),e.enableFallbackComponent&&!e.customFallbackComponent&&s.component("FallbackComponent",f.defineAsyncComponent(()=>Promise.resolve().then(()=>Ie)));const{storyblokApi:t}=_e(e);I=t||null,s.provide("VueSDKOptions",e)}},Ee={class:"fallback-component"},Ce={class:"component"},Ie=Object.freeze(Object.defineProperty({__proto__:null,default:((s,e)=>{const t=s.__vccOpts||s;for(const[o,r]of e)t[o]=r;return t})(f.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(s){return(e,t)=>(f.openBlock(),f.createElementBlock("div",Ee,[f.createElementVNode("p",null,[t[0]||(t[0]=f.createTextVNode(" Component could not be found for blok ")),f.createElementVNode("span",Ce,f.toDisplayString(e.blok.component),1),t[1]||(t[1]=f.createTextVNode("! Is it configured correctly? "))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));v.BlockTypes=k,v.MarkTypes=$,v.StoryblokComponent=U,v.StoryblokRichText=W,v.StoryblokVue=Se,v.TextTypes=x,v.apiPlugin=ge,v.renderRichText=Te,v.richTextResolver=D,v.useStoryblok=Ae,v.useStoryblokApi=Re,v.useStoryblokBridge=K,v.useStoryblokRichText=Y,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
7
+ (function(v,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],f):(v=typeof globalThis<"u"?globalThis:v||self,f(v.storyblokVue={},v.Vue))})(this,function(v,f){"use strict";function te(s,e){if(!e)return{src:s,attrs:{}};let t=0,o=0;const r={},n=[];function a(i,u,m,y,E){typeof i!="number"||i<=u||i>=m?console.warn(`[StoryblokRichText] - ${y.charAt(0).toUpperCase()+y.slice(1)} value must be a number between ${u} and ${m} (inclusive)`):E.push(`${y}(${i})`)}if(typeof e=="object"){if(typeof e.width=="number"&&e.width>0?(r.width=e.width,t=e.width):console.warn("[StoryblokRichText] - Width value must be a number greater than 0"),e.height&&typeof e.height=="number"&&e.height>0?(r.height=e.height,o=e.height):console.warn("[StoryblokRichText] - Height value must be a number greater than 0"),e.loading&&["lazy","eager"].includes(e.loading)&&(r.loading=e.loading),e.class&&(r.class=e.class),e.filters){const{filters:i}=e||{},{blur:u,brightness:m,fill:y,format:E,grayscale:$,quality:L,rotate:P}=i||{};u&&a(u,0,100,"blur",n),L&&a(L,0,100,"quality",n),m&&a(m,0,100,"brightness",n),y&&n.push(`fill(${y})`),$&&n.push("grayscale()"),P&&[0,90,180,270].includes(e.filters.rotate||0)&&n.push(`rotate(${P})`),E&&["webp","png","jpeg"].includes(E)&&n.push(`format(${E})`)}e.srcset&&(r.srcset=e.srcset.map(i=>{if(typeof i=="number")return`${s}/m/${i}x0/${n.length>0?`filters:${n.join(":")}`:""} ${i}w`;if(Array.isArray(i)&&i.length===2){const[u,m]=i;return`${s}/m/${u}x${m}/${n.length>0?`filters:${n.join(":")}`:""} ${u}w`}else{console.warn("[StoryblokRichText] - srcset entry must be a number or a tuple of two numbers");return}}).join(", ")),e.sizes&&(r.sizes=e.sizes.join(", "))}let c=`${s}/m/`;return t>0&&o>0&&(c=`${c}${t}x${o}/`),n.length>0&&(c=`${c}filters:${n.join(":")}`),{src:c,attrs:r}}var k=(s=>(s.DOCUMENT="doc",s.HEADING="heading",s.PARAGRAPH="paragraph",s.QUOTE="blockquote",s.OL_LIST="ordered_list",s.UL_LIST="bullet_list",s.LIST_ITEM="list_item",s.CODE_BLOCK="code_block",s.HR="horizontal_rule",s.BR="hard_break",s.IMAGE="image",s.EMOJI="emoji",s.COMPONENT="blok",s.TABLE="table",s.TABLE_ROW="tableRow",s.TABLE_CELL="tableCell",s.TABLE_HEADER="tableHeader",s))(k||{}),R=(s=>(s.BOLD="bold",s.STRONG="strong",s.STRIKE="strike",s.UNDERLINE="underline",s.ITALIC="italic",s.CODE="code",s.LINK="link",s.ANCHOR="anchor",s.STYLED="styled",s.SUPERSCRIPT="superscript",s.SUBSCRIPT="subscript",s.TEXT_STYLE="textStyle",s.HIGHLIGHT="highlight",s))(R||{}),x=(s=>(s.TEXT="text",s))(x||{}),C=(s=>(s.URL="url",s.STORY="story",s.ASSET="asset",s.EMAIL="email",s))(C||{});const se=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],re=(s={})=>Object.keys(s).map(e=>`${e}="${s[e]}"`).join(" "),oe=(s={})=>Object.keys(s).map(e=>`${e}: ${s[e]}`).join("; ");function ne(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const O=s=>Object.fromEntries(Object.entries(s).filter(([e,t])=>t!==void 0));function F(s,e={},t){const o=re(e),r=o?`${s} ${o}`:s,n=Array.isArray(t)?t.join(""):t||"";if(s){if(se.includes(s))return`<${r}>`}else return n;return`<${r}>${n}</${s}>`}function D(s={}){const e=new Map,{renderFn:t=F,textFn:o=ne,resolvers:r={},optimizeImages:n=!1,keyedResolvers:a=!1}=s,c=t!==F,i=l=>(h,d)=>{const p=h.attrs||{};return d.render(l,p,h.children||null)},u=(l,h)=>{const{src:d,alt:p,title:g,srcset:T,sizes:_}=l.attrs||{};let w=d,A={};if(n){const{src:Ue,attrs:Me}=te(d,n);w=Ue,A=Me}const He={src:w,alt:p,title:g,srcset:T,sizes:_,...A};return h.render("img",O(He))},m=(l,h)=>{const{level:d,...p}=l.attrs||{};return h.render(`h${d}`,p,l.children)},y=(l,h)=>{var d,p,g,T;const _=h.render("img",{src:(d=l.attrs)==null?void 0:d.fallbackImage,alt:(p=l.attrs)==null?void 0:p.alt,style:"width: 1.25em; height: 1.25em; vertical-align: text-top",draggable:"false",loading:"lazy"});return h.render("span",{"data-type":"emoji","data-name":(g=l.attrs)==null?void 0:g.name,"data-emoji":(T=l.attrs)==null?void 0:T.emoji},_)},E=(l,h)=>h.render("pre",l.attrs||{},h.render("code",{},l.children||"")),$=(l,h=!1)=>({text:d,attrs:p},g)=>{const{class:T,id:_,...w}=p||{},A=h?{class:T,id:_,style:oe(w)||void 0}:p||{};return g.render(l,O(A),d)},L=l=>M(l),P=l=>{const{marks:h,...d}=l;if("text"in l){if(h)return h.reduce((g,T)=>L({...T,text:g}),L({...d,children:d.children}));const p=l.attrs||{};if(a){const g=e.get("txt")||0;e.set("txt",g+1),p.key=`txt-${g}`}return o(d.text,p)}return""},Q=(l,h)=>{const{linktype:d,href:p,anchor:g,...T}=l.attrs||{};let _="";switch(d){case C.ASSET:case C.URL:_=p;break;case C.EMAIL:_=`mailto:${p}`;break;case C.STORY:_=p,g&&(_=`${_}#${g}`);break;default:_=p;break}const w={...T};return _&&(w.href=_),h.render("a",w,l.text)},je=(l,h)=>{var d,p;return console.warn("[StoryblokRichtText] - BLOK resolver is not available for vanilla usage"),h.render("span",{blok:(d=l==null?void 0:l.attrs)==null?void 0:d.body[0],id:(p=l.attrs)==null?void 0:p.id,style:"display: none"})},Pe=(l,h)=>{const d={},p=h.render("tbody",{},l.children);return h.render("table",d,p)},Ne=(l,h)=>{const d={};return h.render("tr",d,l.children)},xe=(l,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:T,..._}=l.attrs||{},w={..._};d>1&&(w.colspan=d),p>1&&(w.rowspan=p);const A=[];return g&&A.push(`width: ${g}px;`),T&&A.push(`background-color: ${T};`),A.length>0&&(w.style=A.join(" ")),h.render("td",O(w),l.children)},De=(l,h)=>{const{colspan:d,rowspan:p,colwidth:g,backgroundColor:T,..._}=l.attrs||{},w={..._};d>1&&(w.colspan=d),p>1&&(w.rowspan=p);const A=[];return g&&A.push(`width: ${g}px;`),T&&A.push(`background-color: ${T};`),A.length>0&&(w.style=A.join(" ")),h.render("th",O(w),l.children)},Z=new Map([[k.DOCUMENT,i("")],[k.HEADING,m],[k.PARAGRAPH,i("p")],[k.UL_LIST,i("ul")],[k.OL_LIST,i("ol")],[k.LIST_ITEM,i("li")],[k.IMAGE,u],[k.EMOJI,y],[k.CODE_BLOCK,E],[k.HR,i("hr")],[k.BR,i("br")],[k.QUOTE,i("blockquote")],[k.COMPONENT,je],[x.TEXT,P],[R.LINK,Q],[R.ANCHOR,Q],[R.STYLED,$("span",!0)],[R.BOLD,$("strong")],[R.TEXT_STYLE,$("span",!0)],[R.ITALIC,$("em")],[R.UNDERLINE,$("u")],[R.STRIKE,$("s")],[R.CODE,$("code")],[R.SUPERSCRIPT,$("sup")],[R.SUBSCRIPT,$("sub")],[R.HIGHLIGHT,$("mark")],[k.TABLE,Pe],[k.TABLE_ROW,Ne],[k.TABLE_CELL,xe],[k.TABLE_HEADER,De]]),ee=new Map([...Z,...Object.entries(r).map(([l,h])=>[l,h])]),Be=()=>({render:(l,h={},d)=>{if(a&&l){const p=e.get(l)||0;e.set(l,p+1),h.key=`${l}-${p}`}return t(l,h,d)},originalResolvers:Z,mergedResolvers:ee});function N(l){const h=ee.get(l.type);if(!h)return console.error("<Storyblok>",`No resolver found for node type ${l.type}`),"";const d=Be();if(l.type==="text")return h(l,d);const p=l.content?l.content.map(M):void 0;return h({...l,children:p},d)}function M(l){return l.type==="doc"?c?l.content.map(N):l.content.map(N).join(""):Array.isArray(l)?l.map(N):N(l)}return{render:M}}let V=!1;const z=[],ie=s=>new Promise((e,t)=>{if(typeof window>"u"||(window.storyblokRegisterEvent=r=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}V?r():z.push(r)},document.getElementById("storyblok-javascript-bridge")))return;const o=document.createElement("script");o.async=!0,o.src=s,o.id="storyblok-javascript-bridge",o.onerror=r=>t(r),o.onload=r=>{z.forEach(n=>n()),V=!0,e(r)},document.getElementsByTagName("head")[0].appendChild(o)});var ae=Object.defineProperty,le=(s,e,t)=>e in s?ae(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,b=(s,e,t)=>le(s,typeof e!="symbol"?e+"":e,t);class ce extends Error{constructor(e){super(e),this.name="AbortError"}}function ue(s,e,t){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");const o=[];let r=[],n=0,a=!1;const c=async()=>{n++;const u=o.shift();if(u)try{const y=await s(...u.args);u.resolve(y)}catch(y){u.reject(y)}const m=setTimeout(()=>{n--,o.length>0&&c(),r=r.filter(y=>y!==m)},t);r.includes(m)||r.push(m)},i=(...u)=>a?Promise.reject(new Error("Throttled function is already aborted and not accepting new promises")):new Promise((m,y)=>{o.push({resolve:m,reject:y,args:u}),n<e&&c()});return i.abort=()=>{a=!0,r.forEach(clearTimeout),r=[],o.forEach(u=>u.reject(()=>new ce("Throttle function aborted"))),o.length=0},i}const he=(s="")=>s.includes("/cdn/"),de=(s,e=25,t=1)=>({...s,per_page:e,page:t}),pe=s=>new Promise(e=>setTimeout(e,s)),fe=(s=0,e)=>Array.from({length:s},e),me=(s=0,e=s)=>{const t=Math.abs(e-s)||0,o=s<e?1:-1;return fe(t,(r,n)=>n*o+s)},ye=async(s,e)=>Promise.all(s.map(e)),be=(s=[],e)=>s.map(e).reduce((t,o)=>[...t,...o],[]),B=(s,e,t)=>{const o=[];for(const r in s){if(!Object.prototype.hasOwnProperty.call(s,r))continue;const n=s[r];if(n==null)continue;const a=t?"":encodeURIComponent(r);let c;typeof n=="object"?c=B(n,e?e+encodeURIComponent(`[${a}]`):a,Array.isArray(n)):c=`${e?e+encodeURIComponent(`[${a}]`):a}=${encodeURIComponent(n)}`,o.push(c)}return o.join("&")},q=s=>{const e={eu:"api.storyblok.com",us:"api-us.storyblok.com",cn:"app.storyblokchina.cn",ap:"api-ap.storyblok.com",ca:"api-ca.storyblok.com"};return e[s]??e.eu};class ke{constructor(e){b(this,"baseURL"),b(this,"timeout"),b(this,"headers"),b(this,"responseInterceptor"),b(this,"fetch"),b(this,"ejectInterceptor"),b(this,"url"),b(this,"parameters"),b(this,"fetchOptions"),this.baseURL=e.baseURL,this.headers=e.headers||new Headers,this.timeout=e!=null&&e.timeout?e.timeout*1e3:0,this.responseInterceptor=e.responseInterceptor,this.fetch=(...t)=>e.fetch?e.fetch(...t):fetch(...t),this.ejectInterceptor=!1,this.url="",this.parameters={},this.fetchOptions={}}get(e,t){return this.url=e,this.parameters=t,this._methodHandler("get")}post(e,t){return this.url=e,this.parameters=t,this._methodHandler("post")}put(e,t){return this.url=e,this.parameters=t,this._methodHandler("put")}delete(e,t){return this.url=e,this.parameters=t??{},this._methodHandler("delete")}async _responseHandler(e){const t=[],o={data:{},headers:{},status:0,statusText:""};e.status!==204&&await e.json().then(r=>{o.data=r});for(const r of e.headers.entries())t[r[0]]=r[1];return o.headers={...t},o.status=e.status,o.statusText=e.statusText,o}async _methodHandler(e){let t=`${this.baseURL}${this.url}`,o=null;e==="get"?t=`${this.baseURL}${this.url}?${B(this.parameters)}`:o=JSON.stringify(this.parameters);const r=new URL(t),n=new AbortController,{signal:a}=n;let c;this.timeout&&(c=setTimeout(()=>n.abort(),this.timeout));try{const i=await this.fetch(`${r}`,{method:e,headers:this.headers,body:o,signal:a,...this.fetchOptions});this.timeout&&clearTimeout(c);const u=await this._responseHandler(i);return this.responseInterceptor&&!this.ejectInterceptor?this._statusHandler(this.responseInterceptor(u)):this._statusHandler(u)}catch(i){return{message:i}}}setFetchOptions(e={}){Object.keys(e).length>0&&"method"in e&&delete e.method,this.fetchOptions={...e}}eject(){this.ejectInterceptor=!0}_normalizeErrorMessage(e){if(Array.isArray(e))return e[0]||"Unknown error";if(e&&typeof e=="object"){if(e.error)return e.error;for(const t in e){if(Array.isArray(e[t]))return`${t}: ${e[t][0]}`;if(typeof e[t]=="string")return`${t}: ${e[t]}`}if(e.slug)return e.slug}return"Unknown error"}_statusHandler(e){const t=/20[0-6]/g;return new Promise((o,r)=>{if(t.test(`${e.status}`))return o(e);const n={message:this._normalizeErrorMessage(e.data),status:e.status,response:e};r(n)})}}const G="SB-Agent",H={defaultAgentName:"SB-JS-CLIENT",defaultAgentVersion:"SB-Agent-Version",packageVersion:"6.0.0"},ge={DRAFT:"draft"};let j={};const S={};class ve{constructor(e,t){b(this,"client"),b(this,"maxRetries"),b(this,"retriesDelay"),b(this,"throttle"),b(this,"accessToken"),b(this,"cache"),b(this,"resolveCounter"),b(this,"relations"),b(this,"links"),b(this,"version"),b(this,"richTextResolver"),b(this,"resolveNestedRelations"),b(this,"stringifiedStoriesCache"),b(this,"inlineAssets");let o=e.endpoint||t;if(!o){const a=e.https===!1?"http":"https";e.oauthToken?o=`${a}://${q(e.region)}/v1`:o=`${a}://${q(e.region)}/v2`}const r=new Headers;r.set("Content-Type","application/json"),r.set("Accept","application/json"),e.headers&&(e.headers.constructor.name==="Headers"?e.headers.entries().toArray():Object.entries(e.headers)).forEach(([a,c])=>{r.set(a,c)}),r.has(G)||(r.set(G,H.defaultAgentName),r.set(H.defaultAgentVersion,H.packageVersion));let n=5;e.oauthToken&&(r.set("Authorization",e.oauthToken),n=3),e.rateLimit&&(n=e.rateLimit),this.maxRetries=e.maxRetries||10,this.retriesDelay=300,this.throttle=ue(this.throttledRequest.bind(this),n,1e3),this.accessToken=e.accessToken||"",this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.resolveCounter=0,this.resolveNestedRelations=e.resolveNestedRelations||!0,this.stringifiedStoriesCache={},this.version=e.version||ge.DRAFT,this.inlineAssets=e.inlineAssets||!1,this.client=new ke({baseURL:o,timeout:e.timeout||0,headers:r,responseInterceptor:e.responseInterceptor,fetch:e.fetch})}parseParams(e){return e.token||(e.token=this.getToken()),e.cv||(e.cv=S[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),typeof e.resolve_relations<"u"&&(e.resolve_level=2),e}factoryParamOptions(e,t){return he(e)?this.parseParams(t):t}makeRequest(e,t,o,r,n){const a=this.factoryParamOptions(e,de(t,o,r));return this.cacheResponse(e,a,void 0,n)}get(e,t={},o){t||(t={});const r=`/${e}`;t.version=t.version||this.version;const n=this.factoryParamOptions(r,t);return this.cacheResponse(r,n,void 0,o)}async getAll(e,t={},o,r){const n=(t==null?void 0:t.per_page)||25,a=`/${e}`.replace(/\/$/,""),c=o??a.substring(a.lastIndexOf("/")+1);t.version=t.version||this.version;const i=1,u=await this.makeRequest(a,t,n,i,r),m=u.total?Math.ceil(u.total/n):1,y=await ye(me(i,m),E=>this.makeRequest(a,t,n,E+1,r));return be([u,...y],E=>Object.values(E.data[c]))}post(e,t={},o){const r=`/${e}`;return this.throttle("post",r,t,o)}put(e,t={},o){const r=`/${e}`;return this.throttle("put",r,t,o)}delete(e,t={},o){t||(t={});const r=`/${e}`;return this.throttle("delete",r,t,o)}getStories(e={},t){return this._addResolveLevel(e),this.get("cdn/stories",e,t)}getStory(e,t={},o){return this._addResolveLevel(t),this.get(`cdn/stories/${e}`,t,o)}getToken(){return this.accessToken}ejectInterceptor(){this.client.eject()}_addResolveLevel(e){typeof e.resolve_relations<"u"&&(e.resolve_level=2)}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t,o){const r=e[t];r&&r.fieldtype==="multilink"&&r.linktype==="story"&&typeof r.id=="string"&&this.links[o][r.id]?r.story=this._cleanCopy(this.links[o][r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[o][r.uuid]&&(r.story=this._cleanCopy(this.links[o][r.uuid]))}getStoryReference(e,t){return this.relations[e][t]?JSON.parse(this.stringifiedStoriesCache[t]||JSON.stringify(this.relations[e][t])):t}_resolveField(e,t,o){const r=e[t];typeof r=="string"?e[t]=this.getStoryReference(o,r):Array.isArray(r)&&(e[t]=r.map(n=>this.getStoryReference(o,n)).filter(Boolean))}_insertRelations(e,t,o,r){if(Array.isArray(o)?o.find(a=>a.endsWith(`.${t}`)):o.endsWith(`.${t}`)){this._resolveField(e,t,r);return}const n=e.component?`${e.component}.${t}`:t;(Array.isArray(o)?o.includes(n):o===n)&&this._resolveField(e,t,r)}iterateTree(e,t,o){const r=(n,a="")=>{if(!(!n||n._stopResolving)){if(Array.isArray(n))n.forEach((c,i)=>r(c,`${a}[${i}]`));else if(typeof n=="object")for(const c in n){const i=a?`${a}.${c}`:c;(n.component&&n._uid||n.type==="link")&&(this._insertRelations(n,c,t,o),this._insertLinks(n,c,o)),r(n[c],i)}}};r(e.content)}async resolveLinks(e,t,o){let r=[];if(e.link_uuids){const n=e.link_uuids.length,a=[],c=50;for(let i=0;i<n;i+=c){const u=Math.min(n,i+c);a.push(e.link_uuids.slice(i,u))}for(let i=0;i<a.length;i++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:a[i].join(",")})).data.stories.forEach(u=>{r.push(u)})}else r=e.links;r.forEach(n=>{this.links[o][n.uuid]={...n,_stopResolving:!0}})}async resolveRelations(e,t,o){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length,a=[],c=50;for(let i=0;i<n;i+=c){const u=Math.min(n,i+c);a.push(e.rel_uuids.slice(i,u))}for(let i=0;i<a.length;i++)(await this.getStories({per_page:c,language:t.language,version:t.version,starts_with:t.starts_with,by_uuids:a[i].join(","),excluding_fields:t.excluding_fields})).data.stories.forEach(u=>{r.push(u)});r.length>0&&(e.rels=r,delete e.rel_uuids)}else r=e.rels;r&&r.length>0&&r.forEach(n=>{this.relations[o][n.uuid]={...n,_stopResolving:!0}})}async resolveStories(e,t,o){var r,n;let a=[];if(this.links[o]={},this.relations[o]={},typeof t.resolve_relations<"u"&&t.resolve_relations.length>0&&(typeof t.resolve_relations=="string"&&(a=t.resolve_relations.split(",")),await this.resolveRelations(e,t,o)),t.resolve_links&&["1","story","url","link"].includes(t.resolve_links)&&((r=e.links)!=null&&r.length||(n=e.link_uuids)!=null&&n.length)&&await this.resolveLinks(e,t,o),this.resolveNestedRelations)for(const c in this.relations[o])this.iterateTree(this.relations[o][c],a,o);e.story?this.iterateTree(e.story,a,o):e.stories.forEach(c=>{this.iterateTree(c,a,o)}),this.stringifiedStoriesCache={},delete this.links[o],delete this.relations[o]}async cacheResponse(e,t,o,r){const n=B({url:e,params:t}),a=this.cacheProvider();if(t.version==="published"&&e!=="/cdn/spaces/me"){const c=await a.get(n);if(c)return Promise.resolve(c)}return new Promise(async(c,i)=>{var u;try{const m=await this.throttle("get",e,t,r);if(m.status!==200)return i(m);let y={data:m.data,headers:m.headers};if((u=m.headers)!=null&&u["per-page"]&&(y=Object.assign({},y,{perPage:m.headers["per-page"]?Number.parseInt(m.headers["per-page"]):0,total:m.headers["per-page"]?Number.parseInt(m.headers.total):0})),y.data.story||y.data.stories){const $=this.resolveCounter=++this.resolveCounter%1e3;await this.resolveStories(y.data,t,`${$}`),y=await this.processInlineAssets(y)}t.version==="published"&&e!=="/cdn/spaces/me"&&await a.set(n,y);const E=this.cache.clear==="onpreview"&&t.version==="draft"||this.cache.clear==="auto";return t.token&&y.data.cv&&(E&&S[t.token]&&S[t.token]!==y.data.cv&&await this.flushCache(),S[t.token]=y.data.cv),c(y)}catch(m){if(m.response&&m.status===429&&(o=typeof o>"u"?0:o+1,o<this.maxRetries))return console.log(`Hit rate limit. Retrying in ${this.retriesDelay/1e3} seconds.`),await pe(this.retriesDelay),this.cacheResponse(e,t,o).then(c).catch(i);i(m)}})}throttledRequest(e,t,o,r){return this.client.setFetchOptions(r),this.client[e](t,o)}cacheVersions(){return S}cacheVersion(){return S[this.accessToken]}setCacheVersion(e){this.accessToken&&(S[this.accessToken]=e)}clearCacheVersion(){this.accessToken&&(S[this.accessToken]=0)}cacheProvider(){switch(this.cache.type){case"memory":return{get(e){return Promise.resolve(j[e])},getAll(){return Promise.resolve(j)},set(e,t){return j[e]=t,Promise.resolve(void 0)},flush(){return j={},Promise.resolve(void 0)}};case"custom":if(this.cache.custom)return this.cache.custom;default:return{get(){return Promise.resolve()},getAll(){return Promise.resolve(void 0)},set(){return Promise.resolve(void 0)},flush(){return Promise.resolve(void 0)}}}}async flushCache(){return await this.cacheProvider().flush(),this.clearCacheVersion(),this}async processInlineAssets(e){if(!this.inlineAssets)return e;const t=o=>{if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>t(n));let r={...o};r.fieldtype==="asset"&&Array.isArray(e.data.assets)&&(r={...r,...e.data.assets.find(n=>n.id===r.id)});for(const n in r)typeof r[n]=="object"&&(r[n]=t(r[n]));return r};return e.data.story&&(e.data.story.content=t(e.data.story.content)),e.data.stories&&(e.data.stories=e.data.stories.map(o=>(o.content=t(o.content),o))),e}}const _e=(s={})=>{const{apiOptions:e}=s;if(!e||!e.accessToken){console.error("You need to provide an access token to interact with Storyblok API. Read https://www.storyblok.com/docs/api/content-delivery#topics/authentication");return}return{storyblokApi:new ve(e)}},we=s=>{if(typeof s!="object"||typeof s._editable>"u")return{};try{const e=JSON.parse(s._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return e?{"data-blok-c":JSON.stringify(e),"data-blok-uid":`${e.id}-${e.uid}`}:{}}catch{return{}}};let J="https://app.storyblok.com/f/storyblok-v2-latest.js";const K=(s,e,t={})=>{var o;const r=!(typeof window>"u")&&typeof window.storyblokRegisterEvent<"u",n=new URL((o=window.location)==null?void 0:o.href).searchParams.get("_storyblok"),a=n!==null&&+n===s;if(!(!r||!a)){if(!s){console.warn("Story ID is not defined. Please provide a valid ID.");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(t).on(["input","published","change"],c=>{var i;c&&(c.action==="input"&&((i=c.story)==null?void 0:i.id)===s?e(c.story):(c.action==="change"||c.action==="published")&&c.storyId===s&&window.location.reload())})})}},Te=(s={})=>{var e,t;const{bridge:o,accessToken:r,use:n=[],apiOptions:a={},bridgeUrl:c}=s;a.accessToken=a.accessToken||r;const i={bridge:o,apiOptions:a};let u={};n.forEach(y=>{u={...u,...y(i)}}),c&&(J=c);const m=!(typeof window>"u")&&((t=(e=window.location)==null?void 0:e.search)==null?void 0:t.includes("_storyblok_tk"));return o!==!1&&m&&ie(J),u};function Re(s,e){return D(e).render(s)}const U=f.defineComponent({__name:"StoryblokComponent",props:{blok:{}},setup(s,{expose:e}){const t=s,o=f.ref();e({value:o});const r=typeof f.resolveDynamicComponent(t.blok.component)!="string",n=f.inject("VueSDKOptions"),a=f.ref(t.blok.component);return!r&&n&&(n.enableFallbackComponent?(a.value=n.customFallbackComponent??"FallbackComponent",typeof f.resolveDynamicComponent(a.value)=="string"&&console.error(`Is the Fallback component "${a.value}" registered properly?`)):console.error(`Component could not be found for blok "${t.blok.component}"! Is it defined in main.ts as "app.component("${t.blok.component}", ${t.blok.component});"?`)),(c,i)=>(f.openBlock(),f.createBlock(f.resolveDynamicComponent(a.value),f.mergeProps({ref_key:"blokRef",ref:o},{...c.$props,...c.$attrs}),null,16))}}),$e=s=>{var e,t;return f.h(U,{blok:(e=s==null?void 0:s.attrs)==null?void 0:e.body[0],id:(t=s.attrs)==null?void 0:t.id},s.children)};function Y(s){const e={renderFn:f.h,textFn:f.createTextVNode,keyedResolvers:!0,resolvers:{[k.COMPONENT]:$e,...s.resolvers}};return D(e)}const W=f.defineComponent({__name:"StoryblokRichText",props:{doc:{},resolvers:{}},setup(s){const e=s,t=f.ref(),o=()=>t.value;return f.watch([()=>e.doc,()=>e.resolvers],([r,n])=>{const{render:a}=Y({resolvers:n??{}});t.value=a(r)},{immediate:!0,deep:!0}),(r,n)=>(f.openBlock(),f.createBlock(o))}}),Ae={beforeMount(s,e){if(e.value){const t=we(e.value);Object.keys(t).length>0&&(s.setAttribute("data-blok-c",t["data-blok-c"]),s.setAttribute("data-blok-uid",t["data-blok-uid"]),s.classList.add("storyblok__outline"))}}},X=s=>{console.error(`You can't use ${s} if you're not loading apiPlugin. Please provide it on StoryblokVue initialization.
8
+ `)};let I=null;const Ee=()=>(I||X("useStoryblokApi"),I),Se=async(s,e={},t={})=>{const o=f.ref(null);if(t.resolveRelations=t.resolveRelations??e.resolve_relations,t.resolveLinks=t.resolveLinks??e.resolve_links,f.onMounted(()=>{o.value&&o.value.id&&K(o.value.id,r=>o.value=r,t)}),I){const{data:r}=await I.get(`cdn/stories/${s}`,e);o.value=r.story}else X("useStoryblok");return o},Ce={install(s,e={}){s.directive("editable",Ae),s.component("StoryblokComponent",U),s.component("StoryblokRichText",W),e.enableFallbackComponent&&!e.customFallbackComponent&&s.component("FallbackComponent",f.defineAsyncComponent(()=>Promise.resolve().then(()=>Oe)));const{storyblokApi:t}=Te(e);I=t||null,s.provide("VueSDKOptions",e)}},Ie={class:"fallback-component"},Le={class:"component"},Oe=Object.freeze(Object.defineProperty({__proto__:null,default:((s,e)=>{const t=s.__vccOpts||s;for(const[o,r]of e)t[o]=r;return t})(f.defineComponent({__name:"FallbackComponent",props:{blok:{}},setup(s){return(e,t)=>(f.openBlock(),f.createElementBlock("div",Ie,[f.createElementVNode("p",null,[t[0]||(t[0]=f.createTextVNode(" Component could not be found for blok ")),f.createElementVNode("span",Le,f.toDisplayString(e.blok.component),1),t[1]||(t[1]=f.createTextVNode("! Is it configured correctly? "))])]))}}),[["__scopeId","data-v-9abcd1f2"]])},Symbol.toStringTag,{value:"Module"}));v.BlockTypes=k,v.MarkTypes=R,v.StoryblokComponent=U,v.StoryblokRichText=W,v.StoryblokVue=Ce,v.TextTypes=x,v.apiPlugin=_e,v.renderRichText=Re,v.richTextResolver=D,v.useStoryblok=Se,v.useStoryblokApi=Ee,v.useStoryblokBridge=K,v.useStoryblokRichText=Y,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});