Anvil/assets/preview-0ad5268f.js

2 lines
3.1 KiB
JavaScript
Raw Normal View History

2024-02-08 10:52:22 +01:00
import{I as S,v as I}from"./preview-errors-dde4324f.js";import{o as j,s as b,g as x}from"./lifecycle-1566062d.js";import"./index-356e4a49.js";const{addons:T}=__STORYBOOK_MODULE_PREVIEW_API__,{global:A}=__STORYBOOK_MODULE_GLOBAL__;var k="storybook/actions",B=`${k}/action-event`,C={depth:10,clearOnStoryChange:!0,limit:50},L=(e,n)=>{let t=Object.getPrototypeOf(e);return!t||n(t)?t:L(t,n)},F=e=>!!(typeof e=="object"&&e&&L(e,n=>/^Synthetic(?:Base)?Event$/.test(n.constructor.name))&&typeof e.persist=="function"),N=e=>{if(F(e)){let n=Object.create(e.constructor.prototype,Object.getOwnPropertyDescriptors(e));n.persist();let t=Object.getOwnPropertyDescriptor(n,"view"),r=t==null?void 0:t.value;return typeof r=="object"&&(r==null?void 0:r.constructor.name)==="Window"&&Object.defineProperty(n,"view",{...t,value:Object.create(r.constructor.prototype)}),n}return e},V=()=>typeof crypto=="object"&&typeof crypto.getRandomValues=="function"?I():Date.now().toString(36)+Math.random().toString(36).substring(2);function R(e,n={}){let t={...C,...n},r=function(...g){var h,i;if(n.implicit){let c=(h="__STORYBOOK_PREVIEW__"in A?A.__STORYBOOK_PREVIEW__:void 0)==null?void 0:h.storyRenders.find(o=>o.phase==="playing"||o.phase==="rendering");if(c){let o=!((i=window==null?void 0:window.FEATURES)!=null&&i.disallowImplicitActionsInRenderV8),s=new S({phase:c.phase,name:e,deprecated:o});if(o)console.warn(s);else throw s}}let f=T.getChannel(),u=V(),v=5,d=g.map(N),O=g.length>1?d:d[0],_={id:u,count:0,data:{name:e,args:O},options:{...t,maxDepth:v+(t.depth||3),allowFunction:t.allowFunction||!1}};f.emit(B,_)};return r.isAction=!0,r}function M(e){b("after-navigate-args",e)}function E(e){return[{subscribe(n){let t=x(e);return n(t),()=>{}}},n=>{b(e,n)}]}var[q,z]=E("page-ctx"),[J,P]=E("navigating-ctx"),[U,W]=E("updated-ctx");U.check=()=>{};var Y=e=>typeof e=="function"?{callback:e,asRegex:!1}:e,Q=[(e,n)=>{var r,g,f,u,v;let t=((r=n.parameters)==null?void 0:r.sveltekit_experimental)??{};return z((g=t==null?void 0:t.stores)==null?void 0:g.page),P((f=t==null?void 0:t.stores)==null?void 0:f.navigating),W((u=t==null?void 0:t.stores)==null?void 0:u.updated),M((v=t==null?void 0:t.navigation)==null?void 0:v.afterNavigate),j(()=>{let d=i=>{let c=i.composedPath().findLast(o=>o instanceof HTMLElement&&o.tagName==="A");if(c&&c instanceof HTMLAnchorElement){let o=c.getAttribute("href");if(!o)return;i.preventDefault();let s=()=>R("navigate")(o,i);if(!t.hrefs){s();return}let a=!0;Object.entries(t.hrefs).forEach(([l,m])=>{let{callback:p,asRegex:y}=Y(m);(y?new RegExp(l).test(o):o===l)&&(a=!1,p==null||p(o,i))}),a&&s()}};function O(i,c,o){let s=[];return c.forEach(a=>{var m;let l=((m=t[i])==null?void 0:m[a])&&t[i][a]instanceof Function;if(l||o){let p=({detail:w=[]})=>{let D=Array.isArray(w)?w:[];(l?t[i][a]:R(a))(...D)},y=`storybook:${a}`;s.push({eventType:y,listener:p}),window.addEventListener(y,p)}}),()=>{s.forEach(({eventType:a,listener:l})=>{window.removeEventListener(a,l)})}}let _=O("navigation",["goto","invalidate","invalidateAll","pushState","replaceState"],!0),h=O("forms",["enhance"]);return window.addEventListener("click",d),()=>{window.removeEventListener("click",d),_(),h()}}),e()}];export{Q as decorators};