diff --git a/apps/src/main/java/org/clulab/processors/apps/ProcessorsJavaExample.java b/apps/src/main/java/org/clulab/processors/apps/ProcessorsJavaExample.java index ecd6005a4..9334be6c5 100644 --- a/apps/src/main/java/org/clulab/processors/apps/ProcessorsJavaExample.java +++ b/apps/src/main/java/org/clulab/processors/apps/ProcessorsJavaExample.java @@ -8,6 +8,7 @@ import org.clulab.utils.JavaUtils; import java.util.Iterator; +import scala.collection.Seq; public class ProcessorsJavaExample { public static void main(String [] args) throws Exception { @@ -20,25 +21,25 @@ public static void main(String [] args) throws Exception { // You are basically done. The rest of this code simply prints out the annotations. // Let's print the sentence-level annotations. - for (int sentenceIndex = 0; sentenceIndex < doc.sentences().length; sentenceIndex++) { - Sentence sentence = doc.sentences()[sentenceIndex]; + for (int sentenceIndex = 0; sentenceIndex < doc.sentences().length(); sentenceIndex++) { + Sentence sentence = doc.sentences().apply(sentenceIndex); System.out.println("Sentence #" + sentenceIndex + ":"); - System.out.println("Tokens: " + mkString(sentence.words())); - System.out.println("Start character offsets: " + mkString(sentence.startOffsets())); - System.out.println("End character offsets: " + mkString(sentence.endOffsets())); + System.out.println("Tokens: " + mkStringStr(sentence.words())); + System.out.println("Start character offsets: " + mkStringInt(sentence.startOffsets())); + System.out.println("End character offsets: " + mkStringInt(sentence.endOffsets())); // These annotations are optional, so they are stored using Option objects, // hence the isDefined() and get() calls. if (sentence.lemmas().isDefined()) - System.out.println("Lemmas: " + mkString(sentence.lemmas().get())); + System.out.println("Lemmas: " + mkStringStr(sentence.lemmas().get())); if (sentence.tags().isDefined()) - System.out.println("POS tags: " + mkString(sentence.tags().get())); + System.out.println("POS tags: " + mkStringStr(sentence.tags().get())); if (sentence.chunks().isDefined()) - System.out.println("Chunks: " + mkString(sentence.chunks().get())); + System.out.println("Chunks: " + mkStringStr(sentence.chunks().get())); if (sentence.entities().isDefined()) - System.out.println("Named entities: " + mkString(sentence.entities().get())); + System.out.println("Named entities: " + mkStringStr(sentence.entities().get())); if (sentence.norms().isDefined()) - System.out.println("Normalized entities: " + mkString(sentence.norms().get())); + System.out.println("Normalized entities: " + mkStringStr(sentence.norms().get())); if (sentence.dependencies().isDefined()) { System.out.println("Syntactic dependencies:"); Iterator> iterator = @@ -53,27 +54,27 @@ public static void main(String [] args) throws Exception { } } - public static String mkString(String[] strings, String sep) { + public static String mkStringStr(Seq strings, String sep) { StringBuilder stringBuilder = new StringBuilder(); - for (int i = 0; i < strings.length; i ++) { + for (int i = 0; i < strings.length(); i ++) { if (i > 0) stringBuilder.append(sep); - stringBuilder.append(strings[i]); + stringBuilder.append(strings.apply(i)); } return stringBuilder.toString(); } - public static String mkString(String[] strings) { return mkString(strings, " "); } + public static String mkStringStr(Seq strings) { return mkStringStr(strings, " "); } - public static String mkString(int[] ints, String sep) { + public static String mkStringInt(Seq ints, String sep) { StringBuilder stringBuilder = new StringBuilder(); - for (int i = 0; i < ints.length; i ++) { + for (int i = 0; i < ints.length(); i ++) { if (i > 0) stringBuilder.append(sep); - stringBuilder.append(ints[i]); + stringBuilder.append(ints.apply(i)); } return stringBuilder.toString(); } - public static String mkString(int[] ints) { return mkString(ints, " "); } + public static String mkStringInt(Seq ints) { return mkStringInt(ints, " "); } public static Iterable iteratorToIterable(Iterator iterator) { return () -> iterator; } } diff --git a/apps/src/main/scala/org/clulab/processors/apps/ColumnsToDocument.scala b/apps/src/main/scala/org/clulab/processors/apps/ColumnsToDocument.scala index 2789eb0d1..506486e88 100644 --- a/apps/src/main/scala/org/clulab/processors/apps/ColumnsToDocument.scala +++ b/apps/src/main/scala/org/clulab/processors/apps/ColumnsToDocument.scala @@ -2,6 +2,8 @@ package org.clulab.processors.apps import org.clulab.processors.{Document, Processor, Sentence} import org.clulab.processors.clu.BalaurProcessor +import org.clulab.scala.WrappedArrayBuffer._ +import org.clulab.utils.WrappedArraySeq import org.slf4j.{Logger, LoggerFactory} import java.io.InputStream @@ -17,101 +19,106 @@ class ColumnsToDocument * Last Modified: Fix compiler issue: import scala.io.Source. */ object ColumnsToDocument { - val logger:Logger = LoggerFactory.getLogger(classOf[ColumnsToDocument]) + type LabelSetter = (Sentence, Seq[String]) => Sentence + type Annotator = (Document) => Document + val logger: Logger = LoggerFactory.getLogger(classOf[ColumnsToDocument]) val WORD_POS_CONLLX = 1 val TAG_POS_CONLLX = 4 val WORD_POS_CONLLU = 1 val TAG_POS_CONLLU = 3 - var proc:Processor = new BalaurProcessor() + var proc: Processor = new BalaurProcessor() var prevLang: String = "en" - def readFromFile(fn:String, - wordPos:Int = WORD_POS_CONLLX, - labelPos:Int = TAG_POS_CONLLX, - setLabels: (Sentence, Array[String]) => Unit, - annotate: (Document) => Unit, - filterOutContractions:Boolean = false, - lang: String = "en" - ): Document = { - - // redefine proc acording to the language used + protected def setProcessor(lang: String): Unit = { if (lang != prevLang) { if (lang == "pt") { println("Using Portuguese processors") throw new RuntimeException(s"ERROR: language '$lang' not supported!") //this.proc = new PortugueseCluProcessor() - } else if (lang == "es") { + } + else if (lang == "es") { println("Using Spanish processors") //this.proc = new SpanishCluProcessor() throw new RuntimeException(s"ERROR: language '$lang' not supported!") - } else { + } + else { println("Using English processors") this.proc = new BalaurProcessor() } this.prevLang = lang } + } + def readFromFile( + fn: String, + wordPos: Int = WORD_POS_CONLLX, + labelPos: Int = TAG_POS_CONLLX, + setLabels: LabelSetter, + annotate: Annotator, + filterOutContractions: Boolean = false, + lang: String = "en" + ): Document = { + setProcessor(lang) Using.resource(Source.fromFile(fn)) { source => readFromSource(source, wordPos, labelPos, setLabels, annotate, filterOutContractions) } } - def readFromStream(stream:InputStream, - wordPos:Int = WORD_POS_CONLLX, - labelPos:Int = TAG_POS_CONLLX, - setLabels: (Sentence, Array[String]) => Unit, - annotate: (Document) => Unit, - filterOutContractions:Boolean = false, - lang: String = "en"): Document = { - - // redefine proc acording to the language used - if (lang == "pt"){ - println("Using Portuguese processors") - //this.proc = new PortugueseCluProcessor() - throw new RuntimeException(s"ERROR: language '$lang' not supported!") - } else if(lang == "es") { - println("Using Spanish processors") - //this.proc = new SpanishCluProcessor() - throw new RuntimeException(s"ERROR: language '$lang' not supported!") - } else { - println("Using English processors") - this.proc = new BalaurProcessor() - } - + def readFromStream( + stream: InputStream, + wordPos: Int = WORD_POS_CONLLX, + labelPos: Int = TAG_POS_CONLLX, + setLabels: LabelSetter, + annotate: Annotator, + filterOutContractions: Boolean = false, + lang: String = "en" + ): Document = { + setProcessor(lang) Using.resource(Source.fromInputStream(stream)) { source => readFromSource(source, wordPos, labelPos, setLabels, annotate, filterOutContractions) } } - def readFromSource(source:Source, - wordPos:Int, - labelPos:Int, - setLabels: (Sentence, Array[String]) => Unit, - annotate: (Document) => Unit, - filterOutContractions:Boolean): Document = { - var words = new ArrayBuffer[String]() - var startOffsets = new ArrayBuffer[Int]() - var endOffsets = new ArrayBuffer[Int]() - var labels = new ArrayBuffer[String]() - var charOffset = 0 + def readFromSource( + source: Source, + wordPos: Int, + labelPos: Int, + setLabels: LabelSetter, + annotate: Annotator, + filterOutContractions:Boolean + ): Document = { + val words = new ArrayBuffer[String]() + val startOffsets = new ArrayBuffer[Int]() + val endOffsets = new ArrayBuffer[Int]() + val labels = new ArrayBuffer[String]() val sentences = new ArrayBuffer[Sentence]() - for(line <- source.getLines()) { - val l = line.trim + var charOffset = 0 + + def mkSentence(): Sentence = { + val wordsSeq = new WrappedArraySeq(words.toArray).toImmutableSeq + val unlabeledSentence = new Sentence(wordsSeq, startOffsets, endOffsets, wordsSeq) + + words.clear() + startOffsets.clear() + endOffsets.clear() + + val labeledSentence = setLabels(unlabeledSentence, labels.toSeq) + + labels.clear() + labeledSentence + } + + source.getLines().map(_.trim).foreach { l => if (l.isEmpty) { // end of sentence if (words.nonEmpty) { - val s = new Sentence(words.toArray, startOffsets.toArray, endOffsets.toArray, words.toArray) - setLabels(s, labels.toArray) - sentences += s - words = new ArrayBuffer[String]() - startOffsets = new ArrayBuffer[Int]() - endOffsets = new ArrayBuffer[Int]() - labels = new ArrayBuffer[String]() + sentences += mkSentence() charOffset += 1 } - } else { + } + else { // within the same sentence val bits = l.split("\\s+") if (bits.length < 2) @@ -125,52 +132,28 @@ object ColumnsToDocument { // 10 as o DET _ Gender=Fem|Number=Plur 11 det _ _ // val offset = bits(0) // we assume token offsets are always in column 0! - if(! filterOutContractions || ! offset.contains("-")) { + if (!filterOutContractions || ! offset.contains("-")) { words += bits(wordPos) labels += bits(labelPos) startOffsets += charOffset charOffset = bits(wordPos).length endOffsets += charOffset charOffset += 1 - } else { + } + else { // println("Skipped line: " + l) } } } - if(words.nonEmpty) { - val s = new Sentence(words.toArray, startOffsets.toArray, endOffsets.toArray, words.toArray) - s.tags = Some(labels.toArray) - sentences += s - } + if (words.nonEmpty) + sentences += mkSentence() logger.debug(s"Loaded ${sentences.size} sentences.") - val d = new Document(sentences.toArray) - annotate(d) - - d - - } - - def setTags(s:Sentence, tags:Array[String]): Unit = { - s.tags = Some(tags) - } - - def setChunks(s:Sentence, chunks:Array[String]): Unit = { - s.chunks = Some(chunks) - } - - def setEntities(s:Sentence, entities:Array[String]): Unit = { - s.entities = Some(entities) - } - - def annotateLemmas(doc:Document): Unit = { - proc.lemmatize(doc) // some features use lemmas, which are not available in the CoNLL data - } + val unannotatedSentence = new Document(sentences) + val annotatedSentence = annotate(unannotatedSentence) - def annotateLemmmaTags(doc:Document): Unit = { - proc.lemmatize(doc) - proc.tagPartsOfSpeech(doc) + annotatedSentence } - def annotateNil(doc:Document): Unit = {} + def annotateNil(document: Document): Document = document } diff --git a/apps/src/main/scala/org/clulab/processors/apps/CommandLineInterface.scala b/apps/src/main/scala/org/clulab/processors/apps/CommandLineInterface.scala index 022a59cc0..c0303f6ca 100644 --- a/apps/src/main/scala/org/clulab/processors/apps/CommandLineInterface.scala +++ b/apps/src/main/scala/org/clulab/processors/apps/CommandLineInterface.scala @@ -3,7 +3,7 @@ package org.clulab.processors.apps import org.clulab.processors.Document import org.clulab.processors.clu.BalaurProcessor import org.clulab.serialization.CoNLLUSerializer -import org.clulab.utils.{FileUtils, StringUtils} +import org.clulab.utils.{FileUtils, StringUtils, WrappedArraySeq} import java.io.PrintWriter import scala.util.Using @@ -36,7 +36,11 @@ object CommandLineInterface extends App { } else if(props.containsKey(TOKENS)) { // one sentence per line; sentences are tokenized val sents = FileUtils.getLinesFromFile(props.getProperty(INPUT)) - val tokenizedSents = sents.map(_.split("\\s+").toIterable) + val tokenizedSents = sents.map { sent => + val tokens = sent.split("\\s+") + + WrappedArraySeq(tokens).toImmutableSeq + } proc.annotateFromTokens(tokenizedSents) } else { // assume raw text diff --git a/apps/src/main/scala/org/clulab/processors/apps/EvalTimeNormApp.scala b/apps/src/main/scala/org/clulab/processors/apps/EvalTimeNormApp.scala deleted file mode 100644 index fdba5a609..000000000 --- a/apps/src/main/scala/org/clulab/processors/apps/EvalTimeNormApp.scala +++ /dev/null @@ -1,10 +0,0 @@ -package org.clulab.processors.apps - -import org.clulab.numeric.EvalTimeNorm -import org.clulab.processors.clu.BalaurProcessor - -object EvalTimeNormApp extends App { - val proc = new BalaurProcessor() - - EvalTimeNorm.run(proc) -} diff --git a/apps/src/main/scala/org/clulab/processors/apps/InfiniteParallelProcessorsExample.scala b/apps/src/main/scala/org/clulab/processors/apps/InfiniteParallelProcessorsExample.scala index f320b6f4b..6220f625e 100644 --- a/apps/src/main/scala/org/clulab/processors/apps/InfiniteParallelProcessorsExample.scala +++ b/apps/src/main/scala/org/clulab/processors/apps/InfiniteParallelProcessorsExample.scala @@ -2,23 +2,21 @@ package org.clulab.processors.apps import org.clulab.processors.Document import org.clulab.processors.Processor +import org.clulab.processors.clu.{BalaurProcessor, DocumentPrettyPrinter} import org.clulab.serialization.DocumentSerializer import org.clulab.utils.{FileUtils, StringUtils, ThreadUtils, Timer} -import java.io.BufferedOutputStream import java.io.File -import java.io.FileOutputStream import java.io.PrintWriter +import scala.collection.compat._ import scala.collection.parallel.ParSeq import scala.util.Using -import org.clulab.processors.clu.BalaurProcessor object InfiniteParallelProcessorsExample { class ProcessorProvider(reuseProcessor: Boolean) { protected val processorOpt: Option[Processor] = - if (reuseProcessor) Some(new BalaurProcessor()) - else None + Option.when(reuseProcessor)(new BalaurProcessor()) def newOrReusedProcessor: Processor = if (reuseProcessor) processorOpt.get @@ -37,9 +35,6 @@ object InfiniteParallelProcessorsExample { val documentSerializer = new DocumentSerializer def processFiles(parFiles: ParSeq[File], processor: Processor): Unit = { - - def printDocument(document: Document, printWriter: PrintWriter): Unit = document.prettyPrint(printWriter) - parFiles.foreach { file => println(s"Processing ${file.getName}...") @@ -47,7 +42,7 @@ object InfiniteParallelProcessorsExample { val outputFile = new File(outputDir + "/" + file.getName) val document = processor.annotate(text) val printedDocument = StringUtils.viaPrintWriter { printWriter => - printDocument(document, printWriter) + new DocumentPrettyPrinter(printWriter).print(document) } val savedDocument = documentSerializer.save(document) val outputDocument = printedDocument + savedDocument diff --git a/apps/src/main/scala/org/clulab/processors/apps/NumericEntityRecognizerShell.scala b/apps/src/main/scala/org/clulab/processors/apps/NumericEntityRecognizerShell.scala index 0009b0f04..d4ddd3cb4 100644 --- a/apps/src/main/scala/org/clulab/processors/apps/NumericEntityRecognizerShell.scala +++ b/apps/src/main/scala/org/clulab/processors/apps/NumericEntityRecognizerShell.scala @@ -1,6 +1,6 @@ package org.clulab.processors.apps -import org.clulab.numeric.{displayMentions, setLabelsAndNorms} +import org.clulab.numeric.NumericUtils import org.clulab.processors.clu.BalaurProcessor import org.clulab.utils.ReloadableProcessor import org.clulab.utils.ReloadableShell @@ -23,9 +23,8 @@ class ReloadableNumericProcessor(ruleDirOpt: Option[String]) extends ReloadableP val numericEntityRecognizerOpt = balaurProcessor .numericEntityRecognizerOpt .map(_.reloaded(new File(ruleDirOpt.get))) - val numericEntityRecognizerOptOpt = numericEntityRecognizerOpt.map(Option(_)) - processorOpt = Some(balaurProcessor.copy(numericEntityRecognizerOptOpt = numericEntityRecognizerOptOpt)) + processorOpt = Some(balaurProcessor.copy(numericEntityRecognizerOpt = numericEntityRecognizerOpt)) } } @@ -35,10 +34,12 @@ class NumericEntityRecognizerShell(ruleDirOpt: Option[String]) extends Reloadabl /** The actual work, including printing out the output */ def work(text: String): Unit = { val doc = proc.get.annotate(text) + // This gets the same numericEntityRecognizer already used in the annotation + // so that the mentions, since thrown away, can be recalculated. val mentions = proc.get.numericEntityRecognizerOpt.map(_.extractFrom(doc)).getOrElse(Seq.empty) - setLabelsAndNorms(doc, mentions) - displayMentions(mentions, doc) + // The doc should already have been annotated two lines above. + NumericUtils.displayMentions(mentions, doc) } def reload(): Unit = { diff --git a/apps/src/main/scala/org/clulab/processors/apps/OdinStarter.scala b/apps/src/main/scala/org/clulab/processors/apps/OdinStarter.scala index 09440b813..106f7d09b 100644 --- a/apps/src/main/scala/org/clulab/processors/apps/OdinStarter.scala +++ b/apps/src/main/scala/org/clulab/processors/apps/OdinStarter.scala @@ -6,6 +6,7 @@ import org.clulab.sequences.LexiconNER import org.clulab.utils.FileUtils import java.io.File +import scala.collection.compat._ object OdinStarter extends App { // When using an IDE rather than sbt, make sure the working directory for the run @@ -20,11 +21,11 @@ object OdinStarter extends App { val kbs = kbsAndCaseInsensitiveMatchings.map(_._1) val caseInsensitiveMatchings = kbsAndCaseInsensitiveMatchings.map(_._2) val isLocal = kbs.forall(new File(resourceDir, _).exists) - val baseDirOpt = if (isLocal) Some(resourceDir) else None + val baseDirOpt = Option.when(isLocal)(resourceDir) LexiconNER(kbs, caseInsensitiveMatchings, baseDirOpt) } - val processor = new BalaurProcessor(optionalNER = Some(customLexiconNer)) + val processor = new BalaurProcessor(lexiconNerOpt = Some(customLexiconNer)) val extractorEngine = { val masterResource = "/org/clulab/odinstarter/main.yml" // We usually want to reload rules during development, diff --git a/apps/src/main/scala/org/clulab/processors/apps/ParallelProcessorsExample.scala b/apps/src/main/scala/org/clulab/processors/apps/ParallelProcessorsExample.scala index 6e514c3e1..bc28048e5 100644 --- a/apps/src/main/scala/org/clulab/processors/apps/ParallelProcessorsExample.scala +++ b/apps/src/main/scala/org/clulab/processors/apps/ParallelProcessorsExample.scala @@ -2,7 +2,7 @@ package org.clulab.processors.apps import org.clulab.processors.Document import org.clulab.processors.Processor -import org.clulab.processors.clu.BalaurProcessor +import org.clulab.processors.clu.{BalaurProcessor, DocumentPrettyPrinter} import org.clulab.serialization.DocumentSerializer import org.clulab.utils.{FileUtils, StringUtils, ThreadUtils, Timer} @@ -13,9 +13,6 @@ import scala.util.Using object ParallelProcessorsExample { def mainWithCallback(args: Array[String])(callback: (File, String) => Unit): Unit = { - - def printDocument(document: Document, printWriter: PrintWriter): Unit = document.prettyPrint(printWriter) - val inputDir = args(0) val outputDir = args(1) val extension = args(2) @@ -56,7 +53,7 @@ object ParallelProcessorsExample { throw throwable } val printedDocument = StringUtils.viaPrintWriter { printWriter => - printDocument(document, printWriter) + new DocumentPrettyPrinter(printWriter).print(document) } val savedDocument = documentSerializer.save(document) val outputDocument = printedDocument + savedDocument diff --git a/apps/src/main/scala/org/clulab/processors/apps/ProcessCoNLL03.scala b/apps/src/main/scala/org/clulab/processors/apps/ProcessCoNLL03.scala index 97a990764..b92b75129 100644 --- a/apps/src/main/scala/org/clulab/processors/apps/ProcessCoNLL03.scala +++ b/apps/src/main/scala/org/clulab/processors/apps/ProcessCoNLL03.scala @@ -30,7 +30,7 @@ object ProcessCoNLL03 extends App { } } - def saveSent(pw: PrintWriter, sent: Array[Row], tags: Option[Array[String]] = None, chunks: Option[Array[String]] = None): Unit = { + def saveSent(pw: PrintWriter, sent: Array[Row], tags: Option[Seq[String]] = None, chunks: Option[Seq[String]] = None): Unit = { if (tags.isDefined) { assert(sent.length == tags.get.length) //println("Using generated POS tags") diff --git a/apps/src/main/scala/org/clulab/processors/apps/ProcessorsDocSerializerExample.scala b/apps/src/main/scala/org/clulab/processors/apps/ProcessorsDocSerializerExample.scala index 8bc6aa608..518e0f667 100644 --- a/apps/src/main/scala/org/clulab/processors/apps/ProcessorsDocSerializerExample.scala +++ b/apps/src/main/scala/org/clulab/processors/apps/ProcessorsDocSerializerExample.scala @@ -1,5 +1,6 @@ package org.clulab.processors.apps +import org.clulab.processors.clu.DocumentPrettyPrinter import org.clulab.processors.{Document, Processor} import org.clulab.serialization.DocumentSerializer @@ -13,6 +14,7 @@ import java.io.PrintWriter */ object ProcessorsDocSerializerExample { def main(args:Array[String]): Unit = { + val documentPrinter = new DocumentPrettyPrinter(new PrintWriter(System.out)) // create the processor val proc = Processor() @@ -20,14 +22,11 @@ object ProcessorsDocSerializerExample { val doc = proc.annotate("John Smith went to China. He visited Beijing, on January 10th, 2013.") // you are basically done. the rest of this code simply prints out the annotations - printDoc(doc) + documentPrinter.print(doc) // serialize the doc using our custom serializer val ser = new DocumentSerializer val out = ser.save(doc) println("SERIALIZED DOC:\n" + out) } - - def printDoc(doc:Document): Unit = { doc.prettyPrint(new PrintWriter(System.out)) } - } diff --git a/apps/src/main/scala/org/clulab/processors/apps/ProcessorsScalaExample.scala b/apps/src/main/scala/org/clulab/processors/apps/ProcessorsScalaExample.scala index 8f8dc65e1..fb203652f 100644 --- a/apps/src/main/scala/org/clulab/processors/apps/ProcessorsScalaExample.scala +++ b/apps/src/main/scala/org/clulab/processors/apps/ProcessorsScalaExample.scala @@ -34,5 +34,5 @@ object ProcessorsScalaExample extends App { println() } - def mkString[T](elems: Array[T]): String = elems.mkString(" ") + def mkString[T](elems: Seq[T]): String = elems.mkString(" ") } diff --git a/apps/src/main/scala/org/clulab/processors/apps/ProcessorsShell.scala b/apps/src/main/scala/org/clulab/processors/apps/ProcessorsShell.scala index 012949e4a..903cf6113 100644 --- a/apps/src/main/scala/org/clulab/processors/apps/ProcessorsShell.scala +++ b/apps/src/main/scala/org/clulab/processors/apps/ProcessorsShell.scala @@ -1,7 +1,7 @@ package org.clulab.processors.apps import org.clulab.processors.Processor -import org.clulab.processors.clu.BalaurProcessor +import org.clulab.processors.clu.{BalaurProcessor, DocumentPrettyPrinter} import org.clulab.utils.CliReader import org.clulab.utils.ExitMenuItem import org.clulab.utils.HelpMenuItem @@ -27,6 +27,7 @@ class ProcessorsShell extends Shell { val lineReader = new CliReader(proc.prompt, "user.home", ".processorshellhistory") val printWriter = new PrintWriter(System.out) + val documentPrinter = new DocumentPrettyPrinter(printWriter) def prepareProcessor(message: String, promptedReloadableProcessor: PromptedReloadableProcessor): Unit = { lineReader.setPrompt(promptedReloadableProcessor.prompt) @@ -40,8 +41,8 @@ class ProcessorsShell extends Shell { override def work(text: String): Unit = { val doc = proc.get.annotate(text) - doc.prettyPrint(printWriter) - printWriter.flush() + + documentPrinter.print(doc) } // We inherit now just from Shell, so no reloading is performed. diff --git a/build.sbt b/build.sbt index 354fc7974..738720e41 100644 --- a/build.sbt +++ b/build.sbt @@ -1,23 +1,24 @@ -// These were last checked on 2025-02-19. +// These were last checked on 2025-05-09. val scala211 = "2.11.12" // up to 2.11.12 -val scala212 = "2.12.19" // up to 2.12.20 -val scala213 = "2.13.14" // up to 2.13.16 +val scala212 = "2.12.20" // up to 2.12.20 +val scala213 = "2.13.16" // up to 2.13.16 val scala30 = "3.0.2" // up to 3.0.2 val scala31 = "3.1.3" // up to 3.1.3 val scala32 = "3.2.2" // up to 3.2.2 -val scala33 = "3.3.5" // up to 3.3.5 (LTS) +val scala33 = "3.3.6" // up to 3.3.6 (LTS) val scala34 = "3.4.3" // up to 3.4.3 val scala35 = "3.5.2" // up to 3.5.2 -val scala36 = "3.6.3" // up to 3.6.3 +val scala36 = "3.6.4" // up to 3.6.4 +val scala37 = "3.7.0" // up to 3.7.0 // See https://www.scala-lang.org/blog/2022/08/17/long-term-compatibility-plans.html. // Scala30: "If you are maintaining a library, you should drop Scala 3.0." Dropped. // Scala31: This is a LTS (long term support) version before it was called that. // Scala32: This is for experimentation, as in Scala Next, and not for release. // Scala33: This is the first official LTS, but hold off until necessary. -val scala3 = scala31 +val scala3 = scala33 -ThisBuild / crossScalaVersions := Seq(scala212, scala211, scala213, scala3) +ThisBuild / crossScalaVersions := Seq(scala212, scala3, scala213, scala211) ThisBuild / scalaVersion := crossScalaVersions.value.head lazy val root = (project in file(".")) @@ -45,7 +46,13 @@ lazy val webapp = project crossScalaVersions := Seq(scala212) ) +lazy val webapp2 = project + .dependsOn(library) + .settings( + crossScalaVersions := Seq(scala212, scala3, scala213) // There is no scala211 for this. + ) + lazy val debugger = project - .dependsOn(library % "compile -> compile; test -> test") + .dependsOn(library % "compile -> compile; test -> test") addCommandAlias("dockerizeWebapp", ";webapp/docker:publishLocal") diff --git a/debugger/build.sbt b/debugger/build.sbt index 019c0ed54..2e657062e 100644 --- a/debugger/build.sbt +++ b/debugger/build.sbt @@ -3,7 +3,7 @@ description := "A debugger for the Odin ExtractionEngine within processors" libraryDependencies ++= { Seq( - "com.lihaoyi" %% "scalatags" % "0.12.0", // as of 2025-02-19 up to 0.13.1 + "com.lihaoyi" %% "scalatags" % "0.12.0", // as of 2025-06-02 up to 0.13.1 "com.lihaoyi" %% "sourcecode" % "0.3.0", // as of 2025-01-27 up to 0.4.2 "org.clulab" % "processors-model" % "0.3.1" diff --git a/debugger/src/main/scala/org/clulab/odin/debugger/apps/DebuggingOdinStarterApp.scala b/debugger/src/main/scala/org/clulab/odin/debugger/apps/DebuggingOdinStarterApp.scala index 6924eef03..f55ff1b9b 100644 --- a/debugger/src/main/scala/org/clulab/odin/debugger/apps/DebuggingOdinStarterApp.scala +++ b/debugger/src/main/scala/org/clulab/odin/debugger/apps/DebuggingOdinStarterApp.scala @@ -31,7 +31,7 @@ object DebuggingOdinStarterApp extends App { LexiconNER(kbs, caseInsensitiveMatchings, baseDirOpt) } - val processor = new CluProcessor(optionalNER = Some(customLexiconNer)) + val processor = new CluProcessor(lexiconNerOpt = Some(customLexiconNer)) val exampleGlobalAction = (inMentions: Seq[Mention], state: State) => { val outMentions = inMentions.map { mention => if (mention.words.length % 2 == 0) diff --git a/debugger/src/main/scala/org/clulab/odin/debugger/visualizer/sentence/HtmlSentenceVisualizer.scala b/debugger/src/main/scala/org/clulab/odin/debugger/visualizer/sentence/HtmlSentenceVisualizer.scala index 4a8866a2e..ff7a632aa 100644 --- a/debugger/src/main/scala/org/clulab/odin/debugger/visualizer/sentence/HtmlSentenceVisualizer.scala +++ b/debugger/src/main/scala/org/clulab/odin/debugger/visualizer/sentence/HtmlSentenceVisualizer.scala @@ -18,8 +18,8 @@ class HtmlSentenceVisualizer extends SentenceVisualizer with HtmlVisualizing { string } - def getOrEmpty(arrayOpt: Option[Array[String]], index: Int): String = - arrayOpt.map(_(index)).getOrElse("") + def getOrEmpty(seqOpt: Option[Seq[String]], index: Int): String = + seqOpt.map(_(index)).getOrElse("") val rows = sentence.words.indices.map { i => tr( diff --git a/debugger/src/test/scala/org/clulab/odin/debugger/extractor/graph/DebugRelationGraphExtractor.scala b/debugger/src/test/scala/org/clulab/odin/debugger/extractor/graph/DebugRelationGraphExtractor.scala index 7534c6415..b88f678b1 100644 --- a/debugger/src/test/scala/org/clulab/odin/debugger/extractor/graph/DebugRelationGraphExtractor.scala +++ b/debugger/src/test/scala/org/clulab/odin/debugger/extractor/graph/DebugRelationGraphExtractor.scala @@ -20,7 +20,7 @@ class DebugRelationGraphExtractor extends DebugTest { val resourceDir: File = new File(resourceDirName) val customLexiconNer = LexiconNER(Seq(s"$baseResourceName/FOOD.tsv"), Seq(true), Some(resourceDir)) - val processor = new CluProcessor(optionalNER = Some(customLexiconNer)) + val processor = new CluProcessor(lexiconNerOpt = Some(customLexiconNer)) val document = processor.annotate("John eats cake.", keepText = true) val sentence = document.sentences.head val ruleName = "people-eat-food" diff --git a/debugger/src/test/scala/org/clulab/odin/debugger/extractor/graph/DebugTriggerMentionGraphExtractor.scala b/debugger/src/test/scala/org/clulab/odin/debugger/extractor/graph/DebugTriggerMentionGraphExtractor.scala index 860646c06..97f8c4631 100644 --- a/debugger/src/test/scala/org/clulab/odin/debugger/extractor/graph/DebugTriggerMentionGraphExtractor.scala +++ b/debugger/src/test/scala/org/clulab/odin/debugger/extractor/graph/DebugTriggerMentionGraphExtractor.scala @@ -20,7 +20,7 @@ class DebugTriggerMentionGraphExtractor extends DebugTest { val resourceDir: File = new File(resourceDirName) val customLexiconNer = LexiconNER(Seq(s"$baseResourceName/FOOD.tsv"), Seq(true), Some(resourceDir)) - val processor = new CluProcessor(optionalNER = Some(customLexiconNer)) + val processor = new CluProcessor(lexiconNerOpt = Some(customLexiconNer)) val document = processor.annotate("John eats cake.", keepText = true) val sentence = document.sentences.head val ruleName = "people-eat-food" diff --git a/debugger/src/test/scala/org/clulab/odin/debugger/extractor/graph/DebugTriggerPatternGraphExtractor.scala b/debugger/src/test/scala/org/clulab/odin/debugger/extractor/graph/DebugTriggerPatternGraphExtractor.scala index 7aa28848b..31447ac66 100644 --- a/debugger/src/test/scala/org/clulab/odin/debugger/extractor/graph/DebugTriggerPatternGraphExtractor.scala +++ b/debugger/src/test/scala/org/clulab/odin/debugger/extractor/graph/DebugTriggerPatternGraphExtractor.scala @@ -20,7 +20,7 @@ class DebugTriggerPatternGraphExtractor extends DebugTest { val resourceDir: File = new File(resourceDirName) val customLexiconNer = LexiconNER(Seq(s"$baseResourceName/FOOD.tsv"), Seq(true), Some(resourceDir)) - val processor = new CluProcessor(optionalNER = Some(customLexiconNer)) + val processor = new CluProcessor(lexiconNerOpt = Some(customLexiconNer)) val document = processor.annotate("John eats cake.", keepText = true) val sentence = document.sentences.head val ruleName = "people-eat-food" diff --git a/library/build.sbt b/library/build.sbt index a562a04b5..9b2e770d0 100644 --- a/library/build.sbt +++ b/library/build.sbt @@ -54,7 +54,7 @@ libraryDependencies ++= { "org.scalatest" %% "scalatest" % "3.2.15" % Test, // up to 3.2.19, Apache-2.0 // for odin "org.apache.commons" % "commons-text" % "1.1", // up to 1.12.0, Apache-2.0 - "org.scala-lang.modules" %% "scala-collection-compat" % "2.11.0", // up to 2.12.0 // Apache-2.0 + "org.scala-lang.modules" %% "scala-collection-compat" % "2.13.0", // up to 2.13.0 // Apache-2.0 "org.scala-lang.modules" %% "scala-parser-combinators" % combinatorsVersion, // Apache-2.0 "org.yaml" % "snakeyaml" % "1.14", // up to 2.2, Apache-2.0 // progress bar for training diff --git a/library/src/main/scala-2.11_2.12/org/clulab/scala/SeqView.scala b/library/src/main/scala-2.11_2.12/org/clulab/scala/SeqView.scala new file mode 100644 index 000000000..649887166 --- /dev/null +++ b/library/src/main/scala-2.11_2.12/org/clulab/scala/SeqView.scala @@ -0,0 +1,5 @@ +package org.clulab.scala + +object SeqView { + type Type[T] = scala.collection.SeqView[T, Seq[T]] +} diff --git a/library/src/main/scala-2.11_2.12/org/clulab/scala/package.scala b/library/src/main/scala-2.11_2.12/org/clulab/scala/package.scala deleted file mode 100644 index a6a43654c..000000000 --- a/library/src/main/scala-2.11_2.12/org/clulab/scala/package.scala +++ /dev/null @@ -1,11 +0,0 @@ -package org.clulab - -import _root_.scala.{BufferedIterator => GenericBufferedIterator} -import _root_.scala.collection.immutable.{Stream => ImmutableStream} - -package object scala { - type BufferedIterator[T] = GenericBufferedIterator[T] - - type LazyList[T] = ImmutableStream[T] - val LazyList = ImmutableStream -} diff --git a/library/src/main/scala-2.11_2.12/org/clulab/struct/DependencyMap.scala b/library/src/main/scala-2.11_2.12/org/clulab/struct/DependencyMap.scala deleted file mode 100644 index d9b2cbfc5..000000000 --- a/library/src/main/scala-2.11_2.12/org/clulab/struct/DependencyMap.scala +++ /dev/null @@ -1,12 +0,0 @@ -package org.clulab.struct - -import scala.collection.mutable - -class DependencyMap protected extends mutable.HashMap[Int, DirectedGraph[String]] { - override def initialSize: Int = 2 // we have very few dependency types, so let's create a small hash to save memory -} - -object DependencyMap extends DependencyMapNames { - - def apply(): DependencyMap = new DependencyMap() -} diff --git a/library/src/main/scala-2.11_2.12/org/clulab/struct/GraphMap.scala b/library/src/main/scala-2.11_2.12/org/clulab/struct/GraphMap.scala deleted file mode 100644 index 57ad2411e..000000000 --- a/library/src/main/scala-2.11_2.12/org/clulab/struct/GraphMap.scala +++ /dev/null @@ -1,17 +0,0 @@ -package org.clulab.struct - -import scala.collection.mutable - -class GraphMap protected extends mutable.HashMap[String, DirectedGraph[String]] { - override def initialSize: Int = 2 // we have very few dependency types, so let's create a small hash to save memory -} - -object GraphMap extends GraphMapNames { - - def apply(): GraphMap = new GraphMap() - - def apply(existing: Map[String, DirectedGraph[String]]): GraphMap = { - val gm = GraphMap() - gm ++= existing - } -} diff --git a/library/src/main/scala-2.13/org/clulab/scala/SeqView.scala b/library/src/main/scala-2.13/org/clulab/scala/SeqView.scala new file mode 100644 index 000000000..e227e7cbb --- /dev/null +++ b/library/src/main/scala-2.13/org/clulab/scala/SeqView.scala @@ -0,0 +1,5 @@ +package org.clulab.scala + +object SeqView { + type Type[T] = scala.collection.View[T] +} diff --git a/library/src/main/scala-2.13/org/clulab/scala/package.scala b/library/src/main/scala-2.13/org/clulab/scala/package.scala deleted file mode 100644 index 8df18bbdf..000000000 --- a/library/src/main/scala-2.13/org/clulab/scala/package.scala +++ /dev/null @@ -1,11 +0,0 @@ -package org.clulab - -import _root_.scala.collection.{BufferedIterator => GenericBufferedIterator} -import _root_.scala.collection.immutable.{LazyList => ImmutableLazyList} - -package object scala { - type BufferedIterator[T] = GenericBufferedIterator[T] - - type LazyList[T] = ImmutableLazyList[T] - val LazyList = ImmutableLazyList -} diff --git a/library/src/main/scala-2.13/org/clulab/struct/DependencyMap.scala b/library/src/main/scala-2.13/org/clulab/struct/DependencyMap.scala deleted file mode 100644 index c4ed49b82..000000000 --- a/library/src/main/scala-2.13/org/clulab/struct/DependencyMap.scala +++ /dev/null @@ -1,14 +0,0 @@ -package org.clulab.struct - -import scala.collection.mutable - -object DependencyMap extends DependencyMapNames { - // This was previously a class inheriting from HashMap. However, - // [warn] ...: inheritance from class HashMap in package mutable is deprecated (since 2.13.0): HashMap will be made final; use .withDefault for the common use case of computing a default value. - type DependencyMap = mutable.HashMap[String, DirectedGraph[String]] - - def apply(): DependencyMap = { - // we have very few dependency types, so let's create a small hash to save memory. - new DependencyMap(2, mutable.HashMap.defaultLoadFactor) - } -} diff --git a/library/src/main/scala-2.13/org/clulab/struct/GraphMap.scala b/library/src/main/scala-2.13/org/clulab/struct/GraphMap.scala deleted file mode 100644 index fd1b32794..000000000 --- a/library/src/main/scala-2.13/org/clulab/struct/GraphMap.scala +++ /dev/null @@ -1,20 +0,0 @@ -package org.clulab.struct - -import scala.collection.mutable - -object GraphMap extends GraphMapNames { - - // This was previously a class inheriting from HashMap. However, - // [warn] ...: inheritance from class HashMap in package mutable is deprecated (since 2.13.0): HashMap will be made final; use .withDefault for the common use case of computing a default value - type GraphMap = mutable.HashMap[String, DirectedGraph[String]] - - def apply(): GraphMap = { - // we have very few dependency types, so let's create a small hash to save memory. - new GraphMap(2, mutable.HashMap.defaultLoadFactor) - } - - def apply(existing: scala.collection.Map[String, DirectedGraph[String]]): GraphMap = { - val gm = GraphMap() - gm ++= existing - } -} diff --git a/library/src/main/scala-3/org/clulab/odinstarter/OdinStarter3.scala b/library/src/main/scala-3/org/clulab/odinstarter/OdinStarter3.scala deleted file mode 100644 index fa9dfa73d..000000000 --- a/library/src/main/scala-3/org/clulab/odinstarter/OdinStarter3.scala +++ /dev/null @@ -1,67 +0,0 @@ -package org.clulab.odinstarter - -import org.clulab.odin.ExtractorEngine -import org.clulab.odin.Mention -import org.clulab.processors.clu.BalaurProcessor -import org.clulab.sequences.LexiconNER -import org.clulab.utils.FileUtils - -import java.io.File - -object OdinStarter3: - - // From sbt use "runMain org.clulab.odinstarter.main". - @main def main() = - // When using an IDE rather than sbt, make sure the working directory for the run - // configuration is the subproject directory so that this resourceDir is accessible. - val resourceDir: File = new File("./src/main/resources") - val customLexiconNer = // i.e., Named Entity Recognizer - val kbsAndCaseInsensitiveMatchings: Seq[(String, Boolean)] = Seq( - // You can add additional kbs (knowledge bases) and caseInsensitiveMatchings here. - ("org/clulab/odinstarter/FOOD.tsv", true) // , - // ("org/clulab/odinstarter/RESTAURANTS.tsv", false) - ) - val kbs = kbsAndCaseInsensitiveMatchings.map(_._1) - val caseInsensitiveMatchings = kbsAndCaseInsensitiveMatchings.map(_._2) - val isLocal = kbs.forall(new File(resourceDir, _).exists) - val baseDirOpt = if isLocal then Some(resourceDir) else None - - LexiconNER(kbs, caseInsensitiveMatchings, baseDirOpt) - val processor = new BalaurProcessor(optionalNER = Some(customLexiconNer)) - val extractorEngine = - val masterResource = "/org/clulab/odinstarter/main.yml" - // We usually want to reload rules during development, - // so we try to load them from the filesystem first, then jar. - // The resource must start with /, but the file probably shouldn't. - val masterFile = new File(resourceDir, masterResource.drop(1)) - - if masterFile.exists then - // Read rules from file in filesystem. - val rules = FileUtils.getTextFromFile(masterFile) - ExtractorEngine(rules, ruleDir = Some(resourceDir)) - else - // Read rules from resource in jar. - val rules = FileUtils.getTextFromResource(masterResource) - ExtractorEngine(rules, ruleDir = None) - val document = processor.annotate("John eats cake.") - val mentions = extractorEngine.extractFrom(document).sortBy(_.arguments.size) - - for mention <- mentions - do printMention(mention) - - def printMention(mention: Mention, nameOpt: Option[String] = None, depth: Int = 0): Unit = - val indent = " " * depth - val name = nameOpt.getOrElse("") - val labels = mention.labels - val words = mention.sentenceObj.words - val tokens = mention.tokenInterval.map(mention.sentenceObj.words) - - println(indent + " Name: " + name) - println(indent + " Labels: " + labels.mkString(" ")) - println(indent + " Sentence: " + words.mkString(" ")) - println(indent + " Tokens: " + tokens.mkString(" ")) - if mention.arguments.nonEmpty then - println(indent + "Arguments:") - for (name, mentions) <- mention.arguments; mention <- mentions - do printMention(mention, Some(name), depth + 1) - println() diff --git a/library/src/main/scala-3/org/clulab/scala/SeqView.scala b/library/src/main/scala-3/org/clulab/scala/SeqView.scala new file mode 100644 index 000000000..e227e7cbb --- /dev/null +++ b/library/src/main/scala-3/org/clulab/scala/SeqView.scala @@ -0,0 +1,5 @@ +package org.clulab.scala + +object SeqView { + type Type[T] = scala.collection.View[T] +} diff --git a/library/src/main/scala-3/org/clulab/scala/package.scala b/library/src/main/scala-3/org/clulab/scala/package.scala deleted file mode 100644 index 8df18bbdf..000000000 --- a/library/src/main/scala-3/org/clulab/scala/package.scala +++ /dev/null @@ -1,11 +0,0 @@ -package org.clulab - -import _root_.scala.collection.{BufferedIterator => GenericBufferedIterator} -import _root_.scala.collection.immutable.{LazyList => ImmutableLazyList} - -package object scala { - type BufferedIterator[T] = GenericBufferedIterator[T] - - type LazyList[T] = ImmutableLazyList[T] - val LazyList = ImmutableLazyList -} diff --git a/library/src/main/scala-3/org/clulab/struct/DependencyMap.scala b/library/src/main/scala-3/org/clulab/struct/DependencyMap.scala deleted file mode 100644 index c4ed49b82..000000000 --- a/library/src/main/scala-3/org/clulab/struct/DependencyMap.scala +++ /dev/null @@ -1,14 +0,0 @@ -package org.clulab.struct - -import scala.collection.mutable - -object DependencyMap extends DependencyMapNames { - // This was previously a class inheriting from HashMap. However, - // [warn] ...: inheritance from class HashMap in package mutable is deprecated (since 2.13.0): HashMap will be made final; use .withDefault for the common use case of computing a default value. - type DependencyMap = mutable.HashMap[String, DirectedGraph[String]] - - def apply(): DependencyMap = { - // we have very few dependency types, so let's create a small hash to save memory. - new DependencyMap(2, mutable.HashMap.defaultLoadFactor) - } -} diff --git a/library/src/main/scala-3/org/clulab/struct/GraphMap.scala b/library/src/main/scala-3/org/clulab/struct/GraphMap.scala deleted file mode 100644 index fd1b32794..000000000 --- a/library/src/main/scala-3/org/clulab/struct/GraphMap.scala +++ /dev/null @@ -1,20 +0,0 @@ -package org.clulab.struct - -import scala.collection.mutable - -object GraphMap extends GraphMapNames { - - // This was previously a class inheriting from HashMap. However, - // [warn] ...: inheritance from class HashMap in package mutable is deprecated (since 2.13.0): HashMap will be made final; use .withDefault for the common use case of computing a default value - type GraphMap = mutable.HashMap[String, DirectedGraph[String]] - - def apply(): GraphMap = { - // we have very few dependency types, so let's create a small hash to save memory. - new GraphMap(2, mutable.HashMap.defaultLoadFactor) - } - - def apply(existing: scala.collection.Map[String, DirectedGraph[String]]): GraphMap = { - val gm = GraphMap() - gm ++= existing - } -} diff --git a/library/src/main/scala/org/clulab/numeric/EvalTimeNorm.scala b/library/src/main/scala/org/clulab/numeric/EvalTimeNorm.scala index add58c14d..9804190fe 100644 --- a/library/src/main/scala/org/clulab/numeric/EvalTimeNorm.scala +++ b/library/src/main/scala/org/clulab/numeric/EvalTimeNorm.scala @@ -2,6 +2,7 @@ package org.clulab.numeric import org.clulab.numeric.mentions.Norm import org.clulab.processors.Processor +import org.clulab.processors.clu.BalaurProcessor import java.nio.charset.StandardCharsets import scala.io.Source @@ -9,9 +10,12 @@ import scala.util.Using object EvalTimeNorm { - def runEval(proc: Processor, ner: NumericEntityRecognizer, - testFile: String): Double = { - val timeNormEvalDir = "/org/clulab/numeric/TimeNormEvalSet" + def runEval( + proc: Processor, + timeNormEvalDir: String, + testFile: String, + ner: NumericEntityRecognizer + ): Double = { val goldStream = getClass.getResourceAsStream(s"$timeNormEvalDir/$testFile") val goldLines = Source.fromInputStream(goldStream).getLines() // Build a Map with the gold time expressions. @@ -34,8 +38,9 @@ object EvalTimeNorm { } val doc = proc.annotate(docText) val mentions = ner.extractFrom(doc) - setLabelsAndNorms(doc, mentions) - val prediction = mentions.collect{ + // The following line does not change the document. + // NumericUtils.mkLabelsAndNorms(doc, mentions) + val prediction = mentions.collect{ case m: Norm if m.neLabel.equals("DATE") || m.neLabel.equals("DATE-RANGE") => (m.startOffset.toString, m.endOffset.toString, m.neNorm) }.toSet @@ -53,13 +58,9 @@ object EvalTimeNorm { fscore } - def run(proc: Processor): Double = { - val ner = NumericEntityRecognizer() + def run(proc: BalaurProcessor, timeNormEvalDir: String, testFile: String): Double = { + val ner = proc.numericEntityRecognizerOpt.get - test(proc, ner) - } - - def test(proc: Processor, ner: NumericEntityRecognizer): Double = { - runEval(proc, ner, "WorldModelersDatesRangesTimex.csv") + runEval(proc, timeNormEvalDir, testFile, ner) } } diff --git a/library/src/main/scala/org/clulab/numeric/NumericEntityRecognizer.scala b/library/src/main/scala/org/clulab/numeric/NumericEntityRecognizer.scala index 3d5976a7d..73cc1940d 100644 --- a/library/src/main/scala/org/clulab/numeric/NumericEntityRecognizer.scala +++ b/library/src/main/scala/org/clulab/numeric/NumericEntityRecognizer.scala @@ -19,41 +19,29 @@ class NumericEntityRecognizer protected (val lexiconNer: LexiconNER, val actions new NumericEntityRecognizer(lexiconNer, actions, extractorEngine) } - /** Matches the lexicon NER on this document, setting the `entities` field */ - def matchLexiconNer(document: Document): Seq[Option[Array[String]]] = { - val originalEntities = new ArrayBuffer[Option[Array[String]]]() - - for(sent <- document.sentences) { - originalEntities += sent.entities - - val labels = lexiconNer.find(sent) - // this needs to happen in place, otherwise Odin does not see these labels - // we will restore the original Sentence.entities at the end in `extractFrom` - sent.entities = Some(labels) - // println(s"ENTITIES: ${sent.entities.get.mkString(" ")}") - } - - originalEntities - } - /** * Entry point for numeric entity recognition * @param doc Input document * @return sets in place the sequence of NER labels and sequence of NER norms (using the TempEval-2 notation) */ - def extractFrom(doc:Document): Seq[Mention] = { - // dictionaries - val originalEntities = matchLexiconNer(doc) - // grammars - var mentions = extractor.extractFrom(doc) + def extractFrom(doc: Document): Seq[Mention] = { + val newSentences = doc.sentences.map { sentence => + val newEntities = lexiconNer.find(sentence) + + sentence.copy(entities = Some(newEntities)) + } + val newDocument = doc.copy(sentences = newSentences) + val mentions = { + val dirtyMentions = extractor.extractFrom(newDocument) + val cleanMentions = actions.cleanupAction(dirtyMentions) - // restore the original entities - for(i <- originalEntities.indices) { - doc.sentences(i).entities = originalEntities(i) + cleanMentions } - // global actions *after* all grammars are done - actions.cleanupAction(mentions) + // These mentions will have doc pointing to the newDocument, + // but sentence will be the index into the new sentences and + // will be valid for the original doc. + mentions } } diff --git a/library/src/main/scala/org/clulab/numeric/NumericUtils.scala b/library/src/main/scala/org/clulab/numeric/NumericUtils.scala new file mode 100644 index 000000000..ba9bcd84b --- /dev/null +++ b/library/src/main/scala/org/clulab/numeric/NumericUtils.scala @@ -0,0 +1,144 @@ +package org.clulab.numeric + +import org.clulab.numeric.actions.NumericActions +import org.clulab.numeric.mentions.Norm +import org.clulab.odin.{EventMention, Mention} +import org.clulab.processors.Document +import org.clulab.struct.Interval +import org.clulab.utils.WrappedArraySeq + +import scala.collection.mutable + +object NumericUtils { + def displayMentions(mentions: Seq[Mention], doc: Document): Unit = { + val mentionsBySentence = mentions.groupBy(_.sentence).map { case (sentence, mentions) => + sentence -> mentions.sortBy(_.start) + }.withDefaultValue(Nil) + for ((s, i) <- doc.sentences.zipWithIndex) { + println(s"sentence #$i") + println(s.getSentenceText) + println("Tokens: " + s.words.indices.zip(s.words).zip(s.tags.get).mkString(", ")) + s.tags foreach (x => println("Tags: " + x.mkString(", "))) + s.entities foreach (x => println("Entities: " + x.mkString(", "))) + s.norms foreach (x => println("Norms: " + x.mkString(", "))) + println() + + val sortedMentions = mentionsBySentence(i).sortBy(_.label) + sortedMentions foreach displayMention + println() + } + } + + def displayMention(mention: Mention): Unit = { + val boundary = s"\t${"-" * 30}" + println(s"${mention.labels} => ${mention.text}") + println(boundary) + println(s"\tRule => ${mention.foundBy}") + val mentionType = mention.getClass.toString.split("""\.""").last + println(s"\tType => $mentionType") + println(s"\tInterval => ${mention.tokenInterval}") + mention match { + case norm: Norm => + println(s"\tNorm => ${norm.neNorm}") + println(s"\tNE => ${norm.neLabel}") + case _ => + } + println(boundary) + if (mention.arguments.nonEmpty) { + println("\tArgs:") + mention match { + case em: EventMention => + println(s"\ttrigger: ${em.trigger}") + displayArguments(em) + case _ => + displayArguments(mention) + } + println(s"$boundary") + } + println() + } + + def displayArguments(b: Mention): Unit = { + b.arguments foreach { + case (argName, ms) => + ms foreach { v => + println(s"\t * $argName ${v.labels.mkString("(", ", ", ")")} => ${v.text}") + } + } + } + + /** + * Sets the entities and norms fields in each Sentence based on the given numeric mentions + * @param doc This document is modified in place + * @param mentions The numeric mentions previously extracted + */ + def mkLabelsAndNorms(doc: Document, mentions: Seq[Mention]): (Seq[Seq[String]], Seq[Seq[String]]) = { + val pertinentMentions = mentions.collect { + case mention: Norm if NumericActions.isNumeric(mention) => mention + } + val mentionsBySentenceIndex = pertinentMentions.groupBy { mention => mention.sentence } + val zippedLabelsAndNorms = doc.sentences.zipWithIndex.map { case (sentence, index) => + val mentions = mentionsBySentenceIndex.getOrElse(index, Seq.empty) + + if (mentions.isEmpty) { + val entities = sentence.entities.getOrElse(WrappedArraySeq(Array.fill(sentence.size)("O")).toImmutableSeq) + val norms = sentence.norms.getOrElse(WrappedArraySeq(Array.fill(sentence.size)("")).toImmutableSeq) + + (entities, norms) + } + else { + val mutableEntities = sentence.entities + .map { entities => Array(entities: _*) } + .getOrElse(Array.fill(sentence.size)("O")) + val mutableNorms = sentence.norms + .map { norms => Array(norms: _*) } + .getOrElse(Array.fill(sentence.size)("")) + + mentions.foreach { mention => + addLabelsAndNorms(mention.neLabel, mention.neNorm, mention.tokenInterval, mutableEntities, mutableNorms) + } + removeOneEntityBeforeAnother(mutableEntities, mutableNorms, "B-LOC", "MEASUREMENT-LENGTH") + + val immutableEntities = WrappedArraySeq(mutableEntities).toImmutableSeq + val immutableNorms = WrappedArraySeq(mutableNorms).toImmutableSeq + (immutableEntities, immutableNorms) + } + } + val unzippedLabelsAndNorms = zippedLabelsAndNorms.unzip + + unzippedLabelsAndNorms + } + + def removeOneEntityBeforeAnother(entities: mutable.Seq[String], norms: mutable.Seq[String], triggerEntity: String, toBeRemovedShortened: String): Unit = { + var triggered = false + + entities.indices.reverse.foreach { index => + val entity = entities(index) + + if (entity == triggerEntity) + triggered = true + else { + if (triggered) + if (entity.endsWith(toBeRemovedShortened)) { + entities(index) = "O" + norms(index) = "" + } + else + triggered = false + } + } + } + + private def addLabelsAndNorms(label: String, norm: String, tokenInt: Interval, entities: mutable.Seq[String], norms: mutable.Seq[String]): Unit = { + // careful here: we may override some existing entities and norms + // but, given that the numeric entity rules tend to be high precision, this is probably Ok... + tokenInt.headOption.foreach { index => + entities(index) = "B-" + label + norms(index) = norm + } + tokenInt.tail.foreach { index => + entities(index) = "I-" + label + norms(index) = norm + } + } +} diff --git a/library/src/main/scala/org/clulab/numeric/actions/NumericActions.scala b/library/src/main/scala/org/clulab/numeric/actions/NumericActions.scala index e2c3fcf97..5d686c2ba 100644 --- a/library/src/main/scala/org/clulab/numeric/actions/NumericActions.scala +++ b/library/src/main/scala/org/clulab/numeric/actions/NumericActions.scala @@ -252,14 +252,14 @@ class NumericActions(seasonNormalizer: SeasonNormalizer, unitNormalizer: UnitNor /** filter out season homonyms (fall, spring) **/ def postprocessNumericEntities(mentions: Seq[Mention]): Seq[Mention] = { - def prevWordsMatch(words: Array[String], wordIndex: Int): Boolean = { + def prevWordsMatch(words: Seq[String], wordIndex: Int): Boolean = { val prevWords = words.slice(wordIndex - 2, wordIndex).map(_.toLowerCase) prevWords.exists(NumericActions.preSeasons) || prevWords.containsSlice(NumericActions.inThe) } - def contextWordsMatch(words: Array[String], wordIndex: Int): Boolean = { + def contextWordsMatch(words: Seq[String], wordIndex: Int): Boolean = { val window = 5 val contextWords = words.slice(wordIndex - window, wordIndex + window).map(_.toLowerCase) diff --git a/library/src/main/scala/org/clulab/numeric/package.scala b/library/src/main/scala/org/clulab/numeric/package.scala deleted file mode 100644 index 70559d0f9..000000000 --- a/library/src/main/scala/org/clulab/numeric/package.scala +++ /dev/null @@ -1,127 +0,0 @@ -package org.clulab - -import org.clulab.numeric.actions.NumericActions -import org.clulab.numeric.mentions.{DateMention, DateRangeMention, MeasurementMention, Norm, PercentageMention} -import org.clulab.odin.{EventMention, Mention} -import org.clulab.processors.{Document, Sentence} -import org.clulab.struct.Interval -import _root_.scala.util.control.Breaks._ - -package object numeric { - def displayMentions(mentions: Seq[Mention], doc: Document): Unit = { - val mentionsBySentence = mentions.groupBy(_.sentence).map { case (sentence, mentions) => - sentence -> mentions.sortBy(_.start) - }.withDefaultValue(Nil) - for ((s, i) <- doc.sentences.zipWithIndex) { - println(s"sentence #$i") - println(s.getSentenceText) - println("Tokens: " + s.words.indices.zip(s.words).zip(s.tags.get).mkString(", ")) - s.tags foreach (x => println("Tags: " + x.mkString(", "))) - s.entities foreach (x => println("Entities: " + x.mkString(", "))) - s.norms foreach (x => println("Norms: " + x.mkString(", "))) - println() - - val sortedMentions = mentionsBySentence(i).sortBy(_.label) - sortedMentions foreach displayMention - println() - } - } - - def displayMention(mention: Mention): Unit = { - val boundary = s"\t${"-" * 30}" - println(s"${mention.labels} => ${mention.text}") - println(boundary) - println(s"\tRule => ${mention.foundBy}") - val mentionType = mention.getClass.toString.split("""\.""").last - println(s"\tType => $mentionType") - println(s"\tInterval => ${mention.tokenInterval}") - mention match { - case norm: Norm => - println(s"\tNorm => ${norm.neNorm}") - println(s"\tNE => ${norm.neLabel}") - case _ => - } - println(boundary) - if (mention.arguments.nonEmpty) { - println("\tArgs:") - mention match { - case em: EventMention => - println(s"\ttrigger: ${em.trigger}") - displayArguments(em) - case _ => - displayArguments(mention) - } - println(s"$boundary") - } - println() - } - - def displayArguments(b: Mention): Unit = { - b.arguments foreach { - case (argName, ms) => - ms foreach { v => - println(s"\t * $argName ${v.labels.mkString("(", ", ", ")")} => ${v.text}") - } - } - } - - /** - * Sets the entities and norms fields in each Sentence based on the given numeric mentions - * @param doc This document is modified in place - * @param mentions The numeric mentions previously extracted - */ - def setLabelsAndNorms(doc: Document, mentions: Seq[Mention]): Unit = { - // - // initialize entities and norms - // - for (sentence <- doc.sentences) { - sentence.entities = sentence.entities.orElse(Some(Array.fill(sentence.size)("O"))) - sentence.norms = sentence.norms .orElse(Some(Array.fill(sentence.size)(""))) - } - - // - // convert numeric entities to entity labels and norms - // - for(mention <- mentions) { - if(NumericActions.isNumeric(mention) && mention.isInstanceOf[Norm]) { - addLabelsAndNorms(mention.asInstanceOf[Norm], mention.sentenceObj, mention.tokenInterval) - } - } - removeOneEntityBeforeAnother(doc, "B-LOC", "MEASUREMENT-LENGTH") - } - - def removeOneEntityBeforeAnother(doc: Document, triggerEntity: String, toBeRemovedShortened: String): Unit = { - // removes entities and norms for unallowable entity sequences, e.g., don't extract 'in' as 'inch' before B-LOC in '... Sahal 108 in Senegal' - // toBeRemovedShortened is entity without BIO- - for(s <- doc.sentences) { - val zippedEntities = s.entities.get.zipWithIndex - for ((e, i) <- zippedEntities) { - if (i > 0 && e == triggerEntity && s.entities.get(i-1).endsWith(toBeRemovedShortened)) { - s.entities.get(i - 1) = "O" - // go in reverse replacing indices and norms in the immediate preceding mention - breakable { - for ((en, j) <- zippedEntities.slice(0, i ).reverse) { - if (en.endsWith(toBeRemovedShortened)) { - s.entities.get(j) = "O" - s.norms.get(j) = "" - } else break() - } - } - } - } - } - } - - private def addLabelsAndNorms(m: Norm, s: Sentence, tokenInt: Interval): Unit = { - var first = true - val norm = m.neNorm - // careful here: we may override some existing entities and norms - // but, given that the numeric entity rules tend to be high precision, this is probably Ok... - for(i <- tokenInt.indices) { - val prefix = if(first) "B-" else "I-" - s.entities.get(i) = prefix + m.neLabel - s.norms.get(i) = norm - first = false - } - } -} diff --git a/library/src/main/scala/org/clulab/odin/impl/MarkdownGeneration.scala b/library/src/main/scala/org/clulab/odin/impl/MarkdownGeneration.scala index f6e282934..26c2252e8 100644 --- a/library/src/main/scala/org/clulab/odin/impl/MarkdownGeneration.scala +++ b/library/src/main/scala/org/clulab/odin/impl/MarkdownGeneration.scala @@ -3,6 +3,7 @@ package org.clulab.odin.impl import org.clulab.odin.impl.MarkdownGeneration._ import org.clulab.odin.impl.RuleReader.{DefaultAction, Rule} +import scala.collection.compat._ import scala.collection.mutable.ArrayBuffer case class RuleSchema( @@ -180,7 +181,7 @@ object MarkdownGeneration { extractorType = "CrossSentenceExtractor", labels = x.labels, priority = priorityString(x.priority), - action = if (r.action != DefaultAction) Some(r.action) else None, + action = Option.when(r.action != DefaultAction)(r.action), keep = x.keep, additional = Map( "leftWindow" -> x.leftWindow.toString, @@ -198,7 +199,7 @@ object MarkdownGeneration { extractorType = "TokenExtractor", labels = x.labels, priority = priorityString(x.priority), - action = if (r.action != DefaultAction) Some(r.action) else None, + action = Option.when(r.action != DefaultAction)(r.action), keep = x.keep, additional = Map.empty, arguments = Seq.empty @@ -213,7 +214,7 @@ object MarkdownGeneration { extractorType = "GraphExtractor", labels = x.labels, priority = priorityString(x.priority), - action = if (r.action != DefaultAction) Some(r.action) else None, + action = Option.when(r.action != DefaultAction)(r.action), keep = x.keep, additional = Map.empty, arguments = toArgSchema(x.pattern.arguments) diff --git a/library/src/main/scala/org/clulab/odin/impl/OdinResourceManager.scala b/library/src/main/scala/org/clulab/odin/impl/OdinResourceManager.scala index f6b8c2c7c..817d93d52 100644 --- a/library/src/main/scala/org/clulab/odin/impl/OdinResourceManager.scala +++ b/library/src/main/scala/org/clulab/odin/impl/OdinResourceManager.scala @@ -1,6 +1,7 @@ package org.clulab.odin.impl import java.io.{BufferedInputStream, InputStream} +import scala.collection.compat._ import scala.io.Source /** @@ -22,8 +23,7 @@ object OdinResourceManager { val embeddingsOption: Option[OdinResource] = constructorMap("embeddings") // cast as EmbeddingsResources, if present val embeddings: Option[EmbeddingsResource] = - if (embeddingsOption.nonEmpty) Some(embeddingsOption.get.asInstanceOf[EmbeddingsResource]) - else None + Option.when(embeddingsOption.nonEmpty)(embeddingsOption.get.asInstanceOf[EmbeddingsResource]) new OdinResourceManager(embeddings) } diff --git a/library/src/main/scala/org/clulab/odin/impl/RuleReader.scala b/library/src/main/scala/org/clulab/odin/impl/RuleReader.scala index a349b4193..45f9a1e35 100644 --- a/library/src/main/scala/org/clulab/odin/impl/RuleReader.scala +++ b/library/src/main/scala/org/clulab/odin/impl/RuleReader.scala @@ -13,6 +13,7 @@ import java.net.URL import java.nio.charset.Charset import java.nio.charset.StandardCharsets import java.util.{Collection, Map => JMap} +import scala.collection.compat._ import scala.io.{Codec, Source} import scala.jdk.CollectionConverters._ import scala.util.Using @@ -28,8 +29,7 @@ class RuleReader(val actions: Actions, val charset: Charset, val ruleDir: Option private val mirror = new ActionMirror(actions) val ruleYamlOpt = - if (OdinConfig.keepRule) Some(new Yaml(new Constructor(classOf[Map[String, Any]]))) - else None + Option.when(OdinConfig.keepRule)(new Yaml(new Constructor(classOf[Map[String, Any]]))) def read(input: String): Vector[Extractor] = { val rules = getRules(input) diff --git a/library/src/main/scala/org/clulab/odin/impl/Taxonomy.scala b/library/src/main/scala/org/clulab/odin/impl/Taxonomy.scala index 3afe9794a..96c3d2e57 100644 --- a/library/src/main/scala/org/clulab/odin/impl/Taxonomy.scala +++ b/library/src/main/scala/org/clulab/odin/impl/Taxonomy.scala @@ -1,7 +1,7 @@ package org.clulab.odin.impl -import org.clulab.scala.LazyList import java.util.{ Collection, Map => JMap } +import scala.collection.compat.immutable.LazyList import scala.jdk.CollectionConverters._ class Taxonomy(parents: Map[String, String]) { diff --git a/library/src/main/scala/org/clulab/odin/impl/Values.scala b/library/src/main/scala/org/clulab/odin/impl/Values.scala index c2e03bbd5..0b78e7f45 100644 --- a/library/src/main/scala/org/clulab/odin/impl/Values.scala +++ b/library/src/main/scala/org/clulab/odin/impl/Values.scala @@ -3,7 +3,7 @@ package org.clulab.odin.impl import org.clulab.processors.Document trait Values { - def values(strings: Option[Array[String]], msg: String): Array[String] = + def values(strings: Option[Seq[String]], msg: String): Seq[String] = strings match { case None => sys.error(msg) case Some(strings) => strings diff --git a/library/src/main/scala/org/clulab/processors/Document.scala b/library/src/main/scala/org/clulab/processors/Document.scala index 6435ab94c..1c9e1ece3 100644 --- a/library/src/main/scala/org/clulab/processors/Document.scala +++ b/library/src/main/scala/org/clulab/processors/Document.scala @@ -1,46 +1,52 @@ package org.clulab.processors -import java.io.PrintWriter - -import org.clulab.struct.{CorefChains, DirectedGraphEdgeIterator} +import org.clulab.struct.CorefChains import org.clulab.utils.Hash import org.clulab.utils.Serializer import org.json4s.JString import org.json4s.JValue import org.json4s.jackson.prettyJson -import scala.collection.mutable - /** * Stores all annotations for one document. * Written by: Mihai Surdeanu and Gus Hahn-Powell. * Last Modified: Add apply method to copy Document. */ -class Document(val sentences: Array[Sentence]) extends Serializable { - +class Document( + val sentences: Seq[Sentence], /** Unique id for this document, if any */ - var id: Option[String] = None - + val id: Option[String] = None, /** Clusters of coreferent mentions */ - var coreferenceChains: Option[CorefChains] = None - + val coreferenceChains: Option[CorefChains] = None, /** The original text corresponding to this document, if it was preserved by the corresponding processor */ - var text: Option[String] = None - + val text: Option[String] = None, /** Map of any arbitrary document attachments such as document creation time */ - protected var attachments: Option[mutable.HashMap[String, DocumentAttachment]] = None - - protected var documentCreationTime:Option[String] = None + val attachments: Option[DocumentAttachments.Type] = None, + /** + * The document creation time using the CoreNLP format + * See useFixedDate here for more details: https://stanfordnlp.github.io/CoreNLP/ner.html#setting-document-date + * The DCT will impact how Sentence.norms are generated for DATE expressions. + */ + val dct: Option[String] = None +) extends Serializable { + + def copy( + sentences: Seq[Sentence] = sentences, + id: Option[String] = id, + coreferenceChains: Option[CorefChains] = coreferenceChains, + text: Option[String] = text, + attachments: Option[DocumentAttachments.Type] = None, + dct: Option[String] = dct + ): Document = new Document(sentences, id, coreferenceChains, text, attachments, dct) /** Clears any internal state potentially constructed by the annotators */ - def clear(): Unit = { } + def clear(): Unit = { } // This is for subclass support. /** * Used to compare Documents. * @return a hash (Int) based primarily on the sentences, ignoring attachments */ def equivalenceHash: Int = { - val stringCode = "org.clulab.processors.Document" // Hash representing the sentences. @@ -66,133 +72,6 @@ class Document(val sentences: Array[Sentence]) extends Serializable { Hash.ordered(sentences.map(_.ambivalenceHash)) ) - /** Adds an attachment to the document's attachment map */ - def addAttachment(name: String, attachment: DocumentAttachment): Unit = { - if (attachments.isEmpty) - attachments = Some(new mutable.HashMap[String, DocumentAttachment]()) - attachments.get += name -> attachment - } - - /** Retrieves the attachment with the given name */ - def getAttachment(name: String): Option[DocumentAttachment] = attachments.flatMap(_.get(name)) - - def removeAttachment(name: String): Unit = attachments.foreach(_ -= name) - - /** Retrieves keys to all attachments so that the entire collection can be read - * for purposes including but not limited to serialization. If there are no - * attachments, that is attachments == None, an empty set is returned. - * This does not distinguish between None and Some(HashMap.empty), especially - * since the latter should not be possible because of the lazy initialization. - */ - def getAttachmentKeys: collection.Set[String] = { - attachments.map { attachments => - attachments.keySet - }.getOrElse(collection.Set.empty[String]) - } - - /** - * Sets the document creation time using the CoreNLP format. - * See useFixedDate here for more details: https://stanfordnlp.github.io/CoreNLP/ner.html#setting-document-date - * The DCT will impacts how Sentence.norms are generated for DATE expressions - * @param dct Document creation time - */ - def setDCT(dct:String): Unit = documentCreationTime = Some(dct) - - def getDCT: Option[String] = documentCreationTime - - def prettyPrint(pw: PrintWriter): Unit = { - // let's print the sentence-level annotations - var sentenceCount = 0 - for (sentence <- sentences) { - pw.println("Sentence #" + sentenceCount + ":") - pw.println("Tokens: " + sentence.words.zipWithIndex.mkString(" ")) - pw.println("Start character offsets: " + sentence.startOffsets.mkString(" ")) - pw.println("End character offsets: " + sentence.endOffsets.mkString(" ")) - - // these annotations are optional, so they are stored using Option objects, hence the foreach statement - sentence.lemmas.foreach(lemmas => pw.println(s"Lemmas: ${lemmas.mkString(" ")}")) - sentence.tags.foreach(tags => pw.println(s"POS tags: ${tags.mkString(" ")}")) - sentence.chunks.foreach(chunks => pw.println(s"Chunks: ${chunks.mkString(" ")}")) - sentence.entities.foreach(entities => pw.println(s"Named entities: ${entities.mkString(" ")}")) - sentence.norms.foreach(norms => pw.println(s"Normalized entities: ${norms.mkString(" ")}")) - sentence.universalBasicDependencies.foreach(dependencies => { - pw.println("Basic syntactic dependencies:") - val iterator = new DirectedGraphEdgeIterator[String](dependencies) - while(iterator.hasNext) { - val dep = iterator.next() - // note that we use offsets starting at 0 (unlike CoreNLP, which uses offsets starting at 1) - pw.println(" head:" + dep._1 + " modifier:" + dep._2 + " label:" + dep._3) - } - }) - sentence.universalEnhancedDependencies.foreach(dependencies => { - pw.println("Enhanced syntactic dependencies:") - val iterator = new DirectedGraphEdgeIterator[String](dependencies) - while(iterator.hasNext) { - val dep = iterator.next() - // note that we use offsets starting at 0 (unlike CoreNLP, which uses offsets starting at 1) - pw.println(" head:" + dep._1 + " modifier:" + dep._2 + " label:" + dep._3) - } - }) - sentence.semanticRoles.foreach(dependencies => { - pw.println("Semantic dependencies:") - val iterator = new DirectedGraphEdgeIterator[String](dependencies) - while(iterator.hasNext) { - val dep = iterator.next() - // note that we use offsets starting at 0 (unlike CoreNLP, which uses offsets starting at 1) - pw.println(" head:" + dep._1 + " modifier:" + dep._2 + " label:" + dep._3) - } - }) - sentence.enhancedSemanticRoles.foreach(dependencies => { - pw.println("Enhanced semantic dependencies:") - val iterator = new DirectedGraphEdgeIterator[String](dependencies) - while(iterator.hasNext) { - val dep = iterator.next() - // note that we use offsets starting at 0 (unlike CoreNLP, which uses offsets starting at 1) - pw.println(" head:" + dep._1 + " modifier:" + dep._2 + " label:" + dep._3) - } - }) - sentence.syntacticTree.foreach(tree => { - pw.println("Constituent tree: " + tree.toStringDepth(showHead = false)) - // see the org.clulab.struct.Tree class for more information - // on syntactic trees, including access to head phrases/words - }) - - sentenceCount += 1 - pw.println("\n") - } - - // let's print the coreference chains - coreferenceChains.foreach(chains => { - for (chain <- chains.getChains) { - pw.println("Found one coreference chain containing the following mentions:") - for (mention <- chain) { - // note that all these offsets start at 0 too - pw.println("\tsentenceIndex:" + mention.sentenceIndex + - " headIndex:" + mention.headIndex + - " startTokenOffset:" + mention.startOffset + - " endTokenOffset:" + mention.endOffset + - " text: " + sentences(mention.sentenceIndex).words.slice(mention.startOffset, mention.endOffset).mkString("[", " ", "]")) - } - } - }) - } - - def assimilate(document: Document, textOpt: Option[String]): Document = { - id = document.id - coreferenceChains = document.coreferenceChains - text = textOpt - attachments = document.attachments - documentCreationTime = document.documentCreationTime - this - } - - // sentences are a val, so they must be initialized through the construction of a new Document. - // Thereafter, the remaining values can be assimilated from the old document. The shortcut - // is used so that subclasses don't have to duplicate almost everything in their copy. - def copy(sentences: Array[Sentence] = sentences, textOpt: Option[String] = text): Document = { - new Document(sentences).assimilate(this, textOpt) - } - def offset(offset: Int): Document = // If a subclass of Document constructs itself with an attachment or a documentCreationTime that // would be overwritten on the copy(), then it should provide its own copy() method(s). @@ -202,20 +81,37 @@ class Document(val sentences: Array[Sentence]) extends Serializable { object Document { - def apply(sentences: Array[Sentence]): Document = new Document(sentences) + def apply(sentences: Seq[Sentence]): Document = apply(sentences, text = None) + + def apply(sentences: Seq[Sentence], text: Option[String]): Document = apply(id = None, sentences, coref = None, text) - def apply(id: Option[String], sentences: Array[Sentence], coref: Option[CorefChains], text: Option[String]): Document = { - val d = Document(sentences) - d.id = id - d.coreferenceChains = coref - d.text = text - d + def apply(id: Option[String], sentences: Seq[Sentence], coref: Option[CorefChains], text: Option[String]): Document = { + val document = new Document( + sentences, + id = id, + coreferenceChains = coref, + text = text + ) + + document } - /** Return a new Document with relevant fields copied from the given Document. */ - def apply (doc: Document): Document = - Document(doc.id, doc.sentences, doc.coreferenceChains, doc.text) + /** Return a new Document with some relevant fields copied from the given Document. */ + def apply(doc: Document): Document = + apply(doc.id, doc.sentences, doc.coreferenceChains, doc.text) + + def apply(doc: Document, sentences: Seq[Sentence]): Document = { + val newDocument = new Document( + sentences, + id = doc.id, + coreferenceChains = doc.coreferenceChains, + text = doc.text, + attachments = doc.attachments, + dct = doc.dct + ) + newDocument + } } /** @@ -317,6 +213,11 @@ trait JsonSerializerAble { */ trait DocumentAttachment extends DocumentAble with DocumentSerializerAble with JsonSerializerAble +object DocumentAttachments { + type Type = Map[String, DocumentAttachment] +} + + /** * Designed to store intermediate attachments that are only used to pass information between processor components. * Thus, these do not need to be serialized diff --git a/library/src/main/scala/org/clulab/processors/Processor.scala b/library/src/main/scala/org/clulab/processors/Processor.scala index 9528d613d..e856f20a5 100644 --- a/library/src/main/scala/org/clulab/processors/Processor.scala +++ b/library/src/main/scala/org/clulab/processors/Processor.scala @@ -2,6 +2,8 @@ package org.clulab.processors import org.clulab.processors.clu.BalaurProcessor +import scala.collection.mutable + /** * User: mihais * Date: 3/1/13 @@ -10,7 +12,7 @@ import org.clulab.processors.clu.BalaurProcessor trait Processor { /** Constructs a document of tokens from free text; includes sentence splitting and tokenization. */ - def mkDocument (text:String, keepText:Boolean = false): Document + def mkDocument(text:String, keepText:Boolean = false): Document // The documents here were created with Processor.mkDocument, which could have created a subclassed // Document or documents with certain fields already filled in. This implementation only handles @@ -21,31 +23,35 @@ trait Processor { require(documents.length > 1) val headDocument = documents.head val tailDocuments = documents.tail - val combinedSentences = documents.flatMap(_.sentences).toArray - val combinedDocument = new Document(combinedSentences) val headId = headDocument.id require(tailDocuments.forall(_.id == headId)) - combinedDocument.id = headId - - require(combinedDocument.text.isEmpty) - combinedDocument.text = combinedTextOpt - + val headDctOpt = headDocument.dct + require(documents.tail.forall(_.dct == headDctOpt)) // Coreference chains involve Mentions that include references to documents. The Mentions are being // moved to a new Document and it would be infeasible to move the chains. - require(combinedDocument.coreferenceChains.isEmpty) require(documents.forall(_.coreferenceChains.isEmpty)) - documents.foreach { document => - document.getAttachmentKeys.foreach { attachmentKey => - require(combinedDocument.getAttachment(attachmentKey).forall(_ == document.getAttachment(attachmentKey).get)) - combinedDocument.addAttachment(attachmentKey, document.getAttachment(attachmentKey).get) - } + val allAttachments = documents.flatMap { document => + document.attachments.getOrElse(Map.empty).toSeq } + // This will remove duplicate (key, value) pairs. + val distinctAttachments = allAttachments.distinct + // If for any key, there are different, contradictory values, only one value will make it into the map. + val attachments = distinctAttachments.toMap + + require(attachments.size == distinctAttachments.length, "Attachments can't contradict each other. Each key needs to map onto the same value.") + + val combinedSentences = documents.flatMap(_.sentences) + val combinedDocument = new Document( + sentences = combinedSentences, + id = headId, + coreferenceChains = None, + text = combinedTextOpt, + attachments = Some(attachments), + dct = headDctOpt + ) - val headDctOpt = headDocument.getDCT - require(documents.tail.forall(_.getDCT == headDctOpt)) - headDctOpt.foreach(combinedDocument.setDCT) combinedDocument } @@ -76,16 +82,22 @@ trait Processor { } /** Constructs a document of tokens from an array of untokenized sentences. */ - def mkDocumentFromSentences (sentences:Iterable[String], - keepText:Boolean = false, - charactersBetweenSentences:Int = 1): Document + def mkDocumentFromSentences( + sentences: Iterable[String], + keepText: Boolean = false, + charactersBetweenSentences: Int = 1 + ): Document /** Constructs a document of tokens from an array of tokenized sentences. */ - def mkDocumentFromTokens (sentences:Iterable[Iterable[String]], - keepText:Boolean = false, - charactersBetweenSentences:Int = 1, - charactersBetweenTokens:Int = 1): Document + def mkDocumentFromTokens( + sentences: Iterable[Iterable[String]], + keepText: Boolean = false, + charactersBetweenSentences: Int = 1, + charactersBetweenTokens: Int = 1 + ): Document + /** Lemmatization; modifies the document in place. */ + def lemmatize(words: Seq[String]): Seq[String] // Side-effecting annotations. These modify the document in place, which is not too elegant. // There are two reasons for this: @@ -94,54 +106,54 @@ trait Processor { // (2) It is more efficient during annotate() where all the possible operations are chained. /** Part of speech tagging; modifies the document in place. */ - def tagPartsOfSpeech (doc:Document): Unit - - /** Lematization; modifies the document in place. */ - def lemmatize (doc:Document): Unit + def tagPartsOfSpeech(doc: Document): Unit /** Named Entity Recognition; modifies the document in place. */ - def recognizeNamedEntities (doc:Document): Unit + def recognizeNamedEntities(doc: Document): Unit /** Syntactic parsing; modifies the document in place. */ - def parse (doc:Document): Unit + def parse(doc:Document): Unit /** Semantic role labeling */ - def srl (doc: Document): Unit + def srl(doc: Document): Unit /** Shallow parsing; modifies the document in place. */ - def chunking (doc:Document): Unit + def chunking(doc:Document): Unit /** Coreference resolution; modifies the document in place. */ - def resolveCoreference (doc:Document): Unit + def resolveCoreference(doc:Document): Unit /** Discourse parsing; modifies the document in place. */ - def discourse (doc:Document): Unit + def discourse(doc:Document): Unit /** Relation extraction; modifies the document in place. */ def relationExtraction(doc:Document): Unit /** Annotate the given text string, specify whether to retain the text in the resultant Document. */ - def annotate (text:String, keepText:Boolean = false): Document = { - val doc = mkDocument(text, keepText) - if (doc.sentences.nonEmpty) - annotate(doc) - else - doc + def annotate(text: String, keepText: Boolean = false): Document = { + val tokenizedDoc = mkDocument(text, keepText) + val annotatedDoc = // For now, these two documents have the same type. + if (tokenizedDoc.sentences.nonEmpty) annotate(tokenizedDoc) + else tokenizedDoc + + annotatedDoc } /** Annotate the given sentences, specify whether to retain the text in the resultant Document. */ - def annotateFromSentences ( - sentences:Iterable[String], - keepText:Boolean = false): Document = { + def annotateFromSentences( + sentences: Iterable[String], + keepText: Boolean = false + ): Document = { val doc = mkDocumentFromSentences(sentences, keepText) annotate(doc) } /** Annotate the given tokens, specify whether to retain the text in the resultant Document. */ - def annotateFromTokens ( + def annotateFromTokens( sentences:Iterable[Iterable[String]], - keepText:Boolean = false): Document = { + keepText:Boolean = false + ): Document = { val doc = mkDocumentFromTokens(sentences, keepText) annotate(doc) } diff --git a/library/src/main/scala/org/clulab/processors/Sentence.scala b/library/src/main/scala/org/clulab/processors/Sentence.scala index 0465226c1..acb14b56b 100644 --- a/library/src/main/scala/org/clulab/processors/Sentence.scala +++ b/library/src/main/scala/org/clulab/processors/Sentence.scala @@ -1,21 +1,18 @@ package org.clulab.processors -import org.clulab.scala.WrappedArray._ import org.clulab.struct.{DirectedGraph, GraphMap, RelationTriple, Tree} -import org.clulab.struct.GraphMap._ import org.clulab.utils.Hash -import org.clulab.utils.SeqUtils import scala.collection.mutable /** Stores the annotations for a single sentence */ class Sentence( /** Raw tokens in this sentence; these MUST match the original text */ - val raw: Array[String], + val raw: Seq[String], /** Start character offsets for the raw tokens; start at 0 */ - val startOffsets: Array[Int], + val startOffsets: Seq[Int], /** End character offsets for the raw tokens; start at 0 */ - val endOffsets: Array[Int], + val endOffsets: Seq[Int], /** * Words produced from raw tokens, closer to what the downstream components expect @@ -24,25 +21,25 @@ class Sentence( * However, the number of raw tokens MUST always equal the number of words, so if the exact text must be recovered, * please use the raw tokens with the same positions */ - val words: Array[String]) extends Serializable { + val words: Seq[String], /** POS tags for words */ - var tags: Option[Array[String]] = None + val tags: Option[Seq[String]] = None, /** Lemmas */ - var lemmas: Option[Array[String]] = None + val lemmas: Option[Seq[String]] = None, /** NE labels */ - var entities: Option[Array[String]] = None + val entities: Option[Seq[String]] = None, /** Normalized values of named/numeric entities, such as dates */ - var norms: Option[Array[String]] = None + val norms: Option[Seq[String]] = None, /** Shallow parsing labels */ - var chunks: Option[Array[String]] = None + val chunks: Option[Seq[String]] = None, /** Constituent tree of this sentence; includes head words */ - var syntacticTree: Option[Tree] = None + val syntacticTree: Option[Tree] = None, /** DAG of syntactic and semantic dependencies; word offsets start at 0 */ - var graphs: GraphMap = GraphMap() + val graphs: GraphMap.Type = GraphMap.empty, /** Relation triples from OpenIE */ - var relations:Option[Array[RelationTriple]] = None - + val relations:Option[Seq[RelationTriple]] = None +) extends Serializable { def size:Int = raw.length @@ -66,7 +63,7 @@ class Sentence( def equivalenceHash: Int = { val stringCode = "org.clulab.processors.Sentence" - def getAnnotationsHash(labelsOpt: Option[Array[_]]): Int = labelsOpt + def getAnnotationsHash(labelsOpt: Option[Seq[_]]): Int = labelsOpt .map { labels => val hs = labels.map(_.hashCode) val result = Hash.withLast(labels.length)( @@ -98,39 +95,38 @@ class Sentence( * * @return A directed graph of dependencies if any exist, otherwise None */ - def dependencies:Option[DirectedGraph[String]] = graphs match { - case collapsed if collapsed.contains(UNIVERSAL_ENHANCED) => collapsed.get(UNIVERSAL_ENHANCED) - case basic if basic.contains(UNIVERSAL_BASIC) => basic.get(UNIVERSAL_BASIC) + def dependencies: Option[DirectedGraph[String]] = graphs match { + case collapsed if collapsed.contains(GraphMap.UNIVERSAL_ENHANCED) => collapsed.get(GraphMap.UNIVERSAL_ENHANCED) + case basic if basic.contains(GraphMap.UNIVERSAL_BASIC) => basic.get(GraphMap.UNIVERSAL_BASIC) case _ => None } /** Fetches the universal basic dependencies */ - def universalBasicDependencies:Option[DirectedGraph[String]] = graphs.get(UNIVERSAL_BASIC) + def universalBasicDependencies: Option[DirectedGraph[String]] = graphs.get(GraphMap.UNIVERSAL_BASIC) /** Fetches the universal enhanced dependencies */ - def universalEnhancedDependencies:Option[DirectedGraph[String]] = graphs.get(UNIVERSAL_ENHANCED) + def universalEnhancedDependencies: Option[DirectedGraph[String]] = graphs.get(GraphMap.UNIVERSAL_ENHANCED) /** Fetches the Stanford basic dependencies */ - def stanfordBasicDependencies:Option[DirectedGraph[String]] = graphs.get(STANFORD_BASIC) + def stanfordBasicDependencies: Option[DirectedGraph[String]] = graphs.get(GraphMap.STANFORD_BASIC) /** Fetches the Stanford collapsed dependencies */ - def stanfordCollapsedDependencies:Option[DirectedGraph[String]] = graphs.get(STANFORD_COLLAPSED) + def stanfordCollapsedDependencies: Option[DirectedGraph[String]] = graphs.get(GraphMap.STANFORD_COLLAPSED) - def semanticRoles:Option[DirectedGraph[String]] = graphs.get(SEMANTIC_ROLES) - def enhancedSemanticRoles:Option[DirectedGraph[String]] = graphs.get(ENHANCED_SEMANTIC_ROLES) + def semanticRoles: Option[DirectedGraph[String]] = graphs.get(GraphMap.SEMANTIC_ROLES) - def hybridDependencies:Option[DirectedGraph[String]] = graphs.get(HYBRID_DEPENDENCIES) + def enhancedSemanticRoles: Option[DirectedGraph[String]] = graphs.get(GraphMap.ENHANCED_SEMANTIC_ROLES) - def setDependencies(depType: String, deps: DirectedGraph[String]): Unit = graphs += (depType -> deps) + def hybridDependencies: Option[DirectedGraph[String]] = graphs.get(GraphMap.HYBRID_DEPENDENCIES) /** * Recreates the text of the sentence, preserving the original number of white spaces between tokens * * @return the text of the sentence */ - def getSentenceText:String = getSentenceFragmentText(0, words.length) + def getSentenceText: String = getSentenceFragmentText(0, words.length) - def getSentenceFragmentText(start:Int, end:Int):String = { + def getSentenceFragmentText(start: Int, end: Int):String = { // optimize the single token case if (end - start == 1) raw(start) else { @@ -149,49 +145,52 @@ class Sentence( } } - /** Reverts the current sentence */ - def revert():Sentence = { - val reverted = new Sentence( - SeqUtils.revert(raw).toArray, - SeqUtils.revert(startOffsets).toArray, - SeqUtils.revert(endOffsets).toArray, - SeqUtils.revert(words).toArray) - if(tags.nonEmpty) - reverted.tags = Some(SeqUtils.revert(tags.get).toArray) - if(lemmas.nonEmpty) - reverted.lemmas = Some(SeqUtils.revert(lemmas.get).toArray) - if(entities.nonEmpty) - reverted.entities = Some(SeqUtils.revert(entities.get).toArray) - if(norms.nonEmpty) - reverted.norms = Some(SeqUtils.revert(norms.get).toArray) - if(chunks.nonEmpty) - reverted.chunks = Some(SeqUtils.revert(chunks.get).toArray) - - // TODO: revert syntacticTree and graphs! - - reverted - } + /** Reverses the current sentence */ + def reverse(): Sentence = { + val reversedSentence = Sentence( + raw.reverse, + startOffsets.reverse, + endOffsets.reverse, + words.reverse, + tags.map(_.reverse), + lemmas.map(_.reverse), + entities.map(_.reverse), + norms.map(_.reverse), + chunks.map(_.reverse), + // TODO: revert syntacticTree and graphs! + syntacticTree, + graphs, + relations + ) - def assimilate(sentence: Sentence): Sentence = { - tags = sentence.tags - lemmas = sentence.lemmas - entities = sentence.entities - norms = sentence.norms - chunks = sentence.chunks - syntacticTree = sentence.syntacticTree - graphs = sentence.graphs - relations = sentence.relations - this + reversedSentence } - def copy(raw: Array[String] = raw, startOffsets: Array[Int] = startOffsets, endOffsets: Array[Int] = endOffsets, words: Array[String] = words): Sentence = - new Sentence(raw, startOffsets, endOffsets, words).assimilate(this) + def copy( + raw: Seq[String] = raw, + startOffsets: Seq[Int] = startOffsets, + endOffsets: Seq[Int] = endOffsets, + words: Seq[String] = words, + + tags: Option[Seq[String]] = tags, + lemmas: Option[Seq[String]] = lemmas, + entities: Option[Seq[String]] = entities, + norms: Option[Seq[String]] = norms, + chunks: Option[Seq[String]] = chunks, + syntacticTree: Option[Tree] = syntacticTree, + graphs: GraphMap.Type = graphs, + relations: Option[Seq[RelationTriple]] = relations + ): Sentence = + new Sentence( + raw, startOffsets, endOffsets, words, + tags, lemmas, entities, norms, chunks, syntacticTree, graphs, relations + ) def offset(offset: Int): Sentence = { if (offset == 0) this else { - val newStartOffsets = startOffsets.map(_ + offset).toArray - val newEndOffsets = endOffsets.map(_ + offset).toArray + val newStartOffsets = startOffsets.map(_ + offset) + val newEndOffsets = endOffsets.map(_ + offset) copy(startOffsets = newStartOffsets, endOffsets = newEndOffsets) } @@ -201,43 +200,35 @@ class Sentence( object Sentence { def apply( - raw:Array[String], - startOffsets: Array[Int], - endOffsets: Array[Int]): Sentence = + raw: Seq[String], + startOffsets: Seq[Int], + endOffsets: Seq[Int]): Sentence = new Sentence(raw, startOffsets, endOffsets, raw) // words are identical to raw tokens (a common situation) def apply( - raw:Array[String], - startOffsets: Array[Int], - endOffsets: Array[Int], - words: Array[String]): Sentence = + raw: Seq[String], + startOffsets: Seq[Int], + endOffsets: Seq[Int], + words: Seq[String]): Sentence = new Sentence(raw, startOffsets, endOffsets, words) def apply( - raw: Array[String], - startOffsets: Array[Int], - endOffsets: Array[Int], - words: Array[String], - tags: Option[Array[String]], - lemmas: Option[Array[String]], - entities: Option[Array[String]], - norms: Option[Array[String]], - chunks: Option[Array[String]], - tree: Option[Tree], - deps: GraphMap, - relations: Option[Array[RelationTriple]] + raw: Seq[String], + startOffsets: Seq[Int], + endOffsets: Seq[Int], + words: Seq[String], + tags: Option[Seq[String]], + lemmas: Option[Seq[String]], + entities: Option[Seq[String]] = None, + norms: Option[Seq[String]] = None, + chunks: Option[Seq[String]] = None, + tree: Option[Tree] = None, + deps: GraphMap.Type = GraphMap.empty, + relations: Option[Seq[RelationTriple]] = None ): Sentence = { - val s = Sentence(raw, startOffsets, endOffsets, words) - // update annotations - s.tags = tags - s.lemmas = lemmas - s.entities = entities - s.norms = norms - s.chunks = chunks - s.syntacticTree = tree - s.graphs = deps - s.relations = relations - s + new Sentence( + raw, startOffsets, endOffsets, words, + tags, lemmas, entities, norms, chunks, tree, deps, relations + ) } - -} \ No newline at end of file +} diff --git a/library/src/main/scala/org/clulab/processors/clu/BalaurProcessor.scala b/library/src/main/scala/org/clulab/processors/clu/BalaurProcessor.scala index b791d181e..2af5a1d3a 100644 --- a/library/src/main/scala/org/clulab/processors/clu/BalaurProcessor.scala +++ b/library/src/main/scala/org/clulab/processors/clu/BalaurProcessor.scala @@ -2,27 +2,28 @@ package org.clulab.processors.clu import com.typesafe.config.Config import com.typesafe.config.ConfigFactory -import org.clulab.numeric.{NumericEntityRecognizer, setLabelsAndNorms} +import org.clulab.numeric.NumericEntityRecognizer +import org.clulab.numeric.NumericUtils import org.clulab.processors.{Document, Processor, Sentence} -import org.clulab.processors.clu.tokenizer._ -import org.clulab.scala.WrappedArray._ -import org.clulab.scala_transformers.encoder.TokenClassifier +import org.clulab.processors.clu.tokenizer.Lemmatizer +import org.clulab.processors.clu.tokenizer.{EnglishLemmatizer, PortugueseLemmatizer, SpanishLemmatizer} +import org.clulab.processors.clu.tokenizer.Tokenizer +import org.clulab.processors.clu.tokenizer.{OpenDomainEnglishTokenizer, OpenDomainPortugueseTokenizer, OpenDomainSpanishTokenizer} +import org.clulab.processors.hexatagging.HexaDecoder import org.clulab.scala_transformers.encoder.EncoderMaxTokensRuntimeException +import org.clulab.scala_transformers.encoder.TokenClassifier import org.clulab.sequences.{LexiconNER, NamedEntity} import org.clulab.struct.DirectedGraph import org.clulab.struct.GraphMap import org.clulab.utils.{Configured, MathUtils, ToEnhancedDependencies} +import org.clulab.utils.WrappedArraySeq import org.slf4j.{Logger, LoggerFactory} -import org.clulab.odin.Mention - import BalaurProcessor._ -import PostProcessor._ -import org.clulab.processors.hexatagging.HexaDecoder class BalaurProcessor protected ( val config: Config, - val optionalNER: Option[LexiconNER], + val lexiconNerOpt: Option[LexiconNER], val numericEntityRecognizerOpt: Option[NumericEntityRecognizer], wordTokenizer: Tokenizer, wordLemmatizer: Lemmatizer, @@ -34,230 +35,245 @@ class BalaurProcessor protected ( // standard, abbreviated constructor def this( config: Config = ConfigFactory.load("balaurprocessor"), - optionalNER: Option[LexiconNER] = None, + lexiconNerOpt: Option[LexiconNER] = None, seasonPathOpt: Option[String] = Some("/org/clulab/numeric/SEASON.tsv") ) = this( config, - optionalNER, + lexiconNerOpt, newNumericEntityRecognizerOpt(seasonPathOpt), - mkTokenizer(BalaurProcessor.getArgString(config, s"$prefix.language", Some("EN"))), - mkLemmatizer(BalaurProcessor.getArgString(config, s"$prefix.language", Some("EN"))), + mkTokenizer(getConfigArgString(config, s"$prefix.language", Some("EN"))), + mkLemmatizer(getConfigArgString(config, s"$prefix.language", Some("EN"))), // TokenClassifier.fromFiles(config.getString(s"$prefix.modelName")) TokenClassifier.fromResources(config.getString(s"$prefix.modelName")) ) def copy( - configOpt: Option[Config] = None, - optionalNEROpt: Option[Option[LexiconNER]] = None, - numericEntityRecognizerOptOpt: Option[Option[NumericEntityRecognizer]] = None, - wordTokenizerOpt: Option[Tokenizer] = None, - wordLemmatizerOpt: Option[Lemmatizer] = None, - tokenClassifierOpt: Option[TokenClassifier] = None + config: Config = config, + lexiconNerOpt: Option[LexiconNER] = lexiconNerOpt, + numericEntityRecognizerOpt: Option[NumericEntityRecognizer] = numericEntityRecognizerOpt, + wordTokenizer: Tokenizer = wordTokenizer, + wordLemmatizer: Lemmatizer = wordLemmatizer, + tokenClassifier: TokenClassifier = tokenClassifier ): BalaurProcessor = { new BalaurProcessor( - configOpt.getOrElse(this.config), - optionalNEROpt.getOrElse(this.optionalNER), - numericEntityRecognizerOptOpt.getOrElse(this.numericEntityRecognizerOpt), - wordTokenizerOpt.getOrElse(this.wordTokenizer), - wordLemmatizerOpt.getOrElse(this.wordLemmatizer), - tokenClassifierOpt.getOrElse(this.tokenClassifier) + config, + lexiconNerOpt, + numericEntityRecognizerOpt, + wordTokenizer, + wordLemmatizer, + tokenClassifier ) } + // TODO: Try not to make a new decoder for each processor? val hexaDecoder = new HexaDecoder() override def getConf: Config = config + // TODO: Why not make the wordTokenizer a val then? + def tokenizer: Tokenizer = wordTokenizer + override def mkDocument(text: String, keepText: Boolean): Document = { DocumentMaker.mkDocument(tokenizer, text, keepText) } - def tokenizer: Tokenizer = wordTokenizer - - override def mkDocumentFromSentences(sentences: Iterable[String], + override def mkDocumentFromSentences( + sentences: Iterable[String], keepText: Boolean, - charactersBetweenSentences: Int): Document = { + charactersBetweenSentences: Int + ): Document = { DocumentMaker.mkDocumentFromSentences(tokenizer, sentences, keepText, charactersBetweenSentences) } - override def mkDocumentFromTokens(sentences: Iterable[Iterable[String]], + override def mkDocumentFromTokens( + sentences: Iterable[Iterable[String]], keepText: Boolean, charactersBetweenSentences: Int, - charactersBetweenTokens: Int): Document = { + charactersBetweenTokens: Int + ): Document = { DocumentMaker.mkDocumentFromTokens(sentences, keepText, charactersBetweenSentences, charactersBetweenSentences) } - override def tagPartsOfSpeech(doc: Document): Unit = { - throw new RuntimeException("ERROR: cannot call this method on its own in this processor!") - } - - /** Lematization; modifies the document in place */ - override def lemmatize(doc: Document): Unit = { - for(sent <- doc.sentences) { - val lemmas = new Array[String](sent.size) - for(i <- sent.words.indices) { - lemmas(i) = wordLemmatizer.lemmatizeWord(sent.words(i)) - - // a lemma may be empty in some weird Unicode situations - if(lemmas(i).isEmpty) { - logger.debug(s"""WARNING: Found empty lemma for word #$i "${sent.words(i)}" in sentence: ${sent.words.mkString(" ")}""") - lemmas(i) = sent.words(i).toLowerCase() - } - } - sent.lemmas = Some(lemmas) + override def lemmatize(words: Seq[String]): Seq[String] = { + val lemmas = words.zipWithIndex.map { case (word, index) => + val lemma = wordLemmatizer.lemmatizeWord(word) + // A lemma may be empty in some weird Unicode situations. + val nonEmptyLemma = + if (lemma.isEmpty) { + logger.debug(s"""WARNING: Found empty lemma for word #$index "$word" in sentence: ${words.mkString(" ")}""") + word.toLowerCase() + } + else lemma + + nonEmptyLemma } + + lemmas } /** Generates cheap lemmas with the word in lower case, for languages where a lemmatizer is not available */ - def cheapLemmatize(doc:Document): Unit = { - for(sent <- doc.sentences) { - val lemmas = sent.words.map(_.toLowerCase()).toArray - sent.lemmas = Some(lemmas) - } - } + def cheapLemmatize(sentence: Sentence): Seq[String] = + sentence.words.map(_.toLowerCase()) - override def recognizeNamedEntities(doc: Document): Unit = { - throw new RuntimeException("ERROR: cannot call this method on its own in this procecessor!") - } + // TODO: Just don't include anything that calls this. + def throwCannotCallException(methodName: String): Unit = + throw new RuntimeException(s"ERROR: cannot call $methodName on its own in this processor!") - override def parse(doc: Document): Unit = { - throw new RuntimeException("ERROR: cannot call this method on its own in this procecessor!") - } + override def tagPartsOfSpeech(doc: Document): Unit = throwCannotCallException("tagPartsOfSpeech") - override def srl(doc: Document): Unit = { - throw new RuntimeException("ERROR: functionality not supported in this procecessor!") - } + override def recognizeNamedEntities(doc: Document): Unit = throwCannotCallException("recognizeNamedEntities") - override def chunking(doc: Document): Unit = { - throw new RuntimeException("ERROR: cannot call this method on its own in this procecessor!") - } + override def parse(doc: Document): Unit = throwCannotCallException("parse") - override def resolveCoreference(doc: Document): Unit = { - throw new RuntimeException("ERROR: functionality not supported in this procecessor!") - } + override def chunking(doc: Document): Unit = throwCannotCallException("chunking") - override def discourse(doc: Document): Unit = { - throw new RuntimeException("ERROR: functionality not supported in this procecessor!") - } + def throwNotSupportedException(methodName: String): Unit = + throw new RuntimeException(s"ERROR: $methodName functionality not supported in this procecessor!") - override def relationExtraction(doc: Document): Unit = { - throw new RuntimeException("ERROR: functionality not supported in this procecessor!") - } + override def srl(doc: Document): Unit = throwNotSupportedException("srl") - override def annotate(doc: Document): Document = { - val verbose = false + override def resolveCoreference(doc: Document): Unit = throwNotSupportedException("resolveCoreference") + + override def discourse(doc: Document): Unit = throwNotSupportedException("discourse") - // lemmas are created deterministically, not through the MTL framework - lemmatize(doc) + override def relationExtraction(doc: Document): Unit = throwNotSupportedException("relationExtraction") + + override def annotate(doc: Document): Document = { + // Process one sentence at a time through the MTL framework. + val partlyAnnotatedSentences = doc.sentences.map { sentence => + val words = sentence.words + // Lemmas are created deterministically, not through the MTL framework. + val lemmas = lemmatize(words) - // process one sentence at a time through the MTL framework - for (sent <- doc.sentences) { try { - val allLabelsAndScores = tokenClassifier.predictWithScores(sent.words) - assignPosTags(allLabelsAndScores(TASK_TO_INDEX(POS_TASK)), sent) - assignNamedEntityLabels(allLabelsAndScores(TASK_TO_INDEX(NER_TASK)), sent) - assignChunkLabels(allLabelsAndScores(TASK_TO_INDEX(CHUNKING_TASK)), sent) - assignDependencyLabelsUsingHexaTags( + val allLabelsAndScores = tokenClassifier.predictWithScores(words) + val tags = mkPosTags(words, allLabelsAndScores(TASK_TO_INDEX(POS_TASK))) + val entities = { + val optionalEntities = mkNerLabelsOpt(words, sentence.startOffsets, sentence.endOffsets, tags, lemmas) + + mkNamedEntityLabels(words, allLabelsAndScores(TASK_TO_INDEX(NER_TASK)), optionalEntities) + } + val chunks = mkChunkLabels(words, allLabelsAndScores(TASK_TO_INDEX(CHUNKING_TASK))) + val graphs = mkDependencyLabelsUsingHexaTags( + words, lemmas, tags, allLabelsAndScores(TASK_TO_INDEX(HEXA_TERM_TASK)), - allLabelsAndScores(TASK_TO_INDEX(HEXA_NONTERM_TASK)), - sent + allLabelsAndScores(TASK_TO_INDEX(HEXA_NONTERM_TASK)) + ) + // Entities and norms need to still be patched and filled in, so this is only a partly annotated sentence. + val partlyAnnotatedSentence = sentence.copy( + tags = Some(tags), lemmas = Some(lemmas), entities = Some(entities), chunks = Some(chunks), graphs = graphs ) - } catch { - case e: EncoderMaxTokensRuntimeException => - // this sentence exceeds the maximum number of tokens for the encoder - // TODO: at some point do something smart here - println(s"ERROR: this sentence exceeds the maximum number of tokens for the encoder and will not be annotated: ${sent.words.mkString(" ")}") + partlyAnnotatedSentence + } + // TODO: Improve error handling. + catch { + // No values, not even lemmas, will be included in the annotation is there was an exception. + case e: EncoderMaxTokensRuntimeException => + // TODO: at some point do something smart here + println(s"ERROR: This sentence exceeds the maximum number of tokens for the encoder and will not be annotated: ${sentence.words.mkString(" ")}") + sentence + case e: AssertionError => + println(s"ERROR: The output of predictWithScores does not satisfy assertions. The sentence will not be annotated: ${sentence.words.mkString(" ")}") + sentence } } + val partlyAnnotatedDocument = doc.copy(sentences = partlyAnnotatedSentences) + val fullyAnnotatedDocument = numericEntityRecognizerOpt.map { numericEntityRecognizer => + val numericMentions = numericEntityRecognizer.extractFrom(partlyAnnotatedDocument) + val (newLabels, newNorms) = NumericUtils.mkLabelsAndNorms(partlyAnnotatedDocument, numericMentions) + val fullyAnnotatedSentences = partlyAnnotatedDocument.sentences.indices.map { index => + partlyAnnotatedDocument.sentences(index).copy( + entities = Some(newLabels(index)), + norms = Some(newNorms(index)) + ) + } - // numeric entities using our numeric entity recognizer based on Odin rules - if(numericEntityRecognizerOpt.nonEmpty) { - val numericMentions = extractNumericEntityMentions(doc) - setLabelsAndNorms(doc, numericMentions) - } + partlyAnnotatedDocument.copy(sentences = fullyAnnotatedSentences) + }.getOrElse(partlyAnnotatedDocument) - doc + fullyAnnotatedDocument } - def extractNumericEntityMentions(doc:Document): Seq[Mention] = { - numericEntityRecognizerOpt.get.extractFrom(doc) - } + private def mkPosTags(words: Seq[String], labels: Array[Array[(String, Float)]]): Seq[String] = { + assert(labels.length == words.length) - private def assignPosTags(labels: Array[Array[(String, Float)]], sent: Sentence): Unit = { - assert(labels.length == sent.words.length) - sent.tags = Some(postprocessPartOfSpeechTags(sent.words, labels.map(_.head._1).toArray)) - } + val rawTags = WrappedArraySeq(labels.map(_.head._1)).toImmutableSeq + val cookedTags = PostProcessor.postprocessPartOfSpeechTags(words, rawTags) - /** Must be called after assignPosTags and lemmatize because it requires Sentence.tags and Sentence.lemmas */ - private def assignNamedEntityLabels(labels: Array[Array[(String, Float)]], sent: Sentence): Unit = { - assert(labels.length == sent.words.length) + cookedTags + } - // NER labels from the custom NER - val optionalNERLabels: Option[Array[String]] = optionalNER.map { ner => + private def mkNerLabelsOpt( + words: Seq[String], startOffsets: Seq[Int], endOffsets: Seq[Int], + tags: Seq[String], lemmas: Seq[String] + ): Option[Seq[String]] = { + lexiconNerOpt.map { lexiconNer => val sentence = Sentence( - sent.words, - sent.startOffsets, - sent.endOffsets, - sent.words, - sent.tags, - sent.lemmas, - entities = None, - norms = None, - chunks = None, - tree = None, - deps = EMPTY_GRAPH, - relations = None + words, // TODO: Why isn't this raw? + startOffsets, + endOffsets, + words, + Some(tags), + Some(lemmas) ) - ner.find(sentence) + lexiconNer.find(sentence) } + } - val genericLabels = NamedEntity.patch(labels.map(_.head._1).toArray) + /** Must be called after assignPosTags and lemmatize because it requires Sentence.tags and Sentence.lemmas */ + private def mkNamedEntityLabels(words: Seq[String], labels: Array[Array[(String, Float)]], nerLabelsOpt: Option[Seq[String]]): Seq[String] = { + assert(labels.length == words.length) - if(optionalNERLabels.isEmpty) { - sent.entities = Some(genericLabels) - } else { + val labelsSeq = WrappedArraySeq(labels.map(_.head._1)).toImmutableSeq + val genericLabels = NamedEntity.patch(labelsSeq) + val specificLabels = nerLabelsOpt.map { nerLabels => //println(s"MERGING NE labels for sentence: ${sent.words.mkString(" ")}") //println(s"Generic labels: ${NamedEntity.patch(labels).mkString(", ")}") //println(s"Optional labels: ${optionalNERLabels.get.mkString(", ")}") - val mergedLabels = NamedEntity.patch(mergeNerLabels(genericLabels, optionalNERLabels.get)) + val mergedLabels = mergeNerLabels(genericLabels, nerLabels) + val patchedLabels = NamedEntity.patch(mergedLabels) //println(s"Merged labels: ${mergedLabels.mkString(", ")}") - sent.entities = Some(mergedLabels) - } + + patchedLabels + }.getOrElse(genericLabels) + + specificLabels } - private def mergeNerLabels(generic: Array[String], custom: Array[String]): Array[String] = { + private def mergeNerLabels(generic: Seq[String], custom: Seq[String]): Seq[String] = { require(generic.length == custom.length) val customNamedEntities = NamedEntity.collect(custom) - val result = generic.toArray // A copy of the generic labels is created here. if (customNamedEntities.isEmpty) - result + generic else { - val genericNamedEntities = NamedEntity.collect(generic) - //println(s"Generic NamedEntity: ${genericNamedEntities.mkString(", ")}") //println(s"Custom NamedEntity: ${customNamedEntities.mkString(", ")}") + val genericNamedEntities = NamedEntity.collect(generic) + val combinedNamedEntities = NamedEntity.combine(generic, genericNamedEntities, customNamedEntities) - // The custom labels override the generic ones! - NamedEntity.combine(result, genericNamedEntities, customNamedEntities) + combinedNamedEntities } } - private def assignChunkLabels(labels: Array[Array[(String, Float)]], sent: Sentence): Unit = { - assert(labels.length == sent.words.length) - sent.chunks = Some(labels.map(_.head._1).toArray) + private def mkChunkLabels(words: Seq[String], labels: Array[Array[(String, Float)]]): Seq[String] = { + assert(labels.length == words.length) + + WrappedArraySeq(labels.map(_.head._1)).toImmutableSeq } + // TODO: This appears to be unused. // The head has one score, the label has another. Here the two scores are interpolated // and the head and label are stored together in a single object with the score if the // object, the Dependency, has a valid absolute head. private def interpolateHeadsAndLabels( - sentHeadPredictionScores: Array[Array[PredictionScore]], - sentLabelPredictionScores: Array[Array[PredictionScore]], - lambda: Float): Array[Array[Dependency]] = { + sentHeadPredictionScores: Array[Array[PredictionScore]], + sentLabelPredictionScores: Array[Array[PredictionScore]], + lambda: Float + ): Array[Array[Dependency]] = { assert(sentHeadPredictionScores.length == sentLabelPredictionScores.length) val sentDependencies = sentHeadPredictionScores.zip(sentLabelPredictionScores).zipWithIndex.map { case ((wordHeadPredictionScores, wordLabelPredictionScores), wordIndex) => @@ -286,86 +302,77 @@ class BalaurProcessor protected ( sentDependencies.toArray } - private def assignDependencyLabelsUsingHexaTags( + private def mkDependencyLabelsUsingHexaTags( + words: Seq[String], lemmas: Seq[String], tags: Seq[String], termTags: Array[Array[PredictionScore]], - nonTermTags: Array[Array[PredictionScore]], - sent: Sentence): Unit = { + nonTermTags: Array[Array[PredictionScore]] + ): GraphMap.Type = { val verbose = false - + val size = words.length // bht is used just for debugging purposes here val (bht, deps, roots) = hexaDecoder.decode(termTags, nonTermTags, topK = 25, verbose) - if(verbose && bht.nonEmpty) { + + if (verbose && bht.nonEmpty) { println(bht) println(s"Dependencies (${deps.get.size}):") println(deps.mkString("\n")) println("Roots: " + roots.get.mkString(", ")) } - - if(deps.nonEmpty && roots.nonEmpty) { + if (deps.nonEmpty && roots.nonEmpty) { // basic dependencies that replicate treebank annotations - val depGraph = new DirectedGraph[String](deps.get, Some(sent.size), roots) - sent.graphs += GraphMap.UNIVERSAL_BASIC -> depGraph - + val depGraph = new DirectedGraph[String](deps.get, Some(size), roots) // enhanced dependencies as defined by Manning - val enhancedDepGraph = ToEnhancedDependencies.generateUniversalEnhancedDependencies(sent, depGraph) - sent.graphs += GraphMap.UNIVERSAL_ENHANCED -> enhancedDepGraph - - // ideally, hybrid dependencies should contain both syntactic dependencies and semantic roles - // however, this processor produces only syntactic dependencies - sent.graphs += GraphMap.HYBRID_DEPENDENCIES -> enhancedDepGraph + val enhancedDepGraph = ToEnhancedDependencies.generateUniversalEnhancedDependencies(words, lemmas, tags, depGraph) + + Map( + GraphMap.UNIVERSAL_BASIC -> depGraph, + GraphMap.UNIVERSAL_ENHANCED -> enhancedDepGraph, + // ideally, hybrid dependencies should contain both syntactic dependencies and semantic roles + // however, this processor produces only syntactic dependencies + GraphMap.HYBRID_DEPENDENCIES -> enhancedDepGraph + ) } - } + else + GraphMap.empty + } } object BalaurProcessor { - val logger:Logger = LoggerFactory.getLogger(classOf[BalaurProcessor]) - val prefix:String = "BalaurProcessor" - - val OUTSIDE = "O" - val EMPTY_GRAPH = GraphMap() + val logger: Logger = LoggerFactory.getLogger(classOf[BalaurProcessor]) + val prefix: String = "BalaurProcessor" val NER_TASK = "NER" val POS_TASK = "POS" val CHUNKING_TASK = "Chunking" - val DEPS_HEAD_TASK = "Deps Head" - val DEPS_LABEL_TASK = "Deps Label" val HEXA_TERM_TASK = "Hexa Term" val HEXA_NONTERM_TASK = "Hexa NonTerm" - val PARSING_INTERPOLATION_LAMBDA = 0.6f - val PARSING_TOPK = 5 - // maps a task name to a head index in the encoder - val TASK_TO_INDEX = Map( - NER_TASK -> 0, - POS_TASK -> 1, - CHUNKING_TASK -> 2, - HEXA_TERM_TASK -> 3, - HEXA_NONTERM_TASK -> 4 - ) - - def mkTokenizer(lang: String): Tokenizer = { - lang match { - case "PT" => new OpenDomainPortugueseTokenizer - case "ES" => new OpenDomainSpanishTokenizer - case _ => new OpenDomainEnglishTokenizer - } + val TASK_TO_INDEX: Map[String, Int] = Seq( + NER_TASK, + POS_TASK, + CHUNKING_TASK, + HEXA_TERM_TASK, + HEXA_NONTERM_TASK + ).zipWithIndex.toMap + + def mkTokenizer(lang: String): Tokenizer = lang match { + case "PT" => new OpenDomainPortugueseTokenizer + case "ES" => new OpenDomainSpanishTokenizer + case "EN" | _ => new OpenDomainEnglishTokenizer } - def mkLemmatizer(lang: String): Lemmatizer = { - lang match { - case "PT" => new PortugueseLemmatizer - case "ES" => new SpanishLemmatizer - case _ => new EnglishLemmatizer - } + def mkLemmatizer(lang: String): Lemmatizer = lang match { + case "PT" => new PortugueseLemmatizer + case "ES" => new SpanishLemmatizer + case "EN" | _ => new EnglishLemmatizer } - def getArgString (config: Config, argPath: String, defaultValue: Option[String]): String = - if (config.hasPath(argPath)) config.getString(argPath) - else if(defaultValue.nonEmpty) defaultValue.get - else throw new RuntimeException(s"ERROR: parameter $argPath must be defined!") + def getConfigArgString (config: Config, argPath: String, defaultValue: Option[String]): String = + if (config.hasPath(argPath)) config.getString(argPath) + else if (defaultValue.nonEmpty) defaultValue.get + else throw new RuntimeException(s"ERROR: parameter $argPath must be defined!") - def newNumericEntityRecognizerOpt(seasonPathOpt: Option[String]): Option[NumericEntityRecognizer] = { - seasonPathOpt.map(NumericEntityRecognizer(_)) - } + def newNumericEntityRecognizerOpt(seasonPathOpt: Option[String]): Option[NumericEntityRecognizer] = + seasonPathOpt.map(NumericEntityRecognizer(_)) } diff --git a/library/src/main/scala/org/clulab/processors/clu/DocumentMaker.scala b/library/src/main/scala/org/clulab/processors/clu/DocumentMaker.scala index 92168b4bd..0a303701e 100644 --- a/library/src/main/scala/org/clulab/processors/clu/DocumentMaker.scala +++ b/library/src/main/scala/org/clulab/processors/clu/DocumentMaker.scala @@ -1,90 +1,100 @@ package org.clulab.processors.clu -import org.slf4j.LoggerFactory -import org.slf4j.Logger -import org.clulab.processors.clu.tokenizer.Tokenizer import org.clulab.processors.Document -import scala.collection.mutable.ArrayBuffer import org.clulab.processors.Sentence +import org.clulab.processors.clu.tokenizer.Tokenizer +import org.clulab.utils.WrappedArraySeq +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import scala.collection.compat._ +import scala.collection.mutable.ArrayBuffer class DocumentMaker object DocumentMaker { - val logger:Logger = LoggerFactory.getLogger(classOf[DocumentMaker]) + val logger: Logger = LoggerFactory.getLogger(classOf[DocumentMaker]) /** Constructs a document of tokens from free text; includes sentence splitting and tokenization */ - def mkDocument(tokenizer:Tokenizer, - text:String, - keepText:Boolean): Document = { - val sents = tokenizer.tokenize(text) - val doc = new Document(sents) - if(keepText) doc.text = Some(text) - doc + def mkDocument( // TODO: mkDocumentFromText + tokenizer: Tokenizer, + text: String, + keepText: Boolean + ): Document = { + val sentences = tokenizer.tokenize(text) + val textOpt = Option.when(keepText)(text) + val document = Document(sentences, textOpt) + + document } /** Constructs a document of tokens from an array of untokenized sentences */ - def mkDocumentFromSentences(tokenizer:Tokenizer, - sentences:Iterable[String], - keepText:Boolean, - charactersBetweenSentences:Int): Document = { - val sents = new ArrayBuffer[Sentence]() + def mkDocumentFromSentences( // TODO: mkDocumentFromTexts + tokenizer: Tokenizer, + texts: Iterable[String], + keepText: Boolean, + charactersBetweenSentences: Int + ): Document = { + val sentenceSep = " " * charactersBetweenSentences var characterOffset = 0 - for(text <- sentences) { - val sent = tokenizer.tokenize(text, sentenceSplit = false).head // we produce a single sentence here! - - // update character offsets between sentences - for(i <- 0 until sent.size) { - sent.startOffsets(i) += characterOffset - sent.endOffsets(i) += characterOffset - } + val sentencesArray = texts.map { text => + val sentence = tokenizer.tokenize(text, sentenceSplit = false, characterOffset).head // We produce a single sentence here! - // move the character offset after the current sentence - characterOffset = sent.endOffsets.last + charactersBetweenSentences + characterOffset = sentence.endOffsets.last + charactersBetweenSentences + sentence + }.toArray + val sentences = WrappedArraySeq(sentencesArray).toImmutableSeq + val textOpt = Option.when(keepText)(texts.mkString(sentenceSep)) + val document = Document(sentences, textOpt) - //println("SENTENCE: " + sent.words.mkString(", ")) - //println("Start offsets: " + sent.startOffsets.mkString(", ")) - //println("End offsets: " + sent.endOffsets.mkString(", ")) - sents += sent - } - val doc = new Document(sents.toArray) - if(keepText) doc.text = Some(sentences.mkString(mkSep(charactersBetweenSentences))) - doc + document } /** Constructs a document of tokens from an array of tokenized sentences */ - def mkDocumentFromTokens(sentences:Iterable[Iterable[String]], - keepText:Boolean, - charactersBetweenSentences:Int, - charactersBetweenTokens:Int): Document = { + def mkDocumentFromTokens( // TODO: mkDocumentFromTokenizedTexts + tokenizedTexts: Iterable[Iterable[String]], + keepText: Boolean, + charactersBetweenSentences: Int, + charactersBetweenTokens: Int + ): Document = { + val sentenceSep = " " * charactersBetweenSentences + val tokenSep = " " * charactersBetweenTokens var charOffset = 0 - var sents = new ArrayBuffer[Sentence]() val text = new StringBuilder - for(sentence <- sentences) { - val startOffsets = new ArrayBuffer[Int]() - val endOffsets = new ArrayBuffer[Int]() - for(word <- sentence) { - startOffsets += charOffset - charOffset += word.length - endOffsets += charOffset + // Just use one buffer for each but clear them as necessary. + val startOffsetsBuffer = new ArrayBuffer[Int]() + val endOffsetsBuffer = new ArrayBuffer[Int]() + val sentencesArray = tokenizedTexts.map { tokenizedTextIterable => + // We are going to need to tokens in an array anyway, so make them now. + val tokenizedTextArray = tokenizedTextIterable.toArray + + tokenizedTextArray.foreach { token => + startOffsetsBuffer += charOffset + charOffset += token.length + endOffsetsBuffer += charOffset charOffset += charactersBetweenTokens } - // note: NO postprocessing happens in this case, so use it carefully! - sents += new Sentence(sentence.toArray, startOffsets.toArray, endOffsets.toArray, sentence.toArray) - charOffset += charactersBetweenSentences - charactersBetweenTokens - if(keepText) { - text.append(sentence.mkString(mkSep(charactersBetweenTokens))) - text.append(mkSep(charactersBetweenSentences)) - } - } + // The simple version of this doesn't work if there were no tokens. + charOffset += charactersBetweenSentences - (if (tokenizedTextArray.nonEmpty) charactersBetweenTokens else 0) - val doc = new Document(sents.toArray) - if(keepText) doc.text = Some(text.toString) - doc - } + // Note: NO postprocessing happens in this case, so use it carefully! + val startOffsets = WrappedArraySeq(startOffsetsBuffer.toArray).toImmutableSeq + startOffsetsBuffer.clear() + val endOffsets = WrappedArraySeq(endOffsetsBuffer.toArray).toImmutableSeq + endOffsetsBuffer.clear() + val tokens = WrappedArraySeq(tokenizedTextArray).toImmutableSeq + val sentence = new Sentence(tokens, startOffsets, endOffsets, tokens) + + if (keepText) { + text.append(tokens.mkString(tokenSep)) + text.append(sentenceSep) + } + sentence + }.toArray + val sentences = WrappedArraySeq(sentencesArray).toImmutableSeq + val textOpt = Option.when(keepText)(text.toString) + val document = Document(sentences, textOpt) - private def mkSep(size:Int):String = { - val os = new StringBuilder - for (_ <- 0 until size) os.append(" ") - os.toString() + document } } diff --git a/library/src/main/scala/org/clulab/processors/clu/DocumentPrinter.scala b/library/src/main/scala/org/clulab/processors/clu/DocumentPrinter.scala new file mode 100644 index 000000000..22c9845c7 --- /dev/null +++ b/library/src/main/scala/org/clulab/processors/clu/DocumentPrinter.scala @@ -0,0 +1,91 @@ +package org.clulab.processors.clu + +import org.clulab.processors.Document +import org.clulab.struct.DirectedGraphEdgeIterator + +import java.io.PrintWriter + +trait DocumentPrinter { + def print(document: Document): Unit +} + +class DocumentPrettyPrinter(printWriter: PrintWriter) extends DocumentPrinter { + + def println(string: String): Unit = printWriter.println(string) + + def print(document: Document): Unit = { + // let's print the sentence-level annotations + document.sentences.zipWithIndex.foreach { case (sentence, sentenceCount) => + println("Sentence #" + sentenceCount + ":") + println("Tokens: " + sentence.words.zipWithIndex.mkString(" ")) + println("Start character offsets: " + sentence.startOffsets.mkString(" ")) + println("End character offsets: " + sentence.endOffsets.mkString(" ")) + + // these annotations are optional, so they are stored using Option objects, hence the foreach statement + sentence.lemmas.foreach(lemmas => println(s"Lemmas: ${lemmas.mkString(" ")}")) + sentence.tags.foreach(tags => println(s"POS tags: ${tags.mkString(" ")}")) + sentence.chunks.foreach(chunks => println(s"Chunks: ${chunks.mkString(" ")}")) + sentence.entities.foreach(entities => println(s"Named entities: ${entities.mkString(" ")}")) + sentence.norms.foreach(norms => println(s"Normalized entities: ${norms.mkString(" ")}")) + sentence.universalBasicDependencies.foreach(dependencies => { + println("Basic syntactic dependencies:") + val iterator = new DirectedGraphEdgeIterator[String](dependencies) + while (iterator.hasNext) { + val dep = iterator.next() + // note that we use offsets starting at 0 (unlike CoreNLP, which uses offsets starting at 1) + println(" head:" + dep._1 + " modifier:" + dep._2 + " label:" + dep._3) + } + }) + sentence.universalEnhancedDependencies.foreach(dependencies => { + println("Enhanced syntactic dependencies:") + val iterator = new DirectedGraphEdgeIterator[String](dependencies) + while (iterator.hasNext) { + val dep = iterator.next() + // note that we use offsets starting at 0 (unlike CoreNLP, which uses offsets starting at 1) + println(" head:" + dep._1 + " modifier:" + dep._2 + " label:" + dep._3) + } + }) + sentence.semanticRoles.foreach(dependencies => { + println("Semantic dependencies:") + val iterator = new DirectedGraphEdgeIterator[String](dependencies) + while (iterator.hasNext) { + val dep = iterator.next() + // note that we use offsets starting at 0 (unlike CoreNLP, which uses offsets starting at 1) + println(" head:" + dep._1 + " modifier:" + dep._2 + " label:" + dep._3) + } + }) + sentence.enhancedSemanticRoles.foreach(dependencies => { + println("Enhanced semantic dependencies:") + val iterator = new DirectedGraphEdgeIterator[String](dependencies) + while (iterator.hasNext) { + val dep = iterator.next() + // note that we use offsets starting at 0 (unlike CoreNLP, which uses offsets starting at 1) + println(" head:" + dep._1 + " modifier:" + dep._2 + " label:" + dep._3) + } + }) + sentence.syntacticTree.foreach(tree => { + println("Constituent tree: " + tree.toStringDepth(showHead = false)) + // see the org.clulab.struct.Tree class for more information + // on syntactic trees, including access to head phrases/words + }) + + println("\n") + } + + // let's print the coreference chains + document.coreferenceChains.foreach(chains => { + for (chain <- chains.getChains) { + println("Found one coreference chain containing the following mentions:") + for (mention <- chain) { + // note that all these offsets start at 0 too + println("\tsentenceIndex:" + mention.sentenceIndex + + " headIndex:" + mention.headIndex + + " startTokenOffset:" + mention.startOffset + + " endTokenOffset:" + mention.endOffset + + " text: " + document.sentences(mention.sentenceIndex).words.slice(mention.startOffset, mention.endOffset).mkString("[", " ", "]")) + } + } + }) + printWriter.flush() + } +} diff --git a/library/src/main/scala/org/clulab/processors/clu/PostProcessor.scala b/library/src/main/scala/org/clulab/processors/clu/PostProcessor.scala index 8de6a5be2..2226e4642 100644 --- a/library/src/main/scala/org/clulab/processors/clu/PostProcessor.scala +++ b/library/src/main/scala/org/clulab/processors/clu/PostProcessor.scala @@ -1,9 +1,7 @@ package org.clulab.processors.clu -import org.clulab.processors.Sentence - import java.util.regex.Pattern -import org.clulab.struct.Edge +import scala.collection.mutable object PostProcessor { // @@ -14,35 +12,32 @@ object PostProcessor { // Matches agricultural season short hands such as "2021DS" or "2021WS" val WET_OR_DRY_SEASON = Pattern.compile("""(?i)[0-9]+(ds|ws)""") - /** POS tag corrections, in place */ - def postprocessPartOfSpeechTags(words: Array[String], tags: Array[String]): Array[String] = { - - // unigram patterns - words.indices.foreach { index => - if (tags(index) != "CC" && VERSUS_PATTERN.matcher(words(index)).matches) { - tags(index) = "CC" // "versus" seems like a CC to me. but maybe not... + /** POS tag corrections */ + def postprocessPartOfSpeechTags(words: Seq[String], tags: Seq[String]): Seq[String] = { + val newTags = words.indices.map { index => + val word = words(index) + val oldTag = tags(index) + val newTag = { + // unigram patterns + if (VERSUS_PATTERN.matcher(word).matches) + "CC" // "versus" seems like a CC to me. but maybe not... + else if (WET_OR_DRY_SEASON.matcher(word).matches) + "CD" // such years should be CDs because our grammars expect it + // bigram patterns + else if (word.equalsIgnoreCase("due")) { + if (words.lift(index + 1).map(_.toLowerCase).contains("to")) "IN" // "due" in "due to" must be a preposition + else oldTag + } + else if (word.equalsIgnoreCase("fall")) { + if (tags.lift(index + 1).contains("CD")) "NN" // "fall" followed by a CD must be NN + else oldTag + } + else oldTag } - if(WET_OR_DRY_SEASON.matcher(words(index)).matches) { - tags(index) = "CD" // such years should be CDs because our grammars expect it - } + newTag } - // bigram patterns - words.indices.dropRight(1).foreach { curr => - val next = curr + 1 - // "due" in "due to" must be a preposition - if (words(curr).equalsIgnoreCase("due") && words(next).equalsIgnoreCase("to")) { - tags(curr) = "IN" - } - - // "fall" followed by a CD must be NN - else if(words(curr).equalsIgnoreCase("fall") && tags(next).equals("CD")) { - tags(curr) = "NN" - } - } - - tags + newTags } - } diff --git a/library/src/main/scala/org/clulab/processors/clu/Veil.scala b/library/src/main/scala/org/clulab/processors/clu/Veil.scala index 6e4494ca4..31d25ed9c 100644 --- a/library/src/main/scala/org/clulab/processors/clu/Veil.scala +++ b/library/src/main/scala/org/clulab/processors/clu/Veil.scala @@ -2,7 +2,7 @@ package org.clulab.processors.clu import org.clulab.processors.{Document, Processor, Sentence} import org.clulab.struct.{DirectedGraph, Edge, GraphMap, RelationTriple, Tree} -import org.clulab.struct.GraphMap._ +import org.clulab.utils.WrappedArraySeq import scala.collection.mutable.{Set => MutableSet} @@ -48,7 +48,7 @@ class VeiledText(originalText: String, veiledLetters: Seq[Range]) extends Veil { } protected def unveilDocument(veiledDocument: Document): Document = { - val unveiledDocument = veiledDocument.copy(textOpt = Some(originalText)) + val unveiledDocument = veiledDocument.copy(text = Some(originalText)) unveiledDocument } @@ -109,7 +109,7 @@ class VeiledDocument(originalDocument: Document, veiledWords: Seq[(Int, Range)]) } protected lazy val veiledDocument = { val veiledSentences = originalDocument.sentences.zipWithIndex.map { case (originalSentence, sentenceIndex) => - val wordIndexes = originalSentence.words.indices.filterNot(veilSets(sentenceIndex)).toArray + val wordIndexes = originalSentence.words.indices.filterNot(veilSets(sentenceIndex)) val veiledRaw = wordIndexes.map(originalSentence.raw) val veiledStartOffsets = wordIndexes.map(originalSentence.startOffsets) val veiledEndOffsets = wordIndexes.map(originalSentence.endOffsets) @@ -122,7 +122,7 @@ class VeiledDocument(originalDocument: Document, veiledWords: Seq[(Int, Range)]) originalDocument.copy(veiledSentences) } - def unveilStringArray(veiledArrayOpt: Option[Array[String]], sentenceIndex: Int, veil: String): Option[Array[String]] = { + def unveilStringArray(veiledArrayOpt: Option[Seq[String]], sentenceIndex: Int, veil: String): Option[Seq[String]] = { val unveilArray = unveilArrays(sentenceIndex) val originalLength = originalDocument.sentences(sentenceIndex).words.length @@ -132,22 +132,20 @@ class VeiledDocument(originalDocument: Document, veiledWords: Seq[(Int, Range)]) veiledArray.zipWithIndex.foreach { case (veiledString, veiledIndex) => unveiledArray(unveilArray(veiledIndex)) = veiledString } - unveiledArray + WrappedArraySeq(unveiledArray).toImmutableSeq } } - def unveilGraphs(veiledGraphs: GraphMap, sentenceIndex: Int): GraphMap = { + def unveilGraphs(veiledGraphs: GraphMap.Type, sentenceIndex: Int): GraphMap.Type = { val unveilArray = unveilArrays(sentenceIndex) - val unveiledGraphs = GraphMap() val originalLength = originalDocument.sentences(sentenceIndex).words.length - - veiledGraphs.foreach { case (name, veiledDirectedGraph) => + val unveiledGraphs = veiledGraphs.map { case (name, veiledDirectedGraph) => val unveiledEdges = veiledDirectedGraph.allEdges.map { case (veiledSource, veiledDestination, relation) => Edge(unveilArray(veiledSource), unveilArray(veiledDestination), relation) } val unveiledRoots = veiledDirectedGraph.roots.map(unveilArray) - unveiledGraphs(name) = new DirectedGraph(unveiledEdges, Some(originalLength), Some(unveiledRoots)) + name -> new DirectedGraph(unveiledEdges, Some(originalLength), Some(unveiledRoots)) } unveiledGraphs } @@ -156,7 +154,7 @@ class VeiledDocument(originalDocument: Document, veiledWords: Seq[(Int, Range)]) def unveilSyntacticTree(syntacticTreeOpt: Option[Tree]): Option[Tree] = syntacticTreeOpt // TODO - def unveilRelations(relations: Option[Array[RelationTriple]]): Option[Array[RelationTriple]] = relations + def unveilRelations(relations: Option[Seq[RelationTriple]]): Option[Seq[RelationTriple]] = relations protected def unveilSentence(veiledSentence: Sentence, sentenceIndex: Int): Sentence = { val originalSentence = originalDocument.sentences(sentenceIndex) @@ -164,21 +162,27 @@ class VeiledDocument(originalDocument: Document, veiledWords: Seq[(Int, Range)]) val unveiledStartOffsets = originalSentence.startOffsets val unveiledEndOffsets = originalSentence.endOffsets val unveiledWords = originalSentence.words + val unveiledSentence = veiledSentence.copy(unveiledRaw, unveiledStartOffsets, unveiledEndOffsets, unveiledWords) - def unveilStringArray(veiledArrayOpt: Option[Array[String]], veil: String): Option[Array[String]] = + def unveilStringArray(veiledArrayOpt: Option[Seq[String]], veil: String): Option[Seq[String]] = this.unveilStringArray(veiledArrayOpt, sentenceIndex, veil) - unveiledSentence.tags = unveilStringArray(unveiledSentence.tags, Veil.veiledTag) - unveiledSentence.lemmas = unveilStringArray(unveiledSentence.lemmas, Veil.veiledLemma) - unveiledSentence.entities = unveilStringArray(unveiledSentence.entities, Veil.veiledEntity) - unveiledSentence.norms = unveilStringArray(unveiledSentence.norms, Veil.veiledNorm) - unveiledSentence.chunks = unveilStringArray(unveiledSentence.chunks, Veil.veiledChunk) - - unveiledSentence.syntacticTree = unveilSyntacticTree(unveiledSentence.syntacticTree) - unveiledSentence.graphs = unveilGraphs(unveiledSentence.graphs, sentenceIndex) - unveiledSentence.relations = unveilRelations(unveiledSentence.relations) - unveiledSentence + val tags = unveilStringArray(unveiledSentence.tags, Veil.veiledTag) + val lemmas = unveilStringArray(unveiledSentence.lemmas, Veil.veiledLemma) + val entities = unveilStringArray(unveiledSentence.entities, Veil.veiledEntity) + val norms = unveilStringArray(unveiledSentence.norms, Veil.veiledNorm) + val chunks = unveilStringArray(unveiledSentence.chunks, Veil.veiledChunk) + + val syntacticTree = unveilSyntacticTree(unveiledSentence.syntacticTree) + val graphs = unveilGraphs(unveiledSentence.graphs, sentenceIndex) + val relations = unveilRelations(unveiledSentence.relations) + + val newSentence = Sentence( + unveiledSentence.raw, unveiledSentence.startOffsets, unveiledSentence.endOffsets, unveiledSentence.words, + tags, lemmas, entities, norms, chunks, syntacticTree, graphs, relations + ) + newSentence } protected def unveilDocument(veiledDocument: Document): Document = { diff --git a/library/src/main/scala/org/clulab/processors/clu/tokenizer/SentenceSplitter.scala b/library/src/main/scala/org/clulab/processors/clu/tokenizer/SentenceSplitter.scala index f644da4f0..8a4790246 100644 --- a/library/src/main/scala/org/clulab/processors/clu/tokenizer/SentenceSplitter.scala +++ b/library/src/main/scala/org/clulab/processors/clu/tokenizer/SentenceSplitter.scala @@ -1,8 +1,10 @@ package org.clulab.processors.clu.tokenizer import org.clulab.processors.Sentence +import org.clulab.scala.WrappedArrayBuffer._ import java.io.{BufferedReader, InputStreamReader} +import scala.collection.compat._ import scala.collection.mutable.ArrayBuffer import scala.util.matching.Regex import scala.util.Using @@ -10,15 +12,17 @@ import scala.util.Using import SentenceSplitter._ trait SentenceSplitter { - def split(tokens:Array[RawToken], sentenceSplit:Boolean):Array[Sentence] + def split(tokens:Array[RawToken], sentenceSplit:Boolean, characterOffset: Int = 0):Seq[Sentence] } abstract class RuleBasedSentenceSplitter extends SentenceSplitter { /** * Sentence splitting over a stream of tokens - * This includes detection of abbreviations as well + * This includes detection of abbreviations as well. + * The characterOffset is included so that Sentences + * in a longer text need not be edited afterward. **/ - override def split(tokens:Array[RawToken], sentenceSplit:Boolean):Array[Sentence] = { + override def split(tokens: Array[RawToken], sentenceSplit: Boolean, characterOffset: Int): Seq[Sentence] = { val sentences = new ArrayBuffer[Sentence]() var raw = new ArrayBuffer[String]() var words = new ArrayBuffer[String]() @@ -26,49 +30,46 @@ abstract class RuleBasedSentenceSplitter extends SentenceSplitter { var endPositions = new ArrayBuffer[Int]() for (i <- tokens.indices) { - val crt = tokens(i) - + val curr: RawToken = tokens(i) // next and previous tokens. We need these to detect proper ends of sentences - var next: Option[RawToken] = None - if (i < tokens.length - 1) next = Some(tokens(i + 1)) - var prev: Option[RawToken] = None - if (i > 0) prev = Some(tokens(i - 1)) + val nextOpt: Option[RawToken] = Option.when(i < tokens.length - 1)(tokens(i + 1)) + val prevOpt: Option[RawToken] = Option.when(i > 0)(tokens(i - 1)) // // we handle end-of-sentence markers (periods, etc.) here // this includes detecting if a period belongs to the previous token (if it's an abbreviation) // and understanding if this token actually marks the end of a sentence // - if (EOS.findFirstIn(crt.word).isDefined) { + if (EOS.findFirstIn(curr.word).isDefined) { // found a token that normally indicates end of sentence var isEos = sentenceSplit // period that probably belongs to an abbreviation and should not be marked as EOS - if (crt.word == "." && prev.isDefined && isAbbreviation(prev.get.word) && crt.beginPosition == prev.get.endPosition) { + if (curr.word == "." && prevOpt.isDefined && isAbbreviation(prevOpt.get.word) && curr.beginPosition == prevOpt.get.endPosition) { // found a period that should be attached to the previous abbreviation - endPositions(endPositions.size - 1) = crt.endPosition - words(words.size - 1) = words.last + crt.word - raw(raw.size - 1) = raw.last + crt.raw + endPositions(endPositions.size - 1) = curr.endPosition + characterOffset + words(words.size - 1) = words.last + curr.word + raw(raw.size - 1) = raw.last + curr.raw // this is not an end of sentence if the next token does NOT look like the start of a sentence // TODO: maybe this should be handled with a binary classifier instead? - if (isEos && next.isDefined && !isSentStart(next.get.word)) { + if (isEos && nextOpt.isDefined && !isSentStart(nextOpt.get.word)) { isEos = false } } // regular end-of-sentence marker; treat is a distinct token else { - raw += crt.raw - words += crt.word - beginPositions += crt.beginPosition - endPositions += crt.endPosition + raw += curr.raw + words += curr.word + beginPositions += curr.beginPosition + characterOffset + endPositions += curr.endPosition + characterOffset } // found a valid end of sentence; start an empty one if (isEos) { - sentences += Sentence(raw.toArray, beginPositions.toArray, endPositions.toArray, words.toArray) - raw = new ArrayBuffer[String]() + sentences += Sentence(raw, beginPositions, endPositions, words) + raw = new ArrayBuffer[String]() // TODO: Check whether clear() is sufficient. words = new ArrayBuffer[String]() beginPositions = new ArrayBuffer[Int]() endPositions = new ArrayBuffer[Int]() @@ -76,27 +77,27 @@ abstract class RuleBasedSentenceSplitter extends SentenceSplitter { } // found a period *inside* a token; sometimes this is an EOS - else if(EOS_FOLLOWEDBY_BULLET.findFirstIn(crt.raw).isDefined && - crt.raw.lastIndexOf('.') > 0 && - next.isDefined && isSentStart(next.get.word)) { + else if(EOS_FOLLOWEDBY_BULLET.findFirstIn(curr.raw).isDefined && + curr.raw.lastIndexOf('.') > 0 && + nextOpt.isDefined && isSentStart(nextOpt.get.word)) { //println(s"FOUND EOS INSIDE TOKEN: ${crt.raw}") // // create the last token from the token fragment before the period, and the period itself // - val dotRawPosition = crt.raw.lastIndexOf('.') + val dotRawPosition = curr.raw.lastIndexOf('.') assert(dotRawPosition > 0) - val dotWordPosition = crt.word.lastIndexOf('.') + val dotWordPosition = curr.word.lastIndexOf('.') assert(dotWordPosition > 0) - raw += crt.raw.substring(0, dotRawPosition) - words += crt.word.substring(0, dotWordPosition) - beginPositions += crt.beginPosition - endPositions += crt.beginPosition + dotRawPosition + raw += curr.raw.substring(0, dotRawPosition) + words += curr.word.substring(0, dotWordPosition) + beginPositions += curr.beginPosition + characterOffset + endPositions += curr.beginPosition + dotRawPosition + characterOffset // This is just for the period with length of 1. - raw += crt.raw.substring(dotRawPosition, dotRawPosition + 1) - words += crt.word.substring(dotWordPosition, dotWordPosition + 1) + raw += curr.raw.substring(dotRawPosition, dotRawPosition + 1) + words += curr.word.substring(dotWordPosition, dotWordPosition + 1) beginPositions += endPositions.last endPositions += beginPositions.last + 1 val lastPosition = endPositions.last @@ -104,7 +105,7 @@ abstract class RuleBasedSentenceSplitter extends SentenceSplitter { // // create the current sentence // - sentences += Sentence(raw.toArray, beginPositions.toArray, endPositions.toArray, words.toArray) + sentences += Sentence(raw, beginPositions, endPositions, words) raw = new ArrayBuffer[String]() words = new ArrayBuffer[String]() beginPositions = new ArrayBuffer[Int]() @@ -113,27 +114,27 @@ abstract class RuleBasedSentenceSplitter extends SentenceSplitter { // // add the part of the token after the period to the new sentence // - raw += crt.raw.substring(dotRawPosition + 1) - words += crt.word.substring(dotWordPosition + 1) + raw += curr.raw.substring(dotRawPosition + 1) + words += curr.word.substring(dotWordPosition + 1) beginPositions += lastPosition endPositions += lastPosition + raw.head.length } else { // just a regular token - raw += crt.raw - words += crt.word - beginPositions += crt.beginPosition - endPositions += crt.endPosition + raw += curr.raw + words += curr.word + beginPositions += curr.beginPosition + characterOffset + endPositions += curr.endPosition + characterOffset } } // a few words left over at the end if (words.nonEmpty) { - sentences += Sentence(raw.toArray, beginPositions.toArray, endPositions.toArray, words.toArray) + sentences += Sentence(raw, beginPositions, endPositions, words) } - sentences.toArray + sentences } def isAbbreviation(word:String):Boolean diff --git a/library/src/main/scala/org/clulab/processors/clu/tokenizer/Tokenizer.scala b/library/src/main/scala/org/clulab/processors/clu/tokenizer/Tokenizer.scala index 85c6a09bc..11fbff7fb 100644 --- a/library/src/main/scala/org/clulab/processors/clu/tokenizer/Tokenizer.scala +++ b/library/src/main/scala/org/clulab/processors/clu/tokenizer/Tokenizer.scala @@ -70,7 +70,7 @@ class Tokenizer( } /** Tokenization and sentence splitting */ - def tokenize(text: String, sentenceSplit: Boolean = true): Array[Sentence] = { + def tokenize(text: String, sentenceSplit: Boolean = true, characterOffset: Int = 0): Seq[Sentence] = { // raw tokenization, using the antlr grammar val rawTokens = readTokens(text) // now apply all the additional non-Antlr steps such as solving contractions, normalization, post-processing @@ -78,7 +78,7 @@ class Tokenizer( step.process(rawTokens) } // sentence splitting, including detection of abbreviations - val sentences = sentenceSplitter.split(stepTokens, sentenceSplit) + val sentences = sentenceSplitter.split(stepTokens, sentenceSplit, characterOffset) sentences } diff --git a/library/src/main/scala/org/clulab/sequences/BiMEMMSequenceTagger.scala b/library/src/main/scala/org/clulab/sequences/BiMEMMSequenceTagger.scala index 3278df5f2..d9fb83262 100644 --- a/library/src/main/scala/org/clulab/sequences/BiMEMMSequenceTagger.scala +++ b/library/src/main/scala/org/clulab/sequences/BiMEMMSequenceTagger.scala @@ -168,7 +168,7 @@ abstract class BiMEMMSequenceTagger[L: ClassTag, F: ClassTag]( // original sentence val origSentence = sentences(sentOffset) // actual sentence to be used - val sentence = if (leftToRight) origSentence else origSentence.revert() + val sentence = if (leftToRight) origSentence else origSentence.reverse() // labels to be learned val labels = if (leftToRight) labelExtractor(origSentence) @@ -211,7 +211,7 @@ abstract class BiMEMMSequenceTagger[L: ClassTag, F: ClassTag]( origSentence: Sentence, firstPassLabels:Option[Array[L]], leftToRight:Boolean): Array[L] = { - val sentence = if(leftToRight) origSentence else origSentence.revert() + val sentence = if(leftToRight) origSentence else origSentence.reverse() val firstPass = if(firstPassLabels.nonEmpty) { @@ -233,7 +233,7 @@ abstract class BiMEMMSequenceTagger[L: ClassTag, F: ClassTag]( if(leftToRight) history.toArray else SeqUtils.revert(history).toArray } - override def classesOf(sentence: Sentence):Array[L] = { + override def classesOf(sentence: Sentence):Seq[L] = { var firstPassLabels:Option[Array[L]] = None if(firstPassModel.nonEmpty) firstPassLabels = Some(classesOf(firstPassModel.get, sentence, None, ! leftToRight)) diff --git a/library/src/main/scala/org/clulab/sequences/CombinedLexiconNER.scala b/library/src/main/scala/org/clulab/sequences/CombinedLexiconNER.scala index cbc12a745..9ab41afda 100644 --- a/library/src/main/scala/org/clulab/sequences/CombinedLexiconNER.scala +++ b/library/src/main/scala/org/clulab/sequences/CombinedLexiconNER.scala @@ -2,6 +2,7 @@ package org.clulab.sequences import org.clulab.processors.Sentence import org.clulab.sequences.LexiconNER._ +import org.clulab.scala.WrappedArray._ import org.clulab.struct.EntityValidator import org.clulab.struct.IntHashTrie @@ -64,7 +65,7 @@ class CombinedLexiconNER ( * @param sentence The input sentence * @return An array of BIO notations the store the outcome of the matches */ - def find(sentence: Sentence): Array[String] = { + def find(sentence: Sentence): Seq[String] = { val caseSensitiveTokens = getTokens(sentence) val caseInsensitiveTokens = if (hasCaseInsensitive) caseSensitiveTokens.map(_.toLowerCase) else caseSensitiveTokens val seq = findLongestMatch(sentence, caseSensitiveTokens, caseInsensitiveTokens) @@ -79,7 +80,7 @@ class CombinedLexiconNER ( * This means that the longest match is always chosen, even if coming from a matcher with lower priority * Only ties are disambiguated according to the order provided in the constructor */ - protected def findLongestMatch(sentence: Sentence, caseSensitiveTokens: Array[String], caseInsensitiveTokens: Array[String]): Array[String] = { + protected def findLongestMatch(sentence: Sentence, caseSensitiveTokens: Seq[String], caseInsensitiveTokens: Seq[String]): Seq[String] = { val labels = new Array[String](caseSensitiveTokens.length) val length = labels.length var offset = 0 @@ -91,7 +92,7 @@ class CombinedLexiconNER ( def getSpanAndIndex: CombinedLexiconNER.SpanAndIndex = { - def innerGetSpanAndIndex(condition: Boolean, intHashTrie: IntHashTrie, tokens: => Array[String]): CombinedLexiconNER.SpanAndIndex = { + def innerGetSpanAndIndex(condition: Boolean, intHashTrie: IntHashTrie, tokens: => Seq[String]): CombinedLexiconNER.SpanAndIndex = { if (condition) { val intTrieNodeMatch = intHashTrie.findAt(tokens, offset) CombinedLexiconNER.SpanAndIndex(intTrieNodeMatch.length, intTrieNodeMatch.completePath) diff --git a/library/src/main/scala/org/clulab/sequences/CompactLexiconNER.scala b/library/src/main/scala/org/clulab/sequences/CompactLexiconNER.scala index 924c8688f..2d16ddbf2 100644 --- a/library/src/main/scala/org/clulab/sequences/CompactLexiconNER.scala +++ b/library/src/main/scala/org/clulab/sequences/CompactLexiconNER.scala @@ -1,15 +1,15 @@ package org.clulab.sequences -import java.io.ObjectInputStream -import java.io.ObjectOutputStream -import java.util.Arrays - import org.clulab.processors.Sentence import org.clulab.sequences.LexiconNER.OUTSIDE_LABEL +import org.clulab.scala.WrappedArray._ import org.clulab.struct.EntityValidator import org.clulab.struct.IntHashTrie import org.clulab.struct.IntTrieNode +import java.io.ObjectInputStream +import java.io.ObjectOutputStream +import java.util.Arrays import scala.collection.mutable /** Lexicon-based NER similar to [[org.clulab.sequences.CombinedLexiconNER CombinedLexiconNER]] but which @@ -56,7 +56,7 @@ class CompactLexiconNER( def getLabels: Seq[String] = labels - def find(sentence: Sentence): Array[String] = { + def find(sentence: Sentence): Seq[String] = { val caseSensitiveTokens = getTokens(sentence) val caseInsensitiveTokens = if (hasCaseInsensitive) caseSensitiveTokens.map(_.toLowerCase) @@ -66,14 +66,14 @@ class CompactLexiconNER( seq } - protected def findLongestMatch(sentence: Sentence, caseSensitiveTokens: Array[String], - caseInsensitiveTokens: Array[String]): Array[String] = { + protected def findLongestMatch(sentence: Sentence, caseSensitiveTokens: Seq[String], + caseInsensitiveTokens: Seq[String]): Seq[String] = { val labels = new Array[String](caseSensitiveTokens.length) val length = labels.length var offset = 0 - val caseSensitiveStringIds = if (hasCaseSensitive) caseSensitiveTokens.map( caseSensitiveCompactTrie.stringIds) else Array.empty[Int] - val caseInsensitiveStringIds = if (hasCaseInsensitive) caseInsensitiveTokens.map(caseInsensitiveCompactTrie.stringIds) else Array.empty[Int] + val caseSensitiveStringIds = if (hasCaseSensitive) caseSensitiveTokens.map( caseSensitiveCompactTrie.stringIds) else Seq.empty[Int] + val caseInsensitiveStringIds = if (hasCaseInsensitive) caseInsensitiveTokens.map(caseInsensitiveCompactTrie.stringIds) else Seq.empty[Int] // These are intended to cut down on the number of objects created. // It worked better when there was only one setting for case. @@ -88,7 +88,7 @@ class CompactLexiconNER( def updateSpanAndIndex(): Unit = { - def innerGetSpanAndIndex(condition: Boolean, stringIds: Array[Int], spanAndIndex: SpanAndIndex, + def innerGetSpanAndIndex(condition: Boolean, stringIds: Seq[Int], spanAndIndex: SpanAndIndex, compactTrie: CompactTrie): SpanAndIndex = { if (condition) { val id = stringIds(offset) @@ -136,7 +136,7 @@ class CompactLexiconNER( labels } - def findAt(ids: Array[Int], wordIndex: Int, nodeMatch: SpanAndIndex, compactTrie: CompactTrie): Unit = { + def findAt(ids: Seq[Int], wordIndex: Int, nodeMatch: SpanAndIndex, compactTrie: CompactTrie): Unit = { def linearSearch(value: Int, left: Int, right: Int): Int = { var index = left @@ -376,7 +376,7 @@ object CompactLexiconNER { // Assume that trieNodes are already sorted as much as necessary and all the tokens have stringIds. // Returns the number of parentsAdded and childrenAdded - def add(trieNodes: Array[IntTrieNode], parentOffset: Int, childOffset: Int): (Int, Int) = { + def add(trieNodes: Seq[IntTrieNode], parentOffset: Int, childOffset: Int): (Int, Int) = { // Area between parentOffset and parentOffset + parentRserve is for this recursive pass and // likewise for between childOffset and childOffset + childReserve. val parentReserve = trieNodes.length diff --git a/library/src/main/scala/org/clulab/sequences/LexiconNER.scala b/library/src/main/scala/org/clulab/sequences/LexiconNER.scala index b1c643fd3..688f196b6 100644 --- a/library/src/main/scala/org/clulab/sequences/LexiconNER.scala +++ b/library/src/main/scala/org/clulab/sequences/LexiconNER.scala @@ -1,12 +1,11 @@ package org.clulab.sequences import org.clulab.processors.Sentence +import org.clulab.scala.SeqView import org.clulab.scala.WrappedArray._ import org.clulab.struct.{EntityValidator, TrueEntityValidator} -import org.clulab.utils.ArrayView import java.io.File -import scala.collection.mutable /** * The abstract base class for several concrete child classes used for Named Entity @@ -55,7 +54,7 @@ abstract class LexiconNER(val knownCaseInsensitives: Set[String], val useLemmas: * @param sentence The input sentence * @return An array of BIO notations the store the outcome of the matches */ - def find(sentence: Sentence): Array[String] + def find(sentence: Sentence): Seq[String] def getLabels: Seq[String] /** @@ -74,49 +73,49 @@ abstract class LexiconNER(val knownCaseInsensitives: Set[String], val useLemmas: } } - def hasCondition(wordsView: ArrayView[String], condition: Char => Boolean): Boolean = + def hasCondition(wordsView: SeqView.Type[String], condition: Char => Boolean): Boolean = wordsView.exists(_.exists(condition)) - def hasLetter(wordsView: ArrayView[String]): Boolean = + def hasLetter(wordsView: SeqView.Type[String]): Boolean = hasCondition(wordsView, Character.isLetter) - def hasDigit(wordsView: ArrayView[String]): Boolean = + def hasDigit(wordsView: SeqView.Type[String]): Boolean = hasCondition(wordsView, Character.isDigit) - def hasUpperCaseLetters(wordsView: ArrayView[String]): Boolean = + def hasUpperCaseLetters(wordsView: SeqView.Type[String]): Boolean = hasCondition(wordsView, Character.isUpperCase) - def hasSpace(wordsView: ArrayView[String]): Boolean = wordsView.length > 1 + def hasSpace(wordsView: SeqView.Type[String]): Boolean = wordsView.size > 1 - def countCharacters(wordsView: ArrayView[String]): Int = + def countCharacters(wordsView: SeqView.Type[String]): Int = // Go ahead and calculate them all even though we only need to know if they exceed a value. wordsView.foldLeft(0) { (sum, word) => sum + word.length } - val contentQualifiers: Array[ArrayView[String] => Boolean] = Array( + val contentQualifiers: Array[SeqView.Type[String] => Boolean] = Array( // Start with the quick and easy ones. hasSpace, - { wordsView => countCharacters(wordsView) > LexiconNER.KNOWN_CASE_INSENSITIVE_LENGTH }, + { (wordsView: SeqView.Type[String]) => countCharacters(wordsView) > LexiconNER.KNOWN_CASE_INSENSITIVE_LENGTH }, hasDigit, hasUpperCaseLetters, - { wordsView => knownCaseInsensitives.contains(wordsView.head) } + { (wordsView: SeqView.Type[String]) => knownCaseInsensitives.contains(wordsView.head) } ) protected def contentfulSpan(sentence: Sentence, start: Int, length: Int): Boolean = { - val wordsView = ArrayView(sentence.words, start, start + length) + val wordsView = sentence.words.view.slice(start, start + length) // A valid view/span must have a letter and at least one of the other qualifiers. val contentful = hasLetter(wordsView) && contentQualifiers.exists(_(wordsView)) contentful } - protected val getTokens: Sentence => Array[String] = + protected val getTokens: Sentence => Seq[String] = // Decide this once and for all and don't revisit it each time getTokens is called. if (useLemmas) getLemmas else getWords - protected def getLemmas(sentence: Sentence): Array[String] = sentence.lemmas.get + protected def getLemmas(sentence: Sentence): Seq[String] = sentence.lemmas.get - protected def getWords(sentence: Sentence): Array[String] = sentence.words + protected def getWords(sentence: Sentence): Seq[String] = sentence.words } object LexiconNER { @@ -313,7 +312,7 @@ object LexiconNER { var upperCaseLetters = 0 val spaces = math.max(0, end - start - 1) // Spaces are between words, not after them. - ArrayView(words, start, end).foreach { word => + words.view.slice(start, end).foreach { word => characters += word.length word.foreach { c => if (Character.isLetter(c)) letters += 1 @@ -346,7 +345,7 @@ object LexiconNER { while (offset < length) { val notOutsideCount = countWhile(src, offset, isNotOutside) // Check that there is not anything in dst that should not be overwritten. - if (!ArrayView(dst, offset, offset + notOutsideCount).exists(isNotOutside(_))) + if (!dst.view.slice(offset, offset + notOutsideCount).exists(isNotOutside(_))) Array.copy(src, offset, dst, offset, notOutsideCount) offset += notOutsideCount diff --git a/library/src/main/scala/org/clulab/sequences/MEMMSequenceTagger.scala b/library/src/main/scala/org/clulab/sequences/MEMMSequenceTagger.scala index aa6ac8b47..ff2dacaab 100644 --- a/library/src/main/scala/org/clulab/sequences/MEMMSequenceTagger.scala +++ b/library/src/main/scala/org/clulab/sequences/MEMMSequenceTagger.scala @@ -14,7 +14,7 @@ import scala.reflect.ClassTag import scala.util.Using /** - * Sequence tagger using a maximum entrop Markov model (MEMM) + * Sequence tagger using a maximum entropy Markov model (MEMM) * User: mihais * Date: 8/26/17 */ @@ -32,7 +32,7 @@ abstract class MEMMSequenceTagger[L: ClassTag, F: ClassTag](var order:Int = 1, v var sentCount = 0 for(doc <- docs; origSentence <- doc.sentences) { // labels and features for one sentence - val sentence = if(leftToRight) origSentence else origSentence.revert() + val sentence = if(leftToRight) origSentence else origSentence.reverse() val labels = if(leftToRight) labelExtractor(origSentence) else SeqUtils.revert(labelExtractor(origSentence)).toArray @@ -67,8 +67,8 @@ abstract class MEMMSequenceTagger[L: ClassTag, F: ClassTag](var order:Int = 1, v logger.debug("Finished training.") } - override def classesOf(origSentence: Sentence):Array[L] = { - val sentence = if(leftToRight) origSentence else origSentence.revert() + override def classesOf(origSentence: Sentence):Seq[L] = { + val sentence = if(leftToRight) origSentence else origSentence.reverse() val history = new ArrayBuffer[L]() for(i <- 0 until sentence.size) { @@ -80,7 +80,7 @@ abstract class MEMMSequenceTagger[L: ClassTag, F: ClassTag](var order:Int = 1, v history += label } - if(leftToRight) history.toArray else SeqUtils.revert(history).toArray + if(leftToRight) history else SeqUtils.revert(history) } override def save(file: File): Unit = { diff --git a/library/src/main/scala/org/clulab/sequences/NamedEntity.scala b/library/src/main/scala/org/clulab/sequences/NamedEntity.scala index 1c2b2bcb9..a8f2a8da8 100644 --- a/library/src/main/scala/org/clulab/sequences/NamedEntity.scala +++ b/library/src/main/scala/org/clulab/sequences/NamedEntity.scala @@ -1,5 +1,9 @@ package org.clulab.sequences +import org.clulab.utils.WrappedArraySeq + +import scala.collection.mutable + // This is definitely not the most efficient as far as number of objects // created, but there should be a NamedEntity thing to hold and not just // shadows of it projected onto the BIO notation in an array of strings. @@ -23,7 +27,7 @@ object NamedEntity { val INSIDE = "I-" val OUTSIDE = "O" - def collect(bioLabels: IndexedSeq[String]): IndexedSeq[NamedEntity] = { + def collect(bioLabels: Seq[String]): Seq[NamedEntity] = { def mkNamedEntity(label: String, begin: Int): NamedEntity = { // Start looking for the end one after the begin. @@ -41,48 +45,51 @@ object NamedEntity { namedEntities } - def combine(bioLabels: Array[String], genericNamedEntities: Seq[NamedEntity], customNamedEntities: Seq[NamedEntity]): Array[String] = { + def combine(bioLabels: Seq[String], genericNamedEntities: Seq[NamedEntity], customNamedEntities: Seq[NamedEntity]): Seq[String] = { + val bioLabelsArray = bioLabels.toArray // Neither named entities sequence can contain overlapping elements within the sequence. // At most, there is overlap between sequences. Use is made of that fact. // The NamedEntities never have empty Ranges, so end - 1 is always at least start. - val outsides = bioLabels.indices.filter(bioLabels(_) == OUTSIDE) + val outsides = bioLabelsArray.indices.filter(bioLabelsArray(_) == OUTSIDE) val validStarts = (genericNamedEntities.map(_.range.start) ++ outsides).toSet // The -1 is used to coordinate ends (exclusive) with the OUTSIDE positions (inclusive). val validEnds = (genericNamedEntities.map(_.range.end - 1) ++ outsides).toSet + val validCustomNamedEntities = customNamedEntities.filter { customNamedEntity => + validStarts(customNamedEntity.range.start) && validEnds(customNamedEntity.range.end - 1) + } - customNamedEntities.foreach { customNamedEntity => - if (validStarts(customNamedEntity.range.start) && validEnds(customNamedEntity.range.end - 1)) - customNamedEntity.fill(bioLabels) + validCustomNamedEntities.foreach { customNamedEntity => + customNamedEntity.fill(bioLabelsArray) } - bioLabels + WrappedArraySeq(bioLabelsArray).toImmutableSeq } - def isValid(bioLabels: Array[String], index: Int): Boolean = { - val currBioLabel = bioLabels(index) - !currBioLabel.startsWith(INSIDE) || { - 0 < index && { - val prevBioLabel = bioLabels(index - 1) - prevBioLabel == currBioLabel || { - prevBioLabel == toBegin(currBioLabel) - } - } + // Only INSIDEs can be invalid, and they are made valid by + // converting them into a BEGIN. + def toBegin(bioLabel: String): String = BEGIN + bioLabel.drop(INSIDE.length) + + def isValid(bioLabels: Seq[String]): Boolean = bioLabels.indices.forall { index => + isValid(bioLabels(index), bioLabels.lift(index - 1)) + } + + def isValid(currBioLabel: String, prevBioLabelOpt: Option[String]): Boolean = { + !currBioLabel.startsWith(INSIDE) || prevBioLabelOpt.exists { prevBioLabel => + prevBioLabel == currBioLabel || prevBioLabel == toBegin(currBioLabel) } } - def isValid(bioLabels: Array[String]): Boolean = - bioLabels.indices.forall(isValid(bioLabels, _)) + def patch(bioLabels: Seq[String]): Seq[String] = { + var prevBioLabelOpt = bioLabels.lift(-1) + val newBioLabels = bioLabels.indices.map { index => + val oldBioLabel = bioLabels(index) + val newBioLabel = + if (!isValid(oldBioLabel, prevBioLabelOpt)) toBegin(oldBioLabel) + else oldBioLabel - // Only INSIDEs can be invalid and they are made valid by - // converting them into a BEGIN. - def toBegin(bioLabel: String): String = - BEGIN + bioLabel.drop(INSIDE.length) - - // Note that this patches the array in place! - def patch(bioLabels: Array[String]): Array[String] = { - bioLabels.indices.foreach { index => - if (!isValid(bioLabels, index)) - bioLabels(index) = toBegin(bioLabels(index)) + prevBioLabelOpt = Some(newBioLabel) + newBioLabel } - bioLabels + + newBioLabels } } diff --git a/library/src/main/scala/org/clulab/sequences/SeparatedLexiconNER.scala b/library/src/main/scala/org/clulab/sequences/SeparatedLexiconNER.scala index 435b91b5d..852ba1d69 100644 --- a/library/src/main/scala/org/clulab/sequences/SeparatedLexiconNER.scala +++ b/library/src/main/scala/org/clulab/sequences/SeparatedLexiconNER.scala @@ -63,7 +63,7 @@ class SeparatedLexiconNER( * @param sentence The input sentence * @return An array of BIO notations the store the outcome of the matches */ - def find(sentence: Sentence): Array[String] = { + def find(sentence: Sentence): Seq[String] = { val seq = findLongestMatch(sentence) seq } @@ -110,7 +110,7 @@ class SeparatedLexiconNER( labels } - protected def findAt(tokens: Array[String], caseInsensitiveTokens: Array[String], offset: Int): (Int, Int) = { + protected def findAt(tokens: Seq[String], caseInsensitiveTokens: Seq[String], offset: Int): (Int, Int) = { def findAt(matcher: BooleanHashTrie): Int = matcher.findAt(if (matcher.caseInsensitive) caseInsensitiveTokens else tokens, offset).length diff --git a/library/src/main/scala/org/clulab/sequences/SequenceTagger.scala b/library/src/main/scala/org/clulab/sequences/SequenceTagger.scala index 6c902e89f..76081875a 100644 --- a/library/src/main/scala/org/clulab/sequences/SequenceTagger.scala +++ b/library/src/main/scala/org/clulab/sequences/SequenceTagger.scala @@ -15,7 +15,7 @@ import scala.util.Using trait SequenceTagger[L, F] extends Tagger[L] { def train(docs:Iterator[Document]): Unit - def classesOf(sentence: Sentence):Array[L] + def classesOf(sentence: Sentence):Seq[L] /** Abstract method that generates the features for the word at the position offset in the given sentence */ def featureExtractor(features:Counter[F], sentence: Sentence, offset:Int): Unit @@ -23,7 +23,7 @@ trait SequenceTagger[L, F] extends Tagger[L] { /** Abstract method that extracts the training labels for a given sentence */ def labelExtractor(sentence:Sentence): Array[L] - override def find(sentence: Sentence): Array[L] = classesOf(sentence) + override def find(sentence: Sentence): Seq[L] = classesOf(sentence) def save(fn:File): Unit diff --git a/library/src/main/scala/org/clulab/sequences/SequenceTaggerShell.scala b/library/src/main/scala/org/clulab/sequences/SequenceTaggerShell.scala index 9bcb7368f..1b4566e68 100644 --- a/library/src/main/scala/org/clulab/sequences/SequenceTaggerShell.scala +++ b/library/src/main/scala/org/clulab/sequences/SequenceTaggerShell.scala @@ -5,6 +5,7 @@ import java.io.File import jline.console.ConsoleReader import jline.console.history.FileHistory import org.clulab.processors.Sentence +import org.clulab.scala.WrappedArray._ /** * Simple shell for sequence taggers diff --git a/library/src/main/scala/org/clulab/sequences/Tagger.scala b/library/src/main/scala/org/clulab/sequences/Tagger.scala index 973e4dba2..8e3f54e5c 100644 --- a/library/src/main/scala/org/clulab/sequences/Tagger.scala +++ b/library/src/main/scala/org/clulab/sequences/Tagger.scala @@ -8,5 +8,5 @@ import org.clulab.processors.Sentence * Date: 10/12/17 */ trait Tagger[L] { - def find(sentence:Sentence):Array[L] + def find(sentence:Sentence):Seq[L] } diff --git a/library/src/main/scala/org/clulab/serialization/CoNLLUSerializer.scala b/library/src/main/scala/org/clulab/serialization/CoNLLUSerializer.scala index 523873e65..9508b133f 100644 --- a/library/src/main/scala/org/clulab/serialization/CoNLLUSerializer.scala +++ b/library/src/main/scala/org/clulab/serialization/CoNLLUSerializer.scala @@ -8,7 +8,7 @@ object CoNLLUSerializer { val UNDEF = "_" val ROOT = "root" - def getOrElseUndef(stringsOpt: Option[Array[String]], i: Int): String = + def getOrElseUndef(stringsOpt: Option[Seq[String]], i: Int): String = stringsOpt.map(_(i)).getOrElse(UNDEF) /** diff --git a/library/src/main/scala/org/clulab/serialization/DocumentSerializer.scala b/library/src/main/scala/org/clulab/serialization/DocumentSerializer.scala index 8016375ee..093185b7f 100644 --- a/library/src/main/scala/org/clulab/serialization/DocumentSerializer.scala +++ b/library/src/main/scala/org/clulab/serialization/DocumentSerializer.scala @@ -3,6 +3,7 @@ package org.clulab.serialization import org.clulab.processors.DocumentAttachment import org.clulab.processors.DocumentAttachmentBuilderFromText import org.clulab.processors.{Document, Sentence} +import org.clulab.scala.WrappedArrayBuffer._ import org.clulab.struct._ import org.clulab.utils.Logging import org.json4s.DefaultFormats @@ -102,13 +103,9 @@ class DocumentSerializer extends Logging { assert(bits(0) == END_OF_DOCUMENT, s"END_OF_DOCUMENT expected, found ${bits(0)}") - val doc = Document(sents.toArray) - doc.coreferenceChains = coref - doc.text = text - - // TODO: Hack by Enrique to resolve the document object for the relations - for(sen <- doc.sentences){ + /* + val relationsOpt = for(sen <- sents){ sen.relations match { case Some(relations) => val newRelations = relations.map(r => RelationTriple(r.confidence, r.subjectInterval, r.relationInterval, r.objectInterval)) @@ -116,13 +113,18 @@ class DocumentSerializer extends Logging { case None => () } } + */ - namedDocumentAttachmentsOpt.foreach { namedDocumentAttachments => - namedDocumentAttachments.foreach { case (name: String, documentAttachment: DocumentAttachment) => - doc.addAttachment(name, documentAttachment) - } + val attachmentsOpt = namedDocumentAttachmentsOpt.map { namedDocumentAttachments => + namedDocumentAttachments.toMap } + val doc = new Document( + sentences = sents, + text = text, + attachments = attachmentsOpt + ) + doc } @@ -166,7 +168,7 @@ class DocumentSerializer extends Logging { Interval(t(0), t(1)) } - private def loadRelations(r: BufferedReader, sz: Int):Option[Array[RelationTriple]] = { + private def loadRelations(r: BufferedReader, sz: Int):Option[Seq[RelationTriple]] = { val ret = (0 until sz) map { _ => val line = r.readLine() @@ -174,7 +176,7 @@ class DocumentSerializer extends Logging { val relInterval = tokens(2) match { case "N" => None; case s => Some(mkRelationInterval(s)) } RelationTriple(tokens(0).toFloat, mkRelationInterval(tokens(1)), relInterval, mkRelationInterval(tokens(3))) } - Some(ret.toArray) + Some(ret) } private def loadSentence(r:BufferedReader): Sentence = { @@ -230,9 +232,9 @@ class DocumentSerializer extends Logging { assert(normBuffer.isEmpty || normBuffer.size == tokenCount) assert(chunkBuffer.isEmpty || chunkBuffer.size == tokenCount) - var deps = GraphMap() + var deps = GraphMap.empty var tree:Option[Tree] = None - var relations:Option[Array[RelationTriple]] = None + var relations:Option[Seq[RelationTriple]] = None while ({ bits = read(r) if (bits(0) == START_DEPENDENCIES) { @@ -252,10 +254,10 @@ class DocumentSerializer extends Logging { }) () Sentence( - rawBuffer.toArray, - startOffsetBuffer.toArray, - endOffsetBuffer.toArray, - wordBuffer.toArray, + rawBuffer, + startOffsetBuffer, + endOffsetBuffer, + wordBuffer, bufferOption(tagBuffer, nilTags), bufferOption(lemmaBuffer, nilLemmas), bufferOption(entityBuffer, nilEntities), @@ -288,10 +290,10 @@ class DocumentSerializer extends Logging { dg } - private def bufferOption[T: ClassTag](b:ArrayBuffer[T], allNils:Boolean): Option[Array[T]] = { + private def bufferOption[T: ClassTag](b:ArrayBuffer[T], allNils:Boolean): Option[Seq[T]] = { if (b.isEmpty) None else if (allNils) None - else Some(b.toArray) + else Some(b) } def save(doc:Document, os:PrintWriter): Unit = save(doc, os, keepText = false) @@ -329,11 +331,12 @@ class DocumentSerializer extends Logging { } // Sort these so that serialization is the same each time. - val attachmentKeys = doc.getAttachmentKeys.toList.sorted + val attachments = doc.attachments.getOrElse(Map.empty) + val attachmentKeys = attachments.keySet if (attachmentKeys.nonEmpty) { os.println(START_ATTACHMENTS + SEP + attachmentKeys.size) attachmentKeys.foreach { key => - val value = doc.getAttachment(key).get + val value = attachments(key) os.print(escapeAttachment(key)) os.print(SEP) os.print(escapeAttachment(value.documentAttachmentBuilderFromTextClassName)) diff --git a/library/src/main/scala/org/clulab/serialization/json/JSONSerializer.scala b/library/src/main/scala/org/clulab/serialization/json/JSONSerializer.scala index 181400b2d..ebc20d8b7 100644 --- a/library/src/main/scala/org/clulab/serialization/json/JSONSerializer.scala +++ b/library/src/main/scala/org/clulab/serialization/json/JSONSerializer.scala @@ -1,10 +1,9 @@ package org.clulab.serialization.json import java.io.File -import org.clulab.processors.DocumentAttachmentBuilderFromJson -import org.clulab.processors.{Document, Sentence} +import org.clulab.processors.{Document, DocumentAttachment, DocumentAttachmentBuilderFromJson, DocumentAttachments, Sentence} import org.clulab.struct.Edge -import org.clulab.struct.{DirectedGraph, GraphMap} +import org.clulab.struct.DirectedGraph import org.clulab.utils.FileUtils import org.json4s import org.json4s.JsonDSL._ @@ -12,6 +11,8 @@ import org.json4s._ import org.json4s.jackson.JsonMethods._ import org.json4s.jackson.prettyJson +import scala.collection.mutable + /** JSON serialization utilities */ // This annotation is to avoid "Compiler synthesis of Manifest and OptManifest is deprecated". @@ -23,12 +24,12 @@ object JSONSerializer { def jsonAST(f: File): JValue = jsonAST(FileUtils.getTextFromFile(f)) - protected def addDocumentAttachments(doc: Document, jValue: JValue): Unit = { + protected def getDocumentAttachments(jValue: JValue): Option[DocumentAttachments.Type] = { // See also DocumentSerializer for text version of nearly the same thing. (jValue \ DOCUMENT_ATTACHMENTS_KEY) match { case jObject: JObject => val keys = jObject.values.keys - keys.foreach { (key: String) => + val keyAndDocumentAttachmentPairs = keys.flatMap { (key: String) => (jObject \ key) match { case jObject: JObject => val documentAttachmentBuilderFromJsonClassName = (jObject \ DOCUMENT_ATTACHMENTS_BUILDER_KEY).extract[String] @@ -38,28 +39,36 @@ object JSONSerializer { val documentAttachmentBuilder = obj.asInstanceOf[DocumentAttachmentBuilderFromJson] val value = (jObject \ DOCUMENT_ATTACHMENTS_VALUE_KEY) val documentAttachment = documentAttachmentBuilder.mkDocumentAttachment(value) - doc.addAttachment(key, documentAttachment) + + Some((key, documentAttachment)) case jValue: JValue => val text = prettyJson(jValue) throw new RuntimeException(s"ERROR: While deserializing document attachments expected JObject but found this: $text") // case _ => // noop. It should never get here. (Famous last words.) - case null => // noop. It should never get here. (Famous last words.) Scala 3 prefers null over _. + case null => None // noop. It should never get here. (Famous last words.) Scala 3 prefers null over _. } } + Some(keyAndDocumentAttachmentPairs.toMap) case _ => // Leave documentAttachments as is: None + None } } def toDocument(json: JValue): Document = { // recover sentences val sentences = (json \ "sentences").asInstanceOf[JArray].arr.map(sjson => toSentence(sjson)).toArray + val id = getStringOption(json, "id") + val text = getStringOption(json, "text") // initialize document - val d = Document(sentences) - // update id - d.id = getStringOption(json, "id") - // update text - d.text = getStringOption(json, "text") - addDocumentAttachments(d, json) + val attachments = getDocumentAttachments(json) + val d = new Document( + id = id, + sentences = sentences, + coreferenceChains = None, + text = text, + attachments = attachments + ) + d } def toDocument(docHash: String, djson: JValue): Document = toDocument(djson \ docHash) @@ -68,25 +77,40 @@ object JSONSerializer { def toSentence(json: JValue): Sentence = { - def getLabels(json: JValue, k: String): Option[Array[String]] = json \ k match { + def getStrings(json: JValue, k: String): Array[String] = (json \ k).extract[Array[String]] + + def getInts(json: JValue, k: String): Array[Int] = (json \ k).extract[Array[Int]] + + def getLabelsOpt(json: JValue, k: String): Option[Seq[String]] = json \ k match { case JNothing => None case contents => Some(contents.extract[Array[String]]) } - val s = json.extract[Sentence] - val preferredSize = s.words.length - // build dependencies - val graphs = (json \ "graphs").extract[JObject].obj.map { case (key, json) => - key -> toDirectedGraph(json, Some(preferredSize)) - }.toMap - s.graphs = GraphMap(graphs) - // build labels - s.tags = getLabels(json, "tags") - s.lemmas = getLabels(json, "lemmas") - s.entities = getLabels(json, "entities") - s.norms = getLabels(json, "norms") - s.chunks = getLabels(json, "chunks") - s + val raw = getStrings(json, "raw") + val startOffsets = getInts(json, "startOffsets") + val endOffsets = getInts(json, "endOffsets") + val words = getStrings(json, "words") + val tags = getLabelsOpt(json, "tags") + val lemmas = getLabelsOpt(json, "lemmas") + val entities = getLabelsOpt(json, "entities") + val norms = getLabelsOpt(json, "norms") + val chunks = getLabelsOpt(json, "chunks") + val syntacticTree = None // TODO: Are these not serialized? + val graphs = { + val preferredSize = words.length + val graphs = (json \ "graphs").extract[JObject].obj.map { case (key, json) => + key -> toDirectedGraph(json, Some(preferredSize)) + }.toMap + + graphs + } + val relations = None // TODO: Are these not serialized? + val parsedSentence = Sentence( + raw, startOffsets, endOffsets, words, + tags, lemmas, entities, norms, chunks, syntacticTree, graphs, relations + ) + + parsedSentence } def toDirectedGraph(json: JValue, preferredSizeOpt: Option[Int] = None): DirectedGraph[String] = { diff --git a/library/src/main/scala/org/clulab/serialization/json/package.scala b/library/src/main/scala/org/clulab/serialization/json/package.scala index 27adb3fd9..a0fbf4f0e 100644 --- a/library/src/main/scala/org/clulab/serialization/json/package.scala +++ b/library/src/main/scala/org/clulab/serialization/json/package.scala @@ -22,7 +22,7 @@ package object json { } // Arrays cannot be directly converted to JValue - implicit class ArrayOps(s: Option[Array[String]]) { + implicit class ArrayOps(s: Option[Seq[String]]) { def toSerializableJSON: Option[List[String]] = s match { case Some(s) => Some(s.toList) case None => None @@ -52,8 +52,8 @@ package object json { } } - implicit class GraphMapOps(gm: GraphMap) extends JSONSerialization { - def jsonAST: JValue = Extraction.decompose(gm.toMap.map { case (k, v) => k -> v.jsonAST }) // instead of mapValues + implicit class GraphMapOps(gm: GraphMap.Type) extends JSONSerialization { + def jsonAST: JValue = Extraction.decompose(gm.map { case (k, v) => k -> v.jsonAST }) // instead of mapValues } /** For Document */ @@ -61,10 +61,11 @@ package object json { def jsonAST: JValue = { // See also DocumentSerializer for a similar text implementation. - val attachmentKeys = doc.getAttachmentKeys.toList.sorted + val attachments = doc.attachments.getOrElse(Map.empty) + val attachmentKeys = attachments.keySet.toList.sorted val documentAttachments: JValue = if (attachmentKeys.nonEmpty) { val jFields = attachmentKeys.map { key => - val value = doc.getAttachment(key).get + val value = attachments(key) JField(key, (DOCUMENT_ATTACHMENTS_BUILDER_KEY -> JString(value.documentAttachmentBuilderFromJsonClassName)) ~ (DOCUMENT_ATTACHMENTS_VALUE_KEY -> value.toJsonSerializer) diff --git a/library/src/main/scala/org/clulab/struct/Annotation.scala b/library/src/main/scala/org/clulab/struct/Annotation.scala new file mode 100644 index 000000000..d9f390a86 --- /dev/null +++ b/library/src/main/scala/org/clulab/struct/Annotation.scala @@ -0,0 +1,37 @@ +package org.clulab.struct + +// These are by the word ones and then there are relationships between words. +// So parse, might not be a thing that is per word. +//case class WordParse(tag: String, lemma: String, entity: String, norm: String, chunk: String) + +//case class SentenceParse(tags: Array[String], syntacticTree, graphs, relations) + +case class Annotation( + tags: Option[Array[String]] = None, + /** Lemmas */ + lemmas: Option[Array[String]] = None, + /** NE labels */ + entities: Option[Array[String]] = None, + /** Normalized values of named/numeric entities, such as dates */ + norms: Option[Array[String]] = None, + /** Shallow parsing labels */ + chunks: Option[Array[String]] = None, + /** Constituent tree of this sentence; includes head words */ + syntacticTree: Option[Tree] = None, + /** DAG of syntactic and semantic dependencies; word offsets start at 0 */ + graphs: GraphMap.Type = GraphMap.empty, + /** Relation triples from OpenIE */ + relations:Option[Array[RelationTriple]] = None +) { + + def reverse: Annotation = { + Annotation( + tags = tags.map(_.reverse), + lemmas = lemmas.map(_.reverse), + entities = entities.map(_.reverse), + norms = norms.map(_.reverse), + chunks = chunks.map(_.reverse) + // TODO: reverse syntacticTree, graphs, and relations! + ) + } +} diff --git a/library/src/main/scala/org/clulab/struct/BooleanHashTrie.scala b/library/src/main/scala/org/clulab/struct/BooleanHashTrie.scala index fd0b586fa..5ab19e3ad 100644 --- a/library/src/main/scala/org/clulab/struct/BooleanHashTrie.scala +++ b/library/src/main/scala/org/clulab/struct/BooleanHashTrie.scala @@ -80,7 +80,7 @@ class BooleanHashTrie(val label: String, val caseInsensitive: Boolean = true) ex * When multiple paths are found, the longest one is kept * Text must be normalized (i.e., case folding) BEFORE this call, if necessary! */ - def findAt(sequenceNormalized: Array[String], offset: Int): BooleanTrieNode.Match = { + def findAt(sequenceNormalized: Seq[String], offset: Int): BooleanTrieNode.Match = { val longestMatch = new BooleanTrieNode.Match() entries.get(sequenceNormalized(offset)).map { tree => @@ -129,7 +129,7 @@ case class BooleanTrieNode(token: String, var completePath: Boolean, var childre * @param longestMatch The value of the longest match interval * @return true if search should stop here; false otherwise */ - def find(sequence: Array[String], + def find(sequence: Seq[String], startOffset: Int, currentSpanLength: Int, longestMatch: BooleanTrieNode.Match): Boolean = { @@ -261,13 +261,13 @@ class DebugBooleanHashTrie(label: String, caseInsensitive: Boolean = true) exten * Generates BIO labels for this sequence when complete trie paths match * When multiple paths match, the longest one is kept */ - def find(sequence: Array[String], outsideLabel: String): Array[String] = { + def find(sequence: Seq[String], outsideLabel: String): Array[String] = { val casedSequence = if (caseInsensitive) sequence.map(_.toLowerCase) else sequence findNormalized(casedSequence, outsideLabel) } - private def findNormalized(sequence: Array[String], outsideLabel: String): Array[String] = { + private def findNormalized(sequence: Seq[String], outsideLabel: String): Array[String] = { val labels = new Array[String](sequence.length) var offset = 0 diff --git a/library/src/main/scala/org/clulab/struct/DependencyMapNames.scala b/library/src/main/scala/org/clulab/struct/DependencyMapNames.scala deleted file mode 100644 index 82a8b39ab..000000000 --- a/library/src/main/scala/org/clulab/struct/DependencyMapNames.scala +++ /dev/null @@ -1,7 +0,0 @@ -package org.clulab.struct - -trait DependencyMapNames { - val STANFORD_BASIC = 0 // basic Stanford dependencies - val STANFORD_COLLAPSED = 1 // collapsed Stanford dependencies - val SEMANTIC_ROLES = 2 // semantic roles from CoNLL 2008-09, which includes PropBank and NomBank -} diff --git a/library/src/main/scala/org/clulab/struct/GraphMapNames.scala b/library/src/main/scala/org/clulab/struct/GraphMap.scala similarity index 86% rename from library/src/main/scala/org/clulab/struct/GraphMapNames.scala rename to library/src/main/scala/org/clulab/struct/GraphMap.scala index 012f0f52a..6857916e3 100644 --- a/library/src/main/scala/org/clulab/struct/GraphMapNames.scala +++ b/library/src/main/scala/org/clulab/struct/GraphMap.scala @@ -1,6 +1,10 @@ package org.clulab.struct -trait GraphMapNames { +object GraphMap { + type Type = Map[String, DirectedGraph[String]] + + val empty: Type = Map.empty + val UNIVERSAL_BASIC = "universal-basic" // basic Universal dependencies val UNIVERSAL_ENHANCED = "universal-enhanced" // collapsed (or enhanced) Universal dependencies val STANFORD_BASIC = "stanford-basic" // basic Stanford dependencies diff --git a/library/src/main/scala/org/clulab/struct/HashTrie.scala b/library/src/main/scala/org/clulab/struct/HashTrie.scala index 331858735..1bcd8c0af 100644 --- a/library/src/main/scala/org/clulab/struct/HashTrie.scala +++ b/library/src/main/scala/org/clulab/struct/HashTrie.scala @@ -4,11 +4,11 @@ package org.clulab.struct class HashTrie(caseInsensitive: Boolean = true) extends BooleanHashTrie("", caseInsensitive) { - def find(sequence:Array[String], label: String, outsideLabel: String): Array[String] = + def find(sequence:Seq[String], label: String, outsideLabel: String): Array[String] = if (caseInsensitive) findNormalized(sequence.map(_.toLowerCase), label, outsideLabel) else findNormalized(sequence, label, outsideLabel) - protected def findNormalized(tokens: Array[String], label: String, outsideLabel: String): Array[String] = { + protected def findNormalized(tokens: Seq[String], label: String, outsideLabel: String): Array[String] = { val labels = new Array[String](tokens.length) lazy val bLabel = "B-" + label // lazy thinking that most calls will not use it lazy val iLabel = "I-" + label diff --git a/library/src/main/scala/org/clulab/struct/IntHashTrie.scala b/library/src/main/scala/org/clulab/struct/IntHashTrie.scala index 70a22984e..9b3403cc5 100644 --- a/library/src/main/scala/org/clulab/struct/IntHashTrie.scala +++ b/library/src/main/scala/org/clulab/struct/IntHashTrie.scala @@ -82,7 +82,7 @@ class IntHashTrie(val caseInsensitive: Boolean = true) extends Serializable { * When multiple paths are found, the longest one is kept * Text must be normalized (i.e., case folding) BEFORE this call, if necessary! */ - def findAt(sequenceNormalized: Array[String], offset: Int): IntTrieNode.Match = { + def findAt(sequenceNormalized: Seq[String], offset: Int): IntTrieNode.Match = { val longestMatch = new IntTrieNode.Match() entries.get(sequenceNormalized(offset)).map { tree => @@ -134,7 +134,7 @@ case class IntTrieNode(token:String, var completePath: Int, var children: Option * @param longestMatch The value of the longest match interval * @return true if search should stop here; false otherwise */ - def find(sequence: Array[String], + def find(sequence: Seq[String], startOffset: Int, currentSpanLength: Int, longestMatch: IntTrieNode.Match): Boolean = { diff --git a/library/src/main/scala/org/clulab/struct/Tokenization.scala b/library/src/main/scala/org/clulab/struct/Tokenization.scala new file mode 100644 index 000000000..78e8b21da --- /dev/null +++ b/library/src/main/scala/org/clulab/struct/Tokenization.scala @@ -0,0 +1,21 @@ +package org.clulab.struct + +// An alternative design would not use aligned arrays, but an array of structures. +case class WordTokenization(raw: String, startOffset: Int, endOffset: Int, word: String) + +case class Tokenization( + raw: Array[String], + startOffsets: Array[Int], + endOffsets: Array[Int], + words: Array[String] +) { + + def reverse: Tokenization = { + Tokenization( + raw = raw.reverse, + startOffsets = startOffsets.reverse, + endOffsets = endOffsets.reverse, + words = words.reverse + ) + } +} diff --git a/library/src/main/scala/org/clulab/utils/ArrayView.scala b/library/src/main/scala/org/clulab/utils/ArrayView.scala deleted file mode 100644 index afbd6d42a..000000000 --- a/library/src/main/scala/org/clulab/utils/ArrayView.scala +++ /dev/null @@ -1,37 +0,0 @@ -package org.clulab.utils - -import scala.collection.mutable - -// Array.view(from, until) is no longer available in Scala 2.13+. -class ArrayView[T](array: Array[T], from: Int, until: Int) extends IndexedSeq[T] { - val length = until - from - - override def apply(index: Int): T = array(from + index) -} - -object ArrayView { - - def apply[T](array: Array[T]): ArrayView[T] = apply(array, 0) - - def apply[T](array: Array[T], from: Int): ArrayView[T] = apply(array, from, array.length) - - def apply[T](array: Array[T], from: Int, until: Int): ArrayView[T] = new ArrayView(array, from, until) -} - -// Array.view(from, until) is no longer available in Scala 2.13+. -class MutableArrayView[T](array: Array[T], from: Int, until: Int) extends mutable.IndexedSeq[T] { - val length = until - from - - override def apply(index: Int): T = array(from + index) - - override def update(index: Int, elem: T): Unit = array(from + index) = elem -} - -object MutableArrayView { - - def apply[T](array: Array[T]): MutableArrayView[T] = apply(array, 0) - - def apply[T](array: Array[T], from: Int): MutableArrayView[T] = apply(array, from, array.length) - - def apply[T](array: Array[T], from: Int, until: Int): MutableArrayView[T] = new MutableArrayView(array, from, until) -} diff --git a/library/src/main/scala/org/clulab/utils/ToEnhancedDependencies.scala b/library/src/main/scala/org/clulab/utils/ToEnhancedDependencies.scala index 3c19d2c1d..1eb8314d5 100644 --- a/library/src/main/scala/org/clulab/utils/ToEnhancedDependencies.scala +++ b/library/src/main/scala/org/clulab/utils/ToEnhancedDependencies.scala @@ -23,29 +23,29 @@ import scala.collection.mutable.{ArrayBuffer, ListBuffer} object ToEnhancedDependencies { type EdgeSpec = (Int, Int, String) - def generateStanfordEnhancedDependencies(sentence:Sentence, dg:DirectedGraph[String]): DirectedGraph[String] = { + def generateStanfordEnhancedDependencies(words: Array[String], tags: Seq[String], dg:DirectedGraph[String]): DirectedGraph[String] = { val dgi = dg.toDirectedGraphIndex() - collapsePrepositionsStanford(sentence, dgi) + collapsePrepositionsStanford(words, dgi) raiseSubjects(dgi) - pushSubjectsObjectsInsideRelativeClauses(sentence, dgi, universal = false) - propagateSubjectsAndObjectsInConjVerbs(sentence, dgi, universal = false) - propagateConjSubjectsAndObjects(sentence, dgi) - dgi.toDirectedGraph(Some(sentence.size)) + pushSubjectsObjectsInsideRelativeClauses(tags, dgi, universal = false) + propagateSubjectsAndObjectsInConjVerbs(tags, dgi, universal = false) + propagateConjSubjectsAndObjects(tags, dgi) + dgi.toDirectedGraph(Some(words.length)) } - def generateUniversalEnhancedDependencies(sentence:Sentence, dg:DirectedGraph[String]): DirectedGraph[String] = { + def generateUniversalEnhancedDependencies(words: Seq[String], lemmas: Seq[String], tags: Seq[String], dg: DirectedGraph[String]): DirectedGraph[String] = { val dgi = dg.toDirectedGraphIndex() - collapseMWEs(sentence, dgi) - val collapsedNmods = collapsePrepositionsUniversal(sentence, dgi) + collapseMWEs(lemmas, tags, dgi) + val collapsedNmods = collapsePrepositionsUniversal(words, lemmas, tags, dgi) replicateCollapsedNmods(collapsedNmods, dgi) raiseSubjects(dgi) - pushSubjectsObjectsInsideRelativeClauses(sentence, dgi, universal = true) - propagateSubjectsAndObjectsInConjVerbs(sentence, dgi, universal = true) - propagateConjSubjectsAndObjects(sentence, dgi) + pushSubjectsObjectsInsideRelativeClauses(tags, dgi, universal = true) + propagateSubjectsAndObjectsInConjVerbs(tags, dgi, universal = true) // requires tags + propagateConjSubjectsAndObjects(tags, dgi) mergeNsubjXcomp(dgi) - replicateCopulativeSubjects(sentence, dgi) - expandConj(sentence, dgi) // this must be last because several of the above methods expect "conj" labels - dgi.toDirectedGraph(Some(sentence.size)) + replicateCopulativeSubjects(dgi) + expandConj(words, dgi) // this must be last because several of the above methods expect "conj" labels + dgi.toDirectedGraph(Some(words.length)) } /** @@ -66,7 +66,7 @@ object ToEnhancedDependencies { * Replicates copulative subjects across conjunctions * It is difficult and expensive => nsubj from 2 to 0 and from 4 to 0 */ - def replicateCopulativeSubjects(sentence: Sentence, dgi: DirectedGraphIndex[String]): Unit = { + def replicateCopulativeSubjects(dgi: DirectedGraphIndex[String]): Unit = { val nsubjs = dgi.findByName("nsubj") for(nsubj <- nsubjs) { val cops = dgi.findByHeadAndName(nsubj.source, "cop") @@ -102,13 +102,13 @@ object ToEnhancedDependencies { * @param sentence * @param dgi */ - def expandConj(sentence: Sentence, dgi: DirectedGraphIndex[String]): Unit = { + def expandConj(words: Seq[String], dgi: DirectedGraphIndex[String]): Unit = { val toRemove = new ListBuffer[Edge[String]] val conjs = dgi.findByName("conj") for (conj <- conjs) { var shouldRemove = false for(cc <- dgi.findByName("cc").filter(_.source == conj.source)) { - val ccWord = sentence.words(cc.destination).toLowerCase() + val ccWord = words(cc.destination).toLowerCase() dgi.addEdge(conj.source, conj.destination, s"conj_$ccWord") shouldRemove = true } @@ -125,12 +125,12 @@ object ToEnhancedDependencies { * @param sentence The sentence to operate on * @param dgi The directed graph of collapsed dependencies at this stage */ - def collapsePrepositionsStanford(sentence:Sentence, dgi:DirectedGraphIndex[String]): Unit = { + def collapsePrepositionsStanford(words: Array[String], dgi:DirectedGraphIndex[String]): Unit = { val toRemove = new ListBuffer[Edge[String]] val preps = dgi.findByName("prep") for(prep <- preps) { toRemove += prep - val word = sentence.words(prep.destination) + val word = words(prep.destination) for(pobj <- dgi.findByName("pobj").filter(_.source == prep.destination)) { dgi.addEdge(prep.source, pobj.destination, s"prep_$word") toRemove += pobj @@ -140,12 +140,12 @@ object ToEnhancedDependencies { } def collapsePrepositionsUniversal( - sentence:Sentence, + words: Seq[String], lemmas: Seq[String], tags: Seq[String], dgi:DirectedGraphIndex[String]): Seq[EdgeSpec] = { val collapsedNmods = new ArrayBuffer[EdgeSpec]() - collapsePrepositionsUniversalNmodCase(sentence, dgi, collapsedNmods) - collapsePrepositionsUniversalDueTo(sentence, dgi, collapsedNmods) + collapsePrepositionsUniversalNmodCase(words, dgi, collapsedNmods) + collapsePrepositionsUniversalDueTo(lemmas, tags, dgi, collapsedNmods) collapsedNmods } @@ -156,7 +156,7 @@ object ToEnhancedDependencies { * @param dgi The directed graph of collapsed dependencies at this stage */ def collapsePrepositionsUniversalNmodCase( - sentence:Sentence, + words: Seq[String], dgi:DirectedGraphIndex[String], collapsedNmods: ArrayBuffer[EdgeSpec]): Unit = { @@ -166,9 +166,9 @@ object ToEnhancedDependencies { for(prep <- preps) { toRemove += prep for(c <- dgi.findByName("case").filter(_.source == prep.destination)) { - val word = sentence.words(c.destination).toLowerCase() + val word = words(c.destination).toLowerCase() // find multi-word prepositions such as "such as" - val mwe = findMultiWord(word, c.destination, sentence, dgi) + val mwe = findMultiWord(word, c.destination, words, dgi) // TODO: add nmod:agent (if word == "by") and passive voice here? dgi.addEdge(prep.source, prep.destination, s"nmod_$mwe") @@ -189,16 +189,15 @@ object ToEnhancedDependencies { * @param dgi The directed graph of collapsed dependencies at this stage */ def collapsePrepositionsUniversalDueTo( - sentence:Sentence, + lemmas: Seq[String], tags: Seq[String], dgi:DirectedGraphIndex[String], collapsedNmods: ArrayBuffer[EdgeSpec]): Unit = { - val tags = sentence.tags.get val toRemove = new ListBuffer[Edge[String]] var shouldRemove = false val preps = dgi.findByName("mwe") for(prep <- preps) { - if(sentence.lemmas.get(prep.source) == "due" && sentence.lemmas.get(prep.destination) == "to") { + if(lemmas(prep.source) == "due" && lemmas(prep.destination) == "to") { // found a "due to" MWE for(leftDep <- dgi.findByModifier(prep.source)) { // found the dep from "famine" to "due" @@ -235,15 +234,15 @@ object ToEnhancedDependencies { * @param dgi */ def collapseMWEs( - sentence:Sentence, + lemmas: Seq[String], + tags: Seq[String], dgi:DirectedGraphIndex[String]): Unit = { - val lemmas = sentence.lemmas.get - val tags = sentence.tags.get + val size = lemmas.length val toRemove = new ListBuffer[Edge[String]] var shouldRemove = true - for(i <- 0 until sentence.size - 1) { + for(i <- 0 until size - 1) { if(lemmas(i) == "due" && lemmas(i + 1) == "to" && tags(i) == "IN") { val toHeads = dgi.findByModifier(i + 1) var found = false @@ -262,7 +261,7 @@ object ToEnhancedDependencies { if(shouldRemove) remove(toRemove, dgi) } - def findMultiWord(first: String, firstPos: Int, sentence: Sentence, dgi:DirectedGraphIndex[String]): String = { + def findMultiWord(first: String, firstPos: Int, words: Seq[String], dgi:DirectedGraphIndex[String]): String = { val buffer = new StringBuilder buffer.append(first) @@ -273,7 +272,7 @@ object ToEnhancedDependencies { if(mods.isEmpty) { done = true } else { - val word = sentence.words(mods.head.destination).toLowerCase() + val word = words(mods.head.destination).toLowerCase() buffer.append("_") buffer.append(word) head = mods.head.destination @@ -303,9 +302,8 @@ object ToEnhancedDependencies { * @param sentence The sentence to operate on * @param dgi The directed graph of collapsed dependencies at this stage */ - def propagateSubjectsAndObjectsInConjVerbs(sentence:Sentence, dgi:DirectedGraphIndex[String], universal:Boolean): Unit = { + def propagateSubjectsAndObjectsInConjVerbs(tags: Seq[String], dgi:DirectedGraphIndex[String], universal:Boolean): Unit = { val conjs = dgi.findByName("conj").sortBy(_.source) - val tags = sentence.tags.get for(conj <- conjs) { val left = math.min(conj.source, conj.destination) val right = math.max(conj.source, conj.destination) @@ -387,9 +385,8 @@ object ToEnhancedDependencies { * @param sentence The sentence to operate on * @param dgi The directed graph of collapsed dependencies at this stage */ - def propagateConjSubjectsAndObjects(sentence:Sentence, dgi:DirectedGraphIndex[String]): Unit = { + def propagateConjSubjectsAndObjects(tags: Seq[String], dgi:DirectedGraphIndex[String]): Unit = { val conjs = dgi.findByName("conj").sortBy(_.source) - val tags = sentence.tags.get for(conj <- conjs) { val left = math.min(conj.source, conj.destination) val right = math.max(conj.source, conj.destination) @@ -424,11 +421,10 @@ object ToEnhancedDependencies { * @param sentence The sentence to operate on * @param dgi The directed graph of collapsed dependencies at this stage */ - def pushSubjectsObjectsInsideRelativeClauses(sentence:Sentence, dgi:DirectedGraphIndex[String], universal:Boolean): Unit = { + def pushSubjectsObjectsInsideRelativeClauses(tags: Seq[String], dgi:DirectedGraphIndex[String], universal:Boolean): Unit = { val rels = if(universal) dgi.findByName("acl:relcl") else dgi.findByName("rcmod") - val tags = sentence.tags.get for(rel <- rels) { val head = rel.source diff --git a/library/src/main/scala/org/clulab/utils/WrappedArraySeq.scala b/library/src/main/scala/org/clulab/utils/WrappedArraySeq.scala new file mode 100644 index 000000000..a9f13f830 --- /dev/null +++ b/library/src/main/scala/org/clulab/utils/WrappedArraySeq.scala @@ -0,0 +1,21 @@ +package org.clulab.utils + +import scala.collection.mutable +import scala.collection.compat.immutable.ArraySeq + +class WrappedArraySeq[T](array: Array[T]) { + def toSeq: Seq[T] = toImmutableSeq + + def toMutableSeq: mutable.Seq[T] = { + array + } + + def toImmutableSeq: Seq[T] = { + ArraySeq.unsafeWrapArray(array) + } +} + +object WrappedArraySeq { + + def apply[T](array: Array[T]): WrappedArraySeq[T] = new WrappedArraySeq(array) +} diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/CLiMIS_FAO_UNICEF_WFP_South_Sudan_IPC_Jun-16/CLiMIS_FAO_UNICEF_WFP_South_Sudan_IPC_Jun-16 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/CLiMIS_FAO_UNICEF_WFP_South_Sudan_IPC_Jun-16/CLiMIS_FAO_UNICEF_WFP_South_Sudan_IPC_Jun-16 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/CLiMIS_FAO_UNICEF_WFP_South_Sudan_IPC_Jun-16/CLiMIS_FAO_UNICEF_WFP_South_Sudan_IPC_Jun-16 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/CLiMIS_FAO_UNICEF_WFP_South_Sudan_IPC_Jun-16/CLiMIS_FAO_UNICEF_WFP_South_Sudan_IPC_Jun-16 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/EAST_AFRICA_Seasonal_Monitor_5-Jun-17/EAST_AFRICA_Seasonal_Monitor_5-Jun-17 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/EAST_AFRICA_Seasonal_Monitor_5-Jun-17/EAST_AFRICA_Seasonal_Monitor_5-Jun-17 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/EAST_AFRICA_Seasonal_Monitor_5-Jun-17/EAST_AFRICA_Seasonal_Monitor_5-Jun-17 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/EAST_AFRICA_Seasonal_Monitor_5-Jun-17/EAST_AFRICA_Seasonal_Monitor_5-Jun-17 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/EA_Seasonal_Monitor_Aug-17/EA_Seasonal_Monitor_Aug-17 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/EA_Seasonal_Monitor_Aug-17/EA_Seasonal_Monitor_Aug-17 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/EA_Seasonal_Monitor_Aug-17/EA_Seasonal_Monitor_Aug-17 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/EA_Seasonal_Monitor_Aug-17/EA_Seasonal_Monitor_Aug-17 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/Enhancing_Food_Security_in_South_Sudan_Nov-15/Enhancing_Food_Security_in_South_Sudan_Nov-15 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/Enhancing_Food_Security_in_South_Sudan_Nov-15/Enhancing_Food_Security_in_South_Sudan_Nov-15 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/Enhancing_Food_Security_in_South_Sudan_Nov-15/Enhancing_Food_Security_in_South_Sudan_Nov-15 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/Enhancing_Food_Security_in_South_Sudan_Nov-15/Enhancing_Food_Security_in_South_Sudan_Nov-15 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/Ethiopia_Food_Security_Outlook_1-Feb-17/Ethiopia_Food_Security_Outlook_1-Feb-17 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/Ethiopia_Food_Security_Outlook_1-Feb-17/Ethiopia_Food_Security_Outlook_1-Feb-17 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/Ethiopia_Food_Security_Outlook_1-Feb-17/Ethiopia_Food_Security_Outlook_1-Feb-17 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/Ethiopia_Food_Security_Outlook_1-Feb-17/Ethiopia_Food_Security_Outlook_1-Feb-17 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/FAO_GIEWS_South_Sudan_Country_Brief_Sep-17/FAO_GIEWS_South_Sudan_Country_Brief_Sep-17 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/FAO_GIEWS_South_Sudan_Country_Brief_Sep-17/FAO_GIEWS_South_Sudan_Country_Brief_Sep-17 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/FAO_GIEWS_South_Sudan_Country_Brief_Sep-17/FAO_GIEWS_South_Sudan_Country_Brief_Sep-17 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/FAO_GIEWS_South_Sudan_Country_Brief_Sep-17/FAO_GIEWS_South_Sudan_Country_Brief_Sep-17 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/FEWS_NET_South_Sudan_Famine_Risk_Alert_Jan-17/FEWS_NET_South_Sudan_Famine_Risk_Alert_Jan-17 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/FEWS_NET_South_Sudan_Famine_Risk_Alert_Jan-17/FEWS_NET_South_Sudan_Famine_Risk_Alert_Jan-17 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/FEWS_NET_South_Sudan_Famine_Risk_Alert_Jan-17/FEWS_NET_South_Sudan_Famine_Risk_Alert_Jan-17 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/FEWS_NET_South_Sudan_Famine_Risk_Alert_Jan-17/FEWS_NET_South_Sudan_Famine_Risk_Alert_Jan-17 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/FEWS_NET_South_Sudan_Outlook_Jan-18/FEWS_NET_South_Sudan_Outlook_Jan-18 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/FEWS_NET_South_Sudan_Outlook_Jan-18/FEWS_NET_South_Sudan_Outlook_Jan-18 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/FEWS_NET_South_Sudan_Outlook_Jan-18/FEWS_NET_South_Sudan_Outlook_Jan-18 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/FEWS_NET_South_Sudan_Outlook_Jan-18/FEWS_NET_South_Sudan_Outlook_Jan-18 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/FFP_Fact_Sheet_South_Sudan_Jan-18/FFP_Fact_Sheet_South_Sudan_Jan-18 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/FFP_Fact_Sheet_South_Sudan_Jan-18/FFP_Fact_Sheet_South_Sudan_Jan-18 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/FFP_Fact_Sheet_South_Sudan_Jan-18/FFP_Fact_Sheet_South_Sudan_Jan-18 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/FFP_Fact_Sheet_South_Sudan_Jan-18/FFP_Fact_Sheet_South_Sudan_Jan-18 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/Floods_Displace_Hundreds_In_War-torn_In_South_Sudan_Sep-17/Floods_Displace_Hundreds_In_War-torn_In_South_Sudan_Sep-17 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/Floods_Displace_Hundreds_In_War-torn_In_South_Sudan_Sep-17/Floods_Displace_Hundreds_In_War-torn_In_South_Sudan_Sep-17 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/Floods_Displace_Hundreds_In_War-torn_In_South_Sudan_Sep-17/Floods_Displace_Hundreds_In_War-torn_In_South_Sudan_Sep-17 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/Floods_Displace_Hundreds_In_War-torn_In_South_Sudan_Sep-17/Floods_Displace_Hundreds_In_War-torn_In_South_Sudan_Sep-17 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/Food_Assistance_Outlook_Brief_1-Jan-18/Food_Assistance_Outlook_Brief_1-Jan-18 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/Food_Assistance_Outlook_Brief_1-Jan-18/Food_Assistance_Outlook_Brief_1-Jan-18 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/Food_Assistance_Outlook_Brief_1-Jan-18/Food_Assistance_Outlook_Brief_1-Jan-18 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/Food_Assistance_Outlook_Brief_1-Jan-18/Food_Assistance_Outlook_Brief_1-Jan-18 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/Price_Watch_28-Feb-18/Price_Watch_28-Feb-18 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/Price_Watch_28-Feb-18/Price_Watch_28-Feb-18 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/Price_Watch_28-Feb-18/Price_Watch_28-Feb-18 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/Price_Watch_28-Feb-18/Price_Watch_28-Feb-18 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/South_Sudan_Humanitarian_Response_Plan_Jan-18/South_Sudan_Humanitarian_Response_Plan_Jan-18 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/South_Sudan_Humanitarian_Response_Plan_Jan-18/South_Sudan_Humanitarian_Response_Plan_Jan-18 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/South_Sudan_Humanitarian_Response_Plan_Jan-18/South_Sudan_Humanitarian_Response_Plan_Jan-18 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/South_Sudan_Humanitarian_Response_Plan_Jan-18/South_Sudan_Humanitarian_Response_Plan_Jan-18 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/South_Sudanese_Risk_Facing_Famine_Jan-18/South_Sudanese_Risk_Facing_Famine_Jan-18 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/South_Sudanese_Risk_Facing_Famine_Jan-18/South_Sudanese_Risk_Facing_Famine_Jan-18 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/South_Sudanese_Risk_Facing_Famine_Jan-18/South_Sudanese_Risk_Facing_Famine_Jan-18 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/South_Sudanese_Risk_Facing_Famine_Jan-18/South_Sudanese_Risk_Facing_Famine_Jan-18 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/TECHNICAL_BRIEF_(RE)ASSESSING_THE_Oct-14/TECHNICAL_BRIEF_(RE)ASSESSING_THE_Oct-14 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/TECHNICAL_BRIEF_(RE)ASSESSING_THE_Oct-14/TECHNICAL_BRIEF_(RE)ASSESSING_THE_Oct-14 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/TECHNICAL_BRIEF_(RE)ASSESSING_THE_Oct-14/TECHNICAL_BRIEF_(RE)ASSESSING_THE_Oct-14 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/TECHNICAL_BRIEF_(RE)ASSESSING_THE_Oct-14/TECHNICAL_BRIEF_(RE)ASSESSING_THE_Oct-14 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/UNICEF_ETHIOPIA_HUMANITARIAN_SITUATION_REPORT_Apr-17/UNICEF_ETHIOPIA_HUMANITARIAN_SITUATION_REPORT_Apr-17 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/UNICEF_ETHIOPIA_HUMANITARIAN_SITUATION_REPORT_Apr-17/UNICEF_ETHIOPIA_HUMANITARIAN_SITUATION_REPORT_Apr-17 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/UNICEF_ETHIOPIA_HUMANITARIAN_SITUATION_REPORT_Apr-17/UNICEF_ETHIOPIA_HUMANITARIAN_SITUATION_REPORT_Apr-17 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/UNICEF_ETHIOPIA_HUMANITARIAN_SITUATION_REPORT_Apr-17/UNICEF_ETHIOPIA_HUMANITARIAN_SITUATION_REPORT_Apr-17 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/WFP_Ethiopia_Drought_Emergency_Situation_Report_5_Jul-17/WFP_Ethiopia_Drought_Emergency_Situation_Report_5_Jul-17 b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/WFP_Ethiopia_Drought_Emergency_Situation_Report_5_Jul-17/WFP_Ethiopia_Drought_Emergency_Situation_Report_5_Jul-17 similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/WFP_Ethiopia_Drought_Emergency_Situation_Report_5_Jul-17/WFP_Ethiopia_Drought_Emergency_Situation_Report_5_Jul-17 rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/WFP_Ethiopia_Drought_Emergency_Situation_Report_5_Jul-17/WFP_Ethiopia_Drought_Emergency_Situation_Report_5_Jul-17 diff --git a/library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/WorldModelersDatesRangesTimex.csv b/library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/WorldModelersDatesRangesTimex.csv similarity index 100% rename from library/src/main/resources/org/clulab/numeric/TimeNormEvalSet/WorldModelersDatesRangesTimex.csv rename to library/src/test/resources/org/clulab/numeric/TimeNormEvalSet/WorldModelersDatesRangesTimex.csv diff --git a/library/src/test/scala-2.11_2.12/org/clulab/utils/TestHash.scala b/library/src/test/scala-2.11_2.12/org/clulab/utils/TestHash.scala index 54ce33916..85125c04b 100644 --- a/library/src/test/scala-2.11_2.12/org/clulab/utils/TestHash.scala +++ b/library/src/test/scala-2.11_2.12/org/clulab/utils/TestHash.scala @@ -16,7 +16,7 @@ class TestHash extends Test { LexiconNER(kbs, caseInsensitiveMatchings, None) } - val processor = new BalaurProcessor(optionalNER = Some(customLexiconNer)) + val processor = new BalaurProcessor(lexiconNerOpt = Some(customLexiconNer)) val extractorEngine = { val rules = FileUtils.getTextFromResource("/org/clulab/odinstarter/main.yml") diff --git a/library/src/test/scala-2.13/org/clulab/utils/TestHash.scala b/library/src/test/scala-2.13/org/clulab/utils/TestHash.scala index 857f10727..88e2b0726 100644 --- a/library/src/test/scala-2.13/org/clulab/utils/TestHash.scala +++ b/library/src/test/scala-2.13/org/clulab/utils/TestHash.scala @@ -16,7 +16,7 @@ class TestHash extends Test { LexiconNER(kbs, caseInsensitiveMatchings, None) } - val processor = new BalaurProcessor(optionalNER = Some(customLexiconNer)) + val processor = new BalaurProcessor(lexiconNerOpt = Some(customLexiconNer)) val extractorEngine = { val rules = FileUtils.getTextFromResource("/org/clulab/odinstarter/main.yml") @@ -34,7 +34,8 @@ class TestHash extends Test { behavior of "Hash" it should "compute the expected equivalence hash for a Document" in { - val expectedHash = 1145238653 + val expectedHash = -1029127286 +// val expectedHash = 1145238653 val actualHash = document.equivalenceHash actualHash should be (expectedHash) @@ -56,7 +57,8 @@ class TestHash extends Test { } it should "compute the expected equivalence hashes for Mentions" in { - val expectedHashes = Array(1317064233, 418554464, 269168883, 1021871359, 1657321605) + val expectedHashes = Array(-674187334, 1183699787, 391766831, -495035159, -2089326276) +// val expectedHashes = Array(1317064233, 418554464, 269168883, 1021871359, 1657321605) val actualHashes = allMentions.map(getEquivalenceHash) actualHashes should be (expectedHashes) diff --git a/library/src/test/scala-3/org/clulab/utils/TestHash.scala b/library/src/test/scala-3/org/clulab/utils/TestHash.scala index c1dcf17a8..9186e9ae6 100644 --- a/library/src/test/scala-3/org/clulab/utils/TestHash.scala +++ b/library/src/test/scala-3/org/clulab/utils/TestHash.scala @@ -17,7 +17,7 @@ class TestHash extends Test { LexiconNER(kbs, caseInsensitiveMatchings, None) } - val processor = new BalaurProcessor(optionalNER = Some(customLexiconNer)) + val processor = new BalaurProcessor(lexiconNerOpt = Some(customLexiconNer)) val extractorEngine = { val rules = FileUtils.getTextFromResource("/org/clulab/odinstarter/main.yml") @@ -35,7 +35,8 @@ class TestHash extends Test { behavior of "Hash" it should "compute the expected equivalence hash for a Document" in { - val expectedHash = 1145238653 + val expectedHash = -1029127286 +// val expectedHash = 1145238653 val actualHash = document.equivalenceHash actualHash should be (expectedHash) @@ -57,7 +58,8 @@ class TestHash extends Test { } it should "compute the expected equivalence hashes for Mentions" in { - val expectedHashes = Array(1317064233, 418554464, 269168883, 1021871359, 1657321605) + val expectedHashes = Array(-674187334, 1183699787, 391766831, -495035159, -2089326276) +// val expectedHashes = Array(1317064233, 418554464, 269168883, 1021871359, 1657321605) val actualHashes = allMentions.map(getEquivalenceHash) actualHashes should be (expectedHashes) diff --git a/library/src/test/scala/org/clulab/numeric/TestEvalTimeNorm.scala b/library/src/test/scala/org/clulab/numeric/TestEvalTimeNorm.scala index bc22534cd..b5575b1b3 100644 --- a/library/src/test/scala/org/clulab/numeric/TestEvalTimeNorm.scala +++ b/library/src/test/scala/org/clulab/numeric/TestEvalTimeNorm.scala @@ -8,12 +8,13 @@ class TestEvalTimeNorm extends Test { behavior of "temporal parser" it should "not degrade in performance" in { + val timeNormEvalDir = "/org/clulab/numeric/TimeNormEvalSet" + val testFile = "WorldModelersDatesRangesTimex.csv" + val seasonPath = "/org/clulab/numeric/custom/SEASON.tsv" val expectedFscore = 0.85 - val proc = new BalaurProcessor(seasonPathOpt = Some("/org/clulab/numeric/custom/SEASON.tsv")) - val ner = NumericEntityRecognizer(seasonPath = "/org/clulab/numeric/custom/SEASON.tsv") - val actualFscore = EvalTimeNorm.test(proc, ner) + val proc = new BalaurProcessor(seasonPathOpt = Some(seasonPath)) + val actualFscore = EvalTimeNorm.run(proc, timeNormEvalDir, testFile) + actualFscore should be >= expectedFscore } - } - diff --git a/library/src/test/scala/org/clulab/numeric/TestNumericEntityRecognition.scala b/library/src/test/scala/org/clulab/numeric/TestNumericEntityRecognition.scala index 2a9214736..e476f1d43 100644 --- a/library/src/test/scala/org/clulab/numeric/TestNumericEntityRecognition.scala +++ b/library/src/test/scala/org/clulab/numeric/TestNumericEntityRecognition.scala @@ -15,7 +15,7 @@ class TestNumericEntityRecognition extends Test { class HabitusTokenizer(tokenizer: Tokenizer) extends Tokenizer(tokenizer.lexer, tokenizer.steps, tokenizer.sentenceSplitter) { // TODO: Make sure en dash is preserved in raw somehow! - override def tokenize(text: String, sentenceSplit: Boolean = true): Array[Sentence] = { + override def tokenize(text: String, sentenceSplit: Boolean = true, characterOffset: Int): Seq[Sentence] = { // Cheat and swap out some en dashes if necessary. val habitusText = if (text.contains(HabitusTokenizer.endash)) @@ -23,7 +23,7 @@ class TestNumericEntityRecognition extends Test { else text - tokenizer.tokenize(habitusText, sentenceSplit) + tokenizer.tokenize(habitusText, sentenceSplit, characterOffset) } } @@ -653,10 +653,10 @@ class TestNumericEntityRecognition extends Test { } /** Runs the actual numeric entity recognizer */ - def numericParse(sentence: String): (Array[String], Array[String], Array[String]) = { + def numericParse(sentence: String): (Seq[String], Seq[String], Seq[String]) = { val doc = proc.annotate(sentence) val mentions = ner.extractFrom(doc) - setLabelsAndNorms(doc, mentions) + NumericUtils.mkLabelsAndNorms(doc, mentions) // assume 1 sentence per doc val sent = doc.sentences.head diff --git a/library/src/test/scala/org/clulab/numeric/TestSeasonNormalizer.scala b/library/src/test/scala/org/clulab/numeric/TestSeasonNormalizer.scala index 2bad85f6e..423bd3eb7 100644 --- a/library/src/test/scala/org/clulab/numeric/TestSeasonNormalizer.scala +++ b/library/src/test/scala/org/clulab/numeric/TestSeasonNormalizer.scala @@ -13,12 +13,12 @@ class TestSeasonNormalizer extends Test { val fallDateRange = "2017-09-22 -- 2017-12-21" val seasonDateRange = "2017-06-XX -- 2017-10-XX" - def mkEntitiesAndNorms(processor: BalaurProcessor, text: String): (Array[String], Array[String]) = { + def mkEntitiesAndNorms(processor: BalaurProcessor, text: String): (Seq[String], Seq[String]) = { val document = processor.annotate(text) - val mentions = processor.extractNumericEntityMentions(document) + val mentions = processor.numericEntityRecognizerOpt.get.extractFrom(document) - setLabelsAndNorms(document, mentions) - (document.sentences.head.entities.get, document.sentences.head.norms.get) + val (entities, norms) = NumericUtils.mkLabelsAndNorms(document, mentions) + (entities.head, norms.head) } behavior of "Default seasonal BalaurProcessor" diff --git a/library/src/test/scala/org/clulab/odin/TestNumericPatterns.scala b/library/src/test/scala/org/clulab/odin/TestNumericPatterns.scala index 297346984..b3b477e18 100644 --- a/library/src/test/scala/org/clulab/odin/TestNumericPatterns.scala +++ b/library/src/test/scala/org/clulab/odin/TestNumericPatterns.scala @@ -9,12 +9,12 @@ class TestNumericPatterns extends Test { val text = "blah" val doc = Document( - Array( + Seq( Sentence( - Array("blah"), - Array(0), - Array(4), - Array("blah") + Seq("blah"), + Seq(0), + Seq(4), + Seq("blah") ) ) ) diff --git a/library/src/test/scala/org/clulab/odin/TestTokenPattern.scala b/library/src/test/scala/org/clulab/odin/TestTokenPattern.scala index 10738826d..3300b791e 100644 --- a/library/src/test/scala/org/clulab/odin/TestTokenPattern.scala +++ b/library/src/test/scala/org/clulab/odin/TestTokenPattern.scala @@ -61,13 +61,13 @@ class TestTokenPattern extends Test { } val text4 = "a b c d e f g h i c" - val tokens = text4.split(" ") + val tokens = text4.split(" ").toSeq val doc = Document( - Array( + Seq( Sentence( tokens, - Array(0, 2, 4, 6, 8, 10, 12, 14, 16, 18), - Array(1, 3, 5, 7, 9, 11, 13, 15, 17, 19), + Seq(0, 2, 4, 6, 8, 10, 12, 14, 16, 18), + Seq(1, 3, 5, 7, 9, 11, 13, 15, 17, 19), tokens ) ) @@ -614,11 +614,11 @@ class TestTokenPattern extends Test { val text8 = "x a a b a b a b a b c d" val doc8 = Document( - Array( + Seq( Sentence( - text8.split(" "), - Array(0, 2, 4, 6, 8, 10, 12, 14, 16, 18), - Array(1, 3, 5, 7, 9, 11, 13, 15, 17, 19) + text8.split(" ").toSeq, + Seq(0, 2, 4, 6, 8, 10, 12, 14, 16, 18), + Seq(1, 3, 5, 7, 9, 11, 13, 15, 17, 19) ) ) ) diff --git a/library/src/test/scala/org/clulab/processors/CluTest.scala b/library/src/test/scala/org/clulab/processors/CluTest.scala index 7b7d323e5..025e71413 100644 --- a/library/src/test/scala/org/clulab/processors/CluTest.scala +++ b/library/src/test/scala/org/clulab/processors/CluTest.scala @@ -29,7 +29,7 @@ class CluTest extends Test with BeforeAndAfterAll { ) val lexiconNer = LexiconNER(kbs, Seq(false), useLemmasForMatching = false) // case sensitive match on this KB - new BalaurProcessor(optionalNER = Some(lexiconNer)) + new BalaurProcessor(lexiconNerOpt = Some(lexiconNer)) } def stop(): Unit = { diff --git a/library/src/test/scala/org/clulab/processors/TestHashTrie.scala b/library/src/test/scala/org/clulab/processors/TestHashTrie.scala index d304713b7..4ec8ee171 100644 --- a/library/src/test/scala/org/clulab/processors/TestHashTrie.scala +++ b/library/src/test/scala/org/clulab/processors/TestHashTrie.scala @@ -19,7 +19,7 @@ class TestHashTrie extends Test { //println("TRIE:\n" + trie) - val tokens = Array("a", "a", "b", "d", "a", "b", "d", "b", "b", "b") + val tokens = Seq("a", "a", "b", "d", "a", "b", "d", "b", "b", "b") val labels = trie.find(tokens, "O") //println("TOKENS: " + tokens.mkString(" ")) //println("LABELS: " + labels.mkString(" ")) @@ -44,7 +44,7 @@ class TestHashTrie extends Test { trie.add(Array("this", "is", "c", "test")) trie.add(Array("this", "is", "b", "test")) - val labels = trie.find(Array("this", "is", "c", "test"), "o") + val labels = trie.find(Seq("this", "is", "c", "test"), "o") sameLabels(Array("B-hello", "I-hello", "I-hello", "I-hello"), labels) } @@ -55,7 +55,7 @@ class TestHashTrie extends Test { trie.add(Array("this", "is", "c", "test")) trie.add(Array("this", "is", "d", "test")) - val labels = trie.find(Array("this", "is", "b", "test"), "o") + val labels = trie.find(Seq("this", "is", "b", "test"), "o") sameLabels(Array("o", "o", "o", "o"), labels) } diff --git a/library/src/test/scala/org/clulab/processors/TestLexiconNER.scala b/library/src/test/scala/org/clulab/processors/TestLexiconNER.scala index 4c2fa4c37..48115479c 100644 --- a/library/src/test/scala/org/clulab/processors/TestLexiconNER.scala +++ b/library/src/test/scala/org/clulab/processors/TestLexiconNER.scala @@ -24,8 +24,8 @@ import scala.util.Using class TestLexiconNER extends CluTest { def mkSentence(text: String): Sentence = { - val doc = proc.mkDocument(text) - proc.annotate(doc) + val simpleDoc = proc.mkDocument(text) + val doc = proc.annotate(simpleDoc) doc.sentences.head } diff --git a/library/src/test/scala/org/clulab/processors/TestProcessor.scala b/library/src/test/scala/org/clulab/processors/TestProcessor.scala index 2f57e439f..e6f1e0d1b 100644 --- a/library/src/test/scala/org/clulab/processors/TestProcessor.scala +++ b/library/src/test/scala/org/clulab/processors/TestProcessor.scala @@ -9,7 +9,6 @@ class TestProcessor extends CluTest { "Processor" should "tokenize raw text correctly" in { val doc = proc.mkDocument("John Doe went to China. There, he visited Beijing.") - doc.clear() doc.sentences(0).words(0) should be ("John") doc.sentences(0).words(1) should be ("Doe") @@ -40,8 +39,8 @@ class TestProcessor extends CluTest { } it should "POS tag correctly" in { - val doc = proc.mkDocument("John Doe went to China. There, he visited Beijing.") - proc.annotate(doc) + val simpleDoc = proc.mkDocument("John Doe went to China. There, he visited Beijing.") + val doc = proc.annotate(simpleDoc) doc.sentences(0).tags.get(0) should be ("NNP") doc.sentences(0).tags.get(1) should be ("NNP") @@ -59,17 +58,16 @@ class TestProcessor extends CluTest { } it should "POS tag parentheses correctly" in { - val doc = proc.mkDocument("This is a test (of parentheses).") - proc.annotate(doc) + val simpleDoc = proc.mkDocument("This is a test (of parentheses).") + val doc = proc.annotate(simpleDoc) doc.sentences(0).tags.get(4) should be ("-LRB-") doc.sentences(0).tags.get(7) should be ("-RRB-") } it should "recognize syntactic chunks correctly" in { - val doc = proc.mkDocument("He reckons the current account deficit will narrow to only 1.8 billion.") - proc.annotate(doc) - doc.clear() + val simpleDoc = proc.mkDocument("He reckons the current account deficit will narrow to only 1.8 billion.") + val doc = proc.annotate(simpleDoc) doc.sentences(0).chunks.get(0) should be ("B-NP") doc.sentences(0).chunks.get(1) should be ("B-VP") @@ -86,9 +84,8 @@ class TestProcessor extends CluTest { } it should "lemmatize text correctly" in { - val doc = proc.mkDocument("John Doe went to the shops.") - proc.annotate(doc) - doc.clear() + val simpleDoc = proc.mkDocument("John Doe went to the shops.") + val doc = proc.annotate(simpleDoc) doc.sentences(0).lemmas.get(0) should be ("john") doc.sentences(0).lemmas.get(2) should be ("go") @@ -112,40 +109,44 @@ class TestProcessor extends CluTest { } it should "parse MWEs correctly" in { - var sent = "Foods such as icecream are tasty." - var doc = proc.mkDocument(sent) - println(s"WORDS: ${doc.sentences.head.words.mkString(", ")}") - - proc.annotate(doc) - println(s"Enhanced universal dependencies for sentence: $sent") - println(doc.sentences.head.universalEnhancedDependencies.get) - - doc.sentences.head.universalEnhancedDependencies.get.hasEdge(0, 3, "nmod_such_as") should be (true) - doc.sentences.head.universalEnhancedDependencies.get.hasEdge(0, 3, "nmod") should be (false) - - sent = "There was famine due to drought." - doc = proc.mkDocument(sent) - println(s"WORDS: ${doc.sentences.head.words.mkString(", ")}") - - proc.annotate(doc) - println(s"Enhanced universal dependencies for sentence: $sent") - println(doc.sentences.head.universalEnhancedDependencies.get) - - doc.sentences.head.universalEnhancedDependencies.get.hasEdge(2, 5, "nmod_due_to") should be (true) - doc.sentences.head.universalEnhancedDependencies.get.hasEdge(2, 3, "amod") should be (false) - doc.sentences.head.universalEnhancedDependencies.get.hasEdge(2, 5, "nmod") should be (false) - - sent = "They ate cake due to hunger." - doc = proc.mkDocument(sent) - println(s"WORDS: ${doc.sentences.head.words.mkString(", ")}") - - proc.annotate(doc) - println(s"Enhanced universal dependencies for sentence: $sent") - println(doc.sentences.head.universalEnhancedDependencies.get) - - doc.sentences.head.universalEnhancedDependencies.get.hasEdge(1, 5, "nmod_due_to") should be (true) - doc.sentences.head.universalEnhancedDependencies.get.hasEdge(1, 3, "amod") should be (false) - doc.sentences.head.universalEnhancedDependencies.get.hasEdge(1, 5, "nmod") should be (false) + { + val sent = "Foods such as icecream are tasty." + val simpleDoc = proc.mkDocument(sent) + println(s"WORDS: ${simpleDoc.sentences.head.words.mkString(", ")}") + + val doc = proc.annotate(simpleDoc) + println(s"Enhanced universal dependencies for sentence: $sent") + println(doc.sentences.head.universalEnhancedDependencies.get) + + doc.sentences.head.universalEnhancedDependencies.get.hasEdge(0, 3, "nmod_such_as") should be(true) + doc.sentences.head.universalEnhancedDependencies.get.hasEdge(0, 3, "nmod") should be(false) + } + { + val sent = "There was famine due to drought." + val simpleDoc = proc.mkDocument(sent) + println(s"WORDS: ${simpleDoc.sentences.head.words.mkString(", ")}") + + val doc = proc.annotate(simpleDoc) + println(s"Enhanced universal dependencies for sentence: $sent") + println(doc.sentences.head.universalEnhancedDependencies.get) + + doc.sentences.head.universalEnhancedDependencies.get.hasEdge(2, 5, "nmod_due_to") should be(true) + doc.sentences.head.universalEnhancedDependencies.get.hasEdge(2, 3, "amod") should be(false) + doc.sentences.head.universalEnhancedDependencies.get.hasEdge(2, 5, "nmod") should be(false) + } + { + val sent = "They ate cake due to hunger." + val simpleDoc = proc.mkDocument(sent) + println(s"WORDS: ${simpleDoc.sentences.head.words.mkString(", ")}") + + val doc = proc.annotate(simpleDoc) + println(s"Enhanced universal dependencies for sentence: $sent") + println(doc.sentences.head.universalEnhancedDependencies.get) + + doc.sentences.head.universalEnhancedDependencies.get.hasEdge(1, 5, "nmod_due_to") should be(true) + doc.sentences.head.universalEnhancedDependencies.get.hasEdge(1, 3, "amod") should be(false) + doc.sentences.head.universalEnhancedDependencies.get.hasEdge(1, 5, "nmod") should be(false) + } } it should "parse incomplete sentence without crashing" in { diff --git a/library/src/test/scala/org/clulab/processors/TestTokenizer.scala b/library/src/test/scala/org/clulab/processors/TestTokenizer.scala index c4d67af56..afd2b594d 100644 --- a/library/src/test/scala/org/clulab/processors/TestTokenizer.scala +++ b/library/src/test/scala/org/clulab/processors/TestTokenizer.scala @@ -223,7 +223,7 @@ class TestTokenizer extends Test { } } - def tok(s:String):Array[Sentence] = { + def tok(s: String): Seq[Sentence] = { println(s"Tokenizing text: $s") val t = new OpenDomainEnglishTokenizer(None) val sents = t.tokenize(s) diff --git a/library/src/test/scala/org/clulab/serialization/json/TestJSONSerializer.scala b/library/src/test/scala/org/clulab/serialization/json/TestJSONSerializer.scala index 5acf466d4..ceabd13f3 100644 --- a/library/src/test/scala/org/clulab/serialization/json/TestJSONSerializer.scala +++ b/library/src/test/scala/org/clulab/serialization/json/TestJSONSerializer.scala @@ -24,8 +24,8 @@ class TestJSONSerializer extends Test { "A Document with an ID" should "produce json with an \"id\" field" in { - val d = jsonStringToDocument(""" {"sentences":[{"raw":["Gonzo","married","Camilla","."], "words":["Gonzo","married","Camilla","."],"startOffsets":[0,6,14,21],"endOffsets":[5,13,21,22],"tags":["NNP","VBD","NNP","."],"lemmas":["Gonzo","marry","Camilla","."],"entities":["O","O","PERSON","O"],"norms":["O","O","O","O"],"chunks":["B-NP","B-VP","B-NP","O"],"graphs":{"stanford-basic":{"edges":[{"source":1,"destination":0,"relation":"nsubj"},{"source":1,"destination":2,"relation":"dobj"},{"source":1,"destination":3,"relation":"punct"}],"roots":[1]},"stanford-collapsed":{"edges":[{"source":1,"destination":0,"relation":"nsubj"},{"source":1,"destination":2,"relation":"dobj"},{"source":1,"destination":3,"relation":"punct"}],"roots":[1]}}}]} """) - d.id = Some("this-is-an-id") + val id = "this-is-an-id" + val d = jsonStringToDocument(s""" {"id":"$id","sentences":[{"raw":["Gonzo","married","Camilla","."], "words":["Gonzo","married","Camilla","."],"startOffsets":[0,6,14,21],"endOffsets":[5,13,21,22],"tags":["NNP","VBD","NNP","."],"lemmas":["Gonzo","marry","Camilla","."],"entities":["O","O","PERSON","O"],"norms":["O","O","O","O"],"chunks":["B-NP","B-VP","B-NP","O"],"graphs":{"stanford-basic":{"edges":[{"source":1,"destination":0,"relation":"nsubj"},{"source":1,"destination":2,"relation":"dobj"},{"source":1,"destination":3,"relation":"punct"}],"roots":[1]},"stanford-collapsed":{"edges":[{"source":1,"destination":0,"relation":"nsubj"},{"source":1,"destination":2,"relation":"dobj"},{"source":1,"destination":3,"relation":"punct"}],"roots":[1]}}}]} """) (d.jsonAST \ "id") should equal (JString("this-is-an-id")) } @@ -35,8 +35,7 @@ class TestJSONSerializer extends Test { } "A Document with text" should "produce json with a \"text\" field" in { - val d = jsonStringToDocument(""" {"sentences":[{"raw":["Gonzo","married","Camilla","."], "words":["Gonzo","married","Camilla","."],"startOffsets":[0,6,14,21],"endOffsets":[5,13,21,22],"tags":["NNP","VBD","NNP","."],"lemmas":["Gonzo","marry","Camilla","."],"entities":["O","O","PERSON","O"],"norms":["O","O","O","O"],"chunks":["B-NP","B-VP","B-NP","O"],"graphs":{"stanford-basic":{"edges":[{"source":1,"destination":0,"relation":"nsubj"},{"source":1,"destination":2,"relation":"dobj"},{"source":1,"destination":3,"relation":"punct"}],"roots":[1]},"stanford-collapsed":{"edges":[{"source":1,"destination":0,"relation":"nsubj"},{"source":1,"destination":2,"relation":"dobj"},{"source":1,"destination":3,"relation":"punct"}],"roots":[1]}}}]} """) - d.text = Some(text) + val d = jsonStringToDocument(s""" {"text":"$text","sentences":[{"raw":["Gonzo","married","Camilla","."], "words":["Gonzo","married","Camilla","."],"startOffsets":[0,6,14,21],"endOffsets":[5,13,21,22],"tags":["NNP","VBD","NNP","."],"lemmas":["Gonzo","marry","Camilla","."],"entities":["O","O","PERSON","O"],"norms":["O","O","O","O"],"chunks":["B-NP","B-VP","B-NP","O"],"graphs":{"stanford-basic":{"edges":[{"source":1,"destination":0,"relation":"nsubj"},{"source":1,"destination":2,"relation":"dobj"},{"source":1,"destination":3,"relation":"punct"}],"roots":[1]},"stanford-collapsed":{"edges":[{"source":1,"destination":0,"relation":"nsubj"},{"source":1,"destination":2,"relation":"dobj"},{"source":1,"destination":3,"relation":"punct"}],"roots":[1]}}}]} """) (d.jsonAST \ "text") should equal (JString(text)) } @@ -61,11 +60,11 @@ class TestJSONSerializer extends Test { class Scratch(var document: Document) extends JSONSerialization { def jsonAST: JValue = document.jsonAST } - - doc.text = Some("This is a test") // Original failing test requires text + + val docWithText = doc.copy(sentences = doc.sentences, text = Some("This is a test")) val documentSerializer = new DocumentSerializer() - val expectedDocAsJSON = new Scratch(doc).json() - val docSaved = documentSerializer.save(doc, keepText = true) + val expectedDocAsJSON = new Scratch(docWithText).json() + val docSaved = documentSerializer.save(docWithText, keepText = true) val docLoaded = documentSerializer.load(docSaved) val actualDocAsJSON = new Scratch(docLoaded).json() diff --git a/library/src/test/scala/org/clulab/struct/TestDocumentAttachment.scala b/library/src/test/scala/org/clulab/struct/TestDocumentAttachment.scala index b84e337a3..a820e26fa 100644 --- a/library/src/test/scala/org/clulab/struct/TestDocumentAttachment.scala +++ b/library/src/test/scala/org/clulab/struct/TestDocumentAttachment.scala @@ -1,7 +1,6 @@ package org.clulab.struct -import org.clulab.processors.Document -import org.clulab.processors.Sentence +import org.clulab.processors.{Document, DocumentAttachment, Sentence} import org.clulab.serialization.DocumentSerializer import org.clulab.serialization.json._ import org.clulab.struct.test.CaseClass @@ -124,68 +123,76 @@ class TestDocumentAttachment extends Test { // } "Document with TextNameDocumentAttachment" should "serialize as text" in { - val oldDocument = new Document(Array.empty[Sentence]) - - oldDocument.addAttachment(FIRST_KEY, new TextNameDocumentAttachment(FIRST_NAME)) - oldDocument.addAttachment(MIDDLE_KEY, new TextNameDocumentAttachment(MIDDLE_NAME)) - oldDocument.addAttachment(LAST_KEY, new TextNameDocumentAttachment(LAST_NAME)) - oldDocument.addAttachment(ALIAS_KEY, new NameDocumentAttachment(ALIAS_NAME)) + val oldAttachments = Map[String, DocumentAttachment]( + (FIRST_KEY, new TextNameDocumentAttachment(FIRST_NAME)), + (MIDDLE_KEY, new TextNameDocumentAttachment(MIDDLE_NAME)), + (LAST_KEY, new TextNameDocumentAttachment(LAST_NAME)), + (ALIAS_KEY, new NameDocumentAttachment(ALIAS_NAME)) + ) + val oldDocument = new Document(sentences = Seq.empty[Sentence], attachments = Some(oldAttachments)) val documentSerializer = new DocumentSerializer() val documentString = documentSerializer.save(oldDocument) val newDocument = documentSerializer.load(documentString) - require(newDocument.getAttachment(FIRST_KEY) == oldDocument.getAttachment(FIRST_KEY)) - require(newDocument.getAttachment(MIDDLE_KEY) == oldDocument.getAttachment(MIDDLE_KEY)) - require(newDocument.getAttachment(LAST_KEY) == oldDocument.getAttachment(LAST_KEY)) - require(newDocument.getAttachment(ALIAS_KEY).get.asInstanceOf[NameDocumentAttachment].name == - oldDocument.getAttachment(ALIAS_KEY).get.asInstanceOf[NameDocumentAttachment].name) + val newAttachments = newDocument.attachments.get + + require(newAttachments(FIRST_KEY) == oldAttachments(FIRST_KEY)) + require(newAttachments(MIDDLE_KEY) == oldAttachments(MIDDLE_KEY)) + require(newAttachments(LAST_KEY) == oldAttachments(LAST_KEY)) + require(newAttachments(ALIAS_KEY).asInstanceOf[NameDocumentAttachment].name == + oldAttachments(ALIAS_KEY).asInstanceOf[NameDocumentAttachment].name) // This one must be avoided. /*require(newDocument == oldDocument)*/ } "Document with ObjectNameDocumentAttachment" should "serialize as text" in { - val oldDocument = new Document(Array.empty[Sentence]) - - oldDocument.addAttachment(FIRST_KEY, new ObjectNameDocumentAttachment(FIRST_NAME)) - oldDocument.addAttachment(MIDDLE_KEY, new ObjectNameDocumentAttachment(MIDDLE_NAME)) - oldDocument.addAttachment(LAST_KEY, new ObjectNameDocumentAttachment(LAST_NAME)) - oldDocument.addAttachment(ALIAS_KEY, new NameDocumentAttachment(ALIAS_NAME)) + val oldAttachments = Map[String, DocumentAttachment]( + (FIRST_KEY, new ObjectNameDocumentAttachment(FIRST_NAME)), + (MIDDLE_KEY, new ObjectNameDocumentAttachment(MIDDLE_NAME)), + (LAST_KEY, new ObjectNameDocumentAttachment(LAST_NAME)), + (ALIAS_KEY, new NameDocumentAttachment(ALIAS_NAME)) + ) + val oldDocument = new Document(sentences = Seq.empty[Sentence], attachments = Some(oldAttachments)) val documentSerializer = new DocumentSerializer() // This should be a messy string. val documentString = documentSerializer.save(oldDocument) - val newDocument = documentSerializer.load(documentString) - require(newDocument.getAttachment(FIRST_KEY) == oldDocument.getAttachment(FIRST_KEY)) - require(newDocument.getAttachment(MIDDLE_KEY) == oldDocument.getAttachment(MIDDLE_KEY)) - require(newDocument.getAttachment(LAST_KEY) == oldDocument.getAttachment(LAST_KEY)) - require(newDocument.getAttachment(ALIAS_KEY).get.asInstanceOf[NameDocumentAttachment].name == - oldDocument.getAttachment(ALIAS_KEY).get.asInstanceOf[NameDocumentAttachment].name) + val newAttachments = newDocument.attachments.get + + require(newAttachments(FIRST_KEY) == oldAttachments(FIRST_KEY)) + require(newAttachments(MIDDLE_KEY) == oldAttachments(MIDDLE_KEY)) + require(newAttachments(LAST_KEY) == oldAttachments(LAST_KEY)) + require(newAttachments(ALIAS_KEY).asInstanceOf[NameDocumentAttachment].name == + oldAttachments(ALIAS_KEY).asInstanceOf[NameDocumentAttachment].name) // This one must be avoided. /*require(newDocument == oldDocument)*/ } "Document with TextNameDocumentAttachments" should "serialize as json" in { - val oldDocument = new Document(Array.empty[Sentence]) + val oldAttachments = Map[String, DocumentAttachment]( + (FIRST_KEY, new TextNameDocumentAttachment(FIRST_NAME)), + (MIDDLE_KEY, new TextNameDocumentAttachment(MIDDLE_NAME)), + (LAST_KEY, new TextNameDocumentAttachment(LAST_NAME)), + (ALIAS_KEY, new NameDocumentAttachment(ALIAS_NAME)) + ) + val oldDocument = new Document(sentences = Seq.empty[Sentence], attachments = Some(oldAttachments)) - oldDocument.addAttachment(FIRST_KEY, new TextNameDocumentAttachment(FIRST_NAME)) - oldDocument.addAttachment(MIDDLE_KEY, new TextNameDocumentAttachment(MIDDLE_NAME)) - oldDocument.addAttachment(LAST_KEY, new TextNameDocumentAttachment(LAST_NAME)) - oldDocument.addAttachment(ALIAS_KEY, new NameDocumentAttachment(ALIAS_NAME)) // This shouldn't compile. /*oldDocument.addAttachment("wrong", new NameMethodAttachment("name"))*/ val documentString = prettyJson(renderJValue(oldDocument.jsonAST)) - val newDocument: Document = JSONSerializer.toDocument(parseJson(documentString)) - newDocument.getAttachment(FIRST_KEY) should be (oldDocument.getAttachment(FIRST_KEY)) - newDocument.getAttachment(MIDDLE_KEY) should be (oldDocument.getAttachment(MIDDLE_KEY)) - newDocument.getAttachment(LAST_KEY) should be (oldDocument.getAttachment(LAST_KEY)) - newDocument.getAttachment(ALIAS_KEY).asInstanceOf[Option[NameDocumentAttachment]].get.name should be ( - oldDocument.getAttachment(ALIAS_KEY).asInstanceOf[Option[NameDocumentAttachment]].get.name + val newAttachments = newDocument.attachments.get + + newAttachments(FIRST_KEY) should be (oldAttachments(FIRST_KEY)) + newAttachments(MIDDLE_KEY) should be (oldAttachments(MIDDLE_KEY)) + newAttachments(LAST_KEY) should be (oldAttachments(LAST_KEY)) + newAttachments(ALIAS_KEY).asInstanceOf[NameDocumentAttachment].name should be ( + oldAttachments(ALIAS_KEY).asInstanceOf[NameDocumentAttachment].name ) // This one must be avoided. @@ -193,25 +200,26 @@ class TestDocumentAttachment extends Test { } "Document with ObjectNameDocumentAttachment" should "serialize as json" in { - val oldDocument = new Document(Array.empty[Sentence]) - - oldDocument.addAttachment(FIRST_KEY, new ObjectNameDocumentAttachment(FIRST_NAME)) - oldDocument.addAttachment(MIDDLE_KEY, new ObjectNameDocumentAttachment(MIDDLE_NAME)) - oldDocument.addAttachment(LAST_KEY, new ObjectNameDocumentAttachment(LAST_NAME)) - oldDocument.addAttachment(ALIAS_KEY, new NameDocumentAttachment(ALIAS_NAME)) + val oldAttachments = Map[String, DocumentAttachment]( + (FIRST_KEY, new ObjectNameDocumentAttachment(FIRST_NAME)), + (MIDDLE_KEY, new ObjectNameDocumentAttachment(MIDDLE_NAME)), + (LAST_KEY, new ObjectNameDocumentAttachment(LAST_NAME)), + (ALIAS_KEY, new NameDocumentAttachment(ALIAS_NAME)) + ) + val oldDocument = new Document(Seq.empty[Sentence], attachments = Some(oldAttachments)) // This should be a messy string. val documentString = prettyJson(renderJValue(oldDocument.jsonAST)) - val newDocument: Document = JSONSerializer.toDocument(parseJson(documentString)) - require(newDocument.getAttachment(FIRST_KEY) == oldDocument.getAttachment(FIRST_KEY)) - require(newDocument.getAttachment(MIDDLE_KEY) == oldDocument.getAttachment(MIDDLE_KEY)) - require(newDocument.getAttachment(LAST_KEY) == oldDocument.getAttachment(LAST_KEY)) - require(newDocument.getAttachment(ALIAS_KEY).get.asInstanceOf[NameDocumentAttachment].name == - oldDocument.getAttachment(ALIAS_KEY).get.asInstanceOf[NameDocumentAttachment].name) + val newAttachments = newDocument.attachments.get + + require(newAttachments(FIRST_KEY) == oldAttachments(FIRST_KEY)) + require(newAttachments(MIDDLE_KEY) == oldAttachments(MIDDLE_KEY)) + require(newAttachments(LAST_KEY) == oldAttachments(LAST_KEY)) + require(newAttachments(ALIAS_KEY).asInstanceOf[NameDocumentAttachment].name == + oldAttachments(ALIAS_KEY).asInstanceOf[NameDocumentAttachment].name) // This one must be avoided. /*require(newDocument == oldDocument)*/ } } - diff --git a/library/src/test/scala/org/clulab/utils/TestArrayView.scala b/library/src/test/scala/org/clulab/utils/TestArrayView.scala deleted file mode 100644 index 2bfbd08ff..000000000 --- a/library/src/test/scala/org/clulab/utils/TestArrayView.scala +++ /dev/null @@ -1,54 +0,0 @@ -package org.clulab.utils - -class TestArrayView extends Test { - - behavior of "ArrayView" - - it should "work with no offset" in { - val array = Array(1, 2, 3) - val arrayView = MutableArrayView(array) - - array.length should be (arrayView.length) - - arrayView.zip(array).foreach { case (arrayViewItem, arrayItem) => - arrayViewItem should be (arrayItem) - } - - arrayView(0) = 4 - arrayView(0) should be (4) - array(0) should be (4) - } - - it should "work with an offset" in { - val offset = 1 - val array = Array(1, 2, 3) - val arrayView = MutableArrayView(array, offset) - - array.length should be (arrayView.length + offset) - - arrayView.zip(array).foreach { case (arrayViewItem, arrayItem) => - arrayViewItem should be (arrayItem + offset) - } - - arrayView(0) = 4 - arrayView(0) should be (4) - array(1) should be (4) - } - - it should "work when clipped" in { - val offset = 1 - val clip = 1 - val array = Array(1, 2, 3) - val arrayView = MutableArrayView(array, offset, array.length - clip) - - array.length should be (arrayView.length + offset + clip) - - arrayView.zip(array).foreach { case (arrayViewItem, arrayItem) => - arrayViewItem should be (arrayItem + offset) - } - - arrayView(0) = 4 - arrayView(0) should be (4) - array(1) should be (4) - } -} diff --git a/library/src/test/scala/org/clulab/utils/TestFindHeads.scala b/library/src/test/scala/org/clulab/utils/TestFindHeads.scala index 13390e71e..bb9ba3823 100644 --- a/library/src/test/scala/org/clulab/utils/TestFindHeads.scala +++ b/library/src/test/scala/org/clulab/utils/TestFindHeads.scala @@ -6,13 +6,15 @@ import org.clulab.struct.{DirectedGraph, Edge, Interval} class TestFindHeads extends Test { - def newSentence(words: Array[String], directedGraph: DirectedGraph[String]): Sentence = { - val startOffsets = Array(0) // unused - val endOffsets = Array(0) // unused - val sentence = new Sentence(words, startOffsets, endOffsets, words) + def newSentence(words: Seq[String], directedGraph: DirectedGraph[String]): Sentence = { + val startOffsets = Seq(0) // unused + val endOffsets = Seq(0) // unused + val sentence = new Sentence( + words, startOffsets, endOffsets, words, + tags = Some(words), + graphs = Map(UNIVERSAL_BASIC -> directedGraph) + ) - sentence.graphs(UNIVERSAL_BASIC) = directedGraph - sentence.tags = Some(words) sentence } @@ -115,7 +117,7 @@ class TestFindHeads extends Test { val len: Int = 78 val directedGraph = DirectedGraph(edges) val tokenInterval = Interval(0, len) - val words = 1.to(len).map { index => s"word$index" }.toArray + val words = 1.to(len).map { index => s"word$index" } val sentence = newSentence(words, directedGraph) val heads = DependencyUtils.findHeadsStrict(tokenInterval, sentence) diff --git a/project/build.properties b/project/build.properties index 11956d958..75ac47aaa 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,6 +1,9 @@ +# This was last checked on 2025-06-02. # Version 1.7.2+ will cause problems when combined with the play plug-in used for the webapp! # [error] * org.scala-lang.modules:scala-xml_2.12:2.1.0 (early-semver) is selected over {1.2.0, 1.1.1} # [error] +- org.scala-lang:scala-compiler:2.12.17 (depends on 2.1.0) # [error] +- com.typesafe.sbt:sbt-native-packager:1.5.2 (scalaVersion=2.12, sbtVersion=1.0) (depends on 1.1.1) # [error] +- com.typesafe.play:twirl-api_2.12:1.5.1 (depends on 1.2.0) -sbt.version = 1.7.2 +# This error is solved by adding a VersionScheme.Always to plugins.sbt. +# up to 1.11.1 +sbt.version = 1.11.1 diff --git a/project/plugins.sbt b/project/plugins.sbt index 273ee7ce6..417c04d23 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,5 @@ +ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always + // Latest version numbers were updated on 2024 July 11. addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2-1") // up to 2.2.1 * addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3") // up to 3.9.21 * diff --git a/webapp/app/org/clulab/processors/webapp/controllers/HomeController.scala b/webapp/app/org/clulab/processors/webapp/controllers/HomeController.scala index 9f4691529..14fc5ebb8 100644 --- a/webapp/app/org/clulab/processors/webapp/controllers/HomeController.scala +++ b/webapp/app/org/clulab/processors/webapp/controllers/HomeController.scala @@ -33,7 +33,7 @@ class HomeController @Inject()(cc: ControllerComponents) extends AbstractControl val kbs = customLexiconNerConfigs.map(_.kb) val caseInsensitiveMatchings = customLexiconNerConfigs.map(_.caseInsensitiveMatching) val customLexiconNer = LexiconNER(kbs, caseInsensitiveMatchings, None) - val processor = new BalaurProcessor(optionalNER = Some(customLexiconNer)) + val processor = new BalaurProcessor(lexiconNerOpt = Some(customLexiconNer)) processor } diff --git a/webapp/app/org/clulab/processors/webapp/serialization/ParseObj.scala b/webapp/app/org/clulab/processors/webapp/serialization/ParseObj.scala index 0c9bff455..617a4303d 100644 --- a/webapp/app/org/clulab/processors/webapp/serialization/ParseObj.scala +++ b/webapp/app/org/clulab/processors/webapp/serialization/ParseObj.scala @@ -14,7 +14,7 @@ class ParseObj(doc: Document) { head + xml.Utility.escape(text) + tail } - def getTdAtOptString(option: Option[Array[String]], n: Int): String = { + def getTdAtOptString(option: Option[Seq[String]], n: Int): String = { val text = if (option.isEmpty) "" else option.get(n) @@ -22,9 +22,9 @@ class ParseObj(doc: Document) { getTd(text) } - def getTdAtString(values: Array[String], n: Int): String = getTd(values(n)) + def getTdAtString(values: Seq[String], n: Int): String = getTd(values(n)) - def getTdAtInt(values: Array[Int], n: Int): String = getTd(values(n).toString, true) + def getTdAtInt(values: Seq[Int], n: Int): String = getTd(values(n).toString, true) def edgesToString(to: Int): String = { val edges = sentence.dependencies.map(_.incomingEdges(to)).getOrElse(Array.empty) diff --git a/webapp2/build.sbt b/webapp2/build.sbt new file mode 100644 index 000000000..231b97166 --- /dev/null +++ b/webapp2/build.sbt @@ -0,0 +1,11 @@ +name := "processors-webapp2" +description := "A webapp based on cast" + +libraryDependencies ++= { + Seq( + "com.lihaoyi" %% "cask" % "0.10.2", // as of 2025-06-02 up to 0.10.2 + "com.lihaoyi" %% "scalatags" % "0.12.0", // as of 2025-06-02 up to 0.13.1 + + "org.clulab" % "processors-model" % "0.3.1" + ) +} diff --git a/webapp2/src/main/resources/brat/client/lib/head.load.min.js b/webapp2/src/main/resources/brat/client/lib/head.load.min.js new file mode 100644 index 000000000..8a561cd2d --- /dev/null +++ b/webapp2/src/main/resources/brat/client/lib/head.load.min.js @@ -0,0 +1,8 @@ +/** + Head JS The only script in your + Copyright Tero Piirainen (tipiirai) + License MIT / http://bit.ly/mit-license + Version 0.9 + + http://headjs.com +*/(function(a){var b=a.documentElement,c,d,e=[],f=[],g={},h={},i=a.createElement("script").async===true||"MozAppearance"in a.documentElement.style||window.opera;var j=window.head_conf&&head_conf.head||"head",k=window[j]=window[j]||function(){k.ready.apply(null,arguments)};var l=0,m=1,n=2,o=3;i?k.js=function(){var a=arguments,b=a[a.length-1],c=[];t(b)||(b=null),s(a,function(d,e){d!=b&&(d=r(d),c.push(d),x(d,b&&e==a.length-2?function(){u(c)&&p(b)}:null))});return k}:k.js=function(){var a=arguments,b=[].slice.call(a,1),d=b[0];if(!c){f.push(function(){k.js.apply(null,a)});return k}d?(s(b,function(a){t(a)||w(r(a))}),x(r(a[0]),t(d)?d:function(){k.js.apply(null,b)})):x(r(a[0]));return k},k.ready=function(a,b){if(a=="dom"){d?p(b):e.push(b);return k}t(a)&&(b=a,a="ALL");var c=h[a];if(c&&c.state==o||a=="ALL"&&u()&&d){p(b);return k}var f=g[a];f?f.push(b):f=g[a]=[b];return k},k.ready("dom",function(){c&&u()&&s(g.ALL,function(a){p(a)}),k.feature&&k.feature("domloaded",true)});function p(a){a._done||(a(),a._done=1)}function q(a){var b=a.split("/"),c=b[b.length-1],d=c.indexOf("?");return d!=-1?c.substring(0,d):c}function r(a){var b;if(typeof a=="object")for(var c in a)a[c]&&(b={name:c,url:a[c]});else b={name:q(a),url:a};var d=h[b.name];if(d&&d.url===b.url)return d;h[b.name]=b;return b}function s(a,b){if(a){typeof a=="object"&&(a=[].slice.call(a));for(var c=0;c=0)&&k(a,!d)}});c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&& +a.element[0].parentNode)for(var e=0;e0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a=9)&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a);return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted= +false;a.target==this._mouseDownEvent.target&&b.data(a.target,this.widgetName+".preventClickEvent",true);this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery); +;/* + * jQuery UI Position 1.8.16 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Position + */ +(function(c){c.ui=c.ui||{};var n=/left|center|right/,o=/top|center|bottom/,t=c.fn.position,u=c.fn.offset;c.fn.position=function(b){if(!b||!b.of)return t.apply(this,arguments);b=c.extend({},b);var a=c(b.of),d=a[0],g=(b.collision||"flip").split(" "),e=b.offset?b.offset.split(" "):[0,0],h,k,j;if(d.nodeType===9){h=a.width();k=a.height();j={top:0,left:0}}else if(d.setTimeout){h=a.width();k=a.height();j={top:a.scrollTop(),left:a.scrollLeft()}}else if(d.preventDefault){b.at="left top";h=k=0;j={top:b.of.pageY, +left:b.of.pageX}}else{h=a.outerWidth();k=a.outerHeight();j=a.offset()}c.each(["my","at"],function(){var f=(b[this]||"").split(" ");if(f.length===1)f=n.test(f[0])?f.concat(["center"]):o.test(f[0])?["center"].concat(f):["center","center"];f[0]=n.test(f[0])?f[0]:"center";f[1]=o.test(f[1])?f[1]:"center";b[this]=f});if(g.length===1)g[1]=g[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(b.at[0]==="right")j.left+=h;else if(b.at[0]==="center")j.left+=h/2;if(b.at[1]==="bottom")j.top+= +k;else if(b.at[1]==="center")j.top+=k/2;j.left+=e[0];j.top+=e[1];return this.each(function(){var f=c(this),l=f.outerWidth(),m=f.outerHeight(),p=parseInt(c.curCSS(this,"marginLeft",true))||0,q=parseInt(c.curCSS(this,"marginTop",true))||0,v=l+p+(parseInt(c.curCSS(this,"marginRight",true))||0),w=m+q+(parseInt(c.curCSS(this,"marginBottom",true))||0),i=c.extend({},j),r;if(b.my[0]==="right")i.left-=l;else if(b.my[0]==="center")i.left-=l/2;if(b.my[1]==="bottom")i.top-=m;else if(b.my[1]==="center")i.top-= +m/2;i.left=Math.round(i.left);i.top=Math.round(i.top);r={left:i.left-p,top:i.top-q};c.each(["left","top"],function(s,x){c.ui.position[g[s]]&&c.ui.position[g[s]][x](i,{targetWidth:h,targetHeight:k,elemWidth:l,elemHeight:m,collisionPosition:r,collisionWidth:v,collisionHeight:w,offset:e,my:b.my,at:b.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(i,{using:b.using}))})};c.ui.position={fit:{left:function(b,a){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();b.left= +d>0?b.left-d:Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();var g=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,h=-2*a.offset[0];b.left+= +a.collisionPosition.left<0?g+e+h:d>0?g+e+h:0}},top:function(b,a){if(a.at[1]!=="center"){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();var g=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,h=-2*a.offset[1];b.top+=a.collisionPosition.top<0?g+e+h:d>0?g+e+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(b,a){if(/static/.test(c.curCSS(b,"position")))b.style.position="relative";var d=c(b), +g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"left",true),10)||0;g={top:a.top-g.top+e,left:a.left-g.left+h};"using"in a?a.using.call(b,g):d.css(g)};c.fn.offset=function(b){var a=this[0];if(!a||!a.ownerDocument)return null;if(b)return this.each(function(){c.offset.setOffset(this,b)});return u.call(this)}}})(jQuery); +;/* + * jQuery UI Draggable 1.8.16 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Draggables + * + * Depends: + * jquery.ui.core.js + * jquery.ui.mouse.js + * jquery.ui.widget.js + */ +(function(d){d.widget("ui.draggable",d.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper== +"original"&&!/^(?:r|a|f)/.test(this.element.css("position")))this.element[0].style.position="relative";this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(a){var b= +this.options;if(this.helper||b.disabled||d(a.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(a);if(!this.handle)return false;if(b.iframeFix)d(b.iframeFix===true?"iframe":b.iframeFix).each(function(){d('
').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(d(this).offset()).appendTo("body")});return true},_mouseStart:function(a){var b=this.options; +this.helper=this._createHelper(a);this._cacheHelperProportions();if(d.ui.ddmanager)d.ui.ddmanager.current=this;this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}); +this.originalPosition=this.position=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);b.containment&&this._setContainment();if(this._trigger("start",a)===false){this._clear();return false}this._cacheHelperProportions();d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(a,true);d.ui.ddmanager&&d.ui.ddmanager.dragStart(this,a);return true}, +_mouseDrag:function(a,b){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");if(!b){b=this._uiHash();if(this._trigger("drag",a,b)===false){this._mouseUp({});return false}this.position=b.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);return false},_mouseStop:function(a){var b= +false;if(d.ui.ddmanager&&!this.options.dropBehaviour)b=d.ui.ddmanager.drop(this,a);if(this.dropped){b=this.dropped;this.dropped=false}if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!b||this.options.revert=="valid"&&b||this.options.revert===true||d.isFunction(this.options.revert)&&this.options.revert.call(this.element,b)){var c=this;d(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration, +10),function(){c._trigger("stop",a)!==false&&c._clear()})}else this._trigger("stop",a)!==false&&this._clear();return false},_mouseUp:function(a){this.options.iframeFix===true&&d("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});d.ui.ddmanager&&d.ui.ddmanager.dragStop(this,a);return d.ui.mouse.prototype._mouseUp.call(this,a)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(a){var b=!this.options.handle|| +!d(this.options.handle,this.element).length?true:false;d(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==a.target)b=true});return b},_createHelper:function(a){var b=this.options;a=d.isFunction(b.helper)?d(b.helper.apply(this.element[0],[a])):b.helper=="clone"?this.element.clone().removeAttr("id"):this.element;a.parents("body").length||a.appendTo(b.appendTo=="parent"?this.element[0].parentNode:b.appendTo);a[0]!=this.element[0]&&!/(fixed|absolute)/.test(a.css("position"))&& +a.css("position","absolute");return a},_adjustOffsetFromHelper:function(a){if(typeof a=="string")a=a.split(" ");if(d.isArray(a))a={left:+a[0],top:+a[1]||0};if("left"in a)this.offset.click.left=a.left+this.margins.left;if("right"in a)this.offset.click.left=this.helperProportions.width-a.right+this.margins.left;if("top"in a)this.offset.click.top=a.top+this.margins.top;if("bottom"in a)this.offset.click.top=this.helperProportions.height-a.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent= +this.helper.offsetParent();var a=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0])){a.left+=this.scrollParent.scrollLeft();a.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&d.browser.msie)a={top:0,left:0};return{top:a.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:a.left+(parseInt(this.offsetParent.css("borderLeftWidth"), +10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.element.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"), +10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var a=this.options;if(a.containment=="parent")a.containment=this.helper[0].parentNode;if(a.containment=="document"||a.containment=="window")this.containment=[a.containment=="document"?0:d(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,a.containment=="document"?0:d(window).scrollTop()-this.offset.relative.top-this.offset.parent.top, +(a.containment=="document"?0:d(window).scrollLeft())+d(a.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a.containment=="document"?0:d(window).scrollTop())+(d(a.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(a.containment)&&a.containment.constructor!=Array){a=d(a.containment);var b=a[0];if(b){a.offset();var c=d(b).css("overflow")!= +"hidden";this.containment=[(parseInt(d(b).css("borderLeftWidth"),10)||0)+(parseInt(d(b).css("paddingLeft"),10)||0),(parseInt(d(b).css("borderTopWidth"),10)||0)+(parseInt(d(b).css("paddingTop"),10)||0),(c?Math.max(b.scrollWidth,b.offsetWidth):b.offsetWidth)-(parseInt(d(b).css("borderLeftWidth"),10)||0)-(parseInt(d(b).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(c?Math.max(b.scrollHeight,b.offsetHeight):b.offsetHeight)-(parseInt(d(b).css("borderTopWidth"), +10)||0)-(parseInt(d(b).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom];this.relative_container=a}}else if(a.containment.constructor==Array)this.containment=a.containment},_convertPositionTo:function(a,b){if(!b)b=this.position;a=a=="absolute"?1:-1;var c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName);return{top:b.top+ +this.offset.relative.top*a+this.offset.parent.top*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():f?0:c.scrollTop())*a),left:b.left+this.offset.relative.left*a+this.offset.parent.left*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())*a)}},_generatePosition:function(a){var b=this.options,c=this.cssPosition=="absolute"&& +!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName),e=a.pageX,h=a.pageY;if(this.originalPosition){var g;if(this.containment){if(this.relative_container){g=this.relative_container.offset();g=[this.containment[0]+g.left,this.containment[1]+g.top,this.containment[2]+g.left,this.containment[3]+g.top]}else g=this.containment;if(a.pageX-this.offset.click.leftg[2])e=g[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>g[3])h=g[3]+this.offset.click.top}if(b.grid){h=b.grid[1]?this.originalPageY+Math.round((h-this.originalPageY)/b.grid[1])*b.grid[1]:this.originalPageY;h=g?!(h-this.offset.click.topg[3])?h:!(h-this.offset.click.topg[2])?e:!(e-this.offset.click.left=0;i--){var j=c.snapElements[i].left,l=j+c.snapElements[i].width,k=c.snapElements[i].top,m=k+c.snapElements[i].height;if(j-e=j&&f<=l||h>=j&&h<=l||fl)&&(e>= +i&&e<=k||g>=i&&g<=k||ek);default:return false}};d.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(a,b){var c=d.ui.ddmanager.droppables[a.options.scope]||[],e=b?b.type:null,g=(a.currentItem||a.element).find(":data(droppable)").andSelf(),f=0;a:for(;f').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(), +top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle= +this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=a.handles||(!e(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne", +nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all")this.handles="n,e,s,w,se,sw,ne,nw";var c=this.handles.split(",");this.handles={};for(var d=0;d');/sw|se|ne|nw/.test(f)&&g.css({zIndex:++a.zIndex});"se"==f&&g.addClass("ui-icon ui-icon-gripsmall-diagonal-se");this.handles[f]=".ui-resizable-"+f;this.element.append(g)}}this._renderAxis=function(h){h=h||this.element;for(var i in this.handles){if(this.handles[i].constructor== +String)this.handles[i]=e(this.handles[i],this.element).show();if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var j=e(this.handles[i],this.element),l=0;l=/sw|ne|nw|se|n|s/.test(i)?j.outerHeight():j.outerWidth();j=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join("");h.css(j,l);this._proportionallyResize()}e(this.handles[i])}};this._renderAxis(this.element);this._handles=e(".ui-resizable-handle",this.element).disableSelection(); +this._handles.mouseover(function(){if(!b.resizing){if(this.className)var h=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);b.axis=h&&h[1]?h[1]:"se"}});if(a.autoHide){this._handles.hide();e(this.element).addClass("ui-resizable-autohide").hover(function(){if(!a.disabled){e(this).removeClass("ui-resizable-autohide");b._handles.show()}},function(){if(!a.disabled)if(!b.resizing){e(this).addClass("ui-resizable-autohide");b._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy(); +var b=function(c){e(c).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){b(this.element);var a=this.element;a.after(this.originalElement.css({position:a.css("position"),width:a.outerWidth(),height:a.outerHeight(),top:a.css("top"),left:a.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);b(this.originalElement);return this},_mouseCapture:function(b){var a= +false;for(var c in this.handles)if(e(this.handles[c])[0]==b.target)a=true;return!this.options.disabled&&a},_mouseStart:function(b){var a=this.options,c=this.element.position(),d=this.element;this.resizing=true;this.documentScroll={top:e(document).scrollTop(),left:e(document).scrollLeft()};if(d.is(".ui-draggable")||/absolute/.test(d.css("position")))d.css({position:"absolute",top:c.top,left:c.left});e.browser.opera&&/relative/.test(d.css("position"))&&d.css({position:"relative",top:"auto",left:"auto"}); +this._renderProxy();c=m(this.helper.css("left"));var f=m(this.helper.css("top"));if(a.containment){c+=e(a.containment).scrollLeft()||0;f+=e(a.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:c,top:f};this.size=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalSize=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalPosition={left:c,top:f};this.sizeDiff= +{width:d.outerWidth()-d.width(),height:d.outerHeight()-d.height()};this.originalMousePosition={left:b.pageX,top:b.pageY};this.aspectRatio=typeof a.aspectRatio=="number"?a.aspectRatio:this.originalSize.width/this.originalSize.height||1;a=e(".ui-resizable-"+this.axis).css("cursor");e("body").css("cursor",a=="auto"?this.axis+"-resize":a);d.addClass("ui-resizable-resizing");this._propagate("start",b);return true},_mouseDrag:function(b){var a=this.helper,c=this.originalMousePosition,d=this._change[this.axis]; +if(!d)return false;c=d.apply(this,[b,b.pageX-c.left||0,b.pageY-c.top||0]);this._updateVirtualBoundaries(b.shiftKey);if(this._aspectRatio||b.shiftKey)c=this._updateRatio(c,b);c=this._respectSize(c,b);this._propagate("resize",b);a.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize();this._updateCache(c);this._trigger("resize",b,this.ui());return false}, +_mouseStop:function(b){this.resizing=false;var a=this.options,c=this;if(this._helper){var d=this._proportionallyResizeElements,f=d.length&&/textarea/i.test(d[0].nodeName);d=f&&e.ui.hasScroll(d[0],"left")?0:c.sizeDiff.height;f=f?0:c.sizeDiff.width;f={width:c.helper.width()-f,height:c.helper.height()-d};d=parseInt(c.element.css("left"),10)+(c.position.left-c.originalPosition.left)||null;var g=parseInt(c.element.css("top"),10)+(c.position.top-c.originalPosition.top)||null;a.animate||this.element.css(e.extend(f, +{top:g,left:d}));c.helper.height(c.size.height);c.helper.width(c.size.width);this._helper&&!a.animate&&this._proportionallyResize()}e("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",b);this._helper&&this.helper.remove();return false},_updateVirtualBoundaries:function(b){var a=this.options,c,d,f;a={minWidth:k(a.minWidth)?a.minWidth:0,maxWidth:k(a.maxWidth)?a.maxWidth:Infinity,minHeight:k(a.minHeight)?a.minHeight:0,maxHeight:k(a.maxHeight)?a.maxHeight: +Infinity};if(this._aspectRatio||b){b=a.minHeight*this.aspectRatio;d=a.minWidth/this.aspectRatio;c=a.maxHeight*this.aspectRatio;f=a.maxWidth/this.aspectRatio;if(b>a.minWidth)a.minWidth=b;if(d>a.minHeight)a.minHeight=d;if(cb.width,h=k(b.height)&&a.minHeight&&a.minHeight>b.height;if(g)b.width=a.minWidth;if(h)b.height=a.minHeight;if(d)b.width=a.maxWidth;if(f)b.height=a.maxHeight;var i=this.originalPosition.left+this.originalSize.width,j=this.position.top+this.size.height,l=/sw|nw|w/.test(c);c=/nw|ne|n/.test(c);if(g&&l)b.left=i-a.minWidth;if(d&&l)b.left=i-a.maxWidth;if(h&&c)b.top=j-a.minHeight;if(f&&c)b.top=j-a.maxHeight;if((a=!b.width&&!b.height)&&!b.left&&b.top)b.top=null;else if(a&&!b.top&&b.left)b.left= +null;return b},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var b=this.helper||this.element,a=0;a');var a=e.browser.msie&&e.browser.version<7,c=a?1:0;a=a?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+ +a,height:this.element.outerHeight()+a,position:"absolute",left:this.elementOffset.left-c+"px",top:this.elementOffset.top-c+"px",zIndex:++b.zIndex});this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(b,a){return{width:this.originalSize.width+a}},w:function(b,a){return{left:this.originalPosition.left+a,width:this.originalSize.width-a}},n:function(b,a,c){return{top:this.originalPosition.top+c,height:this.originalSize.height-c}},s:function(b,a,c){return{height:this.originalSize.height+ +c}},se:function(b,a,c){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[b,a,c]))},sw:function(b,a,c){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[b,a,c]))},ne:function(b,a,c){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[b,a,c]))},nw:function(b,a,c){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[b,a,c]))}},_propagate:function(b,a){e.ui.plugin.call(this,b,[a,this.ui()]); +b!="resize"&&this._trigger(b,a,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});e.extend(e.ui.resizable,{version:"1.8.16"});e.ui.plugin.add("resizable","alsoResize",{start:function(){var b=e(this).data("resizable").options,a=function(c){e(c).each(function(){var d=e(this);d.data("resizable-alsoresize",{width:parseInt(d.width(), +10),height:parseInt(d.height(),10),left:parseInt(d.css("left"),10),top:parseInt(d.css("top"),10),position:d.css("position")})})};if(typeof b.alsoResize=="object"&&!b.alsoResize.parentNode)if(b.alsoResize.length){b.alsoResize=b.alsoResize[0];a(b.alsoResize)}else e.each(b.alsoResize,function(c){a(c)});else a(b.alsoResize)},resize:function(b,a){var c=e(this).data("resizable");b=c.options;var d=c.originalSize,f=c.originalPosition,g={height:c.size.height-d.height||0,width:c.size.width-d.width||0,top:c.position.top- +f.top||0,left:c.position.left-f.left||0},h=function(i,j){e(i).each(function(){var l=e(this),q=e(this).data("resizable-alsoresize"),p={},r=j&&j.length?j:l.parents(a.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(r,function(n,o){if((n=(q[o]||0)+(g[o]||0))&&n>=0)p[o]=n||null});if(e.browser.opera&&/relative/.test(l.css("position"))){c._revertToRelativePosition=true;l.css({position:"absolute",top:"auto",left:"auto"})}l.css(p)})};typeof b.alsoResize=="object"&&!b.alsoResize.nodeType? +e.each(b.alsoResize,function(i,j){h(i,j)}):h(b.alsoResize)},stop:function(){var b=e(this).data("resizable"),a=b.options,c=function(d){e(d).each(function(){var f=e(this);f.css({position:f.data("resizable-alsoresize").position})})};if(b._revertToRelativePosition){b._revertToRelativePosition=false;typeof a.alsoResize=="object"&&!a.alsoResize.nodeType?e.each(a.alsoResize,function(d){c(d)}):c(a.alsoResize)}e(this).removeData("resizable-alsoresize")}});e.ui.plugin.add("resizable","animate",{stop:function(b){var a= +e(this).data("resizable"),c=a.options,d=a._proportionallyResizeElements,f=d.length&&/textarea/i.test(d[0].nodeName),g=f&&e.ui.hasScroll(d[0],"left")?0:a.sizeDiff.height;f={width:a.size.width-(f?0:a.sizeDiff.width),height:a.size.height-g};g=parseInt(a.element.css("left"),10)+(a.position.left-a.originalPosition.left)||null;var h=parseInt(a.element.css("top"),10)+(a.position.top-a.originalPosition.top)||null;a.element.animate(e.extend(f,h&&g?{top:h,left:g}:{}),{duration:c.animateDuration,easing:c.animateEasing, +step:function(){var i={width:parseInt(a.element.css("width"),10),height:parseInt(a.element.css("height"),10),top:parseInt(a.element.css("top"),10),left:parseInt(a.element.css("left"),10)};d&&d.length&&e(d[0]).css({width:i.width,height:i.height});a._updateCache(i);a._propagate("resize",b)}})}});e.ui.plugin.add("resizable","containment",{start:function(){var b=e(this).data("resizable"),a=b.element,c=b.options.containment;if(a=c instanceof e?c.get(0):/parent/.test(c)?a.parent().get(0):c){b.containerElement= +e(a);if(/document/.test(c)||c==document){b.containerOffset={left:0,top:0};b.containerPosition={left:0,top:0};b.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}}else{var d=e(a),f=[];e(["Top","Right","Left","Bottom"]).each(function(i,j){f[i]=m(d.css("padding"+j))});b.containerOffset=d.offset();b.containerPosition=d.position();b.containerSize={height:d.innerHeight()-f[3],width:d.innerWidth()-f[1]};c=b.containerOffset; +var g=b.containerSize.height,h=b.containerSize.width;h=e.ui.hasScroll(a,"left")?a.scrollWidth:h;g=e.ui.hasScroll(a)?a.scrollHeight:g;b.parentData={element:a,left:c.left,top:c.top,width:h,height:g}}}},resize:function(b){var a=e(this).data("resizable"),c=a.options,d=a.containerOffset,f=a.position;b=a._aspectRatio||b.shiftKey;var g={top:0,left:0},h=a.containerElement;if(h[0]!=document&&/static/.test(h.css("position")))g=d;if(f.left<(a._helper?d.left:0)){a.size.width+=a._helper?a.position.left-d.left: +a.position.left-g.left;if(b)a.size.height=a.size.width/c.aspectRatio;a.position.left=c.helper?d.left:0}if(f.top<(a._helper?d.top:0)){a.size.height+=a._helper?a.position.top-d.top:a.position.top;if(b)a.size.width=a.size.height*c.aspectRatio;a.position.top=a._helper?d.top:0}a.offset.left=a.parentData.left+a.position.left;a.offset.top=a.parentData.top+a.position.top;c=Math.abs((a._helper?a.offset.left-g.left:a.offset.left-g.left)+a.sizeDiff.width);d=Math.abs((a._helper?a.offset.top-g.top:a.offset.top- +d.top)+a.sizeDiff.height);f=a.containerElement.get(0)==a.element.parent().get(0);g=/relative|absolute/.test(a.containerElement.css("position"));if(f&&g)c-=a.parentData.left;if(c+a.size.width>=a.parentData.width){a.size.width=a.parentData.width-c;if(b)a.size.height=a.size.width/a.aspectRatio}if(d+a.size.height>=a.parentData.height){a.size.height=a.parentData.height-d;if(b)a.size.width=a.size.height*a.aspectRatio}},stop:function(){var b=e(this).data("resizable"),a=b.options,c=b.containerOffset,d=b.containerPosition, +f=b.containerElement,g=e(b.helper),h=g.offset(),i=g.outerWidth()-b.sizeDiff.width;g=g.outerHeight()-b.sizeDiff.height;b._helper&&!a.animate&&/relative/.test(f.css("position"))&&e(this).css({left:h.left-d.left-c.left,width:i,height:g});b._helper&&!a.animate&&/static/.test(f.css("position"))&&e(this).css({left:h.left-d.left-c.left,width:i,height:g})}});e.ui.plugin.add("resizable","ghost",{start:function(){var b=e(this).data("resizable"),a=b.options,c=b.size;b.ghost=b.originalElement.clone();b.ghost.css({opacity:0.25, +display:"block",position:"relative",height:c.height,width:c.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof a.ghost=="string"?a.ghost:"");b.ghost.appendTo(b.helper)},resize:function(){var b=e(this).data("resizable");b.ghost&&b.ghost.css({position:"relative",height:b.size.height,width:b.size.width})},stop:function(){var b=e(this).data("resizable");b.ghost&&b.helper&&b.helper.get(0).removeChild(b.ghost.get(0))}});e.ui.plugin.add("resizable","grid",{resize:function(){var b= +e(this).data("resizable"),a=b.options,c=b.size,d=b.originalSize,f=b.originalPosition,g=b.axis;a.grid=typeof a.grid=="number"?[a.grid,a.grid]:a.grid;var h=Math.round((c.width-d.width)/(a.grid[0]||1))*(a.grid[0]||1);a=Math.round((c.height-d.height)/(a.grid[1]||1))*(a.grid[1]||1);if(/^(se|s|e)$/.test(g)){b.size.width=d.width+h;b.size.height=d.height+a}else if(/^(ne)$/.test(g)){b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f.top-a}else{if(/^(sw)$/.test(g)){b.size.width=d.width+h;b.size.height= +d.height+a}else{b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f.top-a}b.position.left=f.left-h}}});var m=function(b){return parseInt(b,10)||0},k=function(b){return!isNaN(parseInt(b,10))}})(jQuery); +;/* + * jQuery UI Selectable 1.8.16 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Selectables + * + * Depends: + * jquery.ui.core.js + * jquery.ui.mouse.js + * jquery.ui.widget.js + */ +(function(e){e.widget("ui.selectable",e.ui.mouse,{options:{appendTo:"body",autoRefresh:true,distance:0,filter:"*",tolerance:"touch"},_create:function(){var c=this;this.element.addClass("ui-selectable");this.dragged=false;var f;this.refresh=function(){f=e(c.options.filter,c.element[0]);f.each(function(){var d=e(this),b=d.offset();e.data(this,"selectable-item",{element:this,$element:d,left:b.left,top:b.top,right:b.left+d.outerWidth(),bottom:b.top+d.outerHeight(),startselected:false,selected:d.hasClass("ui-selected"), +selecting:d.hasClass("ui-selecting"),unselecting:d.hasClass("ui-unselecting")})})};this.refresh();this.selectees=f.addClass("ui-selectee");this._mouseInit();this.helper=e("
")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(c){var f=this;this.opos=[c.pageX, +c.pageY];if(!this.options.disabled){var d=this.options;this.selectees=e(d.filter,this.element[0]);this._trigger("start",c);e(d.appendTo).append(this.helper);this.helper.css({left:c.clientX,top:c.clientY,width:0,height:0});d.autoRefresh&&this.refresh();this.selectees.filter(".ui-selected").each(function(){var b=e.data(this,"selectable-item");b.startselected=true;if(!c.metaKey){b.$element.removeClass("ui-selected");b.selected=false;b.$element.addClass("ui-unselecting");b.unselecting=true;f._trigger("unselecting", +c,{unselecting:b.element})}});e(c.target).parents().andSelf().each(function(){var b=e.data(this,"selectable-item");if(b){var g=!c.metaKey||!b.$element.hasClass("ui-selected");b.$element.removeClass(g?"ui-unselecting":"ui-selected").addClass(g?"ui-selecting":"ui-unselecting");b.unselecting=!g;b.selecting=g;(b.selected=g)?f._trigger("selecting",c,{selecting:b.element}):f._trigger("unselecting",c,{unselecting:b.element});return false}})}},_mouseDrag:function(c){var f=this;this.dragged=true;if(!this.options.disabled){var d= +this.options,b=this.opos[0],g=this.opos[1],h=c.pageX,i=c.pageY;if(b>h){var j=h;h=b;b=j}if(g>i){j=i;i=g;g=j}this.helper.css({left:b,top:g,width:h-b,height:i-g});this.selectees.each(function(){var a=e.data(this,"selectable-item");if(!(!a||a.element==f.element[0])){var k=false;if(d.tolerance=="touch")k=!(a.left>h||a.righti||a.bottomb&&a.rightg&&a.bottom *",opacity:false,placeholder:false,revert:false,scroll:true,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1E3},_create:function(){var a=this.options;this.containerCache={};this.element.addClass("ui-sortable"); +this.refresh();this.floating=this.items.length?a.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):false;this.offset=this.element.offset();this._mouseInit()},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var a=this.items.length-1;a>=0;a--)this.items[a].item.removeData("sortable-item");return this},_setOption:function(a,b){if(a=== +"disabled"){this.options[a]=b;this.widget()[b?"addClass":"removeClass"]("ui-sortable-disabled")}else d.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(a,b){if(this.reverting)return false;if(this.options.disabled||this.options.type=="static")return false;this._refreshItems(a);var c=null,e=this;d(a.target).parents().each(function(){if(d.data(this,"sortable-item")==e){c=d(this);return false}});if(d.data(a.target,"sortable-item")==e)c=d(a.target);if(!c)return false;if(this.options.handle&& +!b){var f=false;d(this.options.handle,c).find("*").andSelf().each(function(){if(this==a.target)f=true});if(!f)return false}this.currentItem=c;this._removeCurrentsFromItems();return true},_mouseStart:function(a,b,c){b=this.options;var e=this;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(a);this._cacheHelperProportions();this._cacheMargins();this.scrollParent=this.helper.scrollParent();this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top, +left:this.offset.left-this.margins.left};this.helper.css("position","absolute");this.cssPosition=this.helper.css("position");d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]}; +this.helper[0]!=this.currentItem[0]&&this.currentItem.hide();this._createPlaceholder();b.containment&&this._setContainment();if(b.cursor){if(d("body").css("cursor"))this._storedCursor=d("body").css("cursor");d("body").css("cursor",b.cursor)}if(b.opacity){if(this.helper.css("opacity"))this._storedOpacity=this.helper.css("opacity");this.helper.css("opacity",b.opacity)}if(b.zIndex){if(this.helper.css("zIndex"))this._storedZIndex=this.helper.css("zIndex");this.helper.css("zIndex",b.zIndex)}if(this.scrollParent[0]!= +document&&this.scrollParent[0].tagName!="HTML")this.overflowOffset=this.scrollParent.offset();this._trigger("start",a,this._uiHash());this._preserveHelperProportions||this._cacheHelperProportions();if(!c)for(c=this.containers.length-1;c>=0;c--)this.containers[c]._trigger("activate",a,e._uiHash(this));if(d.ui.ddmanager)d.ui.ddmanager.current=this;d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.dragging=true;this.helper.addClass("ui-sortable-helper");this._mouseDrag(a); +return true},_mouseDrag:function(a){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");if(!this.lastPositionAbs)this.lastPositionAbs=this.positionAbs;if(this.options.scroll){var b=this.options,c=false;if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"){if(this.overflowOffset.top+this.scrollParent[0].offsetHeight-a.pageY=0;b--){c=this.items[b];var e=c.item[0],f=this._intersectsWithPointer(c);if(f)if(e!=this.currentItem[0]&&this.placeholder[f==1?"next":"prev"]()[0]!=e&&!d.ui.contains(this.placeholder[0],e)&&(this.options.type=="semi-dynamic"?!d.ui.contains(this.element[0], +e):true)){this.direction=f==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(c))this._rearrange(a,c);else break;this._trigger("change",a,this._uiHash());break}}this._contactContainers(a);d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);this._trigger("sort",a,this._uiHash());this.lastPositionAbs=this.positionAbs;return false},_mouseStop:function(a,b){if(a){d.ui.ddmanager&&!this.options.dropBehaviour&&d.ui.ddmanager.drop(this,a);if(this.options.revert){var c=this;b=c.placeholder.offset(); +c.reverting=true;d(this.helper).animate({left:b.left-this.offset.parent.left-c.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:b.top-this.offset.parent.top-c.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){c._clear(a)})}else this._clear(a,b);return false}},cancel:function(){var a=this;if(this.dragging){this._mouseUp({target:null});this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"): +this.currentItem.show();for(var b=this.containers.length-1;b>=0;b--){this.containers[b]._trigger("deactivate",null,a._uiHash(this));if(this.containers[b].containerCache.over){this.containers[b]._trigger("out",null,a._uiHash(this));this.containers[b].containerCache.over=0}}}if(this.placeholder){this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]);this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove();d.extend(this,{helper:null, +dragging:false,reverting:false,_noFinalSort:null});this.domPosition.prev?d(this.domPosition.prev).after(this.currentItem):d(this.domPosition.parent).prepend(this.currentItem)}return this},serialize:function(a){var b=this._getItemsAsjQuery(a&&a.connected),c=[];a=a||{};d(b).each(function(){var e=(d(a.item||this).attr(a.attribute||"id")||"").match(a.expression||/(.+)[-=_](.+)/);if(e)c.push((a.key||e[1]+"[]")+"="+(a.key&&a.expression?e[1]:e[2]))});!c.length&&a.key&&c.push(a.key+"=");return c.join("&")}, +toArray:function(a){var b=this._getItemsAsjQuery(a&&a.connected),c=[];a=a||{};b.each(function(){c.push(d(a.item||this).attr(a.attribute||"id")||"")});return c},_intersectsWith:function(a){var b=this.positionAbs.left,c=b+this.helperProportions.width,e=this.positionAbs.top,f=e+this.helperProportions.height,g=a.left,h=g+a.width,i=a.top,k=i+a.height,j=this.offset.click.top,l=this.offset.click.left;j=e+j>i&&e+jg&&b+la[this.floating?"width":"height"]?j:g0?"down":"up")},_getDragHorizontalDirection:function(){var a=this.positionAbs.left-this.lastPositionAbs.left;return a!=0&&(a>0?"right":"left")},refresh:function(a){this._refreshItems(a);this.refreshPositions();return this},_connectWith:function(){var a=this.options;return a.connectWith.constructor==String?[a.connectWith]:a.connectWith},_getItemsAsjQuery:function(a){var b=[],c=[],e=this._connectWith(); +if(e&&a)for(a=e.length-1;a>=0;a--)for(var f=d(e[a]),g=f.length-1;g>=0;g--){var h=d.data(f[g],"sortable");if(h&&h!=this&&!h.options.disabled)c.push([d.isFunction(h.options.items)?h.options.items.call(h.element):d(h.options.items,h.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),h])}c.push([d.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):d(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), +this]);for(a=c.length-1;a>=0;a--)c[a][0].each(function(){b.push(this)});return d(b)},_removeCurrentsFromItems:function(){for(var a=this.currentItem.find(":data(sortable-item)"),b=0;b=0;f--)for(var g=d(e[f]),h=g.length-1;h>=0;h--){var i=d.data(g[h],"sortable");if(i&&i!=this&&!i.options.disabled){c.push([d.isFunction(i.options.items)?i.options.items.call(i.element[0],a,{item:this.currentItem}):d(i.options.items,i.element),i]);this.containers.push(i)}}for(f=c.length-1;f>=0;f--){a=c[f][1];e=c[f][0];h=0;for(g=e.length;h=0;b--){var c=this.items[b];if(!(c.instance!=this.currentContainer&&this.currentContainer&&c.item[0]!=this.currentItem[0])){var e=this.options.toleranceElement?d(this.options.toleranceElement,c.item):c.item;if(!a){c.width=e.outerWidth();c.height=e.outerHeight()}e=e.offset();c.left=e.left;c.top=e.top}}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(b= +this.containers.length-1;b>=0;b--){e=this.containers[b].element.offset();this.containers[b].containerCache.left=e.left;this.containers[b].containerCache.top=e.top;this.containers[b].containerCache.width=this.containers[b].element.outerWidth();this.containers[b].containerCache.height=this.containers[b].element.outerHeight()}return this},_createPlaceholder:function(a){var b=a||this,c=b.options;if(!c.placeholder||c.placeholder.constructor==String){var e=c.placeholder;c.placeholder={element:function(){var f= +d(document.createElement(b.currentItem[0].nodeName)).addClass(e||b.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];if(!e)f.style.visibility="hidden";return f},update:function(f,g){if(!(e&&!c.forcePlaceholderSize)){g.height()||g.height(b.currentItem.innerHeight()-parseInt(b.currentItem.css("paddingTop")||0,10)-parseInt(b.currentItem.css("paddingBottom")||0,10));g.width()||g.width(b.currentItem.innerWidth()-parseInt(b.currentItem.css("paddingLeft")||0,10)-parseInt(b.currentItem.css("paddingRight")|| +0,10))}}}}b.placeholder=d(c.placeholder.element.call(b.element,b.currentItem));b.currentItem.after(b.placeholder);c.placeholder.update(b,b.placeholder)},_contactContainers:function(a){for(var b=null,c=null,e=this.containers.length-1;e>=0;e--)if(!d.ui.contains(this.currentItem[0],this.containers[e].element[0]))if(this._intersectsWith(this.containers[e].containerCache)){if(!(b&&d.ui.contains(this.containers[e].element[0],b.element[0]))){b=this.containers[e];c=e}}else if(this.containers[e].containerCache.over){this.containers[e]._trigger("out", +a,this._uiHash(this));this.containers[e].containerCache.over=0}if(b)if(this.containers.length===1){this.containers[c]._trigger("over",a,this._uiHash(this));this.containers[c].containerCache.over=1}else if(this.currentContainer!=this.containers[c]){b=1E4;e=null;for(var f=this.positionAbs[this.containers[c].floating?"left":"top"],g=this.items.length-1;g>=0;g--)if(d.ui.contains(this.containers[c].element[0],this.items[g].item[0])){var h=this.items[g][this.containers[c].floating?"left":"top"];if(Math.abs(h- +f)this.containment[2])f=this.containment[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>this.containment[3])g=this.containment[3]+this.offset.click.top}if(b.grid){g=this.originalPageY+Math.round((g- +this.originalPageY)/b.grid[1])*b.grid[1];g=this.containment?!(g-this.offset.click.topthis.containment[3])?g:!(g-this.offset.click.topthis.containment[2])?f:!(f-this.offset.click.left=0;e--)if(d.ui.contains(this.containers[e].element[0],this.currentItem[0])&&!b){c.push(function(f){return function(g){f._trigger("receive",g,this._uiHash(this))}}.call(this,this.containers[e]));c.push(function(f){return function(g){f._trigger("update",g,this._uiHash(this))}}.call(this,this.containers[e]))}}for(e=this.containers.length-1;e>=0;e--){b||c.push(function(f){return function(g){f._trigger("deactivate",g,this._uiHash(this))}}.call(this, +this.containers[e]));if(this.containers[e].containerCache.over){c.push(function(f){return function(g){f._trigger("out",g,this._uiHash(this))}}.call(this,this.containers[e]));this.containers[e].containerCache.over=0}}this._storedCursor&&d("body").css("cursor",this._storedCursor);this._storedOpacity&&this.helper.css("opacity",this._storedOpacity);if(this._storedZIndex)this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex);this.dragging=false;if(this.cancelHelperRemoval){if(!b){this._trigger("beforeStop", +a,this._uiHash());for(e=0;e li > :first-child,> :not(li):even",icons:{header:"ui-icon-triangle-1-e",headerSelected:"ui-icon-triangle-1-s"},navigation:false,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}},_create:function(){var a=this,b=a.options;a.running=0;a.element.addClass("ui-accordion ui-widget ui-helper-reset").children("li").addClass("ui-accordion-li-fix"); +a.headers=a.element.find(b.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all").bind("mouseenter.accordion",function(){b.disabled||c(this).addClass("ui-state-hover")}).bind("mouseleave.accordion",function(){b.disabled||c(this).removeClass("ui-state-hover")}).bind("focus.accordion",function(){b.disabled||c(this).addClass("ui-state-focus")}).bind("blur.accordion",function(){b.disabled||c(this).removeClass("ui-state-focus")});a.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom"); +if(b.navigation){var d=a.element.find("a").filter(b.navigationFilter).eq(0);if(d.length){var h=d.closest(".ui-accordion-header");a.active=h.length?h:d.closest(".ui-accordion-content").prev()}}a.active=a._findActive(a.active||b.active).addClass("ui-state-default ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top");a.active.next().addClass("ui-accordion-content-active");a._createIcons();a.resize();a.element.attr("role","tablist");a.headers.attr("role","tab").bind("keydown.accordion", +function(f){return a._keydown(f)}).next().attr("role","tabpanel");a.headers.not(a.active||"").attr({"aria-expanded":"false","aria-selected":"false",tabIndex:-1}).next().hide();a.active.length?a.active.attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}):a.headers.eq(0).attr("tabIndex",0);c.browser.safari||a.headers.find("a").attr("tabIndex",-1);b.event&&a.headers.bind(b.event.split(" ").join(".accordion ")+".accordion",function(f){a._clickHandler.call(a,f,this);f.preventDefault()})},_createIcons:function(){var a= +this.options;if(a.icons){c("").addClass("ui-icon "+a.icons.header).prependTo(this.headers);this.active.children(".ui-icon").toggleClass(a.icons.header).toggleClass(a.icons.headerSelected);this.element.addClass("ui-accordion-icons")}},_destroyIcons:function(){this.headers.children(".ui-icon").remove();this.element.removeClass("ui-accordion-icons")},destroy:function(){var a=this.options;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role");this.headers.unbind(".accordion").removeClass("ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("tabIndex"); +this.headers.find("a").removeAttr("tabIndex");this._destroyIcons();var b=this.headers.next().css("display","").removeAttr("role").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled");if(a.autoHeight||a.fillHeight)b.css("height","");return c.Widget.prototype.destroy.call(this)},_setOption:function(a,b){c.Widget.prototype._setOption.apply(this,arguments);a=="active"&&this.activate(b);if(a=="icons"){this._destroyIcons(); +b&&this._createIcons()}if(a=="disabled")this.headers.add(this.headers.next())[b?"addClass":"removeClass"]("ui-accordion-disabled ui-state-disabled")},_keydown:function(a){if(!(this.options.disabled||a.altKey||a.ctrlKey)){var b=c.ui.keyCode,d=this.headers.length,h=this.headers.index(a.target),f=false;switch(a.keyCode){case b.RIGHT:case b.DOWN:f=this.headers[(h+1)%d];break;case b.LEFT:case b.UP:f=this.headers[(h-1+d)%d];break;case b.SPACE:case b.ENTER:this._clickHandler({target:a.target},a.target); +a.preventDefault()}if(f){c(a.target).attr("tabIndex",-1);c(f).attr("tabIndex",0);f.focus();return false}return true}},resize:function(){var a=this.options,b;if(a.fillSpace){if(c.browser.msie){var d=this.element.parent().css("overflow");this.element.parent().css("overflow","hidden")}b=this.element.parent().height();c.browser.msie&&this.element.parent().css("overflow",d);this.headers.each(function(){b-=c(this).outerHeight(true)});this.headers.next().each(function(){c(this).height(Math.max(0,b-c(this).innerHeight()+ +c(this).height()))}).css("overflow","auto")}else if(a.autoHeight){b=0;this.headers.next().each(function(){b=Math.max(b,c(this).height("").height())}).height(b)}return this},activate:function(a){this.options.active=a;a=this._findActive(a)[0];this._clickHandler({target:a},a);return this},_findActive:function(a){return a?typeof a==="number"?this.headers.filter(":eq("+a+")"):this.headers.not(this.headers.not(a)):a===false?c([]):this.headers.filter(":eq(0)")},_clickHandler:function(a,b){var d=this.options; +if(!d.disabled)if(a.target){a=c(a.currentTarget||b);b=a[0]===this.active[0];d.active=d.collapsible&&b?false:this.headers.index(a);if(!(this.running||!d.collapsible&&b)){var h=this.active;j=a.next();g=this.active.next();e={options:d,newHeader:b&&d.collapsible?c([]):a,oldHeader:this.active,newContent:b&&d.collapsible?c([]):j,oldContent:g};var f=this.headers.index(this.active[0])>this.headers.index(a[0]);this.active=b?c([]):a;this._toggle(j,g,e,b,f);h.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header); +if(!b){a.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top").children(".ui-icon").removeClass(d.icons.header).addClass(d.icons.headerSelected);a.next().addClass("ui-accordion-content-active")}}}else if(d.collapsible){this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header);this.active.next().addClass("ui-accordion-content-active");var g=this.active.next(), +e={options:d,newHeader:c([]),oldHeader:d.active,newContent:c([]),oldContent:g},j=this.active=c([]);this._toggle(j,g,e)}},_toggle:function(a,b,d,h,f){var g=this,e=g.options;g.toShow=a;g.toHide=b;g.data=d;var j=function(){if(g)return g._completed.apply(g,arguments)};g._trigger("changestart",null,g.data);g.running=b.size()===0?a.size():b.size();if(e.animated){d={};d=e.collapsible&&h?{toShow:c([]),toHide:b,complete:j,down:f,autoHeight:e.autoHeight||e.fillSpace}:{toShow:a,toHide:b,complete:j,down:f,autoHeight:e.autoHeight|| +e.fillSpace};if(!e.proxied)e.proxied=e.animated;if(!e.proxiedDuration)e.proxiedDuration=e.duration;e.animated=c.isFunction(e.proxied)?e.proxied(d):e.proxied;e.duration=c.isFunction(e.proxiedDuration)?e.proxiedDuration(d):e.proxiedDuration;h=c.ui.accordion.animations;var i=e.duration,k=e.animated;if(k&&!h[k]&&!c.easing[k])k="slide";h[k]||(h[k]=function(l){this.slide(l,{easing:k,duration:i||700})});h[k](d)}else{if(e.collapsible&&h)a.toggle();else{b.hide();a.show()}j(true)}b.prev().attr({"aria-expanded":"false", +"aria-selected":"false",tabIndex:-1}).blur();a.prev().attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}).focus()},_completed:function(a){this.running=a?0:--this.running;if(!this.running){this.options.clearStyle&&this.toShow.add(this.toHide).css({height:"",overflow:""});this.toHide.removeClass("ui-accordion-content-active");if(this.toHide.length)this.toHide.parent()[0].className=this.toHide.parent()[0].className;this._trigger("change",null,this.data)}}});c.extend(c.ui.accordion,{version:"1.8.16", +animations:{slide:function(a,b){a=c.extend({easing:"swing",duration:300},a,b);if(a.toHide.size())if(a.toShow.size()){var d=a.toShow.css("overflow"),h=0,f={},g={},e;b=a.toShow;e=b[0].style.width;b.width(parseInt(b.parent().width(),10)-parseInt(b.css("paddingLeft"),10)-parseInt(b.css("paddingRight"),10)-(parseInt(b.css("borderLeftWidth"),10)||0)-(parseInt(b.css("borderRightWidth"),10)||0));c.each(["height","paddingTop","paddingBottom"],function(j,i){g[i]="hide";j=(""+c.css(a.toShow[0],i)).match(/^([\d+-.]+)(.*)$/); +f[i]={value:j[1],unit:j[2]||"px"}});a.toShow.css({height:0,overflow:"hidden"}).show();a.toHide.filter(":hidden").each(a.complete).end().filter(":visible").animate(g,{step:function(j,i){if(i.prop=="height")h=i.end-i.start===0?0:(i.now-i.start)/(i.end-i.start);a.toShow[0].style[i.prop]=h*f[i.prop].value+f[i.prop].unit},duration:a.duration,easing:a.easing,complete:function(){a.autoHeight||a.toShow.css("height","");a.toShow.css({width:e,overflow:d});a.complete()}})}else a.toHide.animate({height:"hide", +paddingTop:"hide",paddingBottom:"hide"},a);else a.toShow.animate({height:"show",paddingTop:"show",paddingBottom:"show"},a)},bounceslide:function(a){this.slide(a,{easing:a.down?"easeOutBounce":"swing",duration:a.down?1E3:200})}}})})(jQuery); +;/* + * jQuery UI Autocomplete 1.8.16 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Autocomplete + * + * Depends: + * jquery.ui.core.js + * jquery.ui.widget.js + * jquery.ui.position.js + */ +(function(d){var e=0;d.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:false,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var a=this,b=this.element[0].ownerDocument,g;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(c){if(!(a.options.disabled||a.element.propAttr("readOnly"))){g= +false;var f=d.ui.keyCode;switch(c.keyCode){case f.PAGE_UP:a._move("previousPage",c);break;case f.PAGE_DOWN:a._move("nextPage",c);break;case f.UP:a._move("previous",c);c.preventDefault();break;case f.DOWN:a._move("next",c);c.preventDefault();break;case f.ENTER:case f.NUMPAD_ENTER:if(a.menu.active){g=true;c.preventDefault()}case f.TAB:if(!a.menu.active)return;a.menu.select(c);break;case f.ESCAPE:a.element.val(a.term);a.close(c);break;default:clearTimeout(a.searching);a.searching=setTimeout(function(){if(a.term!= +a.element.val()){a.selectedItem=null;a.search(null,c)}},a.options.delay);break}}}).bind("keypress.autocomplete",function(c){if(g){g=false;c.preventDefault()}}).bind("focus.autocomplete",function(){if(!a.options.disabled){a.selectedItem=null;a.previous=a.element.val()}}).bind("blur.autocomplete",function(c){if(!a.options.disabled){clearTimeout(a.searching);a.closing=setTimeout(function(){a.close(c);a._change(c)},150)}});this._initSource();this.response=function(){return a._response.apply(a,arguments)}; +this.menu=d("
    ").addClass("ui-autocomplete").appendTo(d(this.options.appendTo||"body",b)[0]).mousedown(function(c){var f=a.menu.element[0];d(c.target).closest(".ui-menu-item").length||setTimeout(function(){d(document).one("mousedown",function(h){h.target!==a.element[0]&&h.target!==f&&!d.ui.contains(f,h.target)&&a.close()})},1);setTimeout(function(){clearTimeout(a.closing)},13)}).menu({focus:function(c,f){f=f.item.data("item.autocomplete");false!==a._trigger("focus",c,{item:f})&&/^key/.test(c.originalEvent.type)&& +a.element.val(f.value)},selected:function(c,f){var h=f.item.data("item.autocomplete"),i=a.previous;if(a.element[0]!==b.activeElement){a.element.focus();a.previous=i;setTimeout(function(){a.previous=i;a.selectedItem=h},1)}false!==a._trigger("select",c,{item:h})&&a.element.val(h.value);a.term=a.element.val();a.close(c);a.selectedItem=h},blur:function(){a.menu.element.is(":visible")&&a.element.val()!==a.term&&a.element.val(a.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu"); +d.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");this.menu.element.remove();d.Widget.prototype.destroy.call(this)},_setOption:function(a,b){d.Widget.prototype._setOption.apply(this,arguments);a==="source"&&this._initSource();if(a==="appendTo")this.menu.element.appendTo(d(b||"body",this.element[0].ownerDocument)[0]);a==="disabled"&& +b&&this.xhr&&this.xhr.abort()},_initSource:function(){var a=this,b,g;if(d.isArray(this.options.source)){b=this.options.source;this.source=function(c,f){f(d.ui.autocomplete.filter(b,c.term))}}else if(typeof this.options.source==="string"){g=this.options.source;this.source=function(c,f){a.xhr&&a.xhr.abort();a.xhr=d.ajax({url:g,data:c,dataType:"json",autocompleteRequest:++e,success:function(h){this.autocompleteRequest===e&&f(h)},error:function(){this.autocompleteRequest===e&&f([])}})}}else this.source= +this.options.source},search:function(a,b){a=a!=null?a:this.element.val();this.term=this.element.val();if(a.length").data("item.autocomplete",b).append(d("").text(b.label)).appendTo(a)},_move:function(a,b){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&/^next/.test(a)){this.element.val(this.term);this.menu.deactivate()}else this.menu[a](b);else this.search(null,b)},widget:function(){return this.menu.element}});d.extend(d.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, +"\\$&")},filter:function(a,b){var g=new RegExp(d.ui.autocomplete.escapeRegex(b),"i");return d.grep(a,function(c){return g.test(c.label||c.value||c)})}})})(jQuery); +(function(d){d.widget("ui.menu",{_create:function(){var e=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(a){if(d(a.target).closest(".ui-menu-item a").length){a.preventDefault();e.select(a)}});this.refresh()},refresh:function(){var e=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex", +-1).mouseenter(function(a){e.activate(a,d(this).parent())}).mouseleave(function(){e.deactivate()})},activate:function(e,a){this.deactivate();if(this.hasScroll()){var b=a.offset().top-this.element.offset().top,g=this.element.scrollTop(),c=this.element.height();if(b<0)this.element.scrollTop(g+b);else b>=c&&this.element.scrollTop(g+b-c+a.height())}this.active=a.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",e,{item:a})},deactivate:function(){if(this.active){this.active.children("a").removeClass("ui-state-hover").removeAttr("id"); +this._trigger("blur");this.active=null}},next:function(e){this.move("next",".ui-menu-item:first",e)},previous:function(e){this.move("prev",".ui-menu-item:last",e)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(e,a,b){if(this.active){e=this.active[e+"All"](".ui-menu-item").eq(0);e.length?this.activate(b,e):this.activate(b,this.element.children(a))}else this.activate(b, +this.element.children(a))},nextPage:function(e){if(this.hasScroll())if(!this.active||this.last())this.activate(e,this.element.children(".ui-menu-item:first"));else{var a=this.active.offset().top,b=this.element.height(),g=this.element.children(".ui-menu-item").filter(function(){var c=d(this).offset().top-a-b+d(this).height();return c<10&&c>-10});g.length||(g=this.element.children(".ui-menu-item:last"));this.activate(e,g)}else this.activate(e,this.element.children(".ui-menu-item").filter(!this.active|| +this.last()?":first":":last"))},previousPage:function(e){if(this.hasScroll())if(!this.active||this.first())this.activate(e,this.element.children(".ui-menu-item:last"));else{var a=this.active.offset().top,b=this.element.height();result=this.element.children(".ui-menu-item").filter(function(){var g=d(this).offset().top-a+b-d(this).height();return g<10&&g>-10});result.length||(result=this.element.children(".ui-menu-item:first"));this.activate(e,result)}else this.activate(e,this.element.children(".ui-menu-item").filter(!this.active|| +this.first()?":last":":first"))},hasScroll:function(){return this.element.height()").addClass("ui-button-text").html(this.options.label).appendTo(a.empty()).text(),e=this.options.icons,f=e.primary&&e.secondary,d=[];if(e.primary||e.secondary){if(this.options.text)d.push("ui-button-text-icon"+(f?"s":e.primary?"-primary":"-secondary"));e.primary&&a.prepend("");e.secondary&&a.append("");if(!this.options.text){d.push(f?"ui-button-icons-only": +"ui-button-icon-only");this.hasTitle||a.attr("title",c)}}else d.push("ui-button-text-only");a.addClass(d.join(" "))}}});b.widget("ui.buttonset",{options:{items:":button, :submit, :reset, :checkbox, :radio, a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(a,c){a==="disabled"&&this.buttons.button("option",a,c);b.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){var a=this.element.css("direction")=== +"ltr";this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return b(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(a?"ui-corner-left":"ui-corner-right").end().filter(":last").addClass(a?"ui-corner-right":"ui-corner-left").end().end()},destroy:function(){this.element.removeClass("ui-buttonset");this.buttons.map(function(){return b(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy"); +b.Widget.prototype.destroy.call(this)}})})(jQuery); +;/* + * jQuery UI Dialog 1.8.16 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Dialog + * + * Depends: + * jquery.ui.core.js + * jquery.ui.widget.js + * jquery.ui.button.js + * jquery.ui.draggable.js + * jquery.ui.mouse.js + * jquery.ui.position.js + * jquery.ui.resizable.js + */ +(function(c,l){var m={buttons:true,height:true,maxHeight:true,maxWidth:true,minHeight:true,minWidth:true,width:true},n={maxHeight:true,maxWidth:true,minHeight:true,minWidth:true},o=c.attrFn||{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true,click:true};c.widget("ui.dialog",{options:{autoOpen:true,buttons:{},closeOnEscape:true,closeText:"close",dialogClass:"",draggable:true,hide:null,height:"auto",maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false, +position:{my:"center",at:"center",collision:"fit",using:function(a){var b=c(this).css(a).offset().top;b<0&&c(this).css("top",a.top-b)}},resizable:true,show:null,stack:true,title:"",width:300,zIndex:1E3},_create:function(){this.originalTitle=this.element.attr("title");if(typeof this.originalTitle!=="string")this.originalTitle="";this.options.title=this.options.title||this.originalTitle;var a=this,b=a.options,d=b.title||" ",e=c.ui.dialog.getTitleId(a.element),g=(a.uiDialog=c("
    ")).appendTo(document.body).hide().addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+ +b.dialogClass).css({zIndex:b.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(i){if(b.closeOnEscape&&!i.isDefaultPrevented()&&i.keyCode&&i.keyCode===c.ui.keyCode.ESCAPE){a.close(i);i.preventDefault()}}).attr({role:"dialog","aria-labelledby":e}).mousedown(function(i){a.moveToTop(false,i)});a.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(g);var f=(a.uiDialogTitlebar=c("
    ")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(g), +h=c('').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){h.addClass("ui-state-hover")},function(){h.removeClass("ui-state-hover")}).focus(function(){h.addClass("ui-state-focus")}).blur(function(){h.removeClass("ui-state-focus")}).click(function(i){a.close(i);return false}).appendTo(f);(a.uiDialogTitlebarCloseText=c("")).addClass("ui-icon ui-icon-closethick").text(b.closeText).appendTo(h);c("").addClass("ui-dialog-title").attr("id", +e).html(d).prependTo(f);if(c.isFunction(b.beforeclose)&&!c.isFunction(b.beforeClose))b.beforeClose=b.beforeclose;f.find("*").add(f).disableSelection();b.draggable&&c.fn.draggable&&a._makeDraggable();b.resizable&&c.fn.resizable&&a._makeResizable();a._createButtons(b.buttons);a._isOpen=false;c.fn.bgiframe&&g.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){var a=this;a.overlay&&a.overlay.destroy();a.uiDialog.hide();a.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body"); +a.uiDialog.remove();a.originalTitle&&a.element.attr("title",a.originalTitle);return a},widget:function(){return this.uiDialog},close:function(a){var b=this,d,e;if(false!==b._trigger("beforeClose",a)){b.overlay&&b.overlay.destroy();b.uiDialog.unbind("keypress.ui-dialog");b._isOpen=false;if(b.options.hide)b.uiDialog.hide(b.options.hide,function(){b._trigger("close",a)});else{b.uiDialog.hide();b._trigger("close",a)}c.ui.dialog.overlay.resize();if(b.options.modal){d=0;c(".ui-dialog").each(function(){if(this!== +b.uiDialog[0]){e=c(this).css("z-index");isNaN(e)||(d=Math.max(d,e))}});c.ui.dialog.maxZ=d}return b}},isOpen:function(){return this._isOpen},moveToTop:function(a,b){var d=this,e=d.options;if(e.modal&&!a||!e.stack&&!e.modal)return d._trigger("focus",b);if(e.zIndex>c.ui.dialog.maxZ)c.ui.dialog.maxZ=e.zIndex;if(d.overlay){c.ui.dialog.maxZ+=1;d.overlay.$el.css("z-index",c.ui.dialog.overlay.maxZ=c.ui.dialog.maxZ)}a={scrollTop:d.element.scrollTop(),scrollLeft:d.element.scrollLeft()};c.ui.dialog.maxZ+=1; +d.uiDialog.css("z-index",c.ui.dialog.maxZ);d.element.attr(a);d._trigger("focus",b);return d},open:function(){if(!this._isOpen){var a=this,b=a.options,d=a.uiDialog;a.overlay=b.modal?new c.ui.dialog.overlay(a):null;a._size();a._position(b.position);d.show(b.show);a.moveToTop(true);b.modal&&d.bind("keypress.ui-dialog",function(e){if(e.keyCode===c.ui.keyCode.TAB){var g=c(":tabbable",this),f=g.filter(":first");g=g.filter(":last");if(e.target===g[0]&&!e.shiftKey){f.focus(1);return false}else if(e.target=== +f[0]&&e.shiftKey){g.focus(1);return false}}});c(a.element.find(":tabbable").get().concat(d.find(".ui-dialog-buttonpane :tabbable").get().concat(d.get()))).eq(0).focus();a._isOpen=true;a._trigger("open");return a}},_createButtons:function(a){var b=this,d=false,e=c("
    ").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),g=c("
    ").addClass("ui-dialog-buttonset").appendTo(e);b.uiDialog.find(".ui-dialog-buttonpane").remove();typeof a==="object"&&a!==null&&c.each(a, +function(){return!(d=true)});if(d){c.each(a,function(f,h){h=c.isFunction(h)?{click:h,text:f}:h;var i=c('').click(function(){h.click.apply(b.element[0],arguments)}).appendTo(g);c.each(h,function(j,k){if(j!=="click")j in o?i[j](k):i.attr(j,k)});c.fn.button&&i.button()});e.appendTo(b.uiDialog)}},_makeDraggable:function(){function a(f){return{position:f.position,offset:f.offset}}var b=this,d=b.options,e=c(document),g;b.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close", +handle:".ui-dialog-titlebar",containment:"document",start:function(f,h){g=d.height==="auto"?"auto":c(this).height();c(this).height(c(this).height()).addClass("ui-dialog-dragging");b._trigger("dragStart",f,a(h))},drag:function(f,h){b._trigger("drag",f,a(h))},stop:function(f,h){d.position=[h.position.left-e.scrollLeft(),h.position.top-e.scrollTop()];c(this).removeClass("ui-dialog-dragging").height(g);b._trigger("dragStop",f,a(h));c.ui.dialog.overlay.resize()}})},_makeResizable:function(a){function b(f){return{originalPosition:f.originalPosition, +originalSize:f.originalSize,position:f.position,size:f.size}}a=a===l?this.options.resizable:a;var d=this,e=d.options,g=d.uiDialog.css("position");a=typeof a==="string"?a:"n,e,s,w,se,sw,ne,nw";d.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:d.element,maxWidth:e.maxWidth,maxHeight:e.maxHeight,minWidth:e.minWidth,minHeight:d._minHeight(),handles:a,start:function(f,h){c(this).addClass("ui-dialog-resizing");d._trigger("resizeStart",f,b(h))},resize:function(f,h){d._trigger("resize", +f,b(h))},stop:function(f,h){c(this).removeClass("ui-dialog-resizing");e.height=c(this).height();e.width=c(this).width();d._trigger("resizeStop",f,b(h));c.ui.dialog.overlay.resize()}}).css("position",g).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var a=this.options;return a.height==="auto"?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(a){var b=[],d=[0,0],e;if(a){if(typeof a==="string"||typeof a==="object"&&"0"in a){b=a.split?a.split(" "): +[a[0],a[1]];if(b.length===1)b[1]=b[0];c.each(["left","top"],function(g,f){if(+b[g]===b[g]){d[g]=b[g];b[g]=f}});a={my:b.join(" "),at:b.join(" "),offset:d.join(" ")}}a=c.extend({},c.ui.dialog.prototype.options.position,a)}else a=c.ui.dialog.prototype.options.position;(e=this.uiDialog.is(":visible"))||this.uiDialog.show();this.uiDialog.css({top:0,left:0}).position(c.extend({of:window},a));e||this.uiDialog.hide()},_setOptions:function(a){var b=this,d={},e=false;c.each(a,function(g,f){b._setOption(g,f); +if(g in m)e=true;if(g in n)d[g]=f});e&&this._size();this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",d)},_setOption:function(a,b){var d=this,e=d.uiDialog;switch(a){case "beforeclose":a="beforeClose";break;case "buttons":d._createButtons(b);break;case "closeText":d.uiDialogTitlebarCloseText.text(""+b);break;case "dialogClass":e.removeClass(d.options.dialogClass).addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+b);break;case "disabled":b?e.addClass("ui-dialog-disabled"): +e.removeClass("ui-dialog-disabled");break;case "draggable":var g=e.is(":data(draggable)");g&&!b&&e.draggable("destroy");!g&&b&&d._makeDraggable();break;case "position":d._position(b);break;case "resizable":(g=e.is(":data(resizable)"))&&!b&&e.resizable("destroy");g&&typeof b==="string"&&e.resizable("option","handles",b);!g&&b!==false&&d._makeResizable(b);break;case "title":c(".ui-dialog-title",d.uiDialogTitlebar).html(""+(b||" "));break}c.Widget.prototype._setOption.apply(d,arguments)},_size:function(){var a= +this.options,b,d,e=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0});if(a.minWidth>a.width)a.width=a.minWidth;b=this.uiDialog.css({height:"auto",width:a.width}).height();d=Math.max(0,a.minHeight-b);if(a.height==="auto")if(c.support.minHeight)this.element.css({minHeight:d,height:"auto"});else{this.uiDialog.show();a=this.element.css("height","auto").height();e||this.uiDialog.hide();this.element.height(Math.max(a,d))}else this.element.height(Math.max(a.height- +b,0));this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}});c.extend(c.ui.dialog,{version:"1.8.16",uuid:0,maxZ:0,getTitleId:function(a){a=a.attr("id");if(!a){this.uuid+=1;a=this.uuid}return"ui-dialog-title-"+a},overlay:function(a){this.$el=c.ui.dialog.overlay.create(a)}});c.extend(c.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:c.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(a){return a+".dialog-overlay"}).join(" "), +create:function(a){if(this.instances.length===0){setTimeout(function(){c.ui.dialog.overlay.instances.length&&c(document).bind(c.ui.dialog.overlay.events,function(d){if(c(d.target).zIndex()").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),height:this.height()});c.fn.bgiframe&&b.bgiframe();this.instances.push(b);return b},destroy:function(a){var b=c.inArray(a,this.instances);b!=-1&&this.oldInstances.push(this.instances.splice(b,1)[0]);this.instances.length===0&&c([document,window]).unbind(".dialog-overlay");a.remove();var d=0;c.each(this.instances,function(){d=Math.max(d,this.css("z-index"))});this.maxZ=d},height:function(){var a,b;if(c.browser.msie&& +c.browser.version<7){a=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);b=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);return a").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(b.range==="min"||b.range==="max"?" ui-slider-range-"+b.range:""))}for(var j=c.length;j"); +this.handles=c.add(d(e.join("")).appendTo(a.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(g){g.preventDefault()}).hover(function(){b.disabled||d(this).addClass("ui-state-hover")},function(){d(this).removeClass("ui-state-hover")}).focus(function(){if(b.disabled)d(this).blur();else{d(".ui-slider .ui-state-focus").removeClass("ui-state-focus");d(this).addClass("ui-state-focus")}}).blur(function(){d(this).removeClass("ui-state-focus")});this.handles.each(function(g){d(this).data("index.ui-slider-handle", +g)});this.handles.keydown(function(g){var k=true,l=d(this).data("index.ui-slider-handle"),i,h,m;if(!a.options.disabled){switch(g.keyCode){case d.ui.keyCode.HOME:case d.ui.keyCode.END:case d.ui.keyCode.PAGE_UP:case d.ui.keyCode.PAGE_DOWN:case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:k=false;if(!a._keySliding){a._keySliding=true;d(this).addClass("ui-state-active");i=a._start(g,l);if(i===false)return}break}m=a.options.step;i=a.options.values&&a.options.values.length? +(h=a.values(l)):(h=a.value());switch(g.keyCode){case d.ui.keyCode.HOME:h=a._valueMin();break;case d.ui.keyCode.END:h=a._valueMax();break;case d.ui.keyCode.PAGE_UP:h=a._trimAlignValue(i+(a._valueMax()-a._valueMin())/5);break;case d.ui.keyCode.PAGE_DOWN:h=a._trimAlignValue(i-(a._valueMax()-a._valueMin())/5);break;case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:if(i===a._valueMax())return;h=a._trimAlignValue(i+m);break;case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:if(i===a._valueMin())return;h=a._trimAlignValue(i- +m);break}a._slide(g,l,h);return k}}).keyup(function(g){var k=d(this).data("index.ui-slider-handle");if(a._keySliding){a._keySliding=false;a._stop(g,k);a._change(g,k);d(this).removeClass("ui-state-active")}});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy(); +return this},_mouseCapture:function(a){var b=this.options,c,f,e,j,g;if(b.disabled)return false;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();c=this._normValueFromMouse({x:a.pageX,y:a.pageY});f=this._valueMax()-this._valueMin()+1;j=this;this.handles.each(function(k){var l=Math.abs(c-j.values(k));if(f>l){f=l;e=d(this);g=k}});if(b.range===true&&this.values(1)===b.min){g+=1;e=d(this.handles[g])}if(this._start(a,g)===false)return false; +this._mouseSliding=true;j._handleIndex=g;e.addClass("ui-state-active").focus();b=e.offset();this._clickOffset=!d(a.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:a.pageX-b.left-e.width()/2,top:a.pageY-b.top-e.height()/2-(parseInt(e.css("borderTopWidth"),10)||0)-(parseInt(e.css("borderBottomWidth"),10)||0)+(parseInt(e.css("marginTop"),10)||0)};this.handles.hasClass("ui-state-hover")||this._slide(a,g,c);return this._animateOff=true},_mouseStart:function(){return true},_mouseDrag:function(a){var b= +this._normValueFromMouse({x:a.pageX,y:a.pageY});this._slide(a,this._handleIndex,b);return false},_mouseStop:function(a){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(a,this._handleIndex);this._change(a,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=false},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(a){var b;if(this.orientation==="horizontal"){b= +this.elementSize.width;a=a.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{b=this.elementSize.height;a=a.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}b=a/b;if(b>1)b=1;if(b<0)b=0;if(this.orientation==="vertical")b=1-b;a=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+b*a)},_start:function(a,b){var c={handle:this.handles[b],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(b); +c.values=this.values()}return this._trigger("start",a,c)},_slide:function(a,b,c){var f;if(this.options.values&&this.options.values.length){f=this.values(b?0:1);if(this.options.values.length===2&&this.options.range===true&&(b===0&&c>f||b===1&&c1){this.options.values[a]=this._trimAlignValue(b);this._refreshValue();this._change(null,a)}else if(arguments.length)if(d.isArray(arguments[0])){c=this.options.values;f=arguments[0];for(e=0;e=this._valueMax())return this._valueMax();var b=this.options.step>0?this.options.step:1,c=(a-this._valueMin())%b;a=a-c;if(Math.abs(c)*2>=b)a+=c>0?b:-b;return parseFloat(a.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var a= +this.options.range,b=this.options,c=this,f=!this._animateOff?b.animate:false,e,j={},g,k,l,i;if(this.options.values&&this.options.values.length)this.handles.each(function(h){e=(c.values(h)-c._valueMin())/(c._valueMax()-c._valueMin())*100;j[c.orientation==="horizontal"?"left":"bottom"]=e+"%";d(this).stop(1,1)[f?"animate":"css"](j,b.animate);if(c.options.range===true)if(c.orientation==="horizontal"){if(h===0)c.range.stop(1,1)[f?"animate":"css"]({left:e+"%"},b.animate);if(h===1)c.range[f?"animate":"css"]({width:e- +g+"%"},{queue:false,duration:b.animate})}else{if(h===0)c.range.stop(1,1)[f?"animate":"css"]({bottom:e+"%"},b.animate);if(h===1)c.range[f?"animate":"css"]({height:e-g+"%"},{queue:false,duration:b.animate})}g=e});else{k=this.value();l=this._valueMin();i=this._valueMax();e=i!==l?(k-l)/(i-l)*100:0;j[c.orientation==="horizontal"?"left":"bottom"]=e+"%";this.handle.stop(1,1)[f?"animate":"css"](j,b.animate);if(a==="min"&&this.orientation==="horizontal")this.range.stop(1,1)[f?"animate":"css"]({width:e+"%"}, +b.animate);if(a==="max"&&this.orientation==="horizontal")this.range[f?"animate":"css"]({width:100-e+"%"},{queue:false,duration:b.animate});if(a==="min"&&this.orientation==="vertical")this.range.stop(1,1)[f?"animate":"css"]({height:e+"%"},b.animate);if(a==="max"&&this.orientation==="vertical")this.range[f?"animate":"css"]({height:100-e+"%"},{queue:false,duration:b.animate})}}});d.extend(d.ui.slider,{version:"1.8.16"})})(jQuery); +;/* + * jQuery UI Tabs 1.8.16 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Tabs + * + * Depends: + * jquery.ui.core.js + * jquery.ui.widget.js + */ +(function(d,p){function u(){return++v}function w(){return++x}var v=0,x=0;d.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:false,cookie:null,collapsible:false,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"
    ",remove:null,select:null,show:null,spinner:"Loading…",tabTemplate:"
  • #{label}
  • "},_create:function(){this._tabify(true)},_setOption:function(b,e){if(b=="selected")this.options.collapsible&& +e==this.options.selected||this.select(e);else{this.options[b]=e;this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+u()},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+w());return d.cookie.apply(null,[b].concat(d.makeArray(arguments)))},_ui:function(b,e){return{tab:b,panel:e,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b= +d(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(b){function e(g,f){g.css("display","");!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}var a=this,c=this.options,h=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=d(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);this.anchors.each(function(g,f){var i=d(f).attr("href"),l=i.split("#")[0],q;if(l&&(l===location.toString().split("#")[0]|| +(q=d("base")[0])&&l===q.href)){i=f.hash;f.href=i}if(h.test(i))a.panels=a.panels.add(a.element.find(a._sanitizeSelector(i)));else if(i&&i!=="#"){d.data(f,"href.tabs",i);d.data(f,"load.tabs",i.replace(/#.*$/,""));i=a._tabId(f);f.href="#"+i;f=a.element.find("#"+i);if(!f.length){f=d(c.panelTemplate).attr("id",i).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else c.disabled.push(g)});if(b){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"); +this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(c.selected===p){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){c.selected=g;return false}});if(typeof c.selected!=="number"&&c.cookie)c.selected=parseInt(a._cookie(),10);if(typeof c.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length)c.selected= +this.lis.index(this.lis.filter(".ui-tabs-selected"));c.selected=c.selected||(this.lis.length?0:-1)}else if(c.selected===null)c.selected=-1;c.selected=c.selected>=0&&this.anchors[c.selected]||c.selected<0?c.selected:0;c.disabled=d.unique(c.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(c.selected,c.disabled)!=-1&&c.disabled.splice(d.inArray(c.selected,c.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active"); +if(c.selected>=0&&this.anchors.length){a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(c.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[c.selected],a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash))[0]))});this.load(c.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else c.selected=this.lis.index(this.lis.filter(".ui-tabs-selected")); +this.element[c.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");c.cookie&&this._cookie(c.selected,c.cookie);b=0;for(var j;j=this.lis[b];b++)d(j)[d.inArray(b,c.disabled)!=-1&&!d(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");c.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(c.event!=="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+ +g)};this.lis.bind("mouseover.tabs",function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(c.fx)if(d.isArray(c.fx)){m=c.fx[0];o=c.fx[1]}else m=o=c.fx;var r=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal", +function(){e(f,o);a._trigger("show",null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},s=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")}; +this.anchors.bind(c.event+".tabs",function(){var g=this,f=d(g).closest("li"),i=a.panels.filter(":not(.ui-tabs-hide)"),l=a.element.find(a._sanitizeSelector(g.hash));if(f.hasClass("ui-tabs-selected")&&!c.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a.panels.filter(":animated").length||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}c.selected=a.anchors.index(this);a.abort();if(c.collapsible)if(f.hasClass("ui-tabs-selected")){c.selected= +-1;c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){s(g,i)}).dequeue("tabs");this.blur();return false}else if(!i.length){c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this));this.blur();return false}c.cookie&&a._cookie(c.selected,c.cookie);if(l.length){i.length&&a.element.queue("tabs",function(){s(g,i)});a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier."; +d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){if(typeof b=="string")b=this.anchors.index(this.anchors.filter("[href$="+b+"]"));return b},destroy:function(){var b=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e= +d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(c,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});b.cookie&&this._cookie(null,b.cookie);return this},add:function(b, +e,a){if(a===p)a=this.anchors.length;var c=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,b).replace(/#\{label\}/g,e));b=!b.indexOf("#")?b.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var j=c.element.find("#"+b);j.length||(j=d(h.panelTemplate).attr("id",b).data("destroy.tabs",true));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);j.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]); +j.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");j.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){c._trigger("show",null,c._ui(c.anchors[0],c.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(b){b=this._getIndex(b);var e=this.options,a=this.lis.eq(b).remove(),c=this.panels.eq(b).remove(); +if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(b+(b+1=b?--h:h});this._tabify();this._trigger("remove",null,this._ui(a.find("a")[0],c[0]));return this},enable:function(b){b=this._getIndex(b);var e=this.options;if(d.inArray(b,e.disabled)!=-1){this.lis.eq(b).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=b});this._trigger("enable",null, +this._ui(this.anchors[b],this.panels[b]));return this}},disable:function(b){b=this._getIndex(b);var e=this.options;if(b!=e.selected){this.lis.eq(b).addClass("ui-state-disabled");e.disabled.push(b);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b]))}return this},select:function(b){b=this._getIndex(b);if(b==-1)if(this.options.collapsible&&this.options.selected!=-1)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+".tabs");return this}, +load:function(b){b=this._getIndex(b);var e=this,a=this.options,c=this.anchors.eq(b)[0],h=d.data(c,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(c,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(b).addClass("ui-state-processing");if(a.spinner){var j=d("span",c);j.data("label.tabs",j.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){e.element.find(e._sanitizeSelector(c.hash)).html(k);e._cleanup();a.cache&&d.data(c, +"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.error(k,n,b,c)}catch(m){}}}));e.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this}, +url:function(b,e){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.16"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(b,e){var a=this,c=this.options,h=a._rotate||(a._rotate=function(j){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=c.selected;a.select(++k'))}function N(a){return a.bind("mouseout", +function(b){b=d(b.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");b.length&&b.removeClass("ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover")}).bind("mouseover",function(b){b=d(b.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");if(!(d.datepicker._isDisabledDatepicker(J.inline?a.parent()[0]:J.input[0])||!b.length)){b.parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"); +b.addClass("ui-state-hover");b.hasClass("ui-datepicker-prev")&&b.addClass("ui-datepicker-prev-hover");b.hasClass("ui-datepicker-next")&&b.addClass("ui-datepicker-next-hover")}})}function H(a,b){d.extend(a,b);for(var c in b)if(b[c]==null||b[c]==C)a[c]=b[c];return a}d.extend(d.ui,{datepicker:{version:"1.8.16"}});var B=(new Date).getTime(),J;d.extend(M.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv}, +setDefaults:function(a){H(this._defaults,a||{});return this},_attachDatepicker:function(a,b){var c=null;for(var e in this._defaults){var f=a.getAttribute("date:"+e);if(f){c=c||{};try{c[e]=eval(f)}catch(h){c[e]=f}}}e=a.nodeName.toLowerCase();f=e=="div"||e=="span";if(!a.id){this.uuid+=1;a.id="dp"+this.uuid}var i=this._newInst(d(a),f);i.settings=d.extend({},b||{},c||{});if(e=="input")this._connectDatepicker(a,i);else f&&this._inlineDatepicker(a,i)},_newInst:function(a,b){return{id:a[0].id.replace(/([^A-Za-z0-9_-])/g, +"\\\\$1"),input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:b,dpDiv:!b?this.dpDiv:N(d('
    '))}},_connectDatepicker:function(a,b){var c=d(a);b.append=d([]);b.trigger=d([]);if(!c.hasClass(this.markerClassName)){this._attachments(c,b);c.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker", +function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});this._autoSize(b);d.data(a,"datepicker",b);b.settings.disabled&&this._disableDatepicker(a)}},_attachments:function(a,b){var c=this._get(b,"appendText"),e=this._get(b,"isRTL");b.append&&b.append.remove();if(c){b.append=d(''+c+"");a[e?"before":"after"](b.append)}a.unbind("focus",this._showDatepicker);b.trigger&&b.trigger.remove();c=this._get(b,"showOn");if(c== +"focus"||c=="both")a.focus(this._showDatepicker);if(c=="button"||c=="both"){c=this._get(b,"buttonText");var f=this._get(b,"buttonImage");b.trigger=d(this._get(b,"buttonImageOnly")?d("").addClass(this._triggerClass).attr({src:f,alt:c,title:c}):d('').addClass(this._triggerClass).html(f==""?c:d("").attr({src:f,alt:c,title:c})));a[e?"before":"after"](b.trigger);b.trigger.click(function(){d.datepicker._datepickerShowing&&d.datepicker._lastInput==a[0]?d.datepicker._hideDatepicker(): +d.datepicker._showDatepicker(a[0]);return false})}},_autoSize:function(a){if(this._get(a,"autoSize")&&!a.inline){var b=new Date(2009,11,20),c=this._get(a,"dateFormat");if(c.match(/[DM]/)){var e=function(f){for(var h=0,i=0,g=0;gh){h=f[g].length;i=g}return i};b.setMonth(e(this._get(a,c.match(/MM/)?"monthNames":"monthNamesShort")));b.setDate(e(this._get(a,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-b.getDay())}a.input.attr("size",this._formatDate(a,b).length)}},_inlineDatepicker:function(a, +b){var c=d(a);if(!c.hasClass(this.markerClassName)){c.addClass(this.markerClassName).append(b.dpDiv).bind("setData.datepicker",function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});d.data(a,"datepicker",b);this._setDate(b,this._getDefaultDate(b),true);this._updateDatepicker(b);this._updateAlternate(b);b.settings.disabled&&this._disableDatepicker(a);b.dpDiv.css("display","block")}},_dialogDatepicker:function(a,b,c,e,f){a=this._dialogInst;if(!a){this.uuid+= +1;this._dialogInput=d('');this._dialogInput.keydown(this._doKeyDown);d("body").append(this._dialogInput);a=this._dialogInst=this._newInst(this._dialogInput,false);a.settings={};d.data(this._dialogInput[0],"datepicker",a)}H(a.settings,e||{});b=b&&b.constructor==Date?this._formatDate(a,b):b;this._dialogInput.val(b);this._pos=f?f.length?f:[f.pageX,f.pageY]:null;if(!this._pos)this._pos=[document.documentElement.clientWidth/ +2-100+(document.documentElement.scrollLeft||document.body.scrollLeft),document.documentElement.clientHeight/2-150+(document.documentElement.scrollTop||document.body.scrollTop)];this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px");a.settings.onSelect=c;this._inDialog=true;this.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);d.blockUI&&d.blockUI(this.dpDiv);d.data(this._dialogInput[0],"datepicker",a);return this},_destroyDatepicker:function(a){var b= +d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();d.removeData(a,"datepicker");if(e=="input"){c.append.remove();c.trigger.remove();b.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)}else if(e=="div"||e=="span")b.removeClass(this.markerClassName).empty()}},_enableDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e= +a.nodeName.toLowerCase();if(e=="input"){a.disabled=false;c.trigger.filter("button").each(function(){this.disabled=false}).end().filter("img").css({opacity:"1.0",cursor:""})}else if(e=="div"||e=="span"){b=b.children("."+this._inlineClass);b.children().removeClass("ui-state-disabled");b.find("select.ui-datepicker-month, select.ui-datepicker-year").removeAttr("disabled")}this._disabledInputs=d.map(this._disabledInputs,function(f){return f==a?null:f})}},_disableDatepicker:function(a){var b=d(a),c=d.data(a, +"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if(e=="input"){a.disabled=true;c.trigger.filter("button").each(function(){this.disabled=true}).end().filter("img").css({opacity:"0.5",cursor:"default"})}else if(e=="div"||e=="span"){b=b.children("."+this._inlineClass);b.children().addClass("ui-state-disabled");b.find("select.ui-datepicker-month, select.ui-datepicker-year").attr("disabled","disabled")}this._disabledInputs=d.map(this._disabledInputs,function(f){return f== +a?null:f});this._disabledInputs[this._disabledInputs.length]=a}},_isDisabledDatepicker:function(a){if(!a)return false;for(var b=0;b-1}},_doKeyUp:function(a){a=d.datepicker._getInst(a.target);if(a.input.val()!=a.lastVal)try{if(d.datepicker.parseDate(d.datepicker._get(a,"dateFormat"),a.input?a.input.val():null,d.datepicker._getFormatConfig(a))){d.datepicker._setDateFromField(a);d.datepicker._updateAlternate(a);d.datepicker._updateDatepicker(a)}}catch(b){d.datepicker.log(b)}return true},_showDatepicker:function(a){a=a.target||a;if(a.nodeName.toLowerCase()!="input")a=d("input", +a.parentNode)[0];if(!(d.datepicker._isDisabledDatepicker(a)||d.datepicker._lastInput==a)){var b=d.datepicker._getInst(a);if(d.datepicker._curInst&&d.datepicker._curInst!=b){d.datepicker._datepickerShowing&&d.datepicker._triggerOnClose(d.datepicker._curInst);d.datepicker._curInst.dpDiv.stop(true,true)}var c=d.datepicker._get(b,"beforeShow");c=c?c.apply(a,[a,b]):{};if(c!==false){H(b.settings,c);b.lastVal=null;d.datepicker._lastInput=a;d.datepicker._setDateFromField(b);if(d.datepicker._inDialog)a.value= +"";if(!d.datepicker._pos){d.datepicker._pos=d.datepicker._findPos(a);d.datepicker._pos[1]+=a.offsetHeight}var e=false;d(a).parents().each(function(){e|=d(this).css("position")=="fixed";return!e});if(e&&d.browser.opera){d.datepicker._pos[0]-=document.documentElement.scrollLeft;d.datepicker._pos[1]-=document.documentElement.scrollTop}c={left:d.datepicker._pos[0],top:d.datepicker._pos[1]};d.datepicker._pos=null;b.dpDiv.empty();b.dpDiv.css({position:"absolute",display:"block",top:"-1000px"});d.datepicker._updateDatepicker(b); +c=d.datepicker._checkOffset(b,c,e);b.dpDiv.css({position:d.datepicker._inDialog&&d.blockUI?"static":e?"fixed":"absolute",display:"none",left:c.left+"px",top:c.top+"px"});if(!b.inline){c=d.datepicker._get(b,"showAnim");var f=d.datepicker._get(b,"duration"),h=function(){var i=b.dpDiv.find("iframe.ui-datepicker-cover");if(i.length){var g=d.datepicker._getBorders(b.dpDiv);i.css({left:-g[0],top:-g[1],width:b.dpDiv.outerWidth(),height:b.dpDiv.outerHeight()})}};b.dpDiv.zIndex(d(a).zIndex()+1);d.datepicker._datepickerShowing= +true;d.effects&&d.effects[c]?b.dpDiv.show(c,d.datepicker._get(b,"showOptions"),f,h):b.dpDiv[c||"show"](c?f:null,h);if(!c||!f)h();b.input.is(":visible")&&!b.input.is(":disabled")&&b.input.focus();d.datepicker._curInst=b}}}},_updateDatepicker:function(a){this.maxRows=4;var b=d.datepicker._getBorders(a.dpDiv);J=a;a.dpDiv.empty().append(this._generateHTML(a));var c=a.dpDiv.find("iframe.ui-datepicker-cover");c.length&&c.css({left:-b[0],top:-b[1],width:a.dpDiv.outerWidth(),height:a.dpDiv.outerHeight()}); +a.dpDiv.find("."+this._dayOverClass+" a").mouseover();b=this._getNumberOfMonths(a);c=b[1];a.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");c>1&&a.dpDiv.addClass("ui-datepicker-multi-"+c).css("width",17*c+"em");a.dpDiv[(b[0]!=1||b[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi");a.dpDiv[(this._get(a,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl");a==d.datepicker._curInst&&d.datepicker._datepickerShowing&&a.input&&a.input.is(":visible")&& +!a.input.is(":disabled")&&a.input[0]!=document.activeElement&&a.input.focus();if(a.yearshtml){var e=a.yearshtml;setTimeout(function(){e===a.yearshtml&&a.yearshtml&&a.dpDiv.find("select.ui-datepicker-year:first").replaceWith(a.yearshtml);e=a.yearshtml=null},0)}},_getBorders:function(a){var b=function(c){return{thin:1,medium:2,thick:3}[c]||c};return[parseFloat(b(a.css("border-left-width"))),parseFloat(b(a.css("border-top-width")))]},_checkOffset:function(a,b,c){var e=a.dpDiv.outerWidth(),f=a.dpDiv.outerHeight(), +h=a.input?a.input.outerWidth():0,i=a.input?a.input.outerHeight():0,g=document.documentElement.clientWidth+d(document).scrollLeft(),j=document.documentElement.clientHeight+d(document).scrollTop();b.left-=this._get(a,"isRTL")?e-h:0;b.left-=c&&b.left==a.input.offset().left?d(document).scrollLeft():0;b.top-=c&&b.top==a.input.offset().top+i?d(document).scrollTop():0;b.left-=Math.min(b.left,b.left+e>g&&g>e?Math.abs(b.left+e-g):0);b.top-=Math.min(b.top,b.top+f>j&&j>f?Math.abs(f+i):0);return b},_findPos:function(a){for(var b= +this._get(this._getInst(a),"isRTL");a&&(a.type=="hidden"||a.nodeType!=1||d.expr.filters.hidden(a));)a=a[b?"previousSibling":"nextSibling"];a=d(a).offset();return[a.left,a.top]},_triggerOnClose:function(a){var b=this._get(a,"onClose");if(b)b.apply(a.input?a.input[0]:null,[a.input?a.input.val():"",a])},_hideDatepicker:function(a){var b=this._curInst;if(!(!b||a&&b!=d.data(a,"datepicker")))if(this._datepickerShowing){a=this._get(b,"showAnim");var c=this._get(b,"duration"),e=function(){d.datepicker._tidyDialog(b); +this._curInst=null};d.effects&&d.effects[a]?b.dpDiv.hide(a,d.datepicker._get(b,"showOptions"),c,e):b.dpDiv[a=="slideDown"?"slideUp":a=="fadeIn"?"fadeOut":"hide"](a?c:null,e);a||e();d.datepicker._triggerOnClose(b);this._datepickerShowing=false;this._lastInput=null;if(this._inDialog){this._dialogInput.css({position:"absolute",left:"0",top:"-100px"});if(d.blockUI){d.unblockUI();d("body").append(this.dpDiv)}}this._inDialog=false}},_tidyDialog:function(a){a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")}, +_checkExternalClick:function(a){if(d.datepicker._curInst){a=d(a.target);a[0].id!=d.datepicker._mainDivId&&a.parents("#"+d.datepicker._mainDivId).length==0&&!a.hasClass(d.datepicker.markerClassName)&&!a.hasClass(d.datepicker._triggerClass)&&d.datepicker._datepickerShowing&&!(d.datepicker._inDialog&&d.blockUI)&&d.datepicker._hideDatepicker()}},_adjustDate:function(a,b,c){a=d(a);var e=this._getInst(a[0]);if(!this._isDisabledDatepicker(a[0])){this._adjustInstDate(e,b+(c=="M"?this._get(e,"showCurrentAtPos"): +0),c);this._updateDatepicker(e)}},_gotoToday:function(a){a=d(a);var b=this._getInst(a[0]);if(this._get(b,"gotoCurrent")&&b.currentDay){b.selectedDay=b.currentDay;b.drawMonth=b.selectedMonth=b.currentMonth;b.drawYear=b.selectedYear=b.currentYear}else{var c=new Date;b.selectedDay=c.getDate();b.drawMonth=b.selectedMonth=c.getMonth();b.drawYear=b.selectedYear=c.getFullYear()}this._notifyChange(b);this._adjustDate(a)},_selectMonthYear:function(a,b,c){a=d(a);var e=this._getInst(a[0]);e["selected"+(c=="M"? +"Month":"Year")]=e["draw"+(c=="M"?"Month":"Year")]=parseInt(b.options[b.selectedIndex].value,10);this._notifyChange(e);this._adjustDate(a)},_selectDay:function(a,b,c,e){var f=d(a);if(!(d(e).hasClass(this._unselectableClass)||this._isDisabledDatepicker(f[0]))){f=this._getInst(f[0]);f.selectedDay=f.currentDay=d("a",e).html();f.selectedMonth=f.currentMonth=b;f.selectedYear=f.currentYear=c;this._selectDate(a,this._formatDate(f,f.currentDay,f.currentMonth,f.currentYear))}},_clearDate:function(a){a=d(a); +this._getInst(a[0]);this._selectDate(a,"")},_selectDate:function(a,b){a=this._getInst(d(a)[0]);b=b!=null?b:this._formatDate(a);a.input&&a.input.val(b);this._updateAlternate(a);var c=this._get(a,"onSelect");if(c)c.apply(a.input?a.input[0]:null,[b,a]);else a.input&&a.input.trigger("change");if(a.inline)this._updateDatepicker(a);else{this._hideDatepicker();this._lastInput=a.input[0];typeof a.input[0]!="object"&&a.input.focus();this._lastInput=null}},_updateAlternate:function(a){var b=this._get(a,"altField"); +if(b){var c=this._get(a,"altFormat")||this._get(a,"dateFormat"),e=this._getDate(a),f=this.formatDate(c,e,this._getFormatConfig(a));d(b).each(function(){d(this).val(f)})}},noWeekends:function(a){a=a.getDay();return[a>0&&a<6,""]},iso8601Week:function(a){a=new Date(a.getTime());a.setDate(a.getDate()+4-(a.getDay()||7));var b=a.getTime();a.setMonth(0);a.setDate(1);return Math.floor(Math.round((b-a)/864E5)/7)+1},parseDate:function(a,b,c){if(a==null||b==null)throw"Invalid arguments";b=typeof b=="object"? +b.toString():b+"";if(b=="")return null;var e=(c?c.shortYearCutoff:null)||this._defaults.shortYearCutoff;e=typeof e!="string"?e:(new Date).getFullYear()%100+parseInt(e,10);for(var f=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,h=(c?c.dayNames:null)||this._defaults.dayNames,i=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,g=(c?c.monthNames:null)||this._defaults.monthNames,j=c=-1,l=-1,u=-1,k=false,o=function(p){(p=A+1-1){j=1;l=u;do{e=this._getDaysInMonth(c,j-1);if(l<=e)break;j++;l-=e}while(1)}v=this._daylightSavingAdjust(new Date(c,j-1,l));if(v.getFullYear()!=c||v.getMonth()+1!=j||v.getDate()!=l)throw"Invalid date";return v},ATOM:"yy-mm-dd", +COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*24*60*60*1E7,formatDate:function(a,b,c){if(!b)return"";var e=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,f=(c?c.dayNames:null)||this._defaults.dayNames,h=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort;c=(c?c.monthNames: +null)||this._defaults.monthNames;var i=function(o){(o=k+1 +12?a.getHours()+2:0);return a},_setDate:function(a,b,c){var e=!b,f=a.selectedMonth,h=a.selectedYear;b=this._restrictMinMax(a,this._determineDate(a,b,new Date));a.selectedDay=a.currentDay=b.getDate();a.drawMonth=a.selectedMonth=a.currentMonth=b.getMonth();a.drawYear=a.selectedYear=a.currentYear=b.getFullYear();if((f!=a.selectedMonth||h!=a.selectedYear)&&!c)this._notifyChange(a);this._adjustInstDate(a);if(a.input)a.input.val(e?"":this._formatDate(a))},_getDate:function(a){return!a.currentYear||a.input&& +a.input.val()==""?null:this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay))},_generateHTML:function(a){var b=new Date;b=this._daylightSavingAdjust(new Date(b.getFullYear(),b.getMonth(),b.getDate()));var c=this._get(a,"isRTL"),e=this._get(a,"showButtonPanel"),f=this._get(a,"hideIfNoPrevNext"),h=this._get(a,"navigationAsDateFormat"),i=this._getNumberOfMonths(a),g=this._get(a,"showCurrentAtPos"),j=this._get(a,"stepMonths"),l=i[0]!=1||i[1]!=1,u=this._daylightSavingAdjust(!a.currentDay? +new Date(9999,9,9):new Date(a.currentYear,a.currentMonth,a.currentDay)),k=this._getMinMaxDate(a,"min"),o=this._getMinMaxDate(a,"max");g=a.drawMonth-g;var m=a.drawYear;if(g<0){g+=12;m--}if(o){var n=this._daylightSavingAdjust(new Date(o.getFullYear(),o.getMonth()-i[0]*i[1]+1,o.getDate()));for(n=k&&nn;){g--;if(g<0){g=11;m--}}}a.drawMonth=g;a.drawYear=m;n=this._get(a,"prevText");n=!h?n:this.formatDate(n,this._daylightSavingAdjust(new Date(m,g-j,1)),this._getFormatConfig(a)); +n=this._canAdjustMonth(a,-1,m,g)?''+n+"":f?"":''+n+"";var s=this._get(a,"nextText");s=!h?s:this.formatDate(s,this._daylightSavingAdjust(new Date(m, +g+j,1)),this._getFormatConfig(a));f=this._canAdjustMonth(a,+1,m,g)?''+s+"":f?"":''+s+"";j=this._get(a,"currentText");s=this._get(a,"gotoCurrent")&& +a.currentDay?u:b;j=!h?j:this.formatDate(j,s,this._getFormatConfig(a));h=!a.inline?'":"";e=e?'
    '+(c?h:"")+(this._isInRange(a,s)?'":"")+(c?"":h)+"
    ":"";h=parseInt(this._get(a,"firstDay"),10);h=isNaN(h)?0:h;j=this._get(a,"showWeek");s=this._get(a,"dayNames");this._get(a,"dayNamesShort");var q=this._get(a,"dayNamesMin"),A=this._get(a,"monthNames"),v=this._get(a,"monthNamesShort"),p=this._get(a,"beforeShowDay"),D=this._get(a,"showOtherMonths"),K=this._get(a,"selectOtherMonths");this._get(a,"calculateWeek");for(var E=this._getDefaultDate(a),w="",x=0;x1)switch(G){case 0:y+=" ui-datepicker-group-first";t=" ui-corner-"+(c?"right":"left");break;case i[1]-1:y+=" ui-datepicker-group-last";t=" ui-corner-"+(c?"left":"right");break;default:y+=" ui-datepicker-group-middle";t="";break}y+='">'}y+='
    '+(/all|left/.test(t)&& +x==0?c?f:n:"")+(/all|right/.test(t)&&x==0?c?n:f:"")+this._generateMonthYearHeader(a,g,m,k,o,x>0||G>0,A,v)+'
    ';var z=j?'":"";for(t=0;t<7;t++){var r=(t+h)%7;z+="=5?' class="ui-datepicker-week-end"':"")+'>'+q[r]+""}y+=z+"";z=this._getDaysInMonth(m,g);if(m==a.selectedYear&&g==a.selectedMonth)a.selectedDay=Math.min(a.selectedDay, +z);t=(this._getFirstDayOfMonth(m,g)-h+7)%7;z=Math.ceil((t+z)/7);this.maxRows=z=l?this.maxRows>z?this.maxRows:z:z;r=this._daylightSavingAdjust(new Date(m,g,1-t));for(var Q=0;Q";var R=!j?"":'";for(t=0;t<7;t++){var I=p?p.apply(a.input?a.input[0]:null,[r]):[true,""],F=r.getMonth()!=g,L=F&&!K||!I[0]||k&&ro;R+='";r.setDate(r.getDate()+1);r=this._daylightSavingAdjust(r)}y+=R+""}g++;if(g>11){g=0;m++}y+="
    '+this._get(a,"weekHeader")+"
    '+this._get(a,"calculateWeek")(r)+""+(F&&!D?" ":L?''+ +r.getDate()+"":''+r.getDate()+"")+"
    "+(l?""+(i[0]>0&&G==i[1]-1?'
    ':""):"");O+=y}w+=O}w+=e+(d.browser.msie&&parseInt(d.browser.version,10)<7&&!a.inline?'': +"");a._keyEvent=false;return w},_generateMonthYearHeader:function(a,b,c,e,f,h,i,g){var j=this._get(a,"changeMonth"),l=this._get(a,"changeYear"),u=this._get(a,"showMonthAfterYear"),k='
    ',o="";if(h||!j)o+=''+i[b]+"";else{i=e&&e.getFullYear()==c;var m=f&&f.getFullYear()==c;o+='"}u||(k+=o+(h||!(j&&l)?" ":""));if(!a.yearshtml){a.yearshtml="";if(h||!l)k+=''+c+"";else{g=this._get(a,"yearRange").split(":");var s=(new Date).getFullYear();i=function(q){q=q.match(/c[+-].*/)?c+parseInt(q.substring(1),10):q.match(/[+-].*/)?s+parseInt(q,10):parseInt(q,10);return isNaN(q)?s:q};b=i(g[0]);g=Math.max(b,i(g[1]||""));b=e?Math.max(b, +e.getFullYear()):b;g=f?Math.min(g,f.getFullYear()):g;for(a.yearshtml+='";k+=a.yearshtml;a.yearshtml=null}}k+=this._get(a,"yearSuffix");if(u)k+=(h||!(j&&l)?" ":"")+o;k+="
    ";return k},_adjustInstDate:function(a,b,c){var e=a.drawYear+(c=="Y"?b:0),f=a.drawMonth+ +(c=="M"?b:0);b=Math.min(a.selectedDay,this._getDaysInMonth(e,f))+(c=="D"?b:0);e=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(e,f,b)));a.selectedDay=e.getDate();a.drawMonth=a.selectedMonth=e.getMonth();a.drawYear=a.selectedYear=e.getFullYear();if(c=="M"||c=="Y")this._notifyChange(a)},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");b=c&&ba?a:b},_notifyChange:function(a){var b=this._get(a,"onChangeMonthYear");if(b)b.apply(a.input? +a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])},_getNumberOfMonths:function(a){a=this._get(a,"numberOfMonths");return a==null?[1,1]:typeof a=="number"?[1,a]:a},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a,b){return 32-this._daylightSavingAdjust(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,e){var f=this._getNumberOfMonths(a);c=this._daylightSavingAdjust(new Date(c, +e+(b<0?b:f[0]*f[1]),1));b<0&&c.setDate(this._getDaysInMonth(c.getFullYear(),c.getMonth()));return this._isInRange(a,c)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!a||b.getTime()<=a.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff");b=typeof b!="string"?b:(new Date).getFullYear()%100+parseInt(b,10);return{shortYearCutoff:b,dayNamesShort:this._get(a,"dayNamesShort"),dayNames:this._get(a, +"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,e){if(!b){a.currentDay=a.selectedDay;a.currentMonth=a.selectedMonth;a.currentYear=a.selectedYear}b=b?typeof b=="object"?b:this._daylightSavingAdjust(new Date(e,c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),b,this._getFormatConfig(a))}});d.fn.datepicker=function(a){if(!this.length)return this; +if(!d.datepicker.initialized){d(document).mousedown(d.datepicker._checkExternalClick).find("body").append(d.datepicker.dpDiv);d.datepicker.initialized=true}var b=Array.prototype.slice.call(arguments,1);if(typeof a=="string"&&(a=="isDisabled"||a=="getDate"||a=="widget"))return d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this[0]].concat(b));if(a=="option"&&arguments.length==2&&typeof arguments[1]=="string")return d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this[0]].concat(b));return this.each(function(){typeof a== +"string"?d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this].concat(b)):d.datepicker._attachDatepicker(this,a)})};d.datepicker=new M;d.datepicker.initialized=false;d.datepicker.uuid=(new Date).getTime();d.datepicker.version="1.8.16";window["DP_jQuery_"+B]=d})(jQuery); +;/* + * jQuery UI Progressbar 1.8.16 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Progressbar + * + * Depends: + * jquery.ui.core.js + * jquery.ui.widget.js + */ +(function(b,d){b.widget("ui.progressbar",{options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()});this.valueDiv=b("
    ").appendTo(this.element);this.oldValue=this._value();this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"); +this.valueDiv.remove();b.Widget.prototype.destroy.apply(this,arguments)},value:function(a){if(a===d)return this._value();this._setOption("value",a);return this},_setOption:function(a,c){if(a==="value"){this.options.value=c;this._refreshValue();this._value()===this.options.max&&this._trigger("complete")}b.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var a=this.options.value;if(typeof a!=="number")a=0;return Math.min(this.options.max,Math.max(this.min,a))},_percentage:function(){return 100* +this._value()/this.options.max},_refreshValue:function(){var a=this.value(),c=this._percentage();if(this.oldValue!==a){this.oldValue=a;this._trigger("change")}this.valueDiv.toggle(a>this.min).toggleClass("ui-corner-right",a===this.options.max).width(c.toFixed(0)+"%");this.element.attr("aria-valuenow",a)}});b.extend(b.ui.progressbar,{version:"1.8.16"})})(jQuery); +;/* + * jQuery UI Effects 1.8.16 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Effects/ + */ +jQuery.effects||function(f,j){function m(c){var a;if(c&&c.constructor==Array&&c.length==3)return c;if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c))return[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10)];if(a=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c))return[parseFloat(a[1])*2.55,parseFloat(a[2])*2.55,parseFloat(a[3])*2.55];if(a=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c))return[parseInt(a[1], +16),parseInt(a[2],16),parseInt(a[3],16)];if(a=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c))return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)];if(/rgba\(0, 0, 0, 0\)/.exec(c))return n.transparent;return n[f.trim(c).toLowerCase()]}function s(c,a){var b;do{b=f.curCSS(c,a);if(b!=""&&b!="transparent"||f.nodeName(c,"body"))break;a="backgroundColor"}while(c=c.parentNode);return m(b)}function o(){var c=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle, +a={},b,d;if(c&&c.length&&c[0]&&c[c[0]])for(var e=c.length;e--;){b=c[e];if(typeof c[b]=="string"){d=b.replace(/\-(\w)/g,function(g,h){return h.toUpperCase()});a[d]=c[b]}}else for(b in c)if(typeof c[b]==="string")a[b]=c[b];return a}function p(c){var a,b;for(a in c){b=c[a];if(b==null||f.isFunction(b)||a in t||/scrollbar/.test(a)||!/color/i.test(a)&&isNaN(parseFloat(b)))delete c[a]}return c}function u(c,a){var b={_:0},d;for(d in a)if(c[d]!=a[d])b[d]=a[d];return b}function k(c,a,b,d){if(typeof c=="object"){d= +a;b=null;a=c;c=a.effect}if(f.isFunction(a)){d=a;b=null;a={}}if(typeof a=="number"||f.fx.speeds[a]){d=b;b=a;a={}}if(f.isFunction(b)){d=b;b=null}a=a||{};b=b||a.duration;b=f.fx.off?0:typeof b=="number"?b:b in f.fx.speeds?f.fx.speeds[b]:f.fx.speeds._default;d=d||a.complete;return[c,a,b,d]}function l(c){if(!c||typeof c==="number"||f.fx.speeds[c])return true;if(typeof c==="string"&&!f.effects[c])return true;return false}f.effects={};f.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor", +"borderTopColor","borderColor","color","outlineColor"],function(c,a){f.fx.step[a]=function(b){if(!b.colorInit){b.start=s(b.elem,a);b.end=m(b.end);b.colorInit=true}b.elem.style[a]="rgb("+Math.max(Math.min(parseInt(b.pos*(b.end[0]-b.start[0])+b.start[0],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[1]-b.start[1])+b.start[1],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[2]-b.start[2])+b.start[2],10),255),0)+")"}});var n={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0, +0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211, +211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},q=["add","remove","toggle"],t={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};f.effects.animateClass=function(c,a,b, +d){if(f.isFunction(b)){d=b;b=null}return this.queue(function(){var e=f(this),g=e.attr("style")||" ",h=p(o.call(this)),r,v=e.attr("class");f.each(q,function(w,i){c[i]&&e[i+"Class"](c[i])});r=p(o.call(this));e.attr("class",v);e.animate(u(h,r),{queue:false,duration:a,easing:b,complete:function(){f.each(q,function(w,i){c[i]&&e[i+"Class"](c[i])});if(typeof e.attr("style")=="object"){e.attr("style").cssText="";e.attr("style").cssText=g}else e.attr("style",g);d&&d.apply(this,arguments);f.dequeue(this)}})})}; +f.fn.extend({_addClass:f.fn.addClass,addClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{add:c},a,b,d]):this._addClass(c)},_removeClass:f.fn.removeClass,removeClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{remove:c},a,b,d]):this._removeClass(c)},_toggleClass:f.fn.toggleClass,toggleClass:function(c,a,b,d,e){return typeof a=="boolean"||a===j?b?f.effects.animateClass.apply(this,[a?{add:c}:{remove:c},b,d,e]):this._toggleClass(c,a):f.effects.animateClass.apply(this, +[{toggle:c},a,b,d])},switchClass:function(c,a,b,d,e){return f.effects.animateClass.apply(this,[{add:a,remove:c},b,d,e])}});f.extend(f.effects,{version:"1.8.16",save:function(c,a){for(var b=0;b").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}), +d=document.activeElement;c.wrap(b);if(c[0]===d||f.contains(c[0],d))f(d).focus();b=c.parent();if(c.css("position")=="static"){b.css({position:"relative"});c.css({position:"relative"})}else{f.extend(a,{position:c.css("position"),zIndex:c.css("z-index")});f.each(["top","left","bottom","right"],function(e,g){a[g]=c.css(g);if(isNaN(parseInt(a[g],10)))a[g]="auto"});c.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})}return b.css(a).show()},removeWrapper:function(c){var a,b=document.activeElement; +if(c.parent().is(".ui-effects-wrapper")){a=c.parent().replaceWith(c);if(c[0]===b||f.contains(c[0],b))f(b).focus();return a}return c},setTransition:function(c,a,b,d){d=d||{};f.each(a,function(e,g){unit=c.cssUnit(g);if(unit[0]>0)d[g]=unit[0]*b+unit[1]});return d}});f.fn.extend({effect:function(c){var a=k.apply(this,arguments),b={options:a[1],duration:a[2],callback:a[3]};a=b.options.mode;var d=f.effects[c];if(f.fx.off||!d)return a?this[a](b.duration,b.callback):this.each(function(){b.callback&&b.callback.call(this)}); +return d.call(this,b)},_show:f.fn.show,show:function(c){if(l(c))return this._show.apply(this,arguments);else{var a=k.apply(this,arguments);a[1].mode="show";return this.effect.apply(this,a)}},_hide:f.fn.hide,hide:function(c){if(l(c))return this._hide.apply(this,arguments);else{var a=k.apply(this,arguments);a[1].mode="hide";return this.effect.apply(this,a)}},__toggle:f.fn.toggle,toggle:function(c){if(l(c)||typeof c==="boolean"||f.isFunction(c))return this.__toggle.apply(this,arguments);else{var a=k.apply(this, +arguments);a[1].mode="toggle";return this.effect.apply(this,a)}},cssUnit:function(c){var a=this.css(c),b=[];f.each(["em","px","%","pt"],function(d,e){if(a.indexOf(e)>0)b=[parseFloat(a),e]});return b}});f.easing.jswing=f.easing.swing;f.extend(f.easing,{def:"easeOutQuad",swing:function(c,a,b,d,e){return f.easing[f.easing.def](c,a,b,d,e)},easeInQuad:function(c,a,b,d,e){return d*(a/=e)*a+b},easeOutQuad:function(c,a,b,d,e){return-d*(a/=e)*(a-2)+b},easeInOutQuad:function(c,a,b,d,e){if((a/=e/2)<1)return d/ +2*a*a+b;return-d/2*(--a*(a-2)-1)+b},easeInCubic:function(c,a,b,d,e){return d*(a/=e)*a*a+b},easeOutCubic:function(c,a,b,d,e){return d*((a=a/e-1)*a*a+1)+b},easeInOutCubic:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a+b;return d/2*((a-=2)*a*a+2)+b},easeInQuart:function(c,a,b,d,e){return d*(a/=e)*a*a*a+b},easeOutQuart:function(c,a,b,d,e){return-d*((a=a/e-1)*a*a*a-1)+b},easeInOutQuart:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a+b;return-d/2*((a-=2)*a*a*a-2)+b},easeInQuint:function(c,a,b, +d,e){return d*(a/=e)*a*a*a*a+b},easeOutQuint:function(c,a,b,d,e){return d*((a=a/e-1)*a*a*a*a+1)+b},easeInOutQuint:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a*a+b;return d/2*((a-=2)*a*a*a*a+2)+b},easeInSine:function(c,a,b,d,e){return-d*Math.cos(a/e*(Math.PI/2))+d+b},easeOutSine:function(c,a,b,d,e){return d*Math.sin(a/e*(Math.PI/2))+b},easeInOutSine:function(c,a,b,d,e){return-d/2*(Math.cos(Math.PI*a/e)-1)+b},easeInExpo:function(c,a,b,d,e){return a==0?b:d*Math.pow(2,10*(a/e-1))+b},easeOutExpo:function(c, +a,b,d,e){return a==e?b+d:d*(-Math.pow(2,-10*a/e)+1)+b},easeInOutExpo:function(c,a,b,d,e){if(a==0)return b;if(a==e)return b+d;if((a/=e/2)<1)return d/2*Math.pow(2,10*(a-1))+b;return d/2*(-Math.pow(2,-10*--a)+2)+b},easeInCirc:function(c,a,b,d,e){return-d*(Math.sqrt(1-(a/=e)*a)-1)+b},easeOutCirc:function(c,a,b,d,e){return d*Math.sqrt(1-(a=a/e-1)*a)+b},easeInOutCirc:function(c,a,b,d,e){if((a/=e/2)<1)return-d/2*(Math.sqrt(1-a*a)-1)+b;return d/2*(Math.sqrt(1-(a-=2)*a)+1)+b},easeInElastic:function(c,a,b, +d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e)==1)return b+d;g||(g=e*0.3);if(h").css({position:"absolute",visibility:"visible",left:-f*(h/d),top:-e*(i/c)}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:h/d,height:i/c,left:g.left+f*(h/d)+(a.options.mode=="show"?(f-Math.floor(d/2))*(h/d):0),top:g.top+e*(i/c)+(a.options.mode=="show"?(e-Math.floor(c/2))*(i/c):0),opacity:a.options.mode=="show"?0:1}).animate({left:g.left+f*(h/d)+(a.options.mode=="show"?0:(f-Math.floor(d/2))*(h/d)),top:g.top+ +e*(i/c)+(a.options.mode=="show"?0:(e-Math.floor(c/2))*(i/c)),opacity:a.options.mode=="show"?1:0},a.duration||500);setTimeout(function(){a.options.mode=="show"?b.css({visibility:"visible"}):b.css({visibility:"visible"}).hide();a.callback&&a.callback.apply(b[0]);b.dequeue();j("div.ui-effects-explode").remove()},a.duration||500)})}})(jQuery); +;/* + * jQuery UI Effects Fade 1.8.16 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Effects/Fade + * + * Depends: + * jquery.effects.core.js + */ +(function(b){b.effects.fade=function(a){return this.queue(function(){var c=b(this),d=b.effects.setMode(c,a.options.mode||"hide");c.animate({opacity:d},{queue:false,duration:a.duration,easing:a.options.easing,complete:function(){a.callback&&a.callback.apply(this,arguments);c.dequeue()}})})}})(jQuery); +;/* + * jQuery UI Effects Fold 1.8.16 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Effects/Fold + * + * Depends: + * jquery.effects.core.js + */ +(function(c){c.effects.fold=function(a){return this.queue(function(){var b=c(this),j=["position","top","bottom","left","right"],d=c.effects.setMode(b,a.options.mode||"hide"),g=a.options.size||15,h=!!a.options.horizFirst,k=a.duration?a.duration/2:c.fx.speeds._default/2;c.effects.save(b,j);b.show();var e=c.effects.createWrapper(b).css({overflow:"hidden"}),f=d=="show"!=h,l=f?["width","height"]:["height","width"];f=f?[e.width(),e.height()]:[e.height(),e.width()];var i=/([0-9]+)%/.exec(g);if(i)g=parseInt(i[1], +10)/100*f[d=="hide"?0:1];if(d=="show")e.css(h?{height:0,width:g}:{height:g,width:0});h={};i={};h[l[0]]=d=="show"?f[0]:g;i[l[1]]=d=="show"?f[1]:0;e.animate(h,k,a.options.easing).animate(i,k,a.options.easing,function(){d=="hide"&&b.hide();c.effects.restore(b,j);c.effects.removeWrapper(b);a.callback&&a.callback.apply(b[0],arguments);b.dequeue()})})}})(jQuery); +;/* + * jQuery UI Effects Highlight 1.8.16 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Effects/Highlight + * + * Depends: + * jquery.effects.core.js + */ +(function(b){b.effects.highlight=function(c){return this.queue(function(){var a=b(this),e=["backgroundImage","backgroundColor","opacity"],d=b.effects.setMode(a,c.options.mode||"show"),f={backgroundColor:a.css("backgroundColor")};if(d=="hide")f.opacity=0;b.effects.save(a,e);a.show().css({backgroundImage:"none",backgroundColor:c.options.color||"#ffff99"}).animate(f,{queue:false,duration:c.duration,easing:c.options.easing,complete:function(){d=="hide"&&a.hide();b.effects.restore(a,e);d=="show"&&!b.support.opacity&& +this.style.removeAttribute("filter");c.callback&&c.callback.apply(this,arguments);a.dequeue()}})})}})(jQuery); +;/* + * jQuery UI Effects Pulsate 1.8.16 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Effects/Pulsate + * + * Depends: + * jquery.effects.core.js + */ +(function(d){d.effects.pulsate=function(a){return this.queue(function(){var b=d(this),c=d.effects.setMode(b,a.options.mode||"show");times=(a.options.times||5)*2-1;duration=a.duration?a.duration/2:d.fx.speeds._default/2;isVisible=b.is(":visible");animateTo=0;if(!isVisible){b.css("opacity",0).show();animateTo=1}if(c=="hide"&&isVisible||c=="show"&&!isVisible)times--;for(c=0;c').appendTo(document.body).addClass(a.options.className).css({top:d.top,left:d.left,height:b.innerHeight(),width:b.innerWidth(),position:"absolute"}).animate(c,a.duration,a.options.easing,function(){f.remove();a.callback&&a.callback.apply(b[0],arguments); +b.dequeue()})})}})(jQuery); +; \ No newline at end of file diff --git a/webapp2/src/main/resources/brat/client/lib/jquery-ui.combobox.js b/webapp2/src/main/resources/brat/client/lib/jquery-ui.combobox.js new file mode 100644 index 000000000..635e8208a --- /dev/null +++ b/webapp2/src/main/resources/brat/client/lib/jquery-ui.combobox.js @@ -0,0 +1,243 @@ +/* Adapted from http://jqueryui.com/autocomplete/#combobox */ +/* and http://www.learningjquery.com/2010/06/a-jquery-ui-combobox-under-the-hood/ */ + +(function($) { + $.widget( "ui.combobox", { + _create: function() { + var self = this; + var select = this.element.hide(), + selected = select.children( ":selected" ), + value = selected.val() ? selected.text() : ""; + var input = $( "" ) + .insertAfter(select) + .addClass("ui-combobox-input ui-state-default") + .focus(function() { + input.removeClass('ui-state-default'); + input.autocomplete("search", ""); + }) + .blur(function() { + input.addClass('ui-state-default'); + }) + .val( value ) + .keydown(function(evt) { + var text, start; + if (evt.keyCode == $.ui.keyCode.BACKSPACE + && (start = input[0].selectionStart) > 0 + && (end = input[0].selectionEnd) != start + && end == (text = input.val()).length) { + input.val(text = text.substring(0, start - 1)); + evt.preventDefault(); + return false; + } + }) + .autocomplete({ + delay: 0, + minLength: 0, + source: function(request, response) { + var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex(request.term), "i" ); + options = select.children("option").map(function() { + var text = $( this ).text(); + if ( this.value && ( !request.term || matcher.test(text) ) ) + return { + label: text.replace( + new RegExp( + "(?![^&;]+;)(?!<[^<>]*)(" + + $.ui.autocomplete.escapeRegex(request.term) + + ")(?![^<>]*>)(?![^&;]+;)", "gi"), + "$1"), + value: text, + option: this + }; + }); + response(options); + if (request.term.length && options.length) { + var text = options[0].value; + input.val(text); + input[0].selectionStart = request.term.length; + input[0].selectionEnd = text.length; + options[0].option.selected = true; + } else { + select.val(''); + } + }, + select: function( event, ui ) { + ui.item.option.selected = true; + self._trigger( "selected", event, { + item: ui.item.option + }); + }, + change: function(event, ui) { + if ( !ui.item ) { + var valid = false; + findMatch = function(matcher) { + select.children( "option" ).each(function() { + if ( this.value.match( matcher ) ) { + this.selected = valid = true; + input.val(this.value); + return false; + } + }); + }; + var escapedMatcher = $.ui.autocomplete.escapeRegex( $(this).val() ); + findMatch(new RegExp( "^" + escapedMatcher + "$", "i" )); + if ( !valid ) { + findMatch(new RegExp( "^" + escapedMatcher, "i" )); + } + if ( !valid ) { + // remove invalid value, as it didn't match anything + $( this ).val( "" ); + select.val( "" ); + return false; + } + } + } + }) + .addClass("ui-widget ui-widget-content ui-corner-all ui-combobox"); + + input.data( "ui-autocomplete" )._renderItem = function( ul, item ) { + return $( "
  • " ) + .data( "item.autocomplete", item ) + .append( "" + item.label + "" ) + .appendTo( ul ); + }; + + select.change(function(evt) { + input.val(select.val()); + }); + } + }); +})(jQuery); +/* +(function( $ ) { + $.widget( "custom.combobox", { + _create: function() { + this.wrapper = $( "" ) + .addClass( "custom-combobox" ) + .insertAfter( this.element ); + + this.element.hide(); + this._createAutocomplete(); + this._createShowAllButton(); + }, + + _createAutocomplete: function() { + var selected = this.element.children( ":selected" ), + value = selected.val() ? selected.text() : ""; + + this.input = $( "" ) + .appendTo( this.wrapper ) + .val( value ) + .attr( "title", "" ) + .addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" ) + .autocomplete({ + delay: 0, + minLength: 0, + source: $.proxy( this, "_source" ) + // }) + // .tooltip({ + // tooltipClass: "ui-state-highlight" + }); + + // this._on( this.input, { + $( this.input ).on({ + autocompleteselect: function( event, ui ) { + ui.item.option.selected = true; + $( this ).trigger( "select", event, { + item: ui.item.option + }); + }, + + autocompletechange: this._removeIfInvalid.bind(this) + }); + }, + + _createShowAllButton: function() { + var input = this.input, + wasOpen = false; + + $( "" ) + .attr( "tabIndex", -1 ) + .attr( "title", "Show All Items" ) + // .tooltip() + .appendTo( this.wrapper ) + .button({ + icons: { + primary: "ui-icon-triangle-1-s" + }, + text: false + }) + .removeClass( "ui-corner-all" ) + .addClass( "custom-combobox-toggle ui-corner-right" ) + .mousedown(function() { + wasOpen = input.autocomplete( "widget" ).is( ":visible" ); + }) + .click(function() { + input.focus(); + + // Close if already visible + if ( wasOpen ) { + return; + } + + // Pass empty string as value to search for, displaying all results + input.autocomplete( "search", "" ); + }); + }, + + _source: function( request, response ) { + var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); + response( this.element.children( "option" ).map(function() { + var text = $( this ).text(); + if ( this.value && ( !request.term || matcher.test(text) ) ) + return { + label: text, + value: text, + option: this + }; + }) ); + }, + + _removeIfInvalid: function( event, ui ) { + + // Selected an item, nothing to do + if ( ui.item ) { + return; + } + + // Search for a match (case-insensitive) + var value = this.input.val(), + valueLowerCase = value.toLowerCase(), + valid = false; + this.element.children( "option" ).each(function() { + if ( $( this ).text().toLowerCase() === valueLowerCase ) { + this.selected = valid = true; + return false; + } + }); + + // Found a match, nothing to do + if ( valid ) { + return; + } + + // Remove invalid value + this.input + .val( "" ); + // .attr( "title", value + " didn't match any item" ) + // .tooltip( "open" ); + this.element.val( "" ); + // $(this).delay(function() { + // this.input.tooltip( "close" ).attr( "title", "" ); + // }, 2500 ); + console.log(this.input); + console.log(this.input.data('ui-autocomplete')); + this.input.data( "ui-autocomplete" ).term = ""; // TODO + }, + + _destroy: function() { + this.wrapper.remove(); + this.element.show(); + } + }); +})( jQuery ); +*/ diff --git a/webapp2/src/main/resources/brat/client/lib/jquery-ui.min.js b/webapp2/src/main/resources/brat/client/lib/jquery-ui.min.js new file mode 100644 index 000000000..17eab7903 --- /dev/null +++ b/webapp2/src/main/resources/brat/client/lib/jquery-ui.min.js @@ -0,0 +1,13 @@ +/*! jQuery UI - v1.11.2 - 2014-10-16 +* http://jqueryui.com +* Includes: core.js, widget.js, mouse.js, position.js, accordion.js, autocomplete.js, button.js, datepicker.js, dialog.js, draggable.js, droppable.js, effect.js, effect-blind.js, effect-bounce.js, effect-clip.js, effect-drop.js, effect-explode.js, effect-fade.js, effect-fold.js, effect-highlight.js, effect-puff.js, effect-pulsate.js, effect-scale.js, effect-shake.js, effect-size.js, effect-slide.js, effect-transfer.js, menu.js, progressbar.js, resizable.js, selectable.js, selectmenu.js, slider.js, sortable.js, spinner.js, tabs.js, tooltip.js +* Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */ + +(function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e(jQuery)})(function(e){function t(t,s){var n,a,o,r=t.nodeName.toLowerCase();return"area"===r?(n=t.parentNode,a=n.name,t.href&&a&&"map"===n.nodeName.toLowerCase()?(o=e("img[usemap='#"+a+"']")[0],!!o&&i(o)):!1):(/input|select|textarea|button|object/.test(r)?!t.disabled:"a"===r?t.href||s:s)&&i(t)}function i(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}function s(e){for(var t,i;e.length&&e[0]!==document;){if(t=e.css("position"),("absolute"===t||"relative"===t||"fixed"===t)&&(i=parseInt(e.css("zIndex"),10),!isNaN(i)&&0!==i))return i;e=e.parent()}return 0}function n(){this._curInst=null,this._keyEvent=!1,this._disabledInputs=[],this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId="ui-datepicker-div",this._inlineClass="ui-datepicker-inline",this._appendClass="ui-datepicker-append",this._triggerClass="ui-datepicker-trigger",this._dialogClass="ui-datepicker-dialog",this._disableClass="ui-datepicker-disabled",this._unselectableClass="ui-datepicker-unselectable",this._currentClass="ui-datepicker-current-day",this._dayOverClass="ui-datepicker-days-cell-over",this.regional=[],this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:""},this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:!1,hideIfNoPrevNext:!1,navigationAsDateFormat:!1,gotoCurrent:!1,changeMonth:!1,changeYear:!1,yearRange:"c-10:c+10",showOtherMonths:!1,selectOtherMonths:!1,showWeek:!1,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:!0,showButtonPanel:!1,autoSize:!1,disabled:!1},e.extend(this._defaults,this.regional[""]),this.regional.en=e.extend(!0,{},this.regional[""]),this.regional["en-US"]=e.extend(!0,{},this.regional.en),this.dpDiv=a(e("
    "))}function a(t){var i="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return t.delegate(i,"mouseout",function(){e(this).removeClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&e(this).removeClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&e(this).removeClass("ui-datepicker-next-hover")}).delegate(i,"mouseover",o)}function o(){e.datepicker._isDisabledDatepicker(v.inline?v.dpDiv.parent()[0]:v.input[0])||(e(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),e(this).addClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&e(this).addClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&e(this).addClass("ui-datepicker-next-hover"))}function r(t,i){e.extend(t,i);for(var s in i)null==i[s]&&(t[s]=i[s]);return t}function h(e){return function(){var t=this.element.val();e.apply(this,arguments),this._refresh(),t!==this.element.val()&&this._trigger("change")}}e.ui=e.ui||{},e.extend(e.ui,{version:"1.11.2",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({scrollParent:function(t){var i=this.css("position"),s="absolute"===i,n=t?/(auto|scroll|hidden)/:/(auto|scroll)/,a=this.parents().filter(function(){var t=e(this);return s&&"static"===t.css("position")?!1:n.test(t.css("overflow")+t.css("overflow-y")+t.css("overflow-x"))}).eq(0);return"fixed"!==i&&a.length?a:e(this[0].ownerDocument||document)},uniqueId:function(){var e=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++e)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(i){return!!e.data(i,t)}}):function(t,i,s){return!!e.data(t,s[3])},focusable:function(i){return t(i,!isNaN(e.attr(i,"tabindex")))},tabbable:function(i){var s=e.attr(i,"tabindex"),n=isNaN(s);return(n||s>=0)&&t(i,!n)}}),e("
    ").outerWidth(1).jquery||e.each(["Width","Height"],function(t,i){function s(t,i,s,a){return e.each(n,function(){i-=parseFloat(e.css(t,"padding"+this))||0,s&&(i-=parseFloat(e.css(t,"border"+this+"Width"))||0),a&&(i-=parseFloat(e.css(t,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],a=i.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+i]=function(t){return void 0===t?o["inner"+i].call(this):this.each(function(){e(this).css(a,s(this,t)+"px")})},e.fn["outer"+i]=function(t,n){return"number"!=typeof t?o["outer"+i].call(this,t):this.each(function(){e(this).css(a,s(this,t,!0,n)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e("").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(i){return arguments.length?t.call(this,e.camelCase(i)):t.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.fn.extend({focus:function(t){return function(i,s){return"number"==typeof i?this.each(function(){var t=this;setTimeout(function(){e(t).focus(),s&&s.call(t)},i)}):t.apply(this,arguments)}}(e.fn.focus),disableSelection:function(){var e="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.bind(e+".ui-disableSelection",function(e){e.preventDefault()})}}(),enableSelection:function(){return this.unbind(".ui-disableSelection")},zIndex:function(t){if(void 0!==t)return this.css("zIndex",t);if(this.length)for(var i,s,n=e(this[0]);n.length&&n[0]!==document;){if(i=n.css("position"),("absolute"===i||"relative"===i||"fixed"===i)&&(s=parseInt(n.css("zIndex"),10),!isNaN(s)&&0!==s))return s;n=n.parent()}return 0}}),e.ui.plugin={add:function(t,i,s){var n,a=e.ui[t].prototype;for(n in s)a.plugins[n]=a.plugins[n]||[],a.plugins[n].push([i,s[n]])},call:function(e,t,i,s){var n,a=e.plugins[t];if(a&&(s||e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType))for(n=0;a.length>n;n++)e.options[a[n][0]]&&a[n][1].apply(e.element,i)}};var l=0,u=Array.prototype.slice;e.cleanData=function(t){return function(i){var s,n,a;for(a=0;null!=(n=i[a]);a++)try{s=e._data(n,"events"),s&&s.remove&&e(n).triggerHandler("remove")}catch(o){}t(i)}}(e.cleanData),e.widget=function(t,i,s){var n,a,o,r,h={},l=t.split(".")[0];return t=t.split(".")[1],n=l+"-"+t,s||(s=i,i=e.Widget),e.expr[":"][n.toLowerCase()]=function(t){return!!e.data(t,n)},e[l]=e[l]||{},a=e[l][t],o=e[l][t]=function(e,t){return this._createWidget?(arguments.length&&this._createWidget(e,t),void 0):new o(e,t)},e.extend(o,a,{version:s.version,_proto:e.extend({},s),_childConstructors:[]}),r=new i,r.options=e.widget.extend({},r.options),e.each(s,function(t,s){return e.isFunction(s)?(h[t]=function(){var e=function(){return i.prototype[t].apply(this,arguments)},n=function(e){return i.prototype[t].apply(this,e)};return function(){var t,i=this._super,a=this._superApply;return this._super=e,this._superApply=n,t=s.apply(this,arguments),this._super=i,this._superApply=a,t}}(),void 0):(h[t]=s,void 0)}),o.prototype=e.widget.extend(r,{widgetEventPrefix:a?r.widgetEventPrefix||t:t},h,{constructor:o,namespace:l,widgetName:t,widgetFullName:n}),a?(e.each(a._childConstructors,function(t,i){var s=i.prototype;e.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete a._childConstructors):i._childConstructors.push(o),e.widget.bridge(t,o),o},e.widget.extend=function(t){for(var i,s,n=u.call(arguments,1),a=0,o=n.length;o>a;a++)for(i in n[a])s=n[a][i],n[a].hasOwnProperty(i)&&void 0!==s&&(t[i]=e.isPlainObject(s)?e.isPlainObject(t[i])?e.widget.extend({},t[i],s):e.widget.extend({},s):s);return t},e.widget.bridge=function(t,i){var s=i.prototype.widgetFullName||t;e.fn[t]=function(n){var a="string"==typeof n,o=u.call(arguments,1),r=this;return n=!a&&o.length?e.widget.extend.apply(null,[n].concat(o)):n,a?this.each(function(){var i,a=e.data(this,s);return"instance"===n?(r=a,!1):a?e.isFunction(a[n])&&"_"!==n.charAt(0)?(i=a[n].apply(a,o),i!==a&&void 0!==i?(r=i&&i.jquery?r.pushStack(i.get()):i,!1):void 0):e.error("no such method '"+n+"' for "+t+" widget instance"):e.error("cannot call methods on "+t+" prior to initialization; "+"attempted to call method '"+n+"'")}):this.each(function(){var t=e.data(this,s);t?(t.option(n||{}),t._init&&t._init()):e.data(this,s,new i(n,this))}),r}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
    ",options:{disabled:!1,create:null},_createWidget:function(t,i){i=e(i||this.defaultElement||this)[0],this.element=e(i),this.uuid=l++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=e(),this.hoverable=e(),this.focusable=e(),i!==this&&(e.data(i,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===i&&this.destroy()}}),this.document=e(i.style?i.ownerDocument:i.document||i),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(t,i){var s,n,a,o=t;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof t)if(o={},s=t.split("."),t=s.shift(),s.length){for(n=o[t]=e.widget.extend({},this.options[t]),a=0;s.length-1>a;a++)n[s[a]]=n[s[a]]||{},n=n[s[a]];if(t=s.pop(),1===arguments.length)return void 0===n[t]?null:n[t];n[t]=i}else{if(1===arguments.length)return void 0===this.options[t]?null:this.options[t];o[t]=i}return this._setOptions(o),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,"disabled"===e&&(this.widget().toggleClass(this.widgetFullName+"-disabled",!!t),t&&(this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus"))),this},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_on:function(t,i,s){var n,a=this;"boolean"!=typeof t&&(s=i,i=t,t=!1),s?(i=n=e(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),e.each(s,function(s,o){function r(){return t||a.options.disabled!==!0&&!e(this).hasClass("ui-state-disabled")?("string"==typeof o?a[o]:o).apply(a,arguments):void 0}"string"!=typeof o&&(r.guid=o.guid=o.guid||r.guid||e.guid++);var h=s.match(/^([\w:-]*)\s*(.*)$/),l=h[1]+a.eventNamespace,u=h[2];u?n.delegate(u,l,r):i.bind(l,r)})},_off:function(t,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,t.unbind(i).undelegate(i),this.bindings=e(this.bindings.not(t).get()),this.focusable=e(this.focusable.not(t).get()),this.hoverable=e(this.hoverable.not(t).get())},_delay:function(e,t){function i(){return("string"==typeof e?s[e]:e).apply(s,arguments)}var s=this;return setTimeout(i,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,i,s){var n,a,o=this.options[t];if(s=s||{},i=e.Event(i),i.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),i.target=this.element[0],a=i.originalEvent)for(n in a)n in i||(i[n]=a[n]);return this.element.trigger(i,s),!(e.isFunction(o)&&o.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,i){e.Widget.prototype["_"+t]=function(s,n,a){"string"==typeof n&&(n={effect:n});var o,r=n?n===!0||"number"==typeof n?i:n.effect||i:t;n=n||{},"number"==typeof n&&(n={duration:n}),o=!e.isEmptyObject(n),n.complete=a,n.delay&&s.delay(n.delay),o&&e.effects&&e.effects.effect[r]?s[t](n):r!==t&&s[r]?s[r](n.duration,n.easing,a):s.queue(function(i){e(this)[t](),a&&a.call(s[0]),i()})}}),e.widget;var d=!1;e(document).mouseup(function(){d=!1}),e.widget("ui.mouse",{version:"1.11.2",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.bind("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).bind("click."+this.widgetName,function(i){return!0===e.data(i.target,t.widgetName+".preventClickEvent")?(e.removeData(i.target,t.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&this.document.unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(t){if(!d){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(t),this._mouseDownEvent=t;var i=this,s=1===t.which,n="string"==typeof this.options.cancel&&t.target.nodeName?e(t.target).closest(this.options.cancel).length:!1;return s&&!n&&this._mouseCapture(t)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(t)!==!1,!this._mouseStarted)?(t.preventDefault(),!0):(!0===e.data(t.target,this.widgetName+".preventClickEvent")&&e.removeData(t.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return i._mouseMove(e)},this._mouseUpDelegate=function(e){return i._mouseUp(e)},this.document.bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),t.preventDefault(),d=!0,!0)):!0}},_mouseMove:function(t){if(this._mouseMoved){if(e.ui.ie&&(!document.documentMode||9>document.documentMode)&&!t.button)return this._mouseUp(t);if(!t.which)return this._mouseUp(t)}return(t.which||t.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,t)!==!1,this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted)},_mouseUp:function(t){return this.document.unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&e.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),d=!1,!1},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),function(){function t(e,t,i){return[parseFloat(e[0])*(p.test(e[0])?t/100:1),parseFloat(e[1])*(p.test(e[1])?i/100:1)]}function i(t,i){return parseInt(e.css(t,i),10)||0}function s(t){var i=t[0];return 9===i.nodeType?{width:t.width(),height:t.height(),offset:{top:0,left:0}}:e.isWindow(i)?{width:t.width(),height:t.height(),offset:{top:t.scrollTop(),left:t.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:t.outerWidth(),height:t.outerHeight(),offset:t.offset()}}e.ui=e.ui||{};var n,a,o=Math.max,r=Math.abs,h=Math.round,l=/left|center|right/,u=/top|center|bottom/,d=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,p=/%$/,f=e.fn.position;e.position={scrollbarWidth:function(){if(void 0!==n)return n;var t,i,s=e("
    "),a=s.children()[0];return e("body").append(s),t=a.offsetWidth,s.css("overflow","scroll"),i=a.offsetWidth,t===i&&(i=s[0].clientWidth),s.remove(),n=t-i},getScrollInfo:function(t){var i=t.isWindow||t.isDocument?"":t.element.css("overflow-x"),s=t.isWindow||t.isDocument?"":t.element.css("overflow-y"),n="scroll"===i||"auto"===i&&t.widthi?"left":t>0?"right":"center",vertical:0>a?"top":s>0?"bottom":"middle"};d>m&&m>r(t+i)&&(h.horizontal="center"),c>g&&g>r(s+a)&&(h.vertical="middle"),h.important=o(r(t),r(i))>o(r(s),r(a))?"horizontal":"vertical",n.using.call(this,e,h)}),u.offset(e.extend(M,{using:l}))})},e.ui.position={fit:{left:function(e,t){var i,s=t.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=e.left-t.collisionPosition.marginLeft,h=n-r,l=r+t.collisionWidth-a-n;t.collisionWidth>a?h>0&&0>=l?(i=e.left+h+t.collisionWidth-a-n,e.left+=h-i):e.left=l>0&&0>=h?n:h>l?n+a-t.collisionWidth:n:h>0?e.left+=h:l>0?e.left-=l:e.left=o(e.left-r,e.left)},top:function(e,t){var i,s=t.within,n=s.isWindow?s.scrollTop:s.offset.top,a=t.within.height,r=e.top-t.collisionPosition.marginTop,h=n-r,l=r+t.collisionHeight-a-n;t.collisionHeight>a?h>0&&0>=l?(i=e.top+h+t.collisionHeight-a-n,e.top+=h-i):e.top=l>0&&0>=h?n:h>l?n+a-t.collisionHeight:n:h>0?e.top+=h:l>0?e.top-=l:e.top=o(e.top-r,e.top)}},flip:{left:function(e,t){var i,s,n=t.within,a=n.offset.left+n.scrollLeft,o=n.width,h=n.isWindow?n.scrollLeft:n.offset.left,l=e.left-t.collisionPosition.marginLeft,u=l-h,d=l+t.collisionWidth-o-h,c="left"===t.my[0]?-t.elemWidth:"right"===t.my[0]?t.elemWidth:0,p="left"===t.at[0]?t.targetWidth:"right"===t.at[0]?-t.targetWidth:0,f=-2*t.offset[0];0>u?(i=e.left+c+p+f+t.collisionWidth-o-a,(0>i||r(u)>i)&&(e.left+=c+p+f)):d>0&&(s=e.left-t.collisionPosition.marginLeft+c+p+f-h,(s>0||d>r(s))&&(e.left+=c+p+f))},top:function(e,t){var i,s,n=t.within,a=n.offset.top+n.scrollTop,o=n.height,h=n.isWindow?n.scrollTop:n.offset.top,l=e.top-t.collisionPosition.marginTop,u=l-h,d=l+t.collisionHeight-o-h,c="top"===t.my[1],p=c?-t.elemHeight:"bottom"===t.my[1]?t.elemHeight:0,f="top"===t.at[1]?t.targetHeight:"bottom"===t.at[1]?-t.targetHeight:0,m=-2*t.offset[1];0>u?(s=e.top+p+f+m+t.collisionHeight-o-a,e.top+p+f+m>u&&(0>s||r(u)>s)&&(e.top+=p+f+m)):d>0&&(i=e.top-t.collisionPosition.marginTop+p+f+m-h,e.top+p+f+m>d&&(i>0||d>r(i))&&(e.top+=p+f+m))}},flipfit:{left:function(){e.ui.position.flip.left.apply(this,arguments),e.ui.position.fit.left.apply(this,arguments)},top:function(){e.ui.position.flip.top.apply(this,arguments),e.ui.position.fit.top.apply(this,arguments)}}},function(){var t,i,s,n,o,r=document.getElementsByTagName("body")[0],h=document.createElement("div");t=document.createElement(r?"div":"body"),s={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},r&&e.extend(s,{position:"absolute",left:"-1000px",top:"-1000px"});for(o in s)t.style[o]=s[o];t.appendChild(h),i=r||document.documentElement,i.insertBefore(t,i.firstChild),h.style.cssText="position: absolute; left: 10.7432222px;",n=e(h).offset().left,a=n>10&&11>n,t.innerHTML="",i.removeChild(t)}()}(),e.ui.position,e.widget("ui.accordion",{version:"1.11.2",options:{active:0,animate:{},collapsible:!1,event:"click",header:"> li > :first-child,> :not(li):even",heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},hideProps:{borderTopWidth:"hide",borderBottomWidth:"hide",paddingTop:"hide",paddingBottom:"hide",height:"hide"},showProps:{borderTopWidth:"show",borderBottomWidth:"show",paddingTop:"show",paddingBottom:"show",height:"show"},_create:function(){var t=this.options;this.prevShow=this.prevHide=e(),this.element.addClass("ui-accordion ui-widget ui-helper-reset").attr("role","tablist"),t.collapsible||t.active!==!1&&null!=t.active||(t.active=0),this._processPanels(),0>t.active&&(t.active+=this.headers.length),this._refresh()},_getCreateEventData:function(){return{header:this.active,panel:this.active.length?this.active.next():e()}},_createIcons:function(){var t=this.options.icons;t&&(e("").addClass("ui-accordion-header-icon ui-icon "+t.header).prependTo(this.headers),this.active.children(".ui-accordion-header-icon").removeClass(t.header).addClass(t.activeHeader),this.headers.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.removeClass("ui-accordion-icons").children(".ui-accordion-header-icon").remove()},_destroy:function(){var e;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"),this.headers.removeClass("ui-accordion-header ui-accordion-header-active ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("aria-controls").removeAttr("tabIndex").removeUniqueId(),this._destroyIcons(),e=this.headers.next().removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled").css("display","").removeAttr("role").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeUniqueId(),"content"!==this.options.heightStyle&&e.css("height","")},_setOption:function(e,t){return"active"===e?(this._activate(t),void 0):("event"===e&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(t)),this._super(e,t),"collapsible"!==e||t||this.options.active!==!1||this._activate(0),"icons"===e&&(this._destroyIcons(),t&&this._createIcons()),"disabled"===e&&(this.element.toggleClass("ui-state-disabled",!!t).attr("aria-disabled",t),this.headers.add(this.headers.next()).toggleClass("ui-state-disabled",!!t)),void 0)},_keydown:function(t){if(!t.altKey&&!t.ctrlKey){var i=e.ui.keyCode,s=this.headers.length,n=this.headers.index(t.target),a=!1;switch(t.keyCode){case i.RIGHT:case i.DOWN:a=this.headers[(n+1)%s];break;case i.LEFT:case i.UP:a=this.headers[(n-1+s)%s];break;case i.SPACE:case i.ENTER:this._eventHandler(t);break;case i.HOME:a=this.headers[0];break;case i.END:a=this.headers[s-1]}a&&(e(t.target).attr("tabIndex",-1),e(a).attr("tabIndex",0),a.focus(),t.preventDefault())}},_panelKeyDown:function(t){t.keyCode===e.ui.keyCode.UP&&t.ctrlKey&&e(t.currentTarget).prev().focus()},refresh:function(){var t=this.options;this._processPanels(),t.active===!1&&t.collapsible===!0||!this.headers.length?(t.active=!1,this.active=e()):t.active===!1?this._activate(0):this.active.length&&!e.contains(this.element[0],this.active[0])?this.headers.length===this.headers.find(".ui-state-disabled").length?(t.active=!1,this.active=e()):this._activate(Math.max(0,t.active-1)):t.active=this.headers.index(this.active),this._destroyIcons(),this._refresh()},_processPanels:function(){var e=this.headers,t=this.panels;this.headers=this.element.find(this.options.header).addClass("ui-accordion-header ui-state-default ui-corner-all"),this.panels=this.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").filter(":not(.ui-accordion-content-active)").hide(),t&&(this._off(e.not(this.headers)),this._off(t.not(this.panels)))},_refresh:function(){var t,i=this.options,s=i.heightStyle,n=this.element.parent();this.active=this._findActive(i.active).addClass("ui-accordion-header-active ui-state-active ui-corner-top").removeClass("ui-corner-all"),this.active.next().addClass("ui-accordion-content-active").show(),this.headers.attr("role","tab").each(function(){var t=e(this),i=t.uniqueId().attr("id"),s=t.next(),n=s.uniqueId().attr("id");t.attr("aria-controls",n),s.attr("aria-labelledby",i)}).next().attr("role","tabpanel"),this.headers.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}).next().attr({"aria-hidden":"true"}).hide(),this.active.length?this.active.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}).next().attr({"aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0),this._createIcons(),this._setupEvents(i.event),"fill"===s?(t=n.height(),this.element.siblings(":visible").each(function(){var i=e(this),s=i.css("position");"absolute"!==s&&"fixed"!==s&&(t-=i.outerHeight(!0))}),this.headers.each(function(){t-=e(this).outerHeight(!0)}),this.headers.next().each(function(){e(this).height(Math.max(0,t-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):"auto"===s&&(t=0,this.headers.next().each(function(){t=Math.max(t,e(this).css("height","").height())}).height(t))},_activate:function(t){var i=this._findActive(t)[0];i!==this.active[0]&&(i=i||this.active[0],this._eventHandler({target:i,currentTarget:i,preventDefault:e.noop}))},_findActive:function(t){return"number"==typeof t?this.headers.eq(t):e()},_setupEvents:function(t){var i={keydown:"_keydown"};t&&e.each(t.split(" "),function(e,t){i[t]="_eventHandler"}),this._off(this.headers.add(this.headers.next())),this._on(this.headers,i),this._on(this.headers.next(),{keydown:"_panelKeyDown"}),this._hoverable(this.headers),this._focusable(this.headers)},_eventHandler:function(t){var i=this.options,s=this.active,n=e(t.currentTarget),a=n[0]===s[0],o=a&&i.collapsible,r=o?e():n.next(),h=s.next(),l={oldHeader:s,oldPanel:h,newHeader:o?e():n,newPanel:r};t.preventDefault(),a&&!i.collapsible||this._trigger("beforeActivate",t,l)===!1||(i.active=o?!1:this.headers.index(n),this.active=a?e():n,this._toggle(l),s.removeClass("ui-accordion-header-active ui-state-active"),i.icons&&s.children(".ui-accordion-header-icon").removeClass(i.icons.activeHeader).addClass(i.icons.header),a||(n.removeClass("ui-corner-all").addClass("ui-accordion-header-active ui-state-active ui-corner-top"),i.icons&&n.children(".ui-accordion-header-icon").removeClass(i.icons.header).addClass(i.icons.activeHeader),n.next().addClass("ui-accordion-content-active")))},_toggle:function(t){var i=t.newPanel,s=this.prevShow.length?this.prevShow:t.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=i,this.prevHide=s,this.options.animate?this._animate(i,s,t):(s.hide(),i.show(),this._toggleComplete(t)),s.attr({"aria-hidden":"true"}),s.prev().attr("aria-selected","false"),i.length&&s.length?s.prev().attr({tabIndex:-1,"aria-expanded":"false"}):i.length&&this.headers.filter(function(){return 0===e(this).attr("tabIndex")}).attr("tabIndex",-1),i.attr("aria-hidden","false").prev().attr({"aria-selected":"true",tabIndex:0,"aria-expanded":"true"})},_animate:function(e,t,i){var s,n,a,o=this,r=0,h=e.length&&(!t.length||e.index()",delay:300,options:{icons:{submenu:"ui-icon-carat-1-e"},items:"> *",menus:"ul",position:{my:"left-1 top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.mouseHandled=!1,this.element.uniqueId().addClass("ui-menu ui-widget ui-widget-content").toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length).attr({role:this.options.role,tabIndex:0}),this.options.disabled&&this.element.addClass("ui-state-disabled").attr("aria-disabled","true"),this._on({"mousedown .ui-menu-item":function(e){e.preventDefault()},"click .ui-menu-item":function(t){var i=e(t.target);!this.mouseHandled&&i.not(".ui-state-disabled").length&&(this.select(t),t.isPropagationStopped()||(this.mouseHandled=!0),i.has(".ui-menu").length?this.expand(t):!this.element.is(":focus")&&e(this.document[0].activeElement).closest(".ui-menu").length&&(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(t){if(!this.previousFilter){var i=e(t.currentTarget);i.siblings(".ui-state-active").removeClass("ui-state-active"),this.focus(t,i) +}},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(e,t){var i=this.active||this.element.find(this.options.items).eq(0);t||this.focus(e,i)},blur:function(t){this._delay(function(){e.contains(this.element[0],this.document[0].activeElement)||this.collapseAll(t)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(e){this._closeOnDocumentClick(e)&&this.collapseAll(e),this.mouseHandled=!1}})},_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeClass("ui-menu ui-widget ui-widget-content ui-menu-icons ui-front").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show(),this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").removeUniqueId().removeClass("ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function(){var t=e(this);t.data("ui-menu-submenu-carat")&&t.remove()}),this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")},_keydown:function(t){var i,s,n,a,o=!0;switch(t.keyCode){case e.ui.keyCode.PAGE_UP:this.previousPage(t);break;case e.ui.keyCode.PAGE_DOWN:this.nextPage(t);break;case e.ui.keyCode.HOME:this._move("first","first",t);break;case e.ui.keyCode.END:this._move("last","last",t);break;case e.ui.keyCode.UP:this.previous(t);break;case e.ui.keyCode.DOWN:this.next(t);break;case e.ui.keyCode.LEFT:this.collapse(t);break;case e.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(t);break;case e.ui.keyCode.ENTER:case e.ui.keyCode.SPACE:this._activate(t);break;case e.ui.keyCode.ESCAPE:this.collapse(t);break;default:o=!1,s=this.previousFilter||"",n=String.fromCharCode(t.keyCode),a=!1,clearTimeout(this.filterTimer),n===s?a=!0:n=s+n,i=this._filterMenuItems(n),i=a&&-1!==i.index(this.active.next())?this.active.nextAll(".ui-menu-item"):i,i.length||(n=String.fromCharCode(t.keyCode),i=this._filterMenuItems(n)),i.length?(this.focus(t,i),this.previousFilter=n,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter}o&&t.preventDefault()},_activate:function(e){this.active.is(".ui-state-disabled")||(this.active.is("[aria-haspopup='true']")?this.expand(e):this.select(e))},refresh:function(){var t,i,s=this,n=this.options.icons.submenu,a=this.element.find(this.options.menus);this.element.toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length),a.filter(":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-front").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var t=e(this),i=t.parent(),s=e("").addClass("ui-menu-icon ui-icon "+n).data("ui-menu-submenu-carat",!0);i.attr("aria-haspopup","true").prepend(s),t.attr("aria-labelledby",i.attr("id"))}),t=a.add(this.element),i=t.find(this.options.items),i.not(".ui-menu-item").each(function(){var t=e(this);s._isDivider(t)&&t.addClass("ui-widget-content ui-menu-divider")}),i.not(".ui-menu-item, .ui-menu-divider").addClass("ui-menu-item").uniqueId().attr({tabIndex:-1,role:this._itemRole()}),i.filter(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!e.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},_setOption:function(e,t){"icons"===e&&this.element.find(".ui-menu-icon").removeClass(this.options.icons.submenu).addClass(t.submenu),"disabled"===e&&this.element.toggleClass("ui-state-disabled",!!t).attr("aria-disabled",t),this._super(e,t)},focus:function(e,t){var i,s;this.blur(e,e&&"focus"===e.type),this._scrollIntoView(t),this.active=t.first(),s=this.active.addClass("ui-state-focus").removeClass("ui-state-active"),this.options.role&&this.element.attr("aria-activedescendant",s.attr("id")),this.active.parent().closest(".ui-menu-item").addClass("ui-state-active"),e&&"keydown"===e.type?this._close():this.timer=this._delay(function(){this._close()},this.delay),i=t.children(".ui-menu"),i.length&&e&&/^mouse/.test(e.type)&&this._startOpening(i),this.activeMenu=t.parent(),this._trigger("focus",e,{item:t})},_scrollIntoView:function(t){var i,s,n,a,o,r;this._hasScroll()&&(i=parseFloat(e.css(this.activeMenu[0],"borderTopWidth"))||0,s=parseFloat(e.css(this.activeMenu[0],"paddingTop"))||0,n=t.offset().top-this.activeMenu.offset().top-i-s,a=this.activeMenu.scrollTop(),o=this.activeMenu.height(),r=t.outerHeight(),0>n?this.activeMenu.scrollTop(a+n):n+r>o&&this.activeMenu.scrollTop(a+n-o+r))},blur:function(e,t){t||clearTimeout(this.timer),this.active&&(this.active.removeClass("ui-state-focus"),this.active=null,this._trigger("blur",e,{item:this.active}))},_startOpening:function(e){clearTimeout(this.timer),"true"===e.attr("aria-hidden")&&(this.timer=this._delay(function(){this._close(),this._open(e)},this.delay))},_open:function(t){var i=e.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(t.parents(".ui-menu")).hide().attr("aria-hidden","true"),t.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(i)},collapseAll:function(t,i){clearTimeout(this.timer),this.timer=this._delay(function(){var s=i?this.element:e(t&&t.target).closest(this.element.find(".ui-menu"));s.length||(s=this.element),this._close(s),this.blur(t),this.activeMenu=s},this.delay)},_close:function(e){e||(e=this.active?this.active.parent():this.element),e.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false").end().find(".ui-state-active").not(".ui-state-focus").removeClass("ui-state-active")},_closeOnDocumentClick:function(t){return!e(t.target).closest(".ui-menu").length},_isDivider:function(e){return!/[^\-\u2014\u2013\s]/.test(e.text())},collapse:function(e){var t=this.active&&this.active.parent().closest(".ui-menu-item",this.element);t&&t.length&&(this._close(),this.focus(e,t))},expand:function(e){var t=this.active&&this.active.children(".ui-menu ").find(this.options.items).first();t&&t.length&&(this._open(t.parent()),this._delay(function(){this.focus(e,t)}))},next:function(e){this._move("next","first",e)},previous:function(e){this._move("prev","last",e)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_move:function(e,t,i){var s;this.active&&(s="first"===e||"last"===e?this.active["first"===e?"prevAll":"nextAll"](".ui-menu-item").eq(-1):this.active[e+"All"](".ui-menu-item").eq(0)),s&&s.length&&this.active||(s=this.activeMenu.find(this.options.items)[t]()),this.focus(i,s)},nextPage:function(t){var i,s,n;return this.active?(this.isLastItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){return i=e(this),0>i.offset().top-s-n}),this.focus(t,i)):this.focus(t,this.activeMenu.find(this.options.items)[this.active?"last":"first"]())),void 0):(this.next(t),void 0)},previousPage:function(t){var i,s,n;return this.active?(this.isFirstItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){return i=e(this),i.offset().top-s+n>0}),this.focus(t,i)):this.focus(t,this.activeMenu.find(this.options.items).first())),void 0):(this.next(t),void 0)},_hasScroll:function(){return this.element.outerHeight()",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,_create:function(){var t,i,s,n=this.element[0].nodeName.toLowerCase(),a="textarea"===n,o="input"===n;this.isMultiLine=a?!0:o?!1:this.element.prop("isContentEditable"),this.valueMethod=this.element[a||o?"val":"text"],this.isNewMenu=!0,this.element.addClass("ui-autocomplete-input").attr("autocomplete","off"),this._on(this.element,{keydown:function(n){if(this.element.prop("readOnly"))return t=!0,s=!0,i=!0,void 0;t=!1,s=!1,i=!1;var a=e.ui.keyCode;switch(n.keyCode){case a.PAGE_UP:t=!0,this._move("previousPage",n);break;case a.PAGE_DOWN:t=!0,this._move("nextPage",n);break;case a.UP:t=!0,this._keyEvent("previous",n);break;case a.DOWN:t=!0,this._keyEvent("next",n);break;case a.ENTER:this.menu.active&&(t=!0,n.preventDefault(),this.menu.select(n));break;case a.TAB:this.menu.active&&this.menu.select(n);break;case a.ESCAPE:this.menu.element.is(":visible")&&(this.isMultiLine||this._value(this.term),this.close(n),n.preventDefault());break;default:i=!0,this._searchTimeout(n)}},keypress:function(s){if(t)return t=!1,(!this.isMultiLine||this.menu.element.is(":visible"))&&s.preventDefault(),void 0;if(!i){var n=e.ui.keyCode;switch(s.keyCode){case n.PAGE_UP:this._move("previousPage",s);break;case n.PAGE_DOWN:this._move("nextPage",s);break;case n.UP:this._keyEvent("previous",s);break;case n.DOWN:this._keyEvent("next",s)}}},input:function(e){return s?(s=!1,e.preventDefault(),void 0):(this._searchTimeout(e),void 0)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(e){return this.cancelBlur?(delete this.cancelBlur,void 0):(clearTimeout(this.searching),this.close(e),this._change(e),void 0)}}),this._initSource(),this.menu=e("
      ").addClass("ui-autocomplete ui-front").appendTo(this._appendTo()).menu({role:null}).hide().menu("instance"),this._on(this.menu.element,{mousedown:function(t){t.preventDefault(),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur});var i=this.menu.element[0];e(t.target).closest(".ui-menu-item").length||this._delay(function(){var t=this;this.document.one("mousedown",function(s){s.target===t.element[0]||s.target===i||e.contains(i,s.target)||t.close()})})},menufocus:function(t,i){var s,n;return this.isNewMenu&&(this.isNewMenu=!1,t.originalEvent&&/^mouse/.test(t.originalEvent.type))?(this.menu.blur(),this.document.one("mousemove",function(){e(t.target).trigger(t.originalEvent)}),void 0):(n=i.item.data("ui-autocomplete-item"),!1!==this._trigger("focus",t,{item:n})&&t.originalEvent&&/^key/.test(t.originalEvent.type)&&this._value(n.value),s=i.item.attr("aria-label")||n.value,s&&e.trim(s).length&&(this.liveRegion.children().hide(),e("
      ").text(s).appendTo(this.liveRegion)),void 0)},menuselect:function(e,t){var i=t.item.data("ui-autocomplete-item"),s=this.previous;this.element[0]!==this.document[0].activeElement&&(this.element.focus(),this.previous=s,this._delay(function(){this.previous=s,this.selectedItem=i})),!1!==this._trigger("select",e,{item:i})&&this._value(i.value),this.term=this._value(),this.close(e),this.selectedItem=i}}),this.liveRegion=e("",{role:"status","aria-live":"assertive","aria-relevant":"additions"}).addClass("ui-helper-hidden-accessible").appendTo(this.document[0].body),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_destroy:function(){clearTimeout(this.searching),this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete"),this.menu.element.remove(),this.liveRegion.remove()},_setOption:function(e,t){this._super(e,t),"source"===e&&this._initSource(),"appendTo"===e&&this.menu.element.appendTo(this._appendTo()),"disabled"===e&&t&&this.xhr&&this.xhr.abort()},_appendTo:function(){var t=this.options.appendTo;return t&&(t=t.jquery||t.nodeType?e(t):this.document.find(t).eq(0)),t&&t[0]||(t=this.element.closest(".ui-front")),t.length||(t=this.document[0].body),t},_initSource:function(){var t,i,s=this;e.isArray(this.options.source)?(t=this.options.source,this.source=function(i,s){s(e.ui.autocomplete.filter(t,i.term))}):"string"==typeof this.options.source?(i=this.options.source,this.source=function(t,n){s.xhr&&s.xhr.abort(),s.xhr=e.ajax({url:i,data:t,dataType:"json",success:function(e){n(e)},error:function(){n([])}})}):this.source=this.options.source},_searchTimeout:function(e){clearTimeout(this.searching),this.searching=this._delay(function(){var t=this.term===this._value(),i=this.menu.element.is(":visible"),s=e.altKey||e.ctrlKey||e.metaKey||e.shiftKey;(!t||t&&!i&&!s)&&(this.selectedItem=null,this.search(null,e))},this.options.delay)},search:function(e,t){return e=null!=e?e:this._value(),this.term=this._value(),e.length").text(i.label).appendTo(t)},_move:function(e,t){return this.menu.element.is(":visible")?this.menu.isFirstItem()&&/^previous/.test(e)||this.menu.isLastItem()&&/^next/.test(e)?(this.isMultiLine||this._value(this.term),this.menu.blur(),void 0):(this.menu[e](t),void 0):(this.search(null,t),void 0)},widget:function(){return this.menu.element},_value:function(){return this.valueMethod.apply(this.element,arguments)},_keyEvent:function(e,t){(!this.isMultiLine||this.menu.element.is(":visible"))&&(this._move(e,t),t.preventDefault())}}),e.extend(e.ui.autocomplete,{escapeRegex:function(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},filter:function(t,i){var s=RegExp(e.ui.autocomplete.escapeRegex(i),"i");return e.grep(t,function(e){return s.test(e.label||e.value||e)})}}),e.widget("ui.autocomplete",e.ui.autocomplete,{options:{messages:{noResults:"No search results.",results:function(e){return e+(e>1?" results are":" result is")+" available, use up and down arrow keys to navigate."}}},__response:function(t){var i;this._superApply(arguments),this.options.disabled||this.cancelSearch||(i=t&&t.length?this.options.messages.results(t.length):this.options.messages.noResults,this.liveRegion.children().hide(),e("
      ").text(i).appendTo(this.liveRegion))}}),e.ui.autocomplete;var c,p="ui-button ui-widget ui-state-default ui-corner-all",f="ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",m=function(){var t=e(this);setTimeout(function(){t.find(":ui-button").button("refresh")},1)},g=function(t){var i=t.name,s=t.form,n=e([]);return i&&(i=i.replace(/'/g,"\\'"),n=s?e(s).find("[name='"+i+"'][type=radio]"):e("[name='"+i+"'][type=radio]",t.ownerDocument).filter(function(){return!this.form})),n};e.widget("ui.button",{version:"1.11.2",defaultElement:"").addClass(this._triggerClass).html(a?e("").attr({src:a,alt:n,title:n}):n)),t[r?"before":"after"](i.trigger),i.trigger.click(function(){return e.datepicker._datepickerShowing&&e.datepicker._lastInput===t[0]?e.datepicker._hideDatepicker():e.datepicker._datepickerShowing&&e.datepicker._lastInput!==t[0]?(e.datepicker._hideDatepicker(),e.datepicker._showDatepicker(t[0])):e.datepicker._showDatepicker(t[0]),!1}))},_autoSize:function(e){if(this._get(e,"autoSize")&&!e.inline){var t,i,s,n,a=new Date(2009,11,20),o=this._get(e,"dateFormat");o.match(/[DM]/)&&(t=function(e){for(i=0,s=0,n=0;e.length>n;n++)e[n].length>i&&(i=e[n].length,s=n);return s},a.setMonth(t(this._get(e,o.match(/MM/)?"monthNames":"monthNamesShort"))),a.setDate(t(this._get(e,o.match(/DD/)?"dayNames":"dayNamesShort"))+20-a.getDay())),e.input.attr("size",this._formatDate(e,a).length)}},_inlineDatepicker:function(t,i){var s=e(t);s.hasClass(this.markerClassName)||(s.addClass(this.markerClassName).append(i.dpDiv),e.data(t,"datepicker",i),this._setDate(i,this._getDefaultDate(i),!0),this._updateDatepicker(i),this._updateAlternate(i),i.settings.disabled&&this._disableDatepicker(t),i.dpDiv.css("display","block"))},_dialogDatepicker:function(t,i,s,n,a){var o,h,l,u,d,c=this._dialogInst;return c||(this.uuid+=1,o="dp"+this.uuid,this._dialogInput=e(""),this._dialogInput.keydown(this._doKeyDown),e("body").append(this._dialogInput),c=this._dialogInst=this._newInst(this._dialogInput,!1),c.settings={},e.data(this._dialogInput[0],"datepicker",c)),r(c.settings,n||{}),i=i&&i.constructor===Date?this._formatDate(c,i):i,this._dialogInput.val(i),this._pos=a?a.length?a:[a.pageX,a.pageY]:null,this._pos||(h=document.documentElement.clientWidth,l=document.documentElement.clientHeight,u=document.documentElement.scrollLeft||document.body.scrollLeft,d=document.documentElement.scrollTop||document.body.scrollTop,this._pos=[h/2-100+u,l/2-150+d]),this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px"),c.settings.onSelect=s,this._inDialog=!0,this.dpDiv.addClass(this._dialogClass),this._showDatepicker(this._dialogInput[0]),e.blockUI&&e.blockUI(this.dpDiv),e.data(this._dialogInput[0],"datepicker",c),this},_destroyDatepicker:function(t){var i,s=e(t),n=e.data(t,"datepicker");s.hasClass(this.markerClassName)&&(i=t.nodeName.toLowerCase(),e.removeData(t,"datepicker"),"input"===i?(n.append.remove(),n.trigger.remove(),s.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)):("div"===i||"span"===i)&&s.removeClass(this.markerClassName).empty())},_enableDatepicker:function(t){var i,s,n=e(t),a=e.data(t,"datepicker");n.hasClass(this.markerClassName)&&(i=t.nodeName.toLowerCase(),"input"===i?(t.disabled=!1,a.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""})):("div"===i||"span"===i)&&(s=n.children("."+this._inlineClass),s.children().removeClass("ui-state-disabled"),s.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!1)),this._disabledInputs=e.map(this._disabledInputs,function(e){return e===t?null:e}))},_disableDatepicker:function(t){var i,s,n=e(t),a=e.data(t,"datepicker");n.hasClass(this.markerClassName)&&(i=t.nodeName.toLowerCase(),"input"===i?(t.disabled=!0,a.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"})):("div"===i||"span"===i)&&(s=n.children("."+this._inlineClass),s.children().addClass("ui-state-disabled"),s.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!0)),this._disabledInputs=e.map(this._disabledInputs,function(e){return e===t?null:e}),this._disabledInputs[this._disabledInputs.length]=t)},_isDisabledDatepicker:function(e){if(!e)return!1;for(var t=0;this._disabledInputs.length>t;t++)if(this._disabledInputs[t]===e)return!0;return!1},_getInst:function(t){try{return e.data(t,"datepicker")}catch(i){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(t,i,s){var n,a,o,h,l=this._getInst(t);return 2===arguments.length&&"string"==typeof i?"defaults"===i?e.extend({},e.datepicker._defaults):l?"all"===i?e.extend({},l.settings):this._get(l,i):null:(n=i||{},"string"==typeof i&&(n={},n[i]=s),l&&(this._curInst===l&&this._hideDatepicker(),a=this._getDateDatepicker(t,!0),o=this._getMinMaxDate(l,"min"),h=this._getMinMaxDate(l,"max"),r(l.settings,n),null!==o&&void 0!==n.dateFormat&&void 0===n.minDate&&(l.settings.minDate=this._formatDate(l,o)),null!==h&&void 0!==n.dateFormat&&void 0===n.maxDate&&(l.settings.maxDate=this._formatDate(l,h)),"disabled"in n&&(n.disabled?this._disableDatepicker(t):this._enableDatepicker(t)),this._attachments(e(t),l),this._autoSize(l),this._setDate(l,a),this._updateAlternate(l),this._updateDatepicker(l)),void 0)},_changeDatepicker:function(e,t,i){this._optionDatepicker(e,t,i)},_refreshDatepicker:function(e){var t=this._getInst(e);t&&this._updateDatepicker(t)},_setDateDatepicker:function(e,t){var i=this._getInst(e);i&&(this._setDate(i,t),this._updateDatepicker(i),this._updateAlternate(i))},_getDateDatepicker:function(e,t){var i=this._getInst(e);return i&&!i.inline&&this._setDateFromField(i,t),i?this._getDate(i):null},_doKeyDown:function(t){var i,s,n,a=e.datepicker._getInst(t.target),o=!0,r=a.dpDiv.is(".ui-datepicker-rtl");if(a._keyEvent=!0,e.datepicker._datepickerShowing)switch(t.keyCode){case 9:e.datepicker._hideDatepicker(),o=!1;break;case 13:return n=e("td."+e.datepicker._dayOverClass+":not(."+e.datepicker._currentClass+")",a.dpDiv),n[0]&&e.datepicker._selectDay(t.target,a.selectedMonth,a.selectedYear,n[0]),i=e.datepicker._get(a,"onSelect"),i?(s=e.datepicker._formatDate(a),i.apply(a.input?a.input[0]:null,[s,a])):e.datepicker._hideDatepicker(),!1;case 27:e.datepicker._hideDatepicker();break;case 33:e.datepicker._adjustDate(t.target,t.ctrlKey?-e.datepicker._get(a,"stepBigMonths"):-e.datepicker._get(a,"stepMonths"),"M");break;case 34:e.datepicker._adjustDate(t.target,t.ctrlKey?+e.datepicker._get(a,"stepBigMonths"):+e.datepicker._get(a,"stepMonths"),"M");break;case 35:(t.ctrlKey||t.metaKey)&&e.datepicker._clearDate(t.target),o=t.ctrlKey||t.metaKey;break;case 36:(t.ctrlKey||t.metaKey)&&e.datepicker._gotoToday(t.target),o=t.ctrlKey||t.metaKey;break;case 37:(t.ctrlKey||t.metaKey)&&e.datepicker._adjustDate(t.target,r?1:-1,"D"),o=t.ctrlKey||t.metaKey,t.originalEvent.altKey&&e.datepicker._adjustDate(t.target,t.ctrlKey?-e.datepicker._get(a,"stepBigMonths"):-e.datepicker._get(a,"stepMonths"),"M");break;case 38:(t.ctrlKey||t.metaKey)&&e.datepicker._adjustDate(t.target,-7,"D"),o=t.ctrlKey||t.metaKey;break;case 39:(t.ctrlKey||t.metaKey)&&e.datepicker._adjustDate(t.target,r?-1:1,"D"),o=t.ctrlKey||t.metaKey,t.originalEvent.altKey&&e.datepicker._adjustDate(t.target,t.ctrlKey?+e.datepicker._get(a,"stepBigMonths"):+e.datepicker._get(a,"stepMonths"),"M");break;case 40:(t.ctrlKey||t.metaKey)&&e.datepicker._adjustDate(t.target,7,"D"),o=t.ctrlKey||t.metaKey;break;default:o=!1}else 36===t.keyCode&&t.ctrlKey?e.datepicker._showDatepicker(this):o=!1;o&&(t.preventDefault(),t.stopPropagation())},_doKeyPress:function(t){var i,s,n=e.datepicker._getInst(t.target);return e.datepicker._get(n,"constrainInput")?(i=e.datepicker._possibleChars(e.datepicker._get(n,"dateFormat")),s=String.fromCharCode(null==t.charCode?t.keyCode:t.charCode),t.ctrlKey||t.metaKey||" ">s||!i||i.indexOf(s)>-1):void 0 +},_doKeyUp:function(t){var i,s=e.datepicker._getInst(t.target);if(s.input.val()!==s.lastVal)try{i=e.datepicker.parseDate(e.datepicker._get(s,"dateFormat"),s.input?s.input.val():null,e.datepicker._getFormatConfig(s)),i&&(e.datepicker._setDateFromField(s),e.datepicker._updateAlternate(s),e.datepicker._updateDatepicker(s))}catch(n){}return!0},_showDatepicker:function(t){if(t=t.target||t,"input"!==t.nodeName.toLowerCase()&&(t=e("input",t.parentNode)[0]),!e.datepicker._isDisabledDatepicker(t)&&e.datepicker._lastInput!==t){var i,n,a,o,h,l,u;i=e.datepicker._getInst(t),e.datepicker._curInst&&e.datepicker._curInst!==i&&(e.datepicker._curInst.dpDiv.stop(!0,!0),i&&e.datepicker._datepickerShowing&&e.datepicker._hideDatepicker(e.datepicker._curInst.input[0])),n=e.datepicker._get(i,"beforeShow"),a=n?n.apply(t,[t,i]):{},a!==!1&&(r(i.settings,a),i.lastVal=null,e.datepicker._lastInput=t,e.datepicker._setDateFromField(i),e.datepicker._inDialog&&(t.value=""),e.datepicker._pos||(e.datepicker._pos=e.datepicker._findPos(t),e.datepicker._pos[1]+=t.offsetHeight),o=!1,e(t).parents().each(function(){return o|="fixed"===e(this).css("position"),!o}),h={left:e.datepicker._pos[0],top:e.datepicker._pos[1]},e.datepicker._pos=null,i.dpDiv.empty(),i.dpDiv.css({position:"absolute",display:"block",top:"-1000px"}),e.datepicker._updateDatepicker(i),h=e.datepicker._checkOffset(i,h,o),i.dpDiv.css({position:e.datepicker._inDialog&&e.blockUI?"static":o?"fixed":"absolute",display:"none",left:h.left+"px",top:h.top+"px"}),i.inline||(l=e.datepicker._get(i,"showAnim"),u=e.datepicker._get(i,"duration"),i.dpDiv.css("z-index",s(e(t))+1),e.datepicker._datepickerShowing=!0,e.effects&&e.effects.effect[l]?i.dpDiv.show(l,e.datepicker._get(i,"showOptions"),u):i.dpDiv[l||"show"](l?u:null),e.datepicker._shouldFocusInput(i)&&i.input.focus(),e.datepicker._curInst=i))}},_updateDatepicker:function(t){this.maxRows=4,v=t,t.dpDiv.empty().append(this._generateHTML(t)),this._attachHandlers(t);var i,s=this._getNumberOfMonths(t),n=s[1],a=17,r=t.dpDiv.find("."+this._dayOverClass+" a");r.length>0&&o.apply(r.get(0)),t.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""),n>1&&t.dpDiv.addClass("ui-datepicker-multi-"+n).css("width",a*n+"em"),t.dpDiv[(1!==s[0]||1!==s[1]?"add":"remove")+"Class"]("ui-datepicker-multi"),t.dpDiv[(this._get(t,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl"),t===e.datepicker._curInst&&e.datepicker._datepickerShowing&&e.datepicker._shouldFocusInput(t)&&t.input.focus(),t.yearshtml&&(i=t.yearshtml,setTimeout(function(){i===t.yearshtml&&t.yearshtml&&t.dpDiv.find("select.ui-datepicker-year:first").replaceWith(t.yearshtml),i=t.yearshtml=null},0))},_shouldFocusInput:function(e){return e.input&&e.input.is(":visible")&&!e.input.is(":disabled")&&!e.input.is(":focus")},_checkOffset:function(t,i,s){var n=t.dpDiv.outerWidth(),a=t.dpDiv.outerHeight(),o=t.input?t.input.outerWidth():0,r=t.input?t.input.outerHeight():0,h=document.documentElement.clientWidth+(s?0:e(document).scrollLeft()),l=document.documentElement.clientHeight+(s?0:e(document).scrollTop());return i.left-=this._get(t,"isRTL")?n-o:0,i.left-=s&&i.left===t.input.offset().left?e(document).scrollLeft():0,i.top-=s&&i.top===t.input.offset().top+r?e(document).scrollTop():0,i.left-=Math.min(i.left,i.left+n>h&&h>n?Math.abs(i.left+n-h):0),i.top-=Math.min(i.top,i.top+a>l&&l>a?Math.abs(a+r):0),i},_findPos:function(t){for(var i,s=this._getInst(t),n=this._get(s,"isRTL");t&&("hidden"===t.type||1!==t.nodeType||e.expr.filters.hidden(t));)t=t[n?"previousSibling":"nextSibling"];return i=e(t).offset(),[i.left,i.top]},_hideDatepicker:function(t){var i,s,n,a,o=this._curInst;!o||t&&o!==e.data(t,"datepicker")||this._datepickerShowing&&(i=this._get(o,"showAnim"),s=this._get(o,"duration"),n=function(){e.datepicker._tidyDialog(o)},e.effects&&(e.effects.effect[i]||e.effects[i])?o.dpDiv.hide(i,e.datepicker._get(o,"showOptions"),s,n):o.dpDiv["slideDown"===i?"slideUp":"fadeIn"===i?"fadeOut":"hide"](i?s:null,n),i||n(),this._datepickerShowing=!1,a=this._get(o,"onClose"),a&&a.apply(o.input?o.input[0]:null,[o.input?o.input.val():"",o]),this._lastInput=null,this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),e.blockUI&&(e.unblockUI(),e("body").append(this.dpDiv))),this._inDialog=!1)},_tidyDialog:function(e){e.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(t){if(e.datepicker._curInst){var i=e(t.target),s=e.datepicker._getInst(i[0]);(i[0].id!==e.datepicker._mainDivId&&0===i.parents("#"+e.datepicker._mainDivId).length&&!i.hasClass(e.datepicker.markerClassName)&&!i.closest("."+e.datepicker._triggerClass).length&&e.datepicker._datepickerShowing&&(!e.datepicker._inDialog||!e.blockUI)||i.hasClass(e.datepicker.markerClassName)&&e.datepicker._curInst!==s)&&e.datepicker._hideDatepicker()}},_adjustDate:function(t,i,s){var n=e(t),a=this._getInst(n[0]);this._isDisabledDatepicker(n[0])||(this._adjustInstDate(a,i+("M"===s?this._get(a,"showCurrentAtPos"):0),s),this._updateDatepicker(a))},_gotoToday:function(t){var i,s=e(t),n=this._getInst(s[0]);this._get(n,"gotoCurrent")&&n.currentDay?(n.selectedDay=n.currentDay,n.drawMonth=n.selectedMonth=n.currentMonth,n.drawYear=n.selectedYear=n.currentYear):(i=new Date,n.selectedDay=i.getDate(),n.drawMonth=n.selectedMonth=i.getMonth(),n.drawYear=n.selectedYear=i.getFullYear()),this._notifyChange(n),this._adjustDate(s)},_selectMonthYear:function(t,i,s){var n=e(t),a=this._getInst(n[0]);a["selected"+("M"===s?"Month":"Year")]=a["draw"+("M"===s?"Month":"Year")]=parseInt(i.options[i.selectedIndex].value,10),this._notifyChange(a),this._adjustDate(n)},_selectDay:function(t,i,s,n){var a,o=e(t);e(n).hasClass(this._unselectableClass)||this._isDisabledDatepicker(o[0])||(a=this._getInst(o[0]),a.selectedDay=a.currentDay=e("a",n).html(),a.selectedMonth=a.currentMonth=i,a.selectedYear=a.currentYear=s,this._selectDate(t,this._formatDate(a,a.currentDay,a.currentMonth,a.currentYear)))},_clearDate:function(t){var i=e(t);this._selectDate(i,"")},_selectDate:function(t,i){var s,n=e(t),a=this._getInst(n[0]);i=null!=i?i:this._formatDate(a),a.input&&a.input.val(i),this._updateAlternate(a),s=this._get(a,"onSelect"),s?s.apply(a.input?a.input[0]:null,[i,a]):a.input&&a.input.trigger("change"),a.inline?this._updateDatepicker(a):(this._hideDatepicker(),this._lastInput=a.input[0],"object"!=typeof a.input[0]&&a.input.focus(),this._lastInput=null)},_updateAlternate:function(t){var i,s,n,a=this._get(t,"altField");a&&(i=this._get(t,"altFormat")||this._get(t,"dateFormat"),s=this._getDate(t),n=this.formatDate(i,s,this._getFormatConfig(t)),e(a).each(function(){e(this).val(n)}))},noWeekends:function(e){var t=e.getDay();return[t>0&&6>t,""]},iso8601Week:function(e){var t,i=new Date(e.getTime());return i.setDate(i.getDate()+4-(i.getDay()||7)),t=i.getTime(),i.setMonth(0),i.setDate(1),Math.floor(Math.round((t-i)/864e5)/7)+1},parseDate:function(t,i,s){if(null==t||null==i)throw"Invalid arguments";if(i="object"==typeof i?""+i:i+"",""===i)return null;var n,a,o,r,h=0,l=(s?s.shortYearCutoff:null)||this._defaults.shortYearCutoff,u="string"!=typeof l?l:(new Date).getFullYear()%100+parseInt(l,10),d=(s?s.dayNamesShort:null)||this._defaults.dayNamesShort,c=(s?s.dayNames:null)||this._defaults.dayNames,p=(s?s.monthNamesShort:null)||this._defaults.monthNamesShort,f=(s?s.monthNames:null)||this._defaults.monthNames,m=-1,g=-1,v=-1,y=-1,b=!1,_=function(e){var i=t.length>n+1&&t.charAt(n+1)===e;return i&&n++,i},x=function(e){var t=_(e),s="@"===e?14:"!"===e?20:"y"===e&&t?4:"o"===e?3:2,n="y"===e?s:1,a=RegExp("^\\d{"+n+","+s+"}"),o=i.substring(h).match(a);if(!o)throw"Missing number at position "+h;return h+=o[0].length,parseInt(o[0],10)},w=function(t,s,n){var a=-1,o=e.map(_(t)?n:s,function(e,t){return[[t,e]]}).sort(function(e,t){return-(e[1].length-t[1].length)});if(e.each(o,function(e,t){var s=t[1];return i.substr(h,s.length).toLowerCase()===s.toLowerCase()?(a=t[0],h+=s.length,!1):void 0}),-1!==a)return a+1;throw"Unknown name at position "+h},k=function(){if(i.charAt(h)!==t.charAt(n))throw"Unexpected literal at position "+h;h++};for(n=0;t.length>n;n++)if(b)"'"!==t.charAt(n)||_("'")?k():b=!1;else switch(t.charAt(n)){case"d":v=x("d");break;case"D":w("D",d,c);break;case"o":y=x("o");break;case"m":g=x("m");break;case"M":g=w("M",p,f);break;case"y":m=x("y");break;case"@":r=new Date(x("@")),m=r.getFullYear(),g=r.getMonth()+1,v=r.getDate();break;case"!":r=new Date((x("!")-this._ticksTo1970)/1e4),m=r.getFullYear(),g=r.getMonth()+1,v=r.getDate();break;case"'":_("'")?k():b=!0;break;default:k()}if(i.length>h&&(o=i.substr(h),!/^\s+/.test(o)))throw"Extra/unparsed characters found in date: "+o;if(-1===m?m=(new Date).getFullYear():100>m&&(m+=(new Date).getFullYear()-(new Date).getFullYear()%100+(u>=m?0:-100)),y>-1)for(g=1,v=y;;){if(a=this._getDaysInMonth(m,g-1),a>=v)break;g++,v-=a}if(r=this._daylightSavingAdjust(new Date(m,g-1,v)),r.getFullYear()!==m||r.getMonth()+1!==g||r.getDate()!==v)throw"Invalid date";return r},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:1e7*60*60*24*(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925)),formatDate:function(e,t,i){if(!t)return"";var s,n=(i?i.dayNamesShort:null)||this._defaults.dayNamesShort,a=(i?i.dayNames:null)||this._defaults.dayNames,o=(i?i.monthNamesShort:null)||this._defaults.monthNamesShort,r=(i?i.monthNames:null)||this._defaults.monthNames,h=function(t){var i=e.length>s+1&&e.charAt(s+1)===t;return i&&s++,i},l=function(e,t,i){var s=""+t;if(h(e))for(;i>s.length;)s="0"+s;return s},u=function(e,t,i,s){return h(e)?s[t]:i[t]},d="",c=!1;if(t)for(s=0;e.length>s;s++)if(c)"'"!==e.charAt(s)||h("'")?d+=e.charAt(s):c=!1;else switch(e.charAt(s)){case"d":d+=l("d",t.getDate(),2);break;case"D":d+=u("D",t.getDay(),n,a);break;case"o":d+=l("o",Math.round((new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()-new Date(t.getFullYear(),0,0).getTime())/864e5),3);break;case"m":d+=l("m",t.getMonth()+1,2);break;case"M":d+=u("M",t.getMonth(),o,r);break;case"y":d+=h("y")?t.getFullYear():(10>t.getYear()%100?"0":"")+t.getYear()%100;break;case"@":d+=t.getTime();break;case"!":d+=1e4*t.getTime()+this._ticksTo1970;break;case"'":h("'")?d+="'":c=!0;break;default:d+=e.charAt(s)}return d},_possibleChars:function(e){var t,i="",s=!1,n=function(i){var s=e.length>t+1&&e.charAt(t+1)===i;return s&&t++,s};for(t=0;e.length>t;t++)if(s)"'"!==e.charAt(t)||n("'")?i+=e.charAt(t):s=!1;else switch(e.charAt(t)){case"d":case"m":case"y":case"@":i+="0123456789";break;case"D":case"M":return null;case"'":n("'")?i+="'":s=!0;break;default:i+=e.charAt(t)}return i},_get:function(e,t){return void 0!==e.settings[t]?e.settings[t]:this._defaults[t]},_setDateFromField:function(e,t){if(e.input.val()!==e.lastVal){var i=this._get(e,"dateFormat"),s=e.lastVal=e.input?e.input.val():null,n=this._getDefaultDate(e),a=n,o=this._getFormatConfig(e);try{a=this.parseDate(i,s,o)||n}catch(r){s=t?"":s}e.selectedDay=a.getDate(),e.drawMonth=e.selectedMonth=a.getMonth(),e.drawYear=e.selectedYear=a.getFullYear(),e.currentDay=s?a.getDate():0,e.currentMonth=s?a.getMonth():0,e.currentYear=s?a.getFullYear():0,this._adjustInstDate(e)}},_getDefaultDate:function(e){return this._restrictMinMax(e,this._determineDate(e,this._get(e,"defaultDate"),new Date))},_determineDate:function(t,i,s){var n=function(e){var t=new Date;return t.setDate(t.getDate()+e),t},a=function(i){try{return e.datepicker.parseDate(e.datepicker._get(t,"dateFormat"),i,e.datepicker._getFormatConfig(t))}catch(s){}for(var n=(i.toLowerCase().match(/^c/)?e.datepicker._getDate(t):null)||new Date,a=n.getFullYear(),o=n.getMonth(),r=n.getDate(),h=/([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,l=h.exec(i);l;){switch(l[2]||"d"){case"d":case"D":r+=parseInt(l[1],10);break;case"w":case"W":r+=7*parseInt(l[1],10);break;case"m":case"M":o+=parseInt(l[1],10),r=Math.min(r,e.datepicker._getDaysInMonth(a,o));break;case"y":case"Y":a+=parseInt(l[1],10),r=Math.min(r,e.datepicker._getDaysInMonth(a,o))}l=h.exec(i)}return new Date(a,o,r)},o=null==i||""===i?s:"string"==typeof i?a(i):"number"==typeof i?isNaN(i)?s:n(i):new Date(i.getTime());return o=o&&"Invalid Date"==""+o?s:o,o&&(o.setHours(0),o.setMinutes(0),o.setSeconds(0),o.setMilliseconds(0)),this._daylightSavingAdjust(o)},_daylightSavingAdjust:function(e){return e?(e.setHours(e.getHours()>12?e.getHours()+2:0),e):null},_setDate:function(e,t,i){var s=!t,n=e.selectedMonth,a=e.selectedYear,o=this._restrictMinMax(e,this._determineDate(e,t,new Date));e.selectedDay=e.currentDay=o.getDate(),e.drawMonth=e.selectedMonth=e.currentMonth=o.getMonth(),e.drawYear=e.selectedYear=e.currentYear=o.getFullYear(),n===e.selectedMonth&&a===e.selectedYear||i||this._notifyChange(e),this._adjustInstDate(e),e.input&&e.input.val(s?"":this._formatDate(e))},_getDate:function(e){var t=!e.currentYear||e.input&&""===e.input.val()?null:this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return t},_attachHandlers:function(t){var i=this._get(t,"stepMonths"),s="#"+t.id.replace(/\\\\/g,"\\");t.dpDiv.find("[data-handler]").map(function(){var t={prev:function(){e.datepicker._adjustDate(s,-i,"M")},next:function(){e.datepicker._adjustDate(s,+i,"M")},hide:function(){e.datepicker._hideDatepicker()},today:function(){e.datepicker._gotoToday(s)},selectDay:function(){return e.datepicker._selectDay(s,+this.getAttribute("data-month"),+this.getAttribute("data-year"),this),!1},selectMonth:function(){return e.datepicker._selectMonthYear(s,this,"M"),!1},selectYear:function(){return e.datepicker._selectMonthYear(s,this,"Y"),!1}};e(this).bind(this.getAttribute("data-event"),t[this.getAttribute("data-handler")])})},_generateHTML:function(e){var t,i,s,n,a,o,r,h,l,u,d,c,p,f,m,g,v,y,b,_,x,w,k,T,D,S,M,C,N,A,P,I,z,H,F,E,O,j,W,L=new Date,R=this._daylightSavingAdjust(new Date(L.getFullYear(),L.getMonth(),L.getDate())),Y=this._get(e,"isRTL"),B=this._get(e,"showButtonPanel"),J=this._get(e,"hideIfNoPrevNext"),q=this._get(e,"navigationAsDateFormat"),K=this._getNumberOfMonths(e),V=this._get(e,"showCurrentAtPos"),U=this._get(e,"stepMonths"),Q=1!==K[0]||1!==K[1],G=this._daylightSavingAdjust(e.currentDay?new Date(e.currentYear,e.currentMonth,e.currentDay):new Date(9999,9,9)),X=this._getMinMaxDate(e,"min"),$=this._getMinMaxDate(e,"max"),Z=e.drawMonth-V,et=e.drawYear;if(0>Z&&(Z+=12,et--),$)for(t=this._daylightSavingAdjust(new Date($.getFullYear(),$.getMonth()-K[0]*K[1]+1,$.getDate())),t=X&&X>t?X:t;this._daylightSavingAdjust(new Date(et,Z,1))>t;)Z--,0>Z&&(Z=11,et--);for(e.drawMonth=Z,e.drawYear=et,i=this._get(e,"prevText"),i=q?this.formatDate(i,this._daylightSavingAdjust(new Date(et,Z-U,1)),this._getFormatConfig(e)):i,s=this._canAdjustMonth(e,-1,et,Z)?""+i+"":J?"":""+i+"",n=this._get(e,"nextText"),n=q?this.formatDate(n,this._daylightSavingAdjust(new Date(et,Z+U,1)),this._getFormatConfig(e)):n,a=this._canAdjustMonth(e,1,et,Z)?""+n+"":J?"":""+n+"",o=this._get(e,"currentText"),r=this._get(e,"gotoCurrent")&&e.currentDay?G:R,o=q?this.formatDate(o,r,this._getFormatConfig(e)):o,h=e.inline?"":"",l=B?"
      "+(Y?h:"")+(this._isInRange(e,r)?"":"")+(Y?"":h)+"
      ":"",u=parseInt(this._get(e,"firstDay"),10),u=isNaN(u)?0:u,d=this._get(e,"showWeek"),c=this._get(e,"dayNames"),p=this._get(e,"dayNamesMin"),f=this._get(e,"monthNames"),m=this._get(e,"monthNamesShort"),g=this._get(e,"beforeShowDay"),v=this._get(e,"showOtherMonths"),y=this._get(e,"selectOtherMonths"),b=this._getDefaultDate(e),_="",w=0;K[0]>w;w++){for(k="",this.maxRows=4,T=0;K[1]>T;T++){if(D=this._daylightSavingAdjust(new Date(et,Z,e.selectedDay)),S=" ui-corner-all",M="",Q){if(M+="
      "}for(M+="
      "+(/all|left/.test(S)&&0===w?Y?a:s:"")+(/all|right/.test(S)&&0===w?Y?s:a:"")+this._generateMonthYearHeader(e,Z,et,X,$,w>0||T>0,f,m)+"
      "+"",C=d?"":"",x=0;7>x;x++)N=(x+u)%7,C+="";for(M+=C+"",A=this._getDaysInMonth(et,Z),et===e.selectedYear&&Z===e.selectedMonth&&(e.selectedDay=Math.min(e.selectedDay,A)),P=(this._getFirstDayOfMonth(et,Z)-u+7)%7,I=Math.ceil((P+A)/7),z=Q?this.maxRows>I?this.maxRows:I:I,this.maxRows=z,H=this._daylightSavingAdjust(new Date(et,Z,1-P)),F=0;z>F;F++){for(M+="",E=d?"":"",x=0;7>x;x++)O=g?g.apply(e.input?e.input[0]:null,[H]):[!0,""],j=H.getMonth()!==Z,W=j&&!y||!O[0]||X&&X>H||$&&H>$,E+="",H.setDate(H.getDate()+1),H=this._daylightSavingAdjust(H);M+=E+""}Z++,Z>11&&(Z=0,et++),M+="
      "+this._get(e,"weekHeader")+"=5?" class='ui-datepicker-week-end'":"")+">"+""+p[N]+"
      "+this._get(e,"calculateWeek")(H)+""+(j&&!v?" ":W?""+H.getDate()+"":""+H.getDate()+"")+"
      "+(Q?"
      "+(K[0]>0&&T===K[1]-1?"
      ":""):""),k+=M}_+=k}return _+=l,e._keyEvent=!1,_},_generateMonthYearHeader:function(e,t,i,s,n,a,o,r){var h,l,u,d,c,p,f,m,g=this._get(e,"changeMonth"),v=this._get(e,"changeYear"),y=this._get(e,"showMonthAfterYear"),b="
      ",_="";if(a||!g)_+=""+o[t]+"";else{for(h=s&&s.getFullYear()===i,l=n&&n.getFullYear()===i,_+=""}if(y||(b+=_+(!a&&g&&v?"":" ")),!e.yearshtml)if(e.yearshtml="",a||!v)b+=""+i+"";else{for(d=this._get(e,"yearRange").split(":"),c=(new Date).getFullYear(),p=function(e){var t=e.match(/c[+\-].*/)?i+parseInt(e.substring(1),10):e.match(/[+\-].*/)?c+parseInt(e,10):parseInt(e,10);return isNaN(t)?c:t},f=p(d[0]),m=Math.max(f,p(d[1]||"")),f=s?Math.max(f,s.getFullYear()):f,m=n?Math.min(m,n.getFullYear()):m,e.yearshtml+="",b+=e.yearshtml,e.yearshtml=null}return b+=this._get(e,"yearSuffix"),y&&(b+=(!a&&g&&v?"":" ")+_),b+="
      "},_adjustInstDate:function(e,t,i){var s=e.drawYear+("Y"===i?t:0),n=e.drawMonth+("M"===i?t:0),a=Math.min(e.selectedDay,this._getDaysInMonth(s,n))+("D"===i?t:0),o=this._restrictMinMax(e,this._daylightSavingAdjust(new Date(s,n,a)));e.selectedDay=o.getDate(),e.drawMonth=e.selectedMonth=o.getMonth(),e.drawYear=e.selectedYear=o.getFullYear(),("M"===i||"Y"===i)&&this._notifyChange(e)},_restrictMinMax:function(e,t){var i=this._getMinMaxDate(e,"min"),s=this._getMinMaxDate(e,"max"),n=i&&i>t?i:t;return s&&n>s?s:n},_notifyChange:function(e){var t=this._get(e,"onChangeMonthYear");t&&t.apply(e.input?e.input[0]:null,[e.selectedYear,e.selectedMonth+1,e])},_getNumberOfMonths:function(e){var t=this._get(e,"numberOfMonths");return null==t?[1,1]:"number"==typeof t?[1,t]:t},_getMinMaxDate:function(e,t){return this._determineDate(e,this._get(e,t+"Date"),null)},_getDaysInMonth:function(e,t){return 32-this._daylightSavingAdjust(new Date(e,t,32)).getDate()},_getFirstDayOfMonth:function(e,t){return new Date(e,t,1).getDay()},_canAdjustMonth:function(e,t,i,s){var n=this._getNumberOfMonths(e),a=this._daylightSavingAdjust(new Date(i,s+(0>t?t:n[0]*n[1]),1));return 0>t&&a.setDate(this._getDaysInMonth(a.getFullYear(),a.getMonth())),this._isInRange(e,a)},_isInRange:function(e,t){var i,s,n=this._getMinMaxDate(e,"min"),a=this._getMinMaxDate(e,"max"),o=null,r=null,h=this._get(e,"yearRange");return h&&(i=h.split(":"),s=(new Date).getFullYear(),o=parseInt(i[0],10),r=parseInt(i[1],10),i[0].match(/[+\-].*/)&&(o+=s),i[1].match(/[+\-].*/)&&(r+=s)),(!n||t.getTime()>=n.getTime())&&(!a||t.getTime()<=a.getTime())&&(!o||t.getFullYear()>=o)&&(!r||r>=t.getFullYear())},_getFormatConfig:function(e){var t=this._get(e,"shortYearCutoff");return t="string"!=typeof t?t:(new Date).getFullYear()%100+parseInt(t,10),{shortYearCutoff:t,dayNamesShort:this._get(e,"dayNamesShort"),dayNames:this._get(e,"dayNames"),monthNamesShort:this._get(e,"monthNamesShort"),monthNames:this._get(e,"monthNames")}},_formatDate:function(e,t,i,s){t||(e.currentDay=e.selectedDay,e.currentMonth=e.selectedMonth,e.currentYear=e.selectedYear);var n=t?"object"==typeof t?t:this._daylightSavingAdjust(new Date(s,i,t)):this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return this.formatDate(this._get(e,"dateFormat"),n,this._getFormatConfig(e))}}),e.fn.datepicker=function(t){if(!this.length)return this;e.datepicker.initialized||(e(document).mousedown(e.datepicker._checkExternalClick),e.datepicker.initialized=!0),0===e("#"+e.datepicker._mainDivId).length&&e("body").append(e.datepicker.dpDiv);var i=Array.prototype.slice.call(arguments,1);return"string"!=typeof t||"isDisabled"!==t&&"getDate"!==t&&"widget"!==t?"option"===t&&2===arguments.length&&"string"==typeof arguments[1]?e.datepicker["_"+t+"Datepicker"].apply(e.datepicker,[this[0]].concat(i)):this.each(function(){"string"==typeof t?e.datepicker["_"+t+"Datepicker"].apply(e.datepicker,[this].concat(i)):e.datepicker._attachDatepicker(this,t)}):e.datepicker["_"+t+"Datepicker"].apply(e.datepicker,[this[0]].concat(i))},e.datepicker=new n,e.datepicker.initialized=!1,e.datepicker.uuid=(new Date).getTime(),e.datepicker.version="1.11.2",e.datepicker,e.widget("ui.draggable",e.ui.mouse,{version:"1.11.2",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"===this.options.helper&&this._setPositionRelative(),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._setHandleClassName(),this._mouseInit()},_setOption:function(e,t){this._super(e,t),"handle"===e&&(this._removeHandleClassName(),this._setHandleClassName())},_destroy:function(){return(this.helper||this.element).is(".ui-draggable-dragging")?(this.destroyOnClear=!0,void 0):(this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._removeHandleClassName(),this._mouseDestroy(),void 0)},_mouseCapture:function(t){var i=this.options;return this._blurActiveElement(t),this.helper||i.disabled||e(t.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(t),this.handle?(this._blockFrames(i.iframeFix===!0?"iframe":i.iframeFix),!0):!1)},_blockFrames:function(t){this.iframeBlocks=this.document.find(t).map(function(){var t=e(this);return e("
      ").css("position","absolute").appendTo(t.parent()).outerWidth(t.outerWidth()).outerHeight(t.outerHeight()).offset(t.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_blurActiveElement:function(t){var i=this.document[0];if(this.handleElement.is(t.target))try{i.activeElement&&"body"!==i.activeElement.nodeName.toLowerCase()&&e(i.activeElement).blur()}catch(s){}},_mouseStart:function(t){var i=this.options;return this.helper=this._createHelper(t),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),e.ui.ddmanager&&(e.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(!0),this.offsetParent=this.helper.offsetParent(),this.hasFixedAncestor=this.helper.parents().filter(function(){return"fixed"===e(this).css("position")}).length>0,this.positionAbs=this.element.offset(),this._refreshOffsets(t),this.originalPosition=this.position=this._generatePosition(t,!1),this.originalPageX=t.pageX,this.originalPageY=t.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this._setContainment(),this._trigger("start",t)===!1?(this._clear(),!1):(this._cacheHelperProportions(),e.ui.ddmanager&&!i.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this._normalizeRightBottom(),this._mouseDrag(t,!0),e.ui.ddmanager&&e.ui.ddmanager.dragStart(this,t),!0)},_refreshOffsets:function(e){this.offset={top:this.positionAbs.top-this.margins.top,left:this.positionAbs.left-this.margins.left,scroll:!1,parent:this._getParentOffset(),relative:this._getRelativeOffset()},this.offset.click={left:e.pageX-this.offset.left,top:e.pageY-this.offset.top}},_mouseDrag:function(t,i){if(this.hasFixedAncestor&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(t,!0),this.positionAbs=this._convertPositionTo("absolute"),!i){var s=this._uiHash();if(this._trigger("drag",t,s)===!1)return this._mouseUp({}),!1;this.position=s.position}return this.helper[0].style.left=this.position.left+"px",this.helper[0].style.top=this.position.top+"px",e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),!1},_mouseStop:function(t){var i=this,s=!1;return e.ui.ddmanager&&!this.options.dropBehaviour&&(s=e.ui.ddmanager.drop(this,t)),this.dropped&&(s=this.dropped,this.dropped=!1),"invalid"===this.options.revert&&!s||"valid"===this.options.revert&&s||this.options.revert===!0||e.isFunction(this.options.revert)&&this.options.revert.call(this.element,s)?e(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){i._trigger("stop",t)!==!1&&i._clear()}):this._trigger("stop",t)!==!1&&this._clear(),!1},_mouseUp:function(t){return this._unblockFrames(),e.ui.ddmanager&&e.ui.ddmanager.dragStop(this,t),this.handleElement.is(t.target)&&this.element.focus(),e.ui.mouse.prototype._mouseUp.call(this,t)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(t){return this.options.handle?!!e(t.target).closest(this.element.find(this.options.handle)).length:!0},_setHandleClassName:function(){this.handleElement=this.options.handle?this.element.find(this.options.handle):this.element,this.handleElement.addClass("ui-draggable-handle")},_removeHandleClassName:function(){this.handleElement.removeClass("ui-draggable-handle")},_createHelper:function(t){var i=this.options,s=e.isFunction(i.helper),n=s?e(i.helper.apply(this.element[0],[t])):"clone"===i.helper?this.element.clone().removeAttr("id"):this.element;return n.parents("body").length||n.appendTo("parent"===i.appendTo?this.element[0].parentNode:i.appendTo),s&&n[0]===this.element[0]&&this._setPositionRelative(),n[0]===this.element[0]||/(fixed|absolute)/.test(n.css("position"))||n.css("position","absolute"),n},_setPositionRelative:function(){/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative")},_adjustOffsetFromHelper:function(t){"string"==typeof t&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_isRootNode:function(e){return/(html|body)/i.test(e.tagName)||e===this.document[0]},_getParentOffset:function(){var t=this.offsetParent.offset(),i=this.document[0];return"absolute"===this.cssPosition&&this.scrollParent[0]!==i&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop()),this._isRootNode(this.offsetParent[0])&&(t={top:0,left:0}),{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"!==this.cssPosition)return{top:0,left:0};var e=this.element.position(),t=this._isRootNode(this.scrollParent[0]);return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+(t?0:this.scrollParent.scrollTop()),left:e.left-(parseInt(this.helper.css("left"),10)||0)+(t?0:this.scrollParent.scrollLeft())}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t,i,s,n=this.options,a=this.document[0];return this.relativeContainer=null,n.containment?"window"===n.containment?(this.containment=[e(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,e(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,e(window).scrollLeft()+e(window).width()-this.helperProportions.width-this.margins.left,e(window).scrollTop()+(e(window).height()||a.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):"document"===n.containment?(this.containment=[0,0,e(a).width()-this.helperProportions.width-this.margins.left,(e(a).height()||a.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):n.containment.constructor===Array?(this.containment=n.containment,void 0):("parent"===n.containment&&(n.containment=this.helper[0].parentNode),i=e(n.containment),s=i[0],s&&(t=/(scroll|auto)/.test(i.css("overflow")),this.containment=[(parseInt(i.css("borderLeftWidth"),10)||0)+(parseInt(i.css("paddingLeft"),10)||0),(parseInt(i.css("borderTopWidth"),10)||0)+(parseInt(i.css("paddingTop"),10)||0),(t?Math.max(s.scrollWidth,s.offsetWidth):s.offsetWidth)-(parseInt(i.css("borderRightWidth"),10)||0)-(parseInt(i.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(t?Math.max(s.scrollHeight,s.offsetHeight):s.offsetHeight)-(parseInt(i.css("borderBottomWidth"),10)||0)-(parseInt(i.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relativeContainer=i),void 0):(this.containment=null,void 0) +},_convertPositionTo:function(e,t){t||(t=this.position);var i="absolute"===e?1:-1,s=this._isRootNode(this.scrollParent[0]);return{top:t.top+this.offset.relative.top*i+this.offset.parent.top*i-("fixed"===this.cssPosition?-this.offset.scroll.top:s?0:this.offset.scroll.top)*i,left:t.left+this.offset.relative.left*i+this.offset.parent.left*i-("fixed"===this.cssPosition?-this.offset.scroll.left:s?0:this.offset.scroll.left)*i}},_generatePosition:function(e,t){var i,s,n,a,o=this.options,r=this._isRootNode(this.scrollParent[0]),h=e.pageX,l=e.pageY;return r&&this.offset.scroll||(this.offset.scroll={top:this.scrollParent.scrollTop(),left:this.scrollParent.scrollLeft()}),t&&(this.containment&&(this.relativeContainer?(s=this.relativeContainer.offset(),i=[this.containment[0]+s.left,this.containment[1]+s.top,this.containment[2]+s.left,this.containment[3]+s.top]):i=this.containment,e.pageX-this.offset.click.lefti[2]&&(h=i[2]+this.offset.click.left),e.pageY-this.offset.click.top>i[3]&&(l=i[3]+this.offset.click.top)),o.grid&&(n=o.grid[1]?this.originalPageY+Math.round((l-this.originalPageY)/o.grid[1])*o.grid[1]:this.originalPageY,l=i?n-this.offset.click.top>=i[1]||n-this.offset.click.top>i[3]?n:n-this.offset.click.top>=i[1]?n-o.grid[1]:n+o.grid[1]:n,a=o.grid[0]?this.originalPageX+Math.round((h-this.originalPageX)/o.grid[0])*o.grid[0]:this.originalPageX,h=i?a-this.offset.click.left>=i[0]||a-this.offset.click.left>i[2]?a:a-this.offset.click.left>=i[0]?a-o.grid[0]:a+o.grid[0]:a),"y"===o.axis&&(h=this.originalPageX),"x"===o.axis&&(l=this.originalPageY)),{top:l-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.offset.scroll.top:r?0:this.offset.scroll.top),left:h-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.offset.scroll.left:r?0:this.offset.scroll.left)}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1,this.destroyOnClear&&this.destroy()},_normalizeRightBottom:function(){"y"!==this.options.axis&&"auto"!==this.helper.css("right")&&(this.helper.width(this.helper.width()),this.helper.css("right","auto")),"x"!==this.options.axis&&"auto"!==this.helper.css("bottom")&&(this.helper.height(this.helper.height()),this.helper.css("bottom","auto"))},_trigger:function(t,i,s){return s=s||this._uiHash(),e.ui.plugin.call(this,t,[i,s,this],!0),/^(drag|start|stop)/.test(t)&&(this.positionAbs=this._convertPositionTo("absolute"),s.offset=this.positionAbs),e.Widget.prototype._trigger.call(this,t,i,s)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),e.ui.plugin.add("draggable","connectToSortable",{start:function(t,i,s){var n=e.extend({},i,{item:s.element});s.sortables=[],e(s.options.connectToSortable).each(function(){var i=e(this).sortable("instance");i&&!i.options.disabled&&(s.sortables.push(i),i.refreshPositions(),i._trigger("activate",t,n))})},stop:function(t,i,s){var n=e.extend({},i,{item:s.element});s.cancelHelperRemoval=!1,e.each(s.sortables,function(){var e=this;e.isOver?(e.isOver=0,s.cancelHelperRemoval=!0,e.cancelHelperRemoval=!1,e._storedCSS={position:e.placeholder.css("position"),top:e.placeholder.css("top"),left:e.placeholder.css("left")},e._mouseStop(t),e.options.helper=e.options._helper):(e.cancelHelperRemoval=!0,e._trigger("deactivate",t,n))})},drag:function(t,i,s){e.each(s.sortables,function(){var n=!1,a=this;a.positionAbs=s.positionAbs,a.helperProportions=s.helperProportions,a.offset.click=s.offset.click,a._intersectsWith(a.containerCache)&&(n=!0,e.each(s.sortables,function(){return this.positionAbs=s.positionAbs,this.helperProportions=s.helperProportions,this.offset.click=s.offset.click,this!==a&&this._intersectsWith(this.containerCache)&&e.contains(a.element[0],this.element[0])&&(n=!1),n})),n?(a.isOver||(a.isOver=1,a.currentItem=i.helper.appendTo(a.element).data("ui-sortable-item",!0),a.options._helper=a.options.helper,a.options.helper=function(){return i.helper[0]},t.target=a.currentItem[0],a._mouseCapture(t,!0),a._mouseStart(t,!0,!0),a.offset.click.top=s.offset.click.top,a.offset.click.left=s.offset.click.left,a.offset.parent.left-=s.offset.parent.left-a.offset.parent.left,a.offset.parent.top-=s.offset.parent.top-a.offset.parent.top,s._trigger("toSortable",t),s.dropped=a.element,e.each(s.sortables,function(){this.refreshPositions()}),s.currentItem=s.element,a.fromOutside=s),a.currentItem&&(a._mouseDrag(t),i.position=a.position)):a.isOver&&(a.isOver=0,a.cancelHelperRemoval=!0,a.options._revert=a.options.revert,a.options.revert=!1,a._trigger("out",t,a._uiHash(a)),a._mouseStop(t,!0),a.options.revert=a.options._revert,a.options.helper=a.options._helper,a.placeholder&&a.placeholder.remove(),s._refreshOffsets(t),i.position=s._generatePosition(t,!0),s._trigger("fromSortable",t),s.dropped=!1,e.each(s.sortables,function(){this.refreshPositions()}))})}}),e.ui.plugin.add("draggable","cursor",{start:function(t,i,s){var n=e("body"),a=s.options;n.css("cursor")&&(a._cursor=n.css("cursor")),n.css("cursor",a.cursor)},stop:function(t,i,s){var n=s.options;n._cursor&&e("body").css("cursor",n._cursor)}}),e.ui.plugin.add("draggable","opacity",{start:function(t,i,s){var n=e(i.helper),a=s.options;n.css("opacity")&&(a._opacity=n.css("opacity")),n.css("opacity",a.opacity)},stop:function(t,i,s){var n=s.options;n._opacity&&e(i.helper).css("opacity",n._opacity)}}),e.ui.plugin.add("draggable","scroll",{start:function(e,t,i){i.scrollParentNotHidden||(i.scrollParentNotHidden=i.helper.scrollParent(!1)),i.scrollParentNotHidden[0]!==i.document[0]&&"HTML"!==i.scrollParentNotHidden[0].tagName&&(i.overflowOffset=i.scrollParentNotHidden.offset())},drag:function(t,i,s){var n=s.options,a=!1,o=s.scrollParentNotHidden[0],r=s.document[0];o!==r&&"HTML"!==o.tagName?(n.axis&&"x"===n.axis||(s.overflowOffset.top+o.offsetHeight-t.pageY=0;c--)h=s.snapElements[c].left-s.margins.left,l=h+s.snapElements[c].width,u=s.snapElements[c].top-s.margins.top,d=u+s.snapElements[c].height,h-m>v||g>l+m||u-m>b||y>d+m||!e.contains(s.snapElements[c].item.ownerDocument,s.snapElements[c].item)?(s.snapElements[c].snapping&&s.options.snap.release&&s.options.snap.release.call(s.element,t,e.extend(s._uiHash(),{snapItem:s.snapElements[c].item})),s.snapElements[c].snapping=!1):("inner"!==f.snapMode&&(n=m>=Math.abs(u-b),a=m>=Math.abs(d-y),o=m>=Math.abs(h-v),r=m>=Math.abs(l-g),n&&(i.position.top=s._convertPositionTo("relative",{top:u-s.helperProportions.height,left:0}).top),a&&(i.position.top=s._convertPositionTo("relative",{top:d,left:0}).top),o&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h-s.helperProportions.width}).left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l}).left)),p=n||a||o||r,"outer"!==f.snapMode&&(n=m>=Math.abs(u-y),a=m>=Math.abs(d-b),o=m>=Math.abs(h-g),r=m>=Math.abs(l-v),n&&(i.position.top=s._convertPositionTo("relative",{top:u,left:0}).top),a&&(i.position.top=s._convertPositionTo("relative",{top:d-s.helperProportions.height,left:0}).top),o&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h}).left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l-s.helperProportions.width}).left)),!s.snapElements[c].snapping&&(n||a||o||r||p)&&s.options.snap.snap&&s.options.snap.snap.call(s.element,t,e.extend(s._uiHash(),{snapItem:s.snapElements[c].item})),s.snapElements[c].snapping=n||a||o||r||p)}}),e.ui.plugin.add("draggable","stack",{start:function(t,i,s){var n,a=s.options,o=e.makeArray(e(a.stack)).sort(function(t,i){return(parseInt(e(t).css("zIndex"),10)||0)-(parseInt(e(i).css("zIndex"),10)||0)});o.length&&(n=parseInt(e(o[0]).css("zIndex"),10)||0,e(o).each(function(t){e(this).css("zIndex",n+t)}),this.css("zIndex",n+o.length))}}),e.ui.plugin.add("draggable","zIndex",{start:function(t,i,s){var n=e(i.helper),a=s.options;n.css("zIndex")&&(a._zIndex=n.css("zIndex")),n.css("zIndex",a.zIndex)},stop:function(t,i,s){var n=s.options;n._zIndex&&e(i.helper).css("zIndex",n._zIndex)}}),e.ui.draggable,e.widget("ui.resizable",e.ui.mouse,{version:"1.11.2",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_num:function(e){return parseInt(e,10)||0},_isNumber:function(e){return!isNaN(parseInt(e,10))},_hasScroll:function(t,i){if("hidden"===e(t).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",n=!1;return t[s]>0?!0:(t[s]=1,n=t[s]>0,t[s]=0,n)},_create:function(){var t,i,s,n,a,o=this,r=this.options;if(this.element.addClass("ui-resizable"),e.extend(this,{_aspectRatio:!!r.aspectRatio,aspectRatio:r.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:r.helper||r.ghost||r.animate?r.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(e("
      ").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=r.handles||(e(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),t=this.handles.split(","),this.handles={},i=0;t.length>i;i++)s=e.trim(t[i]),a="ui-resizable-"+s,n=e("
      "),n.css({zIndex:r.zIndex}),"se"===s&&n.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[s]=".ui-resizable-"+s,this.element.append(n);this._renderAxis=function(t){var i,s,n,a;t=t||this.element;for(i in this.handles)this.handles[i].constructor===String&&(this.handles[i]=this.element.children(this.handles[i]).first().show()),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)&&(s=e(this.handles[i],this.element),a=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),t.css(n,a),this._proportionallyResize()),e(this.handles[i]).length},this._renderAxis(this.element),this._handles=e(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){o.resizing||(this.className&&(n=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),o.axis=n&&n[1]?n[1]:"se")}),r.autoHide&&(this._handles.hide(),e(this.element).addClass("ui-resizable-autohide").mouseenter(function(){r.disabled||(e(this).removeClass("ui-resizable-autohide"),o._handles.show())}).mouseleave(function(){r.disabled||o.resizing||(e(this).addClass("ui-resizable-autohide"),o._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var t,i=function(t){e(t).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),t=this.element,this.originalElement.css({position:t.css("position"),width:t.outerWidth(),height:t.outerHeight(),top:t.css("top"),left:t.css("left")}).insertAfter(t),t.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_mouseCapture:function(t){var i,s,n=!1;for(i in this.handles)s=e(this.handles[i])[0],(s===t.target||e.contains(s,t.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(t){var i,s,n,a=this.options,o=this.element;return this.resizing=!0,this._renderProxy(),i=this._num(this.helper.css("left")),s=this._num(this.helper.css("top")),a.containment&&(i+=e(a.containment).scrollLeft()||0,s+=e(a.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:i,top:s},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:o.width(),height:o.height()},this.originalSize=this._helper?{width:o.outerWidth(),height:o.outerHeight()}:{width:o.width(),height:o.height()},this.sizeDiff={width:o.outerWidth()-o.width(),height:o.outerHeight()-o.height()},this.originalPosition={left:i,top:s},this.originalMousePosition={left:t.pageX,top:t.pageY},this.aspectRatio="number"==typeof a.aspectRatio?a.aspectRatio:this.originalSize.width/this.originalSize.height||1,n=e(".ui-resizable-"+this.axis).css("cursor"),e("body").css("cursor","auto"===n?this.axis+"-resize":n),o.addClass("ui-resizable-resizing"),this._propagate("start",t),!0},_mouseDrag:function(t){var i,s,n=this.originalMousePosition,a=this.axis,o=t.pageX-n.left||0,r=t.pageY-n.top||0,h=this._change[a];return this._updatePrevProperties(),h?(i=h.apply(this,[t,o,r]),this._updateVirtualBoundaries(t.shiftKey),(this._aspectRatio||t.shiftKey)&&(i=this._updateRatio(i,t)),i=this._respectSize(i,t),this._updateCache(i),this._propagate("resize",t),s=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),e.isEmptyObject(s)||(this._updatePrevProperties(),this._trigger("resize",t,this.ui()),this._applyChanges()),!1):!1},_mouseStop:function(t){this.resizing=!1;var i,s,n,a,o,r,h,l=this.options,u=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&this._hasScroll(i[0],"left")?0:u.sizeDiff.height,a=s?0:u.sizeDiff.width,o={width:u.helper.width()-a,height:u.helper.height()-n},r=parseInt(u.element.css("left"),10)+(u.position.left-u.originalPosition.left)||null,h=parseInt(u.element.css("top"),10)+(u.position.top-u.originalPosition.top)||null,l.animate||this.element.css(e.extend(o,{top:h,left:r})),u.helper.height(u.size.height),u.helper.width(u.size.width),this._helper&&!l.animate&&this._proportionallyResize()),e("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var e={};return this.position.top!==this.prevPosition.top&&(e.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(e.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(e.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(e.height=this.size.height+"px"),this.helper.css(e),e},_updateVirtualBoundaries:function(e){var t,i,s,n,a,o=this.options;a={minWidth:this._isNumber(o.minWidth)?o.minWidth:0,maxWidth:this._isNumber(o.maxWidth)?o.maxWidth:1/0,minHeight:this._isNumber(o.minHeight)?o.minHeight:0,maxHeight:this._isNumber(o.maxHeight)?o.maxHeight:1/0},(this._aspectRatio||e)&&(t=a.minHeight*this.aspectRatio,s=a.minWidth/this.aspectRatio,i=a.maxHeight*this.aspectRatio,n=a.maxWidth/this.aspectRatio,t>a.minWidth&&(a.minWidth=t),s>a.minHeight&&(a.minHeight=s),a.maxWidth>i&&(a.maxWidth=i),a.maxHeight>n&&(a.maxHeight=n)),this._vBoundaries=a},_updateCache:function(e){this.offset=this.helper.offset(),this._isNumber(e.left)&&(this.position.left=e.left),this._isNumber(e.top)&&(this.position.top=e.top),this._isNumber(e.height)&&(this.size.height=e.height),this._isNumber(e.width)&&(this.size.width=e.width)},_updateRatio:function(e){var t=this.position,i=this.size,s=this.axis;return this._isNumber(e.height)?e.width=e.height*this.aspectRatio:this._isNumber(e.width)&&(e.height=e.width/this.aspectRatio),"sw"===s&&(e.left=t.left+(i.width-e.width),e.top=null),"nw"===s&&(e.top=t.top+(i.height-e.height),e.left=t.left+(i.width-e.width)),e},_respectSize:function(e){var t=this._vBoundaries,i=this.axis,s=this._isNumber(e.width)&&t.maxWidth&&t.maxWidthe.width,o=this._isNumber(e.height)&&t.minHeight&&t.minHeight>e.height,r=this.originalPosition.left+this.originalSize.width,h=this.position.top+this.size.height,l=/sw|nw|w/.test(i),u=/nw|ne|n/.test(i);return a&&(e.width=t.minWidth),o&&(e.height=t.minHeight),s&&(e.width=t.maxWidth),n&&(e.height=t.maxHeight),a&&l&&(e.left=r-t.minWidth),s&&l&&(e.left=r-t.maxWidth),o&&u&&(e.top=h-t.minHeight),n&&u&&(e.top=h-t.maxHeight),e.width||e.height||e.left||!e.top?e.width||e.height||e.top||!e.left||(e.left=null):e.top=null,e},_getPaddingPlusBorderDimensions:function(e){for(var t=0,i=[],s=[e.css("borderTopWidth"),e.css("borderRightWidth"),e.css("borderBottomWidth"),e.css("borderLeftWidth")],n=[e.css("paddingTop"),e.css("paddingRight"),e.css("paddingBottom"),e.css("paddingLeft")];4>t;t++)i[t]=parseInt(s[t],10)||0,i[t]+=parseInt(n[t],10)||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var e,t=0,i=this.helper||this.element;this._proportionallyResizeElements.length>t;t++)e=this._proportionallyResizeElements[t],this.outerDimensions||(this.outerDimensions=this._getPaddingPlusBorderDimensions(e)),e.css({height:i.height()-this.outerDimensions.height||0,width:i.width()-this.outerDimensions.width||0})},_renderProxy:function(){var t=this.element,i=this.options;this.elementOffset=t.offset(),this._helper?(this.helper=this.helper||e("
      "),this.helper.addClass(this._helper).css({width:this.element.outerWidth()-1,height:this.element.outerHeight()-1,position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(e,t){return{width:this.originalSize.width+t}},w:function(e,t){var i=this.originalSize,s=this.originalPosition;return{left:s.left+t,width:i.width-t}},n:function(e,t,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(e,t,i){return{height:this.originalSize.height+i}},se:function(t,i,s){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,i,s]))},sw:function(t,i,s){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,i,s]))},ne:function(t,i,s){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,i,s]))},nw:function(t,i,s){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,i,s]))}},_propagate:function(t,i){e.ui.plugin.call(this,t,[i,this.ui()]),"resize"!==t&&this._trigger(t,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),e.ui.plugin.add("resizable","animate",{stop:function(t){var i=e(this).resizable("instance"),s=i.options,n=i._proportionallyResizeElements,a=n.length&&/textarea/i.test(n[0].nodeName),o=a&&i._hasScroll(n[0],"left")?0:i.sizeDiff.height,r=a?0:i.sizeDiff.width,h={width:i.size.width-r,height:i.size.height-o},l=parseInt(i.element.css("left"),10)+(i.position.left-i.originalPosition.left)||null,u=parseInt(i.element.css("top"),10)+(i.position.top-i.originalPosition.top)||null;i.element.animate(e.extend(h,u&&l?{top:u,left:l}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseInt(i.element.css("width"),10),height:parseInt(i.element.css("height"),10),top:parseInt(i.element.css("top"),10),left:parseInt(i.element.css("left"),10)};n&&n.length&&e(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",t)}})}}),e.ui.plugin.add("resizable","containment",{start:function(){var t,i,s,n,a,o,r,h=e(this).resizable("instance"),l=h.options,u=h.element,d=l.containment,c=d instanceof e?d.get(0):/parent/.test(d)?u.parent().get(0):d;c&&(h.containerElement=e(c),/document/.test(d)||d===document?(h.containerOffset={left:0,top:0},h.containerPosition={left:0,top:0},h.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}):(t=e(c),i=[],e(["Top","Right","Left","Bottom"]).each(function(e,s){i[e]=h._num(t.css("padding"+s))}),h.containerOffset=t.offset(),h.containerPosition=t.position(),h.containerSize={height:t.innerHeight()-i[3],width:t.innerWidth()-i[1]},s=h.containerOffset,n=h.containerSize.height,a=h.containerSize.width,o=h._hasScroll(c,"left")?c.scrollWidth:a,r=h._hasScroll(c)?c.scrollHeight:n,h.parentData={element:c,left:s.left,top:s.top,width:o,height:r}))},resize:function(t){var i,s,n,a,o=e(this).resizable("instance"),r=o.options,h=o.containerOffset,l=o.position,u=o._aspectRatio||t.shiftKey,d={top:0,left:0},c=o.containerElement,p=!0;c[0]!==document&&/static/.test(c.css("position"))&&(d=h),l.left<(o._helper?h.left:0)&&(o.size.width=o.size.width+(o._helper?o.position.left-h.left:o.position.left-d.left),u&&(o.size.height=o.size.width/o.aspectRatio,p=!1),o.position.left=r.helper?h.left:0),l.top<(o._helper?h.top:0)&&(o.size.height=o.size.height+(o._helper?o.position.top-h.top:o.position.top),u&&(o.size.width=o.size.height*o.aspectRatio,p=!1),o.position.top=o._helper?h.top:0),n=o.containerElement.get(0)===o.element.parent().get(0),a=/relative|absolute/.test(o.containerElement.css("position")),n&&a?(o.offset.left=o.parentData.left+o.position.left,o.offset.top=o.parentData.top+o.position.top):(o.offset.left=o.element.offset().left,o.offset.top=o.element.offset().top),i=Math.abs(o.sizeDiff.width+(o._helper?o.offset.left-d.left:o.offset.left-h.left)),s=Math.abs(o.sizeDiff.height+(o._helper?o.offset.top-d.top:o.offset.top-h.top)),i+o.size.width>=o.parentData.width&&(o.size.width=o.parentData.width-i,u&&(o.size.height=o.size.width/o.aspectRatio,p=!1)),s+o.size.height>=o.parentData.height&&(o.size.height=o.parentData.height-s,u&&(o.size.width=o.size.height*o.aspectRatio,p=!1)),p||(o.position.left=o.prevPosition.left,o.position.top=o.prevPosition.top,o.size.width=o.prevSize.width,o.size.height=o.prevSize.height)},stop:function(){var t=e(this).resizable("instance"),i=t.options,s=t.containerOffset,n=t.containerPosition,a=t.containerElement,o=e(t.helper),r=o.offset(),h=o.outerWidth()-t.sizeDiff.width,l=o.outerHeight()-t.sizeDiff.height;t._helper&&!i.animate&&/relative/.test(a.css("position"))&&e(this).css({left:r.left-n.left-s.left,width:h,height:l}),t._helper&&!i.animate&&/static/.test(a.css("position"))&&e(this).css({left:r.left-n.left-s.left,width:h,height:l})}}),e.ui.plugin.add("resizable","alsoResize",{start:function(){var t=e(this).resizable("instance"),i=t.options,s=function(t){e(t).each(function(){var t=e(this);t.data("ui-resizable-alsoresize",{width:parseInt(t.width(),10),height:parseInt(t.height(),10),left:parseInt(t.css("left"),10),top:parseInt(t.css("top"),10)})})};"object"!=typeof i.alsoResize||i.alsoResize.parentNode?s(i.alsoResize):i.alsoResize.length?(i.alsoResize=i.alsoResize[0],s(i.alsoResize)):e.each(i.alsoResize,function(e){s(e)})},resize:function(t,i){var s=e(this).resizable("instance"),n=s.options,a=s.originalSize,o=s.originalPosition,r={height:s.size.height-a.height||0,width:s.size.width-a.width||0,top:s.position.top-o.top||0,left:s.position.left-o.left||0},h=function(t,s){e(t).each(function(){var t=e(this),n=e(this).data("ui-resizable-alsoresize"),a={},o=s&&s.length?s:t.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(o,function(e,t){var i=(n[t]||0)+(r[t]||0);i&&i>=0&&(a[t]=i||null)}),t.css(a)})};"object"!=typeof n.alsoResize||n.alsoResize.nodeType?h(n.alsoResize):e.each(n.alsoResize,function(e,t){h(e,t)})},stop:function(){e(this).removeData("resizable-alsoresize")}}),e.ui.plugin.add("resizable","ghost",{start:function(){var t=e(this).resizable("instance"),i=t.options,s=t.size;t.ghost=t.originalElement.clone(),t.ghost.css({opacity:.25,display:"block",position:"relative",height:s.height,width:s.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass("string"==typeof i.ghost?i.ghost:""),t.ghost.appendTo(t.helper)},resize:function(){var t=e(this).resizable("instance");t.ghost&&t.ghost.css({position:"relative",height:t.size.height,width:t.size.width})},stop:function(){var t=e(this).resizable("instance");t.ghost&&t.helper&&t.helper.get(0).removeChild(t.ghost.get(0))}}),e.ui.plugin.add("resizable","grid",{resize:function(){var t,i=e(this).resizable("instance"),s=i.options,n=i.size,a=i.originalSize,o=i.originalPosition,r=i.axis,h="number"==typeof s.grid?[s.grid,s.grid]:s.grid,l=h[0]||1,u=h[1]||1,d=Math.round((n.width-a.width)/l)*l,c=Math.round((n.height-a.height)/u)*u,p=a.width+d,f=a.height+c,m=s.maxWidth&&p>s.maxWidth,g=s.maxHeight&&f>s.maxHeight,v=s.minWidth&&s.minWidth>p,y=s.minHeight&&s.minHeight>f;s.grid=h,v&&(p+=l),y&&(f+=u),m&&(p-=l),g&&(f-=u),/^(se|s|e)$/.test(r)?(i.size.width=p,i.size.height=f):/^(ne)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.top=o.top-c):/^(sw)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.left=o.left-d):((0>=f-u||0>=p-l)&&(t=i._getPaddingPlusBorderDimensions(this)),f-u>0?(i.size.height=f,i.position.top=o.top-c):(f=u-t.height,i.size.height=f,i.position.top=o.top+a.height-f),p-l>0?(i.size.width=p,i.position.left=o.left-d):(p=u-t.height,i.size.width=p,i.position.left=o.left+a.width-p))}}),e.ui.resizable,e.widget("ui.dialog",{version:"1.11.2",options:{appendTo:"body",autoOpen:!0,buttons:[],closeOnEscape:!0,closeText:"Close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:null,maxWidth:null,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",of:window,collision:"fit",using:function(t){var i=e(this).css(t).offset().top;0>i&&e(this).css("top",t.top-i)}},resizable:!0,show:null,title:null,width:300,beforeClose:null,close:null,drag:null,dragStart:null,dragStop:null,focus:null,open:null,resize:null,resizeStart:null,resizeStop:null},sizeRelatedOptions:{buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},resizableRelatedOptions:{maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0},_create:function(){this.originalCss={display:this.element[0].style.display,width:this.element[0].style.width,minHeight:this.element[0].style.minHeight,maxHeight:this.element[0].style.maxHeight,height:this.element[0].style.height},this.originalPosition={parent:this.element.parent(),index:this.element.parent().children().index(this.element)},this.originalTitle=this.element.attr("title"),this.options.title=this.options.title||this.originalTitle,this._createWrapper(),this.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(this.uiDialog),this._createTitlebar(),this._createButtonPane(),this.options.draggable&&e.fn.draggable&&this._makeDraggable(),this.options.resizable&&e.fn.resizable&&this._makeResizable(),this._isOpen=!1,this._trackFocus()},_init:function(){this.options.autoOpen&&this.open()},_appendTo:function(){var t=this.options.appendTo;return t&&(t.jquery||t.nodeType)?e(t):this.document.find(t||"body").eq(0)},_destroy:function(){var e,t=this.originalPosition;this._destroyOverlay(),this.element.removeUniqueId().removeClass("ui-dialog-content ui-widget-content").css(this.originalCss).detach(),this.uiDialog.stop(!0,!0).remove(),this.originalTitle&&this.element.attr("title",this.originalTitle),e=t.parent.children().eq(t.index),e.length&&e[0]!==this.element[0]?e.before(this.element):t.parent.append(this.element)},widget:function(){return this.uiDialog},disable:e.noop,enable:e.noop,close:function(t){var i,s=this;if(this._isOpen&&this._trigger("beforeClose",t)!==!1){if(this._isOpen=!1,this._focusedElement=null,this._destroyOverlay(),this._untrackInstance(),!this.opener.filter(":focusable").focus().length)try{i=this.document[0].activeElement,i&&"body"!==i.nodeName.toLowerCase()&&e(i).blur()}catch(n){}this._hide(this.uiDialog,this.options.hide,function(){s._trigger("close",t)})}},isOpen:function(){return this._isOpen},moveToTop:function(){this._moveToTop()},_moveToTop:function(t,i){var s=!1,n=this.uiDialog.siblings(".ui-front:visible").map(function(){return+e(this).css("z-index")}).get(),a=Math.max.apply(null,n);return a>=+this.uiDialog.css("z-index")&&(this.uiDialog.css("z-index",a+1),s=!0),s&&!i&&this._trigger("focus",t),s},open:function(){var t=this;return this._isOpen?(this._moveToTop()&&this._focusTabbable(),void 0):(this._isOpen=!0,this.opener=e(this.document[0].activeElement),this._size(),this._position(),this._createOverlay(),this._moveToTop(null,!0),this.overlay&&this.overlay.css("z-index",this.uiDialog.css("z-index")-1),this._show(this.uiDialog,this.options.show,function(){t._focusTabbable(),t._trigger("focus")}),this._makeFocusTarget(),this._trigger("open"),void 0)},_focusTabbable:function(){var e=this._focusedElement;e||(e=this.element.find("[autofocus]")),e.length||(e=this.element.find(":tabbable")),e.length||(e=this.uiDialogButtonPane.find(":tabbable")),e.length||(e=this.uiDialogTitlebarClose.filter(":tabbable")),e.length||(e=this.uiDialog),e.eq(0).focus()},_keepFocus:function(t){function i(){var t=this.document[0].activeElement,i=this.uiDialog[0]===t||e.contains(this.uiDialog[0],t);i||this._focusTabbable()}t.preventDefault(),i.call(this),this._delay(i)},_createWrapper:function(){this.uiDialog=e("
      ").addClass("ui-dialog ui-widget ui-widget-content ui-corner-all ui-front "+this.options.dialogClass).hide().attr({tabIndex:-1,role:"dialog"}).appendTo(this._appendTo()),this._on(this.uiDialog,{keydown:function(t){if(this.options.closeOnEscape&&!t.isDefaultPrevented()&&t.keyCode&&t.keyCode===e.ui.keyCode.ESCAPE)return t.preventDefault(),this.close(t),void 0; +if(t.keyCode===e.ui.keyCode.TAB&&!t.isDefaultPrevented()){var i=this.uiDialog.find(":tabbable"),s=i.filter(":first"),n=i.filter(":last");t.target!==n[0]&&t.target!==this.uiDialog[0]||t.shiftKey?t.target!==s[0]&&t.target!==this.uiDialog[0]||!t.shiftKey||(this._delay(function(){n.focus()}),t.preventDefault()):(this._delay(function(){s.focus()}),t.preventDefault())}},mousedown:function(e){this._moveToTop(e)&&this._focusTabbable()}}),this.element.find("[aria-describedby]").length||this.uiDialog.attr({"aria-describedby":this.element.uniqueId().attr("id")})},_createTitlebar:function(){var t;this.uiDialogTitlebar=e("
      ").addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(this.uiDialog),this._on(this.uiDialogTitlebar,{mousedown:function(t){e(t.target).closest(".ui-dialog-titlebar-close")||this.uiDialog.focus()}}),this.uiDialogTitlebarClose=e("").button({label:this.options.closeText,icons:{primary:"ui-icon-closethick"},text:!1}).addClass("ui-dialog-titlebar-close").appendTo(this.uiDialogTitlebar),this._on(this.uiDialogTitlebarClose,{click:function(e){e.preventDefault(),this.close(e)}}),t=e("").uniqueId().addClass("ui-dialog-title").prependTo(this.uiDialogTitlebar),this._title(t),this.uiDialog.attr({"aria-labelledby":t.attr("id")})},_title:function(e){this.options.title||e.html(" "),e.text(this.options.title)},_createButtonPane:function(){this.uiDialogButtonPane=e("
      ").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),this.uiButtonSet=e("
      ").addClass("ui-dialog-buttonset").appendTo(this.uiDialogButtonPane),this._createButtons()},_createButtons:function(){var t=this,i=this.options.buttons;return this.uiDialogButtonPane.remove(),this.uiButtonSet.empty(),e.isEmptyObject(i)||e.isArray(i)&&!i.length?(this.uiDialog.removeClass("ui-dialog-buttons"),void 0):(e.each(i,function(i,s){var n,a;s=e.isFunction(s)?{click:s,text:i}:s,s=e.extend({type:"button"},s),n=s.click,s.click=function(){n.apply(t.element[0],arguments)},a={icons:s.icons,text:s.showText},delete s.icons,delete s.showText,e("",s).button(a).appendTo(t.uiButtonSet)}),this.uiDialog.addClass("ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog),void 0)},_makeDraggable:function(){function t(e){return{position:e.position,offset:e.offset}}var i=this,s=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(s,n){e(this).addClass("ui-dialog-dragging"),i._blockFrames(),i._trigger("dragStart",s,t(n))},drag:function(e,s){i._trigger("drag",e,t(s))},stop:function(n,a){var o=a.offset.left-i.document.scrollLeft(),r=a.offset.top-i.document.scrollTop();s.position={my:"left top",at:"left"+(o>=0?"+":"")+o+" "+"top"+(r>=0?"+":"")+r,of:i.window},e(this).removeClass("ui-dialog-dragging"),i._unblockFrames(),i._trigger("dragStop",n,t(a))}})},_makeResizable:function(){function t(e){return{originalPosition:e.originalPosition,originalSize:e.originalSize,position:e.position,size:e.size}}var i=this,s=this.options,n=s.resizable,a=this.uiDialog.css("position"),o="string"==typeof n?n:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:this.element,maxWidth:s.maxWidth,maxHeight:s.maxHeight,minWidth:s.minWidth,minHeight:this._minHeight(),handles:o,start:function(s,n){e(this).addClass("ui-dialog-resizing"),i._blockFrames(),i._trigger("resizeStart",s,t(n))},resize:function(e,s){i._trigger("resize",e,t(s))},stop:function(n,a){var o=i.uiDialog.offset(),r=o.left-i.document.scrollLeft(),h=o.top-i.document.scrollTop();s.height=i.uiDialog.height(),s.width=i.uiDialog.width(),s.position={my:"left top",at:"left"+(r>=0?"+":"")+r+" "+"top"+(h>=0?"+":"")+h,of:i.window},e(this).removeClass("ui-dialog-resizing"),i._unblockFrames(),i._trigger("resizeStop",n,t(a))}}).css("position",a)},_trackFocus:function(){this._on(this.widget(),{focusin:function(t){this._makeFocusTarget(),this._focusedElement=e(t.target)}})},_makeFocusTarget:function(){this._untrackInstance(),this._trackingInstances().unshift(this)},_untrackInstance:function(){var t=this._trackingInstances(),i=e.inArray(this,t);-1!==i&&t.splice(i,1)},_trackingInstances:function(){var e=this.document.data("ui-dialog-instances");return e||(e=[],this.document.data("ui-dialog-instances",e)),e},_minHeight:function(){var e=this.options;return"auto"===e.height?e.minHeight:Math.min(e.minHeight,e.height)},_position:function(){var e=this.uiDialog.is(":visible");e||this.uiDialog.show(),this.uiDialog.position(this.options.position),e||this.uiDialog.hide()},_setOptions:function(t){var i=this,s=!1,n={};e.each(t,function(e,t){i._setOption(e,t),e in i.sizeRelatedOptions&&(s=!0),e in i.resizableRelatedOptions&&(n[e]=t)}),s&&(this._size(),this._position()),this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option",n)},_setOption:function(e,t){var i,s,n=this.uiDialog;"dialogClass"===e&&n.removeClass(this.options.dialogClass).addClass(t),"disabled"!==e&&(this._super(e,t),"appendTo"===e&&this.uiDialog.appendTo(this._appendTo()),"buttons"===e&&this._createButtons(),"closeText"===e&&this.uiDialogTitlebarClose.button({label:""+t}),"draggable"===e&&(i=n.is(":data(ui-draggable)"),i&&!t&&n.draggable("destroy"),!i&&t&&this._makeDraggable()),"position"===e&&this._position(),"resizable"===e&&(s=n.is(":data(ui-resizable)"),s&&!t&&n.resizable("destroy"),s&&"string"==typeof t&&n.resizable("option","handles",t),s||t===!1||this._makeResizable()),"title"===e&&this._title(this.uiDialogTitlebar.find(".ui-dialog-title")))},_size:function(){var e,t,i,s=this.options;this.element.show().css({width:"auto",minHeight:0,maxHeight:"none",height:0}),s.minWidth>s.width&&(s.width=s.minWidth),e=this.uiDialog.css({height:"auto",width:s.width}).outerHeight(),t=Math.max(0,s.minHeight-e),i="number"==typeof s.maxHeight?Math.max(0,s.maxHeight-e):"none","auto"===s.height?this.element.css({minHeight:t,maxHeight:i,height:"auto"}):this.element.height(Math.max(0,s.height-e)),this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())},_blockFrames:function(){this.iframeBlocks=this.document.find("iframe").map(function(){var t=e(this);return e("
      ").css({position:"absolute",width:t.outerWidth(),height:t.outerHeight()}).appendTo(t.parent()).offset(t.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_allowInteraction:function(t){return e(t.target).closest(".ui-dialog").length?!0:!!e(t.target).closest(".ui-datepicker").length},_createOverlay:function(){if(this.options.modal){var t=!0;this._delay(function(){t=!1}),this.document.data("ui-dialog-overlays")||this._on(this.document,{focusin:function(e){t||this._allowInteraction(e)||(e.preventDefault(),this._trackingInstances()[0]._focusTabbable())}}),this.overlay=e("
      ").addClass("ui-widget-overlay ui-front").appendTo(this._appendTo()),this._on(this.overlay,{mousedown:"_keepFocus"}),this.document.data("ui-dialog-overlays",(this.document.data("ui-dialog-overlays")||0)+1)}},_destroyOverlay:function(){if(this.options.modal&&this.overlay){var e=this.document.data("ui-dialog-overlays")-1;e?this.document.data("ui-dialog-overlays",e):this.document.unbind("focusin").removeData("ui-dialog-overlays"),this.overlay.remove(),this.overlay=null}}}),e.widget("ui.droppable",{version:"1.11.2",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var t,i=this.options,s=i.accept;this.isover=!1,this.isout=!0,this.accept=e.isFunction(s)?s:function(e){return e.is(s)},this.proportions=function(){return arguments.length?(t=arguments[0],void 0):t?t:t={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight}},this._addToManager(i.scope),i.addClasses&&this.element.addClass("ui-droppable")},_addToManager:function(t){e.ui.ddmanager.droppables[t]=e.ui.ddmanager.droppables[t]||[],e.ui.ddmanager.droppables[t].push(this)},_splice:function(e){for(var t=0;e.length>t;t++)e[t]===this&&e.splice(t,1)},_destroy:function(){var t=e.ui.ddmanager.droppables[this.options.scope];this._splice(t),this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(t,i){if("accept"===t)this.accept=e.isFunction(i)?i:function(e){return e.is(i)};else if("scope"===t){var s=e.ui.ddmanager.droppables[this.options.scope];this._splice(s),this._addToManager(i)}this._super(t,i)},_activate:function(t){var i=e.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),i&&this._trigger("activate",t,this.ui(i))},_deactivate:function(t){var i=e.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),i&&this._trigger("deactivate",t,this.ui(i))},_over:function(t){var i=e.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",t,this.ui(i)))},_out:function(t){var i=e.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",t,this.ui(i)))},_drop:function(t,i){var s=i||e.ui.ddmanager.current,n=!1;return s&&(s.currentItem||s.element)[0]!==this.element[0]?(this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var i=e(this).droppable("instance");return i.options.greedy&&!i.options.disabled&&i.options.scope===s.options.scope&&i.accept.call(i.element[0],s.currentItem||s.element)&&e.ui.intersect(s,e.extend(i,{offset:i.element.offset()}),i.options.tolerance,t)?(n=!0,!1):void 0}),n?!1:this.accept.call(this.element[0],s.currentItem||s.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",t,this.ui(s)),this.element):!1):!1},ui:function(e){return{draggable:e.currentItem||e.element,helper:e.helper,position:e.position,offset:e.positionAbs}}}),e.ui.intersect=function(){function e(e,t,i){return e>=t&&t+i>e}return function(t,i,s,n){if(!i.offset)return!1;var a=(t.positionAbs||t.position.absolute).left+t.margins.left,o=(t.positionAbs||t.position.absolute).top+t.margins.top,r=a+t.helperProportions.width,h=o+t.helperProportions.height,l=i.offset.left,u=i.offset.top,d=l+i.proportions().width,c=u+i.proportions().height;switch(s){case"fit":return a>=l&&d>=r&&o>=u&&c>=h;case"intersect":return a+t.helperProportions.width/2>l&&d>r-t.helperProportions.width/2&&o+t.helperProportions.height/2>u&&c>h-t.helperProportions.height/2;case"pointer":return e(n.pageY,u,i.proportions().height)&&e(n.pageX,l,i.proportions().width);case"touch":return(o>=u&&c>=o||h>=u&&c>=h||u>o&&h>c)&&(a>=l&&d>=a||r>=l&&d>=r||l>a&&r>d);default:return!1}}}(),e.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(t,i){var s,n,a=e.ui.ddmanager.droppables[t.options.scope]||[],o=i?i.type:null,r=(t.currentItem||t.element).find(":data(ui-droppable)").addBack();e:for(s=0;a.length>s;s++)if(!(a[s].options.disabled||t&&!a[s].accept.call(a[s].element[0],t.currentItem||t.element))){for(n=0;r.length>n;n++)if(r[n]===a[s].element[0]){a[s].proportions().height=0;continue e}a[s].visible="none"!==a[s].element.css("display"),a[s].visible&&("mousedown"===o&&a[s]._activate.call(a[s],i),a[s].offset=a[s].element.offset(),a[s].proportions({width:a[s].element[0].offsetWidth,height:a[s].element[0].offsetHeight}))}},drop:function(t,i){var s=!1;return e.each((e.ui.ddmanager.droppables[t.options.scope]||[]).slice(),function(){this.options&&(!this.options.disabled&&this.visible&&e.ui.intersect(t,this,this.options.tolerance,i)&&(s=this._drop.call(this,i)||s),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],t.currentItem||t.element)&&(this.isout=!0,this.isover=!1,this._deactivate.call(this,i)))}),s},dragStart:function(t,i){t.element.parentsUntil("body").bind("scroll.droppable",function(){t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,i)})},drag:function(t,i){t.options.refreshPositions&&e.ui.ddmanager.prepareOffsets(t,i),e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(!this.options.disabled&&!this.greedyChild&&this.visible){var s,n,a,o=e.ui.intersect(t,this,this.options.tolerance,i),r=!o&&this.isover?"isout":o&&!this.isover?"isover":null;r&&(this.options.greedy&&(n=this.options.scope,a=this.element.parents(":data(ui-droppable)").filter(function(){return e(this).droppable("instance").options.scope===n}),a.length&&(s=e(a[0]).droppable("instance"),s.greedyChild="isover"===r)),s&&"isover"===r&&(s.isover=!1,s.isout=!0,s._out.call(s,i)),this[r]=!0,this["isout"===r?"isover":"isout"]=!1,this["isover"===r?"_over":"_out"].call(this,i),s&&"isout"===r&&(s.isout=!1,s.isover=!0,s._over.call(s,i)))}})},dragStop:function(t,i){t.element.parentsUntil("body").unbind("scroll.droppable"),t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,i)}},e.ui.droppable;var y="ui-effects-",b=e;e.effects={effect:{}},function(e,t){function i(e,t,i){var s=d[t.type]||{};return null==e?i||!t.def?null:t.def:(e=s.floor?~~e:parseFloat(e),isNaN(e)?t.def:s.mod?(e+s.mod)%s.mod:0>e?0:e>s.max?s.max:e)}function s(i){var s=l(),n=s._rgba=[];return i=i.toLowerCase(),f(h,function(e,a){var o,r=a.re.exec(i),h=r&&a.parse(r),l=a.space||"rgba";return h?(o=s[l](h),s[u[l].cache]=o[u[l].cache],n=s._rgba=o._rgba,!1):t}),n.length?("0,0,0,0"===n.join()&&e.extend(n,a.transparent),s):a[i]}function n(e,t,i){return i=(i+1)%1,1>6*i?e+6*(t-e)*i:1>2*i?t:2>3*i?e+6*(t-e)*(2/3-i):e}var a,o="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",r=/^([\-+])=\s*(\d+\.?\d*)/,h=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(e){return[e[1],e[2],e[3],e[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(e){return[2.55*e[1],2.55*e[2],2.55*e[3],e[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(e){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(e){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(e){return[e[1],e[2]/100,e[3]/100,e[4]]}}],l=e.Color=function(t,i,s,n){return new e.Color.fn.parse(t,i,s,n)},u={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},d={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},c=l.support={},p=e("

      ")[0],f=e.each;p.style.cssText="background-color:rgba(1,1,1,.5)",c.rgba=p.style.backgroundColor.indexOf("rgba")>-1,f(u,function(e,t){t.cache="_"+e,t.props.alpha={idx:3,type:"percent",def:1}}),l.fn=e.extend(l.prototype,{parse:function(n,o,r,h){if(n===t)return this._rgba=[null,null,null,null],this;(n.jquery||n.nodeType)&&(n=e(n).css(o),o=t);var d=this,c=e.type(n),p=this._rgba=[];return o!==t&&(n=[n,o,r,h],c="array"),"string"===c?this.parse(s(n)||a._default):"array"===c?(f(u.rgba.props,function(e,t){p[t.idx]=i(n[t.idx],t)}),this):"object"===c?(n instanceof l?f(u,function(e,t){n[t.cache]&&(d[t.cache]=n[t.cache].slice())}):f(u,function(t,s){var a=s.cache;f(s.props,function(e,t){if(!d[a]&&s.to){if("alpha"===e||null==n[e])return;d[a]=s.to(d._rgba)}d[a][t.idx]=i(n[e],t,!0)}),d[a]&&0>e.inArray(null,d[a].slice(0,3))&&(d[a][3]=1,s.from&&(d._rgba=s.from(d[a])))}),this):t},is:function(e){var i=l(e),s=!0,n=this;return f(u,function(e,a){var o,r=i[a.cache];return r&&(o=n[a.cache]||a.to&&a.to(n._rgba)||[],f(a.props,function(e,i){return null!=r[i.idx]?s=r[i.idx]===o[i.idx]:t})),s}),s},_space:function(){var e=[],t=this;return f(u,function(i,s){t[s.cache]&&e.push(i)}),e.pop()},transition:function(e,t){var s=l(e),n=s._space(),a=u[n],o=0===this.alpha()?l("transparent"):this,r=o[a.cache]||a.to(o._rgba),h=r.slice();return s=s[a.cache],f(a.props,function(e,n){var a=n.idx,o=r[a],l=s[a],u=d[n.type]||{};null!==l&&(null===o?h[a]=l:(u.mod&&(l-o>u.mod/2?o+=u.mod:o-l>u.mod/2&&(o-=u.mod)),h[a]=i((l-o)*t+o,n)))}),this[n](h)},blend:function(t){if(1===this._rgba[3])return this;var i=this._rgba.slice(),s=i.pop(),n=l(t)._rgba;return l(e.map(i,function(e,t){return(1-s)*n[t]+s*e}))},toRgbaString:function(){var t="rgba(",i=e.map(this._rgba,function(e,t){return null==e?t>2?1:0:e});return 1===i[3]&&(i.pop(),t="rgb("),t+i.join()+")"},toHslaString:function(){var t="hsla(",i=e.map(this.hsla(),function(e,t){return null==e&&(e=t>2?1:0),t&&3>t&&(e=Math.round(100*e)+"%"),e});return 1===i[3]&&(i.pop(),t="hsl("),t+i.join()+")"},toHexString:function(t){var i=this._rgba.slice(),s=i.pop();return t&&i.push(~~(255*s)),"#"+e.map(i,function(e){return e=(e||0).toString(16),1===e.length?"0"+e:e}).join("")},toString:function(){return 0===this._rgba[3]?"transparent":this.toRgbaString()}}),l.fn.parse.prototype=l.fn,u.hsla.to=function(e){if(null==e[0]||null==e[1]||null==e[2])return[null,null,null,e[3]];var t,i,s=e[0]/255,n=e[1]/255,a=e[2]/255,o=e[3],r=Math.max(s,n,a),h=Math.min(s,n,a),l=r-h,u=r+h,d=.5*u;return t=h===r?0:s===r?60*(n-a)/l+360:n===r?60*(a-s)/l+120:60*(s-n)/l+240,i=0===l?0:.5>=d?l/u:l/(2-u),[Math.round(t)%360,i,d,null==o?1:o]},u.hsla.from=function(e){if(null==e[0]||null==e[1]||null==e[2])return[null,null,null,e[3]];var t=e[0]/360,i=e[1],s=e[2],a=e[3],o=.5>=s?s*(1+i):s+i-s*i,r=2*s-o;return[Math.round(255*n(r,o,t+1/3)),Math.round(255*n(r,o,t)),Math.round(255*n(r,o,t-1/3)),a]},f(u,function(s,n){var a=n.props,o=n.cache,h=n.to,u=n.from;l.fn[s]=function(s){if(h&&!this[o]&&(this[o]=h(this._rgba)),s===t)return this[o].slice();var n,r=e.type(s),d="array"===r||"object"===r?s:arguments,c=this[o].slice();return f(a,function(e,t){var s=d["object"===r?e:t.idx];null==s&&(s=c[t.idx]),c[t.idx]=i(s,t)}),u?(n=l(u(c)),n[o]=c,n):l(c)},f(a,function(t,i){l.fn[t]||(l.fn[t]=function(n){var a,o=e.type(n),h="alpha"===t?this._hsla?"hsla":"rgba":s,l=this[h](),u=l[i.idx];return"undefined"===o?u:("function"===o&&(n=n.call(this,u),o=e.type(n)),null==n&&i.empty?this:("string"===o&&(a=r.exec(n),a&&(n=u+parseFloat(a[2])*("+"===a[1]?1:-1))),l[i.idx]=n,this[h](l)))})})}),l.hook=function(t){var i=t.split(" ");f(i,function(t,i){e.cssHooks[i]={set:function(t,n){var a,o,r="";if("transparent"!==n&&("string"!==e.type(n)||(a=s(n)))){if(n=l(a||n),!c.rgba&&1!==n._rgba[3]){for(o="backgroundColor"===i?t.parentNode:t;(""===r||"transparent"===r)&&o&&o.style;)try{r=e.css(o,"backgroundColor"),o=o.parentNode}catch(h){}n=n.blend(r&&"transparent"!==r?r:"_default")}n=n.toRgbaString()}try{t.style[i]=n}catch(h){}}},e.fx.step[i]=function(t){t.colorInit||(t.start=l(t.elem,i),t.end=l(t.end),t.colorInit=!0),e.cssHooks[i].set(t.elem,t.start.transition(t.end,t.pos))}})},l.hook(o),e.cssHooks.borderColor={expand:function(e){var t={};return f(["Top","Right","Bottom","Left"],function(i,s){t["border"+s+"Color"]=e}),t}},a=e.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(b),function(){function t(t){var i,s,n=t.ownerDocument.defaultView?t.ownerDocument.defaultView.getComputedStyle(t,null):t.currentStyle,a={};if(n&&n.length&&n[0]&&n[n[0]])for(s=n.length;s--;)i=n[s],"string"==typeof n[i]&&(a[e.camelCase(i)]=n[i]);else for(i in n)"string"==typeof n[i]&&(a[i]=n[i]);return a}function i(t,i){var s,a,o={};for(s in i)a=i[s],t[s]!==a&&(n[s]||(e.fx.step[s]||!isNaN(parseFloat(a)))&&(o[s]=a));return o}var s=["add","remove","toggle"],n={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};e.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(t,i){e.fx.step[i]=function(e){("none"!==e.end&&!e.setAttr||1===e.pos&&!e.setAttr)&&(b.style(e.elem,i,e.end),e.setAttr=!0)}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e.effects.animateClass=function(n,a,o,r){var h=e.speed(a,o,r);return this.queue(function(){var a,o=e(this),r=o.attr("class")||"",l=h.children?o.find("*").addBack():o;l=l.map(function(){var i=e(this);return{el:i,start:t(this)}}),a=function(){e.each(s,function(e,t){n[t]&&o[t+"Class"](n[t])})},a(),l=l.map(function(){return this.end=t(this.el[0]),this.diff=i(this.start,this.end),this}),o.attr("class",r),l=l.map(function(){var t=this,i=e.Deferred(),s=e.extend({},h,{queue:!1,complete:function(){i.resolve(t)}});return this.el.animate(this.diff,s),i.promise()}),e.when.apply(e,l.get()).done(function(){a(),e.each(arguments,function(){var t=this.el;e.each(this.diff,function(e){t.css(e,"")})}),h.complete.call(o[0])})})},e.fn.extend({addClass:function(t){return function(i,s,n,a){return s?e.effects.animateClass.call(this,{add:i},s,n,a):t.apply(this,arguments)}}(e.fn.addClass),removeClass:function(t){return function(i,s,n,a){return arguments.length>1?e.effects.animateClass.call(this,{remove:i},s,n,a):t.apply(this,arguments)}}(e.fn.removeClass),toggleClass:function(t){return function(i,s,n,a,o){return"boolean"==typeof s||void 0===s?n?e.effects.animateClass.call(this,s?{add:i}:{remove:i},n,a,o):t.apply(this,arguments):e.effects.animateClass.call(this,{toggle:i},s,n,a)}}(e.fn.toggleClass),switchClass:function(t,i,s,n,a){return e.effects.animateClass.call(this,{add:i,remove:t},s,n,a)}})}(),function(){function t(t,i,s,n){return e.isPlainObject(t)&&(i=t,t=t.effect),t={effect:t},null==i&&(i={}),e.isFunction(i)&&(n=i,s=null,i={}),("number"==typeof i||e.fx.speeds[i])&&(n=s,s=i,i={}),e.isFunction(s)&&(n=s,s=null),i&&e.extend(t,i),s=s||i.duration,t.duration=e.fx.off?0:"number"==typeof s?s:s in e.fx.speeds?e.fx.speeds[s]:e.fx.speeds._default,t.complete=n||i.complete,t}function i(t){return!t||"number"==typeof t||e.fx.speeds[t]?!0:"string"!=typeof t||e.effects.effect[t]?e.isFunction(t)?!0:"object"!=typeof t||t.effect?!1:!0:!0}e.extend(e.effects,{version:"1.11.2",save:function(e,t){for(var i=0;t.length>i;i++)null!==t[i]&&e.data(y+t[i],e[0].style[t[i]])},restore:function(e,t){var i,s;for(s=0;t.length>s;s++)null!==t[s]&&(i=e.data(y+t[s]),void 0===i&&(i=""),e.css(t[s],i))},setMode:function(e,t){return"toggle"===t&&(t=e.is(":hidden")?"show":"hide"),t},getBaseline:function(e,t){var i,s;switch(e[0]){case"top":i=0;break;case"middle":i=.5;break;case"bottom":i=1;break;default:i=e[0]/t.height}switch(e[1]){case"left":s=0;break;case"center":s=.5;break;case"right":s=1;break;default:s=e[1]/t.width}return{x:s,y:i}},createWrapper:function(t){if(t.parent().is(".ui-effects-wrapper"))return t.parent();var i={width:t.outerWidth(!0),height:t.outerHeight(!0),"float":t.css("float")},s=e("

      ").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),n={width:t.width(),height:t.height()},a=document.activeElement;try{a.id}catch(o){a=document.body}return t.wrap(s),(t[0]===a||e.contains(t[0],a))&&e(a).focus(),s=t.parent(),"static"===t.css("position")?(s.css({position:"relative"}),t.css({position:"relative"})):(e.extend(i,{position:t.css("position"),zIndex:t.css("z-index")}),e.each(["top","left","bottom","right"],function(e,s){i[s]=t.css(s),isNaN(parseInt(i[s],10))&&(i[s]="auto")}),t.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),t.css(n),s.css(i).show()},removeWrapper:function(t){var i=document.activeElement;return t.parent().is(".ui-effects-wrapper")&&(t.parent().replaceWith(t),(t[0]===i||e.contains(t[0],i))&&e(i).focus()),t},setTransition:function(t,i,s,n){return n=n||{},e.each(i,function(e,i){var a=t.cssUnit(i);a[0]>0&&(n[i]=a[0]*s+a[1])}),n}}),e.fn.extend({effect:function(){function i(t){function i(){e.isFunction(a)&&a.call(n[0]),e.isFunction(t)&&t()}var n=e(this),a=s.complete,r=s.mode;(n.is(":hidden")?"hide"===r:"show"===r)?(n[r](),i()):o.call(n[0],s,i)}var s=t.apply(this,arguments),n=s.mode,a=s.queue,o=e.effects.effect[s.effect];return e.fx.off||!o?n?this[n](s.duration,s.complete):this.each(function(){s.complete&&s.complete.call(this)}):a===!1?this.each(i):this.queue(a||"fx",i)},show:function(e){return function(s){if(i(s))return e.apply(this,arguments);var n=t.apply(this,arguments);return n.mode="show",this.effect.call(this,n)}}(e.fn.show),hide:function(e){return function(s){if(i(s))return e.apply(this,arguments);var n=t.apply(this,arguments);return n.mode="hide",this.effect.call(this,n)}}(e.fn.hide),toggle:function(e){return function(s){if(i(s)||"boolean"==typeof s)return e.apply(this,arguments);var n=t.apply(this,arguments);return n.mode="toggle",this.effect.call(this,n)}}(e.fn.toggle),cssUnit:function(t){var i=this.css(t),s=[];return e.each(["em","px","%","pt"],function(e,t){i.indexOf(t)>0&&(s=[parseFloat(i),t])}),s}})}(),function(){var t={};e.each(["Quad","Cubic","Quart","Quint","Expo"],function(e,i){t[i]=function(t){return Math.pow(t,e+2)}}),e.extend(t,{Sine:function(e){return 1-Math.cos(e*Math.PI/2)},Circ:function(e){return 1-Math.sqrt(1-e*e)},Elastic:function(e){return 0===e||1===e?e:-Math.pow(2,8*(e-1))*Math.sin((80*(e-1)-7.5)*Math.PI/15)},Back:function(e){return e*e*(3*e-2)},Bounce:function(e){for(var t,i=4;((t=Math.pow(2,--i))-1)/11>e;);return 1/Math.pow(4,3-i)-7.5625*Math.pow((3*t-2)/22-e,2)}}),e.each(t,function(t,i){e.easing["easeIn"+t]=i,e.easing["easeOut"+t]=function(e){return 1-i(1-e)},e.easing["easeInOut"+t]=function(e){return.5>e?i(2*e)/2:1-i(-2*e+2)/2}})}(),e.effects,e.effects.effect.blind=function(t,i){var s,n,a,o=e(this),r=/up|down|vertical/,h=/up|left|vertical|horizontal/,l=["position","top","bottom","left","right","height","width"],u=e.effects.setMode(o,t.mode||"hide"),d=t.direction||"up",c=r.test(d),p=c?"height":"width",f=c?"top":"left",m=h.test(d),g={},v="show"===u;o.parent().is(".ui-effects-wrapper")?e.effects.save(o.parent(),l):e.effects.save(o,l),o.show(),s=e.effects.createWrapper(o).css({overflow:"hidden"}),n=s[p](),a=parseFloat(s.css(f))||0,g[p]=v?n:0,m||(o.css(c?"bottom":"right",0).css(c?"top":"left","auto").css({position:"absolute"}),g[f]=v?a:n+a),v&&(s.css(p,0),m||s.css(f,a+n)),s.animate(g,{duration:t.duration,easing:t.easing,queue:!1,complete:function(){"hide"===u&&o.hide(),e.effects.restore(o,l),e.effects.removeWrapper(o),i()}})},e.effects.effect.bounce=function(t,i){var s,n,a,o=e(this),r=["position","top","bottom","left","right","height","width"],h=e.effects.setMode(o,t.mode||"effect"),l="hide"===h,u="show"===h,d=t.direction||"up",c=t.distance,p=t.times||5,f=2*p+(u||l?1:0),m=t.duration/f,g=t.easing,v="up"===d||"down"===d?"top":"left",y="up"===d||"left"===d,b=o.queue(),_=b.length;for((u||l)&&r.push("opacity"),e.effects.save(o,r),o.show(),e.effects.createWrapper(o),c||(c=o["top"===v?"outerHeight":"outerWidth"]()/3),u&&(a={opacity:1},a[v]=0,o.css("opacity",0).css(v,y?2*-c:2*c).animate(a,m,g)),l&&(c/=Math.pow(2,p-1)),a={},a[v]=0,s=0;p>s;s++)n={},n[v]=(y?"-=":"+=")+c,o.animate(n,m,g).animate(a,m,g),c=l?2*c:c/2;l&&(n={opacity:0},n[v]=(y?"-=":"+=")+c,o.animate(n,m,g)),o.queue(function(){l&&o.hide(),e.effects.restore(o,r),e.effects.removeWrapper(o),i()}),_>1&&b.splice.apply(b,[1,0].concat(b.splice(_,f+1))),o.dequeue()},e.effects.effect.clip=function(t,i){var s,n,a,o=e(this),r=["position","top","bottom","left","right","height","width"],h=e.effects.setMode(o,t.mode||"hide"),l="show"===h,u=t.direction||"vertical",d="vertical"===u,c=d?"height":"width",p=d?"top":"left",f={};e.effects.save(o,r),o.show(),s=e.effects.createWrapper(o).css({overflow:"hidden"}),n="IMG"===o[0].tagName?s:o,a=n[c](),l&&(n.css(c,0),n.css(p,a/2)),f[c]=l?a:0,f[p]=l?0:a/2,n.animate(f,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){l||o.hide(),e.effects.restore(o,r),e.effects.removeWrapper(o),i()}})},e.effects.effect.drop=function(t,i){var s,n=e(this),a=["position","top","bottom","left","right","opacity","height","width"],o=e.effects.setMode(n,t.mode||"hide"),r="show"===o,h=t.direction||"left",l="up"===h||"down"===h?"top":"left",u="up"===h||"left"===h?"pos":"neg",d={opacity:r?1:0};e.effects.save(n,a),n.show(),e.effects.createWrapper(n),s=t.distance||n["top"===l?"outerHeight":"outerWidth"](!0)/2,r&&n.css("opacity",0).css(l,"pos"===u?-s:s),d[l]=(r?"pos"===u?"+=":"-=":"pos"===u?"-=":"+=")+s,n.animate(d,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){"hide"===o&&n.hide(),e.effects.restore(n,a),e.effects.removeWrapper(n),i()}})},e.effects.effect.explode=function(t,i){function s(){b.push(this),b.length===d*c&&n()}function n(){p.css({visibility:"visible"}),e(b).remove(),m||p.hide(),i()}var a,o,r,h,l,u,d=t.pieces?Math.round(Math.sqrt(t.pieces)):3,c=d,p=e(this),f=e.effects.setMode(p,t.mode||"hide"),m="show"===f,g=p.show().css("visibility","hidden").offset(),v=Math.ceil(p.outerWidth()/c),y=Math.ceil(p.outerHeight()/d),b=[];for(a=0;d>a;a++)for(h=g.top+a*y,u=a-(d-1)/2,o=0;c>o;o++)r=g.left+o*v,l=o-(c-1)/2,p.clone().appendTo("body").wrap("
      ").css({position:"absolute",visibility:"visible",left:-o*v,top:-a*y}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:v,height:y,left:r+(m?l*v:0),top:h+(m?u*y:0),opacity:m?0:1}).animate({left:r+(m?0:l*v),top:h+(m?0:u*y),opacity:m?1:0},t.duration||500,t.easing,s)},e.effects.effect.fade=function(t,i){var s=e(this),n=e.effects.setMode(s,t.mode||"toggle");s.animate({opacity:n},{queue:!1,duration:t.duration,easing:t.easing,complete:i})},e.effects.effect.fold=function(t,i){var s,n,a=e(this),o=["position","top","bottom","left","right","height","width"],r=e.effects.setMode(a,t.mode||"hide"),h="show"===r,l="hide"===r,u=t.size||15,d=/([0-9]+)%/.exec(u),c=!!t.horizFirst,p=h!==c,f=p?["width","height"]:["height","width"],m=t.duration/2,g={},v={};e.effects.save(a,o),a.show(),s=e.effects.createWrapper(a).css({overflow:"hidden"}),n=p?[s.width(),s.height()]:[s.height(),s.width()],d&&(u=parseInt(d[1],10)/100*n[l?0:1]),h&&s.css(c?{height:0,width:u}:{height:u,width:0}),g[f[0]]=h?n[0]:u,v[f[1]]=h?n[1]:0,s.animate(g,m,t.easing).animate(v,m,t.easing,function(){l&&a.hide(),e.effects.restore(a,o),e.effects.removeWrapper(a),i()})},e.effects.effect.highlight=function(t,i){var s=e(this),n=["backgroundImage","backgroundColor","opacity"],a=e.effects.setMode(s,t.mode||"show"),o={backgroundColor:s.css("backgroundColor")};"hide"===a&&(o.opacity=0),e.effects.save(s,n),s.show().css({backgroundImage:"none",backgroundColor:t.color||"#ffff99"}).animate(o,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){"hide"===a&&s.hide(),e.effects.restore(s,n),i()}})},e.effects.effect.size=function(t,i){var s,n,a,o=e(this),r=["position","top","bottom","left","right","width","height","overflow","opacity"],h=["position","top","bottom","left","right","overflow","opacity"],l=["width","height","overflow"],u=["fontSize"],d=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],c=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],p=e.effects.setMode(o,t.mode||"effect"),f=t.restore||"effect"!==p,m=t.scale||"both",g=t.origin||["middle","center"],v=o.css("position"),y=f?r:h,b={height:0,width:0,outerHeight:0,outerWidth:0};"show"===p&&o.show(),s={height:o.height(),width:o.width(),outerHeight:o.outerHeight(),outerWidth:o.outerWidth()},"toggle"===t.mode&&"show"===p?(o.from=t.to||b,o.to=t.from||s):(o.from=t.from||("show"===p?b:s),o.to=t.to||("hide"===p?b:s)),a={from:{y:o.from.height/s.height,x:o.from.width/s.width},to:{y:o.to.height/s.height,x:o.to.width/s.width}},("box"===m||"both"===m)&&(a.from.y!==a.to.y&&(y=y.concat(d),o.from=e.effects.setTransition(o,d,a.from.y,o.from),o.to=e.effects.setTransition(o,d,a.to.y,o.to)),a.from.x!==a.to.x&&(y=y.concat(c),o.from=e.effects.setTransition(o,c,a.from.x,o.from),o.to=e.effects.setTransition(o,c,a.to.x,o.to))),("content"===m||"both"===m)&&a.from.y!==a.to.y&&(y=y.concat(u).concat(l),o.from=e.effects.setTransition(o,u,a.from.y,o.from),o.to=e.effects.setTransition(o,u,a.to.y,o.to)),e.effects.save(o,y),o.show(),e.effects.createWrapper(o),o.css("overflow","hidden").css(o.from),g&&(n=e.effects.getBaseline(g,s),o.from.top=(s.outerHeight-o.outerHeight())*n.y,o.from.left=(s.outerWidth-o.outerWidth())*n.x,o.to.top=(s.outerHeight-o.to.outerHeight)*n.y,o.to.left=(s.outerWidth-o.to.outerWidth)*n.x),o.css(o.from),("content"===m||"both"===m)&&(d=d.concat(["marginTop","marginBottom"]).concat(u),c=c.concat(["marginLeft","marginRight"]),l=r.concat(d).concat(c),o.find("*[width]").each(function(){var i=e(this),s={height:i.height(),width:i.width(),outerHeight:i.outerHeight(),outerWidth:i.outerWidth()}; +f&&e.effects.save(i,l),i.from={height:s.height*a.from.y,width:s.width*a.from.x,outerHeight:s.outerHeight*a.from.y,outerWidth:s.outerWidth*a.from.x},i.to={height:s.height*a.to.y,width:s.width*a.to.x,outerHeight:s.height*a.to.y,outerWidth:s.width*a.to.x},a.from.y!==a.to.y&&(i.from=e.effects.setTransition(i,d,a.from.y,i.from),i.to=e.effects.setTransition(i,d,a.to.y,i.to)),a.from.x!==a.to.x&&(i.from=e.effects.setTransition(i,c,a.from.x,i.from),i.to=e.effects.setTransition(i,c,a.to.x,i.to)),i.css(i.from),i.animate(i.to,t.duration,t.easing,function(){f&&e.effects.restore(i,l)})})),o.animate(o.to,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){0===o.to.opacity&&o.css("opacity",o.from.opacity),"hide"===p&&o.hide(),e.effects.restore(o,y),f||("static"===v?o.css({position:"relative",top:o.to.top,left:o.to.left}):e.each(["top","left"],function(e,t){o.css(t,function(t,i){var s=parseInt(i,10),n=e?o.to.left:o.to.top;return"auto"===i?n+"px":s+n+"px"})})),e.effects.removeWrapper(o),i()}})},e.effects.effect.scale=function(t,i){var s=e(this),n=e.extend(!0,{},t),a=e.effects.setMode(s,t.mode||"effect"),o=parseInt(t.percent,10)||(0===parseInt(t.percent,10)?0:"hide"===a?0:100),r=t.direction||"both",h=t.origin,l={height:s.height(),width:s.width(),outerHeight:s.outerHeight(),outerWidth:s.outerWidth()},u={y:"horizontal"!==r?o/100:1,x:"vertical"!==r?o/100:1};n.effect="size",n.queue=!1,n.complete=i,"effect"!==a&&(n.origin=h||["middle","center"],n.restore=!0),n.from=t.from||("show"===a?{height:0,width:0,outerHeight:0,outerWidth:0}:l),n.to={height:l.height*u.y,width:l.width*u.x,outerHeight:l.outerHeight*u.y,outerWidth:l.outerWidth*u.x},n.fade&&("show"===a&&(n.from.opacity=0,n.to.opacity=1),"hide"===a&&(n.from.opacity=1,n.to.opacity=0)),s.effect(n)},e.effects.effect.puff=function(t,i){var s=e(this),n=e.effects.setMode(s,t.mode||"hide"),a="hide"===n,o=parseInt(t.percent,10)||150,r=o/100,h={height:s.height(),width:s.width(),outerHeight:s.outerHeight(),outerWidth:s.outerWidth()};e.extend(t,{effect:"scale",queue:!1,fade:!0,mode:n,complete:i,percent:a?o:100,from:a?h:{height:h.height*r,width:h.width*r,outerHeight:h.outerHeight*r,outerWidth:h.outerWidth*r}}),s.effect(t)},e.effects.effect.pulsate=function(t,i){var s,n=e(this),a=e.effects.setMode(n,t.mode||"show"),o="show"===a,r="hide"===a,h=o||"hide"===a,l=2*(t.times||5)+(h?1:0),u=t.duration/l,d=0,c=n.queue(),p=c.length;for((o||!n.is(":visible"))&&(n.css("opacity",0).show(),d=1),s=1;l>s;s++)n.animate({opacity:d},u,t.easing),d=1-d;n.animate({opacity:d},u,t.easing),n.queue(function(){r&&n.hide(),i()}),p>1&&c.splice.apply(c,[1,0].concat(c.splice(p,l+1))),n.dequeue()},e.effects.effect.shake=function(t,i){var s,n=e(this),a=["position","top","bottom","left","right","height","width"],o=e.effects.setMode(n,t.mode||"effect"),r=t.direction||"left",h=t.distance||20,l=t.times||3,u=2*l+1,d=Math.round(t.duration/u),c="up"===r||"down"===r?"top":"left",p="up"===r||"left"===r,f={},m={},g={},v=n.queue(),y=v.length;for(e.effects.save(n,a),n.show(),e.effects.createWrapper(n),f[c]=(p?"-=":"+=")+h,m[c]=(p?"+=":"-=")+2*h,g[c]=(p?"-=":"+=")+2*h,n.animate(f,d,t.easing),s=1;l>s;s++)n.animate(m,d,t.easing).animate(g,d,t.easing);n.animate(m,d,t.easing).animate(f,d/2,t.easing).queue(function(){"hide"===o&&n.hide(),e.effects.restore(n,a),e.effects.removeWrapper(n),i()}),y>1&&v.splice.apply(v,[1,0].concat(v.splice(y,u+1))),n.dequeue()},e.effects.effect.slide=function(t,i){var s,n=e(this),a=["position","top","bottom","left","right","width","height"],o=e.effects.setMode(n,t.mode||"show"),r="show"===o,h=t.direction||"left",l="up"===h||"down"===h?"top":"left",u="up"===h||"left"===h,d={};e.effects.save(n,a),n.show(),s=t.distance||n["top"===l?"outerHeight":"outerWidth"](!0),e.effects.createWrapper(n).css({overflow:"hidden"}),r&&n.css(l,u?isNaN(s)?"-"+s:-s:s),d[l]=(r?u?"+=":"-=":u?"-=":"+=")+s,n.animate(d,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){"hide"===o&&n.hide(),e.effects.restore(n,a),e.effects.removeWrapper(n),i()}})},e.effects.effect.transfer=function(t,i){var s=e(this),n=e(t.to),a="fixed"===n.css("position"),o=e("body"),r=a?o.scrollTop():0,h=a?o.scrollLeft():0,l=n.offset(),u={top:l.top-r,left:l.left-h,height:n.innerHeight(),width:n.innerWidth()},d=s.offset(),c=e("
      ").appendTo(document.body).addClass(t.className).css({top:d.top-r,left:d.left-h,height:s.innerHeight(),width:s.innerWidth(),position:a?"fixed":"absolute"}).animate(u,t.duration,t.easing,function(){c.remove(),i()})},e.widget("ui.progressbar",{version:"1.11.2",options:{max:100,value:0,change:null,complete:null},min:0,_create:function(){this.oldValue=this.options.value=this._constrainedValue(),this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min}),this.valueDiv=e("
      ").appendTo(this.element),this._refreshValue()},_destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.valueDiv.remove()},value:function(e){return void 0===e?this.options.value:(this.options.value=this._constrainedValue(e),this._refreshValue(),void 0)},_constrainedValue:function(e){return void 0===e&&(e=this.options.value),this.indeterminate=e===!1,"number"!=typeof e&&(e=0),this.indeterminate?!1:Math.min(this.options.max,Math.max(this.min,e))},_setOptions:function(e){var t=e.value;delete e.value,this._super(e),this.options.value=this._constrainedValue(t),this._refreshValue()},_setOption:function(e,t){"max"===e&&(t=Math.max(this.min,t)),"disabled"===e&&this.element.toggleClass("ui-state-disabled",!!t).attr("aria-disabled",t),this._super(e,t)},_percentage:function(){return this.indeterminate?100:100*(this.options.value-this.min)/(this.options.max-this.min)},_refreshValue:function(){var t=this.options.value,i=this._percentage();this.valueDiv.toggle(this.indeterminate||t>this.min).toggleClass("ui-corner-right",t===this.options.max).width(i.toFixed(0)+"%"),this.element.toggleClass("ui-progressbar-indeterminate",this.indeterminate),this.indeterminate?(this.element.removeAttr("aria-valuenow"),this.overlayDiv||(this.overlayDiv=e("
      ").appendTo(this.valueDiv))):(this.element.attr({"aria-valuemax":this.options.max,"aria-valuenow":t}),this.overlayDiv&&(this.overlayDiv.remove(),this.overlayDiv=null)),this.oldValue!==t&&(this.oldValue=t,this._trigger("change")),t===this.options.max&&this._trigger("complete")}}),e.widget("ui.selectable",e.ui.mouse,{version:"1.11.2",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch",selected:null,selecting:null,start:null,stop:null,unselected:null,unselecting:null},_create:function(){var t,i=this;this.element.addClass("ui-selectable"),this.dragged=!1,this.refresh=function(){t=e(i.options.filter,i.element[0]),t.addClass("ui-selectee"),t.each(function(){var t=e(this),i=t.offset();e.data(this,"selectable-item",{element:this,$element:t,left:i.left,top:i.top,right:i.left+t.outerWidth(),bottom:i.top+t.outerHeight(),startselected:!1,selected:t.hasClass("ui-selected"),selecting:t.hasClass("ui-selecting"),unselecting:t.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=t.addClass("ui-selectee"),this._mouseInit(),this.helper=e("
      ")},_destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable ui-selectable-disabled"),this._mouseDestroy()},_mouseStart:function(t){var i=this,s=this.options;this.opos=[t.pageX,t.pageY],this.options.disabled||(this.selectees=e(s.filter,this.element[0]),this._trigger("start",t),e(s.appendTo).append(this.helper),this.helper.css({left:t.pageX,top:t.pageY,width:0,height:0}),s.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var s=e.data(this,"selectable-item");s.startselected=!0,t.metaKey||t.ctrlKey||(s.$element.removeClass("ui-selected"),s.selected=!1,s.$element.addClass("ui-unselecting"),s.unselecting=!0,i._trigger("unselecting",t,{unselecting:s.element}))}),e(t.target).parents().addBack().each(function(){var s,n=e.data(this,"selectable-item");return n?(s=!t.metaKey&&!t.ctrlKey||!n.$element.hasClass("ui-selected"),n.$element.removeClass(s?"ui-unselecting":"ui-selected").addClass(s?"ui-selecting":"ui-unselecting"),n.unselecting=!s,n.selecting=s,n.selected=s,s?i._trigger("selecting",t,{selecting:n.element}):i._trigger("unselecting",t,{unselecting:n.element}),!1):void 0}))},_mouseDrag:function(t){if(this.dragged=!0,!this.options.disabled){var i,s=this,n=this.options,a=this.opos[0],o=this.opos[1],r=t.pageX,h=t.pageY;return a>r&&(i=r,r=a,a=i),o>h&&(i=h,h=o,o=i),this.helper.css({left:a,top:o,width:r-a,height:h-o}),this.selectees.each(function(){var i=e.data(this,"selectable-item"),l=!1;i&&i.element!==s.element[0]&&("touch"===n.tolerance?l=!(i.left>r||a>i.right||i.top>h||o>i.bottom):"fit"===n.tolerance&&(l=i.left>a&&r>i.right&&i.top>o&&h>i.bottom),l?(i.selected&&(i.$element.removeClass("ui-selected"),i.selected=!1),i.unselecting&&(i.$element.removeClass("ui-unselecting"),i.unselecting=!1),i.selecting||(i.$element.addClass("ui-selecting"),i.selecting=!0,s._trigger("selecting",t,{selecting:i.element}))):(i.selecting&&((t.metaKey||t.ctrlKey)&&i.startselected?(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.$element.addClass("ui-selected"),i.selected=!0):(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.startselected&&(i.$element.addClass("ui-unselecting"),i.unselecting=!0),s._trigger("unselecting",t,{unselecting:i.element}))),i.selected&&(t.metaKey||t.ctrlKey||i.startselected||(i.$element.removeClass("ui-selected"),i.selected=!1,i.$element.addClass("ui-unselecting"),i.unselecting=!0,s._trigger("unselecting",t,{unselecting:i.element})))))}),!1}},_mouseStop:function(t){var i=this;return this.dragged=!1,e(".ui-unselecting",this.element[0]).each(function(){var s=e.data(this,"selectable-item");s.$element.removeClass("ui-unselecting"),s.unselecting=!1,s.startselected=!1,i._trigger("unselected",t,{unselected:s.element})}),e(".ui-selecting",this.element[0]).each(function(){var s=e.data(this,"selectable-item");s.$element.removeClass("ui-selecting").addClass("ui-selected"),s.selecting=!1,s.selected=!0,s.startselected=!0,i._trigger("selected",t,{selected:s.element})}),this._trigger("stop",t),this.helper.remove(),!1}}),e.widget("ui.selectmenu",{version:"1.11.2",defaultElement:"",widgetEventPrefix:"spin",options:{culture:null,icons:{down:"ui-icon-triangle-1-s",up:"ui-icon-triangle-1-n"},incremental:!0,max:null,min:null,numberFormat:null,page:10,step:1,change:null,spin:null,start:null,stop:null},_create:function(){this._setOption("max",this.options.max),this._setOption("min",this.options.min),this._setOption("step",this.options.step),""!==this.value()&&this._value(this.element.val(),!0),this._draw(),this._on(this._events),this._refresh(),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_getCreateOptions:function(){var t={},i=this.element;return e.each(["min","max","step"],function(e,s){var n=i.attr(s);void 0!==n&&n.length&&(t[s]=n)}),t},_events:{keydown:function(e){this._start(e)&&this._keydown(e)&&e.preventDefault()},keyup:"_stop",focus:function(){this.previous=this.element.val()},blur:function(e){return this.cancelBlur?(delete this.cancelBlur,void 0):(this._stop(),this._refresh(),this.previous!==this.element.val()&&this._trigger("change",e),void 0)},mousewheel:function(e,t){if(t){if(!this.spinning&&!this._start(e))return!1;this._spin((t>0?1:-1)*this.options.step,e),clearTimeout(this.mousewheelTimer),this.mousewheelTimer=this._delay(function(){this.spinning&&this._stop(e)},100),e.preventDefault()}},"mousedown .ui-spinner-button":function(t){function i(){var e=this.element[0]===this.document[0].activeElement;e||(this.element.focus(),this.previous=s,this._delay(function(){this.previous=s}))}var s;s=this.element[0]===this.document[0].activeElement?this.previous:this.element.val(),t.preventDefault(),i.call(this),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur,i.call(this)}),this._start(t)!==!1&&this._repeat(null,e(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t)},"mouseup .ui-spinner-button":"_stop","mouseenter .ui-spinner-button":function(t){return e(t.currentTarget).hasClass("ui-state-active")?this._start(t)===!1?!1:(this._repeat(null,e(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t),void 0):void 0},"mouseleave .ui-spinner-button":"_stop"},_draw:function(){var e=this.uiSpinner=this.element.addClass("ui-spinner-input").attr("autocomplete","off").wrap(this._uiSpinnerHtml()).parent().append(this._buttonHtml());this.element.attr("role","spinbutton"),this.buttons=e.find(".ui-spinner-button").attr("tabIndex",-1).button().removeClass("ui-corner-all"),this.buttons.height()>Math.ceil(.5*e.height())&&e.height()>0&&e.height(e.height()),this.options.disabled&&this.disable()},_keydown:function(t){var i=this.options,s=e.ui.keyCode;switch(t.keyCode){case s.UP:return this._repeat(null,1,t),!0;case s.DOWN:return this._repeat(null,-1,t),!0;case s.PAGE_UP:return this._repeat(null,i.page,t),!0;case s.PAGE_DOWN:return this._repeat(null,-i.page,t),!0}return!1},_uiSpinnerHtml:function(){return""},_buttonHtml:function(){return""+""+""+""+""},_start:function(e){return this.spinning||this._trigger("start",e)!==!1?(this.counter||(this.counter=1),this.spinning=!0,!0):!1},_repeat:function(e,t,i){e=e||500,clearTimeout(this.timer),this.timer=this._delay(function(){this._repeat(40,t,i)},e),this._spin(t*this.options.step,i)},_spin:function(e,t){var i=this.value()||0;this.counter||(this.counter=1),i=this._adjustValue(i+e*this._increment(this.counter)),this.spinning&&this._trigger("spin",t,{value:i})===!1||(this._value(i),this.counter++)},_increment:function(t){var i=this.options.incremental;return i?e.isFunction(i)?i(t):Math.floor(t*t*t/5e4-t*t/500+17*t/200+1):1},_precision:function(){var e=this._precisionOf(this.options.step);return null!==this.options.min&&(e=Math.max(e,this._precisionOf(this.options.min))),e},_precisionOf:function(e){var t=""+e,i=t.indexOf(".");return-1===i?0:t.length-i-1},_adjustValue:function(e){var t,i,s=this.options;return t=null!==s.min?s.min:0,i=e-t,i=Math.round(i/s.step)*s.step,e=t+i,e=parseFloat(e.toFixed(this._precision())),null!==s.max&&e>s.max?s.max:null!==s.min&&s.min>e?s.min:e},_stop:function(e){this.spinning&&(clearTimeout(this.timer),clearTimeout(this.mousewheelTimer),this.counter=0,this.spinning=!1,this._trigger("stop",e))},_setOption:function(e,t){if("culture"===e||"numberFormat"===e){var i=this._parse(this.element.val());return this.options[e]=t,this.element.val(this._format(i)),void 0}("max"===e||"min"===e||"step"===e)&&"string"==typeof t&&(t=this._parse(t)),"icons"===e&&(this.buttons.first().find(".ui-icon").removeClass(this.options.icons.up).addClass(t.up),this.buttons.last().find(".ui-icon").removeClass(this.options.icons.down).addClass(t.down)),this._super(e,t),"disabled"===e&&(this.widget().toggleClass("ui-state-disabled",!!t),this.element.prop("disabled",!!t),this.buttons.button(t?"disable":"enable"))},_setOptions:h(function(e){this._super(e)}),_parse:function(e){return"string"==typeof e&&""!==e&&(e=window.Globalize&&this.options.numberFormat?Globalize.parseFloat(e,10,this.options.culture):+e),""===e||isNaN(e)?null:e},_format:function(e){return""===e?"":window.Globalize&&this.options.numberFormat?Globalize.format(e,this.options.numberFormat,this.options.culture):e},_refresh:function(){this.element.attr({"aria-valuemin":this.options.min,"aria-valuemax":this.options.max,"aria-valuenow":this._parse(this.element.val())})},isValid:function(){var e=this.value();return null===e?!1:e===this._adjustValue(e)},_value:function(e,t){var i;""!==e&&(i=this._parse(e),null!==i&&(t||(i=this._adjustValue(i)),e=this._format(i))),this.element.val(e),this._refresh()},_destroy:function(){this.element.removeClass("ui-spinner-input").prop("disabled",!1).removeAttr("autocomplete").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.uiSpinner.replaceWith(this.element)},stepUp:h(function(e){this._stepUp(e)}),_stepUp:function(e){this._start()&&(this._spin((e||1)*this.options.step),this._stop())},stepDown:h(function(e){this._stepDown(e)}),_stepDown:function(e){this._start()&&(this._spin((e||1)*-this.options.step),this._stop())},pageUp:h(function(e){this._stepUp((e||1)*this.options.page)}),pageDown:h(function(e){this._stepDown((e||1)*this.options.page)}),value:function(e){return arguments.length?(h(this._value).call(this,e),void 0):this._parse(this.element.val())},widget:function(){return this.uiSpinner}}),e.widget("ui.tabs",{version:"1.11.2",delay:300,options:{active:null,collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_isLocal:function(){var e=/#.*$/;return function(t){var i,s;t=t.cloneNode(!1),i=t.href.replace(e,""),s=location.href.replace(e,"");try{i=decodeURIComponent(i)}catch(n){}try{s=decodeURIComponent(s)}catch(n){}return t.hash.length>1&&i===s}}(),_create:function(){var t=this,i=this.options;this.running=!1,this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").toggleClass("ui-tabs-collapsible",i.collapsible),this._processTabs(),i.active=this._initialActive(),e.isArray(i.disabled)&&(i.disabled=e.unique(i.disabled.concat(e.map(this.tabs.filter(".ui-state-disabled"),function(e){return t.tabs.index(e)}))).sort()),this.active=this.options.active!==!1&&this.anchors.length?this._findActive(i.active):e(),this._refresh(),this.active.length&&this.load(i.active)},_initialActive:function(){var t=this.options.active,i=this.options.collapsible,s=location.hash.substring(1);return null===t&&(s&&this.tabs.each(function(i,n){return e(n).attr("aria-controls")===s?(t=i,!1):void 0}),null===t&&(t=this.tabs.index(this.tabs.filter(".ui-tabs-active"))),(null===t||-1===t)&&(t=this.tabs.length?0:!1)),t!==!1&&(t=this.tabs.index(this.tabs.eq(t)),-1===t&&(t=i?!1:0)),!i&&t===!1&&this.anchors.length&&(t=0),t},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):e()}},_tabKeydown:function(t){var i=e(this.document[0].activeElement).closest("li"),s=this.tabs.index(i),n=!0;if(!this._handlePageNav(t)){switch(t.keyCode){case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:s++;break;case e.ui.keyCode.UP:case e.ui.keyCode.LEFT:n=!1,s--;break;case e.ui.keyCode.END:s=this.anchors.length-1;break;case e.ui.keyCode.HOME:s=0;break;case e.ui.keyCode.SPACE:return t.preventDefault(),clearTimeout(this.activating),this._activate(s),void 0;case e.ui.keyCode.ENTER:return t.preventDefault(),clearTimeout(this.activating),this._activate(s===this.options.active?!1:s),void 0;default:return}t.preventDefault(),clearTimeout(this.activating),s=this._focusNextTab(s,n),t.ctrlKey||(i.attr("aria-selected","false"),this.tabs.eq(s).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",s)},this.delay))}},_panelKeydown:function(t){this._handlePageNav(t)||t.ctrlKey&&t.keyCode===e.ui.keyCode.UP&&(t.preventDefault(),this.active.focus())},_handlePageNav:function(t){return t.altKey&&t.keyCode===e.ui.keyCode.PAGE_UP?(this._activate(this._focusNextTab(this.options.active-1,!1)),!0):t.altKey&&t.keyCode===e.ui.keyCode.PAGE_DOWN?(this._activate(this._focusNextTab(this.options.active+1,!0)),!0):void 0},_findNextTab:function(t,i){function s(){return t>n&&(t=0),0>t&&(t=n),t}for(var n=this.tabs.length-1;-1!==e.inArray(s(),this.options.disabled);)t=i?t+1:t-1;return t},_focusNextTab:function(e,t){return e=this._findNextTab(e,t),this.tabs.eq(e).focus(),e},_setOption:function(e,t){return"active"===e?(this._activate(t),void 0):"disabled"===e?(this._setupDisabled(t),void 0):(this._super(e,t),"collapsible"===e&&(this.element.toggleClass("ui-tabs-collapsible",t),t||this.options.active!==!1||this._activate(0)),"event"===e&&this._setupEvents(t),"heightStyle"===e&&this._setupHeightStyle(t),void 0)},_sanitizeSelector:function(e){return e?e.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var t=this.options,i=this.tablist.children(":has(a[href])");t.disabled=e.map(i.filter(".ui-state-disabled"),function(e){return i.index(e)}),this._processTabs(),t.active!==!1&&this.anchors.length?this.active.length&&!e.contains(this.tablist[0],this.active[0])?this.tabs.length===t.disabled.length?(t.active=!1,this.active=e()):this._activate(this._findNextTab(Math.max(0,t.active-1),!1)):t.active=this.tabs.index(this.active):(t.active=!1,this.active=e()),this._refresh()},_refresh:function(){this._setupDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-hidden":"true"}),this.active.length?(this.active.addClass("ui-tabs-active ui-state-active").attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}),this._getPanelForTab(this.active).show().attr({"aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var t=this,i=this.tabs,s=this.anchors,n=this.panels;this.tablist=this._getList().addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").attr("role","tablist").delegate("> li","mousedown"+this.eventNamespace,function(t){e(this).is(".ui-state-disabled")&&t.preventDefault()}).delegate(".ui-tabs-anchor","focus"+this.eventNamespace,function(){e(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this.tabs=this.tablist.find("> li:has(a[href])").addClass("ui-state-default ui-corner-top").attr({role:"tab",tabIndex:-1}),this.anchors=this.tabs.map(function(){return e("a",this)[0] +}).addClass("ui-tabs-anchor").attr({role:"presentation",tabIndex:-1}),this.panels=e(),this.anchors.each(function(i,s){var n,a,o,r=e(s).uniqueId().attr("id"),h=e(s).closest("li"),l=h.attr("aria-controls");t._isLocal(s)?(n=s.hash,o=n.substring(1),a=t.element.find(t._sanitizeSelector(n))):(o=h.attr("aria-controls")||e({}).uniqueId()[0].id,n="#"+o,a=t.element.find(n),a.length||(a=t._createPanel(o),a.insertAfter(t.panels[i-1]||t.tablist)),a.attr("aria-live","polite")),a.length&&(t.panels=t.panels.add(a)),l&&h.data("ui-tabs-aria-controls",l),h.attr({"aria-controls":o,"aria-labelledby":r}),a.attr("aria-labelledby",r)}),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").attr("role","tabpanel"),i&&(this._off(i.not(this.tabs)),this._off(s.not(this.anchors)),this._off(n.not(this.panels)))},_getList:function(){return this.tablist||this.element.find("ol,ul").eq(0)},_createPanel:function(t){return e("
      ").attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)},_setupDisabled:function(t){e.isArray(t)&&(t.length?t.length===this.anchors.length&&(t=!0):t=!1);for(var i,s=0;i=this.tabs[s];s++)t===!0||-1!==e.inArray(s,t)?e(i).addClass("ui-state-disabled").attr("aria-disabled","true"):e(i).removeClass("ui-state-disabled").removeAttr("aria-disabled");this.options.disabled=t},_setupEvents:function(t){var i={};t&&e.each(t.split(" "),function(e,t){i[t]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(!0,this.anchors,{click:function(e){e.preventDefault()}}),this._on(this.anchors,i),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(t){var i,s=this.element.parent();"fill"===t?(i=s.height(),i-=this.element.outerHeight()-this.element.height(),this.element.siblings(":visible").each(function(){var t=e(this),s=t.css("position");"absolute"!==s&&"fixed"!==s&&(i-=t.outerHeight(!0))}),this.element.children().not(this.panels).each(function(){i-=e(this).outerHeight(!0)}),this.panels.each(function(){e(this).height(Math.max(0,i-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):"auto"===t&&(i=0,this.panels.each(function(){i=Math.max(i,e(this).height("").height())}).height(i))},_eventHandler:function(t){var i=this.options,s=this.active,n=e(t.currentTarget),a=n.closest("li"),o=a[0]===s[0],r=o&&i.collapsible,h=r?e():this._getPanelForTab(a),l=s.length?this._getPanelForTab(s):e(),u={oldTab:s,oldPanel:l,newTab:r?e():a,newPanel:h};t.preventDefault(),a.hasClass("ui-state-disabled")||a.hasClass("ui-tabs-loading")||this.running||o&&!i.collapsible||this._trigger("beforeActivate",t,u)===!1||(i.active=r?!1:this.tabs.index(a),this.active=o?e():a,this.xhr&&this.xhr.abort(),l.length||h.length||e.error("jQuery UI Tabs: Mismatching fragment identifier."),h.length&&this.load(this.tabs.index(a),t),this._toggle(t,u))},_toggle:function(t,i){function s(){a.running=!1,a._trigger("activate",t,i)}function n(){i.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),o.length&&a.options.show?a._show(o,a.options.show,s):(o.show(),s())}var a=this,o=i.newPanel,r=i.oldPanel;this.running=!0,r.length&&this.options.hide?this._hide(r,this.options.hide,function(){i.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),n()}):(i.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),r.hide(),n()),r.attr("aria-hidden","true"),i.oldTab.attr({"aria-selected":"false","aria-expanded":"false"}),o.length&&r.length?i.oldTab.attr("tabIndex",-1):o.length&&this.tabs.filter(function(){return 0===e(this).attr("tabIndex")}).attr("tabIndex",-1),o.attr("aria-hidden","false"),i.newTab.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0})},_activate:function(t){var i,s=this._findActive(t);s[0]!==this.active[0]&&(s.length||(s=this.active),i=s.find(".ui-tabs-anchor")[0],this._eventHandler({target:i,currentTarget:i,preventDefault:e.noop}))},_findActive:function(t){return t===!1?e():this.tabs.eq(t)},_getIndex:function(e){return"string"==typeof e&&(e=this.anchors.index(this.anchors.filter("[href$='"+e+"']"))),e},_destroy:function(){this.xhr&&this.xhr.abort(),this.element.removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible"),this.tablist.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").removeAttr("role"),this.anchors.removeClass("ui-tabs-anchor").removeAttr("role").removeAttr("tabIndex").removeUniqueId(),this.tablist.unbind(this.eventNamespace),this.tabs.add(this.panels).each(function(){e.data(this,"ui-tabs-destroy")?e(this).remove():e(this).removeClass("ui-state-default ui-state-active ui-state-disabled ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel").removeAttr("tabIndex").removeAttr("aria-live").removeAttr("aria-busy").removeAttr("aria-selected").removeAttr("aria-labelledby").removeAttr("aria-hidden").removeAttr("aria-expanded").removeAttr("role")}),this.tabs.each(function(){var t=e(this),i=t.data("ui-tabs-aria-controls");i?t.attr("aria-controls",i).removeData("ui-tabs-aria-controls"):t.removeAttr("aria-controls")}),this.panels.show(),"content"!==this.options.heightStyle&&this.panels.css("height","")},enable:function(t){var i=this.options.disabled;i!==!1&&(void 0===t?i=!1:(t=this._getIndex(t),i=e.isArray(i)?e.map(i,function(e){return e!==t?e:null}):e.map(this.tabs,function(e,i){return i!==t?i:null})),this._setupDisabled(i))},disable:function(t){var i=this.options.disabled;if(i!==!0){if(void 0===t)i=!0;else{if(t=this._getIndex(t),-1!==e.inArray(t,i))return;i=e.isArray(i)?e.merge([t],i).sort():[t]}this._setupDisabled(i)}},load:function(t,i){t=this._getIndex(t);var s=this,n=this.tabs.eq(t),a=n.find(".ui-tabs-anchor"),o=this._getPanelForTab(n),r={tab:n,panel:o};this._isLocal(a[0])||(this.xhr=e.ajax(this._ajaxSettings(a,i,r)),this.xhr&&"canceled"!==this.xhr.statusText&&(n.addClass("ui-tabs-loading"),o.attr("aria-busy","true"),this.xhr.success(function(e){setTimeout(function(){o.html(e),s._trigger("load",i,r)},1)}).complete(function(e,t){setTimeout(function(){"abort"===t&&s.panels.stop(!1,!0),n.removeClass("ui-tabs-loading"),o.removeAttr("aria-busy"),e===s.xhr&&delete s.xhr},1)})))},_ajaxSettings:function(t,i,s){var n=this;return{url:t.attr("href"),beforeSend:function(t,a){return n._trigger("beforeLoad",i,e.extend({jqXHR:t,ajaxSettings:a},s))}}},_getPanelForTab:function(t){var i=e(t).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+i))}}),e.widget("ui.tooltip",{version:"1.11.2",options:{content:function(){var t=e(this).attr("title")||"";return e("").text(t).html()},hide:!0,items:"[title]:not([disabled])",position:{my:"left top+15",at:"left bottom",collision:"flipfit flip"},show:!0,tooltipClass:null,track:!1,close:null,open:null},_addDescribedBy:function(t,i){var s=(t.attr("aria-describedby")||"").split(/\s+/);s.push(i),t.data("ui-tooltip-id",i).attr("aria-describedby",e.trim(s.join(" ")))},_removeDescribedBy:function(t){var i=t.data("ui-tooltip-id"),s=(t.attr("aria-describedby")||"").split(/\s+/),n=e.inArray(i,s);-1!==n&&s.splice(n,1),t.removeData("ui-tooltip-id"),s=e.trim(s.join(" ")),s?t.attr("aria-describedby",s):t.removeAttr("aria-describedby")},_create:function(){this._on({mouseover:"open",focusin:"open"}),this.tooltips={},this.parents={},this.options.disabled&&this._disable(),this.liveRegion=e("
      ").attr({role:"log","aria-live":"assertive","aria-relevant":"additions"}).addClass("ui-helper-hidden-accessible").appendTo(this.document[0].body)},_setOption:function(t,i){var s=this;return"disabled"===t?(this[i?"_disable":"_enable"](),this.options[t]=i,void 0):(this._super(t,i),"content"===t&&e.each(this.tooltips,function(e,t){s._updateContent(t.element)}),void 0)},_disable:function(){var t=this;e.each(this.tooltips,function(i,s){var n=e.Event("blur");n.target=n.currentTarget=s.element[0],t.close(n,!0)}),this.element.find(this.options.items).addBack().each(function(){var t=e(this);t.is("[title]")&&t.data("ui-tooltip-title",t.attr("title")).removeAttr("title")})},_enable:function(){this.element.find(this.options.items).addBack().each(function(){var t=e(this);t.data("ui-tooltip-title")&&t.attr("title",t.data("ui-tooltip-title"))})},open:function(t){var i=this,s=e(t?t.target:this.element).closest(this.options.items);s.length&&!s.data("ui-tooltip-id")&&(s.attr("title")&&s.data("ui-tooltip-title",s.attr("title")),s.data("ui-tooltip-open",!0),t&&"mouseover"===t.type&&s.parents().each(function(){var t,s=e(this);s.data("ui-tooltip-open")&&(t=e.Event("blur"),t.target=t.currentTarget=this,i.close(t,!0)),s.attr("title")&&(s.uniqueId(),i.parents[this.id]={element:this,title:s.attr("title")},s.attr("title",""))}),this._updateContent(s,t))},_updateContent:function(e,t){var i,s=this.options.content,n=this,a=t?t.type:null;return"string"==typeof s?this._open(t,e,s):(i=s.call(e[0],function(i){e.data("ui-tooltip-open")&&n._delay(function(){t&&(t.type=a),this._open(t,e,i)})}),i&&this._open(t,e,i),void 0)},_open:function(t,i,s){function n(e){u.of=e,o.is(":hidden")||o.position(u)}var a,o,r,h,l,u=e.extend({},this.options.position);if(s){if(a=this._find(i))return a.tooltip.find(".ui-tooltip-content").html(s),void 0;i.is("[title]")&&(t&&"mouseover"===t.type?i.attr("title",""):i.removeAttr("title")),a=this._tooltip(i),o=a.tooltip,this._addDescribedBy(i,o.attr("id")),o.find(".ui-tooltip-content").html(s),this.liveRegion.children().hide(),s.clone?(l=s.clone(),l.removeAttr("id").find("[id]").removeAttr("id")):l=s,e("
      ").html(l).appendTo(this.liveRegion),this.options.track&&t&&/^mouse/.test(t.type)?(this._on(this.document,{mousemove:n}),n(t)):o.position(e.extend({of:i},this.options.position)),o.hide(),this._show(o,this.options.show),this.options.show&&this.options.show.delay&&(h=this.delayedShow=setInterval(function(){o.is(":visible")&&(n(u.of),clearInterval(h))},e.fx.interval)),this._trigger("open",t,{tooltip:o}),r={keyup:function(t){if(t.keyCode===e.ui.keyCode.ESCAPE){var s=e.Event(t);s.currentTarget=i[0],this.close(s,!0)}}},i[0]!==this.element[0]&&(r.remove=function(){this._removeTooltip(o)}),t&&"mouseover"!==t.type||(r.mouseleave="close"),t&&"focusin"!==t.type||(r.focusout="close"),this._on(!0,i,r)}},close:function(t){var i,s=this,n=e(t?t.currentTarget:this.element),a=this._find(n);a&&(i=a.tooltip,a.closing||(clearInterval(this.delayedShow),n.data("ui-tooltip-title")&&!n.attr("title")&&n.attr("title",n.data("ui-tooltip-title")),this._removeDescribedBy(n),a.hiding=!0,i.stop(!0),this._hide(i,this.options.hide,function(){s._removeTooltip(e(this))}),n.removeData("ui-tooltip-open"),this._off(n,"mouseleave focusout keyup"),n[0]!==this.element[0]&&this._off(n,"remove"),this._off(this.document,"mousemove"),t&&"mouseleave"===t.type&&e.each(this.parents,function(t,i){e(i.element).attr("title",i.title),delete s.parents[t]}),a.closing=!0,this._trigger("close",t,{tooltip:i}),a.hiding||(a.closing=!1)))},_tooltip:function(t){var i=e("
      ").attr("role","tooltip").addClass("ui-tooltip ui-widget ui-corner-all ui-widget-content "+(this.options.tooltipClass||"")),s=i.uniqueId().attr("id");return e("
      ").addClass("ui-tooltip-content").appendTo(i),i.appendTo(this.document[0].body),this.tooltips[s]={element:t,tooltip:i}},_find:function(e){var t=e.data("ui-tooltip-id");return t?this.tooltips[t]:null},_removeTooltip:function(e){e.remove(),delete this.tooltips[e.attr("id")]},_destroy:function(){var t=this;e.each(this.tooltips,function(i,s){var n=e.Event("blur"),a=s.element;n.target=n.currentTarget=a[0],t.close(n,!0),e("#"+i).remove(),a.data("ui-tooltip-title")&&(a.attr("title")||a.attr("title",a.data("ui-tooltip-title")),a.removeData("ui-tooltip-title"))}),this.liveRegion.remove()}})}); \ No newline at end of file diff --git a/webapp2/src/main/resources/brat/client/lib/jquery.ba-bbq.min.js b/webapp2/src/main/resources/brat/client/lib/jquery.ba-bbq.min.js new file mode 100644 index 000000000..feaed5fef --- /dev/null +++ b/webapp2/src/main/resources/brat/client/lib/jquery.ba-bbq.min.js @@ -0,0 +1 @@ +(function($,window){"$:nomunge";var undefined,aps=Array.prototype.slice,decode=decodeURIComponent,jq_param=$.param,jq_param_sorted,jq_param_fragment,jq_deparam,jq_deparam_fragment,jq_bbq=$.bbq=$.bbq||{},jq_bbq_pushState,jq_bbq_getState,jq_elemUrlAttr,special=$.event.special,str_hashchange="hashchange",str_querystring="querystring",str_fragment="fragment",str_elemUrlAttr="elemUrlAttr",str_href="href",str_src="src",re_params_querystring=/^.*\?|#.*$/g,re_params_fragment,re_fragment,re_no_escape,ajax_crawlable,fragment_prefix,elemUrlAttr_cache={};function is_string(arg){return typeof arg==="string"}function curry(func){var args=aps.call(arguments,1);return function(){return func.apply(this,args.concat(aps.call(arguments)))}}function get_fragment(url){return url.replace(re_fragment,"$2")}function get_querystring(url){return url.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function jq_param_sub(is_fragment,get_func,url,params,merge_mode){var result,qs,matches,url_params,hash;if(params!==undefined){matches=url.match(is_fragment?re_fragment:/^([^#?]*)\??([^#]*)(#?.*)/);hash=matches[3]||"";if(merge_mode===2&&is_string(params)){qs=params.replace(is_fragment?re_params_fragment:re_params_querystring,"")}else{url_params=jq_deparam(matches[2]);params=is_string(params)?jq_deparam[is_fragment?str_fragment:str_querystring](params):params;qs=merge_mode===2?params:merge_mode===1?$.extend({},params,url_params):$.extend({},url_params,params);qs=jq_param_sorted(qs);if(is_fragment){qs=qs.replace(re_no_escape,decode)}}result=matches[1]+(is_fragment?fragment_prefix:qs||!matches[1]?"?":"")+qs+hash}else{result=get_func(url!==undefined?url:location.href)}return result}jq_param[str_querystring]=curry(jq_param_sub,0,get_querystring);jq_param[str_fragment]=jq_param_fragment=curry(jq_param_sub,1,get_fragment);jq_param.sorted=jq_param_sorted=function(a,traditional){var arr=[],obj={};$.each(jq_param(a,traditional).split("&"),function(i,v){var key=v.replace(/(?:%5B|=).*$/,""),key_obj=obj[key];if(!key_obj){key_obj=obj[key]=[];arr.push(key)}key_obj.push(v)});return $.map(arr.sort(),function(v){return obj[v]}).join("&")};jq_param_fragment.noEscape=function(chars){chars=chars||"";var arr=$.map(chars.split(""),encodeURIComponent);re_no_escape=new RegExp(arr.join("|"),"g")};jq_param_fragment.noEscape(",/");jq_param_fragment.ajaxCrawlable=function(state){if(state!==undefined){if(state){re_params_fragment=/^.*(?:#!|#)/;re_fragment=/^([^#]*)(?:#!|#)?(.*)$/;fragment_prefix="#!"}else{re_params_fragment=/^.*#/;re_fragment=/^([^#]*)#?(.*)$/;fragment_prefix="#"}ajax_crawlable=!!state}return ajax_crawlable};jq_param_fragment.ajaxCrawlable(0);$.deparam=jq_deparam=function(params,coerce){var obj={},coerce_types={"true":!0,"false":!1,"null":null};$.each(params.replace(/\+/g," ").split("&"),function(j,v){var param=v.split("="),key=decode(param[0]),val,cur=obj,i=0,keys=key.split("]["),keys_last=keys.length-1;if(/\[/.test(keys[0])&&/\]$/.test(keys[keys_last])){keys[keys_last]=keys[keys_last].replace(/\]$/,"");keys=keys.shift().split("[").concat(keys);keys_last=keys.length-1}else{keys_last=0}if(param.length===2){val=decode(param[1]);if(coerce){val=val&&!isNaN(val)?+val:val==="undefined"?undefined:coerce_types[val]!==undefined?coerce_types[val]:val}if(keys_last){for(;i<=keys_last;i++){key=keys[i]===""?cur.length:keys[i];cur=cur[key]=i7);function get_fragment(url){url=url||location.href;return"#"+url.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[str_hashchange]=function(fn){return fn?this.bind(str_hashchange,fn):this.trigger(str_hashchange)};$.fn[str_hashchange].delay=50;special[str_hashchange]=$.extend(special[str_hashchange],{setup:function(){if(supports_onhashchange){return false}$(fake_onhashchange.start)},teardown:function(){if(supports_onhashchange){return false}$(fake_onhashchange.stop)}});fake_onhashchange=function(){var self={},timeout_id,last_hash=get_fragment(),fn_retval=function(val){return val},history_set=fn_retval,history_get=fn_retval;self.start=function(){timeout_id||poll()};self.stop=function(){timeout_id&&clearTimeout(timeout_id);timeout_id=undefined};function poll(){var hash=get_fragment(),history_hash=history_get(last_hash);if(hash!==last_hash){history_set(last_hash=hash,history_hash);$(window).trigger(str_hashchange)}else if(history_hash!==last_hash){location.href=location.href.replace(/#.*/,"")+history_hash}timeout_id=setTimeout(poll,$.fn[str_hashchange].delay)}return self}()})(jQuery,this); \ No newline at end of file diff --git a/webapp2/src/main/resources/brat/client/lib/jquery.json.min.js b/webapp2/src/main/resources/brat/client/lib/jquery.json.min.js new file mode 100644 index 000000000..bad4a0afa --- /dev/null +++ b/webapp2/src/main/resources/brat/client/lib/jquery.json.min.js @@ -0,0 +1,31 @@ + +(function($){$.toJSON=function(o) +{if(typeof(JSON)=='object'&&JSON.stringify) +return JSON.stringify(o);var type=typeof(o);if(o===null) +return"null";if(type=="undefined") +return undefined;if(type=="number"||type=="boolean") +return o+"";if(type=="string") +return $.quoteString(o);if(type=='object') +{if(typeof o.toJSON=="function") +return $.toJSON(o.toJSON());if(o.constructor===Date) +{var month=o.getUTCMonth()+1;if(month<10)month='0'+month;var day=o.getUTCDate();if(day<10)day='0'+day;var year=o.getUTCFullYear();var hours=o.getUTCHours();if(hours<10)hours='0'+hours;var minutes=o.getUTCMinutes();if(minutes<10)minutes='0'+minutes;var seconds=o.getUTCSeconds();if(seconds<10)seconds='0'+seconds;var milli=o.getUTCMilliseconds();if(milli<100)milli='0'+milli;if(milli<10)milli='0'+milli;return'"'+year+'-'+month+'-'+day+'T'+ +hours+':'+minutes+':'+seconds+'.'+milli+'Z"';} +if(o.constructor===Array) +{var ret=[];for(var i=0;ia?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="
      ",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="
      ","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+Math.random()}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b) +},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthx",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*\s*$/g,ib={option:[1,""],thead:[1,"","
      "],col:[2,"","
      "],tr:[2,"","
      "],td:[3,"","
      "],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(ob(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(ob(c,"script"),kb),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(hb,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function tb(a){var b=l,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||n("