/*! Uhm v0.8.0 | MIT LICENSE | https://github.com/n2geoff/uhm */functionapp(mount="body",opts={}){conststate=opts.state||{},view=opts.view||(()=>null),actions=opts.actions||{};constupdate=()=>{constparentNode="string"==typeofmount?document.querySelector(mount):mount;letresult=view(state,actions);if(Array.isArray(result)){constfragment=document.createDocumentFragment();fragment.append(...result.filter((node=>null!=node))),result=fragment}elseif("string"==typeofresult){consttemp=document.createElement(parentNode.tagName);temp.innerHTML=result,result=temp}diff.merge(parentNode,result)};returnopts.view&&mount&&function(data,actions){Object.entries(actions).forEach((([name,action])=>{"function"==typeofaction&&(actions[name]=(...args)=>{Object.assign(state,action(data,...args)),setTimeout((()=>update()),20)})})),update()}(state,actions),{state:state,update:update}}functionh(tagName,props,...children){constel=tagName===DocumentFragment?document.createDocumentFragment():document.createElement(tagName),booleanAttrs=["disabled","checked","selected","hidden","readonly","required","open","autoplay","loop","muted"];if(null==props||"object"!=typeofprops||Array.isArray(props))null!=props&&children.unshift(props);elsefor(const[key,value]ofObject.entries(props))null!=value&&(booleanAttrs.includes(key)?!0===value?(el.setAttribute(key,""),el[key]=!0):!1===value&&(el.removeAttribute(key),el[key]=!1):key.startsWith("on")&&"function"==typeofvalue?el.addEventListener(key.slice(2).toLowerCase(),value):"class"!==key?"style"!==key||"object"!=typeofvalue?(el.setAttribute(key,value),keyinel&&(el[key]=value)):Object.assign(el.style,value):el.className=value);for(constchildofchildren)if(null!=child)if("string"==typeof(value=child)||"number"==typeofvalue)el.appendChild(document.createTextNode(child));elseif(Array.isArray(child)){constfragment=document.createDocumentFragment();fragment.append(...child.filter((c=>null!=c))),el.appendChild(fragment)}elsechildinstanceofNode?el.appendChild(child):"boolean"==typeofchild?console.warn(`Boolean child ${child} passed to h() for tag "${tagName}". Booleans are not rendered.`):console.error(`Unsupported child type: ${typeofchild} for tag "${tagName}" in h() function`);varvalue;returnel}
/*! xhtm v1.6.2 | MIT LICENSE | https://github.com/dy/xhtm */constFIELD="",QUOTES="";functionhtm(statics){letargs,name,value,last,h=this,prev=0,current=[null],field=0,quotes=[],quote=0,level=0,pre=!1;constevaluate=(str,parts=[],raw)=>{leti=0;return(str=raw||""!==str?str.replace(/\ue001/g,(m=>quotes[quote++])):quotes[quote++].slice(1,-1))?(str.replace(/\ue000/g,((match,idx)=>(idx&&parts.push(str.slice(i,idx)),i=idx+1,parts.push(arguments[++field])))),i<str.length&&parts.push(str.slice(i)),parts.length>1?parts:parts[0]):str},up=()=>{[current,last,...args]=current,current.push(h(last,...args)),pre===level--&&(pre=!1)};returnstatics.join("").replace(/<!--[^]*?-->/g,"").replace(/<!\[CDATA\[[^]*\]\]>/g,"").replace(/('|")[^\1]*?\1/g,(match=>(quotes.push(match),""))).replace(/(?:^|>)((?:[^<]|<[^\w\ue000\/?!>])*)(?:$|<)/g,((match,text,idx,str)=>{lettag,close;if(idx&&str.slice(prev,idx).replace(/(\S)\/$/,"$1 /").split(/\s+/).map(((part,i)=>{if("/"===part[0]){if(part=part.slice(1),EMPTY[part])return;close=tag||part||1}elseif(i){if(part){letprops=current[2]||(current[2]={});"..."===part.slice(0,3)?Object.assign(props,arguments[++field]):([name,value]=part.split("="),Array.isArray(value=props[evaluate(name)]=!value||evaluate(value))&&(value.toString=value.join.bind(value,"")))}}else{if(tag=evaluate(part),"string"==typeoftag)for(tag=tag.toLowerCase();CLOSE[current[1]+tag];)up();current=[current,tag,null],level++,!pre&&PRE[tag]&&(pre=level),EMPTY[tag]&&(close=tag)}})),close)for(current[0]||err(`Wrong close tag \`${close}\``),up();last!==close&&CLOSE[last];)up();prev=idx+match.length,pre||(text=text.replace(/\s*\n\s*/g,"").replace(/\s+/g," ")),text&&evaluate((last=0,text),current,!0)})),current[0]&&CLOSE[current[1]]&&up(),level&&err(`Unclosed \`${current[1]}\`.`),current.length<3?current[1]:(current.shift(),current)}consterr=msg=>{throwSyntaxError(msg)},EMPTY=htm.empty={},CLOSE=htm.close={},PRE=htm.pre={},html=htm.bind(h);export{app,h,html};