function getArrayIndexAt(arr, dimensions, data) {
    var currentDimension = dimensions[0];
    data.validate(currentDimension, 'number');
    currentDimension = Math.max(0, Math.floor(currentDimension - 1));

    if (arr.length <= currentDimension) throw new Error('Invalid array bounds');
    var item = arr[currentDimension];
    if (dimensions.length > 1) {
        if (!Array.isArray(item)) throw new Error('Invalid array dimensions');
        return getArrayIndexAt(arr[currentDimension], dimensions.slice(1), data);
    } else return item;
}

function
getArrayIndexAt
(
arr
,
dimensions
,
data
)
{
var
currentDimension
=
dimensions
[
0
]
;
data
.
validate
(
currentDimension
,
'number'
)
;
currentDimension
=
Math
.
max
(
0
,
Math
.
floor
(
currentDimension
1
)
)
;
if
(
arr
.
length
<=
currentDimension
)
throw
new
Error
(
'Invalid array bounds'
)
;
var
item
=
arr
[
currentDimension
]
;
if
(
dimensions
.
length
>
1
)
{
if
(
!
Array
.
isArray
(
item
)
)
throw
new
Error
(
'Invalid array dimensions'
)
;
return
getArrayIndexAt
(
arr
[
currentDimension
]
,
dimensions
.
slice
(
1
)
,
data
)
;
}
else
return
item
;
}

Gets the array item at a certain index, including multiple dimensions

@param {Array} arr The array to search
@param {Array<ExpressionStatement>} dimensions An array of indexes
@param {ExecutionContext} data The execution data context
@returns {Number|String}
@private

Gets the array item at a certain index including multiple dimensions


function createArrayDepth(dimensions, endpoint) {
    var currentDimension = dimensions[0];

    var newArr = new Array(currentDimension);
    for (var i = 0; i < currentDimension; i++) {
        var value = endpoint;
        if (dimensions.length > 1) value = createArrayDepth(dimensions.slice(1), endpoint);
        newArr[i] = value;
    }
    return newArr;
}

function createArrayDepth ( dimensions , endpoint ) { var currentDimension = dimensions [ 0 ] ; var newArr = new Array ( currentDimension ) ; for ( var i = 0 ; i < currentDimension ; i ++ ) { var value = endpoint ; if ( dimensions . length > 1 ) value = createArrayDepth ( dimensions . slice ( 1 ) , endpoint ) ; newArr [ i ] = value ; } return newArr ; }

Creates an array with the specified lengths of dimensions

@param {Array<Number>} dimensions The array dimensions
@param {*} endpoint The value for the array endpoint
@private


function (section) {
		section.children.forEach(function (child) {
			if (child.type === 'section') {
				finalParse(child)
			} else if (child.type === 'text' ||
				child.type === 'value' ||
				child.type === 'code') {
				var sliceStart = child.line - 1,
					sliceEnd = child.line + child.size - 1,
					subLines = lines.slice(sliceStart, sliceEnd)
				if (child.type === 'text') {
					child.content = subLines.join('\n')
				} else if (child.type === 'code') {
					child.language = subLines[0].substr(3)
					child.content = subLines.slice(1, -1).join('\n')
				} else if (child.type === 'value') {
					child.content = subLines.join('\n')

					// Remove starting tab character
					parseValue(child, subLines.map(function (e, i) {
						return {
							line: child.line + i,
							str: e.substr(1)
						}
					}), throwSyntaxError)
				}
			}
		})
	}

function
(
section
)
{
section
.
children
.
forEach
(
function
(
child
)
{
if
(
child
.
type
===
'section'
)
{
finalParse
(
child
)
}
else
if
(
child
.
type
===
'text'
||
child
.
type
===
'value'
||
child
.
type
===
'code'
)
{
var
sliceStart
=
child
.
line
1
,
sliceEnd
=
child
.
line
+
child
.
size
1
,
subLines
=
lines
.
slice
(
sliceStart
,
sliceEnd
)
if
(
child
.
type
===
'text'
)
{
child
.
content
=
subLines
.
join
(
'\n'
)
}
else
if
(
child
.
type
===
'code'
)
{
child
.
language
=
subLines
[
0
]
.
substr
(
3
)
child
.
content
=
subLines
.
slice
(
1
,
1
)
.
join
(
'\n'
)
}
else
if
(
child
.
type
===
'value'
)
{
child
.
content
=
subLines
.
join
(
'\n'
)
// Remove starting tab character
parseValue
(
child
,
subLines
.
map
(
function
(
e
,
i
)
{
return
{
line
:
child
.
line
+
i
,
str
:
e
.
substr
(
1
)
}
}
)
,
throwSyntaxError
)
}
}
}
)
}


function takeHeader(content, level, name) {
		var currLevel = sectionStack.length

		if (level > currLevel + 1) {
			throwSyntaxError('Unexpected header level ' + level + ' on section level ' + currLevel)
		} else if (level === 1) {
			throwSyntaxError('There can be only one header level 1, the first line of the file')
		}

		// Walk out
		sectionStack.length = level - 1

		// Create section
		section = {
			type: 'section',
			name: name || '',
			line: line,
			size: 1,
			content: content,
			level: level,
			children: []
		}
		sectionStack[sectionStack.length - 1].children.push(section)
		sectionStack.push(section)
	}

Process a new header, creating a new section
@param {string} content
@param {number} level
@param {?string} name
@private

Process a new header creating a new section


function throwSyntaxError(message, errorLine, size) {
		errorLine = errorLine === undefined ? line : errorLine
		size = size === undefined ? 1 : size
		var snippet = getSnippet(source, errorLine, size),
			err = new SyntaxError(message + '\n' + snippet)
		err.line = errorLine
		throw err
	}

function throwSyntaxError ( message , errorLine , size ) { errorLine = errorLine === undefined ? line : errorLine size = size === undefined ? 1 : size var snippet = getSnippet ( source , errorLine , size ) , err = new SyntaxError ( message + '\n' + snippet ) err . line = errorLine throw err }

Throw a syntax error in the current position
@param {string} message
@param {number} [errorLine=line]
@param {number} [size=1]
@throws {SyntaxError}
@private


function appendLine(type) {
		var len = section.children.length
		if (newBlock ||
			!len ||
			section.children[len - 1].type !== type) {
			section.children.push({
				type: type,
				line: line,
				size: 1
			})
		} else {
			section.children[len - 1].size += 1
		}
		newBlock = false
	}

function appendLine ( type ) { var len = section . children . length if ( newBlock || ! len || section . children [ len - 1 ] . type !== type ) { section . children . push ( { type : type , line : line , size : 1 } ) } else { section . children [ len - 1 ] . size += 1 } newBlock = false }

Append the current line to the last block with the given type,
or create a new one
@param {string} type
@private

Append the current line to the last block with the given type or create a new one


function on(event, cb, context) {
                var args = Array.prototype.slice.call(arguments, 0);
                return dom.on.apply(false, [this].concat(args));
            }

function on ( event , cb , context ) { var args = Array . prototype . slice . call ( arguments , 0 ) ; return dom . on . apply ( false , [ this ] . concat ( args ) ) ; }


function detach(node) {
            if (node.placeholder instanceof HTMLElement === false) {
                node.placeholder = createPlaceholder(node.data.tag || node.el.tagName);
            }
            if (node && node.el && node.el.parentNode) {
                node.el.parentNode.replaceChild(node.placeholder, node.el);
            }
        }

function detach ( node ) { if ( node . placeholder instanceof HTMLElement === false ) { node . placeholder = createPlaceholder ( node . data . tag || node . el . tagName ) ; } if ( node && node . el && node . el . parentNode ) { node . el . parentNode . replaceChild ( node . placeholder , node . el ) ; } }

Removing element from DOM  @method detach @param {dom.Element}


function attach(node) {
            if (node && node.el && node.placeholder && node.placeholder.parentNode) {
                node.placeholder.parentNode.replaceChild(node.el, node.placeholder);
            }
        }

function attach ( node ) { if ( node && node . el && node . placeholder && node . placeholder . parentNode ) { node . placeholder . parentNode . replaceChild ( node . el , node . placeholder ) ; } }

Adding element back to DOM  @method attach @param {dom.Element}


function append(parent, child) {
            if (parent.el !== undefined && child.el !== undefined) {
                parent.el.appendChild(child.el);
            }
        }

function append ( parent , child ) { if ( parent . el !== undefined && child . el !== undefined ) { parent . el . appendChild ( child . el ) ; } }

Insert element to the end of parent childs  @method append @param {dom.Element} parent @param {dom.Element} child


function insertBefore(parent, child, index) {
            var parentEl = parent.el,
                childEl = child.el;
            if (parentEl !== undefined && childEl !== undefined) {
                if (parentEl.childNodes[index] !== undefined) {
                    parentEl.insertBefore(childEl, parentEl.childNodes[index]);
                } else {
                    parentEl.appendChild(childEl);
                }
            }
        }

function insertBefore ( parent , child , index ) { var parentEl = parent . el , childEl = child . el ; if ( parentEl !== undefined && childEl !== undefined ) { if ( parentEl . childNodes [ index ] !== undefined ) { parentEl . insertBefore ( childEl , parentEl . childNodes [ index ] ) ; } else { parentEl . appendChild ( childEl ) ; } } }

Insert element to the before of specific, child by index  @method insertBefore @param {dom.Element} parent @param {dom.Element} child

Insert element to the before of specific child by index


function changePosition(el, index) {

            var HTMLElement = el.el;
            if (HTMLElement && HTMLElement.parentNode) {

                var parentNode = HTMLElement.parentNode,
                    elGroup = el.elGroup,
                    size = elGroup.size,
                    target = elGroup.getKeyByIndex(index) || elGroup.getLast();

                if (target !== HTMLElement) {
                    if (size - 1 >= index) {
                        parentNode.insertBefore(HTMLElement, target);
                    } else if (target.nextSibling !== null) {
                        parentNode.insertBefore(HTMLElement, target.nextSibling);
                    } else {
                        parentNode.appendChild(HTMLElement);
                    }

                    el.elGroup.changeIndex(HTMLElement, index);
                }
            }
        }

function changePosition ( el , index ) { var HTMLElement = el . el ; if ( HTMLElement && HTMLElement . parentNode ) { var parentNode = HTMLElement . parentNode , elGroup = el . elGroup , size = elGroup . size , target = elGroup . getKeyByIndex ( index ) || elGroup . getLast ( ) ; if ( target !== HTMLElement ) { if ( size - 1 >= index ) { parentNode . insertBefore ( HTMLElement , target ) ; } else if ( target . nextSibling !== null ) { parentNode . insertBefore ( HTMLElement , target . nextSibling ) ; } else { parentNode . appendChild ( HTMLElement ) ; } el . elGroup . changeIndex ( HTMLElement , index ) ; } } }

Changing position in nodeList  @method changePosition @param {dom.Element} @param {Int} index


function text(node, _text2) {
            if (node && node.el) {
                node.el.innerHTML = _text2;
            }
        }

function text ( node , _text2 ) { if ( node && node . el ) { node . el . innerHTML = _text2 ; } }

Adding text in to node  @method text @param {dom.Element} @param {String} text


function setAttribute(node, prop, value) {
            if (node && node.el) {
                if (isObject(prop)) {
                    Object.keys(prop).forEach(function (key) {
                        node.el.setAttribute(key, prop[key]);
                    });
                } else {
                    node.el.setAttribute(prop, value);
                }
            }
        }

function setAttribute ( node , prop , value ) { if ( node && node . el ) { if ( isObject ( prop ) ) { Object . keys ( prop ) . forEach ( function ( key ) { node . el . setAttribute ( key , prop [ key ] ) ; } ) ; } else { node . el . setAttribute ( prop , value ) ; } } }

Setting Attribute in to node  @method setAttribute @prop {dom.Element} node @prop {String||Object} prop @prop {String} value


function getAttribute(node, prop) {
            if (node && node.el) {
                return node.el.getAttribute(prop);
            } else {
                return undefined;
            }
        }

function getAttribute ( node , prop ) { if ( node && node . el ) { return node . el . getAttribute ( prop ) ; } else { return undefined ; } }

Getting Attribute in to node  @method getAttribute @prop {dom.Element} node @prop {String||Object} prop @return {String} value


function removeAttribute(node, prop) {
            if (node && node.el) {
                node.el.removeAttribute(prop);
            }
        }

function removeAttribute ( node , prop ) { if ( node && node . el ) { node . el . removeAttribute ( prop ) ; } }

Removing Attribute from node  @method removeAttribute @prop {dom.Element} node @prop {String} prop


function setStyle(node, prop, value) {
            if (node && node.el) {
                if (isObject(prop)) {
                    Object.keys(prop).forEach(function (key) {
                        node.el.style[key] = prop[key];
                    });
                } else {
                    node.el.style[prop] = value;
                }
            }
        }

function setStyle ( node , prop , value ) { if ( node && node . el ) { if ( isObject ( prop ) ) { Object . keys ( prop ) . forEach ( function ( key ) { node . el . style [ key ] = prop [ key ] ; } ) ; } else { node . el . style [ prop ] = value ; } } }

Setting css style in to node  @method setStyle @prop {dom.Element} node @prop {String||Object} prop @prop {String} value


function getStyle(node, prop) {
            if (node && node.el) {
                if (node.el !== undefined && node.el.style !== undefined) {
                    return node.el.style[prop];
                } else {
                    return undefined;
                }
            }
        }

function getStyle ( node , prop ) { if ( node && node . el ) { if ( node . el !== undefined && node . el . style !== undefined ) { return node . el . style [ prop ] ; } else { return undefined ; } } }

Getting css style from node  @method getStyle @prop {dom.Element} node @prop {String} prop @return {String} value


function removeStyle(node, prop) {
            if (node && node.el) {
                node.el.style[prop] = '';
            }
        }

function removeStyle ( node , prop ) { if ( node && node . el ) { node . el . style [ prop ] = '' ; } }

Removing css style from node  @method removeAttribute @prop {dom.Element} node @prop {String} prop


function addClass(node, className) {
            if (node && node.el) {
                node.el.classList.add(className);
            }
        }

function addClass ( node , className ) { if ( node && node . el ) { node . el . classList . add ( className ) ; } }

Adding class in to node  @method addClass @param {dom.Element} node @param {String} className


function hasClass(node, className) {
            if (node && node.el) {
                return node.el.classList.contains(className);
            } else {
                return false;
            }
        }

function hasClass ( node , className ) { if ( node && node . el ) { return node . el . classList . contains ( className ) ; } else { return false ; } }

checking if className exists in node  @method hasClass @param {dom.Element} node @param {String} className @return boolean


function removeClass(node, className) {
            if (node && node.el) {
                node.el.classList.remove(className);
            }
        }

function removeClass ( node , className ) { if ( node && node . el ) { node . el . classList . remove ( className ) ; } }

Remove class from node  @method removeClass @param {dom.Element} node @param {string} className


function val(node, _val2) {
            if (node && node.el) {
                var el = node.el;
                if (_val2 !== undefined) {
                    el.value = _val2;
                } else {
                    return el.value;
                }
            }
        }

function val ( node , _val2 ) { if ( node && node . el ) { var el = node . el ; if ( _val2 !== undefined ) { el . value = _val2 ; } else { return el . value ; } } }

Setting, Getting value to input element  @method val @param {dom.Element} node @param? {String} val @return {String}


function on(element, ev, cb, context) {
            for (var _len = arguments.length, args = Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++) {
                args[_key - 4] = arguments[_key];
            }

            var _this = this;

            var el = element.el,
                events = ev.split(' '),
                fn = function fn(e) {
                cb.apply(context || _this, [e, element].concat(args));
            };

            events.forEach(function (event) {
                el.addEventListener(event, fn);
            });
            var evt = {
                remove: function remove() {
                    events.forEach(function (event) {
                        return el.removeEventListener(event, fn);
                    });
                    var evts = element._events;
                    evts.splice(evts.indexOf(evt), 1);
                }
            };
            element._events.push(evt);
            return evt;
        }

function
on
(
element
,
ev
,
cb
,
context
)
{
for
(
var
_len
=
arguments
.
length
,
args
=
Array
(
_len
>
4
_len
4
:
0
)
,
_key
=
4
;
_key
<
_len
;
_key
++
)
{
args
[
_key
4
]
=
arguments
[
_key
]
;
}
var
_this
=
this
;
var
el
=
element
.
el
,
events
=
ev
.
split
(
' '
)
,
fn
=
function
fn
(
e
)
{
cb
.
apply
(
context
||
_this
,
[
e
,
element
]
.
concat
(
args
)
)
;
}
;
events
.
forEach
(
function
(
event
)
{
el
.
addEventListener
(
event
,
fn
)
;
}
)
;
var
evt
=
{
remove
:
function
remove
(
)
{
events
.
forEach
(
function
(
event
)
{
return
el
.
removeEventListener
(
event
,
fn
)
;
}
)
;
var
evts
=
element
.
_events
;
evts
.
splice
(
evts
.
indexOf
(
evt
)
,
1
)
;
}
}
;
element
.
_events
.
push
(
evt
)
;
return
evt
;
}

Adding DOM Event in to Element  @method on @param {dom.Element} element @param {String} ev @param {Function} cb @param {Object} context @return {Object} { remove() }


function remove(el) {
            while (el._events.length > 0) {
                el._events.shift().remove();
            }

            if (el.children) {
                destroy(el.children);
            }
            if (el.elGroup !== undefined) {
                el.elGroup.delete(el.el);
            }

            if (el.el !== undefined) {
                if (el.el.remove) {
                    el.el.remove();
                } else if (el.el.parentNode) {
                    el.el.parentNode.removeChild(el.el);
                }
                delete el.el;
            }
        }

function remove ( el ) { while ( el . _events . length > 0 ) { el . _events . shift ( ) . remove ( ) ; } if ( el . children ) { destroy ( el . children ) ; } if ( el . elGroup !== undefined ) { el . elGroup . delete ( el . el ) ; } if ( el . el !== undefined ) { if ( el . el . remove ) { el . el . remove ( ) ; } else if ( el . el . parentNode ) { el . el . parentNode . removeChild ( el . el ) ; } delete el . el ; } }

Remove Dom Element from Dom  @method remove @param {dom.Element}


function onDOMAttached(el) {
            var _this2 = this;

            var handlers = [],
                attached = false,
                _step = undefined;

            if (el.el !== undefined) {
                _step = function step() {
                    if (attached) {
                        while (handlers.length > 0) {
                            handlers.shift()();
                        }
                    } else {
                        window.requestAnimationFrame(_step);
                        if (document.body.contains(el.el)) {
                            attached = true;
                        }
                    }
                };
            }
            return {
                then: function then(cb, context) {
                    handlers.push(cb.bind(context || _this2));
                    window.requestAnimationFrame(_step);
                }
            };
        }

function onDOMAttached ( el ) { var _this2 = this ; var handlers = [ ] , attached = false , _step = undefined ; if ( el . el !== undefined ) { _step = function step ( ) { if ( attached ) { while ( handlers . length > 0 ) { handlers . shift ( ) ( ) ; } } else { window . requestAnimationFrame ( _step ) ; if ( document . body . contains ( el . el ) ) { attached = true ; } } } ; } return { then : function then ( cb , context ) { handlers . push ( cb . bind ( context || _this2 ) ) ; window . requestAnimationFrame ( _step ) ; } } ; }

executes when element attached to Dom  @method onDOMAttached @param {dom.Element} @param {function} cb @param {function} context


function match({ just, nothing }) {
    return function (maybe) {
        for (const value of maybe) {
            return just(value);
        }
        return nothing();
    };
}

function match ( { just , nothing } ) { return function ( maybe ) { for ( const value of maybe ) { return just ( value ) ; } return nothing ( ) ; } ; }

Match the maybe, calling just if there is a value and nothing if not, and return the following value

Match the maybe calling just if there is a value and nothing if not and return the following value


function flatMap(mapper) {
    return function (maybe) {
        for (const value of maybe) {
            return mapper(value);
        }
        return maybe_1.nothing();
    };
}

function flatMap ( mapper ) { return function ( maybe ) { for ( const value of maybe ) { return mapper ( value ) ; } return maybe_1 . nothing ( ) ; } ; }

Return a maybe with the current value, if any, mapped to a new Maybe

Return a maybe with the current value if any mapped to a new Maybe


function filter(predicate) {
    return flatMap(value => predicate(value) ? maybe_1.just(value) : maybe_1.nothing());
}

function filter ( predicate ) { return flatMap ( value => predicate ( value ) ? maybe_1 . just ( value ) : maybe_1 . nothing ( ) ) ; }

Return the current maybe if it has a value that matches the predicate, else return an empty

Return the current maybe if it has a value that matches the predicate else return an empty


function or(defaultValue) {
    return function (maybe) {
        for (const value of maybe) {
            return maybe_1.just(value);
        }
        return defaultValue;
    };
}

function or ( defaultValue ) { return function ( maybe ) { for ( const value of maybe ) { return maybe_1 . just ( value ) ; } return defaultValue ; } ; }

Return either the current maybe, or the maybe provided if the current maybe is empty

Return either the current maybe or the maybe provided if the current maybe is empty


function(e){
			var history=S.History, current = history.getFragment();
			if(OLD_IE && current == history.fragment && history.iframe) current = history.getFragment(history.getHash(history.iframe));
			if(current == history.fragment) return false;
			if(history.iframe) history.navigate(current);
			history.loadUrl();
		}

function ( e ) { var history = S . History , current = history . getFragment ( ) ; if ( OLD_IE && current == history . fragment && history . iframe ) current = history . getFragment ( history . getHash ( history . iframe ) ) ; if ( current == history . fragment ) return false ; if ( history . iframe ) history . navigate ( current ) ; history . loadUrl ( ) ; }

Checks the current URL to see if it has changed, and if it has, calls `loadUrl`, normalizing across the hidden iframe.

Checks the current URL to see if it has changed and if it has calls loadUrl normalizing across the hidden iframe .


function(fragmentOverride,state){
			var fragment = baseUrl+( this.fragment = this.getFragment(fragmentOverride));
			if(fragment){
				var a=$('a[href="'+fragment+'"]');
				a.length===0 ? S.redirect(fragment) : a.click();
			}
		}

function ( fragmentOverride , state ) { var fragment = baseUrl + ( this . fragment = this . getFragment ( fragmentOverride ) ) ; if ( fragment ) { var a = $ ( 'a[href="' + fragment + '"]' ) ; a . length === 0 ? S . redirect ( fragment ) : a . click ( ) ; } }

Attempt to load the current URL fragment.

Attempt to load the current URL fragment .