/**
 * Minified by jsDelivr using Terser v5.48.0.
 * Original file: /npm/pawa-ssr@1.4.2/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{pluginsMap,lazyComponents,components}from"pawajs/index.js";import{DOMParser,parseHTML,HTMLElement}from"linkedom";import PawaComponent from"./pawaComponent.js";import{propsValidator,evaluateExpr,extractAtExpressions,reArrangeAttri,resumeAttribute,pawaGenerateId,escapeHtml,splitAndAdd}from"./utils.js";import{AsyncLocalStorage}from"node:async_hooks";import{If,For,State,Switch,Key}from"./power.js";import PawaElement from"./pawaElement.js";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)}},forwardProps=(e={})=>{const t=store.getStore().stateContext;try{t&&(t.restProps=Object.entries(e).length>0?e:{bPAr:""})}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,forwardProps:forwardProps});export const pawaForServer=setServer;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","case","switch","s-default","for-key","key");export const getPawaAttributes=()=>pawaAttributes;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,restProps:{},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=pawaGenerateId(10),p=e=>Buffer.from(JSON.stringify(e)).toString("base64").replace(/\+/g,"-"),d=o.createComment(`component+${m}`),f=o.createComment(`end component+${m}+${e._componentName}`);e.replaceWith(f),f.parentElement.insertBefore(d,f);const u=e._component;s=u,s._name=e._componentName;let g=!0;Object.entries(e._component.validPropRule).length>0&&(g=propsValidator(e._component.validPropRule,{...e._props,...n},c.component._name,e.toString(),e)),c.component._prop={children:l,...e._props,...n};const h={children:l,...n,...e._props};for(const t of compoBeforeCall)try{await t(s,h)}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}-${m}`);let _="";try{g&&(store.getStore().stateContext=c,_=await u.component(h))}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);const w={children:l,props:{...e._hydrateProps},slots:{...i}};"boolean"!=typeof _&&"string"==typeof _&&(v.innerHTML=_);const b={};if(Object.entries(c.restProps).length>0){const t=e._restProps;c.restProps.className&&t.class&&(b.class={...t.class}),c.restProps.defaultValue&&t.default&&(b.default={...t.default});for(const e in t){let r=e;r=r.replace(/-([a-z])/g,e=>e[1].toUpperCase()),c.restProps[r]&&(b[e]={...t[e]})}}else Object.assign(b,e._restProps);(t=>{const r=t.firstElementChild;if(e._aschild){t.innerHTML=l;const e=t.firstElementChild;if(null===e)return;Array.from(r.attributes).forEach(t=>{if(e.hasAttribute(t.name)){let r=e.getAttribute(t.name);r=t.value+" "+r,e.setAttribute(t.name,r)}else e.setAttribute(t.name,t.value)})}})(v);const y=v.querySelector("[--]")||v.querySelector("[r-]");if(y){for(const[e,t]of Object.entries(b))y.setAttribute(t.name,t.value);y.removeAttribute("--"),y.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(w.data=null,c.serializeData){for(const[e,t]of Object.entries(c.fromSerialized))"function"!=typeof t&&(c.serialize[e]=t);w.data=c.serialize}w.context=[];for(const[e]of Object.entries(c.insert))w.context.push(e);d.data=`component+${m}+${e._componentName}+${p(w)}`,d.parentElement.insertBefore(x,f),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}-${m}`,m),await render(x,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:[],restProps:{},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=pawaGenerateId(10),p=e=>Buffer.from(JSON.stringify(e)).toString("base64").replace(/\+/g,"-"),d=o.createComment(`component+${m}`),f=o.createComment(`end component+${m}+${e._componentName}`);e.replaceWith(f),f.parentElement.insertBefore(d,f);const u=e._component;s=u,s._name=e._componentName;let g=!0;Object.entries(e._component.validPropRule).length>0&&(g=propsValidator(e._component.validPropRule,{...e._props,...n},c.component._name,e.toString(),e)),c.component._prop={children:l,...e._props,...n};const h={children:l,...n,...e._props};for(const t of compoBeforeCall)try{await t(s,h)}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}-${m}`);let _="",w=!1;try{g&&(store.getStore().stateContext=c,_=u.component(h),w=c.suspense&&c.useServer,_ instanceof Promise&&!w&&(_=await _.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);const b={children:l,props:{...e._hydrateProps},slots:{...i}},y={};if(Object.entries(c.restProps).length>0){const t=e._restProps;c.restProps.className&&t.class&&(y.class={...t.class}),c.restProps.defaultValue&&t.default&&(y.default={...t.default});for(const e in t){let r=e;r=r.replace(/-([a-z])/g,e=>e[1].toUpperCase()),c.restProps[r]&&(y[e]={...t[e]})}}else Object.assign(y,e._restProps);const x=t=>{const r=t.firstElementChild;if(e._aschild){t.innerHTML=l;const e=t.firstElementChild;if(null===e)return;Array.from(r.attributes).forEach(t=>{if(e.hasAttribute(t.name)){let r=e.getAttribute(t.name);r=t.value+" "+r,e.setAttribute(t.name,r)}else e.setAttribute(t.name,t.value)})}};w&&store.getStore().batch.push({component:_,id:m,comment:{hydrate:b,encodeJSON:p,name:e._componentName},appContext:c,context:{...e._context},restProps:y,hydrate:b,getAsChild:x}),w&&(_=`<div id="p${m}">${c.suspense}</div>`),"boolean"!=typeof _&&"string"==typeof _&&(v.innerHTML=_),x(v);const C=v.querySelector("[--]")||v.querySelector("[r-]");if(C){for(const[e,t]of Object.entries(y))C.setAttribute(t.name,t.value);C.removeAttribute("--"),C.removeAttribute("r-")}const A=v.firstElementChild;for(const t of compoAfterCall)try{await t(c,A,e)}catch(e){console.error(e.message,e.stack)}if(b.data=null,c.serializeData){for(const[e,t]of Object.entries(c.fromSerialized))"function"!=typeof t&&(c.serialize[e]=t);b.data=c.serialize}b.context=[];for(const[e]of Object.entries(c.insert))b.context.push(e);d.data=`component+${m}+${e._componentName}+${p(b)}`,t(`\x3c!--${d.data}--\x3e`),d.parentElement.insertBefore(A,f),w?(A.setAttribute("p:c",e.getAttribute("p:c")),A.setAttribute("p-async",e.getAttribute("p:c"))):A.setAttribute("p:c",e.getAttribute("p:c")),Array.from(e.attributes).forEach(e=>{e.name.startsWith("c-")&&A.setAttribute(e.name,e.value)}),A.setAttribute(`c-c-${e._componentName}-${m}`,m),await render(A,e._context,t),t(`\x3c!--${f.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.innerHTML.replace("-","(//)"),n=e.ownerDocument.createComment(`textEvaluator-${o}`);e.appendChild(n);const a=Array.from(e.childNodes).filter(e=>3===e.nodeType);a.forEach(e=>{t.set(e,e.nodeValue)});(()=>{try{a.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;if(e._componentName)return;const r=t.name.startsWith("@")?t.name.slice(1):t.name;e._replaceResumeAttr(t.name,`c-at-${r}`,t.value);const o=e.outerHTML,n=new Set;n.add("disabled");(()=>{try{let a=t.value;extractAtExpressions(a).forEach(({fullMatch:t,expression:n})=>{const s=e._evaluateExpr(n,e._context,`from text interpolation @{} - ${n} at ${o} attribute ${r}`);a=a.replace(t,String(s))}),n.has(r)?a?e.setAttribute(r,""):e.removeAttribute(r):e.setAttribute(r,a)}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","hr","input","meta","link","base","col","area","param","track","wbr");const partlyPawajsDirective=new Set;export const addToPartlyDirective=(...e)=>{e.forEach(e=>{partlyPawajsDirective.add(e)})};addToPartlyDirective("else","else-if","case","s-default");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(),void(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)}const i=!!e._componentName;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("@{")&&!o.name.startsWith("@")||i){if(o.name.startsWith("state-"))directives["state-"](e,o);else if(fullNamePlugin.has(o.name)&&!e._componentName){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]&&!e._componentName){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)}}}}else await attributeHandler(e,o);if("TEMPLATE"===e.tagName)return void await templates(e,r);if(e._componentName){if(e._lazy&&lazyComponents.has(splitAndAdd(e.tagName))&&!components.has(splitAndAdd(e.tagName)))try{const t=lazyComponents.get(splitAndAdd(e.tagName)),{name:r,component:o}=t,n=await o();n[r]&&(components.set(r.toUpperCase(),n[r]),e._component.component=n[r],e._component.validPropRule=n[r]?.validateProps||{},lazyComponents.delete(r.toUpperCase()))}catch(t){throw new Error(`lazy component ${e.tagName} : Error from the component - ${t.message}`,t.message)}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}="${escapeHtml(e.value)}"`).join(" "),o=t?` ${t}`:"",n=singleElement.has(e.tagName.toLowerCase()),a=e.tagName.toLowerCase();if(r(`<${a}${o}${n?" />":">"}`),!n){const t=e.childNodes;for(const o of t)3===o.nodeType?r(escapeHtml(o.nodeValue)):8===o.nodeType?r(`\x3c!--${o.nodeValue}--\x3e`):1===o.nodeType&&await render(o,e._context,r);r(`</${a}>`)}}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,getAsChild:i},l,m,p)=>{let d="";const f=e=>{d+=e};f(`<div id="res-${t}" hidden>`),store.getStore().stateContext=n;const u=await e.then(e=>e),g=l.createElement("div");let h="";"boolean"!=typeof u&&u&&(g.innerHTML=u),i(g);const v=g.querySelector("[--]")||g.querySelector("[r-]");if(v){for(const[e,t]of Object.entries(s))v.setAttribute(t.name,t.value);v.removeAttribute("--"),v.removeAttribute("r-")}const _=g.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);h=`component+${t}+${o}+${r(c)}`,_&&await render(_,{context:a,...n.insert},f),f("</div>"),f(`\n          <script class="p${t}">\n            const s${t}=()=>{\n              const placeholder = document.getElementById("p${t}");\n              const resolved = document.getElementById("res-${t}");\n              if(!placeholder || !resolved) return;\n              \n              const comment = placeholder.previousSibling;\n              if(comment && comment.nodeType === 8) comment.data = '${h}';\n              \n              const firstChild = resolved.firstElementChild;\n              Array.from(placeholder.attributes).forEach(a => {\n                if(a.name === 'p-async') return;\n                if (a.name === 'p:c') {\n                  firstChild.setAttribute('p:c', a.value + (firstChild.getAttribute('p:c') || ''));\n                } else {\n                  firstChild.setAttribute(a.name, a.value);\n                }\n              });\n\n              while(resolved.firstChild) placeholder.parentNode.insertBefore(resolved.firstChild, placeholder);\n              placeholder.remove();\n              resolved.remove();\n\n              if (window?.__pawaDev) {\n                window.__pawaStream(firstChild, {}, {});\n              }\n            }\n            s${t}()\n            document.querySelector('.p${t}').remove()\n          <\/script>\n          `),m(d)};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/520527bba5337892fb06975a94ce815bc09642e12d2c676357b736b08e5a863d.map