]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blob - bip39-standalone.html
Standalone update: coin select, hive and mycelium
[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="phrase" class="col-sm-2 control-label">BIP39 Mnemonic</label>
6260 <div class="col-sm-10">
6261 <textarea id="phrase" class="phrase form-control"></textarea>
6262 </div>
6263 </div>
6264 <div class="form-group">
6265 <label for="strength" class="col-sm-2 control-label">Number of words</label>
6266 <div class="col-sm-10">
6267 <div class="input-group">
6268 <input type="number" class="strength form-control" id="strength" value="12">
6269 <span class="input-group-btn">
6270 <button class="btn generate">Generate Random Mnemonic</button>
6271 </span>
6272 </div>
6273 </div>
6274 </div>
6275 <div class="form-group">
6276 <label for="passphrase" class="col-sm-2 control-label">BIP39 Passphrase (optional)</label>
6277 <div class="col-sm-10">
6278 <textarea id="passphrase" class="passphrase form-control"></textarea>
6279 </div>
6280 </div>
6281 <div class="form-group">
6282 <label for="network-phrase" class="col-sm-2 control-label">Coin</label>
6283 <div class="col-sm-10">
6284 <select id="network-phrase" class="network form-control">
6285 <option value="bitcoin">Bitcoin</option>
6286 <option value="bitcoin-testnet">Bitcoin Testnet</option>
6287 <option value="litecoin">Litecoin</option>
6288 <option value="dogecoin">Dogecoin</option>
6289 </select>
6290 </div>
6291 </div>
6292 <div class="form-group">
6293 <label for="root-key" class="col-sm-2 control-label">BIP32 Root Key</label>
6294 <div class="col-sm-10">
6295 <textarea id="root-key" class="root-key form-control" readonly="readonly"></textarea>
6296 </div>
6297 </div>
6298 </form>
6299 </div>
6300 </div>
6301
6302 <hr>
6303
6304 <div class="row">
6305 <div class="col-md-12">
6306 <h2>Derivation Path</h2>
6307 <ul class="derivation-type nav nav-tabs" role="tablist">
6308 <li id="hive-tab" class="active">
6309 <a href="#hive" role="tab" data-toggle="tab">Hive Wallet</a>
6310 </li>
6311 <li id="mycelium-tab">
6312 <a href="#mycelium" role="tab" data-toggle="tab">Mycelium Wallet</a>
6313 </li>
6314 <li id="bip44-tab">
6315 <a href="#bip44" role="tab" data-toggle="tab">BIP44</a>
6316 </li>
6317 <li id="bip32-tab">
6318 <a href="#bip32" role="tab" data-toggle="tab">BIP32</a>
6319 </li>
6320 </ul>
6321 <div class="derivation-type tab-content">
6322 <div id="hive" class="tab-pane active">
6323 <form class="form-horizontal" role="form">
6324 <br>
6325 <div class="col-sm-2"></div>
6326 <div class="col-sm-10">
6327 <p>For more info see the <a href="https://www.hivewallet.com/" target="_blank">Hive Wallet homepage</a></p>
6328 </div>
6329 <div class="form-group">
6330 <label for="hive-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
6331 <div class="col-sm-10">
6332 <input id="hive-path" type="text" class="path form-control" value="m/0'/0" readonly="readonly">
6333 </div>
6334 </div>
6335 </form>
6336 </div>
6337 <div id="mycelium" class="tab-pane">
6338 <form class="form-horizontal" role="form">
6339 <br>
6340 <div class="col-sm-2"></div>
6341 <div class="col-sm-10">
6342 <p>For more info see the <a href="http://www.mycelium.com/" target="_blank">Mycelium Wallet homepage</a></p>
6343 </div>
6344 <div class="form-group">
6345 <label for="mycelium-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
6346 <div class="col-sm-10">
6347 <input id="mycelium-path" type="text" class="path form-control" value="m/44'/0'/0'/0" readonly="readonly">
6348 </div>
6349 </div>
6350 </form>
6351 </div>
6352 <div id="bip44" class="tab-pane">
6353 <form class="form-horizontal" role="form">
6354 <br>
6355 <div class="col-sm-2"></div>
6356 <div class="col-sm-10">
6357 <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">BIP44 spec</a></p>
6358 </div>
6359 <div class="form-group">
6360 <label for="purpose" class="col-sm-2 control-label">
6361 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#purpose" target="_blank">Purpose</a>
6362 </label>
6363 <div class="col-sm-10">
6364 <input id="purpose" type="text" class="purpose form-control" value="44">
6365 </div>
6366 </div>
6367 <div class="form-group">
6368 <label for="coin" class="col-sm-2 control-label">
6369 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#registered-coin-types" target="_blank">Coin</a>
6370 </label>
6371 <div class="col-sm-10">
6372 <input id="coin" type="text" class="coin form-control" value="0">
6373 </div>
6374 </div>
6375 <div class="form-group">
6376 <label for="account" class="col-sm-2 control-label">
6377 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account" target="_blank">Account</a>
6378 </label>
6379 <div class="col-sm-10">
6380 <input id="account" type="text" class="account form-control" value="0">
6381 </div>
6382 </div>
6383 <div class="form-group">
6384 <label for="change" class="col-sm-2 control-label">
6385 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target="_blank">External / Internal</a>
6386 </label>
6387 <div class="col-sm-10">
6388 <input id="change" type="text" class="change form-control" value="0">
6389 </div>
6390 </div>
6391 <div class="form-group">
6392 <label for="bip44-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
6393 <div class="col-sm-10">
6394 <input id="bip44-path" type="text" class="path form-control" value="m/44'/0'/0'/0" readonly="readonly">
6395 </div>
6396 </div>
6397 </form>
6398 </div>
6399 <div id="bip32" class="tab-pane">
6400 <form class="form-horizontal" role="form">
6401 <br>
6402 <div class="col-sm-2"></div>
6403 <div class="col-sm-10">
6404 <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">BIP32 spec</a></p>
6405 </div>
6406 <div class="form-group">
6407 <label for="bip32-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
6408 <div class="col-sm-10">
6409 <input id="bip32-path" type="text" class="path form-control" value="m/0">
6410 </div>
6411 </div>
6412 </form>
6413 </div>
6414 </div>
6415 <form class="form-horizontal" role="form">
6416 <div class="form-group">
6417 <label for="extended-priv-key" class="col-sm-2 control-label">BIP32 Extended Key</label>
6418 <div class="col-sm-10">
6419 <textarea id="extended-priv-key" class="extended-priv-key form-control" readonly="readonly"></textarea>
6420 </div>
6421 </div>
6422 <div class="form-group">
6423 <label for="extended-pub-key" class="col-sm-2 control-label">BIP32 Extended Key (addresses only)</label>
6424 <div class="col-sm-10">
6425 <textarea id="extended-pub-key" class="extended-pub-key form-control" readonly="readonly"></textarea>
6426 </div>
6427 </div>
6428 </form>
6429 </div>
6430 </div>
6431
6432 <hr>
6433
6434 <div class="row">
6435 <div class="col-md-12">
6436 <h2>Derived Addresses</h2>
6437 <p>Note these addreses are derived from the <strong>BIP32 Extended Key</strong></p>
6438 <table class="table table-striped">
6439 <thead>
6440 <th>
6441 <div class="input-group">
6442 Index&nbsp;&nbsp;
6443 <button class="index-toggle">Toggle</button>
6444 </div>
6445 </th>
6446 <th>
6447 <div class="input-group">
6448 Address&nbsp;&nbsp;
6449 <button class="address-toggle">Toggle</button>
6450 </div>
6451 </th>
6452 <th>
6453 <div class="input-group">
6454 Private Key&nbsp;&nbsp;
6455 <button class="private-key-toggle">Toggle</button>
6456 </div>
6457 </th>
6458 </thead>
6459 <tbody class="addresses">
6460 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6461 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6462 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6463 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6464 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6465 </tbody>
6466 </table>
6467 </div>
6468 </div>
6469 <span>Show next </button>
6470 <input type="number" class="rows-to-add" value="20">
6471 <button class="more">Show</button>
6472
6473 <hr>
6474
6475 <div class="row">
6476 <div class="col-md-12">
6477 <h2>More info</h2>
6478 <h3>BIP39 <span class="small">Mnemonic code for generating deterministic keys</span></h3>
6479 <p>
6480 Read more at the
6481 <a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki">official BIP39 spec</a>
6482 </p>
6483 <h3>BIP32 <span class="small">Hierarchical Deterministic Wallets</span></h3>
6484 <p>
6485 Read more at the
6486 <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">official BIP32 spec</a>
6487 and see the demo at
6488 <a href="http://bip32.org/" target="_blank">bip32.org</a>
6489 </p>
6490 <h3>BIP44 <span class="small">Multi-Account Hierarchy for Deterministic Wallets</span></h3>
6491 <p>
6492 Read more at the
6493 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">official BIP44 spec</a>
6494 </p>
6495 <h3>Private Keys</h3>
6496 <p>
6497 Use private keys at
6498 <a href="https://brainwallet.github.io/" target="_blank">brainwallet.org</a>,
6499 but be careful - it can be easy to make mistakes if you
6500 don't know what you're doing
6501 </p>
6502 </div>
6503 </div>
6504
6505 <hr>
6506
6507 <div class="row">
6508 <div class="col-md-12">
6509
6510 <h2>Offline Usage</h2>
6511
6512 <p>
6513 You can use this tool without having to be online.
6514 </p>
6515 <p>
6516 In your browser, select file save-as, and save this page
6517 as a file.
6518 </p>
6519 <p>
6520 Double-click that file to open it in a browser
6521 on any offline computer.
6522 </p>
6523 <p>
6524 Alternatively, download it from
6525 <a href="https://github.com/dcpos/bip39">
6526 https://github.com/dcpos/bip39
6527 </a>
6528
6529 </div>
6530 </div>
6531
6532 <hr>
6533
6534 <div class="row">
6535 <div class="col-md-12">
6536
6537 <h2>This project is 100% open-source code</h2>
6538
6539 <p>
6540 <span>Get the source code at - </span>
6541 <a href="https://github.com/dcpos/bip39" target="_blank">
6542 https://github.com/dcpos/bip39
6543 </a>
6544 </p>
6545
6546 <h3>Libraries</h3>
6547
6548 <p>
6549 <span>BitcoinJS - </span>
6550 <a href="https://github.com/bitcoinjs/bitcoinjs-lib" target="_blank">
6551 https://github.com/bitcoinjs/bitcoinjs-lib
6552 </a>
6553 </p>
6554
6555 <p>
6556 <span>jsBIP39 - </span>
6557 <a href="https://github.com/iancoleman/jsbip39" target="_blank">
6558 https://github.com/iancoleman/jsbip39
6559 </a>
6560 </p>
6561
6562 <p>
6563 <span>sjcl - </span>
6564 <a href="https://github.com/bitwiseshiftleft/sjcl" target="_blank">
6565 https://github.com/bitwiseshiftleft/sjcl
6566 </a>
6567 </p>
6568
6569 <p>
6570 <span>jQuery - </span>
6571 <a href="https://jquery.com/" target="_blank">
6572 https://jquery.com/
6573 </a>
6574 </p>
6575
6576 <p>
6577 <span>Twitter Bootstrap - </span>
6578 <a href="http://getbootstrap.com/" target="_blank">
6579 http://getbootstrap.com/
6580 </a>
6581 </p>
6582
6583 </div>
6584 </div>
6585
6586 </div>
6587
6588 <div class="feedback-container">
6589 <div class="feedback">Loading...</div>
6590 </div>
6591
6592 <script type="text/template" id="address-row-template">
6593 <tr>
6594 <td class="index"><span></span></td>
6595 <td class="address"><span></span></td>
6596 <td class="privkey"><span></span></td>
6597 </tr>
6598 </script>
6599 <script>
6600 /*!
6601 * jQuery JavaScript Library v2.1.1
6602 * http://jquery.com/
6603 *
6604 * Includes Sizzle.js
6605 * http://sizzlejs.com/
6606 *
6607 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
6608 * Released under the MIT license
6609 * http://jquery.org/license
6610 *
6611 * Date: 2014-05-01T17:11Z
6612 */
6613
6614 (function( global, factory ) {
6615
6616 if ( typeof module === "object" && typeof module.exports === "object" ) {
6617 // For CommonJS and CommonJS-like environments where a proper window is present,
6618 // execute the factory and get jQuery
6619 // For environments that do not inherently posses a window with a document
6620 // (such as Node.js), expose a jQuery-making factory as module.exports
6621 // This accentuates the need for the creation of a real window
6622 // e.g. var jQuery = require("jquery")(window);
6623 // See ticket #14549 for more info
6624 module.exports = global.document ?
6625 factory( global, true ) :
6626 function( w ) {
6627 if ( !w.document ) {
6628 throw new Error( "jQuery requires a window with a document" );
6629 }
6630 return factory( w );
6631 };
6632 } else {
6633 factory( global );
6634 }
6635
6636 // Pass this if window is not defined yet
6637 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
6638
6639 // Can't do this because several apps including ASP.NET trace
6640 // the stack via arguments.caller.callee and Firefox dies if
6641 // you try to trace through "use strict" call chains. (#13335)
6642 // Support: Firefox 18+
6643 //
6644
6645 var arr = [];
6646
6647 var slice = arr.slice;
6648
6649 var concat = arr.concat;
6650
6651 var push = arr.push;
6652
6653 var indexOf = arr.indexOf;
6654
6655 var class2type = {};
6656
6657 var toString = class2type.toString;
6658
6659 var hasOwn = class2type.hasOwnProperty;
6660
6661 var support = {};
6662
6663
6664
6665 var
6666 // Use the correct document accordingly with window argument (sandbox)
6667 document = window.document,
6668
6669 version = "2.1.1",
6670
6671 // Define a local copy of jQuery
6672 jQuery = function( selector, context ) {
6673 // The jQuery object is actually just the init constructor 'enhanced'
6674 // Need init if jQuery is called (just allow error to be thrown if not included)
6675 return new jQuery.fn.init( selector, context );
6676 },
6677
6678 // Support: Android<4.1
6679 // Make sure we trim BOM and NBSP
6680 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
6681
6682 // Matches dashed string for camelizing
6683 rmsPrefix = /^-ms-/,
6684 rdashAlpha = /-([\da-z])/gi,
6685
6686 // Used by jQuery.camelCase as callback to replace()
6687 fcamelCase = function( all, letter ) {
6688 return letter.toUpperCase();
6689 };
6690
6691 jQuery.fn = jQuery.prototype = {
6692 // The current version of jQuery being used
6693 jquery: version,
6694
6695 constructor: jQuery,
6696
6697 // Start with an empty selector
6698 selector: "",
6699
6700 // The default length of a jQuery object is 0
6701 length: 0,
6702
6703 toArray: function() {
6704 return slice.call( this );
6705 },
6706
6707 // Get the Nth element in the matched element set OR
6708 // Get the whole matched element set as a clean array
6709 get: function( num ) {
6710 return num != null ?
6711
6712 // Return just the one element from the set
6713 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
6714
6715 // Return all the elements in a clean array
6716 slice.call( this );
6717 },
6718
6719 // Take an array of elements and push it onto the stack
6720 // (returning the new matched element set)
6721 pushStack: function( elems ) {
6722
6723 // Build a new jQuery matched element set
6724 var ret = jQuery.merge( this.constructor(), elems );
6725
6726 // Add the old object onto the stack (as a reference)
6727 ret.prevObject = this;
6728 ret.context = this.context;
6729
6730 // Return the newly-formed element set
6731 return ret;
6732 },
6733
6734 // Execute a callback for every element in the matched set.
6735 // (You can seed the arguments with an array of args, but this is
6736 // only used internally.)
6737 each: function( callback, args ) {
6738 return jQuery.each( this, callback, args );
6739 },
6740
6741 map: function( callback ) {
6742 return this.pushStack( jQuery.map(this, function( elem, i ) {
6743 return callback.call( elem, i, elem );
6744 }));
6745 },
6746
6747 slice: function() {
6748 return this.pushStack( slice.apply( this, arguments ) );
6749 },
6750
6751 first: function() {
6752 return this.eq( 0 );
6753 },
6754
6755 last: function() {
6756 return this.eq( -1 );
6757 },
6758
6759 eq: function( i ) {
6760 var len = this.length,
6761 j = +i + ( i < 0 ? len : 0 );
6762 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
6763 },
6764
6765 end: function() {
6766 return this.prevObject || this.constructor(null);
6767 },
6768
6769 // For internal use only.
6770 // Behaves like an Array's method, not like a jQuery method.
6771 push: push,
6772 sort: arr.sort,
6773 splice: arr.splice
6774 };
6775
6776 jQuery.extend = jQuery.fn.extend = function() {
6777 var options, name, src, copy, copyIsArray, clone,
6778 target = arguments[0] || {},
6779 i = 1,
6780 length = arguments.length,
6781 deep = false;
6782
6783 // Handle a deep copy situation
6784 if ( typeof target === "boolean" ) {
6785 deep = target;
6786
6787 // skip the boolean and the target
6788 target = arguments[ i ] || {};
6789 i++;
6790 }
6791
6792 // Handle case when target is a string or something (possible in deep copy)
6793 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
6794 target = {};
6795 }
6796
6797 // extend jQuery itself if only one argument is passed
6798 if ( i === length ) {
6799 target = this;
6800 i--;
6801 }
6802
6803 for ( ; i < length; i++ ) {
6804 // Only deal with non-null/undefined values
6805 if ( (options = arguments[ i ]) != null ) {
6806 // Extend the base object
6807 for ( name in options ) {
6808 src = target[ name ];
6809 copy = options[ name ];
6810
6811 // Prevent never-ending loop
6812 if ( target === copy ) {
6813 continue;
6814 }
6815
6816 // Recurse if we're merging plain objects or arrays
6817 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
6818 if ( copyIsArray ) {
6819 copyIsArray = false;
6820 clone = src && jQuery.isArray(src) ? src : [];
6821
6822 } else {
6823 clone = src && jQuery.isPlainObject(src) ? src : {};
6824 }
6825
6826 // Never move original objects, clone them
6827 target[ name ] = jQuery.extend( deep, clone, copy );
6828
6829 // Don't bring in undefined values
6830 } else if ( copy !== undefined ) {
6831 target[ name ] = copy;
6832 }
6833 }
6834 }
6835 }
6836
6837 // Return the modified object
6838 return target;
6839 };
6840
6841 jQuery.extend({
6842 // Unique for each copy of jQuery on the page
6843 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
6844
6845 // Assume jQuery is ready without the ready module
6846 isReady: true,
6847
6848 error: function( msg ) {
6849 throw new Error( msg );
6850 },
6851
6852 noop: function() {},
6853
6854 // See test/unit/core.js for details concerning isFunction.
6855 // Since version 1.3, DOM methods and functions like alert
6856 // aren't supported. They return false on IE (#2968).
6857 isFunction: function( obj ) {
6858 return jQuery.type(obj) === "function";
6859 },
6860
6861 isArray: Array.isArray,
6862
6863 isWindow: function( obj ) {
6864 return obj != null && obj === obj.window;
6865 },
6866
6867 isNumeric: function( obj ) {
6868 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
6869 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
6870 // subtraction forces infinities to NaN
6871 return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0;
6872 },
6873
6874 isPlainObject: function( obj ) {
6875 // Not plain objects:
6876 // - Any object or value whose internal [[Class]] property is not "[object Object]"
6877 // - DOM nodes
6878 // - window
6879 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
6880 return false;
6881 }
6882
6883 if ( obj.constructor &&
6884 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
6885 return false;
6886 }
6887
6888 // If the function hasn't returned already, we're confident that
6889 // |obj| is a plain object, created by {} or constructed with new Object
6890 return true;
6891 },
6892
6893 isEmptyObject: function( obj ) {
6894 var name;
6895 for ( name in obj ) {
6896 return false;
6897 }
6898 return true;
6899 },
6900
6901 type: function( obj ) {
6902 if ( obj == null ) {
6903 return obj + "";
6904 }
6905 // Support: Android < 4.0, iOS < 6 (functionish RegExp)
6906 return typeof obj === "object" || typeof obj === "function" ?
6907 class2type[ toString.call(obj) ] || "object" :
6908 typeof obj;
6909 },
6910
6911 // Evaluates a script in a global context
6912 globalEval: function( code ) {
6913 var script,
6914 indirect = eval;
6915
6916 code = jQuery.trim( code );
6917
6918 if ( code ) {
6919 // If the code includes a valid, prologue position
6920 // strict mode pragma, execute code by injecting a
6921 // script tag into the document.
6922 if ( code.indexOf("use strict") === 1 ) {
6923 script = document.createElement("script");
6924 script.text = code;
6925 document.head.appendChild( script ).parentNode.removeChild( script );
6926 } else {
6927 // Otherwise, avoid the DOM node creation, insertion
6928 // and removal by using an indirect global eval
6929 indirect( code );
6930 }
6931 }
6932 },
6933
6934 // Convert dashed to camelCase; used by the css and data modules
6935 // Microsoft forgot to hump their vendor prefix (#9572)
6936 camelCase: function( string ) {
6937 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
6938 },
6939
6940 nodeName: function( elem, name ) {
6941 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
6942 },
6943
6944 // args is for internal usage only
6945 each: function( obj, callback, args ) {
6946 var value,
6947 i = 0,
6948 length = obj.length,
6949 isArray = isArraylike( obj );
6950
6951 if ( args ) {
6952 if ( isArray ) {
6953 for ( ; i < length; i++ ) {
6954 value = callback.apply( obj[ i ], args );
6955
6956 if ( value === false ) {
6957 break;
6958 }
6959 }
6960 } else {
6961 for ( i in obj ) {
6962 value = callback.apply( obj[ i ], args );
6963
6964 if ( value === false ) {
6965 break;
6966 }
6967 }
6968 }
6969
6970 // A special, fast, case for the most common use of each
6971 } else {
6972 if ( isArray ) {
6973 for ( ; i < length; i++ ) {
6974 value = callback.call( obj[ i ], i, obj[ i ] );
6975
6976 if ( value === false ) {
6977 break;
6978 }
6979 }
6980 } else {
6981 for ( i in obj ) {
6982 value = callback.call( obj[ i ], i, obj[ i ] );
6983
6984 if ( value === false ) {
6985 break;
6986 }
6987 }
6988 }
6989 }
6990
6991 return obj;
6992 },
6993
6994 // Support: Android<4.1
6995 trim: function( text ) {
6996 return text == null ?
6997 "" :
6998 ( text + "" ).replace( rtrim, "" );
6999 },
7000
7001 // results is for internal usage only
7002 makeArray: function( arr, results ) {
7003 var ret = results || [];
7004
7005 if ( arr != null ) {
7006 if ( isArraylike( Object(arr) ) ) {
7007 jQuery.merge( ret,
7008 typeof arr === "string" ?
7009 [ arr ] : arr
7010 );
7011 } else {
7012 push.call( ret, arr );
7013 }
7014 }
7015
7016 return ret;
7017 },
7018
7019 inArray: function( elem, arr, i ) {
7020 return arr == null ? -1 : indexOf.call( arr, elem, i );
7021 },
7022
7023 merge: function( first, second ) {
7024 var len = +second.length,
7025 j = 0,
7026 i = first.length;
7027
7028 for ( ; j < len; j++ ) {
7029 first[ i++ ] = second[ j ];
7030 }
7031
7032 first.length = i;
7033
7034 return first;
7035 },
7036
7037 grep: function( elems, callback, invert ) {
7038 var callbackInverse,
7039 matches = [],
7040 i = 0,
7041 length = elems.length,
7042 callbackExpect = !invert;
7043
7044 // Go through the array, only saving the items
7045 // that pass the validator function
7046 for ( ; i < length; i++ ) {
7047 callbackInverse = !callback( elems[ i ], i );
7048 if ( callbackInverse !== callbackExpect ) {
7049 matches.push( elems[ i ] );
7050 }
7051 }
7052
7053 return matches;
7054 },
7055
7056 // arg is for internal usage only
7057 map: function( elems, callback, arg ) {
7058 var value,
7059 i = 0,
7060 length = elems.length,
7061 isArray = isArraylike( elems ),
7062 ret = [];
7063
7064 // Go through the array, translating each of the items to their new values
7065 if ( isArray ) {
7066 for ( ; i < length; i++ ) {
7067 value = callback( elems[ i ], i, arg );
7068
7069 if ( value != null ) {
7070 ret.push( value );
7071 }
7072 }
7073
7074 // Go through every key on the object,
7075 } else {
7076 for ( i in elems ) {
7077 value = callback( elems[ i ], i, arg );
7078
7079 if ( value != null ) {
7080 ret.push( value );
7081 }
7082 }
7083 }
7084
7085 // Flatten any nested arrays
7086 return concat.apply( [], ret );
7087 },
7088
7089 // A global GUID counter for objects
7090 guid: 1,
7091
7092 // Bind a function to a context, optionally partially applying any
7093 // arguments.
7094 proxy: function( fn, context ) {
7095 var tmp, args, proxy;
7096
7097 if ( typeof context === "string" ) {
7098 tmp = fn[ context ];
7099 context = fn;
7100 fn = tmp;
7101 }
7102
7103 // Quick check to determine if target is callable, in the spec
7104 // this throws a TypeError, but we will just return undefined.
7105 if ( !jQuery.isFunction( fn ) ) {
7106 return undefined;
7107 }
7108
7109 // Simulated bind
7110 args = slice.call( arguments, 2 );
7111 proxy = function() {
7112 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
7113 };
7114
7115 // Set the guid of unique handler to the same of original handler, so it can be removed
7116 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
7117
7118 return proxy;
7119 },
7120
7121 now: Date.now,
7122
7123 // jQuery.support is not used in Core but other projects attach their
7124 // properties to it so it needs to exist.
7125 support: support
7126 });
7127
7128 // Populate the class2type map
7129 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
7130 class2type[ "[object " + name + "]" ] = name.toLowerCase();
7131 });
7132
7133 function isArraylike( obj ) {
7134 var length = obj.length,
7135 type = jQuery.type( obj );
7136
7137 if ( type === "function" || jQuery.isWindow( obj ) ) {
7138 return false;
7139 }
7140
7141 if ( obj.nodeType === 1 && length ) {
7142 return true;
7143 }
7144
7145 return type === "array" || length === 0 ||
7146 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
7147 }
7148 var Sizzle =
7149 /*!
7150 * Sizzle CSS Selector Engine v1.10.19
7151 * http://sizzlejs.com/
7152 *
7153 * Copyright 2013 jQuery Foundation, Inc. and other contributors
7154 * Released under the MIT license
7155 * http://jquery.org/license
7156 *
7157 * Date: 2014-04-18
7158 */
7159 (function( window ) {
7160
7161 var i,
7162 support,
7163 Expr,
7164 getText,
7165 isXML,
7166 tokenize,
7167 compile,
7168 select,
7169 outermostContext,
7170 sortInput,
7171 hasDuplicate,
7172
7173 // Local document vars
7174 setDocument,
7175 document,
7176 docElem,
7177 documentIsHTML,
7178 rbuggyQSA,
7179 rbuggyMatches,
7180 matches,
7181 contains,
7182
7183 // Instance-specific data
7184 expando = "sizzle" + -(new Date()),
7185 preferredDoc = window.document,
7186 dirruns = 0,
7187 done = 0,
7188 classCache = createCache(),
7189 tokenCache = createCache(),
7190 compilerCache = createCache(),
7191 sortOrder = function( a, b ) {
7192 if ( a === b ) {
7193 hasDuplicate = true;
7194 }
7195 return 0;
7196 },
7197
7198 // General-purpose constants
7199 strundefined = typeof undefined,
7200 MAX_NEGATIVE = 1 << 31,
7201
7202 // Instance methods
7203 hasOwn = ({}).hasOwnProperty,
7204 arr = [],
7205 pop = arr.pop,
7206 push_native = arr.push,
7207 push = arr.push,
7208 slice = arr.slice,
7209 // Use a stripped-down indexOf if we can't use a native one
7210 indexOf = arr.indexOf || function( elem ) {
7211 var i = 0,
7212 len = this.length;
7213 for ( ; i < len; i++ ) {
7214 if ( this[i] === elem ) {
7215 return i;
7216 }
7217 }
7218 return -1;
7219 },
7220
7221 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
7222
7223 // Regular expressions
7224
7225 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
7226 whitespace = "[\\x20\\t\\r\\n\\f]",
7227 // http://www.w3.org/TR/css3-syntax/#characters
7228 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
7229
7230 // Loosely modeled on CSS identifier characters
7231 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
7232 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
7233 identifier = characterEncoding.replace( "w", "w#" ),
7234
7235 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
7236 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
7237 // Operator (capture 2)
7238 "*([*^$|!~]?=)" + whitespace +
7239 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
7240 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
7241 "*\\]",
7242
7243 pseudos = ":(" + characterEncoding + ")(?:\\((" +
7244 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
7245 // 1. quoted (capture 3; capture 4 or capture 5)
7246 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
7247 // 2. simple (capture 6)
7248 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
7249 // 3. anything else (capture 2)
7250 ".*" +
7251 ")\\)|)",
7252
7253 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
7254 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
7255
7256 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
7257 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
7258
7259 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
7260
7261 rpseudo = new RegExp( pseudos ),
7262 ridentifier = new RegExp( "^" + identifier + "$" ),
7263
7264 matchExpr = {
7265 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
7266 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
7267 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
7268 "ATTR": new RegExp( "^" + attributes ),
7269 "PSEUDO": new RegExp( "^" + pseudos ),
7270 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
7271 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
7272 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
7273 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
7274 // For use in libraries implementing .is()
7275 // We use this for POS matching in `select`
7276 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
7277 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
7278 },
7279
7280 rinputs = /^(?:input|select|textarea|button)$/i,
7281 rheader = /^h\d$/i,
7282
7283 rnative = /^[^{]+\{\s*\[native \w/,
7284
7285 // Easily-parseable/retrievable ID or TAG or CLASS selectors
7286 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
7287
7288 rsibling = /[+~]/,
7289 rescape = /'|\\/g,
7290
7291 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
7292 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
7293 funescape = function( _, escaped, escapedWhitespace ) {
7294 var high = "0x" + escaped - 0x10000;
7295 // NaN means non-codepoint
7296 // Support: Firefox<24
7297 // Workaround erroneous numeric interpretation of +"0x"
7298 return high !== high || escapedWhitespace ?
7299 escaped :
7300 high < 0 ?
7301 // BMP codepoint
7302 String.fromCharCode( high + 0x10000 ) :
7303 // Supplemental Plane codepoint (surrogate pair)
7304 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
7305 };
7306
7307 // Optimize for push.apply( _, NodeList )
7308 try {
7309 push.apply(
7310 (arr = slice.call( preferredDoc.childNodes )),
7311 preferredDoc.childNodes
7312 );
7313 // Support: Android<4.0
7314 // Detect silently failing push.apply
7315 arr[ preferredDoc.childNodes.length ].nodeType;
7316 } catch ( e ) {
7317 push = { apply: arr.length ?
7318
7319 // Leverage slice if possible
7320 function( target, els ) {
7321 push_native.apply( target, slice.call(els) );
7322 } :
7323
7324 // Support: IE<9
7325 // Otherwise append directly
7326 function( target, els ) {
7327 var j = target.length,
7328 i = 0;
7329 // Can't trust NodeList.length
7330 while ( (target[j++] = els[i++]) ) {}
7331 target.length = j - 1;
7332 }
7333 };
7334 }
7335
7336 function Sizzle( selector, context, results, seed ) {
7337 var match, elem, m, nodeType,
7338 // QSA vars
7339 i, groups, old, nid, newContext, newSelector;
7340
7341 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
7342 setDocument( context );
7343 }
7344
7345 context = context || document;
7346 results = results || [];
7347
7348 if ( !selector || typeof selector !== "string" ) {
7349 return results;
7350 }
7351
7352 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
7353 return [];
7354 }
7355
7356 if ( documentIsHTML && !seed ) {
7357
7358 // Shortcuts
7359 if ( (match = rquickExpr.exec( selector )) ) {
7360 // Speed-up: Sizzle("#ID")
7361 if ( (m = match[1]) ) {
7362 if ( nodeType === 9 ) {
7363 elem = context.getElementById( m );
7364 // Check parentNode to catch when Blackberry 4.6 returns
7365 // nodes that are no longer in the document (jQuery #6963)
7366 if ( elem && elem.parentNode ) {
7367 // Handle the case where IE, Opera, and Webkit return items
7368 // by name instead of ID
7369 if ( elem.id === m ) {
7370 results.push( elem );
7371 return results;
7372 }
7373 } else {
7374 return results;
7375 }
7376 } else {
7377 // Context is not a document
7378 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
7379 contains( context, elem ) && elem.id === m ) {
7380 results.push( elem );
7381 return results;
7382 }
7383 }
7384
7385 // Speed-up: Sizzle("TAG")
7386 } else if ( match[2] ) {
7387 push.apply( results, context.getElementsByTagName( selector ) );
7388 return results;
7389
7390 // Speed-up: Sizzle(".CLASS")
7391 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
7392 push.apply( results, context.getElementsByClassName( m ) );
7393 return results;
7394 }
7395 }
7396
7397 // QSA path
7398 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
7399 nid = old = expando;
7400 newContext = context;
7401 newSelector = nodeType === 9 && selector;
7402
7403 // qSA works strangely on Element-rooted queries
7404 // We can work around this by specifying an extra ID on the root
7405 // and working up from there (Thanks to Andrew Dupont for the technique)
7406 // IE 8 doesn't work on object elements
7407 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
7408 groups = tokenize( selector );
7409
7410 if ( (old = context.getAttribute("id")) ) {
7411 nid = old.replace( rescape, "\\$&" );
7412 } else {
7413 context.setAttribute( "id", nid );
7414 }
7415 nid = "[id='" + nid + "'] ";
7416
7417 i = groups.length;
7418 while ( i-- ) {
7419 groups[i] = nid + toSelector( groups[i] );
7420 }
7421 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
7422 newSelector = groups.join(",");
7423 }
7424
7425 if ( newSelector ) {
7426 try {
7427 push.apply( results,
7428 newContext.querySelectorAll( newSelector )
7429 );
7430 return results;
7431 } catch(qsaError) {
7432 } finally {
7433 if ( !old ) {
7434 context.removeAttribute("id");
7435 }
7436 }
7437 }
7438 }
7439 }
7440
7441 // All others
7442 return select( selector.replace( rtrim, "$1" ), context, results, seed );
7443 }
7444
7445 /**
7446 * Create key-value caches of limited size
7447 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
7448 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
7449 * deleting the oldest entry
7450 */
7451 function createCache() {
7452 var keys = [];
7453
7454 function cache( key, value ) {
7455 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
7456 if ( keys.push( key + " " ) > Expr.cacheLength ) {
7457 // Only keep the most recent entries
7458 delete cache[ keys.shift() ];
7459 }
7460 return (cache[ key + " " ] = value);
7461 }
7462 return cache;
7463 }
7464
7465 /**
7466 * Mark a function for special use by Sizzle
7467 * @param {Function} fn The function to mark
7468 */
7469 function markFunction( fn ) {
7470 fn[ expando ] = true;
7471 return fn;
7472 }
7473
7474 /**
7475 * Support testing using an element
7476 * @param {Function} fn Passed the created div and expects a boolean result
7477 */
7478 function assert( fn ) {
7479 var div = document.createElement("div");
7480
7481 try {
7482 return !!fn( div );
7483 } catch (e) {
7484 return false;
7485 } finally {
7486 // Remove from its parent by default
7487 if ( div.parentNode ) {
7488 div.parentNode.removeChild( div );
7489 }
7490 // release memory in IE
7491 div = null;
7492 }
7493 }
7494
7495 /**
7496 * Adds the same handler for all of the specified attrs
7497 * @param {String} attrs Pipe-separated list of attributes
7498 * @param {Function} handler The method that will be applied
7499 */
7500 function addHandle( attrs, handler ) {
7501 var arr = attrs.split("|"),
7502 i = attrs.length;
7503
7504 while ( i-- ) {
7505 Expr.attrHandle[ arr[i] ] = handler;
7506 }
7507 }
7508
7509 /**
7510 * Checks document order of two siblings
7511 * @param {Element} a
7512 * @param {Element} b
7513 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
7514 */
7515 function siblingCheck( a, b ) {
7516 var cur = b && a,
7517 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
7518 ( ~b.sourceIndex || MAX_NEGATIVE ) -
7519 ( ~a.sourceIndex || MAX_NEGATIVE );
7520
7521 // Use IE sourceIndex if available on both nodes
7522 if ( diff ) {
7523 return diff;
7524 }
7525
7526 // Check if b follows a
7527 if ( cur ) {
7528 while ( (cur = cur.nextSibling) ) {
7529 if ( cur === b ) {
7530 return -1;
7531 }
7532 }
7533 }
7534
7535 return a ? 1 : -1;
7536 }
7537
7538 /**
7539 * Returns a function to use in pseudos for input types
7540 * @param {String} type
7541 */
7542 function createInputPseudo( type ) {
7543 return function( elem ) {
7544 var name = elem.nodeName.toLowerCase();
7545 return name === "input" && elem.type === type;
7546 };
7547 }
7548
7549 /**
7550 * Returns a function to use in pseudos for buttons
7551 * @param {String} type
7552 */
7553 function createButtonPseudo( type ) {
7554 return function( elem ) {
7555 var name = elem.nodeName.toLowerCase();
7556 return (name === "input" || name === "button") && elem.type === type;
7557 };
7558 }
7559
7560 /**
7561 * Returns a function to use in pseudos for positionals
7562 * @param {Function} fn
7563 */
7564 function createPositionalPseudo( fn ) {
7565 return markFunction(function( argument ) {
7566 argument = +argument;
7567 return markFunction(function( seed, matches ) {
7568 var j,
7569 matchIndexes = fn( [], seed.length, argument ),
7570 i = matchIndexes.length;
7571
7572 // Match elements found at the specified indexes
7573 while ( i-- ) {
7574 if ( seed[ (j = matchIndexes[i]) ] ) {
7575 seed[j] = !(matches[j] = seed[j]);
7576 }
7577 }
7578 });
7579 });
7580 }
7581
7582 /**
7583 * Checks a node for validity as a Sizzle context
7584 * @param {Element|Object=} context
7585 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
7586 */
7587 function testContext( context ) {
7588 return context && typeof context.getElementsByTagName !== strundefined && context;
7589 }
7590
7591 // Expose support vars for convenience
7592 support = Sizzle.support = {};
7593
7594 /**
7595 * Detects XML nodes
7596 * @param {Element|Object} elem An element or a document
7597 * @returns {Boolean} True iff elem is a non-HTML XML node
7598 */
7599 isXML = Sizzle.isXML = function( elem ) {
7600 // documentElement is verified for cases where it doesn't yet exist
7601 // (such as loading iframes in IE - #4833)
7602 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
7603 return documentElement ? documentElement.nodeName !== "HTML" : false;
7604 };
7605
7606 /**
7607 * Sets document-related variables once based on the current document
7608 * @param {Element|Object} [doc] An element or document object to use to set the document
7609 * @returns {Object} Returns the current document
7610 */
7611 setDocument = Sizzle.setDocument = function( node ) {
7612 var hasCompare,
7613 doc = node ? node.ownerDocument || node : preferredDoc,
7614 parent = doc.defaultView;
7615
7616 // If no document and documentElement is available, return
7617 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
7618 return document;
7619 }
7620
7621 // Set our document
7622 document = doc;
7623 docElem = doc.documentElement;
7624
7625 // Support tests
7626 documentIsHTML = !isXML( doc );
7627
7628 // Support: IE>8
7629 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
7630 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
7631 // IE6-8 do not support the defaultView property so parent will be undefined
7632 if ( parent && parent !== parent.top ) {
7633 // IE11 does not have attachEvent, so all must suffer
7634 if ( parent.addEventListener ) {
7635 parent.addEventListener( "unload", function() {
7636 setDocument();
7637 }, false );
7638 } else if ( parent.attachEvent ) {
7639 parent.attachEvent( "onunload", function() {
7640 setDocument();
7641 });
7642 }
7643 }
7644
7645 /* Attributes
7646 ---------------------------------------------------------------------- */
7647
7648 // Support: IE<8
7649 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
7650 support.attributes = assert(function( div ) {
7651 div.className = "i";
7652 return !div.getAttribute("className");
7653 });
7654
7655 /* getElement(s)By*
7656 ---------------------------------------------------------------------- */
7657
7658 // Check if getElementsByTagName("*") returns only elements
7659 support.getElementsByTagName = assert(function( div ) {
7660 div.appendChild( doc.createComment("") );
7661 return !div.getElementsByTagName("*").length;
7662 });
7663
7664 // Check if getElementsByClassName can be trusted
7665 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
7666 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
7667
7668 // Support: Safari<4
7669 // Catch class over-caching
7670 div.firstChild.className = "i";
7671 // Support: Opera<10
7672 // Catch gEBCN failure to find non-leading classes
7673 return div.getElementsByClassName("i").length === 2;
7674 });
7675
7676 // Support: IE<10
7677 // Check if getElementById returns elements by name
7678 // The broken getElementById methods don't pick up programatically-set names,
7679 // so use a roundabout getElementsByName test
7680 support.getById = assert(function( div ) {
7681 docElem.appendChild( div ).id = expando;
7682 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
7683 });
7684
7685 // ID find and filter
7686 if ( support.getById ) {
7687 Expr.find["ID"] = function( id, context ) {
7688 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
7689 var m = context.getElementById( id );
7690 // Check parentNode to catch when Blackberry 4.6 returns
7691 // nodes that are no longer in the document #6963
7692 return m && m.parentNode ? [ m ] : [];
7693 }
7694 };
7695 Expr.filter["ID"] = function( id ) {
7696 var attrId = id.replace( runescape, funescape );
7697 return function( elem ) {
7698 return elem.getAttribute("id") === attrId;
7699 };
7700 };
7701 } else {
7702 // Support: IE6/7
7703 // getElementById is not reliable as a find shortcut
7704 delete Expr.find["ID"];
7705
7706 Expr.filter["ID"] = function( id ) {
7707 var attrId = id.replace( runescape, funescape );
7708 return function( elem ) {
7709 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
7710 return node && node.value === attrId;
7711 };
7712 };
7713 }
7714
7715 // Tag
7716 Expr.find["TAG"] = support.getElementsByTagName ?
7717 function( tag, context ) {
7718 if ( typeof context.getElementsByTagName !== strundefined ) {
7719 return context.getElementsByTagName( tag );
7720 }
7721 } :
7722 function( tag, context ) {
7723 var elem,
7724 tmp = [],
7725 i = 0,
7726 results = context.getElementsByTagName( tag );
7727
7728 // Filter out possible comments
7729 if ( tag === "*" ) {
7730 while ( (elem = results[i++]) ) {
7731 if ( elem.nodeType === 1 ) {
7732 tmp.push( elem );
7733 }
7734 }
7735
7736 return tmp;
7737 }
7738 return results;
7739 };
7740
7741 // Class
7742 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
7743 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
7744 return context.getElementsByClassName( className );
7745 }
7746 };
7747
7748 /* QSA/matchesSelector
7749 ---------------------------------------------------------------------- */
7750
7751 // QSA and matchesSelector support
7752
7753 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
7754 rbuggyMatches = [];
7755
7756 // qSa(:focus) reports false when true (Chrome 21)
7757 // We allow this because of a bug in IE8/9 that throws an error
7758 // whenever `document.activeElement` is accessed on an iframe
7759 // So, we allow :focus to pass through QSA all the time to avoid the IE error
7760 // See http://bugs.jquery.com/ticket/13378
7761 rbuggyQSA = [];
7762
7763 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
7764 // Build QSA regex
7765 // Regex strategy adopted from Diego Perini
7766 assert(function( div ) {
7767 // Select is set to empty string on purpose
7768 // This is to test IE's treatment of not explicitly
7769 // setting a boolean content attribute,
7770 // since its presence should be enough
7771 // http://bugs.jquery.com/ticket/12359
7772 div.innerHTML = "<select msallowclip=''><option selected=''></option></select>";
7773
7774 // Support: IE8, Opera 11-12.16
7775 // Nothing should be selected when empty strings follow ^= or $= or *=
7776 // The test attribute must be unknown in Opera but "safe" for WinRT
7777 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
7778 if ( div.querySelectorAll("[msallowclip^='']").length ) {
7779 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
7780 }
7781
7782 // Support: IE8
7783 // Boolean attributes and "value" are not treated correctly
7784 if ( !div.querySelectorAll("[selected]").length ) {
7785 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
7786 }
7787
7788 // Webkit/Opera - :checked should return selected option elements
7789 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
7790 // IE8 throws error here and will not see later tests
7791 if ( !div.querySelectorAll(":checked").length ) {
7792 rbuggyQSA.push(":checked");
7793 }
7794 });
7795
7796 assert(function( div ) {
7797 // Support: Windows 8 Native Apps
7798 // The type and name attributes are restricted during .innerHTML assignment
7799 var input = doc.createElement("input");
7800 input.setAttribute( "type", "hidden" );
7801 div.appendChild( input ).setAttribute( "name", "D" );
7802
7803 // Support: IE8
7804 // Enforce case-sensitivity of name attribute
7805 if ( div.querySelectorAll("[name=d]").length ) {
7806 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
7807 }
7808
7809 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
7810 // IE8 throws error here and will not see later tests
7811 if ( !div.querySelectorAll(":enabled").length ) {
7812 rbuggyQSA.push( ":enabled", ":disabled" );
7813 }
7814
7815 // Opera 10-11 does not throw on post-comma invalid pseudos
7816 div.querySelectorAll("*,:x");
7817 rbuggyQSA.push(",.*:");
7818 });
7819 }
7820
7821 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
7822 docElem.webkitMatchesSelector ||
7823 docElem.mozMatchesSelector ||
7824 docElem.oMatchesSelector ||
7825 docElem.msMatchesSelector) )) ) {
7826
7827 assert(function( div ) {
7828 // Check to see if it's possible to do matchesSelector
7829 // on a disconnected node (IE 9)
7830 support.disconnectedMatch = matches.call( div, "div" );
7831
7832 // This should fail with an exception
7833 // Gecko does not error, returns false instead
7834 matches.call( div, "[s!='']:x" );
7835 rbuggyMatches.push( "!=", pseudos );
7836 });
7837 }
7838
7839 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
7840 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
7841
7842 /* Contains
7843 ---------------------------------------------------------------------- */
7844 hasCompare = rnative.test( docElem.compareDocumentPosition );
7845
7846 // Element contains another
7847 // Purposefully does not implement inclusive descendent
7848 // As in, an element does not contain itself
7849 contains = hasCompare || rnative.test( docElem.contains ) ?
7850 function( a, b ) {
7851 var adown = a.nodeType === 9 ? a.documentElement : a,
7852 bup = b && b.parentNode;
7853 return a === bup || !!( bup && bup.nodeType === 1 && (
7854 adown.contains ?
7855 adown.contains( bup ) :
7856 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
7857 ));
7858 } :
7859 function( a, b ) {
7860 if ( b ) {
7861 while ( (b = b.parentNode) ) {
7862 if ( b === a ) {
7863 return true;
7864 }
7865 }
7866 }
7867 return false;
7868 };
7869
7870 /* Sorting
7871 ---------------------------------------------------------------------- */
7872
7873 // Document order sorting
7874 sortOrder = hasCompare ?
7875 function( a, b ) {
7876
7877 // Flag for duplicate removal
7878 if ( a === b ) {
7879 hasDuplicate = true;
7880 return 0;
7881 }
7882
7883 // Sort on method existence if only one input has compareDocumentPosition
7884 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
7885 if ( compare ) {
7886 return compare;
7887 }
7888
7889 // Calculate position if both inputs belong to the same document
7890 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
7891 a.compareDocumentPosition( b ) :
7892
7893 // Otherwise we know they are disconnected
7894 1;
7895
7896 // Disconnected nodes
7897 if ( compare & 1 ||
7898 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
7899
7900 // Choose the first element that is related to our preferred document
7901 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
7902 return -1;
7903 }
7904 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
7905 return 1;
7906 }
7907
7908 // Maintain original order
7909 return sortInput ?
7910 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
7911 0;
7912 }
7913
7914 return compare & 4 ? -1 : 1;
7915 } :
7916 function( a, b ) {
7917 // Exit early if the nodes are identical
7918 if ( a === b ) {
7919 hasDuplicate = true;
7920 return 0;
7921 }
7922
7923 var cur,
7924 i = 0,
7925 aup = a.parentNode,
7926 bup = b.parentNode,
7927 ap = [ a ],
7928 bp = [ b ];
7929
7930 // Parentless nodes are either documents or disconnected
7931 if ( !aup || !bup ) {
7932 return a === doc ? -1 :
7933 b === doc ? 1 :
7934 aup ? -1 :
7935 bup ? 1 :
7936 sortInput ?
7937 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
7938 0;
7939
7940 // If the nodes are siblings, we can do a quick check
7941 } else if ( aup === bup ) {
7942 return siblingCheck( a, b );
7943 }
7944
7945 // Otherwise we need full lists of their ancestors for comparison
7946 cur = a;
7947 while ( (cur = cur.parentNode) ) {
7948 ap.unshift( cur );
7949 }
7950 cur = b;
7951 while ( (cur = cur.parentNode) ) {
7952 bp.unshift( cur );
7953 }
7954
7955 // Walk down the tree looking for a discrepancy
7956 while ( ap[i] === bp[i] ) {
7957 i++;
7958 }
7959
7960 return i ?
7961 // Do a sibling check if the nodes have a common ancestor
7962 siblingCheck( ap[i], bp[i] ) :
7963
7964 // Otherwise nodes in our document sort first
7965 ap[i] === preferredDoc ? -1 :
7966 bp[i] === preferredDoc ? 1 :
7967 0;
7968 };
7969
7970 return doc;
7971 };
7972
7973 Sizzle.matches = function( expr, elements ) {
7974 return Sizzle( expr, null, null, elements );
7975 };
7976
7977 Sizzle.matchesSelector = function( elem, expr ) {
7978 // Set document vars if needed
7979 if ( ( elem.ownerDocument || elem ) !== document ) {
7980 setDocument( elem );
7981 }
7982
7983 // Make sure that attribute selectors are quoted
7984 expr = expr.replace( rattributeQuotes, "='$1']" );
7985
7986 if ( support.matchesSelector && documentIsHTML &&
7987 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
7988 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
7989
7990 try {
7991 var ret = matches.call( elem, expr );
7992
7993 // IE 9's matchesSelector returns false on disconnected nodes
7994 if ( ret || support.disconnectedMatch ||
7995 // As well, disconnected nodes are said to be in a document
7996 // fragment in IE 9
7997 elem.document && elem.document.nodeType !== 11 ) {
7998 return ret;
7999 }
8000 } catch(e) {}
8001 }
8002
8003 return Sizzle( expr, document, null, [ elem ] ).length > 0;
8004 };
8005
8006 Sizzle.contains = function( context, elem ) {
8007 // Set document vars if needed
8008 if ( ( context.ownerDocument || context ) !== document ) {
8009 setDocument( context );
8010 }
8011 return contains( context, elem );
8012 };
8013
8014 Sizzle.attr = function( elem, name ) {
8015 // Set document vars if needed
8016 if ( ( elem.ownerDocument || elem ) !== document ) {
8017 setDocument( elem );
8018 }
8019
8020 var fn = Expr.attrHandle[ name.toLowerCase() ],
8021 // Don't get fooled by Object.prototype properties (jQuery #13807)
8022 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
8023 fn( elem, name, !documentIsHTML ) :
8024 undefined;
8025
8026 return val !== undefined ?
8027 val :
8028 support.attributes || !documentIsHTML ?
8029 elem.getAttribute( name ) :
8030 (val = elem.getAttributeNode(name)) && val.specified ?
8031 val.value :
8032 null;
8033 };
8034
8035 Sizzle.error = function( msg ) {
8036 throw new Error( "Syntax error, unrecognized expression: " + msg );
8037 };
8038
8039 /**
8040 * Document sorting and removing duplicates
8041 * @param {ArrayLike} results
8042 */
8043 Sizzle.uniqueSort = function( results ) {
8044 var elem,
8045 duplicates = [],
8046 j = 0,
8047 i = 0;
8048
8049 // Unless we *know* we can detect duplicates, assume their presence
8050 hasDuplicate = !support.detectDuplicates;
8051 sortInput = !support.sortStable && results.slice( 0 );
8052 results.sort( sortOrder );
8053
8054 if ( hasDuplicate ) {
8055 while ( (elem = results[i++]) ) {
8056 if ( elem === results[ i ] ) {
8057 j = duplicates.push( i );
8058 }
8059 }
8060 while ( j-- ) {
8061 results.splice( duplicates[ j ], 1 );
8062 }
8063 }
8064
8065 // Clear input after sorting to release objects
8066 // See https://github.com/jquery/sizzle/pull/225
8067 sortInput = null;
8068
8069 return results;
8070 };
8071
8072 /**
8073 * Utility function for retrieving the text value of an array of DOM nodes
8074 * @param {Array|Element} elem
8075 */
8076 getText = Sizzle.getText = function( elem ) {
8077 var node,
8078 ret = "",
8079 i = 0,
8080 nodeType = elem.nodeType;
8081
8082 if ( !nodeType ) {
8083 // If no nodeType, this is expected to be an array
8084 while ( (node = elem[i++]) ) {
8085 // Do not traverse comment nodes
8086 ret += getText( node );
8087 }
8088 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
8089 // Use textContent for elements
8090 // innerText usage removed for consistency of new lines (jQuery #11153)
8091 if ( typeof elem.textContent === "string" ) {
8092 return elem.textContent;
8093 } else {
8094 // Traverse its children
8095 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
8096 ret += getText( elem );
8097 }
8098 }
8099 } else if ( nodeType === 3 || nodeType === 4 ) {
8100 return elem.nodeValue;
8101 }
8102 // Do not include comment or processing instruction nodes
8103
8104 return ret;
8105 };
8106
8107 Expr = Sizzle.selectors = {
8108
8109 // Can be adjusted by the user
8110 cacheLength: 50,
8111
8112 createPseudo: markFunction,
8113
8114 match: matchExpr,
8115
8116 attrHandle: {},
8117
8118 find: {},
8119
8120 relative: {
8121 ">": { dir: "parentNode", first: true },
8122 " ": { dir: "parentNode" },
8123 "+": { dir: "previousSibling", first: true },
8124 "~": { dir: "previousSibling" }
8125 },
8126
8127 preFilter: {
8128 "ATTR": function( match ) {
8129 match[1] = match[1].replace( runescape, funescape );
8130
8131 // Move the given value to match[3] whether quoted or unquoted
8132 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
8133
8134 if ( match[2] === "~=" ) {
8135 match[3] = " " + match[3] + " ";
8136 }
8137
8138 return match.slice( 0, 4 );
8139 },
8140
8141 "CHILD": function( match ) {
8142 /* matches from matchExpr["CHILD"]
8143 1 type (only|nth|...)
8144 2 what (child|of-type)
8145 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
8146 4 xn-component of xn+y argument ([+-]?\d*n|)
8147 5 sign of xn-component
8148 6 x of xn-component
8149 7 sign of y-component
8150 8 y of y-component
8151 */
8152 match[1] = match[1].toLowerCase();
8153
8154 if ( match[1].slice( 0, 3 ) === "nth" ) {
8155 // nth-* requires argument
8156 if ( !match[3] ) {
8157 Sizzle.error( match[0] );
8158 }
8159
8160 // numeric x and y parameters for Expr.filter.CHILD
8161 // remember that false/true cast respectively to 0/1
8162 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
8163 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
8164
8165 // other types prohibit arguments
8166 } else if ( match[3] ) {
8167 Sizzle.error( match[0] );
8168 }
8169
8170 return match;
8171 },
8172
8173 "PSEUDO": function( match ) {
8174 var excess,
8175 unquoted = !match[6] && match[2];
8176
8177 if ( matchExpr["CHILD"].test( match[0] ) ) {
8178 return null;
8179 }
8180
8181 // Accept quoted arguments as-is
8182 if ( match[3] ) {
8183 match[2] = match[4] || match[5] || "";
8184
8185 // Strip excess characters from unquoted arguments
8186 } else if ( unquoted && rpseudo.test( unquoted ) &&
8187 // Get excess from tokenize (recursively)
8188 (excess = tokenize( unquoted, true )) &&
8189 // advance to the next closing parenthesis
8190 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
8191
8192 // excess is a negative index
8193 match[0] = match[0].slice( 0, excess );
8194 match[2] = unquoted.slice( 0, excess );
8195 }
8196
8197 // Return only captures needed by the pseudo filter method (type and argument)
8198 return match.slice( 0, 3 );
8199 }
8200 },
8201
8202 filter: {
8203
8204 "TAG": function( nodeNameSelector ) {
8205 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
8206 return nodeNameSelector === "*" ?
8207 function() { return true; } :
8208 function( elem ) {
8209 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
8210 };
8211 },
8212
8213 "CLASS": function( className ) {
8214 var pattern = classCache[ className + " " ];
8215
8216 return pattern ||
8217 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
8218 classCache( className, function( elem ) {
8219 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
8220 });
8221 },
8222
8223 "ATTR": function( name, operator, check ) {
8224 return function( elem ) {
8225 var result = Sizzle.attr( elem, name );
8226
8227 if ( result == null ) {
8228 return operator === "!=";
8229 }
8230 if ( !operator ) {
8231 return true;
8232 }
8233
8234 result += "";
8235
8236 return operator === "=" ? result === check :
8237 operator === "!=" ? result !== check :
8238 operator === "^=" ? check && result.indexOf( check ) === 0 :
8239 operator === "*=" ? check && result.indexOf( check ) > -1 :
8240 operator === "$=" ? check && result.slice( -check.length ) === check :
8241 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
8242 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
8243 false;
8244 };
8245 },
8246
8247 "CHILD": function( type, what, argument, first, last ) {
8248 var simple = type.slice( 0, 3 ) !== "nth",
8249 forward = type.slice( -4 ) !== "last",
8250 ofType = what === "of-type";
8251
8252 return first === 1 && last === 0 ?
8253
8254 // Shortcut for :nth-*(n)
8255 function( elem ) {
8256 return !!elem.parentNode;
8257 } :
8258
8259 function( elem, context, xml ) {
8260 var cache, outerCache, node, diff, nodeIndex, start,
8261 dir = simple !== forward ? "nextSibling" : "previousSibling",
8262 parent = elem.parentNode,
8263 name = ofType && elem.nodeName.toLowerCase(),
8264 useCache = !xml && !ofType;
8265
8266 if ( parent ) {
8267
8268 // :(first|last|only)-(child|of-type)
8269 if ( simple ) {
8270 while ( dir ) {
8271 node = elem;
8272 while ( (node = node[ dir ]) ) {
8273 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
8274 return false;
8275 }
8276 }
8277 // Reverse direction for :only-* (if we haven't yet done so)
8278 start = dir = type === "only" && !start && "nextSibling";
8279 }
8280 return true;
8281 }
8282
8283 start = [ forward ? parent.firstChild : parent.lastChild ];
8284
8285 // non-xml :nth-child(...) stores cache data on `parent`
8286 if ( forward && useCache ) {
8287 // Seek `elem` from a previously-cached index
8288 outerCache = parent[ expando ] || (parent[ expando ] = {});
8289 cache = outerCache[ type ] || [];
8290 nodeIndex = cache[0] === dirruns && cache[1];
8291 diff = cache[0] === dirruns && cache[2];
8292 node = nodeIndex && parent.childNodes[ nodeIndex ];
8293
8294 while ( (node = ++nodeIndex && node && node[ dir ] ||
8295
8296 // Fallback to seeking `elem` from the start
8297 (diff = nodeIndex = 0) || start.pop()) ) {
8298
8299 // When found, cache indexes on `parent` and break
8300 if ( node.nodeType === 1 && ++diff && node === elem ) {
8301 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
8302 break;
8303 }
8304 }
8305
8306 // Use previously-cached element index if available
8307 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
8308 diff = cache[1];
8309
8310 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
8311 } else {
8312 // Use the same loop as above to seek `elem` from the start
8313 while ( (node = ++nodeIndex && node && node[ dir ] ||
8314 (diff = nodeIndex = 0) || start.pop()) ) {
8315
8316 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
8317 // Cache the index of each encountered element
8318 if ( useCache ) {
8319 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
8320 }
8321
8322 if ( node === elem ) {
8323 break;
8324 }
8325 }
8326 }
8327 }
8328
8329 // Incorporate the offset, then check against cycle size
8330 diff -= last;
8331 return diff === first || ( diff % first === 0 && diff / first >= 0 );
8332 }
8333 };
8334 },
8335
8336 "PSEUDO": function( pseudo, argument ) {
8337 // pseudo-class names are case-insensitive
8338 // http://www.w3.org/TR/selectors/#pseudo-classes
8339 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
8340 // Remember that setFilters inherits from pseudos
8341 var args,
8342 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
8343 Sizzle.error( "unsupported pseudo: " + pseudo );
8344
8345 // The user may use createPseudo to indicate that
8346 // arguments are needed to create the filter function
8347 // just as Sizzle does
8348 if ( fn[ expando ] ) {
8349 return fn( argument );
8350 }
8351
8352 // But maintain support for old signatures
8353 if ( fn.length > 1 ) {
8354 args = [ pseudo, pseudo, "", argument ];
8355 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
8356 markFunction(function( seed, matches ) {
8357 var idx,
8358 matched = fn( seed, argument ),
8359 i = matched.length;
8360 while ( i-- ) {
8361 idx = indexOf.call( seed, matched[i] );
8362 seed[ idx ] = !( matches[ idx ] = matched[i] );
8363 }
8364 }) :
8365 function( elem ) {
8366 return fn( elem, 0, args );
8367 };
8368 }
8369
8370 return fn;
8371 }
8372 },
8373
8374 pseudos: {
8375 // Potentially complex pseudos
8376 "not": markFunction(function( selector ) {
8377 // Trim the selector passed to compile
8378 // to avoid treating leading and trailing
8379 // spaces as combinators
8380 var input = [],
8381 results = [],
8382 matcher = compile( selector.replace( rtrim, "$1" ) );
8383
8384 return matcher[ expando ] ?
8385 markFunction(function( seed, matches, context, xml ) {
8386 var elem,
8387 unmatched = matcher( seed, null, xml, [] ),
8388 i = seed.length;
8389
8390 // Match elements unmatched by `matcher`
8391 while ( i-- ) {
8392 if ( (elem = unmatched[i]) ) {
8393 seed[i] = !(matches[i] = elem);
8394 }
8395 }
8396 }) :
8397 function( elem, context, xml ) {
8398 input[0] = elem;
8399 matcher( input, null, xml, results );
8400 return !results.pop();
8401 };
8402 }),
8403
8404 "has": markFunction(function( selector ) {
8405 return function( elem ) {
8406 return Sizzle( selector, elem ).length > 0;
8407 };
8408 }),
8409
8410 "contains": markFunction(function( text ) {
8411 return function( elem ) {
8412 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
8413 };
8414 }),
8415
8416 // "Whether an element is represented by a :lang() selector
8417 // is based solely on the element's language value
8418 // being equal to the identifier C,
8419 // or beginning with the identifier C immediately followed by "-".
8420 // The matching of C against the element's language value is performed case-insensitively.
8421 // The identifier C does not have to be a valid language name."
8422 // http://www.w3.org/TR/selectors/#lang-pseudo
8423 "lang": markFunction( function( lang ) {
8424 // lang value must be a valid identifier
8425 if ( !ridentifier.test(lang || "") ) {
8426 Sizzle.error( "unsupported lang: " + lang );
8427 }
8428 lang = lang.replace( runescape, funescape ).toLowerCase();
8429 return function( elem ) {
8430 var elemLang;
8431 do {
8432 if ( (elemLang = documentIsHTML ?
8433 elem.lang :
8434 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
8435
8436 elemLang = elemLang.toLowerCase();
8437 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
8438 }
8439 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
8440 return false;
8441 };
8442 }),
8443
8444 // Miscellaneous
8445 "target": function( elem ) {
8446 var hash = window.location && window.location.hash;
8447 return hash && hash.slice( 1 ) === elem.id;
8448 },
8449
8450 "root": function( elem ) {
8451 return elem === docElem;
8452 },
8453
8454 "focus": function( elem ) {
8455 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
8456 },
8457
8458 // Boolean properties
8459 "enabled": function( elem ) {
8460 return elem.disabled === false;
8461 },
8462
8463 "disabled": function( elem ) {
8464 return elem.disabled === true;
8465 },
8466
8467 "checked": function( elem ) {
8468 // In CSS3, :checked should return both checked and selected elements
8469 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
8470 var nodeName = elem.nodeName.toLowerCase();
8471 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
8472 },
8473
8474 "selected": function( elem ) {
8475 // Accessing this property makes selected-by-default
8476 // options in Safari work properly
8477 if ( elem.parentNode ) {
8478 elem.parentNode.selectedIndex;
8479 }
8480
8481 return elem.selected === true;
8482 },
8483
8484 // Contents
8485 "empty": function( elem ) {
8486 // http://www.w3.org/TR/selectors/#empty-pseudo
8487 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
8488 // but not by others (comment: 8; processing instruction: 7; etc.)
8489 // nodeType < 6 works because attributes (2) do not appear as children
8490 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
8491 if ( elem.nodeType < 6 ) {
8492 return false;
8493 }
8494 }
8495 return true;
8496 },
8497
8498 "parent": function( elem ) {
8499 return !Expr.pseudos["empty"]( elem );
8500 },
8501
8502 // Element/input types
8503 "header": function( elem ) {
8504 return rheader.test( elem.nodeName );
8505 },
8506
8507 "input": function( elem ) {
8508 return rinputs.test( elem.nodeName );
8509 },
8510
8511 "button": function( elem ) {
8512 var name = elem.nodeName.toLowerCase();
8513 return name === "input" && elem.type === "button" || name === "button";
8514 },
8515
8516 "text": function( elem ) {
8517 var attr;
8518 return elem.nodeName.toLowerCase() === "input" &&
8519 elem.type === "text" &&
8520
8521 // Support: IE<8
8522 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
8523 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
8524 },
8525
8526 // Position-in-collection
8527 "first": createPositionalPseudo(function() {
8528 return [ 0 ];
8529 }),
8530
8531 "last": createPositionalPseudo(function( matchIndexes, length ) {
8532 return [ length - 1 ];
8533 }),
8534
8535 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
8536 return [ argument < 0 ? argument + length : argument ];
8537 }),
8538
8539 "even": createPositionalPseudo(function( matchIndexes, length ) {
8540 var i = 0;
8541 for ( ; i < length; i += 2 ) {
8542 matchIndexes.push( i );
8543 }
8544 return matchIndexes;
8545 }),
8546
8547 "odd": createPositionalPseudo(function( matchIndexes, length ) {
8548 var i = 1;
8549 for ( ; i < length; i += 2 ) {
8550 matchIndexes.push( i );
8551 }
8552 return matchIndexes;
8553 }),
8554
8555 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
8556 var i = argument < 0 ? argument + length : argument;
8557 for ( ; --i >= 0; ) {
8558 matchIndexes.push( i );
8559 }
8560 return matchIndexes;
8561 }),
8562
8563 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
8564 var i = argument < 0 ? argument + length : argument;
8565 for ( ; ++i < length; ) {
8566 matchIndexes.push( i );
8567 }
8568 return matchIndexes;
8569 })
8570 }
8571 };
8572
8573 Expr.pseudos["nth"] = Expr.pseudos["eq"];
8574
8575 // Add button/input type pseudos
8576 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
8577 Expr.pseudos[ i ] = createInputPseudo( i );
8578 }
8579 for ( i in { submit: true, reset: true } ) {
8580 Expr.pseudos[ i ] = createButtonPseudo( i );
8581 }
8582
8583 // Easy API for creating new setFilters
8584 function setFilters() {}
8585 setFilters.prototype = Expr.filters = Expr.pseudos;
8586 Expr.setFilters = new setFilters();
8587
8588 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
8589 var matched, match, tokens, type,
8590 soFar, groups, preFilters,
8591 cached = tokenCache[ selector + " " ];
8592
8593 if ( cached ) {
8594 return parseOnly ? 0 : cached.slice( 0 );
8595 }
8596
8597 soFar = selector;
8598 groups = [];
8599 preFilters = Expr.preFilter;
8600
8601 while ( soFar ) {
8602
8603 // Comma and first run
8604 if ( !matched || (match = rcomma.exec( soFar )) ) {
8605 if ( match ) {
8606 // Don't consume trailing commas as valid
8607 soFar = soFar.slice( match[0].length ) || soFar;
8608 }
8609 groups.push( (tokens = []) );
8610 }
8611
8612 matched = false;
8613
8614 // Combinators
8615 if ( (match = rcombinators.exec( soFar )) ) {
8616 matched = match.shift();
8617 tokens.push({
8618 value: matched,
8619 // Cast descendant combinators to space
8620 type: match[0].replace( rtrim, " " )
8621 });
8622 soFar = soFar.slice( matched.length );
8623 }
8624
8625 // Filters
8626 for ( type in Expr.filter ) {
8627 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
8628 (match = preFilters[ type ]( match ))) ) {
8629 matched = match.shift();
8630 tokens.push({
8631 value: matched,
8632 type: type,
8633 matches: match
8634 });
8635 soFar = soFar.slice( matched.length );
8636 }
8637 }
8638
8639 if ( !matched ) {
8640 break;
8641 }
8642 }
8643
8644 // Return the length of the invalid excess
8645 // if we're just parsing
8646 // Otherwise, throw an error or return tokens
8647 return parseOnly ?
8648 soFar.length :
8649 soFar ?
8650 Sizzle.error( selector ) :
8651 // Cache the tokens
8652 tokenCache( selector, groups ).slice( 0 );
8653 };
8654
8655 function toSelector( tokens ) {
8656 var i = 0,
8657 len = tokens.length,
8658 selector = "";
8659 for ( ; i < len; i++ ) {
8660 selector += tokens[i].value;
8661 }
8662 return selector;
8663 }
8664
8665 function addCombinator( matcher, combinator, base ) {
8666 var dir = combinator.dir,
8667 checkNonElements = base && dir === "parentNode",
8668 doneName = done++;
8669
8670 return combinator.first ?
8671 // Check against closest ancestor/preceding element
8672 function( elem, context, xml ) {
8673 while ( (elem = elem[ dir ]) ) {
8674 if ( elem.nodeType === 1 || checkNonElements ) {
8675 return matcher( elem, context, xml );
8676 }
8677 }
8678 } :
8679
8680 // Check against all ancestor/preceding elements
8681 function( elem, context, xml ) {
8682 var oldCache, outerCache,
8683 newCache = [ dirruns, doneName ];
8684
8685 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
8686 if ( xml ) {
8687 while ( (elem = elem[ dir ]) ) {
8688 if ( elem.nodeType === 1 || checkNonElements ) {
8689 if ( matcher( elem, context, xml ) ) {
8690 return true;
8691 }
8692 }
8693 }
8694 } else {
8695 while ( (elem = elem[ dir ]) ) {
8696 if ( elem.nodeType === 1 || checkNonElements ) {
8697 outerCache = elem[ expando ] || (elem[ expando ] = {});
8698 if ( (oldCache = outerCache[ dir ]) &&
8699 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
8700
8701 // Assign to newCache so results back-propagate to previous elements
8702 return (newCache[ 2 ] = oldCache[ 2 ]);
8703 } else {
8704 // Reuse newcache so results back-propagate to previous elements
8705 outerCache[ dir ] = newCache;
8706
8707 // A match means we're done; a fail means we have to keep checking
8708 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
8709 return true;
8710 }
8711 }
8712 }
8713 }
8714 }
8715 };
8716 }
8717
8718 function elementMatcher( matchers ) {
8719 return matchers.length > 1 ?
8720 function( elem, context, xml ) {
8721 var i = matchers.length;
8722 while ( i-- ) {
8723 if ( !matchers[i]( elem, context, xml ) ) {
8724 return false;
8725 }
8726 }
8727 return true;
8728 } :
8729 matchers[0];
8730 }
8731
8732 function multipleContexts( selector, contexts, results ) {
8733 var i = 0,
8734 len = contexts.length;
8735 for ( ; i < len; i++ ) {
8736 Sizzle( selector, contexts[i], results );
8737 }
8738 return results;
8739 }
8740
8741 function condense( unmatched, map, filter, context, xml ) {
8742 var elem,
8743 newUnmatched = [],
8744 i = 0,
8745 len = unmatched.length,
8746 mapped = map != null;
8747
8748 for ( ; i < len; i++ ) {
8749 if ( (elem = unmatched[i]) ) {
8750 if ( !filter || filter( elem, context, xml ) ) {
8751 newUnmatched.push( elem );
8752 if ( mapped ) {
8753 map.push( i );
8754 }
8755 }
8756 }
8757 }
8758
8759 return newUnmatched;
8760 }
8761
8762 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
8763 if ( postFilter && !postFilter[ expando ] ) {
8764 postFilter = setMatcher( postFilter );
8765 }
8766 if ( postFinder && !postFinder[ expando ] ) {
8767 postFinder = setMatcher( postFinder, postSelector );
8768 }
8769 return markFunction(function( seed, results, context, xml ) {
8770 var temp, i, elem,
8771 preMap = [],
8772 postMap = [],
8773 preexisting = results.length,
8774
8775 // Get initial elements from seed or context
8776 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
8777
8778 // Prefilter to get matcher input, preserving a map for seed-results synchronization
8779 matcherIn = preFilter && ( seed || !selector ) ?
8780 condense( elems, preMap, preFilter, context, xml ) :
8781 elems,
8782
8783 matcherOut = matcher ?
8784 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
8785 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
8786
8787 // ...intermediate processing is necessary
8788 [] :
8789
8790 // ...otherwise use results directly
8791 results :
8792 matcherIn;
8793
8794 // Find primary matches
8795 if ( matcher ) {
8796 matcher( matcherIn, matcherOut, context, xml );
8797 }
8798
8799 // Apply postFilter
8800 if ( postFilter ) {
8801 temp = condense( matcherOut, postMap );
8802 postFilter( temp, [], context, xml );
8803
8804 // Un-match failing elements by moving them back to matcherIn
8805 i = temp.length;
8806 while ( i-- ) {
8807 if ( (elem = temp[i]) ) {
8808 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
8809 }
8810 }
8811 }
8812
8813 if ( seed ) {
8814 if ( postFinder || preFilter ) {
8815 if ( postFinder ) {
8816 // Get the final matcherOut by condensing this intermediate into postFinder contexts
8817 temp = [];
8818 i = matcherOut.length;
8819 while ( i-- ) {
8820 if ( (elem = matcherOut[i]) ) {
8821 // Restore matcherIn since elem is not yet a final match
8822 temp.push( (matcherIn[i] = elem) );
8823 }
8824 }
8825 postFinder( null, (matcherOut = []), temp, xml );
8826 }
8827
8828 // Move matched elements from seed to results to keep them synchronized
8829 i = matcherOut.length;
8830 while ( i-- ) {
8831 if ( (elem = matcherOut[i]) &&
8832 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
8833
8834 seed[temp] = !(results[temp] = elem);
8835 }
8836 }
8837 }
8838
8839 // Add elements to results, through postFinder if defined
8840 } else {
8841 matcherOut = condense(
8842 matcherOut === results ?
8843 matcherOut.splice( preexisting, matcherOut.length ) :
8844 matcherOut
8845 );
8846 if ( postFinder ) {
8847 postFinder( null, results, matcherOut, xml );
8848 } else {
8849 push.apply( results, matcherOut );
8850 }
8851 }
8852 });
8853 }
8854
8855 function matcherFromTokens( tokens ) {
8856 var checkContext, matcher, j,
8857 len = tokens.length,
8858 leadingRelative = Expr.relative[ tokens[0].type ],
8859 implicitRelative = leadingRelative || Expr.relative[" "],
8860 i = leadingRelative ? 1 : 0,
8861
8862 // The foundational matcher ensures that elements are reachable from top-level context(s)
8863 matchContext = addCombinator( function( elem ) {
8864 return elem === checkContext;
8865 }, implicitRelative, true ),
8866 matchAnyContext = addCombinator( function( elem ) {
8867 return indexOf.call( checkContext, elem ) > -1;
8868 }, implicitRelative, true ),
8869 matchers = [ function( elem, context, xml ) {
8870 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
8871 (checkContext = context).nodeType ?
8872 matchContext( elem, context, xml ) :
8873 matchAnyContext( elem, context, xml ) );
8874 } ];
8875
8876 for ( ; i < len; i++ ) {
8877 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
8878 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
8879 } else {
8880 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
8881
8882 // Return special upon seeing a positional matcher
8883 if ( matcher[ expando ] ) {
8884 // Find the next relative operator (if any) for proper handling
8885 j = ++i;
8886 for ( ; j < len; j++ ) {
8887 if ( Expr.relative[ tokens[j].type ] ) {
8888 break;
8889 }
8890 }
8891 return setMatcher(
8892 i > 1 && elementMatcher( matchers ),
8893 i > 1 && toSelector(
8894 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
8895 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
8896 ).replace( rtrim, "$1" ),
8897 matcher,
8898 i < j && matcherFromTokens( tokens.slice( i, j ) ),
8899 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
8900 j < len && toSelector( tokens )
8901 );
8902 }
8903 matchers.push( matcher );
8904 }
8905 }
8906
8907 return elementMatcher( matchers );
8908 }
8909
8910 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
8911 var bySet = setMatchers.length > 0,
8912 byElement = elementMatchers.length > 0,
8913 superMatcher = function( seed, context, xml, results, outermost ) {
8914 var elem, j, matcher,
8915 matchedCount = 0,
8916 i = "0",
8917 unmatched = seed && [],
8918 setMatched = [],
8919 contextBackup = outermostContext,
8920 // We must always have either seed elements or outermost context
8921 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
8922 // Use integer dirruns iff this is the outermost matcher
8923 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
8924 len = elems.length;
8925
8926 if ( outermost ) {
8927 outermostContext = context !== document && context;
8928 }
8929
8930 // Add elements passing elementMatchers directly to results
8931 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
8932 // Support: IE<9, Safari
8933 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
8934 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
8935 if ( byElement && elem ) {
8936 j = 0;
8937 while ( (matcher = elementMatchers[j++]) ) {
8938 if ( matcher( elem, context, xml ) ) {
8939 results.push( elem );
8940 break;
8941 }
8942 }
8943 if ( outermost ) {
8944 dirruns = dirrunsUnique;
8945 }
8946 }
8947
8948 // Track unmatched elements for set filters
8949 if ( bySet ) {
8950 // They will have gone through all possible matchers
8951 if ( (elem = !matcher && elem) ) {
8952 matchedCount--;
8953 }
8954
8955 // Lengthen the array for every element, matched or not
8956 if ( seed ) {
8957 unmatched.push( elem );
8958 }
8959 }
8960 }
8961
8962 // Apply set filters to unmatched elements
8963 matchedCount += i;
8964 if ( bySet && i !== matchedCount ) {
8965 j = 0;
8966 while ( (matcher = setMatchers[j++]) ) {
8967 matcher( unmatched, setMatched, context, xml );
8968 }
8969
8970 if ( seed ) {
8971 // Reintegrate element matches to eliminate the need for sorting
8972 if ( matchedCount > 0 ) {
8973 while ( i-- ) {
8974 if ( !(unmatched[i] || setMatched[i]) ) {
8975 setMatched[i] = pop.call( results );
8976 }
8977 }
8978 }
8979
8980 // Discard index placeholder values to get only actual matches
8981 setMatched = condense( setMatched );
8982 }
8983
8984 // Add matches to results
8985 push.apply( results, setMatched );
8986
8987 // Seedless set matches succeeding multiple successful matchers stipulate sorting
8988 if ( outermost && !seed && setMatched.length > 0 &&
8989 ( matchedCount + setMatchers.length ) > 1 ) {
8990
8991 Sizzle.uniqueSort( results );
8992 }
8993 }
8994
8995 // Override manipulation of globals by nested matchers
8996 if ( outermost ) {
8997 dirruns = dirrunsUnique;
8998 outermostContext = contextBackup;
8999 }
9000
9001 return unmatched;
9002 };
9003
9004 return bySet ?
9005 markFunction( superMatcher ) :
9006 superMatcher;
9007 }
9008
9009 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
9010 var i,
9011 setMatchers = [],
9012 elementMatchers = [],
9013 cached = compilerCache[ selector + " " ];
9014
9015 if ( !cached ) {
9016 // Generate a function of recursive functions that can be used to check each element
9017 if ( !match ) {
9018 match = tokenize( selector );
9019 }
9020 i = match.length;
9021 while ( i-- ) {
9022 cached = matcherFromTokens( match[i] );
9023 if ( cached[ expando ] ) {
9024 setMatchers.push( cached );
9025 } else {
9026 elementMatchers.push( cached );
9027 }
9028 }
9029
9030 // Cache the compiled function
9031 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
9032
9033 // Save selector and tokenization
9034 cached.selector = selector;
9035 }
9036 return cached;
9037 };
9038
9039 /**
9040 * A low-level selection function that works with Sizzle's compiled
9041 * selector functions
9042 * @param {String|Function} selector A selector or a pre-compiled
9043 * selector function built with Sizzle.compile
9044 * @param {Element} context
9045 * @param {Array} [results]
9046 * @param {Array} [seed] A set of elements to match against
9047 */
9048 select = Sizzle.select = function( selector, context, results, seed ) {
9049 var i, tokens, token, type, find,
9050 compiled = typeof selector === "function" && selector,
9051 match = !seed && tokenize( (selector = compiled.selector || selector) );
9052
9053 results = results || [];
9054
9055 // Try to minimize operations if there is no seed and only one group
9056 if ( match.length === 1 ) {
9057
9058 // Take a shortcut and set the context if the root selector is an ID
9059 tokens = match[0] = match[0].slice( 0 );
9060 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
9061 support.getById && context.nodeType === 9 && documentIsHTML &&
9062 Expr.relative[ tokens[1].type ] ) {
9063
9064 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
9065 if ( !context ) {
9066 return results;
9067
9068 // Precompiled matchers will still verify ancestry, so step up a level
9069 } else if ( compiled ) {
9070 context = context.parentNode;
9071 }
9072
9073 selector = selector.slice( tokens.shift().value.length );
9074 }
9075
9076 // Fetch a seed set for right-to-left matching
9077 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
9078 while ( i-- ) {
9079 token = tokens[i];
9080
9081 // Abort if we hit a combinator
9082 if ( Expr.relative[ (type = token.type) ] ) {
9083 break;
9084 }
9085 if ( (find = Expr.find[ type ]) ) {
9086 // Search, expanding context for leading sibling combinators
9087 if ( (seed = find(
9088 token.matches[0].replace( runescape, funescape ),
9089 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
9090 )) ) {
9091
9092 // If seed is empty or no tokens remain, we can return early
9093 tokens.splice( i, 1 );
9094 selector = seed.length && toSelector( tokens );
9095 if ( !selector ) {
9096 push.apply( results, seed );
9097 return results;
9098 }
9099
9100 break;
9101 }
9102 }
9103 }
9104 }
9105
9106 // Compile and execute a filtering function if one is not provided
9107 // Provide `match` to avoid retokenization if we modified the selector above
9108 ( compiled || compile( selector, match ) )(
9109 seed,
9110 context,
9111 !documentIsHTML,
9112 results,
9113 rsibling.test( selector ) && testContext( context.parentNode ) || context
9114 );
9115 return results;
9116 };
9117
9118 // One-time assignments
9119
9120 // Sort stability
9121 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
9122
9123 // Support: Chrome<14
9124 // Always assume duplicates if they aren't passed to the comparison function
9125 support.detectDuplicates = !!hasDuplicate;
9126
9127 // Initialize against the default document
9128 setDocument();
9129
9130 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
9131 // Detached nodes confoundingly follow *each other*
9132 support.sortDetached = assert(function( div1 ) {
9133 // Should return 1, but returns 4 (following)
9134 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
9135 });
9136
9137 // Support: IE<8
9138 // Prevent attribute/property "interpolation"
9139 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
9140 if ( !assert(function( div ) {
9141 div.innerHTML = "<a href='#'></a>";
9142 return div.firstChild.getAttribute("href") === "#" ;
9143 }) ) {
9144 addHandle( "type|href|height|width", function( elem, name, isXML ) {
9145 if ( !isXML ) {
9146 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
9147 }
9148 });
9149 }
9150
9151 // Support: IE<9
9152 // Use defaultValue in place of getAttribute("value")
9153 if ( !support.attributes || !assert(function( div ) {
9154 div.innerHTML = "<input/>";
9155 div.firstChild.setAttribute( "value", "" );
9156 return div.firstChild.getAttribute( "value" ) === "";
9157 }) ) {
9158 addHandle( "value", function( elem, name, isXML ) {
9159 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
9160 return elem.defaultValue;
9161 }
9162 });
9163 }
9164
9165 // Support: IE<9
9166 // Use getAttributeNode to fetch booleans when getAttribute lies
9167 if ( !assert(function( div ) {
9168 return div.getAttribute("disabled") == null;
9169 }) ) {
9170 addHandle( booleans, function( elem, name, isXML ) {
9171 var val;
9172 if ( !isXML ) {
9173 return elem[ name ] === true ? name.toLowerCase() :
9174 (val = elem.getAttributeNode( name )) && val.specified ?
9175 val.value :
9176 null;
9177 }
9178 });
9179 }
9180
9181 return Sizzle;
9182
9183 })( window );
9184
9185
9186
9187 jQuery.find = Sizzle;
9188 jQuery.expr = Sizzle.selectors;
9189 jQuery.expr[":"] = jQuery.expr.pseudos;
9190 jQuery.unique = Sizzle.uniqueSort;
9191 jQuery.text = Sizzle.getText;
9192 jQuery.isXMLDoc = Sizzle.isXML;
9193 jQuery.contains = Sizzle.contains;
9194
9195
9196
9197 var rneedsContext = jQuery.expr.match.needsContext;
9198
9199 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
9200
9201
9202
9203 var risSimple = /^.[^:#\[\.,]*$/;
9204
9205 // Implement the identical functionality for filter and not
9206 function winnow( elements, qualifier, not ) {
9207 if ( jQuery.isFunction( qualifier ) ) {
9208 return jQuery.grep( elements, function( elem, i ) {
9209 /* jshint -W018 */
9210 return !!qualifier.call( elem, i, elem ) !== not;
9211 });
9212
9213 }
9214
9215 if ( qualifier.nodeType ) {
9216 return jQuery.grep( elements, function( elem ) {
9217 return ( elem === qualifier ) !== not;
9218 });
9219
9220 }
9221
9222 if ( typeof qualifier === "string" ) {
9223 if ( risSimple.test( qualifier ) ) {
9224 return jQuery.filter( qualifier, elements, not );
9225 }
9226
9227 qualifier = jQuery.filter( qualifier, elements );
9228 }
9229
9230 return jQuery.grep( elements, function( elem ) {
9231 return ( indexOf.call( qualifier, elem ) >= 0 ) !== not;
9232 });
9233 }
9234
9235 jQuery.filter = function( expr, elems, not ) {
9236 var elem = elems[ 0 ];
9237
9238 if ( not ) {
9239 expr = ":not(" + expr + ")";
9240 }
9241
9242 return elems.length === 1 && elem.nodeType === 1 ?
9243 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
9244 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
9245 return elem.nodeType === 1;
9246 }));
9247 };
9248
9249 jQuery.fn.extend({
9250 find: function( selector ) {
9251 var i,
9252 len = this.length,
9253 ret = [],
9254 self = this;
9255
9256 if ( typeof selector !== "string" ) {
9257 return this.pushStack( jQuery( selector ).filter(function() {
9258 for ( i = 0; i < len; i++ ) {
9259 if ( jQuery.contains( self[ i ], this ) ) {
9260 return true;
9261 }
9262 }
9263 }) );
9264 }
9265
9266 for ( i = 0; i < len; i++ ) {
9267 jQuery.find( selector, self[ i ], ret );
9268 }
9269
9270 // Needed because $( selector, context ) becomes $( context ).find( selector )
9271 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
9272 ret.selector = this.selector ? this.selector + " " + selector : selector;
9273 return ret;
9274 },
9275 filter: function( selector ) {
9276 return this.pushStack( winnow(this, selector || [], false) );
9277 },
9278 not: function( selector ) {
9279 return this.pushStack( winnow(this, selector || [], true) );
9280 },
9281 is: function( selector ) {
9282 return !!winnow(
9283 this,
9284
9285 // If this is a positional/relative selector, check membership in the returned set
9286 // so $("p:first").is("p:last") won't return true for a doc with two "p".
9287 typeof selector === "string" && rneedsContext.test( selector ) ?
9288 jQuery( selector ) :
9289 selector || [],
9290 false
9291 ).length;
9292 }
9293 });
9294
9295
9296 // Initialize a jQuery object
9297
9298
9299 // A central reference to the root jQuery(document)
9300 var rootjQuery,
9301
9302 // A simple way to check for HTML strings
9303 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
9304 // Strict HTML recognition (#11290: must start with <)
9305 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
9306
9307 init = jQuery.fn.init = function( selector, context ) {
9308 var match, elem;
9309
9310 // HANDLE: $(""), $(null), $(undefined), $(false)
9311 if ( !selector ) {
9312 return this;
9313 }
9314
9315 // Handle HTML strings
9316 if ( typeof selector === "string" ) {
9317 if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) {
9318 // Assume that strings that start and end with <> are HTML and skip the regex check
9319 match = [ null, selector, null ];
9320
9321 } else {
9322 match = rquickExpr.exec( selector );
9323 }
9324
9325 // Match html or make sure no context is specified for #id
9326 if ( match && (match[1] || !context) ) {
9327
9328 // HANDLE: $(html) -> $(array)
9329 if ( match[1] ) {
9330 context = context instanceof jQuery ? context[0] : context;
9331
9332 // scripts is true for back-compat
9333 // Intentionally let the error be thrown if parseHTML is not present
9334 jQuery.merge( this, jQuery.parseHTML(
9335 match[1],
9336 context && context.nodeType ? context.ownerDocument || context : document,
9337 true
9338 ) );
9339
9340 // HANDLE: $(html, props)
9341 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
9342 for ( match in context ) {
9343 // Properties of context are called as methods if possible
9344 if ( jQuery.isFunction( this[ match ] ) ) {
9345 this[ match ]( context[ match ] );
9346
9347 // ...and otherwise set as attributes
9348 } else {
9349 this.attr( match, context[ match ] );
9350 }
9351 }
9352 }
9353
9354 return this;
9355
9356 // HANDLE: $(#id)
9357 } else {
9358 elem = document.getElementById( match[2] );
9359
9360 // Check parentNode to catch when Blackberry 4.6 returns
9361 // nodes that are no longer in the document #6963
9362 if ( elem && elem.parentNode ) {
9363 // Inject the element directly into the jQuery object
9364 this.length = 1;
9365 this[0] = elem;
9366 }
9367
9368 this.context = document;
9369 this.selector = selector;
9370 return this;
9371 }
9372
9373 // HANDLE: $(expr, $(...))
9374 } else if ( !context || context.jquery ) {
9375 return ( context || rootjQuery ).find( selector );
9376
9377 // HANDLE: $(expr, context)
9378 // (which is just equivalent to: $(context).find(expr)
9379 } else {
9380 return this.constructor( context ).find( selector );
9381 }
9382
9383 // HANDLE: $(DOMElement)
9384 } else if ( selector.nodeType ) {
9385 this.context = this[0] = selector;
9386 this.length = 1;
9387 return this;
9388
9389 // HANDLE: $(function)
9390 // Shortcut for document ready
9391 } else if ( jQuery.isFunction( selector ) ) {
9392 return typeof rootjQuery.ready !== "undefined" ?
9393 rootjQuery.ready( selector ) :
9394 // Execute immediately if ready is not present
9395 selector( jQuery );
9396 }
9397
9398 if ( selector.selector !== undefined ) {
9399 this.selector = selector.selector;
9400 this.context = selector.context;
9401 }
9402
9403 return jQuery.makeArray( selector, this );
9404 };
9405
9406 // Give the init function the jQuery prototype for later instantiation
9407 init.prototype = jQuery.fn;
9408
9409 // Initialize central reference
9410 rootjQuery = jQuery( document );
9411
9412
9413 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
9414 // methods guaranteed to produce a unique set when starting from a unique set
9415 guaranteedUnique = {
9416 children: true,
9417 contents: true,
9418 next: true,
9419 prev: true
9420 };
9421
9422 jQuery.extend({
9423 dir: function( elem, dir, until ) {
9424 var matched = [],
9425 truncate = until !== undefined;
9426
9427 while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) {
9428 if ( elem.nodeType === 1 ) {
9429 if ( truncate && jQuery( elem ).is( until ) ) {
9430 break;
9431 }
9432 matched.push( elem );
9433 }
9434 }
9435 return matched;
9436 },
9437
9438 sibling: function( n, elem ) {
9439 var matched = [];
9440
9441 for ( ; n; n = n.nextSibling ) {
9442 if ( n.nodeType === 1 && n !== elem ) {
9443 matched.push( n );
9444 }
9445 }
9446
9447 return matched;
9448 }
9449 });
9450
9451 jQuery.fn.extend({
9452 has: function( target ) {
9453 var targets = jQuery( target, this ),
9454 l = targets.length;
9455
9456 return this.filter(function() {
9457 var i = 0;
9458 for ( ; i < l; i++ ) {
9459 if ( jQuery.contains( this, targets[i] ) ) {
9460 return true;
9461 }
9462 }
9463 });
9464 },
9465
9466 closest: function( selectors, context ) {
9467 var cur,
9468 i = 0,
9469 l = this.length,
9470 matched = [],
9471 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
9472 jQuery( selectors, context || this.context ) :
9473 0;
9474
9475 for ( ; i < l; i++ ) {
9476 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
9477 // Always skip document fragments
9478 if ( cur.nodeType < 11 && (pos ?
9479 pos.index(cur) > -1 :
9480
9481 // Don't pass non-elements to Sizzle
9482 cur.nodeType === 1 &&
9483 jQuery.find.matchesSelector(cur, selectors)) ) {
9484
9485 matched.push( cur );
9486 break;
9487 }
9488 }
9489 }
9490
9491 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
9492 },
9493
9494 // Determine the position of an element within
9495 // the matched set of elements
9496 index: function( elem ) {
9497
9498 // No argument, return index in parent
9499 if ( !elem ) {
9500 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
9501 }
9502
9503 // index in selector
9504 if ( typeof elem === "string" ) {
9505 return indexOf.call( jQuery( elem ), this[ 0 ] );
9506 }
9507
9508 // Locate the position of the desired element
9509 return indexOf.call( this,
9510
9511 // If it receives a jQuery object, the first element is used
9512 elem.jquery ? elem[ 0 ] : elem
9513 );
9514 },
9515
9516 add: function( selector, context ) {
9517 return this.pushStack(
9518 jQuery.unique(
9519 jQuery.merge( this.get(), jQuery( selector, context ) )
9520 )
9521 );
9522 },
9523
9524 addBack: function( selector ) {
9525 return this.add( selector == null ?
9526 this.prevObject : this.prevObject.filter(selector)
9527 );
9528 }
9529 });
9530
9531 function sibling( cur, dir ) {
9532 while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {}
9533 return cur;
9534 }
9535
9536 jQuery.each({
9537 parent: function( elem ) {
9538 var parent = elem.parentNode;
9539 return parent && parent.nodeType !== 11 ? parent : null;
9540 },
9541 parents: function( elem ) {
9542 return jQuery.dir( elem, "parentNode" );
9543 },
9544 parentsUntil: function( elem, i, until ) {
9545 return jQuery.dir( elem, "parentNode", until );
9546 },
9547 next: function( elem ) {
9548 return sibling( elem, "nextSibling" );
9549 },
9550 prev: function( elem ) {
9551 return sibling( elem, "previousSibling" );
9552 },
9553 nextAll: function( elem ) {
9554 return jQuery.dir( elem, "nextSibling" );
9555 },
9556 prevAll: function( elem ) {
9557 return jQuery.dir( elem, "previousSibling" );
9558 },
9559 nextUntil: function( elem, i, until ) {
9560 return jQuery.dir( elem, "nextSibling", until );
9561 },
9562 prevUntil: function( elem, i, until ) {
9563 return jQuery.dir( elem, "previousSibling", until );
9564 },
9565 siblings: function( elem ) {
9566 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
9567 },
9568 children: function( elem ) {
9569 return jQuery.sibling( elem.firstChild );
9570 },
9571 contents: function( elem ) {
9572 return elem.contentDocument || jQuery.merge( [], elem.childNodes );
9573 }
9574 }, function( name, fn ) {
9575 jQuery.fn[ name ] = function( until, selector ) {
9576 var matched = jQuery.map( this, fn, until );
9577
9578 if ( name.slice( -5 ) !== "Until" ) {
9579 selector = until;
9580 }
9581
9582 if ( selector && typeof selector === "string" ) {
9583 matched = jQuery.filter( selector, matched );
9584 }
9585
9586 if ( this.length > 1 ) {
9587 // Remove duplicates
9588 if ( !guaranteedUnique[ name ] ) {
9589 jQuery.unique( matched );
9590 }
9591
9592 // Reverse order for parents* and prev-derivatives
9593 if ( rparentsprev.test( name ) ) {
9594 matched.reverse();
9595 }
9596 }
9597
9598 return this.pushStack( matched );
9599 };
9600 });
9601 var rnotwhite = (/\S+/g);
9602
9603
9604
9605 // String to Object options format cache
9606 var optionsCache = {};
9607
9608 // Convert String-formatted options into Object-formatted ones and store in cache
9609 function createOptions( options ) {
9610 var object = optionsCache[ options ] = {};
9611 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
9612 object[ flag ] = true;
9613 });
9614 return object;
9615 }
9616
9617 /*
9618 * Create a callback list using the following parameters:
9619 *
9620 * options: an optional list of space-separated options that will change how
9621 * the callback list behaves or a more traditional option object
9622 *
9623 * By default a callback list will act like an event callback list and can be
9624 * "fired" multiple times.
9625 *
9626 * Possible options:
9627 *
9628 * once: will ensure the callback list can only be fired once (like a Deferred)
9629 *
9630 * memory: will keep track of previous values and will call any callback added
9631 * after the list has been fired right away with the latest "memorized"
9632 * values (like a Deferred)
9633 *
9634 * unique: will ensure a callback can only be added once (no duplicate in the list)
9635 *
9636 * stopOnFalse: interrupt callings when a callback returns false
9637 *
9638 */
9639 jQuery.Callbacks = function( options ) {
9640
9641 // Convert options from String-formatted to Object-formatted if needed
9642 // (we check in cache first)
9643 options = typeof options === "string" ?
9644 ( optionsCache[ options ] || createOptions( options ) ) :
9645 jQuery.extend( {}, options );
9646
9647 var // Last fire value (for non-forgettable lists)
9648 memory,
9649 // Flag to know if list was already fired
9650 fired,
9651 // Flag to know if list is currently firing
9652 firing,
9653 // First callback to fire (used internally by add and fireWith)
9654 firingStart,
9655 // End of the loop when firing
9656 firingLength,
9657 // Index of currently firing callback (modified by remove if needed)
9658 firingIndex,
9659 // Actual callback list
9660 list = [],
9661 // Stack of fire calls for repeatable lists
9662 stack = !options.once && [],
9663 // Fire callbacks
9664 fire = function( data ) {
9665 memory = options.memory && data;
9666 fired = true;
9667 firingIndex = firingStart || 0;
9668 firingStart = 0;
9669 firingLength = list.length;
9670 firing = true;
9671 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
9672 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
9673 memory = false; // To prevent further calls using add
9674 break;
9675 }
9676 }
9677 firing = false;
9678 if ( list ) {
9679 if ( stack ) {
9680 if ( stack.length ) {
9681 fire( stack.shift() );
9682 }
9683 } else if ( memory ) {
9684 list = [];
9685 } else {
9686 self.disable();
9687 }
9688 }
9689 },
9690 // Actual Callbacks object
9691 self = {
9692 // Add a callback or a collection of callbacks to the list
9693 add: function() {
9694 if ( list ) {
9695 // First, we save the current length
9696 var start = list.length;
9697 (function add( args ) {
9698 jQuery.each( args, function( _, arg ) {
9699 var type = jQuery.type( arg );
9700 if ( type === "function" ) {
9701 if ( !options.unique || !self.has( arg ) ) {
9702 list.push( arg );
9703 }
9704 } else if ( arg && arg.length && type !== "string" ) {
9705 // Inspect recursively
9706 add( arg );
9707 }
9708 });
9709 })( arguments );
9710 // Do we need to add the callbacks to the
9711 // current firing batch?
9712 if ( firing ) {
9713 firingLength = list.length;
9714 // With memory, if we're not firing then
9715 // we should call right away
9716 } else if ( memory ) {
9717 firingStart = start;
9718 fire( memory );
9719 }
9720 }
9721 return this;
9722 },
9723 // Remove a callback from the list
9724 remove: function() {
9725 if ( list ) {
9726 jQuery.each( arguments, function( _, arg ) {
9727 var index;
9728 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
9729 list.splice( index, 1 );
9730 // Handle firing indexes
9731 if ( firing ) {
9732 if ( index <= firingLength ) {
9733 firingLength--;
9734 }
9735 if ( index <= firingIndex ) {
9736 firingIndex--;
9737 }
9738 }
9739 }
9740 });
9741 }
9742 return this;
9743 },
9744 // Check if a given callback is in the list.
9745 // If no argument is given, return whether or not list has callbacks attached.
9746 has: function( fn ) {
9747 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
9748 },
9749 // Remove all callbacks from the list
9750 empty: function() {
9751 list = [];
9752 firingLength = 0;
9753 return this;
9754 },
9755 // Have the list do nothing anymore
9756 disable: function() {
9757 list = stack = memory = undefined;
9758 return this;
9759 },
9760 // Is it disabled?
9761 disabled: function() {
9762 return !list;
9763 },
9764 // Lock the list in its current state
9765 lock: function() {
9766 stack = undefined;
9767 if ( !memory ) {
9768 self.disable();
9769 }
9770 return this;
9771 },
9772 // Is it locked?
9773 locked: function() {
9774 return !stack;
9775 },
9776 // Call all callbacks with the given context and arguments
9777 fireWith: function( context, args ) {
9778 if ( list && ( !fired || stack ) ) {
9779 args = args || [];
9780 args = [ context, args.slice ? args.slice() : args ];
9781 if ( firing ) {
9782 stack.push( args );
9783 } else {
9784 fire( args );
9785 }
9786 }
9787 return this;
9788 },
9789 // Call all the callbacks with the given arguments
9790 fire: function() {
9791 self.fireWith( this, arguments );
9792 return this;
9793 },
9794 // To know if the callbacks have already been called at least once
9795 fired: function() {
9796 return !!fired;
9797 }
9798 };
9799
9800 return self;
9801 };
9802
9803
9804 jQuery.extend({
9805
9806 Deferred: function( func ) {
9807 var tuples = [
9808 // action, add listener, listener list, final state
9809 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
9810 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
9811 [ "notify", "progress", jQuery.Callbacks("memory") ]
9812 ],
9813 state = "pending",
9814 promise = {
9815 state: function() {
9816 return state;
9817 },
9818 always: function() {
9819 deferred.done( arguments ).fail( arguments );
9820 return this;
9821 },
9822 then: function( /* fnDone, fnFail, fnProgress */ ) {
9823 var fns = arguments;
9824 return jQuery.Deferred(function( newDefer ) {
9825 jQuery.each( tuples, function( i, tuple ) {
9826 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
9827 // deferred[ done | fail | progress ] for forwarding actions to newDefer
9828 deferred[ tuple[1] ](function() {
9829 var returned = fn && fn.apply( this, arguments );
9830 if ( returned && jQuery.isFunction( returned.promise ) ) {
9831 returned.promise()
9832 .done( newDefer.resolve )
9833 .fail( newDefer.reject )
9834 .progress( newDefer.notify );
9835 } else {
9836 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
9837 }
9838 });
9839 });
9840 fns = null;
9841 }).promise();
9842 },
9843 // Get a promise for this deferred
9844 // If obj is provided, the promise aspect is added to the object
9845 promise: function( obj ) {
9846 return obj != null ? jQuery.extend( obj, promise ) : promise;
9847 }
9848 },
9849 deferred = {};
9850
9851 // Keep pipe for back-compat
9852 promise.pipe = promise.then;
9853
9854 // Add list-specific methods
9855 jQuery.each( tuples, function( i, tuple ) {
9856 var list = tuple[ 2 ],
9857 stateString = tuple[ 3 ];
9858
9859 // promise[ done | fail | progress ] = list.add
9860 promise[ tuple[1] ] = list.add;
9861
9862 // Handle state
9863 if ( stateString ) {
9864 list.add(function() {
9865 // state = [ resolved | rejected ]
9866 state = stateString;
9867
9868 // [ reject_list | resolve_list ].disable; progress_list.lock
9869 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
9870 }
9871
9872 // deferred[ resolve | reject | notify ]
9873 deferred[ tuple[0] ] = function() {
9874 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
9875 return this;
9876 };
9877 deferred[ tuple[0] + "With" ] = list.fireWith;
9878 });
9879
9880 // Make the deferred a promise
9881 promise.promise( deferred );
9882
9883 // Call given func if any
9884 if ( func ) {
9885 func.call( deferred, deferred );
9886 }
9887
9888 // All done!
9889 return deferred;
9890 },
9891
9892 // Deferred helper
9893 when: function( subordinate /* , ..., subordinateN */ ) {
9894 var i = 0,
9895 resolveValues = slice.call( arguments ),
9896 length = resolveValues.length,
9897
9898 // the count of uncompleted subordinates
9899 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
9900
9901 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
9902 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
9903
9904 // Update function for both resolve and progress values
9905 updateFunc = function( i, contexts, values ) {
9906 return function( value ) {
9907 contexts[ i ] = this;
9908 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
9909 if ( values === progressValues ) {
9910 deferred.notifyWith( contexts, values );
9911 } else if ( !( --remaining ) ) {
9912 deferred.resolveWith( contexts, values );
9913 }
9914 };
9915 },
9916
9917 progressValues, progressContexts, resolveContexts;
9918
9919 // add listeners to Deferred subordinates; treat others as resolved
9920 if ( length > 1 ) {
9921 progressValues = new Array( length );
9922 progressContexts = new Array( length );
9923 resolveContexts = new Array( length );
9924 for ( ; i < length; i++ ) {
9925 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
9926 resolveValues[ i ].promise()
9927 .done( updateFunc( i, resolveContexts, resolveValues ) )
9928 .fail( deferred.reject )
9929 .progress( updateFunc( i, progressContexts, progressValues ) );
9930 } else {
9931 --remaining;
9932 }
9933 }
9934 }
9935
9936 // if we're not waiting on anything, resolve the master
9937 if ( !remaining ) {
9938 deferred.resolveWith( resolveContexts, resolveValues );
9939 }
9940
9941 return deferred.promise();
9942 }
9943 });
9944
9945
9946 // The deferred used on DOM ready
9947 var readyList;
9948
9949 jQuery.fn.ready = function( fn ) {
9950 // Add the callback
9951 jQuery.ready.promise().done( fn );
9952
9953 return this;
9954 };
9955
9956 jQuery.extend({
9957 // Is the DOM ready to be used? Set to true once it occurs.
9958 isReady: false,
9959
9960 // A counter to track how many items to wait for before
9961 // the ready event fires. See #6781
9962 readyWait: 1,
9963
9964 // Hold (or release) the ready event
9965 holdReady: function( hold ) {
9966 if ( hold ) {
9967 jQuery.readyWait++;
9968 } else {
9969 jQuery.ready( true );
9970 }
9971 },
9972
9973 // Handle when the DOM is ready
9974 ready: function( wait ) {
9975
9976 // Abort if there are pending holds or we're already ready
9977 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
9978 return;
9979 }
9980
9981 // Remember that the DOM is ready
9982 jQuery.isReady = true;
9983
9984 // If a normal DOM Ready event fired, decrement, and wait if need be
9985 if ( wait !== true && --jQuery.readyWait > 0 ) {
9986 return;
9987 }
9988
9989 // If there are functions bound, to execute
9990 readyList.resolveWith( document, [ jQuery ] );
9991
9992 // Trigger any bound ready events
9993 if ( jQuery.fn.triggerHandler ) {
9994 jQuery( document ).triggerHandler( "ready" );
9995 jQuery( document ).off( "ready" );
9996 }
9997 }
9998 });
9999
10000 /**
10001 * The ready event handler and self cleanup method
10002 */
10003 function completed() {
10004 document.removeEventListener( "DOMContentLoaded", completed, false );
10005 window.removeEventListener( "load", completed, false );
10006 jQuery.ready();
10007 }
10008
10009 jQuery.ready.promise = function( obj ) {
10010 if ( !readyList ) {
10011
10012 readyList = jQuery.Deferred();
10013
10014 // Catch cases where $(document).ready() is called after the browser event has already occurred.
10015 // we once tried to use readyState "interactive" here, but it caused issues like the one
10016 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
10017 if ( document.readyState === "complete" ) {
10018 // Handle it asynchronously to allow scripts the opportunity to delay ready
10019 setTimeout( jQuery.ready );
10020
10021 } else {
10022
10023 // Use the handy event callback
10024 document.addEventListener( "DOMContentLoaded", completed, false );
10025
10026 // A fallback to window.onload, that will always work
10027 window.addEventListener( "load", completed, false );
10028 }
10029 }
10030 return readyList.promise( obj );
10031 };
10032
10033 // Kick off the DOM ready check even if the user does not
10034 jQuery.ready.promise();
10035
10036
10037
10038
10039 // Multifunctional method to get and set values of a collection
10040 // The value/s can optionally be executed if it's a function
10041 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
10042 var i = 0,
10043 len = elems.length,
10044 bulk = key == null;
10045
10046 // Sets many values
10047 if ( jQuery.type( key ) === "object" ) {
10048 chainable = true;
10049 for ( i in key ) {
10050 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
10051 }
10052
10053 // Sets one value
10054 } else if ( value !== undefined ) {
10055 chainable = true;
10056
10057 if ( !jQuery.isFunction( value ) ) {
10058 raw = true;
10059 }
10060
10061 if ( bulk ) {
10062 // Bulk operations run against the entire set
10063 if ( raw ) {
10064 fn.call( elems, value );
10065 fn = null;
10066
10067 // ...except when executing function values
10068 } else {
10069 bulk = fn;
10070 fn = function( elem, key, value ) {
10071 return bulk.call( jQuery( elem ), value );
10072 };
10073 }
10074 }
10075
10076 if ( fn ) {
10077 for ( ; i < len; i++ ) {
10078 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
10079 }
10080 }
10081 }
10082
10083 return chainable ?
10084 elems :
10085
10086 // Gets
10087 bulk ?
10088 fn.call( elems ) :
10089 len ? fn( elems[0], key ) : emptyGet;
10090 };
10091
10092
10093 /**
10094 * Determines whether an object can have data
10095 */
10096 jQuery.acceptData = function( owner ) {
10097 // Accepts only:
10098 // - Node
10099 // - Node.ELEMENT_NODE
10100 // - Node.DOCUMENT_NODE
10101 // - Object
10102 // - Any
10103 /* jshint -W018 */
10104 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
10105 };
10106
10107
10108 function Data() {
10109 // Support: Android < 4,
10110 // Old WebKit does not have Object.preventExtensions/freeze method,
10111 // return new empty object instead with no [[set]] accessor
10112 Object.defineProperty( this.cache = {}, 0, {
10113 get: function() {
10114 return {};
10115 }
10116 });
10117
10118 this.expando = jQuery.expando + Math.random();
10119 }
10120
10121 Data.uid = 1;
10122 Data.accepts = jQuery.acceptData;
10123
10124 Data.prototype = {
10125 key: function( owner ) {
10126 // We can accept data for non-element nodes in modern browsers,
10127 // but we should not, see #8335.
10128 // Always return the key for a frozen object.
10129 if ( !Data.accepts( owner ) ) {
10130 return 0;
10131 }
10132
10133 var descriptor = {},
10134 // Check if the owner object already has a cache key
10135 unlock = owner[ this.expando ];
10136
10137 // If not, create one
10138 if ( !unlock ) {
10139 unlock = Data.uid++;
10140
10141 // Secure it in a non-enumerable, non-writable property
10142 try {
10143 descriptor[ this.expando ] = { value: unlock };
10144 Object.defineProperties( owner, descriptor );
10145
10146 // Support: Android < 4
10147 // Fallback to a less secure definition
10148 } catch ( e ) {
10149 descriptor[ this.expando ] = unlock;
10150 jQuery.extend( owner, descriptor );
10151 }
10152 }
10153
10154 // Ensure the cache object
10155 if ( !this.cache[ unlock ] ) {
10156 this.cache[ unlock ] = {};
10157 }
10158
10159 return unlock;
10160 },
10161 set: function( owner, data, value ) {
10162 var prop,
10163 // There may be an unlock assigned to this node,
10164 // if there is no entry for this "owner", create one inline
10165 // and set the unlock as though an owner entry had always existed
10166 unlock = this.key( owner ),
10167 cache = this.cache[ unlock ];
10168
10169 // Handle: [ owner, key, value ] args
10170 if ( typeof data === "string" ) {
10171 cache[ data ] = value;
10172
10173 // Handle: [ owner, { properties } ] args
10174 } else {
10175 // Fresh assignments by object are shallow copied
10176 if ( jQuery.isEmptyObject( cache ) ) {
10177 jQuery.extend( this.cache[ unlock ], data );
10178 // Otherwise, copy the properties one-by-one to the cache object
10179 } else {
10180 for ( prop in data ) {
10181 cache[ prop ] = data[ prop ];
10182 }
10183 }
10184 }
10185 return cache;
10186 },
10187 get: function( owner, key ) {
10188 // Either a valid cache is found, or will be created.
10189 // New caches will be created and the unlock returned,
10190 // allowing direct access to the newly created
10191 // empty data object. A valid owner object must be provided.
10192 var cache = this.cache[ this.key( owner ) ];
10193
10194 return key === undefined ?
10195 cache : cache[ key ];
10196 },
10197 access: function( owner, key, value ) {
10198 var stored;
10199 // In cases where either:
10200 //
10201 // 1. No key was specified
10202 // 2. A string key was specified, but no value provided
10203 //
10204 // Take the "read" path and allow the get method to determine
10205 // which value to return, respectively either:
10206 //
10207 // 1. The entire cache object
10208 // 2. The data stored at the key
10209 //
10210 if ( key === undefined ||
10211 ((key && typeof key === "string") && value === undefined) ) {
10212
10213 stored = this.get( owner, key );
10214
10215 return stored !== undefined ?
10216 stored : this.get( owner, jQuery.camelCase(key) );
10217 }
10218
10219 // [*]When the key is not a string, or both a key and value
10220 // are specified, set or extend (existing objects) with either:
10221 //
10222 // 1. An object of properties
10223 // 2. A key and value
10224 //
10225 this.set( owner, key, value );
10226
10227 // Since the "set" path can have two possible entry points
10228 // return the expected data based on which path was taken[*]
10229 return value !== undefined ? value : key;
10230 },
10231 remove: function( owner, key ) {
10232 var i, name, camel,
10233 unlock = this.key( owner ),
10234 cache = this.cache[ unlock ];
10235
10236 if ( key === undefined ) {
10237 this.cache[ unlock ] = {};
10238
10239 } else {
10240 // Support array or space separated string of keys
10241 if ( jQuery.isArray( key ) ) {
10242 // If "name" is an array of keys...
10243 // When data is initially created, via ("key", "val") signature,
10244 // keys will be converted to camelCase.
10245 // Since there is no way to tell _how_ a key was added, remove
10246 // both plain key and camelCase key. #12786
10247 // This will only penalize the array argument path.
10248 name = key.concat( key.map( jQuery.camelCase ) );
10249 } else {
10250 camel = jQuery.camelCase( key );
10251 // Try the string as a key before any manipulation
10252 if ( key in cache ) {
10253 name = [ key, camel ];
10254 } else {
10255 // If a key with the spaces exists, use it.
10256 // Otherwise, create an array by matching non-whitespace
10257 name = camel;
10258 name = name in cache ?
10259 [ name ] : ( name.match( rnotwhite ) || [] );
10260 }
10261 }
10262
10263 i = name.length;
10264 while ( i-- ) {
10265 delete cache[ name[ i ] ];
10266 }
10267 }
10268 },
10269 hasData: function( owner ) {
10270 return !jQuery.isEmptyObject(
10271 this.cache[ owner[ this.expando ] ] || {}
10272 );
10273 },
10274 discard: function( owner ) {
10275 if ( owner[ this.expando ] ) {
10276 delete this.cache[ owner[ this.expando ] ];
10277 }
10278 }
10279 };
10280 var data_priv = new Data();
10281
10282 var data_user = new Data();
10283
10284
10285
10286 /*
10287 Implementation Summary
10288
10289 1. Enforce API surface and semantic compatibility with 1.9.x branch
10290 2. Improve the module's maintainability by reducing the storage
10291 paths to a single mechanism.
10292 3. Use the same single mechanism to support "private" and "user" data.
10293 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
10294 5. Avoid exposing implementation details on user objects (eg. expando properties)
10295 6. Provide a clear path for implementation upgrade to WeakMap in 2014
10296 */
10297 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
10298 rmultiDash = /([A-Z])/g;
10299
10300 function dataAttr( elem, key, data ) {
10301 var name;
10302
10303 // If nothing was found internally, try to fetch any
10304 // data from the HTML5 data-* attribute
10305 if ( data === undefined && elem.nodeType === 1 ) {
10306 name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
10307 data = elem.getAttribute( name );
10308
10309 if ( typeof data === "string" ) {
10310 try {
10311 data = data === "true" ? true :
10312 data === "false" ? false :
10313 data === "null" ? null :
10314 // Only convert to a number if it doesn't change the string
10315 +data + "" === data ? +data :
10316 rbrace.test( data ) ? jQuery.parseJSON( data ) :
10317 data;
10318 } catch( e ) {}
10319
10320 // Make sure we set the data so it isn't changed later
10321 data_user.set( elem, key, data );
10322 } else {
10323 data = undefined;
10324 }
10325 }
10326 return data;
10327 }
10328
10329 jQuery.extend({
10330 hasData: function( elem ) {
10331 return data_user.hasData( elem ) || data_priv.hasData( elem );
10332 },
10333
10334 data: function( elem, name, data ) {
10335 return data_user.access( elem, name, data );
10336 },
10337
10338 removeData: function( elem, name ) {
10339 data_user.remove( elem, name );
10340 },
10341
10342 // TODO: Now that all calls to _data and _removeData have been replaced
10343 // with direct calls to data_priv methods, these can be deprecated.
10344 _data: function( elem, name, data ) {
10345 return data_priv.access( elem, name, data );
10346 },
10347
10348 _removeData: function( elem, name ) {
10349 data_priv.remove( elem, name );
10350 }
10351 });
10352
10353 jQuery.fn.extend({
10354 data: function( key, value ) {
10355 var i, name, data,
10356 elem = this[ 0 ],
10357 attrs = elem && elem.attributes;
10358
10359 // Gets all values
10360 if ( key === undefined ) {
10361 if ( this.length ) {
10362 data = data_user.get( elem );
10363
10364 if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
10365 i = attrs.length;
10366 while ( i-- ) {
10367
10368 // Support: IE11+
10369 // The attrs elements can be null (#14894)
10370 if ( attrs[ i ] ) {
10371 name = attrs[ i ].name;
10372 if ( name.indexOf( "data-" ) === 0 ) {
10373 name = jQuery.camelCase( name.slice(5) );
10374 dataAttr( elem, name, data[ name ] );
10375 }
10376 }
10377 }
10378 data_priv.set( elem, "hasDataAttrs", true );
10379 }
10380 }
10381
10382 return data;
10383 }
10384
10385 // Sets multiple values
10386 if ( typeof key === "object" ) {
10387 return this.each(function() {
10388 data_user.set( this, key );
10389 });
10390 }
10391
10392 return access( this, function( value ) {
10393 var data,
10394 camelKey = jQuery.camelCase( key );
10395
10396 // The calling jQuery object (element matches) is not empty
10397 // (and therefore has an element appears at this[ 0 ]) and the
10398 // `value` parameter was not undefined. An empty jQuery object
10399 // will result in `undefined` for elem = this[ 0 ] which will
10400 // throw an exception if an attempt to read a data cache is made.
10401 if ( elem && value === undefined ) {
10402 // Attempt to get data from the cache
10403 // with the key as-is
10404 data = data_user.get( elem, key );
10405 if ( data !== undefined ) {
10406 return data;
10407 }
10408
10409 // Attempt to get data from the cache
10410 // with the key camelized
10411 data = data_user.get( elem, camelKey );
10412 if ( data !== undefined ) {
10413 return data;
10414 }
10415
10416 // Attempt to "discover" the data in
10417 // HTML5 custom data-* attrs
10418 data = dataAttr( elem, camelKey, undefined );
10419 if ( data !== undefined ) {
10420 return data;
10421 }
10422
10423 // We tried really hard, but the data doesn't exist.
10424 return;
10425 }
10426
10427 // Set the data...
10428 this.each(function() {
10429 // First, attempt to store a copy or reference of any
10430 // data that might've been store with a camelCased key.
10431 var data = data_user.get( this, camelKey );
10432
10433 // For HTML5 data-* attribute interop, we have to
10434 // store property names with dashes in a camelCase form.
10435 // This might not apply to all properties...*
10436 data_user.set( this, camelKey, value );
10437
10438 // *... In the case of properties that might _actually_
10439 // have dashes, we need to also store a copy of that
10440 // unchanged property.
10441 if ( key.indexOf("-") !== -1 && data !== undefined ) {
10442 data_user.set( this, key, value );
10443 }
10444 });
10445 }, null, value, arguments.length > 1, null, true );
10446 },
10447
10448 removeData: function( key ) {
10449 return this.each(function() {
10450 data_user.remove( this, key );
10451 });
10452 }
10453 });
10454
10455
10456 jQuery.extend({
10457 queue: function( elem, type, data ) {
10458 var queue;
10459
10460 if ( elem ) {
10461 type = ( type || "fx" ) + "queue";
10462 queue = data_priv.get( elem, type );
10463
10464 // Speed up dequeue by getting out quickly if this is just a lookup
10465 if ( data ) {
10466 if ( !queue || jQuery.isArray( data ) ) {
10467 queue = data_priv.access( elem, type, jQuery.makeArray(data) );
10468 } else {
10469 queue.push( data );
10470 }
10471 }
10472 return queue || [];
10473 }
10474 },
10475
10476 dequeue: function( elem, type ) {
10477 type = type || "fx";
10478
10479 var queue = jQuery.queue( elem, type ),
10480 startLength = queue.length,
10481 fn = queue.shift(),
10482 hooks = jQuery._queueHooks( elem, type ),
10483 next = function() {
10484 jQuery.dequeue( elem, type );
10485 };
10486
10487 // If the fx queue is dequeued, always remove the progress sentinel
10488 if ( fn === "inprogress" ) {
10489 fn = queue.shift();
10490 startLength--;
10491 }
10492
10493 if ( fn ) {
10494
10495 // Add a progress sentinel to prevent the fx queue from being
10496 // automatically dequeued
10497 if ( type === "fx" ) {
10498 queue.unshift( "inprogress" );
10499 }
10500
10501 // clear up the last queue stop function
10502 delete hooks.stop;
10503 fn.call( elem, next, hooks );
10504 }
10505
10506 if ( !startLength && hooks ) {
10507 hooks.empty.fire();
10508 }
10509 },
10510
10511 // not intended for public consumption - generates a queueHooks object, or returns the current one
10512 _queueHooks: function( elem, type ) {
10513 var key = type + "queueHooks";
10514 return data_priv.get( elem, key ) || data_priv.access( elem, key, {
10515 empty: jQuery.Callbacks("once memory").add(function() {
10516 data_priv.remove( elem, [ type + "queue", key ] );
10517 })
10518 });
10519 }
10520 });
10521
10522 jQuery.fn.extend({
10523 queue: function( type, data ) {
10524 var setter = 2;
10525
10526 if ( typeof type !== "string" ) {
10527 data = type;
10528 type = "fx";
10529 setter--;
10530 }
10531
10532 if ( arguments.length < setter ) {
10533 return jQuery.queue( this[0], type );
10534 }
10535
10536 return data === undefined ?
10537 this :
10538 this.each(function() {
10539 var queue = jQuery.queue( this, type, data );
10540
10541 // ensure a hooks for this queue
10542 jQuery._queueHooks( this, type );
10543
10544 if ( type === "fx" && queue[0] !== "inprogress" ) {
10545 jQuery.dequeue( this, type );
10546 }
10547 });
10548 },
10549 dequeue: function( type ) {
10550 return this.each(function() {
10551 jQuery.dequeue( this, type );
10552 });
10553 },
10554 clearQueue: function( type ) {
10555 return this.queue( type || "fx", [] );
10556 },
10557 // Get a promise resolved when queues of a certain type
10558 // are emptied (fx is the type by default)
10559 promise: function( type, obj ) {
10560 var tmp,
10561 count = 1,
10562 defer = jQuery.Deferred(),
10563 elements = this,
10564 i = this.length,
10565 resolve = function() {
10566 if ( !( --count ) ) {
10567 defer.resolveWith( elements, [ elements ] );
10568 }
10569 };
10570
10571 if ( typeof type !== "string" ) {
10572 obj = type;
10573 type = undefined;
10574 }
10575 type = type || "fx";
10576
10577 while ( i-- ) {
10578 tmp = data_priv.get( elements[ i ], type + "queueHooks" );
10579 if ( tmp && tmp.empty ) {
10580 count++;
10581 tmp.empty.add( resolve );
10582 }
10583 }
10584 resolve();
10585 return defer.promise( obj );
10586 }
10587 });
10588 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
10589
10590 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
10591
10592 var isHidden = function( elem, el ) {
10593 // isHidden might be called from jQuery#filter function;
10594 // in that case, element will be second argument
10595 elem = el || elem;
10596 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
10597 };
10598
10599 var rcheckableType = (/^(?:checkbox|radio)$/i);
10600
10601
10602
10603 (function() {
10604 var fragment = document.createDocumentFragment(),
10605 div = fragment.appendChild( document.createElement( "div" ) ),
10606 input = document.createElement( "input" );
10607
10608 // #11217 - WebKit loses check when the name is after the checked attribute
10609 // Support: Windows Web Apps (WWA)
10610 // `name` and `type` need .setAttribute for WWA
10611 input.setAttribute( "type", "radio" );
10612 input.setAttribute( "checked", "checked" );
10613 input.setAttribute( "name", "t" );
10614
10615 div.appendChild( input );
10616
10617 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
10618 // old WebKit doesn't clone checked state correctly in fragments
10619 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
10620
10621 // Make sure textarea (and checkbox) defaultValue is properly cloned
10622 // Support: IE9-IE11+
10623 div.innerHTML = "<textarea>x</textarea>";
10624 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
10625 })();
10626 var strundefined = typeof undefined;
10627
10628
10629
10630 support.focusinBubbles = "onfocusin" in window;
10631
10632
10633 var
10634 rkeyEvent = /^key/,
10635 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
10636 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
10637 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
10638
10639 function returnTrue() {
10640 return true;
10641 }
10642
10643 function returnFalse() {
10644 return false;
10645 }
10646
10647 function safeActiveElement() {
10648 try {
10649 return document.activeElement;
10650 } catch ( err ) { }
10651 }
10652
10653 /*
10654 * Helper functions for managing events -- not part of the public interface.
10655 * Props to Dean Edwards' addEvent library for many of the ideas.
10656 */
10657 jQuery.event = {
10658
10659 global: {},
10660
10661 add: function( elem, types, handler, data, selector ) {
10662
10663 var handleObjIn, eventHandle, tmp,
10664 events, t, handleObj,
10665 special, handlers, type, namespaces, origType,
10666 elemData = data_priv.get( elem );
10667
10668 // Don't attach events to noData or text/comment nodes (but allow plain objects)
10669 if ( !elemData ) {
10670 return;
10671 }
10672
10673 // Caller can pass in an object of custom data in lieu of the handler
10674 if ( handler.handler ) {
10675 handleObjIn = handler;
10676 handler = handleObjIn.handler;
10677 selector = handleObjIn.selector;
10678 }
10679
10680 // Make sure that the handler has a unique ID, used to find/remove it later
10681 if ( !handler.guid ) {
10682 handler.guid = jQuery.guid++;
10683 }
10684
10685 // Init the element's event structure and main handler, if this is the first
10686 if ( !(events = elemData.events) ) {
10687 events = elemData.events = {};
10688 }
10689 if ( !(eventHandle = elemData.handle) ) {
10690 eventHandle = elemData.handle = function( e ) {
10691 // Discard the second event of a jQuery.event.trigger() and
10692 // when an event is called after a page has unloaded
10693 return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
10694 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
10695 };
10696 }
10697
10698 // Handle multiple events separated by a space
10699 types = ( types || "" ).match( rnotwhite ) || [ "" ];
10700 t = types.length;
10701 while ( t-- ) {
10702 tmp = rtypenamespace.exec( types[t] ) || [];
10703 type = origType = tmp[1];
10704 namespaces = ( tmp[2] || "" ).split( "." ).sort();
10705
10706 // There *must* be a type, no attaching namespace-only handlers
10707 if ( !type ) {
10708 continue;
10709 }
10710
10711 // If event changes its type, use the special event handlers for the changed type
10712 special = jQuery.event.special[ type ] || {};
10713
10714 // If selector defined, determine special event api type, otherwise given type
10715 type = ( selector ? special.delegateType : special.bindType ) || type;
10716
10717 // Update special based on newly reset type
10718 special = jQuery.event.special[ type ] || {};
10719
10720 // handleObj is passed to all event handlers
10721 handleObj = jQuery.extend({
10722 type: type,
10723 origType: origType,
10724 data: data,
10725 handler: handler,
10726 guid: handler.guid,
10727 selector: selector,
10728 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
10729 namespace: namespaces.join(".")
10730 }, handleObjIn );
10731
10732 // Init the event handler queue if we're the first
10733 if ( !(handlers = events[ type ]) ) {
10734 handlers = events[ type ] = [];
10735 handlers.delegateCount = 0;
10736
10737 // Only use addEventListener if the special events handler returns false
10738 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
10739 if ( elem.addEventListener ) {
10740 elem.addEventListener( type, eventHandle, false );
10741 }
10742 }
10743 }
10744
10745 if ( special.add ) {
10746 special.add.call( elem, handleObj );
10747
10748 if ( !handleObj.handler.guid ) {
10749 handleObj.handler.guid = handler.guid;
10750 }
10751 }
10752
10753 // Add to the element's handler list, delegates in front
10754 if ( selector ) {
10755 handlers.splice( handlers.delegateCount++, 0, handleObj );
10756 } else {
10757 handlers.push( handleObj );
10758 }
10759
10760 // Keep track of which events have ever been used, for event optimization
10761 jQuery.event.global[ type ] = true;
10762 }
10763
10764 },
10765
10766 // Detach an event or set of events from an element
10767 remove: function( elem, types, handler, selector, mappedTypes ) {
10768
10769 var j, origCount, tmp,
10770 events, t, handleObj,
10771 special, handlers, type, namespaces, origType,
10772 elemData = data_priv.hasData( elem ) && data_priv.get( elem );
10773
10774 if ( !elemData || !(events = elemData.events) ) {
10775 return;
10776 }
10777
10778 // Once for each type.namespace in types; type may be omitted
10779 types = ( types || "" ).match( rnotwhite ) || [ "" ];
10780 t = types.length;
10781 while ( t-- ) {
10782 tmp = rtypenamespace.exec( types[t] ) || [];
10783 type = origType = tmp[1];
10784 namespaces = ( tmp[2] || "" ).split( "." ).sort();
10785
10786 // Unbind all events (on this namespace, if provided) for the element
10787 if ( !type ) {
10788 for ( type in events ) {
10789 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
10790 }
10791 continue;
10792 }
10793
10794 special = jQuery.event.special[ type ] || {};
10795 type = ( selector ? special.delegateType : special.bindType ) || type;
10796 handlers = events[ type ] || [];
10797 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
10798
10799 // Remove matching events
10800 origCount = j = handlers.length;
10801 while ( j-- ) {
10802 handleObj = handlers[ j ];
10803
10804 if ( ( mappedTypes || origType === handleObj.origType ) &&
10805 ( !handler || handler.guid === handleObj.guid ) &&
10806 ( !tmp || tmp.test( handleObj.namespace ) ) &&
10807 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
10808 handlers.splice( j, 1 );
10809
10810 if ( handleObj.selector ) {
10811 handlers.delegateCount--;
10812 }
10813 if ( special.remove ) {
10814 special.remove.call( elem, handleObj );
10815 }
10816 }
10817 }
10818
10819 // Remove generic event handler if we removed something and no more handlers exist
10820 // (avoids potential for endless recursion during removal of special event handlers)
10821 if ( origCount && !handlers.length ) {
10822 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
10823 jQuery.removeEvent( elem, type, elemData.handle );
10824 }
10825
10826 delete events[ type ];
10827 }
10828 }
10829
10830 // Remove the expando if it's no longer used
10831 if ( jQuery.isEmptyObject( events ) ) {
10832 delete elemData.handle;
10833 data_priv.remove( elem, "events" );
10834 }
10835 },
10836
10837 trigger: function( event, data, elem, onlyHandlers ) {
10838
10839 var i, cur, tmp, bubbleType, ontype, handle, special,
10840 eventPath = [ elem || document ],
10841 type = hasOwn.call( event, "type" ) ? event.type : event,
10842 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
10843
10844 cur = tmp = elem = elem || document;
10845
10846 // Don't do events on text and comment nodes
10847 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
10848 return;
10849 }
10850
10851 // focus/blur morphs to focusin/out; ensure we're not firing them right now
10852 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
10853 return;
10854 }
10855
10856 if ( type.indexOf(".") >= 0 ) {
10857 // Namespaced trigger; create a regexp to match event type in handle()
10858 namespaces = type.split(".");
10859 type = namespaces.shift();
10860 namespaces.sort();
10861 }
10862 ontype = type.indexOf(":") < 0 && "on" + type;
10863
10864 // Caller can pass in a jQuery.Event object, Object, or just an event type string
10865 event = event[ jQuery.expando ] ?
10866 event :
10867 new jQuery.Event( type, typeof event === "object" && event );
10868
10869 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
10870 event.isTrigger = onlyHandlers ? 2 : 3;
10871 event.namespace = namespaces.join(".");
10872 event.namespace_re = event.namespace ?
10873 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
10874 null;
10875
10876 // Clean up the event in case it is being reused
10877 event.result = undefined;
10878 if ( !event.target ) {
10879 event.target = elem;
10880 }
10881
10882 // Clone any incoming data and prepend the event, creating the handler arg list
10883 data = data == null ?
10884 [ event ] :
10885 jQuery.makeArray( data, [ event ] );
10886
10887 // Allow special events to draw outside the lines
10888 special = jQuery.event.special[ type ] || {};
10889 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
10890 return;
10891 }
10892
10893 // Determine event propagation path in advance, per W3C events spec (#9951)
10894 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
10895 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
10896
10897 bubbleType = special.delegateType || type;
10898 if ( !rfocusMorph.test( bubbleType + type ) ) {
10899 cur = cur.parentNode;
10900 }
10901 for ( ; cur; cur = cur.parentNode ) {
10902 eventPath.push( cur );
10903 tmp = cur;
10904 }
10905
10906 // Only add window if we got to document (e.g., not plain obj or detached DOM)
10907 if ( tmp === (elem.ownerDocument || document) ) {
10908 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
10909 }
10910 }
10911
10912 // Fire handlers on the event path
10913 i = 0;
10914 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
10915
10916 event.type = i > 1 ?
10917 bubbleType :
10918 special.bindType || type;
10919
10920 // jQuery handler
10921 handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
10922 if ( handle ) {
10923 handle.apply( cur, data );
10924 }
10925
10926 // Native handler
10927 handle = ontype && cur[ ontype ];
10928 if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
10929 event.result = handle.apply( cur, data );
10930 if ( event.result === false ) {
10931 event.preventDefault();
10932 }
10933 }
10934 }
10935 event.type = type;
10936
10937 // If nobody prevented the default action, do it now
10938 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
10939
10940 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
10941 jQuery.acceptData( elem ) ) {
10942
10943 // Call a native DOM method on the target with the same name name as the event.
10944 // Don't do default actions on window, that's where global variables be (#6170)
10945 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
10946
10947 // Don't re-trigger an onFOO event when we call its FOO() method
10948 tmp = elem[ ontype ];
10949
10950 if ( tmp ) {
10951 elem[ ontype ] = null;
10952 }
10953
10954 // Prevent re-triggering of the same event, since we already bubbled it above
10955 jQuery.event.triggered = type;
10956 elem[ type ]();
10957 jQuery.event.triggered = undefined;
10958
10959 if ( tmp ) {
10960 elem[ ontype ] = tmp;
10961 }
10962 }
10963 }
10964 }
10965
10966 return event.result;
10967 },
10968
10969 dispatch: function( event ) {
10970
10971 // Make a writable jQuery.Event from the native event object
10972 event = jQuery.event.fix( event );
10973
10974 var i, j, ret, matched, handleObj,
10975 handlerQueue = [],
10976 args = slice.call( arguments ),
10977 handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
10978 special = jQuery.event.special[ event.type ] || {};
10979
10980 // Use the fix-ed jQuery.Event rather than the (read-only) native event
10981 args[0] = event;
10982 event.delegateTarget = this;
10983
10984 // Call the preDispatch hook for the mapped type, and let it bail if desired
10985 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
10986 return;
10987 }
10988
10989 // Determine handlers
10990 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
10991
10992 // Run delegates first; they may want to stop propagation beneath us
10993 i = 0;
10994 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
10995 event.currentTarget = matched.elem;
10996
10997 j = 0;
10998 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
10999
11000 // Triggered event must either 1) have no namespace, or
11001 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
11002 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
11003
11004 event.handleObj = handleObj;
11005 event.data = handleObj.data;
11006
11007 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
11008 .apply( matched.elem, args );
11009
11010 if ( ret !== undefined ) {
11011 if ( (event.result = ret) === false ) {
11012 event.preventDefault();
11013 event.stopPropagation();
11014 }
11015 }
11016 }
11017 }
11018 }
11019
11020 // Call the postDispatch hook for the mapped type
11021 if ( special.postDispatch ) {
11022 special.postDispatch.call( this, event );
11023 }
11024
11025 return event.result;
11026 },
11027
11028 handlers: function( event, handlers ) {
11029 var i, matches, sel, handleObj,
11030 handlerQueue = [],
11031 delegateCount = handlers.delegateCount,
11032 cur = event.target;
11033
11034 // Find delegate handlers
11035 // Black-hole SVG <use> instance trees (#13180)
11036 // Avoid non-left-click bubbling in Firefox (#3861)
11037 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
11038
11039 for ( ; cur !== this; cur = cur.parentNode || this ) {
11040
11041 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
11042 if ( cur.disabled !== true || event.type !== "click" ) {
11043 matches = [];
11044 for ( i = 0; i < delegateCount; i++ ) {
11045 handleObj = handlers[ i ];
11046
11047 // Don't conflict with Object.prototype properties (#13203)
11048 sel = handleObj.selector + " ";
11049
11050 if ( matches[ sel ] === undefined ) {
11051 matches[ sel ] = handleObj.needsContext ?
11052 jQuery( sel, this ).index( cur ) >= 0 :
11053 jQuery.find( sel, this, null, [ cur ] ).length;
11054 }
11055 if ( matches[ sel ] ) {
11056 matches.push( handleObj );
11057 }
11058 }
11059 if ( matches.length ) {
11060 handlerQueue.push({ elem: cur, handlers: matches });
11061 }
11062 }
11063 }
11064 }
11065
11066 // Add the remaining (directly-bound) handlers
11067 if ( delegateCount < handlers.length ) {
11068 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
11069 }
11070
11071 return handlerQueue;
11072 },
11073
11074 // Includes some event props shared by KeyEvent and MouseEvent
11075 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
11076
11077 fixHooks: {},
11078
11079 keyHooks: {
11080 props: "char charCode key keyCode".split(" "),
11081 filter: function( event, original ) {
11082
11083 // Add which for key events
11084 if ( event.which == null ) {
11085 event.which = original.charCode != null ? original.charCode : original.keyCode;
11086 }
11087
11088 return event;
11089 }
11090 },
11091
11092 mouseHooks: {
11093 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
11094 filter: function( event, original ) {
11095 var eventDoc, doc, body,
11096 button = original.button;
11097
11098 // Calculate pageX/Y if missing and clientX/Y available
11099 if ( event.pageX == null && original.clientX != null ) {
11100 eventDoc = event.target.ownerDocument || document;
11101 doc = eventDoc.documentElement;
11102 body = eventDoc.body;
11103
11104 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
11105 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
11106 }
11107
11108 // Add which for click: 1 === left; 2 === middle; 3 === right
11109 // Note: button is not normalized, so don't use it
11110 if ( !event.which && button !== undefined ) {
11111 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
11112 }
11113
11114 return event;
11115 }
11116 },
11117
11118 fix: function( event ) {
11119 if ( event[ jQuery.expando ] ) {
11120 return event;
11121 }
11122
11123 // Create a writable copy of the event object and normalize some properties
11124 var i, prop, copy,
11125 type = event.type,
11126 originalEvent = event,
11127 fixHook = this.fixHooks[ type ];
11128
11129 if ( !fixHook ) {
11130 this.fixHooks[ type ] = fixHook =
11131 rmouseEvent.test( type ) ? this.mouseHooks :
11132 rkeyEvent.test( type ) ? this.keyHooks :
11133 {};
11134 }
11135 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
11136
11137 event = new jQuery.Event( originalEvent );
11138
11139 i = copy.length;
11140 while ( i-- ) {
11141 prop = copy[ i ];
11142 event[ prop ] = originalEvent[ prop ];
11143 }
11144
11145 // Support: Cordova 2.5 (WebKit) (#13255)
11146 // All events should have a target; Cordova deviceready doesn't
11147 if ( !event.target ) {
11148 event.target = document;
11149 }
11150
11151 // Support: Safari 6.0+, Chrome < 28
11152 // Target should not be a text node (#504, #13143)
11153 if ( event.target.nodeType === 3 ) {
11154 event.target = event.target.parentNode;
11155 }
11156
11157 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
11158 },
11159
11160 special: {
11161 load: {
11162 // Prevent triggered image.load events from bubbling to window.load
11163 noBubble: true
11164 },
11165 focus: {
11166 // Fire native event if possible so blur/focus sequence is correct
11167 trigger: function() {
11168 if ( this !== safeActiveElement() && this.focus ) {
11169 this.focus();
11170 return false;
11171 }
11172 },
11173 delegateType: "focusin"
11174 },
11175 blur: {
11176 trigger: function() {
11177 if ( this === safeActiveElement() && this.blur ) {
11178 this.blur();
11179 return false;
11180 }
11181 },
11182 delegateType: "focusout"
11183 },
11184 click: {
11185 // For checkbox, fire native event so checked state will be right
11186 trigger: function() {
11187 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
11188 this.click();
11189 return false;
11190 }
11191 },
11192
11193 // For cross-browser consistency, don't fire native .click() on links
11194 _default: function( event ) {
11195 return jQuery.nodeName( event.target, "a" );
11196 }
11197 },
11198
11199 beforeunload: {
11200 postDispatch: function( event ) {
11201
11202 // Support: Firefox 20+
11203 // Firefox doesn't alert if the returnValue field is not set.
11204 if ( event.result !== undefined && event.originalEvent ) {
11205 event.originalEvent.returnValue = event.result;
11206 }
11207 }
11208 }
11209 },
11210
11211 simulate: function( type, elem, event, bubble ) {
11212 // Piggyback on a donor event to simulate a different one.
11213 // Fake originalEvent to avoid donor's stopPropagation, but if the
11214 // simulated event prevents default then we do the same on the donor.
11215 var e = jQuery.extend(
11216 new jQuery.Event(),
11217 event,
11218 {
11219 type: type,
11220 isSimulated: true,
11221 originalEvent: {}
11222 }
11223 );
11224 if ( bubble ) {
11225 jQuery.event.trigger( e, null, elem );
11226 } else {
11227 jQuery.event.dispatch.call( elem, e );
11228 }
11229 if ( e.isDefaultPrevented() ) {
11230 event.preventDefault();
11231 }
11232 }
11233 };
11234
11235 jQuery.removeEvent = function( elem, type, handle ) {
11236 if ( elem.removeEventListener ) {
11237 elem.removeEventListener( type, handle, false );
11238 }
11239 };
11240
11241 jQuery.Event = function( src, props ) {
11242 // Allow instantiation without the 'new' keyword
11243 if ( !(this instanceof jQuery.Event) ) {
11244 return new jQuery.Event( src, props );
11245 }
11246
11247 // Event object
11248 if ( src && src.type ) {
11249 this.originalEvent = src;
11250 this.type = src.type;
11251
11252 // Events bubbling up the document may have been marked as prevented
11253 // by a handler lower down the tree; reflect the correct value.
11254 this.isDefaultPrevented = src.defaultPrevented ||
11255 src.defaultPrevented === undefined &&
11256 // Support: Android < 4.0
11257 src.returnValue === false ?
11258 returnTrue :
11259 returnFalse;
11260
11261 // Event type
11262 } else {
11263 this.type = src;
11264 }
11265
11266 // Put explicitly provided properties onto the event object
11267 if ( props ) {
11268 jQuery.extend( this, props );
11269 }
11270
11271 // Create a timestamp if incoming event doesn't have one
11272 this.timeStamp = src && src.timeStamp || jQuery.now();
11273
11274 // Mark it as fixed
11275 this[ jQuery.expando ] = true;
11276 };
11277
11278 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
11279 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
11280 jQuery.Event.prototype = {
11281 isDefaultPrevented: returnFalse,
11282 isPropagationStopped: returnFalse,
11283 isImmediatePropagationStopped: returnFalse,
11284
11285 preventDefault: function() {
11286 var e = this.originalEvent;
11287
11288 this.isDefaultPrevented = returnTrue;
11289
11290 if ( e && e.preventDefault ) {
11291 e.preventDefault();
11292 }
11293 },
11294 stopPropagation: function() {
11295 var e = this.originalEvent;
11296
11297 this.isPropagationStopped = returnTrue;
11298
11299 if ( e && e.stopPropagation ) {
11300 e.stopPropagation();
11301 }
11302 },
11303 stopImmediatePropagation: function() {
11304 var e = this.originalEvent;
11305
11306 this.isImmediatePropagationStopped = returnTrue;
11307
11308 if ( e && e.stopImmediatePropagation ) {
11309 e.stopImmediatePropagation();
11310 }
11311
11312 this.stopPropagation();
11313 }
11314 };
11315
11316 // Create mouseenter/leave events using mouseover/out and event-time checks
11317 // Support: Chrome 15+
11318 jQuery.each({
11319 mouseenter: "mouseover",
11320 mouseleave: "mouseout",
11321 pointerenter: "pointerover",
11322 pointerleave: "pointerout"
11323 }, function( orig, fix ) {
11324 jQuery.event.special[ orig ] = {
11325 delegateType: fix,
11326 bindType: fix,
11327
11328 handle: function( event ) {
11329 var ret,
11330 target = this,
11331 related = event.relatedTarget,
11332 handleObj = event.handleObj;
11333
11334 // For mousenter/leave call the handler if related is outside the target.
11335 // NB: No relatedTarget if the mouse left/entered the browser window
11336 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
11337 event.type = handleObj.origType;
11338 ret = handleObj.handler.apply( this, arguments );
11339 event.type = fix;
11340 }
11341 return ret;
11342 }
11343 };
11344 });
11345
11346 // Create "bubbling" focus and blur events
11347 // Support: Firefox, Chrome, Safari
11348 if ( !support.focusinBubbles ) {
11349 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
11350
11351 // Attach a single capturing handler on the document while someone wants focusin/focusout
11352 var handler = function( event ) {
11353 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
11354 };
11355
11356 jQuery.event.special[ fix ] = {
11357 setup: function() {
11358 var doc = this.ownerDocument || this,
11359 attaches = data_priv.access( doc, fix );
11360
11361 if ( !attaches ) {
11362 doc.addEventListener( orig, handler, true );
11363 }
11364 data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
11365 },
11366 teardown: function() {
11367 var doc = this.ownerDocument || this,
11368 attaches = data_priv.access( doc, fix ) - 1;
11369
11370 if ( !attaches ) {
11371 doc.removeEventListener( orig, handler, true );
11372 data_priv.remove( doc, fix );
11373
11374 } else {
11375 data_priv.access( doc, fix, attaches );
11376 }
11377 }
11378 };
11379 });
11380 }
11381
11382 jQuery.fn.extend({
11383
11384 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
11385 var origFn, type;
11386
11387 // Types can be a map of types/handlers
11388 if ( typeof types === "object" ) {
11389 // ( types-Object, selector, data )
11390 if ( typeof selector !== "string" ) {
11391 // ( types-Object, data )
11392 data = data || selector;
11393 selector = undefined;
11394 }
11395 for ( type in types ) {
11396 this.on( type, selector, data, types[ type ], one );
11397 }
11398 return this;
11399 }
11400
11401 if ( data == null && fn == null ) {
11402 // ( types, fn )
11403 fn = selector;
11404 data = selector = undefined;
11405 } else if ( fn == null ) {
11406 if ( typeof selector === "string" ) {
11407 // ( types, selector, fn )
11408 fn = data;
11409 data = undefined;
11410 } else {
11411 // ( types, data, fn )
11412 fn = data;
11413 data = selector;
11414 selector = undefined;
11415 }
11416 }
11417 if ( fn === false ) {
11418 fn = returnFalse;
11419 } else if ( !fn ) {
11420 return this;
11421 }
11422
11423 if ( one === 1 ) {
11424 origFn = fn;
11425 fn = function( event ) {
11426 // Can use an empty set, since event contains the info
11427 jQuery().off( event );
11428 return origFn.apply( this, arguments );
11429 };
11430 // Use same guid so caller can remove using origFn
11431 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
11432 }
11433 return this.each( function() {
11434 jQuery.event.add( this, types, fn, data, selector );
11435 });
11436 },
11437 one: function( types, selector, data, fn ) {
11438 return this.on( types, selector, data, fn, 1 );
11439 },
11440 off: function( types, selector, fn ) {
11441 var handleObj, type;
11442 if ( types && types.preventDefault && types.handleObj ) {
11443 // ( event ) dispatched jQuery.Event
11444 handleObj = types.handleObj;
11445 jQuery( types.delegateTarget ).off(
11446 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
11447 handleObj.selector,
11448 handleObj.handler
11449 );
11450 return this;
11451 }
11452 if ( typeof types === "object" ) {
11453 // ( types-object [, selector] )
11454 for ( type in types ) {
11455 this.off( type, selector, types[ type ] );
11456 }
11457 return this;
11458 }
11459 if ( selector === false || typeof selector === "function" ) {
11460 // ( types [, fn] )
11461 fn = selector;
11462 selector = undefined;
11463 }
11464 if ( fn === false ) {
11465 fn = returnFalse;
11466 }
11467 return this.each(function() {
11468 jQuery.event.remove( this, types, fn, selector );
11469 });
11470 },
11471
11472 trigger: function( type, data ) {
11473 return this.each(function() {
11474 jQuery.event.trigger( type, data, this );
11475 });
11476 },
11477 triggerHandler: function( type, data ) {
11478 var elem = this[0];
11479 if ( elem ) {
11480 return jQuery.event.trigger( type, data, elem, true );
11481 }
11482 }
11483 });
11484
11485
11486 var
11487 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
11488 rtagName = /<([\w:]+)/,
11489 rhtml = /<|&#?\w+;/,
11490 rnoInnerhtml = /<(?:script|style|link)/i,
11491 // checked="checked" or checked
11492 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
11493 rscriptType = /^$|\/(?:java|ecma)script/i,
11494 rscriptTypeMasked = /^true\/(.*)/,
11495 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
11496
11497 // We have to close these tags to support XHTML (#13200)
11498 wrapMap = {
11499
11500 // Support: IE 9
11501 option: [ 1, "<select multiple='multiple'>", "</select>" ],
11502
11503 thead: [ 1, "<table>", "</table>" ],
11504 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
11505 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
11506 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
11507
11508 _default: [ 0, "", "" ]
11509 };
11510
11511 // Support: IE 9
11512 wrapMap.optgroup = wrapMap.option;
11513
11514 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
11515 wrapMap.th = wrapMap.td;
11516
11517 // Support: 1.x compatibility
11518 // Manipulating tables requires a tbody
11519 function manipulationTarget( elem, content ) {
11520 return jQuery.nodeName( elem, "table" ) &&
11521 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
11522
11523 elem.getElementsByTagName("tbody")[0] ||
11524 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
11525 elem;
11526 }
11527
11528 // Replace/restore the type attribute of script elements for safe DOM manipulation
11529 function disableScript( elem ) {
11530 elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
11531 return elem;
11532 }
11533 function restoreScript( elem ) {
11534 var match = rscriptTypeMasked.exec( elem.type );
11535
11536 if ( match ) {
11537 elem.type = match[ 1 ];
11538 } else {
11539 elem.removeAttribute("type");
11540 }
11541
11542 return elem;
11543 }
11544
11545 // Mark scripts as having already been evaluated
11546 function setGlobalEval( elems, refElements ) {
11547 var i = 0,
11548 l = elems.length;
11549
11550 for ( ; i < l; i++ ) {
11551 data_priv.set(
11552 elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
11553 );
11554 }
11555 }
11556
11557 function cloneCopyEvent( src, dest ) {
11558 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
11559
11560 if ( dest.nodeType !== 1 ) {
11561 return;
11562 }
11563
11564 // 1. Copy private data: events, handlers, etc.
11565 if ( data_priv.hasData( src ) ) {
11566 pdataOld = data_priv.access( src );
11567 pdataCur = data_priv.set( dest, pdataOld );
11568 events = pdataOld.events;
11569
11570 if ( events ) {
11571 delete pdataCur.handle;
11572 pdataCur.events = {};
11573
11574 for ( type in events ) {
11575 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
11576 jQuery.event.add( dest, type, events[ type ][ i ] );
11577 }
11578 }
11579 }
11580 }
11581
11582 // 2. Copy user data
11583 if ( data_user.hasData( src ) ) {
11584 udataOld = data_user.access( src );
11585 udataCur = jQuery.extend( {}, udataOld );
11586
11587 data_user.set( dest, udataCur );
11588 }
11589 }
11590
11591 function getAll( context, tag ) {
11592 var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
11593 context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
11594 [];
11595
11596 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
11597 jQuery.merge( [ context ], ret ) :
11598 ret;
11599 }
11600
11601 // Support: IE >= 9
11602 function fixInput( src, dest ) {
11603 var nodeName = dest.nodeName.toLowerCase();
11604
11605 // Fails to persist the checked state of a cloned checkbox or radio button.
11606 if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
11607 dest.checked = src.checked;
11608
11609 // Fails to return the selected option to the default selected state when cloning options
11610 } else if ( nodeName === "input" || nodeName === "textarea" ) {
11611 dest.defaultValue = src.defaultValue;
11612 }
11613 }
11614
11615 jQuery.extend({
11616 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
11617 var i, l, srcElements, destElements,
11618 clone = elem.cloneNode( true ),
11619 inPage = jQuery.contains( elem.ownerDocument, elem );
11620
11621 // Support: IE >= 9
11622 // Fix Cloning issues
11623 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
11624 !jQuery.isXMLDoc( elem ) ) {
11625
11626 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
11627 destElements = getAll( clone );
11628 srcElements = getAll( elem );
11629
11630 for ( i = 0, l = srcElements.length; i < l; i++ ) {
11631 fixInput( srcElements[ i ], destElements[ i ] );
11632 }
11633 }
11634
11635 // Copy the events from the original to the clone
11636 if ( dataAndEvents ) {
11637 if ( deepDataAndEvents ) {
11638 srcElements = srcElements || getAll( elem );
11639 destElements = destElements || getAll( clone );
11640
11641 for ( i = 0, l = srcElements.length; i < l; i++ ) {
11642 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
11643 }
11644 } else {
11645 cloneCopyEvent( elem, clone );
11646 }
11647 }
11648
11649 // Preserve script evaluation history
11650 destElements = getAll( clone, "script" );
11651 if ( destElements.length > 0 ) {
11652 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
11653 }
11654
11655 // Return the cloned set
11656 return clone;
11657 },
11658
11659 buildFragment: function( elems, context, scripts, selection ) {
11660 var elem, tmp, tag, wrap, contains, j,
11661 fragment = context.createDocumentFragment(),
11662 nodes = [],
11663 i = 0,
11664 l = elems.length;
11665
11666 for ( ; i < l; i++ ) {
11667 elem = elems[ i ];
11668
11669 if ( elem || elem === 0 ) {
11670
11671 // Add nodes directly
11672 if ( jQuery.type( elem ) === "object" ) {
11673 // Support: QtWebKit
11674 // jQuery.merge because push.apply(_, arraylike) throws
11675 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
11676
11677 // Convert non-html into a text node
11678 } else if ( !rhtml.test( elem ) ) {
11679 nodes.push( context.createTextNode( elem ) );
11680
11681 // Convert html into DOM nodes
11682 } else {
11683 tmp = tmp || fragment.appendChild( context.createElement("div") );
11684
11685 // Deserialize a standard representation
11686 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
11687 wrap = wrapMap[ tag ] || wrapMap._default;
11688 tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
11689
11690 // Descend through wrappers to the right content
11691 j = wrap[ 0 ];
11692 while ( j-- ) {
11693 tmp = tmp.lastChild;
11694 }
11695
11696 // Support: QtWebKit
11697 // jQuery.merge because push.apply(_, arraylike) throws
11698 jQuery.merge( nodes, tmp.childNodes );
11699
11700 // Remember the top-level container
11701 tmp = fragment.firstChild;
11702
11703 // Fixes #12346
11704 // Support: Webkit, IE
11705 tmp.textContent = "";
11706 }
11707 }
11708 }
11709
11710 // Remove wrapper from fragment
11711 fragment.textContent = "";
11712
11713 i = 0;
11714 while ( (elem = nodes[ i++ ]) ) {
11715
11716 // #4087 - If origin and destination elements are the same, and this is
11717 // that element, do not do anything
11718 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
11719 continue;
11720 }
11721
11722 contains = jQuery.contains( elem.ownerDocument, elem );
11723
11724 // Append to fragment
11725 tmp = getAll( fragment.appendChild( elem ), "script" );
11726
11727 // Preserve script evaluation history
11728 if ( contains ) {
11729 setGlobalEval( tmp );
11730 }
11731
11732 // Capture executables
11733 if ( scripts ) {
11734 j = 0;
11735 while ( (elem = tmp[ j++ ]) ) {
11736 if ( rscriptType.test( elem.type || "" ) ) {
11737 scripts.push( elem );
11738 }
11739 }
11740 }
11741 }
11742
11743 return fragment;
11744 },
11745
11746 cleanData: function( elems ) {
11747 var data, elem, type, key,
11748 special = jQuery.event.special,
11749 i = 0;
11750
11751 for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
11752 if ( jQuery.acceptData( elem ) ) {
11753 key = elem[ data_priv.expando ];
11754
11755 if ( key && (data = data_priv.cache[ key ]) ) {
11756 if ( data.events ) {
11757 for ( type in data.events ) {
11758 if ( special[ type ] ) {
11759 jQuery.event.remove( elem, type );
11760
11761 // This is a shortcut to avoid jQuery.event.remove's overhead
11762 } else {
11763 jQuery.removeEvent( elem, type, data.handle );
11764 }
11765 }
11766 }
11767 if ( data_priv.cache[ key ] ) {
11768 // Discard any remaining `private` data
11769 delete data_priv.cache[ key ];
11770 }
11771 }
11772 }
11773 // Discard any remaining `user` data
11774 delete data_user.cache[ elem[ data_user.expando ] ];
11775 }
11776 }
11777 });
11778
11779 jQuery.fn.extend({
11780 text: function( value ) {
11781 return access( this, function( value ) {
11782 return value === undefined ?
11783 jQuery.text( this ) :
11784 this.empty().each(function() {
11785 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11786 this.textContent = value;
11787 }
11788 });
11789 }, null, value, arguments.length );
11790 },
11791
11792 append: function() {
11793 return this.domManip( arguments, function( elem ) {
11794 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11795 var target = manipulationTarget( this, elem );
11796 target.appendChild( elem );
11797 }
11798 });
11799 },
11800
11801 prepend: function() {
11802 return this.domManip( arguments, function( elem ) {
11803 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11804 var target = manipulationTarget( this, elem );
11805 target.insertBefore( elem, target.firstChild );
11806 }
11807 });
11808 },
11809
11810 before: function() {
11811 return this.domManip( arguments, function( elem ) {
11812 if ( this.parentNode ) {
11813 this.parentNode.insertBefore( elem, this );
11814 }
11815 });
11816 },
11817
11818 after: function() {
11819 return this.domManip( arguments, function( elem ) {
11820 if ( this.parentNode ) {
11821 this.parentNode.insertBefore( elem, this.nextSibling );
11822 }
11823 });
11824 },
11825
11826 remove: function( selector, keepData /* Internal Use Only */ ) {
11827 var elem,
11828 elems = selector ? jQuery.filter( selector, this ) : this,
11829 i = 0;
11830
11831 for ( ; (elem = elems[i]) != null; i++ ) {
11832 if ( !keepData && elem.nodeType === 1 ) {
11833 jQuery.cleanData( getAll( elem ) );
11834 }
11835
11836 if ( elem.parentNode ) {
11837 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
11838 setGlobalEval( getAll( elem, "script" ) );
11839 }
11840 elem.parentNode.removeChild( elem );
11841 }
11842 }
11843
11844 return this;
11845 },
11846
11847 empty: function() {
11848 var elem,
11849 i = 0;
11850
11851 for ( ; (elem = this[i]) != null; i++ ) {
11852 if ( elem.nodeType === 1 ) {
11853
11854 // Prevent memory leaks
11855 jQuery.cleanData( getAll( elem, false ) );
11856
11857 // Remove any remaining nodes
11858 elem.textContent = "";
11859 }
11860 }
11861
11862 return this;
11863 },
11864
11865 clone: function( dataAndEvents, deepDataAndEvents ) {
11866 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
11867 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
11868
11869 return this.map(function() {
11870 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
11871 });
11872 },
11873
11874 html: function( value ) {
11875 return access( this, function( value ) {
11876 var elem = this[ 0 ] || {},
11877 i = 0,
11878 l = this.length;
11879
11880 if ( value === undefined && elem.nodeType === 1 ) {
11881 return elem.innerHTML;
11882 }
11883
11884 // See if we can take a shortcut and just use innerHTML
11885 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
11886 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
11887
11888 value = value.replace( rxhtmlTag, "<$1></$2>" );
11889
11890 try {
11891 for ( ; i < l; i++ ) {
11892 elem = this[ i ] || {};
11893
11894 // Remove element nodes and prevent memory leaks
11895 if ( elem.nodeType === 1 ) {
11896 jQuery.cleanData( getAll( elem, false ) );
11897 elem.innerHTML = value;
11898 }
11899 }
11900
11901 elem = 0;
11902
11903 // If using innerHTML throws an exception, use the fallback method
11904 } catch( e ) {}
11905 }
11906
11907 if ( elem ) {
11908 this.empty().append( value );
11909 }
11910 }, null, value, arguments.length );
11911 },
11912
11913 replaceWith: function() {
11914 var arg = arguments[ 0 ];
11915
11916 // Make the changes, replacing each context element with the new content
11917 this.domManip( arguments, function( elem ) {
11918 arg = this.parentNode;
11919
11920 jQuery.cleanData( getAll( this ) );
11921
11922 if ( arg ) {
11923 arg.replaceChild( elem, this );
11924 }
11925 });
11926
11927 // Force removal if there was no new content (e.g., from empty arguments)
11928 return arg && (arg.length || arg.nodeType) ? this : this.remove();
11929 },
11930
11931 detach: function( selector ) {
11932 return this.remove( selector, true );
11933 },
11934
11935 domManip: function( args, callback ) {
11936
11937 // Flatten any nested arrays
11938 args = concat.apply( [], args );
11939
11940 var fragment, first, scripts, hasScripts, node, doc,
11941 i = 0,
11942 l = this.length,
11943 set = this,
11944 iNoClone = l - 1,
11945 value = args[ 0 ],
11946 isFunction = jQuery.isFunction( value );
11947
11948 // We can't cloneNode fragments that contain checked, in WebKit
11949 if ( isFunction ||
11950 ( l > 1 && typeof value === "string" &&
11951 !support.checkClone && rchecked.test( value ) ) ) {
11952 return this.each(function( index ) {
11953 var self = set.eq( index );
11954 if ( isFunction ) {
11955 args[ 0 ] = value.call( this, index, self.html() );
11956 }
11957 self.domManip( args, callback );
11958 });
11959 }
11960
11961 if ( l ) {
11962 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
11963 first = fragment.firstChild;
11964
11965 if ( fragment.childNodes.length === 1 ) {
11966 fragment = first;
11967 }
11968
11969 if ( first ) {
11970 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
11971 hasScripts = scripts.length;
11972
11973 // Use the original fragment for the last item instead of the first because it can end up
11974 // being emptied incorrectly in certain situations (#8070).
11975 for ( ; i < l; i++ ) {
11976 node = fragment;
11977
11978 if ( i !== iNoClone ) {
11979 node = jQuery.clone( node, true, true );
11980
11981 // Keep references to cloned scripts for later restoration
11982 if ( hasScripts ) {
11983 // Support: QtWebKit
11984 // jQuery.merge because push.apply(_, arraylike) throws
11985 jQuery.merge( scripts, getAll( node, "script" ) );
11986 }
11987 }
11988
11989 callback.call( this[ i ], node, i );
11990 }
11991
11992 if ( hasScripts ) {
11993 doc = scripts[ scripts.length - 1 ].ownerDocument;
11994
11995 // Reenable scripts
11996 jQuery.map( scripts, restoreScript );
11997
11998 // Evaluate executable scripts on first document insertion
11999 for ( i = 0; i < hasScripts; i++ ) {
12000 node = scripts[ i ];
12001 if ( rscriptType.test( node.type || "" ) &&
12002 !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
12003
12004 if ( node.src ) {
12005 // Optional AJAX dependency, but won't run scripts if not present
12006 if ( jQuery._evalUrl ) {
12007 jQuery._evalUrl( node.src );
12008 }
12009 } else {
12010 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
12011 }
12012 }
12013 }
12014 }
12015 }
12016 }
12017
12018 return this;
12019 }
12020 });
12021
12022 jQuery.each({
12023 appendTo: "append",
12024 prependTo: "prepend",
12025 insertBefore: "before",
12026 insertAfter: "after",
12027 replaceAll: "replaceWith"
12028 }, function( name, original ) {
12029 jQuery.fn[ name ] = function( selector ) {
12030 var elems,
12031 ret = [],
12032 insert = jQuery( selector ),
12033 last = insert.length - 1,
12034 i = 0;
12035
12036 for ( ; i <= last; i++ ) {
12037 elems = i === last ? this : this.clone( true );
12038 jQuery( insert[ i ] )[ original ]( elems );
12039
12040 // Support: QtWebKit
12041 // .get() because push.apply(_, arraylike) throws
12042 push.apply( ret, elems.get() );
12043 }
12044
12045 return this.pushStack( ret );
12046 };
12047 });
12048
12049
12050 var iframe,
12051 elemdisplay = {};
12052
12053 /**
12054 * Retrieve the actual display of a element
12055 * @param {String} name nodeName of the element
12056 * @param {Object} doc Document object
12057 */
12058 // Called only from within defaultDisplay
12059 function actualDisplay( name, doc ) {
12060 var style,
12061 elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
12062
12063 // getDefaultComputedStyle might be reliably used only on attached element
12064 display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
12065
12066 // Use of this method is a temporary fix (more like optmization) until something better comes along,
12067 // since it was removed from specification and supported only in FF
12068 style.display : jQuery.css( elem[ 0 ], "display" );
12069
12070 // We don't have any data stored on the element,
12071 // so use "detach" method as fast way to get rid of the element
12072 elem.detach();
12073
12074 return display;
12075 }
12076
12077 /**
12078 * Try to determine the default display value of an element
12079 * @param {String} nodeName
12080 */
12081 function defaultDisplay( nodeName ) {
12082 var doc = document,
12083 display = elemdisplay[ nodeName ];
12084
12085 if ( !display ) {
12086 display = actualDisplay( nodeName, doc );
12087
12088 // If the simple way fails, read from inside an iframe
12089 if ( display === "none" || !display ) {
12090
12091 // Use the already-created iframe if possible
12092 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
12093
12094 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
12095 doc = iframe[ 0 ].contentDocument;
12096
12097 // Support: IE
12098 doc.write();
12099 doc.close();
12100
12101 display = actualDisplay( nodeName, doc );
12102 iframe.detach();
12103 }
12104
12105 // Store the correct default display
12106 elemdisplay[ nodeName ] = display;
12107 }
12108
12109 return display;
12110 }
12111 var rmargin = (/^margin/);
12112
12113 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
12114
12115 var getStyles = function( elem ) {
12116 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
12117 };
12118
12119
12120
12121 function curCSS( elem, name, computed ) {
12122 var width, minWidth, maxWidth, ret,
12123 style = elem.style;
12124
12125 computed = computed || getStyles( elem );
12126
12127 // Support: IE9
12128 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
12129 if ( computed ) {
12130 ret = computed.getPropertyValue( name ) || computed[ name ];
12131 }
12132
12133 if ( computed ) {
12134
12135 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
12136 ret = jQuery.style( elem, name );
12137 }
12138
12139 // Support: iOS < 6
12140 // A tribute to the "awesome hack by Dean Edwards"
12141 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
12142 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
12143 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
12144
12145 // Remember the original values
12146 width = style.width;
12147 minWidth = style.minWidth;
12148 maxWidth = style.maxWidth;
12149
12150 // Put in the new values to get a computed value out
12151 style.minWidth = style.maxWidth = style.width = ret;
12152 ret = computed.width;
12153
12154 // Revert the changed values
12155 style.width = width;
12156 style.minWidth = minWidth;
12157 style.maxWidth = maxWidth;
12158 }
12159 }
12160
12161 return ret !== undefined ?
12162 // Support: IE
12163 // IE returns zIndex value as an integer.
12164 ret + "" :
12165 ret;
12166 }
12167
12168
12169 function addGetHookIf( conditionFn, hookFn ) {
12170 // Define the hook, we'll check on the first run if it's really needed.
12171 return {
12172 get: function() {
12173 if ( conditionFn() ) {
12174 // Hook not needed (or it's not possible to use it due to missing dependency),
12175 // remove it.
12176 // Since there are no other hooks for marginRight, remove the whole object.
12177 delete this.get;
12178 return;
12179 }
12180
12181 // Hook needed; redefine it so that the support test is not executed again.
12182
12183 return (this.get = hookFn).apply( this, arguments );
12184 }
12185 };
12186 }
12187
12188
12189 (function() {
12190 var pixelPositionVal, boxSizingReliableVal,
12191 docElem = document.documentElement,
12192 container = document.createElement( "div" ),
12193 div = document.createElement( "div" );
12194
12195 if ( !div.style ) {
12196 return;
12197 }
12198
12199 div.style.backgroundClip = "content-box";
12200 div.cloneNode( true ).style.backgroundClip = "";
12201 support.clearCloneStyle = div.style.backgroundClip === "content-box";
12202
12203 container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" +
12204 "position:absolute";
12205 container.appendChild( div );
12206
12207 // Executing both pixelPosition & boxSizingReliable tests require only one layout
12208 // so they're executed at the same time to save the second computation.
12209 function computePixelPositionAndBoxSizingReliable() {
12210 div.style.cssText =
12211 // Support: Firefox<29, Android 2.3
12212 // Vendor-prefix box-sizing
12213 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
12214 "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
12215 "border:1px;padding:1px;width:4px;position:absolute";
12216 div.innerHTML = "";
12217 docElem.appendChild( container );
12218
12219 var divStyle = window.getComputedStyle( div, null );
12220 pixelPositionVal = divStyle.top !== "1%";
12221 boxSizingReliableVal = divStyle.width === "4px";
12222
12223 docElem.removeChild( container );
12224 }
12225
12226 // Support: node.js jsdom
12227 // Don't assume that getComputedStyle is a property of the global object
12228 if ( window.getComputedStyle ) {
12229 jQuery.extend( support, {
12230 pixelPosition: function() {
12231 // This test is executed only once but we still do memoizing
12232 // since we can use the boxSizingReliable pre-computing.
12233 // No need to check if the test was already performed, though.
12234 computePixelPositionAndBoxSizingReliable();
12235 return pixelPositionVal;
12236 },
12237 boxSizingReliable: function() {
12238 if ( boxSizingReliableVal == null ) {
12239 computePixelPositionAndBoxSizingReliable();
12240 }
12241 return boxSizingReliableVal;
12242 },
12243 reliableMarginRight: function() {
12244 // Support: Android 2.3
12245 // Check if div with explicit width and no margin-right incorrectly
12246 // gets computed margin-right based on width of container. (#3333)
12247 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
12248 // This support function is only executed once so no memoizing is needed.
12249 var ret,
12250 marginDiv = div.appendChild( document.createElement( "div" ) );
12251
12252 // Reset CSS: box-sizing; display; margin; border; padding
12253 marginDiv.style.cssText = div.style.cssText =
12254 // Support: Firefox<29, Android 2.3
12255 // Vendor-prefix box-sizing
12256 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
12257 "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
12258 marginDiv.style.marginRight = marginDiv.style.width = "0";
12259 div.style.width = "1px";
12260 docElem.appendChild( container );
12261
12262 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
12263
12264 docElem.removeChild( container );
12265
12266 return ret;
12267 }
12268 });
12269 }
12270 })();
12271
12272
12273 // A method for quickly swapping in/out CSS properties to get correct calculations.
12274 jQuery.swap = function( elem, options, callback, args ) {
12275 var ret, name,
12276 old = {};
12277
12278 // Remember the old values, and insert the new ones
12279 for ( name in options ) {
12280 old[ name ] = elem.style[ name ];
12281 elem.style[ name ] = options[ name ];
12282 }
12283
12284 ret = callback.apply( elem, args || [] );
12285
12286 // Revert the old values
12287 for ( name in options ) {
12288 elem.style[ name ] = old[ name ];
12289 }
12290
12291 return ret;
12292 };
12293
12294
12295 var
12296 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
12297 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
12298 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
12299 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
12300 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
12301
12302 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
12303 cssNormalTransform = {
12304 letterSpacing: "0",
12305 fontWeight: "400"
12306 },
12307
12308 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
12309
12310 // return a css property mapped to a potentially vendor prefixed property
12311 function vendorPropName( style, name ) {
12312
12313 // shortcut for names that are not vendor prefixed
12314 if ( name in style ) {
12315 return name;
12316 }
12317
12318 // check for vendor prefixed names
12319 var capName = name[0].toUpperCase() + name.slice(1),
12320 origName = name,
12321 i = cssPrefixes.length;
12322
12323 while ( i-- ) {
12324 name = cssPrefixes[ i ] + capName;
12325 if ( name in style ) {
12326 return name;
12327 }
12328 }
12329
12330 return origName;
12331 }
12332
12333 function setPositiveNumber( elem, value, subtract ) {
12334 var matches = rnumsplit.exec( value );
12335 return matches ?
12336 // Guard against undefined "subtract", e.g., when used as in cssHooks
12337 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
12338 value;
12339 }
12340
12341 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
12342 var i = extra === ( isBorderBox ? "border" : "content" ) ?
12343 // If we already have the right measurement, avoid augmentation
12344 4 :
12345 // Otherwise initialize for horizontal or vertical properties
12346 name === "width" ? 1 : 0,
12347
12348 val = 0;
12349
12350 for ( ; i < 4; i += 2 ) {
12351 // both box models exclude margin, so add it if we want it
12352 if ( extra === "margin" ) {
12353 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
12354 }
12355
12356 if ( isBorderBox ) {
12357 // border-box includes padding, so remove it if we want content
12358 if ( extra === "content" ) {
12359 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
12360 }
12361
12362 // at this point, extra isn't border nor margin, so remove border
12363 if ( extra !== "margin" ) {
12364 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
12365 }
12366 } else {
12367 // at this point, extra isn't content, so add padding
12368 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
12369
12370 // at this point, extra isn't content nor padding, so add border
12371 if ( extra !== "padding" ) {
12372 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
12373 }
12374 }
12375 }
12376
12377 return val;
12378 }
12379
12380 function getWidthOrHeight( elem, name, extra ) {
12381
12382 // Start with offset property, which is equivalent to the border-box value
12383 var valueIsBorderBox = true,
12384 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
12385 styles = getStyles( elem ),
12386 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
12387
12388 // some non-html elements return undefined for offsetWidth, so check for null/undefined
12389 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
12390 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
12391 if ( val <= 0 || val == null ) {
12392 // Fall back to computed then uncomputed css if necessary
12393 val = curCSS( elem, name, styles );
12394 if ( val < 0 || val == null ) {
12395 val = elem.style[ name ];
12396 }
12397
12398 // Computed unit is not pixels. Stop here and return.
12399 if ( rnumnonpx.test(val) ) {
12400 return val;
12401 }
12402
12403 // we need the check for style in case a browser which returns unreliable values
12404 // for getComputedStyle silently falls back to the reliable elem.style
12405 valueIsBorderBox = isBorderBox &&
12406 ( support.boxSizingReliable() || val === elem.style[ name ] );
12407
12408 // Normalize "", auto, and prepare for extra
12409 val = parseFloat( val ) || 0;
12410 }
12411
12412 // use the active box-sizing model to add/subtract irrelevant styles
12413 return ( val +
12414 augmentWidthOrHeight(
12415 elem,
12416 name,
12417 extra || ( isBorderBox ? "border" : "content" ),
12418 valueIsBorderBox,
12419 styles
12420 )
12421 ) + "px";
12422 }
12423
12424 function showHide( elements, show ) {
12425 var display, elem, hidden,
12426 values = [],
12427 index = 0,
12428 length = elements.length;
12429
12430 for ( ; index < length; index++ ) {
12431 elem = elements[ index ];
12432 if ( !elem.style ) {
12433 continue;
12434 }
12435
12436 values[ index ] = data_priv.get( elem, "olddisplay" );
12437 display = elem.style.display;
12438 if ( show ) {
12439 // Reset the inline display of this element to learn if it is
12440 // being hidden by cascaded rules or not
12441 if ( !values[ index ] && display === "none" ) {
12442 elem.style.display = "";
12443 }
12444
12445 // Set elements which have been overridden with display: none
12446 // in a stylesheet to whatever the default browser style is
12447 // for such an element
12448 if ( elem.style.display === "" && isHidden( elem ) ) {
12449 values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
12450 }
12451 } else {
12452 hidden = isHidden( elem );
12453
12454 if ( display !== "none" || !hidden ) {
12455 data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
12456 }
12457 }
12458 }
12459
12460 // Set the display of most of the elements in a second loop
12461 // to avoid the constant reflow
12462 for ( index = 0; index < length; index++ ) {
12463 elem = elements[ index ];
12464 if ( !elem.style ) {
12465 continue;
12466 }
12467 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
12468 elem.style.display = show ? values[ index ] || "" : "none";
12469 }
12470 }
12471
12472 return elements;
12473 }
12474
12475 jQuery.extend({
12476 // Add in style property hooks for overriding the default
12477 // behavior of getting and setting a style property
12478 cssHooks: {
12479 opacity: {
12480 get: function( elem, computed ) {
12481 if ( computed ) {
12482 // We should always get a number back from opacity
12483 var ret = curCSS( elem, "opacity" );
12484 return ret === "" ? "1" : ret;
12485 }
12486 }
12487 }
12488 },
12489
12490 // Don't automatically add "px" to these possibly-unitless properties
12491 cssNumber: {
12492 "columnCount": true,
12493 "fillOpacity": true,
12494 "flexGrow": true,
12495 "flexShrink": true,
12496 "fontWeight": true,
12497 "lineHeight": true,
12498 "opacity": true,
12499 "order": true,
12500 "orphans": true,
12501 "widows": true,
12502 "zIndex": true,
12503 "zoom": true
12504 },
12505
12506 // Add in properties whose names you wish to fix before
12507 // setting or getting the value
12508 cssProps: {
12509 // normalize float css property
12510 "float": "cssFloat"
12511 },
12512
12513 // Get and set the style property on a DOM Node
12514 style: function( elem, name, value, extra ) {
12515 // Don't set styles on text and comment nodes
12516 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
12517 return;
12518 }
12519
12520 // Make sure that we're working with the right name
12521 var ret, type, hooks,
12522 origName = jQuery.camelCase( name ),
12523 style = elem.style;
12524
12525 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
12526
12527 // gets hook for the prefixed version
12528 // followed by the unprefixed version
12529 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
12530
12531 // Check if we're setting a value
12532 if ( value !== undefined ) {
12533 type = typeof value;
12534
12535 // convert relative number strings (+= or -=) to relative numbers. #7345
12536 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
12537 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
12538 // Fixes bug #9237
12539 type = "number";
12540 }
12541
12542 // Make sure that null and NaN values aren't set. See: #7116
12543 if ( value == null || value !== value ) {
12544 return;
12545 }
12546
12547 // If a number was passed in, add 'px' to the (except for certain CSS properties)
12548 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
12549 value += "px";
12550 }
12551
12552 // Fixes #8908, it can be done more correctly by specifying setters in cssHooks,
12553 // but it would mean to define eight (for every problematic property) identical functions
12554 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
12555 style[ name ] = "inherit";
12556 }
12557
12558 // If a hook was provided, use that value, otherwise just set the specified value
12559 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
12560 style[ name ] = value;
12561 }
12562
12563 } else {
12564 // If a hook was provided get the non-computed value from there
12565 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
12566 return ret;
12567 }
12568
12569 // Otherwise just get the value from the style object
12570 return style[ name ];
12571 }
12572 },
12573
12574 css: function( elem, name, extra, styles ) {
12575 var val, num, hooks,
12576 origName = jQuery.camelCase( name );
12577
12578 // Make sure that we're working with the right name
12579 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
12580
12581 // gets hook for the prefixed version
12582 // followed by the unprefixed version
12583 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
12584
12585 // If a hook was provided get the computed value from there
12586 if ( hooks && "get" in hooks ) {
12587 val = hooks.get( elem, true, extra );
12588 }
12589
12590 // Otherwise, if a way to get the computed value exists, use that
12591 if ( val === undefined ) {
12592 val = curCSS( elem, name, styles );
12593 }
12594
12595 //convert "normal" to computed value
12596 if ( val === "normal" && name in cssNormalTransform ) {
12597 val = cssNormalTransform[ name ];
12598 }
12599
12600 // Return, converting to number if forced or a qualifier was provided and val looks numeric
12601 if ( extra === "" || extra ) {
12602 num = parseFloat( val );
12603 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
12604 }
12605 return val;
12606 }
12607 });
12608
12609 jQuery.each([ "height", "width" ], function( i, name ) {
12610 jQuery.cssHooks[ name ] = {
12611 get: function( elem, computed, extra ) {
12612 if ( computed ) {
12613 // certain elements can have dimension info if we invisibly show them
12614 // however, it must have a current display style that would benefit from this
12615 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
12616 jQuery.swap( elem, cssShow, function() {
12617 return getWidthOrHeight( elem, name, extra );
12618 }) :
12619 getWidthOrHeight( elem, name, extra );
12620 }
12621 },
12622
12623 set: function( elem, value, extra ) {
12624 var styles = extra && getStyles( elem );
12625 return setPositiveNumber( elem, value, extra ?
12626 augmentWidthOrHeight(
12627 elem,
12628 name,
12629 extra,
12630 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
12631 styles
12632 ) : 0
12633 );
12634 }
12635 };
12636 });
12637
12638 // Support: Android 2.3
12639 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
12640 function( elem, computed ) {
12641 if ( computed ) {
12642 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
12643 // Work around by temporarily setting element display to inline-block
12644 return jQuery.swap( elem, { "display": "inline-block" },
12645 curCSS, [ elem, "marginRight" ] );
12646 }
12647 }
12648 );
12649
12650 // These hooks are used by animate to expand properties
12651 jQuery.each({
12652 margin: "",
12653 padding: "",
12654 border: "Width"
12655 }, function( prefix, suffix ) {
12656 jQuery.cssHooks[ prefix + suffix ] = {
12657 expand: function( value ) {
12658 var i = 0,
12659 expanded = {},
12660
12661 // assumes a single number if not a string
12662 parts = typeof value === "string" ? value.split(" ") : [ value ];
12663
12664 for ( ; i < 4; i++ ) {
12665 expanded[ prefix + cssExpand[ i ] + suffix ] =
12666 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
12667 }
12668
12669 return expanded;
12670 }
12671 };
12672
12673 if ( !rmargin.test( prefix ) ) {
12674 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
12675 }
12676 });
12677
12678 jQuery.fn.extend({
12679 css: function( name, value ) {
12680 return access( this, function( elem, name, value ) {
12681 var styles, len,
12682 map = {},
12683 i = 0;
12684
12685 if ( jQuery.isArray( name ) ) {
12686 styles = getStyles( elem );
12687 len = name.length;
12688
12689 for ( ; i < len; i++ ) {
12690 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
12691 }
12692
12693 return map;
12694 }
12695
12696 return value !== undefined ?
12697 jQuery.style( elem, name, value ) :
12698 jQuery.css( elem, name );
12699 }, name, value, arguments.length > 1 );
12700 },
12701 show: function() {
12702 return showHide( this, true );
12703 },
12704 hide: function() {
12705 return showHide( this );
12706 },
12707 toggle: function( state ) {
12708 if ( typeof state === "boolean" ) {
12709 return state ? this.show() : this.hide();
12710 }
12711
12712 return this.each(function() {
12713 if ( isHidden( this ) ) {
12714 jQuery( this ).show();
12715 } else {
12716 jQuery( this ).hide();
12717 }
12718 });
12719 }
12720 });
12721
12722
12723 function Tween( elem, options, prop, end, easing ) {
12724 return new Tween.prototype.init( elem, options, prop, end, easing );
12725 }
12726 jQuery.Tween = Tween;
12727
12728 Tween.prototype = {
12729 constructor: Tween,
12730 init: function( elem, options, prop, end, easing, unit ) {
12731 this.elem = elem;
12732 this.prop = prop;
12733 this.easing = easing || "swing";
12734 this.options = options;
12735 this.start = this.now = this.cur();
12736 this.end = end;
12737 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
12738 },
12739 cur: function() {
12740 var hooks = Tween.propHooks[ this.prop ];
12741
12742 return hooks && hooks.get ?
12743 hooks.get( this ) :
12744 Tween.propHooks._default.get( this );
12745 },
12746 run: function( percent ) {
12747 var eased,
12748 hooks = Tween.propHooks[ this.prop ];
12749
12750 if ( this.options.duration ) {
12751 this.pos = eased = jQuery.easing[ this.easing ](
12752 percent, this.options.duration * percent, 0, 1, this.options.duration
12753 );
12754 } else {
12755 this.pos = eased = percent;
12756 }
12757 this.now = ( this.end - this.start ) * eased + this.start;
12758
12759 if ( this.options.step ) {
12760 this.options.step.call( this.elem, this.now, this );
12761 }
12762
12763 if ( hooks && hooks.set ) {
12764 hooks.set( this );
12765 } else {
12766 Tween.propHooks._default.set( this );
12767 }
12768 return this;
12769 }
12770 };
12771
12772 Tween.prototype.init.prototype = Tween.prototype;
12773
12774 Tween.propHooks = {
12775 _default: {
12776 get: function( tween ) {
12777 var result;
12778
12779 if ( tween.elem[ tween.prop ] != null &&
12780 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
12781 return tween.elem[ tween.prop ];
12782 }
12783
12784 // passing an empty string as a 3rd parameter to .css will automatically
12785 // attempt a parseFloat and fallback to a string if the parse fails
12786 // so, simple values such as "10px" are parsed to Float.
12787 // complex values such as "rotate(1rad)" are returned as is.
12788 result = jQuery.css( tween.elem, tween.prop, "" );
12789 // Empty strings, null, undefined and "auto" are converted to 0.
12790 return !result || result === "auto" ? 0 : result;
12791 },
12792 set: function( tween ) {
12793 // use step hook for back compat - use cssHook if its there - use .style if its
12794 // available and use plain properties where available
12795 if ( jQuery.fx.step[ tween.prop ] ) {
12796 jQuery.fx.step[ tween.prop ]( tween );
12797 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
12798 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
12799 } else {
12800 tween.elem[ tween.prop ] = tween.now;
12801 }
12802 }
12803 }
12804 };
12805
12806 // Support: IE9
12807 // Panic based approach to setting things on disconnected nodes
12808
12809 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
12810 set: function( tween ) {
12811 if ( tween.elem.nodeType && tween.elem.parentNode ) {
12812 tween.elem[ tween.prop ] = tween.now;
12813 }
12814 }
12815 };
12816
12817 jQuery.easing = {
12818 linear: function( p ) {
12819 return p;
12820 },
12821 swing: function( p ) {
12822 return 0.5 - Math.cos( p * Math.PI ) / 2;
12823 }
12824 };
12825
12826 jQuery.fx = Tween.prototype.init;
12827
12828 // Back Compat <1.8 extension point
12829 jQuery.fx.step = {};
12830
12831
12832
12833
12834 var
12835 fxNow, timerId,
12836 rfxtypes = /^(?:toggle|show|hide)$/,
12837 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
12838 rrun = /queueHooks$/,
12839 animationPrefilters = [ defaultPrefilter ],
12840 tweeners = {
12841 "*": [ function( prop, value ) {
12842 var tween = this.createTween( prop, value ),
12843 target = tween.cur(),
12844 parts = rfxnum.exec( value ),
12845 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
12846
12847 // Starting value computation is required for potential unit mismatches
12848 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
12849 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
12850 scale = 1,
12851 maxIterations = 20;
12852
12853 if ( start && start[ 3 ] !== unit ) {
12854 // Trust units reported by jQuery.css
12855 unit = unit || start[ 3 ];
12856
12857 // Make sure we update the tween properties later on
12858 parts = parts || [];
12859
12860 // Iteratively approximate from a nonzero starting point
12861 start = +target || 1;
12862
12863 do {
12864 // If previous iteration zeroed out, double until we get *something*
12865 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
12866 scale = scale || ".5";
12867
12868 // Adjust and apply
12869 start = start / scale;
12870 jQuery.style( tween.elem, prop, start + unit );
12871
12872 // Update scale, tolerating zero or NaN from tween.cur()
12873 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
12874 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
12875 }
12876
12877 // Update tween properties
12878 if ( parts ) {
12879 start = tween.start = +start || +target || 0;
12880 tween.unit = unit;
12881 // If a +=/-= token was provided, we're doing a relative animation
12882 tween.end = parts[ 1 ] ?
12883 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
12884 +parts[ 2 ];
12885 }
12886
12887 return tween;
12888 } ]
12889 };
12890
12891 // Animations created synchronously will run synchronously
12892 function createFxNow() {
12893 setTimeout(function() {
12894 fxNow = undefined;
12895 });
12896 return ( fxNow = jQuery.now() );
12897 }
12898
12899 // Generate parameters to create a standard animation
12900 function genFx( type, includeWidth ) {
12901 var which,
12902 i = 0,
12903 attrs = { height: type };
12904
12905 // if we include width, step value is 1 to do all cssExpand values,
12906 // if we don't include width, step value is 2 to skip over Left and Right
12907 includeWidth = includeWidth ? 1 : 0;
12908 for ( ; i < 4 ; i += 2 - includeWidth ) {
12909 which = cssExpand[ i ];
12910 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
12911 }
12912
12913 if ( includeWidth ) {
12914 attrs.opacity = attrs.width = type;
12915 }
12916
12917 return attrs;
12918 }
12919
12920 function createTween( value, prop, animation ) {
12921 var tween,
12922 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
12923 index = 0,
12924 length = collection.length;
12925 for ( ; index < length; index++ ) {
12926 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
12927
12928 // we're done with this property
12929 return tween;
12930 }
12931 }
12932 }
12933
12934 function defaultPrefilter( elem, props, opts ) {
12935 /* jshint validthis: true */
12936 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
12937 anim = this,
12938 orig = {},
12939 style = elem.style,
12940 hidden = elem.nodeType && isHidden( elem ),
12941 dataShow = data_priv.get( elem, "fxshow" );
12942
12943 // handle queue: false promises
12944 if ( !opts.queue ) {
12945 hooks = jQuery._queueHooks( elem, "fx" );
12946 if ( hooks.unqueued == null ) {
12947 hooks.unqueued = 0;
12948 oldfire = hooks.empty.fire;
12949 hooks.empty.fire = function() {
12950 if ( !hooks.unqueued ) {
12951 oldfire();
12952 }
12953 };
12954 }
12955 hooks.unqueued++;
12956
12957 anim.always(function() {
12958 // doing this makes sure that the complete handler will be called
12959 // before this completes
12960 anim.always(function() {
12961 hooks.unqueued--;
12962 if ( !jQuery.queue( elem, "fx" ).length ) {
12963 hooks.empty.fire();
12964 }
12965 });
12966 });
12967 }
12968
12969 // height/width overflow pass
12970 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
12971 // Make sure that nothing sneaks out
12972 // Record all 3 overflow attributes because IE9-10 do not
12973 // change the overflow attribute when overflowX and
12974 // overflowY are set to the same value
12975 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
12976
12977 // Set display property to inline-block for height/width
12978 // animations on inline elements that are having width/height animated
12979 display = jQuery.css( elem, "display" );
12980
12981 // Test default display if display is currently "none"
12982 checkDisplay = display === "none" ?
12983 data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
12984
12985 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
12986 style.display = "inline-block";
12987 }
12988 }
12989
12990 if ( opts.overflow ) {
12991 style.overflow = "hidden";
12992 anim.always(function() {
12993 style.overflow = opts.overflow[ 0 ];
12994 style.overflowX = opts.overflow[ 1 ];
12995 style.overflowY = opts.overflow[ 2 ];
12996 });
12997 }
12998
12999 // show/hide pass
13000 for ( prop in props ) {
13001 value = props[ prop ];
13002 if ( rfxtypes.exec( value ) ) {
13003 delete props[ prop ];
13004 toggle = toggle || value === "toggle";
13005 if ( value === ( hidden ? "hide" : "show" ) ) {
13006
13007 // 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
13008 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
13009 hidden = true;
13010 } else {
13011 continue;
13012 }
13013 }
13014 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
13015
13016 // Any non-fx value stops us from restoring the original display value
13017 } else {
13018 display = undefined;
13019 }
13020 }
13021
13022 if ( !jQuery.isEmptyObject( orig ) ) {
13023 if ( dataShow ) {
13024 if ( "hidden" in dataShow ) {
13025 hidden = dataShow.hidden;
13026 }
13027 } else {
13028 dataShow = data_priv.access( elem, "fxshow", {} );
13029 }
13030
13031 // store state if its toggle - enables .stop().toggle() to "reverse"
13032 if ( toggle ) {
13033 dataShow.hidden = !hidden;
13034 }
13035 if ( hidden ) {
13036 jQuery( elem ).show();
13037 } else {
13038 anim.done(function() {
13039 jQuery( elem ).hide();
13040 });
13041 }
13042 anim.done(function() {
13043 var prop;
13044
13045 data_priv.remove( elem, "fxshow" );
13046 for ( prop in orig ) {
13047 jQuery.style( elem, prop, orig[ prop ] );
13048 }
13049 });
13050 for ( prop in orig ) {
13051 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
13052
13053 if ( !( prop in dataShow ) ) {
13054 dataShow[ prop ] = tween.start;
13055 if ( hidden ) {
13056 tween.end = tween.start;
13057 tween.start = prop === "width" || prop === "height" ? 1 : 0;
13058 }
13059 }
13060 }
13061
13062 // If this is a noop like .hide().hide(), restore an overwritten display value
13063 } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
13064 style.display = display;
13065 }
13066 }
13067
13068 function propFilter( props, specialEasing ) {
13069 var index, name, easing, value, hooks;
13070
13071 // camelCase, specialEasing and expand cssHook pass
13072 for ( index in props ) {
13073 name = jQuery.camelCase( index );
13074 easing = specialEasing[ name ];
13075 value = props[ index ];
13076 if ( jQuery.isArray( value ) ) {
13077 easing = value[ 1 ];
13078 value = props[ index ] = value[ 0 ];
13079 }
13080
13081 if ( index !== name ) {
13082 props[ name ] = value;
13083 delete props[ index ];
13084 }
13085
13086 hooks = jQuery.cssHooks[ name ];
13087 if ( hooks && "expand" in hooks ) {
13088 value = hooks.expand( value );
13089 delete props[ name ];
13090
13091 // not quite $.extend, this wont overwrite keys already present.
13092 // also - reusing 'index' from above because we have the correct "name"
13093 for ( index in value ) {
13094 if ( !( index in props ) ) {
13095 props[ index ] = value[ index ];
13096 specialEasing[ index ] = easing;
13097 }
13098 }
13099 } else {
13100 specialEasing[ name ] = easing;
13101 }
13102 }
13103 }
13104
13105 function Animation( elem, properties, options ) {
13106 var result,
13107 stopped,
13108 index = 0,
13109 length = animationPrefilters.length,
13110 deferred = jQuery.Deferred().always( function() {
13111 // don't match elem in the :animated selector
13112 delete tick.elem;
13113 }),
13114 tick = function() {
13115 if ( stopped ) {
13116 return false;
13117 }
13118 var currentTime = fxNow || createFxNow(),
13119 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
13120 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
13121 temp = remaining / animation.duration || 0,
13122 percent = 1 - temp,
13123 index = 0,
13124 length = animation.tweens.length;
13125
13126 for ( ; index < length ; index++ ) {
13127 animation.tweens[ index ].run( percent );
13128 }
13129
13130 deferred.notifyWith( elem, [ animation, percent, remaining ]);
13131
13132 if ( percent < 1 && length ) {
13133 return remaining;
13134 } else {
13135 deferred.resolveWith( elem, [ animation ] );
13136 return false;
13137 }
13138 },
13139 animation = deferred.promise({
13140 elem: elem,
13141 props: jQuery.extend( {}, properties ),
13142 opts: jQuery.extend( true, { specialEasing: {} }, options ),
13143 originalProperties: properties,
13144 originalOptions: options,
13145 startTime: fxNow || createFxNow(),
13146 duration: options.duration,
13147 tweens: [],
13148 createTween: function( prop, end ) {
13149 var tween = jQuery.Tween( elem, animation.opts, prop, end,
13150 animation.opts.specialEasing[ prop ] || animation.opts.easing );
13151 animation.tweens.push( tween );
13152 return tween;
13153 },
13154 stop: function( gotoEnd ) {
13155 var index = 0,
13156 // if we are going to the end, we want to run all the tweens
13157 // otherwise we skip this part
13158 length = gotoEnd ? animation.tweens.length : 0;
13159 if ( stopped ) {
13160 return this;
13161 }
13162 stopped = true;
13163 for ( ; index < length ; index++ ) {
13164 animation.tweens[ index ].run( 1 );
13165 }
13166
13167 // resolve when we played the last frame
13168 // otherwise, reject
13169 if ( gotoEnd ) {
13170 deferred.resolveWith( elem, [ animation, gotoEnd ] );
13171 } else {
13172 deferred.rejectWith( elem, [ animation, gotoEnd ] );
13173 }
13174 return this;
13175 }
13176 }),
13177 props = animation.props;
13178
13179 propFilter( props, animation.opts.specialEasing );
13180
13181 for ( ; index < length ; index++ ) {
13182 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
13183 if ( result ) {
13184 return result;
13185 }
13186 }
13187
13188 jQuery.map( props, createTween, animation );
13189
13190 if ( jQuery.isFunction( animation.opts.start ) ) {
13191 animation.opts.start.call( elem, animation );
13192 }
13193
13194 jQuery.fx.timer(
13195 jQuery.extend( tick, {
13196 elem: elem,
13197 anim: animation,
13198 queue: animation.opts.queue
13199 })
13200 );
13201
13202 // attach callbacks from options
13203 return animation.progress( animation.opts.progress )
13204 .done( animation.opts.done, animation.opts.complete )
13205 .fail( animation.opts.fail )
13206 .always( animation.opts.always );
13207 }
13208
13209 jQuery.Animation = jQuery.extend( Animation, {
13210
13211 tweener: function( props, callback ) {
13212 if ( jQuery.isFunction( props ) ) {
13213 callback = props;
13214 props = [ "*" ];
13215 } else {
13216 props = props.split(" ");
13217 }
13218
13219 var prop,
13220 index = 0,
13221 length = props.length;
13222
13223 for ( ; index < length ; index++ ) {
13224 prop = props[ index ];
13225 tweeners[ prop ] = tweeners[ prop ] || [];
13226 tweeners[ prop ].unshift( callback );
13227 }
13228 },
13229
13230 prefilter: function( callback, prepend ) {
13231 if ( prepend ) {
13232 animationPrefilters.unshift( callback );
13233 } else {
13234 animationPrefilters.push( callback );
13235 }
13236 }
13237 });
13238
13239 jQuery.speed = function( speed, easing, fn ) {
13240 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
13241 complete: fn || !fn && easing ||
13242 jQuery.isFunction( speed ) && speed,
13243 duration: speed,
13244 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
13245 };
13246
13247 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
13248 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
13249
13250 // normalize opt.queue - true/undefined/null -> "fx"
13251 if ( opt.queue == null || opt.queue === true ) {
13252 opt.queue = "fx";
13253 }
13254
13255 // Queueing
13256 opt.old = opt.complete;
13257
13258 opt.complete = function() {
13259 if ( jQuery.isFunction( opt.old ) ) {
13260 opt.old.call( this );
13261 }
13262
13263 if ( opt.queue ) {
13264 jQuery.dequeue( this, opt.queue );
13265 }
13266 };
13267
13268 return opt;
13269 };
13270
13271 jQuery.fn.extend({
13272 fadeTo: function( speed, to, easing, callback ) {
13273
13274 // show any hidden elements after setting opacity to 0
13275 return this.filter( isHidden ).css( "opacity", 0 ).show()
13276
13277 // animate to the value specified
13278 .end().animate({ opacity: to }, speed, easing, callback );
13279 },
13280 animate: function( prop, speed, easing, callback ) {
13281 var empty = jQuery.isEmptyObject( prop ),
13282 optall = jQuery.speed( speed, easing, callback ),
13283 doAnimation = function() {
13284 // Operate on a copy of prop so per-property easing won't be lost
13285 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
13286
13287 // Empty animations, or finishing resolves immediately
13288 if ( empty || data_priv.get( this, "finish" ) ) {
13289 anim.stop( true );
13290 }
13291 };
13292 doAnimation.finish = doAnimation;
13293
13294 return empty || optall.queue === false ?
13295 this.each( doAnimation ) :
13296 this.queue( optall.queue, doAnimation );
13297 },
13298 stop: function( type, clearQueue, gotoEnd ) {
13299 var stopQueue = function( hooks ) {
13300 var stop = hooks.stop;
13301 delete hooks.stop;
13302 stop( gotoEnd );
13303 };
13304
13305 if ( typeof type !== "string" ) {
13306 gotoEnd = clearQueue;
13307 clearQueue = type;
13308 type = undefined;
13309 }
13310 if ( clearQueue && type !== false ) {
13311 this.queue( type || "fx", [] );
13312 }
13313
13314 return this.each(function() {
13315 var dequeue = true,
13316 index = type != null && type + "queueHooks",
13317 timers = jQuery.timers,
13318 data = data_priv.get( this );
13319
13320 if ( index ) {
13321 if ( data[ index ] && data[ index ].stop ) {
13322 stopQueue( data[ index ] );
13323 }
13324 } else {
13325 for ( index in data ) {
13326 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
13327 stopQueue( data[ index ] );
13328 }
13329 }
13330 }
13331
13332 for ( index = timers.length; index--; ) {
13333 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
13334 timers[ index ].anim.stop( gotoEnd );
13335 dequeue = false;
13336 timers.splice( index, 1 );
13337 }
13338 }
13339
13340 // start the next in the queue if the last step wasn't forced
13341 // timers currently will call their complete callbacks, which will dequeue
13342 // but only if they were gotoEnd
13343 if ( dequeue || !gotoEnd ) {
13344 jQuery.dequeue( this, type );
13345 }
13346 });
13347 },
13348 finish: function( type ) {
13349 if ( type !== false ) {
13350 type = type || "fx";
13351 }
13352 return this.each(function() {
13353 var index,
13354 data = data_priv.get( this ),
13355 queue = data[ type + "queue" ],
13356 hooks = data[ type + "queueHooks" ],
13357 timers = jQuery.timers,
13358 length = queue ? queue.length : 0;
13359
13360 // enable finishing flag on private data
13361 data.finish = true;
13362
13363 // empty the queue first
13364 jQuery.queue( this, type, [] );
13365
13366 if ( hooks && hooks.stop ) {
13367 hooks.stop.call( this, true );
13368 }
13369
13370 // look for any active animations, and finish them
13371 for ( index = timers.length; index--; ) {
13372 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
13373 timers[ index ].anim.stop( true );
13374 timers.splice( index, 1 );
13375 }
13376 }
13377
13378 // look for any animations in the old queue and finish them
13379 for ( index = 0; index < length; index++ ) {
13380 if ( queue[ index ] && queue[ index ].finish ) {
13381 queue[ index ].finish.call( this );
13382 }
13383 }
13384
13385 // turn off finishing flag
13386 delete data.finish;
13387 });
13388 }
13389 });
13390
13391 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
13392 var cssFn = jQuery.fn[ name ];
13393 jQuery.fn[ name ] = function( speed, easing, callback ) {
13394 return speed == null || typeof speed === "boolean" ?
13395 cssFn.apply( this, arguments ) :
13396 this.animate( genFx( name, true ), speed, easing, callback );
13397 };
13398 });
13399
13400 // Generate shortcuts for custom animations
13401 jQuery.each({
13402 slideDown: genFx("show"),
13403 slideUp: genFx("hide"),
13404 slideToggle: genFx("toggle"),
13405 fadeIn: { opacity: "show" },
13406 fadeOut: { opacity: "hide" },
13407 fadeToggle: { opacity: "toggle" }
13408 }, function( name, props ) {
13409 jQuery.fn[ name ] = function( speed, easing, callback ) {
13410 return this.animate( props, speed, easing, callback );
13411 };
13412 });
13413
13414 jQuery.timers = [];
13415 jQuery.fx.tick = function() {
13416 var timer,
13417 i = 0,
13418 timers = jQuery.timers;
13419
13420 fxNow = jQuery.now();
13421
13422 for ( ; i < timers.length; i++ ) {
13423 timer = timers[ i ];
13424 // Checks the timer has not already been removed
13425 if ( !timer() && timers[ i ] === timer ) {
13426 timers.splice( i--, 1 );
13427 }
13428 }
13429
13430 if ( !timers.length ) {
13431 jQuery.fx.stop();
13432 }
13433 fxNow = undefined;
13434 };
13435
13436 jQuery.fx.timer = function( timer ) {
13437 jQuery.timers.push( timer );
13438 if ( timer() ) {
13439 jQuery.fx.start();
13440 } else {
13441 jQuery.timers.pop();
13442 }
13443 };
13444
13445 jQuery.fx.interval = 13;
13446
13447 jQuery.fx.start = function() {
13448 if ( !timerId ) {
13449 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
13450 }
13451 };
13452
13453 jQuery.fx.stop = function() {
13454 clearInterval( timerId );
13455 timerId = null;
13456 };
13457
13458 jQuery.fx.speeds = {
13459 slow: 600,
13460 fast: 200,
13461 // Default speed
13462 _default: 400
13463 };
13464
13465
13466 // Based off of the plugin by Clint Helfers, with permission.
13467 // http://blindsignals.com/index.php/2009/07/jquery-delay/
13468 jQuery.fn.delay = function( time, type ) {
13469 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
13470 type = type || "fx";
13471
13472 return this.queue( type, function( next, hooks ) {
13473 var timeout = setTimeout( next, time );
13474 hooks.stop = function() {
13475 clearTimeout( timeout );
13476 };
13477 });
13478 };
13479
13480
13481 (function() {
13482 var input = document.createElement( "input" ),
13483 select = document.createElement( "select" ),
13484 opt = select.appendChild( document.createElement( "option" ) );
13485
13486 input.type = "checkbox";
13487
13488 // Support: iOS 5.1, Android 4.x, Android 2.3
13489 // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
13490 support.checkOn = input.value !== "";
13491
13492 // Must access the parent to make an option select properly
13493 // Support: IE9, IE10
13494 support.optSelected = opt.selected;
13495
13496 // Make sure that the options inside disabled selects aren't marked as disabled
13497 // (WebKit marks them as disabled)
13498 select.disabled = true;
13499 support.optDisabled = !opt.disabled;
13500
13501 // Check if an input maintains its value after becoming a radio
13502 // Support: IE9, IE10
13503 input = document.createElement( "input" );
13504 input.value = "t";
13505 input.type = "radio";
13506 support.radioValue = input.value === "t";
13507 })();
13508
13509
13510 var nodeHook, boolHook,
13511 attrHandle = jQuery.expr.attrHandle;
13512
13513 jQuery.fn.extend({
13514 attr: function( name, value ) {
13515 return access( this, jQuery.attr, name, value, arguments.length > 1 );
13516 },
13517
13518 removeAttr: function( name ) {
13519 return this.each(function() {
13520 jQuery.removeAttr( this, name );
13521 });
13522 }
13523 });
13524
13525 jQuery.extend({
13526 attr: function( elem, name, value ) {
13527 var hooks, ret,
13528 nType = elem.nodeType;
13529
13530 // don't get/set attributes on text, comment and attribute nodes
13531 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
13532 return;
13533 }
13534
13535 // Fallback to prop when attributes are not supported
13536 if ( typeof elem.getAttribute === strundefined ) {
13537 return jQuery.prop( elem, name, value );
13538 }
13539
13540 // All attributes are lowercase
13541 // Grab necessary hook if one is defined
13542 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
13543 name = name.toLowerCase();
13544 hooks = jQuery.attrHooks[ name ] ||
13545 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
13546 }
13547
13548 if ( value !== undefined ) {
13549
13550 if ( value === null ) {
13551 jQuery.removeAttr( elem, name );
13552
13553 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
13554 return ret;
13555
13556 } else {
13557 elem.setAttribute( name, value + "" );
13558 return value;
13559 }
13560
13561 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
13562 return ret;
13563
13564 } else {
13565 ret = jQuery.find.attr( elem, name );
13566
13567 // Non-existent attributes return null, we normalize to undefined
13568 return ret == null ?
13569 undefined :
13570 ret;
13571 }
13572 },
13573
13574 removeAttr: function( elem, value ) {
13575 var name, propName,
13576 i = 0,
13577 attrNames = value && value.match( rnotwhite );
13578
13579 if ( attrNames && elem.nodeType === 1 ) {
13580 while ( (name = attrNames[i++]) ) {
13581 propName = jQuery.propFix[ name ] || name;
13582
13583 // Boolean attributes get special treatment (#10870)
13584 if ( jQuery.expr.match.bool.test( name ) ) {
13585 // Set corresponding property to false
13586 elem[ propName ] = false;
13587 }
13588
13589 elem.removeAttribute( name );
13590 }
13591 }
13592 },
13593
13594 attrHooks: {
13595 type: {
13596 set: function( elem, value ) {
13597 if ( !support.radioValue && value === "radio" &&
13598 jQuery.nodeName( elem, "input" ) ) {
13599 // Setting the type on a radio button after the value resets the value in IE6-9
13600 // Reset value to default in case type is set after value during creation
13601 var val = elem.value;
13602 elem.setAttribute( "type", value );
13603 if ( val ) {
13604 elem.value = val;
13605 }
13606 return value;
13607 }
13608 }
13609 }
13610 }
13611 });
13612
13613 // Hooks for boolean attributes
13614 boolHook = {
13615 set: function( elem, value, name ) {
13616 if ( value === false ) {
13617 // Remove boolean attributes when set to false
13618 jQuery.removeAttr( elem, name );
13619 } else {
13620 elem.setAttribute( name, name );
13621 }
13622 return name;
13623 }
13624 };
13625 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
13626 var getter = attrHandle[ name ] || jQuery.find.attr;
13627
13628 attrHandle[ name ] = function( elem, name, isXML ) {
13629 var ret, handle;
13630 if ( !isXML ) {
13631 // Avoid an infinite loop by temporarily removing this function from the getter
13632 handle = attrHandle[ name ];
13633 attrHandle[ name ] = ret;
13634 ret = getter( elem, name, isXML ) != null ?
13635 name.toLowerCase() :
13636 null;
13637 attrHandle[ name ] = handle;
13638 }
13639 return ret;
13640 };
13641 });
13642
13643
13644
13645
13646 var rfocusable = /^(?:input|select|textarea|button)$/i;
13647
13648 jQuery.fn.extend({
13649 prop: function( name, value ) {
13650 return access( this, jQuery.prop, name, value, arguments.length > 1 );
13651 },
13652
13653 removeProp: function( name ) {
13654 return this.each(function() {
13655 delete this[ jQuery.propFix[ name ] || name ];
13656 });
13657 }
13658 });
13659
13660 jQuery.extend({
13661 propFix: {
13662 "for": "htmlFor",
13663 "class": "className"
13664 },
13665
13666 prop: function( elem, name, value ) {
13667 var ret, hooks, notxml,
13668 nType = elem.nodeType;
13669
13670 // don't get/set properties on text, comment and attribute nodes
13671 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
13672 return;
13673 }
13674
13675 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
13676
13677 if ( notxml ) {
13678 // Fix name and attach hooks
13679 name = jQuery.propFix[ name ] || name;
13680 hooks = jQuery.propHooks[ name ];
13681 }
13682
13683 if ( value !== undefined ) {
13684 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
13685 ret :
13686 ( elem[ name ] = value );
13687
13688 } else {
13689 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
13690 ret :
13691 elem[ name ];
13692 }
13693 },
13694
13695 propHooks: {
13696 tabIndex: {
13697 get: function( elem ) {
13698 return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
13699 elem.tabIndex :
13700 -1;
13701 }
13702 }
13703 }
13704 });
13705
13706 // Support: IE9+
13707 // Selectedness for an option in an optgroup can be inaccurate
13708 if ( !support.optSelected ) {
13709 jQuery.propHooks.selected = {
13710 get: function( elem ) {
13711 var parent = elem.parentNode;
13712 if ( parent && parent.parentNode ) {
13713 parent.parentNode.selectedIndex;
13714 }
13715 return null;
13716 }
13717 };
13718 }
13719
13720 jQuery.each([
13721 "tabIndex",
13722 "readOnly",
13723 "maxLength",
13724 "cellSpacing",
13725 "cellPadding",
13726 "rowSpan",
13727 "colSpan",
13728 "useMap",
13729 "frameBorder",
13730 "contentEditable"
13731 ], function() {
13732 jQuery.propFix[ this.toLowerCase() ] = this;
13733 });
13734
13735
13736
13737
13738 var rclass = /[\t\r\n\f]/g;
13739
13740 jQuery.fn.extend({
13741 addClass: function( value ) {
13742 var classes, elem, cur, clazz, j, finalValue,
13743 proceed = typeof value === "string" && value,
13744 i = 0,
13745 len = this.length;
13746
13747 if ( jQuery.isFunction( value ) ) {
13748 return this.each(function( j ) {
13749 jQuery( this ).addClass( value.call( this, j, this.className ) );
13750 });
13751 }
13752
13753 if ( proceed ) {
13754 // The disjunction here is for better compressibility (see removeClass)
13755 classes = ( value || "" ).match( rnotwhite ) || [];
13756
13757 for ( ; i < len; i++ ) {
13758 elem = this[ i ];
13759 cur = elem.nodeType === 1 && ( elem.className ?
13760 ( " " + elem.className + " " ).replace( rclass, " " ) :
13761 " "
13762 );
13763
13764 if ( cur ) {
13765 j = 0;
13766 while ( (clazz = classes[j++]) ) {
13767 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
13768 cur += clazz + " ";
13769 }
13770 }
13771
13772 // only assign if different to avoid unneeded rendering.
13773 finalValue = jQuery.trim( cur );
13774 if ( elem.className !== finalValue ) {
13775 elem.className = finalValue;
13776 }
13777 }
13778 }
13779 }
13780
13781 return this;
13782 },
13783
13784 removeClass: function( value ) {
13785 var classes, elem, cur, clazz, j, finalValue,
13786 proceed = arguments.length === 0 || typeof value === "string" && value,
13787 i = 0,
13788 len = this.length;
13789
13790 if ( jQuery.isFunction( value ) ) {
13791 return this.each(function( j ) {
13792 jQuery( this ).removeClass( value.call( this, j, this.className ) );
13793 });
13794 }
13795 if ( proceed ) {
13796 classes = ( value || "" ).match( rnotwhite ) || [];
13797
13798 for ( ; i < len; i++ ) {
13799 elem = this[ i ];
13800 // This expression is here for better compressibility (see addClass)
13801 cur = elem.nodeType === 1 && ( elem.className ?
13802 ( " " + elem.className + " " ).replace( rclass, " " ) :
13803 ""
13804 );
13805
13806 if ( cur ) {
13807 j = 0;
13808 while ( (clazz = classes[j++]) ) {
13809 // Remove *all* instances
13810 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
13811 cur = cur.replace( " " + clazz + " ", " " );
13812 }
13813 }
13814
13815 // only assign if different to avoid unneeded rendering.
13816 finalValue = value ? jQuery.trim( cur ) : "";
13817 if ( elem.className !== finalValue ) {
13818 elem.className = finalValue;
13819 }
13820 }
13821 }
13822 }
13823
13824 return this;
13825 },
13826
13827 toggleClass: function( value, stateVal ) {
13828 var type = typeof value;
13829
13830 if ( typeof stateVal === "boolean" && type === "string" ) {
13831 return stateVal ? this.addClass( value ) : this.removeClass( value );
13832 }
13833
13834 if ( jQuery.isFunction( value ) ) {
13835 return this.each(function( i ) {
13836 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
13837 });
13838 }
13839
13840 return this.each(function() {
13841 if ( type === "string" ) {
13842 // toggle individual class names
13843 var className,
13844 i = 0,
13845 self = jQuery( this ),
13846 classNames = value.match( rnotwhite ) || [];
13847
13848 while ( (className = classNames[ i++ ]) ) {
13849 // check each className given, space separated list
13850 if ( self.hasClass( className ) ) {
13851 self.removeClass( className );
13852 } else {
13853 self.addClass( className );
13854 }
13855 }
13856
13857 // Toggle whole class name
13858 } else if ( type === strundefined || type === "boolean" ) {
13859 if ( this.className ) {
13860 // store className if set
13861 data_priv.set( this, "__className__", this.className );
13862 }
13863
13864 // If the element has a class name or if we're passed "false",
13865 // then remove the whole classname (if there was one, the above saved it).
13866 // Otherwise bring back whatever was previously saved (if anything),
13867 // falling back to the empty string if nothing was stored.
13868 this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
13869 }
13870 });
13871 },
13872
13873 hasClass: function( selector ) {
13874 var className = " " + selector + " ",
13875 i = 0,
13876 l = this.length;
13877 for ( ; i < l; i++ ) {
13878 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
13879 return true;
13880 }
13881 }
13882
13883 return false;
13884 }
13885 });
13886
13887
13888
13889
13890 var rreturn = /\r/g;
13891
13892 jQuery.fn.extend({
13893 val: function( value ) {
13894 var hooks, ret, isFunction,
13895 elem = this[0];
13896
13897 if ( !arguments.length ) {
13898 if ( elem ) {
13899 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
13900
13901 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
13902 return ret;
13903 }
13904
13905 ret = elem.value;
13906
13907 return typeof ret === "string" ?
13908 // handle most common string cases
13909 ret.replace(rreturn, "") :
13910 // handle cases where value is null/undef or number
13911 ret == null ? "" : ret;
13912 }
13913
13914 return;
13915 }
13916
13917 isFunction = jQuery.isFunction( value );
13918
13919 return this.each(function( i ) {
13920 var val;
13921
13922 if ( this.nodeType !== 1 ) {
13923 return;
13924 }
13925
13926 if ( isFunction ) {
13927 val = value.call( this, i, jQuery( this ).val() );
13928 } else {
13929 val = value;
13930 }
13931
13932 // Treat null/undefined as ""; convert numbers to string
13933 if ( val == null ) {
13934 val = "";
13935
13936 } else if ( typeof val === "number" ) {
13937 val += "";
13938
13939 } else if ( jQuery.isArray( val ) ) {
13940 val = jQuery.map( val, function( value ) {
13941 return value == null ? "" : value + "";
13942 });
13943 }
13944
13945 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
13946
13947 // If set returns undefined, fall back to normal setting
13948 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
13949 this.value = val;
13950 }
13951 });
13952 }
13953 });
13954
13955 jQuery.extend({
13956 valHooks: {
13957 option: {
13958 get: function( elem ) {
13959 var val = jQuery.find.attr( elem, "value" );
13960 return val != null ?
13961 val :
13962 // Support: IE10-11+
13963 // option.text throws exceptions (#14686, #14858)
13964 jQuery.trim( jQuery.text( elem ) );
13965 }
13966 },
13967 select: {
13968 get: function( elem ) {
13969 var value, option,
13970 options = elem.options,
13971 index = elem.selectedIndex,
13972 one = elem.type === "select-one" || index < 0,
13973 values = one ? null : [],
13974 max = one ? index + 1 : options.length,
13975 i = index < 0 ?
13976 max :
13977 one ? index : 0;
13978
13979 // Loop through all the selected options
13980 for ( ; i < max; i++ ) {
13981 option = options[ i ];
13982
13983 // IE6-9 doesn't update selected after form reset (#2551)
13984 if ( ( option.selected || i === index ) &&
13985 // Don't return options that are disabled or in a disabled optgroup
13986 ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) &&
13987 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
13988
13989 // Get the specific value for the option
13990 value = jQuery( option ).val();
13991
13992 // We don't need an array for one selects
13993 if ( one ) {
13994 return value;
13995 }
13996
13997 // Multi-Selects return an array
13998 values.push( value );
13999 }
14000 }
14001
14002 return values;
14003 },
14004
14005 set: function( elem, value ) {
14006 var optionSet, option,
14007 options = elem.options,
14008 values = jQuery.makeArray( value ),
14009 i = options.length;
14010
14011 while ( i-- ) {
14012 option = options[ i ];
14013 if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) {
14014 optionSet = true;
14015 }
14016 }
14017
14018 // force browsers to behave consistently when non-matching value is set
14019 if ( !optionSet ) {
14020 elem.selectedIndex = -1;
14021 }
14022 return values;
14023 }
14024 }
14025 }
14026 });
14027
14028 // Radios and checkboxes getter/setter
14029 jQuery.each([ "radio", "checkbox" ], function() {
14030 jQuery.valHooks[ this ] = {
14031 set: function( elem, value ) {
14032 if ( jQuery.isArray( value ) ) {
14033 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
14034 }
14035 }
14036 };
14037 if ( !support.checkOn ) {
14038 jQuery.valHooks[ this ].get = function( elem ) {
14039 // Support: Webkit
14040 // "" is returned instead of "on" if a value isn't specified
14041 return elem.getAttribute("value") === null ? "on" : elem.value;
14042 };
14043 }
14044 });
14045
14046
14047
14048
14049 // Return jQuery for attributes-only inclusion
14050
14051
14052 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
14053 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
14054 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
14055
14056 // Handle event binding
14057 jQuery.fn[ name ] = function( data, fn ) {
14058 return arguments.length > 0 ?
14059 this.on( name, null, data, fn ) :
14060 this.trigger( name );
14061 };
14062 });
14063
14064 jQuery.fn.extend({
14065 hover: function( fnOver, fnOut ) {
14066 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
14067 },
14068
14069 bind: function( types, data, fn ) {
14070 return this.on( types, null, data, fn );
14071 },
14072 unbind: function( types, fn ) {
14073 return this.off( types, null, fn );
14074 },
14075
14076 delegate: function( selector, types, data, fn ) {
14077 return this.on( types, selector, data, fn );
14078 },
14079 undelegate: function( selector, types, fn ) {
14080 // ( namespace ) or ( selector, types [, fn] )
14081 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
14082 }
14083 });
14084
14085
14086 var nonce = jQuery.now();
14087
14088 var rquery = (/\?/);
14089
14090
14091
14092 // Support: Android 2.3
14093 // Workaround failure to string-cast null input
14094 jQuery.parseJSON = function( data ) {
14095 return JSON.parse( data + "" );
14096 };
14097
14098
14099 // Cross-browser xml parsing
14100 jQuery.parseXML = function( data ) {
14101 var xml, tmp;
14102 if ( !data || typeof data !== "string" ) {
14103 return null;
14104 }
14105
14106 // Support: IE9
14107 try {
14108 tmp = new DOMParser();
14109 xml = tmp.parseFromString( data, "text/xml" );
14110 } catch ( e ) {
14111 xml = undefined;
14112 }
14113
14114 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
14115 jQuery.error( "Invalid XML: " + data );
14116 }
14117 return xml;
14118 };
14119
14120
14121 var
14122 // Document location
14123 ajaxLocParts,
14124 ajaxLocation,
14125
14126 rhash = /#.*$/,
14127 rts = /([?&])_=[^&]*/,
14128 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
14129 // #7653, #8125, #8152: local protocol detection
14130 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
14131 rnoContent = /^(?:GET|HEAD)$/,
14132 rprotocol = /^\/\//,
14133 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
14134
14135 /* Prefilters
14136 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
14137 * 2) These are called:
14138 * - BEFORE asking for a transport
14139 * - AFTER param serialization (s.data is a string if s.processData is true)
14140 * 3) key is the dataType
14141 * 4) the catchall symbol "*" can be used
14142 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
14143 */
14144 prefilters = {},
14145
14146 /* Transports bindings
14147 * 1) key is the dataType
14148 * 2) the catchall symbol "*" can be used
14149 * 3) selection will start with transport dataType and THEN go to "*" if needed
14150 */
14151 transports = {},
14152
14153 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
14154 allTypes = "*/".concat("*");
14155
14156 // #8138, IE may throw an exception when accessing
14157 // a field from window.location if document.domain has been set
14158 try {
14159 ajaxLocation = location.href;
14160 } catch( e ) {
14161 // Use the href attribute of an A element
14162 // since IE will modify it given document.location
14163 ajaxLocation = document.createElement( "a" );
14164 ajaxLocation.href = "";
14165 ajaxLocation = ajaxLocation.href;
14166 }
14167
14168 // Segment location into parts
14169 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
14170
14171 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
14172 function addToPrefiltersOrTransports( structure ) {
14173
14174 // dataTypeExpression is optional and defaults to "*"
14175 return function( dataTypeExpression, func ) {
14176
14177 if ( typeof dataTypeExpression !== "string" ) {
14178 func = dataTypeExpression;
14179 dataTypeExpression = "*";
14180 }
14181
14182 var dataType,
14183 i = 0,
14184 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
14185
14186 if ( jQuery.isFunction( func ) ) {
14187 // For each dataType in the dataTypeExpression
14188 while ( (dataType = dataTypes[i++]) ) {
14189 // Prepend if requested
14190 if ( dataType[0] === "+" ) {
14191 dataType = dataType.slice( 1 ) || "*";
14192 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
14193
14194 // Otherwise append
14195 } else {
14196 (structure[ dataType ] = structure[ dataType ] || []).push( func );
14197 }
14198 }
14199 }
14200 };
14201 }
14202
14203 // Base inspection function for prefilters and transports
14204 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
14205
14206 var inspected = {},
14207 seekingTransport = ( structure === transports );
14208
14209 function inspect( dataType ) {
14210 var selected;
14211 inspected[ dataType ] = true;
14212 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
14213 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
14214 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
14215 options.dataTypes.unshift( dataTypeOrTransport );
14216 inspect( dataTypeOrTransport );
14217 return false;
14218 } else if ( seekingTransport ) {
14219 return !( selected = dataTypeOrTransport );
14220 }
14221 });
14222 return selected;
14223 }
14224
14225 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
14226 }
14227
14228 // A special extend for ajax options
14229 // that takes "flat" options (not to be deep extended)
14230 // Fixes #9887
14231 function ajaxExtend( target, src ) {
14232 var key, deep,
14233 flatOptions = jQuery.ajaxSettings.flatOptions || {};
14234
14235 for ( key in src ) {
14236 if ( src[ key ] !== undefined ) {
14237 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
14238 }
14239 }
14240 if ( deep ) {
14241 jQuery.extend( true, target, deep );
14242 }
14243
14244 return target;
14245 }
14246
14247 /* Handles responses to an ajax request:
14248 * - finds the right dataType (mediates between content-type and expected dataType)
14249 * - returns the corresponding response
14250 */
14251 function ajaxHandleResponses( s, jqXHR, responses ) {
14252
14253 var ct, type, finalDataType, firstDataType,
14254 contents = s.contents,
14255 dataTypes = s.dataTypes;
14256
14257 // Remove auto dataType and get content-type in the process
14258 while ( dataTypes[ 0 ] === "*" ) {
14259 dataTypes.shift();
14260 if ( ct === undefined ) {
14261 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
14262 }
14263 }
14264
14265 // Check if we're dealing with a known content-type
14266 if ( ct ) {
14267 for ( type in contents ) {
14268 if ( contents[ type ] && contents[ type ].test( ct ) ) {
14269 dataTypes.unshift( type );
14270 break;
14271 }
14272 }
14273 }
14274
14275 // Check to see if we have a response for the expected dataType
14276 if ( dataTypes[ 0 ] in responses ) {
14277 finalDataType = dataTypes[ 0 ];
14278 } else {
14279 // Try convertible dataTypes
14280 for ( type in responses ) {
14281 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
14282 finalDataType = type;
14283 break;
14284 }
14285 if ( !firstDataType ) {
14286 firstDataType = type;
14287 }
14288 }
14289 // Or just use first one
14290 finalDataType = finalDataType || firstDataType;
14291 }
14292
14293 // If we found a dataType
14294 // We add the dataType to the list if needed
14295 // and return the corresponding response
14296 if ( finalDataType ) {
14297 if ( finalDataType !== dataTypes[ 0 ] ) {
14298 dataTypes.unshift( finalDataType );
14299 }
14300 return responses[ finalDataType ];
14301 }
14302 }
14303
14304 /* Chain conversions given the request and the original response
14305 * Also sets the responseXXX fields on the jqXHR instance
14306 */
14307 function ajaxConvert( s, response, jqXHR, isSuccess ) {
14308 var conv2, current, conv, tmp, prev,
14309 converters = {},
14310 // Work with a copy of dataTypes in case we need to modify it for conversion
14311 dataTypes = s.dataTypes.slice();
14312
14313 // Create converters map with lowercased keys
14314 if ( dataTypes[ 1 ] ) {
14315 for ( conv in s.converters ) {
14316 converters[ conv.toLowerCase() ] = s.converters[ conv ];
14317 }
14318 }
14319
14320 current = dataTypes.shift();
14321
14322 // Convert to each sequential dataType
14323 while ( current ) {
14324
14325 if ( s.responseFields[ current ] ) {
14326 jqXHR[ s.responseFields[ current ] ] = response;
14327 }
14328
14329 // Apply the dataFilter if provided
14330 if ( !prev && isSuccess && s.dataFilter ) {
14331 response = s.dataFilter( response, s.dataType );
14332 }
14333
14334 prev = current;
14335 current = dataTypes.shift();
14336
14337 if ( current ) {
14338
14339 // There's only work to do if current dataType is non-auto
14340 if ( current === "*" ) {
14341
14342 current = prev;
14343
14344 // Convert response if prev dataType is non-auto and differs from current
14345 } else if ( prev !== "*" && prev !== current ) {
14346
14347 // Seek a direct converter
14348 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
14349
14350 // If none found, seek a pair
14351 if ( !conv ) {
14352 for ( conv2 in converters ) {
14353
14354 // If conv2 outputs current
14355 tmp = conv2.split( " " );
14356 if ( tmp[ 1 ] === current ) {
14357
14358 // If prev can be converted to accepted input
14359 conv = converters[ prev + " " + tmp[ 0 ] ] ||
14360 converters[ "* " + tmp[ 0 ] ];
14361 if ( conv ) {
14362 // Condense equivalence converters
14363 if ( conv === true ) {
14364 conv = converters[ conv2 ];
14365
14366 // Otherwise, insert the intermediate dataType
14367 } else if ( converters[ conv2 ] !== true ) {
14368 current = tmp[ 0 ];
14369 dataTypes.unshift( tmp[ 1 ] );
14370 }
14371 break;
14372 }
14373 }
14374 }
14375 }
14376
14377 // Apply converter (if not an equivalence)
14378 if ( conv !== true ) {
14379
14380 // Unless errors are allowed to bubble, catch and return them
14381 if ( conv && s[ "throws" ] ) {
14382 response = conv( response );
14383 } else {
14384 try {
14385 response = conv( response );
14386 } catch ( e ) {
14387 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
14388 }
14389 }
14390 }
14391 }
14392 }
14393 }
14394
14395 return { state: "success", data: response };
14396 }
14397
14398 jQuery.extend({
14399
14400 // Counter for holding the number of active queries
14401 active: 0,
14402
14403 // Last-Modified header cache for next request
14404 lastModified: {},
14405 etag: {},
14406
14407 ajaxSettings: {
14408 url: ajaxLocation,
14409 type: "GET",
14410 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
14411 global: true,
14412 processData: true,
14413 async: true,
14414 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
14415 /*
14416 timeout: 0,
14417 data: null,
14418 dataType: null,
14419 username: null,
14420 password: null,
14421 cache: null,
14422 throws: false,
14423 traditional: false,
14424 headers: {},
14425 */
14426
14427 accepts: {
14428 "*": allTypes,
14429 text: "text/plain",
14430 html: "text/html",
14431 xml: "application/xml, text/xml",
14432 json: "application/json, text/javascript"
14433 },
14434
14435 contents: {
14436 xml: /xml/,
14437 html: /html/,
14438 json: /json/
14439 },
14440
14441 responseFields: {
14442 xml: "responseXML",
14443 text: "responseText",
14444 json: "responseJSON"
14445 },
14446
14447 // Data converters
14448 // Keys separate source (or catchall "*") and destination types with a single space
14449 converters: {
14450
14451 // Convert anything to text
14452 "* text": String,
14453
14454 // Text to html (true = no transformation)
14455 "text html": true,
14456
14457 // Evaluate text as a json expression
14458 "text json": jQuery.parseJSON,
14459
14460 // Parse text as xml
14461 "text xml": jQuery.parseXML
14462 },
14463
14464 // For options that shouldn't be deep extended:
14465 // you can add your own custom options here if
14466 // and when you create one that shouldn't be
14467 // deep extended (see ajaxExtend)
14468 flatOptions: {
14469 url: true,
14470 context: true
14471 }
14472 },
14473
14474 // Creates a full fledged settings object into target
14475 // with both ajaxSettings and settings fields.
14476 // If target is omitted, writes into ajaxSettings.
14477 ajaxSetup: function( target, settings ) {
14478 return settings ?
14479
14480 // Building a settings object
14481 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
14482
14483 // Extending ajaxSettings
14484 ajaxExtend( jQuery.ajaxSettings, target );
14485 },
14486
14487 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
14488 ajaxTransport: addToPrefiltersOrTransports( transports ),
14489
14490 // Main method
14491 ajax: function( url, options ) {
14492
14493 // If url is an object, simulate pre-1.5 signature
14494 if ( typeof url === "object" ) {
14495 options = url;
14496 url = undefined;
14497 }
14498
14499 // Force options to be an object
14500 options = options || {};
14501
14502 var transport,
14503 // URL without anti-cache param
14504 cacheURL,
14505 // Response headers
14506 responseHeadersString,
14507 responseHeaders,
14508 // timeout handle
14509 timeoutTimer,
14510 // Cross-domain detection vars
14511 parts,
14512 // To know if global events are to be dispatched
14513 fireGlobals,
14514 // Loop variable
14515 i,
14516 // Create the final options object
14517 s = jQuery.ajaxSetup( {}, options ),
14518 // Callbacks context
14519 callbackContext = s.context || s,
14520 // Context for global events is callbackContext if it is a DOM node or jQuery collection
14521 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
14522 jQuery( callbackContext ) :
14523 jQuery.event,
14524 // Deferreds
14525 deferred = jQuery.Deferred(),
14526 completeDeferred = jQuery.Callbacks("once memory"),
14527 // Status-dependent callbacks
14528 statusCode = s.statusCode || {},
14529 // Headers (they are sent all at once)
14530 requestHeaders = {},
14531 requestHeadersNames = {},
14532 // The jqXHR state
14533 state = 0,
14534 // Default abort message
14535 strAbort = "canceled",
14536 // Fake xhr
14537 jqXHR = {
14538 readyState: 0,
14539
14540 // Builds headers hashtable if needed
14541 getResponseHeader: function( key ) {
14542 var match;
14543 if ( state === 2 ) {
14544 if ( !responseHeaders ) {
14545 responseHeaders = {};
14546 while ( (match = rheaders.exec( responseHeadersString )) ) {
14547 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
14548 }
14549 }
14550 match = responseHeaders[ key.toLowerCase() ];
14551 }
14552 return match == null ? null : match;
14553 },
14554
14555 // Raw string
14556 getAllResponseHeaders: function() {
14557 return state === 2 ? responseHeadersString : null;
14558 },
14559
14560 // Caches the header
14561 setRequestHeader: function( name, value ) {
14562 var lname = name.toLowerCase();
14563 if ( !state ) {
14564 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
14565 requestHeaders[ name ] = value;
14566 }
14567 return this;
14568 },
14569
14570 // Overrides response content-type header
14571 overrideMimeType: function( type ) {
14572 if ( !state ) {
14573 s.mimeType = type;
14574 }
14575 return this;
14576 },
14577
14578 // Status-dependent callbacks
14579 statusCode: function( map ) {
14580 var code;
14581 if ( map ) {
14582 if ( state < 2 ) {
14583 for ( code in map ) {
14584 // Lazy-add the new callback in a way that preserves old ones
14585 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
14586 }
14587 } else {
14588 // Execute the appropriate callbacks
14589 jqXHR.always( map[ jqXHR.status ] );
14590 }
14591 }
14592 return this;
14593 },
14594
14595 // Cancel the request
14596 abort: function( statusText ) {
14597 var finalText = statusText || strAbort;
14598 if ( transport ) {
14599 transport.abort( finalText );
14600 }
14601 done( 0, finalText );
14602 return this;
14603 }
14604 };
14605
14606 // Attach deferreds
14607 deferred.promise( jqXHR ).complete = completeDeferred.add;
14608 jqXHR.success = jqXHR.done;
14609 jqXHR.error = jqXHR.fail;
14610
14611 // Remove hash character (#7531: and string promotion)
14612 // Add protocol if not provided (prefilters might expect it)
14613 // Handle falsy url in the settings object (#10093: consistency with old signature)
14614 // We also use the url parameter if available
14615 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" )
14616 .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
14617
14618 // Alias method option to type as per ticket #12004
14619 s.type = options.method || options.type || s.method || s.type;
14620
14621 // Extract dataTypes list
14622 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
14623
14624 // A cross-domain request is in order when we have a protocol:host:port mismatch
14625 if ( s.crossDomain == null ) {
14626 parts = rurl.exec( s.url.toLowerCase() );
14627 s.crossDomain = !!( parts &&
14628 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
14629 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
14630 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
14631 );
14632 }
14633
14634 // Convert data if not already a string
14635 if ( s.data && s.processData && typeof s.data !== "string" ) {
14636 s.data = jQuery.param( s.data, s.traditional );
14637 }
14638
14639 // Apply prefilters
14640 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
14641
14642 // If request was aborted inside a prefilter, stop there
14643 if ( state === 2 ) {
14644 return jqXHR;
14645 }
14646
14647 // We can fire global events as of now if asked to
14648 fireGlobals = s.global;
14649
14650 // Watch for a new set of requests
14651 if ( fireGlobals && jQuery.active++ === 0 ) {
14652 jQuery.event.trigger("ajaxStart");
14653 }
14654
14655 // Uppercase the type
14656 s.type = s.type.toUpperCase();
14657
14658 // Determine if request has content
14659 s.hasContent = !rnoContent.test( s.type );
14660
14661 // Save the URL in case we're toying with the If-Modified-Since
14662 // and/or If-None-Match header later on
14663 cacheURL = s.url;
14664
14665 // More options handling for requests with no content
14666 if ( !s.hasContent ) {
14667
14668 // If data is available, append data to url
14669 if ( s.data ) {
14670 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
14671 // #9682: remove data so that it's not used in an eventual retry
14672 delete s.data;
14673 }
14674
14675 // Add anti-cache in url if needed
14676 if ( s.cache === false ) {
14677 s.url = rts.test( cacheURL ) ?
14678
14679 // If there is already a '_' parameter, set its value
14680 cacheURL.replace( rts, "$1_=" + nonce++ ) :
14681
14682 // Otherwise add one to the end
14683 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
14684 }
14685 }
14686
14687 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
14688 if ( s.ifModified ) {
14689 if ( jQuery.lastModified[ cacheURL ] ) {
14690 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
14691 }
14692 if ( jQuery.etag[ cacheURL ] ) {
14693 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
14694 }
14695 }
14696
14697 // Set the correct header, if data is being sent
14698 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
14699 jqXHR.setRequestHeader( "Content-Type", s.contentType );
14700 }
14701
14702 // Set the Accepts header for the server, depending on the dataType
14703 jqXHR.setRequestHeader(
14704 "Accept",
14705 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
14706 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
14707 s.accepts[ "*" ]
14708 );
14709
14710 // Check for headers option
14711 for ( i in s.headers ) {
14712 jqXHR.setRequestHeader( i, s.headers[ i ] );
14713 }
14714
14715 // Allow custom headers/mimetypes and early abort
14716 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
14717 // Abort if not done already and return
14718 return jqXHR.abort();
14719 }
14720
14721 // aborting is no longer a cancellation
14722 strAbort = "abort";
14723
14724 // Install callbacks on deferreds
14725 for ( i in { success: 1, error: 1, complete: 1 } ) {
14726 jqXHR[ i ]( s[ i ] );
14727 }
14728
14729 // Get transport
14730 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
14731
14732 // If no transport, we auto-abort
14733 if ( !transport ) {
14734 done( -1, "No Transport" );
14735 } else {
14736 jqXHR.readyState = 1;
14737
14738 // Send global event
14739 if ( fireGlobals ) {
14740 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
14741 }
14742 // Timeout
14743 if ( s.async && s.timeout > 0 ) {
14744 timeoutTimer = setTimeout(function() {
14745 jqXHR.abort("timeout");
14746 }, s.timeout );
14747 }
14748
14749 try {
14750 state = 1;
14751 transport.send( requestHeaders, done );
14752 } catch ( e ) {
14753 // Propagate exception as error if not done
14754 if ( state < 2 ) {
14755 done( -1, e );
14756 // Simply rethrow otherwise
14757 } else {
14758 throw e;
14759 }
14760 }
14761 }
14762
14763 // Callback for when everything is done
14764 function done( status, nativeStatusText, responses, headers ) {
14765 var isSuccess, success, error, response, modified,
14766 statusText = nativeStatusText;
14767
14768 // Called once
14769 if ( state === 2 ) {
14770 return;
14771 }
14772
14773 // State is "done" now
14774 state = 2;
14775
14776 // Clear timeout if it exists
14777 if ( timeoutTimer ) {
14778 clearTimeout( timeoutTimer );
14779 }
14780
14781 // Dereference transport for early garbage collection
14782 // (no matter how long the jqXHR object will be used)
14783 transport = undefined;
14784
14785 // Cache response headers
14786 responseHeadersString = headers || "";
14787
14788 // Set readyState
14789 jqXHR.readyState = status > 0 ? 4 : 0;
14790
14791 // Determine if successful
14792 isSuccess = status >= 200 && status < 300 || status === 304;
14793
14794 // Get response data
14795 if ( responses ) {
14796 response = ajaxHandleResponses( s, jqXHR, responses );
14797 }
14798
14799 // Convert no matter what (that way responseXXX fields are always set)
14800 response = ajaxConvert( s, response, jqXHR, isSuccess );
14801
14802 // If successful, handle type chaining
14803 if ( isSuccess ) {
14804
14805 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
14806 if ( s.ifModified ) {
14807 modified = jqXHR.getResponseHeader("Last-Modified");
14808 if ( modified ) {
14809 jQuery.lastModified[ cacheURL ] = modified;
14810 }
14811 modified = jqXHR.getResponseHeader("etag");
14812 if ( modified ) {
14813 jQuery.etag[ cacheURL ] = modified;
14814 }
14815 }
14816
14817 // if no content
14818 if ( status === 204 || s.type === "HEAD" ) {
14819 statusText = "nocontent";
14820
14821 // if not modified
14822 } else if ( status === 304 ) {
14823 statusText = "notmodified";
14824
14825 // If we have data, let's convert it
14826 } else {
14827 statusText = response.state;
14828 success = response.data;
14829 error = response.error;
14830 isSuccess = !error;
14831 }
14832 } else {
14833 // We extract error from statusText
14834 // then normalize statusText and status for non-aborts
14835 error = statusText;
14836 if ( status || !statusText ) {
14837 statusText = "error";
14838 if ( status < 0 ) {
14839 status = 0;
14840 }
14841 }
14842 }
14843
14844 // Set data for the fake xhr object
14845 jqXHR.status = status;
14846 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
14847
14848 // Success/Error
14849 if ( isSuccess ) {
14850 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
14851 } else {
14852 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
14853 }
14854
14855 // Status-dependent callbacks
14856 jqXHR.statusCode( statusCode );
14857 statusCode = undefined;
14858
14859 if ( fireGlobals ) {
14860 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
14861 [ jqXHR, s, isSuccess ? success : error ] );
14862 }
14863
14864 // Complete
14865 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
14866
14867 if ( fireGlobals ) {
14868 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
14869 // Handle the global AJAX counter
14870 if ( !( --jQuery.active ) ) {
14871 jQuery.event.trigger("ajaxStop");
14872 }
14873 }
14874 }
14875
14876 return jqXHR;
14877 },
14878
14879 getJSON: function( url, data, callback ) {
14880 return jQuery.get( url, data, callback, "json" );
14881 },
14882
14883 getScript: function( url, callback ) {
14884 return jQuery.get( url, undefined, callback, "script" );
14885 }
14886 });
14887
14888 jQuery.each( [ "get", "post" ], function( i, method ) {
14889 jQuery[ method ] = function( url, data, callback, type ) {
14890 // shift arguments if data argument was omitted
14891 if ( jQuery.isFunction( data ) ) {
14892 type = type || callback;
14893 callback = data;
14894 data = undefined;
14895 }
14896
14897 return jQuery.ajax({
14898 url: url,
14899 type: method,
14900 dataType: type,
14901 data: data,
14902 success: callback
14903 });
14904 };
14905 });
14906
14907 // Attach a bunch of functions for handling common AJAX events
14908 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
14909 jQuery.fn[ type ] = function( fn ) {
14910 return this.on( type, fn );
14911 };
14912 });
14913
14914
14915 jQuery._evalUrl = function( url ) {
14916 return jQuery.ajax({
14917 url: url,
14918 type: "GET",
14919 dataType: "script",
14920 async: false,
14921 global: false,
14922 "throws": true
14923 });
14924 };
14925
14926
14927 jQuery.fn.extend({
14928 wrapAll: function( html ) {
14929 var wrap;
14930
14931 if ( jQuery.isFunction( html ) ) {
14932 return this.each(function( i ) {
14933 jQuery( this ).wrapAll( html.call(this, i) );
14934 });
14935 }
14936
14937 if ( this[ 0 ] ) {
14938
14939 // The elements to wrap the target around
14940 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
14941
14942 if ( this[ 0 ].parentNode ) {
14943 wrap.insertBefore( this[ 0 ] );
14944 }
14945
14946 wrap.map(function() {
14947 var elem = this;
14948
14949 while ( elem.firstElementChild ) {
14950 elem = elem.firstElementChild;
14951 }
14952
14953 return elem;
14954 }).append( this );
14955 }
14956
14957 return this;
14958 },
14959
14960 wrapInner: function( html ) {
14961 if ( jQuery.isFunction( html ) ) {
14962 return this.each(function( i ) {
14963 jQuery( this ).wrapInner( html.call(this, i) );
14964 });
14965 }
14966
14967 return this.each(function() {
14968 var self = jQuery( this ),
14969 contents = self.contents();
14970
14971 if ( contents.length ) {
14972 contents.wrapAll( html );
14973
14974 } else {
14975 self.append( html );
14976 }
14977 });
14978 },
14979
14980 wrap: function( html ) {
14981 var isFunction = jQuery.isFunction( html );
14982
14983 return this.each(function( i ) {
14984 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
14985 });
14986 },
14987
14988 unwrap: function() {
14989 return this.parent().each(function() {
14990 if ( !jQuery.nodeName( this, "body" ) ) {
14991 jQuery( this ).replaceWith( this.childNodes );
14992 }
14993 }).end();
14994 }
14995 });
14996
14997
14998 jQuery.expr.filters.hidden = function( elem ) {
14999 // Support: Opera <= 12.12
15000 // Opera reports offsetWidths and offsetHeights less than zero on some elements
15001 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;
15002 };
15003 jQuery.expr.filters.visible = function( elem ) {
15004 return !jQuery.expr.filters.hidden( elem );
15005 };
15006
15007
15008
15009
15010 var r20 = /%20/g,
15011 rbracket = /\[\]$/,
15012 rCRLF = /\r?\n/g,
15013 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
15014 rsubmittable = /^(?:input|select|textarea|keygen)/i;
15015
15016 function buildParams( prefix, obj, traditional, add ) {
15017 var name;
15018
15019 if ( jQuery.isArray( obj ) ) {
15020 // Serialize array item.
15021 jQuery.each( obj, function( i, v ) {
15022 if ( traditional || rbracket.test( prefix ) ) {
15023 // Treat each array item as a scalar.
15024 add( prefix, v );
15025
15026 } else {
15027 // Item is non-scalar (array or object), encode its numeric index.
15028 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
15029 }
15030 });
15031
15032 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
15033 // Serialize object item.
15034 for ( name in obj ) {
15035 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
15036 }
15037
15038 } else {
15039 // Serialize scalar item.
15040 add( prefix, obj );
15041 }
15042 }
15043
15044 // Serialize an array of form elements or a set of
15045 // key/values into a query string
15046 jQuery.param = function( a, traditional ) {
15047 var prefix,
15048 s = [],
15049 add = function( key, value ) {
15050 // If value is a function, invoke it and return its value
15051 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
15052 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
15053 };
15054
15055 // Set traditional to true for jQuery <= 1.3.2 behavior.
15056 if ( traditional === undefined ) {
15057 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
15058 }
15059
15060 // If an array was passed in, assume that it is an array of form elements.
15061 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
15062 // Serialize the form elements
15063 jQuery.each( a, function() {
15064 add( this.name, this.value );
15065 });
15066
15067 } else {
15068 // If traditional, encode the "old" way (the way 1.3.2 or older
15069 // did it), otherwise encode params recursively.
15070 for ( prefix in a ) {
15071 buildParams( prefix, a[ prefix ], traditional, add );
15072 }
15073 }
15074
15075 // Return the resulting serialization
15076 return s.join( "&" ).replace( r20, "+" );
15077 };
15078
15079 jQuery.fn.extend({
15080 serialize: function() {
15081 return jQuery.param( this.serializeArray() );
15082 },
15083 serializeArray: function() {
15084 return this.map(function() {
15085 // Can add propHook for "elements" to filter or add form elements
15086 var elements = jQuery.prop( this, "elements" );
15087 return elements ? jQuery.makeArray( elements ) : this;
15088 })
15089 .filter(function() {
15090 var type = this.type;
15091
15092 // Use .is( ":disabled" ) so that fieldset[disabled] works
15093 return this.name && !jQuery( this ).is( ":disabled" ) &&
15094 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
15095 ( this.checked || !rcheckableType.test( type ) );
15096 })
15097 .map(function( i, elem ) {
15098 var val = jQuery( this ).val();
15099
15100 return val == null ?
15101 null :
15102 jQuery.isArray( val ) ?
15103 jQuery.map( val, function( val ) {
15104 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
15105 }) :
15106 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
15107 }).get();
15108 }
15109 });
15110
15111
15112 jQuery.ajaxSettings.xhr = function() {
15113 try {
15114 return new XMLHttpRequest();
15115 } catch( e ) {}
15116 };
15117
15118 var xhrId = 0,
15119 xhrCallbacks = {},
15120 xhrSuccessStatus = {
15121 // file protocol always yields status code 0, assume 200
15122 0: 200,
15123 // Support: IE9
15124 // #1450: sometimes IE returns 1223 when it should be 204
15125 1223: 204
15126 },
15127 xhrSupported = jQuery.ajaxSettings.xhr();
15128
15129 // Support: IE9
15130 // Open requests must be manually aborted on unload (#5280)
15131 if ( window.ActiveXObject ) {
15132 jQuery( window ).on( "unload", function() {
15133 for ( var key in xhrCallbacks ) {
15134 xhrCallbacks[ key ]();
15135 }
15136 });
15137 }
15138
15139 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
15140 support.ajax = xhrSupported = !!xhrSupported;
15141
15142 jQuery.ajaxTransport(function( options ) {
15143 var callback;
15144
15145 // Cross domain only allowed if supported through XMLHttpRequest
15146 if ( support.cors || xhrSupported && !options.crossDomain ) {
15147 return {
15148 send: function( headers, complete ) {
15149 var i,
15150 xhr = options.xhr(),
15151 id = ++xhrId;
15152
15153 xhr.open( options.type, options.url, options.async, options.username, options.password );
15154
15155 // Apply custom fields if provided
15156 if ( options.xhrFields ) {
15157 for ( i in options.xhrFields ) {
15158 xhr[ i ] = options.xhrFields[ i ];
15159 }
15160 }
15161
15162 // Override mime type if needed
15163 if ( options.mimeType && xhr.overrideMimeType ) {
15164 xhr.overrideMimeType( options.mimeType );
15165 }
15166
15167 // X-Requested-With header
15168 // For cross-domain requests, seeing as conditions for a preflight are
15169 // akin to a jigsaw puzzle, we simply never set it to be sure.
15170 // (it can always be set on a per-request basis or even using ajaxSetup)
15171 // For same-domain requests, won't change header if already provided.
15172 if ( !options.crossDomain && !headers["X-Requested-With"] ) {
15173 headers["X-Requested-With"] = "XMLHttpRequest";
15174 }
15175
15176 // Set headers
15177 for ( i in headers ) {
15178 xhr.setRequestHeader( i, headers[ i ] );
15179 }
15180
15181 // Callback
15182 callback = function( type ) {
15183 return function() {
15184 if ( callback ) {
15185 delete xhrCallbacks[ id ];
15186 callback = xhr.onload = xhr.onerror = null;
15187
15188 if ( type === "abort" ) {
15189 xhr.abort();
15190 } else if ( type === "error" ) {
15191 complete(
15192 // file: protocol always yields status 0; see #8605, #14207
15193 xhr.status,
15194 xhr.statusText
15195 );
15196 } else {
15197 complete(
15198 xhrSuccessStatus[ xhr.status ] || xhr.status,
15199 xhr.statusText,
15200 // Support: IE9
15201 // Accessing binary-data responseText throws an exception
15202 // (#11426)
15203 typeof xhr.responseText === "string" ? {
15204 text: xhr.responseText
15205 } : undefined,
15206 xhr.getAllResponseHeaders()
15207 );
15208 }
15209 }
15210 };
15211 };
15212
15213 // Listen to events
15214 xhr.onload = callback();
15215 xhr.onerror = callback("error");
15216
15217 // Create the abort callback
15218 callback = xhrCallbacks[ id ] = callback("abort");
15219
15220 try {
15221 // Do send the request (this may raise an exception)
15222 xhr.send( options.hasContent && options.data || null );
15223 } catch ( e ) {
15224 // #14683: Only rethrow if this hasn't been notified as an error yet
15225 if ( callback ) {
15226 throw e;
15227 }
15228 }
15229 },
15230
15231 abort: function() {
15232 if ( callback ) {
15233 callback();
15234 }
15235 }
15236 };
15237 }
15238 });
15239
15240
15241
15242
15243 // Install script dataType
15244 jQuery.ajaxSetup({
15245 accepts: {
15246 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
15247 },
15248 contents: {
15249 script: /(?:java|ecma)script/
15250 },
15251 converters: {
15252 "text script": function( text ) {
15253 jQuery.globalEval( text );
15254 return text;
15255 }
15256 }
15257 });
15258
15259 // Handle cache's special case and crossDomain
15260 jQuery.ajaxPrefilter( "script", function( s ) {
15261 if ( s.cache === undefined ) {
15262 s.cache = false;
15263 }
15264 if ( s.crossDomain ) {
15265 s.type = "GET";
15266 }
15267 });
15268
15269 // Bind script tag hack transport
15270 jQuery.ajaxTransport( "script", function( s ) {
15271 // This transport only deals with cross domain requests
15272 if ( s.crossDomain ) {
15273 var script, callback;
15274 return {
15275 send: function( _, complete ) {
15276 script = jQuery("<script>").prop({
15277 async: true,
15278 charset: s.scriptCharset,
15279 src: s.url
15280 }).on(
15281 "load error",
15282 callback = function( evt ) {
15283 script.remove();
15284 callback = null;
15285 if ( evt ) {
15286 complete( evt.type === "error" ? 404 : 200, evt.type );
15287 }
15288 }
15289 );
15290 document.head.appendChild( script[ 0 ] );
15291 },
15292 abort: function() {
15293 if ( callback ) {
15294 callback();
15295 }
15296 }
15297 };
15298 }
15299 });
15300
15301
15302
15303
15304 var oldCallbacks = [],
15305 rjsonp = /(=)\?(?=&|$)|\?\?/;
15306
15307 // Default jsonp settings
15308 jQuery.ajaxSetup({
15309 jsonp: "callback",
15310 jsonpCallback: function() {
15311 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
15312 this[ callback ] = true;
15313 return callback;
15314 }
15315 });
15316
15317 // Detect, normalize options and install callbacks for jsonp requests
15318 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
15319
15320 var callbackName, overwritten, responseContainer,
15321 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
15322 "url" :
15323 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
15324 );
15325
15326 // Handle iff the expected data type is "jsonp" or we have a parameter to set
15327 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
15328
15329 // Get callback name, remembering preexisting value associated with it
15330 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
15331 s.jsonpCallback() :
15332 s.jsonpCallback;
15333
15334 // Insert callback into url or form data
15335 if ( jsonProp ) {
15336 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
15337 } else if ( s.jsonp !== false ) {
15338 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
15339 }
15340
15341 // Use data converter to retrieve json after script execution
15342 s.converters["script json"] = function() {
15343 if ( !responseContainer ) {
15344 jQuery.error( callbackName + " was not called" );
15345 }
15346 return responseContainer[ 0 ];
15347 };
15348
15349 // force json dataType
15350 s.dataTypes[ 0 ] = "json";
15351
15352 // Install callback
15353 overwritten = window[ callbackName ];
15354 window[ callbackName ] = function() {
15355 responseContainer = arguments;
15356 };
15357
15358 // Clean-up function (fires after converters)
15359 jqXHR.always(function() {
15360 // Restore preexisting value
15361 window[ callbackName ] = overwritten;
15362
15363 // Save back as free
15364 if ( s[ callbackName ] ) {
15365 // make sure that re-using the options doesn't screw things around
15366 s.jsonpCallback = originalSettings.jsonpCallback;
15367
15368 // save the callback name for future use
15369 oldCallbacks.push( callbackName );
15370 }
15371
15372 // Call if it was a function and we have a response
15373 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
15374 overwritten( responseContainer[ 0 ] );
15375 }
15376
15377 responseContainer = overwritten = undefined;
15378 });
15379
15380 // Delegate to script
15381 return "script";
15382 }
15383 });
15384
15385
15386
15387
15388 // data: string of html
15389 // context (optional): If specified, the fragment will be created in this context, defaults to document
15390 // keepScripts (optional): If true, will include scripts passed in the html string
15391 jQuery.parseHTML = function( data, context, keepScripts ) {
15392 if ( !data || typeof data !== "string" ) {
15393 return null;
15394 }
15395 if ( typeof context === "boolean" ) {
15396 keepScripts = context;
15397 context = false;
15398 }
15399 context = context || document;
15400
15401 var parsed = rsingleTag.exec( data ),
15402 scripts = !keepScripts && [];
15403
15404 // Single tag
15405 if ( parsed ) {
15406 return [ context.createElement( parsed[1] ) ];
15407 }
15408
15409 parsed = jQuery.buildFragment( [ data ], context, scripts );
15410
15411 if ( scripts && scripts.length ) {
15412 jQuery( scripts ).remove();
15413 }
15414
15415 return jQuery.merge( [], parsed.childNodes );
15416 };
15417
15418
15419 // Keep a copy of the old load method
15420 var _load = jQuery.fn.load;
15421
15422 /**
15423 * Load a url into a page
15424 */
15425 jQuery.fn.load = function( url, params, callback ) {
15426 if ( typeof url !== "string" && _load ) {
15427 return _load.apply( this, arguments );
15428 }
15429
15430 var selector, type, response,
15431 self = this,
15432 off = url.indexOf(" ");
15433
15434 if ( off >= 0 ) {
15435 selector = jQuery.trim( url.slice( off ) );
15436 url = url.slice( 0, off );
15437 }
15438
15439 // If it's a function
15440 if ( jQuery.isFunction( params ) ) {
15441
15442 // We assume that it's the callback
15443 callback = params;
15444 params = undefined;
15445
15446 // Otherwise, build a param string
15447 } else if ( params && typeof params === "object" ) {
15448 type = "POST";
15449 }
15450
15451 // If we have elements to modify, make the request
15452 if ( self.length > 0 ) {
15453 jQuery.ajax({
15454 url: url,
15455
15456 // if "type" variable is undefined, then "GET" method will be used
15457 type: type,
15458 dataType: "html",
15459 data: params
15460 }).done(function( responseText ) {
15461
15462 // Save response for use in complete callback
15463 response = arguments;
15464
15465 self.html( selector ?
15466
15467 // If a selector was specified, locate the right elements in a dummy div
15468 // Exclude scripts to avoid IE 'Permission Denied' errors
15469 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
15470
15471 // Otherwise use the full result
15472 responseText );
15473
15474 }).complete( callback && function( jqXHR, status ) {
15475 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
15476 });
15477 }
15478
15479 return this;
15480 };
15481
15482
15483
15484
15485 jQuery.expr.filters.animated = function( elem ) {
15486 return jQuery.grep(jQuery.timers, function( fn ) {
15487 return elem === fn.elem;
15488 }).length;
15489 };
15490
15491
15492
15493
15494 var docElem = window.document.documentElement;
15495
15496 /**
15497 * Gets a window from an element
15498 */
15499 function getWindow( elem ) {
15500 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
15501 }
15502
15503 jQuery.offset = {
15504 setOffset: function( elem, options, i ) {
15505 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
15506 position = jQuery.css( elem, "position" ),
15507 curElem = jQuery( elem ),
15508 props = {};
15509
15510 // Set position first, in-case top/left are set even on static elem
15511 if ( position === "static" ) {
15512 elem.style.position = "relative";
15513 }
15514
15515 curOffset = curElem.offset();
15516 curCSSTop = jQuery.css( elem, "top" );
15517 curCSSLeft = jQuery.css( elem, "left" );
15518 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
15519 ( curCSSTop + curCSSLeft ).indexOf("auto") > -1;
15520
15521 // Need to be able to calculate position if either top or left is auto and position is either absolute or fixed
15522 if ( calculatePosition ) {
15523 curPosition = curElem.position();
15524 curTop = curPosition.top;
15525 curLeft = curPosition.left;
15526
15527 } else {
15528 curTop = parseFloat( curCSSTop ) || 0;
15529 curLeft = parseFloat( curCSSLeft ) || 0;
15530 }
15531
15532 if ( jQuery.isFunction( options ) ) {
15533 options = options.call( elem, i, curOffset );
15534 }
15535
15536 if ( options.top != null ) {
15537 props.top = ( options.top - curOffset.top ) + curTop;
15538 }
15539 if ( options.left != null ) {
15540 props.left = ( options.left - curOffset.left ) + curLeft;
15541 }
15542
15543 if ( "using" in options ) {
15544 options.using.call( elem, props );
15545
15546 } else {
15547 curElem.css( props );
15548 }
15549 }
15550 };
15551
15552 jQuery.fn.extend({
15553 offset: function( options ) {
15554 if ( arguments.length ) {
15555 return options === undefined ?
15556 this :
15557 this.each(function( i ) {
15558 jQuery.offset.setOffset( this, options, i );
15559 });
15560 }
15561
15562 var docElem, win,
15563 elem = this[ 0 ],
15564 box = { top: 0, left: 0 },
15565 doc = elem && elem.ownerDocument;
15566
15567 if ( !doc ) {
15568 return;
15569 }
15570
15571 docElem = doc.documentElement;
15572
15573 // Make sure it's not a disconnected DOM node
15574 if ( !jQuery.contains( docElem, elem ) ) {
15575 return box;
15576 }
15577
15578 // If we don't have gBCR, just use 0,0 rather than error
15579 // BlackBerry 5, iOS 3 (original iPhone)
15580 if ( typeof elem.getBoundingClientRect !== strundefined ) {
15581 box = elem.getBoundingClientRect();
15582 }
15583 win = getWindow( doc );
15584 return {
15585 top: box.top + win.pageYOffset - docElem.clientTop,
15586 left: box.left + win.pageXOffset - docElem.clientLeft
15587 };
15588 },
15589
15590 position: function() {
15591 if ( !this[ 0 ] ) {
15592 return;
15593 }
15594
15595 var offsetParent, offset,
15596 elem = this[ 0 ],
15597 parentOffset = { top: 0, left: 0 };
15598
15599 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
15600 if ( jQuery.css( elem, "position" ) === "fixed" ) {
15601 // We assume that getBoundingClientRect is available when computed position is fixed
15602 offset = elem.getBoundingClientRect();
15603
15604 } else {
15605 // Get *real* offsetParent
15606 offsetParent = this.offsetParent();
15607
15608 // Get correct offsets
15609 offset = this.offset();
15610 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
15611 parentOffset = offsetParent.offset();
15612 }
15613
15614 // Add offsetParent borders
15615 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
15616 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
15617 }
15618
15619 // Subtract parent offsets and element margins
15620 return {
15621 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
15622 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
15623 };
15624 },
15625
15626 offsetParent: function() {
15627 return this.map(function() {
15628 var offsetParent = this.offsetParent || docElem;
15629
15630 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
15631 offsetParent = offsetParent.offsetParent;
15632 }
15633
15634 return offsetParent || docElem;
15635 });
15636 }
15637 });
15638
15639 // Create scrollLeft and scrollTop methods
15640 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
15641 var top = "pageYOffset" === prop;
15642
15643 jQuery.fn[ method ] = function( val ) {
15644 return access( this, function( elem, method, val ) {
15645 var win = getWindow( elem );
15646
15647 if ( val === undefined ) {
15648 return win ? win[ prop ] : elem[ method ];
15649 }
15650
15651 if ( win ) {
15652 win.scrollTo(
15653 !top ? val : window.pageXOffset,
15654 top ? val : window.pageYOffset
15655 );
15656
15657 } else {
15658 elem[ method ] = val;
15659 }
15660 }, method, val, arguments.length, null );
15661 };
15662 });
15663
15664 // Add the top/left cssHooks using jQuery.fn.position
15665 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
15666 // getComputedStyle returns percent when specified for top/left/bottom/right
15667 // rather than make the css module depend on the offset module, we just check for it here
15668 jQuery.each( [ "top", "left" ], function( i, prop ) {
15669 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
15670 function( elem, computed ) {
15671 if ( computed ) {
15672 computed = curCSS( elem, prop );
15673 // if curCSS returns percentage, fallback to offset
15674 return rnumnonpx.test( computed ) ?
15675 jQuery( elem ).position()[ prop ] + "px" :
15676 computed;
15677 }
15678 }
15679 );
15680 });
15681
15682
15683 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
15684 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
15685 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
15686 // margin is only for outerHeight, outerWidth
15687 jQuery.fn[ funcName ] = function( margin, value ) {
15688 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
15689 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
15690
15691 return access( this, function( elem, type, value ) {
15692 var doc;
15693
15694 if ( jQuery.isWindow( elem ) ) {
15695 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
15696 // isn't a whole lot we can do. See pull request at this URL for discussion:
15697 // https://github.com/jquery/jquery/pull/764
15698 return elem.document.documentElement[ "client" + name ];
15699 }
15700
15701 // Get document width or height
15702 if ( elem.nodeType === 9 ) {
15703 doc = elem.documentElement;
15704
15705 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
15706 // whichever is greatest
15707 return Math.max(
15708 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
15709 elem.body[ "offset" + name ], doc[ "offset" + name ],
15710 doc[ "client" + name ]
15711 );
15712 }
15713
15714 return value === undefined ?
15715 // Get width or height on the element, requesting but not forcing parseFloat
15716 jQuery.css( elem, type, extra ) :
15717
15718 // Set width or height on the element
15719 jQuery.style( elem, type, value, extra );
15720 }, type, chainable ? margin : undefined, chainable, null );
15721 };
15722 });
15723 });
15724
15725
15726 // The number of elements contained in the matched element set
15727 jQuery.fn.size = function() {
15728 return this.length;
15729 };
15730
15731 jQuery.fn.andSelf = jQuery.fn.addBack;
15732
15733
15734
15735
15736 // Register as a named AMD module, since jQuery can be concatenated with other
15737 // files that may use define, but not via a proper concatenation script that
15738 // understands anonymous AMD modules. A named AMD is safest and most robust
15739 // way to register. Lowercase jquery is used because AMD module names are
15740 // derived from file names, and jQuery is normally delivered in a lowercase
15741 // file name. Do this after creating the global so that if an AMD module wants
15742 // to call noConflict to hide this version of jQuery, it will work.
15743
15744 // Note that for maximum portability, libraries that are not jQuery should
15745 // declare themselves as anonymous modules, and avoid setting a global if an
15746 // AMD loader is present. jQuery is a special case. For more information, see
15747 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
15748
15749 if ( typeof define === "function" && define.amd ) {
15750 define( "jquery", [], function() {
15751 return jQuery;
15752 });
15753 }
15754
15755
15756
15757
15758 var
15759 // Map over jQuery in case of overwrite
15760 _jQuery = window.jQuery,
15761
15762 // Map over the $ in case of overwrite
15763 _$ = window.$;
15764
15765 jQuery.noConflict = function( deep ) {
15766 if ( window.$ === jQuery ) {
15767 window.$ = _$;
15768 }
15769
15770 if ( deep && window.jQuery === jQuery ) {
15771 window.jQuery = _jQuery;
15772 }
15773
15774 return jQuery;
15775 };
15776
15777 // Expose jQuery and $ identifiers, even in
15778 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
15779 // and CommonJS for browser emulators (#13566)
15780 if ( typeof noGlobal === strundefined ) {
15781 window.jQuery = window.$ = jQuery;
15782 }
15783
15784
15785
15786
15787 return jQuery;
15788
15789 }));
15790 </script>
15791 <script>
15792 /*!
15793 * Bootstrap v3.2.0 (http://getbootstrap.com)
15794 * Copyright 2011-2014 Twitter, Inc.
15795 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15796 */
15797
15798 if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript requires jQuery') }
15799
15800 /* ========================================================================
15801 * Bootstrap: transition.js v3.2.0
15802 * http://getbootstrap.com/javascript/#transitions
15803 * ========================================================================
15804 * Copyright 2011-2014 Twitter, Inc.
15805 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15806 * ======================================================================== */
15807
15808
15809 +function ($) {
15810 'use strict';
15811
15812 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
15813 // ============================================================
15814
15815 function transitionEnd() {
15816 var el = document.createElement('bootstrap')
15817
15818 var transEndEventNames = {
15819 WebkitTransition : 'webkitTransitionEnd',
15820 MozTransition : 'transitionend',
15821 OTransition : 'oTransitionEnd otransitionend',
15822 transition : 'transitionend'
15823 }
15824
15825 for (var name in transEndEventNames) {
15826 if (el.style[name] !== undefined) {
15827 return { end: transEndEventNames[name] }
15828 }
15829 }
15830
15831 return false // explicit for ie8 ( ._.)
15832 }
15833
15834 // http://blog.alexmaccaw.com/css-transitions
15835 $.fn.emulateTransitionEnd = function (duration) {
15836 var called = false
15837 var $el = this
15838 $(this).one('bsTransitionEnd', function () { called = true })
15839 var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
15840 setTimeout(callback, duration)
15841 return this
15842 }
15843
15844 $(function () {
15845 $.support.transition = transitionEnd()
15846
15847 if (!$.support.transition) return
15848
15849 $.event.special.bsTransitionEnd = {
15850 bindType: $.support.transition.end,
15851 delegateType: $.support.transition.end,
15852 handle: function (e) {
15853 if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
15854 }
15855 }
15856 })
15857
15858 }(jQuery);
15859
15860 /* ========================================================================
15861 * Bootstrap: alert.js v3.2.0
15862 * http://getbootstrap.com/javascript/#alerts
15863 * ========================================================================
15864 * Copyright 2011-2014 Twitter, Inc.
15865 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15866 * ======================================================================== */
15867
15868
15869 +function ($) {
15870 'use strict';
15871
15872 // ALERT CLASS DEFINITION
15873 // ======================
15874
15875 var dismiss = '[data-dismiss="alert"]'
15876 var Alert = function (el) {
15877 $(el).on('click', dismiss, this.close)
15878 }
15879
15880 Alert.VERSION = '3.2.0'
15881
15882 Alert.prototype.close = function (e) {
15883 var $this = $(this)
15884 var selector = $this.attr('data-target')
15885
15886 if (!selector) {
15887 selector = $this.attr('href')
15888 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
15889 }
15890
15891 var $parent = $(selector)
15892
15893 if (e) e.preventDefault()
15894
15895 if (!$parent.length) {
15896 $parent = $this.hasClass('alert') ? $this : $this.parent()
15897 }
15898
15899 $parent.trigger(e = $.Event('close.bs.alert'))
15900
15901 if (e.isDefaultPrevented()) return
15902
15903 $parent.removeClass('in')
15904
15905 function removeElement() {
15906 // detach from parent, fire event then clean up data
15907 $parent.detach().trigger('closed.bs.alert').remove()
15908 }
15909
15910 $.support.transition && $parent.hasClass('fade') ?
15911 $parent
15912 .one('bsTransitionEnd', removeElement)
15913 .emulateTransitionEnd(150) :
15914 removeElement()
15915 }
15916
15917
15918 // ALERT PLUGIN DEFINITION
15919 // =======================
15920
15921 function Plugin(option) {
15922 return this.each(function () {
15923 var $this = $(this)
15924 var data = $this.data('bs.alert')
15925
15926 if (!data) $this.data('bs.alert', (data = new Alert(this)))
15927 if (typeof option == 'string') data[option].call($this)
15928 })
15929 }
15930
15931 var old = $.fn.alert
15932
15933 $.fn.alert = Plugin
15934 $.fn.alert.Constructor = Alert
15935
15936
15937 // ALERT NO CONFLICT
15938 // =================
15939
15940 $.fn.alert.noConflict = function () {
15941 $.fn.alert = old
15942 return this
15943 }
15944
15945
15946 // ALERT DATA-API
15947 // ==============
15948
15949 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
15950
15951 }(jQuery);
15952
15953 /* ========================================================================
15954 * Bootstrap: button.js v3.2.0
15955 * http://getbootstrap.com/javascript/#buttons
15956 * ========================================================================
15957 * Copyright 2011-2014 Twitter, Inc.
15958 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15959 * ======================================================================== */
15960
15961
15962 +function ($) {
15963 'use strict';
15964
15965 // BUTTON PUBLIC CLASS DEFINITION
15966 // ==============================
15967
15968 var Button = function (element, options) {
15969 this.$element = $(element)
15970 this.options = $.extend({}, Button.DEFAULTS, options)
15971 this.isLoading = false
15972 }
15973
15974 Button.VERSION = '3.2.0'
15975
15976 Button.DEFAULTS = {
15977 loadingText: 'loading...'
15978 }
15979
15980 Button.prototype.setState = function (state) {
15981 var d = 'disabled'
15982 var $el = this.$element
15983 var val = $el.is('input') ? 'val' : 'html'
15984 var data = $el.data()
15985
15986 state = state + 'Text'
15987
15988 if (data.resetText == null) $el.data('resetText', $el[val]())
15989
15990 $el[val](data[state] == null ? this.options[state] : data[state])
15991
15992 // push to event loop to allow forms to submit
15993 setTimeout($.proxy(function () {
15994 if (state == 'loadingText') {
15995 this.isLoading = true
15996 $el.addClass(d).attr(d, d)
15997 } else if (this.isLoading) {
15998 this.isLoading = false
15999 $el.removeClass(d).removeAttr(d)
16000 }
16001 }, this), 0)
16002 }
16003
16004 Button.prototype.toggle = function () {
16005 var changed = true
16006 var $parent = this.$element.closest('[data-toggle="buttons"]')
16007
16008 if ($parent.length) {
16009 var $input = this.$element.find('input')
16010 if ($input.prop('type') == 'radio') {
16011 if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
16012 else $parent.find('.active').removeClass('active')
16013 }
16014 if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
16015 }
16016
16017 if (changed) this.$element.toggleClass('active')
16018 }
16019
16020
16021 // BUTTON PLUGIN DEFINITION
16022 // ========================
16023
16024 function Plugin(option) {
16025 return this.each(function () {
16026 var $this = $(this)
16027 var data = $this.data('bs.button')
16028 var options = typeof option == 'object' && option
16029
16030 if (!data) $this.data('bs.button', (data = new Button(this, options)))
16031
16032 if (option == 'toggle') data.toggle()
16033 else if (option) data.setState(option)
16034 })
16035 }
16036
16037 var old = $.fn.button
16038
16039 $.fn.button = Plugin
16040 $.fn.button.Constructor = Button
16041
16042
16043 // BUTTON NO CONFLICT
16044 // ==================
16045
16046 $.fn.button.noConflict = function () {
16047 $.fn.button = old
16048 return this
16049 }
16050
16051
16052 // BUTTON DATA-API
16053 // ===============
16054
16055 $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
16056 var $btn = $(e.target)
16057 if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
16058 Plugin.call($btn, 'toggle')
16059 e.preventDefault()
16060 })
16061
16062 }(jQuery);
16063
16064 /* ========================================================================
16065 * Bootstrap: carousel.js v3.2.0
16066 * http://getbootstrap.com/javascript/#carousel
16067 * ========================================================================
16068 * Copyright 2011-2014 Twitter, Inc.
16069 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16070 * ======================================================================== */
16071
16072
16073 +function ($) {
16074 'use strict';
16075
16076 // CAROUSEL CLASS DEFINITION
16077 // =========================
16078
16079 var Carousel = function (element, options) {
16080 this.$element = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this))
16081 this.$indicators = this.$element.find('.carousel-indicators')
16082 this.options = options
16083 this.paused =
16084 this.sliding =
16085 this.interval =
16086 this.$active =
16087 this.$items = null
16088
16089 this.options.pause == 'hover' && this.$element
16090 .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
16091 .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
16092 }
16093
16094 Carousel.VERSION = '3.2.0'
16095
16096 Carousel.DEFAULTS = {
16097 interval: 5000,
16098 pause: 'hover',
16099 wrap: true
16100 }
16101
16102 Carousel.prototype.keydown = function (e) {
16103 switch (e.which) {
16104 case 37: this.prev(); break
16105 case 39: this.next(); break
16106 default: return
16107 }
16108
16109 e.preventDefault()
16110 }
16111
16112 Carousel.prototype.cycle = function (e) {
16113 e || (this.paused = false)
16114
16115 this.interval && clearInterval(this.interval)
16116
16117 this.options.interval
16118 && !this.paused
16119 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
16120
16121 return this
16122 }
16123
16124 Carousel.prototype.getItemIndex = function (item) {
16125 this.$items = item.parent().children('.item')
16126 return this.$items.index(item || this.$active)
16127 }
16128
16129 Carousel.prototype.to = function (pos) {
16130 var that = this
16131 var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))
16132
16133 if (pos > (this.$items.length - 1) || pos < 0) return
16134
16135 if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
16136 if (activeIndex == pos) return this.pause().cycle()
16137
16138 return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
16139 }
16140
16141 Carousel.prototype.pause = function (e) {
16142 e || (this.paused = true)
16143
16144 if (this.$element.find('.next, .prev').length && $.support.transition) {
16145 this.$element.trigger($.support.transition.end)
16146 this.cycle(true)
16147 }
16148
16149 this.interval = clearInterval(this.interval)
16150
16151 return this
16152 }
16153
16154 Carousel.prototype.next = function () {
16155 if (this.sliding) return
16156 return this.slide('next')
16157 }
16158
16159 Carousel.prototype.prev = function () {
16160 if (this.sliding) return
16161 return this.slide('prev')
16162 }
16163
16164 Carousel.prototype.slide = function (type, next) {
16165 var $active = this.$element.find('.item.active')
16166 var $next = next || $active[type]()
16167 var isCycling = this.interval
16168 var direction = type == 'next' ? 'left' : 'right'
16169 var fallback = type == 'next' ? 'first' : 'last'
16170 var that = this
16171
16172 if (!$next.length) {
16173 if (!this.options.wrap) return
16174 $next = this.$element.find('.item')[fallback]()
16175 }
16176
16177 if ($next.hasClass('active')) return (this.sliding = false)
16178
16179 var relatedTarget = $next[0]
16180 var slideEvent = $.Event('slide.bs.carousel', {
16181 relatedTarget: relatedTarget,
16182 direction: direction
16183 })
16184 this.$element.trigger(slideEvent)
16185 if (slideEvent.isDefaultPrevented()) return
16186
16187 this.sliding = true
16188
16189 isCycling && this.pause()
16190
16191 if (this.$indicators.length) {
16192 this.$indicators.find('.active').removeClass('active')
16193 var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
16194 $nextIndicator && $nextIndicator.addClass('active')
16195 }
16196
16197 var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
16198 if ($.support.transition && this.$element.hasClass('slide')) {
16199 $next.addClass(type)
16200 $next[0].offsetWidth // force reflow
16201 $active.addClass(direction)
16202 $next.addClass(direction)
16203 $active
16204 .one('bsTransitionEnd', function () {
16205 $next.removeClass([type, direction].join(' ')).addClass('active')
16206 $active.removeClass(['active', direction].join(' '))
16207 that.sliding = false
16208 setTimeout(function () {
16209 that.$element.trigger(slidEvent)
16210 }, 0)
16211 })
16212 .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
16213 } else {
16214 $active.removeClass('active')
16215 $next.addClass('active')
16216 this.sliding = false
16217 this.$element.trigger(slidEvent)
16218 }
16219
16220 isCycling && this.cycle()
16221
16222 return this
16223 }
16224
16225
16226 // CAROUSEL PLUGIN DEFINITION
16227 // ==========================
16228
16229 function Plugin(option) {
16230 return this.each(function () {
16231 var $this = $(this)
16232 var data = $this.data('bs.carousel')
16233 var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
16234 var action = typeof option == 'string' ? option : options.slide
16235
16236 if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
16237 if (typeof option == 'number') data.to(option)
16238 else if (action) data[action]()
16239 else if (options.interval) data.pause().cycle()
16240 })
16241 }
16242
16243 var old = $.fn.carousel
16244
16245 $.fn.carousel = Plugin
16246 $.fn.carousel.Constructor = Carousel
16247
16248
16249 // CAROUSEL NO CONFLICT
16250 // ====================
16251
16252 $.fn.carousel.noConflict = function () {
16253 $.fn.carousel = old
16254 return this
16255 }
16256
16257
16258 // CAROUSEL DATA-API
16259 // =================
16260
16261 $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
16262 var href
16263 var $this = $(this)
16264 var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
16265 if (!$target.hasClass('carousel')) return
16266 var options = $.extend({}, $target.data(), $this.data())
16267 var slideIndex = $this.attr('data-slide-to')
16268 if (slideIndex) options.interval = false
16269
16270 Plugin.call($target, options)
16271
16272 if (slideIndex) {
16273 $target.data('bs.carousel').to(slideIndex)
16274 }
16275
16276 e.preventDefault()
16277 })
16278
16279 $(window).on('load', function () {
16280 $('[data-ride="carousel"]').each(function () {
16281 var $carousel = $(this)
16282 Plugin.call($carousel, $carousel.data())
16283 })
16284 })
16285
16286 }(jQuery);
16287
16288 /* ========================================================================
16289 * Bootstrap: collapse.js v3.2.0
16290 * http://getbootstrap.com/javascript/#collapse
16291 * ========================================================================
16292 * Copyright 2011-2014 Twitter, Inc.
16293 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16294 * ======================================================================== */
16295
16296
16297 +function ($) {
16298 'use strict';
16299
16300 // COLLAPSE PUBLIC CLASS DEFINITION
16301 // ================================
16302
16303 var Collapse = function (element, options) {
16304 this.$element = $(element)
16305 this.options = $.extend({}, Collapse.DEFAULTS, options)
16306 this.transitioning = null
16307
16308 if (this.options.parent) this.$parent = $(this.options.parent)
16309 if (this.options.toggle) this.toggle()
16310 }
16311
16312 Collapse.VERSION = '3.2.0'
16313
16314 Collapse.DEFAULTS = {
16315 toggle: true
16316 }
16317
16318 Collapse.prototype.dimension = function () {
16319 var hasWidth = this.$element.hasClass('width')
16320 return hasWidth ? 'width' : 'height'
16321 }
16322
16323 Collapse.prototype.show = function () {
16324 if (this.transitioning || this.$element.hasClass('in')) return
16325
16326 var startEvent = $.Event('show.bs.collapse')
16327 this.$element.trigger(startEvent)
16328 if (startEvent.isDefaultPrevented()) return
16329
16330 var actives = this.$parent && this.$parent.find('> .panel > .in')
16331
16332 if (actives && actives.length) {
16333 var hasData = actives.data('bs.collapse')
16334 if (hasData && hasData.transitioning) return
16335 Plugin.call(actives, 'hide')
16336 hasData || actives.data('bs.collapse', null)
16337 }
16338
16339 var dimension = this.dimension()
16340
16341 this.$element
16342 .removeClass('collapse')
16343 .addClass('collapsing')[dimension](0)
16344
16345 this.transitioning = 1
16346
16347 var complete = function () {
16348 this.$element
16349 .removeClass('collapsing')
16350 .addClass('collapse in')[dimension]('')
16351 this.transitioning = 0
16352 this.$element
16353 .trigger('shown.bs.collapse')
16354 }
16355
16356 if (!$.support.transition) return complete.call(this)
16357
16358 var scrollSize = $.camelCase(['scroll', dimension].join('-'))
16359
16360 this.$element
16361 .one('bsTransitionEnd', $.proxy(complete, this))
16362 .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
16363 }
16364
16365 Collapse.prototype.hide = function () {
16366 if (this.transitioning || !this.$element.hasClass('in')) return
16367
16368 var startEvent = $.Event('hide.bs.collapse')
16369 this.$element.trigger(startEvent)
16370 if (startEvent.isDefaultPrevented()) return
16371
16372 var dimension = this.dimension()
16373
16374 this.$element[dimension](this.$element[dimension]())[0].offsetHeight
16375
16376 this.$element
16377 .addClass('collapsing')
16378 .removeClass('collapse')
16379 .removeClass('in')
16380
16381 this.transitioning = 1
16382
16383 var complete = function () {
16384 this.transitioning = 0
16385 this.$element
16386 .trigger('hidden.bs.collapse')
16387 .removeClass('collapsing')
16388 .addClass('collapse')
16389 }
16390
16391 if (!$.support.transition) return complete.call(this)
16392
16393 this.$element
16394 [dimension](0)
16395 .one('bsTransitionEnd', $.proxy(complete, this))
16396 .emulateTransitionEnd(350)
16397 }
16398
16399 Collapse.prototype.toggle = function () {
16400 this[this.$element.hasClass('in') ? 'hide' : 'show']()
16401 }
16402
16403
16404 // COLLAPSE PLUGIN DEFINITION
16405 // ==========================
16406
16407 function Plugin(option) {
16408 return this.each(function () {
16409 var $this = $(this)
16410 var data = $this.data('bs.collapse')
16411 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
16412
16413 if (!data && options.toggle && option == 'show') option = !option
16414 if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
16415 if (typeof option == 'string') data[option]()
16416 })
16417 }
16418
16419 var old = $.fn.collapse
16420
16421 $.fn.collapse = Plugin
16422 $.fn.collapse.Constructor = Collapse
16423
16424
16425 // COLLAPSE NO CONFLICT
16426 // ====================
16427
16428 $.fn.collapse.noConflict = function () {
16429 $.fn.collapse = old
16430 return this
16431 }
16432
16433
16434 // COLLAPSE DATA-API
16435 // =================
16436
16437 $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
16438 var href
16439 var $this = $(this)
16440 var target = $this.attr('data-target')
16441 || e.preventDefault()
16442 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
16443 var $target = $(target)
16444 var data = $target.data('bs.collapse')
16445 var option = data ? 'toggle' : $this.data()
16446 var parent = $this.attr('data-parent')
16447 var $parent = parent && $(parent)
16448
16449 if (!data || !data.transitioning) {
16450 if ($parent) $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed')
16451 $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
16452 }
16453
16454 Plugin.call($target, option)
16455 })
16456
16457 }(jQuery);
16458
16459 /* ========================================================================
16460 * Bootstrap: dropdown.js v3.2.0
16461 * http://getbootstrap.com/javascript/#dropdowns
16462 * ========================================================================
16463 * Copyright 2011-2014 Twitter, Inc.
16464 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16465 * ======================================================================== */
16466
16467
16468 +function ($) {
16469 'use strict';
16470
16471 // DROPDOWN CLASS DEFINITION
16472 // =========================
16473
16474 var backdrop = '.dropdown-backdrop'
16475 var toggle = '[data-toggle="dropdown"]'
16476 var Dropdown = function (element) {
16477 $(element).on('click.bs.dropdown', this.toggle)
16478 }
16479
16480 Dropdown.VERSION = '3.2.0'
16481
16482 Dropdown.prototype.toggle = function (e) {
16483 var $this = $(this)
16484
16485 if ($this.is('.disabled, :disabled')) return
16486
16487 var $parent = getParent($this)
16488 var isActive = $parent.hasClass('open')
16489
16490 clearMenus()
16491
16492 if (!isActive) {
16493 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
16494 // if mobile we use a backdrop because click events don't delegate
16495 $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
16496 }
16497
16498 var relatedTarget = { relatedTarget: this }
16499 $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
16500
16501 if (e.isDefaultPrevented()) return
16502
16503 $this.trigger('focus')
16504
16505 $parent
16506 .toggleClass('open')
16507 .trigger('shown.bs.dropdown', relatedTarget)
16508 }
16509
16510 return false
16511 }
16512
16513 Dropdown.prototype.keydown = function (e) {
16514 if (!/(38|40|27)/.test(e.keyCode)) return
16515
16516 var $this = $(this)
16517
16518 e.preventDefault()
16519 e.stopPropagation()
16520
16521 if ($this.is('.disabled, :disabled')) return
16522
16523 var $parent = getParent($this)
16524 var isActive = $parent.hasClass('open')
16525
16526 if (!isActive || (isActive && e.keyCode == 27)) {
16527 if (e.which == 27) $parent.find(toggle).trigger('focus')
16528 return $this.trigger('click')
16529 }
16530
16531 var desc = ' li:not(.divider):visible a'
16532 var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
16533
16534 if (!$items.length) return
16535
16536 var index = $items.index($items.filter(':focus'))
16537
16538 if (e.keyCode == 38 && index > 0) index-- // up
16539 if (e.keyCode == 40 && index < $items.length - 1) index++ // down
16540 if (!~index) index = 0
16541
16542 $items.eq(index).trigger('focus')
16543 }
16544
16545 function clearMenus(e) {
16546 if (e && e.which === 3) return
16547 $(backdrop).remove()
16548 $(toggle).each(function () {
16549 var $parent = getParent($(this))
16550 var relatedTarget = { relatedTarget: this }
16551 if (!$parent.hasClass('open')) return
16552 $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
16553 if (e.isDefaultPrevented()) return
16554 $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
16555 })
16556 }
16557
16558 function getParent($this) {
16559 var selector = $this.attr('data-target')
16560
16561 if (!selector) {
16562 selector = $this.attr('href')
16563 selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
16564 }
16565
16566 var $parent = selector && $(selector)
16567
16568 return $parent && $parent.length ? $parent : $this.parent()
16569 }
16570
16571
16572 // DROPDOWN PLUGIN DEFINITION
16573 // ==========================
16574
16575 function Plugin(option) {
16576 return this.each(function () {
16577 var $this = $(this)
16578 var data = $this.data('bs.dropdown')
16579
16580 if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
16581 if (typeof option == 'string') data[option].call($this)
16582 })
16583 }
16584
16585 var old = $.fn.dropdown
16586
16587 $.fn.dropdown = Plugin
16588 $.fn.dropdown.Constructor = Dropdown
16589
16590
16591 // DROPDOWN NO CONFLICT
16592 // ====================
16593
16594 $.fn.dropdown.noConflict = function () {
16595 $.fn.dropdown = old
16596 return this
16597 }
16598
16599
16600 // APPLY TO STANDARD DROPDOWN ELEMENTS
16601 // ===================================
16602
16603 $(document)
16604 .on('click.bs.dropdown.data-api', clearMenus)
16605 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
16606 .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
16607 .on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown)
16608
16609 }(jQuery);
16610
16611 /* ========================================================================
16612 * Bootstrap: modal.js v3.2.0
16613 * http://getbootstrap.com/javascript/#modals
16614 * ========================================================================
16615 * Copyright 2011-2014 Twitter, Inc.
16616 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16617 * ======================================================================== */
16618
16619
16620 +function ($) {
16621 'use strict';
16622
16623 // MODAL CLASS DEFINITION
16624 // ======================
16625
16626 var Modal = function (element, options) {
16627 this.options = options
16628 this.$body = $(document.body)
16629 this.$element = $(element)
16630 this.$backdrop =
16631 this.isShown = null
16632 this.scrollbarWidth = 0
16633
16634 if (this.options.remote) {
16635 this.$element
16636 .find('.modal-content')
16637 .load(this.options.remote, $.proxy(function () {
16638 this.$element.trigger('loaded.bs.modal')
16639 }, this))
16640 }
16641 }
16642
16643 Modal.VERSION = '3.2.0'
16644
16645 Modal.DEFAULTS = {
16646 backdrop: true,
16647 keyboard: true,
16648 show: true
16649 }
16650
16651 Modal.prototype.toggle = function (_relatedTarget) {
16652 return this.isShown ? this.hide() : this.show(_relatedTarget)
16653 }
16654
16655 Modal.prototype.show = function (_relatedTarget) {
16656 var that = this
16657 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
16658
16659 this.$element.trigger(e)
16660
16661 if (this.isShown || e.isDefaultPrevented()) return
16662
16663 this.isShown = true
16664
16665 this.checkScrollbar()
16666 this.$body.addClass('modal-open')
16667
16668 this.setScrollbar()
16669 this.escape()
16670
16671 this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
16672
16673 this.backdrop(function () {
16674 var transition = $.support.transition && that.$element.hasClass('fade')
16675
16676 if (!that.$element.parent().length) {
16677 that.$element.appendTo(that.$body) // don't move modals dom position
16678 }
16679
16680 that.$element
16681 .show()
16682 .scrollTop(0)
16683
16684 if (transition) {
16685 that.$element[0].offsetWidth // force reflow
16686 }
16687
16688 that.$element
16689 .addClass('in')
16690 .attr('aria-hidden', false)
16691
16692 that.enforceFocus()
16693
16694 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
16695
16696 transition ?
16697 that.$element.find('.modal-dialog') // wait for modal to slide in
16698 .one('bsTransitionEnd', function () {
16699 that.$element.trigger('focus').trigger(e)
16700 })
16701 .emulateTransitionEnd(300) :
16702 that.$element.trigger('focus').trigger(e)
16703 })
16704 }
16705
16706 Modal.prototype.hide = function (e) {
16707 if (e) e.preventDefault()
16708
16709 e = $.Event('hide.bs.modal')
16710
16711 this.$element.trigger(e)
16712
16713 if (!this.isShown || e.isDefaultPrevented()) return
16714
16715 this.isShown = false
16716
16717 this.$body.removeClass('modal-open')
16718
16719 this.resetScrollbar()
16720 this.escape()
16721
16722 $(document).off('focusin.bs.modal')
16723
16724 this.$element
16725 .removeClass('in')
16726 .attr('aria-hidden', true)
16727 .off('click.dismiss.bs.modal')
16728
16729 $.support.transition && this.$element.hasClass('fade') ?
16730 this.$element
16731 .one('bsTransitionEnd', $.proxy(this.hideModal, this))
16732 .emulateTransitionEnd(300) :
16733 this.hideModal()
16734 }
16735
16736 Modal.prototype.enforceFocus = function () {
16737 $(document)
16738 .off('focusin.bs.modal') // guard against infinite focus loop
16739 .on('focusin.bs.modal', $.proxy(function (e) {
16740 if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
16741 this.$element.trigger('focus')
16742 }
16743 }, this))
16744 }
16745
16746 Modal.prototype.escape = function () {
16747 if (this.isShown && this.options.keyboard) {
16748 this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
16749 e.which == 27 && this.hide()
16750 }, this))
16751 } else if (!this.isShown) {
16752 this.$element.off('keyup.dismiss.bs.modal')
16753 }
16754 }
16755
16756 Modal.prototype.hideModal = function () {
16757 var that = this
16758 this.$element.hide()
16759 this.backdrop(function () {
16760 that.$element.trigger('hidden.bs.modal')
16761 })
16762 }
16763
16764 Modal.prototype.removeBackdrop = function () {
16765 this.$backdrop && this.$backdrop.remove()
16766 this.$backdrop = null
16767 }
16768
16769 Modal.prototype.backdrop = function (callback) {
16770 var that = this
16771 var animate = this.$element.hasClass('fade') ? 'fade' : ''
16772
16773 if (this.isShown && this.options.backdrop) {
16774 var doAnimate = $.support.transition && animate
16775
16776 this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
16777 .appendTo(this.$body)
16778
16779 this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
16780 if (e.target !== e.currentTarget) return
16781 this.options.backdrop == 'static'
16782 ? this.$element[0].focus.call(this.$element[0])
16783 : this.hide.call(this)
16784 }, this))
16785
16786 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
16787
16788 this.$backdrop.addClass('in')
16789
16790 if (!callback) return
16791
16792 doAnimate ?
16793 this.$backdrop
16794 .one('bsTransitionEnd', callback)
16795 .emulateTransitionEnd(150) :
16796 callback()
16797
16798 } else if (!this.isShown && this.$backdrop) {
16799 this.$backdrop.removeClass('in')
16800
16801 var callbackRemove = function () {
16802 that.removeBackdrop()
16803 callback && callback()
16804 }
16805 $.support.transition && this.$element.hasClass('fade') ?
16806 this.$backdrop
16807 .one('bsTransitionEnd', callbackRemove)
16808 .emulateTransitionEnd(150) :
16809 callbackRemove()
16810
16811 } else if (callback) {
16812 callback()
16813 }
16814 }
16815
16816 Modal.prototype.checkScrollbar = function () {
16817 if (document.body.clientWidth >= window.innerWidth) return
16818 this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
16819 }
16820
16821 Modal.prototype.setScrollbar = function () {
16822 var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
16823 if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
16824 }
16825
16826 Modal.prototype.resetScrollbar = function () {
16827 this.$body.css('padding-right', '')
16828 }
16829
16830 Modal.prototype.measureScrollbar = function () { // thx walsh
16831 var scrollDiv = document.createElement('div')
16832 scrollDiv.className = 'modal-scrollbar-measure'
16833 this.$body.append(scrollDiv)
16834 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
16835 this.$body[0].removeChild(scrollDiv)
16836 return scrollbarWidth
16837 }
16838
16839
16840 // MODAL PLUGIN DEFINITION
16841 // =======================
16842
16843 function Plugin(option, _relatedTarget) {
16844 return this.each(function () {
16845 var $this = $(this)
16846 var data = $this.data('bs.modal')
16847 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
16848
16849 if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
16850 if (typeof option == 'string') data[option](_relatedTarget)
16851 else if (options.show) data.show(_relatedTarget)
16852 })
16853 }
16854
16855 var old = $.fn.modal
16856
16857 $.fn.modal = Plugin
16858 $.fn.modal.Constructor = Modal
16859
16860
16861 // MODAL NO CONFLICT
16862 // =================
16863
16864 $.fn.modal.noConflict = function () {
16865 $.fn.modal = old
16866 return this
16867 }
16868
16869
16870 // MODAL DATA-API
16871 // ==============
16872
16873 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
16874 var $this = $(this)
16875 var href = $this.attr('href')
16876 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
16877 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
16878
16879 if ($this.is('a')) e.preventDefault()
16880
16881 $target.one('show.bs.modal', function (showEvent) {
16882 if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
16883 $target.one('hidden.bs.modal', function () {
16884 $this.is(':visible') && $this.trigger('focus')
16885 })
16886 })
16887 Plugin.call($target, option, this)
16888 })
16889
16890 }(jQuery);
16891
16892 /* ========================================================================
16893 * Bootstrap: tooltip.js v3.2.0
16894 * http://getbootstrap.com/javascript/#tooltip
16895 * Inspired by the original jQuery.tipsy by Jason Frame
16896 * ========================================================================
16897 * Copyright 2011-2014 Twitter, Inc.
16898 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16899 * ======================================================================== */
16900
16901
16902 +function ($) {
16903 'use strict';
16904
16905 // TOOLTIP PUBLIC CLASS DEFINITION
16906 // ===============================
16907
16908 var Tooltip = function (element, options) {
16909 this.type =
16910 this.options =
16911 this.enabled =
16912 this.timeout =
16913 this.hoverState =
16914 this.$element = null
16915
16916 this.init('tooltip', element, options)
16917 }
16918
16919 Tooltip.VERSION = '3.2.0'
16920
16921 Tooltip.DEFAULTS = {
16922 animation: true,
16923 placement: 'top',
16924 selector: false,
16925 template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
16926 trigger: 'hover focus',
16927 title: '',
16928 delay: 0,
16929 html: false,
16930 container: false,
16931 viewport: {
16932 selector: 'body',
16933 padding: 0
16934 }
16935 }
16936
16937 Tooltip.prototype.init = function (type, element, options) {
16938 this.enabled = true
16939 this.type = type
16940 this.$element = $(element)
16941 this.options = this.getOptions(options)
16942 this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
16943
16944 var triggers = this.options.trigger.split(' ')
16945
16946 for (var i = triggers.length; i--;) {
16947 var trigger = triggers[i]
16948
16949 if (trigger == 'click') {
16950 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
16951 } else if (trigger != 'manual') {
16952 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
16953 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
16954
16955 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
16956 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
16957 }
16958 }
16959
16960 this.options.selector ?
16961 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
16962 this.fixTitle()
16963 }
16964
16965 Tooltip.prototype.getDefaults = function () {
16966 return Tooltip.DEFAULTS
16967 }
16968
16969 Tooltip.prototype.getOptions = function (options) {
16970 options = $.extend({}, this.getDefaults(), this.$element.data(), options)
16971
16972 if (options.delay && typeof options.delay == 'number') {
16973 options.delay = {
16974 show: options.delay,
16975 hide: options.delay
16976 }
16977 }
16978
16979 return options
16980 }
16981
16982 Tooltip.prototype.getDelegateOptions = function () {
16983 var options = {}
16984 var defaults = this.getDefaults()
16985
16986 this._options && $.each(this._options, function (key, value) {
16987 if (defaults[key] != value) options[key] = value
16988 })
16989
16990 return options
16991 }
16992
16993 Tooltip.prototype.enter = function (obj) {
16994 var self = obj instanceof this.constructor ?
16995 obj : $(obj.currentTarget).data('bs.' + this.type)
16996
16997 if (!self) {
16998 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
16999 $(obj.currentTarget).data('bs.' + this.type, self)
17000 }
17001
17002 clearTimeout(self.timeout)
17003
17004 self.hoverState = 'in'
17005
17006 if (!self.options.delay || !self.options.delay.show) return self.show()
17007
17008 self.timeout = setTimeout(function () {
17009 if (self.hoverState == 'in') self.show()
17010 }, self.options.delay.show)
17011 }
17012
17013 Tooltip.prototype.leave = function (obj) {
17014 var self = obj instanceof this.constructor ?
17015 obj : $(obj.currentTarget).data('bs.' + this.type)
17016
17017 if (!self) {
17018 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
17019 $(obj.currentTarget).data('bs.' + this.type, self)
17020 }
17021
17022 clearTimeout(self.timeout)
17023
17024 self.hoverState = 'out'
17025
17026 if (!self.options.delay || !self.options.delay.hide) return self.hide()
17027
17028 self.timeout = setTimeout(function () {
17029 if (self.hoverState == 'out') self.hide()
17030 }, self.options.delay.hide)
17031 }
17032
17033 Tooltip.prototype.show = function () {
17034 var e = $.Event('show.bs.' + this.type)
17035
17036 if (this.hasContent() && this.enabled) {
17037 this.$element.trigger(e)
17038
17039 var inDom = $.contains(document.documentElement, this.$element[0])
17040 if (e.isDefaultPrevented() || !inDom) return
17041 var that = this
17042
17043 var $tip = this.tip()
17044
17045 var tipId = this.getUID(this.type)
17046
17047 this.setContent()
17048 $tip.attr('id', tipId)
17049 this.$element.attr('aria-describedby', tipId)
17050
17051 if (this.options.animation) $tip.addClass('fade')
17052
17053 var placement = typeof this.options.placement == 'function' ?
17054 this.options.placement.call(this, $tip[0], this.$element[0]) :
17055 this.options.placement
17056
17057 var autoToken = /\s?auto?\s?/i
17058 var autoPlace = autoToken.test(placement)
17059 if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
17060
17061 $tip
17062 .detach()
17063 .css({ top: 0, left: 0, display: 'block' })
17064 .addClass(placement)
17065 .data('bs.' + this.type, this)
17066
17067 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
17068
17069 var pos = this.getPosition()
17070 var actualWidth = $tip[0].offsetWidth
17071 var actualHeight = $tip[0].offsetHeight
17072
17073 if (autoPlace) {
17074 var orgPlacement = placement
17075 var $parent = this.$element.parent()
17076 var parentDim = this.getPosition($parent)
17077
17078 placement = placement == 'bottom' && pos.top + pos.height + actualHeight - parentDim.scroll > parentDim.height ? 'top' :
17079 placement == 'top' && pos.top - parentDim.scroll - actualHeight < 0 ? 'bottom' :
17080 placement == 'right' && pos.right + actualWidth > parentDim.width ? 'left' :
17081 placement == 'left' && pos.left - actualWidth < parentDim.left ? 'right' :
17082 placement
17083
17084 $tip
17085 .removeClass(orgPlacement)
17086 .addClass(placement)
17087 }
17088
17089 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
17090
17091 this.applyPlacement(calculatedOffset, placement)
17092
17093 var complete = function () {
17094 that.$element.trigger('shown.bs.' + that.type)
17095 that.hoverState = null
17096 }
17097
17098 $.support.transition && this.$tip.hasClass('fade') ?
17099 $tip
17100 .one('bsTransitionEnd', complete)
17101 .emulateTransitionEnd(150) :
17102 complete()
17103 }
17104 }
17105
17106 Tooltip.prototype.applyPlacement = function (offset, placement) {
17107 var $tip = this.tip()
17108 var width = $tip[0].offsetWidth
17109 var height = $tip[0].offsetHeight
17110
17111 // manually read margins because getBoundingClientRect includes difference
17112 var marginTop = parseInt($tip.css('margin-top'), 10)
17113 var marginLeft = parseInt($tip.css('margin-left'), 10)
17114
17115 // we must check for NaN for ie 8/9
17116 if (isNaN(marginTop)) marginTop = 0
17117 if (isNaN(marginLeft)) marginLeft = 0
17118
17119 offset.top = offset.top + marginTop
17120 offset.left = offset.left + marginLeft
17121
17122 // $.fn.offset doesn't round pixel values
17123 // so we use setOffset directly with our own function B-0
17124 $.offset.setOffset($tip[0], $.extend({
17125 using: function (props) {
17126 $tip.css({
17127 top: Math.round(props.top),
17128 left: Math.round(props.left)
17129 })
17130 }
17131 }, offset), 0)
17132
17133 $tip.addClass('in')
17134
17135 // check to see if placing tip in new offset caused the tip to resize itself
17136 var actualWidth = $tip[0].offsetWidth
17137 var actualHeight = $tip[0].offsetHeight
17138
17139 if (placement == 'top' && actualHeight != height) {
17140 offset.top = offset.top + height - actualHeight
17141 }
17142
17143 var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
17144
17145 if (delta.left) offset.left += delta.left
17146 else offset.top += delta.top
17147
17148 var arrowDelta = delta.left ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
17149 var arrowPosition = delta.left ? 'left' : 'top'
17150 var arrowOffsetPosition = delta.left ? 'offsetWidth' : 'offsetHeight'
17151
17152 $tip.offset(offset)
17153 this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], arrowPosition)
17154 }
17155
17156 Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
17157 this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '')
17158 }
17159
17160 Tooltip.prototype.setContent = function () {
17161 var $tip = this.tip()
17162 var title = this.getTitle()
17163
17164 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
17165 $tip.removeClass('fade in top bottom left right')
17166 }
17167
17168 Tooltip.prototype.hide = function () {
17169 var that = this
17170 var $tip = this.tip()
17171 var e = $.Event('hide.bs.' + this.type)
17172
17173 this.$element.removeAttr('aria-describedby')
17174
17175 function complete() {
17176 if (that.hoverState != 'in') $tip.detach()
17177 that.$element.trigger('hidden.bs.' + that.type)
17178 }
17179
17180 this.$element.trigger(e)
17181
17182 if (e.isDefaultPrevented()) return
17183
17184 $tip.removeClass('in')
17185
17186 $.support.transition && this.$tip.hasClass('fade') ?
17187 $tip
17188 .one('bsTransitionEnd', complete)
17189 .emulateTransitionEnd(150) :
17190 complete()
17191
17192 this.hoverState = null
17193
17194 return this
17195 }
17196
17197 Tooltip.prototype.fixTitle = function () {
17198 var $e = this.$element
17199 if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
17200 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
17201 }
17202 }
17203
17204 Tooltip.prototype.hasContent = function () {
17205 return this.getTitle()
17206 }
17207
17208 Tooltip.prototype.getPosition = function ($element) {
17209 $element = $element || this.$element
17210 var el = $element[0]
17211 var isBody = el.tagName == 'BODY'
17212 return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : null, {
17213 scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop(),
17214 width: isBody ? $(window).width() : $element.outerWidth(),
17215 height: isBody ? $(window).height() : $element.outerHeight()
17216 }, isBody ? { top: 0, left: 0 } : $element.offset())
17217 }
17218
17219 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
17220 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
17221 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
17222 placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
17223 /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
17224
17225 }
17226
17227 Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
17228 var delta = { top: 0, left: 0 }
17229 if (!this.$viewport) return delta
17230
17231 var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
17232 var viewportDimensions = this.getPosition(this.$viewport)
17233
17234 if (/right|left/.test(placement)) {
17235 var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
17236 var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
17237 if (topEdgeOffset < viewportDimensions.top) { // top overflow
17238 delta.top = viewportDimensions.top - topEdgeOffset
17239 } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
17240 delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
17241 }
17242 } else {
17243 var leftEdgeOffset = pos.left - viewportPadding
17244 var rightEdgeOffset = pos.left + viewportPadding + actualWidth
17245 if (leftEdgeOffset < viewportDimensions.left) { // left overflow
17246 delta.left = viewportDimensions.left - leftEdgeOffset
17247 } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
17248 delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
17249 }
17250 }
17251
17252 return delta
17253 }
17254
17255 Tooltip.prototype.getTitle = function () {
17256 var title
17257 var $e = this.$element
17258 var o = this.options
17259
17260 title = $e.attr('data-original-title')
17261 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
17262
17263 return title
17264 }
17265
17266 Tooltip.prototype.getUID = function (prefix) {
17267 do prefix += ~~(Math.random() * 1000000)
17268 while (document.getElementById(prefix))
17269 return prefix
17270 }
17271
17272 Tooltip.prototype.tip = function () {
17273 return (this.$tip = this.$tip || $(this.options.template))
17274 }
17275
17276 Tooltip.prototype.arrow = function () {
17277 return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
17278 }
17279
17280 Tooltip.prototype.validate = function () {
17281 if (!this.$element[0].parentNode) {
17282 this.hide()
17283 this.$element = null
17284 this.options = null
17285 }
17286 }
17287
17288 Tooltip.prototype.enable = function () {
17289 this.enabled = true
17290 }
17291
17292 Tooltip.prototype.disable = function () {
17293 this.enabled = false
17294 }
17295
17296 Tooltip.prototype.toggleEnabled = function () {
17297 this.enabled = !this.enabled
17298 }
17299
17300 Tooltip.prototype.toggle = function (e) {
17301 var self = this
17302 if (e) {
17303 self = $(e.currentTarget).data('bs.' + this.type)
17304 if (!self) {
17305 self = new this.constructor(e.currentTarget, this.getDelegateOptions())
17306 $(e.currentTarget).data('bs.' + this.type, self)
17307 }
17308 }
17309
17310 self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
17311 }
17312
17313 Tooltip.prototype.destroy = function () {
17314 clearTimeout(this.timeout)
17315 this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
17316 }
17317
17318
17319 // TOOLTIP PLUGIN DEFINITION
17320 // =========================
17321
17322 function Plugin(option) {
17323 return this.each(function () {
17324 var $this = $(this)
17325 var data = $this.data('bs.tooltip')
17326 var options = typeof option == 'object' && option
17327
17328 if (!data && option == 'destroy') return
17329 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
17330 if (typeof option == 'string') data[option]()
17331 })
17332 }
17333
17334 var old = $.fn.tooltip
17335
17336 $.fn.tooltip = Plugin
17337 $.fn.tooltip.Constructor = Tooltip
17338
17339
17340 // TOOLTIP NO CONFLICT
17341 // ===================
17342
17343 $.fn.tooltip.noConflict = function () {
17344 $.fn.tooltip = old
17345 return this
17346 }
17347
17348 }(jQuery);
17349
17350 /* ========================================================================
17351 * Bootstrap: popover.js v3.2.0
17352 * http://getbootstrap.com/javascript/#popovers
17353 * ========================================================================
17354 * Copyright 2011-2014 Twitter, Inc.
17355 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17356 * ======================================================================== */
17357
17358
17359 +function ($) {
17360 'use strict';
17361
17362 // POPOVER PUBLIC CLASS DEFINITION
17363 // ===============================
17364
17365 var Popover = function (element, options) {
17366 this.init('popover', element, options)
17367 }
17368
17369 if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
17370
17371 Popover.VERSION = '3.2.0'
17372
17373 Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
17374 placement: 'right',
17375 trigger: 'click',
17376 content: '',
17377 template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
17378 })
17379
17380
17381 // NOTE: POPOVER EXTENDS tooltip.js
17382 // ================================
17383
17384 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
17385
17386 Popover.prototype.constructor = Popover
17387
17388 Popover.prototype.getDefaults = function () {
17389 return Popover.DEFAULTS
17390 }
17391
17392 Popover.prototype.setContent = function () {
17393 var $tip = this.tip()
17394 var title = this.getTitle()
17395 var content = this.getContent()
17396
17397 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
17398 $tip.find('.popover-content').empty()[ // we use append for html objects to maintain js events
17399 this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
17400 ](content)
17401
17402 $tip.removeClass('fade top bottom left right in')
17403
17404 // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
17405 // this manually by checking the contents.
17406 if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
17407 }
17408
17409 Popover.prototype.hasContent = function () {
17410 return this.getTitle() || this.getContent()
17411 }
17412
17413 Popover.prototype.getContent = function () {
17414 var $e = this.$element
17415 var o = this.options
17416
17417 return $e.attr('data-content')
17418 || (typeof o.content == 'function' ?
17419 o.content.call($e[0]) :
17420 o.content)
17421 }
17422
17423 Popover.prototype.arrow = function () {
17424 return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
17425 }
17426
17427 Popover.prototype.tip = function () {
17428 if (!this.$tip) this.$tip = $(this.options.template)
17429 return this.$tip
17430 }
17431
17432
17433 // POPOVER PLUGIN DEFINITION
17434 // =========================
17435
17436 function Plugin(option) {
17437 return this.each(function () {
17438 var $this = $(this)
17439 var data = $this.data('bs.popover')
17440 var options = typeof option == 'object' && option
17441
17442 if (!data && option == 'destroy') return
17443 if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
17444 if (typeof option == 'string') data[option]()
17445 })
17446 }
17447
17448 var old = $.fn.popover
17449
17450 $.fn.popover = Plugin
17451 $.fn.popover.Constructor = Popover
17452
17453
17454 // POPOVER NO CONFLICT
17455 // ===================
17456
17457 $.fn.popover.noConflict = function () {
17458 $.fn.popover = old
17459 return this
17460 }
17461
17462 }(jQuery);
17463
17464 /* ========================================================================
17465 * Bootstrap: scrollspy.js v3.2.0
17466 * http://getbootstrap.com/javascript/#scrollspy
17467 * ========================================================================
17468 * Copyright 2011-2014 Twitter, Inc.
17469 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17470 * ======================================================================== */
17471
17472
17473 +function ($) {
17474 'use strict';
17475
17476 // SCROLLSPY CLASS DEFINITION
17477 // ==========================
17478
17479 function ScrollSpy(element, options) {
17480 var process = $.proxy(this.process, this)
17481
17482 this.$body = $('body')
17483 this.$scrollElement = $(element).is('body') ? $(window) : $(element)
17484 this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
17485 this.selector = (this.options.target || '') + ' .nav li > a'
17486 this.offsets = []
17487 this.targets = []
17488 this.activeTarget = null
17489 this.scrollHeight = 0
17490
17491 this.$scrollElement.on('scroll.bs.scrollspy', process)
17492 this.refresh()
17493 this.process()
17494 }
17495
17496 ScrollSpy.VERSION = '3.2.0'
17497
17498 ScrollSpy.DEFAULTS = {
17499 offset: 10
17500 }
17501
17502 ScrollSpy.prototype.getScrollHeight = function () {
17503 return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
17504 }
17505
17506 ScrollSpy.prototype.refresh = function () {
17507 var offsetMethod = 'offset'
17508 var offsetBase = 0
17509
17510 if (!$.isWindow(this.$scrollElement[0])) {
17511 offsetMethod = 'position'
17512 offsetBase = this.$scrollElement.scrollTop()
17513 }
17514
17515 this.offsets = []
17516 this.targets = []
17517 this.scrollHeight = this.getScrollHeight()
17518
17519 var self = this
17520
17521 this.$body
17522 .find(this.selector)
17523 .map(function () {
17524 var $el = $(this)
17525 var href = $el.data('target') || $el.attr('href')
17526 var $href = /^#./.test(href) && $(href)
17527
17528 return ($href
17529 && $href.length
17530 && $href.is(':visible')
17531 && [[$href[offsetMethod]().top + offsetBase, href]]) || null
17532 })
17533 .sort(function (a, b) { return a[0] - b[0] })
17534 .each(function () {
17535 self.offsets.push(this[0])
17536 self.targets.push(this[1])
17537 })
17538 }
17539
17540 ScrollSpy.prototype.process = function () {
17541 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
17542 var scrollHeight = this.getScrollHeight()
17543 var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height()
17544 var offsets = this.offsets
17545 var targets = this.targets
17546 var activeTarget = this.activeTarget
17547 var i
17548
17549 if (this.scrollHeight != scrollHeight) {
17550 this.refresh()
17551 }
17552
17553 if (scrollTop >= maxScroll) {
17554 return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
17555 }
17556
17557 if (activeTarget && scrollTop <= offsets[0]) {
17558 return activeTarget != (i = targets[0]) && this.activate(i)
17559 }
17560
17561 for (i = offsets.length; i--;) {
17562 activeTarget != targets[i]
17563 && scrollTop >= offsets[i]
17564 && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
17565 && this.activate(targets[i])
17566 }
17567 }
17568
17569 ScrollSpy.prototype.activate = function (target) {
17570 this.activeTarget = target
17571
17572 $(this.selector)
17573 .parentsUntil(this.options.target, '.active')
17574 .removeClass('active')
17575
17576 var selector = this.selector +
17577 '[data-target="' + target + '"],' +
17578 this.selector + '[href="' + target + '"]'
17579
17580 var active = $(selector)
17581 .parents('li')
17582 .addClass('active')
17583
17584 if (active.parent('.dropdown-menu').length) {
17585 active = active
17586 .closest('li.dropdown')
17587 .addClass('active')
17588 }
17589
17590 active.trigger('activate.bs.scrollspy')
17591 }
17592
17593
17594 // SCROLLSPY PLUGIN DEFINITION
17595 // ===========================
17596
17597 function Plugin(option) {
17598 return this.each(function () {
17599 var $this = $(this)
17600 var data = $this.data('bs.scrollspy')
17601 var options = typeof option == 'object' && option
17602
17603 if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
17604 if (typeof option == 'string') data[option]()
17605 })
17606 }
17607
17608 var old = $.fn.scrollspy
17609
17610 $.fn.scrollspy = Plugin
17611 $.fn.scrollspy.Constructor = ScrollSpy
17612
17613
17614 // SCROLLSPY NO CONFLICT
17615 // =====================
17616
17617 $.fn.scrollspy.noConflict = function () {
17618 $.fn.scrollspy = old
17619 return this
17620 }
17621
17622
17623 // SCROLLSPY DATA-API
17624 // ==================
17625
17626 $(window).on('load.bs.scrollspy.data-api', function () {
17627 $('[data-spy="scroll"]').each(function () {
17628 var $spy = $(this)
17629 Plugin.call($spy, $spy.data())
17630 })
17631 })
17632
17633 }(jQuery);
17634
17635 /* ========================================================================
17636 * Bootstrap: tab.js v3.2.0
17637 * http://getbootstrap.com/javascript/#tabs
17638 * ========================================================================
17639 * Copyright 2011-2014 Twitter, Inc.
17640 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17641 * ======================================================================== */
17642
17643
17644 +function ($) {
17645 'use strict';
17646
17647 // TAB CLASS DEFINITION
17648 // ====================
17649
17650 var Tab = function (element) {
17651 this.element = $(element)
17652 }
17653
17654 Tab.VERSION = '3.2.0'
17655
17656 Tab.prototype.show = function () {
17657 var $this = this.element
17658 var $ul = $this.closest('ul:not(.dropdown-menu)')
17659 var selector = $this.data('target')
17660
17661 if (!selector) {
17662 selector = $this.attr('href')
17663 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
17664 }
17665
17666 if ($this.parent('li').hasClass('active')) return
17667
17668 var previous = $ul.find('.active:last a')[0]
17669 var e = $.Event('show.bs.tab', {
17670 relatedTarget: previous
17671 })
17672
17673 $this.trigger(e)
17674
17675 if (e.isDefaultPrevented()) return
17676
17677 var $target = $(selector)
17678
17679 this.activate($this.closest('li'), $ul)
17680 this.activate($target, $target.parent(), function () {
17681 $this.trigger({
17682 type: 'shown.bs.tab',
17683 relatedTarget: previous
17684 })
17685 })
17686 }
17687
17688 Tab.prototype.activate = function (element, container, callback) {
17689 var $active = container.find('> .active')
17690 var transition = callback
17691 && $.support.transition
17692 && $active.hasClass('fade')
17693
17694 function next() {
17695 $active
17696 .removeClass('active')
17697 .find('> .dropdown-menu > .active')
17698 .removeClass('active')
17699
17700 element.addClass('active')
17701
17702 if (transition) {
17703 element[0].offsetWidth // reflow for transition
17704 element.addClass('in')
17705 } else {
17706 element.removeClass('fade')
17707 }
17708
17709 if (element.parent('.dropdown-menu')) {
17710 element.closest('li.dropdown').addClass('active')
17711 }
17712
17713 callback && callback()
17714 }
17715
17716 transition ?
17717 $active
17718 .one('bsTransitionEnd', next)
17719 .emulateTransitionEnd(150) :
17720 next()
17721
17722 $active.removeClass('in')
17723 }
17724
17725
17726 // TAB PLUGIN DEFINITION
17727 // =====================
17728
17729 function Plugin(option) {
17730 return this.each(function () {
17731 var $this = $(this)
17732 var data = $this.data('bs.tab')
17733
17734 if (!data) $this.data('bs.tab', (data = new Tab(this)))
17735 if (typeof option == 'string') data[option]()
17736 })
17737 }
17738
17739 var old = $.fn.tab
17740
17741 $.fn.tab = Plugin
17742 $.fn.tab.Constructor = Tab
17743
17744
17745 // TAB NO CONFLICT
17746 // ===============
17747
17748 $.fn.tab.noConflict = function () {
17749 $.fn.tab = old
17750 return this
17751 }
17752
17753
17754 // TAB DATA-API
17755 // ============
17756
17757 $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
17758 e.preventDefault()
17759 Plugin.call($(this), 'show')
17760 })
17761
17762 }(jQuery);
17763
17764 /* ========================================================================
17765 * Bootstrap: affix.js v3.2.0
17766 * http://getbootstrap.com/javascript/#affix
17767 * ========================================================================
17768 * Copyright 2011-2014 Twitter, Inc.
17769 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17770 * ======================================================================== */
17771
17772
17773 +function ($) {
17774 'use strict';
17775
17776 // AFFIX CLASS DEFINITION
17777 // ======================
17778
17779 var Affix = function (element, options) {
17780 this.options = $.extend({}, Affix.DEFAULTS, options)
17781
17782 this.$target = $(this.options.target)
17783 .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
17784 .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
17785
17786 this.$element = $(element)
17787 this.affixed =
17788 this.unpin =
17789 this.pinnedOffset = null
17790
17791 this.checkPosition()
17792 }
17793
17794 Affix.VERSION = '3.2.0'
17795
17796 Affix.RESET = 'affix affix-top affix-bottom'
17797
17798 Affix.DEFAULTS = {
17799 offset: 0,
17800 target: window
17801 }
17802
17803 Affix.prototype.getPinnedOffset = function () {
17804 if (this.pinnedOffset) return this.pinnedOffset
17805 this.$element.removeClass(Affix.RESET).addClass('affix')
17806 var scrollTop = this.$target.scrollTop()
17807 var position = this.$element.offset()
17808 return (this.pinnedOffset = position.top - scrollTop)
17809 }
17810
17811 Affix.prototype.checkPositionWithEventLoop = function () {
17812 setTimeout($.proxy(this.checkPosition, this), 1)
17813 }
17814
17815 Affix.prototype.checkPosition = function () {
17816 if (!this.$element.is(':visible')) return
17817
17818 var scrollHeight = $(document).height()
17819 var scrollTop = this.$target.scrollTop()
17820 var position = this.$element.offset()
17821 var offset = this.options.offset
17822 var offsetTop = offset.top
17823 var offsetBottom = offset.bottom
17824
17825 if (typeof offset != 'object') offsetBottom = offsetTop = offset
17826 if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
17827 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
17828
17829 var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
17830 offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
17831 offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
17832
17833 if (this.affixed === affix) return
17834 if (this.unpin != null) this.$element.css('top', '')
17835
17836 var affixType = 'affix' + (affix ? '-' + affix : '')
17837 var e = $.Event(affixType + '.bs.affix')
17838
17839 this.$element.trigger(e)
17840
17841 if (e.isDefaultPrevented()) return
17842
17843 this.affixed = affix
17844 this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
17845
17846 this.$element
17847 .removeClass(Affix.RESET)
17848 .addClass(affixType)
17849 .trigger($.Event(affixType.replace('affix', 'affixed')))
17850
17851 if (affix == 'bottom') {
17852 this.$element.offset({
17853 top: scrollHeight - this.$element.height() - offsetBottom
17854 })
17855 }
17856 }
17857
17858
17859 // AFFIX PLUGIN DEFINITION
17860 // =======================
17861
17862 function Plugin(option) {
17863 return this.each(function () {
17864 var $this = $(this)
17865 var data = $this.data('bs.affix')
17866 var options = typeof option == 'object' && option
17867
17868 if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
17869 if (typeof option == 'string') data[option]()
17870 })
17871 }
17872
17873 var old = $.fn.affix
17874
17875 $.fn.affix = Plugin
17876 $.fn.affix.Constructor = Affix
17877
17878
17879 // AFFIX NO CONFLICT
17880 // =================
17881
17882 $.fn.affix.noConflict = function () {
17883 $.fn.affix = old
17884 return this
17885 }
17886
17887
17888 // AFFIX DATA-API
17889 // ==============
17890
17891 $(window).on('load', function () {
17892 $('[data-spy="affix"]').each(function () {
17893 var $spy = $(this)
17894 var data = $spy.data()
17895
17896 data.offset = data.offset || {}
17897
17898 if (data.offsetBottom) data.offset.bottom = data.offsetBottom
17899 if (data.offsetTop) data.offset.top = data.offsetTop
17900
17901 Plugin.call($spy, data)
17902 })
17903 })
17904
17905 }(jQuery);
17906 </script>
17907 <script>
17908 (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){
17909 var assert = _dereq_('assert')
17910
17911 module.exports = BigInteger
17912
17913 // JavaScript engine analysis
17914 var canary = 0xdeadbeefcafe;
17915 var j_lm = ((canary&0xffffff)==0xefcafe);
17916
17917 // (public) Constructor
17918 function BigInteger(a,b,c) {
17919 if (!(this instanceof BigInteger)) {
17920 return new BigInteger(a, b, c);
17921 }
17922
17923 if(a != null) {
17924 if("number" == typeof a) this.fromNumber(a,b,c);
17925 else if(b == null && "string" != typeof a) this.fromString(a,256);
17926 else this.fromString(a,b);
17927 }
17928 }
17929
17930 var proto = BigInteger.prototype;
17931
17932 // return new, unset BigInteger
17933 function nbi() { return new BigInteger(null); }
17934
17935 // Bits per digit
17936 var dbits;
17937
17938 // am: Compute w_j += (x*this_i), propagate carries,
17939 // c is initial carry, returns final carry.
17940 // c < 3*dvalue, x < 2*dvalue, this_i < dvalue
17941 // We need to select the fastest one that works in this environment.
17942
17943 // am1: use a single mult and divide to get the high bits,
17944 // max digit bits should be 26 because
17945 // max internal value = 2*dvalue^2-2*dvalue (< 2^53)
17946 function am1(i,x,w,j,c,n) {
17947 while(--n >= 0) {
17948 var v = x*this[i++]+w[j]+c;
17949 c = Math.floor(v/0x4000000);
17950 w[j++] = v&0x3ffffff;
17951 }
17952 return c;
17953 }
17954 // am2 avoids a big mult-and-extract completely.
17955 // Max digit bits should be <= 30 because we do bitwise ops
17956 // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
17957 function am2(i,x,w,j,c,n) {
17958 var xl = x&0x7fff, xh = x>>15;
17959 while(--n >= 0) {
17960 var l = this[i]&0x7fff;
17961 var h = this[i++]>>15;
17962 var m = xh*l+h*xl;
17963 l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff);
17964 c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);
17965 w[j++] = l&0x3fffffff;
17966 }
17967 return c;
17968 }
17969 // Alternately, set max digit bits to 28 since some
17970 // browsers slow down when dealing with 32-bit numbers.
17971 function am3(i,x,w,j,c,n) {
17972 var xl = x&0x3fff, xh = x>>14;
17973 while(--n >= 0) {
17974 var l = this[i]&0x3fff;
17975 var h = this[i++]>>14;
17976 var m = xh*l+h*xl;
17977 l = xl*l+((m&0x3fff)<<14)+w[j]+c;
17978 c = (l>>28)+(m>>14)+xh*h;
17979 w[j++] = l&0xfffffff;
17980 }
17981 return c;
17982 }
17983
17984 // wtf?
17985 BigInteger.prototype.am = am1;
17986 dbits = 26;
17987
17988 /*
17989 if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
17990 BigInteger.prototype.am = am2;
17991 dbits = 30;
17992 }
17993 else if(j_lm && (navigator.appName != "Netscape")) {
17994 BigInteger.prototype.am = am1;
17995 dbits = 26;
17996 }
17997 else { // Mozilla/Netscape seems to prefer am3
17998 BigInteger.prototype.am = am3;
17999 dbits = 28;
18000 }
18001 */
18002
18003 BigInteger.prototype.DB = dbits;
18004 BigInteger.prototype.DM = ((1<<dbits)-1);
18005 var DV = BigInteger.prototype.DV = (1<<dbits);
18006
18007 var BI_FP = 52;
18008 BigInteger.prototype.FV = Math.pow(2,BI_FP);
18009 BigInteger.prototype.F1 = BI_FP-dbits;
18010 BigInteger.prototype.F2 = 2*dbits-BI_FP;
18011
18012 // Digit conversions
18013 var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
18014 var BI_RC = new Array();
18015 var rr,vv;
18016 rr = "0".charCodeAt(0);
18017 for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
18018 rr = "a".charCodeAt(0);
18019 for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
18020 rr = "A".charCodeAt(0);
18021 for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
18022
18023 function int2char(n) { return BI_RM.charAt(n); }
18024 function intAt(s,i) {
18025 var c = BI_RC[s.charCodeAt(i)];
18026 return (c==null)?-1:c;
18027 }
18028
18029 // (protected) copy this to r
18030 function bnpCopyTo(r) {
18031 for(var i = this.t-1; i >= 0; --i) r[i] = this[i];
18032 r.t = this.t;
18033 r.s = this.s;
18034 }
18035
18036 // (protected) set from integer value x, -DV <= x < DV
18037 function bnpFromInt(x) {
18038 this.t = 1;
18039 this.s = (x<0)?-1:0;
18040 if(x > 0) this[0] = x;
18041 else if(x < -1) this[0] = x+DV;
18042 else this.t = 0;
18043 }
18044
18045 // return bigint initialized to value
18046 function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
18047
18048 // (protected) set from string and radix
18049 function bnpFromString(s,b) {
18050 var self = this;
18051
18052 var k;
18053 if(b == 16) k = 4;
18054 else if(b == 8) k = 3;
18055 else if(b == 256) k = 8; // byte array
18056 else if(b == 2) k = 1;
18057 else if(b == 32) k = 5;
18058 else if(b == 4) k = 2;
18059 else { self.fromRadix(s,b); return; }
18060 self.t = 0;
18061 self.s = 0;
18062 var i = s.length, mi = false, sh = 0;
18063 while(--i >= 0) {
18064 var x = (k==8)?s[i]&0xff:intAt(s,i);
18065 if(x < 0) {
18066 if(s.charAt(i) == "-") mi = true;
18067 continue;
18068 }
18069 mi = false;
18070 if(sh == 0)
18071 self[self.t++] = x;
18072 else if(sh+k > self.DB) {
18073 self[self.t-1] |= (x&((1<<(self.DB-sh))-1))<<sh;
18074 self[self.t++] = (x>>(self.DB-sh));
18075 }
18076 else
18077 self[self.t-1] |= x<<sh;
18078 sh += k;
18079 if(sh >= self.DB) sh -= self.DB;
18080 }
18081 if(k == 8 && (s[0]&0x80) != 0) {
18082 self.s = -1;
18083 if(sh > 0) self[self.t-1] |= ((1<<(self.DB-sh))-1)<<sh;
18084 }
18085 self.clamp();
18086 if(mi) BigInteger.ZERO.subTo(self,self);
18087 }
18088
18089 // (protected) clamp off excess high words
18090 function bnpClamp() {
18091 var c = this.s&this.DM;
18092 while(this.t > 0 && this[this.t-1] == c) --this.t;
18093 }
18094
18095 // (public) return string representation in given radix
18096 function bnToString(b) {
18097 var self = this;
18098 if(self.s < 0) return "-"+self.negate().toString(b);
18099 var k;
18100 if(b == 16) k = 4;
18101 else if(b == 8) k = 3;
18102 else if(b == 2) k = 1;
18103 else if(b == 32) k = 5;
18104 else if(b == 4) k = 2;
18105 else return self.toRadix(b);
18106 var km = (1<<k)-1, d, m = false, r = "", i = self.t;
18107 var p = self.DB-(i*self.DB)%k;
18108 if(i-- > 0) {
18109 if(p < self.DB && (d = self[i]>>p) > 0) { m = true; r = int2char(d); }
18110 while(i >= 0) {
18111 if(p < k) {
18112 d = (self[i]&((1<<p)-1))<<(k-p);
18113 d |= self[--i]>>(p+=self.DB-k);
18114 }
18115 else {
18116 d = (self[i]>>(p-=k))&km;
18117 if(p <= 0) { p += self.DB; --i; }
18118 }
18119 if(d > 0) m = true;
18120 if(m) r += int2char(d);
18121 }
18122 }
18123 return m?r:"0";
18124 }
18125
18126 // (public) -this
18127 function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
18128
18129 // (public) |this|
18130 function bnAbs() { return (this.s<0)?this.negate():this; }
18131
18132 // (public) return + if this > a, - if this < a, 0 if equal
18133 function bnCompareTo(a) {
18134 var r = this.s-a.s;
18135 if(r != 0) return r;
18136 var i = this.t;
18137 r = i-a.t;
18138 if(r != 0) return (this.s<0)?-r:r;
18139 while(--i >= 0) if((r=this[i]-a[i]) != 0) return r;
18140 return 0;
18141 }
18142
18143 // returns bit length of the integer x
18144 function nbits(x) {
18145 var r = 1, t;
18146 if((t=x>>>16) != 0) { x = t; r += 16; }
18147 if((t=x>>8) != 0) { x = t; r += 8; }
18148 if((t=x>>4) != 0) { x = t; r += 4; }
18149 if((t=x>>2) != 0) { x = t; r += 2; }
18150 if((t=x>>1) != 0) { x = t; r += 1; }
18151 return r;
18152 }
18153
18154 // (public) return the number of bits in "this"
18155 function bnBitLength() {
18156 if(this.t <= 0) return 0;
18157 return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM));
18158 }
18159
18160 // (protected) r = this << n*DB
18161 function bnpDLShiftTo(n,r) {
18162 var i;
18163 for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
18164 for(i = n-1; i >= 0; --i) r[i] = 0;
18165 r.t = this.t+n;
18166 r.s = this.s;
18167 }
18168
18169 // (protected) r = this >> n*DB
18170 function bnpDRShiftTo(n,r) {
18171 for(var i = n; i < this.t; ++i) r[i-n] = this[i];
18172 r.t = Math.max(this.t-n,0);
18173 r.s = this.s;
18174 }
18175
18176 // (protected) r = this << n
18177 function bnpLShiftTo(n,r) {
18178 var self = this;
18179 var bs = n%self.DB;
18180 var cbs = self.DB-bs;
18181 var bm = (1<<cbs)-1;
18182 var ds = Math.floor(n/self.DB), c = (self.s<<bs)&self.DM, i;
18183 for(i = self.t-1; i >= 0; --i) {
18184 r[i+ds+1] = (self[i]>>cbs)|c;
18185 c = (self[i]&bm)<<bs;
18186 }
18187 for(i = ds-1; i >= 0; --i) r[i] = 0;
18188 r[ds] = c;
18189 r.t = self.t+ds+1;
18190 r.s = self.s;
18191 r.clamp();
18192 }
18193
18194 // (protected) r = this >> n
18195 function bnpRShiftTo(n,r) {
18196 var self = this;
18197 r.s = self.s;
18198 var ds = Math.floor(n/self.DB);
18199 if(ds >= self.t) { r.t = 0; return; }
18200 var bs = n%self.DB;
18201 var cbs = self.DB-bs;
18202 var bm = (1<<bs)-1;
18203 r[0] = self[ds]>>bs;
18204 for(var i = ds+1; i < self.t; ++i) {
18205 r[i-ds-1] |= (self[i]&bm)<<cbs;
18206 r[i-ds] = self[i]>>bs;
18207 }
18208 if(bs > 0) r[self.t-ds-1] |= (self.s&bm)<<cbs;
18209 r.t = self.t-ds;
18210 r.clamp();
18211 }
18212
18213 // (protected) r = this - a
18214 function bnpSubTo(a,r) {
18215 var self = this;
18216 var i = 0, c = 0, m = Math.min(a.t,self.t);
18217 while(i < m) {
18218 c += self[i]-a[i];
18219 r[i++] = c&self.DM;
18220 c >>= self.DB;
18221 }
18222 if(a.t < self.t) {
18223 c -= a.s;
18224 while(i < self.t) {
18225 c += self[i];
18226 r[i++] = c&self.DM;
18227 c >>= self.DB;
18228 }
18229 c += self.s;
18230 }
18231 else {
18232 c += self.s;
18233 while(i < a.t) {
18234 c -= a[i];
18235 r[i++] = c&self.DM;
18236 c >>= self.DB;
18237 }
18238 c -= a.s;
18239 }
18240 r.s = (c<0)?-1:0;
18241 if(c < -1) r[i++] = self.DV+c;
18242 else if(c > 0) r[i++] = c;
18243 r.t = i;
18244 r.clamp();
18245 }
18246
18247 // (protected) r = this * a, r != this,a (HAC 14.12)
18248 // "this" should be the larger one if appropriate.
18249 function bnpMultiplyTo(a,r) {
18250 var x = this.abs(), y = a.abs();
18251 var i = x.t;
18252 r.t = i+y.t;
18253 while(--i >= 0) r[i] = 0;
18254 for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t);
18255 r.s = 0;
18256 r.clamp();
18257 if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
18258 }
18259
18260 // (protected) r = this^2, r != this (HAC 14.16)
18261 function bnpSquareTo(r) {
18262 var x = this.abs();
18263 var i = r.t = 2*x.t;
18264 while(--i >= 0) r[i] = 0;
18265 for(i = 0; i < x.t-1; ++i) {
18266 var c = x.am(i,x[i],r,2*i,0,1);
18267 if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {
18268 r[i+x.t] -= x.DV;
18269 r[i+x.t+1] = 1;
18270 }
18271 }
18272 if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1);
18273 r.s = 0;
18274 r.clamp();
18275 }
18276
18277 // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
18278 // r != q, this != m. q or r may be null.
18279 function bnpDivRemTo(m,q,r) {
18280 var self = this;
18281 var pm = m.abs();
18282 if(pm.t <= 0) return;
18283 var pt = self.abs();
18284 if(pt.t < pm.t) {
18285 if(q != null) q.fromInt(0);
18286 if(r != null) self.copyTo(r);
18287 return;
18288 }
18289 if(r == null) r = nbi();
18290 var y = nbi(), ts = self.s, ms = m.s;
18291 var nsh = self.DB-nbits(pm[pm.t-1]); // normalize modulus
18292 if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); }
18293 else { pm.copyTo(y); pt.copyTo(r); }
18294 var ys = y.t;
18295 var y0 = y[ys-1];
18296 if(y0 == 0) return;
18297 var yt = y0*(1<<self.F1)+((ys>1)?y[ys-2]>>self.F2:0);
18298 var d1 = self.FV/yt, d2 = (1<<self.F1)/yt, e = 1<<self.F2;
18299 var i = r.t, j = i-ys, t = (q==null)?nbi():q;
18300 y.dlShiftTo(j,t);
18301 if(r.compareTo(t) >= 0) {
18302 r[r.t++] = 1;
18303 r.subTo(t,r);
18304 }
18305 BigInteger.ONE.dlShiftTo(ys,t);
18306 t.subTo(y,y); // "negative" y so we can replace sub with am later
18307 while(y.t < ys) y[y.t++] = 0;
18308 while(--j >= 0) {
18309 // Estimate quotient digit
18310 var qd = (r[--i]==y0)?self.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);
18311 if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out
18312 y.dlShiftTo(j,t);
18313 r.subTo(t,r);
18314 while(r[i] < --qd) r.subTo(t,r);
18315 }
18316 }
18317 if(q != null) {
18318 r.drShiftTo(ys,q);
18319 if(ts != ms) BigInteger.ZERO.subTo(q,q);
18320 }
18321 r.t = ys;
18322 r.clamp();
18323 if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder
18324 if(ts < 0) BigInteger.ZERO.subTo(r,r);
18325 }
18326
18327 // (public) this mod a
18328 function bnMod(a) {
18329 var r = nbi();
18330 this.abs().divRemTo(a,null,r);
18331 if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);
18332 return r;
18333 }
18334
18335 // Modular reduction using "classic" algorithm
18336 function Classic(m) { this.m = m; }
18337 function cConvert(x) {
18338 if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
18339 else return x;
18340 }
18341 function cRevert(x) { return x; }
18342 function cReduce(x) { x.divRemTo(this.m,null,x); }
18343 function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18344 function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18345
18346 Classic.prototype.convert = cConvert;
18347 Classic.prototype.revert = cRevert;
18348 Classic.prototype.reduce = cReduce;
18349 Classic.prototype.mulTo = cMulTo;
18350 Classic.prototype.sqrTo = cSqrTo;
18351
18352 // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
18353 // justification:
18354 // xy == 1 (mod m)
18355 // xy = 1+km
18356 // xy(2-xy) = (1+km)(1-km)
18357 // x[y(2-xy)] = 1-k^2m^2
18358 // x[y(2-xy)] == 1 (mod m^2)
18359 // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
18360 // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
18361 // JS multiply "overflows" differently from C/C++, so care is needed here.
18362 function bnpInvDigit() {
18363 if(this.t < 1) return 0;
18364 var x = this[0];
18365 if((x&1) == 0) return 0;
18366 var y = x&3; // y == 1/x mod 2^2
18367 y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4
18368 y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8
18369 y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16
18370 // last step - calculate inverse mod DV directly;
18371 // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
18372 y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits
18373 // we really want the negative inverse, and -DV < y < DV
18374 return (y>0)?this.DV-y:-y;
18375 }
18376
18377 // Montgomery reduction
18378 function Montgomery(m) {
18379 this.m = m;
18380 this.mp = m.invDigit();
18381 this.mpl = this.mp&0x7fff;
18382 this.mph = this.mp>>15;
18383 this.um = (1<<(m.DB-15))-1;
18384 this.mt2 = 2*m.t;
18385 }
18386
18387 // xR mod m
18388 function montConvert(x) {
18389 var r = nbi();
18390 x.abs().dlShiftTo(this.m.t,r);
18391 r.divRemTo(this.m,null,r);
18392 if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);
18393 return r;
18394 }
18395
18396 // x/R mod m
18397 function montRevert(x) {
18398 var r = nbi();
18399 x.copyTo(r);
18400 this.reduce(r);
18401 return r;
18402 }
18403
18404 // x = x/R mod m (HAC 14.32)
18405 function montReduce(x) {
18406 while(x.t <= this.mt2) // pad x so am has enough room later
18407 x[x.t++] = 0;
18408 for(var i = 0; i < this.m.t; ++i) {
18409 // faster way of calculating u0 = x[i]*mp mod DV
18410 var j = x[i]&0x7fff;
18411 var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM;
18412 // use am to combine the multiply-shift-add into one call
18413 j = i+this.m.t;
18414 x[j] += this.m.am(0,u0,x,i,0,this.m.t);
18415 // propagate carry
18416 while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
18417 }
18418 x.clamp();
18419 x.drShiftTo(this.m.t,x);
18420 if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
18421 }
18422
18423 // r = "x^2/R mod m"; x != r
18424 function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18425
18426 // r = "xy/R mod m"; x,y != r
18427 function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18428
18429 Montgomery.prototype.convert = montConvert;
18430 Montgomery.prototype.revert = montRevert;
18431 Montgomery.prototype.reduce = montReduce;
18432 Montgomery.prototype.mulTo = montMulTo;
18433 Montgomery.prototype.sqrTo = montSqrTo;
18434
18435 // (protected) true iff this is even
18436 function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
18437
18438 // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
18439 function bnpExp(e,z) {
18440 if(e > 0xffffffff || e < 1) return BigInteger.ONE;
18441 var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
18442 g.copyTo(r);
18443 while(--i >= 0) {
18444 z.sqrTo(r,r2);
18445 if((e&(1<<i)) > 0) z.mulTo(r2,g,r);
18446 else { var t = r; r = r2; r2 = t; }
18447 }
18448 return z.revert(r);
18449 }
18450
18451 // (public) this^e % m, 0 <= e < 2^32
18452 function bnModPowInt(e,m) {
18453 var z;
18454 if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
18455 return this.exp(e,z);
18456 }
18457
18458 // protected
18459 proto.copyTo = bnpCopyTo;
18460 proto.fromInt = bnpFromInt;
18461 proto.fromString = bnpFromString;
18462 proto.clamp = bnpClamp;
18463 proto.dlShiftTo = bnpDLShiftTo;
18464 proto.drShiftTo = bnpDRShiftTo;
18465 proto.lShiftTo = bnpLShiftTo;
18466 proto.rShiftTo = bnpRShiftTo;
18467 proto.subTo = bnpSubTo;
18468 proto.multiplyTo = bnpMultiplyTo;
18469 proto.squareTo = bnpSquareTo;
18470 proto.divRemTo = bnpDivRemTo;
18471 proto.invDigit = bnpInvDigit;
18472 proto.isEven = bnpIsEven;
18473 proto.exp = bnpExp;
18474
18475 // public
18476 proto.toString = bnToString;
18477 proto.negate = bnNegate;
18478 proto.abs = bnAbs;
18479 proto.compareTo = bnCompareTo;
18480 proto.bitLength = bnBitLength;
18481 proto.mod = bnMod;
18482 proto.modPowInt = bnModPowInt;
18483
18484 //// jsbn2
18485
18486 function nbi() { return new BigInteger(null); }
18487
18488 // (public)
18489 function bnClone() { var r = nbi(); this.copyTo(r); return r; }
18490
18491 // (public) return value as integer
18492 function bnIntValue() {
18493 if(this.s < 0) {
18494 if(this.t == 1) return this[0]-this.DV;
18495 else if(this.t == 0) return -1;
18496 }
18497 else if(this.t == 1) return this[0];
18498 else if(this.t == 0) return 0;
18499 // assumes 16 < DB < 32
18500 return ((this[1]&((1<<(32-this.DB))-1))<<this.DB)|this[0];
18501 }
18502
18503 // (public) return value as byte
18504 function bnByteValue() { return (this.t==0)?this.s:(this[0]<<24)>>24; }
18505
18506 // (public) return value as short (assumes DB>=16)
18507 function bnShortValue() { return (this.t==0)?this.s:(this[0]<<16)>>16; }
18508
18509 // (protected) return x s.t. r^x < DV
18510 function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }
18511
18512 // (public) 0 if this == 0, 1 if this > 0
18513 function bnSigNum() {
18514 if(this.s < 0) return -1;
18515 else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
18516 else return 1;
18517 }
18518
18519 // (protected) convert to radix string
18520 function bnpToRadix(b) {
18521 if(b == null) b = 10;
18522 if(this.signum() == 0 || b < 2 || b > 36) return "0";
18523 var cs = this.chunkSize(b);
18524 var a = Math.pow(b,cs);
18525 var d = nbv(a), y = nbi(), z = nbi(), r = "";
18526 this.divRemTo(d,y,z);
18527 while(y.signum() > 0) {
18528 r = (a+z.intValue()).toString(b).substr(1) + r;
18529 y.divRemTo(d,y,z);
18530 }
18531 return z.intValue().toString(b) + r;
18532 }
18533
18534 // (protected) convert from radix string
18535 function bnpFromRadix(s,b) {
18536 var self = this;
18537 self.fromInt(0);
18538 if(b == null) b = 10;
18539 var cs = self.chunkSize(b);
18540 var d = Math.pow(b,cs), mi = false, j = 0, w = 0;
18541 for(var i = 0; i < s.length; ++i) {
18542 var x = intAt(s,i);
18543 if(x < 0) {
18544 if(s.charAt(i) == "-" && self.signum() == 0) mi = true;
18545 continue;
18546 }
18547 w = b*w+x;
18548 if(++j >= cs) {
18549 self.dMultiply(d);
18550 self.dAddOffset(w,0);
18551 j = 0;
18552 w = 0;
18553 }
18554 }
18555 if(j > 0) {
18556 self.dMultiply(Math.pow(b,j));
18557 self.dAddOffset(w,0);
18558 }
18559 if(mi) BigInteger.ZERO.subTo(self,self);
18560 }
18561
18562 // (protected) alternate constructor
18563 function bnpFromNumber(a,b,c) {
18564 var self = this;
18565 if("number" == typeof b) {
18566 // new BigInteger(int,int,RNG)
18567 if(a < 2) self.fromInt(1);
18568 else {
18569 self.fromNumber(a,c);
18570 if(!self.testBit(a-1)) // force MSB set
18571 self.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,self);
18572 if(self.isEven()) self.dAddOffset(1,0); // force odd
18573 while(!self.isProbablePrime(b)) {
18574 self.dAddOffset(2,0);
18575 if(self.bitLength() > a) self.subTo(BigInteger.ONE.shiftLeft(a-1),self);
18576 }
18577 }
18578 }
18579 else {
18580 // new BigInteger(int,RNG)
18581 var x = new Array(), t = a&7;
18582 x.length = (a>>3)+1;
18583 b.nextBytes(x);
18584 if(t > 0) x[0] &= ((1<<t)-1); else x[0] = 0;
18585 self.fromString(x,256);
18586 }
18587 }
18588
18589 // (public) convert to bigendian byte array
18590 function bnToByteArray() {
18591 var self = this;
18592 var i = self.t, r = new Array();
18593 r[0] = self.s;
18594 var p = self.DB-(i*self.DB)%8, d, k = 0;
18595 if(i-- > 0) {
18596 if(p < self.DB && (d = self[i]>>p) != (self.s&self.DM)>>p)
18597 r[k++] = d|(self.s<<(self.DB-p));
18598 while(i >= 0) {
18599 if(p < 8) {
18600 d = (self[i]&((1<<p)-1))<<(8-p);
18601 d |= self[--i]>>(p+=self.DB-8);
18602 }
18603 else {
18604 d = (self[i]>>(p-=8))&0xff;
18605 if(p <= 0) { p += self.DB; --i; }
18606 }
18607 if((d&0x80) != 0) d |= -256;
18608 if(k === 0 && (self.s&0x80) != (d&0x80)) ++k;
18609 if(k > 0 || d != self.s) r[k++] = d;
18610 }
18611 }
18612 return r;
18613 }
18614
18615 function bnEquals(a) { return(this.compareTo(a)==0); }
18616 function bnMin(a) { return(this.compareTo(a)<0)?this:a; }
18617 function bnMax(a) { return(this.compareTo(a)>0)?this:a; }
18618
18619 // (protected) r = this op a (bitwise)
18620 function bnpBitwiseTo(a,op,r) {
18621 var self = this;
18622 var i, f, m = Math.min(a.t,self.t);
18623 for(i = 0; i < m; ++i) r[i] = op(self[i],a[i]);
18624 if(a.t < self.t) {
18625 f = a.s&self.DM;
18626 for(i = m; i < self.t; ++i) r[i] = op(self[i],f);
18627 r.t = self.t;
18628 }
18629 else {
18630 f = self.s&self.DM;
18631 for(i = m; i < a.t; ++i) r[i] = op(f,a[i]);
18632 r.t = a.t;
18633 }
18634 r.s = op(self.s,a.s);
18635 r.clamp();
18636 }
18637
18638 // (public) this & a
18639 function op_and(x,y) { return x&y; }
18640 function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
18641
18642 // (public) this | a
18643 function op_or(x,y) { return x|y; }
18644 function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
18645
18646 // (public) this ^ a
18647 function op_xor(x,y) { return x^y; }
18648 function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
18649
18650 // (public) this & ~a
18651 function op_andnot(x,y) { return x&~y; }
18652 function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
18653
18654 // (public) ~this
18655 function bnNot() {
18656 var r = nbi();
18657 for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i];
18658 r.t = this.t;
18659 r.s = ~this.s;
18660 return r;
18661 }
18662
18663 // (public) this << n
18664 function bnShiftLeft(n) {
18665 var r = nbi();
18666 if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
18667 return r;
18668 }
18669
18670 // (public) this >> n
18671 function bnShiftRight(n) {
18672 var r = nbi();
18673 if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
18674 return r;
18675 }
18676
18677 // return index of lowest 1-bit in x, x < 2^31
18678 function lbit(x) {
18679 if(x == 0) return -1;
18680 var r = 0;
18681 if((x&0xffff) == 0) { x >>= 16; r += 16; }
18682 if((x&0xff) == 0) { x >>= 8; r += 8; }
18683 if((x&0xf) == 0) { x >>= 4; r += 4; }
18684 if((x&3) == 0) { x >>= 2; r += 2; }
18685 if((x&1) == 0) ++r;
18686 return r;
18687 }
18688
18689 // (public) returns index of lowest 1-bit (or -1 if none)
18690 function bnGetLowestSetBit() {
18691 for(var i = 0; i < this.t; ++i)
18692 if(this[i] != 0) return i*this.DB+lbit(this[i]);
18693 if(this.s < 0) return this.t*this.DB;
18694 return -1;
18695 }
18696
18697 // return number of 1 bits in x
18698 function cbit(x) {
18699 var r = 0;
18700 while(x != 0) { x &= x-1; ++r; }
18701 return r;
18702 }
18703
18704 // (public) return number of set bits
18705 function bnBitCount() {
18706 var r = 0, x = this.s&this.DM;
18707 for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x);
18708 return r;
18709 }
18710
18711 // (public) true iff nth bit is set
18712 function bnTestBit(n) {
18713 var j = Math.floor(n/this.DB);
18714 if(j >= this.t) return(this.s!=0);
18715 return((this[j]&(1<<(n%this.DB)))!=0);
18716 }
18717
18718 // (protected) this op (1<<n)
18719 function bnpChangeBit(n,op) {
18720 var r = BigInteger.ONE.shiftLeft(n);
18721 this.bitwiseTo(r,op,r);
18722 return r;
18723 }
18724
18725 // (public) this | (1<<n)
18726 function bnSetBit(n) { return this.changeBit(n,op_or); }
18727
18728 // (public) this & ~(1<<n)
18729 function bnClearBit(n) { return this.changeBit(n,op_andnot); }
18730
18731 // (public) this ^ (1<<n)
18732 function bnFlipBit(n) { return this.changeBit(n,op_xor); }
18733
18734 // (protected) r = this + a
18735 function bnpAddTo(a,r) {
18736 var self = this;
18737
18738 var i = 0, c = 0, m = Math.min(a.t,self.t);
18739 while(i < m) {
18740 c += self[i]+a[i];
18741 r[i++] = c&self.DM;
18742 c >>= self.DB;
18743 }
18744 if(a.t < self.t) {
18745 c += a.s;
18746 while(i < self.t) {
18747 c += self[i];
18748 r[i++] = c&self.DM;
18749 c >>= self.DB;
18750 }
18751 c += self.s;
18752 }
18753 else {
18754 c += self.s;
18755 while(i < a.t) {
18756 c += a[i];
18757 r[i++] = c&self.DM;
18758 c >>= self.DB;
18759 }
18760 c += a.s;
18761 }
18762 r.s = (c<0)?-1:0;
18763 if(c > 0) r[i++] = c;
18764 else if(c < -1) r[i++] = self.DV+c;
18765 r.t = i;
18766 r.clamp();
18767 }
18768
18769 // (public) this + a
18770 function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }
18771
18772 // (public) this - a
18773 function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }
18774
18775 // (public) this * a
18776 function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }
18777
18778 // (public) this^2
18779 function bnSquare() { var r = nbi(); this.squareTo(r); return r; }
18780
18781 // (public) this / a
18782 function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }
18783
18784 // (public) this % a
18785 function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }
18786
18787 // (public) [this/a,this%a]
18788 function bnDivideAndRemainder(a) {
18789 var q = nbi(), r = nbi();
18790 this.divRemTo(a,q,r);
18791 return new Array(q,r);
18792 }
18793
18794 // (protected) this *= n, this >= 0, 1 < n < DV
18795 function bnpDMultiply(n) {
18796 this[this.t] = this.am(0,n-1,this,0,0,this.t);
18797 ++this.t;
18798 this.clamp();
18799 }
18800
18801 // (protected) this += n << w words, this >= 0
18802 function bnpDAddOffset(n,w) {
18803 if(n == 0) return;
18804 while(this.t <= w) this[this.t++] = 0;
18805 this[w] += n;
18806 while(this[w] >= this.DV) {
18807 this[w] -= this.DV;
18808 if(++w >= this.t) this[this.t++] = 0;
18809 ++this[w];
18810 }
18811 }
18812
18813 // A "null" reducer
18814 function NullExp() {}
18815 function nNop(x) { return x; }
18816 function nMulTo(x,y,r) { x.multiplyTo(y,r); }
18817 function nSqrTo(x,r) { x.squareTo(r); }
18818
18819 NullExp.prototype.convert = nNop;
18820 NullExp.prototype.revert = nNop;
18821 NullExp.prototype.mulTo = nMulTo;
18822 NullExp.prototype.sqrTo = nSqrTo;
18823
18824 // (public) this^e
18825 function bnPow(e) { return this.exp(e,new NullExp()); }
18826
18827 // (protected) r = lower n words of "this * a", a.t <= n
18828 // "this" should be the larger one if appropriate.
18829 function bnpMultiplyLowerTo(a,n,r) {
18830 var i = Math.min(this.t+a.t,n);
18831 r.s = 0; // assumes a,this >= 0
18832 r.t = i;
18833 while(i > 0) r[--i] = 0;
18834 var j;
18835 for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(0,a[i],r,i,0,this.t);
18836 for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a[i],r,i,0,n-i);
18837 r.clamp();
18838 }
18839
18840 // (protected) r = "this * a" without lower n words, n > 0
18841 // "this" should be the larger one if appropriate.
18842 function bnpMultiplyUpperTo(a,n,r) {
18843 --n;
18844 var i = r.t = this.t+a.t-n;
18845 r.s = 0; // assumes a,this >= 0
18846 while(--i >= 0) r[i] = 0;
18847 for(i = Math.max(n-this.t,0); i < a.t; ++i)
18848 r[this.t+i-n] = this.am(n-i,a[i],r,0,0,this.t+i-n);
18849 r.clamp();
18850 r.drShiftTo(1,r);
18851 }
18852
18853 // Barrett modular reduction
18854 function Barrett(m) {
18855 // setup Barrett
18856 this.r2 = nbi();
18857 this.q3 = nbi();
18858 BigInteger.ONE.dlShiftTo(2*m.t,this.r2);
18859 this.mu = this.r2.divide(m);
18860 this.m = m;
18861 }
18862
18863 function barrettConvert(x) {
18864 if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m);
18865 else if(x.compareTo(this.m) < 0) return x;
18866 else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }
18867 }
18868
18869 function barrettRevert(x) { return x; }
18870
18871 // x = x mod m (HAC 14.42)
18872 function barrettReduce(x) {
18873 var self = this;
18874 x.drShiftTo(self.m.t-1,self.r2);
18875 if(x.t > self.m.t+1) { x.t = self.m.t+1; x.clamp(); }
18876 self.mu.multiplyUpperTo(self.r2,self.m.t+1,self.q3);
18877 self.m.multiplyLowerTo(self.q3,self.m.t+1,self.r2);
18878 while(x.compareTo(self.r2) < 0) x.dAddOffset(1,self.m.t+1);
18879 x.subTo(self.r2,x);
18880 while(x.compareTo(self.m) >= 0) x.subTo(self.m,x);
18881 }
18882
18883 // r = x^2 mod m; x != r
18884 function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18885
18886 // r = x*y mod m; x,y != r
18887 function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18888
18889 Barrett.prototype.convert = barrettConvert;
18890 Barrett.prototype.revert = barrettRevert;
18891 Barrett.prototype.reduce = barrettReduce;
18892 Barrett.prototype.mulTo = barrettMulTo;
18893 Barrett.prototype.sqrTo = barrettSqrTo;
18894
18895 // (public) this^e % m (HAC 14.85)
18896 function bnModPow(e,m) {
18897 var i = e.bitLength(), k, r = nbv(1), z;
18898 if(i <= 0) return r;
18899 else if(i < 18) k = 1;
18900 else if(i < 48) k = 3;
18901 else if(i < 144) k = 4;
18902 else if(i < 768) k = 5;
18903 else k = 6;
18904 if(i < 8)
18905 z = new Classic(m);
18906 else if(m.isEven())
18907 z = new Barrett(m);
18908 else
18909 z = new Montgomery(m);
18910
18911 // precomputation
18912 var g = new Array(), n = 3, k1 = k-1, km = (1<<k)-1;
18913 g[1] = z.convert(this);
18914 if(k > 1) {
18915 var g2 = nbi();
18916 z.sqrTo(g[1],g2);
18917 while(n <= km) {
18918 g[n] = nbi();
18919 z.mulTo(g2,g[n-2],g[n]);
18920 n += 2;
18921 }
18922 }
18923
18924 var j = e.t-1, w, is1 = true, r2 = nbi(), t;
18925 i = nbits(e[j])-1;
18926 while(j >= 0) {
18927 if(i >= k1) w = (e[j]>>(i-k1))&km;
18928 else {
18929 w = (e[j]&((1<<(i+1))-1))<<(k1-i);
18930 if(j > 0) w |= e[j-1]>>(this.DB+i-k1);
18931 }
18932
18933 n = k;
18934 while((w&1) == 0) { w >>= 1; --n; }
18935 if((i -= n) < 0) { i += this.DB; --j; }
18936 if(is1) { // ret == 1, don't bother squaring or multiplying it
18937 g[w].copyTo(r);
18938 is1 = false;
18939 }
18940 else {
18941 while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; }
18942 if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }
18943 z.mulTo(r2,g[w],r);
18944 }
18945
18946 while(j >= 0 && (e[j]&(1<<i)) == 0) {
18947 z.sqrTo(r,r2); t = r; r = r2; r2 = t;
18948 if(--i < 0) { i = this.DB-1; --j; }
18949 }
18950 }
18951 return z.revert(r);
18952 }
18953
18954 // (public) gcd(this,a) (HAC 14.54)
18955 function bnGCD(a) {
18956 var x = (this.s<0)?this.negate():this.clone();
18957 var y = (a.s<0)?a.negate():a.clone();
18958 if(x.compareTo(y) < 0) { var t = x; x = y; y = t; }
18959 var i = x.getLowestSetBit(), g = y.getLowestSetBit();
18960 if(g < 0) return x;
18961 if(i < g) g = i;
18962 if(g > 0) {
18963 x.rShiftTo(g,x);
18964 y.rShiftTo(g,y);
18965 }
18966 while(x.signum() > 0) {
18967 if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x);
18968 if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y);
18969 if(x.compareTo(y) >= 0) {
18970 x.subTo(y,x);
18971 x.rShiftTo(1,x);
18972 }
18973 else {
18974 y.subTo(x,y);
18975 y.rShiftTo(1,y);
18976 }
18977 }
18978 if(g > 0) y.lShiftTo(g,y);
18979 return y;
18980 }
18981
18982 // (protected) this % n, n < 2^26
18983 function bnpModInt(n) {
18984 if(n <= 0) return 0;
18985 var d = this.DV%n, r = (this.s<0)?n-1:0;
18986 if(this.t > 0)
18987 if(d == 0) r = this[0]%n;
18988 else for(var i = this.t-1; i >= 0; --i) r = (d*r+this[i])%n;
18989 return r;
18990 }
18991
18992 // (public) 1/this % m (HAC 14.61)
18993 function bnModInverse(m) {
18994 var ac = m.isEven();
18995 if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
18996 var u = m.clone(), v = this.clone();
18997 var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
18998 while(u.signum() != 0) {
18999 while(u.isEven()) {
19000 u.rShiftTo(1,u);
19001 if(ac) {
19002 if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }
19003 a.rShiftTo(1,a);
19004 }
19005 else if(!b.isEven()) b.subTo(m,b);
19006 b.rShiftTo(1,b);
19007 }
19008 while(v.isEven()) {
19009 v.rShiftTo(1,v);
19010 if(ac) {
19011 if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }
19012 c.rShiftTo(1,c);
19013 }
19014 else if(!d.isEven()) d.subTo(m,d);
19015 d.rShiftTo(1,d);
19016 }
19017 if(u.compareTo(v) >= 0) {
19018 u.subTo(v,u);
19019 if(ac) a.subTo(c,a);
19020 b.subTo(d,b);
19021 }
19022 else {
19023 v.subTo(u,v);
19024 if(ac) c.subTo(a,c);
19025 d.subTo(b,d);
19026 }
19027 }
19028 if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
19029 if(d.compareTo(m) >= 0) return d.subtract(m);
19030 if(d.signum() < 0) d.addTo(m,d); else return d;
19031 if(d.signum() < 0) return d.add(m); else return d;
19032 }
19033
19034 // protected
19035 proto.chunkSize = bnpChunkSize;
19036 proto.toRadix = bnpToRadix;
19037 proto.fromRadix = bnpFromRadix;
19038 proto.fromNumber = bnpFromNumber;
19039 proto.bitwiseTo = bnpBitwiseTo;
19040 proto.changeBit = bnpChangeBit;
19041 proto.addTo = bnpAddTo;
19042 proto.dMultiply = bnpDMultiply;
19043 proto.dAddOffset = bnpDAddOffset;
19044 proto.multiplyLowerTo = bnpMultiplyLowerTo;
19045 proto.multiplyUpperTo = bnpMultiplyUpperTo;
19046 proto.modInt = bnpModInt;
19047
19048 // public
19049 proto.clone = bnClone;
19050 proto.intValue = bnIntValue;
19051 proto.byteValue = bnByteValue;
19052 proto.shortValue = bnShortValue;
19053 proto.signum = bnSigNum;
19054 proto.toByteArray = bnToByteArray;
19055 proto.equals = bnEquals;
19056 proto.min = bnMin;
19057 proto.max = bnMax;
19058 proto.and = bnAnd;
19059 proto.or = bnOr;
19060 proto.xor = bnXor;
19061 proto.andNot = bnAndNot;
19062 proto.not = bnNot;
19063 proto.shiftLeft = bnShiftLeft;
19064 proto.shiftRight = bnShiftRight;
19065 proto.getLowestSetBit = bnGetLowestSetBit;
19066 proto.bitCount = bnBitCount;
19067 proto.testBit = bnTestBit;
19068 proto.setBit = bnSetBit;
19069 proto.clearBit = bnClearBit;
19070 proto.flipBit = bnFlipBit;
19071 proto.add = bnAdd;
19072 proto.subtract = bnSubtract;
19073 proto.multiply = bnMultiply;
19074 proto.divide = bnDivide;
19075 proto.remainder = bnRemainder;
19076 proto.divideAndRemainder = bnDivideAndRemainder;
19077 proto.modPow = bnModPow;
19078 proto.modInverse = bnModInverse;
19079 proto.pow = bnPow;
19080 proto.gcd = bnGCD;
19081
19082 // JSBN-specific extension
19083 proto.square = bnSquare;
19084
19085 // BigInteger interfaces not implemented in jsbn:
19086
19087 // BigInteger(int signum, byte[] magnitude)
19088 // double doubleValue()
19089 // float floatValue()
19090 // int hashCode()
19091 // long longValue()
19092 // static BigInteger valueOf(long val)
19093
19094 // "constants"
19095 BigInteger.ZERO = nbv(0);
19096 BigInteger.ONE = nbv(1);
19097 BigInteger.valueOf = nbv;
19098
19099 },{"assert":4}],2:[function(_dereq_,module,exports){
19100 (function (Buffer){
19101 // FIXME: Kind of a weird way to throw exceptions, consider removing
19102 var assert = _dereq_('assert')
19103 var BigInteger = _dereq_('./bigi')
19104
19105 /**
19106 * Turns a byte array into a big integer.
19107 *
19108 * This function will interpret a byte array as a big integer in big
19109 * endian notation.
19110 */
19111 BigInteger.fromByteArrayUnsigned = function(byteArray) {
19112 // BigInteger expects a DER integer conformant byte array
19113 if (byteArray[0] & 0x80) {
19114 return new BigInteger([0].concat(byteArray))
19115 }
19116
19117 return new BigInteger(byteArray)
19118 }
19119
19120 /**
19121 * Returns a byte array representation of the big integer.
19122 *
19123 * This returns the absolute of the contained value in big endian
19124 * form. A value of zero results in an empty array.
19125 */
19126 BigInteger.prototype.toByteArrayUnsigned = function() {
19127 var byteArray = this.toByteArray()
19128 return byteArray[0] === 0 ? byteArray.slice(1) : byteArray
19129 }
19130
19131 BigInteger.fromDERInteger = function(byteArray) {
19132 return new BigInteger(byteArray)
19133 }
19134
19135 /*
19136 * Converts BigInteger to a DER integer representation.
19137 *
19138 * The format for this value uses the most significant bit as a sign
19139 * bit. If the most significant bit is already set and the integer is
19140 * positive, a 0x00 is prepended.
19141 *
19142 * Examples:
19143 *
19144 * 0 => 0x00
19145 * 1 => 0x01
19146 * -1 => 0x81
19147 * 127 => 0x7f
19148 * -127 => 0xff
19149 * 128 => 0x0080
19150 * -128 => 0x80
19151 * 255 => 0x00ff
19152 * -255 => 0xff
19153 * 16300 => 0x3fac
19154 * -16300 => 0xbfac
19155 * 62300 => 0x00f35c
19156 * -62300 => 0xf35c
19157 */
19158 BigInteger.prototype.toDERInteger = BigInteger.prototype.toByteArray
19159
19160 BigInteger.fromBuffer = function(buffer) {
19161 // BigInteger expects a DER integer conformant byte array
19162 if (buffer[0] & 0x80) {
19163 var byteArray = Array.prototype.slice.call(buffer)
19164
19165 return new BigInteger([0].concat(byteArray))
19166 }
19167
19168 return new BigInteger(buffer)
19169 }
19170
19171 BigInteger.fromHex = function(hex) {
19172 if (hex === '') return BigInteger.ZERO
19173
19174 assert.equal(hex, hex.match(/^[A-Fa-f0-9]+/), 'Invalid hex string')
19175 assert.equal(hex.length % 2, 0, 'Incomplete hex')
19176 return new BigInteger(hex, 16)
19177 }
19178
19179 BigInteger.prototype.toBuffer = function(size) {
19180 var byteArray = this.toByteArrayUnsigned()
19181 var zeros = []
19182
19183 var padding = size - byteArray.length
19184 while (zeros.length < padding) zeros.push(0)
19185
19186 return new Buffer(zeros.concat(byteArray))
19187 }
19188
19189 BigInteger.prototype.toHex = function(size) {
19190 return this.toBuffer(size).toString('hex')
19191 }
19192
19193 }).call(this,_dereq_("buffer").Buffer)
19194 },{"./bigi":1,"assert":4,"buffer":8}],3:[function(_dereq_,module,exports){
19195 var BigInteger = _dereq_('./bigi')
19196
19197 //addons
19198 _dereq_('./convert')
19199
19200 module.exports = BigInteger
19201 },{"./bigi":1,"./convert":2}],4:[function(_dereq_,module,exports){
19202 // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
19203 //
19204 // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
19205 //
19206 // Originally from narwhal.js (http://narwhaljs.org)
19207 // Copyright (c) 2009 Thomas Robinson <280north.com>
19208 //
19209 // Permission is hereby granted, free of charge, to any person obtaining a copy
19210 // of this software and associated documentation files (the 'Software'), to
19211 // deal in the Software without restriction, including without limitation the
19212 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
19213 // sell copies of the Software, and to permit persons to whom the Software is
19214 // furnished to do so, subject to the following conditions:
19215 //
19216 // The above copyright notice and this permission notice shall be included in
19217 // all copies or substantial portions of the Software.
19218 //
19219 // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19220 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19221 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19222 // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19223 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19224 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19225
19226 // when used in node, this will actually load the util module we depend on
19227 // versus loading the builtin util module as happens otherwise
19228 // this is a bug in node module loading as far as I am concerned
19229 var util = _dereq_('util/');
19230
19231 var pSlice = Array.prototype.slice;
19232 var hasOwn = Object.prototype.hasOwnProperty;
19233
19234 // 1. The assert module provides functions that throw
19235 // AssertionError's when particular conditions are not met. The
19236 // assert module must conform to the following interface.
19237
19238 var assert = module.exports = ok;
19239
19240 // 2. The AssertionError is defined in assert.
19241 // new assert.AssertionError({ message: message,
19242 // actual: actual,
19243 // expected: expected })
19244
19245 assert.AssertionError = function AssertionError(options) {
19246 this.name = 'AssertionError';
19247 this.actual = options.actual;
19248 this.expected = options.expected;
19249 this.operator = options.operator;
19250 if (options.message) {
19251 this.message = options.message;
19252 this.generatedMessage = false;
19253 } else {
19254 this.message = getMessage(this);
19255 this.generatedMessage = true;
19256 }
19257 var stackStartFunction = options.stackStartFunction || fail;
19258
19259 if (Error.captureStackTrace) {
19260 Error.captureStackTrace(this, stackStartFunction);
19261 }
19262 else {
19263 // non v8 browsers so we can have a stacktrace
19264 var err = new Error();
19265 if (err.stack) {
19266 var out = err.stack;
19267
19268 // try to strip useless frames
19269 var fn_name = stackStartFunction.name;
19270 var idx = out.indexOf('\n' + fn_name);
19271 if (idx >= 0) {
19272 // once we have located the function frame
19273 // we need to strip out everything before it (and its line)
19274 var next_line = out.indexOf('\n', idx + 1);
19275 out = out.substring(next_line + 1);
19276 }
19277
19278 this.stack = out;
19279 }
19280 }
19281 };
19282
19283 // assert.AssertionError instanceof Error
19284 util.inherits(assert.AssertionError, Error);
19285
19286 function replacer(key, value) {
19287 if (util.isUndefined(value)) {
19288 return '' + value;
19289 }
19290 if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) {
19291 return value.toString();
19292 }
19293 if (util.isFunction(value) || util.isRegExp(value)) {
19294 return value.toString();
19295 }
19296 return value;
19297 }
19298
19299 function truncate(s, n) {
19300 if (util.isString(s)) {
19301 return s.length < n ? s : s.slice(0, n);
19302 } else {
19303 return s;
19304 }
19305 }
19306
19307 function getMessage(self) {
19308 return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
19309 self.operator + ' ' +
19310 truncate(JSON.stringify(self.expected, replacer), 128);
19311 }
19312
19313 // At present only the three keys mentioned above are used and
19314 // understood by the spec. Implementations or sub modules can pass
19315 // other keys to the AssertionError's constructor - they will be
19316 // ignored.
19317
19318 // 3. All of the following functions must throw an AssertionError
19319 // when a corresponding condition is not met, with a message that
19320 // may be undefined if not provided. All assertion methods provide
19321 // both the actual and expected values to the assertion error for
19322 // display purposes.
19323
19324 function fail(actual, expected, message, operator, stackStartFunction) {
19325 throw new assert.AssertionError({
19326 message: message,
19327 actual: actual,
19328 expected: expected,
19329 operator: operator,
19330 stackStartFunction: stackStartFunction
19331 });
19332 }
19333
19334 // EXTENSION! allows for well behaved errors defined elsewhere.
19335 assert.fail = fail;
19336
19337 // 4. Pure assertion tests whether a value is truthy, as determined
19338 // by !!guard.
19339 // assert.ok(guard, message_opt);
19340 // This statement is equivalent to assert.equal(true, !!guard,
19341 // message_opt);. To test strictly for the value true, use
19342 // assert.strictEqual(true, guard, message_opt);.
19343
19344 function ok(value, message) {
19345 if (!value) fail(value, true, message, '==', assert.ok);
19346 }
19347 assert.ok = ok;
19348
19349 // 5. The equality assertion tests shallow, coercive equality with
19350 // ==.
19351 // assert.equal(actual, expected, message_opt);
19352
19353 assert.equal = function equal(actual, expected, message) {
19354 if (actual != expected) fail(actual, expected, message, '==', assert.equal);
19355 };
19356
19357 // 6. The non-equality assertion tests for whether two objects are not equal
19358 // with != assert.notEqual(actual, expected, message_opt);
19359
19360 assert.notEqual = function notEqual(actual, expected, message) {
19361 if (actual == expected) {
19362 fail(actual, expected, message, '!=', assert.notEqual);
19363 }
19364 };
19365
19366 // 7. The equivalence assertion tests a deep equality relation.
19367 // assert.deepEqual(actual, expected, message_opt);
19368
19369 assert.deepEqual = function deepEqual(actual, expected, message) {
19370 if (!_deepEqual(actual, expected)) {
19371 fail(actual, expected, message, 'deepEqual', assert.deepEqual);
19372 }
19373 };
19374
19375 function _deepEqual(actual, expected) {
19376 // 7.1. All identical values are equivalent, as determined by ===.
19377 if (actual === expected) {
19378 return true;
19379
19380 } else if (util.isBuffer(actual) && util.isBuffer(expected)) {
19381 if (actual.length != expected.length) return false;
19382
19383 for (var i = 0; i < actual.length; i++) {
19384 if (actual[i] !== expected[i]) return false;
19385 }
19386
19387 return true;
19388
19389 // 7.2. If the expected value is a Date object, the actual value is
19390 // equivalent if it is also a Date object that refers to the same time.
19391 } else if (util.isDate(actual) && util.isDate(expected)) {
19392 return actual.getTime() === expected.getTime();
19393
19394 // 7.3 If the expected value is a RegExp object, the actual value is
19395 // equivalent if it is also a RegExp object with the same source and
19396 // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
19397 } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
19398 return actual.source === expected.source &&
19399 actual.global === expected.global &&
19400 actual.multiline === expected.multiline &&
19401 actual.lastIndex === expected.lastIndex &&
19402 actual.ignoreCase === expected.ignoreCase;
19403
19404 // 7.4. Other pairs that do not both pass typeof value == 'object',
19405 // equivalence is determined by ==.
19406 } else if (!util.isObject(actual) && !util.isObject(expected)) {
19407 return actual == expected;
19408
19409 // 7.5 For all other Object pairs, including Array objects, equivalence is
19410 // determined by having the same number of owned properties (as verified
19411 // with Object.prototype.hasOwnProperty.call), the same set of keys
19412 // (although not necessarily the same order), equivalent values for every
19413 // corresponding key, and an identical 'prototype' property. Note: this
19414 // accounts for both named and indexed properties on Arrays.
19415 } else {
19416 return objEquiv(actual, expected);
19417 }
19418 }
19419
19420 function isArguments(object) {
19421 return Object.prototype.toString.call(object) == '[object Arguments]';
19422 }
19423
19424 function objEquiv(a, b) {
19425 if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
19426 return false;
19427 // an identical 'prototype' property.
19428 if (a.prototype !== b.prototype) return false;
19429 //~~~I've managed to break Object.keys through screwy arguments passing.
19430 // Converting to array solves the problem.
19431 if (isArguments(a)) {
19432 if (!isArguments(b)) {
19433 return false;
19434 }
19435 a = pSlice.call(a);
19436 b = pSlice.call(b);
19437 return _deepEqual(a, b);
19438 }
19439 try {
19440 var ka = objectKeys(a),
19441 kb = objectKeys(b),
19442 key, i;
19443 } catch (e) {//happens when one is a string literal and the other isn't
19444 return false;
19445 }
19446 // having the same number of owned properties (keys incorporates
19447 // hasOwnProperty)
19448 if (ka.length != kb.length)
19449 return false;
19450 //the same set of keys (although not necessarily the same order),
19451 ka.sort();
19452 kb.sort();
19453 //~~~cheap key test
19454 for (i = ka.length - 1; i >= 0; i--) {
19455 if (ka[i] != kb[i])
19456 return false;
19457 }
19458 //equivalent values for every corresponding key, and
19459 //~~~possibly expensive deep test
19460 for (i = ka.length - 1; i >= 0; i--) {
19461 key = ka[i];
19462 if (!_deepEqual(a[key], b[key])) return false;
19463 }
19464 return true;
19465 }
19466
19467 // 8. The non-equivalence assertion tests for any deep inequality.
19468 // assert.notDeepEqual(actual, expected, message_opt);
19469
19470 assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
19471 if (_deepEqual(actual, expected)) {
19472 fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
19473 }
19474 };
19475
19476 // 9. The strict equality assertion tests strict equality, as determined by ===.
19477 // assert.strictEqual(actual, expected, message_opt);
19478
19479 assert.strictEqual = function strictEqual(actual, expected, message) {
19480 if (actual !== expected) {
19481 fail(actual, expected, message, '===', assert.strictEqual);
19482 }
19483 };
19484
19485 // 10. The strict non-equality assertion tests for strict inequality, as
19486 // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
19487
19488 assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
19489 if (actual === expected) {
19490 fail(actual, expected, message, '!==', assert.notStrictEqual);
19491 }
19492 };
19493
19494 function expectedException(actual, expected) {
19495 if (!actual || !expected) {
19496 return false;
19497 }
19498
19499 if (Object.prototype.toString.call(expected) == '[object RegExp]') {
19500 return expected.test(actual);
19501 } else if (actual instanceof expected) {
19502 return true;
19503 } else if (expected.call({}, actual) === true) {
19504 return true;
19505 }
19506
19507 return false;
19508 }
19509
19510 function _throws(shouldThrow, block, expected, message) {
19511 var actual;
19512
19513 if (util.isString(expected)) {
19514 message = expected;
19515 expected = null;
19516 }
19517
19518 try {
19519 block();
19520 } catch (e) {
19521 actual = e;
19522 }
19523
19524 message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
19525 (message ? ' ' + message : '.');
19526
19527 if (shouldThrow && !actual) {
19528 fail(actual, expected, 'Missing expected exception' + message);
19529 }
19530
19531 if (!shouldThrow && expectedException(actual, expected)) {
19532 fail(actual, expected, 'Got unwanted exception' + message);
19533 }
19534
19535 if ((shouldThrow && actual && expected &&
19536 !expectedException(actual, expected)) || (!shouldThrow && actual)) {
19537 throw actual;
19538 }
19539 }
19540
19541 // 11. Expected to throw an error:
19542 // assert.throws(block, Error_opt, message_opt);
19543
19544 assert.throws = function(block, /*optional*/error, /*optional*/message) {
19545 _throws.apply(this, [true].concat(pSlice.call(arguments)));
19546 };
19547
19548 // EXTENSION! This is annoying to write outside this module.
19549 assert.doesNotThrow = function(block, /*optional*/message) {
19550 _throws.apply(this, [false].concat(pSlice.call(arguments)));
19551 };
19552
19553 assert.ifError = function(err) { if (err) {throw err;}};
19554
19555 var objectKeys = Object.keys || function (obj) {
19556 var keys = [];
19557 for (var key in obj) {
19558 if (hasOwn.call(obj, key)) keys.push(key);
19559 }
19560 return keys;
19561 };
19562
19563 },{"util/":6}],5:[function(_dereq_,module,exports){
19564 module.exports = function isBuffer(arg) {
19565 return arg && typeof arg === 'object'
19566 && typeof arg.copy === 'function'
19567 && typeof arg.fill === 'function'
19568 && typeof arg.readUInt8 === 'function';
19569 }
19570 },{}],6:[function(_dereq_,module,exports){
19571 (function (process,global){
19572 // Copyright Joyent, Inc. and other Node contributors.
19573 //
19574 // Permission is hereby granted, free of charge, to any person obtaining a
19575 // copy of this software and associated documentation files (the
19576 // "Software"), to deal in the Software without restriction, including
19577 // without limitation the rights to use, copy, modify, merge, publish,
19578 // distribute, sublicense, and/or sell copies of the Software, and to permit
19579 // persons to whom the Software is furnished to do so, subject to the
19580 // following conditions:
19581 //
19582 // The above copyright notice and this permission notice shall be included
19583 // in all copies or substantial portions of the Software.
19584 //
19585 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19586 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19587 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
19588 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19589 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19590 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19591 // USE OR OTHER DEALINGS IN THE SOFTWARE.
19592
19593 var formatRegExp = /%[sdj%]/g;
19594 exports.format = function(f) {
19595 if (!isString(f)) {
19596 var objects = [];
19597 for (var i = 0; i < arguments.length; i++) {
19598 objects.push(inspect(arguments[i]));
19599 }
19600 return objects.join(' ');
19601 }
19602
19603 var i = 1;
19604 var args = arguments;
19605 var len = args.length;
19606 var str = String(f).replace(formatRegExp, function(x) {
19607 if (x === '%%') return '%';
19608 if (i >= len) return x;
19609 switch (x) {
19610 case '%s': return String(args[i++]);
19611 case '%d': return Number(args[i++]);
19612 case '%j':
19613 try {
19614 return JSON.stringify(args[i++]);
19615 } catch (_) {
19616 return '[Circular]';
19617 }
19618 default:
19619 return x;
19620 }
19621 });
19622 for (var x = args[i]; i < len; x = args[++i]) {
19623 if (isNull(x) || !isObject(x)) {
19624 str += ' ' + x;
19625 } else {
19626 str += ' ' + inspect(x);
19627 }
19628 }
19629 return str;
19630 };
19631
19632
19633 // Mark that a method should not be used.
19634 // Returns a modified function which warns once by default.
19635 // If --no-deprecation is set, then it is a no-op.
19636 exports.deprecate = function(fn, msg) {
19637 // Allow for deprecating things in the process of starting up.
19638 if (isUndefined(global.process)) {
19639 return function() {
19640 return exports.deprecate(fn, msg).apply(this, arguments);
19641 };
19642 }
19643
19644 if (process.noDeprecation === true) {
19645 return fn;
19646 }
19647
19648 var warned = false;
19649 function deprecated() {
19650 if (!warned) {
19651 if (process.throwDeprecation) {
19652 throw new Error(msg);
19653 } else if (process.traceDeprecation) {
19654 console.trace(msg);
19655 } else {
19656 console.error(msg);
19657 }
19658 warned = true;
19659 }
19660 return fn.apply(this, arguments);
19661 }
19662
19663 return deprecated;
19664 };
19665
19666
19667 var debugs = {};
19668 var debugEnviron;
19669 exports.debuglog = function(set) {
19670 if (isUndefined(debugEnviron))
19671 debugEnviron = process.env.NODE_DEBUG || '';
19672 set = set.toUpperCase();
19673 if (!debugs[set]) {
19674 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
19675 var pid = process.pid;
19676 debugs[set] = function() {
19677 var msg = exports.format.apply(exports, arguments);
19678 console.error('%s %d: %s', set, pid, msg);
19679 };
19680 } else {
19681 debugs[set] = function() {};
19682 }
19683 }
19684 return debugs[set];
19685 };
19686
19687
19688 /**
19689 * Echos the value of a value. Trys to print the value out
19690 * in the best way possible given the different types.
19691 *
19692 * @param {Object} obj The object to print out.
19693 * @param {Object} opts Optional options object that alters the output.
19694 */
19695 /* legacy: obj, showHidden, depth, colors*/
19696 function inspect(obj, opts) {
19697 // default options
19698 var ctx = {
19699 seen: [],
19700 stylize: stylizeNoColor
19701 };
19702 // legacy...
19703 if (arguments.length >= 3) ctx.depth = arguments[2];
19704 if (arguments.length >= 4) ctx.colors = arguments[3];
19705 if (isBoolean(opts)) {
19706 // legacy...
19707 ctx.showHidden = opts;
19708 } else if (opts) {
19709 // got an "options" object
19710 exports._extend(ctx, opts);
19711 }
19712 // set default options
19713 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
19714 if (isUndefined(ctx.depth)) ctx.depth = 2;
19715 if (isUndefined(ctx.colors)) ctx.colors = false;
19716 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
19717 if (ctx.colors) ctx.stylize = stylizeWithColor;
19718 return formatValue(ctx, obj, ctx.depth);
19719 }
19720 exports.inspect = inspect;
19721
19722
19723 // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
19724 inspect.colors = {
19725 'bold' : [1, 22],
19726 'italic' : [3, 23],
19727 'underline' : [4, 24],
19728 'inverse' : [7, 27],
19729 'white' : [37, 39],
19730 'grey' : [90, 39],
19731 'black' : [30, 39],
19732 'blue' : [34, 39],
19733 'cyan' : [36, 39],
19734 'green' : [32, 39],
19735 'magenta' : [35, 39],
19736 'red' : [31, 39],
19737 'yellow' : [33, 39]
19738 };
19739
19740 // Don't use 'blue' not visible on cmd.exe
19741 inspect.styles = {
19742 'special': 'cyan',
19743 'number': 'yellow',
19744 'boolean': 'yellow',
19745 'undefined': 'grey',
19746 'null': 'bold',
19747 'string': 'green',
19748 'date': 'magenta',
19749 // "name": intentionally not styling
19750 'regexp': 'red'
19751 };
19752
19753
19754 function stylizeWithColor(str, styleType) {
19755 var style = inspect.styles[styleType];
19756
19757 if (style) {
19758 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
19759 '\u001b[' + inspect.colors[style][1] + 'm';
19760 } else {
19761 return str;
19762 }
19763 }
19764
19765
19766 function stylizeNoColor(str, styleType) {
19767 return str;
19768 }
19769
19770
19771 function arrayToHash(array) {
19772 var hash = {};
19773
19774 array.forEach(function(val, idx) {
19775 hash[val] = true;
19776 });
19777
19778 return hash;
19779 }
19780
19781
19782 function formatValue(ctx, value, recurseTimes) {
19783 // Provide a hook for user-specified inspect functions.
19784 // Check that value is an object with an inspect function on it
19785 if (ctx.customInspect &&
19786 value &&
19787 isFunction(value.inspect) &&
19788 // Filter out the util module, it's inspect function is special
19789 value.inspect !== exports.inspect &&
19790 // Also filter out any prototype objects using the circular check.
19791 !(value.constructor && value.constructor.prototype === value)) {
19792 var ret = value.inspect(recurseTimes, ctx);
19793 if (!isString(ret)) {
19794 ret = formatValue(ctx, ret, recurseTimes);
19795 }
19796 return ret;
19797 }
19798
19799 // Primitive types cannot have properties
19800 var primitive = formatPrimitive(ctx, value);
19801 if (primitive) {
19802 return primitive;
19803 }
19804
19805 // Look up the keys of the object.
19806 var keys = Object.keys(value);
19807 var visibleKeys = arrayToHash(keys);
19808
19809 if (ctx.showHidden) {
19810 keys = Object.getOwnPropertyNames(value);
19811 }
19812
19813 // IE doesn't make error fields non-enumerable
19814 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
19815 if (isError(value)
19816 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
19817 return formatError(value);
19818 }
19819
19820 // Some type of object without properties can be shortcutted.
19821 if (keys.length === 0) {
19822 if (isFunction(value)) {
19823 var name = value.name ? ': ' + value.name : '';
19824 return ctx.stylize('[Function' + name + ']', 'special');
19825 }
19826 if (isRegExp(value)) {
19827 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
19828 }
19829 if (isDate(value)) {
19830 return ctx.stylize(Date.prototype.toString.call(value), 'date');
19831 }
19832 if (isError(value)) {
19833 return formatError(value);
19834 }
19835 }
19836
19837 var base = '', array = false, braces = ['{', '}'];
19838
19839 // Make Array say that they are Array
19840 if (isArray(value)) {
19841 array = true;
19842 braces = ['[', ']'];
19843 }
19844
19845 // Make functions say that they are functions
19846 if (isFunction(value)) {
19847 var n = value.name ? ': ' + value.name : '';
19848 base = ' [Function' + n + ']';
19849 }
19850
19851 // Make RegExps say that they are RegExps
19852 if (isRegExp(value)) {
19853 base = ' ' + RegExp.prototype.toString.call(value);
19854 }
19855
19856 // Make dates with properties first say the date
19857 if (isDate(value)) {
19858 base = ' ' + Date.prototype.toUTCString.call(value);
19859 }
19860
19861 // Make error with message first say the error
19862 if (isError(value)) {
19863 base = ' ' + formatError(value);
19864 }
19865
19866 if (keys.length === 0 && (!array || value.length == 0)) {
19867 return braces[0] + base + braces[1];
19868 }
19869
19870 if (recurseTimes < 0) {
19871 if (isRegExp(value)) {
19872 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
19873 } else {
19874 return ctx.stylize('[Object]', 'special');
19875 }
19876 }
19877
19878 ctx.seen.push(value);
19879
19880 var output;
19881 if (array) {
19882 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
19883 } else {
19884 output = keys.map(function(key) {
19885 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
19886 });
19887 }
19888
19889 ctx.seen.pop();
19890
19891 return reduceToSingleString(output, base, braces);
19892 }
19893
19894
19895 function formatPrimitive(ctx, value) {
19896 if (isUndefined(value))
19897 return ctx.stylize('undefined', 'undefined');
19898 if (isString(value)) {
19899 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
19900 .replace(/'/g, "\\'")
19901 .replace(/\\"/g, '"') + '\'';
19902 return ctx.stylize(simple, 'string');
19903 }
19904 if (isNumber(value))
19905 return ctx.stylize('' + value, 'number');
19906 if (isBoolean(value))
19907 return ctx.stylize('' + value, 'boolean');
19908 // For some reason typeof null is "object", so special case here.
19909 if (isNull(value))
19910 return ctx.stylize('null', 'null');
19911 }
19912
19913
19914 function formatError(value) {
19915 return '[' + Error.prototype.toString.call(value) + ']';
19916 }
19917
19918
19919 function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
19920 var output = [];
19921 for (var i = 0, l = value.length; i < l; ++i) {
19922 if (hasOwnProperty(value, String(i))) {
19923 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
19924 String(i), true));
19925 } else {
19926 output.push('');
19927 }
19928 }
19929 keys.forEach(function(key) {
19930 if (!key.match(/^\d+$/)) {
19931 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
19932 key, true));
19933 }
19934 });
19935 return output;
19936 }
19937
19938
19939 function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
19940 var name, str, desc;
19941 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
19942 if (desc.get) {
19943 if (desc.set) {
19944 str = ctx.stylize('[Getter/Setter]', 'special');
19945 } else {
19946 str = ctx.stylize('[Getter]', 'special');
19947 }
19948 } else {
19949 if (desc.set) {
19950 str = ctx.stylize('[Setter]', 'special');
19951 }
19952 }
19953 if (!hasOwnProperty(visibleKeys, key)) {
19954 name = '[' + key + ']';
19955 }
19956 if (!str) {
19957 if (ctx.seen.indexOf(desc.value) < 0) {
19958 if (isNull(recurseTimes)) {
19959 str = formatValue(ctx, desc.value, null);
19960 } else {
19961 str = formatValue(ctx, desc.value, recurseTimes - 1);
19962 }
19963 if (str.indexOf('\n') > -1) {
19964 if (array) {
19965 str = str.split('\n').map(function(line) {
19966 return ' ' + line;
19967 }).join('\n').substr(2);
19968 } else {
19969 str = '\n' + str.split('\n').map(function(line) {
19970 return ' ' + line;
19971 }).join('\n');
19972 }
19973 }
19974 } else {
19975 str = ctx.stylize('[Circular]', 'special');
19976 }
19977 }
19978 if (isUndefined(name)) {
19979 if (array && key.match(/^\d+$/)) {
19980 return str;
19981 }
19982 name = JSON.stringify('' + key);
19983 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
19984 name = name.substr(1, name.length - 2);
19985 name = ctx.stylize(name, 'name');
19986 } else {
19987 name = name.replace(/'/g, "\\'")
19988 .replace(/\\"/g, '"')
19989 .replace(/(^"|"$)/g, "'");
19990 name = ctx.stylize(name, 'string');
19991 }
19992 }
19993
19994 return name + ': ' + str;
19995 }
19996
19997
19998 function reduceToSingleString(output, base, braces) {
19999 var numLinesEst = 0;
20000 var length = output.reduce(function(prev, cur) {
20001 numLinesEst++;
20002 if (cur.indexOf('\n') >= 0) numLinesEst++;
20003 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
20004 }, 0);
20005
20006 if (length > 60) {
20007 return braces[0] +
20008 (base === '' ? '' : base + '\n ') +
20009 ' ' +
20010 output.join(',\n ') +
20011 ' ' +
20012 braces[1];
20013 }
20014
20015 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
20016 }
20017
20018
20019 // NOTE: These type checking functions intentionally don't use `instanceof`
20020 // because it is fragile and can be easily faked with `Object.create()`.
20021 function isArray(ar) {
20022 return Array.isArray(ar);
20023 }
20024 exports.isArray = isArray;
20025
20026 function isBoolean(arg) {
20027 return typeof arg === 'boolean';
20028 }
20029 exports.isBoolean = isBoolean;
20030
20031 function isNull(arg) {
20032 return arg === null;
20033 }
20034 exports.isNull = isNull;
20035
20036 function isNullOrUndefined(arg) {
20037 return arg == null;
20038 }
20039 exports.isNullOrUndefined = isNullOrUndefined;
20040
20041 function isNumber(arg) {
20042 return typeof arg === 'number';
20043 }
20044 exports.isNumber = isNumber;
20045
20046 function isString(arg) {
20047 return typeof arg === 'string';
20048 }
20049 exports.isString = isString;
20050
20051 function isSymbol(arg) {
20052 return typeof arg === 'symbol';
20053 }
20054 exports.isSymbol = isSymbol;
20055
20056 function isUndefined(arg) {
20057 return arg === void 0;
20058 }
20059 exports.isUndefined = isUndefined;
20060
20061 function isRegExp(re) {
20062 return isObject(re) && objectToString(re) === '[object RegExp]';
20063 }
20064 exports.isRegExp = isRegExp;
20065
20066 function isObject(arg) {
20067 return typeof arg === 'object' && arg !== null;
20068 }
20069 exports.isObject = isObject;
20070
20071 function isDate(d) {
20072 return isObject(d) && objectToString(d) === '[object Date]';
20073 }
20074 exports.isDate = isDate;
20075
20076 function isError(e) {
20077 return isObject(e) &&
20078 (objectToString(e) === '[object Error]' || e instanceof Error);
20079 }
20080 exports.isError = isError;
20081
20082 function isFunction(arg) {
20083 return typeof arg === 'function';
20084 }
20085 exports.isFunction = isFunction;
20086
20087 function isPrimitive(arg) {
20088 return arg === null ||
20089 typeof arg === 'boolean' ||
20090 typeof arg === 'number' ||
20091 typeof arg === 'string' ||
20092 typeof arg === 'symbol' || // ES6 symbol
20093 typeof arg === 'undefined';
20094 }
20095 exports.isPrimitive = isPrimitive;
20096
20097 exports.isBuffer = _dereq_('./support/isBuffer');
20098
20099 function objectToString(o) {
20100 return Object.prototype.toString.call(o);
20101 }
20102
20103
20104 function pad(n) {
20105 return n < 10 ? '0' + n.toString(10) : n.toString(10);
20106 }
20107
20108
20109 var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
20110 'Oct', 'Nov', 'Dec'];
20111
20112 // 26 Feb 16:19:34
20113 function timestamp() {
20114 var d = new Date();
20115 var time = [pad(d.getHours()),
20116 pad(d.getMinutes()),
20117 pad(d.getSeconds())].join(':');
20118 return [d.getDate(), months[d.getMonth()], time].join(' ');
20119 }
20120
20121
20122 // log is just a thin wrapper to console.log that prepends a timestamp
20123 exports.log = function() {
20124 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
20125 };
20126
20127
20128 /**
20129 * Inherit the prototype methods from one constructor into another.
20130 *
20131 * The Function.prototype.inherits from lang.js rewritten as a standalone
20132 * function (not on Function.prototype). NOTE: If this file is to be loaded
20133 * during bootstrapping this function needs to be rewritten using some native
20134 * functions as prototype setup using normal JavaScript does not work as
20135 * expected during bootstrapping (see mirror.js in r114903).
20136 *
20137 * @param {function} ctor Constructor function which needs to inherit the
20138 * prototype.
20139 * @param {function} superCtor Constructor function to inherit prototype from.
20140 */
20141 exports.inherits = _dereq_('inherits');
20142
20143 exports._extend = function(origin, add) {
20144 // Don't do anything if add isn't an object
20145 if (!add || !isObject(add)) return origin;
20146
20147 var keys = Object.keys(add);
20148 var i = keys.length;
20149 while (i--) {
20150 origin[keys[i]] = add[keys[i]];
20151 }
20152 return origin;
20153 };
20154
20155 function hasOwnProperty(obj, prop) {
20156 return Object.prototype.hasOwnProperty.call(obj, prop);
20157 }
20158
20159 }).call(this,_dereq_("FWaASH"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
20160 },{"./support/isBuffer":5,"FWaASH":12,"inherits":11}],7:[function(_dereq_,module,exports){
20161
20162 },{}],8:[function(_dereq_,module,exports){
20163 /*!
20164 * The buffer module from node.js, for the browser.
20165 *
20166 * at author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
20167 * at license MIT
20168 */
20169
20170 var base64 = _dereq_('base64-js')
20171 var ieee754 = _dereq_('ieee754')
20172
20173 exports.Buffer = Buffer
20174 exports.SlowBuffer = Buffer
20175 exports.INSPECT_MAX_BYTES = 50
20176 Buffer.poolSize = 8192
20177
20178 /**
20179 * If `Buffer._useTypedArrays`:
20180 * === true Use Uint8Array implementation (fastest)
20181 * === false Use Object implementation (compatible down to IE6)
20182 */
20183 Buffer._useTypedArrays = (function () {
20184 // Detect if browser supports Typed Arrays. Supported browsers are IE 10+, Firefox 4+,
20185 // Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+. If the browser does not support adding
20186 // properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support
20187 // because we need to be able to add all the node Buffer API methods. This is an issue
20188 // in Firefox 4-29. Now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=695438
20189 try {
20190 var buf = new ArrayBuffer(0)
20191 var arr = new Uint8Array(buf)
20192 arr.foo = function () { return 42 }
20193 return 42 === arr.foo() &&
20194 typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray`
20195 } catch (e) {
20196 return false
20197 }
20198 })()
20199
20200 /**
20201 * Class: Buffer
20202 * =============
20203 *
20204 * The Buffer constructor returns instances of `Uint8Array` that are augmented
20205 * with function properties for all the node `Buffer` API functions. We use
20206 * `Uint8Array` so that square bracket notation works as expected -- it returns
20207 * a single octet.
20208 *
20209 * By augmenting the instances, we can avoid modifying the `Uint8Array`
20210 * prototype.
20211 */
20212 function Buffer (subject, encoding, noZero) {
20213 if (!(this instanceof Buffer))
20214 return new Buffer(subject, encoding, noZero)
20215
20216 var type = typeof subject
20217
20218 if (encoding === 'base64' && type === 'string') {
20219 subject = base64clean(subject)
20220 }
20221
20222 // Find the length
20223 var length
20224 if (type === 'number')
20225 length = coerce(subject)
20226 else if (type === 'string')
20227 length = Buffer.byteLength(subject, encoding)
20228 else if (type === 'object')
20229 length = coerce(subject.length) // assume that object is array-like
20230 else
20231 throw new Error('First argument needs to be a number, array or string.')
20232
20233 var buf
20234 if (Buffer._useTypedArrays) {
20235 // Preferred: Return an augmented `Uint8Array` instance for best performance
20236 buf = Buffer._augment(new Uint8Array(length))
20237 } else {
20238 // Fallback: Return THIS instance of Buffer (created by `new`)
20239 buf = this
20240 buf.length = length
20241 buf._isBuffer = true
20242 }
20243
20244 var i
20245 if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') {
20246 // Speed optimization -- use set if we're copying from a typed array
20247 buf._set(subject)
20248 } else if (isArrayish(subject)) {
20249 // Treat array-ish objects as a byte array
20250 if (Buffer.isBuffer(subject)) {
20251 for (i = 0; i < length; i++)
20252 buf[i] = subject.readUInt8(i)
20253 } else {
20254 for (i = 0; i < length; i++)
20255 buf[i] = ((subject[i] % 256) + 256) % 256
20256 }
20257 } else if (type === 'string') {
20258 buf.write(subject, 0, encoding)
20259 } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
20260 for (i = 0; i < length; i++) {
20261 buf[i] = 0
20262 }
20263 }
20264
20265 return buf
20266 }
20267
20268 // STATIC METHODS
20269 // ==============
20270
20271 Buffer.isEncoding = function (encoding) {
20272 switch (String(encoding).toLowerCase()) {
20273 case 'hex':
20274 case 'utf8':
20275 case 'utf-8':
20276 case 'ascii':
20277 case 'binary':
20278 case 'base64':
20279 case 'raw':
20280 case 'ucs2':
20281 case 'ucs-2':
20282 case 'utf16le':
20283 case 'utf-16le':
20284 return true
20285 default:
20286 return false
20287 }
20288 }
20289
20290 Buffer.isBuffer = function (b) {
20291 return !!(b !== null && b !== undefined && b._isBuffer)
20292 }
20293
20294 Buffer.byteLength = function (str, encoding) {
20295 var ret
20296 str = str.toString()
20297 switch (encoding || 'utf8') {
20298 case 'hex':
20299 ret = str.length / 2
20300 break
20301 case 'utf8':
20302 case 'utf-8':
20303 ret = utf8ToBytes(str).length
20304 break
20305 case 'ascii':
20306 case 'binary':
20307 case 'raw':
20308 ret = str.length
20309 break
20310 case 'base64':
20311 ret = base64ToBytes(str).length
20312 break
20313 case 'ucs2':
20314 case 'ucs-2':
20315 case 'utf16le':
20316 case 'utf-16le':
20317 ret = str.length * 2
20318 break
20319 default:
20320 throw new Error('Unknown encoding')
20321 }
20322 return ret
20323 }
20324
20325 Buffer.concat = function (list, totalLength) {
20326 assert(isArray(list), 'Usage: Buffer.concat(list[, length])')
20327
20328 if (list.length === 0) {
20329 return new Buffer(0)
20330 } else if (list.length === 1) {
20331 return list[0]
20332 }
20333
20334 var i
20335 if (totalLength === undefined) {
20336 totalLength = 0
20337 for (i = 0; i < list.length; i++) {
20338 totalLength += list[i].length
20339 }
20340 }
20341
20342 var buf = new Buffer(totalLength)
20343 var pos = 0
20344 for (i = 0; i < list.length; i++) {
20345 var item = list[i]
20346 item.copy(buf, pos)
20347 pos += item.length
20348 }
20349 return buf
20350 }
20351
20352 Buffer.compare = function (a, b) {
20353 assert(Buffer.isBuffer(a) && Buffer.isBuffer(b), 'Arguments must be Buffers')
20354 var x = a.length
20355 var y = b.length
20356 for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
20357 if (i !== len) {
20358 x = a[i]
20359 y = b[i]
20360 }
20361 if (x < y) {
20362 return -1
20363 }
20364 if (y < x) {
20365 return 1
20366 }
20367 return 0
20368 }
20369
20370 // BUFFER INSTANCE METHODS
20371 // =======================
20372
20373 function hexWrite (buf, string, offset, length) {
20374 offset = Number(offset) || 0
20375 var remaining = buf.length - offset
20376 if (!length) {
20377 length = remaining
20378 } else {
20379 length = Number(length)
20380 if (length > remaining) {
20381 length = remaining
20382 }
20383 }
20384
20385 // must be an even number of digits
20386 var strLen = string.length
20387 assert(strLen % 2 === 0, 'Invalid hex string')
20388
20389 if (length > strLen / 2) {
20390 length = strLen / 2
20391 }
20392 for (var i = 0; i < length; i++) {
20393 var byte = parseInt(string.substr(i * 2, 2), 16)
20394 assert(!isNaN(byte), 'Invalid hex string')
20395 buf[offset + i] = byte
20396 }
20397 return i
20398 }
20399
20400 function utf8Write (buf, string, offset, length) {
20401 var charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length)
20402 return charsWritten
20403 }
20404
20405 function asciiWrite (buf, string, offset, length) {
20406 var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length)
20407 return charsWritten
20408 }
20409
20410 function binaryWrite (buf, string, offset, length) {
20411 return asciiWrite(buf, string, offset, length)
20412 }
20413
20414 function base64Write (buf, string, offset, length) {
20415 var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length)
20416 return charsWritten
20417 }
20418
20419 function utf16leWrite (buf, string, offset, length) {
20420 var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length)
20421 return charsWritten
20422 }
20423
20424 Buffer.prototype.write = function (string, offset, length, encoding) {
20425 // Support both (string, offset, length, encoding)
20426 // and the legacy (string, encoding, offset, length)
20427 if (isFinite(offset)) {
20428 if (!isFinite(length)) {
20429 encoding = length
20430 length = undefined
20431 }
20432 } else { // legacy
20433 var swap = encoding
20434 encoding = offset
20435 offset = length
20436 length = swap
20437 }
20438
20439 offset = Number(offset) || 0
20440 var remaining = this.length - offset
20441 if (!length) {
20442 length = remaining
20443 } else {
20444 length = Number(length)
20445 if (length > remaining) {
20446 length = remaining
20447 }
20448 }
20449 encoding = String(encoding || 'utf8').toLowerCase()
20450
20451 var ret
20452 switch (encoding) {
20453 case 'hex':
20454 ret = hexWrite(this, string, offset, length)
20455 break
20456 case 'utf8':
20457 case 'utf-8':
20458 ret = utf8Write(this, string, offset, length)
20459 break
20460 case 'ascii':
20461 ret = asciiWrite(this, string, offset, length)
20462 break
20463 case 'binary':
20464 ret = binaryWrite(this, string, offset, length)
20465 break
20466 case 'base64':
20467 ret = base64Write(this, string, offset, length)
20468 break
20469 case 'ucs2':
20470 case 'ucs-2':
20471 case 'utf16le':
20472 case 'utf-16le':
20473 ret = utf16leWrite(this, string, offset, length)
20474 break
20475 default:
20476 throw new Error('Unknown encoding')
20477 }
20478 return ret
20479 }
20480
20481 Buffer.prototype.toString = function (encoding, start, end) {
20482 var self = this
20483
20484 encoding = String(encoding || 'utf8').toLowerCase()
20485 start = Number(start) || 0
20486 end = (end === undefined) ? self.length : Number(end)
20487
20488 // Fastpath empty strings
20489 if (end === start)
20490 return ''
20491
20492 var ret
20493 switch (encoding) {
20494 case 'hex':
20495 ret = hexSlice(self, start, end)
20496 break
20497 case 'utf8':
20498 case 'utf-8':
20499 ret = utf8Slice(self, start, end)
20500 break
20501 case 'ascii':
20502 ret = asciiSlice(self, start, end)
20503 break
20504 case 'binary':
20505 ret = binarySlice(self, start, end)
20506 break
20507 case 'base64':
20508 ret = base64Slice(self, start, end)
20509 break
20510 case 'ucs2':
20511 case 'ucs-2':
20512 case 'utf16le':
20513 case 'utf-16le':
20514 ret = utf16leSlice(self, start, end)
20515 break
20516 default:
20517 throw new Error('Unknown encoding')
20518 }
20519 return ret
20520 }
20521
20522 Buffer.prototype.toJSON = function () {
20523 return {
20524 type: 'Buffer',
20525 data: Array.prototype.slice.call(this._arr || this, 0)
20526 }
20527 }
20528
20529 Buffer.prototype.equals = function (b) {
20530 assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
20531 return Buffer.compare(this, b) === 0
20532 }
20533
20534 Buffer.prototype.compare = function (b) {
20535 assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
20536 return Buffer.compare(this, b)
20537 }
20538
20539 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
20540 Buffer.prototype.copy = function (target, target_start, start, end) {
20541 var source = this
20542
20543 if (!start) start = 0
20544 if (!end && end !== 0) end = this.length
20545 if (!target_start) target_start = 0
20546
20547 // Copy 0 bytes; we're done
20548 if (end === start) return
20549 if (target.length === 0 || source.length === 0) return
20550
20551 // Fatal error conditions
20552 assert(end >= start, 'sourceEnd < sourceStart')
20553 assert(target_start >= 0 && target_start < target.length,
20554 'targetStart out of bounds')
20555 assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
20556 assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
20557
20558 // Are we oob?
20559 if (end > this.length)
20560 end = this.length
20561 if (target.length - target_start < end - start)
20562 end = target.length - target_start + start
20563
20564 var len = end - start
20565
20566 if (len < 100 || !Buffer._useTypedArrays) {
20567 for (var i = 0; i < len; i++) {
20568 target[i + target_start] = this[i + start]
20569 }
20570 } else {
20571 target._set(this.subarray(start, start + len), target_start)
20572 }
20573 }
20574
20575 function base64Slice (buf, start, end) {
20576 if (start === 0 && end === buf.length) {
20577 return base64.fromByteArray(buf)
20578 } else {
20579 return base64.fromByteArray(buf.slice(start, end))
20580 }
20581 }
20582
20583 function utf8Slice (buf, start, end) {
20584 var res = ''
20585 var tmp = ''
20586 end = Math.min(buf.length, end)
20587
20588 for (var i = start; i < end; i++) {
20589 if (buf[i] <= 0x7F) {
20590 res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
20591 tmp = ''
20592 } else {
20593 tmp += '%' + buf[i].toString(16)
20594 }
20595 }
20596
20597 return res + decodeUtf8Char(tmp)
20598 }
20599
20600 function asciiSlice (buf, start, end) {
20601 var ret = ''
20602 end = Math.min(buf.length, end)
20603
20604 for (var i = start; i < end; i++) {
20605 ret += String.fromCharCode(buf[i])
20606 }
20607 return ret
20608 }
20609
20610 function binarySlice (buf, start, end) {
20611 return asciiSlice(buf, start, end)
20612 }
20613
20614 function hexSlice (buf, start, end) {
20615 var len = buf.length
20616
20617 if (!start || start < 0) start = 0
20618 if (!end || end < 0 || end > len) end = len
20619
20620 var out = ''
20621 for (var i = start; i < end; i++) {
20622 out += toHex(buf[i])
20623 }
20624 return out
20625 }
20626
20627 function utf16leSlice (buf, start, end) {
20628 var bytes = buf.slice(start, end)
20629 var res = ''
20630 for (var i = 0; i < bytes.length; i += 2) {
20631 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
20632 }
20633 return res
20634 }
20635
20636 Buffer.prototype.slice = function (start, end) {
20637 var len = this.length
20638 start = clamp(start, len, 0)
20639 end = clamp(end, len, len)
20640
20641 if (Buffer._useTypedArrays) {
20642 return Buffer._augment(this.subarray(start, end))
20643 } else {
20644 var sliceLen = end - start
20645 var newBuf = new Buffer(sliceLen, undefined, true)
20646 for (var i = 0; i < sliceLen; i++) {
20647 newBuf[i] = this[i + start]
20648 }
20649 return newBuf
20650 }
20651 }
20652
20653 // `get` will be removed in Node 0.13+
20654 Buffer.prototype.get = function (offset) {
20655 console.log('.get() is deprecated. Access using array indexes instead.')
20656 return this.readUInt8(offset)
20657 }
20658
20659 // `set` will be removed in Node 0.13+
20660 Buffer.prototype.set = function (v, offset) {
20661 console.log('.set() is deprecated. Access using array indexes instead.')
20662 return this.writeUInt8(v, offset)
20663 }
20664
20665 Buffer.prototype.readUInt8 = function (offset, noAssert) {
20666 if (!noAssert) {
20667 assert(offset !== undefined && offset !== null, 'missing offset')
20668 assert(offset < this.length, 'Trying to read beyond buffer length')
20669 }
20670
20671 if (offset >= this.length)
20672 return
20673
20674 return this[offset]
20675 }
20676
20677 function readUInt16 (buf, offset, littleEndian, noAssert) {
20678 if (!noAssert) {
20679 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20680 assert(offset !== undefined && offset !== null, 'missing offset')
20681 assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
20682 }
20683
20684 var len = buf.length
20685 if (offset >= len)
20686 return
20687
20688 var val
20689 if (littleEndian) {
20690 val = buf[offset]
20691 if (offset + 1 < len)
20692 val |= buf[offset + 1] << 8
20693 } else {
20694 val = buf[offset] << 8
20695 if (offset + 1 < len)
20696 val |= buf[offset + 1]
20697 }
20698 return val
20699 }
20700
20701 Buffer.prototype.readUInt16LE = function (offset, noAssert) {
20702 return readUInt16(this, offset, true, noAssert)
20703 }
20704
20705 Buffer.prototype.readUInt16BE = function (offset, noAssert) {
20706 return readUInt16(this, offset, false, noAssert)
20707 }
20708
20709 function readUInt32 (buf, offset, littleEndian, noAssert) {
20710 if (!noAssert) {
20711 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20712 assert(offset !== undefined && offset !== null, 'missing offset')
20713 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20714 }
20715
20716 var len = buf.length
20717 if (offset >= len)
20718 return
20719
20720 var val
20721 if (littleEndian) {
20722 if (offset + 2 < len)
20723 val = buf[offset + 2] << 16
20724 if (offset + 1 < len)
20725 val |= buf[offset + 1] << 8
20726 val |= buf[offset]
20727 if (offset + 3 < len)
20728 val = val + (buf[offset + 3] << 24 >>> 0)
20729 } else {
20730 if (offset + 1 < len)
20731 val = buf[offset + 1] << 16
20732 if (offset + 2 < len)
20733 val |= buf[offset + 2] << 8
20734 if (offset + 3 < len)
20735 val |= buf[offset + 3]
20736 val = val + (buf[offset] << 24 >>> 0)
20737 }
20738 return val
20739 }
20740
20741 Buffer.prototype.readUInt32LE = function (offset, noAssert) {
20742 return readUInt32(this, offset, true, noAssert)
20743 }
20744
20745 Buffer.prototype.readUInt32BE = function (offset, noAssert) {
20746 return readUInt32(this, offset, false, noAssert)
20747 }
20748
20749 Buffer.prototype.readInt8 = function (offset, noAssert) {
20750 if (!noAssert) {
20751 assert(offset !== undefined && offset !== null,
20752 'missing offset')
20753 assert(offset < this.length, 'Trying to read beyond buffer length')
20754 }
20755
20756 if (offset >= this.length)
20757 return
20758
20759 var neg = this[offset] & 0x80
20760 if (neg)
20761 return (0xff - this[offset] + 1) * -1
20762 else
20763 return this[offset]
20764 }
20765
20766 function readInt16 (buf, offset, littleEndian, noAssert) {
20767 if (!noAssert) {
20768 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20769 assert(offset !== undefined && offset !== null, 'missing offset')
20770 assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
20771 }
20772
20773 var len = buf.length
20774 if (offset >= len)
20775 return
20776
20777 var val = readUInt16(buf, offset, littleEndian, true)
20778 var neg = val & 0x8000
20779 if (neg)
20780 return (0xffff - val + 1) * -1
20781 else
20782 return val
20783 }
20784
20785 Buffer.prototype.readInt16LE = function (offset, noAssert) {
20786 return readInt16(this, offset, true, noAssert)
20787 }
20788
20789 Buffer.prototype.readInt16BE = function (offset, noAssert) {
20790 return readInt16(this, offset, false, noAssert)
20791 }
20792
20793 function readInt32 (buf, offset, littleEndian, noAssert) {
20794 if (!noAssert) {
20795 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20796 assert(offset !== undefined && offset !== null, 'missing offset')
20797 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20798 }
20799
20800 var len = buf.length
20801 if (offset >= len)
20802 return
20803
20804 var val = readUInt32(buf, offset, littleEndian, true)
20805 var neg = val & 0x80000000
20806 if (neg)
20807 return (0xffffffff - val + 1) * -1
20808 else
20809 return val
20810 }
20811
20812 Buffer.prototype.readInt32LE = function (offset, noAssert) {
20813 return readInt32(this, offset, true, noAssert)
20814 }
20815
20816 Buffer.prototype.readInt32BE = function (offset, noAssert) {
20817 return readInt32(this, offset, false, noAssert)
20818 }
20819
20820 function readFloat (buf, offset, littleEndian, noAssert) {
20821 if (!noAssert) {
20822 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20823 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20824 }
20825
20826 return ieee754.read(buf, offset, littleEndian, 23, 4)
20827 }
20828
20829 Buffer.prototype.readFloatLE = function (offset, noAssert) {
20830 return readFloat(this, offset, true, noAssert)
20831 }
20832
20833 Buffer.prototype.readFloatBE = function (offset, noAssert) {
20834 return readFloat(this, offset, false, noAssert)
20835 }
20836
20837 function readDouble (buf, offset, littleEndian, noAssert) {
20838 if (!noAssert) {
20839 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20840 assert(offset + 7 < buf.length, 'Trying to read beyond buffer length')
20841 }
20842
20843 return ieee754.read(buf, offset, littleEndian, 52, 8)
20844 }
20845
20846 Buffer.prototype.readDoubleLE = function (offset, noAssert) {
20847 return readDouble(this, offset, true, noAssert)
20848 }
20849
20850 Buffer.prototype.readDoubleBE = function (offset, noAssert) {
20851 return readDouble(this, offset, false, noAssert)
20852 }
20853
20854 Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
20855 if (!noAssert) {
20856 assert(value !== undefined && value !== null, 'missing value')
20857 assert(offset !== undefined && offset !== null, 'missing offset')
20858 assert(offset < this.length, 'trying to write beyond buffer length')
20859 verifuint(value, 0xff)
20860 }
20861
20862 if (offset >= this.length) return
20863
20864 this[offset] = value
20865 return offset + 1
20866 }
20867
20868 function writeUInt16 (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 + 1 < buf.length, 'trying to write beyond buffer length')
20874 verifuint(value, 0xffff)
20875 }
20876
20877 var len = buf.length
20878 if (offset >= len)
20879 return
20880
20881 for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) {
20882 buf[offset + i] =
20883 (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
20884 (littleEndian ? i : 1 - i) * 8
20885 }
20886 return offset + 2
20887 }
20888
20889 Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
20890 return writeUInt16(this, value, offset, true, noAssert)
20891 }
20892
20893 Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
20894 return writeUInt16(this, value, offset, false, noAssert)
20895 }
20896
20897 function writeUInt32 (buf, value, offset, littleEndian, noAssert) {
20898 if (!noAssert) {
20899 assert(value !== undefined && value !== null, 'missing value')
20900 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20901 assert(offset !== undefined && offset !== null, 'missing offset')
20902 assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
20903 verifuint(value, 0xffffffff)
20904 }
20905
20906 var len = buf.length
20907 if (offset >= len)
20908 return
20909
20910 for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) {
20911 buf[offset + i] =
20912 (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
20913 }
20914 return offset + 4
20915 }
20916
20917 Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
20918 return writeUInt32(this, value, offset, true, noAssert)
20919 }
20920
20921 Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
20922 return writeUInt32(this, value, offset, false, noAssert)
20923 }
20924
20925 Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
20926 if (!noAssert) {
20927 assert(value !== undefined && value !== null, 'missing value')
20928 assert(offset !== undefined && offset !== null, 'missing offset')
20929 assert(offset < this.length, 'Trying to write beyond buffer length')
20930 verifsint(value, 0x7f, -0x80)
20931 }
20932
20933 if (offset >= this.length)
20934 return
20935
20936 if (value >= 0)
20937 this.writeUInt8(value, offset, noAssert)
20938 else
20939 this.writeUInt8(0xff + value + 1, offset, noAssert)
20940 return offset + 1
20941 }
20942
20943 function writeInt16 (buf, value, offset, littleEndian, noAssert) {
20944 if (!noAssert) {
20945 assert(value !== undefined && value !== null, 'missing value')
20946 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20947 assert(offset !== undefined && offset !== null, 'missing offset')
20948 assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
20949 verifsint(value, 0x7fff, -0x8000)
20950 }
20951
20952 var len = buf.length
20953 if (offset >= len)
20954 return
20955
20956 if (value >= 0)
20957 writeUInt16(buf, value, offset, littleEndian, noAssert)
20958 else
20959 writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
20960 return offset + 2
20961 }
20962
20963 Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
20964 return writeInt16(this, value, offset, true, noAssert)
20965 }
20966
20967 Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
20968 return writeInt16(this, value, offset, false, noAssert)
20969 }
20970
20971 function writeInt32 (buf, value, offset, littleEndian, noAssert) {
20972 if (!noAssert) {
20973 assert(value !== undefined && value !== null, 'missing value')
20974 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20975 assert(offset !== undefined && offset !== null, 'missing offset')
20976 assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
20977 verifsint(value, 0x7fffffff, -0x80000000)
20978 }
20979
20980 var len = buf.length
20981 if (offset >= len)
20982 return
20983
20984 if (value >= 0)
20985 writeUInt32(buf, value, offset, littleEndian, noAssert)
20986 else
20987 writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert)
20988 return offset + 4
20989 }
20990
20991 Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
20992 return writeInt32(this, value, offset, true, noAssert)
20993 }
20994
20995 Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
20996 return writeInt32(this, value, offset, false, noAssert)
20997 }
20998
20999 function writeFloat (buf, value, offset, littleEndian, noAssert) {
21000 if (!noAssert) {
21001 assert(value !== undefined && value !== null, 'missing value')
21002 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
21003 assert(offset !== undefined && offset !== null, 'missing offset')
21004 assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
21005 verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
21006 }
21007
21008 var len = buf.length
21009 if (offset >= len)
21010 return
21011
21012 ieee754.write(buf, value, offset, littleEndian, 23, 4)
21013 return offset + 4
21014 }
21015
21016 Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
21017 return writeFloat(this, value, offset, true, noAssert)
21018 }
21019
21020 Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
21021 return writeFloat(this, value, offset, false, noAssert)
21022 }
21023
21024 function writeDouble (buf, value, offset, littleEndian, noAssert) {
21025 if (!noAssert) {
21026 assert(value !== undefined && value !== null, 'missing value')
21027 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
21028 assert(offset !== undefined && offset !== null, 'missing offset')
21029 assert(offset + 7 < buf.length,
21030 'Trying to write beyond buffer length')
21031 verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308)
21032 }
21033
21034 var len = buf.length
21035 if (offset >= len)
21036 return
21037
21038 ieee754.write(buf, value, offset, littleEndian, 52, 8)
21039 return offset + 8
21040 }
21041
21042 Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
21043 return writeDouble(this, value, offset, true, noAssert)
21044 }
21045
21046 Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
21047 return writeDouble(this, value, offset, false, noAssert)
21048 }
21049
21050 // fill(value, start=0, end=buffer.length)
21051 Buffer.prototype.fill = function (value, start, end) {
21052 if (!value) value = 0
21053 if (!start) start = 0
21054 if (!end) end = this.length
21055
21056 assert(end >= start, 'end < start')
21057
21058 // Fill 0 bytes; we're done
21059 if (end === start) return
21060 if (this.length === 0) return
21061
21062 assert(start >= 0 && start < this.length, 'start out of bounds')
21063 assert(end >= 0 && end <= this.length, 'end out of bounds')
21064
21065 var i
21066 if (typeof value === 'number') {
21067 for (i = start; i < end; i++) {
21068 this[i] = value
21069 }
21070 } else {
21071 var bytes = utf8ToBytes(value.toString())
21072 var len = bytes.length
21073 for (i = start; i < end; i++) {
21074 this[i] = bytes[i % len]
21075 }
21076 }
21077
21078 return this
21079 }
21080
21081 Buffer.prototype.inspect = function () {
21082 var out = []
21083 var len = this.length
21084 for (var i = 0; i < len; i++) {
21085 out[i] = toHex(this[i])
21086 if (i === exports.INSPECT_MAX_BYTES) {
21087 out[i + 1] = '...'
21088 break
21089 }
21090 }
21091 return '<Buffer ' + out.join(' ') + '>'
21092 }
21093
21094 /**
21095 * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
21096 * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
21097 */
21098 Buffer.prototype.toArrayBuffer = function () {
21099 if (typeof Uint8Array !== 'undefined') {
21100 if (Buffer._useTypedArrays) {
21101 return (new Buffer(this)).buffer
21102 } else {
21103 var buf = new Uint8Array(this.length)
21104 for (var i = 0, len = buf.length; i < len; i += 1) {
21105 buf[i] = this[i]
21106 }
21107 return buf.buffer
21108 }
21109 } else {
21110 throw new Error('Buffer.toArrayBuffer not supported in this browser')
21111 }
21112 }
21113
21114 // HELPER FUNCTIONS
21115 // ================
21116
21117 var BP = Buffer.prototype
21118
21119 /**
21120 * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
21121 */
21122 Buffer._augment = function (arr) {
21123 arr._isBuffer = true
21124
21125 // save reference to original Uint8Array get/set methods before overwriting
21126 arr._get = arr.get
21127 arr._set = arr.set
21128
21129 // deprecated, will be removed in node 0.13+
21130 arr.get = BP.get
21131 arr.set = BP.set
21132
21133 arr.write = BP.write
21134 arr.toString = BP.toString
21135 arr.toLocaleString = BP.toString
21136 arr.toJSON = BP.toJSON
21137 arr.equals = BP.equals
21138 arr.compare = BP.compare
21139 arr.copy = BP.copy
21140 arr.slice = BP.slice
21141 arr.readUInt8 = BP.readUInt8
21142 arr.readUInt16LE = BP.readUInt16LE
21143 arr.readUInt16BE = BP.readUInt16BE
21144 arr.readUInt32LE = BP.readUInt32LE
21145 arr.readUInt32BE = BP.readUInt32BE
21146 arr.readInt8 = BP.readInt8
21147 arr.readInt16LE = BP.readInt16LE
21148 arr.readInt16BE = BP.readInt16BE
21149 arr.readInt32LE = BP.readInt32LE
21150 arr.readInt32BE = BP.readInt32BE
21151 arr.readFloatLE = BP.readFloatLE
21152 arr.readFloatBE = BP.readFloatBE
21153 arr.readDoubleLE = BP.readDoubleLE
21154 arr.readDoubleBE = BP.readDoubleBE
21155 arr.writeUInt8 = BP.writeUInt8
21156 arr.writeUInt16LE = BP.writeUInt16LE
21157 arr.writeUInt16BE = BP.writeUInt16BE
21158 arr.writeUInt32LE = BP.writeUInt32LE
21159 arr.writeUInt32BE = BP.writeUInt32BE
21160 arr.writeInt8 = BP.writeInt8
21161 arr.writeInt16LE = BP.writeInt16LE
21162 arr.writeInt16BE = BP.writeInt16BE
21163 arr.writeInt32LE = BP.writeInt32LE
21164 arr.writeInt32BE = BP.writeInt32BE
21165 arr.writeFloatLE = BP.writeFloatLE
21166 arr.writeFloatBE = BP.writeFloatBE
21167 arr.writeDoubleLE = BP.writeDoubleLE
21168 arr.writeDoubleBE = BP.writeDoubleBE
21169 arr.fill = BP.fill
21170 arr.inspect = BP.inspect
21171 arr.toArrayBuffer = BP.toArrayBuffer
21172
21173 return arr
21174 }
21175
21176 var INVALID_BASE64_RE = /[^+\/0-9A-z]/g
21177
21178 function base64clean (str) {
21179 // Node strips out invalid characters like \n and \t from the string, base64-js does not
21180 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
21181 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
21182 while (str.length % 4 !== 0) {
21183 str = str + '='
21184 }
21185 return str
21186 }
21187
21188 function stringtrim (str) {
21189 if (str.trim) return str.trim()
21190 return str.replace(/^\s+|\s+$/g, '')
21191 }
21192
21193 // slice(start, end)
21194 function clamp (index, len, defaultValue) {
21195 if (typeof index !== 'number') return defaultValue
21196 index = ~~index; // Coerce to integer.
21197 if (index >= len) return len
21198 if (index >= 0) return index
21199 index += len
21200 if (index >= 0) return index
21201 return 0
21202 }
21203
21204 function coerce (length) {
21205 // Coerce length to a number (possibly NaN), round up
21206 // in case it's fractional (e.g. 123.456) then do a
21207 // double negate to coerce a NaN to 0. Easy, right?
21208 length = ~~Math.ceil(+length)
21209 return length < 0 ? 0 : length
21210 }
21211
21212 function isArray (subject) {
21213 return (Array.isArray || function (subject) {
21214 return Object.prototype.toString.call(subject) === '[object Array]'
21215 })(subject)
21216 }
21217
21218 function isArrayish (subject) {
21219 return isArray(subject) || Buffer.isBuffer(subject) ||
21220 subject && typeof subject === 'object' &&
21221 typeof subject.length === 'number'
21222 }
21223
21224 function toHex (n) {
21225 if (n < 16) return '0' + n.toString(16)
21226 return n.toString(16)
21227 }
21228
21229 function utf8ToBytes (str) {
21230 var byteArray = []
21231 for (var i = 0; i < str.length; i++) {
21232 var b = str.charCodeAt(i)
21233 if (b <= 0x7F) {
21234 byteArray.push(b)
21235 } else {
21236 var start = i
21237 if (b >= 0xD800 && b <= 0xDFFF) i++
21238 var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%')
21239 for (var j = 0; j < h.length; j++) {
21240 byteArray.push(parseInt(h[j], 16))
21241 }
21242 }
21243 }
21244 return byteArray
21245 }
21246
21247 function asciiToBytes (str) {
21248 var byteArray = []
21249 for (var i = 0; i < str.length; i++) {
21250 // Node's code seems to be doing this and not & 0x7F..
21251 byteArray.push(str.charCodeAt(i) & 0xFF)
21252 }
21253 return byteArray
21254 }
21255
21256 function utf16leToBytes (str) {
21257 var c, hi, lo
21258 var byteArray = []
21259 for (var i = 0; i < str.length; i++) {
21260 c = str.charCodeAt(i)
21261 hi = c >> 8
21262 lo = c % 256
21263 byteArray.push(lo)
21264 byteArray.push(hi)
21265 }
21266
21267 return byteArray
21268 }
21269
21270 function base64ToBytes (str) {
21271 return base64.toByteArray(str)
21272 }
21273
21274 function blitBuffer (src, dst, offset, length) {
21275 for (var i = 0; i < length; i++) {
21276 if ((i + offset >= dst.length) || (i >= src.length))
21277 break
21278 dst[i + offset] = src[i]
21279 }
21280 return i
21281 }
21282
21283 function decodeUtf8Char (str) {
21284 try {
21285 return decodeURIComponent(str)
21286 } catch (err) {
21287 return String.fromCharCode(0xFFFD) // UTF 8 invalid char
21288 }
21289 }
21290
21291 /*
21292 * We have to make sure that the value is a valid integer. This means that it
21293 * is non-negative. It has no fractional component and that it does not
21294 * exceed the maximum allowed value.
21295 */
21296 function verifuint (value, max) {
21297 assert(typeof value === 'number', 'cannot write a non-number as a number')
21298 assert(value >= 0, 'specified a negative value for writing an unsigned value')
21299 assert(value <= max, 'value is larger than maximum value for type')
21300 assert(Math.floor(value) === value, 'value has a fractional component')
21301 }
21302
21303 function verifsint (value, max, min) {
21304 assert(typeof value === 'number', 'cannot write a non-number as a number')
21305 assert(value <= max, 'value larger than maximum allowed value')
21306 assert(value >= min, 'value smaller than minimum allowed value')
21307 assert(Math.floor(value) === value, 'value has a fractional component')
21308 }
21309
21310 function verifIEEE754 (value, max, min) {
21311 assert(typeof value === 'number', 'cannot write a non-number as a number')
21312 assert(value <= max, 'value larger than maximum allowed value')
21313 assert(value >= min, 'value smaller than minimum allowed value')
21314 }
21315
21316 function assert (test, message) {
21317 if (!test) throw new Error(message || 'Failed assertion')
21318 }
21319
21320 },{"base64-js":9,"ieee754":10}],9:[function(_dereq_,module,exports){
21321 var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
21322
21323 ;(function (exports) {
21324 'use strict';
21325
21326 var Arr = (typeof Uint8Array !== 'undefined')
21327 ? Uint8Array
21328 : Array
21329
21330 var PLUS = '+'.charCodeAt(0)
21331 var SLASH = '/'.charCodeAt(0)
21332 var NUMBER = '0'.charCodeAt(0)
21333 var LOWER = 'a'.charCodeAt(0)
21334 var UPPER = 'A'.charCodeAt(0)
21335
21336 function decode (elt) {
21337 var code = elt.charCodeAt(0)
21338 if (code === PLUS)
21339 return 62 // '+'
21340 if (code === SLASH)
21341 return 63 // '/'
21342 if (code < NUMBER)
21343 return -1 //no match
21344 if (code < NUMBER + 10)
21345 return code - NUMBER + 26 + 26
21346 if (code < UPPER + 26)
21347 return code - UPPER
21348 if (code < LOWER + 26)
21349 return code - LOWER + 26
21350 }
21351
21352 function b64ToByteArray (b64) {
21353 var i, j, l, tmp, placeHolders, arr
21354
21355 if (b64.length % 4 > 0) {
21356 throw new Error('Invalid string. Length must be a multiple of 4')
21357 }
21358
21359 // the number of equal signs (place holders)
21360 // if there are two placeholders, than the two characters before it
21361 // represent one byte
21362 // if there is only one, then the three characters before it represent 2 bytes
21363 // this is just a cheap hack to not do indexOf twice
21364 var len = b64.length
21365 placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
21366
21367 // base64 is 4/3 + up to two characters of the original data
21368 arr = new Arr(b64.length * 3 / 4 - placeHolders)
21369
21370 // if there are placeholders, only get up to the last complete 4 chars
21371 l = placeHolders > 0 ? b64.length - 4 : b64.length
21372
21373 var L = 0
21374
21375 function push (v) {
21376 arr[L++] = v
21377 }
21378
21379 for (i = 0, j = 0; i < l; i += 4, j += 3) {
21380 tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
21381 push((tmp & 0xFF0000) >> 16)
21382 push((tmp & 0xFF00) >> 8)
21383 push(tmp & 0xFF)
21384 }
21385
21386 if (placeHolders === 2) {
21387 tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
21388 push(tmp & 0xFF)
21389 } else if (placeHolders === 1) {
21390 tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
21391 push((tmp >> 8) & 0xFF)
21392 push(tmp & 0xFF)
21393 }
21394
21395 return arr
21396 }
21397
21398 function uint8ToBase64 (uint8) {
21399 var i,
21400 extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
21401 output = "",
21402 temp, length
21403
21404 function encode (num) {
21405 return lookup.charAt(num)
21406 }
21407
21408 function tripletToBase64 (num) {
21409 return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
21410 }
21411
21412 // go through the array every three bytes, we'll deal with trailing stuff later
21413 for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
21414 temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
21415 output += tripletToBase64(temp)
21416 }
21417
21418 // pad the end with zeros, but make sure to not forget the extra bytes
21419 switch (extraBytes) {
21420 case 1:
21421 temp = uint8[uint8.length - 1]
21422 output += encode(temp >> 2)
21423 output += encode((temp << 4) & 0x3F)
21424 output += '=='
21425 break
21426 case 2:
21427 temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
21428 output += encode(temp >> 10)
21429 output += encode((temp >> 4) & 0x3F)
21430 output += encode((temp << 2) & 0x3F)
21431 output += '='
21432 break
21433 }
21434
21435 return output
21436 }
21437
21438 exports.toByteArray = b64ToByteArray
21439 exports.fromByteArray = uint8ToBase64
21440 }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
21441
21442 },{}],10:[function(_dereq_,module,exports){
21443 exports.read = function(buffer, offset, isLE, mLen, nBytes) {
21444 var e, m,
21445 eLen = nBytes * 8 - mLen - 1,
21446 eMax = (1 << eLen) - 1,
21447 eBias = eMax >> 1,
21448 nBits = -7,
21449 i = isLE ? (nBytes - 1) : 0,
21450 d = isLE ? -1 : 1,
21451 s = buffer[offset + i];
21452
21453 i += d;
21454
21455 e = s & ((1 << (-nBits)) - 1);
21456 s >>= (-nBits);
21457 nBits += eLen;
21458 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8){};
21459
21460 m = e & ((1 << (-nBits)) - 1);
21461 e >>= (-nBits);
21462 nBits += mLen;
21463 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8){};
21464
21465 if (e === 0) {
21466 e = 1 - eBias;
21467 } else if (e === eMax) {
21468 return m ? NaN : ((s ? -1 : 1) * Infinity);
21469 } else {
21470 m = m + Math.pow(2, mLen);
21471 e = e - eBias;
21472 }
21473 return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
21474 };
21475
21476 exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
21477 var e, m, c,
21478 eLen = nBytes * 8 - mLen - 1,
21479 eMax = (1 << eLen) - 1,
21480 eBias = eMax >> 1,
21481 rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
21482 i = isLE ? 0 : (nBytes - 1),
21483 d = isLE ? 1 : -1,
21484 s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
21485
21486 value = Math.abs(value);
21487
21488 if (isNaN(value) || value === Infinity) {
21489 m = isNaN(value) ? 1 : 0;
21490 e = eMax;
21491 } else {
21492 e = Math.floor(Math.log(value) / Math.LN2);
21493 if (value * (c = Math.pow(2, -e)) < 1) {
21494 e--;
21495 c *= 2;
21496 }
21497 if (e + eBias >= 1) {
21498 value += rt / c;
21499 } else {
21500 value += rt * Math.pow(2, 1 - eBias);
21501 }
21502 if (value * c >= 2) {
21503 e++;
21504 c /= 2;
21505 }
21506
21507 if (e + eBias >= eMax) {
21508 m = 0;
21509 e = eMax;
21510 } else if (e + eBias >= 1) {
21511 m = (value * c - 1) * Math.pow(2, mLen);
21512 e = e + eBias;
21513 } else {
21514 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
21515 e = 0;
21516 }
21517 }
21518
21519 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8){};
21520
21521 e = (e << mLen) | m;
21522 eLen += mLen;
21523 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8){};
21524
21525 buffer[offset + i - d] |= s * 128;
21526 };
21527
21528 },{}],11:[function(_dereq_,module,exports){
21529 if (typeof Object.create === 'function') {
21530 // implementation from standard node.js 'util' module
21531 module.exports = function inherits(ctor, superCtor) {
21532 ctor.super_ = superCtor
21533 ctor.prototype = Object.create(superCtor.prototype, {
21534 constructor: {
21535 value: ctor,
21536 enumerable: false,
21537 writable: true,
21538 configurable: true
21539 }
21540 });
21541 };
21542 } else {
21543 // old school shim for old browsers
21544 module.exports = function inherits(ctor, superCtor) {
21545 ctor.super_ = superCtor
21546 var TempCtor = function () {}
21547 TempCtor.prototype = superCtor.prototype
21548 ctor.prototype = new TempCtor()
21549 ctor.prototype.constructor = ctor
21550 }
21551 }
21552
21553 },{}],12:[function(_dereq_,module,exports){
21554 // shim for using process in browser
21555
21556 var process = module.exports = {};
21557
21558 process.nextTick = (function () {
21559 var canSetImmediate = typeof window !== 'undefined'
21560 && window.setImmediate;
21561 var canPost = typeof window !== 'undefined'
21562 && window.postMessage && window.addEventListener
21563 ;
21564
21565 if (canSetImmediate) {
21566 return function (f) { return window.setImmediate(f) };
21567 }
21568
21569 if (canPost) {
21570 var queue = [];
21571 window.addEventListener('message', function (ev) {
21572 var source = ev.source;
21573 if ((source === window || source === null) && ev.data === 'process-tick') {
21574 ev.stopPropagation();
21575 if (queue.length > 0) {
21576 var fn = queue.shift();
21577 fn();
21578 }
21579 }
21580 }, true);
21581
21582 return function nextTick(fn) {
21583 queue.push(fn);
21584 window.postMessage('process-tick', '*');
21585 };
21586 }
21587
21588 return function nextTick(fn) {
21589 setTimeout(fn, 0);
21590 };
21591 })();
21592
21593 process.title = 'browser';
21594 process.browser = true;
21595 process.env = {};
21596 process.argv = [];
21597
21598 function noop() {}
21599
21600 process.on = noop;
21601 process.addListener = noop;
21602 process.once = noop;
21603 process.off = noop;
21604 process.removeListener = noop;
21605 process.removeAllListeners = noop;
21606 process.emit = noop;
21607
21608 process.binding = function (name) {
21609 throw new Error('process.binding is not supported');
21610 }
21611
21612 // TODO(shtylman)
21613 process.cwd = function () { return '/' };
21614 process.chdir = function (dir) {
21615 throw new Error('process.chdir is not supported');
21616 };
21617
21618 },{}],13:[function(_dereq_,module,exports){
21619 module.exports=_dereq_(5)
21620 },{}],14:[function(_dereq_,module,exports){
21621 module.exports=_dereq_(6)
21622 },{"./support/isBuffer":13,"FWaASH":12,"inherits":11}],15:[function(_dereq_,module,exports){
21623 (function (Buffer){
21624 // Base58 encoding/decoding
21625 // Originally written by Mike Hearn for BitcoinJ
21626 // Copyright (c) 2011 Google Inc
21627 // Ported to JavaScript by Stefan Thomas
21628 // Merged Buffer refactorings from base58-native by Stephen Pair
21629 // Copyright (c) 2013 BitPay Inc
21630
21631 var assert = _dereq_('assert')
21632 var BigInteger = _dereq_('bigi')
21633
21634 var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
21635 var ALPHABET_BUF = new Buffer(ALPHABET, 'ascii')
21636 var ALPHABET_MAP = {}
21637 for(var i = 0; i < ALPHABET.length; i++) {
21638 ALPHABET_MAP[ALPHABET.charAt(i)] = BigInteger.valueOf(i)
21639 }
21640 var BASE = new BigInteger('58')
21641
21642 function encode(buffer) {
21643 var bi = BigInteger.fromBuffer(buffer)
21644 var result = new Buffer(buffer.length << 1)
21645
21646 var i = result.length - 1
21647 while (bi.signum() > 0) {
21648 var remainder = bi.mod(BASE)
21649 bi = bi.divide(BASE)
21650
21651 result[i] = ALPHABET_BUF[remainder.intValue()]
21652 i--
21653 }
21654
21655 // deal with leading zeros
21656 var j = 0
21657 while (buffer[j] === 0) {
21658 result[i] = ALPHABET_BUF[0]
21659 j++
21660 i--
21661 }
21662
21663 return result.slice(i + 1, result.length).toString('ascii')
21664 }
21665
21666 function decode(string) {
21667 if (string.length === 0) return new Buffer(0)
21668
21669 var num = BigInteger.ZERO
21670
21671 for (var i = 0; i < string.length; i++) {
21672 num = num.multiply(BASE)
21673
21674 var figure = ALPHABET_MAP[string.charAt(i)]
21675 assert.notEqual(figure, undefined, 'Non-base58 character')
21676
21677 num = num.add(figure)
21678 }
21679
21680 // deal with leading zeros
21681 var j = 0
21682 while ((j < string.length) && (string[j] === ALPHABET[0])) {
21683 j++
21684 }
21685
21686 var buffer = num.toBuffer()
21687 var leadingZeros = new Buffer(j)
21688 leadingZeros.fill(0)
21689
21690 return Buffer.concat([leadingZeros, buffer])
21691 }
21692
21693 module.exports = {
21694 encode: encode,
21695 decode: decode
21696 }
21697
21698 }).call(this,_dereq_("buffer").Buffer)
21699 },{"assert":4,"bigi":3,"buffer":8}],16:[function(_dereq_,module,exports){
21700 (function (Buffer){
21701 var createHash = _dereq_('sha.js')
21702
21703 var md5 = toConstructor(_dereq_('./md5'))
21704 var rmd160 = toConstructor(_dereq_('ripemd160'))
21705
21706 function toConstructor (fn) {
21707 return function () {
21708 var buffers = []
21709 var m= {
21710 update: function (data, enc) {
21711 if(!Buffer.isBuffer(data)) data = new Buffer(data, enc)
21712 buffers.push(data)
21713 return this
21714 },
21715 digest: function (enc) {
21716 var buf = Buffer.concat(buffers)
21717 var r = fn(buf)
21718 buffers = null
21719 return enc ? r.toString(enc) : r
21720 }
21721 }
21722 return m
21723 }
21724 }
21725
21726 module.exports = function (alg) {
21727 if('md5' === alg) return new md5()
21728 if('rmd160' === alg) return new rmd160()
21729 return createHash(alg)
21730 }
21731
21732 }).call(this,_dereq_("buffer").Buffer)
21733 },{"./md5":20,"buffer":8,"ripemd160":21,"sha.js":23}],17:[function(_dereq_,module,exports){
21734 (function (Buffer){
21735 var createHash = _dereq_('./create-hash')
21736
21737 var blocksize = 64
21738 var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(0)
21739
21740 module.exports = Hmac
21741
21742 function Hmac (alg, key) {
21743 if(!(this instanceof Hmac)) return new Hmac(alg, key)
21744 this._opad = opad
21745 this._alg = alg
21746
21747 key = this._key = !Buffer.isBuffer(key) ? new Buffer(key) : key
21748
21749 if(key.length > blocksize) {
21750 key = createHash(alg).update(key).digest()
21751 } else if(key.length < blocksize) {
21752 key = Buffer.concat([key, zeroBuffer], blocksize)
21753 }
21754
21755 var ipad = this._ipad = new Buffer(blocksize)
21756 var opad = this._opad = new Buffer(blocksize)
21757
21758 for(var i = 0; i < blocksize; i++) {
21759 ipad[i] = key[i] ^ 0x36
21760 opad[i] = key[i] ^ 0x5C
21761 }
21762
21763 this._hash = createHash(alg).update(ipad)
21764 }
21765
21766 Hmac.prototype.update = function (data, enc) {
21767 this._hash.update(data, enc)
21768 return this
21769 }
21770
21771 Hmac.prototype.digest = function (enc) {
21772 var h = this._hash.digest()
21773 return createHash(this._alg).update(this._opad).update(h).digest(enc)
21774 }
21775
21776
21777 }).call(this,_dereq_("buffer").Buffer)
21778 },{"./create-hash":16,"buffer":8}],18:[function(_dereq_,module,exports){
21779 (function (Buffer){
21780 var intSize = 4;
21781 var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(0);
21782 var chrsz = 8;
21783
21784 function toArray(buf, bigEndian) {
21785 if ((buf.length % intSize) !== 0) {
21786 var len = buf.length + (intSize - (buf.length % intSize));
21787 buf = Buffer.concat([buf, zeroBuffer], len);
21788 }
21789
21790 var arr = [];
21791 var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
21792 for (var i = 0; i < buf.length; i += intSize) {
21793 arr.push(fn.call(buf, i));
21794 }
21795 return arr;
21796 }
21797
21798 function toBuffer(arr, size, bigEndian) {
21799 var buf = new Buffer(size);
21800 var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
21801 for (var i = 0; i < arr.length; i++) {
21802 fn.call(buf, arr[i], i * 4, true);
21803 }
21804 return buf;
21805 }
21806
21807 function hash(buf, fn, hashSize, bigEndian) {
21808 if (!Buffer.isBuffer(buf)) buf = new Buffer(buf);
21809 var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
21810 return toBuffer(arr, hashSize, bigEndian);
21811 }
21812
21813 module.exports = { hash: hash };
21814
21815 }).call(this,_dereq_("buffer").Buffer)
21816 },{"buffer":8}],19:[function(_dereq_,module,exports){
21817 (function (Buffer){
21818 var rng = _dereq_('./rng')
21819
21820 function error () {
21821 var m = [].slice.call(arguments).join(' ')
21822 throw new Error([
21823 m,
21824 'we accept pull requests',
21825 'http://github.com/dominictarr/crypto-browserify'
21826 ].join('\n'))
21827 }
21828
21829 exports.createHash = _dereq_('./create-hash')
21830
21831 exports.createHmac = _dereq_('./create-hmac')
21832
21833 exports.randomBytes = function(size, callback) {
21834 if (callback && callback.call) {
21835 try {
21836 callback.call(this, undefined, new Buffer(rng(size)))
21837 } catch (err) { callback(err) }
21838 } else {
21839 return new Buffer(rng(size))
21840 }
21841 }
21842
21843 function each(a, f) {
21844 for(var i in a)
21845 f(a[i], i)
21846 }
21847
21848 exports.getHashes = function () {
21849 return ['sha1', 'sha256', 'md5', 'rmd160']
21850
21851 }
21852
21853 var p = _dereq_('./pbkdf2')(exports.createHmac)
21854 exports.pbkdf2 = p.pbkdf2
21855 exports.pbkdf2Sync = p.pbkdf2Sync
21856
21857
21858 // the least I can do is make error messages for the rest of the node.js/crypto api.
21859 each(['createCredentials'
21860 , 'createCipher'
21861 , 'createCipheriv'
21862 , 'createDecipher'
21863 , 'createDecipheriv'
21864 , 'createSign'
21865 , 'createVerify'
21866 , 'createDiffieHellman'
21867 ], function (name) {
21868 exports[name] = function () {
21869 error('sorry,', name, 'is not implemented yet')
21870 }
21871 })
21872
21873 }).call(this,_dereq_("buffer").Buffer)
21874 },{"./create-hash":16,"./create-hmac":17,"./pbkdf2":27,"./rng":28,"buffer":8}],20:[function(_dereq_,module,exports){
21875 /*
21876 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
21877 * Digest Algorithm, as defined in RFC 1321.
21878 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
21879 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
21880 * Distributed under the BSD License
21881 * See http://pajhome.org.uk/crypt/md5 for more info.
21882 */
21883
21884 var helpers = _dereq_('./helpers');
21885
21886 /*
21887 * Calculate the MD5 of an array of little-endian words, and a bit length
21888 */
21889 function core_md5(x, len)
21890 {
21891 /* append padding */
21892 x[len >> 5] |= 0x80 << ((len) % 32);
21893 x[(((len + 64) >>> 9) << 4) + 14] = len;
21894
21895 var a = 1732584193;
21896 var b = -271733879;
21897 var c = -1732584194;
21898 var d = 271733878;
21899
21900 for(var i = 0; i < x.length; i += 16)
21901 {
21902 var olda = a;
21903 var oldb = b;
21904 var oldc = c;
21905 var oldd = d;
21906
21907 a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
21908 d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
21909 c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
21910 b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
21911 a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
21912 d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
21913 c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
21914 b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
21915 a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
21916 d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
21917 c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
21918 b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
21919 a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
21920 d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
21921 c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
21922 b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
21923
21924 a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
21925 d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
21926 c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
21927 b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
21928 a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
21929 d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
21930 c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
21931 b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
21932 a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
21933 d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
21934 c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
21935 b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
21936 a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
21937 d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
21938 c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
21939 b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
21940
21941 a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
21942 d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
21943 c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
21944 b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
21945 a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
21946 d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
21947 c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
21948 b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
21949 a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
21950 d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
21951 c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
21952 b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
21953 a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
21954 d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
21955 c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
21956 b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
21957
21958 a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
21959 d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
21960 c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
21961 b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
21962 a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
21963 d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
21964 c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
21965 b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
21966 a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
21967 d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
21968 c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
21969 b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
21970 a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
21971 d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
21972 c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
21973 b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
21974
21975 a = safe_add(a, olda);
21976 b = safe_add(b, oldb);
21977 c = safe_add(c, oldc);
21978 d = safe_add(d, oldd);
21979 }
21980 return Array(a, b, c, d);
21981
21982 }
21983
21984 /*
21985 * These functions implement the four basic operations the algorithm uses.
21986 */
21987 function md5_cmn(q, a, b, x, s, t)
21988 {
21989 return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
21990 }
21991 function md5_ff(a, b, c, d, x, s, t)
21992 {
21993 return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
21994 }
21995 function md5_gg(a, b, c, d, x, s, t)
21996 {
21997 return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
21998 }
21999 function md5_hh(a, b, c, d, x, s, t)
22000 {
22001 return md5_cmn(b ^ c ^ d, a, b, x, s, t);
22002 }
22003 function md5_ii(a, b, c, d, x, s, t)
22004 {
22005 return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
22006 }
22007
22008 /*
22009 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
22010 * to work around bugs in some JS interpreters.
22011 */
22012 function safe_add(x, y)
22013 {
22014 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
22015 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
22016 return (msw << 16) | (lsw & 0xFFFF);
22017 }
22018
22019 /*
22020 * Bitwise rotate a 32-bit number to the left.
22021 */
22022 function bit_rol(num, cnt)
22023 {
22024 return (num << cnt) | (num >>> (32 - cnt));
22025 }
22026
22027 module.exports = function md5(buf) {
22028 return helpers.hash(buf, core_md5, 16);
22029 };
22030
22031 },{"./helpers":18}],21:[function(_dereq_,module,exports){
22032 (function (Buffer){
22033
22034 module.exports = ripemd160
22035
22036
22037
22038 /*
22039 CryptoJS v3.1.2
22040 code.google.com/p/crypto-js
22041 (c) 2009-2013 by Jeff Mott. All rights reserved.
22042 code.google.com/p/crypto-js/wiki/License
22043 */
22044 /** @preserve
22045 (c) 2012 by Cédric Mesnil. All rights reserved.
22046
22047 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
22048
22049 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
22050 - 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.
22051
22052 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.
22053 */
22054
22055 // Constants table
22056 var zl = [
22057 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
22058 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
22059 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
22060 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
22061 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13];
22062 var zr = [
22063 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
22064 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
22065 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
22066 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
22067 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11];
22068 var sl = [
22069 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
22070 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
22071 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
22072 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
22073 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ];
22074 var sr = [
22075 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
22076 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
22077 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
22078 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
22079 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ];
22080
22081 var hl = [ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E];
22082 var hr = [ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000];
22083
22084 var bytesToWords = function (bytes) {
22085 var words = [];
22086 for (var i = 0, b = 0; i < bytes.length; i++, b += 8) {
22087 words[b >>> 5] |= bytes[i] << (24 - b % 32);
22088 }
22089 return words;
22090 };
22091
22092 var wordsToBytes = function (words) {
22093 var bytes = [];
22094 for (var b = 0; b < words.length * 32; b += 8) {
22095 bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
22096 }
22097 return bytes;
22098 };
22099
22100 var processBlock = function (H, M, offset) {
22101
22102 // Swap endian
22103 for (var i = 0; i < 16; i++) {
22104 var offset_i = offset + i;
22105 var M_offset_i = M[offset_i];
22106
22107 // Swap
22108 M[offset_i] = (
22109 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
22110 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
22111 );
22112 }
22113
22114 // Working variables
22115 var al, bl, cl, dl, el;
22116 var ar, br, cr, dr, er;
22117
22118 ar = al = H[0];
22119 br = bl = H[1];
22120 cr = cl = H[2];
22121 dr = dl = H[3];
22122 er = el = H[4];
22123 // Computation
22124 var t;
22125 for (var i = 0; i < 80; i += 1) {
22126 t = (al + M[offset+zl[i]])|0;
22127 if (i<16){
22128 t += f1(bl,cl,dl) + hl[0];
22129 } else if (i<32) {
22130 t += f2(bl,cl,dl) + hl[1];
22131 } else if (i<48) {
22132 t += f3(bl,cl,dl) + hl[2];
22133 } else if (i<64) {
22134 t += f4(bl,cl,dl) + hl[3];
22135 } else {// if (i<80) {
22136 t += f5(bl,cl,dl) + hl[4];
22137 }
22138 t = t|0;
22139 t = rotl(t,sl[i]);
22140 t = (t+el)|0;
22141 al = el;
22142 el = dl;
22143 dl = rotl(cl, 10);
22144 cl = bl;
22145 bl = t;
22146
22147 t = (ar + M[offset+zr[i]])|0;
22148 if (i<16){
22149 t += f5(br,cr,dr) + hr[0];
22150 } else if (i<32) {
22151 t += f4(br,cr,dr) + hr[1];
22152 } else if (i<48) {
22153 t += f3(br,cr,dr) + hr[2];
22154 } else if (i<64) {
22155 t += f2(br,cr,dr) + hr[3];
22156 } else {// if (i<80) {
22157 t += f1(br,cr,dr) + hr[4];
22158 }
22159 t = t|0;
22160 t = rotl(t,sr[i]) ;
22161 t = (t+er)|0;
22162 ar = er;
22163 er = dr;
22164 dr = rotl(cr, 10);
22165 cr = br;
22166 br = t;
22167 }
22168 // Intermediate hash value
22169 t = (H[1] + cl + dr)|0;
22170 H[1] = (H[2] + dl + er)|0;
22171 H[2] = (H[3] + el + ar)|0;
22172 H[3] = (H[4] + al + br)|0;
22173 H[4] = (H[0] + bl + cr)|0;
22174 H[0] = t;
22175 };
22176
22177 function f1(x, y, z) {
22178 return ((x) ^ (y) ^ (z));
22179 }
22180
22181 function f2(x, y, z) {
22182 return (((x)&(y)) | ((~x)&(z)));
22183 }
22184
22185 function f3(x, y, z) {
22186 return (((x) | (~(y))) ^ (z));
22187 }
22188
22189 function f4(x, y, z) {
22190 return (((x) & (z)) | ((y)&(~(z))));
22191 }
22192
22193 function f5(x, y, z) {
22194 return ((x) ^ ((y) |(~(z))));
22195 }
22196
22197 function rotl(x,n) {
22198 return (x<<n) | (x>>>(32-n));
22199 }
22200
22201 function ripemd160(message) {
22202 var H = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];
22203
22204 if (typeof message == 'string')
22205 message = new Buffer(message, 'utf8');
22206
22207 var m = bytesToWords(message);
22208
22209 var nBitsLeft = message.length * 8;
22210 var nBitsTotal = message.length * 8;
22211
22212 // Add padding
22213 m[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
22214 m[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
22215 (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
22216 (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
22217 );
22218
22219 for (var i=0 ; i<m.length; i += 16) {
22220 processBlock(H, m, i);
22221 }
22222
22223 // Swap endian
22224 for (var i = 0; i < 5; i++) {
22225 // Shortcut
22226 var H_i = H[i];
22227
22228 // Swap
22229 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
22230 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
22231 }
22232
22233 var digestbytes = wordsToBytes(H);
22234 return new Buffer(digestbytes);
22235 }
22236
22237
22238
22239 }).call(this,_dereq_("buffer").Buffer)
22240 },{"buffer":8}],22:[function(_dereq_,module,exports){
22241 var u = _dereq_('./util')
22242 var write = u.write
22243 var fill = u.zeroFill
22244
22245 module.exports = function (Buffer) {
22246
22247 //prototype class for hash functions
22248 function Hash (blockSize, finalSize) {
22249 this._block = new Buffer(blockSize) //new Uint32Array(blockSize/4)
22250 this._finalSize = finalSize
22251 this._blockSize = blockSize
22252 this._len = 0
22253 this._s = 0
22254 }
22255
22256 Hash.prototype.init = function () {
22257 this._s = 0
22258 this._len = 0
22259 }
22260
22261 function lengthOf(data, enc) {
22262 if(enc == null) return data.byteLength || data.length
22263 if(enc == 'ascii' || enc == 'binary') return data.length
22264 if(enc == 'hex') return data.length/2
22265 if(enc == 'base64') return data.length/3
22266 }
22267
22268 Hash.prototype.update = function (data, enc) {
22269 var bl = this._blockSize
22270
22271 //I'd rather do this with a streaming encoder, like the opposite of
22272 //http://nodejs.org/api/string_decoder.html
22273 var length
22274 if(!enc && 'string' === typeof data)
22275 enc = 'utf8'
22276
22277 if(enc) {
22278 if(enc === 'utf-8')
22279 enc = 'utf8'
22280
22281 if(enc === 'base64' || enc === 'utf8')
22282 data = new Buffer(data, enc), enc = null
22283
22284 length = lengthOf(data, enc)
22285 } else
22286 length = data.byteLength || data.length
22287
22288 var l = this._len += length
22289 var s = this._s = (this._s || 0)
22290 var f = 0
22291 var buffer = this._block
22292 while(s < l) {
22293 var t = Math.min(length, f + bl)
22294 write(buffer, data, enc, s%bl, f, t)
22295 var ch = (t - f);
22296 s += ch; f += ch
22297
22298 if(!(s%bl))
22299 this._update(buffer)
22300 }
22301 this._s = s
22302
22303 return this
22304
22305 }
22306
22307 Hash.prototype.digest = function (enc) {
22308 var bl = this._blockSize
22309 var fl = this._finalSize
22310 var len = this._len*8
22311
22312 var x = this._block
22313
22314 var bits = len % (bl*8)
22315
22316 //add end marker, so that appending 0's creats a different hash.
22317 x[this._len % bl] = 0x80
22318 fill(this._block, this._len % bl + 1)
22319
22320 if(bits >= fl*8) {
22321 this._update(this._block)
22322 u.zeroFill(this._block, 0)
22323 }
22324
22325 //TODO: handle case where the bit length is > Math.pow(2, 29)
22326 x.writeInt32BE(len, fl + 4) //big endian
22327
22328 var hash = this._update(this._block) || this._hash()
22329 if(enc == null) return hash
22330 return hash.toString(enc)
22331 }
22332
22333 Hash.prototype._update = function () {
22334 throw new Error('_update must be implemented by subclass')
22335 }
22336
22337 return Hash
22338 }
22339
22340 },{"./util":26}],23:[function(_dereq_,module,exports){
22341 var exports = module.exports = function (alg) {
22342 var Alg = exports[alg]
22343 if(!Alg) throw new Error(alg + ' is not supported (we accept pull requests)')
22344 return new Alg()
22345 }
22346
22347 var Buffer = _dereq_('buffer').Buffer
22348 var Hash = _dereq_('./hash')(Buffer)
22349
22350 exports.sha =
22351 exports.sha1 = _dereq_('./sha1')(Buffer, Hash)
22352 exports.sha256 = _dereq_('./sha256')(Buffer, Hash)
22353
22354 },{"./hash":22,"./sha1":24,"./sha256":25,"buffer":8}],24:[function(_dereq_,module,exports){
22355 /*
22356 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
22357 * in FIPS PUB 180-1
22358 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
22359 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
22360 * Distributed under the BSD License
22361 * See http://pajhome.org.uk/crypt/md5 for details.
22362 */
22363 module.exports = function (Buffer, Hash) {
22364
22365 var inherits = _dereq_('util').inherits
22366
22367 inherits(Sha1, Hash)
22368
22369 var A = 0|0
22370 var B = 4|0
22371 var C = 8|0
22372 var D = 12|0
22373 var E = 16|0
22374
22375 var BE = false
22376 var LE = true
22377
22378 var W = new Int32Array(80)
22379
22380 var POOL = []
22381
22382 function Sha1 () {
22383 if(POOL.length)
22384 return POOL.pop().init()
22385
22386 if(!(this instanceof Sha1)) return new Sha1()
22387 this._w = W
22388 Hash.call(this, 16*4, 14*4)
22389
22390 this._h = null
22391 this.init()
22392 }
22393
22394 Sha1.prototype.init = function () {
22395 this._a = 0x67452301
22396 this._b = 0xefcdab89
22397 this._c = 0x98badcfe
22398 this._d = 0x10325476
22399 this._e = 0xc3d2e1f0
22400
22401 Hash.prototype.init.call(this)
22402 return this
22403 }
22404
22405 Sha1.prototype._POOL = POOL
22406
22407 // assume that array is a Uint32Array with length=16,
22408 // and that if it is the last block, it already has the length and the 1 bit appended.
22409
22410
22411 var isDV = new Buffer(1) instanceof DataView
22412 function readInt32BE (X, i) {
22413 return isDV
22414 ? X.getInt32(i, false)
22415 : X.readInt32BE(i)
22416 }
22417
22418 Sha1.prototype._update = function (array) {
22419
22420 var X = this._block
22421 var h = this._h
22422 var a, b, c, d, e, _a, _b, _c, _d, _e
22423
22424 a = _a = this._a
22425 b = _b = this._b
22426 c = _c = this._c
22427 d = _d = this._d
22428 e = _e = this._e
22429
22430 var w = this._w
22431
22432 for(var j = 0; j < 80; j++) {
22433 var W = w[j]
22434 = j < 16
22435 //? X.getInt32(j*4, false)
22436 //? readInt32BE(X, j*4) //*/ X.readInt32BE(j*4) //*/
22437 ? X.readInt32BE(j*4)
22438 : rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1)
22439
22440 var t =
22441 add(
22442 add(rol(a, 5), sha1_ft(j, b, c, d)),
22443 add(add(e, W), sha1_kt(j))
22444 );
22445
22446 e = d
22447 d = c
22448 c = rol(b, 30)
22449 b = a
22450 a = t
22451 }
22452
22453 this._a = add(a, _a)
22454 this._b = add(b, _b)
22455 this._c = add(c, _c)
22456 this._d = add(d, _d)
22457 this._e = add(e, _e)
22458 }
22459
22460 Sha1.prototype._hash = function () {
22461 if(POOL.length < 100) POOL.push(this)
22462 var H = new Buffer(20)
22463 //console.log(this._a|0, this._b|0, this._c|0, this._d|0, this._e|0)
22464 H.writeInt32BE(this._a|0, A)
22465 H.writeInt32BE(this._b|0, B)
22466 H.writeInt32BE(this._c|0, C)
22467 H.writeInt32BE(this._d|0, D)
22468 H.writeInt32BE(this._e|0, E)
22469 return H
22470 }
22471
22472 /*
22473 * Perform the appropriate triplet combination function for the current
22474 * iteration
22475 */
22476 function sha1_ft(t, b, c, d) {
22477 if(t < 20) return (b & c) | ((~b) & d);
22478 if(t < 40) return b ^ c ^ d;
22479 if(t < 60) return (b & c) | (b & d) | (c & d);
22480 return b ^ c ^ d;
22481 }
22482
22483 /*
22484 * Determine the appropriate additive constant for the current iteration
22485 */
22486 function sha1_kt(t) {
22487 return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
22488 (t < 60) ? -1894007588 : -899497514;
22489 }
22490
22491 /*
22492 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
22493 * to work around bugs in some JS interpreters.
22494 * //dominictarr: this is 10 years old, so maybe this can be dropped?)
22495 *
22496 */
22497 function add(x, y) {
22498 return (x + y ) | 0
22499 //lets see how this goes on testling.
22500 // var lsw = (x & 0xFFFF) + (y & 0xFFFF);
22501 // var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
22502 // return (msw << 16) | (lsw & 0xFFFF);
22503 }
22504
22505 /*
22506 * Bitwise rotate a 32-bit number to the left.
22507 */
22508 function rol(num, cnt) {
22509 return (num << cnt) | (num >>> (32 - cnt));
22510 }
22511
22512 return Sha1
22513 }
22514
22515 },{"util":14}],25:[function(_dereq_,module,exports){
22516
22517 /**
22518 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
22519 * in FIPS 180-2
22520 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
22521 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
22522 *
22523 */
22524
22525 var inherits = _dereq_('util').inherits
22526 var BE = false
22527 var LE = true
22528 var u = _dereq_('./util')
22529
22530 module.exports = function (Buffer, Hash) {
22531
22532 var K = [
22533 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
22534 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
22535 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
22536 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
22537 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
22538 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
22539 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
22540 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
22541 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
22542 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
22543 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
22544 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
22545 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
22546 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
22547 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
22548 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
22549 ]
22550
22551 inherits(Sha256, Hash)
22552 var W = new Array(64)
22553 var POOL = []
22554 function Sha256() {
22555 // Closure compiler warning - this code lacks side effects - thus commented out
22556 // if(POOL.length) {
22557 // return POOL.shift().init()
22558 // }
22559 //this._data = new Buffer(32)
22560
22561 this.init()
22562
22563 this._w = W //new Array(64)
22564
22565 Hash.call(this, 16*4, 14*4)
22566 };
22567
22568 Sha256.prototype.init = function () {
22569
22570 this._a = 0x6a09e667|0
22571 this._b = 0xbb67ae85|0
22572 this._c = 0x3c6ef372|0
22573 this._d = 0xa54ff53a|0
22574 this._e = 0x510e527f|0
22575 this._f = 0x9b05688c|0
22576 this._g = 0x1f83d9ab|0
22577 this._h = 0x5be0cd19|0
22578
22579 this._len = this._s = 0
22580
22581 return this
22582 }
22583
22584 var safe_add = function(x, y) {
22585 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
22586 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
22587 return (msw << 16) | (lsw & 0xFFFF);
22588 }
22589
22590 function S (X, n) {
22591 return (X >>> n) | (X << (32 - n));
22592 }
22593
22594 function R (X, n) {
22595 return (X >>> n);
22596 }
22597
22598 function Ch (x, y, z) {
22599 return ((x & y) ^ ((~x) & z));
22600 }
22601
22602 function Maj (x, y, z) {
22603 return ((x & y) ^ (x & z) ^ (y & z));
22604 }
22605
22606 function Sigma0256 (x) {
22607 return (S(x, 2) ^ S(x, 13) ^ S(x, 22));
22608 }
22609
22610 function Sigma1256 (x) {
22611 return (S(x, 6) ^ S(x, 11) ^ S(x, 25));
22612 }
22613
22614 function Gamma0256 (x) {
22615 return (S(x, 7) ^ S(x, 18) ^ R(x, 3));
22616 }
22617
22618 function Gamma1256 (x) {
22619 return (S(x, 17) ^ S(x, 19) ^ R(x, 10));
22620 }
22621
22622 Sha256.prototype._update = function(m) {
22623 var M = this._block
22624 var W = this._w
22625 var a, b, c, d, e, f, g, h
22626 var T1, T2
22627
22628 a = this._a | 0
22629 b = this._b | 0
22630 c = this._c | 0
22631 d = this._d | 0
22632 e = this._e | 0
22633 f = this._f | 0
22634 g = this._g | 0
22635 h = this._h | 0
22636
22637 for (var j = 0; j < 64; j++) {
22638 var w = W[j] = j < 16
22639 ? M.readInt32BE(j * 4)
22640 : Gamma1256(W[j - 2]) + W[j - 7] + Gamma0256(W[j - 15]) + W[j - 16]
22641
22642 T1 = h + Sigma1256(e) + Ch(e, f, g) + K[j] + w
22643
22644 T2 = Sigma0256(a) + Maj(a, b, c);
22645 h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2;
22646 }
22647
22648 this._a = (a + this._a) | 0
22649 this._b = (b + this._b) | 0
22650 this._c = (c + this._c) | 0
22651 this._d = (d + this._d) | 0
22652 this._e = (e + this._e) | 0
22653 this._f = (f + this._f) | 0
22654 this._g = (g + this._g) | 0
22655 this._h = (h + this._h) | 0
22656
22657 };
22658
22659 Sha256.prototype._hash = function () {
22660 if(POOL.length < 10)
22661 POOL.push(this)
22662
22663 var H = new Buffer(32)
22664
22665 H.writeInt32BE(this._a, 0)
22666 H.writeInt32BE(this._b, 4)
22667 H.writeInt32BE(this._c, 8)
22668 H.writeInt32BE(this._d, 12)
22669 H.writeInt32BE(this._e, 16)
22670 H.writeInt32BE(this._f, 20)
22671 H.writeInt32BE(this._g, 24)
22672 H.writeInt32BE(this._h, 28)
22673
22674 return H
22675 }
22676
22677 return Sha256
22678
22679 }
22680
22681 },{"./util":26,"util":14}],26:[function(_dereq_,module,exports){
22682 exports.write = write
22683 exports.zeroFill = zeroFill
22684
22685 exports.toString = toString
22686
22687 function write (buffer, string, enc, start, from, to, LE) {
22688 var l = (to - from)
22689 if(enc === 'ascii' || enc === 'binary') {
22690 for( var i = 0; i < l; i++) {
22691 buffer[start + i] = string.charCodeAt(i + from)
22692 }
22693 }
22694 else if(enc == null) {
22695 for( var i = 0; i < l; i++) {
22696 buffer[start + i] = string[i + from]
22697 }
22698 }
22699 else if(enc === 'hex') {
22700 for(var i = 0; i < l; i++) {
22701 var j = from + i
22702 buffer[start + i] = parseInt(string[j*2] + string[(j*2)+1], 16)
22703 }
22704 }
22705 else if(enc === 'base64') {
22706 throw new Error('base64 encoding not yet supported')
22707 }
22708 else
22709 throw new Error(enc +' encoding not yet supported')
22710 }
22711
22712 //always fill to the end!
22713 function zeroFill(buf, from) {
22714 for(var i = from; i < buf.length; i++)
22715 buf[i] = 0
22716 }
22717
22718
22719 },{}],27:[function(_dereq_,module,exports){
22720 (function (Buffer){
22721 // JavaScript PBKDF2 Implementation
22722 // Based on http://git.io/qsv2zw
22723 // Licensed under LGPL v3
22724 // Copyright (c) 2013 jduncanator
22725
22726 var blocksize = 64
22727 var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(0)
22728
22729 module.exports = function (createHmac, exports) {
22730 exports = exports || {}
22731
22732 exports.pbkdf2 = function(password, salt, iterations, keylen, cb) {
22733 if('function' !== typeof cb)
22734 throw new Error('No callback provided to pbkdf2');
22735 setTimeout(function () {
22736 cb(null, exports.pbkdf2Sync(password, salt, iterations, keylen))
22737 })
22738 }
22739
22740 exports.pbkdf2Sync = function(key, salt, iterations, keylen) {
22741 if('number' !== typeof iterations)
22742 throw new TypeError('Iterations not a number')
22743 if(iterations < 0)
22744 throw new TypeError('Bad iterations')
22745 if('number' !== typeof keylen)
22746 throw new TypeError('Key length not a number')
22747 if(keylen < 0)
22748 throw new TypeError('Bad key length')
22749
22750 //stretch key to the correct length that hmac wants it,
22751 //otherwise this will happen every time hmac is called
22752 //twice per iteration.
22753 var key = !Buffer.isBuffer(key) ? new Buffer(key) : key
22754
22755 if(key.length > blocksize) {
22756 key = createHash(alg).update(key).digest()
22757 } else if(key.length < blocksize) {
22758 key = Buffer.concat([key, zeroBuffer], blocksize)
22759 }
22760
22761 var HMAC;
22762 var cplen, p = 0, i = 1, itmp = new Buffer(4), digtmp;
22763 var out = new Buffer(keylen);
22764 out.fill(0);
22765 while(keylen) {
22766 if(keylen > 20)
22767 cplen = 20;
22768 else
22769 cplen = keylen;
22770
22771 /* We are unlikely to ever use more than 256 blocks (5120 bits!)
22772 * but just in case...
22773 */
22774 itmp[0] = (i >> 24) & 0xff;
22775 itmp[1] = (i >> 16) & 0xff;
22776 itmp[2] = (i >> 8) & 0xff;
22777 itmp[3] = i & 0xff;
22778
22779 HMAC = createHmac('sha1', key);
22780 HMAC.update(salt)
22781 HMAC.update(itmp);
22782 digtmp = HMAC.digest();
22783 digtmp.copy(out, p, 0, cplen);
22784
22785 for(var j = 1; j < iterations; j++) {
22786 HMAC = createHmac('sha1', key);
22787 HMAC.update(digtmp);
22788 digtmp = HMAC.digest();
22789 for(var k = 0; k < cplen; k++) {
22790 out[k] ^= digtmp[k];
22791 }
22792 }
22793 keylen -= cplen;
22794 i++;
22795 p += cplen;
22796 }
22797
22798 return out;
22799 }
22800
22801 return exports
22802 }
22803
22804 }).call(this,_dereq_("buffer").Buffer)
22805 },{"buffer":8}],28:[function(_dereq_,module,exports){
22806 (function (Buffer){
22807 // Original code adapted from Robert Kieffer.
22808 // details at https://github.com/broofa/node-uuid
22809
22810
22811 (function() {
22812 var _global = this;
22813
22814 var mathRNG, whatwgRNG;
22815
22816 // NOTE: Math.random() does not guarantee "cryptographic quality"
22817 mathRNG = function(size) {
22818 var bytes = new Buffer(size);
22819 var r;
22820
22821 for (var i = 0, r; i < size; i++) {
22822 if ((i & 0x03) == 0) r = Math.random() * 0x100000000;
22823 bytes[i] = r >>> ((i & 0x03) << 3) & 0xff;
22824 }
22825
22826 return bytes;
22827 }
22828
22829 if (_global.crypto && crypto.getRandomValues) {
22830 whatwgRNG = function(size) {
22831 var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array
22832 crypto.getRandomValues(bytes);
22833 return bytes;
22834 }
22835 }
22836
22837 module.exports = whatwgRNG || mathRNG;
22838
22839 }())
22840
22841 }).call(this,_dereq_("buffer").Buffer)
22842 },{"buffer":8}],29:[function(_dereq_,module,exports){
22843 ;(function (root, factory, undef) {
22844 if (typeof exports === "object") {
22845 // CommonJS
22846 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
22847 }
22848 else if (typeof define === "function" && define.amd) {
22849 // AMD
22850 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
22851 }
22852 else {
22853 // Global (browser)
22854 factory(root.CryptoJS);
22855 }
22856 }(this, function (CryptoJS) {
22857
22858 (function () {
22859 // Shortcuts
22860 var C = CryptoJS;
22861 var C_lib = C.lib;
22862 var BlockCipher = C_lib.BlockCipher;
22863 var C_algo = C.algo;
22864
22865 // Lookup tables
22866 var SBOX = [];
22867 var INV_SBOX = [];
22868 var SUB_MIX_0 = [];
22869 var SUB_MIX_1 = [];
22870 var SUB_MIX_2 = [];
22871 var SUB_MIX_3 = [];
22872 var INV_SUB_MIX_0 = [];
22873 var INV_SUB_MIX_1 = [];
22874 var INV_SUB_MIX_2 = [];
22875 var INV_SUB_MIX_3 = [];
22876
22877 // Compute lookup tables
22878 (function () {
22879 // Compute double table
22880 var d = [];
22881 for (var i = 0; i < 256; i++) {
22882 if (i < 128) {
22883 d[i] = i << 1;
22884 } else {
22885 d[i] = (i << 1) ^ 0x11b;
22886 }
22887 }
22888
22889 // Walk GF(2^8)
22890 var x = 0;
22891 var xi = 0;
22892 for (var i = 0; i < 256; i++) {
22893 // Compute sbox
22894 var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
22895 sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
22896 SBOX[x] = sx;
22897 INV_SBOX[sx] = x;
22898
22899 // Compute multiplication
22900 var x2 = d[x];
22901 var x4 = d[x2];
22902 var x8 = d[x4];
22903
22904 // Compute sub bytes, mix columns tables
22905 var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
22906 SUB_MIX_0[x] = (t << 24) | (t >>> 8);
22907 SUB_MIX_1[x] = (t << 16) | (t >>> 16);
22908 SUB_MIX_2[x] = (t << 8) | (t >>> 24);
22909 SUB_MIX_3[x] = t;
22910
22911 // Compute inv sub bytes, inv mix columns tables
22912 var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
22913 INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
22914 INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
22915 INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
22916 INV_SUB_MIX_3[sx] = t;
22917
22918 // Compute next counter
22919 if (!x) {
22920 x = xi = 1;
22921 } else {
22922 x = x2 ^ d[d[d[x8 ^ x2]]];
22923 xi ^= d[d[xi]];
22924 }
22925 }
22926 }());
22927
22928 // Precomputed Rcon lookup
22929 var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
22930
22931 /**
22932 * AES block cipher algorithm.
22933 */
22934 var AES = C_algo.AES = BlockCipher.extend({
22935 _doReset: function () {
22936 // Shortcuts
22937 var key = this._key;
22938 var keyWords = key.words;
22939 var keySize = key.sigBytes / 4;
22940
22941 // Compute number of rounds
22942 var nRounds = this._nRounds = keySize + 6
22943
22944 // Compute number of key schedule rows
22945 var ksRows = (nRounds + 1) * 4;
22946
22947 // Compute key schedule
22948 var keySchedule = this._keySchedule = [];
22949 for (var ksRow = 0; ksRow < ksRows; ksRow++) {
22950 if (ksRow < keySize) {
22951 keySchedule[ksRow] = keyWords[ksRow];
22952 } else {
22953 var t = keySchedule[ksRow - 1];
22954
22955 if (!(ksRow % keySize)) {
22956 // Rot word
22957 t = (t << 8) | (t >>> 24);
22958
22959 // Sub word
22960 t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
22961
22962 // Mix Rcon
22963 t ^= RCON[(ksRow / keySize) | 0] << 24;
22964 } else if (keySize > 6 && ksRow % keySize == 4) {
22965 // Sub word
22966 t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
22967 }
22968
22969 keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
22970 }
22971 }
22972
22973 // Compute inv key schedule
22974 var invKeySchedule = this._invKeySchedule = [];
22975 for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
22976 var ksRow = ksRows - invKsRow;
22977
22978 if (invKsRow % 4) {
22979 var t = keySchedule[ksRow];
22980 } else {
22981 var t = keySchedule[ksRow - 4];
22982 }
22983
22984 if (invKsRow < 4 || ksRow <= 4) {
22985 invKeySchedule[invKsRow] = t;
22986 } else {
22987 invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
22988 INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
22989 }
22990 }
22991 },
22992
22993 encryptBlock: function (M, offset) {
22994 this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
22995 },
22996
22997 decryptBlock: function (M, offset) {
22998 // Swap 2nd and 4th rows
22999 var t = M[offset + 1];
23000 M[offset + 1] = M[offset + 3];
23001 M[offset + 3] = t;
23002
23003 this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
23004
23005 // Inv swap 2nd and 4th rows
23006 var t = M[offset + 1];
23007 M[offset + 1] = M[offset + 3];
23008 M[offset + 3] = t;
23009 },
23010
23011 _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
23012 // Shortcut
23013 var nRounds = this._nRounds;
23014
23015 // Get input, add round key
23016 var s0 = M[offset] ^ keySchedule[0];
23017 var s1 = M[offset + 1] ^ keySchedule[1];
23018 var s2 = M[offset + 2] ^ keySchedule[2];
23019 var s3 = M[offset + 3] ^ keySchedule[3];
23020
23021 // Key schedule row counter
23022 var ksRow = 4;
23023
23024 // Rounds
23025 for (var round = 1; round < nRounds; round++) {
23026 // Shift rows, sub bytes, mix columns, add round key
23027 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++];
23028 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++];
23029 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++];
23030 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++];
23031
23032 // Update state
23033 s0 = t0;
23034 s1 = t1;
23035 s2 = t2;
23036 s3 = t3;
23037 }
23038
23039 // Shift rows, sub bytes, add round key
23040 var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
23041 var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
23042 var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
23043 var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
23044
23045 // Set output
23046 M[offset] = t0;
23047 M[offset + 1] = t1;
23048 M[offset + 2] = t2;
23049 M[offset + 3] = t3;
23050 },
23051
23052 keySize: 256/32
23053 });
23054
23055 /**
23056 * Shortcut functions to the cipher's object interface.
23057 *
23058 * @example
23059 *
23060 * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
23061 * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
23062 */
23063 C.AES = BlockCipher._createHelper(AES);
23064 }());
23065
23066
23067 return CryptoJS.AES;
23068
23069 }));
23070 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],30:[function(_dereq_,module,exports){
23071 ;(function (root, factory) {
23072 if (typeof exports === "object") {
23073 // CommonJS
23074 module.exports = exports = factory(_dereq_("./core"));
23075 }
23076 else if (typeof define === "function" && define.amd) {
23077 // AMD
23078 define(["./core"], factory);
23079 }
23080 else {
23081 // Global (browser)
23082 factory(root.CryptoJS);
23083 }
23084 }(this, function (CryptoJS) {
23085
23086 /**
23087 * Cipher core components.
23088 */
23089 CryptoJS.lib.Cipher || (function (undefined) {
23090 // Shortcuts
23091 var C = CryptoJS;
23092 var C_lib = C.lib;
23093 var Base = C_lib.Base;
23094 var WordArray = C_lib.WordArray;
23095 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
23096 var C_enc = C.enc;
23097 var Utf8 = C_enc.Utf8;
23098 var Base64 = C_enc.Base64;
23099 var C_algo = C.algo;
23100 var EvpKDF = C_algo.EvpKDF;
23101
23102 /**
23103 * Abstract base cipher template.
23104 *
23105 * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
23106 * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
23107 * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
23108 * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
23109 */
23110 var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
23111 /**
23112 * Configuration options.
23113 *
23114 * @property {WordArray} iv The IV to use for this operation.
23115 */
23116 cfg: Base.extend(),
23117
23118 /**
23119 * Creates this cipher in encryption mode.
23120 *
23121 * @param {WordArray} key The key.
23122 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23123 *
23124 * @return {Cipher} A cipher instance.
23125 *
23126 * @static
23127 *
23128 * @example
23129 *
23130 * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
23131 */
23132 createEncryptor: function (key, cfg) {
23133 return this.create(this._ENC_XFORM_MODE, key, cfg);
23134 },
23135
23136 /**
23137 * Creates this cipher in decryption mode.
23138 *
23139 * @param {WordArray} key The key.
23140 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23141 *
23142 * @return {Cipher} A cipher instance.
23143 *
23144 * @static
23145 *
23146 * @example
23147 *
23148 * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
23149 */
23150 createDecryptor: function (key, cfg) {
23151 return this.create(this._DEC_XFORM_MODE, key, cfg);
23152 },
23153
23154 /**
23155 * Initializes a newly created cipher.
23156 *
23157 * @param {number} xformMode Either the encryption or decryption transormation mode constant.
23158 * @param {WordArray} key The key.
23159 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23160 *
23161 * @example
23162 *
23163 * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
23164 */
23165 init: function (xformMode, key, cfg) {
23166 // Apply config defaults
23167 this.cfg = this.cfg.extend(cfg);
23168
23169 // Store transform mode and key
23170 this._xformMode = xformMode;
23171 this._key = key;
23172
23173 // Set initial values
23174 this.reset();
23175 },
23176
23177 /**
23178 * Resets this cipher to its initial state.
23179 *
23180 * @example
23181 *
23182 * cipher.reset();
23183 */
23184 reset: function () {
23185 // Reset data buffer
23186 BufferedBlockAlgorithm.reset.call(this);
23187
23188 // Perform concrete-cipher logic
23189 this._doReset();
23190 },
23191
23192 /**
23193 * Adds data to be encrypted or decrypted.
23194 *
23195 * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
23196 *
23197 * @return {WordArray} The data after processing.
23198 *
23199 * @example
23200 *
23201 * var encrypted = cipher.process('data');
23202 * var encrypted = cipher.process(wordArray);
23203 */
23204 process: function (dataUpdate) {
23205 // Append
23206 this._append(dataUpdate);
23207
23208 // Process available blocks
23209 return this._process();
23210 },
23211
23212 /**
23213 * Finalizes the encryption or decryption process.
23214 * Note that the finalize operation is effectively a destructive, read-once operation.
23215 *
23216 * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
23217 *
23218 * @return {WordArray} The data after final processing.
23219 *
23220 * @example
23221 *
23222 * var encrypted = cipher.finalize();
23223 * var encrypted = cipher.finalize('data');
23224 * var encrypted = cipher.finalize(wordArray);
23225 */
23226 finalize: function (dataUpdate) {
23227 // Final data update
23228 if (dataUpdate) {
23229 this._append(dataUpdate);
23230 }
23231
23232 // Perform concrete-cipher logic
23233 var finalProcessedData = this._doFinalize();
23234
23235 return finalProcessedData;
23236 },
23237
23238 keySize: 128/32,
23239
23240 ivSize: 128/32,
23241
23242 _ENC_XFORM_MODE: 1,
23243
23244 _DEC_XFORM_MODE: 2,
23245
23246 /**
23247 * Creates shortcut functions to a cipher's object interface.
23248 *
23249 * @param {Cipher} cipher The cipher to create a helper for.
23250 *
23251 * @return {Object} An object with encrypt and decrypt shortcut functions.
23252 *
23253 * @static
23254 *
23255 * @example
23256 *
23257 * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
23258 */
23259 _createHelper: (function () {
23260 function selectCipherStrategy(key) {
23261 if (typeof key == 'string') {
23262 return PasswordBasedCipher;
23263 } else {
23264 return SerializableCipher;
23265 }
23266 }
23267
23268 return function (cipher) {
23269 return {
23270 encrypt: function (message, key, cfg) {
23271 return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
23272 },
23273
23274 decrypt: function (ciphertext, key, cfg) {
23275 return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
23276 }
23277 };
23278 };
23279 }())
23280 });
23281
23282 /**
23283 * Abstract base stream cipher template.
23284 *
23285 * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
23286 */
23287 var StreamCipher = C_lib.StreamCipher = Cipher.extend({
23288 _doFinalize: function () {
23289 // Process partial blocks
23290 var finalProcessedBlocks = this._process(!!'flush');
23291
23292 return finalProcessedBlocks;
23293 },
23294
23295 blockSize: 1
23296 });
23297
23298 /**
23299 * Mode namespace.
23300 */
23301 var C_mode = C.mode = {};
23302
23303 /**
23304 * Abstract base block cipher mode template.
23305 */
23306 var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
23307 /**
23308 * Creates this mode for encryption.
23309 *
23310 * @param {Cipher} cipher A block cipher instance.
23311 * @param {Array} iv The IV words.
23312 *
23313 * @static
23314 *
23315 * @example
23316 *
23317 * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
23318 */
23319 createEncryptor: function (cipher, iv) {
23320 return this.Encryptor.create(cipher, iv);
23321 },
23322
23323 /**
23324 * Creates this mode for decryption.
23325 *
23326 * @param {Cipher} cipher A block cipher instance.
23327 * @param {Array} iv The IV words.
23328 *
23329 * @static
23330 *
23331 * @example
23332 *
23333 * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
23334 */
23335 createDecryptor: function (cipher, iv) {
23336 return this.Decryptor.create(cipher, iv);
23337 },
23338
23339 /**
23340 * Initializes a newly created mode.
23341 *
23342 * @param {Cipher} cipher A block cipher instance.
23343 * @param {Array} iv The IV words.
23344 *
23345 * @example
23346 *
23347 * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
23348 */
23349 init: function (cipher, iv) {
23350 this._cipher = cipher;
23351 this._iv = iv;
23352 }
23353 });
23354
23355 /**
23356 * Cipher Block Chaining mode.
23357 */
23358 var CBC = C_mode.CBC = (function () {
23359 /**
23360 * Abstract base CBC mode.
23361 */
23362 var CBC = BlockCipherMode.extend();
23363
23364 /**
23365 * CBC encryptor.
23366 */
23367 CBC.Encryptor = CBC.extend({
23368 /**
23369 * Processes the data block at offset.
23370 *
23371 * @param {Array} words The data words to operate on.
23372 * @param {number} offset The offset where the block starts.
23373 *
23374 * @example
23375 *
23376 * mode.processBlock(data.words, offset);
23377 */
23378 processBlock: function (words, offset) {
23379 // Shortcuts
23380 var cipher = this._cipher;
23381 var blockSize = cipher.blockSize;
23382
23383 // XOR and encrypt
23384 xorBlock.call(this, words, offset, blockSize);
23385 cipher.encryptBlock(words, offset);
23386
23387 // Remember this block to use with next block
23388 this._prevBlock = words.slice(offset, offset + blockSize);
23389 }
23390 });
23391
23392 /**
23393 * CBC decryptor.
23394 */
23395 CBC.Decryptor = CBC.extend({
23396 /**
23397 * Processes the data block at offset.
23398 *
23399 * @param {Array} words The data words to operate on.
23400 * @param {number} offset The offset where the block starts.
23401 *
23402 * @example
23403 *
23404 * mode.processBlock(data.words, offset);
23405 */
23406 processBlock: function (words, offset) {
23407 // Shortcuts
23408 var cipher = this._cipher;
23409 var blockSize = cipher.blockSize;
23410
23411 // Remember this block to use with next block
23412 var thisBlock = words.slice(offset, offset + blockSize);
23413
23414 // Decrypt and XOR
23415 cipher.decryptBlock(words, offset);
23416 xorBlock.call(this, words, offset, blockSize);
23417
23418 // This block becomes the previous block
23419 this._prevBlock = thisBlock;
23420 }
23421 });
23422
23423 function xorBlock(words, offset, blockSize) {
23424 // Shortcut
23425 var iv = this._iv;
23426
23427 // Choose mixing block
23428 if (iv) {
23429 var block = iv;
23430
23431 // Remove IV for subsequent blocks
23432 this._iv = undefined;
23433 } else {
23434 var block = this._prevBlock;
23435 }
23436
23437 // XOR blocks
23438 for (var i = 0; i < blockSize; i++) {
23439 words[offset + i] ^= block[i];
23440 }
23441 }
23442
23443 return CBC;
23444 }());
23445
23446 /**
23447 * Padding namespace.
23448 */
23449 var C_pad = C.pad = {};
23450
23451 /**
23452 * PKCS #5/7 padding strategy.
23453 */
23454 var Pkcs7 = C_pad.Pkcs7 = {
23455 /**
23456 * Pads data using the algorithm defined in PKCS #5/7.
23457 *
23458 * @param {WordArray} data The data to pad.
23459 * @param {number} blockSize The multiple that the data should be padded to.
23460 *
23461 * @static
23462 *
23463 * @example
23464 *
23465 * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
23466 */
23467 pad: function (data, blockSize) {
23468 // Shortcut
23469 var blockSizeBytes = blockSize * 4;
23470
23471 // Count padding bytes
23472 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
23473
23474 // Create padding word
23475 var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
23476
23477 // Create padding
23478 var paddingWords = [];
23479 for (var i = 0; i < nPaddingBytes; i += 4) {
23480 paddingWords.push(paddingWord);
23481 }
23482 var padding = WordArray.create(paddingWords, nPaddingBytes);
23483
23484 // Add padding
23485 data.concat(padding);
23486 },
23487
23488 /**
23489 * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
23490 *
23491 * @param {WordArray} data The data to unpad.
23492 *
23493 * @static
23494 *
23495 * @example
23496 *
23497 * CryptoJS.pad.Pkcs7.unpad(wordArray);
23498 */
23499 unpad: function (data) {
23500 // Get number of padding bytes from last byte
23501 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
23502
23503 // Remove padding
23504 data.sigBytes -= nPaddingBytes;
23505 }
23506 };
23507
23508 /**
23509 * Abstract base block cipher template.
23510 *
23511 * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
23512 */
23513 var BlockCipher = C_lib.BlockCipher = Cipher.extend({
23514 /**
23515 * Configuration options.
23516 *
23517 * @property {Mode} mode The block mode to use. Default: CBC
23518 * @property {Padding} padding The padding strategy to use. Default: Pkcs7
23519 */
23520 cfg: Cipher.cfg.extend({
23521 mode: CBC,
23522 padding: Pkcs7
23523 }),
23524
23525 reset: function () {
23526 // Reset cipher
23527 Cipher.reset.call(this);
23528
23529 // Shortcuts
23530 var cfg = this.cfg;
23531 var iv = cfg.iv;
23532 var mode = cfg.mode;
23533
23534 // Reset block mode
23535 if (this._xformMode == this._ENC_XFORM_MODE) {
23536 var modeCreator = mode.createEncryptor;
23537 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
23538 var modeCreator = mode.createDecryptor;
23539
23540 // Keep at least one block in the buffer for unpadding
23541 this._minBufferSize = 1;
23542 }
23543 this._mode = modeCreator.call(mode, this, iv && iv.words);
23544 },
23545
23546 _doProcessBlock: function (words, offset) {
23547 this._mode.processBlock(words, offset);
23548 },
23549
23550 _doFinalize: function () {
23551 // Shortcut
23552 var padding = this.cfg.padding;
23553
23554 // Finalize
23555 if (this._xformMode == this._ENC_XFORM_MODE) {
23556 // Pad data
23557 padding.pad(this._data, this.blockSize);
23558
23559 // Process final blocks
23560 var finalProcessedBlocks = this._process(!!'flush');
23561 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
23562 // Process final blocks
23563 var finalProcessedBlocks = this._process(!!'flush');
23564
23565 // Unpad data
23566 padding.unpad(finalProcessedBlocks);
23567 }
23568
23569 return finalProcessedBlocks;
23570 },
23571
23572 blockSize: 128/32
23573 });
23574
23575 /**
23576 * A collection of cipher parameters.
23577 *
23578 * @property {WordArray} ciphertext The raw ciphertext.
23579 * @property {WordArray} key The key to this ciphertext.
23580 * @property {WordArray} iv The IV used in the ciphering operation.
23581 * @property {WordArray} salt The salt used with a key derivation function.
23582 * @property {Cipher} algorithm The cipher algorithm.
23583 * @property {Mode} mode The block mode used in the ciphering operation.
23584 * @property {Padding} padding The padding scheme used in the ciphering operation.
23585 * @property {number} blockSize The block size of the cipher.
23586 * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
23587 */
23588 var CipherParams = C_lib.CipherParams = Base.extend({
23589 /**
23590 * Initializes a newly created cipher params object.
23591 *
23592 * @param {Object} cipherParams An object with any of the possible cipher parameters.
23593 *
23594 * @example
23595 *
23596 * var cipherParams = CryptoJS.lib.CipherParams.create({
23597 * ciphertext: ciphertextWordArray,
23598 * key: keyWordArray,
23599 * iv: ivWordArray,
23600 * salt: saltWordArray,
23601 * algorithm: CryptoJS.algo.AES,
23602 * mode: CryptoJS.mode.CBC,
23603 * padding: CryptoJS.pad.PKCS7,
23604 * blockSize: 4,
23605 * formatter: CryptoJS.format.OpenSSL
23606 * });
23607 */
23608 init: function (cipherParams) {
23609 this.mixIn(cipherParams);
23610 },
23611
23612 /**
23613 * Converts this cipher params object to a string.
23614 *
23615 * @param {Format} formatter (Optional) The formatting strategy to use.
23616 *
23617 * @return {string} The stringified cipher params.
23618 *
23619 * @throws Error If neither the formatter nor the default formatter is set.
23620 *
23621 * @example
23622 *
23623 * var string = cipherParams + '';
23624 * var string = cipherParams.toString();
23625 * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
23626 */
23627 toString: function (formatter) {
23628 return (formatter || this.formatter).stringify(this);
23629 }
23630 });
23631
23632 /**
23633 * Format namespace.
23634 */
23635 var C_format = C.format = {};
23636
23637 /**
23638 * OpenSSL formatting strategy.
23639 */
23640 var OpenSSLFormatter = C_format.OpenSSL = {
23641 /**
23642 * Converts a cipher params object to an OpenSSL-compatible string.
23643 *
23644 * @param {CipherParams} cipherParams The cipher params object.
23645 *
23646 * @return {string} The OpenSSL-compatible string.
23647 *
23648 * @static
23649 *
23650 * @example
23651 *
23652 * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
23653 */
23654 stringify: function (cipherParams) {
23655 // Shortcuts
23656 var ciphertext = cipherParams.ciphertext;
23657 var salt = cipherParams.salt;
23658
23659 // Format
23660 if (salt) {
23661 var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
23662 } else {
23663 var wordArray = ciphertext;
23664 }
23665
23666 return wordArray.toString(Base64);
23667 },
23668
23669 /**
23670 * Converts an OpenSSL-compatible string to a cipher params object.
23671 *
23672 * @param {string} openSSLStr The OpenSSL-compatible string.
23673 *
23674 * @return {CipherParams} The cipher params object.
23675 *
23676 * @static
23677 *
23678 * @example
23679 *
23680 * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
23681 */
23682 parse: function (openSSLStr) {
23683 // Parse base64
23684 var ciphertext = Base64.parse(openSSLStr);
23685
23686 // Shortcut
23687 var ciphertextWords = ciphertext.words;
23688
23689 // Test for salt
23690 if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
23691 // Extract salt
23692 var salt = WordArray.create(ciphertextWords.slice(2, 4));
23693
23694 // Remove salt from ciphertext
23695 ciphertextWords.splice(0, 4);
23696 ciphertext.sigBytes -= 16;
23697 }
23698
23699 return CipherParams.create({ ciphertext: ciphertext, salt: salt });
23700 }
23701 };
23702
23703 /**
23704 * A cipher wrapper that returns ciphertext as a serializable cipher params object.
23705 */
23706 var SerializableCipher = C_lib.SerializableCipher = Base.extend({
23707 /**
23708 * Configuration options.
23709 *
23710 * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
23711 */
23712 cfg: Base.extend({
23713 format: OpenSSLFormatter
23714 }),
23715
23716 /**
23717 * Encrypts a message.
23718 *
23719 * @param {Cipher} cipher The cipher algorithm to use.
23720 * @param {WordArray|string} message The message to encrypt.
23721 * @param {WordArray} key The key.
23722 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23723 *
23724 * @return {CipherParams} A cipher params object.
23725 *
23726 * @static
23727 *
23728 * @example
23729 *
23730 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
23731 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
23732 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23733 */
23734 encrypt: function (cipher, message, key, cfg) {
23735 // Apply config defaults
23736 cfg = this.cfg.extend(cfg);
23737
23738 // Encrypt
23739 var encryptor = cipher.createEncryptor(key, cfg);
23740 var ciphertext = encryptor.finalize(message);
23741
23742 // Shortcut
23743 var cipherCfg = encryptor.cfg;
23744
23745 // Create and return serializable cipher params
23746 return CipherParams.create({
23747 ciphertext: ciphertext,
23748 key: key,
23749 iv: cipherCfg.iv,
23750 algorithm: cipher,
23751 mode: cipherCfg.mode,
23752 padding: cipherCfg.padding,
23753 blockSize: cipher.blockSize,
23754 formatter: cfg.format
23755 });
23756 },
23757
23758 /**
23759 * Decrypts serialized ciphertext.
23760 *
23761 * @param {Cipher} cipher The cipher algorithm to use.
23762 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
23763 * @param {WordArray} key The key.
23764 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23765 *
23766 * @return {WordArray} The plaintext.
23767 *
23768 * @static
23769 *
23770 * @example
23771 *
23772 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23773 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23774 */
23775 decrypt: function (cipher, ciphertext, key, cfg) {
23776 // Apply config defaults
23777 cfg = this.cfg.extend(cfg);
23778
23779 // Convert string to CipherParams
23780 ciphertext = this._parse(ciphertext, cfg.format);
23781
23782 // Decrypt
23783 var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
23784
23785 return plaintext;
23786 },
23787
23788 /**
23789 * Converts serialized ciphertext to CipherParams,
23790 * else assumed CipherParams already and returns ciphertext unchanged.
23791 *
23792 * @param {CipherParams|string} ciphertext The ciphertext.
23793 * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
23794 *
23795 * @return {CipherParams} The unserialized ciphertext.
23796 *
23797 * @static
23798 *
23799 * @example
23800 *
23801 * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
23802 */
23803 _parse: function (ciphertext, format) {
23804 if (typeof ciphertext == 'string') {
23805 return format.parse(ciphertext, this);
23806 } else {
23807 return ciphertext;
23808 }
23809 }
23810 });
23811
23812 /**
23813 * Key derivation function namespace.
23814 */
23815 var C_kdf = C.kdf = {};
23816
23817 /**
23818 * OpenSSL key derivation function.
23819 */
23820 var OpenSSLKdf = C_kdf.OpenSSL = {
23821 /**
23822 * Derives a key and IV from a password.
23823 *
23824 * @param {string} password The password to derive from.
23825 * @param {number} keySize The size in words of the key to generate.
23826 * @param {number} ivSize The size in words of the IV to generate.
23827 * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
23828 *
23829 * @return {CipherParams} A cipher params object with the key, IV, and salt.
23830 *
23831 * @static
23832 *
23833 * @example
23834 *
23835 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
23836 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
23837 */
23838 execute: function (password, keySize, ivSize, salt) {
23839 // Generate random salt
23840 if (!salt) {
23841 salt = WordArray.random(64/8);
23842 }
23843
23844 // Derive key and IV
23845 var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
23846
23847 // Separate key and IV
23848 var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
23849 key.sigBytes = keySize * 4;
23850
23851 // Return params
23852 return CipherParams.create({ key: key, iv: iv, salt: salt });
23853 }
23854 };
23855
23856 /**
23857 * A serializable cipher wrapper that derives the key from a password,
23858 * and returns ciphertext as a serializable cipher params object.
23859 */
23860 var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
23861 /**
23862 * Configuration options.
23863 *
23864 * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
23865 */
23866 cfg: SerializableCipher.cfg.extend({
23867 kdf: OpenSSLKdf
23868 }),
23869
23870 /**
23871 * Encrypts a message using a password.
23872 *
23873 * @param {Cipher} cipher The cipher algorithm to use.
23874 * @param {WordArray|string} message The message to encrypt.
23875 * @param {string} password The password.
23876 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23877 *
23878 * @return {CipherParams} A cipher params object.
23879 *
23880 * @static
23881 *
23882 * @example
23883 *
23884 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
23885 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
23886 */
23887 encrypt: function (cipher, message, password, cfg) {
23888 // Apply config defaults
23889 cfg = this.cfg.extend(cfg);
23890
23891 // Derive key and other params
23892 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
23893
23894 // Add IV to config
23895 cfg.iv = derivedParams.iv;
23896
23897 // Encrypt
23898 var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
23899
23900 // Mix in derived params
23901 ciphertext.mixIn(derivedParams);
23902
23903 return ciphertext;
23904 },
23905
23906 /**
23907 * Decrypts serialized ciphertext using a password.
23908 *
23909 * @param {Cipher} cipher The cipher algorithm to use.
23910 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
23911 * @param {string} password The password.
23912 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23913 *
23914 * @return {WordArray} The plaintext.
23915 *
23916 * @static
23917 *
23918 * @example
23919 *
23920 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
23921 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
23922 */
23923 decrypt: function (cipher, ciphertext, password, cfg) {
23924 // Apply config defaults
23925 cfg = this.cfg.extend(cfg);
23926
23927 // Convert string to CipherParams
23928 ciphertext = this._parse(ciphertext, cfg.format);
23929
23930 // Derive key and other params
23931 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
23932
23933 // Add IV to config
23934 cfg.iv = derivedParams.iv;
23935
23936 // Decrypt
23937 var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
23938
23939 return plaintext;
23940 }
23941 });
23942 }());
23943
23944
23945 }));
23946 },{"./core":31}],31:[function(_dereq_,module,exports){
23947 ;(function (root, factory) {
23948 if (typeof exports === "object") {
23949 // CommonJS
23950 module.exports = exports = factory();
23951 }
23952 else if (typeof define === "function" && define.amd) {
23953 // AMD
23954 define([], factory);
23955 }
23956 else {
23957 // Global (browser)
23958 root.CryptoJS = factory();
23959 }
23960 }(this, function () {
23961
23962 /**
23963 * CryptoJS core components.
23964 */
23965 var CryptoJS = CryptoJS || (function (Math, undefined) {
23966 /**
23967 * CryptoJS namespace.
23968 */
23969 var C = {};
23970
23971 /**
23972 * Library namespace.
23973 */
23974 var C_lib = C.lib = {};
23975
23976 /**
23977 * Base object for prototypal inheritance.
23978 */
23979 var Base = C_lib.Base = (function () {
23980 function F() {}
23981
23982 return {
23983 /**
23984 * Creates a new object that inherits from this object.
23985 *
23986 * @param {Object} overrides Properties to copy into the new object.
23987 *
23988 * @return {Object} The new object.
23989 *
23990 * @static
23991 *
23992 * @example
23993 *
23994 * var MyType = CryptoJS.lib.Base.extend({
23995 * field: 'value',
23996 *
23997 * method: function () {
23998 * }
23999 * });
24000 */
24001 extend: function (overrides) {
24002 // Spawn
24003 F.prototype = this;
24004 var subtype = new F();
24005
24006 // Augment
24007 if (overrides) {
24008 subtype.mixIn(overrides);
24009 }
24010
24011 // Create default initializer
24012 if (!subtype.hasOwnProperty('init')) {
24013 subtype.init = function () {
24014 subtype.$super.init.apply(this, arguments);
24015 };
24016 }
24017
24018 // Initializer's prototype is the subtype object
24019 subtype.init.prototype = subtype;
24020
24021 // Reference supertype
24022 subtype.$super = this;
24023
24024 return subtype;
24025 },
24026
24027 /**
24028 * Extends this object and runs the init method.
24029 * Arguments to create() will be passed to init().
24030 *
24031 * @return {Object} The new object.
24032 *
24033 * @static
24034 *
24035 * @example
24036 *
24037 * var instance = MyType.create();
24038 */
24039 create: function () {
24040 var instance = this.extend();
24041 instance.init.apply(instance, arguments);
24042
24043 return instance;
24044 },
24045
24046 /**
24047 * Initializes a newly created object.
24048 * Override this method to add some logic when your objects are created.
24049 *
24050 * @example
24051 *
24052 * var MyType = CryptoJS.lib.Base.extend({
24053 * init: function () {
24054 * // ...
24055 * }
24056 * });
24057 */
24058 init: function () {
24059 },
24060
24061 /**
24062 * Copies properties into this object.
24063 *
24064 * @param {Object} properties The properties to mix in.
24065 *
24066 * @example
24067 *
24068 * MyType.mixIn({
24069 * field: 'value'
24070 * });
24071 */
24072 mixIn: function (properties) {
24073 for (var propertyName in properties) {
24074 if (properties.hasOwnProperty(propertyName)) {
24075 this[propertyName] = properties[propertyName];
24076 }
24077 }
24078
24079 // IE won't copy toString using the loop above
24080 if (properties.hasOwnProperty('toString')) {
24081 this.toString = properties.toString;
24082 }
24083 },
24084
24085 /**
24086 * Creates a copy of this object.
24087 *
24088 * @return {Object} The clone.
24089 *
24090 * @example
24091 *
24092 * var clone = instance.clone();
24093 */
24094 clone: function () {
24095 return this.init.prototype.extend(this);
24096 }
24097 };
24098 }());
24099
24100 /**
24101 * An array of 32-bit words.
24102 *
24103 * @property {Array} words The array of 32-bit words.
24104 * @property {number} sigBytes The number of significant bytes in this word array.
24105 */
24106 var WordArray = C_lib.WordArray = Base.extend({
24107 /**
24108 * Initializes a newly created word array.
24109 *
24110 * @param {Array} words (Optional) An array of 32-bit words.
24111 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
24112 *
24113 * @example
24114 *
24115 * var wordArray = CryptoJS.lib.WordArray.create();
24116 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
24117 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
24118 */
24119 init: function (words, sigBytes) {
24120 words = this.words = words || [];
24121
24122 if (sigBytes != undefined) {
24123 this.sigBytes = sigBytes;
24124 } else {
24125 this.sigBytes = words.length * 4;
24126 }
24127 },
24128
24129 /**
24130 * Converts this word array to a string.
24131 *
24132 * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
24133 *
24134 * @return {string} The stringified word array.
24135 *
24136 * @example
24137 *
24138 * var string = wordArray + '';
24139 * var string = wordArray.toString();
24140 * var string = wordArray.toString(CryptoJS.enc.Utf8);
24141 */
24142 toString: function (encoder) {
24143 return (encoder || Hex).stringify(this);
24144 },
24145
24146 /**
24147 * Concatenates a word array to this word array.
24148 *
24149 * @param {WordArray} wordArray The word array to append.
24150 *
24151 * @return {WordArray} This word array.
24152 *
24153 * @example
24154 *
24155 * wordArray1.concat(wordArray2);
24156 */
24157 concat: function (wordArray) {
24158 // Shortcuts
24159 var thisWords = this.words;
24160 var thatWords = wordArray.words;
24161 var thisSigBytes = this.sigBytes;
24162 var thatSigBytes = wordArray.sigBytes;
24163
24164 // Clamp excess bits
24165 this.clamp();
24166
24167 // Concat
24168 if (thisSigBytes % 4) {
24169 // Copy one byte at a time
24170 for (var i = 0; i < thatSigBytes; i++) {
24171 var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24172 thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
24173 }
24174 } else if (thatWords.length > 0xffff) {
24175 // Copy one word at a time
24176 for (var i = 0; i < thatSigBytes; i += 4) {
24177 thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
24178 }
24179 } else {
24180 // Copy all words at once
24181 thisWords.push.apply(thisWords, thatWords);
24182 }
24183 this.sigBytes += thatSigBytes;
24184
24185 // Chainable
24186 return this;
24187 },
24188
24189 /**
24190 * Removes insignificant bits.
24191 *
24192 * @example
24193 *
24194 * wordArray.clamp();
24195 */
24196 clamp: function () {
24197 // Shortcuts
24198 var words = this.words;
24199 var sigBytes = this.sigBytes;
24200
24201 // Clamp
24202 words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
24203 words.length = Math.ceil(sigBytes / 4);
24204 },
24205
24206 /**
24207 * Creates a copy of this word array.
24208 *
24209 * @return {WordArray} The clone.
24210 *
24211 * @example
24212 *
24213 * var clone = wordArray.clone();
24214 */
24215 clone: function () {
24216 var clone = Base.clone.call(this);
24217 clone.words = this.words.slice(0);
24218
24219 return clone;
24220 },
24221
24222 /**
24223 * Creates a word array filled with random bytes.
24224 *
24225 * @param {number} nBytes The number of random bytes to generate.
24226 *
24227 * @return {WordArray} The random word array.
24228 *
24229 * @static
24230 *
24231 * @example
24232 *
24233 * var wordArray = CryptoJS.lib.WordArray.random(16);
24234 */
24235 random: function (nBytes) {
24236 var words = [];
24237 for (var i = 0; i < nBytes; i += 4) {
24238 words.push((Math.random() * 0x100000000) | 0);
24239 }
24240
24241 return new WordArray.init(words, nBytes);
24242 }
24243 });
24244
24245 /**
24246 * Encoder namespace.
24247 */
24248 var C_enc = C.enc = {};
24249
24250 /**
24251 * Hex encoding strategy.
24252 */
24253 var Hex = C_enc.Hex = {
24254 /**
24255 * Converts a word array to a hex string.
24256 *
24257 * @param {WordArray} wordArray The word array.
24258 *
24259 * @return {string} The hex string.
24260 *
24261 * @static
24262 *
24263 * @example
24264 *
24265 * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
24266 */
24267 stringify: function (wordArray) {
24268 // Shortcuts
24269 var words = wordArray.words;
24270 var sigBytes = wordArray.sigBytes;
24271
24272 // Convert
24273 var hexChars = [];
24274 for (var i = 0; i < sigBytes; i++) {
24275 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24276 hexChars.push((bite >>> 4).toString(16));
24277 hexChars.push((bite & 0x0f).toString(16));
24278 }
24279
24280 return hexChars.join('');
24281 },
24282
24283 /**
24284 * Converts a hex string to a word array.
24285 *
24286 * @param {string} hexStr The hex string.
24287 *
24288 * @return {WordArray} The word array.
24289 *
24290 * @static
24291 *
24292 * @example
24293 *
24294 * var wordArray = CryptoJS.enc.Hex.parse(hexString);
24295 */
24296 parse: function (hexStr) {
24297 // Shortcut
24298 var hexStrLength = hexStr.length;
24299
24300 // Convert
24301 var words = [];
24302 for (var i = 0; i < hexStrLength; i += 2) {
24303 words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
24304 }
24305
24306 return new WordArray.init(words, hexStrLength / 2);
24307 }
24308 };
24309
24310 /**
24311 * Latin1 encoding strategy.
24312 */
24313 var Latin1 = C_enc.Latin1 = {
24314 /**
24315 * Converts a word array to a Latin1 string.
24316 *
24317 * @param {WordArray} wordArray The word array.
24318 *
24319 * @return {string} The Latin1 string.
24320 *
24321 * @static
24322 *
24323 * @example
24324 *
24325 * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
24326 */
24327 stringify: function (wordArray) {
24328 // Shortcuts
24329 var words = wordArray.words;
24330 var sigBytes = wordArray.sigBytes;
24331
24332 // Convert
24333 var latin1Chars = [];
24334 for (var i = 0; i < sigBytes; i++) {
24335 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24336 latin1Chars.push(String.fromCharCode(bite));
24337 }
24338
24339 return latin1Chars.join('');
24340 },
24341
24342 /**
24343 * Converts a Latin1 string to a word array.
24344 *
24345 * @param {string} latin1Str The Latin1 string.
24346 *
24347 * @return {WordArray} The word array.
24348 *
24349 * @static
24350 *
24351 * @example
24352 *
24353 * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
24354 */
24355 parse: function (latin1Str) {
24356 // Shortcut
24357 var latin1StrLength = latin1Str.length;
24358
24359 // Convert
24360 var words = [];
24361 for (var i = 0; i < latin1StrLength; i++) {
24362 words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
24363 }
24364
24365 return new WordArray.init(words, latin1StrLength);
24366 }
24367 };
24368
24369 /**
24370 * UTF-8 encoding strategy.
24371 */
24372 var Utf8 = C_enc.Utf8 = {
24373 /**
24374 * Converts a word array to a UTF-8 string.
24375 *
24376 * @param {WordArray} wordArray The word array.
24377 *
24378 * @return {string} The UTF-8 string.
24379 *
24380 * @static
24381 *
24382 * @example
24383 *
24384 * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
24385 */
24386 stringify: function (wordArray) {
24387 try {
24388 return decodeURIComponent(escape(Latin1.stringify(wordArray)));
24389 } catch (e) {
24390 throw new Error('Malformed UTF-8 data');
24391 }
24392 },
24393
24394 /**
24395 * Converts a UTF-8 string to a word array.
24396 *
24397 * @param {string} utf8Str The UTF-8 string.
24398 *
24399 * @return {WordArray} The word array.
24400 *
24401 * @static
24402 *
24403 * @example
24404 *
24405 * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
24406 */
24407 parse: function (utf8Str) {
24408 return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
24409 }
24410 };
24411
24412 /**
24413 * Abstract buffered block algorithm template.
24414 *
24415 * The property blockSize must be implemented in a concrete subtype.
24416 *
24417 * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
24418 */
24419 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
24420 /**
24421 * Resets this block algorithm's data buffer to its initial state.
24422 *
24423 * @example
24424 *
24425 * bufferedBlockAlgorithm.reset();
24426 */
24427 reset: function () {
24428 // Initial values
24429 this._data = new WordArray.init();
24430 this._nDataBytes = 0;
24431 },
24432
24433 /**
24434 * Adds new data to this block algorithm's buffer.
24435 *
24436 * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
24437 *
24438 * @example
24439 *
24440 * bufferedBlockAlgorithm._append('data');
24441 * bufferedBlockAlgorithm._append(wordArray);
24442 */
24443 _append: function (data) {
24444 // Convert string to WordArray, else assume WordArray already
24445 if (typeof data == 'string') {
24446 data = Utf8.parse(data);
24447 }
24448
24449 // Append
24450 this._data.concat(data);
24451 this._nDataBytes += data.sigBytes;
24452 },
24453
24454 /**
24455 * Processes available data blocks.
24456 *
24457 * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
24458 *
24459 * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
24460 *
24461 * @return {WordArray} The processed data.
24462 *
24463 * @example
24464 *
24465 * var processedData = bufferedBlockAlgorithm._process();
24466 * var processedData = bufferedBlockAlgorithm._process(!!'flush');
24467 */
24468 _process: function (doFlush) {
24469 // Shortcuts
24470 var data = this._data;
24471 var dataWords = data.words;
24472 var dataSigBytes = data.sigBytes;
24473 var blockSize = this.blockSize;
24474 var blockSizeBytes = blockSize * 4;
24475
24476 // Count blocks ready
24477 var nBlocksReady = dataSigBytes / blockSizeBytes;
24478 if (doFlush) {
24479 // Round up to include partial blocks
24480 nBlocksReady = Math.ceil(nBlocksReady);
24481 } else {
24482 // Round down to include only full blocks,
24483 // less the number of blocks that must remain in the buffer
24484 nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
24485 }
24486
24487 // Count words ready
24488 var nWordsReady = nBlocksReady * blockSize;
24489
24490 // Count bytes ready
24491 var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
24492
24493 // Process blocks
24494 if (nWordsReady) {
24495 for (var offset = 0; offset < nWordsReady; offset += blockSize) {
24496 // Perform concrete-algorithm logic
24497 this._doProcessBlock(dataWords, offset);
24498 }
24499
24500 // Remove processed words
24501 var processedWords = dataWords.splice(0, nWordsReady);
24502 data.sigBytes -= nBytesReady;
24503 }
24504
24505 // Return processed words
24506 return new WordArray.init(processedWords, nBytesReady);
24507 },
24508
24509 /**
24510 * Creates a copy of this object.
24511 *
24512 * @return {Object} The clone.
24513 *
24514 * @example
24515 *
24516 * var clone = bufferedBlockAlgorithm.clone();
24517 */
24518 clone: function () {
24519 var clone = Base.clone.call(this);
24520 clone._data = this._data.clone();
24521
24522 return clone;
24523 },
24524
24525 _minBufferSize: 0
24526 });
24527
24528 /**
24529 * Abstract hasher template.
24530 *
24531 * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
24532 */
24533 var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
24534 /**
24535 * Configuration options.
24536 */
24537 cfg: Base.extend(),
24538
24539 /**
24540 * Initializes a newly created hasher.
24541 *
24542 * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
24543 *
24544 * @example
24545 *
24546 * var hasher = CryptoJS.algo.SHA256.create();
24547 */
24548 init: function (cfg) {
24549 // Apply config defaults
24550 this.cfg = this.cfg.extend(cfg);
24551
24552 // Set initial values
24553 this.reset();
24554 },
24555
24556 /**
24557 * Resets this hasher to its initial state.
24558 *
24559 * @example
24560 *
24561 * hasher.reset();
24562 */
24563 reset: function () {
24564 // Reset data buffer
24565 BufferedBlockAlgorithm.reset.call(this);
24566
24567 // Perform concrete-hasher logic
24568 this._doReset();
24569 },
24570
24571 /**
24572 * Updates this hasher with a message.
24573 *
24574 * @param {WordArray|string} messageUpdate The message to append.
24575 *
24576 * @return {Hasher} This hasher.
24577 *
24578 * @example
24579 *
24580 * hasher.update('message');
24581 * hasher.update(wordArray);
24582 */
24583 update: function (messageUpdate) {
24584 // Append
24585 this._append(messageUpdate);
24586
24587 // Update the hash
24588 this._process();
24589
24590 // Chainable
24591 return this;
24592 },
24593
24594 /**
24595 * Finalizes the hash computation.
24596 * Note that the finalize operation is effectively a destructive, read-once operation.
24597 *
24598 * @param {WordArray|string} messageUpdate (Optional) A final message update.
24599 *
24600 * @return {WordArray} The hash.
24601 *
24602 * @example
24603 *
24604 * var hash = hasher.finalize();
24605 * var hash = hasher.finalize('message');
24606 * var hash = hasher.finalize(wordArray);
24607 */
24608 finalize: function (messageUpdate) {
24609 // Final message update
24610 if (messageUpdate) {
24611 this._append(messageUpdate);
24612 }
24613
24614 // Perform concrete-hasher logic
24615 var hash = this._doFinalize();
24616
24617 return hash;
24618 },
24619
24620 blockSize: 512/32,
24621
24622 /**
24623 * Creates a shortcut function to a hasher's object interface.
24624 *
24625 * @param {Hasher} hasher The hasher to create a helper for.
24626 *
24627 * @return {Function} The shortcut function.
24628 *
24629 * @static
24630 *
24631 * @example
24632 *
24633 * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
24634 */
24635 _createHelper: function (hasher) {
24636 return function (message, cfg) {
24637 return new hasher.init(cfg).finalize(message);
24638 };
24639 },
24640
24641 /**
24642 * Creates a shortcut function to the HMAC's object interface.
24643 *
24644 * @param {Hasher} hasher The hasher to use in this HMAC helper.
24645 *
24646 * @return {Function} The shortcut function.
24647 *
24648 * @static
24649 *
24650 * @example
24651 *
24652 * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
24653 */
24654 _createHmacHelper: function (hasher) {
24655 return function (message, key) {
24656 return new C_algo.HMAC.init(hasher, key).finalize(message);
24657 };
24658 }
24659 });
24660
24661 /**
24662 * Algorithm namespace.
24663 */
24664 var C_algo = C.algo = {};
24665
24666 return C;
24667 }(Math));
24668
24669
24670 return CryptoJS;
24671
24672 }));
24673 },{}],32:[function(_dereq_,module,exports){
24674 ;(function (root, factory) {
24675 if (typeof exports === "object") {
24676 // CommonJS
24677 module.exports = exports = factory(_dereq_("./core"));
24678 }
24679 else if (typeof define === "function" && define.amd) {
24680 // AMD
24681 define(["./core"], factory);
24682 }
24683 else {
24684 // Global (browser)
24685 factory(root.CryptoJS);
24686 }
24687 }(this, function (CryptoJS) {
24688
24689 (function () {
24690 // Shortcuts
24691 var C = CryptoJS;
24692 var C_lib = C.lib;
24693 var WordArray = C_lib.WordArray;
24694 var C_enc = C.enc;
24695
24696 /**
24697 * Base64 encoding strategy.
24698 */
24699 var Base64 = C_enc.Base64 = {
24700 /**
24701 * Converts a word array to a Base64 string.
24702 *
24703 * @param {WordArray} wordArray The word array.
24704 *
24705 * @return {string} The Base64 string.
24706 *
24707 * @static
24708 *
24709 * @example
24710 *
24711 * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
24712 */
24713 stringify: function (wordArray) {
24714 // Shortcuts
24715 var words = wordArray.words;
24716 var sigBytes = wordArray.sigBytes;
24717 var map = this._map;
24718
24719 // Clamp excess bits
24720 wordArray.clamp();
24721
24722 // Convert
24723 var base64Chars = [];
24724 for (var i = 0; i < sigBytes; i += 3) {
24725 var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24726 var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
24727 var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
24728
24729 var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
24730
24731 for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
24732 base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
24733 }
24734 }
24735
24736 // Add padding
24737 var paddingChar = map.charAt(64);
24738 if (paddingChar) {
24739 while (base64Chars.length % 4) {
24740 base64Chars.push(paddingChar);
24741 }
24742 }
24743
24744 return base64Chars.join('');
24745 },
24746
24747 /**
24748 * Converts a Base64 string to a word array.
24749 *
24750 * @param {string} base64Str The Base64 string.
24751 *
24752 * @return {WordArray} The word array.
24753 *
24754 * @static
24755 *
24756 * @example
24757 *
24758 * var wordArray = CryptoJS.enc.Base64.parse(base64String);
24759 */
24760 parse: function (base64Str) {
24761 // Shortcuts
24762 var base64StrLength = base64Str.length;
24763 var map = this._map;
24764
24765 // Ignore padding
24766 var paddingChar = map.charAt(64);
24767 if (paddingChar) {
24768 var paddingIndex = base64Str.indexOf(paddingChar);
24769 if (paddingIndex != -1) {
24770 base64StrLength = paddingIndex;
24771 }
24772 }
24773
24774 // Convert
24775 var words = [];
24776 var nBytes = 0;
24777 for (var i = 0; i < base64StrLength; i++) {
24778 if (i % 4) {
24779 var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2);
24780 var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2);
24781 words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
24782 nBytes++;
24783 }
24784 }
24785
24786 return WordArray.create(words, nBytes);
24787 },
24788
24789 _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
24790 };
24791 }());
24792
24793
24794 return CryptoJS.enc.Base64;
24795
24796 }));
24797 },{"./core":31}],33:[function(_dereq_,module,exports){
24798 ;(function (root, factory) {
24799 if (typeof exports === "object") {
24800 // CommonJS
24801 module.exports = exports = factory(_dereq_("./core"));
24802 }
24803 else if (typeof define === "function" && define.amd) {
24804 // AMD
24805 define(["./core"], factory);
24806 }
24807 else {
24808 // Global (browser)
24809 factory(root.CryptoJS);
24810 }
24811 }(this, function (CryptoJS) {
24812
24813 (function () {
24814 // Shortcuts
24815 var C = CryptoJS;
24816 var C_lib = C.lib;
24817 var WordArray = C_lib.WordArray;
24818 var C_enc = C.enc;
24819
24820 /**
24821 * UTF-16 BE encoding strategy.
24822 */
24823 var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
24824 /**
24825 * Converts a word array to a UTF-16 BE string.
24826 *
24827 * @param {WordArray} wordArray The word array.
24828 *
24829 * @return {string} The UTF-16 BE string.
24830 *
24831 * @static
24832 *
24833 * @example
24834 *
24835 * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
24836 */
24837 stringify: function (wordArray) {
24838 // Shortcuts
24839 var words = wordArray.words;
24840 var sigBytes = wordArray.sigBytes;
24841
24842 // Convert
24843 var utf16Chars = [];
24844 for (var i = 0; i < sigBytes; i += 2) {
24845 var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
24846 utf16Chars.push(String.fromCharCode(codePoint));
24847 }
24848
24849 return utf16Chars.join('');
24850 },
24851
24852 /**
24853 * Converts a UTF-16 BE string to a word array.
24854 *
24855 * @param {string} utf16Str The UTF-16 BE string.
24856 *
24857 * @return {WordArray} The word array.
24858 *
24859 * @static
24860 *
24861 * @example
24862 *
24863 * var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
24864 */
24865 parse: function (utf16Str) {
24866 // Shortcut
24867 var utf16StrLength = utf16Str.length;
24868
24869 // Convert
24870 var words = [];
24871 for (var i = 0; i < utf16StrLength; i++) {
24872 words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
24873 }
24874
24875 return WordArray.create(words, utf16StrLength * 2);
24876 }
24877 };
24878
24879 /**
24880 * UTF-16 LE encoding strategy.
24881 */
24882 C_enc.Utf16LE = {
24883 /**
24884 * Converts a word array to a UTF-16 LE string.
24885 *
24886 * @param {WordArray} wordArray The word array.
24887 *
24888 * @return {string} The UTF-16 LE string.
24889 *
24890 * @static
24891 *
24892 * @example
24893 *
24894 * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
24895 */
24896 stringify: function (wordArray) {
24897 // Shortcuts
24898 var words = wordArray.words;
24899 var sigBytes = wordArray.sigBytes;
24900
24901 // Convert
24902 var utf16Chars = [];
24903 for (var i = 0; i < sigBytes; i += 2) {
24904 var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
24905 utf16Chars.push(String.fromCharCode(codePoint));
24906 }
24907
24908 return utf16Chars.join('');
24909 },
24910
24911 /**
24912 * Converts a UTF-16 LE string to a word array.
24913 *
24914 * @param {string} utf16Str The UTF-16 LE string.
24915 *
24916 * @return {WordArray} The word array.
24917 *
24918 * @static
24919 *
24920 * @example
24921 *
24922 * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
24923 */
24924 parse: function (utf16Str) {
24925 // Shortcut
24926 var utf16StrLength = utf16Str.length;
24927
24928 // Convert
24929 var words = [];
24930 for (var i = 0; i < utf16StrLength; i++) {
24931 words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
24932 }
24933
24934 return WordArray.create(words, utf16StrLength * 2);
24935 }
24936 };
24937
24938 function swapEndian(word) {
24939 return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
24940 }
24941 }());
24942
24943
24944 return CryptoJS.enc.Utf16;
24945
24946 }));
24947 },{"./core":31}],34:[function(_dereq_,module,exports){
24948 ;(function (root, factory, undef) {
24949 if (typeof exports === "object") {
24950 // CommonJS
24951 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
24952 }
24953 else if (typeof define === "function" && define.amd) {
24954 // AMD
24955 define(["./core", "./sha1", "./hmac"], factory);
24956 }
24957 else {
24958 // Global (browser)
24959 factory(root.CryptoJS);
24960 }
24961 }(this, function (CryptoJS) {
24962
24963 (function () {
24964 // Shortcuts
24965 var C = CryptoJS;
24966 var C_lib = C.lib;
24967 var Base = C_lib.Base;
24968 var WordArray = C_lib.WordArray;
24969 var C_algo = C.algo;
24970 var MD5 = C_algo.MD5;
24971
24972 /**
24973 * This key derivation function is meant to conform with EVP_BytesToKey.
24974 * www.openssl.org/docs/crypto/EVP_BytesToKey.html
24975 */
24976 var EvpKDF = C_algo.EvpKDF = Base.extend({
24977 /**
24978 * Configuration options.
24979 *
24980 * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
24981 * @property {Hasher} hasher The hash algorithm to use. Default: MD5
24982 * @property {number} iterations The number of iterations to perform. Default: 1
24983 */
24984 cfg: Base.extend({
24985 keySize: 128/32,
24986 hasher: MD5,
24987 iterations: 1
24988 }),
24989
24990 /**
24991 * Initializes a newly created key derivation function.
24992 *
24993 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
24994 *
24995 * @example
24996 *
24997 * var kdf = CryptoJS.algo.EvpKDF.create();
24998 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
24999 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
25000 */
25001 init: function (cfg) {
25002 this.cfg = this.cfg.extend(cfg);
25003 },
25004
25005 /**
25006 * Derives a key from a password.
25007 *
25008 * @param {WordArray|string} password The password.
25009 * @param {WordArray|string} salt A salt.
25010 *
25011 * @return {WordArray} The derived key.
25012 *
25013 * @example
25014 *
25015 * var key = kdf.compute(password, salt);
25016 */
25017 compute: function (password, salt) {
25018 // Shortcut
25019 var cfg = this.cfg;
25020
25021 // Init hasher
25022 var hasher = cfg.hasher.create();
25023
25024 // Initial values
25025 var derivedKey = WordArray.create();
25026
25027 // Shortcuts
25028 var derivedKeyWords = derivedKey.words;
25029 var keySize = cfg.keySize;
25030 var iterations = cfg.iterations;
25031
25032 // Generate key
25033 while (derivedKeyWords.length < keySize) {
25034 if (block) {
25035 hasher.update(block);
25036 }
25037 var block = hasher.update(password).finalize(salt);
25038 hasher.reset();
25039
25040 // Iterations
25041 for (var i = 1; i < iterations; i++) {
25042 block = hasher.finalize(block);
25043 hasher.reset();
25044 }
25045
25046 derivedKey.concat(block);
25047 }
25048 derivedKey.sigBytes = keySize * 4;
25049
25050 return derivedKey;
25051 }
25052 });
25053
25054 /**
25055 * Derives a key from a password.
25056 *
25057 * @param {WordArray|string} password The password.
25058 * @param {WordArray|string} salt A salt.
25059 * @param {Object} cfg (Optional) The configuration options to use for this computation.
25060 *
25061 * @return {WordArray} The derived key.
25062 *
25063 * @static
25064 *
25065 * @example
25066 *
25067 * var key = CryptoJS.EvpKDF(password, salt);
25068 * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
25069 * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
25070 */
25071 C.EvpKDF = function (password, salt, cfg) {
25072 return EvpKDF.create(cfg).compute(password, salt);
25073 };
25074 }());
25075
25076
25077 return CryptoJS.EvpKDF;
25078
25079 }));
25080 },{"./core":31,"./hmac":36,"./sha1":55}],35:[function(_dereq_,module,exports){
25081 ;(function (root, factory, undef) {
25082 if (typeof exports === "object") {
25083 // CommonJS
25084 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25085 }
25086 else if (typeof define === "function" && define.amd) {
25087 // AMD
25088 define(["./core", "./cipher-core"], factory);
25089 }
25090 else {
25091 // Global (browser)
25092 factory(root.CryptoJS);
25093 }
25094 }(this, function (CryptoJS) {
25095
25096 (function (undefined) {
25097 // Shortcuts
25098 var C = CryptoJS;
25099 var C_lib = C.lib;
25100 var CipherParams = C_lib.CipherParams;
25101 var C_enc = C.enc;
25102 var Hex = C_enc.Hex;
25103 var C_format = C.format;
25104
25105 var HexFormatter = C_format.Hex = {
25106 /**
25107 * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
25108 *
25109 * @param {CipherParams} cipherParams The cipher params object.
25110 *
25111 * @return {string} The hexadecimally encoded string.
25112 *
25113 * @static
25114 *
25115 * @example
25116 *
25117 * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
25118 */
25119 stringify: function (cipherParams) {
25120 return cipherParams.ciphertext.toString(Hex);
25121 },
25122
25123 /**
25124 * Converts a hexadecimally encoded ciphertext string to a cipher params object.
25125 *
25126 * @param {string} input The hexadecimally encoded string.
25127 *
25128 * @return {CipherParams} The cipher params object.
25129 *
25130 * @static
25131 *
25132 * @example
25133 *
25134 * var cipherParams = CryptoJS.format.Hex.parse(hexString);
25135 */
25136 parse: function (input) {
25137 var ciphertext = Hex.parse(input);
25138 return CipherParams.create({ ciphertext: ciphertext });
25139 }
25140 };
25141 }());
25142
25143
25144 return CryptoJS.format.Hex;
25145
25146 }));
25147 },{"./cipher-core":30,"./core":31}],36:[function(_dereq_,module,exports){
25148 ;(function (root, factory) {
25149 if (typeof exports === "object") {
25150 // CommonJS
25151 module.exports = exports = factory(_dereq_("./core"));
25152 }
25153 else if (typeof define === "function" && define.amd) {
25154 // AMD
25155 define(["./core"], factory);
25156 }
25157 else {
25158 // Global (browser)
25159 factory(root.CryptoJS);
25160 }
25161 }(this, function (CryptoJS) {
25162
25163 (function () {
25164 // Shortcuts
25165 var C = CryptoJS;
25166 var C_lib = C.lib;
25167 var Base = C_lib.Base;
25168 var C_enc = C.enc;
25169 var Utf8 = C_enc.Utf8;
25170 var C_algo = C.algo;
25171
25172 /**
25173 * HMAC algorithm.
25174 */
25175 var HMAC = C_algo.HMAC = Base.extend({
25176 /**
25177 * Initializes a newly created HMAC.
25178 *
25179 * @param {Hasher} hasher The hash algorithm to use.
25180 * @param {WordArray|string} key The secret key.
25181 *
25182 * @example
25183 *
25184 * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
25185 */
25186 init: function (hasher, key) {
25187 // Init hasher
25188 hasher = this._hasher = new hasher.init();
25189
25190 // Convert string to WordArray, else assume WordArray already
25191 if (typeof key == 'string') {
25192 key = Utf8.parse(key);
25193 }
25194
25195 // Shortcuts
25196 var hasherBlockSize = hasher.blockSize;
25197 var hasherBlockSizeBytes = hasherBlockSize * 4;
25198
25199 // Allow arbitrary length keys
25200 if (key.sigBytes > hasherBlockSizeBytes) {
25201 key = hasher.finalize(key);
25202 }
25203
25204 // Clamp excess bits
25205 key.clamp();
25206
25207 // Clone key for inner and outer pads
25208 var oKey = this._oKey = key.clone();
25209 var iKey = this._iKey = key.clone();
25210
25211 // Shortcuts
25212 var oKeyWords = oKey.words;
25213 var iKeyWords = iKey.words;
25214
25215 // XOR keys with pad constants
25216 for (var i = 0; i < hasherBlockSize; i++) {
25217 oKeyWords[i] ^= 0x5c5c5c5c;
25218 iKeyWords[i] ^= 0x36363636;
25219 }
25220 oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
25221
25222 // Set initial values
25223 this.reset();
25224 },
25225
25226 /**
25227 * Resets this HMAC to its initial state.
25228 *
25229 * @example
25230 *
25231 * hmacHasher.reset();
25232 */
25233 reset: function () {
25234 // Shortcut
25235 var hasher = this._hasher;
25236
25237 // Reset
25238 hasher.reset();
25239 hasher.update(this._iKey);
25240 },
25241
25242 /**
25243 * Updates this HMAC with a message.
25244 *
25245 * @param {WordArray|string} messageUpdate The message to append.
25246 *
25247 * @return {HMAC} This HMAC instance.
25248 *
25249 * @example
25250 *
25251 * hmacHasher.update('message');
25252 * hmacHasher.update(wordArray);
25253 */
25254 update: function (messageUpdate) {
25255 this._hasher.update(messageUpdate);
25256
25257 // Chainable
25258 return this;
25259 },
25260
25261 /**
25262 * Finalizes the HMAC computation.
25263 * Note that the finalize operation is effectively a destructive, read-once operation.
25264 *
25265 * @param {WordArray|string} messageUpdate (Optional) A final message update.
25266 *
25267 * @return {WordArray} The HMAC.
25268 *
25269 * @example
25270 *
25271 * var hmac = hmacHasher.finalize();
25272 * var hmac = hmacHasher.finalize('message');
25273 * var hmac = hmacHasher.finalize(wordArray);
25274 */
25275 finalize: function (messageUpdate) {
25276 // Shortcut
25277 var hasher = this._hasher;
25278
25279 // Compute HMAC
25280 var innerHash = hasher.finalize(messageUpdate);
25281 hasher.reset();
25282 var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
25283
25284 return hmac;
25285 }
25286 });
25287 }());
25288
25289
25290 }));
25291 },{"./core":31}],37:[function(_dereq_,module,exports){
25292 ;(function (root, factory, undef) {
25293 if (typeof exports === "object") {
25294 // CommonJS
25295 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"));
25296 }
25297 else if (typeof define === "function" && define.amd) {
25298 // AMD
25299 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);
25300 }
25301 else {
25302 // Global (browser)
25303 factory(root.CryptoJS);
25304 }
25305 }(this, function (CryptoJS) {
25306
25307 return CryptoJS;
25308
25309 }));
25310 },{"./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){
25311 ;(function (root, factory) {
25312 if (typeof exports === "object") {
25313 // CommonJS
25314 module.exports = exports = factory(_dereq_("./core"));
25315 }
25316 else if (typeof define === "function" && define.amd) {
25317 // AMD
25318 define(["./core"], factory);
25319 }
25320 else {
25321 // Global (browser)
25322 factory(root.CryptoJS);
25323 }
25324 }(this, function (CryptoJS) {
25325
25326 (function () {
25327 // Check if typed arrays are supported
25328 if (typeof ArrayBuffer != 'function') {
25329 return;
25330 }
25331
25332 // Shortcuts
25333 var C = CryptoJS;
25334 var C_lib = C.lib;
25335 var WordArray = C_lib.WordArray;
25336
25337 // Reference original init
25338 var superInit = WordArray.init;
25339
25340 // Augment WordArray.init to handle typed arrays
25341 var subInit = WordArray.init = function (typedArray) {
25342 // Convert buffers to uint8
25343 if (typedArray instanceof ArrayBuffer) {
25344 typedArray = new Uint8Array(typedArray);
25345 }
25346
25347 // Convert other array views to uint8
25348 if (
25349 typedArray instanceof Int8Array ||
25350 typedArray instanceof Uint8ClampedArray ||
25351 typedArray instanceof Int16Array ||
25352 typedArray instanceof Uint16Array ||
25353 typedArray instanceof Int32Array ||
25354 typedArray instanceof Uint32Array ||
25355 typedArray instanceof Float32Array ||
25356 typedArray instanceof Float64Array
25357 ) {
25358 typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
25359 }
25360
25361 // Handle Uint8Array
25362 if (typedArray instanceof Uint8Array) {
25363 // Shortcut
25364 var typedArrayByteLength = typedArray.byteLength;
25365
25366 // Extract bytes
25367 var words = [];
25368 for (var i = 0; i < typedArrayByteLength; i++) {
25369 words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
25370 }
25371
25372 // Initialize this word array
25373 superInit.call(this, words, typedArrayByteLength);
25374 } else {
25375 // Else call normal init
25376 superInit.apply(this, arguments);
25377 }
25378 };
25379
25380 subInit.prototype = WordArray;
25381 }());
25382
25383
25384 return CryptoJS.lib.WordArray;
25385
25386 }));
25387 },{"./core":31}],39:[function(_dereq_,module,exports){
25388 ;(function (root, factory) {
25389 if (typeof exports === "object") {
25390 // CommonJS
25391 module.exports = exports = factory(_dereq_("./core"));
25392 }
25393 else if (typeof define === "function" && define.amd) {
25394 // AMD
25395 define(["./core"], factory);
25396 }
25397 else {
25398 // Global (browser)
25399 factory(root.CryptoJS);
25400 }
25401 }(this, function (CryptoJS) {
25402
25403 (function (Math) {
25404 // Shortcuts
25405 var C = CryptoJS;
25406 var C_lib = C.lib;
25407 var WordArray = C_lib.WordArray;
25408 var Hasher = C_lib.Hasher;
25409 var C_algo = C.algo;
25410
25411 // Constants table
25412 var T = [];
25413
25414 // Compute constants
25415 (function () {
25416 for (var i = 0; i < 64; i++) {
25417 T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
25418 }
25419 }());
25420
25421 /**
25422 * MD5 hash algorithm.
25423 */
25424 var MD5 = C_algo.MD5 = Hasher.extend({
25425 _doReset: function () {
25426 this._hash = new WordArray.init([
25427 0x67452301, 0xefcdab89,
25428 0x98badcfe, 0x10325476
25429 ]);
25430 },
25431
25432 _doProcessBlock: function (M, offset) {
25433 // Swap endian
25434 for (var i = 0; i < 16; i++) {
25435 // Shortcuts
25436 var offset_i = offset + i;
25437 var M_offset_i = M[offset_i];
25438
25439 M[offset_i] = (
25440 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
25441 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
25442 );
25443 }
25444
25445 // Shortcuts
25446 var H = this._hash.words;
25447
25448 var M_offset_0 = M[offset + 0];
25449 var M_offset_1 = M[offset + 1];
25450 var M_offset_2 = M[offset + 2];
25451 var M_offset_3 = M[offset + 3];
25452 var M_offset_4 = M[offset + 4];
25453 var M_offset_5 = M[offset + 5];
25454 var M_offset_6 = M[offset + 6];
25455 var M_offset_7 = M[offset + 7];
25456 var M_offset_8 = M[offset + 8];
25457 var M_offset_9 = M[offset + 9];
25458 var M_offset_10 = M[offset + 10];
25459 var M_offset_11 = M[offset + 11];
25460 var M_offset_12 = M[offset + 12];
25461 var M_offset_13 = M[offset + 13];
25462 var M_offset_14 = M[offset + 14];
25463 var M_offset_15 = M[offset + 15];
25464
25465 // Working varialbes
25466 var a = H[0];
25467 var b = H[1];
25468 var c = H[2];
25469 var d = H[3];
25470
25471 // Computation
25472 a = FF(a, b, c, d, M_offset_0, 7, T[0]);
25473 d = FF(d, a, b, c, M_offset_1, 12, T[1]);
25474 c = FF(c, d, a, b, M_offset_2, 17, T[2]);
25475 b = FF(b, c, d, a, M_offset_3, 22, T[3]);
25476 a = FF(a, b, c, d, M_offset_4, 7, T[4]);
25477 d = FF(d, a, b, c, M_offset_5, 12, T[5]);
25478 c = FF(c, d, a, b, M_offset_6, 17, T[6]);
25479 b = FF(b, c, d, a, M_offset_7, 22, T[7]);
25480 a = FF(a, b, c, d, M_offset_8, 7, T[8]);
25481 d = FF(d, a, b, c, M_offset_9, 12, T[9]);
25482 c = FF(c, d, a, b, M_offset_10, 17, T[10]);
25483 b = FF(b, c, d, a, M_offset_11, 22, T[11]);
25484 a = FF(a, b, c, d, M_offset_12, 7, T[12]);
25485 d = FF(d, a, b, c, M_offset_13, 12, T[13]);
25486 c = FF(c, d, a, b, M_offset_14, 17, T[14]);
25487 b = FF(b, c, d, a, M_offset_15, 22, T[15]);
25488
25489 a = GG(a, b, c, d, M_offset_1, 5, T[16]);
25490 d = GG(d, a, b, c, M_offset_6, 9, T[17]);
25491 c = GG(c, d, a, b, M_offset_11, 14, T[18]);
25492 b = GG(b, c, d, a, M_offset_0, 20, T[19]);
25493 a = GG(a, b, c, d, M_offset_5, 5, T[20]);
25494 d = GG(d, a, b, c, M_offset_10, 9, T[21]);
25495 c = GG(c, d, a, b, M_offset_15, 14, T[22]);
25496 b = GG(b, c, d, a, M_offset_4, 20, T[23]);
25497 a = GG(a, b, c, d, M_offset_9, 5, T[24]);
25498 d = GG(d, a, b, c, M_offset_14, 9, T[25]);
25499 c = GG(c, d, a, b, M_offset_3, 14, T[26]);
25500 b = GG(b, c, d, a, M_offset_8, 20, T[27]);
25501 a = GG(a, b, c, d, M_offset_13, 5, T[28]);
25502 d = GG(d, a, b, c, M_offset_2, 9, T[29]);
25503 c = GG(c, d, a, b, M_offset_7, 14, T[30]);
25504 b = GG(b, c, d, a, M_offset_12, 20, T[31]);
25505
25506 a = HH(a, b, c, d, M_offset_5, 4, T[32]);
25507 d = HH(d, a, b, c, M_offset_8, 11, T[33]);
25508 c = HH(c, d, a, b, M_offset_11, 16, T[34]);
25509 b = HH(b, c, d, a, M_offset_14, 23, T[35]);
25510 a = HH(a, b, c, d, M_offset_1, 4, T[36]);
25511 d = HH(d, a, b, c, M_offset_4, 11, T[37]);
25512 c = HH(c, d, a, b, M_offset_7, 16, T[38]);
25513 b = HH(b, c, d, a, M_offset_10, 23, T[39]);
25514 a = HH(a, b, c, d, M_offset_13, 4, T[40]);
25515 d = HH(d, a, b, c, M_offset_0, 11, T[41]);
25516 c = HH(c, d, a, b, M_offset_3, 16, T[42]);
25517 b = HH(b, c, d, a, M_offset_6, 23, T[43]);
25518 a = HH(a, b, c, d, M_offset_9, 4, T[44]);
25519 d = HH(d, a, b, c, M_offset_12, 11, T[45]);
25520 c = HH(c, d, a, b, M_offset_15, 16, T[46]);
25521 b = HH(b, c, d, a, M_offset_2, 23, T[47]);
25522
25523 a = II(a, b, c, d, M_offset_0, 6, T[48]);
25524 d = II(d, a, b, c, M_offset_7, 10, T[49]);
25525 c = II(c, d, a, b, M_offset_14, 15, T[50]);
25526 b = II(b, c, d, a, M_offset_5, 21, T[51]);
25527 a = II(a, b, c, d, M_offset_12, 6, T[52]);
25528 d = II(d, a, b, c, M_offset_3, 10, T[53]);
25529 c = II(c, d, a, b, M_offset_10, 15, T[54]);
25530 b = II(b, c, d, a, M_offset_1, 21, T[55]);
25531 a = II(a, b, c, d, M_offset_8, 6, T[56]);
25532 d = II(d, a, b, c, M_offset_15, 10, T[57]);
25533 c = II(c, d, a, b, M_offset_6, 15, T[58]);
25534 b = II(b, c, d, a, M_offset_13, 21, T[59]);
25535 a = II(a, b, c, d, M_offset_4, 6, T[60]);
25536 d = II(d, a, b, c, M_offset_11, 10, T[61]);
25537 c = II(c, d, a, b, M_offset_2, 15, T[62]);
25538 b = II(b, c, d, a, M_offset_9, 21, T[63]);
25539
25540 // Intermediate hash value
25541 H[0] = (H[0] + a) | 0;
25542 H[1] = (H[1] + b) | 0;
25543 H[2] = (H[2] + c) | 0;
25544 H[3] = (H[3] + d) | 0;
25545 },
25546
25547 _doFinalize: function () {
25548 // Shortcuts
25549 var data = this._data;
25550 var dataWords = data.words;
25551
25552 var nBitsTotal = this._nDataBytes * 8;
25553 var nBitsLeft = data.sigBytes * 8;
25554
25555 // Add padding
25556 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
25557
25558 var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
25559 var nBitsTotalL = nBitsTotal;
25560 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
25561 (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
25562 (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
25563 );
25564 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
25565 (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
25566 (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
25567 );
25568
25569 data.sigBytes = (dataWords.length + 1) * 4;
25570
25571 // Hash final blocks
25572 this._process();
25573
25574 // Shortcuts
25575 var hash = this._hash;
25576 var H = hash.words;
25577
25578 // Swap endian
25579 for (var i = 0; i < 4; i++) {
25580 // Shortcut
25581 var H_i = H[i];
25582
25583 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
25584 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
25585 }
25586
25587 // Return final computed hash
25588 return hash;
25589 },
25590
25591 clone: function () {
25592 var clone = Hasher.clone.call(this);
25593 clone._hash = this._hash.clone();
25594
25595 return clone;
25596 }
25597 });
25598
25599 function FF(a, b, c, d, x, s, t) {
25600 var n = a + ((b & c) | (~b & d)) + x + t;
25601 return ((n << s) | (n >>> (32 - s))) + b;
25602 }
25603
25604 function GG(a, b, c, d, x, s, t) {
25605 var n = a + ((b & d) | (c & ~d)) + x + t;
25606 return ((n << s) | (n >>> (32 - s))) + b;
25607 }
25608
25609 function HH(a, b, c, d, x, s, t) {
25610 var n = a + (b ^ c ^ d) + x + t;
25611 return ((n << s) | (n >>> (32 - s))) + b;
25612 }
25613
25614 function II(a, b, c, d, x, s, t) {
25615 var n = a + (c ^ (b | ~d)) + x + t;
25616 return ((n << s) | (n >>> (32 - s))) + b;
25617 }
25618
25619 /**
25620 * Shortcut function to the hasher's object interface.
25621 *
25622 * @param {WordArray|string} message The message to hash.
25623 *
25624 * @return {WordArray} The hash.
25625 *
25626 * @static
25627 *
25628 * @example
25629 *
25630 * var hash = CryptoJS.MD5('message');
25631 * var hash = CryptoJS.MD5(wordArray);
25632 */
25633 C.MD5 = Hasher._createHelper(MD5);
25634
25635 /**
25636 * Shortcut function to the HMAC's object interface.
25637 *
25638 * @param {WordArray|string} message The message to hash.
25639 * @param {WordArray|string} key The secret key.
25640 *
25641 * @return {WordArray} The HMAC.
25642 *
25643 * @static
25644 *
25645 * @example
25646 *
25647 * var hmac = CryptoJS.HmacMD5(message, key);
25648 */
25649 C.HmacMD5 = Hasher._createHmacHelper(MD5);
25650 }(Math));
25651
25652
25653 return CryptoJS.MD5;
25654
25655 }));
25656 },{"./core":31}],40:[function(_dereq_,module,exports){
25657 ;(function (root, factory, undef) {
25658 if (typeof exports === "object") {
25659 // CommonJS
25660 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25661 }
25662 else if (typeof define === "function" && define.amd) {
25663 // AMD
25664 define(["./core", "./cipher-core"], factory);
25665 }
25666 else {
25667 // Global (browser)
25668 factory(root.CryptoJS);
25669 }
25670 }(this, function (CryptoJS) {
25671
25672 /**
25673 * Cipher Feedback block mode.
25674 */
25675 CryptoJS.mode.CFB = (function () {
25676 var CFB = CryptoJS.lib.BlockCipherMode.extend();
25677
25678 CFB.Encryptor = CFB.extend({
25679 processBlock: function (words, offset) {
25680 // Shortcuts
25681 var cipher = this._cipher;
25682 var blockSize = cipher.blockSize;
25683
25684 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
25685
25686 // Remember this block to use with next block
25687 this._prevBlock = words.slice(offset, offset + blockSize);
25688 }
25689 });
25690
25691 CFB.Decryptor = CFB.extend({
25692 processBlock: function (words, offset) {
25693 // Shortcuts
25694 var cipher = this._cipher;
25695 var blockSize = cipher.blockSize;
25696
25697 // Remember this block to use with next block
25698 var thisBlock = words.slice(offset, offset + blockSize);
25699
25700 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
25701
25702 // This block becomes the previous block
25703 this._prevBlock = thisBlock;
25704 }
25705 });
25706
25707 function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
25708 // Shortcut
25709 var iv = this._iv;
25710
25711 // Generate keystream
25712 if (iv) {
25713 var keystream = iv.slice(0);
25714
25715 // Remove IV for subsequent blocks
25716 this._iv = undefined;
25717 } else {
25718 var keystream = this._prevBlock;
25719 }
25720 cipher.encryptBlock(keystream, 0);
25721
25722 // Encrypt
25723 for (var i = 0; i < blockSize; i++) {
25724 words[offset + i] ^= keystream[i];
25725 }
25726 }
25727
25728 return CFB;
25729 }());
25730
25731
25732 return CryptoJS.mode.CFB;
25733
25734 }));
25735 },{"./cipher-core":30,"./core":31}],41:[function(_dereq_,module,exports){
25736 ;(function (root, factory, undef) {
25737 if (typeof exports === "object") {
25738 // CommonJS
25739 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25740 }
25741 else if (typeof define === "function" && define.amd) {
25742 // AMD
25743 define(["./core", "./cipher-core"], factory);
25744 }
25745 else {
25746 // Global (browser)
25747 factory(root.CryptoJS);
25748 }
25749 }(this, function (CryptoJS) {
25750
25751 /** @preserve
25752 * Counter block mode compatible with Dr Brian Gladman fileenc.c
25753 * derived from CryptoJS.mode.CTR
25754 * Jan Hruby jhruby.web@gmail.com
25755 */
25756 CryptoJS.mode.CTRGladman = (function () {
25757 var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
25758
25759 function incWord(word)
25760 {
25761 if (((word >> 24) & 0xff) === 0xff) { //overflow
25762 var b1 = (word >> 16)&0xff;
25763 var b2 = (word >> 8)&0xff;
25764 var b3 = word & 0xff;
25765
25766 if (b1 === 0xff) // overflow b1
25767 {
25768 b1 = 0;
25769 if (b2 === 0xff)
25770 {
25771 b2 = 0;
25772 if (b3 === 0xff)
25773 {
25774 b3 = 0;
25775 }
25776 else
25777 {
25778 ++b3;
25779 }
25780 }
25781 else
25782 {
25783 ++b2;
25784 }
25785 }
25786 else
25787 {
25788 ++b1;
25789 }
25790
25791 word = 0;
25792 word += (b1 << 16);
25793 word += (b2 << 8);
25794 word += b3;
25795 }
25796 else
25797 {
25798 word += (0x01 << 24);
25799 }
25800 return word;
25801 }
25802
25803 function incCounter(counter)
25804 {
25805 if ((counter[0] = incWord(counter[0])) === 0)
25806 {
25807 // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
25808 counter[1] = incWord(counter[1]);
25809 }
25810 return counter;
25811 }
25812
25813 var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
25814 processBlock: function (words, offset) {
25815 // Shortcuts
25816 var cipher = this._cipher
25817 var blockSize = cipher.blockSize;
25818 var iv = this._iv;
25819 var counter = this._counter;
25820
25821 // Generate keystream
25822 if (iv) {
25823 counter = this._counter = iv.slice(0);
25824
25825 // Remove IV for subsequent blocks
25826 this._iv = undefined;
25827 }
25828
25829 incCounter(counter);
25830
25831 var keystream = counter.slice(0);
25832 cipher.encryptBlock(keystream, 0);
25833
25834 // Encrypt
25835 for (var i = 0; i < blockSize; i++) {
25836 words[offset + i] ^= keystream[i];
25837 }
25838 }
25839 });
25840
25841 CTRGladman.Decryptor = Encryptor;
25842
25843 return CTRGladman;
25844 }());
25845
25846
25847
25848
25849 return CryptoJS.mode.CTRGladman;
25850
25851 }));
25852 },{"./cipher-core":30,"./core":31}],42:[function(_dereq_,module,exports){
25853 ;(function (root, factory, undef) {
25854 if (typeof exports === "object") {
25855 // CommonJS
25856 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25857 }
25858 else if (typeof define === "function" && define.amd) {
25859 // AMD
25860 define(["./core", "./cipher-core"], factory);
25861 }
25862 else {
25863 // Global (browser)
25864 factory(root.CryptoJS);
25865 }
25866 }(this, function (CryptoJS) {
25867
25868 /**
25869 * Counter block mode.
25870 */
25871 CryptoJS.mode.CTR = (function () {
25872 var CTR = CryptoJS.lib.BlockCipherMode.extend();
25873
25874 var Encryptor = CTR.Encryptor = CTR.extend({
25875 processBlock: function (words, offset) {
25876 // Shortcuts
25877 var cipher = this._cipher
25878 var blockSize = cipher.blockSize;
25879 var iv = this._iv;
25880 var counter = this._counter;
25881
25882 // Generate keystream
25883 if (iv) {
25884 counter = this._counter = iv.slice(0);
25885
25886 // Remove IV for subsequent blocks
25887 this._iv = undefined;
25888 }
25889 var keystream = counter.slice(0);
25890 cipher.encryptBlock(keystream, 0);
25891
25892 // Increment counter
25893 counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
25894
25895 // Encrypt
25896 for (var i = 0; i < blockSize; i++) {
25897 words[offset + i] ^= keystream[i];
25898 }
25899 }
25900 });
25901
25902 CTR.Decryptor = Encryptor;
25903
25904 return CTR;
25905 }());
25906
25907
25908 return CryptoJS.mode.CTR;
25909
25910 }));
25911 },{"./cipher-core":30,"./core":31}],43:[function(_dereq_,module,exports){
25912 ;(function (root, factory, undef) {
25913 if (typeof exports === "object") {
25914 // CommonJS
25915 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25916 }
25917 else if (typeof define === "function" && define.amd) {
25918 // AMD
25919 define(["./core", "./cipher-core"], factory);
25920 }
25921 else {
25922 // Global (browser)
25923 factory(root.CryptoJS);
25924 }
25925 }(this, function (CryptoJS) {
25926
25927 /**
25928 * Electronic Codebook block mode.
25929 */
25930 CryptoJS.mode.ECB = (function () {
25931 var ECB = CryptoJS.lib.BlockCipherMode.extend();
25932
25933 ECB.Encryptor = ECB.extend({
25934 processBlock: function (words, offset) {
25935 this._cipher.encryptBlock(words, offset);
25936 }
25937 });
25938
25939 ECB.Decryptor = ECB.extend({
25940 processBlock: function (words, offset) {
25941 this._cipher.decryptBlock(words, offset);
25942 }
25943 });
25944
25945 return ECB;
25946 }());
25947
25948
25949 return CryptoJS.mode.ECB;
25950
25951 }));
25952 },{"./cipher-core":30,"./core":31}],44:[function(_dereq_,module,exports){
25953 ;(function (root, factory, undef) {
25954 if (typeof exports === "object") {
25955 // CommonJS
25956 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25957 }
25958 else if (typeof define === "function" && define.amd) {
25959 // AMD
25960 define(["./core", "./cipher-core"], factory);
25961 }
25962 else {
25963 // Global (browser)
25964 factory(root.CryptoJS);
25965 }
25966 }(this, function (CryptoJS) {
25967
25968 /**
25969 * Output Feedback block mode.
25970 */
25971 CryptoJS.mode.OFB = (function () {
25972 var OFB = CryptoJS.lib.BlockCipherMode.extend();
25973
25974 var Encryptor = OFB.Encryptor = OFB.extend({
25975 processBlock: function (words, offset) {
25976 // Shortcuts
25977 var cipher = this._cipher
25978 var blockSize = cipher.blockSize;
25979 var iv = this._iv;
25980 var keystream = this._keystream;
25981
25982 // Generate keystream
25983 if (iv) {
25984 keystream = this._keystream = iv.slice(0);
25985
25986 // Remove IV for subsequent blocks
25987 this._iv = undefined;
25988 }
25989 cipher.encryptBlock(keystream, 0);
25990
25991 // Encrypt
25992 for (var i = 0; i < blockSize; i++) {
25993 words[offset + i] ^= keystream[i];
25994 }
25995 }
25996 });
25997
25998 OFB.Decryptor = Encryptor;
25999
26000 return OFB;
26001 }());
26002
26003
26004 return CryptoJS.mode.OFB;
26005
26006 }));
26007 },{"./cipher-core":30,"./core":31}],45:[function(_dereq_,module,exports){
26008 ;(function (root, factory, undef) {
26009 if (typeof exports === "object") {
26010 // CommonJS
26011 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26012 }
26013 else if (typeof define === "function" && define.amd) {
26014 // AMD
26015 define(["./core", "./cipher-core"], factory);
26016 }
26017 else {
26018 // Global (browser)
26019 factory(root.CryptoJS);
26020 }
26021 }(this, function (CryptoJS) {
26022
26023 /**
26024 * ANSI X.923 padding strategy.
26025 */
26026 CryptoJS.pad.AnsiX923 = {
26027 pad: function (data, blockSize) {
26028 // Shortcuts
26029 var dataSigBytes = data.sigBytes;
26030 var blockSizeBytes = blockSize * 4;
26031
26032 // Count padding bytes
26033 var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
26034
26035 // Compute last byte position
26036 var lastBytePos = dataSigBytes + nPaddingBytes - 1;
26037
26038 // Pad
26039 data.clamp();
26040 data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
26041 data.sigBytes += nPaddingBytes;
26042 },
26043
26044 unpad: function (data) {
26045 // Get number of padding bytes from last byte
26046 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
26047
26048 // Remove padding
26049 data.sigBytes -= nPaddingBytes;
26050 }
26051 };
26052
26053
26054 return CryptoJS.pad.Ansix923;
26055
26056 }));
26057 },{"./cipher-core":30,"./core":31}],46:[function(_dereq_,module,exports){
26058 ;(function (root, factory, undef) {
26059 if (typeof exports === "object") {
26060 // CommonJS
26061 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26062 }
26063 else if (typeof define === "function" && define.amd) {
26064 // AMD
26065 define(["./core", "./cipher-core"], factory);
26066 }
26067 else {
26068 // Global (browser)
26069 factory(root.CryptoJS);
26070 }
26071 }(this, function (CryptoJS) {
26072
26073 /**
26074 * ISO 10126 padding strategy.
26075 */
26076 CryptoJS.pad.Iso10126 = {
26077 pad: function (data, blockSize) {
26078 // Shortcut
26079 var blockSizeBytes = blockSize * 4;
26080
26081 // Count padding bytes
26082 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
26083
26084 // Pad
26085 data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
26086 concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
26087 },
26088
26089 unpad: function (data) {
26090 // Get number of padding bytes from last byte
26091 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
26092
26093 // Remove padding
26094 data.sigBytes -= nPaddingBytes;
26095 }
26096 };
26097
26098
26099 return CryptoJS.pad.Iso10126;
26100
26101 }));
26102 },{"./cipher-core":30,"./core":31}],47:[function(_dereq_,module,exports){
26103 ;(function (root, factory, undef) {
26104 if (typeof exports === "object") {
26105 // CommonJS
26106 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26107 }
26108 else if (typeof define === "function" && define.amd) {
26109 // AMD
26110 define(["./core", "./cipher-core"], factory);
26111 }
26112 else {
26113 // Global (browser)
26114 factory(root.CryptoJS);
26115 }
26116 }(this, function (CryptoJS) {
26117
26118 /**
26119 * ISO/IEC 9797-1 Padding Method 2.
26120 */
26121 CryptoJS.pad.Iso97971 = {
26122 pad: function (data, blockSize) {
26123 // Add 0x80 byte
26124 data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
26125
26126 // Zero pad the rest
26127 CryptoJS.pad.ZeroPadding.pad(data, blockSize);
26128 },
26129
26130 unpad: function (data) {
26131 // Remove zero padding
26132 CryptoJS.pad.ZeroPadding.unpad(data);
26133
26134 // Remove one more byte -- the 0x80 byte
26135 data.sigBytes--;
26136 }
26137 };
26138
26139
26140 return CryptoJS.pad.Iso97971;
26141
26142 }));
26143 },{"./cipher-core":30,"./core":31}],48:[function(_dereq_,module,exports){
26144 ;(function (root, factory, undef) {
26145 if (typeof exports === "object") {
26146 // CommonJS
26147 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26148 }
26149 else if (typeof define === "function" && define.amd) {
26150 // AMD
26151 define(["./core", "./cipher-core"], factory);
26152 }
26153 else {
26154 // Global (browser)
26155 factory(root.CryptoJS);
26156 }
26157 }(this, function (CryptoJS) {
26158
26159 /**
26160 * A noop padding strategy.
26161 */
26162 CryptoJS.pad.NoPadding = {
26163 pad: function () {
26164 },
26165
26166 unpad: function () {
26167 }
26168 };
26169
26170
26171 return CryptoJS.pad.NoPadding;
26172
26173 }));
26174 },{"./cipher-core":30,"./core":31}],49:[function(_dereq_,module,exports){
26175 ;(function (root, factory, undef) {
26176 if (typeof exports === "object") {
26177 // CommonJS
26178 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26179 }
26180 else if (typeof define === "function" && define.amd) {
26181 // AMD
26182 define(["./core", "./cipher-core"], factory);
26183 }
26184 else {
26185 // Global (browser)
26186 factory(root.CryptoJS);
26187 }
26188 }(this, function (CryptoJS) {
26189
26190 /**
26191 * Zero padding strategy.
26192 */
26193 CryptoJS.pad.ZeroPadding = {
26194 pad: function (data, blockSize) {
26195 // Shortcut
26196 var blockSizeBytes = blockSize * 4;
26197
26198 // Pad
26199 data.clamp();
26200 data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
26201 },
26202
26203 unpad: function (data) {
26204 // Shortcut
26205 var dataWords = data.words;
26206
26207 // Unpad
26208 var i = data.sigBytes - 1;
26209 while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
26210 i--;
26211 }
26212 data.sigBytes = i + 1;
26213 }
26214 };
26215
26216
26217 return CryptoJS.pad.ZeroPadding;
26218
26219 }));
26220 },{"./cipher-core":30,"./core":31}],50:[function(_dereq_,module,exports){
26221 ;(function (root, factory, undef) {
26222 if (typeof exports === "object") {
26223 // CommonJS
26224 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
26225 }
26226 else if (typeof define === "function" && define.amd) {
26227 // AMD
26228 define(["./core", "./sha1", "./hmac"], factory);
26229 }
26230 else {
26231 // Global (browser)
26232 factory(root.CryptoJS);
26233 }
26234 }(this, function (CryptoJS) {
26235
26236 (function () {
26237 // Shortcuts
26238 var C = CryptoJS;
26239 var C_lib = C.lib;
26240 var Base = C_lib.Base;
26241 var WordArray = C_lib.WordArray;
26242 var C_algo = C.algo;
26243 var SHA1 = C_algo.SHA1;
26244 var HMAC = C_algo.HMAC;
26245
26246 /**
26247 * Password-Based Key Derivation Function 2 algorithm.
26248 */
26249 var PBKDF2 = C_algo.PBKDF2 = Base.extend({
26250 /**
26251 * Configuration options.
26252 *
26253 * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
26254 * @property {Hasher} hasher The hasher to use. Default: SHA1
26255 * @property {number} iterations The number of iterations to perform. Default: 1
26256 */
26257 cfg: Base.extend({
26258 keySize: 128/32,
26259 hasher: SHA1,
26260 iterations: 1
26261 }),
26262
26263 /**
26264 * Initializes a newly created key derivation function.
26265 *
26266 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
26267 *
26268 * @example
26269 *
26270 * var kdf = CryptoJS.algo.PBKDF2.create();
26271 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
26272 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
26273 */
26274 init: function (cfg) {
26275 this.cfg = this.cfg.extend(cfg);
26276 },
26277
26278 /**
26279 * Computes the Password-Based Key Derivation Function 2.
26280 *
26281 * @param {WordArray|string} password The password.
26282 * @param {WordArray|string} salt A salt.
26283 *
26284 * @return {WordArray} The derived key.
26285 *
26286 * @example
26287 *
26288 * var key = kdf.compute(password, salt);
26289 */
26290 compute: function (password, salt) {
26291 // Shortcut
26292 var cfg = this.cfg;
26293
26294 // Init HMAC
26295 var hmac = HMAC.create(cfg.hasher, password);
26296
26297 // Initial values
26298 var derivedKey = WordArray.create();
26299 var blockIndex = WordArray.create([0x00000001]);
26300
26301 // Shortcuts
26302 var derivedKeyWords = derivedKey.words;
26303 var blockIndexWords = blockIndex.words;
26304 var keySize = cfg.keySize;
26305 var iterations = cfg.iterations;
26306
26307 // Generate key
26308 while (derivedKeyWords.length < keySize) {
26309 var block = hmac.update(salt).finalize(blockIndex);
26310 hmac.reset();
26311
26312 // Shortcuts
26313 var blockWords = block.words;
26314 var blockWordsLength = blockWords.length;
26315
26316 // Iterations
26317 var intermediate = block;
26318 for (var i = 1; i < iterations; i++) {
26319 intermediate = hmac.finalize(intermediate);
26320 hmac.reset();
26321
26322 // Shortcut
26323 var intermediateWords = intermediate.words;
26324
26325 // XOR intermediate with block
26326 for (var j = 0; j < blockWordsLength; j++) {
26327 blockWords[j] ^= intermediateWords[j];
26328 }
26329 }
26330
26331 derivedKey.concat(block);
26332 blockIndexWords[0]++;
26333 }
26334 derivedKey.sigBytes = keySize * 4;
26335
26336 return derivedKey;
26337 }
26338 });
26339
26340 /**
26341 * Computes the Password-Based Key Derivation Function 2.
26342 *
26343 * @param {WordArray|string} password The password.
26344 * @param {WordArray|string} salt A salt.
26345 * @param {Object} cfg (Optional) The configuration options to use for this computation.
26346 *
26347 * @return {WordArray} The derived key.
26348 *
26349 * @static
26350 *
26351 * @example
26352 *
26353 * var key = CryptoJS.PBKDF2(password, salt);
26354 * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
26355 * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
26356 */
26357 C.PBKDF2 = function (password, salt, cfg) {
26358 return PBKDF2.create(cfg).compute(password, salt);
26359 };
26360 }());
26361
26362
26363 return CryptoJS.PBKDF2;
26364
26365 }));
26366 },{"./core":31,"./hmac":36,"./sha1":55}],51:[function(_dereq_,module,exports){
26367 ;(function (root, factory, undef) {
26368 if (typeof exports === "object") {
26369 // CommonJS
26370 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26371 }
26372 else if (typeof define === "function" && define.amd) {
26373 // AMD
26374 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26375 }
26376 else {
26377 // Global (browser)
26378 factory(root.CryptoJS);
26379 }
26380 }(this, function (CryptoJS) {
26381
26382 (function () {
26383 // Shortcuts
26384 var C = CryptoJS;
26385 var C_lib = C.lib;
26386 var StreamCipher = C_lib.StreamCipher;
26387 var C_algo = C.algo;
26388
26389 // Reusable objects
26390 var S = [];
26391 var C_ = [];
26392 var G = [];
26393
26394 /**
26395 * Rabbit stream cipher algorithm.
26396 *
26397 * This is a legacy version that neglected to convert the key to little-endian.
26398 * This error doesn't affect the cipher's security,
26399 * but it does affect its compatibility with other implementations.
26400 */
26401 var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
26402 _doReset: function () {
26403 // Shortcuts
26404 var K = this._key.words;
26405 var iv = this.cfg.iv;
26406
26407 // Generate initial state values
26408 var X = this._X = [
26409 K[0], (K[3] << 16) | (K[2] >>> 16),
26410 K[1], (K[0] << 16) | (K[3] >>> 16),
26411 K[2], (K[1] << 16) | (K[0] >>> 16),
26412 K[3], (K[2] << 16) | (K[1] >>> 16)
26413 ];
26414
26415 // Generate initial counter values
26416 var C = this._C = [
26417 (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
26418 (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
26419 (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
26420 (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
26421 ];
26422
26423 // Carry bit
26424 this._b = 0;
26425
26426 // Iterate the system four times
26427 for (var i = 0; i < 4; i++) {
26428 nextState.call(this);
26429 }
26430
26431 // Modify the counters
26432 for (var i = 0; i < 8; i++) {
26433 C[i] ^= X[(i + 4) & 7];
26434 }
26435
26436 // IV setup
26437 if (iv) {
26438 // Shortcuts
26439 var IV = iv.words;
26440 var IV_0 = IV[0];
26441 var IV_1 = IV[1];
26442
26443 // Generate four subvectors
26444 var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
26445 var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
26446 var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
26447 var i3 = (i2 << 16) | (i0 & 0x0000ffff);
26448
26449 // Modify counter values
26450 C[0] ^= i0;
26451 C[1] ^= i1;
26452 C[2] ^= i2;
26453 C[3] ^= i3;
26454 C[4] ^= i0;
26455 C[5] ^= i1;
26456 C[6] ^= i2;
26457 C[7] ^= i3;
26458
26459 // Iterate the system four times
26460 for (var i = 0; i < 4; i++) {
26461 nextState.call(this);
26462 }
26463 }
26464 },
26465
26466 _doProcessBlock: function (M, offset) {
26467 // Shortcut
26468 var X = this._X;
26469
26470 // Iterate the system
26471 nextState.call(this);
26472
26473 // Generate four keystream words
26474 S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
26475 S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
26476 S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
26477 S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
26478
26479 for (var i = 0; i < 4; i++) {
26480 // Swap endian
26481 S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
26482 (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
26483
26484 // Encrypt
26485 M[offset + i] ^= S[i];
26486 }
26487 },
26488
26489 blockSize: 128/32,
26490
26491 ivSize: 64/32
26492 });
26493
26494 function nextState() {
26495 // Shortcuts
26496 var X = this._X;
26497 var C = this._C;
26498
26499 // Save old counter values
26500 for (var i = 0; i < 8; i++) {
26501 C_[i] = C[i];
26502 }
26503
26504 // Calculate new counter values
26505 C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
26506 C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
26507 C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
26508 C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
26509 C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
26510 C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
26511 C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
26512 C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
26513 this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
26514
26515 // Calculate the g-values
26516 for (var i = 0; i < 8; i++) {
26517 var gx = X[i] + C[i];
26518
26519 // Construct high and low argument for squaring
26520 var ga = gx & 0xffff;
26521 var gb = gx >>> 16;
26522
26523 // Calculate high and low result of squaring
26524 var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
26525 var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
26526
26527 // High XOR low
26528 G[i] = gh ^ gl;
26529 }
26530
26531 // Calculate new state values
26532 X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
26533 X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
26534 X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
26535 X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
26536 X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
26537 X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
26538 X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
26539 X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
26540 }
26541
26542 /**
26543 * Shortcut functions to the cipher's object interface.
26544 *
26545 * @example
26546 *
26547 * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
26548 * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
26549 */
26550 C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
26551 }());
26552
26553
26554 return CryptoJS.RabbitLegacy;
26555
26556 }));
26557 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],52:[function(_dereq_,module,exports){
26558 ;(function (root, factory, undef) {
26559 if (typeof exports === "object") {
26560 // CommonJS
26561 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26562 }
26563 else if (typeof define === "function" && define.amd) {
26564 // AMD
26565 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26566 }
26567 else {
26568 // Global (browser)
26569 factory(root.CryptoJS);
26570 }
26571 }(this, function (CryptoJS) {
26572
26573 (function () {
26574 // Shortcuts
26575 var C = CryptoJS;
26576 var C_lib = C.lib;
26577 var StreamCipher = C_lib.StreamCipher;
26578 var C_algo = C.algo;
26579
26580 // Reusable objects
26581 var S = [];
26582 var C_ = [];
26583 var G = [];
26584
26585 /**
26586 * Rabbit stream cipher algorithm
26587 */
26588 var Rabbit = C_algo.Rabbit = StreamCipher.extend({
26589 _doReset: function () {
26590 // Shortcuts
26591 var K = this._key.words;
26592 var iv = this.cfg.iv;
26593
26594 // Swap endian
26595 for (var i = 0; i < 4; i++) {
26596 K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) |
26597 (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00);
26598 }
26599
26600 // Generate initial state values
26601 var X = this._X = [
26602 K[0], (K[3] << 16) | (K[2] >>> 16),
26603 K[1], (K[0] << 16) | (K[3] >>> 16),
26604 K[2], (K[1] << 16) | (K[0] >>> 16),
26605 K[3], (K[2] << 16) | (K[1] >>> 16)
26606 ];
26607
26608 // Generate initial counter values
26609 var C = this._C = [
26610 (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
26611 (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
26612 (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
26613 (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
26614 ];
26615
26616 // Carry bit
26617 this._b = 0;
26618
26619 // Iterate the system four times
26620 for (var i = 0; i < 4; i++) {
26621 nextState.call(this);
26622 }
26623
26624 // Modify the counters
26625 for (var i = 0; i < 8; i++) {
26626 C[i] ^= X[(i + 4) & 7];
26627 }
26628
26629 // IV setup
26630 if (iv) {
26631 // Shortcuts
26632 var IV = iv.words;
26633 var IV_0 = IV[0];
26634 var IV_1 = IV[1];
26635
26636 // Generate four subvectors
26637 var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
26638 var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
26639 var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
26640 var i3 = (i2 << 16) | (i0 & 0x0000ffff);
26641
26642 // Modify counter values
26643 C[0] ^= i0;
26644 C[1] ^= i1;
26645 C[2] ^= i2;
26646 C[3] ^= i3;
26647 C[4] ^= i0;
26648 C[5] ^= i1;
26649 C[6] ^= i2;
26650 C[7] ^= i3;
26651
26652 // Iterate the system four times
26653 for (var i = 0; i < 4; i++) {
26654 nextState.call(this);
26655 }
26656 }
26657 },
26658
26659 _doProcessBlock: function (M, offset) {
26660 // Shortcut
26661 var X = this._X;
26662
26663 // Iterate the system
26664 nextState.call(this);
26665
26666 // Generate four keystream words
26667 S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
26668 S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
26669 S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
26670 S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
26671
26672 for (var i = 0; i < 4; i++) {
26673 // Swap endian
26674 S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
26675 (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
26676
26677 // Encrypt
26678 M[offset + i] ^= S[i];
26679 }
26680 },
26681
26682 blockSize: 128/32,
26683
26684 ivSize: 64/32
26685 });
26686
26687 function nextState() {
26688 // Shortcuts
26689 var X = this._X;
26690 var C = this._C;
26691
26692 // Save old counter values
26693 for (var i = 0; i < 8; i++) {
26694 C_[i] = C[i];
26695 }
26696
26697 // Calculate new counter values
26698 C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
26699 C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
26700 C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
26701 C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
26702 C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
26703 C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
26704 C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
26705 C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
26706 this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
26707
26708 // Calculate the g-values
26709 for (var i = 0; i < 8; i++) {
26710 var gx = X[i] + C[i];
26711
26712 // Construct high and low argument for squaring
26713 var ga = gx & 0xffff;
26714 var gb = gx >>> 16;
26715
26716 // Calculate high and low result of squaring
26717 var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
26718 var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
26719
26720 // High XOR low
26721 G[i] = gh ^ gl;
26722 }
26723
26724 // Calculate new state values
26725 X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
26726 X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
26727 X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
26728 X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
26729 X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
26730 X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
26731 X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
26732 X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
26733 }
26734
26735 /**
26736 * Shortcut functions to the cipher's object interface.
26737 *
26738 * @example
26739 *
26740 * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
26741 * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
26742 */
26743 C.Rabbit = StreamCipher._createHelper(Rabbit);
26744 }());
26745
26746
26747 return CryptoJS.Rabbit;
26748
26749 }));
26750 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],53:[function(_dereq_,module,exports){
26751 ;(function (root, factory, undef) {
26752 if (typeof exports === "object") {
26753 // CommonJS
26754 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26755 }
26756 else if (typeof define === "function" && define.amd) {
26757 // AMD
26758 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26759 }
26760 else {
26761 // Global (browser)
26762 factory(root.CryptoJS);
26763 }
26764 }(this, function (CryptoJS) {
26765
26766 (function () {
26767 // Shortcuts
26768 var C = CryptoJS;
26769 var C_lib = C.lib;
26770 var StreamCipher = C_lib.StreamCipher;
26771 var C_algo = C.algo;
26772
26773 /**
26774 * RC4 stream cipher algorithm.
26775 */
26776 var RC4 = C_algo.RC4 = StreamCipher.extend({
26777 _doReset: function () {
26778 // Shortcuts
26779 var key = this._key;
26780 var keyWords = key.words;
26781 var keySigBytes = key.sigBytes;
26782
26783 // Init sbox
26784 var S = this._S = [];
26785 for (var i = 0; i < 256; i++) {
26786 S[i] = i;
26787 }
26788
26789 // Key setup
26790 for (var i = 0, j = 0; i < 256; i++) {
26791 var keyByteIndex = i % keySigBytes;
26792 var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
26793
26794 j = (j + S[i] + keyByte) % 256;
26795
26796 // Swap
26797 var t = S[i];
26798 S[i] = S[j];
26799 S[j] = t;
26800 }
26801
26802 // Counters
26803 this._i = this._j = 0;
26804 },
26805
26806 _doProcessBlock: function (M, offset) {
26807 M[offset] ^= generateKeystreamWord.call(this);
26808 },
26809
26810 keySize: 256/32,
26811
26812 ivSize: 0
26813 });
26814
26815 function generateKeystreamWord() {
26816 // Shortcuts
26817 var S = this._S;
26818 var i = this._i;
26819 var j = this._j;
26820
26821 // Generate keystream word
26822 var keystreamWord = 0;
26823 for (var n = 0; n < 4; n++) {
26824 i = (i + 1) % 256;
26825 j = (j + S[i]) % 256;
26826
26827 // Swap
26828 var t = S[i];
26829 S[i] = S[j];
26830 S[j] = t;
26831
26832 keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
26833 }
26834
26835 // Update counters
26836 this._i = i;
26837 this._j = j;
26838
26839 return keystreamWord;
26840 }
26841
26842 /**
26843 * Shortcut functions to the cipher's object interface.
26844 *
26845 * @example
26846 *
26847 * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
26848 * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
26849 */
26850 C.RC4 = StreamCipher._createHelper(RC4);
26851
26852 /**
26853 * Modified RC4 stream cipher algorithm.
26854 */
26855 var RC4Drop = C_algo.RC4Drop = RC4.extend({
26856 /**
26857 * Configuration options.
26858 *
26859 * @property {number} drop The number of keystream words to drop. Default 192
26860 */
26861 cfg: RC4.cfg.extend({
26862 drop: 192
26863 }),
26864
26865 _doReset: function () {
26866 RC4._doReset.call(this);
26867
26868 // Drop
26869 for (var i = this.cfg.drop; i > 0; i--) {
26870 generateKeystreamWord.call(this);
26871 }
26872 }
26873 });
26874
26875 /**
26876 * Shortcut functions to the cipher's object interface.
26877 *
26878 * @example
26879 *
26880 * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
26881 * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
26882 */
26883 C.RC4Drop = StreamCipher._createHelper(RC4Drop);
26884 }());
26885
26886
26887 return CryptoJS.RC4;
26888
26889 }));
26890 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],54:[function(_dereq_,module,exports){
26891 ;(function (root, factory) {
26892 if (typeof exports === "object") {
26893 // CommonJS
26894 module.exports = exports = factory(_dereq_("./core"));
26895 }
26896 else if (typeof define === "function" && define.amd) {
26897 // AMD
26898 define(["./core"], factory);
26899 }
26900 else {
26901 // Global (browser)
26902 factory(root.CryptoJS);
26903 }
26904 }(this, function (CryptoJS) {
26905
26906 /** @preserve
26907 (c) 2012 by Cédric Mesnil. All rights reserved.
26908
26909 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
26910
26911 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
26912 - 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.
26913
26914 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.
26915 */
26916
26917 (function (Math) {
26918 // Shortcuts
26919 var C = CryptoJS;
26920 var C_lib = C.lib;
26921 var WordArray = C_lib.WordArray;
26922 var Hasher = C_lib.Hasher;
26923 var C_algo = C.algo;
26924
26925 // Constants table
26926 var _zl = WordArray.create([
26927 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
26928 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
26929 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
26930 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
26931 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]);
26932 var _zr = WordArray.create([
26933 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
26934 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
26935 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
26936 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
26937 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]);
26938 var _sl = WordArray.create([
26939 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
26940 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
26941 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
26942 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
26943 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]);
26944 var _sr = WordArray.create([
26945 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
26946 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
26947 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
26948 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
26949 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]);
26950
26951 var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
26952 var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
26953
26954 /**
26955 * RIPEMD160 hash algorithm.
26956 */
26957 var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
26958 _doReset: function () {
26959 this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
26960 },
26961
26962 _doProcessBlock: function (M, offset) {
26963
26964 // Swap endian
26965 for (var i = 0; i < 16; i++) {
26966 // Shortcuts
26967 var offset_i = offset + i;
26968 var M_offset_i = M[offset_i];
26969
26970 // Swap
26971 M[offset_i] = (
26972 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
26973 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
26974 );
26975 }
26976 // Shortcut
26977 var H = this._hash.words;
26978 var hl = _hl.words;
26979 var hr = _hr.words;
26980 var zl = _zl.words;
26981 var zr = _zr.words;
26982 var sl = _sl.words;
26983 var sr = _sr.words;
26984
26985 // Working variables
26986 var al, bl, cl, dl, el;
26987 var ar, br, cr, dr, er;
26988
26989 ar = al = H[0];
26990 br = bl = H[1];
26991 cr = cl = H[2];
26992 dr = dl = H[3];
26993 er = el = H[4];
26994 // Computation
26995 var t;
26996 for (var i = 0; i < 80; i += 1) {
26997 t = (al + M[offset+zl[i]])|0;
26998 if (i<16){
26999 t += f1(bl,cl,dl) + hl[0];
27000 } else if (i<32) {
27001 t += f2(bl,cl,dl) + hl[1];
27002 } else if (i<48) {
27003 t += f3(bl,cl,dl) + hl[2];
27004 } else if (i<64) {
27005 t += f4(bl,cl,dl) + hl[3];
27006 } else {// if (i<80) {
27007 t += f5(bl,cl,dl) + hl[4];
27008 }
27009 t = t|0;
27010 t = rotl(t,sl[i]);
27011 t = (t+el)|0;
27012 al = el;
27013 el = dl;
27014 dl = rotl(cl, 10);
27015 cl = bl;
27016 bl = t;
27017
27018 t = (ar + M[offset+zr[i]])|0;
27019 if (i<16){
27020 t += f5(br,cr,dr) + hr[0];
27021 } else if (i<32) {
27022 t += f4(br,cr,dr) + hr[1];
27023 } else if (i<48) {
27024 t += f3(br,cr,dr) + hr[2];
27025 } else if (i<64) {
27026 t += f2(br,cr,dr) + hr[3];
27027 } else {// if (i<80) {
27028 t += f1(br,cr,dr) + hr[4];
27029 }
27030 t = t|0;
27031 t = rotl(t,sr[i]) ;
27032 t = (t+er)|0;
27033 ar = er;
27034 er = dr;
27035 dr = rotl(cr, 10);
27036 cr = br;
27037 br = t;
27038 }
27039 // Intermediate hash value
27040 t = (H[1] + cl + dr)|0;
27041 H[1] = (H[2] + dl + er)|0;
27042 H[2] = (H[3] + el + ar)|0;
27043 H[3] = (H[4] + al + br)|0;
27044 H[4] = (H[0] + bl + cr)|0;
27045 H[0] = t;
27046 },
27047
27048 _doFinalize: function () {
27049 // Shortcuts
27050 var data = this._data;
27051 var dataWords = data.words;
27052
27053 var nBitsTotal = this._nDataBytes * 8;
27054 var nBitsLeft = data.sigBytes * 8;
27055
27056 // Add padding
27057 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27058 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
27059 (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
27060 (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
27061 );
27062 data.sigBytes = (dataWords.length + 1) * 4;
27063
27064 // Hash final blocks
27065 this._process();
27066
27067 // Shortcuts
27068 var hash = this._hash;
27069 var H = hash.words;
27070
27071 // Swap endian
27072 for (var i = 0; i < 5; i++) {
27073 // Shortcut
27074 var H_i = H[i];
27075
27076 // Swap
27077 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
27078 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
27079 }
27080
27081 // Return final computed hash
27082 return hash;
27083 },
27084
27085 clone: function () {
27086 var clone = Hasher.clone.call(this);
27087 clone._hash = this._hash.clone();
27088
27089 return clone;
27090 }
27091 });
27092
27093
27094 function f1(x, y, z) {
27095 return ((x) ^ (y) ^ (z));
27096
27097 }
27098
27099 function f2(x, y, z) {
27100 return (((x)&(y)) | ((~x)&(z)));
27101 }
27102
27103 function f3(x, y, z) {
27104 return (((x) | (~(y))) ^ (z));
27105 }
27106
27107 function f4(x, y, z) {
27108 return (((x) & (z)) | ((y)&(~(z))));
27109 }
27110
27111 function f5(x, y, z) {
27112 return ((x) ^ ((y) |(~(z))));
27113
27114 }
27115
27116 function rotl(x,n) {
27117 return (x<<n) | (x>>>(32-n));
27118 }
27119
27120
27121 /**
27122 * Shortcut function to the hasher's object interface.
27123 *
27124 * @param {WordArray|string} message The message to hash.
27125 *
27126 * @return {WordArray} The hash.
27127 *
27128 * @static
27129 *
27130 * @example
27131 *
27132 * var hash = CryptoJS.RIPEMD160('message');
27133 * var hash = CryptoJS.RIPEMD160(wordArray);
27134 */
27135 C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
27136
27137 /**
27138 * Shortcut function to the HMAC's object interface.
27139 *
27140 * @param {WordArray|string} message The message to hash.
27141 * @param {WordArray|string} key The secret key.
27142 *
27143 * @return {WordArray} The HMAC.
27144 *
27145 * @static
27146 *
27147 * @example
27148 *
27149 * var hmac = CryptoJS.HmacRIPEMD160(message, key);
27150 */
27151 C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
27152 }(Math));
27153
27154
27155 return CryptoJS.RIPEMD160;
27156
27157 }));
27158 },{"./core":31}],55:[function(_dereq_,module,exports){
27159 ;(function (root, factory) {
27160 if (typeof exports === "object") {
27161 // CommonJS
27162 module.exports = exports = factory(_dereq_("./core"));
27163 }
27164 else if (typeof define === "function" && define.amd) {
27165 // AMD
27166 define(["./core"], factory);
27167 }
27168 else {
27169 // Global (browser)
27170 factory(root.CryptoJS);
27171 }
27172 }(this, function (CryptoJS) {
27173
27174 (function () {
27175 // Shortcuts
27176 var C = CryptoJS;
27177 var C_lib = C.lib;
27178 var WordArray = C_lib.WordArray;
27179 var Hasher = C_lib.Hasher;
27180 var C_algo = C.algo;
27181
27182 // Reusable object
27183 var W = [];
27184
27185 /**
27186 * SHA-1 hash algorithm.
27187 */
27188 var SHA1 = C_algo.SHA1 = Hasher.extend({
27189 _doReset: function () {
27190 this._hash = new WordArray.init([
27191 0x67452301, 0xefcdab89,
27192 0x98badcfe, 0x10325476,
27193 0xc3d2e1f0
27194 ]);
27195 },
27196
27197 _doProcessBlock: function (M, offset) {
27198 // Shortcut
27199 var H = this._hash.words;
27200
27201 // Working variables
27202 var a = H[0];
27203 var b = H[1];
27204 var c = H[2];
27205 var d = H[3];
27206 var e = H[4];
27207
27208 // Computation
27209 for (var i = 0; i < 80; i++) {
27210 if (i < 16) {
27211 W[i] = M[offset + i] | 0;
27212 } else {
27213 var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
27214 W[i] = (n << 1) | (n >>> 31);
27215 }
27216
27217 var t = ((a << 5) | (a >>> 27)) + e + W[i];
27218 if (i < 20) {
27219 t += ((b & c) | (~b & d)) + 0x5a827999;
27220 } else if (i < 40) {
27221 t += (b ^ c ^ d) + 0x6ed9eba1;
27222 } else if (i < 60) {
27223 t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
27224 } else /* if (i < 80) */ {
27225 t += (b ^ c ^ d) - 0x359d3e2a;
27226 }
27227
27228 e = d;
27229 d = c;
27230 c = (b << 30) | (b >>> 2);
27231 b = a;
27232 a = t;
27233 }
27234
27235 // Intermediate hash value
27236 H[0] = (H[0] + a) | 0;
27237 H[1] = (H[1] + b) | 0;
27238 H[2] = (H[2] + c) | 0;
27239 H[3] = (H[3] + d) | 0;
27240 H[4] = (H[4] + e) | 0;
27241 },
27242
27243 _doFinalize: function () {
27244 // Shortcuts
27245 var data = this._data;
27246 var dataWords = data.words;
27247
27248 var nBitsTotal = this._nDataBytes * 8;
27249 var nBitsLeft = data.sigBytes * 8;
27250
27251 // Add padding
27252 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27253 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
27254 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
27255 data.sigBytes = dataWords.length * 4;
27256
27257 // Hash final blocks
27258 this._process();
27259
27260 // Return final computed hash
27261 return this._hash;
27262 },
27263
27264 clone: function () {
27265 var clone = Hasher.clone.call(this);
27266 clone._hash = this._hash.clone();
27267
27268 return clone;
27269 }
27270 });
27271
27272 /**
27273 * Shortcut function to the hasher's object interface.
27274 *
27275 * @param {WordArray|string} message The message to hash.
27276 *
27277 * @return {WordArray} The hash.
27278 *
27279 * @static
27280 *
27281 * @example
27282 *
27283 * var hash = CryptoJS.SHA1('message');
27284 * var hash = CryptoJS.SHA1(wordArray);
27285 */
27286 C.SHA1 = Hasher._createHelper(SHA1);
27287
27288 /**
27289 * Shortcut function to the HMAC's object interface.
27290 *
27291 * @param {WordArray|string} message The message to hash.
27292 * @param {WordArray|string} key The secret key.
27293 *
27294 * @return {WordArray} The HMAC.
27295 *
27296 * @static
27297 *
27298 * @example
27299 *
27300 * var hmac = CryptoJS.HmacSHA1(message, key);
27301 */
27302 C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
27303 }());
27304
27305
27306 return CryptoJS.SHA1;
27307
27308 }));
27309 },{"./core":31}],56:[function(_dereq_,module,exports){
27310 ;(function (root, factory, undef) {
27311 if (typeof exports === "object") {
27312 // CommonJS
27313 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha256"));
27314 }
27315 else if (typeof define === "function" && define.amd) {
27316 // AMD
27317 define(["./core", "./sha256"], factory);
27318 }
27319 else {
27320 // Global (browser)
27321 factory(root.CryptoJS);
27322 }
27323 }(this, function (CryptoJS) {
27324
27325 (function () {
27326 // Shortcuts
27327 var C = CryptoJS;
27328 var C_lib = C.lib;
27329 var WordArray = C_lib.WordArray;
27330 var C_algo = C.algo;
27331 var SHA256 = C_algo.SHA256;
27332
27333 /**
27334 * SHA-224 hash algorithm.
27335 */
27336 var SHA224 = C_algo.SHA224 = SHA256.extend({
27337 _doReset: function () {
27338 this._hash = new WordArray.init([
27339 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
27340 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
27341 ]);
27342 },
27343
27344 _doFinalize: function () {
27345 var hash = SHA256._doFinalize.call(this);
27346
27347 hash.sigBytes -= 4;
27348
27349 return hash;
27350 }
27351 });
27352
27353 /**
27354 * Shortcut function to the hasher's object interface.
27355 *
27356 * @param {WordArray|string} message The message to hash.
27357 *
27358 * @return {WordArray} The hash.
27359 *
27360 * @static
27361 *
27362 * @example
27363 *
27364 * var hash = CryptoJS.SHA224('message');
27365 * var hash = CryptoJS.SHA224(wordArray);
27366 */
27367 C.SHA224 = SHA256._createHelper(SHA224);
27368
27369 /**
27370 * Shortcut function to the HMAC's object interface.
27371 *
27372 * @param {WordArray|string} message The message to hash.
27373 * @param {WordArray|string} key The secret key.
27374 *
27375 * @return {WordArray} The HMAC.
27376 *
27377 * @static
27378 *
27379 * @example
27380 *
27381 * var hmac = CryptoJS.HmacSHA224(message, key);
27382 */
27383 C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
27384 }());
27385
27386
27387 return CryptoJS.SHA224;
27388
27389 }));
27390 },{"./core":31,"./sha256":57}],57:[function(_dereq_,module,exports){
27391 ;(function (root, factory) {
27392 if (typeof exports === "object") {
27393 // CommonJS
27394 module.exports = exports = factory(_dereq_("./core"));
27395 }
27396 else if (typeof define === "function" && define.amd) {
27397 // AMD
27398 define(["./core"], factory);
27399 }
27400 else {
27401 // Global (browser)
27402 factory(root.CryptoJS);
27403 }
27404 }(this, function (CryptoJS) {
27405
27406 (function (Math) {
27407 // Shortcuts
27408 var C = CryptoJS;
27409 var C_lib = C.lib;
27410 var WordArray = C_lib.WordArray;
27411 var Hasher = C_lib.Hasher;
27412 var C_algo = C.algo;
27413
27414 // Initialization and round constants tables
27415 var H = [];
27416 var K = [];
27417
27418 // Compute constants
27419 (function () {
27420 function isPrime(n) {
27421 var sqrtN = Math.sqrt(n);
27422 for (var factor = 2; factor <= sqrtN; factor++) {
27423 if (!(n % factor)) {
27424 return false;
27425 }
27426 }
27427
27428 return true;
27429 }
27430
27431 function getFractionalBits(n) {
27432 return ((n - (n | 0)) * 0x100000000) | 0;
27433 }
27434
27435 var n = 2;
27436 var nPrime = 0;
27437 while (nPrime < 64) {
27438 if (isPrime(n)) {
27439 if (nPrime < 8) {
27440 H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
27441 }
27442 K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
27443
27444 nPrime++;
27445 }
27446
27447 n++;
27448 }
27449 }());
27450
27451 // Reusable object
27452 var W = [];
27453
27454 /**
27455 * SHA-256 hash algorithm.
27456 */
27457 var SHA256 = C_algo.SHA256 = Hasher.extend({
27458 _doReset: function () {
27459 this._hash = new WordArray.init(H.slice(0));
27460 },
27461
27462 _doProcessBlock: function (M, offset) {
27463 // Shortcut
27464 var H = this._hash.words;
27465
27466 // Working variables
27467 var a = H[0];
27468 var b = H[1];
27469 var c = H[2];
27470 var d = H[3];
27471 var e = H[4];
27472 var f = H[5];
27473 var g = H[6];
27474 var h = H[7];
27475
27476 // Computation
27477 for (var i = 0; i < 64; i++) {
27478 if (i < 16) {
27479 W[i] = M[offset + i] | 0;
27480 } else {
27481 var gamma0x = W[i - 15];
27482 var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
27483 ((gamma0x << 14) | (gamma0x >>> 18)) ^
27484 (gamma0x >>> 3);
27485
27486 var gamma1x = W[i - 2];
27487 var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
27488 ((gamma1x << 13) | (gamma1x >>> 19)) ^
27489 (gamma1x >>> 10);
27490
27491 W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
27492 }
27493
27494 var ch = (e & f) ^ (~e & g);
27495 var maj = (a & b) ^ (a & c) ^ (b & c);
27496
27497 var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
27498 var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
27499
27500 var t1 = h + sigma1 + ch + K[i] + W[i];
27501 var t2 = sigma0 + maj;
27502
27503 h = g;
27504 g = f;
27505 f = e;
27506 e = (d + t1) | 0;
27507 d = c;
27508 c = b;
27509 b = a;
27510 a = (t1 + t2) | 0;
27511 }
27512
27513 // Intermediate hash value
27514 H[0] = (H[0] + a) | 0;
27515 H[1] = (H[1] + b) | 0;
27516 H[2] = (H[2] + c) | 0;
27517 H[3] = (H[3] + d) | 0;
27518 H[4] = (H[4] + e) | 0;
27519 H[5] = (H[5] + f) | 0;
27520 H[6] = (H[6] + g) | 0;
27521 H[7] = (H[7] + h) | 0;
27522 },
27523
27524 _doFinalize: function () {
27525 // Shortcuts
27526 var data = this._data;
27527 var dataWords = data.words;
27528
27529 var nBitsTotal = this._nDataBytes * 8;
27530 var nBitsLeft = data.sigBytes * 8;
27531
27532 // Add padding
27533 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27534 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
27535 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
27536 data.sigBytes = dataWords.length * 4;
27537
27538 // Hash final blocks
27539 this._process();
27540
27541 // Return final computed hash
27542 return this._hash;
27543 },
27544
27545 clone: function () {
27546 var clone = Hasher.clone.call(this);
27547 clone._hash = this._hash.clone();
27548
27549 return clone;
27550 }
27551 });
27552
27553 /**
27554 * Shortcut function to the hasher's object interface.
27555 *
27556 * @param {WordArray|string} message The message to hash.
27557 *
27558 * @return {WordArray} The hash.
27559 *
27560 * @static
27561 *
27562 * @example
27563 *
27564 * var hash = CryptoJS.SHA256('message');
27565 * var hash = CryptoJS.SHA256(wordArray);
27566 */
27567 C.SHA256 = Hasher._createHelper(SHA256);
27568
27569 /**
27570 * Shortcut function to the HMAC's object interface.
27571 *
27572 * @param {WordArray|string} message The message to hash.
27573 * @param {WordArray|string} key The secret key.
27574 *
27575 * @return {WordArray} The HMAC.
27576 *
27577 * @static
27578 *
27579 * @example
27580 *
27581 * var hmac = CryptoJS.HmacSHA256(message, key);
27582 */
27583 C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
27584 }(Math));
27585
27586
27587 return CryptoJS.SHA256;
27588
27589 }));
27590 },{"./core":31}],58:[function(_dereq_,module,exports){
27591 ;(function (root, factory, undef) {
27592 if (typeof exports === "object") {
27593 // CommonJS
27594 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"));
27595 }
27596 else if (typeof define === "function" && define.amd) {
27597 // AMD
27598 define(["./core", "./x64-core"], factory);
27599 }
27600 else {
27601 // Global (browser)
27602 factory(root.CryptoJS);
27603 }
27604 }(this, function (CryptoJS) {
27605
27606 (function (Math) {
27607 // Shortcuts
27608 var C = CryptoJS;
27609 var C_lib = C.lib;
27610 var WordArray = C_lib.WordArray;
27611 var Hasher = C_lib.Hasher;
27612 var C_x64 = C.x64;
27613 var X64Word = C_x64.Word;
27614 var C_algo = C.algo;
27615
27616 // Constants tables
27617 var RHO_OFFSETS = [];
27618 var PI_INDEXES = [];
27619 var ROUND_CONSTANTS = [];
27620
27621 // Compute Constants
27622 (function () {
27623 // Compute rho offset constants
27624 var x = 1, y = 0;
27625 for (var t = 0; t < 24; t++) {
27626 RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
27627
27628 var newX = y % 5;
27629 var newY = (2 * x + 3 * y) % 5;
27630 x = newX;
27631 y = newY;
27632 }
27633
27634 // Compute pi index constants
27635 for (var x = 0; x < 5; x++) {
27636 for (var y = 0; y < 5; y++) {
27637 PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
27638 }
27639 }
27640
27641 // Compute round constants
27642 var LFSR = 0x01;
27643 for (var i = 0; i < 24; i++) {
27644 var roundConstantMsw = 0;
27645 var roundConstantLsw = 0;
27646
27647 for (var j = 0; j < 7; j++) {
27648 if (LFSR & 0x01) {
27649 var bitPosition = (1 << j) - 1;
27650 if (bitPosition < 32) {
27651 roundConstantLsw ^= 1 << bitPosition;
27652 } else /* if (bitPosition >= 32) */ {
27653 roundConstantMsw ^= 1 << (bitPosition - 32);
27654 }
27655 }
27656
27657 // Compute next LFSR
27658 if (LFSR & 0x80) {
27659 // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
27660 LFSR = (LFSR << 1) ^ 0x71;
27661 } else {
27662 LFSR <<= 1;
27663 }
27664 }
27665
27666 ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
27667 }
27668 }());
27669
27670 // Reusable objects for temporary values
27671 var T = [];
27672 (function () {
27673 for (var i = 0; i < 25; i++) {
27674 T[i] = X64Word.create();
27675 }
27676 }());
27677
27678 /**
27679 * SHA-3 hash algorithm.
27680 */
27681 var SHA3 = C_algo.SHA3 = Hasher.extend({
27682 /**
27683 * Configuration options.
27684 *
27685 * @property {number} outputLength
27686 * The desired number of bits in the output hash.
27687 * Only values permitted are: 224, 256, 384, 512.
27688 * Default: 512
27689 */
27690 cfg: Hasher.cfg.extend({
27691 outputLength: 512
27692 }),
27693
27694 _doReset: function () {
27695 var state = this._state = []
27696 for (var i = 0; i < 25; i++) {
27697 state[i] = new X64Word.init();
27698 }
27699
27700 this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
27701 },
27702
27703 _doProcessBlock: function (M, offset) {
27704 // Shortcuts
27705 var state = this._state;
27706 var nBlockSizeLanes = this.blockSize / 2;
27707
27708 // Absorb
27709 for (var i = 0; i < nBlockSizeLanes; i++) {
27710 // Shortcuts
27711 var M2i = M[offset + 2 * i];
27712 var M2i1 = M[offset + 2 * i + 1];
27713
27714 // Swap endian
27715 M2i = (
27716 (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) |
27717 (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00)
27718 );
27719 M2i1 = (
27720 (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) |
27721 (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00)
27722 );
27723
27724 // Absorb message into state
27725 var lane = state[i];
27726 lane.high ^= M2i1;
27727 lane.low ^= M2i;
27728 }
27729
27730 // Rounds
27731 for (var round = 0; round < 24; round++) {
27732 // Theta
27733 for (var x = 0; x < 5; x++) {
27734 // Mix column lanes
27735 var tMsw = 0, tLsw = 0;
27736 for (var y = 0; y < 5; y++) {
27737 var lane = state[x + 5 * y];
27738 tMsw ^= lane.high;
27739 tLsw ^= lane.low;
27740 }
27741
27742 // Temporary values
27743 var Tx = T[x];
27744 Tx.high = tMsw;
27745 Tx.low = tLsw;
27746 }
27747 for (var x = 0; x < 5; x++) {
27748 // Shortcuts
27749 var Tx4 = T[(x + 4) % 5];
27750 var Tx1 = T[(x + 1) % 5];
27751 var Tx1Msw = Tx1.high;
27752 var Tx1Lsw = Tx1.low;
27753
27754 // Mix surrounding columns
27755 var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
27756 var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
27757 for (var y = 0; y < 5; y++) {
27758 var lane = state[x + 5 * y];
27759 lane.high ^= tMsw;
27760 lane.low ^= tLsw;
27761 }
27762 }
27763
27764 // Rho Pi
27765 for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
27766 // Shortcuts
27767 var lane = state[laneIndex];
27768 var laneMsw = lane.high;
27769 var laneLsw = lane.low;
27770 var rhoOffset = RHO_OFFSETS[laneIndex];
27771
27772 // Rotate lanes
27773 if (rhoOffset < 32) {
27774 var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
27775 var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
27776 } else /* if (rhoOffset >= 32) */ {
27777 var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
27778 var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
27779 }
27780
27781 // Transpose lanes
27782 var TPiLane = T[PI_INDEXES[laneIndex]];
27783 TPiLane.high = tMsw;
27784 TPiLane.low = tLsw;
27785 }
27786
27787 // Rho pi at x = y = 0
27788 var T0 = T[0];
27789 var state0 = state[0];
27790 T0.high = state0.high;
27791 T0.low = state0.low;
27792
27793 // Chi
27794 for (var x = 0; x < 5; x++) {
27795 for (var y = 0; y < 5; y++) {
27796 // Shortcuts
27797 var laneIndex = x + 5 * y;
27798 var lane = state[laneIndex];
27799 var TLane = T[laneIndex];
27800 var Tx1Lane = T[((x + 1) % 5) + 5 * y];
27801 var Tx2Lane = T[((x + 2) % 5) + 5 * y];
27802
27803 // Mix rows
27804 lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
27805 lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
27806 }
27807 }
27808
27809 // Iota
27810 var lane = state[0];
27811 var roundConstant = ROUND_CONSTANTS[round];
27812 lane.high ^= roundConstant.high;
27813 lane.low ^= roundConstant.low;;
27814 }
27815 },
27816
27817 _doFinalize: function () {
27818 // Shortcuts
27819 var data = this._data;
27820 var dataWords = data.words;
27821 var nBitsTotal = this._nDataBytes * 8;
27822 var nBitsLeft = data.sigBytes * 8;
27823 var blockSizeBits = this.blockSize * 32;
27824
27825 // Add padding
27826 dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
27827 dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
27828 data.sigBytes = dataWords.length * 4;
27829
27830 // Hash final blocks
27831 this._process();
27832
27833 // Shortcuts
27834 var state = this._state;
27835 var outputLengthBytes = this.cfg.outputLength / 8;
27836 var outputLengthLanes = outputLengthBytes / 8;
27837
27838 // Squeeze
27839 var hashWords = [];
27840 for (var i = 0; i < outputLengthLanes; i++) {
27841 // Shortcuts
27842 var lane = state[i];
27843 var laneMsw = lane.high;
27844 var laneLsw = lane.low;
27845
27846 // Swap endian
27847 laneMsw = (
27848 (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) |
27849 (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00)
27850 );
27851 laneLsw = (
27852 (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) |
27853 (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00)
27854 );
27855
27856 // Squeeze state to retrieve hash
27857 hashWords.push(laneLsw);
27858 hashWords.push(laneMsw);
27859 }
27860
27861 // Return final computed hash
27862 return new WordArray.init(hashWords, outputLengthBytes);
27863 },
27864
27865 clone: function () {
27866 var clone = Hasher.clone.call(this);
27867
27868 var state = clone._state = this._state.slice(0);
27869 for (var i = 0; i < 25; i++) {
27870 state[i] = state[i].clone();
27871 }
27872
27873 return clone;
27874 }
27875 });
27876
27877 /**
27878 * Shortcut function to the hasher's object interface.
27879 *
27880 * @param {WordArray|string} message The message to hash.
27881 *
27882 * @return {WordArray} The hash.
27883 *
27884 * @static
27885 *
27886 * @example
27887 *
27888 * var hash = CryptoJS.SHA3('message');
27889 * var hash = CryptoJS.SHA3(wordArray);
27890 */
27891 C.SHA3 = Hasher._createHelper(SHA3);
27892
27893 /**
27894 * Shortcut function to the HMAC's object interface.
27895 *
27896 * @param {WordArray|string} message The message to hash.
27897 * @param {WordArray|string} key The secret key.
27898 *
27899 * @return {WordArray} The HMAC.
27900 *
27901 * @static
27902 *
27903 * @example
27904 *
27905 * var hmac = CryptoJS.HmacSHA3(message, key);
27906 */
27907 C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
27908 }(Math));
27909
27910
27911 return CryptoJS.SHA3;
27912
27913 }));
27914 },{"./core":31,"./x64-core":62}],59:[function(_dereq_,module,exports){
27915 ;(function (root, factory, undef) {
27916 if (typeof exports === "object") {
27917 // CommonJS
27918 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"), _dereq_("./sha512"));
27919 }
27920 else if (typeof define === "function" && define.amd) {
27921 // AMD
27922 define(["./core", "./x64-core", "./sha512"], factory);
27923 }
27924 else {
27925 // Global (browser)
27926 factory(root.CryptoJS);
27927 }
27928 }(this, function (CryptoJS) {
27929
27930 (function () {
27931 // Shortcuts
27932 var C = CryptoJS;
27933 var C_x64 = C.x64;
27934 var X64Word = C_x64.Word;
27935 var X64WordArray = C_x64.WordArray;
27936 var C_algo = C.algo;
27937 var SHA512 = C_algo.SHA512;
27938
27939 /**
27940 * SHA-384 hash algorithm.
27941 */
27942 var SHA384 = C_algo.SHA384 = SHA512.extend({
27943 _doReset: function () {
27944 this._hash = new X64WordArray.init([
27945 new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
27946 new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
27947 new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
27948 new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
27949 ]);
27950 },
27951
27952 _doFinalize: function () {
27953 var hash = SHA512._doFinalize.call(this);
27954
27955 hash.sigBytes -= 16;
27956
27957 return hash;
27958 }
27959 });
27960
27961 /**
27962 * Shortcut function to the hasher's object interface.
27963 *
27964 * @param {WordArray|string} message The message to hash.
27965 *
27966 * @return {WordArray} The hash.
27967 *
27968 * @static
27969 *
27970 * @example
27971 *
27972 * var hash = CryptoJS.SHA384('message');
27973 * var hash = CryptoJS.SHA384(wordArray);
27974 */
27975 C.SHA384 = SHA512._createHelper(SHA384);
27976
27977 /**
27978 * Shortcut function to the HMAC's object interface.
27979 *
27980 * @param {WordArray|string} message The message to hash.
27981 * @param {WordArray|string} key The secret key.
27982 *
27983 * @return {WordArray} The HMAC.
27984 *
27985 * @static
27986 *
27987 * @example
27988 *
27989 * var hmac = CryptoJS.HmacSHA384(message, key);
27990 */
27991 C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
27992 }());
27993
27994
27995 return CryptoJS.SHA384;
27996
27997 }));
27998 },{"./core":31,"./sha512":60,"./x64-core":62}],60:[function(_dereq_,module,exports){
27999 ;(function (root, factory, undef) {
28000 if (typeof exports === "object") {
28001 // CommonJS
28002 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"));
28003 }
28004 else if (typeof define === "function" && define.amd) {
28005 // AMD
28006 define(["./core", "./x64-core"], factory);
28007 }
28008 else {
28009 // Global (browser)
28010 factory(root.CryptoJS);
28011 }
28012 }(this, function (CryptoJS) {
28013
28014 (function () {
28015 // Shortcuts
28016 var C = CryptoJS;
28017 var C_lib = C.lib;
28018 var Hasher = C_lib.Hasher;
28019 var C_x64 = C.x64;
28020 var X64Word = C_x64.Word;
28021 var X64WordArray = C_x64.WordArray;
28022 var C_algo = C.algo;
28023
28024 function X64Word_create() {
28025 return X64Word.create.apply(X64Word, arguments);
28026 }
28027
28028 // Constants
28029 var K = [
28030 X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
28031 X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
28032 X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
28033 X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
28034 X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
28035 X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
28036 X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
28037 X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
28038 X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
28039 X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
28040 X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
28041 X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
28042 X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
28043 X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
28044 X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
28045 X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
28046 X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
28047 X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
28048 X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
28049 X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
28050 X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
28051 X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
28052 X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
28053 X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
28054 X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
28055 X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
28056 X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
28057 X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
28058 X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
28059 X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
28060 X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
28061 X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
28062 X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
28063 X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
28064 X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
28065 X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
28066 X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
28067 X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
28068 X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
28069 X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
28070 ];
28071
28072 // Reusable objects
28073 var W = [];
28074 (function () {
28075 for (var i = 0; i < 80; i++) {
28076 W[i] = X64Word_create();
28077 }
28078 }());
28079
28080 /**
28081 * SHA-512 hash algorithm.
28082 */
28083 var SHA512 = C_algo.SHA512 = Hasher.extend({
28084 _doReset: function () {
28085 this._hash = new X64WordArray.init([
28086 new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
28087 new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
28088 new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
28089 new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
28090 ]);
28091 },
28092
28093 _doProcessBlock: function (M, offset) {
28094 // Shortcuts
28095 var H = this._hash.words;
28096
28097 var H0 = H[0];
28098 var H1 = H[1];
28099 var H2 = H[2];
28100 var H3 = H[3];
28101 var H4 = H[4];
28102 var H5 = H[5];
28103 var H6 = H[6];
28104 var H7 = H[7];
28105
28106 var H0h = H0.high;
28107 var H0l = H0.low;
28108 var H1h = H1.high;
28109 var H1l = H1.low;
28110 var H2h = H2.high;
28111 var H2l = H2.low;
28112 var H3h = H3.high;
28113 var H3l = H3.low;
28114 var H4h = H4.high;
28115 var H4l = H4.low;
28116 var H5h = H5.high;
28117 var H5l = H5.low;
28118 var H6h = H6.high;
28119 var H6l = H6.low;
28120 var H7h = H7.high;
28121 var H7l = H7.low;
28122
28123 // Working variables
28124 var ah = H0h;
28125 var al = H0l;
28126 var bh = H1h;
28127 var bl = H1l;
28128 var ch = H2h;
28129 var cl = H2l;
28130 var dh = H3h;
28131 var dl = H3l;
28132 var eh = H4h;
28133 var el = H4l;
28134 var fh = H5h;
28135 var fl = H5l;
28136 var gh = H6h;
28137 var gl = H6l;
28138 var hh = H7h;
28139 var hl = H7l;
28140
28141 // Rounds
28142 for (var i = 0; i < 80; i++) {
28143 // Shortcut
28144 var Wi = W[i];
28145
28146 // Extend message
28147 if (i < 16) {
28148 var Wih = Wi.high = M[offset + i * 2] | 0;
28149 var Wil = Wi.low = M[offset + i * 2 + 1] | 0;
28150 } else {
28151 // Gamma0
28152 var gamma0x = W[i - 15];
28153 var gamma0xh = gamma0x.high;
28154 var gamma0xl = gamma0x.low;
28155 var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
28156 var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
28157
28158 // Gamma1
28159 var gamma1x = W[i - 2];
28160 var gamma1xh = gamma1x.high;
28161 var gamma1xl = gamma1x.low;
28162 var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
28163 var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
28164
28165 // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
28166 var Wi7 = W[i - 7];
28167 var Wi7h = Wi7.high;
28168 var Wi7l = Wi7.low;
28169
28170 var Wi16 = W[i - 16];
28171 var Wi16h = Wi16.high;
28172 var Wi16l = Wi16.low;
28173
28174 var Wil = gamma0l + Wi7l;
28175 var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
28176 var Wil = Wil + gamma1l;
28177 var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
28178 var Wil = Wil + Wi16l;
28179 var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
28180
28181 Wi.high = Wih;
28182 Wi.low = Wil;
28183 }
28184
28185 var chh = (eh & fh) ^ (~eh & gh);
28186 var chl = (el & fl) ^ (~el & gl);
28187 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
28188 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
28189
28190 var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
28191 var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
28192 var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
28193 var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
28194
28195 // t1 = h + sigma1 + ch + K[i] + W[i]
28196 var Ki = K[i];
28197 var Kih = Ki.high;
28198 var Kil = Ki.low;
28199
28200 var t1l = hl + sigma1l;
28201 var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
28202 var t1l = t1l + chl;
28203 var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
28204 var t1l = t1l + Kil;
28205 var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
28206 var t1l = t1l + Wil;
28207 var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
28208
28209 // t2 = sigma0 + maj
28210 var t2l = sigma0l + majl;
28211 var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
28212
28213 // Update working variables
28214 hh = gh;
28215 hl = gl;
28216 gh = fh;
28217 gl = fl;
28218 fh = eh;
28219 fl = el;
28220 el = (dl + t1l) | 0;
28221 eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
28222 dh = ch;
28223 dl = cl;
28224 ch = bh;
28225 cl = bl;
28226 bh = ah;
28227 bl = al;
28228 al = (t1l + t2l) | 0;
28229 ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
28230 }
28231
28232 // Intermediate hash value
28233 H0l = H0.low = (H0l + al);
28234 H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
28235 H1l = H1.low = (H1l + bl);
28236 H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
28237 H2l = H2.low = (H2l + cl);
28238 H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
28239 H3l = H3.low = (H3l + dl);
28240 H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
28241 H4l = H4.low = (H4l + el);
28242 H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
28243 H5l = H5.low = (H5l + fl);
28244 H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
28245 H6l = H6.low = (H6l + gl);
28246 H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
28247 H7l = H7.low = (H7l + hl);
28248 H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
28249 },
28250
28251 _doFinalize: function () {
28252 // Shortcuts
28253 var data = this._data;
28254 var dataWords = data.words;
28255
28256 var nBitsTotal = this._nDataBytes * 8;
28257 var nBitsLeft = data.sigBytes * 8;
28258
28259 // Add padding
28260 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
28261 dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
28262 dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
28263 data.sigBytes = dataWords.length * 4;
28264
28265 // Hash final blocks
28266 this._process();
28267
28268 // Convert hash to 32-bit word array before returning
28269 var hash = this._hash.toX32();
28270
28271 // Return final computed hash
28272 return hash;
28273 },
28274
28275 clone: function () {
28276 var clone = Hasher.clone.call(this);
28277 clone._hash = this._hash.clone();
28278
28279 return clone;
28280 },
28281
28282 blockSize: 1024/32
28283 });
28284
28285 /**
28286 * Shortcut function to the hasher's object interface.
28287 *
28288 * @param {WordArray|string} message The message to hash.
28289 *
28290 * @return {WordArray} The hash.
28291 *
28292 * @static
28293 *
28294 * @example
28295 *
28296 * var hash = CryptoJS.SHA512('message');
28297 * var hash = CryptoJS.SHA512(wordArray);
28298 */
28299 C.SHA512 = Hasher._createHelper(SHA512);
28300
28301 /**
28302 * Shortcut function to the HMAC's object interface.
28303 *
28304 * @param {WordArray|string} message The message to hash.
28305 * @param {WordArray|string} key The secret key.
28306 *
28307 * @return {WordArray} The HMAC.
28308 *
28309 * @static
28310 *
28311 * @example
28312 *
28313 * var hmac = CryptoJS.HmacSHA512(message, key);
28314 */
28315 C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
28316 }());
28317
28318
28319 return CryptoJS.SHA512;
28320
28321 }));
28322 },{"./core":31,"./x64-core":62}],61:[function(_dereq_,module,exports){
28323 ;(function (root, factory, undef) {
28324 if (typeof exports === "object") {
28325 // CommonJS
28326 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
28327 }
28328 else if (typeof define === "function" && define.amd) {
28329 // AMD
28330 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
28331 }
28332 else {
28333 // Global (browser)
28334 factory(root.CryptoJS);
28335 }
28336 }(this, function (CryptoJS) {
28337
28338 (function () {
28339 // Shortcuts
28340 var C = CryptoJS;
28341 var C_lib = C.lib;
28342 var WordArray = C_lib.WordArray;
28343 var BlockCipher = C_lib.BlockCipher;
28344 var C_algo = C.algo;
28345
28346 // Permuted Choice 1 constants
28347 var PC1 = [
28348 57, 49, 41, 33, 25, 17, 9, 1,
28349 58, 50, 42, 34, 26, 18, 10, 2,
28350 59, 51, 43, 35, 27, 19, 11, 3,
28351 60, 52, 44, 36, 63, 55, 47, 39,
28352 31, 23, 15, 7, 62, 54, 46, 38,
28353 30, 22, 14, 6, 61, 53, 45, 37,
28354 29, 21, 13, 5, 28, 20, 12, 4
28355 ];
28356
28357 // Permuted Choice 2 constants
28358 var PC2 = [
28359 14, 17, 11, 24, 1, 5,
28360 3, 28, 15, 6, 21, 10,
28361 23, 19, 12, 4, 26, 8,
28362 16, 7, 27, 20, 13, 2,
28363 41, 52, 31, 37, 47, 55,
28364 30, 40, 51, 45, 33, 48,
28365 44, 49, 39, 56, 34, 53,
28366 46, 42, 50, 36, 29, 32
28367 ];
28368
28369 // Cumulative bit shift constants
28370 var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
28371
28372 // SBOXes and round permutation constants
28373 var SBOX_P = [
28374 {
28375 0x0: 0x808200,
28376 0x10000000: 0x8000,
28377 0x20000000: 0x808002,
28378 0x30000000: 0x2,
28379 0x40000000: 0x200,
28380 0x50000000: 0x808202,
28381 0x60000000: 0x800202,
28382 0x70000000: 0x800000,
28383 0x80000000: 0x202,
28384 0x90000000: 0x800200,
28385 0xa0000000: 0x8200,
28386 0xb0000000: 0x808000,
28387 0xc0000000: 0x8002,
28388 0xd0000000: 0x800002,
28389 0xe0000000: 0x0,
28390 0xf0000000: 0x8202,
28391 0x8000000: 0x0,
28392 0x18000000: 0x808202,
28393 0x28000000: 0x8202,
28394 0x38000000: 0x8000,
28395 0x48000000: 0x808200,
28396 0x58000000: 0x200,
28397 0x68000000: 0x808002,
28398 0x78000000: 0x2,
28399 0x88000000: 0x800200,
28400 0x98000000: 0x8200,
28401 0xa8000000: 0x808000,
28402 0xb8000000: 0x800202,
28403 0xc8000000: 0x800002,
28404 0xd8000000: 0x8002,
28405 0xe8000000: 0x202,
28406 0xf8000000: 0x800000,
28407 0x1: 0x8000,
28408 0x10000001: 0x2,
28409 0x20000001: 0x808200,
28410 0x30000001: 0x800000,
28411 0x40000001: 0x808002,
28412 0x50000001: 0x8200,
28413 0x60000001: 0x200,
28414 0x70000001: 0x800202,
28415 0x80000001: 0x808202,
28416 0x90000001: 0x808000,
28417 0xa0000001: 0x800002,
28418 0xb0000001: 0x8202,
28419 0xc0000001: 0x202,
28420 0xd0000001: 0x800200,
28421 0xe0000001: 0x8002,
28422 0xf0000001: 0x0,
28423 0x8000001: 0x808202,
28424 0x18000001: 0x808000,
28425 0x28000001: 0x800000,
28426 0x38000001: 0x200,
28427 0x48000001: 0x8000,
28428 0x58000001: 0x800002,
28429 0x68000001: 0x2,
28430 0x78000001: 0x8202,
28431 0x88000001: 0x8002,
28432 0x98000001: 0x800202,
28433 0xa8000001: 0x202,
28434 0xb8000001: 0x808200,
28435 0xc8000001: 0x800200,
28436 0xd8000001: 0x0,
28437 0xe8000001: 0x8200,
28438 0xf8000001: 0x808002
28439 },
28440 {
28441 0x0: 0x40084010,
28442 0x1000000: 0x4000,
28443 0x2000000: 0x80000,
28444 0x3000000: 0x40080010,
28445 0x4000000: 0x40000010,
28446 0x5000000: 0x40084000,
28447 0x6000000: 0x40004000,
28448 0x7000000: 0x10,
28449 0x8000000: 0x84000,
28450 0x9000000: 0x40004010,
28451 0xa000000: 0x40000000,
28452 0xb000000: 0x84010,
28453 0xc000000: 0x80010,
28454 0xd000000: 0x0,
28455 0xe000000: 0x4010,
28456 0xf000000: 0x40080000,
28457 0x800000: 0x40004000,
28458 0x1800000: 0x84010,
28459 0x2800000: 0x10,
28460 0x3800000: 0x40004010,
28461 0x4800000: 0x40084010,
28462 0x5800000: 0x40000000,
28463 0x6800000: 0x80000,
28464 0x7800000: 0x40080010,
28465 0x8800000: 0x80010,
28466 0x9800000: 0x0,
28467 0xa800000: 0x4000,
28468 0xb800000: 0x40080000,
28469 0xc800000: 0x40000010,
28470 0xd800000: 0x84000,
28471 0xe800000: 0x40084000,
28472 0xf800000: 0x4010,
28473 0x10000000: 0x0,
28474 0x11000000: 0x40080010,
28475 0x12000000: 0x40004010,
28476 0x13000000: 0x40084000,
28477 0x14000000: 0x40080000,
28478 0x15000000: 0x10,
28479 0x16000000: 0x84010,
28480 0x17000000: 0x4000,
28481 0x18000000: 0x4010,
28482 0x19000000: 0x80000,
28483 0x1a000000: 0x80010,
28484 0x1b000000: 0x40000010,
28485 0x1c000000: 0x84000,
28486 0x1d000000: 0x40004000,
28487 0x1e000000: 0x40000000,
28488 0x1f000000: 0x40084010,
28489 0x10800000: 0x84010,
28490 0x11800000: 0x80000,
28491 0x12800000: 0x40080000,
28492 0x13800000: 0x4000,
28493 0x14800000: 0x40004000,
28494 0x15800000: 0x40084010,
28495 0x16800000: 0x10,
28496 0x17800000: 0x40000000,
28497 0x18800000: 0x40084000,
28498 0x19800000: 0x40000010,
28499 0x1a800000: 0x40004010,
28500 0x1b800000: 0x80010,
28501 0x1c800000: 0x0,
28502 0x1d800000: 0x4010,
28503 0x1e800000: 0x40080010,
28504 0x1f800000: 0x84000
28505 },
28506 {
28507 0x0: 0x104,
28508 0x100000: 0x0,
28509 0x200000: 0x4000100,
28510 0x300000: 0x10104,
28511 0x400000: 0x10004,
28512 0x500000: 0x4000004,
28513 0x600000: 0x4010104,
28514 0x700000: 0x4010000,
28515 0x800000: 0x4000000,
28516 0x900000: 0x4010100,
28517 0xa00000: 0x10100,
28518 0xb00000: 0x4010004,
28519 0xc00000: 0x4000104,
28520 0xd00000: 0x10000,
28521 0xe00000: 0x4,
28522 0xf00000: 0x100,
28523 0x80000: 0x4010100,
28524 0x180000: 0x4010004,
28525 0x280000: 0x0,
28526 0x380000: 0x4000100,
28527 0x480000: 0x4000004,
28528 0x580000: 0x10000,
28529 0x680000: 0x10004,
28530 0x780000: 0x104,
28531 0x880000: 0x4,
28532 0x980000: 0x100,
28533 0xa80000: 0x4010000,
28534 0xb80000: 0x10104,
28535 0xc80000: 0x10100,
28536 0xd80000: 0x4000104,
28537 0xe80000: 0x4010104,
28538 0xf80000: 0x4000000,
28539 0x1000000: 0x4010100,
28540 0x1100000: 0x10004,
28541 0x1200000: 0x10000,
28542 0x1300000: 0x4000100,
28543 0x1400000: 0x100,
28544 0x1500000: 0x4010104,
28545 0x1600000: 0x4000004,
28546 0x1700000: 0x0,
28547 0x1800000: 0x4000104,
28548 0x1900000: 0x4000000,
28549 0x1a00000: 0x4,
28550 0x1b00000: 0x10100,
28551 0x1c00000: 0x4010000,
28552 0x1d00000: 0x104,
28553 0x1e00000: 0x10104,
28554 0x1f00000: 0x4010004,
28555 0x1080000: 0x4000000,
28556 0x1180000: 0x104,
28557 0x1280000: 0x4010100,
28558 0x1380000: 0x0,
28559 0x1480000: 0x10004,
28560 0x1580000: 0x4000100,
28561 0x1680000: 0x100,
28562 0x1780000: 0x4010004,
28563 0x1880000: 0x10000,
28564 0x1980000: 0x4010104,
28565 0x1a80000: 0x10104,
28566 0x1b80000: 0x4000004,
28567 0x1c80000: 0x4000104,
28568 0x1d80000: 0x4010000,
28569 0x1e80000: 0x4,
28570 0x1f80000: 0x10100
28571 },
28572 {
28573 0x0: 0x80401000,
28574 0x10000: 0x80001040,
28575 0x20000: 0x401040,
28576 0x30000: 0x80400000,
28577 0x40000: 0x0,
28578 0x50000: 0x401000,
28579 0x60000: 0x80000040,
28580 0x70000: 0x400040,
28581 0x80000: 0x80000000,
28582 0x90000: 0x400000,
28583 0xa0000: 0x40,
28584 0xb0000: 0x80001000,
28585 0xc0000: 0x80400040,
28586 0xd0000: 0x1040,
28587 0xe0000: 0x1000,
28588 0xf0000: 0x80401040,
28589 0x8000: 0x80001040,
28590 0x18000: 0x40,
28591 0x28000: 0x80400040,
28592 0x38000: 0x80001000,
28593 0x48000: 0x401000,
28594 0x58000: 0x80401040,
28595 0x68000: 0x0,
28596 0x78000: 0x80400000,
28597 0x88000: 0x1000,
28598 0x98000: 0x80401000,
28599 0xa8000: 0x400000,
28600 0xb8000: 0x1040,
28601 0xc8000: 0x80000000,
28602 0xd8000: 0x400040,
28603 0xe8000: 0x401040,
28604 0xf8000: 0x80000040,
28605 0x100000: 0x400040,
28606 0x110000: 0x401000,
28607 0x120000: 0x80000040,
28608 0x130000: 0x0,
28609 0x140000: 0x1040,
28610 0x150000: 0x80400040,
28611 0x160000: 0x80401000,
28612 0x170000: 0x80001040,
28613 0x180000: 0x80401040,
28614 0x190000: 0x80000000,
28615 0x1a0000: 0x80400000,
28616 0x1b0000: 0x401040,
28617 0x1c0000: 0x80001000,
28618 0x1d0000: 0x400000,
28619 0x1e0000: 0x40,
28620 0x1f0000: 0x1000,
28621 0x108000: 0x80400000,
28622 0x118000: 0x80401040,
28623 0x128000: 0x0,
28624 0x138000: 0x401000,
28625 0x148000: 0x400040,
28626 0x158000: 0x80000000,
28627 0x168000: 0x80001040,
28628 0x178000: 0x40,
28629 0x188000: 0x80000040,
28630 0x198000: 0x1000,
28631 0x1a8000: 0x80001000,
28632 0x1b8000: 0x80400040,
28633 0x1c8000: 0x1040,
28634 0x1d8000: 0x80401000,
28635 0x1e8000: 0x400000,
28636 0x1f8000: 0x401040
28637 },
28638 {
28639 0x0: 0x80,
28640 0x1000: 0x1040000,
28641 0x2000: 0x40000,
28642 0x3000: 0x20000000,
28643 0x4000: 0x20040080,
28644 0x5000: 0x1000080,
28645 0x6000: 0x21000080,
28646 0x7000: 0x40080,
28647 0x8000: 0x1000000,
28648 0x9000: 0x20040000,
28649 0xa000: 0x20000080,
28650 0xb000: 0x21040080,
28651 0xc000: 0x21040000,
28652 0xd000: 0x0,
28653 0xe000: 0x1040080,
28654 0xf000: 0x21000000,
28655 0x800: 0x1040080,
28656 0x1800: 0x21000080,
28657 0x2800: 0x80,
28658 0x3800: 0x1040000,
28659 0x4800: 0x40000,
28660 0x5800: 0x20040080,
28661 0x6800: 0x21040000,
28662 0x7800: 0x20000000,
28663 0x8800: 0x20040000,
28664 0x9800: 0x0,
28665 0xa800: 0x21040080,
28666 0xb800: 0x1000080,
28667 0xc800: 0x20000080,
28668 0xd800: 0x21000000,
28669 0xe800: 0x1000000,
28670 0xf800: 0x40080,
28671 0x10000: 0x40000,
28672 0x11000: 0x80,
28673 0x12000: 0x20000000,
28674 0x13000: 0x21000080,
28675 0x14000: 0x1000080,
28676 0x15000: 0x21040000,
28677 0x16000: 0x20040080,
28678 0x17000: 0x1000000,
28679 0x18000: 0x21040080,
28680 0x19000: 0x21000000,
28681 0x1a000: 0x1040000,
28682 0x1b000: 0x20040000,
28683 0x1c000: 0x40080,
28684 0x1d000: 0x20000080,
28685 0x1e000: 0x0,
28686 0x1f000: 0x1040080,
28687 0x10800: 0x21000080,
28688 0x11800: 0x1000000,
28689 0x12800: 0x1040000,
28690 0x13800: 0x20040080,
28691 0x14800: 0x20000000,
28692 0x15800: 0x1040080,
28693 0x16800: 0x80,
28694 0x17800: 0x21040000,
28695 0x18800: 0x40080,
28696 0x19800: 0x21040080,
28697 0x1a800: 0x0,
28698 0x1b800: 0x21000000,
28699 0x1c800: 0x1000080,
28700 0x1d800: 0x40000,
28701 0x1e800: 0x20040000,
28702 0x1f800: 0x20000080
28703 },
28704 {
28705 0x0: 0x10000008,
28706 0x100: 0x2000,
28707 0x200: 0x10200000,
28708 0x300: 0x10202008,
28709 0x400: 0x10002000,
28710 0x500: 0x200000,
28711 0x600: 0x200008,
28712 0x700: 0x10000000,
28713 0x800: 0x0,
28714 0x900: 0x10002008,
28715 0xa00: 0x202000,
28716 0xb00: 0x8,
28717 0xc00: 0x10200008,
28718 0xd00: 0x202008,
28719 0xe00: 0x2008,
28720 0xf00: 0x10202000,
28721 0x80: 0x10200000,
28722 0x180: 0x10202008,
28723 0x280: 0x8,
28724 0x380: 0x200000,
28725 0x480: 0x202008,
28726 0x580: 0x10000008,
28727 0x680: 0x10002000,
28728 0x780: 0x2008,
28729 0x880: 0x200008,
28730 0x980: 0x2000,
28731 0xa80: 0x10002008,
28732 0xb80: 0x10200008,
28733 0xc80: 0x0,
28734 0xd80: 0x10202000,
28735 0xe80: 0x202000,
28736 0xf80: 0x10000000,
28737 0x1000: 0x10002000,
28738 0x1100: 0x10200008,
28739 0x1200: 0x10202008,
28740 0x1300: 0x2008,
28741 0x1400: 0x200000,
28742 0x1500: 0x10000000,
28743 0x1600: 0x10000008,
28744 0x1700: 0x202000,
28745 0x1800: 0x202008,
28746 0x1900: 0x0,
28747 0x1a00: 0x8,
28748 0x1b00: 0x10200000,
28749 0x1c00: 0x2000,
28750 0x1d00: 0x10002008,
28751 0x1e00: 0x10202000,
28752 0x1f00: 0x200008,
28753 0x1080: 0x8,
28754 0x1180: 0x202000,
28755 0x1280: 0x200000,
28756 0x1380: 0x10000008,
28757 0x1480: 0x10002000,
28758 0x1580: 0x2008,
28759 0x1680: 0x10202008,
28760 0x1780: 0x10200000,
28761 0x1880: 0x10202000,
28762 0x1980: 0x10200008,
28763 0x1a80: 0x2000,
28764 0x1b80: 0x202008,
28765 0x1c80: 0x200008,
28766 0x1d80: 0x0,
28767 0x1e80: 0x10000000,
28768 0x1f80: 0x10002008
28769 },
28770 {
28771 0x0: 0x100000,
28772 0x10: 0x2000401,
28773 0x20: 0x400,
28774 0x30: 0x100401,
28775 0x40: 0x2100401,
28776 0x50: 0x0,
28777 0x60: 0x1,
28778 0x70: 0x2100001,
28779 0x80: 0x2000400,
28780 0x90: 0x100001,
28781 0xa0: 0x2000001,
28782 0xb0: 0x2100400,
28783 0xc0: 0x2100000,
28784 0xd0: 0x401,
28785 0xe0: 0x100400,
28786 0xf0: 0x2000000,
28787 0x8: 0x2100001,
28788 0x18: 0x0,
28789 0x28: 0x2000401,
28790 0x38: 0x2100400,
28791 0x48: 0x100000,
28792 0x58: 0x2000001,
28793 0x68: 0x2000000,
28794 0x78: 0x401,
28795 0x88: 0x100401,
28796 0x98: 0x2000400,
28797 0xa8: 0x2100000,
28798 0xb8: 0x100001,
28799 0xc8: 0x400,
28800 0xd8: 0x2100401,
28801 0xe8: 0x1,
28802 0xf8: 0x100400,
28803 0x100: 0x2000000,
28804 0x110: 0x100000,
28805 0x120: 0x2000401,
28806 0x130: 0x2100001,
28807 0x140: 0x100001,
28808 0x150: 0x2000400,
28809 0x160: 0x2100400,
28810 0x170: 0x100401,
28811 0x180: 0x401,
28812 0x190: 0x2100401,
28813 0x1a0: 0x100400,
28814 0x1b0: 0x1,
28815 0x1c0: 0x0,
28816 0x1d0: 0x2100000,
28817 0x1e0: 0x2000001,
28818 0x1f0: 0x400,
28819 0x108: 0x100400,
28820 0x118: 0x2000401,
28821 0x128: 0x2100001,
28822 0x138: 0x1,
28823 0x148: 0x2000000,
28824 0x158: 0x100000,
28825 0x168: 0x401,
28826 0x178: 0x2100400,
28827 0x188: 0x2000001,
28828 0x198: 0x2100000,
28829 0x1a8: 0x0,
28830 0x1b8: 0x2100401,
28831 0x1c8: 0x100401,
28832 0x1d8: 0x400,
28833 0x1e8: 0x2000400,
28834 0x1f8: 0x100001
28835 },
28836 {
28837 0x0: 0x8000820,
28838 0x1: 0x20000,
28839 0x2: 0x8000000,
28840 0x3: 0x20,
28841 0x4: 0x20020,
28842 0x5: 0x8020820,
28843 0x6: 0x8020800,
28844 0x7: 0x800,
28845 0x8: 0x8020000,
28846 0x9: 0x8000800,
28847 0xa: 0x20800,
28848 0xb: 0x8020020,
28849 0xc: 0x820,
28850 0xd: 0x0,
28851 0xe: 0x8000020,
28852 0xf: 0x20820,
28853 0x80000000: 0x800,
28854 0x80000001: 0x8020820,
28855 0x80000002: 0x8000820,
28856 0x80000003: 0x8000000,
28857 0x80000004: 0x8020000,
28858 0x80000005: 0x20800,
28859 0x80000006: 0x20820,
28860 0x80000007: 0x20,
28861 0x80000008: 0x8000020,
28862 0x80000009: 0x820,
28863 0x8000000a: 0x20020,
28864 0x8000000b: 0x8020800,
28865 0x8000000c: 0x0,
28866 0x8000000d: 0x8020020,
28867 0x8000000e: 0x8000800,
28868 0x8000000f: 0x20000,
28869 0x10: 0x20820,
28870 0x11: 0x8020800,
28871 0x12: 0x20,
28872 0x13: 0x800,
28873 0x14: 0x8000800,
28874 0x15: 0x8000020,
28875 0x16: 0x8020020,
28876 0x17: 0x20000,
28877 0x18: 0x0,
28878 0x19: 0x20020,
28879 0x1a: 0x8020000,
28880 0x1b: 0x8000820,
28881 0x1c: 0x8020820,
28882 0x1d: 0x20800,
28883 0x1e: 0x820,
28884 0x1f: 0x8000000,
28885 0x80000010: 0x20000,
28886 0x80000011: 0x800,
28887 0x80000012: 0x8020020,
28888 0x80000013: 0x20820,
28889 0x80000014: 0x20,
28890 0x80000015: 0x8020000,
28891 0x80000016: 0x8000000,
28892 0x80000017: 0x8000820,
28893 0x80000018: 0x8020820,
28894 0x80000019: 0x8000020,
28895 0x8000001a: 0x8000800,
28896 0x8000001b: 0x0,
28897 0x8000001c: 0x20800,
28898 0x8000001d: 0x820,
28899 0x8000001e: 0x20020,
28900 0x8000001f: 0x8020800
28901 }
28902 ];
28903
28904 // Masks that select the SBOX input
28905 var SBOX_MASK = [
28906 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
28907 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
28908 ];
28909
28910 /**
28911 * DES block cipher algorithm.
28912 */
28913 var DES = C_algo.DES = BlockCipher.extend({
28914 _doReset: function () {
28915 // Shortcuts
28916 var key = this._key;
28917 var keyWords = key.words;
28918
28919 // Select 56 bits according to PC1
28920 var keyBits = [];
28921 for (var i = 0; i < 56; i++) {
28922 var keyBitPos = PC1[i] - 1;
28923 keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
28924 }
28925
28926 // Assemble 16 subkeys
28927 var subKeys = this._subKeys = [];
28928 for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
28929 // Create subkey
28930 var subKey = subKeys[nSubKey] = [];
28931
28932 // Shortcut
28933 var bitShift = BIT_SHIFTS[nSubKey];
28934
28935 // Select 48 bits according to PC2
28936 for (var i = 0; i < 24; i++) {
28937 // Select from the left 28 key bits
28938 subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
28939
28940 // Select from the right 28 key bits
28941 subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
28942 }
28943
28944 // Since each subkey is applied to an expanded 32-bit input,
28945 // the subkey can be broken into 8 values scaled to 32-bits,
28946 // which allows the key to be used without expansion
28947 subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
28948 for (var i = 1; i < 7; i++) {
28949 subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
28950 }
28951 subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
28952 }
28953
28954 // Compute inverse subkeys
28955 var invSubKeys = this._invSubKeys = [];
28956 for (var i = 0; i < 16; i++) {
28957 invSubKeys[i] = subKeys[15 - i];
28958 }
28959 },
28960
28961 encryptBlock: function (M, offset) {
28962 this._doCryptBlock(M, offset, this._subKeys);
28963 },
28964
28965 decryptBlock: function (M, offset) {
28966 this._doCryptBlock(M, offset, this._invSubKeys);
28967 },
28968
28969 _doCryptBlock: function (M, offset, subKeys) {
28970 // Get input
28971 this._lBlock = M[offset];
28972 this._rBlock = M[offset + 1];
28973
28974 // Initial permutation
28975 exchangeLR.call(this, 4, 0x0f0f0f0f);
28976 exchangeLR.call(this, 16, 0x0000ffff);
28977 exchangeRL.call(this, 2, 0x33333333);
28978 exchangeRL.call(this, 8, 0x00ff00ff);
28979 exchangeLR.call(this, 1, 0x55555555);
28980
28981 // Rounds
28982 for (var round = 0; round < 16; round++) {
28983 // Shortcuts
28984 var subKey = subKeys[round];
28985 var lBlock = this._lBlock;
28986 var rBlock = this._rBlock;
28987
28988 // Feistel function
28989 var f = 0;
28990 for (var i = 0; i < 8; i++) {
28991 f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
28992 }
28993 this._lBlock = rBlock;
28994 this._rBlock = lBlock ^ f;
28995 }
28996
28997 // Undo swap from last round
28998 var t = this._lBlock;
28999 this._lBlock = this._rBlock;
29000 this._rBlock = t;
29001
29002 // Final permutation
29003 exchangeLR.call(this, 1, 0x55555555);
29004 exchangeRL.call(this, 8, 0x00ff00ff);
29005 exchangeRL.call(this, 2, 0x33333333);
29006 exchangeLR.call(this, 16, 0x0000ffff);
29007 exchangeLR.call(this, 4, 0x0f0f0f0f);
29008
29009 // Set output
29010 M[offset] = this._lBlock;
29011 M[offset + 1] = this._rBlock;
29012 },
29013
29014 keySize: 64/32,
29015
29016 ivSize: 64/32,
29017
29018 blockSize: 64/32
29019 });
29020
29021 // Swap bits across the left and right words
29022 function exchangeLR(offset, mask) {
29023 var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
29024 this._rBlock ^= t;
29025 this._lBlock ^= t << offset;
29026 }
29027
29028 function exchangeRL(offset, mask) {
29029 var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
29030 this._lBlock ^= t;
29031 this._rBlock ^= t << offset;
29032 }
29033
29034 /**
29035 * Shortcut functions to the cipher's object interface.
29036 *
29037 * @example
29038 *
29039 * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
29040 * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
29041 */
29042 C.DES = BlockCipher._createHelper(DES);
29043
29044 /**
29045 * Triple-DES block cipher algorithm.
29046 */
29047 var TripleDES = C_algo.TripleDES = BlockCipher.extend({
29048 _doReset: function () {
29049 // Shortcuts
29050 var key = this._key;
29051 var keyWords = key.words;
29052
29053 // Create DES instances
29054 this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
29055 this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
29056 this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
29057 },
29058
29059 encryptBlock: function (M, offset) {
29060 this._des1.encryptBlock(M, offset);
29061 this._des2.decryptBlock(M, offset);
29062 this._des3.encryptBlock(M, offset);
29063 },
29064
29065 decryptBlock: function (M, offset) {
29066 this._des3.decryptBlock(M, offset);
29067 this._des2.encryptBlock(M, offset);
29068 this._des1.decryptBlock(M, offset);
29069 },
29070
29071 keySize: 192/32,
29072
29073 ivSize: 64/32,
29074
29075 blockSize: 64/32
29076 });
29077
29078 /**
29079 * Shortcut functions to the cipher's object interface.
29080 *
29081 * @example
29082 *
29083 * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
29084 * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
29085 */
29086 C.TripleDES = BlockCipher._createHelper(TripleDES);
29087 }());
29088
29089
29090 return CryptoJS.TripleDES;
29091
29092 }));
29093 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],62:[function(_dereq_,module,exports){
29094 ;(function (root, factory) {
29095 if (typeof exports === "object") {
29096 // CommonJS
29097 module.exports = exports = factory(_dereq_("./core"));
29098 }
29099 else if (typeof define === "function" && define.amd) {
29100 // AMD
29101 define(["./core"], factory);
29102 }
29103 else {
29104 // Global (browser)
29105 factory(root.CryptoJS);
29106 }
29107 }(this, function (CryptoJS) {
29108
29109 (function (undefined) {
29110 // Shortcuts
29111 var C = CryptoJS;
29112 var C_lib = C.lib;
29113 var Base = C_lib.Base;
29114 var X32WordArray = C_lib.WordArray;
29115
29116 /**
29117 * x64 namespace.
29118 */
29119 var C_x64 = C.x64 = {};
29120
29121 /**
29122 * A 64-bit word.
29123 */
29124 var X64Word = C_x64.Word = Base.extend({
29125 /**
29126 * Initializes a newly created 64-bit word.
29127 *
29128 * @param {number} high The high 32 bits.
29129 * @param {number} low The low 32 bits.
29130 *
29131 * @example
29132 *
29133 * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
29134 */
29135 init: function (high, low) {
29136 this.high = high;
29137 this.low = low;
29138 }
29139
29140 /**
29141 * Bitwise NOTs this word.
29142 *
29143 * @return {X64Word} A new x64-Word object after negating.
29144 *
29145 * @example
29146 *
29147 * var negated = x64Word.not();
29148 */
29149 // not: function () {
29150 // var high = ~this.high;
29151 // var low = ~this.low;
29152
29153 // return X64Word.create(high, low);
29154 // },
29155
29156 /**
29157 * Bitwise ANDs this word with the passed word.
29158 *
29159 * @param {X64Word} word The x64-Word to AND with this word.
29160 *
29161 * @return {X64Word} A new x64-Word object after ANDing.
29162 *
29163 * @example
29164 *
29165 * var anded = x64Word.and(anotherX64Word);
29166 */
29167 // and: function (word) {
29168 // var high = this.high & word.high;
29169 // var low = this.low & word.low;
29170
29171 // return X64Word.create(high, low);
29172 // },
29173
29174 /**
29175 * Bitwise ORs this word with the passed word.
29176 *
29177 * @param {X64Word} word The x64-Word to OR with this word.
29178 *
29179 * @return {X64Word} A new x64-Word object after ORing.
29180 *
29181 * @example
29182 *
29183 * var ored = x64Word.or(anotherX64Word);
29184 */
29185 // or: function (word) {
29186 // var high = this.high | word.high;
29187 // var low = this.low | word.low;
29188
29189 // return X64Word.create(high, low);
29190 // },
29191
29192 /**
29193 * Bitwise XORs this word with the passed word.
29194 *
29195 * @param {X64Word} word The x64-Word to XOR with this word.
29196 *
29197 * @return {X64Word} A new x64-Word object after XORing.
29198 *
29199 * @example
29200 *
29201 * var xored = x64Word.xor(anotherX64Word);
29202 */
29203 // xor: function (word) {
29204 // var high = this.high ^ word.high;
29205 // var low = this.low ^ word.low;
29206
29207 // return X64Word.create(high, low);
29208 // },
29209
29210 /**
29211 * Shifts this word n bits to the left.
29212 *
29213 * @param {number} n The number of bits to shift.
29214 *
29215 * @return {X64Word} A new x64-Word object after shifting.
29216 *
29217 * @example
29218 *
29219 * var shifted = x64Word.shiftL(25);
29220 */
29221 // shiftL: function (n) {
29222 // if (n < 32) {
29223 // var high = (this.high << n) | (this.low >>> (32 - n));
29224 // var low = this.low << n;
29225 // } else {
29226 // var high = this.low << (n - 32);
29227 // var low = 0;
29228 // }
29229
29230 // return X64Word.create(high, low);
29231 // },
29232
29233 /**
29234 * Shifts this word n bits to the right.
29235 *
29236 * @param {number} n The number of bits to shift.
29237 *
29238 * @return {X64Word} A new x64-Word object after shifting.
29239 *
29240 * @example
29241 *
29242 * var shifted = x64Word.shiftR(7);
29243 */
29244 // shiftR: function (n) {
29245 // if (n < 32) {
29246 // var low = (this.low >>> n) | (this.high << (32 - n));
29247 // var high = this.high >>> n;
29248 // } else {
29249 // var low = this.high >>> (n - 32);
29250 // var high = 0;
29251 // }
29252
29253 // return X64Word.create(high, low);
29254 // },
29255
29256 /**
29257 * Rotates this word n bits to the left.
29258 *
29259 * @param {number} n The number of bits to rotate.
29260 *
29261 * @return {X64Word} A new x64-Word object after rotating.
29262 *
29263 * @example
29264 *
29265 * var rotated = x64Word.rotL(25);
29266 */
29267 // rotL: function (n) {
29268 // return this.shiftL(n).or(this.shiftR(64 - n));
29269 // },
29270
29271 /**
29272 * Rotates this word n bits to the right.
29273 *
29274 * @param {number} n The number of bits to rotate.
29275 *
29276 * @return {X64Word} A new x64-Word object after rotating.
29277 *
29278 * @example
29279 *
29280 * var rotated = x64Word.rotR(7);
29281 */
29282 // rotR: function (n) {
29283 // return this.shiftR(n).or(this.shiftL(64 - n));
29284 // },
29285
29286 /**
29287 * Adds this word with the passed word.
29288 *
29289 * @param {X64Word} word The x64-Word to add with this word.
29290 *
29291 * @return {X64Word} A new x64-Word object after adding.
29292 *
29293 * @example
29294 *
29295 * var added = x64Word.add(anotherX64Word);
29296 */
29297 // add: function (word) {
29298 // var low = (this.low + word.low) | 0;
29299 // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
29300 // var high = (this.high + word.high + carry) | 0;
29301
29302 // return X64Word.create(high, low);
29303 // }
29304 });
29305
29306 /**
29307 * An array of 64-bit words.
29308 *
29309 * @property {Array} words The array of CryptoJS.x64.Word objects.
29310 * @property {number} sigBytes The number of significant bytes in this word array.
29311 */
29312 var X64WordArray = C_x64.WordArray = Base.extend({
29313 /**
29314 * Initializes a newly created word array.
29315 *
29316 * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
29317 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
29318 *
29319 * @example
29320 *
29321 * var wordArray = CryptoJS.x64.WordArray.create();
29322 *
29323 * var wordArray = CryptoJS.x64.WordArray.create([
29324 * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
29325 * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
29326 * ]);
29327 *
29328 * var wordArray = CryptoJS.x64.WordArray.create([
29329 * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
29330 * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
29331 * ], 10);
29332 */
29333 init: function (words, sigBytes) {
29334 words = this.words = words || [];
29335
29336 if (sigBytes != undefined) {
29337 this.sigBytes = sigBytes;
29338 } else {
29339 this.sigBytes = words.length * 8;
29340 }
29341 },
29342
29343 /**
29344 * Converts this 64-bit word array to a 32-bit word array.
29345 *
29346 * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
29347 *
29348 * @example
29349 *
29350 * var x32WordArray = x64WordArray.toX32();
29351 */
29352 toX32: function () {
29353 // Shortcuts
29354 var x64Words = this.words;
29355 var x64WordsLength = x64Words.length;
29356
29357 // Convert
29358 var x32Words = [];
29359 for (var i = 0; i < x64WordsLength; i++) {
29360 var x64Word = x64Words[i];
29361 x32Words.push(x64Word.high);
29362 x32Words.push(x64Word.low);
29363 }
29364
29365 return X32WordArray.create(x32Words, this.sigBytes);
29366 },
29367
29368 /**
29369 * Creates a copy of this word array.
29370 *
29371 * @return {X64WordArray} The clone.
29372 *
29373 * @example
29374 *
29375 * var clone = x64WordArray.clone();
29376 */
29377 clone: function () {
29378 var clone = Base.clone.call(this);
29379
29380 // Clone "words" array
29381 var words = clone.words = this.words.slice(0);
29382
29383 // Clone each X64Word object
29384 var wordsLength = words.length;
29385 for (var i = 0; i < wordsLength; i++) {
29386 words[i] = words[i].clone();
29387 }
29388
29389 return clone;
29390 }
29391 });
29392 }());
29393
29394
29395 return CryptoJS;
29396
29397 }));
29398 },{"./core":31}],63:[function(_dereq_,module,exports){
29399 var assert = _dereq_('assert')
29400 var BigInteger = _dereq_('bigi')
29401
29402 var Point = _dereq_('./point')
29403
29404 function Curve(p, a, b, Gx, Gy, n, h) {
29405 this.p = p
29406 this.a = a
29407 this.b = b
29408 this.G = Point.fromAffine(this, Gx, Gy)
29409 this.n = n
29410 this.h = h
29411
29412 this.infinity = new Point(this, null, null, BigInteger.ZERO)
29413
29414 // result caching
29415 this.pOverFour = p.add(BigInteger.ONE).shiftRight(2)
29416 }
29417
29418 Curve.prototype.pointFromX = function(isOdd, x) {
29419 var alpha = x.pow(3).add(this.a.multiply(x)).add(this.b).mod(this.p)
29420 var beta = alpha.modPow(this.pOverFour, this.p)
29421
29422 var y = beta
29423 if (beta.isEven() ^ !isOdd) {
29424 y = this.p.subtract(y) // -y % p
29425 }
29426
29427 return Point.fromAffine(this, x, y)
29428 }
29429
29430 Curve.prototype.isInfinity = function(Q) {
29431 if (Q === this.infinity) return true
29432
29433 return Q.z.signum() === 0 && Q.y.signum() !== 0
29434 }
29435
29436 Curve.prototype.isOnCurve = function(Q) {
29437 if (this.isInfinity(Q)) return true
29438
29439 var x = Q.affineX
29440 var y = Q.affineY
29441 var a = this.a
29442 var b = this.b
29443 var p = this.p
29444
29445 // Check that xQ and yQ are integers in the interval [0, p - 1]
29446 if (x.signum() < 0 || x.compareTo(p) >= 0) return false
29447 if (y.signum() < 0 || y.compareTo(p) >= 0) return false
29448
29449 // and check that y^2 = x^3 + ax + b (mod p)
29450 var lhs = y.square().mod(p)
29451 var rhs = x.pow(3).add(a.multiply(x)).add(b).mod(p)
29452 return lhs.equals(rhs)
29453 }
29454
29455 /**
29456 * Validate an elliptic curve point.
29457 *
29458 * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive
29459 */
29460 Curve.prototype.validate = function(Q) {
29461 // Check Q != O
29462 assert(!this.isInfinity(Q), 'Point is at infinity')
29463 assert(this.isOnCurve(Q), 'Point is not on the curve')
29464
29465 // Check nQ = O (where Q is a scalar multiple of G)
29466 var nQ = Q.multiply(this.n)
29467 assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G')
29468
29469 return true
29470 }
29471
29472 module.exports = Curve
29473
29474 },{"./point":67,"assert":4,"bigi":3}],64:[function(_dereq_,module,exports){
29475 module.exports={
29476 "secp128r1": {
29477 "p": "fffffffdffffffffffffffffffffffff",
29478 "a": "fffffffdfffffffffffffffffffffffc",
29479 "b": "e87579c11079f43dd824993c2cee5ed3",
29480 "n": "fffffffe0000000075a30d1b9038a115",
29481 "h": "01",
29482 "Gx": "161ff7528b899b2d0c28607ca52c5b86",
29483 "Gy": "cf5ac8395bafeb13c02da292dded7a83"
29484 },
29485 "secp160k1": {
29486 "p": "fffffffffffffffffffffffffffffffeffffac73",
29487 "a": "00",
29488 "b": "07",
29489 "n": "0100000000000000000001b8fa16dfab9aca16b6b3",
29490 "h": "01",
29491 "Gx": "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",
29492 "Gy": "938cf935318fdced6bc28286531733c3f03c4fee"
29493 },
29494 "secp160r1": {
29495 "p": "ffffffffffffffffffffffffffffffff7fffffff",
29496 "a": "ffffffffffffffffffffffffffffffff7ffffffc",
29497 "b": "1c97befc54bd7a8b65acf89f81d4d4adc565fa45",
29498 "n": "0100000000000000000001f4c8f927aed3ca752257",
29499 "h": "01",
29500 "Gx": "4a96b5688ef573284664698968c38bb913cbfc82",
29501 "Gy": "23a628553168947d59dcc912042351377ac5fb32"
29502 },
29503 "secp192k1": {
29504 "p": "fffffffffffffffffffffffffffffffffffffffeffffee37",
29505 "a": "00",
29506 "b": "03",
29507 "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d",
29508 "h": "01",
29509 "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",
29510 "Gy": "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"
29511 },
29512 "secp192r1": {
29513 "p": "fffffffffffffffffffffffffffffffeffffffffffffffff",
29514 "a": "fffffffffffffffffffffffffffffffefffffffffffffffc",
29515 "b": "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",
29516 "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831",
29517 "h": "01",
29518 "Gx": "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",
29519 "Gy": "07192b95ffc8da78631011ed6b24cdd573f977a11e794811"
29520 },
29521 "secp224r1": {
29522 "p": "ffffffffffffffffffffffffffffffff000000000000000000000001",
29523 "a": "fffffffffffffffffffffffffffffffefffffffffffffffffffffffe",
29524 "b": "b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4",
29525 "n": "ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d",
29526 "h": "01",
29527 "Gx": "b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21",
29528 "Gy": "bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"
29529 },
29530 "secp256k1": {
29531 "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
29532 "a": "00",
29533 "b": "07",
29534 "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
29535 "h": "01",
29536 "Gx": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
29537 "Gy": "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
29538 },
29539 "secp256r1": {
29540 "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
29541 "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",
29542 "b": "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
29543 "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
29544 "h": "01",
29545 "Gx": "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
29546 "Gy": "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"
29547 }
29548 }
29549
29550 },{}],65:[function(_dereq_,module,exports){
29551 var Point = _dereq_('./point')
29552 var Curve = _dereq_('./curve')
29553
29554 var getCurveByName = _dereq_('./names')
29555
29556 module.exports = {
29557 Curve: Curve,
29558 Point: Point,
29559 getCurveByName: getCurveByName
29560 }
29561
29562 },{"./curve":63,"./names":66,"./point":67}],66:[function(_dereq_,module,exports){
29563 var BigInteger = _dereq_('bigi')
29564
29565 var curves = _dereq_('./curves')
29566 var Curve = _dereq_('./curve')
29567
29568 function getCurveByName(name) {
29569 var curve = curves[name]
29570 if (!curve) return null
29571
29572 var p = new BigInteger(curve.p, 16)
29573 var a = new BigInteger(curve.a, 16)
29574 var b = new BigInteger(curve.b, 16)
29575 var n = new BigInteger(curve.n, 16)
29576 var h = new BigInteger(curve.h, 16)
29577 var Gx = new BigInteger(curve.Gx, 16)
29578 var Gy = new BigInteger(curve.Gy, 16)
29579
29580 return new Curve(p, a, b, Gx, Gy, n, h)
29581 }
29582
29583 module.exports = getCurveByName
29584
29585 },{"./curve":63,"./curves":64,"bigi":3}],67:[function(_dereq_,module,exports){
29586 (function (Buffer){
29587 var assert = _dereq_('assert')
29588 var BigInteger = _dereq_('bigi')
29589
29590 var THREE = BigInteger.valueOf(3)
29591
29592 function Point(curve, x, y, z) {
29593 assert.notStrictEqual(z, undefined, 'Missing Z coordinate')
29594
29595 this.curve = curve
29596 this.x = x
29597 this.y = y
29598 this.z = z
29599 this._zInv = null
29600
29601 this.compressed = true
29602 }
29603
29604 Object.defineProperty(Point.prototype, 'zInv', {
29605 get: function() {
29606 if (this._zInv === null) {
29607 this._zInv = this.z.modInverse(this.curve.p)
29608 }
29609
29610 return this._zInv
29611 }
29612 })
29613
29614 Object.defineProperty(Point.prototype, 'affineX', {
29615 get: function() {
29616 return this.x.multiply(this.zInv).mod(this.curve.p)
29617 }
29618 })
29619
29620 Object.defineProperty(Point.prototype, 'affineY', {
29621 get: function() {
29622 return this.y.multiply(this.zInv).mod(this.curve.p)
29623 }
29624 })
29625
29626 Point.fromAffine = function(curve, x, y) {
29627 return new Point(curve, x, y, BigInteger.ONE)
29628 }
29629
29630 Point.prototype.equals = function(other) {
29631 if (other === this) return true
29632 if (this.curve.isInfinity(this)) return this.curve.isInfinity(other)
29633 if (this.curve.isInfinity(other)) return this.curve.isInfinity(this)
29634
29635 // u = Y2 * Z1 - Y1 * Z2
29636 var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p)
29637
29638 if (u.signum() !== 0) return false
29639
29640 // v = X2 * Z1 - X1 * Z2
29641 var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p)
29642
29643 return v.signum() === 0
29644 }
29645
29646 Point.prototype.negate = function() {
29647 var y = this.curve.p.subtract(this.y)
29648
29649 return new Point(this.curve, this.x, y, this.z)
29650 }
29651
29652 Point.prototype.add = function(b) {
29653 if (this.curve.isInfinity(this)) return b
29654 if (this.curve.isInfinity(b)) return this
29655
29656 var x1 = this.x
29657 var y1 = this.y
29658 var x2 = b.x
29659 var y2 = b.y
29660
29661 // u = Y2 * Z1 - Y1 * Z2
29662 var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p)
29663 // v = X2 * Z1 - X1 * Z2
29664 var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p)
29665
29666 if (v.signum() === 0) {
29667 if (u.signum() === 0) {
29668 return this.twice() // this == b, so double
29669 }
29670
29671 return this.curve.infinity // this = -b, so infinity
29672 }
29673
29674 var v2 = v.square()
29675 var v3 = v2.multiply(v)
29676 var x1v2 = x1.multiply(v2)
29677 var zu2 = u.square().multiply(this.z)
29678
29679 // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3)
29680 var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p)
29681 // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3
29682 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)
29683 // z3 = v^3 * z1 * z2
29684 var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p)
29685
29686 return new Point(this.curve, x3, y3, z3)
29687 }
29688
29689 Point.prototype.twice = function() {
29690 if (this.curve.isInfinity(this)) return this
29691 if (this.y.signum() === 0) return this.curve.infinity
29692
29693 var x1 = this.x
29694 var y1 = this.y
29695
29696 var y1z1 = y1.multiply(this.z)
29697 var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p)
29698 var a = this.curve.a
29699
29700 // w = 3 * x1^2 + a * z1^2
29701 var w = x1.square().multiply(THREE)
29702
29703 if (a.signum() !== 0) {
29704 w = w.add(this.z.square().multiply(a))
29705 }
29706
29707 w = w.mod(this.curve.p)
29708 // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1)
29709 var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.p)
29710 // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3
29711 var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.pow(3)).mod(this.curve.p)
29712 // z3 = 8 * (y1 * z1)^3
29713 var z3 = y1z1.pow(3).shiftLeft(3).mod(this.curve.p)
29714
29715 return new Point(this.curve, x3, y3, z3)
29716 }
29717
29718 // Simple NAF (Non-Adjacent Form) multiplication algorithm
29719 // TODO: modularize the multiplication algorithm
29720 Point.prototype.multiply = function(k) {
29721 if (this.curve.isInfinity(this)) return this
29722 if (k.signum() === 0) return this.curve.infinity
29723
29724 var e = k
29725 var h = e.multiply(THREE)
29726
29727 var neg = this.negate()
29728 var R = this
29729
29730 for (var i = h.bitLength() - 2; i > 0; --i) {
29731 R = R.twice()
29732
29733 var hBit = h.testBit(i)
29734 var eBit = e.testBit(i)
29735
29736 if (hBit != eBit) {
29737 R = R.add(hBit ? this : neg)
29738 }
29739 }
29740
29741 return R
29742 }
29743
29744 // Compute this*j + x*k (simultaneous multiplication)
29745 Point.prototype.multiplyTwo = function(j, x, k) {
29746 var i
29747
29748 if (j.bitLength() > k.bitLength())
29749 i = j.bitLength() - 1
29750 else
29751 i = k.bitLength() - 1
29752
29753 var R = this.curve.infinity
29754 var both = this.add(x)
29755
29756 while (i >= 0) {
29757 R = R.twice()
29758
29759 var jBit = j.testBit(i)
29760 var kBit = k.testBit(i)
29761
29762 if (jBit) {
29763 if (kBit) {
29764 R = R.add(both)
29765
29766 } else {
29767 R = R.add(this)
29768 }
29769
29770 } else {
29771 if (kBit) {
29772 R = R.add(x)
29773 }
29774 }
29775 --i
29776 }
29777
29778 return R
29779 }
29780
29781 Point.prototype.getEncoded = function(compressed) {
29782 if (compressed == undefined) compressed = this.compressed
29783 if (this.curve.isInfinity(this)) return new Buffer('00', 'hex') // Infinity point encoded is simply '00'
29784
29785 var x = this.affineX
29786 var y = this.affineY
29787
29788 var buffer
29789
29790 // Determine size of q in bytes
29791 var byteLength = Math.floor((this.curve.p.bitLength() + 7) / 8)
29792
29793 // 0x02/0x03 | X
29794 if (compressed) {
29795 buffer = new Buffer(1 + byteLength)
29796 buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0)
29797
29798 // 0x04 | X | Y
29799 } else {
29800 buffer = new Buffer(1 + byteLength + byteLength)
29801 buffer.writeUInt8(0x04, 0)
29802
29803 y.toBuffer(byteLength).copy(buffer, 1 + byteLength)
29804 }
29805
29806 x.toBuffer(byteLength).copy(buffer, 1)
29807
29808 return buffer
29809 }
29810
29811 Point.decodeFrom = function(curve, buffer) {
29812 var type = buffer.readUInt8(0)
29813 var compressed = (type !== 4)
29814
29815 var x = BigInteger.fromBuffer(buffer.slice(1, 33))
29816 var byteLength = Math.floor((curve.p.bitLength() + 7) / 8)
29817
29818 var Q
29819 if (compressed) {
29820 assert.equal(buffer.length, byteLength + 1, 'Invalid sequence length')
29821 assert(type === 0x02 || type === 0x03, 'Invalid sequence tag')
29822
29823 var isOdd = (type === 0x03)
29824 Q = curve.pointFromX(isOdd, x)
29825
29826 } else {
29827 assert.equal(buffer.length, 1 + byteLength + byteLength, 'Invalid sequence length')
29828
29829 var y = BigInteger.fromBuffer(buffer.slice(1 + byteLength))
29830 Q = Point.fromAffine(curve, x, y)
29831 }
29832
29833 Q.compressed = compressed
29834 return Q
29835 }
29836
29837 Point.prototype.toString = function () {
29838 if (this.curve.isInfinity(this)) return '(INFINITY)'
29839
29840 return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')'
29841 }
29842
29843 module.exports = Point
29844
29845 }).call(this,_dereq_("buffer").Buffer)
29846 },{"assert":4,"bigi":3,"buffer":8}],68:[function(_dereq_,module,exports){
29847 (function (process,Buffer){
29848 // Closure compiler error - result of 'not' operator not being used
29849 //!function(globals){
29850 (function(globals){
29851 'use strict'
29852
29853 //*** UMD BEGIN
29854 if (typeof define !== 'undefined' && define.amd) { //require.js / AMD
29855 define([], function() {
29856 return secureRandom
29857 })
29858 } else if (typeof module !== 'undefined' && module.exports) { //CommonJS
29859 module.exports = secureRandom
29860 } else { //script / browser
29861 globals.secureRandom = secureRandom
29862 }
29863 //*** UMD END
29864
29865 //options.type is the only valid option
29866 function secureRandom(count, options) {
29867 options = options || {type: 'Array'}
29868 //we check for process.pid to prevent browserify from tricking us
29869 if (typeof process != 'undefined' && typeof process.pid == 'number') {
29870 return nodeRandom(count, options)
29871 } else {
29872 var crypto = window.crypto || window.msCrypto
29873 if (!crypto) throw new Error("Your browser does not support window.crypto.")
29874 return browserRandom(count, options)
29875 }
29876 }
29877
29878 function nodeRandom(count, options) {
29879 var crypto = _dereq_('crypto')
29880 var buf = crypto.randomBytes(count)
29881
29882 switch (options.type) {
29883 case 'Array':
29884 return [].slice.call(buf)
29885 case 'Buffer':
29886 return buf
29887 case 'Uint8Array':
29888 var arr = new Uint8Array(count)
29889 for (var i = 0; i < count; ++i) { arr[i] = buf.readUInt8(i) }
29890 return arr
29891 default:
29892 throw new Error(options.type + " is unsupported.")
29893 }
29894 }
29895
29896 function browserRandom(count, options) {
29897 var nativeArr = new Uint8Array(count)
29898 var crypto = window.crypto || window.msCrypto
29899 crypto.getRandomValues(nativeArr)
29900
29901 switch (options.type) {
29902 case 'Array':
29903 return [].slice.call(nativeArr)
29904 case 'Buffer':
29905 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.')}
29906 return new Buffer(nativeArr)
29907 case 'Uint8Array':
29908 return nativeArr
29909 default:
29910 throw new Error(options.type + " is unsupported.")
29911 }
29912 }
29913
29914 secureRandom.randomArray = function(byteCount) {
29915 return secureRandom(byteCount, {type: 'Array'})
29916 }
29917
29918 secureRandom.randomUint8Array = function(byteCount) {
29919 return secureRandom(byteCount, {type: 'Uint8Array'})
29920 }
29921
29922 secureRandom.randomBuffer = function(byteCount) {
29923 return secureRandom(byteCount, {type: 'Buffer'})
29924 }
29925
29926
29927 })(this);
29928
29929 }).call(this,_dereq_("FWaASH"),_dereq_("buffer").Buffer)
29930 },{"FWaASH":12,"buffer":8,"crypto":7}],69:[function(_dereq_,module,exports){
29931 (function (Buffer){
29932 var assert = _dereq_('assert')
29933 var base58check = _dereq_('./base58check')
29934 var networks = _dereq_('./networks')
29935 var scripts = _dereq_('./scripts')
29936
29937 function findScriptTypeByVersion(version) {
29938 for (var networkName in networks) {
29939 var network = networks[networkName]
29940
29941 if (version === network.pubKeyHash) return 'pubkeyhash'
29942 if (version === network.scriptHash) return 'scripthash'
29943 }
29944 }
29945
29946 function Address(hash, version) {
29947 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
29948 assert.strictEqual(hash.length, 20, 'Invalid hash length')
29949 assert.strictEqual(version & 0xff, version, 'Invalid version byte')
29950
29951 this.hash = hash
29952 this.version = version
29953 }
29954
29955 // Import functions
29956 Address.fromBase58Check = function(string) {
29957 var payload = base58check.decode(string)
29958 var version = payload.readUInt8(0)
29959 var hash = payload.slice(1)
29960
29961 return new Address(hash, version)
29962 }
29963
29964 Address.fromOutputScript = function(script, network) {
29965 network = network || networks.bitcoin
29966
29967 var type = scripts.classifyOutput(script)
29968
29969 if (type === 'pubkeyhash') return new Address(script.chunks[2], network.pubKeyHash)
29970 if (type === 'scripthash') return new Address(script.chunks[1], network.scriptHash)
29971
29972 assert(false, type + ' has no matching Address')
29973 }
29974
29975 // Export functions
29976 Address.prototype.toBase58Check = function () {
29977 var payload = new Buffer(21)
29978 payload.writeUInt8(this.version, 0)
29979 this.hash.copy(payload, 1)
29980
29981 return base58check.encode(payload)
29982 }
29983
29984 Address.prototype.toOutputScript = function() {
29985 var scriptType = findScriptTypeByVersion(this.version)
29986
29987 if (scriptType === 'pubkeyhash') return scripts.pubKeyHashOutput(this.hash)
29988 if (scriptType === 'scripthash') return scripts.scriptHashOutput(this.hash)
29989
29990 assert(false, this.toString() + ' has no matching Script')
29991 }
29992
29993 Address.prototype.toString = Address.prototype.toBase58Check
29994
29995 module.exports = Address
29996
29997 }).call(this,_dereq_("buffer").Buffer)
29998 },{"./base58check":70,"./networks":81,"./scripts":84,"assert":4,"buffer":8}],70:[function(_dereq_,module,exports){
29999 (function (Buffer){
30000 // https://en.bitcoin.it/wiki/Base58Check_encoding
30001 var assert = _dereq_('assert')
30002 var base58 = _dereq_('bs58')
30003 var crypto = _dereq_('./crypto')
30004
30005 // Encode a buffer as a base58-check-encoded string
30006 function encode(payload) {
30007 var checksum = crypto.hash256(payload).slice(0, 4)
30008
30009 return base58.encode(Buffer.concat([
30010 payload,
30011 checksum
30012 ]))
30013 }
30014
30015 // Decode a base58-check-encoded string to a buffer
30016 function decode(string) {
30017 var buffer = base58.decode(string)
30018
30019 var payload = buffer.slice(0, -4)
30020 var checksum = buffer.slice(-4)
30021 var newChecksum = crypto.hash256(payload).slice(0, 4)
30022
30023 assert.deepEqual(newChecksum, checksum, 'Invalid checksum')
30024
30025 return payload
30026 }
30027
30028 module.exports = {
30029 encode: encode,
30030 decode: decode
30031 }
30032
30033 }).call(this,_dereq_("buffer").Buffer)
30034 },{"./crypto":73,"assert":4,"bs58":15,"buffer":8}],71:[function(_dereq_,module,exports){
30035 var assert = _dereq_('assert')
30036 var opcodes = _dereq_('./opcodes')
30037
30038 // https://github.com/feross/buffer/blob/master/index.js#L1127
30039 function verifuint(value, max) {
30040 assert(typeof value === 'number', 'cannot write a non-number as a number')
30041 assert(value >= 0, 'specified a negative value for writing an unsigned value')
30042 assert(value <= max, 'value is larger than maximum value for type')
30043 assert(Math.floor(value) === value, 'value has a fractional component')
30044 }
30045
30046 function pushDataSize(i) {
30047 return i < opcodes.OP_PUSHDATA1 ? 1
30048 : i < 0xff ? 2
30049 : i < 0xffff ? 3
30050 : 5
30051 }
30052
30053 function readPushDataInt(buffer, offset) {
30054 var opcode = buffer.readUInt8(offset)
30055 var number, size
30056
30057 // ~6 bit
30058 if (opcode < opcodes.OP_PUSHDATA1) {
30059 number = opcode
30060 size = 1
30061
30062 // 8 bit
30063 } else if (opcode === opcodes.OP_PUSHDATA1) {
30064 number = buffer.readUInt8(offset + 1)
30065 size = 2
30066
30067 // 16 bit
30068 } else if (opcode === opcodes.OP_PUSHDATA2) {
30069 number = buffer.readUInt16LE(offset + 1)
30070 size = 3
30071
30072 // 32 bit
30073 } else {
30074 assert.equal(opcode, opcodes.OP_PUSHDATA4, 'Unexpected opcode')
30075
30076 number = buffer.readUInt32LE(offset + 1)
30077 size = 5
30078
30079 }
30080
30081 return {
30082 opcode: opcode,
30083 number: number,
30084 size: size
30085 }
30086 }
30087
30088 function readUInt64LE(buffer, offset) {
30089 var a = buffer.readUInt32LE(offset)
30090 var b = buffer.readUInt32LE(offset + 4)
30091 b *= 0x100000000
30092
30093 verifuint(b + a, 0x001fffffffffffff)
30094
30095 return b + a
30096 }
30097
30098 function readVarInt(buffer, offset) {
30099 var t = buffer.readUInt8(offset)
30100 var number, size
30101
30102 // 8 bit
30103 if (t < 253) {
30104 number = t
30105 size = 1
30106
30107 // 16 bit
30108 } else if (t < 254) {
30109 number = buffer.readUInt16LE(offset + 1)
30110 size = 3
30111
30112 // 32 bit
30113 } else if (t < 255) {
30114 number = buffer.readUInt32LE(offset + 1)
30115 size = 5
30116
30117 // 64 bit
30118 } else {
30119 number = readUInt64LE(buffer, offset + 1)
30120 size = 9
30121 }
30122
30123 return {
30124 number: number,
30125 size: size
30126 }
30127 }
30128
30129 function writePushDataInt(buffer, number, offset) {
30130 var size = pushDataSize(number)
30131
30132 // ~6 bit
30133 if (size === 1) {
30134 buffer.writeUInt8(number, offset)
30135
30136 // 8 bit
30137 } else if (size === 2) {
30138 buffer.writeUInt8(opcodes.OP_PUSHDATA1, offset)
30139 buffer.writeUInt8(number, offset + 1)
30140
30141 // 16 bit
30142 } else if (size === 3) {
30143 buffer.writeUInt8(opcodes.OP_PUSHDATA2, offset)
30144 buffer.writeUInt16LE(number, offset + 1)
30145
30146 // 32 bit
30147 } else {
30148 buffer.writeUInt8(opcodes.OP_PUSHDATA4, offset)
30149 buffer.writeUInt32LE(number, offset + 1)
30150
30151 }
30152
30153 return size
30154 }
30155
30156 function writeUInt64LE(buffer, value, offset) {
30157 verifuint(value, 0x001fffffffffffff)
30158
30159 buffer.writeInt32LE(value & -1, offset)
30160 buffer.writeUInt32LE(Math.floor(value / 0x100000000), offset + 4)
30161 }
30162
30163 function varIntSize(i) {
30164 return i < 253 ? 1
30165 : i < 0x10000 ? 3
30166 : i < 0x100000000 ? 5
30167 : 9
30168 }
30169
30170 function writeVarInt(buffer, number, offset) {
30171 var size = varIntSize(number)
30172
30173 // 8 bit
30174 if (size === 1) {
30175 buffer.writeUInt8(number, offset)
30176
30177 // 16 bit
30178 } else if (size === 3) {
30179 buffer.writeUInt8(253, offset)
30180 buffer.writeUInt16LE(number, offset + 1)
30181
30182 // 32 bit
30183 } else if (size === 5) {
30184 buffer.writeUInt8(254, offset)
30185 buffer.writeUInt32LE(number, offset + 1)
30186
30187 // 64 bit
30188 } else {
30189 buffer.writeUInt8(255, offset)
30190 writeUInt64LE(buffer, number, offset + 1)
30191 }
30192
30193 return size
30194 }
30195
30196 module.exports = {
30197 pushDataSize: pushDataSize,
30198 readPushDataInt: readPushDataInt,
30199 readUInt64LE: readUInt64LE,
30200 readVarInt: readVarInt,
30201 varIntSize: varIntSize,
30202 writePushDataInt: writePushDataInt,
30203 writeUInt64LE: writeUInt64LE,
30204 writeVarInt: writeVarInt
30205 }
30206
30207 },{"./opcodes":82,"assert":4}],72:[function(_dereq_,module,exports){
30208 (function (Buffer){
30209 var assert = _dereq_('assert')
30210 var Crypto = _dereq_('crypto-js')
30211 var WordArray = Crypto.lib.WordArray
30212
30213 function bufferToWordArray(buffer) {
30214 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got', buffer)
30215
30216 var words = []
30217 for (var i = 0, b = 0; i < buffer.length; i++, b += 8) {
30218 words[b >>> 5] |= buffer[i] << (24 - b % 32)
30219 }
30220
30221 return new WordArray.init(words, buffer.length)
30222 }
30223
30224 function wordArrayToBuffer(wordArray) {
30225 assert(Array.isArray(wordArray.words), 'Expected WordArray, got' + wordArray)
30226
30227 var words = wordArray.words
30228 var buffer = new Buffer(words.length * 4)
30229
30230 words.forEach(function(value, i) {
30231 buffer.writeInt32BE(value & -1, i * 4)
30232 })
30233
30234 return buffer
30235 }
30236
30237 module.exports = {
30238 bufferToWordArray: bufferToWordArray,
30239 wordArrayToBuffer: wordArrayToBuffer
30240 }
30241
30242 }).call(this,_dereq_("buffer").Buffer)
30243 },{"assert":4,"buffer":8,"crypto-js":37}],73:[function(_dereq_,module,exports){
30244 (function (Buffer){
30245 // Crypto, crypto, where art thou crypto
30246 var assert = _dereq_('assert')
30247 var CryptoJS = _dereq_('crypto-js')
30248 var crypto = _dereq_('crypto')
30249 var convert = _dereq_('./convert')
30250
30251 function hash160(buffer) {
30252 return ripemd160(sha256(buffer))
30253 }
30254
30255 function hash256(buffer) {
30256 return sha256(sha256(buffer))
30257 }
30258
30259 function ripemd160(buffer) {
30260 return crypto.createHash('rmd160').update(buffer).digest()
30261 }
30262
30263 function sha1(buffer) {
30264 return crypto.createHash('sha1').update(buffer).digest()
30265 }
30266
30267 function sha256(buffer) {
30268 return crypto.createHash('sha256').update(buffer).digest()
30269 }
30270
30271 // FIXME: Name not consistent with others
30272 function HmacSHA256(buffer, secret) {
30273 return crypto.createHmac('sha256', secret).update(buffer).digest()
30274 }
30275
30276 function HmacSHA512(data, secret) {
30277 assert(Buffer.isBuffer(data), 'Expected Buffer for data, got ' + data)
30278 assert(Buffer.isBuffer(secret), 'Expected Buffer for secret, got ' + secret)
30279
30280 var dataWords = convert.bufferToWordArray(data)
30281 var secretWords = convert.bufferToWordArray(secret)
30282
30283 var hash = CryptoJS.HmacSHA512(dataWords, secretWords)
30284
30285 return convert.wordArrayToBuffer(hash)
30286 }
30287
30288 module.exports = {
30289 ripemd160: ripemd160,
30290 sha1: sha1,
30291 sha256: sha256,
30292 hash160: hash160,
30293 hash256: hash256,
30294 HmacSHA256: HmacSHA256,
30295 HmacSHA512: HmacSHA512
30296 }
30297
30298 }).call(this,_dereq_("buffer").Buffer)
30299 },{"./convert":72,"assert":4,"buffer":8,"crypto":19,"crypto-js":37}],74:[function(_dereq_,module,exports){
30300 (function (Buffer){
30301 var assert = _dereq_('assert')
30302 var crypto = _dereq_('./crypto')
30303
30304 var BigInteger = _dereq_('bigi')
30305 var ECSignature = _dereq_('./ecsignature')
30306 var Point = _dereq_('ecurve').Point
30307
30308 // https://tools.ietf.org/html/rfc6979#section-3.2
30309 function deterministicGenerateK(curve, hash, d) {
30310 assert(Buffer.isBuffer(hash), 'Hash must be a Buffer, not ' + hash)
30311 assert.equal(hash.length, 32, 'Hash must be 256 bit')
30312 assert(d instanceof BigInteger, 'Private key must be a BigInteger')
30313
30314 var x = d.toBuffer(32)
30315 var k = new Buffer(32)
30316 var v = new Buffer(32)
30317
30318 // Step B
30319 v.fill(1)
30320
30321 // Step C
30322 k.fill(0)
30323
30324 // Step D
30325 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([0]), x, hash]), k)
30326
30327 // Step E
30328 v = crypto.HmacSHA256(v, k)
30329
30330 // Step F
30331 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([1]), x, hash]), k)
30332
30333 // Step G
30334 v = crypto.HmacSHA256(v, k)
30335
30336 // Step H1/H2a, ignored as tlen === qlen (256 bit)
30337 // Step H2b
30338 v = crypto.HmacSHA256(v, k)
30339
30340 var T = BigInteger.fromBuffer(v)
30341
30342 // Step H3, repeat until T is within the interval [1, n - 1]
30343 while ((T.signum() <= 0) || (T.compareTo(curve.n) >= 0)) {
30344 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([0])]), k)
30345 v = crypto.HmacSHA256(v, k)
30346
30347 T = BigInteger.fromBuffer(v)
30348 }
30349
30350 return T
30351 }
30352
30353 function sign(curve, hash, d) {
30354 var k = deterministicGenerateK(curve, hash, d)
30355
30356 var n = curve.n
30357 var G = curve.G
30358 var Q = G.multiply(k)
30359 var e = BigInteger.fromBuffer(hash)
30360
30361 var r = Q.affineX.mod(n)
30362 assert.notEqual(r.signum(), 0, 'Invalid R value')
30363
30364 var s = k.modInverse(n).multiply(e.add(d.multiply(r))).mod(n)
30365 assert.notEqual(s.signum(), 0, 'Invalid S value')
30366
30367 var N_OVER_TWO = n.shiftRight(1)
30368
30369 // enforce low S values, see bip62: 'low s values in signatures'
30370 if (s.compareTo(N_OVER_TWO) > 0) {
30371 s = n.subtract(s)
30372 }
30373
30374 return new ECSignature(r, s)
30375 }
30376
30377 function verify(curve, hash, signature, Q) {
30378 var e = BigInteger.fromBuffer(hash)
30379
30380 return verifyRaw(curve, e, signature, Q)
30381 }
30382
30383 function verifyRaw(curve, e, signature, Q) {
30384 var n = curve.n
30385 var G = curve.G
30386
30387 var r = signature.r
30388 var s = signature.s
30389
30390 if (r.signum() === 0 || r.compareTo(n) >= 0) return false
30391 if (s.signum() === 0 || s.compareTo(n) >= 0) return false
30392
30393 var c = s.modInverse(n)
30394
30395 var u1 = e.multiply(c).mod(n)
30396 var u2 = r.multiply(c).mod(n)
30397
30398 var point = G.multiplyTwo(u1, Q, u2)
30399 var v = point.affineX.mod(n)
30400
30401 return v.equals(r)
30402 }
30403
30404 /**
30405 * Recover a public key from a signature.
30406 *
30407 * See SEC 1: Elliptic Curve Cryptography, section 4.1.6, "Public
30408 * Key Recovery Operation".
30409 *
30410 * http://www.secg.org/download/aid-780/sec1-v2.pdf
30411 */
30412 function recoverPubKey(curve, e, signature, i) {
30413 assert.strictEqual(i & 3, i, 'Recovery param is more than two bits')
30414
30415 var r = signature.r
30416 var s = signature.s
30417
30418 // A set LSB signifies that the y-coordinate is odd
30419 var isYOdd = i & 1
30420
30421 // The more significant bit specifies whether we should use the
30422 // first or second candidate key.
30423 var isSecondKey = i >> 1
30424
30425 var n = curve.n
30426 var G = curve.G
30427
30428 // 1.1 Let x = r + jn
30429 var x = isSecondKey ? r.add(n) : r
30430 var R = curve.pointFromX(isYOdd, x)
30431
30432 // 1.4 Check that nR is at infinity
30433 var nR = R.multiply(n)
30434 assert(curve.isInfinity(nR), 'nR is not a valid curve point')
30435
30436 // Compute -e from e
30437 var eNeg = e.negate().mod(n)
30438
30439 // 1.6.1 Compute Q = r^-1 (sR - eG)
30440 // Q = r^-1 (sR + -eG)
30441 var rInv = r.modInverse(n)
30442
30443 var Q = R.multiplyTwo(s, G, eNeg).multiply(rInv)
30444 curve.validate(Q)
30445
30446 return Q
30447 }
30448
30449 /**
30450 * Calculate pubkey extraction parameter.
30451 *
30452 * When extracting a pubkey from a signature, we have to
30453 * distinguish four different cases. Rather than putting this
30454 * burden on the verifier, Bitcoin includes a 2-bit value with the
30455 * signature.
30456 *
30457 * This function simply tries all four cases and returns the value
30458 * that resulted in a successful pubkey recovery.
30459 */
30460 function calcPubKeyRecoveryParam(curve, e, signature, Q) {
30461 for (var i = 0; i < 4; i++) {
30462 var Qprime = recoverPubKey(curve, e, signature, i)
30463
30464 // 1.6.2 Verify Q
30465 if (Qprime.equals(Q)) {
30466 return i
30467 }
30468 }
30469
30470 throw new Error('Unable to find valid recovery factor')
30471 }
30472
30473 module.exports = {
30474 calcPubKeyRecoveryParam: calcPubKeyRecoveryParam,
30475 deterministicGenerateK: deterministicGenerateK,
30476 recoverPubKey: recoverPubKey,
30477 sign: sign,
30478 verify: verify,
30479 verifyRaw: verifyRaw
30480 }
30481
30482 }).call(this,_dereq_("buffer").Buffer)
30483 },{"./crypto":73,"./ecsignature":77,"assert":4,"bigi":3,"buffer":8,"ecurve":65}],75:[function(_dereq_,module,exports){
30484 (function (Buffer){
30485 var assert = _dereq_('assert')
30486 var base58check = _dereq_('./base58check')
30487 var ecdsa = _dereq_('./ecdsa')
30488 var networks = _dereq_('./networks')
30489 var secureRandom = _dereq_('secure-random')
30490
30491 var BigInteger = _dereq_('bigi')
30492 var ECPubKey = _dereq_('./ecpubkey')
30493
30494 var ecurve = _dereq_('ecurve')
30495 var curve = ecurve.getCurveByName('secp256k1')
30496
30497 function ECKey(d, compressed) {
30498 assert(d.signum() > 0, 'Private key must be greater than 0')
30499 assert(d.compareTo(curve.n) < 0, 'Private key must be less than the curve order')
30500
30501 var Q = curve.G.multiply(d)
30502
30503 this.d = d
30504 this.pub = new ECPubKey(Q, compressed)
30505 }
30506
30507 // Static constructors
30508 ECKey.fromWIF = function(string) {
30509 var payload = base58check.decode(string)
30510 var compressed = false
30511
30512 // Ignore the version byte
30513 payload = payload.slice(1)
30514
30515 if (payload.length === 33) {
30516 assert.strictEqual(payload[32], 0x01, 'Invalid compression flag')
30517
30518 // Truncate the compression flag
30519 payload = payload.slice(0, -1)
30520 compressed = true
30521 }
30522
30523 assert.equal(payload.length, 32, 'Invalid WIF payload length')
30524
30525 var d = BigInteger.fromBuffer(payload)
30526 return new ECKey(d, compressed)
30527 }
30528
30529 ECKey.makeRandom = function(compressed, rng) {
30530 rng = rng || secureRandom.randomBuffer
30531
30532 var buffer = rng(32)
30533 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)
30534
30535 var d = BigInteger.fromBuffer(buffer)
30536 d = d.mod(curve.n)
30537
30538 return new ECKey(d, compressed)
30539 }
30540
30541 // Export functions
30542 ECKey.prototype.toWIF = function(network) {
30543 network = network || networks.bitcoin
30544
30545 var bufferLen = this.pub.compressed ? 34 : 33
30546 var buffer = new Buffer(bufferLen)
30547
30548 buffer.writeUInt8(network.wif, 0)
30549 this.d.toBuffer(32).copy(buffer, 1)
30550
30551 if (this.pub.compressed) {
30552 buffer.writeUInt8(0x01, 33)
30553 }
30554
30555 return base58check.encode(buffer)
30556 }
30557
30558 // Operations
30559 ECKey.prototype.sign = function(hash) {
30560 return ecdsa.sign(curve, hash, this.d)
30561 }
30562
30563 module.exports = ECKey
30564
30565 }).call(this,_dereq_("buffer").Buffer)
30566 },{"./base58check":70,"./ecdsa":74,"./ecpubkey":76,"./networks":81,"assert":4,"bigi":3,"buffer":8,"ecurve":65,"secure-random":68}],76:[function(_dereq_,module,exports){
30567 (function (Buffer){
30568 var assert = _dereq_('assert')
30569 var crypto = _dereq_('./crypto')
30570 var ecdsa = _dereq_('./ecdsa')
30571 var networks = _dereq_('./networks')
30572
30573 var Address = _dereq_('./address')
30574
30575 var ecurve = _dereq_('ecurve')
30576 var curve = ecurve.getCurveByName('secp256k1')
30577
30578 function ECPubKey(Q, compressed) {
30579 assert(Q instanceof ecurve.Point, 'Expected Point, got ' + Q)
30580
30581 if (compressed == undefined) compressed = true
30582 assert.strictEqual(typeof compressed, 'boolean', 'Expected boolean, got ' + compressed)
30583
30584 this.compressed = compressed
30585 this.Q = Q
30586 }
30587
30588 // Static constructors
30589 ECPubKey.fromBuffer = function(buffer) {
30590 var Q = ecurve.Point.decodeFrom(curve, buffer)
30591 return new ECPubKey(Q, Q.compressed)
30592 }
30593
30594 ECPubKey.fromHex = function(hex) {
30595 return ECPubKey.fromBuffer(new Buffer(hex, 'hex'))
30596 }
30597
30598 // Operations
30599 ECPubKey.prototype.getAddress = function(network) {
30600 network = network || networks.bitcoin
30601
30602 return new Address(crypto.hash160(this.toBuffer()), network.pubKeyHash)
30603 }
30604
30605 ECPubKey.prototype.verify = function(hash, signature) {
30606 return ecdsa.verify(curve, hash, signature, this.Q)
30607 }
30608
30609 // Export functions
30610 ECPubKey.prototype.toBuffer = function() {
30611 return this.Q.getEncoded(this.compressed)
30612 }
30613
30614 ECPubKey.prototype.toHex = function() {
30615 return this.toBuffer().toString('hex')
30616 }
30617
30618 module.exports = ECPubKey
30619
30620 }).call(this,_dereq_("buffer").Buffer)
30621 },{"./address":69,"./crypto":73,"./ecdsa":74,"./networks":81,"assert":4,"buffer":8,"ecurve":65}],77:[function(_dereq_,module,exports){
30622 (function (Buffer){
30623 var assert = _dereq_('assert')
30624 var BigInteger = _dereq_('bigi')
30625
30626 function ECSignature(r, s) {
30627 assert(r instanceof BigInteger, 'Expected BigInteger, got ' + r)
30628 assert(s instanceof BigInteger, 'Expected BigInteger, got ' + s)
30629 this.r = r
30630 this.s = s
30631 }
30632
30633 // Import operations
30634 ECSignature.parseCompact = function(buffer) {
30635 assert.equal(buffer.length, 65, 'Invalid signature length')
30636 var i = buffer.readUInt8(0) - 27
30637
30638 // At most 3 bits
30639 assert.equal(i, i & 7, 'Invalid signature parameter')
30640 var compressed = !!(i & 4)
30641
30642 // Recovery param only
30643 i = i & 3
30644
30645 var r = BigInteger.fromBuffer(buffer.slice(1, 33))
30646 var s = BigInteger.fromBuffer(buffer.slice(33))
30647
30648 return {
30649 compressed: compressed,
30650 i: i,
30651 signature: new ECSignature(r, s)
30652 }
30653 }
30654
30655 ECSignature.fromDER = function(buffer) {
30656 assert.equal(buffer.readUInt8(0), 0x30, 'Not a DER sequence')
30657 assert.equal(buffer.readUInt8(1), buffer.length - 2, 'Invalid sequence length')
30658 assert.equal(buffer.readUInt8(2), 0x02, 'Expected a DER integer')
30659
30660 var rLen = buffer.readUInt8(3)
30661 assert(rLen > 0, 'R length is zero')
30662
30663 var offset = 4 + rLen
30664 assert.equal(buffer.readUInt8(offset), 0x02, 'Expected a DER integer (2)')
30665
30666 var sLen = buffer.readUInt8(offset + 1)
30667 assert(sLen > 0, 'S length is zero')
30668
30669 var rB = buffer.slice(4, offset)
30670 var sB = buffer.slice(offset + 2)
30671 offset += 2 + sLen
30672
30673 if (rLen > 1 && rB.readUInt8(0) === 0x00) {
30674 assert(rB.readUInt8(1) & 0x80, 'R value excessively padded')
30675 }
30676
30677 if (sLen > 1 && sB.readUInt8(0) === 0x00) {
30678 assert(sB.readUInt8(1) & 0x80, 'S value excessively padded')
30679 }
30680
30681 assert.equal(offset, buffer.length, 'Invalid DER encoding')
30682 var r = BigInteger.fromDERInteger(rB)
30683 var s = BigInteger.fromDERInteger(sB)
30684
30685 assert(r.signum() >= 0, 'R value is negative')
30686 assert(s.signum() >= 0, 'S value is negative')
30687
30688 return new ECSignature(r, s)
30689 }
30690
30691 // FIXME: 0x00, 0x04, 0x80 are SIGHASH_* boundary constants, importing Transaction causes a circular dependency
30692 ECSignature.parseScriptSignature = function(buffer) {
30693 var hashType = buffer.readUInt8(buffer.length - 1)
30694 var hashTypeMod = hashType & ~0x80
30695
30696 assert(hashTypeMod > 0x00 && hashTypeMod < 0x04, 'Invalid hashType')
30697
30698 return {
30699 signature: ECSignature.fromDER(buffer.slice(0, -1)),
30700 hashType: hashType
30701 }
30702 }
30703
30704 // Export operations
30705 ECSignature.prototype.toCompact = function(i, compressed) {
30706 if (compressed) i += 4
30707 i += 27
30708
30709 var buffer = new Buffer(65)
30710 buffer.writeUInt8(i, 0)
30711
30712 this.r.toBuffer(32).copy(buffer, 1)
30713 this.s.toBuffer(32).copy(buffer, 33)
30714
30715 return buffer
30716 }
30717
30718 ECSignature.prototype.toDER = function() {
30719 var rBa = this.r.toDERInteger()
30720 var sBa = this.s.toDERInteger()
30721
30722 var sequence = []
30723 sequence.push(0x02) // INTEGER
30724 sequence.push(rBa.length)
30725 sequence = sequence.concat(rBa)
30726
30727 sequence.push(0x02) // INTEGER
30728 sequence.push(sBa.length)
30729 sequence = sequence.concat(sBa)
30730
30731 sequence.unshift(sequence.length)
30732 sequence.unshift(0x30) // SEQUENCE
30733
30734 return new Buffer(sequence)
30735 }
30736
30737 ECSignature.prototype.toScriptSignature = function(hashType) {
30738 var hashTypeBuffer = new Buffer(1)
30739 hashTypeBuffer.writeUInt8(hashType, 0)
30740
30741 return Buffer.concat([this.toDER(), hashTypeBuffer])
30742 }
30743
30744 module.exports = ECSignature
30745
30746 }).call(this,_dereq_("buffer").Buffer)
30747 },{"assert":4,"bigi":3,"buffer":8}],78:[function(_dereq_,module,exports){
30748 (function (Buffer){
30749 var assert = _dereq_('assert')
30750 var base58check = _dereq_('./base58check')
30751 var crypto = _dereq_('./crypto')
30752 var networks = _dereq_('./networks')
30753
30754 var BigInteger = _dereq_('bigi')
30755 var ECKey = _dereq_('./eckey')
30756 var ECPubKey = _dereq_('./ecpubkey')
30757
30758 var ecurve = _dereq_('ecurve')
30759 var curve = ecurve.getCurveByName('secp256k1')
30760
30761 function findBIP32ParamsByVersion(version) {
30762 for (var name in networks) {
30763 var network = networks[name]
30764
30765 for (var type in network.bip32) {
30766 if (version != network.bip32[type]) continue
30767
30768 return {
30769 isPrivate: (type === 'private'),
30770 network: network
30771 }
30772 }
30773 }
30774
30775 assert(false, 'Could not find version ' + version.toString(16))
30776 }
30777
30778 function HDNode(K, chainCode, network) {
30779 network = network || networks.bitcoin
30780
30781 assert(Buffer.isBuffer(chainCode), 'Expected Buffer, got ' + chainCode)
30782 assert(network.bip32, 'Unknown BIP32 constants for network')
30783
30784 this.chainCode = chainCode
30785 this.depth = 0
30786 this.index = 0
30787 this.network = network
30788
30789 if (K instanceof BigInteger) {
30790 this.privKey = new ECKey(K, true)
30791 this.pubKey = this.privKey.pub
30792 } else {
30793 this.pubKey = new ECPubKey(K, true)
30794 }
30795 }
30796
30797 HDNode.MASTER_SECRET = new Buffer('Bitcoin seed')
30798 HDNode.HIGHEST_BIT = 0x80000000
30799 HDNode.LENGTH = 78
30800
30801 HDNode.fromSeedBuffer = function(seed, network) {
30802 var I = crypto.HmacSHA512(seed, HDNode.MASTER_SECRET)
30803 var IL = I.slice(0, 32)
30804 var IR = I.slice(32)
30805
30806 // In case IL is 0 or >= n, the master key is invalid
30807 // This is handled by `new ECKey` in the HDNode constructor
30808 var pIL = BigInteger.fromBuffer(IL)
30809
30810 return new HDNode(pIL, IR, network)
30811 }
30812
30813 HDNode.fromSeedHex = function(hex, network) {
30814 return HDNode.fromSeedBuffer(new Buffer(hex, 'hex'), network)
30815 }
30816
30817 HDNode.fromBase58 = function(string) {
30818 return HDNode.fromBuffer(base58check.decode(string))
30819 }
30820
30821 HDNode.fromBuffer = function(buffer) {
30822 assert.strictEqual(buffer.length, HDNode.LENGTH, 'Invalid buffer length')
30823
30824 // 4 byte: version bytes
30825 var version = buffer.readUInt32BE(0)
30826 var params = findBIP32ParamsByVersion(version)
30827
30828 // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ...
30829 var depth = buffer.readUInt8(4)
30830
30831 // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
30832 var parentFingerprint = buffer.readUInt32BE(5)
30833 if (depth === 0) {
30834 assert.strictEqual(parentFingerprint, 0x00000000, 'Invalid parent fingerprint')
30835 }
30836
30837 // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
30838 // This is encoded in MSB order. (0x00000000 if master key)
30839 var index = buffer.readUInt32BE(9)
30840 assert(depth > 0 || index === 0, 'Invalid index')
30841
30842 // 32 bytes: the chain code
30843 var chainCode = buffer.slice(13, 45)
30844 var hd
30845
30846 // 33 bytes: private key data (0x00 + k)
30847 if (params.isPrivate) {
30848 assert.strictEqual(buffer.readUInt8(45), 0x00, 'Invalid private key')
30849 var data = buffer.slice(46, 78)
30850 var d = BigInteger.fromBuffer(data)
30851 hd = new HDNode(d, chainCode, params.network)
30852
30853 // 33 bytes: public key data (0x02 + X or 0x03 + X)
30854 } else {
30855 var data = buffer.slice(45, 78)
30856 var Q = ecurve.Point.decodeFrom(curve, data)
30857 assert.equal(Q.compressed, true, 'Invalid public key')
30858
30859 // Verify that the X coordinate in the public point corresponds to a point on the curve.
30860 // If not, the extended public key is invalid.
30861 curve.validate(Q)
30862
30863 hd = new HDNode(Q, chainCode, params.network)
30864 }
30865
30866 hd.depth = depth
30867 hd.index = index
30868 hd.parentFingerprint = parentFingerprint
30869
30870 return hd
30871 }
30872
30873 HDNode.fromHex = function(hex) {
30874 return HDNode.fromBuffer(new Buffer(hex, 'hex'))
30875 }
30876
30877 HDNode.prototype.getIdentifier = function() {
30878 return crypto.hash160(this.pubKey.toBuffer())
30879 }
30880
30881 HDNode.prototype.getFingerprint = function() {
30882 return this.getIdentifier().slice(0, 4)
30883 }
30884
30885 HDNode.prototype.getAddress = function() {
30886 return this.pubKey.getAddress(this.network)
30887 }
30888
30889 HDNode.prototype.toBase58 = function(isPrivate) {
30890 return base58check.encode(this.toBuffer(isPrivate))
30891 }
30892
30893 HDNode.prototype.toBuffer = function(isPrivate) {
30894 if (isPrivate == undefined) isPrivate = !!this.privKey
30895
30896 // Version
30897 var version = isPrivate ? this.network.bip32.private : this.network.bip32.public
30898 var buffer = new Buffer(HDNode.LENGTH)
30899
30900 // 4 bytes: version bytes
30901 buffer.writeUInt32BE(version, 0)
30902
30903 // Depth
30904 // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ....
30905 buffer.writeUInt8(this.depth, 4)
30906
30907 // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
30908 var fingerprint = (this.depth === 0) ? 0x00000000 : this.parentFingerprint
30909 buffer.writeUInt32BE(fingerprint, 5)
30910
30911 // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
30912 // This is encoded in Big endian. (0x00000000 if master key)
30913 buffer.writeUInt32BE(this.index, 9)
30914
30915 // 32 bytes: the chain code
30916 this.chainCode.copy(buffer, 13)
30917
30918 // 33 bytes: the public key or private key data
30919 if (isPrivate) {
30920 assert(this.privKey, 'Missing private key')
30921
30922 // 0x00 + k for private keys
30923 buffer.writeUInt8(0, 45)
30924 this.privKey.d.toBuffer(32).copy(buffer, 46)
30925 } else {
30926
30927 // X9.62 encoding for public keys
30928 this.pubKey.toBuffer().copy(buffer, 45)
30929 }
30930
30931 return buffer
30932 }
30933
30934 HDNode.prototype.toHex = function(isPrivate) {
30935 return this.toBuffer(isPrivate).toString('hex')
30936 }
30937
30938 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
30939 HDNode.prototype.derive = function(index) {
30940 var isHardened = index >= HDNode.HIGHEST_BIT
30941 var indexBuffer = new Buffer(4)
30942 indexBuffer.writeUInt32BE(index, 0)
30943
30944 var data
30945
30946 // Hardened child
30947 if (isHardened) {
30948 assert(this.privKey, 'Could not derive hardened child key')
30949
30950 // data = 0x00 || ser256(kpar) || ser32(index)
30951 data = Buffer.concat([
30952 this.privKey.d.toBuffer(33),
30953 indexBuffer
30954 ])
30955
30956 // Normal child
30957 } else {
30958 // data = serP(point(kpar)) || ser32(index)
30959 // = serP(Kpar) || ser32(index)
30960 data = Buffer.concat([
30961 this.pubKey.toBuffer(),
30962 indexBuffer
30963 ])
30964 }
30965
30966 var I = crypto.HmacSHA512(data, this.chainCode)
30967 var IL = I.slice(0, 32)
30968 var IR = I.slice(32)
30969
30970 var pIL = BigInteger.fromBuffer(IL)
30971
30972 // In case parse256(IL) >= n, proceed with the next value for i
30973 if (pIL.compareTo(curve.n) >= 0) {
30974 return this.derive(index + 1)
30975 }
30976
30977 // Private parent key -> private child key
30978 var hd
30979 if (this.privKey) {
30980 // ki = parse256(IL) + kpar (mod n)
30981 var ki = pIL.add(this.privKey.d).mod(curve.n)
30982
30983 // In case ki == 0, proceed with the next value for i
30984 if (ki.signum() === 0) {
30985 return this.derive(index + 1)
30986 }
30987
30988 hd = new HDNode(ki, IR, this.network)
30989
30990 // Public parent key -> public child key
30991 } else {
30992 // Ki = point(parse256(IL)) + Kpar
30993 // = G*IL + Kpar
30994 var Ki = curve.G.multiply(pIL).add(this.pubKey.Q)
30995
30996 // In case Ki is the point at infinity, proceed with the next value for i
30997 if (curve.isInfinity(Ki)) {
30998 return this.derive(index + 1)
30999 }
31000
31001 hd = new HDNode(Ki, IR, this.network)
31002 }
31003
31004 hd.depth = this.depth + 1
31005 hd.index = index
31006 hd.parentFingerprint = this.getFingerprint().readUInt32BE(0)
31007
31008 return hd
31009 }
31010
31011 HDNode.prototype.deriveHardened = function(index) {
31012 // Only derives hardened private keys by default
31013 return this.derive(index + HDNode.HIGHEST_BIT)
31014 }
31015
31016 HDNode.prototype.toString = HDNode.prototype.toBase58
31017
31018 module.exports = HDNode
31019
31020 }).call(this,_dereq_("buffer").Buffer)
31021 },{"./base58check":70,"./crypto":73,"./eckey":75,"./ecpubkey":76,"./networks":81,"assert":4,"bigi":3,"buffer":8,"ecurve":65}],79:[function(_dereq_,module,exports){
31022 module.exports = {
31023 Address: _dereq_('./address'),
31024 base58check: _dereq_('./base58check'),
31025 bufferutils: _dereq_('./bufferutils'),
31026 convert: _dereq_('./convert'),
31027 crypto: _dereq_('./crypto'),
31028 ecdsa: _dereq_('./ecdsa'),
31029 ECKey: _dereq_('./eckey'),
31030 ECPubKey: _dereq_('./ecpubkey'),
31031 ECSignature: _dereq_('./ecsignature'),
31032 Message: _dereq_('./message'),
31033 opcodes: _dereq_('./opcodes'),
31034 HDNode: _dereq_('./hdnode'),
31035 Script: _dereq_('./script'),
31036 scripts: _dereq_('./scripts'),
31037 Transaction: _dereq_('./transaction'),
31038 networks: _dereq_('./networks'),
31039 Wallet: _dereq_('./wallet')
31040 }
31041
31042 },{"./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){
31043 (function (Buffer){
31044 /// Implements Bitcoin's feature for signing arbitrary messages.
31045 var Address = _dereq_('./address')
31046 var BigInteger = _dereq_('bigi')
31047 var bufferutils = _dereq_('./bufferutils')
31048 var crypto = _dereq_('./crypto')
31049 var ecdsa = _dereq_('./ecdsa')
31050 var networks = _dereq_('./networks')
31051
31052 var Address = _dereq_('./address')
31053 var ECPubKey = _dereq_('./ecpubkey')
31054 var ECSignature = _dereq_('./ecsignature')
31055
31056 var ecurve = _dereq_('ecurve')
31057 var ecparams = ecurve.getCurveByName('secp256k1')
31058
31059 function magicHash(message, network) {
31060 var magicPrefix = new Buffer(network.magicPrefix)
31061 var messageBuffer = new Buffer(message)
31062 var lengthBuffer = new Buffer(bufferutils.varIntSize(messageBuffer.length))
31063 bufferutils.writeVarInt(lengthBuffer, messageBuffer.length, 0)
31064
31065 var buffer = Buffer.concat([magicPrefix, lengthBuffer, messageBuffer])
31066 return crypto.hash256(buffer)
31067 }
31068
31069 function sign(privKey, message, network) {
31070 network = network || networks.bitcoin
31071
31072 var hash = magicHash(message, network)
31073 var signature = privKey.sign(hash)
31074 var e = BigInteger.fromBuffer(hash)
31075 var i = ecdsa.calcPubKeyRecoveryParam(ecparams, e, signature, privKey.pub.Q)
31076
31077 return signature.toCompact(i, privKey.pub.compressed)
31078 }
31079
31080 // TODO: network could be implied from address
31081 function verify(address, signatureBuffer, message, network) {
31082 if (address instanceof Address) {
31083 address = address.toString()
31084 }
31085 network = network || networks.bitcoin
31086
31087 var hash = magicHash(message, network)
31088 var parsed = ECSignature.parseCompact(signatureBuffer)
31089 var e = BigInteger.fromBuffer(hash)
31090 var Q = ecdsa.recoverPubKey(ecparams, e, parsed.signature, parsed.i)
31091
31092 var pubKey = new ECPubKey(Q, parsed.compressed)
31093 return pubKey.getAddress(network).toString() === address
31094 }
31095
31096 module.exports = {
31097 magicHash: magicHash,
31098 sign: sign,
31099 verify: verify
31100 }
31101
31102 }).call(this,_dereq_("buffer").Buffer)
31103 },{"./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){
31104 // https://en.bitcoin.it/wiki/List_of_address_prefixes
31105 // Dogecoin BIP32 is a proposed standard: https://bitcointalk.org/index.php?topic=409731
31106
31107 var networks = {
31108 bitcoin: {
31109 magicPrefix: '\x18Bitcoin Signed Message:\n',
31110 bip32: {
31111 public: 0x0488b21e,
31112 private: 0x0488ade4
31113 },
31114 pubKeyHash: 0x00,
31115 scriptHash: 0x05,
31116 wif: 0x80,
31117 dustThreshold: 546, // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/core.h#L151-L162
31118 feePerKb: 10000, // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/main.cpp#L53
31119 estimateFee: estimateFee('bitcoin')
31120 },
31121 dogecoin: {
31122 magicPrefix: '\x19Dogecoin Signed Message:\n',
31123 bip32: {
31124 public: 0x02facafd,
31125 private: 0x02fac398
31126 },
31127 pubKeyHash: 0x1e,
31128 scriptHash: 0x16,
31129 wif: 0x9e,
31130 dustThreshold: 0, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/core.h#L155-L160
31131 dustSoftThreshold: 100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.h#L62
31132 feePerKb: 100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.cpp#L58
31133 estimateFee: estimateFee('dogecoin')
31134 },
31135 litecoin: {
31136 magicPrefix: '\x19Litecoin Signed Message:\n',
31137 bip32: {
31138 public: 0x019da462,
31139 private: 0x019d9cfe
31140 },
31141 pubKeyHash: 0x30,
31142 scriptHash: 0x05,
31143 wif: 0xb0,
31144 dustThreshold: 0, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L360-L365
31145 dustSoftThreshold: 100000, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.h#L53
31146 feePerKb: 100000, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L56
31147 estimateFee: estimateFee('litecoin')
31148 },
31149 testnet: {
31150 magicPrefix: '\x18Bitcoin Signed Message:\n',
31151 bip32: {
31152 public: 0x043587cf,
31153 private: 0x04358394
31154 },
31155 pubKeyHash: 0x6f,
31156 scriptHash: 0xc4,
31157 wif: 0xef,
31158 dustThreshold: 546,
31159 feePerKb: 10000,
31160 estimateFee: estimateFee('testnet')
31161 }
31162 }
31163
31164 function estimateFee(type) {
31165 return function(tx) {
31166 var network = networks[type]
31167 var baseFee = network.feePerKb
31168 var byteSize = tx.toBuffer().length
31169
31170 var fee = baseFee * Math.ceil(byteSize / 1000)
31171 if (network.dustSoftThreshold == undefined) return fee
31172
31173 tx.outs.forEach(function(e){
31174 if (e.value < network.dustSoftThreshold) {
31175 fee += baseFee
31176 }
31177 })
31178
31179 return fee
31180 }
31181 }
31182
31183 module.exports = networks
31184
31185 },{}],82:[function(_dereq_,module,exports){
31186 module.exports = {
31187 // push value
31188 OP_FALSE : 0,
31189 OP_0 : 0,
31190 OP_PUSHDATA1 : 76,
31191 OP_PUSHDATA2 : 77,
31192 OP_PUSHDATA4 : 78,
31193 OP_1NEGATE : 79,
31194 OP_RESERVED : 80,
31195 OP_1 : 81,
31196 OP_TRUE : 81,
31197 OP_2 : 82,
31198 OP_3 : 83,
31199 OP_4 : 84,
31200 OP_5 : 85,
31201 OP_6 : 86,
31202 OP_7 : 87,
31203 OP_8 : 88,
31204 OP_9 : 89,
31205 OP_10 : 90,
31206 OP_11 : 91,
31207 OP_12 : 92,
31208 OP_13 : 93,
31209 OP_14 : 94,
31210 OP_15 : 95,
31211 OP_16 : 96,
31212
31213 // control
31214 OP_NOP : 97,
31215 OP_VER : 98,
31216 OP_IF : 99,
31217 OP_NOTIF : 100,
31218 OP_VERIF : 101,
31219 OP_VERNOTIF : 102,
31220 OP_ELSE : 103,
31221 OP_ENDIF : 104,
31222 OP_VERIFY : 105,
31223 OP_RETURN : 106,
31224
31225 // stack ops
31226 OP_TOALTSTACK : 107,
31227 OP_FROMALTSTACK : 108,
31228 OP_2DROP : 109,
31229 OP_2DUP : 110,
31230 OP_3DUP : 111,
31231 OP_2OVER : 112,
31232 OP_2ROT : 113,
31233 OP_2SWAP : 114,
31234 OP_IFDUP : 115,
31235 OP_DEPTH : 116,
31236 OP_DROP : 117,
31237 OP_DUP : 118,
31238 OP_NIP : 119,
31239 OP_OVER : 120,
31240 OP_PICK : 121,
31241 OP_ROLL : 122,
31242 OP_ROT : 123,
31243 OP_SWAP : 124,
31244 OP_TUCK : 125,
31245
31246 // splice ops
31247 OP_CAT : 126,
31248 OP_SUBSTR : 127,
31249 OP_LEFT : 128,
31250 OP_RIGHT : 129,
31251 OP_SIZE : 130,
31252
31253 // bit logic
31254 OP_INVERT : 131,
31255 OP_AND : 132,
31256 OP_OR : 133,
31257 OP_XOR : 134,
31258 OP_EQUAL : 135,
31259 OP_EQUALVERIFY : 136,
31260 OP_RESERVED1 : 137,
31261 OP_RESERVED2 : 138,
31262
31263 // numeric
31264 OP_1ADD : 139,
31265 OP_1SUB : 140,
31266 OP_2MUL : 141,
31267 OP_2DIV : 142,
31268 OP_NEGATE : 143,
31269 OP_ABS : 144,
31270 OP_NOT : 145,
31271 OP_0NOTEQUAL : 146,
31272
31273 OP_ADD : 147,
31274 OP_SUB : 148,
31275 OP_MUL : 149,
31276 OP_DIV : 150,
31277 OP_MOD : 151,
31278 OP_LSHIFT : 152,
31279 OP_RSHIFT : 153,
31280
31281 OP_BOOLAND : 154,
31282 OP_BOOLOR : 155,
31283 OP_NUMEQUAL : 156,
31284 OP_NUMEQUALVERIFY : 157,
31285 OP_NUMNOTEQUAL : 158,
31286 OP_LESSTHAN : 159,
31287 OP_GREATERTHAN : 160,
31288 OP_LESSTHANOREQUAL : 161,
31289 OP_GREATERTHANOREQUAL : 162,
31290 OP_MIN : 163,
31291 OP_MAX : 164,
31292
31293 OP_WITHIN : 165,
31294
31295 // crypto
31296 OP_RIPEMD160 : 166,
31297 OP_SHA1 : 167,
31298 OP_SHA256 : 168,
31299 OP_HASH160 : 169,
31300 OP_HASH256 : 170,
31301 OP_CODESEPARATOR : 171,
31302 OP_CHECKSIG : 172,
31303 OP_CHECKSIGVERIFY : 173,
31304 OP_CHECKMULTISIG : 174,
31305 OP_CHECKMULTISIGVERIFY : 175,
31306
31307 // expansion
31308 OP_NOP1 : 176,
31309 OP_NOP2 : 177,
31310 OP_NOP3 : 178,
31311 OP_NOP4 : 179,
31312 OP_NOP5 : 180,
31313 OP_NOP6 : 181,
31314 OP_NOP7 : 182,
31315 OP_NOP8 : 183,
31316 OP_NOP9 : 184,
31317 OP_NOP10 : 185,
31318
31319 // template matching params
31320 OP_PUBKEYHASH : 253,
31321 OP_PUBKEY : 254,
31322 OP_INVALIDOPCODE : 255
31323 }
31324
31325 },{}],83:[function(_dereq_,module,exports){
31326 (function (Buffer){
31327 var assert = _dereq_('assert')
31328 var bufferutils = _dereq_('./bufferutils')
31329 var crypto = _dereq_('./crypto')
31330 var opcodes = _dereq_('./opcodes')
31331
31332 function Script(buffer, chunks) {
31333 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)
31334 assert(Array.isArray(chunks), 'Expected Array, got ' + chunks)
31335
31336 this.buffer = buffer
31337 this.chunks = chunks
31338 }
31339
31340 // Import operations
31341 Script.fromASM = function(asm) {
31342 var strChunks = asm.split(' ')
31343
31344 var chunks = strChunks.map(function(strChunk) {
31345 if (strChunk in opcodes) {
31346 return opcodes[strChunk]
31347
31348 } else {
31349 return new Buffer(strChunk, 'hex')
31350 }
31351 })
31352
31353 return Script.fromChunks(chunks)
31354 }
31355
31356 Script.fromBuffer = function(buffer) {
31357 var chunks = []
31358
31359 var i = 0
31360
31361 while (i < buffer.length) {
31362 var opcode = buffer.readUInt8(i)
31363
31364 if ((opcode > opcodes.OP_0) && (opcode <= opcodes.OP_PUSHDATA4)) {
31365 var d = bufferutils.readPushDataInt(buffer, i)
31366 i += d.size
31367
31368 var data = buffer.slice(i, i + d.number)
31369 i += d.number
31370
31371 chunks.push(data)
31372
31373 } else {
31374 chunks.push(opcode)
31375
31376 i += 1
31377 }
31378 }
31379
31380 return new Script(buffer, chunks)
31381 }
31382
31383 Script.fromChunks = function(chunks) {
31384 assert(Array.isArray(chunks), 'Expected Array, got ' + chunks)
31385
31386 var bufferSize = chunks.reduce(function(accum, chunk) {
31387 if (Buffer.isBuffer(chunk)) {
31388 return accum + bufferutils.pushDataSize(chunk.length) + chunk.length
31389 }
31390
31391 return accum + 1
31392 }, 0.0)
31393
31394 var buffer = new Buffer(bufferSize)
31395 var offset = 0
31396
31397 chunks.forEach(function(chunk) {
31398 if (Buffer.isBuffer(chunk)) {
31399 offset += bufferutils.writePushDataInt(buffer, chunk.length, offset)
31400
31401 chunk.copy(buffer, offset)
31402 offset += chunk.length
31403
31404 } else {
31405 buffer.writeUInt8(chunk, offset)
31406 offset += 1
31407 }
31408 })
31409
31410 assert.equal(offset, buffer.length, 'Could not decode chunks')
31411 return new Script(buffer, chunks)
31412 }
31413
31414 Script.fromHex = function(hex) {
31415 return Script.fromBuffer(new Buffer(hex, 'hex'))
31416 }
31417
31418 // Constants
31419 Script.EMPTY = Script.fromChunks([])
31420
31421 // Operations
31422 Script.prototype.getHash = function() {
31423 return crypto.hash160(this.buffer)
31424 }
31425
31426 // FIXME: doesn't work for data chunks, maybe time to use buffertools.compare...
31427 Script.prototype.without = function(needle) {
31428 return Script.fromChunks(this.chunks.filter(function(op) {
31429 return op !== needle
31430 }))
31431 }
31432
31433 // Export operations
31434 var reverseOps = []
31435 for (var op in opcodes) {
31436 var code = opcodes[op]
31437 reverseOps[code] = op
31438 }
31439
31440 Script.prototype.toASM = function() {
31441 return this.chunks.map(function(chunk) {
31442 if (Buffer.isBuffer(chunk)) {
31443 return chunk.toString('hex')
31444
31445 } else {
31446 return reverseOps[chunk]
31447 }
31448 }).join(' ')
31449 }
31450
31451 Script.prototype.toBuffer = function() {
31452 return this.buffer
31453 }
31454
31455 Script.prototype.toHex = function() {
31456 return this.toBuffer().toString('hex')
31457 }
31458
31459 module.exports = Script
31460
31461 }).call(this,_dereq_("buffer").Buffer)
31462 },{"./bufferutils":71,"./crypto":73,"./opcodes":82,"assert":4,"buffer":8}],84:[function(_dereq_,module,exports){
31463 (function (Buffer){
31464 var assert = _dereq_('assert')
31465 var opcodes = _dereq_('./opcodes')
31466
31467 // FIXME: use ECPubKey, currently the circular dependency breaks everything.
31468 //
31469 // Solutions:
31470 // * Remove ECPubKey.getAddress
31471 // - Minimal change, but likely unpopular
31472 // * Move all script related functionality out of Address
31473 // - Means a lot of changes to Transaction/Wallet
31474 // * Ignore it (existing solution)
31475 // * Some form of hackery with commonjs
31476 //
31477 var ecurve = _dereq_('ecurve')
31478 var curve = ecurve.getCurveByName('secp256k1')
31479
31480 var ECSignature = _dereq_('./ecsignature')
31481 var Script = _dereq_('./script')
31482
31483 function classifyOutput(script) {
31484 assert(script instanceof Script, 'Expected Script, got ', script)
31485
31486 if (isPubKeyHashOutput.call(script)) {
31487 return 'pubkeyhash'
31488 } else if (isScriptHashOutput.call(script)) {
31489 return 'scripthash'
31490 } else if (isMultisigOutput.call(script)) {
31491 return 'multisig'
31492 } else if (isPubKeyOutput.call(script)) {
31493 return 'pubkey'
31494 } else if (isNulldataOutput.call(script)) {
31495 return 'nulldata'
31496 } else {
31497 return 'nonstandard'
31498 }
31499 }
31500
31501 function classifyInput(script) {
31502 assert(script instanceof Script, 'Expected Script, got ', script)
31503
31504 if (isPubKeyHashInput.call(script)) {
31505 return 'pubkeyhash'
31506 } else if (isScriptHashInput.call(script)) {
31507 return 'scripthash'
31508 } else if (isMultisigInput.call(script)) {
31509 return 'multisig'
31510 } else if (isPubKeyInput.call(script)) {
31511 return 'pubkey'
31512 } else {
31513 return 'nonstandard'
31514 }
31515 }
31516
31517 function isCanonicalPubKey(buffer) {
31518 if (!Buffer.isBuffer(buffer)) return false
31519
31520 try {
31521 // FIXME: boo
31522 ecurve.Point.decodeFrom(curve, buffer)
31523 } catch (e) {
31524 if (!(e.message.match(/Invalid sequence (length|tag)/))) throw e
31525
31526 return false
31527 }
31528
31529 return true
31530 }
31531
31532 function isCanonicalSignature(buffer) {
31533 if (!Buffer.isBuffer(buffer)) return false
31534
31535 try {
31536 ECSignature.parseScriptSignature(buffer)
31537 } catch(e) {
31538 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
31539
31540 return false
31541 }
31542
31543 return true
31544 }
31545
31546 function isPubKeyHashInput() {
31547 return this.chunks.length === 2 &&
31548 isCanonicalSignature(this.chunks[0]) &&
31549 isCanonicalPubKey(this.chunks[1])
31550 }
31551
31552 function isPubKeyHashOutput() {
31553 return this.chunks.length === 5 &&
31554 this.chunks[0] === opcodes.OP_DUP &&
31555 this.chunks[1] === opcodes.OP_HASH160 &&
31556 Buffer.isBuffer(this.chunks[2]) &&
31557 this.chunks[2].length === 20 &&
31558 this.chunks[3] === opcodes.OP_EQUALVERIFY &&
31559 this.chunks[4] === opcodes.OP_CHECKSIG
31560 }
31561
31562 function isPubKeyInput() {
31563 return this.chunks.length === 1 &&
31564 isCanonicalSignature(this.chunks[0])
31565 }
31566
31567 function isPubKeyOutput() {
31568 return this.chunks.length === 2 &&
31569 isCanonicalPubKey(this.chunks[0]) &&
31570 this.chunks[1] === opcodes.OP_CHECKSIG
31571 }
31572
31573 function isScriptHashInput() {
31574 if (this.chunks.length < 2) return false
31575 var lastChunk = this.chunks[this.chunks.length - 1]
31576
31577 if (!Buffer.isBuffer(lastChunk)) return false
31578
31579 var scriptSig = Script.fromChunks(this.chunks.slice(0, -1))
31580 var scriptPubKey = Script.fromBuffer(lastChunk)
31581
31582 return classifyInput(scriptSig) === classifyOutput(scriptPubKey)
31583 }
31584
31585 function isScriptHashOutput() {
31586 return this.chunks.length === 3 &&
31587 this.chunks[0] === opcodes.OP_HASH160 &&
31588 Buffer.isBuffer(this.chunks[1]) &&
31589 this.chunks[1].length === 20 &&
31590 this.chunks[2] === opcodes.OP_EQUAL
31591 }
31592
31593 function isMultisigInput() {
31594 return this.chunks[0] === opcodes.OP_0 &&
31595 this.chunks.slice(1).every(isCanonicalSignature)
31596 }
31597
31598 function isMultisigOutput() {
31599 if (this.chunks < 4) return false
31600 if (this.chunks[this.chunks.length - 1] !== opcodes.OP_CHECKMULTISIG) return false
31601
31602 var mOp = this.chunks[0]
31603 if (mOp === opcodes.OP_0) return false
31604 if (mOp < opcodes.OP_1) return false
31605 if (mOp > opcodes.OP_16) return false
31606
31607 var nOp = this.chunks[this.chunks.length - 2]
31608 if (nOp === opcodes.OP_0) return false
31609 if (nOp < opcodes.OP_1) return false
31610 if (nOp > opcodes.OP_16) return false
31611
31612 var m = mOp - (opcodes.OP_1 - 1)
31613 var n = nOp - (opcodes.OP_1 - 1)
31614 if (n < m) return false
31615
31616 var pubKeys = this.chunks.slice(1, -2)
31617 if (n < pubKeys.length) return false
31618
31619 return pubKeys.every(isCanonicalPubKey)
31620 }
31621
31622 function isNulldataOutput() {
31623 return this.chunks[0] === opcodes.OP_RETURN
31624 }
31625
31626 // Standard Script Templates
31627 // {pubKey} OP_CHECKSIG
31628 function pubKeyOutput(pubKey) {
31629 return Script.fromChunks([
31630 pubKey.toBuffer(),
31631 opcodes.OP_CHECKSIG
31632 ])
31633 }
31634
31635 // OP_DUP OP_HASH160 {pubKeyHash} OP_EQUALVERIFY OP_CHECKSIG
31636 function pubKeyHashOutput(hash) {
31637 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
31638
31639 return Script.fromChunks([
31640 opcodes.OP_DUP,
31641 opcodes.OP_HASH160,
31642 hash,
31643 opcodes.OP_EQUALVERIFY,
31644 opcodes.OP_CHECKSIG
31645 ])
31646 }
31647
31648 // OP_HASH160 {scriptHash} OP_EQUAL
31649 function scriptHashOutput(hash) {
31650 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
31651
31652 return Script.fromChunks([
31653 opcodes.OP_HASH160,
31654 hash,
31655 opcodes.OP_EQUAL
31656 ])
31657 }
31658
31659 // m [pubKeys ...] n OP_CHECKMULTISIG
31660 function multisigOutput(m, pubKeys) {
31661 assert(Array.isArray(pubKeys), 'Expected Array, got ' + pubKeys)
31662 assert(pubKeys.length >= m, 'Not enough pubKeys provided')
31663
31664 var pubKeyBuffers = pubKeys.map(function(pubKey) {
31665 return pubKey.toBuffer()
31666 })
31667 var n = pubKeys.length
31668
31669 return Script.fromChunks([].concat(
31670 (opcodes.OP_1 - 1) + m,
31671 pubKeyBuffers,
31672 (opcodes.OP_1 - 1) + n,
31673 opcodes.OP_CHECKMULTISIG
31674 ))
31675 }
31676
31677 // {signature}
31678 function pubKeyInput(signature) {
31679 assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
31680
31681 return Script.fromChunks([signature])
31682 }
31683
31684 // {signature} {pubKey}
31685 function pubKeyHashInput(signature, pubKey) {
31686 assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
31687
31688 return Script.fromChunks([signature, pubKey.toBuffer()])
31689 }
31690
31691 // <scriptSig> {serialized scriptPubKey script}
31692 function scriptHashInput(scriptSig, scriptPubKey) {
31693 return Script.fromChunks([].concat(
31694 scriptSig.chunks,
31695 scriptPubKey.toBuffer()
31696 ))
31697 }
31698
31699 // OP_0 [signatures ...]
31700 function multisigInput(signatures, scriptPubKey) {
31701 if (scriptPubKey) {
31702 assert(isMultisigOutput.call(scriptPubKey))
31703
31704 var m = scriptPubKey.chunks[0]
31705 var k = m - (opcodes.OP_1 - 1)
31706 assert(k <= signatures.length, 'Not enough signatures provided')
31707 }
31708
31709 return Script.fromChunks([].concat(opcodes.OP_0, signatures))
31710 }
31711
31712 module.exports = {
31713 classifyInput: classifyInput,
31714 classifyOutput: classifyOutput,
31715 multisigInput: multisigInput,
31716 multisigOutput: multisigOutput,
31717 pubKeyHashInput: pubKeyHashInput,
31718 pubKeyHashOutput: pubKeyHashOutput,
31719 pubKeyInput: pubKeyInput,
31720 pubKeyOutput: pubKeyOutput,
31721 scriptHashInput: scriptHashInput,
31722 scriptHashOutput: scriptHashOutput
31723 }
31724
31725 }).call(this,_dereq_("buffer").Buffer)
31726 },{"./ecsignature":77,"./opcodes":82,"./script":83,"assert":4,"buffer":8,"ecurve":65}],85:[function(_dereq_,module,exports){
31727 (function (Buffer){
31728 var assert = _dereq_('assert')
31729 var bufferutils = _dereq_('./bufferutils')
31730 var crypto = _dereq_('./crypto')
31731 var opcodes = _dereq_('./opcodes')
31732 var scripts = _dereq_('./scripts')
31733
31734 var Address = _dereq_('./address')
31735 var ECKey = _dereq_('./eckey')
31736 var ECSignature = _dereq_('./ecsignature')
31737 var Script = _dereq_('./script')
31738
31739 Transaction.DEFAULT_SEQUENCE = 0xffffffff
31740 Transaction.SIGHASH_ALL = 0x01
31741 Transaction.SIGHASH_NONE = 0x02
31742 Transaction.SIGHASH_SINGLE = 0x03
31743 Transaction.SIGHASH_ANYONECANPAY = 0x80
31744
31745 function Transaction() {
31746 this.version = 1
31747 this.locktime = 0
31748 this.ins = []
31749 this.outs = []
31750 }
31751
31752 /**
31753 * Create a new txin.
31754 *
31755 * Can be called with any of:
31756 *
31757 * - A transaction and an index
31758 * - A transaction hash and an index
31759 *
31760 * Note that this method does not sign the created input.
31761 */
31762 Transaction.prototype.addInput = function(tx, index, sequence) {
31763 if (sequence == undefined) sequence = Transaction.DEFAULT_SEQUENCE
31764
31765 var hash
31766
31767 if (typeof tx === 'string') {
31768 hash = new Buffer(tx, 'hex')
31769
31770 // TxId hex is big-endian, we need little-endian
31771 Array.prototype.reverse.call(hash)
31772
31773 } else if (tx instanceof Transaction) {
31774 hash = tx.getHash()
31775
31776 } else {
31777 hash = tx
31778 }
31779
31780 assert(Buffer.isBuffer(hash), 'Expected Transaction, txId or txHash, got ' + tx)
31781 assert.equal(hash.length, 32, 'Expected hash length of 32, got ' + hash.length)
31782 assert.equal(typeof index, 'number', 'Expected number index, got ' + index)
31783
31784 return (this.ins.push({
31785 hash: hash,
31786 index: index,
31787 script: Script.EMPTY,
31788 sequence: sequence
31789 }) - 1)
31790 }
31791
31792 /**
31793 * Create a new txout.
31794 *
31795 * Can be called with:
31796 *
31797 * - A base58 address string and a value
31798 * - An Address object and a value
31799 * - A scriptPubKey Script and a value
31800 */
31801 Transaction.prototype.addOutput = function(scriptPubKey, value) {
31802 // Attempt to get a valid address if it's a base58 address string
31803 if (typeof scriptPubKey === 'string') {
31804 scriptPubKey = Address.fromBase58Check(scriptPubKey)
31805 }
31806
31807 // Attempt to get a valid script if it's an Address object
31808 if (scriptPubKey instanceof Address) {
31809 var address = scriptPubKey
31810
31811 scriptPubKey = address.toOutputScript()
31812 }
31813
31814 return (this.outs.push({
31815 script: scriptPubKey,
31816 value: value,
31817 }) - 1)
31818 }
31819
31820 Transaction.prototype.toBuffer = function () {
31821 var txInSize = this.ins.reduce(function(a, x) {
31822 return a + (40 + bufferutils.varIntSize(x.script.buffer.length) + x.script.buffer.length)
31823 }, 0)
31824
31825 var txOutSize = this.outs.reduce(function(a, x) {
31826 return a + (8 + bufferutils.varIntSize(x.script.buffer.length) + x.script.buffer.length)
31827 }, 0)
31828
31829 var buffer = new Buffer(
31830 8 +
31831 bufferutils.varIntSize(this.ins.length) +
31832 bufferutils.varIntSize(this.outs.length) +
31833 txInSize +
31834 txOutSize
31835 )
31836
31837 var offset = 0
31838 function writeSlice(slice) {
31839 slice.copy(buffer, offset)
31840 offset += slice.length
31841 }
31842 function writeUInt32(i) {
31843 buffer.writeUInt32LE(i, offset)
31844 offset += 4
31845 }
31846 function writeUInt64(i) {
31847 bufferutils.writeUInt64LE(buffer, i, offset)
31848 offset += 8
31849 }
31850 function writeVarInt(i) {
31851 var n = bufferutils.writeVarInt(buffer, i, offset)
31852 offset += n
31853 }
31854
31855 writeUInt32(this.version)
31856 writeVarInt(this.ins.length)
31857
31858 this.ins.forEach(function(txin) {
31859 writeSlice(txin.hash)
31860 writeUInt32(txin.index)
31861 writeVarInt(txin.script.buffer.length)
31862 writeSlice(txin.script.buffer)
31863 writeUInt32(txin.sequence)
31864 })
31865
31866 writeVarInt(this.outs.length)
31867 this.outs.forEach(function(txout) {
31868 writeUInt64(txout.value)
31869 writeVarInt(txout.script.buffer.length)
31870 writeSlice(txout.script.buffer)
31871 })
31872
31873 writeUInt32(this.locktime)
31874
31875 return buffer
31876 }
31877
31878 Transaction.prototype.toHex = function() {
31879 return this.toBuffer().toString('hex')
31880 }
31881
31882 /**
31883 * Hash transaction for signing a specific input.
31884 *
31885 * Bitcoin uses a different hash for each signed transaction input. This
31886 * method copies the transaction, makes the necessary changes based on the
31887 * hashType, serializes and finally hashes the result. This hash can then be
31888 * used to sign the transaction input in question.
31889 */
31890 Transaction.prototype.hashForSignature = function(prevOutScript, inIndex, hashType) {
31891 assert(inIndex >= 0, 'Invalid vin index')
31892 assert(inIndex < this.ins.length, 'Invalid vin index')
31893 assert(prevOutScript instanceof Script, 'Invalid Script object')
31894
31895 var txTmp = this.clone()
31896 var hashScript = prevOutScript.without(opcodes.OP_CODESEPARATOR)
31897
31898 // Blank out other inputs' signatures
31899 txTmp.ins.forEach(function(txin) {
31900 txin.script = Script.EMPTY
31901 })
31902 txTmp.ins[inIndex].script = hashScript
31903
31904 var hashTypeModifier = hashType & 0x1f
31905 if (hashTypeModifier === Transaction.SIGHASH_NONE) {
31906 assert(false, 'SIGHASH_NONE not yet supported')
31907
31908 } else if (hashTypeModifier === Transaction.SIGHASH_SINGLE) {
31909 assert(false, 'SIGHASH_SINGLE not yet supported')
31910
31911 }
31912
31913 if (hashType & Transaction.SIGHASH_ANYONECANPAY) {
31914 assert(false, 'SIGHASH_ANYONECANPAY not yet supported')
31915 }
31916
31917 var hashTypeBuffer = new Buffer(4)
31918 hashTypeBuffer.writeInt32LE(hashType, 0)
31919
31920 var buffer = Buffer.concat([txTmp.toBuffer(), hashTypeBuffer])
31921 return crypto.hash256(buffer)
31922 }
31923
31924 Transaction.prototype.getHash = function () {
31925 return crypto.hash256(this.toBuffer())
31926 }
31927
31928 Transaction.prototype.getId = function () {
31929 var buffer = this.getHash()
31930
31931 // Big-endian is used for TxHash
31932 Array.prototype.reverse.call(buffer)
31933
31934 return buffer.toString('hex')
31935 }
31936
31937 Transaction.prototype.clone = function () {
31938 var newTx = new Transaction()
31939 newTx.version = this.version
31940 newTx.locktime = this.locktime
31941
31942 newTx.ins = this.ins.map(function(txin) {
31943 return {
31944 hash: txin.hash,
31945 index: txin.index,
31946 script: txin.script,
31947 sequence: txin.sequence
31948 }
31949 })
31950
31951 newTx.outs = this.outs.map(function(txout) {
31952 return {
31953 script: txout.script,
31954 value: txout.value
31955 }
31956 })
31957
31958 return newTx
31959 }
31960
31961 Transaction.fromBuffer = function(buffer) {
31962 var offset = 0
31963 function readSlice(n) {
31964 offset += n
31965 return buffer.slice(offset - n, offset)
31966 }
31967 function readUInt32() {
31968 var i = buffer.readUInt32LE(offset)
31969 offset += 4
31970 return i
31971 }
31972 function readUInt64() {
31973 var i = bufferutils.readUInt64LE(buffer, offset)
31974 offset += 8
31975 return i
31976 }
31977 function readVarInt() {
31978 var vi = bufferutils.readVarInt(buffer, offset)
31979 offset += vi.size
31980 return vi.number
31981 }
31982
31983 var tx = new Transaction()
31984 tx.version = readUInt32()
31985
31986 var vinLen = readVarInt()
31987 for (var i = 0; i < vinLen; ++i) {
31988 var hash = readSlice(32)
31989 var vout = readUInt32()
31990 var scriptLen = readVarInt()
31991 var script = readSlice(scriptLen)
31992 var sequence = readUInt32()
31993
31994 tx.ins.push({
31995 hash: hash,
31996 index: vout,
31997 script: Script.fromBuffer(script),
31998 sequence: sequence
31999 })
32000 }
32001
32002 var voutLen = readVarInt()
32003 for (i = 0; i < voutLen; ++i) {
32004 var value = readUInt64()
32005 var scriptLen = readVarInt()
32006 var script = readSlice(scriptLen)
32007
32008 tx.outs.push({
32009 value: value,
32010 script: Script.fromBuffer(script)
32011 })
32012 }
32013
32014 tx.locktime = readUInt32()
32015 assert.equal(offset, buffer.length, 'Transaction has unexpected data')
32016
32017 return tx
32018 }
32019
32020 Transaction.fromHex = function(hex) {
32021 return Transaction.fromBuffer(new Buffer(hex, 'hex'))
32022 }
32023
32024 /**
32025 * Signs a pubKeyHash output at some index with the given key
32026 */
32027 Transaction.prototype.sign = function(index, privKey, hashType) {
32028 var prevOutScript = privKey.pub.getAddress().toOutputScript()
32029 var signature = this.signInput(index, prevOutScript, privKey, hashType)
32030
32031 // FIXME: Assumed prior TX was pay-to-pubkey-hash
32032 var scriptSig = scripts.pubKeyHashInput(signature, privKey.pub)
32033 this.setInputScript(index, scriptSig)
32034 }
32035
32036 Transaction.prototype.signInput = function(index, prevOutScript, privKey, hashType) {
32037 hashType = hashType || Transaction.SIGHASH_ALL
32038
32039 var hash = this.hashForSignature(prevOutScript, index, hashType)
32040 var signature = privKey.sign(hash)
32041
32042 return signature.toScriptSignature(hashType)
32043 }
32044
32045 Transaction.prototype.setInputScript = function(index, script) {
32046 this.ins[index].script = script
32047 }
32048
32049 // FIXME: could be validateInput(index, prevTxOut, pub)
32050 Transaction.prototype.validateInput = function(index, prevOutScript, pubKey, buffer) {
32051 var parsed = ECSignature.parseScriptSignature(buffer)
32052 var hash = this.hashForSignature(prevOutScript, index, parsed.hashType)
32053
32054 return pubKey.verify(hash, parsed.signature)
32055 }
32056
32057 module.exports = Transaction
32058
32059 }).call(this,_dereq_("buffer").Buffer)
32060 },{"./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){
32061 (function (Buffer){
32062 var assert = _dereq_('assert')
32063 var networks = _dereq_('./networks')
32064 var rng = _dereq_('secure-random')
32065
32066 var Address = _dereq_('./address')
32067 var HDNode = _dereq_('./hdnode')
32068 var Transaction = _dereq_('./transaction')
32069
32070 function Wallet(seed, network) {
32071 network = network || networks.bitcoin
32072
32073 // Stored in a closure to make accidental serialization less likely
32074 var masterkey = null
32075 var me = this
32076 var accountZero = null
32077 var internalAccount = null
32078 var externalAccount = null
32079
32080 // Addresses
32081 this.addresses = []
32082 this.changeAddresses = []
32083
32084 // Transaction output data
32085 this.outputs = {}
32086
32087 // Make a new master key
32088 this.newMasterKey = function(seed) {
32089 seed = seed || new Buffer(rng(32))
32090 masterkey = HDNode.fromSeedBuffer(seed, network)
32091
32092 // HD first-level child derivation method should be hardened
32093 // See https://bitcointalk.org/index.php?topic=405179.msg4415254#msg4415254
32094 accountZero = masterkey.deriveHardened(0)
32095 externalAccount = accountZero.derive(0)
32096 internalAccount = accountZero.derive(1)
32097
32098 me.addresses = []
32099 me.changeAddresses = []
32100
32101 me.outputs = {}
32102 }
32103
32104 this.newMasterKey(seed)
32105
32106 this.generateAddress = function() {
32107 var key = externalAccount.derive(this.addresses.length)
32108 this.addresses.push(key.getAddress().toString())
32109 return this.addresses[this.addresses.length - 1]
32110 }
32111
32112 this.generateChangeAddress = function() {
32113 var key = internalAccount.derive(this.changeAddresses.length)
32114 this.changeAddresses.push(key.getAddress().toString())
32115 return this.changeAddresses[this.changeAddresses.length - 1]
32116 }
32117
32118 this.getBalance = function() {
32119 return this.getUnspentOutputs().reduce(function(memo, output){
32120 return memo + output.value
32121 }, 0)
32122 }
32123
32124 this.getUnspentOutputs = function() {
32125 var utxo = []
32126
32127 for(var key in this.outputs){
32128 var output = this.outputs[key]
32129 if(!output.to) utxo.push(outputToUnspentOutput(output))
32130 }
32131
32132 return utxo
32133 }
32134
32135 this.setUnspentOutputs = function(utxo) {
32136 var outputs = {}
32137
32138 utxo.forEach(function(uo){
32139 validateUnspentOutput(uo)
32140 var o = unspentOutputToOutput(uo)
32141 outputs[o.from] = o
32142 })
32143
32144 this.outputs = outputs
32145 }
32146
32147 function outputToUnspentOutput(output){
32148 var hashAndIndex = output.from.split(":")
32149
32150 return {
32151 hash: hashAndIndex[0],
32152 outputIndex: parseInt(hashAndIndex[1]),
32153 address: output.address,
32154 value: output.value,
32155 pending: output.pending
32156 }
32157 }
32158
32159 function unspentOutputToOutput(o) {
32160 var hash = o.hash
32161 var key = hash + ":" + o.outputIndex
32162 return {
32163 from: key,
32164 address: o.address,
32165 value: o.value,
32166 pending: o.pending
32167 }
32168 }
32169
32170 function validateUnspentOutput(uo) {
32171 var missingField
32172
32173 if (isNullOrUndefined(uo.hash)) {
32174 missingField = "hash"
32175 }
32176
32177 var requiredKeys = ['outputIndex', 'address', 'value']
32178 requiredKeys.forEach(function (key) {
32179 if (isNullOrUndefined(uo[key])){
32180 missingField = key
32181 }
32182 })
32183
32184 if (missingField) {
32185 var message = [
32186 'Invalid unspent output: key', missingField, 'is missing.',
32187 'A valid unspent output must contain'
32188 ]
32189 message.push(requiredKeys.join(', '))
32190 message.push("and hash")
32191 throw new Error(message.join(' '))
32192 }
32193 }
32194
32195 function isNullOrUndefined(value) {
32196 return value == undefined
32197 }
32198
32199 this.processPendingTx = function(tx){
32200 processTx(tx, true)
32201 }
32202
32203 this.processConfirmedTx = function(tx){
32204 processTx(tx, false)
32205 }
32206
32207 function processTx(tx, isPending) {
32208 var txid = tx.getId()
32209
32210 tx.outs.forEach(function(txOut, i) {
32211 var address
32212
32213 try {
32214 address = Address.fromOutputScript(txOut.script, network).toString()
32215 } catch(e) {
32216 if (!(e.message.match(/has no matching Address/))) throw e
32217 }
32218
32219 if (isMyAddress(address)) {
32220 var output = txid + ':' + i
32221
32222 me.outputs[output] = {
32223 from: output,
32224 value: txOut.value,
32225 address: address,
32226 pending: isPending
32227 }
32228 }
32229 })
32230
32231 tx.ins.forEach(function(txIn, i) {
32232 // copy and convert to big-endian hex
32233 var txinId = new Buffer(txIn.hash)
32234 Array.prototype.reverse.call(txinId)
32235 txinId = txinId.toString('hex')
32236
32237 var output = txinId + ':' + txIn.index
32238
32239 if (!(output in me.outputs)) return
32240
32241 if (isPending) {
32242 me.outputs[output].to = txid + ':' + i
32243 me.outputs[output].pending = true
32244 } else {
32245 delete me.outputs[output]
32246 }
32247 })
32248 }
32249
32250 this.createTx = function(to, value, fixedFee, changeAddress) {
32251 assert(value > network.dustThreshold, value + ' must be above dust threshold (' + network.dustThreshold + ' Satoshis)')
32252
32253 var utxos = getCandidateOutputs(value)
32254 var accum = 0
32255 var subTotal = value
32256 var addresses = []
32257
32258 var tx = new Transaction()
32259 tx.addOutput(to, value)
32260
32261 for (var i = 0; i < utxos.length; ++i) {
32262 var utxo = utxos[i]
32263 addresses.push(utxo.address)
32264
32265 var outpoint = utxo.from.split(':')
32266 tx.addInput(outpoint[0], parseInt(outpoint[1]))
32267
32268 var fee = fixedFee == undefined ? estimateFeePadChangeOutput(tx) : fixedFee
32269
32270 accum += utxo.value
32271 subTotal = value + fee
32272 if (accum >= subTotal) {
32273 var change = accum - subTotal
32274
32275 if (change > network.dustThreshold) {
32276 tx.addOutput(changeAddress || getChangeAddress(), change)
32277 }
32278
32279 break
32280 }
32281 }
32282
32283 assert(accum >= subTotal, 'Not enough funds (incl. fee): ' + accum + ' < ' + subTotal)
32284
32285 this.signWith(tx, addresses)
32286 return tx
32287 }
32288
32289 function getCandidateOutputs() {
32290 var unspent = []
32291
32292 for (var key in me.outputs) {
32293 var output = me.outputs[key]
32294 if (!output.pending) unspent.push(output)
32295 }
32296
32297 var sortByValueDesc = unspent.sort(function(o1, o2){
32298 return o2.value - o1.value
32299 })
32300
32301 return sortByValueDesc
32302 }
32303
32304 function estimateFeePadChangeOutput(tx) {
32305 var tmpTx = tx.clone()
32306 tmpTx.addOutput(getChangeAddress(), network.dustSoftThreshold || 0)
32307
32308 return network.estimateFee(tmpTx)
32309 }
32310
32311 function getChangeAddress() {
32312 if(me.changeAddresses.length === 0) me.generateChangeAddress();
32313 return me.changeAddresses[me.changeAddresses.length - 1]
32314 }
32315
32316 this.signWith = function(tx, addresses) {
32317 assert.equal(tx.ins.length, addresses.length, 'Number of addresses must match number of transaction inputs')
32318
32319 addresses.forEach(function(address, i) {
32320 var key = me.getPrivateKeyForAddress(address)
32321
32322 tx.sign(i, key)
32323 })
32324
32325 return tx
32326 }
32327
32328 this.getMasterKey = function() { return masterkey }
32329 this.getAccountZero = function() { return accountZero }
32330 this.getInternalAccount = function() { return internalAccount }
32331 this.getExternalAccount = function() { return externalAccount }
32332
32333 this.getPrivateKey = function(index) {
32334 return externalAccount.derive(index).privKey
32335 }
32336
32337 this.getInternalPrivateKey = function(index) {
32338 return internalAccount.derive(index).privKey
32339 }
32340
32341 this.getPrivateKeyForAddress = function(address) {
32342 var index
32343 if((index = this.addresses.indexOf(address)) > -1) {
32344 return this.getPrivateKey(index)
32345 } else if((index = this.changeAddresses.indexOf(address)) > -1) {
32346 return this.getInternalPrivateKey(index)
32347 } else {
32348 throw new Error('Unknown address. Make sure the address is from the keychain and has been generated.')
32349 }
32350 }
32351
32352 function isReceiveAddress(address){
32353 return me.addresses.indexOf(address) > -1
32354 }
32355
32356 function isChangeAddress(address){
32357 return me.changeAddresses.indexOf(address) > -1
32358 }
32359
32360 function isMyAddress(address) {
32361 return isReceiveAddress(address) || isChangeAddress(address)
32362 }
32363 }
32364
32365 module.exports = Wallet
32366
32367 }).call(this,_dereq_("buffer").Buffer)
32368 },{"./address":69,"./hdnode":78,"./networks":81,"./transaction":85,"assert":4,"buffer":8,"secure-random":68}]},{},[79])
32369 (79)
32370 });
32371 </script>
32372 <script>
32373 // Select components from sjcl to suit the crypto operations bip39 requires.
32374
32375 //// base.js
32376
32377 /** @fileOverview Javascript cryptography implementation.
32378 *
32379 * Crush to remove comments, shorten variable names and
32380 * generally reduce transmission size.
32381 *
32382 * @author Emily Stark
32383 * @author Mike Hamburg
32384 * @author Dan Boneh
32385 */
32386
32387 "use strict";
32388 /*jslint indent: 2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
32389 /*global document, window, escape, unescape, module, require, Uint32Array */
32390
32391 /** @namespace The Stanford Javascript Crypto Library, top-level namespace. */
32392 var sjcl = {
32393 /** @namespace Symmetric ciphers. */
32394 cipher: {},
32395
32396 /** @namespace Hash functions. Right now only SHA256 is implemented. */
32397 hash: {},
32398
32399 /** @namespace Key exchange functions. Right now only SRP is implemented. */
32400 keyexchange: {},
32401
32402 /** @namespace Block cipher modes of operation. */
32403 mode: {},
32404
32405 /** @namespace Miscellaneous. HMAC and PBKDF2. */
32406 misc: {},
32407
32408 /**
32409 * @namespace Bit array encoders and decoders.
32410 *
32411 * @description
32412 * The members of this namespace are functions which translate between
32413 * SJCL's bitArrays and other objects (usually strings). Because it
32414 * isn't always clear which direction is encoding and which is decoding,
32415 * the method names are "fromBits" and "toBits".
32416 */
32417 codec: {},
32418
32419 /** @namespace Exceptions. */
32420 exception: {
32421 /** @constructor Ciphertext is corrupt. */
32422 corrupt: function(message) {
32423 this.toString = function() { return "CORRUPT: "+this.message; };
32424 this.message = message;
32425 },
32426
32427 /** @constructor Invalid parameter. */
32428 invalid: function(message) {
32429 this.toString = function() { return "INVALID: "+this.message; };
32430 this.message = message;
32431 },
32432
32433 /** @constructor Bug or missing feature in SJCL. @constructor */
32434 bug: function(message) {
32435 this.toString = function() { return "BUG: "+this.message; };
32436 this.message = message;
32437 },
32438
32439 /** @constructor Something isn't ready. */
32440 notReady: function(message) {
32441 this.toString = function() { return "NOT READY: "+this.message; };
32442 this.message = message;
32443 }
32444 }
32445 };
32446
32447 if(typeof module !== 'undefined' && module.exports){
32448 module.exports = sjcl;
32449 }
32450 if (typeof define === "function") {
32451 define([], function () {
32452 return sjcl;
32453 });
32454 }
32455
32456
32457 //// bitArray.js
32458
32459 /** @fileOverview Arrays of bits, encoded as arrays of Numbers.
32460 *
32461 * @author Emily Stark
32462 * @author Mike Hamburg
32463 * @author Dan Boneh
32464 */
32465
32466 /** @namespace Arrays of bits, encoded as arrays of Numbers.
32467 *
32468 * @description
32469 * <p>
32470 * These objects are the currency accepted by SJCL's crypto functions.
32471 * </p>
32472 *
32473 * <p>
32474 * Most of our crypto primitives operate on arrays of 4-byte words internally,
32475 * but many of them can take arguments that are not a multiple of 4 bytes.
32476 * This library encodes arrays of bits (whose size need not be a multiple of 8
32477 * bits) as arrays of 32-bit words. The bits are packed, big-endian, into an
32478 * array of words, 32 bits at a time. Since the words are double-precision
32479 * floating point numbers, they fit some extra data. We use this (in a private,
32480 * possibly-changing manner) to encode the number of bits actually present
32481 * in the last word of the array.
32482 * </p>
32483 *
32484 * <p>
32485 * Because bitwise ops clear this out-of-band data, these arrays can be passed
32486 * to ciphers like AES which want arrays of words.
32487 * </p>
32488 */
32489 sjcl.bitArray = {
32490 /**
32491 * Array slices in units of bits.
32492 * @param {bitArray} a The array to slice.
32493 * @param {Number} bstart The offset to the start of the slice, in bits.
32494 * @param {Number} bend The offset to the end of the slice, in bits. If this is undefined,
32495 * slice until the end of the array.
32496 * @return {bitArray} The requested slice.
32497 */
32498 bitSlice: function (a, bstart, bend) {
32499 a = sjcl.bitArray._shiftRight(a.slice(bstart/32), 32 - (bstart & 31)).slice(1);
32500 return (bend === undefined) ? a : sjcl.bitArray.clamp(a, bend-bstart);
32501 },
32502
32503 /**
32504 * Extract a number packed into a bit array.
32505 * @param {bitArray} a The array to slice.
32506 * @param {Number} bstart The offset to the start of the slice, in bits.
32507 * @param {Number} length The length of the number to extract.
32508 * @return {Number} The requested slice.
32509 */
32510 extract: function(a, bstart, blength) {
32511 // FIXME: this Math.floor is not necessary at all, but for some reason
32512 // seems to suppress a bug in the Chromium JIT.
32513 var x, sh = Math.floor((-bstart-blength) & 31);
32514 if ((bstart + blength - 1 ^ bstart) & -32) {
32515 // it crosses a boundary
32516 x = (a[bstart/32|0] << (32 - sh)) ^ (a[bstart/32+1|0] >>> sh);
32517 } else {
32518 // within a single word
32519 x = a[bstart/32|0] >>> sh;
32520 }
32521 return x & ((1<<blength) - 1);
32522 },
32523
32524 /**
32525 * Concatenate two bit arrays.
32526 * @param {bitArray} a1 The first array.
32527 * @param {bitArray} a2 The second array.
32528 * @return {bitArray} The concatenation of a1 and a2.
32529 */
32530 concat: function (a1, a2) {
32531 if (a1.length === 0 || a2.length === 0) {
32532 return a1.concat(a2);
32533 }
32534
32535 var last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last);
32536 if (shift === 32) {
32537 return a1.concat(a2);
32538 } else {
32539 return sjcl.bitArray._shiftRight(a2, shift, last|0, a1.slice(0,a1.length-1));
32540 }
32541 },
32542
32543 /**
32544 * Find the length of an array of bits.
32545 * @param {bitArray} a The array.
32546 * @return {Number} The length of a, in bits.
32547 */
32548 bitLength: function (a) {
32549 var l = a.length, x;
32550 if (l === 0) { return 0; }
32551 x = a[l - 1];
32552 return (l-1) * 32 + sjcl.bitArray.getPartial(x);
32553 },
32554
32555 /**
32556 * Truncate an array.
32557 * @param {bitArray} a The array.
32558 * @param {Number} len The length to truncate to, in bits.
32559 * @return {bitArray} A new array, truncated to len bits.
32560 */
32561 clamp: function (a, len) {
32562 if (a.length * 32 < len) { return a; }
32563 a = a.slice(0, Math.ceil(len / 32));
32564 var l = a.length;
32565 len = len & 31;
32566 if (l > 0 && len) {
32567 a[l-1] = sjcl.bitArray.partial(len, a[l-1] & 0x80000000 >> (len-1), 1);
32568 }
32569 return a;
32570 },
32571
32572 /**
32573 * Make a partial word for a bit array.
32574 * @param {Number} len The number of bits in the word.
32575 * @param {Number} x The bits.
32576 * @param {Number} [0] _end Pass 1 if x has already been shifted to the high side.
32577 * @return {Number} The partial word.
32578 */
32579 partial: function (len, x, _end) {
32580 if (len === 32) { return x; }
32581 return (_end ? x|0 : x << (32-len)) + len * 0x10000000000;
32582 },
32583
32584 /**
32585 * Get the number of bits used by a partial word.
32586 * @param {Number} x The partial word.
32587 * @return {Number} The number of bits used by the partial word.
32588 */
32589 getPartial: function (x) {
32590 return Math.round(x/0x10000000000) || 32;
32591 },
32592
32593 /**
32594 * Compare two arrays for equality in a predictable amount of time.
32595 * @param {bitArray} a The first array.
32596 * @param {bitArray} b The second array.
32597 * @return {boolean} true if a == b; false otherwise.
32598 */
32599 equal: function (a, b) {
32600 if (sjcl.bitArray.bitLength(a) !== sjcl.bitArray.bitLength(b)) {
32601 return false;
32602 }
32603 var x = 0, i;
32604 for (i=0; i<a.length; i++) {
32605 x |= a[i]^b[i];
32606 }
32607 return (x === 0);
32608 },
32609
32610 /** Shift an array right.
32611 * @param {bitArray} a The array to shift.
32612 * @param {Number} shift The number of bits to shift.
32613 * @param {Number} [carry=0] A byte to carry in
32614 * @param {bitArray} [out=[]] An array to prepend to the output.
32615 * @private
32616 */
32617 _shiftRight: function (a, shift, carry, out) {
32618 var i, last2=0, shift2;
32619 if (out === undefined) { out = []; }
32620
32621 for (; shift >= 32; shift -= 32) {
32622 out.push(carry);
32623 carry = 0;
32624 }
32625 if (shift === 0) {
32626 return out.concat(a);
32627 }
32628
32629 for (i=0; i<a.length; i++) {
32630 out.push(carry | a[i]>>>shift);
32631 carry = a[i] << (32-shift);
32632 }
32633 last2 = a.length ? a[a.length-1] : 0;
32634 shift2 = sjcl.bitArray.getPartial(last2);
32635 out.push(sjcl.bitArray.partial(shift+shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(),1));
32636 return out;
32637 },
32638
32639 /** xor a block of 4 words together.
32640 * @private
32641 */
32642 _xor4: function(x,y) {
32643 return [x[0]^y[0],x[1]^y[1],x[2]^y[2],x[3]^y[3]];
32644 },
32645
32646 /** byteswap a word array inplace.
32647 * (does not handle partial words)
32648 * @param {sjcl.bitArray} a word array
32649 * @return {sjcl.bitArray} byteswapped array
32650 */
32651 byteswapM: function(a) {
32652 var i, v, m = 0xff00;
32653 for (i = 0; i < a.length; ++i) {
32654 v = a[i];
32655 a[i] = (v >>> 24) | ((v >>> 8) & m) | ((v & m) << 8) | (v << 24);
32656 }
32657 return a;
32658 }
32659 };
32660
32661
32662 //// codecString.js
32663
32664 /** @fileOverview Bit array codec implementations.
32665 *
32666 * @author Emily Stark
32667 * @author Mike Hamburg
32668 * @author Dan Boneh
32669 */
32670
32671 /** @namespace UTF-8 strings */
32672 sjcl.codec.utf8String = {
32673 /** Convert from a bitArray to a UTF-8 string. */
32674 fromBits: function (arr) {
32675 var out = "", bl = sjcl.bitArray.bitLength(arr), i, tmp;
32676 for (i=0; i<bl/8; i++) {
32677 if ((i&3) === 0) {
32678 tmp = arr[i/4];
32679 }
32680 out += String.fromCharCode(tmp >>> 24);
32681 tmp <<= 8;
32682 }
32683 return decodeURIComponent(escape(out));
32684 },
32685
32686 /** Convert from a UTF-8 string to a bitArray. */
32687 toBits: function (str) {
32688 str = unescape(encodeURIComponent(str));
32689 var out = [], i, tmp=0;
32690 for (i=0; i<str.length; i++) {
32691 tmp = tmp << 8 | str.charCodeAt(i);
32692 if ((i&3) === 3) {
32693 out.push(tmp);
32694 tmp = 0;
32695 }
32696 }
32697 if (i&3) {
32698 out.push(sjcl.bitArray.partial(8*(i&3), tmp));
32699 }
32700 return out;
32701 }
32702 };
32703
32704
32705 //// codecHex.js
32706
32707 /** @fileOverview Bit array codec implementations.
32708 *
32709 * @author Emily Stark
32710 * @author Mike Hamburg
32711 * @author Dan Boneh
32712 */
32713
32714 /** @namespace Hexadecimal */
32715 sjcl.codec.hex = {
32716 /** Convert from a bitArray to a hex string. */
32717 fromBits: function (arr) {
32718 var out = "", i;
32719 for (i=0; i<arr.length; i++) {
32720 out += ((arr[i]|0)+0xF00000000000).toString(16).substr(4);
32721 }
32722 return out.substr(0, sjcl.bitArray.bitLength(arr)/4);//.replace(/(.{8})/g, "$1 ");
32723 },
32724 /** Convert from a hex string to a bitArray. */
32725 toBits: function (str) {
32726 var i, out=[], len;
32727 str = str.replace(/\s|0x/g, "");
32728 len = str.length;
32729 str = str + "00000000";
32730 for (i=0; i<str.length; i+=8) {
32731 out.push(parseInt(str.substr(i,8),16)^0);
32732 }
32733 return sjcl.bitArray.clamp(out, len*4);
32734 }
32735 };
32736
32737
32738 //// sha512.js
32739
32740 /** @fileOverview Javascript SHA-512 implementation.
32741 *
32742 * This implementation was written for CryptoJS by Jeff Mott and adapted for
32743 * SJCL by Stefan Thomas.
32744 *
32745 * CryptoJS (c) 2009–2012 by Jeff Mott. All rights reserved.
32746 * Released with New BSD License
32747 *
32748 * @author Emily Stark
32749 * @author Mike Hamburg
32750 * @author Dan Boneh
32751 * @author Jeff Mott
32752 * @author Stefan Thomas
32753 */
32754
32755 /**
32756 * Context for a SHA-512 operation in progress.
32757 * @constructor
32758 * @class Secure Hash Algorithm, 512 bits.
32759 */
32760 sjcl.hash.sha512 = function (hash) {
32761 if (!this._key[0]) { this._precompute(); }
32762 if (hash) {
32763 this._h = hash._h.slice(0);
32764 this._buffer = hash._buffer.slice(0);
32765 this._length = hash._length;
32766 } else {
32767 this.reset();
32768 }
32769 };
32770
32771 /**
32772 * Hash a string or an array of words.
32773 * @static
32774 * @param {bitArray|String} data the data to hash.
32775 * @return {bitArray} The hash value, an array of 16 big-endian words.
32776 */
32777 sjcl.hash.sha512.hash = function (data) {
32778 return (new sjcl.hash.sha512()).update(data).finalize();
32779 };
32780
32781 sjcl.hash.sha512.prototype = {
32782 /**
32783 * The hash's block size, in bits.
32784 * @constant
32785 */
32786 blockSize: 1024,
32787
32788 /**
32789 * Reset the hash state.
32790 * @return this
32791 */
32792 reset:function () {
32793 this._h = this._init.slice(0);
32794 this._buffer = [];
32795 this._length = 0;
32796 return this;
32797 },
32798
32799 /**
32800 * Input several words to the hash.
32801 * @param {bitArray|String} data the data to hash.
32802 * @return this
32803 */
32804 update: function (data) {
32805 if (typeof data === "string") {
32806 data = sjcl.codec.utf8String.toBits(data);
32807 }
32808 var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
32809 ol = this._length,
32810 nl = this._length = ol + sjcl.bitArray.bitLength(data);
32811 for (i = 1024+ol & -1024; i <= nl; i+= 1024) {
32812 this._block(b.splice(0,32));
32813 }
32814 return this;
32815 },
32816
32817 /**
32818 * Complete hashing and output the hash value.
32819 * @return {bitArray} The hash value, an array of 16 big-endian words.
32820 */
32821 finalize:function () {
32822 var i, b = this._buffer, h = this._h;
32823
32824 // Round out and push the buffer
32825 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);
32826
32827 // Round out the buffer to a multiple of 32 words, less the 4 length words.
32828 for (i = b.length + 4; i & 31; i++) {
32829 b.push(0);
32830 }
32831
32832 // append the length
32833 b.push(0);
32834 b.push(0);
32835 b.push(Math.floor(this._length / 0x100000000));
32836 b.push(this._length | 0);
32837
32838 while (b.length) {
32839 this._block(b.splice(0,32));
32840 }
32841
32842 this.reset();
32843 return h;
32844 },
32845
32846 /**
32847 * The SHA-512 initialization vector, to be precomputed.
32848 * @private
32849 */
32850 _init:[],
32851
32852 /**
32853 * Least significant 24 bits of SHA512 initialization values.
32854 *
32855 * Javascript only has 53 bits of precision, so we compute the 40 most
32856 * significant bits and add the remaining 24 bits as constants.
32857 *
32858 * @private
32859 */
32860 _initr: [ 0xbcc908, 0xcaa73b, 0x94f82b, 0x1d36f1, 0xe682d1, 0x3e6c1f, 0x41bd6b, 0x7e2179 ],
32861
32862 /*
32863 _init:
32864 [0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,
32865 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179],
32866 */
32867
32868 /**
32869 * The SHA-512 hash key, to be precomputed.
32870 * @private
32871 */
32872 _key:[],
32873
32874 /**
32875 * Least significant 24 bits of SHA512 key values.
32876 * @private
32877 */
32878 _keyr:
32879 [0x28ae22, 0xef65cd, 0x4d3b2f, 0x89dbbc, 0x48b538, 0x05d019, 0x194f9b, 0x6d8118,
32880 0x030242, 0x706fbe, 0xe4b28c, 0xffb4e2, 0x7b896f, 0x1696b1, 0xc71235, 0x692694,
32881 0xf14ad2, 0x4f25e3, 0x8cd5b5, 0xac9c65, 0x2b0275, 0xa6e483, 0x41fbd4, 0x1153b5,
32882 0x66dfab, 0xb43210, 0xfb213f, 0xef0ee4, 0xa88fc2, 0x0aa725, 0x03826f, 0x0e6e70,
32883 0xd22ffc, 0x26c926, 0xc42aed, 0x95b3df, 0xaf63de, 0x77b2a8, 0xedaee6, 0x82353b,
32884 0xf10364, 0x423001, 0xf89791, 0x54be30, 0xef5218, 0x65a910, 0x71202a, 0xbbd1b8,
32885 0xd2d0c8, 0x41ab53, 0x8eeb99, 0x9b48a8, 0xc95a63, 0x418acb, 0x63e373, 0xb2b8a3,
32886 0xefb2fc, 0x172f60, 0xf0ab72, 0x6439ec, 0x631e28, 0x82bde9, 0xc67915, 0x72532b,
32887 0x26619c, 0xc0c207, 0xe0eb1e, 0x6ed178, 0x176fba, 0xc898a6, 0xf90dae, 0x1c471b,
32888 0x047d84, 0xc72493, 0xc9bebc, 0x100d4c, 0x3e42b6, 0x657e2a, 0xd6faec, 0x475817],
32889
32890 /*
32891 _key:
32892 [0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
32893 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
32894 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
32895 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
32896 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
32897 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
32898 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
32899 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
32900 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
32901 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
32902 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
32903 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
32904 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
32905 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
32906 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
32907 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
32908 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
32909 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
32910 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
32911 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817],
32912 */
32913
32914 /**
32915 * Function to precompute _init and _key.
32916 * @private
32917 */
32918 _precompute: function () {
32919 // XXX: This code is for precomputing the SHA256 constants, change for
32920 // SHA512 and re-enable.
32921 var i = 0, prime = 2, factor;
32922
32923 function frac(x) { return (x-Math.floor(x)) * 0x100000000 | 0; }
32924 function frac2(x) { return (x-Math.floor(x)) * 0x10000000000 & 0xff; }
32925
32926 outer: for (; i<80; prime++) {
32927 for (factor=2; factor*factor <= prime; factor++) {
32928 if (prime % factor === 0) {
32929 // not a prime
32930 continue outer;
32931 }
32932 }
32933
32934 if (i<8) {
32935 this._init[i*2] = frac(Math.pow(prime, 1/2));
32936 this._init[i*2+1] = (frac2(Math.pow(prime, 1/2)) << 24) | this._initr[i];
32937 }
32938 this._key[i*2] = frac(Math.pow(prime, 1/3));
32939 this._key[i*2+1] = (frac2(Math.pow(prime, 1/3)) << 24) | this._keyr[i];
32940 i++;
32941 }
32942 },
32943
32944 /**
32945 * Perform one cycle of SHA-512.
32946 * @param {bitArray} words one block of words.
32947 * @private
32948 */
32949 _block:function (words) {
32950 var i, wrh, wrl,
32951 w = words.slice(0),
32952 h = this._h,
32953 k = this._key,
32954 h0h = h[ 0], h0l = h[ 1], h1h = h[ 2], h1l = h[ 3],
32955 h2h = h[ 4], h2l = h[ 5], h3h = h[ 6], h3l = h[ 7],
32956 h4h = h[ 8], h4l = h[ 9], h5h = h[10], h5l = h[11],
32957 h6h = h[12], h6l = h[13], h7h = h[14], h7l = h[15];
32958
32959 // Working variables
32960 var ah = h0h, al = h0l, bh = h1h, bl = h1l,
32961 ch = h2h, cl = h2l, dh = h3h, dl = h3l,
32962 eh = h4h, el = h4l, fh = h5h, fl = h5l,
32963 gh = h6h, gl = h6l, hh = h7h, hl = h7l;
32964
32965 for (i=0; i<80; i++) {
32966 // load up the input word for this round
32967 if (i<16) {
32968 wrh = w[i * 2];
32969 wrl = w[i * 2 + 1];
32970 } else {
32971 // Gamma0
32972 var gamma0xh = w[(i-15) * 2];
32973 var gamma0xl = w[(i-15) * 2 + 1];
32974 var gamma0h =
32975 ((gamma0xl << 31) | (gamma0xh >>> 1)) ^
32976 ((gamma0xl << 24) | (gamma0xh >>> 8)) ^
32977 (gamma0xh >>> 7);
32978 var gamma0l =
32979 ((gamma0xh << 31) | (gamma0xl >>> 1)) ^
32980 ((gamma0xh << 24) | (gamma0xl >>> 8)) ^
32981 ((gamma0xh << 25) | (gamma0xl >>> 7));
32982
32983 // Gamma1
32984 var gamma1xh = w[(i-2) * 2];
32985 var gamma1xl = w[(i-2) * 2 + 1];
32986 var gamma1h =
32987 ((gamma1xl << 13) | (gamma1xh >>> 19)) ^
32988 ((gamma1xh << 3) | (gamma1xl >>> 29)) ^
32989 (gamma1xh >>> 6);
32990 var gamma1l =
32991 ((gamma1xh << 13) | (gamma1xl >>> 19)) ^
32992 ((gamma1xl << 3) | (gamma1xh >>> 29)) ^
32993 ((gamma1xh << 26) | (gamma1xl >>> 6));
32994
32995 // Shortcuts
32996 var wr7h = w[(i-7) * 2];
32997 var wr7l = w[(i-7) * 2 + 1];
32998
32999 var wr16h = w[(i-16) * 2];
33000 var wr16l = w[(i-16) * 2 + 1];
33001
33002 // W(round) = gamma0 + W(round - 7) + gamma1 + W(round - 16)
33003 wrl = gamma0l + wr7l;
33004 wrh = gamma0h + wr7h + ((wrl >>> 0) < (gamma0l >>> 0) ? 1 : 0);
33005 wrl += gamma1l;
33006 wrh += gamma1h + ((wrl >>> 0) < (gamma1l >>> 0) ? 1 : 0);
33007 wrl += wr16l;
33008 wrh += wr16h + ((wrl >>> 0) < (wr16l >>> 0) ? 1 : 0);
33009 }
33010
33011 w[i*2] = wrh |= 0;
33012 w[i*2 + 1] = wrl |= 0;
33013
33014 // Ch
33015 var chh = (eh & fh) ^ (~eh & gh);
33016 var chl = (el & fl) ^ (~el & gl);
33017
33018 // Maj
33019 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
33020 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
33021
33022 // Sigma0
33023 var sigma0h = ((al << 4) | (ah >>> 28)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
33024 var sigma0l = ((ah << 4) | (al >>> 28)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
33025
33026 // Sigma1
33027 var sigma1h = ((el << 18) | (eh >>> 14)) ^ ((el << 14) | (eh >>> 18)) ^ ((eh << 23) | (el >>> 9));
33028 var sigma1l = ((eh << 18) | (el >>> 14)) ^ ((eh << 14) | (el >>> 18)) ^ ((el << 23) | (eh >>> 9));
33029
33030 // K(round)
33031 var krh = k[i*2];
33032 var krl = k[i*2+1];
33033
33034 // t1 = h + sigma1 + ch + K(round) + W(round)
33035 var t1l = hl + sigma1l;
33036 var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
33037 t1l += chl;
33038 t1h += chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
33039 t1l += krl;
33040 t1h += krh + ((t1l >>> 0) < (krl >>> 0) ? 1 : 0);
33041 t1l = t1l + wrl|0; // FF32..FF34 perf issue https://bugzilla.mozilla.org/show_bug.cgi?id=1054972
33042 t1h += wrh + ((t1l >>> 0) < (wrl >>> 0) ? 1 : 0);
33043
33044 // t2 = sigma0 + maj
33045 var t2l = sigma0l + majl;
33046 var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
33047
33048 // Update working variables
33049 hh = gh;
33050 hl = gl;
33051 gh = fh;
33052 gl = fl;
33053 fh = eh;
33054 fl = el;
33055 el = (dl + t1l) | 0;
33056 eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
33057 dh = ch;
33058 dl = cl;
33059 ch = bh;
33060 cl = bl;
33061 bh = ah;
33062 bl = al;
33063 al = (t1l + t2l) | 0;
33064 ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
33065 }
33066
33067 // Intermediate hash
33068 h0l = h[1] = (h0l + al) | 0;
33069 h[0] = (h0h + ah + ((h0l >>> 0) < (al >>> 0) ? 1 : 0)) | 0;
33070 h1l = h[3] = (h1l + bl) | 0;
33071 h[2] = (h1h + bh + ((h1l >>> 0) < (bl >>> 0) ? 1 : 0)) | 0;
33072 h2l = h[5] = (h2l + cl) | 0;
33073 h[4] = (h2h + ch + ((h2l >>> 0) < (cl >>> 0) ? 1 : 0)) | 0;
33074 h3l = h[7] = (h3l + dl) | 0;
33075 h[6] = (h3h + dh + ((h3l >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
33076 h4l = h[9] = (h4l + el) | 0;
33077 h[8] = (h4h + eh + ((h4l >>> 0) < (el >>> 0) ? 1 : 0)) | 0;
33078 h5l = h[11] = (h5l + fl) | 0;
33079 h[10] = (h5h + fh + ((h5l >>> 0) < (fl >>> 0) ? 1 : 0)) | 0;
33080 h6l = h[13] = (h6l + gl) | 0;
33081 h[12] = (h6h + gh + ((h6l >>> 0) < (gl >>> 0) ? 1 : 0)) | 0;
33082 h7l = h[15] = (h7l + hl) | 0;
33083 h[14] = (h7h + hh + ((h7l >>> 0) < (hl >>> 0) ? 1 : 0)) | 0;
33084 }
33085 };
33086
33087
33088 //// hmac.js
33089
33090 /** @fileOverview HMAC implementation.
33091 *
33092 * @author Emily Stark
33093 * @author Mike Hamburg
33094 * @author Dan Boneh
33095 */
33096
33097 /** HMAC with the specified hash function.
33098 * @constructor
33099 * @param {bitArray} key the key for HMAC.
33100 * @param {Object} [hash=sjcl.hash.sha256] The hash function to use.
33101 */
33102 sjcl.misc.hmac = function (key, Hash) {
33103 this._hash = Hash = Hash || sjcl.hash.sha256;
33104 var exKey = [[],[]], i,
33105 bs = Hash.prototype.blockSize / 32;
33106 this._baseHash = [new Hash(), new Hash()];
33107
33108 if (key.length > bs) {
33109 key = Hash.hash(key);
33110 }
33111
33112 for (i=0; i<bs; i++) {
33113 exKey[0][i] = key[i]^0x36363636;
33114 exKey[1][i] = key[i]^0x5C5C5C5C;
33115 }
33116
33117 this._baseHash[0].update(exKey[0]);
33118 this._baseHash[1].update(exKey[1]);
33119 this._resultHash = new Hash(this._baseHash[0]);
33120 };
33121
33122 /** HMAC with the specified hash function. Also called encrypt since it's a prf.
33123 * @param {bitArray|String} data The data to mac.
33124 */
33125 sjcl.misc.hmac.prototype.encrypt = sjcl.misc.hmac.prototype.mac = function (data) {
33126 if (!this._updated) {
33127 this.update(data);
33128 return this.digest(data);
33129 } else {
33130 throw new sjcl.exception.invalid("encrypt on already updated hmac called!");
33131 }
33132 };
33133
33134 sjcl.misc.hmac.prototype.reset = function () {
33135 this._resultHash = new this._hash(this._baseHash[0]);
33136 this._updated = false;
33137 };
33138
33139 sjcl.misc.hmac.prototype.update = function (data) {
33140 this._updated = true;
33141 this._resultHash.update(data);
33142 };
33143
33144 sjcl.misc.hmac.prototype.digest = function () {
33145 var w = this._resultHash.finalize(), result = new (this._hash)(this._baseHash[1]).update(w).finalize();
33146
33147 this.reset();
33148
33149 return result;
33150 };
33151
33152
33153 //// pbkdf2.js
33154
33155
33156 /** @fileOverview Password-based key-derivation function, version 2.0.
33157 *
33158 * @author Emily Stark
33159 * @author Mike Hamburg
33160 * @author Dan Boneh
33161 */
33162
33163 /** Password-Based Key-Derivation Function, version 2.0.
33164 *
33165 * Generate keys from passwords using PBKDF2-HMAC-SHA256.
33166 *
33167 * This is the method specified by RSA's PKCS #5 standard.
33168 *
33169 * @param {bitArray|String} password The password.
33170 * @param {bitArray|String} salt The salt. Should have lots of entropy.
33171 * @param {Number} [count=1000] The number of iterations. Higher numbers make the function slower but more secure.
33172 * @param {Number} [length] The length of the derived key. Defaults to the
33173 output size of the hash function.
33174 * @param {Object} [Prff=sjcl.misc.hmac] The pseudorandom function family.
33175 * @return {bitArray} the derived key.
33176 */
33177 sjcl.misc.pbkdf2 = function (password, salt, count, length, Prff) {
33178 count = count || 1000;
33179
33180 if (length < 0 || count < 0) {
33181 throw sjcl.exception.invalid("invalid params to pbkdf2");
33182 }
33183
33184 if (typeof password === "string") {
33185 password = sjcl.codec.utf8String.toBits(password);
33186 }
33187
33188 if (typeof salt === "string") {
33189 salt = sjcl.codec.utf8String.toBits(salt);
33190 }
33191
33192 Prff = Prff || sjcl.misc.hmac;
33193
33194 var prf = new Prff(password),
33195 u, ui, i, j, k, out = [], b = sjcl.bitArray;
33196
33197 for (k = 1; 32 * out.length < (length || 1); k++) {
33198 u = ui = prf.encrypt(b.concat(salt,[k]));
33199
33200 for (i=1; i<count; i++) {
33201 ui = prf.encrypt(ui);
33202 for (j=0; j<ui.length; j++) {
33203 u[j] ^= ui[j];
33204 }
33205 }
33206
33207 out = out.concat(u);
33208 }
33209
33210 if (length) { out = b.clamp(out, length); }
33211
33212 return out;
33213 };
33214
33215
33216 //// sha256.js
33217
33218 /** @fileOverview Javascript SHA-256 implementation.
33219 *
33220 * An older version of this implementation is available in the public
33221 * domain, but this one is (c) Emily Stark, Mike Hamburg, Dan Boneh,
33222 * Stanford University 2008-2010 and BSD-licensed for liability
33223 * reasons.
33224 *
33225 * Special thanks to Aldo Cortesi for pointing out several bugs in
33226 * this code.
33227 *
33228 * @author Emily Stark
33229 * @author Mike Hamburg
33230 * @author Dan Boneh
33231 */
33232
33233 /**
33234 * Context for a SHA-256 operation in progress.
33235 * @constructor
33236 * @class Secure Hash Algorithm, 256 bits.
33237 */
33238 sjcl.hash.sha256 = function (hash) {
33239 if (!this._key[0]) { this._precompute(); }
33240 if (hash) {
33241 this._h = hash._h.slice(0);
33242 this._buffer = hash._buffer.slice(0);
33243 this._length = hash._length;
33244 } else {
33245 this.reset();
33246 }
33247 };
33248
33249 /**
33250 * Hash a string or an array of words.
33251 * @static
33252 * @param {bitArray|String} data the data to hash.
33253 * @return {bitArray} The hash value, an array of 16 big-endian words.
33254 */
33255 sjcl.hash.sha256.hash = function (data) {
33256 return (new sjcl.hash.sha256()).update(data).finalize();
33257 };
33258
33259 sjcl.hash.sha256.prototype = {
33260 /**
33261 * The hash's block size, in bits.
33262 * @constant
33263 */
33264 blockSize: 512,
33265
33266 /**
33267 * Reset the hash state.
33268 * @return this
33269 */
33270 reset:function () {
33271 this._h = this._init.slice(0);
33272 this._buffer = [];
33273 this._length = 0;
33274 return this;
33275 },
33276
33277 /**
33278 * Input several words to the hash.
33279 * @param {bitArray|String} data the data to hash.
33280 * @return this
33281 */
33282 update: function (data) {
33283 if (typeof data === "string") {
33284 data = sjcl.codec.utf8String.toBits(data);
33285 }
33286 var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
33287 ol = this._length,
33288 nl = this._length = ol + sjcl.bitArray.bitLength(data);
33289 for (i = 512+ol & -512; i <= nl; i+= 512) {
33290 this._block(b.splice(0,16));
33291 }
33292 return this;
33293 },
33294
33295 /**
33296 * Complete hashing and output the hash value.
33297 * @return {bitArray} The hash value, an array of 8 big-endian words.
33298 */
33299 finalize:function () {
33300 var i, b = this._buffer, h = this._h;
33301
33302 // Round out and push the buffer
33303 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);
33304
33305 // Round out the buffer to a multiple of 16 words, less the 2 length words.
33306 for (i = b.length + 2; i & 15; i++) {
33307 b.push(0);
33308 }
33309
33310 // append the length
33311 b.push(Math.floor(this._length / 0x100000000));
33312 b.push(this._length | 0);
33313
33314 while (b.length) {
33315 this._block(b.splice(0,16));
33316 }
33317
33318 this.reset();
33319 return h;
33320 },
33321
33322 /**
33323 * The SHA-256 initialization vector, to be precomputed.
33324 * @private
33325 */
33326 _init:[],
33327 /*
33328 _init:[0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19],
33329 */
33330
33331 /**
33332 * The SHA-256 hash key, to be precomputed.
33333 * @private
33334 */
33335 _key:[],
33336 /*
33337 _key:
33338 [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
33339 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
33340 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
33341 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
33342 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
33343 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
33344 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
33345 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2],
33346 */
33347
33348
33349 /**
33350 * Function to precompute _init and _key.
33351 * @private
33352 */
33353 _precompute: function () {
33354 var i = 0, prime = 2, factor;
33355
33356 function frac(x) { return (x-Math.floor(x)) * 0x100000000 | 0; }
33357
33358 outer: for (; i<64; prime++) {
33359 for (factor=2; factor*factor <= prime; factor++) {
33360 if (prime % factor === 0) {
33361 // not a prime
33362 continue outer;
33363 }
33364 }
33365
33366 if (i<8) {
33367 this._init[i] = frac(Math.pow(prime, 1/2));
33368 }
33369 this._key[i] = frac(Math.pow(prime, 1/3));
33370 i++;
33371 }
33372 },
33373
33374 /**
33375 * Perform one cycle of SHA-256.
33376 * @param {bitArray} words one block of words.
33377 * @private
33378 */
33379 _block:function (words) {
33380 var i, tmp, a, b,
33381 w = words.slice(0),
33382 h = this._h,
33383 k = this._key,
33384 h0 = h[0], h1 = h[1], h2 = h[2], h3 = h[3],
33385 h4 = h[4], h5 = h[5], h6 = h[6], h7 = h[7];
33386
33387 /* Rationale for placement of |0 :
33388 * If a value can overflow is original 32 bits by a factor of more than a few
33389 * million (2^23 ish), there is a possibility that it might overflow the
33390 * 53-bit mantissa and lose precision.
33391 *
33392 * To avoid this, we clamp back to 32 bits by |'ing with 0 on any value that
33393 * propagates around the loop, and on the hash state h[]. I don't believe
33394 * that the clamps on h4 and on h0 are strictly necessary, but it's close
33395 * (for h4 anyway), and better safe than sorry.
33396 *
33397 * The clamps on h[] are necessary for the output to be correct even in the
33398 * common case and for short inputs.
33399 */
33400 for (i=0; i<64; i++) {
33401 // load up the input word for this round
33402 if (i<16) {
33403 tmp = w[i];
33404 } else {
33405 a = w[(i+1 ) & 15];
33406 b = w[(i+14) & 15];
33407 tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) +
33408 (b>>>17 ^ b>>>19 ^ b>>>10 ^ b<<15 ^ b<<13) +
33409 w[i&15] + w[(i+9) & 15]) | 0;
33410 }
33411
33412 tmp = (tmp + h7 + (h4>>>6 ^ h4>>>11 ^ h4>>>25 ^ h4<<26 ^ h4<<21 ^ h4<<7) + (h6 ^ h4&(h5^h6)) + k[i]); // | 0;
33413
33414 // shift register
33415 h7 = h6; h6 = h5; h5 = h4;
33416 h4 = h3 + tmp | 0;
33417 h3 = h2; h2 = h1; h1 = h0;
33418
33419 h0 = (tmp + ((h1&h2) ^ (h3&(h1^h2))) + (h1>>>2 ^ h1>>>13 ^ h1>>>22 ^ h1<<30 ^ h1<<19 ^ h1<<10)) | 0;
33420 }
33421
33422 h[0] = h[0]+h0 | 0;
33423 h[1] = h[1]+h1 | 0;
33424 h[2] = h[2]+h2 | 0;
33425 h[3] = h[3]+h3 | 0;
33426 h[4] = h[4]+h4 | 0;
33427 h[5] = h[5]+h5 | 0;
33428 h[6] = h[6]+h6 | 0;
33429 h[7] = h[7]+h7 | 0;
33430 }
33431 };
33432 </script>
33433 <script>
33434 WORDLISTS = typeof WORDLISTS == "undefined" ? {} : WORDLISTS;
33435 WORDLISTS["english"] = [
33436 "abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse",
33437 "access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act",
33438 "action","actor","actress","actual","adapt","add","addict","address","adjust","admit",
33439 "adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent",
33440 "agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert",
33441 "alien","all","alley","allow","almost","alone","alpha","already","also","alter",
33442 "always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger",
33443 "angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique",
33444 "anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic",
33445 "area","arena","argue","arm","armed","armor","army","around","arrange","arrest",
33446 "arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset",
33447 "assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction",
33448 "audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake",
33449 "aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge",
33450 "bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain",
33451 "barrel","base","basic","basket","battle","beach","bean","beauty","because","become",
33452 "beef","before","begin","behave","behind","believe","below","belt","bench","benefit",
33453 "best","betray","better","between","beyond","bicycle","bid","bike","bind","biology",
33454 "bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless",
33455 "blind","blood","blossom","blouse","blue","blur","blush","board","boat","body",
33456 "boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss",
33457 "bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread",
33458 "breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze",
33459 "broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb",
33460 "bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy",
33461 "butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call",
33462 "calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas",
33463 "canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry",
33464 "cart","case","cash","casino","castle","casual","cat","catalog","catch","category",
33465 "cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century",
33466 "cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase",
33467 "chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child",
33468 "chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle",
33469 "citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk",
33470 "clever","click","client","cliff","climb","clinic","clip","clock","clog","close",
33471 "cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut",
33472 "code","coffee","coil","coin","collect","color","column","combine","come","comfort",
33473 "comic","common","company","concert","conduct","confirm","congress","connect","consider","control",
33474 "convince","cook","cool","copper","copy","coral","core","corn","correct","cost",
33475 "cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle",
33476 "craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek",
33477 "crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial",
33478 "cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup",
33479 "cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad",
33480 "damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal",
33481 "debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense",
33482 "define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny",
33483 "depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk",
33484 "despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond",
33485 "diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur",
33486 "direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance",
33487 "divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain",
33488 "donate","donkey","donor","door","dose","double","dove","draft","dragon","drama",
33489 "drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop",
33490 "drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf",
33491 "dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo",
33492 "ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow",
33493 "elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody",
33494 "embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless",
33495 "endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough",
33496 "enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip",
33497 "era","erase","erode","erosion","error","erupt","escape","essay","essence","estate",
33498 "eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange",
33499 "excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit",
33500 "exotic","expand","expect","expire","explain","expose","express","extend","extra","eye",
33501 "eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame",
33502 "family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father",
33503 "fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female",
33504 "fence","festival","fetch","fever","few","fiber","fiction","field","figure","file",
33505 "film","filter","final","find","fine","finger","finish","fire","firm","first",
33506 "fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor",
33507 "flee","flight","flip","float","flock","floor","flower","fluid","flush","fly",
33508 "foam","focus","fog","foil","fold","follow","food","foot","force","forest",
33509 "forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile",
33510 "frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen",
33511 "fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy",
33512 "gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp",
33513 "gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture",
33514 "ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance",
33515 "glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue",
33516 "goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown",
33517 "grab","grace","grain","grant","grape","grass","gravity","great","green","grid",
33518 "grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt",
33519 "guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy",
33520 "harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health",
33521 "heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden",
33522 "high","hill","hint","hip","hire","history","hobby","hockey","hold","hole",
33523 "holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital",
33524 "host","hotel","hour","hover","hub","huge","human","humble","humor","hundred",
33525 "hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea",
33526 "identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune",
33527 "impact","impose","improve","impulse","inch","include","income","increase","index","indicate",
33528 "indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury",
33529 "inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install",
33530 "intact","interest","into","invest","invite","involve","iron","island","isolate","issue",
33531 "item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel",
33532 "job","join","joke","journey","joy","judge","juice","jump","jungle","junior",
33533 "junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney",
33534 "kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife",
33535 "knock","know","lab","label","labor","ladder","lady","lake","lamp","language",
33536 "laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit",
33537 "layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal",
33538 "legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level",
33539 "liar","liberty","library","license","life","lift","light","like","limb","limit",
33540 "link","lion","liquid","list","little","live","lizard","load","loan","lobster",
33541 "local","lock","logic","lonely","long","loop","lottery","loud","lounge","love",
33542 "loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad",
33543 "magic","magnet","maid","mail","main","major","make","mammal","man","manage",
33544 "mandate","mango","mansion","manual","maple","marble","march","margin","marine","market",
33545 "marriage","mask","mass","master","match","material","math","matrix","matter","maximum",
33546 "maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt",
33547 "member","memory","mention","menu","mercy","merge","merit","merry","mesh","message",
33548 "metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor",
33549 "minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile",
33550 "model","modify","mom","moment","monitor","monkey","monster","month","moon","moral",
33551 "more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie",
33552 "much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual",
33553 "myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature",
33554 "near","neck","need","negative","neglect","neither","nephew","nerve","nest","net",
33555 "network","neutral","never","news","next","nice","night","noble","noise","nominee",
33556 "noodle","normal","north","nose","notable","note","nothing","notice","novel","now",
33557 "nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe",
33558 "obtain","obvious","occur","ocean","october","odor","off","offer","office","often",
33559 "oil","okay","old","olive","olympic","omit","once","one","onion","online",
33560 "only","open","opera","opinion","oppose","option","orange","orbit","orchard","order",
33561 "ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output",
33562 "outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact",
33563 "paddle","page","pair","palace","palm","panda","panel","panic","panther","paper",
33564 "parade","parent","park","parrot","party","pass","patch","path","patient","patrol",
33565 "pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen",
33566 "penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo",
33567 "phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot",
33568 "pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate",
33569 "play","please","pledge","pluck","plug","plunge","poem","poet","point","polar",
33570 "pole","police","pond","pony","pool","popular","portion","position","possible","post",
33571 "potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare",
33572 "present","pretty","prevent","price","pride","primary","print","priority","prison","private",
33573 "prize","problem","process","produce","profit","program","project","promote","proof","property",
33574 "prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin",
33575 "punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle",
33576 "pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit",
33577 "raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp",
33578 "ranch","random","range","rapid","rare","rate","rather","raven","raw","razor",
33579 "ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle",
33580 "reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release",
33581 "relief","rely","remain","remember","remind","remove","render","renew","rent","reopen",
33582 "repair","repeat","replace","report","require","rescue","resemble","resist","resource","response",
33583 "result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib",
33584 "ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot",
33585 "ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket",
33586 "romance","roof","rookie","room","rose","rotate","rough","round","route","royal",
33587 "rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness",
33588 "safe","sail","salad","salmon","salon","salt","salute","same","sample","sand",
33589 "satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter",
33590 "scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script",
33591 "scrub","sea","search","season","seat","second","secret","section","security","seed",
33592 "seek","segment","select","sell","seminar","senior","sense","sentence","series","service",
33593 "session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell",
33594 "sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop",
33595 "short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side",
33596 "siege","sight","sign","silent","silk","silly","silver","similar","simple","since",
33597 "sing","siren","sister","situate","six","size","skate","sketch","ski","skill",
33598 "skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight",
33599 "slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth",
33600 "snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda",
33601 "soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry",
33602 "sort","soul","sound","soup","source","south","space","spare","spatial","spawn",
33603 "speak","special","speed","spell","spend","sphere","spice","spider","spike","spin",
33604 "spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring",
33605 "spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp",
33606 "stand","start","state","stay","steak","steel","stem","step","stereo","stick",
33607 "still","sting","stock","stomach","stone","stool","story","stove","strategy","street",
33608 "strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway",
33609 "success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny",
33610 "sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey",
33611 "suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim",
33612 "swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag",
33613 "tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi",
33614 "teach","team","tell","ten","tenant","tennis","tent","term","test","text",
33615 "thank","that","theme","then","theory","there","they","thing","this","thought",
33616 "three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber",
33617 "time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler",
33618 "toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool",
33619 "tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist",
33620 "toward","tower","town","toy","track","trade","traffic","tragic","train","transfer",
33621 "trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick",
33622 "trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust",
33623 "truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle",
33624 "twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella",
33625 "unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform",
33626 "unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade",
33627 "uphold","upon","upper","upset","urban","urge","usage","use","used","useful",
33628 "useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van",
33629 "vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue",
33630 "verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory",
33631 "video","view","village","vintage","violin","virtual","virus","visa","visit","visual",
33632 "vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage",
33633 "wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash",
33634 "wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather",
33635 "web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat",
33636 "wheel","when","where","whip","whisper","wide","width","wife","wild","will",
33637 "win","window","wine","wing","wink","winner","winter","wire","wisdom","wise",
33638 "wish","witness","wolf","woman","wonder","wood","wool","word","work","world",
33639 "worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year",
33640 "yellow","you","young","youth","zebra","zero","zone","zoo"]
33641 </script>
33642 <script>
33643 /*
33644 * Copyright (c) 2013 Pavol Rusnak
33645 *
33646 * Permission is hereby granted, free of charge, to any person obtaining a copy of
33647 * this software and associated documentation files (the "Software"), to deal in
33648 * the Software without restriction, including without limitation the rights to
33649 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
33650 * of the Software, and to permit persons to whom the Software is furnished to do
33651 * so, subject to the following conditions:
33652 *
33653 * The above copyright notice and this permission notice shall be included in all
33654 * copies or substantial portions of the Software.
33655 *
33656 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33657 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33658 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33659 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33660 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33661 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33662 */
33663
33664 /*
33665 * Javascript port from python by Ian Coleman
33666 *
33667 * Requires code from sjcl
33668 * https://github.com/bitwiseshiftleft/sjcl
33669 */
33670
33671 var Mnemonic = function(language) {
33672
33673 var PBKDF2_ROUNDS = 2048;
33674 var RADIX = 2048;
33675
33676 var self = this;
33677 var wordlist = [];
33678
33679 var hmacSHA512 = function(key) {
33680 var hasher = new sjcl.misc.hmac(key, sjcl.hash.sha512);
33681 this.encrypt = function() {
33682 return hasher.encrypt.apply(hasher, arguments);
33683 };
33684 };
33685
33686 function init() {
33687 wordlist = WORDLISTS[language];
33688 if (wordlist.length != RADIX) {
33689 err = 'Wordlist should contain ' + RADIX + ' words, but it contains ' + wordlist.length + ' words.';
33690 throw err;
33691 }
33692 }
33693
33694 self.generate = function(strength) {
33695 strength = strength || 128;
33696 var r = strength % 32;
33697 if (r > 0) {
33698 throw 'Strength should be divisible by 32, but it is not (' + r + ').';
33699 }
33700 var hasStrongCrypto = 'crypto' in window && window['crypto'] !== null;
33701 if (!hasStrongCrypto) {
33702 throw 'Mnemonic should be generated with strong randomness, but crypto.getRandomValues is unavailable';
33703 }
33704 var buffer = new Uint8Array(strength / 8);
33705 var data = crypto.getRandomValues(buffer);
33706 return self.toMnemonic(data);
33707 }
33708
33709 self.toMnemonic = function(byteArray) {
33710 if (byteArray.length % 4 > 0) {
33711 throw 'Data length in bits should be divisible by 32, but it is not (' + byteArray.length + ' bytes = ' + byteArray.length*8 + ' bits).'
33712 }
33713
33714 //h = hashlib.sha256(data).hexdigest()
33715 var data = byteArrayToWordArray(byteArray);
33716 var hash = sjcl.hash.sha256.hash(data);
33717 var h = sjcl.codec.hex.fromBits(hash);
33718
33719 // b is a binary string, eg '00111010101100...'
33720 //b = bin(int(binascii.hexlify(data), 16))[2:].zfill(len(data) * 8) + \
33721 // bin(int(h, 16))[2:].zfill(256)[:len(data) * 8 / 32]
33722 //
33723 // a = bin(int(binascii.hexlify(data), 16))[2:].zfill(len(data) * 8)
33724 // c = bin(int(h, 16))[2:].zfill(256)
33725 // d = c[:len(data) * 8 / 32]
33726 var a = byteArrayToBinaryString(byteArray);
33727 var c = zfill(hexStringToBinaryString(h), 256);
33728 var d = c.substring(0, byteArray.length * 8 / 32);
33729 // b = line1 + line2
33730 var b = a + d;
33731
33732 var result = [];
33733 var blen = b.length / 11;
33734 for (var i=0; i<blen; i++) {
33735 var idx = parseInt(b.substring(i * 11, (i + 1) * 11), 2);
33736 result.push(wordlist[idx]);
33737 }
33738 return result.join(' ');
33739 }
33740
33741 self.check = function(mnemonic) {
33742 var mnemonic = mnemonic.split(' ')
33743 if (mnemonic.length % 3 > 0) {
33744 return false
33745 }
33746 // idx = map(lambda x: bin(self.wordlist.index(x))[2:].zfill(11), mnemonic)
33747 var idx = [];
33748 for (var i=0; i<mnemonic.length; i++) {
33749 var word = mnemonic[i];
33750 var wordIndex = wordlist.indexOf(word);
33751 if (wordIndex == -1) {
33752 return false;
33753 }
33754 var binaryIndex = zfill(wordIndex.toString(2), 11);
33755 idx.push(binaryIndex);
33756 }
33757 var b = idx.join('');
33758 var l = b.length;
33759 //d = b[:l / 33 * 32]
33760 //h = b[-l / 33:]
33761 var d = b.substring(0, l / 33 * 32);
33762 var h = b.substring(l - l / 33, l);
33763 //nd = binascii.unhexlify(hex(int(d, 2))[2:].rstrip('L').zfill(l / 33 * 8))
33764 var nd = binaryStringToWordArray(d);
33765 //nh = bin(int(hashlib.sha256(nd).hexdigest(), 16))[2:].zfill(256)[:l / 33]
33766 var ndHash = sjcl.hash.sha256.hash(nd);
33767 var ndHex = sjcl.codec.hex.fromBits(ndHash);
33768 var ndBstr = zfill(hexStringToBinaryString(ndHex), 256);
33769 var nh = ndBstr.substring(0,l/33);
33770 return h == nh;
33771 }
33772
33773 self.toSeed = function(mnemonic, passphrase) {
33774 passphrase = passphrase || '';
33775 mnemonic = self.normalizeString(mnemonic)
33776 passphrase = self.normalizeString(passphrase)
33777 passphrase = "mnemonic" + passphrase;
33778 var mnemonicBits = sjcl.codec.utf8String.toBits(mnemonic);
33779 var passphraseBits = sjcl.codec.utf8String.toBits(passphrase);
33780 var result = sjcl.misc.pbkdf2(mnemonicBits, passphraseBits, PBKDF2_ROUNDS, 512, hmacSHA512);
33781 var hashHex = sjcl.codec.hex.fromBits(result);
33782 return hashHex;
33783 }
33784
33785 self.normalizeString = function(str) {
33786 if (typeof str.normalize == "function") {
33787 return str.normalize("NFKD");
33788 }
33789 else {
33790 // TODO decide how to handle this in the future.
33791 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
33792 return str;
33793 }
33794 }
33795
33796 function byteArrayToWordArray(data) {
33797 var a = [];
33798 for (var i=0; i<data.length/4; i++) {
33799 v = 0;
33800 v += data[i*4 + 0] << 8 * 3;
33801 v += data[i*4 + 1] << 8 * 2;
33802 v += data[i*4 + 2] << 8 * 1;
33803 v += data[i*4 + 3] << 8 * 0;
33804 a.push(v);
33805 }
33806 return a;
33807 }
33808
33809 function byteArrayToBinaryString(data) {
33810 var bin = "";
33811 for (var i=0; i<data.length; i++) {
33812 bin += zfill(data[i].toString(2), 8);
33813 }
33814 return bin;
33815 }
33816
33817 function hexStringToBinaryString(hexString) {
33818 binaryString = "";
33819 for (var i=0; i<hexString.length; i++) {
33820 binaryString += zfill(parseInt(hexString[i], 16).toString(2),4);
33821 }
33822 return binaryString;
33823 }
33824
33825 function binaryStringToWordArray(binary) {
33826 var aLen = binary.length / 32;
33827 var a = [];
33828 for (var i=0; i<aLen; i++) {
33829 var valueStr = binary.substring(0,32);
33830 var value = parseInt(valueStr, 2);
33831 a.push(value);
33832 binary = binary.slice(32);
33833 }
33834 return a;
33835 }
33836
33837 // Pad a numeric string on the left with zero digits until the given width
33838 // is reached.
33839 // Note this differs to the python implementation because it does not
33840 // handle numbers starting with a sign.
33841 function zfill(source, length) {
33842 source = source.toString();
33843 while (source.length < length) {
33844 source = '0' + source;
33845 }
33846 return source;
33847 }
33848
33849 init();
33850
33851 }
33852 </script>
33853 <script>
33854 (function() {
33855
33856 var mnemonic = new Mnemonic("english");
33857 var bip32RootKey = null;
33858 var bip32ExtendedKey = null;
33859 var network = Bitcoin.networks.bitcoin;
33860 var addressRowTemplate = $("#address-row-template");
33861
33862 var showIndex = true;
33863 var showAddress = true;
33864 var showPrivKey = true;
33865
33866 var phraseChangeTimeoutEvent = null;
33867
33868 var DOM = {};
33869 DOM.network = $(".network");
33870 DOM.phraseNetwork = $("#network-phrase");
33871 DOM.phrase = $(".phrase");
33872 DOM.passphrase = $(".passphrase");
33873 DOM.generate = $(".generate");
33874 DOM.rootKey = $(".root-key");
33875 DOM.extendedPrivKey = $(".extended-priv-key");
33876 DOM.extendedPubKey = $(".extended-pub-key");
33877 DOM.bip32tab = $("#bip32-tab");
33878 DOM.bip44tab = $("#bip44-tab");
33879 DOM.bip32panel = $("#bip32");
33880 DOM.bip44panel = $("#bip44");
33881 DOM.bip32path = $("#bip32-path");
33882 DOM.bip44path = $("#bip44-path");
33883 DOM.bip44purpose = $("#bip44 .purpose");
33884 DOM.bip44coin = $("#bip44 .coin");
33885 DOM.bip44account = $("#bip44 .account");
33886 DOM.bip44change = $("#bip44 .change");
33887 DOM.strength = $(".strength");
33888 DOM.addresses = $(".addresses");
33889 DOM.rowsToAdd = $(".rows-to-add");
33890 DOM.more = $(".more");
33891 DOM.feedback = $(".feedback");
33892 DOM.tab = $(".derivation-type a");
33893 DOM.indexToggle = $(".index-toggle");
33894 DOM.addressToggle = $(".address-toggle");
33895 DOM.privateKeyToggle = $(".private-key-toggle");
33896
33897 var derivationPath = $(".tab-pane.active .path").val();
33898
33899 function init() {
33900 // Events
33901 DOM.network.on("change", networkChanged);
33902 DOM.phrase.on("input", delayedPhraseChanged);
33903 DOM.passphrase.on("input", delayedPhraseChanged);
33904 DOM.generate.on("click", generateClicked);
33905 DOM.more.on("click", showMore);
33906 DOM.bip32path.on("input", bip32Changed);
33907 DOM.bip44purpose.on("input", bip44Changed);
33908 DOM.bip44coin.on("input", bip44Changed);
33909 DOM.bip44account.on("input", bip44Changed);
33910 DOM.bip44change.on("input", bip44Changed);
33911 DOM.tab.on("click", tabClicked);
33912 DOM.indexToggle.on("click", toggleIndexes);
33913 DOM.addressToggle.on("click", toggleAddresses);
33914 DOM.privateKeyToggle.on("click", togglePrivateKeys);
33915 disableForms();
33916 hidePending();
33917 hideValidationError();
33918 }
33919
33920 // Event handlers
33921
33922 function networkChanged(e) {
33923 var n = e.target.value;
33924 if (n == "bitcoin") {
33925 network = Bitcoin.networks.bitcoin;
33926 DOM.bip44coin.val(0);
33927 }
33928 else if (n == "bitcoin-testnet") {
33929 network = Bitcoin.networks.testnet;
33930 DOM.bip44coin.val(1);
33931 }
33932 else if (n == "litecoin") {
33933 network = Bitcoin.networks.litecoin;
33934 DOM.bip44coin.val(2);
33935 }
33936 else if (n == "dogecoin") {
33937 network = Bitcoin.networks.dogecoin;
33938 var UNOFFICIAL_BIP44_COIN = 9999;
33939 DOM.bip44coin.val(UNOFFICIAL_BIP44_COIN); // This coin is not in BIP44
33940 }
33941 setBip44DerivationPath();
33942 delayedPhraseChanged();
33943 }
33944
33945 function delayedPhraseChanged() {
33946 hideValidationError();
33947 showPending();
33948 if (phraseChangeTimeoutEvent != null) {
33949 clearTimeout(phraseChangeTimeoutEvent);
33950 }
33951 phraseChangeTimeoutEvent = setTimeout(phraseChanged, 400);
33952 }
33953
33954 function phraseChanged() {
33955 showPending();
33956 hideValidationError();
33957 // Get the mnemonic phrase
33958 var phrase = DOM.phrase.val();
33959 var passphrase = DOM.passphrase.val();
33960 var errorText = findPhraseErrors(phrase);
33961 if (errorText) {
33962 showValidationError(errorText);
33963 return;
33964 }
33965 // Get the derivation path
33966 var errorText = findDerivationPathErrors();
33967 if (errorText) {
33968 showValidationError(errorText);
33969 return;
33970 }
33971 // Calculate and display
33972 calcBip32Seed(phrase, passphrase, derivationPath);
33973 displayBip32Info();
33974 hidePending();
33975 }
33976
33977 function generateClicked() {
33978 clearDisplay();
33979 showPending();
33980 setTimeout(function() {
33981 var phrase = generateRandomPhrase();
33982 if (!phrase) {
33983 return;
33984 }
33985 phraseChanged();
33986 }, 50);
33987 }
33988
33989 function tabClicked(e) {
33990 var activePath = $(e.target.getAttribute("href") + " .path");
33991 derivationPath = activePath.val();
33992 derivationChanged();
33993 }
33994
33995 function derivationChanged() {
33996 delayedPhraseChanged();
33997 }
33998
33999 function bip32Changed() {
34000 derivationPath = DOM.bip32path.val();
34001 derivationChanged();
34002 }
34003
34004 function bip44Changed() {
34005 setBip44DerivationPath();
34006 derivationPath = DOM.bip44path.val();
34007 derivationChanged();
34008 }
34009
34010 function toggleIndexes() {
34011 showIndex = !showIndex;
34012 $("td.index span").toggleClass("invisible");
34013 }
34014
34015 function toggleAddresses() {
34016 showAddress = !showAddress;
34017 $("td.address span").toggleClass("invisible");
34018 }
34019
34020 function togglePrivateKeys() {
34021 showPrivKey = !showPrivKey;
34022 $("td.privkey span").toggleClass("invisible");
34023 }
34024
34025 // Private methods
34026
34027 function generateRandomPhrase() {
34028 if (!hasStrongRandom()) {
34029 var errorText = "This browser does not support strong randomness";
34030 showValidationError(errorText);
34031 return;
34032 }
34033 var numWords = parseInt(DOM.strength.val());
34034 // Check strength is an integer
34035 if (isNaN(numWords)) {
34036 DOM.strength.val("12");
34037 numWords = 12;
34038 }
34039 // Check strength is a multiple of 32, if not round it down
34040 if (numWords % 3 != 0) {
34041 numWords = Math.floor(numWords / 3) * 3;
34042 DOM.strength.val(numWords);
34043 }
34044 // Check strength is at least 32
34045 if (numWords == 0) {
34046 numWords = 3;
34047 DOM.strength.val(numWords);
34048 }
34049 var strength = numWords / 3 * 32;
34050 var words = mnemonic.generate(strength);
34051 DOM.phrase.val(words);
34052 return words;
34053 }
34054
34055 function calcBip32Seed(phrase, passphrase, path) {
34056 var seed = mnemonic.toSeed(phrase, passphrase);
34057 bip32RootKey = Bitcoin.HDNode.fromSeedHex(seed, network);
34058 bip32ExtendedKey = bip32RootKey;
34059 // Derive the key from the path
34060 var pathBits = path.split("/");
34061 for (var i=0; i<pathBits.length; i++) {
34062 var bit = pathBits[i];
34063 var index = parseInt(bit);
34064 if (isNaN(index)) {
34065 continue;
34066 }
34067 var hardened = bit[bit.length-1] == "'";
34068 if (hardened) {
34069 bip32ExtendedKey = bip32ExtendedKey.deriveHardened(index);
34070 }
34071 else {
34072 bip32ExtendedKey = bip32ExtendedKey.derive(index);
34073 }
34074 }
34075 }
34076
34077 function showValidationError(errorText) {
34078 DOM.feedback
34079 .text(errorText)
34080 .show();
34081 }
34082
34083 function hideValidationError() {
34084 DOM.feedback
34085 .text("")
34086 .hide();
34087 }
34088
34089 function findPhraseErrors(phrase) {
34090 // TODO make this right
34091 // Preprocess the words
34092 phrase = mnemonic.normalizeString(phrase);
34093 var parts = phrase.split(" ");
34094 var proper = [];
34095 for (var i=0; i<parts.length; i++) {
34096 var part = parts[i];
34097 if (part.length > 0) {
34098 // TODO check that lowercasing is always valid to do
34099 proper.push(part.toLowerCase());
34100 }
34101 }
34102 // TODO some levenstein on the words
34103 var properPhrase = proper.join(' ');
34104 // Check the words are valid
34105 var isValid = mnemonic.check(properPhrase);
34106 if (!isValid) {
34107 return "Invalid mnemonic";
34108 }
34109 return false;
34110 }
34111
34112 function findDerivationPathErrors(path) {
34113 // TODO
34114 return false;
34115 }
34116
34117 function displayBip32Info() {
34118 // Display the key
34119 var rootKey = bip32RootKey.toBase58();
34120 DOM.rootKey.val(rootKey);
34121 var extendedPrivKey = bip32ExtendedKey.toBase58();
34122 DOM.extendedPrivKey.val(extendedPrivKey);
34123 var extendedPubKey = bip32ExtendedKey.toBase58(false);
34124 DOM.extendedPubKey.val(extendedPubKey);
34125 // Display the addresses and privkeys
34126 clearAddressesList();
34127 displayAddresses(0, 20);
34128 }
34129
34130 function displayAddresses(start, total) {
34131 for (var i=0; i<total; i++) {
34132 var index = i + start;
34133 new TableRow(index);
34134 }
34135 }
34136
34137 function TableRow(index) {
34138
34139 function init() {
34140 calculateValues();
34141 }
34142
34143 function calculateValues() {
34144 setTimeout(function() {
34145 var key = bip32ExtendedKey.derive(index);
34146 var address = key.getAddress().toString();
34147 var privkey = key.privKey.toWIF(network);
34148 addAddressToList(index, address, privkey);
34149 }, 50)
34150 }
34151
34152 init();
34153
34154 }
34155
34156 function showMore() {
34157 var start = DOM.addresses.children().length;
34158 var rowsToAdd = parseInt(DOM.rowsToAdd.val());
34159 if (isNaN(rowsToAdd)) {
34160 rowsToAdd = 20;
34161 DOM.rowsToAdd.val("20");
34162 }
34163 if (rowsToAdd > 200) {
34164 var msg = "Generating " + rowsToAdd + " rows could take a while. ";
34165 msg += "Do you want to continue?";
34166 if (!confirm(msg)) {
34167 return;
34168 }
34169 }
34170 displayAddresses(start, rowsToAdd);
34171 }
34172
34173 function clearDisplay() {
34174 clearAddressesList();
34175 clearKey();
34176 hideValidationError();
34177 }
34178
34179 function clearAddressesList() {
34180 DOM.addresses.empty();
34181 }
34182
34183 function clearKey() {
34184 DOM.rootKey.val("");
34185 DOM.extendedPrivKey.val("");
34186 DOM.extendedPubKey.val("");
34187 }
34188
34189 function addAddressToList(index, address, privkey) {
34190 var row = $(addressRowTemplate.html());
34191 // Elements
34192 var indexCell = row.find(".index span");
34193 var addressCell = row.find(".address span");
34194 var privkeyCell = row.find(".privkey span");
34195 // Content
34196 indexCell.text(index);
34197 addressCell.text(address);
34198 privkeyCell.text(privkey);
34199 // Visibility
34200 if (!showIndex) {
34201 indexCell.addClass("invisible");
34202 }
34203 if (!showAddress) {
34204 addressCell.addClass("invisible");
34205 }
34206 if (!showPrivKey) {
34207 privkeCell.addClass("invisible");
34208 }
34209 DOM.addresses.append(row);
34210 }
34211
34212 function hasStrongRandom() {
34213 return 'crypto' in window && window['crypto'] !== null;
34214 }
34215
34216 function disableForms() {
34217 $("form").on("submit", function(e) {
34218 e.preventDefault();
34219 });
34220 }
34221
34222 function setBip44DerivationPath() {
34223 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
34224 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
34225 var account = parseIntNoNaN(DOM.bip44account.val(), 0);
34226 var change = parseIntNoNaN(DOM.bip44change.val(), 0);
34227 var path = "m/";
34228 path += purpose + "'/";
34229 path += coin + "'/";
34230 path += account + "'/";
34231 path += change;
34232 DOM.bip44path.val(path);
34233 }
34234
34235 function parseIntNoNaN(val, defaultVal) {
34236 var v = parseInt(val);
34237 if (isNaN(v)) {
34238 return defaultVal;
34239 }
34240 return v;
34241 }
34242
34243 function showPending() {
34244 DOM.feedback
34245 .text("Calculating...")
34246 .show();
34247 }
34248
34249 function hidePending() {
34250 DOM.feedback
34251 .text("")
34252 .hide();
34253 }
34254
34255 init();
34256
34257 })();
34258 </script>
34259 </body>
34260 </html>