/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/pawa-ssr@1.3.7/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import{getServerInstance,setServer}from"pawajs/server.js";import{DOMParser,parseHTML,HTMLElement}from"linkedom";import PawaComponent from"./pawaComponent.js";import{propsValidator,evaluateExpr,extractAtExpressions,reArrangeAttri,resumeAttribute,pawaGenerateId}from"./utils.js";import{AsyncLocalStorage}from"node:async_hooks";import{If,For,State,Switch,Key}from"./power.js";import PawaElement from"./pawaElement.js";import{pluginsMap}from"pawajs";const PAWA_STORE_SYMBOL=Symbol.for("pawa.ssr.store"),getStoreInstance=()=>(global[PAWA_STORE_SYMBOL]||(global[PAWA_STORE_SYMBOL]=new AsyncLocalStorage),global[PAWA_STORE_SYMBOL]),store=getStoreInstance(),useInsert=(e={})=>{try{const t=store.getStore();t?.stateContext?.insert&&Object.assign(t.stateContext.insert,e)}catch(e){__pawaDev&&console.log(e.message,e.stack)}},useAsync=()=>{try{const e=store.getStore();if(e?.stateContext){const t=e?.stateContext;return{$async:e=>{if("function"==typeof e){store.getStore().stateContext=t;return e()}},onSuspense:e=>{"string"==typeof e&&(t.suspense=e)}}}}catch(e){}},setContext=()=>{const e=crypto.randomUUID();return{id:e,setValue:(t={})=>{try{const r=store.getStore();r?.stateContext?.transportContext&&(r.stateContext.transportContext[e]=t)}catch(e){isDevelopment&&console.log(e.message,"this hook must be used inside of a component",e.stack)}}}},accessChild=()=>{try{const e=store.getStore();e?.stateContext&&(e.stateContext.accessChild=!0)}catch(e){isDevelopment&&console.log(e.message,"this is from component",e.stack)}},useServer=()=>{const e=store.getStore().stateContext;try{if(e){e.useServer=!0,e.serializeData=!0;return{setServerData:(t={})=>{for(const[r,o]of Object.entries(t))"function"!=typeof o&&(e.fromSerialized[r]=o)},getServerData:()=>e.fromSerialized}}}catch(e){isDevelopment&&console.log(e.message,"this is from component",e.stack)}},useContext=e=>{try{const t=store.getStore(),r=e?.id;return t?.stateContext?.transportContext&&r?t.stateContext.transportContext[r]:{}}catch(e){isDevelopment&&console.log(e.message,e.stack)}},useInnerContext=()=>{try{const e=store.getStore();return e?.stateContext?.innerContext||{}}catch(e){isDevelopment&&console.log(e.message,e.stack)}},$state=e=>{const t={value:null,id:crypto.randomUUID()};if("function"==typeof e){const r=e();r instanceof Promise?(t.async=!0,t.failed=!1,t.retry=()=>{}):t.value=r}else t.value=e;const r=(e,t)=>{const r={...e},o=e.value;if(o&&"object"==typeof o)try{r.value=structuredClone(o)}catch(e){r.value=Array.isArray(o)?[...o]:{...o}}else r.value=o;t.states.set(e,r)};return new Proxy(t,{get(e,t,o){const n=store.getStore();return n?(n.states||(n.states=new Map),n.states.has(e)||r(e,n),n.states.get(e)[t]):Reflect.get(e,t,o)},set(e,t,o,n){const a=store.getStore();return a?(a.states||(a.states=new Map),a.states.has(e)||r(e,a),a.states.get(e)[t]=o,!0):Reflect.set(e,t,o,n)}})};setServer({useContext:useContext,useInnerContext:useInnerContext,useInsert:useInsert,setContext:setContext,$state:$state,accessChild:accessChild,useServer:useServer,useAsync:useAsync});export const pawaForServer=setServer;const components=new Map;export const getPawaComponentsMap=()=>components;const getStore=()=>store.getStore();let isDevelopment;export const getDevelopment=()=>isDevelopment;const allServerAttr=["if","else","else-if","for","ref"];export const getAllServerAttrArray=()=>allServerAttr;const{compoAfterCall:compoAfterCall,compoBeforeCall:compoBeforeCall,externalPlugin:externalPlugin,fullNamePlugin:fullNamePlugin,renderAfterPawa:renderAfterPawa,renderBeforeChild:renderBeforeChild,renderBeforePawa:renderBeforePawa,startsWithSet:startsWithSet,pawaAttributes:pawaAttributes}=pluginsMap(),setPawaAttribute=(...e)=>{e.forEach((e=>{pawaAttributes.add(e)}))};setPawaAttribute("if","else","else-if","for-each","ref","key");export const getPawaAttributes=()=>pawaAttributes;export const PluginSystem=(...e)=>{e.forEach((e=>{if("function"!=typeof e)return void console.warn("plugin must be a function that returns the plugin objects");const t=e();t?.attribute&&t.attribute.register.forEach((e=>{if(e.fullName&&e.startsWith)console.warn("Either Plugins FullName or startsWith. you are not required to use to of does plugin registers at this same entry.");else if(e?.fullName){if(pawaAttributes.has(e.fullName))return void console.warn(`attribute plugin already exist ${e.fullName}`);pawaAttributes.add(e.fullName),fullNamePlugin.add(e.fullName),externalPlugin[e.fullName]=e?.plugin}else if(e?.startsWith){if(pawaAttributes.has(e.startsWith))return void console.warn(`attribute plugin already exist ${e.startsWith}`);pawaAttributes.add(e.startsWith),startsWithSet.add(e.startsWith),externalPlugin[e.startsWith]=e?.plugin}})),t?.component&&(t.component?.beforeCall&&"function"==typeof t.component?.beforeCall&&compoBeforeCall.add(t.component.beforeCall),t.component?.afterCall&&"function"==typeof t.component?.afterCall&&compoAfterCall.add(t.component.afterCall)),t?.renderSystem&&(t.renderSystem?.beforePawa&&"function"==typeof t.renderSystem?.beforePawa&&renderBeforePawa.add(t.renderSystem?.beforePawa),t.renderSystem?.afterPawa&&"function"==typeof t.renderSystem?.afterPawa&&renderAfterPawa.add(t.renderSystem?.afterPawa),t.renderSystem?.beforeChildRender&&"function"==typeof t.renderSystem?.beforeChildRender&&renderBeforeChild.add(t.renderSystem?.beforeChildRender))}))};export const useValidateComponent=(e,t)=>{"function"==typeof e&&e.name&&(e.validateProps=t)};const component=async(e,t)=>{if(!e._running)try{const r=e._slots,o=e.ownerDocument,n={},a=store.getStore().stateContext;let s={},c={transportContext:{},innerContext:e._context,mount:[],formerContext:a,name:e._componentName,insert:{},component:e._component,accessChild:!1,serializeData:!1,serialize:{},fromSerialized:{},useServer:!1,suspense:"",carrier:"",pc:e.getAttribute("p:c")};Object.assign(c.transportContext,a?.transportContext||{});const i={};Array.from(r.children).forEach((e=>{if(e.getAttribute("prop")){const t=e.innerHTML;n[e.getAttribute("prop")]=()=>t,i[e.getAttribute("prop")]=t}else console.warn("sloting props must have prop attribute")}));const l=e._componentChildren,m={children:l,props:{...e._hydrateProps},slots:{...i}},p=pawaGenerateId(10),d=e=>Buffer.from(JSON.stringify(e)).toString("base64").replace(/\+/g,"-"),f=o.createComment(`component+${p}`),u=o.createComment(`end component+${p}+${e._componentName}`);e.replaceWith(u),u.parentElement.insertBefore(f,u);const g=e._component;s=g,s._name=e._componentName;let h=!0;Object.entries(e._component.validPropRule).length>0&&(h=propsValidator(e._component.validPropRule,{...e._props,...n},c.component._name,e.toString(),e)),c.component._prop={children:l,...e._props,...n};const w={children:l,...n,...e._props};for(const t of compoBeforeCall)try{await t(s,w)}catch(t){console.error(`Error in beforeCall for ${e._componentName}:`,t.message,t.stack),__pawaDev.setError({el:e,msg:`from  compoBeforeCall${e._componentName}:`+t.message+t.stack,directives:"plugin",stack:t.stack,template:e?._template})}const v=o.createElement("div");e._setResumeAttr(`c-compo-${e._componentName}-${p}`);let y="";try{h&&(store.getStore().stateContext=c,y=await g.component(w))}catch(t){console.error(`error from PawaComponent.${c.component._name}`,t.message,t.stack),__pawaDev.setError({el:e,msg:`error from PawaComponent.${c.component._name}`+t.message+t.stack,directives:e.tagName,stack:t.stack,template:e?._template})}c?.insert&&Object.assign(e._context,c.insert),"boolean"!=typeof y&&"string"==typeof y&&(v.innerHTML=y);const b=v.querySelector("[--]")||v.querySelector("[r-]");if(b){for(const[t,r]of Object.entries(e?._restProps))b.setAttribute(r.name,r.value);b.removeAttribute("--"),b.removeAttribute("r-")}const _=v.firstElementChild;for(const t of compoAfterCall)try{await t(c,_,e)}catch(e){console.error(e.message,e.stack)}if(m.data=null,c.serializeData){for(const[e,t]of Object.entries(c.fromSerialized))"function"!=typeof t&&(c.serialize[e]=t);m.data=c.serialize}m.context=[];for(const[e]of Object.entries(c.insert))m.context.push(e);f.data=`component+${p}+${e._componentName}+${d(m)}`,f.parentElement.insertBefore(_,u),_.setAttribute("p:c",e.getAttribute("p:c")),Array.from(e.attributes).forEach((e=>{e.name.startsWith("c-")&&_.setAttribute(e.name,e.value)})),_.setAttribute(`c-c-${e._componentName}-${p}`,p),await render(_,e._context,t),store.getStore().stateContext=c.formerContext}catch(t){console.log(t.message,t.stack),__pawaDev.setError({el:e,msg:`from  ${e.tagName} component`,directives:"component",stack:t.stack,template:e?._template})}},streamingComponent=async(e,t)=>{if(!e._running)try{const r=e._slots,o=e.ownerDocument,n={},a=store.getStore().stateContext;let s={},c={transportContext:{},innerContext:e._context,mount:[],formerContext:a,name:e._componentName,insert:{},component:e._component,accessChild:!1,serializeData:!1,serialize:{},fromSerialized:{},useServer:!1,suspense:"",carrier:"",pc:e.getAttribute("p:c")};Object.assign(c.transportContext,a?.transportContext||{});const i={};Array.from(r.children).forEach((e=>{if(e.getAttribute("prop")){const t=e.innerHTML;n[e.getAttribute("prop")]=()=>t,i[e.getAttribute("prop")]=t}else console.warn("sloting props must have prop attribute")}));const l=e._componentChildren,m={children:l,props:{...e._hydrateProps},slots:{...i}},p=pawaGenerateId(10),d=e=>Buffer.from(JSON.stringify(e)).toString("base64").replace(/\+/g,"-"),f=o.createComment(`component+${p}`),u=o.createComment(`end component+${p}+${e._componentName}`);e.replaceWith(u),u.parentElement.insertBefore(f,u);const g=e._component;s=g,s._name=e._componentName;let h=!0;Object.entries(e._component.validPropRule).length>0&&(h=propsValidator(e._component.validPropRule,{...e._props,...n},c.component._name,e.toString(),e)),c.component._prop={children:l,...e._props,...n};const w={children:l,...n,...e._props};for(const t of compoBeforeCall)try{await t(s,w)}catch(t){console.error(`Error in beforeCall for ${e._componentName}:`,t.message,t.stack),__pawaDev.setError({el:e,msg:`from  compoBeforeCall${e._componentName}:`+t.message+t.stack,directives:"plugin",stack:t.stack,template:e?._template})}const v=o.createElement("div");e._setResumeAttr(`c-compo-${e._componentName}-${p}`);let y="",b=!1;try{h&&(store.getStore().stateContext=c,y=g.component(w),b=c.suspense&&c.useServer,y instanceof Promise&&!b&&(y=await y.then((e=>e))))}catch(t){console.error(`error from PawaComponent.${c.component._name}`,t.message,t.stack),__pawaDev.setError({el:e,msg:`error from PawaComponent.${c.component._name}`+t.message+t.stack,directives:e.tagName,stack:t.stack,template:e?._template})}c?.insert&&Object.assign(e._context,c.insert),b&&store.getStore().batch.push({component:y,id:p,comment:{hydrate:m,encodeJSON:d,name:e._componentName},appContext:c,context:{...e._context},restProps:e._restProps,hydrate:m}),b&&(y=`<div id="p${p}">${c.suspense}</div>`),"boolean"!=typeof y&&"string"==typeof y&&(v.innerHTML=y);const _=v.querySelector("[--]")||v.querySelector("[r-]");if(_){for(const[t,r]of Object.entries(e?._restProps))_.setAttribute(r.name,r.value);_.removeAttribute("--"),_.removeAttribute("r-")}const x=v.firstElementChild;for(const t of compoAfterCall)try{await t(c,x,e)}catch(e){console.error(e.message,e.stack)}if(m.data=null,c.serializeData){for(const[e,t]of Object.entries(c.fromSerialized))"function"!=typeof t&&(c.serialize[e]=t);m.data=c.serialize}m.context=[];for(const[e]of Object.entries(c.insert))m.context.push(e);f.data=`component+${p}+${e._componentName}+${d(m)}`,t(`\x3c!--${f.data}--\x3e`),f.parentElement.insertBefore(x,u),b?(x.setAttribute("p:c",e.getAttribute("p:c")),x.setAttribute("p-async",e.getAttribute("p:c"))):x.setAttribute("p:c",e.getAttribute("p:c")),Array.from(e.attributes).forEach((e=>{e.name.startsWith("c-")&&x.setAttribute(e.name,e.value)})),x.setAttribute(`c-c-${e._componentName}-${p}`,p),await render(x,e._context,t),t(`\x3c!--${u.data}--\x3e`),c.mount.forEach((async e=>{await e()})),store.getStore().stateContext=c.formerContext}catch(t){console.log(t.message,t.stack),__pawaDev.setError({el:e,msg:`from  ${e.tagName} component`,directives:"component",stack:t.stack,template:e?._template})}},templates=async(e,t)=>{if(e._running)return;const r=e.ownerDocument,o=r.createComment("<template>"),n=r.createComment("</template>");e.replaceWith(n),n.parentElement.insertBefore(o,n),t(`\x3c!--${o.data}--\x3e`);let a=[];for(const t of Array.from(e.content.children))n.parentElement.insertBefore(t,n),a.push(t);for(const[r,o]of a.entries()){if(o.setAttribute("p:c",e.getAttribute("p:c")),0===r)for(const t of Array.from(e.attributes))t.name.startsWith("c-")&&o.setAttribute(t.name,t.value);await render(o,e._context,t)}t(`\x3c!--${n.data}--\x3e`)},textContentHandler=async e=>{if(e._running||e._componentName)return;if(e._hasForOrIf())return;const t=new Map,r=e.outerHTML;e.setAttribute("c-t",!0);const o=e.ownerDocument.createComment(`textEvaluator-${e.innerHTML}`);e.appendChild(o);const n=Array.from(e.childNodes).filter((e=>3===e.nodeType));n.forEach((e=>{t.set(e,e.nodeValue)}));(()=>{try{n.forEach((o=>{let n=t.get(o);extractAtExpressions(n).forEach((({fullMatch:t,expression:o})=>{const a=e._evaluateExpr(o,e._context,`from text interpolation @{} - ${o} at ${r}`);""!==o&&(n=n.replace(t,String(a)))})),o.nodeValue=n}))}catch(t){console.warn(`error at ${e._template} textcontent`),console.error(t.message,t.stack,`error at ${e._template} textcontent`),__pawaDev.setError({el:e,msg:"Error from textHandler"+t.message+t.stack,directives:e.tagName,stack:t.stack,template:e?._template})}})()},attributeHandler=async(e,t)=>{if(e._hasForOrIf())return;if(e._running)return;e._replaceResumeAttr(t.name,`c-at-${t.name}`,t.value);const r=e.outerHTML,o=new Set;o.add("disabled");(()=>{try{let n=t.value;extractAtExpressions(n).forEach((({fullMatch:o,expression:a})=>{const s=e._evaluateExpr(a,e._context,`from text interpolation @{} - ${a} at ${r} attribute ${t.name}`);n=n.replace(o,String(s))})),o.has(t.name)?n?e.setAttribute(t.name,""):e.removeAttribute(t.name):e.setAttribute(t.name,n)}catch(t){console.log(t.message,t.stack),__pawaDev.setError({el:e,msg:"error from Attribute Handler"+t.message+t.stack,directives:"Attribute Handler",stack:t.stack,template:e?._template})}})()},singleElement=new Set,setSingle=(...e)=>{e.forEach((e=>singleElement.add(e)))};setSingle("img","br");const partlyPawajsDirective=new Set;export const addToPartlyDirective=(...e)=>{e.forEach((e=>{partlyPawajsDirective.add(e)}))};addToPartlyDirective("else","else-if","case");const checkIfRemove=e=>{for(const t of partlyPawajsDirective)if(e.hasAttribute(t))return!0;return!1};export const render=async(e,t={},r)=>{if(checkIfRemove(e)&&!e.hasAttribute("switch"))return;const o=store.getStore().stream;if(e.hasAttribute("only-client")){e.removeAttribute("only-client");const t=e.ownerDocument.createElement("template"),n=e.ownerDocument.createComment("only-client");return e.replaceWith(n),t.appendChild(e),n.replaceWith(t),void(o&&r(t.outerHTML))}if("HEAD"===e.tagName)return e.querySelector("title")&&(e.ownerDocument.head.querySelector("title")?.remove(),o&&r(`<script>document.title='${e.querySelector("title").textContent||""}'<\/script>`)),Array.from(e.children).forEach((t=>{e.ownerDocument.head.appendChild(t)})),void e.remove();const n={...t};for(const t of renderBeforePawa)try{await t(e,n)}catch(e){console.error(e.message,e.stack)}const a=store.getStore().stateContext;PawaElement.Element(e,n),e.childNodes.some((e=>3===e.nodeType&&e.nodeValue.includes("@{")))&&!e._avoidPawaRender&&await textContentHandler(e);let s=!1;const c={};e._avoidPawaRender||startsWithSet.forEach((t=>{e._attributes.forEach((e=>{e.name.startsWith(t)&&(s=!0,c[e.name]=t)}))}));for(const t of renderAfterPawa)try{await t(e)}catch(e){console.error(e.message,e.stack)}if(!e._avoidPawaRender){const t=Array.from(e.attributes);for(const o of t)if(directives[o.name])await directives[o.name](e,o,r);else if(o.value.includes("@{"))await attributeHandler(e,o);else if(o.name.startsWith("state-"))directives["state-"](e,o);else if(fullNamePlugin.has(o.name)){if(externalPlugin[o.name]){const t=externalPlugin[o.name];try{if("function"!=typeof t)return void console.warn(`${o.name} plugin must be a function`);await t(e,o,a,r)}catch(e){console.warn(e.message,e.stack)}}}else if(s){const t=c[o.name];if(externalPlugin[t]){const n=externalPlugin[t];try{if("function"!=typeof n)return void console.warn(`${t} plugin must be a function`);await n(e,o,a,r)}catch(e){console.warn(e.message,e.stack)}}}if("TEMPLATE"===e.tagName)return void await templates(e,r);if(e._componentName)return o?void await streamingComponent(e,r):void await component(e,r)}for(const t of renderBeforeChild)try{await t(e)}catch(e){console.error(e.message,e.stack)}if(!e._running){const t=Array.from(e.attributes).map((e=>`${e.name}="${e.value}"`)).join(" "),o=singleElement.has(e.tagName.toLowerCase());r(o?`<${e.tagName.toLowerCase()} ${t} />`:`<${e.tagName.toLowerCase()} ${t} >`);const n=e.childNodes;for(const t of n)3===t.nodeType?r(t.nodeValue):8===t.nodeType?r(`\x3c!--${t.nodeValue}--\x3e`):1===t.nodeType&&await render(t,e._context,r);o||r(`</${e.tagName.toLowerCase()}>`)}e._setError()};const directives={if:If,"for-each":For,"state-":State,switch:Switch,key:Key};export const startApp=async(e,t={},r=!1)=>{const o={context:t,stateContext:null,stream:!1};isDevelopment=r;const n=(new DOMParser).parseFromString(e,"text/html"),a=n.firstElementChild,s=n.createElement("div");s.appendChild(a?.cloneNode(!0));const c=e=>{};return await store.run(o,(async()=>{await render(s.firstElementChild,t,c)})),{element:s?.firstElementChild,toString:async()=>s?.firstElementChild?.outerHTML,head:n.head.innerHTML}};export const startStreamApp=async(e,t={},r,{templateStart:o,templateEnd:n})=>{const a={context:t,stateContext:null,useServer:!1,batch:[],stream:!0},s=(new DOMParser).parseFromString(e,"text/html"),c=s.firstElementChild,i=s.createElement("div");i.appendChild(c?.cloneNode(!0)),await store.run(a,(async()=>{r(o),r('<div id="app">'),await render(i.firstElementChild,t,r),r("</div>");store.getStore().batch;r("<script>\n        if (window?.__pawaDev && !window?.__pawaHasStarted) {\n        window?.__startClient()\n        window.__pawaHasStarted=true\n        __startClient=null\n      } <\/script>");let e=store.getStore().batch,n=0;for(;e.length>0&&n<10;){const t=[...e];store.getStore().batch=[],await Promise.allSettled(t.map((e=>resolvesAsync({...e},s,r)))),e=store.getStore().batch,n++}r("<script>\n            if (window?.__pawaDev && !window?.__pawaHasStarted && window?.__startClient !== null) {\n                window?.__startClient();\n                window.__pawaHasStarted = true;\n                __startClient = null;\n            } else {\n                window.__shouldStart = true;\n            }\n        <\/script>")}));const l=__pawaDev.errors,m=l?.length?`\n    <div pawa-avoid style="position:fixed; top:0; left:0; width:100vw; height:100vh; background-color:#1a1a1a; z-index:99999; overflow-y:auto; font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; padding:2rem; box-sizing:border-box;">\n      <h1 style="color:#ff6b6b; margin-top:0; border-bottom:1px solid #333; padding-bottom:1rem;">PawaJS Error Overlay</h1>\n      ${l.map(((e,t)=>`\n        <div style="background-color:#242424; border:1px solid #333; border-radius:0.5rem; padding:1.5rem; margin-bottom:1.5rem; box-shadow:0 4px 6px -1px rgba(0, 0, 0, 0.5);">\n          <div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:1rem;">\n            <h2 style="color:#e0e0e0; margin:0; font-size:1.25rem;">${e.directives||"Runtime Error"}</h2>\n            <span style="background-color:#333; color:#888; padding:0.25rem 0.5rem; border-radius:0.25rem; font-size:0.75rem;">Error #${t+1}</span>\n          </div>\n          \n          <div style="margin-bottom:1rem;">\n            <p style="color:#ff8787; margin:0; font-weight:bold;">${e.msg}</p>\n          </div>\n\n          ${e.template?`\n          <div style="margin-bottom:1rem;">\n            <h3 style="color:#888; font-size:0.875rem; text-transform:uppercase; margin:0 0 0.5rem 0;">Template Context</h3>\n            <pre style="background-color:#111; color:#a8a8a8; padding:1rem; border-radius:0.25rem; overflow-x:auto; margin:0; border:1px solid #333;"><code>${e.template.replace(/</g,"&lt;").replace(/>/g,"&gt;")}</code></pre>\n          </div>\n          `:""}\n\n          <div>\n            <h3 style="color:#888; font-size:0.875rem; text-transform:uppercase; margin:0 0 0.5rem 0;">Stack Trace</h3>\n            <pre style="background-color:#111; color:#888; padding:1rem; border-radius:0.25rem; overflow-x:auto; margin:0; border:1px solid #333; font-size:0.875rem; line-height:1.5;"><code>${e.stack.split("\n").map((e=>e.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/((?:[a-zA-Z]:\\|\/)[^:)]+):(\d+):(\d+)/g,((e,t,r,o)=>`<a href="/__open-in-editor?file=${encodeURIComponent(t+":"+r+":"+o)}" onclick="event.preventDefault(); fetch(this.href);" style="color:#64b5f6; text-decoration:underline; cursor:pointer;">${e}</a>`)))).join("\n")}</code></pre>\n          </div>\n        </div>\n      `)).join("")}\n    </div>\n    `:"";r(m),r(n),__pawaDev.errors=[]};const resolvesAsync=async({component:e,id:t,comment:{encodeJSON:r,name:o},appContext:n,context:a,restProps:s,hydrate:c},i,l,m)=>{let p="";const d=e=>{p+=e};d(`<div id="p${t}" hidden>`),store.getStore().stateContext=n;const f=await e.then((e=>e)),u=i.createElement("div");let g="";"boolean"!=typeof f&&f&&(u.innerHTML=f);const h=u.querySelector("[--]")||u.querySelector("[r-]");if(h){for(const[e,t]of Object.entries(s))h.setAttribute(t.name,t.value);h.removeAttribute("--"),h.removeAttribute("r-")}const w=u.firstElementChild;if(c.data=null,n.serializeData){for(const[e,t]of Object.entries(n.fromSerialized))"function"!=typeof t&&(n.serialize[e]=t);c.data=n.serialize}c.context=[];for(const[e]of Object.entries(n.insert))c.context.push(e);g=`component+${t}+${o}+${r(c)}`,w&&await render(w,{context:a,...n.insert},d),d("</div>"),d(`\n          <script class="p${t}">\n            const s${t}=()=>{\n              let p=document.querySelectorAll("#p${t}")\n              if(p.length < 2){\n                if(p[0]) p[0].remove()\n                document.querySelector('.p${t}').remove()\n                return\n              }\n            let c=p[0].previousSibling\n            c.data='${g}'\n            p[0].remove()\n            const sc=p[0]?._stateContext\n            let ec=c.nextSibling\n            let fc=p[1].firstElementChild\n            p[0].removeAttribute('pawa-avoid')\n            Array.from(p[0].attributes).forEach(a => {\n              if(a.name === 'p-async') return\n              if (a.name === 'p:c') {\n                let o=a.value + (fc.getAttribute('p:c') || '')\n                fc.setAttribute('p:c',o)\n              }else{\n                fc.setAttribute(a.name,a.value)\n                }\n            });\n            p[1].childNodes.forEach(e => {\n              c.parentElement.insertBefore(e,ec)\n            });\n            if (window?.__pawaDev) {\n              window.__pawaStream(fc,p[0]._context,sc)\n            }\n            p[1].remove()\n              }\n            s${t}()\n            document.querySelector('.p${t}').remove()\n          <\/script>\n          `),l(p)};function streamErrorFallback(e,t){t(`\n        <div hidden id="R${e}">\n            <div class="async-error">\n                <p>⚠️ Failed to load content</p>\n                <button onclick="location.reload()">Retry</button>\n            </div>\n        </div>\n        <script>\n            (function() {\n                try {\n                    var p = document.getElementById("p${e}");\n                    var r = document.getElementById("R${e}");\n                    if (p && r) {\n                        p.innerHTML = r.innerHTML;\n                        p.classList.add('error-state');\n                        r.remove();\n                    }\n                } catch (e) {\n                    console.error('Error handling fallback:', e);\n                }\n            })();\n        <\/script>\n    `)}
//# sourceMappingURL=/sm/d9e42f1c7e4073c28f6f33758d3dc049191bb06d9ee8bc5ecd491b5fe6a172b8.map