// @bun
var{defineProperty:x,getOwnPropertyNames:B,getOwnPropertyDescriptor:D}=Object,F=Object.prototype.hasOwnProperty;function G(f){return this[f]}var O=(f)=>{var j=(z??=new WeakMap).get(f),h;if(j)return j;if(j=x({},"__esModule",{value:!0}),f&&typeof f==="object"||typeof f==="function"){for(var k of B(f))if(!F.call(j,k))x(j,k,{get:G.bind(f,k),enumerable:!(h=D(f,k))||h.enumerable})}return z.set(f,j),j},z;var I=(f)=>f;function J(f,j){this[f]=I.bind(null,j)}var P=(f,j)=>{for(var h in j)x(f,h,{get:j[h],enumerable:!0,configurable:!0,set:J.bind(j,h)})};var Q=(f,j)=>()=>(f&&(j=f(f=0)),j);var U=import.meta.require;function W(f,j,h){let k=K(f,j);return{type:f,message:j,suggestions:k,...h}}function K(f,j){let h=[];switch(f){case"parse_error":h.push("Check for syntax errors in your .story.stx file"),h.push("Ensure all tags are properly closed"),h.push("Verify that <Story> and <Variant> components are used correctly");break;case"component_error":h.push("Check that the component file exists"),h.push("Verify the import path is correct"),h.push("Ensure all required props are provided");break;case"render_error":h.push("Check the browser console for more details"),h.push("Verify that all dependencies are available"),h.push("Try simplifying the component to isolate the issue");break;case"config_error":h.push("Check your stx.config.ts file for syntax errors"),h.push("Verify that all required config options are set"),h.push("Try using the default configuration");break;case"file_not_found":h.push("Check that the file path is correct"),h.push("Verify the file exists in the specified location"),h.push("Check for case sensitivity in the file path");break;case"circular_dependency":h.push("Review your component imports for circular references"),h.push("Consider restructuring your components"),h.push("Use lazy loading for problematic dependencies");break;case"prop_type_error":if(h.push("Check that the prop value matches the expected type"),h.push("Review the component's prop definitions"),j.includes("required"))h.push("Ensure all required props are provided");break;default:h.push("Check the console for more details"),h.push("Try restarting the story server"),h.push("Report this issue if it persists")}return h}function X(f){let j=[];if(j.push(`\u274C ${A(f.type)}`),j.push(""),j.push(f.message),j.push(""),f.file){let h=`\uD83D\uDCC1 ${f.file}`;if(f.line){if(h+=`:${f.line}`,f.column)h+=`:${f.column}`}j.push(h),j.push("")}if(f.suggestions&&f.suggestions.length>0){j.push("\uD83D\uDCA1 Suggestions:");for(let h of f.suggestions)j.push(`   \u2022 ${h}`);j.push("")}return j.join(`
`)}function A(f){return{parse_error:"Parse Error",component_error:"Component Error",render_error:"Render Error",config_error:"Configuration Error",file_not_found:"File Not Found",circular_dependency:"Circular Dependency",prop_type_error:"Prop Type Error",unknown:"Unknown Error"}[f]}function Y(f){let j=f.suggestions?f.suggestions.map((h)=>`<li>${q(h)}</li>`).join(""):"";return`
    <div class="stx-error">
      <div class="stx-error-header">
        <span class="stx-error-icon">\u274C</span>
        <span class="stx-error-title">${A(f.type)}</span>
      </div>
      <div class="stx-error-message">${q(f.message)}</div>
      ${f.file?`
        <div class="stx-error-location">
          \uD83D\uDCC1 ${q(f.file)}${f.line?`:${f.line}`:""}${f.column?`:${f.column}`:""}
        </div>
      `:""}
      ${j?`
        <div class="stx-error-suggestions">
          <div class="stx-error-suggestions-title">\uD83D\uDCA1 Suggestions:</div>
          <ul>${j}</ul>
        </div>
      `:""}
      <div class="stx-error-actions">
        <button onclick="window.__stxStory.dismissError()">Dismiss</button>
        <button onclick="window.__stxStory.retryRender()">Retry</button>
      </div>
    </div>
  `}function Z(){return`
    .stx-error {
      background: #fef2f2;
      border: 1px solid #fecaca;
      border-radius: 8px;
      padding: 16px;
      margin: 16px;
      font-family: var(--font-family);
    }
    .dark .stx-error {
      background: #450a0a;
      border-color: #7f1d1d;
    }
    .stx-error-header {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 12px;
    }
    .stx-error-icon {
      font-size: 20px;
    }
    .stx-error-title {
      font-weight: 600;
      font-size: 16px;
      color: #dc2626;
    }
    .dark .stx-error-title {
      color: #f87171;
    }
    .stx-error-message {
      color: #991b1b;
      margin-bottom: 12px;
      font-family: var(--code-font-family);
      font-size: 13px;
      white-space: pre-wrap;
    }
    .dark .stx-error-message {
      color: #fca5a5;
    }
    .stx-error-location {
      color: #6b7280;
      font-size: 12px;
      margin-bottom: 12px;
    }
    .stx-error-suggestions {
      margin-bottom: 12px;
    }
    .stx-error-suggestions-title {
      font-weight: 500;
      margin-bottom: 8px;
      color: #374151;
    }
    .dark .stx-error-suggestions-title {
      color: #d1d5db;
    }
    .stx-error-suggestions ul {
      margin: 0;
      padding-left: 20px;
      color: #4b5563;
      font-size: 13px;
    }
    .dark .stx-error-suggestions ul {
      color: #9ca3af;
    }
    .stx-error-suggestions li {
      margin-bottom: 4px;
    }
    .stx-error-actions {
      display: flex;
      gap: 8px;
      margin-top: 16px;
    }
    .stx-error-actions button {
      padding: 8px 16px;
      border: 1px solid #d1d5db;
      border-radius: 4px;
      background: white;
      color: #374151;
      cursor: pointer;
      font-size: 13px;
    }
    .stx-error-actions button:hover {
      background: #f3f4f6;
    }
    .dark .stx-error-actions button {
      background: #374151;
      border-color: #4b5563;
      color: #f3f4f6;
    }
    .dark .stx-error-actions button:hover {
      background: #4b5563;
    }
  `}function _(f,j){return`
    <div class="stx-error-boundary" data-component="${q(j)}">
      ${f}
    </div>
    <script>
      (function() {
        const boundary = document.currentScript.previousElementSibling;
        window.addEventListener('error', function(e) {
          if (boundary.contains(e.target)) {
            boundary.innerHTML = window.__stxStory.renderError({
              type: 'render_error',
              message: e.message,
              file: '${q(j)}'
            });
          }
        });
      })();
    </script>
  `}function q(f){return f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}export{Z as getErrorStyles,Y as generateErrorHTML,X as formatStoryError,W as createStoryError,_ as createErrorBoundary};
