]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blob - bip39-standalone.html
Derivation path tabs display by network selection
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / bip39-standalone.html
1 <!DOCTYPE html>
2 <html>
3 <head lang="en">
4 <meta charset="utf-8" />
5 <title>BIP39 - Mnemonic Code</title>
6 <style>
7 /*!
8 * Bootstrap v3.2.0 (http://getbootstrap.com)
9 * Copyright 2011-2014 Twitter, Inc.
10 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
11 */
12
13 /*! normalize.css v3.0.1 | MIT License | git.io/normalize */
14 html {
15 font-family: sans-serif;
16 -webkit-text-size-adjust: 100%;
17 -ms-text-size-adjust: 100%;
18 }
19 body {
20 margin: 0;
21 }
22 article,
23 aside,
24 details,
25 figcaption,
26 figure,
27 footer,
28 header,
29 hgroup,
30 main,
31 nav,
32 section,
33 summary {
34 display: block;
35 }
36 audio,
37 canvas,
38 progress,
39 video {
40 display: inline-block;
41 vertical-align: baseline;
42 }
43 audio:not([controls]) {
44 display: none;
45 height: 0;
46 }
47 [hidden],
48 template {
49 display: none;
50 }
51 a {
52 background: transparent;
53 }
54 a:active,
55 a:hover {
56 outline: 0;
57 }
58 abbr[title] {
59 border-bottom: 1px dotted;
60 }
61 b,
62 strong {
63 font-weight: bold;
64 }
65 dfn {
66 font-style: italic;
67 }
68 h1 {
69 margin: .67em 0;
70 font-size: 2em;
71 }
72 mark {
73 color: #000;
74 background: #ff0;
75 }
76 small {
77 font-size: 80%;
78 }
79 sub,
80 sup {
81 position: relative;
82 font-size: 75%;
83 line-height: 0;
84 vertical-align: baseline;
85 }
86 sup {
87 top: -.5em;
88 }
89 sub {
90 bottom: -.25em;
91 }
92 img {
93 border: 0;
94 }
95 svg:not(:root) {
96 overflow: hidden;
97 }
98 figure {
99 margin: 1em 40px;
100 }
101 hr {
102 height: 0;
103 -webkit-box-sizing: content-box;
104 -moz-box-sizing: content-box;
105 box-sizing: content-box;
106 }
107 pre {
108 overflow: auto;
109 }
110 code,
111 kbd,
112 pre,
113 samp {
114 font-family: monospace, monospace;
115 font-size: 1em;
116 }
117 button,
118 input,
119 optgroup,
120 select,
121 textarea {
122 margin: 0;
123 font: inherit;
124 color: inherit;
125 }
126 button {
127 overflow: visible;
128 }
129 button,
130 select {
131 text-transform: none;
132 }
133 button,
134 html input[type="button"],
135 input[type="reset"],
136 input[type="submit"] {
137 -webkit-appearance: button;
138 cursor: pointer;
139 }
140 button[disabled],
141 html input[disabled] {
142 cursor: default;
143 }
144 button::-moz-focus-inner,
145 input::-moz-focus-inner {
146 padding: 0;
147 border: 0;
148 }
149 input {
150 line-height: normal;
151 }
152 input[type="checkbox"],
153 input[type="radio"] {
154 -webkit-box-sizing: border-box;
155 -moz-box-sizing: border-box;
156 box-sizing: border-box;
157 padding: 0;
158 }
159 input[type="number"]::-webkit-inner-spin-button,
160 input[type="number"]::-webkit-outer-spin-button {
161 height: auto;
162 }
163 input[type="search"] {
164 -webkit-box-sizing: content-box;
165 -moz-box-sizing: content-box;
166 box-sizing: content-box;
167 -webkit-appearance: textfield;
168 }
169 input[type="search"]::-webkit-search-cancel-button,
170 input[type="search"]::-webkit-search-decoration {
171 -webkit-appearance: none;
172 }
173 fieldset {
174 padding: .35em .625em .75em;
175 margin: 0 2px;
176 border: 1px solid #c0c0c0;
177 }
178 legend {
179 padding: 0;
180 border: 0;
181 }
182 textarea {
183 overflow: auto;
184 }
185 optgroup {
186 font-weight: bold;
187 }
188 table {
189 border-spacing: 0;
190 border-collapse: collapse;
191 }
192 td,
193 th {
194 padding: 0;
195 }
196 @media print {
197 * {
198 color: #000 !important;
199 text-shadow: none !important;
200 background: transparent !important;
201 -webkit-box-shadow: none !important;
202 box-shadow: none !important;
203 }
204 a,
205 a:visited {
206 text-decoration: underline;
207 }
208 a[href]:after {
209 content: " (" attr(href) ")";
210 }
211 abbr[title]:after {
212 content: " (" attr(title) ")";
213 }
214 a[href^="javascript:"]:after,
215 a[href^="#"]:after {
216 content: "";
217 }
218 pre,
219 blockquote {
220 border: 1px solid #999;
221
222 page-break-inside: avoid;
223 }
224 thead {
225 display: table-header-group;
226 }
227 tr,
228 img {
229 page-break-inside: avoid;
230 }
231 img {
232 max-width: 100% !important;
233 }
234 p,
235 h2,
236 h3 {
237 orphans: 3;
238 widows: 3;
239 }
240 h2,
241 h3 {
242 page-break-after: avoid;
243 }
244 select {
245 background: #fff !important;
246 }
247 .navbar {
248 display: none;
249 }
250 .table td,
251 .table th {
252 background-color: #fff !important;
253 }
254 .btn > .caret,
255 .dropup > .btn > .caret {
256 border-top-color: #000 !important;
257 }
258 .label {
259 border: 1px solid #000;
260 }
261 .table {
262 border-collapse: collapse !important;
263 }
264 .table-bordered th,
265 .table-bordered td {
266 border: 1px solid #ddd !important;
267 }
268 }
269 @font-face {
270 font-family: 'Glyphicons Halflings';
271
272 src: url('../fonts/glyphicons-halflings-regular.eot');
273 src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
274 }
275 .glyphicon {
276 position: relative;
277 top: 1px;
278 display: inline-block;
279 font-family: 'Glyphicons Halflings';
280 font-style: normal;
281 font-weight: normal;
282 line-height: 1;
283
284 -webkit-font-smoothing: antialiased;
285 -moz-osx-font-smoothing: grayscale;
286 }
287 .glyphicon-asterisk:before {
288 content: "\2a";
289 }
290 .glyphicon-plus:before {
291 content: "\2b";
292 }
293 .glyphicon-euro:before {
294 content: "\20ac";
295 }
296 .glyphicon-minus:before {
297 content: "\2212";
298 }
299 .glyphicon-cloud:before {
300 content: "\2601";
301 }
302 .glyphicon-envelope:before {
303 content: "\2709";
304 }
305 .glyphicon-pencil:before {
306 content: "\270f";
307 }
308 .glyphicon-glass:before {
309 content: "\e001";
310 }
311 .glyphicon-music:before {
312 content: "\e002";
313 }
314 .glyphicon-search:before {
315 content: "\e003";
316 }
317 .glyphicon-heart:before {
318 content: "\e005";
319 }
320 .glyphicon-star:before {
321 content: "\e006";
322 }
323 .glyphicon-star-empty:before {
324 content: "\e007";
325 }
326 .glyphicon-user:before {
327 content: "\e008";
328 }
329 .glyphicon-film:before {
330 content: "\e009";
331 }
332 .glyphicon-th-large:before {
333 content: "\e010";
334 }
335 .glyphicon-th:before {
336 content: "\e011";
337 }
338 .glyphicon-th-list:before {
339 content: "\e012";
340 }
341 .glyphicon-ok:before {
342 content: "\e013";
343 }
344 .glyphicon-remove:before {
345 content: "\e014";
346 }
347 .glyphicon-zoom-in:before {
348 content: "\e015";
349 }
350 .glyphicon-zoom-out:before {
351 content: "\e016";
352 }
353 .glyphicon-off:before {
354 content: "\e017";
355 }
356 .glyphicon-signal:before {
357 content: "\e018";
358 }
359 .glyphicon-cog:before {
360 content: "\e019";
361 }
362 .glyphicon-trash:before {
363 content: "\e020";
364 }
365 .glyphicon-home:before {
366 content: "\e021";
367 }
368 .glyphicon-file:before {
369 content: "\e022";
370 }
371 .glyphicon-time:before {
372 content: "\e023";
373 }
374 .glyphicon-road:before {
375 content: "\e024";
376 }
377 .glyphicon-download-alt:before {
378 content: "\e025";
379 }
380 .glyphicon-download:before {
381 content: "\e026";
382 }
383 .glyphicon-upload:before {
384 content: "\e027";
385 }
386 .glyphicon-inbox:before {
387 content: "\e028";
388 }
389 .glyphicon-play-circle:before {
390 content: "\e029";
391 }
392 .glyphicon-repeat:before {
393 content: "\e030";
394 }
395 .glyphicon-refresh:before {
396 content: "\e031";
397 }
398 .glyphicon-list-alt:before {
399 content: "\e032";
400 }
401 .glyphicon-lock:before {
402 content: "\e033";
403 }
404 .glyphicon-flag:before {
405 content: "\e034";
406 }
407 .glyphicon-headphones:before {
408 content: "\e035";
409 }
410 .glyphicon-volume-off:before {
411 content: "\e036";
412 }
413 .glyphicon-volume-down:before {
414 content: "\e037";
415 }
416 .glyphicon-volume-up:before {
417 content: "\e038";
418 }
419 .glyphicon-qrcode:before {
420 content: "\e039";
421 }
422 .glyphicon-barcode:before {
423 content: "\e040";
424 }
425 .glyphicon-tag:before {
426 content: "\e041";
427 }
428 .glyphicon-tags:before {
429 content: "\e042";
430 }
431 .glyphicon-book:before {
432 content: "\e043";
433 }
434 .glyphicon-bookmark:before {
435 content: "\e044";
436 }
437 .glyphicon-print:before {
438 content: "\e045";
439 }
440 .glyphicon-camera:before {
441 content: "\e046";
442 }
443 .glyphicon-font:before {
444 content: "\e047";
445 }
446 .glyphicon-bold:before {
447 content: "\e048";
448 }
449 .glyphicon-italic:before {
450 content: "\e049";
451 }
452 .glyphicon-text-height:before {
453 content: "\e050";
454 }
455 .glyphicon-text-width:before {
456 content: "\e051";
457 }
458 .glyphicon-align-left:before {
459 content: "\e052";
460 }
461 .glyphicon-align-center:before {
462 content: "\e053";
463 }
464 .glyphicon-align-right:before {
465 content: "\e054";
466 }
467 .glyphicon-align-justify:before {
468 content: "\e055";
469 }
470 .glyphicon-list:before {
471 content: "\e056";
472 }
473 .glyphicon-indent-left:before {
474 content: "\e057";
475 }
476 .glyphicon-indent-right:before {
477 content: "\e058";
478 }
479 .glyphicon-facetime-video:before {
480 content: "\e059";
481 }
482 .glyphicon-picture:before {
483 content: "\e060";
484 }
485 .glyphicon-map-marker:before {
486 content: "\e062";
487 }
488 .glyphicon-adjust:before {
489 content: "\e063";
490 }
491 .glyphicon-tint:before {
492 content: "\e064";
493 }
494 .glyphicon-edit:before {
495 content: "\e065";
496 }
497 .glyphicon-share:before {
498 content: "\e066";
499 }
500 .glyphicon-check:before {
501 content: "\e067";
502 }
503 .glyphicon-move:before {
504 content: "\e068";
505 }
506 .glyphicon-step-backward:before {
507 content: "\e069";
508 }
509 .glyphicon-fast-backward:before {
510 content: "\e070";
511 }
512 .glyphicon-backward:before {
513 content: "\e071";
514 }
515 .glyphicon-play:before {
516 content: "\e072";
517 }
518 .glyphicon-pause:before {
519 content: "\e073";
520 }
521 .glyphicon-stop:before {
522 content: "\e074";
523 }
524 .glyphicon-forward:before {
525 content: "\e075";
526 }
527 .glyphicon-fast-forward:before {
528 content: "\e076";
529 }
530 .glyphicon-step-forward:before {
531 content: "\e077";
532 }
533 .glyphicon-eject:before {
534 content: "\e078";
535 }
536 .glyphicon-chevron-left:before {
537 content: "\e079";
538 }
539 .glyphicon-chevron-right:before {
540 content: "\e080";
541 }
542 .glyphicon-plus-sign:before {
543 content: "\e081";
544 }
545 .glyphicon-minus-sign:before {
546 content: "\e082";
547 }
548 .glyphicon-remove-sign:before {
549 content: "\e083";
550 }
551 .glyphicon-ok-sign:before {
552 content: "\e084";
553 }
554 .glyphicon-question-sign:before {
555 content: "\e085";
556 }
557 .glyphicon-info-sign:before {
558 content: "\e086";
559 }
560 .glyphicon-screenshot:before {
561 content: "\e087";
562 }
563 .glyphicon-remove-circle:before {
564 content: "\e088";
565 }
566 .glyphicon-ok-circle:before {
567 content: "\e089";
568 }
569 .glyphicon-ban-circle:before {
570 content: "\e090";
571 }
572 .glyphicon-arrow-left:before {
573 content: "\e091";
574 }
575 .glyphicon-arrow-right:before {
576 content: "\e092";
577 }
578 .glyphicon-arrow-up:before {
579 content: "\e093";
580 }
581 .glyphicon-arrow-down:before {
582 content: "\e094";
583 }
584 .glyphicon-share-alt:before {
585 content: "\e095";
586 }
587 .glyphicon-resize-full:before {
588 content: "\e096";
589 }
590 .glyphicon-resize-small:before {
591 content: "\e097";
592 }
593 .glyphicon-exclamation-sign:before {
594 content: "\e101";
595 }
596 .glyphicon-gift:before {
597 content: "\e102";
598 }
599 .glyphicon-leaf:before {
600 content: "\e103";
601 }
602 .glyphicon-fire:before {
603 content: "\e104";
604 }
605 .glyphicon-eye-open:before {
606 content: "\e105";
607 }
608 .glyphicon-eye-close:before {
609 content: "\e106";
610 }
611 .glyphicon-warning-sign:before {
612 content: "\e107";
613 }
614 .glyphicon-plane:before {
615 content: "\e108";
616 }
617 .glyphicon-calendar:before {
618 content: "\e109";
619 }
620 .glyphicon-random:before {
621 content: "\e110";
622 }
623 .glyphicon-comment:before {
624 content: "\e111";
625 }
626 .glyphicon-magnet:before {
627 content: "\e112";
628 }
629 .glyphicon-chevron-up:before {
630 content: "\e113";
631 }
632 .glyphicon-chevron-down:before {
633 content: "\e114";
634 }
635 .glyphicon-retweet:before {
636 content: "\e115";
637 }
638 .glyphicon-shopping-cart:before {
639 content: "\e116";
640 }
641 .glyphicon-folder-close:before {
642 content: "\e117";
643 }
644 .glyphicon-folder-open:before {
645 content: "\e118";
646 }
647 .glyphicon-resize-vertical:before {
648 content: "\e119";
649 }
650 .glyphicon-resize-horizontal:before {
651 content: "\e120";
652 }
653 .glyphicon-hdd:before {
654 content: "\e121";
655 }
656 .glyphicon-bullhorn:before {
657 content: "\e122";
658 }
659 .glyphicon-bell:before {
660 content: "\e123";
661 }
662 .glyphicon-certificate:before {
663 content: "\e124";
664 }
665 .glyphicon-thumbs-up:before {
666 content: "\e125";
667 }
668 .glyphicon-thumbs-down:before {
669 content: "\e126";
670 }
671 .glyphicon-hand-right:before {
672 content: "\e127";
673 }
674 .glyphicon-hand-left:before {
675 content: "\e128";
676 }
677 .glyphicon-hand-up:before {
678 content: "\e129";
679 }
680 .glyphicon-hand-down:before {
681 content: "\e130";
682 }
683 .glyphicon-circle-arrow-right:before {
684 content: "\e131";
685 }
686 .glyphicon-circle-arrow-left:before {
687 content: "\e132";
688 }
689 .glyphicon-circle-arrow-up:before {
690 content: "\e133";
691 }
692 .glyphicon-circle-arrow-down:before {
693 content: "\e134";
694 }
695 .glyphicon-globe:before {
696 content: "\e135";
697 }
698 .glyphicon-wrench:before {
699 content: "\e136";
700 }
701 .glyphicon-tasks:before {
702 content: "\e137";
703 }
704 .glyphicon-filter:before {
705 content: "\e138";
706 }
707 .glyphicon-briefcase:before {
708 content: "\e139";
709 }
710 .glyphicon-fullscreen:before {
711 content: "\e140";
712 }
713 .glyphicon-dashboard:before {
714 content: "\e141";
715 }
716 .glyphicon-paperclip:before {
717 content: "\e142";
718 }
719 .glyphicon-heart-empty:before {
720 content: "\e143";
721 }
722 .glyphicon-link:before {
723 content: "\e144";
724 }
725 .glyphicon-phone:before {
726 content: "\e145";
727 }
728 .glyphicon-pushpin:before {
729 content: "\e146";
730 }
731 .glyphicon-usd:before {
732 content: "\e148";
733 }
734 .glyphicon-gbp:before {
735 content: "\e149";
736 }
737 .glyphicon-sort:before {
738 content: "\e150";
739 }
740 .glyphicon-sort-by-alphabet:before {
741 content: "\e151";
742 }
743 .glyphicon-sort-by-alphabet-alt:before {
744 content: "\e152";
745 }
746 .glyphicon-sort-by-order:before {
747 content: "\e153";
748 }
749 .glyphicon-sort-by-order-alt:before {
750 content: "\e154";
751 }
752 .glyphicon-sort-by-attributes:before {
753 content: "\e155";
754 }
755 .glyphicon-sort-by-attributes-alt:before {
756 content: "\e156";
757 }
758 .glyphicon-unchecked:before {
759 content: "\e157";
760 }
761 .glyphicon-expand:before {
762 content: "\e158";
763 }
764 .glyphicon-collapse-down:before {
765 content: "\e159";
766 }
767 .glyphicon-collapse-up:before {
768 content: "\e160";
769 }
770 .glyphicon-log-in:before {
771 content: "\e161";
772 }
773 .glyphicon-flash:before {
774 content: "\e162";
775 }
776 .glyphicon-log-out:before {
777 content: "\e163";
778 }
779 .glyphicon-new-window:before {
780 content: "\e164";
781 }
782 .glyphicon-record:before {
783 content: "\e165";
784 }
785 .glyphicon-save:before {
786 content: "\e166";
787 }
788 .glyphicon-open:before {
789 content: "\e167";
790 }
791 .glyphicon-saved:before {
792 content: "\e168";
793 }
794 .glyphicon-import:before {
795 content: "\e169";
796 }
797 .glyphicon-export:before {
798 content: "\e170";
799 }
800 .glyphicon-send:before {
801 content: "\e171";
802 }
803 .glyphicon-floppy-disk:before {
804 content: "\e172";
805 }
806 .glyphicon-floppy-saved:before {
807 content: "\e173";
808 }
809 .glyphicon-floppy-remove:before {
810 content: "\e174";
811 }
812 .glyphicon-floppy-save:before {
813 content: "\e175";
814 }
815 .glyphicon-floppy-open:before {
816 content: "\e176";
817 }
818 .glyphicon-credit-card:before {
819 content: "\e177";
820 }
821 .glyphicon-transfer:before {
822 content: "\e178";
823 }
824 .glyphicon-cutlery:before {
825 content: "\e179";
826 }
827 .glyphicon-header:before {
828 content: "\e180";
829 }
830 .glyphicon-compressed:before {
831 content: "\e181";
832 }
833 .glyphicon-earphone:before {
834 content: "\e182";
835 }
836 .glyphicon-phone-alt:before {
837 content: "\e183";
838 }
839 .glyphicon-tower:before {
840 content: "\e184";
841 }
842 .glyphicon-stats:before {
843 content: "\e185";
844 }
845 .glyphicon-sd-video:before {
846 content: "\e186";
847 }
848 .glyphicon-hd-video:before {
849 content: "\e187";
850 }
851 .glyphicon-subtitles:before {
852 content: "\e188";
853 }
854 .glyphicon-sound-stereo:before {
855 content: "\e189";
856 }
857 .glyphicon-sound-dolby:before {
858 content: "\e190";
859 }
860 .glyphicon-sound-5-1:before {
861 content: "\e191";
862 }
863 .glyphicon-sound-6-1:before {
864 content: "\e192";
865 }
866 .glyphicon-sound-7-1:before {
867 content: "\e193";
868 }
869 .glyphicon-copyright-mark:before {
870 content: "\e194";
871 }
872 .glyphicon-registration-mark:before {
873 content: "\e195";
874 }
875 .glyphicon-cloud-download:before {
876 content: "\e197";
877 }
878 .glyphicon-cloud-upload:before {
879 content: "\e198";
880 }
881 .glyphicon-tree-conifer:before {
882 content: "\e199";
883 }
884 .glyphicon-tree-deciduous:before {
885 content: "\e200";
886 }
887 * {
888 -webkit-box-sizing: border-box;
889 -moz-box-sizing: border-box;
890 box-sizing: border-box;
891 }
892 *:before,
893 *:after {
894 -webkit-box-sizing: border-box;
895 -moz-box-sizing: border-box;
896 box-sizing: border-box;
897 }
898 html {
899 font-size: 10px;
900
901 -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
902 }
903 body {
904 font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
905 font-size: 14px;
906 line-height: 1.42857143;
907 color: #333;
908 background-color: #fff;
909 }
910 input,
911 button,
912 select,
913 textarea {
914 font-family: inherit;
915 font-size: inherit;
916 line-height: inherit;
917 }
918 a {
919 color: #428bca;
920 text-decoration: none;
921 }
922 a:hover,
923 a:focus {
924 color: #2a6496;
925 text-decoration: underline;
926 }
927 a:focus {
928 outline: thin dotted;
929 outline: 5px auto -webkit-focus-ring-color;
930 outline-offset: -2px;
931 }
932 figure {
933 margin: 0;
934 }
935 img {
936 vertical-align: middle;
937 }
938 .img-responsive,
939 .thumbnail > img,
940 .thumbnail a > img,
941 .carousel-inner > .item > img,
942 .carousel-inner > .item > a > img {
943 display: block;
944 width: 100% \9;
945 max-width: 100%;
946 height: auto;
947 }
948 .img-rounded {
949 border-radius: 6px;
950 }
951 .img-thumbnail {
952 display: inline-block;
953 width: 100% \9;
954 max-width: 100%;
955 height: auto;
956 padding: 4px;
957 line-height: 1.42857143;
958 background-color: #fff;
959 border: 1px solid #ddd;
960 border-radius: 4px;
961 -webkit-transition: all .2s ease-in-out;
962 -o-transition: all .2s ease-in-out;
963 transition: all .2s ease-in-out;
964 }
965 .img-circle {
966 border-radius: 50%;
967 }
968 hr {
969 margin-top: 20px;
970 margin-bottom: 20px;
971 border: 0;
972 border-top: 1px solid #eee;
973 }
974 .sr-only {
975 position: absolute;
976 width: 1px;
977 height: 1px;
978 padding: 0;
979 margin: -1px;
980 overflow: hidden;
981 clip: rect(0, 0, 0, 0);
982 border: 0;
983 }
984 .sr-only-focusable:active,
985 .sr-only-focusable:focus {
986 position: static;
987 width: auto;
988 height: auto;
989 margin: 0;
990 overflow: visible;
991 clip: auto;
992 }
993 h1,
994 h2,
995 h3,
996 h4,
997 h5,
998 h6,
999 .h1,
1000 .h2,
1001 .h3,
1002 .h4,
1003 .h5,
1004 .h6 {
1005 font-family: inherit;
1006 font-weight: 500;
1007 line-height: 1.1;
1008 color: inherit;
1009 }
1010 h1 small,
1011 h2 small,
1012 h3 small,
1013 h4 small,
1014 h5 small,
1015 h6 small,
1016 .h1 small,
1017 .h2 small,
1018 .h3 small,
1019 .h4 small,
1020 .h5 small,
1021 .h6 small,
1022 h1 .small,
1023 h2 .small,
1024 h3 .small,
1025 h4 .small,
1026 h5 .small,
1027 h6 .small,
1028 .h1 .small,
1029 .h2 .small,
1030 .h3 .small,
1031 .h4 .small,
1032 .h5 .small,
1033 .h6 .small {
1034 font-weight: normal;
1035 line-height: 1;
1036 color: #777;
1037 }
1038 h1,
1039 .h1,
1040 h2,
1041 .h2,
1042 h3,
1043 .h3 {
1044 margin-top: 20px;
1045 margin-bottom: 10px;
1046 }
1047 h1 small,
1048 .h1 small,
1049 h2 small,
1050 .h2 small,
1051 h3 small,
1052 .h3 small,
1053 h1 .small,
1054 .h1 .small,
1055 h2 .small,
1056 .h2 .small,
1057 h3 .small,
1058 .h3 .small {
1059 font-size: 65%;
1060 }
1061 h4,
1062 .h4,
1063 h5,
1064 .h5,
1065 h6,
1066 .h6 {
1067 margin-top: 10px;
1068 margin-bottom: 10px;
1069 }
1070 h4 small,
1071 .h4 small,
1072 h5 small,
1073 .h5 small,
1074 h6 small,
1075 .h6 small,
1076 h4 .small,
1077 .h4 .small,
1078 h5 .small,
1079 .h5 .small,
1080 h6 .small,
1081 .h6 .small {
1082 font-size: 75%;
1083 }
1084 h1,
1085 .h1 {
1086 font-size: 36px;
1087 }
1088 h2,
1089 .h2 {
1090 font-size: 30px;
1091 }
1092 h3,
1093 .h3 {
1094 font-size: 24px;
1095 }
1096 h4,
1097 .h4 {
1098 font-size: 18px;
1099 }
1100 h5,
1101 .h5 {
1102 font-size: 14px;
1103 }
1104 h6,
1105 .h6 {
1106 font-size: 12px;
1107 }
1108 p {
1109 margin: 0 0 10px;
1110 }
1111 .lead {
1112 margin-bottom: 20px;
1113 font-size: 16px;
1114 font-weight: 300;
1115 line-height: 1.4;
1116 }
1117 @media (min-width: 768px) {
1118 .lead {
1119 font-size: 21px;
1120 }
1121 }
1122 small,
1123 .small {
1124 font-size: 85%;
1125 }
1126 cite {
1127 font-style: normal;
1128 }
1129 mark,
1130 .mark {
1131 padding: .2em;
1132 background-color: #fcf8e3;
1133 }
1134 .text-left {
1135 text-align: left;
1136 }
1137 .text-right {
1138 text-align: right;
1139 }
1140 .text-center {
1141 text-align: center;
1142 }
1143 .text-justify {
1144 text-align: justify;
1145 }
1146 .text-nowrap {
1147 white-space: nowrap;
1148 }
1149 .text-lowercase {
1150 text-transform: lowercase;
1151 }
1152 .text-uppercase {
1153 text-transform: uppercase;
1154 }
1155 .text-capitalize {
1156 text-transform: capitalize;
1157 }
1158 .text-muted {
1159 color: #777;
1160 }
1161 .text-primary {
1162 color: #428bca;
1163 }
1164 a.text-primary:hover {
1165 color: #3071a9;
1166 }
1167 .text-success {
1168 color: #3c763d;
1169 }
1170 a.text-success:hover {
1171 color: #2b542c;
1172 }
1173 .text-info {
1174 color: #31708f;
1175 }
1176 a.text-info:hover {
1177 color: #245269;
1178 }
1179 .text-warning {
1180 color: #8a6d3b;
1181 }
1182 a.text-warning:hover {
1183 color: #66512c;
1184 }
1185 .text-danger {
1186 color: #a94442;
1187 }
1188 a.text-danger:hover {
1189 color: #843534;
1190 }
1191 .bg-primary {
1192 color: #fff;
1193 background-color: #428bca;
1194 }
1195 a.bg-primary:hover {
1196 background-color: #3071a9;
1197 }
1198 .bg-success {
1199 background-color: #dff0d8;
1200 }
1201 a.bg-success:hover {
1202 background-color: #c1e2b3;
1203 }
1204 .bg-info {
1205 background-color: #d9edf7;
1206 }
1207 a.bg-info:hover {
1208 background-color: #afd9ee;
1209 }
1210 .bg-warning {
1211 background-color: #fcf8e3;
1212 }
1213 a.bg-warning:hover {
1214 background-color: #f7ecb5;
1215 }
1216 .bg-danger {
1217 background-color: #f2dede;
1218 }
1219 a.bg-danger:hover {
1220 background-color: #e4b9b9;
1221 }
1222 .page-header {
1223 padding-bottom: 9px;
1224 margin: 40px 0 20px;
1225 border-bottom: 1px solid #eee;
1226 }
1227 ul,
1228 ol {
1229 margin-top: 0;
1230 margin-bottom: 10px;
1231 }
1232 ul ul,
1233 ol ul,
1234 ul ol,
1235 ol ol {
1236 margin-bottom: 0;
1237 }
1238 .list-unstyled {
1239 padding-left: 0;
1240 list-style: none;
1241 }
1242 .list-inline {
1243 padding-left: 0;
1244 margin-left: -5px;
1245 list-style: none;
1246 }
1247 .list-inline > li {
1248 display: inline-block;
1249 padding-right: 5px;
1250 padding-left: 5px;
1251 }
1252 dl {
1253 margin-top: 0;
1254 margin-bottom: 20px;
1255 }
1256 dt,
1257 dd {
1258 line-height: 1.42857143;
1259 }
1260 dt {
1261 font-weight: bold;
1262 }
1263 dd {
1264 margin-left: 0;
1265 }
1266 @media (min-width: 768px) {
1267 .dl-horizontal dt {
1268 float: left;
1269 width: 160px;
1270 overflow: hidden;
1271 clear: left;
1272 text-align: right;
1273 text-overflow: ellipsis;
1274 white-space: nowrap;
1275 }
1276 .dl-horizontal dd {
1277 margin-left: 180px;
1278 }
1279 }
1280 abbr[title],
1281 abbr[data-original-title] {
1282 cursor: help;
1283 border-bottom: 1px dotted #777;
1284 }
1285 .initialism {
1286 font-size: 90%;
1287 text-transform: uppercase;
1288 }
1289 blockquote {
1290 padding: 10px 20px;
1291 margin: 0 0 20px;
1292 font-size: 17.5px;
1293 border-left: 5px solid #eee;
1294 }
1295 blockquote p:last-child,
1296 blockquote ul:last-child,
1297 blockquote ol:last-child {
1298 margin-bottom: 0;
1299 }
1300 blockquote footer,
1301 blockquote small,
1302 blockquote .small {
1303 display: block;
1304 font-size: 80%;
1305 line-height: 1.42857143;
1306 color: #777;
1307 }
1308 blockquote footer:before,
1309 blockquote small:before,
1310 blockquote .small:before {
1311 content: '\2014 \00A0';
1312 }
1313 .blockquote-reverse,
1314 blockquote.pull-right {
1315 padding-right: 15px;
1316 padding-left: 0;
1317 text-align: right;
1318 border-right: 5px solid #eee;
1319 border-left: 0;
1320 }
1321 .blockquote-reverse footer:before,
1322 blockquote.pull-right footer:before,
1323 .blockquote-reverse small:before,
1324 blockquote.pull-right small:before,
1325 .blockquote-reverse .small:before,
1326 blockquote.pull-right .small:before {
1327 content: '';
1328 }
1329 .blockquote-reverse footer:after,
1330 blockquote.pull-right footer:after,
1331 .blockquote-reverse small:after,
1332 blockquote.pull-right small:after,
1333 .blockquote-reverse .small:after,
1334 blockquote.pull-right .small:after {
1335 content: '\00A0 \2014';
1336 }
1337 blockquote:before,
1338 blockquote:after {
1339 content: "";
1340 }
1341 address {
1342 margin-bottom: 20px;
1343 font-style: normal;
1344 line-height: 1.42857143;
1345 }
1346 code,
1347 kbd,
1348 pre,
1349 samp {
1350 font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
1351 }
1352 code {
1353 padding: 2px 4px;
1354 font-size: 90%;
1355 color: #c7254e;
1356 background-color: #f9f2f4;
1357 border-radius: 4px;
1358 }
1359 kbd {
1360 padding: 2px 4px;
1361 font-size: 90%;
1362 color: #fff;
1363 background-color: #333;
1364 border-radius: 3px;
1365 -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .25);
1366 box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .25);
1367 }
1368 kbd kbd {
1369 padding: 0;
1370 font-size: 100%;
1371 -webkit-box-shadow: none;
1372 box-shadow: none;
1373 }
1374 pre {
1375 display: block;
1376 padding: 9.5px;
1377 margin: 0 0 10px;
1378 font-size: 13px;
1379 line-height: 1.42857143;
1380 color: #333;
1381 word-break: break-all;
1382 word-wrap: break-word;
1383 background-color: #f5f5f5;
1384 border: 1px solid #ccc;
1385 border-radius: 4px;
1386 }
1387 pre code {
1388 padding: 0;
1389 font-size: inherit;
1390 color: inherit;
1391 white-space: pre-wrap;
1392 background-color: transparent;
1393 border-radius: 0;
1394 }
1395 .pre-scrollable {
1396 max-height: 340px;
1397 overflow-y: scroll;
1398 }
1399 .container {
1400 padding-right: 15px;
1401 padding-left: 15px;
1402 margin-right: auto;
1403 margin-left: auto;
1404 }
1405 @media (min-width: 768px) {
1406 .container {
1407 width: 750px;
1408 }
1409 }
1410 @media (min-width: 992px) {
1411 .container {
1412 width: 970px;
1413 }
1414 }
1415 @media (min-width: 1200px) {
1416 .container {
1417 width: 1170px;
1418 }
1419 }
1420 .container-fluid {
1421 padding-right: 15px;
1422 padding-left: 15px;
1423 margin-right: auto;
1424 margin-left: auto;
1425 }
1426 .row {
1427 margin-right: -15px;
1428 margin-left: -15px;
1429 }
1430 .col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 {
1431 position: relative;
1432 min-height: 1px;
1433 padding-right: 15px;
1434 padding-left: 15px;
1435 }
1436 .col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 {
1437 float: left;
1438 }
1439 .col-xs-12 {
1440 width: 100%;
1441 }
1442 .col-xs-11 {
1443 width: 91.66666667%;
1444 }
1445 .col-xs-10 {
1446 width: 83.33333333%;
1447 }
1448 .col-xs-9 {
1449 width: 75%;
1450 }
1451 .col-xs-8 {
1452 width: 66.66666667%;
1453 }
1454 .col-xs-7 {
1455 width: 58.33333333%;
1456 }
1457 .col-xs-6 {
1458 width: 50%;
1459 }
1460 .col-xs-5 {
1461 width: 41.66666667%;
1462 }
1463 .col-xs-4 {
1464 width: 33.33333333%;
1465 }
1466 .col-xs-3 {
1467 width: 25%;
1468 }
1469 .col-xs-2 {
1470 width: 16.66666667%;
1471 }
1472 .col-xs-1 {
1473 width: 8.33333333%;
1474 }
1475 .col-xs-pull-12 {
1476 right: 100%;
1477 }
1478 .col-xs-pull-11 {
1479 right: 91.66666667%;
1480 }
1481 .col-xs-pull-10 {
1482 right: 83.33333333%;
1483 }
1484 .col-xs-pull-9 {
1485 right: 75%;
1486 }
1487 .col-xs-pull-8 {
1488 right: 66.66666667%;
1489 }
1490 .col-xs-pull-7 {
1491 right: 58.33333333%;
1492 }
1493 .col-xs-pull-6 {
1494 right: 50%;
1495 }
1496 .col-xs-pull-5 {
1497 right: 41.66666667%;
1498 }
1499 .col-xs-pull-4 {
1500 right: 33.33333333%;
1501 }
1502 .col-xs-pull-3 {
1503 right: 25%;
1504 }
1505 .col-xs-pull-2 {
1506 right: 16.66666667%;
1507 }
1508 .col-xs-pull-1 {
1509 right: 8.33333333%;
1510 }
1511 .col-xs-pull-0 {
1512 right: auto;
1513 }
1514 .col-xs-push-12 {
1515 left: 100%;
1516 }
1517 .col-xs-push-11 {
1518 left: 91.66666667%;
1519 }
1520 .col-xs-push-10 {
1521 left: 83.33333333%;
1522 }
1523 .col-xs-push-9 {
1524 left: 75%;
1525 }
1526 .col-xs-push-8 {
1527 left: 66.66666667%;
1528 }
1529 .col-xs-push-7 {
1530 left: 58.33333333%;
1531 }
1532 .col-xs-push-6 {
1533 left: 50%;
1534 }
1535 .col-xs-push-5 {
1536 left: 41.66666667%;
1537 }
1538 .col-xs-push-4 {
1539 left: 33.33333333%;
1540 }
1541 .col-xs-push-3 {
1542 left: 25%;
1543 }
1544 .col-xs-push-2 {
1545 left: 16.66666667%;
1546 }
1547 .col-xs-push-1 {
1548 left: 8.33333333%;
1549 }
1550 .col-xs-push-0 {
1551 left: auto;
1552 }
1553 .col-xs-offset-12 {
1554 margin-left: 100%;
1555 }
1556 .col-xs-offset-11 {
1557 margin-left: 91.66666667%;
1558 }
1559 .col-xs-offset-10 {
1560 margin-left: 83.33333333%;
1561 }
1562 .col-xs-offset-9 {
1563 margin-left: 75%;
1564 }
1565 .col-xs-offset-8 {
1566 margin-left: 66.66666667%;
1567 }
1568 .col-xs-offset-7 {
1569 margin-left: 58.33333333%;
1570 }
1571 .col-xs-offset-6 {
1572 margin-left: 50%;
1573 }
1574 .col-xs-offset-5 {
1575 margin-left: 41.66666667%;
1576 }
1577 .col-xs-offset-4 {
1578 margin-left: 33.33333333%;
1579 }
1580 .col-xs-offset-3 {
1581 margin-left: 25%;
1582 }
1583 .col-xs-offset-2 {
1584 margin-left: 16.66666667%;
1585 }
1586 .col-xs-offset-1 {
1587 margin-left: 8.33333333%;
1588 }
1589 .col-xs-offset-0 {
1590 margin-left: 0;
1591 }
1592 @media (min-width: 768px) {
1593 .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 {
1594 float: left;
1595 }
1596 .col-sm-12 {
1597 width: 100%;
1598 }
1599 .col-sm-11 {
1600 width: 91.66666667%;
1601 }
1602 .col-sm-10 {
1603 width: 83.33333333%;
1604 }
1605 .col-sm-9 {
1606 width: 75%;
1607 }
1608 .col-sm-8 {
1609 width: 66.66666667%;
1610 }
1611 .col-sm-7 {
1612 width: 58.33333333%;
1613 }
1614 .col-sm-6 {
1615 width: 50%;
1616 }
1617 .col-sm-5 {
1618 width: 41.66666667%;
1619 }
1620 .col-sm-4 {
1621 width: 33.33333333%;
1622 }
1623 .col-sm-3 {
1624 width: 25%;
1625 }
1626 .col-sm-2 {
1627 width: 16.66666667%;
1628 }
1629 .col-sm-1 {
1630 width: 8.33333333%;
1631 }
1632 .col-sm-pull-12 {
1633 right: 100%;
1634 }
1635 .col-sm-pull-11 {
1636 right: 91.66666667%;
1637 }
1638 .col-sm-pull-10 {
1639 right: 83.33333333%;
1640 }
1641 .col-sm-pull-9 {
1642 right: 75%;
1643 }
1644 .col-sm-pull-8 {
1645 right: 66.66666667%;
1646 }
1647 .col-sm-pull-7 {
1648 right: 58.33333333%;
1649 }
1650 .col-sm-pull-6 {
1651 right: 50%;
1652 }
1653 .col-sm-pull-5 {
1654 right: 41.66666667%;
1655 }
1656 .col-sm-pull-4 {
1657 right: 33.33333333%;
1658 }
1659 .col-sm-pull-3 {
1660 right: 25%;
1661 }
1662 .col-sm-pull-2 {
1663 right: 16.66666667%;
1664 }
1665 .col-sm-pull-1 {
1666 right: 8.33333333%;
1667 }
1668 .col-sm-pull-0 {
1669 right: auto;
1670 }
1671 .col-sm-push-12 {
1672 left: 100%;
1673 }
1674 .col-sm-push-11 {
1675 left: 91.66666667%;
1676 }
1677 .col-sm-push-10 {
1678 left: 83.33333333%;
1679 }
1680 .col-sm-push-9 {
1681 left: 75%;
1682 }
1683 .col-sm-push-8 {
1684 left: 66.66666667%;
1685 }
1686 .col-sm-push-7 {
1687 left: 58.33333333%;
1688 }
1689 .col-sm-push-6 {
1690 left: 50%;
1691 }
1692 .col-sm-push-5 {
1693 left: 41.66666667%;
1694 }
1695 .col-sm-push-4 {
1696 left: 33.33333333%;
1697 }
1698 .col-sm-push-3 {
1699 left: 25%;
1700 }
1701 .col-sm-push-2 {
1702 left: 16.66666667%;
1703 }
1704 .col-sm-push-1 {
1705 left: 8.33333333%;
1706 }
1707 .col-sm-push-0 {
1708 left: auto;
1709 }
1710 .col-sm-offset-12 {
1711 margin-left: 100%;
1712 }
1713 .col-sm-offset-11 {
1714 margin-left: 91.66666667%;
1715 }
1716 .col-sm-offset-10 {
1717 margin-left: 83.33333333%;
1718 }
1719 .col-sm-offset-9 {
1720 margin-left: 75%;
1721 }
1722 .col-sm-offset-8 {
1723 margin-left: 66.66666667%;
1724 }
1725 .col-sm-offset-7 {
1726 margin-left: 58.33333333%;
1727 }
1728 .col-sm-offset-6 {
1729 margin-left: 50%;
1730 }
1731 .col-sm-offset-5 {
1732 margin-left: 41.66666667%;
1733 }
1734 .col-sm-offset-4 {
1735 margin-left: 33.33333333%;
1736 }
1737 .col-sm-offset-3 {
1738 margin-left: 25%;
1739 }
1740 .col-sm-offset-2 {
1741 margin-left: 16.66666667%;
1742 }
1743 .col-sm-offset-1 {
1744 margin-left: 8.33333333%;
1745 }
1746 .col-sm-offset-0 {
1747 margin-left: 0;
1748 }
1749 }
1750 @media (min-width: 992px) {
1751 .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 {
1752 float: left;
1753 }
1754 .col-md-12 {
1755 width: 100%;
1756 }
1757 .col-md-11 {
1758 width: 91.66666667%;
1759 }
1760 .col-md-10 {
1761 width: 83.33333333%;
1762 }
1763 .col-md-9 {
1764 width: 75%;
1765 }
1766 .col-md-8 {
1767 width: 66.66666667%;
1768 }
1769 .col-md-7 {
1770 width: 58.33333333%;
1771 }
1772 .col-md-6 {
1773 width: 50%;
1774 }
1775 .col-md-5 {
1776 width: 41.66666667%;
1777 }
1778 .col-md-4 {
1779 width: 33.33333333%;
1780 }
1781 .col-md-3 {
1782 width: 25%;
1783 }
1784 .col-md-2 {
1785 width: 16.66666667%;
1786 }
1787 .col-md-1 {
1788 width: 8.33333333%;
1789 }
1790 .col-md-pull-12 {
1791 right: 100%;
1792 }
1793 .col-md-pull-11 {
1794 right: 91.66666667%;
1795 }
1796 .col-md-pull-10 {
1797 right: 83.33333333%;
1798 }
1799 .col-md-pull-9 {
1800 right: 75%;
1801 }
1802 .col-md-pull-8 {
1803 right: 66.66666667%;
1804 }
1805 .col-md-pull-7 {
1806 right: 58.33333333%;
1807 }
1808 .col-md-pull-6 {
1809 right: 50%;
1810 }
1811 .col-md-pull-5 {
1812 right: 41.66666667%;
1813 }
1814 .col-md-pull-4 {
1815 right: 33.33333333%;
1816 }
1817 .col-md-pull-3 {
1818 right: 25%;
1819 }
1820 .col-md-pull-2 {
1821 right: 16.66666667%;
1822 }
1823 .col-md-pull-1 {
1824 right: 8.33333333%;
1825 }
1826 .col-md-pull-0 {
1827 right: auto;
1828 }
1829 .col-md-push-12 {
1830 left: 100%;
1831 }
1832 .col-md-push-11 {
1833 left: 91.66666667%;
1834 }
1835 .col-md-push-10 {
1836 left: 83.33333333%;
1837 }
1838 .col-md-push-9 {
1839 left: 75%;
1840 }
1841 .col-md-push-8 {
1842 left: 66.66666667%;
1843 }
1844 .col-md-push-7 {
1845 left: 58.33333333%;
1846 }
1847 .col-md-push-6 {
1848 left: 50%;
1849 }
1850 .col-md-push-5 {
1851 left: 41.66666667%;
1852 }
1853 .col-md-push-4 {
1854 left: 33.33333333%;
1855 }
1856 .col-md-push-3 {
1857 left: 25%;
1858 }
1859 .col-md-push-2 {
1860 left: 16.66666667%;
1861 }
1862 .col-md-push-1 {
1863 left: 8.33333333%;
1864 }
1865 .col-md-push-0 {
1866 left: auto;
1867 }
1868 .col-md-offset-12 {
1869 margin-left: 100%;
1870 }
1871 .col-md-offset-11 {
1872 margin-left: 91.66666667%;
1873 }
1874 .col-md-offset-10 {
1875 margin-left: 83.33333333%;
1876 }
1877 .col-md-offset-9 {
1878 margin-left: 75%;
1879 }
1880 .col-md-offset-8 {
1881 margin-left: 66.66666667%;
1882 }
1883 .col-md-offset-7 {
1884 margin-left: 58.33333333%;
1885 }
1886 .col-md-offset-6 {
1887 margin-left: 50%;
1888 }
1889 .col-md-offset-5 {
1890 margin-left: 41.66666667%;
1891 }
1892 .col-md-offset-4 {
1893 margin-left: 33.33333333%;
1894 }
1895 .col-md-offset-3 {
1896 margin-left: 25%;
1897 }
1898 .col-md-offset-2 {
1899 margin-left: 16.66666667%;
1900 }
1901 .col-md-offset-1 {
1902 margin-left: 8.33333333%;
1903 }
1904 .col-md-offset-0 {
1905 margin-left: 0;
1906 }
1907 }
1908 @media (min-width: 1200px) {
1909 .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 {
1910 float: left;
1911 }
1912 .col-lg-12 {
1913 width: 100%;
1914 }
1915 .col-lg-11 {
1916 width: 91.66666667%;
1917 }
1918 .col-lg-10 {
1919 width: 83.33333333%;
1920 }
1921 .col-lg-9 {
1922 width: 75%;
1923 }
1924 .col-lg-8 {
1925 width: 66.66666667%;
1926 }
1927 .col-lg-7 {
1928 width: 58.33333333%;
1929 }
1930 .col-lg-6 {
1931 width: 50%;
1932 }
1933 .col-lg-5 {
1934 width: 41.66666667%;
1935 }
1936 .col-lg-4 {
1937 width: 33.33333333%;
1938 }
1939 .col-lg-3 {
1940 width: 25%;
1941 }
1942 .col-lg-2 {
1943 width: 16.66666667%;
1944 }
1945 .col-lg-1 {
1946 width: 8.33333333%;
1947 }
1948 .col-lg-pull-12 {
1949 right: 100%;
1950 }
1951 .col-lg-pull-11 {
1952 right: 91.66666667%;
1953 }
1954 .col-lg-pull-10 {
1955 right: 83.33333333%;
1956 }
1957 .col-lg-pull-9 {
1958 right: 75%;
1959 }
1960 .col-lg-pull-8 {
1961 right: 66.66666667%;
1962 }
1963 .col-lg-pull-7 {
1964 right: 58.33333333%;
1965 }
1966 .col-lg-pull-6 {
1967 right: 50%;
1968 }
1969 .col-lg-pull-5 {
1970 right: 41.66666667%;
1971 }
1972 .col-lg-pull-4 {
1973 right: 33.33333333%;
1974 }
1975 .col-lg-pull-3 {
1976 right: 25%;
1977 }
1978 .col-lg-pull-2 {
1979 right: 16.66666667%;
1980 }
1981 .col-lg-pull-1 {
1982 right: 8.33333333%;
1983 }
1984 .col-lg-pull-0 {
1985 right: auto;
1986 }
1987 .col-lg-push-12 {
1988 left: 100%;
1989 }
1990 .col-lg-push-11 {
1991 left: 91.66666667%;
1992 }
1993 .col-lg-push-10 {
1994 left: 83.33333333%;
1995 }
1996 .col-lg-push-9 {
1997 left: 75%;
1998 }
1999 .col-lg-push-8 {
2000 left: 66.66666667%;
2001 }
2002 .col-lg-push-7 {
2003 left: 58.33333333%;
2004 }
2005 .col-lg-push-6 {
2006 left: 50%;
2007 }
2008 .col-lg-push-5 {
2009 left: 41.66666667%;
2010 }
2011 .col-lg-push-4 {
2012 left: 33.33333333%;
2013 }
2014 .col-lg-push-3 {
2015 left: 25%;
2016 }
2017 .col-lg-push-2 {
2018 left: 16.66666667%;
2019 }
2020 .col-lg-push-1 {
2021 left: 8.33333333%;
2022 }
2023 .col-lg-push-0 {
2024 left: auto;
2025 }
2026 .col-lg-offset-12 {
2027 margin-left: 100%;
2028 }
2029 .col-lg-offset-11 {
2030 margin-left: 91.66666667%;
2031 }
2032 .col-lg-offset-10 {
2033 margin-left: 83.33333333%;
2034 }
2035 .col-lg-offset-9 {
2036 margin-left: 75%;
2037 }
2038 .col-lg-offset-8 {
2039 margin-left: 66.66666667%;
2040 }
2041 .col-lg-offset-7 {
2042 margin-left: 58.33333333%;
2043 }
2044 .col-lg-offset-6 {
2045 margin-left: 50%;
2046 }
2047 .col-lg-offset-5 {
2048 margin-left: 41.66666667%;
2049 }
2050 .col-lg-offset-4 {
2051 margin-left: 33.33333333%;
2052 }
2053 .col-lg-offset-3 {
2054 margin-left: 25%;
2055 }
2056 .col-lg-offset-2 {
2057 margin-left: 16.66666667%;
2058 }
2059 .col-lg-offset-1 {
2060 margin-left: 8.33333333%;
2061 }
2062 .col-lg-offset-0 {
2063 margin-left: 0;
2064 }
2065 }
2066 table {
2067 background-color: transparent;
2068 }
2069 th {
2070 text-align: left;
2071 }
2072 .table {
2073 width: 100%;
2074 max-width: 100%;
2075 margin-bottom: 20px;
2076 }
2077 .table > thead > tr > th,
2078 .table > tbody > tr > th,
2079 .table > tfoot > tr > th,
2080 .table > thead > tr > td,
2081 .table > tbody > tr > td,
2082 .table > tfoot > tr > td {
2083 padding: 8px;
2084 line-height: 1.42857143;
2085 vertical-align: top;
2086 border-top: 1px solid #ddd;
2087 }
2088 .table > thead > tr > th {
2089 vertical-align: bottom;
2090 border-bottom: 2px solid #ddd;
2091 }
2092 .table > caption + thead > tr:first-child > th,
2093 .table > colgroup + thead > tr:first-child > th,
2094 .table > thead:first-child > tr:first-child > th,
2095 .table > caption + thead > tr:first-child > td,
2096 .table > colgroup + thead > tr:first-child > td,
2097 .table > thead:first-child > tr:first-child > td {
2098 border-top: 0;
2099 }
2100 .table > tbody + tbody {
2101 border-top: 2px solid #ddd;
2102 }
2103 .table .table {
2104 background-color: #fff;
2105 }
2106 .table-condensed > thead > tr > th,
2107 .table-condensed > tbody > tr > th,
2108 .table-condensed > tfoot > tr > th,
2109 .table-condensed > thead > tr > td,
2110 .table-condensed > tbody > tr > td,
2111 .table-condensed > tfoot > tr > td {
2112 padding: 5px;
2113 }
2114 .table-bordered {
2115 border: 1px solid #ddd;
2116 }
2117 .table-bordered > thead > tr > th,
2118 .table-bordered > tbody > tr > th,
2119 .table-bordered > tfoot > tr > th,
2120 .table-bordered > thead > tr > td,
2121 .table-bordered > tbody > tr > td,
2122 .table-bordered > tfoot > tr > td {
2123 border: 1px solid #ddd;
2124 }
2125 .table-bordered > thead > tr > th,
2126 .table-bordered > thead > tr > td {
2127 border-bottom-width: 2px;
2128 }
2129 .table-striped > tbody > tr:nth-child(odd) > td,
2130 .table-striped > tbody > tr:nth-child(odd) > th {
2131 background-color: #f9f9f9;
2132 }
2133 .table-hover > tbody > tr:hover > td,
2134 .table-hover > tbody > tr:hover > th {
2135 background-color: #f5f5f5;
2136 }
2137 table col[class*="col-"] {
2138 position: static;
2139 display: table-column;
2140 float: none;
2141 }
2142 table td[class*="col-"],
2143 table th[class*="col-"] {
2144 position: static;
2145 display: table-cell;
2146 float: none;
2147 }
2148 .table > thead > tr > td.active,
2149 .table > tbody > tr > td.active,
2150 .table > tfoot > tr > td.active,
2151 .table > thead > tr > th.active,
2152 .table > tbody > tr > th.active,
2153 .table > tfoot > tr > th.active,
2154 .table > thead > tr.active > td,
2155 .table > tbody > tr.active > td,
2156 .table > tfoot > tr.active > td,
2157 .table > thead > tr.active > th,
2158 .table > tbody > tr.active > th,
2159 .table > tfoot > tr.active > th {
2160 background-color: #f5f5f5;
2161 }
2162 .table-hover > tbody > tr > td.active:hover,
2163 .table-hover > tbody > tr > th.active:hover,
2164 .table-hover > tbody > tr.active:hover > td,
2165 .table-hover > tbody > tr:hover > .active,
2166 .table-hover > tbody > tr.active:hover > th {
2167 background-color: #e8e8e8;
2168 }
2169 .table > thead > tr > td.success,
2170 .table > tbody > tr > td.success,
2171 .table > tfoot > tr > td.success,
2172 .table > thead > tr > th.success,
2173 .table > tbody > tr > th.success,
2174 .table > tfoot > tr > th.success,
2175 .table > thead > tr.success > td,
2176 .table > tbody > tr.success > td,
2177 .table > tfoot > tr.success > td,
2178 .table > thead > tr.success > th,
2179 .table > tbody > tr.success > th,
2180 .table > tfoot > tr.success > th {
2181 background-color: #dff0d8;
2182 }
2183 .table-hover > tbody > tr > td.success:hover,
2184 .table-hover > tbody > tr > th.success:hover,
2185 .table-hover > tbody > tr.success:hover > td,
2186 .table-hover > tbody > tr:hover > .success,
2187 .table-hover > tbody > tr.success:hover > th {
2188 background-color: #d0e9c6;
2189 }
2190 .table > thead > tr > td.info,
2191 .table > tbody > tr > td.info,
2192 .table > tfoot > tr > td.info,
2193 .table > thead > tr > th.info,
2194 .table > tbody > tr > th.info,
2195 .table > tfoot > tr > th.info,
2196 .table > thead > tr.info > td,
2197 .table > tbody > tr.info > td,
2198 .table > tfoot > tr.info > td,
2199 .table > thead > tr.info > th,
2200 .table > tbody > tr.info > th,
2201 .table > tfoot > tr.info > th {
2202 background-color: #d9edf7;
2203 }
2204 .table-hover > tbody > tr > td.info:hover,
2205 .table-hover > tbody > tr > th.info:hover,
2206 .table-hover > tbody > tr.info:hover > td,
2207 .table-hover > tbody > tr:hover > .info,
2208 .table-hover > tbody > tr.info:hover > th {
2209 background-color: #c4e3f3;
2210 }
2211 .table > thead > tr > td.warning,
2212 .table > tbody > tr > td.warning,
2213 .table > tfoot > tr > td.warning,
2214 .table > thead > tr > th.warning,
2215 .table > tbody > tr > th.warning,
2216 .table > tfoot > tr > th.warning,
2217 .table > thead > tr.warning > td,
2218 .table > tbody > tr.warning > td,
2219 .table > tfoot > tr.warning > td,
2220 .table > thead > tr.warning > th,
2221 .table > tbody > tr.warning > th,
2222 .table > tfoot > tr.warning > th {
2223 background-color: #fcf8e3;
2224 }
2225 .table-hover > tbody > tr > td.warning:hover,
2226 .table-hover > tbody > tr > th.warning:hover,
2227 .table-hover > tbody > tr.warning:hover > td,
2228 .table-hover > tbody > tr:hover > .warning,
2229 .table-hover > tbody > tr.warning:hover > th {
2230 background-color: #faf2cc;
2231 }
2232 .table > thead > tr > td.danger,
2233 .table > tbody > tr > td.danger,
2234 .table > tfoot > tr > td.danger,
2235 .table > thead > tr > th.danger,
2236 .table > tbody > tr > th.danger,
2237 .table > tfoot > tr > th.danger,
2238 .table > thead > tr.danger > td,
2239 .table > tbody > tr.danger > td,
2240 .table > tfoot > tr.danger > td,
2241 .table > thead > tr.danger > th,
2242 .table > tbody > tr.danger > th,
2243 .table > tfoot > tr.danger > th {
2244 background-color: #f2dede;
2245 }
2246 .table-hover > tbody > tr > td.danger:hover,
2247 .table-hover > tbody > tr > th.danger:hover,
2248 .table-hover > tbody > tr.danger:hover > td,
2249 .table-hover > tbody > tr:hover > .danger,
2250 .table-hover > tbody > tr.danger:hover > th {
2251 background-color: #ebcccc;
2252 }
2253 @media screen and (max-width: 767px) {
2254 .table-responsive {
2255 width: 100%;
2256 margin-bottom: 15px;
2257 overflow-x: auto;
2258 overflow-y: hidden;
2259 -webkit-overflow-scrolling: touch;
2260 -ms-overflow-style: -ms-autohiding-scrollbar;
2261 border: 1px solid #ddd;
2262 }
2263 .table-responsive > .table {
2264 margin-bottom: 0;
2265 }
2266 .table-responsive > .table > thead > tr > th,
2267 .table-responsive > .table > tbody > tr > th,
2268 .table-responsive > .table > tfoot > tr > th,
2269 .table-responsive > .table > thead > tr > td,
2270 .table-responsive > .table > tbody > tr > td,
2271 .table-responsive > .table > tfoot > tr > td {
2272 white-space: nowrap;
2273 }
2274 .table-responsive > .table-bordered {
2275 border: 0;
2276 }
2277 .table-responsive > .table-bordered > thead > tr > th:first-child,
2278 .table-responsive > .table-bordered > tbody > tr > th:first-child,
2279 .table-responsive > .table-bordered > tfoot > tr > th:first-child,
2280 .table-responsive > .table-bordered > thead > tr > td:first-child,
2281 .table-responsive > .table-bordered > tbody > tr > td:first-child,
2282 .table-responsive > .table-bordered > tfoot > tr > td:first-child {
2283 border-left: 0;
2284 }
2285 .table-responsive > .table-bordered > thead > tr > th:last-child,
2286 .table-responsive > .table-bordered > tbody > tr > th:last-child,
2287 .table-responsive > .table-bordered > tfoot > tr > th:last-child,
2288 .table-responsive > .table-bordered > thead > tr > td:last-child,
2289 .table-responsive > .table-bordered > tbody > tr > td:last-child,
2290 .table-responsive > .table-bordered > tfoot > tr > td:last-child {
2291 border-right: 0;
2292 }
2293 .table-responsive > .table-bordered > tbody > tr:last-child > th,
2294 .table-responsive > .table-bordered > tfoot > tr:last-child > th,
2295 .table-responsive > .table-bordered > tbody > tr:last-child > td,
2296 .table-responsive > .table-bordered > tfoot > tr:last-child > td {
2297 border-bottom: 0;
2298 }
2299 }
2300 fieldset {
2301 min-width: 0;
2302 padding: 0;
2303 margin: 0;
2304 border: 0;
2305 }
2306 legend {
2307 display: block;
2308 width: 100%;
2309 padding: 0;
2310 margin-bottom: 20px;
2311 font-size: 21px;
2312 line-height: inherit;
2313 color: #333;
2314 border: 0;
2315 border-bottom: 1px solid #e5e5e5;
2316 }
2317 label {
2318 display: inline-block;
2319 max-width: 100%;
2320 margin-bottom: 5px;
2321 font-weight: bold;
2322 }
2323 input[type="search"] {
2324 -webkit-box-sizing: border-box;
2325 -moz-box-sizing: border-box;
2326 box-sizing: border-box;
2327 }
2328 input[type="radio"],
2329 input[type="checkbox"] {
2330 margin: 4px 0 0;
2331 margin-top: 1px \9;
2332 line-height: normal;
2333 }
2334 input[type="file"] {
2335 display: block;
2336 }
2337 input[type="range"] {
2338 display: block;
2339 width: 100%;
2340 }
2341 select[multiple],
2342 select[size] {
2343 height: auto;
2344 }
2345 input[type="file"]:focus,
2346 input[type="radio"]:focus,
2347 input[type="checkbox"]:focus {
2348 outline: thin dotted;
2349 outline: 5px auto -webkit-focus-ring-color;
2350 outline-offset: -2px;
2351 }
2352 output {
2353 display: block;
2354 padding-top: 7px;
2355 font-size: 14px;
2356 line-height: 1.42857143;
2357 color: #555;
2358 }
2359 .form-control {
2360 display: block;
2361 width: 100%;
2362 height: 34px;
2363 padding: 6px 12px;
2364 font-size: 14px;
2365 line-height: 1.42857143;
2366 color: #555;
2367 background-color: #fff;
2368 background-image: none;
2369 border: 1px solid #ccc;
2370 border-radius: 4px;
2371 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2372 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2373 -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
2374 -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
2375 transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
2376 }
2377 .form-control:focus {
2378 border-color: #66afe9;
2379 outline: 0;
2380 -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
2381 box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
2382 }
2383 .form-control::-moz-placeholder {
2384 color: #777;
2385 opacity: 1;
2386 }
2387 .form-control:-ms-input-placeholder {
2388 color: #777;
2389 }
2390 .form-control::-webkit-input-placeholder {
2391 color: #777;
2392 }
2393 .form-control[disabled],
2394 .form-control[readonly],
2395 fieldset[disabled] .form-control {
2396 cursor: not-allowed;
2397 background-color: #eee;
2398 opacity: 1;
2399 }
2400 textarea.form-control {
2401 height: auto;
2402 }
2403 input[type="search"] {
2404 -webkit-appearance: none;
2405 }
2406 input[type="date"],
2407 input[type="time"],
2408 input[type="datetime-local"],
2409 input[type="month"] {
2410 line-height: 34px;
2411 line-height: 1.42857143 \0;
2412 }
2413 input[type="date"].input-sm,
2414 input[type="time"].input-sm,
2415 input[type="datetime-local"].input-sm,
2416 input[type="month"].input-sm {
2417 line-height: 30px;
2418 }
2419 input[type="date"].input-lg,
2420 input[type="time"].input-lg,
2421 input[type="datetime-local"].input-lg,
2422 input[type="month"].input-lg {
2423 line-height: 46px;
2424 }
2425 .form-group {
2426 margin-bottom: 15px;
2427 }
2428 .radio,
2429 .checkbox {
2430 position: relative;
2431 display: block;
2432 min-height: 20px;
2433 margin-top: 10px;
2434 margin-bottom: 10px;
2435 }
2436 .radio label,
2437 .checkbox label {
2438 padding-left: 20px;
2439 margin-bottom: 0;
2440 font-weight: normal;
2441 cursor: pointer;
2442 }
2443 .radio input[type="radio"],
2444 .radio-inline input[type="radio"],
2445 .checkbox input[type="checkbox"],
2446 .checkbox-inline input[type="checkbox"] {
2447 position: absolute;
2448 margin-top: 4px \9;
2449 margin-left: -20px;
2450 }
2451 .radio + .radio,
2452 .checkbox + .checkbox {
2453 margin-top: -5px;
2454 }
2455 .radio-inline,
2456 .checkbox-inline {
2457 display: inline-block;
2458 padding-left: 20px;
2459 margin-bottom: 0;
2460 font-weight: normal;
2461 vertical-align: middle;
2462 cursor: pointer;
2463 }
2464 .radio-inline + .radio-inline,
2465 .checkbox-inline + .checkbox-inline {
2466 margin-top: 0;
2467 margin-left: 10px;
2468 }
2469 input[type="radio"][disabled],
2470 input[type="checkbox"][disabled],
2471 input[type="radio"].disabled,
2472 input[type="checkbox"].disabled,
2473 fieldset[disabled] input[type="radio"],
2474 fieldset[disabled] input[type="checkbox"] {
2475 cursor: not-allowed;
2476 }
2477 .radio-inline.disabled,
2478 .checkbox-inline.disabled,
2479 fieldset[disabled] .radio-inline,
2480 fieldset[disabled] .checkbox-inline {
2481 cursor: not-allowed;
2482 }
2483 .radio.disabled label,
2484 .checkbox.disabled label,
2485 fieldset[disabled] .radio label,
2486 fieldset[disabled] .checkbox label {
2487 cursor: not-allowed;
2488 }
2489 .form-control-static {
2490 padding-top: 7px;
2491 padding-bottom: 7px;
2492 margin-bottom: 0;
2493 }
2494 .form-control-static.input-lg,
2495 .form-control-static.input-sm {
2496 padding-right: 0;
2497 padding-left: 0;
2498 }
2499 .input-sm,
2500 .form-horizontal .form-group-sm .form-control {
2501 height: 30px;
2502 padding: 5px 10px;
2503 font-size: 12px;
2504 line-height: 1.5;
2505 border-radius: 3px;
2506 }
2507 select.input-sm {
2508 height: 30px;
2509 line-height: 30px;
2510 }
2511 textarea.input-sm,
2512 select[multiple].input-sm {
2513 height: auto;
2514 }
2515 .input-lg,
2516 .form-horizontal .form-group-lg .form-control {
2517 height: 46px;
2518 padding: 10px 16px;
2519 font-size: 18px;
2520 line-height: 1.33;
2521 border-radius: 6px;
2522 }
2523 select.input-lg {
2524 height: 46px;
2525 line-height: 46px;
2526 }
2527 textarea.input-lg,
2528 select[multiple].input-lg {
2529 height: auto;
2530 }
2531 .has-feedback {
2532 position: relative;
2533 }
2534 .has-feedback .form-control {
2535 padding-right: 42.5px;
2536 }
2537 .form-control-feedback {
2538 position: absolute;
2539 top: 25px;
2540 right: 0;
2541 z-index: 2;
2542 display: block;
2543 width: 34px;
2544 height: 34px;
2545 line-height: 34px;
2546 text-align: center;
2547 }
2548 .input-lg + .form-control-feedback {
2549 width: 46px;
2550 height: 46px;
2551 line-height: 46px;
2552 }
2553 .input-sm + .form-control-feedback {
2554 width: 30px;
2555 height: 30px;
2556 line-height: 30px;
2557 }
2558 .has-success .help-block,
2559 .has-success .control-label,
2560 .has-success .radio,
2561 .has-success .checkbox,
2562 .has-success .radio-inline,
2563 .has-success .checkbox-inline {
2564 color: #3c763d;
2565 }
2566 .has-success .form-control {
2567 border-color: #3c763d;
2568 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2569 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2570 }
2571 .has-success .form-control:focus {
2572 border-color: #2b542c;
2573 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #67b168;
2574 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #67b168;
2575 }
2576 .has-success .input-group-addon {
2577 color: #3c763d;
2578 background-color: #dff0d8;
2579 border-color: #3c763d;
2580 }
2581 .has-success .form-control-feedback {
2582 color: #3c763d;
2583 }
2584 .has-warning .help-block,
2585 .has-warning .control-label,
2586 .has-warning .radio,
2587 .has-warning .checkbox,
2588 .has-warning .radio-inline,
2589 .has-warning .checkbox-inline {
2590 color: #8a6d3b;
2591 }
2592 .has-warning .form-control {
2593 border-color: #8a6d3b;
2594 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2595 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2596 }
2597 .has-warning .form-control:focus {
2598 border-color: #66512c;
2599 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #c0a16b;
2600 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #c0a16b;
2601 }
2602 .has-warning .input-group-addon {
2603 color: #8a6d3b;
2604 background-color: #fcf8e3;
2605 border-color: #8a6d3b;
2606 }
2607 .has-warning .form-control-feedback {
2608 color: #8a6d3b;
2609 }
2610 .has-error .help-block,
2611 .has-error .control-label,
2612 .has-error .radio,
2613 .has-error .checkbox,
2614 .has-error .radio-inline,
2615 .has-error .checkbox-inline {
2616 color: #a94442;
2617 }
2618 .has-error .form-control {
2619 border-color: #a94442;
2620 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2621 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2622 }
2623 .has-error .form-control:focus {
2624 border-color: #843534;
2625 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #ce8483;
2626 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #ce8483;
2627 }
2628 .has-error .input-group-addon {
2629 color: #a94442;
2630 background-color: #f2dede;
2631 border-color: #a94442;
2632 }
2633 .has-error .form-control-feedback {
2634 color: #a94442;
2635 }
2636 .has-feedback label.sr-only ~ .form-control-feedback {
2637 top: 0;
2638 }
2639 .help-block {
2640 display: block;
2641 margin-top: 5px;
2642 margin-bottom: 10px;
2643 color: #737373;
2644 }
2645 @media (min-width: 768px) {
2646 .form-inline .form-group {
2647 display: inline-block;
2648 margin-bottom: 0;
2649 vertical-align: middle;
2650 }
2651 .form-inline .form-control {
2652 display: inline-block;
2653 width: auto;
2654 vertical-align: middle;
2655 }
2656 .form-inline .input-group {
2657 display: inline-table;
2658 vertical-align: middle;
2659 }
2660 .form-inline .input-group .input-group-addon,
2661 .form-inline .input-group .input-group-btn,
2662 .form-inline .input-group .form-control {
2663 width: auto;
2664 }
2665 .form-inline .input-group > .form-control {
2666 width: 100%;
2667 }
2668 .form-inline .control-label {
2669 margin-bottom: 0;
2670 vertical-align: middle;
2671 }
2672 .form-inline .radio,
2673 .form-inline .checkbox {
2674 display: inline-block;
2675 margin-top: 0;
2676 margin-bottom: 0;
2677 vertical-align: middle;
2678 }
2679 .form-inline .radio label,
2680 .form-inline .checkbox label {
2681 padding-left: 0;
2682 }
2683 .form-inline .radio input[type="radio"],
2684 .form-inline .checkbox input[type="checkbox"] {
2685 position: relative;
2686 margin-left: 0;
2687 }
2688 .form-inline .has-feedback .form-control-feedback {
2689 top: 0;
2690 }
2691 }
2692 .form-horizontal .radio,
2693 .form-horizontal .checkbox,
2694 .form-horizontal .radio-inline,
2695 .form-horizontal .checkbox-inline {
2696 padding-top: 7px;
2697 margin-top: 0;
2698 margin-bottom: 0;
2699 }
2700 .form-horizontal .radio,
2701 .form-horizontal .checkbox {
2702 min-height: 27px;
2703 }
2704 .form-horizontal .form-group {
2705 margin-right: -15px;
2706 margin-left: -15px;
2707 }
2708 @media (min-width: 768px) {
2709 .form-horizontal .control-label {
2710 padding-top: 7px;
2711 margin-bottom: 0;
2712 text-align: right;
2713 }
2714 }
2715 .form-horizontal .has-feedback .form-control-feedback {
2716 top: 0;
2717 right: 15px;
2718 }
2719 @media (min-width: 768px) {
2720 .form-horizontal .form-group-lg .control-label {
2721 padding-top: 14.3px;
2722 }
2723 }
2724 @media (min-width: 768px) {
2725 .form-horizontal .form-group-sm .control-label {
2726 padding-top: 6px;
2727 }
2728 }
2729 .btn {
2730 display: inline-block;
2731 padding: 6px 12px;
2732 margin-bottom: 0;
2733 font-size: 14px;
2734 font-weight: normal;
2735 line-height: 1.42857143;
2736 text-align: center;
2737 white-space: nowrap;
2738 vertical-align: middle;
2739 cursor: pointer;
2740 -webkit-user-select: none;
2741 -moz-user-select: none;
2742 -ms-user-select: none;
2743 user-select: none;
2744 background-image: none;
2745 border: 1px solid transparent;
2746 border-radius: 4px;
2747 }
2748 .btn:focus,
2749 .btn:active:focus,
2750 .btn.active:focus {
2751 outline: thin dotted;
2752 outline: 5px auto -webkit-focus-ring-color;
2753 outline-offset: -2px;
2754 }
2755 .btn:hover,
2756 .btn:focus {
2757 color: #333;
2758 text-decoration: none;
2759 }
2760 .btn:active,
2761 .btn.active {
2762 background-image: none;
2763 outline: 0;
2764 -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
2765 box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
2766 }
2767 .btn.disabled,
2768 .btn[disabled],
2769 fieldset[disabled] .btn {
2770 pointer-events: none;
2771 cursor: not-allowed;
2772 filter: alpha(opacity=65);
2773 -webkit-box-shadow: none;
2774 box-shadow: none;
2775 opacity: .65;
2776 }
2777 .btn-default {
2778 color: #333;
2779 background-color: #fff;
2780 border-color: #ccc;
2781 }
2782 .btn-default:hover,
2783 .btn-default:focus,
2784 .btn-default:active,
2785 .btn-default.active,
2786 .open > .dropdown-toggle.btn-default {
2787 color: #333;
2788 background-color: #e6e6e6;
2789 border-color: #adadad;
2790 }
2791 .btn-default:active,
2792 .btn-default.active,
2793 .open > .dropdown-toggle.btn-default {
2794 background-image: none;
2795 }
2796 .btn-default.disabled,
2797 .btn-default[disabled],
2798 fieldset[disabled] .btn-default,
2799 .btn-default.disabled:hover,
2800 .btn-default[disabled]:hover,
2801 fieldset[disabled] .btn-default:hover,
2802 .btn-default.disabled:focus,
2803 .btn-default[disabled]:focus,
2804 fieldset[disabled] .btn-default:focus,
2805 .btn-default.disabled:active,
2806 .btn-default[disabled]:active,
2807 fieldset[disabled] .btn-default:active,
2808 .btn-default.disabled.active,
2809 .btn-default[disabled].active,
2810 fieldset[disabled] .btn-default.active {
2811 background-color: #fff;
2812 border-color: #ccc;
2813 }
2814 .btn-default .badge {
2815 color: #fff;
2816 background-color: #333;
2817 }
2818 .btn-primary {
2819 color: #fff;
2820 background-color: #428bca;
2821 border-color: #357ebd;
2822 }
2823 .btn-primary:hover,
2824 .btn-primary:focus,
2825 .btn-primary:active,
2826 .btn-primary.active,
2827 .open > .dropdown-toggle.btn-primary {
2828 color: #fff;
2829 background-color: #3071a9;
2830 border-color: #285e8e;
2831 }
2832 .btn-primary:active,
2833 .btn-primary.active,
2834 .open > .dropdown-toggle.btn-primary {
2835 background-image: none;
2836 }
2837 .btn-primary.disabled,
2838 .btn-primary[disabled],
2839 fieldset[disabled] .btn-primary,
2840 .btn-primary.disabled:hover,
2841 .btn-primary[disabled]:hover,
2842 fieldset[disabled] .btn-primary:hover,
2843 .btn-primary.disabled:focus,
2844 .btn-primary[disabled]:focus,
2845 fieldset[disabled] .btn-primary:focus,
2846 .btn-primary.disabled:active,
2847 .btn-primary[disabled]:active,
2848 fieldset[disabled] .btn-primary:active,
2849 .btn-primary.disabled.active,
2850 .btn-primary[disabled].active,
2851 fieldset[disabled] .btn-primary.active {
2852 background-color: #428bca;
2853 border-color: #357ebd;
2854 }
2855 .btn-primary .badge {
2856 color: #428bca;
2857 background-color: #fff;
2858 }
2859 .btn-success {
2860 color: #fff;
2861 background-color: #5cb85c;
2862 border-color: #4cae4c;
2863 }
2864 .btn-success:hover,
2865 .btn-success:focus,
2866 .btn-success:active,
2867 .btn-success.active,
2868 .open > .dropdown-toggle.btn-success {
2869 color: #fff;
2870 background-color: #449d44;
2871 border-color: #398439;
2872 }
2873 .btn-success:active,
2874 .btn-success.active,
2875 .open > .dropdown-toggle.btn-success {
2876 background-image: none;
2877 }
2878 .btn-success.disabled,
2879 .btn-success[disabled],
2880 fieldset[disabled] .btn-success,
2881 .btn-success.disabled:hover,
2882 .btn-success[disabled]:hover,
2883 fieldset[disabled] .btn-success:hover,
2884 .btn-success.disabled:focus,
2885 .btn-success[disabled]:focus,
2886 fieldset[disabled] .btn-success:focus,
2887 .btn-success.disabled:active,
2888 .btn-success[disabled]:active,
2889 fieldset[disabled] .btn-success:active,
2890 .btn-success.disabled.active,
2891 .btn-success[disabled].active,
2892 fieldset[disabled] .btn-success.active {
2893 background-color: #5cb85c;
2894 border-color: #4cae4c;
2895 }
2896 .btn-success .badge {
2897 color: #5cb85c;
2898 background-color: #fff;
2899 }
2900 .btn-info {
2901 color: #fff;
2902 background-color: #5bc0de;
2903 border-color: #46b8da;
2904 }
2905 .btn-info:hover,
2906 .btn-info:focus,
2907 .btn-info:active,
2908 .btn-info.active,
2909 .open > .dropdown-toggle.btn-info {
2910 color: #fff;
2911 background-color: #31b0d5;
2912 border-color: #269abc;
2913 }
2914 .btn-info:active,
2915 .btn-info.active,
2916 .open > .dropdown-toggle.btn-info {
2917 background-image: none;
2918 }
2919 .btn-info.disabled,
2920 .btn-info[disabled],
2921 fieldset[disabled] .btn-info,
2922 .btn-info.disabled:hover,
2923 .btn-info[disabled]:hover,
2924 fieldset[disabled] .btn-info:hover,
2925 .btn-info.disabled:focus,
2926 .btn-info[disabled]:focus,
2927 fieldset[disabled] .btn-info:focus,
2928 .btn-info.disabled:active,
2929 .btn-info[disabled]:active,
2930 fieldset[disabled] .btn-info:active,
2931 .btn-info.disabled.active,
2932 .btn-info[disabled].active,
2933 fieldset[disabled] .btn-info.active {
2934 background-color: #5bc0de;
2935 border-color: #46b8da;
2936 }
2937 .btn-info .badge {
2938 color: #5bc0de;
2939 background-color: #fff;
2940 }
2941 .btn-warning {
2942 color: #fff;
2943 background-color: #f0ad4e;
2944 border-color: #eea236;
2945 }
2946 .btn-warning:hover,
2947 .btn-warning:focus,
2948 .btn-warning:active,
2949 .btn-warning.active,
2950 .open > .dropdown-toggle.btn-warning {
2951 color: #fff;
2952 background-color: #ec971f;
2953 border-color: #d58512;
2954 }
2955 .btn-warning:active,
2956 .btn-warning.active,
2957 .open > .dropdown-toggle.btn-warning {
2958 background-image: none;
2959 }
2960 .btn-warning.disabled,
2961 .btn-warning[disabled],
2962 fieldset[disabled] .btn-warning,
2963 .btn-warning.disabled:hover,
2964 .btn-warning[disabled]:hover,
2965 fieldset[disabled] .btn-warning:hover,
2966 .btn-warning.disabled:focus,
2967 .btn-warning[disabled]:focus,
2968 fieldset[disabled] .btn-warning:focus,
2969 .btn-warning.disabled:active,
2970 .btn-warning[disabled]:active,
2971 fieldset[disabled] .btn-warning:active,
2972 .btn-warning.disabled.active,
2973 .btn-warning[disabled].active,
2974 fieldset[disabled] .btn-warning.active {
2975 background-color: #f0ad4e;
2976 border-color: #eea236;
2977 }
2978 .btn-warning .badge {
2979 color: #f0ad4e;
2980 background-color: #fff;
2981 }
2982 .btn-danger {
2983 color: #fff;
2984 background-color: #d9534f;
2985 border-color: #d43f3a;
2986 }
2987 .btn-danger:hover,
2988 .btn-danger:focus,
2989 .btn-danger:active,
2990 .btn-danger.active,
2991 .open > .dropdown-toggle.btn-danger {
2992 color: #fff;
2993 background-color: #c9302c;
2994 border-color: #ac2925;
2995 }
2996 .btn-danger:active,
2997 .btn-danger.active,
2998 .open > .dropdown-toggle.btn-danger {
2999 background-image: none;
3000 }
3001 .btn-danger.disabled,
3002 .btn-danger[disabled],
3003 fieldset[disabled] .btn-danger,
3004 .btn-danger.disabled:hover,
3005 .btn-danger[disabled]:hover,
3006 fieldset[disabled] .btn-danger:hover,
3007 .btn-danger.disabled:focus,
3008 .btn-danger[disabled]:focus,
3009 fieldset[disabled] .btn-danger:focus,
3010 .btn-danger.disabled:active,
3011 .btn-danger[disabled]:active,
3012 fieldset[disabled] .btn-danger:active,
3013 .btn-danger.disabled.active,
3014 .btn-danger[disabled].active,
3015 fieldset[disabled] .btn-danger.active {
3016 background-color: #d9534f;
3017 border-color: #d43f3a;
3018 }
3019 .btn-danger .badge {
3020 color: #d9534f;
3021 background-color: #fff;
3022 }
3023 .btn-link {
3024 font-weight: normal;
3025 color: #428bca;
3026 cursor: pointer;
3027 border-radius: 0;
3028 }
3029 .btn-link,
3030 .btn-link:active,
3031 .btn-link[disabled],
3032 fieldset[disabled] .btn-link {
3033 background-color: transparent;
3034 -webkit-box-shadow: none;
3035 box-shadow: none;
3036 }
3037 .btn-link,
3038 .btn-link:hover,
3039 .btn-link:focus,
3040 .btn-link:active {
3041 border-color: transparent;
3042 }
3043 .btn-link:hover,
3044 .btn-link:focus {
3045 color: #2a6496;
3046 text-decoration: underline;
3047 background-color: transparent;
3048 }
3049 .btn-link[disabled]:hover,
3050 fieldset[disabled] .btn-link:hover,
3051 .btn-link[disabled]:focus,
3052 fieldset[disabled] .btn-link:focus {
3053 color: #777;
3054 text-decoration: none;
3055 }
3056 .btn-lg,
3057 .btn-group-lg > .btn {
3058 padding: 10px 16px;
3059 font-size: 18px;
3060 line-height: 1.33;
3061 border-radius: 6px;
3062 }
3063 .btn-sm,
3064 .btn-group-sm > .btn {
3065 padding: 5px 10px;
3066 font-size: 12px;
3067 line-height: 1.5;
3068 border-radius: 3px;
3069 }
3070 .btn-xs,
3071 .btn-group-xs > .btn {
3072 padding: 1px 5px;
3073 font-size: 12px;
3074 line-height: 1.5;
3075 border-radius: 3px;
3076 }
3077 .btn-block {
3078 display: block;
3079 width: 100%;
3080 }
3081 .btn-block + .btn-block {
3082 margin-top: 5px;
3083 }
3084 input[type="submit"].btn-block,
3085 input[type="reset"].btn-block,
3086 input[type="button"].btn-block {
3087 width: 100%;
3088 }
3089 .fade {
3090 opacity: 0;
3091 -webkit-transition: opacity .15s linear;
3092 -o-transition: opacity .15s linear;
3093 transition: opacity .15s linear;
3094 }
3095 .fade.in {
3096 opacity: 1;
3097 }
3098 .collapse {
3099 display: none;
3100 }
3101 .collapse.in {
3102 display: block;
3103 }
3104 tr.collapse.in {
3105 display: table-row;
3106 }
3107 tbody.collapse.in {
3108 display: table-row-group;
3109 }
3110 .collapsing {
3111 position: relative;
3112 height: 0;
3113 overflow: hidden;
3114 -webkit-transition: height .35s ease;
3115 -o-transition: height .35s ease;
3116 transition: height .35s ease;
3117 }
3118 .caret {
3119 display: inline-block;
3120 width: 0;
3121 height: 0;
3122 margin-left: 2px;
3123 vertical-align: middle;
3124 border-top: 4px solid;
3125 border-right: 4px solid transparent;
3126 border-left: 4px solid transparent;
3127 }
3128 .dropdown {
3129 position: relative;
3130 }
3131 .dropdown-toggle:focus {
3132 outline: 0;
3133 }
3134 .dropdown-menu {
3135 position: absolute;
3136 top: 100%;
3137 left: 0;
3138 z-index: 1000;
3139 display: none;
3140 float: left;
3141 min-width: 160px;
3142 padding: 5px 0;
3143 margin: 2px 0 0;
3144 font-size: 14px;
3145 text-align: left;
3146 list-style: none;
3147 background-color: #fff;
3148 -webkit-background-clip: padding-box;
3149 background-clip: padding-box;
3150 border: 1px solid #ccc;
3151 border: 1px solid rgba(0, 0, 0, .15);
3152 border-radius: 4px;
3153 -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
3154 box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
3155 }
3156 .dropdown-menu.pull-right {
3157 right: 0;
3158 left: auto;
3159 }
3160 .dropdown-menu .divider {
3161 height: 1px;
3162 margin: 9px 0;
3163 overflow: hidden;
3164 background-color: #e5e5e5;
3165 }
3166 .dropdown-menu > li > a {
3167 display: block;
3168 padding: 3px 20px;
3169 clear: both;
3170 font-weight: normal;
3171 line-height: 1.42857143;
3172 color: #333;
3173 white-space: nowrap;
3174 }
3175 .dropdown-menu > li > a:hover,
3176 .dropdown-menu > li > a:focus {
3177 color: #262626;
3178 text-decoration: none;
3179 background-color: #f5f5f5;
3180 }
3181 .dropdown-menu > .active > a,
3182 .dropdown-menu > .active > a:hover,
3183 .dropdown-menu > .active > a:focus {
3184 color: #fff;
3185 text-decoration: none;
3186 background-color: #428bca;
3187 outline: 0;
3188 }
3189 .dropdown-menu > .disabled > a,
3190 .dropdown-menu > .disabled > a:hover,
3191 .dropdown-menu > .disabled > a:focus {
3192 color: #777;
3193 }
3194 .dropdown-menu > .disabled > a:hover,
3195 .dropdown-menu > .disabled > a:focus {
3196 text-decoration: none;
3197 cursor: not-allowed;
3198 background-color: transparent;
3199 background-image: none;
3200 filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
3201 }
3202 .open > .dropdown-menu {
3203 display: block;
3204 }
3205 .open > a {
3206 outline: 0;
3207 }
3208 .dropdown-menu-right {
3209 right: 0;
3210 left: auto;
3211 }
3212 .dropdown-menu-left {
3213 right: auto;
3214 left: 0;
3215 }
3216 .dropdown-header {
3217 display: block;
3218 padding: 3px 20px;
3219 font-size: 12px;
3220 line-height: 1.42857143;
3221 color: #777;
3222 white-space: nowrap;
3223 }
3224 .dropdown-backdrop {
3225 position: fixed;
3226 top: 0;
3227 right: 0;
3228 bottom: 0;
3229 left: 0;
3230 z-index: 990;
3231 }
3232 .pull-right > .dropdown-menu {
3233 right: 0;
3234 left: auto;
3235 }
3236 .dropup .caret,
3237 .navbar-fixed-bottom .dropdown .caret {
3238 content: "";
3239 border-top: 0;
3240 border-bottom: 4px solid;
3241 }
3242 .dropup .dropdown-menu,
3243 .navbar-fixed-bottom .dropdown .dropdown-menu {
3244 top: auto;
3245 bottom: 100%;
3246 margin-bottom: 1px;
3247 }
3248 @media (min-width: 768px) {
3249 .navbar-right .dropdown-menu {
3250 right: 0;
3251 left: auto;
3252 }
3253 .navbar-right .dropdown-menu-left {
3254 right: auto;
3255 left: 0;
3256 }
3257 }
3258 .btn-group,
3259 .btn-group-vertical {
3260 position: relative;
3261 display: inline-block;
3262 vertical-align: middle;
3263 }
3264 .btn-group > .btn,
3265 .btn-group-vertical > .btn {
3266 position: relative;
3267 float: left;
3268 }
3269 .btn-group > .btn:hover,
3270 .btn-group-vertical > .btn:hover,
3271 .btn-group > .btn:focus,
3272 .btn-group-vertical > .btn:focus,
3273 .btn-group > .btn:active,
3274 .btn-group-vertical > .btn:active,
3275 .btn-group > .btn.active,
3276 .btn-group-vertical > .btn.active {
3277 z-index: 2;
3278 }
3279 .btn-group > .btn:focus,
3280 .btn-group-vertical > .btn:focus {
3281 outline: 0;
3282 }
3283 .btn-group .btn + .btn,
3284 .btn-group .btn + .btn-group,
3285 .btn-group .btn-group + .btn,
3286 .btn-group .btn-group + .btn-group {
3287 margin-left: -1px;
3288 }
3289 .btn-toolbar {
3290 margin-left: -5px;
3291 }
3292 .btn-toolbar .btn-group,
3293 .btn-toolbar .input-group {
3294 float: left;
3295 }
3296 .btn-toolbar > .btn,
3297 .btn-toolbar > .btn-group,
3298 .btn-toolbar > .input-group {
3299 margin-left: 5px;
3300 }
3301 .btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) {
3302 border-radius: 0;
3303 }
3304 .btn-group > .btn:first-child {
3305 margin-left: 0;
3306 }
3307 .btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) {
3308 border-top-right-radius: 0;
3309 border-bottom-right-radius: 0;
3310 }
3311 .btn-group > .btn:last-child:not(:first-child),
3312 .btn-group > .dropdown-toggle:not(:first-child) {
3313 border-top-left-radius: 0;
3314 border-bottom-left-radius: 0;
3315 }
3316 .btn-group > .btn-group {
3317 float: left;
3318 }
3319 .btn-group > .btn-group:not(:first-child):not(:last-child) > .btn {
3320 border-radius: 0;
3321 }
3322 .btn-group > .btn-group:first-child > .btn:last-child,
3323 .btn-group > .btn-group:first-child > .dropdown-toggle {
3324 border-top-right-radius: 0;
3325 border-bottom-right-radius: 0;
3326 }
3327 .btn-group > .btn-group:last-child > .btn:first-child {
3328 border-top-left-radius: 0;
3329 border-bottom-left-radius: 0;
3330 }
3331 .btn-group .dropdown-toggle:active,
3332 .btn-group.open .dropdown-toggle {
3333 outline: 0;
3334 }
3335 .btn-group > .btn + .dropdown-toggle {
3336 padding-right: 8px;
3337 padding-left: 8px;
3338 }
3339 .btn-group > .btn-lg + .dropdown-toggle {
3340 padding-right: 12px;
3341 padding-left: 12px;
3342 }
3343 .btn-group.open .dropdown-toggle {
3344 -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
3345 box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
3346 }
3347 .btn-group.open .dropdown-toggle.btn-link {
3348 -webkit-box-shadow: none;
3349 box-shadow: none;
3350 }
3351 .btn .caret {
3352 margin-left: 0;
3353 }
3354 .btn-lg .caret {
3355 border-width: 5px 5px 0;
3356 border-bottom-width: 0;
3357 }
3358 .dropup .btn-lg .caret {
3359 border-width: 0 5px 5px;
3360 }
3361 .btn-group-vertical > .btn,
3362 .btn-group-vertical > .btn-group,
3363 .btn-group-vertical > .btn-group > .btn {
3364 display: block;
3365 float: none;
3366 width: 100%;
3367 max-width: 100%;
3368 }
3369 .btn-group-vertical > .btn-group > .btn {
3370 float: none;
3371 }
3372 .btn-group-vertical > .btn + .btn,
3373 .btn-group-vertical > .btn + .btn-group,
3374 .btn-group-vertical > .btn-group + .btn,
3375 .btn-group-vertical > .btn-group + .btn-group {
3376 margin-top: -1px;
3377 margin-left: 0;
3378 }
3379 .btn-group-vertical > .btn:not(:first-child):not(:last-child) {
3380 border-radius: 0;
3381 }
3382 .btn-group-vertical > .btn:first-child:not(:last-child) {
3383 border-top-right-radius: 4px;
3384 border-bottom-right-radius: 0;
3385 border-bottom-left-radius: 0;
3386 }
3387 .btn-group-vertical > .btn:last-child:not(:first-child) {
3388 border-top-left-radius: 0;
3389 border-top-right-radius: 0;
3390 border-bottom-left-radius: 4px;
3391 }
3392 .btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn {
3393 border-radius: 0;
3394 }
3395 .btn-group-vertical > .btn-group:first-child:not(:last-child) > .btn:last-child,
3396 .btn-group-vertical > .btn-group:first-child:not(:last-child) > .dropdown-toggle {
3397 border-bottom-right-radius: 0;
3398 border-bottom-left-radius: 0;
3399 }
3400 .btn-group-vertical > .btn-group:last-child:not(:first-child) > .btn:first-child {
3401 border-top-left-radius: 0;
3402 border-top-right-radius: 0;
3403 }
3404 .btn-group-justified {
3405 display: table;
3406 width: 100%;
3407 table-layout: fixed;
3408 border-collapse: separate;
3409 }
3410 .btn-group-justified > .btn,
3411 .btn-group-justified > .btn-group {
3412 display: table-cell;
3413 float: none;
3414 width: 1%;
3415 }
3416 .btn-group-justified > .btn-group .btn {
3417 width: 100%;
3418 }
3419 .btn-group-justified > .btn-group .dropdown-menu {
3420 left: auto;
3421 }
3422 [data-toggle="buttons"] > .btn > input[type="radio"],
3423 [data-toggle="buttons"] > .btn > input[type="checkbox"] {
3424 position: absolute;
3425 z-index: -1;
3426 filter: alpha(opacity=0);
3427 opacity: 0;
3428 }
3429 .input-group {
3430 position: relative;
3431 display: table;
3432 border-collapse: separate;
3433 }
3434 .input-group[class*="col-"] {
3435 float: none;
3436 padding-right: 0;
3437 padding-left: 0;
3438 }
3439 .input-group .form-control {
3440 position: relative;
3441 z-index: 2;
3442 float: left;
3443 width: 100%;
3444 margin-bottom: 0;
3445 }
3446 .input-group-lg > .form-control,
3447 .input-group-lg > .input-group-addon,
3448 .input-group-lg > .input-group-btn > .btn {
3449 height: 46px;
3450 padding: 10px 16px;
3451 font-size: 18px;
3452 line-height: 1.33;
3453 border-radius: 6px;
3454 }
3455 select.input-group-lg > .form-control,
3456 select.input-group-lg > .input-group-addon,
3457 select.input-group-lg > .input-group-btn > .btn {
3458 height: 46px;
3459 line-height: 46px;
3460 }
3461 textarea.input-group-lg > .form-control,
3462 textarea.input-group-lg > .input-group-addon,
3463 textarea.input-group-lg > .input-group-btn > .btn,
3464 select[multiple].input-group-lg > .form-control,
3465 select[multiple].input-group-lg > .input-group-addon,
3466 select[multiple].input-group-lg > .input-group-btn > .btn {
3467 height: auto;
3468 }
3469 .input-group-sm > .form-control,
3470 .input-group-sm > .input-group-addon,
3471 .input-group-sm > .input-group-btn > .btn {
3472 height: 30px;
3473 padding: 5px 10px;
3474 font-size: 12px;
3475 line-height: 1.5;
3476 border-radius: 3px;
3477 }
3478 select.input-group-sm > .form-control,
3479 select.input-group-sm > .input-group-addon,
3480 select.input-group-sm > .input-group-btn > .btn {
3481 height: 30px;
3482 line-height: 30px;
3483 }
3484 textarea.input-group-sm > .form-control,
3485 textarea.input-group-sm > .input-group-addon,
3486 textarea.input-group-sm > .input-group-btn > .btn,
3487 select[multiple].input-group-sm > .form-control,
3488 select[multiple].input-group-sm > .input-group-addon,
3489 select[multiple].input-group-sm > .input-group-btn > .btn {
3490 height: auto;
3491 }
3492 .input-group-addon,
3493 .input-group-btn,
3494 .input-group .form-control {
3495 display: table-cell;
3496 }
3497 .input-group-addon:not(:first-child):not(:last-child),
3498 .input-group-btn:not(:first-child):not(:last-child),
3499 .input-group .form-control:not(:first-child):not(:last-child) {
3500 border-radius: 0;
3501 }
3502 .input-group-addon,
3503 .input-group-btn {
3504 width: 1%;
3505 white-space: nowrap;
3506 vertical-align: middle;
3507 }
3508 .input-group-addon {
3509 padding: 6px 12px;
3510 font-size: 14px;
3511 font-weight: normal;
3512 line-height: 1;
3513 color: #555;
3514 text-align: center;
3515 background-color: #eee;
3516 border: 1px solid #ccc;
3517 border-radius: 4px;
3518 }
3519 .input-group-addon.input-sm {
3520 padding: 5px 10px;
3521 font-size: 12px;
3522 border-radius: 3px;
3523 }
3524 .input-group-addon.input-lg {
3525 padding: 10px 16px;
3526 font-size: 18px;
3527 border-radius: 6px;
3528 }
3529 .input-group-addon input[type="radio"],
3530 .input-group-addon input[type="checkbox"] {
3531 margin-top: 0;
3532 }
3533 .input-group .form-control:first-child,
3534 .input-group-addon:first-child,
3535 .input-group-btn:first-child > .btn,
3536 .input-group-btn:first-child > .btn-group > .btn,
3537 .input-group-btn:first-child > .dropdown-toggle,
3538 .input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle),
3539 .input-group-btn:last-child > .btn-group:not(:last-child) > .btn {
3540 border-top-right-radius: 0;
3541 border-bottom-right-radius: 0;
3542 }
3543 .input-group-addon:first-child {
3544 border-right: 0;
3545 }
3546 .input-group .form-control:last-child,
3547 .input-group-addon:last-child,
3548 .input-group-btn:last-child > .btn,
3549 .input-group-btn:last-child > .btn-group > .btn,
3550 .input-group-btn:last-child > .dropdown-toggle,
3551 .input-group-btn:first-child > .btn:not(:first-child),
3552 .input-group-btn:first-child > .btn-group:not(:first-child) > .btn {
3553 border-top-left-radius: 0;
3554 border-bottom-left-radius: 0;
3555 }
3556 .input-group-addon:last-child {
3557 border-left: 0;
3558 }
3559 .input-group-btn {
3560 position: relative;
3561 font-size: 0;
3562 white-space: nowrap;
3563 }
3564 .input-group-btn > .btn {
3565 position: relative;
3566 }
3567 .input-group-btn > .btn + .btn {
3568 margin-left: -1px;
3569 }
3570 .input-group-btn > .btn:hover,
3571 .input-group-btn > .btn:focus,
3572 .input-group-btn > .btn:active {
3573 z-index: 2;
3574 }
3575 .input-group-btn:first-child > .btn,
3576 .input-group-btn:first-child > .btn-group {
3577 margin-right: -1px;
3578 }
3579 .input-group-btn:last-child > .btn,
3580 .input-group-btn:last-child > .btn-group {
3581 margin-left: -1px;
3582 }
3583 .nav {
3584 padding-left: 0;
3585 margin-bottom: 0;
3586 list-style: none;
3587 }
3588 .nav > li {
3589 position: relative;
3590 display: block;
3591 }
3592 .nav > li > a {
3593 position: relative;
3594 display: block;
3595 padding: 10px 15px;
3596 }
3597 .nav > li > a:hover,
3598 .nav > li > a:focus {
3599 text-decoration: none;
3600 background-color: #eee;
3601 }
3602 .nav > li.disabled > a {
3603 color: #777;
3604 }
3605 .nav > li.disabled > a:hover,
3606 .nav > li.disabled > a:focus {
3607 color: #777;
3608 text-decoration: none;
3609 cursor: not-allowed;
3610 background-color: transparent;
3611 }
3612 .nav .open > a,
3613 .nav .open > a:hover,
3614 .nav .open > a:focus {
3615 background-color: #eee;
3616 border-color: #428bca;
3617 }
3618 .nav .nav-divider {
3619 height: 1px;
3620 margin: 9px 0;
3621 overflow: hidden;
3622 background-color: #e5e5e5;
3623 }
3624 .nav > li > a > img {
3625 max-width: none;
3626 }
3627 .nav-tabs {
3628 border-bottom: 1px solid #ddd;
3629 }
3630 .nav-tabs > li {
3631 float: left;
3632 margin-bottom: -1px;
3633 }
3634 .nav-tabs > li > a {
3635 margin-right: 2px;
3636 line-height: 1.42857143;
3637 border: 1px solid transparent;
3638 border-radius: 4px 4px 0 0;
3639 }
3640 .nav-tabs > li > a:hover {
3641 border-color: #eee #eee #ddd;
3642 }
3643 .nav-tabs > li.active > a,
3644 .nav-tabs > li.active > a:hover,
3645 .nav-tabs > li.active > a:focus {
3646 color: #555;
3647 cursor: default;
3648 background-color: #fff;
3649 border: 1px solid #ddd;
3650 border-bottom-color: transparent;
3651 }
3652 .nav-tabs.nav-justified {
3653 width: 100%;
3654 border-bottom: 0;
3655 }
3656 .nav-tabs.nav-justified > li {
3657 float: none;
3658 }
3659 .nav-tabs.nav-justified > li > a {
3660 margin-bottom: 5px;
3661 text-align: center;
3662 }
3663 .nav-tabs.nav-justified > .dropdown .dropdown-menu {
3664 top: auto;
3665 left: auto;
3666 }
3667 @media (min-width: 768px) {
3668 .nav-tabs.nav-justified > li {
3669 display: table-cell;
3670 width: 1%;
3671 }
3672 .nav-tabs.nav-justified > li > a {
3673 margin-bottom: 0;
3674 }
3675 }
3676 .nav-tabs.nav-justified > li > a {
3677 margin-right: 0;
3678 border-radius: 4px;
3679 }
3680 .nav-tabs.nav-justified > .active > a,
3681 .nav-tabs.nav-justified > .active > a:hover,
3682 .nav-tabs.nav-justified > .active > a:focus {
3683 border: 1px solid #ddd;
3684 }
3685 @media (min-width: 768px) {
3686 .nav-tabs.nav-justified > li > a {
3687 border-bottom: 1px solid #ddd;
3688 border-radius: 4px 4px 0 0;
3689 }
3690 .nav-tabs.nav-justified > .active > a,
3691 .nav-tabs.nav-justified > .active > a:hover,
3692 .nav-tabs.nav-justified > .active > a:focus {
3693 border-bottom-color: #fff;
3694 }
3695 }
3696 .nav-pills > li {
3697 float: left;
3698 }
3699 .nav-pills > li > a {
3700 border-radius: 4px;
3701 }
3702 .nav-pills > li + li {
3703 margin-left: 2px;
3704 }
3705 .nav-pills > li.active > a,
3706 .nav-pills > li.active > a:hover,
3707 .nav-pills > li.active > a:focus {
3708 color: #fff;
3709 background-color: #428bca;
3710 }
3711 .nav-stacked > li {
3712 float: none;
3713 }
3714 .nav-stacked > li + li {
3715 margin-top: 2px;
3716 margin-left: 0;
3717 }
3718 .nav-justified {
3719 width: 100%;
3720 }
3721 .nav-justified > li {
3722 float: none;
3723 }
3724 .nav-justified > li > a {
3725 margin-bottom: 5px;
3726 text-align: center;
3727 }
3728 .nav-justified > .dropdown .dropdown-menu {
3729 top: auto;
3730 left: auto;
3731 }
3732 @media (min-width: 768px) {
3733 .nav-justified > li {
3734 display: table-cell;
3735 width: 1%;
3736 }
3737 .nav-justified > li > a {
3738 margin-bottom: 0;
3739 }
3740 }
3741 .nav-tabs-justified {
3742 border-bottom: 0;
3743 }
3744 .nav-tabs-justified > li > a {
3745 margin-right: 0;
3746 border-radius: 4px;
3747 }
3748 .nav-tabs-justified > .active > a,
3749 .nav-tabs-justified > .active > a:hover,
3750 .nav-tabs-justified > .active > a:focus {
3751 border: 1px solid #ddd;
3752 }
3753 @media (min-width: 768px) {
3754 .nav-tabs-justified > li > a {
3755 border-bottom: 1px solid #ddd;
3756 border-radius: 4px 4px 0 0;
3757 }
3758 .nav-tabs-justified > .active > a,
3759 .nav-tabs-justified > .active > a:hover,
3760 .nav-tabs-justified > .active > a:focus {
3761 border-bottom-color: #fff;
3762 }
3763 }
3764 .tab-content > .tab-pane {
3765 display: none;
3766 }
3767 .tab-content > .active {
3768 display: block;
3769 }
3770 .nav-tabs .dropdown-menu {
3771 margin-top: -1px;
3772 border-top-left-radius: 0;
3773 border-top-right-radius: 0;
3774 }
3775 .navbar {
3776 position: relative;
3777 min-height: 50px;
3778 margin-bottom: 20px;
3779 border: 1px solid transparent;
3780 }
3781 @media (min-width: 768px) {
3782 .navbar {
3783 border-radius: 4px;
3784 }
3785 }
3786 @media (min-width: 768px) {
3787 .navbar-header {
3788 float: left;
3789 }
3790 }
3791 .navbar-collapse {
3792 padding-right: 15px;
3793 padding-left: 15px;
3794 overflow-x: visible;
3795 -webkit-overflow-scrolling: touch;
3796 border-top: 1px solid transparent;
3797 -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
3798 box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
3799 }
3800 .navbar-collapse.in {
3801 overflow-y: auto;
3802 }
3803 @media (min-width: 768px) {
3804 .navbar-collapse {
3805 width: auto;
3806 border-top: 0;
3807 -webkit-box-shadow: none;
3808 box-shadow: none;
3809 }
3810 .navbar-collapse.collapse {
3811 display: block !important;
3812 height: auto !important;
3813 padding-bottom: 0;
3814 overflow: visible !important;
3815 }
3816 .navbar-collapse.in {
3817 overflow-y: visible;
3818 }
3819 .navbar-fixed-top .navbar-collapse,
3820 .navbar-static-top .navbar-collapse,
3821 .navbar-fixed-bottom .navbar-collapse {
3822 padding-right: 0;
3823 padding-left: 0;
3824 }
3825 }
3826 .navbar-fixed-top .navbar-collapse,
3827 .navbar-fixed-bottom .navbar-collapse {
3828 max-height: 340px;
3829 }
3830 @media (max-width: 480px) and (orientation: landscape) {
3831 .navbar-fixed-top .navbar-collapse,
3832 .navbar-fixed-bottom .navbar-collapse {
3833 max-height: 200px;
3834 }
3835 }
3836 .container > .navbar-header,
3837 .container-fluid > .navbar-header,
3838 .container > .navbar-collapse,
3839 .container-fluid > .navbar-collapse {
3840 margin-right: -15px;
3841 margin-left: -15px;
3842 }
3843 @media (min-width: 768px) {
3844 .container > .navbar-header,
3845 .container-fluid > .navbar-header,
3846 .container > .navbar-collapse,
3847 .container-fluid > .navbar-collapse {
3848 margin-right: 0;
3849 margin-left: 0;
3850 }
3851 }
3852 .navbar-static-top {
3853 z-index: 1000;
3854 border-width: 0 0 1px;
3855 }
3856 @media (min-width: 768px) {
3857 .navbar-static-top {
3858 border-radius: 0;
3859 }
3860 }
3861 .navbar-fixed-top,
3862 .navbar-fixed-bottom {
3863 position: fixed;
3864 right: 0;
3865 left: 0;
3866 z-index: 1030;
3867 -webkit-transform: translate3d(0, 0, 0);
3868 -o-transform: translate3d(0, 0, 0);
3869 transform: translate3d(0, 0, 0);
3870 }
3871 @media (min-width: 768px) {
3872 .navbar-fixed-top,
3873 .navbar-fixed-bottom {
3874 border-radius: 0;
3875 }
3876 }
3877 .navbar-fixed-top {
3878 top: 0;
3879 border-width: 0 0 1px;
3880 }
3881 .navbar-fixed-bottom {
3882 bottom: 0;
3883 margin-bottom: 0;
3884 border-width: 1px 0 0;
3885 }
3886 .navbar-brand {
3887 float: left;
3888 height: 50px;
3889 padding: 15px 15px;
3890 font-size: 18px;
3891 line-height: 20px;
3892 }
3893 .navbar-brand:hover,
3894 .navbar-brand:focus {
3895 text-decoration: none;
3896 }
3897 @media (min-width: 768px) {
3898 .navbar > .container .navbar-brand,
3899 .navbar > .container-fluid .navbar-brand {
3900 margin-left: -15px;
3901 }
3902 }
3903 .navbar-toggle {
3904 position: relative;
3905 float: right;
3906 padding: 9px 10px;
3907 margin-top: 8px;
3908 margin-right: 15px;
3909 margin-bottom: 8px;
3910 background-color: transparent;
3911 background-image: none;
3912 border: 1px solid transparent;
3913 border-radius: 4px;
3914 }
3915 .navbar-toggle:focus {
3916 outline: 0;
3917 }
3918 .navbar-toggle .icon-bar {
3919 display: block;
3920 width: 22px;
3921 height: 2px;
3922 border-radius: 1px;
3923 }
3924 .navbar-toggle .icon-bar + .icon-bar {
3925 margin-top: 4px;
3926 }
3927 @media (min-width: 768px) {
3928 .navbar-toggle {
3929 display: none;
3930 }
3931 }
3932 .navbar-nav {
3933 margin: 7.5px -15px;
3934 }
3935 .navbar-nav > li > a {
3936 padding-top: 10px;
3937 padding-bottom: 10px;
3938 line-height: 20px;
3939 }
3940 @media (max-width: 767px) {
3941 .navbar-nav .open .dropdown-menu {
3942 position: static;
3943 float: none;
3944 width: auto;
3945 margin-top: 0;
3946 background-color: transparent;
3947 border: 0;
3948 -webkit-box-shadow: none;
3949 box-shadow: none;
3950 }
3951 .navbar-nav .open .dropdown-menu > li > a,
3952 .navbar-nav .open .dropdown-menu .dropdown-header {
3953 padding: 5px 15px 5px 25px;
3954 }
3955 .navbar-nav .open .dropdown-menu > li > a {
3956 line-height: 20px;
3957 }
3958 .navbar-nav .open .dropdown-menu > li > a:hover,
3959 .navbar-nav .open .dropdown-menu > li > a:focus {
3960 background-image: none;
3961 }
3962 }
3963 @media (min-width: 768px) {
3964 .navbar-nav {
3965 float: left;
3966 margin: 0;
3967 }
3968 .navbar-nav > li {
3969 float: left;
3970 }
3971 .navbar-nav > li > a {
3972 padding-top: 15px;
3973 padding-bottom: 15px;
3974 }
3975 .navbar-nav.navbar-right:last-child {
3976 margin-right: -15px;
3977 }
3978 }
3979 @media (min-width: 768px) {
3980 .navbar-left {
3981 float: left !important;
3982 }
3983 .navbar-right {
3984 float: right !important;
3985 }
3986 }
3987 .navbar-form {
3988 padding: 10px 15px;
3989 margin-top: 8px;
3990 margin-right: -15px;
3991 margin-bottom: 8px;
3992 margin-left: -15px;
3993 border-top: 1px solid transparent;
3994 border-bottom: 1px solid transparent;
3995 -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 1px 0 rgba(255, 255, 255, .1);
3996 box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 1px 0 rgba(255, 255, 255, .1);
3997 }
3998 @media (min-width: 768px) {
3999 .navbar-form .form-group {
4000 display: inline-block;
4001 margin-bottom: 0;
4002 vertical-align: middle;
4003 }
4004 .navbar-form .form-control {
4005 display: inline-block;
4006 width: auto;
4007 vertical-align: middle;
4008 }
4009 .navbar-form .input-group {
4010 display: inline-table;
4011 vertical-align: middle;
4012 }
4013 .navbar-form .input-group .input-group-addon,
4014 .navbar-form .input-group .input-group-btn,
4015 .navbar-form .input-group .form-control {
4016 width: auto;
4017 }
4018 .navbar-form .input-group > .form-control {
4019 width: 100%;
4020 }
4021 .navbar-form .control-label {
4022 margin-bottom: 0;
4023 vertical-align: middle;
4024 }
4025 .navbar-form .radio,
4026 .navbar-form .checkbox {
4027 display: inline-block;
4028 margin-top: 0;
4029 margin-bottom: 0;
4030 vertical-align: middle;
4031 }
4032 .navbar-form .radio label,
4033 .navbar-form .checkbox label {
4034 padding-left: 0;
4035 }
4036 .navbar-form .radio input[type="radio"],
4037 .navbar-form .checkbox input[type="checkbox"] {
4038 position: relative;
4039 margin-left: 0;
4040 }
4041 .navbar-form .has-feedback .form-control-feedback {
4042 top: 0;
4043 }
4044 }
4045 @media (max-width: 767px) {
4046 .navbar-form .form-group {
4047 margin-bottom: 5px;
4048 }
4049 }
4050 @media (min-width: 768px) {
4051 .navbar-form {
4052 width: auto;
4053 padding-top: 0;
4054 padding-bottom: 0;
4055 margin-right: 0;
4056 margin-left: 0;
4057 border: 0;
4058 -webkit-box-shadow: none;
4059 box-shadow: none;
4060 }
4061 .navbar-form.navbar-right:last-child {
4062 margin-right: -15px;
4063 }
4064 }
4065 .navbar-nav > li > .dropdown-menu {
4066 margin-top: 0;
4067 border-top-left-radius: 0;
4068 border-top-right-radius: 0;
4069 }
4070 .navbar-fixed-bottom .navbar-nav > li > .dropdown-menu {
4071 border-bottom-right-radius: 0;
4072 border-bottom-left-radius: 0;
4073 }
4074 .navbar-btn {
4075 margin-top: 8px;
4076 margin-bottom: 8px;
4077 }
4078 .navbar-btn.btn-sm {
4079 margin-top: 10px;
4080 margin-bottom: 10px;
4081 }
4082 .navbar-btn.btn-xs {
4083 margin-top: 14px;
4084 margin-bottom: 14px;
4085 }
4086 .navbar-text {
4087 margin-top: 15px;
4088 margin-bottom: 15px;
4089 }
4090 @media (min-width: 768px) {
4091 .navbar-text {
4092 float: left;
4093 margin-right: 15px;
4094 margin-left: 15px;
4095 }
4096 .navbar-text.navbar-right:last-child {
4097 margin-right: 0;
4098 }
4099 }
4100 .navbar-default {
4101 background-color: #f8f8f8;
4102 border-color: #e7e7e7;
4103 }
4104 .navbar-default .navbar-brand {
4105 color: #777;
4106 }
4107 .navbar-default .navbar-brand:hover,
4108 .navbar-default .navbar-brand:focus {
4109 color: #5e5e5e;
4110 background-color: transparent;
4111 }
4112 .navbar-default .navbar-text {
4113 color: #777;
4114 }
4115 .navbar-default .navbar-nav > li > a {
4116 color: #777;
4117 }
4118 .navbar-default .navbar-nav > li > a:hover,
4119 .navbar-default .navbar-nav > li > a:focus {
4120 color: #333;
4121 background-color: transparent;
4122 }
4123 .navbar-default .navbar-nav > .active > a,
4124 .navbar-default .navbar-nav > .active > a:hover,
4125 .navbar-default .navbar-nav > .active > a:focus {
4126 color: #555;
4127 background-color: #e7e7e7;
4128 }
4129 .navbar-default .navbar-nav > .disabled > a,
4130 .navbar-default .navbar-nav > .disabled > a:hover,
4131 .navbar-default .navbar-nav > .disabled > a:focus {
4132 color: #ccc;
4133 background-color: transparent;
4134 }
4135 .navbar-default .navbar-toggle {
4136 border-color: #ddd;
4137 }
4138 .navbar-default .navbar-toggle:hover,
4139 .navbar-default .navbar-toggle:focus {
4140 background-color: #ddd;
4141 }
4142 .navbar-default .navbar-toggle .icon-bar {
4143 background-color: #888;
4144 }
4145 .navbar-default .navbar-collapse,
4146 .navbar-default .navbar-form {
4147 border-color: #e7e7e7;
4148 }
4149 .navbar-default .navbar-nav > .open > a,
4150 .navbar-default .navbar-nav > .open > a:hover,
4151 .navbar-default .navbar-nav > .open > a:focus {
4152 color: #555;
4153 background-color: #e7e7e7;
4154 }
4155 @media (max-width: 767px) {
4156 .navbar-default .navbar-nav .open .dropdown-menu > li > a {
4157 color: #777;
4158 }
4159 .navbar-default .navbar-nav .open .dropdown-menu > li > a:hover,
4160 .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus {
4161 color: #333;
4162 background-color: transparent;
4163 }
4164 .navbar-default .navbar-nav .open .dropdown-menu > .active > a,
4165 .navbar-default .navbar-nav .open .dropdown-menu > .active > a:hover,
4166 .navbar-default .navbar-nav .open .dropdown-menu > .active > a:focus {
4167 color: #555;
4168 background-color: #e7e7e7;
4169 }
4170 .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a,
4171 .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:hover,
4172 .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:focus {
4173 color: #ccc;
4174 background-color: transparent;
4175 }
4176 }
4177 .navbar-default .navbar-link {
4178 color: #777;
4179 }
4180 .navbar-default .navbar-link:hover {
4181 color: #333;
4182 }
4183 .navbar-default .btn-link {
4184 color: #777;
4185 }
4186 .navbar-default .btn-link:hover,
4187 .navbar-default .btn-link:focus {
4188 color: #333;
4189 }
4190 .navbar-default .btn-link[disabled]:hover,
4191 fieldset[disabled] .navbar-default .btn-link:hover,
4192 .navbar-default .btn-link[disabled]:focus,
4193 fieldset[disabled] .navbar-default .btn-link:focus {
4194 color: #ccc;
4195 }
4196 .navbar-inverse {
4197 background-color: #222;
4198 border-color: #080808;
4199 }
4200 .navbar-inverse .navbar-brand {
4201 color: #777;
4202 }
4203 .navbar-inverse .navbar-brand:hover,
4204 .navbar-inverse .navbar-brand:focus {
4205 color: #fff;
4206 background-color: transparent;
4207 }
4208 .navbar-inverse .navbar-text {
4209 color: #777;
4210 }
4211 .navbar-inverse .navbar-nav > li > a {
4212 color: #777;
4213 }
4214 .navbar-inverse .navbar-nav > li > a:hover,
4215 .navbar-inverse .navbar-nav > li > a:focus {
4216 color: #fff;
4217 background-color: transparent;
4218 }
4219 .navbar-inverse .navbar-nav > .active > a,
4220 .navbar-inverse .navbar-nav > .active > a:hover,
4221 .navbar-inverse .navbar-nav > .active > a:focus {
4222 color: #fff;
4223 background-color: #080808;
4224 }
4225 .navbar-inverse .navbar-nav > .disabled > a,
4226 .navbar-inverse .navbar-nav > .disabled > a:hover,
4227 .navbar-inverse .navbar-nav > .disabled > a:focus {
4228 color: #444;
4229 background-color: transparent;
4230 }
4231 .navbar-inverse .navbar-toggle {
4232 border-color: #333;
4233 }
4234 .navbar-inverse .navbar-toggle:hover,
4235 .navbar-inverse .navbar-toggle:focus {
4236 background-color: #333;
4237 }
4238 .navbar-inverse .navbar-toggle .icon-bar {
4239 background-color: #fff;
4240 }
4241 .navbar-inverse .navbar-collapse,
4242 .navbar-inverse .navbar-form {
4243 border-color: #101010;
4244 }
4245 .navbar-inverse .navbar-nav > .open > a,
4246 .navbar-inverse .navbar-nav > .open > a:hover,
4247 .navbar-inverse .navbar-nav > .open > a:focus {
4248 color: #fff;
4249 background-color: #080808;
4250 }
4251 @media (max-width: 767px) {
4252 .navbar-inverse .navbar-nav .open .dropdown-menu > .dropdown-header {
4253 border-color: #080808;
4254 }
4255 .navbar-inverse .navbar-nav .open .dropdown-menu .divider {
4256 background-color: #080808;
4257 }
4258 .navbar-inverse .navbar-nav .open .dropdown-menu > li > a {
4259 color: #777;
4260 }
4261 .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover,
4262 .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus {
4263 color: #fff;
4264 background-color: transparent;
4265 }
4266 .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a,
4267 .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover,
4268 .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus {
4269 color: #fff;
4270 background-color: #080808;
4271 }
4272 .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a,
4273 .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:hover,
4274 .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:focus {
4275 color: #444;
4276 background-color: transparent;
4277 }
4278 }
4279 .navbar-inverse .navbar-link {
4280 color: #777;
4281 }
4282 .navbar-inverse .navbar-link:hover {
4283 color: #fff;
4284 }
4285 .navbar-inverse .btn-link {
4286 color: #777;
4287 }
4288 .navbar-inverse .btn-link:hover,
4289 .navbar-inverse .btn-link:focus {
4290 color: #fff;
4291 }
4292 .navbar-inverse .btn-link[disabled]:hover,
4293 fieldset[disabled] .navbar-inverse .btn-link:hover,
4294 .navbar-inverse .btn-link[disabled]:focus,
4295 fieldset[disabled] .navbar-inverse .btn-link:focus {
4296 color: #444;
4297 }
4298 .breadcrumb {
4299 padding: 8px 15px;
4300 margin-bottom: 20px;
4301 list-style: none;
4302 background-color: #f5f5f5;
4303 border-radius: 4px;
4304 }
4305 .breadcrumb > li {
4306 display: inline-block;
4307 }
4308 .breadcrumb > li + li:before {
4309 padding: 0 5px;
4310 color: #ccc;
4311 content: "/\00a0";
4312 }
4313 .breadcrumb > .active {
4314 color: #777;
4315 }
4316 .pagination {
4317 display: inline-block;
4318 padding-left: 0;
4319 margin: 20px 0;
4320 border-radius: 4px;
4321 }
4322 .pagination > li {
4323 display: inline;
4324 }
4325 .pagination > li > a,
4326 .pagination > li > span {
4327 position: relative;
4328 float: left;
4329 padding: 6px 12px;
4330 margin-left: -1px;
4331 line-height: 1.42857143;
4332 color: #428bca;
4333 text-decoration: none;
4334 background-color: #fff;
4335 border: 1px solid #ddd;
4336 }
4337 .pagination > li:first-child > a,
4338 .pagination > li:first-child > span {
4339 margin-left: 0;
4340 border-top-left-radius: 4px;
4341 border-bottom-left-radius: 4px;
4342 }
4343 .pagination > li:last-child > a,
4344 .pagination > li:last-child > span {
4345 border-top-right-radius: 4px;
4346 border-bottom-right-radius: 4px;
4347 }
4348 .pagination > li > a:hover,
4349 .pagination > li > span:hover,
4350 .pagination > li > a:focus,
4351 .pagination > li > span:focus {
4352 color: #2a6496;
4353 background-color: #eee;
4354 border-color: #ddd;
4355 }
4356 .pagination > .active > a,
4357 .pagination > .active > span,
4358 .pagination > .active > a:hover,
4359 .pagination > .active > span:hover,
4360 .pagination > .active > a:focus,
4361 .pagination > .active > span:focus {
4362 z-index: 2;
4363 color: #fff;
4364 cursor: default;
4365 background-color: #428bca;
4366 border-color: #428bca;
4367 }
4368 .pagination > .disabled > span,
4369 .pagination > .disabled > span:hover,
4370 .pagination > .disabled > span:focus,
4371 .pagination > .disabled > a,
4372 .pagination > .disabled > a:hover,
4373 .pagination > .disabled > a:focus {
4374 color: #777;
4375 cursor: not-allowed;
4376 background-color: #fff;
4377 border-color: #ddd;
4378 }
4379 .pagination-lg > li > a,
4380 .pagination-lg > li > span {
4381 padding: 10px 16px;
4382 font-size: 18px;
4383 }
4384 .pagination-lg > li:first-child > a,
4385 .pagination-lg > li:first-child > span {
4386 border-top-left-radius: 6px;
4387 border-bottom-left-radius: 6px;
4388 }
4389 .pagination-lg > li:last-child > a,
4390 .pagination-lg > li:last-child > span {
4391 border-top-right-radius: 6px;
4392 border-bottom-right-radius: 6px;
4393 }
4394 .pagination-sm > li > a,
4395 .pagination-sm > li > span {
4396 padding: 5px 10px;
4397 font-size: 12px;
4398 }
4399 .pagination-sm > li:first-child > a,
4400 .pagination-sm > li:first-child > span {
4401 border-top-left-radius: 3px;
4402 border-bottom-left-radius: 3px;
4403 }
4404 .pagination-sm > li:last-child > a,
4405 .pagination-sm > li:last-child > span {
4406 border-top-right-radius: 3px;
4407 border-bottom-right-radius: 3px;
4408 }
4409 .pager {
4410 padding-left: 0;
4411 margin: 20px 0;
4412 text-align: center;
4413 list-style: none;
4414 }
4415 .pager li {
4416 display: inline;
4417 }
4418 .pager li > a,
4419 .pager li > span {
4420 display: inline-block;
4421 padding: 5px 14px;
4422 background-color: #fff;
4423 border: 1px solid #ddd;
4424 border-radius: 15px;
4425 }
4426 .pager li > a:hover,
4427 .pager li > a:focus {
4428 text-decoration: none;
4429 background-color: #eee;
4430 }
4431 .pager .next > a,
4432 .pager .next > span {
4433 float: right;
4434 }
4435 .pager .previous > a,
4436 .pager .previous > span {
4437 float: left;
4438 }
4439 .pager .disabled > a,
4440 .pager .disabled > a:hover,
4441 .pager .disabled > a:focus,
4442 .pager .disabled > span {
4443 color: #777;
4444 cursor: not-allowed;
4445 background-color: #fff;
4446 }
4447 .label {
4448 display: inline;
4449 padding: .2em .6em .3em;
4450 font-size: 75%;
4451 font-weight: bold;
4452 line-height: 1;
4453 color: #fff;
4454 text-align: center;
4455 white-space: nowrap;
4456 vertical-align: baseline;
4457 border-radius: .25em;
4458 }
4459 a.label:hover,
4460 a.label:focus {
4461 color: #fff;
4462 text-decoration: none;
4463 cursor: pointer;
4464 }
4465 .label:empty {
4466 display: none;
4467 }
4468 .btn .label {
4469 position: relative;
4470 top: -1px;
4471 }
4472 .label-default {
4473 background-color: #777;
4474 }
4475 .label-default[href]:hover,
4476 .label-default[href]:focus {
4477 background-color: #5e5e5e;
4478 }
4479 .label-primary {
4480 background-color: #428bca;
4481 }
4482 .label-primary[href]:hover,
4483 .label-primary[href]:focus {
4484 background-color: #3071a9;
4485 }
4486 .label-success {
4487 background-color: #5cb85c;
4488 }
4489 .label-success[href]:hover,
4490 .label-success[href]:focus {
4491 background-color: #449d44;
4492 }
4493 .label-info {
4494 background-color: #5bc0de;
4495 }
4496 .label-info[href]:hover,
4497 .label-info[href]:focus {
4498 background-color: #31b0d5;
4499 }
4500 .label-warning {
4501 background-color: #f0ad4e;
4502 }
4503 .label-warning[href]:hover,
4504 .label-warning[href]:focus {
4505 background-color: #ec971f;
4506 }
4507 .label-danger {
4508 background-color: #d9534f;
4509 }
4510 .label-danger[href]:hover,
4511 .label-danger[href]:focus {
4512 background-color: #c9302c;
4513 }
4514 .badge {
4515 display: inline-block;
4516 min-width: 10px;
4517 padding: 3px 7px;
4518 font-size: 12px;
4519 font-weight: bold;
4520 line-height: 1;
4521 color: #fff;
4522 text-align: center;
4523 white-space: nowrap;
4524 vertical-align: baseline;
4525 background-color: #777;
4526 border-radius: 10px;
4527 }
4528 .badge:empty {
4529 display: none;
4530 }
4531 .btn .badge {
4532 position: relative;
4533 top: -1px;
4534 }
4535 .btn-xs .badge {
4536 top: 0;
4537 padding: 1px 5px;
4538 }
4539 a.badge:hover,
4540 a.badge:focus {
4541 color: #fff;
4542 text-decoration: none;
4543 cursor: pointer;
4544 }
4545 a.list-group-item.active > .badge,
4546 .nav-pills > .active > a > .badge {
4547 color: #428bca;
4548 background-color: #fff;
4549 }
4550 .nav-pills > li > a > .badge {
4551 margin-left: 3px;
4552 }
4553 .jumbotron {
4554 padding: 30px;
4555 margin-bottom: 30px;
4556 color: inherit;
4557 background-color: #eee;
4558 }
4559 .jumbotron h1,
4560 .jumbotron .h1 {
4561 color: inherit;
4562 }
4563 .jumbotron p {
4564 margin-bottom: 15px;
4565 font-size: 21px;
4566 font-weight: 200;
4567 }
4568 .jumbotron > hr {
4569 border-top-color: #d5d5d5;
4570 }
4571 .container .jumbotron {
4572 border-radius: 6px;
4573 }
4574 .jumbotron .container {
4575 max-width: 100%;
4576 }
4577 @media screen and (min-width: 768px) {
4578 .jumbotron {
4579 padding-top: 48px;
4580 padding-bottom: 48px;
4581 }
4582 .container .jumbotron {
4583 padding-right: 60px;
4584 padding-left: 60px;
4585 }
4586 .jumbotron h1,
4587 .jumbotron .h1 {
4588 font-size: 63px;
4589 }
4590 }
4591 .thumbnail {
4592 display: block;
4593 padding: 4px;
4594 margin-bottom: 20px;
4595 line-height: 1.42857143;
4596 background-color: #fff;
4597 border: 1px solid #ddd;
4598 border-radius: 4px;
4599 -webkit-transition: all .2s ease-in-out;
4600 -o-transition: all .2s ease-in-out;
4601 transition: all .2s ease-in-out;
4602 }
4603 .thumbnail > img,
4604 .thumbnail a > img {
4605 margin-right: auto;
4606 margin-left: auto;
4607 }
4608 a.thumbnail:hover,
4609 a.thumbnail:focus,
4610 a.thumbnail.active {
4611 border-color: #428bca;
4612 }
4613 .thumbnail .caption {
4614 padding: 9px;
4615 color: #333;
4616 }
4617 .alert {
4618 padding: 15px;
4619 margin-bottom: 20px;
4620 border: 1px solid transparent;
4621 border-radius: 4px;
4622 }
4623 .alert h4 {
4624 margin-top: 0;
4625 color: inherit;
4626 }
4627 .alert .alert-link {
4628 font-weight: bold;
4629 }
4630 .alert > p,
4631 .alert > ul {
4632 margin-bottom: 0;
4633 }
4634 .alert > p + p {
4635 margin-top: 5px;
4636 }
4637 .alert-dismissable,
4638 .alert-dismissible {
4639 padding-right: 35px;
4640 }
4641 .alert-dismissable .close,
4642 .alert-dismissible .close {
4643 position: relative;
4644 top: -2px;
4645 right: -21px;
4646 color: inherit;
4647 }
4648 .alert-success {
4649 color: #3c763d;
4650 background-color: #dff0d8;
4651 border-color: #d6e9c6;
4652 }
4653 .alert-success hr {
4654 border-top-color: #c9e2b3;
4655 }
4656 .alert-success .alert-link {
4657 color: #2b542c;
4658 }
4659 .alert-info {
4660 color: #31708f;
4661 background-color: #d9edf7;
4662 border-color: #bce8f1;
4663 }
4664 .alert-info hr {
4665 border-top-color: #a6e1ec;
4666 }
4667 .alert-info .alert-link {
4668 color: #245269;
4669 }
4670 .alert-warning {
4671 color: #8a6d3b;
4672 background-color: #fcf8e3;
4673 border-color: #faebcc;
4674 }
4675 .alert-warning hr {
4676 border-top-color: #f7e1b5;
4677 }
4678 .alert-warning .alert-link {
4679 color: #66512c;
4680 }
4681 .alert-danger {
4682 color: #a94442;
4683 background-color: #f2dede;
4684 border-color: #ebccd1;
4685 }
4686 .alert-danger hr {
4687 border-top-color: #e4b9c0;
4688 }
4689 .alert-danger .alert-link {
4690 color: #843534;
4691 }
4692 @-webkit-keyframes progress-bar-stripes {
4693 from {
4694 background-position: 40px 0;
4695 }
4696 to {
4697 background-position: 0 0;
4698 }
4699 }
4700 @-o-keyframes progress-bar-stripes {
4701 from {
4702 background-position: 40px 0;
4703 }
4704 to {
4705 background-position: 0 0;
4706 }
4707 }
4708 @keyframes progress-bar-stripes {
4709 from {
4710 background-position: 40px 0;
4711 }
4712 to {
4713 background-position: 0 0;
4714 }
4715 }
4716 .progress {
4717 height: 20px;
4718 margin-bottom: 20px;
4719 overflow: hidden;
4720 background-color: #f5f5f5;
4721 border-radius: 4px;
4722 -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1);
4723 box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1);
4724 }
4725 .progress-bar {
4726 float: left;
4727 width: 0;
4728 height: 100%;
4729 font-size: 12px;
4730 line-height: 20px;
4731 color: #fff;
4732 text-align: center;
4733 background-color: #428bca;
4734 -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15);
4735 box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15);
4736 -webkit-transition: width .6s ease;
4737 -o-transition: width .6s ease;
4738 transition: width .6s ease;
4739 }
4740 .progress-striped .progress-bar,
4741 .progress-bar-striped {
4742 background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4743 background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4744 background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4745 -webkit-background-size: 40px 40px;
4746 background-size: 40px 40px;
4747 }
4748 .progress.active .progress-bar,
4749 .progress-bar.active {
4750 -webkit-animation: progress-bar-stripes 2s linear infinite;
4751 -o-animation: progress-bar-stripes 2s linear infinite;
4752 animation: progress-bar-stripes 2s linear infinite;
4753 }
4754 .progress-bar[aria-valuenow="1"],
4755 .progress-bar[aria-valuenow="2"] {
4756 min-width: 30px;
4757 }
4758 .progress-bar[aria-valuenow="0"] {
4759 min-width: 30px;
4760 color: #777;
4761 background-color: transparent;
4762 background-image: none;
4763 -webkit-box-shadow: none;
4764 box-shadow: none;
4765 }
4766 .progress-bar-success {
4767 background-color: #5cb85c;
4768 }
4769 .progress-striped .progress-bar-success {
4770 background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4771 background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4772 background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4773 }
4774 .progress-bar-info {
4775 background-color: #5bc0de;
4776 }
4777 .progress-striped .progress-bar-info {
4778 background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4779 background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4780 background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4781 }
4782 .progress-bar-warning {
4783 background-color: #f0ad4e;
4784 }
4785 .progress-striped .progress-bar-warning {
4786 background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4787 background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4788 background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4789 }
4790 .progress-bar-danger {
4791 background-color: #d9534f;
4792 }
4793 .progress-striped .progress-bar-danger {
4794 background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4795 background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4796 background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4797 }
4798 .media,
4799 .media-body {
4800 overflow: hidden;
4801 zoom: 1;
4802 }
4803 .media,
4804 .media .media {
4805 margin-top: 15px;
4806 }
4807 .media:first-child {
4808 margin-top: 0;
4809 }
4810 .media-object {
4811 display: block;
4812 }
4813 .media-heading {
4814 margin: 0 0 5px;
4815 }
4816 .media > .pull-left {
4817 margin-right: 10px;
4818 }
4819 .media > .pull-right {
4820 margin-left: 10px;
4821 }
4822 .media-list {
4823 padding-left: 0;
4824 list-style: none;
4825 }
4826 .list-group {
4827 padding-left: 0;
4828 margin-bottom: 20px;
4829 }
4830 .list-group-item {
4831 position: relative;
4832 display: block;
4833 padding: 10px 15px;
4834 margin-bottom: -1px;
4835 background-color: #fff;
4836 border: 1px solid #ddd;
4837 }
4838 .list-group-item:first-child {
4839 border-top-left-radius: 4px;
4840 border-top-right-radius: 4px;
4841 }
4842 .list-group-item:last-child {
4843 margin-bottom: 0;
4844 border-bottom-right-radius: 4px;
4845 border-bottom-left-radius: 4px;
4846 }
4847 .list-group-item > .badge {
4848 float: right;
4849 }
4850 .list-group-item > .badge + .badge {
4851 margin-right: 5px;
4852 }
4853 a.list-group-item {
4854 color: #555;
4855 }
4856 a.list-group-item .list-group-item-heading {
4857 color: #333;
4858 }
4859 a.list-group-item:hover,
4860 a.list-group-item:focus {
4861 color: #555;
4862 text-decoration: none;
4863 background-color: #f5f5f5;
4864 }
4865 .list-group-item.disabled,
4866 .list-group-item.disabled:hover,
4867 .list-group-item.disabled:focus {
4868 color: #777;
4869 background-color: #eee;
4870 }
4871 .list-group-item.disabled .list-group-item-heading,
4872 .list-group-item.disabled:hover .list-group-item-heading,
4873 .list-group-item.disabled:focus .list-group-item-heading {
4874 color: inherit;
4875 }
4876 .list-group-item.disabled .list-group-item-text,
4877 .list-group-item.disabled:hover .list-group-item-text,
4878 .list-group-item.disabled:focus .list-group-item-text {
4879 color: #777;
4880 }
4881 .list-group-item.active,
4882 .list-group-item.active:hover,
4883 .list-group-item.active:focus {
4884 z-index: 2;
4885 color: #fff;
4886 background-color: #428bca;
4887 border-color: #428bca;
4888 }
4889 .list-group-item.active .list-group-item-heading,
4890 .list-group-item.active:hover .list-group-item-heading,
4891 .list-group-item.active:focus .list-group-item-heading,
4892 .list-group-item.active .list-group-item-heading > small,
4893 .list-group-item.active:hover .list-group-item-heading > small,
4894 .list-group-item.active:focus .list-group-item-heading > small,
4895 .list-group-item.active .list-group-item-heading > .small,
4896 .list-group-item.active:hover .list-group-item-heading > .small,
4897 .list-group-item.active:focus .list-group-item-heading > .small {
4898 color: inherit;
4899 }
4900 .list-group-item.active .list-group-item-text,
4901 .list-group-item.active:hover .list-group-item-text,
4902 .list-group-item.active:focus .list-group-item-text {
4903 color: #e1edf7;
4904 }
4905 .list-group-item-success {
4906 color: #3c763d;
4907 background-color: #dff0d8;
4908 }
4909 a.list-group-item-success {
4910 color: #3c763d;
4911 }
4912 a.list-group-item-success .list-group-item-heading {
4913 color: inherit;
4914 }
4915 a.list-group-item-success:hover,
4916 a.list-group-item-success:focus {
4917 color: #3c763d;
4918 background-color: #d0e9c6;
4919 }
4920 a.list-group-item-success.active,
4921 a.list-group-item-success.active:hover,
4922 a.list-group-item-success.active:focus {
4923 color: #fff;
4924 background-color: #3c763d;
4925 border-color: #3c763d;
4926 }
4927 .list-group-item-info {
4928 color: #31708f;
4929 background-color: #d9edf7;
4930 }
4931 a.list-group-item-info {
4932 color: #31708f;
4933 }
4934 a.list-group-item-info .list-group-item-heading {
4935 color: inherit;
4936 }
4937 a.list-group-item-info:hover,
4938 a.list-group-item-info:focus {
4939 color: #31708f;
4940 background-color: #c4e3f3;
4941 }
4942 a.list-group-item-info.active,
4943 a.list-group-item-info.active:hover,
4944 a.list-group-item-info.active:focus {
4945 color: #fff;
4946 background-color: #31708f;
4947 border-color: #31708f;
4948 }
4949 .list-group-item-warning {
4950 color: #8a6d3b;
4951 background-color: #fcf8e3;
4952 }
4953 a.list-group-item-warning {
4954 color: #8a6d3b;
4955 }
4956 a.list-group-item-warning .list-group-item-heading {
4957 color: inherit;
4958 }
4959 a.list-group-item-warning:hover,
4960 a.list-group-item-warning:focus {
4961 color: #8a6d3b;
4962 background-color: #faf2cc;
4963 }
4964 a.list-group-item-warning.active,
4965 a.list-group-item-warning.active:hover,
4966 a.list-group-item-warning.active:focus {
4967 color: #fff;
4968 background-color: #8a6d3b;
4969 border-color: #8a6d3b;
4970 }
4971 .list-group-item-danger {
4972 color: #a94442;
4973 background-color: #f2dede;
4974 }
4975 a.list-group-item-danger {
4976 color: #a94442;
4977 }
4978 a.list-group-item-danger .list-group-item-heading {
4979 color: inherit;
4980 }
4981 a.list-group-item-danger:hover,
4982 a.list-group-item-danger:focus {
4983 color: #a94442;
4984 background-color: #ebcccc;
4985 }
4986 a.list-group-item-danger.active,
4987 a.list-group-item-danger.active:hover,
4988 a.list-group-item-danger.active:focus {
4989 color: #fff;
4990 background-color: #a94442;
4991 border-color: #a94442;
4992 }
4993 .list-group-item-heading {
4994 margin-top: 0;
4995 margin-bottom: 5px;
4996 }
4997 .list-group-item-text {
4998 margin-bottom: 0;
4999 line-height: 1.3;
5000 }
5001 .panel {
5002 margin-bottom: 20px;
5003 background-color: #fff;
5004 border: 1px solid transparent;
5005 border-radius: 4px;
5006 -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
5007 box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
5008 }
5009 .panel-body {
5010 padding: 15px;
5011 }
5012 .panel-heading {
5013 padding: 10px 15px;
5014 border-bottom: 1px solid transparent;
5015 border-top-left-radius: 3px;
5016 border-top-right-radius: 3px;
5017 }
5018 .panel-heading > .dropdown .dropdown-toggle {
5019 color: inherit;
5020 }
5021 .panel-title {
5022 margin-top: 0;
5023 margin-bottom: 0;
5024 font-size: 16px;
5025 color: inherit;
5026 }
5027 .panel-title > a {
5028 color: inherit;
5029 }
5030 .panel-footer {
5031 padding: 10px 15px;
5032 background-color: #f5f5f5;
5033 border-top: 1px solid #ddd;
5034 border-bottom-right-radius: 3px;
5035 border-bottom-left-radius: 3px;
5036 }
5037 .panel > .list-group {
5038 margin-bottom: 0;
5039 }
5040 .panel > .list-group .list-group-item {
5041 border-width: 1px 0;
5042 border-radius: 0;
5043 }
5044 .panel > .list-group:first-child .list-group-item:first-child {
5045 border-top: 0;
5046 border-top-left-radius: 3px;
5047 border-top-right-radius: 3px;
5048 }
5049 .panel > .list-group:last-child .list-group-item:last-child {
5050 border-bottom: 0;
5051 border-bottom-right-radius: 3px;
5052 border-bottom-left-radius: 3px;
5053 }
5054 .panel-heading + .list-group .list-group-item:first-child {
5055 border-top-width: 0;
5056 }
5057 .list-group + .panel-footer {
5058 border-top-width: 0;
5059 }
5060 .panel > .table,
5061 .panel > .table-responsive > .table,
5062 .panel > .panel-collapse > .table {
5063 margin-bottom: 0;
5064 }
5065 .panel > .table:first-child,
5066 .panel > .table-responsive:first-child > .table:first-child {
5067 border-top-left-radius: 3px;
5068 border-top-right-radius: 3px;
5069 }
5070 .panel > .table:first-child > thead:first-child > tr:first-child td:first-child,
5071 .panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:first-child,
5072 .panel > .table:first-child > tbody:first-child > tr:first-child td:first-child,
5073 .panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:first-child,
5074 .panel > .table:first-child > thead:first-child > tr:first-child th:first-child,
5075 .panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:first-child,
5076 .panel > .table:first-child > tbody:first-child > tr:first-child th:first-child,
5077 .panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:first-child {
5078 border-top-left-radius: 3px;
5079 }
5080 .panel > .table:first-child > thead:first-child > tr:first-child td:last-child,
5081 .panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:last-child,
5082 .panel > .table:first-child > tbody:first-child > tr:first-child td:last-child,
5083 .panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:last-child,
5084 .panel > .table:first-child > thead:first-child > tr:first-child th:last-child,
5085 .panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:last-child,
5086 .panel > .table:first-child > tbody:first-child > tr:first-child th:last-child,
5087 .panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:last-child {
5088 border-top-right-radius: 3px;
5089 }
5090 .panel > .table:last-child,
5091 .panel > .table-responsive:last-child > .table:last-child {
5092 border-bottom-right-radius: 3px;
5093 border-bottom-left-radius: 3px;
5094 }
5095 .panel > .table:last-child > tbody:last-child > tr:last-child td:first-child,
5096 .panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:first-child,
5097 .panel > .table:last-child > tfoot:last-child > tr:last-child td:first-child,
5098 .panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:first-child,
5099 .panel > .table:last-child > tbody:last-child > tr:last-child th:first-child,
5100 .panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:first-child,
5101 .panel > .table:last-child > tfoot:last-child > tr:last-child th:first-child,
5102 .panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:first-child {
5103 border-bottom-left-radius: 3px;
5104 }
5105 .panel > .table:last-child > tbody:last-child > tr:last-child td:last-child,
5106 .panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:last-child,
5107 .panel > .table:last-child > tfoot:last-child > tr:last-child td:last-child,
5108 .panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:last-child,
5109 .panel > .table:last-child > tbody:last-child > tr:last-child th:last-child,
5110 .panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:last-child,
5111 .panel > .table:last-child > tfoot:last-child > tr:last-child th:last-child,
5112 .panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:last-child {
5113 border-bottom-right-radius: 3px;
5114 }
5115 .panel > .panel-body + .table,
5116 .panel > .panel-body + .table-responsive {
5117 border-top: 1px solid #ddd;
5118 }
5119 .panel > .table > tbody:first-child > tr:first-child th,
5120 .panel > .table > tbody:first-child > tr:first-child td {
5121 border-top: 0;
5122 }
5123 .panel > .table-bordered,
5124 .panel > .table-responsive > .table-bordered {
5125 border: 0;
5126 }
5127 .panel > .table-bordered > thead > tr > th:first-child,
5128 .panel > .table-responsive > .table-bordered > thead > tr > th:first-child,
5129 .panel > .table-bordered > tbody > tr > th:first-child,
5130 .panel > .table-responsive > .table-bordered > tbody > tr > th:first-child,
5131 .panel > .table-bordered > tfoot > tr > th:first-child,
5132 .panel > .table-responsive > .table-bordered > tfoot > tr > th:first-child,
5133 .panel > .table-bordered > thead > tr > td:first-child,
5134 .panel > .table-responsive > .table-bordered > thead > tr > td:first-child,
5135 .panel > .table-bordered > tbody > tr > td:first-child,
5136 .panel > .table-responsive > .table-bordered > tbody > tr > td:first-child,
5137 .panel > .table-bordered > tfoot > tr > td:first-child,
5138 .panel > .table-responsive > .table-bordered > tfoot > tr > td:first-child {
5139 border-left: 0;
5140 }
5141 .panel > .table-bordered > thead > tr > th:last-child,
5142 .panel > .table-responsive > .table-bordered > thead > tr > th:last-child,
5143 .panel > .table-bordered > tbody > tr > th:last-child,
5144 .panel > .table-responsive > .table-bordered > tbody > tr > th:last-child,
5145 .panel > .table-bordered > tfoot > tr > th:last-child,
5146 .panel > .table-responsive > .table-bordered > tfoot > tr > th:last-child,
5147 .panel > .table-bordered > thead > tr > td:last-child,
5148 .panel > .table-responsive > .table-bordered > thead > tr > td:last-child,
5149 .panel > .table-bordered > tbody > tr > td:last-child,
5150 .panel > .table-responsive > .table-bordered > tbody > tr > td:last-child,
5151 .panel > .table-bordered > tfoot > tr > td:last-child,
5152 .panel > .table-responsive > .table-bordered > tfoot > tr > td:last-child {
5153 border-right: 0;
5154 }
5155 .panel > .table-bordered > thead > tr:first-child > td,
5156 .panel > .table-responsive > .table-bordered > thead > tr:first-child > td,
5157 .panel > .table-bordered > tbody > tr:first-child > td,
5158 .panel > .table-responsive > .table-bordered > tbody > tr:first-child > td,
5159 .panel > .table-bordered > thead > tr:first-child > th,
5160 .panel > .table-responsive > .table-bordered > thead > tr:first-child > th,
5161 .panel > .table-bordered > tbody > tr:first-child > th,
5162 .panel > .table-responsive > .table-bordered > tbody > tr:first-child > th {
5163 border-bottom: 0;
5164 }
5165 .panel > .table-bordered > tbody > tr:last-child > td,
5166 .panel > .table-responsive > .table-bordered > tbody > tr:last-child > td,
5167 .panel > .table-bordered > tfoot > tr:last-child > td,
5168 .panel > .table-responsive > .table-bordered > tfoot > tr:last-child > td,
5169 .panel > .table-bordered > tbody > tr:last-child > th,
5170 .panel > .table-responsive > .table-bordered > tbody > tr:last-child > th,
5171 .panel > .table-bordered > tfoot > tr:last-child > th,
5172 .panel > .table-responsive > .table-bordered > tfoot > tr:last-child > th {
5173 border-bottom: 0;
5174 }
5175 .panel > .table-responsive {
5176 margin-bottom: 0;
5177 border: 0;
5178 }
5179 .panel-group {
5180 margin-bottom: 20px;
5181 }
5182 .panel-group .panel {
5183 margin-bottom: 0;
5184 border-radius: 4px;
5185 }
5186 .panel-group .panel + .panel {
5187 margin-top: 5px;
5188 }
5189 .panel-group .panel-heading {
5190 border-bottom: 0;
5191 }
5192 .panel-group .panel-heading + .panel-collapse > .panel-body {
5193 border-top: 1px solid #ddd;
5194 }
5195 .panel-group .panel-footer {
5196 border-top: 0;
5197 }
5198 .panel-group .panel-footer + .panel-collapse .panel-body {
5199 border-bottom: 1px solid #ddd;
5200 }
5201 .panel-default {
5202 border-color: #ddd;
5203 }
5204 .panel-default > .panel-heading {
5205 color: #333;
5206 background-color: #f5f5f5;
5207 border-color: #ddd;
5208 }
5209 .panel-default > .panel-heading + .panel-collapse > .panel-body {
5210 border-top-color: #ddd;
5211 }
5212 .panel-default > .panel-heading .badge {
5213 color: #f5f5f5;
5214 background-color: #333;
5215 }
5216 .panel-default > .panel-footer + .panel-collapse > .panel-body {
5217 border-bottom-color: #ddd;
5218 }
5219 .panel-primary {
5220 border-color: #428bca;
5221 }
5222 .panel-primary > .panel-heading {
5223 color: #fff;
5224 background-color: #428bca;
5225 border-color: #428bca;
5226 }
5227 .panel-primary > .panel-heading + .panel-collapse > .panel-body {
5228 border-top-color: #428bca;
5229 }
5230 .panel-primary > .panel-heading .badge {
5231 color: #428bca;
5232 background-color: #fff;
5233 }
5234 .panel-primary > .panel-footer + .panel-collapse > .panel-body {
5235 border-bottom-color: #428bca;
5236 }
5237 .panel-success {
5238 border-color: #d6e9c6;
5239 }
5240 .panel-success > .panel-heading {
5241 color: #3c763d;
5242 background-color: #dff0d8;
5243 border-color: #d6e9c6;
5244 }
5245 .panel-success > .panel-heading + .panel-collapse > .panel-body {
5246 border-top-color: #d6e9c6;
5247 }
5248 .panel-success > .panel-heading .badge {
5249 color: #dff0d8;
5250 background-color: #3c763d;
5251 }
5252 .panel-success > .panel-footer + .panel-collapse > .panel-body {
5253 border-bottom-color: #d6e9c6;
5254 }
5255 .panel-info {
5256 border-color: #bce8f1;
5257 }
5258 .panel-info > .panel-heading {
5259 color: #31708f;
5260 background-color: #d9edf7;
5261 border-color: #bce8f1;
5262 }
5263 .panel-info > .panel-heading + .panel-collapse > .panel-body {
5264 border-top-color: #bce8f1;
5265 }
5266 .panel-info > .panel-heading .badge {
5267 color: #d9edf7;
5268 background-color: #31708f;
5269 }
5270 .panel-info > .panel-footer + .panel-collapse > .panel-body {
5271 border-bottom-color: #bce8f1;
5272 }
5273 .panel-warning {
5274 border-color: #faebcc;
5275 }
5276 .panel-warning > .panel-heading {
5277 color: #8a6d3b;
5278 background-color: #fcf8e3;
5279 border-color: #faebcc;
5280 }
5281 .panel-warning > .panel-heading + .panel-collapse > .panel-body {
5282 border-top-color: #faebcc;
5283 }
5284 .panel-warning > .panel-heading .badge {
5285 color: #fcf8e3;
5286 background-color: #8a6d3b;
5287 }
5288 .panel-warning > .panel-footer + .panel-collapse > .panel-body {
5289 border-bottom-color: #faebcc;
5290 }
5291 .panel-danger {
5292 border-color: #ebccd1;
5293 }
5294 .panel-danger > .panel-heading {
5295 color: #a94442;
5296 background-color: #f2dede;
5297 border-color: #ebccd1;
5298 }
5299 .panel-danger > .panel-heading + .panel-collapse > .panel-body {
5300 border-top-color: #ebccd1;
5301 }
5302 .panel-danger > .panel-heading .badge {
5303 color: #f2dede;
5304 background-color: #a94442;
5305 }
5306 .panel-danger > .panel-footer + .panel-collapse > .panel-body {
5307 border-bottom-color: #ebccd1;
5308 }
5309 .embed-responsive {
5310 position: relative;
5311 display: block;
5312 height: 0;
5313 padding: 0;
5314 overflow: hidden;
5315 }
5316 .embed-responsive .embed-responsive-item,
5317 .embed-responsive iframe,
5318 .embed-responsive embed,
5319 .embed-responsive object {
5320 position: absolute;
5321 top: 0;
5322 bottom: 0;
5323 left: 0;
5324 width: 100%;
5325 height: 100%;
5326 border: 0;
5327 }
5328 .embed-responsive.embed-responsive-16by9 {
5329 padding-bottom: 56.25%;
5330 }
5331 .embed-responsive.embed-responsive-4by3 {
5332 padding-bottom: 75%;
5333 }
5334 .well {
5335 min-height: 20px;
5336 padding: 19px;
5337 margin-bottom: 20px;
5338 background-color: #f5f5f5;
5339 border: 1px solid #e3e3e3;
5340 border-radius: 4px;
5341 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);
5342 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);
5343 }
5344 .well blockquote {
5345 border-color: #ddd;
5346 border-color: rgba(0, 0, 0, .15);
5347 }
5348 .well-lg {
5349 padding: 24px;
5350 border-radius: 6px;
5351 }
5352 .well-sm {
5353 padding: 9px;
5354 border-radius: 3px;
5355 }
5356 .close {
5357 float: right;
5358 font-size: 21px;
5359 font-weight: bold;
5360 line-height: 1;
5361 color: #000;
5362 text-shadow: 0 1px 0 #fff;
5363 filter: alpha(opacity=20);
5364 opacity: .2;
5365 }
5366 .close:hover,
5367 .close:focus {
5368 color: #000;
5369 text-decoration: none;
5370 cursor: pointer;
5371 filter: alpha(opacity=50);
5372 opacity: .5;
5373 }
5374 button.close {
5375 -webkit-appearance: none;
5376 padding: 0;
5377 cursor: pointer;
5378 background: transparent;
5379 border: 0;
5380 }
5381 .modal-open {
5382 overflow: hidden;
5383 }
5384 .modal {
5385 position: fixed;
5386 top: 0;
5387 right: 0;
5388 bottom: 0;
5389 left: 0;
5390 z-index: 1050;
5391 display: none;
5392 overflow: hidden;
5393 -webkit-overflow-scrolling: touch;
5394 outline: 0;
5395 }
5396 .modal.fade .modal-dialog {
5397 -webkit-transition: -webkit-transform .3s ease-out;
5398 -o-transition: -o-transform .3s ease-out;
5399 transition: transform .3s ease-out;
5400 -webkit-transform: translate3d(0, -25%, 0);
5401 -o-transform: translate3d(0, -25%, 0);
5402 transform: translate3d(0, -25%, 0);
5403 }
5404 .modal.in .modal-dialog {
5405 -webkit-transform: translate3d(0, 0, 0);
5406 -o-transform: translate3d(0, 0, 0);
5407 transform: translate3d(0, 0, 0);
5408 }
5409 .modal-open .modal {
5410 overflow-x: hidden;
5411 overflow-y: auto;
5412 }
5413 .modal-dialog {
5414 position: relative;
5415 width: auto;
5416 margin: 10px;
5417 }
5418 .modal-content {
5419 position: relative;
5420 background-color: #fff;
5421 -webkit-background-clip: padding-box;
5422 background-clip: padding-box;
5423 border: 1px solid #999;
5424 border: 1px solid rgba(0, 0, 0, .2);
5425 border-radius: 6px;
5426 outline: 0;
5427 -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
5428 box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
5429 }
5430 .modal-backdrop {
5431 position: fixed;
5432 top: 0;
5433 right: 0;
5434 bottom: 0;
5435 left: 0;
5436 z-index: 1040;
5437 background-color: #000;
5438 }
5439 .modal-backdrop.fade {
5440 filter: alpha(opacity=0);
5441 opacity: 0;
5442 }
5443 .modal-backdrop.in {
5444 filter: alpha(opacity=50);
5445 opacity: .5;
5446 }
5447 .modal-header {
5448 min-height: 16.42857143px;
5449 padding: 15px;
5450 border-bottom: 1px solid #e5e5e5;
5451 }
5452 .modal-header .close {
5453 margin-top: -2px;
5454 }
5455 .modal-title {
5456 margin: 0;
5457 line-height: 1.42857143;
5458 }
5459 .modal-body {
5460 position: relative;
5461 padding: 15px;
5462 }
5463 .modal-footer {
5464 padding: 15px;
5465 text-align: right;
5466 border-top: 1px solid #e5e5e5;
5467 }
5468 .modal-footer .btn + .btn {
5469 margin-bottom: 0;
5470 margin-left: 5px;
5471 }
5472 .modal-footer .btn-group .btn + .btn {
5473 margin-left: -1px;
5474 }
5475 .modal-footer .btn-block + .btn-block {
5476 margin-left: 0;
5477 }
5478 .modal-scrollbar-measure {
5479 position: absolute;
5480 top: -9999px;
5481 width: 50px;
5482 height: 50px;
5483 overflow: scroll;
5484 }
5485 @media (min-width: 768px) {
5486 .modal-dialog {
5487 width: 600px;
5488 margin: 30px auto;
5489 }
5490 .modal-content {
5491 -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, .5);
5492 box-shadow: 0 5px 15px rgba(0, 0, 0, .5);
5493 }
5494 .modal-sm {
5495 width: 300px;
5496 }
5497 }
5498 @media (min-width: 992px) {
5499 .modal-lg {
5500 width: 900px;
5501 }
5502 }
5503 .tooltip {
5504 position: absolute;
5505 z-index: 1070;
5506 display: block;
5507 font-size: 12px;
5508 line-height: 1.4;
5509 visibility: visible;
5510 filter: alpha(opacity=0);
5511 opacity: 0;
5512 }
5513 .tooltip.in {
5514 filter: alpha(opacity=90);
5515 opacity: .9;
5516 }
5517 .tooltip.top {
5518 padding: 5px 0;
5519 margin-top: -3px;
5520 }
5521 .tooltip.right {
5522 padding: 0 5px;
5523 margin-left: 3px;
5524 }
5525 .tooltip.bottom {
5526 padding: 5px 0;
5527 margin-top: 3px;
5528 }
5529 .tooltip.left {
5530 padding: 0 5px;
5531 margin-left: -3px;
5532 }
5533 .tooltip-inner {
5534 max-width: 200px;
5535 padding: 3px 8px;
5536 color: #fff;
5537 text-align: center;
5538 text-decoration: none;
5539 background-color: #000;
5540 border-radius: 4px;
5541 }
5542 .tooltip-arrow {
5543 position: absolute;
5544 width: 0;
5545 height: 0;
5546 border-color: transparent;
5547 border-style: solid;
5548 }
5549 .tooltip.top .tooltip-arrow {
5550 bottom: 0;
5551 left: 50%;
5552 margin-left: -5px;
5553 border-width: 5px 5px 0;
5554 border-top-color: #000;
5555 }
5556 .tooltip.top-left .tooltip-arrow {
5557 bottom: 0;
5558 left: 5px;
5559 border-width: 5px 5px 0;
5560 border-top-color: #000;
5561 }
5562 .tooltip.top-right .tooltip-arrow {
5563 right: 5px;
5564 bottom: 0;
5565 border-width: 5px 5px 0;
5566 border-top-color: #000;
5567 }
5568 .tooltip.right .tooltip-arrow {
5569 top: 50%;
5570 left: 0;
5571 margin-top: -5px;
5572 border-width: 5px 5px 5px 0;
5573 border-right-color: #000;
5574 }
5575 .tooltip.left .tooltip-arrow {
5576 top: 50%;
5577 right: 0;
5578 margin-top: -5px;
5579 border-width: 5px 0 5px 5px;
5580 border-left-color: #000;
5581 }
5582 .tooltip.bottom .tooltip-arrow {
5583 top: 0;
5584 left: 50%;
5585 margin-left: -5px;
5586 border-width: 0 5px 5px;
5587 border-bottom-color: #000;
5588 }
5589 .tooltip.bottom-left .tooltip-arrow {
5590 top: 0;
5591 left: 5px;
5592 border-width: 0 5px 5px;
5593 border-bottom-color: #000;
5594 }
5595 .tooltip.bottom-right .tooltip-arrow {
5596 top: 0;
5597 right: 5px;
5598 border-width: 0 5px 5px;
5599 border-bottom-color: #000;
5600 }
5601 .popover {
5602 position: absolute;
5603 top: 0;
5604 left: 0;
5605 z-index: 1060;
5606 display: none;
5607 max-width: 276px;
5608 padding: 1px;
5609 text-align: left;
5610 white-space: normal;
5611 background-color: #fff;
5612 -webkit-background-clip: padding-box;
5613 background-clip: padding-box;
5614 border: 1px solid #ccc;
5615 border: 1px solid rgba(0, 0, 0, .2);
5616 border-radius: 6px;
5617 -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
5618 box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
5619 }
5620 .popover.top {
5621 margin-top: -10px;
5622 }
5623 .popover.right {
5624 margin-left: 10px;
5625 }
5626 .popover.bottom {
5627 margin-top: 10px;
5628 }
5629 .popover.left {
5630 margin-left: -10px;
5631 }
5632 .popover-title {
5633 padding: 8px 14px;
5634 margin: 0;
5635 font-size: 14px;
5636 font-weight: normal;
5637 line-height: 18px;
5638 background-color: #f7f7f7;
5639 border-bottom: 1px solid #ebebeb;
5640 border-radius: 5px 5px 0 0;
5641 }
5642 .popover-content {
5643 padding: 9px 14px;
5644 }
5645 .popover > .arrow,
5646 .popover > .arrow:after {
5647 position: absolute;
5648 display: block;
5649 width: 0;
5650 height: 0;
5651 border-color: transparent;
5652 border-style: solid;
5653 }
5654 .popover > .arrow {
5655 border-width: 11px;
5656 }
5657 .popover > .arrow:after {
5658 content: "";
5659 border-width: 10px;
5660 }
5661 .popover.top > .arrow {
5662 bottom: -11px;
5663 left: 50%;
5664 margin-left: -11px;
5665 border-top-color: #999;
5666 border-top-color: rgba(0, 0, 0, .25);
5667 border-bottom-width: 0;
5668 }
5669 .popover.top > .arrow:after {
5670 bottom: 1px;
5671 margin-left: -10px;
5672 content: " ";
5673 border-top-color: #fff;
5674 border-bottom-width: 0;
5675 }
5676 .popover.right > .arrow {
5677 top: 50%;
5678 left: -11px;
5679 margin-top: -11px;
5680 border-right-color: #999;
5681 border-right-color: rgba(0, 0, 0, .25);
5682 border-left-width: 0;
5683 }
5684 .popover.right > .arrow:after {
5685 bottom: -10px;
5686 left: 1px;
5687 content: " ";
5688 border-right-color: #fff;
5689 border-left-width: 0;
5690 }
5691 .popover.bottom > .arrow {
5692 top: -11px;
5693 left: 50%;
5694 margin-left: -11px;
5695 border-top-width: 0;
5696 border-bottom-color: #999;
5697 border-bottom-color: rgba(0, 0, 0, .25);
5698 }
5699 .popover.bottom > .arrow:after {
5700 top: 1px;
5701 margin-left: -10px;
5702 content: " ";
5703 border-top-width: 0;
5704 border-bottom-color: #fff;
5705 }
5706 .popover.left > .arrow {
5707 top: 50%;
5708 right: -11px;
5709 margin-top: -11px;
5710 border-right-width: 0;
5711 border-left-color: #999;
5712 border-left-color: rgba(0, 0, 0, .25);
5713 }
5714 .popover.left > .arrow:after {
5715 right: 1px;
5716 bottom: -10px;
5717 content: " ";
5718 border-right-width: 0;
5719 border-left-color: #fff;
5720 }
5721 .carousel {
5722 position: relative;
5723 }
5724 .carousel-inner {
5725 position: relative;
5726 width: 100%;
5727 overflow: hidden;
5728 }
5729 .carousel-inner > .item {
5730 position: relative;
5731 display: none;
5732 -webkit-transition: .6s ease-in-out left;
5733 -o-transition: .6s ease-in-out left;
5734 transition: .6s ease-in-out left;
5735 }
5736 .carousel-inner > .item > img,
5737 .carousel-inner > .item > a > img {
5738 line-height: 1;
5739 }
5740 .carousel-inner > .active,
5741 .carousel-inner > .next,
5742 .carousel-inner > .prev {
5743 display: block;
5744 }
5745 .carousel-inner > .active {
5746 left: 0;
5747 }
5748 .carousel-inner > .next,
5749 .carousel-inner > .prev {
5750 position: absolute;
5751 top: 0;
5752 width: 100%;
5753 }
5754 .carousel-inner > .next {
5755 left: 100%;
5756 }
5757 .carousel-inner > .prev {
5758 left: -100%;
5759 }
5760 .carousel-inner > .next.left,
5761 .carousel-inner > .prev.right {
5762 left: 0;
5763 }
5764 .carousel-inner > .active.left {
5765 left: -100%;
5766 }
5767 .carousel-inner > .active.right {
5768 left: 100%;
5769 }
5770 .carousel-control {
5771 position: absolute;
5772 top: 0;
5773 bottom: 0;
5774 left: 0;
5775 width: 15%;
5776 font-size: 20px;
5777 color: #fff;
5778 text-align: center;
5779 text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
5780 filter: alpha(opacity=50);
5781 opacity: .5;
5782 }
5783 .carousel-control.left {
5784 background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%);
5785 background-image: -o-linear-gradient(left, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%);
5786 background-image: -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, .5)), to(rgba(0, 0, 0, .0001)));
5787 background-image: linear-gradient(to right, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%);
5788 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1);
5789 background-repeat: repeat-x;
5790 }
5791 .carousel-control.right {
5792 right: 0;
5793 left: auto;
5794 background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%);
5795 background-image: -o-linear-gradient(left, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%);
5796 background-image: -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, .0001)), to(rgba(0, 0, 0, .5)));
5797 background-image: linear-gradient(to right, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%);
5798 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1);
5799 background-repeat: repeat-x;
5800 }
5801 .carousel-control:hover,
5802 .carousel-control:focus {
5803 color: #fff;
5804 text-decoration: none;
5805 filter: alpha(opacity=90);
5806 outline: 0;
5807 opacity: .9;
5808 }
5809 .carousel-control .icon-prev,
5810 .carousel-control .icon-next,
5811 .carousel-control .glyphicon-chevron-left,
5812 .carousel-control .glyphicon-chevron-right {
5813 position: absolute;
5814 top: 50%;
5815 z-index: 5;
5816 display: inline-block;
5817 }
5818 .carousel-control .icon-prev,
5819 .carousel-control .glyphicon-chevron-left {
5820 left: 50%;
5821 margin-left: -10px;
5822 }
5823 .carousel-control .icon-next,
5824 .carousel-control .glyphicon-chevron-right {
5825 right: 50%;
5826 margin-right: -10px;
5827 }
5828 .carousel-control .icon-prev,
5829 .carousel-control .icon-next {
5830 width: 20px;
5831 height: 20px;
5832 margin-top: -10px;
5833 font-family: serif;
5834 }
5835 .carousel-control .icon-prev:before {
5836 content: '\2039';
5837 }
5838 .carousel-control .icon-next:before {
5839 content: '\203a';
5840 }
5841 .carousel-indicators {
5842 position: absolute;
5843 bottom: 10px;
5844 left: 50%;
5845 z-index: 15;
5846 width: 60%;
5847 padding-left: 0;
5848 margin-left: -30%;
5849 text-align: center;
5850 list-style: none;
5851 }
5852 .carousel-indicators li {
5853 display: inline-block;
5854 width: 10px;
5855 height: 10px;
5856 margin: 1px;
5857 text-indent: -999px;
5858 cursor: pointer;
5859 background-color: #000 \9;
5860 background-color: rgba(0, 0, 0, 0);
5861 border: 1px solid #fff;
5862 border-radius: 10px;
5863 }
5864 .carousel-indicators .active {
5865 width: 12px;
5866 height: 12px;
5867 margin: 0;
5868 background-color: #fff;
5869 }
5870 .carousel-caption {
5871 position: absolute;
5872 right: 15%;
5873 bottom: 20px;
5874 left: 15%;
5875 z-index: 10;
5876 padding-top: 20px;
5877 padding-bottom: 20px;
5878 color: #fff;
5879 text-align: center;
5880 text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
5881 }
5882 .carousel-caption .btn {
5883 text-shadow: none;
5884 }
5885 @media screen and (min-width: 768px) {
5886 .carousel-control .glyphicon-chevron-left,
5887 .carousel-control .glyphicon-chevron-right,
5888 .carousel-control .icon-prev,
5889 .carousel-control .icon-next {
5890 width: 30px;
5891 height: 30px;
5892 margin-top: -15px;
5893 font-size: 30px;
5894 }
5895 .carousel-control .glyphicon-chevron-left,
5896 .carousel-control .icon-prev {
5897 margin-left: -15px;
5898 }
5899 .carousel-control .glyphicon-chevron-right,
5900 .carousel-control .icon-next {
5901 margin-right: -15px;
5902 }
5903 .carousel-caption {
5904 right: 20%;
5905 left: 20%;
5906 padding-bottom: 30px;
5907 }
5908 .carousel-indicators {
5909 bottom: 20px;
5910 }
5911 }
5912 .clearfix:before,
5913 .clearfix:after,
5914 .dl-horizontal dd:before,
5915 .dl-horizontal dd:after,
5916 .container:before,
5917 .container:after,
5918 .container-fluid:before,
5919 .container-fluid:after,
5920 .row:before,
5921 .row:after,
5922 .form-horizontal .form-group:before,
5923 .form-horizontal .form-group:after,
5924 .btn-toolbar:before,
5925 .btn-toolbar:after,
5926 .btn-group-vertical > .btn-group:before,
5927 .btn-group-vertical > .btn-group:after,
5928 .nav:before,
5929 .nav:after,
5930 .navbar:before,
5931 .navbar:after,
5932 .navbar-header:before,
5933 .navbar-header:after,
5934 .navbar-collapse:before,
5935 .navbar-collapse:after,
5936 .pager:before,
5937 .pager:after,
5938 .panel-body:before,
5939 .panel-body:after,
5940 .modal-footer:before,
5941 .modal-footer:after {
5942 display: table;
5943 content: " ";
5944 }
5945 .clearfix:after,
5946 .dl-horizontal dd:after,
5947 .container:after,
5948 .container-fluid:after,
5949 .row:after,
5950 .form-horizontal .form-group:after,
5951 .btn-toolbar:after,
5952 .btn-group-vertical > .btn-group:after,
5953 .nav:after,
5954 .navbar:after,
5955 .navbar-header:after,
5956 .navbar-collapse:after,
5957 .pager:after,
5958 .panel-body:after,
5959 .modal-footer:after {
5960 clear: both;
5961 }
5962 .center-block {
5963 display: block;
5964 margin-right: auto;
5965 margin-left: auto;
5966 }
5967 .pull-right {
5968 float: right !important;
5969 }
5970 .pull-left {
5971 float: left !important;
5972 }
5973 .hide {
5974 display: none !important;
5975 }
5976 .show {
5977 display: block !important;
5978 }
5979 .invisible {
5980 visibility: hidden;
5981 }
5982 .text-hide {
5983 font: 0/0 a;
5984 color: transparent;
5985 text-shadow: none;
5986 background-color: transparent;
5987 border: 0;
5988 }
5989 .hidden {
5990 display: none !important;
5991 visibility: hidden !important;
5992 }
5993 .affix {
5994 position: fixed;
5995 -webkit-transform: translate3d(0, 0, 0);
5996 -o-transform: translate3d(0, 0, 0);
5997 transform: translate3d(0, 0, 0);
5998 }
5999 @-ms-viewport {
6000 width: device-width;
6001 }
6002 .visible-xs,
6003 .visible-sm,
6004 .visible-md,
6005 .visible-lg {
6006 display: none !important;
6007 }
6008 .visible-xs-block,
6009 .visible-xs-inline,
6010 .visible-xs-inline-block,
6011 .visible-sm-block,
6012 .visible-sm-inline,
6013 .visible-sm-inline-block,
6014 .visible-md-block,
6015 .visible-md-inline,
6016 .visible-md-inline-block,
6017 .visible-lg-block,
6018 .visible-lg-inline,
6019 .visible-lg-inline-block {
6020 display: none !important;
6021 }
6022 @media (max-width: 767px) {
6023 .visible-xs {
6024 display: block !important;
6025 }
6026 table.visible-xs {
6027 display: table;
6028 }
6029 tr.visible-xs {
6030 display: table-row !important;
6031 }
6032 th.visible-xs,
6033 td.visible-xs {
6034 display: table-cell !important;
6035 }
6036 }
6037 @media (max-width: 767px) {
6038 .visible-xs-block {
6039 display: block !important;
6040 }
6041 }
6042 @media (max-width: 767px) {
6043 .visible-xs-inline {
6044 display: inline !important;
6045 }
6046 }
6047 @media (max-width: 767px) {
6048 .visible-xs-inline-block {
6049 display: inline-block !important;
6050 }
6051 }
6052 @media (min-width: 768px) and (max-width: 991px) {
6053 .visible-sm {
6054 display: block !important;
6055 }
6056 table.visible-sm {
6057 display: table;
6058 }
6059 tr.visible-sm {
6060 display: table-row !important;
6061 }
6062 th.visible-sm,
6063 td.visible-sm {
6064 display: table-cell !important;
6065 }
6066 }
6067 @media (min-width: 768px) and (max-width: 991px) {
6068 .visible-sm-block {
6069 display: block !important;
6070 }
6071 }
6072 @media (min-width: 768px) and (max-width: 991px) {
6073 .visible-sm-inline {
6074 display: inline !important;
6075 }
6076 }
6077 @media (min-width: 768px) and (max-width: 991px) {
6078 .visible-sm-inline-block {
6079 display: inline-block !important;
6080 }
6081 }
6082 @media (min-width: 992px) and (max-width: 1199px) {
6083 .visible-md {
6084 display: block !important;
6085 }
6086 table.visible-md {
6087 display: table;
6088 }
6089 tr.visible-md {
6090 display: table-row !important;
6091 }
6092 th.visible-md,
6093 td.visible-md {
6094 display: table-cell !important;
6095 }
6096 }
6097 @media (min-width: 992px) and (max-width: 1199px) {
6098 .visible-md-block {
6099 display: block !important;
6100 }
6101 }
6102 @media (min-width: 992px) and (max-width: 1199px) {
6103 .visible-md-inline {
6104 display: inline !important;
6105 }
6106 }
6107 @media (min-width: 992px) and (max-width: 1199px) {
6108 .visible-md-inline-block {
6109 display: inline-block !important;
6110 }
6111 }
6112 @media (min-width: 1200px) {
6113 .visible-lg {
6114 display: block !important;
6115 }
6116 table.visible-lg {
6117 display: table;
6118 }
6119 tr.visible-lg {
6120 display: table-row !important;
6121 }
6122 th.visible-lg,
6123 td.visible-lg {
6124 display: table-cell !important;
6125 }
6126 }
6127 @media (min-width: 1200px) {
6128 .visible-lg-block {
6129 display: block !important;
6130 }
6131 }
6132 @media (min-width: 1200px) {
6133 .visible-lg-inline {
6134 display: inline !important;
6135 }
6136 }
6137 @media (min-width: 1200px) {
6138 .visible-lg-inline-block {
6139 display: inline-block !important;
6140 }
6141 }
6142 @media (max-width: 767px) {
6143 .hidden-xs {
6144 display: none !important;
6145 }
6146 }
6147 @media (min-width: 768px) and (max-width: 991px) {
6148 .hidden-sm {
6149 display: none !important;
6150 }
6151 }
6152 @media (min-width: 992px) and (max-width: 1199px) {
6153 .hidden-md {
6154 display: none !important;
6155 }
6156 }
6157 @media (min-width: 1200px) {
6158 .hidden-lg {
6159 display: none !important;
6160 }
6161 }
6162 .visible-print {
6163 display: none !important;
6164 }
6165 @media print {
6166 .visible-print {
6167 display: block !important;
6168 }
6169 table.visible-print {
6170 display: table;
6171 }
6172 tr.visible-print {
6173 display: table-row !important;
6174 }
6175 th.visible-print,
6176 td.visible-print {
6177 display: table-cell !important;
6178 }
6179 }
6180 .visible-print-block {
6181 display: none !important;
6182 }
6183 @media print {
6184 .visible-print-block {
6185 display: block !important;
6186 }
6187 }
6188 .visible-print-inline {
6189 display: none !important;
6190 }
6191 @media print {
6192 .visible-print-inline {
6193 display: inline !important;
6194 }
6195 }
6196 .visible-print-inline-block {
6197 display: none !important;
6198 }
6199 @media print {
6200 .visible-print-inline-block {
6201 display: inline-block !important;
6202 }
6203 }
6204 @media print {
6205 .hidden-print {
6206 display: none !important;
6207 }
6208 }
6209 /*# sourceMappingURL=bootstrap.css.map */
6210 </style>
6211 <meta content="Mnemonic code for generating deterministic keys" name="description"/>
6212 <meta content="width=device-width, initial-scale=1.0" name="viewport" />
6213 <meta content="bitcoin mnemonic converter" name="description" />
6214 <meta content="DC POS" name="author" />
6215
6216 <style>
6217 body {
6218 padding-bottom: 32px;
6219 }
6220 .form-control[readonly] {
6221 cursor: text;
6222 }
6223 .feedback-container {
6224 position: fixed;
6225 top: 0;
6226 width: 100%;
6227 text-align: center;
6228 z-index: 4;
6229 }
6230 .feedback {
6231 display: table;
6232 padding: 0.5em 1em;
6233 background-color: orange;
6234 margin: 0 auto;
6235 font-size: 2em;
6236 color: #444;
6237 border: 2px solid #555;
6238 border-top: 0;
6239 border-bottom-left-radius: 20px 20px;
6240 border-bottom-right-radius: 20px 20px;
6241 }
6242 </style>
6243 </head>
6244 <body>
6245 <div class="container">
6246
6247 <h1 class="text-center">Mnemonic Code Converter</h1>
6248 <hr>
6249 <div class="row">
6250 <div class="col-md-12">
6251 <h2>Mnemonic</h2>
6252 <form class="form-horizontal" role="form">
6253 <div class="col-sm-2"></div>
6254 <div class="col-sm-10">
6255 <p>You can enter an existing BIP39 mnemonic, or generate a new random one. Typing your own twelve words will probably not work how you expect, since the words require a particular structure (the last word is a checksum)</p>
6256 <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki" target="_blank">BIP39 spec</a></p>
6257 </div>
6258 <div class="form-group">
6259 <label for="network-phrase" class="col-sm-2 control-label">Coin</label>
6260 <div class="col-sm-10">
6261 <select id="network-phrase" class="network form-control">
6262 <option value="bitcoin">Bitcoin</option>
6263 <option value="bitcoin-testnet">Bitcoin Testnet</option>
6264 <option value="litecoin">Litecoin</option>
6265 <option value="dogecoin">Dogecoin</option>
6266 </select>
6267 </div>
6268 </div>
6269 <div class="form-group">
6270 <label for="phrase" class="col-sm-2 control-label">BIP39 Mnemonic</label>
6271 <div class="col-sm-10">
6272 <textarea id="phrase" class="phrase form-control"></textarea>
6273 </div>
6274 </div>
6275 <div class="form-group">
6276 <label for="strength" class="col-sm-2 control-label">Number of words</label>
6277 <div class="col-sm-10">
6278 <div class="input-group">
6279 <input type="number" class="strength form-control" id="strength" value="12">
6280 <span class="input-group-btn">
6281 <button class="btn generate">Generate Random Mnemonic</button>
6282 </span>
6283 </div>
6284 </div>
6285 </div>
6286 <div class="form-group">
6287 <label for="passphrase" class="col-sm-2 control-label">BIP39 Passphrase (optional)</label>
6288 <div class="col-sm-10">
6289 <textarea id="passphrase" class="passphrase form-control"></textarea>
6290 </div>
6291 </div>
6292 <div class="form-group">
6293 <label for="root-key" class="col-sm-2 control-label">BIP32 Root Key</label>
6294 <div class="col-sm-10">
6295 <textarea id="root-key" class="root-key form-control" readonly="readonly"></textarea>
6296 </div>
6297 </div>
6298 </form>
6299 </div>
6300 </div>
6301
6302 <hr>
6303
6304 <div class="row">
6305 <div class="col-md-12">
6306 <h2>Derivation Path</h2>
6307 <ul class="derivation-type nav nav-tabs" role="tablist">
6308 <li id="bip44-tab" class="active">
6309 <a href="#bip44" role="tab" data-toggle="tab">BIP44</a>
6310 </li>
6311 <li id="bip32-tab">
6312 <a href="#bip32" role="tab" data-toggle="tab">BIP32</a>
6313 </li>
6314 </ul>
6315 <div class="derivation-type tab-content">
6316 <div id="bip44" class="tab-pane active">
6317 <form class="form-horizontal" role="form">
6318 <br>
6319 <div class="col-sm-2"></div>
6320 <div class="col-sm-10">
6321 <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">BIP44 spec</a></p>
6322 </div>
6323 <div class="form-group">
6324 <label for="network-bip44" class="col-sm-2 control-label">Coin</label>
6325 <div class="col-sm-10">
6326 <select id="network-bip44" class="network form-control">
6327 <option value="bitcoin">Bitcoin</option>
6328 <option value="bitcoin-testnet">Bitcoin Testnet</option>
6329 <option value="litecoin">Litecoin</option>
6330 </select>
6331 </div>
6332 </div>
6333 <div class="form-group">
6334 <label for="purpose" class="col-sm-2 control-label">
6335 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#purpose" target="_blank">Purpose</a>
6336 </label>
6337 <div class="col-sm-10">
6338 <input id="purpose" type="text" class="purpose form-control" value="44">
6339 </div>
6340 </div>
6341 <div class="form-group">
6342 <label for="coin" class="col-sm-2 control-label">
6343 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#registered-coin-types" target="_blank">Coin</a>
6344 </label>
6345 <div class="col-sm-10">
6346 <input id="coin" type="text" class="coin form-control" value="0">
6347 </div>
6348 </div>
6349 <div class="form-group">
6350 <label for="account" class="col-sm-2 control-label">
6351 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account" target="_blank">Account</a>
6352 </label>
6353 <div class="col-sm-10">
6354 <input id="account" type="text" class="account form-control" value="0">
6355 </div>
6356 </div>
6357 <div class="form-group">
6358 <label for="change" class="col-sm-2 control-label">
6359 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target="_blank">External / Internal</a>
6360 </label>
6361 <div class="col-sm-10">
6362 <input id="change" type="text" class="change form-control" value="0">
6363 </div>
6364 </div>
6365 <div class="form-group">
6366 <label for="bip44-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
6367 <div class="col-sm-10">
6368 <input id="bip44-path" type="text" class="path form-control" value="m/44'/0'/0'/0" readonly="readonly">
6369 </div>
6370 </div>
6371 </form>
6372 </div>
6373 <div id="bip32" class="tab-pane">
6374 <form class="form-horizontal" role="form">
6375 <br>
6376 <div class="col-sm-2"></div>
6377 <div class="col-sm-10">
6378 <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">BIP32 spec</a></p>
6379 </div>
6380 <div class="form-group">
6381 <label for="bip32-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
6382 <div class="col-sm-10">
6383 <input id="bip32-path" type="text" class="path form-control" value="m/0">
6384 </div>
6385 </div>
6386 </form>
6387 </div>
6388 </div>
6389 <form class="form-horizontal" role="form">
6390 <div class="form-group">
6391 <label for="extended-priv-key" class="col-sm-2 control-label">BIP32 Extended Key</label>
6392 <div class="col-sm-10">
6393 <textarea id="extended-priv-key" class="extended-priv-key form-control" readonly="readonly"></textarea>
6394 </div>
6395 </div>
6396 <div class="form-group">
6397 <label for="extended-pub-key" class="col-sm-2 control-label">BIP32 Extended Key (addresses only)</label>
6398 <div class="col-sm-10">
6399 <textarea id="extended-pub-key" class="extended-pub-key form-control" readonly="readonly"></textarea>
6400 </div>
6401 </div>
6402 </form>
6403 </div>
6404 </div>
6405
6406 <hr>
6407
6408 <div class="row">
6409 <div class="col-md-12">
6410 <h2>Derived Addresses</h2>
6411 <p>Note these addreses are derived from the <strong>BIP32 Extended Key</strong></p>
6412 <table class="table table-striped">
6413 <thead>
6414 <th>
6415 <div class="input-group">
6416 Index&nbsp;&nbsp;
6417 <button class="index-toggle">Toggle</button>
6418 </div>
6419 </th>
6420 <th>
6421 <div class="input-group">
6422 Address&nbsp;&nbsp;
6423 <button class="address-toggle">Toggle</button>
6424 </div>
6425 </th>
6426 <th>
6427 <div class="input-group">
6428 Private Key&nbsp;&nbsp;
6429 <button class="private-key-toggle">Toggle</button>
6430 </div>
6431 </th>
6432 </thead>
6433 <tbody class="addresses">
6434 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6435 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6436 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6437 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6438 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6439 </tbody>
6440 </table>
6441 </div>
6442 </div>
6443 <span>Show next </button>
6444 <input type="number" class="rows-to-add" value="20">
6445 <button class="more">Show</button>
6446
6447 <hr>
6448
6449 <div class="row">
6450 <div class="col-md-12">
6451 <h2>More info</h2>
6452 <h3>BIP39 <span class="small">Mnemonic code for generating deterministic keys</span></h3>
6453 <p>
6454 Read more at the
6455 <a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki">official BIP39 spec</a>
6456 </p>
6457 <h3>BIP32 <span class="small">Hierarchical Deterministic Wallets</span></h3>
6458 <p>
6459 Read more at the
6460 <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">official BIP32 spec</a>
6461 and see the demo at
6462 <a href="http://bip32.org/" target="_blank">bip32.org</a>
6463 </p>
6464 <h3>BIP44 <span class="small">Multi-Account Hierarchy for Deterministic Wallets</span></h3>
6465 <p>
6466 Read more at the
6467 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">official BIP44 spec</a>
6468 </p>
6469 <h3>Private Keys</h3>
6470 <p>
6471 Use private keys at
6472 <a href="https://brainwallet.github.io/" target="_blank">brainwallet.org</a>,
6473 but be careful - it can be easy to make mistakes if you
6474 don't know what you're doing
6475 </p>
6476 </div>
6477 </div>
6478
6479 <hr>
6480
6481 <div class="row">
6482 <div class="col-md-12">
6483
6484 <h2>Offline Usage</h2>
6485
6486 <p>
6487 You can use this tool without having to be online.
6488 </p>
6489 <p>
6490 In your browser, select file save-as, and save this page
6491 as a file.
6492 </p>
6493 <p>
6494 Double-click that file to open it in a browser
6495 on any offline computer.
6496 </p>
6497 <p>
6498 Alternatively, download it from
6499 <a href="https://github.com/dcpos/bip39">
6500 https://github.com/dcpos/bip39
6501 </a>
6502
6503 </div>
6504 </div>
6505
6506 <hr>
6507
6508 <div class="row">
6509 <div class="col-md-12">
6510
6511 <h2>This project is 100% open-source code</h2>
6512
6513 <p>
6514 <span>Get the source code at - </span>
6515 <a href="https://github.com/dcpos/bip39" target="_blank">
6516 https://github.com/dcpos/bip39
6517 </a>
6518 </p>
6519
6520 <h3>Libraries</h3>
6521
6522 <p>
6523 <span>BitcoinJS - </span>
6524 <a href="https://github.com/bitcoinjs/bitcoinjs-lib" target="_blank">
6525 https://github.com/bitcoinjs/bitcoinjs-lib
6526 </a>
6527 </p>
6528
6529 <p>
6530 <span>jsBIP39 - </span>
6531 <a href="https://github.com/iancoleman/jsbip39" target="_blank">
6532 https://github.com/iancoleman/jsbip39
6533 </a>
6534 </p>
6535
6536 <p>
6537 <span>sjcl - </span>
6538 <a href="https://github.com/bitwiseshiftleft/sjcl" target="_blank">
6539 https://github.com/bitwiseshiftleft/sjcl
6540 </a>
6541 </p>
6542
6543 <p>
6544 <span>jQuery - </span>
6545 <a href="https://jquery.com/" target="_blank">
6546 https://jquery.com/
6547 </a>
6548 </p>
6549
6550 <p>
6551 <span>Twitter Bootstrap - </span>
6552 <a href="http://getbootstrap.com/" target="_blank">
6553 http://getbootstrap.com/
6554 </a>
6555 </p>
6556
6557 </div>
6558 </div>
6559
6560 </div>
6561
6562 <div class="feedback-container">
6563 <div class="feedback">Loading...</div>
6564 </div>
6565
6566 <script type="text/template" id="address-row-template">
6567 <tr>
6568 <td class="index"><span></span></td>
6569 <td class="address"><span></span></td>
6570 <td class="privkey"><span></span></td>
6571 </tr>
6572 </script>
6573 <script>
6574 /*!
6575 * jQuery JavaScript Library v2.1.1
6576 * http://jquery.com/
6577 *
6578 * Includes Sizzle.js
6579 * http://sizzlejs.com/
6580 *
6581 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
6582 * Released under the MIT license
6583 * http://jquery.org/license
6584 *
6585 * Date: 2014-05-01T17:11Z
6586 */
6587
6588 (function( global, factory ) {
6589
6590 if ( typeof module === "object" && typeof module.exports === "object" ) {
6591 // For CommonJS and CommonJS-like environments where a proper window is present,
6592 // execute the factory and get jQuery
6593 // For environments that do not inherently posses a window with a document
6594 // (such as Node.js), expose a jQuery-making factory as module.exports
6595 // This accentuates the need for the creation of a real window
6596 // e.g. var jQuery = require("jquery")(window);
6597 // See ticket #14549 for more info
6598 module.exports = global.document ?
6599 factory( global, true ) :
6600 function( w ) {
6601 if ( !w.document ) {
6602 throw new Error( "jQuery requires a window with a document" );
6603 }
6604 return factory( w );
6605 };
6606 } else {
6607 factory( global );
6608 }
6609
6610 // Pass this if window is not defined yet
6611 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
6612
6613 // Can't do this because several apps including ASP.NET trace
6614 // the stack via arguments.caller.callee and Firefox dies if
6615 // you try to trace through "use strict" call chains. (#13335)
6616 // Support: Firefox 18+
6617 //
6618
6619 var arr = [];
6620
6621 var slice = arr.slice;
6622
6623 var concat = arr.concat;
6624
6625 var push = arr.push;
6626
6627 var indexOf = arr.indexOf;
6628
6629 var class2type = {};
6630
6631 var toString = class2type.toString;
6632
6633 var hasOwn = class2type.hasOwnProperty;
6634
6635 var support = {};
6636
6637
6638
6639 var
6640 // Use the correct document accordingly with window argument (sandbox)
6641 document = window.document,
6642
6643 version = "2.1.1",
6644
6645 // Define a local copy of jQuery
6646 jQuery = function( selector, context ) {
6647 // The jQuery object is actually just the init constructor 'enhanced'
6648 // Need init if jQuery is called (just allow error to be thrown if not included)
6649 return new jQuery.fn.init( selector, context );
6650 },
6651
6652 // Support: Android<4.1
6653 // Make sure we trim BOM and NBSP
6654 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
6655
6656 // Matches dashed string for camelizing
6657 rmsPrefix = /^-ms-/,
6658 rdashAlpha = /-([\da-z])/gi,
6659
6660 // Used by jQuery.camelCase as callback to replace()
6661 fcamelCase = function( all, letter ) {
6662 return letter.toUpperCase();
6663 };
6664
6665 jQuery.fn = jQuery.prototype = {
6666 // The current version of jQuery being used
6667 jquery: version,
6668
6669 constructor: jQuery,
6670
6671 // Start with an empty selector
6672 selector: "",
6673
6674 // The default length of a jQuery object is 0
6675 length: 0,
6676
6677 toArray: function() {
6678 return slice.call( this );
6679 },
6680
6681 // Get the Nth element in the matched element set OR
6682 // Get the whole matched element set as a clean array
6683 get: function( num ) {
6684 return num != null ?
6685
6686 // Return just the one element from the set
6687 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
6688
6689 // Return all the elements in a clean array
6690 slice.call( this );
6691 },
6692
6693 // Take an array of elements and push it onto the stack
6694 // (returning the new matched element set)
6695 pushStack: function( elems ) {
6696
6697 // Build a new jQuery matched element set
6698 var ret = jQuery.merge( this.constructor(), elems );
6699
6700 // Add the old object onto the stack (as a reference)
6701 ret.prevObject = this;
6702 ret.context = this.context;
6703
6704 // Return the newly-formed element set
6705 return ret;
6706 },
6707
6708 // Execute a callback for every element in the matched set.
6709 // (You can seed the arguments with an array of args, but this is
6710 // only used internally.)
6711 each: function( callback, args ) {
6712 return jQuery.each( this, callback, args );
6713 },
6714
6715 map: function( callback ) {
6716 return this.pushStack( jQuery.map(this, function( elem, i ) {
6717 return callback.call( elem, i, elem );
6718 }));
6719 },
6720
6721 slice: function() {
6722 return this.pushStack( slice.apply( this, arguments ) );
6723 },
6724
6725 first: function() {
6726 return this.eq( 0 );
6727 },
6728
6729 last: function() {
6730 return this.eq( -1 );
6731 },
6732
6733 eq: function( i ) {
6734 var len = this.length,
6735 j = +i + ( i < 0 ? len : 0 );
6736 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
6737 },
6738
6739 end: function() {
6740 return this.prevObject || this.constructor(null);
6741 },
6742
6743 // For internal use only.
6744 // Behaves like an Array's method, not like a jQuery method.
6745 push: push,
6746 sort: arr.sort,
6747 splice: arr.splice
6748 };
6749
6750 jQuery.extend = jQuery.fn.extend = function() {
6751 var options, name, src, copy, copyIsArray, clone,
6752 target = arguments[0] || {},
6753 i = 1,
6754 length = arguments.length,
6755 deep = false;
6756
6757 // Handle a deep copy situation
6758 if ( typeof target === "boolean" ) {
6759 deep = target;
6760
6761 // skip the boolean and the target
6762 target = arguments[ i ] || {};
6763 i++;
6764 }
6765
6766 // Handle case when target is a string or something (possible in deep copy)
6767 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
6768 target = {};
6769 }
6770
6771 // extend jQuery itself if only one argument is passed
6772 if ( i === length ) {
6773 target = this;
6774 i--;
6775 }
6776
6777 for ( ; i < length; i++ ) {
6778 // Only deal with non-null/undefined values
6779 if ( (options = arguments[ i ]) != null ) {
6780 // Extend the base object
6781 for ( name in options ) {
6782 src = target[ name ];
6783 copy = options[ name ];
6784
6785 // Prevent never-ending loop
6786 if ( target === copy ) {
6787 continue;
6788 }
6789
6790 // Recurse if we're merging plain objects or arrays
6791 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
6792 if ( copyIsArray ) {
6793 copyIsArray = false;
6794 clone = src && jQuery.isArray(src) ? src : [];
6795
6796 } else {
6797 clone = src && jQuery.isPlainObject(src) ? src : {};
6798 }
6799
6800 // Never move original objects, clone them
6801 target[ name ] = jQuery.extend( deep, clone, copy );
6802
6803 // Don't bring in undefined values
6804 } else if ( copy !== undefined ) {
6805 target[ name ] = copy;
6806 }
6807 }
6808 }
6809 }
6810
6811 // Return the modified object
6812 return target;
6813 };
6814
6815 jQuery.extend({
6816 // Unique for each copy of jQuery on the page
6817 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
6818
6819 // Assume jQuery is ready without the ready module
6820 isReady: true,
6821
6822 error: function( msg ) {
6823 throw new Error( msg );
6824 },
6825
6826 noop: function() {},
6827
6828 // See test/unit/core.js for details concerning isFunction.
6829 // Since version 1.3, DOM methods and functions like alert
6830 // aren't supported. They return false on IE (#2968).
6831 isFunction: function( obj ) {
6832 return jQuery.type(obj) === "function";
6833 },
6834
6835 isArray: Array.isArray,
6836
6837 isWindow: function( obj ) {
6838 return obj != null && obj === obj.window;
6839 },
6840
6841 isNumeric: function( obj ) {
6842 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
6843 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
6844 // subtraction forces infinities to NaN
6845 return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0;
6846 },
6847
6848 isPlainObject: function( obj ) {
6849 // Not plain objects:
6850 // - Any object or value whose internal [[Class]] property is not "[object Object]"
6851 // - DOM nodes
6852 // - window
6853 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
6854 return false;
6855 }
6856
6857 if ( obj.constructor &&
6858 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
6859 return false;
6860 }
6861
6862 // If the function hasn't returned already, we're confident that
6863 // |obj| is a plain object, created by {} or constructed with new Object
6864 return true;
6865 },
6866
6867 isEmptyObject: function( obj ) {
6868 var name;
6869 for ( name in obj ) {
6870 return false;
6871 }
6872 return true;
6873 },
6874
6875 type: function( obj ) {
6876 if ( obj == null ) {
6877 return obj + "";
6878 }
6879 // Support: Android < 4.0, iOS < 6 (functionish RegExp)
6880 return typeof obj === "object" || typeof obj === "function" ?
6881 class2type[ toString.call(obj) ] || "object" :
6882 typeof obj;
6883 },
6884
6885 // Evaluates a script in a global context
6886 globalEval: function( code ) {
6887 var script,
6888 indirect = eval;
6889
6890 code = jQuery.trim( code );
6891
6892 if ( code ) {
6893 // If the code includes a valid, prologue position
6894 // strict mode pragma, execute code by injecting a
6895 // script tag into the document.
6896 if ( code.indexOf("use strict") === 1 ) {
6897 script = document.createElement("script");
6898 script.text = code;
6899 document.head.appendChild( script ).parentNode.removeChild( script );
6900 } else {
6901 // Otherwise, avoid the DOM node creation, insertion
6902 // and removal by using an indirect global eval
6903 indirect( code );
6904 }
6905 }
6906 },
6907
6908 // Convert dashed to camelCase; used by the css and data modules
6909 // Microsoft forgot to hump their vendor prefix (#9572)
6910 camelCase: function( string ) {
6911 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
6912 },
6913
6914 nodeName: function( elem, name ) {
6915 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
6916 },
6917
6918 // args is for internal usage only
6919 each: function( obj, callback, args ) {
6920 var value,
6921 i = 0,
6922 length = obj.length,
6923 isArray = isArraylike( obj );
6924
6925 if ( args ) {
6926 if ( isArray ) {
6927 for ( ; i < length; i++ ) {
6928 value = callback.apply( obj[ i ], args );
6929
6930 if ( value === false ) {
6931 break;
6932 }
6933 }
6934 } else {
6935 for ( i in obj ) {
6936 value = callback.apply( obj[ i ], args );
6937
6938 if ( value === false ) {
6939 break;
6940 }
6941 }
6942 }
6943
6944 // A special, fast, case for the most common use of each
6945 } else {
6946 if ( isArray ) {
6947 for ( ; i < length; i++ ) {
6948 value = callback.call( obj[ i ], i, obj[ i ] );
6949
6950 if ( value === false ) {
6951 break;
6952 }
6953 }
6954 } else {
6955 for ( i in obj ) {
6956 value = callback.call( obj[ i ], i, obj[ i ] );
6957
6958 if ( value === false ) {
6959 break;
6960 }
6961 }
6962 }
6963 }
6964
6965 return obj;
6966 },
6967
6968 // Support: Android<4.1
6969 trim: function( text ) {
6970 return text == null ?
6971 "" :
6972 ( text + "" ).replace( rtrim, "" );
6973 },
6974
6975 // results is for internal usage only
6976 makeArray: function( arr, results ) {
6977 var ret = results || [];
6978
6979 if ( arr != null ) {
6980 if ( isArraylike( Object(arr) ) ) {
6981 jQuery.merge( ret,
6982 typeof arr === "string" ?
6983 [ arr ] : arr
6984 );
6985 } else {
6986 push.call( ret, arr );
6987 }
6988 }
6989
6990 return ret;
6991 },
6992
6993 inArray: function( elem, arr, i ) {
6994 return arr == null ? -1 : indexOf.call( arr, elem, i );
6995 },
6996
6997 merge: function( first, second ) {
6998 var len = +second.length,
6999 j = 0,
7000 i = first.length;
7001
7002 for ( ; j < len; j++ ) {
7003 first[ i++ ] = second[ j ];
7004 }
7005
7006 first.length = i;
7007
7008 return first;
7009 },
7010
7011 grep: function( elems, callback, invert ) {
7012 var callbackInverse,
7013 matches = [],
7014 i = 0,
7015 length = elems.length,
7016 callbackExpect = !invert;
7017
7018 // Go through the array, only saving the items
7019 // that pass the validator function
7020 for ( ; i < length; i++ ) {
7021 callbackInverse = !callback( elems[ i ], i );
7022 if ( callbackInverse !== callbackExpect ) {
7023 matches.push( elems[ i ] );
7024 }
7025 }
7026
7027 return matches;
7028 },
7029
7030 // arg is for internal usage only
7031 map: function( elems, callback, arg ) {
7032 var value,
7033 i = 0,
7034 length = elems.length,
7035 isArray = isArraylike( elems ),
7036 ret = [];
7037
7038 // Go through the array, translating each of the items to their new values
7039 if ( isArray ) {
7040 for ( ; i < length; i++ ) {
7041 value = callback( elems[ i ], i, arg );
7042
7043 if ( value != null ) {
7044 ret.push( value );
7045 }
7046 }
7047
7048 // Go through every key on the object,
7049 } else {
7050 for ( i in elems ) {
7051 value = callback( elems[ i ], i, arg );
7052
7053 if ( value != null ) {
7054 ret.push( value );
7055 }
7056 }
7057 }
7058
7059 // Flatten any nested arrays
7060 return concat.apply( [], ret );
7061 },
7062
7063 // A global GUID counter for objects
7064 guid: 1,
7065
7066 // Bind a function to a context, optionally partially applying any
7067 // arguments.
7068 proxy: function( fn, context ) {
7069 var tmp, args, proxy;
7070
7071 if ( typeof context === "string" ) {
7072 tmp = fn[ context ];
7073 context = fn;
7074 fn = tmp;
7075 }
7076
7077 // Quick check to determine if target is callable, in the spec
7078 // this throws a TypeError, but we will just return undefined.
7079 if ( !jQuery.isFunction( fn ) ) {
7080 return undefined;
7081 }
7082
7083 // Simulated bind
7084 args = slice.call( arguments, 2 );
7085 proxy = function() {
7086 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
7087 };
7088
7089 // Set the guid of unique handler to the same of original handler, so it can be removed
7090 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
7091
7092 return proxy;
7093 },
7094
7095 now: Date.now,
7096
7097 // jQuery.support is not used in Core but other projects attach their
7098 // properties to it so it needs to exist.
7099 support: support
7100 });
7101
7102 // Populate the class2type map
7103 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
7104 class2type[ "[object " + name + "]" ] = name.toLowerCase();
7105 });
7106
7107 function isArraylike( obj ) {
7108 var length = obj.length,
7109 type = jQuery.type( obj );
7110
7111 if ( type === "function" || jQuery.isWindow( obj ) ) {
7112 return false;
7113 }
7114
7115 if ( obj.nodeType === 1 && length ) {
7116 return true;
7117 }
7118
7119 return type === "array" || length === 0 ||
7120 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
7121 }
7122 var Sizzle =
7123 /*!
7124 * Sizzle CSS Selector Engine v1.10.19
7125 * http://sizzlejs.com/
7126 *
7127 * Copyright 2013 jQuery Foundation, Inc. and other contributors
7128 * Released under the MIT license
7129 * http://jquery.org/license
7130 *
7131 * Date: 2014-04-18
7132 */
7133 (function( window ) {
7134
7135 var i,
7136 support,
7137 Expr,
7138 getText,
7139 isXML,
7140 tokenize,
7141 compile,
7142 select,
7143 outermostContext,
7144 sortInput,
7145 hasDuplicate,
7146
7147 // Local document vars
7148 setDocument,
7149 document,
7150 docElem,
7151 documentIsHTML,
7152 rbuggyQSA,
7153 rbuggyMatches,
7154 matches,
7155 contains,
7156
7157 // Instance-specific data
7158 expando = "sizzle" + -(new Date()),
7159 preferredDoc = window.document,
7160 dirruns = 0,
7161 done = 0,
7162 classCache = createCache(),
7163 tokenCache = createCache(),
7164 compilerCache = createCache(),
7165 sortOrder = function( a, b ) {
7166 if ( a === b ) {
7167 hasDuplicate = true;
7168 }
7169 return 0;
7170 },
7171
7172 // General-purpose constants
7173 strundefined = typeof undefined,
7174 MAX_NEGATIVE = 1 << 31,
7175
7176 // Instance methods
7177 hasOwn = ({}).hasOwnProperty,
7178 arr = [],
7179 pop = arr.pop,
7180 push_native = arr.push,
7181 push = arr.push,
7182 slice = arr.slice,
7183 // Use a stripped-down indexOf if we can't use a native one
7184 indexOf = arr.indexOf || function( elem ) {
7185 var i = 0,
7186 len = this.length;
7187 for ( ; i < len; i++ ) {
7188 if ( this[i] === elem ) {
7189 return i;
7190 }
7191 }
7192 return -1;
7193 },
7194
7195 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
7196
7197 // Regular expressions
7198
7199 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
7200 whitespace = "[\\x20\\t\\r\\n\\f]",
7201 // http://www.w3.org/TR/css3-syntax/#characters
7202 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
7203
7204 // Loosely modeled on CSS identifier characters
7205 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
7206 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
7207 identifier = characterEncoding.replace( "w", "w#" ),
7208
7209 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
7210 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
7211 // Operator (capture 2)
7212 "*([*^$|!~]?=)" + whitespace +
7213 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
7214 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
7215 "*\\]",
7216
7217 pseudos = ":(" + characterEncoding + ")(?:\\((" +
7218 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
7219 // 1. quoted (capture 3; capture 4 or capture 5)
7220 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
7221 // 2. simple (capture 6)
7222 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
7223 // 3. anything else (capture 2)
7224 ".*" +
7225 ")\\)|)",
7226
7227 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
7228 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
7229
7230 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
7231 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
7232
7233 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
7234
7235 rpseudo = new RegExp( pseudos ),
7236 ridentifier = new RegExp( "^" + identifier + "$" ),
7237
7238 matchExpr = {
7239 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
7240 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
7241 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
7242 "ATTR": new RegExp( "^" + attributes ),
7243 "PSEUDO": new RegExp( "^" + pseudos ),
7244 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
7245 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
7246 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
7247 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
7248 // For use in libraries implementing .is()
7249 // We use this for POS matching in `select`
7250 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
7251 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
7252 },
7253
7254 rinputs = /^(?:input|select|textarea|button)$/i,
7255 rheader = /^h\d$/i,
7256
7257 rnative = /^[^{]+\{\s*\[native \w/,
7258
7259 // Easily-parseable/retrievable ID or TAG or CLASS selectors
7260 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
7261
7262 rsibling = /[+~]/,
7263 rescape = /'|\\/g,
7264
7265 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
7266 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
7267 funescape = function( _, escaped, escapedWhitespace ) {
7268 var high = "0x" + escaped - 0x10000;
7269 // NaN means non-codepoint
7270 // Support: Firefox<24
7271 // Workaround erroneous numeric interpretation of +"0x"
7272 return high !== high || escapedWhitespace ?
7273 escaped :
7274 high < 0 ?
7275 // BMP codepoint
7276 String.fromCharCode( high + 0x10000 ) :
7277 // Supplemental Plane codepoint (surrogate pair)
7278 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
7279 };
7280
7281 // Optimize for push.apply( _, NodeList )
7282 try {
7283 push.apply(
7284 (arr = slice.call( preferredDoc.childNodes )),
7285 preferredDoc.childNodes
7286 );
7287 // Support: Android<4.0
7288 // Detect silently failing push.apply
7289 arr[ preferredDoc.childNodes.length ].nodeType;
7290 } catch ( e ) {
7291 push = { apply: arr.length ?
7292
7293 // Leverage slice if possible
7294 function( target, els ) {
7295 push_native.apply( target, slice.call(els) );
7296 } :
7297
7298 // Support: IE<9
7299 // Otherwise append directly
7300 function( target, els ) {
7301 var j = target.length,
7302 i = 0;
7303 // Can't trust NodeList.length
7304 while ( (target[j++] = els[i++]) ) {}
7305 target.length = j - 1;
7306 }
7307 };
7308 }
7309
7310 function Sizzle( selector, context, results, seed ) {
7311 var match, elem, m, nodeType,
7312 // QSA vars
7313 i, groups, old, nid, newContext, newSelector;
7314
7315 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
7316 setDocument( context );
7317 }
7318
7319 context = context || document;
7320 results = results || [];
7321
7322 if ( !selector || typeof selector !== "string" ) {
7323 return results;
7324 }
7325
7326 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
7327 return [];
7328 }
7329
7330 if ( documentIsHTML && !seed ) {
7331
7332 // Shortcuts
7333 if ( (match = rquickExpr.exec( selector )) ) {
7334 // Speed-up: Sizzle("#ID")
7335 if ( (m = match[1]) ) {
7336 if ( nodeType === 9 ) {
7337 elem = context.getElementById( m );
7338 // Check parentNode to catch when Blackberry 4.6 returns
7339 // nodes that are no longer in the document (jQuery #6963)
7340 if ( elem && elem.parentNode ) {
7341 // Handle the case where IE, Opera, and Webkit return items
7342 // by name instead of ID
7343 if ( elem.id === m ) {
7344 results.push( elem );
7345 return results;
7346 }
7347 } else {
7348 return results;
7349 }
7350 } else {
7351 // Context is not a document
7352 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
7353 contains( context, elem ) && elem.id === m ) {
7354 results.push( elem );
7355 return results;
7356 }
7357 }
7358
7359 // Speed-up: Sizzle("TAG")
7360 } else if ( match[2] ) {
7361 push.apply( results, context.getElementsByTagName( selector ) );
7362 return results;
7363
7364 // Speed-up: Sizzle(".CLASS")
7365 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
7366 push.apply( results, context.getElementsByClassName( m ) );
7367 return results;
7368 }
7369 }
7370
7371 // QSA path
7372 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
7373 nid = old = expando;
7374 newContext = context;
7375 newSelector = nodeType === 9 && selector;
7376
7377 // qSA works strangely on Element-rooted queries
7378 // We can work around this by specifying an extra ID on the root
7379 // and working up from there (Thanks to Andrew Dupont for the technique)
7380 // IE 8 doesn't work on object elements
7381 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
7382 groups = tokenize( selector );
7383
7384 if ( (old = context.getAttribute("id")) ) {
7385 nid = old.replace( rescape, "\\$&" );
7386 } else {
7387 context.setAttribute( "id", nid );
7388 }
7389 nid = "[id='" + nid + "'] ";
7390
7391 i = groups.length;
7392 while ( i-- ) {
7393 groups[i] = nid + toSelector( groups[i] );
7394 }
7395 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
7396 newSelector = groups.join(",");
7397 }
7398
7399 if ( newSelector ) {
7400 try {
7401 push.apply( results,
7402 newContext.querySelectorAll( newSelector )
7403 );
7404 return results;
7405 } catch(qsaError) {
7406 } finally {
7407 if ( !old ) {
7408 context.removeAttribute("id");
7409 }
7410 }
7411 }
7412 }
7413 }
7414
7415 // All others
7416 return select( selector.replace( rtrim, "$1" ), context, results, seed );
7417 }
7418
7419 /**
7420 * Create key-value caches of limited size
7421 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
7422 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
7423 * deleting the oldest entry
7424 */
7425 function createCache() {
7426 var keys = [];
7427
7428 function cache( key, value ) {
7429 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
7430 if ( keys.push( key + " " ) > Expr.cacheLength ) {
7431 // Only keep the most recent entries
7432 delete cache[ keys.shift() ];
7433 }
7434 return (cache[ key + " " ] = value);
7435 }
7436 return cache;
7437 }
7438
7439 /**
7440 * Mark a function for special use by Sizzle
7441 * @param {Function} fn The function to mark
7442 */
7443 function markFunction( fn ) {
7444 fn[ expando ] = true;
7445 return fn;
7446 }
7447
7448 /**
7449 * Support testing using an element
7450 * @param {Function} fn Passed the created div and expects a boolean result
7451 */
7452 function assert( fn ) {
7453 var div = document.createElement("div");
7454
7455 try {
7456 return !!fn( div );
7457 } catch (e) {
7458 return false;
7459 } finally {
7460 // Remove from its parent by default
7461 if ( div.parentNode ) {
7462 div.parentNode.removeChild( div );
7463 }
7464 // release memory in IE
7465 div = null;
7466 }
7467 }
7468
7469 /**
7470 * Adds the same handler for all of the specified attrs
7471 * @param {String} attrs Pipe-separated list of attributes
7472 * @param {Function} handler The method that will be applied
7473 */
7474 function addHandle( attrs, handler ) {
7475 var arr = attrs.split("|"),
7476 i = attrs.length;
7477
7478 while ( i-- ) {
7479 Expr.attrHandle[ arr[i] ] = handler;
7480 }
7481 }
7482
7483 /**
7484 * Checks document order of two siblings
7485 * @param {Element} a
7486 * @param {Element} b
7487 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
7488 */
7489 function siblingCheck( a, b ) {
7490 var cur = b && a,
7491 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
7492 ( ~b.sourceIndex || MAX_NEGATIVE ) -
7493 ( ~a.sourceIndex || MAX_NEGATIVE );
7494
7495 // Use IE sourceIndex if available on both nodes
7496 if ( diff ) {
7497 return diff;
7498 }
7499
7500 // Check if b follows a
7501 if ( cur ) {
7502 while ( (cur = cur.nextSibling) ) {
7503 if ( cur === b ) {
7504 return -1;
7505 }
7506 }
7507 }
7508
7509 return a ? 1 : -1;
7510 }
7511
7512 /**
7513 * Returns a function to use in pseudos for input types
7514 * @param {String} type
7515 */
7516 function createInputPseudo( type ) {
7517 return function( elem ) {
7518 var name = elem.nodeName.toLowerCase();
7519 return name === "input" && elem.type === type;
7520 };
7521 }
7522
7523 /**
7524 * Returns a function to use in pseudos for buttons
7525 * @param {String} type
7526 */
7527 function createButtonPseudo( type ) {
7528 return function( elem ) {
7529 var name = elem.nodeName.toLowerCase();
7530 return (name === "input" || name === "button") && elem.type === type;
7531 };
7532 }
7533
7534 /**
7535 * Returns a function to use in pseudos for positionals
7536 * @param {Function} fn
7537 */
7538 function createPositionalPseudo( fn ) {
7539 return markFunction(function( argument ) {
7540 argument = +argument;
7541 return markFunction(function( seed, matches ) {
7542 var j,
7543 matchIndexes = fn( [], seed.length, argument ),
7544 i = matchIndexes.length;
7545
7546 // Match elements found at the specified indexes
7547 while ( i-- ) {
7548 if ( seed[ (j = matchIndexes[i]) ] ) {
7549 seed[j] = !(matches[j] = seed[j]);
7550 }
7551 }
7552 });
7553 });
7554 }
7555
7556 /**
7557 * Checks a node for validity as a Sizzle context
7558 * @param {Element|Object=} context
7559 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
7560 */
7561 function testContext( context ) {
7562 return context && typeof context.getElementsByTagName !== strundefined && context;
7563 }
7564
7565 // Expose support vars for convenience
7566 support = Sizzle.support = {};
7567
7568 /**
7569 * Detects XML nodes
7570 * @param {Element|Object} elem An element or a document
7571 * @returns {Boolean} True iff elem is a non-HTML XML node
7572 */
7573 isXML = Sizzle.isXML = function( elem ) {
7574 // documentElement is verified for cases where it doesn't yet exist
7575 // (such as loading iframes in IE - #4833)
7576 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
7577 return documentElement ? documentElement.nodeName !== "HTML" : false;
7578 };
7579
7580 /**
7581 * Sets document-related variables once based on the current document
7582 * @param {Element|Object} [doc] An element or document object to use to set the document
7583 * @returns {Object} Returns the current document
7584 */
7585 setDocument = Sizzle.setDocument = function( node ) {
7586 var hasCompare,
7587 doc = node ? node.ownerDocument || node : preferredDoc,
7588 parent = doc.defaultView;
7589
7590 // If no document and documentElement is available, return
7591 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
7592 return document;
7593 }
7594
7595 // Set our document
7596 document = doc;
7597 docElem = doc.documentElement;
7598
7599 // Support tests
7600 documentIsHTML = !isXML( doc );
7601
7602 // Support: IE>8
7603 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
7604 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
7605 // IE6-8 do not support the defaultView property so parent will be undefined
7606 if ( parent && parent !== parent.top ) {
7607 // IE11 does not have attachEvent, so all must suffer
7608 if ( parent.addEventListener ) {
7609 parent.addEventListener( "unload", function() {
7610 setDocument();
7611 }, false );
7612 } else if ( parent.attachEvent ) {
7613 parent.attachEvent( "onunload", function() {
7614 setDocument();
7615 });
7616 }
7617 }
7618
7619 /* Attributes
7620 ---------------------------------------------------------------------- */
7621
7622 // Support: IE<8
7623 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
7624 support.attributes = assert(function( div ) {
7625 div.className = "i";
7626 return !div.getAttribute("className");
7627 });
7628
7629 /* getElement(s)By*
7630 ---------------------------------------------------------------------- */
7631
7632 // Check if getElementsByTagName("*") returns only elements
7633 support.getElementsByTagName = assert(function( div ) {
7634 div.appendChild( doc.createComment("") );
7635 return !div.getElementsByTagName("*").length;
7636 });
7637
7638 // Check if getElementsByClassName can be trusted
7639 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
7640 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
7641
7642 // Support: Safari<4
7643 // Catch class over-caching
7644 div.firstChild.className = "i";
7645 // Support: Opera<10
7646 // Catch gEBCN failure to find non-leading classes
7647 return div.getElementsByClassName("i").length === 2;
7648 });
7649
7650 // Support: IE<10
7651 // Check if getElementById returns elements by name
7652 // The broken getElementById methods don't pick up programatically-set names,
7653 // so use a roundabout getElementsByName test
7654 support.getById = assert(function( div ) {
7655 docElem.appendChild( div ).id = expando;
7656 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
7657 });
7658
7659 // ID find and filter
7660 if ( support.getById ) {
7661 Expr.find["ID"] = function( id, context ) {
7662 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
7663 var m = context.getElementById( id );
7664 // Check parentNode to catch when Blackberry 4.6 returns
7665 // nodes that are no longer in the document #6963
7666 return m && m.parentNode ? [ m ] : [];
7667 }
7668 };
7669 Expr.filter["ID"] = function( id ) {
7670 var attrId = id.replace( runescape, funescape );
7671 return function( elem ) {
7672 return elem.getAttribute("id") === attrId;
7673 };
7674 };
7675 } else {
7676 // Support: IE6/7
7677 // getElementById is not reliable as a find shortcut
7678 delete Expr.find["ID"];
7679
7680 Expr.filter["ID"] = function( id ) {
7681 var attrId = id.replace( runescape, funescape );
7682 return function( elem ) {
7683 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
7684 return node && node.value === attrId;
7685 };
7686 };
7687 }
7688
7689 // Tag
7690 Expr.find["TAG"] = support.getElementsByTagName ?
7691 function( tag, context ) {
7692 if ( typeof context.getElementsByTagName !== strundefined ) {
7693 return context.getElementsByTagName( tag );
7694 }
7695 } :
7696 function( tag, context ) {
7697 var elem,
7698 tmp = [],
7699 i = 0,
7700 results = context.getElementsByTagName( tag );
7701
7702 // Filter out possible comments
7703 if ( tag === "*" ) {
7704 while ( (elem = results[i++]) ) {
7705 if ( elem.nodeType === 1 ) {
7706 tmp.push( elem );
7707 }
7708 }
7709
7710 return tmp;
7711 }
7712 return results;
7713 };
7714
7715 // Class
7716 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
7717 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
7718 return context.getElementsByClassName( className );
7719 }
7720 };
7721
7722 /* QSA/matchesSelector
7723 ---------------------------------------------------------------------- */
7724
7725 // QSA and matchesSelector support
7726
7727 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
7728 rbuggyMatches = [];
7729
7730 // qSa(:focus) reports false when true (Chrome 21)
7731 // We allow this because of a bug in IE8/9 that throws an error
7732 // whenever `document.activeElement` is accessed on an iframe
7733 // So, we allow :focus to pass through QSA all the time to avoid the IE error
7734 // See http://bugs.jquery.com/ticket/13378
7735 rbuggyQSA = [];
7736
7737 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
7738 // Build QSA regex
7739 // Regex strategy adopted from Diego Perini
7740 assert(function( div ) {
7741 // Select is set to empty string on purpose
7742 // This is to test IE's treatment of not explicitly
7743 // setting a boolean content attribute,
7744 // since its presence should be enough
7745 // http://bugs.jquery.com/ticket/12359
7746 div.innerHTML = "<select msallowclip=''><option selected=''></option></select>";
7747
7748 // Support: IE8, Opera 11-12.16
7749 // Nothing should be selected when empty strings follow ^= or $= or *=
7750 // The test attribute must be unknown in Opera but "safe" for WinRT
7751 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
7752 if ( div.querySelectorAll("[msallowclip^='']").length ) {
7753 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
7754 }
7755
7756 // Support: IE8
7757 // Boolean attributes and "value" are not treated correctly
7758 if ( !div.querySelectorAll("[selected]").length ) {
7759 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
7760 }
7761
7762 // Webkit/Opera - :checked should return selected option elements
7763 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
7764 // IE8 throws error here and will not see later tests
7765 if ( !div.querySelectorAll(":checked").length ) {
7766 rbuggyQSA.push(":checked");
7767 }
7768 });
7769
7770 assert(function( div ) {
7771 // Support: Windows 8 Native Apps
7772 // The type and name attributes are restricted during .innerHTML assignment
7773 var input = doc.createElement("input");
7774 input.setAttribute( "type", "hidden" );
7775 div.appendChild( input ).setAttribute( "name", "D" );
7776
7777 // Support: IE8
7778 // Enforce case-sensitivity of name attribute
7779 if ( div.querySelectorAll("[name=d]").length ) {
7780 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
7781 }
7782
7783 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
7784 // IE8 throws error here and will not see later tests
7785 if ( !div.querySelectorAll(":enabled").length ) {
7786 rbuggyQSA.push( ":enabled", ":disabled" );
7787 }
7788
7789 // Opera 10-11 does not throw on post-comma invalid pseudos
7790 div.querySelectorAll("*,:x");
7791 rbuggyQSA.push(",.*:");
7792 });
7793 }
7794
7795 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
7796 docElem.webkitMatchesSelector ||
7797 docElem.mozMatchesSelector ||
7798 docElem.oMatchesSelector ||
7799 docElem.msMatchesSelector) )) ) {
7800
7801 assert(function( div ) {
7802 // Check to see if it's possible to do matchesSelector
7803 // on a disconnected node (IE 9)
7804 support.disconnectedMatch = matches.call( div, "div" );
7805
7806 // This should fail with an exception
7807 // Gecko does not error, returns false instead
7808 matches.call( div, "[s!='']:x" );
7809 rbuggyMatches.push( "!=", pseudos );
7810 });
7811 }
7812
7813 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
7814 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
7815
7816 /* Contains
7817 ---------------------------------------------------------------------- */
7818 hasCompare = rnative.test( docElem.compareDocumentPosition );
7819
7820 // Element contains another
7821 // Purposefully does not implement inclusive descendent
7822 // As in, an element does not contain itself
7823 contains = hasCompare || rnative.test( docElem.contains ) ?
7824 function( a, b ) {
7825 var adown = a.nodeType === 9 ? a.documentElement : a,
7826 bup = b && b.parentNode;
7827 return a === bup || !!( bup && bup.nodeType === 1 && (
7828 adown.contains ?
7829 adown.contains( bup ) :
7830 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
7831 ));
7832 } :
7833 function( a, b ) {
7834 if ( b ) {
7835 while ( (b = b.parentNode) ) {
7836 if ( b === a ) {
7837 return true;
7838 }
7839 }
7840 }
7841 return false;
7842 };
7843
7844 /* Sorting
7845 ---------------------------------------------------------------------- */
7846
7847 // Document order sorting
7848 sortOrder = hasCompare ?
7849 function( a, b ) {
7850
7851 // Flag for duplicate removal
7852 if ( a === b ) {
7853 hasDuplicate = true;
7854 return 0;
7855 }
7856
7857 // Sort on method existence if only one input has compareDocumentPosition
7858 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
7859 if ( compare ) {
7860 return compare;
7861 }
7862
7863 // Calculate position if both inputs belong to the same document
7864 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
7865 a.compareDocumentPosition( b ) :
7866
7867 // Otherwise we know they are disconnected
7868 1;
7869
7870 // Disconnected nodes
7871 if ( compare & 1 ||
7872 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
7873
7874 // Choose the first element that is related to our preferred document
7875 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
7876 return -1;
7877 }
7878 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
7879 return 1;
7880 }
7881
7882 // Maintain original order
7883 return sortInput ?
7884 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
7885 0;
7886 }
7887
7888 return compare & 4 ? -1 : 1;
7889 } :
7890 function( a, b ) {
7891 // Exit early if the nodes are identical
7892 if ( a === b ) {
7893 hasDuplicate = true;
7894 return 0;
7895 }
7896
7897 var cur,
7898 i = 0,
7899 aup = a.parentNode,
7900 bup = b.parentNode,
7901 ap = [ a ],
7902 bp = [ b ];
7903
7904 // Parentless nodes are either documents or disconnected
7905 if ( !aup || !bup ) {
7906 return a === doc ? -1 :
7907 b === doc ? 1 :
7908 aup ? -1 :
7909 bup ? 1 :
7910 sortInput ?
7911 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
7912 0;
7913
7914 // If the nodes are siblings, we can do a quick check
7915 } else if ( aup === bup ) {
7916 return siblingCheck( a, b );
7917 }
7918
7919 // Otherwise we need full lists of their ancestors for comparison
7920 cur = a;
7921 while ( (cur = cur.parentNode) ) {
7922 ap.unshift( cur );
7923 }
7924 cur = b;
7925 while ( (cur = cur.parentNode) ) {
7926 bp.unshift( cur );
7927 }
7928
7929 // Walk down the tree looking for a discrepancy
7930 while ( ap[i] === bp[i] ) {
7931 i++;
7932 }
7933
7934 return i ?
7935 // Do a sibling check if the nodes have a common ancestor
7936 siblingCheck( ap[i], bp[i] ) :
7937
7938 // Otherwise nodes in our document sort first
7939 ap[i] === preferredDoc ? -1 :
7940 bp[i] === preferredDoc ? 1 :
7941 0;
7942 };
7943
7944 return doc;
7945 };
7946
7947 Sizzle.matches = function( expr, elements ) {
7948 return Sizzle( expr, null, null, elements );
7949 };
7950
7951 Sizzle.matchesSelector = function( elem, expr ) {
7952 // Set document vars if needed
7953 if ( ( elem.ownerDocument || elem ) !== document ) {
7954 setDocument( elem );
7955 }
7956
7957 // Make sure that attribute selectors are quoted
7958 expr = expr.replace( rattributeQuotes, "='$1']" );
7959
7960 if ( support.matchesSelector && documentIsHTML &&
7961 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
7962 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
7963
7964 try {
7965 var ret = matches.call( elem, expr );
7966
7967 // IE 9's matchesSelector returns false on disconnected nodes
7968 if ( ret || support.disconnectedMatch ||
7969 // As well, disconnected nodes are said to be in a document
7970 // fragment in IE 9
7971 elem.document && elem.document.nodeType !== 11 ) {
7972 return ret;
7973 }
7974 } catch(e) {}
7975 }
7976
7977 return Sizzle( expr, document, null, [ elem ] ).length > 0;
7978 };
7979
7980 Sizzle.contains = function( context, elem ) {
7981 // Set document vars if needed
7982 if ( ( context.ownerDocument || context ) !== document ) {
7983 setDocument( context );
7984 }
7985 return contains( context, elem );
7986 };
7987
7988 Sizzle.attr = function( elem, name ) {
7989 // Set document vars if needed
7990 if ( ( elem.ownerDocument || elem ) !== document ) {
7991 setDocument( elem );
7992 }
7993
7994 var fn = Expr.attrHandle[ name.toLowerCase() ],
7995 // Don't get fooled by Object.prototype properties (jQuery #13807)
7996 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
7997 fn( elem, name, !documentIsHTML ) :
7998 undefined;
7999
8000 return val !== undefined ?
8001 val :
8002 support.attributes || !documentIsHTML ?
8003 elem.getAttribute( name ) :
8004 (val = elem.getAttributeNode(name)) && val.specified ?
8005 val.value :
8006 null;
8007 };
8008
8009 Sizzle.error = function( msg ) {
8010 throw new Error( "Syntax error, unrecognized expression: " + msg );
8011 };
8012
8013 /**
8014 * Document sorting and removing duplicates
8015 * @param {ArrayLike} results
8016 */
8017 Sizzle.uniqueSort = function( results ) {
8018 var elem,
8019 duplicates = [],
8020 j = 0,
8021 i = 0;
8022
8023 // Unless we *know* we can detect duplicates, assume their presence
8024 hasDuplicate = !support.detectDuplicates;
8025 sortInput = !support.sortStable && results.slice( 0 );
8026 results.sort( sortOrder );
8027
8028 if ( hasDuplicate ) {
8029 while ( (elem = results[i++]) ) {
8030 if ( elem === results[ i ] ) {
8031 j = duplicates.push( i );
8032 }
8033 }
8034 while ( j-- ) {
8035 results.splice( duplicates[ j ], 1 );
8036 }
8037 }
8038
8039 // Clear input after sorting to release objects
8040 // See https://github.com/jquery/sizzle/pull/225
8041 sortInput = null;
8042
8043 return results;
8044 };
8045
8046 /**
8047 * Utility function for retrieving the text value of an array of DOM nodes
8048 * @param {Array|Element} elem
8049 */
8050 getText = Sizzle.getText = function( elem ) {
8051 var node,
8052 ret = "",
8053 i = 0,
8054 nodeType = elem.nodeType;
8055
8056 if ( !nodeType ) {
8057 // If no nodeType, this is expected to be an array
8058 while ( (node = elem[i++]) ) {
8059 // Do not traverse comment nodes
8060 ret += getText( node );
8061 }
8062 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
8063 // Use textContent for elements
8064 // innerText usage removed for consistency of new lines (jQuery #11153)
8065 if ( typeof elem.textContent === "string" ) {
8066 return elem.textContent;
8067 } else {
8068 // Traverse its children
8069 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
8070 ret += getText( elem );
8071 }
8072 }
8073 } else if ( nodeType === 3 || nodeType === 4 ) {
8074 return elem.nodeValue;
8075 }
8076 // Do not include comment or processing instruction nodes
8077
8078 return ret;
8079 };
8080
8081 Expr = Sizzle.selectors = {
8082
8083 // Can be adjusted by the user
8084 cacheLength: 50,
8085
8086 createPseudo: markFunction,
8087
8088 match: matchExpr,
8089
8090 attrHandle: {},
8091
8092 find: {},
8093
8094 relative: {
8095 ">": { dir: "parentNode", first: true },
8096 " ": { dir: "parentNode" },
8097 "+": { dir: "previousSibling", first: true },
8098 "~": { dir: "previousSibling" }
8099 },
8100
8101 preFilter: {
8102 "ATTR": function( match ) {
8103 match[1] = match[1].replace( runescape, funescape );
8104
8105 // Move the given value to match[3] whether quoted or unquoted
8106 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
8107
8108 if ( match[2] === "~=" ) {
8109 match[3] = " " + match[3] + " ";
8110 }
8111
8112 return match.slice( 0, 4 );
8113 },
8114
8115 "CHILD": function( match ) {
8116 /* matches from matchExpr["CHILD"]
8117 1 type (only|nth|...)
8118 2 what (child|of-type)
8119 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
8120 4 xn-component of xn+y argument ([+-]?\d*n|)
8121 5 sign of xn-component
8122 6 x of xn-component
8123 7 sign of y-component
8124 8 y of y-component
8125 */
8126 match[1] = match[1].toLowerCase();
8127
8128 if ( match[1].slice( 0, 3 ) === "nth" ) {
8129 // nth-* requires argument
8130 if ( !match[3] ) {
8131 Sizzle.error( match[0] );
8132 }
8133
8134 // numeric x and y parameters for Expr.filter.CHILD
8135 // remember that false/true cast respectively to 0/1
8136 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
8137 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
8138
8139 // other types prohibit arguments
8140 } else if ( match[3] ) {
8141 Sizzle.error( match[0] );
8142 }
8143
8144 return match;
8145 },
8146
8147 "PSEUDO": function( match ) {
8148 var excess,
8149 unquoted = !match[6] && match[2];
8150
8151 if ( matchExpr["CHILD"].test( match[0] ) ) {
8152 return null;
8153 }
8154
8155 // Accept quoted arguments as-is
8156 if ( match[3] ) {
8157 match[2] = match[4] || match[5] || "";
8158
8159 // Strip excess characters from unquoted arguments
8160 } else if ( unquoted && rpseudo.test( unquoted ) &&
8161 // Get excess from tokenize (recursively)
8162 (excess = tokenize( unquoted, true )) &&
8163 // advance to the next closing parenthesis
8164 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
8165
8166 // excess is a negative index
8167 match[0] = match[0].slice( 0, excess );
8168 match[2] = unquoted.slice( 0, excess );
8169 }
8170
8171 // Return only captures needed by the pseudo filter method (type and argument)
8172 return match.slice( 0, 3 );
8173 }
8174 },
8175
8176 filter: {
8177
8178 "TAG": function( nodeNameSelector ) {
8179 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
8180 return nodeNameSelector === "*" ?
8181 function() { return true; } :
8182 function( elem ) {
8183 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
8184 };
8185 },
8186
8187 "CLASS": function( className ) {
8188 var pattern = classCache[ className + " " ];
8189
8190 return pattern ||
8191 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
8192 classCache( className, function( elem ) {
8193 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
8194 });
8195 },
8196
8197 "ATTR": function( name, operator, check ) {
8198 return function( elem ) {
8199 var result = Sizzle.attr( elem, name );
8200
8201 if ( result == null ) {
8202 return operator === "!=";
8203 }
8204 if ( !operator ) {
8205 return true;
8206 }
8207
8208 result += "";
8209
8210 return operator === "=" ? result === check :
8211 operator === "!=" ? result !== check :
8212 operator === "^=" ? check && result.indexOf( check ) === 0 :
8213 operator === "*=" ? check && result.indexOf( check ) > -1 :
8214 operator === "$=" ? check && result.slice( -check.length ) === check :
8215 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
8216 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
8217 false;
8218 };
8219 },
8220
8221 "CHILD": function( type, what, argument, first, last ) {
8222 var simple = type.slice( 0, 3 ) !== "nth",
8223 forward = type.slice( -4 ) !== "last",
8224 ofType = what === "of-type";
8225
8226 return first === 1 && last === 0 ?
8227
8228 // Shortcut for :nth-*(n)
8229 function( elem ) {
8230 return !!elem.parentNode;
8231 } :
8232
8233 function( elem, context, xml ) {
8234 var cache, outerCache, node, diff, nodeIndex, start,
8235 dir = simple !== forward ? "nextSibling" : "previousSibling",
8236 parent = elem.parentNode,
8237 name = ofType && elem.nodeName.toLowerCase(),
8238 useCache = !xml && !ofType;
8239
8240 if ( parent ) {
8241
8242 // :(first|last|only)-(child|of-type)
8243 if ( simple ) {
8244 while ( dir ) {
8245 node = elem;
8246 while ( (node = node[ dir ]) ) {
8247 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
8248 return false;
8249 }
8250 }
8251 // Reverse direction for :only-* (if we haven't yet done so)
8252 start = dir = type === "only" && !start && "nextSibling";
8253 }
8254 return true;
8255 }
8256
8257 start = [ forward ? parent.firstChild : parent.lastChild ];
8258
8259 // non-xml :nth-child(...) stores cache data on `parent`
8260 if ( forward && useCache ) {
8261 // Seek `elem` from a previously-cached index
8262 outerCache = parent[ expando ] || (parent[ expando ] = {});
8263 cache = outerCache[ type ] || [];
8264 nodeIndex = cache[0] === dirruns && cache[1];
8265 diff = cache[0] === dirruns && cache[2];
8266 node = nodeIndex && parent.childNodes[ nodeIndex ];
8267
8268 while ( (node = ++nodeIndex && node && node[ dir ] ||
8269
8270 // Fallback to seeking `elem` from the start
8271 (diff = nodeIndex = 0) || start.pop()) ) {
8272
8273 // When found, cache indexes on `parent` and break
8274 if ( node.nodeType === 1 && ++diff && node === elem ) {
8275 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
8276 break;
8277 }
8278 }
8279
8280 // Use previously-cached element index if available
8281 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
8282 diff = cache[1];
8283
8284 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
8285 } else {
8286 // Use the same loop as above to seek `elem` from the start
8287 while ( (node = ++nodeIndex && node && node[ dir ] ||
8288 (diff = nodeIndex = 0) || start.pop()) ) {
8289
8290 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
8291 // Cache the index of each encountered element
8292 if ( useCache ) {
8293 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
8294 }
8295
8296 if ( node === elem ) {
8297 break;
8298 }
8299 }
8300 }
8301 }
8302
8303 // Incorporate the offset, then check against cycle size
8304 diff -= last;
8305 return diff === first || ( diff % first === 0 && diff / first >= 0 );
8306 }
8307 };
8308 },
8309
8310 "PSEUDO": function( pseudo, argument ) {
8311 // pseudo-class names are case-insensitive
8312 // http://www.w3.org/TR/selectors/#pseudo-classes
8313 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
8314 // Remember that setFilters inherits from pseudos
8315 var args,
8316 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
8317 Sizzle.error( "unsupported pseudo: " + pseudo );
8318
8319 // The user may use createPseudo to indicate that
8320 // arguments are needed to create the filter function
8321 // just as Sizzle does
8322 if ( fn[ expando ] ) {
8323 return fn( argument );
8324 }
8325
8326 // But maintain support for old signatures
8327 if ( fn.length > 1 ) {
8328 args = [ pseudo, pseudo, "", argument ];
8329 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
8330 markFunction(function( seed, matches ) {
8331 var idx,
8332 matched = fn( seed, argument ),
8333 i = matched.length;
8334 while ( i-- ) {
8335 idx = indexOf.call( seed, matched[i] );
8336 seed[ idx ] = !( matches[ idx ] = matched[i] );
8337 }
8338 }) :
8339 function( elem ) {
8340 return fn( elem, 0, args );
8341 };
8342 }
8343
8344 return fn;
8345 }
8346 },
8347
8348 pseudos: {
8349 // Potentially complex pseudos
8350 "not": markFunction(function( selector ) {
8351 // Trim the selector passed to compile
8352 // to avoid treating leading and trailing
8353 // spaces as combinators
8354 var input = [],
8355 results = [],
8356 matcher = compile( selector.replace( rtrim, "$1" ) );
8357
8358 return matcher[ expando ] ?
8359 markFunction(function( seed, matches, context, xml ) {
8360 var elem,
8361 unmatched = matcher( seed, null, xml, [] ),
8362 i = seed.length;
8363
8364 // Match elements unmatched by `matcher`
8365 while ( i-- ) {
8366 if ( (elem = unmatched[i]) ) {
8367 seed[i] = !(matches[i] = elem);
8368 }
8369 }
8370 }) :
8371 function( elem, context, xml ) {
8372 input[0] = elem;
8373 matcher( input, null, xml, results );
8374 return !results.pop();
8375 };
8376 }),
8377
8378 "has": markFunction(function( selector ) {
8379 return function( elem ) {
8380 return Sizzle( selector, elem ).length > 0;
8381 };
8382 }),
8383
8384 "contains": markFunction(function( text ) {
8385 return function( elem ) {
8386 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
8387 };
8388 }),
8389
8390 // "Whether an element is represented by a :lang() selector
8391 // is based solely on the element's language value
8392 // being equal to the identifier C,
8393 // or beginning with the identifier C immediately followed by "-".
8394 // The matching of C against the element's language value is performed case-insensitively.
8395 // The identifier C does not have to be a valid language name."
8396 // http://www.w3.org/TR/selectors/#lang-pseudo
8397 "lang": markFunction( function( lang ) {
8398 // lang value must be a valid identifier
8399 if ( !ridentifier.test(lang || "") ) {
8400 Sizzle.error( "unsupported lang: " + lang );
8401 }
8402 lang = lang.replace( runescape, funescape ).toLowerCase();
8403 return function( elem ) {
8404 var elemLang;
8405 do {
8406 if ( (elemLang = documentIsHTML ?
8407 elem.lang :
8408 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
8409
8410 elemLang = elemLang.toLowerCase();
8411 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
8412 }
8413 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
8414 return false;
8415 };
8416 }),
8417
8418 // Miscellaneous
8419 "target": function( elem ) {
8420 var hash = window.location && window.location.hash;
8421 return hash && hash.slice( 1 ) === elem.id;
8422 },
8423
8424 "root": function( elem ) {
8425 return elem === docElem;
8426 },
8427
8428 "focus": function( elem ) {
8429 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
8430 },
8431
8432 // Boolean properties
8433 "enabled": function( elem ) {
8434 return elem.disabled === false;
8435 },
8436
8437 "disabled": function( elem ) {
8438 return elem.disabled === true;
8439 },
8440
8441 "checked": function( elem ) {
8442 // In CSS3, :checked should return both checked and selected elements
8443 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
8444 var nodeName = elem.nodeName.toLowerCase();
8445 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
8446 },
8447
8448 "selected": function( elem ) {
8449 // Accessing this property makes selected-by-default
8450 // options in Safari work properly
8451 if ( elem.parentNode ) {
8452 elem.parentNode.selectedIndex;
8453 }
8454
8455 return elem.selected === true;
8456 },
8457
8458 // Contents
8459 "empty": function( elem ) {
8460 // http://www.w3.org/TR/selectors/#empty-pseudo
8461 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
8462 // but not by others (comment: 8; processing instruction: 7; etc.)
8463 // nodeType < 6 works because attributes (2) do not appear as children
8464 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
8465 if ( elem.nodeType < 6 ) {
8466 return false;
8467 }
8468 }
8469 return true;
8470 },
8471
8472 "parent": function( elem ) {
8473 return !Expr.pseudos["empty"]( elem );
8474 },
8475
8476 // Element/input types
8477 "header": function( elem ) {
8478 return rheader.test( elem.nodeName );
8479 },
8480
8481 "input": function( elem ) {
8482 return rinputs.test( elem.nodeName );
8483 },
8484
8485 "button": function( elem ) {
8486 var name = elem.nodeName.toLowerCase();
8487 return name === "input" && elem.type === "button" || name === "button";
8488 },
8489
8490 "text": function( elem ) {
8491 var attr;
8492 return elem.nodeName.toLowerCase() === "input" &&
8493 elem.type === "text" &&
8494
8495 // Support: IE<8
8496 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
8497 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
8498 },
8499
8500 // Position-in-collection
8501 "first": createPositionalPseudo(function() {
8502 return [ 0 ];
8503 }),
8504
8505 "last": createPositionalPseudo(function( matchIndexes, length ) {
8506 return [ length - 1 ];
8507 }),
8508
8509 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
8510 return [ argument < 0 ? argument + length : argument ];
8511 }),
8512
8513 "even": createPositionalPseudo(function( matchIndexes, length ) {
8514 var i = 0;
8515 for ( ; i < length; i += 2 ) {
8516 matchIndexes.push( i );
8517 }
8518 return matchIndexes;
8519 }),
8520
8521 "odd": createPositionalPseudo(function( matchIndexes, length ) {
8522 var i = 1;
8523 for ( ; i < length; i += 2 ) {
8524 matchIndexes.push( i );
8525 }
8526 return matchIndexes;
8527 }),
8528
8529 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
8530 var i = argument < 0 ? argument + length : argument;
8531 for ( ; --i >= 0; ) {
8532 matchIndexes.push( i );
8533 }
8534 return matchIndexes;
8535 }),
8536
8537 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
8538 var i = argument < 0 ? argument + length : argument;
8539 for ( ; ++i < length; ) {
8540 matchIndexes.push( i );
8541 }
8542 return matchIndexes;
8543 })
8544 }
8545 };
8546
8547 Expr.pseudos["nth"] = Expr.pseudos["eq"];
8548
8549 // Add button/input type pseudos
8550 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
8551 Expr.pseudos[ i ] = createInputPseudo( i );
8552 }
8553 for ( i in { submit: true, reset: true } ) {
8554 Expr.pseudos[ i ] = createButtonPseudo( i );
8555 }
8556
8557 // Easy API for creating new setFilters
8558 function setFilters() {}
8559 setFilters.prototype = Expr.filters = Expr.pseudos;
8560 Expr.setFilters = new setFilters();
8561
8562 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
8563 var matched, match, tokens, type,
8564 soFar, groups, preFilters,
8565 cached = tokenCache[ selector + " " ];
8566
8567 if ( cached ) {
8568 return parseOnly ? 0 : cached.slice( 0 );
8569 }
8570
8571 soFar = selector;
8572 groups = [];
8573 preFilters = Expr.preFilter;
8574
8575 while ( soFar ) {
8576
8577 // Comma and first run
8578 if ( !matched || (match = rcomma.exec( soFar )) ) {
8579 if ( match ) {
8580 // Don't consume trailing commas as valid
8581 soFar = soFar.slice( match[0].length ) || soFar;
8582 }
8583 groups.push( (tokens = []) );
8584 }
8585
8586 matched = false;
8587
8588 // Combinators
8589 if ( (match = rcombinators.exec( soFar )) ) {
8590 matched = match.shift();
8591 tokens.push({
8592 value: matched,
8593 // Cast descendant combinators to space
8594 type: match[0].replace( rtrim, " " )
8595 });
8596 soFar = soFar.slice( matched.length );
8597 }
8598
8599 // Filters
8600 for ( type in Expr.filter ) {
8601 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
8602 (match = preFilters[ type ]( match ))) ) {
8603 matched = match.shift();
8604 tokens.push({
8605 value: matched,
8606 type: type,
8607 matches: match
8608 });
8609 soFar = soFar.slice( matched.length );
8610 }
8611 }
8612
8613 if ( !matched ) {
8614 break;
8615 }
8616 }
8617
8618 // Return the length of the invalid excess
8619 // if we're just parsing
8620 // Otherwise, throw an error or return tokens
8621 return parseOnly ?
8622 soFar.length :
8623 soFar ?
8624 Sizzle.error( selector ) :
8625 // Cache the tokens
8626 tokenCache( selector, groups ).slice( 0 );
8627 };
8628
8629 function toSelector( tokens ) {
8630 var i = 0,
8631 len = tokens.length,
8632 selector = "";
8633 for ( ; i < len; i++ ) {
8634 selector += tokens[i].value;
8635 }
8636 return selector;
8637 }
8638
8639 function addCombinator( matcher, combinator, base ) {
8640 var dir = combinator.dir,
8641 checkNonElements = base && dir === "parentNode",
8642 doneName = done++;
8643
8644 return combinator.first ?
8645 // Check against closest ancestor/preceding element
8646 function( elem, context, xml ) {
8647 while ( (elem = elem[ dir ]) ) {
8648 if ( elem.nodeType === 1 || checkNonElements ) {
8649 return matcher( elem, context, xml );
8650 }
8651 }
8652 } :
8653
8654 // Check against all ancestor/preceding elements
8655 function( elem, context, xml ) {
8656 var oldCache, outerCache,
8657 newCache = [ dirruns, doneName ];
8658
8659 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
8660 if ( xml ) {
8661 while ( (elem = elem[ dir ]) ) {
8662 if ( elem.nodeType === 1 || checkNonElements ) {
8663 if ( matcher( elem, context, xml ) ) {
8664 return true;
8665 }
8666 }
8667 }
8668 } else {
8669 while ( (elem = elem[ dir ]) ) {
8670 if ( elem.nodeType === 1 || checkNonElements ) {
8671 outerCache = elem[ expando ] || (elem[ expando ] = {});
8672 if ( (oldCache = outerCache[ dir ]) &&
8673 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
8674
8675 // Assign to newCache so results back-propagate to previous elements
8676 return (newCache[ 2 ] = oldCache[ 2 ]);
8677 } else {
8678 // Reuse newcache so results back-propagate to previous elements
8679 outerCache[ dir ] = newCache;
8680
8681 // A match means we're done; a fail means we have to keep checking
8682 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
8683 return true;
8684 }
8685 }
8686 }
8687 }
8688 }
8689 };
8690 }
8691
8692 function elementMatcher( matchers ) {
8693 return matchers.length > 1 ?
8694 function( elem, context, xml ) {
8695 var i = matchers.length;
8696 while ( i-- ) {
8697 if ( !matchers[i]( elem, context, xml ) ) {
8698 return false;
8699 }
8700 }
8701 return true;
8702 } :
8703 matchers[0];
8704 }
8705
8706 function multipleContexts( selector, contexts, results ) {
8707 var i = 0,
8708 len = contexts.length;
8709 for ( ; i < len; i++ ) {
8710 Sizzle( selector, contexts[i], results );
8711 }
8712 return results;
8713 }
8714
8715 function condense( unmatched, map, filter, context, xml ) {
8716 var elem,
8717 newUnmatched = [],
8718 i = 0,
8719 len = unmatched.length,
8720 mapped = map != null;
8721
8722 for ( ; i < len; i++ ) {
8723 if ( (elem = unmatched[i]) ) {
8724 if ( !filter || filter( elem, context, xml ) ) {
8725 newUnmatched.push( elem );
8726 if ( mapped ) {
8727 map.push( i );
8728 }
8729 }
8730 }
8731 }
8732
8733 return newUnmatched;
8734 }
8735
8736 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
8737 if ( postFilter && !postFilter[ expando ] ) {
8738 postFilter = setMatcher( postFilter );
8739 }
8740 if ( postFinder && !postFinder[ expando ] ) {
8741 postFinder = setMatcher( postFinder, postSelector );
8742 }
8743 return markFunction(function( seed, results, context, xml ) {
8744 var temp, i, elem,
8745 preMap = [],
8746 postMap = [],
8747 preexisting = results.length,
8748
8749 // Get initial elements from seed or context
8750 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
8751
8752 // Prefilter to get matcher input, preserving a map for seed-results synchronization
8753 matcherIn = preFilter && ( seed || !selector ) ?
8754 condense( elems, preMap, preFilter, context, xml ) :
8755 elems,
8756
8757 matcherOut = matcher ?
8758 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
8759 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
8760
8761 // ...intermediate processing is necessary
8762 [] :
8763
8764 // ...otherwise use results directly
8765 results :
8766 matcherIn;
8767
8768 // Find primary matches
8769 if ( matcher ) {
8770 matcher( matcherIn, matcherOut, context, xml );
8771 }
8772
8773 // Apply postFilter
8774 if ( postFilter ) {
8775 temp = condense( matcherOut, postMap );
8776 postFilter( temp, [], context, xml );
8777
8778 // Un-match failing elements by moving them back to matcherIn
8779 i = temp.length;
8780 while ( i-- ) {
8781 if ( (elem = temp[i]) ) {
8782 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
8783 }
8784 }
8785 }
8786
8787 if ( seed ) {
8788 if ( postFinder || preFilter ) {
8789 if ( postFinder ) {
8790 // Get the final matcherOut by condensing this intermediate into postFinder contexts
8791 temp = [];
8792 i = matcherOut.length;
8793 while ( i-- ) {
8794 if ( (elem = matcherOut[i]) ) {
8795 // Restore matcherIn since elem is not yet a final match
8796 temp.push( (matcherIn[i] = elem) );
8797 }
8798 }
8799 postFinder( null, (matcherOut = []), temp, xml );
8800 }
8801
8802 // Move matched elements from seed to results to keep them synchronized
8803 i = matcherOut.length;
8804 while ( i-- ) {
8805 if ( (elem = matcherOut[i]) &&
8806 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
8807
8808 seed[temp] = !(results[temp] = elem);
8809 }
8810 }
8811 }
8812
8813 // Add elements to results, through postFinder if defined
8814 } else {
8815 matcherOut = condense(
8816 matcherOut === results ?
8817 matcherOut.splice( preexisting, matcherOut.length ) :
8818 matcherOut
8819 );
8820 if ( postFinder ) {
8821 postFinder( null, results, matcherOut, xml );
8822 } else {
8823 push.apply( results, matcherOut );
8824 }
8825 }
8826 });
8827 }
8828
8829 function matcherFromTokens( tokens ) {
8830 var checkContext, matcher, j,
8831 len = tokens.length,
8832 leadingRelative = Expr.relative[ tokens[0].type ],
8833 implicitRelative = leadingRelative || Expr.relative[" "],
8834 i = leadingRelative ? 1 : 0,
8835
8836 // The foundational matcher ensures that elements are reachable from top-level context(s)
8837 matchContext = addCombinator( function( elem ) {
8838 return elem === checkContext;
8839 }, implicitRelative, true ),
8840 matchAnyContext = addCombinator( function( elem ) {
8841 return indexOf.call( checkContext, elem ) > -1;
8842 }, implicitRelative, true ),
8843 matchers = [ function( elem, context, xml ) {
8844 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
8845 (checkContext = context).nodeType ?
8846 matchContext( elem, context, xml ) :
8847 matchAnyContext( elem, context, xml ) );
8848 } ];
8849
8850 for ( ; i < len; i++ ) {
8851 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
8852 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
8853 } else {
8854 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
8855
8856 // Return special upon seeing a positional matcher
8857 if ( matcher[ expando ] ) {
8858 // Find the next relative operator (if any) for proper handling
8859 j = ++i;
8860 for ( ; j < len; j++ ) {
8861 if ( Expr.relative[ tokens[j].type ] ) {
8862 break;
8863 }
8864 }
8865 return setMatcher(
8866 i > 1 && elementMatcher( matchers ),
8867 i > 1 && toSelector(
8868 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
8869 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
8870 ).replace( rtrim, "$1" ),
8871 matcher,
8872 i < j && matcherFromTokens( tokens.slice( i, j ) ),
8873 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
8874 j < len && toSelector( tokens )
8875 );
8876 }
8877 matchers.push( matcher );
8878 }
8879 }
8880
8881 return elementMatcher( matchers );
8882 }
8883
8884 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
8885 var bySet = setMatchers.length > 0,
8886 byElement = elementMatchers.length > 0,
8887 superMatcher = function( seed, context, xml, results, outermost ) {
8888 var elem, j, matcher,
8889 matchedCount = 0,
8890 i = "0",
8891 unmatched = seed && [],
8892 setMatched = [],
8893 contextBackup = outermostContext,
8894 // We must always have either seed elements or outermost context
8895 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
8896 // Use integer dirruns iff this is the outermost matcher
8897 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
8898 len = elems.length;
8899
8900 if ( outermost ) {
8901 outermostContext = context !== document && context;
8902 }
8903
8904 // Add elements passing elementMatchers directly to results
8905 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
8906 // Support: IE<9, Safari
8907 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
8908 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
8909 if ( byElement && elem ) {
8910 j = 0;
8911 while ( (matcher = elementMatchers[j++]) ) {
8912 if ( matcher( elem, context, xml ) ) {
8913 results.push( elem );
8914 break;
8915 }
8916 }
8917 if ( outermost ) {
8918 dirruns = dirrunsUnique;
8919 }
8920 }
8921
8922 // Track unmatched elements for set filters
8923 if ( bySet ) {
8924 // They will have gone through all possible matchers
8925 if ( (elem = !matcher && elem) ) {
8926 matchedCount--;
8927 }
8928
8929 // Lengthen the array for every element, matched or not
8930 if ( seed ) {
8931 unmatched.push( elem );
8932 }
8933 }
8934 }
8935
8936 // Apply set filters to unmatched elements
8937 matchedCount += i;
8938 if ( bySet && i !== matchedCount ) {
8939 j = 0;
8940 while ( (matcher = setMatchers[j++]) ) {
8941 matcher( unmatched, setMatched, context, xml );
8942 }
8943
8944 if ( seed ) {
8945 // Reintegrate element matches to eliminate the need for sorting
8946 if ( matchedCount > 0 ) {
8947 while ( i-- ) {
8948 if ( !(unmatched[i] || setMatched[i]) ) {
8949 setMatched[i] = pop.call( results );
8950 }
8951 }
8952 }
8953
8954 // Discard index placeholder values to get only actual matches
8955 setMatched = condense( setMatched );
8956 }
8957
8958 // Add matches to results
8959 push.apply( results, setMatched );
8960
8961 // Seedless set matches succeeding multiple successful matchers stipulate sorting
8962 if ( outermost && !seed && setMatched.length > 0 &&
8963 ( matchedCount + setMatchers.length ) > 1 ) {
8964
8965 Sizzle.uniqueSort( results );
8966 }
8967 }
8968
8969 // Override manipulation of globals by nested matchers
8970 if ( outermost ) {
8971 dirruns = dirrunsUnique;
8972 outermostContext = contextBackup;
8973 }
8974
8975 return unmatched;
8976 };
8977
8978 return bySet ?
8979 markFunction( superMatcher ) :
8980 superMatcher;
8981 }
8982
8983 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
8984 var i,
8985 setMatchers = [],
8986 elementMatchers = [],
8987 cached = compilerCache[ selector + " " ];
8988
8989 if ( !cached ) {
8990 // Generate a function of recursive functions that can be used to check each element
8991 if ( !match ) {
8992 match = tokenize( selector );
8993 }
8994 i = match.length;
8995 while ( i-- ) {
8996 cached = matcherFromTokens( match[i] );
8997 if ( cached[ expando ] ) {
8998 setMatchers.push( cached );
8999 } else {
9000 elementMatchers.push( cached );
9001 }
9002 }
9003
9004 // Cache the compiled function
9005 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
9006
9007 // Save selector and tokenization
9008 cached.selector = selector;
9009 }
9010 return cached;
9011 };
9012
9013 /**
9014 * A low-level selection function that works with Sizzle's compiled
9015 * selector functions
9016 * @param {String|Function} selector A selector or a pre-compiled
9017 * selector function built with Sizzle.compile
9018 * @param {Element} context
9019 * @param {Array} [results]
9020 * @param {Array} [seed] A set of elements to match against
9021 */
9022 select = Sizzle.select = function( selector, context, results, seed ) {
9023 var i, tokens, token, type, find,
9024 compiled = typeof selector === "function" && selector,
9025 match = !seed && tokenize( (selector = compiled.selector || selector) );
9026
9027 results = results || [];
9028
9029 // Try to minimize operations if there is no seed and only one group
9030 if ( match.length === 1 ) {
9031
9032 // Take a shortcut and set the context if the root selector is an ID
9033 tokens = match[0] = match[0].slice( 0 );
9034 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
9035 support.getById && context.nodeType === 9 && documentIsHTML &&
9036 Expr.relative[ tokens[1].type ] ) {
9037
9038 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
9039 if ( !context ) {
9040 return results;
9041
9042 // Precompiled matchers will still verify ancestry, so step up a level
9043 } else if ( compiled ) {
9044 context = context.parentNode;
9045 }
9046
9047 selector = selector.slice( tokens.shift().value.length );
9048 }
9049
9050 // Fetch a seed set for right-to-left matching
9051 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
9052 while ( i-- ) {
9053 token = tokens[i];
9054
9055 // Abort if we hit a combinator
9056 if ( Expr.relative[ (type = token.type) ] ) {
9057 break;
9058 }
9059 if ( (find = Expr.find[ type ]) ) {
9060 // Search, expanding context for leading sibling combinators
9061 if ( (seed = find(
9062 token.matches[0].replace( runescape, funescape ),
9063 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
9064 )) ) {
9065
9066 // If seed is empty or no tokens remain, we can return early
9067 tokens.splice( i, 1 );
9068 selector = seed.length && toSelector( tokens );
9069 if ( !selector ) {
9070 push.apply( results, seed );
9071 return results;
9072 }
9073
9074 break;
9075 }
9076 }
9077 }
9078 }
9079
9080 // Compile and execute a filtering function if one is not provided
9081 // Provide `match` to avoid retokenization if we modified the selector above
9082 ( compiled || compile( selector, match ) )(
9083 seed,
9084 context,
9085 !documentIsHTML,
9086 results,
9087 rsibling.test( selector ) && testContext( context.parentNode ) || context
9088 );
9089 return results;
9090 };
9091
9092 // One-time assignments
9093
9094 // Sort stability
9095 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
9096
9097 // Support: Chrome<14
9098 // Always assume duplicates if they aren't passed to the comparison function
9099 support.detectDuplicates = !!hasDuplicate;
9100
9101 // Initialize against the default document
9102 setDocument();
9103
9104 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
9105 // Detached nodes confoundingly follow *each other*
9106 support.sortDetached = assert(function( div1 ) {
9107 // Should return 1, but returns 4 (following)
9108 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
9109 });
9110
9111 // Support: IE<8
9112 // Prevent attribute/property "interpolation"
9113 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
9114 if ( !assert(function( div ) {
9115 div.innerHTML = "<a href='#'></a>";
9116 return div.firstChild.getAttribute("href") === "#" ;
9117 }) ) {
9118 addHandle( "type|href|height|width", function( elem, name, isXML ) {
9119 if ( !isXML ) {
9120 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
9121 }
9122 });
9123 }
9124
9125 // Support: IE<9
9126 // Use defaultValue in place of getAttribute("value")
9127 if ( !support.attributes || !assert(function( div ) {
9128 div.innerHTML = "<input/>";
9129 div.firstChild.setAttribute( "value", "" );
9130 return div.firstChild.getAttribute( "value" ) === "";
9131 }) ) {
9132 addHandle( "value", function( elem, name, isXML ) {
9133 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
9134 return elem.defaultValue;
9135 }
9136 });
9137 }
9138
9139 // Support: IE<9
9140 // Use getAttributeNode to fetch booleans when getAttribute lies
9141 if ( !assert(function( div ) {
9142 return div.getAttribute("disabled") == null;
9143 }) ) {
9144 addHandle( booleans, function( elem, name, isXML ) {
9145 var val;
9146 if ( !isXML ) {
9147 return elem[ name ] === true ? name.toLowerCase() :
9148 (val = elem.getAttributeNode( name )) && val.specified ?
9149 val.value :
9150 null;
9151 }
9152 });
9153 }
9154
9155 return Sizzle;
9156
9157 })( window );
9158
9159
9160
9161 jQuery.find = Sizzle;
9162 jQuery.expr = Sizzle.selectors;
9163 jQuery.expr[":"] = jQuery.expr.pseudos;
9164 jQuery.unique = Sizzle.uniqueSort;
9165 jQuery.text = Sizzle.getText;
9166 jQuery.isXMLDoc = Sizzle.isXML;
9167 jQuery.contains = Sizzle.contains;
9168
9169
9170
9171 var rneedsContext = jQuery.expr.match.needsContext;
9172
9173 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
9174
9175
9176
9177 var risSimple = /^.[^:#\[\.,]*$/;
9178
9179 // Implement the identical functionality for filter and not
9180 function winnow( elements, qualifier, not ) {
9181 if ( jQuery.isFunction( qualifier ) ) {
9182 return jQuery.grep( elements, function( elem, i ) {
9183 /* jshint -W018 */
9184 return !!qualifier.call( elem, i, elem ) !== not;
9185 });
9186
9187 }
9188
9189 if ( qualifier.nodeType ) {
9190 return jQuery.grep( elements, function( elem ) {
9191 return ( elem === qualifier ) !== not;
9192 });
9193
9194 }
9195
9196 if ( typeof qualifier === "string" ) {
9197 if ( risSimple.test( qualifier ) ) {
9198 return jQuery.filter( qualifier, elements, not );
9199 }
9200
9201 qualifier = jQuery.filter( qualifier, elements );
9202 }
9203
9204 return jQuery.grep( elements, function( elem ) {
9205 return ( indexOf.call( qualifier, elem ) >= 0 ) !== not;
9206 });
9207 }
9208
9209 jQuery.filter = function( expr, elems, not ) {
9210 var elem = elems[ 0 ];
9211
9212 if ( not ) {
9213 expr = ":not(" + expr + ")";
9214 }
9215
9216 return elems.length === 1 && elem.nodeType === 1 ?
9217 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
9218 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
9219 return elem.nodeType === 1;
9220 }));
9221 };
9222
9223 jQuery.fn.extend({
9224 find: function( selector ) {
9225 var i,
9226 len = this.length,
9227 ret = [],
9228 self = this;
9229
9230 if ( typeof selector !== "string" ) {
9231 return this.pushStack( jQuery( selector ).filter(function() {
9232 for ( i = 0; i < len; i++ ) {
9233 if ( jQuery.contains( self[ i ], this ) ) {
9234 return true;
9235 }
9236 }
9237 }) );
9238 }
9239
9240 for ( i = 0; i < len; i++ ) {
9241 jQuery.find( selector, self[ i ], ret );
9242 }
9243
9244 // Needed because $( selector, context ) becomes $( context ).find( selector )
9245 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
9246 ret.selector = this.selector ? this.selector + " " + selector : selector;
9247 return ret;
9248 },
9249 filter: function( selector ) {
9250 return this.pushStack( winnow(this, selector || [], false) );
9251 },
9252 not: function( selector ) {
9253 return this.pushStack( winnow(this, selector || [], true) );
9254 },
9255 is: function( selector ) {
9256 return !!winnow(
9257 this,
9258
9259 // If this is a positional/relative selector, check membership in the returned set
9260 // so $("p:first").is("p:last") won't return true for a doc with two "p".
9261 typeof selector === "string" && rneedsContext.test( selector ) ?
9262 jQuery( selector ) :
9263 selector || [],
9264 false
9265 ).length;
9266 }
9267 });
9268
9269
9270 // Initialize a jQuery object
9271
9272
9273 // A central reference to the root jQuery(document)
9274 var rootjQuery,
9275
9276 // A simple way to check for HTML strings
9277 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
9278 // Strict HTML recognition (#11290: must start with <)
9279 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
9280
9281 init = jQuery.fn.init = function( selector, context ) {
9282 var match, elem;
9283
9284 // HANDLE: $(""), $(null), $(undefined), $(false)
9285 if ( !selector ) {
9286 return this;
9287 }
9288
9289 // Handle HTML strings
9290 if ( typeof selector === "string" ) {
9291 if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) {
9292 // Assume that strings that start and end with <> are HTML and skip the regex check
9293 match = [ null, selector, null ];
9294
9295 } else {
9296 match = rquickExpr.exec( selector );
9297 }
9298
9299 // Match html or make sure no context is specified for #id
9300 if ( match && (match[1] || !context) ) {
9301
9302 // HANDLE: $(html) -> $(array)
9303 if ( match[1] ) {
9304 context = context instanceof jQuery ? context[0] : context;
9305
9306 // scripts is true for back-compat
9307 // Intentionally let the error be thrown if parseHTML is not present
9308 jQuery.merge( this, jQuery.parseHTML(
9309 match[1],
9310 context && context.nodeType ? context.ownerDocument || context : document,
9311 true
9312 ) );
9313
9314 // HANDLE: $(html, props)
9315 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
9316 for ( match in context ) {
9317 // Properties of context are called as methods if possible
9318 if ( jQuery.isFunction( this[ match ] ) ) {
9319 this[ match ]( context[ match ] );
9320
9321 // ...and otherwise set as attributes
9322 } else {
9323 this.attr( match, context[ match ] );
9324 }
9325 }
9326 }
9327
9328 return this;
9329
9330 // HANDLE: $(#id)
9331 } else {
9332 elem = document.getElementById( match[2] );
9333
9334 // Check parentNode to catch when Blackberry 4.6 returns
9335 // nodes that are no longer in the document #6963
9336 if ( elem && elem.parentNode ) {
9337 // Inject the element directly into the jQuery object
9338 this.length = 1;
9339 this[0] = elem;
9340 }
9341
9342 this.context = document;
9343 this.selector = selector;
9344 return this;
9345 }
9346
9347 // HANDLE: $(expr, $(...))
9348 } else if ( !context || context.jquery ) {
9349 return ( context || rootjQuery ).find( selector );
9350
9351 // HANDLE: $(expr, context)
9352 // (which is just equivalent to: $(context).find(expr)
9353 } else {
9354 return this.constructor( context ).find( selector );
9355 }
9356
9357 // HANDLE: $(DOMElement)
9358 } else if ( selector.nodeType ) {
9359 this.context = this[0] = selector;
9360 this.length = 1;
9361 return this;
9362
9363 // HANDLE: $(function)
9364 // Shortcut for document ready
9365 } else if ( jQuery.isFunction( selector ) ) {
9366 return typeof rootjQuery.ready !== "undefined" ?
9367 rootjQuery.ready( selector ) :
9368 // Execute immediately if ready is not present
9369 selector( jQuery );
9370 }
9371
9372 if ( selector.selector !== undefined ) {
9373 this.selector = selector.selector;
9374 this.context = selector.context;
9375 }
9376
9377 return jQuery.makeArray( selector, this );
9378 };
9379
9380 // Give the init function the jQuery prototype for later instantiation
9381 init.prototype = jQuery.fn;
9382
9383 // Initialize central reference
9384 rootjQuery = jQuery( document );
9385
9386
9387 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
9388 // methods guaranteed to produce a unique set when starting from a unique set
9389 guaranteedUnique = {
9390 children: true,
9391 contents: true,
9392 next: true,
9393 prev: true
9394 };
9395
9396 jQuery.extend({
9397 dir: function( elem, dir, until ) {
9398 var matched = [],
9399 truncate = until !== undefined;
9400
9401 while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) {
9402 if ( elem.nodeType === 1 ) {
9403 if ( truncate && jQuery( elem ).is( until ) ) {
9404 break;
9405 }
9406 matched.push( elem );
9407 }
9408 }
9409 return matched;
9410 },
9411
9412 sibling: function( n, elem ) {
9413 var matched = [];
9414
9415 for ( ; n; n = n.nextSibling ) {
9416 if ( n.nodeType === 1 && n !== elem ) {
9417 matched.push( n );
9418 }
9419 }
9420
9421 return matched;
9422 }
9423 });
9424
9425 jQuery.fn.extend({
9426 has: function( target ) {
9427 var targets = jQuery( target, this ),
9428 l = targets.length;
9429
9430 return this.filter(function() {
9431 var i = 0;
9432 for ( ; i < l; i++ ) {
9433 if ( jQuery.contains( this, targets[i] ) ) {
9434 return true;
9435 }
9436 }
9437 });
9438 },
9439
9440 closest: function( selectors, context ) {
9441 var cur,
9442 i = 0,
9443 l = this.length,
9444 matched = [],
9445 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
9446 jQuery( selectors, context || this.context ) :
9447 0;
9448
9449 for ( ; i < l; i++ ) {
9450 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
9451 // Always skip document fragments
9452 if ( cur.nodeType < 11 && (pos ?
9453 pos.index(cur) > -1 :
9454
9455 // Don't pass non-elements to Sizzle
9456 cur.nodeType === 1 &&
9457 jQuery.find.matchesSelector(cur, selectors)) ) {
9458
9459 matched.push( cur );
9460 break;
9461 }
9462 }
9463 }
9464
9465 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
9466 },
9467
9468 // Determine the position of an element within
9469 // the matched set of elements
9470 index: function( elem ) {
9471
9472 // No argument, return index in parent
9473 if ( !elem ) {
9474 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
9475 }
9476
9477 // index in selector
9478 if ( typeof elem === "string" ) {
9479 return indexOf.call( jQuery( elem ), this[ 0 ] );
9480 }
9481
9482 // Locate the position of the desired element
9483 return indexOf.call( this,
9484
9485 // If it receives a jQuery object, the first element is used
9486 elem.jquery ? elem[ 0 ] : elem
9487 );
9488 },
9489
9490 add: function( selector, context ) {
9491 return this.pushStack(
9492 jQuery.unique(
9493 jQuery.merge( this.get(), jQuery( selector, context ) )
9494 )
9495 );
9496 },
9497
9498 addBack: function( selector ) {
9499 return this.add( selector == null ?
9500 this.prevObject : this.prevObject.filter(selector)
9501 );
9502 }
9503 });
9504
9505 function sibling( cur, dir ) {
9506 while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {}
9507 return cur;
9508 }
9509
9510 jQuery.each({
9511 parent: function( elem ) {
9512 var parent = elem.parentNode;
9513 return parent && parent.nodeType !== 11 ? parent : null;
9514 },
9515 parents: function( elem ) {
9516 return jQuery.dir( elem, "parentNode" );
9517 },
9518 parentsUntil: function( elem, i, until ) {
9519 return jQuery.dir( elem, "parentNode", until );
9520 },
9521 next: function( elem ) {
9522 return sibling( elem, "nextSibling" );
9523 },
9524 prev: function( elem ) {
9525 return sibling( elem, "previousSibling" );
9526 },
9527 nextAll: function( elem ) {
9528 return jQuery.dir( elem, "nextSibling" );
9529 },
9530 prevAll: function( elem ) {
9531 return jQuery.dir( elem, "previousSibling" );
9532 },
9533 nextUntil: function( elem, i, until ) {
9534 return jQuery.dir( elem, "nextSibling", until );
9535 },
9536 prevUntil: function( elem, i, until ) {
9537 return jQuery.dir( elem, "previousSibling", until );
9538 },
9539 siblings: function( elem ) {
9540 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
9541 },
9542 children: function( elem ) {
9543 return jQuery.sibling( elem.firstChild );
9544 },
9545 contents: function( elem ) {
9546 return elem.contentDocument || jQuery.merge( [], elem.childNodes );
9547 }
9548 }, function( name, fn ) {
9549 jQuery.fn[ name ] = function( until, selector ) {
9550 var matched = jQuery.map( this, fn, until );
9551
9552 if ( name.slice( -5 ) !== "Until" ) {
9553 selector = until;
9554 }
9555
9556 if ( selector && typeof selector === "string" ) {
9557 matched = jQuery.filter( selector, matched );
9558 }
9559
9560 if ( this.length > 1 ) {
9561 // Remove duplicates
9562 if ( !guaranteedUnique[ name ] ) {
9563 jQuery.unique( matched );
9564 }
9565
9566 // Reverse order for parents* and prev-derivatives
9567 if ( rparentsprev.test( name ) ) {
9568 matched.reverse();
9569 }
9570 }
9571
9572 return this.pushStack( matched );
9573 };
9574 });
9575 var rnotwhite = (/\S+/g);
9576
9577
9578
9579 // String to Object options format cache
9580 var optionsCache = {};
9581
9582 // Convert String-formatted options into Object-formatted ones and store in cache
9583 function createOptions( options ) {
9584 var object = optionsCache[ options ] = {};
9585 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
9586 object[ flag ] = true;
9587 });
9588 return object;
9589 }
9590
9591 /*
9592 * Create a callback list using the following parameters:
9593 *
9594 * options: an optional list of space-separated options that will change how
9595 * the callback list behaves or a more traditional option object
9596 *
9597 * By default a callback list will act like an event callback list and can be
9598 * "fired" multiple times.
9599 *
9600 * Possible options:
9601 *
9602 * once: will ensure the callback list can only be fired once (like a Deferred)
9603 *
9604 * memory: will keep track of previous values and will call any callback added
9605 * after the list has been fired right away with the latest "memorized"
9606 * values (like a Deferred)
9607 *
9608 * unique: will ensure a callback can only be added once (no duplicate in the list)
9609 *
9610 * stopOnFalse: interrupt callings when a callback returns false
9611 *
9612 */
9613 jQuery.Callbacks = function( options ) {
9614
9615 // Convert options from String-formatted to Object-formatted if needed
9616 // (we check in cache first)
9617 options = typeof options === "string" ?
9618 ( optionsCache[ options ] || createOptions( options ) ) :
9619 jQuery.extend( {}, options );
9620
9621 var // Last fire value (for non-forgettable lists)
9622 memory,
9623 // Flag to know if list was already fired
9624 fired,
9625 // Flag to know if list is currently firing
9626 firing,
9627 // First callback to fire (used internally by add and fireWith)
9628 firingStart,
9629 // End of the loop when firing
9630 firingLength,
9631 // Index of currently firing callback (modified by remove if needed)
9632 firingIndex,
9633 // Actual callback list
9634 list = [],
9635 // Stack of fire calls for repeatable lists
9636 stack = !options.once && [],
9637 // Fire callbacks
9638 fire = function( data ) {
9639 memory = options.memory && data;
9640 fired = true;
9641 firingIndex = firingStart || 0;
9642 firingStart = 0;
9643 firingLength = list.length;
9644 firing = true;
9645 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
9646 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
9647 memory = false; // To prevent further calls using add
9648 break;
9649 }
9650 }
9651 firing = false;
9652 if ( list ) {
9653 if ( stack ) {
9654 if ( stack.length ) {
9655 fire( stack.shift() );
9656 }
9657 } else if ( memory ) {
9658 list = [];
9659 } else {
9660 self.disable();
9661 }
9662 }
9663 },
9664 // Actual Callbacks object
9665 self = {
9666 // Add a callback or a collection of callbacks to the list
9667 add: function() {
9668 if ( list ) {
9669 // First, we save the current length
9670 var start = list.length;
9671 (function add( args ) {
9672 jQuery.each( args, function( _, arg ) {
9673 var type = jQuery.type( arg );
9674 if ( type === "function" ) {
9675 if ( !options.unique || !self.has( arg ) ) {
9676 list.push( arg );
9677 }
9678 } else if ( arg && arg.length && type !== "string" ) {
9679 // Inspect recursively
9680 add( arg );
9681 }
9682 });
9683 })( arguments );
9684 // Do we need to add the callbacks to the
9685 // current firing batch?
9686 if ( firing ) {
9687 firingLength = list.length;
9688 // With memory, if we're not firing then
9689 // we should call right away
9690 } else if ( memory ) {
9691 firingStart = start;
9692 fire( memory );
9693 }
9694 }
9695 return this;
9696 },
9697 // Remove a callback from the list
9698 remove: function() {
9699 if ( list ) {
9700 jQuery.each( arguments, function( _, arg ) {
9701 var index;
9702 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
9703 list.splice( index, 1 );
9704 // Handle firing indexes
9705 if ( firing ) {
9706 if ( index <= firingLength ) {
9707 firingLength--;
9708 }
9709 if ( index <= firingIndex ) {
9710 firingIndex--;
9711 }
9712 }
9713 }
9714 });
9715 }
9716 return this;
9717 },
9718 // Check if a given callback is in the list.
9719 // If no argument is given, return whether or not list has callbacks attached.
9720 has: function( fn ) {
9721 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
9722 },
9723 // Remove all callbacks from the list
9724 empty: function() {
9725 list = [];
9726 firingLength = 0;
9727 return this;
9728 },
9729 // Have the list do nothing anymore
9730 disable: function() {
9731 list = stack = memory = undefined;
9732 return this;
9733 },
9734 // Is it disabled?
9735 disabled: function() {
9736 return !list;
9737 },
9738 // Lock the list in its current state
9739 lock: function() {
9740 stack = undefined;
9741 if ( !memory ) {
9742 self.disable();
9743 }
9744 return this;
9745 },
9746 // Is it locked?
9747 locked: function() {
9748 return !stack;
9749 },
9750 // Call all callbacks with the given context and arguments
9751 fireWith: function( context, args ) {
9752 if ( list && ( !fired || stack ) ) {
9753 args = args || [];
9754 args = [ context, args.slice ? args.slice() : args ];
9755 if ( firing ) {
9756 stack.push( args );
9757 } else {
9758 fire( args );
9759 }
9760 }
9761 return this;
9762 },
9763 // Call all the callbacks with the given arguments
9764 fire: function() {
9765 self.fireWith( this, arguments );
9766 return this;
9767 },
9768 // To know if the callbacks have already been called at least once
9769 fired: function() {
9770 return !!fired;
9771 }
9772 };
9773
9774 return self;
9775 };
9776
9777
9778 jQuery.extend({
9779
9780 Deferred: function( func ) {
9781 var tuples = [
9782 // action, add listener, listener list, final state
9783 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
9784 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
9785 [ "notify", "progress", jQuery.Callbacks("memory") ]
9786 ],
9787 state = "pending",
9788 promise = {
9789 state: function() {
9790 return state;
9791 },
9792 always: function() {
9793 deferred.done( arguments ).fail( arguments );
9794 return this;
9795 },
9796 then: function( /* fnDone, fnFail, fnProgress */ ) {
9797 var fns = arguments;
9798 return jQuery.Deferred(function( newDefer ) {
9799 jQuery.each( tuples, function( i, tuple ) {
9800 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
9801 // deferred[ done | fail | progress ] for forwarding actions to newDefer
9802 deferred[ tuple[1] ](function() {
9803 var returned = fn && fn.apply( this, arguments );
9804 if ( returned && jQuery.isFunction( returned.promise ) ) {
9805 returned.promise()
9806 .done( newDefer.resolve )
9807 .fail( newDefer.reject )
9808 .progress( newDefer.notify );
9809 } else {
9810 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
9811 }
9812 });
9813 });
9814 fns = null;
9815 }).promise();
9816 },
9817 // Get a promise for this deferred
9818 // If obj is provided, the promise aspect is added to the object
9819 promise: function( obj ) {
9820 return obj != null ? jQuery.extend( obj, promise ) : promise;
9821 }
9822 },
9823 deferred = {};
9824
9825 // Keep pipe for back-compat
9826 promise.pipe = promise.then;
9827
9828 // Add list-specific methods
9829 jQuery.each( tuples, function( i, tuple ) {
9830 var list = tuple[ 2 ],
9831 stateString = tuple[ 3 ];
9832
9833 // promise[ done | fail | progress ] = list.add
9834 promise[ tuple[1] ] = list.add;
9835
9836 // Handle state
9837 if ( stateString ) {
9838 list.add(function() {
9839 // state = [ resolved | rejected ]
9840 state = stateString;
9841
9842 // [ reject_list | resolve_list ].disable; progress_list.lock
9843 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
9844 }
9845
9846 // deferred[ resolve | reject | notify ]
9847 deferred[ tuple[0] ] = function() {
9848 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
9849 return this;
9850 };
9851 deferred[ tuple[0] + "With" ] = list.fireWith;
9852 });
9853
9854 // Make the deferred a promise
9855 promise.promise( deferred );
9856
9857 // Call given func if any
9858 if ( func ) {
9859 func.call( deferred, deferred );
9860 }
9861
9862 // All done!
9863 return deferred;
9864 },
9865
9866 // Deferred helper
9867 when: function( subordinate /* , ..., subordinateN */ ) {
9868 var i = 0,
9869 resolveValues = slice.call( arguments ),
9870 length = resolveValues.length,
9871
9872 // the count of uncompleted subordinates
9873 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
9874
9875 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
9876 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
9877
9878 // Update function for both resolve and progress values
9879 updateFunc = function( i, contexts, values ) {
9880 return function( value ) {
9881 contexts[ i ] = this;
9882 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
9883 if ( values === progressValues ) {
9884 deferred.notifyWith( contexts, values );
9885 } else if ( !( --remaining ) ) {
9886 deferred.resolveWith( contexts, values );
9887 }
9888 };
9889 },
9890
9891 progressValues, progressContexts, resolveContexts;
9892
9893 // add listeners to Deferred subordinates; treat others as resolved
9894 if ( length > 1 ) {
9895 progressValues = new Array( length );
9896 progressContexts = new Array( length );
9897 resolveContexts = new Array( length );
9898 for ( ; i < length; i++ ) {
9899 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
9900 resolveValues[ i ].promise()
9901 .done( updateFunc( i, resolveContexts, resolveValues ) )
9902 .fail( deferred.reject )
9903 .progress( updateFunc( i, progressContexts, progressValues ) );
9904 } else {
9905 --remaining;
9906 }
9907 }
9908 }
9909
9910 // if we're not waiting on anything, resolve the master
9911 if ( !remaining ) {
9912 deferred.resolveWith( resolveContexts, resolveValues );
9913 }
9914
9915 return deferred.promise();
9916 }
9917 });
9918
9919
9920 // The deferred used on DOM ready
9921 var readyList;
9922
9923 jQuery.fn.ready = function( fn ) {
9924 // Add the callback
9925 jQuery.ready.promise().done( fn );
9926
9927 return this;
9928 };
9929
9930 jQuery.extend({
9931 // Is the DOM ready to be used? Set to true once it occurs.
9932 isReady: false,
9933
9934 // A counter to track how many items to wait for before
9935 // the ready event fires. See #6781
9936 readyWait: 1,
9937
9938 // Hold (or release) the ready event
9939 holdReady: function( hold ) {
9940 if ( hold ) {
9941 jQuery.readyWait++;
9942 } else {
9943 jQuery.ready( true );
9944 }
9945 },
9946
9947 // Handle when the DOM is ready
9948 ready: function( wait ) {
9949
9950 // Abort if there are pending holds or we're already ready
9951 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
9952 return;
9953 }
9954
9955 // Remember that the DOM is ready
9956 jQuery.isReady = true;
9957
9958 // If a normal DOM Ready event fired, decrement, and wait if need be
9959 if ( wait !== true && --jQuery.readyWait > 0 ) {
9960 return;
9961 }
9962
9963 // If there are functions bound, to execute
9964 readyList.resolveWith( document, [ jQuery ] );
9965
9966 // Trigger any bound ready events
9967 if ( jQuery.fn.triggerHandler ) {
9968 jQuery( document ).triggerHandler( "ready" );
9969 jQuery( document ).off( "ready" );
9970 }
9971 }
9972 });
9973
9974 /**
9975 * The ready event handler and self cleanup method
9976 */
9977 function completed() {
9978 document.removeEventListener( "DOMContentLoaded", completed, false );
9979 window.removeEventListener( "load", completed, false );
9980 jQuery.ready();
9981 }
9982
9983 jQuery.ready.promise = function( obj ) {
9984 if ( !readyList ) {
9985
9986 readyList = jQuery.Deferred();
9987
9988 // Catch cases where $(document).ready() is called after the browser event has already occurred.
9989 // we once tried to use readyState "interactive" here, but it caused issues like the one
9990 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
9991 if ( document.readyState === "complete" ) {
9992 // Handle it asynchronously to allow scripts the opportunity to delay ready
9993 setTimeout( jQuery.ready );
9994
9995 } else {
9996
9997 // Use the handy event callback
9998 document.addEventListener( "DOMContentLoaded", completed, false );
9999
10000 // A fallback to window.onload, that will always work
10001 window.addEventListener( "load", completed, false );
10002 }
10003 }
10004 return readyList.promise( obj );
10005 };
10006
10007 // Kick off the DOM ready check even if the user does not
10008 jQuery.ready.promise();
10009
10010
10011
10012
10013 // Multifunctional method to get and set values of a collection
10014 // The value/s can optionally be executed if it's a function
10015 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
10016 var i = 0,
10017 len = elems.length,
10018 bulk = key == null;
10019
10020 // Sets many values
10021 if ( jQuery.type( key ) === "object" ) {
10022 chainable = true;
10023 for ( i in key ) {
10024 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
10025 }
10026
10027 // Sets one value
10028 } else if ( value !== undefined ) {
10029 chainable = true;
10030
10031 if ( !jQuery.isFunction( value ) ) {
10032 raw = true;
10033 }
10034
10035 if ( bulk ) {
10036 // Bulk operations run against the entire set
10037 if ( raw ) {
10038 fn.call( elems, value );
10039 fn = null;
10040
10041 // ...except when executing function values
10042 } else {
10043 bulk = fn;
10044 fn = function( elem, key, value ) {
10045 return bulk.call( jQuery( elem ), value );
10046 };
10047 }
10048 }
10049
10050 if ( fn ) {
10051 for ( ; i < len; i++ ) {
10052 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
10053 }
10054 }
10055 }
10056
10057 return chainable ?
10058 elems :
10059
10060 // Gets
10061 bulk ?
10062 fn.call( elems ) :
10063 len ? fn( elems[0], key ) : emptyGet;
10064 };
10065
10066
10067 /**
10068 * Determines whether an object can have data
10069 */
10070 jQuery.acceptData = function( owner ) {
10071 // Accepts only:
10072 // - Node
10073 // - Node.ELEMENT_NODE
10074 // - Node.DOCUMENT_NODE
10075 // - Object
10076 // - Any
10077 /* jshint -W018 */
10078 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
10079 };
10080
10081
10082 function Data() {
10083 // Support: Android < 4,
10084 // Old WebKit does not have Object.preventExtensions/freeze method,
10085 // return new empty object instead with no [[set]] accessor
10086 Object.defineProperty( this.cache = {}, 0, {
10087 get: function() {
10088 return {};
10089 }
10090 });
10091
10092 this.expando = jQuery.expando + Math.random();
10093 }
10094
10095 Data.uid = 1;
10096 Data.accepts = jQuery.acceptData;
10097
10098 Data.prototype = {
10099 key: function( owner ) {
10100 // We can accept data for non-element nodes in modern browsers,
10101 // but we should not, see #8335.
10102 // Always return the key for a frozen object.
10103 if ( !Data.accepts( owner ) ) {
10104 return 0;
10105 }
10106
10107 var descriptor = {},
10108 // Check if the owner object already has a cache key
10109 unlock = owner[ this.expando ];
10110
10111 // If not, create one
10112 if ( !unlock ) {
10113 unlock = Data.uid++;
10114
10115 // Secure it in a non-enumerable, non-writable property
10116 try {
10117 descriptor[ this.expando ] = { value: unlock };
10118 Object.defineProperties( owner, descriptor );
10119
10120 // Support: Android < 4
10121 // Fallback to a less secure definition
10122 } catch ( e ) {
10123 descriptor[ this.expando ] = unlock;
10124 jQuery.extend( owner, descriptor );
10125 }
10126 }
10127
10128 // Ensure the cache object
10129 if ( !this.cache[ unlock ] ) {
10130 this.cache[ unlock ] = {};
10131 }
10132
10133 return unlock;
10134 },
10135 set: function( owner, data, value ) {
10136 var prop,
10137 // There may be an unlock assigned to this node,
10138 // if there is no entry for this "owner", create one inline
10139 // and set the unlock as though an owner entry had always existed
10140 unlock = this.key( owner ),
10141 cache = this.cache[ unlock ];
10142
10143 // Handle: [ owner, key, value ] args
10144 if ( typeof data === "string" ) {
10145 cache[ data ] = value;
10146
10147 // Handle: [ owner, { properties } ] args
10148 } else {
10149 // Fresh assignments by object are shallow copied
10150 if ( jQuery.isEmptyObject( cache ) ) {
10151 jQuery.extend( this.cache[ unlock ], data );
10152 // Otherwise, copy the properties one-by-one to the cache object
10153 } else {
10154 for ( prop in data ) {
10155 cache[ prop ] = data[ prop ];
10156 }
10157 }
10158 }
10159 return cache;
10160 },
10161 get: function( owner, key ) {
10162 // Either a valid cache is found, or will be created.
10163 // New caches will be created and the unlock returned,
10164 // allowing direct access to the newly created
10165 // empty data object. A valid owner object must be provided.
10166 var cache = this.cache[ this.key( owner ) ];
10167
10168 return key === undefined ?
10169 cache : cache[ key ];
10170 },
10171 access: function( owner, key, value ) {
10172 var stored;
10173 // In cases where either:
10174 //
10175 // 1. No key was specified
10176 // 2. A string key was specified, but no value provided
10177 //
10178 // Take the "read" path and allow the get method to determine
10179 // which value to return, respectively either:
10180 //
10181 // 1. The entire cache object
10182 // 2. The data stored at the key
10183 //
10184 if ( key === undefined ||
10185 ((key && typeof key === "string") && value === undefined) ) {
10186
10187 stored = this.get( owner, key );
10188
10189 return stored !== undefined ?
10190 stored : this.get( owner, jQuery.camelCase(key) );
10191 }
10192
10193 // [*]When the key is not a string, or both a key and value
10194 // are specified, set or extend (existing objects) with either:
10195 //
10196 // 1. An object of properties
10197 // 2. A key and value
10198 //
10199 this.set( owner, key, value );
10200
10201 // Since the "set" path can have two possible entry points
10202 // return the expected data based on which path was taken[*]
10203 return value !== undefined ? value : key;
10204 },
10205 remove: function( owner, key ) {
10206 var i, name, camel,
10207 unlock = this.key( owner ),
10208 cache = this.cache[ unlock ];
10209
10210 if ( key === undefined ) {
10211 this.cache[ unlock ] = {};
10212
10213 } else {
10214 // Support array or space separated string of keys
10215 if ( jQuery.isArray( key ) ) {
10216 // If "name" is an array of keys...
10217 // When data is initially created, via ("key", "val") signature,
10218 // keys will be converted to camelCase.
10219 // Since there is no way to tell _how_ a key was added, remove
10220 // both plain key and camelCase key. #12786
10221 // This will only penalize the array argument path.
10222 name = key.concat( key.map( jQuery.camelCase ) );
10223 } else {
10224 camel = jQuery.camelCase( key );
10225 // Try the string as a key before any manipulation
10226 if ( key in cache ) {
10227 name = [ key, camel ];
10228 } else {
10229 // If a key with the spaces exists, use it.
10230 // Otherwise, create an array by matching non-whitespace
10231 name = camel;
10232 name = name in cache ?
10233 [ name ] : ( name.match( rnotwhite ) || [] );
10234 }
10235 }
10236
10237 i = name.length;
10238 while ( i-- ) {
10239 delete cache[ name[ i ] ];
10240 }
10241 }
10242 },
10243 hasData: function( owner ) {
10244 return !jQuery.isEmptyObject(
10245 this.cache[ owner[ this.expando ] ] || {}
10246 );
10247 },
10248 discard: function( owner ) {
10249 if ( owner[ this.expando ] ) {
10250 delete this.cache[ owner[ this.expando ] ];
10251 }
10252 }
10253 };
10254 var data_priv = new Data();
10255
10256 var data_user = new Data();
10257
10258
10259
10260 /*
10261 Implementation Summary
10262
10263 1. Enforce API surface and semantic compatibility with 1.9.x branch
10264 2. Improve the module's maintainability by reducing the storage
10265 paths to a single mechanism.
10266 3. Use the same single mechanism to support "private" and "user" data.
10267 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
10268 5. Avoid exposing implementation details on user objects (eg. expando properties)
10269 6. Provide a clear path for implementation upgrade to WeakMap in 2014
10270 */
10271 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
10272 rmultiDash = /([A-Z])/g;
10273
10274 function dataAttr( elem, key, data ) {
10275 var name;
10276
10277 // If nothing was found internally, try to fetch any
10278 // data from the HTML5 data-* attribute
10279 if ( data === undefined && elem.nodeType === 1 ) {
10280 name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
10281 data = elem.getAttribute( name );
10282
10283 if ( typeof data === "string" ) {
10284 try {
10285 data = data === "true" ? true :
10286 data === "false" ? false :
10287 data === "null" ? null :
10288 // Only convert to a number if it doesn't change the string
10289 +data + "" === data ? +data :
10290 rbrace.test( data ) ? jQuery.parseJSON( data ) :
10291 data;
10292 } catch( e ) {}
10293
10294 // Make sure we set the data so it isn't changed later
10295 data_user.set( elem, key, data );
10296 } else {
10297 data = undefined;
10298 }
10299 }
10300 return data;
10301 }
10302
10303 jQuery.extend({
10304 hasData: function( elem ) {
10305 return data_user.hasData( elem ) || data_priv.hasData( elem );
10306 },
10307
10308 data: function( elem, name, data ) {
10309 return data_user.access( elem, name, data );
10310 },
10311
10312 removeData: function( elem, name ) {
10313 data_user.remove( elem, name );
10314 },
10315
10316 // TODO: Now that all calls to _data and _removeData have been replaced
10317 // with direct calls to data_priv methods, these can be deprecated.
10318 _data: function( elem, name, data ) {
10319 return data_priv.access( elem, name, data );
10320 },
10321
10322 _removeData: function( elem, name ) {
10323 data_priv.remove( elem, name );
10324 }
10325 });
10326
10327 jQuery.fn.extend({
10328 data: function( key, value ) {
10329 var i, name, data,
10330 elem = this[ 0 ],
10331 attrs = elem && elem.attributes;
10332
10333 // Gets all values
10334 if ( key === undefined ) {
10335 if ( this.length ) {
10336 data = data_user.get( elem );
10337
10338 if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
10339 i = attrs.length;
10340 while ( i-- ) {
10341
10342 // Support: IE11+
10343 // The attrs elements can be null (#14894)
10344 if ( attrs[ i ] ) {
10345 name = attrs[ i ].name;
10346 if ( name.indexOf( "data-" ) === 0 ) {
10347 name = jQuery.camelCase( name.slice(5) );
10348 dataAttr( elem, name, data[ name ] );
10349 }
10350 }
10351 }
10352 data_priv.set( elem, "hasDataAttrs", true );
10353 }
10354 }
10355
10356 return data;
10357 }
10358
10359 // Sets multiple values
10360 if ( typeof key === "object" ) {
10361 return this.each(function() {
10362 data_user.set( this, key );
10363 });
10364 }
10365
10366 return access( this, function( value ) {
10367 var data,
10368 camelKey = jQuery.camelCase( key );
10369
10370 // The calling jQuery object (element matches) is not empty
10371 // (and therefore has an element appears at this[ 0 ]) and the
10372 // `value` parameter was not undefined. An empty jQuery object
10373 // will result in `undefined` for elem = this[ 0 ] which will
10374 // throw an exception if an attempt to read a data cache is made.
10375 if ( elem && value === undefined ) {
10376 // Attempt to get data from the cache
10377 // with the key as-is
10378 data = data_user.get( elem, key );
10379 if ( data !== undefined ) {
10380 return data;
10381 }
10382
10383 // Attempt to get data from the cache
10384 // with the key camelized
10385 data = data_user.get( elem, camelKey );
10386 if ( data !== undefined ) {
10387 return data;
10388 }
10389
10390 // Attempt to "discover" the data in
10391 // HTML5 custom data-* attrs
10392 data = dataAttr( elem, camelKey, undefined );
10393 if ( data !== undefined ) {
10394 return data;
10395 }
10396
10397 // We tried really hard, but the data doesn't exist.
10398 return;
10399 }
10400
10401 // Set the data...
10402 this.each(function() {
10403 // First, attempt to store a copy or reference of any
10404 // data that might've been store with a camelCased key.
10405 var data = data_user.get( this, camelKey );
10406
10407 // For HTML5 data-* attribute interop, we have to
10408 // store property names with dashes in a camelCase form.
10409 // This might not apply to all properties...*
10410 data_user.set( this, camelKey, value );
10411
10412 // *... In the case of properties that might _actually_
10413 // have dashes, we need to also store a copy of that
10414 // unchanged property.
10415 if ( key.indexOf("-") !== -1 && data !== undefined ) {
10416 data_user.set( this, key, value );
10417 }
10418 });
10419 }, null, value, arguments.length > 1, null, true );
10420 },
10421
10422 removeData: function( key ) {
10423 return this.each(function() {
10424 data_user.remove( this, key );
10425 });
10426 }
10427 });
10428
10429
10430 jQuery.extend({
10431 queue: function( elem, type, data ) {
10432 var queue;
10433
10434 if ( elem ) {
10435 type = ( type || "fx" ) + "queue";
10436 queue = data_priv.get( elem, type );
10437
10438 // Speed up dequeue by getting out quickly if this is just a lookup
10439 if ( data ) {
10440 if ( !queue || jQuery.isArray( data ) ) {
10441 queue = data_priv.access( elem, type, jQuery.makeArray(data) );
10442 } else {
10443 queue.push( data );
10444 }
10445 }
10446 return queue || [];
10447 }
10448 },
10449
10450 dequeue: function( elem, type ) {
10451 type = type || "fx";
10452
10453 var queue = jQuery.queue( elem, type ),
10454 startLength = queue.length,
10455 fn = queue.shift(),
10456 hooks = jQuery._queueHooks( elem, type ),
10457 next = function() {
10458 jQuery.dequeue( elem, type );
10459 };
10460
10461 // If the fx queue is dequeued, always remove the progress sentinel
10462 if ( fn === "inprogress" ) {
10463 fn = queue.shift();
10464 startLength--;
10465 }
10466
10467 if ( fn ) {
10468
10469 // Add a progress sentinel to prevent the fx queue from being
10470 // automatically dequeued
10471 if ( type === "fx" ) {
10472 queue.unshift( "inprogress" );
10473 }
10474
10475 // clear up the last queue stop function
10476 delete hooks.stop;
10477 fn.call( elem, next, hooks );
10478 }
10479
10480 if ( !startLength && hooks ) {
10481 hooks.empty.fire();
10482 }
10483 },
10484
10485 // not intended for public consumption - generates a queueHooks object, or returns the current one
10486 _queueHooks: function( elem, type ) {
10487 var key = type + "queueHooks";
10488 return data_priv.get( elem, key ) || data_priv.access( elem, key, {
10489 empty: jQuery.Callbacks("once memory").add(function() {
10490 data_priv.remove( elem, [ type + "queue", key ] );
10491 })
10492 });
10493 }
10494 });
10495
10496 jQuery.fn.extend({
10497 queue: function( type, data ) {
10498 var setter = 2;
10499
10500 if ( typeof type !== "string" ) {
10501 data = type;
10502 type = "fx";
10503 setter--;
10504 }
10505
10506 if ( arguments.length < setter ) {
10507 return jQuery.queue( this[0], type );
10508 }
10509
10510 return data === undefined ?
10511 this :
10512 this.each(function() {
10513 var queue = jQuery.queue( this, type, data );
10514
10515 // ensure a hooks for this queue
10516 jQuery._queueHooks( this, type );
10517
10518 if ( type === "fx" && queue[0] !== "inprogress" ) {
10519 jQuery.dequeue( this, type );
10520 }
10521 });
10522 },
10523 dequeue: function( type ) {
10524 return this.each(function() {
10525 jQuery.dequeue( this, type );
10526 });
10527 },
10528 clearQueue: function( type ) {
10529 return this.queue( type || "fx", [] );
10530 },
10531 // Get a promise resolved when queues of a certain type
10532 // are emptied (fx is the type by default)
10533 promise: function( type, obj ) {
10534 var tmp,
10535 count = 1,
10536 defer = jQuery.Deferred(),
10537 elements = this,
10538 i = this.length,
10539 resolve = function() {
10540 if ( !( --count ) ) {
10541 defer.resolveWith( elements, [ elements ] );
10542 }
10543 };
10544
10545 if ( typeof type !== "string" ) {
10546 obj = type;
10547 type = undefined;
10548 }
10549 type = type || "fx";
10550
10551 while ( i-- ) {
10552 tmp = data_priv.get( elements[ i ], type + "queueHooks" );
10553 if ( tmp && tmp.empty ) {
10554 count++;
10555 tmp.empty.add( resolve );
10556 }
10557 }
10558 resolve();
10559 return defer.promise( obj );
10560 }
10561 });
10562 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
10563
10564 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
10565
10566 var isHidden = function( elem, el ) {
10567 // isHidden might be called from jQuery#filter function;
10568 // in that case, element will be second argument
10569 elem = el || elem;
10570 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
10571 };
10572
10573 var rcheckableType = (/^(?:checkbox|radio)$/i);
10574
10575
10576
10577 (function() {
10578 var fragment = document.createDocumentFragment(),
10579 div = fragment.appendChild( document.createElement( "div" ) ),
10580 input = document.createElement( "input" );
10581
10582 // #11217 - WebKit loses check when the name is after the checked attribute
10583 // Support: Windows Web Apps (WWA)
10584 // `name` and `type` need .setAttribute for WWA
10585 input.setAttribute( "type", "radio" );
10586 input.setAttribute( "checked", "checked" );
10587 input.setAttribute( "name", "t" );
10588
10589 div.appendChild( input );
10590
10591 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
10592 // old WebKit doesn't clone checked state correctly in fragments
10593 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
10594
10595 // Make sure textarea (and checkbox) defaultValue is properly cloned
10596 // Support: IE9-IE11+
10597 div.innerHTML = "<textarea>x</textarea>";
10598 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
10599 })();
10600 var strundefined = typeof undefined;
10601
10602
10603
10604 support.focusinBubbles = "onfocusin" in window;
10605
10606
10607 var
10608 rkeyEvent = /^key/,
10609 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
10610 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
10611 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
10612
10613 function returnTrue() {
10614 return true;
10615 }
10616
10617 function returnFalse() {
10618 return false;
10619 }
10620
10621 function safeActiveElement() {
10622 try {
10623 return document.activeElement;
10624 } catch ( err ) { }
10625 }
10626
10627 /*
10628 * Helper functions for managing events -- not part of the public interface.
10629 * Props to Dean Edwards' addEvent library for many of the ideas.
10630 */
10631 jQuery.event = {
10632
10633 global: {},
10634
10635 add: function( elem, types, handler, data, selector ) {
10636
10637 var handleObjIn, eventHandle, tmp,
10638 events, t, handleObj,
10639 special, handlers, type, namespaces, origType,
10640 elemData = data_priv.get( elem );
10641
10642 // Don't attach events to noData or text/comment nodes (but allow plain objects)
10643 if ( !elemData ) {
10644 return;
10645 }
10646
10647 // Caller can pass in an object of custom data in lieu of the handler
10648 if ( handler.handler ) {
10649 handleObjIn = handler;
10650 handler = handleObjIn.handler;
10651 selector = handleObjIn.selector;
10652 }
10653
10654 // Make sure that the handler has a unique ID, used to find/remove it later
10655 if ( !handler.guid ) {
10656 handler.guid = jQuery.guid++;
10657 }
10658
10659 // Init the element's event structure and main handler, if this is the first
10660 if ( !(events = elemData.events) ) {
10661 events = elemData.events = {};
10662 }
10663 if ( !(eventHandle = elemData.handle) ) {
10664 eventHandle = elemData.handle = function( e ) {
10665 // Discard the second event of a jQuery.event.trigger() and
10666 // when an event is called after a page has unloaded
10667 return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
10668 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
10669 };
10670 }
10671
10672 // Handle multiple events separated by a space
10673 types = ( types || "" ).match( rnotwhite ) || [ "" ];
10674 t = types.length;
10675 while ( t-- ) {
10676 tmp = rtypenamespace.exec( types[t] ) || [];
10677 type = origType = tmp[1];
10678 namespaces = ( tmp[2] || "" ).split( "." ).sort();
10679
10680 // There *must* be a type, no attaching namespace-only handlers
10681 if ( !type ) {
10682 continue;
10683 }
10684
10685 // If event changes its type, use the special event handlers for the changed type
10686 special = jQuery.event.special[ type ] || {};
10687
10688 // If selector defined, determine special event api type, otherwise given type
10689 type = ( selector ? special.delegateType : special.bindType ) || type;
10690
10691 // Update special based on newly reset type
10692 special = jQuery.event.special[ type ] || {};
10693
10694 // handleObj is passed to all event handlers
10695 handleObj = jQuery.extend({
10696 type: type,
10697 origType: origType,
10698 data: data,
10699 handler: handler,
10700 guid: handler.guid,
10701 selector: selector,
10702 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
10703 namespace: namespaces.join(".")
10704 }, handleObjIn );
10705
10706 // Init the event handler queue if we're the first
10707 if ( !(handlers = events[ type ]) ) {
10708 handlers = events[ type ] = [];
10709 handlers.delegateCount = 0;
10710
10711 // Only use addEventListener if the special events handler returns false
10712 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
10713 if ( elem.addEventListener ) {
10714 elem.addEventListener( type, eventHandle, false );
10715 }
10716 }
10717 }
10718
10719 if ( special.add ) {
10720 special.add.call( elem, handleObj );
10721
10722 if ( !handleObj.handler.guid ) {
10723 handleObj.handler.guid = handler.guid;
10724 }
10725 }
10726
10727 // Add to the element's handler list, delegates in front
10728 if ( selector ) {
10729 handlers.splice( handlers.delegateCount++, 0, handleObj );
10730 } else {
10731 handlers.push( handleObj );
10732 }
10733
10734 // Keep track of which events have ever been used, for event optimization
10735 jQuery.event.global[ type ] = true;
10736 }
10737
10738 },
10739
10740 // Detach an event or set of events from an element
10741 remove: function( elem, types, handler, selector, mappedTypes ) {
10742
10743 var j, origCount, tmp,
10744 events, t, handleObj,
10745 special, handlers, type, namespaces, origType,
10746 elemData = data_priv.hasData( elem ) && data_priv.get( elem );
10747
10748 if ( !elemData || !(events = elemData.events) ) {
10749 return;
10750 }
10751
10752 // Once for each type.namespace in types; type may be omitted
10753 types = ( types || "" ).match( rnotwhite ) || [ "" ];
10754 t = types.length;
10755 while ( t-- ) {
10756 tmp = rtypenamespace.exec( types[t] ) || [];
10757 type = origType = tmp[1];
10758 namespaces = ( tmp[2] || "" ).split( "." ).sort();
10759
10760 // Unbind all events (on this namespace, if provided) for the element
10761 if ( !type ) {
10762 for ( type in events ) {
10763 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
10764 }
10765 continue;
10766 }
10767
10768 special = jQuery.event.special[ type ] || {};
10769 type = ( selector ? special.delegateType : special.bindType ) || type;
10770 handlers = events[ type ] || [];
10771 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
10772
10773 // Remove matching events
10774 origCount = j = handlers.length;
10775 while ( j-- ) {
10776 handleObj = handlers[ j ];
10777
10778 if ( ( mappedTypes || origType === handleObj.origType ) &&
10779 ( !handler || handler.guid === handleObj.guid ) &&
10780 ( !tmp || tmp.test( handleObj.namespace ) ) &&
10781 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
10782 handlers.splice( j, 1 );
10783
10784 if ( handleObj.selector ) {
10785 handlers.delegateCount--;
10786 }
10787 if ( special.remove ) {
10788 special.remove.call( elem, handleObj );
10789 }
10790 }
10791 }
10792
10793 // Remove generic event handler if we removed something and no more handlers exist
10794 // (avoids potential for endless recursion during removal of special event handlers)
10795 if ( origCount && !handlers.length ) {
10796 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
10797 jQuery.removeEvent( elem, type, elemData.handle );
10798 }
10799
10800 delete events[ type ];
10801 }
10802 }
10803
10804 // Remove the expando if it's no longer used
10805 if ( jQuery.isEmptyObject( events ) ) {
10806 delete elemData.handle;
10807 data_priv.remove( elem, "events" );
10808 }
10809 },
10810
10811 trigger: function( event, data, elem, onlyHandlers ) {
10812
10813 var i, cur, tmp, bubbleType, ontype, handle, special,
10814 eventPath = [ elem || document ],
10815 type = hasOwn.call( event, "type" ) ? event.type : event,
10816 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
10817
10818 cur = tmp = elem = elem || document;
10819
10820 // Don't do events on text and comment nodes
10821 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
10822 return;
10823 }
10824
10825 // focus/blur morphs to focusin/out; ensure we're not firing them right now
10826 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
10827 return;
10828 }
10829
10830 if ( type.indexOf(".") >= 0 ) {
10831 // Namespaced trigger; create a regexp to match event type in handle()
10832 namespaces = type.split(".");
10833 type = namespaces.shift();
10834 namespaces.sort();
10835 }
10836 ontype = type.indexOf(":") < 0 && "on" + type;
10837
10838 // Caller can pass in a jQuery.Event object, Object, or just an event type string
10839 event = event[ jQuery.expando ] ?
10840 event :
10841 new jQuery.Event( type, typeof event === "object" && event );
10842
10843 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
10844 event.isTrigger = onlyHandlers ? 2 : 3;
10845 event.namespace = namespaces.join(".");
10846 event.namespace_re = event.namespace ?
10847 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
10848 null;
10849
10850 // Clean up the event in case it is being reused
10851 event.result = undefined;
10852 if ( !event.target ) {
10853 event.target = elem;
10854 }
10855
10856 // Clone any incoming data and prepend the event, creating the handler arg list
10857 data = data == null ?
10858 [ event ] :
10859 jQuery.makeArray( data, [ event ] );
10860
10861 // Allow special events to draw outside the lines
10862 special = jQuery.event.special[ type ] || {};
10863 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
10864 return;
10865 }
10866
10867 // Determine event propagation path in advance, per W3C events spec (#9951)
10868 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
10869 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
10870
10871 bubbleType = special.delegateType || type;
10872 if ( !rfocusMorph.test( bubbleType + type ) ) {
10873 cur = cur.parentNode;
10874 }
10875 for ( ; cur; cur = cur.parentNode ) {
10876 eventPath.push( cur );
10877 tmp = cur;
10878 }
10879
10880 // Only add window if we got to document (e.g., not plain obj or detached DOM)
10881 if ( tmp === (elem.ownerDocument || document) ) {
10882 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
10883 }
10884 }
10885
10886 // Fire handlers on the event path
10887 i = 0;
10888 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
10889
10890 event.type = i > 1 ?
10891 bubbleType :
10892 special.bindType || type;
10893
10894 // jQuery handler
10895 handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
10896 if ( handle ) {
10897 handle.apply( cur, data );
10898 }
10899
10900 // Native handler
10901 handle = ontype && cur[ ontype ];
10902 if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
10903 event.result = handle.apply( cur, data );
10904 if ( event.result === false ) {
10905 event.preventDefault();
10906 }
10907 }
10908 }
10909 event.type = type;
10910
10911 // If nobody prevented the default action, do it now
10912 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
10913
10914 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
10915 jQuery.acceptData( elem ) ) {
10916
10917 // Call a native DOM method on the target with the same name name as the event.
10918 // Don't do default actions on window, that's where global variables be (#6170)
10919 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
10920
10921 // Don't re-trigger an onFOO event when we call its FOO() method
10922 tmp = elem[ ontype ];
10923
10924 if ( tmp ) {
10925 elem[ ontype ] = null;
10926 }
10927
10928 // Prevent re-triggering of the same event, since we already bubbled it above
10929 jQuery.event.triggered = type;
10930 elem[ type ]();
10931 jQuery.event.triggered = undefined;
10932
10933 if ( tmp ) {
10934 elem[ ontype ] = tmp;
10935 }
10936 }
10937 }
10938 }
10939
10940 return event.result;
10941 },
10942
10943 dispatch: function( event ) {
10944
10945 // Make a writable jQuery.Event from the native event object
10946 event = jQuery.event.fix( event );
10947
10948 var i, j, ret, matched, handleObj,
10949 handlerQueue = [],
10950 args = slice.call( arguments ),
10951 handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
10952 special = jQuery.event.special[ event.type ] || {};
10953
10954 // Use the fix-ed jQuery.Event rather than the (read-only) native event
10955 args[0] = event;
10956 event.delegateTarget = this;
10957
10958 // Call the preDispatch hook for the mapped type, and let it bail if desired
10959 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
10960 return;
10961 }
10962
10963 // Determine handlers
10964 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
10965
10966 // Run delegates first; they may want to stop propagation beneath us
10967 i = 0;
10968 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
10969 event.currentTarget = matched.elem;
10970
10971 j = 0;
10972 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
10973
10974 // Triggered event must either 1) have no namespace, or
10975 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
10976 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
10977
10978 event.handleObj = handleObj;
10979 event.data = handleObj.data;
10980
10981 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
10982 .apply( matched.elem, args );
10983
10984 if ( ret !== undefined ) {
10985 if ( (event.result = ret) === false ) {
10986 event.preventDefault();
10987 event.stopPropagation();
10988 }
10989 }
10990 }
10991 }
10992 }
10993
10994 // Call the postDispatch hook for the mapped type
10995 if ( special.postDispatch ) {
10996 special.postDispatch.call( this, event );
10997 }
10998
10999 return event.result;
11000 },
11001
11002 handlers: function( event, handlers ) {
11003 var i, matches, sel, handleObj,
11004 handlerQueue = [],
11005 delegateCount = handlers.delegateCount,
11006 cur = event.target;
11007
11008 // Find delegate handlers
11009 // Black-hole SVG <use> instance trees (#13180)
11010 // Avoid non-left-click bubbling in Firefox (#3861)
11011 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
11012
11013 for ( ; cur !== this; cur = cur.parentNode || this ) {
11014
11015 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
11016 if ( cur.disabled !== true || event.type !== "click" ) {
11017 matches = [];
11018 for ( i = 0; i < delegateCount; i++ ) {
11019 handleObj = handlers[ i ];
11020
11021 // Don't conflict with Object.prototype properties (#13203)
11022 sel = handleObj.selector + " ";
11023
11024 if ( matches[ sel ] === undefined ) {
11025 matches[ sel ] = handleObj.needsContext ?
11026 jQuery( sel, this ).index( cur ) >= 0 :
11027 jQuery.find( sel, this, null, [ cur ] ).length;
11028 }
11029 if ( matches[ sel ] ) {
11030 matches.push( handleObj );
11031 }
11032 }
11033 if ( matches.length ) {
11034 handlerQueue.push({ elem: cur, handlers: matches });
11035 }
11036 }
11037 }
11038 }
11039
11040 // Add the remaining (directly-bound) handlers
11041 if ( delegateCount < handlers.length ) {
11042 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
11043 }
11044
11045 return handlerQueue;
11046 },
11047
11048 // Includes some event props shared by KeyEvent and MouseEvent
11049 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
11050
11051 fixHooks: {},
11052
11053 keyHooks: {
11054 props: "char charCode key keyCode".split(" "),
11055 filter: function( event, original ) {
11056
11057 // Add which for key events
11058 if ( event.which == null ) {
11059 event.which = original.charCode != null ? original.charCode : original.keyCode;
11060 }
11061
11062 return event;
11063 }
11064 },
11065
11066 mouseHooks: {
11067 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
11068 filter: function( event, original ) {
11069 var eventDoc, doc, body,
11070 button = original.button;
11071
11072 // Calculate pageX/Y if missing and clientX/Y available
11073 if ( event.pageX == null && original.clientX != null ) {
11074 eventDoc = event.target.ownerDocument || document;
11075 doc = eventDoc.documentElement;
11076 body = eventDoc.body;
11077
11078 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
11079 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
11080 }
11081
11082 // Add which for click: 1 === left; 2 === middle; 3 === right
11083 // Note: button is not normalized, so don't use it
11084 if ( !event.which && button !== undefined ) {
11085 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
11086 }
11087
11088 return event;
11089 }
11090 },
11091
11092 fix: function( event ) {
11093 if ( event[ jQuery.expando ] ) {
11094 return event;
11095 }
11096
11097 // Create a writable copy of the event object and normalize some properties
11098 var i, prop, copy,
11099 type = event.type,
11100 originalEvent = event,
11101 fixHook = this.fixHooks[ type ];
11102
11103 if ( !fixHook ) {
11104 this.fixHooks[ type ] = fixHook =
11105 rmouseEvent.test( type ) ? this.mouseHooks :
11106 rkeyEvent.test( type ) ? this.keyHooks :
11107 {};
11108 }
11109 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
11110
11111 event = new jQuery.Event( originalEvent );
11112
11113 i = copy.length;
11114 while ( i-- ) {
11115 prop = copy[ i ];
11116 event[ prop ] = originalEvent[ prop ];
11117 }
11118
11119 // Support: Cordova 2.5 (WebKit) (#13255)
11120 // All events should have a target; Cordova deviceready doesn't
11121 if ( !event.target ) {
11122 event.target = document;
11123 }
11124
11125 // Support: Safari 6.0+, Chrome < 28
11126 // Target should not be a text node (#504, #13143)
11127 if ( event.target.nodeType === 3 ) {
11128 event.target = event.target.parentNode;
11129 }
11130
11131 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
11132 },
11133
11134 special: {
11135 load: {
11136 // Prevent triggered image.load events from bubbling to window.load
11137 noBubble: true
11138 },
11139 focus: {
11140 // Fire native event if possible so blur/focus sequence is correct
11141 trigger: function() {
11142 if ( this !== safeActiveElement() && this.focus ) {
11143 this.focus();
11144 return false;
11145 }
11146 },
11147 delegateType: "focusin"
11148 },
11149 blur: {
11150 trigger: function() {
11151 if ( this === safeActiveElement() && this.blur ) {
11152 this.blur();
11153 return false;
11154 }
11155 },
11156 delegateType: "focusout"
11157 },
11158 click: {
11159 // For checkbox, fire native event so checked state will be right
11160 trigger: function() {
11161 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
11162 this.click();
11163 return false;
11164 }
11165 },
11166
11167 // For cross-browser consistency, don't fire native .click() on links
11168 _default: function( event ) {
11169 return jQuery.nodeName( event.target, "a" );
11170 }
11171 },
11172
11173 beforeunload: {
11174 postDispatch: function( event ) {
11175
11176 // Support: Firefox 20+
11177 // Firefox doesn't alert if the returnValue field is not set.
11178 if ( event.result !== undefined && event.originalEvent ) {
11179 event.originalEvent.returnValue = event.result;
11180 }
11181 }
11182 }
11183 },
11184
11185 simulate: function( type, elem, event, bubble ) {
11186 // Piggyback on a donor event to simulate a different one.
11187 // Fake originalEvent to avoid donor's stopPropagation, but if the
11188 // simulated event prevents default then we do the same on the donor.
11189 var e = jQuery.extend(
11190 new jQuery.Event(),
11191 event,
11192 {
11193 type: type,
11194 isSimulated: true,
11195 originalEvent: {}
11196 }
11197 );
11198 if ( bubble ) {
11199 jQuery.event.trigger( e, null, elem );
11200 } else {
11201 jQuery.event.dispatch.call( elem, e );
11202 }
11203 if ( e.isDefaultPrevented() ) {
11204 event.preventDefault();
11205 }
11206 }
11207 };
11208
11209 jQuery.removeEvent = function( elem, type, handle ) {
11210 if ( elem.removeEventListener ) {
11211 elem.removeEventListener( type, handle, false );
11212 }
11213 };
11214
11215 jQuery.Event = function( src, props ) {
11216 // Allow instantiation without the 'new' keyword
11217 if ( !(this instanceof jQuery.Event) ) {
11218 return new jQuery.Event( src, props );
11219 }
11220
11221 // Event object
11222 if ( src && src.type ) {
11223 this.originalEvent = src;
11224 this.type = src.type;
11225
11226 // Events bubbling up the document may have been marked as prevented
11227 // by a handler lower down the tree; reflect the correct value.
11228 this.isDefaultPrevented = src.defaultPrevented ||
11229 src.defaultPrevented === undefined &&
11230 // Support: Android < 4.0
11231 src.returnValue === false ?
11232 returnTrue :
11233 returnFalse;
11234
11235 // Event type
11236 } else {
11237 this.type = src;
11238 }
11239
11240 // Put explicitly provided properties onto the event object
11241 if ( props ) {
11242 jQuery.extend( this, props );
11243 }
11244
11245 // Create a timestamp if incoming event doesn't have one
11246 this.timeStamp = src && src.timeStamp || jQuery.now();
11247
11248 // Mark it as fixed
11249 this[ jQuery.expando ] = true;
11250 };
11251
11252 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
11253 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
11254 jQuery.Event.prototype = {
11255 isDefaultPrevented: returnFalse,
11256 isPropagationStopped: returnFalse,
11257 isImmediatePropagationStopped: returnFalse,
11258
11259 preventDefault: function() {
11260 var e = this.originalEvent;
11261
11262 this.isDefaultPrevented = returnTrue;
11263
11264 if ( e && e.preventDefault ) {
11265 e.preventDefault();
11266 }
11267 },
11268 stopPropagation: function() {
11269 var e = this.originalEvent;
11270
11271 this.isPropagationStopped = returnTrue;
11272
11273 if ( e && e.stopPropagation ) {
11274 e.stopPropagation();
11275 }
11276 },
11277 stopImmediatePropagation: function() {
11278 var e = this.originalEvent;
11279
11280 this.isImmediatePropagationStopped = returnTrue;
11281
11282 if ( e && e.stopImmediatePropagation ) {
11283 e.stopImmediatePropagation();
11284 }
11285
11286 this.stopPropagation();
11287 }
11288 };
11289
11290 // Create mouseenter/leave events using mouseover/out and event-time checks
11291 // Support: Chrome 15+
11292 jQuery.each({
11293 mouseenter: "mouseover",
11294 mouseleave: "mouseout",
11295 pointerenter: "pointerover",
11296 pointerleave: "pointerout"
11297 }, function( orig, fix ) {
11298 jQuery.event.special[ orig ] = {
11299 delegateType: fix,
11300 bindType: fix,
11301
11302 handle: function( event ) {
11303 var ret,
11304 target = this,
11305 related = event.relatedTarget,
11306 handleObj = event.handleObj;
11307
11308 // For mousenter/leave call the handler if related is outside the target.
11309 // NB: No relatedTarget if the mouse left/entered the browser window
11310 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
11311 event.type = handleObj.origType;
11312 ret = handleObj.handler.apply( this, arguments );
11313 event.type = fix;
11314 }
11315 return ret;
11316 }
11317 };
11318 });
11319
11320 // Create "bubbling" focus and blur events
11321 // Support: Firefox, Chrome, Safari
11322 if ( !support.focusinBubbles ) {
11323 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
11324
11325 // Attach a single capturing handler on the document while someone wants focusin/focusout
11326 var handler = function( event ) {
11327 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
11328 };
11329
11330 jQuery.event.special[ fix ] = {
11331 setup: function() {
11332 var doc = this.ownerDocument || this,
11333 attaches = data_priv.access( doc, fix );
11334
11335 if ( !attaches ) {
11336 doc.addEventListener( orig, handler, true );
11337 }
11338 data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
11339 },
11340 teardown: function() {
11341 var doc = this.ownerDocument || this,
11342 attaches = data_priv.access( doc, fix ) - 1;
11343
11344 if ( !attaches ) {
11345 doc.removeEventListener( orig, handler, true );
11346 data_priv.remove( doc, fix );
11347
11348 } else {
11349 data_priv.access( doc, fix, attaches );
11350 }
11351 }
11352 };
11353 });
11354 }
11355
11356 jQuery.fn.extend({
11357
11358 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
11359 var origFn, type;
11360
11361 // Types can be a map of types/handlers
11362 if ( typeof types === "object" ) {
11363 // ( types-Object, selector, data )
11364 if ( typeof selector !== "string" ) {
11365 // ( types-Object, data )
11366 data = data || selector;
11367 selector = undefined;
11368 }
11369 for ( type in types ) {
11370 this.on( type, selector, data, types[ type ], one );
11371 }
11372 return this;
11373 }
11374
11375 if ( data == null && fn == null ) {
11376 // ( types, fn )
11377 fn = selector;
11378 data = selector = undefined;
11379 } else if ( fn == null ) {
11380 if ( typeof selector === "string" ) {
11381 // ( types, selector, fn )
11382 fn = data;
11383 data = undefined;
11384 } else {
11385 // ( types, data, fn )
11386 fn = data;
11387 data = selector;
11388 selector = undefined;
11389 }
11390 }
11391 if ( fn === false ) {
11392 fn = returnFalse;
11393 } else if ( !fn ) {
11394 return this;
11395 }
11396
11397 if ( one === 1 ) {
11398 origFn = fn;
11399 fn = function( event ) {
11400 // Can use an empty set, since event contains the info
11401 jQuery().off( event );
11402 return origFn.apply( this, arguments );
11403 };
11404 // Use same guid so caller can remove using origFn
11405 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
11406 }
11407 return this.each( function() {
11408 jQuery.event.add( this, types, fn, data, selector );
11409 });
11410 },
11411 one: function( types, selector, data, fn ) {
11412 return this.on( types, selector, data, fn, 1 );
11413 },
11414 off: function( types, selector, fn ) {
11415 var handleObj, type;
11416 if ( types && types.preventDefault && types.handleObj ) {
11417 // ( event ) dispatched jQuery.Event
11418 handleObj = types.handleObj;
11419 jQuery( types.delegateTarget ).off(
11420 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
11421 handleObj.selector,
11422 handleObj.handler
11423 );
11424 return this;
11425 }
11426 if ( typeof types === "object" ) {
11427 // ( types-object [, selector] )
11428 for ( type in types ) {
11429 this.off( type, selector, types[ type ] );
11430 }
11431 return this;
11432 }
11433 if ( selector === false || typeof selector === "function" ) {
11434 // ( types [, fn] )
11435 fn = selector;
11436 selector = undefined;
11437 }
11438 if ( fn === false ) {
11439 fn = returnFalse;
11440 }
11441 return this.each(function() {
11442 jQuery.event.remove( this, types, fn, selector );
11443 });
11444 },
11445
11446 trigger: function( type, data ) {
11447 return this.each(function() {
11448 jQuery.event.trigger( type, data, this );
11449 });
11450 },
11451 triggerHandler: function( type, data ) {
11452 var elem = this[0];
11453 if ( elem ) {
11454 return jQuery.event.trigger( type, data, elem, true );
11455 }
11456 }
11457 });
11458
11459
11460 var
11461 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
11462 rtagName = /<([\w:]+)/,
11463 rhtml = /<|&#?\w+;/,
11464 rnoInnerhtml = /<(?:script|style|link)/i,
11465 // checked="checked" or checked
11466 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
11467 rscriptType = /^$|\/(?:java|ecma)script/i,
11468 rscriptTypeMasked = /^true\/(.*)/,
11469 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
11470
11471 // We have to close these tags to support XHTML (#13200)
11472 wrapMap = {
11473
11474 // Support: IE 9
11475 option: [ 1, "<select multiple='multiple'>", "</select>" ],
11476
11477 thead: [ 1, "<table>", "</table>" ],
11478 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
11479 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
11480 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
11481
11482 _default: [ 0, "", "" ]
11483 };
11484
11485 // Support: IE 9
11486 wrapMap.optgroup = wrapMap.option;
11487
11488 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
11489 wrapMap.th = wrapMap.td;
11490
11491 // Support: 1.x compatibility
11492 // Manipulating tables requires a tbody
11493 function manipulationTarget( elem, content ) {
11494 return jQuery.nodeName( elem, "table" ) &&
11495 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
11496
11497 elem.getElementsByTagName("tbody")[0] ||
11498 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
11499 elem;
11500 }
11501
11502 // Replace/restore the type attribute of script elements for safe DOM manipulation
11503 function disableScript( elem ) {
11504 elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
11505 return elem;
11506 }
11507 function restoreScript( elem ) {
11508 var match = rscriptTypeMasked.exec( elem.type );
11509
11510 if ( match ) {
11511 elem.type = match[ 1 ];
11512 } else {
11513 elem.removeAttribute("type");
11514 }
11515
11516 return elem;
11517 }
11518
11519 // Mark scripts as having already been evaluated
11520 function setGlobalEval( elems, refElements ) {
11521 var i = 0,
11522 l = elems.length;
11523
11524 for ( ; i < l; i++ ) {
11525 data_priv.set(
11526 elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
11527 );
11528 }
11529 }
11530
11531 function cloneCopyEvent( src, dest ) {
11532 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
11533
11534 if ( dest.nodeType !== 1 ) {
11535 return;
11536 }
11537
11538 // 1. Copy private data: events, handlers, etc.
11539 if ( data_priv.hasData( src ) ) {
11540 pdataOld = data_priv.access( src );
11541 pdataCur = data_priv.set( dest, pdataOld );
11542 events = pdataOld.events;
11543
11544 if ( events ) {
11545 delete pdataCur.handle;
11546 pdataCur.events = {};
11547
11548 for ( type in events ) {
11549 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
11550 jQuery.event.add( dest, type, events[ type ][ i ] );
11551 }
11552 }
11553 }
11554 }
11555
11556 // 2. Copy user data
11557 if ( data_user.hasData( src ) ) {
11558 udataOld = data_user.access( src );
11559 udataCur = jQuery.extend( {}, udataOld );
11560
11561 data_user.set( dest, udataCur );
11562 }
11563 }
11564
11565 function getAll( context, tag ) {
11566 var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
11567 context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
11568 [];
11569
11570 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
11571 jQuery.merge( [ context ], ret ) :
11572 ret;
11573 }
11574
11575 // Support: IE >= 9
11576 function fixInput( src, dest ) {
11577 var nodeName = dest.nodeName.toLowerCase();
11578
11579 // Fails to persist the checked state of a cloned checkbox or radio button.
11580 if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
11581 dest.checked = src.checked;
11582
11583 // Fails to return the selected option to the default selected state when cloning options
11584 } else if ( nodeName === "input" || nodeName === "textarea" ) {
11585 dest.defaultValue = src.defaultValue;
11586 }
11587 }
11588
11589 jQuery.extend({
11590 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
11591 var i, l, srcElements, destElements,
11592 clone = elem.cloneNode( true ),
11593 inPage = jQuery.contains( elem.ownerDocument, elem );
11594
11595 // Support: IE >= 9
11596 // Fix Cloning issues
11597 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
11598 !jQuery.isXMLDoc( elem ) ) {
11599
11600 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
11601 destElements = getAll( clone );
11602 srcElements = getAll( elem );
11603
11604 for ( i = 0, l = srcElements.length; i < l; i++ ) {
11605 fixInput( srcElements[ i ], destElements[ i ] );
11606 }
11607 }
11608
11609 // Copy the events from the original to the clone
11610 if ( dataAndEvents ) {
11611 if ( deepDataAndEvents ) {
11612 srcElements = srcElements || getAll( elem );
11613 destElements = destElements || getAll( clone );
11614
11615 for ( i = 0, l = srcElements.length; i < l; i++ ) {
11616 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
11617 }
11618 } else {
11619 cloneCopyEvent( elem, clone );
11620 }
11621 }
11622
11623 // Preserve script evaluation history
11624 destElements = getAll( clone, "script" );
11625 if ( destElements.length > 0 ) {
11626 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
11627 }
11628
11629 // Return the cloned set
11630 return clone;
11631 },
11632
11633 buildFragment: function( elems, context, scripts, selection ) {
11634 var elem, tmp, tag, wrap, contains, j,
11635 fragment = context.createDocumentFragment(),
11636 nodes = [],
11637 i = 0,
11638 l = elems.length;
11639
11640 for ( ; i < l; i++ ) {
11641 elem = elems[ i ];
11642
11643 if ( elem || elem === 0 ) {
11644
11645 // Add nodes directly
11646 if ( jQuery.type( elem ) === "object" ) {
11647 // Support: QtWebKit
11648 // jQuery.merge because push.apply(_, arraylike) throws
11649 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
11650
11651 // Convert non-html into a text node
11652 } else if ( !rhtml.test( elem ) ) {
11653 nodes.push( context.createTextNode( elem ) );
11654
11655 // Convert html into DOM nodes
11656 } else {
11657 tmp = tmp || fragment.appendChild( context.createElement("div") );
11658
11659 // Deserialize a standard representation
11660 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
11661 wrap = wrapMap[ tag ] || wrapMap._default;
11662 tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
11663
11664 // Descend through wrappers to the right content
11665 j = wrap[ 0 ];
11666 while ( j-- ) {
11667 tmp = tmp.lastChild;
11668 }
11669
11670 // Support: QtWebKit
11671 // jQuery.merge because push.apply(_, arraylike) throws
11672 jQuery.merge( nodes, tmp.childNodes );
11673
11674 // Remember the top-level container
11675 tmp = fragment.firstChild;
11676
11677 // Fixes #12346
11678 // Support: Webkit, IE
11679 tmp.textContent = "";
11680 }
11681 }
11682 }
11683
11684 // Remove wrapper from fragment
11685 fragment.textContent = "";
11686
11687 i = 0;
11688 while ( (elem = nodes[ i++ ]) ) {
11689
11690 // #4087 - If origin and destination elements are the same, and this is
11691 // that element, do not do anything
11692 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
11693 continue;
11694 }
11695
11696 contains = jQuery.contains( elem.ownerDocument, elem );
11697
11698 // Append to fragment
11699 tmp = getAll( fragment.appendChild( elem ), "script" );
11700
11701 // Preserve script evaluation history
11702 if ( contains ) {
11703 setGlobalEval( tmp );
11704 }
11705
11706 // Capture executables
11707 if ( scripts ) {
11708 j = 0;
11709 while ( (elem = tmp[ j++ ]) ) {
11710 if ( rscriptType.test( elem.type || "" ) ) {
11711 scripts.push( elem );
11712 }
11713 }
11714 }
11715 }
11716
11717 return fragment;
11718 },
11719
11720 cleanData: function( elems ) {
11721 var data, elem, type, key,
11722 special = jQuery.event.special,
11723 i = 0;
11724
11725 for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
11726 if ( jQuery.acceptData( elem ) ) {
11727 key = elem[ data_priv.expando ];
11728
11729 if ( key && (data = data_priv.cache[ key ]) ) {
11730 if ( data.events ) {
11731 for ( type in data.events ) {
11732 if ( special[ type ] ) {
11733 jQuery.event.remove( elem, type );
11734
11735 // This is a shortcut to avoid jQuery.event.remove's overhead
11736 } else {
11737 jQuery.removeEvent( elem, type, data.handle );
11738 }
11739 }
11740 }
11741 if ( data_priv.cache[ key ] ) {
11742 // Discard any remaining `private` data
11743 delete data_priv.cache[ key ];
11744 }
11745 }
11746 }
11747 // Discard any remaining `user` data
11748 delete data_user.cache[ elem[ data_user.expando ] ];
11749 }
11750 }
11751 });
11752
11753 jQuery.fn.extend({
11754 text: function( value ) {
11755 return access( this, function( value ) {
11756 return value === undefined ?
11757 jQuery.text( this ) :
11758 this.empty().each(function() {
11759 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11760 this.textContent = value;
11761 }
11762 });
11763 }, null, value, arguments.length );
11764 },
11765
11766 append: function() {
11767 return this.domManip( arguments, function( elem ) {
11768 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11769 var target = manipulationTarget( this, elem );
11770 target.appendChild( elem );
11771 }
11772 });
11773 },
11774
11775 prepend: function() {
11776 return this.domManip( arguments, function( elem ) {
11777 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11778 var target = manipulationTarget( this, elem );
11779 target.insertBefore( elem, target.firstChild );
11780 }
11781 });
11782 },
11783
11784 before: function() {
11785 return this.domManip( arguments, function( elem ) {
11786 if ( this.parentNode ) {
11787 this.parentNode.insertBefore( elem, this );
11788 }
11789 });
11790 },
11791
11792 after: function() {
11793 return this.domManip( arguments, function( elem ) {
11794 if ( this.parentNode ) {
11795 this.parentNode.insertBefore( elem, this.nextSibling );
11796 }
11797 });
11798 },
11799
11800 remove: function( selector, keepData /* Internal Use Only */ ) {
11801 var elem,
11802 elems = selector ? jQuery.filter( selector, this ) : this,
11803 i = 0;
11804
11805 for ( ; (elem = elems[i]) != null; i++ ) {
11806 if ( !keepData && elem.nodeType === 1 ) {
11807 jQuery.cleanData( getAll( elem ) );
11808 }
11809
11810 if ( elem.parentNode ) {
11811 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
11812 setGlobalEval( getAll( elem, "script" ) );
11813 }
11814 elem.parentNode.removeChild( elem );
11815 }
11816 }
11817
11818 return this;
11819 },
11820
11821 empty: function() {
11822 var elem,
11823 i = 0;
11824
11825 for ( ; (elem = this[i]) != null; i++ ) {
11826 if ( elem.nodeType === 1 ) {
11827
11828 // Prevent memory leaks
11829 jQuery.cleanData( getAll( elem, false ) );
11830
11831 // Remove any remaining nodes
11832 elem.textContent = "";
11833 }
11834 }
11835
11836 return this;
11837 },
11838
11839 clone: function( dataAndEvents, deepDataAndEvents ) {
11840 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
11841 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
11842
11843 return this.map(function() {
11844 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
11845 });
11846 },
11847
11848 html: function( value ) {
11849 return access( this, function( value ) {
11850 var elem = this[ 0 ] || {},
11851 i = 0,
11852 l = this.length;
11853
11854 if ( value === undefined && elem.nodeType === 1 ) {
11855 return elem.innerHTML;
11856 }
11857
11858 // See if we can take a shortcut and just use innerHTML
11859 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
11860 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
11861
11862 value = value.replace( rxhtmlTag, "<$1></$2>" );
11863
11864 try {
11865 for ( ; i < l; i++ ) {
11866 elem = this[ i ] || {};
11867
11868 // Remove element nodes and prevent memory leaks
11869 if ( elem.nodeType === 1 ) {
11870 jQuery.cleanData( getAll( elem, false ) );
11871 elem.innerHTML = value;
11872 }
11873 }
11874
11875 elem = 0;
11876
11877 // If using innerHTML throws an exception, use the fallback method
11878 } catch( e ) {}
11879 }
11880
11881 if ( elem ) {
11882 this.empty().append( value );
11883 }
11884 }, null, value, arguments.length );
11885 },
11886
11887 replaceWith: function() {
11888 var arg = arguments[ 0 ];
11889
11890 // Make the changes, replacing each context element with the new content
11891 this.domManip( arguments, function( elem ) {
11892 arg = this.parentNode;
11893
11894 jQuery.cleanData( getAll( this ) );
11895
11896 if ( arg ) {
11897 arg.replaceChild( elem, this );
11898 }
11899 });
11900
11901 // Force removal if there was no new content (e.g., from empty arguments)
11902 return arg && (arg.length || arg.nodeType) ? this : this.remove();
11903 },
11904
11905 detach: function( selector ) {
11906 return this.remove( selector, true );
11907 },
11908
11909 domManip: function( args, callback ) {
11910
11911 // Flatten any nested arrays
11912 args = concat.apply( [], args );
11913
11914 var fragment, first, scripts, hasScripts, node, doc,
11915 i = 0,
11916 l = this.length,
11917 set = this,
11918 iNoClone = l - 1,
11919 value = args[ 0 ],
11920 isFunction = jQuery.isFunction( value );
11921
11922 // We can't cloneNode fragments that contain checked, in WebKit
11923 if ( isFunction ||
11924 ( l > 1 && typeof value === "string" &&
11925 !support.checkClone && rchecked.test( value ) ) ) {
11926 return this.each(function( index ) {
11927 var self = set.eq( index );
11928 if ( isFunction ) {
11929 args[ 0 ] = value.call( this, index, self.html() );
11930 }
11931 self.domManip( args, callback );
11932 });
11933 }
11934
11935 if ( l ) {
11936 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
11937 first = fragment.firstChild;
11938
11939 if ( fragment.childNodes.length === 1 ) {
11940 fragment = first;
11941 }
11942
11943 if ( first ) {
11944 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
11945 hasScripts = scripts.length;
11946
11947 // Use the original fragment for the last item instead of the first because it can end up
11948 // being emptied incorrectly in certain situations (#8070).
11949 for ( ; i < l; i++ ) {
11950 node = fragment;
11951
11952 if ( i !== iNoClone ) {
11953 node = jQuery.clone( node, true, true );
11954
11955 // Keep references to cloned scripts for later restoration
11956 if ( hasScripts ) {
11957 // Support: QtWebKit
11958 // jQuery.merge because push.apply(_, arraylike) throws
11959 jQuery.merge( scripts, getAll( node, "script" ) );
11960 }
11961 }
11962
11963 callback.call( this[ i ], node, i );
11964 }
11965
11966 if ( hasScripts ) {
11967 doc = scripts[ scripts.length - 1 ].ownerDocument;
11968
11969 // Reenable scripts
11970 jQuery.map( scripts, restoreScript );
11971
11972 // Evaluate executable scripts on first document insertion
11973 for ( i = 0; i < hasScripts; i++ ) {
11974 node = scripts[ i ];
11975 if ( rscriptType.test( node.type || "" ) &&
11976 !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
11977
11978 if ( node.src ) {
11979 // Optional AJAX dependency, but won't run scripts if not present
11980 if ( jQuery._evalUrl ) {
11981 jQuery._evalUrl( node.src );
11982 }
11983 } else {
11984 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
11985 }
11986 }
11987 }
11988 }
11989 }
11990 }
11991
11992 return this;
11993 }
11994 });
11995
11996 jQuery.each({
11997 appendTo: "append",
11998 prependTo: "prepend",
11999 insertBefore: "before",
12000 insertAfter: "after",
12001 replaceAll: "replaceWith"
12002 }, function( name, original ) {
12003 jQuery.fn[ name ] = function( selector ) {
12004 var elems,
12005 ret = [],
12006 insert = jQuery( selector ),
12007 last = insert.length - 1,
12008 i = 0;
12009
12010 for ( ; i <= last; i++ ) {
12011 elems = i === last ? this : this.clone( true );
12012 jQuery( insert[ i ] )[ original ]( elems );
12013
12014 // Support: QtWebKit
12015 // .get() because push.apply(_, arraylike) throws
12016 push.apply( ret, elems.get() );
12017 }
12018
12019 return this.pushStack( ret );
12020 };
12021 });
12022
12023
12024 var iframe,
12025 elemdisplay = {};
12026
12027 /**
12028 * Retrieve the actual display of a element
12029 * @param {String} name nodeName of the element
12030 * @param {Object} doc Document object
12031 */
12032 // Called only from within defaultDisplay
12033 function actualDisplay( name, doc ) {
12034 var style,
12035 elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
12036
12037 // getDefaultComputedStyle might be reliably used only on attached element
12038 display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
12039
12040 // Use of this method is a temporary fix (more like optmization) until something better comes along,
12041 // since it was removed from specification and supported only in FF
12042 style.display : jQuery.css( elem[ 0 ], "display" );
12043
12044 // We don't have any data stored on the element,
12045 // so use "detach" method as fast way to get rid of the element
12046 elem.detach();
12047
12048 return display;
12049 }
12050
12051 /**
12052 * Try to determine the default display value of an element
12053 * @param {String} nodeName
12054 */
12055 function defaultDisplay( nodeName ) {
12056 var doc = document,
12057 display = elemdisplay[ nodeName ];
12058
12059 if ( !display ) {
12060 display = actualDisplay( nodeName, doc );
12061
12062 // If the simple way fails, read from inside an iframe
12063 if ( display === "none" || !display ) {
12064
12065 // Use the already-created iframe if possible
12066 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
12067
12068 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
12069 doc = iframe[ 0 ].contentDocument;
12070
12071 // Support: IE
12072 doc.write();
12073 doc.close();
12074
12075 display = actualDisplay( nodeName, doc );
12076 iframe.detach();
12077 }
12078
12079 // Store the correct default display
12080 elemdisplay[ nodeName ] = display;
12081 }
12082
12083 return display;
12084 }
12085 var rmargin = (/^margin/);
12086
12087 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
12088
12089 var getStyles = function( elem ) {
12090 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
12091 };
12092
12093
12094
12095 function curCSS( elem, name, computed ) {
12096 var width, minWidth, maxWidth, ret,
12097 style = elem.style;
12098
12099 computed = computed || getStyles( elem );
12100
12101 // Support: IE9
12102 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
12103 if ( computed ) {
12104 ret = computed.getPropertyValue( name ) || computed[ name ];
12105 }
12106
12107 if ( computed ) {
12108
12109 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
12110 ret = jQuery.style( elem, name );
12111 }
12112
12113 // Support: iOS < 6
12114 // A tribute to the "awesome hack by Dean Edwards"
12115 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
12116 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
12117 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
12118
12119 // Remember the original values
12120 width = style.width;
12121 minWidth = style.minWidth;
12122 maxWidth = style.maxWidth;
12123
12124 // Put in the new values to get a computed value out
12125 style.minWidth = style.maxWidth = style.width = ret;
12126 ret = computed.width;
12127
12128 // Revert the changed values
12129 style.width = width;
12130 style.minWidth = minWidth;
12131 style.maxWidth = maxWidth;
12132 }
12133 }
12134
12135 return ret !== undefined ?
12136 // Support: IE
12137 // IE returns zIndex value as an integer.
12138 ret + "" :
12139 ret;
12140 }
12141
12142
12143 function addGetHookIf( conditionFn, hookFn ) {
12144 // Define the hook, we'll check on the first run if it's really needed.
12145 return {
12146 get: function() {
12147 if ( conditionFn() ) {
12148 // Hook not needed (or it's not possible to use it due to missing dependency),
12149 // remove it.
12150 // Since there are no other hooks for marginRight, remove the whole object.
12151 delete this.get;
12152 return;
12153 }
12154
12155 // Hook needed; redefine it so that the support test is not executed again.
12156
12157 return (this.get = hookFn).apply( this, arguments );
12158 }
12159 };
12160 }
12161
12162
12163 (function() {
12164 var pixelPositionVal, boxSizingReliableVal,
12165 docElem = document.documentElement,
12166 container = document.createElement( "div" ),
12167 div = document.createElement( "div" );
12168
12169 if ( !div.style ) {
12170 return;
12171 }
12172
12173 div.style.backgroundClip = "content-box";
12174 div.cloneNode( true ).style.backgroundClip = "";
12175 support.clearCloneStyle = div.style.backgroundClip === "content-box";
12176
12177 container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" +
12178 "position:absolute";
12179 container.appendChild( div );
12180
12181 // Executing both pixelPosition & boxSizingReliable tests require only one layout
12182 // so they're executed at the same time to save the second computation.
12183 function computePixelPositionAndBoxSizingReliable() {
12184 div.style.cssText =
12185 // Support: Firefox<29, Android 2.3
12186 // Vendor-prefix box-sizing
12187 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
12188 "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
12189 "border:1px;padding:1px;width:4px;position:absolute";
12190 div.innerHTML = "";
12191 docElem.appendChild( container );
12192
12193 var divStyle = window.getComputedStyle( div, null );
12194 pixelPositionVal = divStyle.top !== "1%";
12195 boxSizingReliableVal = divStyle.width === "4px";
12196
12197 docElem.removeChild( container );
12198 }
12199
12200 // Support: node.js jsdom
12201 // Don't assume that getComputedStyle is a property of the global object
12202 if ( window.getComputedStyle ) {
12203 jQuery.extend( support, {
12204 pixelPosition: function() {
12205 // This test is executed only once but we still do memoizing
12206 // since we can use the boxSizingReliable pre-computing.
12207 // No need to check if the test was already performed, though.
12208 computePixelPositionAndBoxSizingReliable();
12209 return pixelPositionVal;
12210 },
12211 boxSizingReliable: function() {
12212 if ( boxSizingReliableVal == null ) {
12213 computePixelPositionAndBoxSizingReliable();
12214 }
12215 return boxSizingReliableVal;
12216 },
12217 reliableMarginRight: function() {
12218 // Support: Android 2.3
12219 // Check if div with explicit width and no margin-right incorrectly
12220 // gets computed margin-right based on width of container. (#3333)
12221 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
12222 // This support function is only executed once so no memoizing is needed.
12223 var ret,
12224 marginDiv = div.appendChild( document.createElement( "div" ) );
12225
12226 // Reset CSS: box-sizing; display; margin; border; padding
12227 marginDiv.style.cssText = div.style.cssText =
12228 // Support: Firefox<29, Android 2.3
12229 // Vendor-prefix box-sizing
12230 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
12231 "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
12232 marginDiv.style.marginRight = marginDiv.style.width = "0";
12233 div.style.width = "1px";
12234 docElem.appendChild( container );
12235
12236 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
12237
12238 docElem.removeChild( container );
12239
12240 return ret;
12241 }
12242 });
12243 }
12244 })();
12245
12246
12247 // A method for quickly swapping in/out CSS properties to get correct calculations.
12248 jQuery.swap = function( elem, options, callback, args ) {
12249 var ret, name,
12250 old = {};
12251
12252 // Remember the old values, and insert the new ones
12253 for ( name in options ) {
12254 old[ name ] = elem.style[ name ];
12255 elem.style[ name ] = options[ name ];
12256 }
12257
12258 ret = callback.apply( elem, args || [] );
12259
12260 // Revert the old values
12261 for ( name in options ) {
12262 elem.style[ name ] = old[ name ];
12263 }
12264
12265 return ret;
12266 };
12267
12268
12269 var
12270 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
12271 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
12272 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
12273 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
12274 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
12275
12276 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
12277 cssNormalTransform = {
12278 letterSpacing: "0",
12279 fontWeight: "400"
12280 },
12281
12282 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
12283
12284 // return a css property mapped to a potentially vendor prefixed property
12285 function vendorPropName( style, name ) {
12286
12287 // shortcut for names that are not vendor prefixed
12288 if ( name in style ) {
12289 return name;
12290 }
12291
12292 // check for vendor prefixed names
12293 var capName = name[0].toUpperCase() + name.slice(1),
12294 origName = name,
12295 i = cssPrefixes.length;
12296
12297 while ( i-- ) {
12298 name = cssPrefixes[ i ] + capName;
12299 if ( name in style ) {
12300 return name;
12301 }
12302 }
12303
12304 return origName;
12305 }
12306
12307 function setPositiveNumber( elem, value, subtract ) {
12308 var matches = rnumsplit.exec( value );
12309 return matches ?
12310 // Guard against undefined "subtract", e.g., when used as in cssHooks
12311 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
12312 value;
12313 }
12314
12315 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
12316 var i = extra === ( isBorderBox ? "border" : "content" ) ?
12317 // If we already have the right measurement, avoid augmentation
12318 4 :
12319 // Otherwise initialize for horizontal or vertical properties
12320 name === "width" ? 1 : 0,
12321
12322 val = 0;
12323
12324 for ( ; i < 4; i += 2 ) {
12325 // both box models exclude margin, so add it if we want it
12326 if ( extra === "margin" ) {
12327 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
12328 }
12329
12330 if ( isBorderBox ) {
12331 // border-box includes padding, so remove it if we want content
12332 if ( extra === "content" ) {
12333 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
12334 }
12335
12336 // at this point, extra isn't border nor margin, so remove border
12337 if ( extra !== "margin" ) {
12338 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
12339 }
12340 } else {
12341 // at this point, extra isn't content, so add padding
12342 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
12343
12344 // at this point, extra isn't content nor padding, so add border
12345 if ( extra !== "padding" ) {
12346 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
12347 }
12348 }
12349 }
12350
12351 return val;
12352 }
12353
12354 function getWidthOrHeight( elem, name, extra ) {
12355
12356 // Start with offset property, which is equivalent to the border-box value
12357 var valueIsBorderBox = true,
12358 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
12359 styles = getStyles( elem ),
12360 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
12361
12362 // some non-html elements return undefined for offsetWidth, so check for null/undefined
12363 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
12364 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
12365 if ( val <= 0 || val == null ) {
12366 // Fall back to computed then uncomputed css if necessary
12367 val = curCSS( elem, name, styles );
12368 if ( val < 0 || val == null ) {
12369 val = elem.style[ name ];
12370 }
12371
12372 // Computed unit is not pixels. Stop here and return.
12373 if ( rnumnonpx.test(val) ) {
12374 return val;
12375 }
12376
12377 // we need the check for style in case a browser which returns unreliable values
12378 // for getComputedStyle silently falls back to the reliable elem.style
12379 valueIsBorderBox = isBorderBox &&
12380 ( support.boxSizingReliable() || val === elem.style[ name ] );
12381
12382 // Normalize "", auto, and prepare for extra
12383 val = parseFloat( val ) || 0;
12384 }
12385
12386 // use the active box-sizing model to add/subtract irrelevant styles
12387 return ( val +
12388 augmentWidthOrHeight(
12389 elem,
12390 name,
12391 extra || ( isBorderBox ? "border" : "content" ),
12392 valueIsBorderBox,
12393 styles
12394 )
12395 ) + "px";
12396 }
12397
12398 function showHide( elements, show ) {
12399 var display, elem, hidden,
12400 values = [],
12401 index = 0,
12402 length = elements.length;
12403
12404 for ( ; index < length; index++ ) {
12405 elem = elements[ index ];
12406 if ( !elem.style ) {
12407 continue;
12408 }
12409
12410 values[ index ] = data_priv.get( elem, "olddisplay" );
12411 display = elem.style.display;
12412 if ( show ) {
12413 // Reset the inline display of this element to learn if it is
12414 // being hidden by cascaded rules or not
12415 if ( !values[ index ] && display === "none" ) {
12416 elem.style.display = "";
12417 }
12418
12419 // Set elements which have been overridden with display: none
12420 // in a stylesheet to whatever the default browser style is
12421 // for such an element
12422 if ( elem.style.display === "" && isHidden( elem ) ) {
12423 values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
12424 }
12425 } else {
12426 hidden = isHidden( elem );
12427
12428 if ( display !== "none" || !hidden ) {
12429 data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
12430 }
12431 }
12432 }
12433
12434 // Set the display of most of the elements in a second loop
12435 // to avoid the constant reflow
12436 for ( index = 0; index < length; index++ ) {
12437 elem = elements[ index ];
12438 if ( !elem.style ) {
12439 continue;
12440 }
12441 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
12442 elem.style.display = show ? values[ index ] || "" : "none";
12443 }
12444 }
12445
12446 return elements;
12447 }
12448
12449 jQuery.extend({
12450 // Add in style property hooks for overriding the default
12451 // behavior of getting and setting a style property
12452 cssHooks: {
12453 opacity: {
12454 get: function( elem, computed ) {
12455 if ( computed ) {
12456 // We should always get a number back from opacity
12457 var ret = curCSS( elem, "opacity" );
12458 return ret === "" ? "1" : ret;
12459 }
12460 }
12461 }
12462 },
12463
12464 // Don't automatically add "px" to these possibly-unitless properties
12465 cssNumber: {
12466 "columnCount": true,
12467 "fillOpacity": true,
12468 "flexGrow": true,
12469 "flexShrink": true,
12470 "fontWeight": true,
12471 "lineHeight": true,
12472 "opacity": true,
12473 "order": true,
12474 "orphans": true,
12475 "widows": true,
12476 "zIndex": true,
12477 "zoom": true
12478 },
12479
12480 // Add in properties whose names you wish to fix before
12481 // setting or getting the value
12482 cssProps: {
12483 // normalize float css property
12484 "float": "cssFloat"
12485 },
12486
12487 // Get and set the style property on a DOM Node
12488 style: function( elem, name, value, extra ) {
12489 // Don't set styles on text and comment nodes
12490 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
12491 return;
12492 }
12493
12494 // Make sure that we're working with the right name
12495 var ret, type, hooks,
12496 origName = jQuery.camelCase( name ),
12497 style = elem.style;
12498
12499 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
12500
12501 // gets hook for the prefixed version
12502 // followed by the unprefixed version
12503 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
12504
12505 // Check if we're setting a value
12506 if ( value !== undefined ) {
12507 type = typeof value;
12508
12509 // convert relative number strings (+= or -=) to relative numbers. #7345
12510 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
12511 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
12512 // Fixes bug #9237
12513 type = "number";
12514 }
12515
12516 // Make sure that null and NaN values aren't set. See: #7116
12517 if ( value == null || value !== value ) {
12518 return;
12519 }
12520
12521 // If a number was passed in, add 'px' to the (except for certain CSS properties)
12522 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
12523 value += "px";
12524 }
12525
12526 // Fixes #8908, it can be done more correctly by specifying setters in cssHooks,
12527 // but it would mean to define eight (for every problematic property) identical functions
12528 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
12529 style[ name ] = "inherit";
12530 }
12531
12532 // If a hook was provided, use that value, otherwise just set the specified value
12533 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
12534 style[ name ] = value;
12535 }
12536
12537 } else {
12538 // If a hook was provided get the non-computed value from there
12539 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
12540 return ret;
12541 }
12542
12543 // Otherwise just get the value from the style object
12544 return style[ name ];
12545 }
12546 },
12547
12548 css: function( elem, name, extra, styles ) {
12549 var val, num, hooks,
12550 origName = jQuery.camelCase( name );
12551
12552 // Make sure that we're working with the right name
12553 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
12554
12555 // gets hook for the prefixed version
12556 // followed by the unprefixed version
12557 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
12558
12559 // If a hook was provided get the computed value from there
12560 if ( hooks && "get" in hooks ) {
12561 val = hooks.get( elem, true, extra );
12562 }
12563
12564 // Otherwise, if a way to get the computed value exists, use that
12565 if ( val === undefined ) {
12566 val = curCSS( elem, name, styles );
12567 }
12568
12569 //convert "normal" to computed value
12570 if ( val === "normal" && name in cssNormalTransform ) {
12571 val = cssNormalTransform[ name ];
12572 }
12573
12574 // Return, converting to number if forced or a qualifier was provided and val looks numeric
12575 if ( extra === "" || extra ) {
12576 num = parseFloat( val );
12577 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
12578 }
12579 return val;
12580 }
12581 });
12582
12583 jQuery.each([ "height", "width" ], function( i, name ) {
12584 jQuery.cssHooks[ name ] = {
12585 get: function( elem, computed, extra ) {
12586 if ( computed ) {
12587 // certain elements can have dimension info if we invisibly show them
12588 // however, it must have a current display style that would benefit from this
12589 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
12590 jQuery.swap( elem, cssShow, function() {
12591 return getWidthOrHeight( elem, name, extra );
12592 }) :
12593 getWidthOrHeight( elem, name, extra );
12594 }
12595 },
12596
12597 set: function( elem, value, extra ) {
12598 var styles = extra && getStyles( elem );
12599 return setPositiveNumber( elem, value, extra ?
12600 augmentWidthOrHeight(
12601 elem,
12602 name,
12603 extra,
12604 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
12605 styles
12606 ) : 0
12607 );
12608 }
12609 };
12610 });
12611
12612 // Support: Android 2.3
12613 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
12614 function( elem, computed ) {
12615 if ( computed ) {
12616 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
12617 // Work around by temporarily setting element display to inline-block
12618 return jQuery.swap( elem, { "display": "inline-block" },
12619 curCSS, [ elem, "marginRight" ] );
12620 }
12621 }
12622 );
12623
12624 // These hooks are used by animate to expand properties
12625 jQuery.each({
12626 margin: "",
12627 padding: "",
12628 border: "Width"
12629 }, function( prefix, suffix ) {
12630 jQuery.cssHooks[ prefix + suffix ] = {
12631 expand: function( value ) {
12632 var i = 0,
12633 expanded = {},
12634
12635 // assumes a single number if not a string
12636 parts = typeof value === "string" ? value.split(" ") : [ value ];
12637
12638 for ( ; i < 4; i++ ) {
12639 expanded[ prefix + cssExpand[ i ] + suffix ] =
12640 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
12641 }
12642
12643 return expanded;
12644 }
12645 };
12646
12647 if ( !rmargin.test( prefix ) ) {
12648 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
12649 }
12650 });
12651
12652 jQuery.fn.extend({
12653 css: function( name, value ) {
12654 return access( this, function( elem, name, value ) {
12655 var styles, len,
12656 map = {},
12657 i = 0;
12658
12659 if ( jQuery.isArray( name ) ) {
12660 styles = getStyles( elem );
12661 len = name.length;
12662
12663 for ( ; i < len; i++ ) {
12664 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
12665 }
12666
12667 return map;
12668 }
12669
12670 return value !== undefined ?
12671 jQuery.style( elem, name, value ) :
12672 jQuery.css( elem, name );
12673 }, name, value, arguments.length > 1 );
12674 },
12675 show: function() {
12676 return showHide( this, true );
12677 },
12678 hide: function() {
12679 return showHide( this );
12680 },
12681 toggle: function( state ) {
12682 if ( typeof state === "boolean" ) {
12683 return state ? this.show() : this.hide();
12684 }
12685
12686 return this.each(function() {
12687 if ( isHidden( this ) ) {
12688 jQuery( this ).show();
12689 } else {
12690 jQuery( this ).hide();
12691 }
12692 });
12693 }
12694 });
12695
12696
12697 function Tween( elem, options, prop, end, easing ) {
12698 return new Tween.prototype.init( elem, options, prop, end, easing );
12699 }
12700 jQuery.Tween = Tween;
12701
12702 Tween.prototype = {
12703 constructor: Tween,
12704 init: function( elem, options, prop, end, easing, unit ) {
12705 this.elem = elem;
12706 this.prop = prop;
12707 this.easing = easing || "swing";
12708 this.options = options;
12709 this.start = this.now = this.cur();
12710 this.end = end;
12711 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
12712 },
12713 cur: function() {
12714 var hooks = Tween.propHooks[ this.prop ];
12715
12716 return hooks && hooks.get ?
12717 hooks.get( this ) :
12718 Tween.propHooks._default.get( this );
12719 },
12720 run: function( percent ) {
12721 var eased,
12722 hooks = Tween.propHooks[ this.prop ];
12723
12724 if ( this.options.duration ) {
12725 this.pos = eased = jQuery.easing[ this.easing ](
12726 percent, this.options.duration * percent, 0, 1, this.options.duration
12727 );
12728 } else {
12729 this.pos = eased = percent;
12730 }
12731 this.now = ( this.end - this.start ) * eased + this.start;
12732
12733 if ( this.options.step ) {
12734 this.options.step.call( this.elem, this.now, this );
12735 }
12736
12737 if ( hooks && hooks.set ) {
12738 hooks.set( this );
12739 } else {
12740 Tween.propHooks._default.set( this );
12741 }
12742 return this;
12743 }
12744 };
12745
12746 Tween.prototype.init.prototype = Tween.prototype;
12747
12748 Tween.propHooks = {
12749 _default: {
12750 get: function( tween ) {
12751 var result;
12752
12753 if ( tween.elem[ tween.prop ] != null &&
12754 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
12755 return tween.elem[ tween.prop ];
12756 }
12757
12758 // passing an empty string as a 3rd parameter to .css will automatically
12759 // attempt a parseFloat and fallback to a string if the parse fails
12760 // so, simple values such as "10px" are parsed to Float.
12761 // complex values such as "rotate(1rad)" are returned as is.
12762 result = jQuery.css( tween.elem, tween.prop, "" );
12763 // Empty strings, null, undefined and "auto" are converted to 0.
12764 return !result || result === "auto" ? 0 : result;
12765 },
12766 set: function( tween ) {
12767 // use step hook for back compat - use cssHook if its there - use .style if its
12768 // available and use plain properties where available
12769 if ( jQuery.fx.step[ tween.prop ] ) {
12770 jQuery.fx.step[ tween.prop ]( tween );
12771 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
12772 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
12773 } else {
12774 tween.elem[ tween.prop ] = tween.now;
12775 }
12776 }
12777 }
12778 };
12779
12780 // Support: IE9
12781 // Panic based approach to setting things on disconnected nodes
12782
12783 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
12784 set: function( tween ) {
12785 if ( tween.elem.nodeType && tween.elem.parentNode ) {
12786 tween.elem[ tween.prop ] = tween.now;
12787 }
12788 }
12789 };
12790
12791 jQuery.easing = {
12792 linear: function( p ) {
12793 return p;
12794 },
12795 swing: function( p ) {
12796 return 0.5 - Math.cos( p * Math.PI ) / 2;
12797 }
12798 };
12799
12800 jQuery.fx = Tween.prototype.init;
12801
12802 // Back Compat <1.8 extension point
12803 jQuery.fx.step = {};
12804
12805
12806
12807
12808 var
12809 fxNow, timerId,
12810 rfxtypes = /^(?:toggle|show|hide)$/,
12811 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
12812 rrun = /queueHooks$/,
12813 animationPrefilters = [ defaultPrefilter ],
12814 tweeners = {
12815 "*": [ function( prop, value ) {
12816 var tween = this.createTween( prop, value ),
12817 target = tween.cur(),
12818 parts = rfxnum.exec( value ),
12819 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
12820
12821 // Starting value computation is required for potential unit mismatches
12822 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
12823 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
12824 scale = 1,
12825 maxIterations = 20;
12826
12827 if ( start && start[ 3 ] !== unit ) {
12828 // Trust units reported by jQuery.css
12829 unit = unit || start[ 3 ];
12830
12831 // Make sure we update the tween properties later on
12832 parts = parts || [];
12833
12834 // Iteratively approximate from a nonzero starting point
12835 start = +target || 1;
12836
12837 do {
12838 // If previous iteration zeroed out, double until we get *something*
12839 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
12840 scale = scale || ".5";
12841
12842 // Adjust and apply
12843 start = start / scale;
12844 jQuery.style( tween.elem, prop, start + unit );
12845
12846 // Update scale, tolerating zero or NaN from tween.cur()
12847 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
12848 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
12849 }
12850
12851 // Update tween properties
12852 if ( parts ) {
12853 start = tween.start = +start || +target || 0;
12854 tween.unit = unit;
12855 // If a +=/-= token was provided, we're doing a relative animation
12856 tween.end = parts[ 1 ] ?
12857 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
12858 +parts[ 2 ];
12859 }
12860
12861 return tween;
12862 } ]
12863 };
12864
12865 // Animations created synchronously will run synchronously
12866 function createFxNow() {
12867 setTimeout(function() {
12868 fxNow = undefined;
12869 });
12870 return ( fxNow = jQuery.now() );
12871 }
12872
12873 // Generate parameters to create a standard animation
12874 function genFx( type, includeWidth ) {
12875 var which,
12876 i = 0,
12877 attrs = { height: type };
12878
12879 // if we include width, step value is 1 to do all cssExpand values,
12880 // if we don't include width, step value is 2 to skip over Left and Right
12881 includeWidth = includeWidth ? 1 : 0;
12882 for ( ; i < 4 ; i += 2 - includeWidth ) {
12883 which = cssExpand[ i ];
12884 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
12885 }
12886
12887 if ( includeWidth ) {
12888 attrs.opacity = attrs.width = type;
12889 }
12890
12891 return attrs;
12892 }
12893
12894 function createTween( value, prop, animation ) {
12895 var tween,
12896 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
12897 index = 0,
12898 length = collection.length;
12899 for ( ; index < length; index++ ) {
12900 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
12901
12902 // we're done with this property
12903 return tween;
12904 }
12905 }
12906 }
12907
12908 function defaultPrefilter( elem, props, opts ) {
12909 /* jshint validthis: true */
12910 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
12911 anim = this,
12912 orig = {},
12913 style = elem.style,
12914 hidden = elem.nodeType && isHidden( elem ),
12915 dataShow = data_priv.get( elem, "fxshow" );
12916
12917 // handle queue: false promises
12918 if ( !opts.queue ) {
12919 hooks = jQuery._queueHooks( elem, "fx" );
12920 if ( hooks.unqueued == null ) {
12921 hooks.unqueued = 0;
12922 oldfire = hooks.empty.fire;
12923 hooks.empty.fire = function() {
12924 if ( !hooks.unqueued ) {
12925 oldfire();
12926 }
12927 };
12928 }
12929 hooks.unqueued++;
12930
12931 anim.always(function() {
12932 // doing this makes sure that the complete handler will be called
12933 // before this completes
12934 anim.always(function() {
12935 hooks.unqueued--;
12936 if ( !jQuery.queue( elem, "fx" ).length ) {
12937 hooks.empty.fire();
12938 }
12939 });
12940 });
12941 }
12942
12943 // height/width overflow pass
12944 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
12945 // Make sure that nothing sneaks out
12946 // Record all 3 overflow attributes because IE9-10 do not
12947 // change the overflow attribute when overflowX and
12948 // overflowY are set to the same value
12949 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
12950
12951 // Set display property to inline-block for height/width
12952 // animations on inline elements that are having width/height animated
12953 display = jQuery.css( elem, "display" );
12954
12955 // Test default display if display is currently "none"
12956 checkDisplay = display === "none" ?
12957 data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
12958
12959 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
12960 style.display = "inline-block";
12961 }
12962 }
12963
12964 if ( opts.overflow ) {
12965 style.overflow = "hidden";
12966 anim.always(function() {
12967 style.overflow = opts.overflow[ 0 ];
12968 style.overflowX = opts.overflow[ 1 ];
12969 style.overflowY = opts.overflow[ 2 ];
12970 });
12971 }
12972
12973 // show/hide pass
12974 for ( prop in props ) {
12975 value = props[ prop ];
12976 if ( rfxtypes.exec( value ) ) {
12977 delete props[ prop ];
12978 toggle = toggle || value === "toggle";
12979 if ( value === ( hidden ? "hide" : "show" ) ) {
12980
12981 // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
12982 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
12983 hidden = true;
12984 } else {
12985 continue;
12986 }
12987 }
12988 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
12989
12990 // Any non-fx value stops us from restoring the original display value
12991 } else {
12992 display = undefined;
12993 }
12994 }
12995
12996 if ( !jQuery.isEmptyObject( orig ) ) {
12997 if ( dataShow ) {
12998 if ( "hidden" in dataShow ) {
12999 hidden = dataShow.hidden;
13000 }
13001 } else {
13002 dataShow = data_priv.access( elem, "fxshow", {} );
13003 }
13004
13005 // store state if its toggle - enables .stop().toggle() to "reverse"
13006 if ( toggle ) {
13007 dataShow.hidden = !hidden;
13008 }
13009 if ( hidden ) {
13010 jQuery( elem ).show();
13011 } else {
13012 anim.done(function() {
13013 jQuery( elem ).hide();
13014 });
13015 }
13016 anim.done(function() {
13017 var prop;
13018
13019 data_priv.remove( elem, "fxshow" );
13020 for ( prop in orig ) {
13021 jQuery.style( elem, prop, orig[ prop ] );
13022 }
13023 });
13024 for ( prop in orig ) {
13025 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
13026
13027 if ( !( prop in dataShow ) ) {
13028 dataShow[ prop ] = tween.start;
13029 if ( hidden ) {
13030 tween.end = tween.start;
13031 tween.start = prop === "width" || prop === "height" ? 1 : 0;
13032 }
13033 }
13034 }
13035
13036 // If this is a noop like .hide().hide(), restore an overwritten display value
13037 } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
13038 style.display = display;
13039 }
13040 }
13041
13042 function propFilter( props, specialEasing ) {
13043 var index, name, easing, value, hooks;
13044
13045 // camelCase, specialEasing and expand cssHook pass
13046 for ( index in props ) {
13047 name = jQuery.camelCase( index );
13048 easing = specialEasing[ name ];
13049 value = props[ index ];
13050 if ( jQuery.isArray( value ) ) {
13051 easing = value[ 1 ];
13052 value = props[ index ] = value[ 0 ];
13053 }
13054
13055 if ( index !== name ) {
13056 props[ name ] = value;
13057 delete props[ index ];
13058 }
13059
13060 hooks = jQuery.cssHooks[ name ];
13061 if ( hooks && "expand" in hooks ) {
13062 value = hooks.expand( value );
13063 delete props[ name ];
13064
13065 // not quite $.extend, this wont overwrite keys already present.
13066 // also - reusing 'index' from above because we have the correct "name"
13067 for ( index in value ) {
13068 if ( !( index in props ) ) {
13069 props[ index ] = value[ index ];
13070 specialEasing[ index ] = easing;
13071 }
13072 }
13073 } else {
13074 specialEasing[ name ] = easing;
13075 }
13076 }
13077 }
13078
13079 function Animation( elem, properties, options ) {
13080 var result,
13081 stopped,
13082 index = 0,
13083 length = animationPrefilters.length,
13084 deferred = jQuery.Deferred().always( function() {
13085 // don't match elem in the :animated selector
13086 delete tick.elem;
13087 }),
13088 tick = function() {
13089 if ( stopped ) {
13090 return false;
13091 }
13092 var currentTime = fxNow || createFxNow(),
13093 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
13094 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
13095 temp = remaining / animation.duration || 0,
13096 percent = 1 - temp,
13097 index = 0,
13098 length = animation.tweens.length;
13099
13100 for ( ; index < length ; index++ ) {
13101 animation.tweens[ index ].run( percent );
13102 }
13103
13104 deferred.notifyWith( elem, [ animation, percent, remaining ]);
13105
13106 if ( percent < 1 && length ) {
13107 return remaining;
13108 } else {
13109 deferred.resolveWith( elem, [ animation ] );
13110 return false;
13111 }
13112 },
13113 animation = deferred.promise({
13114 elem: elem,
13115 props: jQuery.extend( {}, properties ),
13116 opts: jQuery.extend( true, { specialEasing: {} }, options ),
13117 originalProperties: properties,
13118 originalOptions: options,
13119 startTime: fxNow || createFxNow(),
13120 duration: options.duration,
13121 tweens: [],
13122 createTween: function( prop, end ) {
13123 var tween = jQuery.Tween( elem, animation.opts, prop, end,
13124 animation.opts.specialEasing[ prop ] || animation.opts.easing );
13125 animation.tweens.push( tween );
13126 return tween;
13127 },
13128 stop: function( gotoEnd ) {
13129 var index = 0,
13130 // if we are going to the end, we want to run all the tweens
13131 // otherwise we skip this part
13132 length = gotoEnd ? animation.tweens.length : 0;
13133 if ( stopped ) {
13134 return this;
13135 }
13136 stopped = true;
13137 for ( ; index < length ; index++ ) {
13138 animation.tweens[ index ].run( 1 );
13139 }
13140
13141 // resolve when we played the last frame
13142 // otherwise, reject
13143 if ( gotoEnd ) {
13144 deferred.resolveWith( elem, [ animation, gotoEnd ] );
13145 } else {
13146 deferred.rejectWith( elem, [ animation, gotoEnd ] );
13147 }
13148 return this;
13149 }
13150 }),
13151 props = animation.props;
13152
13153 propFilter( props, animation.opts.specialEasing );
13154
13155 for ( ; index < length ; index++ ) {
13156 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
13157 if ( result ) {
13158 return result;
13159 }
13160 }
13161
13162 jQuery.map( props, createTween, animation );
13163
13164 if ( jQuery.isFunction( animation.opts.start ) ) {
13165 animation.opts.start.call( elem, animation );
13166 }
13167
13168 jQuery.fx.timer(
13169 jQuery.extend( tick, {
13170 elem: elem,
13171 anim: animation,
13172 queue: animation.opts.queue
13173 })
13174 );
13175
13176 // attach callbacks from options
13177 return animation.progress( animation.opts.progress )
13178 .done( animation.opts.done, animation.opts.complete )
13179 .fail( animation.opts.fail )
13180 .always( animation.opts.always );
13181 }
13182
13183 jQuery.Animation = jQuery.extend( Animation, {
13184
13185 tweener: function( props, callback ) {
13186 if ( jQuery.isFunction( props ) ) {
13187 callback = props;
13188 props = [ "*" ];
13189 } else {
13190 props = props.split(" ");
13191 }
13192
13193 var prop,
13194 index = 0,
13195 length = props.length;
13196
13197 for ( ; index < length ; index++ ) {
13198 prop = props[ index ];
13199 tweeners[ prop ] = tweeners[ prop ] || [];
13200 tweeners[ prop ].unshift( callback );
13201 }
13202 },
13203
13204 prefilter: function( callback, prepend ) {
13205 if ( prepend ) {
13206 animationPrefilters.unshift( callback );
13207 } else {
13208 animationPrefilters.push( callback );
13209 }
13210 }
13211 });
13212
13213 jQuery.speed = function( speed, easing, fn ) {
13214 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
13215 complete: fn || !fn && easing ||
13216 jQuery.isFunction( speed ) && speed,
13217 duration: speed,
13218 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
13219 };
13220
13221 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
13222 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
13223
13224 // normalize opt.queue - true/undefined/null -> "fx"
13225 if ( opt.queue == null || opt.queue === true ) {
13226 opt.queue = "fx";
13227 }
13228
13229 // Queueing
13230 opt.old = opt.complete;
13231
13232 opt.complete = function() {
13233 if ( jQuery.isFunction( opt.old ) ) {
13234 opt.old.call( this );
13235 }
13236
13237 if ( opt.queue ) {
13238 jQuery.dequeue( this, opt.queue );
13239 }
13240 };
13241
13242 return opt;
13243 };
13244
13245 jQuery.fn.extend({
13246 fadeTo: function( speed, to, easing, callback ) {
13247
13248 // show any hidden elements after setting opacity to 0
13249 return this.filter( isHidden ).css( "opacity", 0 ).show()
13250
13251 // animate to the value specified
13252 .end().animate({ opacity: to }, speed, easing, callback );
13253 },
13254 animate: function( prop, speed, easing, callback ) {
13255 var empty = jQuery.isEmptyObject( prop ),
13256 optall = jQuery.speed( speed, easing, callback ),
13257 doAnimation = function() {
13258 // Operate on a copy of prop so per-property easing won't be lost
13259 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
13260
13261 // Empty animations, or finishing resolves immediately
13262 if ( empty || data_priv.get( this, "finish" ) ) {
13263 anim.stop( true );
13264 }
13265 };
13266 doAnimation.finish = doAnimation;
13267
13268 return empty || optall.queue === false ?
13269 this.each( doAnimation ) :
13270 this.queue( optall.queue, doAnimation );
13271 },
13272 stop: function( type, clearQueue, gotoEnd ) {
13273 var stopQueue = function( hooks ) {
13274 var stop = hooks.stop;
13275 delete hooks.stop;
13276 stop( gotoEnd );
13277 };
13278
13279 if ( typeof type !== "string" ) {
13280 gotoEnd = clearQueue;
13281 clearQueue = type;
13282 type = undefined;
13283 }
13284 if ( clearQueue && type !== false ) {
13285 this.queue( type || "fx", [] );
13286 }
13287
13288 return this.each(function() {
13289 var dequeue = true,
13290 index = type != null && type + "queueHooks",
13291 timers = jQuery.timers,
13292 data = data_priv.get( this );
13293
13294 if ( index ) {
13295 if ( data[ index ] && data[ index ].stop ) {
13296 stopQueue( data[ index ] );
13297 }
13298 } else {
13299 for ( index in data ) {
13300 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
13301 stopQueue( data[ index ] );
13302 }
13303 }
13304 }
13305
13306 for ( index = timers.length; index--; ) {
13307 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
13308 timers[ index ].anim.stop( gotoEnd );
13309 dequeue = false;
13310 timers.splice( index, 1 );
13311 }
13312 }
13313
13314 // start the next in the queue if the last step wasn't forced
13315 // timers currently will call their complete callbacks, which will dequeue
13316 // but only if they were gotoEnd
13317 if ( dequeue || !gotoEnd ) {
13318 jQuery.dequeue( this, type );
13319 }
13320 });
13321 },
13322 finish: function( type ) {
13323 if ( type !== false ) {
13324 type = type || "fx";
13325 }
13326 return this.each(function() {
13327 var index,
13328 data = data_priv.get( this ),
13329 queue = data[ type + "queue" ],
13330 hooks = data[ type + "queueHooks" ],
13331 timers = jQuery.timers,
13332 length = queue ? queue.length : 0;
13333
13334 // enable finishing flag on private data
13335 data.finish = true;
13336
13337 // empty the queue first
13338 jQuery.queue( this, type, [] );
13339
13340 if ( hooks && hooks.stop ) {
13341 hooks.stop.call( this, true );
13342 }
13343
13344 // look for any active animations, and finish them
13345 for ( index = timers.length; index--; ) {
13346 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
13347 timers[ index ].anim.stop( true );
13348 timers.splice( index, 1 );
13349 }
13350 }
13351
13352 // look for any animations in the old queue and finish them
13353 for ( index = 0; index < length; index++ ) {
13354 if ( queue[ index ] && queue[ index ].finish ) {
13355 queue[ index ].finish.call( this );
13356 }
13357 }
13358
13359 // turn off finishing flag
13360 delete data.finish;
13361 });
13362 }
13363 });
13364
13365 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
13366 var cssFn = jQuery.fn[ name ];
13367 jQuery.fn[ name ] = function( speed, easing, callback ) {
13368 return speed == null || typeof speed === "boolean" ?
13369 cssFn.apply( this, arguments ) :
13370 this.animate( genFx( name, true ), speed, easing, callback );
13371 };
13372 });
13373
13374 // Generate shortcuts for custom animations
13375 jQuery.each({
13376 slideDown: genFx("show"),
13377 slideUp: genFx("hide"),
13378 slideToggle: genFx("toggle"),
13379 fadeIn: { opacity: "show" },
13380 fadeOut: { opacity: "hide" },
13381 fadeToggle: { opacity: "toggle" }
13382 }, function( name, props ) {
13383 jQuery.fn[ name ] = function( speed, easing, callback ) {
13384 return this.animate( props, speed, easing, callback );
13385 };
13386 });
13387
13388 jQuery.timers = [];
13389 jQuery.fx.tick = function() {
13390 var timer,
13391 i = 0,
13392 timers = jQuery.timers;
13393
13394 fxNow = jQuery.now();
13395
13396 for ( ; i < timers.length; i++ ) {
13397 timer = timers[ i ];
13398 // Checks the timer has not already been removed
13399 if ( !timer() && timers[ i ] === timer ) {
13400 timers.splice( i--, 1 );
13401 }
13402 }
13403
13404 if ( !timers.length ) {
13405 jQuery.fx.stop();
13406 }
13407 fxNow = undefined;
13408 };
13409
13410 jQuery.fx.timer = function( timer ) {
13411 jQuery.timers.push( timer );
13412 if ( timer() ) {
13413 jQuery.fx.start();
13414 } else {
13415 jQuery.timers.pop();
13416 }
13417 };
13418
13419 jQuery.fx.interval = 13;
13420
13421 jQuery.fx.start = function() {
13422 if ( !timerId ) {
13423 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
13424 }
13425 };
13426
13427 jQuery.fx.stop = function() {
13428 clearInterval( timerId );
13429 timerId = null;
13430 };
13431
13432 jQuery.fx.speeds = {
13433 slow: 600,
13434 fast: 200,
13435 // Default speed
13436 _default: 400
13437 };
13438
13439
13440 // Based off of the plugin by Clint Helfers, with permission.
13441 // http://blindsignals.com/index.php/2009/07/jquery-delay/
13442 jQuery.fn.delay = function( time, type ) {
13443 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
13444 type = type || "fx";
13445
13446 return this.queue( type, function( next, hooks ) {
13447 var timeout = setTimeout( next, time );
13448 hooks.stop = function() {
13449 clearTimeout( timeout );
13450 };
13451 });
13452 };
13453
13454
13455 (function() {
13456 var input = document.createElement( "input" ),
13457 select = document.createElement( "select" ),
13458 opt = select.appendChild( document.createElement( "option" ) );
13459
13460 input.type = "checkbox";
13461
13462 // Support: iOS 5.1, Android 4.x, Android 2.3
13463 // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
13464 support.checkOn = input.value !== "";
13465
13466 // Must access the parent to make an option select properly
13467 // Support: IE9, IE10
13468 support.optSelected = opt.selected;
13469
13470 // Make sure that the options inside disabled selects aren't marked as disabled
13471 // (WebKit marks them as disabled)
13472 select.disabled = true;
13473 support.optDisabled = !opt.disabled;
13474
13475 // Check if an input maintains its value after becoming a radio
13476 // Support: IE9, IE10
13477 input = document.createElement( "input" );
13478 input.value = "t";
13479 input.type = "radio";
13480 support.radioValue = input.value === "t";
13481 })();
13482
13483
13484 var nodeHook, boolHook,
13485 attrHandle = jQuery.expr.attrHandle;
13486
13487 jQuery.fn.extend({
13488 attr: function( name, value ) {
13489 return access( this, jQuery.attr, name, value, arguments.length > 1 );
13490 },
13491
13492 removeAttr: function( name ) {
13493 return this.each(function() {
13494 jQuery.removeAttr( this, name );
13495 });
13496 }
13497 });
13498
13499 jQuery.extend({
13500 attr: function( elem, name, value ) {
13501 var hooks, ret,
13502 nType = elem.nodeType;
13503
13504 // don't get/set attributes on text, comment and attribute nodes
13505 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
13506 return;
13507 }
13508
13509 // Fallback to prop when attributes are not supported
13510 if ( typeof elem.getAttribute === strundefined ) {
13511 return jQuery.prop( elem, name, value );
13512 }
13513
13514 // All attributes are lowercase
13515 // Grab necessary hook if one is defined
13516 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
13517 name = name.toLowerCase();
13518 hooks = jQuery.attrHooks[ name ] ||
13519 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
13520 }
13521
13522 if ( value !== undefined ) {
13523
13524 if ( value === null ) {
13525 jQuery.removeAttr( elem, name );
13526
13527 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
13528 return ret;
13529
13530 } else {
13531 elem.setAttribute( name, value + "" );
13532 return value;
13533 }
13534
13535 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
13536 return ret;
13537
13538 } else {
13539 ret = jQuery.find.attr( elem, name );
13540
13541 // Non-existent attributes return null, we normalize to undefined
13542 return ret == null ?
13543 undefined :
13544 ret;
13545 }
13546 },
13547
13548 removeAttr: function( elem, value ) {
13549 var name, propName,
13550 i = 0,
13551 attrNames = value && value.match( rnotwhite );
13552
13553 if ( attrNames && elem.nodeType === 1 ) {
13554 while ( (name = attrNames[i++]) ) {
13555 propName = jQuery.propFix[ name ] || name;
13556
13557 // Boolean attributes get special treatment (#10870)
13558 if ( jQuery.expr.match.bool.test( name ) ) {
13559 // Set corresponding property to false
13560 elem[ propName ] = false;
13561 }
13562
13563 elem.removeAttribute( name );
13564 }
13565 }
13566 },
13567
13568 attrHooks: {
13569 type: {
13570 set: function( elem, value ) {
13571 if ( !support.radioValue && value === "radio" &&
13572 jQuery.nodeName( elem, "input" ) ) {
13573 // Setting the type on a radio button after the value resets the value in IE6-9
13574 // Reset value to default in case type is set after value during creation
13575 var val = elem.value;
13576 elem.setAttribute( "type", value );
13577 if ( val ) {
13578 elem.value = val;
13579 }
13580 return value;
13581 }
13582 }
13583 }
13584 }
13585 });
13586
13587 // Hooks for boolean attributes
13588 boolHook = {
13589 set: function( elem, value, name ) {
13590 if ( value === false ) {
13591 // Remove boolean attributes when set to false
13592 jQuery.removeAttr( elem, name );
13593 } else {
13594 elem.setAttribute( name, name );
13595 }
13596 return name;
13597 }
13598 };
13599 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
13600 var getter = attrHandle[ name ] || jQuery.find.attr;
13601
13602 attrHandle[ name ] = function( elem, name, isXML ) {
13603 var ret, handle;
13604 if ( !isXML ) {
13605 // Avoid an infinite loop by temporarily removing this function from the getter
13606 handle = attrHandle[ name ];
13607 attrHandle[ name ] = ret;
13608 ret = getter( elem, name, isXML ) != null ?
13609 name.toLowerCase() :
13610 null;
13611 attrHandle[ name ] = handle;
13612 }
13613 return ret;
13614 };
13615 });
13616
13617
13618
13619
13620 var rfocusable = /^(?:input|select|textarea|button)$/i;
13621
13622 jQuery.fn.extend({
13623 prop: function( name, value ) {
13624 return access( this, jQuery.prop, name, value, arguments.length > 1 );
13625 },
13626
13627 removeProp: function( name ) {
13628 return this.each(function() {
13629 delete this[ jQuery.propFix[ name ] || name ];
13630 });
13631 }
13632 });
13633
13634 jQuery.extend({
13635 propFix: {
13636 "for": "htmlFor",
13637 "class": "className"
13638 },
13639
13640 prop: function( elem, name, value ) {
13641 var ret, hooks, notxml,
13642 nType = elem.nodeType;
13643
13644 // don't get/set properties on text, comment and attribute nodes
13645 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
13646 return;
13647 }
13648
13649 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
13650
13651 if ( notxml ) {
13652 // Fix name and attach hooks
13653 name = jQuery.propFix[ name ] || name;
13654 hooks = jQuery.propHooks[ name ];
13655 }
13656
13657 if ( value !== undefined ) {
13658 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
13659 ret :
13660 ( elem[ name ] = value );
13661
13662 } else {
13663 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
13664 ret :
13665 elem[ name ];
13666 }
13667 },
13668
13669 propHooks: {
13670 tabIndex: {
13671 get: function( elem ) {
13672 return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
13673 elem.tabIndex :
13674 -1;
13675 }
13676 }
13677 }
13678 });
13679
13680 // Support: IE9+
13681 // Selectedness for an option in an optgroup can be inaccurate
13682 if ( !support.optSelected ) {
13683 jQuery.propHooks.selected = {
13684 get: function( elem ) {
13685 var parent = elem.parentNode;
13686 if ( parent && parent.parentNode ) {
13687 parent.parentNode.selectedIndex;
13688 }
13689 return null;
13690 }
13691 };
13692 }
13693
13694 jQuery.each([
13695 "tabIndex",
13696 "readOnly",
13697 "maxLength",
13698 "cellSpacing",
13699 "cellPadding",
13700 "rowSpan",
13701 "colSpan",
13702 "useMap",
13703 "frameBorder",
13704 "contentEditable"
13705 ], function() {
13706 jQuery.propFix[ this.toLowerCase() ] = this;
13707 });
13708
13709
13710
13711
13712 var rclass = /[\t\r\n\f]/g;
13713
13714 jQuery.fn.extend({
13715 addClass: function( value ) {
13716 var classes, elem, cur, clazz, j, finalValue,
13717 proceed = typeof value === "string" && value,
13718 i = 0,
13719 len = this.length;
13720
13721 if ( jQuery.isFunction( value ) ) {
13722 return this.each(function( j ) {
13723 jQuery( this ).addClass( value.call( this, j, this.className ) );
13724 });
13725 }
13726
13727 if ( proceed ) {
13728 // The disjunction here is for better compressibility (see removeClass)
13729 classes = ( value || "" ).match( rnotwhite ) || [];
13730
13731 for ( ; i < len; i++ ) {
13732 elem = this[ i ];
13733 cur = elem.nodeType === 1 && ( elem.className ?
13734 ( " " + elem.className + " " ).replace( rclass, " " ) :
13735 " "
13736 );
13737
13738 if ( cur ) {
13739 j = 0;
13740 while ( (clazz = classes[j++]) ) {
13741 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
13742 cur += clazz + " ";
13743 }
13744 }
13745
13746 // only assign if different to avoid unneeded rendering.
13747 finalValue = jQuery.trim( cur );
13748 if ( elem.className !== finalValue ) {
13749 elem.className = finalValue;
13750 }
13751 }
13752 }
13753 }
13754
13755 return this;
13756 },
13757
13758 removeClass: function( value ) {
13759 var classes, elem, cur, clazz, j, finalValue,
13760 proceed = arguments.length === 0 || typeof value === "string" && value,
13761 i = 0,
13762 len = this.length;
13763
13764 if ( jQuery.isFunction( value ) ) {
13765 return this.each(function( j ) {
13766 jQuery( this ).removeClass( value.call( this, j, this.className ) );
13767 });
13768 }
13769 if ( proceed ) {
13770 classes = ( value || "" ).match( rnotwhite ) || [];
13771
13772 for ( ; i < len; i++ ) {
13773 elem = this[ i ];
13774 // This expression is here for better compressibility (see addClass)
13775 cur = elem.nodeType === 1 && ( elem.className ?
13776 ( " " + elem.className + " " ).replace( rclass, " " ) :
13777 ""
13778 );
13779
13780 if ( cur ) {
13781 j = 0;
13782 while ( (clazz = classes[j++]) ) {
13783 // Remove *all* instances
13784 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
13785 cur = cur.replace( " " + clazz + " ", " " );
13786 }
13787 }
13788
13789 // only assign if different to avoid unneeded rendering.
13790 finalValue = value ? jQuery.trim( cur ) : "";
13791 if ( elem.className !== finalValue ) {
13792 elem.className = finalValue;
13793 }
13794 }
13795 }
13796 }
13797
13798 return this;
13799 },
13800
13801 toggleClass: function( value, stateVal ) {
13802 var type = typeof value;
13803
13804 if ( typeof stateVal === "boolean" && type === "string" ) {
13805 return stateVal ? this.addClass( value ) : this.removeClass( value );
13806 }
13807
13808 if ( jQuery.isFunction( value ) ) {
13809 return this.each(function( i ) {
13810 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
13811 });
13812 }
13813
13814 return this.each(function() {
13815 if ( type === "string" ) {
13816 // toggle individual class names
13817 var className,
13818 i = 0,
13819 self = jQuery( this ),
13820 classNames = value.match( rnotwhite ) || [];
13821
13822 while ( (className = classNames[ i++ ]) ) {
13823 // check each className given, space separated list
13824 if ( self.hasClass( className ) ) {
13825 self.removeClass( className );
13826 } else {
13827 self.addClass( className );
13828 }
13829 }
13830
13831 // Toggle whole class name
13832 } else if ( type === strundefined || type === "boolean" ) {
13833 if ( this.className ) {
13834 // store className if set
13835 data_priv.set( this, "__className__", this.className );
13836 }
13837
13838 // If the element has a class name or if we're passed "false",
13839 // then remove the whole classname (if there was one, the above saved it).
13840 // Otherwise bring back whatever was previously saved (if anything),
13841 // falling back to the empty string if nothing was stored.
13842 this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
13843 }
13844 });
13845 },
13846
13847 hasClass: function( selector ) {
13848 var className = " " + selector + " ",
13849 i = 0,
13850 l = this.length;
13851 for ( ; i < l; i++ ) {
13852 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
13853 return true;
13854 }
13855 }
13856
13857 return false;
13858 }
13859 });
13860
13861
13862
13863
13864 var rreturn = /\r/g;
13865
13866 jQuery.fn.extend({
13867 val: function( value ) {
13868 var hooks, ret, isFunction,
13869 elem = this[0];
13870
13871 if ( !arguments.length ) {
13872 if ( elem ) {
13873 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
13874
13875 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
13876 return ret;
13877 }
13878
13879 ret = elem.value;
13880
13881 return typeof ret === "string" ?
13882 // handle most common string cases
13883 ret.replace(rreturn, "") :
13884 // handle cases where value is null/undef or number
13885 ret == null ? "" : ret;
13886 }
13887
13888 return;
13889 }
13890
13891 isFunction = jQuery.isFunction( value );
13892
13893 return this.each(function( i ) {
13894 var val;
13895
13896 if ( this.nodeType !== 1 ) {
13897 return;
13898 }
13899
13900 if ( isFunction ) {
13901 val = value.call( this, i, jQuery( this ).val() );
13902 } else {
13903 val = value;
13904 }
13905
13906 // Treat null/undefined as ""; convert numbers to string
13907 if ( val == null ) {
13908 val = "";
13909
13910 } else if ( typeof val === "number" ) {
13911 val += "";
13912
13913 } else if ( jQuery.isArray( val ) ) {
13914 val = jQuery.map( val, function( value ) {
13915 return value == null ? "" : value + "";
13916 });
13917 }
13918
13919 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
13920
13921 // If set returns undefined, fall back to normal setting
13922 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
13923 this.value = val;
13924 }
13925 });
13926 }
13927 });
13928
13929 jQuery.extend({
13930 valHooks: {
13931 option: {
13932 get: function( elem ) {
13933 var val = jQuery.find.attr( elem, "value" );
13934 return val != null ?
13935 val :
13936 // Support: IE10-11+
13937 // option.text throws exceptions (#14686, #14858)
13938 jQuery.trim( jQuery.text( elem ) );
13939 }
13940 },
13941 select: {
13942 get: function( elem ) {
13943 var value, option,
13944 options = elem.options,
13945 index = elem.selectedIndex,
13946 one = elem.type === "select-one" || index < 0,
13947 values = one ? null : [],
13948 max = one ? index + 1 : options.length,
13949 i = index < 0 ?
13950 max :
13951 one ? index : 0;
13952
13953 // Loop through all the selected options
13954 for ( ; i < max; i++ ) {
13955 option = options[ i ];
13956
13957 // IE6-9 doesn't update selected after form reset (#2551)
13958 if ( ( option.selected || i === index ) &&
13959 // Don't return options that are disabled or in a disabled optgroup
13960 ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) &&
13961 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
13962
13963 // Get the specific value for the option
13964 value = jQuery( option ).val();
13965
13966 // We don't need an array for one selects
13967 if ( one ) {
13968 return value;
13969 }
13970
13971 // Multi-Selects return an array
13972 values.push( value );
13973 }
13974 }
13975
13976 return values;
13977 },
13978
13979 set: function( elem, value ) {
13980 var optionSet, option,
13981 options = elem.options,
13982 values = jQuery.makeArray( value ),
13983 i = options.length;
13984
13985 while ( i-- ) {
13986 option = options[ i ];
13987 if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) {
13988 optionSet = true;
13989 }
13990 }
13991
13992 // force browsers to behave consistently when non-matching value is set
13993 if ( !optionSet ) {
13994 elem.selectedIndex = -1;
13995 }
13996 return values;
13997 }
13998 }
13999 }
14000 });
14001
14002 // Radios and checkboxes getter/setter
14003 jQuery.each([ "radio", "checkbox" ], function() {
14004 jQuery.valHooks[ this ] = {
14005 set: function( elem, value ) {
14006 if ( jQuery.isArray( value ) ) {
14007 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
14008 }
14009 }
14010 };
14011 if ( !support.checkOn ) {
14012 jQuery.valHooks[ this ].get = function( elem ) {
14013 // Support: Webkit
14014 // "" is returned instead of "on" if a value isn't specified
14015 return elem.getAttribute("value") === null ? "on" : elem.value;
14016 };
14017 }
14018 });
14019
14020
14021
14022
14023 // Return jQuery for attributes-only inclusion
14024
14025
14026 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
14027 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
14028 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
14029
14030 // Handle event binding
14031 jQuery.fn[ name ] = function( data, fn ) {
14032 return arguments.length > 0 ?
14033 this.on( name, null, data, fn ) :
14034 this.trigger( name );
14035 };
14036 });
14037
14038 jQuery.fn.extend({
14039 hover: function( fnOver, fnOut ) {
14040 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
14041 },
14042
14043 bind: function( types, data, fn ) {
14044 return this.on( types, null, data, fn );
14045 },
14046 unbind: function( types, fn ) {
14047 return this.off( types, null, fn );
14048 },
14049
14050 delegate: function( selector, types, data, fn ) {
14051 return this.on( types, selector, data, fn );
14052 },
14053 undelegate: function( selector, types, fn ) {
14054 // ( namespace ) or ( selector, types [, fn] )
14055 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
14056 }
14057 });
14058
14059
14060 var nonce = jQuery.now();
14061
14062 var rquery = (/\?/);
14063
14064
14065
14066 // Support: Android 2.3
14067 // Workaround failure to string-cast null input
14068 jQuery.parseJSON = function( data ) {
14069 return JSON.parse( data + "" );
14070 };
14071
14072
14073 // Cross-browser xml parsing
14074 jQuery.parseXML = function( data ) {
14075 var xml, tmp;
14076 if ( !data || typeof data !== "string" ) {
14077 return null;
14078 }
14079
14080 // Support: IE9
14081 try {
14082 tmp = new DOMParser();
14083 xml = tmp.parseFromString( data, "text/xml" );
14084 } catch ( e ) {
14085 xml = undefined;
14086 }
14087
14088 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
14089 jQuery.error( "Invalid XML: " + data );
14090 }
14091 return xml;
14092 };
14093
14094
14095 var
14096 // Document location
14097 ajaxLocParts,
14098 ajaxLocation,
14099
14100 rhash = /#.*$/,
14101 rts = /([?&])_=[^&]*/,
14102 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
14103 // #7653, #8125, #8152: local protocol detection
14104 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
14105 rnoContent = /^(?:GET|HEAD)$/,
14106 rprotocol = /^\/\//,
14107 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
14108
14109 /* Prefilters
14110 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
14111 * 2) These are called:
14112 * - BEFORE asking for a transport
14113 * - AFTER param serialization (s.data is a string if s.processData is true)
14114 * 3) key is the dataType
14115 * 4) the catchall symbol "*" can be used
14116 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
14117 */
14118 prefilters = {},
14119
14120 /* Transports bindings
14121 * 1) key is the dataType
14122 * 2) the catchall symbol "*" can be used
14123 * 3) selection will start with transport dataType and THEN go to "*" if needed
14124 */
14125 transports = {},
14126
14127 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
14128 allTypes = "*/".concat("*");
14129
14130 // #8138, IE may throw an exception when accessing
14131 // a field from window.location if document.domain has been set
14132 try {
14133 ajaxLocation = location.href;
14134 } catch( e ) {
14135 // Use the href attribute of an A element
14136 // since IE will modify it given document.location
14137 ajaxLocation = document.createElement( "a" );
14138 ajaxLocation.href = "";
14139 ajaxLocation = ajaxLocation.href;
14140 }
14141
14142 // Segment location into parts
14143 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
14144
14145 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
14146 function addToPrefiltersOrTransports( structure ) {
14147
14148 // dataTypeExpression is optional and defaults to "*"
14149 return function( dataTypeExpression, func ) {
14150
14151 if ( typeof dataTypeExpression !== "string" ) {
14152 func = dataTypeExpression;
14153 dataTypeExpression = "*";
14154 }
14155
14156 var dataType,
14157 i = 0,
14158 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
14159
14160 if ( jQuery.isFunction( func ) ) {
14161 // For each dataType in the dataTypeExpression
14162 while ( (dataType = dataTypes[i++]) ) {
14163 // Prepend if requested
14164 if ( dataType[0] === "+" ) {
14165 dataType = dataType.slice( 1 ) || "*";
14166 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
14167
14168 // Otherwise append
14169 } else {
14170 (structure[ dataType ] = structure[ dataType ] || []).push( func );
14171 }
14172 }
14173 }
14174 };
14175 }
14176
14177 // Base inspection function for prefilters and transports
14178 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
14179
14180 var inspected = {},
14181 seekingTransport = ( structure === transports );
14182
14183 function inspect( dataType ) {
14184 var selected;
14185 inspected[ dataType ] = true;
14186 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
14187 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
14188 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
14189 options.dataTypes.unshift( dataTypeOrTransport );
14190 inspect( dataTypeOrTransport );
14191 return false;
14192 } else if ( seekingTransport ) {
14193 return !( selected = dataTypeOrTransport );
14194 }
14195 });
14196 return selected;
14197 }
14198
14199 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
14200 }
14201
14202 // A special extend for ajax options
14203 // that takes "flat" options (not to be deep extended)
14204 // Fixes #9887
14205 function ajaxExtend( target, src ) {
14206 var key, deep,
14207 flatOptions = jQuery.ajaxSettings.flatOptions || {};
14208
14209 for ( key in src ) {
14210 if ( src[ key ] !== undefined ) {
14211 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
14212 }
14213 }
14214 if ( deep ) {
14215 jQuery.extend( true, target, deep );
14216 }
14217
14218 return target;
14219 }
14220
14221 /* Handles responses to an ajax request:
14222 * - finds the right dataType (mediates between content-type and expected dataType)
14223 * - returns the corresponding response
14224 */
14225 function ajaxHandleResponses( s, jqXHR, responses ) {
14226
14227 var ct, type, finalDataType, firstDataType,
14228 contents = s.contents,
14229 dataTypes = s.dataTypes;
14230
14231 // Remove auto dataType and get content-type in the process
14232 while ( dataTypes[ 0 ] === "*" ) {
14233 dataTypes.shift();
14234 if ( ct === undefined ) {
14235 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
14236 }
14237 }
14238
14239 // Check if we're dealing with a known content-type
14240 if ( ct ) {
14241 for ( type in contents ) {
14242 if ( contents[ type ] && contents[ type ].test( ct ) ) {
14243 dataTypes.unshift( type );
14244 break;
14245 }
14246 }
14247 }
14248
14249 // Check to see if we have a response for the expected dataType
14250 if ( dataTypes[ 0 ] in responses ) {
14251 finalDataType = dataTypes[ 0 ];
14252 } else {
14253 // Try convertible dataTypes
14254 for ( type in responses ) {
14255 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
14256 finalDataType = type;
14257 break;
14258 }
14259 if ( !firstDataType ) {
14260 firstDataType = type;
14261 }
14262 }
14263 // Or just use first one
14264 finalDataType = finalDataType || firstDataType;
14265 }
14266
14267 // If we found a dataType
14268 // We add the dataType to the list if needed
14269 // and return the corresponding response
14270 if ( finalDataType ) {
14271 if ( finalDataType !== dataTypes[ 0 ] ) {
14272 dataTypes.unshift( finalDataType );
14273 }
14274 return responses[ finalDataType ];
14275 }
14276 }
14277
14278 /* Chain conversions given the request and the original response
14279 * Also sets the responseXXX fields on the jqXHR instance
14280 */
14281 function ajaxConvert( s, response, jqXHR, isSuccess ) {
14282 var conv2, current, conv, tmp, prev,
14283 converters = {},
14284 // Work with a copy of dataTypes in case we need to modify it for conversion
14285 dataTypes = s.dataTypes.slice();
14286
14287 // Create converters map with lowercased keys
14288 if ( dataTypes[ 1 ] ) {
14289 for ( conv in s.converters ) {
14290 converters[ conv.toLowerCase() ] = s.converters[ conv ];
14291 }
14292 }
14293
14294 current = dataTypes.shift();
14295
14296 // Convert to each sequential dataType
14297 while ( current ) {
14298
14299 if ( s.responseFields[ current ] ) {
14300 jqXHR[ s.responseFields[ current ] ] = response;
14301 }
14302
14303 // Apply the dataFilter if provided
14304 if ( !prev && isSuccess && s.dataFilter ) {
14305 response = s.dataFilter( response, s.dataType );
14306 }
14307
14308 prev = current;
14309 current = dataTypes.shift();
14310
14311 if ( current ) {
14312
14313 // There's only work to do if current dataType is non-auto
14314 if ( current === "*" ) {
14315
14316 current = prev;
14317
14318 // Convert response if prev dataType is non-auto and differs from current
14319 } else if ( prev !== "*" && prev !== current ) {
14320
14321 // Seek a direct converter
14322 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
14323
14324 // If none found, seek a pair
14325 if ( !conv ) {
14326 for ( conv2 in converters ) {
14327
14328 // If conv2 outputs current
14329 tmp = conv2.split( " " );
14330 if ( tmp[ 1 ] === current ) {
14331
14332 // If prev can be converted to accepted input
14333 conv = converters[ prev + " " + tmp[ 0 ] ] ||
14334 converters[ "* " + tmp[ 0 ] ];
14335 if ( conv ) {
14336 // Condense equivalence converters
14337 if ( conv === true ) {
14338 conv = converters[ conv2 ];
14339
14340 // Otherwise, insert the intermediate dataType
14341 } else if ( converters[ conv2 ] !== true ) {
14342 current = tmp[ 0 ];
14343 dataTypes.unshift( tmp[ 1 ] );
14344 }
14345 break;
14346 }
14347 }
14348 }
14349 }
14350
14351 // Apply converter (if not an equivalence)
14352 if ( conv !== true ) {
14353
14354 // Unless errors are allowed to bubble, catch and return them
14355 if ( conv && s[ "throws" ] ) {
14356 response = conv( response );
14357 } else {
14358 try {
14359 response = conv( response );
14360 } catch ( e ) {
14361 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
14362 }
14363 }
14364 }
14365 }
14366 }
14367 }
14368
14369 return { state: "success", data: response };
14370 }
14371
14372 jQuery.extend({
14373
14374 // Counter for holding the number of active queries
14375 active: 0,
14376
14377 // Last-Modified header cache for next request
14378 lastModified: {},
14379 etag: {},
14380
14381 ajaxSettings: {
14382 url: ajaxLocation,
14383 type: "GET",
14384 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
14385 global: true,
14386 processData: true,
14387 async: true,
14388 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
14389 /*
14390 timeout: 0,
14391 data: null,
14392 dataType: null,
14393 username: null,
14394 password: null,
14395 cache: null,
14396 throws: false,
14397 traditional: false,
14398 headers: {},
14399 */
14400
14401 accepts: {
14402 "*": allTypes,
14403 text: "text/plain",
14404 html: "text/html",
14405 xml: "application/xml, text/xml",
14406 json: "application/json, text/javascript"
14407 },
14408
14409 contents: {
14410 xml: /xml/,
14411 html: /html/,
14412 json: /json/
14413 },
14414
14415 responseFields: {
14416 xml: "responseXML",
14417 text: "responseText",
14418 json: "responseJSON"
14419 },
14420
14421 // Data converters
14422 // Keys separate source (or catchall "*") and destination types with a single space
14423 converters: {
14424
14425 // Convert anything to text
14426 "* text": String,
14427
14428 // Text to html (true = no transformation)
14429 "text html": true,
14430
14431 // Evaluate text as a json expression
14432 "text json": jQuery.parseJSON,
14433
14434 // Parse text as xml
14435 "text xml": jQuery.parseXML
14436 },
14437
14438 // For options that shouldn't be deep extended:
14439 // you can add your own custom options here if
14440 // and when you create one that shouldn't be
14441 // deep extended (see ajaxExtend)
14442 flatOptions: {
14443 url: true,
14444 context: true
14445 }
14446 },
14447
14448 // Creates a full fledged settings object into target
14449 // with both ajaxSettings and settings fields.
14450 // If target is omitted, writes into ajaxSettings.
14451 ajaxSetup: function( target, settings ) {
14452 return settings ?
14453
14454 // Building a settings object
14455 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
14456
14457 // Extending ajaxSettings
14458 ajaxExtend( jQuery.ajaxSettings, target );
14459 },
14460
14461 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
14462 ajaxTransport: addToPrefiltersOrTransports( transports ),
14463
14464 // Main method
14465 ajax: function( url, options ) {
14466
14467 // If url is an object, simulate pre-1.5 signature
14468 if ( typeof url === "object" ) {
14469 options = url;
14470 url = undefined;
14471 }
14472
14473 // Force options to be an object
14474 options = options || {};
14475
14476 var transport,
14477 // URL without anti-cache param
14478 cacheURL,
14479 // Response headers
14480 responseHeadersString,
14481 responseHeaders,
14482 // timeout handle
14483 timeoutTimer,
14484 // Cross-domain detection vars
14485 parts,
14486 // To know if global events are to be dispatched
14487 fireGlobals,
14488 // Loop variable
14489 i,
14490 // Create the final options object
14491 s = jQuery.ajaxSetup( {}, options ),
14492 // Callbacks context
14493 callbackContext = s.context || s,
14494 // Context for global events is callbackContext if it is a DOM node or jQuery collection
14495 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
14496 jQuery( callbackContext ) :
14497 jQuery.event,
14498 // Deferreds
14499 deferred = jQuery.Deferred(),
14500 completeDeferred = jQuery.Callbacks("once memory"),
14501 // Status-dependent callbacks
14502 statusCode = s.statusCode || {},
14503 // Headers (they are sent all at once)
14504 requestHeaders = {},
14505 requestHeadersNames = {},
14506 // The jqXHR state
14507 state = 0,
14508 // Default abort message
14509 strAbort = "canceled",
14510 // Fake xhr
14511 jqXHR = {
14512 readyState: 0,
14513
14514 // Builds headers hashtable if needed
14515 getResponseHeader: function( key ) {
14516 var match;
14517 if ( state === 2 ) {
14518 if ( !responseHeaders ) {
14519 responseHeaders = {};
14520 while ( (match = rheaders.exec( responseHeadersString )) ) {
14521 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
14522 }
14523 }
14524 match = responseHeaders[ key.toLowerCase() ];
14525 }
14526 return match == null ? null : match;
14527 },
14528
14529 // Raw string
14530 getAllResponseHeaders: function() {
14531 return state === 2 ? responseHeadersString : null;
14532 },
14533
14534 // Caches the header
14535 setRequestHeader: function( name, value ) {
14536 var lname = name.toLowerCase();
14537 if ( !state ) {
14538 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
14539 requestHeaders[ name ] = value;
14540 }
14541 return this;
14542 },
14543
14544 // Overrides response content-type header
14545 overrideMimeType: function( type ) {
14546 if ( !state ) {
14547 s.mimeType = type;
14548 }
14549 return this;
14550 },
14551
14552 // Status-dependent callbacks
14553 statusCode: function( map ) {
14554 var code;
14555 if ( map ) {
14556 if ( state < 2 ) {
14557 for ( code in map ) {
14558 // Lazy-add the new callback in a way that preserves old ones
14559 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
14560 }
14561 } else {
14562 // Execute the appropriate callbacks
14563 jqXHR.always( map[ jqXHR.status ] );
14564 }
14565 }
14566 return this;
14567 },
14568
14569 // Cancel the request
14570 abort: function( statusText ) {
14571 var finalText = statusText || strAbort;
14572 if ( transport ) {
14573 transport.abort( finalText );
14574 }
14575 done( 0, finalText );
14576 return this;
14577 }
14578 };
14579
14580 // Attach deferreds
14581 deferred.promise( jqXHR ).complete = completeDeferred.add;
14582 jqXHR.success = jqXHR.done;
14583 jqXHR.error = jqXHR.fail;
14584
14585 // Remove hash character (#7531: and string promotion)
14586 // Add protocol if not provided (prefilters might expect it)
14587 // Handle falsy url in the settings object (#10093: consistency with old signature)
14588 // We also use the url parameter if available
14589 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" )
14590 .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
14591
14592 // Alias method option to type as per ticket #12004
14593 s.type = options.method || options.type || s.method || s.type;
14594
14595 // Extract dataTypes list
14596 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
14597
14598 // A cross-domain request is in order when we have a protocol:host:port mismatch
14599 if ( s.crossDomain == null ) {
14600 parts = rurl.exec( s.url.toLowerCase() );
14601 s.crossDomain = !!( parts &&
14602 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
14603 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
14604 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
14605 );
14606 }
14607
14608 // Convert data if not already a string
14609 if ( s.data && s.processData && typeof s.data !== "string" ) {
14610 s.data = jQuery.param( s.data, s.traditional );
14611 }
14612
14613 // Apply prefilters
14614 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
14615
14616 // If request was aborted inside a prefilter, stop there
14617 if ( state === 2 ) {
14618 return jqXHR;
14619 }
14620
14621 // We can fire global events as of now if asked to
14622 fireGlobals = s.global;
14623
14624 // Watch for a new set of requests
14625 if ( fireGlobals && jQuery.active++ === 0 ) {
14626 jQuery.event.trigger("ajaxStart");
14627 }
14628
14629 // Uppercase the type
14630 s.type = s.type.toUpperCase();
14631
14632 // Determine if request has content
14633 s.hasContent = !rnoContent.test( s.type );
14634
14635 // Save the URL in case we're toying with the If-Modified-Since
14636 // and/or If-None-Match header later on
14637 cacheURL = s.url;
14638
14639 // More options handling for requests with no content
14640 if ( !s.hasContent ) {
14641
14642 // If data is available, append data to url
14643 if ( s.data ) {
14644 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
14645 // #9682: remove data so that it's not used in an eventual retry
14646 delete s.data;
14647 }
14648
14649 // Add anti-cache in url if needed
14650 if ( s.cache === false ) {
14651 s.url = rts.test( cacheURL ) ?
14652
14653 // If there is already a '_' parameter, set its value
14654 cacheURL.replace( rts, "$1_=" + nonce++ ) :
14655
14656 // Otherwise add one to the end
14657 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
14658 }
14659 }
14660
14661 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
14662 if ( s.ifModified ) {
14663 if ( jQuery.lastModified[ cacheURL ] ) {
14664 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
14665 }
14666 if ( jQuery.etag[ cacheURL ] ) {
14667 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
14668 }
14669 }
14670
14671 // Set the correct header, if data is being sent
14672 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
14673 jqXHR.setRequestHeader( "Content-Type", s.contentType );
14674 }
14675
14676 // Set the Accepts header for the server, depending on the dataType
14677 jqXHR.setRequestHeader(
14678 "Accept",
14679 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
14680 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
14681 s.accepts[ "*" ]
14682 );
14683
14684 // Check for headers option
14685 for ( i in s.headers ) {
14686 jqXHR.setRequestHeader( i, s.headers[ i ] );
14687 }
14688
14689 // Allow custom headers/mimetypes and early abort
14690 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
14691 // Abort if not done already and return
14692 return jqXHR.abort();
14693 }
14694
14695 // aborting is no longer a cancellation
14696 strAbort = "abort";
14697
14698 // Install callbacks on deferreds
14699 for ( i in { success: 1, error: 1, complete: 1 } ) {
14700 jqXHR[ i ]( s[ i ] );
14701 }
14702
14703 // Get transport
14704 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
14705
14706 // If no transport, we auto-abort
14707 if ( !transport ) {
14708 done( -1, "No Transport" );
14709 } else {
14710 jqXHR.readyState = 1;
14711
14712 // Send global event
14713 if ( fireGlobals ) {
14714 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
14715 }
14716 // Timeout
14717 if ( s.async && s.timeout > 0 ) {
14718 timeoutTimer = setTimeout(function() {
14719 jqXHR.abort("timeout");
14720 }, s.timeout );
14721 }
14722
14723 try {
14724 state = 1;
14725 transport.send( requestHeaders, done );
14726 } catch ( e ) {
14727 // Propagate exception as error if not done
14728 if ( state < 2 ) {
14729 done( -1, e );
14730 // Simply rethrow otherwise
14731 } else {
14732 throw e;
14733 }
14734 }
14735 }
14736
14737 // Callback for when everything is done
14738 function done( status, nativeStatusText, responses, headers ) {
14739 var isSuccess, success, error, response, modified,
14740 statusText = nativeStatusText;
14741
14742 // Called once
14743 if ( state === 2 ) {
14744 return;
14745 }
14746
14747 // State is "done" now
14748 state = 2;
14749
14750 // Clear timeout if it exists
14751 if ( timeoutTimer ) {
14752 clearTimeout( timeoutTimer );
14753 }
14754
14755 // Dereference transport for early garbage collection
14756 // (no matter how long the jqXHR object will be used)
14757 transport = undefined;
14758
14759 // Cache response headers
14760 responseHeadersString = headers || "";
14761
14762 // Set readyState
14763 jqXHR.readyState = status > 0 ? 4 : 0;
14764
14765 // Determine if successful
14766 isSuccess = status >= 200 && status < 300 || status === 304;
14767
14768 // Get response data
14769 if ( responses ) {
14770 response = ajaxHandleResponses( s, jqXHR, responses );
14771 }
14772
14773 // Convert no matter what (that way responseXXX fields are always set)
14774 response = ajaxConvert( s, response, jqXHR, isSuccess );
14775
14776 // If successful, handle type chaining
14777 if ( isSuccess ) {
14778
14779 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
14780 if ( s.ifModified ) {
14781 modified = jqXHR.getResponseHeader("Last-Modified");
14782 if ( modified ) {
14783 jQuery.lastModified[ cacheURL ] = modified;
14784 }
14785 modified = jqXHR.getResponseHeader("etag");
14786 if ( modified ) {
14787 jQuery.etag[ cacheURL ] = modified;
14788 }
14789 }
14790
14791 // if no content
14792 if ( status === 204 || s.type === "HEAD" ) {
14793 statusText = "nocontent";
14794
14795 // if not modified
14796 } else if ( status === 304 ) {
14797 statusText = "notmodified";
14798
14799 // If we have data, let's convert it
14800 } else {
14801 statusText = response.state;
14802 success = response.data;
14803 error = response.error;
14804 isSuccess = !error;
14805 }
14806 } else {
14807 // We extract error from statusText
14808 // then normalize statusText and status for non-aborts
14809 error = statusText;
14810 if ( status || !statusText ) {
14811 statusText = "error";
14812 if ( status < 0 ) {
14813 status = 0;
14814 }
14815 }
14816 }
14817
14818 // Set data for the fake xhr object
14819 jqXHR.status = status;
14820 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
14821
14822 // Success/Error
14823 if ( isSuccess ) {
14824 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
14825 } else {
14826 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
14827 }
14828
14829 // Status-dependent callbacks
14830 jqXHR.statusCode( statusCode );
14831 statusCode = undefined;
14832
14833 if ( fireGlobals ) {
14834 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
14835 [ jqXHR, s, isSuccess ? success : error ] );
14836 }
14837
14838 // Complete
14839 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
14840
14841 if ( fireGlobals ) {
14842 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
14843 // Handle the global AJAX counter
14844 if ( !( --jQuery.active ) ) {
14845 jQuery.event.trigger("ajaxStop");
14846 }
14847 }
14848 }
14849
14850 return jqXHR;
14851 },
14852
14853 getJSON: function( url, data, callback ) {
14854 return jQuery.get( url, data, callback, "json" );
14855 },
14856
14857 getScript: function( url, callback ) {
14858 return jQuery.get( url, undefined, callback, "script" );
14859 }
14860 });
14861
14862 jQuery.each( [ "get", "post" ], function( i, method ) {
14863 jQuery[ method ] = function( url, data, callback, type ) {
14864 // shift arguments if data argument was omitted
14865 if ( jQuery.isFunction( data ) ) {
14866 type = type || callback;
14867 callback = data;
14868 data = undefined;
14869 }
14870
14871 return jQuery.ajax({
14872 url: url,
14873 type: method,
14874 dataType: type,
14875 data: data,
14876 success: callback
14877 });
14878 };
14879 });
14880
14881 // Attach a bunch of functions for handling common AJAX events
14882 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
14883 jQuery.fn[ type ] = function( fn ) {
14884 return this.on( type, fn );
14885 };
14886 });
14887
14888
14889 jQuery._evalUrl = function( url ) {
14890 return jQuery.ajax({
14891 url: url,
14892 type: "GET",
14893 dataType: "script",
14894 async: false,
14895 global: false,
14896 "throws": true
14897 });
14898 };
14899
14900
14901 jQuery.fn.extend({
14902 wrapAll: function( html ) {
14903 var wrap;
14904
14905 if ( jQuery.isFunction( html ) ) {
14906 return this.each(function( i ) {
14907 jQuery( this ).wrapAll( html.call(this, i) );
14908 });
14909 }
14910
14911 if ( this[ 0 ] ) {
14912
14913 // The elements to wrap the target around
14914 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
14915
14916 if ( this[ 0 ].parentNode ) {
14917 wrap.insertBefore( this[ 0 ] );
14918 }
14919
14920 wrap.map(function() {
14921 var elem = this;
14922
14923 while ( elem.firstElementChild ) {
14924 elem = elem.firstElementChild;
14925 }
14926
14927 return elem;
14928 }).append( this );
14929 }
14930
14931 return this;
14932 },
14933
14934 wrapInner: function( html ) {
14935 if ( jQuery.isFunction( html ) ) {
14936 return this.each(function( i ) {
14937 jQuery( this ).wrapInner( html.call(this, i) );
14938 });
14939 }
14940
14941 return this.each(function() {
14942 var self = jQuery( this ),
14943 contents = self.contents();
14944
14945 if ( contents.length ) {
14946 contents.wrapAll( html );
14947
14948 } else {
14949 self.append( html );
14950 }
14951 });
14952 },
14953
14954 wrap: function( html ) {
14955 var isFunction = jQuery.isFunction( html );
14956
14957 return this.each(function( i ) {
14958 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
14959 });
14960 },
14961
14962 unwrap: function() {
14963 return this.parent().each(function() {
14964 if ( !jQuery.nodeName( this, "body" ) ) {
14965 jQuery( this ).replaceWith( this.childNodes );
14966 }
14967 }).end();
14968 }
14969 });
14970
14971
14972 jQuery.expr.filters.hidden = function( elem ) {
14973 // Support: Opera <= 12.12
14974 // Opera reports offsetWidths and offsetHeights less than zero on some elements
14975 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;
14976 };
14977 jQuery.expr.filters.visible = function( elem ) {
14978 return !jQuery.expr.filters.hidden( elem );
14979 };
14980
14981
14982
14983
14984 var r20 = /%20/g,
14985 rbracket = /\[\]$/,
14986 rCRLF = /\r?\n/g,
14987 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
14988 rsubmittable = /^(?:input|select|textarea|keygen)/i;
14989
14990 function buildParams( prefix, obj, traditional, add ) {
14991 var name;
14992
14993 if ( jQuery.isArray( obj ) ) {
14994 // Serialize array item.
14995 jQuery.each( obj, function( i, v ) {
14996 if ( traditional || rbracket.test( prefix ) ) {
14997 // Treat each array item as a scalar.
14998 add( prefix, v );
14999
15000 } else {
15001 // Item is non-scalar (array or object), encode its numeric index.
15002 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
15003 }
15004 });
15005
15006 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
15007 // Serialize object item.
15008 for ( name in obj ) {
15009 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
15010 }
15011
15012 } else {
15013 // Serialize scalar item.
15014 add( prefix, obj );
15015 }
15016 }
15017
15018 // Serialize an array of form elements or a set of
15019 // key/values into a query string
15020 jQuery.param = function( a, traditional ) {
15021 var prefix,
15022 s = [],
15023 add = function( key, value ) {
15024 // If value is a function, invoke it and return its value
15025 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
15026 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
15027 };
15028
15029 // Set traditional to true for jQuery <= 1.3.2 behavior.
15030 if ( traditional === undefined ) {
15031 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
15032 }
15033
15034 // If an array was passed in, assume that it is an array of form elements.
15035 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
15036 // Serialize the form elements
15037 jQuery.each( a, function() {
15038 add( this.name, this.value );
15039 });
15040
15041 } else {
15042 // If traditional, encode the "old" way (the way 1.3.2 or older
15043 // did it), otherwise encode params recursively.
15044 for ( prefix in a ) {
15045 buildParams( prefix, a[ prefix ], traditional, add );
15046 }
15047 }
15048
15049 // Return the resulting serialization
15050 return s.join( "&" ).replace( r20, "+" );
15051 };
15052
15053 jQuery.fn.extend({
15054 serialize: function() {
15055 return jQuery.param( this.serializeArray() );
15056 },
15057 serializeArray: function() {
15058 return this.map(function() {
15059 // Can add propHook for "elements" to filter or add form elements
15060 var elements = jQuery.prop( this, "elements" );
15061 return elements ? jQuery.makeArray( elements ) : this;
15062 })
15063 .filter(function() {
15064 var type = this.type;
15065
15066 // Use .is( ":disabled" ) so that fieldset[disabled] works
15067 return this.name && !jQuery( this ).is( ":disabled" ) &&
15068 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
15069 ( this.checked || !rcheckableType.test( type ) );
15070 })
15071 .map(function( i, elem ) {
15072 var val = jQuery( this ).val();
15073
15074 return val == null ?
15075 null :
15076 jQuery.isArray( val ) ?
15077 jQuery.map( val, function( val ) {
15078 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
15079 }) :
15080 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
15081 }).get();
15082 }
15083 });
15084
15085
15086 jQuery.ajaxSettings.xhr = function() {
15087 try {
15088 return new XMLHttpRequest();
15089 } catch( e ) {}
15090 };
15091
15092 var xhrId = 0,
15093 xhrCallbacks = {},
15094 xhrSuccessStatus = {
15095 // file protocol always yields status code 0, assume 200
15096 0: 200,
15097 // Support: IE9
15098 // #1450: sometimes IE returns 1223 when it should be 204
15099 1223: 204
15100 },
15101 xhrSupported = jQuery.ajaxSettings.xhr();
15102
15103 // Support: IE9
15104 // Open requests must be manually aborted on unload (#5280)
15105 if ( window.ActiveXObject ) {
15106 jQuery( window ).on( "unload", function() {
15107 for ( var key in xhrCallbacks ) {
15108 xhrCallbacks[ key ]();
15109 }
15110 });
15111 }
15112
15113 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
15114 support.ajax = xhrSupported = !!xhrSupported;
15115
15116 jQuery.ajaxTransport(function( options ) {
15117 var callback;
15118
15119 // Cross domain only allowed if supported through XMLHttpRequest
15120 if ( support.cors || xhrSupported && !options.crossDomain ) {
15121 return {
15122 send: function( headers, complete ) {
15123 var i,
15124 xhr = options.xhr(),
15125 id = ++xhrId;
15126
15127 xhr.open( options.type, options.url, options.async, options.username, options.password );
15128
15129 // Apply custom fields if provided
15130 if ( options.xhrFields ) {
15131 for ( i in options.xhrFields ) {
15132 xhr[ i ] = options.xhrFields[ i ];
15133 }
15134 }
15135
15136 // Override mime type if needed
15137 if ( options.mimeType && xhr.overrideMimeType ) {
15138 xhr.overrideMimeType( options.mimeType );
15139 }
15140
15141 // X-Requested-With header
15142 // For cross-domain requests, seeing as conditions for a preflight are
15143 // akin to a jigsaw puzzle, we simply never set it to be sure.
15144 // (it can always be set on a per-request basis or even using ajaxSetup)
15145 // For same-domain requests, won't change header if already provided.
15146 if ( !options.crossDomain && !headers["X-Requested-With"] ) {
15147 headers["X-Requested-With"] = "XMLHttpRequest";
15148 }
15149
15150 // Set headers
15151 for ( i in headers ) {
15152 xhr.setRequestHeader( i, headers[ i ] );
15153 }
15154
15155 // Callback
15156 callback = function( type ) {
15157 return function() {
15158 if ( callback ) {
15159 delete xhrCallbacks[ id ];
15160 callback = xhr.onload = xhr.onerror = null;
15161
15162 if ( type === "abort" ) {
15163 xhr.abort();
15164 } else if ( type === "error" ) {
15165 complete(
15166 // file: protocol always yields status 0; see #8605, #14207
15167 xhr.status,
15168 xhr.statusText
15169 );
15170 } else {
15171 complete(
15172 xhrSuccessStatus[ xhr.status ] || xhr.status,
15173 xhr.statusText,
15174 // Support: IE9
15175 // Accessing binary-data responseText throws an exception
15176 // (#11426)
15177 typeof xhr.responseText === "string" ? {
15178 text: xhr.responseText
15179 } : undefined,
15180 xhr.getAllResponseHeaders()
15181 );
15182 }
15183 }
15184 };
15185 };
15186
15187 // Listen to events
15188 xhr.onload = callback();
15189 xhr.onerror = callback("error");
15190
15191 // Create the abort callback
15192 callback = xhrCallbacks[ id ] = callback("abort");
15193
15194 try {
15195 // Do send the request (this may raise an exception)
15196 xhr.send( options.hasContent && options.data || null );
15197 } catch ( e ) {
15198 // #14683: Only rethrow if this hasn't been notified as an error yet
15199 if ( callback ) {
15200 throw e;
15201 }
15202 }
15203 },
15204
15205 abort: function() {
15206 if ( callback ) {
15207 callback();
15208 }
15209 }
15210 };
15211 }
15212 });
15213
15214
15215
15216
15217 // Install script dataType
15218 jQuery.ajaxSetup({
15219 accepts: {
15220 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
15221 },
15222 contents: {
15223 script: /(?:java|ecma)script/
15224 },
15225 converters: {
15226 "text script": function( text ) {
15227 jQuery.globalEval( text );
15228 return text;
15229 }
15230 }
15231 });
15232
15233 // Handle cache's special case and crossDomain
15234 jQuery.ajaxPrefilter( "script", function( s ) {
15235 if ( s.cache === undefined ) {
15236 s.cache = false;
15237 }
15238 if ( s.crossDomain ) {
15239 s.type = "GET";
15240 }
15241 });
15242
15243 // Bind script tag hack transport
15244 jQuery.ajaxTransport( "script", function( s ) {
15245 // This transport only deals with cross domain requests
15246 if ( s.crossDomain ) {
15247 var script, callback;
15248 return {
15249 send: function( _, complete ) {
15250 script = jQuery("<script>").prop({
15251 async: true,
15252 charset: s.scriptCharset,
15253 src: s.url
15254 }).on(
15255 "load error",
15256 callback = function( evt ) {
15257 script.remove();
15258 callback = null;
15259 if ( evt ) {
15260 complete( evt.type === "error" ? 404 : 200, evt.type );
15261 }
15262 }
15263 );
15264 document.head.appendChild( script[ 0 ] );
15265 },
15266 abort: function() {
15267 if ( callback ) {
15268 callback();
15269 }
15270 }
15271 };
15272 }
15273 });
15274
15275
15276
15277
15278 var oldCallbacks = [],
15279 rjsonp = /(=)\?(?=&|$)|\?\?/;
15280
15281 // Default jsonp settings
15282 jQuery.ajaxSetup({
15283 jsonp: "callback",
15284 jsonpCallback: function() {
15285 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
15286 this[ callback ] = true;
15287 return callback;
15288 }
15289 });
15290
15291 // Detect, normalize options and install callbacks for jsonp requests
15292 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
15293
15294 var callbackName, overwritten, responseContainer,
15295 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
15296 "url" :
15297 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
15298 );
15299
15300 // Handle iff the expected data type is "jsonp" or we have a parameter to set
15301 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
15302
15303 // Get callback name, remembering preexisting value associated with it
15304 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
15305 s.jsonpCallback() :
15306 s.jsonpCallback;
15307
15308 // Insert callback into url or form data
15309 if ( jsonProp ) {
15310 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
15311 } else if ( s.jsonp !== false ) {
15312 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
15313 }
15314
15315 // Use data converter to retrieve json after script execution
15316 s.converters["script json"] = function() {
15317 if ( !responseContainer ) {
15318 jQuery.error( callbackName + " was not called" );
15319 }
15320 return responseContainer[ 0 ];
15321 };
15322
15323 // force json dataType
15324 s.dataTypes[ 0 ] = "json";
15325
15326 // Install callback
15327 overwritten = window[ callbackName ];
15328 window[ callbackName ] = function() {
15329 responseContainer = arguments;
15330 };
15331
15332 // Clean-up function (fires after converters)
15333 jqXHR.always(function() {
15334 // Restore preexisting value
15335 window[ callbackName ] = overwritten;
15336
15337 // Save back as free
15338 if ( s[ callbackName ] ) {
15339 // make sure that re-using the options doesn't screw things around
15340 s.jsonpCallback = originalSettings.jsonpCallback;
15341
15342 // save the callback name for future use
15343 oldCallbacks.push( callbackName );
15344 }
15345
15346 // Call if it was a function and we have a response
15347 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
15348 overwritten( responseContainer[ 0 ] );
15349 }
15350
15351 responseContainer = overwritten = undefined;
15352 });
15353
15354 // Delegate to script
15355 return "script";
15356 }
15357 });
15358
15359
15360
15361
15362 // data: string of html
15363 // context (optional): If specified, the fragment will be created in this context, defaults to document
15364 // keepScripts (optional): If true, will include scripts passed in the html string
15365 jQuery.parseHTML = function( data, context, keepScripts ) {
15366 if ( !data || typeof data !== "string" ) {
15367 return null;
15368 }
15369 if ( typeof context === "boolean" ) {
15370 keepScripts = context;
15371 context = false;
15372 }
15373 context = context || document;
15374
15375 var parsed = rsingleTag.exec( data ),
15376 scripts = !keepScripts && [];
15377
15378 // Single tag
15379 if ( parsed ) {
15380 return [ context.createElement( parsed[1] ) ];
15381 }
15382
15383 parsed = jQuery.buildFragment( [ data ], context, scripts );
15384
15385 if ( scripts && scripts.length ) {
15386 jQuery( scripts ).remove();
15387 }
15388
15389 return jQuery.merge( [], parsed.childNodes );
15390 };
15391
15392
15393 // Keep a copy of the old load method
15394 var _load = jQuery.fn.load;
15395
15396 /**
15397 * Load a url into a page
15398 */
15399 jQuery.fn.load = function( url, params, callback ) {
15400 if ( typeof url !== "string" && _load ) {
15401 return _load.apply( this, arguments );
15402 }
15403
15404 var selector, type, response,
15405 self = this,
15406 off = url.indexOf(" ");
15407
15408 if ( off >= 0 ) {
15409 selector = jQuery.trim( url.slice( off ) );
15410 url = url.slice( 0, off );
15411 }
15412
15413 // If it's a function
15414 if ( jQuery.isFunction( params ) ) {
15415
15416 // We assume that it's the callback
15417 callback = params;
15418 params = undefined;
15419
15420 // Otherwise, build a param string
15421 } else if ( params && typeof params === "object" ) {
15422 type = "POST";
15423 }
15424
15425 // If we have elements to modify, make the request
15426 if ( self.length > 0 ) {
15427 jQuery.ajax({
15428 url: url,
15429
15430 // if "type" variable is undefined, then "GET" method will be used
15431 type: type,
15432 dataType: "html",
15433 data: params
15434 }).done(function( responseText ) {
15435
15436 // Save response for use in complete callback
15437 response = arguments;
15438
15439 self.html( selector ?
15440
15441 // If a selector was specified, locate the right elements in a dummy div
15442 // Exclude scripts to avoid IE 'Permission Denied' errors
15443 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
15444
15445 // Otherwise use the full result
15446 responseText );
15447
15448 }).complete( callback && function( jqXHR, status ) {
15449 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
15450 });
15451 }
15452
15453 return this;
15454 };
15455
15456
15457
15458
15459 jQuery.expr.filters.animated = function( elem ) {
15460 return jQuery.grep(jQuery.timers, function( fn ) {
15461 return elem === fn.elem;
15462 }).length;
15463 };
15464
15465
15466
15467
15468 var docElem = window.document.documentElement;
15469
15470 /**
15471 * Gets a window from an element
15472 */
15473 function getWindow( elem ) {
15474 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
15475 }
15476
15477 jQuery.offset = {
15478 setOffset: function( elem, options, i ) {
15479 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
15480 position = jQuery.css( elem, "position" ),
15481 curElem = jQuery( elem ),
15482 props = {};
15483
15484 // Set position first, in-case top/left are set even on static elem
15485 if ( position === "static" ) {
15486 elem.style.position = "relative";
15487 }
15488
15489 curOffset = curElem.offset();
15490 curCSSTop = jQuery.css( elem, "top" );
15491 curCSSLeft = jQuery.css( elem, "left" );
15492 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
15493 ( curCSSTop + curCSSLeft ).indexOf("auto") > -1;
15494
15495 // Need to be able to calculate position if either top or left is auto and position is either absolute or fixed
15496 if ( calculatePosition ) {
15497 curPosition = curElem.position();
15498 curTop = curPosition.top;
15499 curLeft = curPosition.left;
15500
15501 } else {
15502 curTop = parseFloat( curCSSTop ) || 0;
15503 curLeft = parseFloat( curCSSLeft ) || 0;
15504 }
15505
15506 if ( jQuery.isFunction( options ) ) {
15507 options = options.call( elem, i, curOffset );
15508 }
15509
15510 if ( options.top != null ) {
15511 props.top = ( options.top - curOffset.top ) + curTop;
15512 }
15513 if ( options.left != null ) {
15514 props.left = ( options.left - curOffset.left ) + curLeft;
15515 }
15516
15517 if ( "using" in options ) {
15518 options.using.call( elem, props );
15519
15520 } else {
15521 curElem.css( props );
15522 }
15523 }
15524 };
15525
15526 jQuery.fn.extend({
15527 offset: function( options ) {
15528 if ( arguments.length ) {
15529 return options === undefined ?
15530 this :
15531 this.each(function( i ) {
15532 jQuery.offset.setOffset( this, options, i );
15533 });
15534 }
15535
15536 var docElem, win,
15537 elem = this[ 0 ],
15538 box = { top: 0, left: 0 },
15539 doc = elem && elem.ownerDocument;
15540
15541 if ( !doc ) {
15542 return;
15543 }
15544
15545 docElem = doc.documentElement;
15546
15547 // Make sure it's not a disconnected DOM node
15548 if ( !jQuery.contains( docElem, elem ) ) {
15549 return box;
15550 }
15551
15552 // If we don't have gBCR, just use 0,0 rather than error
15553 // BlackBerry 5, iOS 3 (original iPhone)
15554 if ( typeof elem.getBoundingClientRect !== strundefined ) {
15555 box = elem.getBoundingClientRect();
15556 }
15557 win = getWindow( doc );
15558 return {
15559 top: box.top + win.pageYOffset - docElem.clientTop,
15560 left: box.left + win.pageXOffset - docElem.clientLeft
15561 };
15562 },
15563
15564 position: function() {
15565 if ( !this[ 0 ] ) {
15566 return;
15567 }
15568
15569 var offsetParent, offset,
15570 elem = this[ 0 ],
15571 parentOffset = { top: 0, left: 0 };
15572
15573 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
15574 if ( jQuery.css( elem, "position" ) === "fixed" ) {
15575 // We assume that getBoundingClientRect is available when computed position is fixed
15576 offset = elem.getBoundingClientRect();
15577
15578 } else {
15579 // Get *real* offsetParent
15580 offsetParent = this.offsetParent();
15581
15582 // Get correct offsets
15583 offset = this.offset();
15584 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
15585 parentOffset = offsetParent.offset();
15586 }
15587
15588 // Add offsetParent borders
15589 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
15590 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
15591 }
15592
15593 // Subtract parent offsets and element margins
15594 return {
15595 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
15596 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
15597 };
15598 },
15599
15600 offsetParent: function() {
15601 return this.map(function() {
15602 var offsetParent = this.offsetParent || docElem;
15603
15604 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
15605 offsetParent = offsetParent.offsetParent;
15606 }
15607
15608 return offsetParent || docElem;
15609 });
15610 }
15611 });
15612
15613 // Create scrollLeft and scrollTop methods
15614 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
15615 var top = "pageYOffset" === prop;
15616
15617 jQuery.fn[ method ] = function( val ) {
15618 return access( this, function( elem, method, val ) {
15619 var win = getWindow( elem );
15620
15621 if ( val === undefined ) {
15622 return win ? win[ prop ] : elem[ method ];
15623 }
15624
15625 if ( win ) {
15626 win.scrollTo(
15627 !top ? val : window.pageXOffset,
15628 top ? val : window.pageYOffset
15629 );
15630
15631 } else {
15632 elem[ method ] = val;
15633 }
15634 }, method, val, arguments.length, null );
15635 };
15636 });
15637
15638 // Add the top/left cssHooks using jQuery.fn.position
15639 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
15640 // getComputedStyle returns percent when specified for top/left/bottom/right
15641 // rather than make the css module depend on the offset module, we just check for it here
15642 jQuery.each( [ "top", "left" ], function( i, prop ) {
15643 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
15644 function( elem, computed ) {
15645 if ( computed ) {
15646 computed = curCSS( elem, prop );
15647 // if curCSS returns percentage, fallback to offset
15648 return rnumnonpx.test( computed ) ?
15649 jQuery( elem ).position()[ prop ] + "px" :
15650 computed;
15651 }
15652 }
15653 );
15654 });
15655
15656
15657 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
15658 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
15659 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
15660 // margin is only for outerHeight, outerWidth
15661 jQuery.fn[ funcName ] = function( margin, value ) {
15662 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
15663 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
15664
15665 return access( this, function( elem, type, value ) {
15666 var doc;
15667
15668 if ( jQuery.isWindow( elem ) ) {
15669 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
15670 // isn't a whole lot we can do. See pull request at this URL for discussion:
15671 // https://github.com/jquery/jquery/pull/764
15672 return elem.document.documentElement[ "client" + name ];
15673 }
15674
15675 // Get document width or height
15676 if ( elem.nodeType === 9 ) {
15677 doc = elem.documentElement;
15678
15679 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
15680 // whichever is greatest
15681 return Math.max(
15682 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
15683 elem.body[ "offset" + name ], doc[ "offset" + name ],
15684 doc[ "client" + name ]
15685 );
15686 }
15687
15688 return value === undefined ?
15689 // Get width or height on the element, requesting but not forcing parseFloat
15690 jQuery.css( elem, type, extra ) :
15691
15692 // Set width or height on the element
15693 jQuery.style( elem, type, value, extra );
15694 }, type, chainable ? margin : undefined, chainable, null );
15695 };
15696 });
15697 });
15698
15699
15700 // The number of elements contained in the matched element set
15701 jQuery.fn.size = function() {
15702 return this.length;
15703 };
15704
15705 jQuery.fn.andSelf = jQuery.fn.addBack;
15706
15707
15708
15709
15710 // Register as a named AMD module, since jQuery can be concatenated with other
15711 // files that may use define, but not via a proper concatenation script that
15712 // understands anonymous AMD modules. A named AMD is safest and most robust
15713 // way to register. Lowercase jquery is used because AMD module names are
15714 // derived from file names, and jQuery is normally delivered in a lowercase
15715 // file name. Do this after creating the global so that if an AMD module wants
15716 // to call noConflict to hide this version of jQuery, it will work.
15717
15718 // Note that for maximum portability, libraries that are not jQuery should
15719 // declare themselves as anonymous modules, and avoid setting a global if an
15720 // AMD loader is present. jQuery is a special case. For more information, see
15721 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
15722
15723 if ( typeof define === "function" && define.amd ) {
15724 define( "jquery", [], function() {
15725 return jQuery;
15726 });
15727 }
15728
15729
15730
15731
15732 var
15733 // Map over jQuery in case of overwrite
15734 _jQuery = window.jQuery,
15735
15736 // Map over the $ in case of overwrite
15737 _$ = window.$;
15738
15739 jQuery.noConflict = function( deep ) {
15740 if ( window.$ === jQuery ) {
15741 window.$ = _$;
15742 }
15743
15744 if ( deep && window.jQuery === jQuery ) {
15745 window.jQuery = _jQuery;
15746 }
15747
15748 return jQuery;
15749 };
15750
15751 // Expose jQuery and $ identifiers, even in
15752 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
15753 // and CommonJS for browser emulators (#13566)
15754 if ( typeof noGlobal === strundefined ) {
15755 window.jQuery = window.$ = jQuery;
15756 }
15757
15758
15759
15760
15761 return jQuery;
15762
15763 }));
15764 </script>
15765 <script>
15766 /*!
15767 * Bootstrap v3.2.0 (http://getbootstrap.com)
15768 * Copyright 2011-2014 Twitter, Inc.
15769 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15770 */
15771
15772 if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript requires jQuery') }
15773
15774 /* ========================================================================
15775 * Bootstrap: transition.js v3.2.0
15776 * http://getbootstrap.com/javascript/#transitions
15777 * ========================================================================
15778 * Copyright 2011-2014 Twitter, Inc.
15779 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15780 * ======================================================================== */
15781
15782
15783 +function ($) {
15784 'use strict';
15785
15786 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
15787 // ============================================================
15788
15789 function transitionEnd() {
15790 var el = document.createElement('bootstrap')
15791
15792 var transEndEventNames = {
15793 WebkitTransition : 'webkitTransitionEnd',
15794 MozTransition : 'transitionend',
15795 OTransition : 'oTransitionEnd otransitionend',
15796 transition : 'transitionend'
15797 }
15798
15799 for (var name in transEndEventNames) {
15800 if (el.style[name] !== undefined) {
15801 return { end: transEndEventNames[name] }
15802 }
15803 }
15804
15805 return false // explicit for ie8 ( ._.)
15806 }
15807
15808 // http://blog.alexmaccaw.com/css-transitions
15809 $.fn.emulateTransitionEnd = function (duration) {
15810 var called = false
15811 var $el = this
15812 $(this).one('bsTransitionEnd', function () { called = true })
15813 var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
15814 setTimeout(callback, duration)
15815 return this
15816 }
15817
15818 $(function () {
15819 $.support.transition = transitionEnd()
15820
15821 if (!$.support.transition) return
15822
15823 $.event.special.bsTransitionEnd = {
15824 bindType: $.support.transition.end,
15825 delegateType: $.support.transition.end,
15826 handle: function (e) {
15827 if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
15828 }
15829 }
15830 })
15831
15832 }(jQuery);
15833
15834 /* ========================================================================
15835 * Bootstrap: alert.js v3.2.0
15836 * http://getbootstrap.com/javascript/#alerts
15837 * ========================================================================
15838 * Copyright 2011-2014 Twitter, Inc.
15839 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15840 * ======================================================================== */
15841
15842
15843 +function ($) {
15844 'use strict';
15845
15846 // ALERT CLASS DEFINITION
15847 // ======================
15848
15849 var dismiss = '[data-dismiss="alert"]'
15850 var Alert = function (el) {
15851 $(el).on('click', dismiss, this.close)
15852 }
15853
15854 Alert.VERSION = '3.2.0'
15855
15856 Alert.prototype.close = function (e) {
15857 var $this = $(this)
15858 var selector = $this.attr('data-target')
15859
15860 if (!selector) {
15861 selector = $this.attr('href')
15862 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
15863 }
15864
15865 var $parent = $(selector)
15866
15867 if (e) e.preventDefault()
15868
15869 if (!$parent.length) {
15870 $parent = $this.hasClass('alert') ? $this : $this.parent()
15871 }
15872
15873 $parent.trigger(e = $.Event('close.bs.alert'))
15874
15875 if (e.isDefaultPrevented()) return
15876
15877 $parent.removeClass('in')
15878
15879 function removeElement() {
15880 // detach from parent, fire event then clean up data
15881 $parent.detach().trigger('closed.bs.alert').remove()
15882 }
15883
15884 $.support.transition && $parent.hasClass('fade') ?
15885 $parent
15886 .one('bsTransitionEnd', removeElement)
15887 .emulateTransitionEnd(150) :
15888 removeElement()
15889 }
15890
15891
15892 // ALERT PLUGIN DEFINITION
15893 // =======================
15894
15895 function Plugin(option) {
15896 return this.each(function () {
15897 var $this = $(this)
15898 var data = $this.data('bs.alert')
15899
15900 if (!data) $this.data('bs.alert', (data = new Alert(this)))
15901 if (typeof option == 'string') data[option].call($this)
15902 })
15903 }
15904
15905 var old = $.fn.alert
15906
15907 $.fn.alert = Plugin
15908 $.fn.alert.Constructor = Alert
15909
15910
15911 // ALERT NO CONFLICT
15912 // =================
15913
15914 $.fn.alert.noConflict = function () {
15915 $.fn.alert = old
15916 return this
15917 }
15918
15919
15920 // ALERT DATA-API
15921 // ==============
15922
15923 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
15924
15925 }(jQuery);
15926
15927 /* ========================================================================
15928 * Bootstrap: button.js v3.2.0
15929 * http://getbootstrap.com/javascript/#buttons
15930 * ========================================================================
15931 * Copyright 2011-2014 Twitter, Inc.
15932 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15933 * ======================================================================== */
15934
15935
15936 +function ($) {
15937 'use strict';
15938
15939 // BUTTON PUBLIC CLASS DEFINITION
15940 // ==============================
15941
15942 var Button = function (element, options) {
15943 this.$element = $(element)
15944 this.options = $.extend({}, Button.DEFAULTS, options)
15945 this.isLoading = false
15946 }
15947
15948 Button.VERSION = '3.2.0'
15949
15950 Button.DEFAULTS = {
15951 loadingText: 'loading...'
15952 }
15953
15954 Button.prototype.setState = function (state) {
15955 var d = 'disabled'
15956 var $el = this.$element
15957 var val = $el.is('input') ? 'val' : 'html'
15958 var data = $el.data()
15959
15960 state = state + 'Text'
15961
15962 if (data.resetText == null) $el.data('resetText', $el[val]())
15963
15964 $el[val](data[state] == null ? this.options[state] : data[state])
15965
15966 // push to event loop to allow forms to submit
15967 setTimeout($.proxy(function () {
15968 if (state == 'loadingText') {
15969 this.isLoading = true
15970 $el.addClass(d).attr(d, d)
15971 } else if (this.isLoading) {
15972 this.isLoading = false
15973 $el.removeClass(d).removeAttr(d)
15974 }
15975 }, this), 0)
15976 }
15977
15978 Button.prototype.toggle = function () {
15979 var changed = true
15980 var $parent = this.$element.closest('[data-toggle="buttons"]')
15981
15982 if ($parent.length) {
15983 var $input = this.$element.find('input')
15984 if ($input.prop('type') == 'radio') {
15985 if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
15986 else $parent.find('.active').removeClass('active')
15987 }
15988 if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
15989 }
15990
15991 if (changed) this.$element.toggleClass('active')
15992 }
15993
15994
15995 // BUTTON PLUGIN DEFINITION
15996 // ========================
15997
15998 function Plugin(option) {
15999 return this.each(function () {
16000 var $this = $(this)
16001 var data = $this.data('bs.button')
16002 var options = typeof option == 'object' && option
16003
16004 if (!data) $this.data('bs.button', (data = new Button(this, options)))
16005
16006 if (option == 'toggle') data.toggle()
16007 else if (option) data.setState(option)
16008 })
16009 }
16010
16011 var old = $.fn.button
16012
16013 $.fn.button = Plugin
16014 $.fn.button.Constructor = Button
16015
16016
16017 // BUTTON NO CONFLICT
16018 // ==================
16019
16020 $.fn.button.noConflict = function () {
16021 $.fn.button = old
16022 return this
16023 }
16024
16025
16026 // BUTTON DATA-API
16027 // ===============
16028
16029 $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
16030 var $btn = $(e.target)
16031 if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
16032 Plugin.call($btn, 'toggle')
16033 e.preventDefault()
16034 })
16035
16036 }(jQuery);
16037
16038 /* ========================================================================
16039 * Bootstrap: carousel.js v3.2.0
16040 * http://getbootstrap.com/javascript/#carousel
16041 * ========================================================================
16042 * Copyright 2011-2014 Twitter, Inc.
16043 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16044 * ======================================================================== */
16045
16046
16047 +function ($) {
16048 'use strict';
16049
16050 // CAROUSEL CLASS DEFINITION
16051 // =========================
16052
16053 var Carousel = function (element, options) {
16054 this.$element = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this))
16055 this.$indicators = this.$element.find('.carousel-indicators')
16056 this.options = options
16057 this.paused =
16058 this.sliding =
16059 this.interval =
16060 this.$active =
16061 this.$items = null
16062
16063 this.options.pause == 'hover' && this.$element
16064 .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
16065 .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
16066 }
16067
16068 Carousel.VERSION = '3.2.0'
16069
16070 Carousel.DEFAULTS = {
16071 interval: 5000,
16072 pause: 'hover',
16073 wrap: true
16074 }
16075
16076 Carousel.prototype.keydown = function (e) {
16077 switch (e.which) {
16078 case 37: this.prev(); break
16079 case 39: this.next(); break
16080 default: return
16081 }
16082
16083 e.preventDefault()
16084 }
16085
16086 Carousel.prototype.cycle = function (e) {
16087 e || (this.paused = false)
16088
16089 this.interval && clearInterval(this.interval)
16090
16091 this.options.interval
16092 && !this.paused
16093 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
16094
16095 return this
16096 }
16097
16098 Carousel.prototype.getItemIndex = function (item) {
16099 this.$items = item.parent().children('.item')
16100 return this.$items.index(item || this.$active)
16101 }
16102
16103 Carousel.prototype.to = function (pos) {
16104 var that = this
16105 var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))
16106
16107 if (pos > (this.$items.length - 1) || pos < 0) return
16108
16109 if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
16110 if (activeIndex == pos) return this.pause().cycle()
16111
16112 return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
16113 }
16114
16115 Carousel.prototype.pause = function (e) {
16116 e || (this.paused = true)
16117
16118 if (this.$element.find('.next, .prev').length && $.support.transition) {
16119 this.$element.trigger($.support.transition.end)
16120 this.cycle(true)
16121 }
16122
16123 this.interval = clearInterval(this.interval)
16124
16125 return this
16126 }
16127
16128 Carousel.prototype.next = function () {
16129 if (this.sliding) return
16130 return this.slide('next')
16131 }
16132
16133 Carousel.prototype.prev = function () {
16134 if (this.sliding) return
16135 return this.slide('prev')
16136 }
16137
16138 Carousel.prototype.slide = function (type, next) {
16139 var $active = this.$element.find('.item.active')
16140 var $next = next || $active[type]()
16141 var isCycling = this.interval
16142 var direction = type == 'next' ? 'left' : 'right'
16143 var fallback = type == 'next' ? 'first' : 'last'
16144 var that = this
16145
16146 if (!$next.length) {
16147 if (!this.options.wrap) return
16148 $next = this.$element.find('.item')[fallback]()
16149 }
16150
16151 if ($next.hasClass('active')) return (this.sliding = false)
16152
16153 var relatedTarget = $next[0]
16154 var slideEvent = $.Event('slide.bs.carousel', {
16155 relatedTarget: relatedTarget,
16156 direction: direction
16157 })
16158 this.$element.trigger(slideEvent)
16159 if (slideEvent.isDefaultPrevented()) return
16160
16161 this.sliding = true
16162
16163 isCycling && this.pause()
16164
16165 if (this.$indicators.length) {
16166 this.$indicators.find('.active').removeClass('active')
16167 var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
16168 $nextIndicator && $nextIndicator.addClass('active')
16169 }
16170
16171 var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
16172 if ($.support.transition && this.$element.hasClass('slide')) {
16173 $next.addClass(type)
16174 $next[0].offsetWidth // force reflow
16175 $active.addClass(direction)
16176 $next.addClass(direction)
16177 $active
16178 .one('bsTransitionEnd', function () {
16179 $next.removeClass([type, direction].join(' ')).addClass('active')
16180 $active.removeClass(['active', direction].join(' '))
16181 that.sliding = false
16182 setTimeout(function () {
16183 that.$element.trigger(slidEvent)
16184 }, 0)
16185 })
16186 .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
16187 } else {
16188 $active.removeClass('active')
16189 $next.addClass('active')
16190 this.sliding = false
16191 this.$element.trigger(slidEvent)
16192 }
16193
16194 isCycling && this.cycle()
16195
16196 return this
16197 }
16198
16199
16200 // CAROUSEL PLUGIN DEFINITION
16201 // ==========================
16202
16203 function Plugin(option) {
16204 return this.each(function () {
16205 var $this = $(this)
16206 var data = $this.data('bs.carousel')
16207 var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
16208 var action = typeof option == 'string' ? option : options.slide
16209
16210 if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
16211 if (typeof option == 'number') data.to(option)
16212 else if (action) data[action]()
16213 else if (options.interval) data.pause().cycle()
16214 })
16215 }
16216
16217 var old = $.fn.carousel
16218
16219 $.fn.carousel = Plugin
16220 $.fn.carousel.Constructor = Carousel
16221
16222
16223 // CAROUSEL NO CONFLICT
16224 // ====================
16225
16226 $.fn.carousel.noConflict = function () {
16227 $.fn.carousel = old
16228 return this
16229 }
16230
16231
16232 // CAROUSEL DATA-API
16233 // =================
16234
16235 $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
16236 var href
16237 var $this = $(this)
16238 var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
16239 if (!$target.hasClass('carousel')) return
16240 var options = $.extend({}, $target.data(), $this.data())
16241 var slideIndex = $this.attr('data-slide-to')
16242 if (slideIndex) options.interval = false
16243
16244 Plugin.call($target, options)
16245
16246 if (slideIndex) {
16247 $target.data('bs.carousel').to(slideIndex)
16248 }
16249
16250 e.preventDefault()
16251 })
16252
16253 $(window).on('load', function () {
16254 $('[data-ride="carousel"]').each(function () {
16255 var $carousel = $(this)
16256 Plugin.call($carousel, $carousel.data())
16257 })
16258 })
16259
16260 }(jQuery);
16261
16262 /* ========================================================================
16263 * Bootstrap: collapse.js v3.2.0
16264 * http://getbootstrap.com/javascript/#collapse
16265 * ========================================================================
16266 * Copyright 2011-2014 Twitter, Inc.
16267 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16268 * ======================================================================== */
16269
16270
16271 +function ($) {
16272 'use strict';
16273
16274 // COLLAPSE PUBLIC CLASS DEFINITION
16275 // ================================
16276
16277 var Collapse = function (element, options) {
16278 this.$element = $(element)
16279 this.options = $.extend({}, Collapse.DEFAULTS, options)
16280 this.transitioning = null
16281
16282 if (this.options.parent) this.$parent = $(this.options.parent)
16283 if (this.options.toggle) this.toggle()
16284 }
16285
16286 Collapse.VERSION = '3.2.0'
16287
16288 Collapse.DEFAULTS = {
16289 toggle: true
16290 }
16291
16292 Collapse.prototype.dimension = function () {
16293 var hasWidth = this.$element.hasClass('width')
16294 return hasWidth ? 'width' : 'height'
16295 }
16296
16297 Collapse.prototype.show = function () {
16298 if (this.transitioning || this.$element.hasClass('in')) return
16299
16300 var startEvent = $.Event('show.bs.collapse')
16301 this.$element.trigger(startEvent)
16302 if (startEvent.isDefaultPrevented()) return
16303
16304 var actives = this.$parent && this.$parent.find('> .panel > .in')
16305
16306 if (actives && actives.length) {
16307 var hasData = actives.data('bs.collapse')
16308 if (hasData && hasData.transitioning) return
16309 Plugin.call(actives, 'hide')
16310 hasData || actives.data('bs.collapse', null)
16311 }
16312
16313 var dimension = this.dimension()
16314
16315 this.$element
16316 .removeClass('collapse')
16317 .addClass('collapsing')[dimension](0)
16318
16319 this.transitioning = 1
16320
16321 var complete = function () {
16322 this.$element
16323 .removeClass('collapsing')
16324 .addClass('collapse in')[dimension]('')
16325 this.transitioning = 0
16326 this.$element
16327 .trigger('shown.bs.collapse')
16328 }
16329
16330 if (!$.support.transition) return complete.call(this)
16331
16332 var scrollSize = $.camelCase(['scroll', dimension].join('-'))
16333
16334 this.$element
16335 .one('bsTransitionEnd', $.proxy(complete, this))
16336 .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
16337 }
16338
16339 Collapse.prototype.hide = function () {
16340 if (this.transitioning || !this.$element.hasClass('in')) return
16341
16342 var startEvent = $.Event('hide.bs.collapse')
16343 this.$element.trigger(startEvent)
16344 if (startEvent.isDefaultPrevented()) return
16345
16346 var dimension = this.dimension()
16347
16348 this.$element[dimension](this.$element[dimension]())[0].offsetHeight
16349
16350 this.$element
16351 .addClass('collapsing')
16352 .removeClass('collapse')
16353 .removeClass('in')
16354
16355 this.transitioning = 1
16356
16357 var complete = function () {
16358 this.transitioning = 0
16359 this.$element
16360 .trigger('hidden.bs.collapse')
16361 .removeClass('collapsing')
16362 .addClass('collapse')
16363 }
16364
16365 if (!$.support.transition) return complete.call(this)
16366
16367 this.$element
16368 [dimension](0)
16369 .one('bsTransitionEnd', $.proxy(complete, this))
16370 .emulateTransitionEnd(350)
16371 }
16372
16373 Collapse.prototype.toggle = function () {
16374 this[this.$element.hasClass('in') ? 'hide' : 'show']()
16375 }
16376
16377
16378 // COLLAPSE PLUGIN DEFINITION
16379 // ==========================
16380
16381 function Plugin(option) {
16382 return this.each(function () {
16383 var $this = $(this)
16384 var data = $this.data('bs.collapse')
16385 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
16386
16387 if (!data && options.toggle && option == 'show') option = !option
16388 if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
16389 if (typeof option == 'string') data[option]()
16390 })
16391 }
16392
16393 var old = $.fn.collapse
16394
16395 $.fn.collapse = Plugin
16396 $.fn.collapse.Constructor = Collapse
16397
16398
16399 // COLLAPSE NO CONFLICT
16400 // ====================
16401
16402 $.fn.collapse.noConflict = function () {
16403 $.fn.collapse = old
16404 return this
16405 }
16406
16407
16408 // COLLAPSE DATA-API
16409 // =================
16410
16411 $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
16412 var href
16413 var $this = $(this)
16414 var target = $this.attr('data-target')
16415 || e.preventDefault()
16416 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
16417 var $target = $(target)
16418 var data = $target.data('bs.collapse')
16419 var option = data ? 'toggle' : $this.data()
16420 var parent = $this.attr('data-parent')
16421 var $parent = parent && $(parent)
16422
16423 if (!data || !data.transitioning) {
16424 if ($parent) $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed')
16425 $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
16426 }
16427
16428 Plugin.call($target, option)
16429 })
16430
16431 }(jQuery);
16432
16433 /* ========================================================================
16434 * Bootstrap: dropdown.js v3.2.0
16435 * http://getbootstrap.com/javascript/#dropdowns
16436 * ========================================================================
16437 * Copyright 2011-2014 Twitter, Inc.
16438 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16439 * ======================================================================== */
16440
16441
16442 +function ($) {
16443 'use strict';
16444
16445 // DROPDOWN CLASS DEFINITION
16446 // =========================
16447
16448 var backdrop = '.dropdown-backdrop'
16449 var toggle = '[data-toggle="dropdown"]'
16450 var Dropdown = function (element) {
16451 $(element).on('click.bs.dropdown', this.toggle)
16452 }
16453
16454 Dropdown.VERSION = '3.2.0'
16455
16456 Dropdown.prototype.toggle = function (e) {
16457 var $this = $(this)
16458
16459 if ($this.is('.disabled, :disabled')) return
16460
16461 var $parent = getParent($this)
16462 var isActive = $parent.hasClass('open')
16463
16464 clearMenus()
16465
16466 if (!isActive) {
16467 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
16468 // if mobile we use a backdrop because click events don't delegate
16469 $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
16470 }
16471
16472 var relatedTarget = { relatedTarget: this }
16473 $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
16474
16475 if (e.isDefaultPrevented()) return
16476
16477 $this.trigger('focus')
16478
16479 $parent
16480 .toggleClass('open')
16481 .trigger('shown.bs.dropdown', relatedTarget)
16482 }
16483
16484 return false
16485 }
16486
16487 Dropdown.prototype.keydown = function (e) {
16488 if (!/(38|40|27)/.test(e.keyCode)) return
16489
16490 var $this = $(this)
16491
16492 e.preventDefault()
16493 e.stopPropagation()
16494
16495 if ($this.is('.disabled, :disabled')) return
16496
16497 var $parent = getParent($this)
16498 var isActive = $parent.hasClass('open')
16499
16500 if (!isActive || (isActive && e.keyCode == 27)) {
16501 if (e.which == 27) $parent.find(toggle).trigger('focus')
16502 return $this.trigger('click')
16503 }
16504
16505 var desc = ' li:not(.divider):visible a'
16506 var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
16507
16508 if (!$items.length) return
16509
16510 var index = $items.index($items.filter(':focus'))
16511
16512 if (e.keyCode == 38 && index > 0) index-- // up
16513 if (e.keyCode == 40 && index < $items.length - 1) index++ // down
16514 if (!~index) index = 0
16515
16516 $items.eq(index).trigger('focus')
16517 }
16518
16519 function clearMenus(e) {
16520 if (e && e.which === 3) return
16521 $(backdrop).remove()
16522 $(toggle).each(function () {
16523 var $parent = getParent($(this))
16524 var relatedTarget = { relatedTarget: this }
16525 if (!$parent.hasClass('open')) return
16526 $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
16527 if (e.isDefaultPrevented()) return
16528 $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
16529 })
16530 }
16531
16532 function getParent($this) {
16533 var selector = $this.attr('data-target')
16534
16535 if (!selector) {
16536 selector = $this.attr('href')
16537 selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
16538 }
16539
16540 var $parent = selector && $(selector)
16541
16542 return $parent && $parent.length ? $parent : $this.parent()
16543 }
16544
16545
16546 // DROPDOWN PLUGIN DEFINITION
16547 // ==========================
16548
16549 function Plugin(option) {
16550 return this.each(function () {
16551 var $this = $(this)
16552 var data = $this.data('bs.dropdown')
16553
16554 if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
16555 if (typeof option == 'string') data[option].call($this)
16556 })
16557 }
16558
16559 var old = $.fn.dropdown
16560
16561 $.fn.dropdown = Plugin
16562 $.fn.dropdown.Constructor = Dropdown
16563
16564
16565 // DROPDOWN NO CONFLICT
16566 // ====================
16567
16568 $.fn.dropdown.noConflict = function () {
16569 $.fn.dropdown = old
16570 return this
16571 }
16572
16573
16574 // APPLY TO STANDARD DROPDOWN ELEMENTS
16575 // ===================================
16576
16577 $(document)
16578 .on('click.bs.dropdown.data-api', clearMenus)
16579 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
16580 .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
16581 .on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown)
16582
16583 }(jQuery);
16584
16585 /* ========================================================================
16586 * Bootstrap: modal.js v3.2.0
16587 * http://getbootstrap.com/javascript/#modals
16588 * ========================================================================
16589 * Copyright 2011-2014 Twitter, Inc.
16590 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16591 * ======================================================================== */
16592
16593
16594 +function ($) {
16595 'use strict';
16596
16597 // MODAL CLASS DEFINITION
16598 // ======================
16599
16600 var Modal = function (element, options) {
16601 this.options = options
16602 this.$body = $(document.body)
16603 this.$element = $(element)
16604 this.$backdrop =
16605 this.isShown = null
16606 this.scrollbarWidth = 0
16607
16608 if (this.options.remote) {
16609 this.$element
16610 .find('.modal-content')
16611 .load(this.options.remote, $.proxy(function () {
16612 this.$element.trigger('loaded.bs.modal')
16613 }, this))
16614 }
16615 }
16616
16617 Modal.VERSION = '3.2.0'
16618
16619 Modal.DEFAULTS = {
16620 backdrop: true,
16621 keyboard: true,
16622 show: true
16623 }
16624
16625 Modal.prototype.toggle = function (_relatedTarget) {
16626 return this.isShown ? this.hide() : this.show(_relatedTarget)
16627 }
16628
16629 Modal.prototype.show = function (_relatedTarget) {
16630 var that = this
16631 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
16632
16633 this.$element.trigger(e)
16634
16635 if (this.isShown || e.isDefaultPrevented()) return
16636
16637 this.isShown = true
16638
16639 this.checkScrollbar()
16640 this.$body.addClass('modal-open')
16641
16642 this.setScrollbar()
16643 this.escape()
16644
16645 this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
16646
16647 this.backdrop(function () {
16648 var transition = $.support.transition && that.$element.hasClass('fade')
16649
16650 if (!that.$element.parent().length) {
16651 that.$element.appendTo(that.$body) // don't move modals dom position
16652 }
16653
16654 that.$element
16655 .show()
16656 .scrollTop(0)
16657
16658 if (transition) {
16659 that.$element[0].offsetWidth // force reflow
16660 }
16661
16662 that.$element
16663 .addClass('in')
16664 .attr('aria-hidden', false)
16665
16666 that.enforceFocus()
16667
16668 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
16669
16670 transition ?
16671 that.$element.find('.modal-dialog') // wait for modal to slide in
16672 .one('bsTransitionEnd', function () {
16673 that.$element.trigger('focus').trigger(e)
16674 })
16675 .emulateTransitionEnd(300) :
16676 that.$element.trigger('focus').trigger(e)
16677 })
16678 }
16679
16680 Modal.prototype.hide = function (e) {
16681 if (e) e.preventDefault()
16682
16683 e = $.Event('hide.bs.modal')
16684
16685 this.$element.trigger(e)
16686
16687 if (!this.isShown || e.isDefaultPrevented()) return
16688
16689 this.isShown = false
16690
16691 this.$body.removeClass('modal-open')
16692
16693 this.resetScrollbar()
16694 this.escape()
16695
16696 $(document).off('focusin.bs.modal')
16697
16698 this.$element
16699 .removeClass('in')
16700 .attr('aria-hidden', true)
16701 .off('click.dismiss.bs.modal')
16702
16703 $.support.transition && this.$element.hasClass('fade') ?
16704 this.$element
16705 .one('bsTransitionEnd', $.proxy(this.hideModal, this))
16706 .emulateTransitionEnd(300) :
16707 this.hideModal()
16708 }
16709
16710 Modal.prototype.enforceFocus = function () {
16711 $(document)
16712 .off('focusin.bs.modal') // guard against infinite focus loop
16713 .on('focusin.bs.modal', $.proxy(function (e) {
16714 if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
16715 this.$element.trigger('focus')
16716 }
16717 }, this))
16718 }
16719
16720 Modal.prototype.escape = function () {
16721 if (this.isShown && this.options.keyboard) {
16722 this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
16723 e.which == 27 && this.hide()
16724 }, this))
16725 } else if (!this.isShown) {
16726 this.$element.off('keyup.dismiss.bs.modal')
16727 }
16728 }
16729
16730 Modal.prototype.hideModal = function () {
16731 var that = this
16732 this.$element.hide()
16733 this.backdrop(function () {
16734 that.$element.trigger('hidden.bs.modal')
16735 })
16736 }
16737
16738 Modal.prototype.removeBackdrop = function () {
16739 this.$backdrop && this.$backdrop.remove()
16740 this.$backdrop = null
16741 }
16742
16743 Modal.prototype.backdrop = function (callback) {
16744 var that = this
16745 var animate = this.$element.hasClass('fade') ? 'fade' : ''
16746
16747 if (this.isShown && this.options.backdrop) {
16748 var doAnimate = $.support.transition && animate
16749
16750 this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
16751 .appendTo(this.$body)
16752
16753 this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
16754 if (e.target !== e.currentTarget) return
16755 this.options.backdrop == 'static'
16756 ? this.$element[0].focus.call(this.$element[0])
16757 : this.hide.call(this)
16758 }, this))
16759
16760 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
16761
16762 this.$backdrop.addClass('in')
16763
16764 if (!callback) return
16765
16766 doAnimate ?
16767 this.$backdrop
16768 .one('bsTransitionEnd', callback)
16769 .emulateTransitionEnd(150) :
16770 callback()
16771
16772 } else if (!this.isShown && this.$backdrop) {
16773 this.$backdrop.removeClass('in')
16774
16775 var callbackRemove = function () {
16776 that.removeBackdrop()
16777 callback && callback()
16778 }
16779 $.support.transition && this.$element.hasClass('fade') ?
16780 this.$backdrop
16781 .one('bsTransitionEnd', callbackRemove)
16782 .emulateTransitionEnd(150) :
16783 callbackRemove()
16784
16785 } else if (callback) {
16786 callback()
16787 }
16788 }
16789
16790 Modal.prototype.checkScrollbar = function () {
16791 if (document.body.clientWidth >= window.innerWidth) return
16792 this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
16793 }
16794
16795 Modal.prototype.setScrollbar = function () {
16796 var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
16797 if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
16798 }
16799
16800 Modal.prototype.resetScrollbar = function () {
16801 this.$body.css('padding-right', '')
16802 }
16803
16804 Modal.prototype.measureScrollbar = function () { // thx walsh
16805 var scrollDiv = document.createElement('div')
16806 scrollDiv.className = 'modal-scrollbar-measure'
16807 this.$body.append(scrollDiv)
16808 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
16809 this.$body[0].removeChild(scrollDiv)
16810 return scrollbarWidth
16811 }
16812
16813
16814 // MODAL PLUGIN DEFINITION
16815 // =======================
16816
16817 function Plugin(option, _relatedTarget) {
16818 return this.each(function () {
16819 var $this = $(this)
16820 var data = $this.data('bs.modal')
16821 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
16822
16823 if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
16824 if (typeof option == 'string') data[option](_relatedTarget)
16825 else if (options.show) data.show(_relatedTarget)
16826 })
16827 }
16828
16829 var old = $.fn.modal
16830
16831 $.fn.modal = Plugin
16832 $.fn.modal.Constructor = Modal
16833
16834
16835 // MODAL NO CONFLICT
16836 // =================
16837
16838 $.fn.modal.noConflict = function () {
16839 $.fn.modal = old
16840 return this
16841 }
16842
16843
16844 // MODAL DATA-API
16845 // ==============
16846
16847 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
16848 var $this = $(this)
16849 var href = $this.attr('href')
16850 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
16851 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
16852
16853 if ($this.is('a')) e.preventDefault()
16854
16855 $target.one('show.bs.modal', function (showEvent) {
16856 if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
16857 $target.one('hidden.bs.modal', function () {
16858 $this.is(':visible') && $this.trigger('focus')
16859 })
16860 })
16861 Plugin.call($target, option, this)
16862 })
16863
16864 }(jQuery);
16865
16866 /* ========================================================================
16867 * Bootstrap: tooltip.js v3.2.0
16868 * http://getbootstrap.com/javascript/#tooltip
16869 * Inspired by the original jQuery.tipsy by Jason Frame
16870 * ========================================================================
16871 * Copyright 2011-2014 Twitter, Inc.
16872 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16873 * ======================================================================== */
16874
16875
16876 +function ($) {
16877 'use strict';
16878
16879 // TOOLTIP PUBLIC CLASS DEFINITION
16880 // ===============================
16881
16882 var Tooltip = function (element, options) {
16883 this.type =
16884 this.options =
16885 this.enabled =
16886 this.timeout =
16887 this.hoverState =
16888 this.$element = null
16889
16890 this.init('tooltip', element, options)
16891 }
16892
16893 Tooltip.VERSION = '3.2.0'
16894
16895 Tooltip.DEFAULTS = {
16896 animation: true,
16897 placement: 'top',
16898 selector: false,
16899 template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
16900 trigger: 'hover focus',
16901 title: '',
16902 delay: 0,
16903 html: false,
16904 container: false,
16905 viewport: {
16906 selector: 'body',
16907 padding: 0
16908 }
16909 }
16910
16911 Tooltip.prototype.init = function (type, element, options) {
16912 this.enabled = true
16913 this.type = type
16914 this.$element = $(element)
16915 this.options = this.getOptions(options)
16916 this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
16917
16918 var triggers = this.options.trigger.split(' ')
16919
16920 for (var i = triggers.length; i--;) {
16921 var trigger = triggers[i]
16922
16923 if (trigger == 'click') {
16924 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
16925 } else if (trigger != 'manual') {
16926 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
16927 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
16928
16929 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
16930 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
16931 }
16932 }
16933
16934 this.options.selector ?
16935 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
16936 this.fixTitle()
16937 }
16938
16939 Tooltip.prototype.getDefaults = function () {
16940 return Tooltip.DEFAULTS
16941 }
16942
16943 Tooltip.prototype.getOptions = function (options) {
16944 options = $.extend({}, this.getDefaults(), this.$element.data(), options)
16945
16946 if (options.delay && typeof options.delay == 'number') {
16947 options.delay = {
16948 show: options.delay,
16949 hide: options.delay
16950 }
16951 }
16952
16953 return options
16954 }
16955
16956 Tooltip.prototype.getDelegateOptions = function () {
16957 var options = {}
16958 var defaults = this.getDefaults()
16959
16960 this._options && $.each(this._options, function (key, value) {
16961 if (defaults[key] != value) options[key] = value
16962 })
16963
16964 return options
16965 }
16966
16967 Tooltip.prototype.enter = function (obj) {
16968 var self = obj instanceof this.constructor ?
16969 obj : $(obj.currentTarget).data('bs.' + this.type)
16970
16971 if (!self) {
16972 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
16973 $(obj.currentTarget).data('bs.' + this.type, self)
16974 }
16975
16976 clearTimeout(self.timeout)
16977
16978 self.hoverState = 'in'
16979
16980 if (!self.options.delay || !self.options.delay.show) return self.show()
16981
16982 self.timeout = setTimeout(function () {
16983 if (self.hoverState == 'in') self.show()
16984 }, self.options.delay.show)
16985 }
16986
16987 Tooltip.prototype.leave = function (obj) {
16988 var self = obj instanceof this.constructor ?
16989 obj : $(obj.currentTarget).data('bs.' + this.type)
16990
16991 if (!self) {
16992 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
16993 $(obj.currentTarget).data('bs.' + this.type, self)
16994 }
16995
16996 clearTimeout(self.timeout)
16997
16998 self.hoverState = 'out'
16999
17000 if (!self.options.delay || !self.options.delay.hide) return self.hide()
17001
17002 self.timeout = setTimeout(function () {
17003 if (self.hoverState == 'out') self.hide()
17004 }, self.options.delay.hide)
17005 }
17006
17007 Tooltip.prototype.show = function () {
17008 var e = $.Event('show.bs.' + this.type)
17009
17010 if (this.hasContent() && this.enabled) {
17011 this.$element.trigger(e)
17012
17013 var inDom = $.contains(document.documentElement, this.$element[0])
17014 if (e.isDefaultPrevented() || !inDom) return
17015 var that = this
17016
17017 var $tip = this.tip()
17018
17019 var tipId = this.getUID(this.type)
17020
17021 this.setContent()
17022 $tip.attr('id', tipId)
17023 this.$element.attr('aria-describedby', tipId)
17024
17025 if (this.options.animation) $tip.addClass('fade')
17026
17027 var placement = typeof this.options.placement == 'function' ?
17028 this.options.placement.call(this, $tip[0], this.$element[0]) :
17029 this.options.placement
17030
17031 var autoToken = /\s?auto?\s?/i
17032 var autoPlace = autoToken.test(placement)
17033 if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
17034
17035 $tip
17036 .detach()
17037 .css({ top: 0, left: 0, display: 'block' })
17038 .addClass(placement)
17039 .data('bs.' + this.type, this)
17040
17041 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
17042
17043 var pos = this.getPosition()
17044 var actualWidth = $tip[0].offsetWidth
17045 var actualHeight = $tip[0].offsetHeight
17046
17047 if (autoPlace) {
17048 var orgPlacement = placement
17049 var $parent = this.$element.parent()
17050 var parentDim = this.getPosition($parent)
17051
17052 placement = placement == 'bottom' && pos.top + pos.height + actualHeight - parentDim.scroll > parentDim.height ? 'top' :
17053 placement == 'top' && pos.top - parentDim.scroll - actualHeight < 0 ? 'bottom' :
17054 placement == 'right' && pos.right + actualWidth > parentDim.width ? 'left' :
17055 placement == 'left' && pos.left - actualWidth < parentDim.left ? 'right' :
17056 placement
17057
17058 $tip
17059 .removeClass(orgPlacement)
17060 .addClass(placement)
17061 }
17062
17063 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
17064
17065 this.applyPlacement(calculatedOffset, placement)
17066
17067 var complete = function () {
17068 that.$element.trigger('shown.bs.' + that.type)
17069 that.hoverState = null
17070 }
17071
17072 $.support.transition && this.$tip.hasClass('fade') ?
17073 $tip
17074 .one('bsTransitionEnd', complete)
17075 .emulateTransitionEnd(150) :
17076 complete()
17077 }
17078 }
17079
17080 Tooltip.prototype.applyPlacement = function (offset, placement) {
17081 var $tip = this.tip()
17082 var width = $tip[0].offsetWidth
17083 var height = $tip[0].offsetHeight
17084
17085 // manually read margins because getBoundingClientRect includes difference
17086 var marginTop = parseInt($tip.css('margin-top'), 10)
17087 var marginLeft = parseInt($tip.css('margin-left'), 10)
17088
17089 // we must check for NaN for ie 8/9
17090 if (isNaN(marginTop)) marginTop = 0
17091 if (isNaN(marginLeft)) marginLeft = 0
17092
17093 offset.top = offset.top + marginTop
17094 offset.left = offset.left + marginLeft
17095
17096 // $.fn.offset doesn't round pixel values
17097 // so we use setOffset directly with our own function B-0
17098 $.offset.setOffset($tip[0], $.extend({
17099 using: function (props) {
17100 $tip.css({
17101 top: Math.round(props.top),
17102 left: Math.round(props.left)
17103 })
17104 }
17105 }, offset), 0)
17106
17107 $tip.addClass('in')
17108
17109 // check to see if placing tip in new offset caused the tip to resize itself
17110 var actualWidth = $tip[0].offsetWidth
17111 var actualHeight = $tip[0].offsetHeight
17112
17113 if (placement == 'top' && actualHeight != height) {
17114 offset.top = offset.top + height - actualHeight
17115 }
17116
17117 var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
17118
17119 if (delta.left) offset.left += delta.left
17120 else offset.top += delta.top
17121
17122 var arrowDelta = delta.left ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
17123 var arrowPosition = delta.left ? 'left' : 'top'
17124 var arrowOffsetPosition = delta.left ? 'offsetWidth' : 'offsetHeight'
17125
17126 $tip.offset(offset)
17127 this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], arrowPosition)
17128 }
17129
17130 Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
17131 this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '')
17132 }
17133
17134 Tooltip.prototype.setContent = function () {
17135 var $tip = this.tip()
17136 var title = this.getTitle()
17137
17138 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
17139 $tip.removeClass('fade in top bottom left right')
17140 }
17141
17142 Tooltip.prototype.hide = function () {
17143 var that = this
17144 var $tip = this.tip()
17145 var e = $.Event('hide.bs.' + this.type)
17146
17147 this.$element.removeAttr('aria-describedby')
17148
17149 function complete() {
17150 if (that.hoverState != 'in') $tip.detach()
17151 that.$element.trigger('hidden.bs.' + that.type)
17152 }
17153
17154 this.$element.trigger(e)
17155
17156 if (e.isDefaultPrevented()) return
17157
17158 $tip.removeClass('in')
17159
17160 $.support.transition && this.$tip.hasClass('fade') ?
17161 $tip
17162 .one('bsTransitionEnd', complete)
17163 .emulateTransitionEnd(150) :
17164 complete()
17165
17166 this.hoverState = null
17167
17168 return this
17169 }
17170
17171 Tooltip.prototype.fixTitle = function () {
17172 var $e = this.$element
17173 if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
17174 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
17175 }
17176 }
17177
17178 Tooltip.prototype.hasContent = function () {
17179 return this.getTitle()
17180 }
17181
17182 Tooltip.prototype.getPosition = function ($element) {
17183 $element = $element || this.$element
17184 var el = $element[0]
17185 var isBody = el.tagName == 'BODY'
17186 return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : null, {
17187 scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop(),
17188 width: isBody ? $(window).width() : $element.outerWidth(),
17189 height: isBody ? $(window).height() : $element.outerHeight()
17190 }, isBody ? { top: 0, left: 0 } : $element.offset())
17191 }
17192
17193 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
17194 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
17195 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
17196 placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
17197 /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
17198
17199 }
17200
17201 Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
17202 var delta = { top: 0, left: 0 }
17203 if (!this.$viewport) return delta
17204
17205 var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
17206 var viewportDimensions = this.getPosition(this.$viewport)
17207
17208 if (/right|left/.test(placement)) {
17209 var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
17210 var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
17211 if (topEdgeOffset < viewportDimensions.top) { // top overflow
17212 delta.top = viewportDimensions.top - topEdgeOffset
17213 } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
17214 delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
17215 }
17216 } else {
17217 var leftEdgeOffset = pos.left - viewportPadding
17218 var rightEdgeOffset = pos.left + viewportPadding + actualWidth
17219 if (leftEdgeOffset < viewportDimensions.left) { // left overflow
17220 delta.left = viewportDimensions.left - leftEdgeOffset
17221 } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
17222 delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
17223 }
17224 }
17225
17226 return delta
17227 }
17228
17229 Tooltip.prototype.getTitle = function () {
17230 var title
17231 var $e = this.$element
17232 var o = this.options
17233
17234 title = $e.attr('data-original-title')
17235 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
17236
17237 return title
17238 }
17239
17240 Tooltip.prototype.getUID = function (prefix) {
17241 do prefix += ~~(Math.random() * 1000000)
17242 while (document.getElementById(prefix))
17243 return prefix
17244 }
17245
17246 Tooltip.prototype.tip = function () {
17247 return (this.$tip = this.$tip || $(this.options.template))
17248 }
17249
17250 Tooltip.prototype.arrow = function () {
17251 return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
17252 }
17253
17254 Tooltip.prototype.validate = function () {
17255 if (!this.$element[0].parentNode) {
17256 this.hide()
17257 this.$element = null
17258 this.options = null
17259 }
17260 }
17261
17262 Tooltip.prototype.enable = function () {
17263 this.enabled = true
17264 }
17265
17266 Tooltip.prototype.disable = function () {
17267 this.enabled = false
17268 }
17269
17270 Tooltip.prototype.toggleEnabled = function () {
17271 this.enabled = !this.enabled
17272 }
17273
17274 Tooltip.prototype.toggle = function (e) {
17275 var self = this
17276 if (e) {
17277 self = $(e.currentTarget).data('bs.' + this.type)
17278 if (!self) {
17279 self = new this.constructor(e.currentTarget, this.getDelegateOptions())
17280 $(e.currentTarget).data('bs.' + this.type, self)
17281 }
17282 }
17283
17284 self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
17285 }
17286
17287 Tooltip.prototype.destroy = function () {
17288 clearTimeout(this.timeout)
17289 this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
17290 }
17291
17292
17293 // TOOLTIP PLUGIN DEFINITION
17294 // =========================
17295
17296 function Plugin(option) {
17297 return this.each(function () {
17298 var $this = $(this)
17299 var data = $this.data('bs.tooltip')
17300 var options = typeof option == 'object' && option
17301
17302 if (!data && option == 'destroy') return
17303 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
17304 if (typeof option == 'string') data[option]()
17305 })
17306 }
17307
17308 var old = $.fn.tooltip
17309
17310 $.fn.tooltip = Plugin
17311 $.fn.tooltip.Constructor = Tooltip
17312
17313
17314 // TOOLTIP NO CONFLICT
17315 // ===================
17316
17317 $.fn.tooltip.noConflict = function () {
17318 $.fn.tooltip = old
17319 return this
17320 }
17321
17322 }(jQuery);
17323
17324 /* ========================================================================
17325 * Bootstrap: popover.js v3.2.0
17326 * http://getbootstrap.com/javascript/#popovers
17327 * ========================================================================
17328 * Copyright 2011-2014 Twitter, Inc.
17329 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17330 * ======================================================================== */
17331
17332
17333 +function ($) {
17334 'use strict';
17335
17336 // POPOVER PUBLIC CLASS DEFINITION
17337 // ===============================
17338
17339 var Popover = function (element, options) {
17340 this.init('popover', element, options)
17341 }
17342
17343 if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
17344
17345 Popover.VERSION = '3.2.0'
17346
17347 Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
17348 placement: 'right',
17349 trigger: 'click',
17350 content: '',
17351 template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
17352 })
17353
17354
17355 // NOTE: POPOVER EXTENDS tooltip.js
17356 // ================================
17357
17358 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
17359
17360 Popover.prototype.constructor = Popover
17361
17362 Popover.prototype.getDefaults = function () {
17363 return Popover.DEFAULTS
17364 }
17365
17366 Popover.prototype.setContent = function () {
17367 var $tip = this.tip()
17368 var title = this.getTitle()
17369 var content = this.getContent()
17370
17371 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
17372 $tip.find('.popover-content').empty()[ // we use append for html objects to maintain js events
17373 this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
17374 ](content)
17375
17376 $tip.removeClass('fade top bottom left right in')
17377
17378 // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
17379 // this manually by checking the contents.
17380 if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
17381 }
17382
17383 Popover.prototype.hasContent = function () {
17384 return this.getTitle() || this.getContent()
17385 }
17386
17387 Popover.prototype.getContent = function () {
17388 var $e = this.$element
17389 var o = this.options
17390
17391 return $e.attr('data-content')
17392 || (typeof o.content == 'function' ?
17393 o.content.call($e[0]) :
17394 o.content)
17395 }
17396
17397 Popover.prototype.arrow = function () {
17398 return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
17399 }
17400
17401 Popover.prototype.tip = function () {
17402 if (!this.$tip) this.$tip = $(this.options.template)
17403 return this.$tip
17404 }
17405
17406
17407 // POPOVER PLUGIN DEFINITION
17408 // =========================
17409
17410 function Plugin(option) {
17411 return this.each(function () {
17412 var $this = $(this)
17413 var data = $this.data('bs.popover')
17414 var options = typeof option == 'object' && option
17415
17416 if (!data && option == 'destroy') return
17417 if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
17418 if (typeof option == 'string') data[option]()
17419 })
17420 }
17421
17422 var old = $.fn.popover
17423
17424 $.fn.popover = Plugin
17425 $.fn.popover.Constructor = Popover
17426
17427
17428 // POPOVER NO CONFLICT
17429 // ===================
17430
17431 $.fn.popover.noConflict = function () {
17432 $.fn.popover = old
17433 return this
17434 }
17435
17436 }(jQuery);
17437
17438 /* ========================================================================
17439 * Bootstrap: scrollspy.js v3.2.0
17440 * http://getbootstrap.com/javascript/#scrollspy
17441 * ========================================================================
17442 * Copyright 2011-2014 Twitter, Inc.
17443 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17444 * ======================================================================== */
17445
17446
17447 +function ($) {
17448 'use strict';
17449
17450 // SCROLLSPY CLASS DEFINITION
17451 // ==========================
17452
17453 function ScrollSpy(element, options) {
17454 var process = $.proxy(this.process, this)
17455
17456 this.$body = $('body')
17457 this.$scrollElement = $(element).is('body') ? $(window) : $(element)
17458 this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
17459 this.selector = (this.options.target || '') + ' .nav li > a'
17460 this.offsets = []
17461 this.targets = []
17462 this.activeTarget = null
17463 this.scrollHeight = 0
17464
17465 this.$scrollElement.on('scroll.bs.scrollspy', process)
17466 this.refresh()
17467 this.process()
17468 }
17469
17470 ScrollSpy.VERSION = '3.2.0'
17471
17472 ScrollSpy.DEFAULTS = {
17473 offset: 10
17474 }
17475
17476 ScrollSpy.prototype.getScrollHeight = function () {
17477 return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
17478 }
17479
17480 ScrollSpy.prototype.refresh = function () {
17481 var offsetMethod = 'offset'
17482 var offsetBase = 0
17483
17484 if (!$.isWindow(this.$scrollElement[0])) {
17485 offsetMethod = 'position'
17486 offsetBase = this.$scrollElement.scrollTop()
17487 }
17488
17489 this.offsets = []
17490 this.targets = []
17491 this.scrollHeight = this.getScrollHeight()
17492
17493 var self = this
17494
17495 this.$body
17496 .find(this.selector)
17497 .map(function () {
17498 var $el = $(this)
17499 var href = $el.data('target') || $el.attr('href')
17500 var $href = /^#./.test(href) && $(href)
17501
17502 return ($href
17503 && $href.length
17504 && $href.is(':visible')
17505 && [[$href[offsetMethod]().top + offsetBase, href]]) || null
17506 })
17507 .sort(function (a, b) { return a[0] - b[0] })
17508 .each(function () {
17509 self.offsets.push(this[0])
17510 self.targets.push(this[1])
17511 })
17512 }
17513
17514 ScrollSpy.prototype.process = function () {
17515 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
17516 var scrollHeight = this.getScrollHeight()
17517 var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height()
17518 var offsets = this.offsets
17519 var targets = this.targets
17520 var activeTarget = this.activeTarget
17521 var i
17522
17523 if (this.scrollHeight != scrollHeight) {
17524 this.refresh()
17525 }
17526
17527 if (scrollTop >= maxScroll) {
17528 return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
17529 }
17530
17531 if (activeTarget && scrollTop <= offsets[0]) {
17532 return activeTarget != (i = targets[0]) && this.activate(i)
17533 }
17534
17535 for (i = offsets.length; i--;) {
17536 activeTarget != targets[i]
17537 && scrollTop >= offsets[i]
17538 && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
17539 && this.activate(targets[i])
17540 }
17541 }
17542
17543 ScrollSpy.prototype.activate = function (target) {
17544 this.activeTarget = target
17545
17546 $(this.selector)
17547 .parentsUntil(this.options.target, '.active')
17548 .removeClass('active')
17549
17550 var selector = this.selector +
17551 '[data-target="' + target + '"],' +
17552 this.selector + '[href="' + target + '"]'
17553
17554 var active = $(selector)
17555 .parents('li')
17556 .addClass('active')
17557
17558 if (active.parent('.dropdown-menu').length) {
17559 active = active
17560 .closest('li.dropdown')
17561 .addClass('active')
17562 }
17563
17564 active.trigger('activate.bs.scrollspy')
17565 }
17566
17567
17568 // SCROLLSPY PLUGIN DEFINITION
17569 // ===========================
17570
17571 function Plugin(option) {
17572 return this.each(function () {
17573 var $this = $(this)
17574 var data = $this.data('bs.scrollspy')
17575 var options = typeof option == 'object' && option
17576
17577 if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
17578 if (typeof option == 'string') data[option]()
17579 })
17580 }
17581
17582 var old = $.fn.scrollspy
17583
17584 $.fn.scrollspy = Plugin
17585 $.fn.scrollspy.Constructor = ScrollSpy
17586
17587
17588 // SCROLLSPY NO CONFLICT
17589 // =====================
17590
17591 $.fn.scrollspy.noConflict = function () {
17592 $.fn.scrollspy = old
17593 return this
17594 }
17595
17596
17597 // SCROLLSPY DATA-API
17598 // ==================
17599
17600 $(window).on('load.bs.scrollspy.data-api', function () {
17601 $('[data-spy="scroll"]').each(function () {
17602 var $spy = $(this)
17603 Plugin.call($spy, $spy.data())
17604 })
17605 })
17606
17607 }(jQuery);
17608
17609 /* ========================================================================
17610 * Bootstrap: tab.js v3.2.0
17611 * http://getbootstrap.com/javascript/#tabs
17612 * ========================================================================
17613 * Copyright 2011-2014 Twitter, Inc.
17614 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17615 * ======================================================================== */
17616
17617
17618 +function ($) {
17619 'use strict';
17620
17621 // TAB CLASS DEFINITION
17622 // ====================
17623
17624 var Tab = function (element) {
17625 this.element = $(element)
17626 }
17627
17628 Tab.VERSION = '3.2.0'
17629
17630 Tab.prototype.show = function () {
17631 var $this = this.element
17632 var $ul = $this.closest('ul:not(.dropdown-menu)')
17633 var selector = $this.data('target')
17634
17635 if (!selector) {
17636 selector = $this.attr('href')
17637 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
17638 }
17639
17640 if ($this.parent('li').hasClass('active')) return
17641
17642 var previous = $ul.find('.active:last a')[0]
17643 var e = $.Event('show.bs.tab', {
17644 relatedTarget: previous
17645 })
17646
17647 $this.trigger(e)
17648
17649 if (e.isDefaultPrevented()) return
17650
17651 var $target = $(selector)
17652
17653 this.activate($this.closest('li'), $ul)
17654 this.activate($target, $target.parent(), function () {
17655 $this.trigger({
17656 type: 'shown.bs.tab',
17657 relatedTarget: previous
17658 })
17659 })
17660 }
17661
17662 Tab.prototype.activate = function (element, container, callback) {
17663 var $active = container.find('> .active')
17664 var transition = callback
17665 && $.support.transition
17666 && $active.hasClass('fade')
17667
17668 function next() {
17669 $active
17670 .removeClass('active')
17671 .find('> .dropdown-menu > .active')
17672 .removeClass('active')
17673
17674 element.addClass('active')
17675
17676 if (transition) {
17677 element[0].offsetWidth // reflow for transition
17678 element.addClass('in')
17679 } else {
17680 element.removeClass('fade')
17681 }
17682
17683 if (element.parent('.dropdown-menu')) {
17684 element.closest('li.dropdown').addClass('active')
17685 }
17686
17687 callback && callback()
17688 }
17689
17690 transition ?
17691 $active
17692 .one('bsTransitionEnd', next)
17693 .emulateTransitionEnd(150) :
17694 next()
17695
17696 $active.removeClass('in')
17697 }
17698
17699
17700 // TAB PLUGIN DEFINITION
17701 // =====================
17702
17703 function Plugin(option) {
17704 return this.each(function () {
17705 var $this = $(this)
17706 var data = $this.data('bs.tab')
17707
17708 if (!data) $this.data('bs.tab', (data = new Tab(this)))
17709 if (typeof option == 'string') data[option]()
17710 })
17711 }
17712
17713 var old = $.fn.tab
17714
17715 $.fn.tab = Plugin
17716 $.fn.tab.Constructor = Tab
17717
17718
17719 // TAB NO CONFLICT
17720 // ===============
17721
17722 $.fn.tab.noConflict = function () {
17723 $.fn.tab = old
17724 return this
17725 }
17726
17727
17728 // TAB DATA-API
17729 // ============
17730
17731 $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
17732 e.preventDefault()
17733 Plugin.call($(this), 'show')
17734 })
17735
17736 }(jQuery);
17737
17738 /* ========================================================================
17739 * Bootstrap: affix.js v3.2.0
17740 * http://getbootstrap.com/javascript/#affix
17741 * ========================================================================
17742 * Copyright 2011-2014 Twitter, Inc.
17743 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17744 * ======================================================================== */
17745
17746
17747 +function ($) {
17748 'use strict';
17749
17750 // AFFIX CLASS DEFINITION
17751 // ======================
17752
17753 var Affix = function (element, options) {
17754 this.options = $.extend({}, Affix.DEFAULTS, options)
17755
17756 this.$target = $(this.options.target)
17757 .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
17758 .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
17759
17760 this.$element = $(element)
17761 this.affixed =
17762 this.unpin =
17763 this.pinnedOffset = null
17764
17765 this.checkPosition()
17766 }
17767
17768 Affix.VERSION = '3.2.0'
17769
17770 Affix.RESET = 'affix affix-top affix-bottom'
17771
17772 Affix.DEFAULTS = {
17773 offset: 0,
17774 target: window
17775 }
17776
17777 Affix.prototype.getPinnedOffset = function () {
17778 if (this.pinnedOffset) return this.pinnedOffset
17779 this.$element.removeClass(Affix.RESET).addClass('affix')
17780 var scrollTop = this.$target.scrollTop()
17781 var position = this.$element.offset()
17782 return (this.pinnedOffset = position.top - scrollTop)
17783 }
17784
17785 Affix.prototype.checkPositionWithEventLoop = function () {
17786 setTimeout($.proxy(this.checkPosition, this), 1)
17787 }
17788
17789 Affix.prototype.checkPosition = function () {
17790 if (!this.$element.is(':visible')) return
17791
17792 var scrollHeight = $(document).height()
17793 var scrollTop = this.$target.scrollTop()
17794 var position = this.$element.offset()
17795 var offset = this.options.offset
17796 var offsetTop = offset.top
17797 var offsetBottom = offset.bottom
17798
17799 if (typeof offset != 'object') offsetBottom = offsetTop = offset
17800 if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
17801 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
17802
17803 var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
17804 offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
17805 offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
17806
17807 if (this.affixed === affix) return
17808 if (this.unpin != null) this.$element.css('top', '')
17809
17810 var affixType = 'affix' + (affix ? '-' + affix : '')
17811 var e = $.Event(affixType + '.bs.affix')
17812
17813 this.$element.trigger(e)
17814
17815 if (e.isDefaultPrevented()) return
17816
17817 this.affixed = affix
17818 this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
17819
17820 this.$element
17821 .removeClass(Affix.RESET)
17822 .addClass(affixType)
17823 .trigger($.Event(affixType.replace('affix', 'affixed')))
17824
17825 if (affix == 'bottom') {
17826 this.$element.offset({
17827 top: scrollHeight - this.$element.height() - offsetBottom
17828 })
17829 }
17830 }
17831
17832
17833 // AFFIX PLUGIN DEFINITION
17834 // =======================
17835
17836 function Plugin(option) {
17837 return this.each(function () {
17838 var $this = $(this)
17839 var data = $this.data('bs.affix')
17840 var options = typeof option == 'object' && option
17841
17842 if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
17843 if (typeof option == 'string') data[option]()
17844 })
17845 }
17846
17847 var old = $.fn.affix
17848
17849 $.fn.affix = Plugin
17850 $.fn.affix.Constructor = Affix
17851
17852
17853 // AFFIX NO CONFLICT
17854 // =================
17855
17856 $.fn.affix.noConflict = function () {
17857 $.fn.affix = old
17858 return this
17859 }
17860
17861
17862 // AFFIX DATA-API
17863 // ==============
17864
17865 $(window).on('load', function () {
17866 $('[data-spy="affix"]').each(function () {
17867 var $spy = $(this)
17868 var data = $spy.data()
17869
17870 data.offset = data.offset || {}
17871
17872 if (data.offsetBottom) data.offset.bottom = data.offsetBottom
17873 if (data.offsetTop) data.offset.top = data.offsetTop
17874
17875 Plugin.call($spy, data)
17876 })
17877 })
17878
17879 }(jQuery);
17880 </script>
17881 <script>
17882 (function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Bitcoin=e()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
17883 var assert = _dereq_('assert')
17884
17885 module.exports = BigInteger
17886
17887 // JavaScript engine analysis
17888 var canary = 0xdeadbeefcafe;
17889 var j_lm = ((canary&0xffffff)==0xefcafe);
17890
17891 // (public) Constructor
17892 function BigInteger(a,b,c) {
17893 if (!(this instanceof BigInteger)) {
17894 return new BigInteger(a, b, c);
17895 }
17896
17897 if(a != null) {
17898 if("number" == typeof a) this.fromNumber(a,b,c);
17899 else if(b == null && "string" != typeof a) this.fromString(a,256);
17900 else this.fromString(a,b);
17901 }
17902 }
17903
17904 var proto = BigInteger.prototype;
17905
17906 // return new, unset BigInteger
17907 function nbi() { return new BigInteger(null); }
17908
17909 // Bits per digit
17910 var dbits;
17911
17912 // am: Compute w_j += (x*this_i), propagate carries,
17913 // c is initial carry, returns final carry.
17914 // c < 3*dvalue, x < 2*dvalue, this_i < dvalue
17915 // We need to select the fastest one that works in this environment.
17916
17917 // am1: use a single mult and divide to get the high bits,
17918 // max digit bits should be 26 because
17919 // max internal value = 2*dvalue^2-2*dvalue (< 2^53)
17920 function am1(i,x,w,j,c,n) {
17921 while(--n >= 0) {
17922 var v = x*this[i++]+w[j]+c;
17923 c = Math.floor(v/0x4000000);
17924 w[j++] = v&0x3ffffff;
17925 }
17926 return c;
17927 }
17928 // am2 avoids a big mult-and-extract completely.
17929 // Max digit bits should be <= 30 because we do bitwise ops
17930 // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
17931 function am2(i,x,w,j,c,n) {
17932 var xl = x&0x7fff, xh = x>>15;
17933 while(--n >= 0) {
17934 var l = this[i]&0x7fff;
17935 var h = this[i++]>>15;
17936 var m = xh*l+h*xl;
17937 l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff);
17938 c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);
17939 w[j++] = l&0x3fffffff;
17940 }
17941 return c;
17942 }
17943 // Alternately, set max digit bits to 28 since some
17944 // browsers slow down when dealing with 32-bit numbers.
17945 function am3(i,x,w,j,c,n) {
17946 var xl = x&0x3fff, xh = x>>14;
17947 while(--n >= 0) {
17948 var l = this[i]&0x3fff;
17949 var h = this[i++]>>14;
17950 var m = xh*l+h*xl;
17951 l = xl*l+((m&0x3fff)<<14)+w[j]+c;
17952 c = (l>>28)+(m>>14)+xh*h;
17953 w[j++] = l&0xfffffff;
17954 }
17955 return c;
17956 }
17957
17958 // wtf?
17959 BigInteger.prototype.am = am1;
17960 dbits = 26;
17961
17962 /*
17963 if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
17964 BigInteger.prototype.am = am2;
17965 dbits = 30;
17966 }
17967 else if(j_lm && (navigator.appName != "Netscape")) {
17968 BigInteger.prototype.am = am1;
17969 dbits = 26;
17970 }
17971 else { // Mozilla/Netscape seems to prefer am3
17972 BigInteger.prototype.am = am3;
17973 dbits = 28;
17974 }
17975 */
17976
17977 BigInteger.prototype.DB = dbits;
17978 BigInteger.prototype.DM = ((1<<dbits)-1);
17979 var DV = BigInteger.prototype.DV = (1<<dbits);
17980
17981 var BI_FP = 52;
17982 BigInteger.prototype.FV = Math.pow(2,BI_FP);
17983 BigInteger.prototype.F1 = BI_FP-dbits;
17984 BigInteger.prototype.F2 = 2*dbits-BI_FP;
17985
17986 // Digit conversions
17987 var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
17988 var BI_RC = new Array();
17989 var rr,vv;
17990 rr = "0".charCodeAt(0);
17991 for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
17992 rr = "a".charCodeAt(0);
17993 for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
17994 rr = "A".charCodeAt(0);
17995 for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
17996
17997 function int2char(n) { return BI_RM.charAt(n); }
17998 function intAt(s,i) {
17999 var c = BI_RC[s.charCodeAt(i)];
18000 return (c==null)?-1:c;
18001 }
18002
18003 // (protected) copy this to r
18004 function bnpCopyTo(r) {
18005 for(var i = this.t-1; i >= 0; --i) r[i] = this[i];
18006 r.t = this.t;
18007 r.s = this.s;
18008 }
18009
18010 // (protected) set from integer value x, -DV <= x < DV
18011 function bnpFromInt(x) {
18012 this.t = 1;
18013 this.s = (x<0)?-1:0;
18014 if(x > 0) this[0] = x;
18015 else if(x < -1) this[0] = x+DV;
18016 else this.t = 0;
18017 }
18018
18019 // return bigint initialized to value
18020 function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
18021
18022 // (protected) set from string and radix
18023 function bnpFromString(s,b) {
18024 var self = this;
18025
18026 var k;
18027 if(b == 16) k = 4;
18028 else if(b == 8) k = 3;
18029 else if(b == 256) k = 8; // byte array
18030 else if(b == 2) k = 1;
18031 else if(b == 32) k = 5;
18032 else if(b == 4) k = 2;
18033 else { self.fromRadix(s,b); return; }
18034 self.t = 0;
18035 self.s = 0;
18036 var i = s.length, mi = false, sh = 0;
18037 while(--i >= 0) {
18038 var x = (k==8)?s[i]&0xff:intAt(s,i);
18039 if(x < 0) {
18040 if(s.charAt(i) == "-") mi = true;
18041 continue;
18042 }
18043 mi = false;
18044 if(sh == 0)
18045 self[self.t++] = x;
18046 else if(sh+k > self.DB) {
18047 self[self.t-1] |= (x&((1<<(self.DB-sh))-1))<<sh;
18048 self[self.t++] = (x>>(self.DB-sh));
18049 }
18050 else
18051 self[self.t-1] |= x<<sh;
18052 sh += k;
18053 if(sh >= self.DB) sh -= self.DB;
18054 }
18055 if(k == 8 && (s[0]&0x80) != 0) {
18056 self.s = -1;
18057 if(sh > 0) self[self.t-1] |= ((1<<(self.DB-sh))-1)<<sh;
18058 }
18059 self.clamp();
18060 if(mi) BigInteger.ZERO.subTo(self,self);
18061 }
18062
18063 // (protected) clamp off excess high words
18064 function bnpClamp() {
18065 var c = this.s&this.DM;
18066 while(this.t > 0 && this[this.t-1] == c) --this.t;
18067 }
18068
18069 // (public) return string representation in given radix
18070 function bnToString(b) {
18071 var self = this;
18072 if(self.s < 0) return "-"+self.negate().toString(b);
18073 var k;
18074 if(b == 16) k = 4;
18075 else if(b == 8) k = 3;
18076 else if(b == 2) k = 1;
18077 else if(b == 32) k = 5;
18078 else if(b == 4) k = 2;
18079 else return self.toRadix(b);
18080 var km = (1<<k)-1, d, m = false, r = "", i = self.t;
18081 var p = self.DB-(i*self.DB)%k;
18082 if(i-- > 0) {
18083 if(p < self.DB && (d = self[i]>>p) > 0) { m = true; r = int2char(d); }
18084 while(i >= 0) {
18085 if(p < k) {
18086 d = (self[i]&((1<<p)-1))<<(k-p);
18087 d |= self[--i]>>(p+=self.DB-k);
18088 }
18089 else {
18090 d = (self[i]>>(p-=k))&km;
18091 if(p <= 0) { p += self.DB; --i; }
18092 }
18093 if(d > 0) m = true;
18094 if(m) r += int2char(d);
18095 }
18096 }
18097 return m?r:"0";
18098 }
18099
18100 // (public) -this
18101 function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
18102
18103 // (public) |this|
18104 function bnAbs() { return (this.s<0)?this.negate():this; }
18105
18106 // (public) return + if this > a, - if this < a, 0 if equal
18107 function bnCompareTo(a) {
18108 var r = this.s-a.s;
18109 if(r != 0) return r;
18110 var i = this.t;
18111 r = i-a.t;
18112 if(r != 0) return (this.s<0)?-r:r;
18113 while(--i >= 0) if((r=this[i]-a[i]) != 0) return r;
18114 return 0;
18115 }
18116
18117 // returns bit length of the integer x
18118 function nbits(x) {
18119 var r = 1, t;
18120 if((t=x>>>16) != 0) { x = t; r += 16; }
18121 if((t=x>>8) != 0) { x = t; r += 8; }
18122 if((t=x>>4) != 0) { x = t; r += 4; }
18123 if((t=x>>2) != 0) { x = t; r += 2; }
18124 if((t=x>>1) != 0) { x = t; r += 1; }
18125 return r;
18126 }
18127
18128 // (public) return the number of bits in "this"
18129 function bnBitLength() {
18130 if(this.t <= 0) return 0;
18131 return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM));
18132 }
18133
18134 // (protected) r = this << n*DB
18135 function bnpDLShiftTo(n,r) {
18136 var i;
18137 for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
18138 for(i = n-1; i >= 0; --i) r[i] = 0;
18139 r.t = this.t+n;
18140 r.s = this.s;
18141 }
18142
18143 // (protected) r = this >> n*DB
18144 function bnpDRShiftTo(n,r) {
18145 for(var i = n; i < this.t; ++i) r[i-n] = this[i];
18146 r.t = Math.max(this.t-n,0);
18147 r.s = this.s;
18148 }
18149
18150 // (protected) r = this << n
18151 function bnpLShiftTo(n,r) {
18152 var self = this;
18153 var bs = n%self.DB;
18154 var cbs = self.DB-bs;
18155 var bm = (1<<cbs)-1;
18156 var ds = Math.floor(n/self.DB), c = (self.s<<bs)&self.DM, i;
18157 for(i = self.t-1; i >= 0; --i) {
18158 r[i+ds+1] = (self[i]>>cbs)|c;
18159 c = (self[i]&bm)<<bs;
18160 }
18161 for(i = ds-1; i >= 0; --i) r[i] = 0;
18162 r[ds] = c;
18163 r.t = self.t+ds+1;
18164 r.s = self.s;
18165 r.clamp();
18166 }
18167
18168 // (protected) r = this >> n
18169 function bnpRShiftTo(n,r) {
18170 var self = this;
18171 r.s = self.s;
18172 var ds = Math.floor(n/self.DB);
18173 if(ds >= self.t) { r.t = 0; return; }
18174 var bs = n%self.DB;
18175 var cbs = self.DB-bs;
18176 var bm = (1<<bs)-1;
18177 r[0] = self[ds]>>bs;
18178 for(var i = ds+1; i < self.t; ++i) {
18179 r[i-ds-1] |= (self[i]&bm)<<cbs;
18180 r[i-ds] = self[i]>>bs;
18181 }
18182 if(bs > 0) r[self.t-ds-1] |= (self.s&bm)<<cbs;
18183 r.t = self.t-ds;
18184 r.clamp();
18185 }
18186
18187 // (protected) r = this - a
18188 function bnpSubTo(a,r) {
18189 var self = this;
18190 var i = 0, c = 0, m = Math.min(a.t,self.t);
18191 while(i < m) {
18192 c += self[i]-a[i];
18193 r[i++] = c&self.DM;
18194 c >>= self.DB;
18195 }
18196 if(a.t < self.t) {
18197 c -= a.s;
18198 while(i < self.t) {
18199 c += self[i];
18200 r[i++] = c&self.DM;
18201 c >>= self.DB;
18202 }
18203 c += self.s;
18204 }
18205 else {
18206 c += self.s;
18207 while(i < a.t) {
18208 c -= a[i];
18209 r[i++] = c&self.DM;
18210 c >>= self.DB;
18211 }
18212 c -= a.s;
18213 }
18214 r.s = (c<0)?-1:0;
18215 if(c < -1) r[i++] = self.DV+c;
18216 else if(c > 0) r[i++] = c;
18217 r.t = i;
18218 r.clamp();
18219 }
18220
18221 // (protected) r = this * a, r != this,a (HAC 14.12)
18222 // "this" should be the larger one if appropriate.
18223 function bnpMultiplyTo(a,r) {
18224 var x = this.abs(), y = a.abs();
18225 var i = x.t;
18226 r.t = i+y.t;
18227 while(--i >= 0) r[i] = 0;
18228 for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t);
18229 r.s = 0;
18230 r.clamp();
18231 if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
18232 }
18233
18234 // (protected) r = this^2, r != this (HAC 14.16)
18235 function bnpSquareTo(r) {
18236 var x = this.abs();
18237 var i = r.t = 2*x.t;
18238 while(--i >= 0) r[i] = 0;
18239 for(i = 0; i < x.t-1; ++i) {
18240 var c = x.am(i,x[i],r,2*i,0,1);
18241 if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {
18242 r[i+x.t] -= x.DV;
18243 r[i+x.t+1] = 1;
18244 }
18245 }
18246 if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1);
18247 r.s = 0;
18248 r.clamp();
18249 }
18250
18251 // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
18252 // r != q, this != m. q or r may be null.
18253 function bnpDivRemTo(m,q,r) {
18254 var self = this;
18255 var pm = m.abs();
18256 if(pm.t <= 0) return;
18257 var pt = self.abs();
18258 if(pt.t < pm.t) {
18259 if(q != null) q.fromInt(0);
18260 if(r != null) self.copyTo(r);
18261 return;
18262 }
18263 if(r == null) r = nbi();
18264 var y = nbi(), ts = self.s, ms = m.s;
18265 var nsh = self.DB-nbits(pm[pm.t-1]); // normalize modulus
18266 if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); }
18267 else { pm.copyTo(y); pt.copyTo(r); }
18268 var ys = y.t;
18269 var y0 = y[ys-1];
18270 if(y0 == 0) return;
18271 var yt = y0*(1<<self.F1)+((ys>1)?y[ys-2]>>self.F2:0);
18272 var d1 = self.FV/yt, d2 = (1<<self.F1)/yt, e = 1<<self.F2;
18273 var i = r.t, j = i-ys, t = (q==null)?nbi():q;
18274 y.dlShiftTo(j,t);
18275 if(r.compareTo(t) >= 0) {
18276 r[r.t++] = 1;
18277 r.subTo(t,r);
18278 }
18279 BigInteger.ONE.dlShiftTo(ys,t);
18280 t.subTo(y,y); // "negative" y so we can replace sub with am later
18281 while(y.t < ys) y[y.t++] = 0;
18282 while(--j >= 0) {
18283 // Estimate quotient digit
18284 var qd = (r[--i]==y0)?self.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);
18285 if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out
18286 y.dlShiftTo(j,t);
18287 r.subTo(t,r);
18288 while(r[i] < --qd) r.subTo(t,r);
18289 }
18290 }
18291 if(q != null) {
18292 r.drShiftTo(ys,q);
18293 if(ts != ms) BigInteger.ZERO.subTo(q,q);
18294 }
18295 r.t = ys;
18296 r.clamp();
18297 if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder
18298 if(ts < 0) BigInteger.ZERO.subTo(r,r);
18299 }
18300
18301 // (public) this mod a
18302 function bnMod(a) {
18303 var r = nbi();
18304 this.abs().divRemTo(a,null,r);
18305 if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);
18306 return r;
18307 }
18308
18309 // Modular reduction using "classic" algorithm
18310 function Classic(m) { this.m = m; }
18311 function cConvert(x) {
18312 if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
18313 else return x;
18314 }
18315 function cRevert(x) { return x; }
18316 function cReduce(x) { x.divRemTo(this.m,null,x); }
18317 function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18318 function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18319
18320 Classic.prototype.convert = cConvert;
18321 Classic.prototype.revert = cRevert;
18322 Classic.prototype.reduce = cReduce;
18323 Classic.prototype.mulTo = cMulTo;
18324 Classic.prototype.sqrTo = cSqrTo;
18325
18326 // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
18327 // justification:
18328 // xy == 1 (mod m)
18329 // xy = 1+km
18330 // xy(2-xy) = (1+km)(1-km)
18331 // x[y(2-xy)] = 1-k^2m^2
18332 // x[y(2-xy)] == 1 (mod m^2)
18333 // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
18334 // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
18335 // JS multiply "overflows" differently from C/C++, so care is needed here.
18336 function bnpInvDigit() {
18337 if(this.t < 1) return 0;
18338 var x = this[0];
18339 if((x&1) == 0) return 0;
18340 var y = x&3; // y == 1/x mod 2^2
18341 y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4
18342 y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8
18343 y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16
18344 // last step - calculate inverse mod DV directly;
18345 // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
18346 y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits
18347 // we really want the negative inverse, and -DV < y < DV
18348 return (y>0)?this.DV-y:-y;
18349 }
18350
18351 // Montgomery reduction
18352 function Montgomery(m) {
18353 this.m = m;
18354 this.mp = m.invDigit();
18355 this.mpl = this.mp&0x7fff;
18356 this.mph = this.mp>>15;
18357 this.um = (1<<(m.DB-15))-1;
18358 this.mt2 = 2*m.t;
18359 }
18360
18361 // xR mod m
18362 function montConvert(x) {
18363 var r = nbi();
18364 x.abs().dlShiftTo(this.m.t,r);
18365 r.divRemTo(this.m,null,r);
18366 if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);
18367 return r;
18368 }
18369
18370 // x/R mod m
18371 function montRevert(x) {
18372 var r = nbi();
18373 x.copyTo(r);
18374 this.reduce(r);
18375 return r;
18376 }
18377
18378 // x = x/R mod m (HAC 14.32)
18379 function montReduce(x) {
18380 while(x.t <= this.mt2) // pad x so am has enough room later
18381 x[x.t++] = 0;
18382 for(var i = 0; i < this.m.t; ++i) {
18383 // faster way of calculating u0 = x[i]*mp mod DV
18384 var j = x[i]&0x7fff;
18385 var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM;
18386 // use am to combine the multiply-shift-add into one call
18387 j = i+this.m.t;
18388 x[j] += this.m.am(0,u0,x,i,0,this.m.t);
18389 // propagate carry
18390 while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
18391 }
18392 x.clamp();
18393 x.drShiftTo(this.m.t,x);
18394 if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
18395 }
18396
18397 // r = "x^2/R mod m"; x != r
18398 function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18399
18400 // r = "xy/R mod m"; x,y != r
18401 function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18402
18403 Montgomery.prototype.convert = montConvert;
18404 Montgomery.prototype.revert = montRevert;
18405 Montgomery.prototype.reduce = montReduce;
18406 Montgomery.prototype.mulTo = montMulTo;
18407 Montgomery.prototype.sqrTo = montSqrTo;
18408
18409 // (protected) true iff this is even
18410 function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
18411
18412 // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
18413 function bnpExp(e,z) {
18414 if(e > 0xffffffff || e < 1) return BigInteger.ONE;
18415 var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
18416 g.copyTo(r);
18417 while(--i >= 0) {
18418 z.sqrTo(r,r2);
18419 if((e&(1<<i)) > 0) z.mulTo(r2,g,r);
18420 else { var t = r; r = r2; r2 = t; }
18421 }
18422 return z.revert(r);
18423 }
18424
18425 // (public) this^e % m, 0 <= e < 2^32
18426 function bnModPowInt(e,m) {
18427 var z;
18428 if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
18429 return this.exp(e,z);
18430 }
18431
18432 // protected
18433 proto.copyTo = bnpCopyTo;
18434 proto.fromInt = bnpFromInt;
18435 proto.fromString = bnpFromString;
18436 proto.clamp = bnpClamp;
18437 proto.dlShiftTo = bnpDLShiftTo;
18438 proto.drShiftTo = bnpDRShiftTo;
18439 proto.lShiftTo = bnpLShiftTo;
18440 proto.rShiftTo = bnpRShiftTo;
18441 proto.subTo = bnpSubTo;
18442 proto.multiplyTo = bnpMultiplyTo;
18443 proto.squareTo = bnpSquareTo;
18444 proto.divRemTo = bnpDivRemTo;
18445 proto.invDigit = bnpInvDigit;
18446 proto.isEven = bnpIsEven;
18447 proto.exp = bnpExp;
18448
18449 // public
18450 proto.toString = bnToString;
18451 proto.negate = bnNegate;
18452 proto.abs = bnAbs;
18453 proto.compareTo = bnCompareTo;
18454 proto.bitLength = bnBitLength;
18455 proto.mod = bnMod;
18456 proto.modPowInt = bnModPowInt;
18457
18458 //// jsbn2
18459
18460 function nbi() { return new BigInteger(null); }
18461
18462 // (public)
18463 function bnClone() { var r = nbi(); this.copyTo(r); return r; }
18464
18465 // (public) return value as integer
18466 function bnIntValue() {
18467 if(this.s < 0) {
18468 if(this.t == 1) return this[0]-this.DV;
18469 else if(this.t == 0) return -1;
18470 }
18471 else if(this.t == 1) return this[0];
18472 else if(this.t == 0) return 0;
18473 // assumes 16 < DB < 32
18474 return ((this[1]&((1<<(32-this.DB))-1))<<this.DB)|this[0];
18475 }
18476
18477 // (public) return value as byte
18478 function bnByteValue() { return (this.t==0)?this.s:(this[0]<<24)>>24; }
18479
18480 // (public) return value as short (assumes DB>=16)
18481 function bnShortValue() { return (this.t==0)?this.s:(this[0]<<16)>>16; }
18482
18483 // (protected) return x s.t. r^x < DV
18484 function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }
18485
18486 // (public) 0 if this == 0, 1 if this > 0
18487 function bnSigNum() {
18488 if(this.s < 0) return -1;
18489 else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
18490 else return 1;
18491 }
18492
18493 // (protected) convert to radix string
18494 function bnpToRadix(b) {
18495 if(b == null) b = 10;
18496 if(this.signum() == 0 || b < 2 || b > 36) return "0";
18497 var cs = this.chunkSize(b);
18498 var a = Math.pow(b,cs);
18499 var d = nbv(a), y = nbi(), z = nbi(), r = "";
18500 this.divRemTo(d,y,z);
18501 while(y.signum() > 0) {
18502 r = (a+z.intValue()).toString(b).substr(1) + r;
18503 y.divRemTo(d,y,z);
18504 }
18505 return z.intValue().toString(b) + r;
18506 }
18507
18508 // (protected) convert from radix string
18509 function bnpFromRadix(s,b) {
18510 var self = this;
18511 self.fromInt(0);
18512 if(b == null) b = 10;
18513 var cs = self.chunkSize(b);
18514 var d = Math.pow(b,cs), mi = false, j = 0, w = 0;
18515 for(var i = 0; i < s.length; ++i) {
18516 var x = intAt(s,i);
18517 if(x < 0) {
18518 if(s.charAt(i) == "-" && self.signum() == 0) mi = true;
18519 continue;
18520 }
18521 w = b*w+x;
18522 if(++j >= cs) {
18523 self.dMultiply(d);
18524 self.dAddOffset(w,0);
18525 j = 0;
18526 w = 0;
18527 }
18528 }
18529 if(j > 0) {
18530 self.dMultiply(Math.pow(b,j));
18531 self.dAddOffset(w,0);
18532 }
18533 if(mi) BigInteger.ZERO.subTo(self,self);
18534 }
18535
18536 // (protected) alternate constructor
18537 function bnpFromNumber(a,b,c) {
18538 var self = this;
18539 if("number" == typeof b) {
18540 // new BigInteger(int,int,RNG)
18541 if(a < 2) self.fromInt(1);
18542 else {
18543 self.fromNumber(a,c);
18544 if(!self.testBit(a-1)) // force MSB set
18545 self.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,self);
18546 if(self.isEven()) self.dAddOffset(1,0); // force odd
18547 while(!self.isProbablePrime(b)) {
18548 self.dAddOffset(2,0);
18549 if(self.bitLength() > a) self.subTo(BigInteger.ONE.shiftLeft(a-1),self);
18550 }
18551 }
18552 }
18553 else {
18554 // new BigInteger(int,RNG)
18555 var x = new Array(), t = a&7;
18556 x.length = (a>>3)+1;
18557 b.nextBytes(x);
18558 if(t > 0) x[0] &= ((1<<t)-1); else x[0] = 0;
18559 self.fromString(x,256);
18560 }
18561 }
18562
18563 // (public) convert to bigendian byte array
18564 function bnToByteArray() {
18565 var self = this;
18566 var i = self.t, r = new Array();
18567 r[0] = self.s;
18568 var p = self.DB-(i*self.DB)%8, d, k = 0;
18569 if(i-- > 0) {
18570 if(p < self.DB && (d = self[i]>>p) != (self.s&self.DM)>>p)
18571 r[k++] = d|(self.s<<(self.DB-p));
18572 while(i >= 0) {
18573 if(p < 8) {
18574 d = (self[i]&((1<<p)-1))<<(8-p);
18575 d |= self[--i]>>(p+=self.DB-8);
18576 }
18577 else {
18578 d = (self[i]>>(p-=8))&0xff;
18579 if(p <= 0) { p += self.DB; --i; }
18580 }
18581 if((d&0x80) != 0) d |= -256;
18582 if(k === 0 && (self.s&0x80) != (d&0x80)) ++k;
18583 if(k > 0 || d != self.s) r[k++] = d;
18584 }
18585 }
18586 return r;
18587 }
18588
18589 function bnEquals(a) { return(this.compareTo(a)==0); }
18590 function bnMin(a) { return(this.compareTo(a)<0)?this:a; }
18591 function bnMax(a) { return(this.compareTo(a)>0)?this:a; }
18592
18593 // (protected) r = this op a (bitwise)
18594 function bnpBitwiseTo(a,op,r) {
18595 var self = this;
18596 var i, f, m = Math.min(a.t,self.t);
18597 for(i = 0; i < m; ++i) r[i] = op(self[i],a[i]);
18598 if(a.t < self.t) {
18599 f = a.s&self.DM;
18600 for(i = m; i < self.t; ++i) r[i] = op(self[i],f);
18601 r.t = self.t;
18602 }
18603 else {
18604 f = self.s&self.DM;
18605 for(i = m; i < a.t; ++i) r[i] = op(f,a[i]);
18606 r.t = a.t;
18607 }
18608 r.s = op(self.s,a.s);
18609 r.clamp();
18610 }
18611
18612 // (public) this & a
18613 function op_and(x,y) { return x&y; }
18614 function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
18615
18616 // (public) this | a
18617 function op_or(x,y) { return x|y; }
18618 function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
18619
18620 // (public) this ^ a
18621 function op_xor(x,y) { return x^y; }
18622 function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
18623
18624 // (public) this & ~a
18625 function op_andnot(x,y) { return x&~y; }
18626 function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
18627
18628 // (public) ~this
18629 function bnNot() {
18630 var r = nbi();
18631 for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i];
18632 r.t = this.t;
18633 r.s = ~this.s;
18634 return r;
18635 }
18636
18637 // (public) this << n
18638 function bnShiftLeft(n) {
18639 var r = nbi();
18640 if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
18641 return r;
18642 }
18643
18644 // (public) this >> n
18645 function bnShiftRight(n) {
18646 var r = nbi();
18647 if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
18648 return r;
18649 }
18650
18651 // return index of lowest 1-bit in x, x < 2^31
18652 function lbit(x) {
18653 if(x == 0) return -1;
18654 var r = 0;
18655 if((x&0xffff) == 0) { x >>= 16; r += 16; }
18656 if((x&0xff) == 0) { x >>= 8; r += 8; }
18657 if((x&0xf) == 0) { x >>= 4; r += 4; }
18658 if((x&3) == 0) { x >>= 2; r += 2; }
18659 if((x&1) == 0) ++r;
18660 return r;
18661 }
18662
18663 // (public) returns index of lowest 1-bit (or -1 if none)
18664 function bnGetLowestSetBit() {
18665 for(var i = 0; i < this.t; ++i)
18666 if(this[i] != 0) return i*this.DB+lbit(this[i]);
18667 if(this.s < 0) return this.t*this.DB;
18668 return -1;
18669 }
18670
18671 // return number of 1 bits in x
18672 function cbit(x) {
18673 var r = 0;
18674 while(x != 0) { x &= x-1; ++r; }
18675 return r;
18676 }
18677
18678 // (public) return number of set bits
18679 function bnBitCount() {
18680 var r = 0, x = this.s&this.DM;
18681 for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x);
18682 return r;
18683 }
18684
18685 // (public) true iff nth bit is set
18686 function bnTestBit(n) {
18687 var j = Math.floor(n/this.DB);
18688 if(j >= this.t) return(this.s!=0);
18689 return((this[j]&(1<<(n%this.DB)))!=0);
18690 }
18691
18692 // (protected) this op (1<<n)
18693 function bnpChangeBit(n,op) {
18694 var r = BigInteger.ONE.shiftLeft(n);
18695 this.bitwiseTo(r,op,r);
18696 return r;
18697 }
18698
18699 // (public) this | (1<<n)
18700 function bnSetBit(n) { return this.changeBit(n,op_or); }
18701
18702 // (public) this & ~(1<<n)
18703 function bnClearBit(n) { return this.changeBit(n,op_andnot); }
18704
18705 // (public) this ^ (1<<n)
18706 function bnFlipBit(n) { return this.changeBit(n,op_xor); }
18707
18708 // (protected) r = this + a
18709 function bnpAddTo(a,r) {
18710 var self = this;
18711
18712 var i = 0, c = 0, m = Math.min(a.t,self.t);
18713 while(i < m) {
18714 c += self[i]+a[i];
18715 r[i++] = c&self.DM;
18716 c >>= self.DB;
18717 }
18718 if(a.t < self.t) {
18719 c += a.s;
18720 while(i < self.t) {
18721 c += self[i];
18722 r[i++] = c&self.DM;
18723 c >>= self.DB;
18724 }
18725 c += self.s;
18726 }
18727 else {
18728 c += self.s;
18729 while(i < a.t) {
18730 c += a[i];
18731 r[i++] = c&self.DM;
18732 c >>= self.DB;
18733 }
18734 c += a.s;
18735 }
18736 r.s = (c<0)?-1:0;
18737 if(c > 0) r[i++] = c;
18738 else if(c < -1) r[i++] = self.DV+c;
18739 r.t = i;
18740 r.clamp();
18741 }
18742
18743 // (public) this + a
18744 function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }
18745
18746 // (public) this - a
18747 function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }
18748
18749 // (public) this * a
18750 function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }
18751
18752 // (public) this^2
18753 function bnSquare() { var r = nbi(); this.squareTo(r); return r; }
18754
18755 // (public) this / a
18756 function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }
18757
18758 // (public) this % a
18759 function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }
18760
18761 // (public) [this/a,this%a]
18762 function bnDivideAndRemainder(a) {
18763 var q = nbi(), r = nbi();
18764 this.divRemTo(a,q,r);
18765 return new Array(q,r);
18766 }
18767
18768 // (protected) this *= n, this >= 0, 1 < n < DV
18769 function bnpDMultiply(n) {
18770 this[this.t] = this.am(0,n-1,this,0,0,this.t);
18771 ++this.t;
18772 this.clamp();
18773 }
18774
18775 // (protected) this += n << w words, this >= 0
18776 function bnpDAddOffset(n,w) {
18777 if(n == 0) return;
18778 while(this.t <= w) this[this.t++] = 0;
18779 this[w] += n;
18780 while(this[w] >= this.DV) {
18781 this[w] -= this.DV;
18782 if(++w >= this.t) this[this.t++] = 0;
18783 ++this[w];
18784 }
18785 }
18786
18787 // A "null" reducer
18788 function NullExp() {}
18789 function nNop(x) { return x; }
18790 function nMulTo(x,y,r) { x.multiplyTo(y,r); }
18791 function nSqrTo(x,r) { x.squareTo(r); }
18792
18793 NullExp.prototype.convert = nNop;
18794 NullExp.prototype.revert = nNop;
18795 NullExp.prototype.mulTo = nMulTo;
18796 NullExp.prototype.sqrTo = nSqrTo;
18797
18798 // (public) this^e
18799 function bnPow(e) { return this.exp(e,new NullExp()); }
18800
18801 // (protected) r = lower n words of "this * a", a.t <= n
18802 // "this" should be the larger one if appropriate.
18803 function bnpMultiplyLowerTo(a,n,r) {
18804 var i = Math.min(this.t+a.t,n);
18805 r.s = 0; // assumes a,this >= 0
18806 r.t = i;
18807 while(i > 0) r[--i] = 0;
18808 var j;
18809 for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(0,a[i],r,i,0,this.t);
18810 for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a[i],r,i,0,n-i);
18811 r.clamp();
18812 }
18813
18814 // (protected) r = "this * a" without lower n words, n > 0
18815 // "this" should be the larger one if appropriate.
18816 function bnpMultiplyUpperTo(a,n,r) {
18817 --n;
18818 var i = r.t = this.t+a.t-n;
18819 r.s = 0; // assumes a,this >= 0
18820 while(--i >= 0) r[i] = 0;
18821 for(i = Math.max(n-this.t,0); i < a.t; ++i)
18822 r[this.t+i-n] = this.am(n-i,a[i],r,0,0,this.t+i-n);
18823 r.clamp();
18824 r.drShiftTo(1,r);
18825 }
18826
18827 // Barrett modular reduction
18828 function Barrett(m) {
18829 // setup Barrett
18830 this.r2 = nbi();
18831 this.q3 = nbi();
18832 BigInteger.ONE.dlShiftTo(2*m.t,this.r2);
18833 this.mu = this.r2.divide(m);
18834 this.m = m;
18835 }
18836
18837 function barrettConvert(x) {
18838 if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m);
18839 else if(x.compareTo(this.m) < 0) return x;
18840 else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }
18841 }
18842
18843 function barrettRevert(x) { return x; }
18844
18845 // x = x mod m (HAC 14.42)
18846 function barrettReduce(x) {
18847 var self = this;
18848 x.drShiftTo(self.m.t-1,self.r2);
18849 if(x.t > self.m.t+1) { x.t = self.m.t+1; x.clamp(); }
18850 self.mu.multiplyUpperTo(self.r2,self.m.t+1,self.q3);
18851 self.m.multiplyLowerTo(self.q3,self.m.t+1,self.r2);
18852 while(x.compareTo(self.r2) < 0) x.dAddOffset(1,self.m.t+1);
18853 x.subTo(self.r2,x);
18854 while(x.compareTo(self.m) >= 0) x.subTo(self.m,x);
18855 }
18856
18857 // r = x^2 mod m; x != r
18858 function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18859
18860 // r = x*y mod m; x,y != r
18861 function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18862
18863 Barrett.prototype.convert = barrettConvert;
18864 Barrett.prototype.revert = barrettRevert;
18865 Barrett.prototype.reduce = barrettReduce;
18866 Barrett.prototype.mulTo = barrettMulTo;
18867 Barrett.prototype.sqrTo = barrettSqrTo;
18868
18869 // (public) this^e % m (HAC 14.85)
18870 function bnModPow(e,m) {
18871 var i = e.bitLength(), k, r = nbv(1), z;
18872 if(i <= 0) return r;
18873 else if(i < 18) k = 1;
18874 else if(i < 48) k = 3;
18875 else if(i < 144) k = 4;
18876 else if(i < 768) k = 5;
18877 else k = 6;
18878 if(i < 8)
18879 z = new Classic(m);
18880 else if(m.isEven())
18881 z = new Barrett(m);
18882 else
18883 z = new Montgomery(m);
18884
18885 // precomputation
18886 var g = new Array(), n = 3, k1 = k-1, km = (1<<k)-1;
18887 g[1] = z.convert(this);
18888 if(k > 1) {
18889 var g2 = nbi();
18890 z.sqrTo(g[1],g2);
18891 while(n <= km) {
18892 g[n] = nbi();
18893 z.mulTo(g2,g[n-2],g[n]);
18894 n += 2;
18895 }
18896 }
18897
18898 var j = e.t-1, w, is1 = true, r2 = nbi(), t;
18899 i = nbits(e[j])-1;
18900 while(j >= 0) {
18901 if(i >= k1) w = (e[j]>>(i-k1))&km;
18902 else {
18903 w = (e[j]&((1<<(i+1))-1))<<(k1-i);
18904 if(j > 0) w |= e[j-1]>>(this.DB+i-k1);
18905 }
18906
18907 n = k;
18908 while((w&1) == 0) { w >>= 1; --n; }
18909 if((i -= n) < 0) { i += this.DB; --j; }
18910 if(is1) { // ret == 1, don't bother squaring or multiplying it
18911 g[w].copyTo(r);
18912 is1 = false;
18913 }
18914 else {
18915 while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; }
18916 if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }
18917 z.mulTo(r2,g[w],r);
18918 }
18919
18920 while(j >= 0 && (e[j]&(1<<i)) == 0) {
18921 z.sqrTo(r,r2); t = r; r = r2; r2 = t;
18922 if(--i < 0) { i = this.DB-1; --j; }
18923 }
18924 }
18925 return z.revert(r);
18926 }
18927
18928 // (public) gcd(this,a) (HAC 14.54)
18929 function bnGCD(a) {
18930 var x = (this.s<0)?this.negate():this.clone();
18931 var y = (a.s<0)?a.negate():a.clone();
18932 if(x.compareTo(y) < 0) { var t = x; x = y; y = t; }
18933 var i = x.getLowestSetBit(), g = y.getLowestSetBit();
18934 if(g < 0) return x;
18935 if(i < g) g = i;
18936 if(g > 0) {
18937 x.rShiftTo(g,x);
18938 y.rShiftTo(g,y);
18939 }
18940 while(x.signum() > 0) {
18941 if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x);
18942 if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y);
18943 if(x.compareTo(y) >= 0) {
18944 x.subTo(y,x);
18945 x.rShiftTo(1,x);
18946 }
18947 else {
18948 y.subTo(x,y);
18949 y.rShiftTo(1,y);
18950 }
18951 }
18952 if(g > 0) y.lShiftTo(g,y);
18953 return y;
18954 }
18955
18956 // (protected) this % n, n < 2^26
18957 function bnpModInt(n) {
18958 if(n <= 0) return 0;
18959 var d = this.DV%n, r = (this.s<0)?n-1:0;
18960 if(this.t > 0)
18961 if(d == 0) r = this[0]%n;
18962 else for(var i = this.t-1; i >= 0; --i) r = (d*r+this[i])%n;
18963 return r;
18964 }
18965
18966 // (public) 1/this % m (HAC 14.61)
18967 function bnModInverse(m) {
18968 var ac = m.isEven();
18969 if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
18970 var u = m.clone(), v = this.clone();
18971 var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
18972 while(u.signum() != 0) {
18973 while(u.isEven()) {
18974 u.rShiftTo(1,u);
18975 if(ac) {
18976 if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }
18977 a.rShiftTo(1,a);
18978 }
18979 else if(!b.isEven()) b.subTo(m,b);
18980 b.rShiftTo(1,b);
18981 }
18982 while(v.isEven()) {
18983 v.rShiftTo(1,v);
18984 if(ac) {
18985 if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }
18986 c.rShiftTo(1,c);
18987 }
18988 else if(!d.isEven()) d.subTo(m,d);
18989 d.rShiftTo(1,d);
18990 }
18991 if(u.compareTo(v) >= 0) {
18992 u.subTo(v,u);
18993 if(ac) a.subTo(c,a);
18994 b.subTo(d,b);
18995 }
18996 else {
18997 v.subTo(u,v);
18998 if(ac) c.subTo(a,c);
18999 d.subTo(b,d);
19000 }
19001 }
19002 if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
19003 if(d.compareTo(m) >= 0) return d.subtract(m);
19004 if(d.signum() < 0) d.addTo(m,d); else return d;
19005 if(d.signum() < 0) return d.add(m); else return d;
19006 }
19007
19008 // protected
19009 proto.chunkSize = bnpChunkSize;
19010 proto.toRadix = bnpToRadix;
19011 proto.fromRadix = bnpFromRadix;
19012 proto.fromNumber = bnpFromNumber;
19013 proto.bitwiseTo = bnpBitwiseTo;
19014 proto.changeBit = bnpChangeBit;
19015 proto.addTo = bnpAddTo;
19016 proto.dMultiply = bnpDMultiply;
19017 proto.dAddOffset = bnpDAddOffset;
19018 proto.multiplyLowerTo = bnpMultiplyLowerTo;
19019 proto.multiplyUpperTo = bnpMultiplyUpperTo;
19020 proto.modInt = bnpModInt;
19021
19022 // public
19023 proto.clone = bnClone;
19024 proto.intValue = bnIntValue;
19025 proto.byteValue = bnByteValue;
19026 proto.shortValue = bnShortValue;
19027 proto.signum = bnSigNum;
19028 proto.toByteArray = bnToByteArray;
19029 proto.equals = bnEquals;
19030 proto.min = bnMin;
19031 proto.max = bnMax;
19032 proto.and = bnAnd;
19033 proto.or = bnOr;
19034 proto.xor = bnXor;
19035 proto.andNot = bnAndNot;
19036 proto.not = bnNot;
19037 proto.shiftLeft = bnShiftLeft;
19038 proto.shiftRight = bnShiftRight;
19039 proto.getLowestSetBit = bnGetLowestSetBit;
19040 proto.bitCount = bnBitCount;
19041 proto.testBit = bnTestBit;
19042 proto.setBit = bnSetBit;
19043 proto.clearBit = bnClearBit;
19044 proto.flipBit = bnFlipBit;
19045 proto.add = bnAdd;
19046 proto.subtract = bnSubtract;
19047 proto.multiply = bnMultiply;
19048 proto.divide = bnDivide;
19049 proto.remainder = bnRemainder;
19050 proto.divideAndRemainder = bnDivideAndRemainder;
19051 proto.modPow = bnModPow;
19052 proto.modInverse = bnModInverse;
19053 proto.pow = bnPow;
19054 proto.gcd = bnGCD;
19055
19056 // JSBN-specific extension
19057 proto.square = bnSquare;
19058
19059 // BigInteger interfaces not implemented in jsbn:
19060
19061 // BigInteger(int signum, byte[] magnitude)
19062 // double doubleValue()
19063 // float floatValue()
19064 // int hashCode()
19065 // long longValue()
19066 // static BigInteger valueOf(long val)
19067
19068 // "constants"
19069 BigInteger.ZERO = nbv(0);
19070 BigInteger.ONE = nbv(1);
19071 BigInteger.valueOf = nbv;
19072
19073 },{"assert":4}],2:[function(_dereq_,module,exports){
19074 (function (Buffer){
19075 // FIXME: Kind of a weird way to throw exceptions, consider removing
19076 var assert = _dereq_('assert')
19077 var BigInteger = _dereq_('./bigi')
19078
19079 /**
19080 * Turns a byte array into a big integer.
19081 *
19082 * This function will interpret a byte array as a big integer in big
19083 * endian notation.
19084 */
19085 BigInteger.fromByteArrayUnsigned = function(byteArray) {
19086 // BigInteger expects a DER integer conformant byte array
19087 if (byteArray[0] & 0x80) {
19088 return new BigInteger([0].concat(byteArray))
19089 }
19090
19091 return new BigInteger(byteArray)
19092 }
19093
19094 /**
19095 * Returns a byte array representation of the big integer.
19096 *
19097 * This returns the absolute of the contained value in big endian
19098 * form. A value of zero results in an empty array.
19099 */
19100 BigInteger.prototype.toByteArrayUnsigned = function() {
19101 var byteArray = this.toByteArray()
19102 return byteArray[0] === 0 ? byteArray.slice(1) : byteArray
19103 }
19104
19105 BigInteger.fromDERInteger = function(byteArray) {
19106 return new BigInteger(byteArray)
19107 }
19108
19109 /*
19110 * Converts BigInteger to a DER integer representation.
19111 *
19112 * The format for this value uses the most significant bit as a sign
19113 * bit. If the most significant bit is already set and the integer is
19114 * positive, a 0x00 is prepended.
19115 *
19116 * Examples:
19117 *
19118 * 0 => 0x00
19119 * 1 => 0x01
19120 * -1 => 0x81
19121 * 127 => 0x7f
19122 * -127 => 0xff
19123 * 128 => 0x0080
19124 * -128 => 0x80
19125 * 255 => 0x00ff
19126 * -255 => 0xff
19127 * 16300 => 0x3fac
19128 * -16300 => 0xbfac
19129 * 62300 => 0x00f35c
19130 * -62300 => 0xf35c
19131 */
19132 BigInteger.prototype.toDERInteger = BigInteger.prototype.toByteArray
19133
19134 BigInteger.fromBuffer = function(buffer) {
19135 // BigInteger expects a DER integer conformant byte array
19136 if (buffer[0] & 0x80) {
19137 var byteArray = Array.prototype.slice.call(buffer)
19138
19139 return new BigInteger([0].concat(byteArray))
19140 }
19141
19142 return new BigInteger(buffer)
19143 }
19144
19145 BigInteger.fromHex = function(hex) {
19146 if (hex === '') return BigInteger.ZERO
19147
19148 assert.equal(hex, hex.match(/^[A-Fa-f0-9]+/), 'Invalid hex string')
19149 assert.equal(hex.length % 2, 0, 'Incomplete hex')
19150 return new BigInteger(hex, 16)
19151 }
19152
19153 BigInteger.prototype.toBuffer = function(size) {
19154 var byteArray = this.toByteArrayUnsigned()
19155 var zeros = []
19156
19157 var padding = size - byteArray.length
19158 while (zeros.length < padding) zeros.push(0)
19159
19160 return new Buffer(zeros.concat(byteArray))
19161 }
19162
19163 BigInteger.prototype.toHex = function(size) {
19164 return this.toBuffer(size).toString('hex')
19165 }
19166
19167 }).call(this,_dereq_("buffer").Buffer)
19168 },{"./bigi":1,"assert":4,"buffer":8}],3:[function(_dereq_,module,exports){
19169 var BigInteger = _dereq_('./bigi')
19170
19171 //addons
19172 _dereq_('./convert')
19173
19174 module.exports = BigInteger
19175 },{"./bigi":1,"./convert":2}],4:[function(_dereq_,module,exports){
19176 // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
19177 //
19178 // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
19179 //
19180 // Originally from narwhal.js (http://narwhaljs.org)
19181 // Copyright (c) 2009 Thomas Robinson <280north.com>
19182 //
19183 // Permission is hereby granted, free of charge, to any person obtaining a copy
19184 // of this software and associated documentation files (the 'Software'), to
19185 // deal in the Software without restriction, including without limitation the
19186 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
19187 // sell copies of the Software, and to permit persons to whom the Software is
19188 // furnished to do so, subject to the following conditions:
19189 //
19190 // The above copyright notice and this permission notice shall be included in
19191 // all copies or substantial portions of the Software.
19192 //
19193 // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19194 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19195 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19196 // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19197 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19198 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19199
19200 // when used in node, this will actually load the util module we depend on
19201 // versus loading the builtin util module as happens otherwise
19202 // this is a bug in node module loading as far as I am concerned
19203 var util = _dereq_('util/');
19204
19205 var pSlice = Array.prototype.slice;
19206 var hasOwn = Object.prototype.hasOwnProperty;
19207
19208 // 1. The assert module provides functions that throw
19209 // AssertionError's when particular conditions are not met. The
19210 // assert module must conform to the following interface.
19211
19212 var assert = module.exports = ok;
19213
19214 // 2. The AssertionError is defined in assert.
19215 // new assert.AssertionError({ message: message,
19216 // actual: actual,
19217 // expected: expected })
19218
19219 assert.AssertionError = function AssertionError(options) {
19220 this.name = 'AssertionError';
19221 this.actual = options.actual;
19222 this.expected = options.expected;
19223 this.operator = options.operator;
19224 if (options.message) {
19225 this.message = options.message;
19226 this.generatedMessage = false;
19227 } else {
19228 this.message = getMessage(this);
19229 this.generatedMessage = true;
19230 }
19231 var stackStartFunction = options.stackStartFunction || fail;
19232
19233 if (Error.captureStackTrace) {
19234 Error.captureStackTrace(this, stackStartFunction);
19235 }
19236 else {
19237 // non v8 browsers so we can have a stacktrace
19238 var err = new Error();
19239 if (err.stack) {
19240 var out = err.stack;
19241
19242 // try to strip useless frames
19243 var fn_name = stackStartFunction.name;
19244 var idx = out.indexOf('\n' + fn_name);
19245 if (idx >= 0) {
19246 // once we have located the function frame
19247 // we need to strip out everything before it (and its line)
19248 var next_line = out.indexOf('\n', idx + 1);
19249 out = out.substring(next_line + 1);
19250 }
19251
19252 this.stack = out;
19253 }
19254 }
19255 };
19256
19257 // assert.AssertionError instanceof Error
19258 util.inherits(assert.AssertionError, Error);
19259
19260 function replacer(key, value) {
19261 if (util.isUndefined(value)) {
19262 return '' + value;
19263 }
19264 if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) {
19265 return value.toString();
19266 }
19267 if (util.isFunction(value) || util.isRegExp(value)) {
19268 return value.toString();
19269 }
19270 return value;
19271 }
19272
19273 function truncate(s, n) {
19274 if (util.isString(s)) {
19275 return s.length < n ? s : s.slice(0, n);
19276 } else {
19277 return s;
19278 }
19279 }
19280
19281 function getMessage(self) {
19282 return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
19283 self.operator + ' ' +
19284 truncate(JSON.stringify(self.expected, replacer), 128);
19285 }
19286
19287 // At present only the three keys mentioned above are used and
19288 // understood by the spec. Implementations or sub modules can pass
19289 // other keys to the AssertionError's constructor - they will be
19290 // ignored.
19291
19292 // 3. All of the following functions must throw an AssertionError
19293 // when a corresponding condition is not met, with a message that
19294 // may be undefined if not provided. All assertion methods provide
19295 // both the actual and expected values to the assertion error for
19296 // display purposes.
19297
19298 function fail(actual, expected, message, operator, stackStartFunction) {
19299 throw new assert.AssertionError({
19300 message: message,
19301 actual: actual,
19302 expected: expected,
19303 operator: operator,
19304 stackStartFunction: stackStartFunction
19305 });
19306 }
19307
19308 // EXTENSION! allows for well behaved errors defined elsewhere.
19309 assert.fail = fail;
19310
19311 // 4. Pure assertion tests whether a value is truthy, as determined
19312 // by !!guard.
19313 // assert.ok(guard, message_opt);
19314 // This statement is equivalent to assert.equal(true, !!guard,
19315 // message_opt);. To test strictly for the value true, use
19316 // assert.strictEqual(true, guard, message_opt);.
19317
19318 function ok(value, message) {
19319 if (!value) fail(value, true, message, '==', assert.ok);
19320 }
19321 assert.ok = ok;
19322
19323 // 5. The equality assertion tests shallow, coercive equality with
19324 // ==.
19325 // assert.equal(actual, expected, message_opt);
19326
19327 assert.equal = function equal(actual, expected, message) {
19328 if (actual != expected) fail(actual, expected, message, '==', assert.equal);
19329 };
19330
19331 // 6. The non-equality assertion tests for whether two objects are not equal
19332 // with != assert.notEqual(actual, expected, message_opt);
19333
19334 assert.notEqual = function notEqual(actual, expected, message) {
19335 if (actual == expected) {
19336 fail(actual, expected, message, '!=', assert.notEqual);
19337 }
19338 };
19339
19340 // 7. The equivalence assertion tests a deep equality relation.
19341 // assert.deepEqual(actual, expected, message_opt);
19342
19343 assert.deepEqual = function deepEqual(actual, expected, message) {
19344 if (!_deepEqual(actual, expected)) {
19345 fail(actual, expected, message, 'deepEqual', assert.deepEqual);
19346 }
19347 };
19348
19349 function _deepEqual(actual, expected) {
19350 // 7.1. All identical values are equivalent, as determined by ===.
19351 if (actual === expected) {
19352 return true;
19353
19354 } else if (util.isBuffer(actual) && util.isBuffer(expected)) {
19355 if (actual.length != expected.length) return false;
19356
19357 for (var i = 0; i < actual.length; i++) {
19358 if (actual[i] !== expected[i]) return false;
19359 }
19360
19361 return true;
19362
19363 // 7.2. If the expected value is a Date object, the actual value is
19364 // equivalent if it is also a Date object that refers to the same time.
19365 } else if (util.isDate(actual) && util.isDate(expected)) {
19366 return actual.getTime() === expected.getTime();
19367
19368 // 7.3 If the expected value is a RegExp object, the actual value is
19369 // equivalent if it is also a RegExp object with the same source and
19370 // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
19371 } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
19372 return actual.source === expected.source &&
19373 actual.global === expected.global &&
19374 actual.multiline === expected.multiline &&
19375 actual.lastIndex === expected.lastIndex &&
19376 actual.ignoreCase === expected.ignoreCase;
19377
19378 // 7.4. Other pairs that do not both pass typeof value == 'object',
19379 // equivalence is determined by ==.
19380 } else if (!util.isObject(actual) && !util.isObject(expected)) {
19381 return actual == expected;
19382
19383 // 7.5 For all other Object pairs, including Array objects, equivalence is
19384 // determined by having the same number of owned properties (as verified
19385 // with Object.prototype.hasOwnProperty.call), the same set of keys
19386 // (although not necessarily the same order), equivalent values for every
19387 // corresponding key, and an identical 'prototype' property. Note: this
19388 // accounts for both named and indexed properties on Arrays.
19389 } else {
19390 return objEquiv(actual, expected);
19391 }
19392 }
19393
19394 function isArguments(object) {
19395 return Object.prototype.toString.call(object) == '[object Arguments]';
19396 }
19397
19398 function objEquiv(a, b) {
19399 if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
19400 return false;
19401 // an identical 'prototype' property.
19402 if (a.prototype !== b.prototype) return false;
19403 //~~~I've managed to break Object.keys through screwy arguments passing.
19404 // Converting to array solves the problem.
19405 if (isArguments(a)) {
19406 if (!isArguments(b)) {
19407 return false;
19408 }
19409 a = pSlice.call(a);
19410 b = pSlice.call(b);
19411 return _deepEqual(a, b);
19412 }
19413 try {
19414 var ka = objectKeys(a),
19415 kb = objectKeys(b),
19416 key, i;
19417 } catch (e) {//happens when one is a string literal and the other isn't
19418 return false;
19419 }
19420 // having the same number of owned properties (keys incorporates
19421 // hasOwnProperty)
19422 if (ka.length != kb.length)
19423 return false;
19424 //the same set of keys (although not necessarily the same order),
19425 ka.sort();
19426 kb.sort();
19427 //~~~cheap key test
19428 for (i = ka.length - 1; i >= 0; i--) {
19429 if (ka[i] != kb[i])
19430 return false;
19431 }
19432 //equivalent values for every corresponding key, and
19433 //~~~possibly expensive deep test
19434 for (i = ka.length - 1; i >= 0; i--) {
19435 key = ka[i];
19436 if (!_deepEqual(a[key], b[key])) return false;
19437 }
19438 return true;
19439 }
19440
19441 // 8. The non-equivalence assertion tests for any deep inequality.
19442 // assert.notDeepEqual(actual, expected, message_opt);
19443
19444 assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
19445 if (_deepEqual(actual, expected)) {
19446 fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
19447 }
19448 };
19449
19450 // 9. The strict equality assertion tests strict equality, as determined by ===.
19451 // assert.strictEqual(actual, expected, message_opt);
19452
19453 assert.strictEqual = function strictEqual(actual, expected, message) {
19454 if (actual !== expected) {
19455 fail(actual, expected, message, '===', assert.strictEqual);
19456 }
19457 };
19458
19459 // 10. The strict non-equality assertion tests for strict inequality, as
19460 // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
19461
19462 assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
19463 if (actual === expected) {
19464 fail(actual, expected, message, '!==', assert.notStrictEqual);
19465 }
19466 };
19467
19468 function expectedException(actual, expected) {
19469 if (!actual || !expected) {
19470 return false;
19471 }
19472
19473 if (Object.prototype.toString.call(expected) == '[object RegExp]') {
19474 return expected.test(actual);
19475 } else if (actual instanceof expected) {
19476 return true;
19477 } else if (expected.call({}, actual) === true) {
19478 return true;
19479 }
19480
19481 return false;
19482 }
19483
19484 function _throws(shouldThrow, block, expected, message) {
19485 var actual;
19486
19487 if (util.isString(expected)) {
19488 message = expected;
19489 expected = null;
19490 }
19491
19492 try {
19493 block();
19494 } catch (e) {
19495 actual = e;
19496 }
19497
19498 message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
19499 (message ? ' ' + message : '.');
19500
19501 if (shouldThrow && !actual) {
19502 fail(actual, expected, 'Missing expected exception' + message);
19503 }
19504
19505 if (!shouldThrow && expectedException(actual, expected)) {
19506 fail(actual, expected, 'Got unwanted exception' + message);
19507 }
19508
19509 if ((shouldThrow && actual && expected &&
19510 !expectedException(actual, expected)) || (!shouldThrow && actual)) {
19511 throw actual;
19512 }
19513 }
19514
19515 // 11. Expected to throw an error:
19516 // assert.throws(block, Error_opt, message_opt);
19517
19518 assert.throws = function(block, /*optional*/error, /*optional*/message) {
19519 _throws.apply(this, [true].concat(pSlice.call(arguments)));
19520 };
19521
19522 // EXTENSION! This is annoying to write outside this module.
19523 assert.doesNotThrow = function(block, /*optional*/message) {
19524 _throws.apply(this, [false].concat(pSlice.call(arguments)));
19525 };
19526
19527 assert.ifError = function(err) { if (err) {throw err;}};
19528
19529 var objectKeys = Object.keys || function (obj) {
19530 var keys = [];
19531 for (var key in obj) {
19532 if (hasOwn.call(obj, key)) keys.push(key);
19533 }
19534 return keys;
19535 };
19536
19537 },{"util/":6}],5:[function(_dereq_,module,exports){
19538 module.exports = function isBuffer(arg) {
19539 return arg && typeof arg === 'object'
19540 && typeof arg.copy === 'function'
19541 && typeof arg.fill === 'function'
19542 && typeof arg.readUInt8 === 'function';
19543 }
19544 },{}],6:[function(_dereq_,module,exports){
19545 (function (process,global){
19546 // Copyright Joyent, Inc. and other Node contributors.
19547 //
19548 // Permission is hereby granted, free of charge, to any person obtaining a
19549 // copy of this software and associated documentation files (the
19550 // "Software"), to deal in the Software without restriction, including
19551 // without limitation the rights to use, copy, modify, merge, publish,
19552 // distribute, sublicense, and/or sell copies of the Software, and to permit
19553 // persons to whom the Software is furnished to do so, subject to the
19554 // following conditions:
19555 //
19556 // The above copyright notice and this permission notice shall be included
19557 // in all copies or substantial portions of the Software.
19558 //
19559 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19560 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19561 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
19562 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19563 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19564 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19565 // USE OR OTHER DEALINGS IN THE SOFTWARE.
19566
19567 var formatRegExp = /%[sdj%]/g;
19568 exports.format = function(f) {
19569 if (!isString(f)) {
19570 var objects = [];
19571 for (var i = 0; i < arguments.length; i++) {
19572 objects.push(inspect(arguments[i]));
19573 }
19574 return objects.join(' ');
19575 }
19576
19577 var i = 1;
19578 var args = arguments;
19579 var len = args.length;
19580 var str = String(f).replace(formatRegExp, function(x) {
19581 if (x === '%%') return '%';
19582 if (i >= len) return x;
19583 switch (x) {
19584 case '%s': return String(args[i++]);
19585 case '%d': return Number(args[i++]);
19586 case '%j':
19587 try {
19588 return JSON.stringify(args[i++]);
19589 } catch (_) {
19590 return '[Circular]';
19591 }
19592 default:
19593 return x;
19594 }
19595 });
19596 for (var x = args[i]; i < len; x = args[++i]) {
19597 if (isNull(x) || !isObject(x)) {
19598 str += ' ' + x;
19599 } else {
19600 str += ' ' + inspect(x);
19601 }
19602 }
19603 return str;
19604 };
19605
19606
19607 // Mark that a method should not be used.
19608 // Returns a modified function which warns once by default.
19609 // If --no-deprecation is set, then it is a no-op.
19610 exports.deprecate = function(fn, msg) {
19611 // Allow for deprecating things in the process of starting up.
19612 if (isUndefined(global.process)) {
19613 return function() {
19614 return exports.deprecate(fn, msg).apply(this, arguments);
19615 };
19616 }
19617
19618 if (process.noDeprecation === true) {
19619 return fn;
19620 }
19621
19622 var warned = false;
19623 function deprecated() {
19624 if (!warned) {
19625 if (process.throwDeprecation) {
19626 throw new Error(msg);
19627 } else if (process.traceDeprecation) {
19628 console.trace(msg);
19629 } else {
19630 console.error(msg);
19631 }
19632 warned = true;
19633 }
19634 return fn.apply(this, arguments);
19635 }
19636
19637 return deprecated;
19638 };
19639
19640
19641 var debugs = {};
19642 var debugEnviron;
19643 exports.debuglog = function(set) {
19644 if (isUndefined(debugEnviron))
19645 debugEnviron = process.env.NODE_DEBUG || '';
19646 set = set.toUpperCase();
19647 if (!debugs[set]) {
19648 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
19649 var pid = process.pid;
19650 debugs[set] = function() {
19651 var msg = exports.format.apply(exports, arguments);
19652 console.error('%s %d: %s', set, pid, msg);
19653 };
19654 } else {
19655 debugs[set] = function() {};
19656 }
19657 }
19658 return debugs[set];
19659 };
19660
19661
19662 /**
19663 * Echos the value of a value. Trys to print the value out
19664 * in the best way possible given the different types.
19665 *
19666 * @param {Object} obj The object to print out.
19667 * @param {Object} opts Optional options object that alters the output.
19668 */
19669 /* legacy: obj, showHidden, depth, colors*/
19670 function inspect(obj, opts) {
19671 // default options
19672 var ctx = {
19673 seen: [],
19674 stylize: stylizeNoColor
19675 };
19676 // legacy...
19677 if (arguments.length >= 3) ctx.depth = arguments[2];
19678 if (arguments.length >= 4) ctx.colors = arguments[3];
19679 if (isBoolean(opts)) {
19680 // legacy...
19681 ctx.showHidden = opts;
19682 } else if (opts) {
19683 // got an "options" object
19684 exports._extend(ctx, opts);
19685 }
19686 // set default options
19687 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
19688 if (isUndefined(ctx.depth)) ctx.depth = 2;
19689 if (isUndefined(ctx.colors)) ctx.colors = false;
19690 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
19691 if (ctx.colors) ctx.stylize = stylizeWithColor;
19692 return formatValue(ctx, obj, ctx.depth);
19693 }
19694 exports.inspect = inspect;
19695
19696
19697 // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
19698 inspect.colors = {
19699 'bold' : [1, 22],
19700 'italic' : [3, 23],
19701 'underline' : [4, 24],
19702 'inverse' : [7, 27],
19703 'white' : [37, 39],
19704 'grey' : [90, 39],
19705 'black' : [30, 39],
19706 'blue' : [34, 39],
19707 'cyan' : [36, 39],
19708 'green' : [32, 39],
19709 'magenta' : [35, 39],
19710 'red' : [31, 39],
19711 'yellow' : [33, 39]
19712 };
19713
19714 // Don't use 'blue' not visible on cmd.exe
19715 inspect.styles = {
19716 'special': 'cyan',
19717 'number': 'yellow',
19718 'boolean': 'yellow',
19719 'undefined': 'grey',
19720 'null': 'bold',
19721 'string': 'green',
19722 'date': 'magenta',
19723 // "name": intentionally not styling
19724 'regexp': 'red'
19725 };
19726
19727
19728 function stylizeWithColor(str, styleType) {
19729 var style = inspect.styles[styleType];
19730
19731 if (style) {
19732 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
19733 '\u001b[' + inspect.colors[style][1] + 'm';
19734 } else {
19735 return str;
19736 }
19737 }
19738
19739
19740 function stylizeNoColor(str, styleType) {
19741 return str;
19742 }
19743
19744
19745 function arrayToHash(array) {
19746 var hash = {};
19747
19748 array.forEach(function(val, idx) {
19749 hash[val] = true;
19750 });
19751
19752 return hash;
19753 }
19754
19755
19756 function formatValue(ctx, value, recurseTimes) {
19757 // Provide a hook for user-specified inspect functions.
19758 // Check that value is an object with an inspect function on it
19759 if (ctx.customInspect &&
19760 value &&
19761 isFunction(value.inspect) &&
19762 // Filter out the util module, it's inspect function is special
19763 value.inspect !== exports.inspect &&
19764 // Also filter out any prototype objects using the circular check.
19765 !(value.constructor && value.constructor.prototype === value)) {
19766 var ret = value.inspect(recurseTimes, ctx);
19767 if (!isString(ret)) {
19768 ret = formatValue(ctx, ret, recurseTimes);
19769 }
19770 return ret;
19771 }
19772
19773 // Primitive types cannot have properties
19774 var primitive = formatPrimitive(ctx, value);
19775 if (primitive) {
19776 return primitive;
19777 }
19778
19779 // Look up the keys of the object.
19780 var keys = Object.keys(value);
19781 var visibleKeys = arrayToHash(keys);
19782
19783 if (ctx.showHidden) {
19784 keys = Object.getOwnPropertyNames(value);
19785 }
19786
19787 // IE doesn't make error fields non-enumerable
19788 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
19789 if (isError(value)
19790 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
19791 return formatError(value);
19792 }
19793
19794 // Some type of object without properties can be shortcutted.
19795 if (keys.length === 0) {
19796 if (isFunction(value)) {
19797 var name = value.name ? ': ' + value.name : '';
19798 return ctx.stylize('[Function' + name + ']', 'special');
19799 }
19800 if (isRegExp(value)) {
19801 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
19802 }
19803 if (isDate(value)) {
19804 return ctx.stylize(Date.prototype.toString.call(value), 'date');
19805 }
19806 if (isError(value)) {
19807 return formatError(value);
19808 }
19809 }
19810
19811 var base = '', array = false, braces = ['{', '}'];
19812
19813 // Make Array say that they are Array
19814 if (isArray(value)) {
19815 array = true;
19816 braces = ['[', ']'];
19817 }
19818
19819 // Make functions say that they are functions
19820 if (isFunction(value)) {
19821 var n = value.name ? ': ' + value.name : '';
19822 base = ' [Function' + n + ']';
19823 }
19824
19825 // Make RegExps say that they are RegExps
19826 if (isRegExp(value)) {
19827 base = ' ' + RegExp.prototype.toString.call(value);
19828 }
19829
19830 // Make dates with properties first say the date
19831 if (isDate(value)) {
19832 base = ' ' + Date.prototype.toUTCString.call(value);
19833 }
19834
19835 // Make error with message first say the error
19836 if (isError(value)) {
19837 base = ' ' + formatError(value);
19838 }
19839
19840 if (keys.length === 0 && (!array || value.length == 0)) {
19841 return braces[0] + base + braces[1];
19842 }
19843
19844 if (recurseTimes < 0) {
19845 if (isRegExp(value)) {
19846 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
19847 } else {
19848 return ctx.stylize('[Object]', 'special');
19849 }
19850 }
19851
19852 ctx.seen.push(value);
19853
19854 var output;
19855 if (array) {
19856 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
19857 } else {
19858 output = keys.map(function(key) {
19859 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
19860 });
19861 }
19862
19863 ctx.seen.pop();
19864
19865 return reduceToSingleString(output, base, braces);
19866 }
19867
19868
19869 function formatPrimitive(ctx, value) {
19870 if (isUndefined(value))
19871 return ctx.stylize('undefined', 'undefined');
19872 if (isString(value)) {
19873 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
19874 .replace(/'/g, "\\'")
19875 .replace(/\\"/g, '"') + '\'';
19876 return ctx.stylize(simple, 'string');
19877 }
19878 if (isNumber(value))
19879 return ctx.stylize('' + value, 'number');
19880 if (isBoolean(value))
19881 return ctx.stylize('' + value, 'boolean');
19882 // For some reason typeof null is "object", so special case here.
19883 if (isNull(value))
19884 return ctx.stylize('null', 'null');
19885 }
19886
19887
19888 function formatError(value) {
19889 return '[' + Error.prototype.toString.call(value) + ']';
19890 }
19891
19892
19893 function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
19894 var output = [];
19895 for (var i = 0, l = value.length; i < l; ++i) {
19896 if (hasOwnProperty(value, String(i))) {
19897 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
19898 String(i), true));
19899 } else {
19900 output.push('');
19901 }
19902 }
19903 keys.forEach(function(key) {
19904 if (!key.match(/^\d+$/)) {
19905 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
19906 key, true));
19907 }
19908 });
19909 return output;
19910 }
19911
19912
19913 function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
19914 var name, str, desc;
19915 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
19916 if (desc.get) {
19917 if (desc.set) {
19918 str = ctx.stylize('[Getter/Setter]', 'special');
19919 } else {
19920 str = ctx.stylize('[Getter]', 'special');
19921 }
19922 } else {
19923 if (desc.set) {
19924 str = ctx.stylize('[Setter]', 'special');
19925 }
19926 }
19927 if (!hasOwnProperty(visibleKeys, key)) {
19928 name = '[' + key + ']';
19929 }
19930 if (!str) {
19931 if (ctx.seen.indexOf(desc.value) < 0) {
19932 if (isNull(recurseTimes)) {
19933 str = formatValue(ctx, desc.value, null);
19934 } else {
19935 str = formatValue(ctx, desc.value, recurseTimes - 1);
19936 }
19937 if (str.indexOf('\n') > -1) {
19938 if (array) {
19939 str = str.split('\n').map(function(line) {
19940 return ' ' + line;
19941 }).join('\n').substr(2);
19942 } else {
19943 str = '\n' + str.split('\n').map(function(line) {
19944 return ' ' + line;
19945 }).join('\n');
19946 }
19947 }
19948 } else {
19949 str = ctx.stylize('[Circular]', 'special');
19950 }
19951 }
19952 if (isUndefined(name)) {
19953 if (array && key.match(/^\d+$/)) {
19954 return str;
19955 }
19956 name = JSON.stringify('' + key);
19957 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
19958 name = name.substr(1, name.length - 2);
19959 name = ctx.stylize(name, 'name');
19960 } else {
19961 name = name.replace(/'/g, "\\'")
19962 .replace(/\\"/g, '"')
19963 .replace(/(^"|"$)/g, "'");
19964 name = ctx.stylize(name, 'string');
19965 }
19966 }
19967
19968 return name + ': ' + str;
19969 }
19970
19971
19972 function reduceToSingleString(output, base, braces) {
19973 var numLinesEst = 0;
19974 var length = output.reduce(function(prev, cur) {
19975 numLinesEst++;
19976 if (cur.indexOf('\n') >= 0) numLinesEst++;
19977 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
19978 }, 0);
19979
19980 if (length > 60) {
19981 return braces[0] +
19982 (base === '' ? '' : base + '\n ') +
19983 ' ' +
19984 output.join(',\n ') +
19985 ' ' +
19986 braces[1];
19987 }
19988
19989 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
19990 }
19991
19992
19993 // NOTE: These type checking functions intentionally don't use `instanceof`
19994 // because it is fragile and can be easily faked with `Object.create()`.
19995 function isArray(ar) {
19996 return Array.isArray(ar);
19997 }
19998 exports.isArray = isArray;
19999
20000 function isBoolean(arg) {
20001 return typeof arg === 'boolean';
20002 }
20003 exports.isBoolean = isBoolean;
20004
20005 function isNull(arg) {
20006 return arg === null;
20007 }
20008 exports.isNull = isNull;
20009
20010 function isNullOrUndefined(arg) {
20011 return arg == null;
20012 }
20013 exports.isNullOrUndefined = isNullOrUndefined;
20014
20015 function isNumber(arg) {
20016 return typeof arg === 'number';
20017 }
20018 exports.isNumber = isNumber;
20019
20020 function isString(arg) {
20021 return typeof arg === 'string';
20022 }
20023 exports.isString = isString;
20024
20025 function isSymbol(arg) {
20026 return typeof arg === 'symbol';
20027 }
20028 exports.isSymbol = isSymbol;
20029
20030 function isUndefined(arg) {
20031 return arg === void 0;
20032 }
20033 exports.isUndefined = isUndefined;
20034
20035 function isRegExp(re) {
20036 return isObject(re) && objectToString(re) === '[object RegExp]';
20037 }
20038 exports.isRegExp = isRegExp;
20039
20040 function isObject(arg) {
20041 return typeof arg === 'object' && arg !== null;
20042 }
20043 exports.isObject = isObject;
20044
20045 function isDate(d) {
20046 return isObject(d) && objectToString(d) === '[object Date]';
20047 }
20048 exports.isDate = isDate;
20049
20050 function isError(e) {
20051 return isObject(e) &&
20052 (objectToString(e) === '[object Error]' || e instanceof Error);
20053 }
20054 exports.isError = isError;
20055
20056 function isFunction(arg) {
20057 return typeof arg === 'function';
20058 }
20059 exports.isFunction = isFunction;
20060
20061 function isPrimitive(arg) {
20062 return arg === null ||
20063 typeof arg === 'boolean' ||
20064 typeof arg === 'number' ||
20065 typeof arg === 'string' ||
20066 typeof arg === 'symbol' || // ES6 symbol
20067 typeof arg === 'undefined';
20068 }
20069 exports.isPrimitive = isPrimitive;
20070
20071 exports.isBuffer = _dereq_('./support/isBuffer');
20072
20073 function objectToString(o) {
20074 return Object.prototype.toString.call(o);
20075 }
20076
20077
20078 function pad(n) {
20079 return n < 10 ? '0' + n.toString(10) : n.toString(10);
20080 }
20081
20082
20083 var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
20084 'Oct', 'Nov', 'Dec'];
20085
20086 // 26 Feb 16:19:34
20087 function timestamp() {
20088 var d = new Date();
20089 var time = [pad(d.getHours()),
20090 pad(d.getMinutes()),
20091 pad(d.getSeconds())].join(':');
20092 return [d.getDate(), months[d.getMonth()], time].join(' ');
20093 }
20094
20095
20096 // log is just a thin wrapper to console.log that prepends a timestamp
20097 exports.log = function() {
20098 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
20099 };
20100
20101
20102 /**
20103 * Inherit the prototype methods from one constructor into another.
20104 *
20105 * The Function.prototype.inherits from lang.js rewritten as a standalone
20106 * function (not on Function.prototype). NOTE: If this file is to be loaded
20107 * during bootstrapping this function needs to be rewritten using some native
20108 * functions as prototype setup using normal JavaScript does not work as
20109 * expected during bootstrapping (see mirror.js in r114903).
20110 *
20111 * @param {function} ctor Constructor function which needs to inherit the
20112 * prototype.
20113 * @param {function} superCtor Constructor function to inherit prototype from.
20114 */
20115 exports.inherits = _dereq_('inherits');
20116
20117 exports._extend = function(origin, add) {
20118 // Don't do anything if add isn't an object
20119 if (!add || !isObject(add)) return origin;
20120
20121 var keys = Object.keys(add);
20122 var i = keys.length;
20123 while (i--) {
20124 origin[keys[i]] = add[keys[i]];
20125 }
20126 return origin;
20127 };
20128
20129 function hasOwnProperty(obj, prop) {
20130 return Object.prototype.hasOwnProperty.call(obj, prop);
20131 }
20132
20133 }).call(this,_dereq_("FWaASH"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
20134 },{"./support/isBuffer":5,"FWaASH":12,"inherits":11}],7:[function(_dereq_,module,exports){
20135
20136 },{}],8:[function(_dereq_,module,exports){
20137 /*!
20138 * The buffer module from node.js, for the browser.
20139 *
20140 * at author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
20141 * at license MIT
20142 */
20143
20144 var base64 = _dereq_('base64-js')
20145 var ieee754 = _dereq_('ieee754')
20146
20147 exports.Buffer = Buffer
20148 exports.SlowBuffer = Buffer
20149 exports.INSPECT_MAX_BYTES = 50
20150 Buffer.poolSize = 8192
20151
20152 /**
20153 * If `Buffer._useTypedArrays`:
20154 * === true Use Uint8Array implementation (fastest)
20155 * === false Use Object implementation (compatible down to IE6)
20156 */
20157 Buffer._useTypedArrays = (function () {
20158 // Detect if browser supports Typed Arrays. Supported browsers are IE 10+, Firefox 4+,
20159 // Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+. If the browser does not support adding
20160 // properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support
20161 // because we need to be able to add all the node Buffer API methods. This is an issue
20162 // in Firefox 4-29. Now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=695438
20163 try {
20164 var buf = new ArrayBuffer(0)
20165 var arr = new Uint8Array(buf)
20166 arr.foo = function () { return 42 }
20167 return 42 === arr.foo() &&
20168 typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray`
20169 } catch (e) {
20170 return false
20171 }
20172 })()
20173
20174 /**
20175 * Class: Buffer
20176 * =============
20177 *
20178 * The Buffer constructor returns instances of `Uint8Array` that are augmented
20179 * with function properties for all the node `Buffer` API functions. We use
20180 * `Uint8Array` so that square bracket notation works as expected -- it returns
20181 * a single octet.
20182 *
20183 * By augmenting the instances, we can avoid modifying the `Uint8Array`
20184 * prototype.
20185 */
20186 function Buffer (subject, encoding, noZero) {
20187 if (!(this instanceof Buffer))
20188 return new Buffer(subject, encoding, noZero)
20189
20190 var type = typeof subject
20191
20192 if (encoding === 'base64' && type === 'string') {
20193 subject = base64clean(subject)
20194 }
20195
20196 // Find the length
20197 var length
20198 if (type === 'number')
20199 length = coerce(subject)
20200 else if (type === 'string')
20201 length = Buffer.byteLength(subject, encoding)
20202 else if (type === 'object')
20203 length = coerce(subject.length) // assume that object is array-like
20204 else
20205 throw new Error('First argument needs to be a number, array or string.')
20206
20207 var buf
20208 if (Buffer._useTypedArrays) {
20209 // Preferred: Return an augmented `Uint8Array` instance for best performance
20210 buf = Buffer._augment(new Uint8Array(length))
20211 } else {
20212 // Fallback: Return THIS instance of Buffer (created by `new`)
20213 buf = this
20214 buf.length = length
20215 buf._isBuffer = true
20216 }
20217
20218 var i
20219 if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') {
20220 // Speed optimization -- use set if we're copying from a typed array
20221 buf._set(subject)
20222 } else if (isArrayish(subject)) {
20223 // Treat array-ish objects as a byte array
20224 if (Buffer.isBuffer(subject)) {
20225 for (i = 0; i < length; i++)
20226 buf[i] = subject.readUInt8(i)
20227 } else {
20228 for (i = 0; i < length; i++)
20229 buf[i] = ((subject[i] % 256) + 256) % 256
20230 }
20231 } else if (type === 'string') {
20232 buf.write(subject, 0, encoding)
20233 } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
20234 for (i = 0; i < length; i++) {
20235 buf[i] = 0
20236 }
20237 }
20238
20239 return buf
20240 }
20241
20242 // STATIC METHODS
20243 // ==============
20244
20245 Buffer.isEncoding = function (encoding) {
20246 switch (String(encoding).toLowerCase()) {
20247 case 'hex':
20248 case 'utf8':
20249 case 'utf-8':
20250 case 'ascii':
20251 case 'binary':
20252 case 'base64':
20253 case 'raw':
20254 case 'ucs2':
20255 case 'ucs-2':
20256 case 'utf16le':
20257 case 'utf-16le':
20258 return true
20259 default:
20260 return false
20261 }
20262 }
20263
20264 Buffer.isBuffer = function (b) {
20265 return !!(b !== null && b !== undefined && b._isBuffer)
20266 }
20267
20268 Buffer.byteLength = function (str, encoding) {
20269 var ret
20270 str = str.toString()
20271 switch (encoding || 'utf8') {
20272 case 'hex':
20273 ret = str.length / 2
20274 break
20275 case 'utf8':
20276 case 'utf-8':
20277 ret = utf8ToBytes(str).length
20278 break
20279 case 'ascii':
20280 case 'binary':
20281 case 'raw':
20282 ret = str.length
20283 break
20284 case 'base64':
20285 ret = base64ToBytes(str).length
20286 break
20287 case 'ucs2':
20288 case 'ucs-2':
20289 case 'utf16le':
20290 case 'utf-16le':
20291 ret = str.length * 2
20292 break
20293 default:
20294 throw new Error('Unknown encoding')
20295 }
20296 return ret
20297 }
20298
20299 Buffer.concat = function (list, totalLength) {
20300 assert(isArray(list), 'Usage: Buffer.concat(list[, length])')
20301
20302 if (list.length === 0) {
20303 return new Buffer(0)
20304 } else if (list.length === 1) {
20305 return list[0]
20306 }
20307
20308 var i
20309 if (totalLength === undefined) {
20310 totalLength = 0
20311 for (i = 0; i < list.length; i++) {
20312 totalLength += list[i].length
20313 }
20314 }
20315
20316 var buf = new Buffer(totalLength)
20317 var pos = 0
20318 for (i = 0; i < list.length; i++) {
20319 var item = list[i]
20320 item.copy(buf, pos)
20321 pos += item.length
20322 }
20323 return buf
20324 }
20325
20326 Buffer.compare = function (a, b) {
20327 assert(Buffer.isBuffer(a) && Buffer.isBuffer(b), 'Arguments must be Buffers')
20328 var x = a.length
20329 var y = b.length
20330 for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
20331 if (i !== len) {
20332 x = a[i]
20333 y = b[i]
20334 }
20335 if (x < y) {
20336 return -1
20337 }
20338 if (y < x) {
20339 return 1
20340 }
20341 return 0
20342 }
20343
20344 // BUFFER INSTANCE METHODS
20345 // =======================
20346
20347 function hexWrite (buf, string, offset, length) {
20348 offset = Number(offset) || 0
20349 var remaining = buf.length - offset
20350 if (!length) {
20351 length = remaining
20352 } else {
20353 length = Number(length)
20354 if (length > remaining) {
20355 length = remaining
20356 }
20357 }
20358
20359 // must be an even number of digits
20360 var strLen = string.length
20361 assert(strLen % 2 === 0, 'Invalid hex string')
20362
20363 if (length > strLen / 2) {
20364 length = strLen / 2
20365 }
20366 for (var i = 0; i < length; i++) {
20367 var byte = parseInt(string.substr(i * 2, 2), 16)
20368 assert(!isNaN(byte), 'Invalid hex string')
20369 buf[offset + i] = byte
20370 }
20371 return i
20372 }
20373
20374 function utf8Write (buf, string, offset, length) {
20375 var charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length)
20376 return charsWritten
20377 }
20378
20379 function asciiWrite (buf, string, offset, length) {
20380 var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length)
20381 return charsWritten
20382 }
20383
20384 function binaryWrite (buf, string, offset, length) {
20385 return asciiWrite(buf, string, offset, length)
20386 }
20387
20388 function base64Write (buf, string, offset, length) {
20389 var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length)
20390 return charsWritten
20391 }
20392
20393 function utf16leWrite (buf, string, offset, length) {
20394 var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length)
20395 return charsWritten
20396 }
20397
20398 Buffer.prototype.write = function (string, offset, length, encoding) {
20399 // Support both (string, offset, length, encoding)
20400 // and the legacy (string, encoding, offset, length)
20401 if (isFinite(offset)) {
20402 if (!isFinite(length)) {
20403 encoding = length
20404 length = undefined
20405 }
20406 } else { // legacy
20407 var swap = encoding
20408 encoding = offset
20409 offset = length
20410 length = swap
20411 }
20412
20413 offset = Number(offset) || 0
20414 var remaining = this.length - offset
20415 if (!length) {
20416 length = remaining
20417 } else {
20418 length = Number(length)
20419 if (length > remaining) {
20420 length = remaining
20421 }
20422 }
20423 encoding = String(encoding || 'utf8').toLowerCase()
20424
20425 var ret
20426 switch (encoding) {
20427 case 'hex':
20428 ret = hexWrite(this, string, offset, length)
20429 break
20430 case 'utf8':
20431 case 'utf-8':
20432 ret = utf8Write(this, string, offset, length)
20433 break
20434 case 'ascii':
20435 ret = asciiWrite(this, string, offset, length)
20436 break
20437 case 'binary':
20438 ret = binaryWrite(this, string, offset, length)
20439 break
20440 case 'base64':
20441 ret = base64Write(this, string, offset, length)
20442 break
20443 case 'ucs2':
20444 case 'ucs-2':
20445 case 'utf16le':
20446 case 'utf-16le':
20447 ret = utf16leWrite(this, string, offset, length)
20448 break
20449 default:
20450 throw new Error('Unknown encoding')
20451 }
20452 return ret
20453 }
20454
20455 Buffer.prototype.toString = function (encoding, start, end) {
20456 var self = this
20457
20458 encoding = String(encoding || 'utf8').toLowerCase()
20459 start = Number(start) || 0
20460 end = (end === undefined) ? self.length : Number(end)
20461
20462 // Fastpath empty strings
20463 if (end === start)
20464 return ''
20465
20466 var ret
20467 switch (encoding) {
20468 case 'hex':
20469 ret = hexSlice(self, start, end)
20470 break
20471 case 'utf8':
20472 case 'utf-8':
20473 ret = utf8Slice(self, start, end)
20474 break
20475 case 'ascii':
20476 ret = asciiSlice(self, start, end)
20477 break
20478 case 'binary':
20479 ret = binarySlice(self, start, end)
20480 break
20481 case 'base64':
20482 ret = base64Slice(self, start, end)
20483 break
20484 case 'ucs2':
20485 case 'ucs-2':
20486 case 'utf16le':
20487 case 'utf-16le':
20488 ret = utf16leSlice(self, start, end)
20489 break
20490 default:
20491 throw new Error('Unknown encoding')
20492 }
20493 return ret
20494 }
20495
20496 Buffer.prototype.toJSON = function () {
20497 return {
20498 type: 'Buffer',
20499 data: Array.prototype.slice.call(this._arr || this, 0)
20500 }
20501 }
20502
20503 Buffer.prototype.equals = function (b) {
20504 assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
20505 return Buffer.compare(this, b) === 0
20506 }
20507
20508 Buffer.prototype.compare = function (b) {
20509 assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
20510 return Buffer.compare(this, b)
20511 }
20512
20513 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
20514 Buffer.prototype.copy = function (target, target_start, start, end) {
20515 var source = this
20516
20517 if (!start) start = 0
20518 if (!end && end !== 0) end = this.length
20519 if (!target_start) target_start = 0
20520
20521 // Copy 0 bytes; we're done
20522 if (end === start) return
20523 if (target.length === 0 || source.length === 0) return
20524
20525 // Fatal error conditions
20526 assert(end >= start, 'sourceEnd < sourceStart')
20527 assert(target_start >= 0 && target_start < target.length,
20528 'targetStart out of bounds')
20529 assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
20530 assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
20531
20532 // Are we oob?
20533 if (end > this.length)
20534 end = this.length
20535 if (target.length - target_start < end - start)
20536 end = target.length - target_start + start
20537
20538 var len = end - start
20539
20540 if (len < 100 || !Buffer._useTypedArrays) {
20541 for (var i = 0; i < len; i++) {
20542 target[i + target_start] = this[i + start]
20543 }
20544 } else {
20545 target._set(this.subarray(start, start + len), target_start)
20546 }
20547 }
20548
20549 function base64Slice (buf, start, end) {
20550 if (start === 0 && end === buf.length) {
20551 return base64.fromByteArray(buf)
20552 } else {
20553 return base64.fromByteArray(buf.slice(start, end))
20554 }
20555 }
20556
20557 function utf8Slice (buf, start, end) {
20558 var res = ''
20559 var tmp = ''
20560 end = Math.min(buf.length, end)
20561
20562 for (var i = start; i < end; i++) {
20563 if (buf[i] <= 0x7F) {
20564 res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
20565 tmp = ''
20566 } else {
20567 tmp += '%' + buf[i].toString(16)
20568 }
20569 }
20570
20571 return res + decodeUtf8Char(tmp)
20572 }
20573
20574 function asciiSlice (buf, start, end) {
20575 var ret = ''
20576 end = Math.min(buf.length, end)
20577
20578 for (var i = start; i < end; i++) {
20579 ret += String.fromCharCode(buf[i])
20580 }
20581 return ret
20582 }
20583
20584 function binarySlice (buf, start, end) {
20585 return asciiSlice(buf, start, end)
20586 }
20587
20588 function hexSlice (buf, start, end) {
20589 var len = buf.length
20590
20591 if (!start || start < 0) start = 0
20592 if (!end || end < 0 || end > len) end = len
20593
20594 var out = ''
20595 for (var i = start; i < end; i++) {
20596 out += toHex(buf[i])
20597 }
20598 return out
20599 }
20600
20601 function utf16leSlice (buf, start, end) {
20602 var bytes = buf.slice(start, end)
20603 var res = ''
20604 for (var i = 0; i < bytes.length; i += 2) {
20605 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
20606 }
20607 return res
20608 }
20609
20610 Buffer.prototype.slice = function (start, end) {
20611 var len = this.length
20612 start = clamp(start, len, 0)
20613 end = clamp(end, len, len)
20614
20615 if (Buffer._useTypedArrays) {
20616 return Buffer._augment(this.subarray(start, end))
20617 } else {
20618 var sliceLen = end - start
20619 var newBuf = new Buffer(sliceLen, undefined, true)
20620 for (var i = 0; i < sliceLen; i++) {
20621 newBuf[i] = this[i + start]
20622 }
20623 return newBuf
20624 }
20625 }
20626
20627 // `get` will be removed in Node 0.13+
20628 Buffer.prototype.get = function (offset) {
20629 console.log('.get() is deprecated. Access using array indexes instead.')
20630 return this.readUInt8(offset)
20631 }
20632
20633 // `set` will be removed in Node 0.13+
20634 Buffer.prototype.set = function (v, offset) {
20635 console.log('.set() is deprecated. Access using array indexes instead.')
20636 return this.writeUInt8(v, offset)
20637 }
20638
20639 Buffer.prototype.readUInt8 = function (offset, noAssert) {
20640 if (!noAssert) {
20641 assert(offset !== undefined && offset !== null, 'missing offset')
20642 assert(offset < this.length, 'Trying to read beyond buffer length')
20643 }
20644
20645 if (offset >= this.length)
20646 return
20647
20648 return this[offset]
20649 }
20650
20651 function readUInt16 (buf, offset, littleEndian, noAssert) {
20652 if (!noAssert) {
20653 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20654 assert(offset !== undefined && offset !== null, 'missing offset')
20655 assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
20656 }
20657
20658 var len = buf.length
20659 if (offset >= len)
20660 return
20661
20662 var val
20663 if (littleEndian) {
20664 val = buf[offset]
20665 if (offset + 1 < len)
20666 val |= buf[offset + 1] << 8
20667 } else {
20668 val = buf[offset] << 8
20669 if (offset + 1 < len)
20670 val |= buf[offset + 1]
20671 }
20672 return val
20673 }
20674
20675 Buffer.prototype.readUInt16LE = function (offset, noAssert) {
20676 return readUInt16(this, offset, true, noAssert)
20677 }
20678
20679 Buffer.prototype.readUInt16BE = function (offset, noAssert) {
20680 return readUInt16(this, offset, false, noAssert)
20681 }
20682
20683 function readUInt32 (buf, offset, littleEndian, noAssert) {
20684 if (!noAssert) {
20685 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20686 assert(offset !== undefined && offset !== null, 'missing offset')
20687 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20688 }
20689
20690 var len = buf.length
20691 if (offset >= len)
20692 return
20693
20694 var val
20695 if (littleEndian) {
20696 if (offset + 2 < len)
20697 val = buf[offset + 2] << 16
20698 if (offset + 1 < len)
20699 val |= buf[offset + 1] << 8
20700 val |= buf[offset]
20701 if (offset + 3 < len)
20702 val = val + (buf[offset + 3] << 24 >>> 0)
20703 } else {
20704 if (offset + 1 < len)
20705 val = buf[offset + 1] << 16
20706 if (offset + 2 < len)
20707 val |= buf[offset + 2] << 8
20708 if (offset + 3 < len)
20709 val |= buf[offset + 3]
20710 val = val + (buf[offset] << 24 >>> 0)
20711 }
20712 return val
20713 }
20714
20715 Buffer.prototype.readUInt32LE = function (offset, noAssert) {
20716 return readUInt32(this, offset, true, noAssert)
20717 }
20718
20719 Buffer.prototype.readUInt32BE = function (offset, noAssert) {
20720 return readUInt32(this, offset, false, noAssert)
20721 }
20722
20723 Buffer.prototype.readInt8 = function (offset, noAssert) {
20724 if (!noAssert) {
20725 assert(offset !== undefined && offset !== null,
20726 'missing offset')
20727 assert(offset < this.length, 'Trying to read beyond buffer length')
20728 }
20729
20730 if (offset >= this.length)
20731 return
20732
20733 var neg = this[offset] & 0x80
20734 if (neg)
20735 return (0xff - this[offset] + 1) * -1
20736 else
20737 return this[offset]
20738 }
20739
20740 function readInt16 (buf, offset, littleEndian, noAssert) {
20741 if (!noAssert) {
20742 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20743 assert(offset !== undefined && offset !== null, 'missing offset')
20744 assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
20745 }
20746
20747 var len = buf.length
20748 if (offset >= len)
20749 return
20750
20751 var val = readUInt16(buf, offset, littleEndian, true)
20752 var neg = val & 0x8000
20753 if (neg)
20754 return (0xffff - val + 1) * -1
20755 else
20756 return val
20757 }
20758
20759 Buffer.prototype.readInt16LE = function (offset, noAssert) {
20760 return readInt16(this, offset, true, noAssert)
20761 }
20762
20763 Buffer.prototype.readInt16BE = function (offset, noAssert) {
20764 return readInt16(this, offset, false, noAssert)
20765 }
20766
20767 function readInt32 (buf, offset, littleEndian, noAssert) {
20768 if (!noAssert) {
20769 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20770 assert(offset !== undefined && offset !== null, 'missing offset')
20771 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20772 }
20773
20774 var len = buf.length
20775 if (offset >= len)
20776 return
20777
20778 var val = readUInt32(buf, offset, littleEndian, true)
20779 var neg = val & 0x80000000
20780 if (neg)
20781 return (0xffffffff - val + 1) * -1
20782 else
20783 return val
20784 }
20785
20786 Buffer.prototype.readInt32LE = function (offset, noAssert) {
20787 return readInt32(this, offset, true, noAssert)
20788 }
20789
20790 Buffer.prototype.readInt32BE = function (offset, noAssert) {
20791 return readInt32(this, offset, false, noAssert)
20792 }
20793
20794 function readFloat (buf, offset, littleEndian, noAssert) {
20795 if (!noAssert) {
20796 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20797 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20798 }
20799
20800 return ieee754.read(buf, offset, littleEndian, 23, 4)
20801 }
20802
20803 Buffer.prototype.readFloatLE = function (offset, noAssert) {
20804 return readFloat(this, offset, true, noAssert)
20805 }
20806
20807 Buffer.prototype.readFloatBE = function (offset, noAssert) {
20808 return readFloat(this, offset, false, noAssert)
20809 }
20810
20811 function readDouble (buf, offset, littleEndian, noAssert) {
20812 if (!noAssert) {
20813 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20814 assert(offset + 7 < buf.length, 'Trying to read beyond buffer length')
20815 }
20816
20817 return ieee754.read(buf, offset, littleEndian, 52, 8)
20818 }
20819
20820 Buffer.prototype.readDoubleLE = function (offset, noAssert) {
20821 return readDouble(this, offset, true, noAssert)
20822 }
20823
20824 Buffer.prototype.readDoubleBE = function (offset, noAssert) {
20825 return readDouble(this, offset, false, noAssert)
20826 }
20827
20828 Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
20829 if (!noAssert) {
20830 assert(value !== undefined && value !== null, 'missing value')
20831 assert(offset !== undefined && offset !== null, 'missing offset')
20832 assert(offset < this.length, 'trying to write beyond buffer length')
20833 verifuint(value, 0xff)
20834 }
20835
20836 if (offset >= this.length) return
20837
20838 this[offset] = value
20839 return offset + 1
20840 }
20841
20842 function writeUInt16 (buf, value, offset, littleEndian, noAssert) {
20843 if (!noAssert) {
20844 assert(value !== undefined && value !== null, 'missing value')
20845 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20846 assert(offset !== undefined && offset !== null, 'missing offset')
20847 assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
20848 verifuint(value, 0xffff)
20849 }
20850
20851 var len = buf.length
20852 if (offset >= len)
20853 return
20854
20855 for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) {
20856 buf[offset + i] =
20857 (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
20858 (littleEndian ? i : 1 - i) * 8
20859 }
20860 return offset + 2
20861 }
20862
20863 Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
20864 return writeUInt16(this, value, offset, true, noAssert)
20865 }
20866
20867 Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
20868 return writeUInt16(this, value, offset, false, noAssert)
20869 }
20870
20871 function writeUInt32 (buf, value, offset, littleEndian, noAssert) {
20872 if (!noAssert) {
20873 assert(value !== undefined && value !== null, 'missing value')
20874 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20875 assert(offset !== undefined && offset !== null, 'missing offset')
20876 assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
20877 verifuint(value, 0xffffffff)
20878 }
20879
20880 var len = buf.length
20881 if (offset >= len)
20882 return
20883
20884 for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) {
20885 buf[offset + i] =
20886 (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
20887 }
20888 return offset + 4
20889 }
20890
20891 Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
20892 return writeUInt32(this, value, offset, true, noAssert)
20893 }
20894
20895 Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
20896 return writeUInt32(this, value, offset, false, noAssert)
20897 }
20898
20899 Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
20900 if (!noAssert) {
20901 assert(value !== undefined && value !== null, 'missing value')
20902 assert(offset !== undefined && offset !== null, 'missing offset')
20903 assert(offset < this.length, 'Trying to write beyond buffer length')
20904 verifsint(value, 0x7f, -0x80)
20905 }
20906
20907 if (offset >= this.length)
20908 return
20909
20910 if (value >= 0)
20911 this.writeUInt8(value, offset, noAssert)
20912 else
20913 this.writeUInt8(0xff + value + 1, offset, noAssert)
20914 return offset + 1
20915 }
20916
20917 function writeInt16 (buf, value, offset, littleEndian, noAssert) {
20918 if (!noAssert) {
20919 assert(value !== undefined && value !== null, 'missing value')
20920 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20921 assert(offset !== undefined && offset !== null, 'missing offset')
20922 assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
20923 verifsint(value, 0x7fff, -0x8000)
20924 }
20925
20926 var len = buf.length
20927 if (offset >= len)
20928 return
20929
20930 if (value >= 0)
20931 writeUInt16(buf, value, offset, littleEndian, noAssert)
20932 else
20933 writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
20934 return offset + 2
20935 }
20936
20937 Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
20938 return writeInt16(this, value, offset, true, noAssert)
20939 }
20940
20941 Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
20942 return writeInt16(this, value, offset, false, noAssert)
20943 }
20944
20945 function writeInt32 (buf, value, offset, littleEndian, noAssert) {
20946 if (!noAssert) {
20947 assert(value !== undefined && value !== null, 'missing value')
20948 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20949 assert(offset !== undefined && offset !== null, 'missing offset')
20950 assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
20951 verifsint(value, 0x7fffffff, -0x80000000)
20952 }
20953
20954 var len = buf.length
20955 if (offset >= len)
20956 return
20957
20958 if (value >= 0)
20959 writeUInt32(buf, value, offset, littleEndian, noAssert)
20960 else
20961 writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert)
20962 return offset + 4
20963 }
20964
20965 Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
20966 return writeInt32(this, value, offset, true, noAssert)
20967 }
20968
20969 Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
20970 return writeInt32(this, value, offset, false, noAssert)
20971 }
20972
20973 function writeFloat (buf, value, offset, littleEndian, noAssert) {
20974 if (!noAssert) {
20975 assert(value !== undefined && value !== null, 'missing value')
20976 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20977 assert(offset !== undefined && offset !== null, 'missing offset')
20978 assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
20979 verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
20980 }
20981
20982 var len = buf.length
20983 if (offset >= len)
20984 return
20985
20986 ieee754.write(buf, value, offset, littleEndian, 23, 4)
20987 return offset + 4
20988 }
20989
20990 Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
20991 return writeFloat(this, value, offset, true, noAssert)
20992 }
20993
20994 Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
20995 return writeFloat(this, value, offset, false, noAssert)
20996 }
20997
20998 function writeDouble (buf, value, offset, littleEndian, noAssert) {
20999 if (!noAssert) {
21000 assert(value !== undefined && value !== null, 'missing value')
21001 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
21002 assert(offset !== undefined && offset !== null, 'missing offset')
21003 assert(offset + 7 < buf.length,
21004 'Trying to write beyond buffer length')
21005 verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308)
21006 }
21007
21008 var len = buf.length
21009 if (offset >= len)
21010 return
21011
21012 ieee754.write(buf, value, offset, littleEndian, 52, 8)
21013 return offset + 8
21014 }
21015
21016 Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
21017 return writeDouble(this, value, offset, true, noAssert)
21018 }
21019
21020 Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
21021 return writeDouble(this, value, offset, false, noAssert)
21022 }
21023
21024 // fill(value, start=0, end=buffer.length)
21025 Buffer.prototype.fill = function (value, start, end) {
21026 if (!value) value = 0
21027 if (!start) start = 0
21028 if (!end) end = this.length
21029
21030 assert(end >= start, 'end < start')
21031
21032 // Fill 0 bytes; we're done
21033 if (end === start) return
21034 if (this.length === 0) return
21035
21036 assert(start >= 0 && start < this.length, 'start out of bounds')
21037 assert(end >= 0 && end <= this.length, 'end out of bounds')
21038
21039 var i
21040 if (typeof value === 'number') {
21041 for (i = start; i < end; i++) {
21042 this[i] = value
21043 }
21044 } else {
21045 var bytes = utf8ToBytes(value.toString())
21046 var len = bytes.length
21047 for (i = start; i < end; i++) {
21048 this[i] = bytes[i % len]
21049 }
21050 }
21051
21052 return this
21053 }
21054
21055 Buffer.prototype.inspect = function () {
21056 var out = []
21057 var len = this.length
21058 for (var i = 0; i < len; i++) {
21059 out[i] = toHex(this[i])
21060 if (i === exports.INSPECT_MAX_BYTES) {
21061 out[i + 1] = '...'
21062 break
21063 }
21064 }
21065 return '<Buffer ' + out.join(' ') + '>'
21066 }
21067
21068 /**
21069 * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
21070 * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
21071 */
21072 Buffer.prototype.toArrayBuffer = function () {
21073 if (typeof Uint8Array !== 'undefined') {
21074 if (Buffer._useTypedArrays) {
21075 return (new Buffer(this)).buffer
21076 } else {
21077 var buf = new Uint8Array(this.length)
21078 for (var i = 0, len = buf.length; i < len; i += 1) {
21079 buf[i] = this[i]
21080 }
21081 return buf.buffer
21082 }
21083 } else {
21084 throw new Error('Buffer.toArrayBuffer not supported in this browser')
21085 }
21086 }
21087
21088 // HELPER FUNCTIONS
21089 // ================
21090
21091 var BP = Buffer.prototype
21092
21093 /**
21094 * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
21095 */
21096 Buffer._augment = function (arr) {
21097 arr._isBuffer = true
21098
21099 // save reference to original Uint8Array get/set methods before overwriting
21100 arr._get = arr.get
21101 arr._set = arr.set
21102
21103 // deprecated, will be removed in node 0.13+
21104 arr.get = BP.get
21105 arr.set = BP.set
21106
21107 arr.write = BP.write
21108 arr.toString = BP.toString
21109 arr.toLocaleString = BP.toString
21110 arr.toJSON = BP.toJSON
21111 arr.equals = BP.equals
21112 arr.compare = BP.compare
21113 arr.copy = BP.copy
21114 arr.slice = BP.slice
21115 arr.readUInt8 = BP.readUInt8
21116 arr.readUInt16LE = BP.readUInt16LE
21117 arr.readUInt16BE = BP.readUInt16BE
21118 arr.readUInt32LE = BP.readUInt32LE
21119 arr.readUInt32BE = BP.readUInt32BE
21120 arr.readInt8 = BP.readInt8
21121 arr.readInt16LE = BP.readInt16LE
21122 arr.readInt16BE = BP.readInt16BE
21123 arr.readInt32LE = BP.readInt32LE
21124 arr.readInt32BE = BP.readInt32BE
21125 arr.readFloatLE = BP.readFloatLE
21126 arr.readFloatBE = BP.readFloatBE
21127 arr.readDoubleLE = BP.readDoubleLE
21128 arr.readDoubleBE = BP.readDoubleBE
21129 arr.writeUInt8 = BP.writeUInt8
21130 arr.writeUInt16LE = BP.writeUInt16LE
21131 arr.writeUInt16BE = BP.writeUInt16BE
21132 arr.writeUInt32LE = BP.writeUInt32LE
21133 arr.writeUInt32BE = BP.writeUInt32BE
21134 arr.writeInt8 = BP.writeInt8
21135 arr.writeInt16LE = BP.writeInt16LE
21136 arr.writeInt16BE = BP.writeInt16BE
21137 arr.writeInt32LE = BP.writeInt32LE
21138 arr.writeInt32BE = BP.writeInt32BE
21139 arr.writeFloatLE = BP.writeFloatLE
21140 arr.writeFloatBE = BP.writeFloatBE
21141 arr.writeDoubleLE = BP.writeDoubleLE
21142 arr.writeDoubleBE = BP.writeDoubleBE
21143 arr.fill = BP.fill
21144 arr.inspect = BP.inspect
21145 arr.toArrayBuffer = BP.toArrayBuffer
21146
21147 return arr
21148 }
21149
21150 var INVALID_BASE64_RE = /[^+\/0-9A-z]/g
21151
21152 function base64clean (str) {
21153 // Node strips out invalid characters like \n and \t from the string, base64-js does not
21154 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
21155 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
21156 while (str.length % 4 !== 0) {
21157 str = str + '='
21158 }
21159 return str
21160 }
21161
21162 function stringtrim (str) {
21163 if (str.trim) return str.trim()
21164 return str.replace(/^\s+|\s+$/g, '')
21165 }
21166
21167 // slice(start, end)
21168 function clamp (index, len, defaultValue) {
21169 if (typeof index !== 'number') return defaultValue
21170 index = ~~index; // Coerce to integer.
21171 if (index >= len) return len
21172 if (index >= 0) return index
21173 index += len
21174 if (index >= 0) return index
21175 return 0
21176 }
21177
21178 function coerce (length) {
21179 // Coerce length to a number (possibly NaN), round up
21180 // in case it's fractional (e.g. 123.456) then do a
21181 // double negate to coerce a NaN to 0. Easy, right?
21182 length = ~~Math.ceil(+length)
21183 return length < 0 ? 0 : length
21184 }
21185
21186 function isArray (subject) {
21187 return (Array.isArray || function (subject) {
21188 return Object.prototype.toString.call(subject) === '[object Array]'
21189 })(subject)
21190 }
21191
21192 function isArrayish (subject) {
21193 return isArray(subject) || Buffer.isBuffer(subject) ||
21194 subject && typeof subject === 'object' &&
21195 typeof subject.length === 'number'
21196 }
21197
21198 function toHex (n) {
21199 if (n < 16) return '0' + n.toString(16)
21200 return n.toString(16)
21201 }
21202
21203 function utf8ToBytes (str) {
21204 var byteArray = []
21205 for (var i = 0; i < str.length; i++) {
21206 var b = str.charCodeAt(i)
21207 if (b <= 0x7F) {
21208 byteArray.push(b)
21209 } else {
21210 var start = i
21211 if (b >= 0xD800 && b <= 0xDFFF) i++
21212 var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%')
21213 for (var j = 0; j < h.length; j++) {
21214 byteArray.push(parseInt(h[j], 16))
21215 }
21216 }
21217 }
21218 return byteArray
21219 }
21220
21221 function asciiToBytes (str) {
21222 var byteArray = []
21223 for (var i = 0; i < str.length; i++) {
21224 // Node's code seems to be doing this and not & 0x7F..
21225 byteArray.push(str.charCodeAt(i) & 0xFF)
21226 }
21227 return byteArray
21228 }
21229
21230 function utf16leToBytes (str) {
21231 var c, hi, lo
21232 var byteArray = []
21233 for (var i = 0; i < str.length; i++) {
21234 c = str.charCodeAt(i)
21235 hi = c >> 8
21236 lo = c % 256
21237 byteArray.push(lo)
21238 byteArray.push(hi)
21239 }
21240
21241 return byteArray
21242 }
21243
21244 function base64ToBytes (str) {
21245 return base64.toByteArray(str)
21246 }
21247
21248 function blitBuffer (src, dst, offset, length) {
21249 for (var i = 0; i < length; i++) {
21250 if ((i + offset >= dst.length) || (i >= src.length))
21251 break
21252 dst[i + offset] = src[i]
21253 }
21254 return i
21255 }
21256
21257 function decodeUtf8Char (str) {
21258 try {
21259 return decodeURIComponent(str)
21260 } catch (err) {
21261 return String.fromCharCode(0xFFFD) // UTF 8 invalid char
21262 }
21263 }
21264
21265 /*
21266 * We have to make sure that the value is a valid integer. This means that it
21267 * is non-negative. It has no fractional component and that it does not
21268 * exceed the maximum allowed value.
21269 */
21270 function verifuint (value, max) {
21271 assert(typeof value === 'number', 'cannot write a non-number as a number')
21272 assert(value >= 0, 'specified a negative value for writing an unsigned value')
21273 assert(value <= max, 'value is larger than maximum value for type')
21274 assert(Math.floor(value) === value, 'value has a fractional component')
21275 }
21276
21277 function verifsint (value, max, min) {
21278 assert(typeof value === 'number', 'cannot write a non-number as a number')
21279 assert(value <= max, 'value larger than maximum allowed value')
21280 assert(value >= min, 'value smaller than minimum allowed value')
21281 assert(Math.floor(value) === value, 'value has a fractional component')
21282 }
21283
21284 function verifIEEE754 (value, max, min) {
21285 assert(typeof value === 'number', 'cannot write a non-number as a number')
21286 assert(value <= max, 'value larger than maximum allowed value')
21287 assert(value >= min, 'value smaller than minimum allowed value')
21288 }
21289
21290 function assert (test, message) {
21291 if (!test) throw new Error(message || 'Failed assertion')
21292 }
21293
21294 },{"base64-js":9,"ieee754":10}],9:[function(_dereq_,module,exports){
21295 var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
21296
21297 ;(function (exports) {
21298 'use strict';
21299
21300 var Arr = (typeof Uint8Array !== 'undefined')
21301 ? Uint8Array
21302 : Array
21303
21304 var PLUS = '+'.charCodeAt(0)
21305 var SLASH = '/'.charCodeAt(0)
21306 var NUMBER = '0'.charCodeAt(0)
21307 var LOWER = 'a'.charCodeAt(0)
21308 var UPPER = 'A'.charCodeAt(0)
21309
21310 function decode (elt) {
21311 var code = elt.charCodeAt(0)
21312 if (code === PLUS)
21313 return 62 // '+'
21314 if (code === SLASH)
21315 return 63 // '/'
21316 if (code < NUMBER)
21317 return -1 //no match
21318 if (code < NUMBER + 10)
21319 return code - NUMBER + 26 + 26
21320 if (code < UPPER + 26)
21321 return code - UPPER
21322 if (code < LOWER + 26)
21323 return code - LOWER + 26
21324 }
21325
21326 function b64ToByteArray (b64) {
21327 var i, j, l, tmp, placeHolders, arr
21328
21329 if (b64.length % 4 > 0) {
21330 throw new Error('Invalid string. Length must be a multiple of 4')
21331 }
21332
21333 // the number of equal signs (place holders)
21334 // if there are two placeholders, than the two characters before it
21335 // represent one byte
21336 // if there is only one, then the three characters before it represent 2 bytes
21337 // this is just a cheap hack to not do indexOf twice
21338 var len = b64.length
21339 placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
21340
21341 // base64 is 4/3 + up to two characters of the original data
21342 arr = new Arr(b64.length * 3 / 4 - placeHolders)
21343
21344 // if there are placeholders, only get up to the last complete 4 chars
21345 l = placeHolders > 0 ? b64.length - 4 : b64.length
21346
21347 var L = 0
21348
21349 function push (v) {
21350 arr[L++] = v
21351 }
21352
21353 for (i = 0, j = 0; i < l; i += 4, j += 3) {
21354 tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
21355 push((tmp & 0xFF0000) >> 16)
21356 push((tmp & 0xFF00) >> 8)
21357 push(tmp & 0xFF)
21358 }
21359
21360 if (placeHolders === 2) {
21361 tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
21362 push(tmp & 0xFF)
21363 } else if (placeHolders === 1) {
21364 tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
21365 push((tmp >> 8) & 0xFF)
21366 push(tmp & 0xFF)
21367 }
21368
21369 return arr
21370 }
21371
21372 function uint8ToBase64 (uint8) {
21373 var i,
21374 extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
21375 output = "",
21376 temp, length
21377
21378 function encode (num) {
21379 return lookup.charAt(num)
21380 }
21381
21382 function tripletToBase64 (num) {
21383 return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
21384 }
21385
21386 // go through the array every three bytes, we'll deal with trailing stuff later
21387 for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
21388 temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
21389 output += tripletToBase64(temp)
21390 }
21391
21392 // pad the end with zeros, but make sure to not forget the extra bytes
21393 switch (extraBytes) {
21394 case 1:
21395 temp = uint8[uint8.length - 1]
21396 output += encode(temp >> 2)
21397 output += encode((temp << 4) & 0x3F)
21398 output += '=='
21399 break
21400 case 2:
21401 temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
21402 output += encode(temp >> 10)
21403 output += encode((temp >> 4) & 0x3F)
21404 output += encode((temp << 2) & 0x3F)
21405 output += '='
21406 break
21407 }
21408
21409 return output
21410 }
21411
21412 exports.toByteArray = b64ToByteArray
21413 exports.fromByteArray = uint8ToBase64
21414 }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
21415
21416 },{}],10:[function(_dereq_,module,exports){
21417 exports.read = function(buffer, offset, isLE, mLen, nBytes) {
21418 var e, m,
21419 eLen = nBytes * 8 - mLen - 1,
21420 eMax = (1 << eLen) - 1,
21421 eBias = eMax >> 1,
21422 nBits = -7,
21423 i = isLE ? (nBytes - 1) : 0,
21424 d = isLE ? -1 : 1,
21425 s = buffer[offset + i];
21426
21427 i += d;
21428
21429 e = s & ((1 << (-nBits)) - 1);
21430 s >>= (-nBits);
21431 nBits += eLen;
21432 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8){};
21433
21434 m = e & ((1 << (-nBits)) - 1);
21435 e >>= (-nBits);
21436 nBits += mLen;
21437 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8){};
21438
21439 if (e === 0) {
21440 e = 1 - eBias;
21441 } else if (e === eMax) {
21442 return m ? NaN : ((s ? -1 : 1) * Infinity);
21443 } else {
21444 m = m + Math.pow(2, mLen);
21445 e = e - eBias;
21446 }
21447 return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
21448 };
21449
21450 exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
21451 var e, m, c,
21452 eLen = nBytes * 8 - mLen - 1,
21453 eMax = (1 << eLen) - 1,
21454 eBias = eMax >> 1,
21455 rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
21456 i = isLE ? 0 : (nBytes - 1),
21457 d = isLE ? 1 : -1,
21458 s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
21459
21460 value = Math.abs(value);
21461
21462 if (isNaN(value) || value === Infinity) {
21463 m = isNaN(value) ? 1 : 0;
21464 e = eMax;
21465 } else {
21466 e = Math.floor(Math.log(value) / Math.LN2);
21467 if (value * (c = Math.pow(2, -e)) < 1) {
21468 e--;
21469 c *= 2;
21470 }
21471 if (e + eBias >= 1) {
21472 value += rt / c;
21473 } else {
21474 value += rt * Math.pow(2, 1 - eBias);
21475 }
21476 if (value * c >= 2) {
21477 e++;
21478 c /= 2;
21479 }
21480
21481 if (e + eBias >= eMax) {
21482 m = 0;
21483 e = eMax;
21484 } else if (e + eBias >= 1) {
21485 m = (value * c - 1) * Math.pow(2, mLen);
21486 e = e + eBias;
21487 } else {
21488 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
21489 e = 0;
21490 }
21491 }
21492
21493 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8){};
21494
21495 e = (e << mLen) | m;
21496 eLen += mLen;
21497 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8){};
21498
21499 buffer[offset + i - d] |= s * 128;
21500 };
21501
21502 },{}],11:[function(_dereq_,module,exports){
21503 if (typeof Object.create === 'function') {
21504 // implementation from standard node.js 'util' module
21505 module.exports = function inherits(ctor, superCtor) {
21506 ctor.super_ = superCtor
21507 ctor.prototype = Object.create(superCtor.prototype, {
21508 constructor: {
21509 value: ctor,
21510 enumerable: false,
21511 writable: true,
21512 configurable: true
21513 }
21514 });
21515 };
21516 } else {
21517 // old school shim for old browsers
21518 module.exports = function inherits(ctor, superCtor) {
21519 ctor.super_ = superCtor
21520 var TempCtor = function () {}
21521 TempCtor.prototype = superCtor.prototype
21522 ctor.prototype = new TempCtor()
21523 ctor.prototype.constructor = ctor
21524 }
21525 }
21526
21527 },{}],12:[function(_dereq_,module,exports){
21528 // shim for using process in browser
21529
21530 var process = module.exports = {};
21531
21532 process.nextTick = (function () {
21533 var canSetImmediate = typeof window !== 'undefined'
21534 && window.setImmediate;
21535 var canPost = typeof window !== 'undefined'
21536 && window.postMessage && window.addEventListener
21537 ;
21538
21539 if (canSetImmediate) {
21540 return function (f) { return window.setImmediate(f) };
21541 }
21542
21543 if (canPost) {
21544 var queue = [];
21545 window.addEventListener('message', function (ev) {
21546 var source = ev.source;
21547 if ((source === window || source === null) && ev.data === 'process-tick') {
21548 ev.stopPropagation();
21549 if (queue.length > 0) {
21550 var fn = queue.shift();
21551 fn();
21552 }
21553 }
21554 }, true);
21555
21556 return function nextTick(fn) {
21557 queue.push(fn);
21558 window.postMessage('process-tick', '*');
21559 };
21560 }
21561
21562 return function nextTick(fn) {
21563 setTimeout(fn, 0);
21564 };
21565 })();
21566
21567 process.title = 'browser';
21568 process.browser = true;
21569 process.env = {};
21570 process.argv = [];
21571
21572 function noop() {}
21573
21574 process.on = noop;
21575 process.addListener = noop;
21576 process.once = noop;
21577 process.off = noop;
21578 process.removeListener = noop;
21579 process.removeAllListeners = noop;
21580 process.emit = noop;
21581
21582 process.binding = function (name) {
21583 throw new Error('process.binding is not supported');
21584 }
21585
21586 // TODO(shtylman)
21587 process.cwd = function () { return '/' };
21588 process.chdir = function (dir) {
21589 throw new Error('process.chdir is not supported');
21590 };
21591
21592 },{}],13:[function(_dereq_,module,exports){
21593 module.exports=_dereq_(5)
21594 },{}],14:[function(_dereq_,module,exports){
21595 module.exports=_dereq_(6)
21596 },{"./support/isBuffer":13,"FWaASH":12,"inherits":11}],15:[function(_dereq_,module,exports){
21597 (function (Buffer){
21598 // Base58 encoding/decoding
21599 // Originally written by Mike Hearn for BitcoinJ
21600 // Copyright (c) 2011 Google Inc
21601 // Ported to JavaScript by Stefan Thomas
21602 // Merged Buffer refactorings from base58-native by Stephen Pair
21603 // Copyright (c) 2013 BitPay Inc
21604
21605 var assert = _dereq_('assert')
21606 var BigInteger = _dereq_('bigi')
21607
21608 var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
21609 var ALPHABET_BUF = new Buffer(ALPHABET, 'ascii')
21610 var ALPHABET_MAP = {}
21611 for(var i = 0; i < ALPHABET.length; i++) {
21612 ALPHABET_MAP[ALPHABET.charAt(i)] = BigInteger.valueOf(i)
21613 }
21614 var BASE = new BigInteger('58')
21615
21616 function encode(buffer) {
21617 var bi = BigInteger.fromBuffer(buffer)
21618 var result = new Buffer(buffer.length << 1)
21619
21620 var i = result.length - 1
21621 while (bi.signum() > 0) {
21622 var remainder = bi.mod(BASE)
21623 bi = bi.divide(BASE)
21624
21625 result[i] = ALPHABET_BUF[remainder.intValue()]
21626 i--
21627 }
21628
21629 // deal with leading zeros
21630 var j = 0
21631 while (buffer[j] === 0) {
21632 result[i] = ALPHABET_BUF[0]
21633 j++
21634 i--
21635 }
21636
21637 return result.slice(i + 1, result.length).toString('ascii')
21638 }
21639
21640 function decode(string) {
21641 if (string.length === 0) return new Buffer(0)
21642
21643 var num = BigInteger.ZERO
21644
21645 for (var i = 0; i < string.length; i++) {
21646 num = num.multiply(BASE)
21647
21648 var figure = ALPHABET_MAP[string.charAt(i)]
21649 assert.notEqual(figure, undefined, 'Non-base58 character')
21650
21651 num = num.add(figure)
21652 }
21653
21654 // deal with leading zeros
21655 var j = 0
21656 while ((j < string.length) && (string[j] === ALPHABET[0])) {
21657 j++
21658 }
21659
21660 var buffer = num.toBuffer()
21661 var leadingZeros = new Buffer(j)
21662 leadingZeros.fill(0)
21663
21664 return Buffer.concat([leadingZeros, buffer])
21665 }
21666
21667 module.exports = {
21668 encode: encode,
21669 decode: decode
21670 }
21671
21672 }).call(this,_dereq_("buffer").Buffer)
21673 },{"assert":4,"bigi":3,"buffer":8}],16:[function(_dereq_,module,exports){
21674 (function (Buffer){
21675 var createHash = _dereq_('sha.js')
21676
21677 var md5 = toConstructor(_dereq_('./md5'))
21678 var rmd160 = toConstructor(_dereq_('ripemd160'))
21679
21680 function toConstructor (fn) {
21681 return function () {
21682 var buffers = []
21683 var m= {
21684 update: function (data, enc) {
21685 if(!Buffer.isBuffer(data)) data = new Buffer(data, enc)
21686 buffers.push(data)
21687 return this
21688 },
21689 digest: function (enc) {
21690 var buf = Buffer.concat(buffers)
21691 var r = fn(buf)
21692 buffers = null
21693 return enc ? r.toString(enc) : r
21694 }
21695 }
21696 return m
21697 }
21698 }
21699
21700 module.exports = function (alg) {
21701 if('md5' === alg) return new md5()
21702 if('rmd160' === alg) return new rmd160()
21703 return createHash(alg)
21704 }
21705
21706 }).call(this,_dereq_("buffer").Buffer)
21707 },{"./md5":20,"buffer":8,"ripemd160":21,"sha.js":23}],17:[function(_dereq_,module,exports){
21708 (function (Buffer){
21709 var createHash = _dereq_('./create-hash')
21710
21711 var blocksize = 64
21712 var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(0)
21713
21714 module.exports = Hmac
21715
21716 function Hmac (alg, key) {
21717 if(!(this instanceof Hmac)) return new Hmac(alg, key)
21718 this._opad = opad
21719 this._alg = alg
21720
21721 key = this._key = !Buffer.isBuffer(key) ? new Buffer(key) : key
21722
21723 if(key.length > blocksize) {
21724 key = createHash(alg).update(key).digest()
21725 } else if(key.length < blocksize) {
21726 key = Buffer.concat([key, zeroBuffer], blocksize)
21727 }
21728
21729 var ipad = this._ipad = new Buffer(blocksize)
21730 var opad = this._opad = new Buffer(blocksize)
21731
21732 for(var i = 0; i < blocksize; i++) {
21733 ipad[i] = key[i] ^ 0x36
21734 opad[i] = key[i] ^ 0x5C
21735 }
21736
21737 this._hash = createHash(alg).update(ipad)
21738 }
21739
21740 Hmac.prototype.update = function (data, enc) {
21741 this._hash.update(data, enc)
21742 return this
21743 }
21744
21745 Hmac.prototype.digest = function (enc) {
21746 var h = this._hash.digest()
21747 return createHash(this._alg).update(this._opad).update(h).digest(enc)
21748 }
21749
21750
21751 }).call(this,_dereq_("buffer").Buffer)
21752 },{"./create-hash":16,"buffer":8}],18:[function(_dereq_,module,exports){
21753 (function (Buffer){
21754 var intSize = 4;
21755 var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(0);
21756 var chrsz = 8;
21757
21758 function toArray(buf, bigEndian) {
21759 if ((buf.length % intSize) !== 0) {
21760 var len = buf.length + (intSize - (buf.length % intSize));
21761 buf = Buffer.concat([buf, zeroBuffer], len);
21762 }
21763
21764 var arr = [];
21765 var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
21766 for (var i = 0; i < buf.length; i += intSize) {
21767 arr.push(fn.call(buf, i));
21768 }
21769 return arr;
21770 }
21771
21772 function toBuffer(arr, size, bigEndian) {
21773 var buf = new Buffer(size);
21774 var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
21775 for (var i = 0; i < arr.length; i++) {
21776 fn.call(buf, arr[i], i * 4, true);
21777 }
21778 return buf;
21779 }
21780
21781 function hash(buf, fn, hashSize, bigEndian) {
21782 if (!Buffer.isBuffer(buf)) buf = new Buffer(buf);
21783 var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
21784 return toBuffer(arr, hashSize, bigEndian);
21785 }
21786
21787 module.exports = { hash: hash };
21788
21789 }).call(this,_dereq_("buffer").Buffer)
21790 },{"buffer":8}],19:[function(_dereq_,module,exports){
21791 (function (Buffer){
21792 var rng = _dereq_('./rng')
21793
21794 function error () {
21795 var m = [].slice.call(arguments).join(' ')
21796 throw new Error([
21797 m,
21798 'we accept pull requests',
21799 'http://github.com/dominictarr/crypto-browserify'
21800 ].join('\n'))
21801 }
21802
21803 exports.createHash = _dereq_('./create-hash')
21804
21805 exports.createHmac = _dereq_('./create-hmac')
21806
21807 exports.randomBytes = function(size, callback) {
21808 if (callback && callback.call) {
21809 try {
21810 callback.call(this, undefined, new Buffer(rng(size)))
21811 } catch (err) { callback(err) }
21812 } else {
21813 return new Buffer(rng(size))
21814 }
21815 }
21816
21817 function each(a, f) {
21818 for(var i in a)
21819 f(a[i], i)
21820 }
21821
21822 exports.getHashes = function () {
21823 return ['sha1', 'sha256', 'md5', 'rmd160']
21824
21825 }
21826
21827 var p = _dereq_('./pbkdf2')(exports.createHmac)
21828 exports.pbkdf2 = p.pbkdf2
21829 exports.pbkdf2Sync = p.pbkdf2Sync
21830
21831
21832 // the least I can do is make error messages for the rest of the node.js/crypto api.
21833 each(['createCredentials'
21834 , 'createCipher'
21835 , 'createCipheriv'
21836 , 'createDecipher'
21837 , 'createDecipheriv'
21838 , 'createSign'
21839 , 'createVerify'
21840 , 'createDiffieHellman'
21841 ], function (name) {
21842 exports[name] = function () {
21843 error('sorry,', name, 'is not implemented yet')
21844 }
21845 })
21846
21847 }).call(this,_dereq_("buffer").Buffer)
21848 },{"./create-hash":16,"./create-hmac":17,"./pbkdf2":27,"./rng":28,"buffer":8}],20:[function(_dereq_,module,exports){
21849 /*
21850 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
21851 * Digest Algorithm, as defined in RFC 1321.
21852 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
21853 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
21854 * Distributed under the BSD License
21855 * See http://pajhome.org.uk/crypt/md5 for more info.
21856 */
21857
21858 var helpers = _dereq_('./helpers');
21859
21860 /*
21861 * Calculate the MD5 of an array of little-endian words, and a bit length
21862 */
21863 function core_md5(x, len)
21864 {
21865 /* append padding */
21866 x[len >> 5] |= 0x80 << ((len) % 32);
21867 x[(((len + 64) >>> 9) << 4) + 14] = len;
21868
21869 var a = 1732584193;
21870 var b = -271733879;
21871 var c = -1732584194;
21872 var d = 271733878;
21873
21874 for(var i = 0; i < x.length; i += 16)
21875 {
21876 var olda = a;
21877 var oldb = b;
21878 var oldc = c;
21879 var oldd = d;
21880
21881 a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
21882 d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
21883 c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
21884 b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
21885 a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
21886 d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
21887 c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
21888 b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
21889 a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
21890 d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
21891 c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
21892 b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
21893 a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
21894 d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
21895 c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
21896 b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
21897
21898 a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
21899 d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
21900 c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
21901 b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
21902 a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
21903 d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
21904 c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
21905 b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
21906 a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
21907 d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
21908 c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
21909 b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
21910 a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
21911 d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
21912 c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
21913 b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
21914
21915 a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
21916 d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
21917 c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
21918 b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
21919 a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
21920 d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
21921 c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
21922 b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
21923 a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
21924 d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
21925 c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
21926 b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
21927 a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
21928 d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
21929 c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
21930 b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
21931
21932 a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
21933 d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
21934 c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
21935 b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
21936 a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
21937 d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
21938 c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
21939 b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
21940 a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
21941 d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
21942 c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
21943 b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
21944 a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
21945 d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
21946 c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
21947 b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
21948
21949 a = safe_add(a, olda);
21950 b = safe_add(b, oldb);
21951 c = safe_add(c, oldc);
21952 d = safe_add(d, oldd);
21953 }
21954 return Array(a, b, c, d);
21955
21956 }
21957
21958 /*
21959 * These functions implement the four basic operations the algorithm uses.
21960 */
21961 function md5_cmn(q, a, b, x, s, t)
21962 {
21963 return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
21964 }
21965 function md5_ff(a, b, c, d, x, s, t)
21966 {
21967 return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
21968 }
21969 function md5_gg(a, b, c, d, x, s, t)
21970 {
21971 return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
21972 }
21973 function md5_hh(a, b, c, d, x, s, t)
21974 {
21975 return md5_cmn(b ^ c ^ d, a, b, x, s, t);
21976 }
21977 function md5_ii(a, b, c, d, x, s, t)
21978 {
21979 return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
21980 }
21981
21982 /*
21983 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
21984 * to work around bugs in some JS interpreters.
21985 */
21986 function safe_add(x, y)
21987 {
21988 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
21989 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
21990 return (msw << 16) | (lsw & 0xFFFF);
21991 }
21992
21993 /*
21994 * Bitwise rotate a 32-bit number to the left.
21995 */
21996 function bit_rol(num, cnt)
21997 {
21998 return (num << cnt) | (num >>> (32 - cnt));
21999 }
22000
22001 module.exports = function md5(buf) {
22002 return helpers.hash(buf, core_md5, 16);
22003 };
22004
22005 },{"./helpers":18}],21:[function(_dereq_,module,exports){
22006 (function (Buffer){
22007
22008 module.exports = ripemd160
22009
22010
22011
22012 /*
22013 CryptoJS v3.1.2
22014 code.google.com/p/crypto-js
22015 (c) 2009-2013 by Jeff Mott. All rights reserved.
22016 code.google.com/p/crypto-js/wiki/License
22017 */
22018 /** @preserve
22019 (c) 2012 by Cédric Mesnil. All rights reserved.
22020
22021 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
22022
22023 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
22024 - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
22025
22026 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22027 */
22028
22029 // Constants table
22030 var zl = [
22031 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
22032 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
22033 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
22034 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
22035 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13];
22036 var zr = [
22037 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
22038 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
22039 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
22040 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
22041 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11];
22042 var sl = [
22043 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
22044 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
22045 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
22046 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
22047 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ];
22048 var sr = [
22049 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
22050 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
22051 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
22052 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
22053 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ];
22054
22055 var hl = [ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E];
22056 var hr = [ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000];
22057
22058 var bytesToWords = function (bytes) {
22059 var words = [];
22060 for (var i = 0, b = 0; i < bytes.length; i++, b += 8) {
22061 words[b >>> 5] |= bytes[i] << (24 - b % 32);
22062 }
22063 return words;
22064 };
22065
22066 var wordsToBytes = function (words) {
22067 var bytes = [];
22068 for (var b = 0; b < words.length * 32; b += 8) {
22069 bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
22070 }
22071 return bytes;
22072 };
22073
22074 var processBlock = function (H, M, offset) {
22075
22076 // Swap endian
22077 for (var i = 0; i < 16; i++) {
22078 var offset_i = offset + i;
22079 var M_offset_i = M[offset_i];
22080
22081 // Swap
22082 M[offset_i] = (
22083 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
22084 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
22085 );
22086 }
22087
22088 // Working variables
22089 var al, bl, cl, dl, el;
22090 var ar, br, cr, dr, er;
22091
22092 ar = al = H[0];
22093 br = bl = H[1];
22094 cr = cl = H[2];
22095 dr = dl = H[3];
22096 er = el = H[4];
22097 // Computation
22098 var t;
22099 for (var i = 0; i < 80; i += 1) {
22100 t = (al + M[offset+zl[i]])|0;
22101 if (i<16){
22102 t += f1(bl,cl,dl) + hl[0];
22103 } else if (i<32) {
22104 t += f2(bl,cl,dl) + hl[1];
22105 } else if (i<48) {
22106 t += f3(bl,cl,dl) + hl[2];
22107 } else if (i<64) {
22108 t += f4(bl,cl,dl) + hl[3];
22109 } else {// if (i<80) {
22110 t += f5(bl,cl,dl) + hl[4];
22111 }
22112 t = t|0;
22113 t = rotl(t,sl[i]);
22114 t = (t+el)|0;
22115 al = el;
22116 el = dl;
22117 dl = rotl(cl, 10);
22118 cl = bl;
22119 bl = t;
22120
22121 t = (ar + M[offset+zr[i]])|0;
22122 if (i<16){
22123 t += f5(br,cr,dr) + hr[0];
22124 } else if (i<32) {
22125 t += f4(br,cr,dr) + hr[1];
22126 } else if (i<48) {
22127 t += f3(br,cr,dr) + hr[2];
22128 } else if (i<64) {
22129 t += f2(br,cr,dr) + hr[3];
22130 } else {// if (i<80) {
22131 t += f1(br,cr,dr) + hr[4];
22132 }
22133 t = t|0;
22134 t = rotl(t,sr[i]) ;
22135 t = (t+er)|0;
22136 ar = er;
22137 er = dr;
22138 dr = rotl(cr, 10);
22139 cr = br;
22140 br = t;
22141 }
22142 // Intermediate hash value
22143 t = (H[1] + cl + dr)|0;
22144 H[1] = (H[2] + dl + er)|0;
22145 H[2] = (H[3] + el + ar)|0;
22146 H[3] = (H[4] + al + br)|0;
22147 H[4] = (H[0] + bl + cr)|0;
22148 H[0] = t;
22149 };
22150
22151 function f1(x, y, z) {
22152 return ((x) ^ (y) ^ (z));
22153 }
22154
22155 function f2(x, y, z) {
22156 return (((x)&(y)) | ((~x)&(z)));
22157 }
22158
22159 function f3(x, y, z) {
22160 return (((x) | (~(y))) ^ (z));
22161 }
22162
22163 function f4(x, y, z) {
22164 return (((x) & (z)) | ((y)&(~(z))));
22165 }
22166
22167 function f5(x, y, z) {
22168 return ((x) ^ ((y) |(~(z))));
22169 }
22170
22171 function rotl(x,n) {
22172 return (x<<n) | (x>>>(32-n));
22173 }
22174
22175 function ripemd160(message) {
22176 var H = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];
22177
22178 if (typeof message == 'string')
22179 message = new Buffer(message, 'utf8');
22180
22181 var m = bytesToWords(message);
22182
22183 var nBitsLeft = message.length * 8;
22184 var nBitsTotal = message.length * 8;
22185
22186 // Add padding
22187 m[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
22188 m[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
22189 (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
22190 (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
22191 );
22192
22193 for (var i=0 ; i<m.length; i += 16) {
22194 processBlock(H, m, i);
22195 }
22196
22197 // Swap endian
22198 for (var i = 0; i < 5; i++) {
22199 // Shortcut
22200 var H_i = H[i];
22201
22202 // Swap
22203 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
22204 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
22205 }
22206
22207 var digestbytes = wordsToBytes(H);
22208 return new Buffer(digestbytes);
22209 }
22210
22211
22212
22213 }).call(this,_dereq_("buffer").Buffer)
22214 },{"buffer":8}],22:[function(_dereq_,module,exports){
22215 var u = _dereq_('./util')
22216 var write = u.write
22217 var fill = u.zeroFill
22218
22219 module.exports = function (Buffer) {
22220
22221 //prototype class for hash functions
22222 function Hash (blockSize, finalSize) {
22223 this._block = new Buffer(blockSize) //new Uint32Array(blockSize/4)
22224 this._finalSize = finalSize
22225 this._blockSize = blockSize
22226 this._len = 0
22227 this._s = 0
22228 }
22229
22230 Hash.prototype.init = function () {
22231 this._s = 0
22232 this._len = 0
22233 }
22234
22235 function lengthOf(data, enc) {
22236 if(enc == null) return data.byteLength || data.length
22237 if(enc == 'ascii' || enc == 'binary') return data.length
22238 if(enc == 'hex') return data.length/2
22239 if(enc == 'base64') return data.length/3
22240 }
22241
22242 Hash.prototype.update = function (data, enc) {
22243 var bl = this._blockSize
22244
22245 //I'd rather do this with a streaming encoder, like the opposite of
22246 //http://nodejs.org/api/string_decoder.html
22247 var length
22248 if(!enc && 'string' === typeof data)
22249 enc = 'utf8'
22250
22251 if(enc) {
22252 if(enc === 'utf-8')
22253 enc = 'utf8'
22254
22255 if(enc === 'base64' || enc === 'utf8')
22256 data = new Buffer(data, enc), enc = null
22257
22258 length = lengthOf(data, enc)
22259 } else
22260 length = data.byteLength || data.length
22261
22262 var l = this._len += length
22263 var s = this._s = (this._s || 0)
22264 var f = 0
22265 var buffer = this._block
22266 while(s < l) {
22267 var t = Math.min(length, f + bl)
22268 write(buffer, data, enc, s%bl, f, t)
22269 var ch = (t - f);
22270 s += ch; f += ch
22271
22272 if(!(s%bl))
22273 this._update(buffer)
22274 }
22275 this._s = s
22276
22277 return this
22278
22279 }
22280
22281 Hash.prototype.digest = function (enc) {
22282 var bl = this._blockSize
22283 var fl = this._finalSize
22284 var len = this._len*8
22285
22286 var x = this._block
22287
22288 var bits = len % (bl*8)
22289
22290 //add end marker, so that appending 0's creats a different hash.
22291 x[this._len % bl] = 0x80
22292 fill(this._block, this._len % bl + 1)
22293
22294 if(bits >= fl*8) {
22295 this._update(this._block)
22296 u.zeroFill(this._block, 0)
22297 }
22298
22299 //TODO: handle case where the bit length is > Math.pow(2, 29)
22300 x.writeInt32BE(len, fl + 4) //big endian
22301
22302 var hash = this._update(this._block) || this._hash()
22303 if(enc == null) return hash
22304 return hash.toString(enc)
22305 }
22306
22307 Hash.prototype._update = function () {
22308 throw new Error('_update must be implemented by subclass')
22309 }
22310
22311 return Hash
22312 }
22313
22314 },{"./util":26}],23:[function(_dereq_,module,exports){
22315 var exports = module.exports = function (alg) {
22316 var Alg = exports[alg]
22317 if(!Alg) throw new Error(alg + ' is not supported (we accept pull requests)')
22318 return new Alg()
22319 }
22320
22321 var Buffer = _dereq_('buffer').Buffer
22322 var Hash = _dereq_('./hash')(Buffer)
22323
22324 exports.sha =
22325 exports.sha1 = _dereq_('./sha1')(Buffer, Hash)
22326 exports.sha256 = _dereq_('./sha256')(Buffer, Hash)
22327
22328 },{"./hash":22,"./sha1":24,"./sha256":25,"buffer":8}],24:[function(_dereq_,module,exports){
22329 /*
22330 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
22331 * in FIPS PUB 180-1
22332 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
22333 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
22334 * Distributed under the BSD License
22335 * See http://pajhome.org.uk/crypt/md5 for details.
22336 */
22337 module.exports = function (Buffer, Hash) {
22338
22339 var inherits = _dereq_('util').inherits
22340
22341 inherits(Sha1, Hash)
22342
22343 var A = 0|0
22344 var B = 4|0
22345 var C = 8|0
22346 var D = 12|0
22347 var E = 16|0
22348
22349 var BE = false
22350 var LE = true
22351
22352 var W = new Int32Array(80)
22353
22354 var POOL = []
22355
22356 function Sha1 () {
22357 if(POOL.length)
22358 return POOL.pop().init()
22359
22360 if(!(this instanceof Sha1)) return new Sha1()
22361 this._w = W
22362 Hash.call(this, 16*4, 14*4)
22363
22364 this._h = null
22365 this.init()
22366 }
22367
22368 Sha1.prototype.init = function () {
22369 this._a = 0x67452301
22370 this._b = 0xefcdab89
22371 this._c = 0x98badcfe
22372 this._d = 0x10325476
22373 this._e = 0xc3d2e1f0
22374
22375 Hash.prototype.init.call(this)
22376 return this
22377 }
22378
22379 Sha1.prototype._POOL = POOL
22380
22381 // assume that array is a Uint32Array with length=16,
22382 // and that if it is the last block, it already has the length and the 1 bit appended.
22383
22384
22385 var isDV = new Buffer(1) instanceof DataView
22386 function readInt32BE (X, i) {
22387 return isDV
22388 ? X.getInt32(i, false)
22389 : X.readInt32BE(i)
22390 }
22391
22392 Sha1.prototype._update = function (array) {
22393
22394 var X = this._block
22395 var h = this._h
22396 var a, b, c, d, e, _a, _b, _c, _d, _e
22397
22398 a = _a = this._a
22399 b = _b = this._b
22400 c = _c = this._c
22401 d = _d = this._d
22402 e = _e = this._e
22403
22404 var w = this._w
22405
22406 for(var j = 0; j < 80; j++) {
22407 var W = w[j]
22408 = j < 16
22409 //? X.getInt32(j*4, false)
22410 //? readInt32BE(X, j*4) //*/ X.readInt32BE(j*4) //*/
22411 ? X.readInt32BE(j*4)
22412 : rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1)
22413
22414 var t =
22415 add(
22416 add(rol(a, 5), sha1_ft(j, b, c, d)),
22417 add(add(e, W), sha1_kt(j))
22418 );
22419
22420 e = d
22421 d = c
22422 c = rol(b, 30)
22423 b = a
22424 a = t
22425 }
22426
22427 this._a = add(a, _a)
22428 this._b = add(b, _b)
22429 this._c = add(c, _c)
22430 this._d = add(d, _d)
22431 this._e = add(e, _e)
22432 }
22433
22434 Sha1.prototype._hash = function () {
22435 if(POOL.length < 100) POOL.push(this)
22436 var H = new Buffer(20)
22437 //console.log(this._a|0, this._b|0, this._c|0, this._d|0, this._e|0)
22438 H.writeInt32BE(this._a|0, A)
22439 H.writeInt32BE(this._b|0, B)
22440 H.writeInt32BE(this._c|0, C)
22441 H.writeInt32BE(this._d|0, D)
22442 H.writeInt32BE(this._e|0, E)
22443 return H
22444 }
22445
22446 /*
22447 * Perform the appropriate triplet combination function for the current
22448 * iteration
22449 */
22450 function sha1_ft(t, b, c, d) {
22451 if(t < 20) return (b & c) | ((~b) & d);
22452 if(t < 40) return b ^ c ^ d;
22453 if(t < 60) return (b & c) | (b & d) | (c & d);
22454 return b ^ c ^ d;
22455 }
22456
22457 /*
22458 * Determine the appropriate additive constant for the current iteration
22459 */
22460 function sha1_kt(t) {
22461 return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
22462 (t < 60) ? -1894007588 : -899497514;
22463 }
22464
22465 /*
22466 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
22467 * to work around bugs in some JS interpreters.
22468 * //dominictarr: this is 10 years old, so maybe this can be dropped?)
22469 *
22470 */
22471 function add(x, y) {
22472 return (x + y ) | 0
22473 //lets see how this goes on testling.
22474 // var lsw = (x & 0xFFFF) + (y & 0xFFFF);
22475 // var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
22476 // return (msw << 16) | (lsw & 0xFFFF);
22477 }
22478
22479 /*
22480 * Bitwise rotate a 32-bit number to the left.
22481 */
22482 function rol(num, cnt) {
22483 return (num << cnt) | (num >>> (32 - cnt));
22484 }
22485
22486 return Sha1
22487 }
22488
22489 },{"util":14}],25:[function(_dereq_,module,exports){
22490
22491 /**
22492 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
22493 * in FIPS 180-2
22494 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
22495 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
22496 *
22497 */
22498
22499 var inherits = _dereq_('util').inherits
22500 var BE = false
22501 var LE = true
22502 var u = _dereq_('./util')
22503
22504 module.exports = function (Buffer, Hash) {
22505
22506 var K = [
22507 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
22508 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
22509 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
22510 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
22511 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
22512 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
22513 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
22514 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
22515 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
22516 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
22517 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
22518 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
22519 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
22520 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
22521 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
22522 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
22523 ]
22524
22525 inherits(Sha256, Hash)
22526 var W = new Array(64)
22527 var POOL = []
22528 function Sha256() {
22529 // Closure compiler warning - this code lacks side effects - thus commented out
22530 // if(POOL.length) {
22531 // return POOL.shift().init()
22532 // }
22533 //this._data = new Buffer(32)
22534
22535 this.init()
22536
22537 this._w = W //new Array(64)
22538
22539 Hash.call(this, 16*4, 14*4)
22540 };
22541
22542 Sha256.prototype.init = function () {
22543
22544 this._a = 0x6a09e667|0
22545 this._b = 0xbb67ae85|0
22546 this._c = 0x3c6ef372|0
22547 this._d = 0xa54ff53a|0
22548 this._e = 0x510e527f|0
22549 this._f = 0x9b05688c|0
22550 this._g = 0x1f83d9ab|0
22551 this._h = 0x5be0cd19|0
22552
22553 this._len = this._s = 0
22554
22555 return this
22556 }
22557
22558 var safe_add = function(x, y) {
22559 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
22560 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
22561 return (msw << 16) | (lsw & 0xFFFF);
22562 }
22563
22564 function S (X, n) {
22565 return (X >>> n) | (X << (32 - n));
22566 }
22567
22568 function R (X, n) {
22569 return (X >>> n);
22570 }
22571
22572 function Ch (x, y, z) {
22573 return ((x & y) ^ ((~x) & z));
22574 }
22575
22576 function Maj (x, y, z) {
22577 return ((x & y) ^ (x & z) ^ (y & z));
22578 }
22579
22580 function Sigma0256 (x) {
22581 return (S(x, 2) ^ S(x, 13) ^ S(x, 22));
22582 }
22583
22584 function Sigma1256 (x) {
22585 return (S(x, 6) ^ S(x, 11) ^ S(x, 25));
22586 }
22587
22588 function Gamma0256 (x) {
22589 return (S(x, 7) ^ S(x, 18) ^ R(x, 3));
22590 }
22591
22592 function Gamma1256 (x) {
22593 return (S(x, 17) ^ S(x, 19) ^ R(x, 10));
22594 }
22595
22596 Sha256.prototype._update = function(m) {
22597 var M = this._block
22598 var W = this._w
22599 var a, b, c, d, e, f, g, h
22600 var T1, T2
22601
22602 a = this._a | 0
22603 b = this._b | 0
22604 c = this._c | 0
22605 d = this._d | 0
22606 e = this._e | 0
22607 f = this._f | 0
22608 g = this._g | 0
22609 h = this._h | 0
22610
22611 for (var j = 0; j < 64; j++) {
22612 var w = W[j] = j < 16
22613 ? M.readInt32BE(j * 4)
22614 : Gamma1256(W[j - 2]) + W[j - 7] + Gamma0256(W[j - 15]) + W[j - 16]
22615
22616 T1 = h + Sigma1256(e) + Ch(e, f, g) + K[j] + w
22617
22618 T2 = Sigma0256(a) + Maj(a, b, c);
22619 h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2;
22620 }
22621
22622 this._a = (a + this._a) | 0
22623 this._b = (b + this._b) | 0
22624 this._c = (c + this._c) | 0
22625 this._d = (d + this._d) | 0
22626 this._e = (e + this._e) | 0
22627 this._f = (f + this._f) | 0
22628 this._g = (g + this._g) | 0
22629 this._h = (h + this._h) | 0
22630
22631 };
22632
22633 Sha256.prototype._hash = function () {
22634 if(POOL.length < 10)
22635 POOL.push(this)
22636
22637 var H = new Buffer(32)
22638
22639 H.writeInt32BE(this._a, 0)
22640 H.writeInt32BE(this._b, 4)
22641 H.writeInt32BE(this._c, 8)
22642 H.writeInt32BE(this._d, 12)
22643 H.writeInt32BE(this._e, 16)
22644 H.writeInt32BE(this._f, 20)
22645 H.writeInt32BE(this._g, 24)
22646 H.writeInt32BE(this._h, 28)
22647
22648 return H
22649 }
22650
22651 return Sha256
22652
22653 }
22654
22655 },{"./util":26,"util":14}],26:[function(_dereq_,module,exports){
22656 exports.write = write
22657 exports.zeroFill = zeroFill
22658
22659 exports.toString = toString
22660
22661 function write (buffer, string, enc, start, from, to, LE) {
22662 var l = (to - from)
22663 if(enc === 'ascii' || enc === 'binary') {
22664 for( var i = 0; i < l; i++) {
22665 buffer[start + i] = string.charCodeAt(i + from)
22666 }
22667 }
22668 else if(enc == null) {
22669 for( var i = 0; i < l; i++) {
22670 buffer[start + i] = string[i + from]
22671 }
22672 }
22673 else if(enc === 'hex') {
22674 for(var i = 0; i < l; i++) {
22675 var j = from + i
22676 buffer[start + i] = parseInt(string[j*2] + string[(j*2)+1], 16)
22677 }
22678 }
22679 else if(enc === 'base64') {
22680 throw new Error('base64 encoding not yet supported')
22681 }
22682 else
22683 throw new Error(enc +' encoding not yet supported')
22684 }
22685
22686 //always fill to the end!
22687 function zeroFill(buf, from) {
22688 for(var i = from; i < buf.length; i++)
22689 buf[i] = 0
22690 }
22691
22692
22693 },{}],27:[function(_dereq_,module,exports){
22694 (function (Buffer){
22695 // JavaScript PBKDF2 Implementation
22696 // Based on http://git.io/qsv2zw
22697 // Licensed under LGPL v3
22698 // Copyright (c) 2013 jduncanator
22699
22700 var blocksize = 64
22701 var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(0)
22702
22703 module.exports = function (createHmac, exports) {
22704 exports = exports || {}
22705
22706 exports.pbkdf2 = function(password, salt, iterations, keylen, cb) {
22707 if('function' !== typeof cb)
22708 throw new Error('No callback provided to pbkdf2');
22709 setTimeout(function () {
22710 cb(null, exports.pbkdf2Sync(password, salt, iterations, keylen))
22711 })
22712 }
22713
22714 exports.pbkdf2Sync = function(key, salt, iterations, keylen) {
22715 if('number' !== typeof iterations)
22716 throw new TypeError('Iterations not a number')
22717 if(iterations < 0)
22718 throw new TypeError('Bad iterations')
22719 if('number' !== typeof keylen)
22720 throw new TypeError('Key length not a number')
22721 if(keylen < 0)
22722 throw new TypeError('Bad key length')
22723
22724 //stretch key to the correct length that hmac wants it,
22725 //otherwise this will happen every time hmac is called
22726 //twice per iteration.
22727 var key = !Buffer.isBuffer(key) ? new Buffer(key) : key
22728
22729 if(key.length > blocksize) {
22730 key = createHash(alg).update(key).digest()
22731 } else if(key.length < blocksize) {
22732 key = Buffer.concat([key, zeroBuffer], blocksize)
22733 }
22734
22735 var HMAC;
22736 var cplen, p = 0, i = 1, itmp = new Buffer(4), digtmp;
22737 var out = new Buffer(keylen);
22738 out.fill(0);
22739 while(keylen) {
22740 if(keylen > 20)
22741 cplen = 20;
22742 else
22743 cplen = keylen;
22744
22745 /* We are unlikely to ever use more than 256 blocks (5120 bits!)
22746 * but just in case...
22747 */
22748 itmp[0] = (i >> 24) & 0xff;
22749 itmp[1] = (i >> 16) & 0xff;
22750 itmp[2] = (i >> 8) & 0xff;
22751 itmp[3] = i & 0xff;
22752
22753 HMAC = createHmac('sha1', key);
22754 HMAC.update(salt)
22755 HMAC.update(itmp);
22756 digtmp = HMAC.digest();
22757 digtmp.copy(out, p, 0, cplen);
22758
22759 for(var j = 1; j < iterations; j++) {
22760 HMAC = createHmac('sha1', key);
22761 HMAC.update(digtmp);
22762 digtmp = HMAC.digest();
22763 for(var k = 0; k < cplen; k++) {
22764 out[k] ^= digtmp[k];
22765 }
22766 }
22767 keylen -= cplen;
22768 i++;
22769 p += cplen;
22770 }
22771
22772 return out;
22773 }
22774
22775 return exports
22776 }
22777
22778 }).call(this,_dereq_("buffer").Buffer)
22779 },{"buffer":8}],28:[function(_dereq_,module,exports){
22780 (function (Buffer){
22781 // Original code adapted from Robert Kieffer.
22782 // details at https://github.com/broofa/node-uuid
22783
22784
22785 (function() {
22786 var _global = this;
22787
22788 var mathRNG, whatwgRNG;
22789
22790 // NOTE: Math.random() does not guarantee "cryptographic quality"
22791 mathRNG = function(size) {
22792 var bytes = new Buffer(size);
22793 var r;
22794
22795 for (var i = 0, r; i < size; i++) {
22796 if ((i & 0x03) == 0) r = Math.random() * 0x100000000;
22797 bytes[i] = r >>> ((i & 0x03) << 3) & 0xff;
22798 }
22799
22800 return bytes;
22801 }
22802
22803 if (_global.crypto && crypto.getRandomValues) {
22804 whatwgRNG = function(size) {
22805 var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array
22806 crypto.getRandomValues(bytes);
22807 return bytes;
22808 }
22809 }
22810
22811 module.exports = whatwgRNG || mathRNG;
22812
22813 }())
22814
22815 }).call(this,_dereq_("buffer").Buffer)
22816 },{"buffer":8}],29:[function(_dereq_,module,exports){
22817 ;(function (root, factory, undef) {
22818 if (typeof exports === "object") {
22819 // CommonJS
22820 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
22821 }
22822 else if (typeof define === "function" && define.amd) {
22823 // AMD
22824 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
22825 }
22826 else {
22827 // Global (browser)
22828 factory(root.CryptoJS);
22829 }
22830 }(this, function (CryptoJS) {
22831
22832 (function () {
22833 // Shortcuts
22834 var C = CryptoJS;
22835 var C_lib = C.lib;
22836 var BlockCipher = C_lib.BlockCipher;
22837 var C_algo = C.algo;
22838
22839 // Lookup tables
22840 var SBOX = [];
22841 var INV_SBOX = [];
22842 var SUB_MIX_0 = [];
22843 var SUB_MIX_1 = [];
22844 var SUB_MIX_2 = [];
22845 var SUB_MIX_3 = [];
22846 var INV_SUB_MIX_0 = [];
22847 var INV_SUB_MIX_1 = [];
22848 var INV_SUB_MIX_2 = [];
22849 var INV_SUB_MIX_3 = [];
22850
22851 // Compute lookup tables
22852 (function () {
22853 // Compute double table
22854 var d = [];
22855 for (var i = 0; i < 256; i++) {
22856 if (i < 128) {
22857 d[i] = i << 1;
22858 } else {
22859 d[i] = (i << 1) ^ 0x11b;
22860 }
22861 }
22862
22863 // Walk GF(2^8)
22864 var x = 0;
22865 var xi = 0;
22866 for (var i = 0; i < 256; i++) {
22867 // Compute sbox
22868 var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
22869 sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
22870 SBOX[x] = sx;
22871 INV_SBOX[sx] = x;
22872
22873 // Compute multiplication
22874 var x2 = d[x];
22875 var x4 = d[x2];
22876 var x8 = d[x4];
22877
22878 // Compute sub bytes, mix columns tables
22879 var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
22880 SUB_MIX_0[x] = (t << 24) | (t >>> 8);
22881 SUB_MIX_1[x] = (t << 16) | (t >>> 16);
22882 SUB_MIX_2[x] = (t << 8) | (t >>> 24);
22883 SUB_MIX_3[x] = t;
22884
22885 // Compute inv sub bytes, inv mix columns tables
22886 var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
22887 INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
22888 INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
22889 INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
22890 INV_SUB_MIX_3[sx] = t;
22891
22892 // Compute next counter
22893 if (!x) {
22894 x = xi = 1;
22895 } else {
22896 x = x2 ^ d[d[d[x8 ^ x2]]];
22897 xi ^= d[d[xi]];
22898 }
22899 }
22900 }());
22901
22902 // Precomputed Rcon lookup
22903 var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
22904
22905 /**
22906 * AES block cipher algorithm.
22907 */
22908 var AES = C_algo.AES = BlockCipher.extend({
22909 _doReset: function () {
22910 // Shortcuts
22911 var key = this._key;
22912 var keyWords = key.words;
22913 var keySize = key.sigBytes / 4;
22914
22915 // Compute number of rounds
22916 var nRounds = this._nRounds = keySize + 6
22917
22918 // Compute number of key schedule rows
22919 var ksRows = (nRounds + 1) * 4;
22920
22921 // Compute key schedule
22922 var keySchedule = this._keySchedule = [];
22923 for (var ksRow = 0; ksRow < ksRows; ksRow++) {
22924 if (ksRow < keySize) {
22925 keySchedule[ksRow] = keyWords[ksRow];
22926 } else {
22927 var t = keySchedule[ksRow - 1];
22928
22929 if (!(ksRow % keySize)) {
22930 // Rot word
22931 t = (t << 8) | (t >>> 24);
22932
22933 // Sub word
22934 t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
22935
22936 // Mix Rcon
22937 t ^= RCON[(ksRow / keySize) | 0] << 24;
22938 } else if (keySize > 6 && ksRow % keySize == 4) {
22939 // Sub word
22940 t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
22941 }
22942
22943 keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
22944 }
22945 }
22946
22947 // Compute inv key schedule
22948 var invKeySchedule = this._invKeySchedule = [];
22949 for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
22950 var ksRow = ksRows - invKsRow;
22951
22952 if (invKsRow % 4) {
22953 var t = keySchedule[ksRow];
22954 } else {
22955 var t = keySchedule[ksRow - 4];
22956 }
22957
22958 if (invKsRow < 4 || ksRow <= 4) {
22959 invKeySchedule[invKsRow] = t;
22960 } else {
22961 invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
22962 INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
22963 }
22964 }
22965 },
22966
22967 encryptBlock: function (M, offset) {
22968 this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
22969 },
22970
22971 decryptBlock: function (M, offset) {
22972 // Swap 2nd and 4th rows
22973 var t = M[offset + 1];
22974 M[offset + 1] = M[offset + 3];
22975 M[offset + 3] = t;
22976
22977 this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
22978
22979 // Inv swap 2nd and 4th rows
22980 var t = M[offset + 1];
22981 M[offset + 1] = M[offset + 3];
22982 M[offset + 3] = t;
22983 },
22984
22985 _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
22986 // Shortcut
22987 var nRounds = this._nRounds;
22988
22989 // Get input, add round key
22990 var s0 = M[offset] ^ keySchedule[0];
22991 var s1 = M[offset + 1] ^ keySchedule[1];
22992 var s2 = M[offset + 2] ^ keySchedule[2];
22993 var s3 = M[offset + 3] ^ keySchedule[3];
22994
22995 // Key schedule row counter
22996 var ksRow = 4;
22997
22998 // Rounds
22999 for (var round = 1; round < nRounds; round++) {
23000 // Shift rows, sub bytes, mix columns, add round key
23001 var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
23002 var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
23003 var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
23004 var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
23005
23006 // Update state
23007 s0 = t0;
23008 s1 = t1;
23009 s2 = t2;
23010 s3 = t3;
23011 }
23012
23013 // Shift rows, sub bytes, add round key
23014 var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
23015 var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
23016 var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
23017 var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
23018
23019 // Set output
23020 M[offset] = t0;
23021 M[offset + 1] = t1;
23022 M[offset + 2] = t2;
23023 M[offset + 3] = t3;
23024 },
23025
23026 keySize: 256/32
23027 });
23028
23029 /**
23030 * Shortcut functions to the cipher's object interface.
23031 *
23032 * @example
23033 *
23034 * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
23035 * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
23036 */
23037 C.AES = BlockCipher._createHelper(AES);
23038 }());
23039
23040
23041 return CryptoJS.AES;
23042
23043 }));
23044 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],30:[function(_dereq_,module,exports){
23045 ;(function (root, factory) {
23046 if (typeof exports === "object") {
23047 // CommonJS
23048 module.exports = exports = factory(_dereq_("./core"));
23049 }
23050 else if (typeof define === "function" && define.amd) {
23051 // AMD
23052 define(["./core"], factory);
23053 }
23054 else {
23055 // Global (browser)
23056 factory(root.CryptoJS);
23057 }
23058 }(this, function (CryptoJS) {
23059
23060 /**
23061 * Cipher core components.
23062 */
23063 CryptoJS.lib.Cipher || (function (undefined) {
23064 // Shortcuts
23065 var C = CryptoJS;
23066 var C_lib = C.lib;
23067 var Base = C_lib.Base;
23068 var WordArray = C_lib.WordArray;
23069 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
23070 var C_enc = C.enc;
23071 var Utf8 = C_enc.Utf8;
23072 var Base64 = C_enc.Base64;
23073 var C_algo = C.algo;
23074 var EvpKDF = C_algo.EvpKDF;
23075
23076 /**
23077 * Abstract base cipher template.
23078 *
23079 * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
23080 * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
23081 * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
23082 * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
23083 */
23084 var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
23085 /**
23086 * Configuration options.
23087 *
23088 * @property {WordArray} iv The IV to use for this operation.
23089 */
23090 cfg: Base.extend(),
23091
23092 /**
23093 * Creates this cipher in encryption mode.
23094 *
23095 * @param {WordArray} key The key.
23096 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23097 *
23098 * @return {Cipher} A cipher instance.
23099 *
23100 * @static
23101 *
23102 * @example
23103 *
23104 * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
23105 */
23106 createEncryptor: function (key, cfg) {
23107 return this.create(this._ENC_XFORM_MODE, key, cfg);
23108 },
23109
23110 /**
23111 * Creates this cipher in decryption mode.
23112 *
23113 * @param {WordArray} key The key.
23114 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23115 *
23116 * @return {Cipher} A cipher instance.
23117 *
23118 * @static
23119 *
23120 * @example
23121 *
23122 * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
23123 */
23124 createDecryptor: function (key, cfg) {
23125 return this.create(this._DEC_XFORM_MODE, key, cfg);
23126 },
23127
23128 /**
23129 * Initializes a newly created cipher.
23130 *
23131 * @param {number} xformMode Either the encryption or decryption transormation mode constant.
23132 * @param {WordArray} key The key.
23133 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23134 *
23135 * @example
23136 *
23137 * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
23138 */
23139 init: function (xformMode, key, cfg) {
23140 // Apply config defaults
23141 this.cfg = this.cfg.extend(cfg);
23142
23143 // Store transform mode and key
23144 this._xformMode = xformMode;
23145 this._key = key;
23146
23147 // Set initial values
23148 this.reset();
23149 },
23150
23151 /**
23152 * Resets this cipher to its initial state.
23153 *
23154 * @example
23155 *
23156 * cipher.reset();
23157 */
23158 reset: function () {
23159 // Reset data buffer
23160 BufferedBlockAlgorithm.reset.call(this);
23161
23162 // Perform concrete-cipher logic
23163 this._doReset();
23164 },
23165
23166 /**
23167 * Adds data to be encrypted or decrypted.
23168 *
23169 * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
23170 *
23171 * @return {WordArray} The data after processing.
23172 *
23173 * @example
23174 *
23175 * var encrypted = cipher.process('data');
23176 * var encrypted = cipher.process(wordArray);
23177 */
23178 process: function (dataUpdate) {
23179 // Append
23180 this._append(dataUpdate);
23181
23182 // Process available blocks
23183 return this._process();
23184 },
23185
23186 /**
23187 * Finalizes the encryption or decryption process.
23188 * Note that the finalize operation is effectively a destructive, read-once operation.
23189 *
23190 * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
23191 *
23192 * @return {WordArray} The data after final processing.
23193 *
23194 * @example
23195 *
23196 * var encrypted = cipher.finalize();
23197 * var encrypted = cipher.finalize('data');
23198 * var encrypted = cipher.finalize(wordArray);
23199 */
23200 finalize: function (dataUpdate) {
23201 // Final data update
23202 if (dataUpdate) {
23203 this._append(dataUpdate);
23204 }
23205
23206 // Perform concrete-cipher logic
23207 var finalProcessedData = this._doFinalize();
23208
23209 return finalProcessedData;
23210 },
23211
23212 keySize: 128/32,
23213
23214 ivSize: 128/32,
23215
23216 _ENC_XFORM_MODE: 1,
23217
23218 _DEC_XFORM_MODE: 2,
23219
23220 /**
23221 * Creates shortcut functions to a cipher's object interface.
23222 *
23223 * @param {Cipher} cipher The cipher to create a helper for.
23224 *
23225 * @return {Object} An object with encrypt and decrypt shortcut functions.
23226 *
23227 * @static
23228 *
23229 * @example
23230 *
23231 * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
23232 */
23233 _createHelper: (function () {
23234 function selectCipherStrategy(key) {
23235 if (typeof key == 'string') {
23236 return PasswordBasedCipher;
23237 } else {
23238 return SerializableCipher;
23239 }
23240 }
23241
23242 return function (cipher) {
23243 return {
23244 encrypt: function (message, key, cfg) {
23245 return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
23246 },
23247
23248 decrypt: function (ciphertext, key, cfg) {
23249 return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
23250 }
23251 };
23252 };
23253 }())
23254 });
23255
23256 /**
23257 * Abstract base stream cipher template.
23258 *
23259 * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
23260 */
23261 var StreamCipher = C_lib.StreamCipher = Cipher.extend({
23262 _doFinalize: function () {
23263 // Process partial blocks
23264 var finalProcessedBlocks = this._process(!!'flush');
23265
23266 return finalProcessedBlocks;
23267 },
23268
23269 blockSize: 1
23270 });
23271
23272 /**
23273 * Mode namespace.
23274 */
23275 var C_mode = C.mode = {};
23276
23277 /**
23278 * Abstract base block cipher mode template.
23279 */
23280 var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
23281 /**
23282 * Creates this mode for encryption.
23283 *
23284 * @param {Cipher} cipher A block cipher instance.
23285 * @param {Array} iv The IV words.
23286 *
23287 * @static
23288 *
23289 * @example
23290 *
23291 * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
23292 */
23293 createEncryptor: function (cipher, iv) {
23294 return this.Encryptor.create(cipher, iv);
23295 },
23296
23297 /**
23298 * Creates this mode for decryption.
23299 *
23300 * @param {Cipher} cipher A block cipher instance.
23301 * @param {Array} iv The IV words.
23302 *
23303 * @static
23304 *
23305 * @example
23306 *
23307 * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
23308 */
23309 createDecryptor: function (cipher, iv) {
23310 return this.Decryptor.create(cipher, iv);
23311 },
23312
23313 /**
23314 * Initializes a newly created mode.
23315 *
23316 * @param {Cipher} cipher A block cipher instance.
23317 * @param {Array} iv The IV words.
23318 *
23319 * @example
23320 *
23321 * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
23322 */
23323 init: function (cipher, iv) {
23324 this._cipher = cipher;
23325 this._iv = iv;
23326 }
23327 });
23328
23329 /**
23330 * Cipher Block Chaining mode.
23331 */
23332 var CBC = C_mode.CBC = (function () {
23333 /**
23334 * Abstract base CBC mode.
23335 */
23336 var CBC = BlockCipherMode.extend();
23337
23338 /**
23339 * CBC encryptor.
23340 */
23341 CBC.Encryptor = CBC.extend({
23342 /**
23343 * Processes the data block at offset.
23344 *
23345 * @param {Array} words The data words to operate on.
23346 * @param {number} offset The offset where the block starts.
23347 *
23348 * @example
23349 *
23350 * mode.processBlock(data.words, offset);
23351 */
23352 processBlock: function (words, offset) {
23353 // Shortcuts
23354 var cipher = this._cipher;
23355 var blockSize = cipher.blockSize;
23356
23357 // XOR and encrypt
23358 xorBlock.call(this, words, offset, blockSize);
23359 cipher.encryptBlock(words, offset);
23360
23361 // Remember this block to use with next block
23362 this._prevBlock = words.slice(offset, offset + blockSize);
23363 }
23364 });
23365
23366 /**
23367 * CBC decryptor.
23368 */
23369 CBC.Decryptor = CBC.extend({
23370 /**
23371 * Processes the data block at offset.
23372 *
23373 * @param {Array} words The data words to operate on.
23374 * @param {number} offset The offset where the block starts.
23375 *
23376 * @example
23377 *
23378 * mode.processBlock(data.words, offset);
23379 */
23380 processBlock: function (words, offset) {
23381 // Shortcuts
23382 var cipher = this._cipher;
23383 var blockSize = cipher.blockSize;
23384
23385 // Remember this block to use with next block
23386 var thisBlock = words.slice(offset, offset + blockSize);
23387
23388 // Decrypt and XOR
23389 cipher.decryptBlock(words, offset);
23390 xorBlock.call(this, words, offset, blockSize);
23391
23392 // This block becomes the previous block
23393 this._prevBlock = thisBlock;
23394 }
23395 });
23396
23397 function xorBlock(words, offset, blockSize) {
23398 // Shortcut
23399 var iv = this._iv;
23400
23401 // Choose mixing block
23402 if (iv) {
23403 var block = iv;
23404
23405 // Remove IV for subsequent blocks
23406 this._iv = undefined;
23407 } else {
23408 var block = this._prevBlock;
23409 }
23410
23411 // XOR blocks
23412 for (var i = 0; i < blockSize; i++) {
23413 words[offset + i] ^= block[i];
23414 }
23415 }
23416
23417 return CBC;
23418 }());
23419
23420 /**
23421 * Padding namespace.
23422 */
23423 var C_pad = C.pad = {};
23424
23425 /**
23426 * PKCS #5/7 padding strategy.
23427 */
23428 var Pkcs7 = C_pad.Pkcs7 = {
23429 /**
23430 * Pads data using the algorithm defined in PKCS #5/7.
23431 *
23432 * @param {WordArray} data The data to pad.
23433 * @param {number} blockSize The multiple that the data should be padded to.
23434 *
23435 * @static
23436 *
23437 * @example
23438 *
23439 * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
23440 */
23441 pad: function (data, blockSize) {
23442 // Shortcut
23443 var blockSizeBytes = blockSize * 4;
23444
23445 // Count padding bytes
23446 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
23447
23448 // Create padding word
23449 var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
23450
23451 // Create padding
23452 var paddingWords = [];
23453 for (var i = 0; i < nPaddingBytes; i += 4) {
23454 paddingWords.push(paddingWord);
23455 }
23456 var padding = WordArray.create(paddingWords, nPaddingBytes);
23457
23458 // Add padding
23459 data.concat(padding);
23460 },
23461
23462 /**
23463 * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
23464 *
23465 * @param {WordArray} data The data to unpad.
23466 *
23467 * @static
23468 *
23469 * @example
23470 *
23471 * CryptoJS.pad.Pkcs7.unpad(wordArray);
23472 */
23473 unpad: function (data) {
23474 // Get number of padding bytes from last byte
23475 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
23476
23477 // Remove padding
23478 data.sigBytes -= nPaddingBytes;
23479 }
23480 };
23481
23482 /**
23483 * Abstract base block cipher template.
23484 *
23485 * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
23486 */
23487 var BlockCipher = C_lib.BlockCipher = Cipher.extend({
23488 /**
23489 * Configuration options.
23490 *
23491 * @property {Mode} mode The block mode to use. Default: CBC
23492 * @property {Padding} padding The padding strategy to use. Default: Pkcs7
23493 */
23494 cfg: Cipher.cfg.extend({
23495 mode: CBC,
23496 padding: Pkcs7
23497 }),
23498
23499 reset: function () {
23500 // Reset cipher
23501 Cipher.reset.call(this);
23502
23503 // Shortcuts
23504 var cfg = this.cfg;
23505 var iv = cfg.iv;
23506 var mode = cfg.mode;
23507
23508 // Reset block mode
23509 if (this._xformMode == this._ENC_XFORM_MODE) {
23510 var modeCreator = mode.createEncryptor;
23511 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
23512 var modeCreator = mode.createDecryptor;
23513
23514 // Keep at least one block in the buffer for unpadding
23515 this._minBufferSize = 1;
23516 }
23517 this._mode = modeCreator.call(mode, this, iv && iv.words);
23518 },
23519
23520 _doProcessBlock: function (words, offset) {
23521 this._mode.processBlock(words, offset);
23522 },
23523
23524 _doFinalize: function () {
23525 // Shortcut
23526 var padding = this.cfg.padding;
23527
23528 // Finalize
23529 if (this._xformMode == this._ENC_XFORM_MODE) {
23530 // Pad data
23531 padding.pad(this._data, this.blockSize);
23532
23533 // Process final blocks
23534 var finalProcessedBlocks = this._process(!!'flush');
23535 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
23536 // Process final blocks
23537 var finalProcessedBlocks = this._process(!!'flush');
23538
23539 // Unpad data
23540 padding.unpad(finalProcessedBlocks);
23541 }
23542
23543 return finalProcessedBlocks;
23544 },
23545
23546 blockSize: 128/32
23547 });
23548
23549 /**
23550 * A collection of cipher parameters.
23551 *
23552 * @property {WordArray} ciphertext The raw ciphertext.
23553 * @property {WordArray} key The key to this ciphertext.
23554 * @property {WordArray} iv The IV used in the ciphering operation.
23555 * @property {WordArray} salt The salt used with a key derivation function.
23556 * @property {Cipher} algorithm The cipher algorithm.
23557 * @property {Mode} mode The block mode used in the ciphering operation.
23558 * @property {Padding} padding The padding scheme used in the ciphering operation.
23559 * @property {number} blockSize The block size of the cipher.
23560 * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
23561 */
23562 var CipherParams = C_lib.CipherParams = Base.extend({
23563 /**
23564 * Initializes a newly created cipher params object.
23565 *
23566 * @param {Object} cipherParams An object with any of the possible cipher parameters.
23567 *
23568 * @example
23569 *
23570 * var cipherParams = CryptoJS.lib.CipherParams.create({
23571 * ciphertext: ciphertextWordArray,
23572 * key: keyWordArray,
23573 * iv: ivWordArray,
23574 * salt: saltWordArray,
23575 * algorithm: CryptoJS.algo.AES,
23576 * mode: CryptoJS.mode.CBC,
23577 * padding: CryptoJS.pad.PKCS7,
23578 * blockSize: 4,
23579 * formatter: CryptoJS.format.OpenSSL
23580 * });
23581 */
23582 init: function (cipherParams) {
23583 this.mixIn(cipherParams);
23584 },
23585
23586 /**
23587 * Converts this cipher params object to a string.
23588 *
23589 * @param {Format} formatter (Optional) The formatting strategy to use.
23590 *
23591 * @return {string} The stringified cipher params.
23592 *
23593 * @throws Error If neither the formatter nor the default formatter is set.
23594 *
23595 * @example
23596 *
23597 * var string = cipherParams + '';
23598 * var string = cipherParams.toString();
23599 * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
23600 */
23601 toString: function (formatter) {
23602 return (formatter || this.formatter).stringify(this);
23603 }
23604 });
23605
23606 /**
23607 * Format namespace.
23608 */
23609 var C_format = C.format = {};
23610
23611 /**
23612 * OpenSSL formatting strategy.
23613 */
23614 var OpenSSLFormatter = C_format.OpenSSL = {
23615 /**
23616 * Converts a cipher params object to an OpenSSL-compatible string.
23617 *
23618 * @param {CipherParams} cipherParams The cipher params object.
23619 *
23620 * @return {string} The OpenSSL-compatible string.
23621 *
23622 * @static
23623 *
23624 * @example
23625 *
23626 * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
23627 */
23628 stringify: function (cipherParams) {
23629 // Shortcuts
23630 var ciphertext = cipherParams.ciphertext;
23631 var salt = cipherParams.salt;
23632
23633 // Format
23634 if (salt) {
23635 var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
23636 } else {
23637 var wordArray = ciphertext;
23638 }
23639
23640 return wordArray.toString(Base64);
23641 },
23642
23643 /**
23644 * Converts an OpenSSL-compatible string to a cipher params object.
23645 *
23646 * @param {string} openSSLStr The OpenSSL-compatible string.
23647 *
23648 * @return {CipherParams} The cipher params object.
23649 *
23650 * @static
23651 *
23652 * @example
23653 *
23654 * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
23655 */
23656 parse: function (openSSLStr) {
23657 // Parse base64
23658 var ciphertext = Base64.parse(openSSLStr);
23659
23660 // Shortcut
23661 var ciphertextWords = ciphertext.words;
23662
23663 // Test for salt
23664 if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
23665 // Extract salt
23666 var salt = WordArray.create(ciphertextWords.slice(2, 4));
23667
23668 // Remove salt from ciphertext
23669 ciphertextWords.splice(0, 4);
23670 ciphertext.sigBytes -= 16;
23671 }
23672
23673 return CipherParams.create({ ciphertext: ciphertext, salt: salt });
23674 }
23675 };
23676
23677 /**
23678 * A cipher wrapper that returns ciphertext as a serializable cipher params object.
23679 */
23680 var SerializableCipher = C_lib.SerializableCipher = Base.extend({
23681 /**
23682 * Configuration options.
23683 *
23684 * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
23685 */
23686 cfg: Base.extend({
23687 format: OpenSSLFormatter
23688 }),
23689
23690 /**
23691 * Encrypts a message.
23692 *
23693 * @param {Cipher} cipher The cipher algorithm to use.
23694 * @param {WordArray|string} message The message to encrypt.
23695 * @param {WordArray} key The key.
23696 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23697 *
23698 * @return {CipherParams} A cipher params object.
23699 *
23700 * @static
23701 *
23702 * @example
23703 *
23704 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
23705 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
23706 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23707 */
23708 encrypt: function (cipher, message, key, cfg) {
23709 // Apply config defaults
23710 cfg = this.cfg.extend(cfg);
23711
23712 // Encrypt
23713 var encryptor = cipher.createEncryptor(key, cfg);
23714 var ciphertext = encryptor.finalize(message);
23715
23716 // Shortcut
23717 var cipherCfg = encryptor.cfg;
23718
23719 // Create and return serializable cipher params
23720 return CipherParams.create({
23721 ciphertext: ciphertext,
23722 key: key,
23723 iv: cipherCfg.iv,
23724 algorithm: cipher,
23725 mode: cipherCfg.mode,
23726 padding: cipherCfg.padding,
23727 blockSize: cipher.blockSize,
23728 formatter: cfg.format
23729 });
23730 },
23731
23732 /**
23733 * Decrypts serialized ciphertext.
23734 *
23735 * @param {Cipher} cipher The cipher algorithm to use.
23736 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
23737 * @param {WordArray} key The key.
23738 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23739 *
23740 * @return {WordArray} The plaintext.
23741 *
23742 * @static
23743 *
23744 * @example
23745 *
23746 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23747 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23748 */
23749 decrypt: function (cipher, ciphertext, key, cfg) {
23750 // Apply config defaults
23751 cfg = this.cfg.extend(cfg);
23752
23753 // Convert string to CipherParams
23754 ciphertext = this._parse(ciphertext, cfg.format);
23755
23756 // Decrypt
23757 var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
23758
23759 return plaintext;
23760 },
23761
23762 /**
23763 * Converts serialized ciphertext to CipherParams,
23764 * else assumed CipherParams already and returns ciphertext unchanged.
23765 *
23766 * @param {CipherParams|string} ciphertext The ciphertext.
23767 * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
23768 *
23769 * @return {CipherParams} The unserialized ciphertext.
23770 *
23771 * @static
23772 *
23773 * @example
23774 *
23775 * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
23776 */
23777 _parse: function (ciphertext, format) {
23778 if (typeof ciphertext == 'string') {
23779 return format.parse(ciphertext, this);
23780 } else {
23781 return ciphertext;
23782 }
23783 }
23784 });
23785
23786 /**
23787 * Key derivation function namespace.
23788 */
23789 var C_kdf = C.kdf = {};
23790
23791 /**
23792 * OpenSSL key derivation function.
23793 */
23794 var OpenSSLKdf = C_kdf.OpenSSL = {
23795 /**
23796 * Derives a key and IV from a password.
23797 *
23798 * @param {string} password The password to derive from.
23799 * @param {number} keySize The size in words of the key to generate.
23800 * @param {number} ivSize The size in words of the IV to generate.
23801 * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
23802 *
23803 * @return {CipherParams} A cipher params object with the key, IV, and salt.
23804 *
23805 * @static
23806 *
23807 * @example
23808 *
23809 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
23810 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
23811 */
23812 execute: function (password, keySize, ivSize, salt) {
23813 // Generate random salt
23814 if (!salt) {
23815 salt = WordArray.random(64/8);
23816 }
23817
23818 // Derive key and IV
23819 var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
23820
23821 // Separate key and IV
23822 var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
23823 key.sigBytes = keySize * 4;
23824
23825 // Return params
23826 return CipherParams.create({ key: key, iv: iv, salt: salt });
23827 }
23828 };
23829
23830 /**
23831 * A serializable cipher wrapper that derives the key from a password,
23832 * and returns ciphertext as a serializable cipher params object.
23833 */
23834 var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
23835 /**
23836 * Configuration options.
23837 *
23838 * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
23839 */
23840 cfg: SerializableCipher.cfg.extend({
23841 kdf: OpenSSLKdf
23842 }),
23843
23844 /**
23845 * Encrypts a message using a password.
23846 *
23847 * @param {Cipher} cipher The cipher algorithm to use.
23848 * @param {WordArray|string} message The message to encrypt.
23849 * @param {string} password The password.
23850 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23851 *
23852 * @return {CipherParams} A cipher params object.
23853 *
23854 * @static
23855 *
23856 * @example
23857 *
23858 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
23859 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
23860 */
23861 encrypt: function (cipher, message, password, cfg) {
23862 // Apply config defaults
23863 cfg = this.cfg.extend(cfg);
23864
23865 // Derive key and other params
23866 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
23867
23868 // Add IV to config
23869 cfg.iv = derivedParams.iv;
23870
23871 // Encrypt
23872 var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
23873
23874 // Mix in derived params
23875 ciphertext.mixIn(derivedParams);
23876
23877 return ciphertext;
23878 },
23879
23880 /**
23881 * Decrypts serialized ciphertext using a password.
23882 *
23883 * @param {Cipher} cipher The cipher algorithm to use.
23884 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
23885 * @param {string} password The password.
23886 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23887 *
23888 * @return {WordArray} The plaintext.
23889 *
23890 * @static
23891 *
23892 * @example
23893 *
23894 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
23895 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
23896 */
23897 decrypt: function (cipher, ciphertext, password, cfg) {
23898 // Apply config defaults
23899 cfg = this.cfg.extend(cfg);
23900
23901 // Convert string to CipherParams
23902 ciphertext = this._parse(ciphertext, cfg.format);
23903
23904 // Derive key and other params
23905 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
23906
23907 // Add IV to config
23908 cfg.iv = derivedParams.iv;
23909
23910 // Decrypt
23911 var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
23912
23913 return plaintext;
23914 }
23915 });
23916 }());
23917
23918
23919 }));
23920 },{"./core":31}],31:[function(_dereq_,module,exports){
23921 ;(function (root, factory) {
23922 if (typeof exports === "object") {
23923 // CommonJS
23924 module.exports = exports = factory();
23925 }
23926 else if (typeof define === "function" && define.amd) {
23927 // AMD
23928 define([], factory);
23929 }
23930 else {
23931 // Global (browser)
23932 root.CryptoJS = factory();
23933 }
23934 }(this, function () {
23935
23936 /**
23937 * CryptoJS core components.
23938 */
23939 var CryptoJS = CryptoJS || (function (Math, undefined) {
23940 /**
23941 * CryptoJS namespace.
23942 */
23943 var C = {};
23944
23945 /**
23946 * Library namespace.
23947 */
23948 var C_lib = C.lib = {};
23949
23950 /**
23951 * Base object for prototypal inheritance.
23952 */
23953 var Base = C_lib.Base = (function () {
23954 function F() {}
23955
23956 return {
23957 /**
23958 * Creates a new object that inherits from this object.
23959 *
23960 * @param {Object} overrides Properties to copy into the new object.
23961 *
23962 * @return {Object} The new object.
23963 *
23964 * @static
23965 *
23966 * @example
23967 *
23968 * var MyType = CryptoJS.lib.Base.extend({
23969 * field: 'value',
23970 *
23971 * method: function () {
23972 * }
23973 * });
23974 */
23975 extend: function (overrides) {
23976 // Spawn
23977 F.prototype = this;
23978 var subtype = new F();
23979
23980 // Augment
23981 if (overrides) {
23982 subtype.mixIn(overrides);
23983 }
23984
23985 // Create default initializer
23986 if (!subtype.hasOwnProperty('init')) {
23987 subtype.init = function () {
23988 subtype.$super.init.apply(this, arguments);
23989 };
23990 }
23991
23992 // Initializer's prototype is the subtype object
23993 subtype.init.prototype = subtype;
23994
23995 // Reference supertype
23996 subtype.$super = this;
23997
23998 return subtype;
23999 },
24000
24001 /**
24002 * Extends this object and runs the init method.
24003 * Arguments to create() will be passed to init().
24004 *
24005 * @return {Object} The new object.
24006 *
24007 * @static
24008 *
24009 * @example
24010 *
24011 * var instance = MyType.create();
24012 */
24013 create: function () {
24014 var instance = this.extend();
24015 instance.init.apply(instance, arguments);
24016
24017 return instance;
24018 },
24019
24020 /**
24021 * Initializes a newly created object.
24022 * Override this method to add some logic when your objects are created.
24023 *
24024 * @example
24025 *
24026 * var MyType = CryptoJS.lib.Base.extend({
24027 * init: function () {
24028 * // ...
24029 * }
24030 * });
24031 */
24032 init: function () {
24033 },
24034
24035 /**
24036 * Copies properties into this object.
24037 *
24038 * @param {Object} properties The properties to mix in.
24039 *
24040 * @example
24041 *
24042 * MyType.mixIn({
24043 * field: 'value'
24044 * });
24045 */
24046 mixIn: function (properties) {
24047 for (var propertyName in properties) {
24048 if (properties.hasOwnProperty(propertyName)) {
24049 this[propertyName] = properties[propertyName];
24050 }
24051 }
24052
24053 // IE won't copy toString using the loop above
24054 if (properties.hasOwnProperty('toString')) {
24055 this.toString = properties.toString;
24056 }
24057 },
24058
24059 /**
24060 * Creates a copy of this object.
24061 *
24062 * @return {Object} The clone.
24063 *
24064 * @example
24065 *
24066 * var clone = instance.clone();
24067 */
24068 clone: function () {
24069 return this.init.prototype.extend(this);
24070 }
24071 };
24072 }());
24073
24074 /**
24075 * An array of 32-bit words.
24076 *
24077 * @property {Array} words The array of 32-bit words.
24078 * @property {number} sigBytes The number of significant bytes in this word array.
24079 */
24080 var WordArray = C_lib.WordArray = Base.extend({
24081 /**
24082 * Initializes a newly created word array.
24083 *
24084 * @param {Array} words (Optional) An array of 32-bit words.
24085 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
24086 *
24087 * @example
24088 *
24089 * var wordArray = CryptoJS.lib.WordArray.create();
24090 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
24091 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
24092 */
24093 init: function (words, sigBytes) {
24094 words = this.words = words || [];
24095
24096 if (sigBytes != undefined) {
24097 this.sigBytes = sigBytes;
24098 } else {
24099 this.sigBytes = words.length * 4;
24100 }
24101 },
24102
24103 /**
24104 * Converts this word array to a string.
24105 *
24106 * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
24107 *
24108 * @return {string} The stringified word array.
24109 *
24110 * @example
24111 *
24112 * var string = wordArray + '';
24113 * var string = wordArray.toString();
24114 * var string = wordArray.toString(CryptoJS.enc.Utf8);
24115 */
24116 toString: function (encoder) {
24117 return (encoder || Hex).stringify(this);
24118 },
24119
24120 /**
24121 * Concatenates a word array to this word array.
24122 *
24123 * @param {WordArray} wordArray The word array to append.
24124 *
24125 * @return {WordArray} This word array.
24126 *
24127 * @example
24128 *
24129 * wordArray1.concat(wordArray2);
24130 */
24131 concat: function (wordArray) {
24132 // Shortcuts
24133 var thisWords = this.words;
24134 var thatWords = wordArray.words;
24135 var thisSigBytes = this.sigBytes;
24136 var thatSigBytes = wordArray.sigBytes;
24137
24138 // Clamp excess bits
24139 this.clamp();
24140
24141 // Concat
24142 if (thisSigBytes % 4) {
24143 // Copy one byte at a time
24144 for (var i = 0; i < thatSigBytes; i++) {
24145 var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24146 thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
24147 }
24148 } else if (thatWords.length > 0xffff) {
24149 // Copy one word at a time
24150 for (var i = 0; i < thatSigBytes; i += 4) {
24151 thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
24152 }
24153 } else {
24154 // Copy all words at once
24155 thisWords.push.apply(thisWords, thatWords);
24156 }
24157 this.sigBytes += thatSigBytes;
24158
24159 // Chainable
24160 return this;
24161 },
24162
24163 /**
24164 * Removes insignificant bits.
24165 *
24166 * @example
24167 *
24168 * wordArray.clamp();
24169 */
24170 clamp: function () {
24171 // Shortcuts
24172 var words = this.words;
24173 var sigBytes = this.sigBytes;
24174
24175 // Clamp
24176 words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
24177 words.length = Math.ceil(sigBytes / 4);
24178 },
24179
24180 /**
24181 * Creates a copy of this word array.
24182 *
24183 * @return {WordArray} The clone.
24184 *
24185 * @example
24186 *
24187 * var clone = wordArray.clone();
24188 */
24189 clone: function () {
24190 var clone = Base.clone.call(this);
24191 clone.words = this.words.slice(0);
24192
24193 return clone;
24194 },
24195
24196 /**
24197 * Creates a word array filled with random bytes.
24198 *
24199 * @param {number} nBytes The number of random bytes to generate.
24200 *
24201 * @return {WordArray} The random word array.
24202 *
24203 * @static
24204 *
24205 * @example
24206 *
24207 * var wordArray = CryptoJS.lib.WordArray.random(16);
24208 */
24209 random: function (nBytes) {
24210 var words = [];
24211 for (var i = 0; i < nBytes; i += 4) {
24212 words.push((Math.random() * 0x100000000) | 0);
24213 }
24214
24215 return new WordArray.init(words, nBytes);
24216 }
24217 });
24218
24219 /**
24220 * Encoder namespace.
24221 */
24222 var C_enc = C.enc = {};
24223
24224 /**
24225 * Hex encoding strategy.
24226 */
24227 var Hex = C_enc.Hex = {
24228 /**
24229 * Converts a word array to a hex string.
24230 *
24231 * @param {WordArray} wordArray The word array.
24232 *
24233 * @return {string} The hex string.
24234 *
24235 * @static
24236 *
24237 * @example
24238 *
24239 * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
24240 */
24241 stringify: function (wordArray) {
24242 // Shortcuts
24243 var words = wordArray.words;
24244 var sigBytes = wordArray.sigBytes;
24245
24246 // Convert
24247 var hexChars = [];
24248 for (var i = 0; i < sigBytes; i++) {
24249 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24250 hexChars.push((bite >>> 4).toString(16));
24251 hexChars.push((bite & 0x0f).toString(16));
24252 }
24253
24254 return hexChars.join('');
24255 },
24256
24257 /**
24258 * Converts a hex string to a word array.
24259 *
24260 * @param {string} hexStr The hex string.
24261 *
24262 * @return {WordArray} The word array.
24263 *
24264 * @static
24265 *
24266 * @example
24267 *
24268 * var wordArray = CryptoJS.enc.Hex.parse(hexString);
24269 */
24270 parse: function (hexStr) {
24271 // Shortcut
24272 var hexStrLength = hexStr.length;
24273
24274 // Convert
24275 var words = [];
24276 for (var i = 0; i < hexStrLength; i += 2) {
24277 words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
24278 }
24279
24280 return new WordArray.init(words, hexStrLength / 2);
24281 }
24282 };
24283
24284 /**
24285 * Latin1 encoding strategy.
24286 */
24287 var Latin1 = C_enc.Latin1 = {
24288 /**
24289 * Converts a word array to a Latin1 string.
24290 *
24291 * @param {WordArray} wordArray The word array.
24292 *
24293 * @return {string} The Latin1 string.
24294 *
24295 * @static
24296 *
24297 * @example
24298 *
24299 * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
24300 */
24301 stringify: function (wordArray) {
24302 // Shortcuts
24303 var words = wordArray.words;
24304 var sigBytes = wordArray.sigBytes;
24305
24306 // Convert
24307 var latin1Chars = [];
24308 for (var i = 0; i < sigBytes; i++) {
24309 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24310 latin1Chars.push(String.fromCharCode(bite));
24311 }
24312
24313 return latin1Chars.join('');
24314 },
24315
24316 /**
24317 * Converts a Latin1 string to a word array.
24318 *
24319 * @param {string} latin1Str The Latin1 string.
24320 *
24321 * @return {WordArray} The word array.
24322 *
24323 * @static
24324 *
24325 * @example
24326 *
24327 * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
24328 */
24329 parse: function (latin1Str) {
24330 // Shortcut
24331 var latin1StrLength = latin1Str.length;
24332
24333 // Convert
24334 var words = [];
24335 for (var i = 0; i < latin1StrLength; i++) {
24336 words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
24337 }
24338
24339 return new WordArray.init(words, latin1StrLength);
24340 }
24341 };
24342
24343 /**
24344 * UTF-8 encoding strategy.
24345 */
24346 var Utf8 = C_enc.Utf8 = {
24347 /**
24348 * Converts a word array to a UTF-8 string.
24349 *
24350 * @param {WordArray} wordArray The word array.
24351 *
24352 * @return {string} The UTF-8 string.
24353 *
24354 * @static
24355 *
24356 * @example
24357 *
24358 * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
24359 */
24360 stringify: function (wordArray) {
24361 try {
24362 return decodeURIComponent(escape(Latin1.stringify(wordArray)));
24363 } catch (e) {
24364 throw new Error('Malformed UTF-8 data');
24365 }
24366 },
24367
24368 /**
24369 * Converts a UTF-8 string to a word array.
24370 *
24371 * @param {string} utf8Str The UTF-8 string.
24372 *
24373 * @return {WordArray} The word array.
24374 *
24375 * @static
24376 *
24377 * @example
24378 *
24379 * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
24380 */
24381 parse: function (utf8Str) {
24382 return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
24383 }
24384 };
24385
24386 /**
24387 * Abstract buffered block algorithm template.
24388 *
24389 * The property blockSize must be implemented in a concrete subtype.
24390 *
24391 * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
24392 */
24393 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
24394 /**
24395 * Resets this block algorithm's data buffer to its initial state.
24396 *
24397 * @example
24398 *
24399 * bufferedBlockAlgorithm.reset();
24400 */
24401 reset: function () {
24402 // Initial values
24403 this._data = new WordArray.init();
24404 this._nDataBytes = 0;
24405 },
24406
24407 /**
24408 * Adds new data to this block algorithm's buffer.
24409 *
24410 * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
24411 *
24412 * @example
24413 *
24414 * bufferedBlockAlgorithm._append('data');
24415 * bufferedBlockAlgorithm._append(wordArray);
24416 */
24417 _append: function (data) {
24418 // Convert string to WordArray, else assume WordArray already
24419 if (typeof data == 'string') {
24420 data = Utf8.parse(data);
24421 }
24422
24423 // Append
24424 this._data.concat(data);
24425 this._nDataBytes += data.sigBytes;
24426 },
24427
24428 /**
24429 * Processes available data blocks.
24430 *
24431 * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
24432 *
24433 * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
24434 *
24435 * @return {WordArray} The processed data.
24436 *
24437 * @example
24438 *
24439 * var processedData = bufferedBlockAlgorithm._process();
24440 * var processedData = bufferedBlockAlgorithm._process(!!'flush');
24441 */
24442 _process: function (doFlush) {
24443 // Shortcuts
24444 var data = this._data;
24445 var dataWords = data.words;
24446 var dataSigBytes = data.sigBytes;
24447 var blockSize = this.blockSize;
24448 var blockSizeBytes = blockSize * 4;
24449
24450 // Count blocks ready
24451 var nBlocksReady = dataSigBytes / blockSizeBytes;
24452 if (doFlush) {
24453 // Round up to include partial blocks
24454 nBlocksReady = Math.ceil(nBlocksReady);
24455 } else {
24456 // Round down to include only full blocks,
24457 // less the number of blocks that must remain in the buffer
24458 nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
24459 }
24460
24461 // Count words ready
24462 var nWordsReady = nBlocksReady * blockSize;
24463
24464 // Count bytes ready
24465 var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
24466
24467 // Process blocks
24468 if (nWordsReady) {
24469 for (var offset = 0; offset < nWordsReady; offset += blockSize) {
24470 // Perform concrete-algorithm logic
24471 this._doProcessBlock(dataWords, offset);
24472 }
24473
24474 // Remove processed words
24475 var processedWords = dataWords.splice(0, nWordsReady);
24476 data.sigBytes -= nBytesReady;
24477 }
24478
24479 // Return processed words
24480 return new WordArray.init(processedWords, nBytesReady);
24481 },
24482
24483 /**
24484 * Creates a copy of this object.
24485 *
24486 * @return {Object} The clone.
24487 *
24488 * @example
24489 *
24490 * var clone = bufferedBlockAlgorithm.clone();
24491 */
24492 clone: function () {
24493 var clone = Base.clone.call(this);
24494 clone._data = this._data.clone();
24495
24496 return clone;
24497 },
24498
24499 _minBufferSize: 0
24500 });
24501
24502 /**
24503 * Abstract hasher template.
24504 *
24505 * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
24506 */
24507 var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
24508 /**
24509 * Configuration options.
24510 */
24511 cfg: Base.extend(),
24512
24513 /**
24514 * Initializes a newly created hasher.
24515 *
24516 * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
24517 *
24518 * @example
24519 *
24520 * var hasher = CryptoJS.algo.SHA256.create();
24521 */
24522 init: function (cfg) {
24523 // Apply config defaults
24524 this.cfg = this.cfg.extend(cfg);
24525
24526 // Set initial values
24527 this.reset();
24528 },
24529
24530 /**
24531 * Resets this hasher to its initial state.
24532 *
24533 * @example
24534 *
24535 * hasher.reset();
24536 */
24537 reset: function () {
24538 // Reset data buffer
24539 BufferedBlockAlgorithm.reset.call(this);
24540
24541 // Perform concrete-hasher logic
24542 this._doReset();
24543 },
24544
24545 /**
24546 * Updates this hasher with a message.
24547 *
24548 * @param {WordArray|string} messageUpdate The message to append.
24549 *
24550 * @return {Hasher} This hasher.
24551 *
24552 * @example
24553 *
24554 * hasher.update('message');
24555 * hasher.update(wordArray);
24556 */
24557 update: function (messageUpdate) {
24558 // Append
24559 this._append(messageUpdate);
24560
24561 // Update the hash
24562 this._process();
24563
24564 // Chainable
24565 return this;
24566 },
24567
24568 /**
24569 * Finalizes the hash computation.
24570 * Note that the finalize operation is effectively a destructive, read-once operation.
24571 *
24572 * @param {WordArray|string} messageUpdate (Optional) A final message update.
24573 *
24574 * @return {WordArray} The hash.
24575 *
24576 * @example
24577 *
24578 * var hash = hasher.finalize();
24579 * var hash = hasher.finalize('message');
24580 * var hash = hasher.finalize(wordArray);
24581 */
24582 finalize: function (messageUpdate) {
24583 // Final message update
24584 if (messageUpdate) {
24585 this._append(messageUpdate);
24586 }
24587
24588 // Perform concrete-hasher logic
24589 var hash = this._doFinalize();
24590
24591 return hash;
24592 },
24593
24594 blockSize: 512/32,
24595
24596 /**
24597 * Creates a shortcut function to a hasher's object interface.
24598 *
24599 * @param {Hasher} hasher The hasher to create a helper for.
24600 *
24601 * @return {Function} The shortcut function.
24602 *
24603 * @static
24604 *
24605 * @example
24606 *
24607 * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
24608 */
24609 _createHelper: function (hasher) {
24610 return function (message, cfg) {
24611 return new hasher.init(cfg).finalize(message);
24612 };
24613 },
24614
24615 /**
24616 * Creates a shortcut function to the HMAC's object interface.
24617 *
24618 * @param {Hasher} hasher The hasher to use in this HMAC helper.
24619 *
24620 * @return {Function} The shortcut function.
24621 *
24622 * @static
24623 *
24624 * @example
24625 *
24626 * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
24627 */
24628 _createHmacHelper: function (hasher) {
24629 return function (message, key) {
24630 return new C_algo.HMAC.init(hasher, key).finalize(message);
24631 };
24632 }
24633 });
24634
24635 /**
24636 * Algorithm namespace.
24637 */
24638 var C_algo = C.algo = {};
24639
24640 return C;
24641 }(Math));
24642
24643
24644 return CryptoJS;
24645
24646 }));
24647 },{}],32:[function(_dereq_,module,exports){
24648 ;(function (root, factory) {
24649 if (typeof exports === "object") {
24650 // CommonJS
24651 module.exports = exports = factory(_dereq_("./core"));
24652 }
24653 else if (typeof define === "function" && define.amd) {
24654 // AMD
24655 define(["./core"], factory);
24656 }
24657 else {
24658 // Global (browser)
24659 factory(root.CryptoJS);
24660 }
24661 }(this, function (CryptoJS) {
24662
24663 (function () {
24664 // Shortcuts
24665 var C = CryptoJS;
24666 var C_lib = C.lib;
24667 var WordArray = C_lib.WordArray;
24668 var C_enc = C.enc;
24669
24670 /**
24671 * Base64 encoding strategy.
24672 */
24673 var Base64 = C_enc.Base64 = {
24674 /**
24675 * Converts a word array to a Base64 string.
24676 *
24677 * @param {WordArray} wordArray The word array.
24678 *
24679 * @return {string} The Base64 string.
24680 *
24681 * @static
24682 *
24683 * @example
24684 *
24685 * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
24686 */
24687 stringify: function (wordArray) {
24688 // Shortcuts
24689 var words = wordArray.words;
24690 var sigBytes = wordArray.sigBytes;
24691 var map = this._map;
24692
24693 // Clamp excess bits
24694 wordArray.clamp();
24695
24696 // Convert
24697 var base64Chars = [];
24698 for (var i = 0; i < sigBytes; i += 3) {
24699 var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24700 var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
24701 var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
24702
24703 var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
24704
24705 for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
24706 base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
24707 }
24708 }
24709
24710 // Add padding
24711 var paddingChar = map.charAt(64);
24712 if (paddingChar) {
24713 while (base64Chars.length % 4) {
24714 base64Chars.push(paddingChar);
24715 }
24716 }
24717
24718 return base64Chars.join('');
24719 },
24720
24721 /**
24722 * Converts a Base64 string to a word array.
24723 *
24724 * @param {string} base64Str The Base64 string.
24725 *
24726 * @return {WordArray} The word array.
24727 *
24728 * @static
24729 *
24730 * @example
24731 *
24732 * var wordArray = CryptoJS.enc.Base64.parse(base64String);
24733 */
24734 parse: function (base64Str) {
24735 // Shortcuts
24736 var base64StrLength = base64Str.length;
24737 var map = this._map;
24738
24739 // Ignore padding
24740 var paddingChar = map.charAt(64);
24741 if (paddingChar) {
24742 var paddingIndex = base64Str.indexOf(paddingChar);
24743 if (paddingIndex != -1) {
24744 base64StrLength = paddingIndex;
24745 }
24746 }
24747
24748 // Convert
24749 var words = [];
24750 var nBytes = 0;
24751 for (var i = 0; i < base64StrLength; i++) {
24752 if (i % 4) {
24753 var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2);
24754 var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2);
24755 words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
24756 nBytes++;
24757 }
24758 }
24759
24760 return WordArray.create(words, nBytes);
24761 },
24762
24763 _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
24764 };
24765 }());
24766
24767
24768 return CryptoJS.enc.Base64;
24769
24770 }));
24771 },{"./core":31}],33:[function(_dereq_,module,exports){
24772 ;(function (root, factory) {
24773 if (typeof exports === "object") {
24774 // CommonJS
24775 module.exports = exports = factory(_dereq_("./core"));
24776 }
24777 else if (typeof define === "function" && define.amd) {
24778 // AMD
24779 define(["./core"], factory);
24780 }
24781 else {
24782 // Global (browser)
24783 factory(root.CryptoJS);
24784 }
24785 }(this, function (CryptoJS) {
24786
24787 (function () {
24788 // Shortcuts
24789 var C = CryptoJS;
24790 var C_lib = C.lib;
24791 var WordArray = C_lib.WordArray;
24792 var C_enc = C.enc;
24793
24794 /**
24795 * UTF-16 BE encoding strategy.
24796 */
24797 var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
24798 /**
24799 * Converts a word array to a UTF-16 BE string.
24800 *
24801 * @param {WordArray} wordArray The word array.
24802 *
24803 * @return {string} The UTF-16 BE string.
24804 *
24805 * @static
24806 *
24807 * @example
24808 *
24809 * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
24810 */
24811 stringify: function (wordArray) {
24812 // Shortcuts
24813 var words = wordArray.words;
24814 var sigBytes = wordArray.sigBytes;
24815
24816 // Convert
24817 var utf16Chars = [];
24818 for (var i = 0; i < sigBytes; i += 2) {
24819 var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
24820 utf16Chars.push(String.fromCharCode(codePoint));
24821 }
24822
24823 return utf16Chars.join('');
24824 },
24825
24826 /**
24827 * Converts a UTF-16 BE string to a word array.
24828 *
24829 * @param {string} utf16Str The UTF-16 BE string.
24830 *
24831 * @return {WordArray} The word array.
24832 *
24833 * @static
24834 *
24835 * @example
24836 *
24837 * var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
24838 */
24839 parse: function (utf16Str) {
24840 // Shortcut
24841 var utf16StrLength = utf16Str.length;
24842
24843 // Convert
24844 var words = [];
24845 for (var i = 0; i < utf16StrLength; i++) {
24846 words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
24847 }
24848
24849 return WordArray.create(words, utf16StrLength * 2);
24850 }
24851 };
24852
24853 /**
24854 * UTF-16 LE encoding strategy.
24855 */
24856 C_enc.Utf16LE = {
24857 /**
24858 * Converts a word array to a UTF-16 LE string.
24859 *
24860 * @param {WordArray} wordArray The word array.
24861 *
24862 * @return {string} The UTF-16 LE string.
24863 *
24864 * @static
24865 *
24866 * @example
24867 *
24868 * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
24869 */
24870 stringify: function (wordArray) {
24871 // Shortcuts
24872 var words = wordArray.words;
24873 var sigBytes = wordArray.sigBytes;
24874
24875 // Convert
24876 var utf16Chars = [];
24877 for (var i = 0; i < sigBytes; i += 2) {
24878 var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
24879 utf16Chars.push(String.fromCharCode(codePoint));
24880 }
24881
24882 return utf16Chars.join('');
24883 },
24884
24885 /**
24886 * Converts a UTF-16 LE string to a word array.
24887 *
24888 * @param {string} utf16Str The UTF-16 LE string.
24889 *
24890 * @return {WordArray} The word array.
24891 *
24892 * @static
24893 *
24894 * @example
24895 *
24896 * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
24897 */
24898 parse: function (utf16Str) {
24899 // Shortcut
24900 var utf16StrLength = utf16Str.length;
24901
24902 // Convert
24903 var words = [];
24904 for (var i = 0; i < utf16StrLength; i++) {
24905 words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
24906 }
24907
24908 return WordArray.create(words, utf16StrLength * 2);
24909 }
24910 };
24911
24912 function swapEndian(word) {
24913 return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
24914 }
24915 }());
24916
24917
24918 return CryptoJS.enc.Utf16;
24919
24920 }));
24921 },{"./core":31}],34:[function(_dereq_,module,exports){
24922 ;(function (root, factory, undef) {
24923 if (typeof exports === "object") {
24924 // CommonJS
24925 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
24926 }
24927 else if (typeof define === "function" && define.amd) {
24928 // AMD
24929 define(["./core", "./sha1", "./hmac"], factory);
24930 }
24931 else {
24932 // Global (browser)
24933 factory(root.CryptoJS);
24934 }
24935 }(this, function (CryptoJS) {
24936
24937 (function () {
24938 // Shortcuts
24939 var C = CryptoJS;
24940 var C_lib = C.lib;
24941 var Base = C_lib.Base;
24942 var WordArray = C_lib.WordArray;
24943 var C_algo = C.algo;
24944 var MD5 = C_algo.MD5;
24945
24946 /**
24947 * This key derivation function is meant to conform with EVP_BytesToKey.
24948 * www.openssl.org/docs/crypto/EVP_BytesToKey.html
24949 */
24950 var EvpKDF = C_algo.EvpKDF = Base.extend({
24951 /**
24952 * Configuration options.
24953 *
24954 * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
24955 * @property {Hasher} hasher The hash algorithm to use. Default: MD5
24956 * @property {number} iterations The number of iterations to perform. Default: 1
24957 */
24958 cfg: Base.extend({
24959 keySize: 128/32,
24960 hasher: MD5,
24961 iterations: 1
24962 }),
24963
24964 /**
24965 * Initializes a newly created key derivation function.
24966 *
24967 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
24968 *
24969 * @example
24970 *
24971 * var kdf = CryptoJS.algo.EvpKDF.create();
24972 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
24973 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
24974 */
24975 init: function (cfg) {
24976 this.cfg = this.cfg.extend(cfg);
24977 },
24978
24979 /**
24980 * Derives a key from a password.
24981 *
24982 * @param {WordArray|string} password The password.
24983 * @param {WordArray|string} salt A salt.
24984 *
24985 * @return {WordArray} The derived key.
24986 *
24987 * @example
24988 *
24989 * var key = kdf.compute(password, salt);
24990 */
24991 compute: function (password, salt) {
24992 // Shortcut
24993 var cfg = this.cfg;
24994
24995 // Init hasher
24996 var hasher = cfg.hasher.create();
24997
24998 // Initial values
24999 var derivedKey = WordArray.create();
25000
25001 // Shortcuts
25002 var derivedKeyWords = derivedKey.words;
25003 var keySize = cfg.keySize;
25004 var iterations = cfg.iterations;
25005
25006 // Generate key
25007 while (derivedKeyWords.length < keySize) {
25008 if (block) {
25009 hasher.update(block);
25010 }
25011 var block = hasher.update(password).finalize(salt);
25012 hasher.reset();
25013
25014 // Iterations
25015 for (var i = 1; i < iterations; i++) {
25016 block = hasher.finalize(block);
25017 hasher.reset();
25018 }
25019
25020 derivedKey.concat(block);
25021 }
25022 derivedKey.sigBytes = keySize * 4;
25023
25024 return derivedKey;
25025 }
25026 });
25027
25028 /**
25029 * Derives a key from a password.
25030 *
25031 * @param {WordArray|string} password The password.
25032 * @param {WordArray|string} salt A salt.
25033 * @param {Object} cfg (Optional) The configuration options to use for this computation.
25034 *
25035 * @return {WordArray} The derived key.
25036 *
25037 * @static
25038 *
25039 * @example
25040 *
25041 * var key = CryptoJS.EvpKDF(password, salt);
25042 * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
25043 * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
25044 */
25045 C.EvpKDF = function (password, salt, cfg) {
25046 return EvpKDF.create(cfg).compute(password, salt);
25047 };
25048 }());
25049
25050
25051 return CryptoJS.EvpKDF;
25052
25053 }));
25054 },{"./core":31,"./hmac":36,"./sha1":55}],35:[function(_dereq_,module,exports){
25055 ;(function (root, factory, undef) {
25056 if (typeof exports === "object") {
25057 // CommonJS
25058 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25059 }
25060 else if (typeof define === "function" && define.amd) {
25061 // AMD
25062 define(["./core", "./cipher-core"], factory);
25063 }
25064 else {
25065 // Global (browser)
25066 factory(root.CryptoJS);
25067 }
25068 }(this, function (CryptoJS) {
25069
25070 (function (undefined) {
25071 // Shortcuts
25072 var C = CryptoJS;
25073 var C_lib = C.lib;
25074 var CipherParams = C_lib.CipherParams;
25075 var C_enc = C.enc;
25076 var Hex = C_enc.Hex;
25077 var C_format = C.format;
25078
25079 var HexFormatter = C_format.Hex = {
25080 /**
25081 * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
25082 *
25083 * @param {CipherParams} cipherParams The cipher params object.
25084 *
25085 * @return {string} The hexadecimally encoded string.
25086 *
25087 * @static
25088 *
25089 * @example
25090 *
25091 * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
25092 */
25093 stringify: function (cipherParams) {
25094 return cipherParams.ciphertext.toString(Hex);
25095 },
25096
25097 /**
25098 * Converts a hexadecimally encoded ciphertext string to a cipher params object.
25099 *
25100 * @param {string} input The hexadecimally encoded string.
25101 *
25102 * @return {CipherParams} The cipher params object.
25103 *
25104 * @static
25105 *
25106 * @example
25107 *
25108 * var cipherParams = CryptoJS.format.Hex.parse(hexString);
25109 */
25110 parse: function (input) {
25111 var ciphertext = Hex.parse(input);
25112 return CipherParams.create({ ciphertext: ciphertext });
25113 }
25114 };
25115 }());
25116
25117
25118 return CryptoJS.format.Hex;
25119
25120 }));
25121 },{"./cipher-core":30,"./core":31}],36:[function(_dereq_,module,exports){
25122 ;(function (root, factory) {
25123 if (typeof exports === "object") {
25124 // CommonJS
25125 module.exports = exports = factory(_dereq_("./core"));
25126 }
25127 else if (typeof define === "function" && define.amd) {
25128 // AMD
25129 define(["./core"], factory);
25130 }
25131 else {
25132 // Global (browser)
25133 factory(root.CryptoJS);
25134 }
25135 }(this, function (CryptoJS) {
25136
25137 (function () {
25138 // Shortcuts
25139 var C = CryptoJS;
25140 var C_lib = C.lib;
25141 var Base = C_lib.Base;
25142 var C_enc = C.enc;
25143 var Utf8 = C_enc.Utf8;
25144 var C_algo = C.algo;
25145
25146 /**
25147 * HMAC algorithm.
25148 */
25149 var HMAC = C_algo.HMAC = Base.extend({
25150 /**
25151 * Initializes a newly created HMAC.
25152 *
25153 * @param {Hasher} hasher The hash algorithm to use.
25154 * @param {WordArray|string} key The secret key.
25155 *
25156 * @example
25157 *
25158 * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
25159 */
25160 init: function (hasher, key) {
25161 // Init hasher
25162 hasher = this._hasher = new hasher.init();
25163
25164 // Convert string to WordArray, else assume WordArray already
25165 if (typeof key == 'string') {
25166 key = Utf8.parse(key);
25167 }
25168
25169 // Shortcuts
25170 var hasherBlockSize = hasher.blockSize;
25171 var hasherBlockSizeBytes = hasherBlockSize * 4;
25172
25173 // Allow arbitrary length keys
25174 if (key.sigBytes > hasherBlockSizeBytes) {
25175 key = hasher.finalize(key);
25176 }
25177
25178 // Clamp excess bits
25179 key.clamp();
25180
25181 // Clone key for inner and outer pads
25182 var oKey = this._oKey = key.clone();
25183 var iKey = this._iKey = key.clone();
25184
25185 // Shortcuts
25186 var oKeyWords = oKey.words;
25187 var iKeyWords = iKey.words;
25188
25189 // XOR keys with pad constants
25190 for (var i = 0; i < hasherBlockSize; i++) {
25191 oKeyWords[i] ^= 0x5c5c5c5c;
25192 iKeyWords[i] ^= 0x36363636;
25193 }
25194 oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
25195
25196 // Set initial values
25197 this.reset();
25198 },
25199
25200 /**
25201 * Resets this HMAC to its initial state.
25202 *
25203 * @example
25204 *
25205 * hmacHasher.reset();
25206 */
25207 reset: function () {
25208 // Shortcut
25209 var hasher = this._hasher;
25210
25211 // Reset
25212 hasher.reset();
25213 hasher.update(this._iKey);
25214 },
25215
25216 /**
25217 * Updates this HMAC with a message.
25218 *
25219 * @param {WordArray|string} messageUpdate The message to append.
25220 *
25221 * @return {HMAC} This HMAC instance.
25222 *
25223 * @example
25224 *
25225 * hmacHasher.update('message');
25226 * hmacHasher.update(wordArray);
25227 */
25228 update: function (messageUpdate) {
25229 this._hasher.update(messageUpdate);
25230
25231 // Chainable
25232 return this;
25233 },
25234
25235 /**
25236 * Finalizes the HMAC computation.
25237 * Note that the finalize operation is effectively a destructive, read-once operation.
25238 *
25239 * @param {WordArray|string} messageUpdate (Optional) A final message update.
25240 *
25241 * @return {WordArray} The HMAC.
25242 *
25243 * @example
25244 *
25245 * var hmac = hmacHasher.finalize();
25246 * var hmac = hmacHasher.finalize('message');
25247 * var hmac = hmacHasher.finalize(wordArray);
25248 */
25249 finalize: function (messageUpdate) {
25250 // Shortcut
25251 var hasher = this._hasher;
25252
25253 // Compute HMAC
25254 var innerHash = hasher.finalize(messageUpdate);
25255 hasher.reset();
25256 var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
25257
25258 return hmac;
25259 }
25260 });
25261 }());
25262
25263
25264 }));
25265 },{"./core":31}],37:[function(_dereq_,module,exports){
25266 ;(function (root, factory, undef) {
25267 if (typeof exports === "object") {
25268 // CommonJS
25269 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"), _dereq_("./lib-typedarrays"), _dereq_("./enc-utf16"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./sha1"), _dereq_("./sha256"), _dereq_("./sha224"), _dereq_("./sha512"), _dereq_("./sha384"), _dereq_("./sha3"), _dereq_("./ripemd160"), _dereq_("./hmac"), _dereq_("./pbkdf2"), _dereq_("./evpkdf"), _dereq_("./cipher-core"), _dereq_("./mode-cfb"), _dereq_("./mode-ctr"), _dereq_("./mode-ctr-gladman"), _dereq_("./mode-ofb"), _dereq_("./mode-ecb"), _dereq_("./pad-ansix923"), _dereq_("./pad-iso10126"), _dereq_("./pad-iso97971"), _dereq_("./pad-zeropadding"), _dereq_("./pad-nopadding"), _dereq_("./format-hex"), _dereq_("./aes"), _dereq_("./tripledes"), _dereq_("./rc4"), _dereq_("./rabbit"), _dereq_("./rabbit-legacy"));
25270 }
25271 else if (typeof define === "function" && define.amd) {
25272 // AMD
25273 define(["./core", "./x64-core", "./lib-typedarrays", "./enc-utf16", "./enc-base64", "./md5", "./sha1", "./sha256", "./sha224", "./sha512", "./sha384", "./sha3", "./ripemd160", "./hmac", "./pbkdf2", "./evpkdf", "./cipher-core", "./mode-cfb", "./mode-ctr", "./mode-ctr-gladman", "./mode-ofb", "./mode-ecb", "./pad-ansix923", "./pad-iso10126", "./pad-iso97971", "./pad-zeropadding", "./pad-nopadding", "./format-hex", "./aes", "./tripledes", "./rc4", "./rabbit", "./rabbit-legacy"], factory);
25274 }
25275 else {
25276 // Global (browser)
25277 factory(root.CryptoJS);
25278 }
25279 }(this, function (CryptoJS) {
25280
25281 return CryptoJS;
25282
25283 }));
25284 },{"./aes":29,"./cipher-core":30,"./core":31,"./enc-base64":32,"./enc-utf16":33,"./evpkdf":34,"./format-hex":35,"./hmac":36,"./lib-typedarrays":38,"./md5":39,"./mode-cfb":40,"./mode-ctr":42,"./mode-ctr-gladman":41,"./mode-ecb":43,"./mode-ofb":44,"./pad-ansix923":45,"./pad-iso10126":46,"./pad-iso97971":47,"./pad-nopadding":48,"./pad-zeropadding":49,"./pbkdf2":50,"./rabbit":52,"./rabbit-legacy":51,"./rc4":53,"./ripemd160":54,"./sha1":55,"./sha224":56,"./sha256":57,"./sha3":58,"./sha384":59,"./sha512":60,"./tripledes":61,"./x64-core":62}],38:[function(_dereq_,module,exports){
25285 ;(function (root, factory) {
25286 if (typeof exports === "object") {
25287 // CommonJS
25288 module.exports = exports = factory(_dereq_("./core"));
25289 }
25290 else if (typeof define === "function" && define.amd) {
25291 // AMD
25292 define(["./core"], factory);
25293 }
25294 else {
25295 // Global (browser)
25296 factory(root.CryptoJS);
25297 }
25298 }(this, function (CryptoJS) {
25299
25300 (function () {
25301 // Check if typed arrays are supported
25302 if (typeof ArrayBuffer != 'function') {
25303 return;
25304 }
25305
25306 // Shortcuts
25307 var C = CryptoJS;
25308 var C_lib = C.lib;
25309 var WordArray = C_lib.WordArray;
25310
25311 // Reference original init
25312 var superInit = WordArray.init;
25313
25314 // Augment WordArray.init to handle typed arrays
25315 var subInit = WordArray.init = function (typedArray) {
25316 // Convert buffers to uint8
25317 if (typedArray instanceof ArrayBuffer) {
25318 typedArray = new Uint8Array(typedArray);
25319 }
25320
25321 // Convert other array views to uint8
25322 if (
25323 typedArray instanceof Int8Array ||
25324 typedArray instanceof Uint8ClampedArray ||
25325 typedArray instanceof Int16Array ||
25326 typedArray instanceof Uint16Array ||
25327 typedArray instanceof Int32Array ||
25328 typedArray instanceof Uint32Array ||
25329 typedArray instanceof Float32Array ||
25330 typedArray instanceof Float64Array
25331 ) {
25332 typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
25333 }
25334
25335 // Handle Uint8Array
25336 if (typedArray instanceof Uint8Array) {
25337 // Shortcut
25338 var typedArrayByteLength = typedArray.byteLength;
25339
25340 // Extract bytes
25341 var words = [];
25342 for (var i = 0; i < typedArrayByteLength; i++) {
25343 words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
25344 }
25345
25346 // Initialize this word array
25347 superInit.call(this, words, typedArrayByteLength);
25348 } else {
25349 // Else call normal init
25350 superInit.apply(this, arguments);
25351 }
25352 };
25353
25354 subInit.prototype = WordArray;
25355 }());
25356
25357
25358 return CryptoJS.lib.WordArray;
25359
25360 }));
25361 },{"./core":31}],39:[function(_dereq_,module,exports){
25362 ;(function (root, factory) {
25363 if (typeof exports === "object") {
25364 // CommonJS
25365 module.exports = exports = factory(_dereq_("./core"));
25366 }
25367 else if (typeof define === "function" && define.amd) {
25368 // AMD
25369 define(["./core"], factory);
25370 }
25371 else {
25372 // Global (browser)
25373 factory(root.CryptoJS);
25374 }
25375 }(this, function (CryptoJS) {
25376
25377 (function (Math) {
25378 // Shortcuts
25379 var C = CryptoJS;
25380 var C_lib = C.lib;
25381 var WordArray = C_lib.WordArray;
25382 var Hasher = C_lib.Hasher;
25383 var C_algo = C.algo;
25384
25385 // Constants table
25386 var T = [];
25387
25388 // Compute constants
25389 (function () {
25390 for (var i = 0; i < 64; i++) {
25391 T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
25392 }
25393 }());
25394
25395 /**
25396 * MD5 hash algorithm.
25397 */
25398 var MD5 = C_algo.MD5 = Hasher.extend({
25399 _doReset: function () {
25400 this._hash = new WordArray.init([
25401 0x67452301, 0xefcdab89,
25402 0x98badcfe, 0x10325476
25403 ]);
25404 },
25405
25406 _doProcessBlock: function (M, offset) {
25407 // Swap endian
25408 for (var i = 0; i < 16; i++) {
25409 // Shortcuts
25410 var offset_i = offset + i;
25411 var M_offset_i = M[offset_i];
25412
25413 M[offset_i] = (
25414 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
25415 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
25416 );
25417 }
25418
25419 // Shortcuts
25420 var H = this._hash.words;
25421
25422 var M_offset_0 = M[offset + 0];
25423 var M_offset_1 = M[offset + 1];
25424 var M_offset_2 = M[offset + 2];
25425 var M_offset_3 = M[offset + 3];
25426 var M_offset_4 = M[offset + 4];
25427 var M_offset_5 = M[offset + 5];
25428 var M_offset_6 = M[offset + 6];
25429 var M_offset_7 = M[offset + 7];
25430 var M_offset_8 = M[offset + 8];
25431 var M_offset_9 = M[offset + 9];
25432 var M_offset_10 = M[offset + 10];
25433 var M_offset_11 = M[offset + 11];
25434 var M_offset_12 = M[offset + 12];
25435 var M_offset_13 = M[offset + 13];
25436 var M_offset_14 = M[offset + 14];
25437 var M_offset_15 = M[offset + 15];
25438
25439 // Working varialbes
25440 var a = H[0];
25441 var b = H[1];
25442 var c = H[2];
25443 var d = H[3];
25444
25445 // Computation
25446 a = FF(a, b, c, d, M_offset_0, 7, T[0]);
25447 d = FF(d, a, b, c, M_offset_1, 12, T[1]);
25448 c = FF(c, d, a, b, M_offset_2, 17, T[2]);
25449 b = FF(b, c, d, a, M_offset_3, 22, T[3]);
25450 a = FF(a, b, c, d, M_offset_4, 7, T[4]);
25451 d = FF(d, a, b, c, M_offset_5, 12, T[5]);
25452 c = FF(c, d, a, b, M_offset_6, 17, T[6]);
25453 b = FF(b, c, d, a, M_offset_7, 22, T[7]);
25454 a = FF(a, b, c, d, M_offset_8, 7, T[8]);
25455 d = FF(d, a, b, c, M_offset_9, 12, T[9]);
25456 c = FF(c, d, a, b, M_offset_10, 17, T[10]);
25457 b = FF(b, c, d, a, M_offset_11, 22, T[11]);
25458 a = FF(a, b, c, d, M_offset_12, 7, T[12]);
25459 d = FF(d, a, b, c, M_offset_13, 12, T[13]);
25460 c = FF(c, d, a, b, M_offset_14, 17, T[14]);
25461 b = FF(b, c, d, a, M_offset_15, 22, T[15]);
25462
25463 a = GG(a, b, c, d, M_offset_1, 5, T[16]);
25464 d = GG(d, a, b, c, M_offset_6, 9, T[17]);
25465 c = GG(c, d, a, b, M_offset_11, 14, T[18]);
25466 b = GG(b, c, d, a, M_offset_0, 20, T[19]);
25467 a = GG(a, b, c, d, M_offset_5, 5, T[20]);
25468 d = GG(d, a, b, c, M_offset_10, 9, T[21]);
25469 c = GG(c, d, a, b, M_offset_15, 14, T[22]);
25470 b = GG(b, c, d, a, M_offset_4, 20, T[23]);
25471 a = GG(a, b, c, d, M_offset_9, 5, T[24]);
25472 d = GG(d, a, b, c, M_offset_14, 9, T[25]);
25473 c = GG(c, d, a, b, M_offset_3, 14, T[26]);
25474 b = GG(b, c, d, a, M_offset_8, 20, T[27]);
25475 a = GG(a, b, c, d, M_offset_13, 5, T[28]);
25476 d = GG(d, a, b, c, M_offset_2, 9, T[29]);
25477 c = GG(c, d, a, b, M_offset_7, 14, T[30]);
25478 b = GG(b, c, d, a, M_offset_12, 20, T[31]);
25479
25480 a = HH(a, b, c, d, M_offset_5, 4, T[32]);
25481 d = HH(d, a, b, c, M_offset_8, 11, T[33]);
25482 c = HH(c, d, a, b, M_offset_11, 16, T[34]);
25483 b = HH(b, c, d, a, M_offset_14, 23, T[35]);
25484 a = HH(a, b, c, d, M_offset_1, 4, T[36]);
25485 d = HH(d, a, b, c, M_offset_4, 11, T[37]);
25486 c = HH(c, d, a, b, M_offset_7, 16, T[38]);
25487 b = HH(b, c, d, a, M_offset_10, 23, T[39]);
25488 a = HH(a, b, c, d, M_offset_13, 4, T[40]);
25489 d = HH(d, a, b, c, M_offset_0, 11, T[41]);
25490 c = HH(c, d, a, b, M_offset_3, 16, T[42]);
25491 b = HH(b, c, d, a, M_offset_6, 23, T[43]);
25492 a = HH(a, b, c, d, M_offset_9, 4, T[44]);
25493 d = HH(d, a, b, c, M_offset_12, 11, T[45]);
25494 c = HH(c, d, a, b, M_offset_15, 16, T[46]);
25495 b = HH(b, c, d, a, M_offset_2, 23, T[47]);
25496
25497 a = II(a, b, c, d, M_offset_0, 6, T[48]);
25498 d = II(d, a, b, c, M_offset_7, 10, T[49]);
25499 c = II(c, d, a, b, M_offset_14, 15, T[50]);
25500 b = II(b, c, d, a, M_offset_5, 21, T[51]);
25501 a = II(a, b, c, d, M_offset_12, 6, T[52]);
25502 d = II(d, a, b, c, M_offset_3, 10, T[53]);
25503 c = II(c, d, a, b, M_offset_10, 15, T[54]);
25504 b = II(b, c, d, a, M_offset_1, 21, T[55]);
25505 a = II(a, b, c, d, M_offset_8, 6, T[56]);
25506 d = II(d, a, b, c, M_offset_15, 10, T[57]);
25507 c = II(c, d, a, b, M_offset_6, 15, T[58]);
25508 b = II(b, c, d, a, M_offset_13, 21, T[59]);
25509 a = II(a, b, c, d, M_offset_4, 6, T[60]);
25510 d = II(d, a, b, c, M_offset_11, 10, T[61]);
25511 c = II(c, d, a, b, M_offset_2, 15, T[62]);
25512 b = II(b, c, d, a, M_offset_9, 21, T[63]);
25513
25514 // Intermediate hash value
25515 H[0] = (H[0] + a) | 0;
25516 H[1] = (H[1] + b) | 0;
25517 H[2] = (H[2] + c) | 0;
25518 H[3] = (H[3] + d) | 0;
25519 },
25520
25521 _doFinalize: function () {
25522 // Shortcuts
25523 var data = this._data;
25524 var dataWords = data.words;
25525
25526 var nBitsTotal = this._nDataBytes * 8;
25527 var nBitsLeft = data.sigBytes * 8;
25528
25529 // Add padding
25530 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
25531
25532 var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
25533 var nBitsTotalL = nBitsTotal;
25534 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
25535 (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
25536 (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
25537 );
25538 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
25539 (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
25540 (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
25541 );
25542
25543 data.sigBytes = (dataWords.length + 1) * 4;
25544
25545 // Hash final blocks
25546 this._process();
25547
25548 // Shortcuts
25549 var hash = this._hash;
25550 var H = hash.words;
25551
25552 // Swap endian
25553 for (var i = 0; i < 4; i++) {
25554 // Shortcut
25555 var H_i = H[i];
25556
25557 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
25558 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
25559 }
25560
25561 // Return final computed hash
25562 return hash;
25563 },
25564
25565 clone: function () {
25566 var clone = Hasher.clone.call(this);
25567 clone._hash = this._hash.clone();
25568
25569 return clone;
25570 }
25571 });
25572
25573 function FF(a, b, c, d, x, s, t) {
25574 var n = a + ((b & c) | (~b & d)) + x + t;
25575 return ((n << s) | (n >>> (32 - s))) + b;
25576 }
25577
25578 function GG(a, b, c, d, x, s, t) {
25579 var n = a + ((b & d) | (c & ~d)) + x + t;
25580 return ((n << s) | (n >>> (32 - s))) + b;
25581 }
25582
25583 function HH(a, b, c, d, x, s, t) {
25584 var n = a + (b ^ c ^ d) + x + t;
25585 return ((n << s) | (n >>> (32 - s))) + b;
25586 }
25587
25588 function II(a, b, c, d, x, s, t) {
25589 var n = a + (c ^ (b | ~d)) + x + t;
25590 return ((n << s) | (n >>> (32 - s))) + b;
25591 }
25592
25593 /**
25594 * Shortcut function to the hasher's object interface.
25595 *
25596 * @param {WordArray|string} message The message to hash.
25597 *
25598 * @return {WordArray} The hash.
25599 *
25600 * @static
25601 *
25602 * @example
25603 *
25604 * var hash = CryptoJS.MD5('message');
25605 * var hash = CryptoJS.MD5(wordArray);
25606 */
25607 C.MD5 = Hasher._createHelper(MD5);
25608
25609 /**
25610 * Shortcut function to the HMAC's object interface.
25611 *
25612 * @param {WordArray|string} message The message to hash.
25613 * @param {WordArray|string} key The secret key.
25614 *
25615 * @return {WordArray} The HMAC.
25616 *
25617 * @static
25618 *
25619 * @example
25620 *
25621 * var hmac = CryptoJS.HmacMD5(message, key);
25622 */
25623 C.HmacMD5 = Hasher._createHmacHelper(MD5);
25624 }(Math));
25625
25626
25627 return CryptoJS.MD5;
25628
25629 }));
25630 },{"./core":31}],40:[function(_dereq_,module,exports){
25631 ;(function (root, factory, undef) {
25632 if (typeof exports === "object") {
25633 // CommonJS
25634 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25635 }
25636 else if (typeof define === "function" && define.amd) {
25637 // AMD
25638 define(["./core", "./cipher-core"], factory);
25639 }
25640 else {
25641 // Global (browser)
25642 factory(root.CryptoJS);
25643 }
25644 }(this, function (CryptoJS) {
25645
25646 /**
25647 * Cipher Feedback block mode.
25648 */
25649 CryptoJS.mode.CFB = (function () {
25650 var CFB = CryptoJS.lib.BlockCipherMode.extend();
25651
25652 CFB.Encryptor = CFB.extend({
25653 processBlock: function (words, offset) {
25654 // Shortcuts
25655 var cipher = this._cipher;
25656 var blockSize = cipher.blockSize;
25657
25658 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
25659
25660 // Remember this block to use with next block
25661 this._prevBlock = words.slice(offset, offset + blockSize);
25662 }
25663 });
25664
25665 CFB.Decryptor = CFB.extend({
25666 processBlock: function (words, offset) {
25667 // Shortcuts
25668 var cipher = this._cipher;
25669 var blockSize = cipher.blockSize;
25670
25671 // Remember this block to use with next block
25672 var thisBlock = words.slice(offset, offset + blockSize);
25673
25674 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
25675
25676 // This block becomes the previous block
25677 this._prevBlock = thisBlock;
25678 }
25679 });
25680
25681 function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
25682 // Shortcut
25683 var iv = this._iv;
25684
25685 // Generate keystream
25686 if (iv) {
25687 var keystream = iv.slice(0);
25688
25689 // Remove IV for subsequent blocks
25690 this._iv = undefined;
25691 } else {
25692 var keystream = this._prevBlock;
25693 }
25694 cipher.encryptBlock(keystream, 0);
25695
25696 // Encrypt
25697 for (var i = 0; i < blockSize; i++) {
25698 words[offset + i] ^= keystream[i];
25699 }
25700 }
25701
25702 return CFB;
25703 }());
25704
25705
25706 return CryptoJS.mode.CFB;
25707
25708 }));
25709 },{"./cipher-core":30,"./core":31}],41:[function(_dereq_,module,exports){
25710 ;(function (root, factory, undef) {
25711 if (typeof exports === "object") {
25712 // CommonJS
25713 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25714 }
25715 else if (typeof define === "function" && define.amd) {
25716 // AMD
25717 define(["./core", "./cipher-core"], factory);
25718 }
25719 else {
25720 // Global (browser)
25721 factory(root.CryptoJS);
25722 }
25723 }(this, function (CryptoJS) {
25724
25725 /** @preserve
25726 * Counter block mode compatible with Dr Brian Gladman fileenc.c
25727 * derived from CryptoJS.mode.CTR
25728 * Jan Hruby jhruby.web@gmail.com
25729 */
25730 CryptoJS.mode.CTRGladman = (function () {
25731 var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
25732
25733 function incWord(word)
25734 {
25735 if (((word >> 24) & 0xff) === 0xff) { //overflow
25736 var b1 = (word >> 16)&0xff;
25737 var b2 = (word >> 8)&0xff;
25738 var b3 = word & 0xff;
25739
25740 if (b1 === 0xff) // overflow b1
25741 {
25742 b1 = 0;
25743 if (b2 === 0xff)
25744 {
25745 b2 = 0;
25746 if (b3 === 0xff)
25747 {
25748 b3 = 0;
25749 }
25750 else
25751 {
25752 ++b3;
25753 }
25754 }
25755 else
25756 {
25757 ++b2;
25758 }
25759 }
25760 else
25761 {
25762 ++b1;
25763 }
25764
25765 word = 0;
25766 word += (b1 << 16);
25767 word += (b2 << 8);
25768 word += b3;
25769 }
25770 else
25771 {
25772 word += (0x01 << 24);
25773 }
25774 return word;
25775 }
25776
25777 function incCounter(counter)
25778 {
25779 if ((counter[0] = incWord(counter[0])) === 0)
25780 {
25781 // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
25782 counter[1] = incWord(counter[1]);
25783 }
25784 return counter;
25785 }
25786
25787 var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
25788 processBlock: function (words, offset) {
25789 // Shortcuts
25790 var cipher = this._cipher
25791 var blockSize = cipher.blockSize;
25792 var iv = this._iv;
25793 var counter = this._counter;
25794
25795 // Generate keystream
25796 if (iv) {
25797 counter = this._counter = iv.slice(0);
25798
25799 // Remove IV for subsequent blocks
25800 this._iv = undefined;
25801 }
25802
25803 incCounter(counter);
25804
25805 var keystream = counter.slice(0);
25806 cipher.encryptBlock(keystream, 0);
25807
25808 // Encrypt
25809 for (var i = 0; i < blockSize; i++) {
25810 words[offset + i] ^= keystream[i];
25811 }
25812 }
25813 });
25814
25815 CTRGladman.Decryptor = Encryptor;
25816
25817 return CTRGladman;
25818 }());
25819
25820
25821
25822
25823 return CryptoJS.mode.CTRGladman;
25824
25825 }));
25826 },{"./cipher-core":30,"./core":31}],42:[function(_dereq_,module,exports){
25827 ;(function (root, factory, undef) {
25828 if (typeof exports === "object") {
25829 // CommonJS
25830 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25831 }
25832 else if (typeof define === "function" && define.amd) {
25833 // AMD
25834 define(["./core", "./cipher-core"], factory);
25835 }
25836 else {
25837 // Global (browser)
25838 factory(root.CryptoJS);
25839 }
25840 }(this, function (CryptoJS) {
25841
25842 /**
25843 * Counter block mode.
25844 */
25845 CryptoJS.mode.CTR = (function () {
25846 var CTR = CryptoJS.lib.BlockCipherMode.extend();
25847
25848 var Encryptor = CTR.Encryptor = CTR.extend({
25849 processBlock: function (words, offset) {
25850 // Shortcuts
25851 var cipher = this._cipher
25852 var blockSize = cipher.blockSize;
25853 var iv = this._iv;
25854 var counter = this._counter;
25855
25856 // Generate keystream
25857 if (iv) {
25858 counter = this._counter = iv.slice(0);
25859
25860 // Remove IV for subsequent blocks
25861 this._iv = undefined;
25862 }
25863 var keystream = counter.slice(0);
25864 cipher.encryptBlock(keystream, 0);
25865
25866 // Increment counter
25867 counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
25868
25869 // Encrypt
25870 for (var i = 0; i < blockSize; i++) {
25871 words[offset + i] ^= keystream[i];
25872 }
25873 }
25874 });
25875
25876 CTR.Decryptor = Encryptor;
25877
25878 return CTR;
25879 }());
25880
25881
25882 return CryptoJS.mode.CTR;
25883
25884 }));
25885 },{"./cipher-core":30,"./core":31}],43:[function(_dereq_,module,exports){
25886 ;(function (root, factory, undef) {
25887 if (typeof exports === "object") {
25888 // CommonJS
25889 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25890 }
25891 else if (typeof define === "function" && define.amd) {
25892 // AMD
25893 define(["./core", "./cipher-core"], factory);
25894 }
25895 else {
25896 // Global (browser)
25897 factory(root.CryptoJS);
25898 }
25899 }(this, function (CryptoJS) {
25900
25901 /**
25902 * Electronic Codebook block mode.
25903 */
25904 CryptoJS.mode.ECB = (function () {
25905 var ECB = CryptoJS.lib.BlockCipherMode.extend();
25906
25907 ECB.Encryptor = ECB.extend({
25908 processBlock: function (words, offset) {
25909 this._cipher.encryptBlock(words, offset);
25910 }
25911 });
25912
25913 ECB.Decryptor = ECB.extend({
25914 processBlock: function (words, offset) {
25915 this._cipher.decryptBlock(words, offset);
25916 }
25917 });
25918
25919 return ECB;
25920 }());
25921
25922
25923 return CryptoJS.mode.ECB;
25924
25925 }));
25926 },{"./cipher-core":30,"./core":31}],44:[function(_dereq_,module,exports){
25927 ;(function (root, factory, undef) {
25928 if (typeof exports === "object") {
25929 // CommonJS
25930 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25931 }
25932 else if (typeof define === "function" && define.amd) {
25933 // AMD
25934 define(["./core", "./cipher-core"], factory);
25935 }
25936 else {
25937 // Global (browser)
25938 factory(root.CryptoJS);
25939 }
25940 }(this, function (CryptoJS) {
25941
25942 /**
25943 * Output Feedback block mode.
25944 */
25945 CryptoJS.mode.OFB = (function () {
25946 var OFB = CryptoJS.lib.BlockCipherMode.extend();
25947
25948 var Encryptor = OFB.Encryptor = OFB.extend({
25949 processBlock: function (words, offset) {
25950 // Shortcuts
25951 var cipher = this._cipher
25952 var blockSize = cipher.blockSize;
25953 var iv = this._iv;
25954 var keystream = this._keystream;
25955
25956 // Generate keystream
25957 if (iv) {
25958 keystream = this._keystream = iv.slice(0);
25959
25960 // Remove IV for subsequent blocks
25961 this._iv = undefined;
25962 }
25963 cipher.encryptBlock(keystream, 0);
25964
25965 // Encrypt
25966 for (var i = 0; i < blockSize; i++) {
25967 words[offset + i] ^= keystream[i];
25968 }
25969 }
25970 });
25971
25972 OFB.Decryptor = Encryptor;
25973
25974 return OFB;
25975 }());
25976
25977
25978 return CryptoJS.mode.OFB;
25979
25980 }));
25981 },{"./cipher-core":30,"./core":31}],45:[function(_dereq_,module,exports){
25982 ;(function (root, factory, undef) {
25983 if (typeof exports === "object") {
25984 // CommonJS
25985 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25986 }
25987 else if (typeof define === "function" && define.amd) {
25988 // AMD
25989 define(["./core", "./cipher-core"], factory);
25990 }
25991 else {
25992 // Global (browser)
25993 factory(root.CryptoJS);
25994 }
25995 }(this, function (CryptoJS) {
25996
25997 /**
25998 * ANSI X.923 padding strategy.
25999 */
26000 CryptoJS.pad.AnsiX923 = {
26001 pad: function (data, blockSize) {
26002 // Shortcuts
26003 var dataSigBytes = data.sigBytes;
26004 var blockSizeBytes = blockSize * 4;
26005
26006 // Count padding bytes
26007 var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
26008
26009 // Compute last byte position
26010 var lastBytePos = dataSigBytes + nPaddingBytes - 1;
26011
26012 // Pad
26013 data.clamp();
26014 data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
26015 data.sigBytes += nPaddingBytes;
26016 },
26017
26018 unpad: function (data) {
26019 // Get number of padding bytes from last byte
26020 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
26021
26022 // Remove padding
26023 data.sigBytes -= nPaddingBytes;
26024 }
26025 };
26026
26027
26028 return CryptoJS.pad.Ansix923;
26029
26030 }));
26031 },{"./cipher-core":30,"./core":31}],46:[function(_dereq_,module,exports){
26032 ;(function (root, factory, undef) {
26033 if (typeof exports === "object") {
26034 // CommonJS
26035 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26036 }
26037 else if (typeof define === "function" && define.amd) {
26038 // AMD
26039 define(["./core", "./cipher-core"], factory);
26040 }
26041 else {
26042 // Global (browser)
26043 factory(root.CryptoJS);
26044 }
26045 }(this, function (CryptoJS) {
26046
26047 /**
26048 * ISO 10126 padding strategy.
26049 */
26050 CryptoJS.pad.Iso10126 = {
26051 pad: function (data, blockSize) {
26052 // Shortcut
26053 var blockSizeBytes = blockSize * 4;
26054
26055 // Count padding bytes
26056 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
26057
26058 // Pad
26059 data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
26060 concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
26061 },
26062
26063 unpad: function (data) {
26064 // Get number of padding bytes from last byte
26065 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
26066
26067 // Remove padding
26068 data.sigBytes -= nPaddingBytes;
26069 }
26070 };
26071
26072
26073 return CryptoJS.pad.Iso10126;
26074
26075 }));
26076 },{"./cipher-core":30,"./core":31}],47:[function(_dereq_,module,exports){
26077 ;(function (root, factory, undef) {
26078 if (typeof exports === "object") {
26079 // CommonJS
26080 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26081 }
26082 else if (typeof define === "function" && define.amd) {
26083 // AMD
26084 define(["./core", "./cipher-core"], factory);
26085 }
26086 else {
26087 // Global (browser)
26088 factory(root.CryptoJS);
26089 }
26090 }(this, function (CryptoJS) {
26091
26092 /**
26093 * ISO/IEC 9797-1 Padding Method 2.
26094 */
26095 CryptoJS.pad.Iso97971 = {
26096 pad: function (data, blockSize) {
26097 // Add 0x80 byte
26098 data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
26099
26100 // Zero pad the rest
26101 CryptoJS.pad.ZeroPadding.pad(data, blockSize);
26102 },
26103
26104 unpad: function (data) {
26105 // Remove zero padding
26106 CryptoJS.pad.ZeroPadding.unpad(data);
26107
26108 // Remove one more byte -- the 0x80 byte
26109 data.sigBytes--;
26110 }
26111 };
26112
26113
26114 return CryptoJS.pad.Iso97971;
26115
26116 }));
26117 },{"./cipher-core":30,"./core":31}],48:[function(_dereq_,module,exports){
26118 ;(function (root, factory, undef) {
26119 if (typeof exports === "object") {
26120 // CommonJS
26121 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26122 }
26123 else if (typeof define === "function" && define.amd) {
26124 // AMD
26125 define(["./core", "./cipher-core"], factory);
26126 }
26127 else {
26128 // Global (browser)
26129 factory(root.CryptoJS);
26130 }
26131 }(this, function (CryptoJS) {
26132
26133 /**
26134 * A noop padding strategy.
26135 */
26136 CryptoJS.pad.NoPadding = {
26137 pad: function () {
26138 },
26139
26140 unpad: function () {
26141 }
26142 };
26143
26144
26145 return CryptoJS.pad.NoPadding;
26146
26147 }));
26148 },{"./cipher-core":30,"./core":31}],49:[function(_dereq_,module,exports){
26149 ;(function (root, factory, undef) {
26150 if (typeof exports === "object") {
26151 // CommonJS
26152 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26153 }
26154 else if (typeof define === "function" && define.amd) {
26155 // AMD
26156 define(["./core", "./cipher-core"], factory);
26157 }
26158 else {
26159 // Global (browser)
26160 factory(root.CryptoJS);
26161 }
26162 }(this, function (CryptoJS) {
26163
26164 /**
26165 * Zero padding strategy.
26166 */
26167 CryptoJS.pad.ZeroPadding = {
26168 pad: function (data, blockSize) {
26169 // Shortcut
26170 var blockSizeBytes = blockSize * 4;
26171
26172 // Pad
26173 data.clamp();
26174 data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
26175 },
26176
26177 unpad: function (data) {
26178 // Shortcut
26179 var dataWords = data.words;
26180
26181 // Unpad
26182 var i = data.sigBytes - 1;
26183 while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
26184 i--;
26185 }
26186 data.sigBytes = i + 1;
26187 }
26188 };
26189
26190
26191 return CryptoJS.pad.ZeroPadding;
26192
26193 }));
26194 },{"./cipher-core":30,"./core":31}],50:[function(_dereq_,module,exports){
26195 ;(function (root, factory, undef) {
26196 if (typeof exports === "object") {
26197 // CommonJS
26198 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
26199 }
26200 else if (typeof define === "function" && define.amd) {
26201 // AMD
26202 define(["./core", "./sha1", "./hmac"], factory);
26203 }
26204 else {
26205 // Global (browser)
26206 factory(root.CryptoJS);
26207 }
26208 }(this, function (CryptoJS) {
26209
26210 (function () {
26211 // Shortcuts
26212 var C = CryptoJS;
26213 var C_lib = C.lib;
26214 var Base = C_lib.Base;
26215 var WordArray = C_lib.WordArray;
26216 var C_algo = C.algo;
26217 var SHA1 = C_algo.SHA1;
26218 var HMAC = C_algo.HMAC;
26219
26220 /**
26221 * Password-Based Key Derivation Function 2 algorithm.
26222 */
26223 var PBKDF2 = C_algo.PBKDF2 = Base.extend({
26224 /**
26225 * Configuration options.
26226 *
26227 * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
26228 * @property {Hasher} hasher The hasher to use. Default: SHA1
26229 * @property {number} iterations The number of iterations to perform. Default: 1
26230 */
26231 cfg: Base.extend({
26232 keySize: 128/32,
26233 hasher: SHA1,
26234 iterations: 1
26235 }),
26236
26237 /**
26238 * Initializes a newly created key derivation function.
26239 *
26240 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
26241 *
26242 * @example
26243 *
26244 * var kdf = CryptoJS.algo.PBKDF2.create();
26245 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
26246 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
26247 */
26248 init: function (cfg) {
26249 this.cfg = this.cfg.extend(cfg);
26250 },
26251
26252 /**
26253 * Computes the Password-Based Key Derivation Function 2.
26254 *
26255 * @param {WordArray|string} password The password.
26256 * @param {WordArray|string} salt A salt.
26257 *
26258 * @return {WordArray} The derived key.
26259 *
26260 * @example
26261 *
26262 * var key = kdf.compute(password, salt);
26263 */
26264 compute: function (password, salt) {
26265 // Shortcut
26266 var cfg = this.cfg;
26267
26268 // Init HMAC
26269 var hmac = HMAC.create(cfg.hasher, password);
26270
26271 // Initial values
26272 var derivedKey = WordArray.create();
26273 var blockIndex = WordArray.create([0x00000001]);
26274
26275 // Shortcuts
26276 var derivedKeyWords = derivedKey.words;
26277 var blockIndexWords = blockIndex.words;
26278 var keySize = cfg.keySize;
26279 var iterations = cfg.iterations;
26280
26281 // Generate key
26282 while (derivedKeyWords.length < keySize) {
26283 var block = hmac.update(salt).finalize(blockIndex);
26284 hmac.reset();
26285
26286 // Shortcuts
26287 var blockWords = block.words;
26288 var blockWordsLength = blockWords.length;
26289
26290 // Iterations
26291 var intermediate = block;
26292 for (var i = 1; i < iterations; i++) {
26293 intermediate = hmac.finalize(intermediate);
26294 hmac.reset();
26295
26296 // Shortcut
26297 var intermediateWords = intermediate.words;
26298
26299 // XOR intermediate with block
26300 for (var j = 0; j < blockWordsLength; j++) {
26301 blockWords[j] ^= intermediateWords[j];
26302 }
26303 }
26304
26305 derivedKey.concat(block);
26306 blockIndexWords[0]++;
26307 }
26308 derivedKey.sigBytes = keySize * 4;
26309
26310 return derivedKey;
26311 }
26312 });
26313
26314 /**
26315 * Computes the Password-Based Key Derivation Function 2.
26316 *
26317 * @param {WordArray|string} password The password.
26318 * @param {WordArray|string} salt A salt.
26319 * @param {Object} cfg (Optional) The configuration options to use for this computation.
26320 *
26321 * @return {WordArray} The derived key.
26322 *
26323 * @static
26324 *
26325 * @example
26326 *
26327 * var key = CryptoJS.PBKDF2(password, salt);
26328 * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
26329 * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
26330 */
26331 C.PBKDF2 = function (password, salt, cfg) {
26332 return PBKDF2.create(cfg).compute(password, salt);
26333 };
26334 }());
26335
26336
26337 return CryptoJS.PBKDF2;
26338
26339 }));
26340 },{"./core":31,"./hmac":36,"./sha1":55}],51:[function(_dereq_,module,exports){
26341 ;(function (root, factory, undef) {
26342 if (typeof exports === "object") {
26343 // CommonJS
26344 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26345 }
26346 else if (typeof define === "function" && define.amd) {
26347 // AMD
26348 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26349 }
26350 else {
26351 // Global (browser)
26352 factory(root.CryptoJS);
26353 }
26354 }(this, function (CryptoJS) {
26355
26356 (function () {
26357 // Shortcuts
26358 var C = CryptoJS;
26359 var C_lib = C.lib;
26360 var StreamCipher = C_lib.StreamCipher;
26361 var C_algo = C.algo;
26362
26363 // Reusable objects
26364 var S = [];
26365 var C_ = [];
26366 var G = [];
26367
26368 /**
26369 * Rabbit stream cipher algorithm.
26370 *
26371 * This is a legacy version that neglected to convert the key to little-endian.
26372 * This error doesn't affect the cipher's security,
26373 * but it does affect its compatibility with other implementations.
26374 */
26375 var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
26376 _doReset: function () {
26377 // Shortcuts
26378 var K = this._key.words;
26379 var iv = this.cfg.iv;
26380
26381 // Generate initial state values
26382 var X = this._X = [
26383 K[0], (K[3] << 16) | (K[2] >>> 16),
26384 K[1], (K[0] << 16) | (K[3] >>> 16),
26385 K[2], (K[1] << 16) | (K[0] >>> 16),
26386 K[3], (K[2] << 16) | (K[1] >>> 16)
26387 ];
26388
26389 // Generate initial counter values
26390 var C = this._C = [
26391 (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
26392 (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
26393 (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
26394 (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
26395 ];
26396
26397 // Carry bit
26398 this._b = 0;
26399
26400 // Iterate the system four times
26401 for (var i = 0; i < 4; i++) {
26402 nextState.call(this);
26403 }
26404
26405 // Modify the counters
26406 for (var i = 0; i < 8; i++) {
26407 C[i] ^= X[(i + 4) & 7];
26408 }
26409
26410 // IV setup
26411 if (iv) {
26412 // Shortcuts
26413 var IV = iv.words;
26414 var IV_0 = IV[0];
26415 var IV_1 = IV[1];
26416
26417 // Generate four subvectors
26418 var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
26419 var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
26420 var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
26421 var i3 = (i2 << 16) | (i0 & 0x0000ffff);
26422
26423 // Modify counter values
26424 C[0] ^= i0;
26425 C[1] ^= i1;
26426 C[2] ^= i2;
26427 C[3] ^= i3;
26428 C[4] ^= i0;
26429 C[5] ^= i1;
26430 C[6] ^= i2;
26431 C[7] ^= i3;
26432
26433 // Iterate the system four times
26434 for (var i = 0; i < 4; i++) {
26435 nextState.call(this);
26436 }
26437 }
26438 },
26439
26440 _doProcessBlock: function (M, offset) {
26441 // Shortcut
26442 var X = this._X;
26443
26444 // Iterate the system
26445 nextState.call(this);
26446
26447 // Generate four keystream words
26448 S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
26449 S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
26450 S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
26451 S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
26452
26453 for (var i = 0; i < 4; i++) {
26454 // Swap endian
26455 S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
26456 (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
26457
26458 // Encrypt
26459 M[offset + i] ^= S[i];
26460 }
26461 },
26462
26463 blockSize: 128/32,
26464
26465 ivSize: 64/32
26466 });
26467
26468 function nextState() {
26469 // Shortcuts
26470 var X = this._X;
26471 var C = this._C;
26472
26473 // Save old counter values
26474 for (var i = 0; i < 8; i++) {
26475 C_[i] = C[i];
26476 }
26477
26478 // Calculate new counter values
26479 C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
26480 C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
26481 C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
26482 C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
26483 C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
26484 C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
26485 C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
26486 C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
26487 this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
26488
26489 // Calculate the g-values
26490 for (var i = 0; i < 8; i++) {
26491 var gx = X[i] + C[i];
26492
26493 // Construct high and low argument for squaring
26494 var ga = gx & 0xffff;
26495 var gb = gx >>> 16;
26496
26497 // Calculate high and low result of squaring
26498 var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
26499 var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
26500
26501 // High XOR low
26502 G[i] = gh ^ gl;
26503 }
26504
26505 // Calculate new state values
26506 X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
26507 X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
26508 X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
26509 X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
26510 X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
26511 X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
26512 X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
26513 X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
26514 }
26515
26516 /**
26517 * Shortcut functions to the cipher's object interface.
26518 *
26519 * @example
26520 *
26521 * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
26522 * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
26523 */
26524 C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
26525 }());
26526
26527
26528 return CryptoJS.RabbitLegacy;
26529
26530 }));
26531 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],52:[function(_dereq_,module,exports){
26532 ;(function (root, factory, undef) {
26533 if (typeof exports === "object") {
26534 // CommonJS
26535 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26536 }
26537 else if (typeof define === "function" && define.amd) {
26538 // AMD
26539 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26540 }
26541 else {
26542 // Global (browser)
26543 factory(root.CryptoJS);
26544 }
26545 }(this, function (CryptoJS) {
26546
26547 (function () {
26548 // Shortcuts
26549 var C = CryptoJS;
26550 var C_lib = C.lib;
26551 var StreamCipher = C_lib.StreamCipher;
26552 var C_algo = C.algo;
26553
26554 // Reusable objects
26555 var S = [];
26556 var C_ = [];
26557 var G = [];
26558
26559 /**
26560 * Rabbit stream cipher algorithm
26561 */
26562 var Rabbit = C_algo.Rabbit = StreamCipher.extend({
26563 _doReset: function () {
26564 // Shortcuts
26565 var K = this._key.words;
26566 var iv = this.cfg.iv;
26567
26568 // Swap endian
26569 for (var i = 0; i < 4; i++) {
26570 K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) |
26571 (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00);
26572 }
26573
26574 // Generate initial state values
26575 var X = this._X = [
26576 K[0], (K[3] << 16) | (K[2] >>> 16),
26577 K[1], (K[0] << 16) | (K[3] >>> 16),
26578 K[2], (K[1] << 16) | (K[0] >>> 16),
26579 K[3], (K[2] << 16) | (K[1] >>> 16)
26580 ];
26581
26582 // Generate initial counter values
26583 var C = this._C = [
26584 (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
26585 (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
26586 (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
26587 (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
26588 ];
26589
26590 // Carry bit
26591 this._b = 0;
26592
26593 // Iterate the system four times
26594 for (var i = 0; i < 4; i++) {
26595 nextState.call(this);
26596 }
26597
26598 // Modify the counters
26599 for (var i = 0; i < 8; i++) {
26600 C[i] ^= X[(i + 4) & 7];
26601 }
26602
26603 // IV setup
26604 if (iv) {
26605 // Shortcuts
26606 var IV = iv.words;
26607 var IV_0 = IV[0];
26608 var IV_1 = IV[1];
26609
26610 // Generate four subvectors
26611 var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
26612 var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
26613 var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
26614 var i3 = (i2 << 16) | (i0 & 0x0000ffff);
26615
26616 // Modify counter values
26617 C[0] ^= i0;
26618 C[1] ^= i1;
26619 C[2] ^= i2;
26620 C[3] ^= i3;
26621 C[4] ^= i0;
26622 C[5] ^= i1;
26623 C[6] ^= i2;
26624 C[7] ^= i3;
26625
26626 // Iterate the system four times
26627 for (var i = 0; i < 4; i++) {
26628 nextState.call(this);
26629 }
26630 }
26631 },
26632
26633 _doProcessBlock: function (M, offset) {
26634 // Shortcut
26635 var X = this._X;
26636
26637 // Iterate the system
26638 nextState.call(this);
26639
26640 // Generate four keystream words
26641 S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
26642 S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
26643 S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
26644 S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
26645
26646 for (var i = 0; i < 4; i++) {
26647 // Swap endian
26648 S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
26649 (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
26650
26651 // Encrypt
26652 M[offset + i] ^= S[i];
26653 }
26654 },
26655
26656 blockSize: 128/32,
26657
26658 ivSize: 64/32
26659 });
26660
26661 function nextState() {
26662 // Shortcuts
26663 var X = this._X;
26664 var C = this._C;
26665
26666 // Save old counter values
26667 for (var i = 0; i < 8; i++) {
26668 C_[i] = C[i];
26669 }
26670
26671 // Calculate new counter values
26672 C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
26673 C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
26674 C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
26675 C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
26676 C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
26677 C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
26678 C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
26679 C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
26680 this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
26681
26682 // Calculate the g-values
26683 for (var i = 0; i < 8; i++) {
26684 var gx = X[i] + C[i];
26685
26686 // Construct high and low argument for squaring
26687 var ga = gx & 0xffff;
26688 var gb = gx >>> 16;
26689
26690 // Calculate high and low result of squaring
26691 var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
26692 var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
26693
26694 // High XOR low
26695 G[i] = gh ^ gl;
26696 }
26697
26698 // Calculate new state values
26699 X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
26700 X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
26701 X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
26702 X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
26703 X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
26704 X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
26705 X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
26706 X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
26707 }
26708
26709 /**
26710 * Shortcut functions to the cipher's object interface.
26711 *
26712 * @example
26713 *
26714 * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
26715 * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
26716 */
26717 C.Rabbit = StreamCipher._createHelper(Rabbit);
26718 }());
26719
26720
26721 return CryptoJS.Rabbit;
26722
26723 }));
26724 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],53:[function(_dereq_,module,exports){
26725 ;(function (root, factory, undef) {
26726 if (typeof exports === "object") {
26727 // CommonJS
26728 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26729 }
26730 else if (typeof define === "function" && define.amd) {
26731 // AMD
26732 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26733 }
26734 else {
26735 // Global (browser)
26736 factory(root.CryptoJS);
26737 }
26738 }(this, function (CryptoJS) {
26739
26740 (function () {
26741 // Shortcuts
26742 var C = CryptoJS;
26743 var C_lib = C.lib;
26744 var StreamCipher = C_lib.StreamCipher;
26745 var C_algo = C.algo;
26746
26747 /**
26748 * RC4 stream cipher algorithm.
26749 */
26750 var RC4 = C_algo.RC4 = StreamCipher.extend({
26751 _doReset: function () {
26752 // Shortcuts
26753 var key = this._key;
26754 var keyWords = key.words;
26755 var keySigBytes = key.sigBytes;
26756
26757 // Init sbox
26758 var S = this._S = [];
26759 for (var i = 0; i < 256; i++) {
26760 S[i] = i;
26761 }
26762
26763 // Key setup
26764 for (var i = 0, j = 0; i < 256; i++) {
26765 var keyByteIndex = i % keySigBytes;
26766 var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
26767
26768 j = (j + S[i] + keyByte) % 256;
26769
26770 // Swap
26771 var t = S[i];
26772 S[i] = S[j];
26773 S[j] = t;
26774 }
26775
26776 // Counters
26777 this._i = this._j = 0;
26778 },
26779
26780 _doProcessBlock: function (M, offset) {
26781 M[offset] ^= generateKeystreamWord.call(this);
26782 },
26783
26784 keySize: 256/32,
26785
26786 ivSize: 0
26787 });
26788
26789 function generateKeystreamWord() {
26790 // Shortcuts
26791 var S = this._S;
26792 var i = this._i;
26793 var j = this._j;
26794
26795 // Generate keystream word
26796 var keystreamWord = 0;
26797 for (var n = 0; n < 4; n++) {
26798 i = (i + 1) % 256;
26799 j = (j + S[i]) % 256;
26800
26801 // Swap
26802 var t = S[i];
26803 S[i] = S[j];
26804 S[j] = t;
26805
26806 keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
26807 }
26808
26809 // Update counters
26810 this._i = i;
26811 this._j = j;
26812
26813 return keystreamWord;
26814 }
26815
26816 /**
26817 * Shortcut functions to the cipher's object interface.
26818 *
26819 * @example
26820 *
26821 * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
26822 * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
26823 */
26824 C.RC4 = StreamCipher._createHelper(RC4);
26825
26826 /**
26827 * Modified RC4 stream cipher algorithm.
26828 */
26829 var RC4Drop = C_algo.RC4Drop = RC4.extend({
26830 /**
26831 * Configuration options.
26832 *
26833 * @property {number} drop The number of keystream words to drop. Default 192
26834 */
26835 cfg: RC4.cfg.extend({
26836 drop: 192
26837 }),
26838
26839 _doReset: function () {
26840 RC4._doReset.call(this);
26841
26842 // Drop
26843 for (var i = this.cfg.drop; i > 0; i--) {
26844 generateKeystreamWord.call(this);
26845 }
26846 }
26847 });
26848
26849 /**
26850 * Shortcut functions to the cipher's object interface.
26851 *
26852 * @example
26853 *
26854 * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
26855 * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
26856 */
26857 C.RC4Drop = StreamCipher._createHelper(RC4Drop);
26858 }());
26859
26860
26861 return CryptoJS.RC4;
26862
26863 }));
26864 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],54:[function(_dereq_,module,exports){
26865 ;(function (root, factory) {
26866 if (typeof exports === "object") {
26867 // CommonJS
26868 module.exports = exports = factory(_dereq_("./core"));
26869 }
26870 else if (typeof define === "function" && define.amd) {
26871 // AMD
26872 define(["./core"], factory);
26873 }
26874 else {
26875 // Global (browser)
26876 factory(root.CryptoJS);
26877 }
26878 }(this, function (CryptoJS) {
26879
26880 /** @preserve
26881 (c) 2012 by Cédric Mesnil. All rights reserved.
26882
26883 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
26884
26885 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
26886 - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
26887
26888 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26889 */
26890
26891 (function (Math) {
26892 // Shortcuts
26893 var C = CryptoJS;
26894 var C_lib = C.lib;
26895 var WordArray = C_lib.WordArray;
26896 var Hasher = C_lib.Hasher;
26897 var C_algo = C.algo;
26898
26899 // Constants table
26900 var _zl = WordArray.create([
26901 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
26902 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
26903 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
26904 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
26905 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]);
26906 var _zr = WordArray.create([
26907 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
26908 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
26909 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
26910 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
26911 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]);
26912 var _sl = WordArray.create([
26913 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
26914 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
26915 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
26916 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
26917 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]);
26918 var _sr = WordArray.create([
26919 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
26920 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
26921 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
26922 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
26923 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]);
26924
26925 var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
26926 var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
26927
26928 /**
26929 * RIPEMD160 hash algorithm.
26930 */
26931 var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
26932 _doReset: function () {
26933 this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
26934 },
26935
26936 _doProcessBlock: function (M, offset) {
26937
26938 // Swap endian
26939 for (var i = 0; i < 16; i++) {
26940 // Shortcuts
26941 var offset_i = offset + i;
26942 var M_offset_i = M[offset_i];
26943
26944 // Swap
26945 M[offset_i] = (
26946 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
26947 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
26948 );
26949 }
26950 // Shortcut
26951 var H = this._hash.words;
26952 var hl = _hl.words;
26953 var hr = _hr.words;
26954 var zl = _zl.words;
26955 var zr = _zr.words;
26956 var sl = _sl.words;
26957 var sr = _sr.words;
26958
26959 // Working variables
26960 var al, bl, cl, dl, el;
26961 var ar, br, cr, dr, er;
26962
26963 ar = al = H[0];
26964 br = bl = H[1];
26965 cr = cl = H[2];
26966 dr = dl = H[3];
26967 er = el = H[4];
26968 // Computation
26969 var t;
26970 for (var i = 0; i < 80; i += 1) {
26971 t = (al + M[offset+zl[i]])|0;
26972 if (i<16){
26973 t += f1(bl,cl,dl) + hl[0];
26974 } else if (i<32) {
26975 t += f2(bl,cl,dl) + hl[1];
26976 } else if (i<48) {
26977 t += f3(bl,cl,dl) + hl[2];
26978 } else if (i<64) {
26979 t += f4(bl,cl,dl) + hl[3];
26980 } else {// if (i<80) {
26981 t += f5(bl,cl,dl) + hl[4];
26982 }
26983 t = t|0;
26984 t = rotl(t,sl[i]);
26985 t = (t+el)|0;
26986 al = el;
26987 el = dl;
26988 dl = rotl(cl, 10);
26989 cl = bl;
26990 bl = t;
26991
26992 t = (ar + M[offset+zr[i]])|0;
26993 if (i<16){
26994 t += f5(br,cr,dr) + hr[0];
26995 } else if (i<32) {
26996 t += f4(br,cr,dr) + hr[1];
26997 } else if (i<48) {
26998 t += f3(br,cr,dr) + hr[2];
26999 } else if (i<64) {
27000 t += f2(br,cr,dr) + hr[3];
27001 } else {// if (i<80) {
27002 t += f1(br,cr,dr) + hr[4];
27003 }
27004 t = t|0;
27005 t = rotl(t,sr[i]) ;
27006 t = (t+er)|0;
27007 ar = er;
27008 er = dr;
27009 dr = rotl(cr, 10);
27010 cr = br;
27011 br = t;
27012 }
27013 // Intermediate hash value
27014 t = (H[1] + cl + dr)|0;
27015 H[1] = (H[2] + dl + er)|0;
27016 H[2] = (H[3] + el + ar)|0;
27017 H[3] = (H[4] + al + br)|0;
27018 H[4] = (H[0] + bl + cr)|0;
27019 H[0] = t;
27020 },
27021
27022 _doFinalize: function () {
27023 // Shortcuts
27024 var data = this._data;
27025 var dataWords = data.words;
27026
27027 var nBitsTotal = this._nDataBytes * 8;
27028 var nBitsLeft = data.sigBytes * 8;
27029
27030 // Add padding
27031 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27032 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
27033 (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
27034 (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
27035 );
27036 data.sigBytes = (dataWords.length + 1) * 4;
27037
27038 // Hash final blocks
27039 this._process();
27040
27041 // Shortcuts
27042 var hash = this._hash;
27043 var H = hash.words;
27044
27045 // Swap endian
27046 for (var i = 0; i < 5; i++) {
27047 // Shortcut
27048 var H_i = H[i];
27049
27050 // Swap
27051 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
27052 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
27053 }
27054
27055 // Return final computed hash
27056 return hash;
27057 },
27058
27059 clone: function () {
27060 var clone = Hasher.clone.call(this);
27061 clone._hash = this._hash.clone();
27062
27063 return clone;
27064 }
27065 });
27066
27067
27068 function f1(x, y, z) {
27069 return ((x) ^ (y) ^ (z));
27070
27071 }
27072
27073 function f2(x, y, z) {
27074 return (((x)&(y)) | ((~x)&(z)));
27075 }
27076
27077 function f3(x, y, z) {
27078 return (((x) | (~(y))) ^ (z));
27079 }
27080
27081 function f4(x, y, z) {
27082 return (((x) & (z)) | ((y)&(~(z))));
27083 }
27084
27085 function f5(x, y, z) {
27086 return ((x) ^ ((y) |(~(z))));
27087
27088 }
27089
27090 function rotl(x,n) {
27091 return (x<<n) | (x>>>(32-n));
27092 }
27093
27094
27095 /**
27096 * Shortcut function to the hasher's object interface.
27097 *
27098 * @param {WordArray|string} message The message to hash.
27099 *
27100 * @return {WordArray} The hash.
27101 *
27102 * @static
27103 *
27104 * @example
27105 *
27106 * var hash = CryptoJS.RIPEMD160('message');
27107 * var hash = CryptoJS.RIPEMD160(wordArray);
27108 */
27109 C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
27110
27111 /**
27112 * Shortcut function to the HMAC's object interface.
27113 *
27114 * @param {WordArray|string} message The message to hash.
27115 * @param {WordArray|string} key The secret key.
27116 *
27117 * @return {WordArray} The HMAC.
27118 *
27119 * @static
27120 *
27121 * @example
27122 *
27123 * var hmac = CryptoJS.HmacRIPEMD160(message, key);
27124 */
27125 C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
27126 }(Math));
27127
27128
27129 return CryptoJS.RIPEMD160;
27130
27131 }));
27132 },{"./core":31}],55:[function(_dereq_,module,exports){
27133 ;(function (root, factory) {
27134 if (typeof exports === "object") {
27135 // CommonJS
27136 module.exports = exports = factory(_dereq_("./core"));
27137 }
27138 else if (typeof define === "function" && define.amd) {
27139 // AMD
27140 define(["./core"], factory);
27141 }
27142 else {
27143 // Global (browser)
27144 factory(root.CryptoJS);
27145 }
27146 }(this, function (CryptoJS) {
27147
27148 (function () {
27149 // Shortcuts
27150 var C = CryptoJS;
27151 var C_lib = C.lib;
27152 var WordArray = C_lib.WordArray;
27153 var Hasher = C_lib.Hasher;
27154 var C_algo = C.algo;
27155
27156 // Reusable object
27157 var W = [];
27158
27159 /**
27160 * SHA-1 hash algorithm.
27161 */
27162 var SHA1 = C_algo.SHA1 = Hasher.extend({
27163 _doReset: function () {
27164 this._hash = new WordArray.init([
27165 0x67452301, 0xefcdab89,
27166 0x98badcfe, 0x10325476,
27167 0xc3d2e1f0
27168 ]);
27169 },
27170
27171 _doProcessBlock: function (M, offset) {
27172 // Shortcut
27173 var H = this._hash.words;
27174
27175 // Working variables
27176 var a = H[0];
27177 var b = H[1];
27178 var c = H[2];
27179 var d = H[3];
27180 var e = H[4];
27181
27182 // Computation
27183 for (var i = 0; i < 80; i++) {
27184 if (i < 16) {
27185 W[i] = M[offset + i] | 0;
27186 } else {
27187 var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
27188 W[i] = (n << 1) | (n >>> 31);
27189 }
27190
27191 var t = ((a << 5) | (a >>> 27)) + e + W[i];
27192 if (i < 20) {
27193 t += ((b & c) | (~b & d)) + 0x5a827999;
27194 } else if (i < 40) {
27195 t += (b ^ c ^ d) + 0x6ed9eba1;
27196 } else if (i < 60) {
27197 t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
27198 } else /* if (i < 80) */ {
27199 t += (b ^ c ^ d) - 0x359d3e2a;
27200 }
27201
27202 e = d;
27203 d = c;
27204 c = (b << 30) | (b >>> 2);
27205 b = a;
27206 a = t;
27207 }
27208
27209 // Intermediate hash value
27210 H[0] = (H[0] + a) | 0;
27211 H[1] = (H[1] + b) | 0;
27212 H[2] = (H[2] + c) | 0;
27213 H[3] = (H[3] + d) | 0;
27214 H[4] = (H[4] + e) | 0;
27215 },
27216
27217 _doFinalize: function () {
27218 // Shortcuts
27219 var data = this._data;
27220 var dataWords = data.words;
27221
27222 var nBitsTotal = this._nDataBytes * 8;
27223 var nBitsLeft = data.sigBytes * 8;
27224
27225 // Add padding
27226 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27227 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
27228 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
27229 data.sigBytes = dataWords.length * 4;
27230
27231 // Hash final blocks
27232 this._process();
27233
27234 // Return final computed hash
27235 return this._hash;
27236 },
27237
27238 clone: function () {
27239 var clone = Hasher.clone.call(this);
27240 clone._hash = this._hash.clone();
27241
27242 return clone;
27243 }
27244 });
27245
27246 /**
27247 * Shortcut function to the hasher's object interface.
27248 *
27249 * @param {WordArray|string} message The message to hash.
27250 *
27251 * @return {WordArray} The hash.
27252 *
27253 * @static
27254 *
27255 * @example
27256 *
27257 * var hash = CryptoJS.SHA1('message');
27258 * var hash = CryptoJS.SHA1(wordArray);
27259 */
27260 C.SHA1 = Hasher._createHelper(SHA1);
27261
27262 /**
27263 * Shortcut function to the HMAC's object interface.
27264 *
27265 * @param {WordArray|string} message The message to hash.
27266 * @param {WordArray|string} key The secret key.
27267 *
27268 * @return {WordArray} The HMAC.
27269 *
27270 * @static
27271 *
27272 * @example
27273 *
27274 * var hmac = CryptoJS.HmacSHA1(message, key);
27275 */
27276 C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
27277 }());
27278
27279
27280 return CryptoJS.SHA1;
27281
27282 }));
27283 },{"./core":31}],56:[function(_dereq_,module,exports){
27284 ;(function (root, factory, undef) {
27285 if (typeof exports === "object") {
27286 // CommonJS
27287 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha256"));
27288 }
27289 else if (typeof define === "function" && define.amd) {
27290 // AMD
27291 define(["./core", "./sha256"], factory);
27292 }
27293 else {
27294 // Global (browser)
27295 factory(root.CryptoJS);
27296 }
27297 }(this, function (CryptoJS) {
27298
27299 (function () {
27300 // Shortcuts
27301 var C = CryptoJS;
27302 var C_lib = C.lib;
27303 var WordArray = C_lib.WordArray;
27304 var C_algo = C.algo;
27305 var SHA256 = C_algo.SHA256;
27306
27307 /**
27308 * SHA-224 hash algorithm.
27309 */
27310 var SHA224 = C_algo.SHA224 = SHA256.extend({
27311 _doReset: function () {
27312 this._hash = new WordArray.init([
27313 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
27314 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
27315 ]);
27316 },
27317
27318 _doFinalize: function () {
27319 var hash = SHA256._doFinalize.call(this);
27320
27321 hash.sigBytes -= 4;
27322
27323 return hash;
27324 }
27325 });
27326
27327 /**
27328 * Shortcut function to the hasher's object interface.
27329 *
27330 * @param {WordArray|string} message The message to hash.
27331 *
27332 * @return {WordArray} The hash.
27333 *
27334 * @static
27335 *
27336 * @example
27337 *
27338 * var hash = CryptoJS.SHA224('message');
27339 * var hash = CryptoJS.SHA224(wordArray);
27340 */
27341 C.SHA224 = SHA256._createHelper(SHA224);
27342
27343 /**
27344 * Shortcut function to the HMAC's object interface.
27345 *
27346 * @param {WordArray|string} message The message to hash.
27347 * @param {WordArray|string} key The secret key.
27348 *
27349 * @return {WordArray} The HMAC.
27350 *
27351 * @static
27352 *
27353 * @example
27354 *
27355 * var hmac = CryptoJS.HmacSHA224(message, key);
27356 */
27357 C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
27358 }());
27359
27360
27361 return CryptoJS.SHA224;
27362
27363 }));
27364 },{"./core":31,"./sha256":57}],57:[function(_dereq_,module,exports){
27365 ;(function (root, factory) {
27366 if (typeof exports === "object") {
27367 // CommonJS
27368 module.exports = exports = factory(_dereq_("./core"));
27369 }
27370 else if (typeof define === "function" && define.amd) {
27371 // AMD
27372 define(["./core"], factory);
27373 }
27374 else {
27375 // Global (browser)
27376 factory(root.CryptoJS);
27377 }
27378 }(this, function (CryptoJS) {
27379
27380 (function (Math) {
27381 // Shortcuts
27382 var C = CryptoJS;
27383 var C_lib = C.lib;
27384 var WordArray = C_lib.WordArray;
27385 var Hasher = C_lib.Hasher;
27386 var C_algo = C.algo;
27387
27388 // Initialization and round constants tables
27389 var H = [];
27390 var K = [];
27391
27392 // Compute constants
27393 (function () {
27394 function isPrime(n) {
27395 var sqrtN = Math.sqrt(n);
27396 for (var factor = 2; factor <= sqrtN; factor++) {
27397 if (!(n % factor)) {
27398 return false;
27399 }
27400 }
27401
27402 return true;
27403 }
27404
27405 function getFractionalBits(n) {
27406 return ((n - (n | 0)) * 0x100000000) | 0;
27407 }
27408
27409 var n = 2;
27410 var nPrime = 0;
27411 while (nPrime < 64) {
27412 if (isPrime(n)) {
27413 if (nPrime < 8) {
27414 H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
27415 }
27416 K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
27417
27418 nPrime++;
27419 }
27420
27421 n++;
27422 }
27423 }());
27424
27425 // Reusable object
27426 var W = [];
27427
27428 /**
27429 * SHA-256 hash algorithm.
27430 */
27431 var SHA256 = C_algo.SHA256 = Hasher.extend({
27432 _doReset: function () {
27433 this._hash = new WordArray.init(H.slice(0));
27434 },
27435
27436 _doProcessBlock: function (M, offset) {
27437 // Shortcut
27438 var H = this._hash.words;
27439
27440 // Working variables
27441 var a = H[0];
27442 var b = H[1];
27443 var c = H[2];
27444 var d = H[3];
27445 var e = H[4];
27446 var f = H[5];
27447 var g = H[6];
27448 var h = H[7];
27449
27450 // Computation
27451 for (var i = 0; i < 64; i++) {
27452 if (i < 16) {
27453 W[i] = M[offset + i] | 0;
27454 } else {
27455 var gamma0x = W[i - 15];
27456 var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
27457 ((gamma0x << 14) | (gamma0x >>> 18)) ^
27458 (gamma0x >>> 3);
27459
27460 var gamma1x = W[i - 2];
27461 var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
27462 ((gamma1x << 13) | (gamma1x >>> 19)) ^
27463 (gamma1x >>> 10);
27464
27465 W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
27466 }
27467
27468 var ch = (e & f) ^ (~e & g);
27469 var maj = (a & b) ^ (a & c) ^ (b & c);
27470
27471 var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
27472 var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
27473
27474 var t1 = h + sigma1 + ch + K[i] + W[i];
27475 var t2 = sigma0 + maj;
27476
27477 h = g;
27478 g = f;
27479 f = e;
27480 e = (d + t1) | 0;
27481 d = c;
27482 c = b;
27483 b = a;
27484 a = (t1 + t2) | 0;
27485 }
27486
27487 // Intermediate hash value
27488 H[0] = (H[0] + a) | 0;
27489 H[1] = (H[1] + b) | 0;
27490 H[2] = (H[2] + c) | 0;
27491 H[3] = (H[3] + d) | 0;
27492 H[4] = (H[4] + e) | 0;
27493 H[5] = (H[5] + f) | 0;
27494 H[6] = (H[6] + g) | 0;
27495 H[7] = (H[7] + h) | 0;
27496 },
27497
27498 _doFinalize: function () {
27499 // Shortcuts
27500 var data = this._data;
27501 var dataWords = data.words;
27502
27503 var nBitsTotal = this._nDataBytes * 8;
27504 var nBitsLeft = data.sigBytes * 8;
27505
27506 // Add padding
27507 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27508 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
27509 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
27510 data.sigBytes = dataWords.length * 4;
27511
27512 // Hash final blocks
27513 this._process();
27514
27515 // Return final computed hash
27516 return this._hash;
27517 },
27518
27519 clone: function () {
27520 var clone = Hasher.clone.call(this);
27521 clone._hash = this._hash.clone();
27522
27523 return clone;
27524 }
27525 });
27526
27527 /**
27528 * Shortcut function to the hasher's object interface.
27529 *
27530 * @param {WordArray|string} message The message to hash.
27531 *
27532 * @return {WordArray} The hash.
27533 *
27534 * @static
27535 *
27536 * @example
27537 *
27538 * var hash = CryptoJS.SHA256('message');
27539 * var hash = CryptoJS.SHA256(wordArray);
27540 */
27541 C.SHA256 = Hasher._createHelper(SHA256);
27542
27543 /**
27544 * Shortcut function to the HMAC's object interface.
27545 *
27546 * @param {WordArray|string} message The message to hash.
27547 * @param {WordArray|string} key The secret key.
27548 *
27549 * @return {WordArray} The HMAC.
27550 *
27551 * @static
27552 *
27553 * @example
27554 *
27555 * var hmac = CryptoJS.HmacSHA256(message, key);
27556 */
27557 C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
27558 }(Math));
27559
27560
27561 return CryptoJS.SHA256;
27562
27563 }));
27564 },{"./core":31}],58:[function(_dereq_,module,exports){
27565 ;(function (root, factory, undef) {
27566 if (typeof exports === "object") {
27567 // CommonJS
27568 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"));
27569 }
27570 else if (typeof define === "function" && define.amd) {
27571 // AMD
27572 define(["./core", "./x64-core"], factory);
27573 }
27574 else {
27575 // Global (browser)
27576 factory(root.CryptoJS);
27577 }
27578 }(this, function (CryptoJS) {
27579
27580 (function (Math) {
27581 // Shortcuts
27582 var C = CryptoJS;
27583 var C_lib = C.lib;
27584 var WordArray = C_lib.WordArray;
27585 var Hasher = C_lib.Hasher;
27586 var C_x64 = C.x64;
27587 var X64Word = C_x64.Word;
27588 var C_algo = C.algo;
27589
27590 // Constants tables
27591 var RHO_OFFSETS = [];
27592 var PI_INDEXES = [];
27593 var ROUND_CONSTANTS = [];
27594
27595 // Compute Constants
27596 (function () {
27597 // Compute rho offset constants
27598 var x = 1, y = 0;
27599 for (var t = 0; t < 24; t++) {
27600 RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
27601
27602 var newX = y % 5;
27603 var newY = (2 * x + 3 * y) % 5;
27604 x = newX;
27605 y = newY;
27606 }
27607
27608 // Compute pi index constants
27609 for (var x = 0; x < 5; x++) {
27610 for (var y = 0; y < 5; y++) {
27611 PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
27612 }
27613 }
27614
27615 // Compute round constants
27616 var LFSR = 0x01;
27617 for (var i = 0; i < 24; i++) {
27618 var roundConstantMsw = 0;
27619 var roundConstantLsw = 0;
27620
27621 for (var j = 0; j < 7; j++) {
27622 if (LFSR & 0x01) {
27623 var bitPosition = (1 << j) - 1;
27624 if (bitPosition < 32) {
27625 roundConstantLsw ^= 1 << bitPosition;
27626 } else /* if (bitPosition >= 32) */ {
27627 roundConstantMsw ^= 1 << (bitPosition - 32);
27628 }
27629 }
27630
27631 // Compute next LFSR
27632 if (LFSR & 0x80) {
27633 // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
27634 LFSR = (LFSR << 1) ^ 0x71;
27635 } else {
27636 LFSR <<= 1;
27637 }
27638 }
27639
27640 ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
27641 }
27642 }());
27643
27644 // Reusable objects for temporary values
27645 var T = [];
27646 (function () {
27647 for (var i = 0; i < 25; i++) {
27648 T[i] = X64Word.create();
27649 }
27650 }());
27651
27652 /**
27653 * SHA-3 hash algorithm.
27654 */
27655 var SHA3 = C_algo.SHA3 = Hasher.extend({
27656 /**
27657 * Configuration options.
27658 *
27659 * @property {number} outputLength
27660 * The desired number of bits in the output hash.
27661 * Only values permitted are: 224, 256, 384, 512.
27662 * Default: 512
27663 */
27664 cfg: Hasher.cfg.extend({
27665 outputLength: 512
27666 }),
27667
27668 _doReset: function () {
27669 var state = this._state = []
27670 for (var i = 0; i < 25; i++) {
27671 state[i] = new X64Word.init();
27672 }
27673
27674 this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
27675 },
27676
27677 _doProcessBlock: function (M, offset) {
27678 // Shortcuts
27679 var state = this._state;
27680 var nBlockSizeLanes = this.blockSize / 2;
27681
27682 // Absorb
27683 for (var i = 0; i < nBlockSizeLanes; i++) {
27684 // Shortcuts
27685 var M2i = M[offset + 2 * i];
27686 var M2i1 = M[offset + 2 * i + 1];
27687
27688 // Swap endian
27689 M2i = (
27690 (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) |
27691 (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00)
27692 );
27693 M2i1 = (
27694 (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) |
27695 (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00)
27696 );
27697
27698 // Absorb message into state
27699 var lane = state[i];
27700 lane.high ^= M2i1;
27701 lane.low ^= M2i;
27702 }
27703
27704 // Rounds
27705 for (var round = 0; round < 24; round++) {
27706 // Theta
27707 for (var x = 0; x < 5; x++) {
27708 // Mix column lanes
27709 var tMsw = 0, tLsw = 0;
27710 for (var y = 0; y < 5; y++) {
27711 var lane = state[x + 5 * y];
27712 tMsw ^= lane.high;
27713 tLsw ^= lane.low;
27714 }
27715
27716 // Temporary values
27717 var Tx = T[x];
27718 Tx.high = tMsw;
27719 Tx.low = tLsw;
27720 }
27721 for (var x = 0; x < 5; x++) {
27722 // Shortcuts
27723 var Tx4 = T[(x + 4) % 5];
27724 var Tx1 = T[(x + 1) % 5];
27725 var Tx1Msw = Tx1.high;
27726 var Tx1Lsw = Tx1.low;
27727
27728 // Mix surrounding columns
27729 var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
27730 var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
27731 for (var y = 0; y < 5; y++) {
27732 var lane = state[x + 5 * y];
27733 lane.high ^= tMsw;
27734 lane.low ^= tLsw;
27735 }
27736 }
27737
27738 // Rho Pi
27739 for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
27740 // Shortcuts
27741 var lane = state[laneIndex];
27742 var laneMsw = lane.high;
27743 var laneLsw = lane.low;
27744 var rhoOffset = RHO_OFFSETS[laneIndex];
27745
27746 // Rotate lanes
27747 if (rhoOffset < 32) {
27748 var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
27749 var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
27750 } else /* if (rhoOffset >= 32) */ {
27751 var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
27752 var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
27753 }
27754
27755 // Transpose lanes
27756 var TPiLane = T[PI_INDEXES[laneIndex]];
27757 TPiLane.high = tMsw;
27758 TPiLane.low = tLsw;
27759 }
27760
27761 // Rho pi at x = y = 0
27762 var T0 = T[0];
27763 var state0 = state[0];
27764 T0.high = state0.high;
27765 T0.low = state0.low;
27766
27767 // Chi
27768 for (var x = 0; x < 5; x++) {
27769 for (var y = 0; y < 5; y++) {
27770 // Shortcuts
27771 var laneIndex = x + 5 * y;
27772 var lane = state[laneIndex];
27773 var TLane = T[laneIndex];
27774 var Tx1Lane = T[((x + 1) % 5) + 5 * y];
27775 var Tx2Lane = T[((x + 2) % 5) + 5 * y];
27776
27777 // Mix rows
27778 lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
27779 lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
27780 }
27781 }
27782
27783 // Iota
27784 var lane = state[0];
27785 var roundConstant = ROUND_CONSTANTS[round];
27786 lane.high ^= roundConstant.high;
27787 lane.low ^= roundConstant.low;;
27788 }
27789 },
27790
27791 _doFinalize: function () {
27792 // Shortcuts
27793 var data = this._data;
27794 var dataWords = data.words;
27795 var nBitsTotal = this._nDataBytes * 8;
27796 var nBitsLeft = data.sigBytes * 8;
27797 var blockSizeBits = this.blockSize * 32;
27798
27799 // Add padding
27800 dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
27801 dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
27802 data.sigBytes = dataWords.length * 4;
27803
27804 // Hash final blocks
27805 this._process();
27806
27807 // Shortcuts
27808 var state = this._state;
27809 var outputLengthBytes = this.cfg.outputLength / 8;
27810 var outputLengthLanes = outputLengthBytes / 8;
27811
27812 // Squeeze
27813 var hashWords = [];
27814 for (var i = 0; i < outputLengthLanes; i++) {
27815 // Shortcuts
27816 var lane = state[i];
27817 var laneMsw = lane.high;
27818 var laneLsw = lane.low;
27819
27820 // Swap endian
27821 laneMsw = (
27822 (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) |
27823 (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00)
27824 );
27825 laneLsw = (
27826 (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) |
27827 (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00)
27828 );
27829
27830 // Squeeze state to retrieve hash
27831 hashWords.push(laneLsw);
27832 hashWords.push(laneMsw);
27833 }
27834
27835 // Return final computed hash
27836 return new WordArray.init(hashWords, outputLengthBytes);
27837 },
27838
27839 clone: function () {
27840 var clone = Hasher.clone.call(this);
27841
27842 var state = clone._state = this._state.slice(0);
27843 for (var i = 0; i < 25; i++) {
27844 state[i] = state[i].clone();
27845 }
27846
27847 return clone;
27848 }
27849 });
27850
27851 /**
27852 * Shortcut function to the hasher's object interface.
27853 *
27854 * @param {WordArray|string} message The message to hash.
27855 *
27856 * @return {WordArray} The hash.
27857 *
27858 * @static
27859 *
27860 * @example
27861 *
27862 * var hash = CryptoJS.SHA3('message');
27863 * var hash = CryptoJS.SHA3(wordArray);
27864 */
27865 C.SHA3 = Hasher._createHelper(SHA3);
27866
27867 /**
27868 * Shortcut function to the HMAC's object interface.
27869 *
27870 * @param {WordArray|string} message The message to hash.
27871 * @param {WordArray|string} key The secret key.
27872 *
27873 * @return {WordArray} The HMAC.
27874 *
27875 * @static
27876 *
27877 * @example
27878 *
27879 * var hmac = CryptoJS.HmacSHA3(message, key);
27880 */
27881 C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
27882 }(Math));
27883
27884
27885 return CryptoJS.SHA3;
27886
27887 }));
27888 },{"./core":31,"./x64-core":62}],59:[function(_dereq_,module,exports){
27889 ;(function (root, factory, undef) {
27890 if (typeof exports === "object") {
27891 // CommonJS
27892 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"), _dereq_("./sha512"));
27893 }
27894 else if (typeof define === "function" && define.amd) {
27895 // AMD
27896 define(["./core", "./x64-core", "./sha512"], factory);
27897 }
27898 else {
27899 // Global (browser)
27900 factory(root.CryptoJS);
27901 }
27902 }(this, function (CryptoJS) {
27903
27904 (function () {
27905 // Shortcuts
27906 var C = CryptoJS;
27907 var C_x64 = C.x64;
27908 var X64Word = C_x64.Word;
27909 var X64WordArray = C_x64.WordArray;
27910 var C_algo = C.algo;
27911 var SHA512 = C_algo.SHA512;
27912
27913 /**
27914 * SHA-384 hash algorithm.
27915 */
27916 var SHA384 = C_algo.SHA384 = SHA512.extend({
27917 _doReset: function () {
27918 this._hash = new X64WordArray.init([
27919 new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
27920 new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
27921 new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
27922 new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
27923 ]);
27924 },
27925
27926 _doFinalize: function () {
27927 var hash = SHA512._doFinalize.call(this);
27928
27929 hash.sigBytes -= 16;
27930
27931 return hash;
27932 }
27933 });
27934
27935 /**
27936 * Shortcut function to the hasher's object interface.
27937 *
27938 * @param {WordArray|string} message The message to hash.
27939 *
27940 * @return {WordArray} The hash.
27941 *
27942 * @static
27943 *
27944 * @example
27945 *
27946 * var hash = CryptoJS.SHA384('message');
27947 * var hash = CryptoJS.SHA384(wordArray);
27948 */
27949 C.SHA384 = SHA512._createHelper(SHA384);
27950
27951 /**
27952 * Shortcut function to the HMAC's object interface.
27953 *
27954 * @param {WordArray|string} message The message to hash.
27955 * @param {WordArray|string} key The secret key.
27956 *
27957 * @return {WordArray} The HMAC.
27958 *
27959 * @static
27960 *
27961 * @example
27962 *
27963 * var hmac = CryptoJS.HmacSHA384(message, key);
27964 */
27965 C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
27966 }());
27967
27968
27969 return CryptoJS.SHA384;
27970
27971 }));
27972 },{"./core":31,"./sha512":60,"./x64-core":62}],60:[function(_dereq_,module,exports){
27973 ;(function (root, factory, undef) {
27974 if (typeof exports === "object") {
27975 // CommonJS
27976 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"));
27977 }
27978 else if (typeof define === "function" && define.amd) {
27979 // AMD
27980 define(["./core", "./x64-core"], factory);
27981 }
27982 else {
27983 // Global (browser)
27984 factory(root.CryptoJS);
27985 }
27986 }(this, function (CryptoJS) {
27987
27988 (function () {
27989 // Shortcuts
27990 var C = CryptoJS;
27991 var C_lib = C.lib;
27992 var Hasher = C_lib.Hasher;
27993 var C_x64 = C.x64;
27994 var X64Word = C_x64.Word;
27995 var X64WordArray = C_x64.WordArray;
27996 var C_algo = C.algo;
27997
27998 function X64Word_create() {
27999 return X64Word.create.apply(X64Word, arguments);
28000 }
28001
28002 // Constants
28003 var K = [
28004 X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
28005 X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
28006 X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
28007 X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
28008 X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
28009 X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
28010 X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
28011 X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
28012 X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
28013 X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
28014 X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
28015 X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
28016 X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
28017 X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
28018 X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
28019 X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
28020 X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
28021 X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
28022 X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
28023 X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
28024 X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
28025 X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
28026 X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
28027 X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
28028 X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
28029 X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
28030 X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
28031 X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
28032 X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
28033 X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
28034 X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
28035 X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
28036 X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
28037 X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
28038 X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
28039 X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
28040 X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
28041 X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
28042 X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
28043 X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
28044 ];
28045
28046 // Reusable objects
28047 var W = [];
28048 (function () {
28049 for (var i = 0; i < 80; i++) {
28050 W[i] = X64Word_create();
28051 }
28052 }());
28053
28054 /**
28055 * SHA-512 hash algorithm.
28056 */
28057 var SHA512 = C_algo.SHA512 = Hasher.extend({
28058 _doReset: function () {
28059 this._hash = new X64WordArray.init([
28060 new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
28061 new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
28062 new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
28063 new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
28064 ]);
28065 },
28066
28067 _doProcessBlock: function (M, offset) {
28068 // Shortcuts
28069 var H = this._hash.words;
28070
28071 var H0 = H[0];
28072 var H1 = H[1];
28073 var H2 = H[2];
28074 var H3 = H[3];
28075 var H4 = H[4];
28076 var H5 = H[5];
28077 var H6 = H[6];
28078 var H7 = H[7];
28079
28080 var H0h = H0.high;
28081 var H0l = H0.low;
28082 var H1h = H1.high;
28083 var H1l = H1.low;
28084 var H2h = H2.high;
28085 var H2l = H2.low;
28086 var H3h = H3.high;
28087 var H3l = H3.low;
28088 var H4h = H4.high;
28089 var H4l = H4.low;
28090 var H5h = H5.high;
28091 var H5l = H5.low;
28092 var H6h = H6.high;
28093 var H6l = H6.low;
28094 var H7h = H7.high;
28095 var H7l = H7.low;
28096
28097 // Working variables
28098 var ah = H0h;
28099 var al = H0l;
28100 var bh = H1h;
28101 var bl = H1l;
28102 var ch = H2h;
28103 var cl = H2l;
28104 var dh = H3h;
28105 var dl = H3l;
28106 var eh = H4h;
28107 var el = H4l;
28108 var fh = H5h;
28109 var fl = H5l;
28110 var gh = H6h;
28111 var gl = H6l;
28112 var hh = H7h;
28113 var hl = H7l;
28114
28115 // Rounds
28116 for (var i = 0; i < 80; i++) {
28117 // Shortcut
28118 var Wi = W[i];
28119
28120 // Extend message
28121 if (i < 16) {
28122 var Wih = Wi.high = M[offset + i * 2] | 0;
28123 var Wil = Wi.low = M[offset + i * 2 + 1] | 0;
28124 } else {
28125 // Gamma0
28126 var gamma0x = W[i - 15];
28127 var gamma0xh = gamma0x.high;
28128 var gamma0xl = gamma0x.low;
28129 var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
28130 var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
28131
28132 // Gamma1
28133 var gamma1x = W[i - 2];
28134 var gamma1xh = gamma1x.high;
28135 var gamma1xl = gamma1x.low;
28136 var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
28137 var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
28138
28139 // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
28140 var Wi7 = W[i - 7];
28141 var Wi7h = Wi7.high;
28142 var Wi7l = Wi7.low;
28143
28144 var Wi16 = W[i - 16];
28145 var Wi16h = Wi16.high;
28146 var Wi16l = Wi16.low;
28147
28148 var Wil = gamma0l + Wi7l;
28149 var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
28150 var Wil = Wil + gamma1l;
28151 var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
28152 var Wil = Wil + Wi16l;
28153 var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
28154
28155 Wi.high = Wih;
28156 Wi.low = Wil;
28157 }
28158
28159 var chh = (eh & fh) ^ (~eh & gh);
28160 var chl = (el & fl) ^ (~el & gl);
28161 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
28162 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
28163
28164 var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
28165 var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
28166 var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
28167 var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
28168
28169 // t1 = h + sigma1 + ch + K[i] + W[i]
28170 var Ki = K[i];
28171 var Kih = Ki.high;
28172 var Kil = Ki.low;
28173
28174 var t1l = hl + sigma1l;
28175 var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
28176 var t1l = t1l + chl;
28177 var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
28178 var t1l = t1l + Kil;
28179 var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
28180 var t1l = t1l + Wil;
28181 var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
28182
28183 // t2 = sigma0 + maj
28184 var t2l = sigma0l + majl;
28185 var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
28186
28187 // Update working variables
28188 hh = gh;
28189 hl = gl;
28190 gh = fh;
28191 gl = fl;
28192 fh = eh;
28193 fl = el;
28194 el = (dl + t1l) | 0;
28195 eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
28196 dh = ch;
28197 dl = cl;
28198 ch = bh;
28199 cl = bl;
28200 bh = ah;
28201 bl = al;
28202 al = (t1l + t2l) | 0;
28203 ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
28204 }
28205
28206 // Intermediate hash value
28207 H0l = H0.low = (H0l + al);
28208 H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
28209 H1l = H1.low = (H1l + bl);
28210 H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
28211 H2l = H2.low = (H2l + cl);
28212 H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
28213 H3l = H3.low = (H3l + dl);
28214 H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
28215 H4l = H4.low = (H4l + el);
28216 H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
28217 H5l = H5.low = (H5l + fl);
28218 H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
28219 H6l = H6.low = (H6l + gl);
28220 H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
28221 H7l = H7.low = (H7l + hl);
28222 H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
28223 },
28224
28225 _doFinalize: function () {
28226 // Shortcuts
28227 var data = this._data;
28228 var dataWords = data.words;
28229
28230 var nBitsTotal = this._nDataBytes * 8;
28231 var nBitsLeft = data.sigBytes * 8;
28232
28233 // Add padding
28234 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
28235 dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
28236 dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
28237 data.sigBytes = dataWords.length * 4;
28238
28239 // Hash final blocks
28240 this._process();
28241
28242 // Convert hash to 32-bit word array before returning
28243 var hash = this._hash.toX32();
28244
28245 // Return final computed hash
28246 return hash;
28247 },
28248
28249 clone: function () {
28250 var clone = Hasher.clone.call(this);
28251 clone._hash = this._hash.clone();
28252
28253 return clone;
28254 },
28255
28256 blockSize: 1024/32
28257 });
28258
28259 /**
28260 * Shortcut function to the hasher's object interface.
28261 *
28262 * @param {WordArray|string} message The message to hash.
28263 *
28264 * @return {WordArray} The hash.
28265 *
28266 * @static
28267 *
28268 * @example
28269 *
28270 * var hash = CryptoJS.SHA512('message');
28271 * var hash = CryptoJS.SHA512(wordArray);
28272 */
28273 C.SHA512 = Hasher._createHelper(SHA512);
28274
28275 /**
28276 * Shortcut function to the HMAC's object interface.
28277 *
28278 * @param {WordArray|string} message The message to hash.
28279 * @param {WordArray|string} key The secret key.
28280 *
28281 * @return {WordArray} The HMAC.
28282 *
28283 * @static
28284 *
28285 * @example
28286 *
28287 * var hmac = CryptoJS.HmacSHA512(message, key);
28288 */
28289 C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
28290 }());
28291
28292
28293 return CryptoJS.SHA512;
28294
28295 }));
28296 },{"./core":31,"./x64-core":62}],61:[function(_dereq_,module,exports){
28297 ;(function (root, factory, undef) {
28298 if (typeof exports === "object") {
28299 // CommonJS
28300 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
28301 }
28302 else if (typeof define === "function" && define.amd) {
28303 // AMD
28304 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
28305 }
28306 else {
28307 // Global (browser)
28308 factory(root.CryptoJS);
28309 }
28310 }(this, function (CryptoJS) {
28311
28312 (function () {
28313 // Shortcuts
28314 var C = CryptoJS;
28315 var C_lib = C.lib;
28316 var WordArray = C_lib.WordArray;
28317 var BlockCipher = C_lib.BlockCipher;
28318 var C_algo = C.algo;
28319
28320 // Permuted Choice 1 constants
28321 var PC1 = [
28322 57, 49, 41, 33, 25, 17, 9, 1,
28323 58, 50, 42, 34, 26, 18, 10, 2,
28324 59, 51, 43, 35, 27, 19, 11, 3,
28325 60, 52, 44, 36, 63, 55, 47, 39,
28326 31, 23, 15, 7, 62, 54, 46, 38,
28327 30, 22, 14, 6, 61, 53, 45, 37,
28328 29, 21, 13, 5, 28, 20, 12, 4
28329 ];
28330
28331 // Permuted Choice 2 constants
28332 var PC2 = [
28333 14, 17, 11, 24, 1, 5,
28334 3, 28, 15, 6, 21, 10,
28335 23, 19, 12, 4, 26, 8,
28336 16, 7, 27, 20, 13, 2,
28337 41, 52, 31, 37, 47, 55,
28338 30, 40, 51, 45, 33, 48,
28339 44, 49, 39, 56, 34, 53,
28340 46, 42, 50, 36, 29, 32
28341 ];
28342
28343 // Cumulative bit shift constants
28344 var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
28345
28346 // SBOXes and round permutation constants
28347 var SBOX_P = [
28348 {
28349 0x0: 0x808200,
28350 0x10000000: 0x8000,
28351 0x20000000: 0x808002,
28352 0x30000000: 0x2,
28353 0x40000000: 0x200,
28354 0x50000000: 0x808202,
28355 0x60000000: 0x800202,
28356 0x70000000: 0x800000,
28357 0x80000000: 0x202,
28358 0x90000000: 0x800200,
28359 0xa0000000: 0x8200,
28360 0xb0000000: 0x808000,
28361 0xc0000000: 0x8002,
28362 0xd0000000: 0x800002,
28363 0xe0000000: 0x0,
28364 0xf0000000: 0x8202,
28365 0x8000000: 0x0,
28366 0x18000000: 0x808202,
28367 0x28000000: 0x8202,
28368 0x38000000: 0x8000,
28369 0x48000000: 0x808200,
28370 0x58000000: 0x200,
28371 0x68000000: 0x808002,
28372 0x78000000: 0x2,
28373 0x88000000: 0x800200,
28374 0x98000000: 0x8200,
28375 0xa8000000: 0x808000,
28376 0xb8000000: 0x800202,
28377 0xc8000000: 0x800002,
28378 0xd8000000: 0x8002,
28379 0xe8000000: 0x202,
28380 0xf8000000: 0x800000,
28381 0x1: 0x8000,
28382 0x10000001: 0x2,
28383 0x20000001: 0x808200,
28384 0x30000001: 0x800000,
28385 0x40000001: 0x808002,
28386 0x50000001: 0x8200,
28387 0x60000001: 0x200,
28388 0x70000001: 0x800202,
28389 0x80000001: 0x808202,
28390 0x90000001: 0x808000,
28391 0xa0000001: 0x800002,
28392 0xb0000001: 0x8202,
28393 0xc0000001: 0x202,
28394 0xd0000001: 0x800200,
28395 0xe0000001: 0x8002,
28396 0xf0000001: 0x0,
28397 0x8000001: 0x808202,
28398 0x18000001: 0x808000,
28399 0x28000001: 0x800000,
28400 0x38000001: 0x200,
28401 0x48000001: 0x8000,
28402 0x58000001: 0x800002,
28403 0x68000001: 0x2,
28404 0x78000001: 0x8202,
28405 0x88000001: 0x8002,
28406 0x98000001: 0x800202,
28407 0xa8000001: 0x202,
28408 0xb8000001: 0x808200,
28409 0xc8000001: 0x800200,
28410 0xd8000001: 0x0,
28411 0xe8000001: 0x8200,
28412 0xf8000001: 0x808002
28413 },
28414 {
28415 0x0: 0x40084010,
28416 0x1000000: 0x4000,
28417 0x2000000: 0x80000,
28418 0x3000000: 0x40080010,
28419 0x4000000: 0x40000010,
28420 0x5000000: 0x40084000,
28421 0x6000000: 0x40004000,
28422 0x7000000: 0x10,
28423 0x8000000: 0x84000,
28424 0x9000000: 0x40004010,
28425 0xa000000: 0x40000000,
28426 0xb000000: 0x84010,
28427 0xc000000: 0x80010,
28428 0xd000000: 0x0,
28429 0xe000000: 0x4010,
28430 0xf000000: 0x40080000,
28431 0x800000: 0x40004000,
28432 0x1800000: 0x84010,
28433 0x2800000: 0x10,
28434 0x3800000: 0x40004010,
28435 0x4800000: 0x40084010,
28436 0x5800000: 0x40000000,
28437 0x6800000: 0x80000,
28438 0x7800000: 0x40080010,
28439 0x8800000: 0x80010,
28440 0x9800000: 0x0,
28441 0xa800000: 0x4000,
28442 0xb800000: 0x40080000,
28443 0xc800000: 0x40000010,
28444 0xd800000: 0x84000,
28445 0xe800000: 0x40084000,
28446 0xf800000: 0x4010,
28447 0x10000000: 0x0,
28448 0x11000000: 0x40080010,
28449 0x12000000: 0x40004010,
28450 0x13000000: 0x40084000,
28451 0x14000000: 0x40080000,
28452 0x15000000: 0x10,
28453 0x16000000: 0x84010,
28454 0x17000000: 0x4000,
28455 0x18000000: 0x4010,
28456 0x19000000: 0x80000,
28457 0x1a000000: 0x80010,
28458 0x1b000000: 0x40000010,
28459 0x1c000000: 0x84000,
28460 0x1d000000: 0x40004000,
28461 0x1e000000: 0x40000000,
28462 0x1f000000: 0x40084010,
28463 0x10800000: 0x84010,
28464 0x11800000: 0x80000,
28465 0x12800000: 0x40080000,
28466 0x13800000: 0x4000,
28467 0x14800000: 0x40004000,
28468 0x15800000: 0x40084010,
28469 0x16800000: 0x10,
28470 0x17800000: 0x40000000,
28471 0x18800000: 0x40084000,
28472 0x19800000: 0x40000010,
28473 0x1a800000: 0x40004010,
28474 0x1b800000: 0x80010,
28475 0x1c800000: 0x0,
28476 0x1d800000: 0x4010,
28477 0x1e800000: 0x40080010,
28478 0x1f800000: 0x84000
28479 },
28480 {
28481 0x0: 0x104,
28482 0x100000: 0x0,
28483 0x200000: 0x4000100,
28484 0x300000: 0x10104,
28485 0x400000: 0x10004,
28486 0x500000: 0x4000004,
28487 0x600000: 0x4010104,
28488 0x700000: 0x4010000,
28489 0x800000: 0x4000000,
28490 0x900000: 0x4010100,
28491 0xa00000: 0x10100,
28492 0xb00000: 0x4010004,
28493 0xc00000: 0x4000104,
28494 0xd00000: 0x10000,
28495 0xe00000: 0x4,
28496 0xf00000: 0x100,
28497 0x80000: 0x4010100,
28498 0x180000: 0x4010004,
28499 0x280000: 0x0,
28500 0x380000: 0x4000100,
28501 0x480000: 0x4000004,
28502 0x580000: 0x10000,
28503 0x680000: 0x10004,
28504 0x780000: 0x104,
28505 0x880000: 0x4,
28506 0x980000: 0x100,
28507 0xa80000: 0x4010000,
28508 0xb80000: 0x10104,
28509 0xc80000: 0x10100,
28510 0xd80000: 0x4000104,
28511 0xe80000: 0x4010104,
28512 0xf80000: 0x4000000,
28513 0x1000000: 0x4010100,
28514 0x1100000: 0x10004,
28515 0x1200000: 0x10000,
28516 0x1300000: 0x4000100,
28517 0x1400000: 0x100,
28518 0x1500000: 0x4010104,
28519 0x1600000: 0x4000004,
28520 0x1700000: 0x0,
28521 0x1800000: 0x4000104,
28522 0x1900000: 0x4000000,
28523 0x1a00000: 0x4,
28524 0x1b00000: 0x10100,
28525 0x1c00000: 0x4010000,
28526 0x1d00000: 0x104,
28527 0x1e00000: 0x10104,
28528 0x1f00000: 0x4010004,
28529 0x1080000: 0x4000000,
28530 0x1180000: 0x104,
28531 0x1280000: 0x4010100,
28532 0x1380000: 0x0,
28533 0x1480000: 0x10004,
28534 0x1580000: 0x4000100,
28535 0x1680000: 0x100,
28536 0x1780000: 0x4010004,
28537 0x1880000: 0x10000,
28538 0x1980000: 0x4010104,
28539 0x1a80000: 0x10104,
28540 0x1b80000: 0x4000004,
28541 0x1c80000: 0x4000104,
28542 0x1d80000: 0x4010000,
28543 0x1e80000: 0x4,
28544 0x1f80000: 0x10100
28545 },
28546 {
28547 0x0: 0x80401000,
28548 0x10000: 0x80001040,
28549 0x20000: 0x401040,
28550 0x30000: 0x80400000,
28551 0x40000: 0x0,
28552 0x50000: 0x401000,
28553 0x60000: 0x80000040,
28554 0x70000: 0x400040,
28555 0x80000: 0x80000000,
28556 0x90000: 0x400000,
28557 0xa0000: 0x40,
28558 0xb0000: 0x80001000,
28559 0xc0000: 0x80400040,
28560 0xd0000: 0x1040,
28561 0xe0000: 0x1000,
28562 0xf0000: 0x80401040,
28563 0x8000: 0x80001040,
28564 0x18000: 0x40,
28565 0x28000: 0x80400040,
28566 0x38000: 0x80001000,
28567 0x48000: 0x401000,
28568 0x58000: 0x80401040,
28569 0x68000: 0x0,
28570 0x78000: 0x80400000,
28571 0x88000: 0x1000,
28572 0x98000: 0x80401000,
28573 0xa8000: 0x400000,
28574 0xb8000: 0x1040,
28575 0xc8000: 0x80000000,
28576 0xd8000: 0x400040,
28577 0xe8000: 0x401040,
28578 0xf8000: 0x80000040,
28579 0x100000: 0x400040,
28580 0x110000: 0x401000,
28581 0x120000: 0x80000040,
28582 0x130000: 0x0,
28583 0x140000: 0x1040,
28584 0x150000: 0x80400040,
28585 0x160000: 0x80401000,
28586 0x170000: 0x80001040,
28587 0x180000: 0x80401040,
28588 0x190000: 0x80000000,
28589 0x1a0000: 0x80400000,
28590 0x1b0000: 0x401040,
28591 0x1c0000: 0x80001000,
28592 0x1d0000: 0x400000,
28593 0x1e0000: 0x40,
28594 0x1f0000: 0x1000,
28595 0x108000: 0x80400000,
28596 0x118000: 0x80401040,
28597 0x128000: 0x0,
28598 0x138000: 0x401000,
28599 0x148000: 0x400040,
28600 0x158000: 0x80000000,
28601 0x168000: 0x80001040,
28602 0x178000: 0x40,
28603 0x188000: 0x80000040,
28604 0x198000: 0x1000,
28605 0x1a8000: 0x80001000,
28606 0x1b8000: 0x80400040,
28607 0x1c8000: 0x1040,
28608 0x1d8000: 0x80401000,
28609 0x1e8000: 0x400000,
28610 0x1f8000: 0x401040
28611 },
28612 {
28613 0x0: 0x80,
28614 0x1000: 0x1040000,
28615 0x2000: 0x40000,
28616 0x3000: 0x20000000,
28617 0x4000: 0x20040080,
28618 0x5000: 0x1000080,
28619 0x6000: 0x21000080,
28620 0x7000: 0x40080,
28621 0x8000: 0x1000000,
28622 0x9000: 0x20040000,
28623 0xa000: 0x20000080,
28624 0xb000: 0x21040080,
28625 0xc000: 0x21040000,
28626 0xd000: 0x0,
28627 0xe000: 0x1040080,
28628 0xf000: 0x21000000,
28629 0x800: 0x1040080,
28630 0x1800: 0x21000080,
28631 0x2800: 0x80,
28632 0x3800: 0x1040000,
28633 0x4800: 0x40000,
28634 0x5800: 0x20040080,
28635 0x6800: 0x21040000,
28636 0x7800: 0x20000000,
28637 0x8800: 0x20040000,
28638 0x9800: 0x0,
28639 0xa800: 0x21040080,
28640 0xb800: 0x1000080,
28641 0xc800: 0x20000080,
28642 0xd800: 0x21000000,
28643 0xe800: 0x1000000,
28644 0xf800: 0x40080,
28645 0x10000: 0x40000,
28646 0x11000: 0x80,
28647 0x12000: 0x20000000,
28648 0x13000: 0x21000080,
28649 0x14000: 0x1000080,
28650 0x15000: 0x21040000,
28651 0x16000: 0x20040080,
28652 0x17000: 0x1000000,
28653 0x18000: 0x21040080,
28654 0x19000: 0x21000000,
28655 0x1a000: 0x1040000,
28656 0x1b000: 0x20040000,
28657 0x1c000: 0x40080,
28658 0x1d000: 0x20000080,
28659 0x1e000: 0x0,
28660 0x1f000: 0x1040080,
28661 0x10800: 0x21000080,
28662 0x11800: 0x1000000,
28663 0x12800: 0x1040000,
28664 0x13800: 0x20040080,
28665 0x14800: 0x20000000,
28666 0x15800: 0x1040080,
28667 0x16800: 0x80,
28668 0x17800: 0x21040000,
28669 0x18800: 0x40080,
28670 0x19800: 0x21040080,
28671 0x1a800: 0x0,
28672 0x1b800: 0x21000000,
28673 0x1c800: 0x1000080,
28674 0x1d800: 0x40000,
28675 0x1e800: 0x20040000,
28676 0x1f800: 0x20000080
28677 },
28678 {
28679 0x0: 0x10000008,
28680 0x100: 0x2000,
28681 0x200: 0x10200000,
28682 0x300: 0x10202008,
28683 0x400: 0x10002000,
28684 0x500: 0x200000,
28685 0x600: 0x200008,
28686 0x700: 0x10000000,
28687 0x800: 0x0,
28688 0x900: 0x10002008,
28689 0xa00: 0x202000,
28690 0xb00: 0x8,
28691 0xc00: 0x10200008,
28692 0xd00: 0x202008,
28693 0xe00: 0x2008,
28694 0xf00: 0x10202000,
28695 0x80: 0x10200000,
28696 0x180: 0x10202008,
28697 0x280: 0x8,
28698 0x380: 0x200000,
28699 0x480: 0x202008,
28700 0x580: 0x10000008,
28701 0x680: 0x10002000,
28702 0x780: 0x2008,
28703 0x880: 0x200008,
28704 0x980: 0x2000,
28705 0xa80: 0x10002008,
28706 0xb80: 0x10200008,
28707 0xc80: 0x0,
28708 0xd80: 0x10202000,
28709 0xe80: 0x202000,
28710 0xf80: 0x10000000,
28711 0x1000: 0x10002000,
28712 0x1100: 0x10200008,
28713 0x1200: 0x10202008,
28714 0x1300: 0x2008,
28715 0x1400: 0x200000,
28716 0x1500: 0x10000000,
28717 0x1600: 0x10000008,
28718 0x1700: 0x202000,
28719 0x1800: 0x202008,
28720 0x1900: 0x0,
28721 0x1a00: 0x8,
28722 0x1b00: 0x10200000,
28723 0x1c00: 0x2000,
28724 0x1d00: 0x10002008,
28725 0x1e00: 0x10202000,
28726 0x1f00: 0x200008,
28727 0x1080: 0x8,
28728 0x1180: 0x202000,
28729 0x1280: 0x200000,
28730 0x1380: 0x10000008,
28731 0x1480: 0x10002000,
28732 0x1580: 0x2008,
28733 0x1680: 0x10202008,
28734 0x1780: 0x10200000,
28735 0x1880: 0x10202000,
28736 0x1980: 0x10200008,
28737 0x1a80: 0x2000,
28738 0x1b80: 0x202008,
28739 0x1c80: 0x200008,
28740 0x1d80: 0x0,
28741 0x1e80: 0x10000000,
28742 0x1f80: 0x10002008
28743 },
28744 {
28745 0x0: 0x100000,
28746 0x10: 0x2000401,
28747 0x20: 0x400,
28748 0x30: 0x100401,
28749 0x40: 0x2100401,
28750 0x50: 0x0,
28751 0x60: 0x1,
28752 0x70: 0x2100001,
28753 0x80: 0x2000400,
28754 0x90: 0x100001,
28755 0xa0: 0x2000001,
28756 0xb0: 0x2100400,
28757 0xc0: 0x2100000,
28758 0xd0: 0x401,
28759 0xe0: 0x100400,
28760 0xf0: 0x2000000,
28761 0x8: 0x2100001,
28762 0x18: 0x0,
28763 0x28: 0x2000401,
28764 0x38: 0x2100400,
28765 0x48: 0x100000,
28766 0x58: 0x2000001,
28767 0x68: 0x2000000,
28768 0x78: 0x401,
28769 0x88: 0x100401,
28770 0x98: 0x2000400,
28771 0xa8: 0x2100000,
28772 0xb8: 0x100001,
28773 0xc8: 0x400,
28774 0xd8: 0x2100401,
28775 0xe8: 0x1,
28776 0xf8: 0x100400,
28777 0x100: 0x2000000,
28778 0x110: 0x100000,
28779 0x120: 0x2000401,
28780 0x130: 0x2100001,
28781 0x140: 0x100001,
28782 0x150: 0x2000400,
28783 0x160: 0x2100400,
28784 0x170: 0x100401,
28785 0x180: 0x401,
28786 0x190: 0x2100401,
28787 0x1a0: 0x100400,
28788 0x1b0: 0x1,
28789 0x1c0: 0x0,
28790 0x1d0: 0x2100000,
28791 0x1e0: 0x2000001,
28792 0x1f0: 0x400,
28793 0x108: 0x100400,
28794 0x118: 0x2000401,
28795 0x128: 0x2100001,
28796 0x138: 0x1,
28797 0x148: 0x2000000,
28798 0x158: 0x100000,
28799 0x168: 0x401,
28800 0x178: 0x2100400,
28801 0x188: 0x2000001,
28802 0x198: 0x2100000,
28803 0x1a8: 0x0,
28804 0x1b8: 0x2100401,
28805 0x1c8: 0x100401,
28806 0x1d8: 0x400,
28807 0x1e8: 0x2000400,
28808 0x1f8: 0x100001
28809 },
28810 {
28811 0x0: 0x8000820,
28812 0x1: 0x20000,
28813 0x2: 0x8000000,
28814 0x3: 0x20,
28815 0x4: 0x20020,
28816 0x5: 0x8020820,
28817 0x6: 0x8020800,
28818 0x7: 0x800,
28819 0x8: 0x8020000,
28820 0x9: 0x8000800,
28821 0xa: 0x20800,
28822 0xb: 0x8020020,
28823 0xc: 0x820,
28824 0xd: 0x0,
28825 0xe: 0x8000020,
28826 0xf: 0x20820,
28827 0x80000000: 0x800,
28828 0x80000001: 0x8020820,
28829 0x80000002: 0x8000820,
28830 0x80000003: 0x8000000,
28831 0x80000004: 0x8020000,
28832 0x80000005: 0x20800,
28833 0x80000006: 0x20820,
28834 0x80000007: 0x20,
28835 0x80000008: 0x8000020,
28836 0x80000009: 0x820,
28837 0x8000000a: 0x20020,
28838 0x8000000b: 0x8020800,
28839 0x8000000c: 0x0,
28840 0x8000000d: 0x8020020,
28841 0x8000000e: 0x8000800,
28842 0x8000000f: 0x20000,
28843 0x10: 0x20820,
28844 0x11: 0x8020800,
28845 0x12: 0x20,
28846 0x13: 0x800,
28847 0x14: 0x8000800,
28848 0x15: 0x8000020,
28849 0x16: 0x8020020,
28850 0x17: 0x20000,
28851 0x18: 0x0,
28852 0x19: 0x20020,
28853 0x1a: 0x8020000,
28854 0x1b: 0x8000820,
28855 0x1c: 0x8020820,
28856 0x1d: 0x20800,
28857 0x1e: 0x820,
28858 0x1f: 0x8000000,
28859 0x80000010: 0x20000,
28860 0x80000011: 0x800,
28861 0x80000012: 0x8020020,
28862 0x80000013: 0x20820,
28863 0x80000014: 0x20,
28864 0x80000015: 0x8020000,
28865 0x80000016: 0x8000000,
28866 0x80000017: 0x8000820,
28867 0x80000018: 0x8020820,
28868 0x80000019: 0x8000020,
28869 0x8000001a: 0x8000800,
28870 0x8000001b: 0x0,
28871 0x8000001c: 0x20800,
28872 0x8000001d: 0x820,
28873 0x8000001e: 0x20020,
28874 0x8000001f: 0x8020800
28875 }
28876 ];
28877
28878 // Masks that select the SBOX input
28879 var SBOX_MASK = [
28880 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
28881 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
28882 ];
28883
28884 /**
28885 * DES block cipher algorithm.
28886 */
28887 var DES = C_algo.DES = BlockCipher.extend({
28888 _doReset: function () {
28889 // Shortcuts
28890 var key = this._key;
28891 var keyWords = key.words;
28892
28893 // Select 56 bits according to PC1
28894 var keyBits = [];
28895 for (var i = 0; i < 56; i++) {
28896 var keyBitPos = PC1[i] - 1;
28897 keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
28898 }
28899
28900 // Assemble 16 subkeys
28901 var subKeys = this._subKeys = [];
28902 for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
28903 // Create subkey
28904 var subKey = subKeys[nSubKey] = [];
28905
28906 // Shortcut
28907 var bitShift = BIT_SHIFTS[nSubKey];
28908
28909 // Select 48 bits according to PC2
28910 for (var i = 0; i < 24; i++) {
28911 // Select from the left 28 key bits
28912 subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
28913
28914 // Select from the right 28 key bits
28915 subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
28916 }
28917
28918 // Since each subkey is applied to an expanded 32-bit input,
28919 // the subkey can be broken into 8 values scaled to 32-bits,
28920 // which allows the key to be used without expansion
28921 subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
28922 for (var i = 1; i < 7; i++) {
28923 subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
28924 }
28925 subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
28926 }
28927
28928 // Compute inverse subkeys
28929 var invSubKeys = this._invSubKeys = [];
28930 for (var i = 0; i < 16; i++) {
28931 invSubKeys[i] = subKeys[15 - i];
28932 }
28933 },
28934
28935 encryptBlock: function (M, offset) {
28936 this._doCryptBlock(M, offset, this._subKeys);
28937 },
28938
28939 decryptBlock: function (M, offset) {
28940 this._doCryptBlock(M, offset, this._invSubKeys);
28941 },
28942
28943 _doCryptBlock: function (M, offset, subKeys) {
28944 // Get input
28945 this._lBlock = M[offset];
28946 this._rBlock = M[offset + 1];
28947
28948 // Initial permutation
28949 exchangeLR.call(this, 4, 0x0f0f0f0f);
28950 exchangeLR.call(this, 16, 0x0000ffff);
28951 exchangeRL.call(this, 2, 0x33333333);
28952 exchangeRL.call(this, 8, 0x00ff00ff);
28953 exchangeLR.call(this, 1, 0x55555555);
28954
28955 // Rounds
28956 for (var round = 0; round < 16; round++) {
28957 // Shortcuts
28958 var subKey = subKeys[round];
28959 var lBlock = this._lBlock;
28960 var rBlock = this._rBlock;
28961
28962 // Feistel function
28963 var f = 0;
28964 for (var i = 0; i < 8; i++) {
28965 f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
28966 }
28967 this._lBlock = rBlock;
28968 this._rBlock = lBlock ^ f;
28969 }
28970
28971 // Undo swap from last round
28972 var t = this._lBlock;
28973 this._lBlock = this._rBlock;
28974 this._rBlock = t;
28975
28976 // Final permutation
28977 exchangeLR.call(this, 1, 0x55555555);
28978 exchangeRL.call(this, 8, 0x00ff00ff);
28979 exchangeRL.call(this, 2, 0x33333333);
28980 exchangeLR.call(this, 16, 0x0000ffff);
28981 exchangeLR.call(this, 4, 0x0f0f0f0f);
28982
28983 // Set output
28984 M[offset] = this._lBlock;
28985 M[offset + 1] = this._rBlock;
28986 },
28987
28988 keySize: 64/32,
28989
28990 ivSize: 64/32,
28991
28992 blockSize: 64/32
28993 });
28994
28995 // Swap bits across the left and right words
28996 function exchangeLR(offset, mask) {
28997 var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
28998 this._rBlock ^= t;
28999 this._lBlock ^= t << offset;
29000 }
29001
29002 function exchangeRL(offset, mask) {
29003 var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
29004 this._lBlock ^= t;
29005 this._rBlock ^= t << offset;
29006 }
29007
29008 /**
29009 * Shortcut functions to the cipher's object interface.
29010 *
29011 * @example
29012 *
29013 * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
29014 * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
29015 */
29016 C.DES = BlockCipher._createHelper(DES);
29017
29018 /**
29019 * Triple-DES block cipher algorithm.
29020 */
29021 var TripleDES = C_algo.TripleDES = BlockCipher.extend({
29022 _doReset: function () {
29023 // Shortcuts
29024 var key = this._key;
29025 var keyWords = key.words;
29026
29027 // Create DES instances
29028 this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
29029 this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
29030 this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
29031 },
29032
29033 encryptBlock: function (M, offset) {
29034 this._des1.encryptBlock(M, offset);
29035 this._des2.decryptBlock(M, offset);
29036 this._des3.encryptBlock(M, offset);
29037 },
29038
29039 decryptBlock: function (M, offset) {
29040 this._des3.decryptBlock(M, offset);
29041 this._des2.encryptBlock(M, offset);
29042 this._des1.decryptBlock(M, offset);
29043 },
29044
29045 keySize: 192/32,
29046
29047 ivSize: 64/32,
29048
29049 blockSize: 64/32
29050 });
29051
29052 /**
29053 * Shortcut functions to the cipher's object interface.
29054 *
29055 * @example
29056 *
29057 * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
29058 * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
29059 */
29060 C.TripleDES = BlockCipher._createHelper(TripleDES);
29061 }());
29062
29063
29064 return CryptoJS.TripleDES;
29065
29066 }));
29067 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],62:[function(_dereq_,module,exports){
29068 ;(function (root, factory) {
29069 if (typeof exports === "object") {
29070 // CommonJS
29071 module.exports = exports = factory(_dereq_("./core"));
29072 }
29073 else if (typeof define === "function" && define.amd) {
29074 // AMD
29075 define(["./core"], factory);
29076 }
29077 else {
29078 // Global (browser)
29079 factory(root.CryptoJS);
29080 }
29081 }(this, function (CryptoJS) {
29082
29083 (function (undefined) {
29084 // Shortcuts
29085 var C = CryptoJS;
29086 var C_lib = C.lib;
29087 var Base = C_lib.Base;
29088 var X32WordArray = C_lib.WordArray;
29089
29090 /**
29091 * x64 namespace.
29092 */
29093 var C_x64 = C.x64 = {};
29094
29095 /**
29096 * A 64-bit word.
29097 */
29098 var X64Word = C_x64.Word = Base.extend({
29099 /**
29100 * Initializes a newly created 64-bit word.
29101 *
29102 * @param {number} high The high 32 bits.
29103 * @param {number} low The low 32 bits.
29104 *
29105 * @example
29106 *
29107 * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
29108 */
29109 init: function (high, low) {
29110 this.high = high;
29111 this.low = low;
29112 }
29113
29114 /**
29115 * Bitwise NOTs this word.
29116 *
29117 * @return {X64Word} A new x64-Word object after negating.
29118 *
29119 * @example
29120 *
29121 * var negated = x64Word.not();
29122 */
29123 // not: function () {
29124 // var high = ~this.high;
29125 // var low = ~this.low;
29126
29127 // return X64Word.create(high, low);
29128 // },
29129
29130 /**
29131 * Bitwise ANDs this word with the passed word.
29132 *
29133 * @param {X64Word} word The x64-Word to AND with this word.
29134 *
29135 * @return {X64Word} A new x64-Word object after ANDing.
29136 *
29137 * @example
29138 *
29139 * var anded = x64Word.and(anotherX64Word);
29140 */
29141 // and: function (word) {
29142 // var high = this.high & word.high;
29143 // var low = this.low & word.low;
29144
29145 // return X64Word.create(high, low);
29146 // },
29147
29148 /**
29149 * Bitwise ORs this word with the passed word.
29150 *
29151 * @param {X64Word} word The x64-Word to OR with this word.
29152 *
29153 * @return {X64Word} A new x64-Word object after ORing.
29154 *
29155 * @example
29156 *
29157 * var ored = x64Word.or(anotherX64Word);
29158 */
29159 // or: function (word) {
29160 // var high = this.high | word.high;
29161 // var low = this.low | word.low;
29162
29163 // return X64Word.create(high, low);
29164 // },
29165
29166 /**
29167 * Bitwise XORs this word with the passed word.
29168 *
29169 * @param {X64Word} word The x64-Word to XOR with this word.
29170 *
29171 * @return {X64Word} A new x64-Word object after XORing.
29172 *
29173 * @example
29174 *
29175 * var xored = x64Word.xor(anotherX64Word);
29176 */
29177 // xor: function (word) {
29178 // var high = this.high ^ word.high;
29179 // var low = this.low ^ word.low;
29180
29181 // return X64Word.create(high, low);
29182 // },
29183
29184 /**
29185 * Shifts this word n bits to the left.
29186 *
29187 * @param {number} n The number of bits to shift.
29188 *
29189 * @return {X64Word} A new x64-Word object after shifting.
29190 *
29191 * @example
29192 *
29193 * var shifted = x64Word.shiftL(25);
29194 */
29195 // shiftL: function (n) {
29196 // if (n < 32) {
29197 // var high = (this.high << n) | (this.low >>> (32 - n));
29198 // var low = this.low << n;
29199 // } else {
29200 // var high = this.low << (n - 32);
29201 // var low = 0;
29202 // }
29203
29204 // return X64Word.create(high, low);
29205 // },
29206
29207 /**
29208 * Shifts this word n bits to the right.
29209 *
29210 * @param {number} n The number of bits to shift.
29211 *
29212 * @return {X64Word} A new x64-Word object after shifting.
29213 *
29214 * @example
29215 *
29216 * var shifted = x64Word.shiftR(7);
29217 */
29218 // shiftR: function (n) {
29219 // if (n < 32) {
29220 // var low = (this.low >>> n) | (this.high << (32 - n));
29221 // var high = this.high >>> n;
29222 // } else {
29223 // var low = this.high >>> (n - 32);
29224 // var high = 0;
29225 // }
29226
29227 // return X64Word.create(high, low);
29228 // },
29229
29230 /**
29231 * Rotates this word n bits to the left.
29232 *
29233 * @param {number} n The number of bits to rotate.
29234 *
29235 * @return {X64Word} A new x64-Word object after rotating.
29236 *
29237 * @example
29238 *
29239 * var rotated = x64Word.rotL(25);
29240 */
29241 // rotL: function (n) {
29242 // return this.shiftL(n).or(this.shiftR(64 - n));
29243 // },
29244
29245 /**
29246 * Rotates this word n bits to the right.
29247 *
29248 * @param {number} n The number of bits to rotate.
29249 *
29250 * @return {X64Word} A new x64-Word object after rotating.
29251 *
29252 * @example
29253 *
29254 * var rotated = x64Word.rotR(7);
29255 */
29256 // rotR: function (n) {
29257 // return this.shiftR(n).or(this.shiftL(64 - n));
29258 // },
29259
29260 /**
29261 * Adds this word with the passed word.
29262 *
29263 * @param {X64Word} word The x64-Word to add with this word.
29264 *
29265 * @return {X64Word} A new x64-Word object after adding.
29266 *
29267 * @example
29268 *
29269 * var added = x64Word.add(anotherX64Word);
29270 */
29271 // add: function (word) {
29272 // var low = (this.low + word.low) | 0;
29273 // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
29274 // var high = (this.high + word.high + carry) | 0;
29275
29276 // return X64Word.create(high, low);
29277 // }
29278 });
29279
29280 /**
29281 * An array of 64-bit words.
29282 *
29283 * @property {Array} words The array of CryptoJS.x64.Word objects.
29284 * @property {number} sigBytes The number of significant bytes in this word array.
29285 */
29286 var X64WordArray = C_x64.WordArray = Base.extend({
29287 /**
29288 * Initializes a newly created word array.
29289 *
29290 * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
29291 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
29292 *
29293 * @example
29294 *
29295 * var wordArray = CryptoJS.x64.WordArray.create();
29296 *
29297 * var wordArray = CryptoJS.x64.WordArray.create([
29298 * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
29299 * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
29300 * ]);
29301 *
29302 * var wordArray = CryptoJS.x64.WordArray.create([
29303 * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
29304 * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
29305 * ], 10);
29306 */
29307 init: function (words, sigBytes) {
29308 words = this.words = words || [];
29309
29310 if (sigBytes != undefined) {
29311 this.sigBytes = sigBytes;
29312 } else {
29313 this.sigBytes = words.length * 8;
29314 }
29315 },
29316
29317 /**
29318 * Converts this 64-bit word array to a 32-bit word array.
29319 *
29320 * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
29321 *
29322 * @example
29323 *
29324 * var x32WordArray = x64WordArray.toX32();
29325 */
29326 toX32: function () {
29327 // Shortcuts
29328 var x64Words = this.words;
29329 var x64WordsLength = x64Words.length;
29330
29331 // Convert
29332 var x32Words = [];
29333 for (var i = 0; i < x64WordsLength; i++) {
29334 var x64Word = x64Words[i];
29335 x32Words.push(x64Word.high);
29336 x32Words.push(x64Word.low);
29337 }
29338
29339 return X32WordArray.create(x32Words, this.sigBytes);
29340 },
29341
29342 /**
29343 * Creates a copy of this word array.
29344 *
29345 * @return {X64WordArray} The clone.
29346 *
29347 * @example
29348 *
29349 * var clone = x64WordArray.clone();
29350 */
29351 clone: function () {
29352 var clone = Base.clone.call(this);
29353
29354 // Clone "words" array
29355 var words = clone.words = this.words.slice(0);
29356
29357 // Clone each X64Word object
29358 var wordsLength = words.length;
29359 for (var i = 0; i < wordsLength; i++) {
29360 words[i] = words[i].clone();
29361 }
29362
29363 return clone;
29364 }
29365 });
29366 }());
29367
29368
29369 return CryptoJS;
29370
29371 }));
29372 },{"./core":31}],63:[function(_dereq_,module,exports){
29373 var assert = _dereq_('assert')
29374 var BigInteger = _dereq_('bigi')
29375
29376 var Point = _dereq_('./point')
29377
29378 function Curve(p, a, b, Gx, Gy, n, h) {
29379 this.p = p
29380 this.a = a
29381 this.b = b
29382 this.G = Point.fromAffine(this, Gx, Gy)
29383 this.n = n
29384 this.h = h
29385
29386 this.infinity = new Point(this, null, null, BigInteger.ZERO)
29387
29388 // result caching
29389 this.pOverFour = p.add(BigInteger.ONE).shiftRight(2)
29390 }
29391
29392 Curve.prototype.pointFromX = function(isOdd, x) {
29393 var alpha = x.pow(3).add(this.a.multiply(x)).add(this.b).mod(this.p)
29394 var beta = alpha.modPow(this.pOverFour, this.p)
29395
29396 var y = beta
29397 if (beta.isEven() ^ !isOdd) {
29398 y = this.p.subtract(y) // -y % p
29399 }
29400
29401 return Point.fromAffine(this, x, y)
29402 }
29403
29404 Curve.prototype.isInfinity = function(Q) {
29405 if (Q === this.infinity) return true
29406
29407 return Q.z.signum() === 0 && Q.y.signum() !== 0
29408 }
29409
29410 Curve.prototype.isOnCurve = function(Q) {
29411 if (this.isInfinity(Q)) return true
29412
29413 var x = Q.affineX
29414 var y = Q.affineY
29415 var a = this.a
29416 var b = this.b
29417 var p = this.p
29418
29419 // Check that xQ and yQ are integers in the interval [0, p - 1]
29420 if (x.signum() < 0 || x.compareTo(p) >= 0) return false
29421 if (y.signum() < 0 || y.compareTo(p) >= 0) return false
29422
29423 // and check that y^2 = x^3 + ax + b (mod p)
29424 var lhs = y.square().mod(p)
29425 var rhs = x.pow(3).add(a.multiply(x)).add(b).mod(p)
29426 return lhs.equals(rhs)
29427 }
29428
29429 /**
29430 * Validate an elliptic curve point.
29431 *
29432 * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive
29433 */
29434 Curve.prototype.validate = function(Q) {
29435 // Check Q != O
29436 assert(!this.isInfinity(Q), 'Point is at infinity')
29437 assert(this.isOnCurve(Q), 'Point is not on the curve')
29438
29439 // Check nQ = O (where Q is a scalar multiple of G)
29440 var nQ = Q.multiply(this.n)
29441 assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G')
29442
29443 return true
29444 }
29445
29446 module.exports = Curve
29447
29448 },{"./point":67,"assert":4,"bigi":3}],64:[function(_dereq_,module,exports){
29449 module.exports={
29450 "secp128r1": {
29451 "p": "fffffffdffffffffffffffffffffffff",
29452 "a": "fffffffdfffffffffffffffffffffffc",
29453 "b": "e87579c11079f43dd824993c2cee5ed3",
29454 "n": "fffffffe0000000075a30d1b9038a115",
29455 "h": "01",
29456 "Gx": "161ff7528b899b2d0c28607ca52c5b86",
29457 "Gy": "cf5ac8395bafeb13c02da292dded7a83"
29458 },
29459 "secp160k1": {
29460 "p": "fffffffffffffffffffffffffffffffeffffac73",
29461 "a": "00",
29462 "b": "07",
29463 "n": "0100000000000000000001b8fa16dfab9aca16b6b3",
29464 "h": "01",
29465 "Gx": "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",
29466 "Gy": "938cf935318fdced6bc28286531733c3f03c4fee"
29467 },
29468 "secp160r1": {
29469 "p": "ffffffffffffffffffffffffffffffff7fffffff",
29470 "a": "ffffffffffffffffffffffffffffffff7ffffffc",
29471 "b": "1c97befc54bd7a8b65acf89f81d4d4adc565fa45",
29472 "n": "0100000000000000000001f4c8f927aed3ca752257",
29473 "h": "01",
29474 "Gx": "4a96b5688ef573284664698968c38bb913cbfc82",
29475 "Gy": "23a628553168947d59dcc912042351377ac5fb32"
29476 },
29477 "secp192k1": {
29478 "p": "fffffffffffffffffffffffffffffffffffffffeffffee37",
29479 "a": "00",
29480 "b": "03",
29481 "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d",
29482 "h": "01",
29483 "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",
29484 "Gy": "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"
29485 },
29486 "secp192r1": {
29487 "p": "fffffffffffffffffffffffffffffffeffffffffffffffff",
29488 "a": "fffffffffffffffffffffffffffffffefffffffffffffffc",
29489 "b": "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",
29490 "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831",
29491 "h": "01",
29492 "Gx": "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",
29493 "Gy": "07192b95ffc8da78631011ed6b24cdd573f977a11e794811"
29494 },
29495 "secp224r1": {
29496 "p": "ffffffffffffffffffffffffffffffff000000000000000000000001",
29497 "a": "fffffffffffffffffffffffffffffffefffffffffffffffffffffffe",
29498 "b": "b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4",
29499 "n": "ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d",
29500 "h": "01",
29501 "Gx": "b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21",
29502 "Gy": "bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"
29503 },
29504 "secp256k1": {
29505 "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
29506 "a": "00",
29507 "b": "07",
29508 "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
29509 "h": "01",
29510 "Gx": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
29511 "Gy": "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
29512 },
29513 "secp256r1": {
29514 "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
29515 "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",
29516 "b": "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
29517 "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
29518 "h": "01",
29519 "Gx": "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
29520 "Gy": "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"
29521 }
29522 }
29523
29524 },{}],65:[function(_dereq_,module,exports){
29525 var Point = _dereq_('./point')
29526 var Curve = _dereq_('./curve')
29527
29528 var getCurveByName = _dereq_('./names')
29529
29530 module.exports = {
29531 Curve: Curve,
29532 Point: Point,
29533 getCurveByName: getCurveByName
29534 }
29535
29536 },{"./curve":63,"./names":66,"./point":67}],66:[function(_dereq_,module,exports){
29537 var BigInteger = _dereq_('bigi')
29538
29539 var curves = _dereq_('./curves')
29540 var Curve = _dereq_('./curve')
29541
29542 function getCurveByName(name) {
29543 var curve = curves[name]
29544 if (!curve) return null
29545
29546 var p = new BigInteger(curve.p, 16)
29547 var a = new BigInteger(curve.a, 16)
29548 var b = new BigInteger(curve.b, 16)
29549 var n = new BigInteger(curve.n, 16)
29550 var h = new BigInteger(curve.h, 16)
29551 var Gx = new BigInteger(curve.Gx, 16)
29552 var Gy = new BigInteger(curve.Gy, 16)
29553
29554 return new Curve(p, a, b, Gx, Gy, n, h)
29555 }
29556
29557 module.exports = getCurveByName
29558
29559 },{"./curve":63,"./curves":64,"bigi":3}],67:[function(_dereq_,module,exports){
29560 (function (Buffer){
29561 var assert = _dereq_('assert')
29562 var BigInteger = _dereq_('bigi')
29563
29564 var THREE = BigInteger.valueOf(3)
29565
29566 function Point(curve, x, y, z) {
29567 assert.notStrictEqual(z, undefined, 'Missing Z coordinate')
29568
29569 this.curve = curve
29570 this.x = x
29571 this.y = y
29572 this.z = z
29573 this._zInv = null
29574
29575 this.compressed = true
29576 }
29577
29578 Object.defineProperty(Point.prototype, 'zInv', {
29579 get: function() {
29580 if (this._zInv === null) {
29581 this._zInv = this.z.modInverse(this.curve.p)
29582 }
29583
29584 return this._zInv
29585 }
29586 })
29587
29588 Object.defineProperty(Point.prototype, 'affineX', {
29589 get: function() {
29590 return this.x.multiply(this.zInv).mod(this.curve.p)
29591 }
29592 })
29593
29594 Object.defineProperty(Point.prototype, 'affineY', {
29595 get: function() {
29596 return this.y.multiply(this.zInv).mod(this.curve.p)
29597 }
29598 })
29599
29600 Point.fromAffine = function(curve, x, y) {
29601 return new Point(curve, x, y, BigInteger.ONE)
29602 }
29603
29604 Point.prototype.equals = function(other) {
29605 if (other === this) return true
29606 if (this.curve.isInfinity(this)) return this.curve.isInfinity(other)
29607 if (this.curve.isInfinity(other)) return this.curve.isInfinity(this)
29608
29609 // u = Y2 * Z1 - Y1 * Z2
29610 var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p)
29611
29612 if (u.signum() !== 0) return false
29613
29614 // v = X2 * Z1 - X1 * Z2
29615 var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p)
29616
29617 return v.signum() === 0
29618 }
29619
29620 Point.prototype.negate = function() {
29621 var y = this.curve.p.subtract(this.y)
29622
29623 return new Point(this.curve, this.x, y, this.z)
29624 }
29625
29626 Point.prototype.add = function(b) {
29627 if (this.curve.isInfinity(this)) return b
29628 if (this.curve.isInfinity(b)) return this
29629
29630 var x1 = this.x
29631 var y1 = this.y
29632 var x2 = b.x
29633 var y2 = b.y
29634
29635 // u = Y2 * Z1 - Y1 * Z2
29636 var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p)
29637 // v = X2 * Z1 - X1 * Z2
29638 var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p)
29639
29640 if (v.signum() === 0) {
29641 if (u.signum() === 0) {
29642 return this.twice() // this == b, so double
29643 }
29644
29645 return this.curve.infinity // this = -b, so infinity
29646 }
29647
29648 var v2 = v.square()
29649 var v3 = v2.multiply(v)
29650 var x1v2 = x1.multiply(v2)
29651 var zu2 = u.square().multiply(this.z)
29652
29653 // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3)
29654 var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p)
29655 // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3
29656 var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.p)
29657 // z3 = v^3 * z1 * z2
29658 var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p)
29659
29660 return new Point(this.curve, x3, y3, z3)
29661 }
29662
29663 Point.prototype.twice = function() {
29664 if (this.curve.isInfinity(this)) return this
29665 if (this.y.signum() === 0) return this.curve.infinity
29666
29667 var x1 = this.x
29668 var y1 = this.y
29669
29670 var y1z1 = y1.multiply(this.z)
29671 var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p)
29672 var a = this.curve.a
29673
29674 // w = 3 * x1^2 + a * z1^2
29675 var w = x1.square().multiply(THREE)
29676
29677 if (a.signum() !== 0) {
29678 w = w.add(this.z.square().multiply(a))
29679 }
29680
29681 w = w.mod(this.curve.p)
29682 // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1)
29683 var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.p)
29684 // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3
29685 var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.pow(3)).mod(this.curve.p)
29686 // z3 = 8 * (y1 * z1)^3
29687 var z3 = y1z1.pow(3).shiftLeft(3).mod(this.curve.p)
29688
29689 return new Point(this.curve, x3, y3, z3)
29690 }
29691
29692 // Simple NAF (Non-Adjacent Form) multiplication algorithm
29693 // TODO: modularize the multiplication algorithm
29694 Point.prototype.multiply = function(k) {
29695 if (this.curve.isInfinity(this)) return this
29696 if (k.signum() === 0) return this.curve.infinity
29697
29698 var e = k
29699 var h = e.multiply(THREE)
29700
29701 var neg = this.negate()
29702 var R = this
29703
29704 for (var i = h.bitLength() - 2; i > 0; --i) {
29705 R = R.twice()
29706
29707 var hBit = h.testBit(i)
29708 var eBit = e.testBit(i)
29709
29710 if (hBit != eBit) {
29711 R = R.add(hBit ? this : neg)
29712 }
29713 }
29714
29715 return R
29716 }
29717
29718 // Compute this*j + x*k (simultaneous multiplication)
29719 Point.prototype.multiplyTwo = function(j, x, k) {
29720 var i
29721
29722 if (j.bitLength() > k.bitLength())
29723 i = j.bitLength() - 1
29724 else
29725 i = k.bitLength() - 1
29726
29727 var R = this.curve.infinity
29728 var both = this.add(x)
29729
29730 while (i >= 0) {
29731 R = R.twice()
29732
29733 var jBit = j.testBit(i)
29734 var kBit = k.testBit(i)
29735
29736 if (jBit) {
29737 if (kBit) {
29738 R = R.add(both)
29739
29740 } else {
29741 R = R.add(this)
29742 }
29743
29744 } else {
29745 if (kBit) {
29746 R = R.add(x)
29747 }
29748 }
29749 --i
29750 }
29751
29752 return R
29753 }
29754
29755 Point.prototype.getEncoded = function(compressed) {
29756 if (compressed == undefined) compressed = this.compressed
29757 if (this.curve.isInfinity(this)) return new Buffer('00', 'hex') // Infinity point encoded is simply '00'
29758
29759 var x = this.affineX
29760 var y = this.affineY
29761
29762 var buffer
29763
29764 // Determine size of q in bytes
29765 var byteLength = Math.floor((this.curve.p.bitLength() + 7) / 8)
29766
29767 // 0x02/0x03 | X
29768 if (compressed) {
29769 buffer = new Buffer(1 + byteLength)
29770 buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0)
29771
29772 // 0x04 | X | Y
29773 } else {
29774 buffer = new Buffer(1 + byteLength + byteLength)
29775 buffer.writeUInt8(0x04, 0)
29776
29777 y.toBuffer(byteLength).copy(buffer, 1 + byteLength)
29778 }
29779
29780 x.toBuffer(byteLength).copy(buffer, 1)
29781
29782 return buffer
29783 }
29784
29785 Point.decodeFrom = function(curve, buffer) {
29786 var type = buffer.readUInt8(0)
29787 var compressed = (type !== 4)
29788
29789 var x = BigInteger.fromBuffer(buffer.slice(1, 33))
29790 var byteLength = Math.floor((curve.p.bitLength() + 7) / 8)
29791
29792 var Q
29793 if (compressed) {
29794 assert.equal(buffer.length, byteLength + 1, 'Invalid sequence length')
29795 assert(type === 0x02 || type === 0x03, 'Invalid sequence tag')
29796
29797 var isOdd = (type === 0x03)
29798 Q = curve.pointFromX(isOdd, x)
29799
29800 } else {
29801 assert.equal(buffer.length, 1 + byteLength + byteLength, 'Invalid sequence length')
29802
29803 var y = BigInteger.fromBuffer(buffer.slice(1 + byteLength))
29804 Q = Point.fromAffine(curve, x, y)
29805 }
29806
29807 Q.compressed = compressed
29808 return Q
29809 }
29810
29811 Point.prototype.toString = function () {
29812 if (this.curve.isInfinity(this)) return '(INFINITY)'
29813
29814 return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')'
29815 }
29816
29817 module.exports = Point
29818
29819 }).call(this,_dereq_("buffer").Buffer)
29820 },{"assert":4,"bigi":3,"buffer":8}],68:[function(_dereq_,module,exports){
29821 (function (process,Buffer){
29822 // Closure compiler error - result of 'not' operator not being used
29823 //!function(globals){
29824 (function(globals){
29825 'use strict'
29826
29827 //*** UMD BEGIN
29828 if (typeof define !== 'undefined' && define.amd) { //require.js / AMD
29829 define([], function() {
29830 return secureRandom
29831 })
29832 } else if (typeof module !== 'undefined' && module.exports) { //CommonJS
29833 module.exports = secureRandom
29834 } else { //script / browser
29835 globals.secureRandom = secureRandom
29836 }
29837 //*** UMD END
29838
29839 //options.type is the only valid option
29840 function secureRandom(count, options) {
29841 options = options || {type: 'Array'}
29842 //we check for process.pid to prevent browserify from tricking us
29843 if (typeof process != 'undefined' && typeof process.pid == 'number') {
29844 return nodeRandom(count, options)
29845 } else {
29846 var crypto = window.crypto || window.msCrypto
29847 if (!crypto) throw new Error("Your browser does not support window.crypto.")
29848 return browserRandom(count, options)
29849 }
29850 }
29851
29852 function nodeRandom(count, options) {
29853 var crypto = _dereq_('crypto')
29854 var buf = crypto.randomBytes(count)
29855
29856 switch (options.type) {
29857 case 'Array':
29858 return [].slice.call(buf)
29859 case 'Buffer':
29860 return buf
29861 case 'Uint8Array':
29862 var arr = new Uint8Array(count)
29863 for (var i = 0; i < count; ++i) { arr[i] = buf.readUInt8(i) }
29864 return arr
29865 default:
29866 throw new Error(options.type + " is unsupported.")
29867 }
29868 }
29869
29870 function browserRandom(count, options) {
29871 var nativeArr = new Uint8Array(count)
29872 var crypto = window.crypto || window.msCrypto
29873 crypto.getRandomValues(nativeArr)
29874
29875 switch (options.type) {
29876 case 'Array':
29877 return [].slice.call(nativeArr)
29878 case 'Buffer':
29879 try { var b = new Buffer(1) } catch(e) { throw new Error('Buffer not supported in this environment. Use Node.js or Browserify for browser support.')}
29880 return new Buffer(nativeArr)
29881 case 'Uint8Array':
29882 return nativeArr
29883 default:
29884 throw new Error(options.type + " is unsupported.")
29885 }
29886 }
29887
29888 secureRandom.randomArray = function(byteCount) {
29889 return secureRandom(byteCount, {type: 'Array'})
29890 }
29891
29892 secureRandom.randomUint8Array = function(byteCount) {
29893 return secureRandom(byteCount, {type: 'Uint8Array'})
29894 }
29895
29896 secureRandom.randomBuffer = function(byteCount) {
29897 return secureRandom(byteCount, {type: 'Buffer'})
29898 }
29899
29900
29901 })(this);
29902
29903 }).call(this,_dereq_("FWaASH"),_dereq_("buffer").Buffer)
29904 },{"FWaASH":12,"buffer":8,"crypto":7}],69:[function(_dereq_,module,exports){
29905 (function (Buffer){
29906 var assert = _dereq_('assert')
29907 var base58check = _dereq_('./base58check')
29908 var networks = _dereq_('./networks')
29909 var scripts = _dereq_('./scripts')
29910
29911 function findScriptTypeByVersion(version) {
29912 for (var networkName in networks) {
29913 var network = networks[networkName]
29914
29915 if (version === network.pubKeyHash) return 'pubkeyhash'
29916 if (version === network.scriptHash) return 'scripthash'
29917 }
29918 }
29919
29920 function Address(hash, version) {
29921 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
29922 assert.strictEqual(hash.length, 20, 'Invalid hash length')
29923 assert.strictEqual(version & 0xff, version, 'Invalid version byte')
29924
29925 this.hash = hash
29926 this.version = version
29927 }
29928
29929 // Import functions
29930 Address.fromBase58Check = function(string) {
29931 var payload = base58check.decode(string)
29932 var version = payload.readUInt8(0)
29933 var hash = payload.slice(1)
29934
29935 return new Address(hash, version)
29936 }
29937
29938 Address.fromOutputScript = function(script, network) {
29939 network = network || networks.bitcoin
29940
29941 var type = scripts.classifyOutput(script)
29942
29943 if (type === 'pubkeyhash') return new Address(script.chunks[2], network.pubKeyHash)
29944 if (type === 'scripthash') return new Address(script.chunks[1], network.scriptHash)
29945
29946 assert(false, type + ' has no matching Address')
29947 }
29948
29949 // Export functions
29950 Address.prototype.toBase58Check = function () {
29951 var payload = new Buffer(21)
29952 payload.writeUInt8(this.version, 0)
29953 this.hash.copy(payload, 1)
29954
29955 return base58check.encode(payload)
29956 }
29957
29958 Address.prototype.toOutputScript = function() {
29959 var scriptType = findScriptTypeByVersion(this.version)
29960
29961 if (scriptType === 'pubkeyhash') return scripts.pubKeyHashOutput(this.hash)
29962 if (scriptType === 'scripthash') return scripts.scriptHashOutput(this.hash)
29963
29964 assert(false, this.toString() + ' has no matching Script')
29965 }
29966
29967 Address.prototype.toString = Address.prototype.toBase58Check
29968
29969 module.exports = Address
29970
29971 }).call(this,_dereq_("buffer").Buffer)
29972 },{"./base58check":70,"./networks":81,"./scripts":84,"assert":4,"buffer":8}],70:[function(_dereq_,module,exports){
29973 (function (Buffer){
29974 // https://en.bitcoin.it/wiki/Base58Check_encoding
29975 var assert = _dereq_('assert')
29976 var base58 = _dereq_('bs58')
29977 var crypto = _dereq_('./crypto')
29978
29979 // Encode a buffer as a base58-check-encoded string
29980 function encode(payload) {
29981 var checksum = crypto.hash256(payload).slice(0, 4)
29982
29983 return base58.encode(Buffer.concat([
29984 payload,
29985 checksum
29986 ]))
29987 }
29988
29989 // Decode a base58-check-encoded string to a buffer
29990 function decode(string) {
29991 var buffer = base58.decode(string)
29992
29993 var payload = buffer.slice(0, -4)
29994 var checksum = buffer.slice(-4)
29995 var newChecksum = crypto.hash256(payload).slice(0, 4)
29996
29997 assert.deepEqual(newChecksum, checksum, 'Invalid checksum')
29998
29999 return payload
30000 }
30001
30002 module.exports = {
30003 encode: encode,
30004 decode: decode
30005 }
30006
30007 }).call(this,_dereq_("buffer").Buffer)
30008 },{"./crypto":73,"assert":4,"bs58":15,"buffer":8}],71:[function(_dereq_,module,exports){
30009 var assert = _dereq_('assert')
30010 var opcodes = _dereq_('./opcodes')
30011
30012 // https://github.com/feross/buffer/blob/master/index.js#L1127
30013 function verifuint(value, max) {
30014 assert(typeof value === 'number', 'cannot write a non-number as a number')
30015 assert(value >= 0, 'specified a negative value for writing an unsigned value')
30016 assert(value <= max, 'value is larger than maximum value for type')
30017 assert(Math.floor(value) === value, 'value has a fractional component')
30018 }
30019
30020 function pushDataSize(i) {
30021 return i < opcodes.OP_PUSHDATA1 ? 1
30022 : i < 0xff ? 2
30023 : i < 0xffff ? 3
30024 : 5
30025 }
30026
30027 function readPushDataInt(buffer, offset) {
30028 var opcode = buffer.readUInt8(offset)
30029 var number, size
30030
30031 // ~6 bit
30032 if (opcode < opcodes.OP_PUSHDATA1) {
30033 number = opcode
30034 size = 1
30035
30036 // 8 bit
30037 } else if (opcode === opcodes.OP_PUSHDATA1) {
30038 number = buffer.readUInt8(offset + 1)
30039 size = 2
30040
30041 // 16 bit
30042 } else if (opcode === opcodes.OP_PUSHDATA2) {
30043 number = buffer.readUInt16LE(offset + 1)
30044 size = 3
30045
30046 // 32 bit
30047 } else {
30048 assert.equal(opcode, opcodes.OP_PUSHDATA4, 'Unexpected opcode')
30049
30050 number = buffer.readUInt32LE(offset + 1)
30051 size = 5
30052
30053 }
30054
30055 return {
30056 opcode: opcode,
30057 number: number,
30058 size: size
30059 }
30060 }
30061
30062 function readUInt64LE(buffer, offset) {
30063 var a = buffer.readUInt32LE(offset)
30064 var b = buffer.readUInt32LE(offset + 4)
30065 b *= 0x100000000
30066
30067 verifuint(b + a, 0x001fffffffffffff)
30068
30069 return b + a
30070 }
30071
30072 function readVarInt(buffer, offset) {
30073 var t = buffer.readUInt8(offset)
30074 var number, size
30075
30076 // 8 bit
30077 if (t < 253) {
30078 number = t
30079 size = 1
30080
30081 // 16 bit
30082 } else if (t < 254) {
30083 number = buffer.readUInt16LE(offset + 1)
30084 size = 3
30085
30086 // 32 bit
30087 } else if (t < 255) {
30088 number = buffer.readUInt32LE(offset + 1)
30089 size = 5
30090
30091 // 64 bit
30092 } else {
30093 number = readUInt64LE(buffer, offset + 1)
30094 size = 9
30095 }
30096
30097 return {
30098 number: number,
30099 size: size
30100 }
30101 }
30102
30103 function writePushDataInt(buffer, number, offset) {
30104 var size = pushDataSize(number)
30105
30106 // ~6 bit
30107 if (size === 1) {
30108 buffer.writeUInt8(number, offset)
30109
30110 // 8 bit
30111 } else if (size === 2) {
30112 buffer.writeUInt8(opcodes.OP_PUSHDATA1, offset)
30113 buffer.writeUInt8(number, offset + 1)
30114
30115 // 16 bit
30116 } else if (size === 3) {
30117 buffer.writeUInt8(opcodes.OP_PUSHDATA2, offset)
30118 buffer.writeUInt16LE(number, offset + 1)
30119
30120 // 32 bit
30121 } else {
30122 buffer.writeUInt8(opcodes.OP_PUSHDATA4, offset)
30123 buffer.writeUInt32LE(number, offset + 1)
30124
30125 }
30126
30127 return size
30128 }
30129
30130 function writeUInt64LE(buffer, value, offset) {
30131 verifuint(value, 0x001fffffffffffff)
30132
30133 buffer.writeInt32LE(value & -1, offset)
30134 buffer.writeUInt32LE(Math.floor(value / 0x100000000), offset + 4)
30135 }
30136
30137 function varIntSize(i) {
30138 return i < 253 ? 1
30139 : i < 0x10000 ? 3
30140 : i < 0x100000000 ? 5
30141 : 9
30142 }
30143
30144 function writeVarInt(buffer, number, offset) {
30145 var size = varIntSize(number)
30146
30147 // 8 bit
30148 if (size === 1) {
30149 buffer.writeUInt8(number, offset)
30150
30151 // 16 bit
30152 } else if (size === 3) {
30153 buffer.writeUInt8(253, offset)
30154 buffer.writeUInt16LE(number, offset + 1)
30155
30156 // 32 bit
30157 } else if (size === 5) {
30158 buffer.writeUInt8(254, offset)
30159 buffer.writeUInt32LE(number, offset + 1)
30160
30161 // 64 bit
30162 } else {
30163 buffer.writeUInt8(255, offset)
30164 writeUInt64LE(buffer, number, offset + 1)
30165 }
30166
30167 return size
30168 }
30169
30170 module.exports = {
30171 pushDataSize: pushDataSize,
30172 readPushDataInt: readPushDataInt,
30173 readUInt64LE: readUInt64LE,
30174 readVarInt: readVarInt,
30175 varIntSize: varIntSize,
30176 writePushDataInt: writePushDataInt,
30177 writeUInt64LE: writeUInt64LE,
30178 writeVarInt: writeVarInt
30179 }
30180
30181 },{"./opcodes":82,"assert":4}],72:[function(_dereq_,module,exports){
30182 (function (Buffer){
30183 var assert = _dereq_('assert')
30184 var Crypto = _dereq_('crypto-js')
30185 var WordArray = Crypto.lib.WordArray
30186
30187 function bufferToWordArray(buffer) {
30188 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got', buffer)
30189
30190 var words = []
30191 for (var i = 0, b = 0; i < buffer.length; i++, b += 8) {
30192 words[b >>> 5] |= buffer[i] << (24 - b % 32)
30193 }
30194
30195 return new WordArray.init(words, buffer.length)
30196 }
30197
30198 function wordArrayToBuffer(wordArray) {
30199 assert(Array.isArray(wordArray.words), 'Expected WordArray, got' + wordArray)
30200
30201 var words = wordArray.words
30202 var buffer = new Buffer(words.length * 4)
30203
30204 words.forEach(function(value, i) {
30205 buffer.writeInt32BE(value & -1, i * 4)
30206 })
30207
30208 return buffer
30209 }
30210
30211 module.exports = {
30212 bufferToWordArray: bufferToWordArray,
30213 wordArrayToBuffer: wordArrayToBuffer
30214 }
30215
30216 }).call(this,_dereq_("buffer").Buffer)
30217 },{"assert":4,"buffer":8,"crypto-js":37}],73:[function(_dereq_,module,exports){
30218 (function (Buffer){
30219 // Crypto, crypto, where art thou crypto
30220 var assert = _dereq_('assert')
30221 var CryptoJS = _dereq_('crypto-js')
30222 var crypto = _dereq_('crypto')
30223 var convert = _dereq_('./convert')
30224
30225 function hash160(buffer) {
30226 return ripemd160(sha256(buffer))
30227 }
30228
30229 function hash256(buffer) {
30230 return sha256(sha256(buffer))
30231 }
30232
30233 function ripemd160(buffer) {
30234 return crypto.createHash('rmd160').update(buffer).digest()
30235 }
30236
30237 function sha1(buffer) {
30238 return crypto.createHash('sha1').update(buffer).digest()
30239 }
30240
30241 function sha256(buffer) {
30242 return crypto.createHash('sha256').update(buffer).digest()
30243 }
30244
30245 // FIXME: Name not consistent with others
30246 function HmacSHA256(buffer, secret) {
30247 return crypto.createHmac('sha256', secret).update(buffer).digest()
30248 }
30249
30250 function HmacSHA512(data, secret) {
30251 assert(Buffer.isBuffer(data), 'Expected Buffer for data, got ' + data)
30252 assert(Buffer.isBuffer(secret), 'Expected Buffer for secret, got ' + secret)
30253
30254 var dataWords = convert.bufferToWordArray(data)
30255 var secretWords = convert.bufferToWordArray(secret)
30256
30257 var hash = CryptoJS.HmacSHA512(dataWords, secretWords)
30258
30259 return convert.wordArrayToBuffer(hash)
30260 }
30261
30262 module.exports = {
30263 ripemd160: ripemd160,
30264 sha1: sha1,
30265 sha256: sha256,
30266 hash160: hash160,
30267 hash256: hash256,
30268 HmacSHA256: HmacSHA256,
30269 HmacSHA512: HmacSHA512
30270 }
30271
30272 }).call(this,_dereq_("buffer").Buffer)
30273 },{"./convert":72,"assert":4,"buffer":8,"crypto":19,"crypto-js":37}],74:[function(_dereq_,module,exports){
30274 (function (Buffer){
30275 var assert = _dereq_('assert')
30276 var crypto = _dereq_('./crypto')
30277
30278 var BigInteger = _dereq_('bigi')
30279 var ECSignature = _dereq_('./ecsignature')
30280 var Point = _dereq_('ecurve').Point
30281
30282 // https://tools.ietf.org/html/rfc6979#section-3.2
30283 function deterministicGenerateK(curve, hash, d) {
30284 assert(Buffer.isBuffer(hash), 'Hash must be a Buffer, not ' + hash)
30285 assert.equal(hash.length, 32, 'Hash must be 256 bit')
30286 assert(d instanceof BigInteger, 'Private key must be a BigInteger')
30287
30288 var x = d.toBuffer(32)
30289 var k = new Buffer(32)
30290 var v = new Buffer(32)
30291
30292 // Step B
30293 v.fill(1)
30294
30295 // Step C
30296 k.fill(0)
30297
30298 // Step D
30299 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([0]), x, hash]), k)
30300
30301 // Step E
30302 v = crypto.HmacSHA256(v, k)
30303
30304 // Step F
30305 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([1]), x, hash]), k)
30306
30307 // Step G
30308 v = crypto.HmacSHA256(v, k)
30309
30310 // Step H1/H2a, ignored as tlen === qlen (256 bit)
30311 // Step H2b
30312 v = crypto.HmacSHA256(v, k)
30313
30314 var T = BigInteger.fromBuffer(v)
30315
30316 // Step H3, repeat until T is within the interval [1, n - 1]
30317 while ((T.signum() <= 0) || (T.compareTo(curve.n) >= 0)) {
30318 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([0])]), k)
30319 v = crypto.HmacSHA256(v, k)
30320
30321 T = BigInteger.fromBuffer(v)
30322 }
30323
30324 return T
30325 }
30326
30327 function sign(curve, hash, d) {
30328 var k = deterministicGenerateK(curve, hash, d)
30329
30330 var n = curve.n
30331 var G = curve.G
30332 var Q = G.multiply(k)
30333 var e = BigInteger.fromBuffer(hash)
30334
30335 var r = Q.affineX.mod(n)
30336 assert.notEqual(r.signum(), 0, 'Invalid R value')
30337
30338 var s = k.modInverse(n).multiply(e.add(d.multiply(r))).mod(n)
30339 assert.notEqual(s.signum(), 0, 'Invalid S value')
30340
30341 var N_OVER_TWO = n.shiftRight(1)
30342
30343 // enforce low S values, see bip62: 'low s values in signatures'
30344 if (s.compareTo(N_OVER_TWO) > 0) {
30345 s = n.subtract(s)
30346 }
30347
30348 return new ECSignature(r, s)
30349 }
30350
30351 function verify(curve, hash, signature, Q) {
30352 var e = BigInteger.fromBuffer(hash)
30353
30354 return verifyRaw(curve, e, signature, Q)
30355 }
30356
30357 function verifyRaw(curve, e, signature, Q) {
30358 var n = curve.n
30359 var G = curve.G
30360
30361 var r = signature.r
30362 var s = signature.s
30363
30364 if (r.signum() === 0 || r.compareTo(n) >= 0) return false
30365 if (s.signum() === 0 || s.compareTo(n) >= 0) return false
30366
30367 var c = s.modInverse(n)
30368
30369 var u1 = e.multiply(c).mod(n)
30370 var u2 = r.multiply(c).mod(n)
30371
30372 var point = G.multiplyTwo(u1, Q, u2)
30373 var v = point.affineX.mod(n)
30374
30375 return v.equals(r)
30376 }
30377
30378 /**
30379 * Recover a public key from a signature.
30380 *
30381 * See SEC 1: Elliptic Curve Cryptography, section 4.1.6, "Public
30382 * Key Recovery Operation".
30383 *
30384 * http://www.secg.org/download/aid-780/sec1-v2.pdf
30385 */
30386 function recoverPubKey(curve, e, signature, i) {
30387 assert.strictEqual(i & 3, i, 'Recovery param is more than two bits')
30388
30389 var r = signature.r
30390 var s = signature.s
30391
30392 // A set LSB signifies that the y-coordinate is odd
30393 var isYOdd = i & 1
30394
30395 // The more significant bit specifies whether we should use the
30396 // first or second candidate key.
30397 var isSecondKey = i >> 1
30398
30399 var n = curve.n
30400 var G = curve.G
30401
30402 // 1.1 Let x = r + jn
30403 var x = isSecondKey ? r.add(n) : r
30404 var R = curve.pointFromX(isYOdd, x)
30405
30406 // 1.4 Check that nR is at infinity
30407 var nR = R.multiply(n)
30408 assert(curve.isInfinity(nR), 'nR is not a valid curve point')
30409
30410 // Compute -e from e
30411 var eNeg = e.negate().mod(n)
30412
30413 // 1.6.1 Compute Q = r^-1 (sR - eG)
30414 // Q = r^-1 (sR + -eG)
30415 var rInv = r.modInverse(n)
30416
30417 var Q = R.multiplyTwo(s, G, eNeg).multiply(rInv)
30418 curve.validate(Q)
30419
30420 return Q
30421 }
30422
30423 /**
30424 * Calculate pubkey extraction parameter.
30425 *
30426 * When extracting a pubkey from a signature, we have to
30427 * distinguish four different cases. Rather than putting this
30428 * burden on the verifier, Bitcoin includes a 2-bit value with the
30429 * signature.
30430 *
30431 * This function simply tries all four cases and returns the value
30432 * that resulted in a successful pubkey recovery.
30433 */
30434 function calcPubKeyRecoveryParam(curve, e, signature, Q) {
30435 for (var i = 0; i < 4; i++) {
30436 var Qprime = recoverPubKey(curve, e, signature, i)
30437
30438 // 1.6.2 Verify Q
30439 if (Qprime.equals(Q)) {
30440 return i
30441 }
30442 }
30443
30444 throw new Error('Unable to find valid recovery factor')
30445 }
30446
30447 module.exports = {
30448 calcPubKeyRecoveryParam: calcPubKeyRecoveryParam,
30449 deterministicGenerateK: deterministicGenerateK,
30450 recoverPubKey: recoverPubKey,
30451 sign: sign,
30452 verify: verify,
30453 verifyRaw: verifyRaw
30454 }
30455
30456 }).call(this,_dereq_("buffer").Buffer)
30457 },{"./crypto":73,"./ecsignature":77,"assert":4,"bigi":3,"buffer":8,"ecurve":65}],75:[function(_dereq_,module,exports){
30458 (function (Buffer){
30459 var assert = _dereq_('assert')
30460 var base58check = _dereq_('./base58check')
30461 var ecdsa = _dereq_('./ecdsa')
30462 var networks = _dereq_('./networks')
30463 var secureRandom = _dereq_('secure-random')
30464
30465 var BigInteger = _dereq_('bigi')
30466 var ECPubKey = _dereq_('./ecpubkey')
30467
30468 var ecurve = _dereq_('ecurve')
30469 var curve = ecurve.getCurveByName('secp256k1')
30470
30471 function ECKey(d, compressed) {
30472 assert(d.signum() > 0, 'Private key must be greater than 0')
30473 assert(d.compareTo(curve.n) < 0, 'Private key must be less than the curve order')
30474
30475 var Q = curve.G.multiply(d)
30476
30477 this.d = d
30478 this.pub = new ECPubKey(Q, compressed)
30479 }
30480
30481 // Static constructors
30482 ECKey.fromWIF = function(string) {
30483 var payload = base58check.decode(string)
30484 var compressed = false
30485
30486 // Ignore the version byte
30487 payload = payload.slice(1)
30488
30489 if (payload.length === 33) {
30490 assert.strictEqual(payload[32], 0x01, 'Invalid compression flag')
30491
30492 // Truncate the compression flag
30493 payload = payload.slice(0, -1)
30494 compressed = true
30495 }
30496
30497 assert.equal(payload.length, 32, 'Invalid WIF payload length')
30498
30499 var d = BigInteger.fromBuffer(payload)
30500 return new ECKey(d, compressed)
30501 }
30502
30503 ECKey.makeRandom = function(compressed, rng) {
30504 rng = rng || secureRandom.randomBuffer
30505
30506 var buffer = rng(32)
30507 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)
30508
30509 var d = BigInteger.fromBuffer(buffer)
30510 d = d.mod(curve.n)
30511
30512 return new ECKey(d, compressed)
30513 }
30514
30515 // Export functions
30516 ECKey.prototype.toWIF = function(network) {
30517 network = network || networks.bitcoin
30518
30519 var bufferLen = this.pub.compressed ? 34 : 33
30520 var buffer = new Buffer(bufferLen)
30521
30522 buffer.writeUInt8(network.wif, 0)
30523 this.d.toBuffer(32).copy(buffer, 1)
30524
30525 if (this.pub.compressed) {
30526 buffer.writeUInt8(0x01, 33)
30527 }
30528
30529 return base58check.encode(buffer)
30530 }
30531
30532 // Operations
30533 ECKey.prototype.sign = function(hash) {
30534 return ecdsa.sign(curve, hash, this.d)
30535 }
30536
30537 module.exports = ECKey
30538
30539 }).call(this,_dereq_("buffer").Buffer)
30540 },{"./base58check":70,"./ecdsa":74,"./ecpubkey":76,"./networks":81,"assert":4,"bigi":3,"buffer":8,"ecurve":65,"secure-random":68}],76:[function(_dereq_,module,exports){
30541 (function (Buffer){
30542 var assert = _dereq_('assert')
30543 var crypto = _dereq_('./crypto')
30544 var ecdsa = _dereq_('./ecdsa')
30545 var networks = _dereq_('./networks')
30546
30547 var Address = _dereq_('./address')
30548
30549 var ecurve = _dereq_('ecurve')
30550 var curve = ecurve.getCurveByName('secp256k1')
30551
30552 function ECPubKey(Q, compressed) {
30553 assert(Q instanceof ecurve.Point, 'Expected Point, got ' + Q)
30554
30555 if (compressed == undefined) compressed = true
30556 assert.strictEqual(typeof compressed, 'boolean', 'Expected boolean, got ' + compressed)
30557
30558 this.compressed = compressed
30559 this.Q = Q
30560 }
30561
30562 // Static constructors
30563 ECPubKey.fromBuffer = function(buffer) {
30564 var Q = ecurve.Point.decodeFrom(curve, buffer)
30565 return new ECPubKey(Q, Q.compressed)
30566 }
30567
30568 ECPubKey.fromHex = function(hex) {
30569 return ECPubKey.fromBuffer(new Buffer(hex, 'hex'))
30570 }
30571
30572 // Operations
30573 ECPubKey.prototype.getAddress = function(network) {
30574 network = network || networks.bitcoin
30575
30576 return new Address(crypto.hash160(this.toBuffer()), network.pubKeyHash)
30577 }
30578
30579 ECPubKey.prototype.verify = function(hash, signature) {
30580 return ecdsa.verify(curve, hash, signature, this.Q)
30581 }
30582
30583 // Export functions
30584 ECPubKey.prototype.toBuffer = function() {
30585 return this.Q.getEncoded(this.compressed)
30586 }
30587
30588 ECPubKey.prototype.toHex = function() {
30589 return this.toBuffer().toString('hex')
30590 }
30591
30592 module.exports = ECPubKey
30593
30594 }).call(this,_dereq_("buffer").Buffer)
30595 },{"./address":69,"./crypto":73,"./ecdsa":74,"./networks":81,"assert":4,"buffer":8,"ecurve":65}],77:[function(_dereq_,module,exports){
30596 (function (Buffer){
30597 var assert = _dereq_('assert')
30598 var BigInteger = _dereq_('bigi')
30599
30600 function ECSignature(r, s) {
30601 assert(r instanceof BigInteger, 'Expected BigInteger, got ' + r)
30602 assert(s instanceof BigInteger, 'Expected BigInteger, got ' + s)
30603 this.r = r
30604 this.s = s
30605 }
30606
30607 // Import operations
30608 ECSignature.parseCompact = function(buffer) {
30609 assert.equal(buffer.length, 65, 'Invalid signature length')
30610 var i = buffer.readUInt8(0) - 27
30611
30612 // At most 3 bits
30613 assert.equal(i, i & 7, 'Invalid signature parameter')
30614 var compressed = !!(i & 4)
30615
30616 // Recovery param only
30617 i = i & 3
30618
30619 var r = BigInteger.fromBuffer(buffer.slice(1, 33))
30620 var s = BigInteger.fromBuffer(buffer.slice(33))
30621
30622 return {
30623 compressed: compressed,
30624 i: i,
30625 signature: new ECSignature(r, s)
30626 }
30627 }
30628
30629 ECSignature.fromDER = function(buffer) {
30630 assert.equal(buffer.readUInt8(0), 0x30, 'Not a DER sequence')
30631 assert.equal(buffer.readUInt8(1), buffer.length - 2, 'Invalid sequence length')
30632 assert.equal(buffer.readUInt8(2), 0x02, 'Expected a DER integer')
30633
30634 var rLen = buffer.readUInt8(3)
30635 assert(rLen > 0, 'R length is zero')
30636
30637 var offset = 4 + rLen
30638 assert.equal(buffer.readUInt8(offset), 0x02, 'Expected a DER integer (2)')
30639
30640 var sLen = buffer.readUInt8(offset + 1)
30641 assert(sLen > 0, 'S length is zero')
30642
30643 var rB = buffer.slice(4, offset)
30644 var sB = buffer.slice(offset + 2)
30645 offset += 2 + sLen
30646
30647 if (rLen > 1 && rB.readUInt8(0) === 0x00) {
30648 assert(rB.readUInt8(1) & 0x80, 'R value excessively padded')
30649 }
30650
30651 if (sLen > 1 && sB.readUInt8(0) === 0x00) {
30652 assert(sB.readUInt8(1) & 0x80, 'S value excessively padded')
30653 }
30654
30655 assert.equal(offset, buffer.length, 'Invalid DER encoding')
30656 var r = BigInteger.fromDERInteger(rB)
30657 var s = BigInteger.fromDERInteger(sB)
30658
30659 assert(r.signum() >= 0, 'R value is negative')
30660 assert(s.signum() >= 0, 'S value is negative')
30661
30662 return new ECSignature(r, s)
30663 }
30664
30665 // FIXME: 0x00, 0x04, 0x80 are SIGHASH_* boundary constants, importing Transaction causes a circular dependency
30666 ECSignature.parseScriptSignature = function(buffer) {
30667 var hashType = buffer.readUInt8(buffer.length - 1)
30668 var hashTypeMod = hashType & ~0x80
30669
30670 assert(hashTypeMod > 0x00 && hashTypeMod < 0x04, 'Invalid hashType')
30671
30672 return {
30673 signature: ECSignature.fromDER(buffer.slice(0, -1)),
30674 hashType: hashType
30675 }
30676 }
30677
30678 // Export operations
30679 ECSignature.prototype.toCompact = function(i, compressed) {
30680 if (compressed) i += 4
30681 i += 27
30682
30683 var buffer = new Buffer(65)
30684 buffer.writeUInt8(i, 0)
30685
30686 this.r.toBuffer(32).copy(buffer, 1)
30687 this.s.toBuffer(32).copy(buffer, 33)
30688
30689 return buffer
30690 }
30691
30692 ECSignature.prototype.toDER = function() {
30693 var rBa = this.r.toDERInteger()
30694 var sBa = this.s.toDERInteger()
30695
30696 var sequence = []
30697 sequence.push(0x02) // INTEGER
30698 sequence.push(rBa.length)
30699 sequence = sequence.concat(rBa)
30700
30701 sequence.push(0x02) // INTEGER
30702 sequence.push(sBa.length)
30703 sequence = sequence.concat(sBa)
30704
30705 sequence.unshift(sequence.length)
30706 sequence.unshift(0x30) // SEQUENCE
30707
30708 return new Buffer(sequence)
30709 }
30710
30711 ECSignature.prototype.toScriptSignature = function(hashType) {
30712 var hashTypeBuffer = new Buffer(1)
30713 hashTypeBuffer.writeUInt8(hashType, 0)
30714
30715 return Buffer.concat([this.toDER(), hashTypeBuffer])
30716 }
30717
30718 module.exports = ECSignature
30719
30720 }).call(this,_dereq_("buffer").Buffer)
30721 },{"assert":4,"bigi":3,"buffer":8}],78:[function(_dereq_,module,exports){
30722 (function (Buffer){
30723 var assert = _dereq_('assert')
30724 var base58check = _dereq_('./base58check')
30725 var crypto = _dereq_('./crypto')
30726 var networks = _dereq_('./networks')
30727
30728 var BigInteger = _dereq_('bigi')
30729 var ECKey = _dereq_('./eckey')
30730 var ECPubKey = _dereq_('./ecpubkey')
30731
30732 var ecurve = _dereq_('ecurve')
30733 var curve = ecurve.getCurveByName('secp256k1')
30734
30735 function findBIP32ParamsByVersion(version) {
30736 for (var name in networks) {
30737 var network = networks[name]
30738
30739 for (var type in network.bip32) {
30740 if (version != network.bip32[type]) continue
30741
30742 return {
30743 isPrivate: (type === 'private'),
30744 network: network
30745 }
30746 }
30747 }
30748
30749 assert(false, 'Could not find version ' + version.toString(16))
30750 }
30751
30752 function HDNode(K, chainCode, network) {
30753 network = network || networks.bitcoin
30754
30755 assert(Buffer.isBuffer(chainCode), 'Expected Buffer, got ' + chainCode)
30756 assert(network.bip32, 'Unknown BIP32 constants for network')
30757
30758 this.chainCode = chainCode
30759 this.depth = 0
30760 this.index = 0
30761 this.network = network
30762
30763 if (K instanceof BigInteger) {
30764 this.privKey = new ECKey(K, true)
30765 this.pubKey = this.privKey.pub
30766 } else {
30767 this.pubKey = new ECPubKey(K, true)
30768 }
30769 }
30770
30771 HDNode.MASTER_SECRET = new Buffer('Bitcoin seed')
30772 HDNode.HIGHEST_BIT = 0x80000000
30773 HDNode.LENGTH = 78
30774
30775 HDNode.fromSeedBuffer = function(seed, network) {
30776 var I = crypto.HmacSHA512(seed, HDNode.MASTER_SECRET)
30777 var IL = I.slice(0, 32)
30778 var IR = I.slice(32)
30779
30780 // In case IL is 0 or >= n, the master key is invalid
30781 // This is handled by `new ECKey` in the HDNode constructor
30782 var pIL = BigInteger.fromBuffer(IL)
30783
30784 return new HDNode(pIL, IR, network)
30785 }
30786
30787 HDNode.fromSeedHex = function(hex, network) {
30788 return HDNode.fromSeedBuffer(new Buffer(hex, 'hex'), network)
30789 }
30790
30791 HDNode.fromBase58 = function(string) {
30792 return HDNode.fromBuffer(base58check.decode(string))
30793 }
30794
30795 HDNode.fromBuffer = function(buffer) {
30796 assert.strictEqual(buffer.length, HDNode.LENGTH, 'Invalid buffer length')
30797
30798 // 4 byte: version bytes
30799 var version = buffer.readUInt32BE(0)
30800 var params = findBIP32ParamsByVersion(version)
30801
30802 // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ...
30803 var depth = buffer.readUInt8(4)
30804
30805 // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
30806 var parentFingerprint = buffer.readUInt32BE(5)
30807 if (depth === 0) {
30808 assert.strictEqual(parentFingerprint, 0x00000000, 'Invalid parent fingerprint')
30809 }
30810
30811 // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
30812 // This is encoded in MSB order. (0x00000000 if master key)
30813 var index = buffer.readUInt32BE(9)
30814 assert(depth > 0 || index === 0, 'Invalid index')
30815
30816 // 32 bytes: the chain code
30817 var chainCode = buffer.slice(13, 45)
30818 var hd
30819
30820 // 33 bytes: private key data (0x00 + k)
30821 if (params.isPrivate) {
30822 assert.strictEqual(buffer.readUInt8(45), 0x00, 'Invalid private key')
30823 var data = buffer.slice(46, 78)
30824 var d = BigInteger.fromBuffer(data)
30825 hd = new HDNode(d, chainCode, params.network)
30826
30827 // 33 bytes: public key data (0x02 + X or 0x03 + X)
30828 } else {
30829 var data = buffer.slice(45, 78)
30830 var Q = ecurve.Point.decodeFrom(curve, data)
30831 assert.equal(Q.compressed, true, 'Invalid public key')
30832
30833 // Verify that the X coordinate in the public point corresponds to a point on the curve.
30834 // If not, the extended public key is invalid.
30835 curve.validate(Q)
30836
30837 hd = new HDNode(Q, chainCode, params.network)
30838 }
30839
30840 hd.depth = depth
30841 hd.index = index
30842 hd.parentFingerprint = parentFingerprint
30843
30844 return hd
30845 }
30846
30847 HDNode.fromHex = function(hex) {
30848 return HDNode.fromBuffer(new Buffer(hex, 'hex'))
30849 }
30850
30851 HDNode.prototype.getIdentifier = function() {
30852 return crypto.hash160(this.pubKey.toBuffer())
30853 }
30854
30855 HDNode.prototype.getFingerprint = function() {
30856 return this.getIdentifier().slice(0, 4)
30857 }
30858
30859 HDNode.prototype.getAddress = function() {
30860 return this.pubKey.getAddress(this.network)
30861 }
30862
30863 HDNode.prototype.toBase58 = function(isPrivate) {
30864 return base58check.encode(this.toBuffer(isPrivate))
30865 }
30866
30867 HDNode.prototype.toBuffer = function(isPrivate) {
30868 if (isPrivate == undefined) isPrivate = !!this.privKey
30869
30870 // Version
30871 var version = isPrivate ? this.network.bip32.private : this.network.bip32.public
30872 var buffer = new Buffer(HDNode.LENGTH)
30873
30874 // 4 bytes: version bytes
30875 buffer.writeUInt32BE(version, 0)
30876
30877 // Depth
30878 // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ....
30879 buffer.writeUInt8(this.depth, 4)
30880
30881 // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
30882 var fingerprint = (this.depth === 0) ? 0x00000000 : this.parentFingerprint
30883 buffer.writeUInt32BE(fingerprint, 5)
30884
30885 // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
30886 // This is encoded in Big endian. (0x00000000 if master key)
30887 buffer.writeUInt32BE(this.index, 9)
30888
30889 // 32 bytes: the chain code
30890 this.chainCode.copy(buffer, 13)
30891
30892 // 33 bytes: the public key or private key data
30893 if (isPrivate) {
30894 assert(this.privKey, 'Missing private key')
30895
30896 // 0x00 + k for private keys
30897 buffer.writeUInt8(0, 45)
30898 this.privKey.d.toBuffer(32).copy(buffer, 46)
30899 } else {
30900
30901 // X9.62 encoding for public keys
30902 this.pubKey.toBuffer().copy(buffer, 45)
30903 }
30904
30905 return buffer
30906 }
30907
30908 HDNode.prototype.toHex = function(isPrivate) {
30909 return this.toBuffer(isPrivate).toString('hex')
30910 }
30911
30912 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
30913 HDNode.prototype.derive = function(index) {
30914 var isHardened = index >= HDNode.HIGHEST_BIT
30915 var indexBuffer = new Buffer(4)
30916 indexBuffer.writeUInt32BE(index, 0)
30917
30918 var data
30919
30920 // Hardened child
30921 if (isHardened) {
30922 assert(this.privKey, 'Could not derive hardened child key')
30923
30924 // data = 0x00 || ser256(kpar) || ser32(index)
30925 data = Buffer.concat([
30926 this.privKey.d.toBuffer(33),
30927 indexBuffer
30928 ])
30929
30930 // Normal child
30931 } else {
30932 // data = serP(point(kpar)) || ser32(index)
30933 // = serP(Kpar) || ser32(index)
30934 data = Buffer.concat([
30935 this.pubKey.toBuffer(),
30936 indexBuffer
30937 ])
30938 }
30939
30940 var I = crypto.HmacSHA512(data, this.chainCode)
30941 var IL = I.slice(0, 32)
30942 var IR = I.slice(32)
30943
30944 var pIL = BigInteger.fromBuffer(IL)
30945
30946 // In case parse256(IL) >= n, proceed with the next value for i
30947 if (pIL.compareTo(curve.n) >= 0) {
30948 return this.derive(index + 1)
30949 }
30950
30951 // Private parent key -> private child key
30952 var hd
30953 if (this.privKey) {
30954 // ki = parse256(IL) + kpar (mod n)
30955 var ki = pIL.add(this.privKey.d).mod(curve.n)
30956
30957 // In case ki == 0, proceed with the next value for i
30958 if (ki.signum() === 0) {
30959 return this.derive(index + 1)
30960 }
30961
30962 hd = new HDNode(ki, IR, this.network)
30963
30964 // Public parent key -> public child key
30965 } else {
30966 // Ki = point(parse256(IL)) + Kpar
30967 // = G*IL + Kpar
30968 var Ki = curve.G.multiply(pIL).add(this.pubKey.Q)
30969
30970 // In case Ki is the point at infinity, proceed with the next value for i
30971 if (curve.isInfinity(Ki)) {
30972 return this.derive(index + 1)
30973 }
30974
30975 hd = new HDNode(Ki, IR, this.network)
30976 }
30977
30978 hd.depth = this.depth + 1
30979 hd.index = index
30980 hd.parentFingerprint = this.getFingerprint().readUInt32BE(0)
30981
30982 return hd
30983 }
30984
30985 HDNode.prototype.deriveHardened = function(index) {
30986 // Only derives hardened private keys by default
30987 return this.derive(index + HDNode.HIGHEST_BIT)
30988 }
30989
30990 HDNode.prototype.toString = HDNode.prototype.toBase58
30991
30992 module.exports = HDNode
30993
30994 }).call(this,_dereq_("buffer").Buffer)
30995 },{"./base58check":70,"./crypto":73,"./eckey":75,"./ecpubkey":76,"./networks":81,"assert":4,"bigi":3,"buffer":8,"ecurve":65}],79:[function(_dereq_,module,exports){
30996 module.exports = {
30997 Address: _dereq_('./address'),
30998 base58check: _dereq_('./base58check'),
30999 bufferutils: _dereq_('./bufferutils'),
31000 convert: _dereq_('./convert'),
31001 crypto: _dereq_('./crypto'),
31002 ecdsa: _dereq_('./ecdsa'),
31003 ECKey: _dereq_('./eckey'),
31004 ECPubKey: _dereq_('./ecpubkey'),
31005 ECSignature: _dereq_('./ecsignature'),
31006 Message: _dereq_('./message'),
31007 opcodes: _dereq_('./opcodes'),
31008 HDNode: _dereq_('./hdnode'),
31009 Script: _dereq_('./script'),
31010 scripts: _dereq_('./scripts'),
31011 Transaction: _dereq_('./transaction'),
31012 networks: _dereq_('./networks'),
31013 Wallet: _dereq_('./wallet')
31014 }
31015
31016 },{"./address":69,"./base58check":70,"./bufferutils":71,"./convert":72,"./crypto":73,"./ecdsa":74,"./eckey":75,"./ecpubkey":76,"./ecsignature":77,"./hdnode":78,"./message":80,"./networks":81,"./opcodes":82,"./script":83,"./scripts":84,"./transaction":85,"./wallet":86}],80:[function(_dereq_,module,exports){
31017 (function (Buffer){
31018 /// Implements Bitcoin's feature for signing arbitrary messages.
31019 var Address = _dereq_('./address')
31020 var BigInteger = _dereq_('bigi')
31021 var bufferutils = _dereq_('./bufferutils')
31022 var crypto = _dereq_('./crypto')
31023 var ecdsa = _dereq_('./ecdsa')
31024 var networks = _dereq_('./networks')
31025
31026 var Address = _dereq_('./address')
31027 var ECPubKey = _dereq_('./ecpubkey')
31028 var ECSignature = _dereq_('./ecsignature')
31029
31030 var ecurve = _dereq_('ecurve')
31031 var ecparams = ecurve.getCurveByName('secp256k1')
31032
31033 function magicHash(message, network) {
31034 var magicPrefix = new Buffer(network.magicPrefix)
31035 var messageBuffer = new Buffer(message)
31036 var lengthBuffer = new Buffer(bufferutils.varIntSize(messageBuffer.length))
31037 bufferutils.writeVarInt(lengthBuffer, messageBuffer.length, 0)
31038
31039 var buffer = Buffer.concat([magicPrefix, lengthBuffer, messageBuffer])
31040 return crypto.hash256(buffer)
31041 }
31042
31043 function sign(privKey, message, network) {
31044 network = network || networks.bitcoin
31045
31046 var hash = magicHash(message, network)
31047 var signature = privKey.sign(hash)
31048 var e = BigInteger.fromBuffer(hash)
31049 var i = ecdsa.calcPubKeyRecoveryParam(ecparams, e, signature, privKey.pub.Q)
31050
31051 return signature.toCompact(i, privKey.pub.compressed)
31052 }
31053
31054 // TODO: network could be implied from address
31055 function verify(address, signatureBuffer, message, network) {
31056 if (address instanceof Address) {
31057 address = address.toString()
31058 }
31059 network = network || networks.bitcoin
31060
31061 var hash = magicHash(message, network)
31062 var parsed = ECSignature.parseCompact(signatureBuffer)
31063 var e = BigInteger.fromBuffer(hash)
31064 var Q = ecdsa.recoverPubKey(ecparams, e, parsed.signature, parsed.i)
31065
31066 var pubKey = new ECPubKey(Q, parsed.compressed)
31067 return pubKey.getAddress(network).toString() === address
31068 }
31069
31070 module.exports = {
31071 magicHash: magicHash,
31072 sign: sign,
31073 verify: verify
31074 }
31075
31076 }).call(this,_dereq_("buffer").Buffer)
31077 },{"./address":69,"./bufferutils":71,"./crypto":73,"./ecdsa":74,"./ecpubkey":76,"./ecsignature":77,"./networks":81,"bigi":3,"buffer":8,"ecurve":65}],81:[function(_dereq_,module,exports){
31078 // https://en.bitcoin.it/wiki/List_of_address_prefixes
31079 // Dogecoin BIP32 is a proposed standard: https://bitcointalk.org/index.php?topic=409731
31080
31081 var networks = {
31082 bitcoin: {
31083 magicPrefix: '\x18Bitcoin Signed Message:\n',
31084 bip32: {
31085 public: 0x0488b21e,
31086 private: 0x0488ade4
31087 },
31088 pubKeyHash: 0x00,
31089 scriptHash: 0x05,
31090 wif: 0x80,
31091 dustThreshold: 546, // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/core.h#L151-L162
31092 feePerKb: 10000, // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/main.cpp#L53
31093 estimateFee: estimateFee('bitcoin')
31094 },
31095 dogecoin: {
31096 magicPrefix: '\x19Dogecoin Signed Message:\n',
31097 bip32: {
31098 public: 0x02facafd,
31099 private: 0x02fac398
31100 },
31101 pubKeyHash: 0x1e,
31102 scriptHash: 0x16,
31103 wif: 0x9e,
31104 dustThreshold: 0, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/core.h#L155-L160
31105 dustSoftThreshold: 100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.h#L62
31106 feePerKb: 100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.cpp#L58
31107 estimateFee: estimateFee('dogecoin')
31108 },
31109 litecoin: {
31110 magicPrefix: '\x19Litecoin Signed Message:\n',
31111 bip32: {
31112 public: 0x019da462,
31113 private: 0x019d9cfe
31114 },
31115 pubKeyHash: 0x30,
31116 scriptHash: 0x05,
31117 wif: 0xb0,
31118 dustThreshold: 0, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L360-L365
31119 dustSoftThreshold: 100000, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.h#L53
31120 feePerKb: 100000, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L56
31121 estimateFee: estimateFee('litecoin')
31122 },
31123 testnet: {
31124 magicPrefix: '\x18Bitcoin Signed Message:\n',
31125 bip32: {
31126 public: 0x043587cf,
31127 private: 0x04358394
31128 },
31129 pubKeyHash: 0x6f,
31130 scriptHash: 0xc4,
31131 wif: 0xef,
31132 dustThreshold: 546,
31133 feePerKb: 10000,
31134 estimateFee: estimateFee('testnet')
31135 }
31136 }
31137
31138 function estimateFee(type) {
31139 return function(tx) {
31140 var network = networks[type]
31141 var baseFee = network.feePerKb
31142 var byteSize = tx.toBuffer().length
31143
31144 var fee = baseFee * Math.ceil(byteSize / 1000)
31145 if (network.dustSoftThreshold == undefined) return fee
31146
31147 tx.outs.forEach(function(e){
31148 if (e.value < network.dustSoftThreshold) {
31149 fee += baseFee
31150 }
31151 })
31152
31153 return fee
31154 }
31155 }
31156
31157 module.exports = networks
31158
31159 },{}],82:[function(_dereq_,module,exports){
31160 module.exports = {
31161 // push value
31162 OP_FALSE : 0,
31163 OP_0 : 0,
31164 OP_PUSHDATA1 : 76,
31165 OP_PUSHDATA2 : 77,
31166 OP_PUSHDATA4 : 78,
31167 OP_1NEGATE : 79,
31168 OP_RESERVED : 80,
31169 OP_1 : 81,
31170 OP_TRUE : 81,
31171 OP_2 : 82,
31172 OP_3 : 83,
31173 OP_4 : 84,
31174 OP_5 : 85,
31175 OP_6 : 86,
31176 OP_7 : 87,
31177 OP_8 : 88,
31178 OP_9 : 89,
31179 OP_10 : 90,
31180 OP_11 : 91,
31181 OP_12 : 92,
31182 OP_13 : 93,
31183 OP_14 : 94,
31184 OP_15 : 95,
31185 OP_16 : 96,
31186
31187 // control
31188 OP_NOP : 97,
31189 OP_VER : 98,
31190 OP_IF : 99,
31191 OP_NOTIF : 100,
31192 OP_VERIF : 101,
31193 OP_VERNOTIF : 102,
31194 OP_ELSE : 103,
31195 OP_ENDIF : 104,
31196 OP_VERIFY : 105,
31197 OP_RETURN : 106,
31198
31199 // stack ops
31200 OP_TOALTSTACK : 107,
31201 OP_FROMALTSTACK : 108,
31202 OP_2DROP : 109,
31203 OP_2DUP : 110,
31204 OP_3DUP : 111,
31205 OP_2OVER : 112,
31206 OP_2ROT : 113,
31207 OP_2SWAP : 114,
31208 OP_IFDUP : 115,
31209 OP_DEPTH : 116,
31210 OP_DROP : 117,
31211 OP_DUP : 118,
31212 OP_NIP : 119,
31213 OP_OVER : 120,
31214 OP_PICK : 121,
31215 OP_ROLL : 122,
31216 OP_ROT : 123,
31217 OP_SWAP : 124,
31218 OP_TUCK : 125,
31219
31220 // splice ops
31221 OP_CAT : 126,
31222 OP_SUBSTR : 127,
31223 OP_LEFT : 128,
31224 OP_RIGHT : 129,
31225 OP_SIZE : 130,
31226
31227 // bit logic
31228 OP_INVERT : 131,
31229 OP_AND : 132,
31230 OP_OR : 133,
31231 OP_XOR : 134,
31232 OP_EQUAL : 135,
31233 OP_EQUALVERIFY : 136,
31234 OP_RESERVED1 : 137,
31235 OP_RESERVED2 : 138,
31236
31237 // numeric
31238 OP_1ADD : 139,
31239 OP_1SUB : 140,
31240 OP_2MUL : 141,
31241 OP_2DIV : 142,
31242 OP_NEGATE : 143,
31243 OP_ABS : 144,
31244 OP_NOT : 145,
31245 OP_0NOTEQUAL : 146,
31246
31247 OP_ADD : 147,
31248 OP_SUB : 148,
31249 OP_MUL : 149,
31250 OP_DIV : 150,
31251 OP_MOD : 151,
31252 OP_LSHIFT : 152,
31253 OP_RSHIFT : 153,
31254
31255 OP_BOOLAND : 154,
31256 OP_BOOLOR : 155,
31257 OP_NUMEQUAL : 156,
31258 OP_NUMEQUALVERIFY : 157,
31259 OP_NUMNOTEQUAL : 158,
31260 OP_LESSTHAN : 159,
31261 OP_GREATERTHAN : 160,
31262 OP_LESSTHANOREQUAL : 161,
31263 OP_GREATERTHANOREQUAL : 162,
31264 OP_MIN : 163,
31265 OP_MAX : 164,
31266
31267 OP_WITHIN : 165,
31268
31269 // crypto
31270 OP_RIPEMD160 : 166,
31271 OP_SHA1 : 167,
31272 OP_SHA256 : 168,
31273 OP_HASH160 : 169,
31274 OP_HASH256 : 170,
31275 OP_CODESEPARATOR : 171,
31276 OP_CHECKSIG : 172,
31277 OP_CHECKSIGVERIFY : 173,
31278 OP_CHECKMULTISIG : 174,
31279 OP_CHECKMULTISIGVERIFY : 175,
31280
31281 // expansion
31282 OP_NOP1 : 176,
31283 OP_NOP2 : 177,
31284 OP_NOP3 : 178,
31285 OP_NOP4 : 179,
31286 OP_NOP5 : 180,
31287 OP_NOP6 : 181,
31288 OP_NOP7 : 182,
31289 OP_NOP8 : 183,
31290 OP_NOP9 : 184,
31291 OP_NOP10 : 185,
31292
31293 // template matching params
31294 OP_PUBKEYHASH : 253,
31295 OP_PUBKEY : 254,
31296 OP_INVALIDOPCODE : 255
31297 }
31298
31299 },{}],83:[function(_dereq_,module,exports){
31300 (function (Buffer){
31301 var assert = _dereq_('assert')
31302 var bufferutils = _dereq_('./bufferutils')
31303 var crypto = _dereq_('./crypto')
31304 var opcodes = _dereq_('./opcodes')
31305
31306 function Script(buffer, chunks) {
31307 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)
31308 assert(Array.isArray(chunks), 'Expected Array, got ' + chunks)
31309
31310 this.buffer = buffer
31311 this.chunks = chunks
31312 }
31313
31314 // Import operations
31315 Script.fromASM = function(asm) {
31316 var strChunks = asm.split(' ')
31317
31318 var chunks = strChunks.map(function(strChunk) {
31319 if (strChunk in opcodes) {
31320 return opcodes[strChunk]
31321
31322 } else {
31323 return new Buffer(strChunk, 'hex')
31324 }
31325 })
31326
31327 return Script.fromChunks(chunks)
31328 }
31329
31330 Script.fromBuffer = function(buffer) {
31331 var chunks = []
31332
31333 var i = 0
31334
31335 while (i < buffer.length) {
31336 var opcode = buffer.readUInt8(i)
31337
31338 if ((opcode > opcodes.OP_0) && (opcode <= opcodes.OP_PUSHDATA4)) {
31339 var d = bufferutils.readPushDataInt(buffer, i)
31340 i += d.size
31341
31342 var data = buffer.slice(i, i + d.number)
31343 i += d.number
31344
31345 chunks.push(data)
31346
31347 } else {
31348 chunks.push(opcode)
31349
31350 i += 1
31351 }
31352 }
31353
31354 return new Script(buffer, chunks)
31355 }
31356
31357 Script.fromChunks = function(chunks) {
31358 assert(Array.isArray(chunks), 'Expected Array, got ' + chunks)
31359
31360 var bufferSize = chunks.reduce(function(accum, chunk) {
31361 if (Buffer.isBuffer(chunk)) {
31362 return accum + bufferutils.pushDataSize(chunk.length) + chunk.length
31363 }
31364
31365 return accum + 1
31366 }, 0.0)
31367
31368 var buffer = new Buffer(bufferSize)
31369 var offset = 0
31370
31371 chunks.forEach(function(chunk) {
31372 if (Buffer.isBuffer(chunk)) {
31373 offset += bufferutils.writePushDataInt(buffer, chunk.length, offset)
31374
31375 chunk.copy(buffer, offset)
31376 offset += chunk.length
31377
31378 } else {
31379 buffer.writeUInt8(chunk, offset)
31380 offset += 1
31381 }
31382 })
31383
31384 assert.equal(offset, buffer.length, 'Could not decode chunks')
31385 return new Script(buffer, chunks)
31386 }
31387
31388 Script.fromHex = function(hex) {
31389 return Script.fromBuffer(new Buffer(hex, 'hex'))
31390 }
31391
31392 // Constants
31393 Script.EMPTY = Script.fromChunks([])
31394
31395 // Operations
31396 Script.prototype.getHash = function() {
31397 return crypto.hash160(this.buffer)
31398 }
31399
31400 // FIXME: doesn't work for data chunks, maybe time to use buffertools.compare...
31401 Script.prototype.without = function(needle) {
31402 return Script.fromChunks(this.chunks.filter(function(op) {
31403 return op !== needle
31404 }))
31405 }
31406
31407 // Export operations
31408 var reverseOps = []
31409 for (var op in opcodes) {
31410 var code = opcodes[op]
31411 reverseOps[code] = op
31412 }
31413
31414 Script.prototype.toASM = function() {
31415 return this.chunks.map(function(chunk) {
31416 if (Buffer.isBuffer(chunk)) {
31417 return chunk.toString('hex')
31418
31419 } else {
31420 return reverseOps[chunk]
31421 }
31422 }).join(' ')
31423 }
31424
31425 Script.prototype.toBuffer = function() {
31426 return this.buffer
31427 }
31428
31429 Script.prototype.toHex = function() {
31430 return this.toBuffer().toString('hex')
31431 }
31432
31433 module.exports = Script
31434
31435 }).call(this,_dereq_("buffer").Buffer)
31436 },{"./bufferutils":71,"./crypto":73,"./opcodes":82,"assert":4,"buffer":8}],84:[function(_dereq_,module,exports){
31437 (function (Buffer){
31438 var assert = _dereq_('assert')
31439 var opcodes = _dereq_('./opcodes')
31440
31441 // FIXME: use ECPubKey, currently the circular dependency breaks everything.
31442 //
31443 // Solutions:
31444 // * Remove ECPubKey.getAddress
31445 // - Minimal change, but likely unpopular
31446 // * Move all script related functionality out of Address
31447 // - Means a lot of changes to Transaction/Wallet
31448 // * Ignore it (existing solution)
31449 // * Some form of hackery with commonjs
31450 //
31451 var ecurve = _dereq_('ecurve')
31452 var curve = ecurve.getCurveByName('secp256k1')
31453
31454 var ECSignature = _dereq_('./ecsignature')
31455 var Script = _dereq_('./script')
31456
31457 function classifyOutput(script) {
31458 assert(script instanceof Script, 'Expected Script, got ', script)
31459
31460 if (isPubKeyHashOutput.call(script)) {
31461 return 'pubkeyhash'
31462 } else if (isScriptHashOutput.call(script)) {
31463 return 'scripthash'
31464 } else if (isMultisigOutput.call(script)) {
31465 return 'multisig'
31466 } else if (isPubKeyOutput.call(script)) {
31467 return 'pubkey'
31468 } else if (isNulldataOutput.call(script)) {
31469 return 'nulldata'
31470 } else {
31471 return 'nonstandard'
31472 }
31473 }
31474
31475 function classifyInput(script) {
31476 assert(script instanceof Script, 'Expected Script, got ', script)
31477
31478 if (isPubKeyHashInput.call(script)) {
31479 return 'pubkeyhash'
31480 } else if (isScriptHashInput.call(script)) {
31481 return 'scripthash'
31482 } else if (isMultisigInput.call(script)) {
31483 return 'multisig'
31484 } else if (isPubKeyInput.call(script)) {
31485 return 'pubkey'
31486 } else {
31487 return 'nonstandard'
31488 }
31489 }
31490
31491 function isCanonicalPubKey(buffer) {
31492 if (!Buffer.isBuffer(buffer)) return false
31493
31494 try {
31495 // FIXME: boo
31496 ecurve.Point.decodeFrom(curve, buffer)
31497 } catch (e) {
31498 if (!(e.message.match(/Invalid sequence (length|tag)/))) throw e
31499
31500 return false
31501 }
31502
31503 return true
31504 }
31505
31506 function isCanonicalSignature(buffer) {
31507 if (!Buffer.isBuffer(buffer)) return false
31508
31509 try {
31510 ECSignature.parseScriptSignature(buffer)
31511 } catch(e) {
31512 if (!(e.message.match(/Not a DER sequence|Invalid sequence length|Expected a DER integer|R length is zero|S length is zero|R value excessively padded|S value excessively padded|R value is negative|S value is negative|Invalid hashType/))) throw e
31513
31514 return false
31515 }
31516
31517 return true
31518 }
31519
31520 function isPubKeyHashInput() {
31521 return this.chunks.length === 2 &&
31522 isCanonicalSignature(this.chunks[0]) &&
31523 isCanonicalPubKey(this.chunks[1])
31524 }
31525
31526 function isPubKeyHashOutput() {
31527 return this.chunks.length === 5 &&
31528 this.chunks[0] === opcodes.OP_DUP &&
31529 this.chunks[1] === opcodes.OP_HASH160 &&
31530 Buffer.isBuffer(this.chunks[2]) &&
31531 this.chunks[2].length === 20 &&
31532 this.chunks[3] === opcodes.OP_EQUALVERIFY &&
31533 this.chunks[4] === opcodes.OP_CHECKSIG
31534 }
31535
31536 function isPubKeyInput() {
31537 return this.chunks.length === 1 &&
31538 isCanonicalSignature(this.chunks[0])
31539 }
31540
31541 function isPubKeyOutput() {
31542 return this.chunks.length === 2 &&
31543 isCanonicalPubKey(this.chunks[0]) &&
31544 this.chunks[1] === opcodes.OP_CHECKSIG
31545 }
31546
31547 function isScriptHashInput() {
31548 if (this.chunks.length < 2) return false
31549 var lastChunk = this.chunks[this.chunks.length - 1]
31550
31551 if (!Buffer.isBuffer(lastChunk)) return false
31552
31553 var scriptSig = Script.fromChunks(this.chunks.slice(0, -1))
31554 var scriptPubKey = Script.fromBuffer(lastChunk)
31555
31556 return classifyInput(scriptSig) === classifyOutput(scriptPubKey)
31557 }
31558
31559 function isScriptHashOutput() {
31560 return this.chunks.length === 3 &&
31561 this.chunks[0] === opcodes.OP_HASH160 &&
31562 Buffer.isBuffer(this.chunks[1]) &&
31563 this.chunks[1].length === 20 &&
31564 this.chunks[2] === opcodes.OP_EQUAL
31565 }
31566
31567 function isMultisigInput() {
31568 return this.chunks[0] === opcodes.OP_0 &&
31569 this.chunks.slice(1).every(isCanonicalSignature)
31570 }
31571
31572 function isMultisigOutput() {
31573 if (this.chunks < 4) return false
31574 if (this.chunks[this.chunks.length - 1] !== opcodes.OP_CHECKMULTISIG) return false
31575
31576 var mOp = this.chunks[0]
31577 if (mOp === opcodes.OP_0) return false
31578 if (mOp < opcodes.OP_1) return false
31579 if (mOp > opcodes.OP_16) return false
31580
31581 var nOp = this.chunks[this.chunks.length - 2]
31582 if (nOp === opcodes.OP_0) return false
31583 if (nOp < opcodes.OP_1) return false
31584 if (nOp > opcodes.OP_16) return false
31585
31586 var m = mOp - (opcodes.OP_1 - 1)
31587 var n = nOp - (opcodes.OP_1 - 1)
31588 if (n < m) return false
31589
31590 var pubKeys = this.chunks.slice(1, -2)
31591 if (n < pubKeys.length) return false
31592
31593 return pubKeys.every(isCanonicalPubKey)
31594 }
31595
31596 function isNulldataOutput() {
31597 return this.chunks[0] === opcodes.OP_RETURN
31598 }
31599
31600 // Standard Script Templates
31601 // {pubKey} OP_CHECKSIG
31602 function pubKeyOutput(pubKey) {
31603 return Script.fromChunks([
31604 pubKey.toBuffer(),
31605 opcodes.OP_CHECKSIG
31606 ])
31607 }
31608
31609 // OP_DUP OP_HASH160 {pubKeyHash} OP_EQUALVERIFY OP_CHECKSIG
31610 function pubKeyHashOutput(hash) {
31611 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
31612
31613 return Script.fromChunks([
31614 opcodes.OP_DUP,
31615 opcodes.OP_HASH160,
31616 hash,
31617 opcodes.OP_EQUALVERIFY,
31618 opcodes.OP_CHECKSIG
31619 ])
31620 }
31621
31622 // OP_HASH160 {scriptHash} OP_EQUAL
31623 function scriptHashOutput(hash) {
31624 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
31625
31626 return Script.fromChunks([
31627 opcodes.OP_HASH160,
31628 hash,
31629 opcodes.OP_EQUAL
31630 ])
31631 }
31632
31633 // m [pubKeys ...] n OP_CHECKMULTISIG
31634 function multisigOutput(m, pubKeys) {
31635 assert(Array.isArray(pubKeys), 'Expected Array, got ' + pubKeys)
31636 assert(pubKeys.length >= m, 'Not enough pubKeys provided')
31637
31638 var pubKeyBuffers = pubKeys.map(function(pubKey) {
31639 return pubKey.toBuffer()
31640 })
31641 var n = pubKeys.length
31642
31643 return Script.fromChunks([].concat(
31644 (opcodes.OP_1 - 1) + m,
31645 pubKeyBuffers,
31646 (opcodes.OP_1 - 1) + n,
31647 opcodes.OP_CHECKMULTISIG
31648 ))
31649 }
31650
31651 // {signature}
31652 function pubKeyInput(signature) {
31653 assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
31654
31655 return Script.fromChunks([signature])
31656 }
31657
31658 // {signature} {pubKey}
31659 function pubKeyHashInput(signature, pubKey) {
31660 assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
31661
31662 return Script.fromChunks([signature, pubKey.toBuffer()])
31663 }
31664
31665 // <scriptSig> {serialized scriptPubKey script}
31666 function scriptHashInput(scriptSig, scriptPubKey) {
31667 return Script.fromChunks([].concat(
31668 scriptSig.chunks,
31669 scriptPubKey.toBuffer()
31670 ))
31671 }
31672
31673 // OP_0 [signatures ...]
31674 function multisigInput(signatures, scriptPubKey) {
31675 if (scriptPubKey) {
31676 assert(isMultisigOutput.call(scriptPubKey))
31677
31678 var m = scriptPubKey.chunks[0]
31679 var k = m - (opcodes.OP_1 - 1)
31680 assert(k <= signatures.length, 'Not enough signatures provided')
31681 }
31682
31683 return Script.fromChunks([].concat(opcodes.OP_0, signatures))
31684 }
31685
31686 module.exports = {
31687 classifyInput: classifyInput,
31688 classifyOutput: classifyOutput,
31689 multisigInput: multisigInput,
31690 multisigOutput: multisigOutput,
31691 pubKeyHashInput: pubKeyHashInput,
31692 pubKeyHashOutput: pubKeyHashOutput,
31693 pubKeyInput: pubKeyInput,
31694 pubKeyOutput: pubKeyOutput,
31695 scriptHashInput: scriptHashInput,
31696 scriptHashOutput: scriptHashOutput
31697 }
31698
31699 }).call(this,_dereq_("buffer").Buffer)
31700 },{"./ecsignature":77,"./opcodes":82,"./script":83,"assert":4,"buffer":8,"ecurve":65}],85:[function(_dereq_,module,exports){
31701 (function (Buffer){
31702 var assert = _dereq_('assert')
31703 var bufferutils = _dereq_('./bufferutils')
31704 var crypto = _dereq_('./crypto')
31705 var opcodes = _dereq_('./opcodes')
31706 var scripts = _dereq_('./scripts')
31707
31708 var Address = _dereq_('./address')
31709 var ECKey = _dereq_('./eckey')
31710 var ECSignature = _dereq_('./ecsignature')
31711 var Script = _dereq_('./script')
31712
31713 Transaction.DEFAULT_SEQUENCE = 0xffffffff
31714 Transaction.SIGHASH_ALL = 0x01
31715 Transaction.SIGHASH_NONE = 0x02
31716 Transaction.SIGHASH_SINGLE = 0x03
31717 Transaction.SIGHASH_ANYONECANPAY = 0x80
31718
31719 function Transaction() {
31720 this.version = 1
31721 this.locktime = 0
31722 this.ins = []
31723 this.outs = []
31724 }
31725
31726 /**
31727 * Create a new txin.
31728 *
31729 * Can be called with any of:
31730 *
31731 * - A transaction and an index
31732 * - A transaction hash and an index
31733 *
31734 * Note that this method does not sign the created input.
31735 */
31736 Transaction.prototype.addInput = function(tx, index, sequence) {
31737 if (sequence == undefined) sequence = Transaction.DEFAULT_SEQUENCE
31738
31739 var hash
31740
31741 if (typeof tx === 'string') {
31742 hash = new Buffer(tx, 'hex')
31743
31744 // TxId hex is big-endian, we need little-endian
31745 Array.prototype.reverse.call(hash)
31746
31747 } else if (tx instanceof Transaction) {
31748 hash = tx.getHash()
31749
31750 } else {
31751 hash = tx
31752 }
31753
31754 assert(Buffer.isBuffer(hash), 'Expected Transaction, txId or txHash, got ' + tx)
31755 assert.equal(hash.length, 32, 'Expected hash length of 32, got ' + hash.length)
31756 assert.equal(typeof index, 'number', 'Expected number index, got ' + index)
31757
31758 return (this.ins.push({
31759 hash: hash,
31760 index: index,
31761 script: Script.EMPTY,
31762 sequence: sequence
31763 }) - 1)
31764 }
31765
31766 /**
31767 * Create a new txout.
31768 *
31769 * Can be called with:
31770 *
31771 * - A base58 address string and a value
31772 * - An Address object and a value
31773 * - A scriptPubKey Script and a value
31774 */
31775 Transaction.prototype.addOutput = function(scriptPubKey, value) {
31776 // Attempt to get a valid address if it's a base58 address string
31777 if (typeof scriptPubKey === 'string') {
31778 scriptPubKey = Address.fromBase58Check(scriptPubKey)
31779 }
31780
31781 // Attempt to get a valid script if it's an Address object
31782 if (scriptPubKey instanceof Address) {
31783 var address = scriptPubKey
31784
31785 scriptPubKey = address.toOutputScript()
31786 }
31787
31788 return (this.outs.push({
31789 script: scriptPubKey,
31790 value: value,
31791 }) - 1)
31792 }
31793
31794 Transaction.prototype.toBuffer = function () {
31795 var txInSize = this.ins.reduce(function(a, x) {
31796 return a + (40 + bufferutils.varIntSize(x.script.buffer.length) + x.script.buffer.length)
31797 }, 0)
31798
31799 var txOutSize = this.outs.reduce(function(a, x) {
31800 return a + (8 + bufferutils.varIntSize(x.script.buffer.length) + x.script.buffer.length)
31801 }, 0)
31802
31803 var buffer = new Buffer(
31804 8 +
31805 bufferutils.varIntSize(this.ins.length) +
31806 bufferutils.varIntSize(this.outs.length) +
31807 txInSize +
31808 txOutSize
31809 )
31810
31811 var offset = 0
31812 function writeSlice(slice) {
31813 slice.copy(buffer, offset)
31814 offset += slice.length
31815 }
31816 function writeUInt32(i) {
31817 buffer.writeUInt32LE(i, offset)
31818 offset += 4
31819 }
31820 function writeUInt64(i) {
31821 bufferutils.writeUInt64LE(buffer, i, offset)
31822 offset += 8
31823 }
31824 function writeVarInt(i) {
31825 var n = bufferutils.writeVarInt(buffer, i, offset)
31826 offset += n
31827 }
31828
31829 writeUInt32(this.version)
31830 writeVarInt(this.ins.length)
31831
31832 this.ins.forEach(function(txin) {
31833 writeSlice(txin.hash)
31834 writeUInt32(txin.index)
31835 writeVarInt(txin.script.buffer.length)
31836 writeSlice(txin.script.buffer)
31837 writeUInt32(txin.sequence)
31838 })
31839
31840 writeVarInt(this.outs.length)
31841 this.outs.forEach(function(txout) {
31842 writeUInt64(txout.value)
31843 writeVarInt(txout.script.buffer.length)
31844 writeSlice(txout.script.buffer)
31845 })
31846
31847 writeUInt32(this.locktime)
31848
31849 return buffer
31850 }
31851
31852 Transaction.prototype.toHex = function() {
31853 return this.toBuffer().toString('hex')
31854 }
31855
31856 /**
31857 * Hash transaction for signing a specific input.
31858 *
31859 * Bitcoin uses a different hash for each signed transaction input. This
31860 * method copies the transaction, makes the necessary changes based on the
31861 * hashType, serializes and finally hashes the result. This hash can then be
31862 * used to sign the transaction input in question.
31863 */
31864 Transaction.prototype.hashForSignature = function(prevOutScript, inIndex, hashType) {
31865 assert(inIndex >= 0, 'Invalid vin index')
31866 assert(inIndex < this.ins.length, 'Invalid vin index')
31867 assert(prevOutScript instanceof Script, 'Invalid Script object')
31868
31869 var txTmp = this.clone()
31870 var hashScript = prevOutScript.without(opcodes.OP_CODESEPARATOR)
31871
31872 // Blank out other inputs' signatures
31873 txTmp.ins.forEach(function(txin) {
31874 txin.script = Script.EMPTY
31875 })
31876 txTmp.ins[inIndex].script = hashScript
31877
31878 var hashTypeModifier = hashType & 0x1f
31879 if (hashTypeModifier === Transaction.SIGHASH_NONE) {
31880 assert(false, 'SIGHASH_NONE not yet supported')
31881
31882 } else if (hashTypeModifier === Transaction.SIGHASH_SINGLE) {
31883 assert(false, 'SIGHASH_SINGLE not yet supported')
31884
31885 }
31886
31887 if (hashType & Transaction.SIGHASH_ANYONECANPAY) {
31888 assert(false, 'SIGHASH_ANYONECANPAY not yet supported')
31889 }
31890
31891 var hashTypeBuffer = new Buffer(4)
31892 hashTypeBuffer.writeInt32LE(hashType, 0)
31893
31894 var buffer = Buffer.concat([txTmp.toBuffer(), hashTypeBuffer])
31895 return crypto.hash256(buffer)
31896 }
31897
31898 Transaction.prototype.getHash = function () {
31899 return crypto.hash256(this.toBuffer())
31900 }
31901
31902 Transaction.prototype.getId = function () {
31903 var buffer = this.getHash()
31904
31905 // Big-endian is used for TxHash
31906 Array.prototype.reverse.call(buffer)
31907
31908 return buffer.toString('hex')
31909 }
31910
31911 Transaction.prototype.clone = function () {
31912 var newTx = new Transaction()
31913 newTx.version = this.version
31914 newTx.locktime = this.locktime
31915
31916 newTx.ins = this.ins.map(function(txin) {
31917 return {
31918 hash: txin.hash,
31919 index: txin.index,
31920 script: txin.script,
31921 sequence: txin.sequence
31922 }
31923 })
31924
31925 newTx.outs = this.outs.map(function(txout) {
31926 return {
31927 script: txout.script,
31928 value: txout.value
31929 }
31930 })
31931
31932 return newTx
31933 }
31934
31935 Transaction.fromBuffer = function(buffer) {
31936 var offset = 0
31937 function readSlice(n) {
31938 offset += n
31939 return buffer.slice(offset - n, offset)
31940 }
31941 function readUInt32() {
31942 var i = buffer.readUInt32LE(offset)
31943 offset += 4
31944 return i
31945 }
31946 function readUInt64() {
31947 var i = bufferutils.readUInt64LE(buffer, offset)
31948 offset += 8
31949 return i
31950 }
31951 function readVarInt() {
31952 var vi = bufferutils.readVarInt(buffer, offset)
31953 offset += vi.size
31954 return vi.number
31955 }
31956
31957 var tx = new Transaction()
31958 tx.version = readUInt32()
31959
31960 var vinLen = readVarInt()
31961 for (var i = 0; i < vinLen; ++i) {
31962 var hash = readSlice(32)
31963 var vout = readUInt32()
31964 var scriptLen = readVarInt()
31965 var script = readSlice(scriptLen)
31966 var sequence = readUInt32()
31967
31968 tx.ins.push({
31969 hash: hash,
31970 index: vout,
31971 script: Script.fromBuffer(script),
31972 sequence: sequence
31973 })
31974 }
31975
31976 var voutLen = readVarInt()
31977 for (i = 0; i < voutLen; ++i) {
31978 var value = readUInt64()
31979 var scriptLen = readVarInt()
31980 var script = readSlice(scriptLen)
31981
31982 tx.outs.push({
31983 value: value,
31984 script: Script.fromBuffer(script)
31985 })
31986 }
31987
31988 tx.locktime = readUInt32()
31989 assert.equal(offset, buffer.length, 'Transaction has unexpected data')
31990
31991 return tx
31992 }
31993
31994 Transaction.fromHex = function(hex) {
31995 return Transaction.fromBuffer(new Buffer(hex, 'hex'))
31996 }
31997
31998 /**
31999 * Signs a pubKeyHash output at some index with the given key
32000 */
32001 Transaction.prototype.sign = function(index, privKey, hashType) {
32002 var prevOutScript = privKey.pub.getAddress().toOutputScript()
32003 var signature = this.signInput(index, prevOutScript, privKey, hashType)
32004
32005 // FIXME: Assumed prior TX was pay-to-pubkey-hash
32006 var scriptSig = scripts.pubKeyHashInput(signature, privKey.pub)
32007 this.setInputScript(index, scriptSig)
32008 }
32009
32010 Transaction.prototype.signInput = function(index, prevOutScript, privKey, hashType) {
32011 hashType = hashType || Transaction.SIGHASH_ALL
32012
32013 var hash = this.hashForSignature(prevOutScript, index, hashType)
32014 var signature = privKey.sign(hash)
32015
32016 return signature.toScriptSignature(hashType)
32017 }
32018
32019 Transaction.prototype.setInputScript = function(index, script) {
32020 this.ins[index].script = script
32021 }
32022
32023 // FIXME: could be validateInput(index, prevTxOut, pub)
32024 Transaction.prototype.validateInput = function(index, prevOutScript, pubKey, buffer) {
32025 var parsed = ECSignature.parseScriptSignature(buffer)
32026 var hash = this.hashForSignature(prevOutScript, index, parsed.hashType)
32027
32028 return pubKey.verify(hash, parsed.signature)
32029 }
32030
32031 module.exports = Transaction
32032
32033 }).call(this,_dereq_("buffer").Buffer)
32034 },{"./address":69,"./bufferutils":71,"./crypto":73,"./eckey":75,"./ecsignature":77,"./opcodes":82,"./script":83,"./scripts":84,"assert":4,"buffer":8}],86:[function(_dereq_,module,exports){
32035 (function (Buffer){
32036 var assert = _dereq_('assert')
32037 var networks = _dereq_('./networks')
32038 var rng = _dereq_('secure-random')
32039
32040 var Address = _dereq_('./address')
32041 var HDNode = _dereq_('./hdnode')
32042 var Transaction = _dereq_('./transaction')
32043
32044 function Wallet(seed, network) {
32045 network = network || networks.bitcoin
32046
32047 // Stored in a closure to make accidental serialization less likely
32048 var masterkey = null
32049 var me = this
32050 var accountZero = null
32051 var internalAccount = null
32052 var externalAccount = null
32053
32054 // Addresses
32055 this.addresses = []
32056 this.changeAddresses = []
32057
32058 // Transaction output data
32059 this.outputs = {}
32060
32061 // Make a new master key
32062 this.newMasterKey = function(seed) {
32063 seed = seed || new Buffer(rng(32))
32064 masterkey = HDNode.fromSeedBuffer(seed, network)
32065
32066 // HD first-level child derivation method should be hardened
32067 // See https://bitcointalk.org/index.php?topic=405179.msg4415254#msg4415254
32068 accountZero = masterkey.deriveHardened(0)
32069 externalAccount = accountZero.derive(0)
32070 internalAccount = accountZero.derive(1)
32071
32072 me.addresses = []
32073 me.changeAddresses = []
32074
32075 me.outputs = {}
32076 }
32077
32078 this.newMasterKey(seed)
32079
32080 this.generateAddress = function() {
32081 var key = externalAccount.derive(this.addresses.length)
32082 this.addresses.push(key.getAddress().toString())
32083 return this.addresses[this.addresses.length - 1]
32084 }
32085
32086 this.generateChangeAddress = function() {
32087 var key = internalAccount.derive(this.changeAddresses.length)
32088 this.changeAddresses.push(key.getAddress().toString())
32089 return this.changeAddresses[this.changeAddresses.length - 1]
32090 }
32091
32092 this.getBalance = function() {
32093 return this.getUnspentOutputs().reduce(function(memo, output){
32094 return memo + output.value
32095 }, 0)
32096 }
32097
32098 this.getUnspentOutputs = function() {
32099 var utxo = []
32100
32101 for(var key in this.outputs){
32102 var output = this.outputs[key]
32103 if(!output.to) utxo.push(outputToUnspentOutput(output))
32104 }
32105
32106 return utxo
32107 }
32108
32109 this.setUnspentOutputs = function(utxo) {
32110 var outputs = {}
32111
32112 utxo.forEach(function(uo){
32113 validateUnspentOutput(uo)
32114 var o = unspentOutputToOutput(uo)
32115 outputs[o.from] = o
32116 })
32117
32118 this.outputs = outputs
32119 }
32120
32121 function outputToUnspentOutput(output){
32122 var hashAndIndex = output.from.split(":")
32123
32124 return {
32125 hash: hashAndIndex[0],
32126 outputIndex: parseInt(hashAndIndex[1]),
32127 address: output.address,
32128 value: output.value,
32129 pending: output.pending
32130 }
32131 }
32132
32133 function unspentOutputToOutput(o) {
32134 var hash = o.hash
32135 var key = hash + ":" + o.outputIndex
32136 return {
32137 from: key,
32138 address: o.address,
32139 value: o.value,
32140 pending: o.pending
32141 }
32142 }
32143
32144 function validateUnspentOutput(uo) {
32145 var missingField
32146
32147 if (isNullOrUndefined(uo.hash)) {
32148 missingField = "hash"
32149 }
32150
32151 var requiredKeys = ['outputIndex', 'address', 'value']
32152 requiredKeys.forEach(function (key) {
32153 if (isNullOrUndefined(uo[key])){
32154 missingField = key
32155 }
32156 })
32157
32158 if (missingField) {
32159 var message = [
32160 'Invalid unspent output: key', missingField, 'is missing.',
32161 'A valid unspent output must contain'
32162 ]
32163 message.push(requiredKeys.join(', '))
32164 message.push("and hash")
32165 throw new Error(message.join(' '))
32166 }
32167 }
32168
32169 function isNullOrUndefined(value) {
32170 return value == undefined
32171 }
32172
32173 this.processPendingTx = function(tx){
32174 processTx(tx, true)
32175 }
32176
32177 this.processConfirmedTx = function(tx){
32178 processTx(tx, false)
32179 }
32180
32181 function processTx(tx, isPending) {
32182 var txid = tx.getId()
32183
32184 tx.outs.forEach(function(txOut, i) {
32185 var address
32186
32187 try {
32188 address = Address.fromOutputScript(txOut.script, network).toString()
32189 } catch(e) {
32190 if (!(e.message.match(/has no matching Address/))) throw e
32191 }
32192
32193 if (isMyAddress(address)) {
32194 var output = txid + ':' + i
32195
32196 me.outputs[output] = {
32197 from: output,
32198 value: txOut.value,
32199 address: address,
32200 pending: isPending
32201 }
32202 }
32203 })
32204
32205 tx.ins.forEach(function(txIn, i) {
32206 // copy and convert to big-endian hex
32207 var txinId = new Buffer(txIn.hash)
32208 Array.prototype.reverse.call(txinId)
32209 txinId = txinId.toString('hex')
32210
32211 var output = txinId + ':' + txIn.index
32212
32213 if (!(output in me.outputs)) return
32214
32215 if (isPending) {
32216 me.outputs[output].to = txid + ':' + i
32217 me.outputs[output].pending = true
32218 } else {
32219 delete me.outputs[output]
32220 }
32221 })
32222 }
32223
32224 this.createTx = function(to, value, fixedFee, changeAddress) {
32225 assert(value > network.dustThreshold, value + ' must be above dust threshold (' + network.dustThreshold + ' Satoshis)')
32226
32227 var utxos = getCandidateOutputs(value)
32228 var accum = 0
32229 var subTotal = value
32230 var addresses = []
32231
32232 var tx = new Transaction()
32233 tx.addOutput(to, value)
32234
32235 for (var i = 0; i < utxos.length; ++i) {
32236 var utxo = utxos[i]
32237 addresses.push(utxo.address)
32238
32239 var outpoint = utxo.from.split(':')
32240 tx.addInput(outpoint[0], parseInt(outpoint[1]))
32241
32242 var fee = fixedFee == undefined ? estimateFeePadChangeOutput(tx) : fixedFee
32243
32244 accum += utxo.value
32245 subTotal = value + fee
32246 if (accum >= subTotal) {
32247 var change = accum - subTotal
32248
32249 if (change > network.dustThreshold) {
32250 tx.addOutput(changeAddress || getChangeAddress(), change)
32251 }
32252
32253 break
32254 }
32255 }
32256
32257 assert(accum >= subTotal, 'Not enough funds (incl. fee): ' + accum + ' < ' + subTotal)
32258
32259 this.signWith(tx, addresses)
32260 return tx
32261 }
32262
32263 function getCandidateOutputs() {
32264 var unspent = []
32265
32266 for (var key in me.outputs) {
32267 var output = me.outputs[key]
32268 if (!output.pending) unspent.push(output)
32269 }
32270
32271 var sortByValueDesc = unspent.sort(function(o1, o2){
32272 return o2.value - o1.value
32273 })
32274
32275 return sortByValueDesc
32276 }
32277
32278 function estimateFeePadChangeOutput(tx) {
32279 var tmpTx = tx.clone()
32280 tmpTx.addOutput(getChangeAddress(), network.dustSoftThreshold || 0)
32281
32282 return network.estimateFee(tmpTx)
32283 }
32284
32285 function getChangeAddress() {
32286 if(me.changeAddresses.length === 0) me.generateChangeAddress();
32287 return me.changeAddresses[me.changeAddresses.length - 1]
32288 }
32289
32290 this.signWith = function(tx, addresses) {
32291 assert.equal(tx.ins.length, addresses.length, 'Number of addresses must match number of transaction inputs')
32292
32293 addresses.forEach(function(address, i) {
32294 var key = me.getPrivateKeyForAddress(address)
32295
32296 tx.sign(i, key)
32297 })
32298
32299 return tx
32300 }
32301
32302 this.getMasterKey = function() { return masterkey }
32303 this.getAccountZero = function() { return accountZero }
32304 this.getInternalAccount = function() { return internalAccount }
32305 this.getExternalAccount = function() { return externalAccount }
32306
32307 this.getPrivateKey = function(index) {
32308 return externalAccount.derive(index).privKey
32309 }
32310
32311 this.getInternalPrivateKey = function(index) {
32312 return internalAccount.derive(index).privKey
32313 }
32314
32315 this.getPrivateKeyForAddress = function(address) {
32316 var index
32317 if((index = this.addresses.indexOf(address)) > -1) {
32318 return this.getPrivateKey(index)
32319 } else if((index = this.changeAddresses.indexOf(address)) > -1) {
32320 return this.getInternalPrivateKey(index)
32321 } else {
32322 throw new Error('Unknown address. Make sure the address is from the keychain and has been generated.')
32323 }
32324 }
32325
32326 function isReceiveAddress(address){
32327 return me.addresses.indexOf(address) > -1
32328 }
32329
32330 function isChangeAddress(address){
32331 return me.changeAddresses.indexOf(address) > -1
32332 }
32333
32334 function isMyAddress(address) {
32335 return isReceiveAddress(address) || isChangeAddress(address)
32336 }
32337 }
32338
32339 module.exports = Wallet
32340
32341 }).call(this,_dereq_("buffer").Buffer)
32342 },{"./address":69,"./hdnode":78,"./networks":81,"./transaction":85,"assert":4,"buffer":8,"secure-random":68}]},{},[79])
32343 (79)
32344 });
32345 </script>
32346 <script>
32347 // Select components from sjcl to suit the crypto operations bip39 requires.
32348
32349 //// base.js
32350
32351 /** @fileOverview Javascript cryptography implementation.
32352 *
32353 * Crush to remove comments, shorten variable names and
32354 * generally reduce transmission size.
32355 *
32356 * @author Emily Stark
32357 * @author Mike Hamburg
32358 * @author Dan Boneh
32359 */
32360
32361 "use strict";
32362 /*jslint indent: 2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
32363 /*global document, window, escape, unescape, module, require, Uint32Array */
32364
32365 /** @namespace The Stanford Javascript Crypto Library, top-level namespace. */
32366 var sjcl = {
32367 /** @namespace Symmetric ciphers. */
32368 cipher: {},
32369
32370 /** @namespace Hash functions. Right now only SHA256 is implemented. */
32371 hash: {},
32372
32373 /** @namespace Key exchange functions. Right now only SRP is implemented. */
32374 keyexchange: {},
32375
32376 /** @namespace Block cipher modes of operation. */
32377 mode: {},
32378
32379 /** @namespace Miscellaneous. HMAC and PBKDF2. */
32380 misc: {},
32381
32382 /**
32383 * @namespace Bit array encoders and decoders.
32384 *
32385 * @description
32386 * The members of this namespace are functions which translate between
32387 * SJCL's bitArrays and other objects (usually strings). Because it
32388 * isn't always clear which direction is encoding and which is decoding,
32389 * the method names are "fromBits" and "toBits".
32390 */
32391 codec: {},
32392
32393 /** @namespace Exceptions. */
32394 exception: {
32395 /** @constructor Ciphertext is corrupt. */
32396 corrupt: function(message) {
32397 this.toString = function() { return "CORRUPT: "+this.message; };
32398 this.message = message;
32399 },
32400
32401 /** @constructor Invalid parameter. */
32402 invalid: function(message) {
32403 this.toString = function() { return "INVALID: "+this.message; };
32404 this.message = message;
32405 },
32406
32407 /** @constructor Bug or missing feature in SJCL. @constructor */
32408 bug: function(message) {
32409 this.toString = function() { return "BUG: "+this.message; };
32410 this.message = message;
32411 },
32412
32413 /** @constructor Something isn't ready. */
32414 notReady: function(message) {
32415 this.toString = function() { return "NOT READY: "+this.message; };
32416 this.message = message;
32417 }
32418 }
32419 };
32420
32421 if(typeof module !== 'undefined' && module.exports){
32422 module.exports = sjcl;
32423 }
32424 if (typeof define === "function") {
32425 define([], function () {
32426 return sjcl;
32427 });
32428 }
32429
32430
32431 //// bitArray.js
32432
32433 /** @fileOverview Arrays of bits, encoded as arrays of Numbers.
32434 *
32435 * @author Emily Stark
32436 * @author Mike Hamburg
32437 * @author Dan Boneh
32438 */
32439
32440 /** @namespace Arrays of bits, encoded as arrays of Numbers.
32441 *
32442 * @description
32443 * <p>
32444 * These objects are the currency accepted by SJCL's crypto functions.
32445 * </p>
32446 *
32447 * <p>
32448 * Most of our crypto primitives operate on arrays of 4-byte words internally,
32449 * but many of them can take arguments that are not a multiple of 4 bytes.
32450 * This library encodes arrays of bits (whose size need not be a multiple of 8
32451 * bits) as arrays of 32-bit words. The bits are packed, big-endian, into an
32452 * array of words, 32 bits at a time. Since the words are double-precision
32453 * floating point numbers, they fit some extra data. We use this (in a private,
32454 * possibly-changing manner) to encode the number of bits actually present
32455 * in the last word of the array.
32456 * </p>
32457 *
32458 * <p>
32459 * Because bitwise ops clear this out-of-band data, these arrays can be passed
32460 * to ciphers like AES which want arrays of words.
32461 * </p>
32462 */
32463 sjcl.bitArray = {
32464 /**
32465 * Array slices in units of bits.
32466 * @param {bitArray} a The array to slice.
32467 * @param {Number} bstart The offset to the start of the slice, in bits.
32468 * @param {Number} bend The offset to the end of the slice, in bits. If this is undefined,
32469 * slice until the end of the array.
32470 * @return {bitArray} The requested slice.
32471 */
32472 bitSlice: function (a, bstart, bend) {
32473 a = sjcl.bitArray._shiftRight(a.slice(bstart/32), 32 - (bstart & 31)).slice(1);
32474 return (bend === undefined) ? a : sjcl.bitArray.clamp(a, bend-bstart);
32475 },
32476
32477 /**
32478 * Extract a number packed into a bit array.
32479 * @param {bitArray} a The array to slice.
32480 * @param {Number} bstart The offset to the start of the slice, in bits.
32481 * @param {Number} length The length of the number to extract.
32482 * @return {Number} The requested slice.
32483 */
32484 extract: function(a, bstart, blength) {
32485 // FIXME: this Math.floor is not necessary at all, but for some reason
32486 // seems to suppress a bug in the Chromium JIT.
32487 var x, sh = Math.floor((-bstart-blength) & 31);
32488 if ((bstart + blength - 1 ^ bstart) & -32) {
32489 // it crosses a boundary
32490 x = (a[bstart/32|0] << (32 - sh)) ^ (a[bstart/32+1|0] >>> sh);
32491 } else {
32492 // within a single word
32493 x = a[bstart/32|0] >>> sh;
32494 }
32495 return x & ((1<<blength) - 1);
32496 },
32497
32498 /**
32499 * Concatenate two bit arrays.
32500 * @param {bitArray} a1 The first array.
32501 * @param {bitArray} a2 The second array.
32502 * @return {bitArray} The concatenation of a1 and a2.
32503 */
32504 concat: function (a1, a2) {
32505 if (a1.length === 0 || a2.length === 0) {
32506 return a1.concat(a2);
32507 }
32508
32509 var last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last);
32510 if (shift === 32) {
32511 return a1.concat(a2);
32512 } else {
32513 return sjcl.bitArray._shiftRight(a2, shift, last|0, a1.slice(0,a1.length-1));
32514 }
32515 },
32516
32517 /**
32518 * Find the length of an array of bits.
32519 * @param {bitArray} a The array.
32520 * @return {Number} The length of a, in bits.
32521 */
32522 bitLength: function (a) {
32523 var l = a.length, x;
32524 if (l === 0) { return 0; }
32525 x = a[l - 1];
32526 return (l-1) * 32 + sjcl.bitArray.getPartial(x);
32527 },
32528
32529 /**
32530 * Truncate an array.
32531 * @param {bitArray} a The array.
32532 * @param {Number} len The length to truncate to, in bits.
32533 * @return {bitArray} A new array, truncated to len bits.
32534 */
32535 clamp: function (a, len) {
32536 if (a.length * 32 < len) { return a; }
32537 a = a.slice(0, Math.ceil(len / 32));
32538 var l = a.length;
32539 len = len & 31;
32540 if (l > 0 && len) {
32541 a[l-1] = sjcl.bitArray.partial(len, a[l-1] & 0x80000000 >> (len-1), 1);
32542 }
32543 return a;
32544 },
32545
32546 /**
32547 * Make a partial word for a bit array.
32548 * @param {Number} len The number of bits in the word.
32549 * @param {Number} x The bits.
32550 * @param {Number} [0] _end Pass 1 if x has already been shifted to the high side.
32551 * @return {Number} The partial word.
32552 */
32553 partial: function (len, x, _end) {
32554 if (len === 32) { return x; }
32555 return (_end ? x|0 : x << (32-len)) + len * 0x10000000000;
32556 },
32557
32558 /**
32559 * Get the number of bits used by a partial word.
32560 * @param {Number} x The partial word.
32561 * @return {Number} The number of bits used by the partial word.
32562 */
32563 getPartial: function (x) {
32564 return Math.round(x/0x10000000000) || 32;
32565 },
32566
32567 /**
32568 * Compare two arrays for equality in a predictable amount of time.
32569 * @param {bitArray} a The first array.
32570 * @param {bitArray} b The second array.
32571 * @return {boolean} true if a == b; false otherwise.
32572 */
32573 equal: function (a, b) {
32574 if (sjcl.bitArray.bitLength(a) !== sjcl.bitArray.bitLength(b)) {
32575 return false;
32576 }
32577 var x = 0, i;
32578 for (i=0; i<a.length; i++) {
32579 x |= a[i]^b[i];
32580 }
32581 return (x === 0);
32582 },
32583
32584 /** Shift an array right.
32585 * @param {bitArray} a The array to shift.
32586 * @param {Number} shift The number of bits to shift.
32587 * @param {Number} [carry=0] A byte to carry in
32588 * @param {bitArray} [out=[]] An array to prepend to the output.
32589 * @private
32590 */
32591 _shiftRight: function (a, shift, carry, out) {
32592 var i, last2=0, shift2;
32593 if (out === undefined) { out = []; }
32594
32595 for (; shift >= 32; shift -= 32) {
32596 out.push(carry);
32597 carry = 0;
32598 }
32599 if (shift === 0) {
32600 return out.concat(a);
32601 }
32602
32603 for (i=0; i<a.length; i++) {
32604 out.push(carry | a[i]>>>shift);
32605 carry = a[i] << (32-shift);
32606 }
32607 last2 = a.length ? a[a.length-1] : 0;
32608 shift2 = sjcl.bitArray.getPartial(last2);
32609 out.push(sjcl.bitArray.partial(shift+shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(),1));
32610 return out;
32611 },
32612
32613 /** xor a block of 4 words together.
32614 * @private
32615 */
32616 _xor4: function(x,y) {
32617 return [x[0]^y[0],x[1]^y[1],x[2]^y[2],x[3]^y[3]];
32618 },
32619
32620 /** byteswap a word array inplace.
32621 * (does not handle partial words)
32622 * @param {sjcl.bitArray} a word array
32623 * @return {sjcl.bitArray} byteswapped array
32624 */
32625 byteswapM: function(a) {
32626 var i, v, m = 0xff00;
32627 for (i = 0; i < a.length; ++i) {
32628 v = a[i];
32629 a[i] = (v >>> 24) | ((v >>> 8) & m) | ((v & m) << 8) | (v << 24);
32630 }
32631 return a;
32632 }
32633 };
32634
32635
32636 //// codecString.js
32637
32638 /** @fileOverview Bit array codec implementations.
32639 *
32640 * @author Emily Stark
32641 * @author Mike Hamburg
32642 * @author Dan Boneh
32643 */
32644
32645 /** @namespace UTF-8 strings */
32646 sjcl.codec.utf8String = {
32647 /** Convert from a bitArray to a UTF-8 string. */
32648 fromBits: function (arr) {
32649 var out = "", bl = sjcl.bitArray.bitLength(arr), i, tmp;
32650 for (i=0; i<bl/8; i++) {
32651 if ((i&3) === 0) {
32652 tmp = arr[i/4];
32653 }
32654 out += String.fromCharCode(tmp >>> 24);
32655 tmp <<= 8;
32656 }
32657 return decodeURIComponent(escape(out));
32658 },
32659
32660 /** Convert from a UTF-8 string to a bitArray. */
32661 toBits: function (str) {
32662 str = unescape(encodeURIComponent(str));
32663 var out = [], i, tmp=0;
32664 for (i=0; i<str.length; i++) {
32665 tmp = tmp << 8 | str.charCodeAt(i);
32666 if ((i&3) === 3) {
32667 out.push(tmp);
32668 tmp = 0;
32669 }
32670 }
32671 if (i&3) {
32672 out.push(sjcl.bitArray.partial(8*(i&3), tmp));
32673 }
32674 return out;
32675 }
32676 };
32677
32678
32679 //// codecHex.js
32680
32681 /** @fileOverview Bit array codec implementations.
32682 *
32683 * @author Emily Stark
32684 * @author Mike Hamburg
32685 * @author Dan Boneh
32686 */
32687
32688 /** @namespace Hexadecimal */
32689 sjcl.codec.hex = {
32690 /** Convert from a bitArray to a hex string. */
32691 fromBits: function (arr) {
32692 var out = "", i;
32693 for (i=0; i<arr.length; i++) {
32694 out += ((arr[i]|0)+0xF00000000000).toString(16).substr(4);
32695 }
32696 return out.substr(0, sjcl.bitArray.bitLength(arr)/4);//.replace(/(.{8})/g, "$1 ");
32697 },
32698 /** Convert from a hex string to a bitArray. */
32699 toBits: function (str) {
32700 var i, out=[], len;
32701 str = str.replace(/\s|0x/g, "");
32702 len = str.length;
32703 str = str + "00000000";
32704 for (i=0; i<str.length; i+=8) {
32705 out.push(parseInt(str.substr(i,8),16)^0);
32706 }
32707 return sjcl.bitArray.clamp(out, len*4);
32708 }
32709 };
32710
32711
32712 //// sha512.js
32713
32714 /** @fileOverview Javascript SHA-512 implementation.
32715 *
32716 * This implementation was written for CryptoJS by Jeff Mott and adapted for
32717 * SJCL by Stefan Thomas.
32718 *
32719 * CryptoJS (c) 2009–2012 by Jeff Mott. All rights reserved.
32720 * Released with New BSD License
32721 *
32722 * @author Emily Stark
32723 * @author Mike Hamburg
32724 * @author Dan Boneh
32725 * @author Jeff Mott
32726 * @author Stefan Thomas
32727 */
32728
32729 /**
32730 * Context for a SHA-512 operation in progress.
32731 * @constructor
32732 * @class Secure Hash Algorithm, 512 bits.
32733 */
32734 sjcl.hash.sha512 = function (hash) {
32735 if (!this._key[0]) { this._precompute(); }
32736 if (hash) {
32737 this._h = hash._h.slice(0);
32738 this._buffer = hash._buffer.slice(0);
32739 this._length = hash._length;
32740 } else {
32741 this.reset();
32742 }
32743 };
32744
32745 /**
32746 * Hash a string or an array of words.
32747 * @static
32748 * @param {bitArray|String} data the data to hash.
32749 * @return {bitArray} The hash value, an array of 16 big-endian words.
32750 */
32751 sjcl.hash.sha512.hash = function (data) {
32752 return (new sjcl.hash.sha512()).update(data).finalize();
32753 };
32754
32755 sjcl.hash.sha512.prototype = {
32756 /**
32757 * The hash's block size, in bits.
32758 * @constant
32759 */
32760 blockSize: 1024,
32761
32762 /**
32763 * Reset the hash state.
32764 * @return this
32765 */
32766 reset:function () {
32767 this._h = this._init.slice(0);
32768 this._buffer = [];
32769 this._length = 0;
32770 return this;
32771 },
32772
32773 /**
32774 * Input several words to the hash.
32775 * @param {bitArray|String} data the data to hash.
32776 * @return this
32777 */
32778 update: function (data) {
32779 if (typeof data === "string") {
32780 data = sjcl.codec.utf8String.toBits(data);
32781 }
32782 var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
32783 ol = this._length,
32784 nl = this._length = ol + sjcl.bitArray.bitLength(data);
32785 for (i = 1024+ol & -1024; i <= nl; i+= 1024) {
32786 this._block(b.splice(0,32));
32787 }
32788 return this;
32789 },
32790
32791 /**
32792 * Complete hashing and output the hash value.
32793 * @return {bitArray} The hash value, an array of 16 big-endian words.
32794 */
32795 finalize:function () {
32796 var i, b = this._buffer, h = this._h;
32797
32798 // Round out and push the buffer
32799 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);
32800
32801 // Round out the buffer to a multiple of 32 words, less the 4 length words.
32802 for (i = b.length + 4; i & 31; i++) {
32803 b.push(0);
32804 }
32805
32806 // append the length
32807 b.push(0);
32808 b.push(0);
32809 b.push(Math.floor(this._length / 0x100000000));
32810 b.push(this._length | 0);
32811
32812 while (b.length) {
32813 this._block(b.splice(0,32));
32814 }
32815
32816 this.reset();
32817 return h;
32818 },
32819
32820 /**
32821 * The SHA-512 initialization vector, to be precomputed.
32822 * @private
32823 */
32824 _init:[],
32825
32826 /**
32827 * Least significant 24 bits of SHA512 initialization values.
32828 *
32829 * Javascript only has 53 bits of precision, so we compute the 40 most
32830 * significant bits and add the remaining 24 bits as constants.
32831 *
32832 * @private
32833 */
32834 _initr: [ 0xbcc908, 0xcaa73b, 0x94f82b, 0x1d36f1, 0xe682d1, 0x3e6c1f, 0x41bd6b, 0x7e2179 ],
32835
32836 /*
32837 _init:
32838 [0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,
32839 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179],
32840 */
32841
32842 /**
32843 * The SHA-512 hash key, to be precomputed.
32844 * @private
32845 */
32846 _key:[],
32847
32848 /**
32849 * Least significant 24 bits of SHA512 key values.
32850 * @private
32851 */
32852 _keyr:
32853 [0x28ae22, 0xef65cd, 0x4d3b2f, 0x89dbbc, 0x48b538, 0x05d019, 0x194f9b, 0x6d8118,
32854 0x030242, 0x706fbe, 0xe4b28c, 0xffb4e2, 0x7b896f, 0x1696b1, 0xc71235, 0x692694,
32855 0xf14ad2, 0x4f25e3, 0x8cd5b5, 0xac9c65, 0x2b0275, 0xa6e483, 0x41fbd4, 0x1153b5,
32856 0x66dfab, 0xb43210, 0xfb213f, 0xef0ee4, 0xa88fc2, 0x0aa725, 0x03826f, 0x0e6e70,
32857 0xd22ffc, 0x26c926, 0xc42aed, 0x95b3df, 0xaf63de, 0x77b2a8, 0xedaee6, 0x82353b,
32858 0xf10364, 0x423001, 0xf89791, 0x54be30, 0xef5218, 0x65a910, 0x71202a, 0xbbd1b8,
32859 0xd2d0c8, 0x41ab53, 0x8eeb99, 0x9b48a8, 0xc95a63, 0x418acb, 0x63e373, 0xb2b8a3,
32860 0xefb2fc, 0x172f60, 0xf0ab72, 0x6439ec, 0x631e28, 0x82bde9, 0xc67915, 0x72532b,
32861 0x26619c, 0xc0c207, 0xe0eb1e, 0x6ed178, 0x176fba, 0xc898a6, 0xf90dae, 0x1c471b,
32862 0x047d84, 0xc72493, 0xc9bebc, 0x100d4c, 0x3e42b6, 0x657e2a, 0xd6faec, 0x475817],
32863
32864 /*
32865 _key:
32866 [0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
32867 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
32868 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
32869 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
32870 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
32871 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
32872 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
32873 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
32874 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
32875 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
32876 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
32877 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
32878 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
32879 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
32880 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
32881 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
32882 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
32883 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
32884 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
32885 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817],
32886 */
32887
32888 /**
32889 * Function to precompute _init and _key.
32890 * @private
32891 */
32892 _precompute: function () {
32893 // XXX: This code is for precomputing the SHA256 constants, change for
32894 // SHA512 and re-enable.
32895 var i = 0, prime = 2, factor;
32896
32897 function frac(x) { return (x-Math.floor(x)) * 0x100000000 | 0; }
32898 function frac2(x) { return (x-Math.floor(x)) * 0x10000000000 & 0xff; }
32899
32900 outer: for (; i<80; prime++) {
32901 for (factor=2; factor*factor <= prime; factor++) {
32902 if (prime % factor === 0) {
32903 // not a prime
32904 continue outer;
32905 }
32906 }
32907
32908 if (i<8) {
32909 this._init[i*2] = frac(Math.pow(prime, 1/2));
32910 this._init[i*2+1] = (frac2(Math.pow(prime, 1/2)) << 24) | this._initr[i];
32911 }
32912 this._key[i*2] = frac(Math.pow(prime, 1/3));
32913 this._key[i*2+1] = (frac2(Math.pow(prime, 1/3)) << 24) | this._keyr[i];
32914 i++;
32915 }
32916 },
32917
32918 /**
32919 * Perform one cycle of SHA-512.
32920 * @param {bitArray} words one block of words.
32921 * @private
32922 */
32923 _block:function (words) {
32924 var i, wrh, wrl,
32925 w = words.slice(0),
32926 h = this._h,
32927 k = this._key,
32928 h0h = h[ 0], h0l = h[ 1], h1h = h[ 2], h1l = h[ 3],
32929 h2h = h[ 4], h2l = h[ 5], h3h = h[ 6], h3l = h[ 7],
32930 h4h = h[ 8], h4l = h[ 9], h5h = h[10], h5l = h[11],
32931 h6h = h[12], h6l = h[13], h7h = h[14], h7l = h[15];
32932
32933 // Working variables
32934 var ah = h0h, al = h0l, bh = h1h, bl = h1l,
32935 ch = h2h, cl = h2l, dh = h3h, dl = h3l,
32936 eh = h4h, el = h4l, fh = h5h, fl = h5l,
32937 gh = h6h, gl = h6l, hh = h7h, hl = h7l;
32938
32939 for (i=0; i<80; i++) {
32940 // load up the input word for this round
32941 if (i<16) {
32942 wrh = w[i * 2];
32943 wrl = w[i * 2 + 1];
32944 } else {
32945 // Gamma0
32946 var gamma0xh = w[(i-15) * 2];
32947 var gamma0xl = w[(i-15) * 2 + 1];
32948 var gamma0h =
32949 ((gamma0xl << 31) | (gamma0xh >>> 1)) ^
32950 ((gamma0xl << 24) | (gamma0xh >>> 8)) ^
32951 (gamma0xh >>> 7);
32952 var gamma0l =
32953 ((gamma0xh << 31) | (gamma0xl >>> 1)) ^
32954 ((gamma0xh << 24) | (gamma0xl >>> 8)) ^
32955 ((gamma0xh << 25) | (gamma0xl >>> 7));
32956
32957 // Gamma1
32958 var gamma1xh = w[(i-2) * 2];
32959 var gamma1xl = w[(i-2) * 2 + 1];
32960 var gamma1h =
32961 ((gamma1xl << 13) | (gamma1xh >>> 19)) ^
32962 ((gamma1xh << 3) | (gamma1xl >>> 29)) ^
32963 (gamma1xh >>> 6);
32964 var gamma1l =
32965 ((gamma1xh << 13) | (gamma1xl >>> 19)) ^
32966 ((gamma1xl << 3) | (gamma1xh >>> 29)) ^
32967 ((gamma1xh << 26) | (gamma1xl >>> 6));
32968
32969 // Shortcuts
32970 var wr7h = w[(i-7) * 2];
32971 var wr7l = w[(i-7) * 2 + 1];
32972
32973 var wr16h = w[(i-16) * 2];
32974 var wr16l = w[(i-16) * 2 + 1];
32975
32976 // W(round) = gamma0 + W(round - 7) + gamma1 + W(round - 16)
32977 wrl = gamma0l + wr7l;
32978 wrh = gamma0h + wr7h + ((wrl >>> 0) < (gamma0l >>> 0) ? 1 : 0);
32979 wrl += gamma1l;
32980 wrh += gamma1h + ((wrl >>> 0) < (gamma1l >>> 0) ? 1 : 0);
32981 wrl += wr16l;
32982 wrh += wr16h + ((wrl >>> 0) < (wr16l >>> 0) ? 1 : 0);
32983 }
32984
32985 w[i*2] = wrh |= 0;
32986 w[i*2 + 1] = wrl |= 0;
32987
32988 // Ch
32989 var chh = (eh & fh) ^ (~eh & gh);
32990 var chl = (el & fl) ^ (~el & gl);
32991
32992 // Maj
32993 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
32994 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
32995
32996 // Sigma0
32997 var sigma0h = ((al << 4) | (ah >>> 28)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
32998 var sigma0l = ((ah << 4) | (al >>> 28)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
32999
33000 // Sigma1
33001 var sigma1h = ((el << 18) | (eh >>> 14)) ^ ((el << 14) | (eh >>> 18)) ^ ((eh << 23) | (el >>> 9));
33002 var sigma1l = ((eh << 18) | (el >>> 14)) ^ ((eh << 14) | (el >>> 18)) ^ ((el << 23) | (eh >>> 9));
33003
33004 // K(round)
33005 var krh = k[i*2];
33006 var krl = k[i*2+1];
33007
33008 // t1 = h + sigma1 + ch + K(round) + W(round)
33009 var t1l = hl + sigma1l;
33010 var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
33011 t1l += chl;
33012 t1h += chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
33013 t1l += krl;
33014 t1h += krh + ((t1l >>> 0) < (krl >>> 0) ? 1 : 0);
33015 t1l = t1l + wrl|0; // FF32..FF34 perf issue https://bugzilla.mozilla.org/show_bug.cgi?id=1054972
33016 t1h += wrh + ((t1l >>> 0) < (wrl >>> 0) ? 1 : 0);
33017
33018 // t2 = sigma0 + maj
33019 var t2l = sigma0l + majl;
33020 var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
33021
33022 // Update working variables
33023 hh = gh;
33024 hl = gl;
33025 gh = fh;
33026 gl = fl;
33027 fh = eh;
33028 fl = el;
33029 el = (dl + t1l) | 0;
33030 eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
33031 dh = ch;
33032 dl = cl;
33033 ch = bh;
33034 cl = bl;
33035 bh = ah;
33036 bl = al;
33037 al = (t1l + t2l) | 0;
33038 ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
33039 }
33040
33041 // Intermediate hash
33042 h0l = h[1] = (h0l + al) | 0;
33043 h[0] = (h0h + ah + ((h0l >>> 0) < (al >>> 0) ? 1 : 0)) | 0;
33044 h1l = h[3] = (h1l + bl) | 0;
33045 h[2] = (h1h + bh + ((h1l >>> 0) < (bl >>> 0) ? 1 : 0)) | 0;
33046 h2l = h[5] = (h2l + cl) | 0;
33047 h[4] = (h2h + ch + ((h2l >>> 0) < (cl >>> 0) ? 1 : 0)) | 0;
33048 h3l = h[7] = (h3l + dl) | 0;
33049 h[6] = (h3h + dh + ((h3l >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
33050 h4l = h[9] = (h4l + el) | 0;
33051 h[8] = (h4h + eh + ((h4l >>> 0) < (el >>> 0) ? 1 : 0)) | 0;
33052 h5l = h[11] = (h5l + fl) | 0;
33053 h[10] = (h5h + fh + ((h5l >>> 0) < (fl >>> 0) ? 1 : 0)) | 0;
33054 h6l = h[13] = (h6l + gl) | 0;
33055 h[12] = (h6h + gh + ((h6l >>> 0) < (gl >>> 0) ? 1 : 0)) | 0;
33056 h7l = h[15] = (h7l + hl) | 0;
33057 h[14] = (h7h + hh + ((h7l >>> 0) < (hl >>> 0) ? 1 : 0)) | 0;
33058 }
33059 };
33060
33061
33062 //// hmac.js
33063
33064 /** @fileOverview HMAC implementation.
33065 *
33066 * @author Emily Stark
33067 * @author Mike Hamburg
33068 * @author Dan Boneh
33069 */
33070
33071 /** HMAC with the specified hash function.
33072 * @constructor
33073 * @param {bitArray} key the key for HMAC.
33074 * @param {Object} [hash=sjcl.hash.sha256] The hash function to use.
33075 */
33076 sjcl.misc.hmac = function (key, Hash) {
33077 this._hash = Hash = Hash || sjcl.hash.sha256;
33078 var exKey = [[],[]], i,
33079 bs = Hash.prototype.blockSize / 32;
33080 this._baseHash = [new Hash(), new Hash()];
33081
33082 if (key.length > bs) {
33083 key = Hash.hash(key);
33084 }
33085
33086 for (i=0; i<bs; i++) {
33087 exKey[0][i] = key[i]^0x36363636;
33088 exKey[1][i] = key[i]^0x5C5C5C5C;
33089 }
33090
33091 this._baseHash[0].update(exKey[0]);
33092 this._baseHash[1].update(exKey[1]);
33093 this._resultHash = new Hash(this._baseHash[0]);
33094 };
33095
33096 /** HMAC with the specified hash function. Also called encrypt since it's a prf.
33097 * @param {bitArray|String} data The data to mac.
33098 */
33099 sjcl.misc.hmac.prototype.encrypt = sjcl.misc.hmac.prototype.mac = function (data) {
33100 if (!this._updated) {
33101 this.update(data);
33102 return this.digest(data);
33103 } else {
33104 throw new sjcl.exception.invalid("encrypt on already updated hmac called!");
33105 }
33106 };
33107
33108 sjcl.misc.hmac.prototype.reset = function () {
33109 this._resultHash = new this._hash(this._baseHash[0]);
33110 this._updated = false;
33111 };
33112
33113 sjcl.misc.hmac.prototype.update = function (data) {
33114 this._updated = true;
33115 this._resultHash.update(data);
33116 };
33117
33118 sjcl.misc.hmac.prototype.digest = function () {
33119 var w = this._resultHash.finalize(), result = new (this._hash)(this._baseHash[1]).update(w).finalize();
33120
33121 this.reset();
33122
33123 return result;
33124 };
33125
33126
33127 //// pbkdf2.js
33128
33129
33130 /** @fileOverview Password-based key-derivation function, version 2.0.
33131 *
33132 * @author Emily Stark
33133 * @author Mike Hamburg
33134 * @author Dan Boneh
33135 */
33136
33137 /** Password-Based Key-Derivation Function, version 2.0.
33138 *
33139 * Generate keys from passwords using PBKDF2-HMAC-SHA256.
33140 *
33141 * This is the method specified by RSA's PKCS #5 standard.
33142 *
33143 * @param {bitArray|String} password The password.
33144 * @param {bitArray|String} salt The salt. Should have lots of entropy.
33145 * @param {Number} [count=1000] The number of iterations. Higher numbers make the function slower but more secure.
33146 * @param {Number} [length] The length of the derived key. Defaults to the
33147 output size of the hash function.
33148 * @param {Object} [Prff=sjcl.misc.hmac] The pseudorandom function family.
33149 * @return {bitArray} the derived key.
33150 */
33151 sjcl.misc.pbkdf2 = function (password, salt, count, length, Prff) {
33152 count = count || 1000;
33153
33154 if (length < 0 || count < 0) {
33155 throw sjcl.exception.invalid("invalid params to pbkdf2");
33156 }
33157
33158 if (typeof password === "string") {
33159 password = sjcl.codec.utf8String.toBits(password);
33160 }
33161
33162 if (typeof salt === "string") {
33163 salt = sjcl.codec.utf8String.toBits(salt);
33164 }
33165
33166 Prff = Prff || sjcl.misc.hmac;
33167
33168 var prf = new Prff(password),
33169 u, ui, i, j, k, out = [], b = sjcl.bitArray;
33170
33171 for (k = 1; 32 * out.length < (length || 1); k++) {
33172 u = ui = prf.encrypt(b.concat(salt,[k]));
33173
33174 for (i=1; i<count; i++) {
33175 ui = prf.encrypt(ui);
33176 for (j=0; j<ui.length; j++) {
33177 u[j] ^= ui[j];
33178 }
33179 }
33180
33181 out = out.concat(u);
33182 }
33183
33184 if (length) { out = b.clamp(out, length); }
33185
33186 return out;
33187 };
33188
33189
33190 //// sha256.js
33191
33192 /** @fileOverview Javascript SHA-256 implementation.
33193 *
33194 * An older version of this implementation is available in the public
33195 * domain, but this one is (c) Emily Stark, Mike Hamburg, Dan Boneh,
33196 * Stanford University 2008-2010 and BSD-licensed for liability
33197 * reasons.
33198 *
33199 * Special thanks to Aldo Cortesi for pointing out several bugs in
33200 * this code.
33201 *
33202 * @author Emily Stark
33203 * @author Mike Hamburg
33204 * @author Dan Boneh
33205 */
33206
33207 /**
33208 * Context for a SHA-256 operation in progress.
33209 * @constructor
33210 * @class Secure Hash Algorithm, 256 bits.
33211 */
33212 sjcl.hash.sha256 = function (hash) {
33213 if (!this._key[0]) { this._precompute(); }
33214 if (hash) {
33215 this._h = hash._h.slice(0);
33216 this._buffer = hash._buffer.slice(0);
33217 this._length = hash._length;
33218 } else {
33219 this.reset();
33220 }
33221 };
33222
33223 /**
33224 * Hash a string or an array of words.
33225 * @static
33226 * @param {bitArray|String} data the data to hash.
33227 * @return {bitArray} The hash value, an array of 16 big-endian words.
33228 */
33229 sjcl.hash.sha256.hash = function (data) {
33230 return (new sjcl.hash.sha256()).update(data).finalize();
33231 };
33232
33233 sjcl.hash.sha256.prototype = {
33234 /**
33235 * The hash's block size, in bits.
33236 * @constant
33237 */
33238 blockSize: 512,
33239
33240 /**
33241 * Reset the hash state.
33242 * @return this
33243 */
33244 reset:function () {
33245 this._h = this._init.slice(0);
33246 this._buffer = [];
33247 this._length = 0;
33248 return this;
33249 },
33250
33251 /**
33252 * Input several words to the hash.
33253 * @param {bitArray|String} data the data to hash.
33254 * @return this
33255 */
33256 update: function (data) {
33257 if (typeof data === "string") {
33258 data = sjcl.codec.utf8String.toBits(data);
33259 }
33260 var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
33261 ol = this._length,
33262 nl = this._length = ol + sjcl.bitArray.bitLength(data);
33263 for (i = 512+ol & -512; i <= nl; i+= 512) {
33264 this._block(b.splice(0,16));
33265 }
33266 return this;
33267 },
33268
33269 /**
33270 * Complete hashing and output the hash value.
33271 * @return {bitArray} The hash value, an array of 8 big-endian words.
33272 */
33273 finalize:function () {
33274 var i, b = this._buffer, h = this._h;
33275
33276 // Round out and push the buffer
33277 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);
33278
33279 // Round out the buffer to a multiple of 16 words, less the 2 length words.
33280 for (i = b.length + 2; i & 15; i++) {
33281 b.push(0);
33282 }
33283
33284 // append the length
33285 b.push(Math.floor(this._length / 0x100000000));
33286 b.push(this._length | 0);
33287
33288 while (b.length) {
33289 this._block(b.splice(0,16));
33290 }
33291
33292 this.reset();
33293 return h;
33294 },
33295
33296 /**
33297 * The SHA-256 initialization vector, to be precomputed.
33298 * @private
33299 */
33300 _init:[],
33301 /*
33302 _init:[0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19],
33303 */
33304
33305 /**
33306 * The SHA-256 hash key, to be precomputed.
33307 * @private
33308 */
33309 _key:[],
33310 /*
33311 _key:
33312 [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
33313 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
33314 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
33315 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
33316 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
33317 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
33318 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
33319 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2],
33320 */
33321
33322
33323 /**
33324 * Function to precompute _init and _key.
33325 * @private
33326 */
33327 _precompute: function () {
33328 var i = 0, prime = 2, factor;
33329
33330 function frac(x) { return (x-Math.floor(x)) * 0x100000000 | 0; }
33331
33332 outer: for (; i<64; prime++) {
33333 for (factor=2; factor*factor <= prime; factor++) {
33334 if (prime % factor === 0) {
33335 // not a prime
33336 continue outer;
33337 }
33338 }
33339
33340 if (i<8) {
33341 this._init[i] = frac(Math.pow(prime, 1/2));
33342 }
33343 this._key[i] = frac(Math.pow(prime, 1/3));
33344 i++;
33345 }
33346 },
33347
33348 /**
33349 * Perform one cycle of SHA-256.
33350 * @param {bitArray} words one block of words.
33351 * @private
33352 */
33353 _block:function (words) {
33354 var i, tmp, a, b,
33355 w = words.slice(0),
33356 h = this._h,
33357 k = this._key,
33358 h0 = h[0], h1 = h[1], h2 = h[2], h3 = h[3],
33359 h4 = h[4], h5 = h[5], h6 = h[6], h7 = h[7];
33360
33361 /* Rationale for placement of |0 :
33362 * If a value can overflow is original 32 bits by a factor of more than a few
33363 * million (2^23 ish), there is a possibility that it might overflow the
33364 * 53-bit mantissa and lose precision.
33365 *
33366 * To avoid this, we clamp back to 32 bits by |'ing with 0 on any value that
33367 * propagates around the loop, and on the hash state h[]. I don't believe
33368 * that the clamps on h4 and on h0 are strictly necessary, but it's close
33369 * (for h4 anyway), and better safe than sorry.
33370 *
33371 * The clamps on h[] are necessary for the output to be correct even in the
33372 * common case and for short inputs.
33373 */
33374 for (i=0; i<64; i++) {
33375 // load up the input word for this round
33376 if (i<16) {
33377 tmp = w[i];
33378 } else {
33379 a = w[(i+1 ) & 15];
33380 b = w[(i+14) & 15];
33381 tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) +
33382 (b>>>17 ^ b>>>19 ^ b>>>10 ^ b<<15 ^ b<<13) +
33383 w[i&15] + w[(i+9) & 15]) | 0;
33384 }
33385
33386 tmp = (tmp + h7 + (h4>>>6 ^ h4>>>11 ^ h4>>>25 ^ h4<<26 ^ h4<<21 ^ h4<<7) + (h6 ^ h4&(h5^h6)) + k[i]); // | 0;
33387
33388 // shift register
33389 h7 = h6; h6 = h5; h5 = h4;
33390 h4 = h3 + tmp | 0;
33391 h3 = h2; h2 = h1; h1 = h0;
33392
33393 h0 = (tmp + ((h1&h2) ^ (h3&(h1^h2))) + (h1>>>2 ^ h1>>>13 ^ h1>>>22 ^ h1<<30 ^ h1<<19 ^ h1<<10)) | 0;
33394 }
33395
33396 h[0] = h[0]+h0 | 0;
33397 h[1] = h[1]+h1 | 0;
33398 h[2] = h[2]+h2 | 0;
33399 h[3] = h[3]+h3 | 0;
33400 h[4] = h[4]+h4 | 0;
33401 h[5] = h[5]+h5 | 0;
33402 h[6] = h[6]+h6 | 0;
33403 h[7] = h[7]+h7 | 0;
33404 }
33405 };
33406 </script>
33407 <script>
33408 WORDLISTS = {};
33409 </script>
33410 <script>
33411 WORDLISTS["english"] = [
33412 "abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse",
33413 "access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act",
33414 "action","actor","actress","actual","adapt","add","addict","address","adjust","admit",
33415 "adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent",
33416 "agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert",
33417 "alien","all","alley","allow","almost","alone","alpha","already","also","alter",
33418 "always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger",
33419 "angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique",
33420 "anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic",
33421 "area","arena","argue","arm","armed","armor","army","around","arrange","arrest",
33422 "arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset",
33423 "assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction",
33424 "audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake",
33425 "aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge",
33426 "bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain",
33427 "barrel","base","basic","basket","battle","beach","bean","beauty","because","become",
33428 "beef","before","begin","behave","behind","believe","below","belt","bench","benefit",
33429 "best","betray","better","between","beyond","bicycle","bid","bike","bind","biology",
33430 "bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless",
33431 "blind","blood","blossom","blouse","blue","blur","blush","board","boat","body",
33432 "boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss",
33433 "bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread",
33434 "breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze",
33435 "broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb",
33436 "bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy",
33437 "butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call",
33438 "calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas",
33439 "canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry",
33440 "cart","case","cash","casino","castle","casual","cat","catalog","catch","category",
33441 "cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century",
33442 "cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase",
33443 "chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child",
33444 "chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle",
33445 "citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk",
33446 "clever","click","client","cliff","climb","clinic","clip","clock","clog","close",
33447 "cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut",
33448 "code","coffee","coil","coin","collect","color","column","combine","come","comfort",
33449 "comic","common","company","concert","conduct","confirm","congress","connect","consider","control",
33450 "convince","cook","cool","copper","copy","coral","core","corn","correct","cost",
33451 "cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle",
33452 "craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek",
33453 "crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial",
33454 "cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup",
33455 "cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad",
33456 "damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal",
33457 "debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense",
33458 "define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny",
33459 "depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk",
33460 "despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond",
33461 "diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur",
33462 "direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance",
33463 "divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain",
33464 "donate","donkey","donor","door","dose","double","dove","draft","dragon","drama",
33465 "drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop",
33466 "drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf",
33467 "dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo",
33468 "ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow",
33469 "elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody",
33470 "embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless",
33471 "endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough",
33472 "enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip",
33473 "era","erase","erode","erosion","error","erupt","escape","essay","essence","estate",
33474 "eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange",
33475 "excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit",
33476 "exotic","expand","expect","expire","explain","expose","express","extend","extra","eye",
33477 "eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame",
33478 "family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father",
33479 "fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female",
33480 "fence","festival","fetch","fever","few","fiber","fiction","field","figure","file",
33481 "film","filter","final","find","fine","finger","finish","fire","firm","first",
33482 "fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor",
33483 "flee","flight","flip","float","flock","floor","flower","fluid","flush","fly",
33484 "foam","focus","fog","foil","fold","follow","food","foot","force","forest",
33485 "forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile",
33486 "frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen",
33487 "fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy",
33488 "gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp",
33489 "gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture",
33490 "ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance",
33491 "glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue",
33492 "goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown",
33493 "grab","grace","grain","grant","grape","grass","gravity","great","green","grid",
33494 "grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt",
33495 "guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy",
33496 "harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health",
33497 "heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden",
33498 "high","hill","hint","hip","hire","history","hobby","hockey","hold","hole",
33499 "holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital",
33500 "host","hotel","hour","hover","hub","huge","human","humble","humor","hundred",
33501 "hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea",
33502 "identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune",
33503 "impact","impose","improve","impulse","inch","include","income","increase","index","indicate",
33504 "indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury",
33505 "inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install",
33506 "intact","interest","into","invest","invite","involve","iron","island","isolate","issue",
33507 "item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel",
33508 "job","join","joke","journey","joy","judge","juice","jump","jungle","junior",
33509 "junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney",
33510 "kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife",
33511 "knock","know","lab","label","labor","ladder","lady","lake","lamp","language",
33512 "laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit",
33513 "layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal",
33514 "legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level",
33515 "liar","liberty","library","license","life","lift","light","like","limb","limit",
33516 "link","lion","liquid","list","little","live","lizard","load","loan","lobster",
33517 "local","lock","logic","lonely","long","loop","lottery","loud","lounge","love",
33518 "loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad",
33519 "magic","magnet","maid","mail","main","major","make","mammal","man","manage",
33520 "mandate","mango","mansion","manual","maple","marble","march","margin","marine","market",
33521 "marriage","mask","mass","master","match","material","math","matrix","matter","maximum",
33522 "maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt",
33523 "member","memory","mention","menu","mercy","merge","merit","merry","mesh","message",
33524 "metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor",
33525 "minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile",
33526 "model","modify","mom","moment","monitor","monkey","monster","month","moon","moral",
33527 "more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie",
33528 "much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual",
33529 "myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature",
33530 "near","neck","need","negative","neglect","neither","nephew","nerve","nest","net",
33531 "network","neutral","never","news","next","nice","night","noble","noise","nominee",
33532 "noodle","normal","north","nose","notable","note","nothing","notice","novel","now",
33533 "nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe",
33534 "obtain","obvious","occur","ocean","october","odor","off","offer","office","often",
33535 "oil","okay","old","olive","olympic","omit","once","one","onion","online",
33536 "only","open","opera","opinion","oppose","option","orange","orbit","orchard","order",
33537 "ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output",
33538 "outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact",
33539 "paddle","page","pair","palace","palm","panda","panel","panic","panther","paper",
33540 "parade","parent","park","parrot","party","pass","patch","path","patient","patrol",
33541 "pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen",
33542 "penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo",
33543 "phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot",
33544 "pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate",
33545 "play","please","pledge","pluck","plug","plunge","poem","poet","point","polar",
33546 "pole","police","pond","pony","pool","popular","portion","position","possible","post",
33547 "potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare",
33548 "present","pretty","prevent","price","pride","primary","print","priority","prison","private",
33549 "prize","problem","process","produce","profit","program","project","promote","proof","property",
33550 "prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin",
33551 "punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle",
33552 "pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit",
33553 "raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp",
33554 "ranch","random","range","rapid","rare","rate","rather","raven","raw","razor",
33555 "ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle",
33556 "reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release",
33557 "relief","rely","remain","remember","remind","remove","render","renew","rent","reopen",
33558 "repair","repeat","replace","report","require","rescue","resemble","resist","resource","response",
33559 "result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib",
33560 "ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot",
33561 "ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket",
33562 "romance","roof","rookie","room","rose","rotate","rough","round","route","royal",
33563 "rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness",
33564 "safe","sail","salad","salmon","salon","salt","salute","same","sample","sand",
33565 "satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter",
33566 "scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script",
33567 "scrub","sea","search","season","seat","second","secret","section","security","seed",
33568 "seek","segment","select","sell","seminar","senior","sense","sentence","series","service",
33569 "session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell",
33570 "sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop",
33571 "short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side",
33572 "siege","sight","sign","silent","silk","silly","silver","similar","simple","since",
33573 "sing","siren","sister","situate","six","size","skate","sketch","ski","skill",
33574 "skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight",
33575 "slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth",
33576 "snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda",
33577 "soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry",
33578 "sort","soul","sound","soup","source","south","space","spare","spatial","spawn",
33579 "speak","special","speed","spell","spend","sphere","spice","spider","spike","spin",
33580 "spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring",
33581 "spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp",
33582 "stand","start","state","stay","steak","steel","stem","step","stereo","stick",
33583 "still","sting","stock","stomach","stone","stool","story","stove","strategy","street",
33584 "strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway",
33585 "success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny",
33586 "sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey",
33587 "suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim",
33588 "swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag",
33589 "tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi",
33590 "teach","team","tell","ten","tenant","tennis","tent","term","test","text",
33591 "thank","that","theme","then","theory","there","they","thing","this","thought",
33592 "three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber",
33593 "time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler",
33594 "toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool",
33595 "tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist",
33596 "toward","tower","town","toy","track","trade","traffic","tragic","train","transfer",
33597 "trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick",
33598 "trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust",
33599 "truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle",
33600 "twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella",
33601 "unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform",
33602 "unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade",
33603 "uphold","upon","upper","upset","urban","urge","usage","use","used","useful",
33604 "useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van",
33605 "vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue",
33606 "verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory",
33607 "video","view","village","vintage","violin","virtual","virus","visa","visit","visual",
33608 "vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage",
33609 "wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash",
33610 "wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather",
33611 "web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat",
33612 "wheel","when","where","whip","whisper","wide","width","wife","wild","will",
33613 "win","window","wine","wing","wink","winner","winter","wire","wisdom","wise",
33614 "wish","witness","wolf","woman","wonder","wood","wool","word","work","world",
33615 "worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year",
33616 "yellow","you","young","youth","zebra","zero","zone","zoo"]
33617 </script>
33618 <script>
33619 /*
33620 * Copyright (c) 2013 Pavol Rusnak
33621 *
33622 * Permission is hereby granted, free of charge, to any person obtaining a copy of
33623 * this software and associated documentation files (the "Software"), to deal in
33624 * the Software without restriction, including without limitation the rights to
33625 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
33626 * of the Software, and to permit persons to whom the Software is furnished to do
33627 * so, subject to the following conditions:
33628 *
33629 * The above copyright notice and this permission notice shall be included in all
33630 * copies or substantial portions of the Software.
33631 *
33632 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33633 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33634 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33635 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33636 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33637 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33638 */
33639
33640 /*
33641 * Javascript port from python by Ian Coleman
33642 *
33643 * Requires code from sjcl
33644 * https://github.com/bitwiseshiftleft/sjcl
33645 */
33646
33647 var Mnemonic = function(language) {
33648
33649 var PBKDF2_ROUNDS = 2048;
33650 var RADIX = 2048;
33651
33652 var self = this;
33653 var wordlist = [];
33654
33655 var hmacSHA512 = function(key) {
33656 var hasher = new sjcl.misc.hmac(key, sjcl.hash.sha512);
33657 this.encrypt = function() {
33658 return hasher.encrypt.apply(hasher, arguments);
33659 };
33660 };
33661
33662 function init() {
33663 wordlist = WORDLISTS[language];
33664 if (wordlist.length != RADIX) {
33665 err = 'Wordlist should contain ' + RADIX + ' words, but it contains ' + wordlist.length + ' words.';
33666 throw err;
33667 }
33668 }
33669
33670 self.generate = function(strength) {
33671 strength = strength || 128;
33672 var r = strength % 32;
33673 if (r > 0) {
33674 throw 'Strength should be divisible by 32, but it is not (' + r + ').';
33675 }
33676 var hasStrongCrypto = 'crypto' in window && window['crypto'] !== null;
33677 if (!hasStrongCrypto) {
33678 throw 'Mnemonic should be generated with strong randomness, but crypto.getRandomValues is unavailable';
33679 }
33680 var buffer = new Uint8Array(strength / 8);
33681 var data = crypto.getRandomValues(buffer);
33682 return self.toMnemonic(data);
33683 }
33684
33685 self.toMnemonic = function(byteArray) {
33686 if (byteArray.length % 4 > 0) {
33687 throw 'Data length in bits should be divisible by 32, but it is not (' + byteArray.length + ' bytes = ' + byteArray.length*8 + ' bits).'
33688 }
33689
33690 //h = hashlib.sha256(data).hexdigest()
33691 var data = byteArrayToWordArray(byteArray);
33692 var hash = sjcl.hash.sha256.hash(data);
33693 var h = sjcl.codec.hex.fromBits(hash);
33694
33695 // b is a binary string, eg '00111010101100...'
33696 //b = bin(int(binascii.hexlify(data), 16))[2:].zfill(len(data) * 8) + \
33697 // bin(int(h, 16))[2:].zfill(256)[:len(data) * 8 / 32]
33698 //
33699 // a = bin(int(binascii.hexlify(data), 16))[2:].zfill(len(data) * 8)
33700 // c = bin(int(h, 16))[2:].zfill(256)
33701 // d = c[:len(data) * 8 / 32]
33702 var a = byteArrayToBinaryString(byteArray);
33703 var c = zfill(hexStringToBinaryString(h), 256);
33704 var d = c.substring(0, byteArray.length * 8 / 32);
33705 // b = line1 + line2
33706 var b = a + d;
33707
33708 var result = [];
33709 var blen = b.length / 11;
33710 for (var i=0; i<blen; i++) {
33711 var idx = parseInt(b.substring(i * 11, (i + 1) * 11), 2);
33712 result.push(wordlist[idx]);
33713 }
33714 return result.join(' ');
33715 }
33716
33717 self.check = function(mnemonic) {
33718 var mnemonic = mnemonic.split(' ')
33719 if (mnemonic.length % 3 > 0) {
33720 return false
33721 }
33722 // idx = map(lambda x: bin(self.wordlist.index(x))[2:].zfill(11), mnemonic)
33723 var idx = [];
33724 for (var i=0; i<mnemonic.length; i++) {
33725 var word = mnemonic[i];
33726 var wordIndex = wordlist.indexOf(word);
33727 if (wordIndex == -1) {
33728 return false;
33729 }
33730 var binaryIndex = zfill(wordIndex.toString(2), 11);
33731 idx.push(binaryIndex);
33732 }
33733 var b = idx.join('');
33734 var l = b.length;
33735 //d = b[:l / 33 * 32]
33736 //h = b[-l / 33:]
33737 var d = b.substring(0, l / 33 * 32);
33738 var h = b.substring(l - l / 33, l);
33739 //nd = binascii.unhexlify(hex(int(d, 2))[2:].rstrip('L').zfill(l / 33 * 8))
33740 var nd = binaryStringToWordArray(d);
33741 //nh = bin(int(hashlib.sha256(nd).hexdigest(), 16))[2:].zfill(256)[:l / 33]
33742 var ndHash = sjcl.hash.sha256.hash(nd);
33743 var ndHex = sjcl.codec.hex.fromBits(ndHash);
33744 var ndBstr = zfill(hexStringToBinaryString(ndHex), 256);
33745 var nh = ndBstr.substring(0,l/33);
33746 return h == nh;
33747 }
33748
33749 self.toSeed = function(mnemonic, passphrase) {
33750 passphrase = passphrase || '';
33751 mnemonic = self.normalizeString(mnemonic)
33752 passphrase = self.normalizeString(passphrase)
33753 passphrase = "mnemonic" + passphrase;
33754 var mnemonicBits = sjcl.codec.utf8String.toBits(mnemonic);
33755 var passphraseBits = sjcl.codec.utf8String.toBits(passphrase);
33756 var result = sjcl.misc.pbkdf2(mnemonicBits, passphraseBits, PBKDF2_ROUNDS, 512, hmacSHA512);
33757 var hashHex = sjcl.codec.hex.fromBits(result);
33758 return hashHex;
33759 }
33760
33761 self.normalizeString = function(str) {
33762 if (typeof str.normalize == "function") {
33763 return str.normalize("NFKD");
33764 }
33765 else {
33766 // TODO decide how to handle this in the future.
33767 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
33768 return str;
33769 }
33770 }
33771
33772 function byteArrayToWordArray(data) {
33773 var a = [];
33774 for (var i=0; i<data.length/4; i++) {
33775 v = 0;
33776 v += data[i*4 + 0] << 8 * 3;
33777 v += data[i*4 + 1] << 8 * 2;
33778 v += data[i*4 + 2] << 8 * 1;
33779 v += data[i*4 + 3] << 8 * 0;
33780 a.push(v);
33781 }
33782 return a;
33783 }
33784
33785 function byteArrayToBinaryString(data) {
33786 var bin = "";
33787 for (var i=0; i<data.length; i++) {
33788 bin += zfill(data[i].toString(2), 8);
33789 }
33790 return bin;
33791 }
33792
33793 function hexStringToBinaryString(hexString) {
33794 binaryString = "";
33795 for (var i=0; i<hexString.length; i++) {
33796 binaryString += zfill(parseInt(hexString[i], 16).toString(2),4);
33797 }
33798 return binaryString;
33799 }
33800
33801 function binaryStringToWordArray(binary) {
33802 var aLen = binary.length / 32;
33803 var a = [];
33804 for (var i=0; i<aLen; i++) {
33805 var valueStr = binary.substring(0,32);
33806 var value = parseInt(valueStr, 2);
33807 a.push(value);
33808 binary = binary.slice(32);
33809 }
33810 return a;
33811 }
33812
33813 // Pad a numeric string on the left with zero digits until the given width
33814 // is reached.
33815 // Note this differs to the python implementation because it does not
33816 // handle numbers starting with a sign.
33817 function zfill(source, length) {
33818 source = source.toString();
33819 while (source.length < length) {
33820 source = '0' + source;
33821 }
33822 return source;
33823 }
33824
33825 init();
33826
33827 }
33828 </script>
33829 <script>
33830 (function() {
33831
33832 var mnemonic = new Mnemonic("english");
33833 var bip32RootKey = null;
33834 var bip32ExtendedKey = null;
33835 var network = Bitcoin.networks.bitcoin;
33836 var addressRowTemplate = $("#address-row-template");
33837
33838 var showIndex = true;
33839 var showAddress = true;
33840 var showPrivKey = true;
33841
33842 var phraseChangeTimeoutEvent = null;
33843
33844 var DOM = {};
33845 DOM.network = $(".network");
33846 DOM.phraseNetwork = $("#network-phrase");
33847 DOM.bip44Network = $("#network-bip44");
33848 DOM.phrase = $(".phrase");
33849 DOM.passphrase = $(".passphrase");
33850 DOM.generate = $(".generate");
33851 DOM.rootKey = $(".root-key");
33852 DOM.extendedPrivKey = $(".extended-priv-key");
33853 DOM.extendedPubKey = $(".extended-pub-key");
33854 DOM.bip32tab = $("#bip32-tab");
33855 DOM.bip44tab = $("#bip44-tab");
33856 DOM.bip32panel = $("#bip32");
33857 DOM.bip44panel = $("#bip44");
33858 DOM.bip32path = $("#bip32-path");
33859 DOM.bip44path = $("#bip44-path");
33860 DOM.bip44purpose = $("#bip44 .purpose");
33861 DOM.bip44coin = $("#bip44 .coin");
33862 DOM.bip44account = $("#bip44 .account");
33863 DOM.bip44change = $("#bip44 .change");
33864 DOM.strength = $(".strength");
33865 DOM.addresses = $(".addresses");
33866 DOM.rowsToAdd = $(".rows-to-add");
33867 DOM.more = $(".more");
33868 DOM.feedback = $(".feedback");
33869 DOM.tab = $(".derivation-type a");
33870 DOM.indexToggle = $(".index-toggle");
33871 DOM.addressToggle = $(".address-toggle");
33872 DOM.privateKeyToggle = $(".private-key-toggle");
33873
33874 var derivationPath = DOM.bip44path.val();
33875
33876 function init() {
33877 // Events
33878 DOM.network.on("change", networkChanged);
33879 DOM.phrase.on("input", delayedPhraseChanged);
33880 DOM.passphrase.on("input", delayedPhraseChanged);
33881 DOM.generate.on("click", generateClicked);
33882 DOM.more.on("click", showMore);
33883 DOM.bip32path.on("input", bip32Changed);
33884 DOM.bip44purpose.on("input", bip44Changed);
33885 DOM.bip44coin.on("input", bip44Changed);
33886 DOM.bip44account.on("input", bip44Changed);
33887 DOM.bip44change.on("input", bip44Changed);
33888 DOM.tab.on("click", tabClicked);
33889 DOM.indexToggle.on("click", toggleIndexes);
33890 DOM.addressToggle.on("click", toggleAddresses);
33891 DOM.privateKeyToggle.on("click", togglePrivateKeys);
33892 disableForms();
33893 hidePending();
33894 hideValidationError();
33895 }
33896
33897 // Event handlers
33898
33899 function networkChanged(e) {
33900 var n = e.target.value;
33901 if (n == "bitcoin") {
33902 network = Bitcoin.networks.bitcoin;
33903 DOM.bip44coin.val(0);
33904 setBip44DerivationPath();
33905 enableBip44Tab();
33906 }
33907 else if (n == "bitcoin-testnet") {
33908 network = Bitcoin.networks.testnet;
33909 DOM.bip44coin.val(1);
33910 setBip44DerivationPath();
33911 enableBip44Tab();
33912 }
33913 else if (n == "litecoin") {
33914 network = Bitcoin.networks.litecoin;
33915 DOM.bip44coin.val(2);
33916 setBip44DerivationPath();
33917 enableBip44Tab();
33918 }
33919 else if (n == "dogecoin") {
33920 network = Bitcoin.networks.dogecoin;
33921 disableBip44Tab();
33922 }
33923 DOM.phraseNetwork.val(n);
33924 DOM.bip44Network.val(n);
33925 delayedPhraseChanged();
33926 }
33927
33928 function delayedPhraseChanged() {
33929 hideValidationError();
33930 showPending();
33931 if (phraseChangeTimeoutEvent != null) {
33932 clearTimeout(phraseChangeTimeoutEvent);
33933 }
33934 phraseChangeTimeoutEvent = setTimeout(phraseChanged, 400);
33935 }
33936
33937 function phraseChanged() {
33938 showPending();
33939 hideValidationError();
33940 // Get the mnemonic phrase
33941 var phrase = DOM.phrase.val();
33942 var passphrase = DOM.passphrase.val();
33943 var errorText = findPhraseErrors(phrase);
33944 if (errorText) {
33945 showValidationError(errorText);
33946 return;
33947 }
33948 // Get the derivation path
33949 var errorText = findDerivationPathErrors();
33950 if (errorText) {
33951 showValidationError(errorText);
33952 return;
33953 }
33954 // Calculate and display
33955 calcBip32Seed(phrase, passphrase, derivationPath);
33956 displayBip32Info();
33957 hidePending();
33958 }
33959
33960 function generateClicked() {
33961 clearDisplay();
33962 showPending();
33963 setTimeout(function() {
33964 var phrase = generateRandomPhrase();
33965 if (!phrase) {
33966 return;
33967 }
33968 phraseChanged();
33969 }, 50);
33970 }
33971
33972 function tabClicked(e) {
33973 var activePath = $(e.target.getAttribute("href") + " .path");
33974 derivationPath = activePath.val();
33975 derivationChanged();
33976 }
33977
33978 function derivationChanged() {
33979 delayedPhraseChanged();
33980 }
33981
33982 function bip32Changed() {
33983 derivationPath = DOM.bip32path.val();
33984 derivationChanged();
33985 }
33986
33987 function bip44Changed() {
33988 setBip44DerivationPath();
33989 derivationPath = DOM.bip44path.val();
33990 derivationChanged();
33991 }
33992
33993 function toggleIndexes() {
33994 showIndex = !showIndex;
33995 $("td.index span").toggleClass("invisible");
33996 }
33997
33998 function toggleAddresses() {
33999 showAddress = !showAddress;
34000 $("td.address span").toggleClass("invisible");
34001 }
34002
34003 function togglePrivateKeys() {
34004 showPrivKey = !showPrivKey;
34005 $("td.privkey span").toggleClass("invisible");
34006 }
34007
34008 // Private methods
34009
34010 function generateRandomPhrase() {
34011 if (!hasStrongRandom()) {
34012 var errorText = "This browser does not support strong randomness";
34013 showValidationError(errorText);
34014 return;
34015 }
34016 var numWords = parseInt(DOM.strength.val());
34017 // Check strength is an integer
34018 if (isNaN(numWords)) {
34019 DOM.strength.val("12");
34020 numWords = 12;
34021 }
34022 // Check strength is a multiple of 32, if not round it down
34023 if (numWords % 3 != 0) {
34024 numWords = Math.floor(numWords / 3) * 3;
34025 DOM.strength.val(numWords);
34026 }
34027 // Check strength is at least 32
34028 if (numWords == 0) {
34029 numWords = 3;
34030 DOM.strength.val(numWords);
34031 }
34032 var strength = numWords / 3 * 32;
34033 var words = mnemonic.generate(strength);
34034 DOM.phrase.val(words);
34035 return words;
34036 }
34037
34038 function calcBip32Seed(phrase, passphrase, path) {
34039 var seed = mnemonic.toSeed(phrase, passphrase);
34040 bip32RootKey = Bitcoin.HDNode.fromSeedHex(seed, network);
34041 bip32ExtendedKey = bip32RootKey;
34042 // Derive the key from the path
34043 var pathBits = path.split("/");
34044 for (var i=0; i<pathBits.length; i++) {
34045 var bit = pathBits[i];
34046 var index = parseInt(bit);
34047 if (isNaN(index)) {
34048 continue;
34049 }
34050 var hardened = bit[bit.length-1] == "'";
34051 if (hardened) {
34052 bip32ExtendedKey = bip32ExtendedKey.deriveHardened(index);
34053 }
34054 else {
34055 bip32ExtendedKey = bip32ExtendedKey.derive(index);
34056 }
34057 }
34058 }
34059
34060 function showValidationError(errorText) {
34061 DOM.feedback
34062 .text(errorText)
34063 .show();
34064 }
34065
34066 function hideValidationError() {
34067 DOM.feedback
34068 .text("")
34069 .hide();
34070 }
34071
34072 function findPhraseErrors(phrase) {
34073 // TODO make this right
34074 // Preprocess the words
34075 phrase = mnemonic.normalizeString(phrase);
34076 var parts = phrase.split(" ");
34077 var proper = [];
34078 for (var i=0; i<parts.length; i++) {
34079 var part = parts[i];
34080 if (part.length > 0) {
34081 // TODO check that lowercasing is always valid to do
34082 proper.push(part.toLowerCase());
34083 }
34084 }
34085 // TODO some levenstein on the words
34086 var properPhrase = proper.join(' ');
34087 // Check the words are valid
34088 var isValid = mnemonic.check(properPhrase);
34089 if (!isValid) {
34090 return "Invalid mnemonic";
34091 }
34092 return false;
34093 }
34094
34095 function findDerivationPathErrors(path) {
34096 // TODO
34097 return false;
34098 }
34099
34100 function displayBip32Info() {
34101 // Display the key
34102 var rootKey = bip32RootKey.toBase58();
34103 DOM.rootKey.val(rootKey);
34104 var extendedPrivKey = bip32ExtendedKey.toBase58();
34105 DOM.extendedPrivKey.val(extendedPrivKey);
34106 var extendedPubKey = bip32ExtendedKey.toBase58(false);
34107 DOM.extendedPubKey.val(extendedPubKey);
34108 // Display the addresses and privkeys
34109 clearAddressesList();
34110 displayAddresses(0, 20);
34111 }
34112
34113 function displayAddresses(start, total) {
34114 for (var i=0; i<total; i++) {
34115 var index = i + start;
34116 new TableRow(index);
34117 }
34118 }
34119
34120 function TableRow(index) {
34121
34122 function init() {
34123 calculateValues();
34124 }
34125
34126 function calculateValues() {
34127 setTimeout(function() {
34128 var key = bip32ExtendedKey.derive(index);
34129 var address = key.getAddress().toString();
34130 var privkey = key.privKey.toWIF(network);
34131 addAddressToList(index, address, privkey);
34132 }, 50)
34133 }
34134
34135 init();
34136
34137 }
34138
34139 function showMore() {
34140 var start = DOM.addresses.children().length;
34141 var rowsToAdd = parseInt(DOM.rowsToAdd.val());
34142 if (isNaN(rowsToAdd)) {
34143 rowsToAdd = 20;
34144 DOM.rowsToAdd.val("20");
34145 }
34146 if (rowsToAdd > 200) {
34147 var msg = "Generating " + rowsToAdd + " rows could take a while. ";
34148 msg += "Do you want to continue?";
34149 if (!confirm(msg)) {
34150 return;
34151 }
34152 }
34153 displayAddresses(start, rowsToAdd);
34154 }
34155
34156 function clearDisplay() {
34157 clearAddressesList();
34158 clearKey();
34159 hideValidationError();
34160 }
34161
34162 function clearAddressesList() {
34163 DOM.addresses.empty();
34164 }
34165
34166 function clearKey() {
34167 DOM.rootKey.val("");
34168 DOM.extendedPrivKey.val("");
34169 DOM.extendedPubKey.val("");
34170 }
34171
34172 function addAddressToList(index, address, privkey) {
34173 var row = $(addressRowTemplate.html());
34174 // Elements
34175 var indexCell = row.find(".index span");
34176 var addressCell = row.find(".address span");
34177 var privkeyCell = row.find(".privkey span");
34178 // Content
34179 indexCell.text(index);
34180 addressCell.text(address);
34181 privkeyCell.text(privkey);
34182 // Visibility
34183 if (!showIndex) {
34184 indexCell.addClass("invisible");
34185 }
34186 if (!showAddress) {
34187 addressCell.addClass("invisible");
34188 }
34189 if (!showPrivKey) {
34190 privkeCell.addClass("invisible");
34191 }
34192 DOM.addresses.append(row);
34193 }
34194
34195 function hasStrongRandom() {
34196 return 'crypto' in window && window['crypto'] !== null;
34197 }
34198
34199 function disableForms() {
34200 $("form").on("submit", function(e) {
34201 e.preventDefault();
34202 });
34203 }
34204
34205 function setBip44DerivationPath() {
34206 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
34207 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
34208 var account = parseIntNoNaN(DOM.bip44account.val(), 0);
34209 var change = parseIntNoNaN(DOM.bip44change.val(), 0);
34210 var path = "m/";
34211 path += purpose + "'/";
34212 path += coin + "'/";
34213 path += account + "'/";
34214 path += change;
34215 DOM.bip44path.val(path);
34216 }
34217
34218 function parseIntNoNaN(val, defaultVal) {
34219 var v = parseInt(val);
34220 if (isNaN(v)) {
34221 return defaultVal;
34222 }
34223 return v;
34224 }
34225
34226 function showPending() {
34227 DOM.feedback
34228 .text("Calculating...")
34229 .show();
34230 }
34231
34232 function hidePending() {
34233 DOM.feedback
34234 .text("")
34235 .hide();
34236 }
34237
34238 function enableBip44Tab() {
34239 // show bip44 tab (but don't select it)
34240 DOM.bip44tab.removeClass("hidden");
34241 DOM.bip44panel.removeClass("hidden");
34242 }
34243
34244 function disableBip44Tab() {
34245 // hide bip44 tab
34246 DOM.bip44tab.addClass("hidden");
34247 DOM.bip44tab.removeClass("active");
34248 // hide bip44 panel
34249 DOM.bip44panel.addClass("hidden");
34250 DOM.bip44panel.removeClass("active");
34251 // show bip32 tab
34252 DOM.bip32tab.addClass("active");
34253 // show bip32 panel
34254 DOM.bip32panel.addClass("active");
34255 // set the derivation path
34256 var activePath = $("#bip32 .path");
34257 derivationPath = activePath.val();
34258 }
34259
34260 init();
34261
34262 })();
34263 </script>
34264 </body>
34265 </html>