text: (()=>{const component={name:"submit",version:[7,3,1],ccm:"https://ccmjs.github.io/ccm/versions/ccm-24.1.1.js",config:{html:{entry:{class:"form-group"},label:{tag:"label",class:"item-label",inner:"%label%"},info:{tag:"span",class:"info",inner:[{tag:"input",type:"checkbox",id:"%id%"},{tag:"label",for:"%id%",inner:{tag:"span",class:"info-icon glyphicon glyphicon-info-sign"}},{tag:"span",class:"alert alert-info",inner:"%info%"}]},section:{class:"section",inner:[{tag:"input",type:"hidden",name:"%name%",value:"%value%"},{class:"items"},{class:"buttons btn-group",inner:[{tag:"a",class:"add btn btn-default btn-sm",role:"button",inner:{tag:"span",class:"glyphicon glyphicon-plus"},onclick:"%add%"},{tag:"a",class:"del btn btn-default btn-sm",role:"button",inner:{tag:"span",class:"glyphicon glyphicon-minus"},onclick:"%del%"}]}]}},css:["ccm.load",{context:"head",url:"https://ccmjs.github.io/akless-components/libs/bootstrap/css/font-face.css"},"https://ccmjs.github.io/akless-components/libs/bootstrap/css/bootstrap.css","https://ccmjs.github.io/akless-components/submit/resources/default.css"],data:{store:["ccm.store"]}},Instance:function(){const self=this;let $;let inputs;let element;this.ready=(async()=>{$=this.ccm.helper;this.submit=this.component;this.submit.config=await $.integrate(JSON.parse(this.config),this.submit.config);this.submit.config.parent=this;delete this.submit.config.inner;delete this.submit.config.data;if(this.entries&&!this.inner)convertData($.clone(this.entries));this.logger&&this.logger.log("ready",$.privatize(this,true));function convertData(data){self.inner=document.createDocumentFragment();data.forEach((entry,i)=>self.inner.appendChild(newItem(entry,i)));function newItem(entry,i){entry=$.format(entry,{nr:"<nr>"});if(!$.isObject(entry)||!entry.type)return $.html(entry);entry.id="item-"+(i+1);let entry_elem=$.html(self.html.entry);if(entry.label){entry_elem.appendChild($.html(self.html.label,entry));if(entry.info)entry_elem.querySelector(".item-label").appendChild($.html(self.html.info,entry))}delete entry.info;delete entry.id;switch(entry.type){case"color":case"date":case"datetime-local":case"email":case"file":case"month":case"number":case"password":case"range":case"search":case"tel":case"text":case"time":case"url":case"week":delete entry.label;entry.tag="input";entry.class="form-control";entry_elem.appendChild($.html(entry));break;case"app":delete entry.label;entry.tag="input";entry.class="form-control";entry_elem.appendChild($.html(entry));break;case"key":case"hidden":entry.tag="input";entry_elem=$.html(entry);break;case"checkbox":delete entry.label;entry.tag="input";entry_elem.appendChild($.html({class:"checkbox",inner:{tag:"label",inner:entry}}));break;case"multi-checkbox":entry.type="checkbox";case"radio":delete entry.label;entry.tag="input";entry.items.forEach(item=>{const label=item.label;delete item.label;item=Object.assign(item,entry);delete item.items;entry_elem.appendChild($.html({class:entry.type,inner:{tag:"label",inner:[item,label]}}))});break;case"multi-select":entry.multiple=true;case"select":delete entry.label;entry.tag="select";delete entry.type;entry.class="form-control";const items=entry.items;delete entry.items;const select_elem=$.html(entry);items.forEach(item=>{item.tag="option";if(item.label&&!item.inner){item.inner=item.label;delete item.label}select_elem.appendChild($.html(item))});entry_elem.appendChild(select_elem);break;case"textarea":delete entry.label;entry.tag="textarea";delete entry.type;entry.class="form-control";entry_elem.appendChild($.html(entry));break;case"contenteditable":delete entry.label;delete entry.type;entry.contenteditable=true;entry_elem.appendChild($.html(entry));break;case"object":entry.type="several";entry.items=[{label:"Key",name:"property",type:"text"},{label:"Value",name:"value",type:"text"}];case"several":if(entry.name){const callout_elem=$.html({class:"callout callout-primary"});const several_elem=$.html({tag:"several",name:entry.name});entry.items.forEach((item,i)=>callout_elem.appendChild(newItem(item,i)));several_elem.appendChild(callout_elem);entry_elem.appendChild(several_elem)}else{const several_elem=$.html({tag:"several"});const item_elem=newItem(entry.item);item_elem.classList.add("callout","callout-primary");several_elem.appendChild(item_elem);entry_elem.appendChild(several_elem)}break;case"submit":delete entry.label;entry.tag="input";entry.class="btn btn-primary";entry_elem.appendChild($.html(entry.name?{class:"callout",inner:entry}:entry));break;default:delete entry.label;entry.tag="input";entry.class="form-control";entry_elem.appendChild($.html({class:"callout",inner:entry}));break}return entry_elem}}});this.start=(async()=>{if(!this.inner)return;let dataset=await $.dataset(this.data);if(this.ignore)dataset=await $.integrate(this.ignore.defaults,dataset,true);this.logger&&this.logger.log("start",$.clone(dataset));inputs=[];const inner=$.html(this.inner);const content=this.content&&await this.content.start({inner:inner,css:JSON.parse(this.config).css});$.setContent(this.element,content?content.root:inner);element=content?content.element:this.element;element.classList.add("main");const form=document.createElement("form");element.parentNode.replaceChild(form,element);form.appendChild(element);await $.asyncForEach([...element.querySelectorAll("several")],handleSeveral);$.fillForm(element,dataset);await $.asyncForEach([...element.querySelectorAll("input")],handleSpecial);[...element.querySelectorAll("[name]")].forEach(elem=>{elem.onchange=(event=>{feedback(event.target);if(!elem.checkValidity())return;const value=$.deepValue(this.getValue(),elem.name);this.logger&&this.logger.log("change",{name:elem.name,value:$.clone(value)});this.onchange&&this.onchange.call(this,{name:elem.name,value:$.clone(value),event:event})});if(this.disabled)elem.disabled=true});feedback();const submit=element.querySelector("input[type=submit]");submit&&this.no_submit_button&&$.removeElement(submit);this.lang&&this.lang.translate();if(!submit)return;form.onsubmit=(async event=>{event.preventDefault();this.user&&await this.user.login();let results=this.getValue();this.logger&&this.logger.log("submit",$.clone(results));dataset=results;feedback();this.onfinish&&await $.onFinish(this,$.clone(results))});async function handleSeveral(several){if(several.hasAttribute("name")){const input=$.html({tag:"input",type:"submit",name:several.getAttribute("name")});input.setAttribute("inner",several.innerHTML);$.setContent(several,input)}let template=$.html({class:"item"});while(several.childNodes.length)template.appendChild(several.childNodes[0]);template=template.cloneNode(true);const name=template.querySelector("[name]").getAttribute("name");const section=$.html(self.html.section,{name:name,value:template.innerHTML.includes("property")&&template.innerHTML.includes("value")?"{}":"[]",add:addItem,del:delItem});$.replace(several,section);let value=$.deepValue(dataset,name);if(!value)value=$.deepValue(dataset,name,[]);if($.isObject(value)){const arr=[];$.deepValue(dataset,name,arr);for(const key in value)arr.push({property:key,value:value[key]});value=arr}value.forEach((value,i)=>dataset[name+"."+i]=value);for(let i=0;i<value.length;i++)await addItem(true);delete dataset[name];async function addItem(initial){const items=section.querySelector(".items");const item=template.cloneNode(true);const input=item.querySelector("[name]");$.append(items,item);input.setAttribute("name",input.getAttribute("name")+"."+(items.childElementCount-1));input.onchange=(event=>{const value=$.deepValue(self.getValue(),input.name);self.logger&&self.logger.log("change",{name:input.name,value:$.clone(value)});self.onchange&&self.onchange.call(self,{name:input.name,value:$.clone(value),event:event})});[...item.querySelectorAll("nr")].forEach(nr=>$.replace(nr,$.html({tag:"span",inner:items.childElementCount})));if(input.tagName==="SEVERAL")await handleSeveral(input);await handleSpecial(input);initial!==true&&self.onchange&&self.onchange.call(self,{name:input.name,value:$.deepValue(self.getValue(),input.name)})}function delItem(){const items=section.querySelector(".items");if(!items.hasChildNodes())return;inputs=inputs.filter(input=>!items.lastChild.querySelector("[id]")||input.instance.index!==items.lastChild.querySelector("[id]").id);items.childElementCount&&items.removeChild(items.lastChild);self.onchange&&self.onchange.call(self)}}async function handleSpecial(input){if(!input||!input.type)return;const type=input.getAttribute("type");switch(type){case"hidden":case"button":case"checkbox":case"color":case"date":case"datetime-local":case"email":case"file":case"image":case"month":case"number":case"password":case"radio":case"range":case"reset":case"search":case"tel":case"text":case"time":case"url":case"week":break;case"app":const dependency=dataset[input.name];if(!dependency||!self.helper||!self.helper.appURL)return;input.value=self.helper.appURL(dependency[1],dependency[2][1],dependency[2][2]);break;case"key":if(!input.value)input.value=$.generateKey();input.type="hidden";break;default:if(!$.deepValue(self,type))return;if(type==="submit"&&!input.getAttribute("name"))return;let instance;instance=await $.deepValue(self,type).start(await $.integrate({data:{store:["ccm.store",{config:$.deepValue($.solveDotNotation(dataset),input.name)}],key:"config"},onchange:function(){const value=this.getValue();delete value.key;instance&&self.logger&&self.logger.log("change",{name:input.name,value:$.clone(value),builder:instance});instance&&self.onchange&&self.onchange.call(self,{name:input.name,value:$.clone(value),builder:instance})}},$.generateConfig(input)));$.replace(input,instance.root);inputs.push({instance:instance,name:input.name})}}function feedback(elem){if(!elem)return[...element.querySelectorAll("[name]")].forEach(feedback);const name=elem.getAttribute("name");const input_value=$.deepValue(self.getValue(),name);const data_value=$.deepValue($.solveDotNotation(dataset),name);elem.classList.remove("changed","unchanged");elem.classList.add($.stringify(input_value)===$.stringify(data_value)||!input_value===!data_value===true?"unchanged":"changed")}});this.getValue=(()=>{let results=$.formData(element);[...element.querySelectorAll('input[type="app"]')].forEach(input=>{if(!results[input.name]||!this.helper||!this.helper.decomposeAppURL)return;const app=this.helper.decomposeAppURL(results[input.name]);const instance=["ccm.instance",app.component,["ccm.get",app.store,app.key]];results[input.name]=instance});inputs.forEach(input=>{const result=input.instance.getValue();delete result.key;const keys=Object.keys(result);if(keys.length===2&&keys.every(key=>["property","value"].includes(key)))result.property&&$.deepValue(results,input.name.substr(0,input.name.lastIndexOf("."))+"."+result.property,result.value);else $.deepValue(results,input.name,result)});return $.clone(results)})}};let b="ccm."+component.name+(component.version?"-"+component.version.join("."):"")+".js";if(window.ccm&&null===window.ccm.files[b])return window.ccm.files[b]=component;(b=window.ccm&&window.ccm.components[component.name])&&b.ccm&&(component.ccm=b.ccm);"string"===typeof component.ccm&&(component.ccm={url:component.ccm});let c=(component.ccm.url.match(/(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)/)||["latest"])[0];if(window.ccm&&window.ccm[c])window.ccm[c].component(component);else{var a=document.createElement("script");document.head.appendChild(a);component.ccm.integrity&&a.setAttribute("integrity",component.ccm.integrity);component.ccm.crossorigin&&a.setAttribute("crossorigin",component.ccm.crossorigin);a.onload=function(){window.ccm[c].component(component);document.head.removeChild(a)};a.src=component.ccm.url}})();