"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    default: ()=>ensureHMRForScripts
});
const external_schema_utils_namespaceObject = require("schema-utils");
const schema = {
    type: 'object',
    properties: {
        test: {
            type: 'string'
        },
        manifestPath: {
            type: 'string'
        },
        includeList: {
            type: 'object'
        }
    },
    additionalProperties: false
};
function ensureHMRForScripts(source) {
    const resourceQuery = String(this.resourceQuery || '');
    if (resourceQuery.includes('vue&type=')) return source;
    const options = this.getOptions();
    try {
        (0, external_schema_utils_namespaceObject.validate)(schema, options, {
            name: "html:ensure-hmr-for-scripts",
            baseDataPath: 'options'
        });
    } catch (error) {
        throw error;
    }
    const reloadCode = `
if (import.meta.webpackHot) {
  try {
    // Accept updates for HTML-attached scripts and clear common containers
    import.meta.webpackHot.accept();
    import.meta.webpackHot.dispose(function() {
      try {
        var clear = function(el) {
          if (!el) return;
          while (el.firstChild) el.removeChild(el.firstChild);
        };

        // Clear default template container
        clear(document.getElementById('app'));

        // Also clear any extension-root wrappers if present
        var roots = document.querySelectorAll('[data-extension-root]');
        roots.forEach(function(node) {
          clear(node);
        });
      } catch (err) {
        // 'err' is local in this catch, keep for error clarity
        console.error('Error clearing HTML containers', err);
      }
    });
  } catch (error) {
    console.error('Error accepting HMR', error);
  }
}
`;
    return `${reloadCode}${source}`;
}
exports["default"] = __webpack_exports__["default"];
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "default"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
