Skip to content

Instantly share code, notes, and snippets.

@insin
Last active August 29, 2015 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save insin/9063570 to your computer and use it in GitHub Desktop.
Save insin/9063570 to your computer and use it in GitHub Desktop.
newforms & React Contact Form Example - http://bl.ocks.org/insin/raw/9063570/
/** @jsx React.DOM */
var STATES = [
'AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI',
'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS',
'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR',
'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'
]
var BootstrapRadioInlineRenderer = forms.RadioFieldRenderer.extend({
render: function() {
return this.choiceInputs().map(function(input) {
return <label className="radio-inline">
{input.tag()} {input.choiceLabel}
</label>
})
}
})
var ContactForm = forms.Form.extend({
firstName: forms.CharField({maxLength: 50})
, lastName: forms.CharField({maxLength: 50})
, phoneNumber: forms.RegexField(/^[-\d]*$/, {
errorMessages: {invalid: 'Invalid characters in phone number'}
})
, email: forms.EmailField()
, question: forms.CharField({widget: forms.Textarea({attrs: {rows: 3}})})
, address: forms.CharField({widget: forms.Textarea({attrs: {rows: 3}})})
, city: forms.CharField({maxLength: 50})
, state: forms.ChoiceField({choices: flatChoices(STATES)})
, zipCode: forms.RegexField(/^\d{5}(?:-?\d{4})?$/, {
errorMessages: {invalid: 'Must be 5 digts or 5+4 digits'}
})
, currentCustomer: forms.ChoiceField({
choices: [['Y', 'Yes'], ['N', 'No']]
, initial: 'N'
, widget: forms.RadioSelect({renderer: BootstrapRadioInlineRenderer})
})
, constructor: function(kwargs) {
kwargs = extend({email: false, question: false}, kwargs)
ContactForm.__super__.constructor.call(this, kwargs)
this.fields.currentCustomer.label = 'Are you currently a ' + kwargs.company + ' Customer?'
if (!kwargs.email) {
delete this.fields.email
}
if (!kwargs.question) {
delete this.fields.question
}
}
, cleanPhoneNumber: function() {
var phoneNumber = this.cleanedData.phoneNumber.replace(/-/g, '')
if (phoneNumber.length < 10) {
throw forms.ValidationError('Must contain at least 10 digits')
}
return phoneNumber
}
, render: function() {
return this.visibleFields().map(this.renderField.bind(this))
}
, renderField: function(bf) {
var errors = bf.errors()
var hasErrors = errors.isPopulated()
var fieldCassName = $c({'form-control': bf.name !== 'currentCustomer'})
return <div key={bf.htmlName} className={$c('form-group', {'has-error': hasErrors})}>
{bf.labelTag({attrs: {className: "col-sm-4 control-label"}})}
<div className="col-sm-4">
{bf.render({attrs: {className: fieldCassName}})}
</div>
<div className="col-sm-4 help-text">
<p className="form-control-static">
{hasErrors && errors.messages()[0]}
</p>
</div>
</div>
}
})
var Example = React.createClass({
getInitialState: function() {
return {
email: true
, question: true
, submitted: null
}
}
, render: function() {
var submitted
if (this.state.submitted !== null) {
submitted = <div className="alert alert-success">
<p>ContactForm data:</p>
<pre><code>{JSON.stringify(this.state.submitted, null, ' ')}</code></pre>
</div>
}
return <div>
<div className="panel panel-default">
<div className="panel-heading clearfix">
<h3 className="panel-title pull-left">Contact Form</h3>
<div className="pull-right">
<label className="checkbox-inline">
<input type="checkbox"
checked={this.state.email}
onChange={this.handleChange.bind(this, 'email')}
/> Email
</label>
<label className="checkbox-inline">
<input type="checkbox"
checked={this.state.question}
onChange={this.handleChange.bind(this, 'question')}
/> Question
</label>
</div>
</div>
<div className="panel-body">
<ContactFormComponent ref="contactForm"
email={this.state.email}
question={this.state.question}
company={this.props.company}
/>
</div>
<div className="panel-footer">
<button type="button" className="btn btn-primary btn-block" onClick={this.handleSubmit}>Submit</button>
</div>
</div>
{submitted}
</div>
}
, handleChange: function(field, e) {
var nextState = {}
nextState[field] = e.target.checked
this.setState(nextState)
}
, handleSubmit: function() {
var data = this.refs.contactForm.getFormData()
if (data !== null) {
this.setState({submitted: data})
}
}
})
/**
* A contact form with certain optional fields.
*/
var ContactFormComponent = React.createClass({
getDefaultProps: function() {
return {
email: true
, question: false
}
}
, getInitialState: function() {
return {
form: new ContactForm(this.getFormKwargs(this.props))
}
}
, getFormKwargs: function(props, extraKwargs) {
return extend({
company: props.company
, email: props.email
, question: props.question
}, extraKwargs)
}
, componentWillReceiveProps: function(nextProps) {
if (nextProps.email !== this.props.email ||
nextProps.question !== this.props.question) {
var formKwargs = this.getFormKwargs(nextProps, {
data: (this.state.form.isBound ? this.state.form.data : null)
})
var form = new ContactForm(formKwargs)
// Carry over any errors present, as they're needed for display. We don't
// want to force the entire form to re-validate as we may be showing a new
// field and marking it as invalid before the user has had a chance to
// enter data.
form._errors = this.state.form._errors
this.setState({form: form})
}
}
, getFormData: function() {
var form = new ContactForm(this.getFormKwargs(this.props, {
data: forms.formData(this.refs.form.getDOMNode())
}))
var isValid = form.isValid()
this.setState({form: form})
return isValid ? form.cleanedData : null
}
, render: function() {
return <form ref="form">
<div className="form-horizontal">
{this.state.form.render()}
</div>
</form>
}
})
React.renderComponent(<Example company="FakeCo"/>, document.getElementById('contactform'))
// Utils
/**
* [choice1, choice2...] => [[choice1, choice1], [choice2, choice2]...]
*/
function flatChoices(choices) {
return choices.map(function(choice) {
return [choice, choice]
})
}
function extend(dest) {
for (var i = 1, l = arguments.length; i < l; i++) {
var src = arguments[i]
if (!src || typeof src != 'object') { continue }
for (var prop in src) {
if (!Object.prototype.hasOwnProperty.call(src, prop)) { continue }
dest[prop] = src[prop]
}
}
return dest
}
function $c(staticClassName, conditionalClassNames) {
var classNames = []
if (typeof conditionalClassNames == 'undefined') {
conditionalClassNames = staticClassName
}
else {
classNames.push(staticClassName)
}
for (var className in conditionalClassNames) {
if (!!conditionalClassNames[className]) {
classNames.push(className)
}
}
return classNames.join(' ')
}
<!DOCTYPE html>
<html>
<head>
<title>newforms &amp; React Contact Form Example</title>
<script src="//fb.me/react-0.9.0.js"></script>
<script src="//fb.me/JSXTransformer-0.9.0.js"></script>
<script src="newforms-0.5.0-dev.min.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap-theme.min.css">
</head>
<body>
<div class="container">
<div class="page-header">
<h1><a href="https://github.com/insin/newforms">newforms</a> &amp; <a href="http://facebook.github.io/react/">React</a> Contact Form Example</h1>
<p>A sample contact form made with newforms and React.</p>
<p>
The <a href="https://github.com/insin/newforms/tree/react">next version of newforms</a>
will use <code>React.DOM</code> to generate form contents &ndash; in
addition to no longer having to blow the entire form away on each render
due to React's DOM reconciliation, it should be easier to implement
custom form rendering using JSX.
</p>
<p>
Currently, newforms is only generating uncontrolled form inputs, so
form data must be collected manually (using <code>form.formData()</code>
with the real <code>&lt;form&gt;</code> DOM node) and form state must
be carefully managed between prop changes where they drive dynamic
elements a form may implement (for example: conditional display of the
Email and Question inputs below).
</p>
<p>
This should improve as the newforms API starts to grow away from its
<code>django.forms</code> roots&hellip;
</p>
</div>
<div id="contactform"></div>
</div>
<script type="text/jsx" src="contactform.js"></script>
<a href="https://gist.github.com/insin/9063570"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
</body>
</html>
/**
* newforms 0.5.0-dev - https://github.com/insin/newforms
* MIT Licensed
*/
!function(t){if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.forms=t()}}(function(){var t;return function e(t,r,i){function n(s,a){if(!r[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var u=r[s]={exports:{}};t[s][0].call(u.exports,function(e){var r=t[s][1][e];return n(r?r:e)},u,u.exports,e,t,r,i)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(t,e){"use strict";var r=t("Concur"),i=t("isomorph/is"),n=t("isomorph/format").formatObj,o=t("isomorph/object"),s=t("isomorph/time"),a=t("isomorph/url"),l=t("validators"),u=t("./util"),c=t("./widgets"),h=l.ValidationError,d=l.isEmptyValue,p=c.Widget,f=l.ipv6.cleanIPv6Address,m=r.extend({constructor:function B(t){t=o.extend({required:!0,widget:null,label:null,initial:null,helpText:null,errorMessages:null,showHiddenInitial:!1,validators:[],extraClasses:null},t),this.required=t.required,this.label=t.label,this.initial=t.initial,this.showHiddenInitial=t.showHiddenInitial,this.helpText=t.helpText||"",this.extraClasses=t.extraClasses;var e=t.widget||this.widget;e instanceof p||(e=new e),e.isRequired=this.required,o.extend(e.attrs,this.widgetAttrs(e)),this.widget=e,this.creationCounter=B.creationCounter++,this.errorMessages=o.extend({},this.defaultErrorMessages,t.errorMessages||{}),this.validators=this.defaultValidators.concat(t.validators)},widget:c.TextInput,hiddenWidget:c.HiddenInput,defaultValidators:[],defaultErrorMessages:{required:"This field is required.",invalid:"Enter a valid value."}});m.creationCounter=0,m.prototype.prepareValue=function(t){return t},m.prototype.toJavaScript=function(t){return t},m.prototype.validate=function(t){if(this.required&&d(t))throw h(this.errorMessages.required)},m.prototype.runValidators=function(t){if(!d(t)){for(var e=[],r=0,i=this.validators.length;i>r;r++)try{l.callValidator(this.validators[r],t)}catch(o){if(!(o instanceof h))throw o;if("undefined"!=typeof o.code&&"undefined"!=typeof this.errorMessages[o.code]&&this.errorMessages[o.code]!==this.defaultErrorMessages[o.code]){var s=this.errorMessages[o.code];"undefined"!=typeof o.params&&(s=n(s,o.params)),e.push(s)}else e=e.concat(o.messages())}if(e.length>0)throw h(e)}},m.prototype.clean=function(t){return t=this.toJavaScript(t),this.validate(t),this.runValidators(t),t},m.prototype.boundData=function(t){return t},m.prototype.widgetAttrs=function(){return{}},m.prototype._hasChanged=function(t,e){var r=null===e?"":e,i=null===t?"":t;return""+i!=""+r};var v=m.extend({constructor:function J(t){return this instanceof m?(t=o.extend({maxLength:null,minLength:null},t),this.maxLength=t.maxLength,this.minLength=t.minLength,m.call(this,t),null!==this.minLength&&this.validators.push(l.MinLengthValidator(this.minLength)),void(null!==this.maxLength&&this.validators.push(l.MaxLengthValidator(this.maxLength)))):new J(t)}});v.prototype.toJavaScript=function(t){return d(t)?"":""+t},v.prototype.widgetAttrs=function(t){var e={};return null!==this.maxLength&&(t instanceof c.TextInput||t instanceof c.PasswordInput)&&(e.maxLength=""+this.maxLength),e};var g=m.extend({widget:c.NumberInput,constructor:function H(t){return this instanceof m?(t=o.extend({maxValue:null,minValue:null},t),this.maxValue=t.maxValue,this.minValue=t.minValue,m.call(this,t),null!==this.minValue&&this.validators.push(l.MinValueValidator(this.minValue)),void(null!==this.maxValue&&this.validators.push(l.MaxValueValidator(this.maxValue)))):new H(t)}});g.prototype.defaultErrorMessages=o.extend({},g.prototype.defaultErrorMessages,{invalid:"Enter a whole number."}),g.prototype.toJavaScript=function(t){if(t=m.prototype.toJavaScript.call(this,t),d(t))return null;if(t=Number(t),isNaN(t)||-1!=t.toString().indexOf("."))throw h(this.errorMessages.invalid);return t},g.prototype.widgetAttrs=function(t){var e=m.prototype.widgetAttrs.call(this,t);return t instanceof c.NumberInput&&(null!==this.minValue&&(e.min=this.minValue),null!==this.maxValue&&(e.max=this.maxValue)),e};var y=g.extend({constructor:function W(t){return this instanceof m?void g.call(this,t):new W(t)}});y.FLOAT_REGEXP=/^[-+]?(?:\d+(?:\.\d+)?|(?:\d+)?\.\d+)$/,y.prototype.defaultErrorMessages=o.extend({},y.prototype.defaultErrorMessages,{invalid:"Enter a number."}),y.prototype.toJavaScript=function(t){if(t=m.prototype.toJavaScript.call(this,t),d(t))return null;if(t=u.strip(t),!y.FLOAT_REGEXP.test(t))throw h(this.errorMessages.invalid);if(t=parseFloat(t),isNaN(t))throw h(this.errorMessages.invalid);return t},y.prototype._hasChanged=function(t,e){var r=null===e?"":e,i=null===t?"":t;return i===r?!1:""===i||""===r?!0:parseFloat(""+i)!=parseFloat(""+r)},y.prototype.widgetAttrs=function(t){var e=g.prototype.widgetAttrs.call(this,t);return t instanceof c.NumberInput&&!o.hasOwn(t.attrs,"step")&&o.setDefault(e,"step","any"),e};var x=g.extend({constructor:function Y(t){return this instanceof m?(t=o.extend({maxDigits:null,decimalPlaces:null},t),this.maxDigits=t.maxDigits,this.decimalPlaces=t.decimalPlaces,void g.call(this,t)):new Y(t)}});x.DECIMAL_REGEXP=/^[-+]?(?:\d+(?:\.\d+)?|(?:\d+)?\.\d+)$/,x.prototype.defaultErrorMessages=o.extend({},x.prototype.defaultErrorMessages,{invalid:"Enter a number.",maxDigits:"Ensure that there are no more than {maxDigits} digits in total.",maxDecimalPlaces:"Ensure that there are no more than {maxDecimalPlaces} decimal places.",maxWholeDigits:"Ensure that there are no more than {maxWholeDigits} digits before the decimal point."}),x.prototype.clean=function(t){if(m.prototype.validate.call(this,t),d(t))return null;if(t=u.strip(""+t),!x.DECIMAL_REGEXP.test(t))throw h(this.errorMessages.invalid);var e=!1;("+"==t.charAt(0)||"-"==t.charAt(0))&&(e="-"==t.charAt(0),t=t.substr(1)),t=t.replace(/^0+/,"");var r=t.split("."),i=r[0].length,o=2==r.length?r[1].length:0,s=i+o;if(null!==this.maxDigits&&s>this.maxDigits)throw h(n(this.errorMessages.maxDigits,{maxDigits:this.maxDigits}));if(null!==this.decimalPlaces&&o>this.decimalPlaces)throw h(n(this.errorMessages.maxDecimalPlaces,{maxDecimalPlaces:this.decimalPlaces}));if(null!==this.maxDigits&&null!==this.decimalPlaces&&i>this.maxDigits-this.decimalPlaces)throw h(n(this.errorMessages.maxWholeDigits,{maxWholeDigits:this.maxDigits-this.decimalPlaces}));return"."==t.charAt(0)&&(t="0"+t),e&&(t="-"+t),this.runValidators(parseFloat(t)),t},x.prototype.widgetAttrs=function(t){var e=g.prototype.widgetAttrs.call(this,t);if(t instanceof c.NumberInput&&!o.hasOwn(t.attrs,"step")){var r="any";null!==this.decimalPlaces&&(r=0===this.decimalPlaces?"1":this.decimalPlaces<7?"0."+"000001".slice(-this.decimalPlaces):"1e-"+this.decimalPlaces),o.setDefault(e,"step",r)}return e};var w=m.extend({constructor:function(t){t=o.extend({inputFormats:null},t),m.call(this,t),null!==t.inputFormats&&(this.inputFormats=t.inputFormats)}});w.prototype.toJavaScript=function(t){if(i.Date(t)||(t=u.strip(t)),i.String(t))for(var e=0,r=this.inputFormats.length;r>e;e++)try{return this.strpdate(t,this.inputFormats[e])}catch(n){continue}throw h(this.errorMessages.invalid)},w.prototype.strpdate=function(t,e){return s.strpdate(t,e)},w.prototype._hasChanged=function(t,e){try{e=this.toJavaScript(e)}catch(r){if(!(r instanceof h))throw r;return!0}return t=this.toJavaScript(t),t&&e?t.getTime()!==e.getTime():t!==e};var _=w.extend({constructor:function $(t){return this instanceof m?void w.call(this,t):new $(t)},widget:c.DateInput,inputFormats:u.DEFAULT_DATE_INPUT_FORMATS});_.prototype.defaultErrorMessages=o.extend({},_.prototype.defaultErrorMessages,{invalid:"Enter a valid date."}),_.prototype.toJavaScript=function(t){return d(t)?null:t instanceof Date?new Date(t.getFullYear(),t.getMonth(),t.getDate()):w.prototype.toJavaScript.call(this,t)};var b=w.extend({constructor:function Z(t){return this instanceof m?void w.call(this,t):new Z(t)},widget:c.TimeInput,inputFormats:u.DEFAULT_TIME_INPUT_FORMATS});b.prototype.defaultErrorMessages=o.extend({},b.prototype.defaultErrorMessages,{invalid:"Enter a valid time."}),b.prototype.toJavaScript=function(t){return d(t)?null:t instanceof Date?new Date(1900,0,1,t.getHours(),t.getMinutes(),t.getSeconds()):w.prototype.toJavaScript.call(this,t)},b.prototype.strpdate=function(t,e){var r=s.strptime(t,e);return new Date(1900,0,1,r[3],r[4],r[5])};var F=w.extend({constructor:function Q(t){return this instanceof m?void w.call(this,t):new Q(t)},widget:c.DateTimeInput,inputFormats:u.DEFAULT_DATETIME_INPUT_FORMATS});F.prototype.defaultErrorMessages=o.extend({},F.prototype.defaultErrorMessages,{invalid:"Enter a valid date/time."}),F.prototype.toJavaScript=function(t){if(d(t))return null;if(t instanceof Date)return t;if(i.Array(t)){if(2!=t.length)throw h(this.errorMessages.invalid);if(d(t[0])&&d(t[1]))return null;t=t.join(" ")}return w.prototype.toJavaScript.call(this,t)};var M=v.extend({constructor:function G(t,e){return this instanceof m?(v.call(this,e),i.String(t)&&(t=new RegExp(t)),this.regex=t,void this.validators.push(l.RegexValidator({regex:this.regex}))):new G(t,e)}}),E=v.extend({constructor:function X(t){return this instanceof m?void v.call(this,t):new X(t)},widget:c.EmailInput,defaultValidators:[l.validateEmail]});E.prototype.clean=function(t){return t=u.strip(this.toJavaScript(t)),v.prototype.clean.call(this,t)};var C=m.extend({constructor:function z(t){return this instanceof m?(t=o.extend({maxLength:null,allowEmptyFile:!1},t),this.maxLength=t.maxLength,this.allowEmptyFile=t.allowEmptyFile,delete t.maxLength,void m.call(this,t)):new z(t)},widget:c.ClearableFileInput});C.prototype.defaultErrorMessages=o.extend({},C.prototype.defaultErrorMessages,{invalid:"No file was submitted. Check the encoding type on the form.",missing:"No file was submitted.",empty:"The submitted file is empty.",maxLength:"Ensure this filename has at most {max} characters (it has {length}).",contradicton:"Please either submit a file or check the clear checkbox, not both."}),C.prototype.toJavaScript=function(t){if(d(t))return null;if("undefined"==typeof t.name||"undefined"==typeof t.size)throw h(this.errorMessages.invalid);var e=t.name,r=t.size;if(null!==this.maxLength&&e.length>this.maxLength)throw h(n(this.errorMessages.maxLength,{max:this.maxLength,length:e.length}));if(!e)throw h(this.errorMessages.invalid);if(!this.allowEmptyFile&&!r)throw h(this.errorMessages.empty);return t},C.prototype.clean=function(t,e){if(t===c.FILE_INPUT_CONTRADICTION)throw h(this.errorMessages.contradiction);if(t===!1){if(!this.required)return!1;t=null}return!t&&e?e:v.prototype.clean.call(this,t)},C.prototype.boundData=function(t,e){return null===t||t===c.FILE_INPUT_CONTRADICTION?e:t},C.prototype._hasChanged=function(t,e){return null===e?!1:!0};var I=C.extend({constructor:function K(t){return this instanceof m?void C.call(this,t):new K(t)}});I.prototype.defaultErrorMessages=o.extend({},I.prototype.defaultErrorMessages,{invalidImage:"Upload a valid image. The file you uploaded was either not an image or a corrupted image."}),I.prototype.toJavaScript=function(t,e){var r=C.prototype.toJavaScript.call(this,t,e);return null===r?null:r};var D=v.extend({constructor:function te(t){return this instanceof m?(v.call(this,t),void this.validators.push(l.URLValidator())):new te(t)},widget:c.URLInput});D.prototype.defaultErrorMessages=o.extend({},D.prototype.defaultErrorMessages,{invalid:"Enter a valid URL.",invalidLink:"This URL appears to be a broken link."}),D.prototype.toJavaScript=function(t){if(t){var e=a.parseUri(t);e.protocol||(e.protocol="http"),e.path||(e.path="/"),t=a.makeUri(e)}return v.prototype.toJavaScript.call(this,t)},D.prototype.clean=function(t){return t=u.strip(this.toJavaScript(t)),v.prototype.clean.call(this,t)};var O=m.extend({constructor:function ee(t){return this instanceof m?void m.call(this,t):new ee(t)},widget:c.CheckboxInput});O.prototype.toJavaScript=function(t){if(t=!i.String(t)||"false"!=t.toLowerCase()&&"0"!=t?Boolean(t):!1,t=m.prototype.toJavaScript.call(this,t),!t&&this.required)throw h(this.errorMessages.required);return t},O.prototype._hasChanged=function(t,e){return"false"===t&&(t=!1),Boolean(t)!=Boolean(e)};var A=O.extend({constructor:function re(t){return this instanceof m?void O.call(this,t):new re(t)},widget:c.NullBooleanSelect});A.prototype.toJavaScript=function(t){return t===!0||"True"==t||"true"==t||"1"==t?!0:t===!1||"False"==t||"false"==t||"0"==t?!1:null},A.prototype.validate=function(){},A.prototype._hasChanged=function(t,e){return null!==t&&(t=Boolean(t)),null!==e&&(e=Boolean(e)),t!=e};var T=m.extend({constructor:function ie(t){return this instanceof m?(t=o.extend({choices:[]},t),m.call(this,t),void this.setChoices(t.choices)):new ie(t)},widget:c.Select});T.prototype.defaultErrorMessages=o.extend({},T.prototype.defaultErrorMessages,{invalidChoice:"Select a valid choice. {value} is not one of the available choices."}),T.prototype.choices=function(){return this._choices},T.prototype.setChoices=function(t){this._choices=this.widget.choices=t},T.prototype.toJavaScript=function(t){return d(t)?"":""+t},T.prototype.validate=function(t){if(m.prototype.validate.call(this,t),t&&!this.validValue(t))throw h(n(this.errorMessages.invalidChoice,{value:t}))},T.prototype.validValue=function(t){for(var e=this.choices(),r=0,n=e.length;n>r;r++)if(i.Array(e[r][1])){for(var o=e[r][1],s=0,a=o.length;a>s;s++)if(t===""+o[s][0])return!0}else if(t===""+e[r][0])return!0;return!1};var V=T.extend({constructor:function ne(t){return this instanceof m?(t=o.extend({coerce:function(t){return t},emptyValue:""},t),this.coerce=t.coerce,this.emptyValue=t.emptyValue,delete t.coerce,delete t.emptyValue,void T.call(this,t)):new ne(t)}});V.prototype.toJavaScript=function(t){if(t=T.prototype.toJavaScript.call(this,t),T.prototype.validate.call(this,t),t===this.emptyValue||d(t))return this.emptyValue;try{t=this.coerce(t)}catch(e){throw h(n(this.errorMessages.invalidChoice,{value:t}))}return t},V.prototype.validate=function(){};var P=T.extend({constructor:function oe(t){return this instanceof m?void T.call(this,t):new oe(t)},widget:c.SelectMultiple,hiddenWidget:c.MultipleHiddenInput});P.prototype.defaultErrorMessages=o.extend({},P.prototype.defaultErrorMessages,{invalidChoice:"Select a valid choice. {value} is not one of the available choices.",invalidList:"Enter a list of values."}),P.prototype.toJavaScript=function(t){if(!t)return[];if(!i.Array(t))throw h(this.errorMessages.invalidList);for(var e=[],r=0,n=t.length;n>r;r++)e.push(""+t[r]);return e},P.prototype.validate=function(t){if(this.required&&!t.length)throw h(this.errorMessages.required);for(var e=0,r=t.length;r>e;e++)if(!this.validValue(t[e]))throw h(n(this.errorMessages.invalidChoice,{value:t[e]}))},P.prototype._hasChanged=function(t,e){if(null===t&&(t=[]),null===e&&(e=[]),t.length!=e.length)return!0;for(var r=o.lookup(e),i=0,n=t.length;n>i;i++)if("undefined"==typeof r[""+t[i]])return!0;return!1};var L=P.extend({constructor:function se(t){return this instanceof m?(t=o.extend({coerce:function(t){return t},emptyValue:[]},t),this.coerce=t.coerce,this.emptyValue=t.emptyValue,delete t.coerce,delete t.emptyValue,void P.call(this,t)):new se(t)}});L.prototype.toJavaScript=function(t){if(t=P.prototype.toJavaScript.call(this,t),P.prototype.validate.call(this,t),t===this.emptyValue||d(t)||i.Array(t)&&!t.length)return this.emptyValue;for(var e=[],r=0,o=t.length;o>r;r++)try{e.push(this.coerce(t[r]))}catch(s){throw h(n(this.errorMessages.invalidChoice,{value:t[r]}))}return e},L.prototype.validate=function(){};var S=T.extend({constructor:function ae(t,e){return this instanceof m?(e=o.extend({match:null,recursive:!1,required:!0,widget:null,label:null,initial:null,helpText:null},e),this.path=t,this.match=e.match,this.recursive=e.recursive,delete e.match,delete e.recursive,e.choices=[],T.call(this,e),this.setChoices(this.required?[]:[["","---------"]]),null!==this.match&&(this.matchRE=new RegExp(this.match)),void(this.widget.choices=this.choices())):new ae(t,e)}}),R=m.extend({constructor:function le(t){if(!(this instanceof m))return new le(t);t=o.extend({fields:[]},t),m.call(this,t);for(var e=0,r=t.fields.length;r>e;e++)t.fields[e].required=!1;this.fields=t.fields}});R.prototype.clean=function(t){m.prototype.clean.call(this,t);for(var e=0,r=this.fields.length;r>e;e++)t=this.fields[e].clean(t);return t};var j=m.extend({constructor:function ue(t){if(!(this instanceof m))return new ue(t);t=o.extend({fields:[]},t),this.requireAllFields=o.pop(t,"requireAllFields",!0),m.call(this,t);for(var e=0,r=t.fields.length;r>e;e++){var i=t.fields[e];o.setDefault(i.errorMessages,"incomplete",this.errorMessages.incomplete),this.requireAllFields&&(i.required=!1)}this.fields=t.fields}});j.prototype.defaultErrorMessages=o.extend({},j.prototype.defaultErrorMessages,{invalid:"Enter a list of values.",incomplete:"Enter a complete value."}),j.prototype.validate=function(){},j.prototype.clean=function(t){var e=[],r=[];if(t&&!i.Array(t))throw h(this.errorMessages.invalid);var n=!0;if(i.Array(t))for(var o=0,s=t.length;s>o;o++)if(t[o]){n=!1;break}if(!t||n){if(this.required)throw h(this.errorMessages.required);return this.compress([])}for(o=0,s=this.fields.length;s>o;o++){var a=this.fields[o],l=t[o];if(void 0===l&&(l=null),d(l))if(this.requireAllFields){if(this.required)throw h(this.errorMessages.required,{code:"required"})}else if(a.required){-1==r.indexOf(a.errorMessages.incomplete)&&r.push(a.errorMessages.incomplete);continue}try{e.push(a.clean(l))}catch(u){if(!(u instanceof h))throw u;r=r.concat(u.messages().filter(function(t){return-1==r.indexOf(t)}))}}if(0!==r.length)throw h(r);var c=this.compress(e);return this.validate(c),this.runValidators(c),c},j.prototype.compress=function(){throw new Error("Subclasses must implement this method.")},j.prototype._hasChanged=function(t,e){var r,n;if(null===t)for(t=[],r=0,n=e.length;n>r;r++)t.push("");else i.Array(t)||(t=this.widget.decompress(t));for(r=0,n=this.fields.length;n>r;r++)if(this.fields[r]._hasChanged(t[r],e[r]))return!0;return!1};var N=j.extend({constructor:function ce(t){if(!(this instanceof m))return new ce(t);t=o.extend({inputDateFormats:null,inputTimeFormats:null},t);var e=o.extend({},this.defaultErrorMessages);"undefined"!=typeof t.errorMessages&&o.extend(e,t.errorMessages),t.fields=[_({inputFormats:t.inputDateFormats,errorMessages:{invalid:e.invalidDate}}),b({inputFormats:t.inputTimeFormats,errorMessages:{invalid:e.invalidTime}})],j.call(this,t)},widget:c.SplitDateTimeWidget,hiddenWidget:c.SplitHiddenDateTimeWidget});N.prototype.defaultErrorMessages=o.extend({},N.prototype.defaultErrorMessages,{invalidDate:"Enter a valid date.",invalidTime:"Enter a valid time."}),N.prototype.compress=function(t){if(i.Array(t)&&t.length>0){var e=t[0],r=t[1];if(d(e))throw h(this.errorMessages.invalidDate);if(d(r))throw h(this.errorMessages.invalidTime);return new Date(e.getFullYear(),e.getMonth(),e.getDate(),r.getHours(),r.getMinutes(),r.getSeconds())}return null};var k=v.extend({constructor:function he(t){return this instanceof m?void v.call(this,t):new he(t)}});k.prototype.defaultValidators=[l.validateIPv4Address],k.prototype.defaultErrorMessages=o.extend({},k.prototype.defaultErrorMessages,{invalid:"Enter a valid IPv4 address."});var U=v.extend({constructor:function de(t){if(!(this instanceof m))return new de(t);t=o.extend({protocol:"both",unpackIPv4:!1},t),this.unpackIPv4=t.unpackIPv4;var e=l.ipAddressValidators(t.protocol,t.unpackIPv4);this.defaultValidators=e.validators,this.defaultErrorMessages=o.extend({},this.defaultErrorMessages,{invalid:e.message}),v.call(this,t)}});U.prototype.toJavaScript=function(t){return t?t&&-1!=t.indexOf(":")?f(t,{unpackIPv4:this.unpackIPv4,errorMessage:this.errorMessages.invalid}):t:""};var q=v.extend({constructor:function pe(t){return this instanceof m?void v.call(this,t):new pe(t)}});q.prototype.defaultValidators=[l.validateSlug],q.prototype.defaultErrorMessages=o.extend({},q.prototype.defaultErrorMessages,{invalid:"Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens."}),q.prototype.clean=function(t){return t=u.strip(this.toJavaScript(t)),v.prototype.clean.call(this,t)},e.exports={Field:m,CharField:v,IntegerField:g,FloatField:y,DecimalField:x,BaseTemporalField:w,DateField:_,TimeField:b,DateTimeField:F,RegexField:M,EmailField:E,FileField:C,ImageField:I,URLField:D,BooleanField:O,NullBooleanField:A,ChoiceField:T,TypedChoiceField:V,MultipleChoiceField:P,TypedMultipleChoiceField:L,FilePathField:S,ComboField:R,MultiValueField:j,SplitDateTimeField:N,IPAddressField:k,GenericIPAddressField:U,SlugField:q}},{"./util":6,"./widgets":7,Concur:8,"isomorph/format":11,"isomorph/is":12,"isomorph/object":13,"isomorph/time":14,"isomorph/url":15,validators:18}],2:[function(t,e){"use strict";function r(t){var e=[];for(var r in t)s.hasOwn(t,r)&&t[r]instanceof m&&(e.push([r,t[r]]),delete t[r]);if(e.sort(function(t,e){return t[1].creationCounter-e[1].creationCounter}),s.hasOwn(t,"__mixin__")){var i=t.__mixin__;n.Array(i)||(i=[i]);for(var o=i.length-1;o>=0;o--){var a=i[o];if(n.Function(a)&&"undefined"!=typeof a.prototype.baseFields){e=s.items(a.prototype.baseFields).concat(e);var l=s.extend({},a.prototype);delete l.baseFields,i[o]=l}}t.__mixin__=i}"undefined"!=typeof this.baseFields&&(e=s.items(this.baseFields).concat(e)),t.baseFields=s.fromItems(e)}var i=t("Concur"),n=t("isomorph/is"),o=t("isomorph/format").formatObj,s=t("isomorph/object"),a=t("isomorph/copy"),l=t("validators"),u=t("./util"),c=t("./fields"),h=t("./widgets"),d=u.ErrorList,p=u.ErrorObject,f=l.ValidationError,m=c.Field,v=c.FileField,g=h.Textarea,y=h.TextInput,x="__all__",w=i.extend({constructor:function F(t,e,r){return this instanceof F?(this.form=t,this.field=e,this.name=r,this.htmlName=t.addPrefix(r),this.htmlInitialName=t.addInitialPrefix(r),this.htmlInitialId=t.addInitialPrefix(this.autoId()),this.label=null!==this.field.label?this.field.label:u.prettyName(r),void(this.helpText=e.helpText||"")):new F(t,e,r)}});w.prototype.errors=function(){return this.form.errors(this.name)||new this.form.errorConstructor},w.prototype.isHidden=function(){return this.field.widget.isHidden},w.prototype.autoId=function(){var t=this.form.autoId;return t?(t=""+t,-1!=t.indexOf("{name}")?o(t,{name:this.htmlName}):this.htmlName):""},w.prototype.data=function(){return this.field.widget.valueFromData(this.form.data,this.form.files,this.htmlName)},w.prototype.idForLabel=function(){var t=this.field.widget,e=s.get(t.attrs,"id",this.autoId());return t.idForLabel(e)},w.prototype.render=function(t){return this.field.showHiddenInitial?React.DOM.div(null,this.asWidget(t),this.asHidden({onlyInitial:!0})):this.asWidget(t)},w.prototype.subWidgets=w.prototype.__iter__=function(){return this.field.widget.subWidgets(this.htmlName,this.value())},w.prototype.asWidget=function(t){t=s.extend({widget:null,attrs:null,onlyInitial:!1},t);var e=null!==t.widget?t.widget:this.field.widget,r=null!==t.attrs?t.attrs:{},i=this.autoId(),n=t.onlyInitial?this.htmlInitialName:this.htmlName;return i&&"undefined"==typeof r.id&&"undefined"==typeof e.attrs.id&&(r.id=t.onlyInitial?this.htmlInitialId:i),e.render(n,this.value(),{attrs:r})},w.prototype.asText=function(t){return t=s.extend({},t,{widget:y()}),this.asWidget(t)},w.prototype.asTextarea=function(t){return t=s.extend({},t,{widget:g()}),this.asWidget(t)},w.prototype.asHidden=function(t){return t=s.extend({},t,{widget:new this.field.hiddenWidget}),this.asWidget(t)},w.prototype.value=function(){var t;return this.form.isBound?t=this.field.boundData(this.data(),s.get(this.form.initial,this.name,this.field.initial)):(t=s.get(this.form.initial,this.name,this.field.initial),n.Function(t)&&(t=t())),this.field.prepareValue(t)},w.prototype.getLabel=function(){return this._addLabelSuffix(""+this.label)},w.prototype._addLabelSuffix=function(t){return this.form.labelSuffix&&-1==":?.!".indexOf(t.charAt(t.length-1))&&(t+=this.form.labelSuffix),t},w.prototype.labelTag=function(t){t=s.extend({contents:null,attrs:null},t);var e;e=null!==t.contents?this._addLabelSuffix(""+t.contents):this.getLabel();var r=this.field.widget,i=s.get(r.attrs,"id",this.autoId());if(i){var n=s.extend(t.attrs||{},{htmlFor:r.idForLabel(i)});e=React.DOM.label(n,e)}return e},w.prototype.cssClasses=function(t){return t=t||this.field.extraClasses,null!==t&&n.Function(t.split)&&(t=t.split()),t=t||[],"undefined"!=typeof this.form.rowCssClass&&t.push(this.form.rowCssClass),this.errors().isPopulated()&&"undefined"!=typeof this.form.errorCssClass&&t.push(this.form.errorCssClass),this.field.required&&"undefined"!=typeof this.form.requiredCssClass&&t.push(this.form.requiredCssClass),t.join(" ")};var _=i.extend({constructor:function(t){t=s.extend({data:null,files:null,autoId:"id_{name}",prefix:null,initial:null,errorConstructor:d,labelSuffix:":",emptyPermitted:!1},t),this.isBound=null!==t.data||null!==t.files,this.data=t.data||{},this.files=t.files||{},this.autoId=t.autoId,this.prefix=t.prefix,this.initial=t.initial||{},this.errorConstructor=t.errorConstructor,this.labelSuffix=t.labelSuffix,this.emptyPermitted=t.emptyPermitted,this._errors=null,this._changedData=null,this.fields=a.deepCopy(this.baseFields)}});_.prototype.errors=function(t){return null===this._errors&&this.fullClean(),t?this._errors.get(t):this._errors},_.prototype.changedData=function(){if(null===this._changedData){this._changedData=[];var t;for(var e in this.fields)if(s.hasOwn(this.fields,e)){var r=this.fields[e],i=this.addPrefix(e),o=r.widget.valueFromData(this.data,this.files,i);if(r.showHiddenInitial){var a=this.addInitialPrefix(e),l=new r.hiddenWidget;try{t=l.valueFromData(this.data,this.files,a)}catch(u){if(!(u instanceof f))throw u;this._changedData.push(e);continue}}else t=s.get(this.initial,e,r.initial),n.Function(t)&&(t=t());r._hasChanged(t,o)&&this._changedData.push(e)}}return this._changedData},_.prototype.render=function(){return this.asTable()},_.prototype.boundFields=function(t){t=t||function(){return!0};var e=[];for(var r in this.fields)s.hasOwn(this.fields,r)&&t(this.fields[r],r)===!0&&e.push(w(this,this.fields[r],r));return e},_.prototype.boundFieldsObj=function(t){t=t||function(){return!0};var e={};for(var r in this.fields)s.hasOwn(this.fields,r)&&t(this.fields[r],r)===!0&&(e[r]=w(this,this.fields[r],r));return e},_.prototype.boundField=function(t){if(!s.hasOwn(this.fields,t))throw new Error("Form does not have a '"+t+"' field.");return w(this,this.fields[t],t)},_.prototype.isValid=function(){return this.isBound?!this.errors().isPopulated():!1},_.prototype.addPrefix=function(t){return null!==this.prefix?o("{prefix}-{fieldName}",{prefix:this.prefix,fieldName:t}):t},_.prototype.addInitialPrefix=function(t){return o("initial-{fieldName}",{fieldName:this.addPrefix(t)})},_.prototype._htmlOutput=function(t,e,r){for(var i=this.nonFieldErrors(),n=[],o=[],s=null,a=null,l=this.hiddenFields(),u=this.visibleFields(),c=0,h=l.length;h>c;c++){var d=l[c],p=d.errors();p.isPopulated&&i.extend(p.messages().map(function(t){return"(Hidden field "+d.name+") "+t})),o.push(d.render())}for(c=0,h=u.length;h>c;c++){d=u[c],s="",a=d.cssClasses(),a&&(s=a);var f=null,m=null,v=null,g=null;p=d.errors(),p.isPopulated()&&(f=p,r===!0&&(n.push(e(f.render())),f=null)),d.label&&(m=d.labelTag()||""),d.field.helpText&&(v=d.field.helpText),c==h-1&&o.length>0&&(g=o),null!==f&&(f=f.render()),n.push(t(d.htmlName,m,d.render(),v,f,s,g))}return i.isPopulated()&&(g=null,o.length>0&&0===n.length&&(g=o),n.splice(0,0,e(i.render(),g))),o.length>0&&0===n.length&&n.push(e("",o,this.hiddenFieldRowCssClass)),n},_.prototype.asTable=function(){var t=function(t,e,r,i,n,o,s){var a=[];n&&a.push(n),a.push(r),i&&(a.push(React.DOM.br(null)),a.push(i)),s&&(a=a.concat(s));var l={key:t};return o&&(l.className=o),React.DOM.tr(l,React.DOM.th(null,e),React.DOM.td(null,a))},e=function(t,e,r){var i=[];t&&i.push(t),e&&(i=i.concat(e));var n={};return r&&(n.className=r),React.DOM.tr(n,React.DOM.td({colSpan:2},i))};return function(){return this._htmlOutput(t,e,!1)}}(),_.prototype.asUL=function(){var t=function(t,e,r,i,n,o,s){var a=[];n&&a.push(n),e&&a.push(e),a.push(" "),a.push(r),i&&(a.push(" "),a.push(i)),s&&(a=a.concat(s));var l={key:t};return o&&(l.className=o),React.DOM.li(l,a)},e=function(t,e,r){var i=[];t&&i.push(t),e&&(i=i.concat(e));var n={};return r&&(n.className=r),React.DOM.li(n,i)};return function(){return this._htmlOutput(t,e,!1)}}(),_.prototype.asP=function(){var t=function(t,e,r,i,n,o,s){var a=[];e&&a.push(e),a.push(" "),a.push(r),i&&(a.push(" "),a.push(i)),s&&(a=a.concat(s));var l={key:t};return o&&(l.className=o),React.DOM.p(l,a)},e=function(t,e,r){if(e){var i=[];t&&i.push(t),i=i.concat(e);var n={};return r&&(n.className=r),React.DOM.div(n,i)}return t};return function(){return this._htmlOutput(t,e,!0)}}(),_.prototype.nonFieldErrors=function(){return this.errors(x)||new this.errorConstructor},_.prototype._rawValue=function(t){var e=this.fields[t],r=this.addPrefix(t);return e.widget.valueFromData(this.data,this.files,r)},_.prototype.addError=function(t,e){if(e instanceof f||(e=f(e)),s.hasOwn(e,"errorObj")){if(null!==t)throw new Error("The argument 'field' must be null when the 'error' argument contains errors for multiple fields.");e=e.errorObj}else{var r=e.errorList;e={},e[t||x]=r}for(var i=Object.keys(e),n=0,o=i.length;o>n;n++){if(t=i[n],r=e[t],!this._errors.hasField(t)){if(t!==x&&!s.hasOwn(this.fields,t)){var a=this.constructor.name?"'"+this.constructor.name+"'":"Form";throw new Error(a+" has no field named '"+t+"'")}this._errors.set(t,new this.errorConstructor)}this._errors.get(t).extend(r),s.hasOwn(this.cleanedData,t)&&delete this.cleanedData[t]}},_.prototype.fullClean=function(){this._errors=p(),this.isBound&&(this.cleanedData={},(!this.emptyPermitted||this.hasChanged())&&(this._cleanFields(),this._cleanForm(),this._postClean()))},_.prototype._cleanFields=function(){for(var t in this.fields)if(s.hasOwn(this.fields,t)){var e=this.fields[t],r=e.widget.valueFromData(this.data,this.files,this.addPrefix(t));try{if(e instanceof v){var i=s.get(this.initial,t,e.initial);r=e.clean(r,i)}else r=e.clean(r);this.cleanedData[t]=r;var o="clean_"+t;if("undefined"!=typeof this[o]&&n.Function(this[o])){r=this[o](),this.cleanedData[t]=r;continue}o="clean"+t.charAt(0).toUpperCase()+t.substr(1),"undefined"!=typeof this[o]&&n.Function(this[o])&&(r=this[o](),this.cleanedData[t]=r)}catch(a){if(!(a instanceof f))throw a;this.addError(t,a)}}},_.prototype._cleanForm=function(){var t;try{t=this.clean()}catch(e){if(!(e instanceof f))throw e;this.addError(null,e)}t&&(this.cleanedData=t)},_.prototype._postClean=function(){},_.prototype.clean=function(){return this.cleanedData},_.prototype.hasChanged=function(){return this.changedData().length>0},_.prototype.isMultipart=function(){for(var t in this.fields)if(s.hasOwn(this.fields,t)&&this.fields[t].widget.needsMultipartForm)return!0;return!1},_.prototype.hiddenFields=function(){return this.boundFields(function(t){return t.widget.isHidden})},_.prototype.visibleFields=function(){return this.boundFields(function(t){return!t.widget.isHidden})};var b=_.extend({__meta__:r,constructor:function(){_.apply(this,arguments)}});e.exports={NON_FIELD_ERRORS:x,BoundField:w,BaseForm:_,DeclarativeFieldsMeta:r,Form:b}},{"./fields":1,"./util":6,"./widgets":7,Concur:8,"isomorph/copy":10,"isomorph/format":11,"isomorph/is":12,"isomorph/object":13,validators:18}],3:[function(t,e){"use strict";function r(t,e){e=o.extend({formset:E,extra:1,canOrder:!1,canDelete:!1,maxNum:F,validateMax:!1,minNum:b,validateMin:!1},e);var r=o.pop(e,"formset"),i=o.pop(e,"extra"),n=o.pop(e,"canOrder"),s=o.pop(e,"canDelete"),a=o.pop(e,"maxNum"),l=o.pop(e,"validateMax"),u=o.pop(e,"minNum"),c=o.pop(e,"validateMin"),h=a+F;i+=u,e.constructor=function(e){this.form=t,this.extra=i,this.canOrder=n,this.canDelete=s,this.maxNum=a,this.validateMax=l,this.minNum=u,this.validateMin=c,this.absoluteMax=h,r.call(this,e)
};var d=r.extend(e);return d}function i(t){for(var e=!0,r=0,i=t.length;i>r;r++)t[r].isValid()||(e=!1);return e}var n=t("Concur"),o=t("isomorph/object"),s=t("validators"),a=t("./util"),l=t("./widgets"),u=t("./fields"),c=t("./forms"),h=a.ErrorList,d=s.ValidationError,p=u.IntegerField,f=u.BooleanField,m=l.HiddenInput,v="TOTAL_FORMS",g="INITIAL_FORMS",y="MIN_NUM_FORMS",x="MAX_NUM_FORMS",w="ORDER",_="DELETE",b=0,F=1e3,M=function(){var t={};return t[v]=p({widget:m}),t[g]=p({widget:m}),t[y]=p({required:!1,widget:m}),t[x]=p({required:!1,widget:m}),c.Form.extend(t)}(),E=n.extend({constructor:function(t){t=o.extend({data:null,files:null,autoId:"id_{name}",prefix:null,initial:null,errorConstructor:h,managementFormCssClass:null},t),this.isBound=null!==t.data||null!==t.files,this.prefix=t.prefix||this.getDefaultPrefix(),this.autoId=t.autoId,this.data=t.data||{},this.files=t.files||{},this.initial=t.initial,this.errorConstructor=t.errorConstructor,this.managementFormCssClass=t.managementFormCssClass,this._forms=null,this._errors=null,this._nonFormErrors=null}});E.prototype.managementForm=function(){var t;if(this.isBound){if(t=new M({data:this.data,autoId:this.autoId,prefix:this.prefix}),!t.isValid())throw d("ManagementForm data is missing or has been tampered with",{code:"missing_management_form"})}else{var e={};e[v]=this.totalFormCount(),e[g]=this.initialFormCount(),e[y]=this.minNum,e[x]=this.maxNum,t=new M({autoId:this.autoId,prefix:this.prefix,initial:e})}return null!==this.managementFormCssClass&&(t.hiddenFieldRowCssClass=this.managementFormCssClass),t},E.prototype.totalFormCount=function(){if(this.isBound)return Math.min(this.managementForm().cleanedData[v],this.absoluteMax);var t=this.initialFormCount(),e=this.initialFormCount()+this.extra;return null!==this.maxNum&&t>this.maxNum&&this.maxNum>=0&&(e=t),null!==this.maxNum&&e>this.maxNum&&this.maxNum>=0&&(e=this.maxNum),e},E.prototype.initialFormCount=function(){if(this.isBound)return this.managementForm().cleanedData[g];var t=null!==this.initial&&this.initial.length>0?this.initial.length:0;return t},E.prototype.forms=function(){if(null===this._forms){this._forms=[];for(var t=this.totalFormCount(),e=0;t>e;e++)this._forms.push(this._constructForm(e))}return this._forms},E.prototype._constructForm=function(t){var e={autoId:this.autoId,prefix:this.addPrefix(t),errorConstructor:this.errorConstructor};this.isBound&&(e.data=this.data,e.files=this.files),null!==this.initial&&this.initial.length>0&&"undefined"!=typeof this.initial[t]&&(e.initial=this.initial[t]),t>=this.initialFormCount()&&(e.emptyPermitted=!0);var r=new this.form(e);return this.addFields(r,t),r},E.prototype.initialForms=function(){return this.forms().slice(0,this.initialFormCount())},E.prototype.extraForms=function(){return this.forms().slice(this.initialFormCount())},E.prototype.emptyForm=function(){var t={autoId:this.autoId,prefix:this.addPrefix("__prefix__"),emptyPermitted:!0},e=new this.form(t);return this.addFields(e,null),e},E.prototype.cleanedData=function(){if(!this.isValid())throw new Error(this.constructor.name+" object has no attribute 'cleanedData'");return this.forms().map(function(t){return t.cleanedData})},E.prototype.deletedForms=function(){if(!this.isValid()||!this.canDelete)return[];var t=this.forms();if("undefined"==typeof this._deletedFormIndexes){this._deletedFormIndexes=[];for(var e=0,r=t.length;r>e;e++){var i=t[e];e>=this.initialFormCount()&&!i.hasChanged()||this._shouldDeleteForm(i)&&this._deletedFormIndexes.push(e)}}return this._deletedFormIndexes.map(function(e){return t[e]})},E.prototype.orderedForms=function(){if(!this.isValid()||!this.canOrder)throw new Error(this.constructor.name+" object has no attribute 'orderedForms'");var t=this.forms();if("undefined"==typeof this._ordering){this._ordering=[];for(var e=0,r=t.length;r>e;e++){var i=t[e];e>=this.initialFormCount()&&!i.hasChanged()||this.canDelete&&this._shouldDeleteForm(i)||this._ordering.push([e,i.cleanedData[w]])}this._ordering.sort(function(t,e){return null===t[1]&&null===e[1]?t[0]-e[0]:null===t[1]?1:null===e[1]?-1:t[1]-e[1]})}return this._ordering.map(function(e){return t[e[0]]})},E.prototype.getDefaultPrefix=function(){return"form"},E.prototype.nonFormErrors=function(){return null===this._nonFormErrors&&this.fullClean(),this._nonFormErrors},E.prototype.errors=function(){return null===this._errors&&this.fullClean(),this._errors},E.prototype.totalErrorCount=function(){return this.nonFormErrors().length()+this.errors().reduce(function(t,e){return t+e.length()},0)},E.prototype._shouldDeleteForm=function(t){return o.get(t.cleanedData,_,!1)},E.prototype.isValid=function(){if(!this.isBound)return!1;var t=!0;this.errors();for(var e=this.forms(),r=0,i=e.length;i>r;r++){var n=e[r];this.canDelete&&this._shouldDeleteForm(n)||n.isValid()||(t=!1)}return t&&!this.nonFormErrors().isPopulated()},E.prototype.fullClean=function(){if(this._errors=[],this._nonFormErrors=new this.errorConstructor,this.isBound){for(var t=this.forms(),e=0,r=t.length;r>e;e++){var i=t[e];this._errors.push(i.errors())}try{var n=this.totalFormCount(),o=this.deletedForms().length;if(this.validateMax&&n-o>this.maxNum||this.managementForm().cleanedData[v]>this.absoluteMax)throw d("Please submit "+this.maxNum+" or fewer forms.",{code:"tooManyForms"});if(this.validateMin&&n-o<this.minNum)throw d("Please submit "+this.minNum+" or more forms.",{code:"tooFewForms"});this.clean()}catch(s){if(!(s instanceof d))throw s;this._nonFormErrors=new this.errorConstructor(s.messages())}}},E.prototype.clean=function(){},E.prototype.hasChanged=function(){for(var t=this.forms(),e=0,r=t.length;r>e;e++)if(t[e].hasChanged())return!0;return!1},E.prototype.addFields=function(t,e){this.canOrder&&(t.fields[w]=p(null!=e&&e<this.initialFormCount()?{label:"Order",initial:e+1,required:!1}:{label:"Order",required:!1})),this.canDelete&&(t.fields[_]=f({label:"Delete",required:!1}))},E.prototype.addPrefix=function(t){return this.prefix+"-"+t},E.prototype.isMultipart=function(){return this.forms().length>0&&this.forms()[0].isMultipart()},E.prototype.render=function(){return this.asTable()},E.prototype.asTable=function(){var t=this.managementForm().asTable();return this.forms().forEach(function(e){t=t.concat(e.asTable())}),t},E.prototype.asP=function(){var t=this.managementForm().asP();return this.forms().forEach(function(e){t=t.concat(e.asP())}),t},E.prototype.asUL=function(){var t=this.managementForm().asUL();return this.forms().forEach(function(e){t=t.concat(e.asUL())}),t},e.exports={DEFAULT_MAX_NUM:F,BaseFormSet:E,formsetFactory:r,allValid:i}},{"./fields":1,"./forms":2,"./util":6,"./widgets":7,Concur:8,"isomorph/object":13,validators:18}],4:[function(t,e){"use strict";function r(t){this.field=t,this.modelQuery=t.modelQuery}var i=t("isomorph/object"),n=t("validators"),o=t("./util"),s=t("./fields"),a=s.Field,l=n.ValidationError,u={throwsIfNotFound:!0,notFoundErrorConstructor:Error,notFoundValue:null,prepareValue:function(){throw new Error("You must implement the forms.ModelInterface methods to use Model fields")},findById:function(){throw new Error("You must implement the forms.ModelInterface methods to use Model fields")}};r.prototype.__iter__=function(){var t=[];return null!==this.field.emptyLabel&&t.push(["",this.field.emptyLabel]),this.field.cacheChoices?(null===this.field.choiceCache&&(this.field.choiceCache=t.concat(this.modelChoices())),this.field.choiceCache):t.concat(this.modelChoices())},r.prototype.modelChoices=function(){for(var t=o.iterate(this.modelQuery),e=[],r=0,i=t.length;i>r;r++)e.push(this.choice(t[r]));return e},r.prototype.choice=function(t){return[this.field.prepareValue(t),this.field.labelFromInstance(t)]};var c=s.ChoiceField.extend({constructor:function h(t,e){return this instanceof a?(e=i.extend({required:!0,initial:null,cacheChoices:!1,emptyLabel:"---------",modelInterface:u},e),this.emptyLabel=e.required===!0&&null!==e.initial?null:e.emptyLabel,this.emptyLabel=e.emptyLabel,this.cacheChoices=e.cacheChoices,this.modelInterface=e.modelInterface,a.call(this,e),this.setModelQuery(t),void(this.choiceCache=null)):new h(t,e)}});c.prototype.defaultErrorMessages=i.extend({},c.prototype.defaultErrorMessages,{invalidChoice:"Select a valid choice. That choice is not one of the available choices."}),c.prototype.getModelQuery=function(){return this.modelQuery},c.prototype.setModelQuery=function(t){this.modelQuery=t,this.widget.choices=this.getChoices()},c.prototype.getChoices=function(){return"undefined"!=typeof this._choices?this._choices:new r(this)},c.prototype.prepareValue=function(t){var e=null;return null!=t&&(e=this.modelInterface.prepareValue(t)),null==e&&(e=a.prototype.prepareValue.call(this,t)),e},c.prototype.labelFromInstance=function(t){return""+t},c.prototype.toJavaScript=function(t){if(n.isEmptyValue(t))return null;if(this.modelInterface.throwsIfNotFound)try{t=this.modelInterface.findById(this.modelQuery,t)}catch(e){if(null!==this.modelInterface.notFoundErrorConstructor&&!(e instanceof this.modelInterface.notFoundErrorConstructor))throw e;throw new l(this.errorMessages.invalidChoice)}else if(t=this.modelInterface.findById(this.modelQuery,t),t===this.modelInterface.notFoundValue)throw new l(this.errorMessages.invalidChoice);return t},c.prototype.validate=function(t){return a.prototype.validate.call(this,t)},e.exports={ModelInterface:u,ModelChoiceField:c}},{"./fields":1,"./util":6,"isomorph/object":13,validators:18}],5:[function(t,e){"use strict";var r=t("isomorph/object"),i=t("validators"),n=t("./util"),o=t("./widgets"),s=t("./fields"),a=t("./forms"),l=t("./formsets"),u=t("./models");r.extend(e.exports,{ValidationError:i.ValidationError,ErrorObject:n.ErrorObject,ErrorList:n.ErrorList,formData:n.formData,util:{iterate:n.iterate,prettyName:n.prettyName}},i,o,s,a,l,u)},{"./fields":1,"./forms":2,"./formsets":3,"./models":4,"./util":6,"./widgets":7,"isomorph/object":13,validators:18}],6:[function(t,e){"use strict";function r(t){return o.Array(t)?t:(o.Function(t)&&(t=t()),null!=t&&o.Function(t.__iter__)&&(t=t.__iter__()),t||[])}function i(t){var e={};if(o.String(t)&&(t=document.getElementById(t)||document.forms[t]),!t)throw new Error("formData couldn't find a form with '"+t+"'");for(var r=0,i=t.elements.length;i>r;r++){var n=t.elements[r],a=n.type,l=null;if("hidden"==a||"password"==a||"text"==a||"email"==a||"url"==a||"number"==a||"textarea"==a||("checkbox"==a||"radio"==a)&&n.checked)l=n.value;else if("select-one"==a)l=n.options[n.selectedIndex].value;else if("select-multiple"==a){l=[];for(var u=0,c=n.options.length;c>u;u++)n.options[u].selected&&l.push(n.options[u].value);0===l.length&&(l=null)}null!==l&&(e[n.name]=s.hasOwn(e,n.name)?o.Array(e[n.name])?e[n.name].concat(l):[e[n.name],l]:l)}return e}var n=t("Concur"),o=t("isomorph/is"),s=t("isomorph/object"),a=t("validators"),l=a.ValidationError,u=["%Y-%m-%d","%m/%d/%Y","%m/%d/%y","%b %d %Y","%b %d, %Y","%d %b %Y","%d %b, %Y","%B %d %Y","%B %d, %Y","%d %B %Y","%d %B, %Y"],c=["%H:%M:%S","%H:%M"],h=["%Y-%m-%d %H:%M:%S","%Y-%m-%d %H:%M","%Y-%m-%d","%m/%d/%Y %H:%M:%S","%m/%d/%Y %H:%M","%m/%d/%Y","%m/%d/%y %H:%M:%S","%m/%d/%y %H:%M","%m/%d/%y"],d=function(){var t=/([A-Z]+)/g,e=/[ _]+/,r=/^[A-Z][A-Z0-9]+$/;return function(i){var n=i.replace(t," $1").split(e);""===n[0]&&n.splice(0,1);for(var o=0,s=n.length;s>o;o++)0===o?n[0]=n[0].charAt(0).toUpperCase()+n[0].substr(1):r.test(n[o])||(n[o]=n[o].charAt(0).toLowerCase()+n[o].substr(1));return n.join(" ")}}(),p=function(){var t=/(^\s+|\s+$)/g;return function(e){return(""+e).replace(t,"")}}(),f=n.extend({constructor:function v(t){return this instanceof v?void(this.errors=t||{}):new v(t)}});f.prototype.set=function(t,e){this.errors[t]=e},f.prototype.get=function(t){return this.errors[t]},f.prototype.hasField=function(t){return s.hasOwn(this.errors,t)},f.prototype.length=function(){return Object.keys(this.errors).length},f.prototype.isPopulated=function(){return this.length()>0},f.prototype.render=function(){return this.asUL()},f.prototype.asUL=function(){var t=Object.keys(this.errors).map(function(t){return React.DOM.li(null,t,this.errors[t].asUL())}.bind(this));return 0===t.length?"":React.DOM.ul({className:"errorlist"},t)},f.prototype.asText=function(){return Object.keys(this.errors).map(function(t){var e=this.errors[t].messages();return["* "+t].concat(e.map(function(t){return" * "+t})).join("\n")}.bind(this)).join("\n")};var m=n.extend({constructor:function g(t){return this instanceof g?void(this.data=t||[]):new g(t)}});m.prototype.extend=function(t){this.data.push.apply(this.data,t)},m.prototype.length=function(){return this.data.length},m.prototype.isPopulated=function(){return this.length()>0},m.prototype.messages=function(){for(var t=[],e=0,r=this.data.length;r>e;e++){var i=this.data[e];i instanceof l&&(i=i.messages()[0]),t.push(i)}return t},m.prototype.render=function(){return this.asUL()},m.prototype.asUL=function(){return React.DOM.ul({className:"errorlist"},this.messages().map(function(t){return React.DOM.li(null,t)}))},m.prototype.asText=function(){return this.messages().map(function(t){return"* "+t}).join("\n")},e.exports={DEFAULT_DATE_INPUT_FORMATS:u,DEFAULT_TIME_INPUT_FORMATS:c,DEFAULT_DATETIME_INPUT_FORMATS:h,ErrorObject:f,ErrorList:m,formData:i,iterate:r,prettyName:d,strip:p}},{Concur:8,"isomorph/is":12,"isomorph/object":13,validators:18}],7:[function(t,e){"use strict";var r=t("Concur"),i=t("isomorph/is"),n=t("isomorph/format").formatObj,o=t("isomorph/object"),s=t("isomorph/time"),a=t("./util"),l=r.extend({constructor:function J(t,e,r,i){return this instanceof J?(this.parentWidget=t,this.name=e,this.value=r,i=o.extend({attrs:null,choices:[]},i),this.attrs=i.attrs,void(this.choices=i.choices)):new J(t,e,r,i)}});l.prototype.render=function(){var t={attrs:this.attrs};return this.choices.length&&(t.choices=this.choices),this.parentWidget.render(this.name,this.value,t)};var u=r.extend({constructor:function(t){t=o.extend({attrs:null},t),this.attrs=o.extend({},t.attrs)},isHidden:!1,needsMultipartForm:!1,isRequired:!1});u.prototype.subWidgets=function(t,e,r){return[l(this,t,e,r)]},u.prototype.render=function(){throw new Error("Constructors extending must implement a render() method.")},u.prototype.buildAttrs=function(t,e){var r=o.extend({},this.attrs,e,t);return r.ref=r.id,r},u.prototype.valueFromData=function(t,e,r){return o.get(t,r,null)},u.prototype.idForLabel=function(t){return t};var c=u.extend({constructor:function H(t){return this instanceof u?void u.call(this,t):new H(t)},inputType:null});c.prototype._formatValue=function(t){return t},c.prototype.render=function(t,e,r){r=o.extend({attrs:null},r),null===e&&(e="");var i=this.buildAttrs(r.attrs,{type:this.inputType,name:t});return""!==e&&(i.defaultValue=""+this._formatValue(e)),React.DOM.input(i)};var h=c.extend({constructor:function W(t){return this instanceof u?(t=o.extend({attrs:null},t),null!=t.attrs&&(this.inputType=o.pop(t.attrs,"type",this.inputType)),void c.call(this,t)):new W(t)},inputType:"text"}),d=h.extend({constructor:function Y(t){return this instanceof u?void h.call(this,t):new Y(t)},inputType:"number"}),p=h.extend({constructor:function $(t){return this instanceof u?void h.call(this,t):new $(t)},inputType:"email"}),f=h.extend({constructor:function Z(t){return this instanceof u?void h.call(this,t):new Z(t)},inputType:"url"}),m=h.extend({constructor:function Q(t){return this instanceof u?(t=o.extend({renderValue:!1},t),h.call(this,t),void(this.renderValue=t.renderValue)):new Q(t)},inputType:"password"});m.prototype.render=function(t,e,r){return this.renderValue||(e=""),h.prototype.render.call(this,t,e,r)};var v=c.extend({constructor:function G(t){return this instanceof u?void c.call(this,t):new G(t)},inputType:"hidden",isHidden:!0}),g=v.extend({constructor:function X(t){return this instanceof u?void v.call(this,t):new X(t)}});g.prototype.render=function(t,e,r){r=o.extend({attrs:null},r),null===e&&(e=[]);for(var i=this.buildAttrs(r.attrs,{type:this.inputType,name:t}),s=o.get(i,"id",null),a=[],l=0,u=e.length;u>l;l++){var c=o.extend({},i,{value:e[l]});s&&(c.id=n("{id}_{i}",{id:s,i:l})),a.push(React.DOM.input(c))}return React.DOM.div(null,a)},g.prototype.valueFromData=function(t,e,r){return"undefined"!=typeof t[r]?[].concat(t[r]):null};var y=c.extend({constructor:function z(t){return this instanceof u?void c.call(this,t):new z(t)},inputType:"file",needsMultipartForm:!0});y.prototype.render=function(t,e,r){return c.prototype.render.call(this,t,null,r)},y.prototype.valueFromData=function(t,e,r){return o.get(e,r,null)};var x={},w=y.extend({constructor:function K(t){return this instanceof u?void y.call(this,t):new K(t)},initialText:"Currently",inputText:"Change",clearCheckboxLabel:"Clear"});w.prototype.clearCheckboxName=function(t){return t+"-clear"},w.prototype.clearCheckboxId=function(t){return t+"_id"},w.prototype.render=function(t,e,r){var i=y.prototype.render.call(this,t,e,r);if(e&&"undefined"!=typeof e.url){var n=[this.initialText,": ",React.DOM.a({href:e.url},""+e)," "];if(!this.isRequired){var o=this.clearCheckboxName(t),s=this.clearCheckboxId(o);n=n.concat([I().render(o,!1,{attrs:{id:s}})," ",React.DOM.label({htmlFor:s},this.clearCheckboxLabel)])}return n=n.concat([React.DOM.br(null),this.inputText,": ",i]),React.DOM.div(null,n)}return i},w.prototype.valueFromData=function(t,e,r){var i=y.prototype.valueFromData(t,e,r);return!this.isRequired&&I().valueFromData(t,e,this.clearCheckboxName(r))?i?x:!1:i};var _=u.extend({constructor:function te(t){return this instanceof u?(t=o.extend({attrs:null},t),t.attrs=o.extend({rows:"10",cols:"40"},t.attrs),void u.call(this,t)):new te(t)}});_.prototype.render=function(t,e,r){r=o.extend({attrs:null},r),null===e&&(e="");var i=this.buildAttrs(r.attrs,{name:t,defaultValue:e});return React.DOM.textarea(i)};var b=h.extend({constructor:function(t){t=o.extend({format:null},t),h.call(this,t),this.format=null!==t.format?t.format:this.defaultFormat}});b.prototype._formatValue=function(t){return i.Date(t)?s.strftime(t,this.format):t};var F=b.extend({constructor:function ee(t){return this instanceof ee?void b.call(this,t):new ee(t)},defaultFormat:a.DEFAULT_DATE_INPUT_FORMATS[0]}),M=b.extend({constructor:function re(t){return this instanceof re?void b.call(this,t):new re(t)},defaultFormat:a.DEFAULT_DATETIME_INPUT_FORMATS[0]}),E=b.extend({constructor:function ie(t){return this instanceof ie?void b.call(this,t):new ie(t)},defaultFormat:a.DEFAULT_TIME_INPUT_FORMATS[0]}),C=function(t){return t!==!1&&null!==t&&""!==t},I=u.extend({constructor:function ne(t){return this instanceof u?(t=o.extend({checkTest:C},t),u.call(this,t),void(this.checkTest=t.checkTest)):new ne(t)}});I.prototype.render=function(t,e,r){r=o.extend({attrs:null},r);var i=this.checkTest(e),n=this.buildAttrs(r.attrs,{type:"checkbox",name:t});return""!==e&&e!==!0&&e!==!1&&null!==e&&void 0!==e&&(n.value=e),i&&(n.defaultChecked="checked"),React.DOM.input(n)},I.prototype.valueFromData=function(t,e,r){if("undefined"==typeof t[r])return!1;var n=t[r],s={"true":!0,"false":!1};return i.String(n)&&(n=o.get(s,n.toLowerCase(),n)),!!n};var D=u.extend({constructor:function oe(t){return this instanceof u?(t=o.extend({choices:[]},t),u.call(this,t),void(this.choices=t.choices||[])):new oe(t)},allowMultipleSelected:!1});D.prototype.render=function(t,e,r){r=o.extend({attrs:null,choices:[]},r),null===e&&(e="");var i=this.buildAttrs(r.attrs,{name:t}),n=this.renderOptions(r.choices,[e]);return React.DOM.select(i,n)},D.prototype.renderOptions=function(t,e){var r,n,o={},s=i.String(e);for(r=0,n=e.length;n>r;r++)o[""+(s?e.charAt(r):e[r])]=!0;var l=[],u=a.iterate(this.choices).concat(t||[]);for(r=0,n=u.length;n>r;r++)if(i.Array(u[r][1])){for(var c=[],h=u[r][1],d=0,p=h.length;p>d;d++)c.push(this.renderOption(o,h[d][0],h[d][1]));l.push(React.DOM.optgroup({label:u[r][0]},c))}else l.push(this.renderOption(o,u[r][0],u[r][1]));return l},D.prototype.renderOption=function(t,e,r){e=""+e;var i={value:e};return"undefined"!=typeof t[e]&&(i.selected="selected",this.allowMultipleSelected||delete t[e]),React.DOM.option(i,r)};var O=D.extend({constructor:function se(t){return this instanceof u?(t=t||{},t.choices=[["1","Unknown"],["2","Yes"],["3","No"]],void D.call(this,t)):new se(t)}});O.prototype.render=function(t,e,r){return e=e===!0||"2"==e?"2":e===!1||"3"==e?"3":"1",D.prototype.render.call(this,t,e,r)},O.prototype.valueFromData=function(t,e,r){var i=null;if("undefined"!=typeof t[r]){var n=t[r];n===!0||"True"==n||"true"==n||"2"==n?i=!0:(n===!1||"False"==n||"false"==n||"3"==n)&&(i=!1)}return i};var A=D.extend({constructor:function ae(t){return this instanceof u?void D.call(this,t):new ae(t)},allowMultipleSelected:!0});A.prototype.render=function(t,e,r){r=o.extend({attrs:null,choices:[]},r),null===e&&(e=[]),i.Array(e)||(e=[e]);var n=this.buildAttrs(r.attrs,{name:t,multiple:"multiple",defaultValue:e}),s=this.renderOptions(r.choices,e);return React.DOM.select(n,s)},A.prototype.valueFromData=function(t,e,r){return"undefined"!=typeof t[r]?[].concat(t[r]):null};var T=l.extend({constructor:function(t,e,r,i,n){this.name=t,this.value=e,this.attrs=r,this.choiceValue=""+i[0],this.choiceLabel=""+i[1],this.index=n,"undefined"!=typeof this.attrs.id&&(this.attrs.id+="_"+this.index)},inputType:null});T.prototype.render=function(){var t={};return this.idForLabel()&&(t.htmlFor=this.idForLabel()),React.DOM.label(t,this.tag()," ",this.choiceLabel)},T.prototype.isChecked=function(){return this.value===this.choiceValue},T.prototype.tag=function(){var t=o.extend({},this.attrs,{type:this.inputType,name:this.name,value:this.choiceValue});return this.isChecked()&&(t.defaultChecked="checked"),React.DOM.input(t)},T.prototype.idForLabel=function(){return o.get(this.attrs,"id","")};var V=T.extend({constructor:function le(t,e,r,i,n){return this instanceof le?(T.call(this,t,e,r,i,n),void(this.value=""+this.value)):new le(t,e,r,i,n)},inputType:"radio"}),P=T.extend({constructor:function ue(t,e,r,n,o){if(!(this instanceof ue))return new ue(t,e,r,n,o);i.Array(e)||(e=[e]),T.call(this,t,e,r,n,o);for(var s=0,a=this.value.length;a>s;s++)this.value[s]=""+this.value[s]},inputType:"checkbox"});P.prototype.isChecked=function(){return-1!==this.value.indexOf(this.choiceValue)};var L=r.extend({constructor:function ce(t,e,r,i){return this instanceof ce?(this.name=t,this.value=e,this.attrs=r,void(this.choices=i)):new ce(t,e,r,i)},choiceInputConstructor:null});L.prototype.__iter__=function(){return this.choiceInputs()},L.prototype.choiceInputs=function(){for(var t=[],e=0,r=this.choices.length;r>e;e++)t.push(this.choiceInputConstructor(this.name,this.value,o.extend({},this.attrs),this.choices[e],e));return t},L.prototype.choiceInput=function(t){if(t>=this.choices.length)throw new Error("Index out of bounds");return this.choiceInputConstructor(this.name,this.value,o.extend({},this.attrs),this.choices[t],t)},L.prototype.render=function(){for(var t=o.get(this.attrs,"id",null),e=[],r=0,n=this.choices.length;n>r;r++){var s=this.choices[r],a=s[0],l=s[1];if(i.Array(l)){var u=o.extend({},this.attrs);t&&(u.id+="_"+r);var c=L(this.name,this.value,u,l);c.choiceInputConstructor=this.choiceInputConstructor,e.push(React.DOM.li(null,a,c.render()))}else{var h=this.choiceInputConstructor(this.name,this.value,o.extend({},this.attrs),s,r);e.push(React.DOM.li(null,h.render()))}}var d={};return t&&(d.id=t),React.DOM.ul(d,e)};var S=L.extend({constructor:function he(t,e,r,i){return this instanceof he?void L.apply(this,arguments):new he(t,e,r,i)},choiceInputConstructor:V}),R=L.extend({constructor:function de(t,e,r,i){return this instanceof de?void L.apply(this,arguments):new de(t,e,r,i)},choiceInputConstructor:P}),j=r.extend({constructor:function(t){t=o.extend({renderer:null},t),null!==t.renderer&&(this.renderer=t.renderer)},_emptyValue:null});j.prototype.subWidgets=function(t,e,r){return a.iterate(this.getRenderer(t,e,r))},j.prototype.getRenderer=function(t,e,r){r=o.extend({attrs:null,choices:[]},r),null===e&&(e=this._emptyValue);var i=this.buildAttrs(r.attrs),n=a.iterate(this.choices).concat(r.choices||[]);return new this.renderer(t,e,i,n)},j.prototype.render=function(t,e,r){return this.getRenderer(t,e,r).render()},j.prototype.idForLabel=function(t){return t&&(t+="_0"),t};var N=D.extend({__mixin__:j,constructor:function(t){return this instanceof N?(j.call(this,t),void D.call(this,t)):new N(t)},renderer:S,_emptyValue:""}),k=A.extend({__mixin__:j,constructor:function(t){return this instanceof k?(j.call(this,t),void A.call(this,t)):new k(t)},renderer:R,_emptyValue:[]}),U=u.extend({constructor:function pe(t,e){if(!(this instanceof u))return new pe(t,e);this.widgets=[];for(var r=!1,i=0,n=t.length;n>i;i++){var o=t[i]instanceof u?t[i]:new t[i];o.needsMultipartForm&&(r=!0),this.widgets.push(o)}this.needsMultipartForm=r,u.call(this,e)}});U.prototype.render=function(t,e,r){r=o.extend({attrs:null},r),i.Array(e)||(e=this.decompress(e));for(var n=this.buildAttrs(r.attrs),s="undefined"!=typeof n.id?n.id:null,a=[],l=0,u=this.widgets.length;u>l;l++){var c=this.widgets[l],h=null;"undefined"!=typeof e[l]&&(h=e[l]),s&&(n.id=s+"_"+l),a.push(c.render(t+"_"+l,h,{attrs:n}))}return this.formatOutput(a)},U.prototype.idForLabel=function(t){return t&&(t+="_0"),t},U.prototype.valueFromData=function(t,e,r){for(var i=[],n=0,o=this.widgets.length;o>n;n++)i[n]=this.widgets[n].valueFromData(t,e,r+"_"+n);return i},U.prototype.formatOutput=function(t){return React.DOM.div(null,t)},U.prototype.decompress=function(){throw new Error("MultiWidget subclasses must implement a decompress() method.")};var q=U.extend({constructor:function fe(t){if(!(this instanceof u))return new fe(t);t=o.extend({dateFormat:null,timeFormat:null},t);var e=[F({attrs:t.attrs,format:t.dateFormat}),E({attrs:t.attrs,format:t.timeFormat})];U.call(this,e,t.attrs)}});q.prototype.decompress=function(t){return t?[new Date(t.getFullYear(),t.getMonth(),t.getDate()),new Date(1900,0,1,t.getHours(),t.getMinutes(),t.getSeconds())]:[null,null]};var B=q.extend({constructor:function me(t){if(!(this instanceof u))return new me(t);q.call(this,t);for(var e=0,r=this.widgets.length;r>e;e++)this.widgets[e].inputType="hidden",this.widgets[e].isHidden=!0},isHidden:!0});e.exports={Widget:u,Input:c,TextInput:h,NumberInput:d,EmailInput:p,URLInput:f,PasswordInput:m,HiddenInput:v,MultipleHiddenInput:g,FileInput:y,FILE_INPUT_CONTRADICTION:x,ClearableFileInput:w,Textarea:_,DateInput:F,DateTimeInput:M,TimeInput:E,CheckboxInput:I,Select:D,NullBooleanSelect:O,SelectMultiple:A,ChoiceInput:T,RadioChoiceInput:V,CheckboxChoiceInput:P,ChoiceFieldRenderer:L,RendererMixin:j,RadioFieldRenderer:S,CheckboxFieldRenderer:R,RadioSelect:N,CheckboxSelectMultiple:k,MultiWidget:U,SplitDateTimeWidget:q,SplitHiddenDateTimeWidget:B}},{"./util":6,Concur:8,"isomorph/format":11,"isomorph/is":12,"isomorph/object":13,"isomorph/time":14}],8:[function(t,e){function r(t,e){o.Function(e)?s.extend(t,e.prototype):s.extend(t,e)}function i(t){var e=t.__mixin__;o.Array(e)||(e=[e]);for(var i={},n=0,a=e.length;a>n;n++)r(i,e[n]);return delete t.__mixin__,s.extend(i,t)}function n(t,e,r){var i;return i=e&&s.hasOwn(e,"constructor")?e.constructor:function(){t.apply(this,arguments)},t!==a&&(s.inherits(i,t),i.__super__=t.prototype),e&&s.extend(i.prototype,e),r&&s.extend(i,r),i}var o=t("isomorph/is"),s=t("isomorph/object"),a=e.exports=function(){};a.extend=function(t,e){"undefined"!=typeof this.prototype.__meta__&&(t=t||{},e=e||{},this.prototype.__meta__(t,e)),t&&s.hasOwn(t,"__mixin__")&&(t=i(t)),e&&s.hasOwn(e,"__mixin__")&&(e=i(e));var r=n(this,t,e);return r.extend=this.extend,r}},{"isomorph/is":12,"isomorph/object":13}],9:[function(e,r,i){var n="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};!function(e){function o(t){throw RangeError(L[t])}function s(t,e){for(var r=t.length;r--;)t[r]=e(t[r]);return t}function a(t,e){return s(t.split(P),e).join(".")}function l(t){for(var e,r,i=[],n=0,o=t.length;o>n;)e=t.charCodeAt(n++),e>=55296&&56319>=e&&o>n?(r=t.charCodeAt(n++),56320==(64512&r)?i.push(((1023&e)<<10)+(1023&r)+65536):(i.push(e),n--)):i.push(e);return i}function u(t){return s(t,function(t){var e="";return t>65535&&(t-=65536,e+=j(t>>>10&1023|55296),t=56320|1023&t),e+=j(t)}).join("")}function c(t){return 10>t-48?t-22:26>t-65?t-65:26>t-97?t-97:F}function h(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function d(t,e,r){var i=0;for(t=r?R(t/I):t>>1,t+=R(t/e);t>S*E>>1;i+=F)t=R(t/S);return R(i+(S+1)*t/(t+C))}function p(t){var e,r,i,n,s,a,l,h,p,f,m=[],v=t.length,g=0,y=O,x=D;for(r=t.lastIndexOf(A),0>r&&(r=0),i=0;r>i;++i)t.charCodeAt(i)>=128&&o("not-basic"),m.push(t.charCodeAt(i));for(n=r>0?r+1:0;v>n;){for(s=g,a=1,l=F;n>=v&&o("invalid-input"),h=c(t.charCodeAt(n++)),(h>=F||h>R((b-g)/a))&&o("overflow"),g+=h*a,p=x>=l?M:l>=x+E?E:l-x,!(p>h);l+=F)f=F-p,a>R(b/f)&&o("overflow"),a*=f;e=m.length+1,x=d(g-s,e,0==s),R(g/e)>b-y&&o("overflow"),y+=R(g/e),g%=e,m.splice(g++,0,y)}return u(m)}function f(t){var e,r,i,n,s,a,u,c,p,f,m,v,g,y,x,w=[];for(t=l(t),v=t.length,e=O,r=0,s=D,a=0;v>a;++a)m=t[a],128>m&&w.push(j(m));for(i=n=w.length,n&&w.push(A);v>i;){for(u=b,a=0;v>a;++a)m=t[a],m>=e&&u>m&&(u=m);for(g=i+1,u-e>R((b-r)/g)&&o("overflow"),r+=(u-e)*g,e=u,a=0;v>a;++a)if(m=t[a],e>m&&++r>b&&o("overflow"),m==e){for(c=r,p=F;f=s>=p?M:p>=s+E?E:p-s,!(f>c);p+=F)x=c-f,y=F-f,w.push(j(h(f+x%y,0))),c=R(x/y);w.push(j(h(c,0))),s=d(r,g,i==n),r=0,++i}++r,++e}return w.join("")}function m(t){return a(t,function(t){return T.test(t)?p(t.slice(4).toLowerCase()):t})}function v(t){return a(t,function(t){return V.test(t)?"xn--"+f(t):t})}var g="object"==typeof i&&i,y="object"==typeof r&&r&&r.exports==g&&r,x="object"==typeof n&&n;(x.global===x||x.window===x)&&(e=x);var w,_,b=2147483647,F=36,M=1,E=26,C=38,I=700,D=72,O=128,A="-",T=/^xn--/,V=/[^ -~]/,P=/\x2E|\u3002|\uFF0E|\uFF61/g,L={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},S=F-M,R=Math.floor,j=String.fromCharCode;if(w={version:"1.2.4",ucs2:{decode:l,encode:u},decode:p,encode:f,toASCII:v,toUnicode:m},"function"==typeof t&&"object"==typeof t.amd&&t.amd)t("punycode",function(){return w});else if(g&&!g.nodeType)if(y)y.exports=w;else for(_ in w)w.hasOwnProperty(_)&&(g[_]=w[_]);else e.punycode=w}(this)},{}],10:[function(t,e){"use strict";function r(){}function i(t){return"object"==typeof t?(r.prototype=t,new r):t}function n(t){if("object"!=typeof t)return t;var e=t.valueOf();if(t!=e)return new t.constructor(e);var r,n;if(t instanceof t.constructor&&t.constructor!==Object){r=i(t.constructor.prototype);for(n in t)t.hasOwnProperty(n)&&(r[n]=t[n])}else{r={};for(n in t)r[n]=t[n]}return r}function o(t){for(var e in t)this[e]=t[e]}function s(){this.copiedObjects=[];var t=this;this.recursiveDeepCopy=function(e){return t.deepCopy(e)},this.depth=0}function a(t,e){var r=new s;return e&&(r.maxDepth=e),r.deepCopy(t)}var l=t("./is"),u=[];o.prototype={constructor:o,canCopy:function(){return!1},create:function(){},populate:function(){}},s.prototype={constructor:s,maxDepth:256,cacheResult:function(t,e){this.copiedObjects.push([t,e])},getCachedResult:function(t){for(var e=this.copiedObjects,r=e.length,i=0;r>i;i++)if(e[i][0]===t)return e[i][1];return void 0},deepCopy:function(t){if(null===t)return null;if("object"!=typeof t)return t;var e=this.getCachedResult(t);if(e)return e;for(var r=0;r<u.length;r++){var i=u[r];if(i.canCopy(t))return this.applyDeepCopier(i,t)}throw new Error("no DeepCopier is able to copy "+t)},applyDeepCopier:function(t,e){var r=t.create(e);if(this.cacheResult(e,r),this.depth++,this.depth>this.maxDepth)throw new Error("Exceeded max recursion depth in deep copy.");return t.populate(this.recursiveDeepCopy,e,r),this.depth--,r}},a.DeepCopier=o,a.deepCopiers=u,a.register=function(t){t instanceof o||(t=new o(t)),u.unshift(t)},a.register({canCopy:function(){return!0},create:function(t){return t instanceof t.constructor?i(t.constructor.prototype):{}},populate:function(t,e,r){for(var i in e)e.hasOwnProperty(i)&&(r[i]=t(e[i]));return r}}),a.register({canCopy:function(t){return l.Array(t)
},create:function(t){return new t.constructor},populate:function(t,e,r){for(var i=0;i<e.length;i++)r.push(t(e[i]));return r}}),a.register({canCopy:function(t){return l.Date(t)},create:function(t){return new Date(t)}}),a.register({canCopy:function(t){return l.RegExp(t)},create:function(t){return t}}),e.exports={DeepCopyAlgorithm:s,copy:n,clone:i,deepCopy:a}},{"./is":12}],11:[function(t,e){"use strict";function r(t){return i(t,s.call(arguments,1))}function i(t,e){var r=0;return t.replace(a,function(t){return"%%"==t?"%":e[r++]})}function n(t,e){return t.replace(l,function(t,r,i){return 2==r.length?t.slice(1):e[i]})}function o(t,e){e=Math.min(e||768,1024);for(var r=-1,i="bytes",n=t;n>e&&r<u.length;)n/=1024,r++;return r>-1&&(i=u.charAt(r)+"B"),n.toFixed(2).replace(c,"")+" "+i}var s=Array.prototype.slice,a=/%[%s]/g,l=/({{?)(\w+)}/g,u="kMGTPEZY",c=/\.00$|0$/;e.exports={format:r,formatArr:i,formatObj:n,fileSize:o}},{}],12:[function(t,e){"use strict";function r(t){return"[object Array]"==d.call(t)}function i(t){return"[object Boolean]"==d.call(t)}function n(t){return"[object Date]"==d.call(t)}function o(t){return"[object Error]"==d.call(t)}function s(t){return"[object Function]"==d.call(t)}function a(t){return"[object Number]"==d.call(t)}function l(t){return"[object Object]"==d.call(t)}function u(t){return"[object RegExp]"==d.call(t)}function c(t){return"[object String]"==d.call(t)}function h(t){for(var e in t)return!1;return!0}var d=Object.prototype.toString;e.exports={Array:r,Boolean:i,Date:n,Empty:h,Error:o,Function:s,NaN:isNaN,Number:a,Object:l,RegExp:u,String:c}},{}],13:[function(t,e){"use strict";function r(t){for(var e,r=1,i=arguments.length;i>r;r++)if(e=arguments[r])for(var n in e)c(e,n)&&(t[n]=e[n]);return t}function i(t,e){var r=function(){};return r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t}function n(t){var e=[];for(var r in t)c(t,r)&&e.push([r,t[r]]);return e}function o(t){for(var e,r={},i=0,n=t.length;n>i;i++)e=t[i],r[e[0]]=e[1];return r}function s(t){for(var e={},r=0,i=t.length;i>r;r++)e[""+t[r]]=!0;return e}function a(t,e,r){return c(t,e)?t[e]:r}function l(t,e,r){if(null==t)throw new Error("popProp was given "+t);if(c(t,e)){var i=t[e];return delete t[e],i}if(2==arguments.length)throw new Error("popProp was given an object which didn't have an own '"+e+"' property, without a default value to return");return r}function u(t,e,r){if(null==t)throw new Error("setDefault was given "+t);return r=r||null,c(t,e)?t[e]:(t[e]=r,r)}var c=function(){var t=Object.prototype.hasOwnProperty;return function(e,r){return t.call(e,r)}}();e.exports={hasOwn:c,extend:r,inherits:i,items:n,fromItems:o,lookup:s,get:a,pop:l,setDefault:u}},{}],14:[function(t,e){"use strict";function r(t){return 10>t?"0"+t:t}function i(t,e){for(var r=0,i=e.length;i>r;r++)if(t===e[r])return r;return-1}function n(t,e){this.format=t,this.locale=e;var r=n._cache[e.name+"|"+t];void 0!==r?(this.re=r[0],this.matchOrder=r[1]):this.compilePattern()}var o=t("./is"),s={b:function(t){return"("+t.b.join("|")+")"},B:function(t){return"("+t.B.join("|")+")"},p:function(t){return"("+t.AM+"|"+t.PM+")"},d:"(\\d\\d?)",H:"(\\d\\d?)",I:"(\\d\\d?)",m:"(\\d\\d?)",M:"(\\d\\d?)",S:"(\\d\\d?)",y:"(\\d\\d?)",Y:"(\\d{4})","%":"%"},a={a:function(t,e){return e.a[t.getDay()]},A:function(t,e){return e.A[t.getDay()]},b:function(t,e){return e.b[t.getMonth()]},B:function(t,e){return e.B[t.getMonth()]},d:function(t){return r(t.getDate(),2)},H:function(t){return r(t.getHours(),2)},M:function(t){return r(t.getMinutes(),2)},m:function(t){return r(t.getMonth()+1,2)},S:function(t){return r(t.getSeconds(),2)},w:function(t){return t.getDay()},Y:function(t){return t.getFullYear()},"%":function(){return"%"}},l=/[^%]%$/;n._cache={},n.prototype.compilePattern=function(){for(var t,e,r=this.format.split(/(?:\s|\t|\n)+/).join(" "),i=[],a=[],l=0,u=r.length;u>l;l++)if(t=r.charAt(l),"%"==t){if(l==u-1)throw new Error("strptime format ends with raw %");if(t=r.charAt(++l),e=s[t],void 0===e)throw new Error("strptime format contains an unknown directive: %"+t);i.push(o.Function(e)?e(this.locale):e),"%"!=t&&a.push(t)}else i.push(" "===t?" +":t);this.re=new RegExp("^"+i.join("")+"$"),this.matchOrder=a,n._cache[this.locale.name+"|"+this.format]=[this.re,a]},n.prototype.parse=function(t){var e=this.re.exec(t);if(null===e)throw new Error("Time data did not match format: data="+t+", format="+this.format);for(var r=[1900,1,1,0,0,0],n={},o=1,s=e.length;s>o;o++)n[this.matchOrder[o-1]]=e[o];if(n.hasOwnProperty("Y"))r[0]=parseInt(n.Y,10);else if(n.hasOwnProperty("y")){var a=parseInt(n.y,10);68>a?a=2e3+a:100>a&&(a=1900+a),r[0]=a}if(n.hasOwnProperty("m")){var l=parseInt(n.m,10);if(1>l||l>12)throw new Error("Month is out of range: "+l);r[1]=l}else n.hasOwnProperty("B")?r[1]=i(n.B,this.locale.B)+1:n.hasOwnProperty("b")&&(r[1]=i(n.b,this.locale.b)+1);if(n.hasOwnProperty("d")){var u=parseInt(n.d,10);if(1>u||u>31)throw new Error("Day is out of range: "+u);r[2]=u}var c;if(n.hasOwnProperty("H")){if(c=parseInt(n.H,10),c>23)throw new Error("Hour is out of range: "+c);r[3]=c}else if(n.hasOwnProperty("I")){if(c=parseInt(n.I,10),1>c||c>12)throw new Error("Hour is out of range: "+c);12==c&&(c=0),r[3]=c,n.hasOwnProperty("p")&&n.p==this.locale.PM&&(r[3]=r[3]+12)}if(n.hasOwnProperty("M")){var h=parseInt(n.M,10);if(h>59)throw new Error("Minute is out of range: "+h);r[4]=h}if(n.hasOwnProperty("S")){var d=parseInt(n.S,10);if(d>59)throw new Error("Second is out of range: "+d);r[5]=d}if(u=r[2],l=r[1],a=r[0],(4==l||6==l||9==l||11==l)&&u>30||2==l&&u>(a%4===0&&a%100!==0||a%400===0?29:28))throw new Error("Day is out of range: "+u);return r};var u={defaultLocale:"en",locales:{en:{name:"en",a:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],AM:"AM",b:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B:["January","February","March","April","May","June","July","August","September","October","November","December"],PM:"PM"}}},c=u.getLocale=function(t){if(t){if(u.locales.hasOwnProperty(t))return u.locales[t];if(t.length>2){var e=t.substring(0,2);if(u.locales.hasOwnProperty(e))return u.locales[e]}}return u.locales[u.defaultLocale]},h=u.strptime=function(t,e,r){return new n(e,c(r)).parse(t)};u.strpdate=function(t,e,r){var i=h(t,e,r);return new Date(i[0],i[1]-1,i[2],i[3],i[4],i[5])},u.strftime=function(t,e,r){if(l.test(e))throw new Error("strftime format ends with raw %");return r=c(r),e.replace(/(%.)/g,function(e,i){var n=i.charAt(1);if("undefined"==typeof a[n])throw new Error("strftime format contains an unknown directive: "+i);return a[n](t,r)})},e.exports=u},{"./is":12}],15:[function(t,e){"use strict";function r(t){for(var e=r.options,i=e.parser[e.strictMode?"strict":"loose"].exec(t),n={},o=14;o--;)n[e.key[o]]=i[o]||"";return n[e.q.name]={},n[e.key[12]].replace(e.q.parser,function(t,r,i){r&&(n[e.q.name][r]=i)}),n}function i(t){var e="";t.protocol&&(e+=t.protocol+"://"),t.user&&(e+=t.user),t.password&&(e+=":"+t.password),(t.user||t.password)&&(e+="@"),t.host&&(e+=t.host),t.port&&(e+=":"+t.port),t.path&&(e+=t.path);var r=t.queryKey,i=[];for(var n in r)if(r.hasOwnProperty(n)){var o=encodeURIComponent(r[n]);n=encodeURIComponent(n),i.push(o?n+"="+o:n)}return i.length>0&&(e+="?"+i.join("&")),t.anchor&&(e+="#"+t.anchor),e}r.options={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},e.exports={parseUri:r,makeUri:i}},{}],16:[function(t,e){"use strict";var r=t("Concur"),i=t("isomorph/format").formatObj,n=t("isomorph/is"),o=t("isomorph/object"),s="__all__",a=r.extend({constructor:function l(t,e){if(!(this instanceof l))return new l(t,e);e=o.extend({code:null,params:null},e);var r=e.code,i=e.params;t instanceof l&&(o.hasOwn(t,"errorObj")?t=t.errorObj:o.hasOwn(t,"message")?t=t.errorList:(r=t.code,i=t.params,t=t.message)),n.Object(t)?(this.errorObj={},Object.keys(t).forEach(function(e){var r=t[e];r instanceof l||(r=l(r)),this.errorObj[e]=r.errorList}.bind(this))):n.Array(t)?(this.errorList=[],t.forEach(function(t){t instanceof l||(t=l(t)),this.errorList.push.apply(this.errorList,t.errorList)}.bind(this))):(this.message=t,this.code=r,this.params=i,this.errorList=[this])}});a.prototype.messageObj=function(){if(!o.hasOwn(this,"errorObj"))throw new Error("ValidationError has no errorObj");return this.__iter__()},a.prototype.messages=function(){if(o.hasOwn(this,"errorObj")){var t=[];return Object.keys(this.errorObj).forEach(function(e){var r=this.errorObj[e];t.push.apply(t,a(r).__iter__())}.bind(this)),t}return this.__iter__()},a.prototype.__iter__=function(){if(o.hasOwn(this,"errorObj")){var t={};return Object.keys(this.errorObj).forEach(function(e){var r=this.errorObj[e];t[e]=a(r).__iter__()}.bind(this)),t}return this.errorList.map(function(t){var e=t.message;return t.params&&(e=i(e,t.params)),e})},a.prototype.updateErrorObj=function(t){if(o.hasOwn(this,"errorObj"))t?Object.keys(this.errorObj).forEach(function(e){o.hasOwn(t,e)||(t[e]=[]);var r=t[e];r.push.apply(r,this.errorObj[e])}.bind(this)):t=this.errorObj;else{o.hasOwn(t,s)||(t[s]=[]);var e=t[s];e.push.apply(e,this.errorList)}return t},a.prototype.toString=function(){return"ValidationError("+JSON.stringify(this.__iter__())+")"},e.exports={ValidationError:a}},{Concur:8,"isomorph/format":11,"isomorph/is":12,"isomorph/object":13}],17:[function(t,e){"use strict";function r(t,e){e=c.extend({unpackIPv4:!1,errorMessage:"This is not a valid IPv6 address"},e);var r=-1,a=0,l=-1,u=0;if(!o(t))throw d(e.errorMessage);if(t=s(t),t=i(t),e.unpackIPv4){var h=n(t);if(h)return h}for(var p=t.split(":"),f=0,m=p.length;m>f;f++)p[f]=p[f].replace(/^0+/,""),""===p[f]&&(p[f]="0"),"0"==p[f]?(u+=1,-1==l&&(l=f),u>a&&(a=u,r=l)):(u=0,l=-1);if(a>1){var v=r+a;v==p.length&&p.push(""),p.splice(r,a,""),0===r&&p.unshift("")}return p.join(":").toLowerCase()}function i(t){if(0!==t.toLowerCase().indexOf("0000:0000:0000:0000:0000:ffff:"))return t;var e=t.split(":");if(-1!=e[e.length-1].indexOf("."))return t;var r=[parseInt(e[6].substring(0,2),16),parseInt(e[6].substring(2,4),16),parseInt(e[7].substring(0,2),16),parseInt(e[7].substring(2,4),16)].join(".");return e.slice(0,6).join(":")+":"+r}function n(t){if(0!==t.toLowerCase().indexOf("0000:0000:0000:0000:0000:ffff:"))return null;var e=t.split(":");return e.pop()}function o(e){var r=t("./validators").validateIPv4Address;if(-1==e.indexOf(":"))return!1;if(u(e,"::")>1)return!1;if(-1!=e.indexOf(":::"))return!1;if(":"==e.charAt(0)&&":"!=e.charAt(1)||":"==e.charAt(e.length-1)&&":"!=e.charAt(e.length-2))return!1;if(u(e,":")>7)return!1;if(-1==e.indexOf("::")&&7!=u(e,":")&&3!=u(e,"."))return!1;e=s(e);for(var i,n=e.split(":"),o=0,a=n.length;a>o;o++)if(i=n[o],3==u(i,".")){if(e.split(":").pop()!=i)return!1;try{r.__call__(i)}catch(l){if(!(l instanceof d))throw l;return!1}}else{if(!p.test(i))return!1;var c=parseInt(i,16);if(isNaN(c)||0>c||c>65535)return!1}return!0}function s(t){if(!a(t))return t;var e=[],r=t.split("::"),i=-1!=t.split(":").pop().indexOf(".")?7:8;if(r.length>1){var n=r[0].split(":").length+r[1].split(":").length;e=r[0].split(":");for(var o=0,s=i-n;s>o;o++)e.push("0000");e=e.concat(r[1].split(":"))}else e=t.split(":");var u=[];for(o=0,s=e.length;s>o;o++)u.push(l(e[o],4)+e[o].toLowerCase());return u.join(":")}function a(t){if(1==u(t,"::"))return!0;for(var e=t.split(":"),r=0,i=e.length;i>r;r++)if(e[r].length<4)return!0;return!1}function l(t,e){return t.length>=e?"":new Array(e-t.length+1).join("0")}function u(t,e){return t.split(e).length-1}var c=t("isomorph/object"),h=t("./errors"),d=h.ValidationError,p=/^[0-9a-f]+$/;e.exports={cleanIPv6Address:r,isValidIPv6Address:o}},{"./errors":16,"./validators":18,"isomorph/object":13}],18:[function(t,e){"use strict";function r(t){return u.Function(t)||u.Function(t.__call__)}function i(t,e){u.Function(t)?t(e):u.Function(t.__call__)&&t.__call__(e)}function n(t,e,r){var i=t.split(e);return r?[i.slice(0,-r).join(e)].concat(i.slice(-r)):i}function o(t){if(!v(t))throw m("Enter a valid IPv6 address.",{code:"invalid"})}function s(t){try{C.__call__(t)}catch(e){if(!(e instanceof m))throw e;if(!v(t))throw m("Enter a valid IPv4 or IPv6 address.",{code:"invalid"})}}function a(t,e){if("both"!=t&&e)throw new Error('You can only use unpackIPv4 if protocol is set to "both"');if(t=t.toLowerCase(),"undefined"==typeof I[t])throw new Error('The protocol "'+t+'" is unknown');return I[t]}var l=t("Concur"),u=t("isomorph/is"),c=t("isomorph/object"),h=t("punycode"),d=t("isomorph/url"),p=t("./errors"),f=t("./ipv6"),m=p.ValidationError,v=f.isValidIPv6Address,g=[null,void 0,""],y=function(t){for(var e=0,r=g.length;r>e;e++)if(t===g[e])return!0;return!1},x=l.extend({constructor:function(t){return this instanceof x?(t=c.extend({regex:null,message:null,code:null,inverseMatch:null},t),t.regex&&(this.regex=t.regex),t.message&&(this.message=t.message),t.code&&(this.code=t.code),t.inverseMatch&&(this.inverseMatch=t.inverseMatch),void(u.String(this.regex)&&(this.regex=new RegExp(this.regex)))):new x(t)},regex:"",message:"Enter a valid value.",code:"invalid",inverseMatch:!1,__call__:function(t){if(this.inverseMatch===this.regex.test(""+t))throw m(this.message,{code:this.code})}}),w=x.extend({regex:new RegExp("^(?:[a-z0-9\\.\\-]*)://(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}\\.?)|localhost|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\[?[A-F0-9]*:[A-F0-9:]+\\]?)(?::\\d+)?(?:/?|[/?]\\S+)$","i"),message:"Enter a valid URL.",schemes:["http","https","ftp","ftps"],constructor:function(t){return this instanceof w?(t=c.extend({schemes:null},t),x.call(this,t),void(null!==t.schemes&&(this.schemes=t.schemes))):new w(t)},__call__:function(t){t=""+t;var e=t.split("://")[0].toLowerCase();if(-1===this.schemes.indexOf(e))throw m(this.message,{code:this.code});try{x.prototype.__call__.call(this,t)}catch(r){if(!(r instanceof m))throw r;var i=d.parseUri(t);try{i.host=h.toASCII(i.host)}catch(n){throw r}t=d.makeUri(i),x.prototype.__call__.call(this,t)}}}),_=l.extend({message:"Enter a valid email address.",code:"invalid",userRegex:new RegExp("(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*$|^\"([\\001-\\010\\013\\014\\016-\\037!#-\\[\\]-\\177]|\\\\[\\001-\\011\\013\\014\\016-\\177])*\"$)","i"),domainRegex:new RegExp("^(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}|[A-Z0-9-]{2,})$|^\\[(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\]$","i"),domainWhitelist:["localhost"],constructor:function(t){return this instanceof _?(t=c.extend({message:null,code:null,whitelist:null},t),null!==t.message&&(this.message=t.message),null!==t.code&&(this.code=t.code),void(null!==t.whitelist&&(this.domainWhitelist=t.whitelist))):new _(t)},__call__:function(t){if(t=""+t,!t||-1==t.indexOf("@"))throw m(this.message,{code:this.code});var e=n(t,"@",1),r=e[0],i=e[1];if(!this.userRegex.test(r))throw m(this.message,{code:this.code});if(-1==this.domainWhitelist.indexOf(i)&&!this.domainRegex.test(i)){try{if(i=h.toASCII(i),this.domainRegex.test(i))return}catch(o){}throw m(this.message,{code:this.code})}}}),b=_(),F=/^[-a-zA-Z0-9_]+$/,M=x({regex:F,message:'Enter a valid "slug" consisting of letters, numbers, underscores or hyphens.',code:"invalid"}),E=/^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$/,C=x({regex:E,message:"Enter a valid IPv4 address.",code:"invalid"}),I={both:{validators:[s],message:"Enter a valid IPv4 or IPv6 address."},ipv4:{validators:[C],message:"Enter a valid IPv4 address."},ipv6:{validators:[o],message:"Enter a valid IPv6 address."}},D=/^[\d,]+$/,O=x({regex:D,message:"Enter only digits separated by commas.",code:"invalid"}),A=l.extend({constructor:function(t){return this instanceof A?void(this.limitValue=t):new A(t)},compare:function(t,e){return t!==e},clean:function(t){return t},message:"Ensure this value is {limitValue} (it is {showValue}).",code:"limitValue",__call__:function(t){var e=this.clean(t),r={limitValue:this.limitValue,showValue:e};if(this.compare(e,this.limitValue))throw m(this.message,{code:this.code,params:r})}}),T=A.extend({constructor:function(t){return this instanceof T?void A.call(this,t):new T(t)},compare:function(t,e){return t>e},message:"Ensure this value is less than or equal to {limitValue}.",code:"maxValue"}),V=A.extend({constructor:function(t){return this instanceof V?void A.call(this,t):new V(t)},compare:function(t,e){return e>t},message:"Ensure this value is greater than or equal to {limitValue}.",code:"minValue"}),P=A.extend({constructor:function(t){return this instanceof P?void A.call(this,t):new P(t)},compare:function(t,e){return e>t},clean:function(t){return t.length},message:"Ensure this value has at least {limitValue} characters (it has {showValue}).",code:"minLength"}),L=A.extend({constructor:function(t){return this instanceof L?void A.call(this,t):new L(t)},compare:function(t,e){return t>e},clean:function(t){return t.length},message:"Ensure this value has at most {limitValue} characters (it has {showValue}).",code:"maxLength"});e.exports={EMPTY_VALUES:g,isEmptyValue:y,isCallable:r,callValidator:i,RegexValidator:x,URLValidator:w,EmailValidator:_,validateEmail:b,validateSlug:M,validateIPv4Address:C,validateIPv6Address:o,validateIPv46Address:s,ipAddressValidators:a,validateCommaSeparatedIntegerList:O,BaseValidator:A,MaxValueValidator:T,MinValueValidator:V,MaxLengthValidator:L,MinLengthValidator:P,ValidationError:m,ipv6:f}},{"./errors":16,"./ipv6":17,Concur:8,"isomorph/is":12,"isomorph/object":13,"isomorph/url":15,punycode:9}]},{},[5])(5)});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment