]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blob - bip39-standalone.html
Unsupported coins removed
[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 class="active">
6309 <a href="#bip44" role="tab" data-toggle="tab">BIP44</a></li>
6310 <li><a href="#bip32" role="tab" data-toggle="tab">BIP32</a></li>
6311 </ul>
6312 <div class="derivation-type tab-content">
6313 <div id="bip44" class="tab-pane active">
6314 <form class="form-horizontal" role="form">
6315 <br>
6316 <div class="col-sm-2"></div>
6317 <div class="col-sm-10">
6318 <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">BIP44 spec</a></p>
6319 </div>
6320 <div class="form-group">
6321 <label for="network-bip44" class="col-sm-2 control-label">Coin</label>
6322 <div class="col-sm-10">
6323 <select id="network-bip44" class="network form-control">
6324 <option value="bitcoin">Bitcoin</option>
6325 <option value="bitcoin-testnet">Bitcoin Testnet</option>
6326 <option value="litecoin">Litecoin</option>
6327 </select>
6328 </div>
6329 </div>
6330 <div class="form-group">
6331 <label for="purpose" class="col-sm-2 control-label">
6332 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#purpose" target="_blank">Purpose</a>
6333 </label>
6334 <div class="col-sm-10">
6335 <input id="purpose" type="text" class="purpose form-control" value="44">
6336 </div>
6337 </div>
6338 <div class="form-group">
6339 <label for="coin" class="col-sm-2 control-label">
6340 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#registered-coin-types" target="_blank">Coin</a>
6341 </label>
6342 <div class="col-sm-10">
6343 <input id="coin" type="text" class="coin form-control" value="0">
6344 </div>
6345 </div>
6346 <div class="form-group">
6347 <label for="account" class="col-sm-2 control-label">
6348 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account" target="_blank">Account</a>
6349 </label>
6350 <div class="col-sm-10">
6351 <input id="account" type="text" class="account form-control" value="0">
6352 </div>
6353 </div>
6354 <div class="form-group">
6355 <label for="change" class="col-sm-2 control-label">
6356 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target="_blank">External / Internal</a>
6357 </label>
6358 <div class="col-sm-10">
6359 <input id="change" type="text" class="change form-control" value="0">
6360 </div>
6361 </div>
6362 <div class="form-group">
6363 <label for="bip44-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
6364 <div class="col-sm-10">
6365 <input id="bip44-path" type="text" class="path form-control" value="m/44'/0'/0'/0" readonly="readonly">
6366 </div>
6367 </div>
6368 </form>
6369 </div>
6370 <div id="bip32" class="tab-pane">
6371 <form class="form-horizontal" role="form">
6372 <br>
6373 <div class="col-sm-2"></div>
6374 <div class="col-sm-10">
6375 <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">BIP32 spec</a></p>
6376 </div>
6377 <div class="form-group">
6378 <label for="bip32-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
6379 <div class="col-sm-10">
6380 <input id="bip32-path" type="text" class="path form-control" value="m/0">
6381 </div>
6382 </div>
6383 </form>
6384 </div>
6385 </div>
6386 <form class="form-horizontal" role="form">
6387 <div class="form-group">
6388 <label for="extended-priv-key" class="col-sm-2 control-label">BIP32 Extended Key</label>
6389 <div class="col-sm-10">
6390 <textarea id="extended-priv-key" class="extended-priv-key form-control" readonly="readonly"></textarea>
6391 </div>
6392 </div>
6393 <div class="form-group">
6394 <label for="extended-pub-key" class="col-sm-2 control-label">BIP32 Extended Key (addresses only)</label>
6395 <div class="col-sm-10">
6396 <textarea id="extended-pub-key" class="extended-pub-key form-control" readonly="readonly"></textarea>
6397 </div>
6398 </div>
6399 </form>
6400 </div>
6401 </div>
6402
6403 <hr>
6404
6405 <div class="row">
6406 <div class="col-md-12">
6407 <h2>Derived Addresses</h2>
6408 <p>Note these addreses are derived from the <strong>BIP32 Extended Key</strong></p>
6409 <table class="table table-striped">
6410 <thead>
6411 <th>
6412 <div class="input-group">
6413 Index&nbsp;&nbsp;
6414 <button class="index-toggle">Toggle</button>
6415 </div>
6416 </th>
6417 <th>
6418 <div class="input-group">
6419 Address&nbsp;&nbsp;
6420 <button class="address-toggle">Toggle</button>
6421 </div>
6422 </th>
6423 <th>
6424 <div class="input-group">
6425 Private Key&nbsp;&nbsp;
6426 <button class="private-key-toggle">Toggle</button>
6427 </div>
6428 </th>
6429 </thead>
6430 <tbody class="addresses">
6431 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6432 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6433 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
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 </tbody>
6437 </table>
6438 </div>
6439 </div>
6440 <span>Show next </button>
6441 <input type="number" class="rows-to-add" value="20">
6442 <button class="more">Show</button>
6443
6444 <hr>
6445
6446 <div class="row">
6447 <div class="col-md-12">
6448 <h2>More info</h2>
6449 <h3>BIP39 <span class="small">Mnemonic code for generating deterministic keys</span></h3>
6450 <p>
6451 Read more at the
6452 <a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki">official BIP39 spec</a>
6453 </p>
6454 <h3>BIP32 <span class="small">Hierarchical Deterministic Wallets</span></h3>
6455 <p>
6456 Read more at the
6457 <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">official BIP32 spec</a>
6458 and see the demo at
6459 <a href="http://bip32.org/" target="_blank">bip32.org</a>
6460 </p>
6461 <h3>BIP44 <span class="small">Multi-Account Hierarchy for Deterministic Wallets</span></h3>
6462 <p>
6463 Read more at the
6464 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">official BIP44 spec</a>
6465 </p>
6466 <h3>Private Keys</h3>
6467 <p>
6468 Use private keys at
6469 <a href="https://brainwallet.github.io/" target="_blank">brainwallet.org</a>,
6470 but be careful - it can be easy to make mistakes if you
6471 don't know what you're doing
6472 </p>
6473 </div>
6474 </div>
6475
6476 <hr>
6477
6478 <div class="row">
6479 <div class="col-md-12">
6480
6481 <h2>Offline Usage</h2>
6482
6483 <p>
6484 You can use this tool without having to be online.
6485 </p>
6486 <p>
6487 In your browser, select file save-as, and save this page
6488 as a file.
6489 </p>
6490 <p>
6491 Double-click that file to open it in a browser
6492 on any offline computer.
6493 </p>
6494 <p>
6495 Alternatively, download it from
6496 <a href="https://github.com/dcpos/bip39">
6497 https://github.com/dcpos/bip39
6498 </a>
6499
6500 </div>
6501 </div>
6502
6503 <hr>
6504
6505 <div class="row">
6506 <div class="col-md-12">
6507
6508 <h2>This project is 100% open-source code</h2>
6509
6510 <p>
6511 <span>Get the source code at - </span>
6512 <a href="https://github.com/dcpos/bip39" target="_blank">
6513 https://github.com/dcpos/bip39
6514 </a>
6515 </p>
6516
6517 <h3>Libraries</h3>
6518
6519 <p>
6520 <span>BitcoinJS - </span>
6521 <a href="https://github.com/bitcoinjs/bitcoinjs-lib" target="_blank">
6522 https://github.com/bitcoinjs/bitcoinjs-lib
6523 </a>
6524 </p>
6525
6526 <p>
6527 <span>jsBIP39 - </span>
6528 <a href="https://github.com/iancoleman/jsbip39" target="_blank">
6529 https://github.com/iancoleman/jsbip39
6530 </a>
6531 </p>
6532
6533 <p>
6534 <span>sjcl - </span>
6535 <a href="https://github.com/bitwiseshiftleft/sjcl" target="_blank">
6536 https://github.com/bitwiseshiftleft/sjcl
6537 </a>
6538 </p>
6539
6540 <p>
6541 <span>jQuery - </span>
6542 <a href="https://jquery.com/" target="_blank">
6543 https://jquery.com/
6544 </a>
6545 </p>
6546
6547 <p>
6548 <span>Twitter Bootstrap - </span>
6549 <a href="http://getbootstrap.com/" target="_blank">
6550 http://getbootstrap.com/
6551 </a>
6552 </p>
6553
6554 </div>
6555 </div>
6556
6557 </div>
6558
6559 <div class="feedback-container">
6560 <div class="feedback">Loading...</div>
6561 </div>
6562
6563 <script type="text/template" id="address-row-template">
6564 <tr>
6565 <td class="index"><span></span></td>
6566 <td class="address"><span></span></td>
6567 <td class="privkey"><span></span></td>
6568 </tr>
6569 </script>
6570 <script>
6571 /*!
6572 * jQuery JavaScript Library v2.1.1
6573 * http://jquery.com/
6574 *
6575 * Includes Sizzle.js
6576 * http://sizzlejs.com/
6577 *
6578 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
6579 * Released under the MIT license
6580 * http://jquery.org/license
6581 *
6582 * Date: 2014-05-01T17:11Z
6583 */
6584
6585 (function( global, factory ) {
6586
6587 if ( typeof module === "object" && typeof module.exports === "object" ) {
6588 // For CommonJS and CommonJS-like environments where a proper window is present,
6589 // execute the factory and get jQuery
6590 // For environments that do not inherently posses a window with a document
6591 // (such as Node.js), expose a jQuery-making factory as module.exports
6592 // This accentuates the need for the creation of a real window
6593 // e.g. var jQuery = require("jquery")(window);
6594 // See ticket #14549 for more info
6595 module.exports = global.document ?
6596 factory( global, true ) :
6597 function( w ) {
6598 if ( !w.document ) {
6599 throw new Error( "jQuery requires a window with a document" );
6600 }
6601 return factory( w );
6602 };
6603 } else {
6604 factory( global );
6605 }
6606
6607 // Pass this if window is not defined yet
6608 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
6609
6610 // Can't do this because several apps including ASP.NET trace
6611 // the stack via arguments.caller.callee and Firefox dies if
6612 // you try to trace through "use strict" call chains. (#13335)
6613 // Support: Firefox 18+
6614 //
6615
6616 var arr = [];
6617
6618 var slice = arr.slice;
6619
6620 var concat = arr.concat;
6621
6622 var push = arr.push;
6623
6624 var indexOf = arr.indexOf;
6625
6626 var class2type = {};
6627
6628 var toString = class2type.toString;
6629
6630 var hasOwn = class2type.hasOwnProperty;
6631
6632 var support = {};
6633
6634
6635
6636 var
6637 // Use the correct document accordingly with window argument (sandbox)
6638 document = window.document,
6639
6640 version = "2.1.1",
6641
6642 // Define a local copy of jQuery
6643 jQuery = function( selector, context ) {
6644 // The jQuery object is actually just the init constructor 'enhanced'
6645 // Need init if jQuery is called (just allow error to be thrown if not included)
6646 return new jQuery.fn.init( selector, context );
6647 },
6648
6649 // Support: Android<4.1
6650 // Make sure we trim BOM and NBSP
6651 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
6652
6653 // Matches dashed string for camelizing
6654 rmsPrefix = /^-ms-/,
6655 rdashAlpha = /-([\da-z])/gi,
6656
6657 // Used by jQuery.camelCase as callback to replace()
6658 fcamelCase = function( all, letter ) {
6659 return letter.toUpperCase();
6660 };
6661
6662 jQuery.fn = jQuery.prototype = {
6663 // The current version of jQuery being used
6664 jquery: version,
6665
6666 constructor: jQuery,
6667
6668 // Start with an empty selector
6669 selector: "",
6670
6671 // The default length of a jQuery object is 0
6672 length: 0,
6673
6674 toArray: function() {
6675 return slice.call( this );
6676 },
6677
6678 // Get the Nth element in the matched element set OR
6679 // Get the whole matched element set as a clean array
6680 get: function( num ) {
6681 return num != null ?
6682
6683 // Return just the one element from the set
6684 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
6685
6686 // Return all the elements in a clean array
6687 slice.call( this );
6688 },
6689
6690 // Take an array of elements and push it onto the stack
6691 // (returning the new matched element set)
6692 pushStack: function( elems ) {
6693
6694 // Build a new jQuery matched element set
6695 var ret = jQuery.merge( this.constructor(), elems );
6696
6697 // Add the old object onto the stack (as a reference)
6698 ret.prevObject = this;
6699 ret.context = this.context;
6700
6701 // Return the newly-formed element set
6702 return ret;
6703 },
6704
6705 // Execute a callback for every element in the matched set.
6706 // (You can seed the arguments with an array of args, but this is
6707 // only used internally.)
6708 each: function( callback, args ) {
6709 return jQuery.each( this, callback, args );
6710 },
6711
6712 map: function( callback ) {
6713 return this.pushStack( jQuery.map(this, function( elem, i ) {
6714 return callback.call( elem, i, elem );
6715 }));
6716 },
6717
6718 slice: function() {
6719 return this.pushStack( slice.apply( this, arguments ) );
6720 },
6721
6722 first: function() {
6723 return this.eq( 0 );
6724 },
6725
6726 last: function() {
6727 return this.eq( -1 );
6728 },
6729
6730 eq: function( i ) {
6731 var len = this.length,
6732 j = +i + ( i < 0 ? len : 0 );
6733 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
6734 },
6735
6736 end: function() {
6737 return this.prevObject || this.constructor(null);
6738 },
6739
6740 // For internal use only.
6741 // Behaves like an Array's method, not like a jQuery method.
6742 push: push,
6743 sort: arr.sort,
6744 splice: arr.splice
6745 };
6746
6747 jQuery.extend = jQuery.fn.extend = function() {
6748 var options, name, src, copy, copyIsArray, clone,
6749 target = arguments[0] || {},
6750 i = 1,
6751 length = arguments.length,
6752 deep = false;
6753
6754 // Handle a deep copy situation
6755 if ( typeof target === "boolean" ) {
6756 deep = target;
6757
6758 // skip the boolean and the target
6759 target = arguments[ i ] || {};
6760 i++;
6761 }
6762
6763 // Handle case when target is a string or something (possible in deep copy)
6764 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
6765 target = {};
6766 }
6767
6768 // extend jQuery itself if only one argument is passed
6769 if ( i === length ) {
6770 target = this;
6771 i--;
6772 }
6773
6774 for ( ; i < length; i++ ) {
6775 // Only deal with non-null/undefined values
6776 if ( (options = arguments[ i ]) != null ) {
6777 // Extend the base object
6778 for ( name in options ) {
6779 src = target[ name ];
6780 copy = options[ name ];
6781
6782 // Prevent never-ending loop
6783 if ( target === copy ) {
6784 continue;
6785 }
6786
6787 // Recurse if we're merging plain objects or arrays
6788 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
6789 if ( copyIsArray ) {
6790 copyIsArray = false;
6791 clone = src && jQuery.isArray(src) ? src : [];
6792
6793 } else {
6794 clone = src && jQuery.isPlainObject(src) ? src : {};
6795 }
6796
6797 // Never move original objects, clone them
6798 target[ name ] = jQuery.extend( deep, clone, copy );
6799
6800 // Don't bring in undefined values
6801 } else if ( copy !== undefined ) {
6802 target[ name ] = copy;
6803 }
6804 }
6805 }
6806 }
6807
6808 // Return the modified object
6809 return target;
6810 };
6811
6812 jQuery.extend({
6813 // Unique for each copy of jQuery on the page
6814 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
6815
6816 // Assume jQuery is ready without the ready module
6817 isReady: true,
6818
6819 error: function( msg ) {
6820 throw new Error( msg );
6821 },
6822
6823 noop: function() {},
6824
6825 // See test/unit/core.js for details concerning isFunction.
6826 // Since version 1.3, DOM methods and functions like alert
6827 // aren't supported. They return false on IE (#2968).
6828 isFunction: function( obj ) {
6829 return jQuery.type(obj) === "function";
6830 },
6831
6832 isArray: Array.isArray,
6833
6834 isWindow: function( obj ) {
6835 return obj != null && obj === obj.window;
6836 },
6837
6838 isNumeric: function( obj ) {
6839 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
6840 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
6841 // subtraction forces infinities to NaN
6842 return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0;
6843 },
6844
6845 isPlainObject: function( obj ) {
6846 // Not plain objects:
6847 // - Any object or value whose internal [[Class]] property is not "[object Object]"
6848 // - DOM nodes
6849 // - window
6850 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
6851 return false;
6852 }
6853
6854 if ( obj.constructor &&
6855 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
6856 return false;
6857 }
6858
6859 // If the function hasn't returned already, we're confident that
6860 // |obj| is a plain object, created by {} or constructed with new Object
6861 return true;
6862 },
6863
6864 isEmptyObject: function( obj ) {
6865 var name;
6866 for ( name in obj ) {
6867 return false;
6868 }
6869 return true;
6870 },
6871
6872 type: function( obj ) {
6873 if ( obj == null ) {
6874 return obj + "";
6875 }
6876 // Support: Android < 4.0, iOS < 6 (functionish RegExp)
6877 return typeof obj === "object" || typeof obj === "function" ?
6878 class2type[ toString.call(obj) ] || "object" :
6879 typeof obj;
6880 },
6881
6882 // Evaluates a script in a global context
6883 globalEval: function( code ) {
6884 var script,
6885 indirect = eval;
6886
6887 code = jQuery.trim( code );
6888
6889 if ( code ) {
6890 // If the code includes a valid, prologue position
6891 // strict mode pragma, execute code by injecting a
6892 // script tag into the document.
6893 if ( code.indexOf("use strict") === 1 ) {
6894 script = document.createElement("script");
6895 script.text = code;
6896 document.head.appendChild( script ).parentNode.removeChild( script );
6897 } else {
6898 // Otherwise, avoid the DOM node creation, insertion
6899 // and removal by using an indirect global eval
6900 indirect( code );
6901 }
6902 }
6903 },
6904
6905 // Convert dashed to camelCase; used by the css and data modules
6906 // Microsoft forgot to hump their vendor prefix (#9572)
6907 camelCase: function( string ) {
6908 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
6909 },
6910
6911 nodeName: function( elem, name ) {
6912 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
6913 },
6914
6915 // args is for internal usage only
6916 each: function( obj, callback, args ) {
6917 var value,
6918 i = 0,
6919 length = obj.length,
6920 isArray = isArraylike( obj );
6921
6922 if ( args ) {
6923 if ( isArray ) {
6924 for ( ; i < length; i++ ) {
6925 value = callback.apply( obj[ i ], args );
6926
6927 if ( value === false ) {
6928 break;
6929 }
6930 }
6931 } else {
6932 for ( i in obj ) {
6933 value = callback.apply( obj[ i ], args );
6934
6935 if ( value === false ) {
6936 break;
6937 }
6938 }
6939 }
6940
6941 // A special, fast, case for the most common use of each
6942 } else {
6943 if ( isArray ) {
6944 for ( ; i < length; i++ ) {
6945 value = callback.call( obj[ i ], i, obj[ i ] );
6946
6947 if ( value === false ) {
6948 break;
6949 }
6950 }
6951 } else {
6952 for ( i in obj ) {
6953 value = callback.call( obj[ i ], i, obj[ i ] );
6954
6955 if ( value === false ) {
6956 break;
6957 }
6958 }
6959 }
6960 }
6961
6962 return obj;
6963 },
6964
6965 // Support: Android<4.1
6966 trim: function( text ) {
6967 return text == null ?
6968 "" :
6969 ( text + "" ).replace( rtrim, "" );
6970 },
6971
6972 // results is for internal usage only
6973 makeArray: function( arr, results ) {
6974 var ret = results || [];
6975
6976 if ( arr != null ) {
6977 if ( isArraylike( Object(arr) ) ) {
6978 jQuery.merge( ret,
6979 typeof arr === "string" ?
6980 [ arr ] : arr
6981 );
6982 } else {
6983 push.call( ret, arr );
6984 }
6985 }
6986
6987 return ret;
6988 },
6989
6990 inArray: function( elem, arr, i ) {
6991 return arr == null ? -1 : indexOf.call( arr, elem, i );
6992 },
6993
6994 merge: function( first, second ) {
6995 var len = +second.length,
6996 j = 0,
6997 i = first.length;
6998
6999 for ( ; j < len; j++ ) {
7000 first[ i++ ] = second[ j ];
7001 }
7002
7003 first.length = i;
7004
7005 return first;
7006 },
7007
7008 grep: function( elems, callback, invert ) {
7009 var callbackInverse,
7010 matches = [],
7011 i = 0,
7012 length = elems.length,
7013 callbackExpect = !invert;
7014
7015 // Go through the array, only saving the items
7016 // that pass the validator function
7017 for ( ; i < length; i++ ) {
7018 callbackInverse = !callback( elems[ i ], i );
7019 if ( callbackInverse !== callbackExpect ) {
7020 matches.push( elems[ i ] );
7021 }
7022 }
7023
7024 return matches;
7025 },
7026
7027 // arg is for internal usage only
7028 map: function( elems, callback, arg ) {
7029 var value,
7030 i = 0,
7031 length = elems.length,
7032 isArray = isArraylike( elems ),
7033 ret = [];
7034
7035 // Go through the array, translating each of the items to their new values
7036 if ( isArray ) {
7037 for ( ; i < length; i++ ) {
7038 value = callback( elems[ i ], i, arg );
7039
7040 if ( value != null ) {
7041 ret.push( value );
7042 }
7043 }
7044
7045 // Go through every key on the object,
7046 } else {
7047 for ( i in elems ) {
7048 value = callback( elems[ i ], i, arg );
7049
7050 if ( value != null ) {
7051 ret.push( value );
7052 }
7053 }
7054 }
7055
7056 // Flatten any nested arrays
7057 return concat.apply( [], ret );
7058 },
7059
7060 // A global GUID counter for objects
7061 guid: 1,
7062
7063 // Bind a function to a context, optionally partially applying any
7064 // arguments.
7065 proxy: function( fn, context ) {
7066 var tmp, args, proxy;
7067
7068 if ( typeof context === "string" ) {
7069 tmp = fn[ context ];
7070 context = fn;
7071 fn = tmp;
7072 }
7073
7074 // Quick check to determine if target is callable, in the spec
7075 // this throws a TypeError, but we will just return undefined.
7076 if ( !jQuery.isFunction( fn ) ) {
7077 return undefined;
7078 }
7079
7080 // Simulated bind
7081 args = slice.call( arguments, 2 );
7082 proxy = function() {
7083 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
7084 };
7085
7086 // Set the guid of unique handler to the same of original handler, so it can be removed
7087 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
7088
7089 return proxy;
7090 },
7091
7092 now: Date.now,
7093
7094 // jQuery.support is not used in Core but other projects attach their
7095 // properties to it so it needs to exist.
7096 support: support
7097 });
7098
7099 // Populate the class2type map
7100 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
7101 class2type[ "[object " + name + "]" ] = name.toLowerCase();
7102 });
7103
7104 function isArraylike( obj ) {
7105 var length = obj.length,
7106 type = jQuery.type( obj );
7107
7108 if ( type === "function" || jQuery.isWindow( obj ) ) {
7109 return false;
7110 }
7111
7112 if ( obj.nodeType === 1 && length ) {
7113 return true;
7114 }
7115
7116 return type === "array" || length === 0 ||
7117 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
7118 }
7119 var Sizzle =
7120 /*!
7121 * Sizzle CSS Selector Engine v1.10.19
7122 * http://sizzlejs.com/
7123 *
7124 * Copyright 2013 jQuery Foundation, Inc. and other contributors
7125 * Released under the MIT license
7126 * http://jquery.org/license
7127 *
7128 * Date: 2014-04-18
7129 */
7130 (function( window ) {
7131
7132 var i,
7133 support,
7134 Expr,
7135 getText,
7136 isXML,
7137 tokenize,
7138 compile,
7139 select,
7140 outermostContext,
7141 sortInput,
7142 hasDuplicate,
7143
7144 // Local document vars
7145 setDocument,
7146 document,
7147 docElem,
7148 documentIsHTML,
7149 rbuggyQSA,
7150 rbuggyMatches,
7151 matches,
7152 contains,
7153
7154 // Instance-specific data
7155 expando = "sizzle" + -(new Date()),
7156 preferredDoc = window.document,
7157 dirruns = 0,
7158 done = 0,
7159 classCache = createCache(),
7160 tokenCache = createCache(),
7161 compilerCache = createCache(),
7162 sortOrder = function( a, b ) {
7163 if ( a === b ) {
7164 hasDuplicate = true;
7165 }
7166 return 0;
7167 },
7168
7169 // General-purpose constants
7170 strundefined = typeof undefined,
7171 MAX_NEGATIVE = 1 << 31,
7172
7173 // Instance methods
7174 hasOwn = ({}).hasOwnProperty,
7175 arr = [],
7176 pop = arr.pop,
7177 push_native = arr.push,
7178 push = arr.push,
7179 slice = arr.slice,
7180 // Use a stripped-down indexOf if we can't use a native one
7181 indexOf = arr.indexOf || function( elem ) {
7182 var i = 0,
7183 len = this.length;
7184 for ( ; i < len; i++ ) {
7185 if ( this[i] === elem ) {
7186 return i;
7187 }
7188 }
7189 return -1;
7190 },
7191
7192 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
7193
7194 // Regular expressions
7195
7196 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
7197 whitespace = "[\\x20\\t\\r\\n\\f]",
7198 // http://www.w3.org/TR/css3-syntax/#characters
7199 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
7200
7201 // Loosely modeled on CSS identifier characters
7202 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
7203 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
7204 identifier = characterEncoding.replace( "w", "w#" ),
7205
7206 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
7207 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
7208 // Operator (capture 2)
7209 "*([*^$|!~]?=)" + whitespace +
7210 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
7211 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
7212 "*\\]",
7213
7214 pseudos = ":(" + characterEncoding + ")(?:\\((" +
7215 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
7216 // 1. quoted (capture 3; capture 4 or capture 5)
7217 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
7218 // 2. simple (capture 6)
7219 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
7220 // 3. anything else (capture 2)
7221 ".*" +
7222 ")\\)|)",
7223
7224 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
7225 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
7226
7227 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
7228 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
7229
7230 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
7231
7232 rpseudo = new RegExp( pseudos ),
7233 ridentifier = new RegExp( "^" + identifier + "$" ),
7234
7235 matchExpr = {
7236 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
7237 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
7238 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
7239 "ATTR": new RegExp( "^" + attributes ),
7240 "PSEUDO": new RegExp( "^" + pseudos ),
7241 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
7242 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
7243 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
7244 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
7245 // For use in libraries implementing .is()
7246 // We use this for POS matching in `select`
7247 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
7248 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
7249 },
7250
7251 rinputs = /^(?:input|select|textarea|button)$/i,
7252 rheader = /^h\d$/i,
7253
7254 rnative = /^[^{]+\{\s*\[native \w/,
7255
7256 // Easily-parseable/retrievable ID or TAG or CLASS selectors
7257 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
7258
7259 rsibling = /[+~]/,
7260 rescape = /'|\\/g,
7261
7262 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
7263 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
7264 funescape = function( _, escaped, escapedWhitespace ) {
7265 var high = "0x" + escaped - 0x10000;
7266 // NaN means non-codepoint
7267 // Support: Firefox<24
7268 // Workaround erroneous numeric interpretation of +"0x"
7269 return high !== high || escapedWhitespace ?
7270 escaped :
7271 high < 0 ?
7272 // BMP codepoint
7273 String.fromCharCode( high + 0x10000 ) :
7274 // Supplemental Plane codepoint (surrogate pair)
7275 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
7276 };
7277
7278 // Optimize for push.apply( _, NodeList )
7279 try {
7280 push.apply(
7281 (arr = slice.call( preferredDoc.childNodes )),
7282 preferredDoc.childNodes
7283 );
7284 // Support: Android<4.0
7285 // Detect silently failing push.apply
7286 arr[ preferredDoc.childNodes.length ].nodeType;
7287 } catch ( e ) {
7288 push = { apply: arr.length ?
7289
7290 // Leverage slice if possible
7291 function( target, els ) {
7292 push_native.apply( target, slice.call(els) );
7293 } :
7294
7295 // Support: IE<9
7296 // Otherwise append directly
7297 function( target, els ) {
7298 var j = target.length,
7299 i = 0;
7300 // Can't trust NodeList.length
7301 while ( (target[j++] = els[i++]) ) {}
7302 target.length = j - 1;
7303 }
7304 };
7305 }
7306
7307 function Sizzle( selector, context, results, seed ) {
7308 var match, elem, m, nodeType,
7309 // QSA vars
7310 i, groups, old, nid, newContext, newSelector;
7311
7312 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
7313 setDocument( context );
7314 }
7315
7316 context = context || document;
7317 results = results || [];
7318
7319 if ( !selector || typeof selector !== "string" ) {
7320 return results;
7321 }
7322
7323 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
7324 return [];
7325 }
7326
7327 if ( documentIsHTML && !seed ) {
7328
7329 // Shortcuts
7330 if ( (match = rquickExpr.exec( selector )) ) {
7331 // Speed-up: Sizzle("#ID")
7332 if ( (m = match[1]) ) {
7333 if ( nodeType === 9 ) {
7334 elem = context.getElementById( m );
7335 // Check parentNode to catch when Blackberry 4.6 returns
7336 // nodes that are no longer in the document (jQuery #6963)
7337 if ( elem && elem.parentNode ) {
7338 // Handle the case where IE, Opera, and Webkit return items
7339 // by name instead of ID
7340 if ( elem.id === m ) {
7341 results.push( elem );
7342 return results;
7343 }
7344 } else {
7345 return results;
7346 }
7347 } else {
7348 // Context is not a document
7349 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
7350 contains( context, elem ) && elem.id === m ) {
7351 results.push( elem );
7352 return results;
7353 }
7354 }
7355
7356 // Speed-up: Sizzle("TAG")
7357 } else if ( match[2] ) {
7358 push.apply( results, context.getElementsByTagName( selector ) );
7359 return results;
7360
7361 // Speed-up: Sizzle(".CLASS")
7362 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
7363 push.apply( results, context.getElementsByClassName( m ) );
7364 return results;
7365 }
7366 }
7367
7368 // QSA path
7369 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
7370 nid = old = expando;
7371 newContext = context;
7372 newSelector = nodeType === 9 && selector;
7373
7374 // qSA works strangely on Element-rooted queries
7375 // We can work around this by specifying an extra ID on the root
7376 // and working up from there (Thanks to Andrew Dupont for the technique)
7377 // IE 8 doesn't work on object elements
7378 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
7379 groups = tokenize( selector );
7380
7381 if ( (old = context.getAttribute("id")) ) {
7382 nid = old.replace( rescape, "\\$&" );
7383 } else {
7384 context.setAttribute( "id", nid );
7385 }
7386 nid = "[id='" + nid + "'] ";
7387
7388 i = groups.length;
7389 while ( i-- ) {
7390 groups[i] = nid + toSelector( groups[i] );
7391 }
7392 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
7393 newSelector = groups.join(",");
7394 }
7395
7396 if ( newSelector ) {
7397 try {
7398 push.apply( results,
7399 newContext.querySelectorAll( newSelector )
7400 );
7401 return results;
7402 } catch(qsaError) {
7403 } finally {
7404 if ( !old ) {
7405 context.removeAttribute("id");
7406 }
7407 }
7408 }
7409 }
7410 }
7411
7412 // All others
7413 return select( selector.replace( rtrim, "$1" ), context, results, seed );
7414 }
7415
7416 /**
7417 * Create key-value caches of limited size
7418 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
7419 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
7420 * deleting the oldest entry
7421 */
7422 function createCache() {
7423 var keys = [];
7424
7425 function cache( key, value ) {
7426 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
7427 if ( keys.push( key + " " ) > Expr.cacheLength ) {
7428 // Only keep the most recent entries
7429 delete cache[ keys.shift() ];
7430 }
7431 return (cache[ key + " " ] = value);
7432 }
7433 return cache;
7434 }
7435
7436 /**
7437 * Mark a function for special use by Sizzle
7438 * @param {Function} fn The function to mark
7439 */
7440 function markFunction( fn ) {
7441 fn[ expando ] = true;
7442 return fn;
7443 }
7444
7445 /**
7446 * Support testing using an element
7447 * @param {Function} fn Passed the created div and expects a boolean result
7448 */
7449 function assert( fn ) {
7450 var div = document.createElement("div");
7451
7452 try {
7453 return !!fn( div );
7454 } catch (e) {
7455 return false;
7456 } finally {
7457 // Remove from its parent by default
7458 if ( div.parentNode ) {
7459 div.parentNode.removeChild( div );
7460 }
7461 // release memory in IE
7462 div = null;
7463 }
7464 }
7465
7466 /**
7467 * Adds the same handler for all of the specified attrs
7468 * @param {String} attrs Pipe-separated list of attributes
7469 * @param {Function} handler The method that will be applied
7470 */
7471 function addHandle( attrs, handler ) {
7472 var arr = attrs.split("|"),
7473 i = attrs.length;
7474
7475 while ( i-- ) {
7476 Expr.attrHandle[ arr[i] ] = handler;
7477 }
7478 }
7479
7480 /**
7481 * Checks document order of two siblings
7482 * @param {Element} a
7483 * @param {Element} b
7484 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
7485 */
7486 function siblingCheck( a, b ) {
7487 var cur = b && a,
7488 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
7489 ( ~b.sourceIndex || MAX_NEGATIVE ) -
7490 ( ~a.sourceIndex || MAX_NEGATIVE );
7491
7492 // Use IE sourceIndex if available on both nodes
7493 if ( diff ) {
7494 return diff;
7495 }
7496
7497 // Check if b follows a
7498 if ( cur ) {
7499 while ( (cur = cur.nextSibling) ) {
7500 if ( cur === b ) {
7501 return -1;
7502 }
7503 }
7504 }
7505
7506 return a ? 1 : -1;
7507 }
7508
7509 /**
7510 * Returns a function to use in pseudos for input types
7511 * @param {String} type
7512 */
7513 function createInputPseudo( type ) {
7514 return function( elem ) {
7515 var name = elem.nodeName.toLowerCase();
7516 return name === "input" && elem.type === type;
7517 };
7518 }
7519
7520 /**
7521 * Returns a function to use in pseudos for buttons
7522 * @param {String} type
7523 */
7524 function createButtonPseudo( type ) {
7525 return function( elem ) {
7526 var name = elem.nodeName.toLowerCase();
7527 return (name === "input" || name === "button") && elem.type === type;
7528 };
7529 }
7530
7531 /**
7532 * Returns a function to use in pseudos for positionals
7533 * @param {Function} fn
7534 */
7535 function createPositionalPseudo( fn ) {
7536 return markFunction(function( argument ) {
7537 argument = +argument;
7538 return markFunction(function( seed, matches ) {
7539 var j,
7540 matchIndexes = fn( [], seed.length, argument ),
7541 i = matchIndexes.length;
7542
7543 // Match elements found at the specified indexes
7544 while ( i-- ) {
7545 if ( seed[ (j = matchIndexes[i]) ] ) {
7546 seed[j] = !(matches[j] = seed[j]);
7547 }
7548 }
7549 });
7550 });
7551 }
7552
7553 /**
7554 * Checks a node for validity as a Sizzle context
7555 * @param {Element|Object=} context
7556 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
7557 */
7558 function testContext( context ) {
7559 return context && typeof context.getElementsByTagName !== strundefined && context;
7560 }
7561
7562 // Expose support vars for convenience
7563 support = Sizzle.support = {};
7564
7565 /**
7566 * Detects XML nodes
7567 * @param {Element|Object} elem An element or a document
7568 * @returns {Boolean} True iff elem is a non-HTML XML node
7569 */
7570 isXML = Sizzle.isXML = function( elem ) {
7571 // documentElement is verified for cases where it doesn't yet exist
7572 // (such as loading iframes in IE - #4833)
7573 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
7574 return documentElement ? documentElement.nodeName !== "HTML" : false;
7575 };
7576
7577 /**
7578 * Sets document-related variables once based on the current document
7579 * @param {Element|Object} [doc] An element or document object to use to set the document
7580 * @returns {Object} Returns the current document
7581 */
7582 setDocument = Sizzle.setDocument = function( node ) {
7583 var hasCompare,
7584 doc = node ? node.ownerDocument || node : preferredDoc,
7585 parent = doc.defaultView;
7586
7587 // If no document and documentElement is available, return
7588 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
7589 return document;
7590 }
7591
7592 // Set our document
7593 document = doc;
7594 docElem = doc.documentElement;
7595
7596 // Support tests
7597 documentIsHTML = !isXML( doc );
7598
7599 // Support: IE>8
7600 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
7601 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
7602 // IE6-8 do not support the defaultView property so parent will be undefined
7603 if ( parent && parent !== parent.top ) {
7604 // IE11 does not have attachEvent, so all must suffer
7605 if ( parent.addEventListener ) {
7606 parent.addEventListener( "unload", function() {
7607 setDocument();
7608 }, false );
7609 } else if ( parent.attachEvent ) {
7610 parent.attachEvent( "onunload", function() {
7611 setDocument();
7612 });
7613 }
7614 }
7615
7616 /* Attributes
7617 ---------------------------------------------------------------------- */
7618
7619 // Support: IE<8
7620 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
7621 support.attributes = assert(function( div ) {
7622 div.className = "i";
7623 return !div.getAttribute("className");
7624 });
7625
7626 /* getElement(s)By*
7627 ---------------------------------------------------------------------- */
7628
7629 // Check if getElementsByTagName("*") returns only elements
7630 support.getElementsByTagName = assert(function( div ) {
7631 div.appendChild( doc.createComment("") );
7632 return !div.getElementsByTagName("*").length;
7633 });
7634
7635 // Check if getElementsByClassName can be trusted
7636 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
7637 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
7638
7639 // Support: Safari<4
7640 // Catch class over-caching
7641 div.firstChild.className = "i";
7642 // Support: Opera<10
7643 // Catch gEBCN failure to find non-leading classes
7644 return div.getElementsByClassName("i").length === 2;
7645 });
7646
7647 // Support: IE<10
7648 // Check if getElementById returns elements by name
7649 // The broken getElementById methods don't pick up programatically-set names,
7650 // so use a roundabout getElementsByName test
7651 support.getById = assert(function( div ) {
7652 docElem.appendChild( div ).id = expando;
7653 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
7654 });
7655
7656 // ID find and filter
7657 if ( support.getById ) {
7658 Expr.find["ID"] = function( id, context ) {
7659 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
7660 var m = context.getElementById( id );
7661 // Check parentNode to catch when Blackberry 4.6 returns
7662 // nodes that are no longer in the document #6963
7663 return m && m.parentNode ? [ m ] : [];
7664 }
7665 };
7666 Expr.filter["ID"] = function( id ) {
7667 var attrId = id.replace( runescape, funescape );
7668 return function( elem ) {
7669 return elem.getAttribute("id") === attrId;
7670 };
7671 };
7672 } else {
7673 // Support: IE6/7
7674 // getElementById is not reliable as a find shortcut
7675 delete Expr.find["ID"];
7676
7677 Expr.filter["ID"] = function( id ) {
7678 var attrId = id.replace( runescape, funescape );
7679 return function( elem ) {
7680 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
7681 return node && node.value === attrId;
7682 };
7683 };
7684 }
7685
7686 // Tag
7687 Expr.find["TAG"] = support.getElementsByTagName ?
7688 function( tag, context ) {
7689 if ( typeof context.getElementsByTagName !== strundefined ) {
7690 return context.getElementsByTagName( tag );
7691 }
7692 } :
7693 function( tag, context ) {
7694 var elem,
7695 tmp = [],
7696 i = 0,
7697 results = context.getElementsByTagName( tag );
7698
7699 // Filter out possible comments
7700 if ( tag === "*" ) {
7701 while ( (elem = results[i++]) ) {
7702 if ( elem.nodeType === 1 ) {
7703 tmp.push( elem );
7704 }
7705 }
7706
7707 return tmp;
7708 }
7709 return results;
7710 };
7711
7712 // Class
7713 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
7714 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
7715 return context.getElementsByClassName( className );
7716 }
7717 };
7718
7719 /* QSA/matchesSelector
7720 ---------------------------------------------------------------------- */
7721
7722 // QSA and matchesSelector support
7723
7724 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
7725 rbuggyMatches = [];
7726
7727 // qSa(:focus) reports false when true (Chrome 21)
7728 // We allow this because of a bug in IE8/9 that throws an error
7729 // whenever `document.activeElement` is accessed on an iframe
7730 // So, we allow :focus to pass through QSA all the time to avoid the IE error
7731 // See http://bugs.jquery.com/ticket/13378
7732 rbuggyQSA = [];
7733
7734 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
7735 // Build QSA regex
7736 // Regex strategy adopted from Diego Perini
7737 assert(function( div ) {
7738 // Select is set to empty string on purpose
7739 // This is to test IE's treatment of not explicitly
7740 // setting a boolean content attribute,
7741 // since its presence should be enough
7742 // http://bugs.jquery.com/ticket/12359
7743 div.innerHTML = "<select msallowclip=''><option selected=''></option></select>";
7744
7745 // Support: IE8, Opera 11-12.16
7746 // Nothing should be selected when empty strings follow ^= or $= or *=
7747 // The test attribute must be unknown in Opera but "safe" for WinRT
7748 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
7749 if ( div.querySelectorAll("[msallowclip^='']").length ) {
7750 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
7751 }
7752
7753 // Support: IE8
7754 // Boolean attributes and "value" are not treated correctly
7755 if ( !div.querySelectorAll("[selected]").length ) {
7756 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
7757 }
7758
7759 // Webkit/Opera - :checked should return selected option elements
7760 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
7761 // IE8 throws error here and will not see later tests
7762 if ( !div.querySelectorAll(":checked").length ) {
7763 rbuggyQSA.push(":checked");
7764 }
7765 });
7766
7767 assert(function( div ) {
7768 // Support: Windows 8 Native Apps
7769 // The type and name attributes are restricted during .innerHTML assignment
7770 var input = doc.createElement("input");
7771 input.setAttribute( "type", "hidden" );
7772 div.appendChild( input ).setAttribute( "name", "D" );
7773
7774 // Support: IE8
7775 // Enforce case-sensitivity of name attribute
7776 if ( div.querySelectorAll("[name=d]").length ) {
7777 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
7778 }
7779
7780 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
7781 // IE8 throws error here and will not see later tests
7782 if ( !div.querySelectorAll(":enabled").length ) {
7783 rbuggyQSA.push( ":enabled", ":disabled" );
7784 }
7785
7786 // Opera 10-11 does not throw on post-comma invalid pseudos
7787 div.querySelectorAll("*,:x");
7788 rbuggyQSA.push(",.*:");
7789 });
7790 }
7791
7792 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
7793 docElem.webkitMatchesSelector ||
7794 docElem.mozMatchesSelector ||
7795 docElem.oMatchesSelector ||
7796 docElem.msMatchesSelector) )) ) {
7797
7798 assert(function( div ) {
7799 // Check to see if it's possible to do matchesSelector
7800 // on a disconnected node (IE 9)
7801 support.disconnectedMatch = matches.call( div, "div" );
7802
7803 // This should fail with an exception
7804 // Gecko does not error, returns false instead
7805 matches.call( div, "[s!='']:x" );
7806 rbuggyMatches.push( "!=", pseudos );
7807 });
7808 }
7809
7810 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
7811 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
7812
7813 /* Contains
7814 ---------------------------------------------------------------------- */
7815 hasCompare = rnative.test( docElem.compareDocumentPosition );
7816
7817 // Element contains another
7818 // Purposefully does not implement inclusive descendent
7819 // As in, an element does not contain itself
7820 contains = hasCompare || rnative.test( docElem.contains ) ?
7821 function( a, b ) {
7822 var adown = a.nodeType === 9 ? a.documentElement : a,
7823 bup = b && b.parentNode;
7824 return a === bup || !!( bup && bup.nodeType === 1 && (
7825 adown.contains ?
7826 adown.contains( bup ) :
7827 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
7828 ));
7829 } :
7830 function( a, b ) {
7831 if ( b ) {
7832 while ( (b = b.parentNode) ) {
7833 if ( b === a ) {
7834 return true;
7835 }
7836 }
7837 }
7838 return false;
7839 };
7840
7841 /* Sorting
7842 ---------------------------------------------------------------------- */
7843
7844 // Document order sorting
7845 sortOrder = hasCompare ?
7846 function( a, b ) {
7847
7848 // Flag for duplicate removal
7849 if ( a === b ) {
7850 hasDuplicate = true;
7851 return 0;
7852 }
7853
7854 // Sort on method existence if only one input has compareDocumentPosition
7855 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
7856 if ( compare ) {
7857 return compare;
7858 }
7859
7860 // Calculate position if both inputs belong to the same document
7861 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
7862 a.compareDocumentPosition( b ) :
7863
7864 // Otherwise we know they are disconnected
7865 1;
7866
7867 // Disconnected nodes
7868 if ( compare & 1 ||
7869 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
7870
7871 // Choose the first element that is related to our preferred document
7872 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
7873 return -1;
7874 }
7875 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
7876 return 1;
7877 }
7878
7879 // Maintain original order
7880 return sortInput ?
7881 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
7882 0;
7883 }
7884
7885 return compare & 4 ? -1 : 1;
7886 } :
7887 function( a, b ) {
7888 // Exit early if the nodes are identical
7889 if ( a === b ) {
7890 hasDuplicate = true;
7891 return 0;
7892 }
7893
7894 var cur,
7895 i = 0,
7896 aup = a.parentNode,
7897 bup = b.parentNode,
7898 ap = [ a ],
7899 bp = [ b ];
7900
7901 // Parentless nodes are either documents or disconnected
7902 if ( !aup || !bup ) {
7903 return a === doc ? -1 :
7904 b === doc ? 1 :
7905 aup ? -1 :
7906 bup ? 1 :
7907 sortInput ?
7908 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
7909 0;
7910
7911 // If the nodes are siblings, we can do a quick check
7912 } else if ( aup === bup ) {
7913 return siblingCheck( a, b );
7914 }
7915
7916 // Otherwise we need full lists of their ancestors for comparison
7917 cur = a;
7918 while ( (cur = cur.parentNode) ) {
7919 ap.unshift( cur );
7920 }
7921 cur = b;
7922 while ( (cur = cur.parentNode) ) {
7923 bp.unshift( cur );
7924 }
7925
7926 // Walk down the tree looking for a discrepancy
7927 while ( ap[i] === bp[i] ) {
7928 i++;
7929 }
7930
7931 return i ?
7932 // Do a sibling check if the nodes have a common ancestor
7933 siblingCheck( ap[i], bp[i] ) :
7934
7935 // Otherwise nodes in our document sort first
7936 ap[i] === preferredDoc ? -1 :
7937 bp[i] === preferredDoc ? 1 :
7938 0;
7939 };
7940
7941 return doc;
7942 };
7943
7944 Sizzle.matches = function( expr, elements ) {
7945 return Sizzle( expr, null, null, elements );
7946 };
7947
7948 Sizzle.matchesSelector = function( elem, expr ) {
7949 // Set document vars if needed
7950 if ( ( elem.ownerDocument || elem ) !== document ) {
7951 setDocument( elem );
7952 }
7953
7954 // Make sure that attribute selectors are quoted
7955 expr = expr.replace( rattributeQuotes, "='$1']" );
7956
7957 if ( support.matchesSelector && documentIsHTML &&
7958 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
7959 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
7960
7961 try {
7962 var ret = matches.call( elem, expr );
7963
7964 // IE 9's matchesSelector returns false on disconnected nodes
7965 if ( ret || support.disconnectedMatch ||
7966 // As well, disconnected nodes are said to be in a document
7967 // fragment in IE 9
7968 elem.document && elem.document.nodeType !== 11 ) {
7969 return ret;
7970 }
7971 } catch(e) {}
7972 }
7973
7974 return Sizzle( expr, document, null, [ elem ] ).length > 0;
7975 };
7976
7977 Sizzle.contains = function( context, elem ) {
7978 // Set document vars if needed
7979 if ( ( context.ownerDocument || context ) !== document ) {
7980 setDocument( context );
7981 }
7982 return contains( context, elem );
7983 };
7984
7985 Sizzle.attr = function( elem, name ) {
7986 // Set document vars if needed
7987 if ( ( elem.ownerDocument || elem ) !== document ) {
7988 setDocument( elem );
7989 }
7990
7991 var fn = Expr.attrHandle[ name.toLowerCase() ],
7992 // Don't get fooled by Object.prototype properties (jQuery #13807)
7993 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
7994 fn( elem, name, !documentIsHTML ) :
7995 undefined;
7996
7997 return val !== undefined ?
7998 val :
7999 support.attributes || !documentIsHTML ?
8000 elem.getAttribute( name ) :
8001 (val = elem.getAttributeNode(name)) && val.specified ?
8002 val.value :
8003 null;
8004 };
8005
8006 Sizzle.error = function( msg ) {
8007 throw new Error( "Syntax error, unrecognized expression: " + msg );
8008 };
8009
8010 /**
8011 * Document sorting and removing duplicates
8012 * @param {ArrayLike} results
8013 */
8014 Sizzle.uniqueSort = function( results ) {
8015 var elem,
8016 duplicates = [],
8017 j = 0,
8018 i = 0;
8019
8020 // Unless we *know* we can detect duplicates, assume their presence
8021 hasDuplicate = !support.detectDuplicates;
8022 sortInput = !support.sortStable && results.slice( 0 );
8023 results.sort( sortOrder );
8024
8025 if ( hasDuplicate ) {
8026 while ( (elem = results[i++]) ) {
8027 if ( elem === results[ i ] ) {
8028 j = duplicates.push( i );
8029 }
8030 }
8031 while ( j-- ) {
8032 results.splice( duplicates[ j ], 1 );
8033 }
8034 }
8035
8036 // Clear input after sorting to release objects
8037 // See https://github.com/jquery/sizzle/pull/225
8038 sortInput = null;
8039
8040 return results;
8041 };
8042
8043 /**
8044 * Utility function for retrieving the text value of an array of DOM nodes
8045 * @param {Array|Element} elem
8046 */
8047 getText = Sizzle.getText = function( elem ) {
8048 var node,
8049 ret = "",
8050 i = 0,
8051 nodeType = elem.nodeType;
8052
8053 if ( !nodeType ) {
8054 // If no nodeType, this is expected to be an array
8055 while ( (node = elem[i++]) ) {
8056 // Do not traverse comment nodes
8057 ret += getText( node );
8058 }
8059 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
8060 // Use textContent for elements
8061 // innerText usage removed for consistency of new lines (jQuery #11153)
8062 if ( typeof elem.textContent === "string" ) {
8063 return elem.textContent;
8064 } else {
8065 // Traverse its children
8066 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
8067 ret += getText( elem );
8068 }
8069 }
8070 } else if ( nodeType === 3 || nodeType === 4 ) {
8071 return elem.nodeValue;
8072 }
8073 // Do not include comment or processing instruction nodes
8074
8075 return ret;
8076 };
8077
8078 Expr = Sizzle.selectors = {
8079
8080 // Can be adjusted by the user
8081 cacheLength: 50,
8082
8083 createPseudo: markFunction,
8084
8085 match: matchExpr,
8086
8087 attrHandle: {},
8088
8089 find: {},
8090
8091 relative: {
8092 ">": { dir: "parentNode", first: true },
8093 " ": { dir: "parentNode" },
8094 "+": { dir: "previousSibling", first: true },
8095 "~": { dir: "previousSibling" }
8096 },
8097
8098 preFilter: {
8099 "ATTR": function( match ) {
8100 match[1] = match[1].replace( runescape, funescape );
8101
8102 // Move the given value to match[3] whether quoted or unquoted
8103 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
8104
8105 if ( match[2] === "~=" ) {
8106 match[3] = " " + match[3] + " ";
8107 }
8108
8109 return match.slice( 0, 4 );
8110 },
8111
8112 "CHILD": function( match ) {
8113 /* matches from matchExpr["CHILD"]
8114 1 type (only|nth|...)
8115 2 what (child|of-type)
8116 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
8117 4 xn-component of xn+y argument ([+-]?\d*n|)
8118 5 sign of xn-component
8119 6 x of xn-component
8120 7 sign of y-component
8121 8 y of y-component
8122 */
8123 match[1] = match[1].toLowerCase();
8124
8125 if ( match[1].slice( 0, 3 ) === "nth" ) {
8126 // nth-* requires argument
8127 if ( !match[3] ) {
8128 Sizzle.error( match[0] );
8129 }
8130
8131 // numeric x and y parameters for Expr.filter.CHILD
8132 // remember that false/true cast respectively to 0/1
8133 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
8134 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
8135
8136 // other types prohibit arguments
8137 } else if ( match[3] ) {
8138 Sizzle.error( match[0] );
8139 }
8140
8141 return match;
8142 },
8143
8144 "PSEUDO": function( match ) {
8145 var excess,
8146 unquoted = !match[6] && match[2];
8147
8148 if ( matchExpr["CHILD"].test( match[0] ) ) {
8149 return null;
8150 }
8151
8152 // Accept quoted arguments as-is
8153 if ( match[3] ) {
8154 match[2] = match[4] || match[5] || "";
8155
8156 // Strip excess characters from unquoted arguments
8157 } else if ( unquoted && rpseudo.test( unquoted ) &&
8158 // Get excess from tokenize (recursively)
8159 (excess = tokenize( unquoted, true )) &&
8160 // advance to the next closing parenthesis
8161 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
8162
8163 // excess is a negative index
8164 match[0] = match[0].slice( 0, excess );
8165 match[2] = unquoted.slice( 0, excess );
8166 }
8167
8168 // Return only captures needed by the pseudo filter method (type and argument)
8169 return match.slice( 0, 3 );
8170 }
8171 },
8172
8173 filter: {
8174
8175 "TAG": function( nodeNameSelector ) {
8176 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
8177 return nodeNameSelector === "*" ?
8178 function() { return true; } :
8179 function( elem ) {
8180 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
8181 };
8182 },
8183
8184 "CLASS": function( className ) {
8185 var pattern = classCache[ className + " " ];
8186
8187 return pattern ||
8188 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
8189 classCache( className, function( elem ) {
8190 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
8191 });
8192 },
8193
8194 "ATTR": function( name, operator, check ) {
8195 return function( elem ) {
8196 var result = Sizzle.attr( elem, name );
8197
8198 if ( result == null ) {
8199 return operator === "!=";
8200 }
8201 if ( !operator ) {
8202 return true;
8203 }
8204
8205 result += "";
8206
8207 return operator === "=" ? result === check :
8208 operator === "!=" ? result !== check :
8209 operator === "^=" ? check && result.indexOf( check ) === 0 :
8210 operator === "*=" ? check && result.indexOf( check ) > -1 :
8211 operator === "$=" ? check && result.slice( -check.length ) === check :
8212 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
8213 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
8214 false;
8215 };
8216 },
8217
8218 "CHILD": function( type, what, argument, first, last ) {
8219 var simple = type.slice( 0, 3 ) !== "nth",
8220 forward = type.slice( -4 ) !== "last",
8221 ofType = what === "of-type";
8222
8223 return first === 1 && last === 0 ?
8224
8225 // Shortcut for :nth-*(n)
8226 function( elem ) {
8227 return !!elem.parentNode;
8228 } :
8229
8230 function( elem, context, xml ) {
8231 var cache, outerCache, node, diff, nodeIndex, start,
8232 dir = simple !== forward ? "nextSibling" : "previousSibling",
8233 parent = elem.parentNode,
8234 name = ofType && elem.nodeName.toLowerCase(),
8235 useCache = !xml && !ofType;
8236
8237 if ( parent ) {
8238
8239 // :(first|last|only)-(child|of-type)
8240 if ( simple ) {
8241 while ( dir ) {
8242 node = elem;
8243 while ( (node = node[ dir ]) ) {
8244 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
8245 return false;
8246 }
8247 }
8248 // Reverse direction for :only-* (if we haven't yet done so)
8249 start = dir = type === "only" && !start && "nextSibling";
8250 }
8251 return true;
8252 }
8253
8254 start = [ forward ? parent.firstChild : parent.lastChild ];
8255
8256 // non-xml :nth-child(...) stores cache data on `parent`
8257 if ( forward && useCache ) {
8258 // Seek `elem` from a previously-cached index
8259 outerCache = parent[ expando ] || (parent[ expando ] = {});
8260 cache = outerCache[ type ] || [];
8261 nodeIndex = cache[0] === dirruns && cache[1];
8262 diff = cache[0] === dirruns && cache[2];
8263 node = nodeIndex && parent.childNodes[ nodeIndex ];
8264
8265 while ( (node = ++nodeIndex && node && node[ dir ] ||
8266
8267 // Fallback to seeking `elem` from the start
8268 (diff = nodeIndex = 0) || start.pop()) ) {
8269
8270 // When found, cache indexes on `parent` and break
8271 if ( node.nodeType === 1 && ++diff && node === elem ) {
8272 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
8273 break;
8274 }
8275 }
8276
8277 // Use previously-cached element index if available
8278 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
8279 diff = cache[1];
8280
8281 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
8282 } else {
8283 // Use the same loop as above to seek `elem` from the start
8284 while ( (node = ++nodeIndex && node && node[ dir ] ||
8285 (diff = nodeIndex = 0) || start.pop()) ) {
8286
8287 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
8288 // Cache the index of each encountered element
8289 if ( useCache ) {
8290 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
8291 }
8292
8293 if ( node === elem ) {
8294 break;
8295 }
8296 }
8297 }
8298 }
8299
8300 // Incorporate the offset, then check against cycle size
8301 diff -= last;
8302 return diff === first || ( diff % first === 0 && diff / first >= 0 );
8303 }
8304 };
8305 },
8306
8307 "PSEUDO": function( pseudo, argument ) {
8308 // pseudo-class names are case-insensitive
8309 // http://www.w3.org/TR/selectors/#pseudo-classes
8310 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
8311 // Remember that setFilters inherits from pseudos
8312 var args,
8313 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
8314 Sizzle.error( "unsupported pseudo: " + pseudo );
8315
8316 // The user may use createPseudo to indicate that
8317 // arguments are needed to create the filter function
8318 // just as Sizzle does
8319 if ( fn[ expando ] ) {
8320 return fn( argument );
8321 }
8322
8323 // But maintain support for old signatures
8324 if ( fn.length > 1 ) {
8325 args = [ pseudo, pseudo, "", argument ];
8326 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
8327 markFunction(function( seed, matches ) {
8328 var idx,
8329 matched = fn( seed, argument ),
8330 i = matched.length;
8331 while ( i-- ) {
8332 idx = indexOf.call( seed, matched[i] );
8333 seed[ idx ] = !( matches[ idx ] = matched[i] );
8334 }
8335 }) :
8336 function( elem ) {
8337 return fn( elem, 0, args );
8338 };
8339 }
8340
8341 return fn;
8342 }
8343 },
8344
8345 pseudos: {
8346 // Potentially complex pseudos
8347 "not": markFunction(function( selector ) {
8348 // Trim the selector passed to compile
8349 // to avoid treating leading and trailing
8350 // spaces as combinators
8351 var input = [],
8352 results = [],
8353 matcher = compile( selector.replace( rtrim, "$1" ) );
8354
8355 return matcher[ expando ] ?
8356 markFunction(function( seed, matches, context, xml ) {
8357 var elem,
8358 unmatched = matcher( seed, null, xml, [] ),
8359 i = seed.length;
8360
8361 // Match elements unmatched by `matcher`
8362 while ( i-- ) {
8363 if ( (elem = unmatched[i]) ) {
8364 seed[i] = !(matches[i] = elem);
8365 }
8366 }
8367 }) :
8368 function( elem, context, xml ) {
8369 input[0] = elem;
8370 matcher( input, null, xml, results );
8371 return !results.pop();
8372 };
8373 }),
8374
8375 "has": markFunction(function( selector ) {
8376 return function( elem ) {
8377 return Sizzle( selector, elem ).length > 0;
8378 };
8379 }),
8380
8381 "contains": markFunction(function( text ) {
8382 return function( elem ) {
8383 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
8384 };
8385 }),
8386
8387 // "Whether an element is represented by a :lang() selector
8388 // is based solely on the element's language value
8389 // being equal to the identifier C,
8390 // or beginning with the identifier C immediately followed by "-".
8391 // The matching of C against the element's language value is performed case-insensitively.
8392 // The identifier C does not have to be a valid language name."
8393 // http://www.w3.org/TR/selectors/#lang-pseudo
8394 "lang": markFunction( function( lang ) {
8395 // lang value must be a valid identifier
8396 if ( !ridentifier.test(lang || "") ) {
8397 Sizzle.error( "unsupported lang: " + lang );
8398 }
8399 lang = lang.replace( runescape, funescape ).toLowerCase();
8400 return function( elem ) {
8401 var elemLang;
8402 do {
8403 if ( (elemLang = documentIsHTML ?
8404 elem.lang :
8405 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
8406
8407 elemLang = elemLang.toLowerCase();
8408 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
8409 }
8410 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
8411 return false;
8412 };
8413 }),
8414
8415 // Miscellaneous
8416 "target": function( elem ) {
8417 var hash = window.location && window.location.hash;
8418 return hash && hash.slice( 1 ) === elem.id;
8419 },
8420
8421 "root": function( elem ) {
8422 return elem === docElem;
8423 },
8424
8425 "focus": function( elem ) {
8426 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
8427 },
8428
8429 // Boolean properties
8430 "enabled": function( elem ) {
8431 return elem.disabled === false;
8432 },
8433
8434 "disabled": function( elem ) {
8435 return elem.disabled === true;
8436 },
8437
8438 "checked": function( elem ) {
8439 // In CSS3, :checked should return both checked and selected elements
8440 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
8441 var nodeName = elem.nodeName.toLowerCase();
8442 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
8443 },
8444
8445 "selected": function( elem ) {
8446 // Accessing this property makes selected-by-default
8447 // options in Safari work properly
8448 if ( elem.parentNode ) {
8449 elem.parentNode.selectedIndex;
8450 }
8451
8452 return elem.selected === true;
8453 },
8454
8455 // Contents
8456 "empty": function( elem ) {
8457 // http://www.w3.org/TR/selectors/#empty-pseudo
8458 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
8459 // but not by others (comment: 8; processing instruction: 7; etc.)
8460 // nodeType < 6 works because attributes (2) do not appear as children
8461 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
8462 if ( elem.nodeType < 6 ) {
8463 return false;
8464 }
8465 }
8466 return true;
8467 },
8468
8469 "parent": function( elem ) {
8470 return !Expr.pseudos["empty"]( elem );
8471 },
8472
8473 // Element/input types
8474 "header": function( elem ) {
8475 return rheader.test( elem.nodeName );
8476 },
8477
8478 "input": function( elem ) {
8479 return rinputs.test( elem.nodeName );
8480 },
8481
8482 "button": function( elem ) {
8483 var name = elem.nodeName.toLowerCase();
8484 return name === "input" && elem.type === "button" || name === "button";
8485 },
8486
8487 "text": function( elem ) {
8488 var attr;
8489 return elem.nodeName.toLowerCase() === "input" &&
8490 elem.type === "text" &&
8491
8492 // Support: IE<8
8493 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
8494 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
8495 },
8496
8497 // Position-in-collection
8498 "first": createPositionalPseudo(function() {
8499 return [ 0 ];
8500 }),
8501
8502 "last": createPositionalPseudo(function( matchIndexes, length ) {
8503 return [ length - 1 ];
8504 }),
8505
8506 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
8507 return [ argument < 0 ? argument + length : argument ];
8508 }),
8509
8510 "even": createPositionalPseudo(function( matchIndexes, length ) {
8511 var i = 0;
8512 for ( ; i < length; i += 2 ) {
8513 matchIndexes.push( i );
8514 }
8515 return matchIndexes;
8516 }),
8517
8518 "odd": createPositionalPseudo(function( matchIndexes, length ) {
8519 var i = 1;
8520 for ( ; i < length; i += 2 ) {
8521 matchIndexes.push( i );
8522 }
8523 return matchIndexes;
8524 }),
8525
8526 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
8527 var i = argument < 0 ? argument + length : argument;
8528 for ( ; --i >= 0; ) {
8529 matchIndexes.push( i );
8530 }
8531 return matchIndexes;
8532 }),
8533
8534 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
8535 var i = argument < 0 ? argument + length : argument;
8536 for ( ; ++i < length; ) {
8537 matchIndexes.push( i );
8538 }
8539 return matchIndexes;
8540 })
8541 }
8542 };
8543
8544 Expr.pseudos["nth"] = Expr.pseudos["eq"];
8545
8546 // Add button/input type pseudos
8547 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
8548 Expr.pseudos[ i ] = createInputPseudo( i );
8549 }
8550 for ( i in { submit: true, reset: true } ) {
8551 Expr.pseudos[ i ] = createButtonPseudo( i );
8552 }
8553
8554 // Easy API for creating new setFilters
8555 function setFilters() {}
8556 setFilters.prototype = Expr.filters = Expr.pseudos;
8557 Expr.setFilters = new setFilters();
8558
8559 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
8560 var matched, match, tokens, type,
8561 soFar, groups, preFilters,
8562 cached = tokenCache[ selector + " " ];
8563
8564 if ( cached ) {
8565 return parseOnly ? 0 : cached.slice( 0 );
8566 }
8567
8568 soFar = selector;
8569 groups = [];
8570 preFilters = Expr.preFilter;
8571
8572 while ( soFar ) {
8573
8574 // Comma and first run
8575 if ( !matched || (match = rcomma.exec( soFar )) ) {
8576 if ( match ) {
8577 // Don't consume trailing commas as valid
8578 soFar = soFar.slice( match[0].length ) || soFar;
8579 }
8580 groups.push( (tokens = []) );
8581 }
8582
8583 matched = false;
8584
8585 // Combinators
8586 if ( (match = rcombinators.exec( soFar )) ) {
8587 matched = match.shift();
8588 tokens.push({
8589 value: matched,
8590 // Cast descendant combinators to space
8591 type: match[0].replace( rtrim, " " )
8592 });
8593 soFar = soFar.slice( matched.length );
8594 }
8595
8596 // Filters
8597 for ( type in Expr.filter ) {
8598 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
8599 (match = preFilters[ type ]( match ))) ) {
8600 matched = match.shift();
8601 tokens.push({
8602 value: matched,
8603 type: type,
8604 matches: match
8605 });
8606 soFar = soFar.slice( matched.length );
8607 }
8608 }
8609
8610 if ( !matched ) {
8611 break;
8612 }
8613 }
8614
8615 // Return the length of the invalid excess
8616 // if we're just parsing
8617 // Otherwise, throw an error or return tokens
8618 return parseOnly ?
8619 soFar.length :
8620 soFar ?
8621 Sizzle.error( selector ) :
8622 // Cache the tokens
8623 tokenCache( selector, groups ).slice( 0 );
8624 };
8625
8626 function toSelector( tokens ) {
8627 var i = 0,
8628 len = tokens.length,
8629 selector = "";
8630 for ( ; i < len; i++ ) {
8631 selector += tokens[i].value;
8632 }
8633 return selector;
8634 }
8635
8636 function addCombinator( matcher, combinator, base ) {
8637 var dir = combinator.dir,
8638 checkNonElements = base && dir === "parentNode",
8639 doneName = done++;
8640
8641 return combinator.first ?
8642 // Check against closest ancestor/preceding element
8643 function( elem, context, xml ) {
8644 while ( (elem = elem[ dir ]) ) {
8645 if ( elem.nodeType === 1 || checkNonElements ) {
8646 return matcher( elem, context, xml );
8647 }
8648 }
8649 } :
8650
8651 // Check against all ancestor/preceding elements
8652 function( elem, context, xml ) {
8653 var oldCache, outerCache,
8654 newCache = [ dirruns, doneName ];
8655
8656 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
8657 if ( xml ) {
8658 while ( (elem = elem[ dir ]) ) {
8659 if ( elem.nodeType === 1 || checkNonElements ) {
8660 if ( matcher( elem, context, xml ) ) {
8661 return true;
8662 }
8663 }
8664 }
8665 } else {
8666 while ( (elem = elem[ dir ]) ) {
8667 if ( elem.nodeType === 1 || checkNonElements ) {
8668 outerCache = elem[ expando ] || (elem[ expando ] = {});
8669 if ( (oldCache = outerCache[ dir ]) &&
8670 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
8671
8672 // Assign to newCache so results back-propagate to previous elements
8673 return (newCache[ 2 ] = oldCache[ 2 ]);
8674 } else {
8675 // Reuse newcache so results back-propagate to previous elements
8676 outerCache[ dir ] = newCache;
8677
8678 // A match means we're done; a fail means we have to keep checking
8679 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
8680 return true;
8681 }
8682 }
8683 }
8684 }
8685 }
8686 };
8687 }
8688
8689 function elementMatcher( matchers ) {
8690 return matchers.length > 1 ?
8691 function( elem, context, xml ) {
8692 var i = matchers.length;
8693 while ( i-- ) {
8694 if ( !matchers[i]( elem, context, xml ) ) {
8695 return false;
8696 }
8697 }
8698 return true;
8699 } :
8700 matchers[0];
8701 }
8702
8703 function multipleContexts( selector, contexts, results ) {
8704 var i = 0,
8705 len = contexts.length;
8706 for ( ; i < len; i++ ) {
8707 Sizzle( selector, contexts[i], results );
8708 }
8709 return results;
8710 }
8711
8712 function condense( unmatched, map, filter, context, xml ) {
8713 var elem,
8714 newUnmatched = [],
8715 i = 0,
8716 len = unmatched.length,
8717 mapped = map != null;
8718
8719 for ( ; i < len; i++ ) {
8720 if ( (elem = unmatched[i]) ) {
8721 if ( !filter || filter( elem, context, xml ) ) {
8722 newUnmatched.push( elem );
8723 if ( mapped ) {
8724 map.push( i );
8725 }
8726 }
8727 }
8728 }
8729
8730 return newUnmatched;
8731 }
8732
8733 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
8734 if ( postFilter && !postFilter[ expando ] ) {
8735 postFilter = setMatcher( postFilter );
8736 }
8737 if ( postFinder && !postFinder[ expando ] ) {
8738 postFinder = setMatcher( postFinder, postSelector );
8739 }
8740 return markFunction(function( seed, results, context, xml ) {
8741 var temp, i, elem,
8742 preMap = [],
8743 postMap = [],
8744 preexisting = results.length,
8745
8746 // Get initial elements from seed or context
8747 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
8748
8749 // Prefilter to get matcher input, preserving a map for seed-results synchronization
8750 matcherIn = preFilter && ( seed || !selector ) ?
8751 condense( elems, preMap, preFilter, context, xml ) :
8752 elems,
8753
8754 matcherOut = matcher ?
8755 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
8756 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
8757
8758 // ...intermediate processing is necessary
8759 [] :
8760
8761 // ...otherwise use results directly
8762 results :
8763 matcherIn;
8764
8765 // Find primary matches
8766 if ( matcher ) {
8767 matcher( matcherIn, matcherOut, context, xml );
8768 }
8769
8770 // Apply postFilter
8771 if ( postFilter ) {
8772 temp = condense( matcherOut, postMap );
8773 postFilter( temp, [], context, xml );
8774
8775 // Un-match failing elements by moving them back to matcherIn
8776 i = temp.length;
8777 while ( i-- ) {
8778 if ( (elem = temp[i]) ) {
8779 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
8780 }
8781 }
8782 }
8783
8784 if ( seed ) {
8785 if ( postFinder || preFilter ) {
8786 if ( postFinder ) {
8787 // Get the final matcherOut by condensing this intermediate into postFinder contexts
8788 temp = [];
8789 i = matcherOut.length;
8790 while ( i-- ) {
8791 if ( (elem = matcherOut[i]) ) {
8792 // Restore matcherIn since elem is not yet a final match
8793 temp.push( (matcherIn[i] = elem) );
8794 }
8795 }
8796 postFinder( null, (matcherOut = []), temp, xml );
8797 }
8798
8799 // Move matched elements from seed to results to keep them synchronized
8800 i = matcherOut.length;
8801 while ( i-- ) {
8802 if ( (elem = matcherOut[i]) &&
8803 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
8804
8805 seed[temp] = !(results[temp] = elem);
8806 }
8807 }
8808 }
8809
8810 // Add elements to results, through postFinder if defined
8811 } else {
8812 matcherOut = condense(
8813 matcherOut === results ?
8814 matcherOut.splice( preexisting, matcherOut.length ) :
8815 matcherOut
8816 );
8817 if ( postFinder ) {
8818 postFinder( null, results, matcherOut, xml );
8819 } else {
8820 push.apply( results, matcherOut );
8821 }
8822 }
8823 });
8824 }
8825
8826 function matcherFromTokens( tokens ) {
8827 var checkContext, matcher, j,
8828 len = tokens.length,
8829 leadingRelative = Expr.relative[ tokens[0].type ],
8830 implicitRelative = leadingRelative || Expr.relative[" "],
8831 i = leadingRelative ? 1 : 0,
8832
8833 // The foundational matcher ensures that elements are reachable from top-level context(s)
8834 matchContext = addCombinator( function( elem ) {
8835 return elem === checkContext;
8836 }, implicitRelative, true ),
8837 matchAnyContext = addCombinator( function( elem ) {
8838 return indexOf.call( checkContext, elem ) > -1;
8839 }, implicitRelative, true ),
8840 matchers = [ function( elem, context, xml ) {
8841 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
8842 (checkContext = context).nodeType ?
8843 matchContext( elem, context, xml ) :
8844 matchAnyContext( elem, context, xml ) );
8845 } ];
8846
8847 for ( ; i < len; i++ ) {
8848 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
8849 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
8850 } else {
8851 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
8852
8853 // Return special upon seeing a positional matcher
8854 if ( matcher[ expando ] ) {
8855 // Find the next relative operator (if any) for proper handling
8856 j = ++i;
8857 for ( ; j < len; j++ ) {
8858 if ( Expr.relative[ tokens[j].type ] ) {
8859 break;
8860 }
8861 }
8862 return setMatcher(
8863 i > 1 && elementMatcher( matchers ),
8864 i > 1 && toSelector(
8865 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
8866 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
8867 ).replace( rtrim, "$1" ),
8868 matcher,
8869 i < j && matcherFromTokens( tokens.slice( i, j ) ),
8870 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
8871 j < len && toSelector( tokens )
8872 );
8873 }
8874 matchers.push( matcher );
8875 }
8876 }
8877
8878 return elementMatcher( matchers );
8879 }
8880
8881 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
8882 var bySet = setMatchers.length > 0,
8883 byElement = elementMatchers.length > 0,
8884 superMatcher = function( seed, context, xml, results, outermost ) {
8885 var elem, j, matcher,
8886 matchedCount = 0,
8887 i = "0",
8888 unmatched = seed && [],
8889 setMatched = [],
8890 contextBackup = outermostContext,
8891 // We must always have either seed elements or outermost context
8892 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
8893 // Use integer dirruns iff this is the outermost matcher
8894 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
8895 len = elems.length;
8896
8897 if ( outermost ) {
8898 outermostContext = context !== document && context;
8899 }
8900
8901 // Add elements passing elementMatchers directly to results
8902 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
8903 // Support: IE<9, Safari
8904 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
8905 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
8906 if ( byElement && elem ) {
8907 j = 0;
8908 while ( (matcher = elementMatchers[j++]) ) {
8909 if ( matcher( elem, context, xml ) ) {
8910 results.push( elem );
8911 break;
8912 }
8913 }
8914 if ( outermost ) {
8915 dirruns = dirrunsUnique;
8916 }
8917 }
8918
8919 // Track unmatched elements for set filters
8920 if ( bySet ) {
8921 // They will have gone through all possible matchers
8922 if ( (elem = !matcher && elem) ) {
8923 matchedCount--;
8924 }
8925
8926 // Lengthen the array for every element, matched or not
8927 if ( seed ) {
8928 unmatched.push( elem );
8929 }
8930 }
8931 }
8932
8933 // Apply set filters to unmatched elements
8934 matchedCount += i;
8935 if ( bySet && i !== matchedCount ) {
8936 j = 0;
8937 while ( (matcher = setMatchers[j++]) ) {
8938 matcher( unmatched, setMatched, context, xml );
8939 }
8940
8941 if ( seed ) {
8942 // Reintegrate element matches to eliminate the need for sorting
8943 if ( matchedCount > 0 ) {
8944 while ( i-- ) {
8945 if ( !(unmatched[i] || setMatched[i]) ) {
8946 setMatched[i] = pop.call( results );
8947 }
8948 }
8949 }
8950
8951 // Discard index placeholder values to get only actual matches
8952 setMatched = condense( setMatched );
8953 }
8954
8955 // Add matches to results
8956 push.apply( results, setMatched );
8957
8958 // Seedless set matches succeeding multiple successful matchers stipulate sorting
8959 if ( outermost && !seed && setMatched.length > 0 &&
8960 ( matchedCount + setMatchers.length ) > 1 ) {
8961
8962 Sizzle.uniqueSort( results );
8963 }
8964 }
8965
8966 // Override manipulation of globals by nested matchers
8967 if ( outermost ) {
8968 dirruns = dirrunsUnique;
8969 outermostContext = contextBackup;
8970 }
8971
8972 return unmatched;
8973 };
8974
8975 return bySet ?
8976 markFunction( superMatcher ) :
8977 superMatcher;
8978 }
8979
8980 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
8981 var i,
8982 setMatchers = [],
8983 elementMatchers = [],
8984 cached = compilerCache[ selector + " " ];
8985
8986 if ( !cached ) {
8987 // Generate a function of recursive functions that can be used to check each element
8988 if ( !match ) {
8989 match = tokenize( selector );
8990 }
8991 i = match.length;
8992 while ( i-- ) {
8993 cached = matcherFromTokens( match[i] );
8994 if ( cached[ expando ] ) {
8995 setMatchers.push( cached );
8996 } else {
8997 elementMatchers.push( cached );
8998 }
8999 }
9000
9001 // Cache the compiled function
9002 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
9003
9004 // Save selector and tokenization
9005 cached.selector = selector;
9006 }
9007 return cached;
9008 };
9009
9010 /**
9011 * A low-level selection function that works with Sizzle's compiled
9012 * selector functions
9013 * @param {String|Function} selector A selector or a pre-compiled
9014 * selector function built with Sizzle.compile
9015 * @param {Element} context
9016 * @param {Array} [results]
9017 * @param {Array} [seed] A set of elements to match against
9018 */
9019 select = Sizzle.select = function( selector, context, results, seed ) {
9020 var i, tokens, token, type, find,
9021 compiled = typeof selector === "function" && selector,
9022 match = !seed && tokenize( (selector = compiled.selector || selector) );
9023
9024 results = results || [];
9025
9026 // Try to minimize operations if there is no seed and only one group
9027 if ( match.length === 1 ) {
9028
9029 // Take a shortcut and set the context if the root selector is an ID
9030 tokens = match[0] = match[0].slice( 0 );
9031 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
9032 support.getById && context.nodeType === 9 && documentIsHTML &&
9033 Expr.relative[ tokens[1].type ] ) {
9034
9035 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
9036 if ( !context ) {
9037 return results;
9038
9039 // Precompiled matchers will still verify ancestry, so step up a level
9040 } else if ( compiled ) {
9041 context = context.parentNode;
9042 }
9043
9044 selector = selector.slice( tokens.shift().value.length );
9045 }
9046
9047 // Fetch a seed set for right-to-left matching
9048 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
9049 while ( i-- ) {
9050 token = tokens[i];
9051
9052 // Abort if we hit a combinator
9053 if ( Expr.relative[ (type = token.type) ] ) {
9054 break;
9055 }
9056 if ( (find = Expr.find[ type ]) ) {
9057 // Search, expanding context for leading sibling combinators
9058 if ( (seed = find(
9059 token.matches[0].replace( runescape, funescape ),
9060 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
9061 )) ) {
9062
9063 // If seed is empty or no tokens remain, we can return early
9064 tokens.splice( i, 1 );
9065 selector = seed.length && toSelector( tokens );
9066 if ( !selector ) {
9067 push.apply( results, seed );
9068 return results;
9069 }
9070
9071 break;
9072 }
9073 }
9074 }
9075 }
9076
9077 // Compile and execute a filtering function if one is not provided
9078 // Provide `match` to avoid retokenization if we modified the selector above
9079 ( compiled || compile( selector, match ) )(
9080 seed,
9081 context,
9082 !documentIsHTML,
9083 results,
9084 rsibling.test( selector ) && testContext( context.parentNode ) || context
9085 );
9086 return results;
9087 };
9088
9089 // One-time assignments
9090
9091 // Sort stability
9092 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
9093
9094 // Support: Chrome<14
9095 // Always assume duplicates if they aren't passed to the comparison function
9096 support.detectDuplicates = !!hasDuplicate;
9097
9098 // Initialize against the default document
9099 setDocument();
9100
9101 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
9102 // Detached nodes confoundingly follow *each other*
9103 support.sortDetached = assert(function( div1 ) {
9104 // Should return 1, but returns 4 (following)
9105 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
9106 });
9107
9108 // Support: IE<8
9109 // Prevent attribute/property "interpolation"
9110 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
9111 if ( !assert(function( div ) {
9112 div.innerHTML = "<a href='#'></a>";
9113 return div.firstChild.getAttribute("href") === "#" ;
9114 }) ) {
9115 addHandle( "type|href|height|width", function( elem, name, isXML ) {
9116 if ( !isXML ) {
9117 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
9118 }
9119 });
9120 }
9121
9122 // Support: IE<9
9123 // Use defaultValue in place of getAttribute("value")
9124 if ( !support.attributes || !assert(function( div ) {
9125 div.innerHTML = "<input/>";
9126 div.firstChild.setAttribute( "value", "" );
9127 return div.firstChild.getAttribute( "value" ) === "";
9128 }) ) {
9129 addHandle( "value", function( elem, name, isXML ) {
9130 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
9131 return elem.defaultValue;
9132 }
9133 });
9134 }
9135
9136 // Support: IE<9
9137 // Use getAttributeNode to fetch booleans when getAttribute lies
9138 if ( !assert(function( div ) {
9139 return div.getAttribute("disabled") == null;
9140 }) ) {
9141 addHandle( booleans, function( elem, name, isXML ) {
9142 var val;
9143 if ( !isXML ) {
9144 return elem[ name ] === true ? name.toLowerCase() :
9145 (val = elem.getAttributeNode( name )) && val.specified ?
9146 val.value :
9147 null;
9148 }
9149 });
9150 }
9151
9152 return Sizzle;
9153
9154 })( window );
9155
9156
9157
9158 jQuery.find = Sizzle;
9159 jQuery.expr = Sizzle.selectors;
9160 jQuery.expr[":"] = jQuery.expr.pseudos;
9161 jQuery.unique = Sizzle.uniqueSort;
9162 jQuery.text = Sizzle.getText;
9163 jQuery.isXMLDoc = Sizzle.isXML;
9164 jQuery.contains = Sizzle.contains;
9165
9166
9167
9168 var rneedsContext = jQuery.expr.match.needsContext;
9169
9170 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
9171
9172
9173
9174 var risSimple = /^.[^:#\[\.,]*$/;
9175
9176 // Implement the identical functionality for filter and not
9177 function winnow( elements, qualifier, not ) {
9178 if ( jQuery.isFunction( qualifier ) ) {
9179 return jQuery.grep( elements, function( elem, i ) {
9180 /* jshint -W018 */
9181 return !!qualifier.call( elem, i, elem ) !== not;
9182 });
9183
9184 }
9185
9186 if ( qualifier.nodeType ) {
9187 return jQuery.grep( elements, function( elem ) {
9188 return ( elem === qualifier ) !== not;
9189 });
9190
9191 }
9192
9193 if ( typeof qualifier === "string" ) {
9194 if ( risSimple.test( qualifier ) ) {
9195 return jQuery.filter( qualifier, elements, not );
9196 }
9197
9198 qualifier = jQuery.filter( qualifier, elements );
9199 }
9200
9201 return jQuery.grep( elements, function( elem ) {
9202 return ( indexOf.call( qualifier, elem ) >= 0 ) !== not;
9203 });
9204 }
9205
9206 jQuery.filter = function( expr, elems, not ) {
9207 var elem = elems[ 0 ];
9208
9209 if ( not ) {
9210 expr = ":not(" + expr + ")";
9211 }
9212
9213 return elems.length === 1 && elem.nodeType === 1 ?
9214 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
9215 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
9216 return elem.nodeType === 1;
9217 }));
9218 };
9219
9220 jQuery.fn.extend({
9221 find: function( selector ) {
9222 var i,
9223 len = this.length,
9224 ret = [],
9225 self = this;
9226
9227 if ( typeof selector !== "string" ) {
9228 return this.pushStack( jQuery( selector ).filter(function() {
9229 for ( i = 0; i < len; i++ ) {
9230 if ( jQuery.contains( self[ i ], this ) ) {
9231 return true;
9232 }
9233 }
9234 }) );
9235 }
9236
9237 for ( i = 0; i < len; i++ ) {
9238 jQuery.find( selector, self[ i ], ret );
9239 }
9240
9241 // Needed because $( selector, context ) becomes $( context ).find( selector )
9242 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
9243 ret.selector = this.selector ? this.selector + " " + selector : selector;
9244 return ret;
9245 },
9246 filter: function( selector ) {
9247 return this.pushStack( winnow(this, selector || [], false) );
9248 },
9249 not: function( selector ) {
9250 return this.pushStack( winnow(this, selector || [], true) );
9251 },
9252 is: function( selector ) {
9253 return !!winnow(
9254 this,
9255
9256 // If this is a positional/relative selector, check membership in the returned set
9257 // so $("p:first").is("p:last") won't return true for a doc with two "p".
9258 typeof selector === "string" && rneedsContext.test( selector ) ?
9259 jQuery( selector ) :
9260 selector || [],
9261 false
9262 ).length;
9263 }
9264 });
9265
9266
9267 // Initialize a jQuery object
9268
9269
9270 // A central reference to the root jQuery(document)
9271 var rootjQuery,
9272
9273 // A simple way to check for HTML strings
9274 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
9275 // Strict HTML recognition (#11290: must start with <)
9276 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
9277
9278 init = jQuery.fn.init = function( selector, context ) {
9279 var match, elem;
9280
9281 // HANDLE: $(""), $(null), $(undefined), $(false)
9282 if ( !selector ) {
9283 return this;
9284 }
9285
9286 // Handle HTML strings
9287 if ( typeof selector === "string" ) {
9288 if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) {
9289 // Assume that strings that start and end with <> are HTML and skip the regex check
9290 match = [ null, selector, null ];
9291
9292 } else {
9293 match = rquickExpr.exec( selector );
9294 }
9295
9296 // Match html or make sure no context is specified for #id
9297 if ( match && (match[1] || !context) ) {
9298
9299 // HANDLE: $(html) -> $(array)
9300 if ( match[1] ) {
9301 context = context instanceof jQuery ? context[0] : context;
9302
9303 // scripts is true for back-compat
9304 // Intentionally let the error be thrown if parseHTML is not present
9305 jQuery.merge( this, jQuery.parseHTML(
9306 match[1],
9307 context && context.nodeType ? context.ownerDocument || context : document,
9308 true
9309 ) );
9310
9311 // HANDLE: $(html, props)
9312 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
9313 for ( match in context ) {
9314 // Properties of context are called as methods if possible
9315 if ( jQuery.isFunction( this[ match ] ) ) {
9316 this[ match ]( context[ match ] );
9317
9318 // ...and otherwise set as attributes
9319 } else {
9320 this.attr( match, context[ match ] );
9321 }
9322 }
9323 }
9324
9325 return this;
9326
9327 // HANDLE: $(#id)
9328 } else {
9329 elem = document.getElementById( match[2] );
9330
9331 // Check parentNode to catch when Blackberry 4.6 returns
9332 // nodes that are no longer in the document #6963
9333 if ( elem && elem.parentNode ) {
9334 // Inject the element directly into the jQuery object
9335 this.length = 1;
9336 this[0] = elem;
9337 }
9338
9339 this.context = document;
9340 this.selector = selector;
9341 return this;
9342 }
9343
9344 // HANDLE: $(expr, $(...))
9345 } else if ( !context || context.jquery ) {
9346 return ( context || rootjQuery ).find( selector );
9347
9348 // HANDLE: $(expr, context)
9349 // (which is just equivalent to: $(context).find(expr)
9350 } else {
9351 return this.constructor( context ).find( selector );
9352 }
9353
9354 // HANDLE: $(DOMElement)
9355 } else if ( selector.nodeType ) {
9356 this.context = this[0] = selector;
9357 this.length = 1;
9358 return this;
9359
9360 // HANDLE: $(function)
9361 // Shortcut for document ready
9362 } else if ( jQuery.isFunction( selector ) ) {
9363 return typeof rootjQuery.ready !== "undefined" ?
9364 rootjQuery.ready( selector ) :
9365 // Execute immediately if ready is not present
9366 selector( jQuery );
9367 }
9368
9369 if ( selector.selector !== undefined ) {
9370 this.selector = selector.selector;
9371 this.context = selector.context;
9372 }
9373
9374 return jQuery.makeArray( selector, this );
9375 };
9376
9377 // Give the init function the jQuery prototype for later instantiation
9378 init.prototype = jQuery.fn;
9379
9380 // Initialize central reference
9381 rootjQuery = jQuery( document );
9382
9383
9384 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
9385 // methods guaranteed to produce a unique set when starting from a unique set
9386 guaranteedUnique = {
9387 children: true,
9388 contents: true,
9389 next: true,
9390 prev: true
9391 };
9392
9393 jQuery.extend({
9394 dir: function( elem, dir, until ) {
9395 var matched = [],
9396 truncate = until !== undefined;
9397
9398 while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) {
9399 if ( elem.nodeType === 1 ) {
9400 if ( truncate && jQuery( elem ).is( until ) ) {
9401 break;
9402 }
9403 matched.push( elem );
9404 }
9405 }
9406 return matched;
9407 },
9408
9409 sibling: function( n, elem ) {
9410 var matched = [];
9411
9412 for ( ; n; n = n.nextSibling ) {
9413 if ( n.nodeType === 1 && n !== elem ) {
9414 matched.push( n );
9415 }
9416 }
9417
9418 return matched;
9419 }
9420 });
9421
9422 jQuery.fn.extend({
9423 has: function( target ) {
9424 var targets = jQuery( target, this ),
9425 l = targets.length;
9426
9427 return this.filter(function() {
9428 var i = 0;
9429 for ( ; i < l; i++ ) {
9430 if ( jQuery.contains( this, targets[i] ) ) {
9431 return true;
9432 }
9433 }
9434 });
9435 },
9436
9437 closest: function( selectors, context ) {
9438 var cur,
9439 i = 0,
9440 l = this.length,
9441 matched = [],
9442 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
9443 jQuery( selectors, context || this.context ) :
9444 0;
9445
9446 for ( ; i < l; i++ ) {
9447 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
9448 // Always skip document fragments
9449 if ( cur.nodeType < 11 && (pos ?
9450 pos.index(cur) > -1 :
9451
9452 // Don't pass non-elements to Sizzle
9453 cur.nodeType === 1 &&
9454 jQuery.find.matchesSelector(cur, selectors)) ) {
9455
9456 matched.push( cur );
9457 break;
9458 }
9459 }
9460 }
9461
9462 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
9463 },
9464
9465 // Determine the position of an element within
9466 // the matched set of elements
9467 index: function( elem ) {
9468
9469 // No argument, return index in parent
9470 if ( !elem ) {
9471 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
9472 }
9473
9474 // index in selector
9475 if ( typeof elem === "string" ) {
9476 return indexOf.call( jQuery( elem ), this[ 0 ] );
9477 }
9478
9479 // Locate the position of the desired element
9480 return indexOf.call( this,
9481
9482 // If it receives a jQuery object, the first element is used
9483 elem.jquery ? elem[ 0 ] : elem
9484 );
9485 },
9486
9487 add: function( selector, context ) {
9488 return this.pushStack(
9489 jQuery.unique(
9490 jQuery.merge( this.get(), jQuery( selector, context ) )
9491 )
9492 );
9493 },
9494
9495 addBack: function( selector ) {
9496 return this.add( selector == null ?
9497 this.prevObject : this.prevObject.filter(selector)
9498 );
9499 }
9500 });
9501
9502 function sibling( cur, dir ) {
9503 while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {}
9504 return cur;
9505 }
9506
9507 jQuery.each({
9508 parent: function( elem ) {
9509 var parent = elem.parentNode;
9510 return parent && parent.nodeType !== 11 ? parent : null;
9511 },
9512 parents: function( elem ) {
9513 return jQuery.dir( elem, "parentNode" );
9514 },
9515 parentsUntil: function( elem, i, until ) {
9516 return jQuery.dir( elem, "parentNode", until );
9517 },
9518 next: function( elem ) {
9519 return sibling( elem, "nextSibling" );
9520 },
9521 prev: function( elem ) {
9522 return sibling( elem, "previousSibling" );
9523 },
9524 nextAll: function( elem ) {
9525 return jQuery.dir( elem, "nextSibling" );
9526 },
9527 prevAll: function( elem ) {
9528 return jQuery.dir( elem, "previousSibling" );
9529 },
9530 nextUntil: function( elem, i, until ) {
9531 return jQuery.dir( elem, "nextSibling", until );
9532 },
9533 prevUntil: function( elem, i, until ) {
9534 return jQuery.dir( elem, "previousSibling", until );
9535 },
9536 siblings: function( elem ) {
9537 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
9538 },
9539 children: function( elem ) {
9540 return jQuery.sibling( elem.firstChild );
9541 },
9542 contents: function( elem ) {
9543 return elem.contentDocument || jQuery.merge( [], elem.childNodes );
9544 }
9545 }, function( name, fn ) {
9546 jQuery.fn[ name ] = function( until, selector ) {
9547 var matched = jQuery.map( this, fn, until );
9548
9549 if ( name.slice( -5 ) !== "Until" ) {
9550 selector = until;
9551 }
9552
9553 if ( selector && typeof selector === "string" ) {
9554 matched = jQuery.filter( selector, matched );
9555 }
9556
9557 if ( this.length > 1 ) {
9558 // Remove duplicates
9559 if ( !guaranteedUnique[ name ] ) {
9560 jQuery.unique( matched );
9561 }
9562
9563 // Reverse order for parents* and prev-derivatives
9564 if ( rparentsprev.test( name ) ) {
9565 matched.reverse();
9566 }
9567 }
9568
9569 return this.pushStack( matched );
9570 };
9571 });
9572 var rnotwhite = (/\S+/g);
9573
9574
9575
9576 // String to Object options format cache
9577 var optionsCache = {};
9578
9579 // Convert String-formatted options into Object-formatted ones and store in cache
9580 function createOptions( options ) {
9581 var object = optionsCache[ options ] = {};
9582 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
9583 object[ flag ] = true;
9584 });
9585 return object;
9586 }
9587
9588 /*
9589 * Create a callback list using the following parameters:
9590 *
9591 * options: an optional list of space-separated options that will change how
9592 * the callback list behaves or a more traditional option object
9593 *
9594 * By default a callback list will act like an event callback list and can be
9595 * "fired" multiple times.
9596 *
9597 * Possible options:
9598 *
9599 * once: will ensure the callback list can only be fired once (like a Deferred)
9600 *
9601 * memory: will keep track of previous values and will call any callback added
9602 * after the list has been fired right away with the latest "memorized"
9603 * values (like a Deferred)
9604 *
9605 * unique: will ensure a callback can only be added once (no duplicate in the list)
9606 *
9607 * stopOnFalse: interrupt callings when a callback returns false
9608 *
9609 */
9610 jQuery.Callbacks = function( options ) {
9611
9612 // Convert options from String-formatted to Object-formatted if needed
9613 // (we check in cache first)
9614 options = typeof options === "string" ?
9615 ( optionsCache[ options ] || createOptions( options ) ) :
9616 jQuery.extend( {}, options );
9617
9618 var // Last fire value (for non-forgettable lists)
9619 memory,
9620 // Flag to know if list was already fired
9621 fired,
9622 // Flag to know if list is currently firing
9623 firing,
9624 // First callback to fire (used internally by add and fireWith)
9625 firingStart,
9626 // End of the loop when firing
9627 firingLength,
9628 // Index of currently firing callback (modified by remove if needed)
9629 firingIndex,
9630 // Actual callback list
9631 list = [],
9632 // Stack of fire calls for repeatable lists
9633 stack = !options.once && [],
9634 // Fire callbacks
9635 fire = function( data ) {
9636 memory = options.memory && data;
9637 fired = true;
9638 firingIndex = firingStart || 0;
9639 firingStart = 0;
9640 firingLength = list.length;
9641 firing = true;
9642 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
9643 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
9644 memory = false; // To prevent further calls using add
9645 break;
9646 }
9647 }
9648 firing = false;
9649 if ( list ) {
9650 if ( stack ) {
9651 if ( stack.length ) {
9652 fire( stack.shift() );
9653 }
9654 } else if ( memory ) {
9655 list = [];
9656 } else {
9657 self.disable();
9658 }
9659 }
9660 },
9661 // Actual Callbacks object
9662 self = {
9663 // Add a callback or a collection of callbacks to the list
9664 add: function() {
9665 if ( list ) {
9666 // First, we save the current length
9667 var start = list.length;
9668 (function add( args ) {
9669 jQuery.each( args, function( _, arg ) {
9670 var type = jQuery.type( arg );
9671 if ( type === "function" ) {
9672 if ( !options.unique || !self.has( arg ) ) {
9673 list.push( arg );
9674 }
9675 } else if ( arg && arg.length && type !== "string" ) {
9676 // Inspect recursively
9677 add( arg );
9678 }
9679 });
9680 })( arguments );
9681 // Do we need to add the callbacks to the
9682 // current firing batch?
9683 if ( firing ) {
9684 firingLength = list.length;
9685 // With memory, if we're not firing then
9686 // we should call right away
9687 } else if ( memory ) {
9688 firingStart = start;
9689 fire( memory );
9690 }
9691 }
9692 return this;
9693 },
9694 // Remove a callback from the list
9695 remove: function() {
9696 if ( list ) {
9697 jQuery.each( arguments, function( _, arg ) {
9698 var index;
9699 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
9700 list.splice( index, 1 );
9701 // Handle firing indexes
9702 if ( firing ) {
9703 if ( index <= firingLength ) {
9704 firingLength--;
9705 }
9706 if ( index <= firingIndex ) {
9707 firingIndex--;
9708 }
9709 }
9710 }
9711 });
9712 }
9713 return this;
9714 },
9715 // Check if a given callback is in the list.
9716 // If no argument is given, return whether or not list has callbacks attached.
9717 has: function( fn ) {
9718 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
9719 },
9720 // Remove all callbacks from the list
9721 empty: function() {
9722 list = [];
9723 firingLength = 0;
9724 return this;
9725 },
9726 // Have the list do nothing anymore
9727 disable: function() {
9728 list = stack = memory = undefined;
9729 return this;
9730 },
9731 // Is it disabled?
9732 disabled: function() {
9733 return !list;
9734 },
9735 // Lock the list in its current state
9736 lock: function() {
9737 stack = undefined;
9738 if ( !memory ) {
9739 self.disable();
9740 }
9741 return this;
9742 },
9743 // Is it locked?
9744 locked: function() {
9745 return !stack;
9746 },
9747 // Call all callbacks with the given context and arguments
9748 fireWith: function( context, args ) {
9749 if ( list && ( !fired || stack ) ) {
9750 args = args || [];
9751 args = [ context, args.slice ? args.slice() : args ];
9752 if ( firing ) {
9753 stack.push( args );
9754 } else {
9755 fire( args );
9756 }
9757 }
9758 return this;
9759 },
9760 // Call all the callbacks with the given arguments
9761 fire: function() {
9762 self.fireWith( this, arguments );
9763 return this;
9764 },
9765 // To know if the callbacks have already been called at least once
9766 fired: function() {
9767 return !!fired;
9768 }
9769 };
9770
9771 return self;
9772 };
9773
9774
9775 jQuery.extend({
9776
9777 Deferred: function( func ) {
9778 var tuples = [
9779 // action, add listener, listener list, final state
9780 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
9781 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
9782 [ "notify", "progress", jQuery.Callbacks("memory") ]
9783 ],
9784 state = "pending",
9785 promise = {
9786 state: function() {
9787 return state;
9788 },
9789 always: function() {
9790 deferred.done( arguments ).fail( arguments );
9791 return this;
9792 },
9793 then: function( /* fnDone, fnFail, fnProgress */ ) {
9794 var fns = arguments;
9795 return jQuery.Deferred(function( newDefer ) {
9796 jQuery.each( tuples, function( i, tuple ) {
9797 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
9798 // deferred[ done | fail | progress ] for forwarding actions to newDefer
9799 deferred[ tuple[1] ](function() {
9800 var returned = fn && fn.apply( this, arguments );
9801 if ( returned && jQuery.isFunction( returned.promise ) ) {
9802 returned.promise()
9803 .done( newDefer.resolve )
9804 .fail( newDefer.reject )
9805 .progress( newDefer.notify );
9806 } else {
9807 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
9808 }
9809 });
9810 });
9811 fns = null;
9812 }).promise();
9813 },
9814 // Get a promise for this deferred
9815 // If obj is provided, the promise aspect is added to the object
9816 promise: function( obj ) {
9817 return obj != null ? jQuery.extend( obj, promise ) : promise;
9818 }
9819 },
9820 deferred = {};
9821
9822 // Keep pipe for back-compat
9823 promise.pipe = promise.then;
9824
9825 // Add list-specific methods
9826 jQuery.each( tuples, function( i, tuple ) {
9827 var list = tuple[ 2 ],
9828 stateString = tuple[ 3 ];
9829
9830 // promise[ done | fail | progress ] = list.add
9831 promise[ tuple[1] ] = list.add;
9832
9833 // Handle state
9834 if ( stateString ) {
9835 list.add(function() {
9836 // state = [ resolved | rejected ]
9837 state = stateString;
9838
9839 // [ reject_list | resolve_list ].disable; progress_list.lock
9840 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
9841 }
9842
9843 // deferred[ resolve | reject | notify ]
9844 deferred[ tuple[0] ] = function() {
9845 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
9846 return this;
9847 };
9848 deferred[ tuple[0] + "With" ] = list.fireWith;
9849 });
9850
9851 // Make the deferred a promise
9852 promise.promise( deferred );
9853
9854 // Call given func if any
9855 if ( func ) {
9856 func.call( deferred, deferred );
9857 }
9858
9859 // All done!
9860 return deferred;
9861 },
9862
9863 // Deferred helper
9864 when: function( subordinate /* , ..., subordinateN */ ) {
9865 var i = 0,
9866 resolveValues = slice.call( arguments ),
9867 length = resolveValues.length,
9868
9869 // the count of uncompleted subordinates
9870 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
9871
9872 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
9873 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
9874
9875 // Update function for both resolve and progress values
9876 updateFunc = function( i, contexts, values ) {
9877 return function( value ) {
9878 contexts[ i ] = this;
9879 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
9880 if ( values === progressValues ) {
9881 deferred.notifyWith( contexts, values );
9882 } else if ( !( --remaining ) ) {
9883 deferred.resolveWith( contexts, values );
9884 }
9885 };
9886 },
9887
9888 progressValues, progressContexts, resolveContexts;
9889
9890 // add listeners to Deferred subordinates; treat others as resolved
9891 if ( length > 1 ) {
9892 progressValues = new Array( length );
9893 progressContexts = new Array( length );
9894 resolveContexts = new Array( length );
9895 for ( ; i < length; i++ ) {
9896 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
9897 resolveValues[ i ].promise()
9898 .done( updateFunc( i, resolveContexts, resolveValues ) )
9899 .fail( deferred.reject )
9900 .progress( updateFunc( i, progressContexts, progressValues ) );
9901 } else {
9902 --remaining;
9903 }
9904 }
9905 }
9906
9907 // if we're not waiting on anything, resolve the master
9908 if ( !remaining ) {
9909 deferred.resolveWith( resolveContexts, resolveValues );
9910 }
9911
9912 return deferred.promise();
9913 }
9914 });
9915
9916
9917 // The deferred used on DOM ready
9918 var readyList;
9919
9920 jQuery.fn.ready = function( fn ) {
9921 // Add the callback
9922 jQuery.ready.promise().done( fn );
9923
9924 return this;
9925 };
9926
9927 jQuery.extend({
9928 // Is the DOM ready to be used? Set to true once it occurs.
9929 isReady: false,
9930
9931 // A counter to track how many items to wait for before
9932 // the ready event fires. See #6781
9933 readyWait: 1,
9934
9935 // Hold (or release) the ready event
9936 holdReady: function( hold ) {
9937 if ( hold ) {
9938 jQuery.readyWait++;
9939 } else {
9940 jQuery.ready( true );
9941 }
9942 },
9943
9944 // Handle when the DOM is ready
9945 ready: function( wait ) {
9946
9947 // Abort if there are pending holds or we're already ready
9948 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
9949 return;
9950 }
9951
9952 // Remember that the DOM is ready
9953 jQuery.isReady = true;
9954
9955 // If a normal DOM Ready event fired, decrement, and wait if need be
9956 if ( wait !== true && --jQuery.readyWait > 0 ) {
9957 return;
9958 }
9959
9960 // If there are functions bound, to execute
9961 readyList.resolveWith( document, [ jQuery ] );
9962
9963 // Trigger any bound ready events
9964 if ( jQuery.fn.triggerHandler ) {
9965 jQuery( document ).triggerHandler( "ready" );
9966 jQuery( document ).off( "ready" );
9967 }
9968 }
9969 });
9970
9971 /**
9972 * The ready event handler and self cleanup method
9973 */
9974 function completed() {
9975 document.removeEventListener( "DOMContentLoaded", completed, false );
9976 window.removeEventListener( "load", completed, false );
9977 jQuery.ready();
9978 }
9979
9980 jQuery.ready.promise = function( obj ) {
9981 if ( !readyList ) {
9982
9983 readyList = jQuery.Deferred();
9984
9985 // Catch cases where $(document).ready() is called after the browser event has already occurred.
9986 // we once tried to use readyState "interactive" here, but it caused issues like the one
9987 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
9988 if ( document.readyState === "complete" ) {
9989 // Handle it asynchronously to allow scripts the opportunity to delay ready
9990 setTimeout( jQuery.ready );
9991
9992 } else {
9993
9994 // Use the handy event callback
9995 document.addEventListener( "DOMContentLoaded", completed, false );
9996
9997 // A fallback to window.onload, that will always work
9998 window.addEventListener( "load", completed, false );
9999 }
10000 }
10001 return readyList.promise( obj );
10002 };
10003
10004 // Kick off the DOM ready check even if the user does not
10005 jQuery.ready.promise();
10006
10007
10008
10009
10010 // Multifunctional method to get and set values of a collection
10011 // The value/s can optionally be executed if it's a function
10012 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
10013 var i = 0,
10014 len = elems.length,
10015 bulk = key == null;
10016
10017 // Sets many values
10018 if ( jQuery.type( key ) === "object" ) {
10019 chainable = true;
10020 for ( i in key ) {
10021 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
10022 }
10023
10024 // Sets one value
10025 } else if ( value !== undefined ) {
10026 chainable = true;
10027
10028 if ( !jQuery.isFunction( value ) ) {
10029 raw = true;
10030 }
10031
10032 if ( bulk ) {
10033 // Bulk operations run against the entire set
10034 if ( raw ) {
10035 fn.call( elems, value );
10036 fn = null;
10037
10038 // ...except when executing function values
10039 } else {
10040 bulk = fn;
10041 fn = function( elem, key, value ) {
10042 return bulk.call( jQuery( elem ), value );
10043 };
10044 }
10045 }
10046
10047 if ( fn ) {
10048 for ( ; i < len; i++ ) {
10049 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
10050 }
10051 }
10052 }
10053
10054 return chainable ?
10055 elems :
10056
10057 // Gets
10058 bulk ?
10059 fn.call( elems ) :
10060 len ? fn( elems[0], key ) : emptyGet;
10061 };
10062
10063
10064 /**
10065 * Determines whether an object can have data
10066 */
10067 jQuery.acceptData = function( owner ) {
10068 // Accepts only:
10069 // - Node
10070 // - Node.ELEMENT_NODE
10071 // - Node.DOCUMENT_NODE
10072 // - Object
10073 // - Any
10074 /* jshint -W018 */
10075 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
10076 };
10077
10078
10079 function Data() {
10080 // Support: Android < 4,
10081 // Old WebKit does not have Object.preventExtensions/freeze method,
10082 // return new empty object instead with no [[set]] accessor
10083 Object.defineProperty( this.cache = {}, 0, {
10084 get: function() {
10085 return {};
10086 }
10087 });
10088
10089 this.expando = jQuery.expando + Math.random();
10090 }
10091
10092 Data.uid = 1;
10093 Data.accepts = jQuery.acceptData;
10094
10095 Data.prototype = {
10096 key: function( owner ) {
10097 // We can accept data for non-element nodes in modern browsers,
10098 // but we should not, see #8335.
10099 // Always return the key for a frozen object.
10100 if ( !Data.accepts( owner ) ) {
10101 return 0;
10102 }
10103
10104 var descriptor = {},
10105 // Check if the owner object already has a cache key
10106 unlock = owner[ this.expando ];
10107
10108 // If not, create one
10109 if ( !unlock ) {
10110 unlock = Data.uid++;
10111
10112 // Secure it in a non-enumerable, non-writable property
10113 try {
10114 descriptor[ this.expando ] = { value: unlock };
10115 Object.defineProperties( owner, descriptor );
10116
10117 // Support: Android < 4
10118 // Fallback to a less secure definition
10119 } catch ( e ) {
10120 descriptor[ this.expando ] = unlock;
10121 jQuery.extend( owner, descriptor );
10122 }
10123 }
10124
10125 // Ensure the cache object
10126 if ( !this.cache[ unlock ] ) {
10127 this.cache[ unlock ] = {};
10128 }
10129
10130 return unlock;
10131 },
10132 set: function( owner, data, value ) {
10133 var prop,
10134 // There may be an unlock assigned to this node,
10135 // if there is no entry for this "owner", create one inline
10136 // and set the unlock as though an owner entry had always existed
10137 unlock = this.key( owner ),
10138 cache = this.cache[ unlock ];
10139
10140 // Handle: [ owner, key, value ] args
10141 if ( typeof data === "string" ) {
10142 cache[ data ] = value;
10143
10144 // Handle: [ owner, { properties } ] args
10145 } else {
10146 // Fresh assignments by object are shallow copied
10147 if ( jQuery.isEmptyObject( cache ) ) {
10148 jQuery.extend( this.cache[ unlock ], data );
10149 // Otherwise, copy the properties one-by-one to the cache object
10150 } else {
10151 for ( prop in data ) {
10152 cache[ prop ] = data[ prop ];
10153 }
10154 }
10155 }
10156 return cache;
10157 },
10158 get: function( owner, key ) {
10159 // Either a valid cache is found, or will be created.
10160 // New caches will be created and the unlock returned,
10161 // allowing direct access to the newly created
10162 // empty data object. A valid owner object must be provided.
10163 var cache = this.cache[ this.key( owner ) ];
10164
10165 return key === undefined ?
10166 cache : cache[ key ];
10167 },
10168 access: function( owner, key, value ) {
10169 var stored;
10170 // In cases where either:
10171 //
10172 // 1. No key was specified
10173 // 2. A string key was specified, but no value provided
10174 //
10175 // Take the "read" path and allow the get method to determine
10176 // which value to return, respectively either:
10177 //
10178 // 1. The entire cache object
10179 // 2. The data stored at the key
10180 //
10181 if ( key === undefined ||
10182 ((key && typeof key === "string") && value === undefined) ) {
10183
10184 stored = this.get( owner, key );
10185
10186 return stored !== undefined ?
10187 stored : this.get( owner, jQuery.camelCase(key) );
10188 }
10189
10190 // [*]When the key is not a string, or both a key and value
10191 // are specified, set or extend (existing objects) with either:
10192 //
10193 // 1. An object of properties
10194 // 2. A key and value
10195 //
10196 this.set( owner, key, value );
10197
10198 // Since the "set" path can have two possible entry points
10199 // return the expected data based on which path was taken[*]
10200 return value !== undefined ? value : key;
10201 },
10202 remove: function( owner, key ) {
10203 var i, name, camel,
10204 unlock = this.key( owner ),
10205 cache = this.cache[ unlock ];
10206
10207 if ( key === undefined ) {
10208 this.cache[ unlock ] = {};
10209
10210 } else {
10211 // Support array or space separated string of keys
10212 if ( jQuery.isArray( key ) ) {
10213 // If "name" is an array of keys...
10214 // When data is initially created, via ("key", "val") signature,
10215 // keys will be converted to camelCase.
10216 // Since there is no way to tell _how_ a key was added, remove
10217 // both plain key and camelCase key. #12786
10218 // This will only penalize the array argument path.
10219 name = key.concat( key.map( jQuery.camelCase ) );
10220 } else {
10221 camel = jQuery.camelCase( key );
10222 // Try the string as a key before any manipulation
10223 if ( key in cache ) {
10224 name = [ key, camel ];
10225 } else {
10226 // If a key with the spaces exists, use it.
10227 // Otherwise, create an array by matching non-whitespace
10228 name = camel;
10229 name = name in cache ?
10230 [ name ] : ( name.match( rnotwhite ) || [] );
10231 }
10232 }
10233
10234 i = name.length;
10235 while ( i-- ) {
10236 delete cache[ name[ i ] ];
10237 }
10238 }
10239 },
10240 hasData: function( owner ) {
10241 return !jQuery.isEmptyObject(
10242 this.cache[ owner[ this.expando ] ] || {}
10243 );
10244 },
10245 discard: function( owner ) {
10246 if ( owner[ this.expando ] ) {
10247 delete this.cache[ owner[ this.expando ] ];
10248 }
10249 }
10250 };
10251 var data_priv = new Data();
10252
10253 var data_user = new Data();
10254
10255
10256
10257 /*
10258 Implementation Summary
10259
10260 1. Enforce API surface and semantic compatibility with 1.9.x branch
10261 2. Improve the module's maintainability by reducing the storage
10262 paths to a single mechanism.
10263 3. Use the same single mechanism to support "private" and "user" data.
10264 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
10265 5. Avoid exposing implementation details on user objects (eg. expando properties)
10266 6. Provide a clear path for implementation upgrade to WeakMap in 2014
10267 */
10268 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
10269 rmultiDash = /([A-Z])/g;
10270
10271 function dataAttr( elem, key, data ) {
10272 var name;
10273
10274 // If nothing was found internally, try to fetch any
10275 // data from the HTML5 data-* attribute
10276 if ( data === undefined && elem.nodeType === 1 ) {
10277 name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
10278 data = elem.getAttribute( name );
10279
10280 if ( typeof data === "string" ) {
10281 try {
10282 data = data === "true" ? true :
10283 data === "false" ? false :
10284 data === "null" ? null :
10285 // Only convert to a number if it doesn't change the string
10286 +data + "" === data ? +data :
10287 rbrace.test( data ) ? jQuery.parseJSON( data ) :
10288 data;
10289 } catch( e ) {}
10290
10291 // Make sure we set the data so it isn't changed later
10292 data_user.set( elem, key, data );
10293 } else {
10294 data = undefined;
10295 }
10296 }
10297 return data;
10298 }
10299
10300 jQuery.extend({
10301 hasData: function( elem ) {
10302 return data_user.hasData( elem ) || data_priv.hasData( elem );
10303 },
10304
10305 data: function( elem, name, data ) {
10306 return data_user.access( elem, name, data );
10307 },
10308
10309 removeData: function( elem, name ) {
10310 data_user.remove( elem, name );
10311 },
10312
10313 // TODO: Now that all calls to _data and _removeData have been replaced
10314 // with direct calls to data_priv methods, these can be deprecated.
10315 _data: function( elem, name, data ) {
10316 return data_priv.access( elem, name, data );
10317 },
10318
10319 _removeData: function( elem, name ) {
10320 data_priv.remove( elem, name );
10321 }
10322 });
10323
10324 jQuery.fn.extend({
10325 data: function( key, value ) {
10326 var i, name, data,
10327 elem = this[ 0 ],
10328 attrs = elem && elem.attributes;
10329
10330 // Gets all values
10331 if ( key === undefined ) {
10332 if ( this.length ) {
10333 data = data_user.get( elem );
10334
10335 if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
10336 i = attrs.length;
10337 while ( i-- ) {
10338
10339 // Support: IE11+
10340 // The attrs elements can be null (#14894)
10341 if ( attrs[ i ] ) {
10342 name = attrs[ i ].name;
10343 if ( name.indexOf( "data-" ) === 0 ) {
10344 name = jQuery.camelCase( name.slice(5) );
10345 dataAttr( elem, name, data[ name ] );
10346 }
10347 }
10348 }
10349 data_priv.set( elem, "hasDataAttrs", true );
10350 }
10351 }
10352
10353 return data;
10354 }
10355
10356 // Sets multiple values
10357 if ( typeof key === "object" ) {
10358 return this.each(function() {
10359 data_user.set( this, key );
10360 });
10361 }
10362
10363 return access( this, function( value ) {
10364 var data,
10365 camelKey = jQuery.camelCase( key );
10366
10367 // The calling jQuery object (element matches) is not empty
10368 // (and therefore has an element appears at this[ 0 ]) and the
10369 // `value` parameter was not undefined. An empty jQuery object
10370 // will result in `undefined` for elem = this[ 0 ] which will
10371 // throw an exception if an attempt to read a data cache is made.
10372 if ( elem && value === undefined ) {
10373 // Attempt to get data from the cache
10374 // with the key as-is
10375 data = data_user.get( elem, key );
10376 if ( data !== undefined ) {
10377 return data;
10378 }
10379
10380 // Attempt to get data from the cache
10381 // with the key camelized
10382 data = data_user.get( elem, camelKey );
10383 if ( data !== undefined ) {
10384 return data;
10385 }
10386
10387 // Attempt to "discover" the data in
10388 // HTML5 custom data-* attrs
10389 data = dataAttr( elem, camelKey, undefined );
10390 if ( data !== undefined ) {
10391 return data;
10392 }
10393
10394 // We tried really hard, but the data doesn't exist.
10395 return;
10396 }
10397
10398 // Set the data...
10399 this.each(function() {
10400 // First, attempt to store a copy or reference of any
10401 // data that might've been store with a camelCased key.
10402 var data = data_user.get( this, camelKey );
10403
10404 // For HTML5 data-* attribute interop, we have to
10405 // store property names with dashes in a camelCase form.
10406 // This might not apply to all properties...*
10407 data_user.set( this, camelKey, value );
10408
10409 // *... In the case of properties that might _actually_
10410 // have dashes, we need to also store a copy of that
10411 // unchanged property.
10412 if ( key.indexOf("-") !== -1 && data !== undefined ) {
10413 data_user.set( this, key, value );
10414 }
10415 });
10416 }, null, value, arguments.length > 1, null, true );
10417 },
10418
10419 removeData: function( key ) {
10420 return this.each(function() {
10421 data_user.remove( this, key );
10422 });
10423 }
10424 });
10425
10426
10427 jQuery.extend({
10428 queue: function( elem, type, data ) {
10429 var queue;
10430
10431 if ( elem ) {
10432 type = ( type || "fx" ) + "queue";
10433 queue = data_priv.get( elem, type );
10434
10435 // Speed up dequeue by getting out quickly if this is just a lookup
10436 if ( data ) {
10437 if ( !queue || jQuery.isArray( data ) ) {
10438 queue = data_priv.access( elem, type, jQuery.makeArray(data) );
10439 } else {
10440 queue.push( data );
10441 }
10442 }
10443 return queue || [];
10444 }
10445 },
10446
10447 dequeue: function( elem, type ) {
10448 type = type || "fx";
10449
10450 var queue = jQuery.queue( elem, type ),
10451 startLength = queue.length,
10452 fn = queue.shift(),
10453 hooks = jQuery._queueHooks( elem, type ),
10454 next = function() {
10455 jQuery.dequeue( elem, type );
10456 };
10457
10458 // If the fx queue is dequeued, always remove the progress sentinel
10459 if ( fn === "inprogress" ) {
10460 fn = queue.shift();
10461 startLength--;
10462 }
10463
10464 if ( fn ) {
10465
10466 // Add a progress sentinel to prevent the fx queue from being
10467 // automatically dequeued
10468 if ( type === "fx" ) {
10469 queue.unshift( "inprogress" );
10470 }
10471
10472 // clear up the last queue stop function
10473 delete hooks.stop;
10474 fn.call( elem, next, hooks );
10475 }
10476
10477 if ( !startLength && hooks ) {
10478 hooks.empty.fire();
10479 }
10480 },
10481
10482 // not intended for public consumption - generates a queueHooks object, or returns the current one
10483 _queueHooks: function( elem, type ) {
10484 var key = type + "queueHooks";
10485 return data_priv.get( elem, key ) || data_priv.access( elem, key, {
10486 empty: jQuery.Callbacks("once memory").add(function() {
10487 data_priv.remove( elem, [ type + "queue", key ] );
10488 })
10489 });
10490 }
10491 });
10492
10493 jQuery.fn.extend({
10494 queue: function( type, data ) {
10495 var setter = 2;
10496
10497 if ( typeof type !== "string" ) {
10498 data = type;
10499 type = "fx";
10500 setter--;
10501 }
10502
10503 if ( arguments.length < setter ) {
10504 return jQuery.queue( this[0], type );
10505 }
10506
10507 return data === undefined ?
10508 this :
10509 this.each(function() {
10510 var queue = jQuery.queue( this, type, data );
10511
10512 // ensure a hooks for this queue
10513 jQuery._queueHooks( this, type );
10514
10515 if ( type === "fx" && queue[0] !== "inprogress" ) {
10516 jQuery.dequeue( this, type );
10517 }
10518 });
10519 },
10520 dequeue: function( type ) {
10521 return this.each(function() {
10522 jQuery.dequeue( this, type );
10523 });
10524 },
10525 clearQueue: function( type ) {
10526 return this.queue( type || "fx", [] );
10527 },
10528 // Get a promise resolved when queues of a certain type
10529 // are emptied (fx is the type by default)
10530 promise: function( type, obj ) {
10531 var tmp,
10532 count = 1,
10533 defer = jQuery.Deferred(),
10534 elements = this,
10535 i = this.length,
10536 resolve = function() {
10537 if ( !( --count ) ) {
10538 defer.resolveWith( elements, [ elements ] );
10539 }
10540 };
10541
10542 if ( typeof type !== "string" ) {
10543 obj = type;
10544 type = undefined;
10545 }
10546 type = type || "fx";
10547
10548 while ( i-- ) {
10549 tmp = data_priv.get( elements[ i ], type + "queueHooks" );
10550 if ( tmp && tmp.empty ) {
10551 count++;
10552 tmp.empty.add( resolve );
10553 }
10554 }
10555 resolve();
10556 return defer.promise( obj );
10557 }
10558 });
10559 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
10560
10561 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
10562
10563 var isHidden = function( elem, el ) {
10564 // isHidden might be called from jQuery#filter function;
10565 // in that case, element will be second argument
10566 elem = el || elem;
10567 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
10568 };
10569
10570 var rcheckableType = (/^(?:checkbox|radio)$/i);
10571
10572
10573
10574 (function() {
10575 var fragment = document.createDocumentFragment(),
10576 div = fragment.appendChild( document.createElement( "div" ) ),
10577 input = document.createElement( "input" );
10578
10579 // #11217 - WebKit loses check when the name is after the checked attribute
10580 // Support: Windows Web Apps (WWA)
10581 // `name` and `type` need .setAttribute for WWA
10582 input.setAttribute( "type", "radio" );
10583 input.setAttribute( "checked", "checked" );
10584 input.setAttribute( "name", "t" );
10585
10586 div.appendChild( input );
10587
10588 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
10589 // old WebKit doesn't clone checked state correctly in fragments
10590 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
10591
10592 // Make sure textarea (and checkbox) defaultValue is properly cloned
10593 // Support: IE9-IE11+
10594 div.innerHTML = "<textarea>x</textarea>";
10595 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
10596 })();
10597 var strundefined = typeof undefined;
10598
10599
10600
10601 support.focusinBubbles = "onfocusin" in window;
10602
10603
10604 var
10605 rkeyEvent = /^key/,
10606 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
10607 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
10608 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
10609
10610 function returnTrue() {
10611 return true;
10612 }
10613
10614 function returnFalse() {
10615 return false;
10616 }
10617
10618 function safeActiveElement() {
10619 try {
10620 return document.activeElement;
10621 } catch ( err ) { }
10622 }
10623
10624 /*
10625 * Helper functions for managing events -- not part of the public interface.
10626 * Props to Dean Edwards' addEvent library for many of the ideas.
10627 */
10628 jQuery.event = {
10629
10630 global: {},
10631
10632 add: function( elem, types, handler, data, selector ) {
10633
10634 var handleObjIn, eventHandle, tmp,
10635 events, t, handleObj,
10636 special, handlers, type, namespaces, origType,
10637 elemData = data_priv.get( elem );
10638
10639 // Don't attach events to noData or text/comment nodes (but allow plain objects)
10640 if ( !elemData ) {
10641 return;
10642 }
10643
10644 // Caller can pass in an object of custom data in lieu of the handler
10645 if ( handler.handler ) {
10646 handleObjIn = handler;
10647 handler = handleObjIn.handler;
10648 selector = handleObjIn.selector;
10649 }
10650
10651 // Make sure that the handler has a unique ID, used to find/remove it later
10652 if ( !handler.guid ) {
10653 handler.guid = jQuery.guid++;
10654 }
10655
10656 // Init the element's event structure and main handler, if this is the first
10657 if ( !(events = elemData.events) ) {
10658 events = elemData.events = {};
10659 }
10660 if ( !(eventHandle = elemData.handle) ) {
10661 eventHandle = elemData.handle = function( e ) {
10662 // Discard the second event of a jQuery.event.trigger() and
10663 // when an event is called after a page has unloaded
10664 return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
10665 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
10666 };
10667 }
10668
10669 // Handle multiple events separated by a space
10670 types = ( types || "" ).match( rnotwhite ) || [ "" ];
10671 t = types.length;
10672 while ( t-- ) {
10673 tmp = rtypenamespace.exec( types[t] ) || [];
10674 type = origType = tmp[1];
10675 namespaces = ( tmp[2] || "" ).split( "." ).sort();
10676
10677 // There *must* be a type, no attaching namespace-only handlers
10678 if ( !type ) {
10679 continue;
10680 }
10681
10682 // If event changes its type, use the special event handlers for the changed type
10683 special = jQuery.event.special[ type ] || {};
10684
10685 // If selector defined, determine special event api type, otherwise given type
10686 type = ( selector ? special.delegateType : special.bindType ) || type;
10687
10688 // Update special based on newly reset type
10689 special = jQuery.event.special[ type ] || {};
10690
10691 // handleObj is passed to all event handlers
10692 handleObj = jQuery.extend({
10693 type: type,
10694 origType: origType,
10695 data: data,
10696 handler: handler,
10697 guid: handler.guid,
10698 selector: selector,
10699 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
10700 namespace: namespaces.join(".")
10701 }, handleObjIn );
10702
10703 // Init the event handler queue if we're the first
10704 if ( !(handlers = events[ type ]) ) {
10705 handlers = events[ type ] = [];
10706 handlers.delegateCount = 0;
10707
10708 // Only use addEventListener if the special events handler returns false
10709 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
10710 if ( elem.addEventListener ) {
10711 elem.addEventListener( type, eventHandle, false );
10712 }
10713 }
10714 }
10715
10716 if ( special.add ) {
10717 special.add.call( elem, handleObj );
10718
10719 if ( !handleObj.handler.guid ) {
10720 handleObj.handler.guid = handler.guid;
10721 }
10722 }
10723
10724 // Add to the element's handler list, delegates in front
10725 if ( selector ) {
10726 handlers.splice( handlers.delegateCount++, 0, handleObj );
10727 } else {
10728 handlers.push( handleObj );
10729 }
10730
10731 // Keep track of which events have ever been used, for event optimization
10732 jQuery.event.global[ type ] = true;
10733 }
10734
10735 },
10736
10737 // Detach an event or set of events from an element
10738 remove: function( elem, types, handler, selector, mappedTypes ) {
10739
10740 var j, origCount, tmp,
10741 events, t, handleObj,
10742 special, handlers, type, namespaces, origType,
10743 elemData = data_priv.hasData( elem ) && data_priv.get( elem );
10744
10745 if ( !elemData || !(events = elemData.events) ) {
10746 return;
10747 }
10748
10749 // Once for each type.namespace in types; type may be omitted
10750 types = ( types || "" ).match( rnotwhite ) || [ "" ];
10751 t = types.length;
10752 while ( t-- ) {
10753 tmp = rtypenamespace.exec( types[t] ) || [];
10754 type = origType = tmp[1];
10755 namespaces = ( tmp[2] || "" ).split( "." ).sort();
10756
10757 // Unbind all events (on this namespace, if provided) for the element
10758 if ( !type ) {
10759 for ( type in events ) {
10760 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
10761 }
10762 continue;
10763 }
10764
10765 special = jQuery.event.special[ type ] || {};
10766 type = ( selector ? special.delegateType : special.bindType ) || type;
10767 handlers = events[ type ] || [];
10768 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
10769
10770 // Remove matching events
10771 origCount = j = handlers.length;
10772 while ( j-- ) {
10773 handleObj = handlers[ j ];
10774
10775 if ( ( mappedTypes || origType === handleObj.origType ) &&
10776 ( !handler || handler.guid === handleObj.guid ) &&
10777 ( !tmp || tmp.test( handleObj.namespace ) ) &&
10778 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
10779 handlers.splice( j, 1 );
10780
10781 if ( handleObj.selector ) {
10782 handlers.delegateCount--;
10783 }
10784 if ( special.remove ) {
10785 special.remove.call( elem, handleObj );
10786 }
10787 }
10788 }
10789
10790 // Remove generic event handler if we removed something and no more handlers exist
10791 // (avoids potential for endless recursion during removal of special event handlers)
10792 if ( origCount && !handlers.length ) {
10793 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
10794 jQuery.removeEvent( elem, type, elemData.handle );
10795 }
10796
10797 delete events[ type ];
10798 }
10799 }
10800
10801 // Remove the expando if it's no longer used
10802 if ( jQuery.isEmptyObject( events ) ) {
10803 delete elemData.handle;
10804 data_priv.remove( elem, "events" );
10805 }
10806 },
10807
10808 trigger: function( event, data, elem, onlyHandlers ) {
10809
10810 var i, cur, tmp, bubbleType, ontype, handle, special,
10811 eventPath = [ elem || document ],
10812 type = hasOwn.call( event, "type" ) ? event.type : event,
10813 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
10814
10815 cur = tmp = elem = elem || document;
10816
10817 // Don't do events on text and comment nodes
10818 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
10819 return;
10820 }
10821
10822 // focus/blur morphs to focusin/out; ensure we're not firing them right now
10823 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
10824 return;
10825 }
10826
10827 if ( type.indexOf(".") >= 0 ) {
10828 // Namespaced trigger; create a regexp to match event type in handle()
10829 namespaces = type.split(".");
10830 type = namespaces.shift();
10831 namespaces.sort();
10832 }
10833 ontype = type.indexOf(":") < 0 && "on" + type;
10834
10835 // Caller can pass in a jQuery.Event object, Object, or just an event type string
10836 event = event[ jQuery.expando ] ?
10837 event :
10838 new jQuery.Event( type, typeof event === "object" && event );
10839
10840 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
10841 event.isTrigger = onlyHandlers ? 2 : 3;
10842 event.namespace = namespaces.join(".");
10843 event.namespace_re = event.namespace ?
10844 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
10845 null;
10846
10847 // Clean up the event in case it is being reused
10848 event.result = undefined;
10849 if ( !event.target ) {
10850 event.target = elem;
10851 }
10852
10853 // Clone any incoming data and prepend the event, creating the handler arg list
10854 data = data == null ?
10855 [ event ] :
10856 jQuery.makeArray( data, [ event ] );
10857
10858 // Allow special events to draw outside the lines
10859 special = jQuery.event.special[ type ] || {};
10860 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
10861 return;
10862 }
10863
10864 // Determine event propagation path in advance, per W3C events spec (#9951)
10865 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
10866 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
10867
10868 bubbleType = special.delegateType || type;
10869 if ( !rfocusMorph.test( bubbleType + type ) ) {
10870 cur = cur.parentNode;
10871 }
10872 for ( ; cur; cur = cur.parentNode ) {
10873 eventPath.push( cur );
10874 tmp = cur;
10875 }
10876
10877 // Only add window if we got to document (e.g., not plain obj or detached DOM)
10878 if ( tmp === (elem.ownerDocument || document) ) {
10879 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
10880 }
10881 }
10882
10883 // Fire handlers on the event path
10884 i = 0;
10885 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
10886
10887 event.type = i > 1 ?
10888 bubbleType :
10889 special.bindType || type;
10890
10891 // jQuery handler
10892 handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
10893 if ( handle ) {
10894 handle.apply( cur, data );
10895 }
10896
10897 // Native handler
10898 handle = ontype && cur[ ontype ];
10899 if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
10900 event.result = handle.apply( cur, data );
10901 if ( event.result === false ) {
10902 event.preventDefault();
10903 }
10904 }
10905 }
10906 event.type = type;
10907
10908 // If nobody prevented the default action, do it now
10909 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
10910
10911 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
10912 jQuery.acceptData( elem ) ) {
10913
10914 // Call a native DOM method on the target with the same name name as the event.
10915 // Don't do default actions on window, that's where global variables be (#6170)
10916 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
10917
10918 // Don't re-trigger an onFOO event when we call its FOO() method
10919 tmp = elem[ ontype ];
10920
10921 if ( tmp ) {
10922 elem[ ontype ] = null;
10923 }
10924
10925 // Prevent re-triggering of the same event, since we already bubbled it above
10926 jQuery.event.triggered = type;
10927 elem[ type ]();
10928 jQuery.event.triggered = undefined;
10929
10930 if ( tmp ) {
10931 elem[ ontype ] = tmp;
10932 }
10933 }
10934 }
10935 }
10936
10937 return event.result;
10938 },
10939
10940 dispatch: function( event ) {
10941
10942 // Make a writable jQuery.Event from the native event object
10943 event = jQuery.event.fix( event );
10944
10945 var i, j, ret, matched, handleObj,
10946 handlerQueue = [],
10947 args = slice.call( arguments ),
10948 handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
10949 special = jQuery.event.special[ event.type ] || {};
10950
10951 // Use the fix-ed jQuery.Event rather than the (read-only) native event
10952 args[0] = event;
10953 event.delegateTarget = this;
10954
10955 // Call the preDispatch hook for the mapped type, and let it bail if desired
10956 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
10957 return;
10958 }
10959
10960 // Determine handlers
10961 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
10962
10963 // Run delegates first; they may want to stop propagation beneath us
10964 i = 0;
10965 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
10966 event.currentTarget = matched.elem;
10967
10968 j = 0;
10969 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
10970
10971 // Triggered event must either 1) have no namespace, or
10972 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
10973 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
10974
10975 event.handleObj = handleObj;
10976 event.data = handleObj.data;
10977
10978 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
10979 .apply( matched.elem, args );
10980
10981 if ( ret !== undefined ) {
10982 if ( (event.result = ret) === false ) {
10983 event.preventDefault();
10984 event.stopPropagation();
10985 }
10986 }
10987 }
10988 }
10989 }
10990
10991 // Call the postDispatch hook for the mapped type
10992 if ( special.postDispatch ) {
10993 special.postDispatch.call( this, event );
10994 }
10995
10996 return event.result;
10997 },
10998
10999 handlers: function( event, handlers ) {
11000 var i, matches, sel, handleObj,
11001 handlerQueue = [],
11002 delegateCount = handlers.delegateCount,
11003 cur = event.target;
11004
11005 // Find delegate handlers
11006 // Black-hole SVG <use> instance trees (#13180)
11007 // Avoid non-left-click bubbling in Firefox (#3861)
11008 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
11009
11010 for ( ; cur !== this; cur = cur.parentNode || this ) {
11011
11012 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
11013 if ( cur.disabled !== true || event.type !== "click" ) {
11014 matches = [];
11015 for ( i = 0; i < delegateCount; i++ ) {
11016 handleObj = handlers[ i ];
11017
11018 // Don't conflict with Object.prototype properties (#13203)
11019 sel = handleObj.selector + " ";
11020
11021 if ( matches[ sel ] === undefined ) {
11022 matches[ sel ] = handleObj.needsContext ?
11023 jQuery( sel, this ).index( cur ) >= 0 :
11024 jQuery.find( sel, this, null, [ cur ] ).length;
11025 }
11026 if ( matches[ sel ] ) {
11027 matches.push( handleObj );
11028 }
11029 }
11030 if ( matches.length ) {
11031 handlerQueue.push({ elem: cur, handlers: matches });
11032 }
11033 }
11034 }
11035 }
11036
11037 // Add the remaining (directly-bound) handlers
11038 if ( delegateCount < handlers.length ) {
11039 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
11040 }
11041
11042 return handlerQueue;
11043 },
11044
11045 // Includes some event props shared by KeyEvent and MouseEvent
11046 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
11047
11048 fixHooks: {},
11049
11050 keyHooks: {
11051 props: "char charCode key keyCode".split(" "),
11052 filter: function( event, original ) {
11053
11054 // Add which for key events
11055 if ( event.which == null ) {
11056 event.which = original.charCode != null ? original.charCode : original.keyCode;
11057 }
11058
11059 return event;
11060 }
11061 },
11062
11063 mouseHooks: {
11064 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
11065 filter: function( event, original ) {
11066 var eventDoc, doc, body,
11067 button = original.button;
11068
11069 // Calculate pageX/Y if missing and clientX/Y available
11070 if ( event.pageX == null && original.clientX != null ) {
11071 eventDoc = event.target.ownerDocument || document;
11072 doc = eventDoc.documentElement;
11073 body = eventDoc.body;
11074
11075 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
11076 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
11077 }
11078
11079 // Add which for click: 1 === left; 2 === middle; 3 === right
11080 // Note: button is not normalized, so don't use it
11081 if ( !event.which && button !== undefined ) {
11082 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
11083 }
11084
11085 return event;
11086 }
11087 },
11088
11089 fix: function( event ) {
11090 if ( event[ jQuery.expando ] ) {
11091 return event;
11092 }
11093
11094 // Create a writable copy of the event object and normalize some properties
11095 var i, prop, copy,
11096 type = event.type,
11097 originalEvent = event,
11098 fixHook = this.fixHooks[ type ];
11099
11100 if ( !fixHook ) {
11101 this.fixHooks[ type ] = fixHook =
11102 rmouseEvent.test( type ) ? this.mouseHooks :
11103 rkeyEvent.test( type ) ? this.keyHooks :
11104 {};
11105 }
11106 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
11107
11108 event = new jQuery.Event( originalEvent );
11109
11110 i = copy.length;
11111 while ( i-- ) {
11112 prop = copy[ i ];
11113 event[ prop ] = originalEvent[ prop ];
11114 }
11115
11116 // Support: Cordova 2.5 (WebKit) (#13255)
11117 // All events should have a target; Cordova deviceready doesn't
11118 if ( !event.target ) {
11119 event.target = document;
11120 }
11121
11122 // Support: Safari 6.0+, Chrome < 28
11123 // Target should not be a text node (#504, #13143)
11124 if ( event.target.nodeType === 3 ) {
11125 event.target = event.target.parentNode;
11126 }
11127
11128 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
11129 },
11130
11131 special: {
11132 load: {
11133 // Prevent triggered image.load events from bubbling to window.load
11134 noBubble: true
11135 },
11136 focus: {
11137 // Fire native event if possible so blur/focus sequence is correct
11138 trigger: function() {
11139 if ( this !== safeActiveElement() && this.focus ) {
11140 this.focus();
11141 return false;
11142 }
11143 },
11144 delegateType: "focusin"
11145 },
11146 blur: {
11147 trigger: function() {
11148 if ( this === safeActiveElement() && this.blur ) {
11149 this.blur();
11150 return false;
11151 }
11152 },
11153 delegateType: "focusout"
11154 },
11155 click: {
11156 // For checkbox, fire native event so checked state will be right
11157 trigger: function() {
11158 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
11159 this.click();
11160 return false;
11161 }
11162 },
11163
11164 // For cross-browser consistency, don't fire native .click() on links
11165 _default: function( event ) {
11166 return jQuery.nodeName( event.target, "a" );
11167 }
11168 },
11169
11170 beforeunload: {
11171 postDispatch: function( event ) {
11172
11173 // Support: Firefox 20+
11174 // Firefox doesn't alert if the returnValue field is not set.
11175 if ( event.result !== undefined && event.originalEvent ) {
11176 event.originalEvent.returnValue = event.result;
11177 }
11178 }
11179 }
11180 },
11181
11182 simulate: function( type, elem, event, bubble ) {
11183 // Piggyback on a donor event to simulate a different one.
11184 // Fake originalEvent to avoid donor's stopPropagation, but if the
11185 // simulated event prevents default then we do the same on the donor.
11186 var e = jQuery.extend(
11187 new jQuery.Event(),
11188 event,
11189 {
11190 type: type,
11191 isSimulated: true,
11192 originalEvent: {}
11193 }
11194 );
11195 if ( bubble ) {
11196 jQuery.event.trigger( e, null, elem );
11197 } else {
11198 jQuery.event.dispatch.call( elem, e );
11199 }
11200 if ( e.isDefaultPrevented() ) {
11201 event.preventDefault();
11202 }
11203 }
11204 };
11205
11206 jQuery.removeEvent = function( elem, type, handle ) {
11207 if ( elem.removeEventListener ) {
11208 elem.removeEventListener( type, handle, false );
11209 }
11210 };
11211
11212 jQuery.Event = function( src, props ) {
11213 // Allow instantiation without the 'new' keyword
11214 if ( !(this instanceof jQuery.Event) ) {
11215 return new jQuery.Event( src, props );
11216 }
11217
11218 // Event object
11219 if ( src && src.type ) {
11220 this.originalEvent = src;
11221 this.type = src.type;
11222
11223 // Events bubbling up the document may have been marked as prevented
11224 // by a handler lower down the tree; reflect the correct value.
11225 this.isDefaultPrevented = src.defaultPrevented ||
11226 src.defaultPrevented === undefined &&
11227 // Support: Android < 4.0
11228 src.returnValue === false ?
11229 returnTrue :
11230 returnFalse;
11231
11232 // Event type
11233 } else {
11234 this.type = src;
11235 }
11236
11237 // Put explicitly provided properties onto the event object
11238 if ( props ) {
11239 jQuery.extend( this, props );
11240 }
11241
11242 // Create a timestamp if incoming event doesn't have one
11243 this.timeStamp = src && src.timeStamp || jQuery.now();
11244
11245 // Mark it as fixed
11246 this[ jQuery.expando ] = true;
11247 };
11248
11249 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
11250 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
11251 jQuery.Event.prototype = {
11252 isDefaultPrevented: returnFalse,
11253 isPropagationStopped: returnFalse,
11254 isImmediatePropagationStopped: returnFalse,
11255
11256 preventDefault: function() {
11257 var e = this.originalEvent;
11258
11259 this.isDefaultPrevented = returnTrue;
11260
11261 if ( e && e.preventDefault ) {
11262 e.preventDefault();
11263 }
11264 },
11265 stopPropagation: function() {
11266 var e = this.originalEvent;
11267
11268 this.isPropagationStopped = returnTrue;
11269
11270 if ( e && e.stopPropagation ) {
11271 e.stopPropagation();
11272 }
11273 },
11274 stopImmediatePropagation: function() {
11275 var e = this.originalEvent;
11276
11277 this.isImmediatePropagationStopped = returnTrue;
11278
11279 if ( e && e.stopImmediatePropagation ) {
11280 e.stopImmediatePropagation();
11281 }
11282
11283 this.stopPropagation();
11284 }
11285 };
11286
11287 // Create mouseenter/leave events using mouseover/out and event-time checks
11288 // Support: Chrome 15+
11289 jQuery.each({
11290 mouseenter: "mouseover",
11291 mouseleave: "mouseout",
11292 pointerenter: "pointerover",
11293 pointerleave: "pointerout"
11294 }, function( orig, fix ) {
11295 jQuery.event.special[ orig ] = {
11296 delegateType: fix,
11297 bindType: fix,
11298
11299 handle: function( event ) {
11300 var ret,
11301 target = this,
11302 related = event.relatedTarget,
11303 handleObj = event.handleObj;
11304
11305 // For mousenter/leave call the handler if related is outside the target.
11306 // NB: No relatedTarget if the mouse left/entered the browser window
11307 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
11308 event.type = handleObj.origType;
11309 ret = handleObj.handler.apply( this, arguments );
11310 event.type = fix;
11311 }
11312 return ret;
11313 }
11314 };
11315 });
11316
11317 // Create "bubbling" focus and blur events
11318 // Support: Firefox, Chrome, Safari
11319 if ( !support.focusinBubbles ) {
11320 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
11321
11322 // Attach a single capturing handler on the document while someone wants focusin/focusout
11323 var handler = function( event ) {
11324 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
11325 };
11326
11327 jQuery.event.special[ fix ] = {
11328 setup: function() {
11329 var doc = this.ownerDocument || this,
11330 attaches = data_priv.access( doc, fix );
11331
11332 if ( !attaches ) {
11333 doc.addEventListener( orig, handler, true );
11334 }
11335 data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
11336 },
11337 teardown: function() {
11338 var doc = this.ownerDocument || this,
11339 attaches = data_priv.access( doc, fix ) - 1;
11340
11341 if ( !attaches ) {
11342 doc.removeEventListener( orig, handler, true );
11343 data_priv.remove( doc, fix );
11344
11345 } else {
11346 data_priv.access( doc, fix, attaches );
11347 }
11348 }
11349 };
11350 });
11351 }
11352
11353 jQuery.fn.extend({
11354
11355 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
11356 var origFn, type;
11357
11358 // Types can be a map of types/handlers
11359 if ( typeof types === "object" ) {
11360 // ( types-Object, selector, data )
11361 if ( typeof selector !== "string" ) {
11362 // ( types-Object, data )
11363 data = data || selector;
11364 selector = undefined;
11365 }
11366 for ( type in types ) {
11367 this.on( type, selector, data, types[ type ], one );
11368 }
11369 return this;
11370 }
11371
11372 if ( data == null && fn == null ) {
11373 // ( types, fn )
11374 fn = selector;
11375 data = selector = undefined;
11376 } else if ( fn == null ) {
11377 if ( typeof selector === "string" ) {
11378 // ( types, selector, fn )
11379 fn = data;
11380 data = undefined;
11381 } else {
11382 // ( types, data, fn )
11383 fn = data;
11384 data = selector;
11385 selector = undefined;
11386 }
11387 }
11388 if ( fn === false ) {
11389 fn = returnFalse;
11390 } else if ( !fn ) {
11391 return this;
11392 }
11393
11394 if ( one === 1 ) {
11395 origFn = fn;
11396 fn = function( event ) {
11397 // Can use an empty set, since event contains the info
11398 jQuery().off( event );
11399 return origFn.apply( this, arguments );
11400 };
11401 // Use same guid so caller can remove using origFn
11402 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
11403 }
11404 return this.each( function() {
11405 jQuery.event.add( this, types, fn, data, selector );
11406 });
11407 },
11408 one: function( types, selector, data, fn ) {
11409 return this.on( types, selector, data, fn, 1 );
11410 },
11411 off: function( types, selector, fn ) {
11412 var handleObj, type;
11413 if ( types && types.preventDefault && types.handleObj ) {
11414 // ( event ) dispatched jQuery.Event
11415 handleObj = types.handleObj;
11416 jQuery( types.delegateTarget ).off(
11417 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
11418 handleObj.selector,
11419 handleObj.handler
11420 );
11421 return this;
11422 }
11423 if ( typeof types === "object" ) {
11424 // ( types-object [, selector] )
11425 for ( type in types ) {
11426 this.off( type, selector, types[ type ] );
11427 }
11428 return this;
11429 }
11430 if ( selector === false || typeof selector === "function" ) {
11431 // ( types [, fn] )
11432 fn = selector;
11433 selector = undefined;
11434 }
11435 if ( fn === false ) {
11436 fn = returnFalse;
11437 }
11438 return this.each(function() {
11439 jQuery.event.remove( this, types, fn, selector );
11440 });
11441 },
11442
11443 trigger: function( type, data ) {
11444 return this.each(function() {
11445 jQuery.event.trigger( type, data, this );
11446 });
11447 },
11448 triggerHandler: function( type, data ) {
11449 var elem = this[0];
11450 if ( elem ) {
11451 return jQuery.event.trigger( type, data, elem, true );
11452 }
11453 }
11454 });
11455
11456
11457 var
11458 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
11459 rtagName = /<([\w:]+)/,
11460 rhtml = /<|&#?\w+;/,
11461 rnoInnerhtml = /<(?:script|style|link)/i,
11462 // checked="checked" or checked
11463 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
11464 rscriptType = /^$|\/(?:java|ecma)script/i,
11465 rscriptTypeMasked = /^true\/(.*)/,
11466 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
11467
11468 // We have to close these tags to support XHTML (#13200)
11469 wrapMap = {
11470
11471 // Support: IE 9
11472 option: [ 1, "<select multiple='multiple'>", "</select>" ],
11473
11474 thead: [ 1, "<table>", "</table>" ],
11475 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
11476 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
11477 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
11478
11479 _default: [ 0, "", "" ]
11480 };
11481
11482 // Support: IE 9
11483 wrapMap.optgroup = wrapMap.option;
11484
11485 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
11486 wrapMap.th = wrapMap.td;
11487
11488 // Support: 1.x compatibility
11489 // Manipulating tables requires a tbody
11490 function manipulationTarget( elem, content ) {
11491 return jQuery.nodeName( elem, "table" ) &&
11492 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
11493
11494 elem.getElementsByTagName("tbody")[0] ||
11495 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
11496 elem;
11497 }
11498
11499 // Replace/restore the type attribute of script elements for safe DOM manipulation
11500 function disableScript( elem ) {
11501 elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
11502 return elem;
11503 }
11504 function restoreScript( elem ) {
11505 var match = rscriptTypeMasked.exec( elem.type );
11506
11507 if ( match ) {
11508 elem.type = match[ 1 ];
11509 } else {
11510 elem.removeAttribute("type");
11511 }
11512
11513 return elem;
11514 }
11515
11516 // Mark scripts as having already been evaluated
11517 function setGlobalEval( elems, refElements ) {
11518 var i = 0,
11519 l = elems.length;
11520
11521 for ( ; i < l; i++ ) {
11522 data_priv.set(
11523 elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
11524 );
11525 }
11526 }
11527
11528 function cloneCopyEvent( src, dest ) {
11529 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
11530
11531 if ( dest.nodeType !== 1 ) {
11532 return;
11533 }
11534
11535 // 1. Copy private data: events, handlers, etc.
11536 if ( data_priv.hasData( src ) ) {
11537 pdataOld = data_priv.access( src );
11538 pdataCur = data_priv.set( dest, pdataOld );
11539 events = pdataOld.events;
11540
11541 if ( events ) {
11542 delete pdataCur.handle;
11543 pdataCur.events = {};
11544
11545 for ( type in events ) {
11546 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
11547 jQuery.event.add( dest, type, events[ type ][ i ] );
11548 }
11549 }
11550 }
11551 }
11552
11553 // 2. Copy user data
11554 if ( data_user.hasData( src ) ) {
11555 udataOld = data_user.access( src );
11556 udataCur = jQuery.extend( {}, udataOld );
11557
11558 data_user.set( dest, udataCur );
11559 }
11560 }
11561
11562 function getAll( context, tag ) {
11563 var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
11564 context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
11565 [];
11566
11567 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
11568 jQuery.merge( [ context ], ret ) :
11569 ret;
11570 }
11571
11572 // Support: IE >= 9
11573 function fixInput( src, dest ) {
11574 var nodeName = dest.nodeName.toLowerCase();
11575
11576 // Fails to persist the checked state of a cloned checkbox or radio button.
11577 if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
11578 dest.checked = src.checked;
11579
11580 // Fails to return the selected option to the default selected state when cloning options
11581 } else if ( nodeName === "input" || nodeName === "textarea" ) {
11582 dest.defaultValue = src.defaultValue;
11583 }
11584 }
11585
11586 jQuery.extend({
11587 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
11588 var i, l, srcElements, destElements,
11589 clone = elem.cloneNode( true ),
11590 inPage = jQuery.contains( elem.ownerDocument, elem );
11591
11592 // Support: IE >= 9
11593 // Fix Cloning issues
11594 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
11595 !jQuery.isXMLDoc( elem ) ) {
11596
11597 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
11598 destElements = getAll( clone );
11599 srcElements = getAll( elem );
11600
11601 for ( i = 0, l = srcElements.length; i < l; i++ ) {
11602 fixInput( srcElements[ i ], destElements[ i ] );
11603 }
11604 }
11605
11606 // Copy the events from the original to the clone
11607 if ( dataAndEvents ) {
11608 if ( deepDataAndEvents ) {
11609 srcElements = srcElements || getAll( elem );
11610 destElements = destElements || getAll( clone );
11611
11612 for ( i = 0, l = srcElements.length; i < l; i++ ) {
11613 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
11614 }
11615 } else {
11616 cloneCopyEvent( elem, clone );
11617 }
11618 }
11619
11620 // Preserve script evaluation history
11621 destElements = getAll( clone, "script" );
11622 if ( destElements.length > 0 ) {
11623 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
11624 }
11625
11626 // Return the cloned set
11627 return clone;
11628 },
11629
11630 buildFragment: function( elems, context, scripts, selection ) {
11631 var elem, tmp, tag, wrap, contains, j,
11632 fragment = context.createDocumentFragment(),
11633 nodes = [],
11634 i = 0,
11635 l = elems.length;
11636
11637 for ( ; i < l; i++ ) {
11638 elem = elems[ i ];
11639
11640 if ( elem || elem === 0 ) {
11641
11642 // Add nodes directly
11643 if ( jQuery.type( elem ) === "object" ) {
11644 // Support: QtWebKit
11645 // jQuery.merge because push.apply(_, arraylike) throws
11646 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
11647
11648 // Convert non-html into a text node
11649 } else if ( !rhtml.test( elem ) ) {
11650 nodes.push( context.createTextNode( elem ) );
11651
11652 // Convert html into DOM nodes
11653 } else {
11654 tmp = tmp || fragment.appendChild( context.createElement("div") );
11655
11656 // Deserialize a standard representation
11657 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
11658 wrap = wrapMap[ tag ] || wrapMap._default;
11659 tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
11660
11661 // Descend through wrappers to the right content
11662 j = wrap[ 0 ];
11663 while ( j-- ) {
11664 tmp = tmp.lastChild;
11665 }
11666
11667 // Support: QtWebKit
11668 // jQuery.merge because push.apply(_, arraylike) throws
11669 jQuery.merge( nodes, tmp.childNodes );
11670
11671 // Remember the top-level container
11672 tmp = fragment.firstChild;
11673
11674 // Fixes #12346
11675 // Support: Webkit, IE
11676 tmp.textContent = "";
11677 }
11678 }
11679 }
11680
11681 // Remove wrapper from fragment
11682 fragment.textContent = "";
11683
11684 i = 0;
11685 while ( (elem = nodes[ i++ ]) ) {
11686
11687 // #4087 - If origin and destination elements are the same, and this is
11688 // that element, do not do anything
11689 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
11690 continue;
11691 }
11692
11693 contains = jQuery.contains( elem.ownerDocument, elem );
11694
11695 // Append to fragment
11696 tmp = getAll( fragment.appendChild( elem ), "script" );
11697
11698 // Preserve script evaluation history
11699 if ( contains ) {
11700 setGlobalEval( tmp );
11701 }
11702
11703 // Capture executables
11704 if ( scripts ) {
11705 j = 0;
11706 while ( (elem = tmp[ j++ ]) ) {
11707 if ( rscriptType.test( elem.type || "" ) ) {
11708 scripts.push( elem );
11709 }
11710 }
11711 }
11712 }
11713
11714 return fragment;
11715 },
11716
11717 cleanData: function( elems ) {
11718 var data, elem, type, key,
11719 special = jQuery.event.special,
11720 i = 0;
11721
11722 for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
11723 if ( jQuery.acceptData( elem ) ) {
11724 key = elem[ data_priv.expando ];
11725
11726 if ( key && (data = data_priv.cache[ key ]) ) {
11727 if ( data.events ) {
11728 for ( type in data.events ) {
11729 if ( special[ type ] ) {
11730 jQuery.event.remove( elem, type );
11731
11732 // This is a shortcut to avoid jQuery.event.remove's overhead
11733 } else {
11734 jQuery.removeEvent( elem, type, data.handle );
11735 }
11736 }
11737 }
11738 if ( data_priv.cache[ key ] ) {
11739 // Discard any remaining `private` data
11740 delete data_priv.cache[ key ];
11741 }
11742 }
11743 }
11744 // Discard any remaining `user` data
11745 delete data_user.cache[ elem[ data_user.expando ] ];
11746 }
11747 }
11748 });
11749
11750 jQuery.fn.extend({
11751 text: function( value ) {
11752 return access( this, function( value ) {
11753 return value === undefined ?
11754 jQuery.text( this ) :
11755 this.empty().each(function() {
11756 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11757 this.textContent = value;
11758 }
11759 });
11760 }, null, value, arguments.length );
11761 },
11762
11763 append: function() {
11764 return this.domManip( arguments, function( elem ) {
11765 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11766 var target = manipulationTarget( this, elem );
11767 target.appendChild( elem );
11768 }
11769 });
11770 },
11771
11772 prepend: function() {
11773 return this.domManip( arguments, function( elem ) {
11774 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11775 var target = manipulationTarget( this, elem );
11776 target.insertBefore( elem, target.firstChild );
11777 }
11778 });
11779 },
11780
11781 before: function() {
11782 return this.domManip( arguments, function( elem ) {
11783 if ( this.parentNode ) {
11784 this.parentNode.insertBefore( elem, this );
11785 }
11786 });
11787 },
11788
11789 after: function() {
11790 return this.domManip( arguments, function( elem ) {
11791 if ( this.parentNode ) {
11792 this.parentNode.insertBefore( elem, this.nextSibling );
11793 }
11794 });
11795 },
11796
11797 remove: function( selector, keepData /* Internal Use Only */ ) {
11798 var elem,
11799 elems = selector ? jQuery.filter( selector, this ) : this,
11800 i = 0;
11801
11802 for ( ; (elem = elems[i]) != null; i++ ) {
11803 if ( !keepData && elem.nodeType === 1 ) {
11804 jQuery.cleanData( getAll( elem ) );
11805 }
11806
11807 if ( elem.parentNode ) {
11808 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
11809 setGlobalEval( getAll( elem, "script" ) );
11810 }
11811 elem.parentNode.removeChild( elem );
11812 }
11813 }
11814
11815 return this;
11816 },
11817
11818 empty: function() {
11819 var elem,
11820 i = 0;
11821
11822 for ( ; (elem = this[i]) != null; i++ ) {
11823 if ( elem.nodeType === 1 ) {
11824
11825 // Prevent memory leaks
11826 jQuery.cleanData( getAll( elem, false ) );
11827
11828 // Remove any remaining nodes
11829 elem.textContent = "";
11830 }
11831 }
11832
11833 return this;
11834 },
11835
11836 clone: function( dataAndEvents, deepDataAndEvents ) {
11837 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
11838 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
11839
11840 return this.map(function() {
11841 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
11842 });
11843 },
11844
11845 html: function( value ) {
11846 return access( this, function( value ) {
11847 var elem = this[ 0 ] || {},
11848 i = 0,
11849 l = this.length;
11850
11851 if ( value === undefined && elem.nodeType === 1 ) {
11852 return elem.innerHTML;
11853 }
11854
11855 // See if we can take a shortcut and just use innerHTML
11856 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
11857 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
11858
11859 value = value.replace( rxhtmlTag, "<$1></$2>" );
11860
11861 try {
11862 for ( ; i < l; i++ ) {
11863 elem = this[ i ] || {};
11864
11865 // Remove element nodes and prevent memory leaks
11866 if ( elem.nodeType === 1 ) {
11867 jQuery.cleanData( getAll( elem, false ) );
11868 elem.innerHTML = value;
11869 }
11870 }
11871
11872 elem = 0;
11873
11874 // If using innerHTML throws an exception, use the fallback method
11875 } catch( e ) {}
11876 }
11877
11878 if ( elem ) {
11879 this.empty().append( value );
11880 }
11881 }, null, value, arguments.length );
11882 },
11883
11884 replaceWith: function() {
11885 var arg = arguments[ 0 ];
11886
11887 // Make the changes, replacing each context element with the new content
11888 this.domManip( arguments, function( elem ) {
11889 arg = this.parentNode;
11890
11891 jQuery.cleanData( getAll( this ) );
11892
11893 if ( arg ) {
11894 arg.replaceChild( elem, this );
11895 }
11896 });
11897
11898 // Force removal if there was no new content (e.g., from empty arguments)
11899 return arg && (arg.length || arg.nodeType) ? this : this.remove();
11900 },
11901
11902 detach: function( selector ) {
11903 return this.remove( selector, true );
11904 },
11905
11906 domManip: function( args, callback ) {
11907
11908 // Flatten any nested arrays
11909 args = concat.apply( [], args );
11910
11911 var fragment, first, scripts, hasScripts, node, doc,
11912 i = 0,
11913 l = this.length,
11914 set = this,
11915 iNoClone = l - 1,
11916 value = args[ 0 ],
11917 isFunction = jQuery.isFunction( value );
11918
11919 // We can't cloneNode fragments that contain checked, in WebKit
11920 if ( isFunction ||
11921 ( l > 1 && typeof value === "string" &&
11922 !support.checkClone && rchecked.test( value ) ) ) {
11923 return this.each(function( index ) {
11924 var self = set.eq( index );
11925 if ( isFunction ) {
11926 args[ 0 ] = value.call( this, index, self.html() );
11927 }
11928 self.domManip( args, callback );
11929 });
11930 }
11931
11932 if ( l ) {
11933 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
11934 first = fragment.firstChild;
11935
11936 if ( fragment.childNodes.length === 1 ) {
11937 fragment = first;
11938 }
11939
11940 if ( first ) {
11941 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
11942 hasScripts = scripts.length;
11943
11944 // Use the original fragment for the last item instead of the first because it can end up
11945 // being emptied incorrectly in certain situations (#8070).
11946 for ( ; i < l; i++ ) {
11947 node = fragment;
11948
11949 if ( i !== iNoClone ) {
11950 node = jQuery.clone( node, true, true );
11951
11952 // Keep references to cloned scripts for later restoration
11953 if ( hasScripts ) {
11954 // Support: QtWebKit
11955 // jQuery.merge because push.apply(_, arraylike) throws
11956 jQuery.merge( scripts, getAll( node, "script" ) );
11957 }
11958 }
11959
11960 callback.call( this[ i ], node, i );
11961 }
11962
11963 if ( hasScripts ) {
11964 doc = scripts[ scripts.length - 1 ].ownerDocument;
11965
11966 // Reenable scripts
11967 jQuery.map( scripts, restoreScript );
11968
11969 // Evaluate executable scripts on first document insertion
11970 for ( i = 0; i < hasScripts; i++ ) {
11971 node = scripts[ i ];
11972 if ( rscriptType.test( node.type || "" ) &&
11973 !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
11974
11975 if ( node.src ) {
11976 // Optional AJAX dependency, but won't run scripts if not present
11977 if ( jQuery._evalUrl ) {
11978 jQuery._evalUrl( node.src );
11979 }
11980 } else {
11981 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
11982 }
11983 }
11984 }
11985 }
11986 }
11987 }
11988
11989 return this;
11990 }
11991 });
11992
11993 jQuery.each({
11994 appendTo: "append",
11995 prependTo: "prepend",
11996 insertBefore: "before",
11997 insertAfter: "after",
11998 replaceAll: "replaceWith"
11999 }, function( name, original ) {
12000 jQuery.fn[ name ] = function( selector ) {
12001 var elems,
12002 ret = [],
12003 insert = jQuery( selector ),
12004 last = insert.length - 1,
12005 i = 0;
12006
12007 for ( ; i <= last; i++ ) {
12008 elems = i === last ? this : this.clone( true );
12009 jQuery( insert[ i ] )[ original ]( elems );
12010
12011 // Support: QtWebKit
12012 // .get() because push.apply(_, arraylike) throws
12013 push.apply( ret, elems.get() );
12014 }
12015
12016 return this.pushStack( ret );
12017 };
12018 });
12019
12020
12021 var iframe,
12022 elemdisplay = {};
12023
12024 /**
12025 * Retrieve the actual display of a element
12026 * @param {String} name nodeName of the element
12027 * @param {Object} doc Document object
12028 */
12029 // Called only from within defaultDisplay
12030 function actualDisplay( name, doc ) {
12031 var style,
12032 elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
12033
12034 // getDefaultComputedStyle might be reliably used only on attached element
12035 display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
12036
12037 // Use of this method is a temporary fix (more like optmization) until something better comes along,
12038 // since it was removed from specification and supported only in FF
12039 style.display : jQuery.css( elem[ 0 ], "display" );
12040
12041 // We don't have any data stored on the element,
12042 // so use "detach" method as fast way to get rid of the element
12043 elem.detach();
12044
12045 return display;
12046 }
12047
12048 /**
12049 * Try to determine the default display value of an element
12050 * @param {String} nodeName
12051 */
12052 function defaultDisplay( nodeName ) {
12053 var doc = document,
12054 display = elemdisplay[ nodeName ];
12055
12056 if ( !display ) {
12057 display = actualDisplay( nodeName, doc );
12058
12059 // If the simple way fails, read from inside an iframe
12060 if ( display === "none" || !display ) {
12061
12062 // Use the already-created iframe if possible
12063 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
12064
12065 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
12066 doc = iframe[ 0 ].contentDocument;
12067
12068 // Support: IE
12069 doc.write();
12070 doc.close();
12071
12072 display = actualDisplay( nodeName, doc );
12073 iframe.detach();
12074 }
12075
12076 // Store the correct default display
12077 elemdisplay[ nodeName ] = display;
12078 }
12079
12080 return display;
12081 }
12082 var rmargin = (/^margin/);
12083
12084 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
12085
12086 var getStyles = function( elem ) {
12087 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
12088 };
12089
12090
12091
12092 function curCSS( elem, name, computed ) {
12093 var width, minWidth, maxWidth, ret,
12094 style = elem.style;
12095
12096 computed = computed || getStyles( elem );
12097
12098 // Support: IE9
12099 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
12100 if ( computed ) {
12101 ret = computed.getPropertyValue( name ) || computed[ name ];
12102 }
12103
12104 if ( computed ) {
12105
12106 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
12107 ret = jQuery.style( elem, name );
12108 }
12109
12110 // Support: iOS < 6
12111 // A tribute to the "awesome hack by Dean Edwards"
12112 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
12113 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
12114 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
12115
12116 // Remember the original values
12117 width = style.width;
12118 minWidth = style.minWidth;
12119 maxWidth = style.maxWidth;
12120
12121 // Put in the new values to get a computed value out
12122 style.minWidth = style.maxWidth = style.width = ret;
12123 ret = computed.width;
12124
12125 // Revert the changed values
12126 style.width = width;
12127 style.minWidth = minWidth;
12128 style.maxWidth = maxWidth;
12129 }
12130 }
12131
12132 return ret !== undefined ?
12133 // Support: IE
12134 // IE returns zIndex value as an integer.
12135 ret + "" :
12136 ret;
12137 }
12138
12139
12140 function addGetHookIf( conditionFn, hookFn ) {
12141 // Define the hook, we'll check on the first run if it's really needed.
12142 return {
12143 get: function() {
12144 if ( conditionFn() ) {
12145 // Hook not needed (or it's not possible to use it due to missing dependency),
12146 // remove it.
12147 // Since there are no other hooks for marginRight, remove the whole object.
12148 delete this.get;
12149 return;
12150 }
12151
12152 // Hook needed; redefine it so that the support test is not executed again.
12153
12154 return (this.get = hookFn).apply( this, arguments );
12155 }
12156 };
12157 }
12158
12159
12160 (function() {
12161 var pixelPositionVal, boxSizingReliableVal,
12162 docElem = document.documentElement,
12163 container = document.createElement( "div" ),
12164 div = document.createElement( "div" );
12165
12166 if ( !div.style ) {
12167 return;
12168 }
12169
12170 div.style.backgroundClip = "content-box";
12171 div.cloneNode( true ).style.backgroundClip = "";
12172 support.clearCloneStyle = div.style.backgroundClip === "content-box";
12173
12174 container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" +
12175 "position:absolute";
12176 container.appendChild( div );
12177
12178 // Executing both pixelPosition & boxSizingReliable tests require only one layout
12179 // so they're executed at the same time to save the second computation.
12180 function computePixelPositionAndBoxSizingReliable() {
12181 div.style.cssText =
12182 // Support: Firefox<29, Android 2.3
12183 // Vendor-prefix box-sizing
12184 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
12185 "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
12186 "border:1px;padding:1px;width:4px;position:absolute";
12187 div.innerHTML = "";
12188 docElem.appendChild( container );
12189
12190 var divStyle = window.getComputedStyle( div, null );
12191 pixelPositionVal = divStyle.top !== "1%";
12192 boxSizingReliableVal = divStyle.width === "4px";
12193
12194 docElem.removeChild( container );
12195 }
12196
12197 // Support: node.js jsdom
12198 // Don't assume that getComputedStyle is a property of the global object
12199 if ( window.getComputedStyle ) {
12200 jQuery.extend( support, {
12201 pixelPosition: function() {
12202 // This test is executed only once but we still do memoizing
12203 // since we can use the boxSizingReliable pre-computing.
12204 // No need to check if the test was already performed, though.
12205 computePixelPositionAndBoxSizingReliable();
12206 return pixelPositionVal;
12207 },
12208 boxSizingReliable: function() {
12209 if ( boxSizingReliableVal == null ) {
12210 computePixelPositionAndBoxSizingReliable();
12211 }
12212 return boxSizingReliableVal;
12213 },
12214 reliableMarginRight: function() {
12215 // Support: Android 2.3
12216 // Check if div with explicit width and no margin-right incorrectly
12217 // gets computed margin-right based on width of container. (#3333)
12218 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
12219 // This support function is only executed once so no memoizing is needed.
12220 var ret,
12221 marginDiv = div.appendChild( document.createElement( "div" ) );
12222
12223 // Reset CSS: box-sizing; display; margin; border; padding
12224 marginDiv.style.cssText = div.style.cssText =
12225 // Support: Firefox<29, Android 2.3
12226 // Vendor-prefix box-sizing
12227 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
12228 "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
12229 marginDiv.style.marginRight = marginDiv.style.width = "0";
12230 div.style.width = "1px";
12231 docElem.appendChild( container );
12232
12233 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
12234
12235 docElem.removeChild( container );
12236
12237 return ret;
12238 }
12239 });
12240 }
12241 })();
12242
12243
12244 // A method for quickly swapping in/out CSS properties to get correct calculations.
12245 jQuery.swap = function( elem, options, callback, args ) {
12246 var ret, name,
12247 old = {};
12248
12249 // Remember the old values, and insert the new ones
12250 for ( name in options ) {
12251 old[ name ] = elem.style[ name ];
12252 elem.style[ name ] = options[ name ];
12253 }
12254
12255 ret = callback.apply( elem, args || [] );
12256
12257 // Revert the old values
12258 for ( name in options ) {
12259 elem.style[ name ] = old[ name ];
12260 }
12261
12262 return ret;
12263 };
12264
12265
12266 var
12267 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
12268 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
12269 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
12270 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
12271 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
12272
12273 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
12274 cssNormalTransform = {
12275 letterSpacing: "0",
12276 fontWeight: "400"
12277 },
12278
12279 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
12280
12281 // return a css property mapped to a potentially vendor prefixed property
12282 function vendorPropName( style, name ) {
12283
12284 // shortcut for names that are not vendor prefixed
12285 if ( name in style ) {
12286 return name;
12287 }
12288
12289 // check for vendor prefixed names
12290 var capName = name[0].toUpperCase() + name.slice(1),
12291 origName = name,
12292 i = cssPrefixes.length;
12293
12294 while ( i-- ) {
12295 name = cssPrefixes[ i ] + capName;
12296 if ( name in style ) {
12297 return name;
12298 }
12299 }
12300
12301 return origName;
12302 }
12303
12304 function setPositiveNumber( elem, value, subtract ) {
12305 var matches = rnumsplit.exec( value );
12306 return matches ?
12307 // Guard against undefined "subtract", e.g., when used as in cssHooks
12308 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
12309 value;
12310 }
12311
12312 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
12313 var i = extra === ( isBorderBox ? "border" : "content" ) ?
12314 // If we already have the right measurement, avoid augmentation
12315 4 :
12316 // Otherwise initialize for horizontal or vertical properties
12317 name === "width" ? 1 : 0,
12318
12319 val = 0;
12320
12321 for ( ; i < 4; i += 2 ) {
12322 // both box models exclude margin, so add it if we want it
12323 if ( extra === "margin" ) {
12324 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
12325 }
12326
12327 if ( isBorderBox ) {
12328 // border-box includes padding, so remove it if we want content
12329 if ( extra === "content" ) {
12330 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
12331 }
12332
12333 // at this point, extra isn't border nor margin, so remove border
12334 if ( extra !== "margin" ) {
12335 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
12336 }
12337 } else {
12338 // at this point, extra isn't content, so add padding
12339 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
12340
12341 // at this point, extra isn't content nor padding, so add border
12342 if ( extra !== "padding" ) {
12343 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
12344 }
12345 }
12346 }
12347
12348 return val;
12349 }
12350
12351 function getWidthOrHeight( elem, name, extra ) {
12352
12353 // Start with offset property, which is equivalent to the border-box value
12354 var valueIsBorderBox = true,
12355 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
12356 styles = getStyles( elem ),
12357 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
12358
12359 // some non-html elements return undefined for offsetWidth, so check for null/undefined
12360 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
12361 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
12362 if ( val <= 0 || val == null ) {
12363 // Fall back to computed then uncomputed css if necessary
12364 val = curCSS( elem, name, styles );
12365 if ( val < 0 || val == null ) {
12366 val = elem.style[ name ];
12367 }
12368
12369 // Computed unit is not pixels. Stop here and return.
12370 if ( rnumnonpx.test(val) ) {
12371 return val;
12372 }
12373
12374 // we need the check for style in case a browser which returns unreliable values
12375 // for getComputedStyle silently falls back to the reliable elem.style
12376 valueIsBorderBox = isBorderBox &&
12377 ( support.boxSizingReliable() || val === elem.style[ name ] );
12378
12379 // Normalize "", auto, and prepare for extra
12380 val = parseFloat( val ) || 0;
12381 }
12382
12383 // use the active box-sizing model to add/subtract irrelevant styles
12384 return ( val +
12385 augmentWidthOrHeight(
12386 elem,
12387 name,
12388 extra || ( isBorderBox ? "border" : "content" ),
12389 valueIsBorderBox,
12390 styles
12391 )
12392 ) + "px";
12393 }
12394
12395 function showHide( elements, show ) {
12396 var display, elem, hidden,
12397 values = [],
12398 index = 0,
12399 length = elements.length;
12400
12401 for ( ; index < length; index++ ) {
12402 elem = elements[ index ];
12403 if ( !elem.style ) {
12404 continue;
12405 }
12406
12407 values[ index ] = data_priv.get( elem, "olddisplay" );
12408 display = elem.style.display;
12409 if ( show ) {
12410 // Reset the inline display of this element to learn if it is
12411 // being hidden by cascaded rules or not
12412 if ( !values[ index ] && display === "none" ) {
12413 elem.style.display = "";
12414 }
12415
12416 // Set elements which have been overridden with display: none
12417 // in a stylesheet to whatever the default browser style is
12418 // for such an element
12419 if ( elem.style.display === "" && isHidden( elem ) ) {
12420 values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
12421 }
12422 } else {
12423 hidden = isHidden( elem );
12424
12425 if ( display !== "none" || !hidden ) {
12426 data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
12427 }
12428 }
12429 }
12430
12431 // Set the display of most of the elements in a second loop
12432 // to avoid the constant reflow
12433 for ( index = 0; index < length; index++ ) {
12434 elem = elements[ index ];
12435 if ( !elem.style ) {
12436 continue;
12437 }
12438 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
12439 elem.style.display = show ? values[ index ] || "" : "none";
12440 }
12441 }
12442
12443 return elements;
12444 }
12445
12446 jQuery.extend({
12447 // Add in style property hooks for overriding the default
12448 // behavior of getting and setting a style property
12449 cssHooks: {
12450 opacity: {
12451 get: function( elem, computed ) {
12452 if ( computed ) {
12453 // We should always get a number back from opacity
12454 var ret = curCSS( elem, "opacity" );
12455 return ret === "" ? "1" : ret;
12456 }
12457 }
12458 }
12459 },
12460
12461 // Don't automatically add "px" to these possibly-unitless properties
12462 cssNumber: {
12463 "columnCount": true,
12464 "fillOpacity": true,
12465 "flexGrow": true,
12466 "flexShrink": true,
12467 "fontWeight": true,
12468 "lineHeight": true,
12469 "opacity": true,
12470 "order": true,
12471 "orphans": true,
12472 "widows": true,
12473 "zIndex": true,
12474 "zoom": true
12475 },
12476
12477 // Add in properties whose names you wish to fix before
12478 // setting or getting the value
12479 cssProps: {
12480 // normalize float css property
12481 "float": "cssFloat"
12482 },
12483
12484 // Get and set the style property on a DOM Node
12485 style: function( elem, name, value, extra ) {
12486 // Don't set styles on text and comment nodes
12487 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
12488 return;
12489 }
12490
12491 // Make sure that we're working with the right name
12492 var ret, type, hooks,
12493 origName = jQuery.camelCase( name ),
12494 style = elem.style;
12495
12496 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
12497
12498 // gets hook for the prefixed version
12499 // followed by the unprefixed version
12500 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
12501
12502 // Check if we're setting a value
12503 if ( value !== undefined ) {
12504 type = typeof value;
12505
12506 // convert relative number strings (+= or -=) to relative numbers. #7345
12507 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
12508 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
12509 // Fixes bug #9237
12510 type = "number";
12511 }
12512
12513 // Make sure that null and NaN values aren't set. See: #7116
12514 if ( value == null || value !== value ) {
12515 return;
12516 }
12517
12518 // If a number was passed in, add 'px' to the (except for certain CSS properties)
12519 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
12520 value += "px";
12521 }
12522
12523 // Fixes #8908, it can be done more correctly by specifying setters in cssHooks,
12524 // but it would mean to define eight (for every problematic property) identical functions
12525 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
12526 style[ name ] = "inherit";
12527 }
12528
12529 // If a hook was provided, use that value, otherwise just set the specified value
12530 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
12531 style[ name ] = value;
12532 }
12533
12534 } else {
12535 // If a hook was provided get the non-computed value from there
12536 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
12537 return ret;
12538 }
12539
12540 // Otherwise just get the value from the style object
12541 return style[ name ];
12542 }
12543 },
12544
12545 css: function( elem, name, extra, styles ) {
12546 var val, num, hooks,
12547 origName = jQuery.camelCase( name );
12548
12549 // Make sure that we're working with the right name
12550 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
12551
12552 // gets hook for the prefixed version
12553 // followed by the unprefixed version
12554 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
12555
12556 // If a hook was provided get the computed value from there
12557 if ( hooks && "get" in hooks ) {
12558 val = hooks.get( elem, true, extra );
12559 }
12560
12561 // Otherwise, if a way to get the computed value exists, use that
12562 if ( val === undefined ) {
12563 val = curCSS( elem, name, styles );
12564 }
12565
12566 //convert "normal" to computed value
12567 if ( val === "normal" && name in cssNormalTransform ) {
12568 val = cssNormalTransform[ name ];
12569 }
12570
12571 // Return, converting to number if forced or a qualifier was provided and val looks numeric
12572 if ( extra === "" || extra ) {
12573 num = parseFloat( val );
12574 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
12575 }
12576 return val;
12577 }
12578 });
12579
12580 jQuery.each([ "height", "width" ], function( i, name ) {
12581 jQuery.cssHooks[ name ] = {
12582 get: function( elem, computed, extra ) {
12583 if ( computed ) {
12584 // certain elements can have dimension info if we invisibly show them
12585 // however, it must have a current display style that would benefit from this
12586 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
12587 jQuery.swap( elem, cssShow, function() {
12588 return getWidthOrHeight( elem, name, extra );
12589 }) :
12590 getWidthOrHeight( elem, name, extra );
12591 }
12592 },
12593
12594 set: function( elem, value, extra ) {
12595 var styles = extra && getStyles( elem );
12596 return setPositiveNumber( elem, value, extra ?
12597 augmentWidthOrHeight(
12598 elem,
12599 name,
12600 extra,
12601 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
12602 styles
12603 ) : 0
12604 );
12605 }
12606 };
12607 });
12608
12609 // Support: Android 2.3
12610 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
12611 function( elem, computed ) {
12612 if ( computed ) {
12613 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
12614 // Work around by temporarily setting element display to inline-block
12615 return jQuery.swap( elem, { "display": "inline-block" },
12616 curCSS, [ elem, "marginRight" ] );
12617 }
12618 }
12619 );
12620
12621 // These hooks are used by animate to expand properties
12622 jQuery.each({
12623 margin: "",
12624 padding: "",
12625 border: "Width"
12626 }, function( prefix, suffix ) {
12627 jQuery.cssHooks[ prefix + suffix ] = {
12628 expand: function( value ) {
12629 var i = 0,
12630 expanded = {},
12631
12632 // assumes a single number if not a string
12633 parts = typeof value === "string" ? value.split(" ") : [ value ];
12634
12635 for ( ; i < 4; i++ ) {
12636 expanded[ prefix + cssExpand[ i ] + suffix ] =
12637 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
12638 }
12639
12640 return expanded;
12641 }
12642 };
12643
12644 if ( !rmargin.test( prefix ) ) {
12645 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
12646 }
12647 });
12648
12649 jQuery.fn.extend({
12650 css: function( name, value ) {
12651 return access( this, function( elem, name, value ) {
12652 var styles, len,
12653 map = {},
12654 i = 0;
12655
12656 if ( jQuery.isArray( name ) ) {
12657 styles = getStyles( elem );
12658 len = name.length;
12659
12660 for ( ; i < len; i++ ) {
12661 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
12662 }
12663
12664 return map;
12665 }
12666
12667 return value !== undefined ?
12668 jQuery.style( elem, name, value ) :
12669 jQuery.css( elem, name );
12670 }, name, value, arguments.length > 1 );
12671 },
12672 show: function() {
12673 return showHide( this, true );
12674 },
12675 hide: function() {
12676 return showHide( this );
12677 },
12678 toggle: function( state ) {
12679 if ( typeof state === "boolean" ) {
12680 return state ? this.show() : this.hide();
12681 }
12682
12683 return this.each(function() {
12684 if ( isHidden( this ) ) {
12685 jQuery( this ).show();
12686 } else {
12687 jQuery( this ).hide();
12688 }
12689 });
12690 }
12691 });
12692
12693
12694 function Tween( elem, options, prop, end, easing ) {
12695 return new Tween.prototype.init( elem, options, prop, end, easing );
12696 }
12697 jQuery.Tween = Tween;
12698
12699 Tween.prototype = {
12700 constructor: Tween,
12701 init: function( elem, options, prop, end, easing, unit ) {
12702 this.elem = elem;
12703 this.prop = prop;
12704 this.easing = easing || "swing";
12705 this.options = options;
12706 this.start = this.now = this.cur();
12707 this.end = end;
12708 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
12709 },
12710 cur: function() {
12711 var hooks = Tween.propHooks[ this.prop ];
12712
12713 return hooks && hooks.get ?
12714 hooks.get( this ) :
12715 Tween.propHooks._default.get( this );
12716 },
12717 run: function( percent ) {
12718 var eased,
12719 hooks = Tween.propHooks[ this.prop ];
12720
12721 if ( this.options.duration ) {
12722 this.pos = eased = jQuery.easing[ this.easing ](
12723 percent, this.options.duration * percent, 0, 1, this.options.duration
12724 );
12725 } else {
12726 this.pos = eased = percent;
12727 }
12728 this.now = ( this.end - this.start ) * eased + this.start;
12729
12730 if ( this.options.step ) {
12731 this.options.step.call( this.elem, this.now, this );
12732 }
12733
12734 if ( hooks && hooks.set ) {
12735 hooks.set( this );
12736 } else {
12737 Tween.propHooks._default.set( this );
12738 }
12739 return this;
12740 }
12741 };
12742
12743 Tween.prototype.init.prototype = Tween.prototype;
12744
12745 Tween.propHooks = {
12746 _default: {
12747 get: function( tween ) {
12748 var result;
12749
12750 if ( tween.elem[ tween.prop ] != null &&
12751 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
12752 return tween.elem[ tween.prop ];
12753 }
12754
12755 // passing an empty string as a 3rd parameter to .css will automatically
12756 // attempt a parseFloat and fallback to a string if the parse fails
12757 // so, simple values such as "10px" are parsed to Float.
12758 // complex values such as "rotate(1rad)" are returned as is.
12759 result = jQuery.css( tween.elem, tween.prop, "" );
12760 // Empty strings, null, undefined and "auto" are converted to 0.
12761 return !result || result === "auto" ? 0 : result;
12762 },
12763 set: function( tween ) {
12764 // use step hook for back compat - use cssHook if its there - use .style if its
12765 // available and use plain properties where available
12766 if ( jQuery.fx.step[ tween.prop ] ) {
12767 jQuery.fx.step[ tween.prop ]( tween );
12768 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
12769 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
12770 } else {
12771 tween.elem[ tween.prop ] = tween.now;
12772 }
12773 }
12774 }
12775 };
12776
12777 // Support: IE9
12778 // Panic based approach to setting things on disconnected nodes
12779
12780 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
12781 set: function( tween ) {
12782 if ( tween.elem.nodeType && tween.elem.parentNode ) {
12783 tween.elem[ tween.prop ] = tween.now;
12784 }
12785 }
12786 };
12787
12788 jQuery.easing = {
12789 linear: function( p ) {
12790 return p;
12791 },
12792 swing: function( p ) {
12793 return 0.5 - Math.cos( p * Math.PI ) / 2;
12794 }
12795 };
12796
12797 jQuery.fx = Tween.prototype.init;
12798
12799 // Back Compat <1.8 extension point
12800 jQuery.fx.step = {};
12801
12802
12803
12804
12805 var
12806 fxNow, timerId,
12807 rfxtypes = /^(?:toggle|show|hide)$/,
12808 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
12809 rrun = /queueHooks$/,
12810 animationPrefilters = [ defaultPrefilter ],
12811 tweeners = {
12812 "*": [ function( prop, value ) {
12813 var tween = this.createTween( prop, value ),
12814 target = tween.cur(),
12815 parts = rfxnum.exec( value ),
12816 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
12817
12818 // Starting value computation is required for potential unit mismatches
12819 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
12820 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
12821 scale = 1,
12822 maxIterations = 20;
12823
12824 if ( start && start[ 3 ] !== unit ) {
12825 // Trust units reported by jQuery.css
12826 unit = unit || start[ 3 ];
12827
12828 // Make sure we update the tween properties later on
12829 parts = parts || [];
12830
12831 // Iteratively approximate from a nonzero starting point
12832 start = +target || 1;
12833
12834 do {
12835 // If previous iteration zeroed out, double until we get *something*
12836 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
12837 scale = scale || ".5";
12838
12839 // Adjust and apply
12840 start = start / scale;
12841 jQuery.style( tween.elem, prop, start + unit );
12842
12843 // Update scale, tolerating zero or NaN from tween.cur()
12844 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
12845 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
12846 }
12847
12848 // Update tween properties
12849 if ( parts ) {
12850 start = tween.start = +start || +target || 0;
12851 tween.unit = unit;
12852 // If a +=/-= token was provided, we're doing a relative animation
12853 tween.end = parts[ 1 ] ?
12854 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
12855 +parts[ 2 ];
12856 }
12857
12858 return tween;
12859 } ]
12860 };
12861
12862 // Animations created synchronously will run synchronously
12863 function createFxNow() {
12864 setTimeout(function() {
12865 fxNow = undefined;
12866 });
12867 return ( fxNow = jQuery.now() );
12868 }
12869
12870 // Generate parameters to create a standard animation
12871 function genFx( type, includeWidth ) {
12872 var which,
12873 i = 0,
12874 attrs = { height: type };
12875
12876 // if we include width, step value is 1 to do all cssExpand values,
12877 // if we don't include width, step value is 2 to skip over Left and Right
12878 includeWidth = includeWidth ? 1 : 0;
12879 for ( ; i < 4 ; i += 2 - includeWidth ) {
12880 which = cssExpand[ i ];
12881 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
12882 }
12883
12884 if ( includeWidth ) {
12885 attrs.opacity = attrs.width = type;
12886 }
12887
12888 return attrs;
12889 }
12890
12891 function createTween( value, prop, animation ) {
12892 var tween,
12893 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
12894 index = 0,
12895 length = collection.length;
12896 for ( ; index < length; index++ ) {
12897 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
12898
12899 // we're done with this property
12900 return tween;
12901 }
12902 }
12903 }
12904
12905 function defaultPrefilter( elem, props, opts ) {
12906 /* jshint validthis: true */
12907 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
12908 anim = this,
12909 orig = {},
12910 style = elem.style,
12911 hidden = elem.nodeType && isHidden( elem ),
12912 dataShow = data_priv.get( elem, "fxshow" );
12913
12914 // handle queue: false promises
12915 if ( !opts.queue ) {
12916 hooks = jQuery._queueHooks( elem, "fx" );
12917 if ( hooks.unqueued == null ) {
12918 hooks.unqueued = 0;
12919 oldfire = hooks.empty.fire;
12920 hooks.empty.fire = function() {
12921 if ( !hooks.unqueued ) {
12922 oldfire();
12923 }
12924 };
12925 }
12926 hooks.unqueued++;
12927
12928 anim.always(function() {
12929 // doing this makes sure that the complete handler will be called
12930 // before this completes
12931 anim.always(function() {
12932 hooks.unqueued--;
12933 if ( !jQuery.queue( elem, "fx" ).length ) {
12934 hooks.empty.fire();
12935 }
12936 });
12937 });
12938 }
12939
12940 // height/width overflow pass
12941 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
12942 // Make sure that nothing sneaks out
12943 // Record all 3 overflow attributes because IE9-10 do not
12944 // change the overflow attribute when overflowX and
12945 // overflowY are set to the same value
12946 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
12947
12948 // Set display property to inline-block for height/width
12949 // animations on inline elements that are having width/height animated
12950 display = jQuery.css( elem, "display" );
12951
12952 // Test default display if display is currently "none"
12953 checkDisplay = display === "none" ?
12954 data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
12955
12956 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
12957 style.display = "inline-block";
12958 }
12959 }
12960
12961 if ( opts.overflow ) {
12962 style.overflow = "hidden";
12963 anim.always(function() {
12964 style.overflow = opts.overflow[ 0 ];
12965 style.overflowX = opts.overflow[ 1 ];
12966 style.overflowY = opts.overflow[ 2 ];
12967 });
12968 }
12969
12970 // show/hide pass
12971 for ( prop in props ) {
12972 value = props[ prop ];
12973 if ( rfxtypes.exec( value ) ) {
12974 delete props[ prop ];
12975 toggle = toggle || value === "toggle";
12976 if ( value === ( hidden ? "hide" : "show" ) ) {
12977
12978 // 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
12979 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
12980 hidden = true;
12981 } else {
12982 continue;
12983 }
12984 }
12985 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
12986
12987 // Any non-fx value stops us from restoring the original display value
12988 } else {
12989 display = undefined;
12990 }
12991 }
12992
12993 if ( !jQuery.isEmptyObject( orig ) ) {
12994 if ( dataShow ) {
12995 if ( "hidden" in dataShow ) {
12996 hidden = dataShow.hidden;
12997 }
12998 } else {
12999 dataShow = data_priv.access( elem, "fxshow", {} );
13000 }
13001
13002 // store state if its toggle - enables .stop().toggle() to "reverse"
13003 if ( toggle ) {
13004 dataShow.hidden = !hidden;
13005 }
13006 if ( hidden ) {
13007 jQuery( elem ).show();
13008 } else {
13009 anim.done(function() {
13010 jQuery( elem ).hide();
13011 });
13012 }
13013 anim.done(function() {
13014 var prop;
13015
13016 data_priv.remove( elem, "fxshow" );
13017 for ( prop in orig ) {
13018 jQuery.style( elem, prop, orig[ prop ] );
13019 }
13020 });
13021 for ( prop in orig ) {
13022 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
13023
13024 if ( !( prop in dataShow ) ) {
13025 dataShow[ prop ] = tween.start;
13026 if ( hidden ) {
13027 tween.end = tween.start;
13028 tween.start = prop === "width" || prop === "height" ? 1 : 0;
13029 }
13030 }
13031 }
13032
13033 // If this is a noop like .hide().hide(), restore an overwritten display value
13034 } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
13035 style.display = display;
13036 }
13037 }
13038
13039 function propFilter( props, specialEasing ) {
13040 var index, name, easing, value, hooks;
13041
13042 // camelCase, specialEasing and expand cssHook pass
13043 for ( index in props ) {
13044 name = jQuery.camelCase( index );
13045 easing = specialEasing[ name ];
13046 value = props[ index ];
13047 if ( jQuery.isArray( value ) ) {
13048 easing = value[ 1 ];
13049 value = props[ index ] = value[ 0 ];
13050 }
13051
13052 if ( index !== name ) {
13053 props[ name ] = value;
13054 delete props[ index ];
13055 }
13056
13057 hooks = jQuery.cssHooks[ name ];
13058 if ( hooks && "expand" in hooks ) {
13059 value = hooks.expand( value );
13060 delete props[ name ];
13061
13062 // not quite $.extend, this wont overwrite keys already present.
13063 // also - reusing 'index' from above because we have the correct "name"
13064 for ( index in value ) {
13065 if ( !( index in props ) ) {
13066 props[ index ] = value[ index ];
13067 specialEasing[ index ] = easing;
13068 }
13069 }
13070 } else {
13071 specialEasing[ name ] = easing;
13072 }
13073 }
13074 }
13075
13076 function Animation( elem, properties, options ) {
13077 var result,
13078 stopped,
13079 index = 0,
13080 length = animationPrefilters.length,
13081 deferred = jQuery.Deferred().always( function() {
13082 // don't match elem in the :animated selector
13083 delete tick.elem;
13084 }),
13085 tick = function() {
13086 if ( stopped ) {
13087 return false;
13088 }
13089 var currentTime = fxNow || createFxNow(),
13090 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
13091 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
13092 temp = remaining / animation.duration || 0,
13093 percent = 1 - temp,
13094 index = 0,
13095 length = animation.tweens.length;
13096
13097 for ( ; index < length ; index++ ) {
13098 animation.tweens[ index ].run( percent );
13099 }
13100
13101 deferred.notifyWith( elem, [ animation, percent, remaining ]);
13102
13103 if ( percent < 1 && length ) {
13104 return remaining;
13105 } else {
13106 deferred.resolveWith( elem, [ animation ] );
13107 return false;
13108 }
13109 },
13110 animation = deferred.promise({
13111 elem: elem,
13112 props: jQuery.extend( {}, properties ),
13113 opts: jQuery.extend( true, { specialEasing: {} }, options ),
13114 originalProperties: properties,
13115 originalOptions: options,
13116 startTime: fxNow || createFxNow(),
13117 duration: options.duration,
13118 tweens: [],
13119 createTween: function( prop, end ) {
13120 var tween = jQuery.Tween( elem, animation.opts, prop, end,
13121 animation.opts.specialEasing[ prop ] || animation.opts.easing );
13122 animation.tweens.push( tween );
13123 return tween;
13124 },
13125 stop: function( gotoEnd ) {
13126 var index = 0,
13127 // if we are going to the end, we want to run all the tweens
13128 // otherwise we skip this part
13129 length = gotoEnd ? animation.tweens.length : 0;
13130 if ( stopped ) {
13131 return this;
13132 }
13133 stopped = true;
13134 for ( ; index < length ; index++ ) {
13135 animation.tweens[ index ].run( 1 );
13136 }
13137
13138 // resolve when we played the last frame
13139 // otherwise, reject
13140 if ( gotoEnd ) {
13141 deferred.resolveWith( elem, [ animation, gotoEnd ] );
13142 } else {
13143 deferred.rejectWith( elem, [ animation, gotoEnd ] );
13144 }
13145 return this;
13146 }
13147 }),
13148 props = animation.props;
13149
13150 propFilter( props, animation.opts.specialEasing );
13151
13152 for ( ; index < length ; index++ ) {
13153 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
13154 if ( result ) {
13155 return result;
13156 }
13157 }
13158
13159 jQuery.map( props, createTween, animation );
13160
13161 if ( jQuery.isFunction( animation.opts.start ) ) {
13162 animation.opts.start.call( elem, animation );
13163 }
13164
13165 jQuery.fx.timer(
13166 jQuery.extend( tick, {
13167 elem: elem,
13168 anim: animation,
13169 queue: animation.opts.queue
13170 })
13171 );
13172
13173 // attach callbacks from options
13174 return animation.progress( animation.opts.progress )
13175 .done( animation.opts.done, animation.opts.complete )
13176 .fail( animation.opts.fail )
13177 .always( animation.opts.always );
13178 }
13179
13180 jQuery.Animation = jQuery.extend( Animation, {
13181
13182 tweener: function( props, callback ) {
13183 if ( jQuery.isFunction( props ) ) {
13184 callback = props;
13185 props = [ "*" ];
13186 } else {
13187 props = props.split(" ");
13188 }
13189
13190 var prop,
13191 index = 0,
13192 length = props.length;
13193
13194 for ( ; index < length ; index++ ) {
13195 prop = props[ index ];
13196 tweeners[ prop ] = tweeners[ prop ] || [];
13197 tweeners[ prop ].unshift( callback );
13198 }
13199 },
13200
13201 prefilter: function( callback, prepend ) {
13202 if ( prepend ) {
13203 animationPrefilters.unshift( callback );
13204 } else {
13205 animationPrefilters.push( callback );
13206 }
13207 }
13208 });
13209
13210 jQuery.speed = function( speed, easing, fn ) {
13211 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
13212 complete: fn || !fn && easing ||
13213 jQuery.isFunction( speed ) && speed,
13214 duration: speed,
13215 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
13216 };
13217
13218 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
13219 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
13220
13221 // normalize opt.queue - true/undefined/null -> "fx"
13222 if ( opt.queue == null || opt.queue === true ) {
13223 opt.queue = "fx";
13224 }
13225
13226 // Queueing
13227 opt.old = opt.complete;
13228
13229 opt.complete = function() {
13230 if ( jQuery.isFunction( opt.old ) ) {
13231 opt.old.call( this );
13232 }
13233
13234 if ( opt.queue ) {
13235 jQuery.dequeue( this, opt.queue );
13236 }
13237 };
13238
13239 return opt;
13240 };
13241
13242 jQuery.fn.extend({
13243 fadeTo: function( speed, to, easing, callback ) {
13244
13245 // show any hidden elements after setting opacity to 0
13246 return this.filter( isHidden ).css( "opacity", 0 ).show()
13247
13248 // animate to the value specified
13249 .end().animate({ opacity: to }, speed, easing, callback );
13250 },
13251 animate: function( prop, speed, easing, callback ) {
13252 var empty = jQuery.isEmptyObject( prop ),
13253 optall = jQuery.speed( speed, easing, callback ),
13254 doAnimation = function() {
13255 // Operate on a copy of prop so per-property easing won't be lost
13256 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
13257
13258 // Empty animations, or finishing resolves immediately
13259 if ( empty || data_priv.get( this, "finish" ) ) {
13260 anim.stop( true );
13261 }
13262 };
13263 doAnimation.finish = doAnimation;
13264
13265 return empty || optall.queue === false ?
13266 this.each( doAnimation ) :
13267 this.queue( optall.queue, doAnimation );
13268 },
13269 stop: function( type, clearQueue, gotoEnd ) {
13270 var stopQueue = function( hooks ) {
13271 var stop = hooks.stop;
13272 delete hooks.stop;
13273 stop( gotoEnd );
13274 };
13275
13276 if ( typeof type !== "string" ) {
13277 gotoEnd = clearQueue;
13278 clearQueue = type;
13279 type = undefined;
13280 }
13281 if ( clearQueue && type !== false ) {
13282 this.queue( type || "fx", [] );
13283 }
13284
13285 return this.each(function() {
13286 var dequeue = true,
13287 index = type != null && type + "queueHooks",
13288 timers = jQuery.timers,
13289 data = data_priv.get( this );
13290
13291 if ( index ) {
13292 if ( data[ index ] && data[ index ].stop ) {
13293 stopQueue( data[ index ] );
13294 }
13295 } else {
13296 for ( index in data ) {
13297 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
13298 stopQueue( data[ index ] );
13299 }
13300 }
13301 }
13302
13303 for ( index = timers.length; index--; ) {
13304 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
13305 timers[ index ].anim.stop( gotoEnd );
13306 dequeue = false;
13307 timers.splice( index, 1 );
13308 }
13309 }
13310
13311 // start the next in the queue if the last step wasn't forced
13312 // timers currently will call their complete callbacks, which will dequeue
13313 // but only if they were gotoEnd
13314 if ( dequeue || !gotoEnd ) {
13315 jQuery.dequeue( this, type );
13316 }
13317 });
13318 },
13319 finish: function( type ) {
13320 if ( type !== false ) {
13321 type = type || "fx";
13322 }
13323 return this.each(function() {
13324 var index,
13325 data = data_priv.get( this ),
13326 queue = data[ type + "queue" ],
13327 hooks = data[ type + "queueHooks" ],
13328 timers = jQuery.timers,
13329 length = queue ? queue.length : 0;
13330
13331 // enable finishing flag on private data
13332 data.finish = true;
13333
13334 // empty the queue first
13335 jQuery.queue( this, type, [] );
13336
13337 if ( hooks && hooks.stop ) {
13338 hooks.stop.call( this, true );
13339 }
13340
13341 // look for any active animations, and finish them
13342 for ( index = timers.length; index--; ) {
13343 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
13344 timers[ index ].anim.stop( true );
13345 timers.splice( index, 1 );
13346 }
13347 }
13348
13349 // look for any animations in the old queue and finish them
13350 for ( index = 0; index < length; index++ ) {
13351 if ( queue[ index ] && queue[ index ].finish ) {
13352 queue[ index ].finish.call( this );
13353 }
13354 }
13355
13356 // turn off finishing flag
13357 delete data.finish;
13358 });
13359 }
13360 });
13361
13362 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
13363 var cssFn = jQuery.fn[ name ];
13364 jQuery.fn[ name ] = function( speed, easing, callback ) {
13365 return speed == null || typeof speed === "boolean" ?
13366 cssFn.apply( this, arguments ) :
13367 this.animate( genFx( name, true ), speed, easing, callback );
13368 };
13369 });
13370
13371 // Generate shortcuts for custom animations
13372 jQuery.each({
13373 slideDown: genFx("show"),
13374 slideUp: genFx("hide"),
13375 slideToggle: genFx("toggle"),
13376 fadeIn: { opacity: "show" },
13377 fadeOut: { opacity: "hide" },
13378 fadeToggle: { opacity: "toggle" }
13379 }, function( name, props ) {
13380 jQuery.fn[ name ] = function( speed, easing, callback ) {
13381 return this.animate( props, speed, easing, callback );
13382 };
13383 });
13384
13385 jQuery.timers = [];
13386 jQuery.fx.tick = function() {
13387 var timer,
13388 i = 0,
13389 timers = jQuery.timers;
13390
13391 fxNow = jQuery.now();
13392
13393 for ( ; i < timers.length; i++ ) {
13394 timer = timers[ i ];
13395 // Checks the timer has not already been removed
13396 if ( !timer() && timers[ i ] === timer ) {
13397 timers.splice( i--, 1 );
13398 }
13399 }
13400
13401 if ( !timers.length ) {
13402 jQuery.fx.stop();
13403 }
13404 fxNow = undefined;
13405 };
13406
13407 jQuery.fx.timer = function( timer ) {
13408 jQuery.timers.push( timer );
13409 if ( timer() ) {
13410 jQuery.fx.start();
13411 } else {
13412 jQuery.timers.pop();
13413 }
13414 };
13415
13416 jQuery.fx.interval = 13;
13417
13418 jQuery.fx.start = function() {
13419 if ( !timerId ) {
13420 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
13421 }
13422 };
13423
13424 jQuery.fx.stop = function() {
13425 clearInterval( timerId );
13426 timerId = null;
13427 };
13428
13429 jQuery.fx.speeds = {
13430 slow: 600,
13431 fast: 200,
13432 // Default speed
13433 _default: 400
13434 };
13435
13436
13437 // Based off of the plugin by Clint Helfers, with permission.
13438 // http://blindsignals.com/index.php/2009/07/jquery-delay/
13439 jQuery.fn.delay = function( time, type ) {
13440 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
13441 type = type || "fx";
13442
13443 return this.queue( type, function( next, hooks ) {
13444 var timeout = setTimeout( next, time );
13445 hooks.stop = function() {
13446 clearTimeout( timeout );
13447 };
13448 });
13449 };
13450
13451
13452 (function() {
13453 var input = document.createElement( "input" ),
13454 select = document.createElement( "select" ),
13455 opt = select.appendChild( document.createElement( "option" ) );
13456
13457 input.type = "checkbox";
13458
13459 // Support: iOS 5.1, Android 4.x, Android 2.3
13460 // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
13461 support.checkOn = input.value !== "";
13462
13463 // Must access the parent to make an option select properly
13464 // Support: IE9, IE10
13465 support.optSelected = opt.selected;
13466
13467 // Make sure that the options inside disabled selects aren't marked as disabled
13468 // (WebKit marks them as disabled)
13469 select.disabled = true;
13470 support.optDisabled = !opt.disabled;
13471
13472 // Check if an input maintains its value after becoming a radio
13473 // Support: IE9, IE10
13474 input = document.createElement( "input" );
13475 input.value = "t";
13476 input.type = "radio";
13477 support.radioValue = input.value === "t";
13478 })();
13479
13480
13481 var nodeHook, boolHook,
13482 attrHandle = jQuery.expr.attrHandle;
13483
13484 jQuery.fn.extend({
13485 attr: function( name, value ) {
13486 return access( this, jQuery.attr, name, value, arguments.length > 1 );
13487 },
13488
13489 removeAttr: function( name ) {
13490 return this.each(function() {
13491 jQuery.removeAttr( this, name );
13492 });
13493 }
13494 });
13495
13496 jQuery.extend({
13497 attr: function( elem, name, value ) {
13498 var hooks, ret,
13499 nType = elem.nodeType;
13500
13501 // don't get/set attributes on text, comment and attribute nodes
13502 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
13503 return;
13504 }
13505
13506 // Fallback to prop when attributes are not supported
13507 if ( typeof elem.getAttribute === strundefined ) {
13508 return jQuery.prop( elem, name, value );
13509 }
13510
13511 // All attributes are lowercase
13512 // Grab necessary hook if one is defined
13513 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
13514 name = name.toLowerCase();
13515 hooks = jQuery.attrHooks[ name ] ||
13516 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
13517 }
13518
13519 if ( value !== undefined ) {
13520
13521 if ( value === null ) {
13522 jQuery.removeAttr( elem, name );
13523
13524 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
13525 return ret;
13526
13527 } else {
13528 elem.setAttribute( name, value + "" );
13529 return value;
13530 }
13531
13532 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
13533 return ret;
13534
13535 } else {
13536 ret = jQuery.find.attr( elem, name );
13537
13538 // Non-existent attributes return null, we normalize to undefined
13539 return ret == null ?
13540 undefined :
13541 ret;
13542 }
13543 },
13544
13545 removeAttr: function( elem, value ) {
13546 var name, propName,
13547 i = 0,
13548 attrNames = value && value.match( rnotwhite );
13549
13550 if ( attrNames && elem.nodeType === 1 ) {
13551 while ( (name = attrNames[i++]) ) {
13552 propName = jQuery.propFix[ name ] || name;
13553
13554 // Boolean attributes get special treatment (#10870)
13555 if ( jQuery.expr.match.bool.test( name ) ) {
13556 // Set corresponding property to false
13557 elem[ propName ] = false;
13558 }
13559
13560 elem.removeAttribute( name );
13561 }
13562 }
13563 },
13564
13565 attrHooks: {
13566 type: {
13567 set: function( elem, value ) {
13568 if ( !support.radioValue && value === "radio" &&
13569 jQuery.nodeName( elem, "input" ) ) {
13570 // Setting the type on a radio button after the value resets the value in IE6-9
13571 // Reset value to default in case type is set after value during creation
13572 var val = elem.value;
13573 elem.setAttribute( "type", value );
13574 if ( val ) {
13575 elem.value = val;
13576 }
13577 return value;
13578 }
13579 }
13580 }
13581 }
13582 });
13583
13584 // Hooks for boolean attributes
13585 boolHook = {
13586 set: function( elem, value, name ) {
13587 if ( value === false ) {
13588 // Remove boolean attributes when set to false
13589 jQuery.removeAttr( elem, name );
13590 } else {
13591 elem.setAttribute( name, name );
13592 }
13593 return name;
13594 }
13595 };
13596 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
13597 var getter = attrHandle[ name ] || jQuery.find.attr;
13598
13599 attrHandle[ name ] = function( elem, name, isXML ) {
13600 var ret, handle;
13601 if ( !isXML ) {
13602 // Avoid an infinite loop by temporarily removing this function from the getter
13603 handle = attrHandle[ name ];
13604 attrHandle[ name ] = ret;
13605 ret = getter( elem, name, isXML ) != null ?
13606 name.toLowerCase() :
13607 null;
13608 attrHandle[ name ] = handle;
13609 }
13610 return ret;
13611 };
13612 });
13613
13614
13615
13616
13617 var rfocusable = /^(?:input|select|textarea|button)$/i;
13618
13619 jQuery.fn.extend({
13620 prop: function( name, value ) {
13621 return access( this, jQuery.prop, name, value, arguments.length > 1 );
13622 },
13623
13624 removeProp: function( name ) {
13625 return this.each(function() {
13626 delete this[ jQuery.propFix[ name ] || name ];
13627 });
13628 }
13629 });
13630
13631 jQuery.extend({
13632 propFix: {
13633 "for": "htmlFor",
13634 "class": "className"
13635 },
13636
13637 prop: function( elem, name, value ) {
13638 var ret, hooks, notxml,
13639 nType = elem.nodeType;
13640
13641 // don't get/set properties on text, comment and attribute nodes
13642 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
13643 return;
13644 }
13645
13646 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
13647
13648 if ( notxml ) {
13649 // Fix name and attach hooks
13650 name = jQuery.propFix[ name ] || name;
13651 hooks = jQuery.propHooks[ name ];
13652 }
13653
13654 if ( value !== undefined ) {
13655 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
13656 ret :
13657 ( elem[ name ] = value );
13658
13659 } else {
13660 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
13661 ret :
13662 elem[ name ];
13663 }
13664 },
13665
13666 propHooks: {
13667 tabIndex: {
13668 get: function( elem ) {
13669 return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
13670 elem.tabIndex :
13671 -1;
13672 }
13673 }
13674 }
13675 });
13676
13677 // Support: IE9+
13678 // Selectedness for an option in an optgroup can be inaccurate
13679 if ( !support.optSelected ) {
13680 jQuery.propHooks.selected = {
13681 get: function( elem ) {
13682 var parent = elem.parentNode;
13683 if ( parent && parent.parentNode ) {
13684 parent.parentNode.selectedIndex;
13685 }
13686 return null;
13687 }
13688 };
13689 }
13690
13691 jQuery.each([
13692 "tabIndex",
13693 "readOnly",
13694 "maxLength",
13695 "cellSpacing",
13696 "cellPadding",
13697 "rowSpan",
13698 "colSpan",
13699 "useMap",
13700 "frameBorder",
13701 "contentEditable"
13702 ], function() {
13703 jQuery.propFix[ this.toLowerCase() ] = this;
13704 });
13705
13706
13707
13708
13709 var rclass = /[\t\r\n\f]/g;
13710
13711 jQuery.fn.extend({
13712 addClass: function( value ) {
13713 var classes, elem, cur, clazz, j, finalValue,
13714 proceed = typeof value === "string" && value,
13715 i = 0,
13716 len = this.length;
13717
13718 if ( jQuery.isFunction( value ) ) {
13719 return this.each(function( j ) {
13720 jQuery( this ).addClass( value.call( this, j, this.className ) );
13721 });
13722 }
13723
13724 if ( proceed ) {
13725 // The disjunction here is for better compressibility (see removeClass)
13726 classes = ( value || "" ).match( rnotwhite ) || [];
13727
13728 for ( ; i < len; i++ ) {
13729 elem = this[ i ];
13730 cur = elem.nodeType === 1 && ( elem.className ?
13731 ( " " + elem.className + " " ).replace( rclass, " " ) :
13732 " "
13733 );
13734
13735 if ( cur ) {
13736 j = 0;
13737 while ( (clazz = classes[j++]) ) {
13738 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
13739 cur += clazz + " ";
13740 }
13741 }
13742
13743 // only assign if different to avoid unneeded rendering.
13744 finalValue = jQuery.trim( cur );
13745 if ( elem.className !== finalValue ) {
13746 elem.className = finalValue;
13747 }
13748 }
13749 }
13750 }
13751
13752 return this;
13753 },
13754
13755 removeClass: function( value ) {
13756 var classes, elem, cur, clazz, j, finalValue,
13757 proceed = arguments.length === 0 || typeof value === "string" && value,
13758 i = 0,
13759 len = this.length;
13760
13761 if ( jQuery.isFunction( value ) ) {
13762 return this.each(function( j ) {
13763 jQuery( this ).removeClass( value.call( this, j, this.className ) );
13764 });
13765 }
13766 if ( proceed ) {
13767 classes = ( value || "" ).match( rnotwhite ) || [];
13768
13769 for ( ; i < len; i++ ) {
13770 elem = this[ i ];
13771 // This expression is here for better compressibility (see addClass)
13772 cur = elem.nodeType === 1 && ( elem.className ?
13773 ( " " + elem.className + " " ).replace( rclass, " " ) :
13774 ""
13775 );
13776
13777 if ( cur ) {
13778 j = 0;
13779 while ( (clazz = classes[j++]) ) {
13780 // Remove *all* instances
13781 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
13782 cur = cur.replace( " " + clazz + " ", " " );
13783 }
13784 }
13785
13786 // only assign if different to avoid unneeded rendering.
13787 finalValue = value ? jQuery.trim( cur ) : "";
13788 if ( elem.className !== finalValue ) {
13789 elem.className = finalValue;
13790 }
13791 }
13792 }
13793 }
13794
13795 return this;
13796 },
13797
13798 toggleClass: function( value, stateVal ) {
13799 var type = typeof value;
13800
13801 if ( typeof stateVal === "boolean" && type === "string" ) {
13802 return stateVal ? this.addClass( value ) : this.removeClass( value );
13803 }
13804
13805 if ( jQuery.isFunction( value ) ) {
13806 return this.each(function( i ) {
13807 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
13808 });
13809 }
13810
13811 return this.each(function() {
13812 if ( type === "string" ) {
13813 // toggle individual class names
13814 var className,
13815 i = 0,
13816 self = jQuery( this ),
13817 classNames = value.match( rnotwhite ) || [];
13818
13819 while ( (className = classNames[ i++ ]) ) {
13820 // check each className given, space separated list
13821 if ( self.hasClass( className ) ) {
13822 self.removeClass( className );
13823 } else {
13824 self.addClass( className );
13825 }
13826 }
13827
13828 // Toggle whole class name
13829 } else if ( type === strundefined || type === "boolean" ) {
13830 if ( this.className ) {
13831 // store className if set
13832 data_priv.set( this, "__className__", this.className );
13833 }
13834
13835 // If the element has a class name or if we're passed "false",
13836 // then remove the whole classname (if there was one, the above saved it).
13837 // Otherwise bring back whatever was previously saved (if anything),
13838 // falling back to the empty string if nothing was stored.
13839 this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
13840 }
13841 });
13842 },
13843
13844 hasClass: function( selector ) {
13845 var className = " " + selector + " ",
13846 i = 0,
13847 l = this.length;
13848 for ( ; i < l; i++ ) {
13849 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
13850 return true;
13851 }
13852 }
13853
13854 return false;
13855 }
13856 });
13857
13858
13859
13860
13861 var rreturn = /\r/g;
13862
13863 jQuery.fn.extend({
13864 val: function( value ) {
13865 var hooks, ret, isFunction,
13866 elem = this[0];
13867
13868 if ( !arguments.length ) {
13869 if ( elem ) {
13870 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
13871
13872 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
13873 return ret;
13874 }
13875
13876 ret = elem.value;
13877
13878 return typeof ret === "string" ?
13879 // handle most common string cases
13880 ret.replace(rreturn, "") :
13881 // handle cases where value is null/undef or number
13882 ret == null ? "" : ret;
13883 }
13884
13885 return;
13886 }
13887
13888 isFunction = jQuery.isFunction( value );
13889
13890 return this.each(function( i ) {
13891 var val;
13892
13893 if ( this.nodeType !== 1 ) {
13894 return;
13895 }
13896
13897 if ( isFunction ) {
13898 val = value.call( this, i, jQuery( this ).val() );
13899 } else {
13900 val = value;
13901 }
13902
13903 // Treat null/undefined as ""; convert numbers to string
13904 if ( val == null ) {
13905 val = "";
13906
13907 } else if ( typeof val === "number" ) {
13908 val += "";
13909
13910 } else if ( jQuery.isArray( val ) ) {
13911 val = jQuery.map( val, function( value ) {
13912 return value == null ? "" : value + "";
13913 });
13914 }
13915
13916 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
13917
13918 // If set returns undefined, fall back to normal setting
13919 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
13920 this.value = val;
13921 }
13922 });
13923 }
13924 });
13925
13926 jQuery.extend({
13927 valHooks: {
13928 option: {
13929 get: function( elem ) {
13930 var val = jQuery.find.attr( elem, "value" );
13931 return val != null ?
13932 val :
13933 // Support: IE10-11+
13934 // option.text throws exceptions (#14686, #14858)
13935 jQuery.trim( jQuery.text( elem ) );
13936 }
13937 },
13938 select: {
13939 get: function( elem ) {
13940 var value, option,
13941 options = elem.options,
13942 index = elem.selectedIndex,
13943 one = elem.type === "select-one" || index < 0,
13944 values = one ? null : [],
13945 max = one ? index + 1 : options.length,
13946 i = index < 0 ?
13947 max :
13948 one ? index : 0;
13949
13950 // Loop through all the selected options
13951 for ( ; i < max; i++ ) {
13952 option = options[ i ];
13953
13954 // IE6-9 doesn't update selected after form reset (#2551)
13955 if ( ( option.selected || i === index ) &&
13956 // Don't return options that are disabled or in a disabled optgroup
13957 ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) &&
13958 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
13959
13960 // Get the specific value for the option
13961 value = jQuery( option ).val();
13962
13963 // We don't need an array for one selects
13964 if ( one ) {
13965 return value;
13966 }
13967
13968 // Multi-Selects return an array
13969 values.push( value );
13970 }
13971 }
13972
13973 return values;
13974 },
13975
13976 set: function( elem, value ) {
13977 var optionSet, option,
13978 options = elem.options,
13979 values = jQuery.makeArray( value ),
13980 i = options.length;
13981
13982 while ( i-- ) {
13983 option = options[ i ];
13984 if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) {
13985 optionSet = true;
13986 }
13987 }
13988
13989 // force browsers to behave consistently when non-matching value is set
13990 if ( !optionSet ) {
13991 elem.selectedIndex = -1;
13992 }
13993 return values;
13994 }
13995 }
13996 }
13997 });
13998
13999 // Radios and checkboxes getter/setter
14000 jQuery.each([ "radio", "checkbox" ], function() {
14001 jQuery.valHooks[ this ] = {
14002 set: function( elem, value ) {
14003 if ( jQuery.isArray( value ) ) {
14004 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
14005 }
14006 }
14007 };
14008 if ( !support.checkOn ) {
14009 jQuery.valHooks[ this ].get = function( elem ) {
14010 // Support: Webkit
14011 // "" is returned instead of "on" if a value isn't specified
14012 return elem.getAttribute("value") === null ? "on" : elem.value;
14013 };
14014 }
14015 });
14016
14017
14018
14019
14020 // Return jQuery for attributes-only inclusion
14021
14022
14023 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
14024 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
14025 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
14026
14027 // Handle event binding
14028 jQuery.fn[ name ] = function( data, fn ) {
14029 return arguments.length > 0 ?
14030 this.on( name, null, data, fn ) :
14031 this.trigger( name );
14032 };
14033 });
14034
14035 jQuery.fn.extend({
14036 hover: function( fnOver, fnOut ) {
14037 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
14038 },
14039
14040 bind: function( types, data, fn ) {
14041 return this.on( types, null, data, fn );
14042 },
14043 unbind: function( types, fn ) {
14044 return this.off( types, null, fn );
14045 },
14046
14047 delegate: function( selector, types, data, fn ) {
14048 return this.on( types, selector, data, fn );
14049 },
14050 undelegate: function( selector, types, fn ) {
14051 // ( namespace ) or ( selector, types [, fn] )
14052 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
14053 }
14054 });
14055
14056
14057 var nonce = jQuery.now();
14058
14059 var rquery = (/\?/);
14060
14061
14062
14063 // Support: Android 2.3
14064 // Workaround failure to string-cast null input
14065 jQuery.parseJSON = function( data ) {
14066 return JSON.parse( data + "" );
14067 };
14068
14069
14070 // Cross-browser xml parsing
14071 jQuery.parseXML = function( data ) {
14072 var xml, tmp;
14073 if ( !data || typeof data !== "string" ) {
14074 return null;
14075 }
14076
14077 // Support: IE9
14078 try {
14079 tmp = new DOMParser();
14080 xml = tmp.parseFromString( data, "text/xml" );
14081 } catch ( e ) {
14082 xml = undefined;
14083 }
14084
14085 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
14086 jQuery.error( "Invalid XML: " + data );
14087 }
14088 return xml;
14089 };
14090
14091
14092 var
14093 // Document location
14094 ajaxLocParts,
14095 ajaxLocation,
14096
14097 rhash = /#.*$/,
14098 rts = /([?&])_=[^&]*/,
14099 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
14100 // #7653, #8125, #8152: local protocol detection
14101 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
14102 rnoContent = /^(?:GET|HEAD)$/,
14103 rprotocol = /^\/\//,
14104 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
14105
14106 /* Prefilters
14107 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
14108 * 2) These are called:
14109 * - BEFORE asking for a transport
14110 * - AFTER param serialization (s.data is a string if s.processData is true)
14111 * 3) key is the dataType
14112 * 4) the catchall symbol "*" can be used
14113 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
14114 */
14115 prefilters = {},
14116
14117 /* Transports bindings
14118 * 1) key is the dataType
14119 * 2) the catchall symbol "*" can be used
14120 * 3) selection will start with transport dataType and THEN go to "*" if needed
14121 */
14122 transports = {},
14123
14124 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
14125 allTypes = "*/".concat("*");
14126
14127 // #8138, IE may throw an exception when accessing
14128 // a field from window.location if document.domain has been set
14129 try {
14130 ajaxLocation = location.href;
14131 } catch( e ) {
14132 // Use the href attribute of an A element
14133 // since IE will modify it given document.location
14134 ajaxLocation = document.createElement( "a" );
14135 ajaxLocation.href = "";
14136 ajaxLocation = ajaxLocation.href;
14137 }
14138
14139 // Segment location into parts
14140 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
14141
14142 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
14143 function addToPrefiltersOrTransports( structure ) {
14144
14145 // dataTypeExpression is optional and defaults to "*"
14146 return function( dataTypeExpression, func ) {
14147
14148 if ( typeof dataTypeExpression !== "string" ) {
14149 func = dataTypeExpression;
14150 dataTypeExpression = "*";
14151 }
14152
14153 var dataType,
14154 i = 0,
14155 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
14156
14157 if ( jQuery.isFunction( func ) ) {
14158 // For each dataType in the dataTypeExpression
14159 while ( (dataType = dataTypes[i++]) ) {
14160 // Prepend if requested
14161 if ( dataType[0] === "+" ) {
14162 dataType = dataType.slice( 1 ) || "*";
14163 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
14164
14165 // Otherwise append
14166 } else {
14167 (structure[ dataType ] = structure[ dataType ] || []).push( func );
14168 }
14169 }
14170 }
14171 };
14172 }
14173
14174 // Base inspection function for prefilters and transports
14175 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
14176
14177 var inspected = {},
14178 seekingTransport = ( structure === transports );
14179
14180 function inspect( dataType ) {
14181 var selected;
14182 inspected[ dataType ] = true;
14183 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
14184 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
14185 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
14186 options.dataTypes.unshift( dataTypeOrTransport );
14187 inspect( dataTypeOrTransport );
14188 return false;
14189 } else if ( seekingTransport ) {
14190 return !( selected = dataTypeOrTransport );
14191 }
14192 });
14193 return selected;
14194 }
14195
14196 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
14197 }
14198
14199 // A special extend for ajax options
14200 // that takes "flat" options (not to be deep extended)
14201 // Fixes #9887
14202 function ajaxExtend( target, src ) {
14203 var key, deep,
14204 flatOptions = jQuery.ajaxSettings.flatOptions || {};
14205
14206 for ( key in src ) {
14207 if ( src[ key ] !== undefined ) {
14208 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
14209 }
14210 }
14211 if ( deep ) {
14212 jQuery.extend( true, target, deep );
14213 }
14214
14215 return target;
14216 }
14217
14218 /* Handles responses to an ajax request:
14219 * - finds the right dataType (mediates between content-type and expected dataType)
14220 * - returns the corresponding response
14221 */
14222 function ajaxHandleResponses( s, jqXHR, responses ) {
14223
14224 var ct, type, finalDataType, firstDataType,
14225 contents = s.contents,
14226 dataTypes = s.dataTypes;
14227
14228 // Remove auto dataType and get content-type in the process
14229 while ( dataTypes[ 0 ] === "*" ) {
14230 dataTypes.shift();
14231 if ( ct === undefined ) {
14232 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
14233 }
14234 }
14235
14236 // Check if we're dealing with a known content-type
14237 if ( ct ) {
14238 for ( type in contents ) {
14239 if ( contents[ type ] && contents[ type ].test( ct ) ) {
14240 dataTypes.unshift( type );
14241 break;
14242 }
14243 }
14244 }
14245
14246 // Check to see if we have a response for the expected dataType
14247 if ( dataTypes[ 0 ] in responses ) {
14248 finalDataType = dataTypes[ 0 ];
14249 } else {
14250 // Try convertible dataTypes
14251 for ( type in responses ) {
14252 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
14253 finalDataType = type;
14254 break;
14255 }
14256 if ( !firstDataType ) {
14257 firstDataType = type;
14258 }
14259 }
14260 // Or just use first one
14261 finalDataType = finalDataType || firstDataType;
14262 }
14263
14264 // If we found a dataType
14265 // We add the dataType to the list if needed
14266 // and return the corresponding response
14267 if ( finalDataType ) {
14268 if ( finalDataType !== dataTypes[ 0 ] ) {
14269 dataTypes.unshift( finalDataType );
14270 }
14271 return responses[ finalDataType ];
14272 }
14273 }
14274
14275 /* Chain conversions given the request and the original response
14276 * Also sets the responseXXX fields on the jqXHR instance
14277 */
14278 function ajaxConvert( s, response, jqXHR, isSuccess ) {
14279 var conv2, current, conv, tmp, prev,
14280 converters = {},
14281 // Work with a copy of dataTypes in case we need to modify it for conversion
14282 dataTypes = s.dataTypes.slice();
14283
14284 // Create converters map with lowercased keys
14285 if ( dataTypes[ 1 ] ) {
14286 for ( conv in s.converters ) {
14287 converters[ conv.toLowerCase() ] = s.converters[ conv ];
14288 }
14289 }
14290
14291 current = dataTypes.shift();
14292
14293 // Convert to each sequential dataType
14294 while ( current ) {
14295
14296 if ( s.responseFields[ current ] ) {
14297 jqXHR[ s.responseFields[ current ] ] = response;
14298 }
14299
14300 // Apply the dataFilter if provided
14301 if ( !prev && isSuccess && s.dataFilter ) {
14302 response = s.dataFilter( response, s.dataType );
14303 }
14304
14305 prev = current;
14306 current = dataTypes.shift();
14307
14308 if ( current ) {
14309
14310 // There's only work to do if current dataType is non-auto
14311 if ( current === "*" ) {
14312
14313 current = prev;
14314
14315 // Convert response if prev dataType is non-auto and differs from current
14316 } else if ( prev !== "*" && prev !== current ) {
14317
14318 // Seek a direct converter
14319 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
14320
14321 // If none found, seek a pair
14322 if ( !conv ) {
14323 for ( conv2 in converters ) {
14324
14325 // If conv2 outputs current
14326 tmp = conv2.split( " " );
14327 if ( tmp[ 1 ] === current ) {
14328
14329 // If prev can be converted to accepted input
14330 conv = converters[ prev + " " + tmp[ 0 ] ] ||
14331 converters[ "* " + tmp[ 0 ] ];
14332 if ( conv ) {
14333 // Condense equivalence converters
14334 if ( conv === true ) {
14335 conv = converters[ conv2 ];
14336
14337 // Otherwise, insert the intermediate dataType
14338 } else if ( converters[ conv2 ] !== true ) {
14339 current = tmp[ 0 ];
14340 dataTypes.unshift( tmp[ 1 ] );
14341 }
14342 break;
14343 }
14344 }
14345 }
14346 }
14347
14348 // Apply converter (if not an equivalence)
14349 if ( conv !== true ) {
14350
14351 // Unless errors are allowed to bubble, catch and return them
14352 if ( conv && s[ "throws" ] ) {
14353 response = conv( response );
14354 } else {
14355 try {
14356 response = conv( response );
14357 } catch ( e ) {
14358 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
14359 }
14360 }
14361 }
14362 }
14363 }
14364 }
14365
14366 return { state: "success", data: response };
14367 }
14368
14369 jQuery.extend({
14370
14371 // Counter for holding the number of active queries
14372 active: 0,
14373
14374 // Last-Modified header cache for next request
14375 lastModified: {},
14376 etag: {},
14377
14378 ajaxSettings: {
14379 url: ajaxLocation,
14380 type: "GET",
14381 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
14382 global: true,
14383 processData: true,
14384 async: true,
14385 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
14386 /*
14387 timeout: 0,
14388 data: null,
14389 dataType: null,
14390 username: null,
14391 password: null,
14392 cache: null,
14393 throws: false,
14394 traditional: false,
14395 headers: {},
14396 */
14397
14398 accepts: {
14399 "*": allTypes,
14400 text: "text/plain",
14401 html: "text/html",
14402 xml: "application/xml, text/xml",
14403 json: "application/json, text/javascript"
14404 },
14405
14406 contents: {
14407 xml: /xml/,
14408 html: /html/,
14409 json: /json/
14410 },
14411
14412 responseFields: {
14413 xml: "responseXML",
14414 text: "responseText",
14415 json: "responseJSON"
14416 },
14417
14418 // Data converters
14419 // Keys separate source (or catchall "*") and destination types with a single space
14420 converters: {
14421
14422 // Convert anything to text
14423 "* text": String,
14424
14425 // Text to html (true = no transformation)
14426 "text html": true,
14427
14428 // Evaluate text as a json expression
14429 "text json": jQuery.parseJSON,
14430
14431 // Parse text as xml
14432 "text xml": jQuery.parseXML
14433 },
14434
14435 // For options that shouldn't be deep extended:
14436 // you can add your own custom options here if
14437 // and when you create one that shouldn't be
14438 // deep extended (see ajaxExtend)
14439 flatOptions: {
14440 url: true,
14441 context: true
14442 }
14443 },
14444
14445 // Creates a full fledged settings object into target
14446 // with both ajaxSettings and settings fields.
14447 // If target is omitted, writes into ajaxSettings.
14448 ajaxSetup: function( target, settings ) {
14449 return settings ?
14450
14451 // Building a settings object
14452 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
14453
14454 // Extending ajaxSettings
14455 ajaxExtend( jQuery.ajaxSettings, target );
14456 },
14457
14458 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
14459 ajaxTransport: addToPrefiltersOrTransports( transports ),
14460
14461 // Main method
14462 ajax: function( url, options ) {
14463
14464 // If url is an object, simulate pre-1.5 signature
14465 if ( typeof url === "object" ) {
14466 options = url;
14467 url = undefined;
14468 }
14469
14470 // Force options to be an object
14471 options = options || {};
14472
14473 var transport,
14474 // URL without anti-cache param
14475 cacheURL,
14476 // Response headers
14477 responseHeadersString,
14478 responseHeaders,
14479 // timeout handle
14480 timeoutTimer,
14481 // Cross-domain detection vars
14482 parts,
14483 // To know if global events are to be dispatched
14484 fireGlobals,
14485 // Loop variable
14486 i,
14487 // Create the final options object
14488 s = jQuery.ajaxSetup( {}, options ),
14489 // Callbacks context
14490 callbackContext = s.context || s,
14491 // Context for global events is callbackContext if it is a DOM node or jQuery collection
14492 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
14493 jQuery( callbackContext ) :
14494 jQuery.event,
14495 // Deferreds
14496 deferred = jQuery.Deferred(),
14497 completeDeferred = jQuery.Callbacks("once memory"),
14498 // Status-dependent callbacks
14499 statusCode = s.statusCode || {},
14500 // Headers (they are sent all at once)
14501 requestHeaders = {},
14502 requestHeadersNames = {},
14503 // The jqXHR state
14504 state = 0,
14505 // Default abort message
14506 strAbort = "canceled",
14507 // Fake xhr
14508 jqXHR = {
14509 readyState: 0,
14510
14511 // Builds headers hashtable if needed
14512 getResponseHeader: function( key ) {
14513 var match;
14514 if ( state === 2 ) {
14515 if ( !responseHeaders ) {
14516 responseHeaders = {};
14517 while ( (match = rheaders.exec( responseHeadersString )) ) {
14518 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
14519 }
14520 }
14521 match = responseHeaders[ key.toLowerCase() ];
14522 }
14523 return match == null ? null : match;
14524 },
14525
14526 // Raw string
14527 getAllResponseHeaders: function() {
14528 return state === 2 ? responseHeadersString : null;
14529 },
14530
14531 // Caches the header
14532 setRequestHeader: function( name, value ) {
14533 var lname = name.toLowerCase();
14534 if ( !state ) {
14535 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
14536 requestHeaders[ name ] = value;
14537 }
14538 return this;
14539 },
14540
14541 // Overrides response content-type header
14542 overrideMimeType: function( type ) {
14543 if ( !state ) {
14544 s.mimeType = type;
14545 }
14546 return this;
14547 },
14548
14549 // Status-dependent callbacks
14550 statusCode: function( map ) {
14551 var code;
14552 if ( map ) {
14553 if ( state < 2 ) {
14554 for ( code in map ) {
14555 // Lazy-add the new callback in a way that preserves old ones
14556 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
14557 }
14558 } else {
14559 // Execute the appropriate callbacks
14560 jqXHR.always( map[ jqXHR.status ] );
14561 }
14562 }
14563 return this;
14564 },
14565
14566 // Cancel the request
14567 abort: function( statusText ) {
14568 var finalText = statusText || strAbort;
14569 if ( transport ) {
14570 transport.abort( finalText );
14571 }
14572 done( 0, finalText );
14573 return this;
14574 }
14575 };
14576
14577 // Attach deferreds
14578 deferred.promise( jqXHR ).complete = completeDeferred.add;
14579 jqXHR.success = jqXHR.done;
14580 jqXHR.error = jqXHR.fail;
14581
14582 // Remove hash character (#7531: and string promotion)
14583 // Add protocol if not provided (prefilters might expect it)
14584 // Handle falsy url in the settings object (#10093: consistency with old signature)
14585 // We also use the url parameter if available
14586 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" )
14587 .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
14588
14589 // Alias method option to type as per ticket #12004
14590 s.type = options.method || options.type || s.method || s.type;
14591
14592 // Extract dataTypes list
14593 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
14594
14595 // A cross-domain request is in order when we have a protocol:host:port mismatch
14596 if ( s.crossDomain == null ) {
14597 parts = rurl.exec( s.url.toLowerCase() );
14598 s.crossDomain = !!( parts &&
14599 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
14600 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
14601 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
14602 );
14603 }
14604
14605 // Convert data if not already a string
14606 if ( s.data && s.processData && typeof s.data !== "string" ) {
14607 s.data = jQuery.param( s.data, s.traditional );
14608 }
14609
14610 // Apply prefilters
14611 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
14612
14613 // If request was aborted inside a prefilter, stop there
14614 if ( state === 2 ) {
14615 return jqXHR;
14616 }
14617
14618 // We can fire global events as of now if asked to
14619 fireGlobals = s.global;
14620
14621 // Watch for a new set of requests
14622 if ( fireGlobals && jQuery.active++ === 0 ) {
14623 jQuery.event.trigger("ajaxStart");
14624 }
14625
14626 // Uppercase the type
14627 s.type = s.type.toUpperCase();
14628
14629 // Determine if request has content
14630 s.hasContent = !rnoContent.test( s.type );
14631
14632 // Save the URL in case we're toying with the If-Modified-Since
14633 // and/or If-None-Match header later on
14634 cacheURL = s.url;
14635
14636 // More options handling for requests with no content
14637 if ( !s.hasContent ) {
14638
14639 // If data is available, append data to url
14640 if ( s.data ) {
14641 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
14642 // #9682: remove data so that it's not used in an eventual retry
14643 delete s.data;
14644 }
14645
14646 // Add anti-cache in url if needed
14647 if ( s.cache === false ) {
14648 s.url = rts.test( cacheURL ) ?
14649
14650 // If there is already a '_' parameter, set its value
14651 cacheURL.replace( rts, "$1_=" + nonce++ ) :
14652
14653 // Otherwise add one to the end
14654 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
14655 }
14656 }
14657
14658 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
14659 if ( s.ifModified ) {
14660 if ( jQuery.lastModified[ cacheURL ] ) {
14661 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
14662 }
14663 if ( jQuery.etag[ cacheURL ] ) {
14664 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
14665 }
14666 }
14667
14668 // Set the correct header, if data is being sent
14669 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
14670 jqXHR.setRequestHeader( "Content-Type", s.contentType );
14671 }
14672
14673 // Set the Accepts header for the server, depending on the dataType
14674 jqXHR.setRequestHeader(
14675 "Accept",
14676 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
14677 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
14678 s.accepts[ "*" ]
14679 );
14680
14681 // Check for headers option
14682 for ( i in s.headers ) {
14683 jqXHR.setRequestHeader( i, s.headers[ i ] );
14684 }
14685
14686 // Allow custom headers/mimetypes and early abort
14687 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
14688 // Abort if not done already and return
14689 return jqXHR.abort();
14690 }
14691
14692 // aborting is no longer a cancellation
14693 strAbort = "abort";
14694
14695 // Install callbacks on deferreds
14696 for ( i in { success: 1, error: 1, complete: 1 } ) {
14697 jqXHR[ i ]( s[ i ] );
14698 }
14699
14700 // Get transport
14701 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
14702
14703 // If no transport, we auto-abort
14704 if ( !transport ) {
14705 done( -1, "No Transport" );
14706 } else {
14707 jqXHR.readyState = 1;
14708
14709 // Send global event
14710 if ( fireGlobals ) {
14711 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
14712 }
14713 // Timeout
14714 if ( s.async && s.timeout > 0 ) {
14715 timeoutTimer = setTimeout(function() {
14716 jqXHR.abort("timeout");
14717 }, s.timeout );
14718 }
14719
14720 try {
14721 state = 1;
14722 transport.send( requestHeaders, done );
14723 } catch ( e ) {
14724 // Propagate exception as error if not done
14725 if ( state < 2 ) {
14726 done( -1, e );
14727 // Simply rethrow otherwise
14728 } else {
14729 throw e;
14730 }
14731 }
14732 }
14733
14734 // Callback for when everything is done
14735 function done( status, nativeStatusText, responses, headers ) {
14736 var isSuccess, success, error, response, modified,
14737 statusText = nativeStatusText;
14738
14739 // Called once
14740 if ( state === 2 ) {
14741 return;
14742 }
14743
14744 // State is "done" now
14745 state = 2;
14746
14747 // Clear timeout if it exists
14748 if ( timeoutTimer ) {
14749 clearTimeout( timeoutTimer );
14750 }
14751
14752 // Dereference transport for early garbage collection
14753 // (no matter how long the jqXHR object will be used)
14754 transport = undefined;
14755
14756 // Cache response headers
14757 responseHeadersString = headers || "";
14758
14759 // Set readyState
14760 jqXHR.readyState = status > 0 ? 4 : 0;
14761
14762 // Determine if successful
14763 isSuccess = status >= 200 && status < 300 || status === 304;
14764
14765 // Get response data
14766 if ( responses ) {
14767 response = ajaxHandleResponses( s, jqXHR, responses );
14768 }
14769
14770 // Convert no matter what (that way responseXXX fields are always set)
14771 response = ajaxConvert( s, response, jqXHR, isSuccess );
14772
14773 // If successful, handle type chaining
14774 if ( isSuccess ) {
14775
14776 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
14777 if ( s.ifModified ) {
14778 modified = jqXHR.getResponseHeader("Last-Modified");
14779 if ( modified ) {
14780 jQuery.lastModified[ cacheURL ] = modified;
14781 }
14782 modified = jqXHR.getResponseHeader("etag");
14783 if ( modified ) {
14784 jQuery.etag[ cacheURL ] = modified;
14785 }
14786 }
14787
14788 // if no content
14789 if ( status === 204 || s.type === "HEAD" ) {
14790 statusText = "nocontent";
14791
14792 // if not modified
14793 } else if ( status === 304 ) {
14794 statusText = "notmodified";
14795
14796 // If we have data, let's convert it
14797 } else {
14798 statusText = response.state;
14799 success = response.data;
14800 error = response.error;
14801 isSuccess = !error;
14802 }
14803 } else {
14804 // We extract error from statusText
14805 // then normalize statusText and status for non-aborts
14806 error = statusText;
14807 if ( status || !statusText ) {
14808 statusText = "error";
14809 if ( status < 0 ) {
14810 status = 0;
14811 }
14812 }
14813 }
14814
14815 // Set data for the fake xhr object
14816 jqXHR.status = status;
14817 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
14818
14819 // Success/Error
14820 if ( isSuccess ) {
14821 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
14822 } else {
14823 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
14824 }
14825
14826 // Status-dependent callbacks
14827 jqXHR.statusCode( statusCode );
14828 statusCode = undefined;
14829
14830 if ( fireGlobals ) {
14831 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
14832 [ jqXHR, s, isSuccess ? success : error ] );
14833 }
14834
14835 // Complete
14836 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
14837
14838 if ( fireGlobals ) {
14839 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
14840 // Handle the global AJAX counter
14841 if ( !( --jQuery.active ) ) {
14842 jQuery.event.trigger("ajaxStop");
14843 }
14844 }
14845 }
14846
14847 return jqXHR;
14848 },
14849
14850 getJSON: function( url, data, callback ) {
14851 return jQuery.get( url, data, callback, "json" );
14852 },
14853
14854 getScript: function( url, callback ) {
14855 return jQuery.get( url, undefined, callback, "script" );
14856 }
14857 });
14858
14859 jQuery.each( [ "get", "post" ], function( i, method ) {
14860 jQuery[ method ] = function( url, data, callback, type ) {
14861 // shift arguments if data argument was omitted
14862 if ( jQuery.isFunction( data ) ) {
14863 type = type || callback;
14864 callback = data;
14865 data = undefined;
14866 }
14867
14868 return jQuery.ajax({
14869 url: url,
14870 type: method,
14871 dataType: type,
14872 data: data,
14873 success: callback
14874 });
14875 };
14876 });
14877
14878 // Attach a bunch of functions for handling common AJAX events
14879 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
14880 jQuery.fn[ type ] = function( fn ) {
14881 return this.on( type, fn );
14882 };
14883 });
14884
14885
14886 jQuery._evalUrl = function( url ) {
14887 return jQuery.ajax({
14888 url: url,
14889 type: "GET",
14890 dataType: "script",
14891 async: false,
14892 global: false,
14893 "throws": true
14894 });
14895 };
14896
14897
14898 jQuery.fn.extend({
14899 wrapAll: function( html ) {
14900 var wrap;
14901
14902 if ( jQuery.isFunction( html ) ) {
14903 return this.each(function( i ) {
14904 jQuery( this ).wrapAll( html.call(this, i) );
14905 });
14906 }
14907
14908 if ( this[ 0 ] ) {
14909
14910 // The elements to wrap the target around
14911 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
14912
14913 if ( this[ 0 ].parentNode ) {
14914 wrap.insertBefore( this[ 0 ] );
14915 }
14916
14917 wrap.map(function() {
14918 var elem = this;
14919
14920 while ( elem.firstElementChild ) {
14921 elem = elem.firstElementChild;
14922 }
14923
14924 return elem;
14925 }).append( this );
14926 }
14927
14928 return this;
14929 },
14930
14931 wrapInner: function( html ) {
14932 if ( jQuery.isFunction( html ) ) {
14933 return this.each(function( i ) {
14934 jQuery( this ).wrapInner( html.call(this, i) );
14935 });
14936 }
14937
14938 return this.each(function() {
14939 var self = jQuery( this ),
14940 contents = self.contents();
14941
14942 if ( contents.length ) {
14943 contents.wrapAll( html );
14944
14945 } else {
14946 self.append( html );
14947 }
14948 });
14949 },
14950
14951 wrap: function( html ) {
14952 var isFunction = jQuery.isFunction( html );
14953
14954 return this.each(function( i ) {
14955 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
14956 });
14957 },
14958
14959 unwrap: function() {
14960 return this.parent().each(function() {
14961 if ( !jQuery.nodeName( this, "body" ) ) {
14962 jQuery( this ).replaceWith( this.childNodes );
14963 }
14964 }).end();
14965 }
14966 });
14967
14968
14969 jQuery.expr.filters.hidden = function( elem ) {
14970 // Support: Opera <= 12.12
14971 // Opera reports offsetWidths and offsetHeights less than zero on some elements
14972 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;
14973 };
14974 jQuery.expr.filters.visible = function( elem ) {
14975 return !jQuery.expr.filters.hidden( elem );
14976 };
14977
14978
14979
14980
14981 var r20 = /%20/g,
14982 rbracket = /\[\]$/,
14983 rCRLF = /\r?\n/g,
14984 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
14985 rsubmittable = /^(?:input|select|textarea|keygen)/i;
14986
14987 function buildParams( prefix, obj, traditional, add ) {
14988 var name;
14989
14990 if ( jQuery.isArray( obj ) ) {
14991 // Serialize array item.
14992 jQuery.each( obj, function( i, v ) {
14993 if ( traditional || rbracket.test( prefix ) ) {
14994 // Treat each array item as a scalar.
14995 add( prefix, v );
14996
14997 } else {
14998 // Item is non-scalar (array or object), encode its numeric index.
14999 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
15000 }
15001 });
15002
15003 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
15004 // Serialize object item.
15005 for ( name in obj ) {
15006 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
15007 }
15008
15009 } else {
15010 // Serialize scalar item.
15011 add( prefix, obj );
15012 }
15013 }
15014
15015 // Serialize an array of form elements or a set of
15016 // key/values into a query string
15017 jQuery.param = function( a, traditional ) {
15018 var prefix,
15019 s = [],
15020 add = function( key, value ) {
15021 // If value is a function, invoke it and return its value
15022 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
15023 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
15024 };
15025
15026 // Set traditional to true for jQuery <= 1.3.2 behavior.
15027 if ( traditional === undefined ) {
15028 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
15029 }
15030
15031 // If an array was passed in, assume that it is an array of form elements.
15032 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
15033 // Serialize the form elements
15034 jQuery.each( a, function() {
15035 add( this.name, this.value );
15036 });
15037
15038 } else {
15039 // If traditional, encode the "old" way (the way 1.3.2 or older
15040 // did it), otherwise encode params recursively.
15041 for ( prefix in a ) {
15042 buildParams( prefix, a[ prefix ], traditional, add );
15043 }
15044 }
15045
15046 // Return the resulting serialization
15047 return s.join( "&" ).replace( r20, "+" );
15048 };
15049
15050 jQuery.fn.extend({
15051 serialize: function() {
15052 return jQuery.param( this.serializeArray() );
15053 },
15054 serializeArray: function() {
15055 return this.map(function() {
15056 // Can add propHook for "elements" to filter or add form elements
15057 var elements = jQuery.prop( this, "elements" );
15058 return elements ? jQuery.makeArray( elements ) : this;
15059 })
15060 .filter(function() {
15061 var type = this.type;
15062
15063 // Use .is( ":disabled" ) so that fieldset[disabled] works
15064 return this.name && !jQuery( this ).is( ":disabled" ) &&
15065 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
15066 ( this.checked || !rcheckableType.test( type ) );
15067 })
15068 .map(function( i, elem ) {
15069 var val = jQuery( this ).val();
15070
15071 return val == null ?
15072 null :
15073 jQuery.isArray( val ) ?
15074 jQuery.map( val, function( val ) {
15075 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
15076 }) :
15077 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
15078 }).get();
15079 }
15080 });
15081
15082
15083 jQuery.ajaxSettings.xhr = function() {
15084 try {
15085 return new XMLHttpRequest();
15086 } catch( e ) {}
15087 };
15088
15089 var xhrId = 0,
15090 xhrCallbacks = {},
15091 xhrSuccessStatus = {
15092 // file protocol always yields status code 0, assume 200
15093 0: 200,
15094 // Support: IE9
15095 // #1450: sometimes IE returns 1223 when it should be 204
15096 1223: 204
15097 },
15098 xhrSupported = jQuery.ajaxSettings.xhr();
15099
15100 // Support: IE9
15101 // Open requests must be manually aborted on unload (#5280)
15102 if ( window.ActiveXObject ) {
15103 jQuery( window ).on( "unload", function() {
15104 for ( var key in xhrCallbacks ) {
15105 xhrCallbacks[ key ]();
15106 }
15107 });
15108 }
15109
15110 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
15111 support.ajax = xhrSupported = !!xhrSupported;
15112
15113 jQuery.ajaxTransport(function( options ) {
15114 var callback;
15115
15116 // Cross domain only allowed if supported through XMLHttpRequest
15117 if ( support.cors || xhrSupported && !options.crossDomain ) {
15118 return {
15119 send: function( headers, complete ) {
15120 var i,
15121 xhr = options.xhr(),
15122 id = ++xhrId;
15123
15124 xhr.open( options.type, options.url, options.async, options.username, options.password );
15125
15126 // Apply custom fields if provided
15127 if ( options.xhrFields ) {
15128 for ( i in options.xhrFields ) {
15129 xhr[ i ] = options.xhrFields[ i ];
15130 }
15131 }
15132
15133 // Override mime type if needed
15134 if ( options.mimeType && xhr.overrideMimeType ) {
15135 xhr.overrideMimeType( options.mimeType );
15136 }
15137
15138 // X-Requested-With header
15139 // For cross-domain requests, seeing as conditions for a preflight are
15140 // akin to a jigsaw puzzle, we simply never set it to be sure.
15141 // (it can always be set on a per-request basis or even using ajaxSetup)
15142 // For same-domain requests, won't change header if already provided.
15143 if ( !options.crossDomain && !headers["X-Requested-With"] ) {
15144 headers["X-Requested-With"] = "XMLHttpRequest";
15145 }
15146
15147 // Set headers
15148 for ( i in headers ) {
15149 xhr.setRequestHeader( i, headers[ i ] );
15150 }
15151
15152 // Callback
15153 callback = function( type ) {
15154 return function() {
15155 if ( callback ) {
15156 delete xhrCallbacks[ id ];
15157 callback = xhr.onload = xhr.onerror = null;
15158
15159 if ( type === "abort" ) {
15160 xhr.abort();
15161 } else if ( type === "error" ) {
15162 complete(
15163 // file: protocol always yields status 0; see #8605, #14207
15164 xhr.status,
15165 xhr.statusText
15166 );
15167 } else {
15168 complete(
15169 xhrSuccessStatus[ xhr.status ] || xhr.status,
15170 xhr.statusText,
15171 // Support: IE9
15172 // Accessing binary-data responseText throws an exception
15173 // (#11426)
15174 typeof xhr.responseText === "string" ? {
15175 text: xhr.responseText
15176 } : undefined,
15177 xhr.getAllResponseHeaders()
15178 );
15179 }
15180 }
15181 };
15182 };
15183
15184 // Listen to events
15185 xhr.onload = callback();
15186 xhr.onerror = callback("error");
15187
15188 // Create the abort callback
15189 callback = xhrCallbacks[ id ] = callback("abort");
15190
15191 try {
15192 // Do send the request (this may raise an exception)
15193 xhr.send( options.hasContent && options.data || null );
15194 } catch ( e ) {
15195 // #14683: Only rethrow if this hasn't been notified as an error yet
15196 if ( callback ) {
15197 throw e;
15198 }
15199 }
15200 },
15201
15202 abort: function() {
15203 if ( callback ) {
15204 callback();
15205 }
15206 }
15207 };
15208 }
15209 });
15210
15211
15212
15213
15214 // Install script dataType
15215 jQuery.ajaxSetup({
15216 accepts: {
15217 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
15218 },
15219 contents: {
15220 script: /(?:java|ecma)script/
15221 },
15222 converters: {
15223 "text script": function( text ) {
15224 jQuery.globalEval( text );
15225 return text;
15226 }
15227 }
15228 });
15229
15230 // Handle cache's special case and crossDomain
15231 jQuery.ajaxPrefilter( "script", function( s ) {
15232 if ( s.cache === undefined ) {
15233 s.cache = false;
15234 }
15235 if ( s.crossDomain ) {
15236 s.type = "GET";
15237 }
15238 });
15239
15240 // Bind script tag hack transport
15241 jQuery.ajaxTransport( "script", function( s ) {
15242 // This transport only deals with cross domain requests
15243 if ( s.crossDomain ) {
15244 var script, callback;
15245 return {
15246 send: function( _, complete ) {
15247 script = jQuery("<script>").prop({
15248 async: true,
15249 charset: s.scriptCharset,
15250 src: s.url
15251 }).on(
15252 "load error",
15253 callback = function( evt ) {
15254 script.remove();
15255 callback = null;
15256 if ( evt ) {
15257 complete( evt.type === "error" ? 404 : 200, evt.type );
15258 }
15259 }
15260 );
15261 document.head.appendChild( script[ 0 ] );
15262 },
15263 abort: function() {
15264 if ( callback ) {
15265 callback();
15266 }
15267 }
15268 };
15269 }
15270 });
15271
15272
15273
15274
15275 var oldCallbacks = [],
15276 rjsonp = /(=)\?(?=&|$)|\?\?/;
15277
15278 // Default jsonp settings
15279 jQuery.ajaxSetup({
15280 jsonp: "callback",
15281 jsonpCallback: function() {
15282 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
15283 this[ callback ] = true;
15284 return callback;
15285 }
15286 });
15287
15288 // Detect, normalize options and install callbacks for jsonp requests
15289 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
15290
15291 var callbackName, overwritten, responseContainer,
15292 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
15293 "url" :
15294 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
15295 );
15296
15297 // Handle iff the expected data type is "jsonp" or we have a parameter to set
15298 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
15299
15300 // Get callback name, remembering preexisting value associated with it
15301 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
15302 s.jsonpCallback() :
15303 s.jsonpCallback;
15304
15305 // Insert callback into url or form data
15306 if ( jsonProp ) {
15307 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
15308 } else if ( s.jsonp !== false ) {
15309 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
15310 }
15311
15312 // Use data converter to retrieve json after script execution
15313 s.converters["script json"] = function() {
15314 if ( !responseContainer ) {
15315 jQuery.error( callbackName + " was not called" );
15316 }
15317 return responseContainer[ 0 ];
15318 };
15319
15320 // force json dataType
15321 s.dataTypes[ 0 ] = "json";
15322
15323 // Install callback
15324 overwritten = window[ callbackName ];
15325 window[ callbackName ] = function() {
15326 responseContainer = arguments;
15327 };
15328
15329 // Clean-up function (fires after converters)
15330 jqXHR.always(function() {
15331 // Restore preexisting value
15332 window[ callbackName ] = overwritten;
15333
15334 // Save back as free
15335 if ( s[ callbackName ] ) {
15336 // make sure that re-using the options doesn't screw things around
15337 s.jsonpCallback = originalSettings.jsonpCallback;
15338
15339 // save the callback name for future use
15340 oldCallbacks.push( callbackName );
15341 }
15342
15343 // Call if it was a function and we have a response
15344 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
15345 overwritten( responseContainer[ 0 ] );
15346 }
15347
15348 responseContainer = overwritten = undefined;
15349 });
15350
15351 // Delegate to script
15352 return "script";
15353 }
15354 });
15355
15356
15357
15358
15359 // data: string of html
15360 // context (optional): If specified, the fragment will be created in this context, defaults to document
15361 // keepScripts (optional): If true, will include scripts passed in the html string
15362 jQuery.parseHTML = function( data, context, keepScripts ) {
15363 if ( !data || typeof data !== "string" ) {
15364 return null;
15365 }
15366 if ( typeof context === "boolean" ) {
15367 keepScripts = context;
15368 context = false;
15369 }
15370 context = context || document;
15371
15372 var parsed = rsingleTag.exec( data ),
15373 scripts = !keepScripts && [];
15374
15375 // Single tag
15376 if ( parsed ) {
15377 return [ context.createElement( parsed[1] ) ];
15378 }
15379
15380 parsed = jQuery.buildFragment( [ data ], context, scripts );
15381
15382 if ( scripts && scripts.length ) {
15383 jQuery( scripts ).remove();
15384 }
15385
15386 return jQuery.merge( [], parsed.childNodes );
15387 };
15388
15389
15390 // Keep a copy of the old load method
15391 var _load = jQuery.fn.load;
15392
15393 /**
15394 * Load a url into a page
15395 */
15396 jQuery.fn.load = function( url, params, callback ) {
15397 if ( typeof url !== "string" && _load ) {
15398 return _load.apply( this, arguments );
15399 }
15400
15401 var selector, type, response,
15402 self = this,
15403 off = url.indexOf(" ");
15404
15405 if ( off >= 0 ) {
15406 selector = jQuery.trim( url.slice( off ) );
15407 url = url.slice( 0, off );
15408 }
15409
15410 // If it's a function
15411 if ( jQuery.isFunction( params ) ) {
15412
15413 // We assume that it's the callback
15414 callback = params;
15415 params = undefined;
15416
15417 // Otherwise, build a param string
15418 } else if ( params && typeof params === "object" ) {
15419 type = "POST";
15420 }
15421
15422 // If we have elements to modify, make the request
15423 if ( self.length > 0 ) {
15424 jQuery.ajax({
15425 url: url,
15426
15427 // if "type" variable is undefined, then "GET" method will be used
15428 type: type,
15429 dataType: "html",
15430 data: params
15431 }).done(function( responseText ) {
15432
15433 // Save response for use in complete callback
15434 response = arguments;
15435
15436 self.html( selector ?
15437
15438 // If a selector was specified, locate the right elements in a dummy div
15439 // Exclude scripts to avoid IE 'Permission Denied' errors
15440 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
15441
15442 // Otherwise use the full result
15443 responseText );
15444
15445 }).complete( callback && function( jqXHR, status ) {
15446 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
15447 });
15448 }
15449
15450 return this;
15451 };
15452
15453
15454
15455
15456 jQuery.expr.filters.animated = function( elem ) {
15457 return jQuery.grep(jQuery.timers, function( fn ) {
15458 return elem === fn.elem;
15459 }).length;
15460 };
15461
15462
15463
15464
15465 var docElem = window.document.documentElement;
15466
15467 /**
15468 * Gets a window from an element
15469 */
15470 function getWindow( elem ) {
15471 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
15472 }
15473
15474 jQuery.offset = {
15475 setOffset: function( elem, options, i ) {
15476 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
15477 position = jQuery.css( elem, "position" ),
15478 curElem = jQuery( elem ),
15479 props = {};
15480
15481 // Set position first, in-case top/left are set even on static elem
15482 if ( position === "static" ) {
15483 elem.style.position = "relative";
15484 }
15485
15486 curOffset = curElem.offset();
15487 curCSSTop = jQuery.css( elem, "top" );
15488 curCSSLeft = jQuery.css( elem, "left" );
15489 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
15490 ( curCSSTop + curCSSLeft ).indexOf("auto") > -1;
15491
15492 // Need to be able to calculate position if either top or left is auto and position is either absolute or fixed
15493 if ( calculatePosition ) {
15494 curPosition = curElem.position();
15495 curTop = curPosition.top;
15496 curLeft = curPosition.left;
15497
15498 } else {
15499 curTop = parseFloat( curCSSTop ) || 0;
15500 curLeft = parseFloat( curCSSLeft ) || 0;
15501 }
15502
15503 if ( jQuery.isFunction( options ) ) {
15504 options = options.call( elem, i, curOffset );
15505 }
15506
15507 if ( options.top != null ) {
15508 props.top = ( options.top - curOffset.top ) + curTop;
15509 }
15510 if ( options.left != null ) {
15511 props.left = ( options.left - curOffset.left ) + curLeft;
15512 }
15513
15514 if ( "using" in options ) {
15515 options.using.call( elem, props );
15516
15517 } else {
15518 curElem.css( props );
15519 }
15520 }
15521 };
15522
15523 jQuery.fn.extend({
15524 offset: function( options ) {
15525 if ( arguments.length ) {
15526 return options === undefined ?
15527 this :
15528 this.each(function( i ) {
15529 jQuery.offset.setOffset( this, options, i );
15530 });
15531 }
15532
15533 var docElem, win,
15534 elem = this[ 0 ],
15535 box = { top: 0, left: 0 },
15536 doc = elem && elem.ownerDocument;
15537
15538 if ( !doc ) {
15539 return;
15540 }
15541
15542 docElem = doc.documentElement;
15543
15544 // Make sure it's not a disconnected DOM node
15545 if ( !jQuery.contains( docElem, elem ) ) {
15546 return box;
15547 }
15548
15549 // If we don't have gBCR, just use 0,0 rather than error
15550 // BlackBerry 5, iOS 3 (original iPhone)
15551 if ( typeof elem.getBoundingClientRect !== strundefined ) {
15552 box = elem.getBoundingClientRect();
15553 }
15554 win = getWindow( doc );
15555 return {
15556 top: box.top + win.pageYOffset - docElem.clientTop,
15557 left: box.left + win.pageXOffset - docElem.clientLeft
15558 };
15559 },
15560
15561 position: function() {
15562 if ( !this[ 0 ] ) {
15563 return;
15564 }
15565
15566 var offsetParent, offset,
15567 elem = this[ 0 ],
15568 parentOffset = { top: 0, left: 0 };
15569
15570 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
15571 if ( jQuery.css( elem, "position" ) === "fixed" ) {
15572 // We assume that getBoundingClientRect is available when computed position is fixed
15573 offset = elem.getBoundingClientRect();
15574
15575 } else {
15576 // Get *real* offsetParent
15577 offsetParent = this.offsetParent();
15578
15579 // Get correct offsets
15580 offset = this.offset();
15581 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
15582 parentOffset = offsetParent.offset();
15583 }
15584
15585 // Add offsetParent borders
15586 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
15587 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
15588 }
15589
15590 // Subtract parent offsets and element margins
15591 return {
15592 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
15593 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
15594 };
15595 },
15596
15597 offsetParent: function() {
15598 return this.map(function() {
15599 var offsetParent = this.offsetParent || docElem;
15600
15601 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
15602 offsetParent = offsetParent.offsetParent;
15603 }
15604
15605 return offsetParent || docElem;
15606 });
15607 }
15608 });
15609
15610 // Create scrollLeft and scrollTop methods
15611 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
15612 var top = "pageYOffset" === prop;
15613
15614 jQuery.fn[ method ] = function( val ) {
15615 return access( this, function( elem, method, val ) {
15616 var win = getWindow( elem );
15617
15618 if ( val === undefined ) {
15619 return win ? win[ prop ] : elem[ method ];
15620 }
15621
15622 if ( win ) {
15623 win.scrollTo(
15624 !top ? val : window.pageXOffset,
15625 top ? val : window.pageYOffset
15626 );
15627
15628 } else {
15629 elem[ method ] = val;
15630 }
15631 }, method, val, arguments.length, null );
15632 };
15633 });
15634
15635 // Add the top/left cssHooks using jQuery.fn.position
15636 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
15637 // getComputedStyle returns percent when specified for top/left/bottom/right
15638 // rather than make the css module depend on the offset module, we just check for it here
15639 jQuery.each( [ "top", "left" ], function( i, prop ) {
15640 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
15641 function( elem, computed ) {
15642 if ( computed ) {
15643 computed = curCSS( elem, prop );
15644 // if curCSS returns percentage, fallback to offset
15645 return rnumnonpx.test( computed ) ?
15646 jQuery( elem ).position()[ prop ] + "px" :
15647 computed;
15648 }
15649 }
15650 );
15651 });
15652
15653
15654 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
15655 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
15656 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
15657 // margin is only for outerHeight, outerWidth
15658 jQuery.fn[ funcName ] = function( margin, value ) {
15659 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
15660 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
15661
15662 return access( this, function( elem, type, value ) {
15663 var doc;
15664
15665 if ( jQuery.isWindow( elem ) ) {
15666 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
15667 // isn't a whole lot we can do. See pull request at this URL for discussion:
15668 // https://github.com/jquery/jquery/pull/764
15669 return elem.document.documentElement[ "client" + name ];
15670 }
15671
15672 // Get document width or height
15673 if ( elem.nodeType === 9 ) {
15674 doc = elem.documentElement;
15675
15676 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
15677 // whichever is greatest
15678 return Math.max(
15679 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
15680 elem.body[ "offset" + name ], doc[ "offset" + name ],
15681 doc[ "client" + name ]
15682 );
15683 }
15684
15685 return value === undefined ?
15686 // Get width or height on the element, requesting but not forcing parseFloat
15687 jQuery.css( elem, type, extra ) :
15688
15689 // Set width or height on the element
15690 jQuery.style( elem, type, value, extra );
15691 }, type, chainable ? margin : undefined, chainable, null );
15692 };
15693 });
15694 });
15695
15696
15697 // The number of elements contained in the matched element set
15698 jQuery.fn.size = function() {
15699 return this.length;
15700 };
15701
15702 jQuery.fn.andSelf = jQuery.fn.addBack;
15703
15704
15705
15706
15707 // Register as a named AMD module, since jQuery can be concatenated with other
15708 // files that may use define, but not via a proper concatenation script that
15709 // understands anonymous AMD modules. A named AMD is safest and most robust
15710 // way to register. Lowercase jquery is used because AMD module names are
15711 // derived from file names, and jQuery is normally delivered in a lowercase
15712 // file name. Do this after creating the global so that if an AMD module wants
15713 // to call noConflict to hide this version of jQuery, it will work.
15714
15715 // Note that for maximum portability, libraries that are not jQuery should
15716 // declare themselves as anonymous modules, and avoid setting a global if an
15717 // AMD loader is present. jQuery is a special case. For more information, see
15718 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
15719
15720 if ( typeof define === "function" && define.amd ) {
15721 define( "jquery", [], function() {
15722 return jQuery;
15723 });
15724 }
15725
15726
15727
15728
15729 var
15730 // Map over jQuery in case of overwrite
15731 _jQuery = window.jQuery,
15732
15733 // Map over the $ in case of overwrite
15734 _$ = window.$;
15735
15736 jQuery.noConflict = function( deep ) {
15737 if ( window.$ === jQuery ) {
15738 window.$ = _$;
15739 }
15740
15741 if ( deep && window.jQuery === jQuery ) {
15742 window.jQuery = _jQuery;
15743 }
15744
15745 return jQuery;
15746 };
15747
15748 // Expose jQuery and $ identifiers, even in
15749 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
15750 // and CommonJS for browser emulators (#13566)
15751 if ( typeof noGlobal === strundefined ) {
15752 window.jQuery = window.$ = jQuery;
15753 }
15754
15755
15756
15757
15758 return jQuery;
15759
15760 }));
15761 </script>
15762 <script>
15763 /*!
15764 * Bootstrap v3.2.0 (http://getbootstrap.com)
15765 * Copyright 2011-2014 Twitter, Inc.
15766 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15767 */
15768
15769 if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript requires jQuery') }
15770
15771 /* ========================================================================
15772 * Bootstrap: transition.js v3.2.0
15773 * http://getbootstrap.com/javascript/#transitions
15774 * ========================================================================
15775 * Copyright 2011-2014 Twitter, Inc.
15776 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15777 * ======================================================================== */
15778
15779
15780 +function ($) {
15781 'use strict';
15782
15783 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
15784 // ============================================================
15785
15786 function transitionEnd() {
15787 var el = document.createElement('bootstrap')
15788
15789 var transEndEventNames = {
15790 WebkitTransition : 'webkitTransitionEnd',
15791 MozTransition : 'transitionend',
15792 OTransition : 'oTransitionEnd otransitionend',
15793 transition : 'transitionend'
15794 }
15795
15796 for (var name in transEndEventNames) {
15797 if (el.style[name] !== undefined) {
15798 return { end: transEndEventNames[name] }
15799 }
15800 }
15801
15802 return false // explicit for ie8 ( ._.)
15803 }
15804
15805 // http://blog.alexmaccaw.com/css-transitions
15806 $.fn.emulateTransitionEnd = function (duration) {
15807 var called = false
15808 var $el = this
15809 $(this).one('bsTransitionEnd', function () { called = true })
15810 var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
15811 setTimeout(callback, duration)
15812 return this
15813 }
15814
15815 $(function () {
15816 $.support.transition = transitionEnd()
15817
15818 if (!$.support.transition) return
15819
15820 $.event.special.bsTransitionEnd = {
15821 bindType: $.support.transition.end,
15822 delegateType: $.support.transition.end,
15823 handle: function (e) {
15824 if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
15825 }
15826 }
15827 })
15828
15829 }(jQuery);
15830
15831 /* ========================================================================
15832 * Bootstrap: alert.js v3.2.0
15833 * http://getbootstrap.com/javascript/#alerts
15834 * ========================================================================
15835 * Copyright 2011-2014 Twitter, Inc.
15836 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15837 * ======================================================================== */
15838
15839
15840 +function ($) {
15841 'use strict';
15842
15843 // ALERT CLASS DEFINITION
15844 // ======================
15845
15846 var dismiss = '[data-dismiss="alert"]'
15847 var Alert = function (el) {
15848 $(el).on('click', dismiss, this.close)
15849 }
15850
15851 Alert.VERSION = '3.2.0'
15852
15853 Alert.prototype.close = function (e) {
15854 var $this = $(this)
15855 var selector = $this.attr('data-target')
15856
15857 if (!selector) {
15858 selector = $this.attr('href')
15859 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
15860 }
15861
15862 var $parent = $(selector)
15863
15864 if (e) e.preventDefault()
15865
15866 if (!$parent.length) {
15867 $parent = $this.hasClass('alert') ? $this : $this.parent()
15868 }
15869
15870 $parent.trigger(e = $.Event('close.bs.alert'))
15871
15872 if (e.isDefaultPrevented()) return
15873
15874 $parent.removeClass('in')
15875
15876 function removeElement() {
15877 // detach from parent, fire event then clean up data
15878 $parent.detach().trigger('closed.bs.alert').remove()
15879 }
15880
15881 $.support.transition && $parent.hasClass('fade') ?
15882 $parent
15883 .one('bsTransitionEnd', removeElement)
15884 .emulateTransitionEnd(150) :
15885 removeElement()
15886 }
15887
15888
15889 // ALERT PLUGIN DEFINITION
15890 // =======================
15891
15892 function Plugin(option) {
15893 return this.each(function () {
15894 var $this = $(this)
15895 var data = $this.data('bs.alert')
15896
15897 if (!data) $this.data('bs.alert', (data = new Alert(this)))
15898 if (typeof option == 'string') data[option].call($this)
15899 })
15900 }
15901
15902 var old = $.fn.alert
15903
15904 $.fn.alert = Plugin
15905 $.fn.alert.Constructor = Alert
15906
15907
15908 // ALERT NO CONFLICT
15909 // =================
15910
15911 $.fn.alert.noConflict = function () {
15912 $.fn.alert = old
15913 return this
15914 }
15915
15916
15917 // ALERT DATA-API
15918 // ==============
15919
15920 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
15921
15922 }(jQuery);
15923
15924 /* ========================================================================
15925 * Bootstrap: button.js v3.2.0
15926 * http://getbootstrap.com/javascript/#buttons
15927 * ========================================================================
15928 * Copyright 2011-2014 Twitter, Inc.
15929 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15930 * ======================================================================== */
15931
15932
15933 +function ($) {
15934 'use strict';
15935
15936 // BUTTON PUBLIC CLASS DEFINITION
15937 // ==============================
15938
15939 var Button = function (element, options) {
15940 this.$element = $(element)
15941 this.options = $.extend({}, Button.DEFAULTS, options)
15942 this.isLoading = false
15943 }
15944
15945 Button.VERSION = '3.2.0'
15946
15947 Button.DEFAULTS = {
15948 loadingText: 'loading...'
15949 }
15950
15951 Button.prototype.setState = function (state) {
15952 var d = 'disabled'
15953 var $el = this.$element
15954 var val = $el.is('input') ? 'val' : 'html'
15955 var data = $el.data()
15956
15957 state = state + 'Text'
15958
15959 if (data.resetText == null) $el.data('resetText', $el[val]())
15960
15961 $el[val](data[state] == null ? this.options[state] : data[state])
15962
15963 // push to event loop to allow forms to submit
15964 setTimeout($.proxy(function () {
15965 if (state == 'loadingText') {
15966 this.isLoading = true
15967 $el.addClass(d).attr(d, d)
15968 } else if (this.isLoading) {
15969 this.isLoading = false
15970 $el.removeClass(d).removeAttr(d)
15971 }
15972 }, this), 0)
15973 }
15974
15975 Button.prototype.toggle = function () {
15976 var changed = true
15977 var $parent = this.$element.closest('[data-toggle="buttons"]')
15978
15979 if ($parent.length) {
15980 var $input = this.$element.find('input')
15981 if ($input.prop('type') == 'radio') {
15982 if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
15983 else $parent.find('.active').removeClass('active')
15984 }
15985 if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
15986 }
15987
15988 if (changed) this.$element.toggleClass('active')
15989 }
15990
15991
15992 // BUTTON PLUGIN DEFINITION
15993 // ========================
15994
15995 function Plugin(option) {
15996 return this.each(function () {
15997 var $this = $(this)
15998 var data = $this.data('bs.button')
15999 var options = typeof option == 'object' && option
16000
16001 if (!data) $this.data('bs.button', (data = new Button(this, options)))
16002
16003 if (option == 'toggle') data.toggle()
16004 else if (option) data.setState(option)
16005 })
16006 }
16007
16008 var old = $.fn.button
16009
16010 $.fn.button = Plugin
16011 $.fn.button.Constructor = Button
16012
16013
16014 // BUTTON NO CONFLICT
16015 // ==================
16016
16017 $.fn.button.noConflict = function () {
16018 $.fn.button = old
16019 return this
16020 }
16021
16022
16023 // BUTTON DATA-API
16024 // ===============
16025
16026 $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
16027 var $btn = $(e.target)
16028 if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
16029 Plugin.call($btn, 'toggle')
16030 e.preventDefault()
16031 })
16032
16033 }(jQuery);
16034
16035 /* ========================================================================
16036 * Bootstrap: carousel.js v3.2.0
16037 * http://getbootstrap.com/javascript/#carousel
16038 * ========================================================================
16039 * Copyright 2011-2014 Twitter, Inc.
16040 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16041 * ======================================================================== */
16042
16043
16044 +function ($) {
16045 'use strict';
16046
16047 // CAROUSEL CLASS DEFINITION
16048 // =========================
16049
16050 var Carousel = function (element, options) {
16051 this.$element = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this))
16052 this.$indicators = this.$element.find('.carousel-indicators')
16053 this.options = options
16054 this.paused =
16055 this.sliding =
16056 this.interval =
16057 this.$active =
16058 this.$items = null
16059
16060 this.options.pause == 'hover' && this.$element
16061 .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
16062 .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
16063 }
16064
16065 Carousel.VERSION = '3.2.0'
16066
16067 Carousel.DEFAULTS = {
16068 interval: 5000,
16069 pause: 'hover',
16070 wrap: true
16071 }
16072
16073 Carousel.prototype.keydown = function (e) {
16074 switch (e.which) {
16075 case 37: this.prev(); break
16076 case 39: this.next(); break
16077 default: return
16078 }
16079
16080 e.preventDefault()
16081 }
16082
16083 Carousel.prototype.cycle = function (e) {
16084 e || (this.paused = false)
16085
16086 this.interval && clearInterval(this.interval)
16087
16088 this.options.interval
16089 && !this.paused
16090 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
16091
16092 return this
16093 }
16094
16095 Carousel.prototype.getItemIndex = function (item) {
16096 this.$items = item.parent().children('.item')
16097 return this.$items.index(item || this.$active)
16098 }
16099
16100 Carousel.prototype.to = function (pos) {
16101 var that = this
16102 var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))
16103
16104 if (pos > (this.$items.length - 1) || pos < 0) return
16105
16106 if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
16107 if (activeIndex == pos) return this.pause().cycle()
16108
16109 return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
16110 }
16111
16112 Carousel.prototype.pause = function (e) {
16113 e || (this.paused = true)
16114
16115 if (this.$element.find('.next, .prev').length && $.support.transition) {
16116 this.$element.trigger($.support.transition.end)
16117 this.cycle(true)
16118 }
16119
16120 this.interval = clearInterval(this.interval)
16121
16122 return this
16123 }
16124
16125 Carousel.prototype.next = function () {
16126 if (this.sliding) return
16127 return this.slide('next')
16128 }
16129
16130 Carousel.prototype.prev = function () {
16131 if (this.sliding) return
16132 return this.slide('prev')
16133 }
16134
16135 Carousel.prototype.slide = function (type, next) {
16136 var $active = this.$element.find('.item.active')
16137 var $next = next || $active[type]()
16138 var isCycling = this.interval
16139 var direction = type == 'next' ? 'left' : 'right'
16140 var fallback = type == 'next' ? 'first' : 'last'
16141 var that = this
16142
16143 if (!$next.length) {
16144 if (!this.options.wrap) return
16145 $next = this.$element.find('.item')[fallback]()
16146 }
16147
16148 if ($next.hasClass('active')) return (this.sliding = false)
16149
16150 var relatedTarget = $next[0]
16151 var slideEvent = $.Event('slide.bs.carousel', {
16152 relatedTarget: relatedTarget,
16153 direction: direction
16154 })
16155 this.$element.trigger(slideEvent)
16156 if (slideEvent.isDefaultPrevented()) return
16157
16158 this.sliding = true
16159
16160 isCycling && this.pause()
16161
16162 if (this.$indicators.length) {
16163 this.$indicators.find('.active').removeClass('active')
16164 var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
16165 $nextIndicator && $nextIndicator.addClass('active')
16166 }
16167
16168 var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
16169 if ($.support.transition && this.$element.hasClass('slide')) {
16170 $next.addClass(type)
16171 $next[0].offsetWidth // force reflow
16172 $active.addClass(direction)
16173 $next.addClass(direction)
16174 $active
16175 .one('bsTransitionEnd', function () {
16176 $next.removeClass([type, direction].join(' ')).addClass('active')
16177 $active.removeClass(['active', direction].join(' '))
16178 that.sliding = false
16179 setTimeout(function () {
16180 that.$element.trigger(slidEvent)
16181 }, 0)
16182 })
16183 .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
16184 } else {
16185 $active.removeClass('active')
16186 $next.addClass('active')
16187 this.sliding = false
16188 this.$element.trigger(slidEvent)
16189 }
16190
16191 isCycling && this.cycle()
16192
16193 return this
16194 }
16195
16196
16197 // CAROUSEL PLUGIN DEFINITION
16198 // ==========================
16199
16200 function Plugin(option) {
16201 return this.each(function () {
16202 var $this = $(this)
16203 var data = $this.data('bs.carousel')
16204 var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
16205 var action = typeof option == 'string' ? option : options.slide
16206
16207 if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
16208 if (typeof option == 'number') data.to(option)
16209 else if (action) data[action]()
16210 else if (options.interval) data.pause().cycle()
16211 })
16212 }
16213
16214 var old = $.fn.carousel
16215
16216 $.fn.carousel = Plugin
16217 $.fn.carousel.Constructor = Carousel
16218
16219
16220 // CAROUSEL NO CONFLICT
16221 // ====================
16222
16223 $.fn.carousel.noConflict = function () {
16224 $.fn.carousel = old
16225 return this
16226 }
16227
16228
16229 // CAROUSEL DATA-API
16230 // =================
16231
16232 $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
16233 var href
16234 var $this = $(this)
16235 var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
16236 if (!$target.hasClass('carousel')) return
16237 var options = $.extend({}, $target.data(), $this.data())
16238 var slideIndex = $this.attr('data-slide-to')
16239 if (slideIndex) options.interval = false
16240
16241 Plugin.call($target, options)
16242
16243 if (slideIndex) {
16244 $target.data('bs.carousel').to(slideIndex)
16245 }
16246
16247 e.preventDefault()
16248 })
16249
16250 $(window).on('load', function () {
16251 $('[data-ride="carousel"]').each(function () {
16252 var $carousel = $(this)
16253 Plugin.call($carousel, $carousel.data())
16254 })
16255 })
16256
16257 }(jQuery);
16258
16259 /* ========================================================================
16260 * Bootstrap: collapse.js v3.2.0
16261 * http://getbootstrap.com/javascript/#collapse
16262 * ========================================================================
16263 * Copyright 2011-2014 Twitter, Inc.
16264 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16265 * ======================================================================== */
16266
16267
16268 +function ($) {
16269 'use strict';
16270
16271 // COLLAPSE PUBLIC CLASS DEFINITION
16272 // ================================
16273
16274 var Collapse = function (element, options) {
16275 this.$element = $(element)
16276 this.options = $.extend({}, Collapse.DEFAULTS, options)
16277 this.transitioning = null
16278
16279 if (this.options.parent) this.$parent = $(this.options.parent)
16280 if (this.options.toggle) this.toggle()
16281 }
16282
16283 Collapse.VERSION = '3.2.0'
16284
16285 Collapse.DEFAULTS = {
16286 toggle: true
16287 }
16288
16289 Collapse.prototype.dimension = function () {
16290 var hasWidth = this.$element.hasClass('width')
16291 return hasWidth ? 'width' : 'height'
16292 }
16293
16294 Collapse.prototype.show = function () {
16295 if (this.transitioning || this.$element.hasClass('in')) return
16296
16297 var startEvent = $.Event('show.bs.collapse')
16298 this.$element.trigger(startEvent)
16299 if (startEvent.isDefaultPrevented()) return
16300
16301 var actives = this.$parent && this.$parent.find('> .panel > .in')
16302
16303 if (actives && actives.length) {
16304 var hasData = actives.data('bs.collapse')
16305 if (hasData && hasData.transitioning) return
16306 Plugin.call(actives, 'hide')
16307 hasData || actives.data('bs.collapse', null)
16308 }
16309
16310 var dimension = this.dimension()
16311
16312 this.$element
16313 .removeClass('collapse')
16314 .addClass('collapsing')[dimension](0)
16315
16316 this.transitioning = 1
16317
16318 var complete = function () {
16319 this.$element
16320 .removeClass('collapsing')
16321 .addClass('collapse in')[dimension]('')
16322 this.transitioning = 0
16323 this.$element
16324 .trigger('shown.bs.collapse')
16325 }
16326
16327 if (!$.support.transition) return complete.call(this)
16328
16329 var scrollSize = $.camelCase(['scroll', dimension].join('-'))
16330
16331 this.$element
16332 .one('bsTransitionEnd', $.proxy(complete, this))
16333 .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
16334 }
16335
16336 Collapse.prototype.hide = function () {
16337 if (this.transitioning || !this.$element.hasClass('in')) return
16338
16339 var startEvent = $.Event('hide.bs.collapse')
16340 this.$element.trigger(startEvent)
16341 if (startEvent.isDefaultPrevented()) return
16342
16343 var dimension = this.dimension()
16344
16345 this.$element[dimension](this.$element[dimension]())[0].offsetHeight
16346
16347 this.$element
16348 .addClass('collapsing')
16349 .removeClass('collapse')
16350 .removeClass('in')
16351
16352 this.transitioning = 1
16353
16354 var complete = function () {
16355 this.transitioning = 0
16356 this.$element
16357 .trigger('hidden.bs.collapse')
16358 .removeClass('collapsing')
16359 .addClass('collapse')
16360 }
16361
16362 if (!$.support.transition) return complete.call(this)
16363
16364 this.$element
16365 [dimension](0)
16366 .one('bsTransitionEnd', $.proxy(complete, this))
16367 .emulateTransitionEnd(350)
16368 }
16369
16370 Collapse.prototype.toggle = function () {
16371 this[this.$element.hasClass('in') ? 'hide' : 'show']()
16372 }
16373
16374
16375 // COLLAPSE PLUGIN DEFINITION
16376 // ==========================
16377
16378 function Plugin(option) {
16379 return this.each(function () {
16380 var $this = $(this)
16381 var data = $this.data('bs.collapse')
16382 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
16383
16384 if (!data && options.toggle && option == 'show') option = !option
16385 if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
16386 if (typeof option == 'string') data[option]()
16387 })
16388 }
16389
16390 var old = $.fn.collapse
16391
16392 $.fn.collapse = Plugin
16393 $.fn.collapse.Constructor = Collapse
16394
16395
16396 // COLLAPSE NO CONFLICT
16397 // ====================
16398
16399 $.fn.collapse.noConflict = function () {
16400 $.fn.collapse = old
16401 return this
16402 }
16403
16404
16405 // COLLAPSE DATA-API
16406 // =================
16407
16408 $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
16409 var href
16410 var $this = $(this)
16411 var target = $this.attr('data-target')
16412 || e.preventDefault()
16413 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
16414 var $target = $(target)
16415 var data = $target.data('bs.collapse')
16416 var option = data ? 'toggle' : $this.data()
16417 var parent = $this.attr('data-parent')
16418 var $parent = parent && $(parent)
16419
16420 if (!data || !data.transitioning) {
16421 if ($parent) $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed')
16422 $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
16423 }
16424
16425 Plugin.call($target, option)
16426 })
16427
16428 }(jQuery);
16429
16430 /* ========================================================================
16431 * Bootstrap: dropdown.js v3.2.0
16432 * http://getbootstrap.com/javascript/#dropdowns
16433 * ========================================================================
16434 * Copyright 2011-2014 Twitter, Inc.
16435 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16436 * ======================================================================== */
16437
16438
16439 +function ($) {
16440 'use strict';
16441
16442 // DROPDOWN CLASS DEFINITION
16443 // =========================
16444
16445 var backdrop = '.dropdown-backdrop'
16446 var toggle = '[data-toggle="dropdown"]'
16447 var Dropdown = function (element) {
16448 $(element).on('click.bs.dropdown', this.toggle)
16449 }
16450
16451 Dropdown.VERSION = '3.2.0'
16452
16453 Dropdown.prototype.toggle = function (e) {
16454 var $this = $(this)
16455
16456 if ($this.is('.disabled, :disabled')) return
16457
16458 var $parent = getParent($this)
16459 var isActive = $parent.hasClass('open')
16460
16461 clearMenus()
16462
16463 if (!isActive) {
16464 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
16465 // if mobile we use a backdrop because click events don't delegate
16466 $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
16467 }
16468
16469 var relatedTarget = { relatedTarget: this }
16470 $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
16471
16472 if (e.isDefaultPrevented()) return
16473
16474 $this.trigger('focus')
16475
16476 $parent
16477 .toggleClass('open')
16478 .trigger('shown.bs.dropdown', relatedTarget)
16479 }
16480
16481 return false
16482 }
16483
16484 Dropdown.prototype.keydown = function (e) {
16485 if (!/(38|40|27)/.test(e.keyCode)) return
16486
16487 var $this = $(this)
16488
16489 e.preventDefault()
16490 e.stopPropagation()
16491
16492 if ($this.is('.disabled, :disabled')) return
16493
16494 var $parent = getParent($this)
16495 var isActive = $parent.hasClass('open')
16496
16497 if (!isActive || (isActive && e.keyCode == 27)) {
16498 if (e.which == 27) $parent.find(toggle).trigger('focus')
16499 return $this.trigger('click')
16500 }
16501
16502 var desc = ' li:not(.divider):visible a'
16503 var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
16504
16505 if (!$items.length) return
16506
16507 var index = $items.index($items.filter(':focus'))
16508
16509 if (e.keyCode == 38 && index > 0) index-- // up
16510 if (e.keyCode == 40 && index < $items.length - 1) index++ // down
16511 if (!~index) index = 0
16512
16513 $items.eq(index).trigger('focus')
16514 }
16515
16516 function clearMenus(e) {
16517 if (e && e.which === 3) return
16518 $(backdrop).remove()
16519 $(toggle).each(function () {
16520 var $parent = getParent($(this))
16521 var relatedTarget = { relatedTarget: this }
16522 if (!$parent.hasClass('open')) return
16523 $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
16524 if (e.isDefaultPrevented()) return
16525 $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
16526 })
16527 }
16528
16529 function getParent($this) {
16530 var selector = $this.attr('data-target')
16531
16532 if (!selector) {
16533 selector = $this.attr('href')
16534 selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
16535 }
16536
16537 var $parent = selector && $(selector)
16538
16539 return $parent && $parent.length ? $parent : $this.parent()
16540 }
16541
16542
16543 // DROPDOWN PLUGIN DEFINITION
16544 // ==========================
16545
16546 function Plugin(option) {
16547 return this.each(function () {
16548 var $this = $(this)
16549 var data = $this.data('bs.dropdown')
16550
16551 if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
16552 if (typeof option == 'string') data[option].call($this)
16553 })
16554 }
16555
16556 var old = $.fn.dropdown
16557
16558 $.fn.dropdown = Plugin
16559 $.fn.dropdown.Constructor = Dropdown
16560
16561
16562 // DROPDOWN NO CONFLICT
16563 // ====================
16564
16565 $.fn.dropdown.noConflict = function () {
16566 $.fn.dropdown = old
16567 return this
16568 }
16569
16570
16571 // APPLY TO STANDARD DROPDOWN ELEMENTS
16572 // ===================================
16573
16574 $(document)
16575 .on('click.bs.dropdown.data-api', clearMenus)
16576 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
16577 .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
16578 .on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown)
16579
16580 }(jQuery);
16581
16582 /* ========================================================================
16583 * Bootstrap: modal.js v3.2.0
16584 * http://getbootstrap.com/javascript/#modals
16585 * ========================================================================
16586 * Copyright 2011-2014 Twitter, Inc.
16587 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16588 * ======================================================================== */
16589
16590
16591 +function ($) {
16592 'use strict';
16593
16594 // MODAL CLASS DEFINITION
16595 // ======================
16596
16597 var Modal = function (element, options) {
16598 this.options = options
16599 this.$body = $(document.body)
16600 this.$element = $(element)
16601 this.$backdrop =
16602 this.isShown = null
16603 this.scrollbarWidth = 0
16604
16605 if (this.options.remote) {
16606 this.$element
16607 .find('.modal-content')
16608 .load(this.options.remote, $.proxy(function () {
16609 this.$element.trigger('loaded.bs.modal')
16610 }, this))
16611 }
16612 }
16613
16614 Modal.VERSION = '3.2.0'
16615
16616 Modal.DEFAULTS = {
16617 backdrop: true,
16618 keyboard: true,
16619 show: true
16620 }
16621
16622 Modal.prototype.toggle = function (_relatedTarget) {
16623 return this.isShown ? this.hide() : this.show(_relatedTarget)
16624 }
16625
16626 Modal.prototype.show = function (_relatedTarget) {
16627 var that = this
16628 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
16629
16630 this.$element.trigger(e)
16631
16632 if (this.isShown || e.isDefaultPrevented()) return
16633
16634 this.isShown = true
16635
16636 this.checkScrollbar()
16637 this.$body.addClass('modal-open')
16638
16639 this.setScrollbar()
16640 this.escape()
16641
16642 this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
16643
16644 this.backdrop(function () {
16645 var transition = $.support.transition && that.$element.hasClass('fade')
16646
16647 if (!that.$element.parent().length) {
16648 that.$element.appendTo(that.$body) // don't move modals dom position
16649 }
16650
16651 that.$element
16652 .show()
16653 .scrollTop(0)
16654
16655 if (transition) {
16656 that.$element[0].offsetWidth // force reflow
16657 }
16658
16659 that.$element
16660 .addClass('in')
16661 .attr('aria-hidden', false)
16662
16663 that.enforceFocus()
16664
16665 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
16666
16667 transition ?
16668 that.$element.find('.modal-dialog') // wait for modal to slide in
16669 .one('bsTransitionEnd', function () {
16670 that.$element.trigger('focus').trigger(e)
16671 })
16672 .emulateTransitionEnd(300) :
16673 that.$element.trigger('focus').trigger(e)
16674 })
16675 }
16676
16677 Modal.prototype.hide = function (e) {
16678 if (e) e.preventDefault()
16679
16680 e = $.Event('hide.bs.modal')
16681
16682 this.$element.trigger(e)
16683
16684 if (!this.isShown || e.isDefaultPrevented()) return
16685
16686 this.isShown = false
16687
16688 this.$body.removeClass('modal-open')
16689
16690 this.resetScrollbar()
16691 this.escape()
16692
16693 $(document).off('focusin.bs.modal')
16694
16695 this.$element
16696 .removeClass('in')
16697 .attr('aria-hidden', true)
16698 .off('click.dismiss.bs.modal')
16699
16700 $.support.transition && this.$element.hasClass('fade') ?
16701 this.$element
16702 .one('bsTransitionEnd', $.proxy(this.hideModal, this))
16703 .emulateTransitionEnd(300) :
16704 this.hideModal()
16705 }
16706
16707 Modal.prototype.enforceFocus = function () {
16708 $(document)
16709 .off('focusin.bs.modal') // guard against infinite focus loop
16710 .on('focusin.bs.modal', $.proxy(function (e) {
16711 if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
16712 this.$element.trigger('focus')
16713 }
16714 }, this))
16715 }
16716
16717 Modal.prototype.escape = function () {
16718 if (this.isShown && this.options.keyboard) {
16719 this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
16720 e.which == 27 && this.hide()
16721 }, this))
16722 } else if (!this.isShown) {
16723 this.$element.off('keyup.dismiss.bs.modal')
16724 }
16725 }
16726
16727 Modal.prototype.hideModal = function () {
16728 var that = this
16729 this.$element.hide()
16730 this.backdrop(function () {
16731 that.$element.trigger('hidden.bs.modal')
16732 })
16733 }
16734
16735 Modal.prototype.removeBackdrop = function () {
16736 this.$backdrop && this.$backdrop.remove()
16737 this.$backdrop = null
16738 }
16739
16740 Modal.prototype.backdrop = function (callback) {
16741 var that = this
16742 var animate = this.$element.hasClass('fade') ? 'fade' : ''
16743
16744 if (this.isShown && this.options.backdrop) {
16745 var doAnimate = $.support.transition && animate
16746
16747 this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
16748 .appendTo(this.$body)
16749
16750 this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
16751 if (e.target !== e.currentTarget) return
16752 this.options.backdrop == 'static'
16753 ? this.$element[0].focus.call(this.$element[0])
16754 : this.hide.call(this)
16755 }, this))
16756
16757 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
16758
16759 this.$backdrop.addClass('in')
16760
16761 if (!callback) return
16762
16763 doAnimate ?
16764 this.$backdrop
16765 .one('bsTransitionEnd', callback)
16766 .emulateTransitionEnd(150) :
16767 callback()
16768
16769 } else if (!this.isShown && this.$backdrop) {
16770 this.$backdrop.removeClass('in')
16771
16772 var callbackRemove = function () {
16773 that.removeBackdrop()
16774 callback && callback()
16775 }
16776 $.support.transition && this.$element.hasClass('fade') ?
16777 this.$backdrop
16778 .one('bsTransitionEnd', callbackRemove)
16779 .emulateTransitionEnd(150) :
16780 callbackRemove()
16781
16782 } else if (callback) {
16783 callback()
16784 }
16785 }
16786
16787 Modal.prototype.checkScrollbar = function () {
16788 if (document.body.clientWidth >= window.innerWidth) return
16789 this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
16790 }
16791
16792 Modal.prototype.setScrollbar = function () {
16793 var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
16794 if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
16795 }
16796
16797 Modal.prototype.resetScrollbar = function () {
16798 this.$body.css('padding-right', '')
16799 }
16800
16801 Modal.prototype.measureScrollbar = function () { // thx walsh
16802 var scrollDiv = document.createElement('div')
16803 scrollDiv.className = 'modal-scrollbar-measure'
16804 this.$body.append(scrollDiv)
16805 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
16806 this.$body[0].removeChild(scrollDiv)
16807 return scrollbarWidth
16808 }
16809
16810
16811 // MODAL PLUGIN DEFINITION
16812 // =======================
16813
16814 function Plugin(option, _relatedTarget) {
16815 return this.each(function () {
16816 var $this = $(this)
16817 var data = $this.data('bs.modal')
16818 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
16819
16820 if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
16821 if (typeof option == 'string') data[option](_relatedTarget)
16822 else if (options.show) data.show(_relatedTarget)
16823 })
16824 }
16825
16826 var old = $.fn.modal
16827
16828 $.fn.modal = Plugin
16829 $.fn.modal.Constructor = Modal
16830
16831
16832 // MODAL NO CONFLICT
16833 // =================
16834
16835 $.fn.modal.noConflict = function () {
16836 $.fn.modal = old
16837 return this
16838 }
16839
16840
16841 // MODAL DATA-API
16842 // ==============
16843
16844 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
16845 var $this = $(this)
16846 var href = $this.attr('href')
16847 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
16848 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
16849
16850 if ($this.is('a')) e.preventDefault()
16851
16852 $target.one('show.bs.modal', function (showEvent) {
16853 if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
16854 $target.one('hidden.bs.modal', function () {
16855 $this.is(':visible') && $this.trigger('focus')
16856 })
16857 })
16858 Plugin.call($target, option, this)
16859 })
16860
16861 }(jQuery);
16862
16863 /* ========================================================================
16864 * Bootstrap: tooltip.js v3.2.0
16865 * http://getbootstrap.com/javascript/#tooltip
16866 * Inspired by the original jQuery.tipsy by Jason Frame
16867 * ========================================================================
16868 * Copyright 2011-2014 Twitter, Inc.
16869 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16870 * ======================================================================== */
16871
16872
16873 +function ($) {
16874 'use strict';
16875
16876 // TOOLTIP PUBLIC CLASS DEFINITION
16877 // ===============================
16878
16879 var Tooltip = function (element, options) {
16880 this.type =
16881 this.options =
16882 this.enabled =
16883 this.timeout =
16884 this.hoverState =
16885 this.$element = null
16886
16887 this.init('tooltip', element, options)
16888 }
16889
16890 Tooltip.VERSION = '3.2.0'
16891
16892 Tooltip.DEFAULTS = {
16893 animation: true,
16894 placement: 'top',
16895 selector: false,
16896 template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
16897 trigger: 'hover focus',
16898 title: '',
16899 delay: 0,
16900 html: false,
16901 container: false,
16902 viewport: {
16903 selector: 'body',
16904 padding: 0
16905 }
16906 }
16907
16908 Tooltip.prototype.init = function (type, element, options) {
16909 this.enabled = true
16910 this.type = type
16911 this.$element = $(element)
16912 this.options = this.getOptions(options)
16913 this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
16914
16915 var triggers = this.options.trigger.split(' ')
16916
16917 for (var i = triggers.length; i--;) {
16918 var trigger = triggers[i]
16919
16920 if (trigger == 'click') {
16921 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
16922 } else if (trigger != 'manual') {
16923 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
16924 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
16925
16926 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
16927 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
16928 }
16929 }
16930
16931 this.options.selector ?
16932 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
16933 this.fixTitle()
16934 }
16935
16936 Tooltip.prototype.getDefaults = function () {
16937 return Tooltip.DEFAULTS
16938 }
16939
16940 Tooltip.prototype.getOptions = function (options) {
16941 options = $.extend({}, this.getDefaults(), this.$element.data(), options)
16942
16943 if (options.delay && typeof options.delay == 'number') {
16944 options.delay = {
16945 show: options.delay,
16946 hide: options.delay
16947 }
16948 }
16949
16950 return options
16951 }
16952
16953 Tooltip.prototype.getDelegateOptions = function () {
16954 var options = {}
16955 var defaults = this.getDefaults()
16956
16957 this._options && $.each(this._options, function (key, value) {
16958 if (defaults[key] != value) options[key] = value
16959 })
16960
16961 return options
16962 }
16963
16964 Tooltip.prototype.enter = function (obj) {
16965 var self = obj instanceof this.constructor ?
16966 obj : $(obj.currentTarget).data('bs.' + this.type)
16967
16968 if (!self) {
16969 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
16970 $(obj.currentTarget).data('bs.' + this.type, self)
16971 }
16972
16973 clearTimeout(self.timeout)
16974
16975 self.hoverState = 'in'
16976
16977 if (!self.options.delay || !self.options.delay.show) return self.show()
16978
16979 self.timeout = setTimeout(function () {
16980 if (self.hoverState == 'in') self.show()
16981 }, self.options.delay.show)
16982 }
16983
16984 Tooltip.prototype.leave = function (obj) {
16985 var self = obj instanceof this.constructor ?
16986 obj : $(obj.currentTarget).data('bs.' + this.type)
16987
16988 if (!self) {
16989 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
16990 $(obj.currentTarget).data('bs.' + this.type, self)
16991 }
16992
16993 clearTimeout(self.timeout)
16994
16995 self.hoverState = 'out'
16996
16997 if (!self.options.delay || !self.options.delay.hide) return self.hide()
16998
16999 self.timeout = setTimeout(function () {
17000 if (self.hoverState == 'out') self.hide()
17001 }, self.options.delay.hide)
17002 }
17003
17004 Tooltip.prototype.show = function () {
17005 var e = $.Event('show.bs.' + this.type)
17006
17007 if (this.hasContent() && this.enabled) {
17008 this.$element.trigger(e)
17009
17010 var inDom = $.contains(document.documentElement, this.$element[0])
17011 if (e.isDefaultPrevented() || !inDom) return
17012 var that = this
17013
17014 var $tip = this.tip()
17015
17016 var tipId = this.getUID(this.type)
17017
17018 this.setContent()
17019 $tip.attr('id', tipId)
17020 this.$element.attr('aria-describedby', tipId)
17021
17022 if (this.options.animation) $tip.addClass('fade')
17023
17024 var placement = typeof this.options.placement == 'function' ?
17025 this.options.placement.call(this, $tip[0], this.$element[0]) :
17026 this.options.placement
17027
17028 var autoToken = /\s?auto?\s?/i
17029 var autoPlace = autoToken.test(placement)
17030 if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
17031
17032 $tip
17033 .detach()
17034 .css({ top: 0, left: 0, display: 'block' })
17035 .addClass(placement)
17036 .data('bs.' + this.type, this)
17037
17038 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
17039
17040 var pos = this.getPosition()
17041 var actualWidth = $tip[0].offsetWidth
17042 var actualHeight = $tip[0].offsetHeight
17043
17044 if (autoPlace) {
17045 var orgPlacement = placement
17046 var $parent = this.$element.parent()
17047 var parentDim = this.getPosition($parent)
17048
17049 placement = placement == 'bottom' && pos.top + pos.height + actualHeight - parentDim.scroll > parentDim.height ? 'top' :
17050 placement == 'top' && pos.top - parentDim.scroll - actualHeight < 0 ? 'bottom' :
17051 placement == 'right' && pos.right + actualWidth > parentDim.width ? 'left' :
17052 placement == 'left' && pos.left - actualWidth < parentDim.left ? 'right' :
17053 placement
17054
17055 $tip
17056 .removeClass(orgPlacement)
17057 .addClass(placement)
17058 }
17059
17060 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
17061
17062 this.applyPlacement(calculatedOffset, placement)
17063
17064 var complete = function () {
17065 that.$element.trigger('shown.bs.' + that.type)
17066 that.hoverState = null
17067 }
17068
17069 $.support.transition && this.$tip.hasClass('fade') ?
17070 $tip
17071 .one('bsTransitionEnd', complete)
17072 .emulateTransitionEnd(150) :
17073 complete()
17074 }
17075 }
17076
17077 Tooltip.prototype.applyPlacement = function (offset, placement) {
17078 var $tip = this.tip()
17079 var width = $tip[0].offsetWidth
17080 var height = $tip[0].offsetHeight
17081
17082 // manually read margins because getBoundingClientRect includes difference
17083 var marginTop = parseInt($tip.css('margin-top'), 10)
17084 var marginLeft = parseInt($tip.css('margin-left'), 10)
17085
17086 // we must check for NaN for ie 8/9
17087 if (isNaN(marginTop)) marginTop = 0
17088 if (isNaN(marginLeft)) marginLeft = 0
17089
17090 offset.top = offset.top + marginTop
17091 offset.left = offset.left + marginLeft
17092
17093 // $.fn.offset doesn't round pixel values
17094 // so we use setOffset directly with our own function B-0
17095 $.offset.setOffset($tip[0], $.extend({
17096 using: function (props) {
17097 $tip.css({
17098 top: Math.round(props.top),
17099 left: Math.round(props.left)
17100 })
17101 }
17102 }, offset), 0)
17103
17104 $tip.addClass('in')
17105
17106 // check to see if placing tip in new offset caused the tip to resize itself
17107 var actualWidth = $tip[0].offsetWidth
17108 var actualHeight = $tip[0].offsetHeight
17109
17110 if (placement == 'top' && actualHeight != height) {
17111 offset.top = offset.top + height - actualHeight
17112 }
17113
17114 var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
17115
17116 if (delta.left) offset.left += delta.left
17117 else offset.top += delta.top
17118
17119 var arrowDelta = delta.left ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
17120 var arrowPosition = delta.left ? 'left' : 'top'
17121 var arrowOffsetPosition = delta.left ? 'offsetWidth' : 'offsetHeight'
17122
17123 $tip.offset(offset)
17124 this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], arrowPosition)
17125 }
17126
17127 Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
17128 this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '')
17129 }
17130
17131 Tooltip.prototype.setContent = function () {
17132 var $tip = this.tip()
17133 var title = this.getTitle()
17134
17135 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
17136 $tip.removeClass('fade in top bottom left right')
17137 }
17138
17139 Tooltip.prototype.hide = function () {
17140 var that = this
17141 var $tip = this.tip()
17142 var e = $.Event('hide.bs.' + this.type)
17143
17144 this.$element.removeAttr('aria-describedby')
17145
17146 function complete() {
17147 if (that.hoverState != 'in') $tip.detach()
17148 that.$element.trigger('hidden.bs.' + that.type)
17149 }
17150
17151 this.$element.trigger(e)
17152
17153 if (e.isDefaultPrevented()) return
17154
17155 $tip.removeClass('in')
17156
17157 $.support.transition && this.$tip.hasClass('fade') ?
17158 $tip
17159 .one('bsTransitionEnd', complete)
17160 .emulateTransitionEnd(150) :
17161 complete()
17162
17163 this.hoverState = null
17164
17165 return this
17166 }
17167
17168 Tooltip.prototype.fixTitle = function () {
17169 var $e = this.$element
17170 if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
17171 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
17172 }
17173 }
17174
17175 Tooltip.prototype.hasContent = function () {
17176 return this.getTitle()
17177 }
17178
17179 Tooltip.prototype.getPosition = function ($element) {
17180 $element = $element || this.$element
17181 var el = $element[0]
17182 var isBody = el.tagName == 'BODY'
17183 return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : null, {
17184 scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop(),
17185 width: isBody ? $(window).width() : $element.outerWidth(),
17186 height: isBody ? $(window).height() : $element.outerHeight()
17187 }, isBody ? { top: 0, left: 0 } : $element.offset())
17188 }
17189
17190 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
17191 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
17192 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
17193 placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
17194 /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
17195
17196 }
17197
17198 Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
17199 var delta = { top: 0, left: 0 }
17200 if (!this.$viewport) return delta
17201
17202 var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
17203 var viewportDimensions = this.getPosition(this.$viewport)
17204
17205 if (/right|left/.test(placement)) {
17206 var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
17207 var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
17208 if (topEdgeOffset < viewportDimensions.top) { // top overflow
17209 delta.top = viewportDimensions.top - topEdgeOffset
17210 } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
17211 delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
17212 }
17213 } else {
17214 var leftEdgeOffset = pos.left - viewportPadding
17215 var rightEdgeOffset = pos.left + viewportPadding + actualWidth
17216 if (leftEdgeOffset < viewportDimensions.left) { // left overflow
17217 delta.left = viewportDimensions.left - leftEdgeOffset
17218 } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
17219 delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
17220 }
17221 }
17222
17223 return delta
17224 }
17225
17226 Tooltip.prototype.getTitle = function () {
17227 var title
17228 var $e = this.$element
17229 var o = this.options
17230
17231 title = $e.attr('data-original-title')
17232 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
17233
17234 return title
17235 }
17236
17237 Tooltip.prototype.getUID = function (prefix) {
17238 do prefix += ~~(Math.random() * 1000000)
17239 while (document.getElementById(prefix))
17240 return prefix
17241 }
17242
17243 Tooltip.prototype.tip = function () {
17244 return (this.$tip = this.$tip || $(this.options.template))
17245 }
17246
17247 Tooltip.prototype.arrow = function () {
17248 return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
17249 }
17250
17251 Tooltip.prototype.validate = function () {
17252 if (!this.$element[0].parentNode) {
17253 this.hide()
17254 this.$element = null
17255 this.options = null
17256 }
17257 }
17258
17259 Tooltip.prototype.enable = function () {
17260 this.enabled = true
17261 }
17262
17263 Tooltip.prototype.disable = function () {
17264 this.enabled = false
17265 }
17266
17267 Tooltip.prototype.toggleEnabled = function () {
17268 this.enabled = !this.enabled
17269 }
17270
17271 Tooltip.prototype.toggle = function (e) {
17272 var self = this
17273 if (e) {
17274 self = $(e.currentTarget).data('bs.' + this.type)
17275 if (!self) {
17276 self = new this.constructor(e.currentTarget, this.getDelegateOptions())
17277 $(e.currentTarget).data('bs.' + this.type, self)
17278 }
17279 }
17280
17281 self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
17282 }
17283
17284 Tooltip.prototype.destroy = function () {
17285 clearTimeout(this.timeout)
17286 this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
17287 }
17288
17289
17290 // TOOLTIP PLUGIN DEFINITION
17291 // =========================
17292
17293 function Plugin(option) {
17294 return this.each(function () {
17295 var $this = $(this)
17296 var data = $this.data('bs.tooltip')
17297 var options = typeof option == 'object' && option
17298
17299 if (!data && option == 'destroy') return
17300 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
17301 if (typeof option == 'string') data[option]()
17302 })
17303 }
17304
17305 var old = $.fn.tooltip
17306
17307 $.fn.tooltip = Plugin
17308 $.fn.tooltip.Constructor = Tooltip
17309
17310
17311 // TOOLTIP NO CONFLICT
17312 // ===================
17313
17314 $.fn.tooltip.noConflict = function () {
17315 $.fn.tooltip = old
17316 return this
17317 }
17318
17319 }(jQuery);
17320
17321 /* ========================================================================
17322 * Bootstrap: popover.js v3.2.0
17323 * http://getbootstrap.com/javascript/#popovers
17324 * ========================================================================
17325 * Copyright 2011-2014 Twitter, Inc.
17326 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17327 * ======================================================================== */
17328
17329
17330 +function ($) {
17331 'use strict';
17332
17333 // POPOVER PUBLIC CLASS DEFINITION
17334 // ===============================
17335
17336 var Popover = function (element, options) {
17337 this.init('popover', element, options)
17338 }
17339
17340 if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
17341
17342 Popover.VERSION = '3.2.0'
17343
17344 Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
17345 placement: 'right',
17346 trigger: 'click',
17347 content: '',
17348 template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
17349 })
17350
17351
17352 // NOTE: POPOVER EXTENDS tooltip.js
17353 // ================================
17354
17355 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
17356
17357 Popover.prototype.constructor = Popover
17358
17359 Popover.prototype.getDefaults = function () {
17360 return Popover.DEFAULTS
17361 }
17362
17363 Popover.prototype.setContent = function () {
17364 var $tip = this.tip()
17365 var title = this.getTitle()
17366 var content = this.getContent()
17367
17368 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
17369 $tip.find('.popover-content').empty()[ // we use append for html objects to maintain js events
17370 this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
17371 ](content)
17372
17373 $tip.removeClass('fade top bottom left right in')
17374
17375 // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
17376 // this manually by checking the contents.
17377 if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
17378 }
17379
17380 Popover.prototype.hasContent = function () {
17381 return this.getTitle() || this.getContent()
17382 }
17383
17384 Popover.prototype.getContent = function () {
17385 var $e = this.$element
17386 var o = this.options
17387
17388 return $e.attr('data-content')
17389 || (typeof o.content == 'function' ?
17390 o.content.call($e[0]) :
17391 o.content)
17392 }
17393
17394 Popover.prototype.arrow = function () {
17395 return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
17396 }
17397
17398 Popover.prototype.tip = function () {
17399 if (!this.$tip) this.$tip = $(this.options.template)
17400 return this.$tip
17401 }
17402
17403
17404 // POPOVER PLUGIN DEFINITION
17405 // =========================
17406
17407 function Plugin(option) {
17408 return this.each(function () {
17409 var $this = $(this)
17410 var data = $this.data('bs.popover')
17411 var options = typeof option == 'object' && option
17412
17413 if (!data && option == 'destroy') return
17414 if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
17415 if (typeof option == 'string') data[option]()
17416 })
17417 }
17418
17419 var old = $.fn.popover
17420
17421 $.fn.popover = Plugin
17422 $.fn.popover.Constructor = Popover
17423
17424
17425 // POPOVER NO CONFLICT
17426 // ===================
17427
17428 $.fn.popover.noConflict = function () {
17429 $.fn.popover = old
17430 return this
17431 }
17432
17433 }(jQuery);
17434
17435 /* ========================================================================
17436 * Bootstrap: scrollspy.js v3.2.0
17437 * http://getbootstrap.com/javascript/#scrollspy
17438 * ========================================================================
17439 * Copyright 2011-2014 Twitter, Inc.
17440 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17441 * ======================================================================== */
17442
17443
17444 +function ($) {
17445 'use strict';
17446
17447 // SCROLLSPY CLASS DEFINITION
17448 // ==========================
17449
17450 function ScrollSpy(element, options) {
17451 var process = $.proxy(this.process, this)
17452
17453 this.$body = $('body')
17454 this.$scrollElement = $(element).is('body') ? $(window) : $(element)
17455 this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
17456 this.selector = (this.options.target || '') + ' .nav li > a'
17457 this.offsets = []
17458 this.targets = []
17459 this.activeTarget = null
17460 this.scrollHeight = 0
17461
17462 this.$scrollElement.on('scroll.bs.scrollspy', process)
17463 this.refresh()
17464 this.process()
17465 }
17466
17467 ScrollSpy.VERSION = '3.2.0'
17468
17469 ScrollSpy.DEFAULTS = {
17470 offset: 10
17471 }
17472
17473 ScrollSpy.prototype.getScrollHeight = function () {
17474 return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
17475 }
17476
17477 ScrollSpy.prototype.refresh = function () {
17478 var offsetMethod = 'offset'
17479 var offsetBase = 0
17480
17481 if (!$.isWindow(this.$scrollElement[0])) {
17482 offsetMethod = 'position'
17483 offsetBase = this.$scrollElement.scrollTop()
17484 }
17485
17486 this.offsets = []
17487 this.targets = []
17488 this.scrollHeight = this.getScrollHeight()
17489
17490 var self = this
17491
17492 this.$body
17493 .find(this.selector)
17494 .map(function () {
17495 var $el = $(this)
17496 var href = $el.data('target') || $el.attr('href')
17497 var $href = /^#./.test(href) && $(href)
17498
17499 return ($href
17500 && $href.length
17501 && $href.is(':visible')
17502 && [[$href[offsetMethod]().top + offsetBase, href]]) || null
17503 })
17504 .sort(function (a, b) { return a[0] - b[0] })
17505 .each(function () {
17506 self.offsets.push(this[0])
17507 self.targets.push(this[1])
17508 })
17509 }
17510
17511 ScrollSpy.prototype.process = function () {
17512 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
17513 var scrollHeight = this.getScrollHeight()
17514 var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height()
17515 var offsets = this.offsets
17516 var targets = this.targets
17517 var activeTarget = this.activeTarget
17518 var i
17519
17520 if (this.scrollHeight != scrollHeight) {
17521 this.refresh()
17522 }
17523
17524 if (scrollTop >= maxScroll) {
17525 return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
17526 }
17527
17528 if (activeTarget && scrollTop <= offsets[0]) {
17529 return activeTarget != (i = targets[0]) && this.activate(i)
17530 }
17531
17532 for (i = offsets.length; i--;) {
17533 activeTarget != targets[i]
17534 && scrollTop >= offsets[i]
17535 && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
17536 && this.activate(targets[i])
17537 }
17538 }
17539
17540 ScrollSpy.prototype.activate = function (target) {
17541 this.activeTarget = target
17542
17543 $(this.selector)
17544 .parentsUntil(this.options.target, '.active')
17545 .removeClass('active')
17546
17547 var selector = this.selector +
17548 '[data-target="' + target + '"],' +
17549 this.selector + '[href="' + target + '"]'
17550
17551 var active = $(selector)
17552 .parents('li')
17553 .addClass('active')
17554
17555 if (active.parent('.dropdown-menu').length) {
17556 active = active
17557 .closest('li.dropdown')
17558 .addClass('active')
17559 }
17560
17561 active.trigger('activate.bs.scrollspy')
17562 }
17563
17564
17565 // SCROLLSPY PLUGIN DEFINITION
17566 // ===========================
17567
17568 function Plugin(option) {
17569 return this.each(function () {
17570 var $this = $(this)
17571 var data = $this.data('bs.scrollspy')
17572 var options = typeof option == 'object' && option
17573
17574 if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
17575 if (typeof option == 'string') data[option]()
17576 })
17577 }
17578
17579 var old = $.fn.scrollspy
17580
17581 $.fn.scrollspy = Plugin
17582 $.fn.scrollspy.Constructor = ScrollSpy
17583
17584
17585 // SCROLLSPY NO CONFLICT
17586 // =====================
17587
17588 $.fn.scrollspy.noConflict = function () {
17589 $.fn.scrollspy = old
17590 return this
17591 }
17592
17593
17594 // SCROLLSPY DATA-API
17595 // ==================
17596
17597 $(window).on('load.bs.scrollspy.data-api', function () {
17598 $('[data-spy="scroll"]').each(function () {
17599 var $spy = $(this)
17600 Plugin.call($spy, $spy.data())
17601 })
17602 })
17603
17604 }(jQuery);
17605
17606 /* ========================================================================
17607 * Bootstrap: tab.js v3.2.0
17608 * http://getbootstrap.com/javascript/#tabs
17609 * ========================================================================
17610 * Copyright 2011-2014 Twitter, Inc.
17611 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17612 * ======================================================================== */
17613
17614
17615 +function ($) {
17616 'use strict';
17617
17618 // TAB CLASS DEFINITION
17619 // ====================
17620
17621 var Tab = function (element) {
17622 this.element = $(element)
17623 }
17624
17625 Tab.VERSION = '3.2.0'
17626
17627 Tab.prototype.show = function () {
17628 var $this = this.element
17629 var $ul = $this.closest('ul:not(.dropdown-menu)')
17630 var selector = $this.data('target')
17631
17632 if (!selector) {
17633 selector = $this.attr('href')
17634 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
17635 }
17636
17637 if ($this.parent('li').hasClass('active')) return
17638
17639 var previous = $ul.find('.active:last a')[0]
17640 var e = $.Event('show.bs.tab', {
17641 relatedTarget: previous
17642 })
17643
17644 $this.trigger(e)
17645
17646 if (e.isDefaultPrevented()) return
17647
17648 var $target = $(selector)
17649
17650 this.activate($this.closest('li'), $ul)
17651 this.activate($target, $target.parent(), function () {
17652 $this.trigger({
17653 type: 'shown.bs.tab',
17654 relatedTarget: previous
17655 })
17656 })
17657 }
17658
17659 Tab.prototype.activate = function (element, container, callback) {
17660 var $active = container.find('> .active')
17661 var transition = callback
17662 && $.support.transition
17663 && $active.hasClass('fade')
17664
17665 function next() {
17666 $active
17667 .removeClass('active')
17668 .find('> .dropdown-menu > .active')
17669 .removeClass('active')
17670
17671 element.addClass('active')
17672
17673 if (transition) {
17674 element[0].offsetWidth // reflow for transition
17675 element.addClass('in')
17676 } else {
17677 element.removeClass('fade')
17678 }
17679
17680 if (element.parent('.dropdown-menu')) {
17681 element.closest('li.dropdown').addClass('active')
17682 }
17683
17684 callback && callback()
17685 }
17686
17687 transition ?
17688 $active
17689 .one('bsTransitionEnd', next)
17690 .emulateTransitionEnd(150) :
17691 next()
17692
17693 $active.removeClass('in')
17694 }
17695
17696
17697 // TAB PLUGIN DEFINITION
17698 // =====================
17699
17700 function Plugin(option) {
17701 return this.each(function () {
17702 var $this = $(this)
17703 var data = $this.data('bs.tab')
17704
17705 if (!data) $this.data('bs.tab', (data = new Tab(this)))
17706 if (typeof option == 'string') data[option]()
17707 })
17708 }
17709
17710 var old = $.fn.tab
17711
17712 $.fn.tab = Plugin
17713 $.fn.tab.Constructor = Tab
17714
17715
17716 // TAB NO CONFLICT
17717 // ===============
17718
17719 $.fn.tab.noConflict = function () {
17720 $.fn.tab = old
17721 return this
17722 }
17723
17724
17725 // TAB DATA-API
17726 // ============
17727
17728 $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
17729 e.preventDefault()
17730 Plugin.call($(this), 'show')
17731 })
17732
17733 }(jQuery);
17734
17735 /* ========================================================================
17736 * Bootstrap: affix.js v3.2.0
17737 * http://getbootstrap.com/javascript/#affix
17738 * ========================================================================
17739 * Copyright 2011-2014 Twitter, Inc.
17740 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17741 * ======================================================================== */
17742
17743
17744 +function ($) {
17745 'use strict';
17746
17747 // AFFIX CLASS DEFINITION
17748 // ======================
17749
17750 var Affix = function (element, options) {
17751 this.options = $.extend({}, Affix.DEFAULTS, options)
17752
17753 this.$target = $(this.options.target)
17754 .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
17755 .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
17756
17757 this.$element = $(element)
17758 this.affixed =
17759 this.unpin =
17760 this.pinnedOffset = null
17761
17762 this.checkPosition()
17763 }
17764
17765 Affix.VERSION = '3.2.0'
17766
17767 Affix.RESET = 'affix affix-top affix-bottom'
17768
17769 Affix.DEFAULTS = {
17770 offset: 0,
17771 target: window
17772 }
17773
17774 Affix.prototype.getPinnedOffset = function () {
17775 if (this.pinnedOffset) return this.pinnedOffset
17776 this.$element.removeClass(Affix.RESET).addClass('affix')
17777 var scrollTop = this.$target.scrollTop()
17778 var position = this.$element.offset()
17779 return (this.pinnedOffset = position.top - scrollTop)
17780 }
17781
17782 Affix.prototype.checkPositionWithEventLoop = function () {
17783 setTimeout($.proxy(this.checkPosition, this), 1)
17784 }
17785
17786 Affix.prototype.checkPosition = function () {
17787 if (!this.$element.is(':visible')) return
17788
17789 var scrollHeight = $(document).height()
17790 var scrollTop = this.$target.scrollTop()
17791 var position = this.$element.offset()
17792 var offset = this.options.offset
17793 var offsetTop = offset.top
17794 var offsetBottom = offset.bottom
17795
17796 if (typeof offset != 'object') offsetBottom = offsetTop = offset
17797 if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
17798 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
17799
17800 var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
17801 offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
17802 offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
17803
17804 if (this.affixed === affix) return
17805 if (this.unpin != null) this.$element.css('top', '')
17806
17807 var affixType = 'affix' + (affix ? '-' + affix : '')
17808 var e = $.Event(affixType + '.bs.affix')
17809
17810 this.$element.trigger(e)
17811
17812 if (e.isDefaultPrevented()) return
17813
17814 this.affixed = affix
17815 this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
17816
17817 this.$element
17818 .removeClass(Affix.RESET)
17819 .addClass(affixType)
17820 .trigger($.Event(affixType.replace('affix', 'affixed')))
17821
17822 if (affix == 'bottom') {
17823 this.$element.offset({
17824 top: scrollHeight - this.$element.height() - offsetBottom
17825 })
17826 }
17827 }
17828
17829
17830 // AFFIX PLUGIN DEFINITION
17831 // =======================
17832
17833 function Plugin(option) {
17834 return this.each(function () {
17835 var $this = $(this)
17836 var data = $this.data('bs.affix')
17837 var options = typeof option == 'object' && option
17838
17839 if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
17840 if (typeof option == 'string') data[option]()
17841 })
17842 }
17843
17844 var old = $.fn.affix
17845
17846 $.fn.affix = Plugin
17847 $.fn.affix.Constructor = Affix
17848
17849
17850 // AFFIX NO CONFLICT
17851 // =================
17852
17853 $.fn.affix.noConflict = function () {
17854 $.fn.affix = old
17855 return this
17856 }
17857
17858
17859 // AFFIX DATA-API
17860 // ==============
17861
17862 $(window).on('load', function () {
17863 $('[data-spy="affix"]').each(function () {
17864 var $spy = $(this)
17865 var data = $spy.data()
17866
17867 data.offset = data.offset || {}
17868
17869 if (data.offsetBottom) data.offset.bottom = data.offsetBottom
17870 if (data.offsetTop) data.offset.top = data.offsetTop
17871
17872 Plugin.call($spy, data)
17873 })
17874 })
17875
17876 }(jQuery);
17877 </script>
17878 <script>
17879 (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){
17880 var assert = _dereq_('assert')
17881
17882 module.exports = BigInteger
17883
17884 // JavaScript engine analysis
17885 var canary = 0xdeadbeefcafe;
17886 var j_lm = ((canary&0xffffff)==0xefcafe);
17887
17888 // (public) Constructor
17889 function BigInteger(a,b,c) {
17890 if (!(this instanceof BigInteger)) {
17891 return new BigInteger(a, b, c);
17892 }
17893
17894 if(a != null) {
17895 if("number" == typeof a) this.fromNumber(a,b,c);
17896 else if(b == null && "string" != typeof a) this.fromString(a,256);
17897 else this.fromString(a,b);
17898 }
17899 }
17900
17901 var proto = BigInteger.prototype;
17902
17903 // return new, unset BigInteger
17904 function nbi() { return new BigInteger(null); }
17905
17906 // Bits per digit
17907 var dbits;
17908
17909 // am: Compute w_j += (x*this_i), propagate carries,
17910 // c is initial carry, returns final carry.
17911 // c < 3*dvalue, x < 2*dvalue, this_i < dvalue
17912 // We need to select the fastest one that works in this environment.
17913
17914 // am1: use a single mult and divide to get the high bits,
17915 // max digit bits should be 26 because
17916 // max internal value = 2*dvalue^2-2*dvalue (< 2^53)
17917 function am1(i,x,w,j,c,n) {
17918 while(--n >= 0) {
17919 var v = x*this[i++]+w[j]+c;
17920 c = Math.floor(v/0x4000000);
17921 w[j++] = v&0x3ffffff;
17922 }
17923 return c;
17924 }
17925 // am2 avoids a big mult-and-extract completely.
17926 // Max digit bits should be <= 30 because we do bitwise ops
17927 // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
17928 function am2(i,x,w,j,c,n) {
17929 var xl = x&0x7fff, xh = x>>15;
17930 while(--n >= 0) {
17931 var l = this[i]&0x7fff;
17932 var h = this[i++]>>15;
17933 var m = xh*l+h*xl;
17934 l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff);
17935 c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);
17936 w[j++] = l&0x3fffffff;
17937 }
17938 return c;
17939 }
17940 // Alternately, set max digit bits to 28 since some
17941 // browsers slow down when dealing with 32-bit numbers.
17942 function am3(i,x,w,j,c,n) {
17943 var xl = x&0x3fff, xh = x>>14;
17944 while(--n >= 0) {
17945 var l = this[i]&0x3fff;
17946 var h = this[i++]>>14;
17947 var m = xh*l+h*xl;
17948 l = xl*l+((m&0x3fff)<<14)+w[j]+c;
17949 c = (l>>28)+(m>>14)+xh*h;
17950 w[j++] = l&0xfffffff;
17951 }
17952 return c;
17953 }
17954
17955 // wtf?
17956 BigInteger.prototype.am = am1;
17957 dbits = 26;
17958
17959 /*
17960 if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
17961 BigInteger.prototype.am = am2;
17962 dbits = 30;
17963 }
17964 else if(j_lm && (navigator.appName != "Netscape")) {
17965 BigInteger.prototype.am = am1;
17966 dbits = 26;
17967 }
17968 else { // Mozilla/Netscape seems to prefer am3
17969 BigInteger.prototype.am = am3;
17970 dbits = 28;
17971 }
17972 */
17973
17974 BigInteger.prototype.DB = dbits;
17975 BigInteger.prototype.DM = ((1<<dbits)-1);
17976 var DV = BigInteger.prototype.DV = (1<<dbits);
17977
17978 var BI_FP = 52;
17979 BigInteger.prototype.FV = Math.pow(2,BI_FP);
17980 BigInteger.prototype.F1 = BI_FP-dbits;
17981 BigInteger.prototype.F2 = 2*dbits-BI_FP;
17982
17983 // Digit conversions
17984 var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
17985 var BI_RC = new Array();
17986 var rr,vv;
17987 rr = "0".charCodeAt(0);
17988 for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
17989 rr = "a".charCodeAt(0);
17990 for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
17991 rr = "A".charCodeAt(0);
17992 for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
17993
17994 function int2char(n) { return BI_RM.charAt(n); }
17995 function intAt(s,i) {
17996 var c = BI_RC[s.charCodeAt(i)];
17997 return (c==null)?-1:c;
17998 }
17999
18000 // (protected) copy this to r
18001 function bnpCopyTo(r) {
18002 for(var i = this.t-1; i >= 0; --i) r[i] = this[i];
18003 r.t = this.t;
18004 r.s = this.s;
18005 }
18006
18007 // (protected) set from integer value x, -DV <= x < DV
18008 function bnpFromInt(x) {
18009 this.t = 1;
18010 this.s = (x<0)?-1:0;
18011 if(x > 0) this[0] = x;
18012 else if(x < -1) this[0] = x+DV;
18013 else this.t = 0;
18014 }
18015
18016 // return bigint initialized to value
18017 function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
18018
18019 // (protected) set from string and radix
18020 function bnpFromString(s,b) {
18021 var self = this;
18022
18023 var k;
18024 if(b == 16) k = 4;
18025 else if(b == 8) k = 3;
18026 else if(b == 256) k = 8; // byte array
18027 else if(b == 2) k = 1;
18028 else if(b == 32) k = 5;
18029 else if(b == 4) k = 2;
18030 else { self.fromRadix(s,b); return; }
18031 self.t = 0;
18032 self.s = 0;
18033 var i = s.length, mi = false, sh = 0;
18034 while(--i >= 0) {
18035 var x = (k==8)?s[i]&0xff:intAt(s,i);
18036 if(x < 0) {
18037 if(s.charAt(i) == "-") mi = true;
18038 continue;
18039 }
18040 mi = false;
18041 if(sh == 0)
18042 self[self.t++] = x;
18043 else if(sh+k > self.DB) {
18044 self[self.t-1] |= (x&((1<<(self.DB-sh))-1))<<sh;
18045 self[self.t++] = (x>>(self.DB-sh));
18046 }
18047 else
18048 self[self.t-1] |= x<<sh;
18049 sh += k;
18050 if(sh >= self.DB) sh -= self.DB;
18051 }
18052 if(k == 8 && (s[0]&0x80) != 0) {
18053 self.s = -1;
18054 if(sh > 0) self[self.t-1] |= ((1<<(self.DB-sh))-1)<<sh;
18055 }
18056 self.clamp();
18057 if(mi) BigInteger.ZERO.subTo(self,self);
18058 }
18059
18060 // (protected) clamp off excess high words
18061 function bnpClamp() {
18062 var c = this.s&this.DM;
18063 while(this.t > 0 && this[this.t-1] == c) --this.t;
18064 }
18065
18066 // (public) return string representation in given radix
18067 function bnToString(b) {
18068 var self = this;
18069 if(self.s < 0) return "-"+self.negate().toString(b);
18070 var k;
18071 if(b == 16) k = 4;
18072 else if(b == 8) k = 3;
18073 else if(b == 2) k = 1;
18074 else if(b == 32) k = 5;
18075 else if(b == 4) k = 2;
18076 else return self.toRadix(b);
18077 var km = (1<<k)-1, d, m = false, r = "", i = self.t;
18078 var p = self.DB-(i*self.DB)%k;
18079 if(i-- > 0) {
18080 if(p < self.DB && (d = self[i]>>p) > 0) { m = true; r = int2char(d); }
18081 while(i >= 0) {
18082 if(p < k) {
18083 d = (self[i]&((1<<p)-1))<<(k-p);
18084 d |= self[--i]>>(p+=self.DB-k);
18085 }
18086 else {
18087 d = (self[i]>>(p-=k))&km;
18088 if(p <= 0) { p += self.DB; --i; }
18089 }
18090 if(d > 0) m = true;
18091 if(m) r += int2char(d);
18092 }
18093 }
18094 return m?r:"0";
18095 }
18096
18097 // (public) -this
18098 function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
18099
18100 // (public) |this|
18101 function bnAbs() { return (this.s<0)?this.negate():this; }
18102
18103 // (public) return + if this > a, - if this < a, 0 if equal
18104 function bnCompareTo(a) {
18105 var r = this.s-a.s;
18106 if(r != 0) return r;
18107 var i = this.t;
18108 r = i-a.t;
18109 if(r != 0) return (this.s<0)?-r:r;
18110 while(--i >= 0) if((r=this[i]-a[i]) != 0) return r;
18111 return 0;
18112 }
18113
18114 // returns bit length of the integer x
18115 function nbits(x) {
18116 var r = 1, t;
18117 if((t=x>>>16) != 0) { x = t; r += 16; }
18118 if((t=x>>8) != 0) { x = t; r += 8; }
18119 if((t=x>>4) != 0) { x = t; r += 4; }
18120 if((t=x>>2) != 0) { x = t; r += 2; }
18121 if((t=x>>1) != 0) { x = t; r += 1; }
18122 return r;
18123 }
18124
18125 // (public) return the number of bits in "this"
18126 function bnBitLength() {
18127 if(this.t <= 0) return 0;
18128 return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM));
18129 }
18130
18131 // (protected) r = this << n*DB
18132 function bnpDLShiftTo(n,r) {
18133 var i;
18134 for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
18135 for(i = n-1; i >= 0; --i) r[i] = 0;
18136 r.t = this.t+n;
18137 r.s = this.s;
18138 }
18139
18140 // (protected) r = this >> n*DB
18141 function bnpDRShiftTo(n,r) {
18142 for(var i = n; i < this.t; ++i) r[i-n] = this[i];
18143 r.t = Math.max(this.t-n,0);
18144 r.s = this.s;
18145 }
18146
18147 // (protected) r = this << n
18148 function bnpLShiftTo(n,r) {
18149 var self = this;
18150 var bs = n%self.DB;
18151 var cbs = self.DB-bs;
18152 var bm = (1<<cbs)-1;
18153 var ds = Math.floor(n/self.DB), c = (self.s<<bs)&self.DM, i;
18154 for(i = self.t-1; i >= 0; --i) {
18155 r[i+ds+1] = (self[i]>>cbs)|c;
18156 c = (self[i]&bm)<<bs;
18157 }
18158 for(i = ds-1; i >= 0; --i) r[i] = 0;
18159 r[ds] = c;
18160 r.t = self.t+ds+1;
18161 r.s = self.s;
18162 r.clamp();
18163 }
18164
18165 // (protected) r = this >> n
18166 function bnpRShiftTo(n,r) {
18167 var self = this;
18168 r.s = self.s;
18169 var ds = Math.floor(n/self.DB);
18170 if(ds >= self.t) { r.t = 0; return; }
18171 var bs = n%self.DB;
18172 var cbs = self.DB-bs;
18173 var bm = (1<<bs)-1;
18174 r[0] = self[ds]>>bs;
18175 for(var i = ds+1; i < self.t; ++i) {
18176 r[i-ds-1] |= (self[i]&bm)<<cbs;
18177 r[i-ds] = self[i]>>bs;
18178 }
18179 if(bs > 0) r[self.t-ds-1] |= (self.s&bm)<<cbs;
18180 r.t = self.t-ds;
18181 r.clamp();
18182 }
18183
18184 // (protected) r = this - a
18185 function bnpSubTo(a,r) {
18186 var self = this;
18187 var i = 0, c = 0, m = Math.min(a.t,self.t);
18188 while(i < m) {
18189 c += self[i]-a[i];
18190 r[i++] = c&self.DM;
18191 c >>= self.DB;
18192 }
18193 if(a.t < self.t) {
18194 c -= a.s;
18195 while(i < self.t) {
18196 c += self[i];
18197 r[i++] = c&self.DM;
18198 c >>= self.DB;
18199 }
18200 c += self.s;
18201 }
18202 else {
18203 c += self.s;
18204 while(i < a.t) {
18205 c -= a[i];
18206 r[i++] = c&self.DM;
18207 c >>= self.DB;
18208 }
18209 c -= a.s;
18210 }
18211 r.s = (c<0)?-1:0;
18212 if(c < -1) r[i++] = self.DV+c;
18213 else if(c > 0) r[i++] = c;
18214 r.t = i;
18215 r.clamp();
18216 }
18217
18218 // (protected) r = this * a, r != this,a (HAC 14.12)
18219 // "this" should be the larger one if appropriate.
18220 function bnpMultiplyTo(a,r) {
18221 var x = this.abs(), y = a.abs();
18222 var i = x.t;
18223 r.t = i+y.t;
18224 while(--i >= 0) r[i] = 0;
18225 for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t);
18226 r.s = 0;
18227 r.clamp();
18228 if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
18229 }
18230
18231 // (protected) r = this^2, r != this (HAC 14.16)
18232 function bnpSquareTo(r) {
18233 var x = this.abs();
18234 var i = r.t = 2*x.t;
18235 while(--i >= 0) r[i] = 0;
18236 for(i = 0; i < x.t-1; ++i) {
18237 var c = x.am(i,x[i],r,2*i,0,1);
18238 if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {
18239 r[i+x.t] -= x.DV;
18240 r[i+x.t+1] = 1;
18241 }
18242 }
18243 if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1);
18244 r.s = 0;
18245 r.clamp();
18246 }
18247
18248 // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
18249 // r != q, this != m. q or r may be null.
18250 function bnpDivRemTo(m,q,r) {
18251 var self = this;
18252 var pm = m.abs();
18253 if(pm.t <= 0) return;
18254 var pt = self.abs();
18255 if(pt.t < pm.t) {
18256 if(q != null) q.fromInt(0);
18257 if(r != null) self.copyTo(r);
18258 return;
18259 }
18260 if(r == null) r = nbi();
18261 var y = nbi(), ts = self.s, ms = m.s;
18262 var nsh = self.DB-nbits(pm[pm.t-1]); // normalize modulus
18263 if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); }
18264 else { pm.copyTo(y); pt.copyTo(r); }
18265 var ys = y.t;
18266 var y0 = y[ys-1];
18267 if(y0 == 0) return;
18268 var yt = y0*(1<<self.F1)+((ys>1)?y[ys-2]>>self.F2:0);
18269 var d1 = self.FV/yt, d2 = (1<<self.F1)/yt, e = 1<<self.F2;
18270 var i = r.t, j = i-ys, t = (q==null)?nbi():q;
18271 y.dlShiftTo(j,t);
18272 if(r.compareTo(t) >= 0) {
18273 r[r.t++] = 1;
18274 r.subTo(t,r);
18275 }
18276 BigInteger.ONE.dlShiftTo(ys,t);
18277 t.subTo(y,y); // "negative" y so we can replace sub with am later
18278 while(y.t < ys) y[y.t++] = 0;
18279 while(--j >= 0) {
18280 // Estimate quotient digit
18281 var qd = (r[--i]==y0)?self.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);
18282 if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out
18283 y.dlShiftTo(j,t);
18284 r.subTo(t,r);
18285 while(r[i] < --qd) r.subTo(t,r);
18286 }
18287 }
18288 if(q != null) {
18289 r.drShiftTo(ys,q);
18290 if(ts != ms) BigInteger.ZERO.subTo(q,q);
18291 }
18292 r.t = ys;
18293 r.clamp();
18294 if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder
18295 if(ts < 0) BigInteger.ZERO.subTo(r,r);
18296 }
18297
18298 // (public) this mod a
18299 function bnMod(a) {
18300 var r = nbi();
18301 this.abs().divRemTo(a,null,r);
18302 if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);
18303 return r;
18304 }
18305
18306 // Modular reduction using "classic" algorithm
18307 function Classic(m) { this.m = m; }
18308 function cConvert(x) {
18309 if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
18310 else return x;
18311 }
18312 function cRevert(x) { return x; }
18313 function cReduce(x) { x.divRemTo(this.m,null,x); }
18314 function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18315 function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18316
18317 Classic.prototype.convert = cConvert;
18318 Classic.prototype.revert = cRevert;
18319 Classic.prototype.reduce = cReduce;
18320 Classic.prototype.mulTo = cMulTo;
18321 Classic.prototype.sqrTo = cSqrTo;
18322
18323 // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
18324 // justification:
18325 // xy == 1 (mod m)
18326 // xy = 1+km
18327 // xy(2-xy) = (1+km)(1-km)
18328 // x[y(2-xy)] = 1-k^2m^2
18329 // x[y(2-xy)] == 1 (mod m^2)
18330 // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
18331 // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
18332 // JS multiply "overflows" differently from C/C++, so care is needed here.
18333 function bnpInvDigit() {
18334 if(this.t < 1) return 0;
18335 var x = this[0];
18336 if((x&1) == 0) return 0;
18337 var y = x&3; // y == 1/x mod 2^2
18338 y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4
18339 y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8
18340 y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16
18341 // last step - calculate inverse mod DV directly;
18342 // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
18343 y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits
18344 // we really want the negative inverse, and -DV < y < DV
18345 return (y>0)?this.DV-y:-y;
18346 }
18347
18348 // Montgomery reduction
18349 function Montgomery(m) {
18350 this.m = m;
18351 this.mp = m.invDigit();
18352 this.mpl = this.mp&0x7fff;
18353 this.mph = this.mp>>15;
18354 this.um = (1<<(m.DB-15))-1;
18355 this.mt2 = 2*m.t;
18356 }
18357
18358 // xR mod m
18359 function montConvert(x) {
18360 var r = nbi();
18361 x.abs().dlShiftTo(this.m.t,r);
18362 r.divRemTo(this.m,null,r);
18363 if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);
18364 return r;
18365 }
18366
18367 // x/R mod m
18368 function montRevert(x) {
18369 var r = nbi();
18370 x.copyTo(r);
18371 this.reduce(r);
18372 return r;
18373 }
18374
18375 // x = x/R mod m (HAC 14.32)
18376 function montReduce(x) {
18377 while(x.t <= this.mt2) // pad x so am has enough room later
18378 x[x.t++] = 0;
18379 for(var i = 0; i < this.m.t; ++i) {
18380 // faster way of calculating u0 = x[i]*mp mod DV
18381 var j = x[i]&0x7fff;
18382 var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM;
18383 // use am to combine the multiply-shift-add into one call
18384 j = i+this.m.t;
18385 x[j] += this.m.am(0,u0,x,i,0,this.m.t);
18386 // propagate carry
18387 while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
18388 }
18389 x.clamp();
18390 x.drShiftTo(this.m.t,x);
18391 if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
18392 }
18393
18394 // r = "x^2/R mod m"; x != r
18395 function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18396
18397 // r = "xy/R mod m"; x,y != r
18398 function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18399
18400 Montgomery.prototype.convert = montConvert;
18401 Montgomery.prototype.revert = montRevert;
18402 Montgomery.prototype.reduce = montReduce;
18403 Montgomery.prototype.mulTo = montMulTo;
18404 Montgomery.prototype.sqrTo = montSqrTo;
18405
18406 // (protected) true iff this is even
18407 function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
18408
18409 // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
18410 function bnpExp(e,z) {
18411 if(e > 0xffffffff || e < 1) return BigInteger.ONE;
18412 var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
18413 g.copyTo(r);
18414 while(--i >= 0) {
18415 z.sqrTo(r,r2);
18416 if((e&(1<<i)) > 0) z.mulTo(r2,g,r);
18417 else { var t = r; r = r2; r2 = t; }
18418 }
18419 return z.revert(r);
18420 }
18421
18422 // (public) this^e % m, 0 <= e < 2^32
18423 function bnModPowInt(e,m) {
18424 var z;
18425 if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
18426 return this.exp(e,z);
18427 }
18428
18429 // protected
18430 proto.copyTo = bnpCopyTo;
18431 proto.fromInt = bnpFromInt;
18432 proto.fromString = bnpFromString;
18433 proto.clamp = bnpClamp;
18434 proto.dlShiftTo = bnpDLShiftTo;
18435 proto.drShiftTo = bnpDRShiftTo;
18436 proto.lShiftTo = bnpLShiftTo;
18437 proto.rShiftTo = bnpRShiftTo;
18438 proto.subTo = bnpSubTo;
18439 proto.multiplyTo = bnpMultiplyTo;
18440 proto.squareTo = bnpSquareTo;
18441 proto.divRemTo = bnpDivRemTo;
18442 proto.invDigit = bnpInvDigit;
18443 proto.isEven = bnpIsEven;
18444 proto.exp = bnpExp;
18445
18446 // public
18447 proto.toString = bnToString;
18448 proto.negate = bnNegate;
18449 proto.abs = bnAbs;
18450 proto.compareTo = bnCompareTo;
18451 proto.bitLength = bnBitLength;
18452 proto.mod = bnMod;
18453 proto.modPowInt = bnModPowInt;
18454
18455 //// jsbn2
18456
18457 function nbi() { return new BigInteger(null); }
18458
18459 // (public)
18460 function bnClone() { var r = nbi(); this.copyTo(r); return r; }
18461
18462 // (public) return value as integer
18463 function bnIntValue() {
18464 if(this.s < 0) {
18465 if(this.t == 1) return this[0]-this.DV;
18466 else if(this.t == 0) return -1;
18467 }
18468 else if(this.t == 1) return this[0];
18469 else if(this.t == 0) return 0;
18470 // assumes 16 < DB < 32
18471 return ((this[1]&((1<<(32-this.DB))-1))<<this.DB)|this[0];
18472 }
18473
18474 // (public) return value as byte
18475 function bnByteValue() { return (this.t==0)?this.s:(this[0]<<24)>>24; }
18476
18477 // (public) return value as short (assumes DB>=16)
18478 function bnShortValue() { return (this.t==0)?this.s:(this[0]<<16)>>16; }
18479
18480 // (protected) return x s.t. r^x < DV
18481 function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }
18482
18483 // (public) 0 if this == 0, 1 if this > 0
18484 function bnSigNum() {
18485 if(this.s < 0) return -1;
18486 else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
18487 else return 1;
18488 }
18489
18490 // (protected) convert to radix string
18491 function bnpToRadix(b) {
18492 if(b == null) b = 10;
18493 if(this.signum() == 0 || b < 2 || b > 36) return "0";
18494 var cs = this.chunkSize(b);
18495 var a = Math.pow(b,cs);
18496 var d = nbv(a), y = nbi(), z = nbi(), r = "";
18497 this.divRemTo(d,y,z);
18498 while(y.signum() > 0) {
18499 r = (a+z.intValue()).toString(b).substr(1) + r;
18500 y.divRemTo(d,y,z);
18501 }
18502 return z.intValue().toString(b) + r;
18503 }
18504
18505 // (protected) convert from radix string
18506 function bnpFromRadix(s,b) {
18507 var self = this;
18508 self.fromInt(0);
18509 if(b == null) b = 10;
18510 var cs = self.chunkSize(b);
18511 var d = Math.pow(b,cs), mi = false, j = 0, w = 0;
18512 for(var i = 0; i < s.length; ++i) {
18513 var x = intAt(s,i);
18514 if(x < 0) {
18515 if(s.charAt(i) == "-" && self.signum() == 0) mi = true;
18516 continue;
18517 }
18518 w = b*w+x;
18519 if(++j >= cs) {
18520 self.dMultiply(d);
18521 self.dAddOffset(w,0);
18522 j = 0;
18523 w = 0;
18524 }
18525 }
18526 if(j > 0) {
18527 self.dMultiply(Math.pow(b,j));
18528 self.dAddOffset(w,0);
18529 }
18530 if(mi) BigInteger.ZERO.subTo(self,self);
18531 }
18532
18533 // (protected) alternate constructor
18534 function bnpFromNumber(a,b,c) {
18535 var self = this;
18536 if("number" == typeof b) {
18537 // new BigInteger(int,int,RNG)
18538 if(a < 2) self.fromInt(1);
18539 else {
18540 self.fromNumber(a,c);
18541 if(!self.testBit(a-1)) // force MSB set
18542 self.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,self);
18543 if(self.isEven()) self.dAddOffset(1,0); // force odd
18544 while(!self.isProbablePrime(b)) {
18545 self.dAddOffset(2,0);
18546 if(self.bitLength() > a) self.subTo(BigInteger.ONE.shiftLeft(a-1),self);
18547 }
18548 }
18549 }
18550 else {
18551 // new BigInteger(int,RNG)
18552 var x = new Array(), t = a&7;
18553 x.length = (a>>3)+1;
18554 b.nextBytes(x);
18555 if(t > 0) x[0] &= ((1<<t)-1); else x[0] = 0;
18556 self.fromString(x,256);
18557 }
18558 }
18559
18560 // (public) convert to bigendian byte array
18561 function bnToByteArray() {
18562 var self = this;
18563 var i = self.t, r = new Array();
18564 r[0] = self.s;
18565 var p = self.DB-(i*self.DB)%8, d, k = 0;
18566 if(i-- > 0) {
18567 if(p < self.DB && (d = self[i]>>p) != (self.s&self.DM)>>p)
18568 r[k++] = d|(self.s<<(self.DB-p));
18569 while(i >= 0) {
18570 if(p < 8) {
18571 d = (self[i]&((1<<p)-1))<<(8-p);
18572 d |= self[--i]>>(p+=self.DB-8);
18573 }
18574 else {
18575 d = (self[i]>>(p-=8))&0xff;
18576 if(p <= 0) { p += self.DB; --i; }
18577 }
18578 if((d&0x80) != 0) d |= -256;
18579 if(k === 0 && (self.s&0x80) != (d&0x80)) ++k;
18580 if(k > 0 || d != self.s) r[k++] = d;
18581 }
18582 }
18583 return r;
18584 }
18585
18586 function bnEquals(a) { return(this.compareTo(a)==0); }
18587 function bnMin(a) { return(this.compareTo(a)<0)?this:a; }
18588 function bnMax(a) { return(this.compareTo(a)>0)?this:a; }
18589
18590 // (protected) r = this op a (bitwise)
18591 function bnpBitwiseTo(a,op,r) {
18592 var self = this;
18593 var i, f, m = Math.min(a.t,self.t);
18594 for(i = 0; i < m; ++i) r[i] = op(self[i],a[i]);
18595 if(a.t < self.t) {
18596 f = a.s&self.DM;
18597 for(i = m; i < self.t; ++i) r[i] = op(self[i],f);
18598 r.t = self.t;
18599 }
18600 else {
18601 f = self.s&self.DM;
18602 for(i = m; i < a.t; ++i) r[i] = op(f,a[i]);
18603 r.t = a.t;
18604 }
18605 r.s = op(self.s,a.s);
18606 r.clamp();
18607 }
18608
18609 // (public) this & a
18610 function op_and(x,y) { return x&y; }
18611 function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
18612
18613 // (public) this | a
18614 function op_or(x,y) { return x|y; }
18615 function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
18616
18617 // (public) this ^ a
18618 function op_xor(x,y) { return x^y; }
18619 function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
18620
18621 // (public) this & ~a
18622 function op_andnot(x,y) { return x&~y; }
18623 function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
18624
18625 // (public) ~this
18626 function bnNot() {
18627 var r = nbi();
18628 for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i];
18629 r.t = this.t;
18630 r.s = ~this.s;
18631 return r;
18632 }
18633
18634 // (public) this << n
18635 function bnShiftLeft(n) {
18636 var r = nbi();
18637 if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
18638 return r;
18639 }
18640
18641 // (public) this >> n
18642 function bnShiftRight(n) {
18643 var r = nbi();
18644 if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
18645 return r;
18646 }
18647
18648 // return index of lowest 1-bit in x, x < 2^31
18649 function lbit(x) {
18650 if(x == 0) return -1;
18651 var r = 0;
18652 if((x&0xffff) == 0) { x >>= 16; r += 16; }
18653 if((x&0xff) == 0) { x >>= 8; r += 8; }
18654 if((x&0xf) == 0) { x >>= 4; r += 4; }
18655 if((x&3) == 0) { x >>= 2; r += 2; }
18656 if((x&1) == 0) ++r;
18657 return r;
18658 }
18659
18660 // (public) returns index of lowest 1-bit (or -1 if none)
18661 function bnGetLowestSetBit() {
18662 for(var i = 0; i < this.t; ++i)
18663 if(this[i] != 0) return i*this.DB+lbit(this[i]);
18664 if(this.s < 0) return this.t*this.DB;
18665 return -1;
18666 }
18667
18668 // return number of 1 bits in x
18669 function cbit(x) {
18670 var r = 0;
18671 while(x != 0) { x &= x-1; ++r; }
18672 return r;
18673 }
18674
18675 // (public) return number of set bits
18676 function bnBitCount() {
18677 var r = 0, x = this.s&this.DM;
18678 for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x);
18679 return r;
18680 }
18681
18682 // (public) true iff nth bit is set
18683 function bnTestBit(n) {
18684 var j = Math.floor(n/this.DB);
18685 if(j >= this.t) return(this.s!=0);
18686 return((this[j]&(1<<(n%this.DB)))!=0);
18687 }
18688
18689 // (protected) this op (1<<n)
18690 function bnpChangeBit(n,op) {
18691 var r = BigInteger.ONE.shiftLeft(n);
18692 this.bitwiseTo(r,op,r);
18693 return r;
18694 }
18695
18696 // (public) this | (1<<n)
18697 function bnSetBit(n) { return this.changeBit(n,op_or); }
18698
18699 // (public) this & ~(1<<n)
18700 function bnClearBit(n) { return this.changeBit(n,op_andnot); }
18701
18702 // (public) this ^ (1<<n)
18703 function bnFlipBit(n) { return this.changeBit(n,op_xor); }
18704
18705 // (protected) r = this + a
18706 function bnpAddTo(a,r) {
18707 var self = this;
18708
18709 var i = 0, c = 0, m = Math.min(a.t,self.t);
18710 while(i < m) {
18711 c += self[i]+a[i];
18712 r[i++] = c&self.DM;
18713 c >>= self.DB;
18714 }
18715 if(a.t < self.t) {
18716 c += a.s;
18717 while(i < self.t) {
18718 c += self[i];
18719 r[i++] = c&self.DM;
18720 c >>= self.DB;
18721 }
18722 c += self.s;
18723 }
18724 else {
18725 c += self.s;
18726 while(i < a.t) {
18727 c += a[i];
18728 r[i++] = c&self.DM;
18729 c >>= self.DB;
18730 }
18731 c += a.s;
18732 }
18733 r.s = (c<0)?-1:0;
18734 if(c > 0) r[i++] = c;
18735 else if(c < -1) r[i++] = self.DV+c;
18736 r.t = i;
18737 r.clamp();
18738 }
18739
18740 // (public) this + a
18741 function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }
18742
18743 // (public) this - a
18744 function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }
18745
18746 // (public) this * a
18747 function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }
18748
18749 // (public) this^2
18750 function bnSquare() { var r = nbi(); this.squareTo(r); return r; }
18751
18752 // (public) this / a
18753 function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }
18754
18755 // (public) this % a
18756 function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }
18757
18758 // (public) [this/a,this%a]
18759 function bnDivideAndRemainder(a) {
18760 var q = nbi(), r = nbi();
18761 this.divRemTo(a,q,r);
18762 return new Array(q,r);
18763 }
18764
18765 // (protected) this *= n, this >= 0, 1 < n < DV
18766 function bnpDMultiply(n) {
18767 this[this.t] = this.am(0,n-1,this,0,0,this.t);
18768 ++this.t;
18769 this.clamp();
18770 }
18771
18772 // (protected) this += n << w words, this >= 0
18773 function bnpDAddOffset(n,w) {
18774 if(n == 0) return;
18775 while(this.t <= w) this[this.t++] = 0;
18776 this[w] += n;
18777 while(this[w] >= this.DV) {
18778 this[w] -= this.DV;
18779 if(++w >= this.t) this[this.t++] = 0;
18780 ++this[w];
18781 }
18782 }
18783
18784 // A "null" reducer
18785 function NullExp() {}
18786 function nNop(x) { return x; }
18787 function nMulTo(x,y,r) { x.multiplyTo(y,r); }
18788 function nSqrTo(x,r) { x.squareTo(r); }
18789
18790 NullExp.prototype.convert = nNop;
18791 NullExp.prototype.revert = nNop;
18792 NullExp.prototype.mulTo = nMulTo;
18793 NullExp.prototype.sqrTo = nSqrTo;
18794
18795 // (public) this^e
18796 function bnPow(e) { return this.exp(e,new NullExp()); }
18797
18798 // (protected) r = lower n words of "this * a", a.t <= n
18799 // "this" should be the larger one if appropriate.
18800 function bnpMultiplyLowerTo(a,n,r) {
18801 var i = Math.min(this.t+a.t,n);
18802 r.s = 0; // assumes a,this >= 0
18803 r.t = i;
18804 while(i > 0) r[--i] = 0;
18805 var j;
18806 for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(0,a[i],r,i,0,this.t);
18807 for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a[i],r,i,0,n-i);
18808 r.clamp();
18809 }
18810
18811 // (protected) r = "this * a" without lower n words, n > 0
18812 // "this" should be the larger one if appropriate.
18813 function bnpMultiplyUpperTo(a,n,r) {
18814 --n;
18815 var i = r.t = this.t+a.t-n;
18816 r.s = 0; // assumes a,this >= 0
18817 while(--i >= 0) r[i] = 0;
18818 for(i = Math.max(n-this.t,0); i < a.t; ++i)
18819 r[this.t+i-n] = this.am(n-i,a[i],r,0,0,this.t+i-n);
18820 r.clamp();
18821 r.drShiftTo(1,r);
18822 }
18823
18824 // Barrett modular reduction
18825 function Barrett(m) {
18826 // setup Barrett
18827 this.r2 = nbi();
18828 this.q3 = nbi();
18829 BigInteger.ONE.dlShiftTo(2*m.t,this.r2);
18830 this.mu = this.r2.divide(m);
18831 this.m = m;
18832 }
18833
18834 function barrettConvert(x) {
18835 if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m);
18836 else if(x.compareTo(this.m) < 0) return x;
18837 else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }
18838 }
18839
18840 function barrettRevert(x) { return x; }
18841
18842 // x = x mod m (HAC 14.42)
18843 function barrettReduce(x) {
18844 var self = this;
18845 x.drShiftTo(self.m.t-1,self.r2);
18846 if(x.t > self.m.t+1) { x.t = self.m.t+1; x.clamp(); }
18847 self.mu.multiplyUpperTo(self.r2,self.m.t+1,self.q3);
18848 self.m.multiplyLowerTo(self.q3,self.m.t+1,self.r2);
18849 while(x.compareTo(self.r2) < 0) x.dAddOffset(1,self.m.t+1);
18850 x.subTo(self.r2,x);
18851 while(x.compareTo(self.m) >= 0) x.subTo(self.m,x);
18852 }
18853
18854 // r = x^2 mod m; x != r
18855 function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18856
18857 // r = x*y mod m; x,y != r
18858 function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18859
18860 Barrett.prototype.convert = barrettConvert;
18861 Barrett.prototype.revert = barrettRevert;
18862 Barrett.prototype.reduce = barrettReduce;
18863 Barrett.prototype.mulTo = barrettMulTo;
18864 Barrett.prototype.sqrTo = barrettSqrTo;
18865
18866 // (public) this^e % m (HAC 14.85)
18867 function bnModPow(e,m) {
18868 var i = e.bitLength(), k, r = nbv(1), z;
18869 if(i <= 0) return r;
18870 else if(i < 18) k = 1;
18871 else if(i < 48) k = 3;
18872 else if(i < 144) k = 4;
18873 else if(i < 768) k = 5;
18874 else k = 6;
18875 if(i < 8)
18876 z = new Classic(m);
18877 else if(m.isEven())
18878 z = new Barrett(m);
18879 else
18880 z = new Montgomery(m);
18881
18882 // precomputation
18883 var g = new Array(), n = 3, k1 = k-1, km = (1<<k)-1;
18884 g[1] = z.convert(this);
18885 if(k > 1) {
18886 var g2 = nbi();
18887 z.sqrTo(g[1],g2);
18888 while(n <= km) {
18889 g[n] = nbi();
18890 z.mulTo(g2,g[n-2],g[n]);
18891 n += 2;
18892 }
18893 }
18894
18895 var j = e.t-1, w, is1 = true, r2 = nbi(), t;
18896 i = nbits(e[j])-1;
18897 while(j >= 0) {
18898 if(i >= k1) w = (e[j]>>(i-k1))&km;
18899 else {
18900 w = (e[j]&((1<<(i+1))-1))<<(k1-i);
18901 if(j > 0) w |= e[j-1]>>(this.DB+i-k1);
18902 }
18903
18904 n = k;
18905 while((w&1) == 0) { w >>= 1; --n; }
18906 if((i -= n) < 0) { i += this.DB; --j; }
18907 if(is1) { // ret == 1, don't bother squaring or multiplying it
18908 g[w].copyTo(r);
18909 is1 = false;
18910 }
18911 else {
18912 while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; }
18913 if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }
18914 z.mulTo(r2,g[w],r);
18915 }
18916
18917 while(j >= 0 && (e[j]&(1<<i)) == 0) {
18918 z.sqrTo(r,r2); t = r; r = r2; r2 = t;
18919 if(--i < 0) { i = this.DB-1; --j; }
18920 }
18921 }
18922 return z.revert(r);
18923 }
18924
18925 // (public) gcd(this,a) (HAC 14.54)
18926 function bnGCD(a) {
18927 var x = (this.s<0)?this.negate():this.clone();
18928 var y = (a.s<0)?a.negate():a.clone();
18929 if(x.compareTo(y) < 0) { var t = x; x = y; y = t; }
18930 var i = x.getLowestSetBit(), g = y.getLowestSetBit();
18931 if(g < 0) return x;
18932 if(i < g) g = i;
18933 if(g > 0) {
18934 x.rShiftTo(g,x);
18935 y.rShiftTo(g,y);
18936 }
18937 while(x.signum() > 0) {
18938 if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x);
18939 if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y);
18940 if(x.compareTo(y) >= 0) {
18941 x.subTo(y,x);
18942 x.rShiftTo(1,x);
18943 }
18944 else {
18945 y.subTo(x,y);
18946 y.rShiftTo(1,y);
18947 }
18948 }
18949 if(g > 0) y.lShiftTo(g,y);
18950 return y;
18951 }
18952
18953 // (protected) this % n, n < 2^26
18954 function bnpModInt(n) {
18955 if(n <= 0) return 0;
18956 var d = this.DV%n, r = (this.s<0)?n-1:0;
18957 if(this.t > 0)
18958 if(d == 0) r = this[0]%n;
18959 else for(var i = this.t-1; i >= 0; --i) r = (d*r+this[i])%n;
18960 return r;
18961 }
18962
18963 // (public) 1/this % m (HAC 14.61)
18964 function bnModInverse(m) {
18965 var ac = m.isEven();
18966 if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
18967 var u = m.clone(), v = this.clone();
18968 var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
18969 while(u.signum() != 0) {
18970 while(u.isEven()) {
18971 u.rShiftTo(1,u);
18972 if(ac) {
18973 if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }
18974 a.rShiftTo(1,a);
18975 }
18976 else if(!b.isEven()) b.subTo(m,b);
18977 b.rShiftTo(1,b);
18978 }
18979 while(v.isEven()) {
18980 v.rShiftTo(1,v);
18981 if(ac) {
18982 if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }
18983 c.rShiftTo(1,c);
18984 }
18985 else if(!d.isEven()) d.subTo(m,d);
18986 d.rShiftTo(1,d);
18987 }
18988 if(u.compareTo(v) >= 0) {
18989 u.subTo(v,u);
18990 if(ac) a.subTo(c,a);
18991 b.subTo(d,b);
18992 }
18993 else {
18994 v.subTo(u,v);
18995 if(ac) c.subTo(a,c);
18996 d.subTo(b,d);
18997 }
18998 }
18999 if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
19000 if(d.compareTo(m) >= 0) return d.subtract(m);
19001 if(d.signum() < 0) d.addTo(m,d); else return d;
19002 if(d.signum() < 0) return d.add(m); else return d;
19003 }
19004
19005 // protected
19006 proto.chunkSize = bnpChunkSize;
19007 proto.toRadix = bnpToRadix;
19008 proto.fromRadix = bnpFromRadix;
19009 proto.fromNumber = bnpFromNumber;
19010 proto.bitwiseTo = bnpBitwiseTo;
19011 proto.changeBit = bnpChangeBit;
19012 proto.addTo = bnpAddTo;
19013 proto.dMultiply = bnpDMultiply;
19014 proto.dAddOffset = bnpDAddOffset;
19015 proto.multiplyLowerTo = bnpMultiplyLowerTo;
19016 proto.multiplyUpperTo = bnpMultiplyUpperTo;
19017 proto.modInt = bnpModInt;
19018
19019 // public
19020 proto.clone = bnClone;
19021 proto.intValue = bnIntValue;
19022 proto.byteValue = bnByteValue;
19023 proto.shortValue = bnShortValue;
19024 proto.signum = bnSigNum;
19025 proto.toByteArray = bnToByteArray;
19026 proto.equals = bnEquals;
19027 proto.min = bnMin;
19028 proto.max = bnMax;
19029 proto.and = bnAnd;
19030 proto.or = bnOr;
19031 proto.xor = bnXor;
19032 proto.andNot = bnAndNot;
19033 proto.not = bnNot;
19034 proto.shiftLeft = bnShiftLeft;
19035 proto.shiftRight = bnShiftRight;
19036 proto.getLowestSetBit = bnGetLowestSetBit;
19037 proto.bitCount = bnBitCount;
19038 proto.testBit = bnTestBit;
19039 proto.setBit = bnSetBit;
19040 proto.clearBit = bnClearBit;
19041 proto.flipBit = bnFlipBit;
19042 proto.add = bnAdd;
19043 proto.subtract = bnSubtract;
19044 proto.multiply = bnMultiply;
19045 proto.divide = bnDivide;
19046 proto.remainder = bnRemainder;
19047 proto.divideAndRemainder = bnDivideAndRemainder;
19048 proto.modPow = bnModPow;
19049 proto.modInverse = bnModInverse;
19050 proto.pow = bnPow;
19051 proto.gcd = bnGCD;
19052
19053 // JSBN-specific extension
19054 proto.square = bnSquare;
19055
19056 // BigInteger interfaces not implemented in jsbn:
19057
19058 // BigInteger(int signum, byte[] magnitude)
19059 // double doubleValue()
19060 // float floatValue()
19061 // int hashCode()
19062 // long longValue()
19063 // static BigInteger valueOf(long val)
19064
19065 // "constants"
19066 BigInteger.ZERO = nbv(0);
19067 BigInteger.ONE = nbv(1);
19068 BigInteger.valueOf = nbv;
19069
19070 },{"assert":4}],2:[function(_dereq_,module,exports){
19071 (function (Buffer){
19072 // FIXME: Kind of a weird way to throw exceptions, consider removing
19073 var assert = _dereq_('assert')
19074 var BigInteger = _dereq_('./bigi')
19075
19076 /**
19077 * Turns a byte array into a big integer.
19078 *
19079 * This function will interpret a byte array as a big integer in big
19080 * endian notation.
19081 */
19082 BigInteger.fromByteArrayUnsigned = function(byteArray) {
19083 // BigInteger expects a DER integer conformant byte array
19084 if (byteArray[0] & 0x80) {
19085 return new BigInteger([0].concat(byteArray))
19086 }
19087
19088 return new BigInteger(byteArray)
19089 }
19090
19091 /**
19092 * Returns a byte array representation of the big integer.
19093 *
19094 * This returns the absolute of the contained value in big endian
19095 * form. A value of zero results in an empty array.
19096 */
19097 BigInteger.prototype.toByteArrayUnsigned = function() {
19098 var byteArray = this.toByteArray()
19099 return byteArray[0] === 0 ? byteArray.slice(1) : byteArray
19100 }
19101
19102 BigInteger.fromDERInteger = function(byteArray) {
19103 return new BigInteger(byteArray)
19104 }
19105
19106 /*
19107 * Converts BigInteger to a DER integer representation.
19108 *
19109 * The format for this value uses the most significant bit as a sign
19110 * bit. If the most significant bit is already set and the integer is
19111 * positive, a 0x00 is prepended.
19112 *
19113 * Examples:
19114 *
19115 * 0 => 0x00
19116 * 1 => 0x01
19117 * -1 => 0x81
19118 * 127 => 0x7f
19119 * -127 => 0xff
19120 * 128 => 0x0080
19121 * -128 => 0x80
19122 * 255 => 0x00ff
19123 * -255 => 0xff
19124 * 16300 => 0x3fac
19125 * -16300 => 0xbfac
19126 * 62300 => 0x00f35c
19127 * -62300 => 0xf35c
19128 */
19129 BigInteger.prototype.toDERInteger = BigInteger.prototype.toByteArray
19130
19131 BigInteger.fromBuffer = function(buffer) {
19132 // BigInteger expects a DER integer conformant byte array
19133 if (buffer[0] & 0x80) {
19134 var byteArray = Array.prototype.slice.call(buffer)
19135
19136 return new BigInteger([0].concat(byteArray))
19137 }
19138
19139 return new BigInteger(buffer)
19140 }
19141
19142 BigInteger.fromHex = function(hex) {
19143 if (hex === '') return BigInteger.ZERO
19144
19145 assert.equal(hex, hex.match(/^[A-Fa-f0-9]+/), 'Invalid hex string')
19146 assert.equal(hex.length % 2, 0, 'Incomplete hex')
19147 return new BigInteger(hex, 16)
19148 }
19149
19150 BigInteger.prototype.toBuffer = function(size) {
19151 var byteArray = this.toByteArrayUnsigned()
19152 var zeros = []
19153
19154 var padding = size - byteArray.length
19155 while (zeros.length < padding) zeros.push(0)
19156
19157 return new Buffer(zeros.concat(byteArray))
19158 }
19159
19160 BigInteger.prototype.toHex = function(size) {
19161 return this.toBuffer(size).toString('hex')
19162 }
19163
19164 }).call(this,_dereq_("buffer").Buffer)
19165 },{"./bigi":1,"assert":4,"buffer":8}],3:[function(_dereq_,module,exports){
19166 var BigInteger = _dereq_('./bigi')
19167
19168 //addons
19169 _dereq_('./convert')
19170
19171 module.exports = BigInteger
19172 },{"./bigi":1,"./convert":2}],4:[function(_dereq_,module,exports){
19173 // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
19174 //
19175 // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
19176 //
19177 // Originally from narwhal.js (http://narwhaljs.org)
19178 // Copyright (c) 2009 Thomas Robinson <280north.com>
19179 //
19180 // Permission is hereby granted, free of charge, to any person obtaining a copy
19181 // of this software and associated documentation files (the 'Software'), to
19182 // deal in the Software without restriction, including without limitation the
19183 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
19184 // sell copies of the Software, and to permit persons to whom the Software is
19185 // furnished to do so, subject to the following conditions:
19186 //
19187 // The above copyright notice and this permission notice shall be included in
19188 // all copies or substantial portions of the Software.
19189 //
19190 // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19191 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19192 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19193 // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19194 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19195 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19196
19197 // when used in node, this will actually load the util module we depend on
19198 // versus loading the builtin util module as happens otherwise
19199 // this is a bug in node module loading as far as I am concerned
19200 var util = _dereq_('util/');
19201
19202 var pSlice = Array.prototype.slice;
19203 var hasOwn = Object.prototype.hasOwnProperty;
19204
19205 // 1. The assert module provides functions that throw
19206 // AssertionError's when particular conditions are not met. The
19207 // assert module must conform to the following interface.
19208
19209 var assert = module.exports = ok;
19210
19211 // 2. The AssertionError is defined in assert.
19212 // new assert.AssertionError({ message: message,
19213 // actual: actual,
19214 // expected: expected })
19215
19216 assert.AssertionError = function AssertionError(options) {
19217 this.name = 'AssertionError';
19218 this.actual = options.actual;
19219 this.expected = options.expected;
19220 this.operator = options.operator;
19221 if (options.message) {
19222 this.message = options.message;
19223 this.generatedMessage = false;
19224 } else {
19225 this.message = getMessage(this);
19226 this.generatedMessage = true;
19227 }
19228 var stackStartFunction = options.stackStartFunction || fail;
19229
19230 if (Error.captureStackTrace) {
19231 Error.captureStackTrace(this, stackStartFunction);
19232 }
19233 else {
19234 // non v8 browsers so we can have a stacktrace
19235 var err = new Error();
19236 if (err.stack) {
19237 var out = err.stack;
19238
19239 // try to strip useless frames
19240 var fn_name = stackStartFunction.name;
19241 var idx = out.indexOf('\n' + fn_name);
19242 if (idx >= 0) {
19243 // once we have located the function frame
19244 // we need to strip out everything before it (and its line)
19245 var next_line = out.indexOf('\n', idx + 1);
19246 out = out.substring(next_line + 1);
19247 }
19248
19249 this.stack = out;
19250 }
19251 }
19252 };
19253
19254 // assert.AssertionError instanceof Error
19255 util.inherits(assert.AssertionError, Error);
19256
19257 function replacer(key, value) {
19258 if (util.isUndefined(value)) {
19259 return '' + value;
19260 }
19261 if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) {
19262 return value.toString();
19263 }
19264 if (util.isFunction(value) || util.isRegExp(value)) {
19265 return value.toString();
19266 }
19267 return value;
19268 }
19269
19270 function truncate(s, n) {
19271 if (util.isString(s)) {
19272 return s.length < n ? s : s.slice(0, n);
19273 } else {
19274 return s;
19275 }
19276 }
19277
19278 function getMessage(self) {
19279 return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
19280 self.operator + ' ' +
19281 truncate(JSON.stringify(self.expected, replacer), 128);
19282 }
19283
19284 // At present only the three keys mentioned above are used and
19285 // understood by the spec. Implementations or sub modules can pass
19286 // other keys to the AssertionError's constructor - they will be
19287 // ignored.
19288
19289 // 3. All of the following functions must throw an AssertionError
19290 // when a corresponding condition is not met, with a message that
19291 // may be undefined if not provided. All assertion methods provide
19292 // both the actual and expected values to the assertion error for
19293 // display purposes.
19294
19295 function fail(actual, expected, message, operator, stackStartFunction) {
19296 throw new assert.AssertionError({
19297 message: message,
19298 actual: actual,
19299 expected: expected,
19300 operator: operator,
19301 stackStartFunction: stackStartFunction
19302 });
19303 }
19304
19305 // EXTENSION! allows for well behaved errors defined elsewhere.
19306 assert.fail = fail;
19307
19308 // 4. Pure assertion tests whether a value is truthy, as determined
19309 // by !!guard.
19310 // assert.ok(guard, message_opt);
19311 // This statement is equivalent to assert.equal(true, !!guard,
19312 // message_opt);. To test strictly for the value true, use
19313 // assert.strictEqual(true, guard, message_opt);.
19314
19315 function ok(value, message) {
19316 if (!value) fail(value, true, message, '==', assert.ok);
19317 }
19318 assert.ok = ok;
19319
19320 // 5. The equality assertion tests shallow, coercive equality with
19321 // ==.
19322 // assert.equal(actual, expected, message_opt);
19323
19324 assert.equal = function equal(actual, expected, message) {
19325 if (actual != expected) fail(actual, expected, message, '==', assert.equal);
19326 };
19327
19328 // 6. The non-equality assertion tests for whether two objects are not equal
19329 // with != assert.notEqual(actual, expected, message_opt);
19330
19331 assert.notEqual = function notEqual(actual, expected, message) {
19332 if (actual == expected) {
19333 fail(actual, expected, message, '!=', assert.notEqual);
19334 }
19335 };
19336
19337 // 7. The equivalence assertion tests a deep equality relation.
19338 // assert.deepEqual(actual, expected, message_opt);
19339
19340 assert.deepEqual = function deepEqual(actual, expected, message) {
19341 if (!_deepEqual(actual, expected)) {
19342 fail(actual, expected, message, 'deepEqual', assert.deepEqual);
19343 }
19344 };
19345
19346 function _deepEqual(actual, expected) {
19347 // 7.1. All identical values are equivalent, as determined by ===.
19348 if (actual === expected) {
19349 return true;
19350
19351 } else if (util.isBuffer(actual) && util.isBuffer(expected)) {
19352 if (actual.length != expected.length) return false;
19353
19354 for (var i = 0; i < actual.length; i++) {
19355 if (actual[i] !== expected[i]) return false;
19356 }
19357
19358 return true;
19359
19360 // 7.2. If the expected value is a Date object, the actual value is
19361 // equivalent if it is also a Date object that refers to the same time.
19362 } else if (util.isDate(actual) && util.isDate(expected)) {
19363 return actual.getTime() === expected.getTime();
19364
19365 // 7.3 If the expected value is a RegExp object, the actual value is
19366 // equivalent if it is also a RegExp object with the same source and
19367 // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
19368 } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
19369 return actual.source === expected.source &&
19370 actual.global === expected.global &&
19371 actual.multiline === expected.multiline &&
19372 actual.lastIndex === expected.lastIndex &&
19373 actual.ignoreCase === expected.ignoreCase;
19374
19375 // 7.4. Other pairs that do not both pass typeof value == 'object',
19376 // equivalence is determined by ==.
19377 } else if (!util.isObject(actual) && !util.isObject(expected)) {
19378 return actual == expected;
19379
19380 // 7.5 For all other Object pairs, including Array objects, equivalence is
19381 // determined by having the same number of owned properties (as verified
19382 // with Object.prototype.hasOwnProperty.call), the same set of keys
19383 // (although not necessarily the same order), equivalent values for every
19384 // corresponding key, and an identical 'prototype' property. Note: this
19385 // accounts for both named and indexed properties on Arrays.
19386 } else {
19387 return objEquiv(actual, expected);
19388 }
19389 }
19390
19391 function isArguments(object) {
19392 return Object.prototype.toString.call(object) == '[object Arguments]';
19393 }
19394
19395 function objEquiv(a, b) {
19396 if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
19397 return false;
19398 // an identical 'prototype' property.
19399 if (a.prototype !== b.prototype) return false;
19400 //~~~I've managed to break Object.keys through screwy arguments passing.
19401 // Converting to array solves the problem.
19402 if (isArguments(a)) {
19403 if (!isArguments(b)) {
19404 return false;
19405 }
19406 a = pSlice.call(a);
19407 b = pSlice.call(b);
19408 return _deepEqual(a, b);
19409 }
19410 try {
19411 var ka = objectKeys(a),
19412 kb = objectKeys(b),
19413 key, i;
19414 } catch (e) {//happens when one is a string literal and the other isn't
19415 return false;
19416 }
19417 // having the same number of owned properties (keys incorporates
19418 // hasOwnProperty)
19419 if (ka.length != kb.length)
19420 return false;
19421 //the same set of keys (although not necessarily the same order),
19422 ka.sort();
19423 kb.sort();
19424 //~~~cheap key test
19425 for (i = ka.length - 1; i >= 0; i--) {
19426 if (ka[i] != kb[i])
19427 return false;
19428 }
19429 //equivalent values for every corresponding key, and
19430 //~~~possibly expensive deep test
19431 for (i = ka.length - 1; i >= 0; i--) {
19432 key = ka[i];
19433 if (!_deepEqual(a[key], b[key])) return false;
19434 }
19435 return true;
19436 }
19437
19438 // 8. The non-equivalence assertion tests for any deep inequality.
19439 // assert.notDeepEqual(actual, expected, message_opt);
19440
19441 assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
19442 if (_deepEqual(actual, expected)) {
19443 fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
19444 }
19445 };
19446
19447 // 9. The strict equality assertion tests strict equality, as determined by ===.
19448 // assert.strictEqual(actual, expected, message_opt);
19449
19450 assert.strictEqual = function strictEqual(actual, expected, message) {
19451 if (actual !== expected) {
19452 fail(actual, expected, message, '===', assert.strictEqual);
19453 }
19454 };
19455
19456 // 10. The strict non-equality assertion tests for strict inequality, as
19457 // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
19458
19459 assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
19460 if (actual === expected) {
19461 fail(actual, expected, message, '!==', assert.notStrictEqual);
19462 }
19463 };
19464
19465 function expectedException(actual, expected) {
19466 if (!actual || !expected) {
19467 return false;
19468 }
19469
19470 if (Object.prototype.toString.call(expected) == '[object RegExp]') {
19471 return expected.test(actual);
19472 } else if (actual instanceof expected) {
19473 return true;
19474 } else if (expected.call({}, actual) === true) {
19475 return true;
19476 }
19477
19478 return false;
19479 }
19480
19481 function _throws(shouldThrow, block, expected, message) {
19482 var actual;
19483
19484 if (util.isString(expected)) {
19485 message = expected;
19486 expected = null;
19487 }
19488
19489 try {
19490 block();
19491 } catch (e) {
19492 actual = e;
19493 }
19494
19495 message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
19496 (message ? ' ' + message : '.');
19497
19498 if (shouldThrow && !actual) {
19499 fail(actual, expected, 'Missing expected exception' + message);
19500 }
19501
19502 if (!shouldThrow && expectedException(actual, expected)) {
19503 fail(actual, expected, 'Got unwanted exception' + message);
19504 }
19505
19506 if ((shouldThrow && actual && expected &&
19507 !expectedException(actual, expected)) || (!shouldThrow && actual)) {
19508 throw actual;
19509 }
19510 }
19511
19512 // 11. Expected to throw an error:
19513 // assert.throws(block, Error_opt, message_opt);
19514
19515 assert.throws = function(block, /*optional*/error, /*optional*/message) {
19516 _throws.apply(this, [true].concat(pSlice.call(arguments)));
19517 };
19518
19519 // EXTENSION! This is annoying to write outside this module.
19520 assert.doesNotThrow = function(block, /*optional*/message) {
19521 _throws.apply(this, [false].concat(pSlice.call(arguments)));
19522 };
19523
19524 assert.ifError = function(err) { if (err) {throw err;}};
19525
19526 var objectKeys = Object.keys || function (obj) {
19527 var keys = [];
19528 for (var key in obj) {
19529 if (hasOwn.call(obj, key)) keys.push(key);
19530 }
19531 return keys;
19532 };
19533
19534 },{"util/":6}],5:[function(_dereq_,module,exports){
19535 module.exports = function isBuffer(arg) {
19536 return arg && typeof arg === 'object'
19537 && typeof arg.copy === 'function'
19538 && typeof arg.fill === 'function'
19539 && typeof arg.readUInt8 === 'function';
19540 }
19541 },{}],6:[function(_dereq_,module,exports){
19542 (function (process,global){
19543 // Copyright Joyent, Inc. and other Node contributors.
19544 //
19545 // Permission is hereby granted, free of charge, to any person obtaining a
19546 // copy of this software and associated documentation files (the
19547 // "Software"), to deal in the Software without restriction, including
19548 // without limitation the rights to use, copy, modify, merge, publish,
19549 // distribute, sublicense, and/or sell copies of the Software, and to permit
19550 // persons to whom the Software is furnished to do so, subject to the
19551 // following conditions:
19552 //
19553 // The above copyright notice and this permission notice shall be included
19554 // in all copies or substantial portions of the Software.
19555 //
19556 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19557 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19558 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
19559 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19560 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19561 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19562 // USE OR OTHER DEALINGS IN THE SOFTWARE.
19563
19564 var formatRegExp = /%[sdj%]/g;
19565 exports.format = function(f) {
19566 if (!isString(f)) {
19567 var objects = [];
19568 for (var i = 0; i < arguments.length; i++) {
19569 objects.push(inspect(arguments[i]));
19570 }
19571 return objects.join(' ');
19572 }
19573
19574 var i = 1;
19575 var args = arguments;
19576 var len = args.length;
19577 var str = String(f).replace(formatRegExp, function(x) {
19578 if (x === '%%') return '%';
19579 if (i >= len) return x;
19580 switch (x) {
19581 case '%s': return String(args[i++]);
19582 case '%d': return Number(args[i++]);
19583 case '%j':
19584 try {
19585 return JSON.stringify(args[i++]);
19586 } catch (_) {
19587 return '[Circular]';
19588 }
19589 default:
19590 return x;
19591 }
19592 });
19593 for (var x = args[i]; i < len; x = args[++i]) {
19594 if (isNull(x) || !isObject(x)) {
19595 str += ' ' + x;
19596 } else {
19597 str += ' ' + inspect(x);
19598 }
19599 }
19600 return str;
19601 };
19602
19603
19604 // Mark that a method should not be used.
19605 // Returns a modified function which warns once by default.
19606 // If --no-deprecation is set, then it is a no-op.
19607 exports.deprecate = function(fn, msg) {
19608 // Allow for deprecating things in the process of starting up.
19609 if (isUndefined(global.process)) {
19610 return function() {
19611 return exports.deprecate(fn, msg).apply(this, arguments);
19612 };
19613 }
19614
19615 if (process.noDeprecation === true) {
19616 return fn;
19617 }
19618
19619 var warned = false;
19620 function deprecated() {
19621 if (!warned) {
19622 if (process.throwDeprecation) {
19623 throw new Error(msg);
19624 } else if (process.traceDeprecation) {
19625 console.trace(msg);
19626 } else {
19627 console.error(msg);
19628 }
19629 warned = true;
19630 }
19631 return fn.apply(this, arguments);
19632 }
19633
19634 return deprecated;
19635 };
19636
19637
19638 var debugs = {};
19639 var debugEnviron;
19640 exports.debuglog = function(set) {
19641 if (isUndefined(debugEnviron))
19642 debugEnviron = process.env.NODE_DEBUG || '';
19643 set = set.toUpperCase();
19644 if (!debugs[set]) {
19645 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
19646 var pid = process.pid;
19647 debugs[set] = function() {
19648 var msg = exports.format.apply(exports, arguments);
19649 console.error('%s %d: %s', set, pid, msg);
19650 };
19651 } else {
19652 debugs[set] = function() {};
19653 }
19654 }
19655 return debugs[set];
19656 };
19657
19658
19659 /**
19660 * Echos the value of a value. Trys to print the value out
19661 * in the best way possible given the different types.
19662 *
19663 * @param {Object} obj The object to print out.
19664 * @param {Object} opts Optional options object that alters the output.
19665 */
19666 /* legacy: obj, showHidden, depth, colors*/
19667 function inspect(obj, opts) {
19668 // default options
19669 var ctx = {
19670 seen: [],
19671 stylize: stylizeNoColor
19672 };
19673 // legacy...
19674 if (arguments.length >= 3) ctx.depth = arguments[2];
19675 if (arguments.length >= 4) ctx.colors = arguments[3];
19676 if (isBoolean(opts)) {
19677 // legacy...
19678 ctx.showHidden = opts;
19679 } else if (opts) {
19680 // got an "options" object
19681 exports._extend(ctx, opts);
19682 }
19683 // set default options
19684 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
19685 if (isUndefined(ctx.depth)) ctx.depth = 2;
19686 if (isUndefined(ctx.colors)) ctx.colors = false;
19687 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
19688 if (ctx.colors) ctx.stylize = stylizeWithColor;
19689 return formatValue(ctx, obj, ctx.depth);
19690 }
19691 exports.inspect = inspect;
19692
19693
19694 // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
19695 inspect.colors = {
19696 'bold' : [1, 22],
19697 'italic' : [3, 23],
19698 'underline' : [4, 24],
19699 'inverse' : [7, 27],
19700 'white' : [37, 39],
19701 'grey' : [90, 39],
19702 'black' : [30, 39],
19703 'blue' : [34, 39],
19704 'cyan' : [36, 39],
19705 'green' : [32, 39],
19706 'magenta' : [35, 39],
19707 'red' : [31, 39],
19708 'yellow' : [33, 39]
19709 };
19710
19711 // Don't use 'blue' not visible on cmd.exe
19712 inspect.styles = {
19713 'special': 'cyan',
19714 'number': 'yellow',
19715 'boolean': 'yellow',
19716 'undefined': 'grey',
19717 'null': 'bold',
19718 'string': 'green',
19719 'date': 'magenta',
19720 // "name": intentionally not styling
19721 'regexp': 'red'
19722 };
19723
19724
19725 function stylizeWithColor(str, styleType) {
19726 var style = inspect.styles[styleType];
19727
19728 if (style) {
19729 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
19730 '\u001b[' + inspect.colors[style][1] + 'm';
19731 } else {
19732 return str;
19733 }
19734 }
19735
19736
19737 function stylizeNoColor(str, styleType) {
19738 return str;
19739 }
19740
19741
19742 function arrayToHash(array) {
19743 var hash = {};
19744
19745 array.forEach(function(val, idx) {
19746 hash[val] = true;
19747 });
19748
19749 return hash;
19750 }
19751
19752
19753 function formatValue(ctx, value, recurseTimes) {
19754 // Provide a hook for user-specified inspect functions.
19755 // Check that value is an object with an inspect function on it
19756 if (ctx.customInspect &&
19757 value &&
19758 isFunction(value.inspect) &&
19759 // Filter out the util module, it's inspect function is special
19760 value.inspect !== exports.inspect &&
19761 // Also filter out any prototype objects using the circular check.
19762 !(value.constructor && value.constructor.prototype === value)) {
19763 var ret = value.inspect(recurseTimes, ctx);
19764 if (!isString(ret)) {
19765 ret = formatValue(ctx, ret, recurseTimes);
19766 }
19767 return ret;
19768 }
19769
19770 // Primitive types cannot have properties
19771 var primitive = formatPrimitive(ctx, value);
19772 if (primitive) {
19773 return primitive;
19774 }
19775
19776 // Look up the keys of the object.
19777 var keys = Object.keys(value);
19778 var visibleKeys = arrayToHash(keys);
19779
19780 if (ctx.showHidden) {
19781 keys = Object.getOwnPropertyNames(value);
19782 }
19783
19784 // IE doesn't make error fields non-enumerable
19785 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
19786 if (isError(value)
19787 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
19788 return formatError(value);
19789 }
19790
19791 // Some type of object without properties can be shortcutted.
19792 if (keys.length === 0) {
19793 if (isFunction(value)) {
19794 var name = value.name ? ': ' + value.name : '';
19795 return ctx.stylize('[Function' + name + ']', 'special');
19796 }
19797 if (isRegExp(value)) {
19798 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
19799 }
19800 if (isDate(value)) {
19801 return ctx.stylize(Date.prototype.toString.call(value), 'date');
19802 }
19803 if (isError(value)) {
19804 return formatError(value);
19805 }
19806 }
19807
19808 var base = '', array = false, braces = ['{', '}'];
19809
19810 // Make Array say that they are Array
19811 if (isArray(value)) {
19812 array = true;
19813 braces = ['[', ']'];
19814 }
19815
19816 // Make functions say that they are functions
19817 if (isFunction(value)) {
19818 var n = value.name ? ': ' + value.name : '';
19819 base = ' [Function' + n + ']';
19820 }
19821
19822 // Make RegExps say that they are RegExps
19823 if (isRegExp(value)) {
19824 base = ' ' + RegExp.prototype.toString.call(value);
19825 }
19826
19827 // Make dates with properties first say the date
19828 if (isDate(value)) {
19829 base = ' ' + Date.prototype.toUTCString.call(value);
19830 }
19831
19832 // Make error with message first say the error
19833 if (isError(value)) {
19834 base = ' ' + formatError(value);
19835 }
19836
19837 if (keys.length === 0 && (!array || value.length == 0)) {
19838 return braces[0] + base + braces[1];
19839 }
19840
19841 if (recurseTimes < 0) {
19842 if (isRegExp(value)) {
19843 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
19844 } else {
19845 return ctx.stylize('[Object]', 'special');
19846 }
19847 }
19848
19849 ctx.seen.push(value);
19850
19851 var output;
19852 if (array) {
19853 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
19854 } else {
19855 output = keys.map(function(key) {
19856 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
19857 });
19858 }
19859
19860 ctx.seen.pop();
19861
19862 return reduceToSingleString(output, base, braces);
19863 }
19864
19865
19866 function formatPrimitive(ctx, value) {
19867 if (isUndefined(value))
19868 return ctx.stylize('undefined', 'undefined');
19869 if (isString(value)) {
19870 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
19871 .replace(/'/g, "\\'")
19872 .replace(/\\"/g, '"') + '\'';
19873 return ctx.stylize(simple, 'string');
19874 }
19875 if (isNumber(value))
19876 return ctx.stylize('' + value, 'number');
19877 if (isBoolean(value))
19878 return ctx.stylize('' + value, 'boolean');
19879 // For some reason typeof null is "object", so special case here.
19880 if (isNull(value))
19881 return ctx.stylize('null', 'null');
19882 }
19883
19884
19885 function formatError(value) {
19886 return '[' + Error.prototype.toString.call(value) + ']';
19887 }
19888
19889
19890 function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
19891 var output = [];
19892 for (var i = 0, l = value.length; i < l; ++i) {
19893 if (hasOwnProperty(value, String(i))) {
19894 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
19895 String(i), true));
19896 } else {
19897 output.push('');
19898 }
19899 }
19900 keys.forEach(function(key) {
19901 if (!key.match(/^\d+$/)) {
19902 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
19903 key, true));
19904 }
19905 });
19906 return output;
19907 }
19908
19909
19910 function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
19911 var name, str, desc;
19912 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
19913 if (desc.get) {
19914 if (desc.set) {
19915 str = ctx.stylize('[Getter/Setter]', 'special');
19916 } else {
19917 str = ctx.stylize('[Getter]', 'special');
19918 }
19919 } else {
19920 if (desc.set) {
19921 str = ctx.stylize('[Setter]', 'special');
19922 }
19923 }
19924 if (!hasOwnProperty(visibleKeys, key)) {
19925 name = '[' + key + ']';
19926 }
19927 if (!str) {
19928 if (ctx.seen.indexOf(desc.value) < 0) {
19929 if (isNull(recurseTimes)) {
19930 str = formatValue(ctx, desc.value, null);
19931 } else {
19932 str = formatValue(ctx, desc.value, recurseTimes - 1);
19933 }
19934 if (str.indexOf('\n') > -1) {
19935 if (array) {
19936 str = str.split('\n').map(function(line) {
19937 return ' ' + line;
19938 }).join('\n').substr(2);
19939 } else {
19940 str = '\n' + str.split('\n').map(function(line) {
19941 return ' ' + line;
19942 }).join('\n');
19943 }
19944 }
19945 } else {
19946 str = ctx.stylize('[Circular]', 'special');
19947 }
19948 }
19949 if (isUndefined(name)) {
19950 if (array && key.match(/^\d+$/)) {
19951 return str;
19952 }
19953 name = JSON.stringify('' + key);
19954 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
19955 name = name.substr(1, name.length - 2);
19956 name = ctx.stylize(name, 'name');
19957 } else {
19958 name = name.replace(/'/g, "\\'")
19959 .replace(/\\"/g, '"')
19960 .replace(/(^"|"$)/g, "'");
19961 name = ctx.stylize(name, 'string');
19962 }
19963 }
19964
19965 return name + ': ' + str;
19966 }
19967
19968
19969 function reduceToSingleString(output, base, braces) {
19970 var numLinesEst = 0;
19971 var length = output.reduce(function(prev, cur) {
19972 numLinesEst++;
19973 if (cur.indexOf('\n') >= 0) numLinesEst++;
19974 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
19975 }, 0);
19976
19977 if (length > 60) {
19978 return braces[0] +
19979 (base === '' ? '' : base + '\n ') +
19980 ' ' +
19981 output.join(',\n ') +
19982 ' ' +
19983 braces[1];
19984 }
19985
19986 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
19987 }
19988
19989
19990 // NOTE: These type checking functions intentionally don't use `instanceof`
19991 // because it is fragile and can be easily faked with `Object.create()`.
19992 function isArray(ar) {
19993 return Array.isArray(ar);
19994 }
19995 exports.isArray = isArray;
19996
19997 function isBoolean(arg) {
19998 return typeof arg === 'boolean';
19999 }
20000 exports.isBoolean = isBoolean;
20001
20002 function isNull(arg) {
20003 return arg === null;
20004 }
20005 exports.isNull = isNull;
20006
20007 function isNullOrUndefined(arg) {
20008 return arg == null;
20009 }
20010 exports.isNullOrUndefined = isNullOrUndefined;
20011
20012 function isNumber(arg) {
20013 return typeof arg === 'number';
20014 }
20015 exports.isNumber = isNumber;
20016
20017 function isString(arg) {
20018 return typeof arg === 'string';
20019 }
20020 exports.isString = isString;
20021
20022 function isSymbol(arg) {
20023 return typeof arg === 'symbol';
20024 }
20025 exports.isSymbol = isSymbol;
20026
20027 function isUndefined(arg) {
20028 return arg === void 0;
20029 }
20030 exports.isUndefined = isUndefined;
20031
20032 function isRegExp(re) {
20033 return isObject(re) && objectToString(re) === '[object RegExp]';
20034 }
20035 exports.isRegExp = isRegExp;
20036
20037 function isObject(arg) {
20038 return typeof arg === 'object' && arg !== null;
20039 }
20040 exports.isObject = isObject;
20041
20042 function isDate(d) {
20043 return isObject(d) && objectToString(d) === '[object Date]';
20044 }
20045 exports.isDate = isDate;
20046
20047 function isError(e) {
20048 return isObject(e) &&
20049 (objectToString(e) === '[object Error]' || e instanceof Error);
20050 }
20051 exports.isError = isError;
20052
20053 function isFunction(arg) {
20054 return typeof arg === 'function';
20055 }
20056 exports.isFunction = isFunction;
20057
20058 function isPrimitive(arg) {
20059 return arg === null ||
20060 typeof arg === 'boolean' ||
20061 typeof arg === 'number' ||
20062 typeof arg === 'string' ||
20063 typeof arg === 'symbol' || // ES6 symbol
20064 typeof arg === 'undefined';
20065 }
20066 exports.isPrimitive = isPrimitive;
20067
20068 exports.isBuffer = _dereq_('./support/isBuffer');
20069
20070 function objectToString(o) {
20071 return Object.prototype.toString.call(o);
20072 }
20073
20074
20075 function pad(n) {
20076 return n < 10 ? '0' + n.toString(10) : n.toString(10);
20077 }
20078
20079
20080 var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
20081 'Oct', 'Nov', 'Dec'];
20082
20083 // 26 Feb 16:19:34
20084 function timestamp() {
20085 var d = new Date();
20086 var time = [pad(d.getHours()),
20087 pad(d.getMinutes()),
20088 pad(d.getSeconds())].join(':');
20089 return [d.getDate(), months[d.getMonth()], time].join(' ');
20090 }
20091
20092
20093 // log is just a thin wrapper to console.log that prepends a timestamp
20094 exports.log = function() {
20095 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
20096 };
20097
20098
20099 /**
20100 * Inherit the prototype methods from one constructor into another.
20101 *
20102 * The Function.prototype.inherits from lang.js rewritten as a standalone
20103 * function (not on Function.prototype). NOTE: If this file is to be loaded
20104 * during bootstrapping this function needs to be rewritten using some native
20105 * functions as prototype setup using normal JavaScript does not work as
20106 * expected during bootstrapping (see mirror.js in r114903).
20107 *
20108 * @param {function} ctor Constructor function which needs to inherit the
20109 * prototype.
20110 * @param {function} superCtor Constructor function to inherit prototype from.
20111 */
20112 exports.inherits = _dereq_('inherits');
20113
20114 exports._extend = function(origin, add) {
20115 // Don't do anything if add isn't an object
20116 if (!add || !isObject(add)) return origin;
20117
20118 var keys = Object.keys(add);
20119 var i = keys.length;
20120 while (i--) {
20121 origin[keys[i]] = add[keys[i]];
20122 }
20123 return origin;
20124 };
20125
20126 function hasOwnProperty(obj, prop) {
20127 return Object.prototype.hasOwnProperty.call(obj, prop);
20128 }
20129
20130 }).call(this,_dereq_("FWaASH"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
20131 },{"./support/isBuffer":5,"FWaASH":12,"inherits":11}],7:[function(_dereq_,module,exports){
20132
20133 },{}],8:[function(_dereq_,module,exports){
20134 /*!
20135 * The buffer module from node.js, for the browser.
20136 *
20137 * at author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
20138 * at license MIT
20139 */
20140
20141 var base64 = _dereq_('base64-js')
20142 var ieee754 = _dereq_('ieee754')
20143
20144 exports.Buffer = Buffer
20145 exports.SlowBuffer = Buffer
20146 exports.INSPECT_MAX_BYTES = 50
20147 Buffer.poolSize = 8192
20148
20149 /**
20150 * If `Buffer._useTypedArrays`:
20151 * === true Use Uint8Array implementation (fastest)
20152 * === false Use Object implementation (compatible down to IE6)
20153 */
20154 Buffer._useTypedArrays = (function () {
20155 // Detect if browser supports Typed Arrays. Supported browsers are IE 10+, Firefox 4+,
20156 // Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+. If the browser does not support adding
20157 // properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support
20158 // because we need to be able to add all the node Buffer API methods. This is an issue
20159 // in Firefox 4-29. Now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=695438
20160 try {
20161 var buf = new ArrayBuffer(0)
20162 var arr = new Uint8Array(buf)
20163 arr.foo = function () { return 42 }
20164 return 42 === arr.foo() &&
20165 typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray`
20166 } catch (e) {
20167 return false
20168 }
20169 })()
20170
20171 /**
20172 * Class: Buffer
20173 * =============
20174 *
20175 * The Buffer constructor returns instances of `Uint8Array` that are augmented
20176 * with function properties for all the node `Buffer` API functions. We use
20177 * `Uint8Array` so that square bracket notation works as expected -- it returns
20178 * a single octet.
20179 *
20180 * By augmenting the instances, we can avoid modifying the `Uint8Array`
20181 * prototype.
20182 */
20183 function Buffer (subject, encoding, noZero) {
20184 if (!(this instanceof Buffer))
20185 return new Buffer(subject, encoding, noZero)
20186
20187 var type = typeof subject
20188
20189 if (encoding === 'base64' && type === 'string') {
20190 subject = base64clean(subject)
20191 }
20192
20193 // Find the length
20194 var length
20195 if (type === 'number')
20196 length = coerce(subject)
20197 else if (type === 'string')
20198 length = Buffer.byteLength(subject, encoding)
20199 else if (type === 'object')
20200 length = coerce(subject.length) // assume that object is array-like
20201 else
20202 throw new Error('First argument needs to be a number, array or string.')
20203
20204 var buf
20205 if (Buffer._useTypedArrays) {
20206 // Preferred: Return an augmented `Uint8Array` instance for best performance
20207 buf = Buffer._augment(new Uint8Array(length))
20208 } else {
20209 // Fallback: Return THIS instance of Buffer (created by `new`)
20210 buf = this
20211 buf.length = length
20212 buf._isBuffer = true
20213 }
20214
20215 var i
20216 if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') {
20217 // Speed optimization -- use set if we're copying from a typed array
20218 buf._set(subject)
20219 } else if (isArrayish(subject)) {
20220 // Treat array-ish objects as a byte array
20221 if (Buffer.isBuffer(subject)) {
20222 for (i = 0; i < length; i++)
20223 buf[i] = subject.readUInt8(i)
20224 } else {
20225 for (i = 0; i < length; i++)
20226 buf[i] = ((subject[i] % 256) + 256) % 256
20227 }
20228 } else if (type === 'string') {
20229 buf.write(subject, 0, encoding)
20230 } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
20231 for (i = 0; i < length; i++) {
20232 buf[i] = 0
20233 }
20234 }
20235
20236 return buf
20237 }
20238
20239 // STATIC METHODS
20240 // ==============
20241
20242 Buffer.isEncoding = function (encoding) {
20243 switch (String(encoding).toLowerCase()) {
20244 case 'hex':
20245 case 'utf8':
20246 case 'utf-8':
20247 case 'ascii':
20248 case 'binary':
20249 case 'base64':
20250 case 'raw':
20251 case 'ucs2':
20252 case 'ucs-2':
20253 case 'utf16le':
20254 case 'utf-16le':
20255 return true
20256 default:
20257 return false
20258 }
20259 }
20260
20261 Buffer.isBuffer = function (b) {
20262 return !!(b !== null && b !== undefined && b._isBuffer)
20263 }
20264
20265 Buffer.byteLength = function (str, encoding) {
20266 var ret
20267 str = str.toString()
20268 switch (encoding || 'utf8') {
20269 case 'hex':
20270 ret = str.length / 2
20271 break
20272 case 'utf8':
20273 case 'utf-8':
20274 ret = utf8ToBytes(str).length
20275 break
20276 case 'ascii':
20277 case 'binary':
20278 case 'raw':
20279 ret = str.length
20280 break
20281 case 'base64':
20282 ret = base64ToBytes(str).length
20283 break
20284 case 'ucs2':
20285 case 'ucs-2':
20286 case 'utf16le':
20287 case 'utf-16le':
20288 ret = str.length * 2
20289 break
20290 default:
20291 throw new Error('Unknown encoding')
20292 }
20293 return ret
20294 }
20295
20296 Buffer.concat = function (list, totalLength) {
20297 assert(isArray(list), 'Usage: Buffer.concat(list[, length])')
20298
20299 if (list.length === 0) {
20300 return new Buffer(0)
20301 } else if (list.length === 1) {
20302 return list[0]
20303 }
20304
20305 var i
20306 if (totalLength === undefined) {
20307 totalLength = 0
20308 for (i = 0; i < list.length; i++) {
20309 totalLength += list[i].length
20310 }
20311 }
20312
20313 var buf = new Buffer(totalLength)
20314 var pos = 0
20315 for (i = 0; i < list.length; i++) {
20316 var item = list[i]
20317 item.copy(buf, pos)
20318 pos += item.length
20319 }
20320 return buf
20321 }
20322
20323 Buffer.compare = function (a, b) {
20324 assert(Buffer.isBuffer(a) && Buffer.isBuffer(b), 'Arguments must be Buffers')
20325 var x = a.length
20326 var y = b.length
20327 for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
20328 if (i !== len) {
20329 x = a[i]
20330 y = b[i]
20331 }
20332 if (x < y) {
20333 return -1
20334 }
20335 if (y < x) {
20336 return 1
20337 }
20338 return 0
20339 }
20340
20341 // BUFFER INSTANCE METHODS
20342 // =======================
20343
20344 function hexWrite (buf, string, offset, length) {
20345 offset = Number(offset) || 0
20346 var remaining = buf.length - offset
20347 if (!length) {
20348 length = remaining
20349 } else {
20350 length = Number(length)
20351 if (length > remaining) {
20352 length = remaining
20353 }
20354 }
20355
20356 // must be an even number of digits
20357 var strLen = string.length
20358 assert(strLen % 2 === 0, 'Invalid hex string')
20359
20360 if (length > strLen / 2) {
20361 length = strLen / 2
20362 }
20363 for (var i = 0; i < length; i++) {
20364 var byte = parseInt(string.substr(i * 2, 2), 16)
20365 assert(!isNaN(byte), 'Invalid hex string')
20366 buf[offset + i] = byte
20367 }
20368 return i
20369 }
20370
20371 function utf8Write (buf, string, offset, length) {
20372 var charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length)
20373 return charsWritten
20374 }
20375
20376 function asciiWrite (buf, string, offset, length) {
20377 var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length)
20378 return charsWritten
20379 }
20380
20381 function binaryWrite (buf, string, offset, length) {
20382 return asciiWrite(buf, string, offset, length)
20383 }
20384
20385 function base64Write (buf, string, offset, length) {
20386 var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length)
20387 return charsWritten
20388 }
20389
20390 function utf16leWrite (buf, string, offset, length) {
20391 var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length)
20392 return charsWritten
20393 }
20394
20395 Buffer.prototype.write = function (string, offset, length, encoding) {
20396 // Support both (string, offset, length, encoding)
20397 // and the legacy (string, encoding, offset, length)
20398 if (isFinite(offset)) {
20399 if (!isFinite(length)) {
20400 encoding = length
20401 length = undefined
20402 }
20403 } else { // legacy
20404 var swap = encoding
20405 encoding = offset
20406 offset = length
20407 length = swap
20408 }
20409
20410 offset = Number(offset) || 0
20411 var remaining = this.length - offset
20412 if (!length) {
20413 length = remaining
20414 } else {
20415 length = Number(length)
20416 if (length > remaining) {
20417 length = remaining
20418 }
20419 }
20420 encoding = String(encoding || 'utf8').toLowerCase()
20421
20422 var ret
20423 switch (encoding) {
20424 case 'hex':
20425 ret = hexWrite(this, string, offset, length)
20426 break
20427 case 'utf8':
20428 case 'utf-8':
20429 ret = utf8Write(this, string, offset, length)
20430 break
20431 case 'ascii':
20432 ret = asciiWrite(this, string, offset, length)
20433 break
20434 case 'binary':
20435 ret = binaryWrite(this, string, offset, length)
20436 break
20437 case 'base64':
20438 ret = base64Write(this, string, offset, length)
20439 break
20440 case 'ucs2':
20441 case 'ucs-2':
20442 case 'utf16le':
20443 case 'utf-16le':
20444 ret = utf16leWrite(this, string, offset, length)
20445 break
20446 default:
20447 throw new Error('Unknown encoding')
20448 }
20449 return ret
20450 }
20451
20452 Buffer.prototype.toString = function (encoding, start, end) {
20453 var self = this
20454
20455 encoding = String(encoding || 'utf8').toLowerCase()
20456 start = Number(start) || 0
20457 end = (end === undefined) ? self.length : Number(end)
20458
20459 // Fastpath empty strings
20460 if (end === start)
20461 return ''
20462
20463 var ret
20464 switch (encoding) {
20465 case 'hex':
20466 ret = hexSlice(self, start, end)
20467 break
20468 case 'utf8':
20469 case 'utf-8':
20470 ret = utf8Slice(self, start, end)
20471 break
20472 case 'ascii':
20473 ret = asciiSlice(self, start, end)
20474 break
20475 case 'binary':
20476 ret = binarySlice(self, start, end)
20477 break
20478 case 'base64':
20479 ret = base64Slice(self, start, end)
20480 break
20481 case 'ucs2':
20482 case 'ucs-2':
20483 case 'utf16le':
20484 case 'utf-16le':
20485 ret = utf16leSlice(self, start, end)
20486 break
20487 default:
20488 throw new Error('Unknown encoding')
20489 }
20490 return ret
20491 }
20492
20493 Buffer.prototype.toJSON = function () {
20494 return {
20495 type: 'Buffer',
20496 data: Array.prototype.slice.call(this._arr || this, 0)
20497 }
20498 }
20499
20500 Buffer.prototype.equals = function (b) {
20501 assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
20502 return Buffer.compare(this, b) === 0
20503 }
20504
20505 Buffer.prototype.compare = function (b) {
20506 assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
20507 return Buffer.compare(this, b)
20508 }
20509
20510 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
20511 Buffer.prototype.copy = function (target, target_start, start, end) {
20512 var source = this
20513
20514 if (!start) start = 0
20515 if (!end && end !== 0) end = this.length
20516 if (!target_start) target_start = 0
20517
20518 // Copy 0 bytes; we're done
20519 if (end === start) return
20520 if (target.length === 0 || source.length === 0) return
20521
20522 // Fatal error conditions
20523 assert(end >= start, 'sourceEnd < sourceStart')
20524 assert(target_start >= 0 && target_start < target.length,
20525 'targetStart out of bounds')
20526 assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
20527 assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
20528
20529 // Are we oob?
20530 if (end > this.length)
20531 end = this.length
20532 if (target.length - target_start < end - start)
20533 end = target.length - target_start + start
20534
20535 var len = end - start
20536
20537 if (len < 100 || !Buffer._useTypedArrays) {
20538 for (var i = 0; i < len; i++) {
20539 target[i + target_start] = this[i + start]
20540 }
20541 } else {
20542 target._set(this.subarray(start, start + len), target_start)
20543 }
20544 }
20545
20546 function base64Slice (buf, start, end) {
20547 if (start === 0 && end === buf.length) {
20548 return base64.fromByteArray(buf)
20549 } else {
20550 return base64.fromByteArray(buf.slice(start, end))
20551 }
20552 }
20553
20554 function utf8Slice (buf, start, end) {
20555 var res = ''
20556 var tmp = ''
20557 end = Math.min(buf.length, end)
20558
20559 for (var i = start; i < end; i++) {
20560 if (buf[i] <= 0x7F) {
20561 res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
20562 tmp = ''
20563 } else {
20564 tmp += '%' + buf[i].toString(16)
20565 }
20566 }
20567
20568 return res + decodeUtf8Char(tmp)
20569 }
20570
20571 function asciiSlice (buf, start, end) {
20572 var ret = ''
20573 end = Math.min(buf.length, end)
20574
20575 for (var i = start; i < end; i++) {
20576 ret += String.fromCharCode(buf[i])
20577 }
20578 return ret
20579 }
20580
20581 function binarySlice (buf, start, end) {
20582 return asciiSlice(buf, start, end)
20583 }
20584
20585 function hexSlice (buf, start, end) {
20586 var len = buf.length
20587
20588 if (!start || start < 0) start = 0
20589 if (!end || end < 0 || end > len) end = len
20590
20591 var out = ''
20592 for (var i = start; i < end; i++) {
20593 out += toHex(buf[i])
20594 }
20595 return out
20596 }
20597
20598 function utf16leSlice (buf, start, end) {
20599 var bytes = buf.slice(start, end)
20600 var res = ''
20601 for (var i = 0; i < bytes.length; i += 2) {
20602 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
20603 }
20604 return res
20605 }
20606
20607 Buffer.prototype.slice = function (start, end) {
20608 var len = this.length
20609 start = clamp(start, len, 0)
20610 end = clamp(end, len, len)
20611
20612 if (Buffer._useTypedArrays) {
20613 return Buffer._augment(this.subarray(start, end))
20614 } else {
20615 var sliceLen = end - start
20616 var newBuf = new Buffer(sliceLen, undefined, true)
20617 for (var i = 0; i < sliceLen; i++) {
20618 newBuf[i] = this[i + start]
20619 }
20620 return newBuf
20621 }
20622 }
20623
20624 // `get` will be removed in Node 0.13+
20625 Buffer.prototype.get = function (offset) {
20626 console.log('.get() is deprecated. Access using array indexes instead.')
20627 return this.readUInt8(offset)
20628 }
20629
20630 // `set` will be removed in Node 0.13+
20631 Buffer.prototype.set = function (v, offset) {
20632 console.log('.set() is deprecated. Access using array indexes instead.')
20633 return this.writeUInt8(v, offset)
20634 }
20635
20636 Buffer.prototype.readUInt8 = function (offset, noAssert) {
20637 if (!noAssert) {
20638 assert(offset !== undefined && offset !== null, 'missing offset')
20639 assert(offset < this.length, 'Trying to read beyond buffer length')
20640 }
20641
20642 if (offset >= this.length)
20643 return
20644
20645 return this[offset]
20646 }
20647
20648 function readUInt16 (buf, offset, littleEndian, noAssert) {
20649 if (!noAssert) {
20650 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20651 assert(offset !== undefined && offset !== null, 'missing offset')
20652 assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
20653 }
20654
20655 var len = buf.length
20656 if (offset >= len)
20657 return
20658
20659 var val
20660 if (littleEndian) {
20661 val = buf[offset]
20662 if (offset + 1 < len)
20663 val |= buf[offset + 1] << 8
20664 } else {
20665 val = buf[offset] << 8
20666 if (offset + 1 < len)
20667 val |= buf[offset + 1]
20668 }
20669 return val
20670 }
20671
20672 Buffer.prototype.readUInt16LE = function (offset, noAssert) {
20673 return readUInt16(this, offset, true, noAssert)
20674 }
20675
20676 Buffer.prototype.readUInt16BE = function (offset, noAssert) {
20677 return readUInt16(this, offset, false, noAssert)
20678 }
20679
20680 function readUInt32 (buf, offset, littleEndian, noAssert) {
20681 if (!noAssert) {
20682 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20683 assert(offset !== undefined && offset !== null, 'missing offset')
20684 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20685 }
20686
20687 var len = buf.length
20688 if (offset >= len)
20689 return
20690
20691 var val
20692 if (littleEndian) {
20693 if (offset + 2 < len)
20694 val = buf[offset + 2] << 16
20695 if (offset + 1 < len)
20696 val |= buf[offset + 1] << 8
20697 val |= buf[offset]
20698 if (offset + 3 < len)
20699 val = val + (buf[offset + 3] << 24 >>> 0)
20700 } else {
20701 if (offset + 1 < len)
20702 val = buf[offset + 1] << 16
20703 if (offset + 2 < len)
20704 val |= buf[offset + 2] << 8
20705 if (offset + 3 < len)
20706 val |= buf[offset + 3]
20707 val = val + (buf[offset] << 24 >>> 0)
20708 }
20709 return val
20710 }
20711
20712 Buffer.prototype.readUInt32LE = function (offset, noAssert) {
20713 return readUInt32(this, offset, true, noAssert)
20714 }
20715
20716 Buffer.prototype.readUInt32BE = function (offset, noAssert) {
20717 return readUInt32(this, offset, false, noAssert)
20718 }
20719
20720 Buffer.prototype.readInt8 = function (offset, noAssert) {
20721 if (!noAssert) {
20722 assert(offset !== undefined && offset !== null,
20723 'missing offset')
20724 assert(offset < this.length, 'Trying to read beyond buffer length')
20725 }
20726
20727 if (offset >= this.length)
20728 return
20729
20730 var neg = this[offset] & 0x80
20731 if (neg)
20732 return (0xff - this[offset] + 1) * -1
20733 else
20734 return this[offset]
20735 }
20736
20737 function readInt16 (buf, offset, littleEndian, noAssert) {
20738 if (!noAssert) {
20739 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20740 assert(offset !== undefined && offset !== null, 'missing offset')
20741 assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
20742 }
20743
20744 var len = buf.length
20745 if (offset >= len)
20746 return
20747
20748 var val = readUInt16(buf, offset, littleEndian, true)
20749 var neg = val & 0x8000
20750 if (neg)
20751 return (0xffff - val + 1) * -1
20752 else
20753 return val
20754 }
20755
20756 Buffer.prototype.readInt16LE = function (offset, noAssert) {
20757 return readInt16(this, offset, true, noAssert)
20758 }
20759
20760 Buffer.prototype.readInt16BE = function (offset, noAssert) {
20761 return readInt16(this, offset, false, noAssert)
20762 }
20763
20764 function readInt32 (buf, offset, littleEndian, noAssert) {
20765 if (!noAssert) {
20766 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20767 assert(offset !== undefined && offset !== null, 'missing offset')
20768 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20769 }
20770
20771 var len = buf.length
20772 if (offset >= len)
20773 return
20774
20775 var val = readUInt32(buf, offset, littleEndian, true)
20776 var neg = val & 0x80000000
20777 if (neg)
20778 return (0xffffffff - val + 1) * -1
20779 else
20780 return val
20781 }
20782
20783 Buffer.prototype.readInt32LE = function (offset, noAssert) {
20784 return readInt32(this, offset, true, noAssert)
20785 }
20786
20787 Buffer.prototype.readInt32BE = function (offset, noAssert) {
20788 return readInt32(this, offset, false, noAssert)
20789 }
20790
20791 function readFloat (buf, offset, littleEndian, noAssert) {
20792 if (!noAssert) {
20793 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20794 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20795 }
20796
20797 return ieee754.read(buf, offset, littleEndian, 23, 4)
20798 }
20799
20800 Buffer.prototype.readFloatLE = function (offset, noAssert) {
20801 return readFloat(this, offset, true, noAssert)
20802 }
20803
20804 Buffer.prototype.readFloatBE = function (offset, noAssert) {
20805 return readFloat(this, offset, false, noAssert)
20806 }
20807
20808 function readDouble (buf, offset, littleEndian, noAssert) {
20809 if (!noAssert) {
20810 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20811 assert(offset + 7 < buf.length, 'Trying to read beyond buffer length')
20812 }
20813
20814 return ieee754.read(buf, offset, littleEndian, 52, 8)
20815 }
20816
20817 Buffer.prototype.readDoubleLE = function (offset, noAssert) {
20818 return readDouble(this, offset, true, noAssert)
20819 }
20820
20821 Buffer.prototype.readDoubleBE = function (offset, noAssert) {
20822 return readDouble(this, offset, false, noAssert)
20823 }
20824
20825 Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
20826 if (!noAssert) {
20827 assert(value !== undefined && value !== null, 'missing value')
20828 assert(offset !== undefined && offset !== null, 'missing offset')
20829 assert(offset < this.length, 'trying to write beyond buffer length')
20830 verifuint(value, 0xff)
20831 }
20832
20833 if (offset >= this.length) return
20834
20835 this[offset] = value
20836 return offset + 1
20837 }
20838
20839 function writeUInt16 (buf, value, offset, littleEndian, noAssert) {
20840 if (!noAssert) {
20841 assert(value !== undefined && value !== null, 'missing value')
20842 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20843 assert(offset !== undefined && offset !== null, 'missing offset')
20844 assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
20845 verifuint(value, 0xffff)
20846 }
20847
20848 var len = buf.length
20849 if (offset >= len)
20850 return
20851
20852 for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) {
20853 buf[offset + i] =
20854 (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
20855 (littleEndian ? i : 1 - i) * 8
20856 }
20857 return offset + 2
20858 }
20859
20860 Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
20861 return writeUInt16(this, value, offset, true, noAssert)
20862 }
20863
20864 Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
20865 return writeUInt16(this, value, offset, false, noAssert)
20866 }
20867
20868 function writeUInt32 (buf, value, offset, littleEndian, noAssert) {
20869 if (!noAssert) {
20870 assert(value !== undefined && value !== null, 'missing value')
20871 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20872 assert(offset !== undefined && offset !== null, 'missing offset')
20873 assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
20874 verifuint(value, 0xffffffff)
20875 }
20876
20877 var len = buf.length
20878 if (offset >= len)
20879 return
20880
20881 for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) {
20882 buf[offset + i] =
20883 (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
20884 }
20885 return offset + 4
20886 }
20887
20888 Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
20889 return writeUInt32(this, value, offset, true, noAssert)
20890 }
20891
20892 Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
20893 return writeUInt32(this, value, offset, false, noAssert)
20894 }
20895
20896 Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
20897 if (!noAssert) {
20898 assert(value !== undefined && value !== null, 'missing value')
20899 assert(offset !== undefined && offset !== null, 'missing offset')
20900 assert(offset < this.length, 'Trying to write beyond buffer length')
20901 verifsint(value, 0x7f, -0x80)
20902 }
20903
20904 if (offset >= this.length)
20905 return
20906
20907 if (value >= 0)
20908 this.writeUInt8(value, offset, noAssert)
20909 else
20910 this.writeUInt8(0xff + value + 1, offset, noAssert)
20911 return offset + 1
20912 }
20913
20914 function writeInt16 (buf, value, offset, littleEndian, noAssert) {
20915 if (!noAssert) {
20916 assert(value !== undefined && value !== null, 'missing value')
20917 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20918 assert(offset !== undefined && offset !== null, 'missing offset')
20919 assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
20920 verifsint(value, 0x7fff, -0x8000)
20921 }
20922
20923 var len = buf.length
20924 if (offset >= len)
20925 return
20926
20927 if (value >= 0)
20928 writeUInt16(buf, value, offset, littleEndian, noAssert)
20929 else
20930 writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
20931 return offset + 2
20932 }
20933
20934 Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
20935 return writeInt16(this, value, offset, true, noAssert)
20936 }
20937
20938 Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
20939 return writeInt16(this, value, offset, false, noAssert)
20940 }
20941
20942 function writeInt32 (buf, value, offset, littleEndian, noAssert) {
20943 if (!noAssert) {
20944 assert(value !== undefined && value !== null, 'missing value')
20945 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20946 assert(offset !== undefined && offset !== null, 'missing offset')
20947 assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
20948 verifsint(value, 0x7fffffff, -0x80000000)
20949 }
20950
20951 var len = buf.length
20952 if (offset >= len)
20953 return
20954
20955 if (value >= 0)
20956 writeUInt32(buf, value, offset, littleEndian, noAssert)
20957 else
20958 writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert)
20959 return offset + 4
20960 }
20961
20962 Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
20963 return writeInt32(this, value, offset, true, noAssert)
20964 }
20965
20966 Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
20967 return writeInt32(this, value, offset, false, noAssert)
20968 }
20969
20970 function writeFloat (buf, value, offset, littleEndian, noAssert) {
20971 if (!noAssert) {
20972 assert(value !== undefined && value !== null, 'missing value')
20973 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20974 assert(offset !== undefined && offset !== null, 'missing offset')
20975 assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
20976 verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
20977 }
20978
20979 var len = buf.length
20980 if (offset >= len)
20981 return
20982
20983 ieee754.write(buf, value, offset, littleEndian, 23, 4)
20984 return offset + 4
20985 }
20986
20987 Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
20988 return writeFloat(this, value, offset, true, noAssert)
20989 }
20990
20991 Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
20992 return writeFloat(this, value, offset, false, noAssert)
20993 }
20994
20995 function writeDouble (buf, value, offset, littleEndian, noAssert) {
20996 if (!noAssert) {
20997 assert(value !== undefined && value !== null, 'missing value')
20998 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20999 assert(offset !== undefined && offset !== null, 'missing offset')
21000 assert(offset + 7 < buf.length,
21001 'Trying to write beyond buffer length')
21002 verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308)
21003 }
21004
21005 var len = buf.length
21006 if (offset >= len)
21007 return
21008
21009 ieee754.write(buf, value, offset, littleEndian, 52, 8)
21010 return offset + 8
21011 }
21012
21013 Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
21014 return writeDouble(this, value, offset, true, noAssert)
21015 }
21016
21017 Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
21018 return writeDouble(this, value, offset, false, noAssert)
21019 }
21020
21021 // fill(value, start=0, end=buffer.length)
21022 Buffer.prototype.fill = function (value, start, end) {
21023 if (!value) value = 0
21024 if (!start) start = 0
21025 if (!end) end = this.length
21026
21027 assert(end >= start, 'end < start')
21028
21029 // Fill 0 bytes; we're done
21030 if (end === start) return
21031 if (this.length === 0) return
21032
21033 assert(start >= 0 && start < this.length, 'start out of bounds')
21034 assert(end >= 0 && end <= this.length, 'end out of bounds')
21035
21036 var i
21037 if (typeof value === 'number') {
21038 for (i = start; i < end; i++) {
21039 this[i] = value
21040 }
21041 } else {
21042 var bytes = utf8ToBytes(value.toString())
21043 var len = bytes.length
21044 for (i = start; i < end; i++) {
21045 this[i] = bytes[i % len]
21046 }
21047 }
21048
21049 return this
21050 }
21051
21052 Buffer.prototype.inspect = function () {
21053 var out = []
21054 var len = this.length
21055 for (var i = 0; i < len; i++) {
21056 out[i] = toHex(this[i])
21057 if (i === exports.INSPECT_MAX_BYTES) {
21058 out[i + 1] = '...'
21059 break
21060 }
21061 }
21062 return '<Buffer ' + out.join(' ') + '>'
21063 }
21064
21065 /**
21066 * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
21067 * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
21068 */
21069 Buffer.prototype.toArrayBuffer = function () {
21070 if (typeof Uint8Array !== 'undefined') {
21071 if (Buffer._useTypedArrays) {
21072 return (new Buffer(this)).buffer
21073 } else {
21074 var buf = new Uint8Array(this.length)
21075 for (var i = 0, len = buf.length; i < len; i += 1) {
21076 buf[i] = this[i]
21077 }
21078 return buf.buffer
21079 }
21080 } else {
21081 throw new Error('Buffer.toArrayBuffer not supported in this browser')
21082 }
21083 }
21084
21085 // HELPER FUNCTIONS
21086 // ================
21087
21088 var BP = Buffer.prototype
21089
21090 /**
21091 * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
21092 */
21093 Buffer._augment = function (arr) {
21094 arr._isBuffer = true
21095
21096 // save reference to original Uint8Array get/set methods before overwriting
21097 arr._get = arr.get
21098 arr._set = arr.set
21099
21100 // deprecated, will be removed in node 0.13+
21101 arr.get = BP.get
21102 arr.set = BP.set
21103
21104 arr.write = BP.write
21105 arr.toString = BP.toString
21106 arr.toLocaleString = BP.toString
21107 arr.toJSON = BP.toJSON
21108 arr.equals = BP.equals
21109 arr.compare = BP.compare
21110 arr.copy = BP.copy
21111 arr.slice = BP.slice
21112 arr.readUInt8 = BP.readUInt8
21113 arr.readUInt16LE = BP.readUInt16LE
21114 arr.readUInt16BE = BP.readUInt16BE
21115 arr.readUInt32LE = BP.readUInt32LE
21116 arr.readUInt32BE = BP.readUInt32BE
21117 arr.readInt8 = BP.readInt8
21118 arr.readInt16LE = BP.readInt16LE
21119 arr.readInt16BE = BP.readInt16BE
21120 arr.readInt32LE = BP.readInt32LE
21121 arr.readInt32BE = BP.readInt32BE
21122 arr.readFloatLE = BP.readFloatLE
21123 arr.readFloatBE = BP.readFloatBE
21124 arr.readDoubleLE = BP.readDoubleLE
21125 arr.readDoubleBE = BP.readDoubleBE
21126 arr.writeUInt8 = BP.writeUInt8
21127 arr.writeUInt16LE = BP.writeUInt16LE
21128 arr.writeUInt16BE = BP.writeUInt16BE
21129 arr.writeUInt32LE = BP.writeUInt32LE
21130 arr.writeUInt32BE = BP.writeUInt32BE
21131 arr.writeInt8 = BP.writeInt8
21132 arr.writeInt16LE = BP.writeInt16LE
21133 arr.writeInt16BE = BP.writeInt16BE
21134 arr.writeInt32LE = BP.writeInt32LE
21135 arr.writeInt32BE = BP.writeInt32BE
21136 arr.writeFloatLE = BP.writeFloatLE
21137 arr.writeFloatBE = BP.writeFloatBE
21138 arr.writeDoubleLE = BP.writeDoubleLE
21139 arr.writeDoubleBE = BP.writeDoubleBE
21140 arr.fill = BP.fill
21141 arr.inspect = BP.inspect
21142 arr.toArrayBuffer = BP.toArrayBuffer
21143
21144 return arr
21145 }
21146
21147 var INVALID_BASE64_RE = /[^+\/0-9A-z]/g
21148
21149 function base64clean (str) {
21150 // Node strips out invalid characters like \n and \t from the string, base64-js does not
21151 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
21152 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
21153 while (str.length % 4 !== 0) {
21154 str = str + '='
21155 }
21156 return str
21157 }
21158
21159 function stringtrim (str) {
21160 if (str.trim) return str.trim()
21161 return str.replace(/^\s+|\s+$/g, '')
21162 }
21163
21164 // slice(start, end)
21165 function clamp (index, len, defaultValue) {
21166 if (typeof index !== 'number') return defaultValue
21167 index = ~~index; // Coerce to integer.
21168 if (index >= len) return len
21169 if (index >= 0) return index
21170 index += len
21171 if (index >= 0) return index
21172 return 0
21173 }
21174
21175 function coerce (length) {
21176 // Coerce length to a number (possibly NaN), round up
21177 // in case it's fractional (e.g. 123.456) then do a
21178 // double negate to coerce a NaN to 0. Easy, right?
21179 length = ~~Math.ceil(+length)
21180 return length < 0 ? 0 : length
21181 }
21182
21183 function isArray (subject) {
21184 return (Array.isArray || function (subject) {
21185 return Object.prototype.toString.call(subject) === '[object Array]'
21186 })(subject)
21187 }
21188
21189 function isArrayish (subject) {
21190 return isArray(subject) || Buffer.isBuffer(subject) ||
21191 subject && typeof subject === 'object' &&
21192 typeof subject.length === 'number'
21193 }
21194
21195 function toHex (n) {
21196 if (n < 16) return '0' + n.toString(16)
21197 return n.toString(16)
21198 }
21199
21200 function utf8ToBytes (str) {
21201 var byteArray = []
21202 for (var i = 0; i < str.length; i++) {
21203 var b = str.charCodeAt(i)
21204 if (b <= 0x7F) {
21205 byteArray.push(b)
21206 } else {
21207 var start = i
21208 if (b >= 0xD800 && b <= 0xDFFF) i++
21209 var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%')
21210 for (var j = 0; j < h.length; j++) {
21211 byteArray.push(parseInt(h[j], 16))
21212 }
21213 }
21214 }
21215 return byteArray
21216 }
21217
21218 function asciiToBytes (str) {
21219 var byteArray = []
21220 for (var i = 0; i < str.length; i++) {
21221 // Node's code seems to be doing this and not & 0x7F..
21222 byteArray.push(str.charCodeAt(i) & 0xFF)
21223 }
21224 return byteArray
21225 }
21226
21227 function utf16leToBytes (str) {
21228 var c, hi, lo
21229 var byteArray = []
21230 for (var i = 0; i < str.length; i++) {
21231 c = str.charCodeAt(i)
21232 hi = c >> 8
21233 lo = c % 256
21234 byteArray.push(lo)
21235 byteArray.push(hi)
21236 }
21237
21238 return byteArray
21239 }
21240
21241 function base64ToBytes (str) {
21242 return base64.toByteArray(str)
21243 }
21244
21245 function blitBuffer (src, dst, offset, length) {
21246 for (var i = 0; i < length; i++) {
21247 if ((i + offset >= dst.length) || (i >= src.length))
21248 break
21249 dst[i + offset] = src[i]
21250 }
21251 return i
21252 }
21253
21254 function decodeUtf8Char (str) {
21255 try {
21256 return decodeURIComponent(str)
21257 } catch (err) {
21258 return String.fromCharCode(0xFFFD) // UTF 8 invalid char
21259 }
21260 }
21261
21262 /*
21263 * We have to make sure that the value is a valid integer. This means that it
21264 * is non-negative. It has no fractional component and that it does not
21265 * exceed the maximum allowed value.
21266 */
21267 function verifuint (value, max) {
21268 assert(typeof value === 'number', 'cannot write a non-number as a number')
21269 assert(value >= 0, 'specified a negative value for writing an unsigned value')
21270 assert(value <= max, 'value is larger than maximum value for type')
21271 assert(Math.floor(value) === value, 'value has a fractional component')
21272 }
21273
21274 function verifsint (value, max, min) {
21275 assert(typeof value === 'number', 'cannot write a non-number as a number')
21276 assert(value <= max, 'value larger than maximum allowed value')
21277 assert(value >= min, 'value smaller than minimum allowed value')
21278 assert(Math.floor(value) === value, 'value has a fractional component')
21279 }
21280
21281 function verifIEEE754 (value, max, min) {
21282 assert(typeof value === 'number', 'cannot write a non-number as a number')
21283 assert(value <= max, 'value larger than maximum allowed value')
21284 assert(value >= min, 'value smaller than minimum allowed value')
21285 }
21286
21287 function assert (test, message) {
21288 if (!test) throw new Error(message || 'Failed assertion')
21289 }
21290
21291 },{"base64-js":9,"ieee754":10}],9:[function(_dereq_,module,exports){
21292 var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
21293
21294 ;(function (exports) {
21295 'use strict';
21296
21297 var Arr = (typeof Uint8Array !== 'undefined')
21298 ? Uint8Array
21299 : Array
21300
21301 var PLUS = '+'.charCodeAt(0)
21302 var SLASH = '/'.charCodeAt(0)
21303 var NUMBER = '0'.charCodeAt(0)
21304 var LOWER = 'a'.charCodeAt(0)
21305 var UPPER = 'A'.charCodeAt(0)
21306
21307 function decode (elt) {
21308 var code = elt.charCodeAt(0)
21309 if (code === PLUS)
21310 return 62 // '+'
21311 if (code === SLASH)
21312 return 63 // '/'
21313 if (code < NUMBER)
21314 return -1 //no match
21315 if (code < NUMBER + 10)
21316 return code - NUMBER + 26 + 26
21317 if (code < UPPER + 26)
21318 return code - UPPER
21319 if (code < LOWER + 26)
21320 return code - LOWER + 26
21321 }
21322
21323 function b64ToByteArray (b64) {
21324 var i, j, l, tmp, placeHolders, arr
21325
21326 if (b64.length % 4 > 0) {
21327 throw new Error('Invalid string. Length must be a multiple of 4')
21328 }
21329
21330 // the number of equal signs (place holders)
21331 // if there are two placeholders, than the two characters before it
21332 // represent one byte
21333 // if there is only one, then the three characters before it represent 2 bytes
21334 // this is just a cheap hack to not do indexOf twice
21335 var len = b64.length
21336 placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
21337
21338 // base64 is 4/3 + up to two characters of the original data
21339 arr = new Arr(b64.length * 3 / 4 - placeHolders)
21340
21341 // if there are placeholders, only get up to the last complete 4 chars
21342 l = placeHolders > 0 ? b64.length - 4 : b64.length
21343
21344 var L = 0
21345
21346 function push (v) {
21347 arr[L++] = v
21348 }
21349
21350 for (i = 0, j = 0; i < l; i += 4, j += 3) {
21351 tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
21352 push((tmp & 0xFF0000) >> 16)
21353 push((tmp & 0xFF00) >> 8)
21354 push(tmp & 0xFF)
21355 }
21356
21357 if (placeHolders === 2) {
21358 tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
21359 push(tmp & 0xFF)
21360 } else if (placeHolders === 1) {
21361 tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
21362 push((tmp >> 8) & 0xFF)
21363 push(tmp & 0xFF)
21364 }
21365
21366 return arr
21367 }
21368
21369 function uint8ToBase64 (uint8) {
21370 var i,
21371 extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
21372 output = "",
21373 temp, length
21374
21375 function encode (num) {
21376 return lookup.charAt(num)
21377 }
21378
21379 function tripletToBase64 (num) {
21380 return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
21381 }
21382
21383 // go through the array every three bytes, we'll deal with trailing stuff later
21384 for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
21385 temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
21386 output += tripletToBase64(temp)
21387 }
21388
21389 // pad the end with zeros, but make sure to not forget the extra bytes
21390 switch (extraBytes) {
21391 case 1:
21392 temp = uint8[uint8.length - 1]
21393 output += encode(temp >> 2)
21394 output += encode((temp << 4) & 0x3F)
21395 output += '=='
21396 break
21397 case 2:
21398 temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
21399 output += encode(temp >> 10)
21400 output += encode((temp >> 4) & 0x3F)
21401 output += encode((temp << 2) & 0x3F)
21402 output += '='
21403 break
21404 }
21405
21406 return output
21407 }
21408
21409 exports.toByteArray = b64ToByteArray
21410 exports.fromByteArray = uint8ToBase64
21411 }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
21412
21413 },{}],10:[function(_dereq_,module,exports){
21414 exports.read = function(buffer, offset, isLE, mLen, nBytes) {
21415 var e, m,
21416 eLen = nBytes * 8 - mLen - 1,
21417 eMax = (1 << eLen) - 1,
21418 eBias = eMax >> 1,
21419 nBits = -7,
21420 i = isLE ? (nBytes - 1) : 0,
21421 d = isLE ? -1 : 1,
21422 s = buffer[offset + i];
21423
21424 i += d;
21425
21426 e = s & ((1 << (-nBits)) - 1);
21427 s >>= (-nBits);
21428 nBits += eLen;
21429 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8){};
21430
21431 m = e & ((1 << (-nBits)) - 1);
21432 e >>= (-nBits);
21433 nBits += mLen;
21434 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8){};
21435
21436 if (e === 0) {
21437 e = 1 - eBias;
21438 } else if (e === eMax) {
21439 return m ? NaN : ((s ? -1 : 1) * Infinity);
21440 } else {
21441 m = m + Math.pow(2, mLen);
21442 e = e - eBias;
21443 }
21444 return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
21445 };
21446
21447 exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
21448 var e, m, c,
21449 eLen = nBytes * 8 - mLen - 1,
21450 eMax = (1 << eLen) - 1,
21451 eBias = eMax >> 1,
21452 rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
21453 i = isLE ? 0 : (nBytes - 1),
21454 d = isLE ? 1 : -1,
21455 s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
21456
21457 value = Math.abs(value);
21458
21459 if (isNaN(value) || value === Infinity) {
21460 m = isNaN(value) ? 1 : 0;
21461 e = eMax;
21462 } else {
21463 e = Math.floor(Math.log(value) / Math.LN2);
21464 if (value * (c = Math.pow(2, -e)) < 1) {
21465 e--;
21466 c *= 2;
21467 }
21468 if (e + eBias >= 1) {
21469 value += rt / c;
21470 } else {
21471 value += rt * Math.pow(2, 1 - eBias);
21472 }
21473 if (value * c >= 2) {
21474 e++;
21475 c /= 2;
21476 }
21477
21478 if (e + eBias >= eMax) {
21479 m = 0;
21480 e = eMax;
21481 } else if (e + eBias >= 1) {
21482 m = (value * c - 1) * Math.pow(2, mLen);
21483 e = e + eBias;
21484 } else {
21485 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
21486 e = 0;
21487 }
21488 }
21489
21490 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8){};
21491
21492 e = (e << mLen) | m;
21493 eLen += mLen;
21494 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8){};
21495
21496 buffer[offset + i - d] |= s * 128;
21497 };
21498
21499 },{}],11:[function(_dereq_,module,exports){
21500 if (typeof Object.create === 'function') {
21501 // implementation from standard node.js 'util' module
21502 module.exports = function inherits(ctor, superCtor) {
21503 ctor.super_ = superCtor
21504 ctor.prototype = Object.create(superCtor.prototype, {
21505 constructor: {
21506 value: ctor,
21507 enumerable: false,
21508 writable: true,
21509 configurable: true
21510 }
21511 });
21512 };
21513 } else {
21514 // old school shim for old browsers
21515 module.exports = function inherits(ctor, superCtor) {
21516 ctor.super_ = superCtor
21517 var TempCtor = function () {}
21518 TempCtor.prototype = superCtor.prototype
21519 ctor.prototype = new TempCtor()
21520 ctor.prototype.constructor = ctor
21521 }
21522 }
21523
21524 },{}],12:[function(_dereq_,module,exports){
21525 // shim for using process in browser
21526
21527 var process = module.exports = {};
21528
21529 process.nextTick = (function () {
21530 var canSetImmediate = typeof window !== 'undefined'
21531 && window.setImmediate;
21532 var canPost = typeof window !== 'undefined'
21533 && window.postMessage && window.addEventListener
21534 ;
21535
21536 if (canSetImmediate) {
21537 return function (f) { return window.setImmediate(f) };
21538 }
21539
21540 if (canPost) {
21541 var queue = [];
21542 window.addEventListener('message', function (ev) {
21543 var source = ev.source;
21544 if ((source === window || source === null) && ev.data === 'process-tick') {
21545 ev.stopPropagation();
21546 if (queue.length > 0) {
21547 var fn = queue.shift();
21548 fn();
21549 }
21550 }
21551 }, true);
21552
21553 return function nextTick(fn) {
21554 queue.push(fn);
21555 window.postMessage('process-tick', '*');
21556 };
21557 }
21558
21559 return function nextTick(fn) {
21560 setTimeout(fn, 0);
21561 };
21562 })();
21563
21564 process.title = 'browser';
21565 process.browser = true;
21566 process.env = {};
21567 process.argv = [];
21568
21569 function noop() {}
21570
21571 process.on = noop;
21572 process.addListener = noop;
21573 process.once = noop;
21574 process.off = noop;
21575 process.removeListener = noop;
21576 process.removeAllListeners = noop;
21577 process.emit = noop;
21578
21579 process.binding = function (name) {
21580 throw new Error('process.binding is not supported');
21581 }
21582
21583 // TODO(shtylman)
21584 process.cwd = function () { return '/' };
21585 process.chdir = function (dir) {
21586 throw new Error('process.chdir is not supported');
21587 };
21588
21589 },{}],13:[function(_dereq_,module,exports){
21590 module.exports=_dereq_(5)
21591 },{}],14:[function(_dereq_,module,exports){
21592 module.exports=_dereq_(6)
21593 },{"./support/isBuffer":13,"FWaASH":12,"inherits":11}],15:[function(_dereq_,module,exports){
21594 (function (Buffer){
21595 // Base58 encoding/decoding
21596 // Originally written by Mike Hearn for BitcoinJ
21597 // Copyright (c) 2011 Google Inc
21598 // Ported to JavaScript by Stefan Thomas
21599 // Merged Buffer refactorings from base58-native by Stephen Pair
21600 // Copyright (c) 2013 BitPay Inc
21601
21602 var assert = _dereq_('assert')
21603 var BigInteger = _dereq_('bigi')
21604
21605 var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
21606 var ALPHABET_BUF = new Buffer(ALPHABET, 'ascii')
21607 var ALPHABET_MAP = {}
21608 for(var i = 0; i < ALPHABET.length; i++) {
21609 ALPHABET_MAP[ALPHABET.charAt(i)] = BigInteger.valueOf(i)
21610 }
21611 var BASE = new BigInteger('58')
21612
21613 function encode(buffer) {
21614 var bi = BigInteger.fromBuffer(buffer)
21615 var result = new Buffer(buffer.length << 1)
21616
21617 var i = result.length - 1
21618 while (bi.signum() > 0) {
21619 var remainder = bi.mod(BASE)
21620 bi = bi.divide(BASE)
21621
21622 result[i] = ALPHABET_BUF[remainder.intValue()]
21623 i--
21624 }
21625
21626 // deal with leading zeros
21627 var j = 0
21628 while (buffer[j] === 0) {
21629 result[i] = ALPHABET_BUF[0]
21630 j++
21631 i--
21632 }
21633
21634 return result.slice(i + 1, result.length).toString('ascii')
21635 }
21636
21637 function decode(string) {
21638 if (string.length === 0) return new Buffer(0)
21639
21640 var num = BigInteger.ZERO
21641
21642 for (var i = 0; i < string.length; i++) {
21643 num = num.multiply(BASE)
21644
21645 var figure = ALPHABET_MAP[string.charAt(i)]
21646 assert.notEqual(figure, undefined, 'Non-base58 character')
21647
21648 num = num.add(figure)
21649 }
21650
21651 // deal with leading zeros
21652 var j = 0
21653 while ((j < string.length) && (string[j] === ALPHABET[0])) {
21654 j++
21655 }
21656
21657 var buffer = num.toBuffer()
21658 var leadingZeros = new Buffer(j)
21659 leadingZeros.fill(0)
21660
21661 return Buffer.concat([leadingZeros, buffer])
21662 }
21663
21664 module.exports = {
21665 encode: encode,
21666 decode: decode
21667 }
21668
21669 }).call(this,_dereq_("buffer").Buffer)
21670 },{"assert":4,"bigi":3,"buffer":8}],16:[function(_dereq_,module,exports){
21671 (function (Buffer){
21672 var createHash = _dereq_('sha.js')
21673
21674 var md5 = toConstructor(_dereq_('./md5'))
21675 var rmd160 = toConstructor(_dereq_('ripemd160'))
21676
21677 function toConstructor (fn) {
21678 return function () {
21679 var buffers = []
21680 var m= {
21681 update: function (data, enc) {
21682 if(!Buffer.isBuffer(data)) data = new Buffer(data, enc)
21683 buffers.push(data)
21684 return this
21685 },
21686 digest: function (enc) {
21687 var buf = Buffer.concat(buffers)
21688 var r = fn(buf)
21689 buffers = null
21690 return enc ? r.toString(enc) : r
21691 }
21692 }
21693 return m
21694 }
21695 }
21696
21697 module.exports = function (alg) {
21698 if('md5' === alg) return new md5()
21699 if('rmd160' === alg) return new rmd160()
21700 return createHash(alg)
21701 }
21702
21703 }).call(this,_dereq_("buffer").Buffer)
21704 },{"./md5":20,"buffer":8,"ripemd160":21,"sha.js":23}],17:[function(_dereq_,module,exports){
21705 (function (Buffer){
21706 var createHash = _dereq_('./create-hash')
21707
21708 var blocksize = 64
21709 var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(0)
21710
21711 module.exports = Hmac
21712
21713 function Hmac (alg, key) {
21714 if(!(this instanceof Hmac)) return new Hmac(alg, key)
21715 this._opad = opad
21716 this._alg = alg
21717
21718 key = this._key = !Buffer.isBuffer(key) ? new Buffer(key) : key
21719
21720 if(key.length > blocksize) {
21721 key = createHash(alg).update(key).digest()
21722 } else if(key.length < blocksize) {
21723 key = Buffer.concat([key, zeroBuffer], blocksize)
21724 }
21725
21726 var ipad = this._ipad = new Buffer(blocksize)
21727 var opad = this._opad = new Buffer(blocksize)
21728
21729 for(var i = 0; i < blocksize; i++) {
21730 ipad[i] = key[i] ^ 0x36
21731 opad[i] = key[i] ^ 0x5C
21732 }
21733
21734 this._hash = createHash(alg).update(ipad)
21735 }
21736
21737 Hmac.prototype.update = function (data, enc) {
21738 this._hash.update(data, enc)
21739 return this
21740 }
21741
21742 Hmac.prototype.digest = function (enc) {
21743 var h = this._hash.digest()
21744 return createHash(this._alg).update(this._opad).update(h).digest(enc)
21745 }
21746
21747
21748 }).call(this,_dereq_("buffer").Buffer)
21749 },{"./create-hash":16,"buffer":8}],18:[function(_dereq_,module,exports){
21750 (function (Buffer){
21751 var intSize = 4;
21752 var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(0);
21753 var chrsz = 8;
21754
21755 function toArray(buf, bigEndian) {
21756 if ((buf.length % intSize) !== 0) {
21757 var len = buf.length + (intSize - (buf.length % intSize));
21758 buf = Buffer.concat([buf, zeroBuffer], len);
21759 }
21760
21761 var arr = [];
21762 var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
21763 for (var i = 0; i < buf.length; i += intSize) {
21764 arr.push(fn.call(buf, i));
21765 }
21766 return arr;
21767 }
21768
21769 function toBuffer(arr, size, bigEndian) {
21770 var buf = new Buffer(size);
21771 var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
21772 for (var i = 0; i < arr.length; i++) {
21773 fn.call(buf, arr[i], i * 4, true);
21774 }
21775 return buf;
21776 }
21777
21778 function hash(buf, fn, hashSize, bigEndian) {
21779 if (!Buffer.isBuffer(buf)) buf = new Buffer(buf);
21780 var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
21781 return toBuffer(arr, hashSize, bigEndian);
21782 }
21783
21784 module.exports = { hash: hash };
21785
21786 }).call(this,_dereq_("buffer").Buffer)
21787 },{"buffer":8}],19:[function(_dereq_,module,exports){
21788 (function (Buffer){
21789 var rng = _dereq_('./rng')
21790
21791 function error () {
21792 var m = [].slice.call(arguments).join(' ')
21793 throw new Error([
21794 m,
21795 'we accept pull requests',
21796 'http://github.com/dominictarr/crypto-browserify'
21797 ].join('\n'))
21798 }
21799
21800 exports.createHash = _dereq_('./create-hash')
21801
21802 exports.createHmac = _dereq_('./create-hmac')
21803
21804 exports.randomBytes = function(size, callback) {
21805 if (callback && callback.call) {
21806 try {
21807 callback.call(this, undefined, new Buffer(rng(size)))
21808 } catch (err) { callback(err) }
21809 } else {
21810 return new Buffer(rng(size))
21811 }
21812 }
21813
21814 function each(a, f) {
21815 for(var i in a)
21816 f(a[i], i)
21817 }
21818
21819 exports.getHashes = function () {
21820 return ['sha1', 'sha256', 'md5', 'rmd160']
21821
21822 }
21823
21824 var p = _dereq_('./pbkdf2')(exports.createHmac)
21825 exports.pbkdf2 = p.pbkdf2
21826 exports.pbkdf2Sync = p.pbkdf2Sync
21827
21828
21829 // the least I can do is make error messages for the rest of the node.js/crypto api.
21830 each(['createCredentials'
21831 , 'createCipher'
21832 , 'createCipheriv'
21833 , 'createDecipher'
21834 , 'createDecipheriv'
21835 , 'createSign'
21836 , 'createVerify'
21837 , 'createDiffieHellman'
21838 ], function (name) {
21839 exports[name] = function () {
21840 error('sorry,', name, 'is not implemented yet')
21841 }
21842 })
21843
21844 }).call(this,_dereq_("buffer").Buffer)
21845 },{"./create-hash":16,"./create-hmac":17,"./pbkdf2":27,"./rng":28,"buffer":8}],20:[function(_dereq_,module,exports){
21846 /*
21847 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
21848 * Digest Algorithm, as defined in RFC 1321.
21849 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
21850 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
21851 * Distributed under the BSD License
21852 * See http://pajhome.org.uk/crypt/md5 for more info.
21853 */
21854
21855 var helpers = _dereq_('./helpers');
21856
21857 /*
21858 * Calculate the MD5 of an array of little-endian words, and a bit length
21859 */
21860 function core_md5(x, len)
21861 {
21862 /* append padding */
21863 x[len >> 5] |= 0x80 << ((len) % 32);
21864 x[(((len + 64) >>> 9) << 4) + 14] = len;
21865
21866 var a = 1732584193;
21867 var b = -271733879;
21868 var c = -1732584194;
21869 var d = 271733878;
21870
21871 for(var i = 0; i < x.length; i += 16)
21872 {
21873 var olda = a;
21874 var oldb = b;
21875 var oldc = c;
21876 var oldd = d;
21877
21878 a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
21879 d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
21880 c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
21881 b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
21882 a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
21883 d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
21884 c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
21885 b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
21886 a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
21887 d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
21888 c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
21889 b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
21890 a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
21891 d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
21892 c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
21893 b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
21894
21895 a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
21896 d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
21897 c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
21898 b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
21899 a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
21900 d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
21901 c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
21902 b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
21903 a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
21904 d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
21905 c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
21906 b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
21907 a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
21908 d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
21909 c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
21910 b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
21911
21912 a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
21913 d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
21914 c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
21915 b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
21916 a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
21917 d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
21918 c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
21919 b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
21920 a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
21921 d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
21922 c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
21923 b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
21924 a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
21925 d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
21926 c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
21927 b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
21928
21929 a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
21930 d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
21931 c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
21932 b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
21933 a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
21934 d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
21935 c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
21936 b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
21937 a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
21938 d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
21939 c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
21940 b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
21941 a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
21942 d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
21943 c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
21944 b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
21945
21946 a = safe_add(a, olda);
21947 b = safe_add(b, oldb);
21948 c = safe_add(c, oldc);
21949 d = safe_add(d, oldd);
21950 }
21951 return Array(a, b, c, d);
21952
21953 }
21954
21955 /*
21956 * These functions implement the four basic operations the algorithm uses.
21957 */
21958 function md5_cmn(q, a, b, x, s, t)
21959 {
21960 return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
21961 }
21962 function md5_ff(a, b, c, d, x, s, t)
21963 {
21964 return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
21965 }
21966 function md5_gg(a, b, c, d, x, s, t)
21967 {
21968 return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
21969 }
21970 function md5_hh(a, b, c, d, x, s, t)
21971 {
21972 return md5_cmn(b ^ c ^ d, a, b, x, s, t);
21973 }
21974 function md5_ii(a, b, c, d, x, s, t)
21975 {
21976 return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
21977 }
21978
21979 /*
21980 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
21981 * to work around bugs in some JS interpreters.
21982 */
21983 function safe_add(x, y)
21984 {
21985 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
21986 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
21987 return (msw << 16) | (lsw & 0xFFFF);
21988 }
21989
21990 /*
21991 * Bitwise rotate a 32-bit number to the left.
21992 */
21993 function bit_rol(num, cnt)
21994 {
21995 return (num << cnt) | (num >>> (32 - cnt));
21996 }
21997
21998 module.exports = function md5(buf) {
21999 return helpers.hash(buf, core_md5, 16);
22000 };
22001
22002 },{"./helpers":18}],21:[function(_dereq_,module,exports){
22003 (function (Buffer){
22004
22005 module.exports = ripemd160
22006
22007
22008
22009 /*
22010 CryptoJS v3.1.2
22011 code.google.com/p/crypto-js
22012 (c) 2009-2013 by Jeff Mott. All rights reserved.
22013 code.google.com/p/crypto-js/wiki/License
22014 */
22015 /** @preserve
22016 (c) 2012 by Cédric Mesnil. All rights reserved.
22017
22018 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
22019
22020 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
22021 - 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.
22022
22023 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.
22024 */
22025
22026 // Constants table
22027 var zl = [
22028 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
22029 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
22030 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
22031 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
22032 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13];
22033 var zr = [
22034 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
22035 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
22036 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
22037 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
22038 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11];
22039 var sl = [
22040 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
22041 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
22042 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
22043 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
22044 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ];
22045 var sr = [
22046 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
22047 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
22048 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
22049 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
22050 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ];
22051
22052 var hl = [ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E];
22053 var hr = [ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000];
22054
22055 var bytesToWords = function (bytes) {
22056 var words = [];
22057 for (var i = 0, b = 0; i < bytes.length; i++, b += 8) {
22058 words[b >>> 5] |= bytes[i] << (24 - b % 32);
22059 }
22060 return words;
22061 };
22062
22063 var wordsToBytes = function (words) {
22064 var bytes = [];
22065 for (var b = 0; b < words.length * 32; b += 8) {
22066 bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
22067 }
22068 return bytes;
22069 };
22070
22071 var processBlock = function (H, M, offset) {
22072
22073 // Swap endian
22074 for (var i = 0; i < 16; i++) {
22075 var offset_i = offset + i;
22076 var M_offset_i = M[offset_i];
22077
22078 // Swap
22079 M[offset_i] = (
22080 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
22081 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
22082 );
22083 }
22084
22085 // Working variables
22086 var al, bl, cl, dl, el;
22087 var ar, br, cr, dr, er;
22088
22089 ar = al = H[0];
22090 br = bl = H[1];
22091 cr = cl = H[2];
22092 dr = dl = H[3];
22093 er = el = H[4];
22094 // Computation
22095 var t;
22096 for (var i = 0; i < 80; i += 1) {
22097 t = (al + M[offset+zl[i]])|0;
22098 if (i<16){
22099 t += f1(bl,cl,dl) + hl[0];
22100 } else if (i<32) {
22101 t += f2(bl,cl,dl) + hl[1];
22102 } else if (i<48) {
22103 t += f3(bl,cl,dl) + hl[2];
22104 } else if (i<64) {
22105 t += f4(bl,cl,dl) + hl[3];
22106 } else {// if (i<80) {
22107 t += f5(bl,cl,dl) + hl[4];
22108 }
22109 t = t|0;
22110 t = rotl(t,sl[i]);
22111 t = (t+el)|0;
22112 al = el;
22113 el = dl;
22114 dl = rotl(cl, 10);
22115 cl = bl;
22116 bl = t;
22117
22118 t = (ar + M[offset+zr[i]])|0;
22119 if (i<16){
22120 t += f5(br,cr,dr) + hr[0];
22121 } else if (i<32) {
22122 t += f4(br,cr,dr) + hr[1];
22123 } else if (i<48) {
22124 t += f3(br,cr,dr) + hr[2];
22125 } else if (i<64) {
22126 t += f2(br,cr,dr) + hr[3];
22127 } else {// if (i<80) {
22128 t += f1(br,cr,dr) + hr[4];
22129 }
22130 t = t|0;
22131 t = rotl(t,sr[i]) ;
22132 t = (t+er)|0;
22133 ar = er;
22134 er = dr;
22135 dr = rotl(cr, 10);
22136 cr = br;
22137 br = t;
22138 }
22139 // Intermediate hash value
22140 t = (H[1] + cl + dr)|0;
22141 H[1] = (H[2] + dl + er)|0;
22142 H[2] = (H[3] + el + ar)|0;
22143 H[3] = (H[4] + al + br)|0;
22144 H[4] = (H[0] + bl + cr)|0;
22145 H[0] = t;
22146 };
22147
22148 function f1(x, y, z) {
22149 return ((x) ^ (y) ^ (z));
22150 }
22151
22152 function f2(x, y, z) {
22153 return (((x)&(y)) | ((~x)&(z)));
22154 }
22155
22156 function f3(x, y, z) {
22157 return (((x) | (~(y))) ^ (z));
22158 }
22159
22160 function f4(x, y, z) {
22161 return (((x) & (z)) | ((y)&(~(z))));
22162 }
22163
22164 function f5(x, y, z) {
22165 return ((x) ^ ((y) |(~(z))));
22166 }
22167
22168 function rotl(x,n) {
22169 return (x<<n) | (x>>>(32-n));
22170 }
22171
22172 function ripemd160(message) {
22173 var H = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];
22174
22175 if (typeof message == 'string')
22176 message = new Buffer(message, 'utf8');
22177
22178 var m = bytesToWords(message);
22179
22180 var nBitsLeft = message.length * 8;
22181 var nBitsTotal = message.length * 8;
22182
22183 // Add padding
22184 m[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
22185 m[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
22186 (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
22187 (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
22188 );
22189
22190 for (var i=0 ; i<m.length; i += 16) {
22191 processBlock(H, m, i);
22192 }
22193
22194 // Swap endian
22195 for (var i = 0; i < 5; i++) {
22196 // Shortcut
22197 var H_i = H[i];
22198
22199 // Swap
22200 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
22201 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
22202 }
22203
22204 var digestbytes = wordsToBytes(H);
22205 return new Buffer(digestbytes);
22206 }
22207
22208
22209
22210 }).call(this,_dereq_("buffer").Buffer)
22211 },{"buffer":8}],22:[function(_dereq_,module,exports){
22212 var u = _dereq_('./util')
22213 var write = u.write
22214 var fill = u.zeroFill
22215
22216 module.exports = function (Buffer) {
22217
22218 //prototype class for hash functions
22219 function Hash (blockSize, finalSize) {
22220 this._block = new Buffer(blockSize) //new Uint32Array(blockSize/4)
22221 this._finalSize = finalSize
22222 this._blockSize = blockSize
22223 this._len = 0
22224 this._s = 0
22225 }
22226
22227 Hash.prototype.init = function () {
22228 this._s = 0
22229 this._len = 0
22230 }
22231
22232 function lengthOf(data, enc) {
22233 if(enc == null) return data.byteLength || data.length
22234 if(enc == 'ascii' || enc == 'binary') return data.length
22235 if(enc == 'hex') return data.length/2
22236 if(enc == 'base64') return data.length/3
22237 }
22238
22239 Hash.prototype.update = function (data, enc) {
22240 var bl = this._blockSize
22241
22242 //I'd rather do this with a streaming encoder, like the opposite of
22243 //http://nodejs.org/api/string_decoder.html
22244 var length
22245 if(!enc && 'string' === typeof data)
22246 enc = 'utf8'
22247
22248 if(enc) {
22249 if(enc === 'utf-8')
22250 enc = 'utf8'
22251
22252 if(enc === 'base64' || enc === 'utf8')
22253 data = new Buffer(data, enc), enc = null
22254
22255 length = lengthOf(data, enc)
22256 } else
22257 length = data.byteLength || data.length
22258
22259 var l = this._len += length
22260 var s = this._s = (this._s || 0)
22261 var f = 0
22262 var buffer = this._block
22263 while(s < l) {
22264 var t = Math.min(length, f + bl)
22265 write(buffer, data, enc, s%bl, f, t)
22266 var ch = (t - f);
22267 s += ch; f += ch
22268
22269 if(!(s%bl))
22270 this._update(buffer)
22271 }
22272 this._s = s
22273
22274 return this
22275
22276 }
22277
22278 Hash.prototype.digest = function (enc) {
22279 var bl = this._blockSize
22280 var fl = this._finalSize
22281 var len = this._len*8
22282
22283 var x = this._block
22284
22285 var bits = len % (bl*8)
22286
22287 //add end marker, so that appending 0's creats a different hash.
22288 x[this._len % bl] = 0x80
22289 fill(this._block, this._len % bl + 1)
22290
22291 if(bits >= fl*8) {
22292 this._update(this._block)
22293 u.zeroFill(this._block, 0)
22294 }
22295
22296 //TODO: handle case where the bit length is > Math.pow(2, 29)
22297 x.writeInt32BE(len, fl + 4) //big endian
22298
22299 var hash = this._update(this._block) || this._hash()
22300 if(enc == null) return hash
22301 return hash.toString(enc)
22302 }
22303
22304 Hash.prototype._update = function () {
22305 throw new Error('_update must be implemented by subclass')
22306 }
22307
22308 return Hash
22309 }
22310
22311 },{"./util":26}],23:[function(_dereq_,module,exports){
22312 var exports = module.exports = function (alg) {
22313 var Alg = exports[alg]
22314 if(!Alg) throw new Error(alg + ' is not supported (we accept pull requests)')
22315 return new Alg()
22316 }
22317
22318 var Buffer = _dereq_('buffer').Buffer
22319 var Hash = _dereq_('./hash')(Buffer)
22320
22321 exports.sha =
22322 exports.sha1 = _dereq_('./sha1')(Buffer, Hash)
22323 exports.sha256 = _dereq_('./sha256')(Buffer, Hash)
22324
22325 },{"./hash":22,"./sha1":24,"./sha256":25,"buffer":8}],24:[function(_dereq_,module,exports){
22326 /*
22327 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
22328 * in FIPS PUB 180-1
22329 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
22330 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
22331 * Distributed under the BSD License
22332 * See http://pajhome.org.uk/crypt/md5 for details.
22333 */
22334 module.exports = function (Buffer, Hash) {
22335
22336 var inherits = _dereq_('util').inherits
22337
22338 inherits(Sha1, Hash)
22339
22340 var A = 0|0
22341 var B = 4|0
22342 var C = 8|0
22343 var D = 12|0
22344 var E = 16|0
22345
22346 var BE = false
22347 var LE = true
22348
22349 var W = new Int32Array(80)
22350
22351 var POOL = []
22352
22353 function Sha1 () {
22354 if(POOL.length)
22355 return POOL.pop().init()
22356
22357 if(!(this instanceof Sha1)) return new Sha1()
22358 this._w = W
22359 Hash.call(this, 16*4, 14*4)
22360
22361 this._h = null
22362 this.init()
22363 }
22364
22365 Sha1.prototype.init = function () {
22366 this._a = 0x67452301
22367 this._b = 0xefcdab89
22368 this._c = 0x98badcfe
22369 this._d = 0x10325476
22370 this._e = 0xc3d2e1f0
22371
22372 Hash.prototype.init.call(this)
22373 return this
22374 }
22375
22376 Sha1.prototype._POOL = POOL
22377
22378 // assume that array is a Uint32Array with length=16,
22379 // and that if it is the last block, it already has the length and the 1 bit appended.
22380
22381
22382 var isDV = new Buffer(1) instanceof DataView
22383 function readInt32BE (X, i) {
22384 return isDV
22385 ? X.getInt32(i, false)
22386 : X.readInt32BE(i)
22387 }
22388
22389 Sha1.prototype._update = function (array) {
22390
22391 var X = this._block
22392 var h = this._h
22393 var a, b, c, d, e, _a, _b, _c, _d, _e
22394
22395 a = _a = this._a
22396 b = _b = this._b
22397 c = _c = this._c
22398 d = _d = this._d
22399 e = _e = this._e
22400
22401 var w = this._w
22402
22403 for(var j = 0; j < 80; j++) {
22404 var W = w[j]
22405 = j < 16
22406 //? X.getInt32(j*4, false)
22407 //? readInt32BE(X, j*4) //*/ X.readInt32BE(j*4) //*/
22408 ? X.readInt32BE(j*4)
22409 : rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1)
22410
22411 var t =
22412 add(
22413 add(rol(a, 5), sha1_ft(j, b, c, d)),
22414 add(add(e, W), sha1_kt(j))
22415 );
22416
22417 e = d
22418 d = c
22419 c = rol(b, 30)
22420 b = a
22421 a = t
22422 }
22423
22424 this._a = add(a, _a)
22425 this._b = add(b, _b)
22426 this._c = add(c, _c)
22427 this._d = add(d, _d)
22428 this._e = add(e, _e)
22429 }
22430
22431 Sha1.prototype._hash = function () {
22432 if(POOL.length < 100) POOL.push(this)
22433 var H = new Buffer(20)
22434 //console.log(this._a|0, this._b|0, this._c|0, this._d|0, this._e|0)
22435 H.writeInt32BE(this._a|0, A)
22436 H.writeInt32BE(this._b|0, B)
22437 H.writeInt32BE(this._c|0, C)
22438 H.writeInt32BE(this._d|0, D)
22439 H.writeInt32BE(this._e|0, E)
22440 return H
22441 }
22442
22443 /*
22444 * Perform the appropriate triplet combination function for the current
22445 * iteration
22446 */
22447 function sha1_ft(t, b, c, d) {
22448 if(t < 20) return (b & c) | ((~b) & d);
22449 if(t < 40) return b ^ c ^ d;
22450 if(t < 60) return (b & c) | (b & d) | (c & d);
22451 return b ^ c ^ d;
22452 }
22453
22454 /*
22455 * Determine the appropriate additive constant for the current iteration
22456 */
22457 function sha1_kt(t) {
22458 return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
22459 (t < 60) ? -1894007588 : -899497514;
22460 }
22461
22462 /*
22463 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
22464 * to work around bugs in some JS interpreters.
22465 * //dominictarr: this is 10 years old, so maybe this can be dropped?)
22466 *
22467 */
22468 function add(x, y) {
22469 return (x + y ) | 0
22470 //lets see how this goes on testling.
22471 // var lsw = (x & 0xFFFF) + (y & 0xFFFF);
22472 // var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
22473 // return (msw << 16) | (lsw & 0xFFFF);
22474 }
22475
22476 /*
22477 * Bitwise rotate a 32-bit number to the left.
22478 */
22479 function rol(num, cnt) {
22480 return (num << cnt) | (num >>> (32 - cnt));
22481 }
22482
22483 return Sha1
22484 }
22485
22486 },{"util":14}],25:[function(_dereq_,module,exports){
22487
22488 /**
22489 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
22490 * in FIPS 180-2
22491 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
22492 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
22493 *
22494 */
22495
22496 var inherits = _dereq_('util').inherits
22497 var BE = false
22498 var LE = true
22499 var u = _dereq_('./util')
22500
22501 module.exports = function (Buffer, Hash) {
22502
22503 var K = [
22504 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
22505 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
22506 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
22507 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
22508 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
22509 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
22510 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
22511 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
22512 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
22513 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
22514 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
22515 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
22516 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
22517 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
22518 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
22519 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
22520 ]
22521
22522 inherits(Sha256, Hash)
22523 var W = new Array(64)
22524 var POOL = []
22525 function Sha256() {
22526 // Closure compiler warning - this code lacks side effects - thus commented out
22527 // if(POOL.length) {
22528 // return POOL.shift().init()
22529 // }
22530 //this._data = new Buffer(32)
22531
22532 this.init()
22533
22534 this._w = W //new Array(64)
22535
22536 Hash.call(this, 16*4, 14*4)
22537 };
22538
22539 Sha256.prototype.init = function () {
22540
22541 this._a = 0x6a09e667|0
22542 this._b = 0xbb67ae85|0
22543 this._c = 0x3c6ef372|0
22544 this._d = 0xa54ff53a|0
22545 this._e = 0x510e527f|0
22546 this._f = 0x9b05688c|0
22547 this._g = 0x1f83d9ab|0
22548 this._h = 0x5be0cd19|0
22549
22550 this._len = this._s = 0
22551
22552 return this
22553 }
22554
22555 var safe_add = function(x, y) {
22556 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
22557 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
22558 return (msw << 16) | (lsw & 0xFFFF);
22559 }
22560
22561 function S (X, n) {
22562 return (X >>> n) | (X << (32 - n));
22563 }
22564
22565 function R (X, n) {
22566 return (X >>> n);
22567 }
22568
22569 function Ch (x, y, z) {
22570 return ((x & y) ^ ((~x) & z));
22571 }
22572
22573 function Maj (x, y, z) {
22574 return ((x & y) ^ (x & z) ^ (y & z));
22575 }
22576
22577 function Sigma0256 (x) {
22578 return (S(x, 2) ^ S(x, 13) ^ S(x, 22));
22579 }
22580
22581 function Sigma1256 (x) {
22582 return (S(x, 6) ^ S(x, 11) ^ S(x, 25));
22583 }
22584
22585 function Gamma0256 (x) {
22586 return (S(x, 7) ^ S(x, 18) ^ R(x, 3));
22587 }
22588
22589 function Gamma1256 (x) {
22590 return (S(x, 17) ^ S(x, 19) ^ R(x, 10));
22591 }
22592
22593 Sha256.prototype._update = function(m) {
22594 var M = this._block
22595 var W = this._w
22596 var a, b, c, d, e, f, g, h
22597 var T1, T2
22598
22599 a = this._a | 0
22600 b = this._b | 0
22601 c = this._c | 0
22602 d = this._d | 0
22603 e = this._e | 0
22604 f = this._f | 0
22605 g = this._g | 0
22606 h = this._h | 0
22607
22608 for (var j = 0; j < 64; j++) {
22609 var w = W[j] = j < 16
22610 ? M.readInt32BE(j * 4)
22611 : Gamma1256(W[j - 2]) + W[j - 7] + Gamma0256(W[j - 15]) + W[j - 16]
22612
22613 T1 = h + Sigma1256(e) + Ch(e, f, g) + K[j] + w
22614
22615 T2 = Sigma0256(a) + Maj(a, b, c);
22616 h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2;
22617 }
22618
22619 this._a = (a + this._a) | 0
22620 this._b = (b + this._b) | 0
22621 this._c = (c + this._c) | 0
22622 this._d = (d + this._d) | 0
22623 this._e = (e + this._e) | 0
22624 this._f = (f + this._f) | 0
22625 this._g = (g + this._g) | 0
22626 this._h = (h + this._h) | 0
22627
22628 };
22629
22630 Sha256.prototype._hash = function () {
22631 if(POOL.length < 10)
22632 POOL.push(this)
22633
22634 var H = new Buffer(32)
22635
22636 H.writeInt32BE(this._a, 0)
22637 H.writeInt32BE(this._b, 4)
22638 H.writeInt32BE(this._c, 8)
22639 H.writeInt32BE(this._d, 12)
22640 H.writeInt32BE(this._e, 16)
22641 H.writeInt32BE(this._f, 20)
22642 H.writeInt32BE(this._g, 24)
22643 H.writeInt32BE(this._h, 28)
22644
22645 return H
22646 }
22647
22648 return Sha256
22649
22650 }
22651
22652 },{"./util":26,"util":14}],26:[function(_dereq_,module,exports){
22653 exports.write = write
22654 exports.zeroFill = zeroFill
22655
22656 exports.toString = toString
22657
22658 function write (buffer, string, enc, start, from, to, LE) {
22659 var l = (to - from)
22660 if(enc === 'ascii' || enc === 'binary') {
22661 for( var i = 0; i < l; i++) {
22662 buffer[start + i] = string.charCodeAt(i + from)
22663 }
22664 }
22665 else if(enc == null) {
22666 for( var i = 0; i < l; i++) {
22667 buffer[start + i] = string[i + from]
22668 }
22669 }
22670 else if(enc === 'hex') {
22671 for(var i = 0; i < l; i++) {
22672 var j = from + i
22673 buffer[start + i] = parseInt(string[j*2] + string[(j*2)+1], 16)
22674 }
22675 }
22676 else if(enc === 'base64') {
22677 throw new Error('base64 encoding not yet supported')
22678 }
22679 else
22680 throw new Error(enc +' encoding not yet supported')
22681 }
22682
22683 //always fill to the end!
22684 function zeroFill(buf, from) {
22685 for(var i = from; i < buf.length; i++)
22686 buf[i] = 0
22687 }
22688
22689
22690 },{}],27:[function(_dereq_,module,exports){
22691 (function (Buffer){
22692 // JavaScript PBKDF2 Implementation
22693 // Based on http://git.io/qsv2zw
22694 // Licensed under LGPL v3
22695 // Copyright (c) 2013 jduncanator
22696
22697 var blocksize = 64
22698 var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(0)
22699
22700 module.exports = function (createHmac, exports) {
22701 exports = exports || {}
22702
22703 exports.pbkdf2 = function(password, salt, iterations, keylen, cb) {
22704 if('function' !== typeof cb)
22705 throw new Error('No callback provided to pbkdf2');
22706 setTimeout(function () {
22707 cb(null, exports.pbkdf2Sync(password, salt, iterations, keylen))
22708 })
22709 }
22710
22711 exports.pbkdf2Sync = function(key, salt, iterations, keylen) {
22712 if('number' !== typeof iterations)
22713 throw new TypeError('Iterations not a number')
22714 if(iterations < 0)
22715 throw new TypeError('Bad iterations')
22716 if('number' !== typeof keylen)
22717 throw new TypeError('Key length not a number')
22718 if(keylen < 0)
22719 throw new TypeError('Bad key length')
22720
22721 //stretch key to the correct length that hmac wants it,
22722 //otherwise this will happen every time hmac is called
22723 //twice per iteration.
22724 var key = !Buffer.isBuffer(key) ? new Buffer(key) : key
22725
22726 if(key.length > blocksize) {
22727 key = createHash(alg).update(key).digest()
22728 } else if(key.length < blocksize) {
22729 key = Buffer.concat([key, zeroBuffer], blocksize)
22730 }
22731
22732 var HMAC;
22733 var cplen, p = 0, i = 1, itmp = new Buffer(4), digtmp;
22734 var out = new Buffer(keylen);
22735 out.fill(0);
22736 while(keylen) {
22737 if(keylen > 20)
22738 cplen = 20;
22739 else
22740 cplen = keylen;
22741
22742 /* We are unlikely to ever use more than 256 blocks (5120 bits!)
22743 * but just in case...
22744 */
22745 itmp[0] = (i >> 24) & 0xff;
22746 itmp[1] = (i >> 16) & 0xff;
22747 itmp[2] = (i >> 8) & 0xff;
22748 itmp[3] = i & 0xff;
22749
22750 HMAC = createHmac('sha1', key);
22751 HMAC.update(salt)
22752 HMAC.update(itmp);
22753 digtmp = HMAC.digest();
22754 digtmp.copy(out, p, 0, cplen);
22755
22756 for(var j = 1; j < iterations; j++) {
22757 HMAC = createHmac('sha1', key);
22758 HMAC.update(digtmp);
22759 digtmp = HMAC.digest();
22760 for(var k = 0; k < cplen; k++) {
22761 out[k] ^= digtmp[k];
22762 }
22763 }
22764 keylen -= cplen;
22765 i++;
22766 p += cplen;
22767 }
22768
22769 return out;
22770 }
22771
22772 return exports
22773 }
22774
22775 }).call(this,_dereq_("buffer").Buffer)
22776 },{"buffer":8}],28:[function(_dereq_,module,exports){
22777 (function (Buffer){
22778 // Original code adapted from Robert Kieffer.
22779 // details at https://github.com/broofa/node-uuid
22780
22781
22782 (function() {
22783 var _global = this;
22784
22785 var mathRNG, whatwgRNG;
22786
22787 // NOTE: Math.random() does not guarantee "cryptographic quality"
22788 mathRNG = function(size) {
22789 var bytes = new Buffer(size);
22790 var r;
22791
22792 for (var i = 0, r; i < size; i++) {
22793 if ((i & 0x03) == 0) r = Math.random() * 0x100000000;
22794 bytes[i] = r >>> ((i & 0x03) << 3) & 0xff;
22795 }
22796
22797 return bytes;
22798 }
22799
22800 if (_global.crypto && crypto.getRandomValues) {
22801 whatwgRNG = function(size) {
22802 var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array
22803 crypto.getRandomValues(bytes);
22804 return bytes;
22805 }
22806 }
22807
22808 module.exports = whatwgRNG || mathRNG;
22809
22810 }())
22811
22812 }).call(this,_dereq_("buffer").Buffer)
22813 },{"buffer":8}],29:[function(_dereq_,module,exports){
22814 ;(function (root, factory, undef) {
22815 if (typeof exports === "object") {
22816 // CommonJS
22817 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
22818 }
22819 else if (typeof define === "function" && define.amd) {
22820 // AMD
22821 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
22822 }
22823 else {
22824 // Global (browser)
22825 factory(root.CryptoJS);
22826 }
22827 }(this, function (CryptoJS) {
22828
22829 (function () {
22830 // Shortcuts
22831 var C = CryptoJS;
22832 var C_lib = C.lib;
22833 var BlockCipher = C_lib.BlockCipher;
22834 var C_algo = C.algo;
22835
22836 // Lookup tables
22837 var SBOX = [];
22838 var INV_SBOX = [];
22839 var SUB_MIX_0 = [];
22840 var SUB_MIX_1 = [];
22841 var SUB_MIX_2 = [];
22842 var SUB_MIX_3 = [];
22843 var INV_SUB_MIX_0 = [];
22844 var INV_SUB_MIX_1 = [];
22845 var INV_SUB_MIX_2 = [];
22846 var INV_SUB_MIX_3 = [];
22847
22848 // Compute lookup tables
22849 (function () {
22850 // Compute double table
22851 var d = [];
22852 for (var i = 0; i < 256; i++) {
22853 if (i < 128) {
22854 d[i] = i << 1;
22855 } else {
22856 d[i] = (i << 1) ^ 0x11b;
22857 }
22858 }
22859
22860 // Walk GF(2^8)
22861 var x = 0;
22862 var xi = 0;
22863 for (var i = 0; i < 256; i++) {
22864 // Compute sbox
22865 var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
22866 sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
22867 SBOX[x] = sx;
22868 INV_SBOX[sx] = x;
22869
22870 // Compute multiplication
22871 var x2 = d[x];
22872 var x4 = d[x2];
22873 var x8 = d[x4];
22874
22875 // Compute sub bytes, mix columns tables
22876 var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
22877 SUB_MIX_0[x] = (t << 24) | (t >>> 8);
22878 SUB_MIX_1[x] = (t << 16) | (t >>> 16);
22879 SUB_MIX_2[x] = (t << 8) | (t >>> 24);
22880 SUB_MIX_3[x] = t;
22881
22882 // Compute inv sub bytes, inv mix columns tables
22883 var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
22884 INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
22885 INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
22886 INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
22887 INV_SUB_MIX_3[sx] = t;
22888
22889 // Compute next counter
22890 if (!x) {
22891 x = xi = 1;
22892 } else {
22893 x = x2 ^ d[d[d[x8 ^ x2]]];
22894 xi ^= d[d[xi]];
22895 }
22896 }
22897 }());
22898
22899 // Precomputed Rcon lookup
22900 var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
22901
22902 /**
22903 * AES block cipher algorithm.
22904 */
22905 var AES = C_algo.AES = BlockCipher.extend({
22906 _doReset: function () {
22907 // Shortcuts
22908 var key = this._key;
22909 var keyWords = key.words;
22910 var keySize = key.sigBytes / 4;
22911
22912 // Compute number of rounds
22913 var nRounds = this._nRounds = keySize + 6
22914
22915 // Compute number of key schedule rows
22916 var ksRows = (nRounds + 1) * 4;
22917
22918 // Compute key schedule
22919 var keySchedule = this._keySchedule = [];
22920 for (var ksRow = 0; ksRow < ksRows; ksRow++) {
22921 if (ksRow < keySize) {
22922 keySchedule[ksRow] = keyWords[ksRow];
22923 } else {
22924 var t = keySchedule[ksRow - 1];
22925
22926 if (!(ksRow % keySize)) {
22927 // Rot word
22928 t = (t << 8) | (t >>> 24);
22929
22930 // Sub word
22931 t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
22932
22933 // Mix Rcon
22934 t ^= RCON[(ksRow / keySize) | 0] << 24;
22935 } else if (keySize > 6 && ksRow % keySize == 4) {
22936 // Sub word
22937 t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
22938 }
22939
22940 keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
22941 }
22942 }
22943
22944 // Compute inv key schedule
22945 var invKeySchedule = this._invKeySchedule = [];
22946 for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
22947 var ksRow = ksRows - invKsRow;
22948
22949 if (invKsRow % 4) {
22950 var t = keySchedule[ksRow];
22951 } else {
22952 var t = keySchedule[ksRow - 4];
22953 }
22954
22955 if (invKsRow < 4 || ksRow <= 4) {
22956 invKeySchedule[invKsRow] = t;
22957 } else {
22958 invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
22959 INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
22960 }
22961 }
22962 },
22963
22964 encryptBlock: function (M, offset) {
22965 this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
22966 },
22967
22968 decryptBlock: function (M, offset) {
22969 // Swap 2nd and 4th rows
22970 var t = M[offset + 1];
22971 M[offset + 1] = M[offset + 3];
22972 M[offset + 3] = t;
22973
22974 this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
22975
22976 // Inv swap 2nd and 4th rows
22977 var t = M[offset + 1];
22978 M[offset + 1] = M[offset + 3];
22979 M[offset + 3] = t;
22980 },
22981
22982 _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
22983 // Shortcut
22984 var nRounds = this._nRounds;
22985
22986 // Get input, add round key
22987 var s0 = M[offset] ^ keySchedule[0];
22988 var s1 = M[offset + 1] ^ keySchedule[1];
22989 var s2 = M[offset + 2] ^ keySchedule[2];
22990 var s3 = M[offset + 3] ^ keySchedule[3];
22991
22992 // Key schedule row counter
22993 var ksRow = 4;
22994
22995 // Rounds
22996 for (var round = 1; round < nRounds; round++) {
22997 // Shift rows, sub bytes, mix columns, add round key
22998 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++];
22999 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++];
23000 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++];
23001 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++];
23002
23003 // Update state
23004 s0 = t0;
23005 s1 = t1;
23006 s2 = t2;
23007 s3 = t3;
23008 }
23009
23010 // Shift rows, sub bytes, add round key
23011 var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
23012 var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
23013 var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
23014 var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
23015
23016 // Set output
23017 M[offset] = t0;
23018 M[offset + 1] = t1;
23019 M[offset + 2] = t2;
23020 M[offset + 3] = t3;
23021 },
23022
23023 keySize: 256/32
23024 });
23025
23026 /**
23027 * Shortcut functions to the cipher's object interface.
23028 *
23029 * @example
23030 *
23031 * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
23032 * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
23033 */
23034 C.AES = BlockCipher._createHelper(AES);
23035 }());
23036
23037
23038 return CryptoJS.AES;
23039
23040 }));
23041 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],30:[function(_dereq_,module,exports){
23042 ;(function (root, factory) {
23043 if (typeof exports === "object") {
23044 // CommonJS
23045 module.exports = exports = factory(_dereq_("./core"));
23046 }
23047 else if (typeof define === "function" && define.amd) {
23048 // AMD
23049 define(["./core"], factory);
23050 }
23051 else {
23052 // Global (browser)
23053 factory(root.CryptoJS);
23054 }
23055 }(this, function (CryptoJS) {
23056
23057 /**
23058 * Cipher core components.
23059 */
23060 CryptoJS.lib.Cipher || (function (undefined) {
23061 // Shortcuts
23062 var C = CryptoJS;
23063 var C_lib = C.lib;
23064 var Base = C_lib.Base;
23065 var WordArray = C_lib.WordArray;
23066 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
23067 var C_enc = C.enc;
23068 var Utf8 = C_enc.Utf8;
23069 var Base64 = C_enc.Base64;
23070 var C_algo = C.algo;
23071 var EvpKDF = C_algo.EvpKDF;
23072
23073 /**
23074 * Abstract base cipher template.
23075 *
23076 * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
23077 * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
23078 * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
23079 * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
23080 */
23081 var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
23082 /**
23083 * Configuration options.
23084 *
23085 * @property {WordArray} iv The IV to use for this operation.
23086 */
23087 cfg: Base.extend(),
23088
23089 /**
23090 * Creates this cipher in encryption mode.
23091 *
23092 * @param {WordArray} key The key.
23093 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23094 *
23095 * @return {Cipher} A cipher instance.
23096 *
23097 * @static
23098 *
23099 * @example
23100 *
23101 * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
23102 */
23103 createEncryptor: function (key, cfg) {
23104 return this.create(this._ENC_XFORM_MODE, key, cfg);
23105 },
23106
23107 /**
23108 * Creates this cipher in decryption mode.
23109 *
23110 * @param {WordArray} key The key.
23111 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23112 *
23113 * @return {Cipher} A cipher instance.
23114 *
23115 * @static
23116 *
23117 * @example
23118 *
23119 * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
23120 */
23121 createDecryptor: function (key, cfg) {
23122 return this.create(this._DEC_XFORM_MODE, key, cfg);
23123 },
23124
23125 /**
23126 * Initializes a newly created cipher.
23127 *
23128 * @param {number} xformMode Either the encryption or decryption transormation mode constant.
23129 * @param {WordArray} key The key.
23130 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23131 *
23132 * @example
23133 *
23134 * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
23135 */
23136 init: function (xformMode, key, cfg) {
23137 // Apply config defaults
23138 this.cfg = this.cfg.extend(cfg);
23139
23140 // Store transform mode and key
23141 this._xformMode = xformMode;
23142 this._key = key;
23143
23144 // Set initial values
23145 this.reset();
23146 },
23147
23148 /**
23149 * Resets this cipher to its initial state.
23150 *
23151 * @example
23152 *
23153 * cipher.reset();
23154 */
23155 reset: function () {
23156 // Reset data buffer
23157 BufferedBlockAlgorithm.reset.call(this);
23158
23159 // Perform concrete-cipher logic
23160 this._doReset();
23161 },
23162
23163 /**
23164 * Adds data to be encrypted or decrypted.
23165 *
23166 * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
23167 *
23168 * @return {WordArray} The data after processing.
23169 *
23170 * @example
23171 *
23172 * var encrypted = cipher.process('data');
23173 * var encrypted = cipher.process(wordArray);
23174 */
23175 process: function (dataUpdate) {
23176 // Append
23177 this._append(dataUpdate);
23178
23179 // Process available blocks
23180 return this._process();
23181 },
23182
23183 /**
23184 * Finalizes the encryption or decryption process.
23185 * Note that the finalize operation is effectively a destructive, read-once operation.
23186 *
23187 * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
23188 *
23189 * @return {WordArray} The data after final processing.
23190 *
23191 * @example
23192 *
23193 * var encrypted = cipher.finalize();
23194 * var encrypted = cipher.finalize('data');
23195 * var encrypted = cipher.finalize(wordArray);
23196 */
23197 finalize: function (dataUpdate) {
23198 // Final data update
23199 if (dataUpdate) {
23200 this._append(dataUpdate);
23201 }
23202
23203 // Perform concrete-cipher logic
23204 var finalProcessedData = this._doFinalize();
23205
23206 return finalProcessedData;
23207 },
23208
23209 keySize: 128/32,
23210
23211 ivSize: 128/32,
23212
23213 _ENC_XFORM_MODE: 1,
23214
23215 _DEC_XFORM_MODE: 2,
23216
23217 /**
23218 * Creates shortcut functions to a cipher's object interface.
23219 *
23220 * @param {Cipher} cipher The cipher to create a helper for.
23221 *
23222 * @return {Object} An object with encrypt and decrypt shortcut functions.
23223 *
23224 * @static
23225 *
23226 * @example
23227 *
23228 * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
23229 */
23230 _createHelper: (function () {
23231 function selectCipherStrategy(key) {
23232 if (typeof key == 'string') {
23233 return PasswordBasedCipher;
23234 } else {
23235 return SerializableCipher;
23236 }
23237 }
23238
23239 return function (cipher) {
23240 return {
23241 encrypt: function (message, key, cfg) {
23242 return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
23243 },
23244
23245 decrypt: function (ciphertext, key, cfg) {
23246 return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
23247 }
23248 };
23249 };
23250 }())
23251 });
23252
23253 /**
23254 * Abstract base stream cipher template.
23255 *
23256 * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
23257 */
23258 var StreamCipher = C_lib.StreamCipher = Cipher.extend({
23259 _doFinalize: function () {
23260 // Process partial blocks
23261 var finalProcessedBlocks = this._process(!!'flush');
23262
23263 return finalProcessedBlocks;
23264 },
23265
23266 blockSize: 1
23267 });
23268
23269 /**
23270 * Mode namespace.
23271 */
23272 var C_mode = C.mode = {};
23273
23274 /**
23275 * Abstract base block cipher mode template.
23276 */
23277 var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
23278 /**
23279 * Creates this mode for encryption.
23280 *
23281 * @param {Cipher} cipher A block cipher instance.
23282 * @param {Array} iv The IV words.
23283 *
23284 * @static
23285 *
23286 * @example
23287 *
23288 * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
23289 */
23290 createEncryptor: function (cipher, iv) {
23291 return this.Encryptor.create(cipher, iv);
23292 },
23293
23294 /**
23295 * Creates this mode for decryption.
23296 *
23297 * @param {Cipher} cipher A block cipher instance.
23298 * @param {Array} iv The IV words.
23299 *
23300 * @static
23301 *
23302 * @example
23303 *
23304 * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
23305 */
23306 createDecryptor: function (cipher, iv) {
23307 return this.Decryptor.create(cipher, iv);
23308 },
23309
23310 /**
23311 * Initializes a newly created mode.
23312 *
23313 * @param {Cipher} cipher A block cipher instance.
23314 * @param {Array} iv The IV words.
23315 *
23316 * @example
23317 *
23318 * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
23319 */
23320 init: function (cipher, iv) {
23321 this._cipher = cipher;
23322 this._iv = iv;
23323 }
23324 });
23325
23326 /**
23327 * Cipher Block Chaining mode.
23328 */
23329 var CBC = C_mode.CBC = (function () {
23330 /**
23331 * Abstract base CBC mode.
23332 */
23333 var CBC = BlockCipherMode.extend();
23334
23335 /**
23336 * CBC encryptor.
23337 */
23338 CBC.Encryptor = CBC.extend({
23339 /**
23340 * Processes the data block at offset.
23341 *
23342 * @param {Array} words The data words to operate on.
23343 * @param {number} offset The offset where the block starts.
23344 *
23345 * @example
23346 *
23347 * mode.processBlock(data.words, offset);
23348 */
23349 processBlock: function (words, offset) {
23350 // Shortcuts
23351 var cipher = this._cipher;
23352 var blockSize = cipher.blockSize;
23353
23354 // XOR and encrypt
23355 xorBlock.call(this, words, offset, blockSize);
23356 cipher.encryptBlock(words, offset);
23357
23358 // Remember this block to use with next block
23359 this._prevBlock = words.slice(offset, offset + blockSize);
23360 }
23361 });
23362
23363 /**
23364 * CBC decryptor.
23365 */
23366 CBC.Decryptor = CBC.extend({
23367 /**
23368 * Processes the data block at offset.
23369 *
23370 * @param {Array} words The data words to operate on.
23371 * @param {number} offset The offset where the block starts.
23372 *
23373 * @example
23374 *
23375 * mode.processBlock(data.words, offset);
23376 */
23377 processBlock: function (words, offset) {
23378 // Shortcuts
23379 var cipher = this._cipher;
23380 var blockSize = cipher.blockSize;
23381
23382 // Remember this block to use with next block
23383 var thisBlock = words.slice(offset, offset + blockSize);
23384
23385 // Decrypt and XOR
23386 cipher.decryptBlock(words, offset);
23387 xorBlock.call(this, words, offset, blockSize);
23388
23389 // This block becomes the previous block
23390 this._prevBlock = thisBlock;
23391 }
23392 });
23393
23394 function xorBlock(words, offset, blockSize) {
23395 // Shortcut
23396 var iv = this._iv;
23397
23398 // Choose mixing block
23399 if (iv) {
23400 var block = iv;
23401
23402 // Remove IV for subsequent blocks
23403 this._iv = undefined;
23404 } else {
23405 var block = this._prevBlock;
23406 }
23407
23408 // XOR blocks
23409 for (var i = 0; i < blockSize; i++) {
23410 words[offset + i] ^= block[i];
23411 }
23412 }
23413
23414 return CBC;
23415 }());
23416
23417 /**
23418 * Padding namespace.
23419 */
23420 var C_pad = C.pad = {};
23421
23422 /**
23423 * PKCS #5/7 padding strategy.
23424 */
23425 var Pkcs7 = C_pad.Pkcs7 = {
23426 /**
23427 * Pads data using the algorithm defined in PKCS #5/7.
23428 *
23429 * @param {WordArray} data The data to pad.
23430 * @param {number} blockSize The multiple that the data should be padded to.
23431 *
23432 * @static
23433 *
23434 * @example
23435 *
23436 * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
23437 */
23438 pad: function (data, blockSize) {
23439 // Shortcut
23440 var blockSizeBytes = blockSize * 4;
23441
23442 // Count padding bytes
23443 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
23444
23445 // Create padding word
23446 var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
23447
23448 // Create padding
23449 var paddingWords = [];
23450 for (var i = 0; i < nPaddingBytes; i += 4) {
23451 paddingWords.push(paddingWord);
23452 }
23453 var padding = WordArray.create(paddingWords, nPaddingBytes);
23454
23455 // Add padding
23456 data.concat(padding);
23457 },
23458
23459 /**
23460 * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
23461 *
23462 * @param {WordArray} data The data to unpad.
23463 *
23464 * @static
23465 *
23466 * @example
23467 *
23468 * CryptoJS.pad.Pkcs7.unpad(wordArray);
23469 */
23470 unpad: function (data) {
23471 // Get number of padding bytes from last byte
23472 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
23473
23474 // Remove padding
23475 data.sigBytes -= nPaddingBytes;
23476 }
23477 };
23478
23479 /**
23480 * Abstract base block cipher template.
23481 *
23482 * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
23483 */
23484 var BlockCipher = C_lib.BlockCipher = Cipher.extend({
23485 /**
23486 * Configuration options.
23487 *
23488 * @property {Mode} mode The block mode to use. Default: CBC
23489 * @property {Padding} padding The padding strategy to use. Default: Pkcs7
23490 */
23491 cfg: Cipher.cfg.extend({
23492 mode: CBC,
23493 padding: Pkcs7
23494 }),
23495
23496 reset: function () {
23497 // Reset cipher
23498 Cipher.reset.call(this);
23499
23500 // Shortcuts
23501 var cfg = this.cfg;
23502 var iv = cfg.iv;
23503 var mode = cfg.mode;
23504
23505 // Reset block mode
23506 if (this._xformMode == this._ENC_XFORM_MODE) {
23507 var modeCreator = mode.createEncryptor;
23508 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
23509 var modeCreator = mode.createDecryptor;
23510
23511 // Keep at least one block in the buffer for unpadding
23512 this._minBufferSize = 1;
23513 }
23514 this._mode = modeCreator.call(mode, this, iv && iv.words);
23515 },
23516
23517 _doProcessBlock: function (words, offset) {
23518 this._mode.processBlock(words, offset);
23519 },
23520
23521 _doFinalize: function () {
23522 // Shortcut
23523 var padding = this.cfg.padding;
23524
23525 // Finalize
23526 if (this._xformMode == this._ENC_XFORM_MODE) {
23527 // Pad data
23528 padding.pad(this._data, this.blockSize);
23529
23530 // Process final blocks
23531 var finalProcessedBlocks = this._process(!!'flush');
23532 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
23533 // Process final blocks
23534 var finalProcessedBlocks = this._process(!!'flush');
23535
23536 // Unpad data
23537 padding.unpad(finalProcessedBlocks);
23538 }
23539
23540 return finalProcessedBlocks;
23541 },
23542
23543 blockSize: 128/32
23544 });
23545
23546 /**
23547 * A collection of cipher parameters.
23548 *
23549 * @property {WordArray} ciphertext The raw ciphertext.
23550 * @property {WordArray} key The key to this ciphertext.
23551 * @property {WordArray} iv The IV used in the ciphering operation.
23552 * @property {WordArray} salt The salt used with a key derivation function.
23553 * @property {Cipher} algorithm The cipher algorithm.
23554 * @property {Mode} mode The block mode used in the ciphering operation.
23555 * @property {Padding} padding The padding scheme used in the ciphering operation.
23556 * @property {number} blockSize The block size of the cipher.
23557 * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
23558 */
23559 var CipherParams = C_lib.CipherParams = Base.extend({
23560 /**
23561 * Initializes a newly created cipher params object.
23562 *
23563 * @param {Object} cipherParams An object with any of the possible cipher parameters.
23564 *
23565 * @example
23566 *
23567 * var cipherParams = CryptoJS.lib.CipherParams.create({
23568 * ciphertext: ciphertextWordArray,
23569 * key: keyWordArray,
23570 * iv: ivWordArray,
23571 * salt: saltWordArray,
23572 * algorithm: CryptoJS.algo.AES,
23573 * mode: CryptoJS.mode.CBC,
23574 * padding: CryptoJS.pad.PKCS7,
23575 * blockSize: 4,
23576 * formatter: CryptoJS.format.OpenSSL
23577 * });
23578 */
23579 init: function (cipherParams) {
23580 this.mixIn(cipherParams);
23581 },
23582
23583 /**
23584 * Converts this cipher params object to a string.
23585 *
23586 * @param {Format} formatter (Optional) The formatting strategy to use.
23587 *
23588 * @return {string} The stringified cipher params.
23589 *
23590 * @throws Error If neither the formatter nor the default formatter is set.
23591 *
23592 * @example
23593 *
23594 * var string = cipherParams + '';
23595 * var string = cipherParams.toString();
23596 * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
23597 */
23598 toString: function (formatter) {
23599 return (formatter || this.formatter).stringify(this);
23600 }
23601 });
23602
23603 /**
23604 * Format namespace.
23605 */
23606 var C_format = C.format = {};
23607
23608 /**
23609 * OpenSSL formatting strategy.
23610 */
23611 var OpenSSLFormatter = C_format.OpenSSL = {
23612 /**
23613 * Converts a cipher params object to an OpenSSL-compatible string.
23614 *
23615 * @param {CipherParams} cipherParams The cipher params object.
23616 *
23617 * @return {string} The OpenSSL-compatible string.
23618 *
23619 * @static
23620 *
23621 * @example
23622 *
23623 * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
23624 */
23625 stringify: function (cipherParams) {
23626 // Shortcuts
23627 var ciphertext = cipherParams.ciphertext;
23628 var salt = cipherParams.salt;
23629
23630 // Format
23631 if (salt) {
23632 var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
23633 } else {
23634 var wordArray = ciphertext;
23635 }
23636
23637 return wordArray.toString(Base64);
23638 },
23639
23640 /**
23641 * Converts an OpenSSL-compatible string to a cipher params object.
23642 *
23643 * @param {string} openSSLStr The OpenSSL-compatible string.
23644 *
23645 * @return {CipherParams} The cipher params object.
23646 *
23647 * @static
23648 *
23649 * @example
23650 *
23651 * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
23652 */
23653 parse: function (openSSLStr) {
23654 // Parse base64
23655 var ciphertext = Base64.parse(openSSLStr);
23656
23657 // Shortcut
23658 var ciphertextWords = ciphertext.words;
23659
23660 // Test for salt
23661 if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
23662 // Extract salt
23663 var salt = WordArray.create(ciphertextWords.slice(2, 4));
23664
23665 // Remove salt from ciphertext
23666 ciphertextWords.splice(0, 4);
23667 ciphertext.sigBytes -= 16;
23668 }
23669
23670 return CipherParams.create({ ciphertext: ciphertext, salt: salt });
23671 }
23672 };
23673
23674 /**
23675 * A cipher wrapper that returns ciphertext as a serializable cipher params object.
23676 */
23677 var SerializableCipher = C_lib.SerializableCipher = Base.extend({
23678 /**
23679 * Configuration options.
23680 *
23681 * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
23682 */
23683 cfg: Base.extend({
23684 format: OpenSSLFormatter
23685 }),
23686
23687 /**
23688 * Encrypts a message.
23689 *
23690 * @param {Cipher} cipher The cipher algorithm to use.
23691 * @param {WordArray|string} message The message to encrypt.
23692 * @param {WordArray} key The key.
23693 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23694 *
23695 * @return {CipherParams} A cipher params object.
23696 *
23697 * @static
23698 *
23699 * @example
23700 *
23701 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
23702 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
23703 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23704 */
23705 encrypt: function (cipher, message, key, cfg) {
23706 // Apply config defaults
23707 cfg = this.cfg.extend(cfg);
23708
23709 // Encrypt
23710 var encryptor = cipher.createEncryptor(key, cfg);
23711 var ciphertext = encryptor.finalize(message);
23712
23713 // Shortcut
23714 var cipherCfg = encryptor.cfg;
23715
23716 // Create and return serializable cipher params
23717 return CipherParams.create({
23718 ciphertext: ciphertext,
23719 key: key,
23720 iv: cipherCfg.iv,
23721 algorithm: cipher,
23722 mode: cipherCfg.mode,
23723 padding: cipherCfg.padding,
23724 blockSize: cipher.blockSize,
23725 formatter: cfg.format
23726 });
23727 },
23728
23729 /**
23730 * Decrypts serialized ciphertext.
23731 *
23732 * @param {Cipher} cipher The cipher algorithm to use.
23733 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
23734 * @param {WordArray} key The key.
23735 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23736 *
23737 * @return {WordArray} The plaintext.
23738 *
23739 * @static
23740 *
23741 * @example
23742 *
23743 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23744 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23745 */
23746 decrypt: function (cipher, ciphertext, key, cfg) {
23747 // Apply config defaults
23748 cfg = this.cfg.extend(cfg);
23749
23750 // Convert string to CipherParams
23751 ciphertext = this._parse(ciphertext, cfg.format);
23752
23753 // Decrypt
23754 var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
23755
23756 return plaintext;
23757 },
23758
23759 /**
23760 * Converts serialized ciphertext to CipherParams,
23761 * else assumed CipherParams already and returns ciphertext unchanged.
23762 *
23763 * @param {CipherParams|string} ciphertext The ciphertext.
23764 * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
23765 *
23766 * @return {CipherParams} The unserialized ciphertext.
23767 *
23768 * @static
23769 *
23770 * @example
23771 *
23772 * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
23773 */
23774 _parse: function (ciphertext, format) {
23775 if (typeof ciphertext == 'string') {
23776 return format.parse(ciphertext, this);
23777 } else {
23778 return ciphertext;
23779 }
23780 }
23781 });
23782
23783 /**
23784 * Key derivation function namespace.
23785 */
23786 var C_kdf = C.kdf = {};
23787
23788 /**
23789 * OpenSSL key derivation function.
23790 */
23791 var OpenSSLKdf = C_kdf.OpenSSL = {
23792 /**
23793 * Derives a key and IV from a password.
23794 *
23795 * @param {string} password The password to derive from.
23796 * @param {number} keySize The size in words of the key to generate.
23797 * @param {number} ivSize The size in words of the IV to generate.
23798 * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
23799 *
23800 * @return {CipherParams} A cipher params object with the key, IV, and salt.
23801 *
23802 * @static
23803 *
23804 * @example
23805 *
23806 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
23807 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
23808 */
23809 execute: function (password, keySize, ivSize, salt) {
23810 // Generate random salt
23811 if (!salt) {
23812 salt = WordArray.random(64/8);
23813 }
23814
23815 // Derive key and IV
23816 var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
23817
23818 // Separate key and IV
23819 var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
23820 key.sigBytes = keySize * 4;
23821
23822 // Return params
23823 return CipherParams.create({ key: key, iv: iv, salt: salt });
23824 }
23825 };
23826
23827 /**
23828 * A serializable cipher wrapper that derives the key from a password,
23829 * and returns ciphertext as a serializable cipher params object.
23830 */
23831 var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
23832 /**
23833 * Configuration options.
23834 *
23835 * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
23836 */
23837 cfg: SerializableCipher.cfg.extend({
23838 kdf: OpenSSLKdf
23839 }),
23840
23841 /**
23842 * Encrypts a message using a password.
23843 *
23844 * @param {Cipher} cipher The cipher algorithm to use.
23845 * @param {WordArray|string} message The message to encrypt.
23846 * @param {string} password The password.
23847 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23848 *
23849 * @return {CipherParams} A cipher params object.
23850 *
23851 * @static
23852 *
23853 * @example
23854 *
23855 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
23856 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
23857 */
23858 encrypt: function (cipher, message, password, cfg) {
23859 // Apply config defaults
23860 cfg = this.cfg.extend(cfg);
23861
23862 // Derive key and other params
23863 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
23864
23865 // Add IV to config
23866 cfg.iv = derivedParams.iv;
23867
23868 // Encrypt
23869 var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
23870
23871 // Mix in derived params
23872 ciphertext.mixIn(derivedParams);
23873
23874 return ciphertext;
23875 },
23876
23877 /**
23878 * Decrypts serialized ciphertext using a password.
23879 *
23880 * @param {Cipher} cipher The cipher algorithm to use.
23881 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
23882 * @param {string} password The password.
23883 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23884 *
23885 * @return {WordArray} The plaintext.
23886 *
23887 * @static
23888 *
23889 * @example
23890 *
23891 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
23892 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
23893 */
23894 decrypt: function (cipher, ciphertext, password, cfg) {
23895 // Apply config defaults
23896 cfg = this.cfg.extend(cfg);
23897
23898 // Convert string to CipherParams
23899 ciphertext = this._parse(ciphertext, cfg.format);
23900
23901 // Derive key and other params
23902 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
23903
23904 // Add IV to config
23905 cfg.iv = derivedParams.iv;
23906
23907 // Decrypt
23908 var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
23909
23910 return plaintext;
23911 }
23912 });
23913 }());
23914
23915
23916 }));
23917 },{"./core":31}],31:[function(_dereq_,module,exports){
23918 ;(function (root, factory) {
23919 if (typeof exports === "object") {
23920 // CommonJS
23921 module.exports = exports = factory();
23922 }
23923 else if (typeof define === "function" && define.amd) {
23924 // AMD
23925 define([], factory);
23926 }
23927 else {
23928 // Global (browser)
23929 root.CryptoJS = factory();
23930 }
23931 }(this, function () {
23932
23933 /**
23934 * CryptoJS core components.
23935 */
23936 var CryptoJS = CryptoJS || (function (Math, undefined) {
23937 /**
23938 * CryptoJS namespace.
23939 */
23940 var C = {};
23941
23942 /**
23943 * Library namespace.
23944 */
23945 var C_lib = C.lib = {};
23946
23947 /**
23948 * Base object for prototypal inheritance.
23949 */
23950 var Base = C_lib.Base = (function () {
23951 function F() {}
23952
23953 return {
23954 /**
23955 * Creates a new object that inherits from this object.
23956 *
23957 * @param {Object} overrides Properties to copy into the new object.
23958 *
23959 * @return {Object} The new object.
23960 *
23961 * @static
23962 *
23963 * @example
23964 *
23965 * var MyType = CryptoJS.lib.Base.extend({
23966 * field: 'value',
23967 *
23968 * method: function () {
23969 * }
23970 * });
23971 */
23972 extend: function (overrides) {
23973 // Spawn
23974 F.prototype = this;
23975 var subtype = new F();
23976
23977 // Augment
23978 if (overrides) {
23979 subtype.mixIn(overrides);
23980 }
23981
23982 // Create default initializer
23983 if (!subtype.hasOwnProperty('init')) {
23984 subtype.init = function () {
23985 subtype.$super.init.apply(this, arguments);
23986 };
23987 }
23988
23989 // Initializer's prototype is the subtype object
23990 subtype.init.prototype = subtype;
23991
23992 // Reference supertype
23993 subtype.$super = this;
23994
23995 return subtype;
23996 },
23997
23998 /**
23999 * Extends this object and runs the init method.
24000 * Arguments to create() will be passed to init().
24001 *
24002 * @return {Object} The new object.
24003 *
24004 * @static
24005 *
24006 * @example
24007 *
24008 * var instance = MyType.create();
24009 */
24010 create: function () {
24011 var instance = this.extend();
24012 instance.init.apply(instance, arguments);
24013
24014 return instance;
24015 },
24016
24017 /**
24018 * Initializes a newly created object.
24019 * Override this method to add some logic when your objects are created.
24020 *
24021 * @example
24022 *
24023 * var MyType = CryptoJS.lib.Base.extend({
24024 * init: function () {
24025 * // ...
24026 * }
24027 * });
24028 */
24029 init: function () {
24030 },
24031
24032 /**
24033 * Copies properties into this object.
24034 *
24035 * @param {Object} properties The properties to mix in.
24036 *
24037 * @example
24038 *
24039 * MyType.mixIn({
24040 * field: 'value'
24041 * });
24042 */
24043 mixIn: function (properties) {
24044 for (var propertyName in properties) {
24045 if (properties.hasOwnProperty(propertyName)) {
24046 this[propertyName] = properties[propertyName];
24047 }
24048 }
24049
24050 // IE won't copy toString using the loop above
24051 if (properties.hasOwnProperty('toString')) {
24052 this.toString = properties.toString;
24053 }
24054 },
24055
24056 /**
24057 * Creates a copy of this object.
24058 *
24059 * @return {Object} The clone.
24060 *
24061 * @example
24062 *
24063 * var clone = instance.clone();
24064 */
24065 clone: function () {
24066 return this.init.prototype.extend(this);
24067 }
24068 };
24069 }());
24070
24071 /**
24072 * An array of 32-bit words.
24073 *
24074 * @property {Array} words The array of 32-bit words.
24075 * @property {number} sigBytes The number of significant bytes in this word array.
24076 */
24077 var WordArray = C_lib.WordArray = Base.extend({
24078 /**
24079 * Initializes a newly created word array.
24080 *
24081 * @param {Array} words (Optional) An array of 32-bit words.
24082 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
24083 *
24084 * @example
24085 *
24086 * var wordArray = CryptoJS.lib.WordArray.create();
24087 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
24088 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
24089 */
24090 init: function (words, sigBytes) {
24091 words = this.words = words || [];
24092
24093 if (sigBytes != undefined) {
24094 this.sigBytes = sigBytes;
24095 } else {
24096 this.sigBytes = words.length * 4;
24097 }
24098 },
24099
24100 /**
24101 * Converts this word array to a string.
24102 *
24103 * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
24104 *
24105 * @return {string} The stringified word array.
24106 *
24107 * @example
24108 *
24109 * var string = wordArray + '';
24110 * var string = wordArray.toString();
24111 * var string = wordArray.toString(CryptoJS.enc.Utf8);
24112 */
24113 toString: function (encoder) {
24114 return (encoder || Hex).stringify(this);
24115 },
24116
24117 /**
24118 * Concatenates a word array to this word array.
24119 *
24120 * @param {WordArray} wordArray The word array to append.
24121 *
24122 * @return {WordArray} This word array.
24123 *
24124 * @example
24125 *
24126 * wordArray1.concat(wordArray2);
24127 */
24128 concat: function (wordArray) {
24129 // Shortcuts
24130 var thisWords = this.words;
24131 var thatWords = wordArray.words;
24132 var thisSigBytes = this.sigBytes;
24133 var thatSigBytes = wordArray.sigBytes;
24134
24135 // Clamp excess bits
24136 this.clamp();
24137
24138 // Concat
24139 if (thisSigBytes % 4) {
24140 // Copy one byte at a time
24141 for (var i = 0; i < thatSigBytes; i++) {
24142 var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24143 thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
24144 }
24145 } else if (thatWords.length > 0xffff) {
24146 // Copy one word at a time
24147 for (var i = 0; i < thatSigBytes; i += 4) {
24148 thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
24149 }
24150 } else {
24151 // Copy all words at once
24152 thisWords.push.apply(thisWords, thatWords);
24153 }
24154 this.sigBytes += thatSigBytes;
24155
24156 // Chainable
24157 return this;
24158 },
24159
24160 /**
24161 * Removes insignificant bits.
24162 *
24163 * @example
24164 *
24165 * wordArray.clamp();
24166 */
24167 clamp: function () {
24168 // Shortcuts
24169 var words = this.words;
24170 var sigBytes = this.sigBytes;
24171
24172 // Clamp
24173 words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
24174 words.length = Math.ceil(sigBytes / 4);
24175 },
24176
24177 /**
24178 * Creates a copy of this word array.
24179 *
24180 * @return {WordArray} The clone.
24181 *
24182 * @example
24183 *
24184 * var clone = wordArray.clone();
24185 */
24186 clone: function () {
24187 var clone = Base.clone.call(this);
24188 clone.words = this.words.slice(0);
24189
24190 return clone;
24191 },
24192
24193 /**
24194 * Creates a word array filled with random bytes.
24195 *
24196 * @param {number} nBytes The number of random bytes to generate.
24197 *
24198 * @return {WordArray} The random word array.
24199 *
24200 * @static
24201 *
24202 * @example
24203 *
24204 * var wordArray = CryptoJS.lib.WordArray.random(16);
24205 */
24206 random: function (nBytes) {
24207 var words = [];
24208 for (var i = 0; i < nBytes; i += 4) {
24209 words.push((Math.random() * 0x100000000) | 0);
24210 }
24211
24212 return new WordArray.init(words, nBytes);
24213 }
24214 });
24215
24216 /**
24217 * Encoder namespace.
24218 */
24219 var C_enc = C.enc = {};
24220
24221 /**
24222 * Hex encoding strategy.
24223 */
24224 var Hex = C_enc.Hex = {
24225 /**
24226 * Converts a word array to a hex string.
24227 *
24228 * @param {WordArray} wordArray The word array.
24229 *
24230 * @return {string} The hex string.
24231 *
24232 * @static
24233 *
24234 * @example
24235 *
24236 * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
24237 */
24238 stringify: function (wordArray) {
24239 // Shortcuts
24240 var words = wordArray.words;
24241 var sigBytes = wordArray.sigBytes;
24242
24243 // Convert
24244 var hexChars = [];
24245 for (var i = 0; i < sigBytes; i++) {
24246 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24247 hexChars.push((bite >>> 4).toString(16));
24248 hexChars.push((bite & 0x0f).toString(16));
24249 }
24250
24251 return hexChars.join('');
24252 },
24253
24254 /**
24255 * Converts a hex string to a word array.
24256 *
24257 * @param {string} hexStr The hex string.
24258 *
24259 * @return {WordArray} The word array.
24260 *
24261 * @static
24262 *
24263 * @example
24264 *
24265 * var wordArray = CryptoJS.enc.Hex.parse(hexString);
24266 */
24267 parse: function (hexStr) {
24268 // Shortcut
24269 var hexStrLength = hexStr.length;
24270
24271 // Convert
24272 var words = [];
24273 for (var i = 0; i < hexStrLength; i += 2) {
24274 words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
24275 }
24276
24277 return new WordArray.init(words, hexStrLength / 2);
24278 }
24279 };
24280
24281 /**
24282 * Latin1 encoding strategy.
24283 */
24284 var Latin1 = C_enc.Latin1 = {
24285 /**
24286 * Converts a word array to a Latin1 string.
24287 *
24288 * @param {WordArray} wordArray The word array.
24289 *
24290 * @return {string} The Latin1 string.
24291 *
24292 * @static
24293 *
24294 * @example
24295 *
24296 * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
24297 */
24298 stringify: function (wordArray) {
24299 // Shortcuts
24300 var words = wordArray.words;
24301 var sigBytes = wordArray.sigBytes;
24302
24303 // Convert
24304 var latin1Chars = [];
24305 for (var i = 0; i < sigBytes; i++) {
24306 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24307 latin1Chars.push(String.fromCharCode(bite));
24308 }
24309
24310 return latin1Chars.join('');
24311 },
24312
24313 /**
24314 * Converts a Latin1 string to a word array.
24315 *
24316 * @param {string} latin1Str The Latin1 string.
24317 *
24318 * @return {WordArray} The word array.
24319 *
24320 * @static
24321 *
24322 * @example
24323 *
24324 * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
24325 */
24326 parse: function (latin1Str) {
24327 // Shortcut
24328 var latin1StrLength = latin1Str.length;
24329
24330 // Convert
24331 var words = [];
24332 for (var i = 0; i < latin1StrLength; i++) {
24333 words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
24334 }
24335
24336 return new WordArray.init(words, latin1StrLength);
24337 }
24338 };
24339
24340 /**
24341 * UTF-8 encoding strategy.
24342 */
24343 var Utf8 = C_enc.Utf8 = {
24344 /**
24345 * Converts a word array to a UTF-8 string.
24346 *
24347 * @param {WordArray} wordArray The word array.
24348 *
24349 * @return {string} The UTF-8 string.
24350 *
24351 * @static
24352 *
24353 * @example
24354 *
24355 * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
24356 */
24357 stringify: function (wordArray) {
24358 try {
24359 return decodeURIComponent(escape(Latin1.stringify(wordArray)));
24360 } catch (e) {
24361 throw new Error('Malformed UTF-8 data');
24362 }
24363 },
24364
24365 /**
24366 * Converts a UTF-8 string to a word array.
24367 *
24368 * @param {string} utf8Str The UTF-8 string.
24369 *
24370 * @return {WordArray} The word array.
24371 *
24372 * @static
24373 *
24374 * @example
24375 *
24376 * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
24377 */
24378 parse: function (utf8Str) {
24379 return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
24380 }
24381 };
24382
24383 /**
24384 * Abstract buffered block algorithm template.
24385 *
24386 * The property blockSize must be implemented in a concrete subtype.
24387 *
24388 * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
24389 */
24390 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
24391 /**
24392 * Resets this block algorithm's data buffer to its initial state.
24393 *
24394 * @example
24395 *
24396 * bufferedBlockAlgorithm.reset();
24397 */
24398 reset: function () {
24399 // Initial values
24400 this._data = new WordArray.init();
24401 this._nDataBytes = 0;
24402 },
24403
24404 /**
24405 * Adds new data to this block algorithm's buffer.
24406 *
24407 * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
24408 *
24409 * @example
24410 *
24411 * bufferedBlockAlgorithm._append('data');
24412 * bufferedBlockAlgorithm._append(wordArray);
24413 */
24414 _append: function (data) {
24415 // Convert string to WordArray, else assume WordArray already
24416 if (typeof data == 'string') {
24417 data = Utf8.parse(data);
24418 }
24419
24420 // Append
24421 this._data.concat(data);
24422 this._nDataBytes += data.sigBytes;
24423 },
24424
24425 /**
24426 * Processes available data blocks.
24427 *
24428 * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
24429 *
24430 * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
24431 *
24432 * @return {WordArray} The processed data.
24433 *
24434 * @example
24435 *
24436 * var processedData = bufferedBlockAlgorithm._process();
24437 * var processedData = bufferedBlockAlgorithm._process(!!'flush');
24438 */
24439 _process: function (doFlush) {
24440 // Shortcuts
24441 var data = this._data;
24442 var dataWords = data.words;
24443 var dataSigBytes = data.sigBytes;
24444 var blockSize = this.blockSize;
24445 var blockSizeBytes = blockSize * 4;
24446
24447 // Count blocks ready
24448 var nBlocksReady = dataSigBytes / blockSizeBytes;
24449 if (doFlush) {
24450 // Round up to include partial blocks
24451 nBlocksReady = Math.ceil(nBlocksReady);
24452 } else {
24453 // Round down to include only full blocks,
24454 // less the number of blocks that must remain in the buffer
24455 nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
24456 }
24457
24458 // Count words ready
24459 var nWordsReady = nBlocksReady * blockSize;
24460
24461 // Count bytes ready
24462 var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
24463
24464 // Process blocks
24465 if (nWordsReady) {
24466 for (var offset = 0; offset < nWordsReady; offset += blockSize) {
24467 // Perform concrete-algorithm logic
24468 this._doProcessBlock(dataWords, offset);
24469 }
24470
24471 // Remove processed words
24472 var processedWords = dataWords.splice(0, nWordsReady);
24473 data.sigBytes -= nBytesReady;
24474 }
24475
24476 // Return processed words
24477 return new WordArray.init(processedWords, nBytesReady);
24478 },
24479
24480 /**
24481 * Creates a copy of this object.
24482 *
24483 * @return {Object} The clone.
24484 *
24485 * @example
24486 *
24487 * var clone = bufferedBlockAlgorithm.clone();
24488 */
24489 clone: function () {
24490 var clone = Base.clone.call(this);
24491 clone._data = this._data.clone();
24492
24493 return clone;
24494 },
24495
24496 _minBufferSize: 0
24497 });
24498
24499 /**
24500 * Abstract hasher template.
24501 *
24502 * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
24503 */
24504 var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
24505 /**
24506 * Configuration options.
24507 */
24508 cfg: Base.extend(),
24509
24510 /**
24511 * Initializes a newly created hasher.
24512 *
24513 * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
24514 *
24515 * @example
24516 *
24517 * var hasher = CryptoJS.algo.SHA256.create();
24518 */
24519 init: function (cfg) {
24520 // Apply config defaults
24521 this.cfg = this.cfg.extend(cfg);
24522
24523 // Set initial values
24524 this.reset();
24525 },
24526
24527 /**
24528 * Resets this hasher to its initial state.
24529 *
24530 * @example
24531 *
24532 * hasher.reset();
24533 */
24534 reset: function () {
24535 // Reset data buffer
24536 BufferedBlockAlgorithm.reset.call(this);
24537
24538 // Perform concrete-hasher logic
24539 this._doReset();
24540 },
24541
24542 /**
24543 * Updates this hasher with a message.
24544 *
24545 * @param {WordArray|string} messageUpdate The message to append.
24546 *
24547 * @return {Hasher} This hasher.
24548 *
24549 * @example
24550 *
24551 * hasher.update('message');
24552 * hasher.update(wordArray);
24553 */
24554 update: function (messageUpdate) {
24555 // Append
24556 this._append(messageUpdate);
24557
24558 // Update the hash
24559 this._process();
24560
24561 // Chainable
24562 return this;
24563 },
24564
24565 /**
24566 * Finalizes the hash computation.
24567 * Note that the finalize operation is effectively a destructive, read-once operation.
24568 *
24569 * @param {WordArray|string} messageUpdate (Optional) A final message update.
24570 *
24571 * @return {WordArray} The hash.
24572 *
24573 * @example
24574 *
24575 * var hash = hasher.finalize();
24576 * var hash = hasher.finalize('message');
24577 * var hash = hasher.finalize(wordArray);
24578 */
24579 finalize: function (messageUpdate) {
24580 // Final message update
24581 if (messageUpdate) {
24582 this._append(messageUpdate);
24583 }
24584
24585 // Perform concrete-hasher logic
24586 var hash = this._doFinalize();
24587
24588 return hash;
24589 },
24590
24591 blockSize: 512/32,
24592
24593 /**
24594 * Creates a shortcut function to a hasher's object interface.
24595 *
24596 * @param {Hasher} hasher The hasher to create a helper for.
24597 *
24598 * @return {Function} The shortcut function.
24599 *
24600 * @static
24601 *
24602 * @example
24603 *
24604 * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
24605 */
24606 _createHelper: function (hasher) {
24607 return function (message, cfg) {
24608 return new hasher.init(cfg).finalize(message);
24609 };
24610 },
24611
24612 /**
24613 * Creates a shortcut function to the HMAC's object interface.
24614 *
24615 * @param {Hasher} hasher The hasher to use in this HMAC helper.
24616 *
24617 * @return {Function} The shortcut function.
24618 *
24619 * @static
24620 *
24621 * @example
24622 *
24623 * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
24624 */
24625 _createHmacHelper: function (hasher) {
24626 return function (message, key) {
24627 return new C_algo.HMAC.init(hasher, key).finalize(message);
24628 };
24629 }
24630 });
24631
24632 /**
24633 * Algorithm namespace.
24634 */
24635 var C_algo = C.algo = {};
24636
24637 return C;
24638 }(Math));
24639
24640
24641 return CryptoJS;
24642
24643 }));
24644 },{}],32:[function(_dereq_,module,exports){
24645 ;(function (root, factory) {
24646 if (typeof exports === "object") {
24647 // CommonJS
24648 module.exports = exports = factory(_dereq_("./core"));
24649 }
24650 else if (typeof define === "function" && define.amd) {
24651 // AMD
24652 define(["./core"], factory);
24653 }
24654 else {
24655 // Global (browser)
24656 factory(root.CryptoJS);
24657 }
24658 }(this, function (CryptoJS) {
24659
24660 (function () {
24661 // Shortcuts
24662 var C = CryptoJS;
24663 var C_lib = C.lib;
24664 var WordArray = C_lib.WordArray;
24665 var C_enc = C.enc;
24666
24667 /**
24668 * Base64 encoding strategy.
24669 */
24670 var Base64 = C_enc.Base64 = {
24671 /**
24672 * Converts a word array to a Base64 string.
24673 *
24674 * @param {WordArray} wordArray The word array.
24675 *
24676 * @return {string} The Base64 string.
24677 *
24678 * @static
24679 *
24680 * @example
24681 *
24682 * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
24683 */
24684 stringify: function (wordArray) {
24685 // Shortcuts
24686 var words = wordArray.words;
24687 var sigBytes = wordArray.sigBytes;
24688 var map = this._map;
24689
24690 // Clamp excess bits
24691 wordArray.clamp();
24692
24693 // Convert
24694 var base64Chars = [];
24695 for (var i = 0; i < sigBytes; i += 3) {
24696 var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24697 var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
24698 var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
24699
24700 var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
24701
24702 for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
24703 base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
24704 }
24705 }
24706
24707 // Add padding
24708 var paddingChar = map.charAt(64);
24709 if (paddingChar) {
24710 while (base64Chars.length % 4) {
24711 base64Chars.push(paddingChar);
24712 }
24713 }
24714
24715 return base64Chars.join('');
24716 },
24717
24718 /**
24719 * Converts a Base64 string to a word array.
24720 *
24721 * @param {string} base64Str The Base64 string.
24722 *
24723 * @return {WordArray} The word array.
24724 *
24725 * @static
24726 *
24727 * @example
24728 *
24729 * var wordArray = CryptoJS.enc.Base64.parse(base64String);
24730 */
24731 parse: function (base64Str) {
24732 // Shortcuts
24733 var base64StrLength = base64Str.length;
24734 var map = this._map;
24735
24736 // Ignore padding
24737 var paddingChar = map.charAt(64);
24738 if (paddingChar) {
24739 var paddingIndex = base64Str.indexOf(paddingChar);
24740 if (paddingIndex != -1) {
24741 base64StrLength = paddingIndex;
24742 }
24743 }
24744
24745 // Convert
24746 var words = [];
24747 var nBytes = 0;
24748 for (var i = 0; i < base64StrLength; i++) {
24749 if (i % 4) {
24750 var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2);
24751 var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2);
24752 words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
24753 nBytes++;
24754 }
24755 }
24756
24757 return WordArray.create(words, nBytes);
24758 },
24759
24760 _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
24761 };
24762 }());
24763
24764
24765 return CryptoJS.enc.Base64;
24766
24767 }));
24768 },{"./core":31}],33:[function(_dereq_,module,exports){
24769 ;(function (root, factory) {
24770 if (typeof exports === "object") {
24771 // CommonJS
24772 module.exports = exports = factory(_dereq_("./core"));
24773 }
24774 else if (typeof define === "function" && define.amd) {
24775 // AMD
24776 define(["./core"], factory);
24777 }
24778 else {
24779 // Global (browser)
24780 factory(root.CryptoJS);
24781 }
24782 }(this, function (CryptoJS) {
24783
24784 (function () {
24785 // Shortcuts
24786 var C = CryptoJS;
24787 var C_lib = C.lib;
24788 var WordArray = C_lib.WordArray;
24789 var C_enc = C.enc;
24790
24791 /**
24792 * UTF-16 BE encoding strategy.
24793 */
24794 var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
24795 /**
24796 * Converts a word array to a UTF-16 BE string.
24797 *
24798 * @param {WordArray} wordArray The word array.
24799 *
24800 * @return {string} The UTF-16 BE string.
24801 *
24802 * @static
24803 *
24804 * @example
24805 *
24806 * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
24807 */
24808 stringify: function (wordArray) {
24809 // Shortcuts
24810 var words = wordArray.words;
24811 var sigBytes = wordArray.sigBytes;
24812
24813 // Convert
24814 var utf16Chars = [];
24815 for (var i = 0; i < sigBytes; i += 2) {
24816 var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
24817 utf16Chars.push(String.fromCharCode(codePoint));
24818 }
24819
24820 return utf16Chars.join('');
24821 },
24822
24823 /**
24824 * Converts a UTF-16 BE string to a word array.
24825 *
24826 * @param {string} utf16Str The UTF-16 BE string.
24827 *
24828 * @return {WordArray} The word array.
24829 *
24830 * @static
24831 *
24832 * @example
24833 *
24834 * var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
24835 */
24836 parse: function (utf16Str) {
24837 // Shortcut
24838 var utf16StrLength = utf16Str.length;
24839
24840 // Convert
24841 var words = [];
24842 for (var i = 0; i < utf16StrLength; i++) {
24843 words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
24844 }
24845
24846 return WordArray.create(words, utf16StrLength * 2);
24847 }
24848 };
24849
24850 /**
24851 * UTF-16 LE encoding strategy.
24852 */
24853 C_enc.Utf16LE = {
24854 /**
24855 * Converts a word array to a UTF-16 LE string.
24856 *
24857 * @param {WordArray} wordArray The word array.
24858 *
24859 * @return {string} The UTF-16 LE string.
24860 *
24861 * @static
24862 *
24863 * @example
24864 *
24865 * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
24866 */
24867 stringify: function (wordArray) {
24868 // Shortcuts
24869 var words = wordArray.words;
24870 var sigBytes = wordArray.sigBytes;
24871
24872 // Convert
24873 var utf16Chars = [];
24874 for (var i = 0; i < sigBytes; i += 2) {
24875 var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
24876 utf16Chars.push(String.fromCharCode(codePoint));
24877 }
24878
24879 return utf16Chars.join('');
24880 },
24881
24882 /**
24883 * Converts a UTF-16 LE string to a word array.
24884 *
24885 * @param {string} utf16Str The UTF-16 LE string.
24886 *
24887 * @return {WordArray} The word array.
24888 *
24889 * @static
24890 *
24891 * @example
24892 *
24893 * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
24894 */
24895 parse: function (utf16Str) {
24896 // Shortcut
24897 var utf16StrLength = utf16Str.length;
24898
24899 // Convert
24900 var words = [];
24901 for (var i = 0; i < utf16StrLength; i++) {
24902 words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
24903 }
24904
24905 return WordArray.create(words, utf16StrLength * 2);
24906 }
24907 };
24908
24909 function swapEndian(word) {
24910 return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
24911 }
24912 }());
24913
24914
24915 return CryptoJS.enc.Utf16;
24916
24917 }));
24918 },{"./core":31}],34:[function(_dereq_,module,exports){
24919 ;(function (root, factory, undef) {
24920 if (typeof exports === "object") {
24921 // CommonJS
24922 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
24923 }
24924 else if (typeof define === "function" && define.amd) {
24925 // AMD
24926 define(["./core", "./sha1", "./hmac"], factory);
24927 }
24928 else {
24929 // Global (browser)
24930 factory(root.CryptoJS);
24931 }
24932 }(this, function (CryptoJS) {
24933
24934 (function () {
24935 // Shortcuts
24936 var C = CryptoJS;
24937 var C_lib = C.lib;
24938 var Base = C_lib.Base;
24939 var WordArray = C_lib.WordArray;
24940 var C_algo = C.algo;
24941 var MD5 = C_algo.MD5;
24942
24943 /**
24944 * This key derivation function is meant to conform with EVP_BytesToKey.
24945 * www.openssl.org/docs/crypto/EVP_BytesToKey.html
24946 */
24947 var EvpKDF = C_algo.EvpKDF = Base.extend({
24948 /**
24949 * Configuration options.
24950 *
24951 * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
24952 * @property {Hasher} hasher The hash algorithm to use. Default: MD5
24953 * @property {number} iterations The number of iterations to perform. Default: 1
24954 */
24955 cfg: Base.extend({
24956 keySize: 128/32,
24957 hasher: MD5,
24958 iterations: 1
24959 }),
24960
24961 /**
24962 * Initializes a newly created key derivation function.
24963 *
24964 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
24965 *
24966 * @example
24967 *
24968 * var kdf = CryptoJS.algo.EvpKDF.create();
24969 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
24970 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
24971 */
24972 init: function (cfg) {
24973 this.cfg = this.cfg.extend(cfg);
24974 },
24975
24976 /**
24977 * Derives a key from a password.
24978 *
24979 * @param {WordArray|string} password The password.
24980 * @param {WordArray|string} salt A salt.
24981 *
24982 * @return {WordArray} The derived key.
24983 *
24984 * @example
24985 *
24986 * var key = kdf.compute(password, salt);
24987 */
24988 compute: function (password, salt) {
24989 // Shortcut
24990 var cfg = this.cfg;
24991
24992 // Init hasher
24993 var hasher = cfg.hasher.create();
24994
24995 // Initial values
24996 var derivedKey = WordArray.create();
24997
24998 // Shortcuts
24999 var derivedKeyWords = derivedKey.words;
25000 var keySize = cfg.keySize;
25001 var iterations = cfg.iterations;
25002
25003 // Generate key
25004 while (derivedKeyWords.length < keySize) {
25005 if (block) {
25006 hasher.update(block);
25007 }
25008 var block = hasher.update(password).finalize(salt);
25009 hasher.reset();
25010
25011 // Iterations
25012 for (var i = 1; i < iterations; i++) {
25013 block = hasher.finalize(block);
25014 hasher.reset();
25015 }
25016
25017 derivedKey.concat(block);
25018 }
25019 derivedKey.sigBytes = keySize * 4;
25020
25021 return derivedKey;
25022 }
25023 });
25024
25025 /**
25026 * Derives a key from a password.
25027 *
25028 * @param {WordArray|string} password The password.
25029 * @param {WordArray|string} salt A salt.
25030 * @param {Object} cfg (Optional) The configuration options to use for this computation.
25031 *
25032 * @return {WordArray} The derived key.
25033 *
25034 * @static
25035 *
25036 * @example
25037 *
25038 * var key = CryptoJS.EvpKDF(password, salt);
25039 * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
25040 * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
25041 */
25042 C.EvpKDF = function (password, salt, cfg) {
25043 return EvpKDF.create(cfg).compute(password, salt);
25044 };
25045 }());
25046
25047
25048 return CryptoJS.EvpKDF;
25049
25050 }));
25051 },{"./core":31,"./hmac":36,"./sha1":55}],35:[function(_dereq_,module,exports){
25052 ;(function (root, factory, undef) {
25053 if (typeof exports === "object") {
25054 // CommonJS
25055 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25056 }
25057 else if (typeof define === "function" && define.amd) {
25058 // AMD
25059 define(["./core", "./cipher-core"], factory);
25060 }
25061 else {
25062 // Global (browser)
25063 factory(root.CryptoJS);
25064 }
25065 }(this, function (CryptoJS) {
25066
25067 (function (undefined) {
25068 // Shortcuts
25069 var C = CryptoJS;
25070 var C_lib = C.lib;
25071 var CipherParams = C_lib.CipherParams;
25072 var C_enc = C.enc;
25073 var Hex = C_enc.Hex;
25074 var C_format = C.format;
25075
25076 var HexFormatter = C_format.Hex = {
25077 /**
25078 * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
25079 *
25080 * @param {CipherParams} cipherParams The cipher params object.
25081 *
25082 * @return {string} The hexadecimally encoded string.
25083 *
25084 * @static
25085 *
25086 * @example
25087 *
25088 * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
25089 */
25090 stringify: function (cipherParams) {
25091 return cipherParams.ciphertext.toString(Hex);
25092 },
25093
25094 /**
25095 * Converts a hexadecimally encoded ciphertext string to a cipher params object.
25096 *
25097 * @param {string} input The hexadecimally encoded string.
25098 *
25099 * @return {CipherParams} The cipher params object.
25100 *
25101 * @static
25102 *
25103 * @example
25104 *
25105 * var cipherParams = CryptoJS.format.Hex.parse(hexString);
25106 */
25107 parse: function (input) {
25108 var ciphertext = Hex.parse(input);
25109 return CipherParams.create({ ciphertext: ciphertext });
25110 }
25111 };
25112 }());
25113
25114
25115 return CryptoJS.format.Hex;
25116
25117 }));
25118 },{"./cipher-core":30,"./core":31}],36:[function(_dereq_,module,exports){
25119 ;(function (root, factory) {
25120 if (typeof exports === "object") {
25121 // CommonJS
25122 module.exports = exports = factory(_dereq_("./core"));
25123 }
25124 else if (typeof define === "function" && define.amd) {
25125 // AMD
25126 define(["./core"], factory);
25127 }
25128 else {
25129 // Global (browser)
25130 factory(root.CryptoJS);
25131 }
25132 }(this, function (CryptoJS) {
25133
25134 (function () {
25135 // Shortcuts
25136 var C = CryptoJS;
25137 var C_lib = C.lib;
25138 var Base = C_lib.Base;
25139 var C_enc = C.enc;
25140 var Utf8 = C_enc.Utf8;
25141 var C_algo = C.algo;
25142
25143 /**
25144 * HMAC algorithm.
25145 */
25146 var HMAC = C_algo.HMAC = Base.extend({
25147 /**
25148 * Initializes a newly created HMAC.
25149 *
25150 * @param {Hasher} hasher The hash algorithm to use.
25151 * @param {WordArray|string} key The secret key.
25152 *
25153 * @example
25154 *
25155 * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
25156 */
25157 init: function (hasher, key) {
25158 // Init hasher
25159 hasher = this._hasher = new hasher.init();
25160
25161 // Convert string to WordArray, else assume WordArray already
25162 if (typeof key == 'string') {
25163 key = Utf8.parse(key);
25164 }
25165
25166 // Shortcuts
25167 var hasherBlockSize = hasher.blockSize;
25168 var hasherBlockSizeBytes = hasherBlockSize * 4;
25169
25170 // Allow arbitrary length keys
25171 if (key.sigBytes > hasherBlockSizeBytes) {
25172 key = hasher.finalize(key);
25173 }
25174
25175 // Clamp excess bits
25176 key.clamp();
25177
25178 // Clone key for inner and outer pads
25179 var oKey = this._oKey = key.clone();
25180 var iKey = this._iKey = key.clone();
25181
25182 // Shortcuts
25183 var oKeyWords = oKey.words;
25184 var iKeyWords = iKey.words;
25185
25186 // XOR keys with pad constants
25187 for (var i = 0; i < hasherBlockSize; i++) {
25188 oKeyWords[i] ^= 0x5c5c5c5c;
25189 iKeyWords[i] ^= 0x36363636;
25190 }
25191 oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
25192
25193 // Set initial values
25194 this.reset();
25195 },
25196
25197 /**
25198 * Resets this HMAC to its initial state.
25199 *
25200 * @example
25201 *
25202 * hmacHasher.reset();
25203 */
25204 reset: function () {
25205 // Shortcut
25206 var hasher = this._hasher;
25207
25208 // Reset
25209 hasher.reset();
25210 hasher.update(this._iKey);
25211 },
25212
25213 /**
25214 * Updates this HMAC with a message.
25215 *
25216 * @param {WordArray|string} messageUpdate The message to append.
25217 *
25218 * @return {HMAC} This HMAC instance.
25219 *
25220 * @example
25221 *
25222 * hmacHasher.update('message');
25223 * hmacHasher.update(wordArray);
25224 */
25225 update: function (messageUpdate) {
25226 this._hasher.update(messageUpdate);
25227
25228 // Chainable
25229 return this;
25230 },
25231
25232 /**
25233 * Finalizes the HMAC computation.
25234 * Note that the finalize operation is effectively a destructive, read-once operation.
25235 *
25236 * @param {WordArray|string} messageUpdate (Optional) A final message update.
25237 *
25238 * @return {WordArray} The HMAC.
25239 *
25240 * @example
25241 *
25242 * var hmac = hmacHasher.finalize();
25243 * var hmac = hmacHasher.finalize('message');
25244 * var hmac = hmacHasher.finalize(wordArray);
25245 */
25246 finalize: function (messageUpdate) {
25247 // Shortcut
25248 var hasher = this._hasher;
25249
25250 // Compute HMAC
25251 var innerHash = hasher.finalize(messageUpdate);
25252 hasher.reset();
25253 var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
25254
25255 return hmac;
25256 }
25257 });
25258 }());
25259
25260
25261 }));
25262 },{"./core":31}],37:[function(_dereq_,module,exports){
25263 ;(function (root, factory, undef) {
25264 if (typeof exports === "object") {
25265 // CommonJS
25266 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"));
25267 }
25268 else if (typeof define === "function" && define.amd) {
25269 // AMD
25270 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);
25271 }
25272 else {
25273 // Global (browser)
25274 factory(root.CryptoJS);
25275 }
25276 }(this, function (CryptoJS) {
25277
25278 return CryptoJS;
25279
25280 }));
25281 },{"./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){
25282 ;(function (root, factory) {
25283 if (typeof exports === "object") {
25284 // CommonJS
25285 module.exports = exports = factory(_dereq_("./core"));
25286 }
25287 else if (typeof define === "function" && define.amd) {
25288 // AMD
25289 define(["./core"], factory);
25290 }
25291 else {
25292 // Global (browser)
25293 factory(root.CryptoJS);
25294 }
25295 }(this, function (CryptoJS) {
25296
25297 (function () {
25298 // Check if typed arrays are supported
25299 if (typeof ArrayBuffer != 'function') {
25300 return;
25301 }
25302
25303 // Shortcuts
25304 var C = CryptoJS;
25305 var C_lib = C.lib;
25306 var WordArray = C_lib.WordArray;
25307
25308 // Reference original init
25309 var superInit = WordArray.init;
25310
25311 // Augment WordArray.init to handle typed arrays
25312 var subInit = WordArray.init = function (typedArray) {
25313 // Convert buffers to uint8
25314 if (typedArray instanceof ArrayBuffer) {
25315 typedArray = new Uint8Array(typedArray);
25316 }
25317
25318 // Convert other array views to uint8
25319 if (
25320 typedArray instanceof Int8Array ||
25321 typedArray instanceof Uint8ClampedArray ||
25322 typedArray instanceof Int16Array ||
25323 typedArray instanceof Uint16Array ||
25324 typedArray instanceof Int32Array ||
25325 typedArray instanceof Uint32Array ||
25326 typedArray instanceof Float32Array ||
25327 typedArray instanceof Float64Array
25328 ) {
25329 typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
25330 }
25331
25332 // Handle Uint8Array
25333 if (typedArray instanceof Uint8Array) {
25334 // Shortcut
25335 var typedArrayByteLength = typedArray.byteLength;
25336
25337 // Extract bytes
25338 var words = [];
25339 for (var i = 0; i < typedArrayByteLength; i++) {
25340 words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
25341 }
25342
25343 // Initialize this word array
25344 superInit.call(this, words, typedArrayByteLength);
25345 } else {
25346 // Else call normal init
25347 superInit.apply(this, arguments);
25348 }
25349 };
25350
25351 subInit.prototype = WordArray;
25352 }());
25353
25354
25355 return CryptoJS.lib.WordArray;
25356
25357 }));
25358 },{"./core":31}],39:[function(_dereq_,module,exports){
25359 ;(function (root, factory) {
25360 if (typeof exports === "object") {
25361 // CommonJS
25362 module.exports = exports = factory(_dereq_("./core"));
25363 }
25364 else if (typeof define === "function" && define.amd) {
25365 // AMD
25366 define(["./core"], factory);
25367 }
25368 else {
25369 // Global (browser)
25370 factory(root.CryptoJS);
25371 }
25372 }(this, function (CryptoJS) {
25373
25374 (function (Math) {
25375 // Shortcuts
25376 var C = CryptoJS;
25377 var C_lib = C.lib;
25378 var WordArray = C_lib.WordArray;
25379 var Hasher = C_lib.Hasher;
25380 var C_algo = C.algo;
25381
25382 // Constants table
25383 var T = [];
25384
25385 // Compute constants
25386 (function () {
25387 for (var i = 0; i < 64; i++) {
25388 T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
25389 }
25390 }());
25391
25392 /**
25393 * MD5 hash algorithm.
25394 */
25395 var MD5 = C_algo.MD5 = Hasher.extend({
25396 _doReset: function () {
25397 this._hash = new WordArray.init([
25398 0x67452301, 0xefcdab89,
25399 0x98badcfe, 0x10325476
25400 ]);
25401 },
25402
25403 _doProcessBlock: function (M, offset) {
25404 // Swap endian
25405 for (var i = 0; i < 16; i++) {
25406 // Shortcuts
25407 var offset_i = offset + i;
25408 var M_offset_i = M[offset_i];
25409
25410 M[offset_i] = (
25411 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
25412 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
25413 );
25414 }
25415
25416 // Shortcuts
25417 var H = this._hash.words;
25418
25419 var M_offset_0 = M[offset + 0];
25420 var M_offset_1 = M[offset + 1];
25421 var M_offset_2 = M[offset + 2];
25422 var M_offset_3 = M[offset + 3];
25423 var M_offset_4 = M[offset + 4];
25424 var M_offset_5 = M[offset + 5];
25425 var M_offset_6 = M[offset + 6];
25426 var M_offset_7 = M[offset + 7];
25427 var M_offset_8 = M[offset + 8];
25428 var M_offset_9 = M[offset + 9];
25429 var M_offset_10 = M[offset + 10];
25430 var M_offset_11 = M[offset + 11];
25431 var M_offset_12 = M[offset + 12];
25432 var M_offset_13 = M[offset + 13];
25433 var M_offset_14 = M[offset + 14];
25434 var M_offset_15 = M[offset + 15];
25435
25436 // Working varialbes
25437 var a = H[0];
25438 var b = H[1];
25439 var c = H[2];
25440 var d = H[3];
25441
25442 // Computation
25443 a = FF(a, b, c, d, M_offset_0, 7, T[0]);
25444 d = FF(d, a, b, c, M_offset_1, 12, T[1]);
25445 c = FF(c, d, a, b, M_offset_2, 17, T[2]);
25446 b = FF(b, c, d, a, M_offset_3, 22, T[3]);
25447 a = FF(a, b, c, d, M_offset_4, 7, T[4]);
25448 d = FF(d, a, b, c, M_offset_5, 12, T[5]);
25449 c = FF(c, d, a, b, M_offset_6, 17, T[6]);
25450 b = FF(b, c, d, a, M_offset_7, 22, T[7]);
25451 a = FF(a, b, c, d, M_offset_8, 7, T[8]);
25452 d = FF(d, a, b, c, M_offset_9, 12, T[9]);
25453 c = FF(c, d, a, b, M_offset_10, 17, T[10]);
25454 b = FF(b, c, d, a, M_offset_11, 22, T[11]);
25455 a = FF(a, b, c, d, M_offset_12, 7, T[12]);
25456 d = FF(d, a, b, c, M_offset_13, 12, T[13]);
25457 c = FF(c, d, a, b, M_offset_14, 17, T[14]);
25458 b = FF(b, c, d, a, M_offset_15, 22, T[15]);
25459
25460 a = GG(a, b, c, d, M_offset_1, 5, T[16]);
25461 d = GG(d, a, b, c, M_offset_6, 9, T[17]);
25462 c = GG(c, d, a, b, M_offset_11, 14, T[18]);
25463 b = GG(b, c, d, a, M_offset_0, 20, T[19]);
25464 a = GG(a, b, c, d, M_offset_5, 5, T[20]);
25465 d = GG(d, a, b, c, M_offset_10, 9, T[21]);
25466 c = GG(c, d, a, b, M_offset_15, 14, T[22]);
25467 b = GG(b, c, d, a, M_offset_4, 20, T[23]);
25468 a = GG(a, b, c, d, M_offset_9, 5, T[24]);
25469 d = GG(d, a, b, c, M_offset_14, 9, T[25]);
25470 c = GG(c, d, a, b, M_offset_3, 14, T[26]);
25471 b = GG(b, c, d, a, M_offset_8, 20, T[27]);
25472 a = GG(a, b, c, d, M_offset_13, 5, T[28]);
25473 d = GG(d, a, b, c, M_offset_2, 9, T[29]);
25474 c = GG(c, d, a, b, M_offset_7, 14, T[30]);
25475 b = GG(b, c, d, a, M_offset_12, 20, T[31]);
25476
25477 a = HH(a, b, c, d, M_offset_5, 4, T[32]);
25478 d = HH(d, a, b, c, M_offset_8, 11, T[33]);
25479 c = HH(c, d, a, b, M_offset_11, 16, T[34]);
25480 b = HH(b, c, d, a, M_offset_14, 23, T[35]);
25481 a = HH(a, b, c, d, M_offset_1, 4, T[36]);
25482 d = HH(d, a, b, c, M_offset_4, 11, T[37]);
25483 c = HH(c, d, a, b, M_offset_7, 16, T[38]);
25484 b = HH(b, c, d, a, M_offset_10, 23, T[39]);
25485 a = HH(a, b, c, d, M_offset_13, 4, T[40]);
25486 d = HH(d, a, b, c, M_offset_0, 11, T[41]);
25487 c = HH(c, d, a, b, M_offset_3, 16, T[42]);
25488 b = HH(b, c, d, a, M_offset_6, 23, T[43]);
25489 a = HH(a, b, c, d, M_offset_9, 4, T[44]);
25490 d = HH(d, a, b, c, M_offset_12, 11, T[45]);
25491 c = HH(c, d, a, b, M_offset_15, 16, T[46]);
25492 b = HH(b, c, d, a, M_offset_2, 23, T[47]);
25493
25494 a = II(a, b, c, d, M_offset_0, 6, T[48]);
25495 d = II(d, a, b, c, M_offset_7, 10, T[49]);
25496 c = II(c, d, a, b, M_offset_14, 15, T[50]);
25497 b = II(b, c, d, a, M_offset_5, 21, T[51]);
25498 a = II(a, b, c, d, M_offset_12, 6, T[52]);
25499 d = II(d, a, b, c, M_offset_3, 10, T[53]);
25500 c = II(c, d, a, b, M_offset_10, 15, T[54]);
25501 b = II(b, c, d, a, M_offset_1, 21, T[55]);
25502 a = II(a, b, c, d, M_offset_8, 6, T[56]);
25503 d = II(d, a, b, c, M_offset_15, 10, T[57]);
25504 c = II(c, d, a, b, M_offset_6, 15, T[58]);
25505 b = II(b, c, d, a, M_offset_13, 21, T[59]);
25506 a = II(a, b, c, d, M_offset_4, 6, T[60]);
25507 d = II(d, a, b, c, M_offset_11, 10, T[61]);
25508 c = II(c, d, a, b, M_offset_2, 15, T[62]);
25509 b = II(b, c, d, a, M_offset_9, 21, T[63]);
25510
25511 // Intermediate hash value
25512 H[0] = (H[0] + a) | 0;
25513 H[1] = (H[1] + b) | 0;
25514 H[2] = (H[2] + c) | 0;
25515 H[3] = (H[3] + d) | 0;
25516 },
25517
25518 _doFinalize: function () {
25519 // Shortcuts
25520 var data = this._data;
25521 var dataWords = data.words;
25522
25523 var nBitsTotal = this._nDataBytes * 8;
25524 var nBitsLeft = data.sigBytes * 8;
25525
25526 // Add padding
25527 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
25528
25529 var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
25530 var nBitsTotalL = nBitsTotal;
25531 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
25532 (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
25533 (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
25534 );
25535 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
25536 (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
25537 (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
25538 );
25539
25540 data.sigBytes = (dataWords.length + 1) * 4;
25541
25542 // Hash final blocks
25543 this._process();
25544
25545 // Shortcuts
25546 var hash = this._hash;
25547 var H = hash.words;
25548
25549 // Swap endian
25550 for (var i = 0; i < 4; i++) {
25551 // Shortcut
25552 var H_i = H[i];
25553
25554 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
25555 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
25556 }
25557
25558 // Return final computed hash
25559 return hash;
25560 },
25561
25562 clone: function () {
25563 var clone = Hasher.clone.call(this);
25564 clone._hash = this._hash.clone();
25565
25566 return clone;
25567 }
25568 });
25569
25570 function FF(a, b, c, d, x, s, t) {
25571 var n = a + ((b & c) | (~b & d)) + x + t;
25572 return ((n << s) | (n >>> (32 - s))) + b;
25573 }
25574
25575 function GG(a, b, c, d, x, s, t) {
25576 var n = a + ((b & d) | (c & ~d)) + x + t;
25577 return ((n << s) | (n >>> (32 - s))) + b;
25578 }
25579
25580 function HH(a, b, c, d, x, s, t) {
25581 var n = a + (b ^ c ^ d) + x + t;
25582 return ((n << s) | (n >>> (32 - s))) + b;
25583 }
25584
25585 function II(a, b, c, d, x, s, t) {
25586 var n = a + (c ^ (b | ~d)) + x + t;
25587 return ((n << s) | (n >>> (32 - s))) + b;
25588 }
25589
25590 /**
25591 * Shortcut function to the hasher's object interface.
25592 *
25593 * @param {WordArray|string} message The message to hash.
25594 *
25595 * @return {WordArray} The hash.
25596 *
25597 * @static
25598 *
25599 * @example
25600 *
25601 * var hash = CryptoJS.MD5('message');
25602 * var hash = CryptoJS.MD5(wordArray);
25603 */
25604 C.MD5 = Hasher._createHelper(MD5);
25605
25606 /**
25607 * Shortcut function to the HMAC's object interface.
25608 *
25609 * @param {WordArray|string} message The message to hash.
25610 * @param {WordArray|string} key The secret key.
25611 *
25612 * @return {WordArray} The HMAC.
25613 *
25614 * @static
25615 *
25616 * @example
25617 *
25618 * var hmac = CryptoJS.HmacMD5(message, key);
25619 */
25620 C.HmacMD5 = Hasher._createHmacHelper(MD5);
25621 }(Math));
25622
25623
25624 return CryptoJS.MD5;
25625
25626 }));
25627 },{"./core":31}],40:[function(_dereq_,module,exports){
25628 ;(function (root, factory, undef) {
25629 if (typeof exports === "object") {
25630 // CommonJS
25631 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25632 }
25633 else if (typeof define === "function" && define.amd) {
25634 // AMD
25635 define(["./core", "./cipher-core"], factory);
25636 }
25637 else {
25638 // Global (browser)
25639 factory(root.CryptoJS);
25640 }
25641 }(this, function (CryptoJS) {
25642
25643 /**
25644 * Cipher Feedback block mode.
25645 */
25646 CryptoJS.mode.CFB = (function () {
25647 var CFB = CryptoJS.lib.BlockCipherMode.extend();
25648
25649 CFB.Encryptor = CFB.extend({
25650 processBlock: function (words, offset) {
25651 // Shortcuts
25652 var cipher = this._cipher;
25653 var blockSize = cipher.blockSize;
25654
25655 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
25656
25657 // Remember this block to use with next block
25658 this._prevBlock = words.slice(offset, offset + blockSize);
25659 }
25660 });
25661
25662 CFB.Decryptor = CFB.extend({
25663 processBlock: function (words, offset) {
25664 // Shortcuts
25665 var cipher = this._cipher;
25666 var blockSize = cipher.blockSize;
25667
25668 // Remember this block to use with next block
25669 var thisBlock = words.slice(offset, offset + blockSize);
25670
25671 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
25672
25673 // This block becomes the previous block
25674 this._prevBlock = thisBlock;
25675 }
25676 });
25677
25678 function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
25679 // Shortcut
25680 var iv = this._iv;
25681
25682 // Generate keystream
25683 if (iv) {
25684 var keystream = iv.slice(0);
25685
25686 // Remove IV for subsequent blocks
25687 this._iv = undefined;
25688 } else {
25689 var keystream = this._prevBlock;
25690 }
25691 cipher.encryptBlock(keystream, 0);
25692
25693 // Encrypt
25694 for (var i = 0; i < blockSize; i++) {
25695 words[offset + i] ^= keystream[i];
25696 }
25697 }
25698
25699 return CFB;
25700 }());
25701
25702
25703 return CryptoJS.mode.CFB;
25704
25705 }));
25706 },{"./cipher-core":30,"./core":31}],41:[function(_dereq_,module,exports){
25707 ;(function (root, factory, undef) {
25708 if (typeof exports === "object") {
25709 // CommonJS
25710 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25711 }
25712 else if (typeof define === "function" && define.amd) {
25713 // AMD
25714 define(["./core", "./cipher-core"], factory);
25715 }
25716 else {
25717 // Global (browser)
25718 factory(root.CryptoJS);
25719 }
25720 }(this, function (CryptoJS) {
25721
25722 /** @preserve
25723 * Counter block mode compatible with Dr Brian Gladman fileenc.c
25724 * derived from CryptoJS.mode.CTR
25725 * Jan Hruby jhruby.web@gmail.com
25726 */
25727 CryptoJS.mode.CTRGladman = (function () {
25728 var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
25729
25730 function incWord(word)
25731 {
25732 if (((word >> 24) & 0xff) === 0xff) { //overflow
25733 var b1 = (word >> 16)&0xff;
25734 var b2 = (word >> 8)&0xff;
25735 var b3 = word & 0xff;
25736
25737 if (b1 === 0xff) // overflow b1
25738 {
25739 b1 = 0;
25740 if (b2 === 0xff)
25741 {
25742 b2 = 0;
25743 if (b3 === 0xff)
25744 {
25745 b3 = 0;
25746 }
25747 else
25748 {
25749 ++b3;
25750 }
25751 }
25752 else
25753 {
25754 ++b2;
25755 }
25756 }
25757 else
25758 {
25759 ++b1;
25760 }
25761
25762 word = 0;
25763 word += (b1 << 16);
25764 word += (b2 << 8);
25765 word += b3;
25766 }
25767 else
25768 {
25769 word += (0x01 << 24);
25770 }
25771 return word;
25772 }
25773
25774 function incCounter(counter)
25775 {
25776 if ((counter[0] = incWord(counter[0])) === 0)
25777 {
25778 // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
25779 counter[1] = incWord(counter[1]);
25780 }
25781 return counter;
25782 }
25783
25784 var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
25785 processBlock: function (words, offset) {
25786 // Shortcuts
25787 var cipher = this._cipher
25788 var blockSize = cipher.blockSize;
25789 var iv = this._iv;
25790 var counter = this._counter;
25791
25792 // Generate keystream
25793 if (iv) {
25794 counter = this._counter = iv.slice(0);
25795
25796 // Remove IV for subsequent blocks
25797 this._iv = undefined;
25798 }
25799
25800 incCounter(counter);
25801
25802 var keystream = counter.slice(0);
25803 cipher.encryptBlock(keystream, 0);
25804
25805 // Encrypt
25806 for (var i = 0; i < blockSize; i++) {
25807 words[offset + i] ^= keystream[i];
25808 }
25809 }
25810 });
25811
25812 CTRGladman.Decryptor = Encryptor;
25813
25814 return CTRGladman;
25815 }());
25816
25817
25818
25819
25820 return CryptoJS.mode.CTRGladman;
25821
25822 }));
25823 },{"./cipher-core":30,"./core":31}],42:[function(_dereq_,module,exports){
25824 ;(function (root, factory, undef) {
25825 if (typeof exports === "object") {
25826 // CommonJS
25827 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25828 }
25829 else if (typeof define === "function" && define.amd) {
25830 // AMD
25831 define(["./core", "./cipher-core"], factory);
25832 }
25833 else {
25834 // Global (browser)
25835 factory(root.CryptoJS);
25836 }
25837 }(this, function (CryptoJS) {
25838
25839 /**
25840 * Counter block mode.
25841 */
25842 CryptoJS.mode.CTR = (function () {
25843 var CTR = CryptoJS.lib.BlockCipherMode.extend();
25844
25845 var Encryptor = CTR.Encryptor = CTR.extend({
25846 processBlock: function (words, offset) {
25847 // Shortcuts
25848 var cipher = this._cipher
25849 var blockSize = cipher.blockSize;
25850 var iv = this._iv;
25851 var counter = this._counter;
25852
25853 // Generate keystream
25854 if (iv) {
25855 counter = this._counter = iv.slice(0);
25856
25857 // Remove IV for subsequent blocks
25858 this._iv = undefined;
25859 }
25860 var keystream = counter.slice(0);
25861 cipher.encryptBlock(keystream, 0);
25862
25863 // Increment counter
25864 counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
25865
25866 // Encrypt
25867 for (var i = 0; i < blockSize; i++) {
25868 words[offset + i] ^= keystream[i];
25869 }
25870 }
25871 });
25872
25873 CTR.Decryptor = Encryptor;
25874
25875 return CTR;
25876 }());
25877
25878
25879 return CryptoJS.mode.CTR;
25880
25881 }));
25882 },{"./cipher-core":30,"./core":31}],43:[function(_dereq_,module,exports){
25883 ;(function (root, factory, undef) {
25884 if (typeof exports === "object") {
25885 // CommonJS
25886 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25887 }
25888 else if (typeof define === "function" && define.amd) {
25889 // AMD
25890 define(["./core", "./cipher-core"], factory);
25891 }
25892 else {
25893 // Global (browser)
25894 factory(root.CryptoJS);
25895 }
25896 }(this, function (CryptoJS) {
25897
25898 /**
25899 * Electronic Codebook block mode.
25900 */
25901 CryptoJS.mode.ECB = (function () {
25902 var ECB = CryptoJS.lib.BlockCipherMode.extend();
25903
25904 ECB.Encryptor = ECB.extend({
25905 processBlock: function (words, offset) {
25906 this._cipher.encryptBlock(words, offset);
25907 }
25908 });
25909
25910 ECB.Decryptor = ECB.extend({
25911 processBlock: function (words, offset) {
25912 this._cipher.decryptBlock(words, offset);
25913 }
25914 });
25915
25916 return ECB;
25917 }());
25918
25919
25920 return CryptoJS.mode.ECB;
25921
25922 }));
25923 },{"./cipher-core":30,"./core":31}],44:[function(_dereq_,module,exports){
25924 ;(function (root, factory, undef) {
25925 if (typeof exports === "object") {
25926 // CommonJS
25927 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25928 }
25929 else if (typeof define === "function" && define.amd) {
25930 // AMD
25931 define(["./core", "./cipher-core"], factory);
25932 }
25933 else {
25934 // Global (browser)
25935 factory(root.CryptoJS);
25936 }
25937 }(this, function (CryptoJS) {
25938
25939 /**
25940 * Output Feedback block mode.
25941 */
25942 CryptoJS.mode.OFB = (function () {
25943 var OFB = CryptoJS.lib.BlockCipherMode.extend();
25944
25945 var Encryptor = OFB.Encryptor = OFB.extend({
25946 processBlock: function (words, offset) {
25947 // Shortcuts
25948 var cipher = this._cipher
25949 var blockSize = cipher.blockSize;
25950 var iv = this._iv;
25951 var keystream = this._keystream;
25952
25953 // Generate keystream
25954 if (iv) {
25955 keystream = this._keystream = iv.slice(0);
25956
25957 // Remove IV for subsequent blocks
25958 this._iv = undefined;
25959 }
25960 cipher.encryptBlock(keystream, 0);
25961
25962 // Encrypt
25963 for (var i = 0; i < blockSize; i++) {
25964 words[offset + i] ^= keystream[i];
25965 }
25966 }
25967 });
25968
25969 OFB.Decryptor = Encryptor;
25970
25971 return OFB;
25972 }());
25973
25974
25975 return CryptoJS.mode.OFB;
25976
25977 }));
25978 },{"./cipher-core":30,"./core":31}],45:[function(_dereq_,module,exports){
25979 ;(function (root, factory, undef) {
25980 if (typeof exports === "object") {
25981 // CommonJS
25982 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25983 }
25984 else if (typeof define === "function" && define.amd) {
25985 // AMD
25986 define(["./core", "./cipher-core"], factory);
25987 }
25988 else {
25989 // Global (browser)
25990 factory(root.CryptoJS);
25991 }
25992 }(this, function (CryptoJS) {
25993
25994 /**
25995 * ANSI X.923 padding strategy.
25996 */
25997 CryptoJS.pad.AnsiX923 = {
25998 pad: function (data, blockSize) {
25999 // Shortcuts
26000 var dataSigBytes = data.sigBytes;
26001 var blockSizeBytes = blockSize * 4;
26002
26003 // Count padding bytes
26004 var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
26005
26006 // Compute last byte position
26007 var lastBytePos = dataSigBytes + nPaddingBytes - 1;
26008
26009 // Pad
26010 data.clamp();
26011 data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
26012 data.sigBytes += nPaddingBytes;
26013 },
26014
26015 unpad: function (data) {
26016 // Get number of padding bytes from last byte
26017 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
26018
26019 // Remove padding
26020 data.sigBytes -= nPaddingBytes;
26021 }
26022 };
26023
26024
26025 return CryptoJS.pad.Ansix923;
26026
26027 }));
26028 },{"./cipher-core":30,"./core":31}],46:[function(_dereq_,module,exports){
26029 ;(function (root, factory, undef) {
26030 if (typeof exports === "object") {
26031 // CommonJS
26032 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26033 }
26034 else if (typeof define === "function" && define.amd) {
26035 // AMD
26036 define(["./core", "./cipher-core"], factory);
26037 }
26038 else {
26039 // Global (browser)
26040 factory(root.CryptoJS);
26041 }
26042 }(this, function (CryptoJS) {
26043
26044 /**
26045 * ISO 10126 padding strategy.
26046 */
26047 CryptoJS.pad.Iso10126 = {
26048 pad: function (data, blockSize) {
26049 // Shortcut
26050 var blockSizeBytes = blockSize * 4;
26051
26052 // Count padding bytes
26053 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
26054
26055 // Pad
26056 data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
26057 concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
26058 },
26059
26060 unpad: function (data) {
26061 // Get number of padding bytes from last byte
26062 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
26063
26064 // Remove padding
26065 data.sigBytes -= nPaddingBytes;
26066 }
26067 };
26068
26069
26070 return CryptoJS.pad.Iso10126;
26071
26072 }));
26073 },{"./cipher-core":30,"./core":31}],47:[function(_dereq_,module,exports){
26074 ;(function (root, factory, undef) {
26075 if (typeof exports === "object") {
26076 // CommonJS
26077 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26078 }
26079 else if (typeof define === "function" && define.amd) {
26080 // AMD
26081 define(["./core", "./cipher-core"], factory);
26082 }
26083 else {
26084 // Global (browser)
26085 factory(root.CryptoJS);
26086 }
26087 }(this, function (CryptoJS) {
26088
26089 /**
26090 * ISO/IEC 9797-1 Padding Method 2.
26091 */
26092 CryptoJS.pad.Iso97971 = {
26093 pad: function (data, blockSize) {
26094 // Add 0x80 byte
26095 data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
26096
26097 // Zero pad the rest
26098 CryptoJS.pad.ZeroPadding.pad(data, blockSize);
26099 },
26100
26101 unpad: function (data) {
26102 // Remove zero padding
26103 CryptoJS.pad.ZeroPadding.unpad(data);
26104
26105 // Remove one more byte -- the 0x80 byte
26106 data.sigBytes--;
26107 }
26108 };
26109
26110
26111 return CryptoJS.pad.Iso97971;
26112
26113 }));
26114 },{"./cipher-core":30,"./core":31}],48:[function(_dereq_,module,exports){
26115 ;(function (root, factory, undef) {
26116 if (typeof exports === "object") {
26117 // CommonJS
26118 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26119 }
26120 else if (typeof define === "function" && define.amd) {
26121 // AMD
26122 define(["./core", "./cipher-core"], factory);
26123 }
26124 else {
26125 // Global (browser)
26126 factory(root.CryptoJS);
26127 }
26128 }(this, function (CryptoJS) {
26129
26130 /**
26131 * A noop padding strategy.
26132 */
26133 CryptoJS.pad.NoPadding = {
26134 pad: function () {
26135 },
26136
26137 unpad: function () {
26138 }
26139 };
26140
26141
26142 return CryptoJS.pad.NoPadding;
26143
26144 }));
26145 },{"./cipher-core":30,"./core":31}],49:[function(_dereq_,module,exports){
26146 ;(function (root, factory, undef) {
26147 if (typeof exports === "object") {
26148 // CommonJS
26149 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26150 }
26151 else if (typeof define === "function" && define.amd) {
26152 // AMD
26153 define(["./core", "./cipher-core"], factory);
26154 }
26155 else {
26156 // Global (browser)
26157 factory(root.CryptoJS);
26158 }
26159 }(this, function (CryptoJS) {
26160
26161 /**
26162 * Zero padding strategy.
26163 */
26164 CryptoJS.pad.ZeroPadding = {
26165 pad: function (data, blockSize) {
26166 // Shortcut
26167 var blockSizeBytes = blockSize * 4;
26168
26169 // Pad
26170 data.clamp();
26171 data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
26172 },
26173
26174 unpad: function (data) {
26175 // Shortcut
26176 var dataWords = data.words;
26177
26178 // Unpad
26179 var i = data.sigBytes - 1;
26180 while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
26181 i--;
26182 }
26183 data.sigBytes = i + 1;
26184 }
26185 };
26186
26187
26188 return CryptoJS.pad.ZeroPadding;
26189
26190 }));
26191 },{"./cipher-core":30,"./core":31}],50:[function(_dereq_,module,exports){
26192 ;(function (root, factory, undef) {
26193 if (typeof exports === "object") {
26194 // CommonJS
26195 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
26196 }
26197 else if (typeof define === "function" && define.amd) {
26198 // AMD
26199 define(["./core", "./sha1", "./hmac"], factory);
26200 }
26201 else {
26202 // Global (browser)
26203 factory(root.CryptoJS);
26204 }
26205 }(this, function (CryptoJS) {
26206
26207 (function () {
26208 // Shortcuts
26209 var C = CryptoJS;
26210 var C_lib = C.lib;
26211 var Base = C_lib.Base;
26212 var WordArray = C_lib.WordArray;
26213 var C_algo = C.algo;
26214 var SHA1 = C_algo.SHA1;
26215 var HMAC = C_algo.HMAC;
26216
26217 /**
26218 * Password-Based Key Derivation Function 2 algorithm.
26219 */
26220 var PBKDF2 = C_algo.PBKDF2 = Base.extend({
26221 /**
26222 * Configuration options.
26223 *
26224 * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
26225 * @property {Hasher} hasher The hasher to use. Default: SHA1
26226 * @property {number} iterations The number of iterations to perform. Default: 1
26227 */
26228 cfg: Base.extend({
26229 keySize: 128/32,
26230 hasher: SHA1,
26231 iterations: 1
26232 }),
26233
26234 /**
26235 * Initializes a newly created key derivation function.
26236 *
26237 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
26238 *
26239 * @example
26240 *
26241 * var kdf = CryptoJS.algo.PBKDF2.create();
26242 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
26243 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
26244 */
26245 init: function (cfg) {
26246 this.cfg = this.cfg.extend(cfg);
26247 },
26248
26249 /**
26250 * Computes the Password-Based Key Derivation Function 2.
26251 *
26252 * @param {WordArray|string} password The password.
26253 * @param {WordArray|string} salt A salt.
26254 *
26255 * @return {WordArray} The derived key.
26256 *
26257 * @example
26258 *
26259 * var key = kdf.compute(password, salt);
26260 */
26261 compute: function (password, salt) {
26262 // Shortcut
26263 var cfg = this.cfg;
26264
26265 // Init HMAC
26266 var hmac = HMAC.create(cfg.hasher, password);
26267
26268 // Initial values
26269 var derivedKey = WordArray.create();
26270 var blockIndex = WordArray.create([0x00000001]);
26271
26272 // Shortcuts
26273 var derivedKeyWords = derivedKey.words;
26274 var blockIndexWords = blockIndex.words;
26275 var keySize = cfg.keySize;
26276 var iterations = cfg.iterations;
26277
26278 // Generate key
26279 while (derivedKeyWords.length < keySize) {
26280 var block = hmac.update(salt).finalize(blockIndex);
26281 hmac.reset();
26282
26283 // Shortcuts
26284 var blockWords = block.words;
26285 var blockWordsLength = blockWords.length;
26286
26287 // Iterations
26288 var intermediate = block;
26289 for (var i = 1; i < iterations; i++) {
26290 intermediate = hmac.finalize(intermediate);
26291 hmac.reset();
26292
26293 // Shortcut
26294 var intermediateWords = intermediate.words;
26295
26296 // XOR intermediate with block
26297 for (var j = 0; j < blockWordsLength; j++) {
26298 blockWords[j] ^= intermediateWords[j];
26299 }
26300 }
26301
26302 derivedKey.concat(block);
26303 blockIndexWords[0]++;
26304 }
26305 derivedKey.sigBytes = keySize * 4;
26306
26307 return derivedKey;
26308 }
26309 });
26310
26311 /**
26312 * Computes the Password-Based Key Derivation Function 2.
26313 *
26314 * @param {WordArray|string} password The password.
26315 * @param {WordArray|string} salt A salt.
26316 * @param {Object} cfg (Optional) The configuration options to use for this computation.
26317 *
26318 * @return {WordArray} The derived key.
26319 *
26320 * @static
26321 *
26322 * @example
26323 *
26324 * var key = CryptoJS.PBKDF2(password, salt);
26325 * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
26326 * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
26327 */
26328 C.PBKDF2 = function (password, salt, cfg) {
26329 return PBKDF2.create(cfg).compute(password, salt);
26330 };
26331 }());
26332
26333
26334 return CryptoJS.PBKDF2;
26335
26336 }));
26337 },{"./core":31,"./hmac":36,"./sha1":55}],51:[function(_dereq_,module,exports){
26338 ;(function (root, factory, undef) {
26339 if (typeof exports === "object") {
26340 // CommonJS
26341 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26342 }
26343 else if (typeof define === "function" && define.amd) {
26344 // AMD
26345 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26346 }
26347 else {
26348 // Global (browser)
26349 factory(root.CryptoJS);
26350 }
26351 }(this, function (CryptoJS) {
26352
26353 (function () {
26354 // Shortcuts
26355 var C = CryptoJS;
26356 var C_lib = C.lib;
26357 var StreamCipher = C_lib.StreamCipher;
26358 var C_algo = C.algo;
26359
26360 // Reusable objects
26361 var S = [];
26362 var C_ = [];
26363 var G = [];
26364
26365 /**
26366 * Rabbit stream cipher algorithm.
26367 *
26368 * This is a legacy version that neglected to convert the key to little-endian.
26369 * This error doesn't affect the cipher's security,
26370 * but it does affect its compatibility with other implementations.
26371 */
26372 var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
26373 _doReset: function () {
26374 // Shortcuts
26375 var K = this._key.words;
26376 var iv = this.cfg.iv;
26377
26378 // Generate initial state values
26379 var X = this._X = [
26380 K[0], (K[3] << 16) | (K[2] >>> 16),
26381 K[1], (K[0] << 16) | (K[3] >>> 16),
26382 K[2], (K[1] << 16) | (K[0] >>> 16),
26383 K[3], (K[2] << 16) | (K[1] >>> 16)
26384 ];
26385
26386 // Generate initial counter values
26387 var C = this._C = [
26388 (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
26389 (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
26390 (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
26391 (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
26392 ];
26393
26394 // Carry bit
26395 this._b = 0;
26396
26397 // Iterate the system four times
26398 for (var i = 0; i < 4; i++) {
26399 nextState.call(this);
26400 }
26401
26402 // Modify the counters
26403 for (var i = 0; i < 8; i++) {
26404 C[i] ^= X[(i + 4) & 7];
26405 }
26406
26407 // IV setup
26408 if (iv) {
26409 // Shortcuts
26410 var IV = iv.words;
26411 var IV_0 = IV[0];
26412 var IV_1 = IV[1];
26413
26414 // Generate four subvectors
26415 var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
26416 var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
26417 var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
26418 var i3 = (i2 << 16) | (i0 & 0x0000ffff);
26419
26420 // Modify counter values
26421 C[0] ^= i0;
26422 C[1] ^= i1;
26423 C[2] ^= i2;
26424 C[3] ^= i3;
26425 C[4] ^= i0;
26426 C[5] ^= i1;
26427 C[6] ^= i2;
26428 C[7] ^= i3;
26429
26430 // Iterate the system four times
26431 for (var i = 0; i < 4; i++) {
26432 nextState.call(this);
26433 }
26434 }
26435 },
26436
26437 _doProcessBlock: function (M, offset) {
26438 // Shortcut
26439 var X = this._X;
26440
26441 // Iterate the system
26442 nextState.call(this);
26443
26444 // Generate four keystream words
26445 S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
26446 S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
26447 S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
26448 S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
26449
26450 for (var i = 0; i < 4; i++) {
26451 // Swap endian
26452 S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
26453 (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
26454
26455 // Encrypt
26456 M[offset + i] ^= S[i];
26457 }
26458 },
26459
26460 blockSize: 128/32,
26461
26462 ivSize: 64/32
26463 });
26464
26465 function nextState() {
26466 // Shortcuts
26467 var X = this._X;
26468 var C = this._C;
26469
26470 // Save old counter values
26471 for (var i = 0; i < 8; i++) {
26472 C_[i] = C[i];
26473 }
26474
26475 // Calculate new counter values
26476 C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
26477 C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
26478 C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
26479 C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
26480 C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
26481 C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
26482 C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
26483 C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
26484 this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
26485
26486 // Calculate the g-values
26487 for (var i = 0; i < 8; i++) {
26488 var gx = X[i] + C[i];
26489
26490 // Construct high and low argument for squaring
26491 var ga = gx & 0xffff;
26492 var gb = gx >>> 16;
26493
26494 // Calculate high and low result of squaring
26495 var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
26496 var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
26497
26498 // High XOR low
26499 G[i] = gh ^ gl;
26500 }
26501
26502 // Calculate new state values
26503 X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
26504 X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
26505 X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
26506 X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
26507 X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
26508 X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
26509 X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
26510 X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
26511 }
26512
26513 /**
26514 * Shortcut functions to the cipher's object interface.
26515 *
26516 * @example
26517 *
26518 * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
26519 * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
26520 */
26521 C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
26522 }());
26523
26524
26525 return CryptoJS.RabbitLegacy;
26526
26527 }));
26528 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],52:[function(_dereq_,module,exports){
26529 ;(function (root, factory, undef) {
26530 if (typeof exports === "object") {
26531 // CommonJS
26532 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26533 }
26534 else if (typeof define === "function" && define.amd) {
26535 // AMD
26536 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26537 }
26538 else {
26539 // Global (browser)
26540 factory(root.CryptoJS);
26541 }
26542 }(this, function (CryptoJS) {
26543
26544 (function () {
26545 // Shortcuts
26546 var C = CryptoJS;
26547 var C_lib = C.lib;
26548 var StreamCipher = C_lib.StreamCipher;
26549 var C_algo = C.algo;
26550
26551 // Reusable objects
26552 var S = [];
26553 var C_ = [];
26554 var G = [];
26555
26556 /**
26557 * Rabbit stream cipher algorithm
26558 */
26559 var Rabbit = C_algo.Rabbit = StreamCipher.extend({
26560 _doReset: function () {
26561 // Shortcuts
26562 var K = this._key.words;
26563 var iv = this.cfg.iv;
26564
26565 // Swap endian
26566 for (var i = 0; i < 4; i++) {
26567 K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) |
26568 (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00);
26569 }
26570
26571 // Generate initial state values
26572 var X = this._X = [
26573 K[0], (K[3] << 16) | (K[2] >>> 16),
26574 K[1], (K[0] << 16) | (K[3] >>> 16),
26575 K[2], (K[1] << 16) | (K[0] >>> 16),
26576 K[3], (K[2] << 16) | (K[1] >>> 16)
26577 ];
26578
26579 // Generate initial counter values
26580 var C = this._C = [
26581 (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
26582 (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
26583 (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
26584 (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
26585 ];
26586
26587 // Carry bit
26588 this._b = 0;
26589
26590 // Iterate the system four times
26591 for (var i = 0; i < 4; i++) {
26592 nextState.call(this);
26593 }
26594
26595 // Modify the counters
26596 for (var i = 0; i < 8; i++) {
26597 C[i] ^= X[(i + 4) & 7];
26598 }
26599
26600 // IV setup
26601 if (iv) {
26602 // Shortcuts
26603 var IV = iv.words;
26604 var IV_0 = IV[0];
26605 var IV_1 = IV[1];
26606
26607 // Generate four subvectors
26608 var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
26609 var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
26610 var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
26611 var i3 = (i2 << 16) | (i0 & 0x0000ffff);
26612
26613 // Modify counter values
26614 C[0] ^= i0;
26615 C[1] ^= i1;
26616 C[2] ^= i2;
26617 C[3] ^= i3;
26618 C[4] ^= i0;
26619 C[5] ^= i1;
26620 C[6] ^= i2;
26621 C[7] ^= i3;
26622
26623 // Iterate the system four times
26624 for (var i = 0; i < 4; i++) {
26625 nextState.call(this);
26626 }
26627 }
26628 },
26629
26630 _doProcessBlock: function (M, offset) {
26631 // Shortcut
26632 var X = this._X;
26633
26634 // Iterate the system
26635 nextState.call(this);
26636
26637 // Generate four keystream words
26638 S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
26639 S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
26640 S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
26641 S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
26642
26643 for (var i = 0; i < 4; i++) {
26644 // Swap endian
26645 S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
26646 (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
26647
26648 // Encrypt
26649 M[offset + i] ^= S[i];
26650 }
26651 },
26652
26653 blockSize: 128/32,
26654
26655 ivSize: 64/32
26656 });
26657
26658 function nextState() {
26659 // Shortcuts
26660 var X = this._X;
26661 var C = this._C;
26662
26663 // Save old counter values
26664 for (var i = 0; i < 8; i++) {
26665 C_[i] = C[i];
26666 }
26667
26668 // Calculate new counter values
26669 C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
26670 C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
26671 C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
26672 C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
26673 C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
26674 C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
26675 C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
26676 C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
26677 this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
26678
26679 // Calculate the g-values
26680 for (var i = 0; i < 8; i++) {
26681 var gx = X[i] + C[i];
26682
26683 // Construct high and low argument for squaring
26684 var ga = gx & 0xffff;
26685 var gb = gx >>> 16;
26686
26687 // Calculate high and low result of squaring
26688 var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
26689 var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
26690
26691 // High XOR low
26692 G[i] = gh ^ gl;
26693 }
26694
26695 // Calculate new state values
26696 X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
26697 X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
26698 X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
26699 X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
26700 X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
26701 X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
26702 X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
26703 X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
26704 }
26705
26706 /**
26707 * Shortcut functions to the cipher's object interface.
26708 *
26709 * @example
26710 *
26711 * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
26712 * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
26713 */
26714 C.Rabbit = StreamCipher._createHelper(Rabbit);
26715 }());
26716
26717
26718 return CryptoJS.Rabbit;
26719
26720 }));
26721 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],53:[function(_dereq_,module,exports){
26722 ;(function (root, factory, undef) {
26723 if (typeof exports === "object") {
26724 // CommonJS
26725 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26726 }
26727 else if (typeof define === "function" && define.amd) {
26728 // AMD
26729 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26730 }
26731 else {
26732 // Global (browser)
26733 factory(root.CryptoJS);
26734 }
26735 }(this, function (CryptoJS) {
26736
26737 (function () {
26738 // Shortcuts
26739 var C = CryptoJS;
26740 var C_lib = C.lib;
26741 var StreamCipher = C_lib.StreamCipher;
26742 var C_algo = C.algo;
26743
26744 /**
26745 * RC4 stream cipher algorithm.
26746 */
26747 var RC4 = C_algo.RC4 = StreamCipher.extend({
26748 _doReset: function () {
26749 // Shortcuts
26750 var key = this._key;
26751 var keyWords = key.words;
26752 var keySigBytes = key.sigBytes;
26753
26754 // Init sbox
26755 var S = this._S = [];
26756 for (var i = 0; i < 256; i++) {
26757 S[i] = i;
26758 }
26759
26760 // Key setup
26761 for (var i = 0, j = 0; i < 256; i++) {
26762 var keyByteIndex = i % keySigBytes;
26763 var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
26764
26765 j = (j + S[i] + keyByte) % 256;
26766
26767 // Swap
26768 var t = S[i];
26769 S[i] = S[j];
26770 S[j] = t;
26771 }
26772
26773 // Counters
26774 this._i = this._j = 0;
26775 },
26776
26777 _doProcessBlock: function (M, offset) {
26778 M[offset] ^= generateKeystreamWord.call(this);
26779 },
26780
26781 keySize: 256/32,
26782
26783 ivSize: 0
26784 });
26785
26786 function generateKeystreamWord() {
26787 // Shortcuts
26788 var S = this._S;
26789 var i = this._i;
26790 var j = this._j;
26791
26792 // Generate keystream word
26793 var keystreamWord = 0;
26794 for (var n = 0; n < 4; n++) {
26795 i = (i + 1) % 256;
26796 j = (j + S[i]) % 256;
26797
26798 // Swap
26799 var t = S[i];
26800 S[i] = S[j];
26801 S[j] = t;
26802
26803 keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
26804 }
26805
26806 // Update counters
26807 this._i = i;
26808 this._j = j;
26809
26810 return keystreamWord;
26811 }
26812
26813 /**
26814 * Shortcut functions to the cipher's object interface.
26815 *
26816 * @example
26817 *
26818 * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
26819 * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
26820 */
26821 C.RC4 = StreamCipher._createHelper(RC4);
26822
26823 /**
26824 * Modified RC4 stream cipher algorithm.
26825 */
26826 var RC4Drop = C_algo.RC4Drop = RC4.extend({
26827 /**
26828 * Configuration options.
26829 *
26830 * @property {number} drop The number of keystream words to drop. Default 192
26831 */
26832 cfg: RC4.cfg.extend({
26833 drop: 192
26834 }),
26835
26836 _doReset: function () {
26837 RC4._doReset.call(this);
26838
26839 // Drop
26840 for (var i = this.cfg.drop; i > 0; i--) {
26841 generateKeystreamWord.call(this);
26842 }
26843 }
26844 });
26845
26846 /**
26847 * Shortcut functions to the cipher's object interface.
26848 *
26849 * @example
26850 *
26851 * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
26852 * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
26853 */
26854 C.RC4Drop = StreamCipher._createHelper(RC4Drop);
26855 }());
26856
26857
26858 return CryptoJS.RC4;
26859
26860 }));
26861 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],54:[function(_dereq_,module,exports){
26862 ;(function (root, factory) {
26863 if (typeof exports === "object") {
26864 // CommonJS
26865 module.exports = exports = factory(_dereq_("./core"));
26866 }
26867 else if (typeof define === "function" && define.amd) {
26868 // AMD
26869 define(["./core"], factory);
26870 }
26871 else {
26872 // Global (browser)
26873 factory(root.CryptoJS);
26874 }
26875 }(this, function (CryptoJS) {
26876
26877 /** @preserve
26878 (c) 2012 by Cédric Mesnil. All rights reserved.
26879
26880 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
26881
26882 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
26883 - 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.
26884
26885 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.
26886 */
26887
26888 (function (Math) {
26889 // Shortcuts
26890 var C = CryptoJS;
26891 var C_lib = C.lib;
26892 var WordArray = C_lib.WordArray;
26893 var Hasher = C_lib.Hasher;
26894 var C_algo = C.algo;
26895
26896 // Constants table
26897 var _zl = WordArray.create([
26898 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
26899 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
26900 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
26901 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
26902 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]);
26903 var _zr = WordArray.create([
26904 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
26905 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
26906 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
26907 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
26908 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]);
26909 var _sl = WordArray.create([
26910 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
26911 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
26912 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
26913 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
26914 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]);
26915 var _sr = WordArray.create([
26916 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
26917 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
26918 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
26919 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
26920 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]);
26921
26922 var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
26923 var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
26924
26925 /**
26926 * RIPEMD160 hash algorithm.
26927 */
26928 var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
26929 _doReset: function () {
26930 this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
26931 },
26932
26933 _doProcessBlock: function (M, offset) {
26934
26935 // Swap endian
26936 for (var i = 0; i < 16; i++) {
26937 // Shortcuts
26938 var offset_i = offset + i;
26939 var M_offset_i = M[offset_i];
26940
26941 // Swap
26942 M[offset_i] = (
26943 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
26944 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
26945 );
26946 }
26947 // Shortcut
26948 var H = this._hash.words;
26949 var hl = _hl.words;
26950 var hr = _hr.words;
26951 var zl = _zl.words;
26952 var zr = _zr.words;
26953 var sl = _sl.words;
26954 var sr = _sr.words;
26955
26956 // Working variables
26957 var al, bl, cl, dl, el;
26958 var ar, br, cr, dr, er;
26959
26960 ar = al = H[0];
26961 br = bl = H[1];
26962 cr = cl = H[2];
26963 dr = dl = H[3];
26964 er = el = H[4];
26965 // Computation
26966 var t;
26967 for (var i = 0; i < 80; i += 1) {
26968 t = (al + M[offset+zl[i]])|0;
26969 if (i<16){
26970 t += f1(bl,cl,dl) + hl[0];
26971 } else if (i<32) {
26972 t += f2(bl,cl,dl) + hl[1];
26973 } else if (i<48) {
26974 t += f3(bl,cl,dl) + hl[2];
26975 } else if (i<64) {
26976 t += f4(bl,cl,dl) + hl[3];
26977 } else {// if (i<80) {
26978 t += f5(bl,cl,dl) + hl[4];
26979 }
26980 t = t|0;
26981 t = rotl(t,sl[i]);
26982 t = (t+el)|0;
26983 al = el;
26984 el = dl;
26985 dl = rotl(cl, 10);
26986 cl = bl;
26987 bl = t;
26988
26989 t = (ar + M[offset+zr[i]])|0;
26990 if (i<16){
26991 t += f5(br,cr,dr) + hr[0];
26992 } else if (i<32) {
26993 t += f4(br,cr,dr) + hr[1];
26994 } else if (i<48) {
26995 t += f3(br,cr,dr) + hr[2];
26996 } else if (i<64) {
26997 t += f2(br,cr,dr) + hr[3];
26998 } else {// if (i<80) {
26999 t += f1(br,cr,dr) + hr[4];
27000 }
27001 t = t|0;
27002 t = rotl(t,sr[i]) ;
27003 t = (t+er)|0;
27004 ar = er;
27005 er = dr;
27006 dr = rotl(cr, 10);
27007 cr = br;
27008 br = t;
27009 }
27010 // Intermediate hash value
27011 t = (H[1] + cl + dr)|0;
27012 H[1] = (H[2] + dl + er)|0;
27013 H[2] = (H[3] + el + ar)|0;
27014 H[3] = (H[4] + al + br)|0;
27015 H[4] = (H[0] + bl + cr)|0;
27016 H[0] = t;
27017 },
27018
27019 _doFinalize: function () {
27020 // Shortcuts
27021 var data = this._data;
27022 var dataWords = data.words;
27023
27024 var nBitsTotal = this._nDataBytes * 8;
27025 var nBitsLeft = data.sigBytes * 8;
27026
27027 // Add padding
27028 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27029 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
27030 (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
27031 (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
27032 );
27033 data.sigBytes = (dataWords.length + 1) * 4;
27034
27035 // Hash final blocks
27036 this._process();
27037
27038 // Shortcuts
27039 var hash = this._hash;
27040 var H = hash.words;
27041
27042 // Swap endian
27043 for (var i = 0; i < 5; i++) {
27044 // Shortcut
27045 var H_i = H[i];
27046
27047 // Swap
27048 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
27049 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
27050 }
27051
27052 // Return final computed hash
27053 return hash;
27054 },
27055
27056 clone: function () {
27057 var clone = Hasher.clone.call(this);
27058 clone._hash = this._hash.clone();
27059
27060 return clone;
27061 }
27062 });
27063
27064
27065 function f1(x, y, z) {
27066 return ((x) ^ (y) ^ (z));
27067
27068 }
27069
27070 function f2(x, y, z) {
27071 return (((x)&(y)) | ((~x)&(z)));
27072 }
27073
27074 function f3(x, y, z) {
27075 return (((x) | (~(y))) ^ (z));
27076 }
27077
27078 function f4(x, y, z) {
27079 return (((x) & (z)) | ((y)&(~(z))));
27080 }
27081
27082 function f5(x, y, z) {
27083 return ((x) ^ ((y) |(~(z))));
27084
27085 }
27086
27087 function rotl(x,n) {
27088 return (x<<n) | (x>>>(32-n));
27089 }
27090
27091
27092 /**
27093 * Shortcut function to the hasher's object interface.
27094 *
27095 * @param {WordArray|string} message The message to hash.
27096 *
27097 * @return {WordArray} The hash.
27098 *
27099 * @static
27100 *
27101 * @example
27102 *
27103 * var hash = CryptoJS.RIPEMD160('message');
27104 * var hash = CryptoJS.RIPEMD160(wordArray);
27105 */
27106 C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
27107
27108 /**
27109 * Shortcut function to the HMAC's object interface.
27110 *
27111 * @param {WordArray|string} message The message to hash.
27112 * @param {WordArray|string} key The secret key.
27113 *
27114 * @return {WordArray} The HMAC.
27115 *
27116 * @static
27117 *
27118 * @example
27119 *
27120 * var hmac = CryptoJS.HmacRIPEMD160(message, key);
27121 */
27122 C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
27123 }(Math));
27124
27125
27126 return CryptoJS.RIPEMD160;
27127
27128 }));
27129 },{"./core":31}],55:[function(_dereq_,module,exports){
27130 ;(function (root, factory) {
27131 if (typeof exports === "object") {
27132 // CommonJS
27133 module.exports = exports = factory(_dereq_("./core"));
27134 }
27135 else if (typeof define === "function" && define.amd) {
27136 // AMD
27137 define(["./core"], factory);
27138 }
27139 else {
27140 // Global (browser)
27141 factory(root.CryptoJS);
27142 }
27143 }(this, function (CryptoJS) {
27144
27145 (function () {
27146 // Shortcuts
27147 var C = CryptoJS;
27148 var C_lib = C.lib;
27149 var WordArray = C_lib.WordArray;
27150 var Hasher = C_lib.Hasher;
27151 var C_algo = C.algo;
27152
27153 // Reusable object
27154 var W = [];
27155
27156 /**
27157 * SHA-1 hash algorithm.
27158 */
27159 var SHA1 = C_algo.SHA1 = Hasher.extend({
27160 _doReset: function () {
27161 this._hash = new WordArray.init([
27162 0x67452301, 0xefcdab89,
27163 0x98badcfe, 0x10325476,
27164 0xc3d2e1f0
27165 ]);
27166 },
27167
27168 _doProcessBlock: function (M, offset) {
27169 // Shortcut
27170 var H = this._hash.words;
27171
27172 // Working variables
27173 var a = H[0];
27174 var b = H[1];
27175 var c = H[2];
27176 var d = H[3];
27177 var e = H[4];
27178
27179 // Computation
27180 for (var i = 0; i < 80; i++) {
27181 if (i < 16) {
27182 W[i] = M[offset + i] | 0;
27183 } else {
27184 var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
27185 W[i] = (n << 1) | (n >>> 31);
27186 }
27187
27188 var t = ((a << 5) | (a >>> 27)) + e + W[i];
27189 if (i < 20) {
27190 t += ((b & c) | (~b & d)) + 0x5a827999;
27191 } else if (i < 40) {
27192 t += (b ^ c ^ d) + 0x6ed9eba1;
27193 } else if (i < 60) {
27194 t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
27195 } else /* if (i < 80) */ {
27196 t += (b ^ c ^ d) - 0x359d3e2a;
27197 }
27198
27199 e = d;
27200 d = c;
27201 c = (b << 30) | (b >>> 2);
27202 b = a;
27203 a = t;
27204 }
27205
27206 // Intermediate hash value
27207 H[0] = (H[0] + a) | 0;
27208 H[1] = (H[1] + b) | 0;
27209 H[2] = (H[2] + c) | 0;
27210 H[3] = (H[3] + d) | 0;
27211 H[4] = (H[4] + e) | 0;
27212 },
27213
27214 _doFinalize: function () {
27215 // Shortcuts
27216 var data = this._data;
27217 var dataWords = data.words;
27218
27219 var nBitsTotal = this._nDataBytes * 8;
27220 var nBitsLeft = data.sigBytes * 8;
27221
27222 // Add padding
27223 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27224 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
27225 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
27226 data.sigBytes = dataWords.length * 4;
27227
27228 // Hash final blocks
27229 this._process();
27230
27231 // Return final computed hash
27232 return this._hash;
27233 },
27234
27235 clone: function () {
27236 var clone = Hasher.clone.call(this);
27237 clone._hash = this._hash.clone();
27238
27239 return clone;
27240 }
27241 });
27242
27243 /**
27244 * Shortcut function to the hasher's object interface.
27245 *
27246 * @param {WordArray|string} message The message to hash.
27247 *
27248 * @return {WordArray} The hash.
27249 *
27250 * @static
27251 *
27252 * @example
27253 *
27254 * var hash = CryptoJS.SHA1('message');
27255 * var hash = CryptoJS.SHA1(wordArray);
27256 */
27257 C.SHA1 = Hasher._createHelper(SHA1);
27258
27259 /**
27260 * Shortcut function to the HMAC's object interface.
27261 *
27262 * @param {WordArray|string} message The message to hash.
27263 * @param {WordArray|string} key The secret key.
27264 *
27265 * @return {WordArray} The HMAC.
27266 *
27267 * @static
27268 *
27269 * @example
27270 *
27271 * var hmac = CryptoJS.HmacSHA1(message, key);
27272 */
27273 C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
27274 }());
27275
27276
27277 return CryptoJS.SHA1;
27278
27279 }));
27280 },{"./core":31}],56:[function(_dereq_,module,exports){
27281 ;(function (root, factory, undef) {
27282 if (typeof exports === "object") {
27283 // CommonJS
27284 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha256"));
27285 }
27286 else if (typeof define === "function" && define.amd) {
27287 // AMD
27288 define(["./core", "./sha256"], factory);
27289 }
27290 else {
27291 // Global (browser)
27292 factory(root.CryptoJS);
27293 }
27294 }(this, function (CryptoJS) {
27295
27296 (function () {
27297 // Shortcuts
27298 var C = CryptoJS;
27299 var C_lib = C.lib;
27300 var WordArray = C_lib.WordArray;
27301 var C_algo = C.algo;
27302 var SHA256 = C_algo.SHA256;
27303
27304 /**
27305 * SHA-224 hash algorithm.
27306 */
27307 var SHA224 = C_algo.SHA224 = SHA256.extend({
27308 _doReset: function () {
27309 this._hash = new WordArray.init([
27310 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
27311 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
27312 ]);
27313 },
27314
27315 _doFinalize: function () {
27316 var hash = SHA256._doFinalize.call(this);
27317
27318 hash.sigBytes -= 4;
27319
27320 return hash;
27321 }
27322 });
27323
27324 /**
27325 * Shortcut function to the hasher's object interface.
27326 *
27327 * @param {WordArray|string} message The message to hash.
27328 *
27329 * @return {WordArray} The hash.
27330 *
27331 * @static
27332 *
27333 * @example
27334 *
27335 * var hash = CryptoJS.SHA224('message');
27336 * var hash = CryptoJS.SHA224(wordArray);
27337 */
27338 C.SHA224 = SHA256._createHelper(SHA224);
27339
27340 /**
27341 * Shortcut function to the HMAC's object interface.
27342 *
27343 * @param {WordArray|string} message The message to hash.
27344 * @param {WordArray|string} key The secret key.
27345 *
27346 * @return {WordArray} The HMAC.
27347 *
27348 * @static
27349 *
27350 * @example
27351 *
27352 * var hmac = CryptoJS.HmacSHA224(message, key);
27353 */
27354 C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
27355 }());
27356
27357
27358 return CryptoJS.SHA224;
27359
27360 }));
27361 },{"./core":31,"./sha256":57}],57:[function(_dereq_,module,exports){
27362 ;(function (root, factory) {
27363 if (typeof exports === "object") {
27364 // CommonJS
27365 module.exports = exports = factory(_dereq_("./core"));
27366 }
27367 else if (typeof define === "function" && define.amd) {
27368 // AMD
27369 define(["./core"], factory);
27370 }
27371 else {
27372 // Global (browser)
27373 factory(root.CryptoJS);
27374 }
27375 }(this, function (CryptoJS) {
27376
27377 (function (Math) {
27378 // Shortcuts
27379 var C = CryptoJS;
27380 var C_lib = C.lib;
27381 var WordArray = C_lib.WordArray;
27382 var Hasher = C_lib.Hasher;
27383 var C_algo = C.algo;
27384
27385 // Initialization and round constants tables
27386 var H = [];
27387 var K = [];
27388
27389 // Compute constants
27390 (function () {
27391 function isPrime(n) {
27392 var sqrtN = Math.sqrt(n);
27393 for (var factor = 2; factor <= sqrtN; factor++) {
27394 if (!(n % factor)) {
27395 return false;
27396 }
27397 }
27398
27399 return true;
27400 }
27401
27402 function getFractionalBits(n) {
27403 return ((n - (n | 0)) * 0x100000000) | 0;
27404 }
27405
27406 var n = 2;
27407 var nPrime = 0;
27408 while (nPrime < 64) {
27409 if (isPrime(n)) {
27410 if (nPrime < 8) {
27411 H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
27412 }
27413 K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
27414
27415 nPrime++;
27416 }
27417
27418 n++;
27419 }
27420 }());
27421
27422 // Reusable object
27423 var W = [];
27424
27425 /**
27426 * SHA-256 hash algorithm.
27427 */
27428 var SHA256 = C_algo.SHA256 = Hasher.extend({
27429 _doReset: function () {
27430 this._hash = new WordArray.init(H.slice(0));
27431 },
27432
27433 _doProcessBlock: function (M, offset) {
27434 // Shortcut
27435 var H = this._hash.words;
27436
27437 // Working variables
27438 var a = H[0];
27439 var b = H[1];
27440 var c = H[2];
27441 var d = H[3];
27442 var e = H[4];
27443 var f = H[5];
27444 var g = H[6];
27445 var h = H[7];
27446
27447 // Computation
27448 for (var i = 0; i < 64; i++) {
27449 if (i < 16) {
27450 W[i] = M[offset + i] | 0;
27451 } else {
27452 var gamma0x = W[i - 15];
27453 var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
27454 ((gamma0x << 14) | (gamma0x >>> 18)) ^
27455 (gamma0x >>> 3);
27456
27457 var gamma1x = W[i - 2];
27458 var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
27459 ((gamma1x << 13) | (gamma1x >>> 19)) ^
27460 (gamma1x >>> 10);
27461
27462 W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
27463 }
27464
27465 var ch = (e & f) ^ (~e & g);
27466 var maj = (a & b) ^ (a & c) ^ (b & c);
27467
27468 var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
27469 var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
27470
27471 var t1 = h + sigma1 + ch + K[i] + W[i];
27472 var t2 = sigma0 + maj;
27473
27474 h = g;
27475 g = f;
27476 f = e;
27477 e = (d + t1) | 0;
27478 d = c;
27479 c = b;
27480 b = a;
27481 a = (t1 + t2) | 0;
27482 }
27483
27484 // Intermediate hash value
27485 H[0] = (H[0] + a) | 0;
27486 H[1] = (H[1] + b) | 0;
27487 H[2] = (H[2] + c) | 0;
27488 H[3] = (H[3] + d) | 0;
27489 H[4] = (H[4] + e) | 0;
27490 H[5] = (H[5] + f) | 0;
27491 H[6] = (H[6] + g) | 0;
27492 H[7] = (H[7] + h) | 0;
27493 },
27494
27495 _doFinalize: function () {
27496 // Shortcuts
27497 var data = this._data;
27498 var dataWords = data.words;
27499
27500 var nBitsTotal = this._nDataBytes * 8;
27501 var nBitsLeft = data.sigBytes * 8;
27502
27503 // Add padding
27504 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27505 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
27506 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
27507 data.sigBytes = dataWords.length * 4;
27508
27509 // Hash final blocks
27510 this._process();
27511
27512 // Return final computed hash
27513 return this._hash;
27514 },
27515
27516 clone: function () {
27517 var clone = Hasher.clone.call(this);
27518 clone._hash = this._hash.clone();
27519
27520 return clone;
27521 }
27522 });
27523
27524 /**
27525 * Shortcut function to the hasher's object interface.
27526 *
27527 * @param {WordArray|string} message The message to hash.
27528 *
27529 * @return {WordArray} The hash.
27530 *
27531 * @static
27532 *
27533 * @example
27534 *
27535 * var hash = CryptoJS.SHA256('message');
27536 * var hash = CryptoJS.SHA256(wordArray);
27537 */
27538 C.SHA256 = Hasher._createHelper(SHA256);
27539
27540 /**
27541 * Shortcut function to the HMAC's object interface.
27542 *
27543 * @param {WordArray|string} message The message to hash.
27544 * @param {WordArray|string} key The secret key.
27545 *
27546 * @return {WordArray} The HMAC.
27547 *
27548 * @static
27549 *
27550 * @example
27551 *
27552 * var hmac = CryptoJS.HmacSHA256(message, key);
27553 */
27554 C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
27555 }(Math));
27556
27557
27558 return CryptoJS.SHA256;
27559
27560 }));
27561 },{"./core":31}],58:[function(_dereq_,module,exports){
27562 ;(function (root, factory, undef) {
27563 if (typeof exports === "object") {
27564 // CommonJS
27565 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"));
27566 }
27567 else if (typeof define === "function" && define.amd) {
27568 // AMD
27569 define(["./core", "./x64-core"], factory);
27570 }
27571 else {
27572 // Global (browser)
27573 factory(root.CryptoJS);
27574 }
27575 }(this, function (CryptoJS) {
27576
27577 (function (Math) {
27578 // Shortcuts
27579 var C = CryptoJS;
27580 var C_lib = C.lib;
27581 var WordArray = C_lib.WordArray;
27582 var Hasher = C_lib.Hasher;
27583 var C_x64 = C.x64;
27584 var X64Word = C_x64.Word;
27585 var C_algo = C.algo;
27586
27587 // Constants tables
27588 var RHO_OFFSETS = [];
27589 var PI_INDEXES = [];
27590 var ROUND_CONSTANTS = [];
27591
27592 // Compute Constants
27593 (function () {
27594 // Compute rho offset constants
27595 var x = 1, y = 0;
27596 for (var t = 0; t < 24; t++) {
27597 RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
27598
27599 var newX = y % 5;
27600 var newY = (2 * x + 3 * y) % 5;
27601 x = newX;
27602 y = newY;
27603 }
27604
27605 // Compute pi index constants
27606 for (var x = 0; x < 5; x++) {
27607 for (var y = 0; y < 5; y++) {
27608 PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
27609 }
27610 }
27611
27612 // Compute round constants
27613 var LFSR = 0x01;
27614 for (var i = 0; i < 24; i++) {
27615 var roundConstantMsw = 0;
27616 var roundConstantLsw = 0;
27617
27618 for (var j = 0; j < 7; j++) {
27619 if (LFSR & 0x01) {
27620 var bitPosition = (1 << j) - 1;
27621 if (bitPosition < 32) {
27622 roundConstantLsw ^= 1 << bitPosition;
27623 } else /* if (bitPosition >= 32) */ {
27624 roundConstantMsw ^= 1 << (bitPosition - 32);
27625 }
27626 }
27627
27628 // Compute next LFSR
27629 if (LFSR & 0x80) {
27630 // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
27631 LFSR = (LFSR << 1) ^ 0x71;
27632 } else {
27633 LFSR <<= 1;
27634 }
27635 }
27636
27637 ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
27638 }
27639 }());
27640
27641 // Reusable objects for temporary values
27642 var T = [];
27643 (function () {
27644 for (var i = 0; i < 25; i++) {
27645 T[i] = X64Word.create();
27646 }
27647 }());
27648
27649 /**
27650 * SHA-3 hash algorithm.
27651 */
27652 var SHA3 = C_algo.SHA3 = Hasher.extend({
27653 /**
27654 * Configuration options.
27655 *
27656 * @property {number} outputLength
27657 * The desired number of bits in the output hash.
27658 * Only values permitted are: 224, 256, 384, 512.
27659 * Default: 512
27660 */
27661 cfg: Hasher.cfg.extend({
27662 outputLength: 512
27663 }),
27664
27665 _doReset: function () {
27666 var state = this._state = []
27667 for (var i = 0; i < 25; i++) {
27668 state[i] = new X64Word.init();
27669 }
27670
27671 this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
27672 },
27673
27674 _doProcessBlock: function (M, offset) {
27675 // Shortcuts
27676 var state = this._state;
27677 var nBlockSizeLanes = this.blockSize / 2;
27678
27679 // Absorb
27680 for (var i = 0; i < nBlockSizeLanes; i++) {
27681 // Shortcuts
27682 var M2i = M[offset + 2 * i];
27683 var M2i1 = M[offset + 2 * i + 1];
27684
27685 // Swap endian
27686 M2i = (
27687 (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) |
27688 (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00)
27689 );
27690 M2i1 = (
27691 (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) |
27692 (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00)
27693 );
27694
27695 // Absorb message into state
27696 var lane = state[i];
27697 lane.high ^= M2i1;
27698 lane.low ^= M2i;
27699 }
27700
27701 // Rounds
27702 for (var round = 0; round < 24; round++) {
27703 // Theta
27704 for (var x = 0; x < 5; x++) {
27705 // Mix column lanes
27706 var tMsw = 0, tLsw = 0;
27707 for (var y = 0; y < 5; y++) {
27708 var lane = state[x + 5 * y];
27709 tMsw ^= lane.high;
27710 tLsw ^= lane.low;
27711 }
27712
27713 // Temporary values
27714 var Tx = T[x];
27715 Tx.high = tMsw;
27716 Tx.low = tLsw;
27717 }
27718 for (var x = 0; x < 5; x++) {
27719 // Shortcuts
27720 var Tx4 = T[(x + 4) % 5];
27721 var Tx1 = T[(x + 1) % 5];
27722 var Tx1Msw = Tx1.high;
27723 var Tx1Lsw = Tx1.low;
27724
27725 // Mix surrounding columns
27726 var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
27727 var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
27728 for (var y = 0; y < 5; y++) {
27729 var lane = state[x + 5 * y];
27730 lane.high ^= tMsw;
27731 lane.low ^= tLsw;
27732 }
27733 }
27734
27735 // Rho Pi
27736 for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
27737 // Shortcuts
27738 var lane = state[laneIndex];
27739 var laneMsw = lane.high;
27740 var laneLsw = lane.low;
27741 var rhoOffset = RHO_OFFSETS[laneIndex];
27742
27743 // Rotate lanes
27744 if (rhoOffset < 32) {
27745 var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
27746 var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
27747 } else /* if (rhoOffset >= 32) */ {
27748 var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
27749 var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
27750 }
27751
27752 // Transpose lanes
27753 var TPiLane = T[PI_INDEXES[laneIndex]];
27754 TPiLane.high = tMsw;
27755 TPiLane.low = tLsw;
27756 }
27757
27758 // Rho pi at x = y = 0
27759 var T0 = T[0];
27760 var state0 = state[0];
27761 T0.high = state0.high;
27762 T0.low = state0.low;
27763
27764 // Chi
27765 for (var x = 0; x < 5; x++) {
27766 for (var y = 0; y < 5; y++) {
27767 // Shortcuts
27768 var laneIndex = x + 5 * y;
27769 var lane = state[laneIndex];
27770 var TLane = T[laneIndex];
27771 var Tx1Lane = T[((x + 1) % 5) + 5 * y];
27772 var Tx2Lane = T[((x + 2) % 5) + 5 * y];
27773
27774 // Mix rows
27775 lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
27776 lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
27777 }
27778 }
27779
27780 // Iota
27781 var lane = state[0];
27782 var roundConstant = ROUND_CONSTANTS[round];
27783 lane.high ^= roundConstant.high;
27784 lane.low ^= roundConstant.low;;
27785 }
27786 },
27787
27788 _doFinalize: function () {
27789 // Shortcuts
27790 var data = this._data;
27791 var dataWords = data.words;
27792 var nBitsTotal = this._nDataBytes * 8;
27793 var nBitsLeft = data.sigBytes * 8;
27794 var blockSizeBits = this.blockSize * 32;
27795
27796 // Add padding
27797 dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
27798 dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
27799 data.sigBytes = dataWords.length * 4;
27800
27801 // Hash final blocks
27802 this._process();
27803
27804 // Shortcuts
27805 var state = this._state;
27806 var outputLengthBytes = this.cfg.outputLength / 8;
27807 var outputLengthLanes = outputLengthBytes / 8;
27808
27809 // Squeeze
27810 var hashWords = [];
27811 for (var i = 0; i < outputLengthLanes; i++) {
27812 // Shortcuts
27813 var lane = state[i];
27814 var laneMsw = lane.high;
27815 var laneLsw = lane.low;
27816
27817 // Swap endian
27818 laneMsw = (
27819 (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) |
27820 (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00)
27821 );
27822 laneLsw = (
27823 (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) |
27824 (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00)
27825 );
27826
27827 // Squeeze state to retrieve hash
27828 hashWords.push(laneLsw);
27829 hashWords.push(laneMsw);
27830 }
27831
27832 // Return final computed hash
27833 return new WordArray.init(hashWords, outputLengthBytes);
27834 },
27835
27836 clone: function () {
27837 var clone = Hasher.clone.call(this);
27838
27839 var state = clone._state = this._state.slice(0);
27840 for (var i = 0; i < 25; i++) {
27841 state[i] = state[i].clone();
27842 }
27843
27844 return clone;
27845 }
27846 });
27847
27848 /**
27849 * Shortcut function to the hasher's object interface.
27850 *
27851 * @param {WordArray|string} message The message to hash.
27852 *
27853 * @return {WordArray} The hash.
27854 *
27855 * @static
27856 *
27857 * @example
27858 *
27859 * var hash = CryptoJS.SHA3('message');
27860 * var hash = CryptoJS.SHA3(wordArray);
27861 */
27862 C.SHA3 = Hasher._createHelper(SHA3);
27863
27864 /**
27865 * Shortcut function to the HMAC's object interface.
27866 *
27867 * @param {WordArray|string} message The message to hash.
27868 * @param {WordArray|string} key The secret key.
27869 *
27870 * @return {WordArray} The HMAC.
27871 *
27872 * @static
27873 *
27874 * @example
27875 *
27876 * var hmac = CryptoJS.HmacSHA3(message, key);
27877 */
27878 C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
27879 }(Math));
27880
27881
27882 return CryptoJS.SHA3;
27883
27884 }));
27885 },{"./core":31,"./x64-core":62}],59:[function(_dereq_,module,exports){
27886 ;(function (root, factory, undef) {
27887 if (typeof exports === "object") {
27888 // CommonJS
27889 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"), _dereq_("./sha512"));
27890 }
27891 else if (typeof define === "function" && define.amd) {
27892 // AMD
27893 define(["./core", "./x64-core", "./sha512"], factory);
27894 }
27895 else {
27896 // Global (browser)
27897 factory(root.CryptoJS);
27898 }
27899 }(this, function (CryptoJS) {
27900
27901 (function () {
27902 // Shortcuts
27903 var C = CryptoJS;
27904 var C_x64 = C.x64;
27905 var X64Word = C_x64.Word;
27906 var X64WordArray = C_x64.WordArray;
27907 var C_algo = C.algo;
27908 var SHA512 = C_algo.SHA512;
27909
27910 /**
27911 * SHA-384 hash algorithm.
27912 */
27913 var SHA384 = C_algo.SHA384 = SHA512.extend({
27914 _doReset: function () {
27915 this._hash = new X64WordArray.init([
27916 new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
27917 new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
27918 new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
27919 new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
27920 ]);
27921 },
27922
27923 _doFinalize: function () {
27924 var hash = SHA512._doFinalize.call(this);
27925
27926 hash.sigBytes -= 16;
27927
27928 return hash;
27929 }
27930 });
27931
27932 /**
27933 * Shortcut function to the hasher's object interface.
27934 *
27935 * @param {WordArray|string} message The message to hash.
27936 *
27937 * @return {WordArray} The hash.
27938 *
27939 * @static
27940 *
27941 * @example
27942 *
27943 * var hash = CryptoJS.SHA384('message');
27944 * var hash = CryptoJS.SHA384(wordArray);
27945 */
27946 C.SHA384 = SHA512._createHelper(SHA384);
27947
27948 /**
27949 * Shortcut function to the HMAC's object interface.
27950 *
27951 * @param {WordArray|string} message The message to hash.
27952 * @param {WordArray|string} key The secret key.
27953 *
27954 * @return {WordArray} The HMAC.
27955 *
27956 * @static
27957 *
27958 * @example
27959 *
27960 * var hmac = CryptoJS.HmacSHA384(message, key);
27961 */
27962 C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
27963 }());
27964
27965
27966 return CryptoJS.SHA384;
27967
27968 }));
27969 },{"./core":31,"./sha512":60,"./x64-core":62}],60:[function(_dereq_,module,exports){
27970 ;(function (root, factory, undef) {
27971 if (typeof exports === "object") {
27972 // CommonJS
27973 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"));
27974 }
27975 else if (typeof define === "function" && define.amd) {
27976 // AMD
27977 define(["./core", "./x64-core"], factory);
27978 }
27979 else {
27980 // Global (browser)
27981 factory(root.CryptoJS);
27982 }
27983 }(this, function (CryptoJS) {
27984
27985 (function () {
27986 // Shortcuts
27987 var C = CryptoJS;
27988 var C_lib = C.lib;
27989 var Hasher = C_lib.Hasher;
27990 var C_x64 = C.x64;
27991 var X64Word = C_x64.Word;
27992 var X64WordArray = C_x64.WordArray;
27993 var C_algo = C.algo;
27994
27995 function X64Word_create() {
27996 return X64Word.create.apply(X64Word, arguments);
27997 }
27998
27999 // Constants
28000 var K = [
28001 X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
28002 X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
28003 X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
28004 X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
28005 X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
28006 X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
28007 X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
28008 X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
28009 X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
28010 X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
28011 X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
28012 X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
28013 X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
28014 X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
28015 X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
28016 X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
28017 X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
28018 X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
28019 X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
28020 X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
28021 X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
28022 X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
28023 X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
28024 X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
28025 X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
28026 X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
28027 X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
28028 X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
28029 X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
28030 X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
28031 X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
28032 X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
28033 X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
28034 X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
28035 X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
28036 X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
28037 X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
28038 X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
28039 X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
28040 X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
28041 ];
28042
28043 // Reusable objects
28044 var W = [];
28045 (function () {
28046 for (var i = 0; i < 80; i++) {
28047 W[i] = X64Word_create();
28048 }
28049 }());
28050
28051 /**
28052 * SHA-512 hash algorithm.
28053 */
28054 var SHA512 = C_algo.SHA512 = Hasher.extend({
28055 _doReset: function () {
28056 this._hash = new X64WordArray.init([
28057 new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
28058 new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
28059 new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
28060 new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
28061 ]);
28062 },
28063
28064 _doProcessBlock: function (M, offset) {
28065 // Shortcuts
28066 var H = this._hash.words;
28067
28068 var H0 = H[0];
28069 var H1 = H[1];
28070 var H2 = H[2];
28071 var H3 = H[3];
28072 var H4 = H[4];
28073 var H5 = H[5];
28074 var H6 = H[6];
28075 var H7 = H[7];
28076
28077 var H0h = H0.high;
28078 var H0l = H0.low;
28079 var H1h = H1.high;
28080 var H1l = H1.low;
28081 var H2h = H2.high;
28082 var H2l = H2.low;
28083 var H3h = H3.high;
28084 var H3l = H3.low;
28085 var H4h = H4.high;
28086 var H4l = H4.low;
28087 var H5h = H5.high;
28088 var H5l = H5.low;
28089 var H6h = H6.high;
28090 var H6l = H6.low;
28091 var H7h = H7.high;
28092 var H7l = H7.low;
28093
28094 // Working variables
28095 var ah = H0h;
28096 var al = H0l;
28097 var bh = H1h;
28098 var bl = H1l;
28099 var ch = H2h;
28100 var cl = H2l;
28101 var dh = H3h;
28102 var dl = H3l;
28103 var eh = H4h;
28104 var el = H4l;
28105 var fh = H5h;
28106 var fl = H5l;
28107 var gh = H6h;
28108 var gl = H6l;
28109 var hh = H7h;
28110 var hl = H7l;
28111
28112 // Rounds
28113 for (var i = 0; i < 80; i++) {
28114 // Shortcut
28115 var Wi = W[i];
28116
28117 // Extend message
28118 if (i < 16) {
28119 var Wih = Wi.high = M[offset + i * 2] | 0;
28120 var Wil = Wi.low = M[offset + i * 2 + 1] | 0;
28121 } else {
28122 // Gamma0
28123 var gamma0x = W[i - 15];
28124 var gamma0xh = gamma0x.high;
28125 var gamma0xl = gamma0x.low;
28126 var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
28127 var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
28128
28129 // Gamma1
28130 var gamma1x = W[i - 2];
28131 var gamma1xh = gamma1x.high;
28132 var gamma1xl = gamma1x.low;
28133 var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
28134 var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
28135
28136 // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
28137 var Wi7 = W[i - 7];
28138 var Wi7h = Wi7.high;
28139 var Wi7l = Wi7.low;
28140
28141 var Wi16 = W[i - 16];
28142 var Wi16h = Wi16.high;
28143 var Wi16l = Wi16.low;
28144
28145 var Wil = gamma0l + Wi7l;
28146 var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
28147 var Wil = Wil + gamma1l;
28148 var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
28149 var Wil = Wil + Wi16l;
28150 var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
28151
28152 Wi.high = Wih;
28153 Wi.low = Wil;
28154 }
28155
28156 var chh = (eh & fh) ^ (~eh & gh);
28157 var chl = (el & fl) ^ (~el & gl);
28158 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
28159 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
28160
28161 var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
28162 var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
28163 var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
28164 var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
28165
28166 // t1 = h + sigma1 + ch + K[i] + W[i]
28167 var Ki = K[i];
28168 var Kih = Ki.high;
28169 var Kil = Ki.low;
28170
28171 var t1l = hl + sigma1l;
28172 var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
28173 var t1l = t1l + chl;
28174 var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
28175 var t1l = t1l + Kil;
28176 var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
28177 var t1l = t1l + Wil;
28178 var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
28179
28180 // t2 = sigma0 + maj
28181 var t2l = sigma0l + majl;
28182 var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
28183
28184 // Update working variables
28185 hh = gh;
28186 hl = gl;
28187 gh = fh;
28188 gl = fl;
28189 fh = eh;
28190 fl = el;
28191 el = (dl + t1l) | 0;
28192 eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
28193 dh = ch;
28194 dl = cl;
28195 ch = bh;
28196 cl = bl;
28197 bh = ah;
28198 bl = al;
28199 al = (t1l + t2l) | 0;
28200 ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
28201 }
28202
28203 // Intermediate hash value
28204 H0l = H0.low = (H0l + al);
28205 H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
28206 H1l = H1.low = (H1l + bl);
28207 H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
28208 H2l = H2.low = (H2l + cl);
28209 H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
28210 H3l = H3.low = (H3l + dl);
28211 H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
28212 H4l = H4.low = (H4l + el);
28213 H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
28214 H5l = H5.low = (H5l + fl);
28215 H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
28216 H6l = H6.low = (H6l + gl);
28217 H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
28218 H7l = H7.low = (H7l + hl);
28219 H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
28220 },
28221
28222 _doFinalize: function () {
28223 // Shortcuts
28224 var data = this._data;
28225 var dataWords = data.words;
28226
28227 var nBitsTotal = this._nDataBytes * 8;
28228 var nBitsLeft = data.sigBytes * 8;
28229
28230 // Add padding
28231 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
28232 dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
28233 dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
28234 data.sigBytes = dataWords.length * 4;
28235
28236 // Hash final blocks
28237 this._process();
28238
28239 // Convert hash to 32-bit word array before returning
28240 var hash = this._hash.toX32();
28241
28242 // Return final computed hash
28243 return hash;
28244 },
28245
28246 clone: function () {
28247 var clone = Hasher.clone.call(this);
28248 clone._hash = this._hash.clone();
28249
28250 return clone;
28251 },
28252
28253 blockSize: 1024/32
28254 });
28255
28256 /**
28257 * Shortcut function to the hasher's object interface.
28258 *
28259 * @param {WordArray|string} message The message to hash.
28260 *
28261 * @return {WordArray} The hash.
28262 *
28263 * @static
28264 *
28265 * @example
28266 *
28267 * var hash = CryptoJS.SHA512('message');
28268 * var hash = CryptoJS.SHA512(wordArray);
28269 */
28270 C.SHA512 = Hasher._createHelper(SHA512);
28271
28272 /**
28273 * Shortcut function to the HMAC's object interface.
28274 *
28275 * @param {WordArray|string} message The message to hash.
28276 * @param {WordArray|string} key The secret key.
28277 *
28278 * @return {WordArray} The HMAC.
28279 *
28280 * @static
28281 *
28282 * @example
28283 *
28284 * var hmac = CryptoJS.HmacSHA512(message, key);
28285 */
28286 C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
28287 }());
28288
28289
28290 return CryptoJS.SHA512;
28291
28292 }));
28293 },{"./core":31,"./x64-core":62}],61:[function(_dereq_,module,exports){
28294 ;(function (root, factory, undef) {
28295 if (typeof exports === "object") {
28296 // CommonJS
28297 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
28298 }
28299 else if (typeof define === "function" && define.amd) {
28300 // AMD
28301 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
28302 }
28303 else {
28304 // Global (browser)
28305 factory(root.CryptoJS);
28306 }
28307 }(this, function (CryptoJS) {
28308
28309 (function () {
28310 // Shortcuts
28311 var C = CryptoJS;
28312 var C_lib = C.lib;
28313 var WordArray = C_lib.WordArray;
28314 var BlockCipher = C_lib.BlockCipher;
28315 var C_algo = C.algo;
28316
28317 // Permuted Choice 1 constants
28318 var PC1 = [
28319 57, 49, 41, 33, 25, 17, 9, 1,
28320 58, 50, 42, 34, 26, 18, 10, 2,
28321 59, 51, 43, 35, 27, 19, 11, 3,
28322 60, 52, 44, 36, 63, 55, 47, 39,
28323 31, 23, 15, 7, 62, 54, 46, 38,
28324 30, 22, 14, 6, 61, 53, 45, 37,
28325 29, 21, 13, 5, 28, 20, 12, 4
28326 ];
28327
28328 // Permuted Choice 2 constants
28329 var PC2 = [
28330 14, 17, 11, 24, 1, 5,
28331 3, 28, 15, 6, 21, 10,
28332 23, 19, 12, 4, 26, 8,
28333 16, 7, 27, 20, 13, 2,
28334 41, 52, 31, 37, 47, 55,
28335 30, 40, 51, 45, 33, 48,
28336 44, 49, 39, 56, 34, 53,
28337 46, 42, 50, 36, 29, 32
28338 ];
28339
28340 // Cumulative bit shift constants
28341 var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
28342
28343 // SBOXes and round permutation constants
28344 var SBOX_P = [
28345 {
28346 0x0: 0x808200,
28347 0x10000000: 0x8000,
28348 0x20000000: 0x808002,
28349 0x30000000: 0x2,
28350 0x40000000: 0x200,
28351 0x50000000: 0x808202,
28352 0x60000000: 0x800202,
28353 0x70000000: 0x800000,
28354 0x80000000: 0x202,
28355 0x90000000: 0x800200,
28356 0xa0000000: 0x8200,
28357 0xb0000000: 0x808000,
28358 0xc0000000: 0x8002,
28359 0xd0000000: 0x800002,
28360 0xe0000000: 0x0,
28361 0xf0000000: 0x8202,
28362 0x8000000: 0x0,
28363 0x18000000: 0x808202,
28364 0x28000000: 0x8202,
28365 0x38000000: 0x8000,
28366 0x48000000: 0x808200,
28367 0x58000000: 0x200,
28368 0x68000000: 0x808002,
28369 0x78000000: 0x2,
28370 0x88000000: 0x800200,
28371 0x98000000: 0x8200,
28372 0xa8000000: 0x808000,
28373 0xb8000000: 0x800202,
28374 0xc8000000: 0x800002,
28375 0xd8000000: 0x8002,
28376 0xe8000000: 0x202,
28377 0xf8000000: 0x800000,
28378 0x1: 0x8000,
28379 0x10000001: 0x2,
28380 0x20000001: 0x808200,
28381 0x30000001: 0x800000,
28382 0x40000001: 0x808002,
28383 0x50000001: 0x8200,
28384 0x60000001: 0x200,
28385 0x70000001: 0x800202,
28386 0x80000001: 0x808202,
28387 0x90000001: 0x808000,
28388 0xa0000001: 0x800002,
28389 0xb0000001: 0x8202,
28390 0xc0000001: 0x202,
28391 0xd0000001: 0x800200,
28392 0xe0000001: 0x8002,
28393 0xf0000001: 0x0,
28394 0x8000001: 0x808202,
28395 0x18000001: 0x808000,
28396 0x28000001: 0x800000,
28397 0x38000001: 0x200,
28398 0x48000001: 0x8000,
28399 0x58000001: 0x800002,
28400 0x68000001: 0x2,
28401 0x78000001: 0x8202,
28402 0x88000001: 0x8002,
28403 0x98000001: 0x800202,
28404 0xa8000001: 0x202,
28405 0xb8000001: 0x808200,
28406 0xc8000001: 0x800200,
28407 0xd8000001: 0x0,
28408 0xe8000001: 0x8200,
28409 0xf8000001: 0x808002
28410 },
28411 {
28412 0x0: 0x40084010,
28413 0x1000000: 0x4000,
28414 0x2000000: 0x80000,
28415 0x3000000: 0x40080010,
28416 0x4000000: 0x40000010,
28417 0x5000000: 0x40084000,
28418 0x6000000: 0x40004000,
28419 0x7000000: 0x10,
28420 0x8000000: 0x84000,
28421 0x9000000: 0x40004010,
28422 0xa000000: 0x40000000,
28423 0xb000000: 0x84010,
28424 0xc000000: 0x80010,
28425 0xd000000: 0x0,
28426 0xe000000: 0x4010,
28427 0xf000000: 0x40080000,
28428 0x800000: 0x40004000,
28429 0x1800000: 0x84010,
28430 0x2800000: 0x10,
28431 0x3800000: 0x40004010,
28432 0x4800000: 0x40084010,
28433 0x5800000: 0x40000000,
28434 0x6800000: 0x80000,
28435 0x7800000: 0x40080010,
28436 0x8800000: 0x80010,
28437 0x9800000: 0x0,
28438 0xa800000: 0x4000,
28439 0xb800000: 0x40080000,
28440 0xc800000: 0x40000010,
28441 0xd800000: 0x84000,
28442 0xe800000: 0x40084000,
28443 0xf800000: 0x4010,
28444 0x10000000: 0x0,
28445 0x11000000: 0x40080010,
28446 0x12000000: 0x40004010,
28447 0x13000000: 0x40084000,
28448 0x14000000: 0x40080000,
28449 0x15000000: 0x10,
28450 0x16000000: 0x84010,
28451 0x17000000: 0x4000,
28452 0x18000000: 0x4010,
28453 0x19000000: 0x80000,
28454 0x1a000000: 0x80010,
28455 0x1b000000: 0x40000010,
28456 0x1c000000: 0x84000,
28457 0x1d000000: 0x40004000,
28458 0x1e000000: 0x40000000,
28459 0x1f000000: 0x40084010,
28460 0x10800000: 0x84010,
28461 0x11800000: 0x80000,
28462 0x12800000: 0x40080000,
28463 0x13800000: 0x4000,
28464 0x14800000: 0x40004000,
28465 0x15800000: 0x40084010,
28466 0x16800000: 0x10,
28467 0x17800000: 0x40000000,
28468 0x18800000: 0x40084000,
28469 0x19800000: 0x40000010,
28470 0x1a800000: 0x40004010,
28471 0x1b800000: 0x80010,
28472 0x1c800000: 0x0,
28473 0x1d800000: 0x4010,
28474 0x1e800000: 0x40080010,
28475 0x1f800000: 0x84000
28476 },
28477 {
28478 0x0: 0x104,
28479 0x100000: 0x0,
28480 0x200000: 0x4000100,
28481 0x300000: 0x10104,
28482 0x400000: 0x10004,
28483 0x500000: 0x4000004,
28484 0x600000: 0x4010104,
28485 0x700000: 0x4010000,
28486 0x800000: 0x4000000,
28487 0x900000: 0x4010100,
28488 0xa00000: 0x10100,
28489 0xb00000: 0x4010004,
28490 0xc00000: 0x4000104,
28491 0xd00000: 0x10000,
28492 0xe00000: 0x4,
28493 0xf00000: 0x100,
28494 0x80000: 0x4010100,
28495 0x180000: 0x4010004,
28496 0x280000: 0x0,
28497 0x380000: 0x4000100,
28498 0x480000: 0x4000004,
28499 0x580000: 0x10000,
28500 0x680000: 0x10004,
28501 0x780000: 0x104,
28502 0x880000: 0x4,
28503 0x980000: 0x100,
28504 0xa80000: 0x4010000,
28505 0xb80000: 0x10104,
28506 0xc80000: 0x10100,
28507 0xd80000: 0x4000104,
28508 0xe80000: 0x4010104,
28509 0xf80000: 0x4000000,
28510 0x1000000: 0x4010100,
28511 0x1100000: 0x10004,
28512 0x1200000: 0x10000,
28513 0x1300000: 0x4000100,
28514 0x1400000: 0x100,
28515 0x1500000: 0x4010104,
28516 0x1600000: 0x4000004,
28517 0x1700000: 0x0,
28518 0x1800000: 0x4000104,
28519 0x1900000: 0x4000000,
28520 0x1a00000: 0x4,
28521 0x1b00000: 0x10100,
28522 0x1c00000: 0x4010000,
28523 0x1d00000: 0x104,
28524 0x1e00000: 0x10104,
28525 0x1f00000: 0x4010004,
28526 0x1080000: 0x4000000,
28527 0x1180000: 0x104,
28528 0x1280000: 0x4010100,
28529 0x1380000: 0x0,
28530 0x1480000: 0x10004,
28531 0x1580000: 0x4000100,
28532 0x1680000: 0x100,
28533 0x1780000: 0x4010004,
28534 0x1880000: 0x10000,
28535 0x1980000: 0x4010104,
28536 0x1a80000: 0x10104,
28537 0x1b80000: 0x4000004,
28538 0x1c80000: 0x4000104,
28539 0x1d80000: 0x4010000,
28540 0x1e80000: 0x4,
28541 0x1f80000: 0x10100
28542 },
28543 {
28544 0x0: 0x80401000,
28545 0x10000: 0x80001040,
28546 0x20000: 0x401040,
28547 0x30000: 0x80400000,
28548 0x40000: 0x0,
28549 0x50000: 0x401000,
28550 0x60000: 0x80000040,
28551 0x70000: 0x400040,
28552 0x80000: 0x80000000,
28553 0x90000: 0x400000,
28554 0xa0000: 0x40,
28555 0xb0000: 0x80001000,
28556 0xc0000: 0x80400040,
28557 0xd0000: 0x1040,
28558 0xe0000: 0x1000,
28559 0xf0000: 0x80401040,
28560 0x8000: 0x80001040,
28561 0x18000: 0x40,
28562 0x28000: 0x80400040,
28563 0x38000: 0x80001000,
28564 0x48000: 0x401000,
28565 0x58000: 0x80401040,
28566 0x68000: 0x0,
28567 0x78000: 0x80400000,
28568 0x88000: 0x1000,
28569 0x98000: 0x80401000,
28570 0xa8000: 0x400000,
28571 0xb8000: 0x1040,
28572 0xc8000: 0x80000000,
28573 0xd8000: 0x400040,
28574 0xe8000: 0x401040,
28575 0xf8000: 0x80000040,
28576 0x100000: 0x400040,
28577 0x110000: 0x401000,
28578 0x120000: 0x80000040,
28579 0x130000: 0x0,
28580 0x140000: 0x1040,
28581 0x150000: 0x80400040,
28582 0x160000: 0x80401000,
28583 0x170000: 0x80001040,
28584 0x180000: 0x80401040,
28585 0x190000: 0x80000000,
28586 0x1a0000: 0x80400000,
28587 0x1b0000: 0x401040,
28588 0x1c0000: 0x80001000,
28589 0x1d0000: 0x400000,
28590 0x1e0000: 0x40,
28591 0x1f0000: 0x1000,
28592 0x108000: 0x80400000,
28593 0x118000: 0x80401040,
28594 0x128000: 0x0,
28595 0x138000: 0x401000,
28596 0x148000: 0x400040,
28597 0x158000: 0x80000000,
28598 0x168000: 0x80001040,
28599 0x178000: 0x40,
28600 0x188000: 0x80000040,
28601 0x198000: 0x1000,
28602 0x1a8000: 0x80001000,
28603 0x1b8000: 0x80400040,
28604 0x1c8000: 0x1040,
28605 0x1d8000: 0x80401000,
28606 0x1e8000: 0x400000,
28607 0x1f8000: 0x401040
28608 },
28609 {
28610 0x0: 0x80,
28611 0x1000: 0x1040000,
28612 0x2000: 0x40000,
28613 0x3000: 0x20000000,
28614 0x4000: 0x20040080,
28615 0x5000: 0x1000080,
28616 0x6000: 0x21000080,
28617 0x7000: 0x40080,
28618 0x8000: 0x1000000,
28619 0x9000: 0x20040000,
28620 0xa000: 0x20000080,
28621 0xb000: 0x21040080,
28622 0xc000: 0x21040000,
28623 0xd000: 0x0,
28624 0xe000: 0x1040080,
28625 0xf000: 0x21000000,
28626 0x800: 0x1040080,
28627 0x1800: 0x21000080,
28628 0x2800: 0x80,
28629 0x3800: 0x1040000,
28630 0x4800: 0x40000,
28631 0x5800: 0x20040080,
28632 0x6800: 0x21040000,
28633 0x7800: 0x20000000,
28634 0x8800: 0x20040000,
28635 0x9800: 0x0,
28636 0xa800: 0x21040080,
28637 0xb800: 0x1000080,
28638 0xc800: 0x20000080,
28639 0xd800: 0x21000000,
28640 0xe800: 0x1000000,
28641 0xf800: 0x40080,
28642 0x10000: 0x40000,
28643 0x11000: 0x80,
28644 0x12000: 0x20000000,
28645 0x13000: 0x21000080,
28646 0x14000: 0x1000080,
28647 0x15000: 0x21040000,
28648 0x16000: 0x20040080,
28649 0x17000: 0x1000000,
28650 0x18000: 0x21040080,
28651 0x19000: 0x21000000,
28652 0x1a000: 0x1040000,
28653 0x1b000: 0x20040000,
28654 0x1c000: 0x40080,
28655 0x1d000: 0x20000080,
28656 0x1e000: 0x0,
28657 0x1f000: 0x1040080,
28658 0x10800: 0x21000080,
28659 0x11800: 0x1000000,
28660 0x12800: 0x1040000,
28661 0x13800: 0x20040080,
28662 0x14800: 0x20000000,
28663 0x15800: 0x1040080,
28664 0x16800: 0x80,
28665 0x17800: 0x21040000,
28666 0x18800: 0x40080,
28667 0x19800: 0x21040080,
28668 0x1a800: 0x0,
28669 0x1b800: 0x21000000,
28670 0x1c800: 0x1000080,
28671 0x1d800: 0x40000,
28672 0x1e800: 0x20040000,
28673 0x1f800: 0x20000080
28674 },
28675 {
28676 0x0: 0x10000008,
28677 0x100: 0x2000,
28678 0x200: 0x10200000,
28679 0x300: 0x10202008,
28680 0x400: 0x10002000,
28681 0x500: 0x200000,
28682 0x600: 0x200008,
28683 0x700: 0x10000000,
28684 0x800: 0x0,
28685 0x900: 0x10002008,
28686 0xa00: 0x202000,
28687 0xb00: 0x8,
28688 0xc00: 0x10200008,
28689 0xd00: 0x202008,
28690 0xe00: 0x2008,
28691 0xf00: 0x10202000,
28692 0x80: 0x10200000,
28693 0x180: 0x10202008,
28694 0x280: 0x8,
28695 0x380: 0x200000,
28696 0x480: 0x202008,
28697 0x580: 0x10000008,
28698 0x680: 0x10002000,
28699 0x780: 0x2008,
28700 0x880: 0x200008,
28701 0x980: 0x2000,
28702 0xa80: 0x10002008,
28703 0xb80: 0x10200008,
28704 0xc80: 0x0,
28705 0xd80: 0x10202000,
28706 0xe80: 0x202000,
28707 0xf80: 0x10000000,
28708 0x1000: 0x10002000,
28709 0x1100: 0x10200008,
28710 0x1200: 0x10202008,
28711 0x1300: 0x2008,
28712 0x1400: 0x200000,
28713 0x1500: 0x10000000,
28714 0x1600: 0x10000008,
28715 0x1700: 0x202000,
28716 0x1800: 0x202008,
28717 0x1900: 0x0,
28718 0x1a00: 0x8,
28719 0x1b00: 0x10200000,
28720 0x1c00: 0x2000,
28721 0x1d00: 0x10002008,
28722 0x1e00: 0x10202000,
28723 0x1f00: 0x200008,
28724 0x1080: 0x8,
28725 0x1180: 0x202000,
28726 0x1280: 0x200000,
28727 0x1380: 0x10000008,
28728 0x1480: 0x10002000,
28729 0x1580: 0x2008,
28730 0x1680: 0x10202008,
28731 0x1780: 0x10200000,
28732 0x1880: 0x10202000,
28733 0x1980: 0x10200008,
28734 0x1a80: 0x2000,
28735 0x1b80: 0x202008,
28736 0x1c80: 0x200008,
28737 0x1d80: 0x0,
28738 0x1e80: 0x10000000,
28739 0x1f80: 0x10002008
28740 },
28741 {
28742 0x0: 0x100000,
28743 0x10: 0x2000401,
28744 0x20: 0x400,
28745 0x30: 0x100401,
28746 0x40: 0x2100401,
28747 0x50: 0x0,
28748 0x60: 0x1,
28749 0x70: 0x2100001,
28750 0x80: 0x2000400,
28751 0x90: 0x100001,
28752 0xa0: 0x2000001,
28753 0xb0: 0x2100400,
28754 0xc0: 0x2100000,
28755 0xd0: 0x401,
28756 0xe0: 0x100400,
28757 0xf0: 0x2000000,
28758 0x8: 0x2100001,
28759 0x18: 0x0,
28760 0x28: 0x2000401,
28761 0x38: 0x2100400,
28762 0x48: 0x100000,
28763 0x58: 0x2000001,
28764 0x68: 0x2000000,
28765 0x78: 0x401,
28766 0x88: 0x100401,
28767 0x98: 0x2000400,
28768 0xa8: 0x2100000,
28769 0xb8: 0x100001,
28770 0xc8: 0x400,
28771 0xd8: 0x2100401,
28772 0xe8: 0x1,
28773 0xf8: 0x100400,
28774 0x100: 0x2000000,
28775 0x110: 0x100000,
28776 0x120: 0x2000401,
28777 0x130: 0x2100001,
28778 0x140: 0x100001,
28779 0x150: 0x2000400,
28780 0x160: 0x2100400,
28781 0x170: 0x100401,
28782 0x180: 0x401,
28783 0x190: 0x2100401,
28784 0x1a0: 0x100400,
28785 0x1b0: 0x1,
28786 0x1c0: 0x0,
28787 0x1d0: 0x2100000,
28788 0x1e0: 0x2000001,
28789 0x1f0: 0x400,
28790 0x108: 0x100400,
28791 0x118: 0x2000401,
28792 0x128: 0x2100001,
28793 0x138: 0x1,
28794 0x148: 0x2000000,
28795 0x158: 0x100000,
28796 0x168: 0x401,
28797 0x178: 0x2100400,
28798 0x188: 0x2000001,
28799 0x198: 0x2100000,
28800 0x1a8: 0x0,
28801 0x1b8: 0x2100401,
28802 0x1c8: 0x100401,
28803 0x1d8: 0x400,
28804 0x1e8: 0x2000400,
28805 0x1f8: 0x100001
28806 },
28807 {
28808 0x0: 0x8000820,
28809 0x1: 0x20000,
28810 0x2: 0x8000000,
28811 0x3: 0x20,
28812 0x4: 0x20020,
28813 0x5: 0x8020820,
28814 0x6: 0x8020800,
28815 0x7: 0x800,
28816 0x8: 0x8020000,
28817 0x9: 0x8000800,
28818 0xa: 0x20800,
28819 0xb: 0x8020020,
28820 0xc: 0x820,
28821 0xd: 0x0,
28822 0xe: 0x8000020,
28823 0xf: 0x20820,
28824 0x80000000: 0x800,
28825 0x80000001: 0x8020820,
28826 0x80000002: 0x8000820,
28827 0x80000003: 0x8000000,
28828 0x80000004: 0x8020000,
28829 0x80000005: 0x20800,
28830 0x80000006: 0x20820,
28831 0x80000007: 0x20,
28832 0x80000008: 0x8000020,
28833 0x80000009: 0x820,
28834 0x8000000a: 0x20020,
28835 0x8000000b: 0x8020800,
28836 0x8000000c: 0x0,
28837 0x8000000d: 0x8020020,
28838 0x8000000e: 0x8000800,
28839 0x8000000f: 0x20000,
28840 0x10: 0x20820,
28841 0x11: 0x8020800,
28842 0x12: 0x20,
28843 0x13: 0x800,
28844 0x14: 0x8000800,
28845 0x15: 0x8000020,
28846 0x16: 0x8020020,
28847 0x17: 0x20000,
28848 0x18: 0x0,
28849 0x19: 0x20020,
28850 0x1a: 0x8020000,
28851 0x1b: 0x8000820,
28852 0x1c: 0x8020820,
28853 0x1d: 0x20800,
28854 0x1e: 0x820,
28855 0x1f: 0x8000000,
28856 0x80000010: 0x20000,
28857 0x80000011: 0x800,
28858 0x80000012: 0x8020020,
28859 0x80000013: 0x20820,
28860 0x80000014: 0x20,
28861 0x80000015: 0x8020000,
28862 0x80000016: 0x8000000,
28863 0x80000017: 0x8000820,
28864 0x80000018: 0x8020820,
28865 0x80000019: 0x8000020,
28866 0x8000001a: 0x8000800,
28867 0x8000001b: 0x0,
28868 0x8000001c: 0x20800,
28869 0x8000001d: 0x820,
28870 0x8000001e: 0x20020,
28871 0x8000001f: 0x8020800
28872 }
28873 ];
28874
28875 // Masks that select the SBOX input
28876 var SBOX_MASK = [
28877 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
28878 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
28879 ];
28880
28881 /**
28882 * DES block cipher algorithm.
28883 */
28884 var DES = C_algo.DES = BlockCipher.extend({
28885 _doReset: function () {
28886 // Shortcuts
28887 var key = this._key;
28888 var keyWords = key.words;
28889
28890 // Select 56 bits according to PC1
28891 var keyBits = [];
28892 for (var i = 0; i < 56; i++) {
28893 var keyBitPos = PC1[i] - 1;
28894 keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
28895 }
28896
28897 // Assemble 16 subkeys
28898 var subKeys = this._subKeys = [];
28899 for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
28900 // Create subkey
28901 var subKey = subKeys[nSubKey] = [];
28902
28903 // Shortcut
28904 var bitShift = BIT_SHIFTS[nSubKey];
28905
28906 // Select 48 bits according to PC2
28907 for (var i = 0; i < 24; i++) {
28908 // Select from the left 28 key bits
28909 subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
28910
28911 // Select from the right 28 key bits
28912 subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
28913 }
28914
28915 // Since each subkey is applied to an expanded 32-bit input,
28916 // the subkey can be broken into 8 values scaled to 32-bits,
28917 // which allows the key to be used without expansion
28918 subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
28919 for (var i = 1; i < 7; i++) {
28920 subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
28921 }
28922 subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
28923 }
28924
28925 // Compute inverse subkeys
28926 var invSubKeys = this._invSubKeys = [];
28927 for (var i = 0; i < 16; i++) {
28928 invSubKeys[i] = subKeys[15 - i];
28929 }
28930 },
28931
28932 encryptBlock: function (M, offset) {
28933 this._doCryptBlock(M, offset, this._subKeys);
28934 },
28935
28936 decryptBlock: function (M, offset) {
28937 this._doCryptBlock(M, offset, this._invSubKeys);
28938 },
28939
28940 _doCryptBlock: function (M, offset, subKeys) {
28941 // Get input
28942 this._lBlock = M[offset];
28943 this._rBlock = M[offset + 1];
28944
28945 // Initial permutation
28946 exchangeLR.call(this, 4, 0x0f0f0f0f);
28947 exchangeLR.call(this, 16, 0x0000ffff);
28948 exchangeRL.call(this, 2, 0x33333333);
28949 exchangeRL.call(this, 8, 0x00ff00ff);
28950 exchangeLR.call(this, 1, 0x55555555);
28951
28952 // Rounds
28953 for (var round = 0; round < 16; round++) {
28954 // Shortcuts
28955 var subKey = subKeys[round];
28956 var lBlock = this._lBlock;
28957 var rBlock = this._rBlock;
28958
28959 // Feistel function
28960 var f = 0;
28961 for (var i = 0; i < 8; i++) {
28962 f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
28963 }
28964 this._lBlock = rBlock;
28965 this._rBlock = lBlock ^ f;
28966 }
28967
28968 // Undo swap from last round
28969 var t = this._lBlock;
28970 this._lBlock = this._rBlock;
28971 this._rBlock = t;
28972
28973 // Final permutation
28974 exchangeLR.call(this, 1, 0x55555555);
28975 exchangeRL.call(this, 8, 0x00ff00ff);
28976 exchangeRL.call(this, 2, 0x33333333);
28977 exchangeLR.call(this, 16, 0x0000ffff);
28978 exchangeLR.call(this, 4, 0x0f0f0f0f);
28979
28980 // Set output
28981 M[offset] = this._lBlock;
28982 M[offset + 1] = this._rBlock;
28983 },
28984
28985 keySize: 64/32,
28986
28987 ivSize: 64/32,
28988
28989 blockSize: 64/32
28990 });
28991
28992 // Swap bits across the left and right words
28993 function exchangeLR(offset, mask) {
28994 var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
28995 this._rBlock ^= t;
28996 this._lBlock ^= t << offset;
28997 }
28998
28999 function exchangeRL(offset, mask) {
29000 var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
29001 this._lBlock ^= t;
29002 this._rBlock ^= t << offset;
29003 }
29004
29005 /**
29006 * Shortcut functions to the cipher's object interface.
29007 *
29008 * @example
29009 *
29010 * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
29011 * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
29012 */
29013 C.DES = BlockCipher._createHelper(DES);
29014
29015 /**
29016 * Triple-DES block cipher algorithm.
29017 */
29018 var TripleDES = C_algo.TripleDES = BlockCipher.extend({
29019 _doReset: function () {
29020 // Shortcuts
29021 var key = this._key;
29022 var keyWords = key.words;
29023
29024 // Create DES instances
29025 this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
29026 this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
29027 this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
29028 },
29029
29030 encryptBlock: function (M, offset) {
29031 this._des1.encryptBlock(M, offset);
29032 this._des2.decryptBlock(M, offset);
29033 this._des3.encryptBlock(M, offset);
29034 },
29035
29036 decryptBlock: function (M, offset) {
29037 this._des3.decryptBlock(M, offset);
29038 this._des2.encryptBlock(M, offset);
29039 this._des1.decryptBlock(M, offset);
29040 },
29041
29042 keySize: 192/32,
29043
29044 ivSize: 64/32,
29045
29046 blockSize: 64/32
29047 });
29048
29049 /**
29050 * Shortcut functions to the cipher's object interface.
29051 *
29052 * @example
29053 *
29054 * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
29055 * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
29056 */
29057 C.TripleDES = BlockCipher._createHelper(TripleDES);
29058 }());
29059
29060
29061 return CryptoJS.TripleDES;
29062
29063 }));
29064 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],62:[function(_dereq_,module,exports){
29065 ;(function (root, factory) {
29066 if (typeof exports === "object") {
29067 // CommonJS
29068 module.exports = exports = factory(_dereq_("./core"));
29069 }
29070 else if (typeof define === "function" && define.amd) {
29071 // AMD
29072 define(["./core"], factory);
29073 }
29074 else {
29075 // Global (browser)
29076 factory(root.CryptoJS);
29077 }
29078 }(this, function (CryptoJS) {
29079
29080 (function (undefined) {
29081 // Shortcuts
29082 var C = CryptoJS;
29083 var C_lib = C.lib;
29084 var Base = C_lib.Base;
29085 var X32WordArray = C_lib.WordArray;
29086
29087 /**
29088 * x64 namespace.
29089 */
29090 var C_x64 = C.x64 = {};
29091
29092 /**
29093 * A 64-bit word.
29094 */
29095 var X64Word = C_x64.Word = Base.extend({
29096 /**
29097 * Initializes a newly created 64-bit word.
29098 *
29099 * @param {number} high The high 32 bits.
29100 * @param {number} low The low 32 bits.
29101 *
29102 * @example
29103 *
29104 * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
29105 */
29106 init: function (high, low) {
29107 this.high = high;
29108 this.low = low;
29109 }
29110
29111 /**
29112 * Bitwise NOTs this word.
29113 *
29114 * @return {X64Word} A new x64-Word object after negating.
29115 *
29116 * @example
29117 *
29118 * var negated = x64Word.not();
29119 */
29120 // not: function () {
29121 // var high = ~this.high;
29122 // var low = ~this.low;
29123
29124 // return X64Word.create(high, low);
29125 // },
29126
29127 /**
29128 * Bitwise ANDs this word with the passed word.
29129 *
29130 * @param {X64Word} word The x64-Word to AND with this word.
29131 *
29132 * @return {X64Word} A new x64-Word object after ANDing.
29133 *
29134 * @example
29135 *
29136 * var anded = x64Word.and(anotherX64Word);
29137 */
29138 // and: function (word) {
29139 // var high = this.high & word.high;
29140 // var low = this.low & word.low;
29141
29142 // return X64Word.create(high, low);
29143 // },
29144
29145 /**
29146 * Bitwise ORs this word with the passed word.
29147 *
29148 * @param {X64Word} word The x64-Word to OR with this word.
29149 *
29150 * @return {X64Word} A new x64-Word object after ORing.
29151 *
29152 * @example
29153 *
29154 * var ored = x64Word.or(anotherX64Word);
29155 */
29156 // or: function (word) {
29157 // var high = this.high | word.high;
29158 // var low = this.low | word.low;
29159
29160 // return X64Word.create(high, low);
29161 // },
29162
29163 /**
29164 * Bitwise XORs this word with the passed word.
29165 *
29166 * @param {X64Word} word The x64-Word to XOR with this word.
29167 *
29168 * @return {X64Word} A new x64-Word object after XORing.
29169 *
29170 * @example
29171 *
29172 * var xored = x64Word.xor(anotherX64Word);
29173 */
29174 // xor: function (word) {
29175 // var high = this.high ^ word.high;
29176 // var low = this.low ^ word.low;
29177
29178 // return X64Word.create(high, low);
29179 // },
29180
29181 /**
29182 * Shifts this word n bits to the left.
29183 *
29184 * @param {number} n The number of bits to shift.
29185 *
29186 * @return {X64Word} A new x64-Word object after shifting.
29187 *
29188 * @example
29189 *
29190 * var shifted = x64Word.shiftL(25);
29191 */
29192 // shiftL: function (n) {
29193 // if (n < 32) {
29194 // var high = (this.high << n) | (this.low >>> (32 - n));
29195 // var low = this.low << n;
29196 // } else {
29197 // var high = this.low << (n - 32);
29198 // var low = 0;
29199 // }
29200
29201 // return X64Word.create(high, low);
29202 // },
29203
29204 /**
29205 * Shifts this word n bits to the right.
29206 *
29207 * @param {number} n The number of bits to shift.
29208 *
29209 * @return {X64Word} A new x64-Word object after shifting.
29210 *
29211 * @example
29212 *
29213 * var shifted = x64Word.shiftR(7);
29214 */
29215 // shiftR: function (n) {
29216 // if (n < 32) {
29217 // var low = (this.low >>> n) | (this.high << (32 - n));
29218 // var high = this.high >>> n;
29219 // } else {
29220 // var low = this.high >>> (n - 32);
29221 // var high = 0;
29222 // }
29223
29224 // return X64Word.create(high, low);
29225 // },
29226
29227 /**
29228 * Rotates this word n bits to the left.
29229 *
29230 * @param {number} n The number of bits to rotate.
29231 *
29232 * @return {X64Word} A new x64-Word object after rotating.
29233 *
29234 * @example
29235 *
29236 * var rotated = x64Word.rotL(25);
29237 */
29238 // rotL: function (n) {
29239 // return this.shiftL(n).or(this.shiftR(64 - n));
29240 // },
29241
29242 /**
29243 * Rotates this word n bits to the right.
29244 *
29245 * @param {number} n The number of bits to rotate.
29246 *
29247 * @return {X64Word} A new x64-Word object after rotating.
29248 *
29249 * @example
29250 *
29251 * var rotated = x64Word.rotR(7);
29252 */
29253 // rotR: function (n) {
29254 // return this.shiftR(n).or(this.shiftL(64 - n));
29255 // },
29256
29257 /**
29258 * Adds this word with the passed word.
29259 *
29260 * @param {X64Word} word The x64-Word to add with this word.
29261 *
29262 * @return {X64Word} A new x64-Word object after adding.
29263 *
29264 * @example
29265 *
29266 * var added = x64Word.add(anotherX64Word);
29267 */
29268 // add: function (word) {
29269 // var low = (this.low + word.low) | 0;
29270 // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
29271 // var high = (this.high + word.high + carry) | 0;
29272
29273 // return X64Word.create(high, low);
29274 // }
29275 });
29276
29277 /**
29278 * An array of 64-bit words.
29279 *
29280 * @property {Array} words The array of CryptoJS.x64.Word objects.
29281 * @property {number} sigBytes The number of significant bytes in this word array.
29282 */
29283 var X64WordArray = C_x64.WordArray = Base.extend({
29284 /**
29285 * Initializes a newly created word array.
29286 *
29287 * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
29288 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
29289 *
29290 * @example
29291 *
29292 * var wordArray = CryptoJS.x64.WordArray.create();
29293 *
29294 * var wordArray = CryptoJS.x64.WordArray.create([
29295 * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
29296 * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
29297 * ]);
29298 *
29299 * var wordArray = CryptoJS.x64.WordArray.create([
29300 * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
29301 * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
29302 * ], 10);
29303 */
29304 init: function (words, sigBytes) {
29305 words = this.words = words || [];
29306
29307 if (sigBytes != undefined) {
29308 this.sigBytes = sigBytes;
29309 } else {
29310 this.sigBytes = words.length * 8;
29311 }
29312 },
29313
29314 /**
29315 * Converts this 64-bit word array to a 32-bit word array.
29316 *
29317 * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
29318 *
29319 * @example
29320 *
29321 * var x32WordArray = x64WordArray.toX32();
29322 */
29323 toX32: function () {
29324 // Shortcuts
29325 var x64Words = this.words;
29326 var x64WordsLength = x64Words.length;
29327
29328 // Convert
29329 var x32Words = [];
29330 for (var i = 0; i < x64WordsLength; i++) {
29331 var x64Word = x64Words[i];
29332 x32Words.push(x64Word.high);
29333 x32Words.push(x64Word.low);
29334 }
29335
29336 return X32WordArray.create(x32Words, this.sigBytes);
29337 },
29338
29339 /**
29340 * Creates a copy of this word array.
29341 *
29342 * @return {X64WordArray} The clone.
29343 *
29344 * @example
29345 *
29346 * var clone = x64WordArray.clone();
29347 */
29348 clone: function () {
29349 var clone = Base.clone.call(this);
29350
29351 // Clone "words" array
29352 var words = clone.words = this.words.slice(0);
29353
29354 // Clone each X64Word object
29355 var wordsLength = words.length;
29356 for (var i = 0; i < wordsLength; i++) {
29357 words[i] = words[i].clone();
29358 }
29359
29360 return clone;
29361 }
29362 });
29363 }());
29364
29365
29366 return CryptoJS;
29367
29368 }));
29369 },{"./core":31}],63:[function(_dereq_,module,exports){
29370 var assert = _dereq_('assert')
29371 var BigInteger = _dereq_('bigi')
29372
29373 var Point = _dereq_('./point')
29374
29375 function Curve(p, a, b, Gx, Gy, n, h) {
29376 this.p = p
29377 this.a = a
29378 this.b = b
29379 this.G = Point.fromAffine(this, Gx, Gy)
29380 this.n = n
29381 this.h = h
29382
29383 this.infinity = new Point(this, null, null, BigInteger.ZERO)
29384
29385 // result caching
29386 this.pOverFour = p.add(BigInteger.ONE).shiftRight(2)
29387 }
29388
29389 Curve.prototype.pointFromX = function(isOdd, x) {
29390 var alpha = x.pow(3).add(this.a.multiply(x)).add(this.b).mod(this.p)
29391 var beta = alpha.modPow(this.pOverFour, this.p)
29392
29393 var y = beta
29394 if (beta.isEven() ^ !isOdd) {
29395 y = this.p.subtract(y) // -y % p
29396 }
29397
29398 return Point.fromAffine(this, x, y)
29399 }
29400
29401 Curve.prototype.isInfinity = function(Q) {
29402 if (Q === this.infinity) return true
29403
29404 return Q.z.signum() === 0 && Q.y.signum() !== 0
29405 }
29406
29407 Curve.prototype.isOnCurve = function(Q) {
29408 if (this.isInfinity(Q)) return true
29409
29410 var x = Q.affineX
29411 var y = Q.affineY
29412 var a = this.a
29413 var b = this.b
29414 var p = this.p
29415
29416 // Check that xQ and yQ are integers in the interval [0, p - 1]
29417 if (x.signum() < 0 || x.compareTo(p) >= 0) return false
29418 if (y.signum() < 0 || y.compareTo(p) >= 0) return false
29419
29420 // and check that y^2 = x^3 + ax + b (mod p)
29421 var lhs = y.square().mod(p)
29422 var rhs = x.pow(3).add(a.multiply(x)).add(b).mod(p)
29423 return lhs.equals(rhs)
29424 }
29425
29426 /**
29427 * Validate an elliptic curve point.
29428 *
29429 * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive
29430 */
29431 Curve.prototype.validate = function(Q) {
29432 // Check Q != O
29433 assert(!this.isInfinity(Q), 'Point is at infinity')
29434 assert(this.isOnCurve(Q), 'Point is not on the curve')
29435
29436 // Check nQ = O (where Q is a scalar multiple of G)
29437 var nQ = Q.multiply(this.n)
29438 assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G')
29439
29440 return true
29441 }
29442
29443 module.exports = Curve
29444
29445 },{"./point":67,"assert":4,"bigi":3}],64:[function(_dereq_,module,exports){
29446 module.exports={
29447 "secp128r1": {
29448 "p": "fffffffdffffffffffffffffffffffff",
29449 "a": "fffffffdfffffffffffffffffffffffc",
29450 "b": "e87579c11079f43dd824993c2cee5ed3",
29451 "n": "fffffffe0000000075a30d1b9038a115",
29452 "h": "01",
29453 "Gx": "161ff7528b899b2d0c28607ca52c5b86",
29454 "Gy": "cf5ac8395bafeb13c02da292dded7a83"
29455 },
29456 "secp160k1": {
29457 "p": "fffffffffffffffffffffffffffffffeffffac73",
29458 "a": "00",
29459 "b": "07",
29460 "n": "0100000000000000000001b8fa16dfab9aca16b6b3",
29461 "h": "01",
29462 "Gx": "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",
29463 "Gy": "938cf935318fdced6bc28286531733c3f03c4fee"
29464 },
29465 "secp160r1": {
29466 "p": "ffffffffffffffffffffffffffffffff7fffffff",
29467 "a": "ffffffffffffffffffffffffffffffff7ffffffc",
29468 "b": "1c97befc54bd7a8b65acf89f81d4d4adc565fa45",
29469 "n": "0100000000000000000001f4c8f927aed3ca752257",
29470 "h": "01",
29471 "Gx": "4a96b5688ef573284664698968c38bb913cbfc82",
29472 "Gy": "23a628553168947d59dcc912042351377ac5fb32"
29473 },
29474 "secp192k1": {
29475 "p": "fffffffffffffffffffffffffffffffffffffffeffffee37",
29476 "a": "00",
29477 "b": "03",
29478 "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d",
29479 "h": "01",
29480 "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",
29481 "Gy": "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"
29482 },
29483 "secp192r1": {
29484 "p": "fffffffffffffffffffffffffffffffeffffffffffffffff",
29485 "a": "fffffffffffffffffffffffffffffffefffffffffffffffc",
29486 "b": "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",
29487 "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831",
29488 "h": "01",
29489 "Gx": "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",
29490 "Gy": "07192b95ffc8da78631011ed6b24cdd573f977a11e794811"
29491 },
29492 "secp224r1": {
29493 "p": "ffffffffffffffffffffffffffffffff000000000000000000000001",
29494 "a": "fffffffffffffffffffffffffffffffefffffffffffffffffffffffe",
29495 "b": "b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4",
29496 "n": "ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d",
29497 "h": "01",
29498 "Gx": "b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21",
29499 "Gy": "bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"
29500 },
29501 "secp256k1": {
29502 "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
29503 "a": "00",
29504 "b": "07",
29505 "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
29506 "h": "01",
29507 "Gx": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
29508 "Gy": "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
29509 },
29510 "secp256r1": {
29511 "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
29512 "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",
29513 "b": "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
29514 "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
29515 "h": "01",
29516 "Gx": "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
29517 "Gy": "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"
29518 }
29519 }
29520
29521 },{}],65:[function(_dereq_,module,exports){
29522 var Point = _dereq_('./point')
29523 var Curve = _dereq_('./curve')
29524
29525 var getCurveByName = _dereq_('./names')
29526
29527 module.exports = {
29528 Curve: Curve,
29529 Point: Point,
29530 getCurveByName: getCurveByName
29531 }
29532
29533 },{"./curve":63,"./names":66,"./point":67}],66:[function(_dereq_,module,exports){
29534 var BigInteger = _dereq_('bigi')
29535
29536 var curves = _dereq_('./curves')
29537 var Curve = _dereq_('./curve')
29538
29539 function getCurveByName(name) {
29540 var curve = curves[name]
29541 if (!curve) return null
29542
29543 var p = new BigInteger(curve.p, 16)
29544 var a = new BigInteger(curve.a, 16)
29545 var b = new BigInteger(curve.b, 16)
29546 var n = new BigInteger(curve.n, 16)
29547 var h = new BigInteger(curve.h, 16)
29548 var Gx = new BigInteger(curve.Gx, 16)
29549 var Gy = new BigInteger(curve.Gy, 16)
29550
29551 return new Curve(p, a, b, Gx, Gy, n, h)
29552 }
29553
29554 module.exports = getCurveByName
29555
29556 },{"./curve":63,"./curves":64,"bigi":3}],67:[function(_dereq_,module,exports){
29557 (function (Buffer){
29558 var assert = _dereq_('assert')
29559 var BigInteger = _dereq_('bigi')
29560
29561 var THREE = BigInteger.valueOf(3)
29562
29563 function Point(curve, x, y, z) {
29564 assert.notStrictEqual(z, undefined, 'Missing Z coordinate')
29565
29566 this.curve = curve
29567 this.x = x
29568 this.y = y
29569 this.z = z
29570 this._zInv = null
29571
29572 this.compressed = true
29573 }
29574
29575 Object.defineProperty(Point.prototype, 'zInv', {
29576 get: function() {
29577 if (this._zInv === null) {
29578 this._zInv = this.z.modInverse(this.curve.p)
29579 }
29580
29581 return this._zInv
29582 }
29583 })
29584
29585 Object.defineProperty(Point.prototype, 'affineX', {
29586 get: function() {
29587 return this.x.multiply(this.zInv).mod(this.curve.p)
29588 }
29589 })
29590
29591 Object.defineProperty(Point.prototype, 'affineY', {
29592 get: function() {
29593 return this.y.multiply(this.zInv).mod(this.curve.p)
29594 }
29595 })
29596
29597 Point.fromAffine = function(curve, x, y) {
29598 return new Point(curve, x, y, BigInteger.ONE)
29599 }
29600
29601 Point.prototype.equals = function(other) {
29602 if (other === this) return true
29603 if (this.curve.isInfinity(this)) return this.curve.isInfinity(other)
29604 if (this.curve.isInfinity(other)) return this.curve.isInfinity(this)
29605
29606 // u = Y2 * Z1 - Y1 * Z2
29607 var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p)
29608
29609 if (u.signum() !== 0) return false
29610
29611 // v = X2 * Z1 - X1 * Z2
29612 var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p)
29613
29614 return v.signum() === 0
29615 }
29616
29617 Point.prototype.negate = function() {
29618 var y = this.curve.p.subtract(this.y)
29619
29620 return new Point(this.curve, this.x, y, this.z)
29621 }
29622
29623 Point.prototype.add = function(b) {
29624 if (this.curve.isInfinity(this)) return b
29625 if (this.curve.isInfinity(b)) return this
29626
29627 var x1 = this.x
29628 var y1 = this.y
29629 var x2 = b.x
29630 var y2 = b.y
29631
29632 // u = Y2 * Z1 - Y1 * Z2
29633 var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p)
29634 // v = X2 * Z1 - X1 * Z2
29635 var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p)
29636
29637 if (v.signum() === 0) {
29638 if (u.signum() === 0) {
29639 return this.twice() // this == b, so double
29640 }
29641
29642 return this.curve.infinity // this = -b, so infinity
29643 }
29644
29645 var v2 = v.square()
29646 var v3 = v2.multiply(v)
29647 var x1v2 = x1.multiply(v2)
29648 var zu2 = u.square().multiply(this.z)
29649
29650 // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3)
29651 var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p)
29652 // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3
29653 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)
29654 // z3 = v^3 * z1 * z2
29655 var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p)
29656
29657 return new Point(this.curve, x3, y3, z3)
29658 }
29659
29660 Point.prototype.twice = function() {
29661 if (this.curve.isInfinity(this)) return this
29662 if (this.y.signum() === 0) return this.curve.infinity
29663
29664 var x1 = this.x
29665 var y1 = this.y
29666
29667 var y1z1 = y1.multiply(this.z)
29668 var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p)
29669 var a = this.curve.a
29670
29671 // w = 3 * x1^2 + a * z1^2
29672 var w = x1.square().multiply(THREE)
29673
29674 if (a.signum() !== 0) {
29675 w = w.add(this.z.square().multiply(a))
29676 }
29677
29678 w = w.mod(this.curve.p)
29679 // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1)
29680 var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.p)
29681 // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3
29682 var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.pow(3)).mod(this.curve.p)
29683 // z3 = 8 * (y1 * z1)^3
29684 var z3 = y1z1.pow(3).shiftLeft(3).mod(this.curve.p)
29685
29686 return new Point(this.curve, x3, y3, z3)
29687 }
29688
29689 // Simple NAF (Non-Adjacent Form) multiplication algorithm
29690 // TODO: modularize the multiplication algorithm
29691 Point.prototype.multiply = function(k) {
29692 if (this.curve.isInfinity(this)) return this
29693 if (k.signum() === 0) return this.curve.infinity
29694
29695 var e = k
29696 var h = e.multiply(THREE)
29697
29698 var neg = this.negate()
29699 var R = this
29700
29701 for (var i = h.bitLength() - 2; i > 0; --i) {
29702 R = R.twice()
29703
29704 var hBit = h.testBit(i)
29705 var eBit = e.testBit(i)
29706
29707 if (hBit != eBit) {
29708 R = R.add(hBit ? this : neg)
29709 }
29710 }
29711
29712 return R
29713 }
29714
29715 // Compute this*j + x*k (simultaneous multiplication)
29716 Point.prototype.multiplyTwo = function(j, x, k) {
29717 var i
29718
29719 if (j.bitLength() > k.bitLength())
29720 i = j.bitLength() - 1
29721 else
29722 i = k.bitLength() - 1
29723
29724 var R = this.curve.infinity
29725 var both = this.add(x)
29726
29727 while (i >= 0) {
29728 R = R.twice()
29729
29730 var jBit = j.testBit(i)
29731 var kBit = k.testBit(i)
29732
29733 if (jBit) {
29734 if (kBit) {
29735 R = R.add(both)
29736
29737 } else {
29738 R = R.add(this)
29739 }
29740
29741 } else {
29742 if (kBit) {
29743 R = R.add(x)
29744 }
29745 }
29746 --i
29747 }
29748
29749 return R
29750 }
29751
29752 Point.prototype.getEncoded = function(compressed) {
29753 if (compressed == undefined) compressed = this.compressed
29754 if (this.curve.isInfinity(this)) return new Buffer('00', 'hex') // Infinity point encoded is simply '00'
29755
29756 var x = this.affineX
29757 var y = this.affineY
29758
29759 var buffer
29760
29761 // Determine size of q in bytes
29762 var byteLength = Math.floor((this.curve.p.bitLength() + 7) / 8)
29763
29764 // 0x02/0x03 | X
29765 if (compressed) {
29766 buffer = new Buffer(1 + byteLength)
29767 buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0)
29768
29769 // 0x04 | X | Y
29770 } else {
29771 buffer = new Buffer(1 + byteLength + byteLength)
29772 buffer.writeUInt8(0x04, 0)
29773
29774 y.toBuffer(byteLength).copy(buffer, 1 + byteLength)
29775 }
29776
29777 x.toBuffer(byteLength).copy(buffer, 1)
29778
29779 return buffer
29780 }
29781
29782 Point.decodeFrom = function(curve, buffer) {
29783 var type = buffer.readUInt8(0)
29784 var compressed = (type !== 4)
29785
29786 var x = BigInteger.fromBuffer(buffer.slice(1, 33))
29787 var byteLength = Math.floor((curve.p.bitLength() + 7) / 8)
29788
29789 var Q
29790 if (compressed) {
29791 assert.equal(buffer.length, byteLength + 1, 'Invalid sequence length')
29792 assert(type === 0x02 || type === 0x03, 'Invalid sequence tag')
29793
29794 var isOdd = (type === 0x03)
29795 Q = curve.pointFromX(isOdd, x)
29796
29797 } else {
29798 assert.equal(buffer.length, 1 + byteLength + byteLength, 'Invalid sequence length')
29799
29800 var y = BigInteger.fromBuffer(buffer.slice(1 + byteLength))
29801 Q = Point.fromAffine(curve, x, y)
29802 }
29803
29804 Q.compressed = compressed
29805 return Q
29806 }
29807
29808 Point.prototype.toString = function () {
29809 if (this.curve.isInfinity(this)) return '(INFINITY)'
29810
29811 return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')'
29812 }
29813
29814 module.exports = Point
29815
29816 }).call(this,_dereq_("buffer").Buffer)
29817 },{"assert":4,"bigi":3,"buffer":8}],68:[function(_dereq_,module,exports){
29818 (function (process,Buffer){
29819 // Closure compiler error - result of 'not' operator not being used
29820 //!function(globals){
29821 (function(globals){
29822 'use strict'
29823
29824 //*** UMD BEGIN
29825 if (typeof define !== 'undefined' && define.amd) { //require.js / AMD
29826 define([], function() {
29827 return secureRandom
29828 })
29829 } else if (typeof module !== 'undefined' && module.exports) { //CommonJS
29830 module.exports = secureRandom
29831 } else { //script / browser
29832 globals.secureRandom = secureRandom
29833 }
29834 //*** UMD END
29835
29836 //options.type is the only valid option
29837 function secureRandom(count, options) {
29838 options = options || {type: 'Array'}
29839 //we check for process.pid to prevent browserify from tricking us
29840 if (typeof process != 'undefined' && typeof process.pid == 'number') {
29841 return nodeRandom(count, options)
29842 } else {
29843 var crypto = window.crypto || window.msCrypto
29844 if (!crypto) throw new Error("Your browser does not support window.crypto.")
29845 return browserRandom(count, options)
29846 }
29847 }
29848
29849 function nodeRandom(count, options) {
29850 var crypto = _dereq_('crypto')
29851 var buf = crypto.randomBytes(count)
29852
29853 switch (options.type) {
29854 case 'Array':
29855 return [].slice.call(buf)
29856 case 'Buffer':
29857 return buf
29858 case 'Uint8Array':
29859 var arr = new Uint8Array(count)
29860 for (var i = 0; i < count; ++i) { arr[i] = buf.readUInt8(i) }
29861 return arr
29862 default:
29863 throw new Error(options.type + " is unsupported.")
29864 }
29865 }
29866
29867 function browserRandom(count, options) {
29868 var nativeArr = new Uint8Array(count)
29869 var crypto = window.crypto || window.msCrypto
29870 crypto.getRandomValues(nativeArr)
29871
29872 switch (options.type) {
29873 case 'Array':
29874 return [].slice.call(nativeArr)
29875 case 'Buffer':
29876 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.')}
29877 return new Buffer(nativeArr)
29878 case 'Uint8Array':
29879 return nativeArr
29880 default:
29881 throw new Error(options.type + " is unsupported.")
29882 }
29883 }
29884
29885 secureRandom.randomArray = function(byteCount) {
29886 return secureRandom(byteCount, {type: 'Array'})
29887 }
29888
29889 secureRandom.randomUint8Array = function(byteCount) {
29890 return secureRandom(byteCount, {type: 'Uint8Array'})
29891 }
29892
29893 secureRandom.randomBuffer = function(byteCount) {
29894 return secureRandom(byteCount, {type: 'Buffer'})
29895 }
29896
29897
29898 })(this);
29899
29900 }).call(this,_dereq_("FWaASH"),_dereq_("buffer").Buffer)
29901 },{"FWaASH":12,"buffer":8,"crypto":7}],69:[function(_dereq_,module,exports){
29902 (function (Buffer){
29903 var assert = _dereq_('assert')
29904 var base58check = _dereq_('./base58check')
29905 var networks = _dereq_('./networks')
29906 var scripts = _dereq_('./scripts')
29907
29908 function findScriptTypeByVersion(version) {
29909 for (var networkName in networks) {
29910 var network = networks[networkName]
29911
29912 if (version === network.pubKeyHash) return 'pubkeyhash'
29913 if (version === network.scriptHash) return 'scripthash'
29914 }
29915 }
29916
29917 function Address(hash, version) {
29918 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
29919 assert.strictEqual(hash.length, 20, 'Invalid hash length')
29920 assert.strictEqual(version & 0xff, version, 'Invalid version byte')
29921
29922 this.hash = hash
29923 this.version = version
29924 }
29925
29926 // Import functions
29927 Address.fromBase58Check = function(string) {
29928 var payload = base58check.decode(string)
29929 var version = payload.readUInt8(0)
29930 var hash = payload.slice(1)
29931
29932 return new Address(hash, version)
29933 }
29934
29935 Address.fromOutputScript = function(script, network) {
29936 network = network || networks.bitcoin
29937
29938 var type = scripts.classifyOutput(script)
29939
29940 if (type === 'pubkeyhash') return new Address(script.chunks[2], network.pubKeyHash)
29941 if (type === 'scripthash') return new Address(script.chunks[1], network.scriptHash)
29942
29943 assert(false, type + ' has no matching Address')
29944 }
29945
29946 // Export functions
29947 Address.prototype.toBase58Check = function () {
29948 var payload = new Buffer(21)
29949 payload.writeUInt8(this.version, 0)
29950 this.hash.copy(payload, 1)
29951
29952 return base58check.encode(payload)
29953 }
29954
29955 Address.prototype.toOutputScript = function() {
29956 var scriptType = findScriptTypeByVersion(this.version)
29957
29958 if (scriptType === 'pubkeyhash') return scripts.pubKeyHashOutput(this.hash)
29959 if (scriptType === 'scripthash') return scripts.scriptHashOutput(this.hash)
29960
29961 assert(false, this.toString() + ' has no matching Script')
29962 }
29963
29964 Address.prototype.toString = Address.prototype.toBase58Check
29965
29966 module.exports = Address
29967
29968 }).call(this,_dereq_("buffer").Buffer)
29969 },{"./base58check":70,"./networks":81,"./scripts":84,"assert":4,"buffer":8}],70:[function(_dereq_,module,exports){
29970 (function (Buffer){
29971 // https://en.bitcoin.it/wiki/Base58Check_encoding
29972 var assert = _dereq_('assert')
29973 var base58 = _dereq_('bs58')
29974 var crypto = _dereq_('./crypto')
29975
29976 // Encode a buffer as a base58-check-encoded string
29977 function encode(payload) {
29978 var checksum = crypto.hash256(payload).slice(0, 4)
29979
29980 return base58.encode(Buffer.concat([
29981 payload,
29982 checksum
29983 ]))
29984 }
29985
29986 // Decode a base58-check-encoded string to a buffer
29987 function decode(string) {
29988 var buffer = base58.decode(string)
29989
29990 var payload = buffer.slice(0, -4)
29991 var checksum = buffer.slice(-4)
29992 var newChecksum = crypto.hash256(payload).slice(0, 4)
29993
29994 assert.deepEqual(newChecksum, checksum, 'Invalid checksum')
29995
29996 return payload
29997 }
29998
29999 module.exports = {
30000 encode: encode,
30001 decode: decode
30002 }
30003
30004 }).call(this,_dereq_("buffer").Buffer)
30005 },{"./crypto":73,"assert":4,"bs58":15,"buffer":8}],71:[function(_dereq_,module,exports){
30006 var assert = _dereq_('assert')
30007 var opcodes = _dereq_('./opcodes')
30008
30009 // https://github.com/feross/buffer/blob/master/index.js#L1127
30010 function verifuint(value, max) {
30011 assert(typeof value === 'number', 'cannot write a non-number as a number')
30012 assert(value >= 0, 'specified a negative value for writing an unsigned value')
30013 assert(value <= max, 'value is larger than maximum value for type')
30014 assert(Math.floor(value) === value, 'value has a fractional component')
30015 }
30016
30017 function pushDataSize(i) {
30018 return i < opcodes.OP_PUSHDATA1 ? 1
30019 : i < 0xff ? 2
30020 : i < 0xffff ? 3
30021 : 5
30022 }
30023
30024 function readPushDataInt(buffer, offset) {
30025 var opcode = buffer.readUInt8(offset)
30026 var number, size
30027
30028 // ~6 bit
30029 if (opcode < opcodes.OP_PUSHDATA1) {
30030 number = opcode
30031 size = 1
30032
30033 // 8 bit
30034 } else if (opcode === opcodes.OP_PUSHDATA1) {
30035 number = buffer.readUInt8(offset + 1)
30036 size = 2
30037
30038 // 16 bit
30039 } else if (opcode === opcodes.OP_PUSHDATA2) {
30040 number = buffer.readUInt16LE(offset + 1)
30041 size = 3
30042
30043 // 32 bit
30044 } else {
30045 assert.equal(opcode, opcodes.OP_PUSHDATA4, 'Unexpected opcode')
30046
30047 number = buffer.readUInt32LE(offset + 1)
30048 size = 5
30049
30050 }
30051
30052 return {
30053 opcode: opcode,
30054 number: number,
30055 size: size
30056 }
30057 }
30058
30059 function readUInt64LE(buffer, offset) {
30060 var a = buffer.readUInt32LE(offset)
30061 var b = buffer.readUInt32LE(offset + 4)
30062 b *= 0x100000000
30063
30064 verifuint(b + a, 0x001fffffffffffff)
30065
30066 return b + a
30067 }
30068
30069 function readVarInt(buffer, offset) {
30070 var t = buffer.readUInt8(offset)
30071 var number, size
30072
30073 // 8 bit
30074 if (t < 253) {
30075 number = t
30076 size = 1
30077
30078 // 16 bit
30079 } else if (t < 254) {
30080 number = buffer.readUInt16LE(offset + 1)
30081 size = 3
30082
30083 // 32 bit
30084 } else if (t < 255) {
30085 number = buffer.readUInt32LE(offset + 1)
30086 size = 5
30087
30088 // 64 bit
30089 } else {
30090 number = readUInt64LE(buffer, offset + 1)
30091 size = 9
30092 }
30093
30094 return {
30095 number: number,
30096 size: size
30097 }
30098 }
30099
30100 function writePushDataInt(buffer, number, offset) {
30101 var size = pushDataSize(number)
30102
30103 // ~6 bit
30104 if (size === 1) {
30105 buffer.writeUInt8(number, offset)
30106
30107 // 8 bit
30108 } else if (size === 2) {
30109 buffer.writeUInt8(opcodes.OP_PUSHDATA1, offset)
30110 buffer.writeUInt8(number, offset + 1)
30111
30112 // 16 bit
30113 } else if (size === 3) {
30114 buffer.writeUInt8(opcodes.OP_PUSHDATA2, offset)
30115 buffer.writeUInt16LE(number, offset + 1)
30116
30117 // 32 bit
30118 } else {
30119 buffer.writeUInt8(opcodes.OP_PUSHDATA4, offset)
30120 buffer.writeUInt32LE(number, offset + 1)
30121
30122 }
30123
30124 return size
30125 }
30126
30127 function writeUInt64LE(buffer, value, offset) {
30128 verifuint(value, 0x001fffffffffffff)
30129
30130 buffer.writeInt32LE(value & -1, offset)
30131 buffer.writeUInt32LE(Math.floor(value / 0x100000000), offset + 4)
30132 }
30133
30134 function varIntSize(i) {
30135 return i < 253 ? 1
30136 : i < 0x10000 ? 3
30137 : i < 0x100000000 ? 5
30138 : 9
30139 }
30140
30141 function writeVarInt(buffer, number, offset) {
30142 var size = varIntSize(number)
30143
30144 // 8 bit
30145 if (size === 1) {
30146 buffer.writeUInt8(number, offset)
30147
30148 // 16 bit
30149 } else if (size === 3) {
30150 buffer.writeUInt8(253, offset)
30151 buffer.writeUInt16LE(number, offset + 1)
30152
30153 // 32 bit
30154 } else if (size === 5) {
30155 buffer.writeUInt8(254, offset)
30156 buffer.writeUInt32LE(number, offset + 1)
30157
30158 // 64 bit
30159 } else {
30160 buffer.writeUInt8(255, offset)
30161 writeUInt64LE(buffer, number, offset + 1)
30162 }
30163
30164 return size
30165 }
30166
30167 module.exports = {
30168 pushDataSize: pushDataSize,
30169 readPushDataInt: readPushDataInt,
30170 readUInt64LE: readUInt64LE,
30171 readVarInt: readVarInt,
30172 varIntSize: varIntSize,
30173 writePushDataInt: writePushDataInt,
30174 writeUInt64LE: writeUInt64LE,
30175 writeVarInt: writeVarInt
30176 }
30177
30178 },{"./opcodes":82,"assert":4}],72:[function(_dereq_,module,exports){
30179 (function (Buffer){
30180 var assert = _dereq_('assert')
30181 var Crypto = _dereq_('crypto-js')
30182 var WordArray = Crypto.lib.WordArray
30183
30184 function bufferToWordArray(buffer) {
30185 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got', buffer)
30186
30187 var words = []
30188 for (var i = 0, b = 0; i < buffer.length; i++, b += 8) {
30189 words[b >>> 5] |= buffer[i] << (24 - b % 32)
30190 }
30191
30192 return new WordArray.init(words, buffer.length)
30193 }
30194
30195 function wordArrayToBuffer(wordArray) {
30196 assert(Array.isArray(wordArray.words), 'Expected WordArray, got' + wordArray)
30197
30198 var words = wordArray.words
30199 var buffer = new Buffer(words.length * 4)
30200
30201 words.forEach(function(value, i) {
30202 buffer.writeInt32BE(value & -1, i * 4)
30203 })
30204
30205 return buffer
30206 }
30207
30208 module.exports = {
30209 bufferToWordArray: bufferToWordArray,
30210 wordArrayToBuffer: wordArrayToBuffer
30211 }
30212
30213 }).call(this,_dereq_("buffer").Buffer)
30214 },{"assert":4,"buffer":8,"crypto-js":37}],73:[function(_dereq_,module,exports){
30215 (function (Buffer){
30216 // Crypto, crypto, where art thou crypto
30217 var assert = _dereq_('assert')
30218 var CryptoJS = _dereq_('crypto-js')
30219 var crypto = _dereq_('crypto')
30220 var convert = _dereq_('./convert')
30221
30222 function hash160(buffer) {
30223 return ripemd160(sha256(buffer))
30224 }
30225
30226 function hash256(buffer) {
30227 return sha256(sha256(buffer))
30228 }
30229
30230 function ripemd160(buffer) {
30231 return crypto.createHash('rmd160').update(buffer).digest()
30232 }
30233
30234 function sha1(buffer) {
30235 return crypto.createHash('sha1').update(buffer).digest()
30236 }
30237
30238 function sha256(buffer) {
30239 return crypto.createHash('sha256').update(buffer).digest()
30240 }
30241
30242 // FIXME: Name not consistent with others
30243 function HmacSHA256(buffer, secret) {
30244 return crypto.createHmac('sha256', secret).update(buffer).digest()
30245 }
30246
30247 function HmacSHA512(data, secret) {
30248 assert(Buffer.isBuffer(data), 'Expected Buffer for data, got ' + data)
30249 assert(Buffer.isBuffer(secret), 'Expected Buffer for secret, got ' + secret)
30250
30251 var dataWords = convert.bufferToWordArray(data)
30252 var secretWords = convert.bufferToWordArray(secret)
30253
30254 var hash = CryptoJS.HmacSHA512(dataWords, secretWords)
30255
30256 return convert.wordArrayToBuffer(hash)
30257 }
30258
30259 module.exports = {
30260 ripemd160: ripemd160,
30261 sha1: sha1,
30262 sha256: sha256,
30263 hash160: hash160,
30264 hash256: hash256,
30265 HmacSHA256: HmacSHA256,
30266 HmacSHA512: HmacSHA512
30267 }
30268
30269 }).call(this,_dereq_("buffer").Buffer)
30270 },{"./convert":72,"assert":4,"buffer":8,"crypto":19,"crypto-js":37}],74:[function(_dereq_,module,exports){
30271 (function (Buffer){
30272 var assert = _dereq_('assert')
30273 var crypto = _dereq_('./crypto')
30274
30275 var BigInteger = _dereq_('bigi')
30276 var ECSignature = _dereq_('./ecsignature')
30277 var Point = _dereq_('ecurve').Point
30278
30279 // https://tools.ietf.org/html/rfc6979#section-3.2
30280 function deterministicGenerateK(curve, hash, d) {
30281 assert(Buffer.isBuffer(hash), 'Hash must be a Buffer, not ' + hash)
30282 assert.equal(hash.length, 32, 'Hash must be 256 bit')
30283 assert(d instanceof BigInteger, 'Private key must be a BigInteger')
30284
30285 var x = d.toBuffer(32)
30286 var k = new Buffer(32)
30287 var v = new Buffer(32)
30288
30289 // Step B
30290 v.fill(1)
30291
30292 // Step C
30293 k.fill(0)
30294
30295 // Step D
30296 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([0]), x, hash]), k)
30297
30298 // Step E
30299 v = crypto.HmacSHA256(v, k)
30300
30301 // Step F
30302 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([1]), x, hash]), k)
30303
30304 // Step G
30305 v = crypto.HmacSHA256(v, k)
30306
30307 // Step H1/H2a, ignored as tlen === qlen (256 bit)
30308 // Step H2b
30309 v = crypto.HmacSHA256(v, k)
30310
30311 var T = BigInteger.fromBuffer(v)
30312
30313 // Step H3, repeat until T is within the interval [1, n - 1]
30314 while ((T.signum() <= 0) || (T.compareTo(curve.n) >= 0)) {
30315 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([0])]), k)
30316 v = crypto.HmacSHA256(v, k)
30317
30318 T = BigInteger.fromBuffer(v)
30319 }
30320
30321 return T
30322 }
30323
30324 function sign(curve, hash, d) {
30325 var k = deterministicGenerateK(curve, hash, d)
30326
30327 var n = curve.n
30328 var G = curve.G
30329 var Q = G.multiply(k)
30330 var e = BigInteger.fromBuffer(hash)
30331
30332 var r = Q.affineX.mod(n)
30333 assert.notEqual(r.signum(), 0, 'Invalid R value')
30334
30335 var s = k.modInverse(n).multiply(e.add(d.multiply(r))).mod(n)
30336 assert.notEqual(s.signum(), 0, 'Invalid S value')
30337
30338 var N_OVER_TWO = n.shiftRight(1)
30339
30340 // enforce low S values, see bip62: 'low s values in signatures'
30341 if (s.compareTo(N_OVER_TWO) > 0) {
30342 s = n.subtract(s)
30343 }
30344
30345 return new ECSignature(r, s)
30346 }
30347
30348 function verify(curve, hash, signature, Q) {
30349 var e = BigInteger.fromBuffer(hash)
30350
30351 return verifyRaw(curve, e, signature, Q)
30352 }
30353
30354 function verifyRaw(curve, e, signature, Q) {
30355 var n = curve.n
30356 var G = curve.G
30357
30358 var r = signature.r
30359 var s = signature.s
30360
30361 if (r.signum() === 0 || r.compareTo(n) >= 0) return false
30362 if (s.signum() === 0 || s.compareTo(n) >= 0) return false
30363
30364 var c = s.modInverse(n)
30365
30366 var u1 = e.multiply(c).mod(n)
30367 var u2 = r.multiply(c).mod(n)
30368
30369 var point = G.multiplyTwo(u1, Q, u2)
30370 var v = point.affineX.mod(n)
30371
30372 return v.equals(r)
30373 }
30374
30375 /**
30376 * Recover a public key from a signature.
30377 *
30378 * See SEC 1: Elliptic Curve Cryptography, section 4.1.6, "Public
30379 * Key Recovery Operation".
30380 *
30381 * http://www.secg.org/download/aid-780/sec1-v2.pdf
30382 */
30383 function recoverPubKey(curve, e, signature, i) {
30384 assert.strictEqual(i & 3, i, 'Recovery param is more than two bits')
30385
30386 var r = signature.r
30387 var s = signature.s
30388
30389 // A set LSB signifies that the y-coordinate is odd
30390 var isYOdd = i & 1
30391
30392 // The more significant bit specifies whether we should use the
30393 // first or second candidate key.
30394 var isSecondKey = i >> 1
30395
30396 var n = curve.n
30397 var G = curve.G
30398
30399 // 1.1 Let x = r + jn
30400 var x = isSecondKey ? r.add(n) : r
30401 var R = curve.pointFromX(isYOdd, x)
30402
30403 // 1.4 Check that nR is at infinity
30404 var nR = R.multiply(n)
30405 assert(curve.isInfinity(nR), 'nR is not a valid curve point')
30406
30407 // Compute -e from e
30408 var eNeg = e.negate().mod(n)
30409
30410 // 1.6.1 Compute Q = r^-1 (sR - eG)
30411 // Q = r^-1 (sR + -eG)
30412 var rInv = r.modInverse(n)
30413
30414 var Q = R.multiplyTwo(s, G, eNeg).multiply(rInv)
30415 curve.validate(Q)
30416
30417 return Q
30418 }
30419
30420 /**
30421 * Calculate pubkey extraction parameter.
30422 *
30423 * When extracting a pubkey from a signature, we have to
30424 * distinguish four different cases. Rather than putting this
30425 * burden on the verifier, Bitcoin includes a 2-bit value with the
30426 * signature.
30427 *
30428 * This function simply tries all four cases and returns the value
30429 * that resulted in a successful pubkey recovery.
30430 */
30431 function calcPubKeyRecoveryParam(curve, e, signature, Q) {
30432 for (var i = 0; i < 4; i++) {
30433 var Qprime = recoverPubKey(curve, e, signature, i)
30434
30435 // 1.6.2 Verify Q
30436 if (Qprime.equals(Q)) {
30437 return i
30438 }
30439 }
30440
30441 throw new Error('Unable to find valid recovery factor')
30442 }
30443
30444 module.exports = {
30445 calcPubKeyRecoveryParam: calcPubKeyRecoveryParam,
30446 deterministicGenerateK: deterministicGenerateK,
30447 recoverPubKey: recoverPubKey,
30448 sign: sign,
30449 verify: verify,
30450 verifyRaw: verifyRaw
30451 }
30452
30453 }).call(this,_dereq_("buffer").Buffer)
30454 },{"./crypto":73,"./ecsignature":77,"assert":4,"bigi":3,"buffer":8,"ecurve":65}],75:[function(_dereq_,module,exports){
30455 (function (Buffer){
30456 var assert = _dereq_('assert')
30457 var base58check = _dereq_('./base58check')
30458 var ecdsa = _dereq_('./ecdsa')
30459 var networks = _dereq_('./networks')
30460 var secureRandom = _dereq_('secure-random')
30461
30462 var BigInteger = _dereq_('bigi')
30463 var ECPubKey = _dereq_('./ecpubkey')
30464
30465 var ecurve = _dereq_('ecurve')
30466 var curve = ecurve.getCurveByName('secp256k1')
30467
30468 function ECKey(d, compressed) {
30469 assert(d.signum() > 0, 'Private key must be greater than 0')
30470 assert(d.compareTo(curve.n) < 0, 'Private key must be less than the curve order')
30471
30472 var Q = curve.G.multiply(d)
30473
30474 this.d = d
30475 this.pub = new ECPubKey(Q, compressed)
30476 }
30477
30478 // Static constructors
30479 ECKey.fromWIF = function(string) {
30480 var payload = base58check.decode(string)
30481 var compressed = false
30482
30483 // Ignore the version byte
30484 payload = payload.slice(1)
30485
30486 if (payload.length === 33) {
30487 assert.strictEqual(payload[32], 0x01, 'Invalid compression flag')
30488
30489 // Truncate the compression flag
30490 payload = payload.slice(0, -1)
30491 compressed = true
30492 }
30493
30494 assert.equal(payload.length, 32, 'Invalid WIF payload length')
30495
30496 var d = BigInteger.fromBuffer(payload)
30497 return new ECKey(d, compressed)
30498 }
30499
30500 ECKey.makeRandom = function(compressed, rng) {
30501 rng = rng || secureRandom.randomBuffer
30502
30503 var buffer = rng(32)
30504 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)
30505
30506 var d = BigInteger.fromBuffer(buffer)
30507 d = d.mod(curve.n)
30508
30509 return new ECKey(d, compressed)
30510 }
30511
30512 // Export functions
30513 ECKey.prototype.toWIF = function(network) {
30514 network = network || networks.bitcoin
30515
30516 var bufferLen = this.pub.compressed ? 34 : 33
30517 var buffer = new Buffer(bufferLen)
30518
30519 buffer.writeUInt8(network.wif, 0)
30520 this.d.toBuffer(32).copy(buffer, 1)
30521
30522 if (this.pub.compressed) {
30523 buffer.writeUInt8(0x01, 33)
30524 }
30525
30526 return base58check.encode(buffer)
30527 }
30528
30529 // Operations
30530 ECKey.prototype.sign = function(hash) {
30531 return ecdsa.sign(curve, hash, this.d)
30532 }
30533
30534 module.exports = ECKey
30535
30536 }).call(this,_dereq_("buffer").Buffer)
30537 },{"./base58check":70,"./ecdsa":74,"./ecpubkey":76,"./networks":81,"assert":4,"bigi":3,"buffer":8,"ecurve":65,"secure-random":68}],76:[function(_dereq_,module,exports){
30538 (function (Buffer){
30539 var assert = _dereq_('assert')
30540 var crypto = _dereq_('./crypto')
30541 var ecdsa = _dereq_('./ecdsa')
30542 var networks = _dereq_('./networks')
30543
30544 var Address = _dereq_('./address')
30545
30546 var ecurve = _dereq_('ecurve')
30547 var curve = ecurve.getCurveByName('secp256k1')
30548
30549 function ECPubKey(Q, compressed) {
30550 assert(Q instanceof ecurve.Point, 'Expected Point, got ' + Q)
30551
30552 if (compressed == undefined) compressed = true
30553 assert.strictEqual(typeof compressed, 'boolean', 'Expected boolean, got ' + compressed)
30554
30555 this.compressed = compressed
30556 this.Q = Q
30557 }
30558
30559 // Static constructors
30560 ECPubKey.fromBuffer = function(buffer) {
30561 var Q = ecurve.Point.decodeFrom(curve, buffer)
30562 return new ECPubKey(Q, Q.compressed)
30563 }
30564
30565 ECPubKey.fromHex = function(hex) {
30566 return ECPubKey.fromBuffer(new Buffer(hex, 'hex'))
30567 }
30568
30569 // Operations
30570 ECPubKey.prototype.getAddress = function(network) {
30571 network = network || networks.bitcoin
30572
30573 return new Address(crypto.hash160(this.toBuffer()), network.pubKeyHash)
30574 }
30575
30576 ECPubKey.prototype.verify = function(hash, signature) {
30577 return ecdsa.verify(curve, hash, signature, this.Q)
30578 }
30579
30580 // Export functions
30581 ECPubKey.prototype.toBuffer = function() {
30582 return this.Q.getEncoded(this.compressed)
30583 }
30584
30585 ECPubKey.prototype.toHex = function() {
30586 return this.toBuffer().toString('hex')
30587 }
30588
30589 module.exports = ECPubKey
30590
30591 }).call(this,_dereq_("buffer").Buffer)
30592 },{"./address":69,"./crypto":73,"./ecdsa":74,"./networks":81,"assert":4,"buffer":8,"ecurve":65}],77:[function(_dereq_,module,exports){
30593 (function (Buffer){
30594 var assert = _dereq_('assert')
30595 var BigInteger = _dereq_('bigi')
30596
30597 function ECSignature(r, s) {
30598 assert(r instanceof BigInteger, 'Expected BigInteger, got ' + r)
30599 assert(s instanceof BigInteger, 'Expected BigInteger, got ' + s)
30600 this.r = r
30601 this.s = s
30602 }
30603
30604 // Import operations
30605 ECSignature.parseCompact = function(buffer) {
30606 assert.equal(buffer.length, 65, 'Invalid signature length')
30607 var i = buffer.readUInt8(0) - 27
30608
30609 // At most 3 bits
30610 assert.equal(i, i & 7, 'Invalid signature parameter')
30611 var compressed = !!(i & 4)
30612
30613 // Recovery param only
30614 i = i & 3
30615
30616 var r = BigInteger.fromBuffer(buffer.slice(1, 33))
30617 var s = BigInteger.fromBuffer(buffer.slice(33))
30618
30619 return {
30620 compressed: compressed,
30621 i: i,
30622 signature: new ECSignature(r, s)
30623 }
30624 }
30625
30626 ECSignature.fromDER = function(buffer) {
30627 assert.equal(buffer.readUInt8(0), 0x30, 'Not a DER sequence')
30628 assert.equal(buffer.readUInt8(1), buffer.length - 2, 'Invalid sequence length')
30629 assert.equal(buffer.readUInt8(2), 0x02, 'Expected a DER integer')
30630
30631 var rLen = buffer.readUInt8(3)
30632 assert(rLen > 0, 'R length is zero')
30633
30634 var offset = 4 + rLen
30635 assert.equal(buffer.readUInt8(offset), 0x02, 'Expected a DER integer (2)')
30636
30637 var sLen = buffer.readUInt8(offset + 1)
30638 assert(sLen > 0, 'S length is zero')
30639
30640 var rB = buffer.slice(4, offset)
30641 var sB = buffer.slice(offset + 2)
30642 offset += 2 + sLen
30643
30644 if (rLen > 1 && rB.readUInt8(0) === 0x00) {
30645 assert(rB.readUInt8(1) & 0x80, 'R value excessively padded')
30646 }
30647
30648 if (sLen > 1 && sB.readUInt8(0) === 0x00) {
30649 assert(sB.readUInt8(1) & 0x80, 'S value excessively padded')
30650 }
30651
30652 assert.equal(offset, buffer.length, 'Invalid DER encoding')
30653 var r = BigInteger.fromDERInteger(rB)
30654 var s = BigInteger.fromDERInteger(sB)
30655
30656 assert(r.signum() >= 0, 'R value is negative')
30657 assert(s.signum() >= 0, 'S value is negative')
30658
30659 return new ECSignature(r, s)
30660 }
30661
30662 // FIXME: 0x00, 0x04, 0x80 are SIGHASH_* boundary constants, importing Transaction causes a circular dependency
30663 ECSignature.parseScriptSignature = function(buffer) {
30664 var hashType = buffer.readUInt8(buffer.length - 1)
30665 var hashTypeMod = hashType & ~0x80
30666
30667 assert(hashTypeMod > 0x00 && hashTypeMod < 0x04, 'Invalid hashType')
30668
30669 return {
30670 signature: ECSignature.fromDER(buffer.slice(0, -1)),
30671 hashType: hashType
30672 }
30673 }
30674
30675 // Export operations
30676 ECSignature.prototype.toCompact = function(i, compressed) {
30677 if (compressed) i += 4
30678 i += 27
30679
30680 var buffer = new Buffer(65)
30681 buffer.writeUInt8(i, 0)
30682
30683 this.r.toBuffer(32).copy(buffer, 1)
30684 this.s.toBuffer(32).copy(buffer, 33)
30685
30686 return buffer
30687 }
30688
30689 ECSignature.prototype.toDER = function() {
30690 var rBa = this.r.toDERInteger()
30691 var sBa = this.s.toDERInteger()
30692
30693 var sequence = []
30694 sequence.push(0x02) // INTEGER
30695 sequence.push(rBa.length)
30696 sequence = sequence.concat(rBa)
30697
30698 sequence.push(0x02) // INTEGER
30699 sequence.push(sBa.length)
30700 sequence = sequence.concat(sBa)
30701
30702 sequence.unshift(sequence.length)
30703 sequence.unshift(0x30) // SEQUENCE
30704
30705 return new Buffer(sequence)
30706 }
30707
30708 ECSignature.prototype.toScriptSignature = function(hashType) {
30709 var hashTypeBuffer = new Buffer(1)
30710 hashTypeBuffer.writeUInt8(hashType, 0)
30711
30712 return Buffer.concat([this.toDER(), hashTypeBuffer])
30713 }
30714
30715 module.exports = ECSignature
30716
30717 }).call(this,_dereq_("buffer").Buffer)
30718 },{"assert":4,"bigi":3,"buffer":8}],78:[function(_dereq_,module,exports){
30719 (function (Buffer){
30720 var assert = _dereq_('assert')
30721 var base58check = _dereq_('./base58check')
30722 var crypto = _dereq_('./crypto')
30723 var networks = _dereq_('./networks')
30724
30725 var BigInteger = _dereq_('bigi')
30726 var ECKey = _dereq_('./eckey')
30727 var ECPubKey = _dereq_('./ecpubkey')
30728
30729 var ecurve = _dereq_('ecurve')
30730 var curve = ecurve.getCurveByName('secp256k1')
30731
30732 function findBIP32ParamsByVersion(version) {
30733 for (var name in networks) {
30734 var network = networks[name]
30735
30736 for (var type in network.bip32) {
30737 if (version != network.bip32[type]) continue
30738
30739 return {
30740 isPrivate: (type === 'private'),
30741 network: network
30742 }
30743 }
30744 }
30745
30746 assert(false, 'Could not find version ' + version.toString(16))
30747 }
30748
30749 function HDNode(K, chainCode, network) {
30750 network = network || networks.bitcoin
30751
30752 assert(Buffer.isBuffer(chainCode), 'Expected Buffer, got ' + chainCode)
30753 assert(network.bip32, 'Unknown BIP32 constants for network')
30754
30755 this.chainCode = chainCode
30756 this.depth = 0
30757 this.index = 0
30758 this.network = network
30759
30760 if (K instanceof BigInteger) {
30761 this.privKey = new ECKey(K, true)
30762 this.pubKey = this.privKey.pub
30763 } else {
30764 this.pubKey = new ECPubKey(K, true)
30765 }
30766 }
30767
30768 HDNode.MASTER_SECRET = new Buffer('Bitcoin seed')
30769 HDNode.HIGHEST_BIT = 0x80000000
30770 HDNode.LENGTH = 78
30771
30772 HDNode.fromSeedBuffer = function(seed, network) {
30773 var I = crypto.HmacSHA512(seed, HDNode.MASTER_SECRET)
30774 var IL = I.slice(0, 32)
30775 var IR = I.slice(32)
30776
30777 // In case IL is 0 or >= n, the master key is invalid
30778 // This is handled by `new ECKey` in the HDNode constructor
30779 var pIL = BigInteger.fromBuffer(IL)
30780
30781 return new HDNode(pIL, IR, network)
30782 }
30783
30784 HDNode.fromSeedHex = function(hex, network) {
30785 return HDNode.fromSeedBuffer(new Buffer(hex, 'hex'), network)
30786 }
30787
30788 HDNode.fromBase58 = function(string) {
30789 return HDNode.fromBuffer(base58check.decode(string))
30790 }
30791
30792 HDNode.fromBuffer = function(buffer) {
30793 assert.strictEqual(buffer.length, HDNode.LENGTH, 'Invalid buffer length')
30794
30795 // 4 byte: version bytes
30796 var version = buffer.readUInt32BE(0)
30797 var params = findBIP32ParamsByVersion(version)
30798
30799 // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ...
30800 var depth = buffer.readUInt8(4)
30801
30802 // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
30803 var parentFingerprint = buffer.readUInt32BE(5)
30804 if (depth === 0) {
30805 assert.strictEqual(parentFingerprint, 0x00000000, 'Invalid parent fingerprint')
30806 }
30807
30808 // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
30809 // This is encoded in MSB order. (0x00000000 if master key)
30810 var index = buffer.readUInt32BE(9)
30811 assert(depth > 0 || index === 0, 'Invalid index')
30812
30813 // 32 bytes: the chain code
30814 var chainCode = buffer.slice(13, 45)
30815 var hd
30816
30817 // 33 bytes: private key data (0x00 + k)
30818 if (params.isPrivate) {
30819 assert.strictEqual(buffer.readUInt8(45), 0x00, 'Invalid private key')
30820 var data = buffer.slice(46, 78)
30821 var d = BigInteger.fromBuffer(data)
30822 hd = new HDNode(d, chainCode, params.network)
30823
30824 // 33 bytes: public key data (0x02 + X or 0x03 + X)
30825 } else {
30826 var data = buffer.slice(45, 78)
30827 var Q = ecurve.Point.decodeFrom(curve, data)
30828 assert.equal(Q.compressed, true, 'Invalid public key')
30829
30830 // Verify that the X coordinate in the public point corresponds to a point on the curve.
30831 // If not, the extended public key is invalid.
30832 curve.validate(Q)
30833
30834 hd = new HDNode(Q, chainCode, params.network)
30835 }
30836
30837 hd.depth = depth
30838 hd.index = index
30839 hd.parentFingerprint = parentFingerprint
30840
30841 return hd
30842 }
30843
30844 HDNode.fromHex = function(hex) {
30845 return HDNode.fromBuffer(new Buffer(hex, 'hex'))
30846 }
30847
30848 HDNode.prototype.getIdentifier = function() {
30849 return crypto.hash160(this.pubKey.toBuffer())
30850 }
30851
30852 HDNode.prototype.getFingerprint = function() {
30853 return this.getIdentifier().slice(0, 4)
30854 }
30855
30856 HDNode.prototype.getAddress = function() {
30857 return this.pubKey.getAddress(this.network)
30858 }
30859
30860 HDNode.prototype.toBase58 = function(isPrivate) {
30861 return base58check.encode(this.toBuffer(isPrivate))
30862 }
30863
30864 HDNode.prototype.toBuffer = function(isPrivate) {
30865 if (isPrivate == undefined) isPrivate = !!this.privKey
30866
30867 // Version
30868 var version = isPrivate ? this.network.bip32.private : this.network.bip32.public
30869 var buffer = new Buffer(HDNode.LENGTH)
30870
30871 // 4 bytes: version bytes
30872 buffer.writeUInt32BE(version, 0)
30873
30874 // Depth
30875 // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ....
30876 buffer.writeUInt8(this.depth, 4)
30877
30878 // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
30879 var fingerprint = (this.depth === 0) ? 0x00000000 : this.parentFingerprint
30880 buffer.writeUInt32BE(fingerprint, 5)
30881
30882 // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
30883 // This is encoded in Big endian. (0x00000000 if master key)
30884 buffer.writeUInt32BE(this.index, 9)
30885
30886 // 32 bytes: the chain code
30887 this.chainCode.copy(buffer, 13)
30888
30889 // 33 bytes: the public key or private key data
30890 if (isPrivate) {
30891 assert(this.privKey, 'Missing private key')
30892
30893 // 0x00 + k for private keys
30894 buffer.writeUInt8(0, 45)
30895 this.privKey.d.toBuffer(32).copy(buffer, 46)
30896 } else {
30897
30898 // X9.62 encoding for public keys
30899 this.pubKey.toBuffer().copy(buffer, 45)
30900 }
30901
30902 return buffer
30903 }
30904
30905 HDNode.prototype.toHex = function(isPrivate) {
30906 return this.toBuffer(isPrivate).toString('hex')
30907 }
30908
30909 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
30910 HDNode.prototype.derive = function(index) {
30911 var isHardened = index >= HDNode.HIGHEST_BIT
30912 var indexBuffer = new Buffer(4)
30913 indexBuffer.writeUInt32BE(index, 0)
30914
30915 var data
30916
30917 // Hardened child
30918 if (isHardened) {
30919 assert(this.privKey, 'Could not derive hardened child key')
30920
30921 // data = 0x00 || ser256(kpar) || ser32(index)
30922 data = Buffer.concat([
30923 this.privKey.d.toBuffer(33),
30924 indexBuffer
30925 ])
30926
30927 // Normal child
30928 } else {
30929 // data = serP(point(kpar)) || ser32(index)
30930 // = serP(Kpar) || ser32(index)
30931 data = Buffer.concat([
30932 this.pubKey.toBuffer(),
30933 indexBuffer
30934 ])
30935 }
30936
30937 var I = crypto.HmacSHA512(data, this.chainCode)
30938 var IL = I.slice(0, 32)
30939 var IR = I.slice(32)
30940
30941 var pIL = BigInteger.fromBuffer(IL)
30942
30943 // In case parse256(IL) >= n, proceed with the next value for i
30944 if (pIL.compareTo(curve.n) >= 0) {
30945 return this.derive(index + 1)
30946 }
30947
30948 // Private parent key -> private child key
30949 var hd
30950 if (this.privKey) {
30951 // ki = parse256(IL) + kpar (mod n)
30952 var ki = pIL.add(this.privKey.d).mod(curve.n)
30953
30954 // In case ki == 0, proceed with the next value for i
30955 if (ki.signum() === 0) {
30956 return this.derive(index + 1)
30957 }
30958
30959 hd = new HDNode(ki, IR, this.network)
30960
30961 // Public parent key -> public child key
30962 } else {
30963 // Ki = point(parse256(IL)) + Kpar
30964 // = G*IL + Kpar
30965 var Ki = curve.G.multiply(pIL).add(this.pubKey.Q)
30966
30967 // In case Ki is the point at infinity, proceed with the next value for i
30968 if (curve.isInfinity(Ki)) {
30969 return this.derive(index + 1)
30970 }
30971
30972 hd = new HDNode(Ki, IR, this.network)
30973 }
30974
30975 hd.depth = this.depth + 1
30976 hd.index = index
30977 hd.parentFingerprint = this.getFingerprint().readUInt32BE(0)
30978
30979 return hd
30980 }
30981
30982 HDNode.prototype.deriveHardened = function(index) {
30983 // Only derives hardened private keys by default
30984 return this.derive(index + HDNode.HIGHEST_BIT)
30985 }
30986
30987 HDNode.prototype.toString = HDNode.prototype.toBase58
30988
30989 module.exports = HDNode
30990
30991 }).call(this,_dereq_("buffer").Buffer)
30992 },{"./base58check":70,"./crypto":73,"./eckey":75,"./ecpubkey":76,"./networks":81,"assert":4,"bigi":3,"buffer":8,"ecurve":65}],79:[function(_dereq_,module,exports){
30993 module.exports = {
30994 Address: _dereq_('./address'),
30995 base58check: _dereq_('./base58check'),
30996 bufferutils: _dereq_('./bufferutils'),
30997 convert: _dereq_('./convert'),
30998 crypto: _dereq_('./crypto'),
30999 ecdsa: _dereq_('./ecdsa'),
31000 ECKey: _dereq_('./eckey'),
31001 ECPubKey: _dereq_('./ecpubkey'),
31002 ECSignature: _dereq_('./ecsignature'),
31003 Message: _dereq_('./message'),
31004 opcodes: _dereq_('./opcodes'),
31005 HDNode: _dereq_('./hdnode'),
31006 Script: _dereq_('./script'),
31007 scripts: _dereq_('./scripts'),
31008 Transaction: _dereq_('./transaction'),
31009 networks: _dereq_('./networks'),
31010 Wallet: _dereq_('./wallet')
31011 }
31012
31013 },{"./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){
31014 (function (Buffer){
31015 /// Implements Bitcoin's feature for signing arbitrary messages.
31016 var Address = _dereq_('./address')
31017 var BigInteger = _dereq_('bigi')
31018 var bufferutils = _dereq_('./bufferutils')
31019 var crypto = _dereq_('./crypto')
31020 var ecdsa = _dereq_('./ecdsa')
31021 var networks = _dereq_('./networks')
31022
31023 var Address = _dereq_('./address')
31024 var ECPubKey = _dereq_('./ecpubkey')
31025 var ECSignature = _dereq_('./ecsignature')
31026
31027 var ecurve = _dereq_('ecurve')
31028 var ecparams = ecurve.getCurveByName('secp256k1')
31029
31030 function magicHash(message, network) {
31031 var magicPrefix = new Buffer(network.magicPrefix)
31032 var messageBuffer = new Buffer(message)
31033 var lengthBuffer = new Buffer(bufferutils.varIntSize(messageBuffer.length))
31034 bufferutils.writeVarInt(lengthBuffer, messageBuffer.length, 0)
31035
31036 var buffer = Buffer.concat([magicPrefix, lengthBuffer, messageBuffer])
31037 return crypto.hash256(buffer)
31038 }
31039
31040 function sign(privKey, message, network) {
31041 network = network || networks.bitcoin
31042
31043 var hash = magicHash(message, network)
31044 var signature = privKey.sign(hash)
31045 var e = BigInteger.fromBuffer(hash)
31046 var i = ecdsa.calcPubKeyRecoveryParam(ecparams, e, signature, privKey.pub.Q)
31047
31048 return signature.toCompact(i, privKey.pub.compressed)
31049 }
31050
31051 // TODO: network could be implied from address
31052 function verify(address, signatureBuffer, message, network) {
31053 if (address instanceof Address) {
31054 address = address.toString()
31055 }
31056 network = network || networks.bitcoin
31057
31058 var hash = magicHash(message, network)
31059 var parsed = ECSignature.parseCompact(signatureBuffer)
31060 var e = BigInteger.fromBuffer(hash)
31061 var Q = ecdsa.recoverPubKey(ecparams, e, parsed.signature, parsed.i)
31062
31063 var pubKey = new ECPubKey(Q, parsed.compressed)
31064 return pubKey.getAddress(network).toString() === address
31065 }
31066
31067 module.exports = {
31068 magicHash: magicHash,
31069 sign: sign,
31070 verify: verify
31071 }
31072
31073 }).call(this,_dereq_("buffer").Buffer)
31074 },{"./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){
31075 // https://en.bitcoin.it/wiki/List_of_address_prefixes
31076 // Dogecoin BIP32 is a proposed standard: https://bitcointalk.org/index.php?topic=409731
31077
31078 var networks = {
31079 bitcoin: {
31080 magicPrefix: '\x18Bitcoin Signed Message:\n',
31081 bip32: {
31082 public: 0x0488b21e,
31083 private: 0x0488ade4
31084 },
31085 pubKeyHash: 0x00,
31086 scriptHash: 0x05,
31087 wif: 0x80,
31088 dustThreshold: 546, // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/core.h#L151-L162
31089 feePerKb: 10000, // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/main.cpp#L53
31090 estimateFee: estimateFee('bitcoin')
31091 },
31092 dogecoin: {
31093 magicPrefix: '\x19Dogecoin Signed Message:\n',
31094 bip32: {
31095 public: 0x02facafd,
31096 private: 0x02fac398
31097 },
31098 pubKeyHash: 0x1e,
31099 scriptHash: 0x16,
31100 wif: 0x9e,
31101 dustThreshold: 0, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/core.h#L155-L160
31102 dustSoftThreshold: 100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.h#L62
31103 feePerKb: 100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.cpp#L58
31104 estimateFee: estimateFee('dogecoin')
31105 },
31106 litecoin: {
31107 magicPrefix: '\x19Litecoin Signed Message:\n',
31108 bip32: {
31109 public: 0x019da462,
31110 private: 0x019d9cfe
31111 },
31112 pubKeyHash: 0x30,
31113 scriptHash: 0x05,
31114 wif: 0xb0,
31115 dustThreshold: 0, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L360-L365
31116 dustSoftThreshold: 100000, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.h#L53
31117 feePerKb: 100000, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L56
31118 estimateFee: estimateFee('litecoin')
31119 },
31120 testnet: {
31121 magicPrefix: '\x18Bitcoin Signed Message:\n',
31122 bip32: {
31123 public: 0x043587cf,
31124 private: 0x04358394
31125 },
31126 pubKeyHash: 0x6f,
31127 scriptHash: 0xc4,
31128 wif: 0xef,
31129 dustThreshold: 546,
31130 feePerKb: 10000,
31131 estimateFee: estimateFee('testnet')
31132 }
31133 }
31134
31135 function estimateFee(type) {
31136 return function(tx) {
31137 var network = networks[type]
31138 var baseFee = network.feePerKb
31139 var byteSize = tx.toBuffer().length
31140
31141 var fee = baseFee * Math.ceil(byteSize / 1000)
31142 if (network.dustSoftThreshold == undefined) return fee
31143
31144 tx.outs.forEach(function(e){
31145 if (e.value < network.dustSoftThreshold) {
31146 fee += baseFee
31147 }
31148 })
31149
31150 return fee
31151 }
31152 }
31153
31154 module.exports = networks
31155
31156 },{}],82:[function(_dereq_,module,exports){
31157 module.exports = {
31158 // push value
31159 OP_FALSE : 0,
31160 OP_0 : 0,
31161 OP_PUSHDATA1 : 76,
31162 OP_PUSHDATA2 : 77,
31163 OP_PUSHDATA4 : 78,
31164 OP_1NEGATE : 79,
31165 OP_RESERVED : 80,
31166 OP_1 : 81,
31167 OP_TRUE : 81,
31168 OP_2 : 82,
31169 OP_3 : 83,
31170 OP_4 : 84,
31171 OP_5 : 85,
31172 OP_6 : 86,
31173 OP_7 : 87,
31174 OP_8 : 88,
31175 OP_9 : 89,
31176 OP_10 : 90,
31177 OP_11 : 91,
31178 OP_12 : 92,
31179 OP_13 : 93,
31180 OP_14 : 94,
31181 OP_15 : 95,
31182 OP_16 : 96,
31183
31184 // control
31185 OP_NOP : 97,
31186 OP_VER : 98,
31187 OP_IF : 99,
31188 OP_NOTIF : 100,
31189 OP_VERIF : 101,
31190 OP_VERNOTIF : 102,
31191 OP_ELSE : 103,
31192 OP_ENDIF : 104,
31193 OP_VERIFY : 105,
31194 OP_RETURN : 106,
31195
31196 // stack ops
31197 OP_TOALTSTACK : 107,
31198 OP_FROMALTSTACK : 108,
31199 OP_2DROP : 109,
31200 OP_2DUP : 110,
31201 OP_3DUP : 111,
31202 OP_2OVER : 112,
31203 OP_2ROT : 113,
31204 OP_2SWAP : 114,
31205 OP_IFDUP : 115,
31206 OP_DEPTH : 116,
31207 OP_DROP : 117,
31208 OP_DUP : 118,
31209 OP_NIP : 119,
31210 OP_OVER : 120,
31211 OP_PICK : 121,
31212 OP_ROLL : 122,
31213 OP_ROT : 123,
31214 OP_SWAP : 124,
31215 OP_TUCK : 125,
31216
31217 // splice ops
31218 OP_CAT : 126,
31219 OP_SUBSTR : 127,
31220 OP_LEFT : 128,
31221 OP_RIGHT : 129,
31222 OP_SIZE : 130,
31223
31224 // bit logic
31225 OP_INVERT : 131,
31226 OP_AND : 132,
31227 OP_OR : 133,
31228 OP_XOR : 134,
31229 OP_EQUAL : 135,
31230 OP_EQUALVERIFY : 136,
31231 OP_RESERVED1 : 137,
31232 OP_RESERVED2 : 138,
31233
31234 // numeric
31235 OP_1ADD : 139,
31236 OP_1SUB : 140,
31237 OP_2MUL : 141,
31238 OP_2DIV : 142,
31239 OP_NEGATE : 143,
31240 OP_ABS : 144,
31241 OP_NOT : 145,
31242 OP_0NOTEQUAL : 146,
31243
31244 OP_ADD : 147,
31245 OP_SUB : 148,
31246 OP_MUL : 149,
31247 OP_DIV : 150,
31248 OP_MOD : 151,
31249 OP_LSHIFT : 152,
31250 OP_RSHIFT : 153,
31251
31252 OP_BOOLAND : 154,
31253 OP_BOOLOR : 155,
31254 OP_NUMEQUAL : 156,
31255 OP_NUMEQUALVERIFY : 157,
31256 OP_NUMNOTEQUAL : 158,
31257 OP_LESSTHAN : 159,
31258 OP_GREATERTHAN : 160,
31259 OP_LESSTHANOREQUAL : 161,
31260 OP_GREATERTHANOREQUAL : 162,
31261 OP_MIN : 163,
31262 OP_MAX : 164,
31263
31264 OP_WITHIN : 165,
31265
31266 // crypto
31267 OP_RIPEMD160 : 166,
31268 OP_SHA1 : 167,
31269 OP_SHA256 : 168,
31270 OP_HASH160 : 169,
31271 OP_HASH256 : 170,
31272 OP_CODESEPARATOR : 171,
31273 OP_CHECKSIG : 172,
31274 OP_CHECKSIGVERIFY : 173,
31275 OP_CHECKMULTISIG : 174,
31276 OP_CHECKMULTISIGVERIFY : 175,
31277
31278 // expansion
31279 OP_NOP1 : 176,
31280 OP_NOP2 : 177,
31281 OP_NOP3 : 178,
31282 OP_NOP4 : 179,
31283 OP_NOP5 : 180,
31284 OP_NOP6 : 181,
31285 OP_NOP7 : 182,
31286 OP_NOP8 : 183,
31287 OP_NOP9 : 184,
31288 OP_NOP10 : 185,
31289
31290 // template matching params
31291 OP_PUBKEYHASH : 253,
31292 OP_PUBKEY : 254,
31293 OP_INVALIDOPCODE : 255
31294 }
31295
31296 },{}],83:[function(_dereq_,module,exports){
31297 (function (Buffer){
31298 var assert = _dereq_('assert')
31299 var bufferutils = _dereq_('./bufferutils')
31300 var crypto = _dereq_('./crypto')
31301 var opcodes = _dereq_('./opcodes')
31302
31303 function Script(buffer, chunks) {
31304 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)
31305 assert(Array.isArray(chunks), 'Expected Array, got ' + chunks)
31306
31307 this.buffer = buffer
31308 this.chunks = chunks
31309 }
31310
31311 // Import operations
31312 Script.fromASM = function(asm) {
31313 var strChunks = asm.split(' ')
31314
31315 var chunks = strChunks.map(function(strChunk) {
31316 if (strChunk in opcodes) {
31317 return opcodes[strChunk]
31318
31319 } else {
31320 return new Buffer(strChunk, 'hex')
31321 }
31322 })
31323
31324 return Script.fromChunks(chunks)
31325 }
31326
31327 Script.fromBuffer = function(buffer) {
31328 var chunks = []
31329
31330 var i = 0
31331
31332 while (i < buffer.length) {
31333 var opcode = buffer.readUInt8(i)
31334
31335 if ((opcode > opcodes.OP_0) && (opcode <= opcodes.OP_PUSHDATA4)) {
31336 var d = bufferutils.readPushDataInt(buffer, i)
31337 i += d.size
31338
31339 var data = buffer.slice(i, i + d.number)
31340 i += d.number
31341
31342 chunks.push(data)
31343
31344 } else {
31345 chunks.push(opcode)
31346
31347 i += 1
31348 }
31349 }
31350
31351 return new Script(buffer, chunks)
31352 }
31353
31354 Script.fromChunks = function(chunks) {
31355 assert(Array.isArray(chunks), 'Expected Array, got ' + chunks)
31356
31357 var bufferSize = chunks.reduce(function(accum, chunk) {
31358 if (Buffer.isBuffer(chunk)) {
31359 return accum + bufferutils.pushDataSize(chunk.length) + chunk.length
31360 }
31361
31362 return accum + 1
31363 }, 0.0)
31364
31365 var buffer = new Buffer(bufferSize)
31366 var offset = 0
31367
31368 chunks.forEach(function(chunk) {
31369 if (Buffer.isBuffer(chunk)) {
31370 offset += bufferutils.writePushDataInt(buffer, chunk.length, offset)
31371
31372 chunk.copy(buffer, offset)
31373 offset += chunk.length
31374
31375 } else {
31376 buffer.writeUInt8(chunk, offset)
31377 offset += 1
31378 }
31379 })
31380
31381 assert.equal(offset, buffer.length, 'Could not decode chunks')
31382 return new Script(buffer, chunks)
31383 }
31384
31385 Script.fromHex = function(hex) {
31386 return Script.fromBuffer(new Buffer(hex, 'hex'))
31387 }
31388
31389 // Constants
31390 Script.EMPTY = Script.fromChunks([])
31391
31392 // Operations
31393 Script.prototype.getHash = function() {
31394 return crypto.hash160(this.buffer)
31395 }
31396
31397 // FIXME: doesn't work for data chunks, maybe time to use buffertools.compare...
31398 Script.prototype.without = function(needle) {
31399 return Script.fromChunks(this.chunks.filter(function(op) {
31400 return op !== needle
31401 }))
31402 }
31403
31404 // Export operations
31405 var reverseOps = []
31406 for (var op in opcodes) {
31407 var code = opcodes[op]
31408 reverseOps[code] = op
31409 }
31410
31411 Script.prototype.toASM = function() {
31412 return this.chunks.map(function(chunk) {
31413 if (Buffer.isBuffer(chunk)) {
31414 return chunk.toString('hex')
31415
31416 } else {
31417 return reverseOps[chunk]
31418 }
31419 }).join(' ')
31420 }
31421
31422 Script.prototype.toBuffer = function() {
31423 return this.buffer
31424 }
31425
31426 Script.prototype.toHex = function() {
31427 return this.toBuffer().toString('hex')
31428 }
31429
31430 module.exports = Script
31431
31432 }).call(this,_dereq_("buffer").Buffer)
31433 },{"./bufferutils":71,"./crypto":73,"./opcodes":82,"assert":4,"buffer":8}],84:[function(_dereq_,module,exports){
31434 (function (Buffer){
31435 var assert = _dereq_('assert')
31436 var opcodes = _dereq_('./opcodes')
31437
31438 // FIXME: use ECPubKey, currently the circular dependency breaks everything.
31439 //
31440 // Solutions:
31441 // * Remove ECPubKey.getAddress
31442 // - Minimal change, but likely unpopular
31443 // * Move all script related functionality out of Address
31444 // - Means a lot of changes to Transaction/Wallet
31445 // * Ignore it (existing solution)
31446 // * Some form of hackery with commonjs
31447 //
31448 var ecurve = _dereq_('ecurve')
31449 var curve = ecurve.getCurveByName('secp256k1')
31450
31451 var ECSignature = _dereq_('./ecsignature')
31452 var Script = _dereq_('./script')
31453
31454 function classifyOutput(script) {
31455 assert(script instanceof Script, 'Expected Script, got ', script)
31456
31457 if (isPubKeyHashOutput.call(script)) {
31458 return 'pubkeyhash'
31459 } else if (isScriptHashOutput.call(script)) {
31460 return 'scripthash'
31461 } else if (isMultisigOutput.call(script)) {
31462 return 'multisig'
31463 } else if (isPubKeyOutput.call(script)) {
31464 return 'pubkey'
31465 } else if (isNulldataOutput.call(script)) {
31466 return 'nulldata'
31467 } else {
31468 return 'nonstandard'
31469 }
31470 }
31471
31472 function classifyInput(script) {
31473 assert(script instanceof Script, 'Expected Script, got ', script)
31474
31475 if (isPubKeyHashInput.call(script)) {
31476 return 'pubkeyhash'
31477 } else if (isScriptHashInput.call(script)) {
31478 return 'scripthash'
31479 } else if (isMultisigInput.call(script)) {
31480 return 'multisig'
31481 } else if (isPubKeyInput.call(script)) {
31482 return 'pubkey'
31483 } else {
31484 return 'nonstandard'
31485 }
31486 }
31487
31488 function isCanonicalPubKey(buffer) {
31489 if (!Buffer.isBuffer(buffer)) return false
31490
31491 try {
31492 // FIXME: boo
31493 ecurve.Point.decodeFrom(curve, buffer)
31494 } catch (e) {
31495 if (!(e.message.match(/Invalid sequence (length|tag)/))) throw e
31496
31497 return false
31498 }
31499
31500 return true
31501 }
31502
31503 function isCanonicalSignature(buffer) {
31504 if (!Buffer.isBuffer(buffer)) return false
31505
31506 try {
31507 ECSignature.parseScriptSignature(buffer)
31508 } catch(e) {
31509 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
31510
31511 return false
31512 }
31513
31514 return true
31515 }
31516
31517 function isPubKeyHashInput() {
31518 return this.chunks.length === 2 &&
31519 isCanonicalSignature(this.chunks[0]) &&
31520 isCanonicalPubKey(this.chunks[1])
31521 }
31522
31523 function isPubKeyHashOutput() {
31524 return this.chunks.length === 5 &&
31525 this.chunks[0] === opcodes.OP_DUP &&
31526 this.chunks[1] === opcodes.OP_HASH160 &&
31527 Buffer.isBuffer(this.chunks[2]) &&
31528 this.chunks[2].length === 20 &&
31529 this.chunks[3] === opcodes.OP_EQUALVERIFY &&
31530 this.chunks[4] === opcodes.OP_CHECKSIG
31531 }
31532
31533 function isPubKeyInput() {
31534 return this.chunks.length === 1 &&
31535 isCanonicalSignature(this.chunks[0])
31536 }
31537
31538 function isPubKeyOutput() {
31539 return this.chunks.length === 2 &&
31540 isCanonicalPubKey(this.chunks[0]) &&
31541 this.chunks[1] === opcodes.OP_CHECKSIG
31542 }
31543
31544 function isScriptHashInput() {
31545 if (this.chunks.length < 2) return false
31546 var lastChunk = this.chunks[this.chunks.length - 1]
31547
31548 if (!Buffer.isBuffer(lastChunk)) return false
31549
31550 var scriptSig = Script.fromChunks(this.chunks.slice(0, -1))
31551 var scriptPubKey = Script.fromBuffer(lastChunk)
31552
31553 return classifyInput(scriptSig) === classifyOutput(scriptPubKey)
31554 }
31555
31556 function isScriptHashOutput() {
31557 return this.chunks.length === 3 &&
31558 this.chunks[0] === opcodes.OP_HASH160 &&
31559 Buffer.isBuffer(this.chunks[1]) &&
31560 this.chunks[1].length === 20 &&
31561 this.chunks[2] === opcodes.OP_EQUAL
31562 }
31563
31564 function isMultisigInput() {
31565 return this.chunks[0] === opcodes.OP_0 &&
31566 this.chunks.slice(1).every(isCanonicalSignature)
31567 }
31568
31569 function isMultisigOutput() {
31570 if (this.chunks < 4) return false
31571 if (this.chunks[this.chunks.length - 1] !== opcodes.OP_CHECKMULTISIG) return false
31572
31573 var mOp = this.chunks[0]
31574 if (mOp === opcodes.OP_0) return false
31575 if (mOp < opcodes.OP_1) return false
31576 if (mOp > opcodes.OP_16) return false
31577
31578 var nOp = this.chunks[this.chunks.length - 2]
31579 if (nOp === opcodes.OP_0) return false
31580 if (nOp < opcodes.OP_1) return false
31581 if (nOp > opcodes.OP_16) return false
31582
31583 var m = mOp - (opcodes.OP_1 - 1)
31584 var n = nOp - (opcodes.OP_1 - 1)
31585 if (n < m) return false
31586
31587 var pubKeys = this.chunks.slice(1, -2)
31588 if (n < pubKeys.length) return false
31589
31590 return pubKeys.every(isCanonicalPubKey)
31591 }
31592
31593 function isNulldataOutput() {
31594 return this.chunks[0] === opcodes.OP_RETURN
31595 }
31596
31597 // Standard Script Templates
31598 // {pubKey} OP_CHECKSIG
31599 function pubKeyOutput(pubKey) {
31600 return Script.fromChunks([
31601 pubKey.toBuffer(),
31602 opcodes.OP_CHECKSIG
31603 ])
31604 }
31605
31606 // OP_DUP OP_HASH160 {pubKeyHash} OP_EQUALVERIFY OP_CHECKSIG
31607 function pubKeyHashOutput(hash) {
31608 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
31609
31610 return Script.fromChunks([
31611 opcodes.OP_DUP,
31612 opcodes.OP_HASH160,
31613 hash,
31614 opcodes.OP_EQUALVERIFY,
31615 opcodes.OP_CHECKSIG
31616 ])
31617 }
31618
31619 // OP_HASH160 {scriptHash} OP_EQUAL
31620 function scriptHashOutput(hash) {
31621 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
31622
31623 return Script.fromChunks([
31624 opcodes.OP_HASH160,
31625 hash,
31626 opcodes.OP_EQUAL
31627 ])
31628 }
31629
31630 // m [pubKeys ...] n OP_CHECKMULTISIG
31631 function multisigOutput(m, pubKeys) {
31632 assert(Array.isArray(pubKeys), 'Expected Array, got ' + pubKeys)
31633 assert(pubKeys.length >= m, 'Not enough pubKeys provided')
31634
31635 var pubKeyBuffers = pubKeys.map(function(pubKey) {
31636 return pubKey.toBuffer()
31637 })
31638 var n = pubKeys.length
31639
31640 return Script.fromChunks([].concat(
31641 (opcodes.OP_1 - 1) + m,
31642 pubKeyBuffers,
31643 (opcodes.OP_1 - 1) + n,
31644 opcodes.OP_CHECKMULTISIG
31645 ))
31646 }
31647
31648 // {signature}
31649 function pubKeyInput(signature) {
31650 assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
31651
31652 return Script.fromChunks([signature])
31653 }
31654
31655 // {signature} {pubKey}
31656 function pubKeyHashInput(signature, pubKey) {
31657 assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
31658
31659 return Script.fromChunks([signature, pubKey.toBuffer()])
31660 }
31661
31662 // <scriptSig> {serialized scriptPubKey script}
31663 function scriptHashInput(scriptSig, scriptPubKey) {
31664 return Script.fromChunks([].concat(
31665 scriptSig.chunks,
31666 scriptPubKey.toBuffer()
31667 ))
31668 }
31669
31670 // OP_0 [signatures ...]
31671 function multisigInput(signatures, scriptPubKey) {
31672 if (scriptPubKey) {
31673 assert(isMultisigOutput.call(scriptPubKey))
31674
31675 var m = scriptPubKey.chunks[0]
31676 var k = m - (opcodes.OP_1 - 1)
31677 assert(k <= signatures.length, 'Not enough signatures provided')
31678 }
31679
31680 return Script.fromChunks([].concat(opcodes.OP_0, signatures))
31681 }
31682
31683 module.exports = {
31684 classifyInput: classifyInput,
31685 classifyOutput: classifyOutput,
31686 multisigInput: multisigInput,
31687 multisigOutput: multisigOutput,
31688 pubKeyHashInput: pubKeyHashInput,
31689 pubKeyHashOutput: pubKeyHashOutput,
31690 pubKeyInput: pubKeyInput,
31691 pubKeyOutput: pubKeyOutput,
31692 scriptHashInput: scriptHashInput,
31693 scriptHashOutput: scriptHashOutput
31694 }
31695
31696 }).call(this,_dereq_("buffer").Buffer)
31697 },{"./ecsignature":77,"./opcodes":82,"./script":83,"assert":4,"buffer":8,"ecurve":65}],85:[function(_dereq_,module,exports){
31698 (function (Buffer){
31699 var assert = _dereq_('assert')
31700 var bufferutils = _dereq_('./bufferutils')
31701 var crypto = _dereq_('./crypto')
31702 var opcodes = _dereq_('./opcodes')
31703 var scripts = _dereq_('./scripts')
31704
31705 var Address = _dereq_('./address')
31706 var ECKey = _dereq_('./eckey')
31707 var ECSignature = _dereq_('./ecsignature')
31708 var Script = _dereq_('./script')
31709
31710 Transaction.DEFAULT_SEQUENCE = 0xffffffff
31711 Transaction.SIGHASH_ALL = 0x01
31712 Transaction.SIGHASH_NONE = 0x02
31713 Transaction.SIGHASH_SINGLE = 0x03
31714 Transaction.SIGHASH_ANYONECANPAY = 0x80
31715
31716 function Transaction() {
31717 this.version = 1
31718 this.locktime = 0
31719 this.ins = []
31720 this.outs = []
31721 }
31722
31723 /**
31724 * Create a new txin.
31725 *
31726 * Can be called with any of:
31727 *
31728 * - A transaction and an index
31729 * - A transaction hash and an index
31730 *
31731 * Note that this method does not sign the created input.
31732 */
31733 Transaction.prototype.addInput = function(tx, index, sequence) {
31734 if (sequence == undefined) sequence = Transaction.DEFAULT_SEQUENCE
31735
31736 var hash
31737
31738 if (typeof tx === 'string') {
31739 hash = new Buffer(tx, 'hex')
31740
31741 // TxId hex is big-endian, we need little-endian
31742 Array.prototype.reverse.call(hash)
31743
31744 } else if (tx instanceof Transaction) {
31745 hash = tx.getHash()
31746
31747 } else {
31748 hash = tx
31749 }
31750
31751 assert(Buffer.isBuffer(hash), 'Expected Transaction, txId or txHash, got ' + tx)
31752 assert.equal(hash.length, 32, 'Expected hash length of 32, got ' + hash.length)
31753 assert.equal(typeof index, 'number', 'Expected number index, got ' + index)
31754
31755 return (this.ins.push({
31756 hash: hash,
31757 index: index,
31758 script: Script.EMPTY,
31759 sequence: sequence
31760 }) - 1)
31761 }
31762
31763 /**
31764 * Create a new txout.
31765 *
31766 * Can be called with:
31767 *
31768 * - A base58 address string and a value
31769 * - An Address object and a value
31770 * - A scriptPubKey Script and a value
31771 */
31772 Transaction.prototype.addOutput = function(scriptPubKey, value) {
31773 // Attempt to get a valid address if it's a base58 address string
31774 if (typeof scriptPubKey === 'string') {
31775 scriptPubKey = Address.fromBase58Check(scriptPubKey)
31776 }
31777
31778 // Attempt to get a valid script if it's an Address object
31779 if (scriptPubKey instanceof Address) {
31780 var address = scriptPubKey
31781
31782 scriptPubKey = address.toOutputScript()
31783 }
31784
31785 return (this.outs.push({
31786 script: scriptPubKey,
31787 value: value,
31788 }) - 1)
31789 }
31790
31791 Transaction.prototype.toBuffer = function () {
31792 var txInSize = this.ins.reduce(function(a, x) {
31793 return a + (40 + bufferutils.varIntSize(x.script.buffer.length) + x.script.buffer.length)
31794 }, 0)
31795
31796 var txOutSize = this.outs.reduce(function(a, x) {
31797 return a + (8 + bufferutils.varIntSize(x.script.buffer.length) + x.script.buffer.length)
31798 }, 0)
31799
31800 var buffer = new Buffer(
31801 8 +
31802 bufferutils.varIntSize(this.ins.length) +
31803 bufferutils.varIntSize(this.outs.length) +
31804 txInSize +
31805 txOutSize
31806 )
31807
31808 var offset = 0
31809 function writeSlice(slice) {
31810 slice.copy(buffer, offset)
31811 offset += slice.length
31812 }
31813 function writeUInt32(i) {
31814 buffer.writeUInt32LE(i, offset)
31815 offset += 4
31816 }
31817 function writeUInt64(i) {
31818 bufferutils.writeUInt64LE(buffer, i, offset)
31819 offset += 8
31820 }
31821 function writeVarInt(i) {
31822 var n = bufferutils.writeVarInt(buffer, i, offset)
31823 offset += n
31824 }
31825
31826 writeUInt32(this.version)
31827 writeVarInt(this.ins.length)
31828
31829 this.ins.forEach(function(txin) {
31830 writeSlice(txin.hash)
31831 writeUInt32(txin.index)
31832 writeVarInt(txin.script.buffer.length)
31833 writeSlice(txin.script.buffer)
31834 writeUInt32(txin.sequence)
31835 })
31836
31837 writeVarInt(this.outs.length)
31838 this.outs.forEach(function(txout) {
31839 writeUInt64(txout.value)
31840 writeVarInt(txout.script.buffer.length)
31841 writeSlice(txout.script.buffer)
31842 })
31843
31844 writeUInt32(this.locktime)
31845
31846 return buffer
31847 }
31848
31849 Transaction.prototype.toHex = function() {
31850 return this.toBuffer().toString('hex')
31851 }
31852
31853 /**
31854 * Hash transaction for signing a specific input.
31855 *
31856 * Bitcoin uses a different hash for each signed transaction input. This
31857 * method copies the transaction, makes the necessary changes based on the
31858 * hashType, serializes and finally hashes the result. This hash can then be
31859 * used to sign the transaction input in question.
31860 */
31861 Transaction.prototype.hashForSignature = function(prevOutScript, inIndex, hashType) {
31862 assert(inIndex >= 0, 'Invalid vin index')
31863 assert(inIndex < this.ins.length, 'Invalid vin index')
31864 assert(prevOutScript instanceof Script, 'Invalid Script object')
31865
31866 var txTmp = this.clone()
31867 var hashScript = prevOutScript.without(opcodes.OP_CODESEPARATOR)
31868
31869 // Blank out other inputs' signatures
31870 txTmp.ins.forEach(function(txin) {
31871 txin.script = Script.EMPTY
31872 })
31873 txTmp.ins[inIndex].script = hashScript
31874
31875 var hashTypeModifier = hashType & 0x1f
31876 if (hashTypeModifier === Transaction.SIGHASH_NONE) {
31877 assert(false, 'SIGHASH_NONE not yet supported')
31878
31879 } else if (hashTypeModifier === Transaction.SIGHASH_SINGLE) {
31880 assert(false, 'SIGHASH_SINGLE not yet supported')
31881
31882 }
31883
31884 if (hashType & Transaction.SIGHASH_ANYONECANPAY) {
31885 assert(false, 'SIGHASH_ANYONECANPAY not yet supported')
31886 }
31887
31888 var hashTypeBuffer = new Buffer(4)
31889 hashTypeBuffer.writeInt32LE(hashType, 0)
31890
31891 var buffer = Buffer.concat([txTmp.toBuffer(), hashTypeBuffer])
31892 return crypto.hash256(buffer)
31893 }
31894
31895 Transaction.prototype.getHash = function () {
31896 return crypto.hash256(this.toBuffer())
31897 }
31898
31899 Transaction.prototype.getId = function () {
31900 var buffer = this.getHash()
31901
31902 // Big-endian is used for TxHash
31903 Array.prototype.reverse.call(buffer)
31904
31905 return buffer.toString('hex')
31906 }
31907
31908 Transaction.prototype.clone = function () {
31909 var newTx = new Transaction()
31910 newTx.version = this.version
31911 newTx.locktime = this.locktime
31912
31913 newTx.ins = this.ins.map(function(txin) {
31914 return {
31915 hash: txin.hash,
31916 index: txin.index,
31917 script: txin.script,
31918 sequence: txin.sequence
31919 }
31920 })
31921
31922 newTx.outs = this.outs.map(function(txout) {
31923 return {
31924 script: txout.script,
31925 value: txout.value
31926 }
31927 })
31928
31929 return newTx
31930 }
31931
31932 Transaction.fromBuffer = function(buffer) {
31933 var offset = 0
31934 function readSlice(n) {
31935 offset += n
31936 return buffer.slice(offset - n, offset)
31937 }
31938 function readUInt32() {
31939 var i = buffer.readUInt32LE(offset)
31940 offset += 4
31941 return i
31942 }
31943 function readUInt64() {
31944 var i = bufferutils.readUInt64LE(buffer, offset)
31945 offset += 8
31946 return i
31947 }
31948 function readVarInt() {
31949 var vi = bufferutils.readVarInt(buffer, offset)
31950 offset += vi.size
31951 return vi.number
31952 }
31953
31954 var tx = new Transaction()
31955 tx.version = readUInt32()
31956
31957 var vinLen = readVarInt()
31958 for (var i = 0; i < vinLen; ++i) {
31959 var hash = readSlice(32)
31960 var vout = readUInt32()
31961 var scriptLen = readVarInt()
31962 var script = readSlice(scriptLen)
31963 var sequence = readUInt32()
31964
31965 tx.ins.push({
31966 hash: hash,
31967 index: vout,
31968 script: Script.fromBuffer(script),
31969 sequence: sequence
31970 })
31971 }
31972
31973 var voutLen = readVarInt()
31974 for (i = 0; i < voutLen; ++i) {
31975 var value = readUInt64()
31976 var scriptLen = readVarInt()
31977 var script = readSlice(scriptLen)
31978
31979 tx.outs.push({
31980 value: value,
31981 script: Script.fromBuffer(script)
31982 })
31983 }
31984
31985 tx.locktime = readUInt32()
31986 assert.equal(offset, buffer.length, 'Transaction has unexpected data')
31987
31988 return tx
31989 }
31990
31991 Transaction.fromHex = function(hex) {
31992 return Transaction.fromBuffer(new Buffer(hex, 'hex'))
31993 }
31994
31995 /**
31996 * Signs a pubKeyHash output at some index with the given key
31997 */
31998 Transaction.prototype.sign = function(index, privKey, hashType) {
31999 var prevOutScript = privKey.pub.getAddress().toOutputScript()
32000 var signature = this.signInput(index, prevOutScript, privKey, hashType)
32001
32002 // FIXME: Assumed prior TX was pay-to-pubkey-hash
32003 var scriptSig = scripts.pubKeyHashInput(signature, privKey.pub)
32004 this.setInputScript(index, scriptSig)
32005 }
32006
32007 Transaction.prototype.signInput = function(index, prevOutScript, privKey, hashType) {
32008 hashType = hashType || Transaction.SIGHASH_ALL
32009
32010 var hash = this.hashForSignature(prevOutScript, index, hashType)
32011 var signature = privKey.sign(hash)
32012
32013 return signature.toScriptSignature(hashType)
32014 }
32015
32016 Transaction.prototype.setInputScript = function(index, script) {
32017 this.ins[index].script = script
32018 }
32019
32020 // FIXME: could be validateInput(index, prevTxOut, pub)
32021 Transaction.prototype.validateInput = function(index, prevOutScript, pubKey, buffer) {
32022 var parsed = ECSignature.parseScriptSignature(buffer)
32023 var hash = this.hashForSignature(prevOutScript, index, parsed.hashType)
32024
32025 return pubKey.verify(hash, parsed.signature)
32026 }
32027
32028 module.exports = Transaction
32029
32030 }).call(this,_dereq_("buffer").Buffer)
32031 },{"./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){
32032 (function (Buffer){
32033 var assert = _dereq_('assert')
32034 var networks = _dereq_('./networks')
32035 var rng = _dereq_('secure-random')
32036
32037 var Address = _dereq_('./address')
32038 var HDNode = _dereq_('./hdnode')
32039 var Transaction = _dereq_('./transaction')
32040
32041 function Wallet(seed, network) {
32042 network = network || networks.bitcoin
32043
32044 // Stored in a closure to make accidental serialization less likely
32045 var masterkey = null
32046 var me = this
32047 var accountZero = null
32048 var internalAccount = null
32049 var externalAccount = null
32050
32051 // Addresses
32052 this.addresses = []
32053 this.changeAddresses = []
32054
32055 // Transaction output data
32056 this.outputs = {}
32057
32058 // Make a new master key
32059 this.newMasterKey = function(seed) {
32060 seed = seed || new Buffer(rng(32))
32061 masterkey = HDNode.fromSeedBuffer(seed, network)
32062
32063 // HD first-level child derivation method should be hardened
32064 // See https://bitcointalk.org/index.php?topic=405179.msg4415254#msg4415254
32065 accountZero = masterkey.deriveHardened(0)
32066 externalAccount = accountZero.derive(0)
32067 internalAccount = accountZero.derive(1)
32068
32069 me.addresses = []
32070 me.changeAddresses = []
32071
32072 me.outputs = {}
32073 }
32074
32075 this.newMasterKey(seed)
32076
32077 this.generateAddress = function() {
32078 var key = externalAccount.derive(this.addresses.length)
32079 this.addresses.push(key.getAddress().toString())
32080 return this.addresses[this.addresses.length - 1]
32081 }
32082
32083 this.generateChangeAddress = function() {
32084 var key = internalAccount.derive(this.changeAddresses.length)
32085 this.changeAddresses.push(key.getAddress().toString())
32086 return this.changeAddresses[this.changeAddresses.length - 1]
32087 }
32088
32089 this.getBalance = function() {
32090 return this.getUnspentOutputs().reduce(function(memo, output){
32091 return memo + output.value
32092 }, 0)
32093 }
32094
32095 this.getUnspentOutputs = function() {
32096 var utxo = []
32097
32098 for(var key in this.outputs){
32099 var output = this.outputs[key]
32100 if(!output.to) utxo.push(outputToUnspentOutput(output))
32101 }
32102
32103 return utxo
32104 }
32105
32106 this.setUnspentOutputs = function(utxo) {
32107 var outputs = {}
32108
32109 utxo.forEach(function(uo){
32110 validateUnspentOutput(uo)
32111 var o = unspentOutputToOutput(uo)
32112 outputs[o.from] = o
32113 })
32114
32115 this.outputs = outputs
32116 }
32117
32118 function outputToUnspentOutput(output){
32119 var hashAndIndex = output.from.split(":")
32120
32121 return {
32122 hash: hashAndIndex[0],
32123 outputIndex: parseInt(hashAndIndex[1]),
32124 address: output.address,
32125 value: output.value,
32126 pending: output.pending
32127 }
32128 }
32129
32130 function unspentOutputToOutput(o) {
32131 var hash = o.hash
32132 var key = hash + ":" + o.outputIndex
32133 return {
32134 from: key,
32135 address: o.address,
32136 value: o.value,
32137 pending: o.pending
32138 }
32139 }
32140
32141 function validateUnspentOutput(uo) {
32142 var missingField
32143
32144 if (isNullOrUndefined(uo.hash)) {
32145 missingField = "hash"
32146 }
32147
32148 var requiredKeys = ['outputIndex', 'address', 'value']
32149 requiredKeys.forEach(function (key) {
32150 if (isNullOrUndefined(uo[key])){
32151 missingField = key
32152 }
32153 })
32154
32155 if (missingField) {
32156 var message = [
32157 'Invalid unspent output: key', missingField, 'is missing.',
32158 'A valid unspent output must contain'
32159 ]
32160 message.push(requiredKeys.join(', '))
32161 message.push("and hash")
32162 throw new Error(message.join(' '))
32163 }
32164 }
32165
32166 function isNullOrUndefined(value) {
32167 return value == undefined
32168 }
32169
32170 this.processPendingTx = function(tx){
32171 processTx(tx, true)
32172 }
32173
32174 this.processConfirmedTx = function(tx){
32175 processTx(tx, false)
32176 }
32177
32178 function processTx(tx, isPending) {
32179 var txid = tx.getId()
32180
32181 tx.outs.forEach(function(txOut, i) {
32182 var address
32183
32184 try {
32185 address = Address.fromOutputScript(txOut.script, network).toString()
32186 } catch(e) {
32187 if (!(e.message.match(/has no matching Address/))) throw e
32188 }
32189
32190 if (isMyAddress(address)) {
32191 var output = txid + ':' + i
32192
32193 me.outputs[output] = {
32194 from: output,
32195 value: txOut.value,
32196 address: address,
32197 pending: isPending
32198 }
32199 }
32200 })
32201
32202 tx.ins.forEach(function(txIn, i) {
32203 // copy and convert to big-endian hex
32204 var txinId = new Buffer(txIn.hash)
32205 Array.prototype.reverse.call(txinId)
32206 txinId = txinId.toString('hex')
32207
32208 var output = txinId + ':' + txIn.index
32209
32210 if (!(output in me.outputs)) return
32211
32212 if (isPending) {
32213 me.outputs[output].to = txid + ':' + i
32214 me.outputs[output].pending = true
32215 } else {
32216 delete me.outputs[output]
32217 }
32218 })
32219 }
32220
32221 this.createTx = function(to, value, fixedFee, changeAddress) {
32222 assert(value > network.dustThreshold, value + ' must be above dust threshold (' + network.dustThreshold + ' Satoshis)')
32223
32224 var utxos = getCandidateOutputs(value)
32225 var accum = 0
32226 var subTotal = value
32227 var addresses = []
32228
32229 var tx = new Transaction()
32230 tx.addOutput(to, value)
32231
32232 for (var i = 0; i < utxos.length; ++i) {
32233 var utxo = utxos[i]
32234 addresses.push(utxo.address)
32235
32236 var outpoint = utxo.from.split(':')
32237 tx.addInput(outpoint[0], parseInt(outpoint[1]))
32238
32239 var fee = fixedFee == undefined ? estimateFeePadChangeOutput(tx) : fixedFee
32240
32241 accum += utxo.value
32242 subTotal = value + fee
32243 if (accum >= subTotal) {
32244 var change = accum - subTotal
32245
32246 if (change > network.dustThreshold) {
32247 tx.addOutput(changeAddress || getChangeAddress(), change)
32248 }
32249
32250 break
32251 }
32252 }
32253
32254 assert(accum >= subTotal, 'Not enough funds (incl. fee): ' + accum + ' < ' + subTotal)
32255
32256 this.signWith(tx, addresses)
32257 return tx
32258 }
32259
32260 function getCandidateOutputs() {
32261 var unspent = []
32262
32263 for (var key in me.outputs) {
32264 var output = me.outputs[key]
32265 if (!output.pending) unspent.push(output)
32266 }
32267
32268 var sortByValueDesc = unspent.sort(function(o1, o2){
32269 return o2.value - o1.value
32270 })
32271
32272 return sortByValueDesc
32273 }
32274
32275 function estimateFeePadChangeOutput(tx) {
32276 var tmpTx = tx.clone()
32277 tmpTx.addOutput(getChangeAddress(), network.dustSoftThreshold || 0)
32278
32279 return network.estimateFee(tmpTx)
32280 }
32281
32282 function getChangeAddress() {
32283 if(me.changeAddresses.length === 0) me.generateChangeAddress();
32284 return me.changeAddresses[me.changeAddresses.length - 1]
32285 }
32286
32287 this.signWith = function(tx, addresses) {
32288 assert.equal(tx.ins.length, addresses.length, 'Number of addresses must match number of transaction inputs')
32289
32290 addresses.forEach(function(address, i) {
32291 var key = me.getPrivateKeyForAddress(address)
32292
32293 tx.sign(i, key)
32294 })
32295
32296 return tx
32297 }
32298
32299 this.getMasterKey = function() { return masterkey }
32300 this.getAccountZero = function() { return accountZero }
32301 this.getInternalAccount = function() { return internalAccount }
32302 this.getExternalAccount = function() { return externalAccount }
32303
32304 this.getPrivateKey = function(index) {
32305 return externalAccount.derive(index).privKey
32306 }
32307
32308 this.getInternalPrivateKey = function(index) {
32309 return internalAccount.derive(index).privKey
32310 }
32311
32312 this.getPrivateKeyForAddress = function(address) {
32313 var index
32314 if((index = this.addresses.indexOf(address)) > -1) {
32315 return this.getPrivateKey(index)
32316 } else if((index = this.changeAddresses.indexOf(address)) > -1) {
32317 return this.getInternalPrivateKey(index)
32318 } else {
32319 throw new Error('Unknown address. Make sure the address is from the keychain and has been generated.')
32320 }
32321 }
32322
32323 function isReceiveAddress(address){
32324 return me.addresses.indexOf(address) > -1
32325 }
32326
32327 function isChangeAddress(address){
32328 return me.changeAddresses.indexOf(address) > -1
32329 }
32330
32331 function isMyAddress(address) {
32332 return isReceiveAddress(address) || isChangeAddress(address)
32333 }
32334 }
32335
32336 module.exports = Wallet
32337
32338 }).call(this,_dereq_("buffer").Buffer)
32339 },{"./address":69,"./hdnode":78,"./networks":81,"./transaction":85,"assert":4,"buffer":8,"secure-random":68}]},{},[79])
32340 (79)
32341 });
32342 </script>
32343 <script>
32344 // Select components from sjcl to suit the crypto operations bip39 requires.
32345
32346 //// base.js
32347
32348 /** @fileOverview Javascript cryptography implementation.
32349 *
32350 * Crush to remove comments, shorten variable names and
32351 * generally reduce transmission size.
32352 *
32353 * @author Emily Stark
32354 * @author Mike Hamburg
32355 * @author Dan Boneh
32356 */
32357
32358 "use strict";
32359 /*jslint indent: 2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
32360 /*global document, window, escape, unescape, module, require, Uint32Array */
32361
32362 /** @namespace The Stanford Javascript Crypto Library, top-level namespace. */
32363 var sjcl = {
32364 /** @namespace Symmetric ciphers. */
32365 cipher: {},
32366
32367 /** @namespace Hash functions. Right now only SHA256 is implemented. */
32368 hash: {},
32369
32370 /** @namespace Key exchange functions. Right now only SRP is implemented. */
32371 keyexchange: {},
32372
32373 /** @namespace Block cipher modes of operation. */
32374 mode: {},
32375
32376 /** @namespace Miscellaneous. HMAC and PBKDF2. */
32377 misc: {},
32378
32379 /**
32380 * @namespace Bit array encoders and decoders.
32381 *
32382 * @description
32383 * The members of this namespace are functions which translate between
32384 * SJCL's bitArrays and other objects (usually strings). Because it
32385 * isn't always clear which direction is encoding and which is decoding,
32386 * the method names are "fromBits" and "toBits".
32387 */
32388 codec: {},
32389
32390 /** @namespace Exceptions. */
32391 exception: {
32392 /** @constructor Ciphertext is corrupt. */
32393 corrupt: function(message) {
32394 this.toString = function() { return "CORRUPT: "+this.message; };
32395 this.message = message;
32396 },
32397
32398 /** @constructor Invalid parameter. */
32399 invalid: function(message) {
32400 this.toString = function() { return "INVALID: "+this.message; };
32401 this.message = message;
32402 },
32403
32404 /** @constructor Bug or missing feature in SJCL. @constructor */
32405 bug: function(message) {
32406 this.toString = function() { return "BUG: "+this.message; };
32407 this.message = message;
32408 },
32409
32410 /** @constructor Something isn't ready. */
32411 notReady: function(message) {
32412 this.toString = function() { return "NOT READY: "+this.message; };
32413 this.message = message;
32414 }
32415 }
32416 };
32417
32418 if(typeof module !== 'undefined' && module.exports){
32419 module.exports = sjcl;
32420 }
32421 if (typeof define === "function") {
32422 define([], function () {
32423 return sjcl;
32424 });
32425 }
32426
32427
32428 //// bitArray.js
32429
32430 /** @fileOverview Arrays of bits, encoded as arrays of Numbers.
32431 *
32432 * @author Emily Stark
32433 * @author Mike Hamburg
32434 * @author Dan Boneh
32435 */
32436
32437 /** @namespace Arrays of bits, encoded as arrays of Numbers.
32438 *
32439 * @description
32440 * <p>
32441 * These objects are the currency accepted by SJCL's crypto functions.
32442 * </p>
32443 *
32444 * <p>
32445 * Most of our crypto primitives operate on arrays of 4-byte words internally,
32446 * but many of them can take arguments that are not a multiple of 4 bytes.
32447 * This library encodes arrays of bits (whose size need not be a multiple of 8
32448 * bits) as arrays of 32-bit words. The bits are packed, big-endian, into an
32449 * array of words, 32 bits at a time. Since the words are double-precision
32450 * floating point numbers, they fit some extra data. We use this (in a private,
32451 * possibly-changing manner) to encode the number of bits actually present
32452 * in the last word of the array.
32453 * </p>
32454 *
32455 * <p>
32456 * Because bitwise ops clear this out-of-band data, these arrays can be passed
32457 * to ciphers like AES which want arrays of words.
32458 * </p>
32459 */
32460 sjcl.bitArray = {
32461 /**
32462 * Array slices in units of bits.
32463 * @param {bitArray} a The array to slice.
32464 * @param {Number} bstart The offset to the start of the slice, in bits.
32465 * @param {Number} bend The offset to the end of the slice, in bits. If this is undefined,
32466 * slice until the end of the array.
32467 * @return {bitArray} The requested slice.
32468 */
32469 bitSlice: function (a, bstart, bend) {
32470 a = sjcl.bitArray._shiftRight(a.slice(bstart/32), 32 - (bstart & 31)).slice(1);
32471 return (bend === undefined) ? a : sjcl.bitArray.clamp(a, bend-bstart);
32472 },
32473
32474 /**
32475 * Extract a number packed into a bit array.
32476 * @param {bitArray} a The array to slice.
32477 * @param {Number} bstart The offset to the start of the slice, in bits.
32478 * @param {Number} length The length of the number to extract.
32479 * @return {Number} The requested slice.
32480 */
32481 extract: function(a, bstart, blength) {
32482 // FIXME: this Math.floor is not necessary at all, but for some reason
32483 // seems to suppress a bug in the Chromium JIT.
32484 var x, sh = Math.floor((-bstart-blength) & 31);
32485 if ((bstart + blength - 1 ^ bstart) & -32) {
32486 // it crosses a boundary
32487 x = (a[bstart/32|0] << (32 - sh)) ^ (a[bstart/32+1|0] >>> sh);
32488 } else {
32489 // within a single word
32490 x = a[bstart/32|0] >>> sh;
32491 }
32492 return x & ((1<<blength) - 1);
32493 },
32494
32495 /**
32496 * Concatenate two bit arrays.
32497 * @param {bitArray} a1 The first array.
32498 * @param {bitArray} a2 The second array.
32499 * @return {bitArray} The concatenation of a1 and a2.
32500 */
32501 concat: function (a1, a2) {
32502 if (a1.length === 0 || a2.length === 0) {
32503 return a1.concat(a2);
32504 }
32505
32506 var last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last);
32507 if (shift === 32) {
32508 return a1.concat(a2);
32509 } else {
32510 return sjcl.bitArray._shiftRight(a2, shift, last|0, a1.slice(0,a1.length-1));
32511 }
32512 },
32513
32514 /**
32515 * Find the length of an array of bits.
32516 * @param {bitArray} a The array.
32517 * @return {Number} The length of a, in bits.
32518 */
32519 bitLength: function (a) {
32520 var l = a.length, x;
32521 if (l === 0) { return 0; }
32522 x = a[l - 1];
32523 return (l-1) * 32 + sjcl.bitArray.getPartial(x);
32524 },
32525
32526 /**
32527 * Truncate an array.
32528 * @param {bitArray} a The array.
32529 * @param {Number} len The length to truncate to, in bits.
32530 * @return {bitArray} A new array, truncated to len bits.
32531 */
32532 clamp: function (a, len) {
32533 if (a.length * 32 < len) { return a; }
32534 a = a.slice(0, Math.ceil(len / 32));
32535 var l = a.length;
32536 len = len & 31;
32537 if (l > 0 && len) {
32538 a[l-1] = sjcl.bitArray.partial(len, a[l-1] & 0x80000000 >> (len-1), 1);
32539 }
32540 return a;
32541 },
32542
32543 /**
32544 * Make a partial word for a bit array.
32545 * @param {Number} len The number of bits in the word.
32546 * @param {Number} x The bits.
32547 * @param {Number} [0] _end Pass 1 if x has already been shifted to the high side.
32548 * @return {Number} The partial word.
32549 */
32550 partial: function (len, x, _end) {
32551 if (len === 32) { return x; }
32552 return (_end ? x|0 : x << (32-len)) + len * 0x10000000000;
32553 },
32554
32555 /**
32556 * Get the number of bits used by a partial word.
32557 * @param {Number} x The partial word.
32558 * @return {Number} The number of bits used by the partial word.
32559 */
32560 getPartial: function (x) {
32561 return Math.round(x/0x10000000000) || 32;
32562 },
32563
32564 /**
32565 * Compare two arrays for equality in a predictable amount of time.
32566 * @param {bitArray} a The first array.
32567 * @param {bitArray} b The second array.
32568 * @return {boolean} true if a == b; false otherwise.
32569 */
32570 equal: function (a, b) {
32571 if (sjcl.bitArray.bitLength(a) !== sjcl.bitArray.bitLength(b)) {
32572 return false;
32573 }
32574 var x = 0, i;
32575 for (i=0; i<a.length; i++) {
32576 x |= a[i]^b[i];
32577 }
32578 return (x === 0);
32579 },
32580
32581 /** Shift an array right.
32582 * @param {bitArray} a The array to shift.
32583 * @param {Number} shift The number of bits to shift.
32584 * @param {Number} [carry=0] A byte to carry in
32585 * @param {bitArray} [out=[]] An array to prepend to the output.
32586 * @private
32587 */
32588 _shiftRight: function (a, shift, carry, out) {
32589 var i, last2=0, shift2;
32590 if (out === undefined) { out = []; }
32591
32592 for (; shift >= 32; shift -= 32) {
32593 out.push(carry);
32594 carry = 0;
32595 }
32596 if (shift === 0) {
32597 return out.concat(a);
32598 }
32599
32600 for (i=0; i<a.length; i++) {
32601 out.push(carry | a[i]>>>shift);
32602 carry = a[i] << (32-shift);
32603 }
32604 last2 = a.length ? a[a.length-1] : 0;
32605 shift2 = sjcl.bitArray.getPartial(last2);
32606 out.push(sjcl.bitArray.partial(shift+shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(),1));
32607 return out;
32608 },
32609
32610 /** xor a block of 4 words together.
32611 * @private
32612 */
32613 _xor4: function(x,y) {
32614 return [x[0]^y[0],x[1]^y[1],x[2]^y[2],x[3]^y[3]];
32615 },
32616
32617 /** byteswap a word array inplace.
32618 * (does not handle partial words)
32619 * @param {sjcl.bitArray} a word array
32620 * @return {sjcl.bitArray} byteswapped array
32621 */
32622 byteswapM: function(a) {
32623 var i, v, m = 0xff00;
32624 for (i = 0; i < a.length; ++i) {
32625 v = a[i];
32626 a[i] = (v >>> 24) | ((v >>> 8) & m) | ((v & m) << 8) | (v << 24);
32627 }
32628 return a;
32629 }
32630 };
32631
32632
32633 //// codecString.js
32634
32635 /** @fileOverview Bit array codec implementations.
32636 *
32637 * @author Emily Stark
32638 * @author Mike Hamburg
32639 * @author Dan Boneh
32640 */
32641
32642 /** @namespace UTF-8 strings */
32643 sjcl.codec.utf8String = {
32644 /** Convert from a bitArray to a UTF-8 string. */
32645 fromBits: function (arr) {
32646 var out = "", bl = sjcl.bitArray.bitLength(arr), i, tmp;
32647 for (i=0; i<bl/8; i++) {
32648 if ((i&3) === 0) {
32649 tmp = arr[i/4];
32650 }
32651 out += String.fromCharCode(tmp >>> 24);
32652 tmp <<= 8;
32653 }
32654 return decodeURIComponent(escape(out));
32655 },
32656
32657 /** Convert from a UTF-8 string to a bitArray. */
32658 toBits: function (str) {
32659 str = unescape(encodeURIComponent(str));
32660 var out = [], i, tmp=0;
32661 for (i=0; i<str.length; i++) {
32662 tmp = tmp << 8 | str.charCodeAt(i);
32663 if ((i&3) === 3) {
32664 out.push(tmp);
32665 tmp = 0;
32666 }
32667 }
32668 if (i&3) {
32669 out.push(sjcl.bitArray.partial(8*(i&3), tmp));
32670 }
32671 return out;
32672 }
32673 };
32674
32675
32676 //// codecHex.js
32677
32678 /** @fileOverview Bit array codec implementations.
32679 *
32680 * @author Emily Stark
32681 * @author Mike Hamburg
32682 * @author Dan Boneh
32683 */
32684
32685 /** @namespace Hexadecimal */
32686 sjcl.codec.hex = {
32687 /** Convert from a bitArray to a hex string. */
32688 fromBits: function (arr) {
32689 var out = "", i;
32690 for (i=0; i<arr.length; i++) {
32691 out += ((arr[i]|0)+0xF00000000000).toString(16).substr(4);
32692 }
32693 return out.substr(0, sjcl.bitArray.bitLength(arr)/4);//.replace(/(.{8})/g, "$1 ");
32694 },
32695 /** Convert from a hex string to a bitArray. */
32696 toBits: function (str) {
32697 var i, out=[], len;
32698 str = str.replace(/\s|0x/g, "");
32699 len = str.length;
32700 str = str + "00000000";
32701 for (i=0; i<str.length; i+=8) {
32702 out.push(parseInt(str.substr(i,8),16)^0);
32703 }
32704 return sjcl.bitArray.clamp(out, len*4);
32705 }
32706 };
32707
32708
32709 //// sha512.js
32710
32711 /** @fileOverview Javascript SHA-512 implementation.
32712 *
32713 * This implementation was written for CryptoJS by Jeff Mott and adapted for
32714 * SJCL by Stefan Thomas.
32715 *
32716 * CryptoJS (c) 2009–2012 by Jeff Mott. All rights reserved.
32717 * Released with New BSD License
32718 *
32719 * @author Emily Stark
32720 * @author Mike Hamburg
32721 * @author Dan Boneh
32722 * @author Jeff Mott
32723 * @author Stefan Thomas
32724 */
32725
32726 /**
32727 * Context for a SHA-512 operation in progress.
32728 * @constructor
32729 * @class Secure Hash Algorithm, 512 bits.
32730 */
32731 sjcl.hash.sha512 = function (hash) {
32732 if (!this._key[0]) { this._precompute(); }
32733 if (hash) {
32734 this._h = hash._h.slice(0);
32735 this._buffer = hash._buffer.slice(0);
32736 this._length = hash._length;
32737 } else {
32738 this.reset();
32739 }
32740 };
32741
32742 /**
32743 * Hash a string or an array of words.
32744 * @static
32745 * @param {bitArray|String} data the data to hash.
32746 * @return {bitArray} The hash value, an array of 16 big-endian words.
32747 */
32748 sjcl.hash.sha512.hash = function (data) {
32749 return (new sjcl.hash.sha512()).update(data).finalize();
32750 };
32751
32752 sjcl.hash.sha512.prototype = {
32753 /**
32754 * The hash's block size, in bits.
32755 * @constant
32756 */
32757 blockSize: 1024,
32758
32759 /**
32760 * Reset the hash state.
32761 * @return this
32762 */
32763 reset:function () {
32764 this._h = this._init.slice(0);
32765 this._buffer = [];
32766 this._length = 0;
32767 return this;
32768 },
32769
32770 /**
32771 * Input several words to the hash.
32772 * @param {bitArray|String} data the data to hash.
32773 * @return this
32774 */
32775 update: function (data) {
32776 if (typeof data === "string") {
32777 data = sjcl.codec.utf8String.toBits(data);
32778 }
32779 var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
32780 ol = this._length,
32781 nl = this._length = ol + sjcl.bitArray.bitLength(data);
32782 for (i = 1024+ol & -1024; i <= nl; i+= 1024) {
32783 this._block(b.splice(0,32));
32784 }
32785 return this;
32786 },
32787
32788 /**
32789 * Complete hashing and output the hash value.
32790 * @return {bitArray} The hash value, an array of 16 big-endian words.
32791 */
32792 finalize:function () {
32793 var i, b = this._buffer, h = this._h;
32794
32795 // Round out and push the buffer
32796 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);
32797
32798 // Round out the buffer to a multiple of 32 words, less the 4 length words.
32799 for (i = b.length + 4; i & 31; i++) {
32800 b.push(0);
32801 }
32802
32803 // append the length
32804 b.push(0);
32805 b.push(0);
32806 b.push(Math.floor(this._length / 0x100000000));
32807 b.push(this._length | 0);
32808
32809 while (b.length) {
32810 this._block(b.splice(0,32));
32811 }
32812
32813 this.reset();
32814 return h;
32815 },
32816
32817 /**
32818 * The SHA-512 initialization vector, to be precomputed.
32819 * @private
32820 */
32821 _init:[],
32822
32823 /**
32824 * Least significant 24 bits of SHA512 initialization values.
32825 *
32826 * Javascript only has 53 bits of precision, so we compute the 40 most
32827 * significant bits and add the remaining 24 bits as constants.
32828 *
32829 * @private
32830 */
32831 _initr: [ 0xbcc908, 0xcaa73b, 0x94f82b, 0x1d36f1, 0xe682d1, 0x3e6c1f, 0x41bd6b, 0x7e2179 ],
32832
32833 /*
32834 _init:
32835 [0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,
32836 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179],
32837 */
32838
32839 /**
32840 * The SHA-512 hash key, to be precomputed.
32841 * @private
32842 */
32843 _key:[],
32844
32845 /**
32846 * Least significant 24 bits of SHA512 key values.
32847 * @private
32848 */
32849 _keyr:
32850 [0x28ae22, 0xef65cd, 0x4d3b2f, 0x89dbbc, 0x48b538, 0x05d019, 0x194f9b, 0x6d8118,
32851 0x030242, 0x706fbe, 0xe4b28c, 0xffb4e2, 0x7b896f, 0x1696b1, 0xc71235, 0x692694,
32852 0xf14ad2, 0x4f25e3, 0x8cd5b5, 0xac9c65, 0x2b0275, 0xa6e483, 0x41fbd4, 0x1153b5,
32853 0x66dfab, 0xb43210, 0xfb213f, 0xef0ee4, 0xa88fc2, 0x0aa725, 0x03826f, 0x0e6e70,
32854 0xd22ffc, 0x26c926, 0xc42aed, 0x95b3df, 0xaf63de, 0x77b2a8, 0xedaee6, 0x82353b,
32855 0xf10364, 0x423001, 0xf89791, 0x54be30, 0xef5218, 0x65a910, 0x71202a, 0xbbd1b8,
32856 0xd2d0c8, 0x41ab53, 0x8eeb99, 0x9b48a8, 0xc95a63, 0x418acb, 0x63e373, 0xb2b8a3,
32857 0xefb2fc, 0x172f60, 0xf0ab72, 0x6439ec, 0x631e28, 0x82bde9, 0xc67915, 0x72532b,
32858 0x26619c, 0xc0c207, 0xe0eb1e, 0x6ed178, 0x176fba, 0xc898a6, 0xf90dae, 0x1c471b,
32859 0x047d84, 0xc72493, 0xc9bebc, 0x100d4c, 0x3e42b6, 0x657e2a, 0xd6faec, 0x475817],
32860
32861 /*
32862 _key:
32863 [0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
32864 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
32865 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
32866 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
32867 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
32868 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
32869 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
32870 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
32871 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
32872 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
32873 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
32874 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
32875 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
32876 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
32877 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
32878 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
32879 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
32880 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
32881 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
32882 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817],
32883 */
32884
32885 /**
32886 * Function to precompute _init and _key.
32887 * @private
32888 */
32889 _precompute: function () {
32890 // XXX: This code is for precomputing the SHA256 constants, change for
32891 // SHA512 and re-enable.
32892 var i = 0, prime = 2, factor;
32893
32894 function frac(x) { return (x-Math.floor(x)) * 0x100000000 | 0; }
32895 function frac2(x) { return (x-Math.floor(x)) * 0x10000000000 & 0xff; }
32896
32897 outer: for (; i<80; prime++) {
32898 for (factor=2; factor*factor <= prime; factor++) {
32899 if (prime % factor === 0) {
32900 // not a prime
32901 continue outer;
32902 }
32903 }
32904
32905 if (i<8) {
32906 this._init[i*2] = frac(Math.pow(prime, 1/2));
32907 this._init[i*2+1] = (frac2(Math.pow(prime, 1/2)) << 24) | this._initr[i];
32908 }
32909 this._key[i*2] = frac(Math.pow(prime, 1/3));
32910 this._key[i*2+1] = (frac2(Math.pow(prime, 1/3)) << 24) | this._keyr[i];
32911 i++;
32912 }
32913 },
32914
32915 /**
32916 * Perform one cycle of SHA-512.
32917 * @param {bitArray} words one block of words.
32918 * @private
32919 */
32920 _block:function (words) {
32921 var i, wrh, wrl,
32922 w = words.slice(0),
32923 h = this._h,
32924 k = this._key,
32925 h0h = h[ 0], h0l = h[ 1], h1h = h[ 2], h1l = h[ 3],
32926 h2h = h[ 4], h2l = h[ 5], h3h = h[ 6], h3l = h[ 7],
32927 h4h = h[ 8], h4l = h[ 9], h5h = h[10], h5l = h[11],
32928 h6h = h[12], h6l = h[13], h7h = h[14], h7l = h[15];
32929
32930 // Working variables
32931 var ah = h0h, al = h0l, bh = h1h, bl = h1l,
32932 ch = h2h, cl = h2l, dh = h3h, dl = h3l,
32933 eh = h4h, el = h4l, fh = h5h, fl = h5l,
32934 gh = h6h, gl = h6l, hh = h7h, hl = h7l;
32935
32936 for (i=0; i<80; i++) {
32937 // load up the input word for this round
32938 if (i<16) {
32939 wrh = w[i * 2];
32940 wrl = w[i * 2 + 1];
32941 } else {
32942 // Gamma0
32943 var gamma0xh = w[(i-15) * 2];
32944 var gamma0xl = w[(i-15) * 2 + 1];
32945 var gamma0h =
32946 ((gamma0xl << 31) | (gamma0xh >>> 1)) ^
32947 ((gamma0xl << 24) | (gamma0xh >>> 8)) ^
32948 (gamma0xh >>> 7);
32949 var gamma0l =
32950 ((gamma0xh << 31) | (gamma0xl >>> 1)) ^
32951 ((gamma0xh << 24) | (gamma0xl >>> 8)) ^
32952 ((gamma0xh << 25) | (gamma0xl >>> 7));
32953
32954 // Gamma1
32955 var gamma1xh = w[(i-2) * 2];
32956 var gamma1xl = w[(i-2) * 2 + 1];
32957 var gamma1h =
32958 ((gamma1xl << 13) | (gamma1xh >>> 19)) ^
32959 ((gamma1xh << 3) | (gamma1xl >>> 29)) ^
32960 (gamma1xh >>> 6);
32961 var gamma1l =
32962 ((gamma1xh << 13) | (gamma1xl >>> 19)) ^
32963 ((gamma1xl << 3) | (gamma1xh >>> 29)) ^
32964 ((gamma1xh << 26) | (gamma1xl >>> 6));
32965
32966 // Shortcuts
32967 var wr7h = w[(i-7) * 2];
32968 var wr7l = w[(i-7) * 2 + 1];
32969
32970 var wr16h = w[(i-16) * 2];
32971 var wr16l = w[(i-16) * 2 + 1];
32972
32973 // W(round) = gamma0 + W(round - 7) + gamma1 + W(round - 16)
32974 wrl = gamma0l + wr7l;
32975 wrh = gamma0h + wr7h + ((wrl >>> 0) < (gamma0l >>> 0) ? 1 : 0);
32976 wrl += gamma1l;
32977 wrh += gamma1h + ((wrl >>> 0) < (gamma1l >>> 0) ? 1 : 0);
32978 wrl += wr16l;
32979 wrh += wr16h + ((wrl >>> 0) < (wr16l >>> 0) ? 1 : 0);
32980 }
32981
32982 w[i*2] = wrh |= 0;
32983 w[i*2 + 1] = wrl |= 0;
32984
32985 // Ch
32986 var chh = (eh & fh) ^ (~eh & gh);
32987 var chl = (el & fl) ^ (~el & gl);
32988
32989 // Maj
32990 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
32991 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
32992
32993 // Sigma0
32994 var sigma0h = ((al << 4) | (ah >>> 28)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
32995 var sigma0l = ((ah << 4) | (al >>> 28)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
32996
32997 // Sigma1
32998 var sigma1h = ((el << 18) | (eh >>> 14)) ^ ((el << 14) | (eh >>> 18)) ^ ((eh << 23) | (el >>> 9));
32999 var sigma1l = ((eh << 18) | (el >>> 14)) ^ ((eh << 14) | (el >>> 18)) ^ ((el << 23) | (eh >>> 9));
33000
33001 // K(round)
33002 var krh = k[i*2];
33003 var krl = k[i*2+1];
33004
33005 // t1 = h + sigma1 + ch + K(round) + W(round)
33006 var t1l = hl + sigma1l;
33007 var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
33008 t1l += chl;
33009 t1h += chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
33010 t1l += krl;
33011 t1h += krh + ((t1l >>> 0) < (krl >>> 0) ? 1 : 0);
33012 t1l = t1l + wrl|0; // FF32..FF34 perf issue https://bugzilla.mozilla.org/show_bug.cgi?id=1054972
33013 t1h += wrh + ((t1l >>> 0) < (wrl >>> 0) ? 1 : 0);
33014
33015 // t2 = sigma0 + maj
33016 var t2l = sigma0l + majl;
33017 var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
33018
33019 // Update working variables
33020 hh = gh;
33021 hl = gl;
33022 gh = fh;
33023 gl = fl;
33024 fh = eh;
33025 fl = el;
33026 el = (dl + t1l) | 0;
33027 eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
33028 dh = ch;
33029 dl = cl;
33030 ch = bh;
33031 cl = bl;
33032 bh = ah;
33033 bl = al;
33034 al = (t1l + t2l) | 0;
33035 ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
33036 }
33037
33038 // Intermediate hash
33039 h0l = h[1] = (h0l + al) | 0;
33040 h[0] = (h0h + ah + ((h0l >>> 0) < (al >>> 0) ? 1 : 0)) | 0;
33041 h1l = h[3] = (h1l + bl) | 0;
33042 h[2] = (h1h + bh + ((h1l >>> 0) < (bl >>> 0) ? 1 : 0)) | 0;
33043 h2l = h[5] = (h2l + cl) | 0;
33044 h[4] = (h2h + ch + ((h2l >>> 0) < (cl >>> 0) ? 1 : 0)) | 0;
33045 h3l = h[7] = (h3l + dl) | 0;
33046 h[6] = (h3h + dh + ((h3l >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
33047 h4l = h[9] = (h4l + el) | 0;
33048 h[8] = (h4h + eh + ((h4l >>> 0) < (el >>> 0) ? 1 : 0)) | 0;
33049 h5l = h[11] = (h5l + fl) | 0;
33050 h[10] = (h5h + fh + ((h5l >>> 0) < (fl >>> 0) ? 1 : 0)) | 0;
33051 h6l = h[13] = (h6l + gl) | 0;
33052 h[12] = (h6h + gh + ((h6l >>> 0) < (gl >>> 0) ? 1 : 0)) | 0;
33053 h7l = h[15] = (h7l + hl) | 0;
33054 h[14] = (h7h + hh + ((h7l >>> 0) < (hl >>> 0) ? 1 : 0)) | 0;
33055 }
33056 };
33057
33058
33059 //// hmac.js
33060
33061 /** @fileOverview HMAC implementation.
33062 *
33063 * @author Emily Stark
33064 * @author Mike Hamburg
33065 * @author Dan Boneh
33066 */
33067
33068 /** HMAC with the specified hash function.
33069 * @constructor
33070 * @param {bitArray} key the key for HMAC.
33071 * @param {Object} [hash=sjcl.hash.sha256] The hash function to use.
33072 */
33073 sjcl.misc.hmac = function (key, Hash) {
33074 this._hash = Hash = Hash || sjcl.hash.sha256;
33075 var exKey = [[],[]], i,
33076 bs = Hash.prototype.blockSize / 32;
33077 this._baseHash = [new Hash(), new Hash()];
33078
33079 if (key.length > bs) {
33080 key = Hash.hash(key);
33081 }
33082
33083 for (i=0; i<bs; i++) {
33084 exKey[0][i] = key[i]^0x36363636;
33085 exKey[1][i] = key[i]^0x5C5C5C5C;
33086 }
33087
33088 this._baseHash[0].update(exKey[0]);
33089 this._baseHash[1].update(exKey[1]);
33090 this._resultHash = new Hash(this._baseHash[0]);
33091 };
33092
33093 /** HMAC with the specified hash function. Also called encrypt since it's a prf.
33094 * @param {bitArray|String} data The data to mac.
33095 */
33096 sjcl.misc.hmac.prototype.encrypt = sjcl.misc.hmac.prototype.mac = function (data) {
33097 if (!this._updated) {
33098 this.update(data);
33099 return this.digest(data);
33100 } else {
33101 throw new sjcl.exception.invalid("encrypt on already updated hmac called!");
33102 }
33103 };
33104
33105 sjcl.misc.hmac.prototype.reset = function () {
33106 this._resultHash = new this._hash(this._baseHash[0]);
33107 this._updated = false;
33108 };
33109
33110 sjcl.misc.hmac.prototype.update = function (data) {
33111 this._updated = true;
33112 this._resultHash.update(data);
33113 };
33114
33115 sjcl.misc.hmac.prototype.digest = function () {
33116 var w = this._resultHash.finalize(), result = new (this._hash)(this._baseHash[1]).update(w).finalize();
33117
33118 this.reset();
33119
33120 return result;
33121 };
33122
33123
33124 //// pbkdf2.js
33125
33126
33127 /** @fileOverview Password-based key-derivation function, version 2.0.
33128 *
33129 * @author Emily Stark
33130 * @author Mike Hamburg
33131 * @author Dan Boneh
33132 */
33133
33134 /** Password-Based Key-Derivation Function, version 2.0.
33135 *
33136 * Generate keys from passwords using PBKDF2-HMAC-SHA256.
33137 *
33138 * This is the method specified by RSA's PKCS #5 standard.
33139 *
33140 * @param {bitArray|String} password The password.
33141 * @param {bitArray|String} salt The salt. Should have lots of entropy.
33142 * @param {Number} [count=1000] The number of iterations. Higher numbers make the function slower but more secure.
33143 * @param {Number} [length] The length of the derived key. Defaults to the
33144 output size of the hash function.
33145 * @param {Object} [Prff=sjcl.misc.hmac] The pseudorandom function family.
33146 * @return {bitArray} the derived key.
33147 */
33148 sjcl.misc.pbkdf2 = function (password, salt, count, length, Prff) {
33149 count = count || 1000;
33150
33151 if (length < 0 || count < 0) {
33152 throw sjcl.exception.invalid("invalid params to pbkdf2");
33153 }
33154
33155 if (typeof password === "string") {
33156 password = sjcl.codec.utf8String.toBits(password);
33157 }
33158
33159 if (typeof salt === "string") {
33160 salt = sjcl.codec.utf8String.toBits(salt);
33161 }
33162
33163 Prff = Prff || sjcl.misc.hmac;
33164
33165 var prf = new Prff(password),
33166 u, ui, i, j, k, out = [], b = sjcl.bitArray;
33167
33168 for (k = 1; 32 * out.length < (length || 1); k++) {
33169 u = ui = prf.encrypt(b.concat(salt,[k]));
33170
33171 for (i=1; i<count; i++) {
33172 ui = prf.encrypt(ui);
33173 for (j=0; j<ui.length; j++) {
33174 u[j] ^= ui[j];
33175 }
33176 }
33177
33178 out = out.concat(u);
33179 }
33180
33181 if (length) { out = b.clamp(out, length); }
33182
33183 return out;
33184 };
33185
33186
33187 //// sha256.js
33188
33189 /** @fileOverview Javascript SHA-256 implementation.
33190 *
33191 * An older version of this implementation is available in the public
33192 * domain, but this one is (c) Emily Stark, Mike Hamburg, Dan Boneh,
33193 * Stanford University 2008-2010 and BSD-licensed for liability
33194 * reasons.
33195 *
33196 * Special thanks to Aldo Cortesi for pointing out several bugs in
33197 * this code.
33198 *
33199 * @author Emily Stark
33200 * @author Mike Hamburg
33201 * @author Dan Boneh
33202 */
33203
33204 /**
33205 * Context for a SHA-256 operation in progress.
33206 * @constructor
33207 * @class Secure Hash Algorithm, 256 bits.
33208 */
33209 sjcl.hash.sha256 = function (hash) {
33210 if (!this._key[0]) { this._precompute(); }
33211 if (hash) {
33212 this._h = hash._h.slice(0);
33213 this._buffer = hash._buffer.slice(0);
33214 this._length = hash._length;
33215 } else {
33216 this.reset();
33217 }
33218 };
33219
33220 /**
33221 * Hash a string or an array of words.
33222 * @static
33223 * @param {bitArray|String} data the data to hash.
33224 * @return {bitArray} The hash value, an array of 16 big-endian words.
33225 */
33226 sjcl.hash.sha256.hash = function (data) {
33227 return (new sjcl.hash.sha256()).update(data).finalize();
33228 };
33229
33230 sjcl.hash.sha256.prototype = {
33231 /**
33232 * The hash's block size, in bits.
33233 * @constant
33234 */
33235 blockSize: 512,
33236
33237 /**
33238 * Reset the hash state.
33239 * @return this
33240 */
33241 reset:function () {
33242 this._h = this._init.slice(0);
33243 this._buffer = [];
33244 this._length = 0;
33245 return this;
33246 },
33247
33248 /**
33249 * Input several words to the hash.
33250 * @param {bitArray|String} data the data to hash.
33251 * @return this
33252 */
33253 update: function (data) {
33254 if (typeof data === "string") {
33255 data = sjcl.codec.utf8String.toBits(data);
33256 }
33257 var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
33258 ol = this._length,
33259 nl = this._length = ol + sjcl.bitArray.bitLength(data);
33260 for (i = 512+ol & -512; i <= nl; i+= 512) {
33261 this._block(b.splice(0,16));
33262 }
33263 return this;
33264 },
33265
33266 /**
33267 * Complete hashing and output the hash value.
33268 * @return {bitArray} The hash value, an array of 8 big-endian words.
33269 */
33270 finalize:function () {
33271 var i, b = this._buffer, h = this._h;
33272
33273 // Round out and push the buffer
33274 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);
33275
33276 // Round out the buffer to a multiple of 16 words, less the 2 length words.
33277 for (i = b.length + 2; i & 15; i++) {
33278 b.push(0);
33279 }
33280
33281 // append the length
33282 b.push(Math.floor(this._length / 0x100000000));
33283 b.push(this._length | 0);
33284
33285 while (b.length) {
33286 this._block(b.splice(0,16));
33287 }
33288
33289 this.reset();
33290 return h;
33291 },
33292
33293 /**
33294 * The SHA-256 initialization vector, to be precomputed.
33295 * @private
33296 */
33297 _init:[],
33298 /*
33299 _init:[0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19],
33300 */
33301
33302 /**
33303 * The SHA-256 hash key, to be precomputed.
33304 * @private
33305 */
33306 _key:[],
33307 /*
33308 _key:
33309 [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
33310 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
33311 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
33312 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
33313 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
33314 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
33315 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
33316 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2],
33317 */
33318
33319
33320 /**
33321 * Function to precompute _init and _key.
33322 * @private
33323 */
33324 _precompute: function () {
33325 var i = 0, prime = 2, factor;
33326
33327 function frac(x) { return (x-Math.floor(x)) * 0x100000000 | 0; }
33328
33329 outer: for (; i<64; prime++) {
33330 for (factor=2; factor*factor <= prime; factor++) {
33331 if (prime % factor === 0) {
33332 // not a prime
33333 continue outer;
33334 }
33335 }
33336
33337 if (i<8) {
33338 this._init[i] = frac(Math.pow(prime, 1/2));
33339 }
33340 this._key[i] = frac(Math.pow(prime, 1/3));
33341 i++;
33342 }
33343 },
33344
33345 /**
33346 * Perform one cycle of SHA-256.
33347 * @param {bitArray} words one block of words.
33348 * @private
33349 */
33350 _block:function (words) {
33351 var i, tmp, a, b,
33352 w = words.slice(0),
33353 h = this._h,
33354 k = this._key,
33355 h0 = h[0], h1 = h[1], h2 = h[2], h3 = h[3],
33356 h4 = h[4], h5 = h[5], h6 = h[6], h7 = h[7];
33357
33358 /* Rationale for placement of |0 :
33359 * If a value can overflow is original 32 bits by a factor of more than a few
33360 * million (2^23 ish), there is a possibility that it might overflow the
33361 * 53-bit mantissa and lose precision.
33362 *
33363 * To avoid this, we clamp back to 32 bits by |'ing with 0 on any value that
33364 * propagates around the loop, and on the hash state h[]. I don't believe
33365 * that the clamps on h4 and on h0 are strictly necessary, but it's close
33366 * (for h4 anyway), and better safe than sorry.
33367 *
33368 * The clamps on h[] are necessary for the output to be correct even in the
33369 * common case and for short inputs.
33370 */
33371 for (i=0; i<64; i++) {
33372 // load up the input word for this round
33373 if (i<16) {
33374 tmp = w[i];
33375 } else {
33376 a = w[(i+1 ) & 15];
33377 b = w[(i+14) & 15];
33378 tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) +
33379 (b>>>17 ^ b>>>19 ^ b>>>10 ^ b<<15 ^ b<<13) +
33380 w[i&15] + w[(i+9) & 15]) | 0;
33381 }
33382
33383 tmp = (tmp + h7 + (h4>>>6 ^ h4>>>11 ^ h4>>>25 ^ h4<<26 ^ h4<<21 ^ h4<<7) + (h6 ^ h4&(h5^h6)) + k[i]); // | 0;
33384
33385 // shift register
33386 h7 = h6; h6 = h5; h5 = h4;
33387 h4 = h3 + tmp | 0;
33388 h3 = h2; h2 = h1; h1 = h0;
33389
33390 h0 = (tmp + ((h1&h2) ^ (h3&(h1^h2))) + (h1>>>2 ^ h1>>>13 ^ h1>>>22 ^ h1<<30 ^ h1<<19 ^ h1<<10)) | 0;
33391 }
33392
33393 h[0] = h[0]+h0 | 0;
33394 h[1] = h[1]+h1 | 0;
33395 h[2] = h[2]+h2 | 0;
33396 h[3] = h[3]+h3 | 0;
33397 h[4] = h[4]+h4 | 0;
33398 h[5] = h[5]+h5 | 0;
33399 h[6] = h[6]+h6 | 0;
33400 h[7] = h[7]+h7 | 0;
33401 }
33402 };
33403 </script>
33404 <script>
33405 WORDLISTS = {};
33406 </script>
33407 <script>
33408 WORDLISTS["english"] = [
33409 "abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse",
33410 "access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act",
33411 "action","actor","actress","actual","adapt","add","addict","address","adjust","admit",
33412 "adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent",
33413 "agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert",
33414 "alien","all","alley","allow","almost","alone","alpha","already","also","alter",
33415 "always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger",
33416 "angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique",
33417 "anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic",
33418 "area","arena","argue","arm","armed","armor","army","around","arrange","arrest",
33419 "arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset",
33420 "assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction",
33421 "audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake",
33422 "aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge",
33423 "bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain",
33424 "barrel","base","basic","basket","battle","beach","bean","beauty","because","become",
33425 "beef","before","begin","behave","behind","believe","below","belt","bench","benefit",
33426 "best","betray","better","between","beyond","bicycle","bid","bike","bind","biology",
33427 "bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless",
33428 "blind","blood","blossom","blouse","blue","blur","blush","board","boat","body",
33429 "boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss",
33430 "bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread",
33431 "breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze",
33432 "broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb",
33433 "bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy",
33434 "butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call",
33435 "calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas",
33436 "canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry",
33437 "cart","case","cash","casino","castle","casual","cat","catalog","catch","category",
33438 "cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century",
33439 "cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase",
33440 "chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child",
33441 "chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle",
33442 "citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk",
33443 "clever","click","client","cliff","climb","clinic","clip","clock","clog","close",
33444 "cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut",
33445 "code","coffee","coil","coin","collect","color","column","combine","come","comfort",
33446 "comic","common","company","concert","conduct","confirm","congress","connect","consider","control",
33447 "convince","cook","cool","copper","copy","coral","core","corn","correct","cost",
33448 "cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle",
33449 "craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek",
33450 "crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial",
33451 "cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup",
33452 "cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad",
33453 "damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal",
33454 "debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense",
33455 "define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny",
33456 "depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk",
33457 "despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond",
33458 "diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur",
33459 "direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance",
33460 "divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain",
33461 "donate","donkey","donor","door","dose","double","dove","draft","dragon","drama",
33462 "drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop",
33463 "drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf",
33464 "dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo",
33465 "ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow",
33466 "elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody",
33467 "embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless",
33468 "endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough",
33469 "enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip",
33470 "era","erase","erode","erosion","error","erupt","escape","essay","essence","estate",
33471 "eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange",
33472 "excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit",
33473 "exotic","expand","expect","expire","explain","expose","express","extend","extra","eye",
33474 "eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame",
33475 "family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father",
33476 "fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female",
33477 "fence","festival","fetch","fever","few","fiber","fiction","field","figure","file",
33478 "film","filter","final","find","fine","finger","finish","fire","firm","first",
33479 "fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor",
33480 "flee","flight","flip","float","flock","floor","flower","fluid","flush","fly",
33481 "foam","focus","fog","foil","fold","follow","food","foot","force","forest",
33482 "forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile",
33483 "frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen",
33484 "fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy",
33485 "gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp",
33486 "gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture",
33487 "ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance",
33488 "glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue",
33489 "goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown",
33490 "grab","grace","grain","grant","grape","grass","gravity","great","green","grid",
33491 "grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt",
33492 "guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy",
33493 "harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health",
33494 "heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden",
33495 "high","hill","hint","hip","hire","history","hobby","hockey","hold","hole",
33496 "holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital",
33497 "host","hotel","hour","hover","hub","huge","human","humble","humor","hundred",
33498 "hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea",
33499 "identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune",
33500 "impact","impose","improve","impulse","inch","include","income","increase","index","indicate",
33501 "indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury",
33502 "inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install",
33503 "intact","interest","into","invest","invite","involve","iron","island","isolate","issue",
33504 "item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel",
33505 "job","join","joke","journey","joy","judge","juice","jump","jungle","junior",
33506 "junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney",
33507 "kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife",
33508 "knock","know","lab","label","labor","ladder","lady","lake","lamp","language",
33509 "laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit",
33510 "layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal",
33511 "legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level",
33512 "liar","liberty","library","license","life","lift","light","like","limb","limit",
33513 "link","lion","liquid","list","little","live","lizard","load","loan","lobster",
33514 "local","lock","logic","lonely","long","loop","lottery","loud","lounge","love",
33515 "loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad",
33516 "magic","magnet","maid","mail","main","major","make","mammal","man","manage",
33517 "mandate","mango","mansion","manual","maple","marble","march","margin","marine","market",
33518 "marriage","mask","mass","master","match","material","math","matrix","matter","maximum",
33519 "maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt",
33520 "member","memory","mention","menu","mercy","merge","merit","merry","mesh","message",
33521 "metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor",
33522 "minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile",
33523 "model","modify","mom","moment","monitor","monkey","monster","month","moon","moral",
33524 "more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie",
33525 "much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual",
33526 "myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature",
33527 "near","neck","need","negative","neglect","neither","nephew","nerve","nest","net",
33528 "network","neutral","never","news","next","nice","night","noble","noise","nominee",
33529 "noodle","normal","north","nose","notable","note","nothing","notice","novel","now",
33530 "nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe",
33531 "obtain","obvious","occur","ocean","october","odor","off","offer","office","often",
33532 "oil","okay","old","olive","olympic","omit","once","one","onion","online",
33533 "only","open","opera","opinion","oppose","option","orange","orbit","orchard","order",
33534 "ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output",
33535 "outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact",
33536 "paddle","page","pair","palace","palm","panda","panel","panic","panther","paper",
33537 "parade","parent","park","parrot","party","pass","patch","path","patient","patrol",
33538 "pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen",
33539 "penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo",
33540 "phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot",
33541 "pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate",
33542 "play","please","pledge","pluck","plug","plunge","poem","poet","point","polar",
33543 "pole","police","pond","pony","pool","popular","portion","position","possible","post",
33544 "potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare",
33545 "present","pretty","prevent","price","pride","primary","print","priority","prison","private",
33546 "prize","problem","process","produce","profit","program","project","promote","proof","property",
33547 "prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin",
33548 "punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle",
33549 "pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit",
33550 "raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp",
33551 "ranch","random","range","rapid","rare","rate","rather","raven","raw","razor",
33552 "ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle",
33553 "reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release",
33554 "relief","rely","remain","remember","remind","remove","render","renew","rent","reopen",
33555 "repair","repeat","replace","report","require","rescue","resemble","resist","resource","response",
33556 "result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib",
33557 "ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot",
33558 "ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket",
33559 "romance","roof","rookie","room","rose","rotate","rough","round","route","royal",
33560 "rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness",
33561 "safe","sail","salad","salmon","salon","salt","salute","same","sample","sand",
33562 "satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter",
33563 "scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script",
33564 "scrub","sea","search","season","seat","second","secret","section","security","seed",
33565 "seek","segment","select","sell","seminar","senior","sense","sentence","series","service",
33566 "session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell",
33567 "sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop",
33568 "short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side",
33569 "siege","sight","sign","silent","silk","silly","silver","similar","simple","since",
33570 "sing","siren","sister","situate","six","size","skate","sketch","ski","skill",
33571 "skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight",
33572 "slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth",
33573 "snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda",
33574 "soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry",
33575 "sort","soul","sound","soup","source","south","space","spare","spatial","spawn",
33576 "speak","special","speed","spell","spend","sphere","spice","spider","spike","spin",
33577 "spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring",
33578 "spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp",
33579 "stand","start","state","stay","steak","steel","stem","step","stereo","stick",
33580 "still","sting","stock","stomach","stone","stool","story","stove","strategy","street",
33581 "strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway",
33582 "success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny",
33583 "sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey",
33584 "suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim",
33585 "swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag",
33586 "tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi",
33587 "teach","team","tell","ten","tenant","tennis","tent","term","test","text",
33588 "thank","that","theme","then","theory","there","they","thing","this","thought",
33589 "three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber",
33590 "time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler",
33591 "toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool",
33592 "tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist",
33593 "toward","tower","town","toy","track","trade","traffic","tragic","train","transfer",
33594 "trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick",
33595 "trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust",
33596 "truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle",
33597 "twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella",
33598 "unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform",
33599 "unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade",
33600 "uphold","upon","upper","upset","urban","urge","usage","use","used","useful",
33601 "useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van",
33602 "vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue",
33603 "verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory",
33604 "video","view","village","vintage","violin","virtual","virus","visa","visit","visual",
33605 "vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage",
33606 "wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash",
33607 "wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather",
33608 "web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat",
33609 "wheel","when","where","whip","whisper","wide","width","wife","wild","will",
33610 "win","window","wine","wing","wink","winner","winter","wire","wisdom","wise",
33611 "wish","witness","wolf","woman","wonder","wood","wool","word","work","world",
33612 "worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year",
33613 "yellow","you","young","youth","zebra","zero","zone","zoo"]
33614 </script>
33615 <script>
33616 /*
33617 * Copyright (c) 2013 Pavol Rusnak
33618 *
33619 * Permission is hereby granted, free of charge, to any person obtaining a copy of
33620 * this software and associated documentation files (the "Software"), to deal in
33621 * the Software without restriction, including without limitation the rights to
33622 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
33623 * of the Software, and to permit persons to whom the Software is furnished to do
33624 * so, subject to the following conditions:
33625 *
33626 * The above copyright notice and this permission notice shall be included in all
33627 * copies or substantial portions of the Software.
33628 *
33629 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33630 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33631 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33632 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33633 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33634 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33635 */
33636
33637 /*
33638 * Javascript port from python by Ian Coleman
33639 *
33640 * Requires code from sjcl
33641 * https://github.com/bitwiseshiftleft/sjcl
33642 */
33643
33644 var Mnemonic = function(language) {
33645
33646 var PBKDF2_ROUNDS = 2048;
33647 var RADIX = 2048;
33648
33649 var self = this;
33650 var wordlist = [];
33651
33652 var hmacSHA512 = function(key) {
33653 var hasher = new sjcl.misc.hmac(key, sjcl.hash.sha512);
33654 this.encrypt = function() {
33655 return hasher.encrypt.apply(hasher, arguments);
33656 };
33657 };
33658
33659 function init() {
33660 wordlist = WORDLISTS[language];
33661 if (wordlist.length != RADIX) {
33662 err = 'Wordlist should contain ' + RADIX + ' words, but it contains ' + wordlist.length + ' words.';
33663 throw err;
33664 }
33665 }
33666
33667 self.generate = function(strength) {
33668 strength = strength || 128;
33669 var r = strength % 32;
33670 if (r > 0) {
33671 throw 'Strength should be divisible by 32, but it is not (' + r + ').';
33672 }
33673 var hasStrongCrypto = 'crypto' in window && window['crypto'] !== null;
33674 if (!hasStrongCrypto) {
33675 throw 'Mnemonic should be generated with strong randomness, but crypto.getRandomValues is unavailable';
33676 }
33677 var buffer = new Uint8Array(strength / 8);
33678 var data = crypto.getRandomValues(buffer);
33679 return self.toMnemonic(data);
33680 }
33681
33682 self.toMnemonic = function(byteArray) {
33683 if (byteArray.length % 4 > 0) {
33684 throw 'Data length in bits should be divisible by 32, but it is not (' + byteArray.length + ' bytes = ' + byteArray.length*8 + ' bits).'
33685 }
33686
33687 //h = hashlib.sha256(data).hexdigest()
33688 var data = byteArrayToWordArray(byteArray);
33689 var hash = sjcl.hash.sha256.hash(data);
33690 var h = sjcl.codec.hex.fromBits(hash);
33691
33692 // b is a binary string, eg '00111010101100...'
33693 //b = bin(int(binascii.hexlify(data), 16))[2:].zfill(len(data) * 8) + \
33694 // bin(int(h, 16))[2:].zfill(256)[:len(data) * 8 / 32]
33695 //
33696 // a = bin(int(binascii.hexlify(data), 16))[2:].zfill(len(data) * 8)
33697 // c = bin(int(h, 16))[2:].zfill(256)
33698 // d = c[:len(data) * 8 / 32]
33699 var a = byteArrayToBinaryString(byteArray);
33700 var c = zfill(hexStringToBinaryString(h), 256);
33701 var d = c.substring(0, byteArray.length * 8 / 32);
33702 // b = line1 + line2
33703 var b = a + d;
33704
33705 var result = [];
33706 var blen = b.length / 11;
33707 for (var i=0; i<blen; i++) {
33708 var idx = parseInt(b.substring(i * 11, (i + 1) * 11), 2);
33709 result.push(wordlist[idx]);
33710 }
33711 return result.join(' ');
33712 }
33713
33714 self.check = function(mnemonic) {
33715 var mnemonic = mnemonic.split(' ')
33716 if (mnemonic.length % 3 > 0) {
33717 return false
33718 }
33719 // idx = map(lambda x: bin(self.wordlist.index(x))[2:].zfill(11), mnemonic)
33720 var idx = [];
33721 for (var i=0; i<mnemonic.length; i++) {
33722 var word = mnemonic[i];
33723 var wordIndex = wordlist.indexOf(word);
33724 if (wordIndex == -1) {
33725 return false;
33726 }
33727 var binaryIndex = zfill(wordIndex.toString(2), 11);
33728 idx.push(binaryIndex);
33729 }
33730 var b = idx.join('');
33731 var l = b.length;
33732 //d = b[:l / 33 * 32]
33733 //h = b[-l / 33:]
33734 var d = b.substring(0, l / 33 * 32);
33735 var h = b.substring(l - l / 33, l);
33736 //nd = binascii.unhexlify(hex(int(d, 2))[2:].rstrip('L').zfill(l / 33 * 8))
33737 var nd = binaryStringToWordArray(d);
33738 //nh = bin(int(hashlib.sha256(nd).hexdigest(), 16))[2:].zfill(256)[:l / 33]
33739 var ndHash = sjcl.hash.sha256.hash(nd);
33740 var ndHex = sjcl.codec.hex.fromBits(ndHash);
33741 var ndBstr = zfill(hexStringToBinaryString(ndHex), 256);
33742 var nh = ndBstr.substring(0,l/33);
33743 return h == nh;
33744 }
33745
33746 self.toSeed = function(mnemonic, passphrase) {
33747 passphrase = passphrase || '';
33748 mnemonic = self.normalizeString(mnemonic)
33749 passphrase = self.normalizeString(passphrase)
33750 passphrase = "mnemonic" + passphrase;
33751 var mnemonicBits = sjcl.codec.utf8String.toBits(mnemonic);
33752 var passphraseBits = sjcl.codec.utf8String.toBits(passphrase);
33753 var result = sjcl.misc.pbkdf2(mnemonicBits, passphraseBits, PBKDF2_ROUNDS, 512, hmacSHA512);
33754 var hashHex = sjcl.codec.hex.fromBits(result);
33755 return hashHex;
33756 }
33757
33758 self.normalizeString = function(str) {
33759 if (typeof str.normalize == "function") {
33760 return str.normalize("NFKD");
33761 }
33762 else {
33763 // TODO decide how to handle this in the future.
33764 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
33765 return str;
33766 }
33767 }
33768
33769 function byteArrayToWordArray(data) {
33770 var a = [];
33771 for (var i=0; i<data.length/4; i++) {
33772 v = 0;
33773 v += data[i*4 + 0] << 8 * 3;
33774 v += data[i*4 + 1] << 8 * 2;
33775 v += data[i*4 + 2] << 8 * 1;
33776 v += data[i*4 + 3] << 8 * 0;
33777 a.push(v);
33778 }
33779 return a;
33780 }
33781
33782 function byteArrayToBinaryString(data) {
33783 var bin = "";
33784 for (var i=0; i<data.length; i++) {
33785 bin += zfill(data[i].toString(2), 8);
33786 }
33787 return bin;
33788 }
33789
33790 function hexStringToBinaryString(hexString) {
33791 binaryString = "";
33792 for (var i=0; i<hexString.length; i++) {
33793 binaryString += zfill(parseInt(hexString[i], 16).toString(2),4);
33794 }
33795 return binaryString;
33796 }
33797
33798 function binaryStringToWordArray(binary) {
33799 var aLen = binary.length / 32;
33800 var a = [];
33801 for (var i=0; i<aLen; i++) {
33802 var valueStr = binary.substring(0,32);
33803 var value = parseInt(valueStr, 2);
33804 a.push(value);
33805 binary = binary.slice(32);
33806 }
33807 return a;
33808 }
33809
33810 // Pad a numeric string on the left with zero digits until the given width
33811 // is reached.
33812 // Note this differs to the python implementation because it does not
33813 // handle numbers starting with a sign.
33814 function zfill(source, length) {
33815 source = source.toString();
33816 while (source.length < length) {
33817 source = '0' + source;
33818 }
33819 return source;
33820 }
33821
33822 init();
33823
33824 }
33825 </script>
33826 <script>
33827 (function() {
33828
33829 var mnemonic = new Mnemonic("english");
33830 var bip32RootKey = null;
33831 var bip32ExtendedKey = null;
33832 var network = Bitcoin.networks.bitcoin;
33833 var addressRowTemplate = $("#address-row-template");
33834
33835 var showIndex = true;
33836 var showAddress = true;
33837 var showPrivKey = true;
33838
33839 var phraseChangeTimeoutEvent = null;
33840
33841 var DOM = {};
33842 DOM.phrase = $(".phrase");
33843 DOM.passphrase = $(".passphrase");
33844 DOM.generate = $(".generate");
33845 DOM.rootKey = $(".root-key");
33846 DOM.extendedPrivKey = $(".extended-priv-key");
33847 DOM.extendedPubKey = $(".extended-pub-key");
33848 DOM.bip32path = $("#bip32-path");
33849 DOM.bip44path = $("#bip44-path");
33850 DOM.bip44purpose = $("#bip44 .purpose");
33851 DOM.bip44coin = $("#bip44 .coin");
33852 DOM.bip44account = $("#bip44 .account");
33853 DOM.bip44change = $("#bip44 .change");
33854 DOM.strength = $(".strength");
33855 DOM.addresses = $(".addresses");
33856 DOM.rowsToAdd = $(".rows-to-add");
33857 DOM.more = $(".more");
33858 DOM.feedback = $(".feedback");
33859 DOM.tab = $(".derivation-type a");
33860 DOM.indexToggle = $(".index-toggle");
33861 DOM.addressToggle = $(".address-toggle");
33862 DOM.privateKeyToggle = $(".private-key-toggle");
33863
33864 var derivationPath = DOM.bip44path.val();
33865
33866 function init() {
33867 // Events
33868 DOM.phrase.on("input", delayedPhraseChanged);
33869 DOM.passphrase.on("input", delayedPhraseChanged);
33870 DOM.generate.on("click", generateClicked);
33871 DOM.more.on("click", showMore);
33872 DOM.bip32path.on("input", bip32Changed);
33873 DOM.bip44purpose.on("input", bip44Changed);
33874 DOM.bip44coin.on("input", bip44Changed);
33875 DOM.bip44account.on("input", bip44Changed);
33876 DOM.bip44change.on("input", bip44Changed);
33877 DOM.tab.on("click", tabClicked);
33878 DOM.indexToggle.on("click", toggleIndexes);
33879 DOM.addressToggle.on("click", toggleAddresses);
33880 DOM.privateKeyToggle.on("click", togglePrivateKeys);
33881 disableForms();
33882 hidePending();
33883 hideValidationError();
33884 }
33885
33886 // Event handlers
33887
33888 function delayedPhraseChanged() {
33889 hideValidationError();
33890 showPending();
33891 if (phraseChangeTimeoutEvent != null) {
33892 clearTimeout(phraseChangeTimeoutEvent);
33893 }
33894 phraseChangeTimeoutEvent = setTimeout(phraseChanged, 400);
33895 }
33896
33897 function phraseChanged() {
33898 showPending();
33899 hideValidationError();
33900 // Get the mnemonic phrase
33901 var phrase = DOM.phrase.val();
33902 var passphrase = DOM.passphrase.val();
33903 var errorText = findPhraseErrors(phrase);
33904 if (errorText) {
33905 showValidationError(errorText);
33906 return;
33907 }
33908 // Get the derivation path
33909 var errorText = findDerivationPathErrors();
33910 if (errorText) {
33911 showValidationError(errorText);
33912 return;
33913 }
33914 // Calculate and display
33915 calcBip32Seed(phrase, passphrase, derivationPath);
33916 displayBip32Info();
33917 hidePending();
33918 }
33919
33920 function generateClicked() {
33921 clearDisplay();
33922 showPending();
33923 setTimeout(function() {
33924 var phrase = generateRandomPhrase();
33925 if (!phrase) {
33926 return;
33927 }
33928 phraseChanged();
33929 }, 50);
33930 }
33931
33932 function tabClicked(e) {
33933 var activePath = $(e.target.getAttribute("href") + " .path");
33934 derivationPath = activePath.val();
33935 derivationChanged();
33936 }
33937
33938 function derivationChanged() {
33939 delayedPhraseChanged();
33940 }
33941
33942 function bip32Changed() {
33943 derivationPath = DOM.bip32path.val();
33944 derivationChanged();
33945 }
33946
33947 function bip44Changed() {
33948 setBip44DerivationPath();
33949 derivationPath = DOM.bip44path.val();
33950 derivationChanged();
33951 }
33952
33953 function toggleIndexes() {
33954 showIndex = !showIndex;
33955 $("td.index span").toggleClass("invisible");
33956 }
33957
33958 function toggleAddresses() {
33959 showAddress = !showAddress;
33960 $("td.address span").toggleClass("invisible");
33961 }
33962
33963 function togglePrivateKeys() {
33964 showPrivKey = !showPrivKey;
33965 $("td.privkey span").toggleClass("invisible");
33966 }
33967
33968 // Private methods
33969
33970 function generateRandomPhrase() {
33971 if (!hasStrongRandom()) {
33972 var errorText = "This browser does not support strong randomness";
33973 showValidationError(errorText);
33974 return;
33975 }
33976 var numWords = parseInt(DOM.strength.val());
33977 // Check strength is an integer
33978 if (isNaN(numWords)) {
33979 DOM.strength.val("12");
33980 numWords = 12;
33981 }
33982 // Check strength is a multiple of 32, if not round it down
33983 if (numWords % 3 != 0) {
33984 numWords = Math.floor(numWords / 3) * 3;
33985 DOM.strength.val(numWords);
33986 }
33987 // Check strength is at least 32
33988 if (numWords == 0) {
33989 numWords = 3;
33990 DOM.strength.val(numWords);
33991 }
33992 var strength = numWords / 3 * 32;
33993 var words = mnemonic.generate(strength);
33994 DOM.phrase.val(words);
33995 return words;
33996 }
33997
33998 function calcBip32Seed(phrase, passphrase, path) {
33999 var seed = mnemonic.toSeed(phrase, passphrase);
34000 bip32RootKey = Bitcoin.HDNode.fromSeedHex(seed, network);
34001 bip32ExtendedKey = bip32RootKey;
34002 // Derive the key from the path
34003 var pathBits = path.split("/");
34004 for (var i=0; i<pathBits.length; i++) {
34005 var bit = pathBits[i];
34006 var index = parseInt(bit);
34007 if (isNaN(index)) {
34008 continue;
34009 }
34010 var hardened = bit[bit.length-1] == "'";
34011 if (hardened) {
34012 bip32ExtendedKey = bip32ExtendedKey.deriveHardened(index);
34013 }
34014 else {
34015 bip32ExtendedKey = bip32ExtendedKey.derive(index);
34016 }
34017 }
34018 }
34019
34020 function showValidationError(errorText) {
34021 DOM.feedback
34022 .text(errorText)
34023 .show();
34024 }
34025
34026 function hideValidationError() {
34027 DOM.feedback
34028 .text("")
34029 .hide();
34030 }
34031
34032 function findPhraseErrors(phrase) {
34033 // TODO make this right
34034 // Preprocess the words
34035 phrase = mnemonic.normalizeString(phrase);
34036 var parts = phrase.split(" ");
34037 var proper = [];
34038 for (var i=0; i<parts.length; i++) {
34039 var part = parts[i];
34040 if (part.length > 0) {
34041 // TODO check that lowercasing is always valid to do
34042 proper.push(part.toLowerCase());
34043 }
34044 }
34045 // TODO some levenstein on the words
34046 var properPhrase = proper.join(' ');
34047 // Check the words are valid
34048 var isValid = mnemonic.check(properPhrase);
34049 if (!isValid) {
34050 return "Invalid mnemonic";
34051 }
34052 return false;
34053 }
34054
34055 function findDerivationPathErrors(path) {
34056 // TODO
34057 return false;
34058 }
34059
34060 function displayBip32Info() {
34061 // Display the key
34062 var rootKey = bip32RootKey.toBase58();
34063 DOM.rootKey.val(rootKey);
34064 var extendedPrivKey = bip32ExtendedKey.toBase58();
34065 DOM.extendedPrivKey.val(extendedPrivKey);
34066 var extendedPubKey = bip32ExtendedKey.toBase58(false);
34067 DOM.extendedPubKey.val(extendedPubKey);
34068 // Display the addresses and privkeys
34069 clearAddressesList();
34070 displayAddresses(0, 20);
34071 }
34072
34073 function displayAddresses(start, total) {
34074 for (var i=0; i<total; i++) {
34075 var index = i + start;
34076 new TableRow(index);
34077 }
34078 }
34079
34080 function TableRow(index) {
34081
34082 function init() {
34083 calculateValues();
34084 }
34085
34086 function calculateValues() {
34087 setTimeout(function() {
34088 var key = bip32ExtendedKey.derive(index);
34089 var address = key.getAddress().toString();
34090 var privkey = key.privKey.toWIF(network);
34091 addAddressToList(index, address, privkey);
34092 }, 50)
34093 }
34094
34095 init();
34096
34097 }
34098
34099 function showMore() {
34100 var start = DOM.addresses.children().length;
34101 var rowsToAdd = parseInt(DOM.rowsToAdd.val());
34102 if (isNaN(rowsToAdd)) {
34103 rowsToAdd = 20;
34104 DOM.rowsToAdd.val("20");
34105 }
34106 if (rowsToAdd > 200) {
34107 var msg = "Generating " + rowsToAdd + " rows could take a while. ";
34108 msg += "Do you want to continue?";
34109 if (!confirm(msg)) {
34110 return;
34111 }
34112 }
34113 displayAddresses(start, rowsToAdd);
34114 }
34115
34116 function clearDisplay() {
34117 clearAddressesList();
34118 clearKey();
34119 hideValidationError();
34120 }
34121
34122 function clearAddressesList() {
34123 DOM.addresses.empty();
34124 }
34125
34126 function clearKey() {
34127 DOM.rootKey.val("");
34128 DOM.extendedPrivKey.val("");
34129 DOM.extendedPubKey.val("");
34130 }
34131
34132 function addAddressToList(index, address, privkey) {
34133 var row = $(addressRowTemplate.html());
34134 // Elements
34135 var indexCell = row.find(".index span");
34136 var addressCell = row.find(".address span");
34137 var privkeyCell = row.find(".privkey span");
34138 // Content
34139 indexCell.text(index);
34140 addressCell.text(address);
34141 privkeyCell.text(privkey);
34142 // Visibility
34143 if (!showIndex) {
34144 indexCell.addClass("invisible");
34145 }
34146 if (!showAddress) {
34147 addressCell.addClass("invisible");
34148 }
34149 if (!showPrivKey) {
34150 privkeCell.addClass("invisible");
34151 }
34152 DOM.addresses.append(row);
34153 }
34154
34155 function hasStrongRandom() {
34156 return 'crypto' in window && window['crypto'] !== null;
34157 }
34158
34159 function disableForms() {
34160 $("form").on("submit", function(e) {
34161 e.preventDefault();
34162 });
34163 }
34164
34165 function setBip44DerivationPath() {
34166 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
34167 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
34168 var account = parseIntNoNaN(DOM.bip44account.val(), 0);
34169 var change = parseIntNoNaN(DOM.bip44change.val(), 0);
34170 var path = "m/";
34171 path += purpose + "'/";
34172 path += coin + "'/";
34173 path += account + "'/";
34174 path += change;
34175 DOM.bip44path.val(path);
34176 }
34177
34178 function parseIntNoNaN(val, defaultVal) {
34179 var v = parseInt(val);
34180 if (isNaN(v)) {
34181 return defaultVal;
34182 }
34183 return v;
34184 }
34185
34186 function showPending() {
34187 DOM.feedback
34188 .text("Calculating...")
34189 .show();
34190 }
34191
34192 function hidePending() {
34193 DOM.feedback
34194 .text("")
34195 .hide();
34196 }
34197
34198 init();
34199
34200 })();
34201 </script>
34202 </body>
34203 </html>