web-component-wrapper 0.0.601 → 0.0.604

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/test.js CHANGED
@@ -1 +1,961 @@
1
- "use strict";if("undefined"!=typeof module&&null!==module&&"undefined"!==eval("typeof require")&&null!==eval("require")&&"main"in eval("require")&&"undefined"!==eval("typeof require.main")&&null!==eval("require.main")){var ORIGINAL_MAIN_MODULE=module;module!==eval("require.main")&&"paths"in module&&"paths"in eval("require.main")&&"undefined"!=typeof __dirname&&null!==__dirname&&(module.paths=eval("require.main.paths").concat(module.paths.filter((function(path){return eval("require.main.paths").includes(path)}))))}if(null==window)var window="undefined"==typeof global||null===global?{}:global;!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("clientnode"),require("clientnode/property-types"),require("react"),require("@jest/globals"),require("react-dom"),require("react-dom/client"),require("@babel/runtime/helpers/initializerDefineProperty"),require("@babel/runtime/helpers/applyDecoratedDescriptor"),require("@babel/runtime/helpers/initializerWarningHelper"));else if("function"==typeof define&&define.amd)define(["clientnode","clientnode/property-types","react","@jest/globals","react-dom","react-dom/client","@babel/runtime/helpers/initializerDefineProperty","@babel/runtime/helpers/applyDecoratedDescriptor","@babel/runtime/helpers/initializerWarningHelper"],t);else{var r="object"==typeof exports?t(require("clientnode"),require("clientnode/property-types"),require("react"),require("@jest/globals"),require("react-dom"),require("react-dom/client"),require("@babel/runtime/helpers/initializerDefineProperty"),require("@babel/runtime/helpers/applyDecoratedDescriptor"),require("@babel/runtime/helpers/initializerWarningHelper")):t(e.clientnode,e["clientnode/property-types"],e.react,e["@jest/globals"],e["react-dom"],e["react-dom/client"],e["@babel/runtime/helpers/initializerDefineProperty"],e["@babel/runtime/helpers/applyDecoratedDescriptor"],e["@babel/runtime/helpers/initializerWarningHelper"]);for(var s in r)("object"==typeof exports?exports:e)[s]=r[s]}}(this,((e,t,r,s,n,o,i,a,p)=>(()=>{var l=[t=>{t.exports=e},e=>{e.exports=t},(e,t,r)=>{r.d(t,{default:()=>o});var s=r(0),n=r(1);const o=function(e={}){return e={readAttribute:!0,type:n.string,...e},function(t,r){if("string"!=typeof r)return;const n=t.self||t.constructor;if(e.readAttribute){Object.prototype.hasOwnProperty.call(n,"observedAttributes")||(n.observedAttributes=n.observedAttributes?[...n.observedAttributes]:[]);const e=(0,s.camelCaseToDelimited)(r);n.observedAttributes&&!n.observedAttributes.includes(e)&&n.observedAttributes.push(e)}if(e.type&&(Object.prototype.hasOwnProperty.call(n,"propertyTypes")||(n.propertyTypes=n.propertyTypes?{...n.propertyTypes}:{}),!n.propertyTypes||!e.update&&Object.prototype.hasOwnProperty.call(n,r)||(n.propertyTypes[r]=e.type)),e.writeAttribute&&(Object.prototype.hasOwnProperty.call(n,"propertiesToReflectAsAttributes")||(n.propertiesToReflectAsAttributes=n.propertiesToReflectAsAttributes?(0,s.copy)(n.propertiesToReflectAsAttributes):[]),e.update||n.propertiesToReflectAsAttributes instanceof Map&&!n.propertiesToReflectAsAttributes.has(r)||Array.isArray(n.propertiesToReflectAsAttributes)&&!n.propertiesToReflectAsAttributes.includes(r)||"object"==typeof n.propertiesToReflectAsAttributes&&!Object.prototype.hasOwnProperty.call(n.propertiesToReflectAsAttributes,r))){let t;"boolean"==typeof e.writeAttribute?e.writeAttribute&&n.propertyTypes&&Object.prototype.hasOwnProperty.call(n.propertyTypes,r)&&(t=n.propertyTypes[r]):t=e.writeAttribute,void 0!==t&&(Array.isArray(n.propertiesToReflectAsAttributes)&&(!0===e.writeAttribute?n.propertiesToReflectAsAttributes.push(r):n.normalizePropertyTypeList&&(n.propertiesToReflectAsAttributes=n.normalizePropertyTypeList(n.propertiesToReflectAsAttributes))),n.propertiesToReflectAsAttributes instanceof Map&&n.propertiesToReflectAsAttributes.set(r,t),"object"==typeof n.propertiesToReflectAsAttributes&&(n.propertiesToReflectAsAttributes[r]=t))}e.alias&&(Object.prototype.hasOwnProperty.call(n,"propertyAliases")||(n.propertyAliases=n.propertyAliases?{...n.propertyAliases}:{}),!n.propertyAliases||!e.update&&Object.prototype.hasOwnProperty.call(n,r)||(n.propertyAliases[r]=e.alias))}}},(e,t,r)=>{r.d(t,{default:()=>b});var s,n,o,i,a=r(4),p=r.n(a),l=r(5),c=r.n(l),d=(r(6),r(0)),h=r(1),u=r(2);const f=new d.Logger({name:"web-component-wrapper-web"}),m="undefined"==typeof HTMLElement?class{}:HTMLElement;let y=(s=(0,u.default)({type:h.boolean,writeAttribute:!0}),i=class e extends m{constructor(){super(),this.renderState={promise:Promise.resolve(""),pending:!1,resolve:d.NOOP},this.childComponentInstances=[],this.batchAttributeUpdates=!0,this.batchPropertyUpdates=!0,this.batchUpdates=!0,this.batchedAttributeUpdateRunning=!0,this.batchedPropertyUpdateRunning=!0,this.batchedUpdateRunning=!0,this.connectionRegistered=!1,this.pendingAttributeUpdates=[],this.parentInstance=null,this.rootInstance=void 0,this.hostDomNode=void 0,this.scope={...d.UTILITY_SCOPE},this.domNodeEventBindings=new Map,this.domNodeTemplateCache=new Map,this.externalProperties={},this.ignoreAttributeUpdateObservations=!1,this.internalProperties={},this.outputEventNames=new Set,this.instance=null,p()(this,"isRoot",o,this),this.runDomConnectionAndRenderingInSameEventQueue=!1,this.self=e,this.slots={},this.prepareNewRenderingPromise(),this.self=this.constructor,this.self._propertiesToReflectAsAttributes||(this.self._propertiesToReflectAsAttributes=this.self.normalizePropertyTypeList(this.self.propertiesToReflectAsAttributes)),this.generateAliasIndex(),this.hostDomNode=this,this.rootInstance=this,this.defineGetterAndSetterInterface()}attributeChangedCallback(e,t,r){this.ignoreAttributeUpdateObservations||t===r||this.onUpdateAttribute(e,r)}onUpdateAttribute(e,t){const r=new Promise((r=>this.pendingAttributeUpdates.push((()=>{this.evaluateStringOrNullAndSetAsProperty(e,t),this.batchAttributeUpdates?this.batchedAttributeUpdateRunning||this.batchedUpdateRunning||(this.batchedAttributeUpdateRunning=!0,this.batchedUpdateRunning=!0,(0,d.timeout)((()=>{this.batchedAttributeUpdateRunning=!1,this.batchedUpdateRunning=!1,this.render("attributeChanged")}))):this.render("attributeChanged"),r()}))));if(this.connectionRegistered)for(;this.pendingAttributeUpdates.length;)this.pendingAttributeUpdates.shift()();return r}connectedCallback(){try{this.isConnected=!0}catch{}for(this.connectionRegistered=!0,this.parentInstance=this,this.rootInstance=this,this.attachEventHandler(),this.self.determineRootBinding&&(this.determineRootBinding(),this.parentInstance!==this&&this.parentInstance.childComponentInstances&&this.parentInstance.childComponentInstances.push(this)),this.self.applyRootBinding&&this.isRoot&&(this.determineRenderScope(),this.applyBinding(this,this.scope));this.pendingAttributeUpdates.length;)this.pendingAttributeUpdates.shift()();this.batchedAttributeUpdateRunning=!1,this.batchedPropertyUpdateRunning=!1,this.batchedUpdateRunning=!1,this.grabGivenSlots(),this.reflectExternalProperties(this.externalProperties),this.runDomConnectionAndRenderingInSameEventQueue?this.render("connected"):(0,d.timeout)((()=>{this.render("connected")}))}disconnectedCallback(){this.unRender("disconnected"),this.unregisterConnectionState()}defineGetterAndSetterInterface(){const e=(0,d.unique)(Object.keys(this.self.propertyTypes).concat(this.self._propertyAliasIndex?Object.keys(this.self._propertyAliasIndex):[]));for(const t of e)Object.prototype.hasOwnProperty.call(this,t)&&this.setPropertyValue(t,this[t]),Object.defineProperty(this,t,{configurable:!0,get:()=>this.getPropertyValue(t),set:e=>{this.setPropertyValue(t,e),this.triggerPropertySpecificRendering(t,e)}})}getPropertyAlias(e){return this.self._propertyAliasIndex&&Object.prototype.hasOwnProperty.call(this.self._propertyAliasIndex,e)?this.self._propertyAliasIndex[e]:null}getPropertyValue(t){var r;const s=this.instance?.current?.properties&&(Object.prototype.hasOwnProperty.call(!e.propertyTypes,t)||Object.prototype.hasOwnProperty.call(this.instance.current.properties,t))?this.instance.current.properties[t]:null!==(r=this.internalProperties[t])&&void 0!==r?r:this.externalProperties[t];return this.instance?.current?.state&&Object.prototype.hasOwnProperty.call(this.instance.current.state,t)?this.instance.current.state[t]:s}setExternalPropertyValue(e,t){this.externalProperties[e]=t;const r=this.getPropertyAlias(e);r&&(this.externalProperties[r]=t)}setInternalPropertyValue(e,t){this.internalProperties[e]=t;const r=this.getPropertyAlias(e);r&&(this.internalProperties[r]=t)}setPropertyValue(e,t){this.reflectProperties({[e]:t}),this.setInternalPropertyValue(e,t)}triggerPropertySpecificRendering(e,t){if(this.batchPropertyUpdates)this.batchedPropertyUpdateRunning||this.batchedUpdateRunning||(this.batchedPropertyUpdateRunning=!0,this.batchedUpdateRunning=!0,(0,d.timeout)((()=>{void 0!==t&&this.isStateProperty(e)?(this.render("preStatePropertyChanged"),(0,d.timeout)((()=>{this.setInternalPropertyValue(e,void 0),this.batchedPropertyUpdateRunning=!1,this.batchedUpdateRunning=!1,this.render("postStatePropertyChanged"),this.triggerOutputEvents()}))):(this.batchedPropertyUpdateRunning=!1,this.batchedUpdateRunning=!1,this.render("propertyChanged"),this.triggerOutputEvents())})));else{const r=this.isStateProperty(e);this.render(r?"preStatePropertyChanged":"propertyChanged"),void 0!==t&&r&&(this.setInternalPropertyValue(e,void 0),this.render("postStatePropertyChanged")),this.triggerOutputEvents()}}unregisterConnectionState(){try{this.isConnected=!1}catch{}this.connectionRegistered=!1,this.slots={}}unregisterDomNodeEventBindings(){for(const e of this.domNodeEventBindings.values())for(const t of e.values())t()}applyBinding(e,t){if(e.getAttributeNames)for(const r of e.getAttributeNames()){let s;if(r.startsWith("data-bind-")?s=r.substring(10):r.startsWith("bind-")&&(s=r.substring(5)),s){const n=e.getAttribute(r);if(null===n)continue;if(s.startsWith("attribute-")||s.startsWith("property-")){const o=(0,d.evaluate)(n,t,!1,!0,e);if(o.error){f.warn("Error occurred during processing given",`attribute binding "${r}" on node:`,e,o.error);continue}s.startsWith("attribute-")?e.setAttribute(s.substring(10),o.result):e[(0,d.delimitedToCamelCase)(s.substring(9))]=o.result}else if(s.startsWith("on-")){s=(0,d.delimitedToCamelCase)(s.substring(3)),t={log:f,event:void 0,parameters:void 0,...t};const o=(0,d.compile)(n,t,!0,!0,e);o.error?f.warn("Error occurred during compiling given event",`binding "${r}" on node:`,e,o.error):this.addSecureEventListener(e,s,((...s)=>{t.event=s[0],t.parameters=s;try{o.templateFunction(...o.originalScopeNames.map((e=>t[e])))}catch(t){f.warn("Error occurred during processing","given event binding",`"${r}" on node:`,e,`Given expression "${n}" could`,"not be evaluated with given scope",'names "'+o.scopeNames.join('", "')+`": ${(0,d.represent)(t)}`)}}))}}}}applyBindings(e,t,r=!0){for(;e;)!e.attributes?.length||!r&&e.getAttribute("slot")||this.applyBinding(e,t),e.nodeName.toLowerCase().includes("-")||this.applyBindings(e.firstChild,t),e=e.nextSibling}compileDomNodeTemplate(e,t=[],r={}){r={ignoreComponents:!0,ignoreNestedComponents:!0,unsafe:this.self.renderUnsafe,...r};const s=e.nodeName.toLowerCase();if(r.ignoreComponents&&s.includes("-"))return null;if(r.unsafe){let r=e.innerHTML;if(!r&&e.template&&(r=e.template),this.self.hasCode(r)){const s=(0,d.compile)(`\`${r}\``,t);return{domNode:e,children:[],error:s.error,scopeNames:s.scopeNames,template:r,templateFunction:s.templateFunction}}return null}let n=null;if("#text"===s){const t=e.textContent;t&&this.self.hasCode(t)&&(n=t.replace(/&nbsp;/g," ").trim())}const o=[],i={children:o,domNode:e};if(n){const e=(0,d.compile)(`\`${n}\``,t);i.error=e.error,i.scopeNames=e.scopeNames,i.template=n,i.templateFunction=e.templateFunction}let a=e.firstChild;for(;a;){if(!r.filter||r.filter(a)){const e=this.compileDomNodeTemplate(a,t,{...r,ignoreComponents:r.ignoreNestedComponents});e&&o.push(e)}a=a.nextSibling}return i}evaluateCompiledDomNodeTemplate(e,t){const{domNode:r,error:s,templateFunction:n,scopeNames:o}=e;if(!n||!o)return null;if(s)return f.warn("Error occurred during compiling node content:",s),null;let i=null;try{i=n(...o.map((e=>t[e])))}catch(s){f.warn(`Error occurred when "${this.self._name}" is running`,`"${String(n)}": with bound`,`names "${o.join('", "')}":`,`"${s}". Rendering node:`,r)}return i}evaluateDomNodeTemplate(e,t={},r={}){const s=(r={domNodeTemplateCache:this.domNodeTemplateCache,ignoreComponents:!0,ignoreNestedComponents:!0,unsafe:this.self.renderUnsafe,...r}).domNodeTemplateCache;if(!s.has(e)){const n={filter:r.filter,ignoreComponents:r.ignoreComponents,ignoreNestedComponents:r.ignoreNestedComponents,unsafe:r.unsafe},o=this.compileDomNodeTemplate(e,t,n);o&&s.set(e,o)}if(s.has(e)){const n=s.get(e),o=this.evaluateCompiledDomNodeTemplate(n,t);if(null!==o&&(r.unsafe&&e.innerHTML?e.innerHTML=o:e.textContent=o),n.children.length){const e=r=>{for(const s of r){const r=this.evaluateCompiledDomNodeTemplate(s,t);null!==r&&(s.domNode.textContent=r),s.children.length&&e(s.children)}};e(n.children)}}r.applyBindings&&this.applyBindings(e,t)}addSecureEventListener(e,t,r,s,n){this.domNodeEventBindings.has(e)||this.domNodeEventBindings.set(e,new Map);const o=this.domNodeEventBindings.get(e),i=o.get(t);i&&i!==r&&i();const a=()=>{e.removeEventListener(t,r,n),o.delete(t),0===o.size&&this.domNodeEventBindings.delete(e)};return o.set(t,a),e.addEventListener(t,r,s),a}determineRootBinding(){let t=this.parentNode;for(;t;){const r=t instanceof e||t.nodeName.includes("-")&&"#document-fragment"!==t.nodeName,s=null===t.parentNode&&"[object ShadowRoot]"===t.toString();r?(this.rootInstance===this&&(this.parentInstance=t,this.setPropertyValue("isRoot",!1)),this.rootInstance=t):s&&this.setPropertyValue("isRoot",!1),t=t.parentNode}}static hasCode(e){return"string"==typeof e&&e.includes("${")&&e.includes("}")&&/\${[\s\S]+}/.test(e)}static normalizePropertyTypeList(t){if("string"==typeof t&&(t=[t]),Array.isArray(t)){const r=t,s=new Map;for(const t of r)Object.prototype.hasOwnProperty.call(e.propertyTypes,t)&&s.set(t,e.propertyTypes[t]);return s}return(0,d.convertPlainObjectToMap)(t)}attachEventHandler(){if(null===this.self.eventToPropertyMapping)return;const e=this.attachExplicitDefinedOutputEventHandler();this.attachImplicitDefinedOutputEventHandler(!e)}attachExplicitDefinedOutputEventHandler(){if(!this.self.eventToPropertyMapping)return!1;let e=!1;for(const t of Object.keys(this.self.eventToPropertyMapping))Object.prototype.hasOwnProperty.call(this.internalProperties,t)||(e=!0,this.outputEventNames.add(t),this.setInternalPropertyValue(t,(async(...e)=>{const r=await this.reflectEventToProperties(t,e);r&&(e[0]=r),this.forwardEvent(t,e)})));return e}attachImplicitDefinedOutputEventHandler(e=!0){for(const[t,r]of Object.entries(this.self.propertyTypes))Object.prototype.hasOwnProperty.call(this.internalProperties,t)||![h.func,"function"].includes(r)||this.self.renderProperties.includes(t)||(this.outputEventNames.add(t),this.setInternalPropertyValue(t,((...r)=>{e&&this.reflectEventToProperties(t,r),this.forwardEvent(t,r)})))}triggerOutputEvents(){for(const e of this.outputEventNames)this.forwardEvent(e,[this.externalProperties])}forwardEvent(e,t){return e.length>3&&e.startsWith("on")&&(e=(0,d.lowerCase)(e.substring(2))),this.dispatchEvent(new CustomEvent(e,{detail:{parameters:t}}))}applySlots(t,r){for(const s of Array.from(t.querySelectorAll("slot"))){const t=s.getAttribute("name");if(null===t||"default"===t)if(this.slots.default){if(this.self.renderSlots){if(this.self.evaluateSlots)for(const e of this.slots.default)this.evaluateDomNodeTemplate(e,r);(0,d.replace)(s,this.slots.default,e.trimSlots)}}else this.slots.default=(0,d.unwrap)(s).map((e=>this.grabSlotContent(e)));else this.slots[t]?this.self.renderSlots&&(this.self.evaluateSlots&&this.evaluateDomNodeTemplate(this.slots[t],r),(0,d.replace)(s,this.slots[t],e.trimSlots)):this.slots[t]=this.grabSlotContent((0,d.unwrap)(s).filter((e=>"#text"!==e.nodeName.toLowerCase()))[0])}}grabSlotContent(e){const t=h.node.firstElementChild?e:null;if(t&&"textarea"===t.firstElementChild?.nodeName.toLowerCase()&&(!t.firstElementChild.hasAttribute("data-no-template")||"false"===t.firstElementChild.getAttribute("data-no-template"))){const e=t.firstElementChild.value;t.classList.remove("web-component-template");const r=t.cloneNode();return t.classList.add("web-component-template"),r.innerHTML="",r.template=e,r}return this.self.cloneSlots?e.cloneNode(!0):e}grabGivenSlots(){this.slots={};for(const e of Array.from(this.querySelectorAll("[slot]"))){let t=e.parentNode,r=!0;for(;t;){if(t.nodeName.includes("-")){t===this&&(r=!1);break}t=t.parentNode}if(r)continue;const s=e.getAttribute("slot")?.trim();this.slots[null!=s?s:e.nodeName.toLowerCase()]=this.grabSlotContent(e)}this.slots.default?this.slots.default=[].concat(this.slots.default):this.childNodes.length>0?this.slots.default=Array.from(this.childNodes).map((e=>this.grabSlotContent(e))):this.slots.default=[]}isStateProperty(e){return Boolean(this.instance?.current?.state&&(Object.prototype.hasOwnProperty.call(this.instance.current.state,e)||this.instance.current.state.modelState&&Object.prototype.hasOwnProperty.call(this.instance.current.state.modelState,e)))}generateAliasIndex(){if(!this.self._propertyAliasIndex){this.self._propertyAliasIndex={...this.self.propertyAliases};for(const[e,t]of Object.entries(this.self._propertyAliasIndex))Object.prototype.hasOwnProperty.call(this.self._propertyAliasIndex,t)||(this.self._propertyAliasIndex[t]=e)}}reflectExternalProperties(e){this.ignoreAttributeUpdateObservations=!0;for(const[t,r]of Object.entries(e)){if(this.setExternalPropertyValue(t,r),!this.isConnected)continue;const e=(0,d.camelCaseToDelimited)(t);if(this.self._propertiesToReflectAsAttributes?.has(t))switch(this.self._propertiesToReflectAsAttributes.get(t)){case h.boolean:case"boolean":r?""!==this.getAttribute(e)&&this.setAttribute(e,""):this.hasAttribute(e)&&this.removeAttribute(e);break;case h.func:case"function":break;case"json":if(r){const t=JSON.stringify(r);if(t&&this.getAttribute(e)!==t){this.setAttribute(e,t);break}}this.hasAttribute(e)&&this.removeAttribute(e);break;case h.number:case"number":if("number"!=typeof r||isNaN(r))this.hasAttribute(e)&&this.removeAttribute(e);else{const t=String(r);this.getAttribute(e)!==t&&this.setAttribute(e,t)}break;case h.string:case"string":r?this.getAttribute(e)!==r&&this.setAttribute(e,r):this.hasAttribute(e)&&this.removeAttribute(e);break;case h.any:case h.array:case h.arrayOf:case h.element:case h.elementType:case h.instanceOf:case h.node:case h.object:case"object":case h.objectOf:case h.shape:case h.exact:case h.symbol:default:if(r){const t=(0,d.represent)(r);if(t&&this.getAttribute(e)!==t){this.setAttribute(e,t);break}}this.hasAttribute(e)&&this.removeAttribute(e)}}this.ignoreAttributeUpdateObservations=!1}reflectProperties(e){if(this.reflectExternalProperties(e),this.instance?.current?.state&&"object"==typeof this.instance.current.state)for(const e of Object.keys(this.instance.current.state).concat(this.instance.current.state.modelState?Object.keys(this.instance.current.state.modelState):[]))Object.prototype.hasOwnProperty.call(this.internalProperties,e)&&this.setInternalPropertyValue(e,void 0);this.internalProperties.model?.state&&(delete this.internalProperties.model.state,this.setInternalPropertyValue("model",this.internalProperties.model));for(const t of this.self.controllableProperties)Object.prototype.hasOwnProperty.call(e,t)&&this.setInternalPropertyValue(t,e[t])}async reflectEventToProperties(e,t){const r=this.batchUpdates;this.batchUpdates=!1;let s=null,n=!1;if(this.self.eventToPropertyMapping&&Object.prototype.hasOwnProperty.call(this.self.eventToPropertyMapping,e)&&(0,d.isFunction)(this.self.eventToPropertyMapping[e])){const r=this.self.eventToPropertyMapping[e](...t,this),o=r&&"then"in r&&(0,d.isFunction)(r.then)?await r:r;n=!0,Array.isArray(o)?(s=o[0],this.reflectProperties(s),(0,d.extend)(!0,this.internalProperties,o[1])):null===o?n=!1:"object"==typeof o&&(s=o,this.reflectProperties(o))}if(!n&&t.length>0&&(0,d.isObject)(t[0])){let e=t[0];if("persist"in t[0]&&(0,d.isFunction)(t[0].persist)){e={};for(const r of Object.keys(this.self.propertyTypes))for(const s of[r].concat(null!==(o=this.getPropertyAlias(r))&&void 0!==o?o:[])){var o;const r=t[0].currentTarget&&Object.prototype.hasOwnProperty.call(t[0].currentTarget,s)?t[0].currentTarget[s]:this.getPropertyValue(s);r!==this.externalProperties[s]&&(e[s]=r)}}else[null,void 0].includes(e.detail?.value)||(e={...e.detail});s=e,this.reflectProperties(e)}return this.triggerRender("propertyReflected"),this.batchUpdates=r,s}evaluateStringOrNullAndSetAsProperty(e,t){const r=e.startsWith("-"),s=r?e.substring(1):e;let n=(0,d.delimitedToCamelCase)(s);const o=this.getPropertyAlias(n);if(o&&Object.prototype.hasOwnProperty.call(this.self.propertyTypes,o)&&(n=o),Object.prototype.hasOwnProperty.call(this.self.propertyTypes,n)){const s=this.self.propertyTypes[n];if(r){if(t){const r=(0,d.evaluate)(t,{...d.UTILITY_SCOPE},!1,!0,this);r.error?(f.warn("Failed to process pre-evaluation attribute",`"${e}": ${r.error}. Will be`,'set to "undefined".'),this.setInternalPropertyValue(n,void 0)):(this.setInternalPropertyValue(n,r.result),this.setExternalPropertyValue(n,r.result))}}else switch(s){case h.boolean:case"boolean":{const e=![null,"false"].includes(t);this.setInternalPropertyValue(n,e),this.setExternalPropertyValue(n,e);break}case h.func:case"function":{let r,s=null;const o=["data","event","firstArgument","firstParameter","options"];if(t){const n=(0,d.compile)(t,o.concat("parameters","scope",d.UTILITY_SCOPE_NAMES),!0,!0,this);s=n.error,r=n.templateFunction,s&&f.warn("Failed to compile given handler",`"${e}": ${s}.`)}this.setInternalPropertyValue(n,((...i)=>{let a;if(this.outputEventNames.has(n)&&this.reflectEventToProperties(n,i),!s){const s={parameters:i,...d.UTILITY_SCOPE};for(const e of o)s[e]=i[0];try{a=r?.(...o.map((e=>s[e])),i,s,...d.UTILITY_SCOPE_NAMES.map((e=>d.UTILITY_SCOPE[e])))}catch(r){f.warn("Failed to evaluate function",`"${e}" with expression`,`"${t}" and scope`,"variables",`"${o.join('", "')}" set to`,`"${(0,d.represent)(i)}":`,`${r}. Set property`,'to "undefined".')}}return this.self.renderProperties.includes(n)||this.forwardEvent(n,i),a})),s||this.setExternalPropertyValue(n,r);break}case"json":if(t){let r;try{r=JSON.parse(t)}catch(t){f.warn("Error occurred during parsing given json",`attribute "${e}":`,(0,d.represent)(t));break}this.setInternalPropertyValue(n,r),this.setExternalPropertyValue(n,(0,d.copy)(r,!1,1))}else this.setInternalPropertyValue(n,null),this.setExternalPropertyValue(n,null);break;case h.number:case"number":{if(null===t){this.setInternalPropertyValue(n,t),this.setExternalPropertyValue(n,t);break}let e=parseFloat(t);isNaN(e)&&(e=void 0),this.setInternalPropertyValue(n,e),this.setExternalPropertyValue(n,e);break}case h.string:case"string":this.setInternalPropertyValue(n,t),this.setExternalPropertyValue(n,t);break;case h.any:case h.array:case h.arrayOf:case h.element:case h.elementType:case h.instanceOf:case h.node:case h.object:case"object":case h.objectOf:case h.oneOf:case h.oneOfType:case h.shape:case h.exact:case h.symbol:default:if(t){const r=(0,d.evaluate)(t,{},!1,!0,this);if(r.error){f.warn("Error occurred during processing given",`attribute configuration "${e}":`,r.error);break}this.setInternalPropertyValue(n,r.result),this.setExternalPropertyValue(n,(0,d.copy)(r.result,!1,1))}else this.hasAttribute(e)?(this.setInternalPropertyValue(n,!0),this.setExternalPropertyValue(n,!0)):(this.setInternalPropertyValue(n,null),this.setExternalPropertyValue(n,null))}}}async waitForNestedComponentRendering(){this.childComponentInstances&&await Promise.all(this.childComponentInstances.map((e=>e.renderState.pending?e.renderState.promise:Promise.resolve())))}async resolveRenderingPromiseIfSet(e,t){t&&(await this.waitForNestedComponentRendering(),this.renderState.pending=!1,this.renderState.resolve(e),this.prepareNewRenderingPromise())}prepareNewRenderingPromise(){this.renderState.pending||(this.renderState.promise=new Promise((e=>{this.renderState.resolve=t=>{this.renderState.pending=!1,e(t)}})))}triggerRender(e){this.batchUpdates?this.batchedUpdateRunning||(this.batchedUpdateRunning=!0,(0,d.timeout)((()=>{this.batchedUpdateRunning=!1,this.render(e)}))):this.render(e)}applyShadowRootIfNotExisting(){this.self.shadowDOM&&this.hostDomNode===this&&(this.hostDomNode=(!("attachShadow"in this)&&"ShadyDOM"in window?window.ShadyDOM.wrap(this):this).attachShadow((0,d.isObject)(this.self.shadowDOM)?this.self.shadowDOM:{mode:"open"}))}determineRenderScope(e={}){this.scope={...this.parentInstance?.scope||{},...this.scope,...this.internalProperties,parentInstance:this.parentInstance,rootInstance:this.rootInstance,self:this,[(0,d.lowerCase)(this.self._name)||"instance"]:this,...e},this.scope.scope=this.scope}async render(e="unknown",t=!0){if(this.unRender("reRender",e),this.childComponentInstances=[],this.renderState.pending=!0,this.isRoot&&(await this.resolveRenderingPromiseIfSet(e,t),t&&(await Promise.all(this.self.pendingRenderPromises),this.self.pendingRenderPromises=[])),this.self.pendingRenderPromises.push(this.renderState.promise),this.determineRenderScope(),!this.self.doRender||!this.dispatchEvent(new CustomEvent("render",{detail:{reason:e,scope:this.scope}})))return void await this.resolveRenderingPromiseIfSet(e,t);const r=(0,d.evaluate)(`\`${this.self.content}\``,this.scope);if(r.error)return f.warn(`Failed to process template: ${r.error}`),this.renderState.resolve(e),void await Promise.all(this.self.pendingRenderPromises);this.applyShadowRootIfNotExisting();const s=document.createElement("div");s.innerHTML=r.result,this.applySlots(s,{...this.scope,parentInstance:this}),this.hostDomNode.innerHTML=s.innerHTML,await(0,d.timeout)(),this.waitForNestedComponentRendering().then((()=>{this.applyBindings(this.hostDomNode.firstChild,this.scope,this.self.renderSlots)})),await this.resolveRenderingPromiseIfSet(e,t)}unRender(e="unknown",t){this.unregisterDomNodeEventBindings()}},i.applyRootBinding=!0,i.pendingRenderPromises=[],i.content="<slot>Please provide a template to transclude.</slot>",i.determineRootBinding=!0,i.shadowDOM=null,i.observedAttributes=[],i.controllableProperties=[],i.eventToPropertyMapping={},i.propertyAliases={},i.propertyTypes={onClick:h.func},i.propertiesToReflectAsAttributes=[],i.renderProperties=["children"],i.doRender=!1,i.cloneSlots=!1,i.evaluateSlots=!1,i.renderSlots=!0,i.trimSlots=!0,i.renderUnsafe=!1,i._name="BaseWeb",i._propertyAliasIndex=void 0,i._propertiesToReflectAsAttributes=void 0,n=i,o=c()(n.prototype,"isRoot",[s],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),n);const b=y},e=>{e.exports=i},e=>{e.exports=a},e=>{e.exports=p},e=>{e.exports=r},(e,t,r)=>{r.d(t,{default:()=>h});var s=r(0),n=r(1),o=r(7),i=r.n(o),a=r(9),p=r(10),l=r(3);const c=new s.Logger({name:"web-component-wrapper-web"});class d extends l.default{constructor(...e){super(...e),this.unmountOnDisconnect=!0,this.compiledSlots={},this.preparedSlots={},this.reactRoot=null,this.rootReactInstance=null,this.self=d,this.wrapMemorizingWrapper=null,this.isWrapped=!1,this.reflectInstanceProperties=()=>{this.instance?.current&&this.instance.current.properties&&this.reflectProperties(this.instance.current.properties)}}connectedCallback(){this.applyComponentWrapper(),this.rootReactInstance=this,super.connectedCallback()}disconnectedCallback(){this.unRender("disconnected"),this.unmountOnDisconnect&&this.reactRoot?.unmount(),this.unregisterConnectionState()}reflectExternalProperties(e){this.isRoot&&super.reflectExternalProperties(e)}async render(e="unknown",t=!0){if(super.unRender("reRender",e),this.childComponentInstances=[],this.renderState.pending=!0,this.isRoot&&(this.self.pendingRenderPromises=[]),this.self.pendingRenderPromises.push(this.renderState.promise),this.rootReactInstance!==this||!this.dispatchEvent(new CustomEvent("render",{detail:{reason:e,scope:this.scope}})))return this.resolveRenderingPromiseIfSet(e,t);if(this.determineRenderScope(),0===Object.keys(this.compiledSlots).length&&this.preCompileSlots(),this.evaluateSlots({...this.scope,parentInstance:this}),this.prepareProperties(this.internalProperties),this.applyShadowRootIfNotExisting(),this.rootInstance!==this&&!this.reactRoot){let e=this.firstChild;for(;e;){const t=e.nextSibling;this.removeChild(e),e=t}}if(!this.reactRoot){const e=this.id||this.internalProperties.id||this.externalProperties.id||this.name||this.internalProperties.name||this.externalProperties.name;let t="";"string"==typeof e&&(t=e),this.reactRoot=(0,p.createRoot)(this.hostDomNode,{identifierPrefix:t})}(0,a.flushSync)((()=>{this.reactRoot?.render((0,o.createElement)(this.self.content,this.internalProperties)),this.resolveRenderingPromiseIfSet(e,t)})),t&&await this.renderState.promise}setPropertyValue(e,t){this.reflectProperties({[e]:(0,s.copy)(t,!1,1)}),this.setInternalPropertyValue(e,(0,s.copy)(t,!1,1))}setInternalPropertyValue(e,t){null===t?t=n.NullSymbol:void 0===t&&(t=n.UndefinedSymbol),super.setInternalPropertyValue(e,t)}preCompileDomNodes(e,t={},r=!1){if(1===(e=e.filter((e=>e.nodeType!==Node.TEXT_NODE||"string"==typeof e.nodeValue&&""!==e.nodeValue.trim()))).length)return this.preCompileDomNode(e[0],t,r);let s=1;const n=[];for(const o of e){const e=this.preCompileDomNode(o,t,r,s.toString());n.push(e),s+=1}return r?e=>(...t)=>{const r=[];for(const s of n){const n=s(e);"function"==typeof n&&r.push(n(...t))}return(0,o.createElement)(o.Fragment,{children:r})}:n}preCompileDomNode(e,t={},r=!1,n){if(r){const r=this.preCompileDomNode(e,{...t,data:void 0,firstArgument:void 0,firstParameter:void 0,options:void 0,scope:void 0,parameters:void 0},!1,n);return e=>(...t)=>{const s=t.length>0?t[0]:null;return r({...e,data:s,firstArgument:s,firstParameter:s,options:s,scope:s,parameters:t})}}if(e.nodeType===Node.TEXT_NODE){const t="string"==typeof e.nodeValue?e.nodeValue.trim():"",r=n&&t?(0,o.createElement)(o.Fragment,{children:t,key:n}):t||null;return()=>r}if(!e.getAttributeNames)return()=>null;const i={};let a;const p=this.self.isReactComponent(e);p?(e.determineRenderScope(),0===Object.keys(this.compiledSlots).length&&e.preCompileSlots(),n&&!Object.prototype.hasOwnProperty.call(i,"key")&&(i.key=n),a=e.constructor.content):(i.key=n,a=e.tagName.toLowerCase());let l=Object.keys(t);const d={};for(const r of e.getAttributeNames()){let n=e.getAttribute(r);if(null===n)continue;let o=!1,a="";if(r.startsWith("data-bind-")?a=r.substring(10):r.startsWith("bind-")&&(a=r.substring(5)),a.startsWith("attribute-")||"attributes"===a||a.startsWith("property-")||"properties"===a){const{error:t,originalScopeNames:i,templateFunction:p}=(0,s.compile)(n,l);if(t){c.warn("Error occurred during compiling given attribute",`binding "${r}" on node:`,e,t);continue}"attributes"===a||"properties"===a?o=!0:a=a.startsWith("attribute-")?a.substring(10):a.substring(9),n={originalScopeNames:i,templateFunction:p.bind(this)}}else if(a.startsWith("on-")){a=(0,s.delimitedToCamelCase)(a),Object.prototype.hasOwnProperty.call(t,"event")||(l=[...l,"event"]),Object.prototype.hasOwnProperty.call(t,"parameters")||(l=[...l,"parameters"]);const{error:o,originalScopeNames:i,scopeNames:p,templateFunction:d}=(0,s.compile)(n,l,!0);if(o){c.warn("Error occurred during compiling given event",`binding "${r}" on node:`,e,o);continue}const h=d.bind(this);n=(...o)=>{t.event=o[0],t.parameters=o;try{h(...i.map((e=>t[e])))}catch(t){c.warn("Error occurred during processing given",`event binding "${r}" on node: `,e,`Given expression "${n}" could`,"not be evaluated with given scope names",`"${p.join('", "')}":`,(0,s.represent)(t))}}}else a=r;const h={class:"className",for:"htmlFor"};Object.prototype.hasOwnProperty.call(h,a)&&(a=h[a]),a=(0,s.delimitedToCamelCase)(a),n?.originalScopeNames?d[o?"":a]=n:p||(i[a]=n)}if(!p){const r=Array.from(e.childNodes);r.length&&(i.children=this.preCompileDomNodes(r,t))}return r=>{(r={...t,...r}).scope=r;let s={...i};for(const[e,{originalScopeNames:t,templateFunction:n}]of Object.entries(d)){const o=n(...t.map((e=>r[e])));""===e?s={...s,...o}:s[e]=o}return Object.prototype.hasOwnProperty.call(s,"innerHTML")&&(s.dangerouslySetInnerHTML={__html:s.innerHTML},delete s.children,delete s.innerHTML),Object.prototype.hasOwnProperty.call(s,"textContent")?(s.children=s.textContent,delete s.textContent):p?(s={...e.internalProperties,...s},r={...s,...r,parentInstance:e},e.evaluateSlots(r),e.prepareProperties(s)):s.children&&(s.children=this.evaluatePreCompiledDomNodes(s.children,r)),(0,o.createElement)(a,s)}}evaluatePreCompiledDomNodes(e,t={}){if(!Array.isArray(e))return e(t);if(1===e.length)return e[0](t);const r=[];for(const s of e){const e=s(t);e&&r.push(e)}return r}preCompileSlots(){for(const e in this.slots)this.slots[e]&&"default"!==e&&(this.compiledSlots[e]=this.preCompileDomNode(this.slots[e],{...this.scope,parentInstance:this},[n.func,"function"].includes(this.self.propertyTypes[e])));this.slots.default&&this.slots.default.length>0&&(this.compiledSlots.children=this.preCompileDomNodes(this.slots.default,{...this.scope,parentInstance:this},[n.func,"function"].includes(this.self.propertyTypes.children)))}evaluateSlots(e){this.preparedSlots={};for(const t in this.compiledSlots)Object.prototype.hasOwnProperty.call(this.compiledSlots,t)&&("children"===t?this.preparedSlots.children=this.evaluatePreCompiledDomNodes(this.compiledSlots[t],e):this.preparedSlots[t]=this.compiledSlots[t](e))}static isReactComponent(e){const t=e.constructor;return"object"==typeof t.content&&(!t.attachWebComponentAdapterIfNotExists||"react"===t.content.webComponentAdapterWrapped)}determineRootBinding(){super.determineRootBinding();let e=this.parentNode;for(;e;){if(this.self.isReactComponent(e)){this.rootReactInstance=e;break}e=e.parentNode}}applyComponentWrapper(){if("string"==typeof this.self.content||this.isWrapped)return;this.isWrapped=!0;const e=this.self.content.wrapped||this.self.content;this.self.content.webComponentAdapterWrapped?this.wrapMemorizingWrapper&&(this.self.content=(0,o.memo)(this.self.content),this.self.content.wrapped=e):this.self.attachWebComponentAdapterIfNotExists?(this.self.content.displayName||(this.self.content.displayName=this.self._name),this.self.content=(0,o.forwardRef)(((t,r)=>((0,o.useImperativeHandle)(r,(()=>({properties:t})),[t]),(0,o.createElement)(e,t)))),(this.wrapMemorizingWrapper||null===this.wrapMemorizingWrapper)&&(this.self.content=(0,o.memo)(this.self.content)),this.self.content.wrapped=e,this.self.content.webComponentAdapterWrapped="react"):this.wrapMemorizingWrapper&&(this.self.content=(0,o.memo)(this.self.content),this.self.content.wrapped=e)}prepareProperties(e){(0,s.extend)(e,this.preparedSlots),this.self.removeKnownUnwantedPropertyKeys(this.self,e),e.ref||(this.instance=(0,o.createRef)(),e.ref=e=>{this.instance?this.instance.current=e:this.instance={current:e},this.reflectInstanceProperties()})}static removeKnownUnwantedPropertyKeys(e,t){if("string"!=typeof e.content)for(const r of["isRoot","isTrusted","__composed"])Object.prototype.hasOwnProperty.call(t,r)&&(Object.prototype.hasOwnProperty.call(e.content,"propTypes")&&!Object.prototype.hasOwnProperty.call(e.content.propTypes,r)||Object.prototype.hasOwnProperty.call(e.content,"wrapped")&&Object.prototype.hasOwnProperty.call(e.content.wrapped,"propTypes")&&!Object.prototype.hasOwnProperty.call(e.content.wrapped.propTypes,r))&&delete t[r]}}d.attachWebComponentAdapterIfNotExists=!0,d.content="div",d.react=i(),d._name="ReactWebComponent";const h=d},e=>{e.exports=n},e=>{e.exports=o},(e,t,r)=>{r.d(t,{default:()=>o});var s=r(0);const n=r(8).default,o=(e,t="NoName",r={})=>{var o,i;const a=e._name||e.___types?.name?.name||t.replace(/^(.*\/+)?([^/]+)\.tsx$/,"$2");r.propTypes&&(e.propTypes=r.propTypes);const p=e.propTypes||{},l=r.propertyAliases||e.propertyAliases||{},c=(0,s.unique)(Object.keys(p).concat(Object.keys(l)).concat(Object.values(l)));let d=r.propertiesToReflectAsAttributes||e.propertiesToReflectAsAttributes||[];if(n.propertiesToReflectAsAttributes)if(Array.isArray(d))d=[...n.propertiesToReflectAsAttributes,...d];else if(d instanceof Map)for(const e of n.propertiesToReflectAsAttributes)d.set(e,n.propertyTypes[e]);else if("object"==typeof d)for(const e of n.propertiesToReflectAsAttributes)d[e]=n.propertyTypes[e];const h=c.map((e=>(0,s.camelCaseToDelimited)(e)));class u extends n{constructor(...t){var s;super(...t),this.self=u,this.internalProperties=r.internalProperties?{...r.internalProperties}:e.internalProperties?{...e.internalProperties}:{},this.unmountOnDisconnect=null===(s=r.unmountOnDisconnect)||void 0===s||s}}u.attachWebComponentAdapterIfNotExists="boolean"!=typeof r.attachWebComponentAdapterIfNotExists||r.attachWebComponentAdapterIfNotExists,u.content=e,u.observedAttributes=n.observedAttributes.concat(h).concat(h.map((e=>`-${e}`))),u.controllableProperties=e.controllableProperties||r.controllableProperties||[],u.eventToPropertyMapping=null===r.eventToPropertyMapping?r.eventToPropertyMapping:r.eventToPropertyMapping?{...r.eventToPropertyMapping}:null===e.eventToPropertyMapping?e.eventToPropertyMapping:e.eventToPropertyMapping?{...e.eventToPropertyMapping}:{},u.propertyAliases={...n.propertyAliases,...l},u.propertiesToReflectAsAttributes=d,u.propertyTypes={...n.propertyTypes,...p},u.renderProperties=null!==(o=null!==(i=r.renderProperties)&&void 0!==i?i:e.renderProperties)&&void 0!==o?o:n.renderProperties,u._name=a;return{component:u,register:(e=(0,s.camelCaseToDelimited)(a))=>{customElements.define(e,u)}}}},,e=>{e.exports=s}],c={};function d(e){var t=c[e];if(void 0!==t)return t.exports;var r=c[e]={exports:{}};return l[e](r,r.exports,d),r.exports}d.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return d.d(t,{a:t}),t},d.d=(e,t)=>{for(var r in t)d.o(t,r)&&!d.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},d.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),d.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var h={};d.r(h);var u=d(0),f=d(1),m=d(7),y=d(13),b=d(11),g=d(8),v=d(3);return(0,y.describe)("Web",(()=>{(0,y.test)("constructor",(()=>{class e extends v.default{constructor(...e){super(...e),this.onClick=y.jest.fn()}}e.observedAttributes=["is-root","on-click","on-event"],(0,y.expect)(e).toHaveProperty("content"),(0,y.expect)(e).toHaveProperty("observedAttributes"),customElements.define("test-web",e);const t=document.createElement("test-web");(0,y.expect)(t).not.toHaveProperty("clicked"),t.setAttribute("on-click","this.clicked = true"),(0,y.expect)(t).not.toHaveProperty("clicked"),document.body.appendChild(t),(0,y.expect)(t).toHaveProperty("rootInstance",t),(0,y.expect)(t).not.toHaveProperty("clicked"),t.onClick(),(0,y.expect)(t).toHaveProperty("clicked",!0);const r=y.jest.fn();t.addEventListener("click",r),(0,y.expect)(r).not.toHaveBeenCalled(),t.onClick(),(0,y.expect)(r).toHaveBeenCalled()}))})),(0,y.describe)("ReactWeb",(()=>{(0,y.test)("constructor",(async()=>{let e,t="initial";class r extends g.default{constructor(...e){super(...e),this.self=r,this.onClick=y.jest.fn(),this.onEvent=y.jest.fn()}}r._name="Test",r.content=({onEvent:r,property:s=t})=>(e=r,t=s,(0,m.createElement)("div",{className:s})),r.observedAttributes=["is-root","on-click","on-event"],r.propertyTypes={...v.default.propertyTypes,onEvent:f.func,property:f.string},(0,y.expect)(r).toHaveProperty("content"),(0,y.expect)(r).toHaveProperty("observedAttributes"),customElements.define("test-react",r);const s=document.createElement("test-react");(0,y.expect)(s).not.toHaveProperty("clicked"),s.setAttribute("on-click","this.clicked = true"),(0,y.expect)(s).toHaveProperty("onClick"),(0,y.expect)(s).not.toHaveProperty("clicked"),s.setAttribute("on-event","this.eventHappened = true"),(0,y.expect)(s).toHaveProperty("onEvent"),(0,y.expect)(e).not.toBeDefined(),document.body.appendChild(s),(0,y.expect)(s).toHaveProperty("rootInstance",s),(0,y.expect)(s).toHaveProperty("reactRoot"),(0,y.expect)(e).not.toBeDefined(),await(0,u.timeout)(),(0,y.expect)(e).toBeDefined(),(0,y.expect)(s).not.toHaveProperty("eventHappened"),e&&e(),(0,y.expect)(s).toHaveProperty("eventHappened",!0);const n=y.jest.fn();s.addEventListener("event",n),(0,y.expect)(n).not.toHaveBeenCalled(),e&&e(),(0,y.expect)(n).toHaveBeenCalled(),(0,y.expect)(s).not.toHaveProperty("clicked"),s.onClick(),(0,y.expect)(s).toHaveProperty("clicked",!0);const o=y.jest.fn();s.addEventListener("click",o),(0,y.expect)(o).not.toHaveBeenCalled(),s.onClick(),(0,y.expect)(o).toHaveBeenCalled(),(0,y.expect)(t).toStrictEqual("initial"),(0,y.expect)(document.querySelector("div")?.className).toStrictEqual("initial"),s.property="test",await(0,u.timeout)(),(0,y.expect)(s).toHaveProperty("property","test"),(0,y.expect)(document.querySelector("div")?.className).toStrictEqual("test")}))})),(0,y.describe)("index",(()=>{(0,y.test)("wrapAsWebComponent",(()=>{const e=(0,b.default)((()=>(0,m.createElement)("div")),"TestComponent",{eventToPropertyMapping:{},propertyAliases:{alternateName:"name"},propertiesToReflectAsAttributes:[],propTypes:{name:"string"}});(0,y.expect)(e).toHaveProperty("component"),(0,y.expect)(e).toHaveProperty("register"),(0,y.expect)(e.component).toHaveProperty("_name","TestComponent"),(0,y.expect)(e.component).toHaveProperty("propertyTypes.name","string"),(0,y.expect)(e.component).toHaveProperty("propertiesToReflectAsAttributes",["isRoot"]),(0,y.expect)(e.component).toHaveProperty("eventToPropertyMapping",{})}))})),h})()));
1
+ if(typeof window==='undefined'||window===null)var window=(typeof global==='undefined'||global===null)?{}:global;import { flushSync as __WEBPACK_EXTERNAL_MODULE_react_dom_c0b5c364_flushSync__ } from "react-dom";
2
+ import { createRoot as __WEBPACK_EXTERNAL_MODULE_react_dom_client_82ef521c_createRoot__ } from "react-dom/client";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_clientnode__ from "clientnode";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__ from "clientnode/property-types";
5
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
6
+ import { describe as __WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_describe__, expect as __WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__, jest as __WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_jest__, test as __WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_test__ } from "@jest/globals";
7
+ /******/ var __webpack_modules__ = ([
8
+ /* 0 */
9
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
10
+
11
+ const x = (y) => {
12
+ const x = {}; __webpack_require__.d(x, y); return x
13
+ }
14
+ const y = (x) => (() => (x))
15
+ module.exports = x({ ["Logger"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.Logger), ["NOOP"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.NOOP), ["UTILITY_SCOPE"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.UTILITY_SCOPE), ["UTILITY_SCOPE_NAMES"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.UTILITY_SCOPE_NAMES), ["camelCaseToDelimited"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.camelCaseToDelimited), ["compile"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.compile), ["convertPlainObjectToMap"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.convertPlainObjectToMap), ["copy"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.copy), ["delimitedToCamelCase"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.delimitedToCamelCase), ["evaluate"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.evaluate), ["extend"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.extend), ["isFunction"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.isFunction), ["isObject"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.isObject), ["lowerCase"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.lowerCase), ["replace"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.replace), ["represent"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.represent), ["timeout"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.timeout), ["unique"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.unique), ["unwrap"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.unwrap) });
16
+
17
+ /***/ }),
18
+ /* 1 */
19
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
20
+
21
+ const x = (y) => {
22
+ const x = {}; __webpack_require__.d(x, y); return x
23
+ }
24
+ const y = (x) => (() => (x))
25
+ module.exports = x({ ["NullSymbol"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.NullSymbol), ["UndefinedSymbol"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.UndefinedSymbol), ["any"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.any), ["array"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.array), ["arrayOf"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.arrayOf), ["boolean"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.boolean), ["element"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.element), ["elementType"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.elementType), ["exact"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.exact), ["func"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.func), ["instanceOf"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.instanceOf), ["node"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.node), ["number"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.number), ["object"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.object), ["objectOf"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.objectOf), ["oneOf"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.oneOf), ["oneOfType"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.oneOfType), ["shape"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.shape), ["string"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.string), ["symbol"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode_property_types_4789ebe2__.symbol) });
26
+
27
+ /***/ }),
28
+ /* 2 */
29
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
30
+
31
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
32
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
33
+ /* harmony export */ });
34
+ /* unused harmony export property */
35
+ /* harmony import */ var clientnode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
36
+ /* harmony import */ var clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
37
+ // #!/usr/bin/env babel-node
38
+ // -*- coding: utf-8 -*-
39
+ /** @module decorator *//* !
40
+ region header
41
+ [Project page](https://torben.website/web-component-wrapper)
42
+
43
+ Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
44
+
45
+ License
46
+ -------
47
+
48
+ This library written by Torben Sickert stands under a creative commons
49
+ naming 3.0 unported license.
50
+ See https://creativecommons.org/licenses/by/3.0/deed.de
51
+ endregion
52
+ */// region imports
53
+ // endregion
54
+ /**
55
+ * Generates a decorator based on given configuration.
56
+ * @param options - Property configuration to define how to transfer attributes
57
+ * and properties into each other.
58
+ * @param options.alias - Alternate property name.
59
+ * @param options.readAttribute - Indicates whether to read from existing
60
+ * attribute also.
61
+ * @param options.type - Value type to parse value.
62
+ * @param options.update - Indicates whether to overwrite already existing
63
+ * property configurations.
64
+ * @param options.writeAttribute - Indicates whether to sync attribute
65
+ * representation back into dom.
66
+ * @returns Generated decorator.
67
+ */function property(options={}){options={readAttribute:true,type:clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.string,...options};/**
68
+ * Registers given property to different property / attribute conversion
69
+ * data structures.
70
+ * NOTE: It is important to set static configuration properties on its
71
+ * "own" properties instead of some inherited one. So we have to check via
72
+ * "hasOwnProperty" for existence in this decorator.
73
+ * @param target - Instance to apply given property to.
74
+ * @param name - Field name to apply.
75
+ */return function(target,name){if(typeof name!=="string")return;const self=target.self||target.constructor;if(options.readAttribute){if(!Object.prototype.hasOwnProperty.call(self,"observedAttributes"))self.observedAttributes=self.observedAttributes?[...self.observedAttributes]:[];const attributeName=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.camelCaseToDelimited)(name);if(self.observedAttributes&&!self.observedAttributes.includes(attributeName))self.observedAttributes.push(attributeName)}if(options.type){if(!Object.prototype.hasOwnProperty.call(self,"propertyTypes"))self.propertyTypes=self.propertyTypes?{...self.propertyTypes}:{};if(self.propertyTypes&&(options.update||!Object.prototype.hasOwnProperty.call(self,name)))self.propertyTypes[name]=options.type}if(options.writeAttribute){if(!Object.prototype.hasOwnProperty.call(self,"propertiesToReflectAsAttributes"))self.propertiesToReflectAsAttributes=self.propertiesToReflectAsAttributes?(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(self.propertiesToReflectAsAttributes):[];if(options.update||self.propertiesToReflectAsAttributes instanceof Map&&!self.propertiesToReflectAsAttributes.has(name)||Array.isArray(self.propertiesToReflectAsAttributes)&&!self.propertiesToReflectAsAttributes.includes(name)||typeof self.propertiesToReflectAsAttributes==="object"&&!Object.prototype.hasOwnProperty.call(self.propertiesToReflectAsAttributes,name)){let result;if(typeof options.writeAttribute==="boolean"){if(options.writeAttribute&&self.propertyTypes&&Object.prototype.hasOwnProperty.call(self.propertyTypes,name))result=self.propertyTypes[name]}else result=options.writeAttribute;if(result!==undefined){if(Array.isArray(self.propertiesToReflectAsAttributes))if(options.writeAttribute===true)self.propertiesToReflectAsAttributes.push(name);else if(self.normalizePropertyTypeList)self.propertiesToReflectAsAttributes=self.normalizePropertyTypeList(self.propertiesToReflectAsAttributes);if(self.propertiesToReflectAsAttributes instanceof Map)self.propertiesToReflectAsAttributes.set(name,result);if(typeof self.propertiesToReflectAsAttributes==="object")self.propertiesToReflectAsAttributes[name]=result}}}if(options.alias){if(!Object.prototype.hasOwnProperty.call(self,"propertyAliases"))self.propertyAliases=self.propertyAliases?{...self.propertyAliases}:{};if(self.propertyAliases&&(options.update||!Object.prototype.hasOwnProperty.call(self,name)))self.propertyAliases[name]=options.alias}}}/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (property);
76
+
77
+ /***/ }),
78
+ /* 3 */
79
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
80
+
81
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
82
+ /* harmony export */ Ay: () => (__WEBPACK_DEFAULT_EXPORT__)
83
+ /* harmony export */ });
84
+ /* unused harmony exports log, GenericHTMLElement, Web, api */
85
+ /* unused harmony import specifier */ var camelCaseToDelimited;
86
+ /* harmony import */ var clientnode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
87
+ /* harmony import */ var clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
88
+ /* harmony import */ var _decorator_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
89
+ // #!/usr/bin/env babel-node
90
+ // -*- coding: utf-8 -*-
91
+ /** @module web *//* !
92
+ region header
93
+ [Project page](https://torben.website/web-component-wrapper)
94
+
95
+ Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
96
+
97
+ License
98
+ -------
99
+
100
+ This library written by Torben Sickert stands under a creative commons
101
+ naming 3.0 unported license.
102
+ See https://creativecommons.org/licenses/by/3.0/deed.de
103
+ endregion
104
+ */// region imports
105
+ var _dec,_class,_descriptor,_Web;function _initializerDefineProperty(e,i,r,l){r&&Object.defineProperty(e,i,{enumerable:r.enumerable,configurable:r.configurable,writable:r.writable,value:r.initializer?r.initializer.call(l):void 0})}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==typeof i?i:i+""}function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function _applyDecoratedDescriptor(i,e,r,n,l){var a={};return Object.keys(n).forEach(function(i){a[i]=n[i]}),a.enumerable=!!a.enumerable,a.configurable=!!a.configurable,("value"in a||a.initializer)&&(a.writable=!0),a=r.slice().reverse().reduce(function(r,n){return n(i,e,r)||r},a),l&&void 0!==a.initializer&&(a.value=a.initializer?a.initializer.call(l):void 0,a.initializer=void 0),void 0===a.initializer?(Object.defineProperty(i,e,a),null):a}function _initializerWarningHelper(r,e){throw Error("Decorating class property failed. Please ensure that transform-class-properties is enabled and runs after the decorators transform.")}// endregion
106
+ const log=new clientnode__WEBPACK_IMPORTED_MODULE_0__.Logger({name:"web-component-wrapper.web"});/*
107
+ NOTE: We mock HTMLElement to be able to load this class and derived one
108
+ into node environments.
109
+ */const GenericHTMLElement=typeof HTMLElement==="undefined"?// eslint-disable-next-line @typescript-eslint/no-extraneous-class
110
+ class HTMLElement{}:HTMLElement;/**
111
+ * Generic web component to render a content against instance-specific values.
112
+ * @property applyRootBinding - If determined itself as root declarative event
113
+ * and property bindings will be applied to itself.
114
+ * @property content - Content to render when changes happened.
115
+ * @property determineRootBinding - If checked this component determines if it
116
+ * is a root component (not wrapped by another web-component).
117
+ * @property shadowDOM - Configures if a shadow dom should be used during
118
+ * web-component instantiation. Can hold initialize configuration.
119
+ * @property observedAttributes - Attribute names to observe for changes.
120
+ * @property controllableProperties - A list of controllable property names.
121
+ * @property eventToPropertyMapping - Explicitly defined output events (a
122
+ * mapping of event names to a potential parameter to properties-transformer).
123
+ * @property propertyAliases - A mapping of property names to be treated as
124
+ * equal.
125
+ * @property propertyTypes - Configuration defining how to convert attributes
126
+ * into properties and reflect property changes back to attributes.
127
+ * @property propertiesToReflectAsAttributes - An Item, List, or Mapping of
128
+ * properties to reflect as attributes.
129
+ * @property renderProperties - List of known render properties.
130
+ * @property cloneSlots - Indicates whether to clone slot before to transclude
131
+ * content into them. If a slot should be used multiple times (for example,
132
+ * when it works as a template node.) they should be copied to avoid unexpected
133
+ * mutations.
134
+ * @property doRender - Configures whether this component instance should
135
+ * evaluate its given body content.
136
+ * @property evaluateSlots - Indicates whether to evaluate slot content when
137
+ * before rendering them.
138
+ * @property renderSlots - Indicates whether determined slots should be
139
+ * rendered into root node.
140
+ * @property trimSlots - Ignore empty text nodes while applying slots.
141
+ * @property renderUnsafe - Defines default render behavior.
142
+ * @property _name - Name to access instance-evaluated content or used
143
+ * to derive default component name. This is also useful for logging.
144
+ * @property _propertyAliasIndex - Internal alias index to quickly match
145
+ * properties in both directions.
146
+ * @property _propertiesToReflectAsAttributes - A mapping of property names to
147
+ * set as attributes when they are set/updated. Uses a map to hold order and
148
+ * determine if a property exists in constant runtime.
149
+ * @property renderState - Holds data about currently running render state.
150
+ * @property renderState.promise - Promise resolving when next rendering has
151
+ * been finished.
152
+ * @property renderState.pending - Indicates whether a rendering task is
153
+ * performing.
154
+ * @property renderState.resolve - Callback to trigger when rendering has been
155
+ * finished.
156
+ * @property childComponentInstances - List of direct child components (needed
157
+ * to wait for them to finish dom manipulation).
158
+ * @property batchAttributeUpdates - Indicates whether to directly update dom
159
+ * after each attribute mutation or to wait and batch mutations after current
160
+ * queue has been finished.
161
+ * @property batchPropertyUpdates - Indicates whether to directly update dom
162
+ * after each property mutation or to wait and batch mutations after current
163
+ * queue has been finished.
164
+ * @property batchUpdates - Indicates whether to directly perform a
165
+ * re-rendering after changes on properties have been made.
166
+ * @property batchedAttributeUpdateRunning - A boolean indicator to identify if
167
+ * an attribute update is currently batched.
168
+ * @property batchedPropertyUpdateRunning - A boolean indicator to identify if
169
+ * a property update is currently batched.
170
+ * @property batchedUpdateRunning - Indicates whether a batched render update
171
+ * is currently running.
172
+ * @param connectionRegistered - Indicates whether this component is connected
173
+ * to DOM and could run its connectedCallback.
174
+ * @param pendingAttributeUpdates - Holds pending attribute updates which
175
+ * should be performed when the component is connected to DOM.
176
+ * @property parentInstance - Parent component instance.
177
+ * @property rootInstance - Root component instance.
178
+ * @property scope - Render scope.
179
+ * @property domNodeEventBindings - Holds a mapping from nodes with registered
180
+ * event handlers mapped to their deregistration function.
181
+ * @property domNodeTemplateCache - Caches template compilation results.
182
+ * @property externalProperties - Holds currently evaluated or seen properties.
183
+ * @property ignoreAttributeUpdateObservations - Indicates whether attribute
184
+ * updates should be considered (usually only needed internally).
185
+ * @property internalProperties - Holds currently evaluated properties which
186
+ * are owned by this instance and should always be delegated.
187
+ * @property outputEventNames - Set of determined output event names.
188
+ * @property instance - Wrapped component instance.
189
+ * @property isRoot - Indicates whether their exists another web-derived
190
+ * component up the tree or not.
191
+ * @property root - Hosting dom node.
192
+ * @property runDomConnectionAndRenderingInSameEventQueue - Indicates whether
193
+ * we should render initial dom immediately after the component is connected to
194
+ * dom. Deactivating this allows wrapped components to detect their parents
195
+ * since their parent-connected callback will be called before the children's
196
+ * render method.
197
+ * @property self - Back-reference to this class.
198
+ * @property slots - Grabbed slots that where present in the connecting phase.
199
+ */let Web=(_dec=(0,_decorator_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A)({type:clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.boolean,writeAttribute:true}),_class=(_Web=class Web extends GenericHTMLElement{// endregion
200
+ // region live cycle hooks
201
+ /**
202
+ * Initializes host dom content and properties.
203
+ * @returns Nothing.
204
+ */constructor(){super();_defineProperty(this,"renderState",{promise:Promise.resolve(""),pending:false,resolve:clientnode__WEBPACK_IMPORTED_MODULE_0__.NOOP});// Constructor might be executed when accessed via child components.
205
+ _defineProperty(this,"childComponentInstances",[]);_defineProperty(this,"batchAttributeUpdates",true);_defineProperty(this,"batchPropertyUpdates",true);_defineProperty(this,"batchUpdates",true);/*
206
+ NOTE: We set these properties to true initially since we want to
207
+ prevent any updates until the component is connected to dom.
208
+ */_defineProperty(this,"batchedAttributeUpdateRunning",true);_defineProperty(this,"batchedPropertyUpdateRunning",true);_defineProperty(this,"batchedUpdateRunning",true);_defineProperty(this,"connectionRegistered",false);_defineProperty(this,"pendingAttributeUpdates",[]);_defineProperty(this,"parentInstance",null);_defineProperty(this,"rootInstance",void 0);_defineProperty(this,"hostDomNode",void 0);_defineProperty(this,"scope",{...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE});_defineProperty(this,"domNodeEventBindings",new Map);_defineProperty(this,"domNodeTemplateCache",new Map);_defineProperty(this,"externalProperties",{});_defineProperty(this,"ignoreAttributeUpdateObservations",false);_defineProperty(this,"internalProperties",{});_defineProperty(this,"outputEventNames",new Set);_defineProperty(this,"instance",null);_initializerDefineProperty(this,"isRoot",_descriptor,this);_defineProperty(this,"runDomConnectionAndRenderingInSameEventQueue",false);_defineProperty(this,"self",Web);_defineProperty(this,"slots",{});this.prepareNewRenderingPromise();/*
209
+ NOTE: We cannot use something like "this." e.g. "this.self" to
210
+ determine class properties since instance properties like "self"
211
+ may not set properly yet because this method is called during
212
+ constructing this instance itself.
213
+ */this.self=this.constructor;if(!this.self._propertiesToReflectAsAttributes)this.self._propertiesToReflectAsAttributes=this.self.normalizePropertyTypeList(this.self.propertiesToReflectAsAttributes);this.generateAliasIndex();// NOTE: Shadow root will be applied when rendering the first time.
214
+ this.hostDomNode=this;this.rootInstance=this;/*
215
+ NOTE: We define getter and setter at the end to avoid shadowing
216
+ existing property names.
217
+ */this.defineGetterAndSetterInterface()}/**
218
+ * Triggered when ever a given attribute has changed and triggers to update
219
+ * configured dom content.
220
+ * @param name - Attribute name which was updates.
221
+ * @param oldValue - Old attribute value.
222
+ * @param newValue - New updated value.
223
+ */attributeChangedCallback(name,oldValue,newValue){if(this.ignoreAttributeUpdateObservations||oldValue===newValue)return;void this.onUpdateAttribute(name,newValue)}/**
224
+ * Updates given attribute representation.
225
+ * @param name - Attribute name which was updates.
226
+ * @param newValue - New updated value.
227
+ * @returns Promise resolving when attribute has been updated.
228
+ */onUpdateAttribute(name,newValue){const promise=new Promise(resolve=>this.pendingAttributeUpdates.push(()=>{this.evaluateStringOrNullAndSetAsProperty(name,newValue);if(this.batchAttributeUpdates){if(!(this.batchedAttributeUpdateRunning||this.batchedUpdateRunning)){this.batchedAttributeUpdateRunning=true;this.batchedUpdateRunning=true;void (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.timeout)(()=>{this.batchedAttributeUpdateRunning=false;this.batchedUpdateRunning=false;void this.render("attributeChanged")})}}else void this.render("attributeChanged");resolve()}));if(this.connectionRegistered)while(this.pendingAttributeUpdates.length)this.pendingAttributeUpdates.shift()();return promise}/**
229
+ * Triggered when this component is mounted into the document.
230
+ * Attaches event handler, grabs given slots, reflects external properties,
231
+ * and enqueues first rendering.
232
+ */connectedCallback(){// NOTE: Hack to support IE 11 here.
233
+ try{this.isConnected=true}catch{// Ignore error.
234
+ }this.connectionRegistered=true;// NOTE: Can be overwritten during optional root determining.
235
+ this.parentInstance=this;this.rootInstance=this;this.attachEventHandler();if(this.self.determineRootBinding){this.determineRootBinding();if(this.parentInstance!==this&&this.parentInstance.childComponentInstances)this.parentInstance.childComponentInstances.push(this)}if(this.self.applyRootBinding&&this.isRoot){this.determineRenderScope();this.applyBinding(this,this.scope)}while(this.pendingAttributeUpdates.length)this.pendingAttributeUpdates.shift()();this.batchedAttributeUpdateRunning=false;this.batchedPropertyUpdateRunning=false;this.batchedUpdateRunning=false;this.grabGivenSlots();this.reflectExternalProperties(this.externalProperties);if(this.runDomConnectionAndRenderingInSameEventQueue)void this.render("connected");else void (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.timeout)(()=>{void this.render("connected")})}/**
236
+ * Triggered when this component is unmounted from the document. Event
237
+ * handlers will be removed and state updated accordingly.
238
+ */disconnectedCallback(){this.unRender("disconnected");this.unregisterConnectionState()}// endregion
239
+ // region getter/setter
240
+ /**
241
+ * Registers needed getter and setter to get notified about changes and
242
+ * reflect them.
243
+ */defineGetterAndSetterInterface(){const allPropertyNames=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.unique)(Object.keys(this.self.propertyTypes).concat(this.self._propertyAliasIndex?Object.keys(this.self._propertyAliasIndex):[]));for(const propertyName of allPropertyNames){// If there already exists a local value, use them.
244
+ if(Object.prototype.hasOwnProperty.call(this,propertyName))this.setPropertyValue(/* eslint-disable @typescript-eslint/unbound-method */propertyName,this[propertyName]/* eslint-enable @typescript-eslint/unbound-method */);Object.defineProperty(this,propertyName,{configurable:true,get:()=>this.getPropertyValue(propertyName),set:value=>{this.setPropertyValue(propertyName,value);this.triggerPropertySpecificRendering(propertyName,value)}})}}/**
245
+ * Creates an index to match alias source and target against each other on
246
+ * constant runtime.
247
+ * @param name - Name to search an alternate name for.
248
+ * @returns Found alias or "null".
249
+ */getPropertyAlias(name){if(this.self._propertyAliasIndex&&Object.prototype.hasOwnProperty.call(this.self._propertyAliasIndex,name))return this.self._propertyAliasIndex[name];return null}/**
250
+ * Generic property getter. Forwards properties from the "properties"
251
+ * field.
252
+ * @param name - Property name to retrieve.
253
+ * @returns Retrieved property value.
254
+ */getPropertyValue(name){const result=this.instance?.current?.properties&&(// NOTE: Base properties should not be shadowed.
255
+ Object.prototype.hasOwnProperty.call(!Web.propertyTypes,name)||Object.prototype.hasOwnProperty.call(this.instance.current.properties,name))?this.instance.current.properties[name]:this.internalProperties[name]??this.externalProperties[name];if(this.instance?.current?.state&&Object.prototype.hasOwnProperty.call(this.instance.current.state,name))return this.instance.current.state[name];return result}/**
256
+ * External property setter. Respects configured aliases.
257
+ * @param name - Property name to write.
258
+ * @param value - New value to write.
259
+ */setExternalPropertyValue(name,value){this.externalProperties[name]=value;const alias=this.getPropertyAlias(name);if(alias)this.externalProperties[alias]=value}/**
260
+ * Internal property setter. Respects configured aliases.
261
+ * @param name - Property name to write.
262
+ * @param value - New value to write.
263
+ */setInternalPropertyValue(name,value){this.internalProperties[name]=value;const alias=this.getPropertyAlias(name);if(alias)this.internalProperties[alias]=value}/**
264
+ * Generic property setter. Forwards field writes into internal and
265
+ * external property representations.
266
+ * @param name - Property name to write.
267
+ * @param value - New value to write.
268
+ */setPropertyValue(name,value){this.reflectProperties({[name]:value});this.setInternalPropertyValue(name,value)}/**
269
+ * Triggers a new rendering cycle and respects property-specific state
270
+ * connection.
271
+ * @param name - Property name to write.
272
+ * @param value - New value to write.
273
+ */triggerPropertySpecificRendering(name,value){if(this.batchPropertyUpdates){if(!(this.batchedPropertyUpdateRunning||this.batchedUpdateRunning)){this.batchedPropertyUpdateRunning=true;this.batchedUpdateRunning=true;void (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.timeout)(()=>{if(value!==undefined&&this.isStateProperty(name)){void this.render("preStatePropertyChanged");void (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.timeout)(()=>{this.setInternalPropertyValue(name,undefined);this.batchedPropertyUpdateRunning=false;this.batchedUpdateRunning=false;void this.render("postStatePropertyChanged");this.triggerOutputEvents()})}else{this.batchedPropertyUpdateRunning=false;this.batchedUpdateRunning=false;void this.render("propertyChanged");this.triggerOutputEvents()}})}}else{const isStateProperty=this.isStateProperty(name);void this.render(isStateProperty?"preStatePropertyChanged":"propertyChanged");if(value!==undefined&&isStateProperty){this.setInternalPropertyValue(name,undefined);void this.render("postStatePropertyChanged")}this.triggerOutputEvents()}}// endregion
274
+ // region helper
275
+ /// region utility
276
+ unregisterConnectionState(){// NOTE: Hack to support IE 11 here.
277
+ try{this.isConnected=false}catch{// Ignore error.
278
+ }this.connectionRegistered=false;this.slots={}}unregisterDomNodeEventBindings(){for(const map of this.domNodeEventBindings.values())for(const deregister of map.values())deregister()}//// region dom nodes
279
+ /**
280
+ * Binds properties and event handler to the given dom node.
281
+ * @param domNode - Node to start traversing from.
282
+ * @param scope - Scope to render property value again.
283
+ */applyBinding(domNode,scope){if(!domNode.getAttributeNames)return;for(const attributeName of domNode.getAttributeNames()){let name;if(attributeName.startsWith("data-bind-"))name=attributeName.substring("data-bind-".length);else if(attributeName.startsWith("bind-"))name=attributeName.substring("bind-".length);if(name){const value=domNode.getAttribute(attributeName);if(value===null)continue;if(name.startsWith("attribute-")||name.startsWith("property-")){const evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,scope,false,true,domNode);if(evaluated.error){log.warn("Error occurred during processing given",`attribute binding "${attributeName}" on node:`,domNode,evaluated.error);continue}if(name.startsWith("attribute-"))domNode.setAttribute(name.substring("attribute-".length),evaluated.result);else/*
284
+ NOTE: Cast to "textContent" to have a writable
285
+ property here.
286
+ */domNode[(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(name.substring("property-".length))]=evaluated.result}else if(name.startsWith("on-")){name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(name.substring("on-".length));scope={log,event:undefined,parameters:undefined,...scope};/*
287
+ NOTE: We pre-compile event listener since they should
288
+ usually be called more often than binded.
289
+ */const compilation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,scope,true,true,domNode);if(compilation.error)log.warn("Error occurred during compiling given event",`binding "${attributeName}" on node:`,domNode,compilation.error);else this.addSecureEventListener(domNode,name,(...parameters)=>{scope.event=parameters[0];scope.parameters=parameters;try{compilation.templateFunction(/*
290
+ NOTE: We want to be sure to have
291
+ the same ordering as we have for
292
+ the scope names and to call
293
+ internal registered getter by
294
+ retrieving values. So simple using
295
+ "...Object.values(scope)" is not
296
+ appreciate here.
297
+ */...compilation.originalScopeNames.map(name=>scope[name]))}catch(error){log.warn("Error occurred during processing","given event binding",`"${attributeName}" on node:`,domNode,`Given expression "${value}" could`,"not be evaluated with given scope","names \""+compilation.scopeNames.join("\", \"")+`": ${(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error)}`)}})}}}}/**
298
+ * Binds properties and event handler to given, sibling, and nested nodes.
299
+ * @param domNode - Node to start traversing from.
300
+ * @param scope - Scope to render property value again.
301
+ * @param renderSlots - Indicates whether to render nested elements of
302
+ * slots (determined by an existing corresponding attribute).
303
+ */applyBindings(domNode,scope,renderSlots=true){while(domNode){if(domNode.attributes?.length&&(renderSlots||!domNode.getAttribute("slot")))this.applyBinding(domNode,scope);/*
304
+ NOTE: Slots of nested custom components (recognized by their
305
+ dash in name) should be rendered by their own.
306
+ */if(!domNode.nodeName.toLowerCase().includes("-"))this.applyBindings(domNode.firstChild,scope);domNode=domNode.nextSibling}}/**
307
+ * Compiles given node content and their children. Provides a corresponding
308
+ * map of compiled template functions connected to their (sub) nodes and
309
+ * expected scope names.
310
+ * @param domNode - Node to compile.
311
+ * @param scope - Scope to extract names from.
312
+ * @param options - Additional compile options.
313
+ * @param options.filter - Callback to exclude some node from being
314
+ * compiled.
315
+ * @param options.ignoreComponents - Indicates if component properties
316
+ * should be traversed or not.
317
+ * @param options.ignoreNestedComponents - Indicates if nested components
318
+ * should be traversed or not.
319
+ * @param options.unsafe - Indicates if full HTML generation should be
320
+ * allowed.
321
+ * @returns Map of compiled templates.
322
+ */compileDomNodeTemplate(domNode,scope=[],options={}){options={ignoreComponents:true,ignoreNestedComponents:true,unsafe:this.self.renderUnsafe,...options};const nodeName=domNode.nodeName.toLowerCase();/*
323
+ NOTE: Slots of nested custom components (recognized by their dash
324
+ in name) should be rendered / controlled by them on their own.
325
+ */if(options.ignoreComponents&&nodeName.includes("-"))return null;if(options.unsafe){let template=domNode.innerHTML;if(!template&&domNode.template)template=domNode.template;if(this.self.hasCode(template)){const result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(`\`${template}\``,scope);return{domNode,children:[],error:result.error,scopeNames:result.scopeNames,template,templateFunction:result.templateFunction}}return null}let template=null;if(nodeName==="#text"){const content=domNode.textContent;if(content&&this.self.hasCode(content))template=content.replace(/&nbsp;/g," ").trim()}const children=[];const result={children,domNode};if(template){const compilationResult=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(`\`${template}\``,scope);result.error=compilationResult.error;result.scopeNames=compilationResult.scopeNames;result.template=template;result.templateFunction=compilationResult.templateFunction}// Compile content of each nested node.
326
+ let currentDomNode=domNode.firstChild;while(currentDomNode){if(!options.filter||options.filter(currentDomNode)){const result=this.compileDomNodeTemplate(currentDomNode,scope,{...options,ignoreComponents:options.ignoreNestedComponents});if(result)children.push(result)}currentDomNode=currentDomNode.nextSibling}return result}/**
327
+ * @param options - Evaluation options.
328
+ * @param scope - Scope to evaluate against.
329
+ * @returns Evaluated string result or null.
330
+ */evaluateCompiledDomNodeTemplate(options,scope){const{domNode,error,templateFunction,scopeNames}=options;if(!(templateFunction&&scopeNames))return null;if(error){log.warn("Error occurred during compiling node content:",error);return null}let output=null;try{output=templateFunction(...scopeNames.map(name=>scope[name]))}catch(error){log.warn(`Error occurred when "${this.self._name}" is running`,`"${String(templateFunction)}": with bound`,`names "${scopeNames.join("\", \"")}":`,`"${error}". Rendering node:`,domNode)}return output}/**
331
+ * Compiles and evaluates given node content and their children. Replaces
332
+ * each node content with their evaluated representation.
333
+ * @param domNode - Node to evaluate.
334
+ * @param scope - Scope to render against.
335
+ * @param options - Compile options.
336
+ * @param options.applyBindings - Indicates whether to apply bindings to
337
+ * given dom nodes.
338
+ * @param options.filter - Callback to exclude some node from being
339
+ * compiled.
340
+ * @param options.ignoreComponents - Indicates if component properties
341
+ * should be traversed or not.
342
+ * @param options.ignoreNestedComponents - Indicates if nested components
343
+ * should be traversed or not.
344
+ * @param options.domNodeTemplateCache - Yet compiled dom nodes to just
345
+ * reference instead of recompiling.
346
+ * @param options.unsafe - Indicates if full HTML generation should be
347
+ * allowed.
348
+ */evaluateDomNodeTemplate(domNode,scope={},options={}){options={domNodeTemplateCache:this.domNodeTemplateCache,ignoreComponents:true,ignoreNestedComponents:true,unsafe:this.self.renderUnsafe,...options};const domNodeTemplateCache=options.domNodeTemplateCache;if(!domNodeTemplateCache.has(domNode)){const compilerOptions={filter:options.filter,ignoreComponents:options.ignoreComponents,ignoreNestedComponents:options.ignoreNestedComponents,unsafe:options.unsafe};const compiledDomNode=this.compileDomNodeTemplate(domNode,scope,compilerOptions);if(compiledDomNode)domNodeTemplateCache.set(domNode,compiledDomNode)}if(domNodeTemplateCache.has(domNode)){const compiledDomNode=domNodeTemplateCache.get(domNode);const output=this.evaluateCompiledDomNodeTemplate(compiledDomNode,scope);if(output!==null)if(options.unsafe&&domNode.innerHTML)domNode.innerHTML=output;else domNode.textContent=output;if(compiledDomNode.children.length){const evaluateChildDomNode=children=>{for(const childCompiledDomNode of children){const output=this.evaluateCompiledDomNodeTemplate(childCompiledDomNode,scope);if(output!==null)childCompiledDomNode.domNode.textContent=output;if(childCompiledDomNode.children.length)evaluateChildDomNode(childCompiledDomNode.children)}};evaluateChildDomNode(compiledDomNode.children)}}if(options.applyBindings)this.applyBindings(domNode,scope)}/**
349
+ * Adds an event listener to the given dom node so that it will be
350
+ * deregistered when the component instance is destroyed.
351
+ * @param domNode - Node to assign event handler to.
352
+ * @param name - Event name.
353
+ * @param handler - Callback to trigger when given event occurs.
354
+ * @param options - Add event listener options.
355
+ * @param removeOptions - Remove event listener options.
356
+ * @returns Deregister function.
357
+ */addSecureEventListener(domNode,name,handler,options,removeOptions){if(!this.domNodeEventBindings.has(domNode))this.domNodeEventBindings.set(// eslint-disable-next-line func-call-spacing
358
+ domNode,new Map);const eventMap=this.domNodeEventBindings.get(domNode);const oldHandler=eventMap.get(name);if(oldHandler&&oldHandler!==handler)oldHandler();const deregister=()=>{domNode.removeEventListener(name,handler,removeOptions);eventMap.delete(name);if(eventMap.size===0)this.domNodeEventBindings.delete(domNode)};eventMap.set(name,deregister);domNode.addEventListener(name,handler,options);return deregister}//// endregion
359
+ /**
360
+ * Determines initial root which initializes rendering digest.
361
+ */determineRootBinding(){/*
362
+ If this component is the root component, we have to trigger
363
+ nested event handler by our own in global context since there is no
364
+ parent doing that for us.
365
+ */let currentElement=this.parentNode;while(currentElement){const isComponent=currentElement instanceof Web||currentElement.nodeName.includes("-")&&currentElement.nodeName!=="#document-fragment";const isInShadowDOM=currentElement.parentNode===null&&/* eslint-disable @typescript-eslint/no-base-to-string */currentElement.toString()==="[object ShadowRoot]";/* eslint-enable @typescript-eslint/no-base-to-string */if(isComponent){// Check whether we found the first parent component.
366
+ if(this.rootInstance===this){this.parentInstance=currentElement;/*
367
+ NOTE: There is at least one parent, so we can set
368
+ "isRoot" to "false".
369
+ */this.setPropertyValue("isRoot",false)}this.rootInstance=currentElement}else if(isInShadowDOM)/*
370
+ NOTE: Assume none root if determined a wrapped closed
371
+ shadow DOM.
372
+ */this.setPropertyValue("isRoot",false);currentElement=currentElement.parentNode}}/**
373
+ * Checks if given content hast code (to compile and render).
374
+ * @param content - Potential string with code inside.
375
+ * @returns A boolean indicating whether given content has code.
376
+ */static hasCode(content){return(// NOTE: First three conditions are only for performance.
377
+ typeof content==="string"&&content.includes("${")&&content.includes("}")&&/\${[\s\S]+}/.test(content))}/**
378
+ * Converts given the list, item, or map to a map (with ordering).
379
+ * @param value - Attribute reflection configuration.
380
+ * @returns Generated map.
381
+ */static normalizePropertyTypeList(value){if(typeof value==="string")value=[value];if(Array.isArray(value)){const givenValue=value;const newValue=new Map;for(const name of givenValue)if(Object.prototype.hasOwnProperty.call(Web.propertyTypes,name))newValue.set(name,Web.propertyTypes[name]);return newValue}return (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.convertPlainObjectToMap)(value)}/// endregion
382
+ /// region events
383
+ /**
384
+ * Attaches event handler to keep in sync with nested components properties
385
+ * states.
386
+ */attachEventHandler(){if(this.self.eventToPropertyMapping===null)return;/*
387
+ NOTE: We only reflect properties by implicit determined events if
388
+ their where no explicitly defined.
389
+ */const somethingDefined=this.attachExplicitDefinedOutputEventHandler();this.attachImplicitDefinedOutputEventHandler(!somethingDefined)}/**
390
+ * Attach explicitly defined event handler to synchronize internal and
391
+ * external property states.
392
+ * @returns Returns "true" if there are some defined and "false" otherwise.
393
+ */attachExplicitDefinedOutputEventHandler(){if(!this.self.eventToPropertyMapping)return false;// Grab all existing output to property definitions
394
+ let result=false;for(const name of Object.keys(this.self.eventToPropertyMapping))if(!Object.prototype.hasOwnProperty.call(this.internalProperties,name)){result=true;this.outputEventNames.add(name);this.setInternalPropertyValue(name,async(...parameters)=>{const result=await this.reflectEventToProperties(name,parameters);if(result)parameters[0]=result;this.forwardEvent(name,parameters)})}return result}/**
395
+ * Attach implicitly defined event handler to synchronize internal and
396
+ * external property states.
397
+ * @param reflectProperties - Indicates whether implicitly determined
398
+ * properties should be reflected.
399
+ */attachImplicitDefinedOutputEventHandler(reflectProperties=true){// Determine all event handlers to inject
400
+ for(const[name,type]of Object.entries(this.self.propertyTypes))if(!Object.prototype.hasOwnProperty.call(this.internalProperties,name)&&[clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func,"function"].includes(type)&&!this.self.renderProperties.includes(name)){this.outputEventNames.add(name);this.setInternalPropertyValue(name,(...parameters)=>{if(reflectProperties)void this.reflectEventToProperties(name,parameters);this.forwardEvent(name,parameters)})}}/**
401
+ * Triggers all identified events to communicate internal property / state
402
+ * changes.
403
+ */triggerOutputEvents(){for(const name of this.outputEventNames)this.forwardEvent(name,[this.externalProperties])}/**
404
+ * Forwards given event as the native web event.
405
+ * @param name - Event name.
406
+ * @param parameters - Event parameters.
407
+ * @returns False if event is cancelable, and at least one of the event
408
+ * handlers which received event called "Event.preventDefault()",
409
+ * otherwise true will be returned.
410
+ */forwardEvent(name,parameters){if(name.length>"onX".length&&name.startsWith("on"))name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.lowerCase)(name.substring(2));return this.dispatchEvent(new CustomEvent(name,{detail:{parameters}}))}/// endregion
411
+ /// region slots
412
+ /**
413
+ * Renders component given slot contents into the given dom node. If
414
+ * expected slots are not given but a fallback is specified, they will be
415
+ * loaded into internal slot mapping.
416
+ * @param targetDomNode - Target dom node to render slots into.
417
+ * @param scope - Environment to render slots again if specified.
418
+ */applySlots(targetDomNode,scope){for(const domNode of Array.from(targetDomNode.querySelectorAll("slot"))){const name=domNode.getAttribute("name");if(name===null||name==="default"){if(this.slots.default){if(this.self.renderSlots){if(this.self.evaluateSlots)for(const domNode of this.slots.default)this.evaluateDomNodeTemplate(domNode,scope);(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.replace)(domNode,this.slots.default,Web.trimSlots)}}else this.slots.default=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.unwrap)(domNode).map(domNode=>this.grabSlotContent(domNode));}else if(this.slots[name]){if(this.self.renderSlots){if(this.self.evaluateSlots)this.evaluateDomNodeTemplate(this.slots[name],scope);(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.replace)(domNode,this.slots[name],Web.trimSlots)}}else this.slots[name]=this.grabSlotContent((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.unwrap)(domNode).filter(domNode=>domNode.nodeName.toLowerCase()!=="#text")[0])}}/**
419
+ * Determines slot content from the given node.
420
+ * @param slot - Node to grab slot content from.
421
+ * @returns Determined slot.
422
+ */grabSlotContent(slot){/*
423
+ If real (template) code is wrapped in a "textarea" tag, unwrap it
424
+ now. This extra wrapping can be used to avoid first dom rendering
425
+ before template code has been evaluated.
426
+ */const element=clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.node.firstElementChild?slot:null;if(element&&element.firstElementChild?.nodeName.toLowerCase()==="textarea"&&(!element.firstElementChild.hasAttribute("data-no-template")||element.firstElementChild.getAttribute("data-no-template")==="false")){const content=element.firstElementChild.value;/*
427
+ NOTE: These kinds of slots are always used as a template and
428
+ should therefore be copied in every case.
429
+ NOTE: A flat copy should suffice since we will replace nested
430
+ content.
431
+ NOTE: Remove template content in copied node to avoid rendering
432
+ them before being evaluated. We cannot remove template code
433
+ from the source node since this would make it impossible to
434
+ re-instantiate this slot during whole component
435
+ re-instantiation.
436
+ */element.classList.remove("web-component-template");const newSlot=element.cloneNode();element.classList.add("web-component-template");newSlot.innerHTML="";newSlot.template=content;return newSlot}return this.self.cloneSlots?slot.cloneNode(true):slot}/**
437
+ * Saves given slots.
438
+ */grabGivenSlots(){this.slots={};for(const slot of Array.from(this.querySelectorAll("[slot]"))){// NOTE: This is how we avoid grabbing slots from nested components.
439
+ let currentElement=slot.parentNode;let skip=true;while(currentElement){if(currentElement.nodeName.includes("-")){if(currentElement===this)skip=false;break}currentElement=currentElement.parentNode}if(skip)continue;const slotValue=slot.getAttribute("slot")?.trim();this.slots[slotValue??slot.nodeName.toLowerCase()]=this.grabSlotContent(slot)}if(this.slots.default)this.slots.default=[].concat(this.slots.default);else if(this.childNodes.length>0)this.slots.default=Array.from(this.childNodes).map(domNode=>this.grabSlotContent(domNode));else this.slots.default=[]}/// endregion
440
+ /// region properties
441
+ /**
442
+ * Determines if a given property name exists in wrapped component state.
443
+ * @param name - Property name to check if exists in state.
444
+ * @returns Boolean result.
445
+ */isStateProperty(name){return Boolean(this.instance?.current?.state&&(Object.prototype.hasOwnProperty.call(this.instance.current.state,name)||this.instance.current.state.modelState&&Object.prototype.hasOwnProperty.call(this.instance.current.state.modelState,name)))}/**
446
+ * Generates an alias to name and the other way around mapping if not
447
+ * exists.
448
+ */generateAliasIndex(){if(!this.self._propertyAliasIndex){this.self._propertyAliasIndex={...this.self.propertyAliases};// Align alias mapping for better performance while mapping them.
449
+ for(const[name,value]of Object.entries(this.self._propertyAliasIndex))if(!Object.prototype.hasOwnProperty.call(this.self._propertyAliasIndex,value))this.self._propertyAliasIndex[value]=name}}/**
450
+ * Reflects wrapped component state back to web-component's attributes.
451
+ * @param properties - Properties to update in reflected attribute state.
452
+ */reflectExternalProperties(properties){/*
453
+ NOTE: We can avoid an additional attribute parsing for
454
+ reflections.
455
+ */this.ignoreAttributeUpdateObservations=true;for(const[name,value]of Object.entries(properties)){this.setExternalPropertyValue(name,value);if(!this.isConnected)continue;const attributeName=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.camelCaseToDelimited)(name);if(this.self._propertiesToReflectAsAttributes?.has(name))switch(this.self._propertiesToReflectAsAttributes.get(name)){case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.boolean:case"boolean":if(value){if(this.getAttribute(attributeName)!=="")this.setAttribute(attributeName,"")}else if(this.hasAttribute(attributeName))this.removeAttribute(attributeName);break;case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func:case"function":break;case"json":if(value){const representation=JSON.stringify(value);if(representation&&this.getAttribute(attributeName)!==representation){this.setAttribute(attributeName,representation);break}}if(this.hasAttribute(attributeName))this.removeAttribute(attributeName);break;case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.number:case"number":if(typeof value==="number"&&!isNaN(value)){const valueAsString=String(value);if(this.getAttribute(attributeName)!==valueAsString)this.setAttribute(attributeName,valueAsString)}else if(this.hasAttribute(attributeName))this.removeAttribute(attributeName);break;case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.string:case"string":if(value){if(this.getAttribute(attributeName)!==value)this.setAttribute(attributeName,value)}else if(this.hasAttribute(attributeName))this.removeAttribute(attributeName);break;case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.any:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.array:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.arrayOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.element:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.elementType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.instanceOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.node:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.object:case"object":case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.objectOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.shape:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.exact:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.symbol:default:if(value){const representation=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(value);if(representation&&this.getAttribute(attributeName)!==representation){this.setAttribute(attributeName,representation);break}}if(this.hasAttribute(attributeName))this.removeAttribute(attributeName);break}}this.ignoreAttributeUpdateObservations=false}/**
456
+ * Reflects wrapped component state back to web-component's attributes and
457
+ * properties.
458
+ * @param properties - Properties to update in reflected property state.
459
+ */reflectProperties(properties){this.reflectExternalProperties(properties);/*
460
+ NOTE: Do not reflect properties which are hold in state. These
461
+ values are only set once when they are explicitly set
462
+ (see "setPropertyValue").
463
+ */if(this.instance?.current?.state&&typeof this.instance.current.state==="object")for(const name of Object.keys(this.instance.current.state).concat(this.instance.current.state.modelState?Object.keys(this.instance.current.state.modelState):[]))if(Object.prototype.hasOwnProperty.call(this.internalProperties,name))/*
464
+ We want to avoid fully deleting this property to know
465
+ which properties exist in the underlying instance.
466
+ */this.setInternalPropertyValue(name,undefined);if(this.internalProperties.model?.state){delete this.internalProperties.model.state;this.setInternalPropertyValue("model",this.internalProperties.model)}for(const name of this.self.controllableProperties)if(Object.prototype.hasOwnProperty.call(properties,name))this.setInternalPropertyValue(name,properties[name])}/**
467
+ * Reflect the given event handler call with the given parameter back to
468
+ * current properties state.
469
+ * @param name - Event name.
470
+ * @param parameters - List of parameter to given event handler call.
471
+ * @returns Mapped properties or null if nothing could be mapped.
472
+ */async reflectEventToProperties(name,parameters){/*
473
+ NOTE: We enforce to update component state immediately after an
474
+ event occurs since batching usually does not make sense here. An
475
+ event runs within its own context.
476
+ On the other hand, it can be necessary to immediately reflect a
477
+ property change to the component internal state to avoid
478
+ contradicting internal render cycles.
479
+ */const oldBatchUpdatesConfiguration=this.batchUpdates;this.batchUpdates=false;let result=null;let handled=false;// region check if there exists an explicit mapper
480
+ if(this.self.eventToPropertyMapping&&Object.prototype.hasOwnProperty.call(this.self.eventToPropertyMapping,name)&&(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isFunction)(this.self.eventToPropertyMapping[name])){const wrappedMapping=this.self.eventToPropertyMapping[name](...parameters,this);const mapping=wrappedMapping&&"then"in wrappedMapping&&(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isFunction)(wrappedMapping.then)?await wrappedMapping:wrappedMapping;handled=true;if(Array.isArray(mapping)){result=mapping[0];this.reflectProperties(result);(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.extend)(true,this.internalProperties,mapping[1])}else if(mapping===null)handled=false;else if(typeof mapping==="object"){result=mapping;this.reflectProperties(mapping)}}// endregion
481
+ if(!handled&&parameters.length>0&&(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isObject)(parameters[0])){/*
482
+ Identified as somehow throw data back event (no synthetic
483
+ event; derived from a user-triggered one) when following
484
+ condition does not hold.
485
+ */let newProperties=parameters[0];if("persist"in parameters[0]&&(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isFunction)(parameters[0].persist)){newProperties={};for(const propertyName of Object.keys(this.self.propertyTypes))for(const name of[propertyName].concat(this.getPropertyAlias(propertyName)??[])){const currentValue=parameters[0].currentTarget&&Object.prototype.hasOwnProperty.call(parameters[0].currentTarget,name)?/*
486
+ Update all known properties from event
487
+ target instance.
488
+ */parameters[0].currentTarget[name]:/*
489
+ Update all known properties from adapter
490
+ instance.
491
+ */this.getPropertyValue(name);if(currentValue!==this.externalProperties[name])newProperties[name]=currentValue}}else if(![null,undefined].includes(newProperties.detail?.value))newProperties={...newProperties.detail};result=newProperties;this.reflectProperties(newProperties)}this.triggerRender("propertyReflected");this.batchUpdates=oldBatchUpdatesConfiguration;return result}/**
492
+ * Evaluates the given property value depending on its property definition
493
+ * and registers in a property mapping object.
494
+ * @param attributeName - Name of given value.
495
+ * @param value - Value to evaluate.
496
+ */evaluateStringOrNullAndSetAsProperty(attributeName,value){const preEvaluate=attributeName.startsWith("-");const effectiveAttributeName=preEvaluate?attributeName.substring(1):attributeName;let name=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.delimitedToCamelCase)(effectiveAttributeName);const alias=this.getPropertyAlias(name);if(alias&&Object.prototype.hasOwnProperty.call(this.self.propertyTypes,alias))name=alias;if(Object.prototype.hasOwnProperty.call(this.self.propertyTypes,name)){const type=this.self.propertyTypes[name];if(preEvaluate){if(value){const result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE},false,true,this);if(result.error){log.warn(`Failed to process pre-evaluation attribute`,`"${attributeName}": ${result.error}. Will be`,"set to \"undefined\".");this.setInternalPropertyValue(name,undefined)}else{this.setInternalPropertyValue(name,result.result);this.setExternalPropertyValue(name,result.result)}}}else switch(type){case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.boolean:case"boolean":{const booleanValue=![null,"false"].includes(value);this.setInternalPropertyValue(name,booleanValue);this.setExternalPropertyValue(name,booleanValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func:case"function":{let error=null;let templateFunction;const scopeNames=["data","event","firstArgument","firstParameter","options"];if(value){const result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.compile)(value,scopeNames.concat("parameters","scope",clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES),true,true,this);error=result.error;templateFunction=result.templateFunction;if(error)log.warn("Failed to compile given handler",`"${attributeName}": ${error}.`)}this.setInternalPropertyValue(name,(...parameters)=>{if(this.outputEventNames.has(name))void this.reflectEventToProperties(name,parameters);let result=undefined;if(!error){const scope={parameters,...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE};for(const name of scopeNames)scope[name]=parameters[0];try{result=templateFunction?.(...scopeNames.map(name=>scope[name]),parameters,scope,...clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE_NAMES.map(name=>clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE[name]))}catch(error){log.warn("Failed to evaluate function",`"${attributeName}" with expression`,`"${value}" and scope`,"variables",`"${scopeNames.join("\", \"")}" set to`,`"${(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(parameters)}":`,`${error}. Set property`,`to "undefined".`)}}if(!this.self.renderProperties.includes(name))this.forwardEvent(name,parameters);return result});if(!error)this.setExternalPropertyValue(name,templateFunction);break}case"json":{if(value){let evaluated;try{evaluated=JSON.parse(value)}catch(error){log.warn("Error occurred during parsing given json",`attribute "${attributeName}":`,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error));break}// NOTE: That both values do have to be avoided.
497
+ this.setInternalPropertyValue(name,evaluated);this.setExternalPropertyValue(name,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(evaluated,false,1))}else{this.setInternalPropertyValue(name,null);this.setExternalPropertyValue(name,null)}break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.number:case"number":{if(value===null){this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}/*
498
+ NOTE: You should not name this variable "number" since
499
+ babel gets confused caused by existing module wide
500
+ property type variable "number".
501
+ */let numberValue=parseFloat(value);if(isNaN(numberValue))numberValue=undefined;this.setInternalPropertyValue(name,numberValue);this.setExternalPropertyValue(name,numberValue);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.string:case"string":{this.setInternalPropertyValue(name,value);this.setExternalPropertyValue(name,value);break}case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.any:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.array:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.arrayOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.element:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.elementType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.instanceOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.node:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.object:case"object":case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.objectOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOf:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.oneOfType:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.shape:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.exact:case clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.symbol:default:{if(value){const evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(value,{},false,true,this);if(evaluated.error){log.warn("Error occurred during processing given",`attribute configuration "${attributeName}":`,evaluated.error);break}// NOTE: That both values do have to be avoided.
502
+ this.setInternalPropertyValue(name,evaluated.result);this.setExternalPropertyValue(name,(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(evaluated.result,false,1))}else if(this.hasAttribute(attributeName)){this.setInternalPropertyValue(name,true);this.setExternalPropertyValue(name,true)}else{this.setInternalPropertyValue(name,null);this.setExternalPropertyValue(name,null)}break}}}}/// endregion
503
+ /// region render
504
+ /**
505
+ * Produces a promise resolving when all nested rendering promises have
506
+ * been resolved. This only waits for registered nested components. That
507
+ * means that nested components which where connected before the parent
508
+ * component got initialized will not be waited for. That might happen
509
+ * when nested component types got registered before the parent ones.
510
+ */async waitForNestedComponentRendering(){if(!this.childComponentInstances)return;await Promise.all(this.childComponentInstances.map(component=>component.renderState.pending?component.renderState.promise:Promise.resolve()))}/**
511
+ * Resolves the rendering promise.
512
+ * @param reason - Rendering reason description.
513
+ * @param resolveRendering - Indicates whether to resolve the rendering or
514
+ * just return a resolving promise directly.
515
+ * @returns A promise resolving when all nested render promises have been
516
+ * resolved.
517
+ */async resolveRenderingPromiseIfSet(reason,resolveRendering){if(resolveRendering){await this.waitForNestedComponentRendering();this.renderState.pending=false;this.renderState.resolve(reason);this.prepareNewRenderingPromise()}}/**
518
+ * Sets up a new rendering cycle representing promise.
519
+ */prepareNewRenderingPromise(){if(!this.renderState.pending)this.renderState.promise=new Promise(resolve=>{this.renderState.resolve=reason=>{this.renderState.pending=false;resolve(reason)}})}/**
520
+ * Triggers a new rendering cycle by respecting batch configuration.
521
+ * @param reason - A description why rendering should be triggered.
522
+ */triggerRender(reason){if(this.batchUpdates){if(!this.batchedUpdateRunning){this.batchedUpdateRunning=true;void (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.timeout)(()=>{this.batchedUpdateRunning=false;void this.render(reason)})}}else void this.render(reason)}/**
523
+ * Creates shadow root if not created yet and assigns to the current root
524
+ * property.
525
+ */applyShadowRootIfNotExisting(){if(this.self.shadowDOM&&this.hostDomNode===this)this.hostDomNode=(!("attachShadow"in this)&&"ShadyDOM"in window?window.ShadyDOM.wrap(this):this).attachShadow((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isObject)(this.self.shadowDOM)?this.self.shadowDOM:{mode:"open"})}/**
526
+ * Determines a new scope object with a useful default set of environment
527
+ * values.
528
+ * @param scope - To apply to generated scope.
529
+ */determineRenderScope(scope={}){this.scope={...(this.parentInstance?.scope||{}),...this.scope,...this.internalProperties,parentInstance:this.parentInstance,rootInstance:this.rootInstance,self:this,[(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.lowerCase)(this.self._name)||"instance"]:this,...scope};this.scope.scope=this.scope}/**
530
+ * Does the rendering job. Should be called when ever state changes should
531
+ * be projected to the hosts dom content.
532
+ * @param reason - Description why rendering is necessary.
533
+ * @param resolveRendering - Indicates whether rendering should be resolved
534
+ * finally. Should be set to "false" via super calls in inherited render
535
+ * methods which do further dom manipulations afterward and resolve the
536
+ * rendering process by their own.
537
+ * @returns A promise resolving when rendering has been finished. A promise
538
+ * may be needed for classes inheriting from this class.
539
+ */async render(reason="unknown",resolveRendering=true){this.unRender("reRender",reason);this.childComponentInstances=[];this.renderState.pending=true;if(this.isRoot){await this.resolveRenderingPromiseIfSet(reason,resolveRendering);if(resolveRendering){await Promise.all(this.self.pendingRenderPromises);this.self.pendingRenderPromises=[]}}this.self.pendingRenderPromises.push(this.renderState.promise);this.determineRenderScope();if(!(this.self.doRender&&this.dispatchEvent(new CustomEvent("render",{detail:{reason,scope:this.scope}})))){await this.resolveRenderingPromiseIfSet(reason,resolveRendering);return}const evaluated=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(`\`${this.self.content}\``,this.scope);if(evaluated.error){log.warn(`Failed to process template: ${evaluated.error}`);this.renderState.resolve(reason);await Promise.all(this.self.pendingRenderPromises);return}this.applyShadowRootIfNotExisting();/*
540
+ NOTE: We first render into an intermediate render target and apply
541
+ slot content until we finally publish everything to the document.
542
+ This avoids painting twice and internetexplorer bugs with an empty
543
+ node after first overwriting the content of "this.rootInstance".
544
+ */const renderTargetDomNode=document.createElement("div");renderTargetDomNode.innerHTML=evaluated.result;this.applySlots(renderTargetDomNode,{...this.scope,parentInstance:this});this.hostDomNode.innerHTML=renderTargetDomNode.innerHTML;/*
545
+ NOTE: Wait until nested components have registered themselves to be
546
+ able to wait for their rendering.
547
+ */await (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.timeout)();void this.waitForNestedComponentRendering().then(()=>{this.applyBindings(this.hostDomNode.firstChild,this.scope,this.self.renderSlots)});await this.resolveRenderingPromiseIfSet(reason,resolveRendering)}/**
548
+ * Should free up memory listeners related to deprecated HTML.
549
+ * @param _reason - Description why rendering is necessary.
550
+ * @param _reRenderReason - Description why a re-rendering is necessary.
551
+ */unRender(_reason="unknown",_reRenderReason){this.unregisterDomNodeEventBindings()}/// endregion
552
+ // endregion
553
+ },_defineProperty(_Web,"applyRootBinding",true),_defineProperty(_Web,"pendingRenderPromises",[]),_defineProperty(_Web,"content","<slot>Please provide a template to transclude.</slot>"),_defineProperty(_Web,"determineRootBinding",true),_defineProperty(_Web,"shadowDOM",null),_defineProperty(_Web,"observedAttributes",[]),_defineProperty(_Web,"controllableProperties",[]),_defineProperty(_Web,"eventToPropertyMapping",{}),_defineProperty(_Web,"propertyAliases",{}),_defineProperty(_Web,"propertyTypes",{onClick:clientnode_property_types__WEBPACK_IMPORTED_MODULE_1__.func}),_defineProperty(_Web,"propertiesToReflectAsAttributes",[]),_defineProperty(_Web,"renderProperties",["children"]),_defineProperty(_Web,"doRender",false),_defineProperty(_Web,"cloneSlots",false),_defineProperty(_Web,"evaluateSlots",false),_defineProperty(_Web,"renderSlots",true),_defineProperty(_Web,"trimSlots",true),_defineProperty(_Web,"renderUnsafe",false),_defineProperty(_Web,"_name","BaseWeb"),_defineProperty(_Web,"_propertyAliasIndex",void 0),_defineProperty(_Web,"_propertiesToReflectAsAttributes",void 0),_Web),_descriptor=_applyDecoratedDescriptor(_class.prototype,"isRoot",[_dec],{configurable:true,enumerable:true,writable:true,initializer:function(){return true}}),_class);const api=(/* unused pure expression or super */ null && ({component:Web,register:(tagName=camelCaseToDelimited(Web._name))=>{customElements.define(tagName,Web)}}));/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Web);
554
+
555
+ /***/ }),
556
+ /* 4 */
557
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
558
+
559
+
560
+ // EXPORTS
561
+ __webpack_require__.d(__webpack_exports__, {
562
+ Ay: () => (/* binding */ src_ReactWeb)
563
+ });
564
+
565
+ // UNUSED EXPORTS: ReactWeb, api, log
566
+
567
+ // EXTERNAL MODULE: external "clientnode"
568
+ var external_clientnode_ = __webpack_require__(0);
569
+ // EXTERNAL MODULE: external "clientnode/property-types"
570
+ var property_types_ = __webpack_require__(1);
571
+ // EXTERNAL MODULE: external "react"
572
+ var external_react_ = __webpack_require__(6);
573
+ ;// external "react-dom"
574
+
575
+ ;// external "react-dom/client"
576
+
577
+ // EXTERNAL MODULE: ./src/Web.ts
578
+ var Web = __webpack_require__(3);
579
+ ;// ./src/ReactWeb.ts
580
+ /* unused harmony import specifier */ var camelCaseToDelimited;
581
+ // #!/usr/bin/env babel-node
582
+ // -*- coding: utf-8 -*-
583
+ /** @module react *//* !
584
+ region header
585
+ [Project page](https://torben.website/web-component-wrapper)
586
+
587
+ Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
588
+
589
+ License
590
+ -------
591
+
592
+ This library written by Torben Sickert stands under a creative commons
593
+ naming 3.0 unported license.
594
+ See https://creativecommons.org/licenses/by/3.0/deed.de
595
+ endregion
596
+ */// region imports
597
+ function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==typeof i?i:i+""}function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}// endregion
598
+ const log=new external_clientnode_.Logger({name:"web-component-wrapper.react-web"});/*
599
+ Live cycle:
600
+
601
+ 1. Render the React component with properties (defined in a web-component)
602
+ and start listing to "onChange" events.
603
+ 2. Reflect component properties to web-component properties and
604
+ attributes (with prevented re-rendering caused by new properties).
605
+ 3. Component triggers an "onChange" event (caused by some react event)
606
+ which delivers updated properties to the web-component.
607
+ -> Starting with the first step.
608
+ *//**
609
+ * Adapter for exposing a React component as a web-component.
610
+ * @property attachWebComponentAdapterIfNotExists - Indicates whether to wrap
611
+ * with a reference wrapper to get updated about internal state changes.
612
+ * @property content - React component to wrap.
613
+ * @property react - React namespace.
614
+ * @property compiledSlots - Cache of yet pre-compiled slot elements.
615
+ * @property preparedSlots - Cache of yet evaluated slot react elements.
616
+ * @property rootReactInstance - Saves determined root react instance.
617
+ * @property self - Back-reference to this class.
618
+ * @property wrapMemorizingWrapper - Determines whether to wrap component with
619
+ * React's memorizing wrapper to cache component render results.
620
+ * @property isWrapped - Indicates whether a React component is wrapped
621
+ * already.
622
+ */class ReactWeb extends Web/* default */.Ay{constructor(...args){super(...args);_defineProperty(this,"unmountOnDisconnect",true);_defineProperty(this,"compiledSlots",{});_defineProperty(this,"preparedSlots",{});_defineProperty(this,"reactRoot",null);_defineProperty(this,"rootReactInstance",null);_defineProperty(this,"self",ReactWeb);_defineProperty(this,"wrapMemorizingWrapper",null);_defineProperty(this,"isWrapped",false);/**
623
+ * Updates the current component instance and reflects newly determined
624
+ * properties.
625
+ */_defineProperty(this,"reflectInstanceProperties",()=>{if(this.instance?.current&&this.instance.current.properties)this.reflectProperties(this.instance.current.properties)})}// region live-cycle
626
+ /**
627
+ * Triggered when this component is mounted into the document. Event
628
+ * handlers will be attached and the final render proceeds.
629
+ */connectedCallback(){this.applyComponentWrapper();// NOTE: Can be overwritten during optional root determining.
630
+ this.rootReactInstance=this;/*
631
+ Attaches event handler, grabs given slots, reflects external
632
+ properties and enqueues first rendering.
633
+ */super.connectedCallback()}/**
634
+ * Triggered when this component is unmounted from the document. Event
635
+ * handlers will be removed and state updated accordingly.
636
+ */disconnectedCallback(){this.unRender("disconnected");if(this.unmountOnDisconnect)this.reactRoot?.unmount();this.unregisterConnectionState()}/**
637
+ * Reflects wrapped component state back to web-component's attributes.
638
+ * @param properties - Properties to update in reflected attribute state.
639
+ */reflectExternalProperties(properties){if(this.isRoot)super.reflectExternalProperties(properties)}/**
640
+ * Method that does the rendering job. Should be called when ever state
641
+ * changes should be projected to the hosts dom content.
642
+ * @param reason - Description why rendering is necessary.
643
+ * @param resolveRendering - Indicates whether rendering should be resolved
644
+ * finally. Should be set to "false" via super calls in inherited render
645
+ * methods which do further dom manipulations afterward and resolve the
646
+ * rendering process by their own.
647
+ * @returns A promise resolving when rendering has finished. A promise may
648
+ * be needed for classes inheriting from this class.
649
+ */async render(reason="unknown",resolveRendering=true){super.unRender("reRender",reason);this.childComponentInstances=[];this.renderState.pending=true;if(this.isRoot)this.self.pendingRenderPromises=[];this.self.pendingRenderPromises.push(this.renderState.promise);/*
650
+ NOTE: We prevent a nested React component from self-rendering since
651
+ they will be rendered by highest react parent.
652
+ */if(this.rootReactInstance!==this||!this.dispatchEvent(new CustomEvent("render",{detail:{reason,scope:this.scope}})))return this.resolveRenderingPromiseIfSet(reason,resolveRendering);this.determineRenderScope();if(Object.keys(this.compiledSlots).length===0)this.preCompileSlots();this.evaluateSlots({...this.scope,parentInstance:this});this.prepareProperties(this.internalProperties);this.applyShadowRootIfNotExisting();if(this.rootInstance!==this&&!this.reactRoot){/*
653
+ Remove template nodes since they will be replaced by reacts
654
+ render result (only necessary when having a dedicated rendering
655
+ target like shadow root and only on first render before React
656
+ takes over DOM management).
657
+ */let domNode=this.firstChild;while(domNode){const nextDomNode=domNode.nextSibling;this.removeChild(domNode);domNode=nextDomNode}}if(!this.reactRoot){const identifierPrefixCandidate=this.id||this.internalProperties.id||this.externalProperties.id||this.name||this.internalProperties.name||this.externalProperties.name;let identifierPrefix="";if(typeof identifierPrefixCandidate==="string")identifierPrefix=identifierPrefixCandidate;this.reactRoot=__WEBPACK_EXTERNAL_MODULE_react_dom_client_82ef521c_createRoot__(this.hostDomNode,{identifierPrefix})}__WEBPACK_EXTERNAL_MODULE_react_dom_c0b5c364_flushSync__(()=>{this.reactRoot?.render((0,external_react_.createElement)(this.self.content,this.internalProperties));void this.resolveRenderingPromiseIfSet(reason,resolveRendering)});if(resolveRendering)await this.renderState.promise}// endregion
658
+ // region property handling
659
+ /**
660
+ * Generic property setter. Forwards field writes into internal and
661
+ * external property representations.
662
+ *
663
+ * In general, it is a bad idea to write properties which shadow state
664
+ * properties (move to a controlled component instance) and re-set the
665
+ * property to "undefined" later to lose control.
666
+ *
667
+ * The reason causes in avoiding this scenario:
668
+ *
669
+ * 1. Property overwrites the state.
670
+ * 2. State changes but is shadowed by recent changes in property.
671
+ *
672
+ * So the following will be ensured:
673
+ *
674
+ * 1. Property overwrites the state.
675
+ * 2. Property is overwritten to "undefined" to lose control over the
676
+ * state.
677
+ * 3. Now a state change can be represented back after property adaptions.
678
+ * (Converts reacts declarative nature into an imperative web-component
679
+ * style).
680
+ * 4. Further state changes should be communicated back via output events.
681
+ * @param name - Property name to write.
682
+ * @param value - New value to write.
683
+ */setPropertyValue(name,value){this.reflectProperties({[name]:(0,external_clientnode_.copy)(value,false,1)});this.setInternalPropertyValue(name,(0,external_clientnode_.copy)(value,false,1))}/**
684
+ * Internal property setter. Respects configured aliases.
685
+ * @param name - Property name to write.
686
+ * @param value - New value to write.
687
+ */setInternalPropertyValue(name,value){if(value===null)value=property_types_.NullSymbol;else if(value===undefined)value=property_types_.UndefinedSymbol;super.setInternalPropertyValue(name,value)}// endregion
688
+ // region handle slots
689
+ /**
690
+ * Converts given html dom nodes into a compiled function to generate a
691
+ * react-element or a react-element list.
692
+ * @param domNodes - Nodes to convert.
693
+ * @param scope - Additional scope to render subcomponents against.
694
+ * Necessary to bound necessary environment variables into compiled context.
695
+ * @param isFunction - Indicates whether a given render result should be
696
+ * provided as function (render property) with bound parameters environment
697
+ * variable name.
698
+ * @returns Transformed react elements.
699
+ */preCompileDomNodes(domNodes,scope={},isFunction=false){// NOTE: We ignore empty text nodes (like React's jsx does).
700
+ domNodes=domNodes.filter(domNode=>domNode.nodeType!==Node.TEXT_NODE||typeof domNode.nodeValue==="string"&&domNode.nodeValue.trim()!=="");if(domNodes.length===1)return this.preCompileDomNode(domNodes[0],scope,isFunction);let index=1;const result=[];for(const node of domNodes){const element=this.preCompileDomNode(node,scope,isFunction,index.toString());result.push(element);index+=1}if(isFunction)return scope=>(...parameters)=>{const renderResult=[];for(const factory of result){const renderItem=factory(scope);if(typeof renderItem==="function")renderResult.push(renderItem(...parameters))}return (0,external_react_.createElement)(external_react_.Fragment,{children:renderResult})};return result}/**
701
+ * Converts a given html dom node into a react-element.
702
+ * @param domNode - Node to convert.
703
+ * @param scope - Additional scope to render subcomponents against.
704
+ * @param isFunction - Indicates whether given nodes should be provided as
705
+ * function (render property).
706
+ * @param key - Optional key to add to component properties.
707
+ * @returns Transformed react element.
708
+ */preCompileDomNode(domNode,scope={},isFunction=false,key){// region render property
709
+ if(isFunction){const node=this.preCompileDomNode(domNode,{...scope,data:undefined,firstArgument:undefined,firstParameter:undefined,options:undefined,scope:undefined,parameters:undefined},false,key);return scope=>(...parameters)=>{const firstArgument=parameters.length>0?parameters[0]:null;return node({...scope,data:firstArgument,firstArgument,firstParameter:firstArgument,options:firstArgument,scope:firstArgument,parameters})}}// endregion
710
+ // region text node
711
+ if(domNode.nodeType===Node.TEXT_NODE){const value=typeof domNode.nodeValue==="string"?domNode.nodeValue.trim():"";const result=key&&value?(0,external_react_.createElement)(external_react_.Fragment,{children:value,key}):value?value:null;return()=>result}// endregion
712
+ if(!domNode.getAttributeNames)return()=>null;// region native elements and wrapped react components
713
+ /// region prepare type and static properties
714
+ const staticProperties={};let target;const isComponent=this.self.isReactComponent(domNode);if(isComponent){// region pre-compile nested render context
715
+ domNode.determineRenderScope();if(Object.keys(this.compiledSlots).length===0)domNode.preCompileSlots();// endregion
716
+ /*
717
+ NOTE: Nested components are already instantiated and connected,
718
+ so use their initialized properties. We need to merge them when
719
+ actually rendering the nested component.
720
+ */if(key&&!Object.prototype.hasOwnProperty.call(staticProperties,"key"))staticProperties.key=key;target=domNode.constructor.content}else{staticProperties.key=key;target=domNode.tagName.toLowerCase()}/// endregion
721
+ /// region pre-compile dynamic properties
722
+ let knownScopeNames=Object.keys(scope);const compiledProperties={};for(const attributeName of domNode.getAttributeNames()){let value=domNode.getAttribute(attributeName);if(value===null)continue;let extend=false;let name="";if(attributeName.startsWith("data-bind-"))name=attributeName.substring("data-bind-".length);else if(attributeName.startsWith("bind-"))name=attributeName.substring("bind-".length);if(name.startsWith("attribute-")||name==="attributes"||name.startsWith("property-")||name==="properties"){const{error,originalScopeNames,templateFunction}=(0,external_clientnode_.compile)(value,knownScopeNames);if(error){log.warn("Error occurred during compiling given attribute",`binding "${attributeName}" on node:`,domNode,error);continue}if(name==="attributes"||name==="properties")extend=true;else name=name.startsWith("attribute-")?name.substring("attribute-".length):name.substring("property-".length);value={originalScopeNames,templateFunction:templateFunction.bind(this)}}else if(name.startsWith("on-")){name=(0,external_clientnode_.delimitedToCamelCase)(name);if(!Object.prototype.hasOwnProperty.call(scope,"event"))knownScopeNames=[...knownScopeNames,"event"];if(!Object.prototype.hasOwnProperty.call(scope,"parameters"))knownScopeNames=[...knownScopeNames,"parameters"];/*
723
+ NOTE: We pre-compile event listener since they should
724
+ usually be called more than it would be re-rendered.
725
+ */const{error,originalScopeNames,scopeNames,templateFunction}=(0,external_clientnode_.compile)(value,knownScopeNames,true);if(error){log.warn("Error occurred during compiling given event",`binding "${attributeName}" on node:`,domNode,error);continue}const eventHandler=templateFunction.bind(this);value=(...parameters)=>{scope.event=parameters[0];scope.parameters=parameters;try{eventHandler(/*
726
+ NOTE: We want to be ensured to have the same
727
+ ordering as we have for the scope names and to
728
+ call internal registered getter by retrieving
729
+ values. So simple using
730
+ "...Object.values(scope)" is not appreciate
731
+ here.
732
+ */...originalScopeNames.map(name=>scope[name]))}catch(error){log.warn("Error occurred during processing given",`event binding "${attributeName}" on node: `,domNode,`Given expression "${value}" could`,"not be evaluated with given scope names",`"${scopeNames.join("\", \"")}":`,(0,external_clientnode_.represent)(error))}}}else name=attributeName;const mapping={class:"className",for:"htmlFor"};if(Object.prototype.hasOwnProperty.call(mapping,name))name=mapping[name];name=(0,external_clientnode_.delimitedToCamelCase)(name);if(value?.originalScopeNames)// NOTE: "''" marks a property set like in JSX "{...props}".
733
+ compiledProperties[extend?"":name]=value;else if(!isComponent)/*
734
+ NOTE: Properties of components are evaluated already by
735
+ them self and set as "internalProperties". Those
736
+ properties, which need to be evaluated against the parent
737
+ scope, should be marked via the "bind-property-" prefix.
738
+ That's why they are omitted here.
739
+ */staticProperties[name]=value}/// endregion
740
+ /// region pre-compiled nested nodes of native elements
741
+ if(!isComponent){const childNodes=Array.from(domNode.childNodes);if(childNodes.length)staticProperties.children=this.preCompileDomNodes(childNodes,scope)}/// endregion
742
+ /// region create evaluable render function
743
+ return runtimeScope=>{// region prepare scope
744
+ runtimeScope={...scope,...runtimeScope};runtimeScope.scope=runtimeScope;// endregion
745
+ let properties={...staticProperties};// region evaluate dynamic properties
746
+ for(const[name,{originalScopeNames,templateFunction}]of Object.entries(compiledProperties)){const value=templateFunction(...originalScopeNames.map(name=>runtimeScope[name]));if(name==="")properties={...properties,...value};else properties[name]=value}// endregion
747
+ // region prepare react specific element property handling
748
+ if(Object.prototype.hasOwnProperty.call(properties,"innerHTML")){properties.dangerouslySetInnerHTML={__html:properties.innerHTML};delete properties.children;delete properties.innerHTML}if(Object.prototype.hasOwnProperty.call(properties,"textContent")){properties.children=properties.textContent;delete properties.textContent}else if(isComponent){// region evaluate nested render contexts
749
+ /*
750
+ NOTE: Properties of components are evaluated already by
751
+ them self and set as "internalProperties". Those
752
+ properties, which need to be evaluated against the parent
753
+ scope, should be marked via the "bind-property-" prefix.
754
+ */properties={...domNode.internalProperties,...properties};runtimeScope={...properties,...runtimeScope,parentInstance:domNode};domNode.evaluateSlots(runtimeScope);domNode.prepareProperties(properties);// endregion
755
+ }else if(properties.children)properties.children=this.evaluatePreCompiledDomNodes(properties.children,runtimeScope);// endregion
756
+ return (0,external_react_.createElement)(target,properties)};/// endregion
757
+ // endregion
758
+ }/**
759
+ * Evaluates given pre-compiled nodes into a single react element or a
760
+ * React element list.
761
+ * @param nodes - Pre-compiled nodes.
762
+ * @param scope - Additional scope to render subcomponents against.
763
+ * @returns Transformed react elements.
764
+ */evaluatePreCompiledDomNodes(nodes,scope={}){if(!Array.isArray(nodes))return nodes(scope);if(nodes.length===1)return nodes[0](scope);const result=[];for(const node of nodes){const element=node(scope);if(element)result.push(element)}return result}/**
765
+ * Pre compiles and caches determined slots.
766
+ */preCompileSlots(){for(const name in this.slots)if(this.slots[name]&&name!=="default")this.compiledSlots[name]=this.preCompileDomNode(this.slots[name],{...this.scope,parentInstance:this},[property_types_.func,"function"].includes(this.self.propertyTypes[name]));if(this.slots.default&&this.slots.default.length>0)this.compiledSlots.children=this.preCompileDomNodes(this.slots.default,{...this.scope,parentInstance:this},[property_types_.func,"function"].includes(this.self.propertyTypes.children))}/**
767
+ * Evaluates pre-compiled slots.
768
+ * @param scope - To render again.
769
+ */evaluateSlots(scope){this.preparedSlots={};for(const name in this.compiledSlots)if(Object.prototype.hasOwnProperty.call(this.compiledSlots,name))if(name==="children")this.preparedSlots.children=this.evaluatePreCompiledDomNodes(this.compiledSlots[name],scope);else this.preparedSlots[name]=this.compiledSlots[name](scope)}// endregion
770
+ // region helper
771
+ /**
772
+ * Determines if the given element type is a react-wrapped component.
773
+ * @param domNode - Node to determine from.
774
+ * @returns Boolean indicator.
775
+ */static isReactComponent(domNode){const type=domNode.constructor;return typeof type.content==="object"&&(!type.attachWebComponentAdapterIfNotExists||type.content.webComponentAdapterWrapped==="react")}/**
776
+ * Determines initial root and react root who initializes their rendering
777
+ * digests.
778
+ */determineRootBinding(){super.determineRootBinding();let currentElement=this.parentNode;while(currentElement){if(this.self.isReactComponent(currentElement)){this.rootReactInstance=currentElement;break}currentElement=currentElement.parentNode}}/**
779
+ * Applies missing forward ref and or memorizing wrapper to a current react
780
+ * component.
781
+ */applyComponentWrapper(){if(typeof this.self.content==="string"||this.isWrapped)return;this.isWrapped=true;const wrapped=this.self.content.wrapped||this.self.content;if(this.self.content.webComponentAdapterWrapped){if(this.wrapMemorizingWrapper){this.self.content=(0,external_react_.memo)(this.self.content);this.self.content.wrapped=wrapped}}else if(this.self.attachWebComponentAdapterIfNotExists){if(!this.self.content.displayName)this.self.content.displayName=this.self._name;this.self.content=(0,external_react_.forwardRef)((properties,reference)=>{(0,external_react_.useImperativeHandle)(reference,()=>({properties}),[properties]);return (0,external_react_.createElement)(wrapped,properties)});if(this.wrapMemorizingWrapper||this.wrapMemorizingWrapper===null)this.self.content=(0,external_react_.memo)(this.self.content);this.self.content.wrapped=wrapped;this.self.content.webComponentAdapterWrapped="react"}else if(this.wrapMemorizingWrapper){this.self.content=(0,external_react_.memo)(this.self.content);this.self.content.wrapped=wrapped}}/**
782
+ * Prepares a given properties object to render against the current
783
+ * component. Creates a reference for being recognized of reacts internal
784
+ * state updates.
785
+ * @param properties - Properties to prepare.
786
+ */prepareProperties(properties){(0,external_clientnode_.extend)(properties,this.preparedSlots);this.self.removeKnownUnwantedPropertyKeys(this.self,properties);/*
787
+ NOTE: Provide instance if and only if not explicitly requested from
788
+ parent via properties.
789
+ */if(!properties.ref){this.instance=(0,external_react_.createRef)();properties.ref=reference=>{if(this.instance)this.instance.current=reference;else this.instance={current:reference};this.reflectInstanceProperties()}}}/**
790
+ * Removes unwanted known and not specified properties from a given
791
+ * properties object (usually added by dev-tools).
792
+ * @param target - ReactElement where properties belong to.
793
+ * @param properties - Properties object to trim.
794
+ */static removeKnownUnwantedPropertyKeys(target,properties){if(typeof target.content==="string")return;// NOTE: Known root of errors caused by browser dev-tools.
795
+ for(const name of["isRoot","isTrusted","__composed"])if(Object.prototype.hasOwnProperty.call(properties,name)&&(Object.prototype.hasOwnProperty.call(target.content,"propTypes")&&!Object.prototype.hasOwnProperty.call(target.content.propTypes,name)||Object.prototype.hasOwnProperty.call(target.content,"wrapped")&&Object.prototype.hasOwnProperty.call(target.content.wrapped,"propTypes")&&!Object.prototype.hasOwnProperty.call(target.content.wrapped.propTypes,name)))delete properties[name]}// endregion
796
+ }_defineProperty(ReactWeb,"attachWebComponentAdapterIfNotExists",true);_defineProperty(ReactWeb,"content","div");_defineProperty(ReactWeb,"react",external_react_["default"]);_defineProperty(ReactWeb,"_name","ReactWebComponent");const api=(/* unused pure expression or super */ null && ({component:ReactWeb,register:(tagName=camelCaseToDelimited(ReactWeb._name))=>{customElements.define(tagName,ReactWeb)}}));/* harmony default export */ const src_ReactWeb = (ReactWeb);
797
+
798
+ /***/ }),
799
+ /* 5 */
800
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
801
+
802
+ /* unused harmony exports property, ReactWeb, reactWebAPI, webAPI, Web, wrapAsWebComponent */
803
+ /* unused harmony import specifier */ var propertyImport;
804
+ /* unused harmony import specifier */ var reactWebAPIImport;
805
+ /* unused harmony import specifier */ var webAPIImport;
806
+ /* unused harmony import specifier */ var WebImport;
807
+ /* harmony import */ var clientnode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
808
+ /* harmony import */ var _ReactWeb_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
809
+ // #!/usr/bin/env babel-node
810
+ // -*- coding: utf-8 -*-
811
+ /** @module index *//* !
812
+ region header
813
+ [Project page](https://torben.website/web-component-wrapper)
814
+
815
+ Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
816
+
817
+ License
818
+ -------
819
+
820
+ This library written by Torben Sickert stands under a creative commons
821
+ naming 3.0 unported license.
822
+ See https://creativecommons.org/licenses/by/3.0/deed.de
823
+ endregion
824
+ */// region imports
825
+ function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==typeof i?i:i+""}function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}// endregion
826
+ const property=(/* unused pure expression or super */ null && (propertyImport));const ReactWeb=_ReactWeb_js__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Ay;const reactWebAPI=(/* unused pure expression or super */ null && (reactWebAPIImport));const webAPI=(/* unused pure expression or super */ null && (webAPIImport));const Web=(/* unused pure expression or super */ null && (WebImport));/**
827
+ * Wraps given react component as web component.
828
+ * @param component - React component to wrap.
829
+ * @param nameHint - A name to set as property in runtime generated web
830
+ * component class.
831
+ * @param configuration - Additional web component configurations.
832
+ * @returns Generated object to register and retrieve generated web component.
833
+ */const wrapAsWebComponent=(component,nameHint="NoName",configuration={})=>{// Determine class / function name.
834
+ const name=component._name||// NOTE: Not minifyable save: "component.name ||"
835
+ /*
836
+ NOTE: There exists babel plugins which reflects component name and
837
+ member variables under this property. Try to respect these.
838
+ */component.___types?.name?.name||nameHint.replace(/^(.*\/+)?([^/]+)\.tsx$/,"$2");if(configuration.propTypes)component.propTypes=configuration.propTypes;const propertyTypes=component.propTypes||{};const propertyAliases=configuration.propertyAliases||component.propertyAliases||{};const allPropertyNames=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.unique)(Object.keys(propertyTypes).concat(Object.keys(propertyAliases)).concat(Object.values(propertyAliases)));// NOTE: We extend given configuration properties by base class defined.
839
+ let propertiesToReflectAsAttributes=configuration.propertiesToReflectAsAttributes||component.propertiesToReflectAsAttributes||[];if(ReactWeb.propertiesToReflectAsAttributes)if(Array.isArray(propertiesToReflectAsAttributes))propertiesToReflectAsAttributes=[...ReactWeb.propertiesToReflectAsAttributes,...propertiesToReflectAsAttributes];else if(propertiesToReflectAsAttributes instanceof Map)for(const name of ReactWeb.propertiesToReflectAsAttributes)propertiesToReflectAsAttributes.set(name,ReactWeb.propertyTypes[name]);else if(typeof propertiesToReflectAsAttributes==="object")for(const name of ReactWeb.propertiesToReflectAsAttributes)propertiesToReflectAsAttributes[name]=ReactWeb.propertyTypes[name];const attributeNames=allPropertyNames.map(name=>(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.camelCaseToDelimited)(name));/**
840
+ * Runtime generated web component.
841
+ */class ConcreteComponent extends ReactWeb{constructor(...args){super(...args);_defineProperty(this,"self",ConcreteComponent);_defineProperty(this,"internalProperties",configuration.internalProperties?{...configuration.internalProperties}:component.internalProperties?{...component.internalProperties}:{});_defineProperty(this,"unmountOnDisconnect",configuration.unmountOnDisconnect??true)}}_defineProperty(ConcreteComponent,"attachWebComponentAdapterIfNotExists",typeof configuration.attachWebComponentAdapterIfNotExists==="boolean"?configuration.attachWebComponentAdapterIfNotExists:true);_defineProperty(ConcreteComponent,"content",component);_defineProperty(ConcreteComponent,"observedAttributes",ReactWeb.observedAttributes.concat(attributeNames)// NOTE: Respect pre-evaluation indicator attributes.
842
+ .concat(attributeNames.map(name=>`-${name}`)));_defineProperty(ConcreteComponent,"controllableProperties",component.controllableProperties||configuration.controllableProperties||[]);_defineProperty(ConcreteComponent,"eventToPropertyMapping",configuration.eventToPropertyMapping===null?configuration.eventToPropertyMapping:configuration.eventToPropertyMapping?{...configuration.eventToPropertyMapping}:component.eventToPropertyMapping===null?component.eventToPropertyMapping:component.eventToPropertyMapping?{...component.eventToPropertyMapping}:{});_defineProperty(ConcreteComponent,"propertyAliases",{...ReactWeb.propertyAliases,...propertyAliases});_defineProperty(ConcreteComponent,"propertiesToReflectAsAttributes",propertiesToReflectAsAttributes);_defineProperty(ConcreteComponent,"propertyTypes",{...ReactWeb.propertyTypes,...propertyTypes});_defineProperty(ConcreteComponent,"renderProperties",configuration.renderProperties??component.renderProperties??ReactWeb.renderProperties);_defineProperty(ConcreteComponent,"_name",name);const webComponentAPI={component:ConcreteComponent,register:(tagName=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.camelCaseToDelimited)(name))=>{customElements.define(tagName,ConcreteComponent)}};return webComponentAPI};/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (wrapAsWebComponent);
843
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, [
844
+ /* harmony export */ "Ay", 0, /* export default binding */ __WEBPACK_DEFAULT_EXPORT__
845
+ /* harmony export */ ]);
846
+
847
+
848
+ /***/ }),
849
+ /* 6 */
850
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
851
+
852
+ const x = (y) => {
853
+ const x = {}; __webpack_require__.d(x, y); return x
854
+ }
855
+ const y = (x) => (() => (x))
856
+ module.exports = x({ ["Fragment"]: () => (__WEBPACK_EXTERNAL_MODULE_react__.Fragment), ["createElement"]: () => (__WEBPACK_EXTERNAL_MODULE_react__.createElement), ["createRef"]: () => (__WEBPACK_EXTERNAL_MODULE_react__.createRef), ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_react__["default"]), ["forwardRef"]: () => (__WEBPACK_EXTERNAL_MODULE_react__.forwardRef), ["memo"]: () => (__WEBPACK_EXTERNAL_MODULE_react__.memo), ["useImperativeHandle"]: () => (__WEBPACK_EXTERNAL_MODULE_react__.useImperativeHandle) });
857
+
858
+ /***/ })
859
+ /******/ ]);
860
+ /************************************************************************/
861
+ /******/ // The module cache
862
+ /******/ const __webpack_module_cache__ = {};
863
+ /******/
864
+ /******/ // The require function
865
+ /******/ function __webpack_require__(moduleId) {
866
+ /******/ // Check if module is in cache
867
+ /******/ const cachedModule = __webpack_module_cache__[moduleId];
868
+ /******/ if (cachedModule !== undefined) {
869
+ /******/ return cachedModule.exports;
870
+ /******/ }
871
+ /******/ // Create a new module (and put it into the cache)
872
+ /******/ const module = __webpack_module_cache__[moduleId] = {
873
+ /******/ // no module.id needed
874
+ /******/ // no module.loaded needed
875
+ /******/ exports: {}
876
+ /******/ };
877
+ /******/
878
+ /******/ // Execute the module function
879
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
880
+ /******/
881
+ /******/ // Return the exports of the module
882
+ /******/ return module.exports;
883
+ /******/ }
884
+ /******/
885
+ /************************************************************************/
886
+ /******/ /* webpack/runtime/define property getters */
887
+ /******/ (() => {
888
+ /******/ // define getter/value functions for harmony exports
889
+ /******/ __webpack_require__.d = (exports, definition) => {
890
+ /******/ if(Array.isArray(definition)) {
891
+ /******/ var i = 0;
892
+ /******/ while(i < definition.length) {
893
+ /******/ var key = definition[i++];
894
+ /******/ var binding = definition[i++];
895
+ /******/ if(!__webpack_require__.o(exports, key)) {
896
+ /******/ if(binding === 0) {
897
+ /******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
898
+ /******/ } else {
899
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
900
+ /******/ }
901
+ /******/ } else if(binding === 0) { i++; }
902
+ /******/ }
903
+ /******/ } else {
904
+ /******/ for(var key in definition) {
905
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
906
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
907
+ /******/ }
908
+ /******/ }
909
+ /******/ }
910
+ /******/ };
911
+ /******/ })();
912
+ /******/
913
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
914
+ /******/ (() => {
915
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
916
+ /******/ })();
917
+ /******/
918
+ /************************************************************************/
919
+
920
+ // EXTERNAL MODULE: external "clientnode"
921
+ var external_clientnode_ = __webpack_require__(0);
922
+ // EXTERNAL MODULE: external "clientnode/property-types"
923
+ var property_types_ = __webpack_require__(1);
924
+ // EXTERNAL MODULE: external "react"
925
+ var external_react_ = __webpack_require__(6);
926
+ ;// external "@jest/globals"
927
+
928
+ // EXTERNAL MODULE: ./src/index.ts
929
+ var src = __webpack_require__(5);
930
+ // EXTERNAL MODULE: ./src/ReactWeb.ts + 2 modules
931
+ var ReactWeb = __webpack_require__(4);
932
+ // EXTERNAL MODULE: ./src/Web.ts
933
+ var Web = __webpack_require__(3);
934
+ ;// ./src/test.ts
935
+ // #!/usr/bin/env babel-node
936
+ // -*- coding: utf-8 -*-
937
+ /* !
938
+ region header
939
+ Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
940
+
941
+ License
942
+ -------
943
+
944
+ This library written by Torben Sickert stands under a creative commons
945
+ naming 3.0 unported license.
946
+ See https://creativecommons.org/licenses/by/3.0/deed.de
947
+ endregion
948
+ */// region imports
949
+ function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==typeof i?i:i+""}function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}// endregion
950
+ // region Web
951
+ __WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_describe__("Web",()=>{__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_test__("constructor",()=>{/**
952
+ * Mock Test class.
953
+ */class WebTest extends Web/* default */.Ay{}_defineProperty(WebTest,"observedAttributes",["is-root","on-click","on-event"]);__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(WebTest).toHaveProperty("content");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(WebTest).toHaveProperty("observedAttributes");customElements.define("test-web",WebTest);const web=document.createElement("test-web");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(web).not.toHaveProperty("clicked");web.setAttribute("on-click","this.clicked = true");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(web).not.toHaveProperty("clicked");document.body.appendChild(web);__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(web).toHaveProperty("rootInstance",web);__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(web).not.toHaveProperty("clicked");web.onClick();__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(web).toHaveProperty("clicked",true);const clickCallback=__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_jest__.fn();web.addEventListener("click",clickCallback);__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(clickCallback).not.toHaveBeenCalled();web.onClick();__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(clickCallback).toHaveBeenCalled()})});// endregion
954
+ // region ReactWeb
955
+ __WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_describe__("ReactWeb",()=>{__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_test__("constructor",async()=>{let triggerOnEvent;let componentProperty="initial";const component=({onEvent,property=componentProperty})=>{/*
956
+ eslint-enable @typescript-eslint/no-useless-default-assignment
957
+ */triggerOnEvent=onEvent;componentProperty=property;return (0,external_react_.createElement)("div",{className:property})};/**
958
+ * Mock test class.
959
+ */class TestReactWeb extends ReactWeb/* default */.Ay{constructor(...args){super(...args);_defineProperty(this,"self",TestReactWeb)}}_defineProperty(TestReactWeb,"_name","Test");_defineProperty(TestReactWeb,"content",component);_defineProperty(TestReactWeb,"observedAttributes",["is-root","on-click","on-event"]);_defineProperty(TestReactWeb,"propertyTypes",{...Web/* default */.Ay.propertyTypes,onEvent:property_types_.func,property:property_types_.string});__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(TestReactWeb).toHaveProperty("content");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(TestReactWeb).toHaveProperty("observedAttributes");customElements.define("test-react",TestReactWeb);const react=document.createElement("test-react");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(react).not.toHaveProperty("clicked");react.setAttribute("on-click","this.clicked = true");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(react).toHaveProperty("onClick");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(react).not.toHaveProperty("clicked");react.setAttribute("on-event","this.eventHappened = true");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(react).toHaveProperty("onEvent");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(triggerOnEvent).not.toBeDefined();document.body.appendChild(react);__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(react).toHaveProperty("rootInstance",react);__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(react).toHaveProperty("reactRoot");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(triggerOnEvent).not.toBeDefined();await (0,external_clientnode_.timeout)();__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(triggerOnEvent).toBeDefined();__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(react).not.toHaveProperty("eventHappened");if(triggerOnEvent)triggerOnEvent();__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(react).toHaveProperty("eventHappened",true);const eventCallback=__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_jest__.fn();react.addEventListener("event",eventCallback);__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(eventCallback).not.toHaveBeenCalled();if(triggerOnEvent)triggerOnEvent();__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(eventCallback).toHaveBeenCalled();__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(react).not.toHaveProperty("clicked");react.onClick();__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(react).toHaveProperty("clicked",true);const clickCallback=__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_jest__.fn();react.addEventListener("click",clickCallback);__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(clickCallback).not.toHaveBeenCalled();react.onClick();__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(clickCallback).toHaveBeenCalled();__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(componentProperty).toStrictEqual("initial");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(document.querySelector("div")?.className).toStrictEqual("initial");react.property="test";await (0,external_clientnode_.timeout)();__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(react).toHaveProperty("property","test");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(document.querySelector("div")?.className).toStrictEqual("test")})});// endregion
960
+ // region index
961
+ __WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_describe__("index",()=>{__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_test__("wrapAsWebComponent",()=>{const componentAPI=(0,src/* default */.Ay)(()=>(0,external_react_.createElement)("div"),"TestComponent",{eventToPropertyMapping:{},propertyAliases:{alternateName:"name"},propertiesToReflectAsAttributes:[],propTypes:{name:"string"}});__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(componentAPI).toHaveProperty("component");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(componentAPI).toHaveProperty("register");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(componentAPI.component).toHaveProperty("_name","TestComponent");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(componentAPI.component).toHaveProperty("propertyTypes.name","string");__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(componentAPI.component).toHaveProperty("propertiesToReflectAsAttributes",["isRoot"]);__WEBPACK_EXTERNAL_MODULE__jest_globals_d700ac6c_expect__(componentAPI.component).toHaveProperty("eventToPropertyMapping",{})})});// endregion