@storyblok/svelte 1.0.0

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 ADDED
@@ -0,0 +1,225 @@
1
+ <div align="center">
2
+ <a href="https://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte" align="center">
3
+ <img src="https://a.storyblok.com/f/88751/1776x360/783760dfac/storybloksvelte.png" alt="Storyblok Logo">
4
+ </a>
5
+ <h1 align="center"><strong>@storyblok/svelte</strong></h1>
6
+ <p align="center">
7
+ The Svelte SDK you need to interact with <a href="http://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte" target="_blank">Storyblok API</a> and enable the <a href="https://www.storyblok.com/docs/guide/essentials/visual-editor?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte" target="_blank">Real-time Visual Editing Experience</a>.
8
+ </p>
9
+ <br />
10
+ </div>
11
+
12
+ <p align="center">
13
+ <a href="https://npmjs.com/package/@storyblok/svelte">
14
+ <img src="https://img.shields.io/npm/v/@storyblok-svelte/latest.svg?style=flat-square" alt="npm package" />
15
+ </a>
16
+ <a href="https://npmjs.com/package/@storyblok/svelte" rel="nofollow">
17
+ <img src="https://img.shields.io/npm/dt/@storyblok-svelte.svg?style=flat-square" alt="download storyblok svelte">
18
+ </a>
19
+ </p>
20
+
21
+ <p align="center">
22
+ <a href="https://discord.gg/jKrbAMz">
23
+ <img src="https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community&style=appveyor&logo=discord&color=09b3af">
24
+ </a>
25
+ <a href="https://twitter.com/intent/follow?screen_name=storyblok">
26
+ <img src="https://img.shields.io/badge/Follow-%40storyblok-09b3af?style=appveyor&logo=twitter" alt="Follow @Storyblok" />
27
+ </a>
28
+ </p>
29
+ <p align="center">
30
+ <a href="https://app.storyblok.com/#!/signup?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte">
31
+ <img src="https://img.shields.io/badge/Try%20Storyblok-Free-09b3af?style=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==" alt="Try @Storyblok" />
32
+ </a>
33
+ </p>
34
+
35
+ <!-- ## 🔎 TL; DR
36
+
37
+ `@storyblok/svelte` helps you connect your Svelte project to Storyblok by:
38
+
39
+ - Providing the `useStoryblokApi` function to interact with the Storyblok APIs, using the [storyblok-js-client](https://github.com/storyblok/storyblok-js-client)
40
+ - Enabling real time editing through the [Storyblok Bridge](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte)
41
+ - Providing the `StoryblokComponent` which allows you to connect your components to the Storyblok Visual Editor -->
42
+
43
+ ## 🚀 Usage
44
+
45
+ > If you are first-time user of the Storyblok, read the [Getting Started](https://www.storyblok.com/tp/add-a-headless-cms-to-svelte-in-5-minutes?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte) guide to get a project ready in less than 5 minutes.
46
+
47
+ ### Installation
48
+
49
+ Install `@storyblok/svelte`
50
+
51
+ ```bash
52
+ npm install @storyblok/svelte
53
+ # yarn add @storyblok/svelte
54
+ ```
55
+
56
+ Initialize the library in your application (usually in `main.js`) by adding the `apiPlugin` and the [access token](https://www.storyblok.com/docs/api/content-delivery/v2?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte) of your Storyblok space:
57
+
58
+ ```js
59
+ import App from "./App.svelte";
60
+ import { storyblokInit, apiPlugin } from "@storyblok/svelte";
61
+
62
+ storyblokInit({
63
+ accessToken: "<your-token>",
64
+ // bridge: false,
65
+ // apiOptions: { },
66
+ use: [apiPlugin],
67
+ components: {
68
+ // teaser: () => import("./Teaser.svelte"), // Lazy load it on demand
69
+ teaser: Teaser,
70
+ },
71
+ });
72
+ ```
73
+
74
+ > Add all your components to the components object in the storyblokInit function. You can either load all of them at the same time by adding them to the list; or you could lazy load them when they are needed by uncommenting the dynamic import line.
75
+
76
+ Now, all features are enabled for you: the _Api Client_ for interacting with [Storyblok CDN API](https://www.storyblok.com/docs/api/content-delivery/v2?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte), 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-svelte).
77
+
78
+ > 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
79
+
80
+ ### From a CDN
81
+
82
+ Install the file from the CDN and access the methods via `window.storyblokSvelte`:
83
+
84
+ ```html
85
+ <script src="https://unpkg.com/@storyblok/svelte"></script>
86
+ ```
87
+
88
+ ## Getting started
89
+
90
+ ### 1. Fetching Content
91
+
92
+ Use the `useStoryblokApi()` gets your stories from the Storyblok CDN API:
93
+
94
+ ```html
95
+ <script>
96
+ import { onMount } from "svelte";
97
+ import { useStoryblokApi } from "@storyblok/svelte";
98
+
99
+ onMount(async () => {
100
+ const storyblokApi = useStoryblokApi();
101
+ const { data } = await storyblokApi.get("cdn/stories/home", {
102
+ version: "draft",
103
+ });
104
+ });
105
+ </script>
106
+ ```
107
+
108
+ > Note: you can skip using `storyblokApi` if you prefer your own method or function to fetch your data.
109
+
110
+ ### 2. Listen to Storyblok Visual Editor events
111
+
112
+ Use `useStoryBridge` to get the updated story every time a change event is triggered 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:
113
+
114
+ ```html
115
+ <script>
116
+ import { onMount } from "svelte";
117
+ import { useStoryblokApi, useStoryblokBridge } from "@storyblok/svelte";
118
+
119
+ let story = null;
120
+
121
+ onMount(async () => {
122
+ const storyblokApi = useStoryblokApi();
123
+ const { data } = await storyblokApi.get("cdn/stories/home", {
124
+ version: "draft",
125
+ });
126
+ story = data.story;
127
+ useStoryblokBridge(story.id, (newStory) => (story = newStory));
128
+ });
129
+ </script>
130
+ ```
131
+
132
+ You can pass [Bridge options](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte) as a third parameter as well:
133
+
134
+ ```js
135
+ useStoryblokBridge(story.id, (newStory) => (story = newStory), {
136
+ resolveRelations: ["Article.author"],
137
+ });
138
+ ```
139
+
140
+ ### 3. Link your components to Storyblok Visual Editor
141
+
142
+ In order to link the storyblok components, you have to
143
+
144
+ - Load them in components when calling `storyblokInit`
145
+
146
+ > If you would like to use dynamic component loading, make sure to use the `StorybloKComponent`an use dynamic import when adding the components to your list.
147
+
148
+ - Use the `storyblokEditable` svelte action on the root element of each component
149
+
150
+ ```html
151
+ <div use:storyblokEditable={blok} / >
152
+ ```
153
+
154
+ - Use the `StoryblokComponent` to load them by passing the blok property
155
+
156
+ ```html
157
+ <StoryblokComponent {blok} />
158
+ ```
159
+
160
+ > The `blok` is the actual blok data coming from [Storblok's Content Delivery API](https://www.storyblok.com/docs/api/content-delivery/v2?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte).
161
+
162
+ ### Features and API
163
+
164
+ 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.
165
+
166
+ #### Storyblok API
167
+
168
+ 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):
169
+
170
+ ```js
171
+ storyblokInit({
172
+ accessToken: "<your-token>",
173
+ apiOptions: {
174
+ //storyblok-js-client config object
175
+ cache: { type: "memory" },
176
+ },
177
+ use: [apiPlugin],
178
+ });
179
+ ```
180
+
181
+ If you prefer to use your own fetch method, just remove the `apiPlugin` and `storyblok-js-client` won't be added to your application. You can find out more about our [Content Delivery API](https://www.storyblok.com/docs/api/content-delivery?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte) in the documentation.
182
+
183
+ #### Storyblok Bridge
184
+
185
+ You can conditionally load it by using the `bridge` option. Very useful if you want to disable it in production:
186
+
187
+ ```js
188
+ storyblokInit({
189
+ bridge: process.env.NODE_ENV !== "production",
190
+ });
191
+ ```
192
+
193
+ Keep in mind you have still access to the raw `window.StoryblokBridge`:
194
+
195
+ ```js
196
+ const sbBridge = new window.StoryblokBridge(options);
197
+
198
+ sbBridge.on(["input", "published", "change"], (event) => {
199
+ // ...
200
+ });
201
+ ```
202
+
203
+ For background information on the [Storyblok JS Bridge](https://www.storyblok.com/docs/Guides/storyblok-latest-js?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte), please check out documentation.
204
+
205
+ ### Compatibility
206
+
207
+ This plugin is for Svelte. Thus, it supports the [same browsers as Svelte 3](https://github.com/sveltejs/svelte/issues/558). In short: all modern browsers and IE10+.
208
+
209
+ ## 🔗 Related Links
210
+
211
+ - **[Add a headless CMS to Svelte in 5 minutes](https://www.storyblok.com/tp/add-a-headless-cms-to-svelte-in-5-minutes?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte)**: Quick-start guide on getting up and running with Storyblok and Vue.
212
+ - **[Storyblok CLI](https://github.com/storyblok/storyblok)**: A simple CLI for scaffolding Storyblok projects and fieldtypes.
213
+ - [Svelte Documentation](https://svelte.dev/docs)
214
+
215
+ ## ℹ️ More Resources
216
+
217
+ ### Support
218
+
219
+ - Bugs or Feature Requests? [Submit an issue](/../../issues/new).
220
+ - Do you have questions about Storyblok or you need help? [Join our Discord Community](https://discord.gg/jKrbAMz).
221
+
222
+ ### Contributing
223
+
224
+ 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#code-of-conduct?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-svelte).
225
+ This project uses [semantic-release](https://semantic-release.gitbook.io/semantic-release/) for generate new versions by using commit messages and we use the [Angular Convention](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#) 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.
@@ -0,0 +1,12 @@
1
+ (function(f,m){typeof exports=="object"&&typeof module!="undefined"?m(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],m):(f=typeof globalThis!="undefined"?globalThis:f||self,m(f.storyblokSvelte={},f.t))})(this,function(f,m){"use strict";function ne(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var re=ne(m),oe=Object.defineProperty,se=Object.defineProperties,ie=Object.getOwnPropertyDescriptors,N=Object.getOwnPropertySymbols,ae=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,B=(t,e,n)=>e in t?oe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,p=(t,e)=>{for(var n in e||(e={}))ae.call(e,n)&&B(t,n,e[n]);if(N)for(var n of N(e))ce.call(e,n)&&B(t,n,e[n]);return t},E=(t,e)=>se(t,ie(e));let q=!1;const L=[],le=t=>new Promise((e,n)=>{if(typeof window=="undefined"||(window.storyblokRegisterEvent=o=>{if(window.location===window.parent.location){console.warn("You are not in Draft Mode or in the Visual Editor.");return}q?o():L.push(o)},document.getElementById("storyblok-javascript-bridge")))return;const r=document.createElement("script");r.async=!0,r.src=t,r.id="storyblok-javascript-bridge",r.onerror=o=>n(o),r.onload=o=>{L.forEach(s=>s()),q=!0,e(o)},document.getElementsByTagName("head")[0].appendChild(r)});/*!
2
+ * storyblok-js-client v0.0.0-development
3
+ * Universal JavaScript SDK for Storyblok's API
4
+ * (c) 2020-2022 Stobylok Team
5
+ */function D(t){return typeof t=="number"&&t==t&&t!==1/0&&t!==-1/0}function U(t,e,n){if(!D(e))throw new TypeError("Expected `limit` to be a finite number");if(!D(n))throw new TypeError("Expected `interval` to be a finite number");var r=[],o=[],s=0,a=function(){s++;var c=setTimeout(function(){s--,r.length>0&&a(),o=o.filter(function(u){return u!==c})},n);o.indexOf(c)<0&&o.push(c);var l=r.shift();l.resolve(t.apply(l.self,l.args))},i=function(){var c=arguments,l=this;return new Promise(function(u,d){r.push({resolve:u,reject:d,args:c,self:l}),s<e&&a()})};return i.abort=function(){o.forEach(clearTimeout),o=[],r.forEach(function(c){c.reject(new throttle.AbortError)}),r.length=0},i}U.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const ue=function(t,e){if(!t)return null;let n={};for(let r in t){let o=t[r];e.indexOf(r)>-1&&o!==null&&(n[r]=o)}return n};var fe={nodes:{horizontal_rule:t=>({singleTag:"hr"}),blockquote:t=>({tag:"blockquote"}),bullet_list:t=>({tag:"ul"}),code_block:t=>({tag:["pre",{tag:"code",attrs:t.attrs}]}),hard_break:t=>({singleTag:"br"}),heading:t=>({tag:"h"+t.attrs.level}),image:t=>({singleTag:[{tag:"img",attrs:ue(t.attrs,["src","alt","title"])}]}),list_item:t=>({tag:"li"}),ordered_list:t=>({tag:"ol"}),paragraph:t=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(t){const e=p({},t.attrs),{linktype:n="url"}=t.attrs;return n==="email"&&(e.href="mailto:"+e.href),e.anchor&&(e.href=`${e.href}#${e.anchor}`,delete e.anchor),{tag:[{tag:"a",attrs:e}]}},styled:t=>({tag:[{tag:"span",attrs:t.attrs}]})}};class de{constructor(e){e||(e=fe),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,n){this.nodes[e]=n}addMark(e,n){this.marks[e]=n}render(e={}){if(e.content&&Array.isArray(e.content)){let n="";return e.content.forEach(r=>{n+=this.renderNode(r)}),n}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let n=[];e.marks&&e.marks.forEach(o=>{const s=this.getMatchingMark(o);s&&n.push(this.renderOpeningTag(s.tag))});const r=this.getMatchingNode(e);return r&&r.tag&&n.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach(o=>{n.push(this.renderNode(o))}):e.text?n.push(function(o){const s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},a=/[&<>"']/g,i=RegExp(a.source);return o&&i.test(o)?o.replace(a,c=>s[c]):o}(e.text)):r&&r.singleTag?n.push(this.renderTag(r.singleTag," /")):r&&r.html&&n.push(r.html),r&&r.tag&&n.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach(o=>{const s=this.getMatchingMark(o);s&&n.push(this.renderClosingTag(s.tag))}),n.join("")}renderTag(e,n){return e.constructor===String?`<${e}${n}>`:e.map(r=>{if(r.constructor===String)return`<${r}${n}>`;{let o="<"+r.tag;if(r.attrs)for(let s in r.attrs){let a=r.attrs[s];a!==null&&(o+=` ${s}="${a}"`)}return`${o}${n}>`}}).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){return e.constructor===String?`</${e}>`:e.slice(0).reverse().map(n=>n.constructor===String?`</${n}>`:`</${n.tag}>`).join("")}getMatchingNode(e){if(typeof this.nodes[e.type]=="function")return this.nodes[e.type](e)}getMatchingMark(e){if(typeof this.marks[e.type]=="function")return this.marks[e.type](e)}}const he=(t=0,e=t)=>{const n=Math.abs(e-t)||0,r=t<e?1:-1;return((o=0,s)=>[...Array(o)].map(s))(n,(o,s)=>s*r+t)},O=(t,e,n)=>{const r=[];for(const o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;const s=t[o],a=n?"":encodeURIComponent(o);let i;i=typeof s=="object"?O(s,e?e+encodeURIComponent("["+a+"]"):a,Array.isArray(s)):(e?e+encodeURIComponent("["+a+"]"):a)+"="+encodeURIComponent(s),r.push(i)}return r.join("&")};let b={},g={};class pe{constructor(e,n){if(!n){let s=e.region?"-"+e.region:"",a=e.https===!1?"http":"https";n=e.oauthToken===void 0?`${a}://api${s}.storyblok.com/v2`:`${a}://api${s}.storyblok.com/v1`}let r=Object.assign({},e.headers),o=5;e.oauthToken!==void 0&&(r.Authorization=e.oauthToken,o=3),e.rateLimit!==void 0&&(o=e.rateLimit),this.richTextResolver=new de(e.richTextSchema),typeof e.componentResolver=="function"&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=U(this.throttledRequest,o,1e3),this.accessToken=e.accessToken,this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.client=re.default.create({baseURL:n,timeout:e.timeout||0,headers:r,proxy:e.proxy||!1}),e.responseInterceptor&&this.client.interceptors.response.use(s=>e.responseInterceptor(s))}setComponentResolver(e){this.richTextResolver.addNode("blok",n=>{let r="";return n.attrs.body.forEach(o=>{r+=e(o.component,o)}),{html:r}})}parseParams(e={}){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=g[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,n={}){return((r="")=>r.indexOf("/cdn/")>-1)(e)?this.parseParams(n):n}makeRequest(e,n,r,o){const s=this.factoryParamOptions(e,((a={},i=25,c=1)=>E(p({},a),{per_page:i,page:c}))(n,r,o));return this.cacheResponse(e,s)}get(e,n){let r="/"+e;const o=this.factoryParamOptions(r,n);return this.cacheResponse(r,o)}async getAll(e,n={},r){const o=n.per_page||25,s="/"+e,a=s.split("/");r=r||a[a.length-1];const i=await this.makeRequest(s,n,o,1),c=Math.ceil(i.total/o);return((l=[],u)=>l.map(u).reduce((d,$)=>[...d,...$],[]))([i,...await(async(l=[],u)=>Promise.all(l.map(u)))(he(1,c),async l=>this.makeRequest(s,n,o,l+1))],l=>Object.values(l.data[r]))}post(e,n){let r="/"+e;return this.throttle("post",r,n)}put(e,n){let r="/"+e;return this.throttle("put",r,n)}delete(e,n){let r="/"+e;return this.throttle("delete",r,n)}getStories(e){return this.get("cdn/stories",e)}getStory(e,n){return this.get("cdn/stories/"+e,n)}setToken(e){this.accessToken=e}getToken(){return this.accessToken}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,n){const r=e[n];r&&r.fieldtype=="multilink"&&r.linktype=="story"&&typeof r.id=="string"&&this.links[r.id]?r.story=this._cleanCopy(this.links[r.id]):r&&r.linktype==="story"&&typeof r.uuid=="string"&&this.links[r.uuid]&&(r.story=this._cleanCopy(this.links[r.uuid]))}_insertRelations(e,n,r){if(r.indexOf(e.component+"."+n)>-1){if(typeof e[n]=="string")this.relations[e[n]]&&(e[n]=this._cleanCopy(this.relations[e[n]]));else if(e[n].constructor===Array){let o=[];e[n].forEach(s=>{this.relations[s]&&o.push(this._cleanCopy(this.relations[s]))}),e[n]=o}}}iterateTree(e,n){let r=o=>{if(o!=null){if(o.constructor===Array)for(let s=0;s<o.length;s++)r(o[s]);else if(o.constructor===Object){if(o._stopResolving)return;for(let s in o)(o.component&&o._uid||o.type==="link")&&(this._insertRelations(o,s,n),this._insertLinks(o,s)),r(o[s])}}};r(e.content)}async resolveLinks(e,n){let r=[];if(e.link_uuids){const o=e.link_uuids.length;let s=[];const a=50;for(let i=0;i<o;i+=a){const c=Math.min(o,i+a);s.push(e.link_uuids.slice(i,c))}for(let i=0;i<s.length;i++)(await this.getStories({per_page:a,language:n.language,version:n.version,by_uuids:s[i].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.links;r.forEach(o=>{this.links[o.uuid]=E(p({},o),{_stopResolving:!0})})}async resolveRelations(e,n){let r=[];if(e.rel_uuids){const o=e.rel_uuids.length;let s=[];const a=50;for(let i=0;i<o;i+=a){const c=Math.min(o,i+a);s.push(e.rel_uuids.slice(i,c))}for(let i=0;i<s.length;i++)(await this.getStories({per_page:a,language:n.language,version:n.version,by_uuids:s[i].join(",")})).data.stories.forEach(c=>{r.push(c)})}else r=e.rels;r.forEach(o=>{this.relations[o.uuid]=E(p({},o),{_stopResolving:!0})})}async resolveStories(e,n){let r=[];n.resolve_relations!==void 0&&n.resolve_relations.length>0&&(r=n.resolve_relations.split(","),await this.resolveRelations(e,n)),["1","story","url"].indexOf(n.resolve_links)>-1&&await this.resolveLinks(e,n);for(const o in this.relations)this.iterateTree(this.relations[o],r);e.story?this.iterateTree(e.story,r):e.stories.forEach(o=>{this.iterateTree(o,r)})}cacheResponse(e,n,r){return r===void 0&&(r=0),new Promise(async(o,s)=>{let a=O({url:e,params:n}),i=this.cacheProvider();if(this.cache.clear==="auto"&&n.version==="draft"&&await this.flushCache(),n.version==="published"&&e!="/cdn/spaces/me"){const l=await i.get(a);if(l)return o(l)}try{let l=await this.throttle("get",e,{params:n,paramsSerializer:d=>O(d)}),u={data:l.data,headers:l.headers};if(l.headers["per-page"]&&(u=Object.assign({},u,{perPage:parseInt(l.headers["per-page"]),total:parseInt(l.headers.total)})),l.status!=200)return s(l);(u.data.story||u.data.stories)&&await this.resolveStories(u.data,n),n.version==="published"&&e!="/cdn/spaces/me"&&i.set(a,u),u.data.cv&&(n.version=="draft"&&g[n.token]!=u.data.cv&&this.flushCache(),g[n.token]=u.data.cv),o(u)}catch(l){if(l.response&&l.response.status===429&&(r+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${r} seconds.`),await(c=1e3*r,new Promise(u=>setTimeout(u,c))),this.cacheResponse(e,n,r).then(o).catch(s);s(l)}var c})}throttledRequest(e,n,r){return this.client[e](n,r)}cacheVersions(){return g}cacheVersion(){return g[this.accessToken]}setCacheVersion(e){this.accessToken&&(g[this.accessToken]=e)}cacheProvider(){switch(this.cache.type){case"memory":return{get:e=>b[e],getAll:()=>b,set(e,n){b[e]=n},flush(){b={}}};default:return{get(){},getAll(){},set(){},flush(){}}}}async flushCache(){return await this.cacheProvider().flush(),this}}var ge=(t={})=>{const{apiOptions:e}=t;if(!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 pe(e)}},me=t=>{if(typeof t!="object"||typeof t._editable=="undefined")return{};const e=JSON.parse(t._editable.replace(/^<!--#storyblok#/,"").replace(/-->$/,""));return{"data-blok-c":JSON.stringify(e),"data-blok-uid":e.id+"-"+e.uid}};const ye=(t,e,n={})=>{if(typeof window!="undefined"){if(typeof window.storyblokRegisterEvent=="undefined"){console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");return}window.storyblokRegisterEvent(()=>{new window.StoryblokBridge(n).on(["input","published","change"],o=>{o.action=="input"&&o.story.id===t?e(o.story):window.location.reload()})})}},_e=(t={})=>{const{bridge:e,accessToken:n,use:r=[],apiOptions:o={}}=t;o.accessToken=o.accessToken||n;const s={bridge:e,apiOptions:o};let a={};return r.forEach(i=>{a=p(p({},a),i(s))}),e!==!1&&le("https://app.storyblok.com/f/storyblok-v2-latest.js"),a};function V(){}function S(t,e){for(const n in e)t[n]=e[n];return t}function J(t){return t()}function Y(){return Object.create(null)}function y(t){t.forEach(J)}function ke(t){return typeof t=="function"}function be(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function ve(t){return Object.keys(t).length===0}function we(t){const e={};for(const n in t)n[0]!=="$"&&(e[n]=t[n]);return e}function z(t,e){const n={};e=new Set(e);for(const r in t)!e.has(r)&&r[0]!=="$"&&(n[r]=t[r]);return n}function Te(t,e,n){t.insertBefore(e,n||null)}function F(t){t.parentNode.removeChild(t)}function $e(t){return document.createTextNode(t)}function Ee(){return $e("")}function Oe(t){return Array.from(t.childNodes)}let P;function _(t){P=t}const k=[],H=[],v=[],W=[],Se=Promise.resolve();let R=!1;function Pe(){R||(R=!0,Se.then(G))}function j(t){v.push(t)}const x=new Set;let w=0;function G(){const t=P;do{for(;w<k.length;){const e=k[w];w++,_(e),Re(e.$$)}for(_(null),k.length=0,w=0;H.length;)H.pop()();for(let e=0;e<v.length;e+=1){const n=v[e];x.has(n)||(x.add(n),n())}v.length=0}while(k.length);for(;W.length;)W.pop()();R=!1,x.clear(),_(t)}function Re(t){if(t.fragment!==null){t.update(),y(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(j)}}const T=new Set;let h;function je(){h={r:0,c:[],p:h}}function xe(){h.r||y(h.c),h=h.p}function C(t,e){t&&t.i&&(T.delete(t),t.i(e))}function K(t,e,n,r){if(t&&t.o){if(T.has(t))return;T.add(t),h.c.push(()=>{T.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}}function Ce(t,e){const n={},r={},o={$$scope:1};let s=t.length;for(;s--;){const a=t[s],i=e[s];if(i){for(const c in a)c in i||(r[c]=1);for(const c in i)o[c]||(n[c]=i[c],o[c]=1);t[s]=i}else for(const c in a)o[c]=1}for(const a in r)a in n||(n[a]=void 0);return n}function Ae(t){return typeof t=="object"&&t!==null?t:{}}function Q(t){t&&t.c()}function A(t,e,n,r){const{fragment:o,on_mount:s,on_destroy:a,after_update:i}=t.$$;o&&o.m(e,n),r||j(()=>{const c=s.map(J).filter(ke);a?a.push(...c):y(c),t.$$.on_mount=[]}),i.forEach(j)}function I(t,e){const n=t.$$;n.fragment!==null&&(y(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Ie(t,e){t.$$.dirty[0]===-1&&(k.push(t),Pe(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function Me(t,e,n,r,o,s,a,i=[-1]){const c=P;_(t);const l=t.$$={fragment:null,ctx:null,props:s,update:V,not_equal:o,bound:Y(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(c?c.$$.context:[])),callbacks:Y(),dirty:i,skip_bound:!1,root:e.target||c.$$.root};a&&a(l.root);let u=!1;if(l.ctx=n?n(t,e.props||{},(d,$,...ee)=>{const te=ee.length?ee[0]:$;return l.ctx&&o(l.ctx[d],l.ctx[d]=te)&&(!l.skip_bound&&l.bound[d]&&l.bound[d](te),u&&Ie(t,d)),$}):[],l.update(),u=!0,y(l.before_update),l.fragment=r?r(l.ctx):!1,e.target){if(e.hydrate){const d=Oe(e.target);l.fragment&&l.fragment.l(d),d.forEach(F)}else l.fragment&&l.fragment.c();e.intro&&C(t.$$.fragment),A(t,e.target,e.anchor,e.customElement),G()}_(c)}class Ne{$destroy(){I(this,1),this.$destroy=V}$on(e,n){const r=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return r.push(n),()=>{const o=r.indexOf(n);o!==-1&&r.splice(o,1)}}$set(e){this.$$set&&!ve(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}function Be(t){let e,n,r;const o=[{blok:t[0]},t[2]];var s=t[1];function a(i){let c={};for(let l=0;l<o.length;l+=1)c=S(c,o[l]);return{props:c}}return s&&(e=new s(a())),{c(){e&&Q(e.$$.fragment),n=Ee()},m(i,c){e&&A(e,i,c),Te(i,n,c),r=!0},p(i,[c]){const l=c&5?Ce(o,[c&1&&{blok:i[0]},c&4&&Ae(i[2])]):{};if(s!==(s=i[1])){if(e){je();const u=e;K(u.$$.fragment,1,0,()=>{I(u,1)}),xe()}s?(e=new s(a()),Q(e.$$.fragment),C(e.$$.fragment,1),A(e,n.parentNode,n)):e=null}else s&&e.$set(l)},i(i){r||(e&&C(e.$$.fragment,i),r=!0)},o(i){e&&K(e.$$.fragment,i),r=!1},d(i){i&&F(n),e&&I(e,i)}}}function qe(t,e,n){const r=["blok"];let o=z(e,r),{blok:s}=e,a;if(s){const i=Z(s.component);if(i){const c=async()=>{const{default:u}=await i();n(1,a=u)};i.name.startsWith("Proxy")?a=i:c()}}else console.error("Please provide a 'blok' property to the StoryblokComponent");return t.$$set=i=>{e=S(S({},e),we(i)),n(2,o=z(e,r)),"blok"in i&&n(0,s=i.blok)},[s,a,o]}class Le extends Ne{constructor(e){super();Me(this,e,qe,Be,be,{blok:0})}}const De=(t,e)=>{const n=r=>{const o=me(r);o["data-blok-c"]&&(t.setAttribute("data-blok-c",o["data-blok-c"]),t.setAttribute("data-blok-uid",o["data-blok-uid"]),t.classList.add("storyblok__outline"))};return n(e),{update(r){n(r)}}};let M=null;const Ue=()=>(M||console.log("You can't use useStoryblokApi if you're not loading apiPlugin."),M);let X=null;const Ve=t=>{const{storyblokApi:e}=_e(t);M=e,X=t.components||{}},Z=t=>{const e=X[t];return e||console.error(`You didn't load the ${t} component. Please load it in storyblokInit. For example:
6
+ storyblokInit({
7
+ accessToken: "<your-token>",
8
+ components: {
9
+ "teaser": Teaser
10
+ }
11
+ })
12
+ `),e};f.StoryblokComponent=Le,f.apiPlugin=ge,f.getComponent=Z,f.storyblokEditable=De,f.storyblokInit=Ve,f.useStoryblokApi=Ue,f.useStoryblokBridge=ye,Object.defineProperty(f,"__esModule",{value:!0}),f[Symbol.toStringTag]="Module"});
@@ -0,0 +1,892 @@
1
+ import t from "axios";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a2, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a2, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a2, prop, b[prop]);
17
+ }
18
+ return a2;
19
+ };
20
+ var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
21
+ let loaded = false;
22
+ const callbacks = [];
23
+ const loadBridge = (src) => {
24
+ return new Promise((resolve, reject) => {
25
+ if (typeof window === "undefined")
26
+ return;
27
+ window.storyblokRegisterEvent = (cb) => {
28
+ if (window.location === window.parent.location) {
29
+ console.warn("You are not in Draft Mode or in the Visual Editor.");
30
+ return;
31
+ }
32
+ if (!loaded)
33
+ callbacks.push(cb);
34
+ else
35
+ cb();
36
+ };
37
+ if (document.getElementById("storyblok-javascript-bridge"))
38
+ return;
39
+ const script = document.createElement("script");
40
+ script.async = true;
41
+ script.src = src;
42
+ script.id = "storyblok-javascript-bridge";
43
+ script.onerror = (error) => reject(error);
44
+ script.onload = (ev) => {
45
+ callbacks.forEach((cb) => cb());
46
+ loaded = true;
47
+ resolve(ev);
48
+ };
49
+ document.getElementsByTagName("head")[0].appendChild(script);
50
+ });
51
+ };
52
+ /*!
53
+ * storyblok-js-client v0.0.0-development
54
+ * Universal JavaScript SDK for Storyblok's API
55
+ * (c) 2020-2022 Stobylok Team
56
+ */
57
+ function e(t2) {
58
+ return typeof t2 == "number" && (t2 == t2 && t2 !== 1 / 0 && t2 !== -1 / 0);
59
+ }
60
+ function r(t2, r2, s2) {
61
+ if (!e(r2))
62
+ throw new TypeError("Expected `limit` to be a finite number");
63
+ if (!e(s2))
64
+ throw new TypeError("Expected `interval` to be a finite number");
65
+ var n2 = [], i2 = [], o2 = 0, a2 = function() {
66
+ o2++;
67
+ var e2 = setTimeout(function() {
68
+ o2--, n2.length > 0 && a2(), i2 = i2.filter(function(t3) {
69
+ return t3 !== e2;
70
+ });
71
+ }, s2);
72
+ i2.indexOf(e2) < 0 && i2.push(e2);
73
+ var r3 = n2.shift();
74
+ r3.resolve(t2.apply(r3.self, r3.args));
75
+ }, l2 = function() {
76
+ var t3 = arguments, e2 = this;
77
+ return new Promise(function(s3, i3) {
78
+ n2.push({ resolve: s3, reject: i3, args: t3, self: e2 }), o2 < r2 && a2();
79
+ });
80
+ };
81
+ return l2.abort = function() {
82
+ i2.forEach(clearTimeout), i2 = [], n2.forEach(function(t3) {
83
+ t3.reject(new throttle.AbortError());
84
+ }), n2.length = 0;
85
+ }, l2;
86
+ }
87
+ r.AbortError = function() {
88
+ Error.call(this, "Throttled function aborted"), this.name = "AbortError";
89
+ };
90
+ const s = function(t2, e2) {
91
+ if (!t2)
92
+ return null;
93
+ let r2 = {};
94
+ for (let s2 in t2) {
95
+ let n2 = t2[s2];
96
+ e2.indexOf(s2) > -1 && n2 !== null && (r2[s2] = n2);
97
+ }
98
+ return r2;
99
+ };
100
+ var n = { nodes: { horizontal_rule: (t2) => ({ singleTag: "hr" }), blockquote: (t2) => ({ tag: "blockquote" }), bullet_list: (t2) => ({ tag: "ul" }), code_block: (t2) => ({ tag: ["pre", { tag: "code", attrs: t2.attrs }] }), hard_break: (t2) => ({ singleTag: "br" }), heading: (t2) => ({ tag: "h" + t2.attrs.level }), image: (t2) => ({ singleTag: [{ tag: "img", attrs: s(t2.attrs, ["src", "alt", "title"]) }] }), list_item: (t2) => ({ tag: "li" }), ordered_list: (t2) => ({ tag: "ol" }), paragraph: (t2) => ({ tag: "p" }) }, marks: { bold: () => ({ tag: "b" }), strike: () => ({ tag: "strike" }), underline: () => ({ tag: "u" }), strong: () => ({ tag: "strong" }), code: () => ({ tag: "code" }), italic: () => ({ tag: "i" }), link(t2) {
101
+ const e2 = __spreadValues({}, t2.attrs), { linktype: r2 = "url" } = t2.attrs;
102
+ return r2 === "email" && (e2.href = "mailto:" + e2.href), e2.anchor && (e2.href = `${e2.href}#${e2.anchor}`, delete e2.anchor), { tag: [{ tag: "a", attrs: e2 }] };
103
+ }, styled: (t2) => ({ tag: [{ tag: "span", attrs: t2.attrs }] }) } };
104
+ class i {
105
+ constructor(t2) {
106
+ t2 || (t2 = n), this.marks = t2.marks || [], this.nodes = t2.nodes || [];
107
+ }
108
+ addNode(t2, e2) {
109
+ this.nodes[t2] = e2;
110
+ }
111
+ addMark(t2, e2) {
112
+ this.marks[t2] = e2;
113
+ }
114
+ render(t2 = {}) {
115
+ if (t2.content && Array.isArray(t2.content)) {
116
+ let e2 = "";
117
+ return t2.content.forEach((t3) => {
118
+ e2 += this.renderNode(t3);
119
+ }), e2;
120
+ }
121
+ return console.warn("The render method must receive an object with a content field, which is an array"), "";
122
+ }
123
+ renderNode(t2) {
124
+ let e2 = [];
125
+ t2.marks && t2.marks.forEach((t3) => {
126
+ const r3 = this.getMatchingMark(t3);
127
+ r3 && e2.push(this.renderOpeningTag(r3.tag));
128
+ });
129
+ const r2 = this.getMatchingNode(t2);
130
+ return r2 && r2.tag && e2.push(this.renderOpeningTag(r2.tag)), t2.content ? t2.content.forEach((t3) => {
131
+ e2.push(this.renderNode(t3));
132
+ }) : t2.text ? e2.push(function(t3) {
133
+ const e3 = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, r3 = /[&<>"']/g, s2 = RegExp(r3.source);
134
+ return t3 && s2.test(t3) ? t3.replace(r3, (t4) => e3[t4]) : t3;
135
+ }(t2.text)) : r2 && r2.singleTag ? e2.push(this.renderTag(r2.singleTag, " /")) : r2 && r2.html && e2.push(r2.html), r2 && r2.tag && e2.push(this.renderClosingTag(r2.tag)), t2.marks && t2.marks.slice(0).reverse().forEach((t3) => {
136
+ const r3 = this.getMatchingMark(t3);
137
+ r3 && e2.push(this.renderClosingTag(r3.tag));
138
+ }), e2.join("");
139
+ }
140
+ renderTag(t2, e2) {
141
+ if (t2.constructor === String)
142
+ return `<${t2}${e2}>`;
143
+ return t2.map((t3) => {
144
+ if (t3.constructor === String)
145
+ return `<${t3}${e2}>`;
146
+ {
147
+ let r2 = "<" + t3.tag;
148
+ if (t3.attrs)
149
+ for (let e3 in t3.attrs) {
150
+ let s2 = t3.attrs[e3];
151
+ s2 !== null && (r2 += ` ${e3}="${s2}"`);
152
+ }
153
+ return `${r2}${e2}>`;
154
+ }
155
+ }).join("");
156
+ }
157
+ renderOpeningTag(t2) {
158
+ return this.renderTag(t2, "");
159
+ }
160
+ renderClosingTag(t2) {
161
+ if (t2.constructor === String)
162
+ return `</${t2}>`;
163
+ return t2.slice(0).reverse().map((t3) => t3.constructor === String ? `</${t3}>` : `</${t3.tag}>`).join("");
164
+ }
165
+ getMatchingNode(t2) {
166
+ if (typeof this.nodes[t2.type] == "function")
167
+ return this.nodes[t2.type](t2);
168
+ }
169
+ getMatchingMark(t2) {
170
+ if (typeof this.marks[t2.type] == "function")
171
+ return this.marks[t2.type](t2);
172
+ }
173
+ }
174
+ const o = (t2 = 0, e2 = t2) => {
175
+ const r2 = Math.abs(e2 - t2) || 0, s2 = t2 < e2 ? 1 : -1;
176
+ return ((t3 = 0, e3) => [...Array(t3)].map(e3))(r2, (e3, r3) => r3 * s2 + t2);
177
+ }, a = (t2, e2, r2) => {
178
+ const s2 = [];
179
+ for (const n2 in t2) {
180
+ if (!Object.prototype.hasOwnProperty.call(t2, n2))
181
+ continue;
182
+ const i2 = t2[n2], o2 = r2 ? "" : encodeURIComponent(n2);
183
+ let l2;
184
+ l2 = typeof i2 == "object" ? a(i2, e2 ? e2 + encodeURIComponent("[" + o2 + "]") : o2, Array.isArray(i2)) : (e2 ? e2 + encodeURIComponent("[" + o2 + "]") : o2) + "=" + encodeURIComponent(i2), s2.push(l2);
185
+ }
186
+ return s2.join("&");
187
+ };
188
+ let l = {}, c = {};
189
+ class StoryblokClient {
190
+ constructor(e2, s2) {
191
+ if (!s2) {
192
+ let t2 = e2.region ? "-" + e2.region : "", r2 = e2.https === false ? "http" : "https";
193
+ s2 = e2.oauthToken === void 0 ? `${r2}://api${t2}.storyblok.com/v2` : `${r2}://api${t2}.storyblok.com/v1`;
194
+ }
195
+ let n2 = Object.assign({}, e2.headers), o2 = 5;
196
+ e2.oauthToken !== void 0 && (n2.Authorization = e2.oauthToken, o2 = 3), e2.rateLimit !== void 0 && (o2 = e2.rateLimit), this.richTextResolver = new i(e2.richTextSchema), typeof e2.componentResolver == "function" && this.setComponentResolver(e2.componentResolver), this.maxRetries = e2.maxRetries || 5, this.throttle = r(this.throttledRequest, o2, 1e3), this.accessToken = e2.accessToken, this.relations = {}, this.links = {}, this.cache = e2.cache || { clear: "manual" }, this.client = t.create({ baseURL: s2, timeout: e2.timeout || 0, headers: n2, proxy: e2.proxy || false }), e2.responseInterceptor && this.client.interceptors.response.use((t2) => e2.responseInterceptor(t2));
197
+ }
198
+ setComponentResolver(t2) {
199
+ this.richTextResolver.addNode("blok", (e2) => {
200
+ let r2 = "";
201
+ return e2.attrs.body.forEach((e3) => {
202
+ r2 += t2(e3.component, e3);
203
+ }), { html: r2 };
204
+ });
205
+ }
206
+ parseParams(t2 = {}) {
207
+ return t2.version || (t2.version = "published"), t2.token || (t2.token = this.getToken()), t2.cv || (t2.cv = c[t2.token]), Array.isArray(t2.resolve_relations) && (t2.resolve_relations = t2.resolve_relations.join(",")), t2;
208
+ }
209
+ factoryParamOptions(t2, e2 = {}) {
210
+ return ((t3 = "") => t3.indexOf("/cdn/") > -1)(t2) ? this.parseParams(e2) : e2;
211
+ }
212
+ makeRequest(t2, e2, r2, s2) {
213
+ const n2 = this.factoryParamOptions(t2, ((t3 = {}, e3 = 25, r3 = 1) => __spreadProps(__spreadValues({}, t3), { per_page: e3, page: r3 }))(e2, r2, s2));
214
+ return this.cacheResponse(t2, n2);
215
+ }
216
+ get(t2, e2) {
217
+ let r2 = "/" + t2;
218
+ const s2 = this.factoryParamOptions(r2, e2);
219
+ return this.cacheResponse(r2, s2);
220
+ }
221
+ async getAll(t2, e2 = {}, r2) {
222
+ const s2 = e2.per_page || 25, n2 = "/" + t2, i2 = n2.split("/");
223
+ r2 = r2 || i2[i2.length - 1];
224
+ const a2 = await this.makeRequest(n2, e2, s2, 1), l2 = Math.ceil(a2.total / s2);
225
+ return ((t3 = [], e3) => t3.map(e3).reduce((t4, e4) => [...t4, ...e4], []))([a2, ...await (async (t3 = [], e3) => Promise.all(t3.map(e3)))(o(1, l2), async (t3) => this.makeRequest(n2, e2, s2, t3 + 1))], (t3) => Object.values(t3.data[r2]));
226
+ }
227
+ post(t2, e2) {
228
+ let r2 = "/" + t2;
229
+ return this.throttle("post", r2, e2);
230
+ }
231
+ put(t2, e2) {
232
+ let r2 = "/" + t2;
233
+ return this.throttle("put", r2, e2);
234
+ }
235
+ delete(t2, e2) {
236
+ let r2 = "/" + t2;
237
+ return this.throttle("delete", r2, e2);
238
+ }
239
+ getStories(t2) {
240
+ return this.get("cdn/stories", t2);
241
+ }
242
+ getStory(t2, e2) {
243
+ return this.get("cdn/stories/" + t2, e2);
244
+ }
245
+ setToken(t2) {
246
+ this.accessToken = t2;
247
+ }
248
+ getToken() {
249
+ return this.accessToken;
250
+ }
251
+ _cleanCopy(t2) {
252
+ return JSON.parse(JSON.stringify(t2));
253
+ }
254
+ _insertLinks(t2, e2) {
255
+ const r2 = t2[e2];
256
+ r2 && r2.fieldtype == "multilink" && r2.linktype == "story" && typeof r2.id == "string" && this.links[r2.id] ? r2.story = this._cleanCopy(this.links[r2.id]) : r2 && r2.linktype === "story" && typeof r2.uuid == "string" && this.links[r2.uuid] && (r2.story = this._cleanCopy(this.links[r2.uuid]));
257
+ }
258
+ _insertRelations(t2, e2, r2) {
259
+ if (r2.indexOf(t2.component + "." + e2) > -1) {
260
+ if (typeof t2[e2] == "string")
261
+ this.relations[t2[e2]] && (t2[e2] = this._cleanCopy(this.relations[t2[e2]]));
262
+ else if (t2[e2].constructor === Array) {
263
+ let r3 = [];
264
+ t2[e2].forEach((t3) => {
265
+ this.relations[t3] && r3.push(this._cleanCopy(this.relations[t3]));
266
+ }), t2[e2] = r3;
267
+ }
268
+ }
269
+ }
270
+ iterateTree(t2, e2) {
271
+ let r2 = (t3) => {
272
+ if (t3 != null) {
273
+ if (t3.constructor === Array)
274
+ for (let e3 = 0; e3 < t3.length; e3++)
275
+ r2(t3[e3]);
276
+ else if (t3.constructor === Object) {
277
+ if (t3._stopResolving)
278
+ return;
279
+ for (let s2 in t3)
280
+ (t3.component && t3._uid || t3.type === "link") && (this._insertRelations(t3, s2, e2), this._insertLinks(t3, s2)), r2(t3[s2]);
281
+ }
282
+ }
283
+ };
284
+ r2(t2.content);
285
+ }
286
+ async resolveLinks(t2, e2) {
287
+ let r2 = [];
288
+ if (t2.link_uuids) {
289
+ const s2 = t2.link_uuids.length;
290
+ let n2 = [];
291
+ const i2 = 50;
292
+ for (let e3 = 0; e3 < s2; e3 += i2) {
293
+ const r3 = Math.min(s2, e3 + i2);
294
+ n2.push(t2.link_uuids.slice(e3, r3));
295
+ }
296
+ for (let t3 = 0; t3 < n2.length; t3++) {
297
+ (await this.getStories({ per_page: i2, language: e2.language, version: e2.version, by_uuids: n2[t3].join(",") })).data.stories.forEach((t4) => {
298
+ r2.push(t4);
299
+ });
300
+ }
301
+ } else
302
+ r2 = t2.links;
303
+ r2.forEach((t3) => {
304
+ this.links[t3.uuid] = __spreadProps(__spreadValues({}, t3), { _stopResolving: true });
305
+ });
306
+ }
307
+ async resolveRelations(t2, e2) {
308
+ let r2 = [];
309
+ if (t2.rel_uuids) {
310
+ const s2 = t2.rel_uuids.length;
311
+ let n2 = [];
312
+ const i2 = 50;
313
+ for (let e3 = 0; e3 < s2; e3 += i2) {
314
+ const r3 = Math.min(s2, e3 + i2);
315
+ n2.push(t2.rel_uuids.slice(e3, r3));
316
+ }
317
+ for (let t3 = 0; t3 < n2.length; t3++) {
318
+ (await this.getStories({ per_page: i2, language: e2.language, version: e2.version, by_uuids: n2[t3].join(",") })).data.stories.forEach((t4) => {
319
+ r2.push(t4);
320
+ });
321
+ }
322
+ } else
323
+ r2 = t2.rels;
324
+ r2.forEach((t3) => {
325
+ this.relations[t3.uuid] = __spreadProps(__spreadValues({}, t3), { _stopResolving: true });
326
+ });
327
+ }
328
+ async resolveStories(t2, e2) {
329
+ let r2 = [];
330
+ e2.resolve_relations !== void 0 && e2.resolve_relations.length > 0 && (r2 = e2.resolve_relations.split(","), await this.resolveRelations(t2, e2)), ["1", "story", "url"].indexOf(e2.resolve_links) > -1 && await this.resolveLinks(t2, e2);
331
+ for (const t3 in this.relations)
332
+ this.iterateTree(this.relations[t3], r2);
333
+ t2.story ? this.iterateTree(t2.story, r2) : t2.stories.forEach((t3) => {
334
+ this.iterateTree(t3, r2);
335
+ });
336
+ }
337
+ cacheResponse(t2, e2, r2) {
338
+ return r2 === void 0 && (r2 = 0), new Promise(async (s2, n2) => {
339
+ let i2 = a({ url: t2, params: e2 }), o2 = this.cacheProvider();
340
+ if (this.cache.clear === "auto" && e2.version === "draft" && await this.flushCache(), e2.version === "published" && t2 != "/cdn/spaces/me") {
341
+ const t3 = await o2.get(i2);
342
+ if (t3)
343
+ return s2(t3);
344
+ }
345
+ try {
346
+ let r3 = await this.throttle("get", t2, { params: e2, paramsSerializer: (t3) => a(t3) }), l3 = { data: r3.data, headers: r3.headers };
347
+ if (r3.headers["per-page"] && (l3 = Object.assign({}, l3, { perPage: parseInt(r3.headers["per-page"]), total: parseInt(r3.headers.total) })), r3.status != 200)
348
+ return n2(r3);
349
+ (l3.data.story || l3.data.stories) && await this.resolveStories(l3.data, e2), e2.version === "published" && t2 != "/cdn/spaces/me" && o2.set(i2, l3), l3.data.cv && (e2.version == "draft" && c[e2.token] != l3.data.cv && this.flushCache(), c[e2.token] = l3.data.cv), s2(l3);
350
+ } catch (i3) {
351
+ if (i3.response && i3.response.status === 429 && (r2 += 1) < this.maxRetries)
352
+ return console.log(`Hit rate limit. Retrying in ${r2} seconds.`), await (l2 = 1e3 * r2, new Promise((t3) => setTimeout(t3, l2))), this.cacheResponse(t2, e2, r2).then(s2).catch(n2);
353
+ n2(i3);
354
+ }
355
+ var l2;
356
+ });
357
+ }
358
+ throttledRequest(t2, e2, r2) {
359
+ return this.client[t2](e2, r2);
360
+ }
361
+ cacheVersions() {
362
+ return c;
363
+ }
364
+ cacheVersion() {
365
+ return c[this.accessToken];
366
+ }
367
+ setCacheVersion(t2) {
368
+ this.accessToken && (c[this.accessToken] = t2);
369
+ }
370
+ cacheProvider() {
371
+ switch (this.cache.type) {
372
+ case "memory":
373
+ return { get: (t2) => l[t2], getAll: () => l, set(t2, e2) {
374
+ l[t2] = e2;
375
+ }, flush() {
376
+ l = {};
377
+ } };
378
+ default:
379
+ return { get() {
380
+ }, getAll() {
381
+ }, set() {
382
+ }, flush() {
383
+ } };
384
+ }
385
+ }
386
+ async flushCache() {
387
+ return await this.cacheProvider().flush(), this;
388
+ }
389
+ }
390
+ var api = (options = {}) => {
391
+ const { apiOptions } = options;
392
+ if (!apiOptions.accessToken) {
393
+ 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");
394
+ return;
395
+ }
396
+ const storyblokApi = new StoryblokClient(apiOptions);
397
+ return { storyblokApi };
398
+ };
399
+ var editable = (blok) => {
400
+ if (typeof blok !== "object" || typeof blok._editable === "undefined") {
401
+ return {};
402
+ }
403
+ const options = JSON.parse(blok._editable.replace(/^<!--#storyblok#/, "").replace(/-->$/, ""));
404
+ return {
405
+ "data-blok-c": JSON.stringify(options),
406
+ "data-blok-uid": options.id + "-" + options.uid
407
+ };
408
+ };
409
+ const useStoryblokBridge = (id, cb, options = {}) => {
410
+ if (typeof window === "undefined") {
411
+ return;
412
+ }
413
+ if (typeof window.storyblokRegisterEvent === "undefined") {
414
+ console.error("Storyblok Bridge is disabled. Please enable it to use it. Read https://github.com/storyblok/storyblok-js");
415
+ return;
416
+ }
417
+ window.storyblokRegisterEvent(() => {
418
+ const sbBridge = new window.StoryblokBridge(options);
419
+ sbBridge.on(["input", "published", "change"], (event) => {
420
+ if (event.action == "input" && event.story.id === id) {
421
+ cb(event.story);
422
+ } else {
423
+ window.location.reload();
424
+ }
425
+ });
426
+ });
427
+ };
428
+ const storyblokInit$1 = (pluginOptions = {}) => {
429
+ const { bridge, accessToken, use = [], apiOptions = {} } = pluginOptions;
430
+ apiOptions.accessToken = apiOptions.accessToken || accessToken;
431
+ const options = { bridge, apiOptions };
432
+ let result = {};
433
+ use.forEach((pluginFactory) => {
434
+ result = __spreadValues(__spreadValues({}, result), pluginFactory(options));
435
+ });
436
+ if (bridge !== false) {
437
+ loadBridge("https://app.storyblok.com/f/storyblok-v2-latest.js");
438
+ }
439
+ return result;
440
+ };
441
+ function noop() {
442
+ }
443
+ function assign(tar, src) {
444
+ for (const k in src)
445
+ tar[k] = src[k];
446
+ return tar;
447
+ }
448
+ function run(fn) {
449
+ return fn();
450
+ }
451
+ function blank_object() {
452
+ return /* @__PURE__ */ Object.create(null);
453
+ }
454
+ function run_all(fns) {
455
+ fns.forEach(run);
456
+ }
457
+ function is_function(thing) {
458
+ return typeof thing === "function";
459
+ }
460
+ function safe_not_equal(a2, b) {
461
+ return a2 != a2 ? b == b : a2 !== b || (a2 && typeof a2 === "object" || typeof a2 === "function");
462
+ }
463
+ function is_empty(obj) {
464
+ return Object.keys(obj).length === 0;
465
+ }
466
+ function exclude_internal_props(props) {
467
+ const result = {};
468
+ for (const k in props)
469
+ if (k[0] !== "$")
470
+ result[k] = props[k];
471
+ return result;
472
+ }
473
+ function compute_rest_props(props, keys) {
474
+ const rest = {};
475
+ keys = new Set(keys);
476
+ for (const k in props)
477
+ if (!keys.has(k) && k[0] !== "$")
478
+ rest[k] = props[k];
479
+ return rest;
480
+ }
481
+ function insert(target, node, anchor) {
482
+ target.insertBefore(node, anchor || null);
483
+ }
484
+ function detach(node) {
485
+ node.parentNode.removeChild(node);
486
+ }
487
+ function text(data) {
488
+ return document.createTextNode(data);
489
+ }
490
+ function empty() {
491
+ return text("");
492
+ }
493
+ function children(element) {
494
+ return Array.from(element.childNodes);
495
+ }
496
+ let current_component;
497
+ function set_current_component(component) {
498
+ current_component = component;
499
+ }
500
+ const dirty_components = [];
501
+ const binding_callbacks = [];
502
+ const render_callbacks = [];
503
+ const flush_callbacks = [];
504
+ const resolved_promise = Promise.resolve();
505
+ let update_scheduled = false;
506
+ function schedule_update() {
507
+ if (!update_scheduled) {
508
+ update_scheduled = true;
509
+ resolved_promise.then(flush);
510
+ }
511
+ }
512
+ function add_render_callback(fn) {
513
+ render_callbacks.push(fn);
514
+ }
515
+ const seen_callbacks = /* @__PURE__ */ new Set();
516
+ let flushidx = 0;
517
+ function flush() {
518
+ const saved_component = current_component;
519
+ do {
520
+ while (flushidx < dirty_components.length) {
521
+ const component = dirty_components[flushidx];
522
+ flushidx++;
523
+ set_current_component(component);
524
+ update(component.$$);
525
+ }
526
+ set_current_component(null);
527
+ dirty_components.length = 0;
528
+ flushidx = 0;
529
+ while (binding_callbacks.length)
530
+ binding_callbacks.pop()();
531
+ for (let i2 = 0; i2 < render_callbacks.length; i2 += 1) {
532
+ const callback = render_callbacks[i2];
533
+ if (!seen_callbacks.has(callback)) {
534
+ seen_callbacks.add(callback);
535
+ callback();
536
+ }
537
+ }
538
+ render_callbacks.length = 0;
539
+ } while (dirty_components.length);
540
+ while (flush_callbacks.length) {
541
+ flush_callbacks.pop()();
542
+ }
543
+ update_scheduled = false;
544
+ seen_callbacks.clear();
545
+ set_current_component(saved_component);
546
+ }
547
+ function update($$) {
548
+ if ($$.fragment !== null) {
549
+ $$.update();
550
+ run_all($$.before_update);
551
+ const dirty = $$.dirty;
552
+ $$.dirty = [-1];
553
+ $$.fragment && $$.fragment.p($$.ctx, dirty);
554
+ $$.after_update.forEach(add_render_callback);
555
+ }
556
+ }
557
+ const outroing = /* @__PURE__ */ new Set();
558
+ let outros;
559
+ function group_outros() {
560
+ outros = {
561
+ r: 0,
562
+ c: [],
563
+ p: outros
564
+ };
565
+ }
566
+ function check_outros() {
567
+ if (!outros.r) {
568
+ run_all(outros.c);
569
+ }
570
+ outros = outros.p;
571
+ }
572
+ function transition_in(block, local) {
573
+ if (block && block.i) {
574
+ outroing.delete(block);
575
+ block.i(local);
576
+ }
577
+ }
578
+ function transition_out(block, local, detach2, callback) {
579
+ if (block && block.o) {
580
+ if (outroing.has(block))
581
+ return;
582
+ outroing.add(block);
583
+ outros.c.push(() => {
584
+ outroing.delete(block);
585
+ if (callback) {
586
+ if (detach2)
587
+ block.d(1);
588
+ callback();
589
+ }
590
+ });
591
+ block.o(local);
592
+ }
593
+ }
594
+ function get_spread_update(levels, updates) {
595
+ const update2 = {};
596
+ const to_null_out = {};
597
+ const accounted_for = { $$scope: 1 };
598
+ let i2 = levels.length;
599
+ while (i2--) {
600
+ const o2 = levels[i2];
601
+ const n2 = updates[i2];
602
+ if (n2) {
603
+ for (const key in o2) {
604
+ if (!(key in n2))
605
+ to_null_out[key] = 1;
606
+ }
607
+ for (const key in n2) {
608
+ if (!accounted_for[key]) {
609
+ update2[key] = n2[key];
610
+ accounted_for[key] = 1;
611
+ }
612
+ }
613
+ levels[i2] = n2;
614
+ } else {
615
+ for (const key in o2) {
616
+ accounted_for[key] = 1;
617
+ }
618
+ }
619
+ }
620
+ for (const key in to_null_out) {
621
+ if (!(key in update2))
622
+ update2[key] = void 0;
623
+ }
624
+ return update2;
625
+ }
626
+ function get_spread_object(spread_props) {
627
+ return typeof spread_props === "object" && spread_props !== null ? spread_props : {};
628
+ }
629
+ function create_component(block) {
630
+ block && block.c();
631
+ }
632
+ function mount_component(component, target, anchor, customElement) {
633
+ const { fragment, on_mount, on_destroy, after_update } = component.$$;
634
+ fragment && fragment.m(target, anchor);
635
+ if (!customElement) {
636
+ add_render_callback(() => {
637
+ const new_on_destroy = on_mount.map(run).filter(is_function);
638
+ if (on_destroy) {
639
+ on_destroy.push(...new_on_destroy);
640
+ } else {
641
+ run_all(new_on_destroy);
642
+ }
643
+ component.$$.on_mount = [];
644
+ });
645
+ }
646
+ after_update.forEach(add_render_callback);
647
+ }
648
+ function destroy_component(component, detaching) {
649
+ const $$ = component.$$;
650
+ if ($$.fragment !== null) {
651
+ run_all($$.on_destroy);
652
+ $$.fragment && $$.fragment.d(detaching);
653
+ $$.on_destroy = $$.fragment = null;
654
+ $$.ctx = [];
655
+ }
656
+ }
657
+ function make_dirty(component, i2) {
658
+ if (component.$$.dirty[0] === -1) {
659
+ dirty_components.push(component);
660
+ schedule_update();
661
+ component.$$.dirty.fill(0);
662
+ }
663
+ component.$$.dirty[i2 / 31 | 0] |= 1 << i2 % 31;
664
+ }
665
+ function init(component, options, instance2, create_fragment2, not_equal, props, append_styles, dirty = [-1]) {
666
+ const parent_component = current_component;
667
+ set_current_component(component);
668
+ const $$ = component.$$ = {
669
+ fragment: null,
670
+ ctx: null,
671
+ props,
672
+ update: noop,
673
+ not_equal,
674
+ bound: blank_object(),
675
+ on_mount: [],
676
+ on_destroy: [],
677
+ on_disconnect: [],
678
+ before_update: [],
679
+ after_update: [],
680
+ context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
681
+ callbacks: blank_object(),
682
+ dirty,
683
+ skip_bound: false,
684
+ root: options.target || parent_component.$$.root
685
+ };
686
+ append_styles && append_styles($$.root);
687
+ let ready = false;
688
+ $$.ctx = instance2 ? instance2(component, options.props || {}, (i2, ret, ...rest) => {
689
+ const value = rest.length ? rest[0] : ret;
690
+ if ($$.ctx && not_equal($$.ctx[i2], $$.ctx[i2] = value)) {
691
+ if (!$$.skip_bound && $$.bound[i2])
692
+ $$.bound[i2](value);
693
+ if (ready)
694
+ make_dirty(component, i2);
695
+ }
696
+ return ret;
697
+ }) : [];
698
+ $$.update();
699
+ ready = true;
700
+ run_all($$.before_update);
701
+ $$.fragment = create_fragment2 ? create_fragment2($$.ctx) : false;
702
+ if (options.target) {
703
+ if (options.hydrate) {
704
+ const nodes = children(options.target);
705
+ $$.fragment && $$.fragment.l(nodes);
706
+ nodes.forEach(detach);
707
+ } else {
708
+ $$.fragment && $$.fragment.c();
709
+ }
710
+ if (options.intro)
711
+ transition_in(component.$$.fragment);
712
+ mount_component(component, options.target, options.anchor, options.customElement);
713
+ flush();
714
+ }
715
+ set_current_component(parent_component);
716
+ }
717
+ class SvelteComponent {
718
+ $destroy() {
719
+ destroy_component(this, 1);
720
+ this.$destroy = noop;
721
+ }
722
+ $on(type, callback) {
723
+ const callbacks2 = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
724
+ callbacks2.push(callback);
725
+ return () => {
726
+ const index = callbacks2.indexOf(callback);
727
+ if (index !== -1)
728
+ callbacks2.splice(index, 1);
729
+ };
730
+ }
731
+ $set($$props) {
732
+ if (this.$$set && !is_empty($$props)) {
733
+ this.$$.skip_bound = true;
734
+ this.$$set($$props);
735
+ this.$$.skip_bound = false;
736
+ }
737
+ }
738
+ }
739
+ function create_fragment(ctx) {
740
+ let switch_instance;
741
+ let switch_instance_anchor;
742
+ let current;
743
+ const switch_instance_spread_levels = [{ blok: ctx[0] }, ctx[2]];
744
+ var switch_value = ctx[1];
745
+ function switch_props(ctx2) {
746
+ let switch_instance_props = {};
747
+ for (let i2 = 0; i2 < switch_instance_spread_levels.length; i2 += 1) {
748
+ switch_instance_props = assign(switch_instance_props, switch_instance_spread_levels[i2]);
749
+ }
750
+ return { props: switch_instance_props };
751
+ }
752
+ if (switch_value) {
753
+ switch_instance = new switch_value(switch_props());
754
+ }
755
+ return {
756
+ c() {
757
+ if (switch_instance)
758
+ create_component(switch_instance.$$.fragment);
759
+ switch_instance_anchor = empty();
760
+ },
761
+ m(target, anchor) {
762
+ if (switch_instance) {
763
+ mount_component(switch_instance, target, anchor);
764
+ }
765
+ insert(target, switch_instance_anchor, anchor);
766
+ current = true;
767
+ },
768
+ p(ctx2, [dirty]) {
769
+ const switch_instance_changes = dirty & 5 ? get_spread_update(switch_instance_spread_levels, [
770
+ dirty & 1 && { blok: ctx2[0] },
771
+ dirty & 4 && get_spread_object(ctx2[2])
772
+ ]) : {};
773
+ if (switch_value !== (switch_value = ctx2[1])) {
774
+ if (switch_instance) {
775
+ group_outros();
776
+ const old_component = switch_instance;
777
+ transition_out(old_component.$$.fragment, 1, 0, () => {
778
+ destroy_component(old_component, 1);
779
+ });
780
+ check_outros();
781
+ }
782
+ if (switch_value) {
783
+ switch_instance = new switch_value(switch_props());
784
+ create_component(switch_instance.$$.fragment);
785
+ transition_in(switch_instance.$$.fragment, 1);
786
+ mount_component(switch_instance, switch_instance_anchor.parentNode, switch_instance_anchor);
787
+ } else {
788
+ switch_instance = null;
789
+ }
790
+ } else if (switch_value) {
791
+ switch_instance.$set(switch_instance_changes);
792
+ }
793
+ },
794
+ i(local) {
795
+ if (current)
796
+ return;
797
+ if (switch_instance)
798
+ transition_in(switch_instance.$$.fragment, local);
799
+ current = true;
800
+ },
801
+ o(local) {
802
+ if (switch_instance)
803
+ transition_out(switch_instance.$$.fragment, local);
804
+ current = false;
805
+ },
806
+ d(detaching) {
807
+ if (detaching)
808
+ detach(switch_instance_anchor);
809
+ if (switch_instance)
810
+ destroy_component(switch_instance, detaching);
811
+ }
812
+ };
813
+ }
814
+ function instance($$self, $$props, $$invalidate) {
815
+ const omit_props_names = ["blok"];
816
+ let $$restProps = compute_rest_props($$props, omit_props_names);
817
+ let { blok } = $$props;
818
+ let resolvedComponent;
819
+ if (blok) {
820
+ const component = getComponent(blok.component);
821
+ if (component) {
822
+ const loadComponent = async () => {
823
+ const { default: loadedComponent } = await component();
824
+ $$invalidate(1, resolvedComponent = loadedComponent);
825
+ };
826
+ const isSvelteComponent = component.name.startsWith("Proxy");
827
+ if (isSvelteComponent)
828
+ resolvedComponent = component;
829
+ else
830
+ loadComponent();
831
+ }
832
+ } else {
833
+ console.error("Please provide a 'blok' property to the StoryblokComponent");
834
+ }
835
+ $$self.$$set = ($$new_props) => {
836
+ $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
837
+ $$invalidate(2, $$restProps = compute_rest_props($$props, omit_props_names));
838
+ if ("blok" in $$new_props)
839
+ $$invalidate(0, blok = $$new_props.blok);
840
+ };
841
+ return [blok, resolvedComponent, $$restProps];
842
+ }
843
+ class StoryblokComponent extends SvelteComponent {
844
+ constructor(options) {
845
+ super();
846
+ init(this, options, instance, create_fragment, safe_not_equal, { blok: 0 });
847
+ }
848
+ }
849
+ const storyblokEditable = (node, value) => {
850
+ const updateDom = (value2) => {
851
+ const options = editable(value2);
852
+ if (options["data-blok-c"]) {
853
+ node.setAttribute("data-blok-c", options["data-blok-c"]);
854
+ node.setAttribute("data-blok-uid", options["data-blok-uid"]);
855
+ node.classList.add("storyblok__outline");
856
+ }
857
+ };
858
+ updateDom(value);
859
+ return {
860
+ update(newValue) {
861
+ updateDom(newValue);
862
+ }
863
+ };
864
+ };
865
+ let storyblokApiInstance = null;
866
+ const useStoryblokApi = () => {
867
+ if (!storyblokApiInstance) {
868
+ console.log(`You can't use useStoryblokApi if you're not loading apiPlugin.`);
869
+ }
870
+ return storyblokApiInstance;
871
+ };
872
+ let componentsMap = null;
873
+ const storyblokInit = (options) => {
874
+ const { storyblokApi } = storyblokInit$1(options);
875
+ storyblokApiInstance = storyblokApi;
876
+ componentsMap = options.components || {};
877
+ };
878
+ const getComponent = (componentName) => {
879
+ const component = componentsMap[componentName];
880
+ if (!component) {
881
+ console.error(`You didn't load the ${componentName} component. Please load it in storyblokInit. For example:
882
+ storyblokInit({
883
+ accessToken: "<your-token>",
884
+ components: {
885
+ "teaser": Teaser
886
+ }
887
+ })
888
+ `);
889
+ }
890
+ return component;
891
+ };
892
+ export { StoryblokComponent, api as apiPlugin, getComponent, storyblokEditable, storyblokInit, useStoryblokApi, useStoryblokBridge };
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@storyblok/svelte",
3
+ "version": "1.0.0",
4
+ "description": "Storyblok SDK to connect Storyblok with Svelte",
5
+ "main": "./dist/storyblok-svelte.js",
6
+ "module": "./dist/storyblok-svelte.mjs",
7
+ "svelte": "index.js",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/storyblok-svelte.mjs",
14
+ "require": "./dist/storyblok-svelte.js"
15
+ }
16
+ },
17
+ "scripts": {
18
+ "dev": "vite build --watch",
19
+ "build": "vite build",
20
+ "test": "npm run test:unit && npm run test:e2e",
21
+ "test:unit": "jest __tests__",
22
+ "test:e2e": "cypress run-ct",
23
+ "test:e2e-watch": "cypress open-ct",
24
+ "prepublishOnly": "npm run build && cp ../README.md ./"
25
+ },
26
+ "dependencies": {
27
+ "@storyblok/js": "^1.0.3"
28
+ },
29
+ "devDependencies": {
30
+ "@babel/core": "^7.15.0",
31
+ "@cypress/vite-dev-server": "^2.2.2",
32
+ "babel-jest": "^27.5.1",
33
+ "cypress": "^9.4.1",
34
+ "cypress-svelte-unit-test": "^3.3.4",
35
+ "eslint-plugin-cypress": "^2.12.1",
36
+ "eslint-plugin-jest": "^26.1.1",
37
+ "jest": "^27.5.1",
38
+ "vite": "^2.4.4"
39
+ },
40
+ "eslintConfig": {
41
+ "env": {
42
+ "node": true
43
+ }
44
+ },
45
+ "jest": {
46
+ "moduleFileExtensions": [
47
+ "js",
48
+ "json"
49
+ ],
50
+ "transform": {
51
+ "^.+\\.js$": "babel-jest"
52
+ }
53
+ },
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "https://github.com/storyblok/storyblok-svelte"
57
+ },
58
+ "keywords": [
59
+ "svelte",
60
+ "storyblok"
61
+ ],
62
+ "author": "Josefine Schaefer",
63
+ "bugs": {
64
+ "url": "https://github.com/storyblok/storyblok-svelte/issues"
65
+ },
66
+ "homepage": "https://github.com/storyblok/storyblok-svelte",
67
+ "release": {
68
+ "branches": [
69
+ "main"
70
+ ]
71
+ },
72
+ "publishConfig": {
73
+ "access": "public"
74
+ }
75
+ }