// Metawidget 4.1 minified
//
// This file is dual licensed under both the LGPL
// (http://www.gnu.org/licenses/lgpl-2.1.html) and the EPL
// (http://www.eclipse.org/org/documents/epl-v10.php). As a
// recipient of Metawidget, you may choose to receive it under either
// the LGPL or the EPL.
//
// Commercial licenses are also available. See http://metawidget.org
// for details.
//
// Author: Richard Kennard (http://kennardconsulting.com)

var metawidget=metawidget||{};(function(){metawidget.inspectionresultprocessor=metawidget.inspectionresultprocessor||{}})();
var metawidget=metawidget||{};(function(){metawidget.inspector=metawidget.inspector||{};metawidget.inspector.CompositeInspector=function(a){if(!(this instanceof metawidget.inspector.CompositeInspector)){throw new Error("Constructor called as a function")}var b;if(a.inspectors!==undefined){b=a.inspectors.slice(0)}else{b=a.slice(0)}this.inspect=function(j,d,h){var e={};for(var c=0,g=b.length;c<g;c++){var f;var i=b[c];if(i.inspect!==undefined){f=i.inspect(j,d,h)}else{f=i(j,d,h)}metawidget.util.combineInspectionResults(e,f)}return e}};metawidget.inspector.PropertyTypeInspector=function(){if(!(this instanceof metawidget.inspector.PropertyTypeInspector)){throw new Error("Constructor called as a function")}};metawidget.inspector.PropertyTypeInspector.prototype.inspect=function(f,b,e){function a(g){if(g instanceof Array){return"array"}else{if(g instanceof Date){return"date"}else{var h=typeof(g);if(h!=="object"){return h}}}}f=metawidget.util.traversePath(f,e);var d={};if(e!==undefined&&e.length>0){d.name=e[e.length-1]}else{if(f===undefined){return}}if(f!==undefined){d.type=a(f);if(d.type===undefined){d.properties={};for(var c in f){d.properties[c]={type:a(f[c])}}}}return d};metawidget.inspector.JsonSchemaInspector=function(a){if(!(this instanceof metawidget.inspector.JsonSchemaInspector)){throw new Error("Constructor called as a function")}var b;if(a.schema!==undefined){b=a.schema}else{b=a}this.inspect=function(j,e,i){function d(o,n){if(o===undefined){return undefined}if(n!==undefined){if(!(n instanceof Array)){throw new Error("Expected array of names")}for(var k=0,m=n.length;k<m;k++){var l=n[k];if(!isNaN(l)){o=o.items;if(o===undefined){return undefined}continue}o=o.properties;if(o===undefined){return undefined}o=o[l];if(o===undefined){return undefined}}}return o}var h=d(b,i);if(h===undefined){return undefined}var g={};if(i!==undefined){g.name=i[i.length-1]}metawidget.util.combineInspectionResults(g,h);if(g.required!==undefined){for(var c=0,f=g.required.length;c<f;c++){g.properties[g.required[c]].required=true
}}return g}}})();
var metawidget=metawidget||{};(function(){metawidget.layout=metawidget.layout||{};metawidget.layout.SimpleLayout=function(){if(!(this instanceof metawidget.layout.SimpleLayout)){throw new Error("Constructor called as a function")}};metawidget.layout.SimpleLayout.prototype.layoutWidget=function(d,a,c,b){if(d.tagName==="STUB"&&!metawidget.util.hasChildElements(d)){return}b.appendChild(d)};metawidget.layout.DefinitionListLayout=function(b){if(!(this instanceof metawidget.layout.DefinitionListLayout)){throw new Error("Constructor called as a function")}var c=b!==undefined?b.labelStyleClass:undefined;var a=b!==undefined&&b.labelSuffix!==undefined?b.labelSuffix:":";this.startContainerLayout=function(d,g){var e=metawidget.util.createElement(g,"dl");if(g.path!==undefined){var f=metawidget.util.getId("property",{},g);if(f!==undefined){e.setAttribute("id","dl-"+f)}}d.appendChild(e)};this.layoutWidget=function(i,e,g,f,j){if(i.tagName==="STUB"&&!metawidget.util.hasChildElements(i)){return}var h=f.childNodes[f.childNodes.length-1];this.layoutLabel(h,i,e,g,j);var d=metawidget.util.createElement(j,"dd");d.appendChild(i);h.appendChild(d)};this.layoutLabel=function(h,j,d,e,k){if(d==="entity"||d==="action"){return}if(e.name===undefined&&e.title===undefined){return}var g=metawidget.util.getLabelString(e,k);if(g===""||g===null){return}var i=metawidget.util.createElement(k,"dt");var f=metawidget.util.createElement(k,"label");if(j.getAttribute("id")!==null){f.setAttribute("for",j.getAttribute("id"))}if(c!==undefined){f.setAttribute("class",c)}f.innerHTML=g+a;i.appendChild(f);h.appendChild(i)}};metawidget.layout.DivLayout=function(b){if(!(this instanceof metawidget.layout.DivLayout)){throw new Error("Constructor called as a function")}var c=b!==undefined?b.divStyleClasses:undefined;var h=b!==undefined?b.labelStyleClass:undefined;var g=b!==undefined&&b.labelSuffix!==undefined?b.labelSuffix:":";var f=b!==undefined&&b.suppressDivAroundLabel!==undefined?b.suppressDivAroundLabel:false;var e=b!==undefined&&b.suppressDivAroundWidget!==undefined?b.suppressDivAroundWidget:false;
var d=b!==undefined&&b.appendRequiredClassOnLabelDiv!==undefined?b.appendRequiredClassOnLabelDiv:undefined;var j=b!==undefined&&b.appendRequiredClassOnWidgetDiv!==undefined?b.appendRequiredClassOnWidgetDiv:undefined;var k=b!==undefined&&b.suppressLabelSuffixOnCheckboxes!==undefined?b.suppressLabelSuffixOnCheckboxes:false;var i=b!==undefined&&b.wrapInsideLabels!==undefined?b.wrapInsideLabels:undefined;var a=b!==undefined&&b.wrapWithExtraDiv!==undefined?b.wrapWithExtraDiv:undefined;this.layoutWidget=function(s,x,q,l,w){if(s.tagName==="STUB"&&!metawidget.util.hasChildElements(s)){return}if(s.tagName==="INPUT"&&(s.getAttribute("type")==="button"||s.getAttribute("type")==="submit")){if(l.childNodes.length>0){var o=l.childNodes[l.childNodes.length-1];if(o.childNodes.length===1){var u=o.childNodes[0];if(u.childNodes.length>0){var m=u.childNodes[u.childNodes.length-1];if(m.tagName==="INPUT"&&(m.getAttribute("type")==="button"||m.getAttribute("type")==="submit")){u.appendChild(s);return}}}}}var v=metawidget.util.createElement(w,"div");if(c!==undefined&&c[0]!==undefined){v.setAttribute("class",c[0])}var n=this.layoutLabel(v,s,x,q,w);var p=s;if(s.tagName==="INPUT"&&metawidget.util.niceIndexOf(i,s.getAttribute("type"))!==-1){n.insertBefore(s,n.firstChild);p=n}else{p=s}if(s.tagName==="INPUT"&&a!==undefined&&a[s.getAttribute("type")]!==undefined){var t=metawidget.util.createElement(w,"div");t.setAttribute("class",a[s.getAttribute("type")]);t.appendChild(p);p=t}if(e!==true){var r=metawidget.util.createElement(w,"div");if(c!==undefined&&c[2]!==undefined){r.setAttribute("class",c[2])}if(metawidget.util.isTrueOrTrueString(q.required)&&j!==undefined){metawidget.util.appendToAttribute(r,"class",j)}r.appendChild(p);p=r}v.appendChild(p);l.appendChild(v)};this.layoutLabel=function(p,q,l,m,s){if(l==="entity"||l==="action"){return}if(m.name===undefined&&m.title===undefined){return}var o=this.getLabelString(q,m,s);if(o===""||o===null){return}var n=metawidget.util.createElement(s,"label");if(q.getAttribute("id")!==null){n.setAttribute("for",q.getAttribute("id"));
n.setAttribute("id",q.getAttribute("id")+"-label")}if(h!==undefined){n.setAttribute("class",h)}n.innerHTML=o;if(f===true){p.appendChild(n)}else{var r=metawidget.util.createElement(s,"div");if(c!==undefined&&c[1]!==undefined){r.setAttribute("class",c[1])}if(metawidget.util.isTrueOrTrueString(m.required)&&d!==undefined){metawidget.util.appendToAttribute(r,"class",d)}r.appendChild(n);p.appendChild(r)}return n};this.getLabelString=function(n,l,o){var m=metawidget.util.getLabelString(l,o);if(m===""||m===null){return m}if(k===true&&n.tagName==="INPUT"){if(n.getAttribute("type")==="checkbox"||n.getAttribute("type")==="radio"){return m}}return m+g}};metawidget.layout.TableLayout=function(d){if(!(this instanceof metawidget.layout.TableLayout)){throw new Error("Constructor called as a function")}var f=d!==undefined?d.tableStyleClass:undefined;var g=d!==undefined?d.columnStyleClasses:undefined;var a=d!==undefined?d.headerStyleClass:undefined;var c=d!==undefined?d.footerStyleClass:undefined;var e=d!==undefined&&d.numberOfColumns?d.numberOfColumns:1;var b=0;this.startContainerLayout=function(h,p){var q=metawidget.util.createElement(p,"table");if(p.path!==undefined){var i=metawidget.util.getId("property",{},p);if(i!==undefined){q.setAttribute("id","table-"+i)}}if(f!==undefined){q.setAttribute("class",f)}h.appendChild(q);if(p.overriddenNodes!==undefined){for(var n=0,j=p.overriddenNodes.length;n<j;n++){var k=p.overriddenNodes[n];if(k.tagName!=="FACET"){continue}var o;if(k.getAttribute("name")==="header"){o=metawidget.util.createElement(p,"thead")}else{if(k.getAttribute("name")==="footer"){o=metawidget.util.createElement(p,"tfoot")}else{continue}}q.appendChild(o);var m=metawidget.util.createElement(p,"tr");o.appendChild(m);var l=metawidget.util.createElement(p,"td");l.setAttribute("colspan",e*3);if(k.getAttribute("name")==="header"){if(a!==undefined){l.setAttribute("class",a)}}else{if(c!==undefined){l.setAttribute("class",c)}}m.appendChild(l);while(k.childNodes.length>0){l.appendChild(k.removeChild(k.childNodes[0]))
}}}q.appendChild(metawidget.util.createElement(p,"tbody"))};this.layoutWidget=function(m,r,k,i,p){if(m.tagName==="STUB"&&!metawidget.util.hasChildElements(m)){return}var n=metawidget.util.isSpanAllColumns(k);if(n===true&&b>0){b=0}var q=i.childNodes[i.childNodes.length-1];var h=undefined;if(k.name!==undefined){if(metawidget.util.hasAttribute(q,"id")){h=q.getAttribute("id")}if(h!==undefined){if(r!=="entity"){if(h.charAt(h.length-1)!=="-"){h+=metawidget.util.capitalize(k.name)}else{h+=k.name}}}else{h="table-"+k.name}}var l=q.childNodes[q.childNodes.length-1];var o;if(b===0){o=metawidget.util.createElement(p,"tr");if(h!==undefined){o.setAttribute("id",h+"-row")}l.appendChild(o)}else{o=l.childNodes[l.childNodes.length-1]}this.layoutLabel(o,h,m,r,k,p);var j=metawidget.util.createElement(p,"td");if(h!==undefined){j.setAttribute("id",h+"-cell")}if(g!==undefined&&g[1]!==undefined){j.setAttribute("class",g[1])}if(n===true){j.setAttribute("colspan",((e*3)-1)-o.childNodes.length)}else{if(o.childNodes.length<1){j.setAttribute("colspan",2-o.childNodes.length)}}j.appendChild(m);o.appendChild(j);this.layoutRequired(o,k,p);if(n===true){b=e-1}b=(b+1)%e};this.layoutLabel=function(m,h,l,p,k,o){if(p==="entity"){return}if(k.name===undefined&&k.title===undefined){return}var j=this.getLabelString(k,o);if(j===null){return}var i=metawidget.util.createElement(o,"th");if(h!==undefined){i.setAttribute("id",h+"-label-cell")}if(g!==undefined&&g[0]!==undefined){i.setAttribute("class",g[0])}if(p!=="action"&&j!==""){var n=metawidget.util.createElement(o,"label");if(metawidget.util.hasAttribute(l,"id")){n.setAttribute("for",l.getAttribute("id"))}if(h!==undefined){n.setAttribute("id",h+"-label")}n.innerHTML=j;i.appendChild(n)}m.appendChild(i)};this.layoutRequired=function(i,h,k){var j=metawidget.util.createElement(k,"td");if(g!==undefined&&g[2]!==undefined){j.setAttribute("class",g[2])}if(!metawidget.util.isTrueOrTrueString(h.readOnly)&&metawidget.util.isTrueOrTrueString(h.required)){j.innerHTML="*"}i.appendChild(j)
};this.getLabelString=function(h,j){var i=metawidget.util.getLabelString(h,j);if(i===""||i===null){return i}return i+":"}};metawidget.layout._createSectionLayoutDecorator=function(b,a,d){var c;if(b.delegate!==undefined){c=b.delegate}else{c=b}a.getDelegate=function(){return c};a.onStartBuild=function(e){if(a.getDelegate().onStartBuild!==undefined){a.getDelegate().onStartBuild(e)}};a.startContainerLayout=function(e,f){e[d]={};if(a.getDelegate().startContainerLayout!==undefined){a.getDelegate().startContainerLayout(e,f)}};a.endContainerLayout=function(e,f){if(a.getDelegate().endContainerLayout!==undefined){a.getDelegate().endContainerLayout(e,f)}e[d]={}};a.onEndBuild=function(e){if(a.getDelegate().onEndBuild!==undefined){a.getDelegate().onEndBuild(e)}}};metawidget.layout.createFlatSectionLayoutDecorator=function(b,a,c){if(this instanceof metawidget.layout.createFlatSectionLayoutDecorator){throw new Error("Function called as a Constructor")}metawidget.layout._createSectionLayoutDecorator(b,a,c);a.layoutWidget=function(g,l,f,e,j){var i;if(a.getDelegate().nestedSectionLayoutDecorator===true){i=metawidget.util.stripSection(f);if(i===undefined||i===e[c].currentSection){return a.getDelegate().layoutWidget(g,l,f,e,j)}if(e[c].currentSection!==undefined){a.getDelegate().endContainerLayout(e,j)}e[c].currentSection=i;if(i!==""){a.addSectionWidget(i,0,f,e,j)}}else{if(f.section===undefined||f.section===e[c].currentSection){return a.getDelegate().layoutWidget(g,l,f,e,j)}var k=f.section;if(!(k instanceof Array)){k=[k]}var h;if(e[c].currentSection!==undefined){h=e[c].currentSection}else{h=[]}for(var d=0;d<k.length;d++){i=k[d];if(i===""){continue}if(d<h.length&&i===h[d]){continue}a.addSectionWidget(i,d,f,e,j)}e[c].currentSection=k}a.getDelegate().layoutWidget(g,l,f,e,j)}};metawidget.layout.createNestedSectionLayoutDecorator=function(b,a,d){if(this instanceof metawidget.layout.createNestedSectionLayoutDecorator){throw new Error("Function called as a Constructor")}metawidget.layout._createSectionLayoutDecorator(b,a,d);
a.nestedSectionLayoutDecorator=true;a.layoutWidget=function(i,e,g,f,k){var j=metawidget.util.stripSection(g);if(j===undefined||j===f[d].currentSection){if(f[d].currentSectionWidget){return a.getDelegate().layoutWidget(i,e,g,f[d].currentSectionWidget,k)}return a.getDelegate().layoutWidget(i,e,g,f,k)}if(f[d].currentSectionWidget!==undefined){a.endContainerLayout(f[d].currentSectionWidget,k)}f[d].currentSection=j;var h=f[d].currentSectionWidget;delete f[d].currentSectionWidget;if(j===""){a.getDelegate().layoutWidget(i,e,g,f,k);return}f[d].currentSectionWidget=a.createSectionWidget(h,j,g,f,k);a.startContainerLayout(f[d].currentSectionWidget,k);a.getDelegate().layoutWidget(i,e,g,f[d].currentSectionWidget,k)};var c=a.endContainerLayout;a.endContainerLayout=function(e,f){if(e[d].currentSectionWidget!==undefined){a.endContainerLayout(e[d].currentSectionWidget,f)}c.call(this,e,f)}};metawidget.layout.HeadingTagLayoutDecorator=function(a){if(!(this instanceof metawidget.layout.HeadingTagLayoutDecorator)){throw new Error("Constructor called as a function")}metawidget.layout.createFlatSectionLayoutDecorator(a,this,"headingTagLayoutDecorator")};metawidget.layout.HeadingTagLayoutDecorator.prototype.addSectionWidget=function(d,f,b,a,e){var c=metawidget.util.createElement(e,"h"+(f+1));c.innerHTML=d;this.getDelegate().layoutWidget(c,"property",{wide:"true"},a,e)};metawidget.layout.DivLayoutDecorator=function(a){if(!(this instanceof metawidget.layout.DivLayoutDecorator)){throw new Error("Constructor called as a function")}metawidget.layout.createNestedSectionLayoutDecorator(a,this,"divLayoutDecorator")};metawidget.layout.DivLayoutDecorator.prototype.createSectionWidget=function(c,d,b,a,f){var e=metawidget.util.createElement(f,"div");e.setAttribute("title",d);this.getDelegate().layoutWidget(e,"property",{wide:"true"},a,f);return e}})();
var metawidget=metawidget||{};(function(){metawidget.util=metawidget.util||{};metawidget.util.getLabelString=function(b,d){if(b.title!==undefined){if(b.title===null){return null}return metawidget.util.getLocalizedString(b.title,d)}var c=b.name;if(d.l10n!==undefined&&d.l10n[c]!==undefined){return d.l10n[c]}return metawidget.util.uncamelCase(c)};metawidget.util.uncamelCase=function(e){function b(l){var k=l.charCodeAt(0);return(k>=48&&k<=57)}function g(l){var k=l.charCodeAt(0);return(k>=65&&k<=90)||(k>=97&&k<=122)}var h="";var i=true;var f=" ";for(var d=0;d<e.length;d++){var j=e.charAt(d);if(i===true){h+=j.toUpperCase();i=false}else{if(a(j)&&(!a(f)||(d<e.length-1&&e[d+1]!==" "&&!a(e[d+1])))){if(f!==" "){h+=" "}h+=j}else{if(b(j)&&g(f)&&f!==" "){h+=" "+j}else{h+=j}}}f=j}return h};metawidget.util.getLocalizedString=function(c,d){var b=metawidget.util.camelCase(c);if(d.l10n!==undefined&&d.l10n[b]!==undefined){return d.l10n[b]}return c};metawidget.util.decapitalize=function(b){if(b.length===0){return b}var c=b.charAt(0);if(!a(c)){return b}if(b.length>1){if(a(b.charAt(1))){return b}}return b.charAt(0).toLowerCase()+b.slice(1)};metawidget.util.capitalize=function(b){if(b.length===0){return b}if(b.length>1){if(a(b.charAt(1))){return b}}return b.charAt(0).toUpperCase()+b.slice(1)};metawidget.util.isTrueOrTrueString=function(b){return(b==="true"||b===true)};metawidget.util.camelCase=function(e){if(!(e instanceof Array)){e=e.split(" ")}var d="";var c=e.length;if(c>0){d+=metawidget.util.decapitalize(e[0])}for(var b=1;b<c;b++){d+=metawidget.util.capitalize(e[b])}return d};metawidget.util.fillString=function(b,d){var c="";for(;;){if(d&1){c+=b}d>>=1;if(d){b+=b}else{break}}return c};metawidget.util.lookupEnumTitle=function(d,e,b){var c=e.indexOf(d);if(c===-1||c>=b.length){c=e.indexOf(""+d);if(c===-1||c>=b.length){return d}}return b[c]};metawidget.util.getId=function(b,d,f){if(f.path!==undefined){var c=f.path.split(".");if(c[0]==="object"){c=c.slice(1)}if(d.name&&b!=="entity"){c.push(d.name)
}else{if(c.length===0){return undefined}}var e=metawidget.util.camelCase(c);e=e.replace(/[\[\]]/g,"");return e}if(d!==undefined){return d.name}};metawidget.util.hasChildElements=function(d){var e=d.childNodes;for(var b=0,c=e.length;b<c;b++){if(e[b].nodeType===1){return true}}return false};metawidget.util.isSpanAllColumns=function(b){if(b===undefined){return false}if(metawidget.util.isTrueOrTrueString(b.large)){return true}return metawidget.util.isTrueOrTrueString(b.wide)};metawidget.util.splitPath=function(g){var c={};if(g!==undefined){var f=g.match(/([^\.\[\]]*)/g);c.type=f[0];for(var b=1,e=f.length;b<e;b++){if(f[b]===""){continue}if(c.names===undefined){c.names=[]}var d=f[b].match(/^(?:\s*(?:\'|\"))([^\']*)(?:(?:\'|\")\s*)$/);if(d!==null&&d[1]!==undefined){f[b]=d[1]}c.names.push(f[b])}}return c};metawidget.util.appendPath=function(b,c){if(c.path!==undefined){return metawidget.util.appendPathWithName(c.path,b)}if(c.toInspect!==undefined){return metawidget.util.appendPathWithName(typeof(c.toInspect),b)}return metawidget.util.appendPathWithName("object",b)};metawidget.util.appendPathWithName=function(d,b){var c=b.name;if(metawidget.util.isTrueOrTrueString(b.nameIncludesSeparator)){return d+c}if(c.indexOf(".")!==-1||c.indexOf("'")!==-1||c.indexOf('"')!==-1||c.indexOf(" ")!==-1){return d+"['"+c.replace("'","\\'")+"']"}return d+"."+c};metawidget.util.traversePath=function(e,d){if(e===undefined){return undefined}if(d!==undefined){if(!(d instanceof Array)){throw new Error("Expected array of names")}for(var b=0,c=d.length;b<c;b++){e=e[d[b]];if(e===undefined){return undefined}}}return e};metawidget.util.getSortedInspectionResultProperties=function(e){var d=[];if(e!==undefined){for(var b in e.properties){var c=e.properties[b];d.push(c);c.name=b;c._syntheticOrder=d.length}d.sort(function(g,f){if(g.propertyOrder===undefined){if(f.propertyOrder===undefined){return(g._syntheticOrder-f._syntheticOrder)}return 1}if(f.propertyOrder===undefined){return -1}var h=(g.propertyOrder-f.propertyOrder);
if(h===0){return(g._syntheticOrder-f._syntheticOrder)}return h})}return d};metawidget.util.combineInspectionResults=function(d,c){if(c===undefined){return}e(c,d);if(c.properties===undefined){return}d.properties=d.properties||{};for(var b in c.properties){d.properties[b]=d.properties[b]||{};e(c.properties[b],d.properties[b])}function e(i,h){for(var g in i){var f=i[g];if(f instanceof Array){h[g]=f.slice(0);continue}if(f instanceof Object){continue}h[g]=i[g]}}};metawidget.util.stripSection=function(b){var c=b.section;if(c===undefined){return undefined}if(!(c instanceof Array)){delete b.section;return c}switch(c.length){case 0:delete b.section;return"";case 1:delete b.section;return c[0];default:b.section=c.slice(1);return c[0]}};metawidget.util.appendToAttribute=function(e,d,c,f){var b=e.getAttribute(d);if(f===undefined){f=" "}if(b===null){e.setAttribute(d,c);return}if(b.toString!==undefined){b=b.toString()}if(b!==c&&b.indexOf(c+f)===-1&&b.indexOf(f+c)===-1){e.setAttribute(d,b+f+c)}};metawidget.util.createElement=function(c,b){if(c.ownerDocument!==undefined){return c.ownerDocument.createElement(b.toUpperCase())}return c.getElement().ownerDocument.createElement(b.toUpperCase())};metawidget.util.createTextNode=function(c,b){if(c.ownerDocument!==undefined){return c.ownerDocument.createTextNode(b)}return c.getElement().ownerDocument.createTextNode(b)};metawidget.util.createEvent=function(d,b){var c;if(d.ownerDocument!==undefined){c=d.ownerDocument.createEvent("Event")}else{c=d.getElement().ownerDocument.createEvent("Event")}c.initEvent(b,true,true);return c};metawidget.util.niceIndexOf=function(c,b){if(c===undefined||b===undefined){return -1}return c.indexOf(b)};metawidget.util.hasAttribute=function(b,c){if(b.hasAttribute!==undefined){return b.hasAttribute(c)}return(b.getAttribute(c)!==null)};function a(d){var b=d.charCodeAt(0);return(b>=65&&b<=90)}})();
var metawidget=metawidget||{};(function(a){function c(d){var e=this.getAttribute(d);if(e===null){return}var f=metawidget.util.splitPath(e);if(f===undefined){return}var g=a[f.type];return metawidget.util.traversePath(g,f.names)}if(a.document!==undefined&&a.document.registerElement!==undefined){var b=Object.create(HTMLElement.prototype);b.attachedCallback=function(){var d=this.createShadowRoot();this._pipeline=new metawidget.Pipeline(d);this._pipeline.inspector=new metawidget.inspector.PropertyTypeInspector();this._pipeline.widgetBuilder=new metawidget.widgetbuilder.CompositeWidgetBuilder([new metawidget.widgetbuilder.OverriddenWidgetBuilder(),new metawidget.widgetbuilder.ReadOnlyWidgetBuilder(),new metawidget.widgetbuilder.HtmlWidgetBuilder()]);this._pipeline.widgetProcessors=[new metawidget.widgetprocessor.IdProcessor(),new metawidget.widgetprocessor.RequiredAttributeProcessor(),new metawidget.widgetprocessor.PlaceholderAttributeProcessor(),new metawidget.widgetprocessor.DisabledAttributeProcessor(),new metawidget.widgetprocessor.SimpleBindingProcessor()];this._pipeline.layout=new metawidget.layout.HeadingTagLayoutDecorator(new metawidget.layout.TableLayout());this._pipeline.configure([c.call(this,"config"),this.config]);this.buildWidgets()};b.attributeChangedCallback=function(f,d,e){if(this._pipeline===undefined){return}switch(f){case"path":this.buildWidgets();break;case"readonly":this.buildWidgets();break;case"config":this._pipeline.configure(c.call(this,"config"));break}};b.clearWidgets=function(){while(this.shadowRoot.childNodes.length>0){this.shadowRoot.removeChild(this.shadowRoot.childNodes[0])}};b.buildWidgets=function(g){this.overriddenNodes=[];for(var d=0,f=this.childNodes.length;d<f;d++){if(this.childNodes[d].nodeType===1){this.overriddenNodes.push(this.childNodes[d].cloneNode(true))}}if(this.getAttribute("path")!==null){this.path=this.getAttribute("path");this.readOnly=metawidget.util.isTrueOrTrueString(this.getAttribute("readonly"));if(g===undefined){if(arguments.length>0){throw new Error("Calling buildWidgets( undefined ) may cause infinite loop. Check your argument, or pass no arguments instead")
}var e=metawidget.util.splitPath(this.path);this.toInspect=a[e.type];g=this._pipeline.inspect(this.toInspect,e.type,e.names,this)}}this._pipeline.buildWidgets(g,this)};b.buildNestedMetawidget=function(d,e){var f=metawidget.util.createElement(this,"x-metawidget");f.getMetawidget=function(){return f};f.setAttribute("path",metawidget.util.appendPath(d,this));f.setAttribute("readonly",this.readOnly||metawidget.util.isTrueOrTrueString(d.readOnly));f.config=this._pipeline;return f};b.save=function(){this.getWidgetProcessor(function(d){return d instanceof metawidget.widgetprocessor.SimpleBindingProcessor}).save(this)};b.inspect=function(f,d,e){return this._pipeline.inspect(f,d,e,this)};b.getWidgetProcessor=function(d){return this._pipeline.getWidgetProcessor(d)};b.setLayout=function(d){this._pipeline.layout=d};a.document.registerElement("x-metawidget",{prototype:b})}})(this);
var metawidget=metawidget||{};(function(){metawidget.widgetbuilder=metawidget.widgetbuilder||{};metawidget.widgetbuilder.CompositeWidgetBuilder=function(a){if(!(this instanceof metawidget.widgetbuilder.CompositeWidgetBuilder)){throw new Error("Constructor called as a function")}var c;if(a.widgetBuilders!==undefined){c=a.widgetBuilders.slice(0)}else{c=a.slice(0)}function b(g,h){for(var d=0,f=c.length;d<f;d++){var e=c[d];if(e[g]!==undefined){e[g](h)}}}this.onStartBuild=function(d){b("onStartBuild",d)};this.buildWidget=function(d,f,j){for(var e=0,h=c.length;e<h;e++){var i;var g=c[e];if(g.buildWidget!==undefined){i=g.buildWidget(d,f,j)}else{i=g(d,f,j)}if(i!==undefined){return i}}};this.onEndBuild=function(d){b("onEndBuild",d)}};metawidget.widgetbuilder.OverriddenWidgetBuilder=function(){if(!(this instanceof metawidget.widgetbuilder.OverriddenWidgetBuilder)){throw new Error("Constructor called as a function")}};metawidget.widgetbuilder.OverriddenWidgetBuilder.prototype.buildWidget=function(b,d,g){if(g.overriddenNodes===undefined){return}var a=metawidget.util.getId(b,d,g);for(var c=0,e=g.overriddenNodes.length;c<e;c++){var f=g.overriddenNodes[c];if(f.nodeType===1&&f.getAttribute("id")===a){g.overriddenNodes.splice(c,1);return f}}};metawidget.widgetbuilder.ReadOnlyWidgetBuilder=function(){if(!(this instanceof metawidget.widgetbuilder.ReadOnlyWidgetBuilder)){throw new Error("Constructor called as a function")}};metawidget.widgetbuilder.ReadOnlyWidgetBuilder.prototype.buildWidget=function(a,b,c){if(!metawidget.util.isTrueOrTrueString(b.readOnly)){return}if(metawidget.util.isTrueOrTrueString(b.hidden)||b.type==="function"){return metawidget.util.createElement(c,"stub")}if(b["enum"]!==undefined||b.type==="string"||b.type==="boolean"||b.type==="number"||b.type==="integer"||b.type==="date"||b.type==="color"){return metawidget.util.createElement(c,"output")}if(metawidget.util.isTrueOrTrueString(b.dontExpand)){return metawidget.util.createElement(c,"output")}};metawidget.widgetbuilder.HtmlWidgetBuilder=function(a){if(!(this instanceof metawidget.widgetbuilder.HtmlWidgetBuilder)){throw new Error("Constructor called as a function")
}var b=false;if(a!==undefined){b=a.alwaysUseNestedMetawidgetInTables}this.buildWidget=function(i,h,p){if(metawidget.util.isTrueOrTrueString(h.hidden)){return metawidget.util.createElement(p,"stub")}if(h.type==="boolean"&&h.componentType==="radio"&&h["enum"]===undefined){h["enum"]=[true,false];h.enumTitles=["Yes","No"]}if(h["enum"]!==undefined){var s,f,l;if(h.type==="array"||h.componentType!==undefined){var o=metawidget.util.createElement(p,"div");f=h["enum"].length;for(s=0;s<f;s++){var g=metawidget.util.createElement(p,"label");l=metawidget.util.createElement(p,"input");if(h.componentType!==undefined){g.setAttribute("class",h.componentType);l.setAttribute("type",h.componentType)}else{g.setAttribute("class","checkbox");l.setAttribute("type","checkbox")}l.value=h["enum"][s];g.appendChild(l);if(h.enumTitles!==undefined&&h.enumTitles[s]!==undefined){g.appendChild(metawidget.util.createTextNode(p,h.enumTitles[s]))}else{g.appendChild(metawidget.util.createTextNode(p,h["enum"][s]))}o.appendChild(g)}return o}var q=metawidget.util.createElement(p,"select");if(!metawidget.util.isTrueOrTrueString(h.required)){q.appendChild(metawidget.util.createElement(p,"option"))}f=h["enum"].length;for(s=0;s<f;s++){l=metawidget.util.createElement(p,"option");l.value=h["enum"][s];if(h.enumTitles!==undefined&&h.enumTitles[s]!==undefined){l.innerHTML=h.enumTitles[s]}else{l.innerHTML=h["enum"][s]}q.appendChild(l)}return q}if(h.type==="function"){var c=metawidget.util.createElement(p,"input");if(metawidget.util.isTrueOrTrueString(h.submit)){c.setAttribute("type","submit")}else{c.setAttribute("type","button")}c.setAttribute("value",metawidget.util.getLabelString(h,p));return c}if(h.type==="number"||h.type==="integer"){if(h.minimum!==undefined&&h.maximum!==undefined){var n=metawidget.util.createElement(p,"input");n.setAttribute("type","range");n.setAttribute("min",h.minimum);n.setAttribute("max",h.maximum);return n}var e=metawidget.util.createElement(p,"input");e.setAttribute("type","number");if(h.minimum!==undefined){e.setAttribute("min",h.minimum)
}else{if(h.maximum!==undefined){e.setAttribute("max",h.maximum)}}return e}if(h.type==="boolean"){var m=metawidget.util.createElement(p,"input");m.setAttribute("type","checkbox");return m}if(h.type==="date"){var t=metawidget.util.createElement(p,"input");t.setAttribute("type","date");return t}if(h.type==="color"){var r=metawidget.util.createElement(p,"input");r.setAttribute("type","color");return r}if(h.type==="string"){if(metawidget.util.isTrueOrTrueString(h.masked)){var d=metawidget.util.createElement(p,"input");d.setAttribute("type","password");if(h.maxLength!==undefined){d.setAttribute("maxlength",h.maxLength)}return d}if(metawidget.util.isTrueOrTrueString(h.large)){return metawidget.util.createElement(p,"textarea")}var j=metawidget.util.createElement(p,"input");if(h.componentType!==undefined){j.setAttribute("type",h.componentType)}else{j.setAttribute("type","text")}if(h.maxLength!==undefined){j.setAttribute("maxlength",h.maxLength)}return j}if(h.type==="array"){return this.createTable(i,h,p)}if(metawidget.util.isTrueOrTrueString(h.dontExpand)){var k=metawidget.util.createElement(p,"input");k.setAttribute("type","text");return k}};this.createTable=function(q,e,k){var m=metawidget.util.createElement(k,"table");var p=metawidget.util.splitPath(k.path);var l=metawidget.util.traversePath(k.toInspect,p.names);if(p.names===undefined){p.names=[]}var i;if(q!=="entity"&&l!==undefined){i=l[e.name];p.names.push(e.name)}else{i=l}p.names.push("0");var d=k.inspect(k.toInspect,p.type,p.names);if(d!==undefined){var f=metawidget.util.createElement(k,"tbody");var o,n;if(d.properties===undefined){m.appendChild(f);if(i!==undefined){n=i.length;for(o=0;o<n;o++){this.addRow(f,i,o,[{type:d.type}],q,e,k)}}}else{var c=metawidget.util.getSortedInspectionResultProperties(d);var g=metawidget.util.createElement(k,"thead");m.appendChild(g);var j=this.addHeaderRow(g,c,k);var h=metawidget.util.createElement(k,"tfoot");this.addFooterRow(h,j);if(h.childNodes.length>0){m.appendChild(h)}m.appendChild(f);
if(i!==undefined){n=i.length;for(o=0;o<n;o++){this.addRow(f,i,o,j,q,e,k)}}}}return m};this.addHeaderRow=function(i,f,j){var h=metawidget.util.createElement(j,"tr");i.appendChild(h);var d=[];for(var c=0,g=f.length;c<g;c++){var e=f[c];if(this.addHeader(h,e,j)){d.push(e)}}return d};this.addHeader=function(f,c,g){if(metawidget.util.isTrueOrTrueString(c.hidden)){return false}var e=metawidget.util.createElement(g,"th");var d="";if(c.columnWidth!==undefined){d+="width:"+c.columnWidth+";"}if(c.columnAlign!==undefined){d+="text-align:"+c.columnAlign+";"}if(d!==""){e.setAttribute("style",d)}if(c.type!=="function"){e.innerHTML=metawidget.util.getLabelString(c,g)}f.appendChild(e);return true};this.addRow=function(f,i,k,c,l,d,j){var h=metawidget.util.createElement(j,"tr");f.appendChild(h);for(var g=0,e=c.length;g<e;g++){this.addColumn(h,i,k,c[g],l,d,j)}return h};this.addColumn=function(h,i,n,l,o,d,k){var e=metawidget.util.createElement(k,"td");var c="";if(l.columnWidth!==undefined){c+="width:"+l.columnWidth+";"}if(l.columnAlign!==undefined){c+="text-align:"+l.columnAlign+";"}if(c!==""){e.setAttribute("style",c)}var m=i[n];if(m!==undefined&&l.name!==undefined){m=m[l.name]}if(l.type===undefined||l.type==="array"||l.type==="function"||b===true){var f={};for(var g in l){f[g]=l[g]}if(f.name===undefined){f.name="["+n+"]"}else{f.name=metawidget.util.appendPathWithName("["+n+"]",f)}f.nameIncludesSeparator=true;if(o!=="entity"){f.name="."+metawidget.util.appendPathWithName(d.name,f)}if(f.readOnly===undefined){f.readOnly=d.readOnly}var j;if(l.type===undefined){j=k.buildNestedMetawidget(f)}else{j=k.buildNestedMetawidget(f,{layout:new metawidget.layout.SimpleLayout()})}k.nestedMetawidgets=k.nestedMetawidgets||[];k.nestedMetawidgets.push(j);e.appendChild(j)}else{if(m!==undefined){e.innerHTML=""+m}}h.appendChild(e);return e};this.addFooterRow=function(d,c){}}})();
var metawidget=metawidget||{};(function(){metawidget.widgetprocessor=metawidget.widgetprocessor||{};metawidget.widgetprocessor.IdProcessor=function(){if(!(this instanceof metawidget.widgetprocessor.IdProcessor)){throw new Error("Constructor called as a function")}};metawidget.widgetprocessor.IdProcessor.prototype.processWidget=function(c,a,b,e){if(!metawidget.util.hasAttribute(c,"id")){var d=metawidget.util.getId(a,b,e);if(d!==undefined){c.setAttribute("id",d)}}return c};metawidget.widgetprocessor.RequiredAttributeProcessor=function(){if(!(this instanceof metawidget.widgetprocessor.RequiredAttributeProcessor)){throw new Error("Constructor called as a function")}};metawidget.widgetprocessor.RequiredAttributeProcessor.prototype.processWidget=function(c,a,b){if(metawidget.util.isTrueOrTrueString(b.required)){c.setAttribute("required","required")}return c};metawidget.widgetprocessor.PlaceholderAttributeProcessor=function(){if(!(this instanceof metawidget.widgetprocessor.PlaceholderAttributeProcessor)){throw new Error("Constructor called as a function")}};metawidget.widgetprocessor.PlaceholderAttributeProcessor.prototype.processWidget=function(c,a,b){if(b.placeholder!==undefined){c.setAttribute("placeholder",b.placeholder)}return c};metawidget.widgetprocessor.DisabledAttributeProcessor=function(){if(!(this instanceof metawidget.widgetprocessor.DisabledAttributeProcessor)){throw new Error("Constructor called as a function")}};metawidget.widgetprocessor.DisabledAttributeProcessor.prototype.processWidget=function(c,a,b){if(metawidget.util.isTrueOrTrueString(b.disabled)){c.setAttribute("disabled","disabled")}return c};metawidget.widgetprocessor.SimpleBindingProcessor=function(){if(!(this instanceof metawidget.widgetprocessor.SimpleBindingProcessor)){throw new Error("Constructor called as a function")}};metawidget.widgetprocessor.SimpleBindingProcessor.prototype.onStartBuild=function(a){a._simpleBindingProcessor={}};metawidget.widgetprocessor.SimpleBindingProcessor.prototype.processWidget=function(f,a,b,h){var c=metawidget.util.splitPath(h.path);
if(f.tagName==="INPUT"&&(f.getAttribute("type")==="button"||f.getAttribute("type")==="submit")){f.onclick=function(){try{return metawidget.util.traversePath(h.toInspect,c.names)[b.name]()}catch(i){if(alert!==undefined){alert(i)}else{throw i}}};return f}var e;if(a==="entity"){e=metawidget.util.traversePath(h.toInspect,c.names);if(c.names===undefined){h._simpleBindingProcessor.topLevel=true}else{h._simpleBindingProcessor.topLevelWithPath=true}}else{var g=metawidget.util.traversePath(h.toInspect,c.names);if(g!==undefined){e=g[b.name]}else{e=undefined}}var d=this.bindToWidget(f,e,a,b,h);if(d===true||f.getMetawidget!==undefined||f.nestedMetawidgets!==undefined){h._simpleBindingProcessor.bindings=h._simpleBindingProcessor.bindings||[];h._simpleBindingProcessor.bindings[b.name]={widget:f,elementName:a,attributes:b}}return f};metawidget.widgetprocessor.SimpleBindingProcessor.prototype.bindToWidget=function(e,h,j,d,i){var c=(e.tagName==="INPUT"||e.tagName==="SELECT"||e.tagName==="TEXTAREA");if(c===true&&metawidget.util.hasAttribute(e,"id")){e.setAttribute("name",e.getAttribute("id"))}var f,b;if(d["enum"]!==undefined&&e.tagName==="DIV"){if(d.type==="array"||d.componentType!==undefined){c=true;b=e.childNodes.length;for(f=0;f<b;f++){var a=e.childNodes[f];if(a.tagName==="LABEL"){var g=a.childNodes[0];if(g.tagName==="INPUT"){g.setAttribute("name",e.getAttribute("id"));if(d.type==="array"){g.checked=(h!==undefined&&h.indexOf(g.value)!==-1)}else{if(d.type==="boolean"){g.checked=(h===g.value||g.value===""+h)}else{g.checked=(h===g.value)}}}}}}}if(h!==undefined){if(e.tagName==="OUTPUT"||e.tagName==="TEXTAREA"){if(metawidget.util.isTrueOrTrueString(d.masked)){e.innerHTML=metawidget.util.fillString("*",h.length)}else{if(d.enumTitles!==undefined){if(d.type==="array"){b=h.length;for(f=0;f<b;f++){if(f===0){e.innerHTML=""}else{e.innerHTML+=", "}e.innerHTML+=metawidget.util.lookupEnumTitle(h[f],d["enum"],d.enumTitles)}}else{e.innerHTML=metawidget.util.lookupEnumTitle(h,d["enum"],d.enumTitles)
}}else{if(d.type==="boolean"){if(h===true){e.innerHTML=metawidget.util.getLocalizedString("Yes",i)}else{if(h===false){e.innerHTML=metawidget.util.getLocalizedString("No",i)}else{e.innerHTML=h}}}else{e.innerHTML=h}}}}else{if(e.tagName==="INPUT"&&e.getAttribute("type")==="checkbox"){e.checked=h}else{if(c===true){e.value=h}}}}return c};metawidget.widgetprocessor.SimpleBindingProcessor.prototype.save=function(l){var m;var b=false;var n=metawidget.util.splitPath(l.path);if(n.names===undefined){m=l.toInspect}else{var f=n.names.slice(0,n.names.length-1);var j=metawidget.util.traversePath(l.toInspect,f);if(l._simpleBindingProcessor.topLevelWithPath===true){m=j}else{var k=n.names[n.names.length-1];m=j[k];if(m===undefined){m={};j[k]=m}}}for(var c in l._simpleBindingProcessor.bindings){var h=l._simpleBindingProcessor.bindings[c];var e=this.getWidgetFromBinding(h,l);if(e.getMetawidget!==undefined){var a=this.save(e.getMetawidget());if(a===true){b=true}continue}var i=this.saveFromWidget(h,l);if(b===false&&m[c]!==i){b=true}if(l._simpleBindingProcessor.topLevel===true){l.toInspect=i;return b}m[c]=i}if(l.nestedMetawidgets!==undefined){for(var g=0,d=l.nestedMetawidgets.length;g<d;g++){var a=this.save(l.nestedMetawidgets[g].getMetawidget());if(a===true){b=true}}}return b};metawidget.widgetprocessor.SimpleBindingProcessor.prototype.saveFromWidget=function(f,i){var c=this.getWidgetFromBinding(f,i);if(c.getAttribute("type")==="checkbox"){return c.checked}if(f.attributes.type==="integer"){var g=parseInt(c.value);if(isNaN(g)){return undefined}return g}if(f.attributes.type==="number"){var g=parseFloat(c.value);if(isNaN(g)){return undefined}return g}if(f.attributes["enum"]!==undefined&&c.tagName==="DIV"){if(f.attributes.type==="array"||f.attributes.componentType!==undefined){var e=[];for(var d=0,b=c.childNodes.length;d<b;d++){var a=c.childNodes[d];if(a.tagName==="LABEL"){var h=a.childNodes[0];if(h.checked){if(f.attributes.type==="boolean"){return(h.value===true||h.value==="true")}if(f.attributes.type!=="array"){return h.value
}e.push(h.value)}}}return e}}if(f.attributes.type==="boolean"){return(c.value===true||c.value==="true")}if(c.value===""||c.value===null){return}return c.value};metawidget.widgetprocessor.SimpleBindingProcessor.prototype.getWidgetFromBinding=function(a,b){return a.widget};metawidget.widgetprocessor.SimpleBindingProcessor.prototype.reload=function(b,e){for(var a in e._simpleBindingProcessor.bindings){var d=e._simpleBindingProcessor.bindings[a];var c=this.getWidgetFromBinding(d,e);if(c.getMetawidget!==undefined){this.reload(b,c.getMetawidget());continue}this.bindToWidget(c,b[c.getAttribute("id")],d.elementName,d.attributes,e)}}})();
var metawidget=metawidget||{};(function(){metawidget.Metawidget=function(d,a){if(!(this instanceof metawidget.Metawidget)){throw new Error("Constructor called as a function")}var f=this;d.getMetawidget=function(){return f};var c=new metawidget.Pipeline(d);c.inspector=new metawidget.inspector.PropertyTypeInspector();c.widgetBuilder=new metawidget.widgetbuilder.CompositeWidgetBuilder([new metawidget.widgetbuilder.OverriddenWidgetBuilder(),new metawidget.widgetbuilder.ReadOnlyWidgetBuilder(),new metawidget.widgetbuilder.HtmlWidgetBuilder()]);c.widgetProcessors=[new metawidget.widgetprocessor.IdProcessor(),new metawidget.widgetprocessor.RequiredAttributeProcessor(),new metawidget.widgetprocessor.PlaceholderAttributeProcessor(),new metawidget.widgetprocessor.DisabledAttributeProcessor(),new metawidget.widgetprocessor.SimpleBindingProcessor()];c.layout=new metawidget.layout.HeadingTagLayoutDecorator(new metawidget.layout.TableLayout());c.configure(a);var e=[];while(d.childNodes.length>0){var b=d.childNodes[0];d.removeChild(b);if(b.nodeType===1){e.push(b)}}this.reconfigure=function(g){return c.configure(g)};this.save=function(){c.getWidgetProcessor(function(g){return g instanceof metawidget.widgetprocessor.SimpleBindingProcessor}).save(this)};this.getWidgetProcessor=function(g){return c.getWidgetProcessor(g)};this.setLayout=function(g){c.layout=g};this.inspect=function(i,g,h){return c.inspect(i,g,h,this)};this.buildWidgets=function(j){this.overriddenNodes=[];for(var g=0,i=e.length;g<i;g++){this.overriddenNodes.push(e[g].cloneNode(true))}if(j===undefined){if(arguments.length>0){throw new Error("Calling buildWidgets( undefined ) may cause infinite loop. Check your argument, or pass no arguments instead")}var h=metawidget.util.splitPath(this.path);j=c.inspect(this.toInspect,h.type,h.names,this)}c.buildWidgets(j,this)};this.getElement=function(){return c.element};this.clearWidgets=function(){var g=this.getElement();while(g.childNodes.length>0){g.removeChild(g.childNodes[0])}};this.buildNestedMetawidget=function(g,h){var j=metawidget.util.createElement(this,"div");
var i=new metawidget.Metawidget(j,[c,h]);i.toInspect=this.toInspect;i.path=metawidget.util.appendPath(g,this);i.readOnly=this.readOnly||metawidget.util.isTrueOrTrueString(g.readOnly);i.buildWidgets();return j}};metawidget.Pipeline=function(a){if(!(this instanceof metawidget.Pipeline)){throw new Error("Constructor called as a function")}this.inspectionResultProcessors=[];this.widgetProcessors=[];this.element=a;this.maximumInspectionDepth=10};metawidget.Pipeline.prototype.configure=function(b){if(b===undefined){return}var a;if(b instanceof Array){for(a=0;a<b.length;a++){this.configure(b[a])}return}if(b.inspector!==undefined){this.inspector=b.inspector}if(b.inspectionResultProcessors!==undefined){this.inspectionResultProcessors=b.inspectionResultProcessors.slice(0)}if(b.appendInspectionResultProcessors!==undefined){for(a=0;a<b.appendInspectionResultProcessors.length;a++){this.inspectionResultProcessors.push(b.appendInspectionResultProcessors[a])}}if(b.widgetBuilder!==undefined){this.widgetBuilder=b.widgetBuilder}if(b.widgetProcessors!==undefined){this.widgetProcessors=b.widgetProcessors.slice(0)}if(b.prependWidgetProcessors!==undefined){for(a=0;a<b.prependWidgetProcessors.length;a++){this.widgetProcessors.splice(a,0,b.prependWidgetProcessors[a])}}if(b.appendWidgetProcessors!==undefined){for(a=0;a<b.appendWidgetProcessors.length;a++){this.widgetProcessors.push(b.appendWidgetProcessors[a])}}if(b.layout!==undefined){this.layout=b.layout}if(b.maximumInspectionDepth!==undefined){this.maximumInspectionDepth=b.maximumInspectionDepth-1}if(b.styleClass!==undefined){this.styleClass=b.styleClass;metawidget.util.appendToAttribute(this.element,"class",b.styleClass)}};metawidget.Pipeline.prototype.getWidgetProcessor=function(b){for(var a=0,c=this.widgetProcessors.length;a<c;a++){var d=this.widgetProcessors[a];if(b(d)){return d}}};metawidget.Pipeline.prototype.inspect=function(g,c,f,h){var e;if(this.inspector.inspect!==undefined){e=this.inspector.inspect(g,c,f)}else{e=this.inspector(g,c,f)
}if(e===undefined){return}for(var a=0,d=this.inspectionResultProcessors.length;a<d;a++){var b=this.inspectionResultProcessors[a];if(b.processInspectionResult!==undefined){e=b.processInspectionResult(e,h,g,c,f)}else{e=b(e,h,g,c,f)}if(e===undefined){return}}return e};metawidget.Pipeline.prototype.buildWidgets=function(h,m){m.clearWidgets();d(this,m);if(h!==undefined){var c=a(h,m,"properties");var n="entity";var i=g(this,n,c,m);if(i!==undefined){i=k(this,i,n,c,m);if(i!==undefined){this.layoutWidget(i,n,c,this.element,m)}}else{var f=metawidget.util.getSortedInspectionResultProperties(h);for(var j=0,e=f.length;j<e;j++){c=a(f[j],m);if(c.type==="function"){n="action"}else{n="property"}i=g(this,n,c,m);if(i===undefined){if(this.maximumInspectionDepth<=0){continue}i=m.buildNestedMetawidget(c);if(i===undefined){continue}}i=k(this,i,n,c,m);if(i!==undefined){this.layoutWidget(i,n,c,this.element,m)}}}}l(this,m);if(this.element.dispatchEvent!==undefined){this.element.dispatchEvent(metawidget.util.createEvent(m,"buildEnd"))}function a(o,s,r){var q={};for(var p in o){if(r!==undefined&&r.indexOf(p)!==-1){continue}q[p]=o[p]}if(s.readOnly===true){q.readOnly="true"}return q}function d(p,r){for(var o=0,q=r.overriddenNodes.length;o<q;o++){r.overriddenNodes[o].overridden=true}if(p.widgetBuilder.onStartBuild!==undefined){p.widgetBuilder.onStartBuild(r)}b("onStartBuild",p,r);if(p.layout.onStartBuild!==undefined){p.layout.onStartBuild(r)}if(p.layout.startContainerLayout!==undefined){p.layout.startContainerLayout(p.element,r)}}function g(q,o,p,r){if(q.widgetBuilder.buildWidget!==undefined){return q.widgetBuilder.buildWidget(o,p,r)}return q.widgetBuilder(o,p,r)}function k(r,t,o,q,v){for(var p=0,s=r.widgetProcessors.length;p<s;p++){var u=r.widgetProcessors[p];if(u.processWidget!==undefined){t=u.processWidget(t,o,q,v)}else{t=u(t,o,q,v)}if(t===undefined){return}}return t}function l(p,u){if(u.onEndBuild!==undefined){u.onEndBuild()}else{while(u.overriddenNodes.length>0){var t=u.overriddenNodes[0];u.overriddenNodes.splice(0,1);
if(t.tagName==="FACET"){continue}var r={section:""};if(t.tagName==="STUB"){for(var o=0,q=t.attributes.length;o<q;o++){var s=t.attributes[o];r[s.nodeName]=s.nodeValue}}p.layoutWidget(t,"property",r,p.element,u)}}if(p.layout.endContainerLayout!==undefined){p.layout.endContainerLayout(p.element,u)}if(p.layout.onEndBuild!==undefined){p.layout.onEndBuild(u)}b("onEndBuild",p,u);if(p.widgetBuilder.onEndBuild!==undefined){p.widgetBuilder.onEndBuild(u)}}function b(r,p,t){for(var o=0,q=p.widgetProcessors.length;o<q;o++){var s=p.widgetProcessors[o];if(s[r]!==undefined){s[r](t)}}}};metawidget.Pipeline.prototype.layoutWidget=function(d,a,c,b,e){if(this.layout.layoutWidget!==undefined){this.layout.layoutWidget(d,a,c,b,e);return}this.layout(d,a,c,b,e)}})();
module.exports = metawidget;