├── Makefile ├── src └── isle │ ├── macros.clj │ ├── svg.cljs │ ├── math.cljs │ └── core.cljs ├── README.md ├── .gitignore ├── scripts ├── build.clj └── figwheel.clj ├── resources └── public │ ├── index.html │ ├── css │ └── isle.css │ └── js │ └── main.js ├── index.html └── project.clj /Makefile: -------------------------------------------------------------------------------- 1 | build: 2 | lein run -m clojure.main scripts/build.clj 3 | -------------------------------------------------------------------------------- /src/isle/macros.clj: -------------------------------------------------------------------------------- 1 | (ns isle.macros) 2 | 3 | (defmacro spy [x] 4 | `(let [x# ~x] 5 | (println '~x " => " x#) 6 | x#)) 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Islands 2 | 3 | A procedural island generator I made with [@jvranish](https://github.com/jvranish) and [@shawn42](https://github.com/shawn42). 4 | 5 | Run with `lein run -m clojure.main scripts/figwheel.clj`. Open a browser to `http://localhost:3454/`. 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | /resources/public/js/* 6 | pom.xml 7 | pom.xml.asc 8 | *.jar 9 | *.class 10 | .lein-deps-sum 11 | .lein-failures 12 | .lein-plugins 13 | .lein-repl-history 14 | 15 | js-dev 16 | 17 | !/resources/public/js/main.js 18 | -------------------------------------------------------------------------------- /scripts/build.clj: -------------------------------------------------------------------------------- 1 | (require 'cljs.build.api) 2 | 3 | (cljs.build.api/build "src" 4 | {:main 'isle.core 5 | :source-paths ["src"] 6 | :asset-path "js" 7 | :optimizations :advanced 8 | :output-to "resources/public/js/main.js" 9 | :output-dir "resources/public/js"}) 10 | -------------------------------------------------------------------------------- /resources/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | Islands 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | Islands 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /src/isle/svg.cljs: -------------------------------------------------------------------------------- 1 | (ns isle.svg 2 | (:require-macros [isle.macros :refer [spy]])) 3 | 4 | (defn translate [x y] 5 | (str "translate(" x "," y ")")) 6 | 7 | (defn rotate [d] 8 | (str "rotate(" d ")")) 9 | 10 | (defn pair [[x y]] 11 | (str x "," y)) 12 | 13 | (defn path [pts] 14 | (as-> pts x 15 | (map pair x) 16 | (interpose "L" x) 17 | (clj->js x) 18 | (.join x "") 19 | (str "M" x))) 20 | 21 | (defn closed-path [pts] 22 | (if (seq pts) 23 | (str (path pts) "Z") 24 | "")) 25 | -------------------------------------------------------------------------------- /resources/public/css/isle.css: -------------------------------------------------------------------------------- 1 | main { 2 | max-width: 600px; 3 | margin: 1rem auto; 4 | } 5 | 6 | button { 7 | margin-bottom: 1rem; 8 | } 9 | 10 | .island { 11 | stroke: green; 12 | stroke-width: 0.5; 13 | fill: limegreen; 14 | fill-rule: evenodd; 15 | vector-effect: non-scaling-stroke; 16 | } 17 | 18 | .water { 19 | fill: dodgerblue; 20 | } 21 | 22 | @media print { 23 | .island { 24 | fill: none; 25 | stroke: black; 26 | } 27 | 28 | .water { 29 | fill: none; 30 | } 31 | 32 | .unprinted { 33 | display: none; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject isle "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :source-paths ["src"] 7 | :dependencies [[org.clojure/clojure "1.7.0"] 8 | [org.clojure/clojurescript "1.7.122" :exclusions [org.apache.ant/ant]] 9 | [org.clojure/core.match "0.3.0-alpha4"] 10 | [org.clojure/core.async "0.2.374"] 11 | [rand-cljc "0.1.0"] 12 | [vdom "0.1.1-SNAPSHOT"]] 13 | :profiles {:dev {:dependencies [[figwheel-sidecar "0.5.0-2" :scope "provided"]]}}) 14 | -------------------------------------------------------------------------------- /scripts/figwheel.clj: -------------------------------------------------------------------------------- 1 | (require '[figwheel-sidecar.repl :as r] 2 | '[figwheel-sidecar.repl-api :as ra]) 3 | 4 | (ra/start-figwheel! 5 | {:figwheel-options {:css-dirs ["resources/public/css"] 6 | :server-port 3454 7 | :nrepl-port 7893 8 | :nrepl-middleware ["cider.nrepl/cider-middleware" 9 | "cemerick.piggieback/wrap-cljs-repl"]} 10 | :build-ids ["dev"] 11 | :all-builds 12 | [{:id "dev" 13 | :figwheel {:on-jsload "isle.core/figwheel-reload"} 14 | :source-paths ["src"] 15 | :compiler {:main 'isle.core 16 | :optimizations :none 17 | :asset-path "js-dev" 18 | :output-to "resources/public/js-dev/main.js" 19 | :output-dir "resources/public/js-dev" 20 | :verbose true}}]}) 21 | 22 | (ra/cljs-repl) 23 | -------------------------------------------------------------------------------- /src/isle/math.cljs: -------------------------------------------------------------------------------- 1 | (ns isle.math 2 | (:require-macros [isle.macros :refer [spy]])) 3 | 4 | (def sin js/Math.sin) 5 | (def cos js/Math.cos) 6 | (def acos js/Math.acos) 7 | (def pi js/Math.PI) 8 | (def tau (* 2 pi)) 9 | (def sqrt js/Math.sqrt) 10 | (def sqr #(js/Math.pow % 2)) 11 | 12 | (defn dist [[x y] [x' y']] 13 | (sqrt (+ (sqr (- x x')) (sqr (- y y'))))) 14 | 15 | (defn avg [xs] 16 | (/ (reduce + xs) (count xs))) 17 | 18 | (def magnitude (partial dist [0 0])) 19 | 20 | (defn unit-vector [[x y]] 21 | (let [len (dist [0 0] [x y])] 22 | [(/ x len) (/ y len)])) 23 | 24 | (defn dot [[ax ay] [bx by]] 25 | (+ (* ax bx) (* ay by))) 26 | 27 | (defn angle [[ax ay] [bx by] [cx cy]] 28 | (let [ba [(- bx ax) (- by ay)] 29 | bc [(- bx cx) (- by cy)]] 30 | (acos (/ (dot ba bc) 31 | (* (magnitude ba) (magnitude bc)))))) 32 | 33 | (defn slope [[ax ay] [bx by]] 34 | (/ (- by ay) (- bx ax))) 35 | 36 | (defn determinant [[ax ay] [bx by]] 37 | (- (* ax by) (* ay bx))) 38 | 39 | (defn diff [[ax ay] [bx by]] 40 | [(- ax bx) (- ay by)]) 41 | 42 | (defn scale [v s] 43 | (mapv #(* 2 %) v)) 44 | 45 | (defn clockwise? [a b c] 46 | (pos? (determinant (diff b a) (diff b c)))) 47 | 48 | (defn colinear? [a b c] 49 | (zero? (determinant (diff b a) (diff b c)))) 50 | 51 | (defn counter-clockwise? [a b c] 52 | (neg? (determinant (diff b a) (diff b c)))) 53 | -------------------------------------------------------------------------------- /src/isle/core.cljs: -------------------------------------------------------------------------------- 1 | (ns isle.core 2 | (:require-macros [isle.macros :refer [spy]]) 3 | (:require [clojure.string :as string] 4 | [rand-cljc.core :as rng] 5 | [vdom.core :refer [renderer]] 6 | [isle.math :as m] 7 | [isle.svg :as s])) 8 | 9 | (enable-console-print!) 10 | 11 | (defn bounds [pts] 12 | (let [extents (juxt #(apply min %) #(apply max %)) 13 | [x1 x2] (extents (map first pts)) 14 | [y1 y2] (extents (map second pts))] 15 | [x1 y1 (- x2 x1) (- y2 y1)])) 16 | 17 | (defn zoom-to [[x y w h] [x' y' w' h']] 18 | (let [s (min (/ w' w) (/ h' h))] 19 | (str (s/translate (+ x' (/ w' 2)) (+ y' (/ h' 2))) 20 | "scale(" (* s 0.95) ")" 21 | (s/translate (- (+ x (/ w 2))) (- (+ y (/ h 2))))))) 22 | 23 | (defn ui [emit {:keys [island] :as model}] 24 | (let [size 600] 25 | [:main {} 26 | [:div {} 27 | [:div {} 28 | [:button 29 | {:className "unprinted" 30 | :onclick #(emit :reset-points)} 31 | "New Island"]] 32 | [:div {} 33 | [:svg {:width size :height size} 34 | [:rect {:class "water" :width size :height size}] 35 | (let [pts (map :position island)] 36 | [:path {:class "island" 37 | :transform (zoom-to (bounds pts) [0 0 size size]) 38 | :d (s/closed-path pts)}])]]]])) 39 | 40 | (defn loopback [xs] 41 | (concat xs [(first xs)])) 42 | 43 | (defn seed-point [rng] 44 | {:offset (rng/rand rng) 45 | :balance (rng/rand rng) 46 | :max-offset (+ 0.05 (rng/rand rng))}) 47 | 48 | (defn circle [rng n radius] 49 | (for [theta (range 0 m/tau (/ m/tau n)) 50 | :let [{:keys [offset balance] :as seed} (seed-point rng)]] 51 | (merge seed 52 | {:id (gensym "radial") 53 | :position (let [r (* radius (+ 1 (- offset balance)))] 54 | [(* r (m/cos theta)) 55 | (* r (m/sin theta))]) 56 | :source {:type :radial 57 | :center [0 0] 58 | :angle theta 59 | :radius radius}}))) 60 | 61 | (defn midpoint [rng a b] 62 | (let [offset (rng/rand rng) 63 | max-offset (m/avg (map :max-offset [a b])) 64 | balance (m/avg (map :balance [a b]))] 65 | {:id (gensym "midpoint") 66 | :offset offset 67 | :balance balance 68 | :max-offset max-offset 69 | :position (let [[x y :as a] (:position a) 70 | [x' y' :as b] (:position b) 71 | len (m/dist a b) 72 | vlen (* max-offset len (- offset balance)) 73 | [mx my] [(m/avg [x x']) (m/avg [y y'])] 74 | [dx dy] (m/unit-vector [(- (- y y')) (- x x')])] 75 | [(+ mx (* vlen dx)) 76 | (+ my (* vlen dy))]) 77 | :source {:type :midpoint 78 | :left (:id a) 79 | :right (:id b)}})) 80 | 81 | (defn subdivide-with [f pred coll max-depth] 82 | (if (pos? max-depth) 83 | (->> coll 84 | (partition 2 1) 85 | (mapcat (fn [[left right]] 86 | (if (pred left right) 87 | (subdivide-with f pred [left (f left right) right] (dec max-depth)) 88 | [left])))) 89 | coll)) 90 | 91 | (defn island [rng max-depth] 92 | (as-> (rng/rand-int rng 17) x 93 | (+ 3 x) 94 | (circle rng x 100) 95 | (loopback x) 96 | (subdivide-with 97 | (partial midpoint rng) 98 | #(<= 2 (m/dist (:position %1) (:position %2))) 99 | x 100 | max-depth))) 101 | 102 | (defn generate-model [] 103 | (let [seed (let [s (string/replace js/location.hash #"#" "")] 104 | (when-not (string/blank? s) 105 | (js/parseInt s))) 106 | rng (rng/rng (or seed (rand-int 100000000)))] 107 | {:rng rng 108 | :island (island rng 15)})) 109 | 110 | (def model (atom (generate-model))) 111 | 112 | (defmulti emit (fn [t & _] t)) 113 | 114 | (defmethod emit :reset-points [_] 115 | (let [seed (rand-int 100000000) 116 | rng (rng/rng seed)] 117 | (set! (.-hash js/location) seed) 118 | (swap! model 119 | (fn [m] 120 | (assoc m 121 | :rng rng 122 | :island (island rng 15)))))) 123 | 124 | (defonce render! 125 | (let [r (renderer (.getElementById js/document "app"))] 126 | #(r (ui emit @model)))) 127 | 128 | (defonce on-update 129 | (add-watch model :rerender 130 | (fn [_ _ _ model] 131 | (render! model)))) 132 | 133 | (defonce hash-change 134 | (.addEventListener js/window "hashchange" 135 | #(reset! model (generate-model)))) 136 | 137 | (render! @model) 138 | -------------------------------------------------------------------------------- /resources/public/js/main.js: -------------------------------------------------------------------------------- 1 | if(typeof Math.imul == "undefined" || (Math.imul(0xffffffff,5) == 0)) { 2 | Math.imul = function (a, b) { 3 | var ah = (a >>> 16) & 0xffff; 4 | var al = a & 0xffff; 5 | var bh = (b >>> 16) & 0xffff; 6 | var bl = b & 0xffff; 7 | // the shift by 0 fixes the sign on the high part 8 | // the final |0 converts the unsigned value into a signed value 9 | return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0); 10 | } 11 | } 12 | 13 | (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 29 | * Available under the MIT License 30 | * ECMAScript compliant, uniform cross-browser split method 31 | */ 32 | 33 | /** 34 | * Splits a string into an array of strings using a regex or string separator. Matches of the 35 | * separator are not included in the result array. However, if `separator` is a regex that contains 36 | * capturing groups, backreferences are spliced into the result each time `separator` is matched. 37 | * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably 38 | * cross-browser. 39 | * @param {String} str String to split. 40 | * @param {RegExp|String} separator Regex or string to use for separating the string. 41 | * @param {Number} [limit] Maximum number of items to include in the result array. 42 | * @returns {Array} Array of substrings. 43 | * @example 44 | * 45 | * // Basic use 46 | * split('a b c d', ' '); 47 | * // -> ['a', 'b', 'c', 'd'] 48 | * 49 | * // With limit 50 | * split('a b c d', ' ', 2); 51 | * // -> ['a', 'b'] 52 | * 53 | * // Backreferences in result array 54 | * split('..word1 word2..', /([a-z]+)(\d+)/i); 55 | * // -> ['..', 'word', '1', ' ', 'word', '2', '..'] 56 | */ 57 | module.exports = (function split(undef) { 58 | 59 | var nativeSplit = String.prototype.split, 60 | compliantExecNpcg = /()??/.exec("")[1] === undef, 61 | // NPCG: nonparticipating capturing group 62 | self; 63 | 64 | self = function(str, separator, limit) { 65 | // If `separator` is not a regex, use `nativeSplit` 66 | if (Object.prototype.toString.call(separator) !== "[object RegExp]") { 67 | return nativeSplit.call(str, separator, limit); 68 | } 69 | var output = [], 70 | flags = (separator.ignoreCase ? "i" : "") + (separator.multiline ? "m" : "") + (separator.extended ? "x" : "") + // Proposed for ES6 71 | (separator.sticky ? "y" : ""), 72 | // Firefox 3+ 73 | lastLastIndex = 0, 74 | // Make `global` and avoid `lastIndex` issues by working with a copy 75 | separator = new RegExp(separator.source, flags + "g"), 76 | separator2, match, lastIndex, lastLength; 77 | str += ""; // Type-convert 78 | if (!compliantExecNpcg) { 79 | // Doesn't need flags gy, but they don't hurt 80 | separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags); 81 | } 82 | /* Values for `limit`, per the spec: 83 | * If undefined: 4294967295 // Math.pow(2, 32) - 1 84 | * If 0, Infinity, or NaN: 0 85 | * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296; 86 | * If negative number: 4294967296 - Math.floor(Math.abs(limit)) 87 | * If other: Type-convert, then use the above rules 88 | */ 89 | limit = limit === undef ? -1 >>> 0 : // Math.pow(2, 32) - 1 90 | limit >>> 0; // ToUint32(limit) 91 | while (match = separator.exec(str)) { 92 | // `separator.lastIndex` is not reliable cross-browser 93 | lastIndex = match.index + match[0].length; 94 | if (lastIndex > lastLastIndex) { 95 | output.push(str.slice(lastLastIndex, match.index)); 96 | // Fix browsers whose `exec` methods don't consistently return `undefined` for 97 | // nonparticipating capturing groups 98 | if (!compliantExecNpcg && match.length > 1) { 99 | match[0].replace(separator2, function() { 100 | for (var i = 1; i < arguments.length - 2; i++) { 101 | if (arguments[i] === undef) { 102 | match[i] = undef; 103 | } 104 | } 105 | }); 106 | } 107 | if (match.length > 1 && match.index < str.length) { 108 | Array.prototype.push.apply(output, match.slice(1)); 109 | } 110 | lastLength = match[0].length; 111 | lastLastIndex = lastIndex; 112 | if (output.length >= limit) { 113 | break; 114 | } 115 | } 116 | if (separator.lastIndex === match.index) { 117 | separator.lastIndex++; // Avoid an infinite loop 118 | } 119 | } 120 | if (lastLastIndex === str.length) { 121 | if (lastLength || !separator.test("")) { 122 | output.push(""); 123 | } 124 | } else { 125 | output.push(str.slice(lastLastIndex)); 126 | } 127 | return output.length > limit ? output.slice(0, limit) : output; 128 | }; 129 | 130 | return self; 131 | })(); 132 | 133 | },{}],5:[function(require,module,exports){ 134 | 'use strict'; 135 | 136 | var OneVersionConstraint = require('individual/one-version'); 137 | 138 | var MY_VERSION = '7'; 139 | OneVersionConstraint('ev-store', MY_VERSION); 140 | 141 | var hashKey = '__EV_STORE_KEY@' + MY_VERSION; 142 | 143 | module.exports = EvStore; 144 | 145 | function EvStore(elem) { 146 | var hash = elem[hashKey]; 147 | 148 | if (!hash) { 149 | hash = elem[hashKey] = {}; 150 | } 151 | 152 | return hash; 153 | } 154 | 155 | },{"individual/one-version":7}],6:[function(require,module,exports){ 156 | (function (global){ 157 | 'use strict'; 158 | 159 | /*global window, global*/ 160 | 161 | var root = typeof window !== 'undefined' ? 162 | window : typeof global !== 'undefined' ? 163 | global : {}; 164 | 165 | module.exports = Individual; 166 | 167 | function Individual(key, value) { 168 | if (key in root) { 169 | return root[key]; 170 | } 171 | 172 | root[key] = value; 173 | 174 | return value; 175 | } 176 | 177 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 178 | },{}],7:[function(require,module,exports){ 179 | 'use strict'; 180 | 181 | var Individual = require('./index.js'); 182 | 183 | module.exports = OneVersion; 184 | 185 | function OneVersion(moduleName, version, defaultValue) { 186 | var key = '__INDIVIDUAL_ONE_VERSION_' + moduleName; 187 | var enforceKey = key + '_ENFORCE_SINGLETON'; 188 | 189 | var versionValue = Individual(enforceKey, version); 190 | 191 | if (versionValue !== version) { 192 | throw new Error('Can only have one copy of ' + 193 | moduleName + '.\n' + 194 | 'You already have version ' + versionValue + 195 | ' installed.\n' + 196 | 'This means you cannot install version ' + version); 197 | } 198 | 199 | return Individual(key, defaultValue); 200 | } 201 | 202 | },{"./index.js":6}],8:[function(require,module,exports){ 203 | (function (global){ 204 | var topLevel = typeof global !== 'undefined' ? global : 205 | typeof window !== 'undefined' ? window : {} 206 | var minDoc = require('min-document'); 207 | 208 | if (typeof document !== 'undefined') { 209 | module.exports = document; 210 | } else { 211 | var doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4']; 212 | 213 | if (!doccy) { 214 | doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc; 215 | } 216 | 217 | module.exports = doccy; 218 | } 219 | 220 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 221 | },{"min-document":1}],9:[function(require,module,exports){ 222 | "use strict"; 223 | 224 | module.exports = function isObject(x) { 225 | return typeof x === "object" && x !== null; 226 | }; 227 | 228 | },{}],10:[function(require,module,exports){ 229 | var nativeIsArray = Array.isArray 230 | var toString = Object.prototype.toString 231 | 232 | module.exports = nativeIsArray || isArray 233 | 234 | function isArray(obj) { 235 | return toString.call(obj) === "[object Array]" 236 | } 237 | 238 | },{}],11:[function(require,module,exports){ 239 | var patch = require("./vdom/patch.js") 240 | 241 | module.exports = patch 242 | 243 | },{"./vdom/patch.js":16}],12:[function(require,module,exports){ 244 | var isObject = require("is-object") 245 | var isHook = require("../vnode/is-vhook.js") 246 | 247 | module.exports = applyProperties 248 | 249 | function applyProperties(node, props, previous) { 250 | for (var propName in props) { 251 | var propValue = props[propName] 252 | 253 | if (propValue === undefined) { 254 | removeProperty(node, propName, propValue, previous); 255 | } else if (isHook(propValue)) { 256 | removeProperty(node, propName, propValue, previous) 257 | if (propValue.hook) { 258 | propValue.hook(node, 259 | propName, 260 | previous ? previous[propName] : undefined) 261 | } 262 | } else { 263 | if (isObject(propValue)) { 264 | patchObject(node, props, previous, propName, propValue); 265 | } else { 266 | node[propName] = propValue 267 | } 268 | } 269 | } 270 | } 271 | 272 | function removeProperty(node, propName, propValue, previous) { 273 | if (previous) { 274 | var previousValue = previous[propName] 275 | 276 | if (!isHook(previousValue)) { 277 | if (propName === "attributes") { 278 | for (var attrName in previousValue) { 279 | node.removeAttribute(attrName) 280 | } 281 | } else if (propName === "style") { 282 | for (var i in previousValue) { 283 | node.style[i] = "" 284 | } 285 | } else if (typeof previousValue === "string") { 286 | node[propName] = "" 287 | } else { 288 | node[propName] = null 289 | } 290 | } else if (previousValue.unhook) { 291 | previousValue.unhook(node, propName, propValue) 292 | } 293 | } 294 | } 295 | 296 | function patchObject(node, props, previous, propName, propValue) { 297 | var previousValue = previous ? previous[propName] : undefined 298 | 299 | // Set attributes 300 | if (propName === "attributes") { 301 | for (var attrName in propValue) { 302 | var attrValue = propValue[attrName] 303 | 304 | if (attrValue === undefined) { 305 | node.removeAttribute(attrName) 306 | } else { 307 | node.setAttribute(attrName, attrValue) 308 | } 309 | } 310 | 311 | return 312 | } 313 | 314 | if(previousValue && isObject(previousValue) && 315 | getPrototype(previousValue) !== getPrototype(propValue)) { 316 | node[propName] = propValue 317 | return 318 | } 319 | 320 | if (!isObject(node[propName])) { 321 | node[propName] = {} 322 | } 323 | 324 | var replacer = propName === "style" ? "" : undefined 325 | 326 | for (var k in propValue) { 327 | var value = propValue[k] 328 | node[propName][k] = (value === undefined) ? replacer : value 329 | } 330 | } 331 | 332 | function getPrototype(value) { 333 | if (Object.getPrototypeOf) { 334 | return Object.getPrototypeOf(value) 335 | } else if (value.__proto__) { 336 | return value.__proto__ 337 | } else if (value.constructor) { 338 | return value.constructor.prototype 339 | } 340 | } 341 | 342 | },{"../vnode/is-vhook.js":27,"is-object":9}],13:[function(require,module,exports){ 343 | var document = require("global/document") 344 | 345 | var applyProperties = require("./apply-properties") 346 | 347 | var isVNode = require("../vnode/is-vnode.js") 348 | var isVText = require("../vnode/is-vtext.js") 349 | var isWidget = require("../vnode/is-widget.js") 350 | var handleThunk = require("../vnode/handle-thunk.js") 351 | 352 | module.exports = createElement 353 | 354 | function createElement(vnode, opts) { 355 | var doc = opts ? opts.document || document : document 356 | var warn = opts ? opts.warn : null 357 | 358 | vnode = handleThunk(vnode).a 359 | 360 | if (isWidget(vnode)) { 361 | return vnode.init() 362 | } else if (isVText(vnode)) { 363 | return doc.createTextNode(vnode.text) 364 | } else if (!isVNode(vnode)) { 365 | if (warn) { 366 | warn("Item is not a valid virtual dom node", vnode) 367 | } 368 | return null 369 | } 370 | 371 | var node = (vnode.namespace === null) ? 372 | doc.createElement(vnode.tagName) : 373 | doc.createElementNS(vnode.namespace, vnode.tagName) 374 | 375 | var props = vnode.properties 376 | applyProperties(node, props) 377 | 378 | var children = vnode.children 379 | 380 | for (var i = 0; i < children.length; i++) { 381 | var childNode = createElement(children[i], opts) 382 | if (childNode) { 383 | node.appendChild(childNode) 384 | } 385 | } 386 | 387 | return node 388 | } 389 | 390 | },{"../vnode/handle-thunk.js":25,"../vnode/is-vnode.js":28,"../vnode/is-vtext.js":29,"../vnode/is-widget.js":30,"./apply-properties":12,"global/document":8}],14:[function(require,module,exports){ 391 | // Maps a virtual DOM tree onto a real DOM tree in an efficient manner. 392 | // We don't want to read all of the DOM nodes in the tree so we use 393 | // the in-order tree indexing to eliminate recursion down certain branches. 394 | // We only recurse into a DOM node if we know that it contains a child of 395 | // interest. 396 | 397 | var noChild = {} 398 | 399 | module.exports = domIndex 400 | 401 | function domIndex(rootNode, tree, indices, nodes) { 402 | if (!indices || indices.length === 0) { 403 | return {} 404 | } else { 405 | indices.sort(ascending) 406 | return recurse(rootNode, tree, indices, nodes, 0) 407 | } 408 | } 409 | 410 | function recurse(rootNode, tree, indices, nodes, rootIndex) { 411 | nodes = nodes || {} 412 | 413 | 414 | if (rootNode) { 415 | if (indexInRange(indices, rootIndex, rootIndex)) { 416 | nodes[rootIndex] = rootNode 417 | } 418 | 419 | var vChildren = tree.children 420 | 421 | if (vChildren) { 422 | 423 | var childNodes = rootNode.childNodes 424 | 425 | for (var i = 0; i < tree.children.length; i++) { 426 | rootIndex += 1 427 | 428 | var vChild = vChildren[i] || noChild 429 | var nextIndex = rootIndex + (vChild.count || 0) 430 | 431 | // skip recursion down the tree if there are no nodes down here 432 | if (indexInRange(indices, rootIndex, nextIndex)) { 433 | recurse(childNodes[i], vChild, indices, nodes, rootIndex) 434 | } 435 | 436 | rootIndex = nextIndex 437 | } 438 | } 439 | } 440 | 441 | return nodes 442 | } 443 | 444 | // Binary search for an index in the interval [left, right] 445 | function indexInRange(indices, left, right) { 446 | if (indices.length === 0) { 447 | return false 448 | } 449 | 450 | var minIndex = 0 451 | var maxIndex = indices.length - 1 452 | var currentIndex 453 | var currentItem 454 | 455 | while (minIndex <= maxIndex) { 456 | currentIndex = ((maxIndex + minIndex) / 2) >> 0 457 | currentItem = indices[currentIndex] 458 | 459 | if (minIndex === maxIndex) { 460 | return currentItem >= left && currentItem <= right 461 | } else if (currentItem < left) { 462 | minIndex = currentIndex + 1 463 | } else if (currentItem > right) { 464 | maxIndex = currentIndex - 1 465 | } else { 466 | return true 467 | } 468 | } 469 | 470 | return false; 471 | } 472 | 473 | function ascending(a, b) { 474 | return a > b ? 1 : -1 475 | } 476 | 477 | },{}],15:[function(require,module,exports){ 478 | var applyProperties = require("./apply-properties") 479 | 480 | var isWidget = require("../vnode/is-widget.js") 481 | var VPatch = require("../vnode/vpatch.js") 482 | 483 | var render = require("./create-element") 484 | var updateWidget = require("./update-widget") 485 | 486 | module.exports = applyPatch 487 | 488 | function applyPatch(vpatch, domNode, renderOptions) { 489 | var type = vpatch.type 490 | var vNode = vpatch.vNode 491 | var patch = vpatch.patch 492 | 493 | switch (type) { 494 | case VPatch.REMOVE: 495 | return removeNode(domNode, vNode) 496 | case VPatch.INSERT: 497 | return insertNode(domNode, patch, renderOptions) 498 | case VPatch.VTEXT: 499 | return stringPatch(domNode, vNode, patch, renderOptions) 500 | case VPatch.WIDGET: 501 | return widgetPatch(domNode, vNode, patch, renderOptions) 502 | case VPatch.VNODE: 503 | return vNodePatch(domNode, vNode, patch, renderOptions) 504 | case VPatch.ORDER: 505 | reorderChildren(domNode, patch) 506 | return domNode 507 | case VPatch.PROPS: 508 | applyProperties(domNode, patch, vNode.properties) 509 | return domNode 510 | case VPatch.THUNK: 511 | return replaceRoot(domNode, 512 | renderOptions.patch(domNode, patch, renderOptions)) 513 | default: 514 | return domNode 515 | } 516 | } 517 | 518 | function removeNode(domNode, vNode) { 519 | var parentNode = domNode.parentNode 520 | 521 | if (parentNode) { 522 | parentNode.removeChild(domNode) 523 | } 524 | 525 | destroyWidget(domNode, vNode); 526 | 527 | return null 528 | } 529 | 530 | function insertNode(parentNode, vNode, renderOptions) { 531 | var newNode = render(vNode, renderOptions) 532 | 533 | if (parentNode) { 534 | parentNode.appendChild(newNode) 535 | } 536 | 537 | return parentNode 538 | } 539 | 540 | function stringPatch(domNode, leftVNode, vText, renderOptions) { 541 | var newNode 542 | 543 | if (domNode.nodeType === 3) { 544 | domNode.replaceData(0, domNode.length, vText.text) 545 | newNode = domNode 546 | } else { 547 | var parentNode = domNode.parentNode 548 | newNode = render(vText, renderOptions) 549 | 550 | if (parentNode && newNode !== domNode) { 551 | parentNode.replaceChild(newNode, domNode) 552 | } 553 | } 554 | 555 | return newNode 556 | } 557 | 558 | function widgetPatch(domNode, leftVNode, widget, renderOptions) { 559 | var updating = updateWidget(leftVNode, widget) 560 | var newNode 561 | 562 | if (updating) { 563 | newNode = widget.update(leftVNode, domNode) || domNode 564 | } else { 565 | newNode = render(widget, renderOptions) 566 | } 567 | 568 | var parentNode = domNode.parentNode 569 | 570 | if (parentNode && newNode !== domNode) { 571 | parentNode.replaceChild(newNode, domNode) 572 | } 573 | 574 | if (!updating) { 575 | destroyWidget(domNode, leftVNode) 576 | } 577 | 578 | return newNode 579 | } 580 | 581 | function vNodePatch(domNode, leftVNode, vNode, renderOptions) { 582 | var parentNode = domNode.parentNode 583 | var newNode = render(vNode, renderOptions) 584 | 585 | if (parentNode && newNode !== domNode) { 586 | parentNode.replaceChild(newNode, domNode) 587 | } 588 | 589 | return newNode 590 | } 591 | 592 | function destroyWidget(domNode, w) { 593 | if (typeof w.destroy === "function" && isWidget(w)) { 594 | w.destroy(domNode) 595 | } 596 | } 597 | 598 | function reorderChildren(domNode, moves) { 599 | var childNodes = domNode.childNodes 600 | var keyMap = {} 601 | var node 602 | var remove 603 | var insert 604 | 605 | for (var i = 0; i < moves.removes.length; i++) { 606 | remove = moves.removes[i] 607 | node = childNodes[remove.from] 608 | if (remove.key) { 609 | keyMap[remove.key] = node 610 | } 611 | domNode.removeChild(node) 612 | } 613 | 614 | var length = childNodes.length 615 | for (var j = 0; j < moves.inserts.length; j++) { 616 | insert = moves.inserts[j] 617 | node = keyMap[insert.key] 618 | // this is the weirdest bug i've ever seen in webkit 619 | domNode.insertBefore(node, insert.to >= length++ ? null : childNodes[insert.to]) 620 | } 621 | } 622 | 623 | function replaceRoot(oldRoot, newRoot) { 624 | if (oldRoot && newRoot && oldRoot !== newRoot && oldRoot.parentNode) { 625 | oldRoot.parentNode.replaceChild(newRoot, oldRoot) 626 | } 627 | 628 | return newRoot; 629 | } 630 | 631 | },{"../vnode/is-widget.js":30,"../vnode/vpatch.js":33,"./apply-properties":12,"./create-element":13,"./update-widget":17}],16:[function(require,module,exports){ 632 | var document = require("global/document") 633 | var isArray = require("x-is-array") 634 | 635 | var domIndex = require("./dom-index") 636 | var patchOp = require("./patch-op") 637 | module.exports = patch 638 | 639 | function patch(rootNode, patches) { 640 | return patchRecursive(rootNode, patches) 641 | } 642 | 643 | function patchRecursive(rootNode, patches, renderOptions) { 644 | var indices = patchIndices(patches) 645 | 646 | if (indices.length === 0) { 647 | return rootNode 648 | } 649 | 650 | var index = domIndex(rootNode, patches.a, indices) 651 | var ownerDocument = rootNode.ownerDocument 652 | 653 | if (!renderOptions) { 654 | renderOptions = { patch: patchRecursive } 655 | if (ownerDocument !== document) { 656 | renderOptions.document = ownerDocument 657 | } 658 | } 659 | 660 | for (var i = 0; i < indices.length; i++) { 661 | var nodeIndex = indices[i] 662 | rootNode = applyPatch(rootNode, 663 | index[nodeIndex], 664 | patches[nodeIndex], 665 | renderOptions) 666 | } 667 | 668 | return rootNode 669 | } 670 | 671 | function applyPatch(rootNode, domNode, patchList, renderOptions) { 672 | if (!domNode) { 673 | return rootNode 674 | } 675 | 676 | var newNode 677 | 678 | if (isArray(patchList)) { 679 | for (var i = 0; i < patchList.length; i++) { 680 | newNode = patchOp(patchList[i], domNode, renderOptions) 681 | 682 | if (domNode === rootNode) { 683 | rootNode = newNode 684 | } 685 | } 686 | } else { 687 | newNode = patchOp(patchList, domNode, renderOptions) 688 | 689 | if (domNode === rootNode) { 690 | rootNode = newNode 691 | } 692 | } 693 | 694 | return rootNode 695 | } 696 | 697 | function patchIndices(patches) { 698 | var indices = [] 699 | 700 | for (var key in patches) { 701 | if (key !== "a") { 702 | indices.push(Number(key)) 703 | } 704 | } 705 | 706 | return indices 707 | } 708 | 709 | },{"./dom-index":14,"./patch-op":15,"global/document":8,"x-is-array":10}],17:[function(require,module,exports){ 710 | var isWidget = require("../vnode/is-widget.js") 711 | 712 | module.exports = updateWidget 713 | 714 | function updateWidget(a, b) { 715 | if (isWidget(a) && isWidget(b)) { 716 | if ("name" in a && "name" in b) { 717 | return a.id === b.id 718 | } else { 719 | return a.init === b.init 720 | } 721 | } 722 | 723 | return false 724 | } 725 | 726 | },{"../vnode/is-widget.js":30}],18:[function(require,module,exports){ 727 | 'use strict'; 728 | 729 | module.exports = AttributeHook; 730 | 731 | function AttributeHook(namespace, value) { 732 | if (!(this instanceof AttributeHook)) { 733 | return new AttributeHook(namespace, value); 734 | } 735 | 736 | this.namespace = namespace; 737 | this.value = value; 738 | } 739 | 740 | AttributeHook.prototype.hook = function (node, prop, prev) { 741 | if (prev && prev.type === 'AttributeHook' && 742 | prev.value === this.value && 743 | prev.namespace === this.namespace) { 744 | return; 745 | } 746 | 747 | node.setAttributeNS(this.namespace, prop, this.value); 748 | }; 749 | 750 | AttributeHook.prototype.unhook = function (node, prop, next) { 751 | if (next && next.type === 'AttributeHook' && 752 | next.namespace === this.namespace) { 753 | return; 754 | } 755 | 756 | var colonPosition = prop.indexOf(':'); 757 | var localName = colonPosition > -1 ? prop.substr(colonPosition + 1) : prop; 758 | node.removeAttributeNS(this.namespace, localName); 759 | }; 760 | 761 | AttributeHook.prototype.type = 'AttributeHook'; 762 | 763 | },{}],19:[function(require,module,exports){ 764 | 'use strict'; 765 | 766 | var EvStore = require('ev-store'); 767 | 768 | module.exports = EvHook; 769 | 770 | function EvHook(value) { 771 | if (!(this instanceof EvHook)) { 772 | return new EvHook(value); 773 | } 774 | 775 | this.value = value; 776 | } 777 | 778 | EvHook.prototype.hook = function (node, propertyName) { 779 | var es = EvStore(node); 780 | var propName = propertyName.substr(3); 781 | 782 | es[propName] = this.value; 783 | }; 784 | 785 | EvHook.prototype.unhook = function(node, propertyName) { 786 | var es = EvStore(node); 787 | var propName = propertyName.substr(3); 788 | 789 | es[propName] = undefined; 790 | }; 791 | 792 | },{"ev-store":5}],20:[function(require,module,exports){ 793 | 'use strict'; 794 | 795 | module.exports = SoftSetHook; 796 | 797 | function SoftSetHook(value) { 798 | if (!(this instanceof SoftSetHook)) { 799 | return new SoftSetHook(value); 800 | } 801 | 802 | this.value = value; 803 | } 804 | 805 | SoftSetHook.prototype.hook = function (node, propertyName) { 806 | if (node[propertyName] !== this.value) { 807 | node[propertyName] = this.value; 808 | } 809 | }; 810 | 811 | },{}],21:[function(require,module,exports){ 812 | 'use strict'; 813 | 814 | var isArray = require('x-is-array'); 815 | 816 | var VNode = require('../vnode/vnode.js'); 817 | var VText = require('../vnode/vtext.js'); 818 | var isVNode = require('../vnode/is-vnode'); 819 | var isVText = require('../vnode/is-vtext'); 820 | var isWidget = require('../vnode/is-widget'); 821 | var isHook = require('../vnode/is-vhook'); 822 | var isVThunk = require('../vnode/is-thunk'); 823 | 824 | var parseTag = require('./parse-tag.js'); 825 | var softSetHook = require('./hooks/soft-set-hook.js'); 826 | var evHook = require('./hooks/ev-hook.js'); 827 | 828 | module.exports = h; 829 | 830 | function h(tagName, properties, children) { 831 | var childNodes = []; 832 | var tag, props, key, namespace; 833 | 834 | if (!children && isChildren(properties)) { 835 | children = properties; 836 | props = {}; 837 | } 838 | 839 | props = props || properties || {}; 840 | tag = parseTag(tagName, props); 841 | 842 | // support keys 843 | if (props.hasOwnProperty('key')) { 844 | key = props.key; 845 | props.key = undefined; 846 | } 847 | 848 | // support namespace 849 | if (props.hasOwnProperty('namespace')) { 850 | namespace = props.namespace; 851 | props.namespace = undefined; 852 | } 853 | 854 | // fix cursor bug 855 | if (tag === 'INPUT' && 856 | !namespace && 857 | props.hasOwnProperty('value') && 858 | props.value !== undefined && 859 | !isHook(props.value) 860 | ) { 861 | props.value = softSetHook(props.value); 862 | } 863 | 864 | transformProperties(props); 865 | 866 | if (children !== undefined && children !== null) { 867 | addChild(children, childNodes, tag, props); 868 | } 869 | 870 | 871 | return new VNode(tag, props, childNodes, key, namespace); 872 | } 873 | 874 | function addChild(c, childNodes, tag, props) { 875 | if (typeof c === 'string') { 876 | childNodes.push(new VText(c)); 877 | } else if (isChild(c)) { 878 | childNodes.push(c); 879 | } else if (isArray(c)) { 880 | for (var i = 0; i < c.length; i++) { 881 | addChild(c[i], childNodes, tag, props); 882 | } 883 | } else if (c === null || c === undefined) { 884 | return; 885 | } else { 886 | throw UnexpectedVirtualElement({ 887 | foreignObject: c, 888 | parentVnode: { 889 | tagName: tag, 890 | properties: props 891 | } 892 | }); 893 | } 894 | } 895 | 896 | function transformProperties(props) { 897 | for (var propName in props) { 898 | if (props.hasOwnProperty(propName)) { 899 | var value = props[propName]; 900 | 901 | if (isHook(value)) { 902 | continue; 903 | } 904 | 905 | if (propName.substr(0, 3) === 'ev-') { 906 | // add ev-foo support 907 | props[propName] = evHook(value); 908 | } 909 | } 910 | } 911 | } 912 | 913 | function isChild(x) { 914 | return isVNode(x) || isVText(x) || isWidget(x) || isVThunk(x); 915 | } 916 | 917 | function isChildren(x) { 918 | return typeof x === 'string' || isArray(x) || isChild(x); 919 | } 920 | 921 | function UnexpectedVirtualElement(data) { 922 | var err = new Error(); 923 | 924 | err.type = 'virtual-hyperscript.unexpected.virtual-element'; 925 | err.message = 'Unexpected virtual child passed to h().\n' + 926 | 'Expected a VNode / Vthunk / VWidget / string but:\n' + 927 | 'got:\n' + 928 | errorString(data.foreignObject) + 929 | '.\n' + 930 | 'The parent vnode is:\n' + 931 | errorString(data.parentVnode) 932 | '\n' + 933 | 'Suggested fix: change your `h(..., [ ... ])` callsite.'; 934 | err.foreignObject = data.foreignObject; 935 | err.parentVnode = data.parentVnode; 936 | 937 | return err; 938 | } 939 | 940 | function errorString(obj) { 941 | try { 942 | return JSON.stringify(obj, null, ' '); 943 | } catch (e) { 944 | return String(obj); 945 | } 946 | } 947 | 948 | },{"../vnode/is-thunk":26,"../vnode/is-vhook":27,"../vnode/is-vnode":28,"../vnode/is-vtext":29,"../vnode/is-widget":30,"../vnode/vnode.js":32,"../vnode/vtext.js":34,"./hooks/ev-hook.js":19,"./hooks/soft-set-hook.js":20,"./parse-tag.js":22,"x-is-array":10}],22:[function(require,module,exports){ 949 | 'use strict'; 950 | 951 | var split = require('browser-split'); 952 | 953 | var classIdSplit = /([\.#]?[a-zA-Z0-9_:-]+)/; 954 | var notClassId = /^\.|#/; 955 | 956 | module.exports = parseTag; 957 | 958 | function parseTag(tag, props) { 959 | if (!tag) { 960 | return 'DIV'; 961 | } 962 | 963 | var noId = !(props.hasOwnProperty('id')); 964 | 965 | var tagParts = split(tag, classIdSplit); 966 | var tagName = null; 967 | 968 | if (notClassId.test(tagParts[1])) { 969 | tagName = 'DIV'; 970 | } 971 | 972 | var classes, part, type, i; 973 | 974 | for (i = 0; i < tagParts.length; i++) { 975 | part = tagParts[i]; 976 | 977 | if (!part) { 978 | continue; 979 | } 980 | 981 | type = part.charAt(0); 982 | 983 | if (!tagName) { 984 | tagName = part; 985 | } else if (type === '.') { 986 | classes = classes || []; 987 | classes.push(part.substring(1, part.length)); 988 | } else if (type === '#' && noId) { 989 | props.id = part.substring(1, part.length); 990 | } 991 | } 992 | 993 | if (classes) { 994 | if (props.className) { 995 | classes.push(props.className); 996 | } 997 | 998 | props.className = classes.join(' '); 999 | } 1000 | 1001 | return props.namespace ? tagName : tagName.toUpperCase(); 1002 | } 1003 | 1004 | },{"browser-split":4}],23:[function(require,module,exports){ 1005 | 'use strict'; 1006 | 1007 | var DEFAULT_NAMESPACE = null; 1008 | var EV_NAMESPACE = 'http://www.w3.org/2001/xml-events'; 1009 | var XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink'; 1010 | var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'; 1011 | 1012 | // http://www.w3.org/TR/SVGTiny12/attributeTable.html 1013 | // http://www.w3.org/TR/SVG/attindex.html 1014 | var SVG_PROPERTIES = { 1015 | 'about': DEFAULT_NAMESPACE, 1016 | 'accent-height': DEFAULT_NAMESPACE, 1017 | 'accumulate': DEFAULT_NAMESPACE, 1018 | 'additive': DEFAULT_NAMESPACE, 1019 | 'alignment-baseline': DEFAULT_NAMESPACE, 1020 | 'alphabetic': DEFAULT_NAMESPACE, 1021 | 'amplitude': DEFAULT_NAMESPACE, 1022 | 'arabic-form': DEFAULT_NAMESPACE, 1023 | 'ascent': DEFAULT_NAMESPACE, 1024 | 'attributeName': DEFAULT_NAMESPACE, 1025 | 'attributeType': DEFAULT_NAMESPACE, 1026 | 'azimuth': DEFAULT_NAMESPACE, 1027 | 'bandwidth': DEFAULT_NAMESPACE, 1028 | 'baseFrequency': DEFAULT_NAMESPACE, 1029 | 'baseProfile': DEFAULT_NAMESPACE, 1030 | 'baseline-shift': DEFAULT_NAMESPACE, 1031 | 'bbox': DEFAULT_NAMESPACE, 1032 | 'begin': DEFAULT_NAMESPACE, 1033 | 'bias': DEFAULT_NAMESPACE, 1034 | 'by': DEFAULT_NAMESPACE, 1035 | 'calcMode': DEFAULT_NAMESPACE, 1036 | 'cap-height': DEFAULT_NAMESPACE, 1037 | 'class': DEFAULT_NAMESPACE, 1038 | 'clip': DEFAULT_NAMESPACE, 1039 | 'clip-path': DEFAULT_NAMESPACE, 1040 | 'clip-rule': DEFAULT_NAMESPACE, 1041 | 'clipPathUnits': DEFAULT_NAMESPACE, 1042 | 'color': DEFAULT_NAMESPACE, 1043 | 'color-interpolation': DEFAULT_NAMESPACE, 1044 | 'color-interpolation-filters': DEFAULT_NAMESPACE, 1045 | 'color-profile': DEFAULT_NAMESPACE, 1046 | 'color-rendering': DEFAULT_NAMESPACE, 1047 | 'content': DEFAULT_NAMESPACE, 1048 | 'contentScriptType': DEFAULT_NAMESPACE, 1049 | 'contentStyleType': DEFAULT_NAMESPACE, 1050 | 'cursor': DEFAULT_NAMESPACE, 1051 | 'cx': DEFAULT_NAMESPACE, 1052 | 'cy': DEFAULT_NAMESPACE, 1053 | 'd': DEFAULT_NAMESPACE, 1054 | 'datatype': DEFAULT_NAMESPACE, 1055 | 'defaultAction': DEFAULT_NAMESPACE, 1056 | 'descent': DEFAULT_NAMESPACE, 1057 | 'diffuseConstant': DEFAULT_NAMESPACE, 1058 | 'direction': DEFAULT_NAMESPACE, 1059 | 'display': DEFAULT_NAMESPACE, 1060 | 'divisor': DEFAULT_NAMESPACE, 1061 | 'dominant-baseline': DEFAULT_NAMESPACE, 1062 | 'dur': DEFAULT_NAMESPACE, 1063 | 'dx': DEFAULT_NAMESPACE, 1064 | 'dy': DEFAULT_NAMESPACE, 1065 | 'edgeMode': DEFAULT_NAMESPACE, 1066 | 'editable': DEFAULT_NAMESPACE, 1067 | 'elevation': DEFAULT_NAMESPACE, 1068 | 'enable-background': DEFAULT_NAMESPACE, 1069 | 'end': DEFAULT_NAMESPACE, 1070 | 'ev:event': EV_NAMESPACE, 1071 | 'event': DEFAULT_NAMESPACE, 1072 | 'exponent': DEFAULT_NAMESPACE, 1073 | 'externalResourcesRequired': DEFAULT_NAMESPACE, 1074 | 'fill': DEFAULT_NAMESPACE, 1075 | 'fill-opacity': DEFAULT_NAMESPACE, 1076 | 'fill-rule': DEFAULT_NAMESPACE, 1077 | 'filter': DEFAULT_NAMESPACE, 1078 | 'filterRes': DEFAULT_NAMESPACE, 1079 | 'filterUnits': DEFAULT_NAMESPACE, 1080 | 'flood-color': DEFAULT_NAMESPACE, 1081 | 'flood-opacity': DEFAULT_NAMESPACE, 1082 | 'focusHighlight': DEFAULT_NAMESPACE, 1083 | 'focusable': DEFAULT_NAMESPACE, 1084 | 'font-family': DEFAULT_NAMESPACE, 1085 | 'font-size': DEFAULT_NAMESPACE, 1086 | 'font-size-adjust': DEFAULT_NAMESPACE, 1087 | 'font-stretch': DEFAULT_NAMESPACE, 1088 | 'font-style': DEFAULT_NAMESPACE, 1089 | 'font-variant': DEFAULT_NAMESPACE, 1090 | 'font-weight': DEFAULT_NAMESPACE, 1091 | 'format': DEFAULT_NAMESPACE, 1092 | 'from': DEFAULT_NAMESPACE, 1093 | 'fx': DEFAULT_NAMESPACE, 1094 | 'fy': DEFAULT_NAMESPACE, 1095 | 'g1': DEFAULT_NAMESPACE, 1096 | 'g2': DEFAULT_NAMESPACE, 1097 | 'glyph-name': DEFAULT_NAMESPACE, 1098 | 'glyph-orientation-horizontal': DEFAULT_NAMESPACE, 1099 | 'glyph-orientation-vertical': DEFAULT_NAMESPACE, 1100 | 'glyphRef': DEFAULT_NAMESPACE, 1101 | 'gradientTransform': DEFAULT_NAMESPACE, 1102 | 'gradientUnits': DEFAULT_NAMESPACE, 1103 | 'handler': DEFAULT_NAMESPACE, 1104 | 'hanging': DEFAULT_NAMESPACE, 1105 | 'height': DEFAULT_NAMESPACE, 1106 | 'horiz-adv-x': DEFAULT_NAMESPACE, 1107 | 'horiz-origin-x': DEFAULT_NAMESPACE, 1108 | 'horiz-origin-y': DEFAULT_NAMESPACE, 1109 | 'id': DEFAULT_NAMESPACE, 1110 | 'ideographic': DEFAULT_NAMESPACE, 1111 | 'image-rendering': DEFAULT_NAMESPACE, 1112 | 'in': DEFAULT_NAMESPACE, 1113 | 'in2': DEFAULT_NAMESPACE, 1114 | 'initialVisibility': DEFAULT_NAMESPACE, 1115 | 'intercept': DEFAULT_NAMESPACE, 1116 | 'k': DEFAULT_NAMESPACE, 1117 | 'k1': DEFAULT_NAMESPACE, 1118 | 'k2': DEFAULT_NAMESPACE, 1119 | 'k3': DEFAULT_NAMESPACE, 1120 | 'k4': DEFAULT_NAMESPACE, 1121 | 'kernelMatrix': DEFAULT_NAMESPACE, 1122 | 'kernelUnitLength': DEFAULT_NAMESPACE, 1123 | 'kerning': DEFAULT_NAMESPACE, 1124 | 'keyPoints': DEFAULT_NAMESPACE, 1125 | 'keySplines': DEFAULT_NAMESPACE, 1126 | 'keyTimes': DEFAULT_NAMESPACE, 1127 | 'lang': DEFAULT_NAMESPACE, 1128 | 'lengthAdjust': DEFAULT_NAMESPACE, 1129 | 'letter-spacing': DEFAULT_NAMESPACE, 1130 | 'lighting-color': DEFAULT_NAMESPACE, 1131 | 'limitingConeAngle': DEFAULT_NAMESPACE, 1132 | 'local': DEFAULT_NAMESPACE, 1133 | 'marker-end': DEFAULT_NAMESPACE, 1134 | 'marker-mid': DEFAULT_NAMESPACE, 1135 | 'marker-start': DEFAULT_NAMESPACE, 1136 | 'markerHeight': DEFAULT_NAMESPACE, 1137 | 'markerUnits': DEFAULT_NAMESPACE, 1138 | 'markerWidth': DEFAULT_NAMESPACE, 1139 | 'mask': DEFAULT_NAMESPACE, 1140 | 'maskContentUnits': DEFAULT_NAMESPACE, 1141 | 'maskUnits': DEFAULT_NAMESPACE, 1142 | 'mathematical': DEFAULT_NAMESPACE, 1143 | 'max': DEFAULT_NAMESPACE, 1144 | 'media': DEFAULT_NAMESPACE, 1145 | 'mediaCharacterEncoding': DEFAULT_NAMESPACE, 1146 | 'mediaContentEncodings': DEFAULT_NAMESPACE, 1147 | 'mediaSize': DEFAULT_NAMESPACE, 1148 | 'mediaTime': DEFAULT_NAMESPACE, 1149 | 'method': DEFAULT_NAMESPACE, 1150 | 'min': DEFAULT_NAMESPACE, 1151 | 'mode': DEFAULT_NAMESPACE, 1152 | 'name': DEFAULT_NAMESPACE, 1153 | 'nav-down': DEFAULT_NAMESPACE, 1154 | 'nav-down-left': DEFAULT_NAMESPACE, 1155 | 'nav-down-right': DEFAULT_NAMESPACE, 1156 | 'nav-left': DEFAULT_NAMESPACE, 1157 | 'nav-next': DEFAULT_NAMESPACE, 1158 | 'nav-prev': DEFAULT_NAMESPACE, 1159 | 'nav-right': DEFAULT_NAMESPACE, 1160 | 'nav-up': DEFAULT_NAMESPACE, 1161 | 'nav-up-left': DEFAULT_NAMESPACE, 1162 | 'nav-up-right': DEFAULT_NAMESPACE, 1163 | 'numOctaves': DEFAULT_NAMESPACE, 1164 | 'observer': DEFAULT_NAMESPACE, 1165 | 'offset': DEFAULT_NAMESPACE, 1166 | 'opacity': DEFAULT_NAMESPACE, 1167 | 'operator': DEFAULT_NAMESPACE, 1168 | 'order': DEFAULT_NAMESPACE, 1169 | 'orient': DEFAULT_NAMESPACE, 1170 | 'orientation': DEFAULT_NAMESPACE, 1171 | 'origin': DEFAULT_NAMESPACE, 1172 | 'overflow': DEFAULT_NAMESPACE, 1173 | 'overlay': DEFAULT_NAMESPACE, 1174 | 'overline-position': DEFAULT_NAMESPACE, 1175 | 'overline-thickness': DEFAULT_NAMESPACE, 1176 | 'panose-1': DEFAULT_NAMESPACE, 1177 | 'path': DEFAULT_NAMESPACE, 1178 | 'pathLength': DEFAULT_NAMESPACE, 1179 | 'patternContentUnits': DEFAULT_NAMESPACE, 1180 | 'patternTransform': DEFAULT_NAMESPACE, 1181 | 'patternUnits': DEFAULT_NAMESPACE, 1182 | 'phase': DEFAULT_NAMESPACE, 1183 | 'playbackOrder': DEFAULT_NAMESPACE, 1184 | 'pointer-events': DEFAULT_NAMESPACE, 1185 | 'points': DEFAULT_NAMESPACE, 1186 | 'pointsAtX': DEFAULT_NAMESPACE, 1187 | 'pointsAtY': DEFAULT_NAMESPACE, 1188 | 'pointsAtZ': DEFAULT_NAMESPACE, 1189 | 'preserveAlpha': DEFAULT_NAMESPACE, 1190 | 'preserveAspectRatio': DEFAULT_NAMESPACE, 1191 | 'primitiveUnits': DEFAULT_NAMESPACE, 1192 | 'propagate': DEFAULT_NAMESPACE, 1193 | 'property': DEFAULT_NAMESPACE, 1194 | 'r': DEFAULT_NAMESPACE, 1195 | 'radius': DEFAULT_NAMESPACE, 1196 | 'refX': DEFAULT_NAMESPACE, 1197 | 'refY': DEFAULT_NAMESPACE, 1198 | 'rel': DEFAULT_NAMESPACE, 1199 | 'rendering-intent': DEFAULT_NAMESPACE, 1200 | 'repeatCount': DEFAULT_NAMESPACE, 1201 | 'repeatDur': DEFAULT_NAMESPACE, 1202 | 'requiredExtensions': DEFAULT_NAMESPACE, 1203 | 'requiredFeatures': DEFAULT_NAMESPACE, 1204 | 'requiredFonts': DEFAULT_NAMESPACE, 1205 | 'requiredFormats': DEFAULT_NAMESPACE, 1206 | 'resource': DEFAULT_NAMESPACE, 1207 | 'restart': DEFAULT_NAMESPACE, 1208 | 'result': DEFAULT_NAMESPACE, 1209 | 'rev': DEFAULT_NAMESPACE, 1210 | 'role': DEFAULT_NAMESPACE, 1211 | 'rotate': DEFAULT_NAMESPACE, 1212 | 'rx': DEFAULT_NAMESPACE, 1213 | 'ry': DEFAULT_NAMESPACE, 1214 | 'scale': DEFAULT_NAMESPACE, 1215 | 'seed': DEFAULT_NAMESPACE, 1216 | 'shape-rendering': DEFAULT_NAMESPACE, 1217 | 'slope': DEFAULT_NAMESPACE, 1218 | 'snapshotTime': DEFAULT_NAMESPACE, 1219 | 'spacing': DEFAULT_NAMESPACE, 1220 | 'specularConstant': DEFAULT_NAMESPACE, 1221 | 'specularExponent': DEFAULT_NAMESPACE, 1222 | 'spreadMethod': DEFAULT_NAMESPACE, 1223 | 'startOffset': DEFAULT_NAMESPACE, 1224 | 'stdDeviation': DEFAULT_NAMESPACE, 1225 | 'stemh': DEFAULT_NAMESPACE, 1226 | 'stemv': DEFAULT_NAMESPACE, 1227 | 'stitchTiles': DEFAULT_NAMESPACE, 1228 | 'stop-color': DEFAULT_NAMESPACE, 1229 | 'stop-opacity': DEFAULT_NAMESPACE, 1230 | 'strikethrough-position': DEFAULT_NAMESPACE, 1231 | 'strikethrough-thickness': DEFAULT_NAMESPACE, 1232 | 'string': DEFAULT_NAMESPACE, 1233 | 'stroke': DEFAULT_NAMESPACE, 1234 | 'stroke-dasharray': DEFAULT_NAMESPACE, 1235 | 'stroke-dashoffset': DEFAULT_NAMESPACE, 1236 | 'stroke-linecap': DEFAULT_NAMESPACE, 1237 | 'stroke-linejoin': DEFAULT_NAMESPACE, 1238 | 'stroke-miterlimit': DEFAULT_NAMESPACE, 1239 | 'stroke-opacity': DEFAULT_NAMESPACE, 1240 | 'stroke-width': DEFAULT_NAMESPACE, 1241 | 'surfaceScale': DEFAULT_NAMESPACE, 1242 | 'syncBehavior': DEFAULT_NAMESPACE, 1243 | 'syncBehaviorDefault': DEFAULT_NAMESPACE, 1244 | 'syncMaster': DEFAULT_NAMESPACE, 1245 | 'syncTolerance': DEFAULT_NAMESPACE, 1246 | 'syncToleranceDefault': DEFAULT_NAMESPACE, 1247 | 'systemLanguage': DEFAULT_NAMESPACE, 1248 | 'tableValues': DEFAULT_NAMESPACE, 1249 | 'target': DEFAULT_NAMESPACE, 1250 | 'targetX': DEFAULT_NAMESPACE, 1251 | 'targetY': DEFAULT_NAMESPACE, 1252 | 'text-anchor': DEFAULT_NAMESPACE, 1253 | 'text-decoration': DEFAULT_NAMESPACE, 1254 | 'text-rendering': DEFAULT_NAMESPACE, 1255 | 'textLength': DEFAULT_NAMESPACE, 1256 | 'timelineBegin': DEFAULT_NAMESPACE, 1257 | 'title': DEFAULT_NAMESPACE, 1258 | 'to': DEFAULT_NAMESPACE, 1259 | 'transform': DEFAULT_NAMESPACE, 1260 | 'transformBehavior': DEFAULT_NAMESPACE, 1261 | 'type': DEFAULT_NAMESPACE, 1262 | 'typeof': DEFAULT_NAMESPACE, 1263 | 'u1': DEFAULT_NAMESPACE, 1264 | 'u2': DEFAULT_NAMESPACE, 1265 | 'underline-position': DEFAULT_NAMESPACE, 1266 | 'underline-thickness': DEFAULT_NAMESPACE, 1267 | 'unicode': DEFAULT_NAMESPACE, 1268 | 'unicode-bidi': DEFAULT_NAMESPACE, 1269 | 'unicode-range': DEFAULT_NAMESPACE, 1270 | 'units-per-em': DEFAULT_NAMESPACE, 1271 | 'v-alphabetic': DEFAULT_NAMESPACE, 1272 | 'v-hanging': DEFAULT_NAMESPACE, 1273 | 'v-ideographic': DEFAULT_NAMESPACE, 1274 | 'v-mathematical': DEFAULT_NAMESPACE, 1275 | 'values': DEFAULT_NAMESPACE, 1276 | 'version': DEFAULT_NAMESPACE, 1277 | 'vert-adv-y': DEFAULT_NAMESPACE, 1278 | 'vert-origin-x': DEFAULT_NAMESPACE, 1279 | 'vert-origin-y': DEFAULT_NAMESPACE, 1280 | 'viewBox': DEFAULT_NAMESPACE, 1281 | 'viewTarget': DEFAULT_NAMESPACE, 1282 | 'visibility': DEFAULT_NAMESPACE, 1283 | 'width': DEFAULT_NAMESPACE, 1284 | 'widths': DEFAULT_NAMESPACE, 1285 | 'word-spacing': DEFAULT_NAMESPACE, 1286 | 'writing-mode': DEFAULT_NAMESPACE, 1287 | 'x': DEFAULT_NAMESPACE, 1288 | 'x-height': DEFAULT_NAMESPACE, 1289 | 'x1': DEFAULT_NAMESPACE, 1290 | 'x2': DEFAULT_NAMESPACE, 1291 | 'xChannelSelector': DEFAULT_NAMESPACE, 1292 | 'xlink:actuate': XLINK_NAMESPACE, 1293 | 'xlink:arcrole': XLINK_NAMESPACE, 1294 | 'xlink:href': XLINK_NAMESPACE, 1295 | 'xlink:role': XLINK_NAMESPACE, 1296 | 'xlink:show': XLINK_NAMESPACE, 1297 | 'xlink:title': XLINK_NAMESPACE, 1298 | 'xlink:type': XLINK_NAMESPACE, 1299 | 'xml:base': XML_NAMESPACE, 1300 | 'xml:id': XML_NAMESPACE, 1301 | 'xml:lang': XML_NAMESPACE, 1302 | 'xml:space': XML_NAMESPACE, 1303 | 'y': DEFAULT_NAMESPACE, 1304 | 'y1': DEFAULT_NAMESPACE, 1305 | 'y2': DEFAULT_NAMESPACE, 1306 | 'yChannelSelector': DEFAULT_NAMESPACE, 1307 | 'z': DEFAULT_NAMESPACE, 1308 | 'zoomAndPan': DEFAULT_NAMESPACE 1309 | }; 1310 | 1311 | module.exports = SVGAttributeNamespace; 1312 | 1313 | function SVGAttributeNamespace(value) { 1314 | if (SVG_PROPERTIES.hasOwnProperty(value)) { 1315 | return SVG_PROPERTIES[value]; 1316 | } 1317 | } 1318 | 1319 | },{}],24:[function(require,module,exports){ 1320 | 'use strict'; 1321 | 1322 | var isArray = require('x-is-array'); 1323 | 1324 | var h = require('./index.js'); 1325 | 1326 | 1327 | var SVGAttributeNamespace = require('./svg-attribute-namespace'); 1328 | var attributeHook = require('./hooks/attribute-hook'); 1329 | 1330 | var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; 1331 | 1332 | module.exports = svg; 1333 | 1334 | function svg(tagName, properties, children) { 1335 | if (!children && isChildren(properties)) { 1336 | children = properties; 1337 | properties = {}; 1338 | } 1339 | 1340 | properties = properties || {}; 1341 | 1342 | // set namespace for svg 1343 | properties.namespace = SVG_NAMESPACE; 1344 | 1345 | var attributes = properties.attributes || (properties.attributes = {}); 1346 | 1347 | for (var key in properties) { 1348 | if (!properties.hasOwnProperty(key)) { 1349 | continue; 1350 | } 1351 | 1352 | var namespace = SVGAttributeNamespace(key); 1353 | 1354 | if (namespace === undefined) { // not a svg attribute 1355 | continue; 1356 | } 1357 | 1358 | var value = properties[key]; 1359 | 1360 | if (typeof value !== 'string' && 1361 | typeof value !== 'number' && 1362 | typeof value !== 'boolean' 1363 | ) { 1364 | continue; 1365 | } 1366 | 1367 | if (namespace !== null) { // namespaced attribute 1368 | properties[key] = attributeHook(namespace, value); 1369 | continue; 1370 | } 1371 | 1372 | attributes[key] = value 1373 | properties[key] = undefined 1374 | } 1375 | 1376 | return h(tagName, properties, children); 1377 | } 1378 | 1379 | function isChildren(x) { 1380 | return typeof x === 'string' || isArray(x); 1381 | } 1382 | 1383 | },{"./hooks/attribute-hook":18,"./index.js":21,"./svg-attribute-namespace":23,"x-is-array":10}],25:[function(require,module,exports){ 1384 | var isVNode = require("./is-vnode") 1385 | var isVText = require("./is-vtext") 1386 | var isWidget = require("./is-widget") 1387 | var isThunk = require("./is-thunk") 1388 | 1389 | module.exports = handleThunk 1390 | 1391 | function handleThunk(a, b) { 1392 | var renderedA = a 1393 | var renderedB = b 1394 | 1395 | if (isThunk(b)) { 1396 | renderedB = renderThunk(b, a) 1397 | } 1398 | 1399 | if (isThunk(a)) { 1400 | renderedA = renderThunk(a, null) 1401 | } 1402 | 1403 | return { 1404 | a: renderedA, 1405 | b: renderedB 1406 | } 1407 | } 1408 | 1409 | function renderThunk(thunk, previous) { 1410 | var renderedThunk = thunk.vnode 1411 | 1412 | if (!renderedThunk) { 1413 | renderedThunk = thunk.vnode = thunk.render(previous) 1414 | } 1415 | 1416 | if (!(isVNode(renderedThunk) || 1417 | isVText(renderedThunk) || 1418 | isWidget(renderedThunk))) { 1419 | throw new Error("thunk did not return a valid node"); 1420 | } 1421 | 1422 | return renderedThunk 1423 | } 1424 | 1425 | },{"./is-thunk":26,"./is-vnode":28,"./is-vtext":29,"./is-widget":30}],26:[function(require,module,exports){ 1426 | module.exports = isThunk 1427 | 1428 | function isThunk(t) { 1429 | return t && t.type === "Thunk" 1430 | } 1431 | 1432 | },{}],27:[function(require,module,exports){ 1433 | module.exports = isHook 1434 | 1435 | function isHook(hook) { 1436 | return hook && 1437 | (typeof hook.hook === "function" && !hook.hasOwnProperty("hook") || 1438 | typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook")) 1439 | } 1440 | 1441 | },{}],28:[function(require,module,exports){ 1442 | var version = require("./version") 1443 | 1444 | module.exports = isVirtualNode 1445 | 1446 | function isVirtualNode(x) { 1447 | return x && x.type === "VirtualNode" && x.version === version 1448 | } 1449 | 1450 | },{"./version":31}],29:[function(require,module,exports){ 1451 | var version = require("./version") 1452 | 1453 | module.exports = isVirtualText 1454 | 1455 | function isVirtualText(x) { 1456 | return x && x.type === "VirtualText" && x.version === version 1457 | } 1458 | 1459 | },{"./version":31}],30:[function(require,module,exports){ 1460 | module.exports = isWidget 1461 | 1462 | function isWidget(w) { 1463 | return w && w.type === "Widget" 1464 | } 1465 | 1466 | },{}],31:[function(require,module,exports){ 1467 | module.exports = "2" 1468 | 1469 | },{}],32:[function(require,module,exports){ 1470 | var version = require("./version") 1471 | var isVNode = require("./is-vnode") 1472 | var isWidget = require("./is-widget") 1473 | var isThunk = require("./is-thunk") 1474 | var isVHook = require("./is-vhook") 1475 | 1476 | module.exports = VirtualNode 1477 | 1478 | var noProperties = {} 1479 | var noChildren = [] 1480 | 1481 | function VirtualNode(tagName, properties, children, key, namespace) { 1482 | this.tagName = tagName 1483 | this.properties = properties || noProperties 1484 | this.children = children || noChildren 1485 | this.key = key != null ? String(key) : undefined 1486 | this.namespace = (typeof namespace === "string") ? namespace : null 1487 | 1488 | var count = (children && children.length) || 0 1489 | var descendants = 0 1490 | var hasWidgets = false 1491 | var hasThunks = false 1492 | var descendantHooks = false 1493 | var hooks 1494 | 1495 | for (var propName in properties) { 1496 | if (properties.hasOwnProperty(propName)) { 1497 | var property = properties[propName] 1498 | if (isVHook(property) && property.unhook) { 1499 | if (!hooks) { 1500 | hooks = {} 1501 | } 1502 | 1503 | hooks[propName] = property 1504 | } 1505 | } 1506 | } 1507 | 1508 | for (var i = 0; i < count; i++) { 1509 | var child = children[i] 1510 | if (isVNode(child)) { 1511 | descendants += child.count || 0 1512 | 1513 | if (!hasWidgets && child.hasWidgets) { 1514 | hasWidgets = true 1515 | } 1516 | 1517 | if (!hasThunks && child.hasThunks) { 1518 | hasThunks = true 1519 | } 1520 | 1521 | if (!descendantHooks && (child.hooks || child.descendantHooks)) { 1522 | descendantHooks = true 1523 | } 1524 | } else if (!hasWidgets && isWidget(child)) { 1525 | if (typeof child.destroy === "function") { 1526 | hasWidgets = true 1527 | } 1528 | } else if (!hasThunks && isThunk(child)) { 1529 | hasThunks = true; 1530 | } 1531 | } 1532 | 1533 | this.count = count + descendants 1534 | this.hasWidgets = hasWidgets 1535 | this.hasThunks = hasThunks 1536 | this.hooks = hooks 1537 | this.descendantHooks = descendantHooks 1538 | } 1539 | 1540 | VirtualNode.prototype.version = version 1541 | VirtualNode.prototype.type = "VirtualNode" 1542 | 1543 | },{"./is-thunk":26,"./is-vhook":27,"./is-vnode":28,"./is-widget":30,"./version":31}],33:[function(require,module,exports){ 1544 | var version = require("./version") 1545 | 1546 | VirtualPatch.NONE = 0 1547 | VirtualPatch.VTEXT = 1 1548 | VirtualPatch.VNODE = 2 1549 | VirtualPatch.WIDGET = 3 1550 | VirtualPatch.PROPS = 4 1551 | VirtualPatch.ORDER = 5 1552 | VirtualPatch.INSERT = 6 1553 | VirtualPatch.REMOVE = 7 1554 | VirtualPatch.THUNK = 8 1555 | 1556 | module.exports = VirtualPatch 1557 | 1558 | function VirtualPatch(type, vNode, patch) { 1559 | this.type = Number(type) 1560 | this.vNode = vNode 1561 | this.patch = patch 1562 | } 1563 | 1564 | VirtualPatch.prototype.version = version 1565 | VirtualPatch.prototype.type = "VirtualPatch" 1566 | 1567 | },{"./version":31}],34:[function(require,module,exports){ 1568 | var version = require("./version") 1569 | 1570 | module.exports = VirtualText 1571 | 1572 | function VirtualText(text) { 1573 | this.text = String(text) 1574 | } 1575 | 1576 | VirtualText.prototype.version = version 1577 | VirtualText.prototype.type = "VirtualText" 1578 | 1579 | },{"./version":31}],35:[function(require,module,exports){ 1580 | var isObject = require("is-object") 1581 | var isHook = require("../vnode/is-vhook") 1582 | 1583 | module.exports = diffProps 1584 | 1585 | function diffProps(a, b) { 1586 | var diff 1587 | 1588 | for (var aKey in a) { 1589 | if (!(aKey in b)) { 1590 | diff = diff || {} 1591 | diff[aKey] = undefined 1592 | } 1593 | 1594 | var aValue = a[aKey] 1595 | var bValue = b[aKey] 1596 | 1597 | if (aValue === bValue) { 1598 | continue 1599 | } else if (isObject(aValue) && isObject(bValue)) { 1600 | if (getPrototype(bValue) !== getPrototype(aValue)) { 1601 | diff = diff || {} 1602 | diff[aKey] = bValue 1603 | } else if (isHook(bValue)) { 1604 | diff = diff || {} 1605 | diff[aKey] = bValue 1606 | } else { 1607 | var objectDiff = diffProps(aValue, bValue) 1608 | if (objectDiff) { 1609 | diff = diff || {} 1610 | diff[aKey] = objectDiff 1611 | } 1612 | } 1613 | } else { 1614 | diff = diff || {} 1615 | diff[aKey] = bValue 1616 | } 1617 | } 1618 | 1619 | for (var bKey in b) { 1620 | if (!(bKey in a)) { 1621 | diff = diff || {} 1622 | diff[bKey] = b[bKey] 1623 | } 1624 | } 1625 | 1626 | return diff 1627 | } 1628 | 1629 | function getPrototype(value) { 1630 | if (Object.getPrototypeOf) { 1631 | return Object.getPrototypeOf(value) 1632 | } else if (value.__proto__) { 1633 | return value.__proto__ 1634 | } else if (value.constructor) { 1635 | return value.constructor.prototype 1636 | } 1637 | } 1638 | 1639 | },{"../vnode/is-vhook":27,"is-object":9}],36:[function(require,module,exports){ 1640 | var isArray = require("x-is-array") 1641 | 1642 | var VPatch = require("../vnode/vpatch") 1643 | var isVNode = require("../vnode/is-vnode") 1644 | var isVText = require("../vnode/is-vtext") 1645 | var isWidget = require("../vnode/is-widget") 1646 | var isThunk = require("../vnode/is-thunk") 1647 | var handleThunk = require("../vnode/handle-thunk") 1648 | 1649 | var diffProps = require("./diff-props") 1650 | 1651 | module.exports = diff 1652 | 1653 | function diff(a, b) { 1654 | var patch = { a: a } 1655 | walk(a, b, patch, 0) 1656 | return patch 1657 | } 1658 | 1659 | function walk(a, b, patch, index) { 1660 | if (a === b) { 1661 | return 1662 | } 1663 | 1664 | var apply = patch[index] 1665 | var applyClear = false 1666 | 1667 | if (isThunk(a) || isThunk(b)) { 1668 | thunks(a, b, patch, index) 1669 | } else if (b == null) { 1670 | 1671 | // If a is a widget we will add a remove patch for it 1672 | // Otherwise any child widgets/hooks must be destroyed. 1673 | // This prevents adding two remove patches for a widget. 1674 | if (!isWidget(a)) { 1675 | clearState(a, patch, index) 1676 | apply = patch[index] 1677 | } 1678 | 1679 | apply = appendPatch(apply, new VPatch(VPatch.REMOVE, a, b)) 1680 | } else if (isVNode(b)) { 1681 | if (isVNode(a)) { 1682 | if (a.tagName === b.tagName && 1683 | a.namespace === b.namespace && 1684 | a.key === b.key) { 1685 | var propsPatch = diffProps(a.properties, b.properties) 1686 | if (propsPatch) { 1687 | apply = appendPatch(apply, 1688 | new VPatch(VPatch.PROPS, a, propsPatch)) 1689 | } 1690 | apply = diffChildren(a, b, patch, apply, index) 1691 | } else { 1692 | apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b)) 1693 | applyClear = true 1694 | } 1695 | } else { 1696 | apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b)) 1697 | applyClear = true 1698 | } 1699 | } else if (isVText(b)) { 1700 | if (!isVText(a)) { 1701 | apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b)) 1702 | applyClear = true 1703 | } else if (a.text !== b.text) { 1704 | apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b)) 1705 | } 1706 | } else if (isWidget(b)) { 1707 | if (!isWidget(a)) { 1708 | applyClear = true 1709 | } 1710 | 1711 | apply = appendPatch(apply, new VPatch(VPatch.WIDGET, a, b)) 1712 | } 1713 | 1714 | if (apply) { 1715 | patch[index] = apply 1716 | } 1717 | 1718 | if (applyClear) { 1719 | clearState(a, patch, index) 1720 | } 1721 | } 1722 | 1723 | function diffChildren(a, b, patch, apply, index) { 1724 | var aChildren = a.children 1725 | var orderedSet = reorder(aChildren, b.children) 1726 | var bChildren = orderedSet.children 1727 | 1728 | var aLen = aChildren.length 1729 | var bLen = bChildren.length 1730 | var len = aLen > bLen ? aLen : bLen 1731 | 1732 | for (var i = 0; i < len; i++) { 1733 | var leftNode = aChildren[i] 1734 | var rightNode = bChildren[i] 1735 | index += 1 1736 | 1737 | if (!leftNode) { 1738 | if (rightNode) { 1739 | // Excess nodes in b need to be added 1740 | apply = appendPatch(apply, 1741 | new VPatch(VPatch.INSERT, null, rightNode)) 1742 | } 1743 | } else { 1744 | walk(leftNode, rightNode, patch, index) 1745 | } 1746 | 1747 | if (isVNode(leftNode) && leftNode.count) { 1748 | index += leftNode.count 1749 | } 1750 | } 1751 | 1752 | if (orderedSet.moves) { 1753 | // Reorder nodes last 1754 | apply = appendPatch(apply, new VPatch( 1755 | VPatch.ORDER, 1756 | a, 1757 | orderedSet.moves 1758 | )) 1759 | } 1760 | 1761 | return apply 1762 | } 1763 | 1764 | function clearState(vNode, patch, index) { 1765 | // TODO: Make this a single walk, not two 1766 | unhook(vNode, patch, index) 1767 | destroyWidgets(vNode, patch, index) 1768 | } 1769 | 1770 | // Patch records for all destroyed widgets must be added because we need 1771 | // a DOM node reference for the destroy function 1772 | function destroyWidgets(vNode, patch, index) { 1773 | if (isWidget(vNode)) { 1774 | if (typeof vNode.destroy === "function") { 1775 | patch[index] = appendPatch( 1776 | patch[index], 1777 | new VPatch(VPatch.REMOVE, vNode, null) 1778 | ) 1779 | } 1780 | } else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) { 1781 | var children = vNode.children 1782 | var len = children.length 1783 | for (var i = 0; i < len; i++) { 1784 | var child = children[i] 1785 | index += 1 1786 | 1787 | destroyWidgets(child, patch, index) 1788 | 1789 | if (isVNode(child) && child.count) { 1790 | index += child.count 1791 | } 1792 | } 1793 | } else if (isThunk(vNode)) { 1794 | thunks(vNode, null, patch, index) 1795 | } 1796 | } 1797 | 1798 | // Create a sub-patch for thunks 1799 | function thunks(a, b, patch, index) { 1800 | var nodes = handleThunk(a, b) 1801 | var thunkPatch = diff(nodes.a, nodes.b) 1802 | if (hasPatches(thunkPatch)) { 1803 | patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch) 1804 | } 1805 | } 1806 | 1807 | function hasPatches(patch) { 1808 | for (var index in patch) { 1809 | if (index !== "a") { 1810 | return true 1811 | } 1812 | } 1813 | 1814 | return false 1815 | } 1816 | 1817 | // Execute hooks when two nodes are identical 1818 | function unhook(vNode, patch, index) { 1819 | if (isVNode(vNode)) { 1820 | if (vNode.hooks) { 1821 | patch[index] = appendPatch( 1822 | patch[index], 1823 | new VPatch( 1824 | VPatch.PROPS, 1825 | vNode, 1826 | undefinedKeys(vNode.hooks) 1827 | ) 1828 | ) 1829 | } 1830 | 1831 | if (vNode.descendantHooks || vNode.hasThunks) { 1832 | var children = vNode.children 1833 | var len = children.length 1834 | for (var i = 0; i < len; i++) { 1835 | var child = children[i] 1836 | index += 1 1837 | 1838 | unhook(child, patch, index) 1839 | 1840 | if (isVNode(child) && child.count) { 1841 | index += child.count 1842 | } 1843 | } 1844 | } 1845 | } else if (isThunk(vNode)) { 1846 | thunks(vNode, null, patch, index) 1847 | } 1848 | } 1849 | 1850 | function undefinedKeys(obj) { 1851 | var result = {} 1852 | 1853 | for (var key in obj) { 1854 | result[key] = undefined 1855 | } 1856 | 1857 | return result 1858 | } 1859 | 1860 | // List diff, naive left to right reordering 1861 | function reorder(aChildren, bChildren) { 1862 | // O(M) time, O(M) memory 1863 | var bChildIndex = keyIndex(bChildren) 1864 | var bKeys = bChildIndex.keys 1865 | var bFree = bChildIndex.free 1866 | 1867 | if (bFree.length === bChildren.length) { 1868 | return { 1869 | children: bChildren, 1870 | moves: null 1871 | } 1872 | } 1873 | 1874 | // O(N) time, O(N) memory 1875 | var aChildIndex = keyIndex(aChildren) 1876 | var aKeys = aChildIndex.keys 1877 | var aFree = aChildIndex.free 1878 | 1879 | if (aFree.length === aChildren.length) { 1880 | return { 1881 | children: bChildren, 1882 | moves: null 1883 | } 1884 | } 1885 | 1886 | // O(MAX(N, M)) memory 1887 | var newChildren = [] 1888 | 1889 | var freeIndex = 0 1890 | var freeCount = bFree.length 1891 | var deletedItems = 0 1892 | 1893 | // Iterate through a and match a node in b 1894 | // O(N) time, 1895 | for (var i = 0 ; i < aChildren.length; i++) { 1896 | var aItem = aChildren[i] 1897 | var itemIndex 1898 | 1899 | if (aItem.key) { 1900 | if (bKeys.hasOwnProperty(aItem.key)) { 1901 | // Match up the old keys 1902 | itemIndex = bKeys[aItem.key] 1903 | newChildren.push(bChildren[itemIndex]) 1904 | 1905 | } else { 1906 | // Remove old keyed items 1907 | itemIndex = i - deletedItems++ 1908 | newChildren.push(null) 1909 | } 1910 | } else { 1911 | // Match the item in a with the next free item in b 1912 | if (freeIndex < freeCount) { 1913 | itemIndex = bFree[freeIndex++] 1914 | newChildren.push(bChildren[itemIndex]) 1915 | } else { 1916 | // There are no free items in b to match with 1917 | // the free items in a, so the extra free nodes 1918 | // are deleted. 1919 | itemIndex = i - deletedItems++ 1920 | newChildren.push(null) 1921 | } 1922 | } 1923 | } 1924 | 1925 | var lastFreeIndex = freeIndex >= bFree.length ? 1926 | bChildren.length : 1927 | bFree[freeIndex] 1928 | 1929 | // Iterate through b and append any new keys 1930 | // O(M) time 1931 | for (var j = 0; j < bChildren.length; j++) { 1932 | var newItem = bChildren[j] 1933 | 1934 | if (newItem.key) { 1935 | if (!aKeys.hasOwnProperty(newItem.key)) { 1936 | // Add any new keyed items 1937 | // We are adding new items to the end and then sorting them 1938 | // in place. In future we should insert new items in place. 1939 | newChildren.push(newItem) 1940 | } 1941 | } else if (j >= lastFreeIndex) { 1942 | // Add any leftover non-keyed items 1943 | newChildren.push(newItem) 1944 | } 1945 | } 1946 | 1947 | var simulate = newChildren.slice() 1948 | var simulateIndex = 0 1949 | var removes = [] 1950 | var inserts = [] 1951 | var simulateItem 1952 | 1953 | for (var k = 0; k < bChildren.length;) { 1954 | var wantedItem = bChildren[k] 1955 | simulateItem = simulate[simulateIndex] 1956 | 1957 | // remove items 1958 | while (simulateItem === null && simulate.length) { 1959 | removes.push(remove(simulate, simulateIndex, null)) 1960 | simulateItem = simulate[simulateIndex] 1961 | } 1962 | 1963 | if (!simulateItem || simulateItem.key !== wantedItem.key) { 1964 | // if we need a key in this position... 1965 | if (wantedItem.key) { 1966 | if (simulateItem && simulateItem.key) { 1967 | // if an insert doesn't put this key in place, it needs to move 1968 | if (bKeys[simulateItem.key] !== k + 1) { 1969 | removes.push(remove(simulate, simulateIndex, simulateItem.key)) 1970 | simulateItem = simulate[simulateIndex] 1971 | // if the remove didn't put the wanted item in place, we need to insert it 1972 | if (!simulateItem || simulateItem.key !== wantedItem.key) { 1973 | inserts.push({key: wantedItem.key, to: k}) 1974 | } 1975 | // items are matching, so skip ahead 1976 | else { 1977 | simulateIndex++ 1978 | } 1979 | } 1980 | else { 1981 | inserts.push({key: wantedItem.key, to: k}) 1982 | } 1983 | } 1984 | else { 1985 | inserts.push({key: wantedItem.key, to: k}) 1986 | } 1987 | k++ 1988 | } 1989 | // a key in simulate has no matching wanted key, remove it 1990 | else if (simulateItem && simulateItem.key) { 1991 | removes.push(remove(simulate, simulateIndex, simulateItem.key)) 1992 | } 1993 | } 1994 | else { 1995 | simulateIndex++ 1996 | k++ 1997 | } 1998 | } 1999 | 2000 | // remove all the remaining nodes from simulate 2001 | while(simulateIndex < simulate.length) { 2002 | simulateItem = simulate[simulateIndex] 2003 | removes.push(remove(simulate, simulateIndex, simulateItem && simulateItem.key)) 2004 | } 2005 | 2006 | // If the only moves we have are deletes then we can just 2007 | // let the delete patch remove these items. 2008 | if (removes.length === deletedItems && !inserts.length) { 2009 | return { 2010 | children: newChildren, 2011 | moves: null 2012 | } 2013 | } 2014 | 2015 | return { 2016 | children: newChildren, 2017 | moves: { 2018 | removes: removes, 2019 | inserts: inserts 2020 | } 2021 | } 2022 | } 2023 | 2024 | function remove(arr, index, key) { 2025 | arr.splice(index, 1) 2026 | 2027 | return { 2028 | from: index, 2029 | key: key 2030 | } 2031 | } 2032 | 2033 | function keyIndex(children) { 2034 | var keys = {} 2035 | var free = [] 2036 | var length = children.length 2037 | 2038 | for (var i = 0; i < length; i++) { 2039 | var child = children[i] 2040 | 2041 | if (child.key) { 2042 | keys[child.key] = i 2043 | } else { 2044 | free.push(i) 2045 | } 2046 | } 2047 | 2048 | return { 2049 | keys: keys, // A hash of key name to index 2050 | free: free, // An array of unkeyed item indices 2051 | } 2052 | } 2053 | 2054 | function appendPatch(apply, patch) { 2055 | if (apply) { 2056 | if (isArray(apply)) { 2057 | apply.push(patch) 2058 | } else { 2059 | apply = [apply, patch] 2060 | } 2061 | 2062 | return apply 2063 | } else { 2064 | return patch 2065 | } 2066 | } 2067 | 2068 | },{"../vnode/handle-thunk":25,"../vnode/is-thunk":26,"../vnode/is-vnode":28,"../vnode/is-vtext":29,"../vnode/is-widget":30,"../vnode/vpatch":33,"./diff-props":35,"x-is-array":10}],37:[function(require,module,exports){ 2069 | return VDOM = { 2070 | diff: require("virtual-dom/diff"), 2071 | patch: require("virtual-dom/patch"), 2072 | create: require("virtual-dom/create-element"), 2073 | VHtml: require("virtual-dom/vnode/vnode"), 2074 | VText: require("virtual-dom/vnode/vtext"), 2075 | VSvg: require("virtual-dom/virtual-hyperscript/svg") 2076 | } 2077 | 2078 | },{"virtual-dom/create-element":2,"virtual-dom/diff":3,"virtual-dom/patch":11,"virtual-dom/virtual-hyperscript/svg":24,"virtual-dom/vnode/vnode":32,"virtual-dom/vnode/vtext":34}]},{},[37]); 2079 | 2080 | var g,aa=this; 2081 | function u(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if("function"== 2082 | b&&"undefined"==typeof a.call)return"object";return b}function ba(a){return a[ca]||(a[ca]=++ea)}var ca="closure_uid_"+(1E9*Math.random()>>>0),ea=0;function ga(a,b,c){return a.call.apply(a.bind,arguments)}function ja(a,b,c){if(!a)throw Error();if(2b?1:a>>16&65535)*d+c*(b>>>16&65535)<<16>>>0)|0};function Zb(a){a=Yb(a|0,-862048943);return Yb(a<<15|a>>>-15,461845907)} 2113 | function $b(a,b){var c=(a|0)^(b|0);return Yb(c<<13|c>>>-13,5)+-430675100|0}function ac(a,b){var c=(a|0)^b,c=Yb(c^c>>>16,-2048144789),c=Yb(c^c>>>13,-1028477387);return c^c>>>16}function bc(a){var b;a:{b=1;for(var c=0;;)if(b>2)}function Ja(a,b){return b instanceof a}function lc(a,b){if(a.Ga===b.Ga)return 0;var c=Na(a.ra);if(y(c?b.ra:c))return-1;if(y(a.ra)){if(Na(b.ra))return 1;c=ra(a.ra,b.ra);return 0===c?ra(a.name,b.name):c}return ra(a.name,b.name)}H;function dc(a,b,c,d,e){this.ra=a;this.name=b;this.Ga=c;this.Ua=d;this.ya=e;this.i=2154168321;this.B=4096}g=dc.prototype;g.toString=function(){return this.Ga};g.equiv=function(a){return this.w(null,a)}; 2116 | g.w=function(a,b){return b instanceof dc?this.Ga===b.Ga:!1};g.call=function(){function a(a,b,c){return H.c?H.c(b,this,c):H.call(null,b,this,c)}function b(a,b){return H.b?H.b(b,this):H.call(null,b,this)}var c=null,c=function(c,e,f){switch(arguments.length){case 2:return b.call(this,0,e);case 3:return a.call(this,0,e,f)}throw Error("Invalid arity: "+arguments.length);};c.b=b;c.c=a;return c}();g.apply=function(a,b){return this.call.apply(this,[this].concat(Qa(b)))}; 2117 | g.a=function(a){return H.b?H.b(a,this):H.call(null,a,this)};g.b=function(a,b){return H.c?H.c(a,this,b):H.call(null,a,this,b)};g.O=function(){return this.ya};g.R=function(a,b){return new dc(this.ra,this.name,this.Ga,this.Ua,b)};g.N=function(){var a=this.Ua;return null!=a?a:this.Ua=a=kc(bc(this.name),ic(this.ra))};g.hb=function(){return this.name};g.ib=function(){return this.ra};g.K=function(a,b){return Ab(b,this.Ga)}; 2118 | var nc=function nc(b){for(var c=[],d=arguments.length,e=0;;)if(ea?0:a};g.N=function(){return xc(this)};g.w=function(a,b){return Cc.b?Cc.b(this,b):Cc.call(null,this,b)};g.Y=function(a,b){return Lc(this.f,b,this.f[this.j],this.j+1)}; 2128 | g.Z=function(a,b,c){return Lc(this.f,b,c,this.j)};g.$=function(){return this.f[this.j]};g.qa=function(){return this.j+1d)c=1;else if(0===c)c=0;else a:for(d=0;;){var e=fc(Zc(a,d),Zc(b,d));if(0===e&&d+1b?a:b};wd.l=function(a,b,c){return Ra.c(wd,a>b?a:b,c)};wd.D=function(a){var b=L(a),c=M(a);a=L(c);c=M(c);return wd.l(b,a,c)};wd.A=2;var xd=function xd(b){for(var c=[],d=arguments.length,e=0;;)if(e>1&1431655765;a=(a&858993459)+(a>>2&858993459);return 16843009*(a+(a>>4)&252645135)>>24}function Bd(a){var b=2;for(a=K(a);;)if(a&&0a?0:a-1>>>5<<5}function De(a,b,c){for(;;){if(0===b)return c;var d=Be(a);d.f[0]=c;c=d;b-=5}}var Ee=function Ee(b,c,d,e){var f=new Ae(d.L,Qa(d.f)),h=b.m-1>>>c&31;5===c?f.f[h]=e:(d=d.f[h],b=null!=d?Ee(b,c-5,d,e):De(null,c-5,e),f.f[h]=b);return f}; 2224 | function Fe(a,b){throw Error([E("No item "),E(a),E(" in vector of length "),E(b)].join(""));}function Ge(a,b){if(b>=Ce(a))return a.I;for(var c=a.root,d=a.shift;;)if(0>>d&31],d=e;else return c.f}function He(a,b){return 0<=b&&b>>c&31;b=Ie(b,c-5,d.f[k],e,f);h.f[k]=b}return h};function Je(a,b,c,d,e,f){this.j=a;this.rb=b;this.f=c;this.Ha=d;this.start=e;this.end=f} 2225 | Je.prototype.ua=function(){return this.j=this.m)return new J(this.I,0);var a;a:{a=this.root;for(var b=this.shift;;)if(0this.m-Ce(this)){for(var c=this.I.length,d=Array(c+1),e=0;;)if(e>>5>1<b)a=new U(null,b,5,V,a,null);else for(var c=32,d=(new U(null,32,5,V,a.slice(0,32),null)).Wa(null);;)if(cb||this.end<=this.start+b?Fe(b,this.end-this.start):G.b(this.Ha,this.start+b)};g.ta=function(a,b,c){return 0>b||this.end<=this.start+b?c:G.c(this.Ha,this.start+b,c)};g.Qa=function(a,b,c){var d=this.start+b;a=this.v;c=ad.c(this.Ha,d,c);b=this.start;var e=this.end,d=d+1,d=e>d?e:d;return Re.C?Re.C(a,c,b,d,null):Re.call(null,a,c,b,d,null)};g.O=function(){return this.v};g.X=function(){return this.end-this.start};g.N=function(){var a=this.s;return null!=a?a:this.s=a=xc(this)}; 2240 | g.w=function(a,b){return Cc(this,b)};g.Y=function(a,b){return Hc(this,b)};g.Z=function(a,b,c){return Ic(this,b,c)};g.Pa=function(a,b,c){if("number"===typeof b)return mb(this,b,c);throw Error("Subvec's key for assoc must be a number.");};g.S=function(){var a=this;return function(b){return function d(e){return e===a.end?null:O(G.b(a.Ha,e),new Ld(null,function(){return function(){return d(e+1)}}(b),null,null))}}(this)(a.start)}; 2241 | g.R=function(a,b){return Re.C?Re.C(b,this.Ha,this.start,this.end,this.s):Re.call(null,b,this.Ha,this.start,this.end,this.s)};g.T=function(a,b){var c=this.v,d=mb(this.Ha,this.end,b),e=this.start,f=this.end+1;return Re.C?Re.C(c,d,e,f,null):Re.call(null,c,d,e,f,null)}; 2242 | g.call=function(){var a=null,a=function(a,c,d){switch(arguments.length){case 2:return this.U(null,c);case 3:return this.ta(null,c,d)}throw Error("Invalid arity: "+arguments.length);};a.b=function(a,c){return this.U(null,c)};a.c=function(a,c,d){return this.ta(null,c,d)};return a}();g.apply=function(a,b){return this.call.apply(this,[this].concat(Qa(b)))};g.a=function(a){return this.U(null,a)};g.b=function(a,b){return this.ta(null,a,b)};Se.prototype[Pa]=function(){return tc(this)}; 2243 | function Re(a,b,c,d,e){for(;;)if(b instanceof Se)c=b.start+c,d=b.start+d,b=b.Ha;else{var f=Xc(b);if(0>c||0>d||c>f||d>f)throw Error("Index out of bounds");return new Se(a,b,c,d,e)}}var Qe=function Qe(b){for(var c=[],d=arguments.length,e=0;;)if(e>>c&31;if(5===c)b=e;else{var h=d.f[f];b=null!=h?Ue(b,c-5,h,e):De(b.root.L,c-5,e)}d.f[f]=b;return d};function Me(a,b,c,d){this.m=a;this.shift=b;this.root=c;this.I=d;this.B=88;this.i=275}g=Me.prototype; 2246 | g.kb=function(a,b){if(this.root.L){if(32>this.m-Ce(this))this.I[this.m&31]=b;else{var c=new Ae(this.root.L,this.I),d=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null];d[0]=b;this.I=d;if(this.m>>>5>1<>>a&31,n=f(a-5,l.f[m]);l.f[m]=n}return l}}(this).call(null,d.shift,d.root),d.root=a),this;if(b===d.m)return Fb(this,c);throw Error([E("Index "),E(b),E(" out of bounds for TransientVector of length"),E(d.m)].join(""));}throw Error("assoc! after persistent!");}; 2250 | g.X=function(){if(this.root.L)return this.m;throw Error("count after persistent!");};g.U=function(a,b){if(this.root.L)return He(this,b)[b&31];throw Error("nth after persistent!");};g.ta=function(a,b,c){return 0<=b&&bb?4:2*(b+1));md(this.f,0,c,0,2*b);return new tf(a,this.aa,c)};g.ob=function(){return lf.a?lf.a(this.f):lf.call(null,this.f)};g.La=function(a,b,c,d){var e=1<<(b>>>a&31);if(0===(this.aa&e))return d;var f=Ad(this.aa&e-1),e=this.f[2*f],f=this.f[2*f+1];return null==e?f.La(a+5,b,c,d):of(c,e)?f:d}; 2269 | g.Ba=function(a,b,c,d,e,f){var h=1<<(c>>>b&31),k=Ad(this.aa&h-1);if(0===(this.aa&h)){var l=Ad(this.aa);if(2*l>>b&31]=uf.Ba(a,b+5,c,d,e,f);for(e=d=0;;)if(32>d)0!== 2270 | (this.aa>>>d&1)&&(k[d]=null!=this.f[e]?uf.Ba(a,b+5,jc(this.f[e]),this.f[e],this.f[e+1],f):this.f[e+1],e+=2),d+=1;else break;return new rf(a,l+1,k)}b=Array(2*(l+4));md(this.f,0,b,0,2*k);b[2*k]=d;b[2*k+1]=e;md(this.f,2*k,b,2*(k+1),2*(l-k));f.M=!0;a=this.Ra(a);a.f=b;a.aa|=h;return a}l=this.f[2*k];h=this.f[2*k+1];if(null==l)return l=h.Ba(a,b+5,c,d,e,f),l===h?this:qf(this,a,2*k+1,l);if(of(d,l))return e===h?this:qf(this,a,2*k+1,e);f.M=!0;f=b+5;d=nf.W?nf.W(a,f,l,h,c,d,e):nf.call(null,a,f,l,h,c,d,e);e=2* 2271 | k;k=2*k+1;a=this.Ra(a);a.f[e]=null;a.f[k]=d;return a}; 2272 | g.Aa=function(a,b,c,d,e){var f=1<<(b>>>a&31),h=Ad(this.aa&f-1);if(0===(this.aa&f)){var k=Ad(this.aa);if(16<=k){h=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null];h[b>>>a&31]=uf.Aa(a+5,b,c,d,e);for(d=c=0;;)if(32>c)0!==(this.aa>>>c&1)&&(h[c]=null!=this.f[d]?uf.Aa(a+5,jc(this.f[d]),this.f[d],this.f[d+1],e):this.f[d+1],d+=2),c+=1;else break;return new rf(null,k+1,h)}a=Array(2*(k+1));md(this.f, 2273 | 0,a,0,2*h);a[2*h]=c;a[2*h+1]=d;md(this.f,2*h,a,2*(h+1),2*(k-h));e.M=!0;return new tf(null,this.aa|f,a)}var l=this.f[2*h],f=this.f[2*h+1];if(null==l)return k=f.Aa(a+5,b,c,d,e),k===f?this:new tf(null,this.aa,pf(this.f,2*h+1,k));if(of(c,l))return d===f?this:new tf(null,this.aa,pf(this.f,2*h+1,d));e.M=!0;e=this.aa;k=this.f;a+=5;a=nf.V?nf.V(a,l,f,b,c,d):nf.call(null,a,l,f,b,c,d);c=2*h;h=2*h+1;d=Qa(k);d[c]=null;d[h]=a;return new tf(null,e,d)};g.Da=function(){return new sf(this.f,0,null,null)}; 2274 | var uf=new tf(null,0,[]);function vf(a,b,c){this.f=a;this.j=b;this.Ca=c}vf.prototype.ua=function(){for(var a=this.f.length;;){if(null!=this.Ca&&this.Ca.ua())return!0;if(this.j>>a&31];return null!=e?e.La(a+5,b,c,d):d};g.Ba=function(a,b,c,d,e,f){var h=c>>>b&31,k=this.f[h];if(null==k)return a=qf(this,a,h,uf.Ba(a,b+5,c,d,e,f)),a.m+=1,a;b=k.Ba(a,b+5,c,d,e,f);return b===k?this:qf(this,a,h,b)}; 2276 | g.Aa=function(a,b,c,d,e){var f=b>>>a&31,h=this.f[f];if(null==h)return new rf(null,this.m+1,pf(this.f,f,uf.Aa(a+5,b,c,d,e)));a=h.Aa(a+5,b,c,d,e);return a===h?this:new rf(null,this.m,pf(this.f,f,a))};g.Da=function(){return new vf(this.f,0,null)};function wf(a,b,c){b*=2;for(var d=0;;)if(da?d:of(c,this.f[a])?this.f[a+1]:d}; 2278 | g.Ba=function(a,b,c,d,e,f){if(c===this.Ka){b=wf(this.f,this.m,d);if(-1===b){if(this.f.length>2*this.m)return b=2*this.m,c=2*this.m+1,a=this.Ra(a),a.f[b]=d,a.f[c]=e,f.M=!0,a.m+=1,a;c=this.f.length;b=Array(c+2);md(this.f,0,b,0,c);b[c]=d;b[c+1]=e;f.M=!0;d=this.m+1;a===this.L?(this.f=b,this.m=d,a=this):a=new xf(this.L,this.Ka,d,b);return a}return this.f[b+1]===e?this:qf(this,a,b+1,e)}return(new tf(a,1<<(this.Ka>>>b&31),[null,this,null,null])).Ba(a,b,c,d,e,f)}; 2279 | g.Aa=function(a,b,c,d,e){return b===this.Ka?(a=wf(this.f,this.m,c),-1===a?(a=2*this.m,b=Array(a+2),md(this.f,0,b,0,a),b[a]=c,b[a+1]=d,e.M=!0,new xf(null,this.Ka,this.m+1,b)):ec.b(this.f[a],d)?this:new xf(null,this.Ka,this.m,pf(this.f,a+1,d))):(new tf(null,1<<(this.Ka>>>a&31),[null,this])).Aa(a,b,c,d,e)};g.Da=function(){return new sf(this.f,0,null,null)}; 2280 | var nf=function nf(b){for(var c=[],d=arguments.length,e=0;;)if(ethis.end};Kf.prototype.next=function(){var a=this.j;this.j+=this.step;return a};function Lf(a,b,c,d,e){this.v=a;this.start=b;this.end=c;this.step=d;this.s=e;this.i=32375006;this.B=8192}g=Lf.prototype;g.toString=function(){return Wb(this)}; 2317 | g.equiv=function(a){return this.w(null,a)};g.U=function(a,b){if(bthis.end&&0===this.step)return this.start;throw Error("Index out of bounds");};g.ta=function(a,b,c){return bthis.end&&0===this.step?this.start:c};g.Da=function(){return new Kf(this.start,this.end,this.step)};g.O=function(){return this.v}; 2318 | g.pa=function(){return 0this.end?new Lf(this.v,this.start+this.step,this.end,this.step,null):null};g.X=function(){return Na(xb(this))?0:Math.ceil((this.end-this.start)/this.step)};g.N=function(){var a=this.s;return null!=a?a:this.s=a=xc(this)};g.w=function(a,b){return Cc(this,b)};g.Y=function(a,b){return Hc(this,b)}; 2319 | g.Z=function(a,b,c){for(a=this.start;;)if(0this.end){c=b.b?b.b(c,a):b.call(null,c,a);if(Gc(c))return N.a?N.a(c):N.call(null,c);a+=this.step}else return c};g.$=function(){return null==xb(this)?null:this.start};g.qa=function(){return null!=xb(this)?new Lf(this.v,this.start+this.step,this.end,this.step,null):rc};g.S=function(){return 0this.step?this.start>this.end?this:null:this.start===this.end?null:this}; 2320 | g.R=function(a,b){return new Lf(b,this.start,this.end,this.step,this.s)};g.T=function(a,b){return O(b,this)};Lf.prototype[Pa]=function(){return tc(this)}; 2321 | function Mf(a,b){return function(){function c(c,d,e){return new U(null,2,5,V,[a.c?a.c(c,d,e):a.call(null,c,d,e),b.c?b.c(c,d,e):b.call(null,c,d,e)],null)}function d(c,d){return new U(null,2,5,V,[a.b?a.b(c,d):a.call(null,c,d),b.b?b.b(c,d):b.call(null,c,d)],null)}function e(c){return new U(null,2,5,V,[a.a?a.a(c):a.call(null,c),b.a?b.a(c):b.call(null,c)],null)}function f(){return new U(null,2,5,V,[a.u?a.u():a.call(null),b.u?b.u():b.call(null)],null)}var h=null,k=function(){function c(a,b,e,f){var h=null; 2322 | if(3wa)return Ab(a,"#");Ab(a,c);if(0===Ha.a(f))K(h)&&Ab(a,function(){var a=Nf.a(f);return y(a)?a:"..."}());else{if(K(h)){var l=L(h);b.c?b.c(l,a,f):b.call(null,l,a,f)}for(var m=M(h),n=Ha.a(f)-1;;)if(!m||null!=n&&0===n){K(m)&&0===n&&(Ab(a,d),Ab(a,function(){var a=Nf.a(f);return y(a)?a:"..."}()));break}else{Ab(a,d);var p=L(m);c=a;h=f;b.c?b.c(p,c,h):b.call(null,p,c,h);var q=M(m);c=n-1;m=q;n=c}}return Ab(a,e)}finally{wa=k}} 2325 | function Of(a,b){for(var c=K(b),d=null,e=0,f=0;;)if(fthis.head?(fh(this.f,this.I,a,0,this.f.length-this.I),fh(this.f,0,a,this.f.length-this.I,this.head),this.I=0,this.head=this.length,this.f=a):this.I===this.head?(this.head=this.I=0,this.f=a):null};if("undefined"===typeof hh)var hh={};var ih; 2381 | function jh(){var a=aa.MessageChannel;"undefined"===typeof a&&"undefined"!==typeof window&&window.postMessage&&window.addEventListener&&-1==ch.indexOf("Presto")&&(a=function(){var a=document.createElement("IFRAME");a.style.display="none";a.src="";document.documentElement.appendChild(a);var b=a.contentWindow,a=b.document;a.open();a.write("");a.close();var c="callImmediate"+Math.random(),d="file:"==b.location.protocol?"*":b.location.protocol+"//"+b.location.host,a=ma(function(a){if(("*"==d||a.origin== 2382 | d)&&a.data==c)this.port1.onmessage()},this);b.addEventListener("message",a,!1);this.port1={};this.port2={postMessage:function(){b.postMessage(c,d)}}});if("undefined"!==typeof a&&-1==ch.indexOf("Trident")&&-1==ch.indexOf("MSIE")){var b=new a,c={},d=c;b.port1.onmessage=function(){if(void 0!==c.next){c=c.next;var a=c.Fb;c.Fb=null;a()}};return function(a){d.next={Fb:a};d=d.next;b.port2.postMessage(0)}}return"undefined"!==typeof document&&"onreadystatechange"in document.createElement("SCRIPT")?function(a){var b= 2383 | document.createElement("SCRIPT");b.onreadystatechange=function(){b.onreadystatechange=null;b.parentNode.removeChild(b);b=null;a();a=null};document.documentElement.appendChild(b)}:function(a){aa.setTimeout(a,0)}};var kh;kh=new gh(0,0,0,Array(32));var lh=!1,mh=!1;nh;function oh(){lh=!0;mh=!1;for(var a=0;;){var b=kh.pop();if(null!=b&&(b.u?b.u():b.call(null),1024>a)){a+=1;continue}break}lh=!1;return 0=this.Na&&(this.Na+=2147483646);b&&this.install()}(function(){function a(){}a.prototype=Ah.prototype;Ch.Cc=Ah.prototype;Ch.prototype=new a;Ch.prototype.constructor=Ch;Ch.rb=function(a,c,d){for(var e=Array(arguments.length-2),f=2;f