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