bpmn-navigated-viewer.js 791 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376
  1. /*!
  2. * bpmn-js - bpmn-navigated-viewer v0.11.0
  3. * Copyright 2014, 2015 camunda Services GmbH and other contributors
  4. *
  5. * Released under the bpmn.io license
  6. * http://bpmn.io/license
  7. *
  8. * Source Code: https://github.com/bpmn-io/bpmn-js
  9. *
  10. * Date: 2015-08-06
  11. */
  12. !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.BpmnJS=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);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<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
  13. 'use strict';
  14. var inherits = _dereq_(81);
  15. var Viewer = _dereq_(2);
  16. /**
  17. * A viewer that includes mouse navigation facilities
  18. *
  19. * @param {Object} options
  20. */
  21. function NavigatedViewer(options) {
  22. Viewer.call(this, options);
  23. }
  24. inherits(NavigatedViewer, Viewer);
  25. module.exports = NavigatedViewer;
  26. NavigatedViewer.prototype._navigationModules = [
  27. _dereq_(62),
  28. _dereq_(59)
  29. ];
  30. NavigatedViewer.prototype._modules = [].concat(
  31. NavigatedViewer.prototype._modules,
  32. NavigatedViewer.prototype._navigationModules);
  33. },{"2":2,"59":59,"62":62,"81":81}],2:[function(_dereq_,module,exports){
  34. 'use strict';
  35. var assign = _dereq_(177),
  36. omit = _dereq_(181),
  37. isString = _dereq_(174),
  38. isNumber = _dereq_(171);
  39. var domify = _dereq_(190),
  40. domQuery = _dereq_(192),
  41. domRemove = _dereq_(193);
  42. var Diagram = _dereq_(36),
  43. BpmnModdle = _dereq_(15);
  44. var Importer = _dereq_(9);
  45. function initListeners(diagram, listeners) {
  46. var events = diagram.get('eventBus');
  47. listeners.forEach(function(l) {
  48. events.on(l.event, l.handler);
  49. });
  50. }
  51. function checkValidationError(err) {
  52. // check if we can help the user by indicating wrong BPMN 2.0 xml
  53. // (in case he or the exporting tool did not get that right)
  54. var pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/;
  55. var match = pattern.exec(err.message);
  56. if (match) {
  57. err.message =
  58. 'unparsable content <' + match[1] + '> detected; ' +
  59. 'this may indicate an invalid BPMN 2.0 diagram file' + match[2];
  60. }
  61. return err;
  62. }
  63. var DEFAULT_OPTIONS = {
  64. width: '100%',
  65. height: '100%',
  66. position: 'relative',
  67. container: 'body'
  68. };
  69. /**
  70. * Ensure the passed argument is a proper unit (defaulting to px)
  71. */
  72. function ensureUnit(val) {
  73. return val + (isNumber(val) ? 'px' : '');
  74. }
  75. /**
  76. * A viewer for BPMN 2.0 diagrams.
  77. *
  78. * Have a look at {@link NavigatedViewer} or {@link Modeler} for bundles that include
  79. * additional features.
  80. *
  81. *
  82. * ## Extending the Viewer
  83. *
  84. * In order to extend the viewer pass extension modules to bootstrap via the
  85. * `additionalModules` option. An extension module is an object that exposes
  86. * named services.
  87. *
  88. * The following example depicts the integration of a simple
  89. * logging component that integrates with interaction events:
  90. *
  91. *
  92. * ```javascript
  93. *
  94. * // logging component
  95. * function InteractionLogger(eventBus) {
  96. * eventBus.on('element.hover', function(event) {
  97. * console.log()
  98. * })
  99. * }
  100. *
  101. * InteractionLogger.$inject = [ 'eventBus' ]; // minification save
  102. *
  103. * // extension module
  104. * var extensionModule = {
  105. * __init__: [ 'interactionLogger' ],
  106. * interactionLogger: [ 'type', InteractionLogger ]
  107. * };
  108. *
  109. * // extend the viewer
  110. * var bpmnViewer = new Viewer({ additionalModules: [ extensionModule ] });
  111. * bpmnViewer.importXML(...);
  112. * ```
  113. *
  114. * @param {Object} [options] configuration options to pass to the viewer
  115. * @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
  116. * @param {String|Number} [options.width] the width of the viewer
  117. * @param {String|Number} [options.height] the height of the viewer
  118. * @param {Object} [options.moddleExtensions] extension packages to provide
  119. * @param {Array<didi.Module>} [options.modules] a list of modules to override the default modules
  120. * @param {Array<didi.Module>} [options.additionalModules] a list of modules to use with the default modules
  121. */
  122. function Viewer(options) {
  123. this.options = options = assign({}, DEFAULT_OPTIONS, options || {});
  124. var parent = options.container;
  125. // support jquery element
  126. // unwrap it if passed
  127. if (parent.get) {
  128. parent = parent.get(0);
  129. }
  130. // support selector
  131. if (isString(parent)) {
  132. parent = domQuery(parent);
  133. }
  134. var container = this.container = domify('<div class="bjs-container"></div>');
  135. parent.appendChild(container);
  136. assign(container.style, {
  137. width: ensureUnit(options.width),
  138. height: ensureUnit(options.height),
  139. position: options.position
  140. });
  141. /**
  142. * The code in the <project-logo></project-logo> area
  143. * must not be changed, see http://bpmn.io/license for more information
  144. *
  145. * <project-logo>
  146. */
  147. /* jshint -W101 */
  148. // inlined ../resources/bpmnjs.png
  149. var logoData = 'iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAMAAADypuvZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADBQTFRFiMte9PrwldFwfcZPqtqN0+zEyOe1XLgjvuKncsJAZ70y6fXh3vDT////UrQV////G2zN+AAAABB0Uk5T////////////////////AOAjXRkAAAHDSURBVHjavJZJkoUgDEBJmAX8979tM8u3E6x20VlYJfFFMoL4vBDxATxZcakIOJTWSmxvKWVIkJ8jHvlRv1F2LFrVISCZI+tCtQx+XfewgVTfyY3plPiQEAzI3zWy+kR6NBhFBYeBuscJLOUuA2WVLpCjVIaFzrNQZArxAZKUQm6gsj37L9Cb7dnIBUKxENaaMJQqMpDXvSL+ktxdGRm2IsKgJGGPg7atwUG5CcFUEuSv+CwQqizTrvDTNXdMU2bMiDWZd8d7QIySWVRsb2vBBioxOFt4OinPBapL+neAb5KL5IJ8szOza2/DYoipUCx+CjO0Bpsv0V6mktNZ+k8rlABlWG0FrOpKYVo8DT3dBeLEjUBAj7moDogVii7nSS9QzZnFcOVBp1g2PyBQ3Vr5aIapN91VJy33HTJLC1iX2FY6F8gRdaAeIEfVONgtFCzZTmoLEdOjBDfsIOA6128gw3eu1shAajdZNAORxuQDJN5A5PbEG6gNIu24QJD5iNyRMZIr6bsHbCtCU/OaOaSvgkUyDMdDa1BXGf5HJ1To+/Ym6mCKT02Y+/Sa126ZKyd3jxhzpc1r8zVL6YM1Qy/kR4ABAFJ6iQUnivhAAAAAAElFTkSuQmCC';
  150. /* jshint +W101 */
  151. var linkMarkup =
  152. '<a href="http://bpmn.io" ' +
  153. 'target="_blank" ' +
  154. 'class="bjs-powered-by" ' +
  155. 'title="Powered by bpmn.io" ' +
  156. 'style="position: absolute; bottom: 15px; right: 15px; z-index: 100">' +
  157. '<img src="data:image/png;base64,' + logoData + '">' +
  158. '</a>';
  159. container.appendChild(domify(linkMarkup));
  160. /* </project-logo> */
  161. }
  162. Viewer.prototype.importXML = function(xml, done) {
  163. var self = this;
  164. this.moddle = this.createModdle();
  165. this.moddle.fromXML(xml, 'bpmn:Definitions', function(err, definitions, context) {
  166. if (err) {
  167. err = checkValidationError(err);
  168. return done(err);
  169. }
  170. var parseWarnings = context.warnings;
  171. self.importDefinitions(definitions, function(err, importWarnings) {
  172. if (err) {
  173. return done(err);
  174. }
  175. done(null, parseWarnings.concat(importWarnings || []));
  176. });
  177. });
  178. };
  179. Viewer.prototype.saveXML = function(options, done) {
  180. if (!done) {
  181. done = options;
  182. options = {};
  183. }
  184. var definitions = this.definitions;
  185. if (!definitions) {
  186. return done(new Error('no definitions loaded'));
  187. }
  188. this.moddle.toXML(definitions, options, done);
  189. };
  190. Viewer.prototype.createModdle = function() {
  191. return new BpmnModdle(this.options.moddleExtensions);
  192. };
  193. Viewer.prototype.saveSVG = function(options, done) {
  194. if (!done) {
  195. done = options;
  196. options = {};
  197. }
  198. var canvas = this.get('canvas');
  199. var contentNode = canvas.getDefaultLayer(),
  200. defsNode = canvas._svg.select('defs');
  201. var contents = contentNode.innerSVG(),
  202. defs = (defsNode && defsNode.outerSVG()) || '';
  203. var bbox = contentNode.getBBox();
  204. var svg =
  205. '<?xml version="1.0" encoding="utf-8"?>\n' +
  206. '<!-- created with bpmn-js / http://bpmn.io -->\n' +
  207. '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
  208. '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
  209. 'width="' + bbox.width + '" height="' + bbox.height + '" ' +
  210. 'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' +
  211. defs + contents +
  212. '</svg>';
  213. done(null, svg);
  214. };
  215. Viewer.prototype.get = function(name) {
  216. if (!this.diagram) {
  217. throw new Error('no diagram loaded');
  218. }
  219. return this.diagram.get(name);
  220. };
  221. Viewer.prototype.invoke = function(fn) {
  222. if (!this.diagram) {
  223. throw new Error('no diagram loaded');
  224. }
  225. return this.diagram.invoke(fn);
  226. };
  227. Viewer.prototype.importDefinitions = function(definitions, done) {
  228. // use try/catch to not swallow synchronous exceptions
  229. // that may be raised during model parsing
  230. try {
  231. if (this.diagram) {
  232. this.clear();
  233. }
  234. this.definitions = definitions;
  235. var diagram = this.diagram = this._createDiagram(this.options);
  236. this._init(diagram);
  237. Importer.importBpmnDiagram(diagram, definitions, done);
  238. } catch (e) {
  239. done(e);
  240. }
  241. };
  242. Viewer.prototype._init = function(diagram) {
  243. initListeners(diagram, this.__listeners || []);
  244. };
  245. Viewer.prototype._createDiagram = function(options) {
  246. var modules = [].concat(options.modules || this.getModules(), options.additionalModules || []);
  247. // add self as an available service
  248. modules.unshift({
  249. bpmnjs: [ 'value', this ],
  250. moddle: [ 'value', this.moddle ]
  251. });
  252. options = omit(options, 'additionalModules');
  253. options = assign(options, {
  254. canvas: { container: this.container },
  255. modules: modules
  256. });
  257. return new Diagram(options);
  258. };
  259. Viewer.prototype.getModules = function() {
  260. return this._modules;
  261. };
  262. /**
  263. * Remove all drawn elements from the viewer.
  264. *
  265. * After calling this method the viewer can still
  266. * be reused for opening another diagram.
  267. */
  268. Viewer.prototype.clear = function() {
  269. var diagram = this.diagram;
  270. if (diagram) {
  271. diagram.destroy();
  272. }
  273. };
  274. /**
  275. * Destroy the viewer instance and remove all its remainders
  276. * from the document tree.
  277. */
  278. Viewer.prototype.destroy = function() {
  279. // clear underlying diagram
  280. this.clear();
  281. // remove container
  282. domRemove(this.container);
  283. };
  284. /**
  285. * Register an event listener on the viewer
  286. *
  287. * @param {String} event
  288. * @param {Function} handler
  289. */
  290. Viewer.prototype.on = function(event, handler) {
  291. var diagram = this.diagram,
  292. listeners = this.__listeners = this.__listeners || [];
  293. listeners.push({ event: event, handler: handler });
  294. if (diagram) {
  295. diagram.get('eventBus').on(event, handler);
  296. }
  297. };
  298. // modules the viewer is composed of
  299. Viewer.prototype._modules = [
  300. _dereq_(3),
  301. _dereq_(56),
  302. _dereq_(52)
  303. ];
  304. module.exports = Viewer;
  305. },{"15":15,"171":171,"174":174,"177":177,"181":181,"190":190,"192":192,"193":193,"3":3,"36":36,"52":52,"56":56,"9":9}],3:[function(_dereq_,module,exports){
  306. module.exports = {
  307. __depends__: [
  308. _dereq_(6),
  309. _dereq_(11)
  310. ]
  311. };
  312. },{"11":11,"6":6}],4:[function(_dereq_,module,exports){
  313. 'use strict';
  314. var inherits = _dereq_(81),
  315. isArray = _dereq_(168),
  316. isObject = _dereq_(172),
  317. assign = _dereq_(177),
  318. forEach = _dereq_(86),
  319. every = _dereq_(83),
  320. includes = _dereq_(88),
  321. some = _dereq_(91);
  322. var DefaultRenderer = _dereq_(44),
  323. TextUtil = _dereq_(73),
  324. DiUtil = _dereq_(12);
  325. var createLine = DefaultRenderer.createLine;
  326. function BpmnRenderer(events, styles, pathMap) {
  327. DefaultRenderer.call(this, styles);
  328. var TASK_BORDER_RADIUS = 10;
  329. var INNER_OUTER_DIST = 3;
  330. var LABEL_STYLE = {
  331. fontFamily: 'Arial, sans-serif',
  332. fontSize: '12px'
  333. };
  334. var textUtil = new TextUtil({
  335. style: LABEL_STYLE,
  336. size: { width: 100 }
  337. });
  338. var markers = {};
  339. function addMarker(id, element) {
  340. markers[id] = element;
  341. }
  342. function marker(id) {
  343. return markers[id];
  344. }
  345. function initMarkers(svg) {
  346. function createMarker(id, options) {
  347. var attrs = assign({
  348. fill: 'black',
  349. strokeWidth: 1,
  350. strokeLinecap: 'round',
  351. strokeDasharray: 'none'
  352. }, options.attrs);
  353. var ref = options.ref || { x: 0, y: 0 };
  354. var scale = options.scale || 1;
  355. // fix for safari / chrome / firefox bug not correctly
  356. // resetting stroke dash array
  357. if (attrs.strokeDasharray === 'none') {
  358. attrs.strokeDasharray = [10000, 1];
  359. }
  360. var marker = options.element
  361. .attr(attrs)
  362. .marker(0, 0, 20, 20, ref.x, ref.y)
  363. .attr({
  364. markerWidth: 20 * scale,
  365. markerHeight: 20 * scale
  366. });
  367. return addMarker(id, marker);
  368. }
  369. createMarker('sequenceflow-end', {
  370. element: svg.path('M 1 5 L 11 10 L 1 15 Z'),
  371. ref: { x: 11, y: 10 },
  372. scale: 0.5
  373. });
  374. createMarker('messageflow-start', {
  375. element: svg.circle(6, 6, 3.5),
  376. attrs: {
  377. fill: 'white',
  378. stroke: 'black'
  379. },
  380. ref: { x: 6, y: 6 }
  381. });
  382. createMarker('messageflow-end', {
  383. element: svg.path('m 1 5 l 0 -3 l 7 3 l -7 3 z'),
  384. attrs: {
  385. fill: 'white',
  386. stroke: 'black',
  387. strokeLinecap: 'butt'
  388. },
  389. ref: { x: 8.5, y: 5 }
  390. });
  391. createMarker('data-association-end', {
  392. element: svg.path('M 1 5 L 11 10 L 1 15'),
  393. attrs: {
  394. fill: 'white',
  395. stroke: 'black'
  396. },
  397. ref: { x: 11, y: 10 },
  398. scale: 0.5
  399. });
  400. createMarker('conditional-flow-marker', {
  401. element: svg.path('M 0 10 L 8 6 L 16 10 L 8 14 Z'),
  402. attrs: {
  403. fill: 'white',
  404. stroke: 'black'
  405. },
  406. ref: { x: -1, y: 10 },
  407. scale: 0.5
  408. });
  409. createMarker('conditional-default-flow-marker', {
  410. element: svg.path('M 1 4 L 5 16'),
  411. attrs: {
  412. stroke: 'black'
  413. },
  414. ref: { x: -5, y: 10 },
  415. scale: 0.5
  416. });
  417. }
  418. function computeStyle(custom, traits, defaultStyles) {
  419. if (!isArray(traits)) {
  420. defaultStyles = traits;
  421. traits = [];
  422. }
  423. return styles.style(traits || [], assign(defaultStyles, custom || {}));
  424. }
  425. function drawCircle(p, width, height, offset, attrs) {
  426. if (isObject(offset)) {
  427. attrs = offset;
  428. offset = 0;
  429. }
  430. offset = offset || 0;
  431. attrs = computeStyle(attrs, {
  432. stroke: 'black',
  433. strokeWidth: 2,
  434. fill: 'white'
  435. });
  436. var cx = width / 2,
  437. cy = height / 2;
  438. return p.circle(cx, cy, Math.round((width + height) / 4 - offset)).attr(attrs);
  439. }
  440. function drawRect(p, width, height, r, offset, attrs) {
  441. if (isObject(offset)) {
  442. attrs = offset;
  443. offset = 0;
  444. }
  445. offset = offset || 0;
  446. attrs = computeStyle(attrs, {
  447. stroke: 'black',
  448. strokeWidth: 2,
  449. fill: 'white'
  450. });
  451. return p.rect(offset, offset, width - offset * 2, height - offset * 2, r).attr(attrs);
  452. }
  453. function drawDiamond(p, width, height, attrs) {
  454. var x_2 = width / 2;
  455. var y_2 = height / 2;
  456. var points = [x_2, 0, width, y_2, x_2, height, 0, y_2 ];
  457. attrs = computeStyle(attrs, {
  458. stroke: 'black',
  459. strokeWidth: 2,
  460. fill: 'white'
  461. });
  462. return p.polygon(points).attr(attrs);
  463. }
  464. function drawLine(p, waypoints, attrs) {
  465. attrs = computeStyle(attrs, [ 'no-fill' ], {
  466. stroke: 'black',
  467. strokeWidth: 2,
  468. fill: 'none'
  469. });
  470. return createLine(waypoints, attrs).appendTo(p);
  471. }
  472. function drawPath(p, d, attrs) {
  473. attrs = computeStyle(attrs, [ 'no-fill' ], {
  474. strokeWidth: 2,
  475. stroke: 'black'
  476. });
  477. return p.path(d).attr(attrs);
  478. }
  479. function as(type) {
  480. return function(p, element) {
  481. return handlers[type](p, element);
  482. };
  483. }
  484. function renderer(type) {
  485. return handlers[type];
  486. }
  487. function renderEventContent(element, p) {
  488. var event = getSemantic(element);
  489. var isThrowing = isThrowEvent(event);
  490. if (isTypedEvent(event, 'bpmn:MessageEventDefinition')) {
  491. return renderer('bpmn:MessageEventDefinition')(p, element, isThrowing);
  492. }
  493. if (isTypedEvent(event, 'bpmn:TimerEventDefinition')) {
  494. return renderer('bpmn:TimerEventDefinition')(p, element, isThrowing);
  495. }
  496. if (isTypedEvent(event, 'bpmn:ConditionalEventDefinition')) {
  497. return renderer('bpmn:ConditionalEventDefinition')(p, element);
  498. }
  499. if (isTypedEvent(event, 'bpmn:SignalEventDefinition')) {
  500. return renderer('bpmn:SignalEventDefinition')(p, element, isThrowing);
  501. }
  502. if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
  503. isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: false })) {
  504. return renderer('bpmn:MultipleEventDefinition')(p, element, isThrowing);
  505. }
  506. if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
  507. isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: true })) {
  508. return renderer('bpmn:ParallelMultipleEventDefinition')(p, element, isThrowing);
  509. }
  510. if (isTypedEvent(event, 'bpmn:EscalationEventDefinition')) {
  511. return renderer('bpmn:EscalationEventDefinition')(p, element, isThrowing);
  512. }
  513. if (isTypedEvent(event, 'bpmn:LinkEventDefinition')) {
  514. return renderer('bpmn:LinkEventDefinition')(p, element, isThrowing);
  515. }
  516. if (isTypedEvent(event, 'bpmn:ErrorEventDefinition')) {
  517. return renderer('bpmn:ErrorEventDefinition')(p, element, isThrowing);
  518. }
  519. if (isTypedEvent(event, 'bpmn:CancelEventDefinition')) {
  520. return renderer('bpmn:CancelEventDefinition')(p, element, isThrowing);
  521. }
  522. if (isTypedEvent(event, 'bpmn:CompensateEventDefinition')) {
  523. return renderer('bpmn:CompensateEventDefinition')(p, element, isThrowing);
  524. }
  525. if (isTypedEvent(event, 'bpmn:TerminateEventDefinition')) {
  526. return renderer('bpmn:TerminateEventDefinition')(p, element, isThrowing);
  527. }
  528. return null;
  529. }
  530. function renderLabel(p, label, options) {
  531. return textUtil.createText(p, label || '', options).addClass('djs-label');
  532. }
  533. function renderEmbeddedLabel(p, element, align) {
  534. var semantic = getSemantic(element);
  535. return renderLabel(p, semantic.name, { box: element, align: align, padding: 5 });
  536. }
  537. function renderExternalLabel(p, element, align) {
  538. var semantic = getSemantic(element);
  539. if (!semantic.name) {
  540. element.hidden = true;
  541. }
  542. return renderLabel(p, semantic.name, { box: element, align: align, style: { fontSize: '11px' } });
  543. }
  544. function renderLaneLabel(p, text, element) {
  545. var textBox = renderLabel(p, text, {
  546. box: { height: 30, width: element.height },
  547. align: 'center-middle'
  548. });
  549. var top = -1 * element.height;
  550. textBox.transform(
  551. 'rotate(270) ' +
  552. 'translate(' + top + ',' + 0 + ')'
  553. );
  554. }
  555. function createPathFromConnection(connection) {
  556. var waypoints = connection.waypoints;
  557. var pathData = 'm ' + waypoints[0].x + ',' + waypoints[0].y;
  558. for (var i = 1; i < waypoints.length; i++) {
  559. pathData += 'L' + waypoints[i].x + ',' + waypoints[i].y + ' ';
  560. }
  561. return pathData;
  562. }
  563. var handlers = {
  564. 'bpmn:Event': function(p, element, attrs) {
  565. return drawCircle(p, element.width, element.height, attrs);
  566. },
  567. 'bpmn:StartEvent': function(p, element) {
  568. var attrs = {};
  569. var semantic = getSemantic(element);
  570. if (!semantic.isInterrupting) {
  571. attrs = {
  572. strokeDasharray: '6',
  573. strokeLinecap: 'round'
  574. };
  575. }
  576. var circle = renderer('bpmn:Event')(p, element, attrs);
  577. renderEventContent(element, p);
  578. return circle;
  579. },
  580. 'bpmn:MessageEventDefinition': function(p, element, isThrowing) {
  581. var pathData = pathMap.getScaledPath('EVENT_MESSAGE', {
  582. xScaleFactor: 0.9,
  583. yScaleFactor: 0.9,
  584. containerWidth: element.width,
  585. containerHeight: element.height,
  586. position: {
  587. mx: 0.235,
  588. my: 0.315
  589. }
  590. });
  591. var fill = isThrowing ? 'black' : 'white';
  592. var stroke = isThrowing ? 'white' : 'black';
  593. var messagePath = drawPath(p, pathData, {
  594. strokeWidth: 1,
  595. fill: fill,
  596. stroke: stroke
  597. });
  598. return messagePath;
  599. },
  600. 'bpmn:TimerEventDefinition': function(p, element) {
  601. var circle = drawCircle(p, element.width, element.height, 0.2 * element.height, {
  602. strokeWidth: 2
  603. });
  604. var pathData = pathMap.getScaledPath('EVENT_TIMER_WH', {
  605. xScaleFactor: 0.75,
  606. yScaleFactor: 0.75,
  607. containerWidth: element.width,
  608. containerHeight: element.height,
  609. position: {
  610. mx: 0.5,
  611. my: 0.5
  612. }
  613. });
  614. drawPath(p, pathData, {
  615. strokeWidth: 2,
  616. strokeLinecap: 'square'
  617. });
  618. for(var i = 0;i < 12;i++) {
  619. var linePathData = pathMap.getScaledPath('EVENT_TIMER_LINE', {
  620. xScaleFactor: 0.75,
  621. yScaleFactor: 0.75,
  622. containerWidth: element.width,
  623. containerHeight: element.height,
  624. position: {
  625. mx: 0.5,
  626. my: 0.5
  627. }
  628. });
  629. var width = element.width / 2;
  630. var height = element.height / 2;
  631. drawPath(p, linePathData, {
  632. strokeWidth: 1,
  633. strokeLinecap: 'square',
  634. transform: 'rotate(' + (i * 30) + ',' + height + ',' + width + ')'
  635. });
  636. }
  637. return circle;
  638. },
  639. 'bpmn:EscalationEventDefinition': function(p, event, isThrowing) {
  640. var pathData = pathMap.getScaledPath('EVENT_ESCALATION', {
  641. xScaleFactor: 1,
  642. yScaleFactor: 1,
  643. containerWidth: event.width,
  644. containerHeight: event.height,
  645. position: {
  646. mx: 0.5,
  647. my: 0.555
  648. }
  649. });
  650. var fill = isThrowing ? 'black' : 'none';
  651. return drawPath(p, pathData, {
  652. strokeWidth: 1,
  653. fill: fill
  654. });
  655. },
  656. 'bpmn:ConditionalEventDefinition': function(p, event) {
  657. var pathData = pathMap.getScaledPath('EVENT_CONDITIONAL', {
  658. xScaleFactor: 1,
  659. yScaleFactor: 1,
  660. containerWidth: event.width,
  661. containerHeight: event.height,
  662. position: {
  663. mx: 0.5,
  664. my: 0.222
  665. }
  666. });
  667. return drawPath(p, pathData, {
  668. strokeWidth: 1
  669. });
  670. },
  671. 'bpmn:LinkEventDefinition': function(p, event, isThrowing) {
  672. var pathData = pathMap.getScaledPath('EVENT_LINK', {
  673. xScaleFactor: 1,
  674. yScaleFactor: 1,
  675. containerWidth: event.width,
  676. containerHeight: event.height,
  677. position: {
  678. mx: 0.57,
  679. my: 0.263
  680. }
  681. });
  682. var fill = isThrowing ? 'black' : 'none';
  683. return drawPath(p, pathData, {
  684. strokeWidth: 1,
  685. fill: fill
  686. });
  687. },
  688. 'bpmn:ErrorEventDefinition': function(p, event, isThrowing) {
  689. var pathData = pathMap.getScaledPath('EVENT_ERROR', {
  690. xScaleFactor: 1.1,
  691. yScaleFactor: 1.1,
  692. containerWidth: event.width,
  693. containerHeight: event.height,
  694. position: {
  695. mx: 0.2,
  696. my: 0.722
  697. }
  698. });
  699. var fill = isThrowing ? 'black' : 'none';
  700. return drawPath(p, pathData, {
  701. strokeWidth: 1,
  702. fill: fill
  703. });
  704. },
  705. 'bpmn:CancelEventDefinition': function(p, event, isThrowing) {
  706. var pathData = pathMap.getScaledPath('EVENT_CANCEL_45', {
  707. xScaleFactor: 1.0,
  708. yScaleFactor: 1.0,
  709. containerWidth: event.width,
  710. containerHeight: event.height,
  711. position: {
  712. mx: 0.638,
  713. my: -0.055
  714. }
  715. });
  716. var fill = isThrowing ? 'black' : 'none';
  717. return drawPath(p, pathData, {
  718. strokeWidth: 1,
  719. fill: fill
  720. }).transform('rotate(45)');
  721. },
  722. 'bpmn:CompensateEventDefinition': function(p, event, isThrowing) {
  723. var pathData = pathMap.getScaledPath('EVENT_COMPENSATION', {
  724. xScaleFactor: 1,
  725. yScaleFactor: 1,
  726. containerWidth: event.width,
  727. containerHeight: event.height,
  728. position: {
  729. mx: 0.201,
  730. my: 0.472
  731. }
  732. });
  733. var fill = isThrowing ? 'black' : 'none';
  734. return drawPath(p, pathData, {
  735. strokeWidth: 1,
  736. fill: fill
  737. });
  738. },
  739. 'bpmn:SignalEventDefinition': function(p, event, isThrowing) {
  740. var pathData = pathMap.getScaledPath('EVENT_SIGNAL', {
  741. xScaleFactor: 0.9,
  742. yScaleFactor: 0.9,
  743. containerWidth: event.width,
  744. containerHeight: event.height,
  745. position: {
  746. mx: 0.5,
  747. my: 0.2
  748. }
  749. });
  750. var fill = isThrowing ? 'black' : 'none';
  751. return drawPath(p, pathData, {
  752. strokeWidth: 1,
  753. fill: fill
  754. });
  755. },
  756. 'bpmn:MultipleEventDefinition': function(p, event, isThrowing) {
  757. var pathData = pathMap.getScaledPath('EVENT_MULTIPLE', {
  758. xScaleFactor: 1.1,
  759. yScaleFactor: 1.1,
  760. containerWidth: event.width,
  761. containerHeight: event.height,
  762. position: {
  763. mx: 0.222,
  764. my: 0.36
  765. }
  766. });
  767. var fill = isThrowing ? 'black' : 'none';
  768. return drawPath(p, pathData, {
  769. strokeWidth: 1,
  770. fill: fill
  771. });
  772. },
  773. 'bpmn:ParallelMultipleEventDefinition': function(p, event) {
  774. var pathData = pathMap.getScaledPath('EVENT_PARALLEL_MULTIPLE', {
  775. xScaleFactor: 1.2,
  776. yScaleFactor: 1.2,
  777. containerWidth: event.width,
  778. containerHeight: event.height,
  779. position: {
  780. mx: 0.458,
  781. my: 0.194
  782. }
  783. });
  784. return drawPath(p, pathData, {
  785. strokeWidth: 1
  786. });
  787. },
  788. 'bpmn:EndEvent': function(p, element) {
  789. var circle = renderer('bpmn:Event')(p, element, {
  790. strokeWidth: 4
  791. });
  792. renderEventContent(element, p, true);
  793. return circle;
  794. },
  795. 'bpmn:TerminateEventDefinition': function(p, element) {
  796. var circle = drawCircle(p, element.width, element.height, 8, {
  797. strokeWidth: 4,
  798. fill: 'black'
  799. });
  800. return circle;
  801. },
  802. 'bpmn:IntermediateEvent': function(p, element) {
  803. var outer = renderer('bpmn:Event')(p, element, { strokeWidth: 1 });
  804. /* inner */ drawCircle(p, element.width, element.height, INNER_OUTER_DIST, { strokeWidth: 1, fill: 'none' });
  805. renderEventContent(element, p);
  806. return outer;
  807. },
  808. 'bpmn:IntermediateCatchEvent': as('bpmn:IntermediateEvent'),
  809. 'bpmn:IntermediateThrowEvent': as('bpmn:IntermediateEvent'),
  810. 'bpmn:Activity': function(p, element, attrs) {
  811. return drawRect(p, element.width, element.height, TASK_BORDER_RADIUS, attrs);
  812. },
  813. 'bpmn:Task': function(p, element, attrs) {
  814. var rect = renderer('bpmn:Activity')(p, element, attrs);
  815. renderEmbeddedLabel(p, element, 'center-middle');
  816. attachTaskMarkers(p, element);
  817. return rect;
  818. },
  819. 'bpmn:ServiceTask': function(p, element) {
  820. var task = renderer('bpmn:Task')(p, element);
  821. var pathDataBG = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
  822. abspos: {
  823. x: 12,
  824. y: 18
  825. }
  826. });
  827. /* service bg */ drawPath(p, pathDataBG, {
  828. strokeWidth: 1,
  829. fill: 'none'
  830. });
  831. var fillPathData = pathMap.getScaledPath('TASK_TYPE_SERVICE_FILL', {
  832. abspos: {
  833. x: 17.2,
  834. y: 18
  835. }
  836. });
  837. /* service fill */ drawPath(p, fillPathData, {
  838. strokeWidth: 0,
  839. stroke: 'none',
  840. fill: 'white'
  841. });
  842. var pathData = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
  843. abspos: {
  844. x: 17,
  845. y: 22
  846. }
  847. });
  848. /* service */ drawPath(p, pathData, {
  849. strokeWidth: 1,
  850. fill: 'white'
  851. });
  852. return task;
  853. },
  854. 'bpmn:UserTask': function(p, element) {
  855. var task = renderer('bpmn:Task')(p, element);
  856. var x = 15;
  857. var y = 12;
  858. var pathData = pathMap.getScaledPath('TASK_TYPE_USER_1', {
  859. abspos: {
  860. x: x,
  861. y: y
  862. }
  863. });
  864. /* user path */ drawPath(p, pathData, {
  865. strokeWidth: 0.5,
  866. fill: 'none'
  867. });
  868. var pathData2 = pathMap.getScaledPath('TASK_TYPE_USER_2', {
  869. abspos: {
  870. x: x,
  871. y: y
  872. }
  873. });
  874. /* user2 path */ drawPath(p, pathData2, {
  875. strokeWidth: 0.5,
  876. fill: 'none'
  877. });
  878. var pathData3 = pathMap.getScaledPath('TASK_TYPE_USER_3', {
  879. abspos: {
  880. x: x,
  881. y: y
  882. }
  883. });
  884. /* user3 path */ drawPath(p, pathData3, {
  885. strokeWidth: 0.5,
  886. fill: 'black'
  887. });
  888. return task;
  889. },
  890. 'bpmn:ManualTask': function(p, element) {
  891. var task = renderer('bpmn:Task')(p, element);
  892. var pathData = pathMap.getScaledPath('TASK_TYPE_MANUAL', {
  893. abspos: {
  894. x: 17,
  895. y: 15
  896. }
  897. });
  898. /* manual path */ drawPath(p, pathData, {
  899. strokeWidth: 0.25,
  900. fill: 'white',
  901. stroke: 'black'
  902. });
  903. return task;
  904. },
  905. 'bpmn:SendTask': function(p, element) {
  906. var task = renderer('bpmn:Task')(p, element);
  907. var pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
  908. xScaleFactor: 1,
  909. yScaleFactor: 1,
  910. containerWidth: 21,
  911. containerHeight: 14,
  912. position: {
  913. mx: 0.285,
  914. my: 0.357
  915. }
  916. });
  917. /* send path */ drawPath(p, pathData, {
  918. strokeWidth: 1,
  919. fill: 'black',
  920. stroke: 'white'
  921. });
  922. return task;
  923. },
  924. 'bpmn:ReceiveTask' : function(p, element) {
  925. var semantic = getSemantic(element);
  926. var task = renderer('bpmn:Task')(p, element);
  927. var pathData;
  928. if (semantic.instantiate) {
  929. drawCircle(p, 28, 28, 20 * 0.22, { strokeWidth: 1 });
  930. pathData = pathMap.getScaledPath('TASK_TYPE_INSTANTIATING_SEND', {
  931. abspos: {
  932. x: 7.77,
  933. y: 9.52
  934. }
  935. });
  936. } else {
  937. pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
  938. xScaleFactor: 0.9,
  939. yScaleFactor: 0.9,
  940. containerWidth: 21,
  941. containerHeight: 14,
  942. position: {
  943. mx: 0.3,
  944. my: 0.4
  945. }
  946. });
  947. }
  948. /* receive path */ drawPath(p, pathData, {
  949. strokeWidth: 1
  950. });
  951. return task;
  952. },
  953. 'bpmn:ScriptTask': function(p, element) {
  954. var task = renderer('bpmn:Task')(p, element);
  955. var pathData = pathMap.getScaledPath('TASK_TYPE_SCRIPT', {
  956. abspos: {
  957. x: 15,
  958. y: 20
  959. }
  960. });
  961. /* script path */ drawPath(p, pathData, {
  962. strokeWidth: 1
  963. });
  964. return task;
  965. },
  966. 'bpmn:BusinessRuleTask': function(p, element) {
  967. var task = renderer('bpmn:Task')(p, element);
  968. var headerPathData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_HEADER', {
  969. abspos: {
  970. x: 8,
  971. y: 8
  972. }
  973. });
  974. var businessHeaderPath = drawPath(p, headerPathData);
  975. businessHeaderPath.attr({
  976. strokeWidth: 1,
  977. fill: 'AAA'
  978. });
  979. var headerData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_MAIN', {
  980. abspos: {
  981. x: 8,
  982. y: 8
  983. }
  984. });
  985. var businessPath = drawPath(p, headerData);
  986. businessPath.attr({
  987. strokeWidth: 1
  988. });
  989. return task;
  990. },
  991. 'bpmn:SubProcess': function(p, element, attrs) {
  992. var rect = renderer('bpmn:Activity')(p, element, attrs);
  993. var semantic = getSemantic(element);
  994. var expanded = DiUtil.isExpanded(semantic);
  995. var isEventSubProcess = !!semantic.triggeredByEvent;
  996. if (isEventSubProcess) {
  997. rect.attr({
  998. strokeDasharray: '1,2'
  999. });
  1000. }
  1001. renderEmbeddedLabel(p, element, expanded ? 'center-top' : 'center-middle');
  1002. if (expanded) {
  1003. attachTaskMarkers(p, element);
  1004. } else {
  1005. attachTaskMarkers(p, element, ['SubProcessMarker']);
  1006. }
  1007. return rect;
  1008. },
  1009. 'bpmn:AdHocSubProcess': function(p, element) {
  1010. return renderer('bpmn:SubProcess')(p, element);
  1011. },
  1012. 'bpmn:Transaction': function(p, element) {
  1013. var outer = renderer('bpmn:SubProcess')(p, element);
  1014. var innerAttrs = styles.style([ 'no-fill', 'no-events' ]);
  1015. /* inner path */ drawRect(p, element.width, element.height, TASK_BORDER_RADIUS - 2, INNER_OUTER_DIST, innerAttrs);
  1016. return outer;
  1017. },
  1018. 'bpmn:CallActivity': function(p, element) {
  1019. return renderer('bpmn:Task')(p, element, {
  1020. strokeWidth: 5
  1021. });
  1022. },
  1023. 'bpmn:Participant': function(p, element) {
  1024. var lane = renderer('bpmn:Lane')(p, element, {
  1025. fill: 'White'
  1026. });
  1027. var expandedPool = DiUtil.isExpanded(element);
  1028. if (expandedPool) {
  1029. drawLine(p, [
  1030. { x: 30, y: 0 },
  1031. { x: 30, y: element.height }
  1032. ]);
  1033. var text = getSemantic(element).name;
  1034. renderLaneLabel(p, text, element);
  1035. } else {
  1036. // Collapsed pool draw text inline
  1037. var text2 = getSemantic(element).name;
  1038. renderLabel(p, text2, { box: element, align: 'center-middle' });
  1039. }
  1040. var participantMultiplicity = !!(getSemantic(element).participantMultiplicity);
  1041. if(participantMultiplicity) {
  1042. renderer('ParticipantMultiplicityMarker')(p, element);
  1043. }
  1044. return lane;
  1045. },
  1046. 'bpmn:Lane': function(p, element, attrs) {
  1047. var rect = drawRect(p, element.width, element.height, 0, attrs || {
  1048. fill: 'none'
  1049. });
  1050. var semantic = getSemantic(element);
  1051. if (semantic.$type === 'bpmn:Lane') {
  1052. var text = semantic.name;
  1053. renderLaneLabel(p, text, element);
  1054. }
  1055. return rect;
  1056. },
  1057. 'bpmn:InclusiveGateway': function(p, element) {
  1058. var diamond = drawDiamond(p, element.width, element.height);
  1059. /* circle path */
  1060. drawCircle(p, element.width, element.height, element.height * 0.24, {
  1061. strokeWidth: 2.5,
  1062. fill: 'none'
  1063. });
  1064. return diamond;
  1065. },
  1066. 'bpmn:ExclusiveGateway': function(p, element) {
  1067. var diamond = drawDiamond(p, element.width, element.height);
  1068. var pathData = pathMap.getScaledPath('GATEWAY_EXCLUSIVE', {
  1069. xScaleFactor: 0.4,
  1070. yScaleFactor: 0.4,
  1071. containerWidth: element.width,
  1072. containerHeight: element.height,
  1073. position: {
  1074. mx: 0.32,
  1075. my: 0.3
  1076. }
  1077. });
  1078. if (!!(getDi(element).isMarkerVisible)) {
  1079. drawPath(p, pathData, {
  1080. strokeWidth: 1,
  1081. fill: 'black'
  1082. });
  1083. }
  1084. return diamond;
  1085. },
  1086. 'bpmn:ComplexGateway': function(p, element) {
  1087. var diamond = drawDiamond(p, element.width, element.height);
  1088. var pathData = pathMap.getScaledPath('GATEWAY_COMPLEX', {
  1089. xScaleFactor: 0.5,
  1090. yScaleFactor:0.5,
  1091. containerWidth: element.width,
  1092. containerHeight: element.height,
  1093. position: {
  1094. mx: 0.46,
  1095. my: 0.26
  1096. }
  1097. });
  1098. /* complex path */ drawPath(p, pathData, {
  1099. strokeWidth: 1,
  1100. fill: 'black'
  1101. });
  1102. return diamond;
  1103. },
  1104. 'bpmn:ParallelGateway': function(p, element) {
  1105. var diamond = drawDiamond(p, element.width, element.height);
  1106. var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
  1107. xScaleFactor: 0.6,
  1108. yScaleFactor:0.6,
  1109. containerWidth: element.width,
  1110. containerHeight: element.height,
  1111. position: {
  1112. mx: 0.46,
  1113. my: 0.2
  1114. }
  1115. });
  1116. /* parallel path */ drawPath(p, pathData, {
  1117. strokeWidth: 1,
  1118. fill: 'black'
  1119. });
  1120. return diamond;
  1121. },
  1122. 'bpmn:EventBasedGateway': function(p, element) {
  1123. var semantic = getSemantic(element);
  1124. var diamond = drawDiamond(p, element.width, element.height);
  1125. /* outer circle path */ drawCircle(p, element.width, element.height, element.height * 0.20, {
  1126. strokeWidth: 1,
  1127. fill: 'none'
  1128. });
  1129. var type = semantic.eventGatewayType;
  1130. var instantiate = !!semantic.instantiate;
  1131. function drawEvent() {
  1132. var pathData = pathMap.getScaledPath('GATEWAY_EVENT_BASED', {
  1133. xScaleFactor: 0.18,
  1134. yScaleFactor: 0.18,
  1135. containerWidth: element.width,
  1136. containerHeight: element.height,
  1137. position: {
  1138. mx: 0.36,
  1139. my: 0.44
  1140. }
  1141. });
  1142. /* event path */ drawPath(p, pathData, {
  1143. strokeWidth: 2,
  1144. fill: 'none'
  1145. });
  1146. }
  1147. if (type === 'Parallel') {
  1148. var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
  1149. xScaleFactor: 0.4,
  1150. yScaleFactor:0.4,
  1151. containerWidth: element.width,
  1152. containerHeight: element.height,
  1153. position: {
  1154. mx: 0.474,
  1155. my: 0.296
  1156. }
  1157. });
  1158. var parallelPath = drawPath(p, pathData);
  1159. parallelPath.attr({
  1160. strokeWidth: 1,
  1161. fill: 'none'
  1162. });
  1163. } else if (type === 'Exclusive') {
  1164. if (!instantiate) {
  1165. var innerCircle = drawCircle(p, element.width, element.height, element.height * 0.26);
  1166. innerCircle.attr({
  1167. strokeWidth: 1,
  1168. fill: 'none'
  1169. });
  1170. }
  1171. drawEvent();
  1172. }
  1173. return diamond;
  1174. },
  1175. 'bpmn:Gateway': function(p, element) {
  1176. return drawDiamond(p, element.width, element.height);
  1177. },
  1178. 'bpmn:SequenceFlow': function(p, element) {
  1179. var pathData = createPathFromConnection(element);
  1180. var path = drawPath(p, pathData, {
  1181. strokeLinejoin: 'round',
  1182. markerEnd: marker('sequenceflow-end')
  1183. });
  1184. var sequenceFlow = getSemantic(element);
  1185. var source = element.source.businessObject;
  1186. // conditional flow marker
  1187. if (sequenceFlow.conditionExpression && source.$instanceOf('bpmn:Task')) {
  1188. path.attr({
  1189. markerStart: marker('conditional-flow-marker')
  1190. });
  1191. }
  1192. // default marker
  1193. if (source.default && source.$instanceOf('bpmn:Gateway') && source.default === sequenceFlow) {
  1194. path.attr({
  1195. markerStart: marker('conditional-default-flow-marker')
  1196. });
  1197. }
  1198. return path;
  1199. },
  1200. 'bpmn:Association': function(p, element, attrs) {
  1201. attrs = assign({
  1202. strokeDasharray: '1,6',
  1203. strokeLinecap: 'round',
  1204. strokeLinejoin: 'round'
  1205. }, attrs || {});
  1206. // TODO(nre): style according to directed state
  1207. return drawLine(p, element.waypoints, attrs);
  1208. },
  1209. 'bpmn:DataInputAssociation': function(p, element) {
  1210. return renderer('bpmn:Association')(p, element, {
  1211. markerEnd: marker('data-association-end')
  1212. });
  1213. },
  1214. 'bpmn:DataOutputAssociation': function(p, element) {
  1215. return renderer('bpmn:Association')(p, element, {
  1216. markerEnd: marker('data-association-end')
  1217. });
  1218. },
  1219. 'bpmn:MessageFlow': function(p, element) {
  1220. var semantic = getSemantic(element),
  1221. di = getDi(element);
  1222. var pathData = createPathFromConnection(element);
  1223. var path = drawPath(p, pathData, {
  1224. markerEnd: marker('messageflow-end'),
  1225. markerStart: marker('messageflow-start'),
  1226. strokeDasharray: '10, 12',
  1227. strokeLinecap: 'round',
  1228. strokeLinejoin: 'round',
  1229. strokeWidth: '1.5px'
  1230. });
  1231. if (semantic.messageRef) {
  1232. var midPoint = path.getPointAtLength(path.getTotalLength() / 2);
  1233. var markerPathData = pathMap.getScaledPath('MESSAGE_FLOW_MARKER', {
  1234. abspos: {
  1235. x: midPoint.x,
  1236. y: midPoint.y
  1237. }
  1238. });
  1239. var messageAttrs = { strokeWidth: 1 };
  1240. if (di.messageVisibleKind === 'initiating') {
  1241. messageAttrs.fill = 'white';
  1242. messageAttrs.stroke = 'black';
  1243. } else {
  1244. messageAttrs.fill = '#888';
  1245. messageAttrs.stroke = 'white';
  1246. }
  1247. drawPath(p, markerPathData, messageAttrs);
  1248. }
  1249. return path;
  1250. },
  1251. 'bpmn:DataObject': function(p, element) {
  1252. var pathData = pathMap.getScaledPath('DATA_OBJECT_PATH', {
  1253. xScaleFactor: 1,
  1254. yScaleFactor: 1,
  1255. containerWidth: element.width,
  1256. containerHeight: element.height,
  1257. position: {
  1258. mx: 0.474,
  1259. my: 0.296
  1260. }
  1261. });
  1262. var elementObject = drawPath(p, pathData, { fill: 'white' });
  1263. var semantic = getSemantic(element);
  1264. if (isCollection(semantic)) {
  1265. renderDataItemCollection(p, element);
  1266. }
  1267. return elementObject;
  1268. },
  1269. 'bpmn:DataObjectReference': as('bpmn:DataObject'),
  1270. 'bpmn:DataInput': function(p, element) {
  1271. var arrowPathData = pathMap.getRawPath('DATA_ARROW');
  1272. // page
  1273. var elementObject = renderer('bpmn:DataObject')(p, element);
  1274. /* input arrow path */ drawPath(p, arrowPathData, { strokeWidth: 1 });
  1275. return elementObject;
  1276. },
  1277. 'bpmn:DataOutput': function(p, element) {
  1278. var arrowPathData = pathMap.getRawPath('DATA_ARROW');
  1279. // page
  1280. var elementObject = renderer('bpmn:DataObject')(p, element);
  1281. /* output arrow path */ drawPath(p, arrowPathData, {
  1282. strokeWidth: 1,
  1283. fill: 'black'
  1284. });
  1285. return elementObject;
  1286. },
  1287. 'bpmn:DataStoreReference': function(p, element) {
  1288. var DATA_STORE_PATH = pathMap.getScaledPath('DATA_STORE', {
  1289. xScaleFactor: 1,
  1290. yScaleFactor: 1,
  1291. containerWidth: element.width,
  1292. containerHeight: element.height,
  1293. position: {
  1294. mx: 0,
  1295. my: 0.133
  1296. }
  1297. });
  1298. var elementStore = drawPath(p, DATA_STORE_PATH, {
  1299. strokeWidth: 2,
  1300. fill: 'white'
  1301. });
  1302. return elementStore;
  1303. },
  1304. 'bpmn:BoundaryEvent': function(p, element) {
  1305. var semantic = getSemantic(element),
  1306. cancel = semantic.cancelActivity;
  1307. var attrs = {
  1308. strokeWidth: 1
  1309. };
  1310. if (!cancel) {
  1311. attrs.strokeDasharray = '6';
  1312. attrs.strokeLinecap = 'round';
  1313. }
  1314. var outer = renderer('bpmn:Event')(p, element, attrs);
  1315. /* inner path */ drawCircle(p, element.width, element.height, INNER_OUTER_DIST, assign(attrs, { fill: 'none' }));
  1316. renderEventContent(element, p);
  1317. return outer;
  1318. },
  1319. 'bpmn:Group': function(p, element) {
  1320. return drawRect(p, element.width, element.height, TASK_BORDER_RADIUS, {
  1321. strokeWidth: 1,
  1322. strokeDasharray: '8,3,1,3',
  1323. fill: 'none',
  1324. pointerEvents: 'none'
  1325. });
  1326. },
  1327. 'label': function(p, element) {
  1328. return renderExternalLabel(p, element, '');
  1329. },
  1330. 'bpmn:TextAnnotation': function(p, element) {
  1331. var style = {
  1332. 'fill': 'none',
  1333. 'stroke': 'none'
  1334. };
  1335. var textElement = drawRect(p, element.width, element.height, 0, 0, style);
  1336. var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', {
  1337. xScaleFactor: 1,
  1338. yScaleFactor: 1,
  1339. containerWidth: element.width,
  1340. containerHeight: element.height,
  1341. position: {
  1342. mx: 0.0,
  1343. my: 0.0
  1344. }
  1345. });
  1346. drawPath(p, textPathData);
  1347. var text = getSemantic(element).text || '';
  1348. renderLabel(p, text, { box: element, align: 'left-middle', padding: 5 });
  1349. return textElement;
  1350. },
  1351. 'ParticipantMultiplicityMarker': function(p, element) {
  1352. var subProcessPath = pathMap.getScaledPath('MARKER_PARALLEL', {
  1353. xScaleFactor: 1,
  1354. yScaleFactor: 1,
  1355. containerWidth: element.width,
  1356. containerHeight: element.height,
  1357. position: {
  1358. mx: ((element.width / 2) / element.width),
  1359. my: (element.height - 15) / element.height
  1360. }
  1361. });
  1362. drawPath(p, subProcessPath);
  1363. },
  1364. 'SubProcessMarker': function(p, element) {
  1365. var markerRect = drawRect(p, 14, 14, 0, {
  1366. strokeWidth: 1
  1367. });
  1368. // Process marker is placed in the middle of the box
  1369. // therefore fixed values can be used here
  1370. markerRect.transform('translate(' + (element.width / 2 - 7.5) + ',' + (element.height - 20) + ')');
  1371. var subProcessPath = pathMap.getScaledPath('MARKER_SUB_PROCESS', {
  1372. xScaleFactor: 1.5,
  1373. yScaleFactor: 1.5,
  1374. containerWidth: element.width,
  1375. containerHeight: element.height,
  1376. position: {
  1377. mx: (element.width / 2 - 7.5) / element.width,
  1378. my: (element.height - 20) / element.height
  1379. }
  1380. });
  1381. drawPath(p, subProcessPath);
  1382. },
  1383. 'ParallelMarker': function(p, element, position) {
  1384. var subProcessPath = pathMap.getScaledPath('MARKER_PARALLEL', {
  1385. xScaleFactor: 1,
  1386. yScaleFactor: 1,
  1387. containerWidth: element.width,
  1388. containerHeight: element.height,
  1389. position: {
  1390. mx: ((element.width / 2 + position.parallel) / element.width),
  1391. my: (element.height - 20) / element.height
  1392. }
  1393. });
  1394. drawPath(p, subProcessPath);
  1395. },
  1396. 'SequentialMarker': function(p, element, position) {
  1397. var sequentialPath = pathMap.getScaledPath('MARKER_SEQUENTIAL', {
  1398. xScaleFactor: 1,
  1399. yScaleFactor: 1,
  1400. containerWidth: element.width,
  1401. containerHeight: element.height,
  1402. position: {
  1403. mx: ((element.width / 2 + position.seq) / element.width),
  1404. my: (element.height - 19) / element.height
  1405. }
  1406. });
  1407. drawPath(p, sequentialPath);
  1408. },
  1409. 'CompensationMarker': function(p, element, position) {
  1410. var compensationPath = pathMap.getScaledPath('MARKER_COMPENSATION', {
  1411. xScaleFactor: 1,
  1412. yScaleFactor: 1,
  1413. containerWidth: element.width,
  1414. containerHeight: element.height,
  1415. position: {
  1416. mx: ((element.width / 2 + position.compensation) / element.width),
  1417. my: (element.height - 13) / element.height
  1418. }
  1419. });
  1420. drawPath(p, compensationPath, { strokeWidth: 1 });
  1421. },
  1422. 'LoopMarker': function(p, element, position) {
  1423. var loopPath = pathMap.getScaledPath('MARKER_LOOP', {
  1424. xScaleFactor: 1,
  1425. yScaleFactor: 1,
  1426. containerWidth: element.width,
  1427. containerHeight: element.height,
  1428. position: {
  1429. mx: ((element.width / 2 + position.loop) / element.width),
  1430. my: (element.height - 7) / element.height
  1431. }
  1432. });
  1433. drawPath(p, loopPath, {
  1434. strokeWidth: 1,
  1435. fill: 'none',
  1436. strokeLinecap: 'round',
  1437. strokeMiterlimit: 0.5
  1438. });
  1439. },
  1440. 'AdhocMarker': function(p, element, position) {
  1441. var loopPath = pathMap.getScaledPath('MARKER_ADHOC', {
  1442. xScaleFactor: 1,
  1443. yScaleFactor: 1,
  1444. containerWidth: element.width,
  1445. containerHeight: element.height,
  1446. position: {
  1447. mx: ((element.width / 2 + position.adhoc) / element.width),
  1448. my: (element.height - 15) / element.height
  1449. }
  1450. });
  1451. drawPath(p, loopPath, {
  1452. strokeWidth: 1,
  1453. fill: 'black'
  1454. });
  1455. }
  1456. };
  1457. function attachTaskMarkers(p, element, taskMarkers) {
  1458. var obj = getSemantic(element);
  1459. var subprocess = includes(taskMarkers, 'SubProcessMarker');
  1460. var position;
  1461. if (subprocess) {
  1462. position = {
  1463. seq: -21,
  1464. parallel: -22,
  1465. compensation: -42,
  1466. loop: -18,
  1467. adhoc: 10
  1468. };
  1469. } else {
  1470. position = {
  1471. seq: -3,
  1472. parallel: -6,
  1473. compensation: -27,
  1474. loop: 0,
  1475. adhoc: 10
  1476. };
  1477. }
  1478. forEach(taskMarkers, function(marker) {
  1479. renderer(marker)(p, element, position);
  1480. });
  1481. if (obj.$type === 'bpmn:AdHocSubProcess') {
  1482. renderer('AdhocMarker')(p, element, position);
  1483. }
  1484. if (obj.loopCharacteristics && obj.loopCharacteristics.isSequential === undefined) {
  1485. renderer('LoopMarker')(p, element, position);
  1486. return;
  1487. }
  1488. if (obj.loopCharacteristics &&
  1489. obj.loopCharacteristics.isSequential !== undefined &&
  1490. !obj.loopCharacteristics.isSequential) {
  1491. renderer('ParallelMarker')(p, element, position);
  1492. }
  1493. if (obj.loopCharacteristics && !!obj.loopCharacteristics.isSequential) {
  1494. renderer('SequentialMarker')(p, element, position);
  1495. }
  1496. if (!!obj.isForCompensation) {
  1497. renderer('CompensationMarker')(p, element, position);
  1498. }
  1499. }
  1500. function drawShape(parent, element) {
  1501. var type = element.type;
  1502. var h = handlers[type];
  1503. /* jshint -W040 */
  1504. if (!h) {
  1505. return DefaultRenderer.prototype.drawShape.apply(this, [ parent, element ]);
  1506. } else {
  1507. return h(parent, element);
  1508. }
  1509. }
  1510. function drawConnection(parent, element) {
  1511. var type = element.type;
  1512. var h = handlers[type];
  1513. /* jshint -W040 */
  1514. if (!h) {
  1515. return DefaultRenderer.prototype.drawConnection.apply(this, [ parent, element ]);
  1516. } else {
  1517. return h(parent, element);
  1518. }
  1519. }
  1520. function renderDataItemCollection(p, element) {
  1521. var yPosition = (element.height - 16) / element.height;
  1522. var pathData = pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH', {
  1523. xScaleFactor: 1,
  1524. yScaleFactor: 1,
  1525. containerWidth: element.width,
  1526. containerHeight: element.height,
  1527. position: {
  1528. mx: 0.451,
  1529. my: yPosition
  1530. }
  1531. });
  1532. /* collection path */ drawPath(p, pathData, {
  1533. strokeWidth: 2
  1534. });
  1535. }
  1536. function isCollection(element, filter) {
  1537. return element.isCollection ||
  1538. (element.elementObjectRef && element.elementObjectRef.isCollection);
  1539. }
  1540. function getDi(element) {
  1541. return element.businessObject.di;
  1542. }
  1543. function getSemantic(element) {
  1544. return element.businessObject;
  1545. }
  1546. /**
  1547. * Checks if eventDefinition of the given element matches with semantic type.
  1548. *
  1549. * @return {boolean} true if element is of the given semantic type
  1550. */
  1551. function isTypedEvent(event, eventDefinitionType, filter) {
  1552. function matches(definition, filter) {
  1553. return every(filter, function(val, key) {
  1554. // we want a == conversion here, to be able to catch
  1555. // undefined == false and friends
  1556. /* jshint -W116 */
  1557. return definition[key] == val;
  1558. });
  1559. }
  1560. return some(event.eventDefinitions, function(definition) {
  1561. return definition.$type === eventDefinitionType && matches(event, filter);
  1562. });
  1563. }
  1564. function isThrowEvent(event) {
  1565. return (event.$type === 'bpmn:IntermediateThrowEvent') || (event.$type === 'bpmn:EndEvent');
  1566. }
  1567. /////// cropping path customizations /////////////////////////
  1568. function componentsToPath(elements) {
  1569. return elements.join(',').replace(/,?([A-z]),?/g, '$1');
  1570. }
  1571. function getCirclePath(shape) {
  1572. var cx = shape.x + shape.width / 2,
  1573. cy = shape.y + shape.height / 2,
  1574. radius = shape.width / 2;
  1575. var circlePath = [
  1576. ['M', cx, cy],
  1577. ['m', 0, -radius],
  1578. ['a', radius, radius, 0, 1, 1, 0, 2 * radius],
  1579. ['a', radius, radius, 0, 1, 1, 0, -2 * radius],
  1580. ['z']
  1581. ];
  1582. return componentsToPath(circlePath);
  1583. }
  1584. function getRoundRectPath(shape) {
  1585. var radius = TASK_BORDER_RADIUS,
  1586. x = shape.x,
  1587. y = shape.y,
  1588. width = shape.width,
  1589. height = shape.height;
  1590. var roundRectPath = [
  1591. ['M', x + radius, y],
  1592. ['l', width - radius * 2, 0],
  1593. ['a', radius, radius, 0, 0, 1, radius, radius],
  1594. ['l', 0, height - radius * 2],
  1595. ['a', radius, radius, 0, 0, 1, -radius, radius],
  1596. ['l', radius * 2 - width, 0],
  1597. ['a', radius, radius, 0, 0, 1, -radius, -radius],
  1598. ['l', 0, radius * 2 - height],
  1599. ['a', radius, radius, 0, 0, 1, radius, -radius],
  1600. ['z']
  1601. ];
  1602. return componentsToPath(roundRectPath);
  1603. }
  1604. function getDiamondPath(shape) {
  1605. var width = shape.width,
  1606. height = shape.height,
  1607. x = shape.x,
  1608. y = shape.y,
  1609. halfWidth = width / 2,
  1610. halfHeight = height / 2;
  1611. var diamondPath = [
  1612. ['M', x + halfWidth, y],
  1613. ['l', halfWidth, halfHeight],
  1614. ['l', -halfWidth, halfHeight],
  1615. ['l', -halfWidth, -halfHeight],
  1616. ['z']
  1617. ];
  1618. return componentsToPath(diamondPath);
  1619. }
  1620. function getRectPath(shape) {
  1621. var x = shape.x,
  1622. y = shape.y,
  1623. width = shape.width,
  1624. height = shape.height;
  1625. var rectPath = [
  1626. ['M', x, y],
  1627. ['l', width, 0],
  1628. ['l', 0, height],
  1629. ['l', -width, 0],
  1630. ['z']
  1631. ];
  1632. return componentsToPath(rectPath);
  1633. }
  1634. function getShapePath(element) {
  1635. var obj = getSemantic(element);
  1636. if (obj.$instanceOf('bpmn:Event')) {
  1637. return getCirclePath(element);
  1638. }
  1639. if (obj.$instanceOf('bpmn:Activity')) {
  1640. return getRoundRectPath(element);
  1641. }
  1642. if (obj.$instanceOf('bpmn:Gateway')) {
  1643. return getDiamondPath(element);
  1644. }
  1645. return getRectPath(element);
  1646. }
  1647. // hook onto canvas init event to initialize
  1648. // connection start/end markers on svg
  1649. events.on('canvas.init', function(event) {
  1650. initMarkers(event.svg);
  1651. });
  1652. this.drawShape = drawShape;
  1653. this.drawConnection = drawConnection;
  1654. this.getShapePath = getShapePath;
  1655. }
  1656. inherits(BpmnRenderer, DefaultRenderer);
  1657. BpmnRenderer.$inject = [ 'eventBus', 'styles', 'pathMap' ];
  1658. module.exports = BpmnRenderer;
  1659. },{"12":12,"168":168,"172":172,"177":177,"44":44,"73":73,"81":81,"83":83,"86":86,"88":88,"91":91}],5:[function(_dereq_,module,exports){
  1660. 'use strict';
  1661. var Snap = _dereq_(76);
  1662. /**
  1663. * Map containing SVG paths needed by BpmnRenderer.
  1664. */
  1665. function PathMap() {
  1666. /**
  1667. * Contains a map of path elements
  1668. *
  1669. * <h1>Path definition</h1>
  1670. * A parameterized path is defined like this:
  1671. * <pre>
  1672. * 'GATEWAY_PARALLEL': {
  1673. * d: 'm {mx},{my} {e.x0},0 0,{e.x1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} ' +
  1674. '-{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z',
  1675. * height: 17.5,
  1676. * width: 17.5,
  1677. * heightElements: [2.5, 7.5],
  1678. * widthElements: [2.5, 7.5]
  1679. * }
  1680. * </pre>
  1681. * <p>It's important to specify a correct <b>height and width</b> for the path as the scaling
  1682. * is based on the ratio between the specified height and width in this object and the
  1683. * height and width that is set as scale target (Note x,y coordinates will be scaled with
  1684. * individual ratios).</p>
  1685. * <p>The '<b>heightElements</b>' and '<b>widthElements</b>' array must contain the values that will be scaled.
  1686. * The scaling is based on the computed ratios.
  1687. * Coordinates on the y axis should be in the <b>heightElement</b>'s array, they will be scaled using
  1688. * the computed ratio coefficient.
  1689. * In the parameterized path the scaled values can be accessed through the 'e' object in {} brackets.
  1690. * <ul>
  1691. * <li>The values for the y axis can be accessed in the path string using {e.y0}, {e.y1}, ....</li>
  1692. * <li>The values for the x axis can be accessed in the path string using {e.x0}, {e.x1}, ....</li>
  1693. * </ul>
  1694. * The numbers x0, x1 respectively y0, y1, ... map to the corresponding array index.
  1695. * </p>
  1696. */
  1697. this.pathMap = {
  1698. 'EVENT_MESSAGE': {
  1699. d: 'm {mx},{my} l 0,{e.y1} l {e.x1},0 l 0,-{e.y1} z l {e.x0},{e.y0} l {e.x0},-{e.y0}',
  1700. height: 36,
  1701. width: 36,
  1702. heightElements: [6, 14],
  1703. widthElements: [10.5, 21]
  1704. },
  1705. 'EVENT_SIGNAL': {
  1706. d: 'M {mx},{my} l {e.x0},{e.y0} l -{e.x1},0 Z',
  1707. height: 36,
  1708. width: 36,
  1709. heightElements: [18],
  1710. widthElements: [10, 20]
  1711. },
  1712. 'EVENT_ESCALATION': {
  1713. d: 'm {mx},{my} c -{e.x1},{e.y0} -{e.x3},{e.y1} -{e.x5},{e.y4} {e.x1},-{e.y3} {e.x3},-{e.y5} {e.x5},-{e.y6} ' +
  1714. '{e.x0},{e.y3} {e.x2},{e.y5} {e.x4},{e.y6} -{e.x0},-{e.y0} -{e.x2},-{e.y1} -{e.x4},-{e.y4} z',
  1715. height: 36,
  1716. width: 36,
  1717. heightElements: [2.382, 4.764, 4.926, 6.589333, 7.146, 13.178667, 19.768],
  1718. widthElements: [2.463, 2.808, 4.926, 5.616, 7.389, 8.424]
  1719. },
  1720. 'EVENT_CONDITIONAL': {
  1721. d: 'M {e.x0},{e.y0} l {e.x1},0 l 0,{e.y2} l -{e.x1},0 Z ' +
  1722. 'M {e.x2},{e.y3} l {e.x0},0 ' +
  1723. 'M {e.x2},{e.y4} l {e.x0},0 ' +
  1724. 'M {e.x2},{e.y5} l {e.x0},0 ' +
  1725. 'M {e.x2},{e.y6} l {e.x0},0 ' +
  1726. 'M {e.x2},{e.y7} l {e.x0},0 ' +
  1727. 'M {e.x2},{e.y8} l {e.x0},0 ',
  1728. height: 36,
  1729. width: 36,
  1730. heightElements: [8.5, 14.5, 18, 11.5, 14.5, 17.5, 20.5, 23.5, 26.5],
  1731. widthElements: [10.5, 14.5, 12.5]
  1732. },
  1733. 'EVENT_LINK': {
  1734. d: 'm {mx},{my} 0,{e.y0} -{e.x1},0 0,{e.y1} {e.x1},0 0,{e.y0} {e.x0},-{e.y2} -{e.x0},-{e.y2} z',
  1735. height: 36,
  1736. width: 36,
  1737. heightElements: [4.4375, 6.75, 7.8125],
  1738. widthElements: [9.84375, 13.5]
  1739. },
  1740. 'EVENT_ERROR': {
  1741. d: 'm {mx},{my} {e.x0},-{e.y0} {e.x1},-{e.y1} {e.x2},{e.y2} {e.x3},-{e.y3} -{e.x4},{e.y4} -{e.x5},-{e.y5} z',
  1742. height: 36,
  1743. width: 36,
  1744. heightElements: [0.023, 8.737, 8.151, 16.564, 10.591, 8.714],
  1745. widthElements: [0.085, 6.672, 6.97, 4.273, 5.337, 6.636]
  1746. },
  1747. 'EVENT_CANCEL_45': {
  1748. d: 'm {mx},{my} -{e.x1},0 0,{e.x0} {e.x1},0 0,{e.y1} {e.x0},0 ' +
  1749. '0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z',
  1750. height: 36,
  1751. width: 36,
  1752. heightElements: [4.75, 8.5],
  1753. widthElements: [4.75, 8.5]
  1754. },
  1755. 'EVENT_COMPENSATION': {
  1756. d: 'm {mx},{my} {e.x0},-{e.y0} 0,{e.y1} z m {e.x0},0 {e.x0},-{e.y0} 0,{e.y1} z',
  1757. height: 36,
  1758. width: 36,
  1759. heightElements: [5, 10],
  1760. widthElements: [10]
  1761. },
  1762. 'EVENT_TIMER_WH': {
  1763. d: 'M {mx},{my} l {e.x0},-{e.y0} m -{e.x0},{e.y0} l {e.x1},{e.y1} ',
  1764. height: 36,
  1765. width: 36,
  1766. heightElements: [10, 2],
  1767. widthElements: [3, 7]
  1768. },
  1769. 'EVENT_TIMER_LINE': {
  1770. d: 'M {mx},{my} ' +
  1771. 'm {e.x0},{e.y0} l -{e.x1},{e.y1} ',
  1772. height: 36,
  1773. width: 36,
  1774. heightElements: [10, 3],
  1775. widthElements: [0, 0]
  1776. },
  1777. 'EVENT_MULTIPLE': {
  1778. d:'m {mx},{my} {e.x1},-{e.y0} {e.x1},{e.y0} -{e.x0},{e.y1} -{e.x2},0 z',
  1779. height: 36,
  1780. width: 36,
  1781. heightElements: [6.28099, 12.56199],
  1782. widthElements: [3.1405, 9.42149, 12.56198]
  1783. },
  1784. 'EVENT_PARALLEL_MULTIPLE': {
  1785. d:'m {mx},{my} {e.x0},0 0,{e.y1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} ' +
  1786. '-{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z',
  1787. height: 36,
  1788. width: 36,
  1789. heightElements: [2.56228, 7.68683],
  1790. widthElements: [2.56228, 7.68683]
  1791. },
  1792. 'GATEWAY_EXCLUSIVE': {
  1793. d:'m {mx},{my} {e.x0},{e.y0} {e.x1},{e.y0} {e.x2},0 {e.x4},{e.y2} ' +
  1794. '{e.x4},{e.y1} {e.x2},0 {e.x1},{e.y3} {e.x0},{e.y3} ' +
  1795. '{e.x3},0 {e.x5},{e.y1} {e.x5},{e.y2} {e.x3},0 z',
  1796. height: 17.5,
  1797. width: 17.5,
  1798. heightElements: [8.5, 6.5312, -6.5312, -8.5],
  1799. widthElements: [6.5, -6.5, 3, -3, 5, -5]
  1800. },
  1801. 'GATEWAY_PARALLEL': {
  1802. d:'m {mx},{my} 0,{e.y1} -{e.x1},0 0,{e.y0} {e.x1},0 0,{e.y1} {e.x0},0 ' +
  1803. '0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z',
  1804. height: 30,
  1805. width: 30,
  1806. heightElements: [5, 12.5],
  1807. widthElements: [5, 12.5]
  1808. },
  1809. 'GATEWAY_EVENT_BASED': {
  1810. d:'m {mx},{my} {e.x0},{e.y0} {e.x0},{e.y1} {e.x1},{e.y2} {e.x2},0 z',
  1811. height: 11,
  1812. width: 11,
  1813. heightElements: [-6, 6, 12, -12],
  1814. widthElements: [9, -3, -12]
  1815. },
  1816. 'GATEWAY_COMPLEX': {
  1817. d:'m {mx},{my} 0,{e.y0} -{e.x0},-{e.y1} -{e.x1},{e.y2} {e.x0},{e.y1} -{e.x2},0 0,{e.y3} ' +
  1818. '{e.x2},0 -{e.x0},{e.y1} l {e.x1},{e.y2} {e.x0},-{e.y1} 0,{e.y0} {e.x3},0 0,-{e.y0} {e.x0},{e.y1} ' +
  1819. '{e.x1},-{e.y2} -{e.x0},-{e.y1} {e.x2},0 0,-{e.y3} -{e.x2},0 {e.x0},-{e.y1} -{e.x1},-{e.y2} ' +
  1820. '-{e.x0},{e.y1} 0,-{e.y0} -{e.x3},0 z',
  1821. height: 17.125,
  1822. width: 17.125,
  1823. heightElements: [4.875, 3.4375, 2.125, 3],
  1824. widthElements: [3.4375, 2.125, 4.875, 3]
  1825. },
  1826. 'DATA_OBJECT_PATH': {
  1827. d:'m 0,0 {e.x1},0 {e.x0},{e.y0} 0,{e.y1} -{e.x2},0 0,-{e.y2} {e.x1},0 0,{e.y0} {e.x0},0',
  1828. height: 61,
  1829. width: 51,
  1830. heightElements: [10, 50, 60],
  1831. widthElements: [10, 40, 50, 60]
  1832. },
  1833. 'DATA_OBJECT_COLLECTION_PATH': {
  1834. d:'m {mx}, {my} ' +
  1835. 'm 0 15 l 0 -15 ' +
  1836. 'm 4 15 l 0 -15 ' +
  1837. 'm 4 15 l 0 -15 ',
  1838. height: 61,
  1839. width: 51,
  1840. heightElements: [12],
  1841. widthElements: [1, 6, 12, 15]
  1842. },
  1843. 'DATA_ARROW': {
  1844. d:'m 5,9 9,0 0,-3 5,5 -5,5 0,-3 -9,0 z',
  1845. height: 61,
  1846. width: 51,
  1847. heightElements: [],
  1848. widthElements: []
  1849. },
  1850. 'DATA_STORE': {
  1851. d:'m {mx},{my} ' +
  1852. 'l 0,{e.y2} ' +
  1853. 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 ' +
  1854. 'l 0,-{e.y2} ' +
  1855. 'c -{e.x0},-{e.y1} -{e.x1},-{e.y1} -{e.x2},0' +
  1856. 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 ' +
  1857. 'm -{e.x2},{e.y0}' +
  1858. 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0' +
  1859. 'm -{e.x2},{e.y0}' +
  1860. 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0',
  1861. height: 61,
  1862. width: 61,
  1863. heightElements: [7, 10, 45],
  1864. widthElements: [2, 58, 60]
  1865. },
  1866. 'TEXT_ANNOTATION': {
  1867. d: 'm {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0',
  1868. height: 30,
  1869. width: 10,
  1870. heightElements: [30],
  1871. widthElements: [10]
  1872. },
  1873. 'MARKER_SUB_PROCESS': {
  1874. d: 'm{mx},{my} m 7,2 l 0,10 m -5,-5 l 10,0',
  1875. height: 10,
  1876. width: 10,
  1877. heightElements: [],
  1878. widthElements: []
  1879. },
  1880. 'MARKER_PARALLEL': {
  1881. d: 'm{mx},{my} m 3,2 l 0,10 m 3,-10 l 0,10 m 3,-10 l 0,10',
  1882. height: 10,
  1883. width: 10,
  1884. heightElements: [],
  1885. widthElements: []
  1886. },
  1887. 'MARKER_SEQUENTIAL': {
  1888. d: 'm{mx},{my} m 0,3 l 10,0 m -10,3 l 10,0 m -10,3 l 10,0',
  1889. height: 10,
  1890. width: 10,
  1891. heightElements: [],
  1892. widthElements: []
  1893. },
  1894. 'MARKER_COMPENSATION': {
  1895. d: 'm {mx},{my} 8,-5 0,10 z m 9,0 8,-5 0,10 z',
  1896. height: 10,
  1897. width: 21,
  1898. heightElements: [],
  1899. widthElements: []
  1900. },
  1901. 'MARKER_LOOP': {
  1902. d: 'm {mx},{my} c 3.526979,0 6.386161,-2.829858 6.386161,-6.320661 0,-3.490806 -2.859182,-6.320661 ' +
  1903. '-6.386161,-6.320661 -3.526978,0 -6.38616,2.829855 -6.38616,6.320661 0,1.745402 ' +
  1904. '0.714797,3.325567 1.870463,4.469381 0.577834,0.571908 1.265885,1.034728 2.029916,1.35457 ' +
  1905. 'l -0.718163,-3.909793 m 0.718163,3.909793 -3.885211,0.802902',
  1906. height: 13.9,
  1907. width: 13.7,
  1908. heightElements: [],
  1909. widthElements: []
  1910. },
  1911. 'MARKER_ADHOC': {
  1912. d: 'm {mx},{my} m 0.84461,2.64411 c 1.05533,-1.23780996 2.64337,-2.07882 4.29653,-1.97997996 2.05163,0.0805 ' +
  1913. '3.85579,1.15803 5.76082,1.79107 1.06385,0.34139996 2.24454,0.1438 3.18759,-0.43767 0.61743,-0.33642 ' +
  1914. '1.2775,-0.64078 1.7542,-1.17511 0,0.56023 0,1.12046 0,1.6807 -0.98706,0.96237996 -2.29792,1.62393996 ' +
  1915. '-3.6918,1.66181996 -1.24459,0.0927 -2.46671,-0.2491 -3.59505,-0.74812 -1.35789,-0.55965 ' +
  1916. '-2.75133,-1.33436996 -4.27027,-1.18121996 -1.37741,0.14601 -2.41842,1.13685996 -3.44288,1.96782996 z',
  1917. height: 4,
  1918. width: 15,
  1919. heightElements: [],
  1920. widthElements: []
  1921. },
  1922. 'TASK_TYPE_SEND': {
  1923. d: 'm {mx},{my} l 0,{e.y1} l {e.x1},0 l 0,-{e.y1} z l {e.x0},{e.y0} l {e.x0},-{e.y0}',
  1924. height: 14,
  1925. width: 21,
  1926. heightElements: [6, 14],
  1927. widthElements: [10.5, 21]
  1928. },
  1929. 'TASK_TYPE_SCRIPT': {
  1930. d: 'm {mx},{my} c 9.966553,-6.27276 -8.000926,-7.91932 2.968968,-14.938 l -8.802728,0 ' +
  1931. 'c -10.969894,7.01868 6.997585,8.66524 -2.968967,14.938 z ' +
  1932. 'm -7,-12 l 5,0 ' +
  1933. 'm -4.5,3 l 4.5,0 ' +
  1934. 'm -3,3 l 5,0' +
  1935. 'm -4,3 l 5,0',
  1936. height: 15,
  1937. width: 12.6,
  1938. heightElements: [6, 14],
  1939. widthElements: [10.5, 21]
  1940. },
  1941. 'TASK_TYPE_USER_1': {
  1942. d: 'm {mx},{my} c 0.909,-0.845 1.594,-2.049 1.594,-3.385 0,-2.554 -1.805,-4.62199999 ' +
  1943. '-4.357,-4.62199999 -2.55199998,0 -4.28799998,2.06799999 -4.28799998,4.62199999 0,1.348 ' +
  1944. '0.974,2.562 1.89599998,3.405 -0.52899998,0.187 -5.669,2.097 -5.794,4.7560005 v 6.718 ' +
  1945. 'h 17 v -6.718 c 0,-2.2980005 -5.5279996,-4.5950005 -6.0509996,-4.7760005 z' +
  1946. 'm -8,6 l 0,5.5 m 11,0 l 0,-5'
  1947. },
  1948. 'TASK_TYPE_USER_2': {
  1949. d: 'm {mx},{my} m 2.162,1.009 c 0,2.4470005 -2.158,4.4310005 -4.821,4.4310005 ' +
  1950. '-2.66499998,0 -4.822,-1.981 -4.822,-4.4310005 '
  1951. },
  1952. 'TASK_TYPE_USER_3': {
  1953. d: 'm {mx},{my} m -6.9,-3.80 c 0,0 2.25099998,-2.358 4.27399998,-1.177 2.024,1.181 4.221,1.537 ' +
  1954. '4.124,0.965 -0.098,-0.57 -0.117,-3.79099999 -4.191,-4.13599999 -3.57499998,0.001 ' +
  1955. '-4.20799998,3.36699999 -4.20699998,4.34799999 z'
  1956. },
  1957. 'TASK_TYPE_MANUAL': {
  1958. d: 'm {mx},{my} c 0.234,-0.01 5.604,0.008 8.029,0.004 0.808,0 1.271,-0.172 1.417,-0.752 0.227,-0.898 ' +
  1959. '-0.334,-1.314 -1.338,-1.316 -2.467,-0.01 -7.886,-0.004 -8.108,-0.004 -0.014,-0.079 0.016,-0.533 0,-0.61 ' +
  1960. '0.195,-0.042 8.507,0.006 9.616,0.002 0.877,-0.007 1.35,-0.438 1.353,-1.208 0.003,-0.768 -0.479,-1.09 ' +
  1961. '-1.35,-1.091 -2.968,-0.002 -9.619,-0.013 -9.619,-0.013 v -0.591 c 0,0 5.052,-0.016 7.225,-0.016 ' +
  1962. '0.888,-0.002 1.354,-0.416 1.351,-1.193 -0.006,-0.761 -0.492,-1.196 -1.361,-1.196 -3.473,-0.005 ' +
  1963. '-10.86,-0.003 -11.0829995,-0.003 -0.022,-0.047 -0.045,-0.094 -0.069,-0.139 0.3939995,-0.319 ' +
  1964. '2.0409995,-1.626 2.4149995,-2.017 0.469,-0.4870005 0.519,-1.1650005 0.162,-1.6040005 -0.414,-0.511 ' +
  1965. '-0.973,-0.5 -1.48,-0.236 -1.4609995,0.764 -6.5999995,3.6430005 -7.7329995,4.2710005 -0.9,0.499 ' +
  1966. '-1.516,1.253 -1.882,2.19 -0.37000002,0.95 -0.17,2.01 -0.166,2.979 0.004,0.718 -0.27300002,1.345 ' +
  1967. '-0.055,2.063 0.629,2.087 2.425,3.312 4.859,3.318 4.6179995,0.014 9.2379995,-0.139 13.8569995,-0.158 ' +
  1968. '0.755,-0.004 1.171,-0.301 1.182,-1.033 0.012,-0.754 -0.423,-0.969 -1.183,-0.973 -1.778,-0.01 ' +
  1969. '-5.824,-0.004 -6.04,-0.004 10e-4,-0.084 0.003,-0.586 10e-4,-0.67 z'
  1970. },
  1971. 'TASK_TYPE_INSTANTIATING_SEND': {
  1972. d: 'm {mx},{my} l 0,8.4 l 12.6,0 l 0,-8.4 z l 6.3,3.6 l 6.3,-3.6'
  1973. },
  1974. 'TASK_TYPE_SERVICE': {
  1975. d: 'm {mx},{my} v -1.71335 c 0.352326,-0.0705 0.703932,-0.17838 1.047628,-0.32133 ' +
  1976. '0.344416,-0.14465 0.665822,-0.32133 0.966377,-0.52145 l 1.19431,1.18005 1.567487,-1.57688 ' +
  1977. '-1.195028,-1.18014 c 0.403376,-0.61394 0.683079,-1.29908 0.825447,-2.01824 l 1.622133,-0.01 ' +
  1978. 'v -2.2196 l -1.636514,0.01 c -0.07333,-0.35153 -0.178319,-0.70024 -0.323564,-1.04372 ' +
  1979. '-0.145244,-0.34406 -0.321407,-0.6644 -0.522735,-0.96217 l 1.131035,-1.13631 -1.583305,-1.56293 ' +
  1980. '-1.129598,1.13589 c -0.614052,-0.40108 -1.302883,-0.68093 -2.022633,-0.82247 l 0.0093,-1.61852 ' +
  1981. 'h -2.241173 l 0.0042,1.63124 c -0.353763,0.0736 -0.705369,0.17977 -1.049785,0.32371 -0.344415,0.14437 ' +
  1982. '-0.665102,0.32092 -0.9635006,0.52046 l -1.1698628,-1.15823 -1.5667691,1.5792 1.1684265,1.15669 ' +
  1983. 'c -0.4026573,0.61283 -0.68308,1.29797 -0.8247287,2.01713 l -1.6588041,0.003 v 2.22174 ' +
  1984. 'l 1.6724648,-0.006 c 0.073327,0.35077 0.1797598,0.70243 0.3242851,1.04472 0.1452428,0.34448 ' +
  1985. '0.3214064,0.6644 0.5227339,0.96066 l -1.1993431,1.19723 1.5840256,1.56011 1.1964668,-1.19348 ' +
  1986. 'c 0.6140517,0.40346 1.3028827,0.68232 2.0233517,0.82331 l 7.19e-4,1.69892 h 2.226848 z ' +
  1987. 'm 0.221462,-3.9957 c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 ' +
  1988. '0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 ' +
  1989. '0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z'
  1990. },
  1991. 'TASK_TYPE_SERVICE_FILL': {
  1992. d: 'm {mx},{my} c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 ' +
  1993. '0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 ' +
  1994. '0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z'
  1995. },
  1996. 'TASK_TYPE_BUSINESS_RULE_HEADER': {
  1997. d: 'm {mx},{my} 0,4 20,0 0,-4 z'
  1998. },
  1999. 'TASK_TYPE_BUSINESS_RULE_MAIN': {
  2000. d: 'm {mx},{my} 0,12 20,0 0,-12 z' +
  2001. 'm 0,8 l 20,0 ' +
  2002. 'm -13,-4 l 0,8'
  2003. },
  2004. 'MESSAGE_FLOW_MARKER': {
  2005. d: 'm {mx},{my} m -10.5 ,-7 l 0,14 l 21,0 l 0,-14 z l 10.5,6 l 10.5,-6'
  2006. }
  2007. };
  2008. this.getRawPath = function getRawPath(pathId) {
  2009. return this.pathMap[pathId].d;
  2010. };
  2011. /**
  2012. * Scales the path to the given height and width.
  2013. * <h1>Use case</h1>
  2014. * <p>Use case is to scale the content of elements (event, gateways) based
  2015. * on the element bounding box's size.
  2016. * </p>
  2017. * <h1>Why not transform</h1>
  2018. * <p>Scaling a path with transform() will also scale the stroke and IE does not support
  2019. * the option 'non-scaling-stroke' to prevent this.
  2020. * Also there are use cases where only some parts of a path should be
  2021. * scaled.</p>
  2022. *
  2023. * @param {String} pathId The ID of the path.
  2024. * @param {Object} param <p>
  2025. * Example param object scales the path to 60% size of the container (data.width, data.height).
  2026. * <pre>
  2027. * {
  2028. * xScaleFactor: 0.6,
  2029. * yScaleFactor:0.6,
  2030. * containerWidth: data.width,
  2031. * containerHeight: data.height,
  2032. * position: {
  2033. * mx: 0.46,
  2034. * my: 0.2,
  2035. * }
  2036. * }
  2037. * </pre>
  2038. * <ul>
  2039. * <li>targetpathwidth = xScaleFactor * containerWidth</li>
  2040. * <li>targetpathheight = yScaleFactor * containerHeight</li>
  2041. * <li>Position is used to set the starting coordinate of the path. M is computed:
  2042. * <ul>
  2043. * <li>position.x * containerWidth</li>
  2044. * <li>position.y * containerHeight</li>
  2045. * </ul>
  2046. * Center of the container <pre> position: {
  2047. * mx: 0.5,
  2048. * my: 0.5,
  2049. * }</pre>
  2050. * Upper left corner of the container
  2051. * <pre> position: {
  2052. * mx: 0.0,
  2053. * my: 0.0,
  2054. * }</pre>
  2055. * </li>
  2056. * </ul>
  2057. * </p>
  2058. *
  2059. */
  2060. this.getScaledPath = function getScaledPath(pathId, param) {
  2061. var rawPath = this.pathMap[pathId];
  2062. // positioning
  2063. // compute the start point of the path
  2064. var mx, my;
  2065. if(!!param.abspos) {
  2066. mx = param.abspos.x;
  2067. my = param.abspos.y;
  2068. } else {
  2069. mx = param.containerWidth * param.position.mx;
  2070. my = param.containerHeight * param.position.my;
  2071. }
  2072. var coordinates = {}; //map for the scaled coordinates
  2073. if(param.position) {
  2074. // path
  2075. var heightRatio = (param.containerHeight / rawPath.height) * param.yScaleFactor;
  2076. var widthRatio = (param.containerWidth / rawPath.width) * param.xScaleFactor;
  2077. //Apply height ratio
  2078. for (var heightIndex = 0; heightIndex < rawPath.heightElements.length; heightIndex++) {
  2079. coordinates['y' + heightIndex] = rawPath.heightElements[heightIndex] * heightRatio;
  2080. }
  2081. //Apply width ratio
  2082. for (var widthIndex = 0; widthIndex < rawPath.widthElements.length; widthIndex++) {
  2083. coordinates['x' + widthIndex] = rawPath.widthElements[widthIndex] * widthRatio;
  2084. }
  2085. }
  2086. //Apply value to raw path
  2087. var path = Snap.format(
  2088. rawPath.d, {
  2089. mx: mx,
  2090. my: my,
  2091. e: coordinates
  2092. }
  2093. );
  2094. return path;
  2095. };
  2096. }
  2097. module.exports = PathMap;
  2098. },{"76":76}],6:[function(_dereq_,module,exports){
  2099. module.exports = {
  2100. renderer: [ 'type', _dereq_(4) ],
  2101. pathMap: [ 'type', _dereq_(5) ]
  2102. };
  2103. },{"4":4,"5":5}],7:[function(_dereq_,module,exports){
  2104. 'use strict';
  2105. var assign = _dereq_(177),
  2106. map = _dereq_(89);
  2107. var LabelUtil = _dereq_(13);
  2108. var is = _dereq_(14).is;
  2109. var hasExternalLabel = LabelUtil.hasExternalLabel,
  2110. getExternalLabelBounds = LabelUtil.getExternalLabelBounds,
  2111. isExpanded = _dereq_(12).isExpanded,
  2112. elementToString = _dereq_(10).elementToString;
  2113. function elementData(semantic, attrs) {
  2114. return assign({
  2115. id: semantic.id,
  2116. type: semantic.$type,
  2117. businessObject: semantic
  2118. }, attrs);
  2119. }
  2120. function collectWaypoints(waypoints) {
  2121. return map(waypoints, function(p) {
  2122. return { x: p.x, y: p.y };
  2123. });
  2124. }
  2125. function notYetDrawn(semantic, refSemantic, property) {
  2126. return new Error(
  2127. 'element ' + elementToString(refSemantic) + ' referenced by ' +
  2128. elementToString(semantic) + '#' + property + ' not yet drawn');
  2129. }
  2130. /**
  2131. * An importer that adds bpmn elements to the canvas
  2132. *
  2133. * @param {EventBus} eventBus
  2134. * @param {Canvas} canvas
  2135. * @param {ElementFactory} elementFactory
  2136. * @param {ElementRegistry} elementRegistry
  2137. */
  2138. function BpmnImporter(eventBus, canvas, elementFactory, elementRegistry) {
  2139. this._eventBus = eventBus;
  2140. this._canvas = canvas;
  2141. this._elementFactory = elementFactory;
  2142. this._elementRegistry = elementRegistry;
  2143. }
  2144. BpmnImporter.$inject = [ 'eventBus', 'canvas', 'elementFactory', 'elementRegistry' ];
  2145. module.exports = BpmnImporter;
  2146. /**
  2147. * Add bpmn element (semantic) to the canvas onto the
  2148. * specified parent shape.
  2149. */
  2150. BpmnImporter.prototype.add = function(semantic, parentElement) {
  2151. var di = semantic.di,
  2152. element;
  2153. // ROOT ELEMENT
  2154. // handle the special case that we deal with a
  2155. // invisible root element (process or collaboration)
  2156. if (di.$instanceOf('bpmndi:BPMNPlane')) {
  2157. // add a virtual element (not being drawn)
  2158. element = this._elementFactory.createRoot(elementData(semantic));
  2159. this._canvas.setRootElement(element);
  2160. }
  2161. // SHAPE
  2162. else if (di.$instanceOf('bpmndi:BPMNShape')) {
  2163. var collapsed = !isExpanded(semantic);
  2164. var hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
  2165. var bounds = semantic.di.bounds;
  2166. element = this._elementFactory.createShape(elementData(semantic, {
  2167. collapsed: collapsed,
  2168. hidden: hidden,
  2169. x: Math.round(bounds.x),
  2170. y: Math.round(bounds.y),
  2171. width: Math.round(bounds.width),
  2172. height: Math.round(bounds.height)
  2173. }));
  2174. if (is(semantic, 'bpmn:BoundaryEvent')) {
  2175. this._attachBoundary(semantic, element);
  2176. }
  2177. this._canvas.addShape(element, parentElement);
  2178. }
  2179. // CONNECTION
  2180. else if (di.$instanceOf('bpmndi:BPMNEdge')) {
  2181. var source = this._getSource(semantic),
  2182. target = this._getTarget(semantic);
  2183. element = this._elementFactory.createConnection(elementData(semantic, {
  2184. source: source,
  2185. target: target,
  2186. waypoints: collectWaypoints(semantic.di.waypoint)
  2187. }));
  2188. this._canvas.addConnection(element, parentElement);
  2189. } else {
  2190. throw new Error('unknown di ' + elementToString(di) + ' for element ' + elementToString(semantic));
  2191. }
  2192. // (optional) LABEL
  2193. if (hasExternalLabel(semantic)) {
  2194. this.addLabel(semantic, element);
  2195. }
  2196. this._eventBus.fire('bpmnElement.added', { element: element });
  2197. return element;
  2198. };
  2199. /**
  2200. * Attach the boundary element to the given host
  2201. *
  2202. * @param {ModdleElement} boundarySemantic
  2203. * @param {djs.model.Base} boundaryElement
  2204. */
  2205. BpmnImporter.prototype._attachBoundary = function(boundarySemantic, boundaryElement) {
  2206. var hostSemantic = boundarySemantic.attachedToRef;
  2207. if (!hostSemantic) {
  2208. throw new Error('missing ' + elementToString(boundarySemantic) + '#attachedToRef');
  2209. }
  2210. var host = this._elementRegistry.get(hostSemantic.id),
  2211. attachers = host && host.attachers;
  2212. if (!host) {
  2213. throw notYetDrawn(boundarySemantic, hostSemantic, 'attachedToRef');
  2214. }
  2215. // wire element.host <> host.attachers
  2216. boundaryElement.host = host;
  2217. if (!attachers) {
  2218. host.attachers = attachers = [];
  2219. }
  2220. if (attachers.indexOf(boundaryElement) === -1) {
  2221. attachers.push(boundaryElement);
  2222. }
  2223. };
  2224. /**
  2225. * add label for an element
  2226. */
  2227. BpmnImporter.prototype.addLabel = function(semantic, element) {
  2228. var bounds = getExternalLabelBounds(semantic, element);
  2229. var label = this._elementFactory.createLabel(elementData(semantic, {
  2230. id: semantic.id + '_label',
  2231. labelTarget: element,
  2232. type: 'label',
  2233. hidden: element.hidden,
  2234. x: Math.round(bounds.x),
  2235. y: Math.round(bounds.y),
  2236. width: Math.round(bounds.width),
  2237. height: Math.round(bounds.height)
  2238. }));
  2239. return this._canvas.addShape(label, element.parent);
  2240. };
  2241. /**
  2242. * Return the drawn connection end based on the given side.
  2243. *
  2244. * @throws {Error} if the end is not yet drawn
  2245. */
  2246. BpmnImporter.prototype._getEnd = function(semantic, side) {
  2247. var element,
  2248. refSemantic,
  2249. type = semantic.$type;
  2250. refSemantic = semantic[side + 'Ref'];
  2251. // handle mysterious isMany DataAssociation#sourceRef
  2252. if (side === 'source' && type === 'bpmn:DataInputAssociation') {
  2253. refSemantic = refSemantic && refSemantic[0];
  2254. }
  2255. // fix source / target for DataInputAssociation / DataOutputAssociation
  2256. if (side === 'source' && type === 'bpmn:DataOutputAssociation' ||
  2257. side === 'target' && type === 'bpmn:DataInputAssociation') {
  2258. refSemantic = semantic.$parent;
  2259. }
  2260. element = refSemantic && this._getElement(refSemantic);
  2261. if (element) {
  2262. return element;
  2263. }
  2264. if (refSemantic) {
  2265. throw notYetDrawn(semantic, refSemantic, side + 'Ref');
  2266. } else {
  2267. throw new Error(elementToString(semantic) + '#' + side + 'Ref not specified');
  2268. }
  2269. };
  2270. BpmnImporter.prototype._getSource = function(semantic) {
  2271. return this._getEnd(semantic, 'source');
  2272. };
  2273. BpmnImporter.prototype._getTarget = function(semantic) {
  2274. return this._getEnd(semantic, 'target');
  2275. };
  2276. BpmnImporter.prototype._getElement = function(semantic) {
  2277. return this._elementRegistry.get(semantic.id);
  2278. };
  2279. },{"10":10,"12":12,"13":13,"14":14,"177":177,"89":89}],8:[function(_dereq_,module,exports){
  2280. 'use strict';
  2281. var filter = _dereq_(84),
  2282. find = _dereq_(85),
  2283. forEach = _dereq_(86);
  2284. var Refs = _dereq_(202);
  2285. var elementToString = _dereq_(10).elementToString;
  2286. var diRefs = new Refs({ name: 'bpmnElement', enumerable: true }, { name: 'di' });
  2287. /**
  2288. * Returns true if an element has the given meta-model type
  2289. *
  2290. * @param {ModdleElement} element
  2291. * @param {String} type
  2292. *
  2293. * @return {Boolean}
  2294. */
  2295. function is(element, type) {
  2296. return element.$instanceOf(type);
  2297. }
  2298. /**
  2299. * Find a suitable display candidate for definitions where the DI does not
  2300. * correctly specify one.
  2301. */
  2302. function findDisplayCandidate(definitions) {
  2303. return find(definitions.rootElements, function(e) {
  2304. return is(e, 'bpmn:Process') || is(e, 'bpmn:Collaboration');
  2305. });
  2306. }
  2307. function BpmnTreeWalker(handler) {
  2308. // list of containers already walked
  2309. var handledProcesses = [];
  2310. // list of elements to handle deferred to ensure
  2311. // prerequisites are drawn
  2312. var deferred = [];
  2313. ///// Helpers /////////////////////////////////
  2314. function contextual(fn, ctx) {
  2315. return function(e) {
  2316. fn(e, ctx);
  2317. };
  2318. }
  2319. function visit(element, ctx) {
  2320. var gfx = element.gfx;
  2321. // avoid multiple rendering of elements
  2322. if (gfx) {
  2323. throw new Error('already rendered ' + elementToString(element));
  2324. }
  2325. // call handler
  2326. return handler.element(element, ctx);
  2327. }
  2328. function visitRoot(element, diagram) {
  2329. return handler.root(element, diagram);
  2330. }
  2331. function visitIfDi(element, ctx) {
  2332. try {
  2333. return element.di && visit(element, ctx);
  2334. } catch (e) {
  2335. logError(e.message, { element: element, error: e });
  2336. console.error('failed to import ' + elementToString(element));
  2337. console.error(e);
  2338. }
  2339. }
  2340. function logError(message, context) {
  2341. handler.error(message, context);
  2342. }
  2343. ////// DI handling ////////////////////////////
  2344. function registerDi(di) {
  2345. var bpmnElement = di.bpmnElement;
  2346. if (bpmnElement) {
  2347. if (bpmnElement.di) {
  2348. logError('multiple DI elements defined for ' + elementToString(bpmnElement), { element: bpmnElement });
  2349. } else {
  2350. diRefs.bind(bpmnElement, 'di');
  2351. bpmnElement.di = di;
  2352. }
  2353. } else {
  2354. logError('no bpmnElement referenced in ' + elementToString(di), { element: di });
  2355. }
  2356. }
  2357. function handleDiagram(diagram) {
  2358. handlePlane(diagram.plane);
  2359. }
  2360. function handlePlane(plane) {
  2361. registerDi(plane);
  2362. forEach(plane.planeElement, handlePlaneElement);
  2363. }
  2364. function handlePlaneElement(planeElement) {
  2365. registerDi(planeElement);
  2366. }
  2367. ////// Semantic handling //////////////////////
  2368. function handleDefinitions(definitions, diagram) {
  2369. // make sure we walk the correct bpmnElement
  2370. var diagrams = definitions.diagrams;
  2371. if (diagram && diagrams.indexOf(diagram) === -1) {
  2372. throw new Error('diagram not part of bpmn:Definitions');
  2373. }
  2374. if (!diagram && diagrams && diagrams.length) {
  2375. diagram = diagrams[0];
  2376. }
  2377. // no diagram -> nothing to import
  2378. if (!diagram) {
  2379. return;
  2380. }
  2381. // load DI from selected diagram only
  2382. handleDiagram(diagram);
  2383. var plane = diagram.plane;
  2384. if (!plane) {
  2385. throw new Error('no plane for ' + elementToString(diagram));
  2386. }
  2387. var rootElement = plane.bpmnElement;
  2388. // ensure we default to a suitable display candidate (process or collaboration),
  2389. // even if non is specified in DI
  2390. if (!rootElement) {
  2391. rootElement = findDisplayCandidate(definitions);
  2392. if (!rootElement) {
  2393. return logError('no process or collaboration present to display');
  2394. } else {
  2395. logError('correcting missing bpmnElement on ' + elementToString(plane) + ' to ' + elementToString(rootElement));
  2396. // correct DI on the fly
  2397. plane.bpmnElement = rootElement;
  2398. registerDi(plane);
  2399. }
  2400. }
  2401. var ctx = visitRoot(rootElement, plane);
  2402. if (is(rootElement, 'bpmn:Process')) {
  2403. handleProcess(rootElement, ctx);
  2404. } else if (is(rootElement, 'bpmn:Collaboration')) {
  2405. handleCollaboration(rootElement, ctx);
  2406. // force drawing of everything not yet drawn that is part of the target DI
  2407. handleUnhandledProcesses(definitions.rootElements, ctx);
  2408. } else {
  2409. throw new Error('unsupported bpmnElement for ' + elementToString(plane) + ' : ' + elementToString(rootElement));
  2410. }
  2411. // handle all deferred elements
  2412. handleDeferred(deferred);
  2413. }
  2414. function handleDeferred(deferred) {
  2415. forEach(deferred, function(d) { d(); });
  2416. }
  2417. function handleProcess(process, context) {
  2418. handleFlowElementsContainer(process, context);
  2419. handleIoSpecification(process.ioSpecification, context);
  2420. handleArtifacts(process.artifacts, context);
  2421. // log process handled
  2422. handledProcesses.push(process);
  2423. }
  2424. function handleUnhandledProcesses(rootElements) {
  2425. // walk through all processes that have not yet been drawn and draw them
  2426. // if they contain lanes with DI information.
  2427. // we do this to pass the free-floating lane test cases in the MIWG test suite
  2428. var processes = filter(rootElements, function(e) {
  2429. return is(e, 'bpmn:Process') && e.laneSets && handledProcesses.indexOf(e) === -1;
  2430. });
  2431. processes.forEach(contextual(handleProcess));
  2432. }
  2433. function handleMessageFlow(messageFlow, context) {
  2434. visitIfDi(messageFlow, context);
  2435. }
  2436. function handleMessageFlows(messageFlows, context) {
  2437. forEach(messageFlows, contextual(handleMessageFlow, context));
  2438. }
  2439. function handleDataAssociation(association, context) {
  2440. visitIfDi(association, context);
  2441. }
  2442. function handleDataInput(dataInput, context) {
  2443. visitIfDi(dataInput, context);
  2444. }
  2445. function handleDataOutput(dataOutput, context) {
  2446. visitIfDi(dataOutput, context);
  2447. }
  2448. function handleArtifact(artifact, context) {
  2449. // bpmn:TextAnnotation
  2450. // bpmn:Group
  2451. // bpmn:Association
  2452. visitIfDi(artifact, context);
  2453. }
  2454. function handleArtifacts(artifacts, context) {
  2455. forEach(artifacts, function(e) {
  2456. if (is(e, 'bpmn:Association')) {
  2457. deferred.push(function() {
  2458. handleArtifact(e, context);
  2459. });
  2460. } else {
  2461. handleArtifact(e, context);
  2462. }
  2463. });
  2464. }
  2465. function handleIoSpecification(ioSpecification, context) {
  2466. if (!ioSpecification) {
  2467. return;
  2468. }
  2469. forEach(ioSpecification.dataInputs, contextual(handleDataInput, context));
  2470. forEach(ioSpecification.dataOutputs, contextual(handleDataOutput, context));
  2471. }
  2472. function handleSubProcess(subProcess, context) {
  2473. handleFlowElementsContainer(subProcess, context);
  2474. handleArtifacts(subProcess.artifacts, context);
  2475. }
  2476. function handleFlowNode(flowNode, context) {
  2477. var childCtx = visitIfDi(flowNode, context);
  2478. if (is(flowNode, 'bpmn:SubProcess')) {
  2479. handleSubProcess(flowNode, childCtx || context);
  2480. }
  2481. }
  2482. function handleSequenceFlow(sequenceFlow, context) {
  2483. visitIfDi(sequenceFlow, context);
  2484. }
  2485. function handleDataElement(dataObject, context) {
  2486. visitIfDi(dataObject, context);
  2487. }
  2488. function handleBoundaryEvent(dataObject, context) {
  2489. visitIfDi(dataObject, context);
  2490. }
  2491. function handleLane(lane, context) {
  2492. var newContext = visitIfDi(lane, context);
  2493. if (lane.childLaneSet) {
  2494. handleLaneSet(lane.childLaneSet, newContext || context);
  2495. } else {
  2496. var filterList = filter(lane.flowNodeRef, function(e) {
  2497. return e.$type !== 'bpmn:BoundaryEvent';
  2498. });
  2499. handleFlowElements(filterList, newContext || context);
  2500. }
  2501. }
  2502. function handleLaneSet(laneSet, context) {
  2503. forEach(laneSet.lanes, contextual(handleLane, context));
  2504. }
  2505. function handleLaneSets(laneSets, context) {
  2506. forEach(laneSets, contextual(handleLaneSet, context));
  2507. }
  2508. function handleFlowElementsContainer(container, context) {
  2509. if (container.laneSets) {
  2510. handleLaneSets(container.laneSets, context);
  2511. handleNonFlowNodes(container.flowElements);
  2512. } else {
  2513. handleFlowElements(container.flowElements, context);
  2514. }
  2515. }
  2516. function handleNonFlowNodes(flowElements, context) {
  2517. forEach(flowElements, function(e) {
  2518. if (is(e, 'bpmn:SequenceFlow')) {
  2519. deferred.push(function() {
  2520. handleSequenceFlow(e, context);
  2521. });
  2522. } else if (is(e, 'bpmn:BoundaryEvent')) {
  2523. deferred.unshift(function() {
  2524. handleBoundaryEvent(e, context);
  2525. });
  2526. } else if (is(e, 'bpmn:DataObject')) {
  2527. // SKIP (assume correct referencing via DataObjectReference)
  2528. } else if (is(e, 'bpmn:DataStoreReference')) {
  2529. handleDataElement(e, context);
  2530. } else if (is(e, 'bpmn:DataObjectReference')) {
  2531. handleDataElement(e, context);
  2532. }
  2533. });
  2534. }
  2535. function handleFlowElements(flowElements, context) {
  2536. forEach(flowElements, function(e) {
  2537. if (is(e, 'bpmn:SequenceFlow')) {
  2538. deferred.push(function() {
  2539. handleSequenceFlow(e, context);
  2540. });
  2541. } else if (is(e, 'bpmn:BoundaryEvent')) {
  2542. deferred.unshift(function() {
  2543. handleBoundaryEvent(e, context);
  2544. });
  2545. } else if (is(e, 'bpmn:FlowNode')) {
  2546. handleFlowNode(e, context);
  2547. if (is(e, 'bpmn:Activity')) {
  2548. handleIoSpecification(e.ioSpecification, context);
  2549. // defer handling of associations
  2550. deferred.push(function() {
  2551. forEach(e.dataInputAssociations, contextual(handleDataAssociation, context));
  2552. forEach(e.dataOutputAssociations, contextual(handleDataAssociation, context));
  2553. });
  2554. }
  2555. } else if (is(e, 'bpmn:DataObject')) {
  2556. // SKIP (assume correct referencing via DataObjectReference)
  2557. } else if (is(e, 'bpmn:DataStoreReference')) {
  2558. handleDataElement(e, context);
  2559. } else if (is(e, 'bpmn:DataObjectReference')) {
  2560. handleDataElement(e, context);
  2561. } else {
  2562. logError(
  2563. 'unrecognized flowElement ' + elementToString(e) + ' in context ' +
  2564. (context ? elementToString(context.businessObject) : null),
  2565. { element: e, context: context });
  2566. }
  2567. });
  2568. }
  2569. function handleParticipant(participant, context) {
  2570. var newCtx = visitIfDi(participant, context);
  2571. var process = participant.processRef;
  2572. if (process) {
  2573. handleProcess(process, newCtx || context);
  2574. }
  2575. }
  2576. function handleCollaboration(collaboration) {
  2577. forEach(collaboration.participants, contextual(handleParticipant));
  2578. handleArtifacts(collaboration.artifacts);
  2579. // handle message flows latest in the process
  2580. deferred.push(function() {
  2581. handleMessageFlows(collaboration.messageFlows);
  2582. });
  2583. }
  2584. ///// API ////////////////////////////////
  2585. return {
  2586. handleDefinitions: handleDefinitions
  2587. };
  2588. }
  2589. module.exports = BpmnTreeWalker;
  2590. },{"10":10,"202":202,"84":84,"85":85,"86":86}],9:[function(_dereq_,module,exports){
  2591. 'use strict';
  2592. var BpmnTreeWalker = _dereq_(8);
  2593. /**
  2594. * Import the definitions into a diagram.
  2595. *
  2596. * Errors and warnings are reported through the specified callback.
  2597. *
  2598. * @param {Diagram} diagram
  2599. * @param {ModdleElement} definitions
  2600. * @param {Function} done the callback, invoked with (err, [ warning ]) once the import is done
  2601. */
  2602. function importBpmnDiagram(diagram, definitions, done) {
  2603. var importer = diagram.get('bpmnImporter'),
  2604. eventBus = diagram.get('eventBus');
  2605. var error,
  2606. warnings = [];
  2607. function parse(definitions) {
  2608. var visitor = {
  2609. root: function(element) {
  2610. return importer.add(element);
  2611. },
  2612. element: function(element, parentShape) {
  2613. return importer.add(element, parentShape);
  2614. },
  2615. error: function(message, context) {
  2616. warnings.push({ message: message, context: context });
  2617. }
  2618. };
  2619. var walker = new BpmnTreeWalker(visitor);
  2620. // import
  2621. walker.handleDefinitions(definitions);
  2622. }
  2623. eventBus.fire('import.start');
  2624. try {
  2625. parse(definitions);
  2626. } catch (e) {
  2627. error = e;
  2628. }
  2629. eventBus.fire(error ? 'import.error' : 'import.success', { error: error, warnings: warnings });
  2630. done(error, warnings);
  2631. }
  2632. module.exports.importBpmnDiagram = importBpmnDiagram;
  2633. },{"8":8}],10:[function(_dereq_,module,exports){
  2634. 'use strict';
  2635. module.exports.elementToString = function(e) {
  2636. if (!e) {
  2637. return '<null>';
  2638. }
  2639. return '<' + e.$type + (e.id ? ' id="' + e.id : '') + '" />';
  2640. };
  2641. },{}],11:[function(_dereq_,module,exports){
  2642. module.exports = {
  2643. bpmnImporter: [ 'type', _dereq_(7) ]
  2644. };
  2645. },{"7":7}],12:[function(_dereq_,module,exports){
  2646. 'use strict';
  2647. var is = _dereq_(14).is,
  2648. getBusinessObject = _dereq_(14).getBusinessObject;
  2649. module.exports.isExpanded = function(element) {
  2650. if (is(element, 'bpmn:CallActivity')) {
  2651. return false;
  2652. }
  2653. if (is(element, 'bpmn:SubProcess')) {
  2654. return getBusinessObject(element).di.isExpanded;
  2655. }
  2656. if (is(element, 'bpmn:Participant')) {
  2657. return !!getBusinessObject(element).processRef;
  2658. }
  2659. return true;
  2660. };
  2661. },{"14":14}],13:[function(_dereq_,module,exports){
  2662. 'use strict';
  2663. var assign = _dereq_(177);
  2664. var DEFAULT_LABEL_SIZE = module.exports.DEFAULT_LABEL_SIZE = {
  2665. width: 90,
  2666. height: 20
  2667. };
  2668. /**
  2669. * Returns true if the given semantic has an external label
  2670. *
  2671. * @param {BpmnElement} semantic
  2672. * @return {Boolean} true if has label
  2673. */
  2674. module.exports.hasExternalLabel = function(semantic) {
  2675. return semantic.$instanceOf('bpmn:Event') ||
  2676. semantic.$instanceOf('bpmn:Gateway') ||
  2677. semantic.$instanceOf('bpmn:DataStoreReference') ||
  2678. semantic.$instanceOf('bpmn:DataObjectReference') ||
  2679. semantic.$instanceOf('bpmn:SequenceFlow') ||
  2680. semantic.$instanceOf('bpmn:MessageFlow');
  2681. };
  2682. /**
  2683. * Get the middle of a number of waypoints
  2684. *
  2685. * @param {Array<Point>} waypoints
  2686. * @return {Point} the mid point
  2687. */
  2688. var getWaypointsMid = module.exports.getWaypointsMid = function(waypoints) {
  2689. var mid = waypoints.length / 2 - 1;
  2690. var first = waypoints[Math.floor(mid)];
  2691. var second = waypoints[Math.ceil(mid + 0.01)];
  2692. return {
  2693. x: first.x + (second.x - first.x) / 2,
  2694. y: first.y + (second.y - first.y) / 2
  2695. };
  2696. };
  2697. var getExternalLabelMid = module.exports.getExternalLabelMid = function(element) {
  2698. if (element.waypoints) {
  2699. return getWaypointsMid(element.waypoints);
  2700. } else {
  2701. return {
  2702. x: element.x + element.width / 2,
  2703. y: element.y + element.height + DEFAULT_LABEL_SIZE.height / 2
  2704. };
  2705. }
  2706. };
  2707. /**
  2708. * Returns the bounds of an elements label, parsed from the elements DI or
  2709. * generated from its bounds.
  2710. *
  2711. * @param {BpmnElement} semantic
  2712. * @param {djs.model.Base} element
  2713. */
  2714. module.exports.getExternalLabelBounds = function(semantic, element) {
  2715. var mid,
  2716. size,
  2717. bounds,
  2718. di = semantic.di,
  2719. label = di.label;
  2720. if (label && label.bounds) {
  2721. bounds = label.bounds;
  2722. size = {
  2723. width: Math.max(DEFAULT_LABEL_SIZE.width, bounds.width),
  2724. height: bounds.height
  2725. };
  2726. mid = {
  2727. x: bounds.x + bounds.width / 2,
  2728. y: bounds.y + bounds.height / 2
  2729. };
  2730. } else {
  2731. mid = getExternalLabelMid(element);
  2732. size = DEFAULT_LABEL_SIZE;
  2733. }
  2734. return assign({
  2735. x: mid.x - size.width / 2,
  2736. y: mid.y - size.height / 2
  2737. }, size);
  2738. };
  2739. },{"177":177}],14:[function(_dereq_,module,exports){
  2740. 'use strict';
  2741. /**
  2742. * Is an element of the given BPMN type?
  2743. *
  2744. * @param {djs.model.Base|ModdleElement} element
  2745. * @param {String} type
  2746. *
  2747. * @return {Boolean}
  2748. */
  2749. function is(element, type) {
  2750. var bo = getBusinessObject(element);
  2751. return bo && bo.$instanceOf(type);
  2752. }
  2753. module.exports.is = is;
  2754. /**
  2755. * Return the business object for a given element.
  2756. *
  2757. * @param {djs.model.Base|ModdleElement} element
  2758. *
  2759. * @return {ModdleElement}
  2760. */
  2761. function getBusinessObject(element) {
  2762. return (element && element.businessObject) || element;
  2763. }
  2764. module.exports.getBusinessObject = getBusinessObject;
  2765. },{}],15:[function(_dereq_,module,exports){
  2766. module.exports = _dereq_(17);
  2767. },{"17":17}],16:[function(_dereq_,module,exports){
  2768. 'use strict';
  2769. var isString = _dereq_(174),
  2770. isFunction = _dereq_(169),
  2771. assign = _dereq_(177);
  2772. var Moddle = _dereq_(23),
  2773. XmlReader = _dereq_(19),
  2774. XmlWriter = _dereq_(20);
  2775. /**
  2776. * A sub class of {@link Moddle} with support for import and export of BPMN 2.0 xml files.
  2777. *
  2778. * @class BpmnModdle
  2779. * @extends Moddle
  2780. *
  2781. * @param {Object|Array} packages to use for instantiating the model
  2782. * @param {Object} [options] additional options to pass over
  2783. */
  2784. function BpmnModdle(packages, options) {
  2785. Moddle.call(this, packages, options);
  2786. }
  2787. BpmnModdle.prototype = Object.create(Moddle.prototype);
  2788. module.exports = BpmnModdle;
  2789. /**
  2790. * Instantiates a BPMN model tree from a given xml string.
  2791. *
  2792. * @param {String} xmlStr
  2793. * @param {String} [typeName='bpmn:Definitions'] name of the root element
  2794. * @param {Object} [options] options to pass to the underlying reader
  2795. * @param {Function} done callback that is invoked with (err, result, parseContext)
  2796. * once the import completes
  2797. */
  2798. BpmnModdle.prototype.fromXML = function(xmlStr, typeName, options, done) {
  2799. if (!isString(typeName)) {
  2800. done = options;
  2801. options = typeName;
  2802. typeName = 'bpmn:Definitions';
  2803. }
  2804. if (isFunction(options)) {
  2805. done = options;
  2806. options = {};
  2807. }
  2808. var reader = new XmlReader(assign({ model: this, lax: true }, options));
  2809. var rootHandler = reader.handler(typeName);
  2810. reader.fromXML(xmlStr, rootHandler, done);
  2811. };
  2812. /**
  2813. * Serializes a BPMN 2.0 object tree to XML.
  2814. *
  2815. * @param {String} element the root element, typically an instance of `bpmn:Definitions`
  2816. * @param {Object} [options] to pass to the underlying writer
  2817. * @param {Function} done callback invoked with (err, xmlStr) once the import completes
  2818. */
  2819. BpmnModdle.prototype.toXML = function(element, options, done) {
  2820. if (isFunction(options)) {
  2821. done = options;
  2822. options = {};
  2823. }
  2824. var writer = new XmlWriter(options);
  2825. try {
  2826. var result = writer.toXML(element);
  2827. done(null, result);
  2828. } catch (e) {
  2829. done(e);
  2830. }
  2831. };
  2832. },{"169":169,"174":174,"177":177,"19":19,"20":20,"23":23}],17:[function(_dereq_,module,exports){
  2833. 'use strict';
  2834. var assign = _dereq_(177);
  2835. var BpmnModdle = _dereq_(16);
  2836. var packages = {
  2837. bpmn: _dereq_(32),
  2838. bpmndi: _dereq_(33),
  2839. dc: _dereq_(34),
  2840. di: _dereq_(35)
  2841. };
  2842. module.exports = function(additionalPackages, options) {
  2843. return new BpmnModdle(assign({}, packages, additionalPackages), options);
  2844. };
  2845. },{"16":16,"177":177,"32":32,"33":33,"34":34,"35":35}],18:[function(_dereq_,module,exports){
  2846. 'use strict';
  2847. function capitalize(string) {
  2848. return string.charAt(0).toUpperCase() + string.slice(1);
  2849. }
  2850. function lower(string) {
  2851. return string.charAt(0).toLowerCase() + string.slice(1);
  2852. }
  2853. function hasLowerCaseAlias(pkg) {
  2854. return pkg.xml && pkg.xml.tagAlias === 'lowerCase';
  2855. }
  2856. module.exports.aliasToName = function(alias, pkg) {
  2857. if (hasLowerCaseAlias(pkg)) {
  2858. return capitalize(alias);
  2859. } else {
  2860. return alias;
  2861. }
  2862. };
  2863. module.exports.nameToAlias = function(name, pkg) {
  2864. if (hasLowerCaseAlias(pkg)) {
  2865. return lower(name);
  2866. } else {
  2867. return name;
  2868. }
  2869. };
  2870. module.exports.DEFAULT_NS_MAP = {
  2871. 'xsi': 'http://www.w3.org/2001/XMLSchema-instance'
  2872. };
  2873. var XSI_TYPE = module.exports.XSI_TYPE = 'xsi:type';
  2874. function serializeFormat(element) {
  2875. return element.xml && element.xml.serialize;
  2876. }
  2877. module.exports.serializeAsType = function(element) {
  2878. return serializeFormat(element) === XSI_TYPE;
  2879. };
  2880. module.exports.serializeAsProperty = function(element) {
  2881. return serializeFormat(element) === 'property';
  2882. };
  2883. },{}],19:[function(_dereq_,module,exports){
  2884. 'use strict';
  2885. var reduce = _dereq_(90),
  2886. forEach = _dereq_(86),
  2887. find = _dereq_(85),
  2888. assign = _dereq_(177),
  2889. defer = _dereq_(94);
  2890. var Stack = _dereq_(22),
  2891. SaxParser = _dereq_(21).parser,
  2892. Moddle = _dereq_(23),
  2893. parseNameNs = _dereq_(28).parseName,
  2894. Types = _dereq_(31),
  2895. coerceType = Types.coerceType,
  2896. isSimpleType = Types.isSimple,
  2897. common = _dereq_(18),
  2898. XSI_TYPE = common.XSI_TYPE,
  2899. XSI_URI = common.DEFAULT_NS_MAP.xsi,
  2900. serializeAsType = common.serializeAsType,
  2901. aliasToName = common.aliasToName;
  2902. function parseNodeAttributes(node) {
  2903. var nodeAttrs = node.attributes;
  2904. return reduce(nodeAttrs, function(result, v, k) {
  2905. var name, ns;
  2906. if (!v.local) {
  2907. name = v.prefix;
  2908. } else {
  2909. ns = parseNameNs(v.name, v.prefix);
  2910. name = ns.name;
  2911. }
  2912. result[name] = v.value;
  2913. return result;
  2914. }, {});
  2915. }
  2916. function normalizeType(node, attr, model) {
  2917. var nameNs = parseNameNs(attr.value);
  2918. var uri = node.ns[nameNs.prefix || ''],
  2919. localName = nameNs.localName,
  2920. pkg = uri && model.getPackage(uri),
  2921. typePrefix;
  2922. if (pkg) {
  2923. typePrefix = pkg.xml && pkg.xml.typePrefix;
  2924. if (typePrefix && localName.indexOf(typePrefix) === 0) {
  2925. localName = localName.slice(typePrefix.length);
  2926. }
  2927. attr.value = pkg.prefix + ':' + localName;
  2928. }
  2929. }
  2930. /**
  2931. * Normalizes namespaces for a node given an optional default namespace and a
  2932. * number of mappings from uris to default prefixes.
  2933. *
  2934. * @param {XmlNode} node
  2935. * @param {Model} model the model containing all registered namespaces
  2936. * @param {Uri} defaultNsUri
  2937. */
  2938. function normalizeNamespaces(node, model, defaultNsUri) {
  2939. var uri, prefix;
  2940. uri = node.uri || defaultNsUri;
  2941. if (uri) {
  2942. var pkg = model.getPackage(uri);
  2943. if (pkg) {
  2944. prefix = pkg.prefix;
  2945. } else {
  2946. prefix = node.prefix;
  2947. }
  2948. node.prefix = prefix;
  2949. node.uri = uri;
  2950. }
  2951. forEach(node.attributes, function(attr) {
  2952. // normalize xsi:type attributes because the
  2953. // assigned type may or may not be namespace prefixed
  2954. if (attr.uri === XSI_URI && attr.local === 'type') {
  2955. normalizeType(node, attr, model);
  2956. }
  2957. normalizeNamespaces(attr, model, null);
  2958. });
  2959. }
  2960. /**
  2961. * A parse context.
  2962. *
  2963. * @class
  2964. *
  2965. * @param {Object} options
  2966. * @param {ElementHandler} options.parseRoot the root handler for parsing a document
  2967. * @param {boolean} [options.lax=false] whether or not to ignore invalid elements
  2968. */
  2969. function Context(options) {
  2970. /**
  2971. * @property {ElementHandler} parseRoot
  2972. */
  2973. /**
  2974. * @property {Boolean} lax
  2975. */
  2976. assign(this, options);
  2977. var elementsById = this.elementsById = {};
  2978. var references = this.references = [];
  2979. var warnings = this.warnings = [];
  2980. this.addReference = function(reference) {
  2981. references.push(reference);
  2982. };
  2983. this.addElement = function(id, element) {
  2984. if (!id || !element) {
  2985. throw new Error('[xml-reader] id or ctx must not be null');
  2986. }
  2987. elementsById[id] = element;
  2988. };
  2989. this.addWarning = function (w) {
  2990. warnings.push(w);
  2991. };
  2992. }
  2993. function BaseHandler() {}
  2994. BaseHandler.prototype.handleEnd = function() {};
  2995. BaseHandler.prototype.handleText = function() {};
  2996. BaseHandler.prototype.handleNode = function() {};
  2997. /**
  2998. * A simple pass through handler that does nothing except for
  2999. * ignoring all input it receives.
  3000. *
  3001. * This is used to ignore unknown elements and
  3002. * attributes.
  3003. */
  3004. function NoopHandler() { }
  3005. NoopHandler.prototype = new BaseHandler();
  3006. NoopHandler.prototype.handleNode = function() {
  3007. return this;
  3008. };
  3009. function BodyHandler() {}
  3010. BodyHandler.prototype = new BaseHandler();
  3011. BodyHandler.prototype.handleText = function(text) {
  3012. this.body = (this.body || '') + text;
  3013. };
  3014. function ReferenceHandler(property, context) {
  3015. this.property = property;
  3016. this.context = context;
  3017. }
  3018. ReferenceHandler.prototype = new BodyHandler();
  3019. ReferenceHandler.prototype.handleNode = function(node) {
  3020. if (this.element) {
  3021. throw new Error('expected no sub nodes');
  3022. } else {
  3023. this.element = this.createReference(node);
  3024. }
  3025. return this;
  3026. };
  3027. ReferenceHandler.prototype.handleEnd = function() {
  3028. this.element.id = this.body;
  3029. };
  3030. ReferenceHandler.prototype.createReference = function() {
  3031. return {
  3032. property: this.property.ns.name,
  3033. id: ''
  3034. };
  3035. };
  3036. function ValueHandler(propertyDesc, element) {
  3037. this.element = element;
  3038. this.propertyDesc = propertyDesc;
  3039. }
  3040. ValueHandler.prototype = new BodyHandler();
  3041. ValueHandler.prototype.handleEnd = function() {
  3042. var value = this.body,
  3043. element = this.element,
  3044. propertyDesc = this.propertyDesc;
  3045. value = coerceType(propertyDesc.type, value);
  3046. if (propertyDesc.isMany) {
  3047. element.get(propertyDesc.name).push(value);
  3048. } else {
  3049. element.set(propertyDesc.name, value);
  3050. }
  3051. };
  3052. function BaseElementHandler() {}
  3053. BaseElementHandler.prototype = Object.create(BodyHandler.prototype);
  3054. BaseElementHandler.prototype.handleNode = function(node) {
  3055. var parser = this,
  3056. element = this.element,
  3057. id;
  3058. if (!element) {
  3059. element = this.element = this.createElement(node);
  3060. id = element.id;
  3061. if (id) {
  3062. this.context.addElement(id, element);
  3063. }
  3064. } else {
  3065. parser = this.handleChild(node);
  3066. }
  3067. return parser;
  3068. };
  3069. /**
  3070. * @class XMLReader.ElementHandler
  3071. *
  3072. */
  3073. function ElementHandler(model, type, context) {
  3074. this.model = model;
  3075. this.type = model.getType(type);
  3076. this.context = context;
  3077. }
  3078. ElementHandler.prototype = new BaseElementHandler();
  3079. ElementHandler.prototype.addReference = function(reference) {
  3080. this.context.addReference(reference);
  3081. };
  3082. ElementHandler.prototype.handleEnd = function() {
  3083. var value = this.body,
  3084. element = this.element,
  3085. descriptor = element.$descriptor,
  3086. bodyProperty = descriptor.bodyProperty;
  3087. if (bodyProperty && value !== undefined) {
  3088. value = coerceType(bodyProperty.type, value);
  3089. element.set(bodyProperty.name, value);
  3090. }
  3091. };
  3092. /**
  3093. * Create an instance of the model from the given node.
  3094. *
  3095. * @param {Element} node the xml node
  3096. */
  3097. ElementHandler.prototype.createElement = function(node) {
  3098. var attributes = parseNodeAttributes(node),
  3099. Type = this.type,
  3100. descriptor = Type.$descriptor,
  3101. context = this.context,
  3102. instance = new Type({});
  3103. forEach(attributes, function(value, name) {
  3104. var prop = descriptor.propertiesByName[name];
  3105. if (prop && prop.isReference) {
  3106. context.addReference({
  3107. element: instance,
  3108. property: prop.ns.name,
  3109. id: value
  3110. });
  3111. } else {
  3112. if (prop) {
  3113. value = coerceType(prop.type, value);
  3114. }
  3115. instance.set(name, value);
  3116. }
  3117. });
  3118. return instance;
  3119. };
  3120. ElementHandler.prototype.getPropertyForNode = function(node) {
  3121. var nameNs = parseNameNs(node.local, node.prefix);
  3122. var type = this.type,
  3123. model = this.model,
  3124. descriptor = type.$descriptor;
  3125. var propertyName = nameNs.name,
  3126. property = descriptor.propertiesByName[propertyName],
  3127. elementTypeName,
  3128. elementType,
  3129. typeAnnotation;
  3130. // search for properties by name first
  3131. if (property) {
  3132. if (serializeAsType(property)) {
  3133. typeAnnotation = node.attributes[XSI_TYPE];
  3134. // xsi type is optional, if it does not exists the
  3135. // default type is assumed
  3136. if (typeAnnotation) {
  3137. elementTypeName = typeAnnotation.value;
  3138. // TODO: extract real name from attribute
  3139. elementType = model.getType(elementTypeName);
  3140. return assign({}, property, { effectiveType: elementType.$descriptor.name });
  3141. }
  3142. }
  3143. // search for properties by name first
  3144. return property;
  3145. }
  3146. var pkg = model.getPackage(nameNs.prefix);
  3147. if (pkg) {
  3148. elementTypeName = nameNs.prefix + ':' + aliasToName(nameNs.localName, descriptor.$pkg);
  3149. elementType = model.getType(elementTypeName);
  3150. // search for collection members later
  3151. property = find(descriptor.properties, function(p) {
  3152. return !p.isVirtual && !p.isReference && !p.isAttribute && elementType.hasType(p.type);
  3153. });
  3154. if (property) {
  3155. return assign({}, property, { effectiveType: elementType.$descriptor.name });
  3156. }
  3157. } else {
  3158. // parse unknown element (maybe extension)
  3159. property = find(descriptor.properties, function(p) {
  3160. return !p.isReference && !p.isAttribute && p.type === 'Element';
  3161. });
  3162. if (property) {
  3163. return property;
  3164. }
  3165. }
  3166. throw new Error('unrecognized element <' + nameNs.name + '>');
  3167. };
  3168. ElementHandler.prototype.toString = function() {
  3169. return 'ElementDescriptor[' + this.type.$descriptor.name + ']';
  3170. };
  3171. ElementHandler.prototype.valueHandler = function(propertyDesc, element) {
  3172. return new ValueHandler(propertyDesc, element);
  3173. };
  3174. ElementHandler.prototype.referenceHandler = function(propertyDesc) {
  3175. return new ReferenceHandler(propertyDesc, this.context);
  3176. };
  3177. ElementHandler.prototype.handler = function(type) {
  3178. if (type === 'Element') {
  3179. return new GenericElementHandler(this.model, type, this.context);
  3180. } else {
  3181. return new ElementHandler(this.model, type, this.context);
  3182. }
  3183. };
  3184. /**
  3185. * Handle the child element parsing
  3186. *
  3187. * @param {Element} node the xml node
  3188. */
  3189. ElementHandler.prototype.handleChild = function(node) {
  3190. var propertyDesc, type, element, childHandler;
  3191. propertyDesc = this.getPropertyForNode(node);
  3192. element = this.element;
  3193. type = propertyDesc.effectiveType || propertyDesc.type;
  3194. if (isSimpleType(type)) {
  3195. return this.valueHandler(propertyDesc, element);
  3196. }
  3197. if (propertyDesc.isReference) {
  3198. childHandler = this.referenceHandler(propertyDesc).handleNode(node);
  3199. } else {
  3200. childHandler = this.handler(type).handleNode(node);
  3201. }
  3202. var newElement = childHandler.element;
  3203. // child handles may decide to skip elements
  3204. // by not returning anything
  3205. if (newElement !== undefined) {
  3206. if (propertyDesc.isMany) {
  3207. element.get(propertyDesc.name).push(newElement);
  3208. } else {
  3209. element.set(propertyDesc.name, newElement);
  3210. }
  3211. if (propertyDesc.isReference) {
  3212. assign(newElement, {
  3213. element: element
  3214. });
  3215. this.context.addReference(newElement);
  3216. } else {
  3217. // establish child -> parent relationship
  3218. newElement.$parent = element;
  3219. }
  3220. }
  3221. return childHandler;
  3222. };
  3223. function GenericElementHandler(model, type, context) {
  3224. this.model = model;
  3225. this.context = context;
  3226. }
  3227. GenericElementHandler.prototype = Object.create(BaseElementHandler.prototype);
  3228. GenericElementHandler.prototype.createElement = function(node) {
  3229. var name = node.name,
  3230. prefix = node.prefix,
  3231. uri = node.ns[prefix],
  3232. attributes = node.attributes;
  3233. return this.model.createAny(name, uri, attributes);
  3234. };
  3235. GenericElementHandler.prototype.handleChild = function(node) {
  3236. var handler = new GenericElementHandler(this.model, 'Element', this.context).handleNode(node),
  3237. element = this.element;
  3238. var newElement = handler.element,
  3239. children;
  3240. if (newElement !== undefined) {
  3241. children = element.$children = element.$children || [];
  3242. children.push(newElement);
  3243. // establish child -> parent relationship
  3244. newElement.$parent = element;
  3245. }
  3246. return handler;
  3247. };
  3248. GenericElementHandler.prototype.handleText = function(text) {
  3249. this.body = this.body || '' + text;
  3250. };
  3251. GenericElementHandler.prototype.handleEnd = function() {
  3252. if (this.body) {
  3253. this.element.$body = this.body;
  3254. }
  3255. };
  3256. /**
  3257. * A reader for a meta-model
  3258. *
  3259. * @param {Object} options
  3260. * @param {Model} options.model used to read xml files
  3261. * @param {Boolean} options.lax whether to make parse errors warnings
  3262. */
  3263. function XMLReader(options) {
  3264. if (options instanceof Moddle) {
  3265. options = {
  3266. model: options
  3267. };
  3268. }
  3269. assign(this, { lax: false }, options);
  3270. }
  3271. XMLReader.prototype.fromXML = function(xml, rootHandler, done) {
  3272. var model = this.model,
  3273. lax = this.lax,
  3274. context = new Context({
  3275. parseRoot: rootHandler
  3276. });
  3277. var parser = new SaxParser(true, { xmlns: true, trim: true }),
  3278. stack = new Stack();
  3279. rootHandler.context = context;
  3280. // push root handler
  3281. stack.push(rootHandler);
  3282. function resolveReferences() {
  3283. var elementsById = context.elementsById;
  3284. var references = context.references;
  3285. var i, r;
  3286. for (i = 0; !!(r = references[i]); i++) {
  3287. var element = r.element;
  3288. var reference = elementsById[r.id];
  3289. var property = element.$descriptor.propertiesByName[r.property];
  3290. if (!reference) {
  3291. context.addWarning({
  3292. message: 'unresolved reference <' + r.id + '>',
  3293. element: r.element,
  3294. property: r.property,
  3295. value: r.id
  3296. });
  3297. }
  3298. if (property.isMany) {
  3299. var collection = element.get(property.name),
  3300. idx = collection.indexOf(r);
  3301. if (!reference) {
  3302. // remove unresolvable reference
  3303. collection.splice(idx, 1);
  3304. } else {
  3305. // update reference
  3306. collection[idx] = reference;
  3307. }
  3308. } else {
  3309. element.set(property.name, reference);
  3310. }
  3311. }
  3312. }
  3313. function handleClose(tagName) {
  3314. stack.pop().handleEnd();
  3315. }
  3316. function handleOpen(node) {
  3317. var handler = stack.peek();
  3318. normalizeNamespaces(node, model);
  3319. try {
  3320. stack.push(handler.handleNode(node));
  3321. } catch (e) {
  3322. var line = this.line,
  3323. column = this.column;
  3324. var message =
  3325. 'unparsable content <' + node.name + '> detected\n\t' +
  3326. 'line: ' + line + '\n\t' +
  3327. 'column: ' + column + '\n\t' +
  3328. 'nested error: ' + e.message;
  3329. if (lax) {
  3330. context.addWarning({
  3331. message: message,
  3332. error: e
  3333. });
  3334. console.warn('could not parse node');
  3335. console.warn(e);
  3336. stack.push(new NoopHandler());
  3337. } else {
  3338. console.error('could not parse document');
  3339. console.error(e);
  3340. throw new Error(message);
  3341. }
  3342. }
  3343. }
  3344. function handleText(text) {
  3345. stack.peek().handleText(text);
  3346. }
  3347. parser.onopentag = handleOpen;
  3348. parser.oncdata = parser.ontext = handleText;
  3349. parser.onclosetag = handleClose;
  3350. parser.onend = resolveReferences;
  3351. // deferred parse XML to make loading really ascnchronous
  3352. // this ensures the execution environment (node or browser)
  3353. // is kept responsive and that certain optimization strategies
  3354. // can kick in
  3355. defer(function() {
  3356. var error;
  3357. try {
  3358. parser.write(xml).close();
  3359. } catch (e) {
  3360. error = e;
  3361. }
  3362. done(error, error ? undefined : rootHandler.element, context);
  3363. });
  3364. };
  3365. XMLReader.prototype.handler = function(name) {
  3366. return new ElementHandler(this.model, name);
  3367. };
  3368. module.exports = XMLReader;
  3369. module.exports.ElementHandler = ElementHandler;
  3370. },{"177":177,"18":18,"21":21,"22":22,"23":23,"28":28,"31":31,"85":85,"86":86,"90":90,"94":94}],20:[function(_dereq_,module,exports){
  3371. 'use strict';
  3372. var map = _dereq_(89),
  3373. forEach = _dereq_(86),
  3374. isString = _dereq_(174),
  3375. filter = _dereq_(84),
  3376. assign = _dereq_(177);
  3377. var Types = _dereq_(31),
  3378. parseNameNs = _dereq_(28).parseName,
  3379. common = _dereq_(18),
  3380. nameToAlias = common.nameToAlias,
  3381. serializeAsType = common.serializeAsType,
  3382. serializeAsProperty = common.serializeAsProperty;
  3383. var XML_PREAMBLE = '<?xml version="1.0" encoding="UTF-8"?>\n',
  3384. ESCAPE_CHARS = /(<|>|'|"|&|\n\r|\n)/g,
  3385. DEFAULT_NS_MAP = common.DEFAULT_NS_MAP,
  3386. XSI_TYPE = common.XSI_TYPE;
  3387. function nsName(ns) {
  3388. if (isString(ns)) {
  3389. return ns;
  3390. } else {
  3391. return (ns.prefix ? ns.prefix + ':' : '') + ns.localName;
  3392. }
  3393. }
  3394. function getElementNs(ns, descriptor) {
  3395. if (descriptor.isGeneric) {
  3396. return descriptor.name;
  3397. } else {
  3398. return assign({ localName: nameToAlias(descriptor.ns.localName, descriptor.$pkg) }, ns);
  3399. }
  3400. }
  3401. function getPropertyNs(ns, descriptor) {
  3402. return assign({ localName: descriptor.ns.localName }, ns);
  3403. }
  3404. function getSerializableProperties(element) {
  3405. var descriptor = element.$descriptor;
  3406. return filter(descriptor.properties, function(p) {
  3407. var name = p.name;
  3408. // do not serialize defaults
  3409. if (!element.hasOwnProperty(name)) {
  3410. return false;
  3411. }
  3412. var value = element[name];
  3413. // do not serialize default equals
  3414. if (value === p.default) {
  3415. return false;
  3416. }
  3417. return p.isMany ? value.length : true;
  3418. });
  3419. }
  3420. var ESCAPE_MAP = {
  3421. '\n': '10',
  3422. '\n\r': '10',
  3423. '"': '34',
  3424. '\'': '39',
  3425. '<': '60',
  3426. '>': '62',
  3427. '&': '38'
  3428. };
  3429. /**
  3430. * Escape a string attribute to not contain any bad values (line breaks, '"', ...)
  3431. *
  3432. * @param {String} str the string to escape
  3433. * @return {String} the escaped string
  3434. */
  3435. function escapeAttr(str) {
  3436. // ensure we are handling strings here
  3437. str = isString(str) ? str : '' + str;
  3438. return str.replace(ESCAPE_CHARS, function(str) {
  3439. return '&#' + ESCAPE_MAP[str] + ';';
  3440. });
  3441. }
  3442. function filterAttributes(props) {
  3443. return filter(props, function(p) { return p.isAttr; });
  3444. }
  3445. function filterContained(props) {
  3446. return filter(props, function(p) { return !p.isAttr; });
  3447. }
  3448. function ReferenceSerializer(parent, ns) {
  3449. this.ns = ns;
  3450. }
  3451. ReferenceSerializer.prototype.build = function(element) {
  3452. this.element = element;
  3453. return this;
  3454. };
  3455. ReferenceSerializer.prototype.serializeTo = function(writer) {
  3456. writer
  3457. .appendIndent()
  3458. .append('<' + nsName(this.ns) + '>' + this.element.id + '</' + nsName(this.ns) + '>')
  3459. .appendNewLine();
  3460. };
  3461. function BodySerializer() {}
  3462. BodySerializer.prototype.serializeValue = BodySerializer.prototype.serializeTo = function(writer) {
  3463. var escape = this.escape;
  3464. if (escape) {
  3465. writer.append('<![CDATA[');
  3466. }
  3467. writer.append(this.value);
  3468. if (escape) {
  3469. writer.append(']]>');
  3470. }
  3471. };
  3472. BodySerializer.prototype.build = function(prop, value) {
  3473. this.value = value;
  3474. if (prop.type === 'String' && ESCAPE_CHARS.test(value)) {
  3475. this.escape = true;
  3476. }
  3477. return this;
  3478. };
  3479. function ValueSerializer(ns) {
  3480. this.ns = ns;
  3481. }
  3482. ValueSerializer.prototype = new BodySerializer();
  3483. ValueSerializer.prototype.serializeTo = function(writer) {
  3484. writer
  3485. .appendIndent()
  3486. .append('<' + nsName(this.ns) + '>');
  3487. this.serializeValue(writer);
  3488. writer
  3489. .append( '</' + nsName(this.ns) + '>')
  3490. .appendNewLine();
  3491. };
  3492. function ElementSerializer(parent, ns) {
  3493. this.body = [];
  3494. this.attrs = [];
  3495. this.parent = parent;
  3496. this.ns = ns;
  3497. }
  3498. ElementSerializer.prototype.build = function(element) {
  3499. this.element = element;
  3500. var otherAttrs = this.parseNsAttributes(element);
  3501. if (!this.ns) {
  3502. this.ns = this.nsTagName(element.$descriptor);
  3503. }
  3504. if (element.$descriptor.isGeneric) {
  3505. this.parseGeneric(element);
  3506. } else {
  3507. var properties = getSerializableProperties(element);
  3508. this.parseAttributes(filterAttributes(properties));
  3509. this.parseContainments(filterContained(properties));
  3510. this.parseGenericAttributes(element, otherAttrs);
  3511. }
  3512. return this;
  3513. };
  3514. ElementSerializer.prototype.nsTagName = function(descriptor) {
  3515. var effectiveNs = this.logNamespaceUsed(descriptor.ns);
  3516. return getElementNs(effectiveNs, descriptor);
  3517. };
  3518. ElementSerializer.prototype.nsPropertyTagName = function(descriptor) {
  3519. var effectiveNs = this.logNamespaceUsed(descriptor.ns);
  3520. return getPropertyNs(effectiveNs, descriptor);
  3521. };
  3522. ElementSerializer.prototype.isLocalNs = function(ns) {
  3523. return ns.uri === this.ns.uri;
  3524. };
  3525. ElementSerializer.prototype.nsAttributeName = function(element) {
  3526. var ns;
  3527. if (isString(element)) {
  3528. ns = parseNameNs(element);
  3529. } else
  3530. if (element.ns) {
  3531. ns = element.ns;
  3532. }
  3533. var effectiveNs = this.logNamespaceUsed(ns);
  3534. // strip prefix if same namespace like parent
  3535. if (this.isLocalNs(effectiveNs)) {
  3536. return { localName: ns.localName };
  3537. } else {
  3538. return assign({ localName: ns.localName }, effectiveNs);
  3539. }
  3540. };
  3541. ElementSerializer.prototype.parseGeneric = function(element) {
  3542. var self = this,
  3543. body = this.body,
  3544. attrs = this.attrs;
  3545. forEach(element, function(val, key) {
  3546. if (key === '$body') {
  3547. body.push(new BodySerializer().build({ type: 'String' }, val));
  3548. } else
  3549. if (key === '$children') {
  3550. forEach(val, function(child) {
  3551. body.push(new ElementSerializer(self).build(child));
  3552. });
  3553. } else
  3554. if (key.indexOf('$') !== 0) {
  3555. attrs.push({ name: key, value: escapeAttr(val) });
  3556. }
  3557. });
  3558. };
  3559. /**
  3560. * Parse namespaces and return a list of left over generic attributes
  3561. *
  3562. * @param {Object} element
  3563. * @return {Array<Object>}
  3564. */
  3565. ElementSerializer.prototype.parseNsAttributes = function(element) {
  3566. var self = this;
  3567. var genericAttrs = element.$attrs;
  3568. var attributes = [];
  3569. // parse namespace attributes first
  3570. // and log them. push non namespace attributes to a list
  3571. // and process them later
  3572. forEach(genericAttrs, function(value, name) {
  3573. var nameNs = parseNameNs(name);
  3574. if (nameNs.prefix === 'xmlns') {
  3575. self.logNamespace({ prefix: nameNs.localName, uri: value });
  3576. } else
  3577. if (!nameNs.prefix && nameNs.localName === 'xmlns') {
  3578. self.logNamespace({ uri: value });
  3579. } else {
  3580. attributes.push({ name: name, value: value });
  3581. }
  3582. });
  3583. return attributes;
  3584. };
  3585. ElementSerializer.prototype.parseGenericAttributes = function(element, attributes) {
  3586. var self = this;
  3587. forEach(attributes, function(attr) {
  3588. // do not serialize xsi:type attribute
  3589. // it is set manually based on the actual implementation type
  3590. if (attr.name === XSI_TYPE) {
  3591. return;
  3592. }
  3593. try {
  3594. self.addAttribute(self.nsAttributeName(attr.name), attr.value);
  3595. } catch (e) {
  3596. console.warn('[writer] missing namespace information for ', attr.name, '=', attr.value, 'on', element, e);
  3597. }
  3598. });
  3599. };
  3600. ElementSerializer.prototype.parseContainments = function(properties) {
  3601. var self = this,
  3602. body = this.body,
  3603. element = this.element;
  3604. forEach(properties, function(p) {
  3605. var value = element.get(p.name),
  3606. isReference = p.isReference,
  3607. isMany = p.isMany;
  3608. var ns = self.nsPropertyTagName(p);
  3609. if (!isMany) {
  3610. value = [ value ];
  3611. }
  3612. if (p.isBody) {
  3613. body.push(new BodySerializer().build(p, value[0]));
  3614. } else
  3615. if (Types.isSimple(p.type)) {
  3616. forEach(value, function(v) {
  3617. body.push(new ValueSerializer(ns).build(p, v));
  3618. });
  3619. } else
  3620. if (isReference) {
  3621. forEach(value, function(v) {
  3622. body.push(new ReferenceSerializer(self, ns).build(v));
  3623. });
  3624. } else {
  3625. // allow serialization via type
  3626. // rather than element name
  3627. var asType = serializeAsType(p),
  3628. asProperty = serializeAsProperty(p);
  3629. forEach(value, function(v) {
  3630. var serializer;
  3631. if (asType) {
  3632. serializer = new TypeSerializer(self, ns);
  3633. } else
  3634. if (asProperty) {
  3635. serializer = new ElementSerializer(self, ns);
  3636. } else {
  3637. serializer = new ElementSerializer(self);
  3638. }
  3639. body.push(serializer.build(v));
  3640. });
  3641. }
  3642. });
  3643. };
  3644. ElementSerializer.prototype.getNamespaces = function() {
  3645. if (!this.parent) {
  3646. if (!this.namespaces) {
  3647. this.namespaces = {
  3648. prefixMap: {},
  3649. uriMap: {},
  3650. used: {}
  3651. };
  3652. }
  3653. } else {
  3654. this.namespaces = this.parent.getNamespaces();
  3655. }
  3656. return this.namespaces;
  3657. };
  3658. ElementSerializer.prototype.logNamespace = function(ns) {
  3659. var namespaces = this.getNamespaces();
  3660. var existing = namespaces.uriMap[ns.uri];
  3661. if (!existing) {
  3662. namespaces.uriMap[ns.uri] = ns;
  3663. }
  3664. namespaces.prefixMap[ns.prefix] = ns.uri;
  3665. return ns;
  3666. };
  3667. ElementSerializer.prototype.logNamespaceUsed = function(ns) {
  3668. var element = this.element,
  3669. model = element.$model,
  3670. namespaces = this.getNamespaces();
  3671. // ns may be
  3672. //
  3673. // * prefix only
  3674. // * prefix:uri
  3675. var prefix = ns.prefix;
  3676. var uri = ns.uri || DEFAULT_NS_MAP[prefix] ||
  3677. namespaces.prefixMap[prefix] || (model ? (model.getPackage(prefix) || {}).uri : null);
  3678. if (!uri) {
  3679. throw new Error('no namespace uri given for prefix <' + ns.prefix + '>');
  3680. }
  3681. ns = namespaces.uriMap[uri];
  3682. if (!ns) {
  3683. ns = this.logNamespace({ prefix: prefix, uri: uri });
  3684. }
  3685. if (!namespaces.used[ns.uri]) {
  3686. namespaces.used[ns.uri] = ns;
  3687. }
  3688. return ns;
  3689. };
  3690. ElementSerializer.prototype.parseAttributes = function(properties) {
  3691. var self = this,
  3692. element = this.element;
  3693. forEach(properties, function(p) {
  3694. self.logNamespaceUsed(p.ns);
  3695. var value = element.get(p.name);
  3696. if (p.isReference) {
  3697. value = value.id;
  3698. }
  3699. self.addAttribute(self.nsAttributeName(p), value);
  3700. });
  3701. };
  3702. ElementSerializer.prototype.addAttribute = function(name, value) {
  3703. var attrs = this.attrs;
  3704. if (isString(value)) {
  3705. value = escapeAttr(value);
  3706. }
  3707. attrs.push({ name: name, value: value });
  3708. };
  3709. ElementSerializer.prototype.serializeAttributes = function(writer) {
  3710. var attrs = this.attrs,
  3711. root = !this.parent,
  3712. namespaces = this.namespaces;
  3713. function collectNsAttrs() {
  3714. return map(namespaces.used, function(ns) {
  3715. var name = 'xmlns' + (ns.prefix ? ':' + ns.prefix : '');
  3716. return { name: name, value: ns.uri };
  3717. });
  3718. }
  3719. if (root) {
  3720. attrs = collectNsAttrs().concat(attrs);
  3721. }
  3722. forEach(attrs, function(a) {
  3723. writer
  3724. .append(' ')
  3725. .append(nsName(a.name)).append('="').append(a.value).append('"');
  3726. });
  3727. };
  3728. ElementSerializer.prototype.serializeTo = function(writer) {
  3729. var hasBody = this.body.length,
  3730. indent = !(this.body.length === 1 && this.body[0] instanceof BodySerializer);
  3731. writer
  3732. .appendIndent()
  3733. .append('<' + nsName(this.ns));
  3734. this.serializeAttributes(writer);
  3735. writer.append(hasBody ? '>' : ' />');
  3736. if (hasBody) {
  3737. if (indent) {
  3738. writer
  3739. .appendNewLine()
  3740. .indent();
  3741. }
  3742. forEach(this.body, function(b) {
  3743. b.serializeTo(writer);
  3744. });
  3745. if (indent) {
  3746. writer
  3747. .unindent()
  3748. .appendIndent();
  3749. }
  3750. writer.append('</' + nsName(this.ns) + '>');
  3751. }
  3752. writer.appendNewLine();
  3753. };
  3754. /**
  3755. * A serializer for types that handles serialization of data types
  3756. */
  3757. function TypeSerializer(parent, ns) {
  3758. ElementSerializer.call(this, parent, ns);
  3759. }
  3760. TypeSerializer.prototype = new ElementSerializer();
  3761. TypeSerializer.prototype.build = function(element) {
  3762. var descriptor = element.$descriptor;
  3763. this.element = element;
  3764. this.typeNs = this.nsTagName(descriptor);
  3765. // add xsi:type attribute to represent the elements
  3766. // actual type
  3767. var typeNs = this.typeNs,
  3768. pkg = element.$model.getPackage(typeNs.uri),
  3769. typePrefix = (pkg.xml && pkg.xml.typePrefix) || '';
  3770. this.addAttribute(this.nsAttributeName(XSI_TYPE),
  3771. (typeNs.prefix ? typeNs.prefix + ':' : '') +
  3772. typePrefix + descriptor.ns.localName);
  3773. // do the usual stuff
  3774. return ElementSerializer.prototype.build.call(this, element);
  3775. };
  3776. TypeSerializer.prototype.isLocalNs = function(ns) {
  3777. return ns.uri === this.typeNs.uri;
  3778. };
  3779. function SavingWriter() {
  3780. this.value = '';
  3781. this.write = function(str) {
  3782. this.value += str;
  3783. };
  3784. }
  3785. function FormatingWriter(out, format) {
  3786. var indent = [''];
  3787. this.append = function(str) {
  3788. out.write(str);
  3789. return this;
  3790. };
  3791. this.appendNewLine = function() {
  3792. if (format) {
  3793. out.write('\n');
  3794. }
  3795. return this;
  3796. };
  3797. this.appendIndent = function() {
  3798. if (format) {
  3799. out.write(indent.join(' '));
  3800. }
  3801. return this;
  3802. };
  3803. this.indent = function() {
  3804. indent.push('');
  3805. return this;
  3806. };
  3807. this.unindent = function() {
  3808. indent.pop();
  3809. return this;
  3810. };
  3811. }
  3812. /**
  3813. * A writer for meta-model backed document trees
  3814. *
  3815. * @param {Object} options output options to pass into the writer
  3816. */
  3817. function XMLWriter(options) {
  3818. options = assign({ format: false, preamble: true }, options || {});
  3819. function toXML(tree, writer) {
  3820. var internalWriter = writer || new SavingWriter();
  3821. var formatingWriter = new FormatingWriter(internalWriter, options.format);
  3822. if (options.preamble) {
  3823. formatingWriter.append(XML_PREAMBLE);
  3824. }
  3825. new ElementSerializer().build(tree).serializeTo(formatingWriter);
  3826. if (!writer) {
  3827. return internalWriter.value;
  3828. }
  3829. }
  3830. return {
  3831. toXML: toXML
  3832. };
  3833. }
  3834. module.exports = XMLWriter;
  3835. },{"174":174,"177":177,"18":18,"28":28,"31":31,"84":84,"86":86,"89":89}],21:[function(_dereq_,module,exports){
  3836. (function (Buffer){
  3837. // wrapper for non-node envs
  3838. ;(function (sax) {
  3839. sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }
  3840. sax.SAXParser = SAXParser
  3841. sax.SAXStream = SAXStream
  3842. sax.createStream = createStream
  3843. // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
  3844. // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
  3845. // since that's the earliest that a buffer overrun could occur. This way, checks are
  3846. // as rare as required, but as often as necessary to ensure never crossing this bound.
  3847. // Furthermore, buffers are only tested at most once per write(), so passing a very
  3848. // large string into write() might have undesirable effects, but this is manageable by
  3849. // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
  3850. // edge case, result in creating at most one complete copy of the string passed in.
  3851. // Set to Infinity to have unlimited buffers.
  3852. sax.MAX_BUFFER_LENGTH = 64 * 1024
  3853. var buffers = [
  3854. "comment", "sgmlDecl", "textNode", "tagName", "doctype",
  3855. "procInstName", "procInstBody", "entity", "attribName",
  3856. "attribValue", "cdata", "script"
  3857. ]
  3858. sax.EVENTS = // for discoverability.
  3859. [ "text"
  3860. , "processinginstruction"
  3861. , "sgmldeclaration"
  3862. , "doctype"
  3863. , "comment"
  3864. , "attribute"
  3865. , "opentag"
  3866. , "closetag"
  3867. , "opencdata"
  3868. , "cdata"
  3869. , "closecdata"
  3870. , "error"
  3871. , "end"
  3872. , "ready"
  3873. , "script"
  3874. , "opennamespace"
  3875. , "closenamespace"
  3876. ]
  3877. function SAXParser (strict, opt) {
  3878. if (!(this instanceof SAXParser)) return new SAXParser(strict, opt)
  3879. var parser = this
  3880. clearBuffers(parser)
  3881. parser.q = parser.c = ""
  3882. parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH
  3883. parser.opt = opt || {}
  3884. parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags
  3885. parser.looseCase = parser.opt.lowercase ? "toLowerCase" : "toUpperCase"
  3886. parser.tags = []
  3887. parser.closed = parser.closedRoot = parser.sawRoot = false
  3888. parser.tag = parser.error = null
  3889. parser.strict = !!strict
  3890. parser.noscript = !!(strict || parser.opt.noscript)
  3891. parser.state = S.BEGIN
  3892. parser.ENTITIES = Object.create(sax.ENTITIES)
  3893. parser.attribList = []
  3894. // namespaces form a prototype chain.
  3895. // it always points at the current tag,
  3896. // which protos to its parent tag.
  3897. if (parser.opt.xmlns) parser.ns = Object.create(rootNS)
  3898. // mostly just for error reporting
  3899. parser.trackPosition = parser.opt.position !== false
  3900. if (parser.trackPosition) {
  3901. parser.position = parser.line = parser.column = 0
  3902. }
  3903. emit(parser, "onready")
  3904. }
  3905. if (!Object.create) Object.create = function (o) {
  3906. function f () { this.__proto__ = o }
  3907. f.prototype = o
  3908. return new f
  3909. }
  3910. if (!Object.getPrototypeOf) Object.getPrototypeOf = function (o) {
  3911. return o.__proto__
  3912. }
  3913. if (!Object.keys) Object.keys = function (o) {
  3914. var a = []
  3915. for (var i in o) if (o.hasOwnProperty(i)) a.push(i)
  3916. return a
  3917. }
  3918. function checkBufferLength (parser) {
  3919. var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)
  3920. , maxActual = 0
  3921. for (var i = 0, l = buffers.length; i < l; i ++) {
  3922. var len = parser[buffers[i]].length
  3923. if (len > maxAllowed) {
  3924. // Text/cdata nodes can get big, and since they're buffered,
  3925. // we can get here under normal conditions.
  3926. // Avoid issues by emitting the text node now,
  3927. // so at least it won't get any bigger.
  3928. switch (buffers[i]) {
  3929. case "textNode":
  3930. closeText(parser)
  3931. break
  3932. case "cdata":
  3933. emitNode(parser, "oncdata", parser.cdata)
  3934. parser.cdata = ""
  3935. break
  3936. case "script":
  3937. emitNode(parser, "onscript", parser.script)
  3938. parser.script = ""
  3939. break
  3940. default:
  3941. error(parser, "Max buffer length exceeded: "+buffers[i])
  3942. }
  3943. }
  3944. maxActual = Math.max(maxActual, len)
  3945. }
  3946. // schedule the next check for the earliest possible buffer overrun.
  3947. parser.bufferCheckPosition = (sax.MAX_BUFFER_LENGTH - maxActual)
  3948. + parser.position
  3949. }
  3950. function clearBuffers (parser) {
  3951. for (var i = 0, l = buffers.length; i < l; i ++) {
  3952. parser[buffers[i]] = ""
  3953. }
  3954. }
  3955. function flushBuffers (parser) {
  3956. closeText(parser)
  3957. if (parser.cdata !== "") {
  3958. emitNode(parser, "oncdata", parser.cdata)
  3959. parser.cdata = ""
  3960. }
  3961. if (parser.script !== "") {
  3962. emitNode(parser, "onscript", parser.script)
  3963. parser.script = ""
  3964. }
  3965. }
  3966. SAXParser.prototype =
  3967. { end: function () { end(this) }
  3968. , write: write
  3969. , resume: function () { this.error = null; return this }
  3970. , close: function () { return this.write(null) }
  3971. , flush: function () { flushBuffers(this) }
  3972. }
  3973. try {
  3974. var Stream = _dereq_("stream").Stream
  3975. } catch (ex) {
  3976. var Stream = function () {}
  3977. }
  3978. var streamWraps = sax.EVENTS.filter(function (ev) {
  3979. return ev !== "error" && ev !== "end"
  3980. })
  3981. function createStream (strict, opt) {
  3982. return new SAXStream(strict, opt)
  3983. }
  3984. function SAXStream (strict, opt) {
  3985. if (!(this instanceof SAXStream)) return new SAXStream(strict, opt)
  3986. Stream.apply(this)
  3987. this._parser = new SAXParser(strict, opt)
  3988. this.writable = true
  3989. this.readable = true
  3990. var me = this
  3991. this._parser.onend = function () {
  3992. me.emit("end")
  3993. }
  3994. this._parser.onerror = function (er) {
  3995. me.emit("error", er)
  3996. // if didn't throw, then means error was handled.
  3997. // go ahead and clear error, so we can write again.
  3998. me._parser.error = null
  3999. }
  4000. this._decoder = null;
  4001. streamWraps.forEach(function (ev) {
  4002. Object.defineProperty(me, "on" + ev, {
  4003. get: function () { return me._parser["on" + ev] },
  4004. set: function (h) {
  4005. if (!h) {
  4006. me.removeAllListeners(ev)
  4007. return me._parser["on"+ev] = h
  4008. }
  4009. me.on(ev, h)
  4010. },
  4011. enumerable: true,
  4012. configurable: false
  4013. })
  4014. })
  4015. }
  4016. SAXStream.prototype = Object.create(Stream.prototype,
  4017. { constructor: { value: SAXStream } })
  4018. SAXStream.prototype.write = function (data) {
  4019. if (typeof Buffer === 'function' &&
  4020. typeof Buffer.isBuffer === 'function' &&
  4021. Buffer.isBuffer(data)) {
  4022. if (!this._decoder) {
  4023. var SD = _dereq_('string_decoder').StringDecoder
  4024. this._decoder = new SD('utf8')
  4025. }
  4026. data = this._decoder.write(data);
  4027. }
  4028. this._parser.write(data.toString())
  4029. this.emit("data", data)
  4030. return true
  4031. }
  4032. SAXStream.prototype.end = function (chunk) {
  4033. if (chunk && chunk.length) this.write(chunk)
  4034. this._parser.end()
  4035. return true
  4036. }
  4037. SAXStream.prototype.on = function (ev, handler) {
  4038. var me = this
  4039. if (!me._parser["on"+ev] && streamWraps.indexOf(ev) !== -1) {
  4040. me._parser["on"+ev] = function () {
  4041. var args = arguments.length === 1 ? [arguments[0]]
  4042. : Array.apply(null, arguments)
  4043. args.splice(0, 0, ev)
  4044. me.emit.apply(me, args)
  4045. }
  4046. }
  4047. return Stream.prototype.on.call(me, ev, handler)
  4048. }
  4049. // character classes and tokens
  4050. var whitespace = "\r\n\t "
  4051. // this really needs to be replaced with character classes.
  4052. // XML allows all manner of ridiculous numbers and digits.
  4053. , number = "0124356789"
  4054. , letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  4055. // (Letter | "_" | ":")
  4056. , quote = "'\""
  4057. , entity = number+letter+"#"
  4058. , attribEnd = whitespace + ">"
  4059. , CDATA = "[CDATA["
  4060. , DOCTYPE = "DOCTYPE"
  4061. , XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace"
  4062. , XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/"
  4063. , rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }
  4064. // turn all the string character sets into character class objects.
  4065. whitespace = charClass(whitespace)
  4066. number = charClass(number)
  4067. letter = charClass(letter)
  4068. // http://www.w3.org/TR/REC-xml/#NT-NameStartChar
  4069. // This implementation works on strings, a single character at a time
  4070. // as such, it cannot ever support astral-plane characters (10000-EFFFF)
  4071. // without a significant breaking change to either this parser, or the
  4072. // JavaScript language. Implementation of an emoji-capable xml parser
  4073. // is left as an exercise for the reader.
  4074. var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
  4075. var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/
  4076. quote = charClass(quote)
  4077. entity = charClass(entity)
  4078. attribEnd = charClass(attribEnd)
  4079. function charClass (str) {
  4080. return str.split("").reduce(function (s, c) {
  4081. s[c] = true
  4082. return s
  4083. }, {})
  4084. }
  4085. function isRegExp (c) {
  4086. return Object.prototype.toString.call(c) === '[object RegExp]'
  4087. }
  4088. function is (charclass, c) {
  4089. return isRegExp(charclass) ? !!c.match(charclass) : charclass[c]
  4090. }
  4091. function not (charclass, c) {
  4092. return !is(charclass, c)
  4093. }
  4094. var S = 0
  4095. sax.STATE =
  4096. { BEGIN : S++
  4097. , TEXT : S++ // general stuff
  4098. , TEXT_ENTITY : S++ // &amp and such.
  4099. , OPEN_WAKA : S++ // <
  4100. , SGML_DECL : S++ // <!BLARG
  4101. , SGML_DECL_QUOTED : S++ // <!BLARG foo "bar
  4102. , DOCTYPE : S++ // <!DOCTYPE
  4103. , DOCTYPE_QUOTED : S++ // <!DOCTYPE "//blah
  4104. , DOCTYPE_DTD : S++ // <!DOCTYPE "//blah" [ ...
  4105. , DOCTYPE_DTD_QUOTED : S++ // <!DOCTYPE "//blah" [ "foo
  4106. , COMMENT_STARTING : S++ // <!-
  4107. , COMMENT : S++ // <!--
  4108. , COMMENT_ENDING : S++ // <!-- blah -
  4109. , COMMENT_ENDED : S++ // <!-- blah --
  4110. , CDATA : S++ // <![CDATA[ something
  4111. , CDATA_ENDING : S++ // ]
  4112. , CDATA_ENDING_2 : S++ // ]]
  4113. , PROC_INST : S++ // <?hi
  4114. , PROC_INST_BODY : S++ // <?hi there
  4115. , PROC_INST_ENDING : S++ // <?hi "there" ?
  4116. , OPEN_TAG : S++ // <strong
  4117. , OPEN_TAG_SLASH : S++ // <strong /
  4118. , ATTRIB : S++ // <a
  4119. , ATTRIB_NAME : S++ // <a foo
  4120. , ATTRIB_NAME_SAW_WHITE : S++ // <a foo _
  4121. , ATTRIB_VALUE : S++ // <a foo=
  4122. , ATTRIB_VALUE_QUOTED : S++ // <a foo="bar
  4123. , ATTRIB_VALUE_CLOSED : S++ // <a foo="bar"
  4124. , ATTRIB_VALUE_UNQUOTED : S++ // <a foo=bar
  4125. , ATTRIB_VALUE_ENTITY_Q : S++ // <foo bar="&quot;"
  4126. , ATTRIB_VALUE_ENTITY_U : S++ // <foo bar=&quot;
  4127. , CLOSE_TAG : S++ // </a
  4128. , CLOSE_TAG_SAW_WHITE : S++ // </a >
  4129. , SCRIPT : S++ // <script> ...
  4130. , SCRIPT_ENDING : S++ // <script> ... <
  4131. }
  4132. sax.ENTITIES =
  4133. { "amp" : "&"
  4134. , "gt" : ">"
  4135. , "lt" : "<"
  4136. , "quot" : "\""
  4137. , "apos" : "'"
  4138. , "AElig" : 198
  4139. , "Aacute" : 193
  4140. , "Acirc" : 194
  4141. , "Agrave" : 192
  4142. , "Aring" : 197
  4143. , "Atilde" : 195
  4144. , "Auml" : 196
  4145. , "Ccedil" : 199
  4146. , "ETH" : 208
  4147. , "Eacute" : 201
  4148. , "Ecirc" : 202
  4149. , "Egrave" : 200
  4150. , "Euml" : 203
  4151. , "Iacute" : 205
  4152. , "Icirc" : 206
  4153. , "Igrave" : 204
  4154. , "Iuml" : 207
  4155. , "Ntilde" : 209
  4156. , "Oacute" : 211
  4157. , "Ocirc" : 212
  4158. , "Ograve" : 210
  4159. , "Oslash" : 216
  4160. , "Otilde" : 213
  4161. , "Ouml" : 214
  4162. , "THORN" : 222
  4163. , "Uacute" : 218
  4164. , "Ucirc" : 219
  4165. , "Ugrave" : 217
  4166. , "Uuml" : 220
  4167. , "Yacute" : 221
  4168. , "aacute" : 225
  4169. , "acirc" : 226
  4170. , "aelig" : 230
  4171. , "agrave" : 224
  4172. , "aring" : 229
  4173. , "atilde" : 227
  4174. , "auml" : 228
  4175. , "ccedil" : 231
  4176. , "eacute" : 233
  4177. , "ecirc" : 234
  4178. , "egrave" : 232
  4179. , "eth" : 240
  4180. , "euml" : 235
  4181. , "iacute" : 237
  4182. , "icirc" : 238
  4183. , "igrave" : 236
  4184. , "iuml" : 239
  4185. , "ntilde" : 241
  4186. , "oacute" : 243
  4187. , "ocirc" : 244
  4188. , "ograve" : 242
  4189. , "oslash" : 248
  4190. , "otilde" : 245
  4191. , "ouml" : 246
  4192. , "szlig" : 223
  4193. , "thorn" : 254
  4194. , "uacute" : 250
  4195. , "ucirc" : 251
  4196. , "ugrave" : 249
  4197. , "uuml" : 252
  4198. , "yacute" : 253
  4199. , "yuml" : 255
  4200. , "copy" : 169
  4201. , "reg" : 174
  4202. , "nbsp" : 160
  4203. , "iexcl" : 161
  4204. , "cent" : 162
  4205. , "pound" : 163
  4206. , "curren" : 164
  4207. , "yen" : 165
  4208. , "brvbar" : 166
  4209. , "sect" : 167
  4210. , "uml" : 168
  4211. , "ordf" : 170
  4212. , "laquo" : 171
  4213. , "not" : 172
  4214. , "shy" : 173
  4215. , "macr" : 175
  4216. , "deg" : 176
  4217. , "plusmn" : 177
  4218. , "sup1" : 185
  4219. , "sup2" : 178
  4220. , "sup3" : 179
  4221. , "acute" : 180
  4222. , "micro" : 181
  4223. , "para" : 182
  4224. , "middot" : 183
  4225. , "cedil" : 184
  4226. , "ordm" : 186
  4227. , "raquo" : 187
  4228. , "frac14" : 188
  4229. , "frac12" : 189
  4230. , "frac34" : 190
  4231. , "iquest" : 191
  4232. , "times" : 215
  4233. , "divide" : 247
  4234. , "OElig" : 338
  4235. , "oelig" : 339
  4236. , "Scaron" : 352
  4237. , "scaron" : 353
  4238. , "Yuml" : 376
  4239. , "fnof" : 402
  4240. , "circ" : 710
  4241. , "tilde" : 732
  4242. , "Alpha" : 913
  4243. , "Beta" : 914
  4244. , "Gamma" : 915
  4245. , "Delta" : 916
  4246. , "Epsilon" : 917
  4247. , "Zeta" : 918
  4248. , "Eta" : 919
  4249. , "Theta" : 920
  4250. , "Iota" : 921
  4251. , "Kappa" : 922
  4252. , "Lambda" : 923
  4253. , "Mu" : 924
  4254. , "Nu" : 925
  4255. , "Xi" : 926
  4256. , "Omicron" : 927
  4257. , "Pi" : 928
  4258. , "Rho" : 929
  4259. , "Sigma" : 931
  4260. , "Tau" : 932
  4261. , "Upsilon" : 933
  4262. , "Phi" : 934
  4263. , "Chi" : 935
  4264. , "Psi" : 936
  4265. , "Omega" : 937
  4266. , "alpha" : 945
  4267. , "beta" : 946
  4268. , "gamma" : 947
  4269. , "delta" : 948
  4270. , "epsilon" : 949
  4271. , "zeta" : 950
  4272. , "eta" : 951
  4273. , "theta" : 952
  4274. , "iota" : 953
  4275. , "kappa" : 954
  4276. , "lambda" : 955
  4277. , "mu" : 956
  4278. , "nu" : 957
  4279. , "xi" : 958
  4280. , "omicron" : 959
  4281. , "pi" : 960
  4282. , "rho" : 961
  4283. , "sigmaf" : 962
  4284. , "sigma" : 963
  4285. , "tau" : 964
  4286. , "upsilon" : 965
  4287. , "phi" : 966
  4288. , "chi" : 967
  4289. , "psi" : 968
  4290. , "omega" : 969
  4291. , "thetasym" : 977
  4292. , "upsih" : 978
  4293. , "piv" : 982
  4294. , "ensp" : 8194
  4295. , "emsp" : 8195
  4296. , "thinsp" : 8201
  4297. , "zwnj" : 8204
  4298. , "zwj" : 8205
  4299. , "lrm" : 8206
  4300. , "rlm" : 8207
  4301. , "ndash" : 8211
  4302. , "mdash" : 8212
  4303. , "lsquo" : 8216
  4304. , "rsquo" : 8217
  4305. , "sbquo" : 8218
  4306. , "ldquo" : 8220
  4307. , "rdquo" : 8221
  4308. , "bdquo" : 8222
  4309. , "dagger" : 8224
  4310. , "Dagger" : 8225
  4311. , "bull" : 8226
  4312. , "hellip" : 8230
  4313. , "permil" : 8240
  4314. , "prime" : 8242
  4315. , "Prime" : 8243
  4316. , "lsaquo" : 8249
  4317. , "rsaquo" : 8250
  4318. , "oline" : 8254
  4319. , "frasl" : 8260
  4320. , "euro" : 8364
  4321. , "image" : 8465
  4322. , "weierp" : 8472
  4323. , "real" : 8476
  4324. , "trade" : 8482
  4325. , "alefsym" : 8501
  4326. , "larr" : 8592
  4327. , "uarr" : 8593
  4328. , "rarr" : 8594
  4329. , "darr" : 8595
  4330. , "harr" : 8596
  4331. , "crarr" : 8629
  4332. , "lArr" : 8656
  4333. , "uArr" : 8657
  4334. , "rArr" : 8658
  4335. , "dArr" : 8659
  4336. , "hArr" : 8660
  4337. , "forall" : 8704
  4338. , "part" : 8706
  4339. , "exist" : 8707
  4340. , "empty" : 8709
  4341. , "nabla" : 8711
  4342. , "isin" : 8712
  4343. , "notin" : 8713
  4344. , "ni" : 8715
  4345. , "prod" : 8719
  4346. , "sum" : 8721
  4347. , "minus" : 8722
  4348. , "lowast" : 8727
  4349. , "radic" : 8730
  4350. , "prop" : 8733
  4351. , "infin" : 8734
  4352. , "ang" : 8736
  4353. , "and" : 8743
  4354. , "or" : 8744
  4355. , "cap" : 8745
  4356. , "cup" : 8746
  4357. , "int" : 8747
  4358. , "there4" : 8756
  4359. , "sim" : 8764
  4360. , "cong" : 8773
  4361. , "asymp" : 8776
  4362. , "ne" : 8800
  4363. , "equiv" : 8801
  4364. , "le" : 8804
  4365. , "ge" : 8805
  4366. , "sub" : 8834
  4367. , "sup" : 8835
  4368. , "nsub" : 8836
  4369. , "sube" : 8838
  4370. , "supe" : 8839
  4371. , "oplus" : 8853
  4372. , "otimes" : 8855
  4373. , "perp" : 8869
  4374. , "sdot" : 8901
  4375. , "lceil" : 8968
  4376. , "rceil" : 8969
  4377. , "lfloor" : 8970
  4378. , "rfloor" : 8971
  4379. , "lang" : 9001
  4380. , "rang" : 9002
  4381. , "loz" : 9674
  4382. , "spades" : 9824
  4383. , "clubs" : 9827
  4384. , "hearts" : 9829
  4385. , "diams" : 9830
  4386. }
  4387. Object.keys(sax.ENTITIES).forEach(function (key) {
  4388. var e = sax.ENTITIES[key]
  4389. var s = typeof e === 'number' ? String.fromCharCode(e) : e
  4390. sax.ENTITIES[key] = s
  4391. })
  4392. for (var S in sax.STATE) sax.STATE[sax.STATE[S]] = S
  4393. // shorthand
  4394. S = sax.STATE
  4395. function emit (parser, event, data) {
  4396. parser[event] && parser[event](data)
  4397. }
  4398. function emitNode (parser, nodeType, data) {
  4399. if (parser.textNode) closeText(parser)
  4400. emit(parser, nodeType, data)
  4401. }
  4402. function closeText (parser) {
  4403. parser.textNode = textopts(parser.opt, parser.textNode)
  4404. if (parser.textNode) emit(parser, "ontext", parser.textNode)
  4405. parser.textNode = ""
  4406. }
  4407. function textopts (opt, text) {
  4408. if (opt.trim) text = text.trim()
  4409. if (opt.normalize) text = text.replace(/\s+/g, " ")
  4410. return text
  4411. }
  4412. function error (parser, er) {
  4413. closeText(parser)
  4414. if (parser.trackPosition) {
  4415. er += "\nLine: "+parser.line+
  4416. "\nColumn: "+parser.column+
  4417. "\nChar: "+parser.c
  4418. }
  4419. er = new Error(er)
  4420. parser.error = er
  4421. emit(parser, "onerror", er)
  4422. return parser
  4423. }
  4424. function end (parser) {
  4425. if (!parser.closedRoot) strictFail(parser, "Unclosed root tag")
  4426. if ((parser.state !== S.BEGIN) && (parser.state !== S.TEXT)) error(parser, "Unexpected end")
  4427. closeText(parser)
  4428. parser.c = ""
  4429. parser.closed = true
  4430. emit(parser, "onend")
  4431. SAXParser.call(parser, parser.strict, parser.opt)
  4432. return parser
  4433. }
  4434. function strictFail (parser, message) {
  4435. if (typeof parser !== 'object' || !(parser instanceof SAXParser))
  4436. throw new Error('bad call to strictFail');
  4437. if (parser.strict) error(parser, message)
  4438. }
  4439. function newTag (parser) {
  4440. if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]()
  4441. var parent = parser.tags[parser.tags.length - 1] || parser
  4442. , tag = parser.tag = { name : parser.tagName, attributes : {} }
  4443. // will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
  4444. if (parser.opt.xmlns) tag.ns = parent.ns
  4445. parser.attribList.length = 0
  4446. }
  4447. function qname (name, attribute) {
  4448. var i = name.indexOf(":")
  4449. , qualName = i < 0 ? [ "", name ] : name.split(":")
  4450. , prefix = qualName[0]
  4451. , local = qualName[1]
  4452. // <x "xmlns"="http://foo">
  4453. if (attribute && name === "xmlns") {
  4454. prefix = "xmlns"
  4455. local = ""
  4456. }
  4457. return { prefix: prefix, local: local }
  4458. }
  4459. function attrib (parser) {
  4460. if (!parser.strict) parser.attribName = parser.attribName[parser.looseCase]()
  4461. if (parser.attribList.indexOf(parser.attribName) !== -1 ||
  4462. parser.tag.attributes.hasOwnProperty(parser.attribName)) {
  4463. return parser.attribName = parser.attribValue = ""
  4464. }
  4465. if (parser.opt.xmlns) {
  4466. var qn = qname(parser.attribName, true)
  4467. , prefix = qn.prefix
  4468. , local = qn.local
  4469. if (prefix === "xmlns") {
  4470. // namespace binding attribute; push the binding into scope
  4471. if (local === "xml" && parser.attribValue !== XML_NAMESPACE) {
  4472. strictFail( parser
  4473. , "xml: prefix must be bound to " + XML_NAMESPACE + "\n"
  4474. + "Actual: " + parser.attribValue )
  4475. } else if (local === "xmlns" && parser.attribValue !== XMLNS_NAMESPACE) {
  4476. strictFail( parser
  4477. , "xmlns: prefix must be bound to " + XMLNS_NAMESPACE + "\n"
  4478. + "Actual: " + parser.attribValue )
  4479. } else {
  4480. var tag = parser.tag
  4481. , parent = parser.tags[parser.tags.length - 1] || parser
  4482. if (tag.ns === parent.ns) {
  4483. tag.ns = Object.create(parent.ns)
  4484. }
  4485. tag.ns[local] = parser.attribValue
  4486. }
  4487. }
  4488. // defer onattribute events until all attributes have been seen
  4489. // so any new bindings can take effect; preserve attribute order
  4490. // so deferred events can be emitted in document order
  4491. parser.attribList.push([parser.attribName, parser.attribValue])
  4492. } else {
  4493. // in non-xmlns mode, we can emit the event right away
  4494. parser.tag.attributes[parser.attribName] = parser.attribValue
  4495. emitNode( parser
  4496. , "onattribute"
  4497. , { name: parser.attribName
  4498. , value: parser.attribValue } )
  4499. }
  4500. parser.attribName = parser.attribValue = ""
  4501. }
  4502. function openTag (parser, selfClosing) {
  4503. if (parser.opt.xmlns) {
  4504. // emit namespace binding events
  4505. var tag = parser.tag
  4506. // add namespace info to tag
  4507. var qn = qname(parser.tagName)
  4508. tag.prefix = qn.prefix
  4509. tag.local = qn.local
  4510. tag.uri = tag.ns[qn.prefix] || ""
  4511. if (tag.prefix && !tag.uri) {
  4512. strictFail(parser, "Unbound namespace prefix: "
  4513. + JSON.stringify(parser.tagName))
  4514. tag.uri = qn.prefix
  4515. }
  4516. var parent = parser.tags[parser.tags.length - 1] || parser
  4517. if (tag.ns && parent.ns !== tag.ns) {
  4518. Object.keys(tag.ns).forEach(function (p) {
  4519. emitNode( parser
  4520. , "onopennamespace"
  4521. , { prefix: p , uri: tag.ns[p] } )
  4522. })
  4523. }
  4524. // handle deferred onattribute events
  4525. // Note: do not apply default ns to attributes:
  4526. // http://www.w3.org/TR/REC-xml-names/#defaulting
  4527. for (var i = 0, l = parser.attribList.length; i < l; i ++) {
  4528. var nv = parser.attribList[i]
  4529. var name = nv[0]
  4530. , value = nv[1]
  4531. , qualName = qname(name, true)
  4532. , prefix = qualName.prefix
  4533. , local = qualName.local
  4534. , uri = prefix == "" ? "" : (tag.ns[prefix] || "")
  4535. , a = { name: name
  4536. , value: value
  4537. , prefix: prefix
  4538. , local: local
  4539. , uri: uri
  4540. }
  4541. // if there's any attributes with an undefined namespace,
  4542. // then fail on them now.
  4543. if (prefix && prefix != "xmlns" && !uri) {
  4544. strictFail(parser, "Unbound namespace prefix: "
  4545. + JSON.stringify(prefix))
  4546. a.uri = prefix
  4547. }
  4548. parser.tag.attributes[name] = a
  4549. emitNode(parser, "onattribute", a)
  4550. }
  4551. parser.attribList.length = 0
  4552. }
  4553. parser.tag.isSelfClosing = !!selfClosing
  4554. // process the tag
  4555. parser.sawRoot = true
  4556. parser.tags.push(parser.tag)
  4557. emitNode(parser, "onopentag", parser.tag)
  4558. if (!selfClosing) {
  4559. // special case for <script> in non-strict mode.
  4560. if (!parser.noscript && parser.tagName.toLowerCase() === "script") {
  4561. parser.state = S.SCRIPT
  4562. } else {
  4563. parser.state = S.TEXT
  4564. }
  4565. parser.tag = null
  4566. parser.tagName = ""
  4567. }
  4568. parser.attribName = parser.attribValue = ""
  4569. parser.attribList.length = 0
  4570. }
  4571. function closeTag (parser) {
  4572. if (!parser.tagName) {
  4573. strictFail(parser, "Weird empty close tag.")
  4574. parser.textNode += "</>"
  4575. parser.state = S.TEXT
  4576. return
  4577. }
  4578. if (parser.script) {
  4579. if (parser.tagName !== "script") {
  4580. parser.script += "</" + parser.tagName + ">"
  4581. parser.tagName = ""
  4582. parser.state = S.SCRIPT
  4583. return
  4584. }
  4585. emitNode(parser, "onscript", parser.script)
  4586. parser.script = ""
  4587. }
  4588. // first make sure that the closing tag actually exists.
  4589. // <a><b></c></b></a> will close everything, otherwise.
  4590. var t = parser.tags.length
  4591. var tagName = parser.tagName
  4592. if (!parser.strict) tagName = tagName[parser.looseCase]()
  4593. var closeTo = tagName
  4594. while (t --) {
  4595. var close = parser.tags[t]
  4596. if (close.name !== closeTo) {
  4597. // fail the first time in strict mode
  4598. strictFail(parser, "Unexpected close tag")
  4599. } else break
  4600. }
  4601. // didn't find it. we already failed for strict, so just abort.
  4602. if (t < 0) {
  4603. strictFail(parser, "Unmatched closing tag: "+parser.tagName)
  4604. parser.textNode += "</" + parser.tagName + ">"
  4605. parser.state = S.TEXT
  4606. return
  4607. }
  4608. parser.tagName = tagName
  4609. var s = parser.tags.length
  4610. while (s --> t) {
  4611. var tag = parser.tag = parser.tags.pop()
  4612. parser.tagName = parser.tag.name
  4613. emitNode(parser, "onclosetag", parser.tagName)
  4614. var x = {}
  4615. for (var i in tag.ns) x[i] = tag.ns[i]
  4616. var parent = parser.tags[parser.tags.length - 1] || parser
  4617. if (parser.opt.xmlns && tag.ns !== parent.ns) {
  4618. // remove namespace bindings introduced by tag
  4619. Object.keys(tag.ns).forEach(function (p) {
  4620. var n = tag.ns[p]
  4621. emitNode(parser, "onclosenamespace", { prefix: p, uri: n })
  4622. })
  4623. }
  4624. }
  4625. if (t === 0) parser.closedRoot = true
  4626. parser.tagName = parser.attribValue = parser.attribName = ""
  4627. parser.attribList.length = 0
  4628. parser.state = S.TEXT
  4629. }
  4630. function parseEntity (parser) {
  4631. var entity = parser.entity
  4632. , entityLC = entity.toLowerCase()
  4633. , num
  4634. , numStr = ""
  4635. if (parser.ENTITIES[entity])
  4636. return parser.ENTITIES[entity]
  4637. if (parser.ENTITIES[entityLC])
  4638. return parser.ENTITIES[entityLC]
  4639. entity = entityLC
  4640. if (entity.charAt(0) === "#") {
  4641. if (entity.charAt(1) === "x") {
  4642. entity = entity.slice(2)
  4643. num = parseInt(entity, 16)
  4644. numStr = num.toString(16)
  4645. } else {
  4646. entity = entity.slice(1)
  4647. num = parseInt(entity, 10)
  4648. numStr = num.toString(10)
  4649. }
  4650. }
  4651. entity = entity.replace(/^0+/, "")
  4652. if (numStr.toLowerCase() !== entity) {
  4653. strictFail(parser, "Invalid character entity")
  4654. return "&"+parser.entity + ";"
  4655. }
  4656. return String.fromCodePoint(num)
  4657. }
  4658. function write (chunk) {
  4659. var parser = this
  4660. if (this.error) throw this.error
  4661. if (parser.closed) return error(parser,
  4662. "Cannot write after close. Assign an onready handler.")
  4663. if (chunk === null) return end(parser)
  4664. var i = 0, c = ""
  4665. while (parser.c = c = chunk.charAt(i++)) {
  4666. if (parser.trackPosition) {
  4667. parser.position ++
  4668. if (c === "\n") {
  4669. parser.line ++
  4670. parser.column = 0
  4671. } else parser.column ++
  4672. }
  4673. switch (parser.state) {
  4674. case S.BEGIN:
  4675. if (c === "<") {
  4676. parser.state = S.OPEN_WAKA
  4677. parser.startTagPosition = parser.position
  4678. } else if (not(whitespace,c)) {
  4679. // have to process this as a text node.
  4680. // weird, but happens.
  4681. strictFail(parser, "Non-whitespace before first tag.")
  4682. parser.textNode = c
  4683. parser.state = S.TEXT
  4684. }
  4685. continue
  4686. case S.TEXT:
  4687. if (parser.sawRoot && !parser.closedRoot) {
  4688. var starti = i-1
  4689. while (c && c!=="<" && c!=="&") {
  4690. c = chunk.charAt(i++)
  4691. if (c && parser.trackPosition) {
  4692. parser.position ++
  4693. if (c === "\n") {
  4694. parser.line ++
  4695. parser.column = 0
  4696. } else parser.column ++
  4697. }
  4698. }
  4699. parser.textNode += chunk.substring(starti, i-1)
  4700. }
  4701. if (c === "<") {
  4702. parser.state = S.OPEN_WAKA
  4703. parser.startTagPosition = parser.position
  4704. } else {
  4705. if (not(whitespace, c) && (!parser.sawRoot || parser.closedRoot))
  4706. strictFail(parser, "Text data outside of root node.")
  4707. if (c === "&") parser.state = S.TEXT_ENTITY
  4708. else parser.textNode += c
  4709. }
  4710. continue
  4711. case S.SCRIPT:
  4712. // only non-strict
  4713. if (c === "<") {
  4714. parser.state = S.SCRIPT_ENDING
  4715. } else parser.script += c
  4716. continue
  4717. case S.SCRIPT_ENDING:
  4718. if (c === "/") {
  4719. parser.state = S.CLOSE_TAG
  4720. } else {
  4721. parser.script += "<" + c
  4722. parser.state = S.SCRIPT
  4723. }
  4724. continue
  4725. case S.OPEN_WAKA:
  4726. // either a /, ?, !, or text is coming next.
  4727. if (c === "!") {
  4728. parser.state = S.SGML_DECL
  4729. parser.sgmlDecl = ""
  4730. } else if (is(whitespace, c)) {
  4731. // wait for it...
  4732. } else if (is(nameStart,c)) {
  4733. parser.state = S.OPEN_TAG
  4734. parser.tagName = c
  4735. } else if (c === "/") {
  4736. parser.state = S.CLOSE_TAG
  4737. parser.tagName = ""
  4738. } else if (c === "?") {
  4739. parser.state = S.PROC_INST
  4740. parser.procInstName = parser.procInstBody = ""
  4741. } else {
  4742. strictFail(parser, "Unencoded <")
  4743. // if there was some whitespace, then add that in.
  4744. if (parser.startTagPosition + 1 < parser.position) {
  4745. var pad = parser.position - parser.startTagPosition
  4746. c = new Array(pad).join(" ") + c
  4747. }
  4748. parser.textNode += "<" + c
  4749. parser.state = S.TEXT
  4750. }
  4751. continue
  4752. case S.SGML_DECL:
  4753. if ((parser.sgmlDecl+c).toUpperCase() === CDATA) {
  4754. emitNode(parser, "onopencdata")
  4755. parser.state = S.CDATA
  4756. parser.sgmlDecl = ""
  4757. parser.cdata = ""
  4758. } else if (parser.sgmlDecl+c === "--") {
  4759. parser.state = S.COMMENT
  4760. parser.comment = ""
  4761. parser.sgmlDecl = ""
  4762. } else if ((parser.sgmlDecl+c).toUpperCase() === DOCTYPE) {
  4763. parser.state = S.DOCTYPE
  4764. if (parser.doctype || parser.sawRoot) strictFail(parser,
  4765. "Inappropriately located doctype declaration")
  4766. parser.doctype = ""
  4767. parser.sgmlDecl = ""
  4768. } else if (c === ">") {
  4769. emitNode(parser, "onsgmldeclaration", parser.sgmlDecl)
  4770. parser.sgmlDecl = ""
  4771. parser.state = S.TEXT
  4772. } else if (is(quote, c)) {
  4773. parser.state = S.SGML_DECL_QUOTED
  4774. parser.sgmlDecl += c
  4775. } else parser.sgmlDecl += c
  4776. continue
  4777. case S.SGML_DECL_QUOTED:
  4778. if (c === parser.q) {
  4779. parser.state = S.SGML_DECL
  4780. parser.q = ""
  4781. }
  4782. parser.sgmlDecl += c
  4783. continue
  4784. case S.DOCTYPE:
  4785. if (c === ">") {
  4786. parser.state = S.TEXT
  4787. emitNode(parser, "ondoctype", parser.doctype)
  4788. parser.doctype = true // just remember that we saw it.
  4789. } else {
  4790. parser.doctype += c
  4791. if (c === "[") parser.state = S.DOCTYPE_DTD
  4792. else if (is(quote, c)) {
  4793. parser.state = S.DOCTYPE_QUOTED
  4794. parser.q = c
  4795. }
  4796. }
  4797. continue
  4798. case S.DOCTYPE_QUOTED:
  4799. parser.doctype += c
  4800. if (c === parser.q) {
  4801. parser.q = ""
  4802. parser.state = S.DOCTYPE
  4803. }
  4804. continue
  4805. case S.DOCTYPE_DTD:
  4806. parser.doctype += c
  4807. if (c === "]") parser.state = S.DOCTYPE
  4808. else if (is(quote,c)) {
  4809. parser.state = S.DOCTYPE_DTD_QUOTED
  4810. parser.q = c
  4811. }
  4812. continue
  4813. case S.DOCTYPE_DTD_QUOTED:
  4814. parser.doctype += c
  4815. if (c === parser.q) {
  4816. parser.state = S.DOCTYPE_DTD
  4817. parser.q = ""
  4818. }
  4819. continue
  4820. case S.COMMENT:
  4821. if (c === "-") parser.state = S.COMMENT_ENDING
  4822. else parser.comment += c
  4823. continue
  4824. case S.COMMENT_ENDING:
  4825. if (c === "-") {
  4826. parser.state = S.COMMENT_ENDED
  4827. parser.comment = textopts(parser.opt, parser.comment)
  4828. if (parser.comment) emitNode(parser, "oncomment", parser.comment)
  4829. parser.comment = ""
  4830. } else {
  4831. parser.comment += "-" + c
  4832. parser.state = S.COMMENT
  4833. }
  4834. continue
  4835. case S.COMMENT_ENDED:
  4836. if (c !== ">") {
  4837. strictFail(parser, "Malformed comment")
  4838. // allow <!-- blah -- bloo --> in non-strict mode,
  4839. // which is a comment of " blah -- bloo "
  4840. parser.comment += "--" + c
  4841. parser.state = S.COMMENT
  4842. } else parser.state = S.TEXT
  4843. continue
  4844. case S.CDATA:
  4845. if (c === "]") parser.state = S.CDATA_ENDING
  4846. else parser.cdata += c
  4847. continue
  4848. case S.CDATA_ENDING:
  4849. if (c === "]") parser.state = S.CDATA_ENDING_2
  4850. else {
  4851. parser.cdata += "]" + c
  4852. parser.state = S.CDATA
  4853. }
  4854. continue
  4855. case S.CDATA_ENDING_2:
  4856. if (c === ">") {
  4857. if (parser.cdata) emitNode(parser, "oncdata", parser.cdata)
  4858. emitNode(parser, "onclosecdata")
  4859. parser.cdata = ""
  4860. parser.state = S.TEXT
  4861. } else if (c === "]") {
  4862. parser.cdata += "]"
  4863. } else {
  4864. parser.cdata += "]]" + c
  4865. parser.state = S.CDATA
  4866. }
  4867. continue
  4868. case S.PROC_INST:
  4869. if (c === "?") parser.state = S.PROC_INST_ENDING
  4870. else if (is(whitespace, c)) parser.state = S.PROC_INST_BODY
  4871. else parser.procInstName += c
  4872. continue
  4873. case S.PROC_INST_BODY:
  4874. if (!parser.procInstBody && is(whitespace, c)) continue
  4875. else if (c === "?") parser.state = S.PROC_INST_ENDING
  4876. else parser.procInstBody += c
  4877. continue
  4878. case S.PROC_INST_ENDING:
  4879. if (c === ">") {
  4880. emitNode(parser, "onprocessinginstruction", {
  4881. name : parser.procInstName,
  4882. body : parser.procInstBody
  4883. })
  4884. parser.procInstName = parser.procInstBody = ""
  4885. parser.state = S.TEXT
  4886. } else {
  4887. parser.procInstBody += "?" + c
  4888. parser.state = S.PROC_INST_BODY
  4889. }
  4890. continue
  4891. case S.OPEN_TAG:
  4892. if (is(nameBody, c)) parser.tagName += c
  4893. else {
  4894. newTag(parser)
  4895. if (c === ">") openTag(parser)
  4896. else if (c === "/") parser.state = S.OPEN_TAG_SLASH
  4897. else {
  4898. if (not(whitespace, c)) strictFail(
  4899. parser, "Invalid character in tag name")
  4900. parser.state = S.ATTRIB
  4901. }
  4902. }
  4903. continue
  4904. case S.OPEN_TAG_SLASH:
  4905. if (c === ">") {
  4906. openTag(parser, true)
  4907. closeTag(parser)
  4908. } else {
  4909. strictFail(parser, "Forward-slash in opening tag not followed by >")
  4910. parser.state = S.ATTRIB
  4911. }
  4912. continue
  4913. case S.ATTRIB:
  4914. // haven't read the attribute name yet.
  4915. if (is(whitespace, c)) continue
  4916. else if (c === ">") openTag(parser)
  4917. else if (c === "/") parser.state = S.OPEN_TAG_SLASH
  4918. else if (is(nameStart, c)) {
  4919. parser.attribName = c
  4920. parser.attribValue = ""
  4921. parser.state = S.ATTRIB_NAME
  4922. } else strictFail(parser, "Invalid attribute name")
  4923. continue
  4924. case S.ATTRIB_NAME:
  4925. if (c === "=") parser.state = S.ATTRIB_VALUE
  4926. else if (c === ">") {
  4927. strictFail(parser, "Attribute without value")
  4928. parser.attribValue = parser.attribName
  4929. attrib(parser)
  4930. openTag(parser)
  4931. }
  4932. else if (is(whitespace, c)) parser.state = S.ATTRIB_NAME_SAW_WHITE
  4933. else if (is(nameBody, c)) parser.attribName += c
  4934. else strictFail(parser, "Invalid attribute name")
  4935. continue
  4936. case S.ATTRIB_NAME_SAW_WHITE:
  4937. if (c === "=") parser.state = S.ATTRIB_VALUE
  4938. else if (is(whitespace, c)) continue
  4939. else {
  4940. strictFail(parser, "Attribute without value")
  4941. parser.tag.attributes[parser.attribName] = ""
  4942. parser.attribValue = ""
  4943. emitNode(parser, "onattribute",
  4944. { name : parser.attribName, value : "" })
  4945. parser.attribName = ""
  4946. if (c === ">") openTag(parser)
  4947. else if (is(nameStart, c)) {
  4948. parser.attribName = c
  4949. parser.state = S.ATTRIB_NAME
  4950. } else {
  4951. strictFail(parser, "Invalid attribute name")
  4952. parser.state = S.ATTRIB
  4953. }
  4954. }
  4955. continue
  4956. case S.ATTRIB_VALUE:
  4957. if (is(whitespace, c)) continue
  4958. else if (is(quote, c)) {
  4959. parser.q = c
  4960. parser.state = S.ATTRIB_VALUE_QUOTED
  4961. } else {
  4962. strictFail(parser, "Unquoted attribute value")
  4963. parser.state = S.ATTRIB_VALUE_UNQUOTED
  4964. parser.attribValue = c
  4965. }
  4966. continue
  4967. case S.ATTRIB_VALUE_QUOTED:
  4968. if (c !== parser.q) {
  4969. if (c === "&") parser.state = S.ATTRIB_VALUE_ENTITY_Q
  4970. else parser.attribValue += c
  4971. continue
  4972. }
  4973. attrib(parser)
  4974. parser.q = ""
  4975. parser.state = S.ATTRIB_VALUE_CLOSED
  4976. continue
  4977. case S.ATTRIB_VALUE_CLOSED:
  4978. if (is(whitespace, c)) {
  4979. parser.state = S.ATTRIB
  4980. } else if (c === ">") openTag(parser)
  4981. else if (c === "/") parser.state = S.OPEN_TAG_SLASH
  4982. else if (is(nameStart, c)) {
  4983. strictFail(parser, "No whitespace between attributes")
  4984. parser.attribName = c
  4985. parser.attribValue = ""
  4986. parser.state = S.ATTRIB_NAME
  4987. } else strictFail(parser, "Invalid attribute name")
  4988. continue
  4989. case S.ATTRIB_VALUE_UNQUOTED:
  4990. if (not(attribEnd,c)) {
  4991. if (c === "&") parser.state = S.ATTRIB_VALUE_ENTITY_U
  4992. else parser.attribValue += c
  4993. continue
  4994. }
  4995. attrib(parser)
  4996. if (c === ">") openTag(parser)
  4997. else parser.state = S.ATTRIB
  4998. continue
  4999. case S.CLOSE_TAG:
  5000. if (!parser.tagName) {
  5001. if (is(whitespace, c)) continue
  5002. else if (not(nameStart, c)) {
  5003. if (parser.script) {
  5004. parser.script += "</" + c
  5005. parser.state = S.SCRIPT
  5006. } else {
  5007. strictFail(parser, "Invalid tagname in closing tag.")
  5008. }
  5009. } else parser.tagName = c
  5010. }
  5011. else if (c === ">") closeTag(parser)
  5012. else if (is(nameBody, c)) parser.tagName += c
  5013. else if (parser.script) {
  5014. parser.script += "</" + parser.tagName
  5015. parser.tagName = ""
  5016. parser.state = S.SCRIPT
  5017. } else {
  5018. if (not(whitespace, c)) strictFail(parser,
  5019. "Invalid tagname in closing tag")
  5020. parser.state = S.CLOSE_TAG_SAW_WHITE
  5021. }
  5022. continue
  5023. case S.CLOSE_TAG_SAW_WHITE:
  5024. if (is(whitespace, c)) continue
  5025. if (c === ">") closeTag(parser)
  5026. else strictFail(parser, "Invalid characters in closing tag")
  5027. continue
  5028. case S.TEXT_ENTITY:
  5029. case S.ATTRIB_VALUE_ENTITY_Q:
  5030. case S.ATTRIB_VALUE_ENTITY_U:
  5031. switch(parser.state) {
  5032. case S.TEXT_ENTITY:
  5033. var returnState = S.TEXT, buffer = "textNode"
  5034. break
  5035. case S.ATTRIB_VALUE_ENTITY_Q:
  5036. var returnState = S.ATTRIB_VALUE_QUOTED, buffer = "attribValue"
  5037. break
  5038. case S.ATTRIB_VALUE_ENTITY_U:
  5039. var returnState = S.ATTRIB_VALUE_UNQUOTED, buffer = "attribValue"
  5040. break
  5041. }
  5042. if (c === ";") {
  5043. parser[buffer] += parseEntity(parser)
  5044. parser.entity = ""
  5045. parser.state = returnState
  5046. }
  5047. else if (is(entity, c)) parser.entity += c
  5048. else {
  5049. strictFail(parser, "Invalid character entity")
  5050. parser[buffer] += "&" + parser.entity + c
  5051. parser.entity = ""
  5052. parser.state = returnState
  5053. }
  5054. continue
  5055. default:
  5056. throw new Error(parser, "Unknown state: " + parser.state)
  5057. }
  5058. } // while
  5059. // cdata blocks can get very big under normal conditions. emit and move on.
  5060. // if (parser.state === S.CDATA && parser.cdata) {
  5061. // emitNode(parser, "oncdata", parser.cdata)
  5062. // parser.cdata = ""
  5063. // }
  5064. if (parser.position >= parser.bufferCheckPosition) checkBufferLength(parser)
  5065. return parser
  5066. }
  5067. /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
  5068. if (!String.fromCodePoint) {
  5069. (function() {
  5070. var stringFromCharCode = String.fromCharCode;
  5071. var floor = Math.floor;
  5072. var fromCodePoint = function() {
  5073. var MAX_SIZE = 0x4000;
  5074. var codeUnits = [];
  5075. var highSurrogate;
  5076. var lowSurrogate;
  5077. var index = -1;
  5078. var length = arguments.length;
  5079. if (!length) {
  5080. return '';
  5081. }
  5082. var result = '';
  5083. while (++index < length) {
  5084. var codePoint = Number(arguments[index]);
  5085. if (
  5086. !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
  5087. codePoint < 0 || // not a valid Unicode code point
  5088. codePoint > 0x10FFFF || // not a valid Unicode code point
  5089. floor(codePoint) != codePoint // not an integer
  5090. ) {
  5091. throw RangeError('Invalid code point: ' + codePoint);
  5092. }
  5093. if (codePoint <= 0xFFFF) { // BMP code point
  5094. codeUnits.push(codePoint);
  5095. } else { // Astral code point; split in surrogate halves
  5096. // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  5097. codePoint -= 0x10000;
  5098. highSurrogate = (codePoint >> 10) + 0xD800;
  5099. lowSurrogate = (codePoint % 0x400) + 0xDC00;
  5100. codeUnits.push(highSurrogate, lowSurrogate);
  5101. }
  5102. if (index + 1 == length || codeUnits.length > MAX_SIZE) {
  5103. result += stringFromCharCode.apply(null, codeUnits);
  5104. codeUnits.length = 0;
  5105. }
  5106. }
  5107. return result;
  5108. };
  5109. if (Object.defineProperty) {
  5110. Object.defineProperty(String, 'fromCodePoint', {
  5111. 'value': fromCodePoint,
  5112. 'configurable': true,
  5113. 'writable': true
  5114. });
  5115. } else {
  5116. String.fromCodePoint = fromCodePoint;
  5117. }
  5118. }());
  5119. }
  5120. })(typeof exports === "undefined" ? sax = {} : exports);
  5121. }).call(this,undefined)
  5122. //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icG1uLW1vZGRsZS9ub2RlX21vZHVsZXMvbW9kZGxlLXhtbC9ub2RlX21vZHVsZXMvc2F4L2xpYi9zYXguanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0F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GdlbmVyYWwgc3R1ZmZcbiwgVEVYVF9FTlRJVFkgICAgICAgICAgICAgICA6IFMrKyAvLyAmYW1wIGFuZCBzdWNoLlxuLCBPUEVOX1dBS0EgICAgICAgICAgICAgICAgIDogUysrIC8vIDxcbiwgU0dNTF9ERUNMICAgICAgICAgICAgICAgICA6IFMrKyAvLyA8IUJMQVJHXG4sIFNHTUxfREVDTF9RVU9URUQgICAgICAgICAgOiBTKysgLy8gPCFCTEFSRyBmb28gXCJiYXJcbiwgRE9DVFlQRSAgICAgICAgICAgICAgICAgICA6IFMrKyAvLyA8IURPQ1RZUEVcbiwgRE9DVFlQRV9RVU9URUQgICAgICAgICAgICA6IFMrKyAvLyA8IURPQ1RZUEUgXCIvL2JsYWhcbiwgRE9DVFlQRV9EVEQgICAgICAgICAgICAgICA6IFMrKyAvLyA8IURPQ1RZUEUgXCIvL2JsYWhcIiBbIC4uLlxuLCBET0NUWVBFX0RURF9RVU9URUQgICAgICAgIDogUysrIC8vIDwhRE9DVFlQRSBcIi8vYmxhaFwiIFsgXCJmb29cbiwgQ09NTUVOVF9TVEFSVElORyAgICAgICAgICA6IFMrKyAvLyA8IS1cbiwgQ09NTUVOVCAgICAgICAgICAgICAgICAgICA6IFMrKyAvLyA8IS0tXG4sIENPTU1FTlRfRU5ESU5HICAgICAgICAgICAgOiBTKysgLy8gPCEtLSBibGFoIC1cbiwgQ09NTUVOVF9FTkRFRCAgICAgICAgICAgICA6IFMrKyAvLyA8IS0tIGJsYWggLS1cbiwgQ0RBVEEgICAgICAgICAgICAgICAgICAgICA6IFMrKyAvLyA8IVtDREFUQVsgc29tZXRoaW5nXG4sIENEQVRBX0VORElORyAgICAgICAgICAgICAgOiBTKysgLy8gXVxuLCBDREFUQV9FTkRJTkdfMiAgICAgICAgICAgIDogUysrIC8vIF1dXG4sIFBST0NfSU5TVCAgICAgICAgICAgICAgICAgOiBTKysgLy8gPD9oaVxuLCBQUk9DX0lOU1RfQk9EWSAgICAgICAgICAgIDogUys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jID0gYyA9IGNodW5rLmNoYXJBdChpKyspKSB7XG4gICAgaWYgKHBhcnNlci50cmFja1Bvc2l0aW9uKSB7XG4gICAgICBwYXJzZXIucG9zaXRpb24gKytcbiAgICAgIGlmIChjID09PSBcIlxcblwiKSB7XG4gICAgICAgIHBhcnNlci5saW5lICsrXG4gICAgICAgIHBhcnNlci5jb2x1bW4gPSAwXG4gICAgICB9IGVsc2UgcGFyc2VyLmNvbHVtbiArK1xuICAgIH1cbiAgICBzd2l0Y2ggKHBhcnNlci5zdGF0ZSkge1xuXG4gICAgICBjYXNlIFMuQkVHSU46XG4gICAgICAgIGlmIChjID09PSBcIjxcIikge1xuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuT1BFTl9XQUtBXG4gICAgICAgICAgcGFyc2VyLnN0YXJ0VGFnUG9zaXRpb24gPSBwYXJzZXIucG9zaXRpb25cbiAgICAgICAgfSBlbHNlIGlmIChub3Qod2hpdGVzcGFjZSxjKSkge1xuICAgICAgICAgIC8vIGhhdmUgdG8gcHJvY2VzcyB0aGlzIGFzIGEgdGV4dCBub2RlLlxuICAgICAgICAgIC8vIHdlaXJkLCBidXQgaGFwcGVucy5cbiAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgXCJOb24td2hpdGVzcGFjZSBiZWZvcmUgZmlyc3QgdGFnLlwiKVxuICAgICAgICAgIHBhcnNlci50ZXh0Tm9kZSA9IGNcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlRFWFRcbiAgICAgICAgfVxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLlRFWFQ6XG4gICAgICAgIGlmIChwYXJzZXIuc2F3Um9vdCAmJiAhcGFyc2VyLmNsb3NlZFJvb3QpIHtcbiAgICAgICAgICB2YXIgc3RhcnRpID0gaS0xXG4gICAgICAgICAgd2hpbGUgKGMgJiYgYyE9PVwiPFwiICYmIGMhPT1cIiZcIikge1xuICAgICAgICAgICAgYyA9IGNodW5rLmNoYXJBdChpKyspXG4gICAgICAgICAgICBpZiAoYyAmJiBwYXJzZXIudHJhY2tQb3NpdGlvbikge1xuICAgICAgICAgICAgICBwYXJzZXIucG9zaXRpb24gKytcbiAgICAgICAgICAgICAgaWYgKGMgPT09IFwiXFxuXCIpIHtcbiAgICAgICAgICAgICAgICBwYXJzZXIubGluZSArK1xuICAgICAgICAgICAgICAgIHBhcnNlci5jb2x1bW4gPSAwXG4gICAgICAgICAgICAgIH0gZWxzZSBwYXJzZXIuY29sdW1uICsrXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIHBhcnNlci50ZXh0Tm9kZSArPSBjaHVuay5zdWJzdHJpbmcoc3RhcnRpLCBpLTEpXG4gICAgICAgIH1cbiAgICAgICAgaWYgKGMgPT09IFwiPFwiKSB7XG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5PUEVOX1dBS0FcbiAgICAgICAgICBwYXJzZXIuc3RhcnRUYWdQb3NpdGlvbiA9IHBhcnNlci5wb3NpdGlvblxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGlmIChub3Qod2hpdGVzcGFjZSwgYykgJiYgKCFwYXJzZXIuc2F3Um9vdCB8fCBwYXJzZXIuY2xvc2VkUm9vdCkpXG4gICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgXCJUZXh0IGRhdGEgb3V0c2lkZSBvZiByb290IG5vZGUuXCIpXG4gICAgICAgICAgaWYgKGMgPT09IFwiJlwiKSBwYXJzZXIuc3RhdGUgPSBTLlRFWFRfRU5USVRZXG4gICAgICAgICAgZWxzZSBwYXJzZXIudGV4dE5vZGUgKz0gY1xuICAgICAgICB9XG4gICAgICBjb250aW51ZVxuXG4gICAgICBjYXNlIFMuU0NSSVBUOlxuICAgICAgICAvLyBvbmx5IG5vbi1zdHJpY3RcbiAgICAgICAgaWYgKGMgPT09IFwiPFwiKSB7XG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5TQ1JJUFRfRU5ESU5HXG4gIC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9XG4gICAgICBjb250aW51ZVxuXG4gICAgICBjYXNlIFMuRE9DVFlQRV9EVERfUVVPVEVEOlxuICAgICAgICBwYXJzZXIuZG9jdHlwZSArPSBjXG4gICAgICAgIGlmIChjID09PSBwYXJzZXIucSkge1xuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRV9EVERcbiAgICAgICAgICBwYXJzZXIucSA9IFwiXCJcbiAgICAgICAgfVxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLkNPTU1FTlQ6XG4gICAgICAgIGlmIChjID09PSBcIi1cIikgcGFyc2VyLnN0YXRlID0gUy5DT01NRU5UX0VORElOR1xuICAgICAgICBlbHNlIHBhcnNlci5jb21tZW50ICs9IGNcbiAgICAgIGNvbnRpbnVlXG5cbiAgICAgIGNhc2UgUy5DT01NRU5UX0VORElORzpcbiAgICAgICAgaWYgKGMgPT09IFwiLVwiKSB7XG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DT01NRU5UX0VOREVEXG4gICAgICAgICAgcGFyc2VyLmNvbW1lbnQgPSB0ZXh0b3B0cyhwYXJzZXIub3B0LCBwYXJzZXIuY29tbWVudClcbiAgICAgICAgICBpZiAocGFyc2VyLmNvbW1lbnQpIGVtaXROb2RlKHBhcnNlciwgXCJvbmNvbW1lbnRcIiwgcGFyc2VyLmNvbW1lbnQpXG4gICAgICAgICAgcGFyc2VyLmNvbW1lbnQgPSBcIlwiXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgcGFyc2VyLmNvbW1lbnQgKz0gXCItXCIgKyBjXG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DT01NRU5UXG4gICAgICAgIH1cbiAgICAgIGNvbnRpbnVlXG5cbiAgICAgIGNhc2UgUy5DT01NRU5UX0VOREVEOlxuICAgICAgICBpZiAoYyAhPT0gXCI+XCIpIHtcbiAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgXCJNYWxmb3JtZWQgY29tbWVudFw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vZnJvbWNvZGVwb2ludCB2MC4xLjAgYnkgQG1hdGhpYXMgKi9cbmlmICghU3RyaW5nLmZyb21Db2RlUG9pbnQpIHtcbiAgICAgICAgKGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIHZhciBzdHJpbmdGcm9tQ2hhckNvZGUgPSBTdHJpbmcuZnJvbUNoYXJDb2RlO1xuICAgICAgICAgICAgICAgIHZhciBmbG9vciA9IE1hdGguZmxvb3I7XG4gICAgICAgICAgICAgICAgdmFyIGZyb21Db2RlUG9pbnQgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBNQVhfU0laRSA9IDB4NDAwMDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBjb2RlVW5pdHMgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBoaWdoU3Vycm9nYXRlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGxvd1N1cnJvZ2F0ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbmRleCA9IC0xO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGxlbmd0aCA9IGFyZ3VtZW50cy5sZW5ndGg7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJyc7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gJyc7XG4gICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoKytpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgY29kZVBvaW50ID0gTnVtYmVyKGFyZ3VtZW50c1tpbmRleF0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIWlzRmluaXRlKGNvZGVQb2ludCkgfHwgLy8gYE5hTmAsIGArSW5maW5pdHlgLCBvciBgLUluZmluaXR5YFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvZGVQb2ludCA8IDAgfHwgLy8gbm90IGEgdmFsaWQgVW5pY29kZSBjb2RlIHBvaW50XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29kZVBvaW50ID4gMHgxMEZGRkYgfHwgLy8gbm90IGEgdmFsaWQgVW5pY29kZSBjb2RlIHBvaW50XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmxvb3IoY29kZVBvaW50KSAhPSBjb2RlUG9pbnQgLy8gbm90IGFuIGludGVnZXJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgUmFuZ2VFcnJvcignSW52YWxpZCBjb2RlIHBvaW50OiAnICsgY29kZVBvaW50KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29kZVBvaW50IDw9IDB4RkZGRikgeyAvLyBCTVAgY29kZSBwb2ludFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvZGVVbml0cy5wdXNoKGNvZGVQb2ludCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7IC8vIEFzdHJhbCBjb2RlIHBvaW50OyBzcGxpdCBpbiBzdXJyb2dhdGUgaGFsdmVzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaHR0cDovL21hdGhpYXNieW5lbnMuYmUvbm90ZXMvamF2YXNjcmlwdC1lbmNvZGluZyNzdXJyb2dhdGUtZm9ybXVsYWVcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2RlUG9pbnQgLT0gMHgxMDAwMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWdoU3Vycm9nYXRlID0gKGNvZGVQb2ludCA+PiAxMCkgKyAweEQ4MDA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG93U3Vycm9nYXRlID0gKGNvZGVQb2ludCAlIDB4NDAwKSArIDB4REMwMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2RlVW5pdHMucHVzaChoaWdoU3Vycm9nYXRlLCBsb3dTdXJyb2dhdGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCArIDEgPT0gbGVuZ3RoIHx8IGNvZGVVbml0cy5sZW5ndGggPiBNQVhfU0laRSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSBzdHJpbmdGcm9tQ2hhckNvZGUuYXBwbHkobnVsbCwgY29kZVVuaXRzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2RlVW5pdHMubGVuZ3RoID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIGlmIChPYmplY3QuZGVmaW5lUHJvcGVydHkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShTdHJpbmcsICdmcm9tQ29kZVBvaW50Jywge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAndmFsdWUnOiBmcm9tQ29kZVBvaW50LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAnY29uZmlndXJhYmxlJzogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJ3dyaXRhYmxlJzogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZy5mcm9tQ29kZVBvaW50ID0gZnJvbUNvZGVQb2ludDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgIH0oKSk7XG59XG5cbn0pKHR5cGVvZiBleHBvcnRzID09PSBcInVuZGVmaW5lZFwiID8gc2F4ID0ge30gOiBleHBvcnRzKTtcbiJdfQ==
  5123. },{"undefined":undefined}],22:[function(_dereq_,module,exports){
  5124. /**
  5125. * Tiny stack for browser or server
  5126. *
  5127. * @author Jason Mulligan <jason.mulligan@avoidwork.com>
  5128. * @copyright 2014 Jason Mulligan
  5129. * @license BSD-3 <https://raw.github.com/avoidwork/tiny-stack/master/LICENSE>
  5130. * @link http://avoidwork.github.io/tiny-stack
  5131. * @module tiny-stack
  5132. * @version 0.1.0
  5133. */
  5134. ( function ( global ) {
  5135. "use strict";
  5136. /**
  5137. * TinyStack
  5138. *
  5139. * @constructor
  5140. */
  5141. function TinyStack () {
  5142. this.data = [null];
  5143. this.top = 0;
  5144. }
  5145. /**
  5146. * Clears the stack
  5147. *
  5148. * @method clear
  5149. * @memberOf TinyStack
  5150. * @return {Object} {@link TinyStack}
  5151. */
  5152. TinyStack.prototype.clear = function clear () {
  5153. this.data = [null];
  5154. this.top = 0;
  5155. return this;
  5156. };
  5157. /**
  5158. * Gets the size of the stack
  5159. *
  5160. * @method length
  5161. * @memberOf TinyStack
  5162. * @return {Number} Size of stack
  5163. */
  5164. TinyStack.prototype.length = function length () {
  5165. return this.top;
  5166. };
  5167. /**
  5168. * Gets the item at the top of the stack
  5169. *
  5170. * @method peek
  5171. * @memberOf TinyStack
  5172. * @return {Mixed} Item at the top of the stack
  5173. */
  5174. TinyStack.prototype.peek = function peek () {
  5175. return this.data[this.top];
  5176. };
  5177. /**
  5178. * Gets & removes the item at the top of the stack
  5179. *
  5180. * @method pop
  5181. * @memberOf TinyStack
  5182. * @return {Mixed} Item at the top of the stack
  5183. */
  5184. TinyStack.prototype.pop = function pop () {
  5185. if ( this.top > 0 ) {
  5186. this.top--;
  5187. return this.data.pop();
  5188. }
  5189. else {
  5190. return undefined;
  5191. }
  5192. };
  5193. /**
  5194. * Pushes an item onto the stack
  5195. *
  5196. * @method push
  5197. * @memberOf TinyStack
  5198. * @return {Object} {@link TinyStack}
  5199. */
  5200. TinyStack.prototype.push = function push ( arg ) {
  5201. this.data[++this.top] = arg;
  5202. return this;
  5203. };
  5204. /**
  5205. * TinyStack factory
  5206. *
  5207. * @method factory
  5208. * @return {Object} {@link TinyStack}
  5209. */
  5210. function factory () {
  5211. return new TinyStack();
  5212. }
  5213. // Node, AMD & window supported
  5214. if ( typeof exports != "undefined" ) {
  5215. module.exports = factory;
  5216. }
  5217. else if ( typeof define == "function" ) {
  5218. define( function () {
  5219. return factory;
  5220. } );
  5221. }
  5222. else {
  5223. global.stack = factory;
  5224. }
  5225. } )( this );
  5226. },{}],23:[function(_dereq_,module,exports){
  5227. module.exports = _dereq_(27);
  5228. },{"27":27}],24:[function(_dereq_,module,exports){
  5229. 'use strict';
  5230. function Base() { }
  5231. Base.prototype.get = function(name) {
  5232. return this.$model.properties.get(this, name);
  5233. };
  5234. Base.prototype.set = function(name, value) {
  5235. this.$model.properties.set(this, name, value);
  5236. };
  5237. module.exports = Base;
  5238. },{}],25:[function(_dereq_,module,exports){
  5239. 'use strict';
  5240. var pick = _dereq_(183),
  5241. assign = _dereq_(177),
  5242. forEach = _dereq_(86);
  5243. var parseNameNs = _dereq_(28).parseName;
  5244. function DescriptorBuilder(nameNs) {
  5245. this.ns = nameNs;
  5246. this.name = nameNs.name;
  5247. this.allTypes = [];
  5248. this.properties = [];
  5249. this.propertiesByName = {};
  5250. }
  5251. module.exports = DescriptorBuilder;
  5252. DescriptorBuilder.prototype.build = function() {
  5253. return pick(this, [ 'ns', 'name', 'allTypes', 'properties', 'propertiesByName', 'bodyProperty' ]);
  5254. };
  5255. DescriptorBuilder.prototype.addProperty = function(p, idx) {
  5256. this.addNamedProperty(p, true);
  5257. var properties = this.properties;
  5258. if (idx !== undefined) {
  5259. properties.splice(idx, 0, p);
  5260. } else {
  5261. properties.push(p);
  5262. }
  5263. };
  5264. DescriptorBuilder.prototype.replaceProperty = function(oldProperty, newProperty) {
  5265. var oldNameNs = oldProperty.ns;
  5266. var props = this.properties,
  5267. propertiesByName = this.propertiesByName,
  5268. rename = oldProperty.name !== newProperty.name;
  5269. if (oldProperty.isBody) {
  5270. if (!newProperty.isBody) {
  5271. throw new Error(
  5272. 'property <' + newProperty.ns.name + '> must be body property ' +
  5273. 'to refine <' + oldProperty.ns.name + '>');
  5274. }
  5275. // TODO: Check compatibility
  5276. this.setBodyProperty(newProperty, false);
  5277. }
  5278. // replacing the named property is intentional
  5279. // thus, validate only if this is a "rename" operation
  5280. this.addNamedProperty(newProperty, rename);
  5281. // replace old property at index with new one
  5282. var idx = props.indexOf(oldProperty);
  5283. if (idx === -1) {
  5284. throw new Error('property <' + oldNameNs.name + '> not found in property list');
  5285. }
  5286. props[idx] = newProperty;
  5287. // replace propertiesByName entry with new property
  5288. propertiesByName[oldNameNs.name] = propertiesByName[oldNameNs.localName] = newProperty;
  5289. };
  5290. DescriptorBuilder.prototype.redefineProperty = function(p) {
  5291. var nsPrefix = p.ns.prefix;
  5292. var parts = p.redefines.split('#');
  5293. var name = parseNameNs(parts[0], nsPrefix);
  5294. var attrName = parseNameNs(parts[1], name.prefix).name;
  5295. var redefinedProperty = this.propertiesByName[attrName];
  5296. if (!redefinedProperty) {
  5297. throw new Error('refined property <' + attrName + '> not found');
  5298. } else {
  5299. this.replaceProperty(redefinedProperty, p);
  5300. }
  5301. delete p.redefines;
  5302. };
  5303. DescriptorBuilder.prototype.addNamedProperty = function(p, validate) {
  5304. var ns = p.ns,
  5305. propsByName = this.propertiesByName;
  5306. if (validate) {
  5307. this.assertNotDefined(p, ns.name);
  5308. this.assertNotDefined(p, ns.localName);
  5309. }
  5310. propsByName[ns.name] = propsByName[ns.localName] = p;
  5311. };
  5312. DescriptorBuilder.prototype.removeNamedProperty = function(p) {
  5313. var ns = p.ns,
  5314. propsByName = this.propertiesByName;
  5315. delete propsByName[ns.name];
  5316. delete propsByName[ns.localName];
  5317. };
  5318. DescriptorBuilder.prototype.setBodyProperty = function(p, validate) {
  5319. if (validate && this.bodyProperty) {
  5320. throw new Error(
  5321. 'body property defined multiple times ' +
  5322. '(<' + this.bodyProperty.ns.name + '>, <' + p.ns.name + '>)');
  5323. }
  5324. this.bodyProperty = p;
  5325. };
  5326. DescriptorBuilder.prototype.addIdProperty = function(name) {
  5327. var nameNs = parseNameNs(name, this.ns.prefix);
  5328. var p = {
  5329. name: nameNs.localName,
  5330. type: 'String',
  5331. isAttr: true,
  5332. ns: nameNs
  5333. };
  5334. // ensure that id is always the first attribute (if present)
  5335. this.addProperty(p, 0);
  5336. };
  5337. DescriptorBuilder.prototype.assertNotDefined = function(p, name) {
  5338. var propertyName = p.name,
  5339. definedProperty = this.propertiesByName[propertyName];
  5340. if (definedProperty) {
  5341. throw new Error(
  5342. 'property <' + propertyName + '> already defined; ' +
  5343. 'override of <' + definedProperty.definedBy.ns.name + '#' + definedProperty.ns.name + '> by ' +
  5344. '<' + p.definedBy.ns.name + '#' + p.ns.name + '> not allowed without redefines');
  5345. }
  5346. };
  5347. DescriptorBuilder.prototype.hasProperty = function(name) {
  5348. return this.propertiesByName[name];
  5349. };
  5350. DescriptorBuilder.prototype.addTrait = function(t) {
  5351. var allTypes = this.allTypes;
  5352. if (allTypes.indexOf(t) !== -1) {
  5353. return;
  5354. }
  5355. forEach(t.properties, function(p) {
  5356. // clone property to allow extensions
  5357. p = assign({}, p, {
  5358. name: p.ns.localName
  5359. });
  5360. Object.defineProperty(p, 'definedBy', {
  5361. value: t
  5362. });
  5363. // add redefine support
  5364. if (p.redefines) {
  5365. this.redefineProperty(p);
  5366. } else {
  5367. if (p.isBody) {
  5368. this.setBodyProperty(p);
  5369. }
  5370. this.addProperty(p);
  5371. }
  5372. }, this);
  5373. allTypes.push(t);
  5374. };
  5375. },{"177":177,"183":183,"28":28,"86":86}],26:[function(_dereq_,module,exports){
  5376. 'use strict';
  5377. var forEach = _dereq_(86);
  5378. var Base = _dereq_(24);
  5379. function Factory(model, properties) {
  5380. this.model = model;
  5381. this.properties = properties;
  5382. }
  5383. module.exports = Factory;
  5384. Factory.prototype.createType = function(descriptor) {
  5385. var model = this.model;
  5386. var props = this.properties,
  5387. prototype = Object.create(Base.prototype);
  5388. // initialize default values
  5389. forEach(descriptor.properties, function(p) {
  5390. if (!p.isMany && p.default !== undefined) {
  5391. prototype[p.name] = p.default;
  5392. }
  5393. });
  5394. props.defineModel(prototype, model);
  5395. props.defineDescriptor(prototype, descriptor);
  5396. var name = descriptor.ns.name;
  5397. /**
  5398. * The new type constructor
  5399. */
  5400. function ModdleElement(attrs) {
  5401. props.define(this, '$type', { value: name, enumerable: true });
  5402. props.define(this, '$attrs', { value: {} });
  5403. props.define(this, '$parent', { writable: true });
  5404. forEach(attrs, function(val, key) {
  5405. this.set(key, val);
  5406. }, this);
  5407. }
  5408. ModdleElement.prototype = prototype;
  5409. ModdleElement.hasType = prototype.$instanceOf = this.model.hasType;
  5410. // static links
  5411. props.defineModel(ModdleElement, model);
  5412. props.defineDescriptor(ModdleElement, descriptor);
  5413. return ModdleElement;
  5414. };
  5415. },{"24":24,"86":86}],27:[function(_dereq_,module,exports){
  5416. 'use strict';
  5417. var isString = _dereq_(174),
  5418. isObject = _dereq_(172),
  5419. forEach = _dereq_(86),
  5420. find = _dereq_(85);
  5421. var Factory = _dereq_(26),
  5422. Registry = _dereq_(30),
  5423. Properties = _dereq_(29);
  5424. var parseNameNs = _dereq_(28).parseName;
  5425. //// Moddle implementation /////////////////////////////////////////////////
  5426. /**
  5427. * @class Moddle
  5428. *
  5429. * A model that can be used to create elements of a specific type.
  5430. *
  5431. * @example
  5432. *
  5433. * var Moddle = require('moddle');
  5434. *
  5435. * var pkg = {
  5436. * name: 'mypackage',
  5437. * prefix: 'my',
  5438. * types: [
  5439. * { name: 'Root' }
  5440. * ]
  5441. * };
  5442. *
  5443. * var moddle = new Moddle([pkg]);
  5444. *
  5445. * @param {Array<Package>} packages the packages to contain
  5446. * @param {Object} options additional options to pass to the model
  5447. */
  5448. function Moddle(packages, options) {
  5449. options = options || {};
  5450. this.properties = new Properties(this);
  5451. this.factory = new Factory(this, this.properties);
  5452. this.registry = new Registry(packages, this.properties, options);
  5453. this.typeCache = {};
  5454. }
  5455. module.exports = Moddle;
  5456. /**
  5457. * Create an instance of the specified type.
  5458. *
  5459. * @method Moddle#create
  5460. *
  5461. * @example
  5462. *
  5463. * var foo = moddle.create('my:Foo');
  5464. * var bar = moddle.create('my:Bar', { id: 'BAR_1' });
  5465. *
  5466. * @param {String|Object} descriptor the type descriptor or name know to the model
  5467. * @param {Object} attrs a number of attributes to initialize the model instance with
  5468. * @return {Object} model instance
  5469. */
  5470. Moddle.prototype.create = function(descriptor, attrs) {
  5471. var Type = this.getType(descriptor);
  5472. if (!Type) {
  5473. throw new Error('unknown type <' + descriptor + '>');
  5474. }
  5475. return new Type(attrs);
  5476. };
  5477. /**
  5478. * Returns the type representing a given descriptor
  5479. *
  5480. * @method Moddle#getType
  5481. *
  5482. * @example
  5483. *
  5484. * var Foo = moddle.getType('my:Foo');
  5485. * var foo = new Foo({ 'id' : 'FOO_1' });
  5486. *
  5487. * @param {String|Object} descriptor the type descriptor or name know to the model
  5488. * @return {Object} the type representing the descriptor
  5489. */
  5490. Moddle.prototype.getType = function(descriptor) {
  5491. var cache = this.typeCache;
  5492. var name = isString(descriptor) ? descriptor : descriptor.ns.name;
  5493. var type = cache[name];
  5494. if (!type) {
  5495. descriptor = this.registry.getEffectiveDescriptor(name);
  5496. type = cache[name] = this.factory.createType(descriptor);
  5497. }
  5498. return type;
  5499. };
  5500. /**
  5501. * Creates an any-element type to be used within model instances.
  5502. *
  5503. * This can be used to create custom elements that lie outside the meta-model.
  5504. * The created element contains all the meta-data required to serialize it
  5505. * as part of meta-model elements.
  5506. *
  5507. * @method Moddle#createAny
  5508. *
  5509. * @example
  5510. *
  5511. * var foo = moddle.createAny('vendor:Foo', 'http://vendor', {
  5512. * value: 'bar'
  5513. * });
  5514. *
  5515. * var container = moddle.create('my:Container', 'http://my', {
  5516. * any: [ foo ]
  5517. * });
  5518. *
  5519. * // go ahead and serialize the stuff
  5520. *
  5521. *
  5522. * @param {String} name the name of the element
  5523. * @param {String} nsUri the namespace uri of the element
  5524. * @param {Object} [properties] a map of properties to initialize the instance with
  5525. * @return {Object} the any type instance
  5526. */
  5527. Moddle.prototype.createAny = function(name, nsUri, properties) {
  5528. var nameNs = parseNameNs(name);
  5529. var element = {
  5530. $type: name
  5531. };
  5532. var descriptor = {
  5533. name: name,
  5534. isGeneric: true,
  5535. ns: {
  5536. prefix: nameNs.prefix,
  5537. localName: nameNs.localName,
  5538. uri: nsUri
  5539. }
  5540. };
  5541. this.properties.defineDescriptor(element, descriptor);
  5542. this.properties.defineModel(element, this);
  5543. this.properties.define(element, '$parent', { enumerable: false, writable: true });
  5544. forEach(properties, function(a, key) {
  5545. if (isObject(a) && a.value !== undefined) {
  5546. element[a.name] = a.value;
  5547. } else {
  5548. element[key] = a;
  5549. }
  5550. });
  5551. return element;
  5552. };
  5553. /**
  5554. * Returns a registered package by uri or prefix
  5555. *
  5556. * @return {Object} the package
  5557. */
  5558. Moddle.prototype.getPackage = function(uriOrPrefix) {
  5559. return this.registry.getPackage(uriOrPrefix);
  5560. };
  5561. /**
  5562. * Returns a snapshot of all known packages
  5563. *
  5564. * @return {Object} the package
  5565. */
  5566. Moddle.prototype.getPackages = function() {
  5567. return this.registry.getPackages();
  5568. };
  5569. /**
  5570. * Returns the descriptor for an element
  5571. */
  5572. Moddle.prototype.getElementDescriptor = function(element) {
  5573. return element.$descriptor;
  5574. };
  5575. /**
  5576. * Returns true if the given descriptor or instance
  5577. * represents the given type.
  5578. *
  5579. * May be applied to this, if element is omitted.
  5580. */
  5581. Moddle.prototype.hasType = function(element, type) {
  5582. if (type === undefined) {
  5583. type = element;
  5584. element = this;
  5585. }
  5586. var descriptor = element.$model.getElementDescriptor(element);
  5587. return !!find(descriptor.allTypes, function(t) {
  5588. return t.name === type;
  5589. });
  5590. };
  5591. /**
  5592. * Returns the descriptor of an elements named property
  5593. */
  5594. Moddle.prototype.getPropertyDescriptor = function(element, property) {
  5595. return this.getElementDescriptor(element).propertiesByName[property];
  5596. };
  5597. },{"172":172,"174":174,"26":26,"28":28,"29":29,"30":30,"85":85,"86":86}],28:[function(_dereq_,module,exports){
  5598. 'use strict';
  5599. /**
  5600. * Parses a namespaced attribute name of the form (ns:)localName to an object,
  5601. * given a default prefix to assume in case no explicit namespace is given.
  5602. *
  5603. * @param {String} name
  5604. * @param {String} [defaultPrefix] the default prefix to take, if none is present.
  5605. *
  5606. * @return {Object} the parsed name
  5607. */
  5608. module.exports.parseName = function(name, defaultPrefix) {
  5609. var parts = name.split(/:/),
  5610. localName, prefix;
  5611. // no prefix (i.e. only local name)
  5612. if (parts.length === 1) {
  5613. localName = name;
  5614. prefix = defaultPrefix;
  5615. } else
  5616. // prefix + local name
  5617. if (parts.length === 2) {
  5618. localName = parts[1];
  5619. prefix = parts[0];
  5620. } else {
  5621. throw new Error('expected <prefix:localName> or <localName>, got ' + name);
  5622. }
  5623. name = (prefix ? prefix + ':' : '') + localName;
  5624. return {
  5625. name: name,
  5626. prefix: prefix,
  5627. localName: localName
  5628. };
  5629. };
  5630. },{}],29:[function(_dereq_,module,exports){
  5631. 'use strict';
  5632. /**
  5633. * A utility that gets and sets properties of model elements.
  5634. *
  5635. * @param {Model} model
  5636. */
  5637. function Properties(model) {
  5638. this.model = model;
  5639. }
  5640. module.exports = Properties;
  5641. /**
  5642. * Sets a named property on the target element
  5643. *
  5644. * @param {Object} target
  5645. * @param {String} name
  5646. * @param {Object} value
  5647. */
  5648. Properties.prototype.set = function(target, name, value) {
  5649. var property = this.model.getPropertyDescriptor(target, name);
  5650. if (!property) {
  5651. target.$attrs[name] = value;
  5652. } else {
  5653. Object.defineProperty(target, property.name, {
  5654. enumerable: !property.isReference,
  5655. writable: true,
  5656. value: value
  5657. });
  5658. }
  5659. };
  5660. /**
  5661. * Returns the named property of the given element
  5662. *
  5663. * @param {Object} target
  5664. * @param {String} name
  5665. *
  5666. * @return {Object}
  5667. */
  5668. Properties.prototype.get = function(target, name) {
  5669. var property = this.model.getPropertyDescriptor(target, name);
  5670. if (!property) {
  5671. return target.$attrs[name];
  5672. }
  5673. var propertyName = property.name;
  5674. // check if access to collection property and lazily initialize it
  5675. if (!target[propertyName] && property.isMany) {
  5676. Object.defineProperty(target, propertyName, {
  5677. enumerable: !property.isReference,
  5678. writable: true,
  5679. value: []
  5680. });
  5681. }
  5682. return target[propertyName];
  5683. };
  5684. /**
  5685. * Define a property on the target element
  5686. *
  5687. * @param {Object} target
  5688. * @param {String} name
  5689. * @param {Object} options
  5690. */
  5691. Properties.prototype.define = function(target, name, options) {
  5692. Object.defineProperty(target, name, options);
  5693. };
  5694. /**
  5695. * Define the descriptor for an element
  5696. */
  5697. Properties.prototype.defineDescriptor = function(target, descriptor) {
  5698. this.define(target, '$descriptor', { value: descriptor });
  5699. };
  5700. /**
  5701. * Define the model for an element
  5702. */
  5703. Properties.prototype.defineModel = function(target, model) {
  5704. this.define(target, '$model', { value: model });
  5705. };
  5706. },{}],30:[function(_dereq_,module,exports){
  5707. 'use strict';
  5708. var assign = _dereq_(177),
  5709. forEach = _dereq_(86);
  5710. var Types = _dereq_(31),
  5711. DescriptorBuilder = _dereq_(25);
  5712. var parseNameNs = _dereq_(28).parseName,
  5713. isBuiltInType = Types.isBuiltIn;
  5714. function Registry(packages, properties, options) {
  5715. this.options = assign({ generateId: 'id' }, options || {});
  5716. this.packageMap = {};
  5717. this.typeMap = {};
  5718. this.packages = [];
  5719. this.properties = properties;
  5720. forEach(packages, this.registerPackage, this);
  5721. }
  5722. module.exports = Registry;
  5723. Registry.prototype.getPackage = function(uriOrPrefix) {
  5724. return this.packageMap[uriOrPrefix];
  5725. };
  5726. Registry.prototype.getPackages = function() {
  5727. return this.packages;
  5728. };
  5729. Registry.prototype.registerPackage = function(pkg) {
  5730. // copy package
  5731. pkg = assign({}, pkg);
  5732. // register types
  5733. forEach(pkg.types, function(descriptor) {
  5734. this.registerType(descriptor, pkg);
  5735. }, this);
  5736. this.packageMap[pkg.uri] = this.packageMap[pkg.prefix] = pkg;
  5737. this.packages.push(pkg);
  5738. };
  5739. /**
  5740. * Register a type from a specific package with us
  5741. */
  5742. Registry.prototype.registerType = function(type, pkg) {
  5743. type = assign({}, type, {
  5744. superClass: (type.superClass || []).slice(),
  5745. extends: (type.extends || []).slice(),
  5746. properties: (type.properties || []).slice()
  5747. });
  5748. var ns = parseNameNs(type.name, pkg.prefix),
  5749. name = ns.name,
  5750. propertiesByName = {};
  5751. // parse properties
  5752. forEach(type.properties, function(p) {
  5753. // namespace property names
  5754. var propertyNs = parseNameNs(p.name, ns.prefix),
  5755. propertyName = propertyNs.name;
  5756. // namespace property types
  5757. if (!isBuiltInType(p.type)) {
  5758. p.type = parseNameNs(p.type, propertyNs.prefix).name;
  5759. }
  5760. assign(p, {
  5761. ns: propertyNs,
  5762. name: propertyName
  5763. });
  5764. propertiesByName[propertyName] = p;
  5765. });
  5766. // update ns + name
  5767. assign(type, {
  5768. ns: ns,
  5769. name: name,
  5770. propertiesByName: propertiesByName
  5771. });
  5772. forEach(type.extends, function(extendsName) {
  5773. var extended = this.typeMap[extendsName];
  5774. extended.traits = extended.traits || [];
  5775. extended.traits.push(name);
  5776. }, this);
  5777. // link to package
  5778. this.definePackage(type, pkg);
  5779. // register
  5780. this.typeMap[name] = type;
  5781. };
  5782. /**
  5783. * Traverse the type hierarchy from bottom to top.
  5784. */
  5785. Registry.prototype.mapTypes = function(nsName, iterator) {
  5786. var type = isBuiltInType(nsName.name) ? { name: nsName.name } : this.typeMap[nsName.name];
  5787. var self = this;
  5788. /**
  5789. * Traverse the selected super type or trait
  5790. *
  5791. * @param {String} cls
  5792. */
  5793. function traverseSuper(cls) {
  5794. var parentNs = parseNameNs(cls, isBuiltInType(cls) ? '' : nsName.prefix);
  5795. self.mapTypes(parentNs, iterator);
  5796. }
  5797. if (!type) {
  5798. throw new Error('unknown type <' + nsName.name + '>');
  5799. }
  5800. forEach(type.superClass, traverseSuper);
  5801. iterator(type);
  5802. forEach(type.traits, traverseSuper);
  5803. };
  5804. /**
  5805. * Returns the effective descriptor for a type.
  5806. *
  5807. * @param {String} type the namespaced name (ns:localName) of the type
  5808. *
  5809. * @return {Descriptor} the resulting effective descriptor
  5810. */
  5811. Registry.prototype.getEffectiveDescriptor = function(name) {
  5812. var nsName = parseNameNs(name);
  5813. var builder = new DescriptorBuilder(nsName);
  5814. this.mapTypes(nsName, function(type) {
  5815. builder.addTrait(type);
  5816. });
  5817. // check we have an id assigned
  5818. var id = this.options.generateId;
  5819. if (id && !builder.hasProperty(id)) {
  5820. builder.addIdProperty(id);
  5821. }
  5822. var descriptor = builder.build();
  5823. // define package link
  5824. this.definePackage(descriptor, descriptor.allTypes[descriptor.allTypes.length - 1].$pkg);
  5825. return descriptor;
  5826. };
  5827. Registry.prototype.definePackage = function(target, pkg) {
  5828. this.properties.define(target, '$pkg', { value: pkg });
  5829. };
  5830. },{"177":177,"25":25,"28":28,"31":31,"86":86}],31:[function(_dereq_,module,exports){
  5831. 'use strict';
  5832. /**
  5833. * Built-in moddle types
  5834. */
  5835. var BUILTINS = {
  5836. String: true,
  5837. Boolean: true,
  5838. Integer: true,
  5839. Real: true,
  5840. Element: true
  5841. };
  5842. /**
  5843. * Converters for built in types from string representations
  5844. */
  5845. var TYPE_CONVERTERS = {
  5846. String: function(s) { return s; },
  5847. Boolean: function(s) { return s === 'true'; },
  5848. Integer: function(s) { return parseInt(s, 10); },
  5849. Real: function(s) { return parseFloat(s, 10); }
  5850. };
  5851. /**
  5852. * Convert a type to its real representation
  5853. */
  5854. module.exports.coerceType = function(type, value) {
  5855. var converter = TYPE_CONVERTERS[type];
  5856. if (converter) {
  5857. return converter(value);
  5858. } else {
  5859. return value;
  5860. }
  5861. };
  5862. /**
  5863. * Return whether the given type is built-in
  5864. */
  5865. module.exports.isBuiltIn = function(type) {
  5866. return !!BUILTINS[type];
  5867. };
  5868. /**
  5869. * Return whether the given type is simple
  5870. */
  5871. module.exports.isSimple = function(type) {
  5872. return !!TYPE_CONVERTERS[type];
  5873. };
  5874. },{}],32:[function(_dereq_,module,exports){
  5875. module.exports={
  5876. "name": "BPMN20",
  5877. "uri": "http://www.omg.org/spec/BPMN/20100524/MODEL",
  5878. "associations": [],
  5879. "types": [
  5880. {
  5881. "name": "Interface",
  5882. "superClass": [
  5883. "RootElement"
  5884. ],
  5885. "properties": [
  5886. {
  5887. "name": "name",
  5888. "isAttr": true,
  5889. "type": "String"
  5890. },
  5891. {
  5892. "name": "operations",
  5893. "type": "Operation",
  5894. "isMany": true
  5895. },
  5896. {
  5897. "name": "implementationRef",
  5898. "type": "String",
  5899. "isAttr": true
  5900. }
  5901. ]
  5902. },
  5903. {
  5904. "name": "Operation",
  5905. "superClass": [
  5906. "BaseElement"
  5907. ],
  5908. "properties": [
  5909. {
  5910. "name": "name",
  5911. "isAttr": true,
  5912. "type": "String"
  5913. },
  5914. {
  5915. "name": "inMessageRef",
  5916. "type": "Message",
  5917. "isAttr": true,
  5918. "isReference": true
  5919. },
  5920. {
  5921. "name": "outMessageRef",
  5922. "type": "Message",
  5923. "isAttr": true,
  5924. "isReference": true
  5925. },
  5926. {
  5927. "name": "errorRefs",
  5928. "type": "Error",
  5929. "isMany": true,
  5930. "isReference": true
  5931. },
  5932. {
  5933. "name": "implementationRef",
  5934. "type": "String",
  5935. "isAttr": true
  5936. }
  5937. ]
  5938. },
  5939. {
  5940. "name": "EndPoint",
  5941. "superClass": [
  5942. "RootElement"
  5943. ]
  5944. },
  5945. {
  5946. "name": "Auditing",
  5947. "superClass": [
  5948. "BaseElement"
  5949. ]
  5950. },
  5951. {
  5952. "name": "GlobalTask",
  5953. "superClass": [
  5954. "CallableElement"
  5955. ],
  5956. "properties": [
  5957. {
  5958. "name": "resources",
  5959. "type": "ResourceRole",
  5960. "isMany": true
  5961. }
  5962. ]
  5963. },
  5964. {
  5965. "name": "Monitoring",
  5966. "superClass": [
  5967. "BaseElement"
  5968. ]
  5969. },
  5970. {
  5971. "name": "Performer",
  5972. "superClass": [
  5973. "ResourceRole"
  5974. ]
  5975. },
  5976. {
  5977. "name": "Process",
  5978. "superClass": [
  5979. "FlowElementsContainer",
  5980. "CallableElement"
  5981. ],
  5982. "properties": [
  5983. {
  5984. "name": "processType",
  5985. "type": "ProcessType",
  5986. "isAttr": true
  5987. },
  5988. {
  5989. "name": "isClosed",
  5990. "isAttr": true,
  5991. "type": "Boolean"
  5992. },
  5993. {
  5994. "name": "auditing",
  5995. "type": "Auditing"
  5996. },
  5997. {
  5998. "name": "monitoring",
  5999. "type": "Monitoring"
  6000. },
  6001. {
  6002. "name": "properties",
  6003. "type": "Property",
  6004. "isMany": true
  6005. },
  6006. {
  6007. "name": "artifacts",
  6008. "type": "Artifact",
  6009. "isMany": true
  6010. },
  6011. {
  6012. "name": "resources",
  6013. "type": "ResourceRole",
  6014. "isMany": true
  6015. },
  6016. {
  6017. "name": "correlationSubscriptions",
  6018. "type": "CorrelationSubscription",
  6019. "isMany": true
  6020. },
  6021. {
  6022. "name": "supports",
  6023. "type": "Process",
  6024. "isMany": true,
  6025. "isReference": true
  6026. },
  6027. {
  6028. "name": "definitionalCollaborationRef",
  6029. "type": "Collaboration",
  6030. "isAttr": true,
  6031. "isReference": true
  6032. },
  6033. {
  6034. "name": "isExecutable",
  6035. "isAttr": true,
  6036. "type": "Boolean"
  6037. }
  6038. ]
  6039. },
  6040. {
  6041. "name": "LaneSet",
  6042. "superClass": [
  6043. "BaseElement"
  6044. ],
  6045. "properties": [
  6046. {
  6047. "name": "lanes",
  6048. "type": "Lane",
  6049. "isMany": true
  6050. },
  6051. {
  6052. "name": "name",
  6053. "isAttr": true,
  6054. "type": "String"
  6055. }
  6056. ]
  6057. },
  6058. {
  6059. "name": "Lane",
  6060. "superClass": [
  6061. "BaseElement"
  6062. ],
  6063. "properties": [
  6064. {
  6065. "name": "name",
  6066. "isAttr": true,
  6067. "type": "String"
  6068. },
  6069. {
  6070. "name": "childLaneSet",
  6071. "type": "LaneSet",
  6072. "xml": {
  6073. "serialize": "xsi:type"
  6074. }
  6075. },
  6076. {
  6077. "name": "partitionElementRef",
  6078. "type": "BaseElement",
  6079. "isAttr": true,
  6080. "isReference": true
  6081. },
  6082. {
  6083. "name": "flowNodeRef",
  6084. "type": "FlowNode",
  6085. "isMany": true,
  6086. "isReference": true
  6087. },
  6088. {
  6089. "name": "partitionElement",
  6090. "type": "BaseElement"
  6091. }
  6092. ]
  6093. },
  6094. {
  6095. "name": "GlobalManualTask",
  6096. "superClass": [
  6097. "GlobalTask"
  6098. ]
  6099. },
  6100. {
  6101. "name": "ManualTask",
  6102. "superClass": [
  6103. "Task"
  6104. ]
  6105. },
  6106. {
  6107. "name": "UserTask",
  6108. "superClass": [
  6109. "Task"
  6110. ],
  6111. "properties": [
  6112. {
  6113. "name": "renderings",
  6114. "type": "Rendering",
  6115. "isMany": true
  6116. },
  6117. {
  6118. "name": "implementation",
  6119. "isAttr": true,
  6120. "type": "String"
  6121. }
  6122. ]
  6123. },
  6124. {
  6125. "name": "Rendering",
  6126. "superClass": [
  6127. "BaseElement"
  6128. ]
  6129. },
  6130. {
  6131. "name": "HumanPerformer",
  6132. "superClass": [
  6133. "Performer"
  6134. ]
  6135. },
  6136. {
  6137. "name": "PotentialOwner",
  6138. "superClass": [
  6139. "HumanPerformer"
  6140. ]
  6141. },
  6142. {
  6143. "name": "GlobalUserTask",
  6144. "superClass": [
  6145. "GlobalTask"
  6146. ],
  6147. "properties": [
  6148. {
  6149. "name": "implementation",
  6150. "isAttr": true,
  6151. "type": "String"
  6152. },
  6153. {
  6154. "name": "renderings",
  6155. "type": "Rendering",
  6156. "isMany": true
  6157. }
  6158. ]
  6159. },
  6160. {
  6161. "name": "Gateway",
  6162. "isAbstract": true,
  6163. "superClass": [
  6164. "FlowNode"
  6165. ],
  6166. "properties": [
  6167. {
  6168. "name": "gatewayDirection",
  6169. "type": "GatewayDirection",
  6170. "default": "Unspecified",
  6171. "isAttr": true
  6172. }
  6173. ]
  6174. },
  6175. {
  6176. "name": "EventBasedGateway",
  6177. "superClass": [
  6178. "Gateway"
  6179. ],
  6180. "properties": [
  6181. {
  6182. "name": "instantiate",
  6183. "default": false,
  6184. "isAttr": true,
  6185. "type": "Boolean"
  6186. },
  6187. {
  6188. "name": "eventGatewayType",
  6189. "type": "EventBasedGatewayType",
  6190. "isAttr": true,
  6191. "default": "Exclusive"
  6192. }
  6193. ]
  6194. },
  6195. {
  6196. "name": "ComplexGateway",
  6197. "superClass": [
  6198. "Gateway"
  6199. ],
  6200. "properties": [
  6201. {
  6202. "name": "activationCondition",
  6203. "type": "Expression",
  6204. "xml": {
  6205. "serialize": "xsi:type"
  6206. }
  6207. },
  6208. {
  6209. "name": "default",
  6210. "type": "SequenceFlow",
  6211. "isAttr": true,
  6212. "isReference": true
  6213. }
  6214. ]
  6215. },
  6216. {
  6217. "name": "ExclusiveGateway",
  6218. "superClass": [
  6219. "Gateway"
  6220. ],
  6221. "properties": [
  6222. {
  6223. "name": "default",
  6224. "type": "SequenceFlow",
  6225. "isAttr": true,
  6226. "isReference": true
  6227. }
  6228. ]
  6229. },
  6230. {
  6231. "name": "InclusiveGateway",
  6232. "superClass": [
  6233. "Gateway"
  6234. ],
  6235. "properties": [
  6236. {
  6237. "name": "default",
  6238. "type": "SequenceFlow",
  6239. "isAttr": true,
  6240. "isReference": true
  6241. }
  6242. ]
  6243. },
  6244. {
  6245. "name": "ParallelGateway",
  6246. "superClass": [
  6247. "Gateway"
  6248. ]
  6249. },
  6250. {
  6251. "name": "RootElement",
  6252. "isAbstract": true,
  6253. "superClass": [
  6254. "BaseElement"
  6255. ]
  6256. },
  6257. {
  6258. "name": "Relationship",
  6259. "superClass": [
  6260. "BaseElement"
  6261. ],
  6262. "properties": [
  6263. {
  6264. "name": "type",
  6265. "isAttr": true,
  6266. "type": "String"
  6267. },
  6268. {
  6269. "name": "direction",
  6270. "type": "RelationshipDirection",
  6271. "isAttr": true
  6272. },
  6273. {
  6274. "name": "source",
  6275. "isMany": true,
  6276. "isReference": true,
  6277. "type": "Element"
  6278. },
  6279. {
  6280. "name": "target",
  6281. "isMany": true,
  6282. "isReference": true,
  6283. "type": "Element"
  6284. }
  6285. ]
  6286. },
  6287. {
  6288. "name": "BaseElement",
  6289. "isAbstract": true,
  6290. "properties": [
  6291. {
  6292. "name": "id",
  6293. "isAttr": true,
  6294. "type": "String"
  6295. },
  6296. {
  6297. "name": "documentation",
  6298. "type": "Documentation",
  6299. "isMany": true
  6300. },
  6301. {
  6302. "name": "extensionDefinitions",
  6303. "type": "ExtensionDefinition",
  6304. "isMany": true,
  6305. "isReference": true
  6306. },
  6307. {
  6308. "name": "extensionElements",
  6309. "type": "ExtensionElements"
  6310. }
  6311. ]
  6312. },
  6313. {
  6314. "name": "Extension",
  6315. "properties": [
  6316. {
  6317. "name": "mustUnderstand",
  6318. "default": false,
  6319. "isAttr": true,
  6320. "type": "Boolean"
  6321. },
  6322. {
  6323. "name": "definition",
  6324. "type": "ExtensionDefinition"
  6325. }
  6326. ]
  6327. },
  6328. {
  6329. "name": "ExtensionDefinition",
  6330. "properties": [
  6331. {
  6332. "name": "name",
  6333. "isAttr": true,
  6334. "type": "String"
  6335. },
  6336. {
  6337. "name": "extensionAttributeDefinitions",
  6338. "type": "ExtensionAttributeDefinition",
  6339. "isMany": true
  6340. }
  6341. ]
  6342. },
  6343. {
  6344. "name": "ExtensionAttributeDefinition",
  6345. "properties": [
  6346. {
  6347. "name": "name",
  6348. "isAttr": true,
  6349. "type": "String"
  6350. },
  6351. {
  6352. "name": "type",
  6353. "isAttr": true,
  6354. "type": "String"
  6355. },
  6356. {
  6357. "name": "isReference",
  6358. "default": false,
  6359. "isAttr": true,
  6360. "type": "Boolean"
  6361. },
  6362. {
  6363. "name": "extensionDefinition",
  6364. "type": "ExtensionDefinition",
  6365. "isAttr": true,
  6366. "isReference": true
  6367. }
  6368. ]
  6369. },
  6370. {
  6371. "name": "ExtensionElements",
  6372. "properties": [
  6373. {
  6374. "name": "valueRef",
  6375. "isAttr": true,
  6376. "isReference": true,
  6377. "type": "Element"
  6378. },
  6379. {
  6380. "name": "values",
  6381. "type": "Element",
  6382. "isMany": true
  6383. },
  6384. {
  6385. "name": "extensionAttributeDefinition",
  6386. "type": "ExtensionAttributeDefinition",
  6387. "isAttr": true,
  6388. "isReference": true
  6389. }
  6390. ]
  6391. },
  6392. {
  6393. "name": "Documentation",
  6394. "superClass": [
  6395. "BaseElement"
  6396. ],
  6397. "properties": [
  6398. {
  6399. "name": "text",
  6400. "type": "String",
  6401. "isBody": true
  6402. },
  6403. {
  6404. "name": "textFormat",
  6405. "default": "text/plain",
  6406. "isAttr": true,
  6407. "type": "String"
  6408. }
  6409. ]
  6410. },
  6411. {
  6412. "name": "Event",
  6413. "isAbstract": true,
  6414. "superClass": [
  6415. "FlowNode",
  6416. "InteractionNode"
  6417. ],
  6418. "properties": [
  6419. {
  6420. "name": "properties",
  6421. "type": "Property",
  6422. "isMany": true
  6423. }
  6424. ]
  6425. },
  6426. {
  6427. "name": "IntermediateCatchEvent",
  6428. "superClass": [
  6429. "CatchEvent"
  6430. ]
  6431. },
  6432. {
  6433. "name": "IntermediateThrowEvent",
  6434. "superClass": [
  6435. "ThrowEvent"
  6436. ]
  6437. },
  6438. {
  6439. "name": "EndEvent",
  6440. "superClass": [
  6441. "ThrowEvent"
  6442. ]
  6443. },
  6444. {
  6445. "name": "StartEvent",
  6446. "superClass": [
  6447. "CatchEvent"
  6448. ],
  6449. "properties": [
  6450. {
  6451. "name": "isInterrupting",
  6452. "default": true,
  6453. "isAttr": true,
  6454. "type": "Boolean"
  6455. }
  6456. ]
  6457. },
  6458. {
  6459. "name": "ThrowEvent",
  6460. "isAbstract": true,
  6461. "superClass": [
  6462. "Event"
  6463. ],
  6464. "properties": [
  6465. {
  6466. "name": "inputSet",
  6467. "type": "InputSet"
  6468. },
  6469. {
  6470. "name": "eventDefinitionRefs",
  6471. "type": "EventDefinition",
  6472. "isMany": true,
  6473. "isReference": true
  6474. },
  6475. {
  6476. "name": "dataInputAssociation",
  6477. "type": "DataInputAssociation",
  6478. "isMany": true
  6479. },
  6480. {
  6481. "name": "dataInputs",
  6482. "type": "DataInput",
  6483. "isMany": true
  6484. },
  6485. {
  6486. "name": "eventDefinitions",
  6487. "type": "EventDefinition",
  6488. "isMany": true
  6489. }
  6490. ]
  6491. },
  6492. {
  6493. "name": "CatchEvent",
  6494. "isAbstract": true,
  6495. "superClass": [
  6496. "Event"
  6497. ],
  6498. "properties": [
  6499. {
  6500. "name": "parallelMultiple",
  6501. "isAttr": true,
  6502. "type": "Boolean",
  6503. "default": false
  6504. },
  6505. {
  6506. "name": "outputSet",
  6507. "type": "OutputSet"
  6508. },
  6509. {
  6510. "name": "eventDefinitionRefs",
  6511. "type": "EventDefinition",
  6512. "isMany": true,
  6513. "isReference": true
  6514. },
  6515. {
  6516. "name": "dataOutputAssociation",
  6517. "type": "DataOutputAssociation",
  6518. "isMany": true
  6519. },
  6520. {
  6521. "name": "dataOutputs",
  6522. "type": "DataOutput",
  6523. "isMany": true
  6524. },
  6525. {
  6526. "name": "eventDefinitions",
  6527. "type": "EventDefinition",
  6528. "isMany": true
  6529. }
  6530. ]
  6531. },
  6532. {
  6533. "name": "BoundaryEvent",
  6534. "superClass": [
  6535. "CatchEvent"
  6536. ],
  6537. "properties": [
  6538. {
  6539. "name": "cancelActivity",
  6540. "default": true,
  6541. "isAttr": true,
  6542. "type": "Boolean"
  6543. },
  6544. {
  6545. "name": "attachedToRef",
  6546. "type": "Activity",
  6547. "isAttr": true,
  6548. "isReference": true
  6549. }
  6550. ]
  6551. },
  6552. {
  6553. "name": "EventDefinition",
  6554. "isAbstract": true,
  6555. "superClass": [
  6556. "RootElement"
  6557. ]
  6558. },
  6559. {
  6560. "name": "CancelEventDefinition",
  6561. "superClass": [
  6562. "EventDefinition"
  6563. ]
  6564. },
  6565. {
  6566. "name": "ErrorEventDefinition",
  6567. "superClass": [
  6568. "EventDefinition"
  6569. ],
  6570. "properties": [
  6571. {
  6572. "name": "errorRef",
  6573. "type": "Error",
  6574. "isAttr": true,
  6575. "isReference": true
  6576. }
  6577. ]
  6578. },
  6579. {
  6580. "name": "TerminateEventDefinition",
  6581. "superClass": [
  6582. "EventDefinition"
  6583. ]
  6584. },
  6585. {
  6586. "name": "EscalationEventDefinition",
  6587. "superClass": [
  6588. "EventDefinition"
  6589. ],
  6590. "properties": [
  6591. {
  6592. "name": "escalationRef",
  6593. "type": "Escalation",
  6594. "isAttr": true,
  6595. "isReference": true
  6596. }
  6597. ]
  6598. },
  6599. {
  6600. "name": "Escalation",
  6601. "properties": [
  6602. {
  6603. "name": "structureRef",
  6604. "type": "ItemDefinition",
  6605. "isAttr": true,
  6606. "isReference": true
  6607. },
  6608. {
  6609. "name": "name",
  6610. "isAttr": true,
  6611. "type": "String"
  6612. },
  6613. {
  6614. "name": "escalationCode",
  6615. "isAttr": true,
  6616. "type": "String"
  6617. }
  6618. ],
  6619. "superClass": [
  6620. "RootElement"
  6621. ]
  6622. },
  6623. {
  6624. "name": "CompensateEventDefinition",
  6625. "superClass": [
  6626. "EventDefinition"
  6627. ],
  6628. "properties": [
  6629. {
  6630. "name": "waitForCompletion",
  6631. "isAttr": true,
  6632. "type": "Boolean"
  6633. },
  6634. {
  6635. "name": "activityRef",
  6636. "type": "Activity",
  6637. "isAttr": true,
  6638. "isReference": true
  6639. }
  6640. ]
  6641. },
  6642. {
  6643. "name": "TimerEventDefinition",
  6644. "superClass": [
  6645. "EventDefinition"
  6646. ],
  6647. "properties": [
  6648. {
  6649. "name": "timeDate",
  6650. "type": "Expression",
  6651. "xml": {
  6652. "serialize": "xsi:type"
  6653. }
  6654. },
  6655. {
  6656. "name": "timeCycle",
  6657. "type": "Expression",
  6658. "xml": {
  6659. "serialize": "xsi:type"
  6660. }
  6661. },
  6662. {
  6663. "name": "timeDuration",
  6664. "type": "Expression",
  6665. "xml": {
  6666. "serialize": "xsi:type"
  6667. }
  6668. }
  6669. ]
  6670. },
  6671. {
  6672. "name": "LinkEventDefinition",
  6673. "superClass": [
  6674. "EventDefinition"
  6675. ],
  6676. "properties": [
  6677. {
  6678. "name": "name",
  6679. "isAttr": true,
  6680. "type": "String"
  6681. },
  6682. {
  6683. "name": "target",
  6684. "type": "LinkEventDefinition",
  6685. "isAttr": true,
  6686. "isReference": true
  6687. },
  6688. {
  6689. "name": "source",
  6690. "type": "LinkEventDefinition",
  6691. "isMany": true,
  6692. "isReference": true
  6693. }
  6694. ]
  6695. },
  6696. {
  6697. "name": "MessageEventDefinition",
  6698. "superClass": [
  6699. "EventDefinition"
  6700. ],
  6701. "properties": [
  6702. {
  6703. "name": "messageRef",
  6704. "type": "Message",
  6705. "isAttr": true,
  6706. "isReference": true
  6707. },
  6708. {
  6709. "name": "operationRef",
  6710. "type": "Operation",
  6711. "isAttr": true,
  6712. "isReference": true
  6713. }
  6714. ]
  6715. },
  6716. {
  6717. "name": "ConditionalEventDefinition",
  6718. "superClass": [
  6719. "EventDefinition"
  6720. ],
  6721. "properties": [
  6722. {
  6723. "name": "condition",
  6724. "type": "Expression",
  6725. "xml": {
  6726. "serialize": "xsi:type"
  6727. }
  6728. }
  6729. ]
  6730. },
  6731. {
  6732. "name": "SignalEventDefinition",
  6733. "superClass": [
  6734. "EventDefinition"
  6735. ],
  6736. "properties": [
  6737. {
  6738. "name": "signalRef",
  6739. "type": "Signal",
  6740. "isAttr": true,
  6741. "isReference": true
  6742. }
  6743. ]
  6744. },
  6745. {
  6746. "name": "Signal",
  6747. "superClass": [
  6748. "RootElement"
  6749. ],
  6750. "properties": [
  6751. {
  6752. "name": "structureRef",
  6753. "type": "ItemDefinition",
  6754. "isAttr": true,
  6755. "isReference": true
  6756. },
  6757. {
  6758. "name": "name",
  6759. "isAttr": true,
  6760. "type": "String"
  6761. }
  6762. ]
  6763. },
  6764. {
  6765. "name": "ImplicitThrowEvent",
  6766. "superClass": [
  6767. "ThrowEvent"
  6768. ]
  6769. },
  6770. {
  6771. "name": "DataState",
  6772. "superClass": [
  6773. "BaseElement"
  6774. ],
  6775. "properties": [
  6776. {
  6777. "name": "name",
  6778. "isAttr": true,
  6779. "type": "String"
  6780. }
  6781. ]
  6782. },
  6783. {
  6784. "name": "ItemAwareElement",
  6785. "superClass": [
  6786. "BaseElement"
  6787. ],
  6788. "properties": [
  6789. {
  6790. "name": "itemSubjectRef",
  6791. "type": "ItemDefinition",
  6792. "isAttr": true,
  6793. "isReference": true
  6794. },
  6795. {
  6796. "name": "dataState",
  6797. "type": "DataState"
  6798. }
  6799. ]
  6800. },
  6801. {
  6802. "name": "DataAssociation",
  6803. "superClass": [
  6804. "BaseElement"
  6805. ],
  6806. "properties": [
  6807. {
  6808. "name": "transformation",
  6809. "type": "FormalExpression"
  6810. },
  6811. {
  6812. "name": "assignment",
  6813. "type": "Assignment",
  6814. "isMany": true
  6815. },
  6816. {
  6817. "name": "sourceRef",
  6818. "type": "ItemAwareElement",
  6819. "isMany": true,
  6820. "isReference": true
  6821. },
  6822. {
  6823. "name": "targetRef",
  6824. "type": "ItemAwareElement",
  6825. "isReference": true
  6826. }
  6827. ]
  6828. },
  6829. {
  6830. "name": "DataInput",
  6831. "superClass": [
  6832. "ItemAwareElement"
  6833. ],
  6834. "properties": [
  6835. {
  6836. "name": "name",
  6837. "isAttr": true,
  6838. "type": "String"
  6839. },
  6840. {
  6841. "name": "isCollection",
  6842. "default": false,
  6843. "isAttr": true,
  6844. "type": "Boolean"
  6845. },
  6846. {
  6847. "name": "inputSetRefs",
  6848. "type": "InputSet",
  6849. "isVirtual": true,
  6850. "isMany": true,
  6851. "isReference": true
  6852. },
  6853. {
  6854. "name": "inputSetWithOptional",
  6855. "type": "InputSet",
  6856. "isVirtual": true,
  6857. "isMany": true,
  6858. "isReference": true
  6859. },
  6860. {
  6861. "name": "inputSetWithWhileExecuting",
  6862. "type": "InputSet",
  6863. "isVirtual": true,
  6864. "isMany": true,
  6865. "isReference": true
  6866. }
  6867. ]
  6868. },
  6869. {
  6870. "name": "DataOutput",
  6871. "superClass": [
  6872. "ItemAwareElement"
  6873. ],
  6874. "properties": [
  6875. {
  6876. "name": "name",
  6877. "isAttr": true,
  6878. "type": "String"
  6879. },
  6880. {
  6881. "name": "isCollection",
  6882. "default": false,
  6883. "isAttr": true,
  6884. "type": "Boolean"
  6885. },
  6886. {
  6887. "name": "outputSetRefs",
  6888. "type": "OutputSet",
  6889. "isVirtual": true,
  6890. "isMany": true,
  6891. "isReference": true
  6892. },
  6893. {
  6894. "name": "outputSetWithOptional",
  6895. "type": "OutputSet",
  6896. "isVirtual": true,
  6897. "isMany": true,
  6898. "isReference": true
  6899. },
  6900. {
  6901. "name": "outputSetWithWhileExecuting",
  6902. "type": "OutputSet",
  6903. "isVirtual": true,
  6904. "isMany": true,
  6905. "isReference": true
  6906. }
  6907. ]
  6908. },
  6909. {
  6910. "name": "InputSet",
  6911. "superClass": [
  6912. "BaseElement"
  6913. ],
  6914. "properties": [
  6915. {
  6916. "name": "name",
  6917. "isAttr": true,
  6918. "type": "String"
  6919. },
  6920. {
  6921. "name": "dataInputRefs",
  6922. "type": "DataInput",
  6923. "isMany": true,
  6924. "isReference": true
  6925. },
  6926. {
  6927. "name": "optionalInputRefs",
  6928. "type": "DataInput",
  6929. "isMany": true,
  6930. "isReference": true
  6931. },
  6932. {
  6933. "name": "whileExecutingInputRefs",
  6934. "type": "DataInput",
  6935. "isMany": true,
  6936. "isReference": true
  6937. },
  6938. {
  6939. "name": "outputSetRefs",
  6940. "type": "OutputSet",
  6941. "isMany": true,
  6942. "isReference": true
  6943. }
  6944. ]
  6945. },
  6946. {
  6947. "name": "OutputSet",
  6948. "superClass": [
  6949. "BaseElement"
  6950. ],
  6951. "properties": [
  6952. {
  6953. "name": "dataOutputRefs",
  6954. "type": "DataOutput",
  6955. "isMany": true,
  6956. "isReference": true
  6957. },
  6958. {
  6959. "name": "name",
  6960. "isAttr": true,
  6961. "type": "String"
  6962. },
  6963. {
  6964. "name": "inputSetRefs",
  6965. "type": "InputSet",
  6966. "isMany": true,
  6967. "isReference": true
  6968. },
  6969. {
  6970. "name": "optionalOutputRefs",
  6971. "type": "DataOutput",
  6972. "isMany": true,
  6973. "isReference": true
  6974. },
  6975. {
  6976. "name": "whileExecutingOutputRefs",
  6977. "type": "DataOutput",
  6978. "isMany": true,
  6979. "isReference": true
  6980. }
  6981. ]
  6982. },
  6983. {
  6984. "name": "Property",
  6985. "superClass": [
  6986. "ItemAwareElement"
  6987. ],
  6988. "properties": [
  6989. {
  6990. "name": "name",
  6991. "isAttr": true,
  6992. "type": "String"
  6993. }
  6994. ]
  6995. },
  6996. {
  6997. "name": "DataInputAssociation",
  6998. "superClass": [
  6999. "DataAssociation"
  7000. ]
  7001. },
  7002. {
  7003. "name": "DataOutputAssociation",
  7004. "superClass": [
  7005. "DataAssociation"
  7006. ]
  7007. },
  7008. {
  7009. "name": "InputOutputSpecification",
  7010. "superClass": [
  7011. "BaseElement"
  7012. ],
  7013. "properties": [
  7014. {
  7015. "name": "dataInputs",
  7016. "type": "DataInput",
  7017. "isMany": true
  7018. },
  7019. {
  7020. "name": "dataOutputs",
  7021. "type": "DataOutput",
  7022. "isMany": true
  7023. },
  7024. {
  7025. "name": "inputSets",
  7026. "type": "InputSet",
  7027. "isMany": true
  7028. },
  7029. {
  7030. "name": "outputSets",
  7031. "type": "OutputSet",
  7032. "isMany": true
  7033. }
  7034. ]
  7035. },
  7036. {
  7037. "name": "DataObject",
  7038. "superClass": [
  7039. "FlowElement",
  7040. "ItemAwareElement"
  7041. ],
  7042. "properties": [
  7043. {
  7044. "name": "isCollection",
  7045. "default": false,
  7046. "isAttr": true,
  7047. "type": "Boolean"
  7048. }
  7049. ]
  7050. },
  7051. {
  7052. "name": "InputOutputBinding",
  7053. "properties": [
  7054. {
  7055. "name": "inputDataRef",
  7056. "type": "InputSet",
  7057. "isAttr": true,
  7058. "isReference": true
  7059. },
  7060. {
  7061. "name": "outputDataRef",
  7062. "type": "OutputSet",
  7063. "isAttr": true,
  7064. "isReference": true
  7065. },
  7066. {
  7067. "name": "operationRef",
  7068. "type": "Operation",
  7069. "isAttr": true,
  7070. "isReference": true
  7071. }
  7072. ]
  7073. },
  7074. {
  7075. "name": "Assignment",
  7076. "superClass": [
  7077. "BaseElement"
  7078. ],
  7079. "properties": [
  7080. {
  7081. "name": "from",
  7082. "type": "Expression",
  7083. "xml": {
  7084. "serialize": "xsi:type"
  7085. }
  7086. },
  7087. {
  7088. "name": "to",
  7089. "type": "Expression",
  7090. "xml": {
  7091. "serialize": "xsi:type"
  7092. }
  7093. }
  7094. ]
  7095. },
  7096. {
  7097. "name": "DataStore",
  7098. "superClass": [
  7099. "RootElement",
  7100. "ItemAwareElement"
  7101. ],
  7102. "properties": [
  7103. {
  7104. "name": "name",
  7105. "isAttr": true,
  7106. "type": "String"
  7107. },
  7108. {
  7109. "name": "capacity",
  7110. "isAttr": true,
  7111. "type": "Integer"
  7112. },
  7113. {
  7114. "name": "isUnlimited",
  7115. "default": true,
  7116. "isAttr": true,
  7117. "type": "Boolean"
  7118. }
  7119. ]
  7120. },
  7121. {
  7122. "name": "DataStoreReference",
  7123. "superClass": [
  7124. "ItemAwareElement",
  7125. "FlowElement"
  7126. ],
  7127. "properties": [
  7128. {
  7129. "name": "dataStoreRef",
  7130. "type": "DataStore",
  7131. "isAttr": true,
  7132. "isReference": true
  7133. }
  7134. ]
  7135. },
  7136. {
  7137. "name": "DataObjectReference",
  7138. "superClass": [
  7139. "ItemAwareElement",
  7140. "FlowElement"
  7141. ],
  7142. "properties": [
  7143. {
  7144. "name": "dataObjectRef",
  7145. "type": "DataObject",
  7146. "isAttr": true,
  7147. "isReference": true
  7148. }
  7149. ]
  7150. },
  7151. {
  7152. "name": "ConversationLink",
  7153. "superClass": [
  7154. "BaseElement"
  7155. ],
  7156. "properties": [
  7157. {
  7158. "name": "sourceRef",
  7159. "type": "InteractionNode",
  7160. "isAttr": true,
  7161. "isReference": true
  7162. },
  7163. {
  7164. "name": "targetRef",
  7165. "type": "InteractionNode",
  7166. "isAttr": true,
  7167. "isReference": true
  7168. },
  7169. {
  7170. "name": "name",
  7171. "isAttr": true,
  7172. "type": "String"
  7173. }
  7174. ]
  7175. },
  7176. {
  7177. "name": "ConversationAssociation",
  7178. "superClass": [
  7179. "BaseElement"
  7180. ],
  7181. "properties": [
  7182. {
  7183. "name": "innerConversationNodeRef",
  7184. "type": "ConversationNode",
  7185. "isAttr": true,
  7186. "isReference": true
  7187. },
  7188. {
  7189. "name": "outerConversationNodeRef",
  7190. "type": "ConversationNode",
  7191. "isAttr": true,
  7192. "isReference": true
  7193. }
  7194. ]
  7195. },
  7196. {
  7197. "name": "CallConversation",
  7198. "superClass": [
  7199. "ConversationNode"
  7200. ],
  7201. "properties": [
  7202. {
  7203. "name": "calledCollaborationRef",
  7204. "type": "Collaboration",
  7205. "isAttr": true,
  7206. "isReference": true
  7207. },
  7208. {
  7209. "name": "participantAssociations",
  7210. "type": "ParticipantAssociation",
  7211. "isMany": true
  7212. }
  7213. ]
  7214. },
  7215. {
  7216. "name": "Conversation",
  7217. "superClass": [
  7218. "ConversationNode"
  7219. ]
  7220. },
  7221. {
  7222. "name": "SubConversation",
  7223. "superClass": [
  7224. "ConversationNode"
  7225. ],
  7226. "properties": [
  7227. {
  7228. "name": "conversationNodes",
  7229. "type": "ConversationNode",
  7230. "isMany": true
  7231. }
  7232. ]
  7233. },
  7234. {
  7235. "name": "ConversationNode",
  7236. "isAbstract": true,
  7237. "superClass": [
  7238. "InteractionNode",
  7239. "BaseElement"
  7240. ],
  7241. "properties": [
  7242. {
  7243. "name": "name",
  7244. "isAttr": true,
  7245. "type": "String"
  7246. },
  7247. {
  7248. "name": "participantRefs",
  7249. "type": "Participant",
  7250. "isMany": true,
  7251. "isReference": true
  7252. },
  7253. {
  7254. "name": "messageFlowRefs",
  7255. "type": "MessageFlow",
  7256. "isMany": true,
  7257. "isReference": true
  7258. },
  7259. {
  7260. "name": "correlationKeys",
  7261. "type": "CorrelationKey",
  7262. "isMany": true
  7263. }
  7264. ]
  7265. },
  7266. {
  7267. "name": "GlobalConversation",
  7268. "superClass": [
  7269. "Collaboration"
  7270. ]
  7271. },
  7272. {
  7273. "name": "PartnerEntity",
  7274. "superClass": [
  7275. "RootElement"
  7276. ],
  7277. "properties": [
  7278. {
  7279. "name": "name",
  7280. "isAttr": true,
  7281. "type": "String"
  7282. },
  7283. {
  7284. "name": "participantRef",
  7285. "type": "Participant",
  7286. "isMany": true,
  7287. "isReference": true
  7288. }
  7289. ]
  7290. },
  7291. {
  7292. "name": "PartnerRole",
  7293. "superClass": [
  7294. "RootElement"
  7295. ],
  7296. "properties": [
  7297. {
  7298. "name": "name",
  7299. "isAttr": true,
  7300. "type": "String"
  7301. },
  7302. {
  7303. "name": "participantRef",
  7304. "type": "Participant",
  7305. "isMany": true,
  7306. "isReference": true
  7307. }
  7308. ]
  7309. },
  7310. {
  7311. "name": "CorrelationProperty",
  7312. "superClass": [
  7313. "RootElement"
  7314. ],
  7315. "properties": [
  7316. {
  7317. "name": "correlationPropertyRetrievalExpression",
  7318. "type": "CorrelationPropertyRetrievalExpression",
  7319. "isMany": true
  7320. },
  7321. {
  7322. "name": "name",
  7323. "isAttr": true,
  7324. "type": "String"
  7325. },
  7326. {
  7327. "name": "type",
  7328. "type": "ItemDefinition",
  7329. "isAttr": true,
  7330. "isReference": true
  7331. }
  7332. ]
  7333. },
  7334. {
  7335. "name": "Error",
  7336. "superClass": [
  7337. "RootElement"
  7338. ],
  7339. "properties": [
  7340. {
  7341. "name": "structureRef",
  7342. "type": "ItemDefinition",
  7343. "isAttr": true,
  7344. "isReference": true
  7345. },
  7346. {
  7347. "name": "name",
  7348. "isAttr": true,
  7349. "type": "String"
  7350. },
  7351. {
  7352. "name": "errorCode",
  7353. "isAttr": true,
  7354. "type": "String"
  7355. }
  7356. ]
  7357. },
  7358. {
  7359. "name": "CorrelationKey",
  7360. "superClass": [
  7361. "BaseElement"
  7362. ],
  7363. "properties": [
  7364. {
  7365. "name": "correlationPropertyRef",
  7366. "type": "CorrelationProperty",
  7367. "isMany": true,
  7368. "isReference": true
  7369. },
  7370. {
  7371. "name": "name",
  7372. "isAttr": true,
  7373. "type": "String"
  7374. }
  7375. ]
  7376. },
  7377. {
  7378. "name": "Expression",
  7379. "superClass": [
  7380. "BaseElement"
  7381. ],
  7382. "isAbstract": true
  7383. },
  7384. {
  7385. "name": "FormalExpression",
  7386. "superClass": [
  7387. "Expression"
  7388. ],
  7389. "properties": [
  7390. {
  7391. "name": "language",
  7392. "isAttr": true,
  7393. "type": "String"
  7394. },
  7395. {
  7396. "name": "body",
  7397. "type": "String",
  7398. "isBody": true
  7399. },
  7400. {
  7401. "name": "evaluatesToTypeRef",
  7402. "type": "ItemDefinition",
  7403. "isAttr": true,
  7404. "isReference": true
  7405. }
  7406. ]
  7407. },
  7408. {
  7409. "name": "Message",
  7410. "superClass": [
  7411. "RootElement"
  7412. ],
  7413. "properties": [
  7414. {
  7415. "name": "name",
  7416. "isAttr": true,
  7417. "type": "String"
  7418. },
  7419. {
  7420. "name": "itemRef",
  7421. "type": "ItemDefinition",
  7422. "isAttr": true,
  7423. "isReference": true
  7424. }
  7425. ]
  7426. },
  7427. {
  7428. "name": "ItemDefinition",
  7429. "superClass": [
  7430. "RootElement"
  7431. ],
  7432. "properties": [
  7433. {
  7434. "name": "itemKind",
  7435. "type": "ItemKind",
  7436. "isAttr": true
  7437. },
  7438. {
  7439. "name": "structureRef",
  7440. "type": "String",
  7441. "isAttr": true
  7442. },
  7443. {
  7444. "name": "isCollection",
  7445. "default": false,
  7446. "isAttr": true,
  7447. "type": "Boolean"
  7448. },
  7449. {
  7450. "name": "import",
  7451. "type": "Import",
  7452. "isAttr": true,
  7453. "isReference": true
  7454. }
  7455. ]
  7456. },
  7457. {
  7458. "name": "FlowElement",
  7459. "isAbstract": true,
  7460. "superClass": [
  7461. "BaseElement"
  7462. ],
  7463. "properties": [
  7464. {
  7465. "name": "name",
  7466. "isAttr": true,
  7467. "type": "String"
  7468. },
  7469. {
  7470. "name": "auditing",
  7471. "type": "Auditing"
  7472. },
  7473. {
  7474. "name": "monitoring",
  7475. "type": "Monitoring"
  7476. },
  7477. {
  7478. "name": "categoryValueRef",
  7479. "type": "CategoryValue",
  7480. "isMany": true,
  7481. "isReference": true
  7482. }
  7483. ]
  7484. },
  7485. {
  7486. "name": "SequenceFlow",
  7487. "superClass": [
  7488. "FlowElement"
  7489. ],
  7490. "properties": [
  7491. {
  7492. "name": "isImmediate",
  7493. "isAttr": true,
  7494. "type": "Boolean"
  7495. },
  7496. {
  7497. "name": "conditionExpression",
  7498. "type": "Expression",
  7499. "xml": {
  7500. "serialize": "xsi:type"
  7501. }
  7502. },
  7503. {
  7504. "name": "sourceRef",
  7505. "type": "FlowNode",
  7506. "isAttr": true,
  7507. "isReference": true
  7508. },
  7509. {
  7510. "name": "targetRef",
  7511. "type": "FlowNode",
  7512. "isAttr": true,
  7513. "isReference": true
  7514. }
  7515. ]
  7516. },
  7517. {
  7518. "name": "FlowElementsContainer",
  7519. "isAbstract": true,
  7520. "superClass": [
  7521. "BaseElement"
  7522. ],
  7523. "properties": [
  7524. {
  7525. "name": "laneSets",
  7526. "type": "LaneSet",
  7527. "isMany": true
  7528. },
  7529. {
  7530. "name": "flowElements",
  7531. "type": "FlowElement",
  7532. "isMany": true
  7533. }
  7534. ]
  7535. },
  7536. {
  7537. "name": "CallableElement",
  7538. "isAbstract": true,
  7539. "superClass": [
  7540. "RootElement"
  7541. ],
  7542. "properties": [
  7543. {
  7544. "name": "name",
  7545. "isAttr": true,
  7546. "type": "String"
  7547. },
  7548. {
  7549. "name": "ioSpecification",
  7550. "type": "InputOutputSpecification",
  7551. "xml": {
  7552. "serialize": "property"
  7553. }
  7554. },
  7555. {
  7556. "name": "supportedInterfaceRefs",
  7557. "type": "Interface",
  7558. "isMany": true,
  7559. "isReference": true
  7560. },
  7561. {
  7562. "name": "ioBinding",
  7563. "type": "InputOutputBinding",
  7564. "isMany": true,
  7565. "xml": {
  7566. "serialize": "property"
  7567. }
  7568. }
  7569. ]
  7570. },
  7571. {
  7572. "name": "FlowNode",
  7573. "isAbstract": true,
  7574. "superClass": [
  7575. "FlowElement"
  7576. ],
  7577. "properties": [
  7578. {
  7579. "name": "incoming",
  7580. "type": "SequenceFlow",
  7581. "isMany": true,
  7582. "isReference": true
  7583. },
  7584. {
  7585. "name": "outgoing",
  7586. "type": "SequenceFlow",
  7587. "isMany": true,
  7588. "isReference": true
  7589. },
  7590. {
  7591. "name": "lanes",
  7592. "type": "Lane",
  7593. "isVirtual": true,
  7594. "isMany": true,
  7595. "isReference": true
  7596. }
  7597. ]
  7598. },
  7599. {
  7600. "name": "CorrelationPropertyRetrievalExpression",
  7601. "superClass": [
  7602. "BaseElement"
  7603. ],
  7604. "properties": [
  7605. {
  7606. "name": "messagePath",
  7607. "type": "FormalExpression"
  7608. },
  7609. {
  7610. "name": "messageRef",
  7611. "type": "Message",
  7612. "isAttr": true,
  7613. "isReference": true
  7614. }
  7615. ]
  7616. },
  7617. {
  7618. "name": "CorrelationPropertyBinding",
  7619. "superClass": [
  7620. "BaseElement"
  7621. ],
  7622. "properties": [
  7623. {
  7624. "name": "dataPath",
  7625. "type": "FormalExpression"
  7626. },
  7627. {
  7628. "name": "correlationPropertyRef",
  7629. "type": "CorrelationProperty",
  7630. "isAttr": true,
  7631. "isReference": true
  7632. }
  7633. ]
  7634. },
  7635. {
  7636. "name": "Resource",
  7637. "superClass": [
  7638. "RootElement"
  7639. ],
  7640. "properties": [
  7641. {
  7642. "name": "name",
  7643. "isAttr": true,
  7644. "type": "String"
  7645. },
  7646. {
  7647. "name": "resourceParameters",
  7648. "type": "ResourceParameter",
  7649. "isMany": true
  7650. }
  7651. ]
  7652. },
  7653. {
  7654. "name": "ResourceParameter",
  7655. "superClass": [
  7656. "BaseElement"
  7657. ],
  7658. "properties": [
  7659. {
  7660. "name": "name",
  7661. "isAttr": true,
  7662. "type": "String"
  7663. },
  7664. {
  7665. "name": "isRequired",
  7666. "isAttr": true,
  7667. "type": "Boolean"
  7668. },
  7669. {
  7670. "name": "type",
  7671. "type": "ItemDefinition",
  7672. "isAttr": true,
  7673. "isReference": true
  7674. }
  7675. ]
  7676. },
  7677. {
  7678. "name": "CorrelationSubscription",
  7679. "superClass": [
  7680. "BaseElement"
  7681. ],
  7682. "properties": [
  7683. {
  7684. "name": "correlationKeyRef",
  7685. "type": "CorrelationKey",
  7686. "isAttr": true,
  7687. "isReference": true
  7688. },
  7689. {
  7690. "name": "correlationPropertyBinding",
  7691. "type": "CorrelationPropertyBinding",
  7692. "isMany": true
  7693. }
  7694. ]
  7695. },
  7696. {
  7697. "name": "MessageFlow",
  7698. "superClass": [
  7699. "BaseElement"
  7700. ],
  7701. "properties": [
  7702. {
  7703. "name": "name",
  7704. "isAttr": true,
  7705. "type": "String"
  7706. },
  7707. {
  7708. "name": "sourceRef",
  7709. "type": "InteractionNode",
  7710. "isAttr": true,
  7711. "isReference": true
  7712. },
  7713. {
  7714. "name": "targetRef",
  7715. "type": "InteractionNode",
  7716. "isAttr": true,
  7717. "isReference": true
  7718. },
  7719. {
  7720. "name": "messageRef",
  7721. "type": "Message",
  7722. "isAttr": true,
  7723. "isReference": true
  7724. }
  7725. ]
  7726. },
  7727. {
  7728. "name": "MessageFlowAssociation",
  7729. "superClass": [
  7730. "BaseElement"
  7731. ],
  7732. "properties": [
  7733. {
  7734. "name": "innerMessageFlowRef",
  7735. "type": "MessageFlow",
  7736. "isAttr": true,
  7737. "isReference": true
  7738. },
  7739. {
  7740. "name": "outerMessageFlowRef",
  7741. "type": "MessageFlow",
  7742. "isAttr": true,
  7743. "isReference": true
  7744. }
  7745. ]
  7746. },
  7747. {
  7748. "name": "InteractionNode",
  7749. "isAbstract": true,
  7750. "properties": [
  7751. {
  7752. "name": "incomingConversationLinks",
  7753. "type": "ConversationLink",
  7754. "isVirtual": true,
  7755. "isMany": true,
  7756. "isReference": true
  7757. },
  7758. {
  7759. "name": "outgoingConversationLinks",
  7760. "type": "ConversationLink",
  7761. "isVirtual": true,
  7762. "isMany": true,
  7763. "isReference": true
  7764. }
  7765. ]
  7766. },
  7767. {
  7768. "name": "Participant",
  7769. "superClass": [
  7770. "InteractionNode",
  7771. "BaseElement"
  7772. ],
  7773. "properties": [
  7774. {
  7775. "name": "name",
  7776. "isAttr": true,
  7777. "type": "String"
  7778. },
  7779. {
  7780. "name": "interfaceRefs",
  7781. "type": "Interface",
  7782. "isMany": true,
  7783. "isReference": true
  7784. },
  7785. {
  7786. "name": "participantMultiplicity",
  7787. "type": "ParticipantMultiplicity"
  7788. },
  7789. {
  7790. "name": "endPointRefs",
  7791. "type": "EndPoint",
  7792. "isMany": true,
  7793. "isReference": true
  7794. },
  7795. {
  7796. "name": "processRef",
  7797. "type": "Process",
  7798. "isAttr": true,
  7799. "isReference": true
  7800. }
  7801. ]
  7802. },
  7803. {
  7804. "name": "ParticipantAssociation",
  7805. "superClass": [
  7806. "BaseElement"
  7807. ],
  7808. "properties": [
  7809. {
  7810. "name": "innerParticipantRef",
  7811. "type": "Participant",
  7812. "isAttr": true,
  7813. "isReference": true
  7814. },
  7815. {
  7816. "name": "outerParticipantRef",
  7817. "type": "Participant",
  7818. "isAttr": true,
  7819. "isReference": true
  7820. }
  7821. ]
  7822. },
  7823. {
  7824. "name": "ParticipantMultiplicity",
  7825. "properties": [
  7826. {
  7827. "name": "minimum",
  7828. "default": 0,
  7829. "isAttr": true,
  7830. "type": "Integer"
  7831. },
  7832. {
  7833. "name": "maximum",
  7834. "default": 1,
  7835. "isAttr": true,
  7836. "type": "Integer"
  7837. }
  7838. ]
  7839. },
  7840. {
  7841. "name": "Collaboration",
  7842. "superClass": [
  7843. "RootElement"
  7844. ],
  7845. "properties": [
  7846. {
  7847. "name": "name",
  7848. "isAttr": true,
  7849. "type": "String"
  7850. },
  7851. {
  7852. "name": "isClosed",
  7853. "isAttr": true,
  7854. "type": "Boolean"
  7855. },
  7856. {
  7857. "name": "choreographyRef",
  7858. "type": "Choreography",
  7859. "isMany": true,
  7860. "isReference": true
  7861. },
  7862. {
  7863. "name": "artifacts",
  7864. "type": "Artifact",
  7865. "isMany": true
  7866. },
  7867. {
  7868. "name": "participantAssociations",
  7869. "type": "ParticipantAssociation",
  7870. "isMany": true
  7871. },
  7872. {
  7873. "name": "messageFlowAssociations",
  7874. "type": "MessageFlowAssociation",
  7875. "isMany": true
  7876. },
  7877. {
  7878. "name": "conversationAssociations",
  7879. "type": "ConversationAssociation"
  7880. },
  7881. {
  7882. "name": "participants",
  7883. "type": "Participant",
  7884. "isMany": true
  7885. },
  7886. {
  7887. "name": "messageFlows",
  7888. "type": "MessageFlow",
  7889. "isMany": true
  7890. },
  7891. {
  7892. "name": "correlationKeys",
  7893. "type": "CorrelationKey",
  7894. "isMany": true
  7895. },
  7896. {
  7897. "name": "conversations",
  7898. "type": "ConversationNode",
  7899. "isMany": true
  7900. },
  7901. {
  7902. "name": "conversationLinks",
  7903. "type": "ConversationLink",
  7904. "isMany": true
  7905. }
  7906. ]
  7907. },
  7908. {
  7909. "name": "ChoreographyActivity",
  7910. "isAbstract": true,
  7911. "superClass": [
  7912. "FlowNode"
  7913. ],
  7914. "properties": [
  7915. {
  7916. "name": "participantRefs",
  7917. "type": "Participant",
  7918. "isMany": true,
  7919. "isReference": true
  7920. },
  7921. {
  7922. "name": "initiatingParticipantRef",
  7923. "type": "Participant",
  7924. "isAttr": true,
  7925. "isReference": true
  7926. },
  7927. {
  7928. "name": "correlationKeys",
  7929. "type": "CorrelationKey",
  7930. "isMany": true
  7931. },
  7932. {
  7933. "name": "loopType",
  7934. "type": "ChoreographyLoopType",
  7935. "default": "None",
  7936. "isAttr": true
  7937. }
  7938. ]
  7939. },
  7940. {
  7941. "name": "CallChoreography",
  7942. "superClass": [
  7943. "ChoreographyActivity"
  7944. ],
  7945. "properties": [
  7946. {
  7947. "name": "calledChoreographyRef",
  7948. "type": "Choreography",
  7949. "isAttr": true,
  7950. "isReference": true
  7951. },
  7952. {
  7953. "name": "participantAssociations",
  7954. "type": "ParticipantAssociation",
  7955. "isMany": true
  7956. }
  7957. ]
  7958. },
  7959. {
  7960. "name": "SubChoreography",
  7961. "superClass": [
  7962. "ChoreographyActivity",
  7963. "FlowElementsContainer"
  7964. ],
  7965. "properties": [
  7966. {
  7967. "name": "artifacts",
  7968. "type": "Artifact",
  7969. "isMany": true
  7970. }
  7971. ]
  7972. },
  7973. {
  7974. "name": "ChoreographyTask",
  7975. "superClass": [
  7976. "ChoreographyActivity"
  7977. ],
  7978. "properties": [
  7979. {
  7980. "name": "messageFlowRef",
  7981. "type": "MessageFlow",
  7982. "isMany": true,
  7983. "isReference": true
  7984. }
  7985. ]
  7986. },
  7987. {
  7988. "name": "Choreography",
  7989. "superClass": [
  7990. "FlowElementsContainer",
  7991. "Collaboration"
  7992. ]
  7993. },
  7994. {
  7995. "name": "GlobalChoreographyTask",
  7996. "superClass": [
  7997. "Choreography"
  7998. ],
  7999. "properties": [
  8000. {
  8001. "name": "initiatingParticipantRef",
  8002. "type": "Participant",
  8003. "isAttr": true,
  8004. "isReference": true
  8005. }
  8006. ]
  8007. },
  8008. {
  8009. "name": "TextAnnotation",
  8010. "superClass": [
  8011. "Artifact"
  8012. ],
  8013. "properties": [
  8014. {
  8015. "name": "text",
  8016. "type": "String"
  8017. },
  8018. {
  8019. "name": "textFormat",
  8020. "default": "text/plain",
  8021. "isAttr": true,
  8022. "type": "String"
  8023. }
  8024. ]
  8025. },
  8026. {
  8027. "name": "Group",
  8028. "superClass": [
  8029. "Artifact"
  8030. ],
  8031. "properties": [
  8032. {
  8033. "name": "categoryValueRef",
  8034. "type": "CategoryValue",
  8035. "isAttr": true,
  8036. "isReference": true
  8037. }
  8038. ]
  8039. },
  8040. {
  8041. "name": "Association",
  8042. "superClass": [
  8043. "Artifact"
  8044. ],
  8045. "properties": [
  8046. {
  8047. "name": "associationDirection",
  8048. "type": "AssociationDirection",
  8049. "isAttr": true
  8050. },
  8051. {
  8052. "name": "sourceRef",
  8053. "type": "BaseElement",
  8054. "isAttr": true,
  8055. "isReference": true
  8056. },
  8057. {
  8058. "name": "targetRef",
  8059. "type": "BaseElement",
  8060. "isAttr": true,
  8061. "isReference": true
  8062. }
  8063. ]
  8064. },
  8065. {
  8066. "name": "Category",
  8067. "superClass": [
  8068. "RootElement"
  8069. ],
  8070. "properties": [
  8071. {
  8072. "name": "categoryValue",
  8073. "type": "CategoryValue",
  8074. "isMany": true
  8075. },
  8076. {
  8077. "name": "name",
  8078. "isAttr": true,
  8079. "type": "String"
  8080. }
  8081. ]
  8082. },
  8083. {
  8084. "name": "Artifact",
  8085. "isAbstract": true,
  8086. "superClass": [
  8087. "BaseElement"
  8088. ]
  8089. },
  8090. {
  8091. "name": "CategoryValue",
  8092. "superClass": [
  8093. "BaseElement"
  8094. ],
  8095. "properties": [
  8096. {
  8097. "name": "categorizedFlowElements",
  8098. "type": "FlowElement",
  8099. "isVirtual": true,
  8100. "isMany": true,
  8101. "isReference": true
  8102. },
  8103. {
  8104. "name": "value",
  8105. "isAttr": true,
  8106. "type": "String"
  8107. }
  8108. ]
  8109. },
  8110. {
  8111. "name": "Activity",
  8112. "isAbstract": true,
  8113. "superClass": [
  8114. "FlowNode"
  8115. ],
  8116. "properties": [
  8117. {
  8118. "name": "isForCompensation",
  8119. "default": false,
  8120. "isAttr": true,
  8121. "type": "Boolean"
  8122. },
  8123. {
  8124. "name": "default",
  8125. "type": "SequenceFlow",
  8126. "isAttr": true,
  8127. "isReference": true
  8128. },
  8129. {
  8130. "name": "ioSpecification",
  8131. "type": "InputOutputSpecification",
  8132. "xml": {
  8133. "serialize": "property"
  8134. }
  8135. },
  8136. {
  8137. "name": "boundaryEventRefs",
  8138. "type": "BoundaryEvent",
  8139. "isMany": true,
  8140. "isReference": true
  8141. },
  8142. {
  8143. "name": "properties",
  8144. "type": "Property",
  8145. "isMany": true
  8146. },
  8147. {
  8148. "name": "dataInputAssociations",
  8149. "type": "DataInputAssociation",
  8150. "isMany": true
  8151. },
  8152. {
  8153. "name": "dataOutputAssociations",
  8154. "type": "DataOutputAssociation",
  8155. "isMany": true
  8156. },
  8157. {
  8158. "name": "startQuantity",
  8159. "default": 1,
  8160. "isAttr": true,
  8161. "type": "Integer"
  8162. },
  8163. {
  8164. "name": "resources",
  8165. "type": "ResourceRole",
  8166. "isMany": true
  8167. },
  8168. {
  8169. "name": "completionQuantity",
  8170. "default": 1,
  8171. "isAttr": true,
  8172. "type": "Integer"
  8173. },
  8174. {
  8175. "name": "loopCharacteristics",
  8176. "type": "LoopCharacteristics"
  8177. }
  8178. ]
  8179. },
  8180. {
  8181. "name": "ServiceTask",
  8182. "superClass": [
  8183. "Task"
  8184. ],
  8185. "properties": [
  8186. {
  8187. "name": "implementation",
  8188. "isAttr": true,
  8189. "type": "String"
  8190. },
  8191. {
  8192. "name": "operationRef",
  8193. "type": "Operation",
  8194. "isAttr": true,
  8195. "isReference": true
  8196. }
  8197. ]
  8198. },
  8199. {
  8200. "name": "SubProcess",
  8201. "superClass": [
  8202. "Activity",
  8203. "FlowElementsContainer",
  8204. "InteractionNode"
  8205. ],
  8206. "properties": [
  8207. {
  8208. "name": "triggeredByEvent",
  8209. "default": false,
  8210. "isAttr": true,
  8211. "type": "Boolean"
  8212. },
  8213. {
  8214. "name": "artifacts",
  8215. "type": "Artifact",
  8216. "isMany": true
  8217. }
  8218. ]
  8219. },
  8220. {
  8221. "name": "LoopCharacteristics",
  8222. "isAbstract": true,
  8223. "superClass": [
  8224. "BaseElement"
  8225. ]
  8226. },
  8227. {
  8228. "name": "MultiInstanceLoopCharacteristics",
  8229. "superClass": [
  8230. "LoopCharacteristics"
  8231. ],
  8232. "properties": [
  8233. {
  8234. "name": "isSequential",
  8235. "default": false,
  8236. "isAttr": true,
  8237. "type": "Boolean"
  8238. },
  8239. {
  8240. "name": "behavior",
  8241. "type": "MultiInstanceBehavior",
  8242. "default": "All",
  8243. "isAttr": true
  8244. },
  8245. {
  8246. "name": "loopCardinality",
  8247. "type": "Expression",
  8248. "xml": {
  8249. "serialize": "xsi:type"
  8250. }
  8251. },
  8252. {
  8253. "name": "loopDataInputRef",
  8254. "type": "ItemAwareElement",
  8255. "isAttr": true,
  8256. "isReference": true
  8257. },
  8258. {
  8259. "name": "loopDataOutputRef",
  8260. "type": "ItemAwareElement",
  8261. "isAttr": true,
  8262. "isReference": true
  8263. },
  8264. {
  8265. "name": "inputDataItem",
  8266. "type": "DataInput"
  8267. },
  8268. {
  8269. "name": "outputDataItem",
  8270. "type": "DataOutput"
  8271. },
  8272. {
  8273. "name": "completionCondition",
  8274. "type": "Expression",
  8275. "xml": {
  8276. "serialize": "xsi:type"
  8277. }
  8278. },
  8279. {
  8280. "name": "complexBehaviorDefinition",
  8281. "type": "ComplexBehaviorDefinition",
  8282. "isMany": true
  8283. },
  8284. {
  8285. "name": "oneBehaviorEventRef",
  8286. "type": "EventDefinition",
  8287. "isAttr": true,
  8288. "isReference": true
  8289. },
  8290. {
  8291. "name": "noneBehaviorEventRef",
  8292. "type": "EventDefinition",
  8293. "isAttr": true,
  8294. "isReference": true
  8295. }
  8296. ]
  8297. },
  8298. {
  8299. "name": "StandardLoopCharacteristics",
  8300. "superClass": [
  8301. "LoopCharacteristics"
  8302. ],
  8303. "properties": [
  8304. {
  8305. "name": "testBefore",
  8306. "default": false,
  8307. "isAttr": true,
  8308. "type": "Boolean"
  8309. },
  8310. {
  8311. "name": "loopCondition",
  8312. "type": "Expression",
  8313. "xml": {
  8314. "serialize": "xsi:type"
  8315. }
  8316. },
  8317. {
  8318. "name": "loopMaximum",
  8319. "type": "Expression",
  8320. "xml": {
  8321. "serialize": "xsi:type"
  8322. }
  8323. }
  8324. ]
  8325. },
  8326. {
  8327. "name": "CallActivity",
  8328. "superClass": [
  8329. "Activity"
  8330. ],
  8331. "properties": [
  8332. {
  8333. "name": "calledElement",
  8334. "type": "String",
  8335. "isAttr": true
  8336. }
  8337. ]
  8338. },
  8339. {
  8340. "name": "Task",
  8341. "superClass": [
  8342. "Activity",
  8343. "InteractionNode"
  8344. ]
  8345. },
  8346. {
  8347. "name": "SendTask",
  8348. "superClass": [
  8349. "Task"
  8350. ],
  8351. "properties": [
  8352. {
  8353. "name": "implementation",
  8354. "isAttr": true,
  8355. "type": "String"
  8356. },
  8357. {
  8358. "name": "operationRef",
  8359. "type": "Operation",
  8360. "isAttr": true,
  8361. "isReference": true
  8362. },
  8363. {
  8364. "name": "messageRef",
  8365. "type": "Message",
  8366. "isAttr": true,
  8367. "isReference": true
  8368. }
  8369. ]
  8370. },
  8371. {
  8372. "name": "ReceiveTask",
  8373. "superClass": [
  8374. "Task"
  8375. ],
  8376. "properties": [
  8377. {
  8378. "name": "implementation",
  8379. "isAttr": true,
  8380. "type": "String"
  8381. },
  8382. {
  8383. "name": "instantiate",
  8384. "default": false,
  8385. "isAttr": true,
  8386. "type": "Boolean"
  8387. },
  8388. {
  8389. "name": "operationRef",
  8390. "type": "Operation",
  8391. "isAttr": true,
  8392. "isReference": true
  8393. },
  8394. {
  8395. "name": "messageRef",
  8396. "type": "Message",
  8397. "isAttr": true,
  8398. "isReference": true
  8399. }
  8400. ]
  8401. },
  8402. {
  8403. "name": "ScriptTask",
  8404. "superClass": [
  8405. "Task"
  8406. ],
  8407. "properties": [
  8408. {
  8409. "name": "scriptFormat",
  8410. "isAttr": true,
  8411. "type": "String"
  8412. },
  8413. {
  8414. "name": "script",
  8415. "type": "String"
  8416. }
  8417. ]
  8418. },
  8419. {
  8420. "name": "BusinessRuleTask",
  8421. "superClass": [
  8422. "Task"
  8423. ],
  8424. "properties": [
  8425. {
  8426. "name": "implementation",
  8427. "isAttr": true,
  8428. "type": "String"
  8429. }
  8430. ]
  8431. },
  8432. {
  8433. "name": "AdHocSubProcess",
  8434. "superClass": [
  8435. "SubProcess"
  8436. ],
  8437. "properties": [
  8438. {
  8439. "name": "completionCondition",
  8440. "type": "Expression",
  8441. "xml": {
  8442. "serialize": "xsi:type"
  8443. }
  8444. },
  8445. {
  8446. "name": "ordering",
  8447. "type": "AdHocOrdering",
  8448. "isAttr": true
  8449. },
  8450. {
  8451. "name": "cancelRemainingInstances",
  8452. "default": true,
  8453. "isAttr": true,
  8454. "type": "Boolean"
  8455. }
  8456. ]
  8457. },
  8458. {
  8459. "name": "Transaction",
  8460. "superClass": [
  8461. "SubProcess"
  8462. ],
  8463. "properties": [
  8464. {
  8465. "name": "protocol",
  8466. "isAttr": true,
  8467. "type": "String"
  8468. },
  8469. {
  8470. "name": "method",
  8471. "isAttr": true,
  8472. "type": "String"
  8473. }
  8474. ]
  8475. },
  8476. {
  8477. "name": "GlobalScriptTask",
  8478. "superClass": [
  8479. "GlobalTask"
  8480. ],
  8481. "properties": [
  8482. {
  8483. "name": "scriptLanguage",
  8484. "isAttr": true,
  8485. "type": "String"
  8486. },
  8487. {
  8488. "name": "script",
  8489. "isAttr": true,
  8490. "type": "String"
  8491. }
  8492. ]
  8493. },
  8494. {
  8495. "name": "GlobalBusinessRuleTask",
  8496. "superClass": [
  8497. "GlobalTask"
  8498. ],
  8499. "properties": [
  8500. {
  8501. "name": "implementation",
  8502. "isAttr": true,
  8503. "type": "String"
  8504. }
  8505. ]
  8506. },
  8507. {
  8508. "name": "ComplexBehaviorDefinition",
  8509. "superClass": [
  8510. "BaseElement"
  8511. ],
  8512. "properties": [
  8513. {
  8514. "name": "condition",
  8515. "type": "FormalExpression"
  8516. },
  8517. {
  8518. "name": "event",
  8519. "type": "ImplicitThrowEvent"
  8520. }
  8521. ]
  8522. },
  8523. {
  8524. "name": "ResourceRole",
  8525. "superClass": [
  8526. "BaseElement"
  8527. ],
  8528. "properties": [
  8529. {
  8530. "name": "resourceRef",
  8531. "type": "Resource",
  8532. "isReference": true
  8533. },
  8534. {
  8535. "name": "resourceParameterBindings",
  8536. "type": "ResourceParameterBinding",
  8537. "isMany": true
  8538. },
  8539. {
  8540. "name": "resourceAssignmentExpression",
  8541. "type": "ResourceAssignmentExpression"
  8542. },
  8543. {
  8544. "name": "name",
  8545. "isAttr": true,
  8546. "type": "String"
  8547. }
  8548. ]
  8549. },
  8550. {
  8551. "name": "ResourceParameterBinding",
  8552. "properties": [
  8553. {
  8554. "name": "expression",
  8555. "type": "Expression",
  8556. "xml": {
  8557. "serialize": "xsi:type"
  8558. }
  8559. },
  8560. {
  8561. "name": "parameterRef",
  8562. "type": "ResourceParameter",
  8563. "isAttr": true,
  8564. "isReference": true
  8565. }
  8566. ]
  8567. },
  8568. {
  8569. "name": "ResourceAssignmentExpression",
  8570. "properties": [
  8571. {
  8572. "name": "expression",
  8573. "type": "Expression",
  8574. "xml": {
  8575. "serialize": "xsi:type"
  8576. }
  8577. }
  8578. ]
  8579. },
  8580. {
  8581. "name": "Import",
  8582. "properties": [
  8583. {
  8584. "name": "importType",
  8585. "isAttr": true,
  8586. "type": "String"
  8587. },
  8588. {
  8589. "name": "location",
  8590. "isAttr": true,
  8591. "type": "String"
  8592. },
  8593. {
  8594. "name": "namespace",
  8595. "isAttr": true,
  8596. "type": "String"
  8597. }
  8598. ]
  8599. },
  8600. {
  8601. "name": "Definitions",
  8602. "superClass": [
  8603. "BaseElement"
  8604. ],
  8605. "properties": [
  8606. {
  8607. "name": "name",
  8608. "isAttr": true,
  8609. "type": "String"
  8610. },
  8611. {
  8612. "name": "targetNamespace",
  8613. "isAttr": true,
  8614. "type": "String"
  8615. },
  8616. {
  8617. "name": "expressionLanguage",
  8618. "default": "http://www.w3.org/1999/XPath",
  8619. "isAttr": true,
  8620. "type": "String"
  8621. },
  8622. {
  8623. "name": "typeLanguage",
  8624. "default": "http://www.w3.org/2001/XMLSchema",
  8625. "isAttr": true,
  8626. "type": "String"
  8627. },
  8628. {
  8629. "name": "imports",
  8630. "type": "Import",
  8631. "isMany": true
  8632. },
  8633. {
  8634. "name": "extensions",
  8635. "type": "Extension",
  8636. "isMany": true
  8637. },
  8638. {
  8639. "name": "rootElements",
  8640. "type": "RootElement",
  8641. "isMany": true
  8642. },
  8643. {
  8644. "name": "diagrams",
  8645. "isMany": true,
  8646. "type": "bpmndi:BPMNDiagram"
  8647. },
  8648. {
  8649. "name": "exporter",
  8650. "isAttr": true,
  8651. "type": "String"
  8652. },
  8653. {
  8654. "name": "relationships",
  8655. "type": "Relationship",
  8656. "isMany": true
  8657. },
  8658. {
  8659. "name": "exporterVersion",
  8660. "isAttr": true,
  8661. "type": "String"
  8662. }
  8663. ]
  8664. }
  8665. ],
  8666. "emumerations": [
  8667. {
  8668. "name": "ProcessType",
  8669. "literalValues": [
  8670. {
  8671. "name": "None"
  8672. },
  8673. {
  8674. "name": "Public"
  8675. },
  8676. {
  8677. "name": "Private"
  8678. }
  8679. ]
  8680. },
  8681. {
  8682. "name": "GatewayDirection",
  8683. "literalValues": [
  8684. {
  8685. "name": "Unspecified"
  8686. },
  8687. {
  8688. "name": "Converging"
  8689. },
  8690. {
  8691. "name": "Diverging"
  8692. },
  8693. {
  8694. "name": "Mixed"
  8695. }
  8696. ]
  8697. },
  8698. {
  8699. "name": "EventBasedGatewayType",
  8700. "literalValues": [
  8701. {
  8702. "name": "Parallel"
  8703. },
  8704. {
  8705. "name": "Exclusive"
  8706. }
  8707. ]
  8708. },
  8709. {
  8710. "name": "RelationshipDirection",
  8711. "literalValues": [
  8712. {
  8713. "name": "None"
  8714. },
  8715. {
  8716. "name": "Forward"
  8717. },
  8718. {
  8719. "name": "Backward"
  8720. },
  8721. {
  8722. "name": "Both"
  8723. }
  8724. ]
  8725. },
  8726. {
  8727. "name": "ItemKind",
  8728. "literalValues": [
  8729. {
  8730. "name": "Physical"
  8731. },
  8732. {
  8733. "name": "Information"
  8734. }
  8735. ]
  8736. },
  8737. {
  8738. "name": "ChoreographyLoopType",
  8739. "literalValues": [
  8740. {
  8741. "name": "None"
  8742. },
  8743. {
  8744. "name": "Standard"
  8745. },
  8746. {
  8747. "name": "MultiInstanceSequential"
  8748. },
  8749. {
  8750. "name": "MultiInstanceParallel"
  8751. }
  8752. ]
  8753. },
  8754. {
  8755. "name": "AssociationDirection",
  8756. "literalValues": [
  8757. {
  8758. "name": "None"
  8759. },
  8760. {
  8761. "name": "One"
  8762. },
  8763. {
  8764. "name": "Both"
  8765. }
  8766. ]
  8767. },
  8768. {
  8769. "name": "MultiInstanceBehavior",
  8770. "literalValues": [
  8771. {
  8772. "name": "None"
  8773. },
  8774. {
  8775. "name": "One"
  8776. },
  8777. {
  8778. "name": "All"
  8779. },
  8780. {
  8781. "name": "Complex"
  8782. }
  8783. ]
  8784. },
  8785. {
  8786. "name": "AdHocOrdering",
  8787. "literalValues": [
  8788. {
  8789. "name": "Parallel"
  8790. },
  8791. {
  8792. "name": "Sequential"
  8793. }
  8794. ]
  8795. }
  8796. ],
  8797. "prefix": "bpmn",
  8798. "xml": {
  8799. "tagAlias": "lowerCase",
  8800. "typePrefix": "t"
  8801. }
  8802. }
  8803. },{}],33:[function(_dereq_,module,exports){
  8804. module.exports={
  8805. "name": "BPMNDI",
  8806. "uri": "http://www.omg.org/spec/BPMN/20100524/DI",
  8807. "types": [
  8808. {
  8809. "name": "BPMNDiagram",
  8810. "properties": [
  8811. {
  8812. "name": "plane",
  8813. "type": "BPMNPlane",
  8814. "redefines": "di:Diagram#rootElement"
  8815. },
  8816. {
  8817. "name": "labelStyle",
  8818. "type": "BPMNLabelStyle",
  8819. "isMany": true
  8820. }
  8821. ],
  8822. "superClass": [
  8823. "di:Diagram"
  8824. ]
  8825. },
  8826. {
  8827. "name": "BPMNPlane",
  8828. "properties": [
  8829. {
  8830. "name": "bpmnElement",
  8831. "isAttr": true,
  8832. "isReference": true,
  8833. "type": "bpmn:BaseElement",
  8834. "redefines": "di:DiagramElement#modelElement"
  8835. }
  8836. ],
  8837. "superClass": [
  8838. "di:Plane"
  8839. ]
  8840. },
  8841. {
  8842. "name": "BPMNShape",
  8843. "properties": [
  8844. {
  8845. "name": "bpmnElement",
  8846. "isAttr": true,
  8847. "isReference": true,
  8848. "type": "bpmn:BaseElement",
  8849. "redefines": "di:DiagramElement#modelElement"
  8850. },
  8851. {
  8852. "name": "isHorizontal",
  8853. "isAttr": true,
  8854. "type": "Boolean"
  8855. },
  8856. {
  8857. "name": "isExpanded",
  8858. "isAttr": true,
  8859. "type": "Boolean"
  8860. },
  8861. {
  8862. "name": "isMarkerVisible",
  8863. "isAttr": true,
  8864. "type": "Boolean"
  8865. },
  8866. {
  8867. "name": "label",
  8868. "type": "BPMNLabel"
  8869. },
  8870. {
  8871. "name": "isMessageVisible",
  8872. "isAttr": true,
  8873. "type": "Boolean"
  8874. },
  8875. {
  8876. "name": "participantBandKind",
  8877. "type": "ParticipantBandKind",
  8878. "isAttr": true
  8879. },
  8880. {
  8881. "name": "choreographyActivityShape",
  8882. "type": "BPMNShape",
  8883. "isAttr": true,
  8884. "isReference": true
  8885. }
  8886. ],
  8887. "superClass": [
  8888. "di:LabeledShape"
  8889. ]
  8890. },
  8891. {
  8892. "name": "BPMNEdge",
  8893. "properties": [
  8894. {
  8895. "name": "label",
  8896. "type": "BPMNLabel"
  8897. },
  8898. {
  8899. "name": "bpmnElement",
  8900. "isAttr": true,
  8901. "isReference": true,
  8902. "type": "bpmn:BaseElement",
  8903. "redefines": "di:DiagramElement#modelElement"
  8904. },
  8905. {
  8906. "name": "sourceElement",
  8907. "isAttr": true,
  8908. "isReference": true,
  8909. "type": "di:DiagramElement",
  8910. "redefines": "di:Edge#source"
  8911. },
  8912. {
  8913. "name": "targetElement",
  8914. "isAttr": true,
  8915. "isReference": true,
  8916. "type": "di:DiagramElement",
  8917. "redefines": "di:Edge#target"
  8918. },
  8919. {
  8920. "name": "messageVisibleKind",
  8921. "type": "MessageVisibleKind",
  8922. "isAttr": true,
  8923. "default": "initiating"
  8924. }
  8925. ],
  8926. "superClass": [
  8927. "di:LabeledEdge"
  8928. ]
  8929. },
  8930. {
  8931. "name": "BPMNLabel",
  8932. "properties": [
  8933. {
  8934. "name": "labelStyle",
  8935. "type": "BPMNLabelStyle",
  8936. "isAttr": true,
  8937. "isReference": true,
  8938. "redefines": "di:DiagramElement#style"
  8939. }
  8940. ],
  8941. "superClass": [
  8942. "di:Label"
  8943. ]
  8944. },
  8945. {
  8946. "name": "BPMNLabelStyle",
  8947. "properties": [
  8948. {
  8949. "name": "font",
  8950. "type": "dc:Font"
  8951. }
  8952. ],
  8953. "superClass": [
  8954. "di:Style"
  8955. ]
  8956. }
  8957. ],
  8958. "emumerations": [
  8959. {
  8960. "name": "ParticipantBandKind",
  8961. "literalValues": [
  8962. {
  8963. "name": "top_initiating"
  8964. },
  8965. {
  8966. "name": "middle_initiating"
  8967. },
  8968. {
  8969. "name": "bottom_initiating"
  8970. },
  8971. {
  8972. "name": "top_non_initiating"
  8973. },
  8974. {
  8975. "name": "middle_non_initiating"
  8976. },
  8977. {
  8978. "name": "bottom_non_initiating"
  8979. }
  8980. ]
  8981. },
  8982. {
  8983. "name": "MessageVisibleKind",
  8984. "literalValues": [
  8985. {
  8986. "name": "initiating"
  8987. },
  8988. {
  8989. "name": "non_initiating"
  8990. }
  8991. ]
  8992. }
  8993. ],
  8994. "associations": [],
  8995. "prefix": "bpmndi"
  8996. }
  8997. },{}],34:[function(_dereq_,module,exports){
  8998. module.exports={
  8999. "name": "DC",
  9000. "uri": "http://www.omg.org/spec/DD/20100524/DC",
  9001. "types": [
  9002. {
  9003. "name": "Boolean"
  9004. },
  9005. {
  9006. "name": "Integer"
  9007. },
  9008. {
  9009. "name": "Real"
  9010. },
  9011. {
  9012. "name": "String"
  9013. },
  9014. {
  9015. "name": "Font",
  9016. "properties": [
  9017. {
  9018. "name": "name",
  9019. "type": "String",
  9020. "isAttr": true
  9021. },
  9022. {
  9023. "name": "size",
  9024. "type": "Real",
  9025. "isAttr": true
  9026. },
  9027. {
  9028. "name": "isBold",
  9029. "type": "Boolean",
  9030. "isAttr": true
  9031. },
  9032. {
  9033. "name": "isItalic",
  9034. "type": "Boolean",
  9035. "isAttr": true
  9036. },
  9037. {
  9038. "name": "isUnderline",
  9039. "type": "Boolean",
  9040. "isAttr": true
  9041. },
  9042. {
  9043. "name": "isStrikeThrough",
  9044. "type": "Boolean",
  9045. "isAttr": true
  9046. }
  9047. ]
  9048. },
  9049. {
  9050. "name": "Point",
  9051. "properties": [
  9052. {
  9053. "name": "x",
  9054. "type": "Real",
  9055. "default": "0",
  9056. "isAttr": true
  9057. },
  9058. {
  9059. "name": "y",
  9060. "type": "Real",
  9061. "default": "0",
  9062. "isAttr": true
  9063. }
  9064. ]
  9065. },
  9066. {
  9067. "name": "Bounds",
  9068. "properties": [
  9069. {
  9070. "name": "x",
  9071. "type": "Real",
  9072. "default": "0",
  9073. "isAttr": true
  9074. },
  9075. {
  9076. "name": "y",
  9077. "type": "Real",
  9078. "default": "0",
  9079. "isAttr": true
  9080. },
  9081. {
  9082. "name": "width",
  9083. "type": "Real",
  9084. "isAttr": true
  9085. },
  9086. {
  9087. "name": "height",
  9088. "type": "Real",
  9089. "isAttr": true
  9090. }
  9091. ]
  9092. }
  9093. ],
  9094. "prefix": "dc",
  9095. "associations": []
  9096. }
  9097. },{}],35:[function(_dereq_,module,exports){
  9098. module.exports={
  9099. "name": "DI",
  9100. "uri": "http://www.omg.org/spec/DD/20100524/DI",
  9101. "types": [
  9102. {
  9103. "name": "DiagramElement",
  9104. "isAbstract": true,
  9105. "properties": [
  9106. {
  9107. "name": "extension",
  9108. "type": "Extension"
  9109. },
  9110. {
  9111. "name": "owningDiagram",
  9112. "type": "Diagram",
  9113. "isReadOnly": true,
  9114. "isVirtual": true,
  9115. "isReference": true
  9116. },
  9117. {
  9118. "name": "owningElement",
  9119. "type": "DiagramElement",
  9120. "isReadOnly": true,
  9121. "isVirtual": true,
  9122. "isReference": true
  9123. },
  9124. {
  9125. "name": "modelElement",
  9126. "isReadOnly": true,
  9127. "isVirtual": true,
  9128. "isReference": true,
  9129. "type": "Element"
  9130. },
  9131. {
  9132. "name": "style",
  9133. "type": "Style",
  9134. "isReadOnly": true,
  9135. "isVirtual": true,
  9136. "isReference": true
  9137. },
  9138. {
  9139. "name": "ownedElement",
  9140. "type": "DiagramElement",
  9141. "isReadOnly": true,
  9142. "isVirtual": true,
  9143. "isMany": true
  9144. }
  9145. ]
  9146. },
  9147. {
  9148. "name": "Node",
  9149. "isAbstract": true,
  9150. "superClass": [
  9151. "DiagramElement"
  9152. ]
  9153. },
  9154. {
  9155. "name": "Edge",
  9156. "isAbstract": true,
  9157. "superClass": [
  9158. "DiagramElement"
  9159. ],
  9160. "properties": [
  9161. {
  9162. "name": "source",
  9163. "type": "DiagramElement",
  9164. "isReadOnly": true,
  9165. "isVirtual": true,
  9166. "isReference": true
  9167. },
  9168. {
  9169. "name": "target",
  9170. "type": "DiagramElement",
  9171. "isReadOnly": true,
  9172. "isVirtual": true,
  9173. "isReference": true
  9174. },
  9175. {
  9176. "name": "waypoint",
  9177. "isUnique": false,
  9178. "isMany": true,
  9179. "type": "dc:Point",
  9180. "xml": {
  9181. "serialize": "xsi:type"
  9182. }
  9183. }
  9184. ]
  9185. },
  9186. {
  9187. "name": "Diagram",
  9188. "isAbstract": true,
  9189. "properties": [
  9190. {
  9191. "name": "rootElement",
  9192. "type": "DiagramElement",
  9193. "isReadOnly": true,
  9194. "isVirtual": true
  9195. },
  9196. {
  9197. "name": "name",
  9198. "isAttr": true,
  9199. "type": "String"
  9200. },
  9201. {
  9202. "name": "documentation",
  9203. "isAttr": true,
  9204. "type": "String"
  9205. },
  9206. {
  9207. "name": "resolution",
  9208. "isAttr": true,
  9209. "type": "Real"
  9210. },
  9211. {
  9212. "name": "ownedStyle",
  9213. "type": "Style",
  9214. "isReadOnly": true,
  9215. "isVirtual": true,
  9216. "isMany": true
  9217. }
  9218. ]
  9219. },
  9220. {
  9221. "name": "Shape",
  9222. "isAbstract": true,
  9223. "superClass": [
  9224. "Node"
  9225. ],
  9226. "properties": [
  9227. {
  9228. "name": "bounds",
  9229. "type": "dc:Bounds"
  9230. }
  9231. ]
  9232. },
  9233. {
  9234. "name": "Plane",
  9235. "isAbstract": true,
  9236. "superClass": [
  9237. "Node"
  9238. ],
  9239. "properties": [
  9240. {
  9241. "name": "planeElement",
  9242. "type": "DiagramElement",
  9243. "subsettedProperty": "DiagramElement-ownedElement",
  9244. "isMany": true
  9245. }
  9246. ]
  9247. },
  9248. {
  9249. "name": "LabeledEdge",
  9250. "isAbstract": true,
  9251. "superClass": [
  9252. "Edge"
  9253. ],
  9254. "properties": [
  9255. {
  9256. "name": "ownedLabel",
  9257. "type": "Label",
  9258. "isReadOnly": true,
  9259. "subsettedProperty": "DiagramElement-ownedElement",
  9260. "isVirtual": true,
  9261. "isMany": true
  9262. }
  9263. ]
  9264. },
  9265. {
  9266. "name": "LabeledShape",
  9267. "isAbstract": true,
  9268. "superClass": [
  9269. "Shape"
  9270. ],
  9271. "properties": [
  9272. {
  9273. "name": "ownedLabel",
  9274. "type": "Label",
  9275. "isReadOnly": true,
  9276. "subsettedProperty": "DiagramElement-ownedElement",
  9277. "isVirtual": true,
  9278. "isMany": true
  9279. }
  9280. ]
  9281. },
  9282. {
  9283. "name": "Label",
  9284. "isAbstract": true,
  9285. "superClass": [
  9286. "Node"
  9287. ],
  9288. "properties": [
  9289. {
  9290. "name": "bounds",
  9291. "type": "dc:Bounds"
  9292. }
  9293. ]
  9294. },
  9295. {
  9296. "name": "Style",
  9297. "isAbstract": true
  9298. },
  9299. {
  9300. "name": "Extension",
  9301. "properties": [
  9302. {
  9303. "name": "values",
  9304. "type": "Element",
  9305. "isMany": true
  9306. }
  9307. ]
  9308. }
  9309. ],
  9310. "associations": [],
  9311. "prefix": "di",
  9312. "xml": {
  9313. "tagAlias": "lowerCase"
  9314. }
  9315. }
  9316. },{}],36:[function(_dereq_,module,exports){
  9317. module.exports = _dereq_(37);
  9318. },{"37":37}],37:[function(_dereq_,module,exports){
  9319. 'use strict';
  9320. var di = _dereq_(78);
  9321. /**
  9322. * Bootstrap an injector from a list of modules, instantiating a number of default components
  9323. *
  9324. * @ignore
  9325. * @param {Array<didi.Module>} bootstrapModules
  9326. *
  9327. * @return {didi.Injector} a injector to use to access the components
  9328. */
  9329. function bootstrap(bootstrapModules) {
  9330. var modules = [],
  9331. components = [];
  9332. function hasModule(m) {
  9333. return modules.indexOf(m) >= 0;
  9334. }
  9335. function addModule(m) {
  9336. modules.push(m);
  9337. }
  9338. function visit(m) {
  9339. if (hasModule(m)) {
  9340. return;
  9341. }
  9342. (m.__depends__ || []).forEach(visit);
  9343. if (hasModule(m)) {
  9344. return;
  9345. }
  9346. addModule(m);
  9347. (m.__init__ || []).forEach(function(c) {
  9348. components.push(c);
  9349. });
  9350. }
  9351. bootstrapModules.forEach(visit);
  9352. var injector = new di.Injector(modules);
  9353. components.forEach(function(c) {
  9354. try {
  9355. // eagerly resolve component (fn or string)
  9356. injector[typeof c === 'string' ? 'get' : 'invoke'](c);
  9357. } catch (e) {
  9358. console.error('Failed to instantiate component');
  9359. console.error(e.stack);
  9360. throw e;
  9361. }
  9362. });
  9363. return injector;
  9364. }
  9365. /**
  9366. * Creates an injector from passed options.
  9367. *
  9368. * @ignore
  9369. * @param {Object} options
  9370. * @return {didi.Injector}
  9371. */
  9372. function createInjector(options) {
  9373. options = options || {};
  9374. var configModule = {
  9375. 'config': ['value', options]
  9376. };
  9377. var coreModule = _dereq_(43);
  9378. var modules = [ configModule, coreModule ].concat(options.modules || []);
  9379. return bootstrap(modules);
  9380. }
  9381. /**
  9382. * The main diagram-js entry point that bootstraps the diagram with the given
  9383. * configuration.
  9384. *
  9385. * To register extensions with the diagram, pass them as Array<didi.Module> to the constructor.
  9386. *
  9387. * @class djs.Diagram
  9388. * @memberOf djs
  9389. * @constructor
  9390. *
  9391. * @example
  9392. *
  9393. * <caption>Creating a plug-in that logs whenever a shape is added to the canvas.</caption>
  9394. *
  9395. * // plug-in implemenentation
  9396. * function MyLoggingPlugin(eventBus) {
  9397. * eventBus.on('shape.added', function(event) {
  9398. * console.log('shape ', event.shape, ' was added to the diagram');
  9399. * });
  9400. * }
  9401. *
  9402. * // export as module
  9403. * module.exports = {
  9404. * __init__: [ 'myLoggingPlugin' ],
  9405. * myLoggingPlugin: [ 'type', MyLoggingPlugin ]
  9406. * };
  9407. *
  9408. *
  9409. * // instantiate the diagram with the new plug-in
  9410. *
  9411. * var diagram = new Diagram({ modules: [ require('path-to-my-logging-plugin') ] });
  9412. *
  9413. * diagram.invoke([ 'canvas', function(canvas) {
  9414. * // add shape to drawing canvas
  9415. * canvas.addShape({ x: 10, y: 10 });
  9416. * });
  9417. *
  9418. * // 'shape ... was added to the diagram' logged to console
  9419. *
  9420. * @param {Object} options
  9421. * @param {Array<didi.Module>} [options.modules] external modules to instantiate with the diagram
  9422. * @param {didi.Injector} [injector] an (optional) injector to bootstrap the diagram with
  9423. */
  9424. function Diagram(options, injector) {
  9425. // create injector unless explicitly specified
  9426. this.injector = injector = injector || createInjector(options);
  9427. // API
  9428. /**
  9429. * Resolves a diagram service
  9430. *
  9431. * @method Diagram#get
  9432. *
  9433. * @param {String} name the name of the diagram service to be retrieved
  9434. * @param {Object} [locals] a number of locals to use to resolve certain dependencies
  9435. */
  9436. this.get = injector.get;
  9437. /**
  9438. * Executes a function into which diagram services are injected
  9439. *
  9440. * @method Diagram#invoke
  9441. *
  9442. * @param {Function|Object[]} fn the function to resolve
  9443. * @param {Object} locals a number of locals to use to resolve certain dependencies
  9444. */
  9445. this.invoke = injector.invoke;
  9446. // init
  9447. // indicate via event
  9448. /**
  9449. * An event indicating that all plug-ins are loaded.
  9450. *
  9451. * Use this event to fire other events to interested plug-ins
  9452. *
  9453. * @memberOf Diagram
  9454. *
  9455. * @event diagram.init
  9456. *
  9457. * @example
  9458. *
  9459. * eventBus.on('diagram.init', function() {
  9460. * eventBus.fire('my-custom-event', { foo: 'BAR' });
  9461. * });
  9462. *
  9463. * @type {Object}
  9464. */
  9465. this.get('eventBus').fire('diagram.init');
  9466. }
  9467. module.exports = Diagram;
  9468. /**
  9469. * Destroys the diagram
  9470. *
  9471. * @method Diagram#destroy
  9472. */
  9473. Diagram.prototype.destroy = function() {
  9474. this.get('eventBus').fire('diagram.destroy');
  9475. };
  9476. },{"43":43,"78":78}],38:[function(_dereq_,module,exports){
  9477. 'use strict';
  9478. var isNumber = _dereq_(171),
  9479. assign = _dereq_(177),
  9480. forEach = _dereq_(86),
  9481. every = _dereq_(83);
  9482. var Collections = _dereq_(64);
  9483. var Snap = _dereq_(76);
  9484. function round(number, resolution) {
  9485. return Math.round(number * resolution) / resolution;
  9486. }
  9487. function ensurePx(number) {
  9488. return isNumber(number) ? number + 'px' : number;
  9489. }
  9490. /**
  9491. * Creates a HTML container element for a SVG element with
  9492. * the given configuration
  9493. *
  9494. * @param {Object} options
  9495. * @return {HTMLElement} the container element
  9496. */
  9497. function createContainer(options) {
  9498. options = assign({}, { width: '100%', height: '100%' }, options);
  9499. var container = options.container || document.body;
  9500. // create a <div> around the svg element with the respective size
  9501. // this way we can always get the correct container size
  9502. // (this is impossible for <svg> elements at the moment)
  9503. var parent = document.createElement('div');
  9504. parent.setAttribute('class', 'djs-container');
  9505. assign(parent.style, {
  9506. position: 'relative',
  9507. overflow: 'hidden',
  9508. width: ensurePx(options.width),
  9509. height: ensurePx(options.height)
  9510. });
  9511. container.appendChild(parent);
  9512. return parent;
  9513. }
  9514. function createGroup(parent, cls) {
  9515. return parent.group().attr({ 'class' : cls });
  9516. }
  9517. var BASE_LAYER = 'base';
  9518. var REQUIRED_MODEL_ATTRS = {
  9519. shape: [ 'x', 'y', 'width', 'height' ],
  9520. connection: [ 'waypoints' ]
  9521. };
  9522. /**
  9523. * The main drawing canvas.
  9524. *
  9525. * @class
  9526. * @constructor
  9527. *
  9528. * @emits Canvas#canvas.init
  9529. *
  9530. * @param {Object} config
  9531. * @param {EventBus} eventBus
  9532. * @param {GraphicsFactory} graphicsFactory
  9533. * @param {ElementRegistry} elementRegistry
  9534. */
  9535. function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
  9536. this._eventBus = eventBus;
  9537. this._elementRegistry = elementRegistry;
  9538. this._graphicsFactory = graphicsFactory;
  9539. this._init(config || {});
  9540. }
  9541. Canvas.$inject = [ 'config.canvas', 'eventBus', 'graphicsFactory', 'elementRegistry' ];
  9542. module.exports = Canvas;
  9543. Canvas.prototype._init = function(config) {
  9544. // Creates a <svg> element that is wrapped into a <div>.
  9545. // This way we are always able to correctly figure out the size of the svg element
  9546. // by querying the parent node.
  9547. //
  9548. // (It is not possible to get the size of a svg element cross browser @ 2014-04-01)
  9549. //
  9550. // <div class="djs-container" style="width: {desired-width}, height: {desired-height}">
  9551. // <svg width="100%" height="100%">
  9552. // ...
  9553. // </svg>
  9554. // </div>
  9555. // html container
  9556. var eventBus = this._eventBus,
  9557. container = createContainer(config),
  9558. svg = Snap.createSnapAt('100%', '100%', container),
  9559. viewport = createGroup(svg, 'viewport'),
  9560. self = this;
  9561. this._container = container;
  9562. this._svg = svg;
  9563. this._viewport = viewport;
  9564. this._layers = {};
  9565. eventBus.on('diagram.init', function(event) {
  9566. /**
  9567. * An event indicating that the canvas is ready to be drawn on.
  9568. *
  9569. * @memberOf Canvas
  9570. *
  9571. * @event canvas.init
  9572. *
  9573. * @type {Object}
  9574. * @property {Snap<SVGSVGElement>} svg the created svg element
  9575. * @property {Snap<SVGGroup>} viewport the direct parent of diagram elements and shapes
  9576. */
  9577. eventBus.fire('canvas.init', { svg: svg, viewport: viewport });
  9578. });
  9579. eventBus.on('diagram.destroy', function() {
  9580. var parent = self._container.parentNode;
  9581. if (parent) {
  9582. parent.removeChild(container);
  9583. }
  9584. eventBus.fire('canvas.destroy', { svg: self._svg, viewport: self._viewport });
  9585. self._svg.remove();
  9586. self._svg = self._container = self._layers = self._viewport = null;
  9587. });
  9588. };
  9589. /**
  9590. * Returns the default layer on which
  9591. * all elements are drawn.
  9592. *
  9593. * @returns {Snap<SVGGroup>}
  9594. */
  9595. Canvas.prototype.getDefaultLayer = function() {
  9596. return this.getLayer(BASE_LAYER);
  9597. };
  9598. /**
  9599. * Returns a layer that is used to draw elements
  9600. * or annotations on it.
  9601. *
  9602. * @param {String} name
  9603. *
  9604. * @returns {Snap<SVGGroup>}
  9605. */
  9606. Canvas.prototype.getLayer = function(name) {
  9607. if (!name) {
  9608. throw new Error('must specify a name');
  9609. }
  9610. var layer = this._layers[name];
  9611. if (!layer) {
  9612. layer = this._layers[name] = createGroup(this._viewport, 'layer-' + name);
  9613. }
  9614. return layer;
  9615. };
  9616. /**
  9617. * Returns the html element that encloses the
  9618. * drawing canvas.
  9619. *
  9620. * @return {DOMNode}
  9621. */
  9622. Canvas.prototype.getContainer = function() {
  9623. return this._container;
  9624. };
  9625. /////////////// markers ///////////////////////////////////
  9626. Canvas.prototype._updateMarker = function(element, marker, add) {
  9627. var container;
  9628. if (!element.id) {
  9629. element = this._elementRegistry.get(element);
  9630. }
  9631. // we need to access all
  9632. container = this._elementRegistry._elements[element.id];
  9633. if (!container) {
  9634. return;
  9635. }
  9636. forEach([ container.gfx, container.secondaryGfx ], function(gfx) {
  9637. if (gfx) {
  9638. // invoke either addClass or removeClass based on mode
  9639. gfx[add ? 'addClass' : 'removeClass'](marker);
  9640. }
  9641. });
  9642. /**
  9643. * An event indicating that a marker has been updated for an element
  9644. *
  9645. * @event element.marker.update
  9646. * @type {Object}
  9647. * @property {djs.model.Element} element the shape
  9648. * @property {Object} gfx the graphical representation of the shape
  9649. * @property {String} marker
  9650. * @property {Boolean} add true if the marker was added, false if it got removed
  9651. */
  9652. this._eventBus.fire('element.marker.update', { element: element, gfx: container.gfx, marker: marker, add: !!add });
  9653. };
  9654. /**
  9655. * Adds a marker to an element (basically a css class).
  9656. *
  9657. * Fires the element.marker.update event, making it possible to
  9658. * integrate extension into the marker life-cycle, too.
  9659. *
  9660. * @example
  9661. * canvas.addMarker('foo', 'some-marker');
  9662. *
  9663. * var fooGfx = canvas.getGraphics('foo');
  9664. *
  9665. * fooGfx; // <g class="... some-marker"> ... </g>
  9666. *
  9667. * @param {String|djs.model.Base} element
  9668. * @param {String} marker
  9669. */
  9670. Canvas.prototype.addMarker = function(element, marker) {
  9671. this._updateMarker(element, marker, true);
  9672. };
  9673. /**
  9674. * Remove a marker from an element.
  9675. *
  9676. * Fires the element.marker.update event, making it possible to
  9677. * integrate extension into the marker life-cycle, too.
  9678. *
  9679. * @param {String|djs.model.Base} element
  9680. * @param {String} marker
  9681. */
  9682. Canvas.prototype.removeMarker = function(element, marker) {
  9683. this._updateMarker(element, marker, false);
  9684. };
  9685. /**
  9686. * Check the existence of a marker on element.
  9687. *
  9688. * @param {String|djs.model.Base} element
  9689. * @param {String} marker
  9690. */
  9691. Canvas.prototype.hasMarker = function(element, marker) {
  9692. if (!element.id) {
  9693. element = this._elementRegistry.get(element);
  9694. }
  9695. var gfx = this.getGraphics(element);
  9696. return gfx && gfx.hasClass(marker);
  9697. };
  9698. /**
  9699. * Toggles a marker on an element.
  9700. *
  9701. * Fires the element.marker.update event, making it possible to
  9702. * integrate extension into the marker life-cycle, too.
  9703. *
  9704. * @param {String|djs.model.Base} element
  9705. * @param {String} marker
  9706. */
  9707. Canvas.prototype.toggleMarker = function(element, marker) {
  9708. if(this.hasMarker(element, marker)) {
  9709. this.removeMarker(element, marker);
  9710. } else {
  9711. this.addMarker(element, marker);
  9712. }
  9713. };
  9714. Canvas.prototype.getRootElement = function() {
  9715. if (!this._rootElement) {
  9716. this.setRootElement({ id: '__implicitroot' });
  9717. }
  9718. return this._rootElement;
  9719. };
  9720. //////////////// root element handling ///////////////////////////
  9721. /**
  9722. * Sets a given element as the new root element for the canvas
  9723. * and returns the new root element.
  9724. *
  9725. * @param {Object|djs.model.Root} element
  9726. * @param {Boolean} [override] whether to override the current root element, if any
  9727. *
  9728. * @return {Object|djs.model.Root} new root element
  9729. */
  9730. Canvas.prototype.setRootElement = function(element, override) {
  9731. this._ensureValid('root', element);
  9732. var oldRoot = this._rootElement,
  9733. elementRegistry = this._elementRegistry,
  9734. eventBus = this._eventBus;
  9735. if (oldRoot) {
  9736. if (!override) {
  9737. throw new Error('rootElement already set, need to specify override');
  9738. }
  9739. // simulate element remove event sequence
  9740. eventBus.fire('root.remove', { element: oldRoot });
  9741. eventBus.fire('root.removed', { element: oldRoot });
  9742. elementRegistry.remove(oldRoot);
  9743. }
  9744. var gfx = this.getDefaultLayer();
  9745. // resemble element add event sequence
  9746. eventBus.fire('root.add', { element: element });
  9747. elementRegistry.add(element, gfx, this._svg);
  9748. eventBus.fire('root.added', { element: element, gfx: gfx });
  9749. this._rootElement = element;
  9750. return element;
  9751. };
  9752. ///////////// add functionality ///////////////////////////////
  9753. Canvas.prototype._ensureValid = function(type, element) {
  9754. if (!element.id) {
  9755. throw new Error('element must have an id');
  9756. }
  9757. if (this._elementRegistry.get(element.id)) {
  9758. throw new Error('element with id ' + element.id + ' already exists');
  9759. }
  9760. var requiredAttrs = REQUIRED_MODEL_ATTRS[type];
  9761. var valid = every(requiredAttrs, function(attr) {
  9762. return typeof element[attr] !== 'undefined';
  9763. });
  9764. if (!valid) {
  9765. throw new Error(
  9766. 'must supply { ' + requiredAttrs.join(', ') + ' } with ' + type);
  9767. }
  9768. };
  9769. Canvas.prototype._setParent = function(element, parent, idx) {
  9770. Collections.add(parent.children, element, idx);
  9771. element.parent = parent;
  9772. };
  9773. /**
  9774. * Adds an element to the canvas.
  9775. *
  9776. * This wires the parent <-> child relationship between the element and
  9777. * a explicitly specified parent or an implicit root element.
  9778. *
  9779. * During add it emits the events
  9780. *
  9781. * * <{type}.add> (element, parent)
  9782. * * <{type}.added> (element, gfx)
  9783. *
  9784. * Extensions may hook into these events to perform their magic.
  9785. *
  9786. * @param {String} type
  9787. * @param {Object|djs.model.Base} element
  9788. * @param {Object|djs.model.Base} [parent]
  9789. *
  9790. * @return {Object|djs.model.Base} the added element
  9791. */
  9792. Canvas.prototype._addElement = function(type, element, parent) {
  9793. parent = parent || this.getRootElement();
  9794. var eventBus = this._eventBus,
  9795. graphicsFactory = this._graphicsFactory,
  9796. idx;
  9797. this._ensureValid(type, element);
  9798. eventBus.fire(type + '.add', { element: element, parent: parent });
  9799. this._setParent(element, parent, idx);
  9800. // create graphics
  9801. var gfx = graphicsFactory.create(type, element);
  9802. this._elementRegistry.add(element, gfx);
  9803. // update its visual
  9804. graphicsFactory.update(type, element, gfx);
  9805. eventBus.fire(type + '.added', { element: element, gfx: gfx });
  9806. return element;
  9807. };
  9808. /**
  9809. * Adds a shape to the canvas
  9810. *
  9811. * @param {Object|djs.model.Shape} shape to add to the diagram
  9812. * @param {djs.model.Base} [parent]
  9813. *
  9814. * @return {djs.model.Shape} the added shape
  9815. */
  9816. Canvas.prototype.addShape = function(shape, parent) {
  9817. return this._addElement('shape', shape, parent);
  9818. };
  9819. /**
  9820. * Adds a connection to the canvas
  9821. *
  9822. * @param {Object|djs.model.Connection} connection to add to the diagram
  9823. * @param {djs.model.Base} [parent]
  9824. *
  9825. * @return {djs.model.Connection} the added connection
  9826. */
  9827. Canvas.prototype.addConnection = function(connection, parent) {
  9828. return this._addElement('connection', connection, parent);
  9829. };
  9830. /**
  9831. * Internal remove element
  9832. */
  9833. Canvas.prototype._removeElement = function(element, type) {
  9834. var elementRegistry = this._elementRegistry,
  9835. graphicsFactory = this._graphicsFactory,
  9836. eventBus = this._eventBus;
  9837. element = elementRegistry.get(element.id || element);
  9838. if (!element) {
  9839. // element was removed already
  9840. return;
  9841. }
  9842. eventBus.fire(type + '.remove', { element: element });
  9843. graphicsFactory.remove(element);
  9844. // unset parent <-> child relationship
  9845. Collections.remove(element.parent && element.parent.children, element);
  9846. element.parent = null;
  9847. eventBus.fire(type + '.removed', { element: element });
  9848. elementRegistry.remove(element);
  9849. return element;
  9850. };
  9851. /**
  9852. * Removes a shape from the canvas
  9853. *
  9854. * @param {String|djs.model.Shape} shape or shape id to be removed
  9855. *
  9856. * @return {djs.model.Shape} the removed shape
  9857. */
  9858. Canvas.prototype.removeShape = function(shape) {
  9859. /**
  9860. * An event indicating that a shape is about to be removed from the canvas.
  9861. *
  9862. * @memberOf Canvas
  9863. *
  9864. * @event shape.remove
  9865. * @type {Object}
  9866. * @property {djs.model.Shape} element the shape descriptor
  9867. * @property {Object} gfx the graphical representation of the shape
  9868. */
  9869. /**
  9870. * An event indicating that a shape has been removed from the canvas.
  9871. *
  9872. * @memberOf Canvas
  9873. *
  9874. * @event shape.removed
  9875. * @type {Object}
  9876. * @property {djs.model.Shape} element the shape descriptor
  9877. * @property {Object} gfx the graphical representation of the shape
  9878. */
  9879. return this._removeElement(shape, 'shape');
  9880. };
  9881. /**
  9882. * Removes a connection from the canvas
  9883. *
  9884. * @param {String|djs.model.Connection} connection or connection id to be removed
  9885. *
  9886. * @return {djs.model.Connection} the removed connection
  9887. */
  9888. Canvas.prototype.removeConnection = function(connection) {
  9889. /**
  9890. * An event indicating that a connection is about to be removed from the canvas.
  9891. *
  9892. * @memberOf Canvas
  9893. *
  9894. * @event connection.remove
  9895. * @type {Object}
  9896. * @property {djs.model.Connection} element the connection descriptor
  9897. * @property {Object} gfx the graphical representation of the connection
  9898. */
  9899. /**
  9900. * An event indicating that a connection has been removed from the canvas.
  9901. *
  9902. * @memberOf Canvas
  9903. *
  9904. * @event connection.removed
  9905. * @type {Object}
  9906. * @property {djs.model.Connection} element the connection descriptor
  9907. * @property {Object} gfx the graphical representation of the connection
  9908. */
  9909. return this._removeElement(connection, 'connection');
  9910. };
  9911. /**
  9912. * Sends a shape to the front.
  9913. *
  9914. * This method takes parent / child relationships between shapes into account
  9915. * and makes sure that children are properly handled, too.
  9916. *
  9917. * @param {djs.model.Shape} shape descriptor of the shape to be sent to front
  9918. * @param {boolean} [bubble=true] whether to send parent shapes to front, too
  9919. */
  9920. Canvas.prototype.sendToFront = function(shape, bubble) {
  9921. if (bubble !== false) {
  9922. bubble = true;
  9923. }
  9924. if (bubble && shape.parent) {
  9925. this.sendToFront(shape.parent);
  9926. }
  9927. forEach(shape.children, function(child) {
  9928. this.sendToFront(child, false);
  9929. }, this);
  9930. var gfx = this.getGraphics(shape),
  9931. gfxParent = gfx.parent();
  9932. gfx.remove().appendTo(gfxParent);
  9933. };
  9934. /**
  9935. * Return the graphical object underlaying a certain diagram element
  9936. *
  9937. * @param {String|djs.model.Base} element descriptor of the element
  9938. * @param {Boolean} [secondary=false] whether to return the secondary connected element
  9939. *
  9940. * @return {SVGElement}
  9941. */
  9942. Canvas.prototype.getGraphics = function(element, secondary) {
  9943. return this._elementRegistry.getGraphics(element, secondary);
  9944. };
  9945. Canvas.prototype._fireViewboxChange = function() {
  9946. this._eventBus.fire('canvas.viewbox.changed', { viewbox: this.viewbox(false) });
  9947. };
  9948. /**
  9949. * Gets or sets the view box of the canvas, i.e. the area that is currently displayed
  9950. *
  9951. * @param {Object} [box] the new view box to set
  9952. * @param {Number} box.x the top left X coordinate of the canvas visible in view box
  9953. * @param {Number} box.y the top left Y coordinate of the canvas visible in view box
  9954. * @param {Number} box.width the visible width
  9955. * @param {Number} box.height
  9956. *
  9957. * @example
  9958. *
  9959. * canvas.viewbox({ x: 100, y: 100, width: 500, height: 500 })
  9960. *
  9961. * // sets the visible area of the diagram to (100|100) -> (600|100)
  9962. * // and and scales it according to the diagram width
  9963. *
  9964. * @return {Object} the current view box
  9965. */
  9966. Canvas.prototype.viewbox = function(box) {
  9967. if (box === undefined && this._cachedViewbox) {
  9968. return this._cachedViewbox;
  9969. }
  9970. var viewport = this._viewport,
  9971. innerBox,
  9972. outerBox = this.getSize(),
  9973. matrix,
  9974. scale,
  9975. x, y;
  9976. if (!box) {
  9977. // compute the inner box based on the
  9978. // diagrams default layer. This allows us to exclude
  9979. // external components, such as overlays
  9980. innerBox = this.getDefaultLayer().getBBox(true);
  9981. matrix = viewport.transform().localMatrix;
  9982. scale = round(matrix.a, 1000);
  9983. x = round(-matrix.e || 0, 1000);
  9984. y = round(-matrix.f || 0, 1000);
  9985. box = this._cachedViewbox = {
  9986. x: x ? x / scale : 0,
  9987. y: y ? y / scale : 0,
  9988. width: outerBox.width / scale,
  9989. height: outerBox.height / scale,
  9990. scale: scale,
  9991. inner: {
  9992. width: innerBox.width,
  9993. height: innerBox.height,
  9994. x: innerBox.x,
  9995. y: innerBox.y
  9996. },
  9997. outer: outerBox
  9998. };
  9999. return box;
  10000. } else {
  10001. scale = Math.min(outerBox.width / box.width, outerBox.height / box.height);
  10002. matrix = new Snap.Matrix().scale(scale).translate(-box.x, -box.y);
  10003. viewport.transform(matrix);
  10004. this._fireViewboxChange();
  10005. }
  10006. return box;
  10007. };
  10008. /**
  10009. * Gets or sets the scroll of the canvas.
  10010. *
  10011. * @param {Object} [delta] the new scroll to apply.
  10012. *
  10013. * @param {Number} [delta.dx]
  10014. * @param {Number} [delta.dy]
  10015. */
  10016. Canvas.prototype.scroll = function(delta) {
  10017. var node = this._viewport.node;
  10018. var matrix = node.getCTM();
  10019. if (delta) {
  10020. delta = assign({ dx: 0, dy: 0 }, delta || {});
  10021. matrix = this._svg.node.createSVGMatrix().translate(delta.dx, delta.dy).multiply(matrix);
  10022. setCTM(node, matrix);
  10023. this._fireViewboxChange();
  10024. }
  10025. return { x: matrix.e, y: matrix.f };
  10026. };
  10027. /**
  10028. * Gets or sets the current zoom of the canvas, optionally zooming to the specified position.
  10029. *
  10030. * @param {String|Number} [newScale] the new zoom level, either a number, i.e. 0.9,
  10031. * or `fit-viewport` to adjust the size to fit the current viewport
  10032. * @param {String|Point} [center] the reference point { x: .., y: ..} to zoom to, 'auto' to zoom into mid or null
  10033. *
  10034. * @return {Number} the current scale
  10035. */
  10036. Canvas.prototype.zoom = function(newScale, center) {
  10037. if (newScale === 'fit-viewport') {
  10038. return this._fitViewport(center);
  10039. }
  10040. var vbox = this.viewbox(),
  10041. outer,
  10042. matrix;
  10043. if (newScale === undefined) {
  10044. return vbox.scale;
  10045. }
  10046. if (typeof center !== 'object') {
  10047. outer = vbox.outer;
  10048. center = {
  10049. x: outer.width / 2,
  10050. y: outer.height / 2
  10051. };
  10052. }
  10053. matrix = this._setZoom(newScale, center);
  10054. this._fireViewboxChange();
  10055. return round(matrix.a, 1000);
  10056. };
  10057. function setCTM(node, m) {
  10058. var mstr = 'matrix(' + m.a + ',' + m.b + ',' + m.c + ',' + m.d + ',' + m.e + ',' + m.f + ')';
  10059. node.setAttribute('transform', mstr);
  10060. }
  10061. Canvas.prototype._fitViewport = function(center) {
  10062. var vbox = this.viewbox(),
  10063. outer = vbox.outer,
  10064. inner = vbox.inner,
  10065. newScale,
  10066. newViewbox;
  10067. // display the complete diagram without zooming in.
  10068. // instead of relying on internal zoom, we perform a
  10069. // hard reset on the canvas viewbox to realize this
  10070. //
  10071. // if diagram does not need to be zoomed in, we focus it around
  10072. // the diagram origin instead
  10073. if (inner.x >= 0 &&
  10074. inner.y >= 0 &&
  10075. inner.x + inner.width <= outer.width &&
  10076. inner.y + inner.height <= outer.height &&
  10077. !center) {
  10078. newViewbox = {
  10079. x: 0,
  10080. y: 0,
  10081. width: Math.max(inner.width + inner.x, outer.width),
  10082. height: Math.max(inner.height + inner.y, outer.height)
  10083. };
  10084. } else {
  10085. newScale = Math.min(1, outer.width / inner.width, outer.height / inner.height);
  10086. newViewbox = {
  10087. x: inner.x + (center ? inner.width / 2 - outer.width / newScale / 2 : 0),
  10088. y: inner.y + (center ? inner.height / 2 - outer.height / newScale / 2 : 0),
  10089. width: outer.width / newScale,
  10090. height: outer.height / newScale
  10091. };
  10092. }
  10093. this.viewbox(newViewbox);
  10094. return this.viewbox().scale;
  10095. };
  10096. Canvas.prototype._setZoom = function(scale, center) {
  10097. var svg = this._svg.node,
  10098. viewport = this._viewport.node;
  10099. var matrix = svg.createSVGMatrix();
  10100. var point = svg.createSVGPoint();
  10101. var centerPoint,
  10102. originalPoint,
  10103. currentMatrix,
  10104. scaleMatrix,
  10105. newMatrix;
  10106. currentMatrix = viewport.getCTM();
  10107. var currentScale = currentMatrix.a;
  10108. if (center) {
  10109. centerPoint = assign(point, center);
  10110. // revert applied viewport transformations
  10111. originalPoint = centerPoint.matrixTransform(currentMatrix.inverse());
  10112. // create scale matrix
  10113. scaleMatrix = matrix
  10114. .translate(originalPoint.x, originalPoint.y)
  10115. .scale(1 / currentScale * scale)
  10116. .translate(-originalPoint.x, -originalPoint.y);
  10117. newMatrix = currentMatrix.multiply(scaleMatrix);
  10118. } else {
  10119. newMatrix = matrix.scale(scale);
  10120. }
  10121. setCTM(this._viewport.node, newMatrix);
  10122. return newMatrix;
  10123. };
  10124. /**
  10125. * Returns the size of the canvas
  10126. *
  10127. * @return {Dimensions}
  10128. */
  10129. Canvas.prototype.getSize = function () {
  10130. return {
  10131. width: this._container.clientWidth,
  10132. height: this._container.clientHeight
  10133. };
  10134. };
  10135. /**
  10136. * Return the absolute bounding box for the given element
  10137. *
  10138. * The absolute bounding box may be used to display overlays in the
  10139. * callers (browser) coordinate system rather than the zoomed in/out
  10140. * canvas coordinates.
  10141. *
  10142. * @param {ElementDescriptor} element
  10143. * @return {Bounds} the absolute bounding box
  10144. */
  10145. Canvas.prototype.getAbsoluteBBox = function(element) {
  10146. var vbox = this.viewbox();
  10147. var bbox;
  10148. // connection
  10149. // use svg bbox
  10150. if (element.waypoints) {
  10151. var gfx = this.getGraphics(element);
  10152. var transformBBox = gfx.getBBox(true);
  10153. bbox = gfx.getBBox();
  10154. bbox.x -= transformBBox.x;
  10155. bbox.y -= transformBBox.y;
  10156. bbox.width += 2 * transformBBox.x;
  10157. bbox.height += 2 * transformBBox.y;
  10158. }
  10159. // shapes
  10160. // use data
  10161. else {
  10162. bbox = element;
  10163. }
  10164. var x = bbox.x * vbox.scale - vbox.x * vbox.scale;
  10165. var y = bbox.y * vbox.scale - vbox.y * vbox.scale;
  10166. var width = bbox.width * vbox.scale;
  10167. var height = bbox.height * vbox.scale;
  10168. return {
  10169. x: x,
  10170. y: y,
  10171. width: width,
  10172. height: height
  10173. };
  10174. };
  10175. },{"171":171,"177":177,"64":64,"76":76,"83":83,"86":86}],39:[function(_dereq_,module,exports){
  10176. 'use strict';
  10177. var Model = _dereq_(57);
  10178. /**
  10179. * A factory for diagram-js shapes
  10180. */
  10181. function ElementFactory() {
  10182. this._uid = 12;
  10183. }
  10184. module.exports = ElementFactory;
  10185. ElementFactory.prototype.createRoot = function(attrs) {
  10186. return this.create('root', attrs);
  10187. };
  10188. ElementFactory.prototype.createLabel = function(attrs) {
  10189. return this.create('label', attrs);
  10190. };
  10191. ElementFactory.prototype.createShape = function(attrs) {
  10192. return this.create('shape', attrs);
  10193. };
  10194. ElementFactory.prototype.createConnection = function(attrs) {
  10195. return this.create('connection', attrs);
  10196. };
  10197. /**
  10198. * Create a model element with the given type and
  10199. * a number of pre-set attributes.
  10200. *
  10201. * @param {String} type
  10202. * @param {Object} attrs
  10203. * @return {djs.model.Base} the newly created model instance
  10204. */
  10205. ElementFactory.prototype.create = function(type, attrs) {
  10206. attrs = attrs || {};
  10207. if (!attrs.id) {
  10208. attrs.id = type + '_' + (this._uid++);
  10209. }
  10210. return Model.create(type, attrs);
  10211. };
  10212. },{"57":57}],40:[function(_dereq_,module,exports){
  10213. 'use strict';
  10214. var ELEMENT_ID = 'data-element-id';
  10215. /**
  10216. * @class
  10217. *
  10218. * A registry that keeps track of all shapes in the diagram.
  10219. */
  10220. function ElementRegistry() {
  10221. this._elements = {};
  10222. }
  10223. module.exports = ElementRegistry;
  10224. /**
  10225. * Register a pair of (element, gfx, (secondaryGfx)).
  10226. *
  10227. * @param {djs.model.Base} element
  10228. * @param {Snap<SVGElement>} gfx
  10229. * @param {Snap<SVGElement>} [secondaryGfx] optional other element to register, too
  10230. */
  10231. ElementRegistry.prototype.add = function(element, gfx, secondaryGfx) {
  10232. var id = element.id;
  10233. this._validateId(id);
  10234. // associate dom node with element
  10235. gfx.attr(ELEMENT_ID, id);
  10236. if (secondaryGfx) {
  10237. secondaryGfx.attr(ELEMENT_ID, id);
  10238. }
  10239. this._elements[id] = { element: element, gfx: gfx, secondaryGfx: secondaryGfx };
  10240. };
  10241. /**
  10242. * Removes an element from the registry.
  10243. *
  10244. * @param {djs.model.Base} element
  10245. */
  10246. ElementRegistry.prototype.remove = function(element) {
  10247. var elements = this._elements,
  10248. id = element.id || element,
  10249. container = id && elements[id];
  10250. if (container) {
  10251. // unset element id on gfx
  10252. container.gfx.attr(ELEMENT_ID, null);
  10253. if (container.secondaryGfx) {
  10254. container.secondaryGfx.attr(ELEMENT_ID, null);
  10255. }
  10256. delete elements[id];
  10257. }
  10258. };
  10259. /**
  10260. * Update the id of an element
  10261. *
  10262. * @param {djs.model.Base} element
  10263. * @param {String} newId
  10264. */
  10265. ElementRegistry.prototype.updateId = function(element, newId) {
  10266. this._validateId(newId);
  10267. if (typeof element === 'string') {
  10268. element = this.get(element);
  10269. }
  10270. var gfx = this.getGraphics(element),
  10271. secondaryGfx = this.getGraphics(element, true);
  10272. this.remove(element);
  10273. element.id = newId;
  10274. this.add(element, gfx, secondaryGfx);
  10275. };
  10276. /**
  10277. * Return the model element for a given id or graphics.
  10278. *
  10279. * @example
  10280. *
  10281. * elementRegistry.get('SomeElementId_1');
  10282. * elementRegistry.get(gfx);
  10283. *
  10284. *
  10285. * @param {String|SVGElement} filter for selecting the element
  10286. *
  10287. * @return {djs.model.Base}
  10288. */
  10289. ElementRegistry.prototype.get = function(filter) {
  10290. var id;
  10291. if (typeof filter === 'string') {
  10292. id = filter;
  10293. } else {
  10294. id = filter && filter.attr(ELEMENT_ID);
  10295. }
  10296. var container = this._elements[id];
  10297. return container && container.element;
  10298. };
  10299. /**
  10300. * Return all elements that match a given filter function.
  10301. *
  10302. * @param {Function} fn
  10303. *
  10304. * @return {Array<djs.model.Base>}
  10305. */
  10306. ElementRegistry.prototype.filter = function(fn) {
  10307. var filtered = [];
  10308. this.forEach(function(element, gfx) {
  10309. if(fn(element, gfx)) {
  10310. filtered.push(element);
  10311. }
  10312. });
  10313. return filtered;
  10314. };
  10315. /**
  10316. * Return all rendered model elements.
  10317. *
  10318. * @return {Array<djs.model.Base>}
  10319. */
  10320. ElementRegistry.prototype.getAll = function() {
  10321. return this.filter(function(e) { return e; });
  10322. };
  10323. /**
  10324. * Iterate over all diagram elements.
  10325. *
  10326. * @param {Function} fn
  10327. */
  10328. ElementRegistry.prototype.forEach = function(fn) {
  10329. var map = this._elements;
  10330. Object.keys(map).forEach(function(id) {
  10331. var container = map[id],
  10332. element = container.element,
  10333. gfx = container.gfx;
  10334. return fn(element, gfx);
  10335. });
  10336. };
  10337. /**
  10338. * Return the graphical representation of an element or its id.
  10339. *
  10340. * @example
  10341. * elementRegistry.getGraphics('SomeElementId_1');
  10342. * elementRegistry.getGraphics(rootElement); // <g ...>
  10343. *
  10344. * elementRegistry.getGraphics(rootElement, true); // <svg ...>
  10345. *
  10346. *
  10347. * @param {String|djs.model.Base} filter
  10348. * @param {Boolean} [secondary=false] whether to return the secondary connected element
  10349. *
  10350. * @return {SVGElement}
  10351. */
  10352. ElementRegistry.prototype.getGraphics = function(filter, secondary) {
  10353. var id = filter.id || filter;
  10354. var container = this._elements[id];
  10355. return container && (secondary ? container.secondaryGfx : container.gfx);
  10356. };
  10357. /**
  10358. * Validate the suitability of the given id and signals a problem
  10359. * with an exception.
  10360. *
  10361. * @param {String} id
  10362. *
  10363. * @throws {Error} if id is empty or already assigned
  10364. */
  10365. ElementRegistry.prototype._validateId = function(id) {
  10366. if (!id) {
  10367. throw new Error('element must have an id');
  10368. }
  10369. if (this._elements[id]) {
  10370. throw new Error('element with id ' + id + ' already added');
  10371. }
  10372. };
  10373. },{}],41:[function(_dereq_,module,exports){
  10374. 'use strict';
  10375. var isFunction = _dereq_(169),
  10376. isArray = _dereq_(168),
  10377. isNumber = _dereq_(171),
  10378. assign = _dereq_(177);
  10379. var DEFAULT_PRIORITY = 1000;
  10380. /**
  10381. * A general purpose event bus.
  10382. *
  10383. * This component is used to communicate across a diagram instance.
  10384. * Other parts of a diagram can use it to listen to and broadcast events.
  10385. *
  10386. *
  10387. * ## Registering for Events
  10388. *
  10389. * The event bus provides the {@link EventBus#on} and {@link EventBus#once}
  10390. * methods to register for events. {@link EventBus#off} can be used to
  10391. * remove event registrations. Listeners receive an instance of {@link Event}
  10392. * as the first argument. It allows them to hook into the event execution.
  10393. *
  10394. * ```javascript
  10395. *
  10396. * // listen for event
  10397. * eventBus.on('foo', function(event) {
  10398. *
  10399. * // access event type
  10400. * event.type; // 'foo'
  10401. *
  10402. * // stop propagation to other listeners
  10403. * event.stopPropagation();
  10404. *
  10405. * // prevent event default
  10406. * event.preventDefault();
  10407. * });
  10408. *
  10409. * // listen for event with custom payload
  10410. * eventBus.on('bar', function(event, payload) {
  10411. * console.log(payload);
  10412. * });
  10413. *
  10414. * // listen for event returning value
  10415. * eventBus.on('foobar', function(event) {
  10416. *
  10417. * // stop event propagation + prevent default
  10418. * return false;
  10419. *
  10420. * // stop event propagation + return custom result
  10421. * return {
  10422. * complex: 'listening result'
  10423. * };
  10424. * });
  10425. *
  10426. *
  10427. * // listen with custom priority (default=1000, higher is better)
  10428. * eventBus.on('priorityfoo', 1500, function(event) {
  10429. * console.log('invoked first!');
  10430. * });
  10431. * ```
  10432. *
  10433. *
  10434. * ## Emitting Events
  10435. *
  10436. * Events can be emitted via the event bus using {@link EventBus#fire}.
  10437. *
  10438. * ```javascript
  10439. *
  10440. * // false indicates that the default action
  10441. * // was prevented by listeners
  10442. * if (eventBus.fire('foo') === false) {
  10443. * console.log('default has been prevented!');
  10444. * };
  10445. *
  10446. *
  10447. * // custom args + return value listener
  10448. * eventBus.on('sum', function(event, a, b) {
  10449. * return a + b;
  10450. * });
  10451. *
  10452. * // you can pass custom arguments + retrieve result values.
  10453. * var sum = eventBus.fire('sum', 1, 2);
  10454. * console.log(sum); // 3
  10455. * ```
  10456. */
  10457. function EventBus() {
  10458. this._listeners = {};
  10459. // cleanup on destroy
  10460. var self = this;
  10461. // destroy on lowest priority to allow
  10462. // message passing until the bitter end
  10463. this.on('diagram.destroy', 1, function() {
  10464. self._listeners = null;
  10465. });
  10466. }
  10467. module.exports = EventBus;
  10468. /**
  10469. * Register an event listener for events with the given name.
  10470. *
  10471. * The callback will be invoked with `event, ...additionalArguments`
  10472. * that have been passed to {@link EventBus#fire}.
  10473. *
  10474. * Returning false from a listener will prevent the events default action
  10475. * (if any is specified). To stop an event from being processed further in
  10476. * other listeners execute {@link Event#stopPropagation}.
  10477. *
  10478. * Returning anything but `undefined` from a listener will stop the listener propagation.
  10479. *
  10480. * @param {String|Array<String>} events
  10481. * @param {Number} [priority=1000] the priority in which this listener is called, larger is higher
  10482. * @param {Function} callback
  10483. */
  10484. EventBus.prototype.on = function(events, priority, callback) {
  10485. events = isArray(events) ? events : [ events ];
  10486. if (isFunction(priority)) {
  10487. callback = priority;
  10488. priority = DEFAULT_PRIORITY;
  10489. }
  10490. if (!isNumber(priority)) {
  10491. throw new Error('priority must be a number');
  10492. }
  10493. var self = this,
  10494. listener = { priority: priority, callback: callback };
  10495. events.forEach(function(e) {
  10496. self._addListener(e, listener);
  10497. });
  10498. };
  10499. /**
  10500. * Register an event listener that is executed only once.
  10501. *
  10502. * @param {String} event the event name to register for
  10503. * @param {Function} callback the callback to execute
  10504. */
  10505. EventBus.prototype.once = function(event, callback) {
  10506. var self = this;
  10507. function wrappedCallback() {
  10508. callback.apply(self, arguments);
  10509. self.off(event, wrappedCallback);
  10510. }
  10511. this.on(event, wrappedCallback);
  10512. };
  10513. /**
  10514. * Removes event listeners by event and callback.
  10515. *
  10516. * If no callback is given, all listeners for a given event name are being removed.
  10517. *
  10518. * @param {String} event
  10519. * @param {Function} [callback]
  10520. */
  10521. EventBus.prototype.off = function(event, callback) {
  10522. var listeners = this._getListeners(event),
  10523. listener, idx;
  10524. if (callback) {
  10525. // move through listeners from back to front
  10526. // and remove matching listeners
  10527. for (idx = listeners.length - 1; !!(listener = listeners[idx]); idx--) {
  10528. if (listener.callback === callback) {
  10529. listeners.splice(idx, 1);
  10530. }
  10531. }
  10532. } else {
  10533. // clear listeners
  10534. listeners.length = 0;
  10535. }
  10536. };
  10537. /**
  10538. * Fires a named event.
  10539. *
  10540. * @example
  10541. *
  10542. * // fire event by name
  10543. * events.fire('foo');
  10544. *
  10545. * // fire event object with nested type
  10546. * var event = { type: 'foo' };
  10547. * events.fire(event);
  10548. *
  10549. * // fire event with explicit type
  10550. * var event = { x: 10, y: 20 };
  10551. * events.fire('element.moved', event);
  10552. *
  10553. * // pass additional arguments to the event
  10554. * events.on('foo', function(event, bar) {
  10555. * alert(bar);
  10556. * });
  10557. *
  10558. * events.fire({ type: 'foo' }, 'I am bar!');
  10559. *
  10560. * @param {String} [name] the optional event name
  10561. * @param {Object} [event] the event object
  10562. * @param {...Object} additional arguments to be passed to the callback functions
  10563. *
  10564. * @return {Boolean} the events return value, if specified or false if the
  10565. * default action was prevented by listeners
  10566. */
  10567. EventBus.prototype.fire = function(type, data) {
  10568. var event,
  10569. originalType,
  10570. listeners, idx, listener,
  10571. returnValue,
  10572. args;
  10573. args = Array.prototype.slice.call(arguments);
  10574. if (typeof type === 'object') {
  10575. event = type;
  10576. type = event.type;
  10577. }
  10578. if (!type) {
  10579. throw new Error('no event type specified');
  10580. }
  10581. listeners = this._listeners[type];
  10582. if (!listeners) {
  10583. return;
  10584. }
  10585. // we make sure we fire instances of our home made
  10586. // events here. We wrap them only once, though
  10587. if (data instanceof Event) {
  10588. // we are fine, we alread have an event
  10589. event = data;
  10590. } else {
  10591. event = new Event();
  10592. event.init(data);
  10593. }
  10594. // ensure we pass the event as the first parameter
  10595. args[0] = event;
  10596. // original event type (in case we delegate)
  10597. originalType = event.type;
  10598. try {
  10599. // update event type before delegation
  10600. if (type !== originalType) {
  10601. event.type = type;
  10602. }
  10603. for (idx = 0; !!(listener = listeners[idx]); idx++) {
  10604. // handle stopped propagation
  10605. if (event.cancelBubble) {
  10606. break;
  10607. }
  10608. try {
  10609. // returning false prevents the default action
  10610. returnValue = event.returnValue = listener.callback.apply(null, args);
  10611. // stop propagation on return value
  10612. if (returnValue !== undefined) {
  10613. event.stopPropagation();
  10614. }
  10615. // prevent default on return false
  10616. if (returnValue === false) {
  10617. event.preventDefault();
  10618. }
  10619. } catch (e) {
  10620. if (!this.handleError(e)) {
  10621. console.error('unhandled error in event listener');
  10622. console.error(e.stack);
  10623. throw e;
  10624. }
  10625. }
  10626. }
  10627. } finally {
  10628. // reset event type after delegation
  10629. if (type !== originalType) {
  10630. event.type = originalType;
  10631. }
  10632. }
  10633. // set the return value to false if the event default
  10634. // got prevented and no other return value exists
  10635. if (returnValue === undefined && event.defaultPrevented) {
  10636. returnValue = false;
  10637. }
  10638. return returnValue;
  10639. };
  10640. EventBus.prototype.handleError = function(error) {
  10641. return this.fire('error', { error: error }) === false;
  10642. };
  10643. /*
  10644. * Add new listener with a certain priority to the list
  10645. * of listeners (for the given event).
  10646. *
  10647. * The semantics of listener registration / listener execution are
  10648. * first register, first serve: New listeners will always be inserted
  10649. * after existing listeners with the same priority.
  10650. *
  10651. * Example: Inserting two listeners with priority 1000 and 1300
  10652. *
  10653. * * before: [ 1500, 1500, 1000, 1000 ]
  10654. * * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
  10655. *
  10656. * @param {String} event
  10657. * @param {Object} listener { priority, callback }
  10658. */
  10659. EventBus.prototype._addListener = function(event, newListener) {
  10660. var listeners = this._getListeners(event),
  10661. existingListener,
  10662. idx;
  10663. // ensure we order listeners by priority from
  10664. // 0 (high) to n > 0 (low)
  10665. for (idx = 0; !!(existingListener = listeners[idx]); idx++) {
  10666. if (existingListener.priority < newListener.priority) {
  10667. // prepend newListener at before existingListener
  10668. listeners.splice(idx, 0, newListener);
  10669. return;
  10670. }
  10671. }
  10672. listeners.push(newListener);
  10673. };
  10674. EventBus.prototype._getListeners = function(name) {
  10675. var listeners = this._listeners[name];
  10676. if (!listeners) {
  10677. this._listeners[name] = listeners = [];
  10678. }
  10679. return listeners;
  10680. };
  10681. /**
  10682. * A event that is emitted via the event bus.
  10683. */
  10684. function Event() { }
  10685. module.exports.Event = Event;
  10686. Event.prototype.stopPropagation = function() {
  10687. this.cancelBubble = true;
  10688. };
  10689. Event.prototype.preventDefault = function() {
  10690. this.defaultPrevented = true;
  10691. };
  10692. Event.prototype.init = function(data) {
  10693. assign(this, data || {});
  10694. };
  10695. },{"168":168,"169":169,"171":171,"177":177}],42:[function(_dereq_,module,exports){
  10696. 'use strict';
  10697. var forEach = _dereq_(86),
  10698. reduce = _dereq_(90);
  10699. var GraphicsUtil = _dereq_(68),
  10700. domClear = _dereq_(188);
  10701. /**
  10702. * A factory that creates graphical elements
  10703. *
  10704. * @param {Renderer} renderer
  10705. */
  10706. function GraphicsFactory(renderer, elementRegistry) {
  10707. this._renderer = renderer;
  10708. this._elementRegistry = elementRegistry;
  10709. }
  10710. GraphicsFactory.$inject = [ 'renderer', 'elementRegistry' ];
  10711. module.exports = GraphicsFactory;
  10712. GraphicsFactory.prototype._getChildren = function(element) {
  10713. var gfx = this._elementRegistry.getGraphics(element);
  10714. var childrenGfx;
  10715. // root element
  10716. if (!element.parent) {
  10717. childrenGfx = gfx;
  10718. } else {
  10719. childrenGfx = GraphicsUtil.getChildren(gfx);
  10720. if (!childrenGfx) {
  10721. childrenGfx = gfx.parent().group().attr('class', 'djs-children');
  10722. }
  10723. }
  10724. return childrenGfx;
  10725. };
  10726. /**
  10727. * Clears the graphical representation of the element and returns the
  10728. * cleared visual (the <g class="djs-visual" /> element).
  10729. */
  10730. GraphicsFactory.prototype._clear = function(gfx) {
  10731. var visual = GraphicsUtil.getVisual(gfx);
  10732. domClear(visual.node);
  10733. return visual;
  10734. };
  10735. /**
  10736. * Creates a gfx container for shapes and connections
  10737. *
  10738. * The layout is as follows:
  10739. *
  10740. * <g class="djs-group">
  10741. *
  10742. * <!-- the gfx -->
  10743. * <g class="djs-element djs-(shape|connection)">
  10744. * <g class="djs-visual">
  10745. * <!-- the renderer draws in here -->
  10746. * </g>
  10747. *
  10748. * <!-- extensions (overlays, click box, ...) goes here
  10749. * </g>
  10750. *
  10751. * <!-- the gfx child nodes -->
  10752. * <g class="djs-children"></g>
  10753. * </g>
  10754. *
  10755. * @param {Object} parent
  10756. * @param {String} type the type of the element, i.e. shape | connection
  10757. */
  10758. GraphicsFactory.prototype._createContainer = function(type, parentGfx) {
  10759. var outerGfx = parentGfx.group().attr('class', 'djs-group'),
  10760. gfx = outerGfx.group().attr('class', 'djs-element djs-' + type);
  10761. // create visual
  10762. gfx.group().attr('class', 'djs-visual');
  10763. return gfx;
  10764. };
  10765. GraphicsFactory.prototype.create = function(type, element) {
  10766. var childrenGfx = this._getChildren(element.parent);
  10767. return this._createContainer(type, childrenGfx);
  10768. };
  10769. GraphicsFactory.prototype.updateContainments = function(elements) {
  10770. var self = this,
  10771. elementRegistry = this._elementRegistry,
  10772. parents;
  10773. parents = reduce(elements, function(map, e) {
  10774. if (e.parent) {
  10775. map[e.parent.id] = e.parent;
  10776. }
  10777. return map;
  10778. }, {});
  10779. // update all parents of changed and reorganized their children
  10780. // in the correct order (as indicated in our model)
  10781. forEach(parents, function(parent) {
  10782. var childGfx = self._getChildren(parent),
  10783. children = parent.children;
  10784. if (!children) {
  10785. return;
  10786. }
  10787. forEach(children.slice().reverse(), function(c) {
  10788. var gfx = elementRegistry.getGraphics(c);
  10789. gfx.parent().prependTo(childGfx);
  10790. });
  10791. });
  10792. };
  10793. GraphicsFactory.prototype.update = function(type, element, gfx) {
  10794. // Do not update root element
  10795. if (!element.parent) {
  10796. return;
  10797. }
  10798. var visual = this._clear(gfx);
  10799. // redraw
  10800. if (type === 'shape') {
  10801. this._renderer.drawShape(visual, element);
  10802. // update positioning
  10803. gfx.translate(element.x, element.y);
  10804. } else
  10805. if (type === 'connection') {
  10806. this._renderer.drawConnection(visual, element);
  10807. } else {
  10808. throw new Error('unknown type: ' + type);
  10809. }
  10810. gfx.attr('display', element.hidden ? 'none' : 'block');
  10811. };
  10812. GraphicsFactory.prototype.remove = function(element) {
  10813. var gfx = this._elementRegistry.getGraphics(element);
  10814. // remove
  10815. gfx.parent().remove();
  10816. };
  10817. },{"188":188,"68":68,"86":86,"90":90}],43:[function(_dereq_,module,exports){
  10818. module.exports = {
  10819. __depends__: [ _dereq_(46) ],
  10820. __init__: [ 'canvas' ],
  10821. canvas: [ 'type', _dereq_(38) ],
  10822. elementRegistry: [ 'type', _dereq_(40) ],
  10823. elementFactory: [ 'type', _dereq_(39) ],
  10824. eventBus: [ 'type', _dereq_(41) ],
  10825. graphicsFactory: [ 'type', _dereq_(42) ]
  10826. };
  10827. },{"38":38,"39":39,"40":40,"41":41,"42":42,"46":46}],44:[function(_dereq_,module,exports){
  10828. 'use strict';
  10829. var Snap = _dereq_(76);
  10830. /**
  10831. * The default renderer used for shapes and connections.
  10832. *
  10833. * @param {Styles} styles
  10834. */
  10835. function Renderer(styles) {
  10836. this.CONNECTION_STYLE = styles.style([ 'no-fill' ], { strokeWidth: 5, stroke: 'fuchsia' });
  10837. this.SHAPE_STYLE = styles.style({ fill: 'white', stroke: 'fuchsia', strokeWidth: 2 });
  10838. }
  10839. module.exports = Renderer;
  10840. Renderer.$inject = ['styles'];
  10841. Renderer.prototype.drawShape = function drawShape(gfxGroup, data) {
  10842. return gfxGroup.rect(0, 0, data.width || 0, data.height || 0).attr(this.SHAPE_STYLE);
  10843. };
  10844. Renderer.prototype.drawConnection = function drawConnection(gfxGroup, data) {
  10845. return createLine(data.waypoints, this.CONNECTION_STYLE).appendTo(gfxGroup);
  10846. };
  10847. function componentsToPath(components) {
  10848. return components.join(',').replace(/,?([A-z]),?/g, '$1');
  10849. }
  10850. /**
  10851. * Gets the default SVG path of a shape that represents it's visual bounds.
  10852. *
  10853. * @param {djs.model.Shape} shape
  10854. * @return {string} svg path
  10855. */
  10856. Renderer.prototype.getShapePath = function getShapePath(shape) {
  10857. var x = shape.x,
  10858. y = shape.y,
  10859. width = shape.width,
  10860. height = shape.height;
  10861. var shapePath = [
  10862. ['M', x, y],
  10863. ['l', width, 0],
  10864. ['l', 0, height],
  10865. ['l', -width, 0],
  10866. ['z']
  10867. ];
  10868. return componentsToPath(shapePath);
  10869. };
  10870. /**
  10871. * Gets the default SVG path of a connection that represents it's visual bounds.
  10872. *
  10873. * @param {djs.model.Connection} connection
  10874. * @return {string} svg path
  10875. */
  10876. Renderer.prototype.getConnectionPath = function getConnectionPath(connection) {
  10877. var waypoints = connection.waypoints;
  10878. var idx, point, connectionPath = [];
  10879. for (idx = 0; !!(point = waypoints[idx]); idx++) {
  10880. // take invisible docking into account
  10881. // when creating the path
  10882. point = point.original || point;
  10883. connectionPath.push([ idx === 0 ? 'M' : 'L', point.x, point.y ]);
  10884. }
  10885. return componentsToPath(connectionPath);
  10886. };
  10887. function toSVGPoints(points) {
  10888. var result = '';
  10889. for (var i = 0, p; !!(p = points[i]); i++) {
  10890. result += p.x + ',' + p.y + ' ';
  10891. }
  10892. return result;
  10893. }
  10894. function createLine(points, attrs) {
  10895. return Snap.create('polyline', { points: toSVGPoints(points) }).attr(attrs || {});
  10896. }
  10897. function updateLine(gfx, points) {
  10898. return gfx.attr({ points: toSVGPoints(points) });
  10899. }
  10900. module.exports.createLine = createLine;
  10901. module.exports.updateLine = updateLine;
  10902. },{"76":76}],45:[function(_dereq_,module,exports){
  10903. 'use strict';
  10904. var isArray = _dereq_(168),
  10905. assign = _dereq_(177),
  10906. reduce = _dereq_(90);
  10907. /**
  10908. * A component that manages shape styles
  10909. */
  10910. function Styles() {
  10911. var defaultTraits = {
  10912. 'no-fill': {
  10913. fill: 'none'
  10914. },
  10915. 'no-border': {
  10916. strokeOpacity: 0.0
  10917. },
  10918. 'no-events': {
  10919. pointerEvents: 'none'
  10920. }
  10921. };
  10922. /**
  10923. * Builds a style definition from a className, a list of traits and an object of additional attributes.
  10924. *
  10925. * @param {String} className
  10926. * @param {Array<String>} traits
  10927. * @param {Object} additionalAttrs
  10928. *
  10929. * @return {Object} the style defintion
  10930. */
  10931. this.cls = function(className, traits, additionalAttrs) {
  10932. var attrs = this.style(traits, additionalAttrs);
  10933. return assign(attrs, { 'class': className });
  10934. };
  10935. /**
  10936. * Builds a style definition from a list of traits and an object of additional attributes.
  10937. *
  10938. * @param {Array<String>} traits
  10939. * @param {Object} additionalAttrs
  10940. *
  10941. * @return {Object} the style defintion
  10942. */
  10943. this.style = function(traits, additionalAttrs) {
  10944. if (!isArray(traits) && !additionalAttrs) {
  10945. additionalAttrs = traits;
  10946. traits = [];
  10947. }
  10948. var attrs = reduce(traits, function(attrs, t) {
  10949. return assign(attrs, defaultTraits[t] || {});
  10950. }, {});
  10951. return additionalAttrs ? assign(attrs, additionalAttrs) : attrs;
  10952. };
  10953. }
  10954. module.exports = Styles;
  10955. },{"168":168,"177":177,"90":90}],46:[function(_dereq_,module,exports){
  10956. module.exports = {
  10957. renderer: [ 'type', _dereq_(44) ],
  10958. styles: [ 'type', _dereq_(45) ]
  10959. };
  10960. },{"44":44,"45":45}],47:[function(_dereq_,module,exports){
  10961. 'use strict';
  10962. var forEach = _dereq_(86),
  10963. domDelegate = _dereq_(189),
  10964. Renderer = _dereq_(44),
  10965. createLine = Renderer.createLine,
  10966. updateLine = Renderer.updateLine;
  10967. var isPrimaryButton = _dereq_(71).isPrimaryButton;
  10968. var Snap = _dereq_(76);
  10969. /**
  10970. * A plugin that provides interaction events for diagram elements.
  10971. *
  10972. * It emits the following events:
  10973. *
  10974. * * element.hover
  10975. * * element.out
  10976. * * element.click
  10977. * * element.dblclick
  10978. * * element.mousedown
  10979. *
  10980. * Each event is a tuple { element, gfx, originalEvent }.
  10981. *
  10982. * Canceling the event via Event#preventDefault() prevents the original DOM operation.
  10983. *
  10984. * @param {EventBus} eventBus
  10985. */
  10986. function InteractionEvents(eventBus, elementRegistry, styles) {
  10987. var HIT_STYLE = styles.cls('djs-hit', [ 'no-fill', 'no-border' ], {
  10988. stroke: 'white',
  10989. strokeWidth: 15
  10990. });
  10991. function fire(type, event) {
  10992. var target = event.delegateTarget || event.target,
  10993. gfx = target && new Snap(target),
  10994. element = elementRegistry.get(gfx),
  10995. returnValue;
  10996. if (!gfx || !element) {
  10997. return;
  10998. }
  10999. returnValue = eventBus.fire(type, { element: element, gfx: gfx, originalEvent: event });
  11000. if (returnValue === false) {
  11001. event.stopPropagation();
  11002. event.preventDefault();
  11003. }
  11004. }
  11005. var handlers = {};
  11006. function mouseHandler(type) {
  11007. var fn = handlers[type];
  11008. if (!fn) {
  11009. fn = handlers[type] = function(event) {
  11010. // only indicate left mouse button interactions
  11011. if (isPrimaryButton(event)) {
  11012. fire(type, event);
  11013. }
  11014. };
  11015. }
  11016. return fn;
  11017. }
  11018. var bindings = {
  11019. mouseover: 'element.hover',
  11020. mouseout: 'element.out',
  11021. click: 'element.click',
  11022. dblclick: 'element.dblclick',
  11023. mousedown: 'element.mousedown',
  11024. mouseup: 'element.mouseup'
  11025. };
  11026. var elementSelector = 'svg, .djs-element';
  11027. ///// event registration
  11028. function registerEvent(node, event, localEvent) {
  11029. var handler = mouseHandler(localEvent);
  11030. handler.$delegate = domDelegate.bind(node, elementSelector, event, handler);
  11031. }
  11032. function unregisterEvent(node, event, localEvent) {
  11033. domDelegate.unbind(node, event, mouseHandler(localEvent).$delegate);
  11034. }
  11035. function registerEvents(svg) {
  11036. forEach(bindings, function(val, key) {
  11037. registerEvent(svg.node, key, val);
  11038. });
  11039. }
  11040. function unregisterEvents(svg) {
  11041. forEach(bindings, function(val, key) {
  11042. unregisterEvent(svg.node, key, val);
  11043. });
  11044. }
  11045. eventBus.on('canvas.destroy', function(event) {
  11046. unregisterEvents(event.svg);
  11047. });
  11048. eventBus.on('canvas.init', function(event) {
  11049. registerEvents(event.svg);
  11050. });
  11051. eventBus.on([ 'shape.added', 'connection.added' ], function(event) {
  11052. var element = event.element,
  11053. gfx = event.gfx,
  11054. hit,
  11055. type;
  11056. if (element.waypoints) {
  11057. hit = createLine(element.waypoints);
  11058. type = 'connection';
  11059. } else {
  11060. hit = Snap.create('rect', { x: 0, y: 0, width: element.width, height: element.height });
  11061. type = 'shape';
  11062. }
  11063. hit.attr(HIT_STYLE).appendTo(gfx.node);
  11064. });
  11065. // update djs-hit on change
  11066. eventBus.on('shape.changed', function(event) {
  11067. var element = event.element,
  11068. gfx = event.gfx,
  11069. hit = gfx.select('.djs-hit');
  11070. hit.attr({
  11071. width: element.width,
  11072. height: element.height
  11073. });
  11074. });
  11075. eventBus.on('connection.changed', function(event) {
  11076. var element = event.element,
  11077. gfx = event.gfx,
  11078. hit = gfx.select('.djs-hit');
  11079. updateLine(hit, element.waypoints);
  11080. });
  11081. // API
  11082. this.fire = fire;
  11083. this.mouseHandler = mouseHandler;
  11084. this.registerEvent = registerEvent;
  11085. this.unregisterEvent = unregisterEvent;
  11086. }
  11087. InteractionEvents.$inject = [ 'eventBus', 'elementRegistry', 'styles' ];
  11088. module.exports = InteractionEvents;
  11089. /**
  11090. * An event indicating that the mouse hovered over an element
  11091. *
  11092. * @event element.hover
  11093. *
  11094. * @type {Object}
  11095. * @property {djs.model.Base} element
  11096. * @property {Snap<Element>} gfx
  11097. * @property {Event} originalEvent
  11098. */
  11099. /**
  11100. * An event indicating that the mouse has left an element
  11101. *
  11102. * @event element.out
  11103. *
  11104. * @type {Object}
  11105. * @property {djs.model.Base} element
  11106. * @property {Snap<Element>} gfx
  11107. * @property {Event} originalEvent
  11108. */
  11109. /**
  11110. * An event indicating that the mouse has clicked an element
  11111. *
  11112. * @event element.click
  11113. *
  11114. * @type {Object}
  11115. * @property {djs.model.Base} element
  11116. * @property {Snap<Element>} gfx
  11117. * @property {Event} originalEvent
  11118. */
  11119. /**
  11120. * An event indicating that the mouse has double clicked an element
  11121. *
  11122. * @event element.dblclick
  11123. *
  11124. * @type {Object}
  11125. * @property {djs.model.Base} element
  11126. * @property {Snap<Element>} gfx
  11127. * @property {Event} originalEvent
  11128. */
  11129. /**
  11130. * An event indicating that the mouse has gone down on an element.
  11131. *
  11132. * @event element.mousedown
  11133. *
  11134. * @type {Object}
  11135. * @property {djs.model.Base} element
  11136. * @property {Snap<Element>} gfx
  11137. * @property {Event} originalEvent
  11138. */
  11139. /**
  11140. * An event indicating that the mouse has gone up on an element.
  11141. *
  11142. * @event element.mouseup
  11143. *
  11144. * @type {Object}
  11145. * @property {djs.model.Base} element
  11146. * @property {Snap<Element>} gfx
  11147. * @property {Event} originalEvent
  11148. */
  11149. },{"189":189,"44":44,"71":71,"76":76,"86":86}],48:[function(_dereq_,module,exports){
  11150. module.exports = {
  11151. __init__: [ 'interactionEvents' ],
  11152. interactionEvents: [ 'type', _dereq_(47) ]
  11153. };
  11154. },{"47":47}],49:[function(_dereq_,module,exports){
  11155. 'use strict';
  11156. var getBBox = _dereq_(66).getBBox;
  11157. /**
  11158. * @class
  11159. *
  11160. * A plugin that adds an outline to shapes and connections that may be activated and styled
  11161. * via CSS classes.
  11162. *
  11163. * @param {EventBus} events the event bus
  11164. */
  11165. function Outline(eventBus, styles, elementRegistry) {
  11166. var OUTLINE_OFFSET = 6;
  11167. var OUTLINE_STYLE = styles.cls('djs-outline', [ 'no-fill' ]);
  11168. function createOutline(gfx, bounds) {
  11169. return gfx.rect(10, 10, 0, 0).attr(OUTLINE_STYLE);
  11170. }
  11171. function updateShapeOutline(outline, bounds) {
  11172. outline.attr({
  11173. x: -OUTLINE_OFFSET,
  11174. y: -OUTLINE_OFFSET,
  11175. width: bounds.width + OUTLINE_OFFSET * 2,
  11176. height: bounds.height + OUTLINE_OFFSET * 2
  11177. });
  11178. }
  11179. function updateConnectionOutline(outline, connection) {
  11180. var bbox = getBBox(connection);
  11181. outline.attr({
  11182. x: bbox.x - OUTLINE_OFFSET,
  11183. y: bbox.y - OUTLINE_OFFSET,
  11184. width: bbox.width + OUTLINE_OFFSET * 2,
  11185. height: bbox.height + OUTLINE_OFFSET * 2
  11186. });
  11187. }
  11188. eventBus.on([ 'shape.added', 'shape.changed' ], function(event) {
  11189. var element = event.element,
  11190. gfx = event.gfx;
  11191. var outline = gfx.select('.djs-outline');
  11192. if (!outline) {
  11193. outline = createOutline(gfx, element);
  11194. }
  11195. updateShapeOutline(outline, element);
  11196. });
  11197. eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
  11198. var element = event.element,
  11199. gfx = event.gfx;
  11200. var outline = gfx.select('.djs-outline');
  11201. if (!outline) {
  11202. outline = createOutline(gfx, element);
  11203. }
  11204. updateConnectionOutline(outline, element);
  11205. });
  11206. }
  11207. Outline.$inject = ['eventBus', 'styles', 'elementRegistry'];
  11208. module.exports = Outline;
  11209. },{"66":66}],50:[function(_dereq_,module,exports){
  11210. 'use strict';
  11211. module.exports = {
  11212. __init__: [ 'outline' ],
  11213. outline: [ 'type', _dereq_(49) ]
  11214. };
  11215. },{"49":49}],51:[function(_dereq_,module,exports){
  11216. 'use strict';
  11217. var isArray = _dereq_(168),
  11218. isString = _dereq_(174),
  11219. isObject = _dereq_(172),
  11220. assign = _dereq_(177),
  11221. forEach = _dereq_(86),
  11222. filter = _dereq_(84),
  11223. debounce = _dereq_(93);
  11224. var domify = _dereq_(190),
  11225. domClasses = _dereq_(187),
  11226. domRemove = _dereq_(193);
  11227. var getBBox = _dereq_(66).getBBox;
  11228. // document wide unique overlay ids
  11229. var ids = new (_dereq_(69))('ov');
  11230. function createRoot(parent) {
  11231. var root = domify('<div class="djs-overlay-container" style="position: absolute; width: 0; height: 0;" />');
  11232. parent.insertBefore(root, parent.firstChild);
  11233. return root;
  11234. }
  11235. function setPosition(el, x, y) {
  11236. assign(el.style, { left: x + 'px', top: y + 'px' });
  11237. }
  11238. function setVisible(el, visible) {
  11239. el.style.display = visible === false ? 'none' : '';
  11240. }
  11241. /**
  11242. * A service that allows users to attach overlays to diagram elements.
  11243. *
  11244. * The overlay service will take care of overlay positioning during updates.
  11245. *
  11246. * @example
  11247. *
  11248. * // add a pink badge on the top left of the shape
  11249. * overlays.add(someShape, {
  11250. * position: {
  11251. * top: -5,
  11252. * left: -5
  11253. * },
  11254. * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
  11255. * });
  11256. *
  11257. * // or add via shape id
  11258. *
  11259. * overlays.add('some-element-id', {
  11260. * position: {
  11261. * top: -5,
  11262. * left: -5
  11263. * }
  11264. * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
  11265. * });
  11266. *
  11267. * // or add with optional type
  11268. *
  11269. * overlays.add(someShape, 'badge', {
  11270. * position: {
  11271. * top: -5,
  11272. * left: -5
  11273. * }
  11274. * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
  11275. * });
  11276. *
  11277. *
  11278. * // remove an overlay
  11279. *
  11280. * var id = overlays.add(...);
  11281. * overlays.remove(id);
  11282. *
  11283. * @param {EventBus} eventBus
  11284. * @param {Canvas} canvas
  11285. * @param {ElementRegistry} elementRegistry
  11286. */
  11287. function Overlays(config, eventBus, canvas, elementRegistry) {
  11288. this._eventBus = eventBus;
  11289. this._canvas = canvas;
  11290. this._elementRegistry = elementRegistry;
  11291. this._ids = ids;
  11292. this._overlayDefaults = {
  11293. show: {
  11294. minZoom: 0.7,
  11295. maxZoom: 5.0
  11296. }
  11297. };
  11298. /**
  11299. * Mapping overlayId -> overlay
  11300. */
  11301. this._overlays = {};
  11302. /**
  11303. * Mapping elementId -> overlay container
  11304. */
  11305. this._overlayContainers = {};
  11306. // root html element for all overlays
  11307. this._overlayRoot = createRoot(canvas.getContainer());
  11308. this._init(config);
  11309. }
  11310. Overlays.$inject = [ 'config.overlays', 'eventBus', 'canvas', 'elementRegistry' ];
  11311. module.exports = Overlays;
  11312. /**
  11313. * Returns the overlay with the specified id or a list of overlays
  11314. * for an element with a given type.
  11315. *
  11316. * @example
  11317. *
  11318. * // return the single overlay with the given id
  11319. * overlays.get('some-id');
  11320. *
  11321. * // return all overlays for the shape
  11322. * overlays.get({ element: someShape });
  11323. *
  11324. * // return all overlays on shape with type 'badge'
  11325. * overlays.get({ element: someShape, type: 'badge' });
  11326. *
  11327. * // shape can also be specified as id
  11328. * overlays.get({ element: 'element-id', type: 'badge' });
  11329. *
  11330. *
  11331. * @param {Object} search
  11332. * @param {String} [search.id]
  11333. * @param {String|djs.model.Base} [search.element]
  11334. * @param {String} [search.type]
  11335. *
  11336. * @return {Object|Array<Object>} the overlay(s)
  11337. */
  11338. Overlays.prototype.get = function(search) {
  11339. if (isString(search)) {
  11340. search = { id: search };
  11341. }
  11342. if (search.element) {
  11343. var container = this._getOverlayContainer(search.element, true);
  11344. // return a list of overlays when searching by element (+type)
  11345. if (container) {
  11346. return search.type ? filter(container.overlays, { type: search.type }) : container.overlays.slice();
  11347. } else {
  11348. return [];
  11349. }
  11350. } else
  11351. if (search.type) {
  11352. return filter(this._overlays, { type: search.type });
  11353. } else {
  11354. // return single element when searching by id
  11355. return search.id ? this._overlays[search.id] : null;
  11356. }
  11357. };
  11358. /**
  11359. * Adds a HTML overlay to an element.
  11360. *
  11361. * @param {String|djs.model.Base} element attach overlay to this shape
  11362. * @param {String} [type] optional type to assign to the overlay
  11363. * @param {Object} overlay the overlay configuration
  11364. *
  11365. * @param {String|DOMElement} overlay.html html element to use as an overlay
  11366. * @param {Object} [overlay.show] show configuration
  11367. * @param {Number} [overlay.show.minZoom] minimal zoom level to show the overlay
  11368. * @param {Number} [overlay.show.maxZoom] maximum zoom level to show the overlay
  11369. * @param {Object} overlay.position where to attach the overlay
  11370. * @param {Number} [overlay.position.left] relative to element bbox left attachment
  11371. * @param {Number} [overlay.position.top] relative to element bbox top attachment
  11372. * @param {Number} [overlay.position.bottom] relative to element bbox bottom attachment
  11373. * @param {Number} [overlay.position.right] relative to element bbox right attachment
  11374. *
  11375. * @return {String} id that may be used to reference the overlay for update or removal
  11376. */
  11377. Overlays.prototype.add = function(element, type, overlay) {
  11378. if (isObject(type)) {
  11379. overlay = type;
  11380. type = null;
  11381. }
  11382. if (!element.id) {
  11383. element = this._elementRegistry.get(element);
  11384. }
  11385. if (!overlay.position) {
  11386. throw new Error('must specifiy overlay position');
  11387. }
  11388. if (!overlay.html) {
  11389. throw new Error('must specifiy overlay html');
  11390. }
  11391. if (!element) {
  11392. throw new Error('invalid element specified');
  11393. }
  11394. var id = this._ids.next();
  11395. overlay = assign({}, this._overlayDefaults, overlay, {
  11396. id: id,
  11397. type: type,
  11398. element: element,
  11399. html: overlay.html
  11400. });
  11401. this._addOverlay(overlay);
  11402. return id;
  11403. };
  11404. /**
  11405. * Remove an overlay with the given id or all overlays matching the given filter.
  11406. *
  11407. * @see Overlays#get for filter options.
  11408. *
  11409. * @param {String} [id]
  11410. * @param {Object} [filter]
  11411. */
  11412. Overlays.prototype.remove = function(filter) {
  11413. var overlays = this.get(filter) || [];
  11414. if (!isArray(overlays)) {
  11415. overlays = [ overlays ];
  11416. }
  11417. var self = this;
  11418. forEach(overlays, function(overlay) {
  11419. var container = self._getOverlayContainer(overlay.element, true);
  11420. if (overlay) {
  11421. domRemove(overlay.html);
  11422. domRemove(overlay.htmlContainer);
  11423. delete overlay.htmlContainer;
  11424. delete overlay.element;
  11425. delete self._overlays[overlay.id];
  11426. }
  11427. if (container) {
  11428. var idx = container.overlays.indexOf(overlay);
  11429. if (idx !== -1) {
  11430. container.overlays.splice(idx, 1);
  11431. }
  11432. }
  11433. });
  11434. };
  11435. Overlays.prototype.show = function() {
  11436. setVisible(this._overlayRoot);
  11437. };
  11438. Overlays.prototype.hide = function() {
  11439. setVisible(this._overlayRoot, false);
  11440. };
  11441. Overlays.prototype._updateOverlayContainer = function(container) {
  11442. var element = container.element,
  11443. html = container.html;
  11444. // update container left,top according to the elements x,y coordinates
  11445. // this ensures we can attach child elements relative to this container
  11446. var x = element.x,
  11447. y = element.y;
  11448. if (element.waypoints) {
  11449. var bbox = getBBox(element);
  11450. x = bbox.x;
  11451. y = bbox.y;
  11452. }
  11453. setPosition(html, x, y);
  11454. };
  11455. Overlays.prototype._updateOverlay = function(overlay) {
  11456. var position = overlay.position,
  11457. htmlContainer = overlay.htmlContainer,
  11458. element = overlay.element;
  11459. // update overlay html relative to shape because
  11460. // it is already positioned on the element
  11461. // update relative
  11462. var left = position.left,
  11463. top = position.top;
  11464. if (position.right !== undefined) {
  11465. var width;
  11466. if (element.waypoints) {
  11467. width = getBBox(element).width;
  11468. } else {
  11469. width = element.width;
  11470. }
  11471. left = position.right * -1 + width;
  11472. }
  11473. if (position.bottom !== undefined) {
  11474. var height;
  11475. if (element.waypoints) {
  11476. height = getBBox(element).height;
  11477. } else {
  11478. height = element.height;
  11479. }
  11480. top = position.bottom * -1 + height;
  11481. }
  11482. setPosition(htmlContainer, left || 0, top || 0);
  11483. };
  11484. Overlays.prototype._createOverlayContainer = function(element) {
  11485. var html = domify('<div class="djs-overlays djs-overlays-' + element.id + '" style="position: absolute" />');
  11486. this._overlayRoot.appendChild(html);
  11487. var container = {
  11488. html: html,
  11489. element: element,
  11490. overlays: []
  11491. };
  11492. this._updateOverlayContainer(container);
  11493. return container;
  11494. };
  11495. Overlays.prototype._updateRoot = function(viewbox) {
  11496. var a = viewbox.scale || 1;
  11497. var d = viewbox.scale || 1;
  11498. var matrix = 'matrix(' + a + ',0,0,' + d + ',' + (-1 * viewbox.x * a) + ',' + (-1 * viewbox.y * d) + ')';
  11499. this._overlayRoot.style.transform = matrix;
  11500. this._overlayRoot.style['-ms-transform'] = matrix;
  11501. };
  11502. Overlays.prototype._getOverlayContainer = function(element, raw) {
  11503. var id = (element && element.id) || element;
  11504. var container = this._overlayContainers[id];
  11505. if (!container && !raw) {
  11506. container = this._overlayContainers[id] = this._createOverlayContainer(element);
  11507. }
  11508. return container;
  11509. };
  11510. Overlays.prototype._addOverlay = function(overlay) {
  11511. var id = overlay.id,
  11512. element = overlay.element,
  11513. html = overlay.html,
  11514. htmlContainer,
  11515. overlayContainer;
  11516. // unwrap jquery (for those who need it)
  11517. if (html.get) {
  11518. html = html.get(0);
  11519. }
  11520. // create proper html elements from
  11521. // overlay HTML strings
  11522. if (isString(html)) {
  11523. html = domify(html);
  11524. }
  11525. overlayContainer = this._getOverlayContainer(element);
  11526. htmlContainer = domify('<div class="djs-overlay" data-overlay-id="' + id + '" style="position: absolute">');
  11527. htmlContainer.appendChild(html);
  11528. if (overlay.type) {
  11529. domClasses(htmlContainer).add('djs-overlay-' + overlay.type);
  11530. }
  11531. overlay.htmlContainer = htmlContainer;
  11532. overlayContainer.overlays.push(overlay);
  11533. overlayContainer.html.appendChild(htmlContainer);
  11534. this._overlays[id] = overlay;
  11535. this._updateOverlay(overlay);
  11536. };
  11537. Overlays.prototype._updateOverlayVisibilty = function(viewbox) {
  11538. forEach(this._overlays, function(overlay) {
  11539. var show = overlay.show,
  11540. htmlContainer = overlay.htmlContainer,
  11541. visible = true;
  11542. if (show) {
  11543. if (show.minZoom > viewbox.scale ||
  11544. show.maxZoom < viewbox.scale) {
  11545. visible = false;
  11546. }
  11547. setVisible(htmlContainer, visible);
  11548. }
  11549. });
  11550. };
  11551. Overlays.prototype._init = function(config) {
  11552. var eventBus = this._eventBus;
  11553. var self = this;
  11554. // scroll/zoom integration
  11555. var updateViewbox = function(viewbox) {
  11556. self._updateRoot(viewbox);
  11557. self._updateOverlayVisibilty(viewbox);
  11558. self.show();
  11559. };
  11560. if (!config || config.deferUpdate !== false) {
  11561. updateViewbox = debounce(updateViewbox, 300);
  11562. }
  11563. eventBus.on('canvas.viewbox.changed', function(event) {
  11564. self.hide();
  11565. updateViewbox(event.viewbox);
  11566. });
  11567. // remove integration
  11568. eventBus.on([ 'shape.remove', 'connection.remove' ], function(e) {
  11569. var overlays = self.get({ element: e.element });
  11570. forEach(overlays, function(o) {
  11571. self.remove(o.id);
  11572. });
  11573. });
  11574. // move integration
  11575. eventBus.on([
  11576. 'element.changed'
  11577. ], function(e) {
  11578. var element = e.element;
  11579. var container = self._getOverlayContainer(element, true);
  11580. if (container) {
  11581. forEach(container.overlays, function(overlay) {
  11582. self._updateOverlay(overlay);
  11583. });
  11584. self._updateOverlayContainer(container);
  11585. }
  11586. });
  11587. // marker integration, simply add them on the overlays as classes, too.
  11588. eventBus.on('element.marker.update', function(e) {
  11589. var container = self._getOverlayContainer(e.element, true);
  11590. if (container) {
  11591. domClasses(container.html)[e.add ? 'add' : 'remove'](e.marker);
  11592. }
  11593. });
  11594. };
  11595. },{"168":168,"172":172,"174":174,"177":177,"187":187,"190":190,"193":193,"66":66,"69":69,"84":84,"86":86,"93":93}],52:[function(_dereq_,module,exports){
  11596. module.exports = {
  11597. __init__: [ 'overlays' ],
  11598. overlays: [ 'type', _dereq_(51) ]
  11599. };
  11600. },{"51":51}],53:[function(_dereq_,module,exports){
  11601. 'use strict';
  11602. var isArray = _dereq_(168),
  11603. forEach = _dereq_(86);
  11604. /**
  11605. * A service that offers the current selection in a diagram.
  11606. * Offers the api to control the selection, too.
  11607. *
  11608. * @class
  11609. *
  11610. * @param {EventBus} eventBus the event bus
  11611. */
  11612. function Selection(eventBus) {
  11613. this._eventBus = eventBus;
  11614. this._selectedElements = [];
  11615. var self = this;
  11616. eventBus.on([ 'shape.remove', 'connection.remove' ], function(e) {
  11617. var element = e.element;
  11618. self.deselect(element);
  11619. });
  11620. }
  11621. Selection.$inject = [ 'eventBus' ];
  11622. module.exports = Selection;
  11623. Selection.prototype.deselect = function(element) {
  11624. var selectedElements = this._selectedElements;
  11625. var idx = selectedElements.indexOf(element);
  11626. if (idx !== -1) {
  11627. var oldSelection = selectedElements.slice();
  11628. selectedElements.splice(idx, 1);
  11629. this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
  11630. }
  11631. };
  11632. Selection.prototype.get = function() {
  11633. return this._selectedElements;
  11634. };
  11635. Selection.prototype.isSelected = function(element) {
  11636. return this._selectedElements.indexOf(element) !== -1;
  11637. };
  11638. /**
  11639. * This method selects one or more elements on the diagram.
  11640. *
  11641. * By passing an additional add parameter you can decide whether or not the element(s)
  11642. * should be added to the already existing selection or not.
  11643. *
  11644. * @method Selection#select
  11645. *
  11646. * @param {Object|Object[]} elements element or array of elements to be selected
  11647. * @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
  11648. */
  11649. Selection.prototype.select = function(elements, add) {
  11650. var selectedElements = this._selectedElements,
  11651. oldSelection = selectedElements.slice();
  11652. if (!isArray(elements)) {
  11653. elements = elements ? [ elements ] : [];
  11654. }
  11655. // selection may be cleared by passing an empty array or null
  11656. // to the method
  11657. if (add) {
  11658. forEach(elements, function(element) {
  11659. if (selectedElements.indexOf(element) !== -1) {
  11660. // already selected
  11661. return;
  11662. } else {
  11663. selectedElements.push(element);
  11664. }
  11665. });
  11666. } else {
  11667. this._selectedElements = selectedElements = elements.slice();
  11668. }
  11669. this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
  11670. };
  11671. },{"168":168,"86":86}],54:[function(_dereq_,module,exports){
  11672. 'use strict';
  11673. var hasPrimaryModifier = _dereq_(71).hasPrimaryModifier;
  11674. function SelectionBehavior(eventBus, selection, canvas) {
  11675. eventBus.on('create.end', 500, function(e) {
  11676. // select the created shape after a
  11677. // successful create operation
  11678. if (e.context.canExecute) {
  11679. selection.select(e.context.shape);
  11680. }
  11681. });
  11682. eventBus.on('connect.end', 500, function(e) {
  11683. // select the connect end target
  11684. // after a connect operation
  11685. if (e.context.canExecute && e.context.target) {
  11686. selection.select(e.context.target);
  11687. }
  11688. });
  11689. eventBus.on('shape.move.end', 500, function(e) {
  11690. var previousSelection = e.previousSelection || [];
  11691. var shape = e.context.shape;
  11692. // make sure at least the main moved element is being
  11693. // selected after a move operation
  11694. if (previousSelection.indexOf(shape) === -1) {
  11695. selection.select(shape);
  11696. }
  11697. });
  11698. // Shift + click selection
  11699. eventBus.on('element.click', function(event) {
  11700. var element = event.element;
  11701. // do not select the root element
  11702. // or connections
  11703. if (element === canvas.getRootElement()) {
  11704. element = null;
  11705. }
  11706. var isSelected = selection.isSelected(element),
  11707. isMultiSelect = selection.get().length > 1;
  11708. // mouse-event: SELECTION_KEY
  11709. var add = hasPrimaryModifier(event);
  11710. // select OR deselect element in multi selection
  11711. if (isSelected && isMultiSelect) {
  11712. if (add) {
  11713. return selection.deselect(element);
  11714. } else {
  11715. return selection.select(element);
  11716. }
  11717. } else
  11718. if (!isSelected) {
  11719. selection.select(element, add);
  11720. } else {
  11721. selection.deselect(element);
  11722. }
  11723. });
  11724. }
  11725. SelectionBehavior.$inject = [ 'eventBus', 'selection', 'canvas' ];
  11726. module.exports = SelectionBehavior;
  11727. },{"71":71}],55:[function(_dereq_,module,exports){
  11728. 'use strict';
  11729. var forEach = _dereq_(86);
  11730. var MARKER_HOVER = 'hover',
  11731. MARKER_SELECTED = 'selected';
  11732. /**
  11733. * A plugin that adds a visible selection UI to shapes and connections
  11734. * by appending the <code>hover</code> and <code>selected</code> classes to them.
  11735. *
  11736. * @class
  11737. *
  11738. * Makes elements selectable, too.
  11739. *
  11740. * @param {EventBus} events
  11741. * @param {SelectionService} selection
  11742. * @param {Canvas} canvas
  11743. */
  11744. function SelectionVisuals(events, canvas, selection, graphicsFactory, styles) {
  11745. this._multiSelectionBox = null;
  11746. function addMarker(e, cls) {
  11747. canvas.addMarker(e, cls);
  11748. }
  11749. function removeMarker(e, cls) {
  11750. canvas.removeMarker(e, cls);
  11751. }
  11752. events.on('element.hover', function(event) {
  11753. addMarker(event.element, MARKER_HOVER);
  11754. });
  11755. events.on('element.out', function(event) {
  11756. removeMarker(event.element, MARKER_HOVER);
  11757. });
  11758. events.on('selection.changed', function(event) {
  11759. function deselect(s) {
  11760. removeMarker(s, MARKER_SELECTED);
  11761. }
  11762. function select(s) {
  11763. addMarker(s, MARKER_SELECTED);
  11764. }
  11765. var oldSelection = event.oldSelection,
  11766. newSelection = event.newSelection;
  11767. forEach(oldSelection, function(e) {
  11768. if (newSelection.indexOf(e) === -1) {
  11769. deselect(e);
  11770. }
  11771. });
  11772. forEach(newSelection, function(e) {
  11773. if (oldSelection.indexOf(e) === -1) {
  11774. select(e);
  11775. }
  11776. });
  11777. });
  11778. }
  11779. SelectionVisuals.$inject = [
  11780. 'eventBus',
  11781. 'canvas',
  11782. 'selection',
  11783. 'graphicsFactory',
  11784. 'styles'
  11785. ];
  11786. module.exports = SelectionVisuals;
  11787. },{"86":86}],56:[function(_dereq_,module,exports){
  11788. module.exports = {
  11789. __init__: [ 'selectionVisuals', 'selectionBehavior' ],
  11790. __depends__: [
  11791. _dereq_(48),
  11792. _dereq_(50)
  11793. ],
  11794. selection: [ 'type', _dereq_(53) ],
  11795. selectionVisuals: [ 'type', _dereq_(55) ],
  11796. selectionBehavior: [ 'type', _dereq_(54) ]
  11797. };
  11798. },{"48":48,"50":50,"53":53,"54":54,"55":55}],57:[function(_dereq_,module,exports){
  11799. 'use strict';
  11800. var assign = _dereq_(177),
  11801. inherits = _dereq_(81);
  11802. var Refs = _dereq_(202);
  11803. var parentRefs = new Refs({ name: 'children', enumerable: true, collection: true }, { name: 'parent' }),
  11804. labelRefs = new Refs({ name: 'label', enumerable: true }, { name: 'labelTarget' }),
  11805. attacherRefs = new Refs({ name: 'attachers', collection: true }, { name: 'host' }),
  11806. outgoingRefs = new Refs({ name: 'outgoing', collection: true }, { name: 'source' }),
  11807. incomingRefs = new Refs({ name: 'incoming', collection: true }, { name: 'target' });
  11808. /**
  11809. * @namespace djs.model
  11810. */
  11811. /**
  11812. * @memberOf djs.model
  11813. */
  11814. /**
  11815. * The basic graphical representation
  11816. *
  11817. * @class
  11818. *
  11819. * @abstract
  11820. */
  11821. function Base() {
  11822. /**
  11823. * The object that backs up the shape
  11824. *
  11825. * @name Base#businessObject
  11826. * @type Object
  11827. */
  11828. Object.defineProperty(this, 'businessObject', {
  11829. writable: true
  11830. });
  11831. /**
  11832. * The parent shape
  11833. *
  11834. * @name Base#parent
  11835. * @type Shape
  11836. */
  11837. parentRefs.bind(this, 'parent');
  11838. /**
  11839. * @name Base#label
  11840. * @type Label
  11841. */
  11842. labelRefs.bind(this, 'label');
  11843. /**
  11844. * The list of outgoing connections
  11845. *
  11846. * @name Base#outgoing
  11847. * @type Array<Connection>
  11848. */
  11849. outgoingRefs.bind(this, 'outgoing');
  11850. /**
  11851. * The list of outgoing connections
  11852. *
  11853. * @name Base#incoming
  11854. * @type Array<Connection>
  11855. */
  11856. incomingRefs.bind(this, 'incoming');
  11857. }
  11858. /**
  11859. * A graphical object
  11860. *
  11861. * @class
  11862. * @constructor
  11863. *
  11864. * @extends Base
  11865. */
  11866. function Shape() {
  11867. Base.call(this);
  11868. /**
  11869. * The list of children
  11870. *
  11871. * @name Shape#children
  11872. * @type Array<Base>
  11873. */
  11874. parentRefs.bind(this, 'children');
  11875. /**
  11876. * @name Shape#host
  11877. * @type Shape
  11878. */
  11879. attacherRefs.bind(this, 'host');
  11880. /**
  11881. * @name Shape#attachers
  11882. * @type Shape
  11883. */
  11884. attacherRefs.bind(this, 'attachers');
  11885. }
  11886. inherits(Shape, Base);
  11887. /**
  11888. * A root graphical object
  11889. *
  11890. * @class
  11891. * @constructor
  11892. *
  11893. * @extends Shape
  11894. */
  11895. function Root() {
  11896. Shape.call(this);
  11897. }
  11898. inherits(Root, Shape);
  11899. /**
  11900. * A label for an element
  11901. *
  11902. * @class
  11903. * @constructor
  11904. *
  11905. * @extends Shape
  11906. */
  11907. function Label() {
  11908. Shape.call(this);
  11909. /**
  11910. * The labeled element
  11911. *
  11912. * @name Label#labelTarget
  11913. * @type Base
  11914. */
  11915. labelRefs.bind(this, 'labelTarget');
  11916. }
  11917. inherits(Label, Shape);
  11918. /**
  11919. * A connection between two elements
  11920. *
  11921. * @class
  11922. * @constructor
  11923. *
  11924. * @extends Base
  11925. */
  11926. function Connection() {
  11927. Base.call(this);
  11928. /**
  11929. * The element this connection originates from
  11930. *
  11931. * @name Connection#source
  11932. * @type Base
  11933. */
  11934. outgoingRefs.bind(this, 'source');
  11935. /**
  11936. * The element this connection points to
  11937. *
  11938. * @name Connection#target
  11939. * @type Base
  11940. */
  11941. incomingRefs.bind(this, 'target');
  11942. }
  11943. inherits(Connection, Base);
  11944. var types = {
  11945. connection: Connection,
  11946. shape: Shape,
  11947. label: Label,
  11948. root: Root
  11949. };
  11950. /**
  11951. * Creates a new model element of the specified type
  11952. *
  11953. * @method create
  11954. *
  11955. * @example
  11956. *
  11957. * var shape1 = Model.create('shape', { x: 10, y: 10, width: 100, height: 100 });
  11958. * var shape2 = Model.create('shape', { x: 210, y: 210, width: 100, height: 100 });
  11959. *
  11960. * var connection = Model.create('connection', { waypoints: [ { x: 110, y: 55 }, {x: 210, y: 55 } ] });
  11961. *
  11962. * @param {String} type lower-cased model name
  11963. * @param {Object} attrs attributes to initialize the new model instance with
  11964. *
  11965. * @return {Base} the new model instance
  11966. */
  11967. module.exports.create = function(type, attrs) {
  11968. var Type = types[type];
  11969. if (!Type) {
  11970. throw new Error('unknown type: <' + type + '>');
  11971. }
  11972. return assign(new Type(), attrs);
  11973. };
  11974. module.exports.Base = Base;
  11975. module.exports.Root = Root;
  11976. module.exports.Shape = Shape;
  11977. module.exports.Connection = Connection;
  11978. module.exports.Label = Label;
  11979. },{"177":177,"202":202,"81":81}],58:[function(_dereq_,module,exports){
  11980. 'use strict';
  11981. var Cursor = _dereq_(65),
  11982. ClickTrap = _dereq_(63),
  11983. domEvent = _dereq_(191),
  11984. Event = _dereq_(67);
  11985. function substract(p1, p2) {
  11986. return {
  11987. x: p1.x - p2.x,
  11988. y: p1.y - p2.y
  11989. };
  11990. }
  11991. function length(point) {
  11992. return Math.sqrt(Math.pow(point.x, 2) + Math.pow(point.y, 2));
  11993. }
  11994. var THRESHOLD = 15;
  11995. function MoveCanvas(eventBus, canvas) {
  11996. var container = canvas._container,
  11997. context;
  11998. function handleMove(event) {
  11999. var start = context.start,
  12000. position = Event.toPoint(event),
  12001. delta = substract(position, start);
  12002. if (!context.dragging && length(delta) > THRESHOLD) {
  12003. context.dragging = true;
  12004. // prevent mouse click in this
  12005. // interaction sequence
  12006. ClickTrap.install();
  12007. Cursor.set('move');
  12008. }
  12009. if (context.dragging) {
  12010. var lastPosition = context.last || context.start;
  12011. delta = substract(position, lastPosition);
  12012. canvas.scroll({
  12013. dx: delta.x,
  12014. dy: delta.y
  12015. });
  12016. context.last = position;
  12017. }
  12018. // prevent select
  12019. event.preventDefault();
  12020. }
  12021. function handleEnd(event) {
  12022. domEvent.unbind(document, 'mousemove', handleMove);
  12023. domEvent.unbind(document, 'mouseup', handleEnd);
  12024. context = null;
  12025. Cursor.unset();
  12026. // prevent select
  12027. Event.stopEvent(event);
  12028. }
  12029. function handleStart(event) {
  12030. // reject non-left left mouse button or modifier key
  12031. if (event.button || event.ctrlKey || event.shiftKey || event.altKey) {
  12032. return;
  12033. }
  12034. context = {
  12035. start: Event.toPoint(event)
  12036. };
  12037. domEvent.bind(document, 'mousemove', handleMove);
  12038. domEvent.bind(document, 'mouseup', handleEnd);
  12039. // prevent select
  12040. Event.stopEvent(event);
  12041. }
  12042. domEvent.bind(container, 'mousedown', handleStart);
  12043. }
  12044. MoveCanvas.$inject = [ 'eventBus', 'canvas' ];
  12045. module.exports = MoveCanvas;
  12046. },{"191":191,"63":63,"65":65,"67":67}],59:[function(_dereq_,module,exports){
  12047. module.exports = {
  12048. __init__: [ 'moveCanvas' ],
  12049. moveCanvas: [ 'type', _dereq_(58) ]
  12050. };
  12051. },{"58":58}],60:[function(_dereq_,module,exports){
  12052. 'use strict';
  12053. var domEvent = _dereq_(191);
  12054. var hasPrimaryModifier = _dereq_(71).hasPrimaryModifier,
  12055. hasSecondaryModifier = _dereq_(71).hasSecondaryModifier;
  12056. var isMac = _dereq_(72).isMac;
  12057. var getStepRange = _dereq_(61).getStepRange,
  12058. cap = _dereq_(61).cap;
  12059. var log10 = _dereq_(70).log10;
  12060. var RANGE = { min: 0.2, max: 4 },
  12061. NUM_STEPS = 10;
  12062. /**
  12063. * An implementation of zooming and scrolling within the {@link Canvas}.
  12064. *
  12065. * @param {EventBus} eventBus
  12066. * @param {Canvas} canvas
  12067. */
  12068. function ZoomScroll(eventBus, canvas) {
  12069. this._canvas = canvas;
  12070. var self = this;
  12071. eventBus.on('canvas.init', function(e) {
  12072. self._init(canvas._container);
  12073. });
  12074. }
  12075. ZoomScroll.prototype.scroll = function scroll(delta) {
  12076. this._canvas.scroll(delta);
  12077. };
  12078. ZoomScroll.prototype.reset = function reset() {
  12079. this._canvas.zoom('fit-viewport');
  12080. };
  12081. ZoomScroll.prototype.zoom = function zoom(direction, position) {
  12082. var canvas = this._canvas;
  12083. var currentZoom = canvas.zoom();
  12084. var factor = Math.pow(1 + Math.abs(direction) , direction > 0 ? 1 : -1);
  12085. canvas.zoom(cap(RANGE, currentZoom * factor), position);
  12086. };
  12087. /**
  12088. * Zoom along fixed zoom steps
  12089. *
  12090. * @param {Integer} direction zoom direction (1 for zooming in, -1 for out)
  12091. */
  12092. ZoomScroll.prototype.stepZoom = function stepZoom(direction, position) {
  12093. var canvas = this._canvas,
  12094. stepRange = getStepRange(RANGE, NUM_STEPS);
  12095. direction = direction > 0 ? 1 : -1;
  12096. var currentLinearZoomLevel = log10(canvas.zoom());
  12097. // snap to a proximate zoom step
  12098. var newLinearZoomLevel = Math.round(currentLinearZoomLevel / stepRange) * stepRange;
  12099. // increase or decrease one zoom step in the given direction
  12100. newLinearZoomLevel += stepRange * direction;
  12101. // calculate the absolute logarithmic zoom level based on the linear zoom level
  12102. // (e.g. 2 for an absolute x2 zoom)
  12103. var newLogZoomLevel = Math.pow(10, newLinearZoomLevel);
  12104. canvas.zoom(cap(RANGE, newLogZoomLevel), position);
  12105. };
  12106. ZoomScroll.prototype._init = function(element) {
  12107. var self = this;
  12108. domEvent.bind(element, 'wheel', function(event) {
  12109. event.preventDefault();
  12110. // mouse-event: SELECTION_KEY
  12111. // mouse-event: AND_KEY
  12112. var isVerticalScroll = hasPrimaryModifier(event),
  12113. isHorizontalScroll = hasSecondaryModifier(event);
  12114. var factor;
  12115. if (isVerticalScroll || isHorizontalScroll) {
  12116. if (isMac) {
  12117. factor = event.deltaMode === 0 ? 1.25 : 50;
  12118. } else {
  12119. factor = event.deltaMode === 0 ? 1/40 : 1/2;
  12120. }
  12121. var delta = {};
  12122. if (isHorizontalScroll) {
  12123. delta.dx = (factor * (event.deltaX || event.deltaY));
  12124. } else {
  12125. delta.dy = (factor * event.deltaY);
  12126. }
  12127. self.scroll(delta);
  12128. } else {
  12129. factor = (event.deltaMode === 0 ? 1/40 : 1/2);
  12130. var elementRect = element.getBoundingClientRect();
  12131. var offset = {
  12132. x: event.clientX - elementRect.left,
  12133. y: event.clientY - elementRect.top
  12134. };
  12135. // zoom in relative to diagram {x,y} coordinates
  12136. self.zoom(event.deltaY * factor / (-5), offset);
  12137. }
  12138. });
  12139. };
  12140. ZoomScroll.$inject = [ 'eventBus', 'canvas' ];
  12141. module.exports = ZoomScroll;
  12142. },{"191":191,"61":61,"70":70,"71":71,"72":72}],61:[function(_dereq_,module,exports){
  12143. 'use strict';
  12144. var log10 = _dereq_(70).log10;
  12145. /**
  12146. * Get the linear range between two zoom steps based on the
  12147. * total number of zoom steps (defined as NUM_STEPS)
  12148. */
  12149. module.exports.getStepRange = function(range, steps) {
  12150. var minLinearRange = log10(range.min),
  12151. maxLinearRange = log10(range.max);
  12152. var absoluteLinearRange = Math.abs(minLinearRange) + Math.abs(maxLinearRange);
  12153. return absoluteLinearRange / steps;
  12154. };
  12155. module.exports.cap = function(range, scale) {
  12156. return Math.max(range.min, Math.min(range.max, scale));
  12157. };
  12158. },{"70":70}],62:[function(_dereq_,module,exports){
  12159. module.exports = {
  12160. __init__: [ 'zoomScroll' ],
  12161. zoomScroll: [ 'type', _dereq_(60) ]
  12162. };
  12163. },{"60":60}],63:[function(_dereq_,module,exports){
  12164. 'use strict';
  12165. var domEvent = _dereq_(191),
  12166. stopEvent = _dereq_(67).stopEvent;
  12167. function trap(event) {
  12168. stopEvent(event);
  12169. toggle(false);
  12170. }
  12171. function toggle(active) {
  12172. domEvent[active ? 'bind' : 'unbind'](document.body, 'click', trap, true);
  12173. }
  12174. /**
  12175. * Installs a click trap that prevents a ghost click following a dragging operation.
  12176. *
  12177. * @return {Function} a function to immediately remove the installed trap.
  12178. */
  12179. function install() {
  12180. toggle(true);
  12181. return function() {
  12182. toggle(false);
  12183. };
  12184. }
  12185. module.exports.install = install;
  12186. },{"191":191,"67":67}],64:[function(_dereq_,module,exports){
  12187. 'use strict';
  12188. /**
  12189. * Failsafe remove an element from a collection
  12190. *
  12191. * @param {Array<Object>} [collection]
  12192. * @param {Object} [element]
  12193. *
  12194. * @return {Object} the element that got removed or undefined
  12195. */
  12196. module.exports.remove = function(collection, element) {
  12197. if (!collection || !element) {
  12198. return;
  12199. }
  12200. var idx = collection.indexOf(element);
  12201. if (idx === -1) {
  12202. return;
  12203. }
  12204. collection.splice(idx, 1);
  12205. return element;
  12206. };
  12207. /**
  12208. * Fail save add an element to the given connection, ensuring
  12209. * it does not yet exist.
  12210. *
  12211. * @param {Array<Object>} collection
  12212. * @param {Object} element
  12213. * @param {Number} idx
  12214. */
  12215. module.exports.add = function(collection, element, idx) {
  12216. if (!collection || !element) {
  12217. return;
  12218. }
  12219. if (isNaN(idx)) {
  12220. idx = -1;
  12221. }
  12222. var currentIdx = collection.indexOf(element);
  12223. if (currentIdx !== -1) {
  12224. if (currentIdx === idx) {
  12225. // nothing to do, position has not changed
  12226. return;
  12227. } else {
  12228. if (idx !== -1) {
  12229. // remove from current position
  12230. collection.splice(currentIdx, 1);
  12231. } else {
  12232. // already exists in collection
  12233. return;
  12234. }
  12235. }
  12236. }
  12237. if (idx !== -1) {
  12238. // insert at specified position
  12239. collection.splice(idx, 0, element);
  12240. } else {
  12241. // push to end
  12242. collection.push(element);
  12243. }
  12244. };
  12245. /**
  12246. * Fail get the index of an element in a collection.
  12247. *
  12248. * @param {Array<Object>} collection
  12249. * @param {Object} element
  12250. *
  12251. * @return {Number} the index or -1 if collection or element do
  12252. * not exist or the element is not contained.
  12253. */
  12254. module.exports.indexOf = function(collection, element) {
  12255. if (!collection || !element) {
  12256. return -1;
  12257. }
  12258. return collection.indexOf(element);
  12259. };
  12260. },{}],65:[function(_dereq_,module,exports){
  12261. 'use strict';
  12262. var domClasses = _dereq_(187);
  12263. var CURSOR_CLS_PATTERN = /^djs-cursor-.*$/;
  12264. module.exports.set = function(mode) {
  12265. var classes = domClasses(document.body);
  12266. classes.removeMatching(CURSOR_CLS_PATTERN);
  12267. if (mode) {
  12268. classes.add('djs-cursor-' + mode);
  12269. }
  12270. };
  12271. module.exports.unset = function() {
  12272. this.set(null);
  12273. };
  12274. },{"187":187}],66:[function(_dereq_,module,exports){
  12275. 'use strict';
  12276. var isArray = _dereq_(168),
  12277. isNumber = _dereq_(171),
  12278. groupBy = _dereq_(87),
  12279. forEach = _dereq_(86);
  12280. /**
  12281. * Adds an element to a collection and returns true if the
  12282. * element was added.
  12283. *
  12284. * @param {Array<Object>} elements
  12285. * @param {Object} e
  12286. * @param {Boolean} unique
  12287. */
  12288. function add(elements, e, unique) {
  12289. var canAdd = !unique || elements.indexOf(e) === -1;
  12290. if (canAdd) {
  12291. elements.push(e);
  12292. }
  12293. return canAdd;
  12294. }
  12295. function eachElement(elements, fn, depth) {
  12296. depth = depth || 0;
  12297. forEach(elements, function(s, i) {
  12298. var filter = fn(s, i, depth);
  12299. if (isArray(filter) && filter.length) {
  12300. eachElement(filter, fn, depth + 1);
  12301. }
  12302. });
  12303. }
  12304. /**
  12305. * Collects self + child elements up to a given depth from a list of elements.
  12306. *
  12307. * @param {Array<djs.model.Base>} elements the elements to select the children from
  12308. * @param {Boolean} unique whether to return a unique result set (no duplicates)
  12309. * @param {Number} maxDepth the depth to search through or -1 for infinite
  12310. *
  12311. * @return {Array<djs.model.Base>} found elements
  12312. */
  12313. function selfAndChildren(elements, unique, maxDepth) {
  12314. var result = [],
  12315. processedChildren = [];
  12316. eachElement(elements, function(element, i, depth) {
  12317. add(result, element, unique);
  12318. var children = element.children;
  12319. // max traversal depth not reached yet
  12320. if (maxDepth === -1 || depth < maxDepth) {
  12321. // children exist && children not yet processed
  12322. if (children && add(processedChildren, children, unique)) {
  12323. return children;
  12324. }
  12325. }
  12326. });
  12327. return result;
  12328. }
  12329. /**
  12330. * Return self + direct children for a number of elements
  12331. *
  12332. * @param {Array<djs.model.Base>} elements to query
  12333. * @param {Boolean} allowDuplicates to allow duplicates in the result set
  12334. *
  12335. * @return {Array<djs.model.Base>} the collected elements
  12336. */
  12337. function selfAndDirectChildren(elements, allowDuplicates) {
  12338. return selfAndChildren(elements, !allowDuplicates, 1);
  12339. }
  12340. /**
  12341. * Return self + ALL children for a number of elements
  12342. *
  12343. * @param {Array<djs.model.Base>} elements to query
  12344. * @param {Boolean} allowDuplicates to allow duplicates in the result set
  12345. *
  12346. * @return {Array<djs.model.Base>} the collected elements
  12347. */
  12348. function selfAndAllChildren(elements, allowDuplicates) {
  12349. return selfAndChildren(elements, !allowDuplicates, -1);
  12350. }
  12351. /**
  12352. * Gets the the closure fo all selected elements,
  12353. * their connections and
  12354. *
  12355. * @param {Array<djs.model.Base>} elements
  12356. * @return {Object} enclosure
  12357. */
  12358. function getClosure(elements) {
  12359. // original elements passed to this function
  12360. var topLevel = groupBy(elements, function(e) { return e.id; });
  12361. var allShapes = {},
  12362. allConnections = {},
  12363. enclosedElements = {},
  12364. enclosedConnections = {};
  12365. function handleConnection(c) {
  12366. if (topLevel[c.source.id] && topLevel[c.target.id]) {
  12367. topLevel[c.id] = c;
  12368. }
  12369. // not enclosed as a child, but maybe logically
  12370. // (connecting two moved elements?)
  12371. if (allShapes[c.source.id] && allShapes[c.target.id]) {
  12372. enclosedConnections[c.id] = enclosedElements[c.id] = c;
  12373. }
  12374. allConnections[c.id] = c;
  12375. }
  12376. function handleElement(element) {
  12377. enclosedElements[element.id] = element;
  12378. if (element.waypoints) {
  12379. // remember connection
  12380. enclosedConnections[element.id] = allConnections[element.id] = element;
  12381. } else {
  12382. // remember shape
  12383. allShapes[element.id] = element;
  12384. // remember all connections
  12385. forEach(element.incoming, handleConnection);
  12386. forEach(element.outgoing, handleConnection);
  12387. // recurse into children
  12388. return element.children;
  12389. }
  12390. }
  12391. eachElement(elements, handleElement);
  12392. return {
  12393. allShapes: allShapes,
  12394. allConnections: allConnections,
  12395. topLevel: topLevel,
  12396. enclosedConnections: enclosedConnections,
  12397. enclosedElements: enclosedElements
  12398. };
  12399. }
  12400. /**
  12401. * Returns the surrounding bbox for all elements in the array or the element primitive.
  12402. */
  12403. function getBBox(elements, stopRecursion) {
  12404. stopRecursion = !!stopRecursion;
  12405. if (!isArray(elements)) {
  12406. elements = [elements];
  12407. }
  12408. var minX,
  12409. minY,
  12410. maxX,
  12411. maxY;
  12412. forEach(elements, function(element) {
  12413. // If element is a connection the bbox must be computed first
  12414. var bbox = element;
  12415. if (element.waypoints && !stopRecursion) {
  12416. bbox = getBBox(element.waypoints, true);
  12417. }
  12418. var x = bbox.x,
  12419. y = bbox.y,
  12420. height = bbox.height || 0,
  12421. width = bbox.width || 0;
  12422. if (x < minX || minX === undefined) {
  12423. minX = x;
  12424. }
  12425. if (y < minY || minY === undefined) {
  12426. minY = y;
  12427. }
  12428. if ((x + width) > maxX || maxX === undefined) {
  12429. maxX = x + width;
  12430. }
  12431. if ((y + height) > maxY || maxY === undefined) {
  12432. maxY = y + height;
  12433. }
  12434. });
  12435. return {
  12436. x: minX,
  12437. y: minY,
  12438. height: maxY - minY,
  12439. width: maxX - minX
  12440. };
  12441. }
  12442. /**
  12443. * Returns all elements that are enclosed from the bounding box.
  12444. *
  12445. * @param {Array<Object>} elements List of Elements to search through
  12446. * @param {Object} bbox the enclosing bbox.
  12447. * <ul>
  12448. * <li>If bbox.(width|height) is not specified
  12449. * the method returns all elements with element.x/y &gt; bbox.x/y
  12450. * </li>
  12451. * <li>If only bbox.x or bbox.y is specified, method return all elements with
  12452. * e.x &gt; bbox.x or e.y &gt; bbox.y.</li>
  12453. * </ul>
  12454. *
  12455. */
  12456. function getEnclosedElements(elements, bbox) {
  12457. var filteredElements = {};
  12458. forEach(elements, function(element) {
  12459. var e = element;
  12460. if (e.waypoints) {
  12461. e = getBBox(e);
  12462. }
  12463. if (!isNumber(bbox.y) && (e.x > bbox.x)) {
  12464. filteredElements[element.id] = element;
  12465. }
  12466. if (!isNumber(bbox.x) && (e.y > bbox.y)) {
  12467. filteredElements[element.id] = element;
  12468. }
  12469. if (e.x > bbox.x && e.y > bbox.y) {
  12470. if (isNumber(bbox.width) && isNumber(bbox.height) &&
  12471. e.width + e.x < bbox.width + bbox.x &&
  12472. e.height + e.y < bbox.height + bbox.y) {
  12473. filteredElements[element.id] = element;
  12474. } else if (!isNumber(bbox.width) || !isNumber(bbox.height)) {
  12475. filteredElements[element.id] = element;
  12476. }
  12477. }
  12478. });
  12479. return filteredElements;
  12480. }
  12481. module.exports.eachElement = eachElement;
  12482. module.exports.selfAndDirectChildren = selfAndDirectChildren;
  12483. module.exports.selfAndAllChildren = selfAndAllChildren;
  12484. module.exports.getBBox = getBBox;
  12485. module.exports.getEnclosedElements = getEnclosedElements;
  12486. module.exports.getClosure = getClosure;
  12487. },{"168":168,"171":171,"86":86,"87":87}],67:[function(_dereq_,module,exports){
  12488. 'use strict';
  12489. function __preventDefault(event) {
  12490. return event && event.preventDefault();
  12491. }
  12492. function __stopPropagation(event, immediate) {
  12493. if (!event) {
  12494. return;
  12495. }
  12496. if (event.stopPropagation) {
  12497. event.stopPropagation();
  12498. }
  12499. if (immediate && event.stopImmediatePropagation) {
  12500. event.stopImmediatePropagation();
  12501. }
  12502. }
  12503. function getOriginal(event) {
  12504. return event.originalEvent || event.srcEvent;
  12505. }
  12506. module.exports.getOriginal = getOriginal;
  12507. function stopEvent(event, immediate) {
  12508. stopPropagation(event, immediate);
  12509. preventDefault(event);
  12510. }
  12511. module.exports.stopEvent = stopEvent;
  12512. function preventDefault(event) {
  12513. __preventDefault(event);
  12514. __preventDefault(getOriginal(event));
  12515. }
  12516. module.exports.preventDefault = preventDefault;
  12517. function stopPropagation(event, immediate) {
  12518. __stopPropagation(event, immediate);
  12519. __stopPropagation(getOriginal(event), immediate);
  12520. }
  12521. module.exports.stopPropagation = stopPropagation;
  12522. function toPoint(event) {
  12523. if (event.pointers && event.pointers.length) {
  12524. event = event.pointers[0];
  12525. }
  12526. if (event.touches && event.touches.length) {
  12527. event = event.touches[0];
  12528. }
  12529. return event ? {
  12530. x: event.clientX,
  12531. y: event.clientY
  12532. } : null;
  12533. }
  12534. module.exports.toPoint = toPoint;
  12535. },{}],68:[function(_dereq_,module,exports){
  12536. 'use strict';
  12537. /**
  12538. * SVGs for elements are generated by the {@link GraphicsFactory}.
  12539. *
  12540. * This utility gives quick access to the important semantic
  12541. * parts of an element.
  12542. */
  12543. /**
  12544. * Returns the visual part of a diagram element
  12545. *
  12546. * @param {Snap<SVGElement>} gfx
  12547. *
  12548. * @return {Snap<SVGElement>}
  12549. */
  12550. function getVisual(gfx) {
  12551. return gfx.select('.djs-visual');
  12552. }
  12553. /**
  12554. * Returns the children for a given diagram element.
  12555. *
  12556. * @param {Snap<SVGElement>} gfx
  12557. * @return {Snap<SVGElement>}
  12558. */
  12559. function getChildren(gfx) {
  12560. return gfx.parent().children()[1];
  12561. }
  12562. /**
  12563. * Returns the visual bbox of an element
  12564. *
  12565. * @param {Snap<SVGElement>} gfx
  12566. *
  12567. * @return {Bounds}
  12568. */
  12569. function getBBox(gfx) {
  12570. return getVisual(gfx).select('*').getBBox();
  12571. }
  12572. module.exports.getVisual = getVisual;
  12573. module.exports.getChildren = getChildren;
  12574. module.exports.getBBox = getBBox;
  12575. },{}],69:[function(_dereq_,module,exports){
  12576. 'use strict';
  12577. /**
  12578. * Util that provides unique IDs.
  12579. *
  12580. * @class djs.util.IdGenerator
  12581. * @constructor
  12582. * @memberOf djs.util
  12583. *
  12584. * The ids can be customized via a given prefix and contain a random value to avoid collisions.
  12585. *
  12586. * @param {String} prefix a prefix to prepend to generated ids (for better readability)
  12587. */
  12588. function IdGenerator(prefix) {
  12589. this._counter = 0;
  12590. this._prefix = (prefix ? prefix + '-' : '') + Math.floor(Math.random() * 1000000000) + '-';
  12591. }
  12592. module.exports = IdGenerator;
  12593. /**
  12594. * Returns a next unique ID.
  12595. *
  12596. * @method djs.util.IdGenerator#next
  12597. *
  12598. * @returns {String} the id
  12599. */
  12600. IdGenerator.prototype.next = function() {
  12601. return this._prefix + (++this._counter);
  12602. };
  12603. },{}],70:[function(_dereq_,module,exports){
  12604. 'use strict';
  12605. /**
  12606. * Get the logarithm of x with base 10
  12607. * @param {Integer} value
  12608. */
  12609. function log10(x) {
  12610. return Math.log(x) / Math.log(10);
  12611. }
  12612. module.exports.log10 = log10;
  12613. },{}],71:[function(_dereq_,module,exports){
  12614. 'use strict';
  12615. var getOriginalEvent = _dereq_(67).getOriginal;
  12616. var isMac = _dereq_(72).isMac;
  12617. function isPrimaryButton(event) {
  12618. // button === 0 -> left áka primary mouse button
  12619. return !(getOriginalEvent(event) || event).button;
  12620. }
  12621. module.exports.isPrimaryButton = isPrimaryButton;
  12622. module.exports.isMac = isMac;
  12623. module.exports.hasPrimaryModifier = function(event) {
  12624. var originalEvent = getOriginalEvent(event) || event;
  12625. if (!isPrimaryButton(event)) {
  12626. return false;
  12627. }
  12628. // Use alt as primary modifier key for mac OS
  12629. if (isMac()) {
  12630. return originalEvent.altKey;
  12631. } else {
  12632. return originalEvent.ctrlKey;
  12633. }
  12634. };
  12635. module.exports.hasSecondaryModifier = function(event) {
  12636. var originalEvent = getOriginalEvent(event) || event;
  12637. return isPrimaryButton(event) && originalEvent.shiftKey;
  12638. };
  12639. },{"67":67,"72":72}],72:[function(_dereq_,module,exports){
  12640. 'use strict';
  12641. module.exports.isMac = function isMac() {
  12642. return (/mac/i).test(navigator.platform);
  12643. };
  12644. },{}],73:[function(_dereq_,module,exports){
  12645. 'use strict';
  12646. var isObject = _dereq_(172),
  12647. assign = _dereq_(177),
  12648. pick = _dereq_(183),
  12649. forEach = _dereq_(86),
  12650. reduce = _dereq_(90),
  12651. merge = _dereq_(180);
  12652. var Snap = _dereq_(76);
  12653. var DEFAULT_BOX_PADDING = 0;
  12654. var DEFAULT_LABEL_SIZE = {
  12655. width: 150,
  12656. height: 50
  12657. };
  12658. function parseAlign(align) {
  12659. var parts = align.split('-');
  12660. return {
  12661. horizontal: parts[0] || 'center',
  12662. vertical: parts[1] || 'top'
  12663. };
  12664. }
  12665. function parsePadding(padding) {
  12666. if (isObject(padding)) {
  12667. return assign({ top: 0, left: 0, right: 0, bottom: 0 }, padding);
  12668. } else {
  12669. return {
  12670. top: padding,
  12671. left: padding,
  12672. right: padding,
  12673. bottom: padding
  12674. };
  12675. }
  12676. }
  12677. function getTextBBox(text, fakeText) {
  12678. fakeText.textContent = text;
  12679. return pick(fakeText.getBBox(), [ 'width', 'height' ]);
  12680. }
  12681. /**
  12682. * Layout the next line and return the layouted element.
  12683. *
  12684. * Alters the lines passed.
  12685. *
  12686. * @param {Array<String>} lines
  12687. * @return {Object} the line descriptor, an object { width, height, text }
  12688. */
  12689. function layoutNext(lines, maxWidth, fakeText) {
  12690. var originalLine = lines.shift(),
  12691. fitLine = originalLine;
  12692. var textBBox;
  12693. while (true) {
  12694. textBBox = getTextBBox(fitLine, fakeText);
  12695. textBBox.width = fitLine ? textBBox.width : 0;
  12696. // try to fit
  12697. if (fitLine === ' ' || fitLine === '' || textBBox.width < Math.round(maxWidth) || fitLine.length < 4) {
  12698. return fit(lines, fitLine, originalLine, textBBox);
  12699. }
  12700. fitLine = shortenLine(fitLine, textBBox.width, maxWidth);
  12701. }
  12702. }
  12703. function fit(lines, fitLine, originalLine, textBBox) {
  12704. if (fitLine.length < originalLine.length) {
  12705. var nextLine = lines[0] || '',
  12706. remainder = originalLine.slice(fitLine.length).trim();
  12707. if (/-\s*$/.test(remainder)) {
  12708. nextLine = remainder.replace(/-\s*$/, '') + nextLine.replace(/^\s+/, '');
  12709. } else {
  12710. nextLine = remainder + ' ' + nextLine;
  12711. }
  12712. lines[0] = nextLine;
  12713. }
  12714. return { width: textBBox.width, height: textBBox.height, text: fitLine };
  12715. }
  12716. /**
  12717. * Shortens a line based on spacing and hyphens.
  12718. * Returns the shortened result on success.
  12719. *
  12720. * @param {String} line
  12721. * @param {Number} maxLength the maximum characters of the string
  12722. * @return {String} the shortened string
  12723. */
  12724. function semanticShorten(line, maxLength) {
  12725. var parts = line.split(/(\s|-)/g),
  12726. part,
  12727. shortenedParts = [],
  12728. length = 0;
  12729. // try to shorten via spaces + hyphens
  12730. if (parts.length > 1) {
  12731. while ((part = parts.shift())) {
  12732. if (part.length + length < maxLength) {
  12733. shortenedParts.push(part);
  12734. length += part.length;
  12735. } else {
  12736. // remove previous part, too if hyphen does not fit anymore
  12737. if (part === '-') {
  12738. shortenedParts.pop();
  12739. }
  12740. break;
  12741. }
  12742. }
  12743. }
  12744. return shortenedParts.join('');
  12745. }
  12746. function shortenLine(line, width, maxWidth) {
  12747. var length = Math.max(line.length * (maxWidth / width), 1);
  12748. // try to shorten semantically (i.e. based on spaces and hyphens)
  12749. var shortenedLine = semanticShorten(line, length);
  12750. if (!shortenedLine) {
  12751. // force shorten by cutting the long word
  12752. shortenedLine = line.slice(0, Math.max(Math.round(length - 1), 1));
  12753. }
  12754. return shortenedLine;
  12755. }
  12756. /**
  12757. * Creates a new label utility
  12758. *
  12759. * @param {Object} config
  12760. * @param {Dimensions} config.size
  12761. * @param {Number} config.padding
  12762. * @param {Object} config.style
  12763. * @param {String} config.align
  12764. */
  12765. function Text(config) {
  12766. this._config = assign({}, {
  12767. size: DEFAULT_LABEL_SIZE,
  12768. padding: DEFAULT_BOX_PADDING,
  12769. style: {},
  12770. align: 'center-top'
  12771. }, config || {});
  12772. }
  12773. /**
  12774. * Create a label in the parent node.
  12775. *
  12776. * @method Text#createText
  12777. *
  12778. * @param {SVGElement} parent the parent to draw the label on
  12779. * @param {String} text the text to render on the label
  12780. * @param {Object} options
  12781. * @param {String} options.align how to align in the bounding box.
  12782. * Any of { 'center-middle', 'center-top' }, defaults to 'center-top'.
  12783. * @param {String} options.style style to be applied to the text
  12784. *
  12785. * @return {SVGText} the text element created
  12786. */
  12787. Text.prototype.createText = function(parent, text, options) {
  12788. var box = merge({}, this._config.size, options.box || {}),
  12789. style = merge({}, this._config.style, options.style || {}),
  12790. align = parseAlign(options.align || this._config.align),
  12791. padding = parsePadding(options.padding !== undefined ? options.padding : this._config.padding);
  12792. var lines = text.split(/\r?\n/g),
  12793. layouted = [];
  12794. var maxWidth = box.width - padding.left - padding.right;
  12795. // FF regression: ensure text is shown during rendering
  12796. // by attaching it directly to the body
  12797. var fakeText = parent.paper.text(0, 0, '').attr(style).node;
  12798. while (lines.length) {
  12799. layouted.push(layoutNext(lines, maxWidth, fakeText));
  12800. }
  12801. var totalHeight = reduce(layouted, function(sum, line, idx) {
  12802. return sum + line.height;
  12803. }, 0);
  12804. // the y position of the next line
  12805. var y, x;
  12806. switch (align.vertical) {
  12807. case 'middle':
  12808. y = (box.height - totalHeight) / 2 - layouted[0].height / 4;
  12809. break;
  12810. default:
  12811. y = padding.top;
  12812. }
  12813. var textElement = parent.text().attr(style);
  12814. forEach(layouted, function(line) {
  12815. y += line.height;
  12816. switch (align.horizontal) {
  12817. case 'left':
  12818. x = padding.left;
  12819. break;
  12820. case 'right':
  12821. x = (maxWidth - padding.right - line.width);
  12822. break;
  12823. default:
  12824. // aka center
  12825. x = Math.max(((maxWidth - line.width) / 2 + padding.left), 0);
  12826. }
  12827. var tspan = Snap.create('tspan', { x: x, y: y }).node;
  12828. tspan.textContent = line.text;
  12829. textElement.append(tspan);
  12830. });
  12831. // remove fake text
  12832. fakeText.parentNode.removeChild(fakeText);
  12833. return textElement;
  12834. };
  12835. module.exports = Text;
  12836. },{"172":172,"177":177,"180":180,"183":183,"76":76,"86":86,"90":90}],74:[function(_dereq_,module,exports){
  12837. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  12838. //
  12839. // Licensed under the Apache License, Version 2.0 (the "License");
  12840. // you may not use this file except in compliance with the License.
  12841. // You may obtain a copy of the License at
  12842. //
  12843. // http://www.apache.org/licenses/LICENSE-2.0
  12844. //
  12845. // Unless required by applicable law or agreed to in writing, software
  12846. // distributed under the License is distributed on an "AS IS" BASIS,
  12847. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12848. // See the License for the specific language governing permissions and
  12849. // limitations under the License.
  12850. // ┌────────────────────────────────────────────────────────────┐ \\
  12851. // │ Eve 0.4.2 - JavaScript Events Library │ \\
  12852. // ├────────────────────────────────────────────────────────────┤ \\
  12853. // │ Author Dmitry Baranovskiy (http://dmitry.baranovskiy.com/) │ \\
  12854. // └────────────────────────────────────────────────────────────┘ \\
  12855. (function (glob) {
  12856. var version = "0.4.2",
  12857. has = "hasOwnProperty",
  12858. separator = /[\.\/]/,
  12859. comaseparator = /\s*,\s*/,
  12860. wildcard = "*",
  12861. fun = function () {},
  12862. numsort = function (a, b) {
  12863. return a - b;
  12864. },
  12865. current_event,
  12866. stop,
  12867. events = {n: {}},
  12868. firstDefined = function () {
  12869. for (var i = 0, ii = this.length; i < ii; i++) {
  12870. if (typeof this[i] != "undefined") {
  12871. return this[i];
  12872. }
  12873. }
  12874. },
  12875. lastDefined = function () {
  12876. var i = this.length;
  12877. while (--i) {
  12878. if (typeof this[i] != "undefined") {
  12879. return this[i];
  12880. }
  12881. }
  12882. },
  12883. /*\
  12884. * eve
  12885. [ method ]
  12886. * Fires event with given `name`, given scope and other parameters.
  12887. > Arguments
  12888. - name (string) name of the *event*, dot (`.`) or slash (`/`) separated
  12889. - scope (object) context for the event handlers
  12890. - varargs (...) the rest of arguments will be sent to event handlers
  12891. = (object) array of returned values from the listeners. Array has two methods `.firstDefined()` and `.lastDefined()` to get first or last not `undefined` value.
  12892. \*/
  12893. eve = function (name, scope) {
  12894. name = String(name);
  12895. var e = events,
  12896. oldstop = stop,
  12897. args = Array.prototype.slice.call(arguments, 2),
  12898. listeners = eve.listeners(name),
  12899. z = 0,
  12900. f = false,
  12901. l,
  12902. indexed = [],
  12903. queue = {},
  12904. out = [],
  12905. ce = current_event,
  12906. errors = [];
  12907. out.firstDefined = firstDefined;
  12908. out.lastDefined = lastDefined;
  12909. current_event = name;
  12910. stop = 0;
  12911. for (var i = 0, ii = listeners.length; i < ii; i++) if ("zIndex" in listeners[i]) {
  12912. indexed.push(listeners[i].zIndex);
  12913. if (listeners[i].zIndex < 0) {
  12914. queue[listeners[i].zIndex] = listeners[i];
  12915. }
  12916. }
  12917. indexed.sort(numsort);
  12918. while (indexed[z] < 0) {
  12919. l = queue[indexed[z++]];
  12920. out.push(l.apply(scope, args));
  12921. if (stop) {
  12922. stop = oldstop;
  12923. return out;
  12924. }
  12925. }
  12926. for (i = 0; i < ii; i++) {
  12927. l = listeners[i];
  12928. if ("zIndex" in l) {
  12929. if (l.zIndex == indexed[z]) {
  12930. out.push(l.apply(scope, args));
  12931. if (stop) {
  12932. break;
  12933. }
  12934. do {
  12935. z++;
  12936. l = queue[indexed[z]];
  12937. l && out.push(l.apply(scope, args));
  12938. if (stop) {
  12939. break;
  12940. }
  12941. } while (l)
  12942. } else {
  12943. queue[l.zIndex] = l;
  12944. }
  12945. } else {
  12946. out.push(l.apply(scope, args));
  12947. if (stop) {
  12948. break;
  12949. }
  12950. }
  12951. }
  12952. stop = oldstop;
  12953. current_event = ce;
  12954. return out;
  12955. };
  12956. // Undocumented. Debug only.
  12957. eve._events = events;
  12958. /*\
  12959. * eve.listeners
  12960. [ method ]
  12961. * Internal method which gives you array of all event handlers that will be triggered by the given `name`.
  12962. > Arguments
  12963. - name (string) name of the event, dot (`.`) or slash (`/`) separated
  12964. = (array) array of event handlers
  12965. \*/
  12966. eve.listeners = function (name) {
  12967. var names = name.split(separator),
  12968. e = events,
  12969. item,
  12970. items,
  12971. k,
  12972. i,
  12973. ii,
  12974. j,
  12975. jj,
  12976. nes,
  12977. es = [e],
  12978. out = [];
  12979. for (i = 0, ii = names.length; i < ii; i++) {
  12980. nes = [];
  12981. for (j = 0, jj = es.length; j < jj; j++) {
  12982. e = es[j].n;
  12983. items = [e[names[i]], e[wildcard]];
  12984. k = 2;
  12985. while (k--) {
  12986. item = items[k];
  12987. if (item) {
  12988. nes.push(item);
  12989. out = out.concat(item.f || []);
  12990. }
  12991. }
  12992. }
  12993. es = nes;
  12994. }
  12995. return out;
  12996. };
  12997. /*\
  12998. * eve.on
  12999. [ method ]
  13000. **
  13001. * Binds given event handler with a given name. You can use wildcards “`*`” for the names:
  13002. | eve.on("*.under.*", f);
  13003. | eve("mouse.under.floor"); // triggers f
  13004. * Use @eve to trigger the listener.
  13005. **
  13006. > Arguments
  13007. **
  13008. - name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards
  13009. - f (function) event handler function
  13010. **
  13011. = (function) returned function accepts a single numeric parameter that represents z-index of the handler. It is an optional feature and only used when you need to ensure that some subset of handlers will be invoked in a given order, despite of the order of assignment.
  13012. > Example:
  13013. | eve.on("mouse", eatIt)(2);
  13014. | eve.on("mouse", scream);
  13015. | eve.on("mouse", catchIt)(1);
  13016. * This will ensure that `catchIt` function will be called before `eatIt`.
  13017. *
  13018. * If you want to put your handler before non-indexed handlers, specify a negative value.
  13019. * Note: I assume most of the time you don’t need to worry about z-index, but it’s nice to have this feature “just in case”.
  13020. \*/
  13021. eve.on = function (name, f) {
  13022. name = String(name);
  13023. if (typeof f != "function") {
  13024. return function () {};
  13025. }
  13026. var names = name.split(comaseparator);
  13027. for (var i = 0, ii = names.length; i < ii; i++) {
  13028. (function (name) {
  13029. var names = name.split(separator),
  13030. e = events,
  13031. exist;
  13032. for (var i = 0, ii = names.length; i < ii; i++) {
  13033. e = e.n;
  13034. e = e.hasOwnProperty(names[i]) && e[names[i]] || (e[names[i]] = {n: {}});
  13035. }
  13036. e.f = e.f || [];
  13037. for (i = 0, ii = e.f.length; i < ii; i++) if (e.f[i] == f) {
  13038. exist = true;
  13039. break;
  13040. }
  13041. !exist && e.f.push(f);
  13042. }(names[i]));
  13043. }
  13044. return function (zIndex) {
  13045. if (+zIndex == +zIndex) {
  13046. f.zIndex = +zIndex;
  13047. }
  13048. };
  13049. };
  13050. /*\
  13051. * eve.f
  13052. [ method ]
  13053. **
  13054. * Returns function that will fire given event with optional arguments.
  13055. * Arguments that will be passed to the result function will be also
  13056. * concated to the list of final arguments.
  13057. | el.onclick = eve.f("click", 1, 2);
  13058. | eve.on("click", function (a, b, c) {
  13059. | console.log(a, b, c); // 1, 2, [event object]
  13060. | });
  13061. > Arguments
  13062. - event (string) event name
  13063. - varargs (…) and any other arguments
  13064. = (function) possible event handler function
  13065. \*/
  13066. eve.f = function (event) {
  13067. var attrs = [].slice.call(arguments, 1);
  13068. return function () {
  13069. eve.apply(null, [event, null].concat(attrs).concat([].slice.call(arguments, 0)));
  13070. };
  13071. };
  13072. /*\
  13073. * eve.stop
  13074. [ method ]
  13075. **
  13076. * Is used inside an event handler to stop the event, preventing any subsequent listeners from firing.
  13077. \*/
  13078. eve.stop = function () {
  13079. stop = 1;
  13080. };
  13081. /*\
  13082. * eve.nt
  13083. [ method ]
  13084. **
  13085. * Could be used inside event handler to figure out actual name of the event.
  13086. **
  13087. > Arguments
  13088. **
  13089. - subname (string) #optional subname of the event
  13090. **
  13091. = (string) name of the event, if `subname` is not specified
  13092. * or
  13093. = (boolean) `true`, if current event’s name contains `subname`
  13094. \*/
  13095. eve.nt = function (subname) {
  13096. if (subname) {
  13097. return new RegExp("(?:\\.|\\/|^)" + subname + "(?:\\.|\\/|$)").test(current_event);
  13098. }
  13099. return current_event;
  13100. };
  13101. /*\
  13102. * eve.nts
  13103. [ method ]
  13104. **
  13105. * Could be used inside event handler to figure out actual name of the event.
  13106. **
  13107. **
  13108. = (array) names of the event
  13109. \*/
  13110. eve.nts = function () {
  13111. return current_event.split(separator);
  13112. };
  13113. /*\
  13114. * eve.off
  13115. [ method ]
  13116. **
  13117. * Removes given function from the list of event listeners assigned to given name.
  13118. * If no arguments specified all the events will be cleared.
  13119. **
  13120. > Arguments
  13121. **
  13122. - name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards
  13123. - f (function) event handler function
  13124. \*/
  13125. /*\
  13126. * eve.unbind
  13127. [ method ]
  13128. **
  13129. * See @eve.off
  13130. \*/
  13131. eve.off = eve.unbind = function (name, f) {
  13132. if (!name) {
  13133. eve._events = events = {n: {}};
  13134. return;
  13135. }
  13136. var names = name.split(comaseparator);
  13137. if (names.length > 1) {
  13138. for (var i = 0, ii = names.length; i < ii; i++) {
  13139. eve.off(names[i], f);
  13140. }
  13141. return;
  13142. }
  13143. names = name.split(separator);
  13144. var e,
  13145. key,
  13146. splice,
  13147. i, ii, j, jj,
  13148. cur = [events];
  13149. for (i = 0, ii = names.length; i < ii; i++) {
  13150. for (j = 0; j < cur.length; j += splice.length - 2) {
  13151. splice = [j, 1];
  13152. e = cur[j].n;
  13153. if (names[i] != wildcard) {
  13154. if (e[names[i]]) {
  13155. splice.push(e[names[i]]);
  13156. }
  13157. } else {
  13158. for (key in e) if (e[has](key)) {
  13159. splice.push(e[key]);
  13160. }
  13161. }
  13162. cur.splice.apply(cur, splice);
  13163. }
  13164. }
  13165. for (i = 0, ii = cur.length; i < ii; i++) {
  13166. e = cur[i];
  13167. while (e.n) {
  13168. if (f) {
  13169. if (e.f) {
  13170. for (j = 0, jj = e.f.length; j < jj; j++) if (e.f[j] == f) {
  13171. e.f.splice(j, 1);
  13172. break;
  13173. }
  13174. !e.f.length && delete e.f;
  13175. }
  13176. for (key in e.n) if (e.n[has](key) && e.n[key].f) {
  13177. var funcs = e.n[key].f;
  13178. for (j = 0, jj = funcs.length; j < jj; j++) if (funcs[j] == f) {
  13179. funcs.splice(j, 1);
  13180. break;
  13181. }
  13182. !funcs.length && delete e.n[key].f;
  13183. }
  13184. } else {
  13185. delete e.f;
  13186. for (key in e.n) if (e.n[has](key) && e.n[key].f) {
  13187. delete e.n[key].f;
  13188. }
  13189. }
  13190. e = e.n;
  13191. }
  13192. }
  13193. };
  13194. /*\
  13195. * eve.once
  13196. [ method ]
  13197. **
  13198. * Binds given event handler with a given name to only run once then unbind itself.
  13199. | eve.once("login", f);
  13200. | eve("login"); // triggers f
  13201. | eve("login"); // no listeners
  13202. * Use @eve to trigger the listener.
  13203. **
  13204. > Arguments
  13205. **
  13206. - name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards
  13207. - f (function) event handler function
  13208. **
  13209. = (function) same return function as @eve.on
  13210. \*/
  13211. eve.once = function (name, f) {
  13212. var f2 = function () {
  13213. eve.unbind(name, f2);
  13214. return f.apply(this, arguments);
  13215. };
  13216. return eve.on(name, f2);
  13217. };
  13218. /*\
  13219. * eve.version
  13220. [ property (string) ]
  13221. **
  13222. * Current version of the library.
  13223. \*/
  13224. eve.version = version;
  13225. eve.toString = function () {
  13226. return "You are running Eve " + version;
  13227. };
  13228. (typeof module != "undefined" && module.exports) ? (module.exports = eve) : (typeof define === "function" && define.amd ? (define("eve", [], function() { return eve; })) : (glob.eve = eve));
  13229. })(this);
  13230. },{}],75:[function(_dereq_,module,exports){
  13231. // Snap.svg 0.3.0
  13232. //
  13233. // Copyright (c) 2013 – 2014 Adobe Systems Incorporated. All rights reserved.
  13234. //
  13235. // Licensed under the Apache License, Version 2.0 (the "License");
  13236. // you may not use this file except in compliance with the License.
  13237. // You may obtain a copy of the License at
  13238. //
  13239. // http://www.apache.org/licenses/LICENSE-2.0
  13240. //
  13241. // Unless required by applicable law or agreed to in writing, software
  13242. // distributed under the License is distributed on an "AS IS" BASIS,
  13243. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13244. // See the License for the specific language governing permissions and
  13245. // limitations under the License.
  13246. //
  13247. // build: 2014-09-08
  13248. (function (glob, factory) {
  13249. // AMD support
  13250. if (typeof define === "function" && define.amd) {
  13251. // Define as an anonymous module
  13252. define(["eve"], function( eve ) {
  13253. return factory(glob, eve);
  13254. });
  13255. } else if (typeof exports !== 'undefined') {
  13256. // Next for Node.js or CommonJS
  13257. var eve = _dereq_(74);
  13258. module.exports = factory(glob, eve);
  13259. } else {
  13260. // Browser globals (glob is window)
  13261. // Snap adds itself to window
  13262. factory(glob, glob.eve);
  13263. }
  13264. }(window || this, function (window, eve) {
  13265. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  13266. //
  13267. // Licensed under the Apache License, Version 2.0 (the "License");
  13268. // you may not use this file except in compliance with the License.
  13269. // You may obtain a copy of the License at
  13270. //
  13271. // http://www.apache.org/licenses/LICENSE-2.0
  13272. //
  13273. // Unless required by applicable law or agreed to in writing, software
  13274. // distributed under the License is distributed on an "AS IS" BASIS,
  13275. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13276. // See the License for the specific language governing permissions and
  13277. // limitations under the License.
  13278. var mina = (function (eve) {
  13279. var animations = {},
  13280. requestAnimFrame = window.requestAnimationFrame ||
  13281. window.webkitRequestAnimationFrame ||
  13282. window.mozRequestAnimationFrame ||
  13283. window.oRequestAnimationFrame ||
  13284. window.msRequestAnimationFrame ||
  13285. function (callback) {
  13286. setTimeout(callback, 16);
  13287. },
  13288. isArray = Array.isArray || function (a) {
  13289. return a instanceof Array ||
  13290. Object.prototype.toString.call(a) == "[object Array]";
  13291. },
  13292. idgen = 0,
  13293. idprefix = "M" + (+new Date).toString(36),
  13294. ID = function () {
  13295. return idprefix + (idgen++).toString(36);
  13296. },
  13297. diff = function (a, b, A, B) {
  13298. if (isArray(a)) {
  13299. res = [];
  13300. for (var i = 0, ii = a.length; i < ii; i++) {
  13301. res[i] = diff(a[i], b, A[i], B);
  13302. }
  13303. return res;
  13304. }
  13305. var dif = (A - a) / (B - b);
  13306. return function (bb) {
  13307. return a + dif * (bb - b);
  13308. };
  13309. },
  13310. timer = Date.now || function () {
  13311. return +new Date;
  13312. },
  13313. sta = function (val) {
  13314. var a = this;
  13315. if (val == null) {
  13316. return a.s;
  13317. }
  13318. var ds = a.s - val;
  13319. a.b += a.dur * ds;
  13320. a.B += a.dur * ds;
  13321. a.s = val;
  13322. },
  13323. speed = function (val) {
  13324. var a = this;
  13325. if (val == null) {
  13326. return a.spd;
  13327. }
  13328. a.spd = val;
  13329. },
  13330. duration = function (val) {
  13331. var a = this;
  13332. if (val == null) {
  13333. return a.dur;
  13334. }
  13335. a.s = a.s * val / a.dur;
  13336. a.dur = val;
  13337. },
  13338. stopit = function () {
  13339. var a = this;
  13340. delete animations[a.id];
  13341. a.update();
  13342. eve("mina.stop." + a.id, a);
  13343. },
  13344. pause = function () {
  13345. var a = this;
  13346. if (a.pdif) {
  13347. return;
  13348. }
  13349. delete animations[a.id];
  13350. a.update();
  13351. a.pdif = a.get() - a.b;
  13352. },
  13353. resume = function () {
  13354. var a = this;
  13355. if (!a.pdif) {
  13356. return;
  13357. }
  13358. a.b = a.get() - a.pdif;
  13359. delete a.pdif;
  13360. animations[a.id] = a;
  13361. },
  13362. update = function () {
  13363. var a = this,
  13364. res;
  13365. if (isArray(a.start)) {
  13366. res = [];
  13367. for (var j = 0, jj = a.start.length; j < jj; j++) {
  13368. res[j] = +a.start[j] +
  13369. (a.end[j] - a.start[j]) * a.easing(a.s);
  13370. }
  13371. } else {
  13372. res = +a.start + (a.end - a.start) * a.easing(a.s);
  13373. }
  13374. a.set(res);
  13375. },
  13376. frame = function () {
  13377. var len = 0;
  13378. for (var i in animations) if (animations.hasOwnProperty(i)) {
  13379. var a = animations[i],
  13380. b = a.get(),
  13381. res;
  13382. len++;
  13383. a.s = (b - a.b) / (a.dur / a.spd);
  13384. if (a.s >= 1) {
  13385. delete animations[i];
  13386. a.s = 1;
  13387. len--;
  13388. (function (a) {
  13389. setTimeout(function () {
  13390. eve("mina.finish." + a.id, a);
  13391. });
  13392. }(a));
  13393. }
  13394. a.update();
  13395. }
  13396. len && requestAnimFrame(frame);
  13397. },
  13398. /*\
  13399. * mina
  13400. [ method ]
  13401. **
  13402. * Generic animation of numbers
  13403. **
  13404. - a (number) start _slave_ number
  13405. - A (number) end _slave_ number
  13406. - b (number) start _master_ number (start time in general case)
  13407. - B (number) end _master_ number (end time in gereal case)
  13408. - get (function) getter of _master_ number (see @mina.time)
  13409. - set (function) setter of _slave_ number
  13410. - easing (function) #optional easing function, default is @mina.linear
  13411. = (object) animation descriptor
  13412. o {
  13413. o id (string) animation id,
  13414. o start (number) start _slave_ number,
  13415. o end (number) end _slave_ number,
  13416. o b (number) start _master_ number,
  13417. o s (number) animation status (0..1),
  13418. o dur (number) animation duration,
  13419. o spd (number) animation speed,
  13420. o get (function) getter of _master_ number (see @mina.time),
  13421. o set (function) setter of _slave_ number,
  13422. o easing (function) easing function, default is @mina.linear,
  13423. o status (function) status getter/setter,
  13424. o speed (function) speed getter/setter,
  13425. o duration (function) duration getter/setter,
  13426. o stop (function) animation stopper
  13427. o pause (function) pauses the animation
  13428. o resume (function) resumes the animation
  13429. o update (function) calles setter with the right value of the animation
  13430. o }
  13431. \*/
  13432. mina = function (a, A, b, B, get, set, easing) {
  13433. var anim = {
  13434. id: ID(),
  13435. start: a,
  13436. end: A,
  13437. b: b,
  13438. s: 0,
  13439. dur: B - b,
  13440. spd: 1,
  13441. get: get,
  13442. set: set,
  13443. easing: easing || mina.linear,
  13444. status: sta,
  13445. speed: speed,
  13446. duration: duration,
  13447. stop: stopit,
  13448. pause: pause,
  13449. resume: resume,
  13450. update: update
  13451. };
  13452. animations[anim.id] = anim;
  13453. var len = 0, i;
  13454. for (i in animations) if (animations.hasOwnProperty(i)) {
  13455. len++;
  13456. if (len == 2) {
  13457. break;
  13458. }
  13459. }
  13460. len == 1 && requestAnimFrame(frame);
  13461. return anim;
  13462. };
  13463. /*\
  13464. * mina.time
  13465. [ method ]
  13466. **
  13467. * Returns the current time. Equivalent to:
  13468. | function () {
  13469. | return (new Date).getTime();
  13470. | }
  13471. \*/
  13472. mina.time = timer;
  13473. /*\
  13474. * mina.getById
  13475. [ method ]
  13476. **
  13477. * Returns an animation by its id
  13478. - id (string) animation's id
  13479. = (object) See @mina
  13480. \*/
  13481. mina.getById = function (id) {
  13482. return animations[id] || null;
  13483. };
  13484. /*\
  13485. * mina.linear
  13486. [ method ]
  13487. **
  13488. * Default linear easing
  13489. - n (number) input 0..1
  13490. = (number) output 0..1
  13491. \*/
  13492. mina.linear = function (n) {
  13493. return n;
  13494. };
  13495. /*\
  13496. * mina.easeout
  13497. [ method ]
  13498. **
  13499. * Easeout easing
  13500. - n (number) input 0..1
  13501. = (number) output 0..1
  13502. \*/
  13503. mina.easeout = function (n) {
  13504. return Math.pow(n, 1.7);
  13505. };
  13506. /*\
  13507. * mina.easein
  13508. [ method ]
  13509. **
  13510. * Easein easing
  13511. - n (number) input 0..1
  13512. = (number) output 0..1
  13513. \*/
  13514. mina.easein = function (n) {
  13515. return Math.pow(n, .48);
  13516. };
  13517. /*\
  13518. * mina.easeinout
  13519. [ method ]
  13520. **
  13521. * Easeinout easing
  13522. - n (number) input 0..1
  13523. = (number) output 0..1
  13524. \*/
  13525. mina.easeinout = function (n) {
  13526. if (n == 1) {
  13527. return 1;
  13528. }
  13529. if (n == 0) {
  13530. return 0;
  13531. }
  13532. var q = .48 - n / 1.04,
  13533. Q = Math.sqrt(.1734 + q * q),
  13534. x = Q - q,
  13535. X = Math.pow(Math.abs(x), 1 / 3) * (x < 0 ? -1 : 1),
  13536. y = -Q - q,
  13537. Y = Math.pow(Math.abs(y), 1 / 3) * (y < 0 ? -1 : 1),
  13538. t = X + Y + .5;
  13539. return (1 - t) * 3 * t * t + t * t * t;
  13540. };
  13541. /*\
  13542. * mina.backin
  13543. [ method ]
  13544. **
  13545. * Backin easing
  13546. - n (number) input 0..1
  13547. = (number) output 0..1
  13548. \*/
  13549. mina.backin = function (n) {
  13550. if (n == 1) {
  13551. return 1;
  13552. }
  13553. var s = 1.70158;
  13554. return n * n * ((s + 1) * n - s);
  13555. };
  13556. /*\
  13557. * mina.backout
  13558. [ method ]
  13559. **
  13560. * Backout easing
  13561. - n (number) input 0..1
  13562. = (number) output 0..1
  13563. \*/
  13564. mina.backout = function (n) {
  13565. if (n == 0) {
  13566. return 0;
  13567. }
  13568. n = n - 1;
  13569. var s = 1.70158;
  13570. return n * n * ((s + 1) * n + s) + 1;
  13571. };
  13572. /*\
  13573. * mina.elastic
  13574. [ method ]
  13575. **
  13576. * Elastic easing
  13577. - n (number) input 0..1
  13578. = (number) output 0..1
  13579. \*/
  13580. mina.elastic = function (n) {
  13581. if (n == !!n) {
  13582. return n;
  13583. }
  13584. return Math.pow(2, -10 * n) * Math.sin((n - .075) *
  13585. (2 * Math.PI) / .3) + 1;
  13586. };
  13587. /*\
  13588. * mina.bounce
  13589. [ method ]
  13590. **
  13591. * Bounce easing
  13592. - n (number) input 0..1
  13593. = (number) output 0..1
  13594. \*/
  13595. mina.bounce = function (n) {
  13596. var s = 7.5625,
  13597. p = 2.75,
  13598. l;
  13599. if (n < (1 / p)) {
  13600. l = s * n * n;
  13601. } else {
  13602. if (n < (2 / p)) {
  13603. n -= (1.5 / p);
  13604. l = s * n * n + .75;
  13605. } else {
  13606. if (n < (2.5 / p)) {
  13607. n -= (2.25 / p);
  13608. l = s * n * n + .9375;
  13609. } else {
  13610. n -= (2.625 / p);
  13611. l = s * n * n + .984375;
  13612. }
  13613. }
  13614. }
  13615. return l;
  13616. };
  13617. window.mina = mina;
  13618. return mina;
  13619. })(typeof eve == "undefined" ? function () {} : eve);
  13620. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  13621. //
  13622. // Licensed under the Apache License, Version 2.0 (the "License");
  13623. // you may not use this file except in compliance with the License.
  13624. // You may obtain a copy of the License at
  13625. //
  13626. // http://www.apache.org/licenses/LICENSE-2.0
  13627. //
  13628. // Unless required by applicable law or agreed to in writing, software
  13629. // distributed under the License is distributed on an "AS IS" BASIS,
  13630. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13631. // See the License for the specific language governing permissions and
  13632. // limitations under the License.
  13633. var Snap = (function(root) {
  13634. Snap.version = "0.3.0";
  13635. /*\
  13636. * Snap
  13637. [ method ]
  13638. **
  13639. * Creates a drawing surface or wraps existing SVG element.
  13640. **
  13641. - width (number|string) width of surface
  13642. - height (number|string) height of surface
  13643. * or
  13644. - DOM (SVGElement) element to be wrapped into Snap structure
  13645. * or
  13646. - array (array) array of elements (will return set of elements)
  13647. * or
  13648. - query (string) CSS query selector
  13649. = (object) @Element
  13650. \*/
  13651. function Snap(w, h) {
  13652. if (w) {
  13653. if (w.tagName) {
  13654. return wrap(w);
  13655. }
  13656. if (is(w, "array") && Snap.set) {
  13657. return Snap.set.apply(Snap, w);
  13658. }
  13659. if (w instanceof Element) {
  13660. return w;
  13661. }
  13662. if (h == null) {
  13663. w = glob.doc.querySelector(w);
  13664. return wrap(w);
  13665. }
  13666. }
  13667. w = w == null ? "100%" : w;
  13668. h = h == null ? "100%" : h;
  13669. return new Paper(w, h);
  13670. }
  13671. Snap.toString = function () {
  13672. return "Snap v" + this.version;
  13673. };
  13674. Snap._ = {};
  13675. var glob = {
  13676. win: root.window,
  13677. doc: root.window.document
  13678. };
  13679. Snap._.glob = glob;
  13680. var has = "hasOwnProperty",
  13681. Str = String,
  13682. toFloat = parseFloat,
  13683. toInt = parseInt,
  13684. math = Math,
  13685. mmax = math.max,
  13686. mmin = math.min,
  13687. abs = math.abs,
  13688. pow = math.pow,
  13689. PI = math.PI,
  13690. round = math.round,
  13691. E = "",
  13692. S = " ",
  13693. objectToString = Object.prototype.toString,
  13694. ISURL = /^url\(['"]?([^\)]+?)['"]?\)$/i,
  13695. colourRegExp = /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?%?)\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?%?)\s*\))\s*$/i,
  13696. bezierrg = /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,
  13697. reURLValue = /^url\(#?([^)]+)\)$/,
  13698. separator = Snap._.separator = /[,\s]+/,
  13699. whitespace = /[\s]/g,
  13700. commaSpaces = /[\s]*,[\s]*/,
  13701. hsrg = {hs: 1, rg: 1},
  13702. pathCommand = /([a-z])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\s]*,?[\s]*)+)/ig,
  13703. tCommand = /([rstm])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\s]*,?[\s]*)+)/ig,
  13704. pathValues = /(-?\d*\.?\d*(?:e[\-+]?\\d+)?)[\s]*,?[\s]*/ig,
  13705. idgen = 0,
  13706. idprefix = "S" + (+new Date).toString(36),
  13707. ID = function (el) {
  13708. return (el && el.type ? el.type : E) + idprefix + (idgen++).toString(36);
  13709. },
  13710. xlink = "http://www.w3.org/1999/xlink",
  13711. xmlns = "http://www.w3.org/2000/svg",
  13712. hub = {},
  13713. URL = Snap.url = function (url) {
  13714. return "url('#" + url + "')";
  13715. };
  13716. function $(el, attr) {
  13717. if (attr) {
  13718. if (el == "#text") {
  13719. el = glob.doc.createTextNode(attr.text || "");
  13720. }
  13721. if (typeof el == "string") {
  13722. el = $(el);
  13723. }
  13724. if (typeof attr == "string") {
  13725. if (attr.substring(0, 6) == "xlink:") {
  13726. return el.getAttributeNS(xlink, attr.substring(6));
  13727. }
  13728. if (attr.substring(0, 4) == "xml:") {
  13729. return el.getAttributeNS(xmlns, attr.substring(4));
  13730. }
  13731. return el.getAttribute(attr);
  13732. }
  13733. for (var key in attr) if (attr[has](key)) {
  13734. var val = Str(attr[key]);
  13735. if (val) {
  13736. if (key.substring(0, 6) == "xlink:") {
  13737. el.setAttributeNS(xlink, key.substring(6), val);
  13738. } else if (key.substring(0, 4) == "xml:") {
  13739. el.setAttributeNS(xmlns, key.substring(4), val);
  13740. } else {
  13741. el.setAttribute(key, val);
  13742. }
  13743. } else {
  13744. el.removeAttribute(key);
  13745. }
  13746. }
  13747. } else {
  13748. el = glob.doc.createElementNS(xmlns, el);
  13749. }
  13750. return el;
  13751. }
  13752. Snap._.$ = $;
  13753. Snap._.id = ID;
  13754. function getAttrs(el) {
  13755. var attrs = el.attributes,
  13756. name,
  13757. out = {};
  13758. for (var i = 0; i < attrs.length; i++) {
  13759. if (attrs[i].namespaceURI == xlink) {
  13760. name = "xlink:";
  13761. } else {
  13762. name = "";
  13763. }
  13764. name += attrs[i].name;
  13765. out[name] = attrs[i].textContent;
  13766. }
  13767. return out;
  13768. }
  13769. function is(o, type) {
  13770. type = Str.prototype.toLowerCase.call(type);
  13771. if (type == "finite") {
  13772. return isFinite(o);
  13773. }
  13774. if (type == "array" &&
  13775. (o instanceof Array || Array.isArray && Array.isArray(o))) {
  13776. return true;
  13777. }
  13778. return (type == "null" && o === null) ||
  13779. (type == typeof o && o !== null) ||
  13780. (type == "object" && o === Object(o)) ||
  13781. objectToString.call(o).slice(8, -1).toLowerCase() == type;
  13782. }
  13783. /*\
  13784. * Snap.format
  13785. [ method ]
  13786. **
  13787. * Replaces construction of type `{<name>}` to the corresponding argument
  13788. **
  13789. - token (string) string to format
  13790. - json (object) object which properties are used as a replacement
  13791. = (string) formatted string
  13792. > Usage
  13793. | // this draws a rectangular shape equivalent to "M10,20h40v50h-40z"
  13794. | paper.path(Snap.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width']}z", {
  13795. | x: 10,
  13796. | y: 20,
  13797. | dim: {
  13798. | width: 40,
  13799. | height: 50,
  13800. | "negative width": -40
  13801. | }
  13802. | }));
  13803. \*/
  13804. Snap.format = (function () {
  13805. var tokenRegex = /\{([^\}]+)\}/g,
  13806. objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, // matches .xxxxx or ["xxxxx"] to run over object properties
  13807. replacer = function (all, key, obj) {
  13808. var res = obj;
  13809. key.replace(objNotationRegex, function (all, name, quote, quotedName, isFunc) {
  13810. name = name || quotedName;
  13811. if (res) {
  13812. if (name in res) {
  13813. res = res[name];
  13814. }
  13815. typeof res == "function" && isFunc && (res = res());
  13816. }
  13817. });
  13818. res = (res == null || res == obj ? all : res) + "";
  13819. return res;
  13820. };
  13821. return function (str, obj) {
  13822. return Str(str).replace(tokenRegex, function (all, key) {
  13823. return replacer(all, key, obj);
  13824. });
  13825. };
  13826. })();
  13827. function clone(obj) {
  13828. if (typeof obj == "function" || Object(obj) !== obj) {
  13829. return obj;
  13830. }
  13831. var res = new obj.constructor;
  13832. for (var key in obj) if (obj[has](key)) {
  13833. res[key] = clone(obj[key]);
  13834. }
  13835. return res;
  13836. }
  13837. Snap._.clone = clone;
  13838. function repush(array, item) {
  13839. for (var i = 0, ii = array.length; i < ii; i++) if (array[i] === item) {
  13840. return array.push(array.splice(i, 1)[0]);
  13841. }
  13842. }
  13843. function cacher(f, scope, postprocessor) {
  13844. function newf() {
  13845. var arg = Array.prototype.slice.call(arguments, 0),
  13846. args = arg.join("\u2400"),
  13847. cache = newf.cache = newf.cache || {},
  13848. count = newf.count = newf.count || [];
  13849. if (cache[has](args)) {
  13850. repush(count, args);
  13851. return postprocessor ? postprocessor(cache[args]) : cache[args];
  13852. }
  13853. count.length >= 1e3 && delete cache[count.shift()];
  13854. count.push(args);
  13855. cache[args] = f.apply(scope, arg);
  13856. return postprocessor ? postprocessor(cache[args]) : cache[args];
  13857. }
  13858. return newf;
  13859. }
  13860. Snap._.cacher = cacher;
  13861. function angle(x1, y1, x2, y2, x3, y3) {
  13862. if (x3 == null) {
  13863. var x = x1 - x2,
  13864. y = y1 - y2;
  13865. if (!x && !y) {
  13866. return 0;
  13867. }
  13868. return (180 + math.atan2(-y, -x) * 180 / PI + 360) % 360;
  13869. } else {
  13870. return angle(x1, y1, x3, y3) - angle(x2, y2, x3, y3);
  13871. }
  13872. }
  13873. function rad(deg) {
  13874. return deg % 360 * PI / 180;
  13875. }
  13876. function deg(rad) {
  13877. return rad * 180 / PI % 360;
  13878. }
  13879. function x_y() {
  13880. return this.x + S + this.y;
  13881. }
  13882. function x_y_w_h() {
  13883. return this.x + S + this.y + S + this.width + " \xd7 " + this.height;
  13884. }
  13885. /*\
  13886. * Snap.rad
  13887. [ method ]
  13888. **
  13889. * Transform angle to radians
  13890. - deg (number) angle in degrees
  13891. = (number) angle in radians
  13892. \*/
  13893. Snap.rad = rad;
  13894. /*\
  13895. * Snap.deg
  13896. [ method ]
  13897. **
  13898. * Transform angle to degrees
  13899. - rad (number) angle in radians
  13900. = (number) angle in degrees
  13901. \*/
  13902. Snap.deg = deg;
  13903. /*\
  13904. * Snap.angle
  13905. [ method ]
  13906. **
  13907. * Returns an angle between two or three points
  13908. > Parameters
  13909. - x1 (number) x coord of first point
  13910. - y1 (number) y coord of first point
  13911. - x2 (number) x coord of second point
  13912. - y2 (number) y coord of second point
  13913. - x3 (number) #optional x coord of third point
  13914. - y3 (number) #optional y coord of third point
  13915. = (number) angle in degrees
  13916. \*/
  13917. Snap.angle = angle;
  13918. /*\
  13919. * Snap.is
  13920. [ method ]
  13921. **
  13922. * Handy replacement for the `typeof` operator
  13923. - o (…) any object or primitive
  13924. - type (string) name of the type, e.g., `string`, `function`, `number`, etc.
  13925. = (boolean) `true` if given value is of given type
  13926. \*/
  13927. Snap.is = is;
  13928. /*\
  13929. * Snap.snapTo
  13930. [ method ]
  13931. **
  13932. * Snaps given value to given grid
  13933. - values (array|number) given array of values or step of the grid
  13934. - value (number) value to adjust
  13935. - tolerance (number) #optional maximum distance to the target value that would trigger the snap. Default is `10`.
  13936. = (number) adjusted value
  13937. \*/
  13938. Snap.snapTo = function (values, value, tolerance) {
  13939. tolerance = is(tolerance, "finite") ? tolerance : 10;
  13940. if (is(values, "array")) {
  13941. var i = values.length;
  13942. while (i--) if (abs(values[i] - value) <= tolerance) {
  13943. return values[i];
  13944. }
  13945. } else {
  13946. values = +values;
  13947. var rem = value % values;
  13948. if (rem < tolerance) {
  13949. return value - rem;
  13950. }
  13951. if (rem > values - tolerance) {
  13952. return value - rem + values;
  13953. }
  13954. }
  13955. return value;
  13956. };
  13957. // Colour
  13958. /*\
  13959. * Snap.getRGB
  13960. [ method ]
  13961. **
  13962. * Parses color string as RGB object
  13963. - color (string) color string in one of the following formats:
  13964. # <ul>
  13965. # <li>Color name (<code>red</code>, <code>green</code>, <code>cornflowerblue</code>, etc)</li>
  13966. # <li>#••• — shortened HTML color: (<code>#000</code>, <code>#fc0</code>, etc.)</li>
  13967. # <li>#•••••• — full length HTML color: (<code>#000000</code>, <code>#bd2300</code>)</li>
  13968. # <li>rgb(•••, •••, •••) — red, green and blue channels values: (<code>rgb(200,&nbsp;100,&nbsp;0)</code>)</li>
  13969. # <li>rgba(•••, •••, •••, •••) — also with opacity</li>
  13970. # <li>rgb(•••%, •••%, •••%) — same as above, but in %: (<code>rgb(100%,&nbsp;175%,&nbsp;0%)</code>)</li>
  13971. # <li>rgba(•••%, •••%, •••%, •••%) — also with opacity</li>
  13972. # <li>hsb(•••, •••, •••) — hue, saturation and brightness values: (<code>hsb(0.5,&nbsp;0.25,&nbsp;1)</code>)</li>
  13973. # <li>hsba(•••, •••, •••, •••) — also with opacity</li>
  13974. # <li>hsb(•••%, •••%, •••%) — same as above, but in %</li>
  13975. # <li>hsba(•••%, •••%, •••%, •••%) — also with opacity</li>
  13976. # <li>hsl(•••, •••, •••) — hue, saturation and luminosity values: (<code>hsb(0.5,&nbsp;0.25,&nbsp;0.5)</code>)</li>
  13977. # <li>hsla(•••, •••, •••, •••) — also with opacity</li>
  13978. # <li>hsl(•••%, •••%, •••%) — same as above, but in %</li>
  13979. # <li>hsla(•••%, •••%, •••%, •••%) — also with opacity</li>
  13980. # </ul>
  13981. * Note that `%` can be used any time: `rgb(20%, 255, 50%)`.
  13982. = (object) RGB object in the following format:
  13983. o {
  13984. o r (number) red,
  13985. o g (number) green,
  13986. o b (number) blue,
  13987. o hex (string) color in HTML/CSS format: #••••••,
  13988. o error (boolean) true if string can't be parsed
  13989. o }
  13990. \*/
  13991. Snap.getRGB = cacher(function (colour) {
  13992. if (!colour || !!((colour = Str(colour)).indexOf("-") + 1)) {
  13993. return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: rgbtoString};
  13994. }
  13995. if (colour == "none") {
  13996. return {r: -1, g: -1, b: -1, hex: "none", toString: rgbtoString};
  13997. }
  13998. !(hsrg[has](colour.toLowerCase().substring(0, 2)) || colour.charAt() == "#") && (colour = toHex(colour));
  13999. if (!colour) {
  14000. return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: rgbtoString};
  14001. }
  14002. var res,
  14003. red,
  14004. green,
  14005. blue,
  14006. opacity,
  14007. t,
  14008. values,
  14009. rgb = colour.match(colourRegExp);
  14010. if (rgb) {
  14011. if (rgb[2]) {
  14012. blue = toInt(rgb[2].substring(5), 16);
  14013. green = toInt(rgb[2].substring(3, 5), 16);
  14014. red = toInt(rgb[2].substring(1, 3), 16);
  14015. }
  14016. if (rgb[3]) {
  14017. blue = toInt((t = rgb[3].charAt(3)) + t, 16);
  14018. green = toInt((t = rgb[3].charAt(2)) + t, 16);
  14019. red = toInt((t = rgb[3].charAt(1)) + t, 16);
  14020. }
  14021. if (rgb[4]) {
  14022. values = rgb[4].split(commaSpaces);
  14023. red = toFloat(values[0]);
  14024. values[0].slice(-1) == "%" && (red *= 2.55);
  14025. green = toFloat(values[1]);
  14026. values[1].slice(-1) == "%" && (green *= 2.55);
  14027. blue = toFloat(values[2]);
  14028. values[2].slice(-1) == "%" && (blue *= 2.55);
  14029. rgb[1].toLowerCase().slice(0, 4) == "rgba" && (opacity = toFloat(values[3]));
  14030. values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
  14031. }
  14032. if (rgb[5]) {
  14033. values = rgb[5].split(commaSpaces);
  14034. red = toFloat(values[0]);
  14035. values[0].slice(-1) == "%" && (red /= 100);
  14036. green = toFloat(values[1]);
  14037. values[1].slice(-1) == "%" && (green /= 100);
  14038. blue = toFloat(values[2]);
  14039. values[2].slice(-1) == "%" && (blue /= 100);
  14040. (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);
  14041. rgb[1].toLowerCase().slice(0, 4) == "hsba" && (opacity = toFloat(values[3]));
  14042. values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
  14043. return Snap.hsb2rgb(red, green, blue, opacity);
  14044. }
  14045. if (rgb[6]) {
  14046. values = rgb[6].split(commaSpaces);
  14047. red = toFloat(values[0]);
  14048. values[0].slice(-1) == "%" && (red /= 100);
  14049. green = toFloat(values[1]);
  14050. values[1].slice(-1) == "%" && (green /= 100);
  14051. blue = toFloat(values[2]);
  14052. values[2].slice(-1) == "%" && (blue /= 100);
  14053. (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);
  14054. rgb[1].toLowerCase().slice(0, 4) == "hsla" && (opacity = toFloat(values[3]));
  14055. values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
  14056. return Snap.hsl2rgb(red, green, blue, opacity);
  14057. }
  14058. red = mmin(math.round(red), 255);
  14059. green = mmin(math.round(green), 255);
  14060. blue = mmin(math.round(blue), 255);
  14061. opacity = mmin(mmax(opacity, 0), 1);
  14062. rgb = {r: red, g: green, b: blue, toString: rgbtoString};
  14063. rgb.hex = "#" + (16777216 | blue | (green << 8) | (red << 16)).toString(16).slice(1);
  14064. rgb.opacity = is(opacity, "finite") ? opacity : 1;
  14065. return rgb;
  14066. }
  14067. return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: rgbtoString};
  14068. }, Snap);
  14069. // SIERRA It seems odd that the following 3 conversion methods are not expressed as .this2that(), like the others.
  14070. /*\
  14071. * Snap.hsb
  14072. [ method ]
  14073. **
  14074. * Converts HSB values to a hex representation of the color
  14075. - h (number) hue
  14076. - s (number) saturation
  14077. - b (number) value or brightness
  14078. = (string) hex representation of the color
  14079. \*/
  14080. Snap.hsb = cacher(function (h, s, b) {
  14081. return Snap.hsb2rgb(h, s, b).hex;
  14082. });
  14083. /*\
  14084. * Snap.hsl
  14085. [ method ]
  14086. **
  14087. * Converts HSL values to a hex representation of the color
  14088. - h (number) hue
  14089. - s (number) saturation
  14090. - l (number) luminosity
  14091. = (string) hex representation of the color
  14092. \*/
  14093. Snap.hsl = cacher(function (h, s, l) {
  14094. return Snap.hsl2rgb(h, s, l).hex;
  14095. });
  14096. /*\
  14097. * Snap.rgb
  14098. [ method ]
  14099. **
  14100. * Converts RGB values to a hex representation of the color
  14101. - r (number) red
  14102. - g (number) green
  14103. - b (number) blue
  14104. = (string) hex representation of the color
  14105. \*/
  14106. Snap.rgb = cacher(function (r, g, b, o) {
  14107. if (is(o, "finite")) {
  14108. var round = math.round;
  14109. return "rgba(" + [round(r), round(g), round(b), +o.toFixed(2)] + ")";
  14110. }
  14111. return "#" + (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1);
  14112. });
  14113. var toHex = function (color) {
  14114. var i = glob.doc.getElementsByTagName("head")[0] || glob.doc.getElementsByTagName("svg")[0],
  14115. red = "rgb(255, 0, 0)";
  14116. toHex = cacher(function (color) {
  14117. if (color.toLowerCase() == "red") {
  14118. return red;
  14119. }
  14120. i.style.color = red;
  14121. i.style.color = color;
  14122. var out = glob.doc.defaultView.getComputedStyle(i, E).getPropertyValue("color");
  14123. return out == red ? null : out;
  14124. });
  14125. return toHex(color);
  14126. },
  14127. hsbtoString = function () {
  14128. return "hsb(" + [this.h, this.s, this.b] + ")";
  14129. },
  14130. hsltoString = function () {
  14131. return "hsl(" + [this.h, this.s, this.l] + ")";
  14132. },
  14133. rgbtoString = function () {
  14134. return this.opacity == 1 || this.opacity == null ?
  14135. this.hex :
  14136. "rgba(" + [this.r, this.g, this.b, this.opacity] + ")";
  14137. },
  14138. prepareRGB = function (r, g, b) {
  14139. if (g == null && is(r, "object") && "r" in r && "g" in r && "b" in r) {
  14140. b = r.b;
  14141. g = r.g;
  14142. r = r.r;
  14143. }
  14144. if (g == null && is(r, string)) {
  14145. var clr = Snap.getRGB(r);
  14146. r = clr.r;
  14147. g = clr.g;
  14148. b = clr.b;
  14149. }
  14150. if (r > 1 || g > 1 || b > 1) {
  14151. r /= 255;
  14152. g /= 255;
  14153. b /= 255;
  14154. }
  14155. return [r, g, b];
  14156. },
  14157. packageRGB = function (r, g, b, o) {
  14158. r = math.round(r * 255);
  14159. g = math.round(g * 255);
  14160. b = math.round(b * 255);
  14161. var rgb = {
  14162. r: r,
  14163. g: g,
  14164. b: b,
  14165. opacity: is(o, "finite") ? o : 1,
  14166. hex: Snap.rgb(r, g, b),
  14167. toString: rgbtoString
  14168. };
  14169. is(o, "finite") && (rgb.opacity = o);
  14170. return rgb;
  14171. };
  14172. // SIERRA Clarify if Snap does not support consolidated HSLA/RGBA colors. E.g., can you specify a semi-transparent value for Snap.filter.shadow()?
  14173. /*\
  14174. * Snap.color
  14175. [ method ]
  14176. **
  14177. * Parses the color string and returns an object featuring the color's component values
  14178. - clr (string) color string in one of the supported formats (see @Snap.getRGB)
  14179. = (object) Combined RGB/HSB object in the following format:
  14180. o {
  14181. o r (number) red,
  14182. o g (number) green,
  14183. o b (number) blue,
  14184. o hex (string) color in HTML/CSS format: #••••••,
  14185. o error (boolean) `true` if string can't be parsed,
  14186. o h (number) hue,
  14187. o s (number) saturation,
  14188. o v (number) value (brightness),
  14189. o l (number) lightness
  14190. o }
  14191. \*/
  14192. Snap.color = function (clr) {
  14193. var rgb;
  14194. if (is(clr, "object") && "h" in clr && "s" in clr && "b" in clr) {
  14195. rgb = Snap.hsb2rgb(clr);
  14196. clr.r = rgb.r;
  14197. clr.g = rgb.g;
  14198. clr.b = rgb.b;
  14199. clr.opacity = 1;
  14200. clr.hex = rgb.hex;
  14201. } else if (is(clr, "object") && "h" in clr && "s" in clr && "l" in clr) {
  14202. rgb = Snap.hsl2rgb(clr);
  14203. clr.r = rgb.r;
  14204. clr.g = rgb.g;
  14205. clr.b = rgb.b;
  14206. clr.opacity = 1;
  14207. clr.hex = rgb.hex;
  14208. } else {
  14209. if (is(clr, "string")) {
  14210. clr = Snap.getRGB(clr);
  14211. }
  14212. if (is(clr, "object") && "r" in clr && "g" in clr && "b" in clr && !("error" in clr)) {
  14213. rgb = Snap.rgb2hsl(clr);
  14214. clr.h = rgb.h;
  14215. clr.s = rgb.s;
  14216. clr.l = rgb.l;
  14217. rgb = Snap.rgb2hsb(clr);
  14218. clr.v = rgb.b;
  14219. } else {
  14220. clr = {hex: "none"};
  14221. clr.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1;
  14222. clr.error = 1;
  14223. }
  14224. }
  14225. clr.toString = rgbtoString;
  14226. return clr;
  14227. };
  14228. /*\
  14229. * Snap.hsb2rgb
  14230. [ method ]
  14231. **
  14232. * Converts HSB values to an RGB object
  14233. - h (number) hue
  14234. - s (number) saturation
  14235. - v (number) value or brightness
  14236. = (object) RGB object in the following format:
  14237. o {
  14238. o r (number) red,
  14239. o g (number) green,
  14240. o b (number) blue,
  14241. o hex (string) color in HTML/CSS format: #••••••
  14242. o }
  14243. \*/
  14244. Snap.hsb2rgb = function (h, s, v, o) {
  14245. if (is(h, "object") && "h" in h && "s" in h && "b" in h) {
  14246. v = h.b;
  14247. s = h.s;
  14248. h = h.h;
  14249. o = h.o;
  14250. }
  14251. h *= 360;
  14252. var R, G, B, X, C;
  14253. h = (h % 360) / 60;
  14254. C = v * s;
  14255. X = C * (1 - abs(h % 2 - 1));
  14256. R = G = B = v - C;
  14257. h = ~~h;
  14258. R += [C, X, 0, 0, X, C][h];
  14259. G += [X, C, C, X, 0, 0][h];
  14260. B += [0, 0, X, C, C, X][h];
  14261. return packageRGB(R, G, B, o);
  14262. };
  14263. /*\
  14264. * Snap.hsl2rgb
  14265. [ method ]
  14266. **
  14267. * Converts HSL values to an RGB object
  14268. - h (number) hue
  14269. - s (number) saturation
  14270. - l (number) luminosity
  14271. = (object) RGB object in the following format:
  14272. o {
  14273. o r (number) red,
  14274. o g (number) green,
  14275. o b (number) blue,
  14276. o hex (string) color in HTML/CSS format: #••••••
  14277. o }
  14278. \*/
  14279. Snap.hsl2rgb = function (h, s, l, o) {
  14280. if (is(h, "object") && "h" in h && "s" in h && "l" in h) {
  14281. l = h.l;
  14282. s = h.s;
  14283. h = h.h;
  14284. }
  14285. if (h > 1 || s > 1 || l > 1) {
  14286. h /= 360;
  14287. s /= 100;
  14288. l /= 100;
  14289. }
  14290. h *= 360;
  14291. var R, G, B, X, C;
  14292. h = (h % 360) / 60;
  14293. C = 2 * s * (l < .5 ? l : 1 - l);
  14294. X = C * (1 - abs(h % 2 - 1));
  14295. R = G = B = l - C / 2;
  14296. h = ~~h;
  14297. R += [C, X, 0, 0, X, C][h];
  14298. G += [X, C, C, X, 0, 0][h];
  14299. B += [0, 0, X, C, C, X][h];
  14300. return packageRGB(R, G, B, o);
  14301. };
  14302. /*\
  14303. * Snap.rgb2hsb
  14304. [ method ]
  14305. **
  14306. * Converts RGB values to an HSB object
  14307. - r (number) red
  14308. - g (number) green
  14309. - b (number) blue
  14310. = (object) HSB object in the following format:
  14311. o {
  14312. o h (number) hue,
  14313. o s (number) saturation,
  14314. o b (number) brightness
  14315. o }
  14316. \*/
  14317. Snap.rgb2hsb = function (r, g, b) {
  14318. b = prepareRGB(r, g, b);
  14319. r = b[0];
  14320. g = b[1];
  14321. b = b[2];
  14322. var H, S, V, C;
  14323. V = mmax(r, g, b);
  14324. C = V - mmin(r, g, b);
  14325. H = (C == 0 ? null :
  14326. V == r ? (g - b) / C :
  14327. V == g ? (b - r) / C + 2 :
  14328. (r - g) / C + 4
  14329. );
  14330. H = ((H + 360) % 6) * 60 / 360;
  14331. S = C == 0 ? 0 : C / V;
  14332. return {h: H, s: S, b: V, toString: hsbtoString};
  14333. };
  14334. /*\
  14335. * Snap.rgb2hsl
  14336. [ method ]
  14337. **
  14338. * Converts RGB values to an HSL object
  14339. - r (number) red
  14340. - g (number) green
  14341. - b (number) blue
  14342. = (object) HSL object in the following format:
  14343. o {
  14344. o h (number) hue,
  14345. o s (number) saturation,
  14346. o l (number) luminosity
  14347. o }
  14348. \*/
  14349. Snap.rgb2hsl = function (r, g, b) {
  14350. b = prepareRGB(r, g, b);
  14351. r = b[0];
  14352. g = b[1];
  14353. b = b[2];
  14354. var H, S, L, M, m, C;
  14355. M = mmax(r, g, b);
  14356. m = mmin(r, g, b);
  14357. C = M - m;
  14358. H = (C == 0 ? null :
  14359. M == r ? (g - b) / C :
  14360. M == g ? (b - r) / C + 2 :
  14361. (r - g) / C + 4);
  14362. H = ((H + 360) % 6) * 60 / 360;
  14363. L = (M + m) / 2;
  14364. S = (C == 0 ? 0 :
  14365. L < .5 ? C / (2 * L) :
  14366. C / (2 - 2 * L));
  14367. return {h: H, s: S, l: L, toString: hsltoString};
  14368. };
  14369. // Transformations
  14370. // SIERRA Snap.parsePathString(): By _array of arrays,_ I assume you mean a format like this for two separate segments? [ ["M10,10","L90,90"], ["M90,10","L10,90"] ] Otherwise how is each command structured?
  14371. /*\
  14372. * Snap.parsePathString
  14373. [ method ]
  14374. **
  14375. * Utility method
  14376. **
  14377. * Parses given path string into an array of arrays of path segments
  14378. - pathString (string|array) path string or array of segments (in the last case it is returned straight away)
  14379. = (array) array of segments
  14380. \*/
  14381. Snap.parsePathString = function (pathString) {
  14382. if (!pathString) {
  14383. return null;
  14384. }
  14385. var pth = Snap.path(pathString);
  14386. if (pth.arr) {
  14387. return Snap.path.clone(pth.arr);
  14388. }
  14389. var paramCounts = {a: 7, c: 6, o: 2, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, u: 3, z: 0},
  14390. data = [];
  14391. if (is(pathString, "array") && is(pathString[0], "array")) { // rough assumption
  14392. data = Snap.path.clone(pathString);
  14393. }
  14394. if (!data.length) {
  14395. Str(pathString).replace(pathCommand, function (a, b, c) {
  14396. var params = [],
  14397. name = b.toLowerCase();
  14398. c.replace(pathValues, function (a, b) {
  14399. b && params.push(+b);
  14400. });
  14401. if (name == "m" && params.length > 2) {
  14402. data.push([b].concat(params.splice(0, 2)));
  14403. name = "l";
  14404. b = b == "m" ? "l" : "L";
  14405. }
  14406. if (name == "o" && params.length == 1) {
  14407. data.push([b, params[0]]);
  14408. }
  14409. if (name == "r") {
  14410. data.push([b].concat(params));
  14411. } else while (params.length >= paramCounts[name]) {
  14412. data.push([b].concat(params.splice(0, paramCounts[name])));
  14413. if (!paramCounts[name]) {
  14414. break;
  14415. }
  14416. }
  14417. });
  14418. }
  14419. data.toString = Snap.path.toString;
  14420. pth.arr = Snap.path.clone(data);
  14421. return data;
  14422. };
  14423. /*\
  14424. * Snap.parseTransformString
  14425. [ method ]
  14426. **
  14427. * Utility method
  14428. **
  14429. * Parses given transform string into an array of transformations
  14430. - TString (string|array) transform string or array of transformations (in the last case it is returned straight away)
  14431. = (array) array of transformations
  14432. \*/
  14433. var parseTransformString = Snap.parseTransformString = function (TString) {
  14434. if (!TString) {
  14435. return null;
  14436. }
  14437. var paramCounts = {r: 3, s: 4, t: 2, m: 6},
  14438. data = [];
  14439. if (is(TString, "array") && is(TString[0], "array")) { // rough assumption
  14440. data = Snap.path.clone(TString);
  14441. }
  14442. if (!data.length) {
  14443. Str(TString).replace(tCommand, function (a, b, c) {
  14444. var params = [],
  14445. name = b.toLowerCase();
  14446. c.replace(pathValues, function (a, b) {
  14447. b && params.push(+b);
  14448. });
  14449. data.push([b].concat(params));
  14450. });
  14451. }
  14452. data.toString = Snap.path.toString;
  14453. return data;
  14454. };
  14455. function svgTransform2string(tstr) {
  14456. var res = [];
  14457. tstr = tstr.replace(/(?:^|\s)(\w+)\(([^)]+)\)/g, function (all, name, params) {
  14458. params = params.split(/\s*,\s*|\s+/);
  14459. if (name == "rotate" && params.length == 1) {
  14460. params.push(0, 0);
  14461. }
  14462. if (name == "scale") {
  14463. if (params.length > 2) {
  14464. params = params.slice(0, 2);
  14465. } else if (params.length == 2) {
  14466. params.push(0, 0);
  14467. }
  14468. if (params.length == 1) {
  14469. params.push(params[0], 0, 0);
  14470. }
  14471. }
  14472. if (name == "skewX") {
  14473. res.push(["m", 1, 0, math.tan(rad(params[0])), 1, 0, 0]);
  14474. } else if (name == "skewY") {
  14475. res.push(["m", 1, math.tan(rad(params[0])), 0, 1, 0, 0]);
  14476. } else {
  14477. res.push([name.charAt(0)].concat(params));
  14478. }
  14479. return all;
  14480. });
  14481. return res;
  14482. }
  14483. Snap._.svgTransform2string = svgTransform2string;
  14484. Snap._.rgTransform = /^[a-z][\s]*-?\.?\d/i;
  14485. function transform2matrix(tstr, bbox) {
  14486. var tdata = parseTransformString(tstr),
  14487. m = new Snap.Matrix;
  14488. if (tdata) {
  14489. for (var i = 0, ii = tdata.length; i < ii; i++) {
  14490. var t = tdata[i],
  14491. tlen = t.length,
  14492. command = Str(t[0]).toLowerCase(),
  14493. absolute = t[0] != command,
  14494. inver = absolute ? m.invert() : 0,
  14495. x1,
  14496. y1,
  14497. x2,
  14498. y2,
  14499. bb;
  14500. if (command == "t" && tlen == 2){
  14501. m.translate(t[1], 0);
  14502. } else if (command == "t" && tlen == 3) {
  14503. if (absolute) {
  14504. x1 = inver.x(0, 0);
  14505. y1 = inver.y(0, 0);
  14506. x2 = inver.x(t[1], t[2]);
  14507. y2 = inver.y(t[1], t[2]);
  14508. m.translate(x2 - x1, y2 - y1);
  14509. } else {
  14510. m.translate(t[1], t[2]);
  14511. }
  14512. } else if (command == "r") {
  14513. if (tlen == 2) {
  14514. bb = bb || bbox;
  14515. m.rotate(t[1], bb.x + bb.width / 2, bb.y + bb.height / 2);
  14516. } else if (tlen == 4) {
  14517. if (absolute) {
  14518. x2 = inver.x(t[2], t[3]);
  14519. y2 = inver.y(t[2], t[3]);
  14520. m.rotate(t[1], x2, y2);
  14521. } else {
  14522. m.rotate(t[1], t[2], t[3]);
  14523. }
  14524. }
  14525. } else if (command == "s") {
  14526. if (tlen == 2 || tlen == 3) {
  14527. bb = bb || bbox;
  14528. m.scale(t[1], t[tlen - 1], bb.x + bb.width / 2, bb.y + bb.height / 2);
  14529. } else if (tlen == 4) {
  14530. if (absolute) {
  14531. x2 = inver.x(t[2], t[3]);
  14532. y2 = inver.y(t[2], t[3]);
  14533. m.scale(t[1], t[1], x2, y2);
  14534. } else {
  14535. m.scale(t[1], t[1], t[2], t[3]);
  14536. }
  14537. } else if (tlen == 5) {
  14538. if (absolute) {
  14539. x2 = inver.x(t[3], t[4]);
  14540. y2 = inver.y(t[3], t[4]);
  14541. m.scale(t[1], t[2], x2, y2);
  14542. } else {
  14543. m.scale(t[1], t[2], t[3], t[4]);
  14544. }
  14545. }
  14546. } else if (command == "m" && tlen == 7) {
  14547. m.add(t[1], t[2], t[3], t[4], t[5], t[6]);
  14548. }
  14549. }
  14550. }
  14551. return m;
  14552. }
  14553. Snap._.transform2matrix = transform2matrix;
  14554. Snap._unit2px = unit2px;
  14555. var contains = glob.doc.contains || glob.doc.compareDocumentPosition ?
  14556. function (a, b) {
  14557. var adown = a.nodeType == 9 ? a.documentElement : a,
  14558. bup = b && b.parentNode;
  14559. return a == bup || !!(bup && bup.nodeType == 1 && (
  14560. adown.contains ?
  14561. adown.contains(bup) :
  14562. a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16
  14563. ));
  14564. } :
  14565. function (a, b) {
  14566. if (b) {
  14567. while (b) {
  14568. b = b.parentNode;
  14569. if (b == a) {
  14570. return true;
  14571. }
  14572. }
  14573. }
  14574. return false;
  14575. };
  14576. function getSomeDefs(el) {
  14577. var p = (el.node.ownerSVGElement && wrap(el.node.ownerSVGElement)) ||
  14578. (el.node.parentNode && wrap(el.node.parentNode)) ||
  14579. Snap.select("svg") ||
  14580. Snap(0, 0),
  14581. pdefs = p.select("defs"),
  14582. defs = pdefs == null ? false : pdefs.node;
  14583. if (!defs) {
  14584. defs = make("defs", p.node).node;
  14585. }
  14586. return defs;
  14587. }
  14588. function getSomeSVG(el) {
  14589. return el.node.ownerSVGElement && wrap(el.node.ownerSVGElement) || Snap.select("svg");
  14590. }
  14591. Snap._.getSomeDefs = getSomeDefs;
  14592. Snap._.getSomeSVG = getSomeSVG;
  14593. function unit2px(el, name, value) {
  14594. var svg = getSomeSVG(el).node,
  14595. out = {},
  14596. mgr = svg.querySelector(".svg---mgr");
  14597. if (!mgr) {
  14598. mgr = $("rect");
  14599. $(mgr, {x: -9e9, y: -9e9, width: 10, height: 10, "class": "svg---mgr", fill: "none"});
  14600. svg.appendChild(mgr);
  14601. }
  14602. function getW(val) {
  14603. if (val == null) {
  14604. return E;
  14605. }
  14606. if (val == +val) {
  14607. return val;
  14608. }
  14609. $(mgr, {width: val});
  14610. try {
  14611. return mgr.getBBox().width;
  14612. } catch (e) {
  14613. return 0;
  14614. }
  14615. }
  14616. function getH(val) {
  14617. if (val == null) {
  14618. return E;
  14619. }
  14620. if (val == +val) {
  14621. return val;
  14622. }
  14623. $(mgr, {height: val});
  14624. try {
  14625. return mgr.getBBox().height;
  14626. } catch (e) {
  14627. return 0;
  14628. }
  14629. }
  14630. function set(nam, f) {
  14631. if (name == null) {
  14632. out[nam] = f(el.attr(nam) || 0);
  14633. } else if (nam == name) {
  14634. out = f(value == null ? el.attr(nam) || 0 : value);
  14635. }
  14636. }
  14637. switch (el.type) {
  14638. case "rect":
  14639. set("rx", getW);
  14640. set("ry", getH);
  14641. case "image":
  14642. set("width", getW);
  14643. set("height", getH);
  14644. case "text":
  14645. set("x", getW);
  14646. set("y", getH);
  14647. break;
  14648. case "circle":
  14649. set("cx", getW);
  14650. set("cy", getH);
  14651. set("r", getW);
  14652. break;
  14653. case "ellipse":
  14654. set("cx", getW);
  14655. set("cy", getH);
  14656. set("rx", getW);
  14657. set("ry", getH);
  14658. break;
  14659. case "line":
  14660. set("x1", getW);
  14661. set("x2", getW);
  14662. set("y1", getH);
  14663. set("y2", getH);
  14664. break;
  14665. case "marker":
  14666. set("refX", getW);
  14667. set("markerWidth", getW);
  14668. set("refY", getH);
  14669. set("markerHeight", getH);
  14670. break;
  14671. case "radialGradient":
  14672. set("fx", getW);
  14673. set("fy", getH);
  14674. break;
  14675. case "tspan":
  14676. set("dx", getW);
  14677. set("dy", getH);
  14678. break;
  14679. default:
  14680. set(name, getW);
  14681. }
  14682. svg.removeChild(mgr);
  14683. return out;
  14684. }
  14685. /*\
  14686. * Snap.select
  14687. [ method ]
  14688. **
  14689. * Wraps a DOM element specified by CSS selector as @Element
  14690. - query (string) CSS selector of the element
  14691. = (Element) the current element
  14692. \*/
  14693. Snap.select = function (query) {
  14694. query = Str(query).replace(/([^\\]):/g, "$1\\:");
  14695. return wrap(glob.doc.querySelector(query));
  14696. };
  14697. /*\
  14698. * Snap.selectAll
  14699. [ method ]
  14700. **
  14701. * Wraps DOM elements specified by CSS selector as set or array of @Element
  14702. - query (string) CSS selector of the element
  14703. = (Element) the current element
  14704. \*/
  14705. Snap.selectAll = function (query) {
  14706. var nodelist = glob.doc.querySelectorAll(query),
  14707. set = (Snap.set || Array)();
  14708. for (var i = 0; i < nodelist.length; i++) {
  14709. set.push(wrap(nodelist[i]));
  14710. }
  14711. return set;
  14712. };
  14713. function add2group(list) {
  14714. if (!is(list, "array")) {
  14715. list = Array.prototype.slice.call(arguments, 0);
  14716. }
  14717. var i = 0,
  14718. j = 0,
  14719. node = this.node;
  14720. while (this[i]) delete this[i++];
  14721. for (i = 0; i < list.length; i++) {
  14722. if (list[i].type == "set") {
  14723. list[i].forEach(function (el) {
  14724. node.appendChild(el.node);
  14725. });
  14726. } else {
  14727. node.appendChild(list[i].node);
  14728. }
  14729. }
  14730. var children = node.childNodes;
  14731. for (i = 0; i < children.length; i++) {
  14732. this[j++] = wrap(children[i]);
  14733. }
  14734. return this;
  14735. }
  14736. // Hub garbage collector every 10s
  14737. setInterval(function () {
  14738. for (var key in hub) if (hub[has](key)) {
  14739. var el = hub[key],
  14740. node = el.node;
  14741. if (el.type != "svg" && !node.ownerSVGElement || el.type == "svg" && (!node.parentNode || "ownerSVGElement" in node.parentNode && !node.ownerSVGElement)) {
  14742. delete hub[key];
  14743. }
  14744. }
  14745. }, 1e4);
  14746. function Element(el) {
  14747. if (el.snap in hub) {
  14748. return hub[el.snap];
  14749. }
  14750. var svg;
  14751. try {
  14752. svg = el.ownerSVGElement;
  14753. } catch(e) {}
  14754. /*\
  14755. * Element.node
  14756. [ property (object) ]
  14757. **
  14758. * Gives you a reference to the DOM object, so you can assign event handlers or just mess around.
  14759. > Usage
  14760. | // draw a circle at coordinate 10,10 with radius of 10
  14761. | var c = paper.circle(10, 10, 10);
  14762. | c.node.onclick = function () {
  14763. | c.attr("fill", "red");
  14764. | };
  14765. \*/
  14766. this.node = el;
  14767. if (svg) {
  14768. this.paper = new Paper(svg);
  14769. }
  14770. /*\
  14771. * Element.type
  14772. [ property (string) ]
  14773. **
  14774. * SVG tag name of the given element.
  14775. \*/
  14776. this.type = el.tagName;
  14777. var id = this.id = ID(this);
  14778. this.anims = {};
  14779. this._ = {
  14780. transform: []
  14781. };
  14782. el.snap = id;
  14783. hub[id] = this;
  14784. if (this.type == "g") {
  14785. this.add = add2group;
  14786. }
  14787. if (this.type in {g: 1, mask: 1, pattern: 1, symbol: 1}) {
  14788. for (var method in Paper.prototype) if (Paper.prototype[has](method)) {
  14789. this[method] = Paper.prototype[method];
  14790. }
  14791. }
  14792. }
  14793. /*\
  14794. * Element.attr
  14795. [ method ]
  14796. **
  14797. * Gets or sets given attributes of the element.
  14798. **
  14799. - params (object) contains key-value pairs of attributes you want to set
  14800. * or
  14801. - param (string) name of the attribute
  14802. = (Element) the current element
  14803. * or
  14804. = (string) value of attribute
  14805. > Usage
  14806. | el.attr({
  14807. | fill: "#fc0",
  14808. | stroke: "#000",
  14809. | strokeWidth: 2, // CamelCase...
  14810. | "fill-opacity": 0.5, // or dash-separated names
  14811. | width: "*=2" // prefixed values
  14812. | });
  14813. | console.log(el.attr("fill")); // #fc0
  14814. * Prefixed values in format `"+=10"` supported. All four operations
  14815. * (`+`, `-`, `*` and `/`) could be used. Optionally you can use units for `+`
  14816. * and `-`: `"+=2em"`.
  14817. \*/
  14818. Element.prototype.attr = function (params, value) {
  14819. var el = this,
  14820. node = el.node;
  14821. if (!params) {
  14822. return el;
  14823. }
  14824. if (is(params, "string")) {
  14825. if (arguments.length > 1) {
  14826. var json = {};
  14827. json[params] = value;
  14828. params = json;
  14829. } else {
  14830. return eve("snap.util.getattr." + params, el).firstDefined();
  14831. }
  14832. }
  14833. for (var att in params) {
  14834. if (params[has](att)) {
  14835. eve("snap.util.attr." + att, el, params[att]);
  14836. }
  14837. }
  14838. return el;
  14839. };
  14840. /*\
  14841. * Snap.parse
  14842. [ method ]
  14843. **
  14844. * Parses SVG fragment and converts it into a @Fragment
  14845. **
  14846. - svg (string) SVG string
  14847. = (Fragment) the @Fragment
  14848. \*/
  14849. Snap.parse = function (svg) {
  14850. var f = glob.doc.createDocumentFragment(),
  14851. full = true,
  14852. div = glob.doc.createElement("div");
  14853. svg = Str(svg);
  14854. if (!svg.match(/^\s*<\s*svg(?:\s|>)/)) {
  14855. svg = "<svg>" + svg + "</svg>";
  14856. full = false;
  14857. }
  14858. div.innerHTML = svg;
  14859. svg = div.getElementsByTagName("svg")[0];
  14860. if (svg) {
  14861. if (full) {
  14862. f = svg;
  14863. } else {
  14864. while (svg.firstChild) {
  14865. f.appendChild(svg.firstChild);
  14866. }
  14867. div.innerHTML = E;
  14868. }
  14869. }
  14870. return new Fragment(f);
  14871. };
  14872. function Fragment(frag) {
  14873. this.node = frag;
  14874. }
  14875. // SIERRA Snap.fragment() could especially use a code example
  14876. /*\
  14877. * Snap.fragment
  14878. [ method ]
  14879. **
  14880. * Creates a DOM fragment from a given list of elements or strings
  14881. **
  14882. - varargs (…) SVG string
  14883. = (Fragment) the @Fragment
  14884. \*/
  14885. Snap.fragment = function () {
  14886. var args = Array.prototype.slice.call(arguments, 0),
  14887. f = glob.doc.createDocumentFragment();
  14888. for (var i = 0, ii = args.length; i < ii; i++) {
  14889. var item = args[i];
  14890. if (item.node && item.node.nodeType) {
  14891. f.appendChild(item.node);
  14892. }
  14893. if (item.nodeType) {
  14894. f.appendChild(item);
  14895. }
  14896. if (typeof item == "string") {
  14897. f.appendChild(Snap.parse(item).node);
  14898. }
  14899. }
  14900. return new Fragment(f);
  14901. };
  14902. function make(name, parent) {
  14903. var res = $(name);
  14904. parent.appendChild(res);
  14905. var el = wrap(res);
  14906. return el;
  14907. }
  14908. function Paper(w, h) {
  14909. var res,
  14910. desc,
  14911. defs,
  14912. proto = Paper.prototype;
  14913. if (w && w.tagName == "svg") {
  14914. if (w.snap in hub) {
  14915. return hub[w.snap];
  14916. }
  14917. var doc = w.ownerDocument;
  14918. res = new Element(w);
  14919. desc = w.getElementsByTagName("desc")[0];
  14920. defs = w.getElementsByTagName("defs")[0];
  14921. if (!desc) {
  14922. desc = $("desc");
  14923. desc.appendChild(doc.createTextNode("Created with Snap"));
  14924. res.node.appendChild(desc);
  14925. }
  14926. if (!defs) {
  14927. defs = $("defs");
  14928. res.node.appendChild(defs);
  14929. }
  14930. res.defs = defs;
  14931. for (var key in proto) if (proto[has](key)) {
  14932. res[key] = proto[key];
  14933. }
  14934. res.paper = res.root = res;
  14935. } else {
  14936. res = make("svg", glob.doc.body);
  14937. $(res.node, {
  14938. height: h,
  14939. version: 1.1,
  14940. width: w,
  14941. xmlns: xmlns
  14942. });
  14943. }
  14944. return res;
  14945. }
  14946. function wrap(dom) {
  14947. if (!dom) {
  14948. return dom;
  14949. }
  14950. if (dom instanceof Element || dom instanceof Fragment) {
  14951. return dom;
  14952. }
  14953. if (dom.tagName && dom.tagName.toLowerCase() == "svg") {
  14954. return new Paper(dom);
  14955. }
  14956. if (dom.tagName && dom.tagName.toLowerCase() == "object" && dom.type == "image/svg+xml") {
  14957. return new Paper(dom.contentDocument.getElementsByTagName("svg")[0]);
  14958. }
  14959. return new Element(dom);
  14960. }
  14961. Snap._.make = make;
  14962. Snap._.wrap = wrap;
  14963. /*\
  14964. * Paper.el
  14965. [ method ]
  14966. **
  14967. * Creates an element on paper with a given name and no attributes
  14968. **
  14969. - name (string) tag name
  14970. - attr (object) attributes
  14971. = (Element) the current element
  14972. > Usage
  14973. | var c = paper.circle(10, 10, 10); // is the same as...
  14974. | var c = paper.el("circle").attr({
  14975. | cx: 10,
  14976. | cy: 10,
  14977. | r: 10
  14978. | });
  14979. | // and the same as
  14980. | var c = paper.el("circle", {
  14981. | cx: 10,
  14982. | cy: 10,
  14983. | r: 10
  14984. | });
  14985. \*/
  14986. Paper.prototype.el = function (name, attr) {
  14987. var el = make(name, this.node);
  14988. attr && el.attr(attr);
  14989. return el;
  14990. };
  14991. // default
  14992. eve.on("snap.util.getattr", function () {
  14993. var att = eve.nt();
  14994. att = att.substring(att.lastIndexOf(".") + 1);
  14995. var css = att.replace(/[A-Z]/g, function (letter) {
  14996. return "-" + letter.toLowerCase();
  14997. });
  14998. if (cssAttr[has](css)) {
  14999. return this.node.ownerDocument.defaultView.getComputedStyle(this.node, null).getPropertyValue(css);
  15000. } else {
  15001. return $(this.node, att);
  15002. }
  15003. });
  15004. var cssAttr = {
  15005. "alignment-baseline": 0,
  15006. "baseline-shift": 0,
  15007. "clip": 0,
  15008. "clip-path": 0,
  15009. "clip-rule": 0,
  15010. "color": 0,
  15011. "color-interpolation": 0,
  15012. "color-interpolation-filters": 0,
  15013. "color-profile": 0,
  15014. "color-rendering": 0,
  15015. "cursor": 0,
  15016. "direction": 0,
  15017. "display": 0,
  15018. "dominant-baseline": 0,
  15019. "enable-background": 0,
  15020. "fill": 0,
  15021. "fill-opacity": 0,
  15022. "fill-rule": 0,
  15023. "filter": 0,
  15024. "flood-color": 0,
  15025. "flood-opacity": 0,
  15026. "font": 0,
  15027. "font-family": 0,
  15028. "font-size": 0,
  15029. "font-size-adjust": 0,
  15030. "font-stretch": 0,
  15031. "font-style": 0,
  15032. "font-variant": 0,
  15033. "font-weight": 0,
  15034. "glyph-orientation-horizontal": 0,
  15035. "glyph-orientation-vertical": 0,
  15036. "image-rendering": 0,
  15037. "kerning": 0,
  15038. "letter-spacing": 0,
  15039. "lighting-color": 0,
  15040. "marker": 0,
  15041. "marker-end": 0,
  15042. "marker-mid": 0,
  15043. "marker-start": 0,
  15044. "mask": 0,
  15045. "opacity": 0,
  15046. "overflow": 0,
  15047. "pointer-events": 0,
  15048. "shape-rendering": 0,
  15049. "stop-color": 0,
  15050. "stop-opacity": 0,
  15051. "stroke": 0,
  15052. "stroke-dasharray": 0,
  15053. "stroke-dashoffset": 0,
  15054. "stroke-linecap": 0,
  15055. "stroke-linejoin": 0,
  15056. "stroke-miterlimit": 0,
  15057. "stroke-opacity": 0,
  15058. "stroke-width": 0,
  15059. "text-anchor": 0,
  15060. "text-decoration": 0,
  15061. "text-rendering": 0,
  15062. "unicode-bidi": 0,
  15063. "visibility": 0,
  15064. "word-spacing": 0,
  15065. "writing-mode": 0
  15066. };
  15067. eve.on("snap.util.attr", function (value) {
  15068. var att = eve.nt(),
  15069. attr = {};
  15070. att = att.substring(att.lastIndexOf(".") + 1);
  15071. attr[att] = value;
  15072. var style = att.replace(/-(\w)/gi, function (all, letter) {
  15073. return letter.toUpperCase();
  15074. }),
  15075. css = att.replace(/[A-Z]/g, function (letter) {
  15076. return "-" + letter.toLowerCase();
  15077. });
  15078. if (cssAttr[has](css)) {
  15079. this.node.style[style] = value == null ? E : value;
  15080. } else {
  15081. $(this.node, attr);
  15082. }
  15083. });
  15084. (function (proto) {}(Paper.prototype));
  15085. // simple ajax
  15086. /*\
  15087. * Snap.ajax
  15088. [ method ]
  15089. **
  15090. * Simple implementation of Ajax
  15091. **
  15092. - url (string) URL
  15093. - postData (object|string) data for post request
  15094. - callback (function) callback
  15095. - scope (object) #optional scope of callback
  15096. * or
  15097. - url (string) URL
  15098. - callback (function) callback
  15099. - scope (object) #optional scope of callback
  15100. = (XMLHttpRequest) the XMLHttpRequest object, just in case
  15101. \*/
  15102. Snap.ajax = function (url, postData, callback, scope){
  15103. var req = new XMLHttpRequest,
  15104. id = ID();
  15105. if (req) {
  15106. if (is(postData, "function")) {
  15107. scope = callback;
  15108. callback = postData;
  15109. postData = null;
  15110. } else if (is(postData, "object")) {
  15111. var pd = [];
  15112. for (var key in postData) if (postData.hasOwnProperty(key)) {
  15113. pd.push(encodeURIComponent(key) + "=" + encodeURIComponent(postData[key]));
  15114. }
  15115. postData = pd.join("&");
  15116. }
  15117. req.open((postData ? "POST" : "GET"), url, true);
  15118. if (postData) {
  15119. req.setRequestHeader("X-Requested-With", "XMLHttpRequest");
  15120. req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  15121. }
  15122. if (callback) {
  15123. eve.once("snap.ajax." + id + ".0", callback);
  15124. eve.once("snap.ajax." + id + ".200", callback);
  15125. eve.once("snap.ajax." + id + ".304", callback);
  15126. }
  15127. req.onreadystatechange = function() {
  15128. if (req.readyState != 4) return;
  15129. eve("snap.ajax." + id + "." + req.status, scope, req);
  15130. };
  15131. if (req.readyState == 4) {
  15132. return req;
  15133. }
  15134. req.send(postData);
  15135. return req;
  15136. }
  15137. };
  15138. /*\
  15139. * Snap.load
  15140. [ method ]
  15141. **
  15142. * Loads external SVG file as a @Fragment (see @Snap.ajax for more advanced AJAX)
  15143. **
  15144. - url (string) URL
  15145. - callback (function) callback
  15146. - scope (object) #optional scope of callback
  15147. \*/
  15148. Snap.load = function (url, callback, scope) {
  15149. Snap.ajax(url, function (req) {
  15150. var f = Snap.parse(req.responseText);
  15151. scope ? callback.call(scope, f) : callback(f);
  15152. });
  15153. };
  15154. var getOffset = function (elem) {
  15155. var box = elem.getBoundingClientRect(),
  15156. doc = elem.ownerDocument,
  15157. body = doc.body,
  15158. docElem = doc.documentElement,
  15159. clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
  15160. top = box.top + (g.win.pageYOffset || docElem.scrollTop || body.scrollTop ) - clientTop,
  15161. left = box.left + (g.win.pageXOffset || docElem.scrollLeft || body.scrollLeft) - clientLeft;
  15162. return {
  15163. y: top,
  15164. x: left
  15165. };
  15166. };
  15167. /*\
  15168. * Snap.getElementByPoint
  15169. [ method ]
  15170. **
  15171. * Returns you topmost element under given point.
  15172. **
  15173. = (object) Snap element object
  15174. - x (number) x coordinate from the top left corner of the window
  15175. - y (number) y coordinate from the top left corner of the window
  15176. > Usage
  15177. | Snap.getElementByPoint(mouseX, mouseY).attr({stroke: "#f00"});
  15178. \*/
  15179. Snap.getElementByPoint = function (x, y) {
  15180. var paper = this,
  15181. svg = paper.canvas,
  15182. target = glob.doc.elementFromPoint(x, y);
  15183. if (glob.win.opera && target.tagName == "svg") {
  15184. var so = getOffset(target),
  15185. sr = target.createSVGRect();
  15186. sr.x = x - so.x;
  15187. sr.y = y - so.y;
  15188. sr.width = sr.height = 1;
  15189. var hits = target.getIntersectionList(sr, null);
  15190. if (hits.length) {
  15191. target = hits[hits.length - 1];
  15192. }
  15193. }
  15194. if (!target) {
  15195. return null;
  15196. }
  15197. return wrap(target);
  15198. };
  15199. /*\
  15200. * Snap.plugin
  15201. [ method ]
  15202. **
  15203. * Let you write plugins. You pass in a function with four arguments, like this:
  15204. | Snap.plugin(function (Snap, Element, Paper, global, Fragment) {
  15205. | Snap.newmethod = function () {};
  15206. | Element.prototype.newmethod = function () {};
  15207. | Paper.prototype.newmethod = function () {};
  15208. | });
  15209. * Inside the function you have access to all main objects (and their
  15210. * prototypes). This allow you to extend anything you want.
  15211. **
  15212. - f (function) your plugin body
  15213. \*/
  15214. Snap.plugin = function (f) {
  15215. f(Snap, Element, Paper, glob, Fragment);
  15216. };
  15217. glob.win.Snap = Snap;
  15218. return Snap;
  15219. }(window || this));
  15220. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  15221. //
  15222. // Licensed under the Apache License, Version 2.0 (the "License");
  15223. // you may not use this file except in compliance with the License.
  15224. // You may obtain a copy of the License at
  15225. //
  15226. // http://www.apache.org/licenses/LICENSE-2.0
  15227. //
  15228. // Unless required by applicable law or agreed to in writing, software
  15229. // distributed under the License is distributed on an "AS IS" BASIS,
  15230. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15231. // See the License for the specific language governing permissions and
  15232. // limitations under the License.
  15233. Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
  15234. var elproto = Element.prototype,
  15235. is = Snap.is,
  15236. Str = String,
  15237. unit2px = Snap._unit2px,
  15238. $ = Snap._.$,
  15239. make = Snap._.make,
  15240. getSomeDefs = Snap._.getSomeDefs,
  15241. has = "hasOwnProperty",
  15242. wrap = Snap._.wrap;
  15243. /*\
  15244. * Element.getBBox
  15245. [ method ]
  15246. **
  15247. * Returns the bounding box descriptor for the given element
  15248. **
  15249. = (object) bounding box descriptor:
  15250. o {
  15251. o cx: (number) x of the center,
  15252. o cy: (number) x of the center,
  15253. o h: (number) height,
  15254. o height: (number) height,
  15255. o path: (string) path command for the box,
  15256. o r0: (number) radius of a circle that fully encloses the box,
  15257. o r1: (number) radius of the smallest circle that can be enclosed,
  15258. o r2: (number) radius of the largest circle that can be enclosed,
  15259. o vb: (string) box as a viewbox command,
  15260. o w: (number) width,
  15261. o width: (number) width,
  15262. o x2: (number) x of the right side,
  15263. o x: (number) x of the left side,
  15264. o y2: (number) y of the bottom edge,
  15265. o y: (number) y of the top edge
  15266. o }
  15267. \*/
  15268. elproto.getBBox = function (isWithoutTransform) {
  15269. if (!Snap.Matrix || !Snap.path) {
  15270. return this.node.getBBox();
  15271. }
  15272. var el = this,
  15273. m = new Snap.Matrix;
  15274. if (el.removed) {
  15275. return Snap._.box();
  15276. }
  15277. while (el.type == "use") {
  15278. if (!isWithoutTransform) {
  15279. m = m.add(el.transform().localMatrix.translate(el.attr("x") || 0, el.attr("y") || 0));
  15280. }
  15281. if (el.original) {
  15282. el = el.original;
  15283. } else {
  15284. var href = el.attr("xlink:href");
  15285. el = el.original = el.node.ownerDocument.getElementById(href.substring(href.indexOf("#") + 1));
  15286. }
  15287. }
  15288. var _ = el._,
  15289. pathfinder = Snap.path.get[el.type] || Snap.path.get.deflt;
  15290. try {
  15291. if (isWithoutTransform) {
  15292. _.bboxwt = pathfinder ? Snap.path.getBBox(el.realPath = pathfinder(el)) : Snap._.box(el.node.getBBox());
  15293. return Snap._.box(_.bboxwt);
  15294. } else {
  15295. el.realPath = pathfinder(el);
  15296. el.matrix = el.transform().localMatrix;
  15297. _.bbox = Snap.path.getBBox(Snap.path.map(el.realPath, m.add(el.matrix)));
  15298. return Snap._.box(_.bbox);
  15299. }
  15300. } catch (e) {
  15301. // Firefox doesn’t give you bbox of hidden element
  15302. return Snap._.box();
  15303. }
  15304. };
  15305. var propString = function () {
  15306. return this.string;
  15307. };
  15308. function extractTransform(el, tstr) {
  15309. if (tstr == null) {
  15310. var doReturn = true;
  15311. if (el.type == "linearGradient" || el.type == "radialGradient") {
  15312. tstr = el.node.getAttribute("gradientTransform");
  15313. } else if (el.type == "pattern") {
  15314. tstr = el.node.getAttribute("patternTransform");
  15315. } else {
  15316. tstr = el.node.getAttribute("transform");
  15317. }
  15318. if (!tstr) {
  15319. return new Snap.Matrix;
  15320. }
  15321. tstr = Snap._.svgTransform2string(tstr);
  15322. } else {
  15323. if (!Snap._.rgTransform.test(tstr)) {
  15324. tstr = Snap._.svgTransform2string(tstr);
  15325. } else {
  15326. tstr = Str(tstr).replace(/\.{3}|\u2026/g, el._.transform || E);
  15327. }
  15328. if (is(tstr, "array")) {
  15329. tstr = Snap.path ? Snap.path.toString.call(tstr) : Str(tstr);
  15330. }
  15331. el._.transform = tstr;
  15332. }
  15333. var m = Snap._.transform2matrix(tstr, el.getBBox(1));
  15334. if (doReturn) {
  15335. return m;
  15336. } else {
  15337. el.matrix = m;
  15338. }
  15339. }
  15340. /*\
  15341. * Element.transform
  15342. [ method ]
  15343. **
  15344. * Gets or sets transformation of the element
  15345. **
  15346. - tstr (string) transform string in Snap or SVG format
  15347. = (Element) the current element
  15348. * or
  15349. = (object) transformation descriptor:
  15350. o {
  15351. o string (string) transform string,
  15352. o globalMatrix (Matrix) matrix of all transformations applied to element or its parents,
  15353. o localMatrix (Matrix) matrix of transformations applied only to the element,
  15354. o diffMatrix (Matrix) matrix of difference between global and local transformations,
  15355. o global (string) global transformation as string,
  15356. o local (string) local transformation as string,
  15357. o toString (function) returns `string` property
  15358. o }
  15359. \*/
  15360. elproto.transform = function (tstr) {
  15361. var _ = this._;
  15362. if (tstr == null) {
  15363. var papa = this,
  15364. global = new Snap.Matrix(this.node.getCTM()),
  15365. local = extractTransform(this),
  15366. ms = [local],
  15367. m = new Snap.Matrix,
  15368. i,
  15369. localString = local.toTransformString(),
  15370. string = Str(local) == Str(this.matrix) ?
  15371. Str(_.transform) : localString;
  15372. while (papa.type != "svg" && (papa = papa.parent())) {
  15373. ms.push(extractTransform(papa));
  15374. }
  15375. i = ms.length;
  15376. while (i--) {
  15377. m.add(ms[i]);
  15378. }
  15379. return {
  15380. string: string,
  15381. globalMatrix: global,
  15382. totalMatrix: m,
  15383. localMatrix: local,
  15384. diffMatrix: global.clone().add(local.invert()),
  15385. global: global.toTransformString(),
  15386. total: m.toTransformString(),
  15387. local: localString,
  15388. toString: propString
  15389. };
  15390. }
  15391. if (tstr instanceof Snap.Matrix) {
  15392. this.matrix = tstr;
  15393. this._.transform = tstr.toTransformString();
  15394. } else {
  15395. extractTransform(this, tstr);
  15396. }
  15397. if (this.node) {
  15398. if (this.type == "linearGradient" || this.type == "radialGradient") {
  15399. $(this.node, {gradientTransform: this.matrix});
  15400. } else if (this.type == "pattern") {
  15401. $(this.node, {patternTransform: this.matrix});
  15402. } else {
  15403. $(this.node, {transform: this.matrix});
  15404. }
  15405. }
  15406. return this;
  15407. };
  15408. /*\
  15409. * Element.parent
  15410. [ method ]
  15411. **
  15412. * Returns the element's parent
  15413. **
  15414. = (Element) the parent element
  15415. \*/
  15416. elproto.parent = function () {
  15417. return wrap(this.node.parentNode);
  15418. };
  15419. /*\
  15420. * Element.append
  15421. [ method ]
  15422. **
  15423. * Appends the given element to current one
  15424. **
  15425. - el (Element|Set) element to append
  15426. = (Element) the parent element
  15427. \*/
  15428. /*\
  15429. * Element.add
  15430. [ method ]
  15431. **
  15432. * See @Element.append
  15433. \*/
  15434. elproto.append = elproto.add = function (el) {
  15435. if (el) {
  15436. if (el.type == "set") {
  15437. var it = this;
  15438. el.forEach(function (el) {
  15439. it.add(el);
  15440. });
  15441. return this;
  15442. }
  15443. el = wrap(el);
  15444. this.node.appendChild(el.node);
  15445. el.paper = this.paper;
  15446. }
  15447. return this;
  15448. };
  15449. /*\
  15450. * Element.appendTo
  15451. [ method ]
  15452. **
  15453. * Appends the current element to the given one
  15454. **
  15455. - el (Element) parent element to append to
  15456. = (Element) the child element
  15457. \*/
  15458. elproto.appendTo = function (el) {
  15459. if (el) {
  15460. el = wrap(el);
  15461. el.append(this);
  15462. }
  15463. return this;
  15464. };
  15465. /*\
  15466. * Element.prepend
  15467. [ method ]
  15468. **
  15469. * Prepends the given element to the current one
  15470. **
  15471. - el (Element) element to prepend
  15472. = (Element) the parent element
  15473. \*/
  15474. elproto.prepend = function (el) {
  15475. if (el) {
  15476. if (el.type == "set") {
  15477. var it = this,
  15478. first;
  15479. el.forEach(function (el) {
  15480. if (first) {
  15481. first.after(el);
  15482. } else {
  15483. it.prepend(el);
  15484. }
  15485. first = el;
  15486. });
  15487. return this;
  15488. }
  15489. el = wrap(el);
  15490. var parent = el.parent();
  15491. this.node.insertBefore(el.node, this.node.firstChild);
  15492. this.add && this.add();
  15493. el.paper = this.paper;
  15494. this.parent() && this.parent().add();
  15495. parent && parent.add();
  15496. }
  15497. return this;
  15498. };
  15499. /*\
  15500. * Element.prependTo
  15501. [ method ]
  15502. **
  15503. * Prepends the current element to the given one
  15504. **
  15505. - el (Element) parent element to prepend to
  15506. = (Element) the child element
  15507. \*/
  15508. elproto.prependTo = function (el) {
  15509. el = wrap(el);
  15510. el.prepend(this);
  15511. return this;
  15512. };
  15513. /*\
  15514. * Element.before
  15515. [ method ]
  15516. **
  15517. * Inserts given element before the current one
  15518. **
  15519. - el (Element) element to insert
  15520. = (Element) the parent element
  15521. \*/
  15522. elproto.before = function (el) {
  15523. if (el.type == "set") {
  15524. var it = this;
  15525. el.forEach(function (el) {
  15526. var parent = el.parent();
  15527. it.node.parentNode.insertBefore(el.node, it.node);
  15528. parent && parent.add();
  15529. });
  15530. this.parent().add();
  15531. return this;
  15532. }
  15533. el = wrap(el);
  15534. var parent = el.parent();
  15535. this.node.parentNode.insertBefore(el.node, this.node);
  15536. this.parent() && this.parent().add();
  15537. parent && parent.add();
  15538. el.paper = this.paper;
  15539. return this;
  15540. };
  15541. /*\
  15542. * Element.after
  15543. [ method ]
  15544. **
  15545. * Inserts given element after the current one
  15546. **
  15547. - el (Element) element to insert
  15548. = (Element) the parent element
  15549. \*/
  15550. elproto.after = function (el) {
  15551. el = wrap(el);
  15552. var parent = el.parent();
  15553. if (this.node.nextSibling) {
  15554. this.node.parentNode.insertBefore(el.node, this.node.nextSibling);
  15555. } else {
  15556. this.node.parentNode.appendChild(el.node);
  15557. }
  15558. this.parent() && this.parent().add();
  15559. parent && parent.add();
  15560. el.paper = this.paper;
  15561. return this;
  15562. };
  15563. /*\
  15564. * Element.insertBefore
  15565. [ method ]
  15566. **
  15567. * Inserts the element after the given one
  15568. **
  15569. - el (Element) element next to whom insert to
  15570. = (Element) the parent element
  15571. \*/
  15572. elproto.insertBefore = function (el) {
  15573. el = wrap(el);
  15574. var parent = this.parent();
  15575. el.node.parentNode.insertBefore(this.node, el.node);
  15576. this.paper = el.paper;
  15577. parent && parent.add();
  15578. el.parent() && el.parent().add();
  15579. return this;
  15580. };
  15581. /*\
  15582. * Element.insertAfter
  15583. [ method ]
  15584. **
  15585. * Inserts the element after the given one
  15586. **
  15587. - el (Element) element next to whom insert to
  15588. = (Element) the parent element
  15589. \*/
  15590. elproto.insertAfter = function (el) {
  15591. el = wrap(el);
  15592. var parent = this.parent();
  15593. el.node.parentNode.insertBefore(this.node, el.node.nextSibling);
  15594. this.paper = el.paper;
  15595. parent && parent.add();
  15596. el.parent() && el.parent().add();
  15597. return this;
  15598. };
  15599. /*\
  15600. * Element.remove
  15601. [ method ]
  15602. **
  15603. * Removes element from the DOM
  15604. = (Element) the detached element
  15605. \*/
  15606. elproto.remove = function () {
  15607. var parent = this.parent();
  15608. this.node.parentNode && this.node.parentNode.removeChild(this.node);
  15609. delete this.paper;
  15610. this.removed = true;
  15611. parent && parent.add();
  15612. return this;
  15613. };
  15614. /*\
  15615. * Element.select
  15616. [ method ]
  15617. **
  15618. * Gathers the nested @Element matching the given set of CSS selectors
  15619. **
  15620. - query (string) CSS selector
  15621. = (Element) result of query selection
  15622. \*/
  15623. elproto.select = function (query) {
  15624. query = Str(query).replace(/([^\\]):/g, "$1\\:");
  15625. return wrap(this.node.querySelector(query));
  15626. };
  15627. /*\
  15628. * Element.selectAll
  15629. [ method ]
  15630. **
  15631. * Gathers nested @Element objects matching the given set of CSS selectors
  15632. **
  15633. - query (string) CSS selector
  15634. = (Set|array) result of query selection
  15635. \*/
  15636. elproto.selectAll = function (query) {
  15637. var nodelist = this.node.querySelectorAll(query),
  15638. set = (Snap.set || Array)();
  15639. for (var i = 0; i < nodelist.length; i++) {
  15640. set.push(wrap(nodelist[i]));
  15641. }
  15642. return set;
  15643. };
  15644. /*\
  15645. * Element.asPX
  15646. [ method ]
  15647. **
  15648. * Returns given attribute of the element as a `px` value (not %, em, etc.)
  15649. **
  15650. - attr (string) attribute name
  15651. - value (string) #optional attribute value
  15652. = (Element) result of query selection
  15653. \*/
  15654. elproto.asPX = function (attr, value) {
  15655. if (value == null) {
  15656. value = this.attr(attr);
  15657. }
  15658. return +unit2px(this, attr, value);
  15659. };
  15660. // SIERRA Element.use(): I suggest adding a note about how to access the original element the returned <use> instantiates. It's a part of SVG with which ordinary web developers may be least familiar.
  15661. /*\
  15662. * Element.use
  15663. [ method ]
  15664. **
  15665. * Creates a `<use>` element linked to the current element
  15666. **
  15667. = (Element) the `<use>` element
  15668. \*/
  15669. elproto.use = function () {
  15670. var use,
  15671. id = this.node.id;
  15672. if (!id) {
  15673. id = this.id;
  15674. $(this.node, {
  15675. id: id
  15676. });
  15677. }
  15678. if (this.type == "linearGradient" || this.type == "radialGradient" ||
  15679. this.type == "pattern") {
  15680. use = make(this.type, this.node.parentNode);
  15681. } else {
  15682. use = make("use", this.node.parentNode);
  15683. }
  15684. $(use.node, {
  15685. "xlink:href": "#" + id
  15686. });
  15687. use.original = this;
  15688. return use;
  15689. };
  15690. function fixids(el) {
  15691. var els = el.selectAll("*"),
  15692. it,
  15693. url = /^\s*url\(("|'|)(.*)\1\)\s*$/,
  15694. ids = [],
  15695. uses = {};
  15696. function urltest(it, name) {
  15697. var val = $(it.node, name);
  15698. val = val && val.match(url);
  15699. val = val && val[2];
  15700. if (val && val.charAt() == "#") {
  15701. val = val.substring(1);
  15702. } else {
  15703. return;
  15704. }
  15705. if (val) {
  15706. uses[val] = (uses[val] || []).concat(function (id) {
  15707. var attr = {};
  15708. attr[name] = URL(id);
  15709. $(it.node, attr);
  15710. });
  15711. }
  15712. }
  15713. function linktest(it) {
  15714. var val = $(it.node, "xlink:href");
  15715. if (val && val.charAt() == "#") {
  15716. val = val.substring(1);
  15717. } else {
  15718. return;
  15719. }
  15720. if (val) {
  15721. uses[val] = (uses[val] || []).concat(function (id) {
  15722. it.attr("xlink:href", "#" + id);
  15723. });
  15724. }
  15725. }
  15726. for (var i = 0, ii = els.length; i < ii; i++) {
  15727. it = els[i];
  15728. urltest(it, "fill");
  15729. urltest(it, "stroke");
  15730. urltest(it, "filter");
  15731. urltest(it, "mask");
  15732. urltest(it, "clip-path");
  15733. linktest(it);
  15734. var oldid = $(it.node, "id");
  15735. if (oldid) {
  15736. $(it.node, {id: it.id});
  15737. ids.push({
  15738. old: oldid,
  15739. id: it.id
  15740. });
  15741. }
  15742. }
  15743. for (i = 0, ii = ids.length; i < ii; i++) {
  15744. var fs = uses[ids[i].old];
  15745. if (fs) {
  15746. for (var j = 0, jj = fs.length; j < jj; j++) {
  15747. fs[j](ids[i].id);
  15748. }
  15749. }
  15750. }
  15751. }
  15752. /*\
  15753. * Element.clone
  15754. [ method ]
  15755. **
  15756. * Creates a clone of the element and inserts it after the element
  15757. **
  15758. = (Element) the clone
  15759. \*/
  15760. elproto.clone = function () {
  15761. var clone = wrap(this.node.cloneNode(true));
  15762. if ($(clone.node, "id")) {
  15763. $(clone.node, {id: clone.id});
  15764. }
  15765. fixids(clone);
  15766. clone.insertAfter(this);
  15767. return clone;
  15768. };
  15769. /*\
  15770. * Element.toDefs
  15771. [ method ]
  15772. **
  15773. * Moves element to the shared `<defs>` area
  15774. **
  15775. = (Element) the element
  15776. \*/
  15777. elproto.toDefs = function () {
  15778. var defs = getSomeDefs(this);
  15779. defs.appendChild(this.node);
  15780. return this;
  15781. };
  15782. /*\
  15783. * Element.toPattern
  15784. [ method ]
  15785. **
  15786. * Creates a `<pattern>` element from the current element
  15787. **
  15788. * To create a pattern you have to specify the pattern rect:
  15789. - x (string|number)
  15790. - y (string|number)
  15791. - width (string|number)
  15792. - height (string|number)
  15793. = (Element) the `<pattern>` element
  15794. * You can use pattern later on as an argument for `fill` attribute:
  15795. | var p = paper.path("M10-5-10,15M15,0,0,15M0-5-20,15").attr({
  15796. | fill: "none",
  15797. | stroke: "#bada55",
  15798. | strokeWidth: 5
  15799. | }).pattern(0, 0, 10, 10),
  15800. | c = paper.circle(200, 200, 100);
  15801. | c.attr({
  15802. | fill: p
  15803. | });
  15804. \*/
  15805. elproto.pattern = elproto.toPattern = function (x, y, width, height) {
  15806. var p = make("pattern", getSomeDefs(this));
  15807. if (x == null) {
  15808. x = this.getBBox();
  15809. }
  15810. if (is(x, "object") && "x" in x) {
  15811. y = x.y;
  15812. width = x.width;
  15813. height = x.height;
  15814. x = x.x;
  15815. }
  15816. $(p.node, {
  15817. x: x,
  15818. y: y,
  15819. width: width,
  15820. height: height,
  15821. patternUnits: "userSpaceOnUse",
  15822. id: p.id,
  15823. viewBox: [x, y, width, height].join(" ")
  15824. });
  15825. p.node.appendChild(this.node);
  15826. return p;
  15827. };
  15828. // SIERRA Element.marker(): clarify what a reference point is. E.g., helps you offset the object from its edge such as when centering it over a path.
  15829. // SIERRA Element.marker(): I suggest the method should accept default reference point values. Perhaps centered with (refX = width/2) and (refY = height/2)? Also, couldn't it assume the element's current _width_ and _height_? And please specify what _x_ and _y_ mean: offsets? If so, from where? Couldn't they also be assigned default values?
  15830. /*\
  15831. * Element.marker
  15832. [ method ]
  15833. **
  15834. * Creates a `<marker>` element from the current element
  15835. **
  15836. * To create a marker you have to specify the bounding rect and reference point:
  15837. - x (number)
  15838. - y (number)
  15839. - width (number)
  15840. - height (number)
  15841. - refX (number)
  15842. - refY (number)
  15843. = (Element) the `<marker>` element
  15844. * You can specify the marker later as an argument for `marker-start`, `marker-end`, `marker-mid`, and `marker` attributes. The `marker` attribute places the marker at every point along the path, and `marker-mid` places them at every point except the start and end.
  15845. \*/
  15846. // TODO add usage for markers
  15847. elproto.marker = function (x, y, width, height, refX, refY) {
  15848. var p = make("marker", getSomeDefs(this));
  15849. if (x == null) {
  15850. x = this.getBBox();
  15851. }
  15852. if (is(x, "object") && "x" in x) {
  15853. y = x.y;
  15854. width = x.width;
  15855. height = x.height;
  15856. refX = x.refX || x.cx;
  15857. refY = x.refY || x.cy;
  15858. x = x.x;
  15859. }
  15860. $(p.node, {
  15861. viewBox: [x, y, width, height].join(" "),
  15862. markerWidth: width,
  15863. markerHeight: height,
  15864. orient: "auto",
  15865. refX: refX || 0,
  15866. refY: refY || 0,
  15867. id: p.id
  15868. });
  15869. p.node.appendChild(this.node);
  15870. return p;
  15871. };
  15872. // animation
  15873. function slice(from, to, f) {
  15874. return function (arr) {
  15875. var res = arr.slice(from, to);
  15876. if (res.length == 1) {
  15877. res = res[0];
  15878. }
  15879. return f ? f(res) : res;
  15880. };
  15881. }
  15882. var Animation = function (attr, ms, easing, callback) {
  15883. if (typeof easing == "function" && !easing.length) {
  15884. callback = easing;
  15885. easing = mina.linear;
  15886. }
  15887. this.attr = attr;
  15888. this.dur = ms;
  15889. easing && (this.easing = easing);
  15890. callback && (this.callback = callback);
  15891. };
  15892. Snap._.Animation = Animation;
  15893. /*\
  15894. * Snap.animation
  15895. [ method ]
  15896. **
  15897. * Creates an animation object
  15898. **
  15899. - attr (object) attributes of final destination
  15900. - duration (number) duration of the animation, in milliseconds
  15901. - easing (function) #optional one of easing functions of @mina or custom one
  15902. - callback (function) #optional callback function that fires when animation ends
  15903. = (object) animation object
  15904. \*/
  15905. Snap.animation = function (attr, ms, easing, callback) {
  15906. return new Animation(attr, ms, easing, callback);
  15907. };
  15908. /*\
  15909. * Element.inAnim
  15910. [ method ]
  15911. **
  15912. * Returns a set of animations that may be able to manipulate the current element
  15913. **
  15914. = (object) in format:
  15915. o {
  15916. o anim (object) animation object,
  15917. o mina (object) @mina object,
  15918. o curStatus (number) 0..1 — status of the animation: 0 — just started, 1 — just finished,
  15919. o status (function) gets or sets the status of the animation,
  15920. o stop (function) stops the animation
  15921. o }
  15922. \*/
  15923. elproto.inAnim = function () {
  15924. var el = this,
  15925. res = [];
  15926. for (var id in el.anims) if (el.anims[has](id)) {
  15927. (function (a) {
  15928. res.push({
  15929. anim: new Animation(a._attrs, a.dur, a.easing, a._callback),
  15930. mina: a,
  15931. curStatus: a.status(),
  15932. status: function (val) {
  15933. return a.status(val);
  15934. },
  15935. stop: function () {
  15936. a.stop();
  15937. }
  15938. });
  15939. }(el.anims[id]));
  15940. }
  15941. return res;
  15942. };
  15943. /*\
  15944. * Snap.animate
  15945. [ method ]
  15946. **
  15947. * Runs generic animation of one number into another with a caring function
  15948. **
  15949. - from (number|array) number or array of numbers
  15950. - to (number|array) number or array of numbers
  15951. - setter (function) caring function that accepts one number argument
  15952. - duration (number) duration, in milliseconds
  15953. - easing (function) #optional easing function from @mina or custom
  15954. - callback (function) #optional callback function to execute when animation ends
  15955. = (object) animation object in @mina format
  15956. o {
  15957. o id (string) animation id, consider it read-only,
  15958. o duration (function) gets or sets the duration of the animation,
  15959. o easing (function) easing,
  15960. o speed (function) gets or sets the speed of the animation,
  15961. o status (function) gets or sets the status of the animation,
  15962. o stop (function) stops the animation
  15963. o }
  15964. | var rect = Snap().rect(0, 0, 10, 10);
  15965. | Snap.animate(0, 10, function (val) {
  15966. | rect.attr({
  15967. | x: val
  15968. | });
  15969. | }, 1000);
  15970. | // in given context is equivalent to
  15971. | rect.animate({x: 10}, 1000);
  15972. \*/
  15973. Snap.animate = function (from, to, setter, ms, easing, callback) {
  15974. if (typeof easing == "function" && !easing.length) {
  15975. callback = easing;
  15976. easing = mina.linear;
  15977. }
  15978. var now = mina.time(),
  15979. anim = mina(from, to, now, now + ms, mina.time, setter, easing);
  15980. callback && eve.once("mina.finish." + anim.id, callback);
  15981. return anim;
  15982. };
  15983. /*\
  15984. * Element.stop
  15985. [ method ]
  15986. **
  15987. * Stops all the animations for the current element
  15988. **
  15989. = (Element) the current element
  15990. \*/
  15991. elproto.stop = function () {
  15992. var anims = this.inAnim();
  15993. for (var i = 0, ii = anims.length; i < ii; i++) {
  15994. anims[i].stop();
  15995. }
  15996. return this;
  15997. };
  15998. /*\
  15999. * Element.animate
  16000. [ method ]
  16001. **
  16002. * Animates the given attributes of the element
  16003. **
  16004. - attrs (object) key-value pairs of destination attributes
  16005. - duration (number) duration of the animation in milliseconds
  16006. - easing (function) #optional easing function from @mina or custom
  16007. - callback (function) #optional callback function that executes when the animation ends
  16008. = (Element) the current element
  16009. \*/
  16010. elproto.animate = function (attrs, ms, easing, callback) {
  16011. if (typeof easing == "function" && !easing.length) {
  16012. callback = easing;
  16013. easing = mina.linear;
  16014. }
  16015. if (attrs instanceof Animation) {
  16016. callback = attrs.callback;
  16017. easing = attrs.easing;
  16018. ms = easing.dur;
  16019. attrs = attrs.attr;
  16020. }
  16021. var fkeys = [], tkeys = [], keys = {}, from, to, f, eq,
  16022. el = this;
  16023. for (var key in attrs) if (attrs[has](key)) {
  16024. if (el.equal) {
  16025. eq = el.equal(key, Str(attrs[key]));
  16026. from = eq.from;
  16027. to = eq.to;
  16028. f = eq.f;
  16029. } else {
  16030. from = +el.attr(key);
  16031. to = +attrs[key];
  16032. }
  16033. var len = is(from, "array") ? from.length : 1;
  16034. keys[key] = slice(fkeys.length, fkeys.length + len, f);
  16035. fkeys = fkeys.concat(from);
  16036. tkeys = tkeys.concat(to);
  16037. }
  16038. var now = mina.time(),
  16039. anim = mina(fkeys, tkeys, now, now + ms, mina.time, function (val) {
  16040. var attr = {};
  16041. for (var key in keys) if (keys[has](key)) {
  16042. attr[key] = keys[key](val);
  16043. }
  16044. el.attr(attr);
  16045. }, easing);
  16046. el.anims[anim.id] = anim;
  16047. anim._attrs = attrs;
  16048. anim._callback = callback;
  16049. eve("snap.animcreated." + el.id, anim);
  16050. eve.once("mina.finish." + anim.id, function () {
  16051. delete el.anims[anim.id];
  16052. callback && callback.call(el);
  16053. });
  16054. eve.once("mina.stop." + anim.id, function () {
  16055. delete el.anims[anim.id];
  16056. });
  16057. return el;
  16058. };
  16059. var eldata = {};
  16060. /*\
  16061. * Element.data
  16062. [ method ]
  16063. **
  16064. * Adds or retrieves given value associated with given key. (Don’t confuse
  16065. * with `data-` attributes)
  16066. *
  16067. * See also @Element.removeData
  16068. - key (string) key to store data
  16069. - value (any) #optional value to store
  16070. = (object) @Element
  16071. * or, if value is not specified:
  16072. = (any) value
  16073. > Usage
  16074. | for (var i = 0, i < 5, i++) {
  16075. | paper.circle(10 + 15 * i, 10, 10)
  16076. | .attr({fill: "#000"})
  16077. | .data("i", i)
  16078. | .click(function () {
  16079. | alert(this.data("i"));
  16080. | });
  16081. | }
  16082. \*/
  16083. elproto.data = function (key, value) {
  16084. var data = eldata[this.id] = eldata[this.id] || {};
  16085. if (arguments.length == 0){
  16086. eve("snap.data.get." + this.id, this, data, null);
  16087. return data;
  16088. }
  16089. if (arguments.length == 1) {
  16090. if (Snap.is(key, "object")) {
  16091. for (var i in key) if (key[has](i)) {
  16092. this.data(i, key[i]);
  16093. }
  16094. return this;
  16095. }
  16096. eve("snap.data.get." + this.id, this, data[key], key);
  16097. return data[key];
  16098. }
  16099. data[key] = value;
  16100. eve("snap.data.set." + this.id, this, value, key);
  16101. return this;
  16102. };
  16103. /*\
  16104. * Element.removeData
  16105. [ method ]
  16106. **
  16107. * Removes value associated with an element by given key.
  16108. * If key is not provided, removes all the data of the element.
  16109. - key (string) #optional key
  16110. = (object) @Element
  16111. \*/
  16112. elproto.removeData = function (key) {
  16113. if (key == null) {
  16114. eldata[this.id] = {};
  16115. } else {
  16116. eldata[this.id] && delete eldata[this.id][key];
  16117. }
  16118. return this;
  16119. };
  16120. /*\
  16121. * Element.outerSVG
  16122. [ method ]
  16123. **
  16124. * Returns SVG code for the element, equivalent to HTML's `outerHTML`.
  16125. *
  16126. * See also @Element.innerSVG
  16127. = (string) SVG code for the element
  16128. \*/
  16129. /*\
  16130. * Element.toString
  16131. [ method ]
  16132. **
  16133. * See @Element.outerSVG
  16134. \*/
  16135. elproto.outerSVG = elproto.toString = toString(1);
  16136. /*\
  16137. * Element.innerSVG
  16138. [ method ]
  16139. **
  16140. * Returns SVG code for the element's contents, equivalent to HTML's `innerHTML`
  16141. = (string) SVG code for the element
  16142. \*/
  16143. elproto.innerSVG = toString();
  16144. function toString(type) {
  16145. return function () {
  16146. var res = type ? "<" + this.type : "",
  16147. attr = this.node.attributes,
  16148. chld = this.node.childNodes;
  16149. if (type) {
  16150. for (var i = 0, ii = attr.length; i < ii; i++) {
  16151. res += " " + attr[i].name + '="' +
  16152. attr[i].value.replace(/"/g, '\\"') + '"';
  16153. }
  16154. }
  16155. if (chld.length) {
  16156. type && (res += ">");
  16157. for (i = 0, ii = chld.length; i < ii; i++) {
  16158. if (chld[i].nodeType == 3) {
  16159. res += chld[i].nodeValue;
  16160. } else if (chld[i].nodeType == 1) {
  16161. res += wrap(chld[i]).toString();
  16162. }
  16163. }
  16164. type && (res += "</" + this.type + ">");
  16165. } else {
  16166. type && (res += "/>");
  16167. }
  16168. return res;
  16169. };
  16170. }
  16171. elproto.toDataURL = function () {
  16172. if (window && window.btoa) {
  16173. var bb = this.getBBox(),
  16174. svg = Snap.format('<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="{width}" height="{height}" viewBox="{x} {y} {width} {height}">{contents}</svg>', {
  16175. x: +bb.x.toFixed(3),
  16176. y: +bb.y.toFixed(3),
  16177. width: +bb.width.toFixed(3),
  16178. height: +bb.height.toFixed(3),
  16179. contents: this.outerSVG()
  16180. });
  16181. return "data:image/svg+xml;base64," + btoa(unescape(encodeURIComponent(svg)));
  16182. }
  16183. };
  16184. /*\
  16185. * Fragment.select
  16186. [ method ]
  16187. **
  16188. * See @Element.select
  16189. \*/
  16190. Fragment.prototype.select = elproto.select;
  16191. /*\
  16192. * Fragment.selectAll
  16193. [ method ]
  16194. **
  16195. * See @Element.selectAll
  16196. \*/
  16197. Fragment.prototype.selectAll = elproto.selectAll;
  16198. });
  16199. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  16200. //
  16201. // Licensed under the Apache License, Version 2.0 (the "License");
  16202. // you may not use this file except in compliance with the License.
  16203. // You may obtain a copy of the License at
  16204. //
  16205. // http://www.apache.org/licenses/LICENSE-2.0
  16206. //
  16207. // Unless required by applicable law or agreed to in writing, software
  16208. // distributed under the License is distributed on an "AS IS" BASIS,
  16209. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16210. // See the License for the specific language governing permissions and
  16211. // limitations under the License.
  16212. Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
  16213. var objectToString = Object.prototype.toString,
  16214. Str = String,
  16215. math = Math,
  16216. E = "";
  16217. function Matrix(a, b, c, d, e, f) {
  16218. if (b == null && objectToString.call(a) == "[object SVGMatrix]") {
  16219. this.a = a.a;
  16220. this.b = a.b;
  16221. this.c = a.c;
  16222. this.d = a.d;
  16223. this.e = a.e;
  16224. this.f = a.f;
  16225. return;
  16226. }
  16227. if (a != null) {
  16228. this.a = +a;
  16229. this.b = +b;
  16230. this.c = +c;
  16231. this.d = +d;
  16232. this.e = +e;
  16233. this.f = +f;
  16234. } else {
  16235. this.a = 1;
  16236. this.b = 0;
  16237. this.c = 0;
  16238. this.d = 1;
  16239. this.e = 0;
  16240. this.f = 0;
  16241. }
  16242. }
  16243. (function (matrixproto) {
  16244. /*\
  16245. * Matrix.add
  16246. [ method ]
  16247. **
  16248. * Adds the given matrix to existing one
  16249. - a (number)
  16250. - b (number)
  16251. - c (number)
  16252. - d (number)
  16253. - e (number)
  16254. - f (number)
  16255. * or
  16256. - matrix (object) @Matrix
  16257. \*/
  16258. matrixproto.add = function (a, b, c, d, e, f) {
  16259. var out = [[], [], []],
  16260. m = [[this.a, this.c, this.e], [this.b, this.d, this.f], [0, 0, 1]],
  16261. matrix = [[a, c, e], [b, d, f], [0, 0, 1]],
  16262. x, y, z, res;
  16263. if (a && a instanceof Matrix) {
  16264. matrix = [[a.a, a.c, a.e], [a.b, a.d, a.f], [0, 0, 1]];
  16265. }
  16266. for (x = 0; x < 3; x++) {
  16267. for (y = 0; y < 3; y++) {
  16268. res = 0;
  16269. for (z = 0; z < 3; z++) {
  16270. res += m[x][z] * matrix[z][y];
  16271. }
  16272. out[x][y] = res;
  16273. }
  16274. }
  16275. this.a = out[0][0];
  16276. this.b = out[1][0];
  16277. this.c = out[0][1];
  16278. this.d = out[1][1];
  16279. this.e = out[0][2];
  16280. this.f = out[1][2];
  16281. return this;
  16282. };
  16283. /*\
  16284. * Matrix.invert
  16285. [ method ]
  16286. **
  16287. * Returns an inverted version of the matrix
  16288. = (object) @Matrix
  16289. \*/
  16290. matrixproto.invert = function () {
  16291. var me = this,
  16292. x = me.a * me.d - me.b * me.c;
  16293. return new Matrix(me.d / x, -me.b / x, -me.c / x, me.a / x, (me.c * me.f - me.d * me.e) / x, (me.b * me.e - me.a * me.f) / x);
  16294. };
  16295. /*\
  16296. * Matrix.clone
  16297. [ method ]
  16298. **
  16299. * Returns a copy of the matrix
  16300. = (object) @Matrix
  16301. \*/
  16302. matrixproto.clone = function () {
  16303. return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f);
  16304. };
  16305. /*\
  16306. * Matrix.translate
  16307. [ method ]
  16308. **
  16309. * Translate the matrix
  16310. - x (number) horizontal offset distance
  16311. - y (number) vertical offset distance
  16312. \*/
  16313. matrixproto.translate = function (x, y) {
  16314. return this.add(1, 0, 0, 1, x, y);
  16315. };
  16316. /*\
  16317. * Matrix.scale
  16318. [ method ]
  16319. **
  16320. * Scales the matrix
  16321. - x (number) amount to be scaled, with `1` resulting in no change
  16322. - y (number) #optional amount to scale along the vertical axis. (Otherwise `x` applies to both axes.)
  16323. - cx (number) #optional horizontal origin point from which to scale
  16324. - cy (number) #optional vertical origin point from which to scale
  16325. * Default cx, cy is the middle point of the element.
  16326. \*/
  16327. matrixproto.scale = function (x, y, cx, cy) {
  16328. y == null && (y = x);
  16329. (cx || cy) && this.add(1, 0, 0, 1, cx, cy);
  16330. this.add(x, 0, 0, y, 0, 0);
  16331. (cx || cy) && this.add(1, 0, 0, 1, -cx, -cy);
  16332. return this;
  16333. };
  16334. /*\
  16335. * Matrix.rotate
  16336. [ method ]
  16337. **
  16338. * Rotates the matrix
  16339. - a (number) angle of rotation, in degrees
  16340. - x (number) horizontal origin point from which to rotate
  16341. - y (number) vertical origin point from which to rotate
  16342. \*/
  16343. matrixproto.rotate = function (a, x, y) {
  16344. a = Snap.rad(a);
  16345. x = x || 0;
  16346. y = y || 0;
  16347. var cos = +math.cos(a).toFixed(9),
  16348. sin = +math.sin(a).toFixed(9);
  16349. this.add(cos, sin, -sin, cos, x, y);
  16350. return this.add(1, 0, 0, 1, -x, -y);
  16351. };
  16352. /*\
  16353. * Matrix.x
  16354. [ method ]
  16355. **
  16356. * Returns x coordinate for given point after transformation described by the matrix. See also @Matrix.y
  16357. - x (number)
  16358. - y (number)
  16359. = (number) x
  16360. \*/
  16361. matrixproto.x = function (x, y) {
  16362. return x * this.a + y * this.c + this.e;
  16363. };
  16364. /*\
  16365. * Matrix.y
  16366. [ method ]
  16367. **
  16368. * Returns y coordinate for given point after transformation described by the matrix. See also @Matrix.x
  16369. - x (number)
  16370. - y (number)
  16371. = (number) y
  16372. \*/
  16373. matrixproto.y = function (x, y) {
  16374. return x * this.b + y * this.d + this.f;
  16375. };
  16376. matrixproto.get = function (i) {
  16377. return +this[Str.fromCharCode(97 + i)].toFixed(4);
  16378. };
  16379. matrixproto.toString = function () {
  16380. return "matrix(" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)].join() + ")";
  16381. };
  16382. matrixproto.offset = function () {
  16383. return [this.e.toFixed(4), this.f.toFixed(4)];
  16384. };
  16385. function norm(a) {
  16386. return a[0] * a[0] + a[1] * a[1];
  16387. }
  16388. function normalize(a) {
  16389. var mag = math.sqrt(norm(a));
  16390. a[0] && (a[0] /= mag);
  16391. a[1] && (a[1] /= mag);
  16392. }
  16393. /*\
  16394. * Matrix.determinant
  16395. [ method ]
  16396. **
  16397. * Finds determinant of the given matrix.
  16398. = (number) determinant
  16399. \*/
  16400. matrixproto.determinant = function () {
  16401. return this.a * this.d - this.b * this.c;
  16402. };
  16403. /*\
  16404. * Matrix.split
  16405. [ method ]
  16406. **
  16407. * Splits matrix into primitive transformations
  16408. = (object) in format:
  16409. o dx (number) translation by x
  16410. o dy (number) translation by y
  16411. o scalex (number) scale by x
  16412. o scaley (number) scale by y
  16413. o shear (number) shear
  16414. o rotate (number) rotation in deg
  16415. o isSimple (boolean) could it be represented via simple transformations
  16416. \*/
  16417. matrixproto.split = function () {
  16418. var out = {};
  16419. // translation
  16420. out.dx = this.e;
  16421. out.dy = this.f;
  16422. // scale and shear
  16423. var row = [[this.a, this.c], [this.b, this.d]];
  16424. out.scalex = math.sqrt(norm(row[0]));
  16425. normalize(row[0]);
  16426. out.shear = row[0][0] * row[1][0] + row[0][1] * row[1][1];
  16427. row[1] = [row[1][0] - row[0][0] * out.shear, row[1][1] - row[0][1] * out.shear];
  16428. out.scaley = math.sqrt(norm(row[1]));
  16429. normalize(row[1]);
  16430. out.shear /= out.scaley;
  16431. if (this.determinant() < 0) {
  16432. out.scalex = -out.scalex;
  16433. }
  16434. // rotation
  16435. var sin = -row[0][1],
  16436. cos = row[1][1];
  16437. if (cos < 0) {
  16438. out.rotate = Snap.deg(math.acos(cos));
  16439. if (sin < 0) {
  16440. out.rotate = 360 - out.rotate;
  16441. }
  16442. } else {
  16443. out.rotate = Snap.deg(math.asin(sin));
  16444. }
  16445. out.isSimple = !+out.shear.toFixed(9) && (out.scalex.toFixed(9) == out.scaley.toFixed(9) || !out.rotate);
  16446. out.isSuperSimple = !+out.shear.toFixed(9) && out.scalex.toFixed(9) == out.scaley.toFixed(9) && !out.rotate;
  16447. out.noRotation = !+out.shear.toFixed(9) && !out.rotate;
  16448. return out;
  16449. };
  16450. /*\
  16451. * Matrix.toTransformString
  16452. [ method ]
  16453. **
  16454. * Returns transform string that represents given matrix
  16455. = (string) transform string
  16456. \*/
  16457. matrixproto.toTransformString = function (shorter) {
  16458. var s = shorter || this.split();
  16459. if (!+s.shear.toFixed(9)) {
  16460. s.scalex = +s.scalex.toFixed(4);
  16461. s.scaley = +s.scaley.toFixed(4);
  16462. s.rotate = +s.rotate.toFixed(4);
  16463. return (s.dx || s.dy ? "t" + [+s.dx.toFixed(4), +s.dy.toFixed(4)] : E) +
  16464. (s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) +
  16465. (s.rotate ? "r" + [+s.rotate.toFixed(4), 0, 0] : E);
  16466. } else {
  16467. return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)];
  16468. }
  16469. };
  16470. })(Matrix.prototype);
  16471. /*\
  16472. * Snap.Matrix
  16473. [ method ]
  16474. **
  16475. * Matrix constructor, extend on your own risk.
  16476. * To create matrices use @Snap.matrix.
  16477. \*/
  16478. Snap.Matrix = Matrix;
  16479. /*\
  16480. * Snap.matrix
  16481. [ method ]
  16482. **
  16483. * Utility method
  16484. **
  16485. * Returns a matrix based on the given parameters
  16486. - a (number)
  16487. - b (number)
  16488. - c (number)
  16489. - d (number)
  16490. - e (number)
  16491. - f (number)
  16492. * or
  16493. - svgMatrix (SVGMatrix)
  16494. = (object) @Matrix
  16495. \*/
  16496. Snap.matrix = function (a, b, c, d, e, f) {
  16497. return new Matrix(a, b, c, d, e, f);
  16498. };
  16499. });
  16500. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  16501. //
  16502. // Licensed under the Apache License, Version 2.0 (the "License");
  16503. // you may not use this file except in compliance with the License.
  16504. // You may obtain a copy of the License at
  16505. //
  16506. // http://www.apache.org/licenses/LICENSE-2.0
  16507. //
  16508. // Unless required by applicable law or agreed to in writing, software
  16509. // distributed under the License is distributed on an "AS IS" BASIS,
  16510. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16511. // See the License for the specific language governing permissions and
  16512. // limitations under the License.
  16513. Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
  16514. var has = "hasOwnProperty",
  16515. make = Snap._.make,
  16516. wrap = Snap._.wrap,
  16517. is = Snap.is,
  16518. getSomeDefs = Snap._.getSomeDefs,
  16519. reURLValue = /^url\(#?([^)]+)\)$/,
  16520. $ = Snap._.$,
  16521. URL = Snap.url,
  16522. Str = String,
  16523. separator = Snap._.separator,
  16524. E = "";
  16525. // Attributes event handlers
  16526. eve.on("snap.util.attr.mask", function (value) {
  16527. if (value instanceof Element || value instanceof Fragment) {
  16528. eve.stop();
  16529. if (value instanceof Fragment && value.node.childNodes.length == 1) {
  16530. value = value.node.firstChild;
  16531. getSomeDefs(this).appendChild(value);
  16532. value = wrap(value);
  16533. }
  16534. if (value.type == "mask") {
  16535. var mask = value;
  16536. } else {
  16537. mask = make("mask", getSomeDefs(this));
  16538. mask.node.appendChild(value.node);
  16539. }
  16540. !mask.node.id && $(mask.node, {
  16541. id: mask.id
  16542. });
  16543. $(this.node, {
  16544. mask: URL(mask.id)
  16545. });
  16546. }
  16547. });
  16548. (function (clipIt) {
  16549. eve.on("snap.util.attr.clip", clipIt);
  16550. eve.on("snap.util.attr.clip-path", clipIt);
  16551. eve.on("snap.util.attr.clipPath", clipIt);
  16552. }(function (value) {
  16553. if (value instanceof Element || value instanceof Fragment) {
  16554. eve.stop();
  16555. if (value.type == "clipPath") {
  16556. var clip = value;
  16557. } else {
  16558. clip = make("clipPath", getSomeDefs(this));
  16559. clip.node.appendChild(value.node);
  16560. !clip.node.id && $(clip.node, {
  16561. id: clip.id
  16562. });
  16563. }
  16564. $(this.node, {
  16565. "clip-path": URL(clip.node.id || clip.id)
  16566. });
  16567. }
  16568. }));
  16569. function fillStroke(name) {
  16570. return function (value) {
  16571. eve.stop();
  16572. if (value instanceof Fragment && value.node.childNodes.length == 1 &&
  16573. (value.node.firstChild.tagName == "radialGradient" ||
  16574. value.node.firstChild.tagName == "linearGradient" ||
  16575. value.node.firstChild.tagName == "pattern")) {
  16576. value = value.node.firstChild;
  16577. getSomeDefs(this).appendChild(value);
  16578. value = wrap(value);
  16579. }
  16580. if (value instanceof Element) {
  16581. if (value.type == "radialGradient" || value.type == "linearGradient"
  16582. || value.type == "pattern") {
  16583. if (!value.node.id) {
  16584. $(value.node, {
  16585. id: value.id
  16586. });
  16587. }
  16588. var fill = URL(value.node.id);
  16589. } else {
  16590. fill = value.attr(name);
  16591. }
  16592. } else {
  16593. fill = Snap.color(value);
  16594. if (fill.error) {
  16595. var grad = Snap(getSomeDefs(this).ownerSVGElement).gradient(value);
  16596. if (grad) {
  16597. if (!grad.node.id) {
  16598. $(grad.node, {
  16599. id: grad.id
  16600. });
  16601. }
  16602. fill = URL(grad.node.id);
  16603. } else {
  16604. fill = value;
  16605. }
  16606. } else {
  16607. fill = Str(fill);
  16608. }
  16609. }
  16610. var attrs = {};
  16611. attrs[name] = fill;
  16612. $(this.node, attrs);
  16613. this.node.style[name] = E;
  16614. };
  16615. }
  16616. eve.on("snap.util.attr.fill", fillStroke("fill"));
  16617. eve.on("snap.util.attr.stroke", fillStroke("stroke"));
  16618. var gradrg = /^([lr])(?:\(([^)]*)\))?(.*)$/i;
  16619. eve.on("snap.util.grad.parse", function parseGrad(string) {
  16620. string = Str(string);
  16621. var tokens = string.match(gradrg);
  16622. if (!tokens) {
  16623. return null;
  16624. }
  16625. var type = tokens[1],
  16626. params = tokens[2],
  16627. stops = tokens[3];
  16628. params = params.split(/\s*,\s*/).map(function (el) {
  16629. return +el == el ? +el : el;
  16630. });
  16631. if (params.length == 1 && params[0] == 0) {
  16632. params = [];
  16633. }
  16634. stops = stops.split("-");
  16635. stops = stops.map(function (el) {
  16636. el = el.split(":");
  16637. var out = {
  16638. color: el[0]
  16639. };
  16640. if (el[1]) {
  16641. out.offset = parseFloat(el[1]);
  16642. }
  16643. return out;
  16644. });
  16645. return {
  16646. type: type,
  16647. params: params,
  16648. stops: stops
  16649. };
  16650. });
  16651. eve.on("snap.util.attr.d", function (value) {
  16652. eve.stop();
  16653. if (is(value, "array") && is(value[0], "array")) {
  16654. value = Snap.path.toString.call(value);
  16655. }
  16656. value = Str(value);
  16657. if (value.match(/[ruo]/i)) {
  16658. value = Snap.path.toAbsolute(value);
  16659. }
  16660. $(this.node, {d: value});
  16661. })(-1);
  16662. eve.on("snap.util.attr.#text", function (value) {
  16663. eve.stop();
  16664. value = Str(value);
  16665. var txt = glob.doc.createTextNode(value);
  16666. while (this.node.firstChild) {
  16667. this.node.removeChild(this.node.firstChild);
  16668. }
  16669. this.node.appendChild(txt);
  16670. })(-1);
  16671. eve.on("snap.util.attr.path", function (value) {
  16672. eve.stop();
  16673. this.attr({d: value});
  16674. })(-1);
  16675. eve.on("snap.util.attr.class", function (value) {
  16676. eve.stop();
  16677. this.node.className.baseVal = value;
  16678. })(-1);
  16679. eve.on("snap.util.attr.viewBox", function (value) {
  16680. var vb;
  16681. if (is(value, "object") && "x" in value) {
  16682. vb = [value.x, value.y, value.width, value.height].join(" ");
  16683. } else if (is(value, "array")) {
  16684. vb = value.join(" ");
  16685. } else {
  16686. vb = value;
  16687. }
  16688. $(this.node, {
  16689. viewBox: vb
  16690. });
  16691. eve.stop();
  16692. })(-1);
  16693. eve.on("snap.util.attr.transform", function (value) {
  16694. this.transform(value);
  16695. eve.stop();
  16696. })(-1);
  16697. eve.on("snap.util.attr.r", function (value) {
  16698. if (this.type == "rect") {
  16699. eve.stop();
  16700. $(this.node, {
  16701. rx: value,
  16702. ry: value
  16703. });
  16704. }
  16705. })(-1);
  16706. eve.on("snap.util.attr.textpath", function (value) {
  16707. eve.stop();
  16708. if (this.type == "text") {
  16709. var id, tp, node;
  16710. if (!value && this.textPath) {
  16711. tp = this.textPath;
  16712. while (tp.node.firstChild) {
  16713. this.node.appendChild(tp.node.firstChild);
  16714. }
  16715. tp.remove();
  16716. delete this.textPath;
  16717. return;
  16718. }
  16719. if (is(value, "string")) {
  16720. var defs = getSomeDefs(this),
  16721. path = wrap(defs.parentNode).path(value);
  16722. defs.appendChild(path.node);
  16723. id = path.id;
  16724. path.attr({id: id});
  16725. } else {
  16726. value = wrap(value);
  16727. if (value instanceof Element) {
  16728. id = value.attr("id");
  16729. if (!id) {
  16730. id = value.id;
  16731. value.attr({id: id});
  16732. }
  16733. }
  16734. }
  16735. if (id) {
  16736. tp = this.textPath;
  16737. node = this.node;
  16738. if (tp) {
  16739. tp.attr({"xlink:href": "#" + id});
  16740. } else {
  16741. tp = $("textPath", {
  16742. "xlink:href": "#" + id
  16743. });
  16744. while (node.firstChild) {
  16745. tp.appendChild(node.firstChild);
  16746. }
  16747. node.appendChild(tp);
  16748. this.textPath = wrap(tp);
  16749. }
  16750. }
  16751. }
  16752. })(-1);
  16753. eve.on("snap.util.attr.text", function (value) {
  16754. if (this.type == "text") {
  16755. var i = 0,
  16756. node = this.node,
  16757. tuner = function (chunk) {
  16758. var out = $("tspan");
  16759. if (is(chunk, "array")) {
  16760. for (var i = 0; i < chunk.length; i++) {
  16761. out.appendChild(tuner(chunk[i]));
  16762. }
  16763. } else {
  16764. out.appendChild(glob.doc.createTextNode(chunk));
  16765. }
  16766. out.normalize && out.normalize();
  16767. return out;
  16768. };
  16769. while (node.firstChild) {
  16770. node.removeChild(node.firstChild);
  16771. }
  16772. var tuned = tuner(value);
  16773. while (tuned.firstChild) {
  16774. node.appendChild(tuned.firstChild);
  16775. }
  16776. }
  16777. eve.stop();
  16778. })(-1);
  16779. function setFontSize(value) {
  16780. eve.stop();
  16781. if (value == +value) {
  16782. value += "px";
  16783. }
  16784. this.node.style.fontSize = value;
  16785. }
  16786. eve.on("snap.util.attr.fontSize", setFontSize)(-1);
  16787. eve.on("snap.util.attr.font-size", setFontSize)(-1);
  16788. eve.on("snap.util.getattr.transform", function () {
  16789. eve.stop();
  16790. return this.transform();
  16791. })(-1);
  16792. eve.on("snap.util.getattr.textpath", function () {
  16793. eve.stop();
  16794. return this.textPath;
  16795. })(-1);
  16796. // Markers
  16797. (function () {
  16798. function getter(end) {
  16799. return function () {
  16800. eve.stop();
  16801. var style = glob.doc.defaultView.getComputedStyle(this.node, null).getPropertyValue("marker-" + end);
  16802. if (style == "none") {
  16803. return style;
  16804. } else {
  16805. return Snap(glob.doc.getElementById(style.match(reURLValue)[1]));
  16806. }
  16807. };
  16808. }
  16809. function setter(end) {
  16810. return function (value) {
  16811. eve.stop();
  16812. var name = "marker" + end.charAt(0).toUpperCase() + end.substring(1);
  16813. if (value == "" || !value) {
  16814. this.node.style[name] = "none";
  16815. return;
  16816. }
  16817. if (value.type == "marker") {
  16818. var id = value.node.id;
  16819. if (!id) {
  16820. $(value.node, {id: value.id});
  16821. }
  16822. this.node.style[name] = URL(id);
  16823. return;
  16824. }
  16825. };
  16826. }
  16827. eve.on("snap.util.getattr.marker-end", getter("end"))(-1);
  16828. eve.on("snap.util.getattr.markerEnd", getter("end"))(-1);
  16829. eve.on("snap.util.getattr.marker-start", getter("start"))(-1);
  16830. eve.on("snap.util.getattr.markerStart", getter("start"))(-1);
  16831. eve.on("snap.util.getattr.marker-mid", getter("mid"))(-1);
  16832. eve.on("snap.util.getattr.markerMid", getter("mid"))(-1);
  16833. eve.on("snap.util.attr.marker-end", setter("end"))(-1);
  16834. eve.on("snap.util.attr.markerEnd", setter("end"))(-1);
  16835. eve.on("snap.util.attr.marker-start", setter("start"))(-1);
  16836. eve.on("snap.util.attr.markerStart", setter("start"))(-1);
  16837. eve.on("snap.util.attr.marker-mid", setter("mid"))(-1);
  16838. eve.on("snap.util.attr.markerMid", setter("mid"))(-1);
  16839. }());
  16840. eve.on("snap.util.getattr.r", function () {
  16841. if (this.type == "rect" && $(this.node, "rx") == $(this.node, "ry")) {
  16842. eve.stop();
  16843. return $(this.node, "rx");
  16844. }
  16845. })(-1);
  16846. function textExtract(node) {
  16847. var out = [];
  16848. var children = node.childNodes;
  16849. for (var i = 0, ii = children.length; i < ii; i++) {
  16850. var chi = children[i];
  16851. if (chi.nodeType == 3) {
  16852. out.push(chi.nodeValue);
  16853. }
  16854. if (chi.tagName == "tspan") {
  16855. if (chi.childNodes.length == 1 && chi.firstChild.nodeType == 3) {
  16856. out.push(chi.firstChild.nodeValue);
  16857. } else {
  16858. out.push(textExtract(chi));
  16859. }
  16860. }
  16861. }
  16862. return out;
  16863. }
  16864. eve.on("snap.util.getattr.text", function () {
  16865. if (this.type == "text" || this.type == "tspan") {
  16866. eve.stop();
  16867. var out = textExtract(this.node);
  16868. return out.length == 1 ? out[0] : out;
  16869. }
  16870. })(-1);
  16871. eve.on("snap.util.getattr.#text", function () {
  16872. return this.node.textContent;
  16873. })(-1);
  16874. eve.on("snap.util.getattr.viewBox", function () {
  16875. eve.stop();
  16876. var vb = $(this.node, "viewBox");
  16877. if (vb) {
  16878. vb = vb.split(separator);
  16879. return Snap._.box(+vb[0], +vb[1], +vb[2], +vb[3]);
  16880. } else {
  16881. return;
  16882. }
  16883. })(-1);
  16884. eve.on("snap.util.getattr.points", function () {
  16885. var p = $(this.node, "points");
  16886. eve.stop();
  16887. if (p) {
  16888. return p.split(separator);
  16889. } else {
  16890. return;
  16891. }
  16892. })(-1);
  16893. eve.on("snap.util.getattr.path", function () {
  16894. var p = $(this.node, "d");
  16895. eve.stop();
  16896. return p;
  16897. })(-1);
  16898. eve.on("snap.util.getattr.class", function () {
  16899. return this.node.className.baseVal;
  16900. })(-1);
  16901. function getFontSize() {
  16902. eve.stop();
  16903. return this.node.style.fontSize;
  16904. }
  16905. eve.on("snap.util.getattr.fontSize", getFontSize)(-1);
  16906. eve.on("snap.util.getattr.font-size", getFontSize)(-1);
  16907. });
  16908. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  16909. //
  16910. // Licensed under the Apache License, Version 2.0 (the "License");
  16911. // you may not use this file except in compliance with the License.
  16912. // You may obtain a copy of the License at
  16913. //
  16914. // http://www.apache.org/licenses/LICENSE-2.0
  16915. //
  16916. // Unless required by applicable law or agreed to in writing, software
  16917. // distributed under the License is distributed on an "AS IS" BASIS,
  16918. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16919. // See the License for the specific language governing permissions and
  16920. // limitations under the License.
  16921. Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
  16922. var proto = Paper.prototype,
  16923. is = Snap.is;
  16924. /*\
  16925. * Paper.rect
  16926. [ method ]
  16927. *
  16928. * Draws a rectangle
  16929. **
  16930. - x (number) x coordinate of the top left corner
  16931. - y (number) y coordinate of the top left corner
  16932. - width (number) width
  16933. - height (number) height
  16934. - rx (number) #optional horizontal radius for rounded corners, default is 0
  16935. - ry (number) #optional vertical radius for rounded corners, default is rx or 0
  16936. = (object) the `rect` element
  16937. **
  16938. > Usage
  16939. | // regular rectangle
  16940. | var c = paper.rect(10, 10, 50, 50);
  16941. | // rectangle with rounded corners
  16942. | var c = paper.rect(40, 40, 50, 50, 10);
  16943. \*/
  16944. proto.rect = function (x, y, w, h, rx, ry) {
  16945. var attr;
  16946. if (ry == null) {
  16947. ry = rx;
  16948. }
  16949. if (is(x, "object") && x == "[object Object]") {
  16950. attr = x;
  16951. } else if (x != null) {
  16952. attr = {
  16953. x: x,
  16954. y: y,
  16955. width: w,
  16956. height: h
  16957. };
  16958. if (rx != null) {
  16959. attr.rx = rx;
  16960. attr.ry = ry;
  16961. }
  16962. }
  16963. return this.el("rect", attr);
  16964. };
  16965. /*\
  16966. * Paper.circle
  16967. [ method ]
  16968. **
  16969. * Draws a circle
  16970. **
  16971. - x (number) x coordinate of the centre
  16972. - y (number) y coordinate of the centre
  16973. - r (number) radius
  16974. = (object) the `circle` element
  16975. **
  16976. > Usage
  16977. | var c = paper.circle(50, 50, 40);
  16978. \*/
  16979. proto.circle = function (cx, cy, r) {
  16980. var attr;
  16981. if (is(cx, "object") && cx == "[object Object]") {
  16982. attr = cx;
  16983. } else if (cx != null) {
  16984. attr = {
  16985. cx: cx,
  16986. cy: cy,
  16987. r: r
  16988. };
  16989. }
  16990. return this.el("circle", attr);
  16991. };
  16992. var preload = (function () {
  16993. function onerror() {
  16994. this.parentNode.removeChild(this);
  16995. }
  16996. return function (src, f) {
  16997. var img = glob.doc.createElement("img"),
  16998. body = glob.doc.body;
  16999. img.style.cssText = "position:absolute;left:-9999em;top:-9999em";
  17000. img.onload = function () {
  17001. f.call(img);
  17002. img.onload = img.onerror = null;
  17003. body.removeChild(img);
  17004. };
  17005. img.onerror = onerror;
  17006. body.appendChild(img);
  17007. img.src = src;
  17008. };
  17009. }());
  17010. /*\
  17011. * Paper.image
  17012. [ method ]
  17013. **
  17014. * Places an image on the surface
  17015. **
  17016. - src (string) URI of the source image
  17017. - x (number) x offset position
  17018. - y (number) y offset position
  17019. - width (number) width of the image
  17020. - height (number) height of the image
  17021. = (object) the `image` element
  17022. * or
  17023. = (object) Snap element object with type `image`
  17024. **
  17025. > Usage
  17026. | var c = paper.image("apple.png", 10, 10, 80, 80);
  17027. \*/
  17028. proto.image = function (src, x, y, width, height) {
  17029. var el = this.el("image");
  17030. if (is(src, "object") && "src" in src) {
  17031. el.attr(src);
  17032. } else if (src != null) {
  17033. var set = {
  17034. "xlink:href": src,
  17035. preserveAspectRatio: "none"
  17036. };
  17037. if (x != null && y != null) {
  17038. set.x = x;
  17039. set.y = y;
  17040. }
  17041. if (width != null && height != null) {
  17042. set.width = width;
  17043. set.height = height;
  17044. } else {
  17045. preload(src, function () {
  17046. Snap._.$(el.node, {
  17047. width: this.offsetWidth,
  17048. height: this.offsetHeight
  17049. });
  17050. });
  17051. }
  17052. Snap._.$(el.node, set);
  17053. }
  17054. return el;
  17055. };
  17056. /*\
  17057. * Paper.ellipse
  17058. [ method ]
  17059. **
  17060. * Draws an ellipse
  17061. **
  17062. - x (number) x coordinate of the centre
  17063. - y (number) y coordinate of the centre
  17064. - rx (number) horizontal radius
  17065. - ry (number) vertical radius
  17066. = (object) the `ellipse` element
  17067. **
  17068. > Usage
  17069. | var c = paper.ellipse(50, 50, 40, 20);
  17070. \*/
  17071. proto.ellipse = function (cx, cy, rx, ry) {
  17072. var attr;
  17073. if (is(cx, "object") && cx == "[object Object]") {
  17074. attr = cx;
  17075. } else if (cx != null) {
  17076. attr ={
  17077. cx: cx,
  17078. cy: cy,
  17079. rx: rx,
  17080. ry: ry
  17081. };
  17082. }
  17083. return this.el("ellipse", attr);
  17084. };
  17085. // SIERRA Paper.path(): Unclear from the link what a Catmull-Rom curveto is, and why it would make life any easier.
  17086. /*\
  17087. * Paper.path
  17088. [ method ]
  17089. **
  17090. * Creates a `<path>` element using the given string as the path's definition
  17091. - pathString (string) #optional path string in SVG format
  17092. * Path string consists of one-letter commands, followed by comma seprarated arguments in numerical form. Example:
  17093. | "M10,20L30,40"
  17094. * This example features two commands: `M`, with arguments `(10, 20)` and `L` with arguments `(30, 40)`. Uppercase letter commands express coordinates in absolute terms, while lowercase commands express them in relative terms from the most recently declared coordinates.
  17095. *
  17096. # <p>Here is short list of commands available, for more details see <a href="http://www.w3.org/TR/SVG/paths.html#PathData" title="Details of a path's data attribute's format are described in the SVG specification.">SVG path string format</a> or <a href="https://developer.mozilla.org/en/SVG/Tutorial/Paths">article about path strings at MDN</a>.</p>
  17097. # <table><thead><tr><th>Command</th><th>Name</th><th>Parameters</th></tr></thead><tbody>
  17098. # <tr><td>M</td><td>moveto</td><td>(x y)+</td></tr>
  17099. # <tr><td>Z</td><td>closepath</td><td>(none)</td></tr>
  17100. # <tr><td>L</td><td>lineto</td><td>(x y)+</td></tr>
  17101. # <tr><td>H</td><td>horizontal lineto</td><td>x+</td></tr>
  17102. # <tr><td>V</td><td>vertical lineto</td><td>y+</td></tr>
  17103. # <tr><td>C</td><td>curveto</td><td>(x1 y1 x2 y2 x y)+</td></tr>
  17104. # <tr><td>S</td><td>smooth curveto</td><td>(x2 y2 x y)+</td></tr>
  17105. # <tr><td>Q</td><td>quadratic Bézier curveto</td><td>(x1 y1 x y)+</td></tr>
  17106. # <tr><td>T</td><td>smooth quadratic Bézier curveto</td><td>(x y)+</td></tr>
  17107. # <tr><td>A</td><td>elliptical arc</td><td>(rx ry x-axis-rotation large-arc-flag sweep-flag x y)+</td></tr>
  17108. # <tr><td>R</td><td><a href="http://en.wikipedia.org/wiki/Catmull–Rom_spline#Catmull.E2.80.93Rom_spline">Catmull-Rom curveto</a>*</td><td>x1 y1 (x y)+</td></tr></tbody></table>
  17109. * * _Catmull-Rom curveto_ is a not standard SVG command and added to make life easier.
  17110. * Note: there is a special case when a path consists of only three commands: `M10,10R…z`. In this case the path connects back to its starting point.
  17111. > Usage
  17112. | var c = paper.path("M10 10L90 90");
  17113. | // draw a diagonal line:
  17114. | // move to 10,10, line to 90,90
  17115. \*/
  17116. proto.path = function (d) {
  17117. var attr;
  17118. if (is(d, "object") && !is(d, "array")) {
  17119. attr = d;
  17120. } else if (d) {
  17121. attr = {d: d};
  17122. }
  17123. return this.el("path", attr);
  17124. };
  17125. /*\
  17126. * Paper.g
  17127. [ method ]
  17128. **
  17129. * Creates a group element
  17130. **
  17131. - varargs (…) #optional elements to nest within the group
  17132. = (object) the `g` element
  17133. **
  17134. > Usage
  17135. | var c1 = paper.circle(),
  17136. | c2 = paper.rect(),
  17137. | g = paper.g(c2, c1); // note that the order of elements is different
  17138. * or
  17139. | var c1 = paper.circle(),
  17140. | c2 = paper.rect(),
  17141. | g = paper.g();
  17142. | g.add(c2, c1);
  17143. \*/
  17144. /*\
  17145. * Paper.group
  17146. [ method ]
  17147. **
  17148. * See @Paper.g
  17149. \*/
  17150. proto.group = proto.g = function (first) {
  17151. var attr,
  17152. el = this.el("g");
  17153. if (arguments.length == 1 && first && !first.type) {
  17154. el.attr(first);
  17155. } else if (arguments.length) {
  17156. el.add(Array.prototype.slice.call(arguments, 0));
  17157. }
  17158. return el;
  17159. };
  17160. /*\
  17161. * Paper.svg
  17162. [ method ]
  17163. **
  17164. * Creates a nested SVG element.
  17165. - x (number) @optional X of the element
  17166. - y (number) @optional Y of the element
  17167. - width (number) @optional width of the element
  17168. - height (number) @optional height of the element
  17169. - vbx (number) @optional viewbox X
  17170. - vby (number) @optional viewbox Y
  17171. - vbw (number) @optional viewbox width
  17172. - vbh (number) @optional viewbox height
  17173. **
  17174. = (object) the `svg` element
  17175. **
  17176. \*/
  17177. proto.svg = function (x, y, width, height, vbx, vby, vbw, vbh) {
  17178. var attrs = {};
  17179. if (is(x, "object") && y == null) {
  17180. attrs = x;
  17181. } else {
  17182. if (x != null) {
  17183. attrs.x = x;
  17184. }
  17185. if (y != null) {
  17186. attrs.y = y;
  17187. }
  17188. if (width != null) {
  17189. attrs.width = width;
  17190. }
  17191. if (height != null) {
  17192. attrs.height = height;
  17193. }
  17194. if (vbx != null && vby != null && vbw != null && vbh != null) {
  17195. attrs.viewBox = [vbx, vby, vbw, vbh];
  17196. }
  17197. }
  17198. return this.el("svg", attrs);
  17199. };
  17200. /*\
  17201. * Paper.mask
  17202. [ method ]
  17203. **
  17204. * Equivalent in behaviour to @Paper.g, except it’s a mask.
  17205. **
  17206. = (object) the `mask` element
  17207. **
  17208. \*/
  17209. proto.mask = function (first) {
  17210. var attr,
  17211. el = this.el("mask");
  17212. if (arguments.length == 1 && first && !first.type) {
  17213. el.attr(first);
  17214. } else if (arguments.length) {
  17215. el.add(Array.prototype.slice.call(arguments, 0));
  17216. }
  17217. return el;
  17218. };
  17219. /*\
  17220. * Paper.ptrn
  17221. [ method ]
  17222. **
  17223. * Equivalent in behaviour to @Paper.g, except it’s a pattern.
  17224. - x (number) @optional X of the element
  17225. - y (number) @optional Y of the element
  17226. - width (number) @optional width of the element
  17227. - height (number) @optional height of the element
  17228. - vbx (number) @optional viewbox X
  17229. - vby (number) @optional viewbox Y
  17230. - vbw (number) @optional viewbox width
  17231. - vbh (number) @optional viewbox height
  17232. **
  17233. = (object) the `pattern` element
  17234. **
  17235. \*/
  17236. proto.ptrn = function (x, y, width, height, vx, vy, vw, vh) {
  17237. if (is(x, "object")) {
  17238. var attr = x;
  17239. } else {
  17240. attr = {patternUnits: "userSpaceOnUse"};
  17241. if (x) {
  17242. attr.x = x;
  17243. }
  17244. if (y) {
  17245. attr.y = y;
  17246. }
  17247. if (width != null) {
  17248. attr.width = width;
  17249. }
  17250. if (height != null) {
  17251. attr.height = height;
  17252. }
  17253. if (vx != null && vy != null && vw != null && vh != null) {
  17254. attr.viewBox = [vx, vy, vw, vh];
  17255. }
  17256. }
  17257. return this.el("pattern", attr);
  17258. };
  17259. /*\
  17260. * Paper.use
  17261. [ method ]
  17262. **
  17263. * Creates a <use> element.
  17264. - id (string) @optional id of element to link
  17265. * or
  17266. - id (Element) @optional element to link
  17267. **
  17268. = (object) the `use` element
  17269. **
  17270. \*/
  17271. proto.use = function (id) {
  17272. if (id != null) {
  17273. if (id instanceof Element) {
  17274. if (!id.attr("id")) {
  17275. id.attr({id: Snap._.id(id)});
  17276. }
  17277. id = id.attr("id");
  17278. }
  17279. if (String(id).charAt() == "#") {
  17280. id = id.substring(1);
  17281. }
  17282. return this.el("use", {"xlink:href": "#" + id});
  17283. } else {
  17284. return Element.prototype.use.call(this);
  17285. }
  17286. };
  17287. /*\
  17288. * Paper.symbol
  17289. [ method ]
  17290. **
  17291. * Creates a <symbol> element.
  17292. - vbx (number) @optional viewbox X
  17293. - vby (number) @optional viewbox Y
  17294. - vbw (number) @optional viewbox width
  17295. - vbh (number) @optional viewbox height
  17296. = (object) the `symbol` element
  17297. **
  17298. \*/
  17299. proto.symbol = function (vx, vy, vw, vh) {
  17300. var attr = {};
  17301. if (vx != null && vy != null && vw != null && vh != null) {
  17302. attr.viewBox = [vx, vy, vw, vh];
  17303. }
  17304. return this.el("symbol", attr);
  17305. };
  17306. /*\
  17307. * Paper.text
  17308. [ method ]
  17309. **
  17310. * Draws a text string
  17311. **
  17312. - x (number) x coordinate position
  17313. - y (number) y coordinate position
  17314. - text (string|array) The text string to draw or array of strings to nest within separate `<tspan>` elements
  17315. = (object) the `text` element
  17316. **
  17317. > Usage
  17318. | var t1 = paper.text(50, 50, "Snap");
  17319. | var t2 = paper.text(50, 50, ["S","n","a","p"]);
  17320. | // Text path usage
  17321. | t1.attr({textpath: "M10,10L100,100"});
  17322. | // or
  17323. | var pth = paper.path("M10,10L100,100");
  17324. | t1.attr({textpath: pth});
  17325. \*/
  17326. proto.text = function (x, y, text) {
  17327. var attr = {};
  17328. if (is(x, "object")) {
  17329. attr = x;
  17330. } else if (x != null) {
  17331. attr = {
  17332. x: x,
  17333. y: y,
  17334. text: text || ""
  17335. };
  17336. }
  17337. return this.el("text", attr);
  17338. };
  17339. /*\
  17340. * Paper.line
  17341. [ method ]
  17342. **
  17343. * Draws a line
  17344. **
  17345. - x1 (number) x coordinate position of the start
  17346. - y1 (number) y coordinate position of the start
  17347. - x2 (number) x coordinate position of the end
  17348. - y2 (number) y coordinate position of the end
  17349. = (object) the `line` element
  17350. **
  17351. > Usage
  17352. | var t1 = paper.line(50, 50, 100, 100);
  17353. \*/
  17354. proto.line = function (x1, y1, x2, y2) {
  17355. var attr = {};
  17356. if (is(x1, "object")) {
  17357. attr = x1;
  17358. } else if (x1 != null) {
  17359. attr = {
  17360. x1: x1,
  17361. x2: x2,
  17362. y1: y1,
  17363. y2: y2
  17364. };
  17365. }
  17366. return this.el("line", attr);
  17367. };
  17368. /*\
  17369. * Paper.polyline
  17370. [ method ]
  17371. **
  17372. * Draws a polyline
  17373. **
  17374. - points (array) array of points
  17375. * or
  17376. - varargs (…) points
  17377. = (object) the `polyline` element
  17378. **
  17379. > Usage
  17380. | var p1 = paper.polyline([10, 10, 100, 100]);
  17381. | var p2 = paper.polyline(10, 10, 100, 100);
  17382. \*/
  17383. proto.polyline = function (points) {
  17384. if (arguments.length > 1) {
  17385. points = Array.prototype.slice.call(arguments, 0);
  17386. }
  17387. var attr = {};
  17388. if (is(points, "object") && !is(points, "array")) {
  17389. attr = points;
  17390. } else if (points != null) {
  17391. attr = {points: points};
  17392. }
  17393. return this.el("polyline", attr);
  17394. };
  17395. /*\
  17396. * Paper.polygon
  17397. [ method ]
  17398. **
  17399. * Draws a polygon. See @Paper.polyline
  17400. \*/
  17401. proto.polygon = function (points) {
  17402. if (arguments.length > 1) {
  17403. points = Array.prototype.slice.call(arguments, 0);
  17404. }
  17405. var attr = {};
  17406. if (is(points, "object") && !is(points, "array")) {
  17407. attr = points;
  17408. } else if (points != null) {
  17409. attr = {points: points};
  17410. }
  17411. return this.el("polygon", attr);
  17412. };
  17413. // gradients
  17414. (function () {
  17415. var $ = Snap._.$;
  17416. // gradients' helpers
  17417. function Gstops() {
  17418. return this.selectAll("stop");
  17419. }
  17420. function GaddStop(color, offset) {
  17421. var stop = $("stop"),
  17422. attr = {
  17423. offset: +offset + "%"
  17424. };
  17425. color = Snap.color(color);
  17426. attr["stop-color"] = color.hex;
  17427. if (color.opacity < 1) {
  17428. attr["stop-opacity"] = color.opacity;
  17429. }
  17430. $(stop, attr);
  17431. this.node.appendChild(stop);
  17432. return this;
  17433. }
  17434. function GgetBBox() {
  17435. if (this.type == "linearGradient") {
  17436. var x1 = $(this.node, "x1") || 0,
  17437. x2 = $(this.node, "x2") || 1,
  17438. y1 = $(this.node, "y1") || 0,
  17439. y2 = $(this.node, "y2") || 0;
  17440. return Snap._.box(x1, y1, math.abs(x2 - x1), math.abs(y2 - y1));
  17441. } else {
  17442. var cx = this.node.cx || .5,
  17443. cy = this.node.cy || .5,
  17444. r = this.node.r || 0;
  17445. return Snap._.box(cx - r, cy - r, r * 2, r * 2);
  17446. }
  17447. }
  17448. function gradient(defs, str) {
  17449. var grad = eve("snap.util.grad.parse", null, str).firstDefined(),
  17450. el;
  17451. if (!grad) {
  17452. return null;
  17453. }
  17454. grad.params.unshift(defs);
  17455. if (grad.type.toLowerCase() == "l") {
  17456. el = gradientLinear.apply(0, grad.params);
  17457. } else {
  17458. el = gradientRadial.apply(0, grad.params);
  17459. }
  17460. if (grad.type != grad.type.toLowerCase()) {
  17461. $(el.node, {
  17462. gradientUnits: "userSpaceOnUse"
  17463. });
  17464. }
  17465. var stops = grad.stops,
  17466. len = stops.length,
  17467. start = 0,
  17468. j = 0;
  17469. function seed(i, end) {
  17470. var step = (end - start) / (i - j);
  17471. for (var k = j; k < i; k++) {
  17472. stops[k].offset = +(+start + step * (k - j)).toFixed(2);
  17473. }
  17474. j = i;
  17475. start = end;
  17476. }
  17477. len--;
  17478. for (var i = 0; i < len; i++) if ("offset" in stops[i]) {
  17479. seed(i, stops[i].offset);
  17480. }
  17481. stops[len].offset = stops[len].offset || 100;
  17482. seed(len, stops[len].offset);
  17483. for (i = 0; i <= len; i++) {
  17484. var stop = stops[i];
  17485. el.addStop(stop.color, stop.offset);
  17486. }
  17487. return el;
  17488. }
  17489. function gradientLinear(defs, x1, y1, x2, y2) {
  17490. var el = Snap._.make("linearGradient", defs);
  17491. el.stops = Gstops;
  17492. el.addStop = GaddStop;
  17493. el.getBBox = GgetBBox;
  17494. if (x1 != null) {
  17495. $(el.node, {
  17496. x1: x1,
  17497. y1: y1,
  17498. x2: x2,
  17499. y2: y2
  17500. });
  17501. }
  17502. return el;
  17503. }
  17504. function gradientRadial(defs, cx, cy, r, fx, fy) {
  17505. var el = Snap._.make("radialGradient", defs);
  17506. el.stops = Gstops;
  17507. el.addStop = GaddStop;
  17508. el.getBBox = GgetBBox;
  17509. if (cx != null) {
  17510. $(el.node, {
  17511. cx: cx,
  17512. cy: cy,
  17513. r: r
  17514. });
  17515. }
  17516. if (fx != null && fy != null) {
  17517. $(el.node, {
  17518. fx: fx,
  17519. fy: fy
  17520. });
  17521. }
  17522. return el;
  17523. }
  17524. /*\
  17525. * Paper.gradient
  17526. [ method ]
  17527. **
  17528. * Creates a gradient element
  17529. **
  17530. - gradient (string) gradient descriptor
  17531. > Gradient Descriptor
  17532. * The gradient descriptor is an expression formatted as
  17533. * follows: `<type>(<coords>)<colors>`. The `<type>` can be
  17534. * either linear or radial. The uppercase `L` or `R` letters
  17535. * indicate absolute coordinates offset from the SVG surface.
  17536. * Lowercase `l` or `r` letters indicate coordinates
  17537. * calculated relative to the element to which the gradient is
  17538. * applied. Coordinates specify a linear gradient vector as
  17539. * `x1`, `y1`, `x2`, `y2`, or a radial gradient as `cx`, `cy`,
  17540. * `r` and optional `fx`, `fy` specifying a focal point away
  17541. * from the center of the circle. Specify `<colors>` as a list
  17542. * of dash-separated CSS color values. Each color may be
  17543. * followed by a custom offset value, separated with a colon
  17544. * character.
  17545. > Examples
  17546. * Linear gradient, relative from top-left corner to bottom-right
  17547. * corner, from black through red to white:
  17548. | var g = paper.gradient("l(0, 0, 1, 1)#000-#f00-#fff");
  17549. * Linear gradient, absolute from (0, 0) to (100, 100), from black
  17550. * through red at 25% to white:
  17551. | var g = paper.gradient("L(0, 0, 100, 100)#000-#f00:25-#fff");
  17552. * Radial gradient, relative from the center of the element with radius
  17553. * half the width, from black to white:
  17554. | var g = paper.gradient("r(0.5, 0.5, 0.5)#000-#fff");
  17555. * To apply the gradient:
  17556. | paper.circle(50, 50, 40).attr({
  17557. | fill: g
  17558. | });
  17559. = (object) the `gradient` element
  17560. \*/
  17561. proto.gradient = function (str) {
  17562. return gradient(this.defs, str);
  17563. };
  17564. proto.gradientLinear = function (x1, y1, x2, y2) {
  17565. return gradientLinear(this.defs, x1, y1, x2, y2);
  17566. };
  17567. proto.gradientRadial = function (cx, cy, r, fx, fy) {
  17568. return gradientRadial(this.defs, cx, cy, r, fx, fy);
  17569. };
  17570. /*\
  17571. * Paper.toString
  17572. [ method ]
  17573. **
  17574. * Returns SVG code for the @Paper
  17575. = (string) SVG code for the @Paper
  17576. \*/
  17577. proto.toString = function () {
  17578. var doc = this.node.ownerDocument,
  17579. f = doc.createDocumentFragment(),
  17580. d = doc.createElement("div"),
  17581. svg = this.node.cloneNode(true),
  17582. res;
  17583. f.appendChild(d);
  17584. d.appendChild(svg);
  17585. Snap._.$(svg, {xmlns: "http://www.w3.org/2000/svg"});
  17586. res = d.innerHTML;
  17587. f.removeChild(f.firstChild);
  17588. return res;
  17589. };
  17590. /*\
  17591. * Paper.toDataURL
  17592. [ method ]
  17593. **
  17594. * Returns SVG code for the @Paper as Data URI string.
  17595. = (string) Data URI string
  17596. \*/
  17597. proto.toDataURL = function () {
  17598. if (window && window.btoa) {
  17599. return "data:image/svg+xml;base64," + btoa(unescape(encodeURIComponent(this)));
  17600. }
  17601. };
  17602. /*\
  17603. * Paper.clear
  17604. [ method ]
  17605. **
  17606. * Removes all child nodes of the paper, except <defs>.
  17607. \*/
  17608. proto.clear = function () {
  17609. var node = this.node.firstChild,
  17610. next;
  17611. while (node) {
  17612. next = node.nextSibling;
  17613. if (node.tagName != "defs") {
  17614. node.parentNode.removeChild(node);
  17615. } else {
  17616. proto.clear.call({node: node});
  17617. }
  17618. node = next;
  17619. }
  17620. };
  17621. }());
  17622. });
  17623. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  17624. //
  17625. // Licensed under the Apache License, Version 2.0 (the "License");
  17626. // you may not use this file except in compliance with the License.
  17627. // You may obtain a copy of the License at
  17628. //
  17629. // http://www.apache.org/licenses/LICENSE-2.0
  17630. //
  17631. // Unless required by applicable law or agreed to in writing, software
  17632. // distributed under the License is distributed on an "AS IS" BASIS,
  17633. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17634. // See the License for the specific language governing permissions and
  17635. // limitations under the License.
  17636. Snap.plugin(function (Snap, Element, Paper, glob) {
  17637. var elproto = Element.prototype,
  17638. is = Snap.is,
  17639. clone = Snap._.clone,
  17640. has = "hasOwnProperty",
  17641. p2s = /,?([a-z]),?/gi,
  17642. toFloat = parseFloat,
  17643. math = Math,
  17644. PI = math.PI,
  17645. mmin = math.min,
  17646. mmax = math.max,
  17647. pow = math.pow,
  17648. abs = math.abs;
  17649. function paths(ps) {
  17650. var p = paths.ps = paths.ps || {};
  17651. if (p[ps]) {
  17652. p[ps].sleep = 100;
  17653. } else {
  17654. p[ps] = {
  17655. sleep: 100
  17656. };
  17657. }
  17658. setTimeout(function () {
  17659. for (var key in p) if (p[has](key) && key != ps) {
  17660. p[key].sleep--;
  17661. !p[key].sleep && delete p[key];
  17662. }
  17663. });
  17664. return p[ps];
  17665. }
  17666. function box(x, y, width, height) {
  17667. if (x == null) {
  17668. x = y = width = height = 0;
  17669. }
  17670. if (y == null) {
  17671. y = x.y;
  17672. width = x.width;
  17673. height = x.height;
  17674. x = x.x;
  17675. }
  17676. return {
  17677. x: x,
  17678. y: y,
  17679. width: width,
  17680. w: width,
  17681. height: height,
  17682. h: height,
  17683. x2: x + width,
  17684. y2: y + height,
  17685. cx: x + width / 2,
  17686. cy: y + height / 2,
  17687. r1: math.min(width, height) / 2,
  17688. r2: math.max(width, height) / 2,
  17689. r0: math.sqrt(width * width + height * height) / 2,
  17690. path: rectPath(x, y, width, height),
  17691. vb: [x, y, width, height].join(" ")
  17692. };
  17693. }
  17694. function toString() {
  17695. return this.join(",").replace(p2s, "$1");
  17696. }
  17697. function pathClone(pathArray) {
  17698. var res = clone(pathArray);
  17699. res.toString = toString;
  17700. return res;
  17701. }
  17702. function getPointAtSegmentLength(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) {
  17703. if (length == null) {
  17704. return bezlen(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y);
  17705. } else {
  17706. return findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y,
  17707. getTotLen(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length));
  17708. }
  17709. }
  17710. function getLengthFactory(istotal, subpath) {
  17711. function O(val) {
  17712. return +(+val).toFixed(3);
  17713. }
  17714. return Snap._.cacher(function (path, length, onlystart) {
  17715. if (path instanceof Element) {
  17716. path = path.attr("d");
  17717. }
  17718. path = path2curve(path);
  17719. var x, y, p, l, sp = "", subpaths = {}, point,
  17720. len = 0;
  17721. for (var i = 0, ii = path.length; i < ii; i++) {
  17722. p = path[i];
  17723. if (p[0] == "M") {
  17724. x = +p[1];
  17725. y = +p[2];
  17726. } else {
  17727. l = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
  17728. if (len + l > length) {
  17729. if (subpath && !subpaths.start) {
  17730. point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);
  17731. sp += [
  17732. "C" + O(point.start.x),
  17733. O(point.start.y),
  17734. O(point.m.x),
  17735. O(point.m.y),
  17736. O(point.x),
  17737. O(point.y)
  17738. ];
  17739. if (onlystart) {return sp;}
  17740. subpaths.start = sp;
  17741. sp = [
  17742. "M" + O(point.x),
  17743. O(point.y) + "C" + O(point.n.x),
  17744. O(point.n.y),
  17745. O(point.end.x),
  17746. O(point.end.y),
  17747. O(p[5]),
  17748. O(p[6])
  17749. ].join();
  17750. len += l;
  17751. x = +p[5];
  17752. y = +p[6];
  17753. continue;
  17754. }
  17755. if (!istotal && !subpath) {
  17756. point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);
  17757. return point;
  17758. }
  17759. }
  17760. len += l;
  17761. x = +p[5];
  17762. y = +p[6];
  17763. }
  17764. sp += p.shift() + p;
  17765. }
  17766. subpaths.end = sp;
  17767. point = istotal ? len : subpath ? subpaths : findDotsAtSegment(x, y, p[0], p[1], p[2], p[3], p[4], p[5], 1);
  17768. return point;
  17769. }, null, Snap._.clone);
  17770. }
  17771. var getTotalLength = getLengthFactory(1),
  17772. getPointAtLength = getLengthFactory(),
  17773. getSubpathsAtLength = getLengthFactory(0, 1);
  17774. function findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
  17775. var t1 = 1 - t,
  17776. t13 = pow(t1, 3),
  17777. t12 = pow(t1, 2),
  17778. t2 = t * t,
  17779. t3 = t2 * t,
  17780. x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x,
  17781. y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y,
  17782. mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x),
  17783. my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y),
  17784. nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x),
  17785. ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y),
  17786. ax = t1 * p1x + t * c1x,
  17787. ay = t1 * p1y + t * c1y,
  17788. cx = t1 * c2x + t * p2x,
  17789. cy = t1 * c2y + t * p2y,
  17790. alpha = (90 - math.atan2(mx - nx, my - ny) * 180 / PI);
  17791. // (mx > nx || my < ny) && (alpha += 180);
  17792. return {
  17793. x: x,
  17794. y: y,
  17795. m: {x: mx, y: my},
  17796. n: {x: nx, y: ny},
  17797. start: {x: ax, y: ay},
  17798. end: {x: cx, y: cy},
  17799. alpha: alpha
  17800. };
  17801. }
  17802. function bezierBBox(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
  17803. if (!Snap.is(p1x, "array")) {
  17804. p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];
  17805. }
  17806. var bbox = curveDim.apply(null, p1x);
  17807. return box(
  17808. bbox.min.x,
  17809. bbox.min.y,
  17810. bbox.max.x - bbox.min.x,
  17811. bbox.max.y - bbox.min.y
  17812. );
  17813. }
  17814. function isPointInsideBBox(bbox, x, y) {
  17815. return x >= bbox.x &&
  17816. x <= bbox.x + bbox.width &&
  17817. y >= bbox.y &&
  17818. y <= bbox.y + bbox.height;
  17819. }
  17820. function isBBoxIntersect(bbox1, bbox2) {
  17821. bbox1 = box(bbox1);
  17822. bbox2 = box(bbox2);
  17823. return isPointInsideBBox(bbox2, bbox1.x, bbox1.y)
  17824. || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y)
  17825. || isPointInsideBBox(bbox2, bbox1.x, bbox1.y2)
  17826. || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y2)
  17827. || isPointInsideBBox(bbox1, bbox2.x, bbox2.y)
  17828. || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y)
  17829. || isPointInsideBBox(bbox1, bbox2.x, bbox2.y2)
  17830. || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y2)
  17831. || (bbox1.x < bbox2.x2 && bbox1.x > bbox2.x
  17832. || bbox2.x < bbox1.x2 && bbox2.x > bbox1.x)
  17833. && (bbox1.y < bbox2.y2 && bbox1.y > bbox2.y
  17834. || bbox2.y < bbox1.y2 && bbox2.y > bbox1.y);
  17835. }
  17836. function base3(t, p1, p2, p3, p4) {
  17837. var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4,
  17838. t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
  17839. return t * t2 - 3 * p1 + 3 * p2;
  17840. }
  17841. function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
  17842. if (z == null) {
  17843. z = 1;
  17844. }
  17845. z = z > 1 ? 1 : z < 0 ? 0 : z;
  17846. var z2 = z / 2,
  17847. n = 12,
  17848. Tvalues = [-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],
  17849. Cvalues = [0.2491,0.2491,0.2335,0.2335,0.2032,0.2032,0.1601,0.1601,0.1069,0.1069,0.0472,0.0472],
  17850. sum = 0;
  17851. for (var i = 0; i < n; i++) {
  17852. var ct = z2 * Tvalues[i] + z2,
  17853. xbase = base3(ct, x1, x2, x3, x4),
  17854. ybase = base3(ct, y1, y2, y3, y4),
  17855. comb = xbase * xbase + ybase * ybase;
  17856. sum += Cvalues[i] * math.sqrt(comb);
  17857. }
  17858. return z2 * sum;
  17859. }
  17860. function getTotLen(x1, y1, x2, y2, x3, y3, x4, y4, ll) {
  17861. if (ll < 0 || bezlen(x1, y1, x2, y2, x3, y3, x4, y4) < ll) {
  17862. return;
  17863. }
  17864. var t = 1,
  17865. step = t / 2,
  17866. t2 = t - step,
  17867. l,
  17868. e = .01;
  17869. l = bezlen(x1, y1, x2, y2, x3, y3, x4, y4, t2);
  17870. while (abs(l - ll) > e) {
  17871. step /= 2;
  17872. t2 += (l < ll ? 1 : -1) * step;
  17873. l = bezlen(x1, y1, x2, y2, x3, y3, x4, y4, t2);
  17874. }
  17875. return t2;
  17876. }
  17877. function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {
  17878. if (
  17879. mmax(x1, x2) < mmin(x3, x4) ||
  17880. mmin(x1, x2) > mmax(x3, x4) ||
  17881. mmax(y1, y2) < mmin(y3, y4) ||
  17882. mmin(y1, y2) > mmax(y3, y4)
  17883. ) {
  17884. return;
  17885. }
  17886. var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4),
  17887. ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4),
  17888. denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
  17889. if (!denominator) {
  17890. return;
  17891. }
  17892. var px = nx / denominator,
  17893. py = ny / denominator,
  17894. px2 = +px.toFixed(2),
  17895. py2 = +py.toFixed(2);
  17896. if (
  17897. px2 < +mmin(x1, x2).toFixed(2) ||
  17898. px2 > +mmax(x1, x2).toFixed(2) ||
  17899. px2 < +mmin(x3, x4).toFixed(2) ||
  17900. px2 > +mmax(x3, x4).toFixed(2) ||
  17901. py2 < +mmin(y1, y2).toFixed(2) ||
  17902. py2 > +mmax(y1, y2).toFixed(2) ||
  17903. py2 < +mmin(y3, y4).toFixed(2) ||
  17904. py2 > +mmax(y3, y4).toFixed(2)
  17905. ) {
  17906. return;
  17907. }
  17908. return {x: px, y: py};
  17909. }
  17910. function inter(bez1, bez2) {
  17911. return interHelper(bez1, bez2);
  17912. }
  17913. function interCount(bez1, bez2) {
  17914. return interHelper(bez1, bez2, 1);
  17915. }
  17916. function interHelper(bez1, bez2, justCount) {
  17917. var bbox1 = bezierBBox(bez1),
  17918. bbox2 = bezierBBox(bez2);
  17919. if (!isBBoxIntersect(bbox1, bbox2)) {
  17920. return justCount ? 0 : [];
  17921. }
  17922. var l1 = bezlen.apply(0, bez1),
  17923. l2 = bezlen.apply(0, bez2),
  17924. n1 = ~~(l1 / 8),
  17925. n2 = ~~(l2 / 8),
  17926. dots1 = [],
  17927. dots2 = [],
  17928. xy = {},
  17929. res = justCount ? 0 : [];
  17930. for (var i = 0; i < n1 + 1; i++) {
  17931. var p = findDotsAtSegment.apply(0, bez1.concat(i / n1));
  17932. dots1.push({x: p.x, y: p.y, t: i / n1});
  17933. }
  17934. for (i = 0; i < n2 + 1; i++) {
  17935. p = findDotsAtSegment.apply(0, bez2.concat(i / n2));
  17936. dots2.push({x: p.x, y: p.y, t: i / n2});
  17937. }
  17938. for (i = 0; i < n1; i++) {
  17939. for (var j = 0; j < n2; j++) {
  17940. var di = dots1[i],
  17941. di1 = dots1[i + 1],
  17942. dj = dots2[j],
  17943. dj1 = dots2[j + 1],
  17944. ci = abs(di1.x - di.x) < .001 ? "y" : "x",
  17945. cj = abs(dj1.x - dj.x) < .001 ? "y" : "x",
  17946. is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);
  17947. if (is) {
  17948. if (xy[is.x.toFixed(4)] == is.y.toFixed(4)) {
  17949. continue;
  17950. }
  17951. xy[is.x.toFixed(4)] = is.y.toFixed(4);
  17952. var t1 = di.t + abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t),
  17953. t2 = dj.t + abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);
  17954. if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {
  17955. if (justCount) {
  17956. res++;
  17957. } else {
  17958. res.push({
  17959. x: is.x,
  17960. y: is.y,
  17961. t1: t1,
  17962. t2: t2
  17963. });
  17964. }
  17965. }
  17966. }
  17967. }
  17968. }
  17969. return res;
  17970. }
  17971. function pathIntersection(path1, path2) {
  17972. return interPathHelper(path1, path2);
  17973. }
  17974. function pathIntersectionNumber(path1, path2) {
  17975. return interPathHelper(path1, path2, 1);
  17976. }
  17977. function interPathHelper(path1, path2, justCount) {
  17978. path1 = path2curve(path1);
  17979. path2 = path2curve(path2);
  17980. var x1, y1, x2, y2, x1m, y1m, x2m, y2m, bez1, bez2,
  17981. res = justCount ? 0 : [];
  17982. for (var i = 0, ii = path1.length; i < ii; i++) {
  17983. var pi = path1[i];
  17984. if (pi[0] == "M") {
  17985. x1 = x1m = pi[1];
  17986. y1 = y1m = pi[2];
  17987. } else {
  17988. if (pi[0] == "C") {
  17989. bez1 = [x1, y1].concat(pi.slice(1));
  17990. x1 = bez1[6];
  17991. y1 = bez1[7];
  17992. } else {
  17993. bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];
  17994. x1 = x1m;
  17995. y1 = y1m;
  17996. }
  17997. for (var j = 0, jj = path2.length; j < jj; j++) {
  17998. var pj = path2[j];
  17999. if (pj[0] == "M") {
  18000. x2 = x2m = pj[1];
  18001. y2 = y2m = pj[2];
  18002. } else {
  18003. if (pj[0] == "C") {
  18004. bez2 = [x2, y2].concat(pj.slice(1));
  18005. x2 = bez2[6];
  18006. y2 = bez2[7];
  18007. } else {
  18008. bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];
  18009. x2 = x2m;
  18010. y2 = y2m;
  18011. }
  18012. var intr = interHelper(bez1, bez2, justCount);
  18013. if (justCount) {
  18014. res += intr;
  18015. } else {
  18016. for (var k = 0, kk = intr.length; k < kk; k++) {
  18017. intr[k].segment1 = i;
  18018. intr[k].segment2 = j;
  18019. intr[k].bez1 = bez1;
  18020. intr[k].bez2 = bez2;
  18021. }
  18022. res = res.concat(intr);
  18023. }
  18024. }
  18025. }
  18026. }
  18027. }
  18028. return res;
  18029. }
  18030. function isPointInsidePath(path, x, y) {
  18031. var bbox = pathBBox(path);
  18032. return isPointInsideBBox(bbox, x, y) &&
  18033. interPathHelper(path, [["M", x, y], ["H", bbox.x2 + 10]], 1) % 2 == 1;
  18034. }
  18035. function pathBBox(path) {
  18036. var pth = paths(path);
  18037. if (pth.bbox) {
  18038. return clone(pth.bbox);
  18039. }
  18040. if (!path) {
  18041. return box();
  18042. }
  18043. path = path2curve(path);
  18044. var x = 0,
  18045. y = 0,
  18046. X = [],
  18047. Y = [],
  18048. p;
  18049. for (var i = 0, ii = path.length; i < ii; i++) {
  18050. p = path[i];
  18051. if (p[0] == "M") {
  18052. x = p[1];
  18053. y = p[2];
  18054. X.push(x);
  18055. Y.push(y);
  18056. } else {
  18057. var dim = curveDim(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
  18058. X = X.concat(dim.min.x, dim.max.x);
  18059. Y = Y.concat(dim.min.y, dim.max.y);
  18060. x = p[5];
  18061. y = p[6];
  18062. }
  18063. }
  18064. var xmin = mmin.apply(0, X),
  18065. ymin = mmin.apply(0, Y),
  18066. xmax = mmax.apply(0, X),
  18067. ymax = mmax.apply(0, Y),
  18068. bb = box(xmin, ymin, xmax - xmin, ymax - ymin);
  18069. pth.bbox = clone(bb);
  18070. return bb;
  18071. }
  18072. function rectPath(x, y, w, h, r) {
  18073. if (r) {
  18074. return [
  18075. ["M", +x + (+r), y],
  18076. ["l", w - r * 2, 0],
  18077. ["a", r, r, 0, 0, 1, r, r],
  18078. ["l", 0, h - r * 2],
  18079. ["a", r, r, 0, 0, 1, -r, r],
  18080. ["l", r * 2 - w, 0],
  18081. ["a", r, r, 0, 0, 1, -r, -r],
  18082. ["l", 0, r * 2 - h],
  18083. ["a", r, r, 0, 0, 1, r, -r],
  18084. ["z"]
  18085. ];
  18086. }
  18087. var res = [["M", x, y], ["l", w, 0], ["l", 0, h], ["l", -w, 0], ["z"]];
  18088. res.toString = toString;
  18089. return res;
  18090. }
  18091. function ellipsePath(x, y, rx, ry, a) {
  18092. if (a == null && ry == null) {
  18093. ry = rx;
  18094. }
  18095. x = +x;
  18096. y = +y;
  18097. rx = +rx;
  18098. ry = +ry;
  18099. if (a != null) {
  18100. var rad = Math.PI / 180,
  18101. x1 = x + rx * Math.cos(-ry * rad),
  18102. x2 = x + rx * Math.cos(-a * rad),
  18103. y1 = y + rx * Math.sin(-ry * rad),
  18104. y2 = y + rx * Math.sin(-a * rad),
  18105. res = [["M", x1, y1], ["A", rx, rx, 0, +(a - ry > 180), 0, x2, y2]];
  18106. } else {
  18107. res = [
  18108. ["M", x, y],
  18109. ["m", 0, -ry],
  18110. ["a", rx, ry, 0, 1, 1, 0, 2 * ry],
  18111. ["a", rx, ry, 0, 1, 1, 0, -2 * ry],
  18112. ["z"]
  18113. ];
  18114. }
  18115. res.toString = toString;
  18116. return res;
  18117. }
  18118. var unit2px = Snap._unit2px,
  18119. getPath = {
  18120. path: function (el) {
  18121. return el.attr("path");
  18122. },
  18123. circle: function (el) {
  18124. var attr = unit2px(el);
  18125. return ellipsePath(attr.cx, attr.cy, attr.r);
  18126. },
  18127. ellipse: function (el) {
  18128. var attr = unit2px(el);
  18129. return ellipsePath(attr.cx || 0, attr.cy || 0, attr.rx, attr.ry);
  18130. },
  18131. rect: function (el) {
  18132. var attr = unit2px(el);
  18133. return rectPath(attr.x || 0, attr.y || 0, attr.width, attr.height, attr.rx, attr.ry);
  18134. },
  18135. image: function (el) {
  18136. var attr = unit2px(el);
  18137. return rectPath(attr.x || 0, attr.y || 0, attr.width, attr.height);
  18138. },
  18139. line: function (el) {
  18140. return "M" + [el.attr("x1") || 0, el.attr("y1") || 0, el.attr("x2"), el.attr("y2")];
  18141. },
  18142. polyline: function (el) {
  18143. return "M" + el.attr("points");
  18144. },
  18145. polygon: function (el) {
  18146. return "M" + el.attr("points") + "z";
  18147. },
  18148. deflt: function (el) {
  18149. var bbox = el.node.getBBox();
  18150. return rectPath(bbox.x, bbox.y, bbox.width, bbox.height);
  18151. }
  18152. };
  18153. function pathToRelative(pathArray) {
  18154. var pth = paths(pathArray),
  18155. lowerCase = String.prototype.toLowerCase;
  18156. if (pth.rel) {
  18157. return pathClone(pth.rel);
  18158. }
  18159. if (!Snap.is(pathArray, "array") || !Snap.is(pathArray && pathArray[0], "array")) {
  18160. pathArray = Snap.parsePathString(pathArray);
  18161. }
  18162. var res = [],
  18163. x = 0,
  18164. y = 0,
  18165. mx = 0,
  18166. my = 0,
  18167. start = 0;
  18168. if (pathArray[0][0] == "M") {
  18169. x = pathArray[0][1];
  18170. y = pathArray[0][2];
  18171. mx = x;
  18172. my = y;
  18173. start++;
  18174. res.push(["M", x, y]);
  18175. }
  18176. for (var i = start, ii = pathArray.length; i < ii; i++) {
  18177. var r = res[i] = [],
  18178. pa = pathArray[i];
  18179. if (pa[0] != lowerCase.call(pa[0])) {
  18180. r[0] = lowerCase.call(pa[0]);
  18181. switch (r[0]) {
  18182. case "a":
  18183. r[1] = pa[1];
  18184. r[2] = pa[2];
  18185. r[3] = pa[3];
  18186. r[4] = pa[4];
  18187. r[5] = pa[5];
  18188. r[6] = +(pa[6] - x).toFixed(3);
  18189. r[7] = +(pa[7] - y).toFixed(3);
  18190. break;
  18191. case "v":
  18192. r[1] = +(pa[1] - y).toFixed(3);
  18193. break;
  18194. case "m":
  18195. mx = pa[1];
  18196. my = pa[2];
  18197. default:
  18198. for (var j = 1, jj = pa.length; j < jj; j++) {
  18199. r[j] = +(pa[j] - ((j % 2) ? x : y)).toFixed(3);
  18200. }
  18201. }
  18202. } else {
  18203. r = res[i] = [];
  18204. if (pa[0] == "m") {
  18205. mx = pa[1] + x;
  18206. my = pa[2] + y;
  18207. }
  18208. for (var k = 0, kk = pa.length; k < kk; k++) {
  18209. res[i][k] = pa[k];
  18210. }
  18211. }
  18212. var len = res[i].length;
  18213. switch (res[i][0]) {
  18214. case "z":
  18215. x = mx;
  18216. y = my;
  18217. break;
  18218. case "h":
  18219. x += +res[i][len - 1];
  18220. break;
  18221. case "v":
  18222. y += +res[i][len - 1];
  18223. break;
  18224. default:
  18225. x += +res[i][len - 2];
  18226. y += +res[i][len - 1];
  18227. }
  18228. }
  18229. res.toString = toString;
  18230. pth.rel = pathClone(res);
  18231. return res;
  18232. }
  18233. function pathToAbsolute(pathArray) {
  18234. var pth = paths(pathArray);
  18235. if (pth.abs) {
  18236. return pathClone(pth.abs);
  18237. }
  18238. if (!is(pathArray, "array") || !is(pathArray && pathArray[0], "array")) { // rough assumption
  18239. pathArray = Snap.parsePathString(pathArray);
  18240. }
  18241. if (!pathArray || !pathArray.length) {
  18242. return [["M", 0, 0]];
  18243. }
  18244. var res = [],
  18245. x = 0,
  18246. y = 0,
  18247. mx = 0,
  18248. my = 0,
  18249. start = 0,
  18250. pa0;
  18251. if (pathArray[0][0] == "M") {
  18252. x = +pathArray[0][1];
  18253. y = +pathArray[0][2];
  18254. mx = x;
  18255. my = y;
  18256. start++;
  18257. res[0] = ["M", x, y];
  18258. }
  18259. var crz = pathArray.length == 3 &&
  18260. pathArray[0][0] == "M" &&
  18261. pathArray[1][0].toUpperCase() == "R" &&
  18262. pathArray[2][0].toUpperCase() == "Z";
  18263. for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {
  18264. res.push(r = []);
  18265. pa = pathArray[i];
  18266. pa0 = pa[0];
  18267. if (pa0 != pa0.toUpperCase()) {
  18268. r[0] = pa0.toUpperCase();
  18269. switch (r[0]) {
  18270. case "A":
  18271. r[1] = pa[1];
  18272. r[2] = pa[2];
  18273. r[3] = pa[3];
  18274. r[4] = pa[4];
  18275. r[5] = pa[5];
  18276. r[6] = +pa[6] + x;
  18277. r[7] = +pa[7] + y;
  18278. break;
  18279. case "V":
  18280. r[1] = +pa[1] + y;
  18281. break;
  18282. case "H":
  18283. r[1] = +pa[1] + x;
  18284. break;
  18285. case "R":
  18286. var dots = [x, y].concat(pa.slice(1));
  18287. for (var j = 2, jj = dots.length; j < jj; j++) {
  18288. dots[j] = +dots[j] + x;
  18289. dots[++j] = +dots[j] + y;
  18290. }
  18291. res.pop();
  18292. res = res.concat(catmullRom2bezier(dots, crz));
  18293. break;
  18294. case "O":
  18295. res.pop();
  18296. dots = ellipsePath(x, y, pa[1], pa[2]);
  18297. dots.push(dots[0]);
  18298. res = res.concat(dots);
  18299. break;
  18300. case "U":
  18301. res.pop();
  18302. res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
  18303. r = ["U"].concat(res[res.length - 1].slice(-2));
  18304. break;
  18305. case "M":
  18306. mx = +pa[1] + x;
  18307. my = +pa[2] + y;
  18308. default:
  18309. for (j = 1, jj = pa.length; j < jj; j++) {
  18310. r[j] = +pa[j] + ((j % 2) ? x : y);
  18311. }
  18312. }
  18313. } else if (pa0 == "R") {
  18314. dots = [x, y].concat(pa.slice(1));
  18315. res.pop();
  18316. res = res.concat(catmullRom2bezier(dots, crz));
  18317. r = ["R"].concat(pa.slice(-2));
  18318. } else if (pa0 == "O") {
  18319. res.pop();
  18320. dots = ellipsePath(x, y, pa[1], pa[2]);
  18321. dots.push(dots[0]);
  18322. res = res.concat(dots);
  18323. } else if (pa0 == "U") {
  18324. res.pop();
  18325. res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
  18326. r = ["U"].concat(res[res.length - 1].slice(-2));
  18327. } else {
  18328. for (var k = 0, kk = pa.length; k < kk; k++) {
  18329. r[k] = pa[k];
  18330. }
  18331. }
  18332. pa0 = pa0.toUpperCase();
  18333. if (pa0 != "O") {
  18334. switch (r[0]) {
  18335. case "Z":
  18336. x = +mx;
  18337. y = +my;
  18338. break;
  18339. case "H":
  18340. x = r[1];
  18341. break;
  18342. case "V":
  18343. y = r[1];
  18344. break;
  18345. case "M":
  18346. mx = r[r.length - 2];
  18347. my = r[r.length - 1];
  18348. default:
  18349. x = r[r.length - 2];
  18350. y = r[r.length - 1];
  18351. }
  18352. }
  18353. }
  18354. res.toString = toString;
  18355. pth.abs = pathClone(res);
  18356. return res;
  18357. }
  18358. function l2c(x1, y1, x2, y2) {
  18359. return [x1, y1, x2, y2, x2, y2];
  18360. }
  18361. function q2c(x1, y1, ax, ay, x2, y2) {
  18362. var _13 = 1 / 3,
  18363. _23 = 2 / 3;
  18364. return [
  18365. _13 * x1 + _23 * ax,
  18366. _13 * y1 + _23 * ay,
  18367. _13 * x2 + _23 * ax,
  18368. _13 * y2 + _23 * ay,
  18369. x2,
  18370. y2
  18371. ];
  18372. }
  18373. function a2c(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
  18374. // for more information of where this math came from visit:
  18375. // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
  18376. var _120 = PI * 120 / 180,
  18377. rad = PI / 180 * (+angle || 0),
  18378. res = [],
  18379. xy,
  18380. rotate = Snap._.cacher(function (x, y, rad) {
  18381. var X = x * math.cos(rad) - y * math.sin(rad),
  18382. Y = x * math.sin(rad) + y * math.cos(rad);
  18383. return {x: X, y: Y};
  18384. });
  18385. if (!recursive) {
  18386. xy = rotate(x1, y1, -rad);
  18387. x1 = xy.x;
  18388. y1 = xy.y;
  18389. xy = rotate(x2, y2, -rad);
  18390. x2 = xy.x;
  18391. y2 = xy.y;
  18392. var cos = math.cos(PI / 180 * angle),
  18393. sin = math.sin(PI / 180 * angle),
  18394. x = (x1 - x2) / 2,
  18395. y = (y1 - y2) / 2;
  18396. var h = (x * x) / (rx * rx) + (y * y) / (ry * ry);
  18397. if (h > 1) {
  18398. h = math.sqrt(h);
  18399. rx = h * rx;
  18400. ry = h * ry;
  18401. }
  18402. var rx2 = rx * rx,
  18403. ry2 = ry * ry,
  18404. k = (large_arc_flag == sweep_flag ? -1 : 1) *
  18405. math.sqrt(abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x))),
  18406. cx = k * rx * y / ry + (x1 + x2) / 2,
  18407. cy = k * -ry * x / rx + (y1 + y2) / 2,
  18408. f1 = math.asin(((y1 - cy) / ry).toFixed(9)),
  18409. f2 = math.asin(((y2 - cy) / ry).toFixed(9));
  18410. f1 = x1 < cx ? PI - f1 : f1;
  18411. f2 = x2 < cx ? PI - f2 : f2;
  18412. f1 < 0 && (f1 = PI * 2 + f1);
  18413. f2 < 0 && (f2 = PI * 2 + f2);
  18414. if (sweep_flag && f1 > f2) {
  18415. f1 = f1 - PI * 2;
  18416. }
  18417. if (!sweep_flag && f2 > f1) {
  18418. f2 = f2 - PI * 2;
  18419. }
  18420. } else {
  18421. f1 = recursive[0];
  18422. f2 = recursive[1];
  18423. cx = recursive[2];
  18424. cy = recursive[3];
  18425. }
  18426. var df = f2 - f1;
  18427. if (abs(df) > _120) {
  18428. var f2old = f2,
  18429. x2old = x2,
  18430. y2old = y2;
  18431. f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
  18432. x2 = cx + rx * math.cos(f2);
  18433. y2 = cy + ry * math.sin(f2);
  18434. res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
  18435. }
  18436. df = f2 - f1;
  18437. var c1 = math.cos(f1),
  18438. s1 = math.sin(f1),
  18439. c2 = math.cos(f2),
  18440. s2 = math.sin(f2),
  18441. t = math.tan(df / 4),
  18442. hx = 4 / 3 * rx * t,
  18443. hy = 4 / 3 * ry * t,
  18444. m1 = [x1, y1],
  18445. m2 = [x1 + hx * s1, y1 - hy * c1],
  18446. m3 = [x2 + hx * s2, y2 - hy * c2],
  18447. m4 = [x2, y2];
  18448. m2[0] = 2 * m1[0] - m2[0];
  18449. m2[1] = 2 * m1[1] - m2[1];
  18450. if (recursive) {
  18451. return [m2, m3, m4].concat(res);
  18452. } else {
  18453. res = [m2, m3, m4].concat(res).join().split(",");
  18454. var newres = [];
  18455. for (var i = 0, ii = res.length; i < ii; i++) {
  18456. newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
  18457. }
  18458. return newres;
  18459. }
  18460. }
  18461. function findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
  18462. var t1 = 1 - t;
  18463. return {
  18464. x: pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + pow(t, 3) * p2x,
  18465. y: pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + pow(t, 3) * p2y
  18466. };
  18467. }
  18468. // Returns bounding box of cubic bezier curve.
  18469. // Source: http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
  18470. // Original version: NISHIO Hirokazu
  18471. // Modifications: https://github.com/timo22345
  18472. function curveDim(x0, y0, x1, y1, x2, y2, x3, y3) {
  18473. var tvalues = [],
  18474. bounds = [[], []],
  18475. a, b, c, t, t1, t2, b2ac, sqrtb2ac;
  18476. for (var i = 0; i < 2; ++i) {
  18477. if (i == 0) {
  18478. b = 6 * x0 - 12 * x1 + 6 * x2;
  18479. a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
  18480. c = 3 * x1 - 3 * x0;
  18481. } else {
  18482. b = 6 * y0 - 12 * y1 + 6 * y2;
  18483. a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
  18484. c = 3 * y1 - 3 * y0;
  18485. }
  18486. if (abs(a) < 1e-12) {
  18487. if (abs(b) < 1e-12) {
  18488. continue;
  18489. }
  18490. t = -c / b;
  18491. if (0 < t && t < 1) {
  18492. tvalues.push(t);
  18493. }
  18494. continue;
  18495. }
  18496. b2ac = b * b - 4 * c * a;
  18497. sqrtb2ac = math.sqrt(b2ac);
  18498. if (b2ac < 0) {
  18499. continue;
  18500. }
  18501. t1 = (-b + sqrtb2ac) / (2 * a);
  18502. if (0 < t1 && t1 < 1) {
  18503. tvalues.push(t1);
  18504. }
  18505. t2 = (-b - sqrtb2ac) / (2 * a);
  18506. if (0 < t2 && t2 < 1) {
  18507. tvalues.push(t2);
  18508. }
  18509. }
  18510. var x, y, j = tvalues.length,
  18511. jlen = j,
  18512. mt;
  18513. while (j--) {
  18514. t = tvalues[j];
  18515. mt = 1 - t;
  18516. bounds[0][j] = (mt * mt * mt * x0) + (3 * mt * mt * t * x1) + (3 * mt * t * t * x2) + (t * t * t * x3);
  18517. bounds[1][j] = (mt * mt * mt * y0) + (3 * mt * mt * t * y1) + (3 * mt * t * t * y2) + (t * t * t * y3);
  18518. }
  18519. bounds[0][jlen] = x0;
  18520. bounds[1][jlen] = y0;
  18521. bounds[0][jlen + 1] = x3;
  18522. bounds[1][jlen + 1] = y3;
  18523. bounds[0].length = bounds[1].length = jlen + 2;
  18524. return {
  18525. min: {x: mmin.apply(0, bounds[0]), y: mmin.apply(0, bounds[1])},
  18526. max: {x: mmax.apply(0, bounds[0]), y: mmax.apply(0, bounds[1])}
  18527. };
  18528. }
  18529. function path2curve(path, path2) {
  18530. var pth = !path2 && paths(path);
  18531. if (!path2 && pth.curve) {
  18532. return pathClone(pth.curve);
  18533. }
  18534. var p = pathToAbsolute(path),
  18535. p2 = path2 && pathToAbsolute(path2),
  18536. attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
  18537. attrs2 = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
  18538. processPath = function (path, d, pcom) {
  18539. var nx, ny;
  18540. if (!path) {
  18541. return ["C", d.x, d.y, d.x, d.y, d.x, d.y];
  18542. }
  18543. !(path[0] in {T: 1, Q: 1}) && (d.qx = d.qy = null);
  18544. switch (path[0]) {
  18545. case "M":
  18546. d.X = path[1];
  18547. d.Y = path[2];
  18548. break;
  18549. case "A":
  18550. path = ["C"].concat(a2c.apply(0, [d.x, d.y].concat(path.slice(1))));
  18551. break;
  18552. case "S":
  18553. if (pcom == "C" || pcom == "S") { // In "S" case we have to take into account, if the previous command is C/S.
  18554. nx = d.x * 2 - d.bx; // And reflect the previous
  18555. ny = d.y * 2 - d.by; // command's control point relative to the current point.
  18556. }
  18557. else { // or some else or nothing
  18558. nx = d.x;
  18559. ny = d.y;
  18560. }
  18561. path = ["C", nx, ny].concat(path.slice(1));
  18562. break;
  18563. case "T":
  18564. if (pcom == "Q" || pcom == "T") { // In "T" case we have to take into account, if the previous command is Q/T.
  18565. d.qx = d.x * 2 - d.qx; // And make a reflection similar
  18566. d.qy = d.y * 2 - d.qy; // to case "S".
  18567. }
  18568. else { // or something else or nothing
  18569. d.qx = d.x;
  18570. d.qy = d.y;
  18571. }
  18572. path = ["C"].concat(q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
  18573. break;
  18574. case "Q":
  18575. d.qx = path[1];
  18576. d.qy = path[2];
  18577. path = ["C"].concat(q2c(d.x, d.y, path[1], path[2], path[3], path[4]));
  18578. break;
  18579. case "L":
  18580. path = ["C"].concat(l2c(d.x, d.y, path[1], path[2]));
  18581. break;
  18582. case "H":
  18583. path = ["C"].concat(l2c(d.x, d.y, path[1], d.y));
  18584. break;
  18585. case "V":
  18586. path = ["C"].concat(l2c(d.x, d.y, d.x, path[1]));
  18587. break;
  18588. case "Z":
  18589. path = ["C"].concat(l2c(d.x, d.y, d.X, d.Y));
  18590. break;
  18591. }
  18592. return path;
  18593. },
  18594. fixArc = function (pp, i) {
  18595. if (pp[i].length > 7) {
  18596. pp[i].shift();
  18597. var pi = pp[i];
  18598. while (pi.length) {
  18599. pcoms1[i] = "A"; // if created multiple C:s, their original seg is saved
  18600. p2 && (pcoms2[i] = "A"); // the same as above
  18601. pp.splice(i++, 0, ["C"].concat(pi.splice(0, 6)));
  18602. }
  18603. pp.splice(i, 1);
  18604. ii = mmax(p.length, p2 && p2.length || 0);
  18605. }
  18606. },
  18607. fixM = function (path1, path2, a1, a2, i) {
  18608. if (path1 && path2 && path1[i][0] == "M" && path2[i][0] != "M") {
  18609. path2.splice(i, 0, ["M", a2.x, a2.y]);
  18610. a1.bx = 0;
  18611. a1.by = 0;
  18612. a1.x = path1[i][1];
  18613. a1.y = path1[i][2];
  18614. ii = mmax(p.length, p2 && p2.length || 0);
  18615. }
  18616. },
  18617. pcoms1 = [], // path commands of original path p
  18618. pcoms2 = [], // path commands of original path p2
  18619. pfirst = "", // temporary holder for original path command
  18620. pcom = ""; // holder for previous path command of original path
  18621. for (var i = 0, ii = mmax(p.length, p2 && p2.length || 0); i < ii; i++) {
  18622. p[i] && (pfirst = p[i][0]); // save current path command
  18623. if (pfirst != "C") // C is not saved yet, because it may be result of conversion
  18624. {
  18625. pcoms1[i] = pfirst; // Save current path command
  18626. i && ( pcom = pcoms1[i - 1]); // Get previous path command pcom
  18627. }
  18628. p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath
  18629. if (pcoms1[i] != "A" && pfirst == "C") pcoms1[i] = "C"; // A is the only command
  18630. // which may produce multiple C:s
  18631. // so we have to make sure that C is also C in original path
  18632. fixArc(p, i); // fixArc adds also the right amount of A:s to pcoms1
  18633. if (p2) { // the same procedures is done to p2
  18634. p2[i] && (pfirst = p2[i][0]);
  18635. if (pfirst != "C") {
  18636. pcoms2[i] = pfirst;
  18637. i && (pcom = pcoms2[i - 1]);
  18638. }
  18639. p2[i] = processPath(p2[i], attrs2, pcom);
  18640. if (pcoms2[i] != "A" && pfirst == "C") {
  18641. pcoms2[i] = "C";
  18642. }
  18643. fixArc(p2, i);
  18644. }
  18645. fixM(p, p2, attrs, attrs2, i);
  18646. fixM(p2, p, attrs2, attrs, i);
  18647. var seg = p[i],
  18648. seg2 = p2 && p2[i],
  18649. seglen = seg.length,
  18650. seg2len = p2 && seg2.length;
  18651. attrs.x = seg[seglen - 2];
  18652. attrs.y = seg[seglen - 1];
  18653. attrs.bx = toFloat(seg[seglen - 4]) || attrs.x;
  18654. attrs.by = toFloat(seg[seglen - 3]) || attrs.y;
  18655. attrs2.bx = p2 && (toFloat(seg2[seg2len - 4]) || attrs2.x);
  18656. attrs2.by = p2 && (toFloat(seg2[seg2len - 3]) || attrs2.y);
  18657. attrs2.x = p2 && seg2[seg2len - 2];
  18658. attrs2.y = p2 && seg2[seg2len - 1];
  18659. }
  18660. if (!p2) {
  18661. pth.curve = pathClone(p);
  18662. }
  18663. return p2 ? [p, p2] : p;
  18664. }
  18665. function mapPath(path, matrix) {
  18666. if (!matrix) {
  18667. return path;
  18668. }
  18669. var x, y, i, j, ii, jj, pathi;
  18670. path = path2curve(path);
  18671. for (i = 0, ii = path.length; i < ii; i++) {
  18672. pathi = path[i];
  18673. for (j = 1, jj = pathi.length; j < jj; j += 2) {
  18674. x = matrix.x(pathi[j], pathi[j + 1]);
  18675. y = matrix.y(pathi[j], pathi[j + 1]);
  18676. pathi[j] = x;
  18677. pathi[j + 1] = y;
  18678. }
  18679. }
  18680. return path;
  18681. }
  18682. // http://schepers.cc/getting-to-the-point
  18683. function catmullRom2bezier(crp, z) {
  18684. var d = [];
  18685. for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {
  18686. var p = [
  18687. {x: +crp[i - 2], y: +crp[i - 1]},
  18688. {x: +crp[i], y: +crp[i + 1]},
  18689. {x: +crp[i + 2], y: +crp[i + 3]},
  18690. {x: +crp[i + 4], y: +crp[i + 5]}
  18691. ];
  18692. if (z) {
  18693. if (!i) {
  18694. p[0] = {x: +crp[iLen - 2], y: +crp[iLen - 1]};
  18695. } else if (iLen - 4 == i) {
  18696. p[3] = {x: +crp[0], y: +crp[1]};
  18697. } else if (iLen - 2 == i) {
  18698. p[2] = {x: +crp[0], y: +crp[1]};
  18699. p[3] = {x: +crp[2], y: +crp[3]};
  18700. }
  18701. } else {
  18702. if (iLen - 4 == i) {
  18703. p[3] = p[2];
  18704. } else if (!i) {
  18705. p[0] = {x: +crp[i], y: +crp[i + 1]};
  18706. }
  18707. }
  18708. d.push(["C",
  18709. (-p[0].x + 6 * p[1].x + p[2].x) / 6,
  18710. (-p[0].y + 6 * p[1].y + p[2].y) / 6,
  18711. (p[1].x + 6 * p[2].x - p[3].x) / 6,
  18712. (p[1].y + 6*p[2].y - p[3].y) / 6,
  18713. p[2].x,
  18714. p[2].y
  18715. ]);
  18716. }
  18717. return d;
  18718. }
  18719. // export
  18720. Snap.path = paths;
  18721. /*\
  18722. * Snap.path.getTotalLength
  18723. [ method ]
  18724. **
  18725. * Returns the length of the given path in pixels
  18726. **
  18727. - path (string) SVG path string
  18728. **
  18729. = (number) length
  18730. \*/
  18731. Snap.path.getTotalLength = getTotalLength;
  18732. /*\
  18733. * Snap.path.getPointAtLength
  18734. [ method ]
  18735. **
  18736. * Returns the coordinates of the point located at the given length along the given path
  18737. **
  18738. - path (string) SVG path string
  18739. - length (number) length, in pixels, from the start of the path, excluding non-rendering jumps
  18740. **
  18741. = (object) representation of the point:
  18742. o {
  18743. o x: (number) x coordinate,
  18744. o y: (number) y coordinate,
  18745. o alpha: (number) angle of derivative
  18746. o }
  18747. \*/
  18748. Snap.path.getPointAtLength = getPointAtLength;
  18749. /*\
  18750. * Snap.path.getSubpath
  18751. [ method ]
  18752. **
  18753. * Returns the subpath of a given path between given start and end lengths
  18754. **
  18755. - path (string) SVG path string
  18756. - from (number) length, in pixels, from the start of the path to the start of the segment
  18757. - to (number) length, in pixels, from the start of the path to the end of the segment
  18758. **
  18759. = (string) path string definition for the segment
  18760. \*/
  18761. Snap.path.getSubpath = function (path, from, to) {
  18762. if (this.getTotalLength(path) - to < 1e-6) {
  18763. return getSubpathsAtLength(path, from).end;
  18764. }
  18765. var a = getSubpathsAtLength(path, to, 1);
  18766. return from ? getSubpathsAtLength(a, from).end : a;
  18767. };
  18768. /*\
  18769. * Element.getTotalLength
  18770. [ method ]
  18771. **
  18772. * Returns the length of the path in pixels (only works for `path` elements)
  18773. = (number) length
  18774. \*/
  18775. elproto.getTotalLength = function () {
  18776. if (this.node.getTotalLength) {
  18777. return this.node.getTotalLength();
  18778. }
  18779. };
  18780. // SIERRA Element.getPointAtLength()/Element.getTotalLength(): If a <path> is broken into different segments, is the jump distance to the new coordinates set by the _M_ or _m_ commands calculated as part of the path's total length?
  18781. /*\
  18782. * Element.getPointAtLength
  18783. [ method ]
  18784. **
  18785. * Returns coordinates of the point located at the given length on the given path (only works for `path` elements)
  18786. **
  18787. - length (number) length, in pixels, from the start of the path, excluding non-rendering jumps
  18788. **
  18789. = (object) representation of the point:
  18790. o {
  18791. o x: (number) x coordinate,
  18792. o y: (number) y coordinate,
  18793. o alpha: (number) angle of derivative
  18794. o }
  18795. \*/
  18796. elproto.getPointAtLength = function (length) {
  18797. return getPointAtLength(this.attr("d"), length);
  18798. };
  18799. // SIERRA Element.getSubpath(): Similar to the problem for Element.getPointAtLength(). Unclear how this would work for a segmented path. Overall, the concept of _subpath_ and what I'm calling a _segment_ (series of non-_M_ or _Z_ commands) is unclear.
  18800. /*\
  18801. * Element.getSubpath
  18802. [ method ]
  18803. **
  18804. * Returns subpath of a given element from given start and end lengths (only works for `path` elements)
  18805. **
  18806. - from (number) length, in pixels, from the start of the path to the start of the segment
  18807. - to (number) length, in pixels, from the start of the path to the end of the segment
  18808. **
  18809. = (string) path string definition for the segment
  18810. \*/
  18811. elproto.getSubpath = function (from, to) {
  18812. return Snap.path.getSubpath(this.attr("d"), from, to);
  18813. };
  18814. Snap._.box = box;
  18815. /*\
  18816. * Snap.path.findDotsAtSegment
  18817. [ method ]
  18818. **
  18819. * Utility method
  18820. **
  18821. * Finds dot coordinates on the given cubic beziér curve at the given t
  18822. - p1x (number) x of the first point of the curve
  18823. - p1y (number) y of the first point of the curve
  18824. - c1x (number) x of the first anchor of the curve
  18825. - c1y (number) y of the first anchor of the curve
  18826. - c2x (number) x of the second anchor of the curve
  18827. - c2y (number) y of the second anchor of the curve
  18828. - p2x (number) x of the second point of the curve
  18829. - p2y (number) y of the second point of the curve
  18830. - t (number) position on the curve (0..1)
  18831. = (object) point information in format:
  18832. o {
  18833. o x: (number) x coordinate of the point,
  18834. o y: (number) y coordinate of the point,
  18835. o m: {
  18836. o x: (number) x coordinate of the left anchor,
  18837. o y: (number) y coordinate of the left anchor
  18838. o },
  18839. o n: {
  18840. o x: (number) x coordinate of the right anchor,
  18841. o y: (number) y coordinate of the right anchor
  18842. o },
  18843. o start: {
  18844. o x: (number) x coordinate of the start of the curve,
  18845. o y: (number) y coordinate of the start of the curve
  18846. o },
  18847. o end: {
  18848. o x: (number) x coordinate of the end of the curve,
  18849. o y: (number) y coordinate of the end of the curve
  18850. o },
  18851. o alpha: (number) angle of the curve derivative at the point
  18852. o }
  18853. \*/
  18854. Snap.path.findDotsAtSegment = findDotsAtSegment;
  18855. /*\
  18856. * Snap.path.bezierBBox
  18857. [ method ]
  18858. **
  18859. * Utility method
  18860. **
  18861. * Returns the bounding box of a given cubic beziér curve
  18862. - p1x (number) x of the first point of the curve
  18863. - p1y (number) y of the first point of the curve
  18864. - c1x (number) x of the first anchor of the curve
  18865. - c1y (number) y of the first anchor of the curve
  18866. - c2x (number) x of the second anchor of the curve
  18867. - c2y (number) y of the second anchor of the curve
  18868. - p2x (number) x of the second point of the curve
  18869. - p2y (number) y of the second point of the curve
  18870. * or
  18871. - bez (array) array of six points for beziér curve
  18872. = (object) bounding box
  18873. o {
  18874. o x: (number) x coordinate of the left top point of the box,
  18875. o y: (number) y coordinate of the left top point of the box,
  18876. o x2: (number) x coordinate of the right bottom point of the box,
  18877. o y2: (number) y coordinate of the right bottom point of the box,
  18878. o width: (number) width of the box,
  18879. o height: (number) height of the box
  18880. o }
  18881. \*/
  18882. Snap.path.bezierBBox = bezierBBox;
  18883. /*\
  18884. * Snap.path.isPointInsideBBox
  18885. [ method ]
  18886. **
  18887. * Utility method
  18888. **
  18889. * Returns `true` if given point is inside bounding box
  18890. - bbox (string) bounding box
  18891. - x (string) x coordinate of the point
  18892. - y (string) y coordinate of the point
  18893. = (boolean) `true` if point is inside
  18894. \*/
  18895. Snap.path.isPointInsideBBox = isPointInsideBBox;
  18896. /*\
  18897. * Snap.path.isBBoxIntersect
  18898. [ method ]
  18899. **
  18900. * Utility method
  18901. **
  18902. * Returns `true` if two bounding boxes intersect
  18903. - bbox1 (string) first bounding box
  18904. - bbox2 (string) second bounding box
  18905. = (boolean) `true` if bounding boxes intersect
  18906. \*/
  18907. Snap.path.isBBoxIntersect = isBBoxIntersect;
  18908. /*\
  18909. * Snap.path.intersection
  18910. [ method ]
  18911. **
  18912. * Utility method
  18913. **
  18914. * Finds intersections of two paths
  18915. - path1 (string) path string
  18916. - path2 (string) path string
  18917. = (array) dots of intersection
  18918. o [
  18919. o {
  18920. o x: (number) x coordinate of the point,
  18921. o y: (number) y coordinate of the point,
  18922. o t1: (number) t value for segment of path1,
  18923. o t2: (number) t value for segment of path2,
  18924. o segment1: (number) order number for segment of path1,
  18925. o segment2: (number) order number for segment of path2,
  18926. o bez1: (array) eight coordinates representing beziér curve for the segment of path1,
  18927. o bez2: (array) eight coordinates representing beziér curve for the segment of path2
  18928. o }
  18929. o ]
  18930. \*/
  18931. Snap.path.intersection = pathIntersection;
  18932. Snap.path.intersectionNumber = pathIntersectionNumber;
  18933. /*\
  18934. * Snap.path.isPointInside
  18935. [ method ]
  18936. **
  18937. * Utility method
  18938. **
  18939. * Returns `true` if given point is inside a given closed path.
  18940. *
  18941. * Note: fill mode doesn’t affect the result of this method.
  18942. - path (string) path string
  18943. - x (number) x of the point
  18944. - y (number) y of the point
  18945. = (boolean) `true` if point is inside the path
  18946. \*/
  18947. Snap.path.isPointInside = isPointInsidePath;
  18948. /*\
  18949. * Snap.path.getBBox
  18950. [ method ]
  18951. **
  18952. * Utility method
  18953. **
  18954. * Returns the bounding box of a given path
  18955. - path (string) path string
  18956. = (object) bounding box
  18957. o {
  18958. o x: (number) x coordinate of the left top point of the box,
  18959. o y: (number) y coordinate of the left top point of the box,
  18960. o x2: (number) x coordinate of the right bottom point of the box,
  18961. o y2: (number) y coordinate of the right bottom point of the box,
  18962. o width: (number) width of the box,
  18963. o height: (number) height of the box
  18964. o }
  18965. \*/
  18966. Snap.path.getBBox = pathBBox;
  18967. Snap.path.get = getPath;
  18968. /*\
  18969. * Snap.path.toRelative
  18970. [ method ]
  18971. **
  18972. * Utility method
  18973. **
  18974. * Converts path coordinates into relative values
  18975. - path (string) path string
  18976. = (array) path string
  18977. \*/
  18978. Snap.path.toRelative = pathToRelative;
  18979. /*\
  18980. * Snap.path.toAbsolute
  18981. [ method ]
  18982. **
  18983. * Utility method
  18984. **
  18985. * Converts path coordinates into absolute values
  18986. - path (string) path string
  18987. = (array) path string
  18988. \*/
  18989. Snap.path.toAbsolute = pathToAbsolute;
  18990. /*\
  18991. * Snap.path.toCubic
  18992. [ method ]
  18993. **
  18994. * Utility method
  18995. **
  18996. * Converts path to a new path where all segments are cubic beziér curves
  18997. - pathString (string|array) path string or array of segments
  18998. = (array) array of segments
  18999. \*/
  19000. Snap.path.toCubic = path2curve;
  19001. /*\
  19002. * Snap.path.map
  19003. [ method ]
  19004. **
  19005. * Transform the path string with the given matrix
  19006. - path (string) path string
  19007. - matrix (object) see @Matrix
  19008. = (string) transformed path string
  19009. \*/
  19010. Snap.path.map = mapPath;
  19011. Snap.path.toString = toString;
  19012. Snap.path.clone = pathClone;
  19013. });
  19014. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  19015. //
  19016. // Licensed under the Apache License, Version 2.0 (the "License");
  19017. // you may not use this file except in compliance with the License.
  19018. // You may obtain a copy of the License at
  19019. //
  19020. // http://www.apache.org/licenses/LICENSE-2.0
  19021. //
  19022. // Unless required by applicable law or agreed to in writing, software
  19023. // distributed under the License is distributed on an "AS IS" BASIS,
  19024. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19025. // See the License for the specific language governing permissions and
  19026. // limitations under the License.
  19027. Snap.plugin(function (Snap, Element, Paper, glob) {
  19028. var elproto = Element.prototype,
  19029. has = "hasOwnProperty",
  19030. supportsTouch = "createTouch" in glob.doc,
  19031. events = [
  19032. "click", "dblclick", "mousedown", "mousemove", "mouseout",
  19033. "mouseover", "mouseup", "touchstart", "touchmove", "touchend",
  19034. "touchcancel"
  19035. ],
  19036. touchMap = {
  19037. mousedown: "touchstart",
  19038. mousemove: "touchmove",
  19039. mouseup: "touchend"
  19040. },
  19041. getScroll = function (xy, el) {
  19042. var name = xy == "y" ? "scrollTop" : "scrollLeft",
  19043. doc = el && el.node ? el.node.ownerDocument : glob.doc;
  19044. return doc[name in doc.documentElement ? "documentElement" : "body"][name];
  19045. },
  19046. preventDefault = function () {
  19047. this.returnValue = false;
  19048. },
  19049. preventTouch = function () {
  19050. return this.originalEvent.preventDefault();
  19051. },
  19052. stopPropagation = function () {
  19053. this.cancelBubble = true;
  19054. },
  19055. stopTouch = function () {
  19056. return this.originalEvent.stopPropagation();
  19057. },
  19058. addEvent = (function () {
  19059. if (glob.doc.addEventListener) {
  19060. return function (obj, type, fn, element) {
  19061. var realName = supportsTouch && touchMap[type] ? touchMap[type] : type,
  19062. f = function (e) {
  19063. var scrollY = getScroll("y", element),
  19064. scrollX = getScroll("x", element);
  19065. if (supportsTouch && touchMap[has](type)) {
  19066. for (var i = 0, ii = e.targetTouches && e.targetTouches.length; i < ii; i++) {
  19067. if (e.targetTouches[i].target == obj || obj.contains(e.targetTouches[i].target)) {
  19068. var olde = e;
  19069. e = e.targetTouches[i];
  19070. e.originalEvent = olde;
  19071. e.preventDefault = preventTouch;
  19072. e.stopPropagation = stopTouch;
  19073. break;
  19074. }
  19075. }
  19076. }
  19077. var x = e.clientX + scrollX,
  19078. y = e.clientY + scrollY;
  19079. return fn.call(element, e, x, y);
  19080. };
  19081. if (type !== realName) {
  19082. obj.addEventListener(type, f, false);
  19083. }
  19084. obj.addEventListener(realName, f, false);
  19085. return function () {
  19086. if (type !== realName) {
  19087. obj.removeEventListener(type, f, false);
  19088. }
  19089. obj.removeEventListener(realName, f, false);
  19090. return true;
  19091. };
  19092. };
  19093. } else if (glob.doc.attachEvent) {
  19094. return function (obj, type, fn, element) {
  19095. var f = function (e) {
  19096. e = e || element.node.ownerDocument.window.event;
  19097. var scrollY = getScroll("y", element),
  19098. scrollX = getScroll("x", element),
  19099. x = e.clientX + scrollX,
  19100. y = e.clientY + scrollY;
  19101. e.preventDefault = e.preventDefault || preventDefault;
  19102. e.stopPropagation = e.stopPropagation || stopPropagation;
  19103. return fn.call(element, e, x, y);
  19104. };
  19105. obj.attachEvent("on" + type, f);
  19106. var detacher = function () {
  19107. obj.detachEvent("on" + type, f);
  19108. return true;
  19109. };
  19110. return detacher;
  19111. };
  19112. }
  19113. })(),
  19114. drag = [],
  19115. dragMove = function (e) {
  19116. var x = e.clientX,
  19117. y = e.clientY,
  19118. scrollY = getScroll("y"),
  19119. scrollX = getScroll("x"),
  19120. dragi,
  19121. j = drag.length;
  19122. while (j--) {
  19123. dragi = drag[j];
  19124. if (supportsTouch) {
  19125. var i = e.touches && e.touches.length,
  19126. touch;
  19127. while (i--) {
  19128. touch = e.touches[i];
  19129. if (touch.identifier == dragi.el._drag.id || dragi.el.node.contains(touch.target)) {
  19130. x = touch.clientX;
  19131. y = touch.clientY;
  19132. (e.originalEvent ? e.originalEvent : e).preventDefault();
  19133. break;
  19134. }
  19135. }
  19136. } else {
  19137. e.preventDefault();
  19138. }
  19139. var node = dragi.el.node,
  19140. o,
  19141. next = node.nextSibling,
  19142. parent = node.parentNode,
  19143. display = node.style.display;
  19144. // glob.win.opera && parent.removeChild(node);
  19145. // node.style.display = "none";
  19146. // o = dragi.el.paper.getElementByPoint(x, y);
  19147. // node.style.display = display;
  19148. // glob.win.opera && (next ? parent.insertBefore(node, next) : parent.appendChild(node));
  19149. // o && eve("snap.drag.over." + dragi.el.id, dragi.el, o);
  19150. x += scrollX;
  19151. y += scrollY;
  19152. eve("snap.drag.move." + dragi.el.id, dragi.move_scope || dragi.el, x - dragi.el._drag.x, y - dragi.el._drag.y, x, y, e);
  19153. }
  19154. },
  19155. dragUp = function (e) {
  19156. Snap.unmousemove(dragMove).unmouseup(dragUp);
  19157. var i = drag.length,
  19158. dragi;
  19159. while (i--) {
  19160. dragi = drag[i];
  19161. dragi.el._drag = {};
  19162. eve("snap.drag.end." + dragi.el.id, dragi.end_scope || dragi.start_scope || dragi.move_scope || dragi.el, e);
  19163. }
  19164. drag = [];
  19165. };
  19166. /*\
  19167. * Element.click
  19168. [ method ]
  19169. **
  19170. * Adds a click event handler to the element
  19171. - handler (function) handler for the event
  19172. = (object) @Element
  19173. \*/
  19174. /*\
  19175. * Element.unclick
  19176. [ method ]
  19177. **
  19178. * Removes a click event handler from the element
  19179. - handler (function) handler for the event
  19180. = (object) @Element
  19181. \*/
  19182. /*\
  19183. * Element.dblclick
  19184. [ method ]
  19185. **
  19186. * Adds a double click event handler to the element
  19187. - handler (function) handler for the event
  19188. = (object) @Element
  19189. \*/
  19190. /*\
  19191. * Element.undblclick
  19192. [ method ]
  19193. **
  19194. * Removes a double click event handler from the element
  19195. - handler (function) handler for the event
  19196. = (object) @Element
  19197. \*/
  19198. /*\
  19199. * Element.mousedown
  19200. [ method ]
  19201. **
  19202. * Adds a mousedown event handler to the element
  19203. - handler (function) handler for the event
  19204. = (object) @Element
  19205. \*/
  19206. /*\
  19207. * Element.unmousedown
  19208. [ method ]
  19209. **
  19210. * Removes a mousedown event handler from the element
  19211. - handler (function) handler for the event
  19212. = (object) @Element
  19213. \*/
  19214. /*\
  19215. * Element.mousemove
  19216. [ method ]
  19217. **
  19218. * Adds a mousemove event handler to the element
  19219. - handler (function) handler for the event
  19220. = (object) @Element
  19221. \*/
  19222. /*\
  19223. * Element.unmousemove
  19224. [ method ]
  19225. **
  19226. * Removes a mousemove event handler from the element
  19227. - handler (function) handler for the event
  19228. = (object) @Element
  19229. \*/
  19230. /*\
  19231. * Element.mouseout
  19232. [ method ]
  19233. **
  19234. * Adds a mouseout event handler to the element
  19235. - handler (function) handler for the event
  19236. = (object) @Element
  19237. \*/
  19238. /*\
  19239. * Element.unmouseout
  19240. [ method ]
  19241. **
  19242. * Removes a mouseout event handler from the element
  19243. - handler (function) handler for the event
  19244. = (object) @Element
  19245. \*/
  19246. /*\
  19247. * Element.mouseover
  19248. [ method ]
  19249. **
  19250. * Adds a mouseover event handler to the element
  19251. - handler (function) handler for the event
  19252. = (object) @Element
  19253. \*/
  19254. /*\
  19255. * Element.unmouseover
  19256. [ method ]
  19257. **
  19258. * Removes a mouseover event handler from the element
  19259. - handler (function) handler for the event
  19260. = (object) @Element
  19261. \*/
  19262. /*\
  19263. * Element.mouseup
  19264. [ method ]
  19265. **
  19266. * Adds a mouseup event handler to the element
  19267. - handler (function) handler for the event
  19268. = (object) @Element
  19269. \*/
  19270. /*\
  19271. * Element.unmouseup
  19272. [ method ]
  19273. **
  19274. * Removes a mouseup event handler from the element
  19275. - handler (function) handler for the event
  19276. = (object) @Element
  19277. \*/
  19278. /*\
  19279. * Element.touchstart
  19280. [ method ]
  19281. **
  19282. * Adds a touchstart event handler to the element
  19283. - handler (function) handler for the event
  19284. = (object) @Element
  19285. \*/
  19286. /*\
  19287. * Element.untouchstart
  19288. [ method ]
  19289. **
  19290. * Removes a touchstart event handler from the element
  19291. - handler (function) handler for the event
  19292. = (object) @Element
  19293. \*/
  19294. /*\
  19295. * Element.touchmove
  19296. [ method ]
  19297. **
  19298. * Adds a touchmove event handler to the element
  19299. - handler (function) handler for the event
  19300. = (object) @Element
  19301. \*/
  19302. /*\
  19303. * Element.untouchmove
  19304. [ method ]
  19305. **
  19306. * Removes a touchmove event handler from the element
  19307. - handler (function) handler for the event
  19308. = (object) @Element
  19309. \*/
  19310. /*\
  19311. * Element.touchend
  19312. [ method ]
  19313. **
  19314. * Adds a touchend event handler to the element
  19315. - handler (function) handler for the event
  19316. = (object) @Element
  19317. \*/
  19318. /*\
  19319. * Element.untouchend
  19320. [ method ]
  19321. **
  19322. * Removes a touchend event handler from the element
  19323. - handler (function) handler for the event
  19324. = (object) @Element
  19325. \*/
  19326. /*\
  19327. * Element.touchcancel
  19328. [ method ]
  19329. **
  19330. * Adds a touchcancel event handler to the element
  19331. - handler (function) handler for the event
  19332. = (object) @Element
  19333. \*/
  19334. /*\
  19335. * Element.untouchcancel
  19336. [ method ]
  19337. **
  19338. * Removes a touchcancel event handler from the element
  19339. - handler (function) handler for the event
  19340. = (object) @Element
  19341. \*/
  19342. for (var i = events.length; i--;) {
  19343. (function (eventName) {
  19344. Snap[eventName] = elproto[eventName] = function (fn, scope) {
  19345. if (Snap.is(fn, "function")) {
  19346. this.events = this.events || [];
  19347. this.events.push({
  19348. name: eventName,
  19349. f: fn,
  19350. unbind: addEvent(this.node || document, eventName, fn, scope || this)
  19351. });
  19352. }
  19353. return this;
  19354. };
  19355. Snap["un" + eventName] =
  19356. elproto["un" + eventName] = function (fn) {
  19357. var events = this.events || [],
  19358. l = events.length;
  19359. while (l--) if (events[l].name == eventName &&
  19360. (events[l].f == fn || !fn)) {
  19361. events[l].unbind();
  19362. events.splice(l, 1);
  19363. !events.length && delete this.events;
  19364. return this;
  19365. }
  19366. return this;
  19367. };
  19368. })(events[i]);
  19369. }
  19370. /*\
  19371. * Element.hover
  19372. [ method ]
  19373. **
  19374. * Adds hover event handlers to the element
  19375. - f_in (function) handler for hover in
  19376. - f_out (function) handler for hover out
  19377. - icontext (object) #optional context for hover in handler
  19378. - ocontext (object) #optional context for hover out handler
  19379. = (object) @Element
  19380. \*/
  19381. elproto.hover = function (f_in, f_out, scope_in, scope_out) {
  19382. return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out || scope_in);
  19383. };
  19384. /*\
  19385. * Element.unhover
  19386. [ method ]
  19387. **
  19388. * Removes hover event handlers from the element
  19389. - f_in (function) handler for hover in
  19390. - f_out (function) handler for hover out
  19391. = (object) @Element
  19392. \*/
  19393. elproto.unhover = function (f_in, f_out) {
  19394. return this.unmouseover(f_in).unmouseout(f_out);
  19395. };
  19396. var draggable = [];
  19397. // SIERRA unclear what _context_ refers to for starting, ending, moving the drag gesture.
  19398. // SIERRA Element.drag(): _x position of the mouse_: Where are the x/y values offset from?
  19399. // SIERRA Element.drag(): much of this member's doc appears to be duplicated for some reason.
  19400. // SIERRA Unclear about this sentence: _Additionally following drag events will be triggered: drag.start.<id> on start, drag.end.<id> on end and drag.move.<id> on every move._ Is there a global _drag_ object to which you can assign handlers keyed by an element's ID?
  19401. /*\
  19402. * Element.drag
  19403. [ method ]
  19404. **
  19405. * Adds event handlers for an element's drag gesture
  19406. **
  19407. - onmove (function) handler for moving
  19408. - onstart (function) handler for drag start
  19409. - onend (function) handler for drag end
  19410. - mcontext (object) #optional context for moving handler
  19411. - scontext (object) #optional context for drag start handler
  19412. - econtext (object) #optional context for drag end handler
  19413. * Additionaly following `drag` events are triggered: `drag.start.<id>` on start,
  19414. * `drag.end.<id>` on end and `drag.move.<id>` on every move. When element is dragged over another element
  19415. * `drag.over.<id>` fires as well.
  19416. *
  19417. * Start event and start handler are called in specified context or in context of the element with following parameters:
  19418. o x (number) x position of the mouse
  19419. o y (number) y position of the mouse
  19420. o event (object) DOM event object
  19421. * Move event and move handler are called in specified context or in context of the element with following parameters:
  19422. o dx (number) shift by x from the start point
  19423. o dy (number) shift by y from the start point
  19424. o x (number) x position of the mouse
  19425. o y (number) y position of the mouse
  19426. o event (object) DOM event object
  19427. * End event and end handler are called in specified context or in context of the element with following parameters:
  19428. o event (object) DOM event object
  19429. = (object) @Element
  19430. \*/
  19431. elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) {
  19432. if (!arguments.length) {
  19433. var origTransform;
  19434. return this.drag(function (dx, dy) {
  19435. this.attr({
  19436. transform: origTransform + (origTransform ? "T" : "t") + [dx, dy]
  19437. });
  19438. }, function () {
  19439. origTransform = this.transform().local;
  19440. });
  19441. }
  19442. function start(e, x, y) {
  19443. (e.originalEvent || e).preventDefault();
  19444. this._drag.x = x;
  19445. this._drag.y = y;
  19446. this._drag.id = e.identifier;
  19447. !drag.length && Snap.mousemove(dragMove).mouseup(dragUp);
  19448. drag.push({el: this, move_scope: move_scope, start_scope: start_scope, end_scope: end_scope});
  19449. onstart && eve.on("snap.drag.start." + this.id, onstart);
  19450. onmove && eve.on("snap.drag.move." + this.id, onmove);
  19451. onend && eve.on("snap.drag.end." + this.id, onend);
  19452. eve("snap.drag.start." + this.id, start_scope || move_scope || this, x, y, e);
  19453. }
  19454. this._drag = {};
  19455. draggable.push({el: this, start: start});
  19456. this.mousedown(start);
  19457. return this;
  19458. };
  19459. /*
  19460. * Element.onDragOver
  19461. [ method ]
  19462. **
  19463. * Shortcut to assign event handler for `drag.over.<id>` event, where `id` is the element's `id` (see @Element.id)
  19464. - f (function) handler for event, first argument would be the element you are dragging over
  19465. \*/
  19466. // elproto.onDragOver = function (f) {
  19467. // f ? eve.on("snap.drag.over." + this.id, f) : eve.unbind("snap.drag.over." + this.id);
  19468. // };
  19469. /*\
  19470. * Element.undrag
  19471. [ method ]
  19472. **
  19473. * Removes all drag event handlers from the given element
  19474. \*/
  19475. elproto.undrag = function () {
  19476. var i = draggable.length;
  19477. while (i--) if (draggable[i].el == this) {
  19478. this.unmousedown(draggable[i].start);
  19479. draggable.splice(i, 1);
  19480. eve.unbind("snap.drag.*." + this.id);
  19481. }
  19482. !draggable.length && Snap.unmousemove(dragMove).unmouseup(dragUp);
  19483. return this;
  19484. };
  19485. });
  19486. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  19487. //
  19488. // Licensed under the Apache License, Version 2.0 (the "License");
  19489. // you may not use this file except in compliance with the License.
  19490. // You may obtain a copy of the License at
  19491. //
  19492. // http://www.apache.org/licenses/LICENSE-2.0
  19493. //
  19494. // Unless required by applicable law or agreed to in writing, software
  19495. // distributed under the License is distributed on an "AS IS" BASIS,
  19496. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19497. // See the License for the specific language governing permissions and
  19498. // limitations under the License.
  19499. Snap.plugin(function (Snap, Element, Paper, glob) {
  19500. var elproto = Element.prototype,
  19501. pproto = Paper.prototype,
  19502. rgurl = /^\s*url\((.+)\)/,
  19503. Str = String,
  19504. $ = Snap._.$;
  19505. Snap.filter = {};
  19506. /*\
  19507. * Paper.filter
  19508. [ method ]
  19509. **
  19510. * Creates a `<filter>` element
  19511. **
  19512. - filstr (string) SVG fragment of filter provided as a string
  19513. = (object) @Element
  19514. * Note: It is recommended to use filters embedded into the page inside an empty SVG element.
  19515. > Usage
  19516. | var f = paper.filter('<feGaussianBlur stdDeviation="2"/>'),
  19517. | c = paper.circle(10, 10, 10).attr({
  19518. | filter: f
  19519. | });
  19520. \*/
  19521. pproto.filter = function (filstr) {
  19522. var paper = this;
  19523. if (paper.type != "svg") {
  19524. paper = paper.paper;
  19525. }
  19526. var f = Snap.parse(Str(filstr)),
  19527. id = Snap._.id(),
  19528. width = paper.node.offsetWidth,
  19529. height = paper.node.offsetHeight,
  19530. filter = $("filter");
  19531. $(filter, {
  19532. id: id,
  19533. filterUnits: "userSpaceOnUse"
  19534. });
  19535. filter.appendChild(f.node);
  19536. paper.defs.appendChild(filter);
  19537. return new Element(filter);
  19538. };
  19539. eve.on("snap.util.getattr.filter", function () {
  19540. eve.stop();
  19541. var p = $(this.node, "filter");
  19542. if (p) {
  19543. var match = Str(p).match(rgurl);
  19544. return match && Snap.select(match[1]);
  19545. }
  19546. });
  19547. eve.on("snap.util.attr.filter", function (value) {
  19548. if (value instanceof Element && value.type == "filter") {
  19549. eve.stop();
  19550. var id = value.node.id;
  19551. if (!id) {
  19552. $(value.node, {id: value.id});
  19553. id = value.id;
  19554. }
  19555. $(this.node, {
  19556. filter: Snap.url(id)
  19557. });
  19558. }
  19559. if (!value || value == "none") {
  19560. eve.stop();
  19561. this.node.removeAttribute("filter");
  19562. }
  19563. });
  19564. /*\
  19565. * Snap.filter.blur
  19566. [ method ]
  19567. **
  19568. * Returns an SVG markup string for the blur filter
  19569. **
  19570. - x (number) amount of horizontal blur, in pixels
  19571. - y (number) #optional amount of vertical blur, in pixels
  19572. = (string) filter representation
  19573. > Usage
  19574. | var f = paper.filter(Snap.filter.blur(5, 10)),
  19575. | c = paper.circle(10, 10, 10).attr({
  19576. | filter: f
  19577. | });
  19578. \*/
  19579. Snap.filter.blur = function (x, y) {
  19580. if (x == null) {
  19581. x = 2;
  19582. }
  19583. var def = y == null ? x : [x, y];
  19584. return Snap.format('\<feGaussianBlur stdDeviation="{def}"/>', {
  19585. def: def
  19586. });
  19587. };
  19588. Snap.filter.blur.toString = function () {
  19589. return this();
  19590. };
  19591. /*\
  19592. * Snap.filter.shadow
  19593. [ method ]
  19594. **
  19595. * Returns an SVG markup string for the shadow filter
  19596. **
  19597. - dx (number) #optional horizontal shift of the shadow, in pixels
  19598. - dy (number) #optional vertical shift of the shadow, in pixels
  19599. - blur (number) #optional amount of blur
  19600. - color (string) #optional color of the shadow
  19601. - opacity (number) #optional `0..1` opacity of the shadow
  19602. * or
  19603. - dx (number) #optional horizontal shift of the shadow, in pixels
  19604. - dy (number) #optional vertical shift of the shadow, in pixels
  19605. - color (string) #optional color of the shadow
  19606. - opacity (number) #optional `0..1` opacity of the shadow
  19607. * which makes blur default to `4`. Or
  19608. - dx (number) #optional horizontal shift of the shadow, in pixels
  19609. - dy (number) #optional vertical shift of the shadow, in pixels
  19610. - opacity (number) #optional `0..1` opacity of the shadow
  19611. = (string) filter representation
  19612. > Usage
  19613. | var f = paper.filter(Snap.filter.shadow(0, 2, 3)),
  19614. | c = paper.circle(10, 10, 10).attr({
  19615. | filter: f
  19616. | });
  19617. \*/
  19618. Snap.filter.shadow = function (dx, dy, blur, color, opacity) {
  19619. if (typeof blur == "string") {
  19620. color = blur;
  19621. opacity = color;
  19622. blur = 4;
  19623. }
  19624. if (typeof color != "string") {
  19625. opacity = color;
  19626. color = "#000";
  19627. }
  19628. color = color || "#000";
  19629. if (blur == null) {
  19630. blur = 4;
  19631. }
  19632. if (opacity == null) {
  19633. opacity = 1;
  19634. }
  19635. if (dx == null) {
  19636. dx = 0;
  19637. dy = 2;
  19638. }
  19639. if (dy == null) {
  19640. dy = dx;
  19641. }
  19642. color = Snap.color(color);
  19643. return Snap.format('<feGaussianBlur in="SourceAlpha" stdDeviation="{blur}"/><feOffset dx="{dx}" dy="{dy}" result="offsetblur"/><feFlood flood-color="{color}"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="{opacity}"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>', {
  19644. color: color,
  19645. dx: dx,
  19646. dy: dy,
  19647. blur: blur,
  19648. opacity: opacity
  19649. });
  19650. };
  19651. Snap.filter.shadow.toString = function () {
  19652. return this();
  19653. };
  19654. /*\
  19655. * Snap.filter.grayscale
  19656. [ method ]
  19657. **
  19658. * Returns an SVG markup string for the grayscale filter
  19659. **
  19660. - amount (number) amount of filter (`0..1`)
  19661. = (string) filter representation
  19662. \*/
  19663. Snap.filter.grayscale = function (amount) {
  19664. if (amount == null) {
  19665. amount = 1;
  19666. }
  19667. return Snap.format('<feColorMatrix type="matrix" values="{a} {b} {c} 0 0 {d} {e} {f} 0 0 {g} {b} {h} 0 0 0 0 0 1 0"/>', {
  19668. a: 0.2126 + 0.7874 * (1 - amount),
  19669. b: 0.7152 - 0.7152 * (1 - amount),
  19670. c: 0.0722 - 0.0722 * (1 - amount),
  19671. d: 0.2126 - 0.2126 * (1 - amount),
  19672. e: 0.7152 + 0.2848 * (1 - amount),
  19673. f: 0.0722 - 0.0722 * (1 - amount),
  19674. g: 0.2126 - 0.2126 * (1 - amount),
  19675. h: 0.0722 + 0.9278 * (1 - amount)
  19676. });
  19677. };
  19678. Snap.filter.grayscale.toString = function () {
  19679. return this();
  19680. };
  19681. /*\
  19682. * Snap.filter.sepia
  19683. [ method ]
  19684. **
  19685. * Returns an SVG markup string for the sepia filter
  19686. **
  19687. - amount (number) amount of filter (`0..1`)
  19688. = (string) filter representation
  19689. \*/
  19690. Snap.filter.sepia = function (amount) {
  19691. if (amount == null) {
  19692. amount = 1;
  19693. }
  19694. return Snap.format('<feColorMatrix type="matrix" values="{a} {b} {c} 0 0 {d} {e} {f} 0 0 {g} {h} {i} 0 0 0 0 0 1 0"/>', {
  19695. a: 0.393 + 0.607 * (1 - amount),
  19696. b: 0.769 - 0.769 * (1 - amount),
  19697. c: 0.189 - 0.189 * (1 - amount),
  19698. d: 0.349 - 0.349 * (1 - amount),
  19699. e: 0.686 + 0.314 * (1 - amount),
  19700. f: 0.168 - 0.168 * (1 - amount),
  19701. g: 0.272 - 0.272 * (1 - amount),
  19702. h: 0.534 - 0.534 * (1 - amount),
  19703. i: 0.131 + 0.869 * (1 - amount)
  19704. });
  19705. };
  19706. Snap.filter.sepia.toString = function () {
  19707. return this();
  19708. };
  19709. /*\
  19710. * Snap.filter.saturate
  19711. [ method ]
  19712. **
  19713. * Returns an SVG markup string for the saturate filter
  19714. **
  19715. - amount (number) amount of filter (`0..1`)
  19716. = (string) filter representation
  19717. \*/
  19718. Snap.filter.saturate = function (amount) {
  19719. if (amount == null) {
  19720. amount = 1;
  19721. }
  19722. return Snap.format('<feColorMatrix type="saturate" values="{amount}"/>', {
  19723. amount: 1 - amount
  19724. });
  19725. };
  19726. Snap.filter.saturate.toString = function () {
  19727. return this();
  19728. };
  19729. /*\
  19730. * Snap.filter.hueRotate
  19731. [ method ]
  19732. **
  19733. * Returns an SVG markup string for the hue-rotate filter
  19734. **
  19735. - angle (number) angle of rotation
  19736. = (string) filter representation
  19737. \*/
  19738. Snap.filter.hueRotate = function (angle) {
  19739. angle = angle || 0;
  19740. return Snap.format('<feColorMatrix type="hueRotate" values="{angle}"/>', {
  19741. angle: angle
  19742. });
  19743. };
  19744. Snap.filter.hueRotate.toString = function () {
  19745. return this();
  19746. };
  19747. /*\
  19748. * Snap.filter.invert
  19749. [ method ]
  19750. **
  19751. * Returns an SVG markup string for the invert filter
  19752. **
  19753. - amount (number) amount of filter (`0..1`)
  19754. = (string) filter representation
  19755. \*/
  19756. Snap.filter.invert = function (amount) {
  19757. if (amount == null) {
  19758. amount = 1;
  19759. }
  19760. return Snap.format('<feComponentTransfer><feFuncR type="table" tableValues="{amount} {amount2}"/><feFuncG type="table" tableValues="{amount} {amount2}"/><feFuncB type="table" tableValues="{amount} {amount2}"/></feComponentTransfer>', {
  19761. amount: amount,
  19762. amount2: 1 - amount
  19763. });
  19764. };
  19765. Snap.filter.invert.toString = function () {
  19766. return this();
  19767. };
  19768. /*\
  19769. * Snap.filter.brightness
  19770. [ method ]
  19771. **
  19772. * Returns an SVG markup string for the brightness filter
  19773. **
  19774. - amount (number) amount of filter (`0..1`)
  19775. = (string) filter representation
  19776. \*/
  19777. Snap.filter.brightness = function (amount) {
  19778. if (amount == null) {
  19779. amount = 1;
  19780. }
  19781. return Snap.format('<feComponentTransfer><feFuncR type="linear" slope="{amount}"/><feFuncG type="linear" slope="{amount}"/><feFuncB type="linear" slope="{amount}"/></feComponentTransfer>', {
  19782. amount: amount
  19783. });
  19784. };
  19785. Snap.filter.brightness.toString = function () {
  19786. return this();
  19787. };
  19788. /*\
  19789. * Snap.filter.contrast
  19790. [ method ]
  19791. **
  19792. * Returns an SVG markup string for the contrast filter
  19793. **
  19794. - amount (number) amount of filter (`0..1`)
  19795. = (string) filter representation
  19796. \*/
  19797. Snap.filter.contrast = function (amount) {
  19798. if (amount == null) {
  19799. amount = 1;
  19800. }
  19801. return Snap.format('<feComponentTransfer><feFuncR type="linear" slope="{amount}" intercept="{amount2}"/><feFuncG type="linear" slope="{amount}" intercept="{amount2}"/><feFuncB type="linear" slope="{amount}" intercept="{amount2}"/></feComponentTransfer>', {
  19802. amount: amount,
  19803. amount2: .5 - amount / 2
  19804. });
  19805. };
  19806. Snap.filter.contrast.toString = function () {
  19807. return this();
  19808. };
  19809. });
  19810. return Snap;
  19811. }));
  19812. },{"74":74}],76:[function(_dereq_,module,exports){
  19813. 'use strict';
  19814. var snapsvg = module.exports = _dereq_(75);
  19815. snapsvg.plugin(function(Snap, Element) {
  19816. /*\
  19817. * Element.children
  19818. [ method ]
  19819. **
  19820. * Returns array of all the children of the element.
  19821. = (array) array of Elements
  19822. \*/
  19823. Element.prototype.children = function () {
  19824. var out = [],
  19825. ch = this.node.childNodes;
  19826. for (var i = 0, ii = ch.length; i < ii; i++) {
  19827. out[i] = new Snap(ch[i]);
  19828. }
  19829. return out;
  19830. };
  19831. });
  19832. /**
  19833. * @class ClassPlugin
  19834. *
  19835. * Extends snapsvg with methods to add and remove classes
  19836. */
  19837. snapsvg.plugin(function (Snap, Element, Paper, global) {
  19838. function split(str) {
  19839. return str.split(/\s+/);
  19840. }
  19841. function join(array) {
  19842. return array.join(' ');
  19843. }
  19844. function getClasses(e) {
  19845. return split(e.attr('class') || '');
  19846. }
  19847. function setClasses(e, classes) {
  19848. e.attr('class', join(classes));
  19849. }
  19850. /**
  19851. * @method snapsvg.Element#addClass
  19852. *
  19853. * @example
  19854. *
  19855. * e.attr('class', 'selector');
  19856. *
  19857. * e.addClass('foo bar'); // adds classes foo and bar
  19858. * e.attr('class'); // -> 'selector foo bar'
  19859. *
  19860. * e.addClass('fooBar');
  19861. * e.attr('class'); // -> 'selector foo bar fooBar'
  19862. *
  19863. * @param {String} cls classes to be added to the element
  19864. *
  19865. * @return {snapsvg.Element} the element (this)
  19866. */
  19867. Element.prototype.addClass = function(cls) {
  19868. var current = getClasses(this),
  19869. add = split(cls),
  19870. i, e;
  19871. for (i = 0, e; !!(e = add[i]); i++) {
  19872. if (current.indexOf(e) === -1) {
  19873. current.push(e);
  19874. }
  19875. }
  19876. setClasses(this, current);
  19877. return this;
  19878. };
  19879. /**
  19880. * @method snapsvg.Element#hasClass
  19881. *
  19882. * @param {String} cls the class to query for
  19883. * @return {Boolean} returns true if the element has the given class
  19884. */
  19885. Element.prototype.hasClass = function(cls) {
  19886. if (!cls) {
  19887. throw new Error('[snapsvg] syntax: hasClass(clsStr)');
  19888. }
  19889. return getClasses(this).indexOf(cls) !== -1;
  19890. };
  19891. /**
  19892. * @method snapsvg.Element#removeClass
  19893. *
  19894. * @example
  19895. *
  19896. * e.attr('class', 'foo bar');
  19897. *
  19898. * e.removeClass('foo');
  19899. * e.attr('class'); // -> 'bar'
  19900. *
  19901. * e.removeClass('foo bar'); // removes classes foo and bar
  19902. * e.attr('class'); // -> ''
  19903. *
  19904. * @param {String} cls classes to be removed from element
  19905. *
  19906. * @return {snapsvg.Element} the element (this)
  19907. */
  19908. Element.prototype.removeClass = function(cls) {
  19909. var current = getClasses(this),
  19910. remove = split(cls),
  19911. i, e, idx;
  19912. for (i = 0, e; !!(e = remove[i]); i++) {
  19913. idx = current.indexOf(e);
  19914. if (idx !== -1) {
  19915. // remove element from array
  19916. current.splice(idx, 1);
  19917. }
  19918. }
  19919. setClasses(this, current);
  19920. return this;
  19921. };
  19922. });
  19923. /**
  19924. * @class TranslatePlugin
  19925. *
  19926. * Extends snapsvg with methods to translate elements
  19927. */
  19928. snapsvg.plugin(function (Snap, Element, Paper, global) {
  19929. /*
  19930. * @method snapsvg.Element#translate
  19931. *
  19932. * @example
  19933. *
  19934. * e.translate(10, 20);
  19935. *
  19936. * // sets transform matrix to translate(10, 20)
  19937. *
  19938. * @param {Number} x translation
  19939. * @param {Number} y translation
  19940. *
  19941. * @return {snapsvg.Element} the element (this)
  19942. */
  19943. Element.prototype.translate = function(x, y) {
  19944. var matrix = new Snap.Matrix();
  19945. matrix.translate(x, y);
  19946. return this.transform(matrix);
  19947. };
  19948. });
  19949. /**
  19950. * @class CreatePlugin
  19951. *
  19952. * Create an svg element without attaching it to the dom
  19953. */
  19954. snapsvg.plugin(function(Snap) {
  19955. Snap.create = function(name, attrs) {
  19956. return Snap._.wrap(Snap._.$(name, attrs));
  19957. };
  19958. });
  19959. /**
  19960. * @class CreatSnapAtPlugin
  19961. *
  19962. * Extends snap.svg with a method to create a SVG element
  19963. * at a specific position in the DOM.
  19964. */
  19965. snapsvg.plugin(function(Snap, Element, Paper, global) {
  19966. /*
  19967. * @method snapsvg.createSnapAt
  19968. *
  19969. * @example
  19970. *
  19971. * snapsvg.createSnapAt(parentNode, 200, 200);
  19972. *
  19973. * @param {Number} width of svg
  19974. * @param {Number} height of svg
  19975. * @param {Object} parentNode svg Element will be child of this
  19976. *
  19977. * @return {snapsvg.Element} the newly created wrapped SVG element instance
  19978. */
  19979. Snap.createSnapAt = function(width, height, parentNode) {
  19980. var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
  19981. svg.setAttribute('width', width);
  19982. svg.setAttribute('height', height);
  19983. if (!parentNode) {
  19984. parentNode = document.body;
  19985. }
  19986. parentNode.appendChild(svg);
  19987. return new Snap(svg);
  19988. };
  19989. });
  19990. },{"75":75}],77:[function(_dereq_,module,exports){
  19991. var isArray = function(obj) {
  19992. return Object.prototype.toString.call(obj) === '[object Array]';
  19993. };
  19994. var annotate = function() {
  19995. var args = Array.prototype.slice.call(arguments);
  19996. if (args.length === 1 && isArray(args[0])) {
  19997. args = args[0];
  19998. }
  19999. var fn = args.pop();
  20000. fn.$inject = args;
  20001. return fn;
  20002. };
  20003. // Current limitations:
  20004. // - can't put into "function arg" comments
  20005. // function /* (no parenthesis like this) */ (){}
  20006. // function abc( /* xx (no parenthesis like this) */ a, b) {}
  20007. //
  20008. // Just put the comment before function or inside:
  20009. // /* (((this is fine))) */ function(a, b) {}
  20010. // function abc(a) { /* (((this is fine))) */}
  20011. var FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
  20012. var FN_ARG = /\/\*([^\*]*)\*\//m;
  20013. var parse = function(fn) {
  20014. if (typeof fn !== 'function') {
  20015. throw new Error('Cannot annotate "' + fn + '". Expected a function!');
  20016. }
  20017. var match = fn.toString().match(FN_ARGS);
  20018. return match[1] && match[1].split(',').map(function(arg) {
  20019. match = arg.match(FN_ARG);
  20020. return match ? match[1].trim() : arg.trim();
  20021. }) || [];
  20022. };
  20023. exports.annotate = annotate;
  20024. exports.parse = parse;
  20025. exports.isArray = isArray;
  20026. },{}],78:[function(_dereq_,module,exports){
  20027. module.exports = {
  20028. annotate: _dereq_(77).annotate,
  20029. Module: _dereq_(80),
  20030. Injector: _dereq_(79)
  20031. };
  20032. },{"77":77,"79":79,"80":80}],79:[function(_dereq_,module,exports){
  20033. var Module = _dereq_(80);
  20034. var autoAnnotate = _dereq_(77).parse;
  20035. var annotate = _dereq_(77).annotate;
  20036. var isArray = _dereq_(77).isArray;
  20037. var Injector = function(modules, parent) {
  20038. parent = parent || {
  20039. get: function(name) {
  20040. currentlyResolving.push(name);
  20041. throw error('No provider for "' + name + '"!');
  20042. }
  20043. };
  20044. var currentlyResolving = [];
  20045. var providers = this._providers = Object.create(parent._providers || null);
  20046. var instances = this._instances = Object.create(null);
  20047. var self = instances.injector = this;
  20048. var error = function(msg) {
  20049. var stack = currentlyResolving.join(' -> ');
  20050. currentlyResolving.length = 0;
  20051. return new Error(stack ? msg + ' (Resolving: ' + stack + ')' : msg);
  20052. };
  20053. var get = function(name) {
  20054. if (!providers[name] && name.indexOf('.') !== -1) {
  20055. var parts = name.split('.');
  20056. var pivot = get(parts.shift());
  20057. while(parts.length) {
  20058. pivot = pivot[parts.shift()];
  20059. }
  20060. return pivot;
  20061. }
  20062. if (Object.hasOwnProperty.call(instances, name)) {
  20063. return instances[name];
  20064. }
  20065. if (Object.hasOwnProperty.call(providers, name)) {
  20066. if (currentlyResolving.indexOf(name) !== -1) {
  20067. currentlyResolving.push(name);
  20068. throw error('Cannot resolve circular dependency!');
  20069. }
  20070. currentlyResolving.push(name);
  20071. instances[name] = providers[name][0](providers[name][1]);
  20072. currentlyResolving.pop();
  20073. return instances[name];
  20074. }
  20075. return parent.get(name);
  20076. };
  20077. var instantiate = function(Type) {
  20078. var instance = Object.create(Type.prototype);
  20079. var returned = invoke(Type, instance);
  20080. return typeof returned === 'object' ? returned : instance;
  20081. };
  20082. var invoke = function(fn, context) {
  20083. if (typeof fn !== 'function') {
  20084. if (isArray(fn)) {
  20085. fn = annotate(fn.slice());
  20086. } else {
  20087. throw new Error('Cannot invoke "' + fn + '". Expected a function!');
  20088. }
  20089. }
  20090. var inject = fn.$inject && fn.$inject || autoAnnotate(fn);
  20091. var dependencies = inject.map(function(dep) {
  20092. return get(dep);
  20093. });
  20094. // TODO(vojta): optimize without apply
  20095. return fn.apply(context, dependencies);
  20096. };
  20097. var createPrivateInjectorFactory = function(privateChildInjector) {
  20098. return annotate(function(key) {
  20099. return privateChildInjector.get(key);
  20100. });
  20101. };
  20102. var createChild = function(modules, forceNewInstances) {
  20103. if (forceNewInstances && forceNewInstances.length) {
  20104. var fromParentModule = Object.create(null);
  20105. var matchedScopes = Object.create(null);
  20106. var privateInjectorsCache = [];
  20107. var privateChildInjectors = [];
  20108. var privateChildFactories = [];
  20109. var provider;
  20110. var cacheIdx;
  20111. var privateChildInjector;
  20112. var privateChildInjectorFactory;
  20113. for (var name in providers) {
  20114. provider = providers[name];
  20115. if (forceNewInstances.indexOf(name) !== -1) {
  20116. if (provider[2] === 'private') {
  20117. cacheIdx = privateInjectorsCache.indexOf(provider[3]);
  20118. if (cacheIdx === -1) {
  20119. privateChildInjector = provider[3].createChild([], forceNewInstances);
  20120. privateChildInjectorFactory = createPrivateInjectorFactory(privateChildInjector);
  20121. privateInjectorsCache.push(provider[3]);
  20122. privateChildInjectors.push(privateChildInjector);
  20123. privateChildFactories.push(privateChildInjectorFactory);
  20124. fromParentModule[name] = [privateChildInjectorFactory, name, 'private', privateChildInjector];
  20125. } else {
  20126. fromParentModule[name] = [privateChildFactories[cacheIdx], name, 'private', privateChildInjectors[cacheIdx]];
  20127. }
  20128. } else {
  20129. fromParentModule[name] = [provider[2], provider[1]];
  20130. }
  20131. matchedScopes[name] = true;
  20132. }
  20133. if ((provider[2] === 'factory' || provider[2] === 'type') && provider[1].$scope) {
  20134. forceNewInstances.forEach(function(scope) {
  20135. if (provider[1].$scope.indexOf(scope) !== -1) {
  20136. fromParentModule[name] = [provider[2], provider[1]];
  20137. matchedScopes[scope] = true;
  20138. }
  20139. });
  20140. }
  20141. }
  20142. forceNewInstances.forEach(function(scope) {
  20143. if (!matchedScopes[scope]) {
  20144. throw new Error('No provider for "' + scope + '". Cannot use provider from the parent!');
  20145. }
  20146. });
  20147. modules.unshift(fromParentModule);
  20148. }
  20149. return new Injector(modules, self);
  20150. };
  20151. var factoryMap = {
  20152. factory: invoke,
  20153. type: instantiate,
  20154. value: function(value) {
  20155. return value;
  20156. }
  20157. };
  20158. modules.forEach(function(module) {
  20159. function arrayUnwrap(type, value) {
  20160. if (type !== 'value' && isArray(value)) {
  20161. value = annotate(value.slice());
  20162. }
  20163. return value;
  20164. }
  20165. // TODO(vojta): handle wrong inputs (modules)
  20166. if (module instanceof Module) {
  20167. module.forEach(function(provider) {
  20168. var name = provider[0];
  20169. var type = provider[1];
  20170. var value = provider[2];
  20171. providers[name] = [factoryMap[type], arrayUnwrap(type, value), type];
  20172. });
  20173. } else if (typeof module === 'object') {
  20174. if (module.__exports__) {
  20175. var clonedModule = Object.keys(module).reduce(function(m, key) {
  20176. if (key.substring(0, 2) !== '__') {
  20177. m[key] = module[key];
  20178. }
  20179. return m;
  20180. }, Object.create(null));
  20181. var privateInjector = new Injector((module.__modules__ || []).concat([clonedModule]), self);
  20182. var getFromPrivateInjector = annotate(function(key) {
  20183. return privateInjector.get(key);
  20184. });
  20185. module.__exports__.forEach(function(key) {
  20186. providers[key] = [getFromPrivateInjector, key, 'private', privateInjector];
  20187. });
  20188. } else {
  20189. Object.keys(module).forEach(function(name) {
  20190. if (module[name][2] === 'private') {
  20191. providers[name] = module[name];
  20192. return;
  20193. }
  20194. var type = module[name][0];
  20195. var value = module[name][1];
  20196. providers[name] = [factoryMap[type], arrayUnwrap(type, value), type];
  20197. });
  20198. }
  20199. }
  20200. });
  20201. // public API
  20202. this.get = get;
  20203. this.invoke = invoke;
  20204. this.instantiate = instantiate;
  20205. this.createChild = createChild;
  20206. };
  20207. module.exports = Injector;
  20208. },{"77":77,"80":80}],80:[function(_dereq_,module,exports){
  20209. var Module = function() {
  20210. var providers = [];
  20211. this.factory = function(name, factory) {
  20212. providers.push([name, 'factory', factory]);
  20213. return this;
  20214. };
  20215. this.value = function(name, value) {
  20216. providers.push([name, 'value', value]);
  20217. return this;
  20218. };
  20219. this.type = function(name, type) {
  20220. providers.push([name, 'type', type]);
  20221. return this;
  20222. };
  20223. this.forEach = function(iterator) {
  20224. providers.forEach(iterator);
  20225. };
  20226. };
  20227. module.exports = Module;
  20228. },{}],81:[function(_dereq_,module,exports){
  20229. if (typeof Object.create === 'function') {
  20230. // implementation from standard node.js 'util' module
  20231. module.exports = function inherits(ctor, superCtor) {
  20232. ctor.super_ = superCtor
  20233. ctor.prototype = Object.create(superCtor.prototype, {
  20234. constructor: {
  20235. value: ctor,
  20236. enumerable: false,
  20237. writable: true,
  20238. configurable: true
  20239. }
  20240. });
  20241. };
  20242. } else {
  20243. // old school shim for old browsers
  20244. module.exports = function inherits(ctor, superCtor) {
  20245. ctor.super_ = superCtor
  20246. var TempCtor = function () {}
  20247. TempCtor.prototype = superCtor.prototype
  20248. ctor.prototype = new TempCtor()
  20249. ctor.prototype.constructor = ctor
  20250. }
  20251. }
  20252. },{}],82:[function(_dereq_,module,exports){
  20253. /**
  20254. * Gets the last element of `array`.
  20255. *
  20256. * @static
  20257. * @memberOf _
  20258. * @category Array
  20259. * @param {Array} array The array to query.
  20260. * @returns {*} Returns the last element of `array`.
  20261. * @example
  20262. *
  20263. * _.last([1, 2, 3]);
  20264. * // => 3
  20265. */
  20266. function last(array) {
  20267. var length = array ? array.length : 0;
  20268. return length ? array[length - 1] : undefined;
  20269. }
  20270. module.exports = last;
  20271. },{}],83:[function(_dereq_,module,exports){
  20272. var arrayEvery = _dereq_(99),
  20273. baseCallback = _dereq_(107),
  20274. baseEvery = _dereq_(112),
  20275. isArray = _dereq_(168),
  20276. isIterateeCall = _dereq_(157);
  20277. /**
  20278. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  20279. * The predicate is bound to `thisArg` and invoked with three arguments:
  20280. * (value, index|key, collection).
  20281. *
  20282. * If a property name is provided for `predicate` the created `_.property`
  20283. * style callback returns the property value of the given element.
  20284. *
  20285. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  20286. * style callback returns `true` for elements that have a matching property
  20287. * value, else `false`.
  20288. *
  20289. * If an object is provided for `predicate` the created `_.matches` style
  20290. * callback returns `true` for elements that have the properties of the given
  20291. * object, else `false`.
  20292. *
  20293. * @static
  20294. * @memberOf _
  20295. * @alias all
  20296. * @category Collection
  20297. * @param {Array|Object|string} collection The collection to iterate over.
  20298. * @param {Function|Object|string} [predicate=_.identity] The function invoked
  20299. * per iteration.
  20300. * @param {*} [thisArg] The `this` binding of `predicate`.
  20301. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  20302. * else `false`.
  20303. * @example
  20304. *
  20305. * _.every([true, 1, null, 'yes'], Boolean);
  20306. * // => false
  20307. *
  20308. * var users = [
  20309. * { 'user': 'barney', 'active': false },
  20310. * { 'user': 'fred', 'active': false }
  20311. * ];
  20312. *
  20313. * // using the `_.matches` callback shorthand
  20314. * _.every(users, { 'user': 'barney', 'active': false });
  20315. * // => false
  20316. *
  20317. * // using the `_.matchesProperty` callback shorthand
  20318. * _.every(users, 'active', false);
  20319. * // => true
  20320. *
  20321. * // using the `_.property` callback shorthand
  20322. * _.every(users, 'active');
  20323. * // => false
  20324. */
  20325. function every(collection, predicate, thisArg) {
  20326. var func = isArray(collection) ? arrayEvery : baseEvery;
  20327. if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
  20328. predicate = undefined;
  20329. }
  20330. if (typeof predicate != 'function' || thisArg !== undefined) {
  20331. predicate = baseCallback(predicate, thisArg, 3);
  20332. }
  20333. return func(collection, predicate);
  20334. }
  20335. module.exports = every;
  20336. },{"107":107,"112":112,"157":157,"168":168,"99":99}],84:[function(_dereq_,module,exports){
  20337. var arrayFilter = _dereq_(100),
  20338. baseCallback = _dereq_(107),
  20339. baseFilter = _dereq_(113),
  20340. isArray = _dereq_(168);
  20341. /**
  20342. * Iterates over elements of `collection`, returning an array of all elements
  20343. * `predicate` returns truthy for. The predicate is bound to `thisArg` and
  20344. * invoked with three arguments: (value, index|key, collection).
  20345. *
  20346. * If a property name is provided for `predicate` the created `_.property`
  20347. * style callback returns the property value of the given element.
  20348. *
  20349. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  20350. * style callback returns `true` for elements that have a matching property
  20351. * value, else `false`.
  20352. *
  20353. * If an object is provided for `predicate` the created `_.matches` style
  20354. * callback returns `true` for elements that have the properties of the given
  20355. * object, else `false`.
  20356. *
  20357. * @static
  20358. * @memberOf _
  20359. * @alias select
  20360. * @category Collection
  20361. * @param {Array|Object|string} collection The collection to iterate over.
  20362. * @param {Function|Object|string} [predicate=_.identity] The function invoked
  20363. * per iteration.
  20364. * @param {*} [thisArg] The `this` binding of `predicate`.
  20365. * @returns {Array} Returns the new filtered array.
  20366. * @example
  20367. *
  20368. * _.filter([4, 5, 6], function(n) {
  20369. * return n % 2 == 0;
  20370. * });
  20371. * // => [4, 6]
  20372. *
  20373. * var users = [
  20374. * { 'user': 'barney', 'age': 36, 'active': true },
  20375. * { 'user': 'fred', 'age': 40, 'active': false }
  20376. * ];
  20377. *
  20378. * // using the `_.matches` callback shorthand
  20379. * _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user');
  20380. * // => ['barney']
  20381. *
  20382. * // using the `_.matchesProperty` callback shorthand
  20383. * _.pluck(_.filter(users, 'active', false), 'user');
  20384. * // => ['fred']
  20385. *
  20386. * // using the `_.property` callback shorthand
  20387. * _.pluck(_.filter(users, 'active'), 'user');
  20388. * // => ['barney']
  20389. */
  20390. function filter(collection, predicate, thisArg) {
  20391. var func = isArray(collection) ? arrayFilter : baseFilter;
  20392. predicate = baseCallback(predicate, thisArg, 3);
  20393. return func(collection, predicate);
  20394. }
  20395. module.exports = filter;
  20396. },{"100":100,"107":107,"113":113,"168":168}],85:[function(_dereq_,module,exports){
  20397. var baseEach = _dereq_(111),
  20398. createFind = _dereq_(145);
  20399. /**
  20400. * Iterates over elements of `collection`, returning the first element
  20401. * `predicate` returns truthy for. The predicate is bound to `thisArg` and
  20402. * invoked with three arguments: (value, index|key, collection).
  20403. *
  20404. * If a property name is provided for `predicate` the created `_.property`
  20405. * style callback returns the property value of the given element.
  20406. *
  20407. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  20408. * style callback returns `true` for elements that have a matching property
  20409. * value, else `false`.
  20410. *
  20411. * If an object is provided for `predicate` the created `_.matches` style
  20412. * callback returns `true` for elements that have the properties of the given
  20413. * object, else `false`.
  20414. *
  20415. * @static
  20416. * @memberOf _
  20417. * @alias detect
  20418. * @category Collection
  20419. * @param {Array|Object|string} collection The collection to search.
  20420. * @param {Function|Object|string} [predicate=_.identity] The function invoked
  20421. * per iteration.
  20422. * @param {*} [thisArg] The `this` binding of `predicate`.
  20423. * @returns {*} Returns the matched element, else `undefined`.
  20424. * @example
  20425. *
  20426. * var users = [
  20427. * { 'user': 'barney', 'age': 36, 'active': true },
  20428. * { 'user': 'fred', 'age': 40, 'active': false },
  20429. * { 'user': 'pebbles', 'age': 1, 'active': true }
  20430. * ];
  20431. *
  20432. * _.result(_.find(users, function(chr) {
  20433. * return chr.age < 40;
  20434. * }), 'user');
  20435. * // => 'barney'
  20436. *
  20437. * // using the `_.matches` callback shorthand
  20438. * _.result(_.find(users, { 'age': 1, 'active': true }), 'user');
  20439. * // => 'pebbles'
  20440. *
  20441. * // using the `_.matchesProperty` callback shorthand
  20442. * _.result(_.find(users, 'active', false), 'user');
  20443. * // => 'fred'
  20444. *
  20445. * // using the `_.property` callback shorthand
  20446. * _.result(_.find(users, 'active'), 'user');
  20447. * // => 'barney'
  20448. */
  20449. var find = createFind(baseEach);
  20450. module.exports = find;
  20451. },{"111":111,"145":145}],86:[function(_dereq_,module,exports){
  20452. var arrayEach = _dereq_(98),
  20453. baseEach = _dereq_(111),
  20454. createForEach = _dereq_(146);
  20455. /**
  20456. * Iterates over elements of `collection` invoking `iteratee` for each element.
  20457. * The `iteratee` is bound to `thisArg` and invoked with three arguments:
  20458. * (value, index|key, collection). Iteratee functions may exit iteration early
  20459. * by explicitly returning `false`.
  20460. *
  20461. * **Note:** As with other "Collections" methods, objects with a "length" property
  20462. * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`
  20463. * may be used for object iteration.
  20464. *
  20465. * @static
  20466. * @memberOf _
  20467. * @alias each
  20468. * @category Collection
  20469. * @param {Array|Object|string} collection The collection to iterate over.
  20470. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  20471. * @param {*} [thisArg] The `this` binding of `iteratee`.
  20472. * @returns {Array|Object|string} Returns `collection`.
  20473. * @example
  20474. *
  20475. * _([1, 2]).forEach(function(n) {
  20476. * console.log(n);
  20477. * }).value();
  20478. * // => logs each value from left to right and returns the array
  20479. *
  20480. * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) {
  20481. * console.log(n, key);
  20482. * });
  20483. * // => logs each value-key pair and returns the object (iteration order is not guaranteed)
  20484. */
  20485. var forEach = createForEach(arrayEach, baseEach);
  20486. module.exports = forEach;
  20487. },{"111":111,"146":146,"98":98}],87:[function(_dereq_,module,exports){
  20488. var createAggregator = _dereq_(140);
  20489. /** Used for native method references. */
  20490. var objectProto = Object.prototype;
  20491. /** Used to check objects for own properties. */
  20492. var hasOwnProperty = objectProto.hasOwnProperty;
  20493. /**
  20494. * Creates an object composed of keys generated from the results of running
  20495. * each element of `collection` through `iteratee`. The corresponding value
  20496. * of each key is an array of the elements responsible for generating the key.
  20497. * The `iteratee` is bound to `thisArg` and invoked with three arguments:
  20498. * (value, index|key, collection).
  20499. *
  20500. * If a property name is provided for `iteratee` the created `_.property`
  20501. * style callback returns the property value of the given element.
  20502. *
  20503. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  20504. * style callback returns `true` for elements that have a matching property
  20505. * value, else `false`.
  20506. *
  20507. * If an object is provided for `iteratee` the created `_.matches` style
  20508. * callback returns `true` for elements that have the properties of the given
  20509. * object, else `false`.
  20510. *
  20511. * @static
  20512. * @memberOf _
  20513. * @category Collection
  20514. * @param {Array|Object|string} collection The collection to iterate over.
  20515. * @param {Function|Object|string} [iteratee=_.identity] The function invoked
  20516. * per iteration.
  20517. * @param {*} [thisArg] The `this` binding of `iteratee`.
  20518. * @returns {Object} Returns the composed aggregate object.
  20519. * @example
  20520. *
  20521. * _.groupBy([4.2, 6.1, 6.4], function(n) {
  20522. * return Math.floor(n);
  20523. * });
  20524. * // => { '4': [4.2], '6': [6.1, 6.4] }
  20525. *
  20526. * _.groupBy([4.2, 6.1, 6.4], function(n) {
  20527. * return this.floor(n);
  20528. * }, Math);
  20529. * // => { '4': [4.2], '6': [6.1, 6.4] }
  20530. *
  20531. * // using the `_.property` callback shorthand
  20532. * _.groupBy(['one', 'two', 'three'], 'length');
  20533. * // => { '3': ['one', 'two'], '5': ['three'] }
  20534. */
  20535. var groupBy = createAggregator(function(result, value, key) {
  20536. if (hasOwnProperty.call(result, key)) {
  20537. result[key].push(value);
  20538. } else {
  20539. result[key] = [value];
  20540. }
  20541. });
  20542. module.exports = groupBy;
  20543. },{"140":140}],88:[function(_dereq_,module,exports){
  20544. var baseIndexOf = _dereq_(121),
  20545. getLength = _dereq_(151),
  20546. isArray = _dereq_(168),
  20547. isIterateeCall = _dereq_(157),
  20548. isLength = _dereq_(159),
  20549. isString = _dereq_(174),
  20550. values = _dereq_(184);
  20551. /* Native method references for those with the same name as other `lodash` methods. */
  20552. var nativeMax = Math.max;
  20553. /**
  20554. * Checks if `target` is in `collection` using
  20555. * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
  20556. * for equality comparisons. If `fromIndex` is negative, it's used as the offset
  20557. * from the end of `collection`.
  20558. *
  20559. * @static
  20560. * @memberOf _
  20561. * @alias contains, include
  20562. * @category Collection
  20563. * @param {Array|Object|string} collection The collection to search.
  20564. * @param {*} target The value to search for.
  20565. * @param {number} [fromIndex=0] The index to search from.
  20566. * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
  20567. * @returns {boolean} Returns `true` if a matching element is found, else `false`.
  20568. * @example
  20569. *
  20570. * _.includes([1, 2, 3], 1);
  20571. * // => true
  20572. *
  20573. * _.includes([1, 2, 3], 1, 2);
  20574. * // => false
  20575. *
  20576. * _.includes({ 'user': 'fred', 'age': 40 }, 'fred');
  20577. * // => true
  20578. *
  20579. * _.includes('pebbles', 'eb');
  20580. * // => true
  20581. */
  20582. function includes(collection, target, fromIndex, guard) {
  20583. var length = collection ? getLength(collection) : 0;
  20584. if (!isLength(length)) {
  20585. collection = values(collection);
  20586. length = collection.length;
  20587. }
  20588. if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
  20589. fromIndex = 0;
  20590. } else {
  20591. fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
  20592. }
  20593. return (typeof collection == 'string' || !isArray(collection) && isString(collection))
  20594. ? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1)
  20595. : (!!length && baseIndexOf(collection, target, fromIndex) > -1);
  20596. }
  20597. module.exports = includes;
  20598. },{"121":121,"151":151,"157":157,"159":159,"168":168,"174":174,"184":184}],89:[function(_dereq_,module,exports){
  20599. var arrayMap = _dereq_(101),
  20600. baseCallback = _dereq_(107),
  20601. baseMap = _dereq_(125),
  20602. isArray = _dereq_(168);
  20603. /**
  20604. * Creates an array of values by running each element in `collection` through
  20605. * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three
  20606. * arguments: (value, index|key, collection).
  20607. *
  20608. * If a property name is provided for `iteratee` the created `_.property`
  20609. * style callback returns the property value of the given element.
  20610. *
  20611. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  20612. * style callback returns `true` for elements that have a matching property
  20613. * value, else `false`.
  20614. *
  20615. * If an object is provided for `iteratee` the created `_.matches` style
  20616. * callback returns `true` for elements that have the properties of the given
  20617. * object, else `false`.
  20618. *
  20619. * Many lodash methods are guarded to work as iteratees for methods like
  20620. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  20621. *
  20622. * The guarded methods are:
  20623. * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`,
  20624. * `drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`,
  20625. * `parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`,
  20626. * `trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`,
  20627. * `sum`, `uniq`, and `words`
  20628. *
  20629. * @static
  20630. * @memberOf _
  20631. * @alias collect
  20632. * @category Collection
  20633. * @param {Array|Object|string} collection The collection to iterate over.
  20634. * @param {Function|Object|string} [iteratee=_.identity] The function invoked
  20635. * per iteration.
  20636. * @param {*} [thisArg] The `this` binding of `iteratee`.
  20637. * @returns {Array} Returns the new mapped array.
  20638. * @example
  20639. *
  20640. * function timesThree(n) {
  20641. * return n * 3;
  20642. * }
  20643. *
  20644. * _.map([1, 2], timesThree);
  20645. * // => [3, 6]
  20646. *
  20647. * _.map({ 'a': 1, 'b': 2 }, timesThree);
  20648. * // => [3, 6] (iteration order is not guaranteed)
  20649. *
  20650. * var users = [
  20651. * { 'user': 'barney' },
  20652. * { 'user': 'fred' }
  20653. * ];
  20654. *
  20655. * // using the `_.property` callback shorthand
  20656. * _.map(users, 'user');
  20657. * // => ['barney', 'fred']
  20658. */
  20659. function map(collection, iteratee, thisArg) {
  20660. var func = isArray(collection) ? arrayMap : baseMap;
  20661. iteratee = baseCallback(iteratee, thisArg, 3);
  20662. return func(collection, iteratee);
  20663. }
  20664. module.exports = map;
  20665. },{"101":101,"107":107,"125":125,"168":168}],90:[function(_dereq_,module,exports){
  20666. var arrayReduce = _dereq_(103),
  20667. baseEach = _dereq_(111),
  20668. createReduce = _dereq_(147);
  20669. /**
  20670. * Reduces `collection` to a value which is the accumulated result of running
  20671. * each element in `collection` through `iteratee`, where each successive
  20672. * invocation is supplied the return value of the previous. If `accumulator`
  20673. * is not provided the first element of `collection` is used as the initial
  20674. * value. The `iteratee` is bound to `thisArg` and invoked with four arguments:
  20675. * (accumulator, value, index|key, collection).
  20676. *
  20677. * Many lodash methods are guarded to work as iteratees for methods like
  20678. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  20679. *
  20680. * The guarded methods are:
  20681. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `sortByAll`,
  20682. * and `sortByOrder`
  20683. *
  20684. * @static
  20685. * @memberOf _
  20686. * @alias foldl, inject
  20687. * @category Collection
  20688. * @param {Array|Object|string} collection The collection to iterate over.
  20689. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  20690. * @param {*} [accumulator] The initial value.
  20691. * @param {*} [thisArg] The `this` binding of `iteratee`.
  20692. * @returns {*} Returns the accumulated value.
  20693. * @example
  20694. *
  20695. * _.reduce([1, 2], function(total, n) {
  20696. * return total + n;
  20697. * });
  20698. * // => 3
  20699. *
  20700. * _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) {
  20701. * result[key] = n * 3;
  20702. * return result;
  20703. * }, {});
  20704. * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed)
  20705. */
  20706. var reduce = createReduce(arrayReduce, baseEach);
  20707. module.exports = reduce;
  20708. },{"103":103,"111":111,"147":147}],91:[function(_dereq_,module,exports){
  20709. var arraySome = _dereq_(104),
  20710. baseCallback = _dereq_(107),
  20711. baseSome = _dereq_(134),
  20712. isArray = _dereq_(168),
  20713. isIterateeCall = _dereq_(157);
  20714. /**
  20715. * Checks if `predicate` returns truthy for **any** element of `collection`.
  20716. * The function returns as soon as it finds a passing value and does not iterate
  20717. * over the entire collection. The predicate is bound to `thisArg` and invoked
  20718. * with three arguments: (value, index|key, collection).
  20719. *
  20720. * If a property name is provided for `predicate` the created `_.property`
  20721. * style callback returns the property value of the given element.
  20722. *
  20723. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  20724. * style callback returns `true` for elements that have a matching property
  20725. * value, else `false`.
  20726. *
  20727. * If an object is provided for `predicate` the created `_.matches` style
  20728. * callback returns `true` for elements that have the properties of the given
  20729. * object, else `false`.
  20730. *
  20731. * @static
  20732. * @memberOf _
  20733. * @alias any
  20734. * @category Collection
  20735. * @param {Array|Object|string} collection The collection to iterate over.
  20736. * @param {Function|Object|string} [predicate=_.identity] The function invoked
  20737. * per iteration.
  20738. * @param {*} [thisArg] The `this` binding of `predicate`.
  20739. * @returns {boolean} Returns `true` if any element passes the predicate check,
  20740. * else `false`.
  20741. * @example
  20742. *
  20743. * _.some([null, 0, 'yes', false], Boolean);
  20744. * // => true
  20745. *
  20746. * var users = [
  20747. * { 'user': 'barney', 'active': true },
  20748. * { 'user': 'fred', 'active': false }
  20749. * ];
  20750. *
  20751. * // using the `_.matches` callback shorthand
  20752. * _.some(users, { 'user': 'barney', 'active': false });
  20753. * // => false
  20754. *
  20755. * // using the `_.matchesProperty` callback shorthand
  20756. * _.some(users, 'active', false);
  20757. * // => true
  20758. *
  20759. * // using the `_.property` callback shorthand
  20760. * _.some(users, 'active');
  20761. * // => true
  20762. */
  20763. function some(collection, predicate, thisArg) {
  20764. var func = isArray(collection) ? arraySome : baseSome;
  20765. if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
  20766. predicate = undefined;
  20767. }
  20768. if (typeof predicate != 'function' || thisArg !== undefined) {
  20769. predicate = baseCallback(predicate, thisArg, 3);
  20770. }
  20771. return func(collection, predicate);
  20772. }
  20773. module.exports = some;
  20774. },{"104":104,"107":107,"134":134,"157":157,"168":168}],92:[function(_dereq_,module,exports){
  20775. var getNative = _dereq_(153);
  20776. /* Native method references for those with the same name as other `lodash` methods. */
  20777. var nativeNow = getNative(Date, 'now');
  20778. /**
  20779. * Gets the number of milliseconds that have elapsed since the Unix epoch
  20780. * (1 January 1970 00:00:00 UTC).
  20781. *
  20782. * @static
  20783. * @memberOf _
  20784. * @category Date
  20785. * @example
  20786. *
  20787. * _.defer(function(stamp) {
  20788. * console.log(_.now() - stamp);
  20789. * }, _.now());
  20790. * // => logs the number of milliseconds it took for the deferred function to be invoked
  20791. */
  20792. var now = nativeNow || function() {
  20793. return new Date().getTime();
  20794. };
  20795. module.exports = now;
  20796. },{"153":153}],93:[function(_dereq_,module,exports){
  20797. var isObject = _dereq_(172),
  20798. now = _dereq_(92);
  20799. /** Used as the `TypeError` message for "Functions" methods. */
  20800. var FUNC_ERROR_TEXT = 'Expected a function';
  20801. /* Native method references for those with the same name as other `lodash` methods. */
  20802. var nativeMax = Math.max;
  20803. /**
  20804. * Creates a debounced function that delays invoking `func` until after `wait`
  20805. * milliseconds have elapsed since the last time the debounced function was
  20806. * invoked. The debounced function comes with a `cancel` method to cancel
  20807. * delayed invocations. Provide an options object to indicate that `func`
  20808. * should be invoked on the leading and/or trailing edge of the `wait` timeout.
  20809. * Subsequent calls to the debounced function return the result of the last
  20810. * `func` invocation.
  20811. *
  20812. * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
  20813. * on the trailing edge of the timeout only if the the debounced function is
  20814. * invoked more than once during the `wait` timeout.
  20815. *
  20816. * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
  20817. * for details over the differences between `_.debounce` and `_.throttle`.
  20818. *
  20819. * @static
  20820. * @memberOf _
  20821. * @category Function
  20822. * @param {Function} func The function to debounce.
  20823. * @param {number} [wait=0] The number of milliseconds to delay.
  20824. * @param {Object} [options] The options object.
  20825. * @param {boolean} [options.leading=false] Specify invoking on the leading
  20826. * edge of the timeout.
  20827. * @param {number} [options.maxWait] The maximum time `func` is allowed to be
  20828. * delayed before it's invoked.
  20829. * @param {boolean} [options.trailing=true] Specify invoking on the trailing
  20830. * edge of the timeout.
  20831. * @returns {Function} Returns the new debounced function.
  20832. * @example
  20833. *
  20834. * // avoid costly calculations while the window size is in flux
  20835. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  20836. *
  20837. * // invoke `sendMail` when the click event is fired, debouncing subsequent calls
  20838. * jQuery('#postbox').on('click', _.debounce(sendMail, 300, {
  20839. * 'leading': true,
  20840. * 'trailing': false
  20841. * }));
  20842. *
  20843. * // ensure `batchLog` is invoked once after 1 second of debounced calls
  20844. * var source = new EventSource('/stream');
  20845. * jQuery(source).on('message', _.debounce(batchLog, 250, {
  20846. * 'maxWait': 1000
  20847. * }));
  20848. *
  20849. * // cancel a debounced call
  20850. * var todoChanges = _.debounce(batchLog, 1000);
  20851. * Object.observe(models.todo, todoChanges);
  20852. *
  20853. * Object.observe(models, function(changes) {
  20854. * if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) {
  20855. * todoChanges.cancel();
  20856. * }
  20857. * }, ['delete']);
  20858. *
  20859. * // ...at some point `models.todo` is changed
  20860. * models.todo.completed = true;
  20861. *
  20862. * // ...before 1 second has passed `models.todo` is deleted
  20863. * // which cancels the debounced `todoChanges` call
  20864. * delete models.todo;
  20865. */
  20866. function debounce(func, wait, options) {
  20867. var args,
  20868. maxTimeoutId,
  20869. result,
  20870. stamp,
  20871. thisArg,
  20872. timeoutId,
  20873. trailingCall,
  20874. lastCalled = 0,
  20875. maxWait = false,
  20876. trailing = true;
  20877. if (typeof func != 'function') {
  20878. throw new TypeError(FUNC_ERROR_TEXT);
  20879. }
  20880. wait = wait < 0 ? 0 : (+wait || 0);
  20881. if (options === true) {
  20882. var leading = true;
  20883. trailing = false;
  20884. } else if (isObject(options)) {
  20885. leading = !!options.leading;
  20886. maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait);
  20887. trailing = 'trailing' in options ? !!options.trailing : trailing;
  20888. }
  20889. function cancel() {
  20890. if (timeoutId) {
  20891. clearTimeout(timeoutId);
  20892. }
  20893. if (maxTimeoutId) {
  20894. clearTimeout(maxTimeoutId);
  20895. }
  20896. lastCalled = 0;
  20897. maxTimeoutId = timeoutId = trailingCall = undefined;
  20898. }
  20899. function complete(isCalled, id) {
  20900. if (id) {
  20901. clearTimeout(id);
  20902. }
  20903. maxTimeoutId = timeoutId = trailingCall = undefined;
  20904. if (isCalled) {
  20905. lastCalled = now();
  20906. result = func.apply(thisArg, args);
  20907. if (!timeoutId && !maxTimeoutId) {
  20908. args = thisArg = undefined;
  20909. }
  20910. }
  20911. }
  20912. function delayed() {
  20913. var remaining = wait - (now() - stamp);
  20914. if (remaining <= 0 || remaining > wait) {
  20915. complete(trailingCall, maxTimeoutId);
  20916. } else {
  20917. timeoutId = setTimeout(delayed, remaining);
  20918. }
  20919. }
  20920. function maxDelayed() {
  20921. complete(trailing, timeoutId);
  20922. }
  20923. function debounced() {
  20924. args = arguments;
  20925. stamp = now();
  20926. thisArg = this;
  20927. trailingCall = trailing && (timeoutId || !leading);
  20928. if (maxWait === false) {
  20929. var leadingCall = leading && !timeoutId;
  20930. } else {
  20931. if (!maxTimeoutId && !leading) {
  20932. lastCalled = stamp;
  20933. }
  20934. var remaining = maxWait - (stamp - lastCalled),
  20935. isCalled = remaining <= 0 || remaining > maxWait;
  20936. if (isCalled) {
  20937. if (maxTimeoutId) {
  20938. maxTimeoutId = clearTimeout(maxTimeoutId);
  20939. }
  20940. lastCalled = stamp;
  20941. result = func.apply(thisArg, args);
  20942. }
  20943. else if (!maxTimeoutId) {
  20944. maxTimeoutId = setTimeout(maxDelayed, remaining);
  20945. }
  20946. }
  20947. if (isCalled && timeoutId) {
  20948. timeoutId = clearTimeout(timeoutId);
  20949. }
  20950. else if (!timeoutId && wait !== maxWait) {
  20951. timeoutId = setTimeout(delayed, wait);
  20952. }
  20953. if (leadingCall) {
  20954. isCalled = true;
  20955. result = func.apply(thisArg, args);
  20956. }
  20957. if (isCalled && !timeoutId && !maxTimeoutId) {
  20958. args = thisArg = undefined;
  20959. }
  20960. return result;
  20961. }
  20962. debounced.cancel = cancel;
  20963. return debounced;
  20964. }
  20965. module.exports = debounce;
  20966. },{"172":172,"92":92}],94:[function(_dereq_,module,exports){
  20967. var baseDelay = _dereq_(109),
  20968. restParam = _dereq_(95);
  20969. /**
  20970. * Defers invoking the `func` until the current call stack has cleared. Any
  20971. * additional arguments are provided to `func` when it's invoked.
  20972. *
  20973. * @static
  20974. * @memberOf _
  20975. * @category Function
  20976. * @param {Function} func The function to defer.
  20977. * @param {...*} [args] The arguments to invoke the function with.
  20978. * @returns {number} Returns the timer id.
  20979. * @example
  20980. *
  20981. * _.defer(function(text) {
  20982. * console.log(text);
  20983. * }, 'deferred');
  20984. * // logs 'deferred' after one or more milliseconds
  20985. */
  20986. var defer = restParam(function(func, args) {
  20987. return baseDelay(func, 1, args);
  20988. });
  20989. module.exports = defer;
  20990. },{"109":109,"95":95}],95:[function(_dereq_,module,exports){
  20991. /** Used as the `TypeError` message for "Functions" methods. */
  20992. var FUNC_ERROR_TEXT = 'Expected a function';
  20993. /* Native method references for those with the same name as other `lodash` methods. */
  20994. var nativeMax = Math.max;
  20995. /**
  20996. * Creates a function that invokes `func` with the `this` binding of the
  20997. * created function and arguments from `start` and beyond provided as an array.
  20998. *
  20999. * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters).
  21000. *
  21001. * @static
  21002. * @memberOf _
  21003. * @category Function
  21004. * @param {Function} func The function to apply a rest parameter to.
  21005. * @param {number} [start=func.length-1] The start position of the rest parameter.
  21006. * @returns {Function} Returns the new function.
  21007. * @example
  21008. *
  21009. * var say = _.restParam(function(what, names) {
  21010. * return what + ' ' + _.initial(names).join(', ') +
  21011. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  21012. * });
  21013. *
  21014. * say('hello', 'fred', 'barney', 'pebbles');
  21015. * // => 'hello fred, barney, & pebbles'
  21016. */
  21017. function restParam(func, start) {
  21018. if (typeof func != 'function') {
  21019. throw new TypeError(FUNC_ERROR_TEXT);
  21020. }
  21021. start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
  21022. return function() {
  21023. var args = arguments,
  21024. index = -1,
  21025. length = nativeMax(args.length - start, 0),
  21026. rest = Array(length);
  21027. while (++index < length) {
  21028. rest[index] = args[start + index];
  21029. }
  21030. switch (start) {
  21031. case 0: return func.call(this, rest);
  21032. case 1: return func.call(this, args[0], rest);
  21033. case 2: return func.call(this, args[0], args[1], rest);
  21034. }
  21035. var otherArgs = Array(start + 1);
  21036. index = -1;
  21037. while (++index < start) {
  21038. otherArgs[index] = args[index];
  21039. }
  21040. otherArgs[start] = rest;
  21041. return func.apply(this, otherArgs);
  21042. };
  21043. }
  21044. module.exports = restParam;
  21045. },{}],96:[function(_dereq_,module,exports){
  21046. (function (global){
  21047. var cachePush = _dereq_(139),
  21048. getNative = _dereq_(153);
  21049. /** Native method references. */
  21050. var Set = getNative(global, 'Set');
  21051. /* Native method references for those with the same name as other `lodash` methods. */
  21052. var nativeCreate = getNative(Object, 'create');
  21053. /**
  21054. *
  21055. * Creates a cache object to store unique values.
  21056. *
  21057. * @private
  21058. * @param {Array} [values] The values to cache.
  21059. */
  21060. function SetCache(values) {
  21061. var length = values ? values.length : 0;
  21062. this.data = { 'hash': nativeCreate(null), 'set': new Set };
  21063. while (length--) {
  21064. this.push(values[length]);
  21065. }
  21066. }
  21067. // Add functions to the `Set` cache.
  21068. SetCache.prototype.push = cachePush;
  21069. module.exports = SetCache;
  21070. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  21071. //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaW50ZXJuYWwvU2V0Q2FjaGUuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsImZpbGUiOiJnZW5lcmF0ZWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc0NvbnRlbnQiOlsidmFyIGNhY2hlUHVzaCA9IHJlcXVpcmUoJy4vY2FjaGVQdXNoJyksXG4gICAgZ2V0TmF0aXZlID0gcmVxdWlyZSgnLi9nZXROYXRpdmUnKTtcblxuLyoqIE5hdGl2ZSBtZXRob2QgcmVmZXJlbmNlcy4gKi9cbnZhciBTZXQgPSBnZXROYXRpdmUoZ2xvYmFsLCAnU2V0Jyk7XG5cbi8qIE5hdGl2ZSBtZXRob2QgcmVmZXJlbmNlcyBmb3IgdGhvc2Ugd2l0aCB0aGUgc2FtZSBuYW1lIGFzIG90aGVyIGBsb2Rhc2hgIG1ldGhvZHMuICovXG52YXIgbmF0aXZlQ3JlYXRlID0gZ2V0TmF0aXZlKE9iamVjdCwgJ2NyZWF0ZScpO1xuXG4vKipcbiAqXG4gKiBDcmVhdGVzIGEgY2FjaGUgb2JqZWN0IHRvIHN0b3JlIHVuaXF1ZSB2YWx1ZXMuXG4gKlxuICogQHByaXZhdGVcbiAqIEBwYXJhbSB7QXJyYXl9IFt2YWx1ZXNdIFRoZSB2YWx1ZXMgdG8gY2FjaGUuXG4gKi9cbmZ1bmN0aW9uIFNldENhY2hlKHZhbHVlcykge1xuICB2YXIgbGVuZ3RoID0gdmFsdWVzID8gdmFsdWVzLmxlbmd0aCA6IDA7XG5cbiAgdGhpcy5kYXRhID0geyAnaGFzaCc6IG5hdGl2ZUNyZWF0ZShudWxsKSwgJ3NldCc6IG5ldyBTZXQgfTtcbiAgd2hpbGUgKGxlbmd0aC0tKSB7XG4gICAgdGhpcy5wdXNoKHZhbHVlc1tsZW5ndGhdKTtcbiAgfVxufVxuXG4vLyBBZGQgZnVuY3Rpb25zIHRvIHRoZSBgU2V0YCBjYWNoZS5cblNldENhY2hlLnByb3RvdHlwZS5wdXNoID0gY2FjaGVQdXNoO1xuXG5tb2R1bGUuZXhwb3J0cyA9IFNldENhY2hlO1xuIl19
  21072. },{"139":139,"153":153}],97:[function(_dereq_,module,exports){
  21073. /**
  21074. * Copies the values of `source` to `array`.
  21075. *
  21076. * @private
  21077. * @param {Array} source The array to copy values from.
  21078. * @param {Array} [array=[]] The array to copy values to.
  21079. * @returns {Array} Returns `array`.
  21080. */
  21081. function arrayCopy(source, array) {
  21082. var index = -1,
  21083. length = source.length;
  21084. array || (array = Array(length));
  21085. while (++index < length) {
  21086. array[index] = source[index];
  21087. }
  21088. return array;
  21089. }
  21090. module.exports = arrayCopy;
  21091. },{}],98:[function(_dereq_,module,exports){
  21092. /**
  21093. * A specialized version of `_.forEach` for arrays without support for callback
  21094. * shorthands and `this` binding.
  21095. *
  21096. * @private
  21097. * @param {Array} array The array to iterate over.
  21098. * @param {Function} iteratee The function invoked per iteration.
  21099. * @returns {Array} Returns `array`.
  21100. */
  21101. function arrayEach(array, iteratee) {
  21102. var index = -1,
  21103. length = array.length;
  21104. while (++index < length) {
  21105. if (iteratee(array[index], index, array) === false) {
  21106. break;
  21107. }
  21108. }
  21109. return array;
  21110. }
  21111. module.exports = arrayEach;
  21112. },{}],99:[function(_dereq_,module,exports){
  21113. /**
  21114. * A specialized version of `_.every` for arrays without support for callback
  21115. * shorthands and `this` binding.
  21116. *
  21117. * @private
  21118. * @param {Array} array The array to iterate over.
  21119. * @param {Function} predicate The function invoked per iteration.
  21120. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  21121. * else `false`.
  21122. */
  21123. function arrayEvery(array, predicate) {
  21124. var index = -1,
  21125. length = array.length;
  21126. while (++index < length) {
  21127. if (!predicate(array[index], index, array)) {
  21128. return false;
  21129. }
  21130. }
  21131. return true;
  21132. }
  21133. module.exports = arrayEvery;
  21134. },{}],100:[function(_dereq_,module,exports){
  21135. /**
  21136. * A specialized version of `_.filter` for arrays without support for callback
  21137. * shorthands and `this` binding.
  21138. *
  21139. * @private
  21140. * @param {Array} array The array to iterate over.
  21141. * @param {Function} predicate The function invoked per iteration.
  21142. * @returns {Array} Returns the new filtered array.
  21143. */
  21144. function arrayFilter(array, predicate) {
  21145. var index = -1,
  21146. length = array.length,
  21147. resIndex = -1,
  21148. result = [];
  21149. while (++index < length) {
  21150. var value = array[index];
  21151. if (predicate(value, index, array)) {
  21152. result[++resIndex] = value;
  21153. }
  21154. }
  21155. return result;
  21156. }
  21157. module.exports = arrayFilter;
  21158. },{}],101:[function(_dereq_,module,exports){
  21159. /**
  21160. * A specialized version of `_.map` for arrays without support for callback
  21161. * shorthands and `this` binding.
  21162. *
  21163. * @private
  21164. * @param {Array} array The array to iterate over.
  21165. * @param {Function} iteratee The function invoked per iteration.
  21166. * @returns {Array} Returns the new mapped array.
  21167. */
  21168. function arrayMap(array, iteratee) {
  21169. var index = -1,
  21170. length = array.length,
  21171. result = Array(length);
  21172. while (++index < length) {
  21173. result[index] = iteratee(array[index], index, array);
  21174. }
  21175. return result;
  21176. }
  21177. module.exports = arrayMap;
  21178. },{}],102:[function(_dereq_,module,exports){
  21179. /**
  21180. * Appends the elements of `values` to `array`.
  21181. *
  21182. * @private
  21183. * @param {Array} array The array to modify.
  21184. * @param {Array} values The values to append.
  21185. * @returns {Array} Returns `array`.
  21186. */
  21187. function arrayPush(array, values) {
  21188. var index = -1,
  21189. length = values.length,
  21190. offset = array.length;
  21191. while (++index < length) {
  21192. array[offset + index] = values[index];
  21193. }
  21194. return array;
  21195. }
  21196. module.exports = arrayPush;
  21197. },{}],103:[function(_dereq_,module,exports){
  21198. /**
  21199. * A specialized version of `_.reduce` for arrays without support for callback
  21200. * shorthands and `this` binding.
  21201. *
  21202. * @private
  21203. * @param {Array} array The array to iterate over.
  21204. * @param {Function} iteratee The function invoked per iteration.
  21205. * @param {*} [accumulator] The initial value.
  21206. * @param {boolean} [initFromArray] Specify using the first element of `array`
  21207. * as the initial value.
  21208. * @returns {*} Returns the accumulated value.
  21209. */
  21210. function arrayReduce(array, iteratee, accumulator, initFromArray) {
  21211. var index = -1,
  21212. length = array.length;
  21213. if (initFromArray && length) {
  21214. accumulator = array[++index];
  21215. }
  21216. while (++index < length) {
  21217. accumulator = iteratee(accumulator, array[index], index, array);
  21218. }
  21219. return accumulator;
  21220. }
  21221. module.exports = arrayReduce;
  21222. },{}],104:[function(_dereq_,module,exports){
  21223. /**
  21224. * A specialized version of `_.some` for arrays without support for callback
  21225. * shorthands and `this` binding.
  21226. *
  21227. * @private
  21228. * @param {Array} array The array to iterate over.
  21229. * @param {Function} predicate The function invoked per iteration.
  21230. * @returns {boolean} Returns `true` if any element passes the predicate check,
  21231. * else `false`.
  21232. */
  21233. function arraySome(array, predicate) {
  21234. var index = -1,
  21235. length = array.length;
  21236. while (++index < length) {
  21237. if (predicate(array[index], index, array)) {
  21238. return true;
  21239. }
  21240. }
  21241. return false;
  21242. }
  21243. module.exports = arraySome;
  21244. },{}],105:[function(_dereq_,module,exports){
  21245. var keys = _dereq_(178);
  21246. /**
  21247. * A specialized version of `_.assign` for customizing assigned values without
  21248. * support for argument juggling, multiple sources, and `this` binding `customizer`
  21249. * functions.
  21250. *
  21251. * @private
  21252. * @param {Object} object The destination object.
  21253. * @param {Object} source The source object.
  21254. * @param {Function} customizer The function to customize assigned values.
  21255. * @returns {Object} Returns `object`.
  21256. */
  21257. function assignWith(object, source, customizer) {
  21258. var index = -1,
  21259. props = keys(source),
  21260. length = props.length;
  21261. while (++index < length) {
  21262. var key = props[index],
  21263. value = object[key],
  21264. result = customizer(value, source[key], key, object, source);
  21265. if ((result === result ? (result !== value) : (value === value)) ||
  21266. (value === undefined && !(key in object))) {
  21267. object[key] = result;
  21268. }
  21269. }
  21270. return object;
  21271. }
  21272. module.exports = assignWith;
  21273. },{"178":178}],106:[function(_dereq_,module,exports){
  21274. var baseCopy = _dereq_(108),
  21275. keys = _dereq_(178);
  21276. /**
  21277. * The base implementation of `_.assign` without support for argument juggling,
  21278. * multiple sources, and `customizer` functions.
  21279. *
  21280. * @private
  21281. * @param {Object} object The destination object.
  21282. * @param {Object} source The source object.
  21283. * @returns {Object} Returns `object`.
  21284. */
  21285. function baseAssign(object, source) {
  21286. return source == null
  21287. ? object
  21288. : baseCopy(source, keys(source), object);
  21289. }
  21290. module.exports = baseAssign;
  21291. },{"108":108,"178":178}],107:[function(_dereq_,module,exports){
  21292. var baseMatches = _dereq_(126),
  21293. baseMatchesProperty = _dereq_(127),
  21294. bindCallback = _dereq_(137),
  21295. identity = _dereq_(185),
  21296. property = _dereq_(186);
  21297. /**
  21298. * The base implementation of `_.callback` which supports specifying the
  21299. * number of arguments to provide to `func`.
  21300. *
  21301. * @private
  21302. * @param {*} [func=_.identity] The value to convert to a callback.
  21303. * @param {*} [thisArg] The `this` binding of `func`.
  21304. * @param {number} [argCount] The number of arguments to provide to `func`.
  21305. * @returns {Function} Returns the callback.
  21306. */
  21307. function baseCallback(func, thisArg, argCount) {
  21308. var type = typeof func;
  21309. if (type == 'function') {
  21310. return thisArg === undefined
  21311. ? func
  21312. : bindCallback(func, thisArg, argCount);
  21313. }
  21314. if (func == null) {
  21315. return identity;
  21316. }
  21317. if (type == 'object') {
  21318. return baseMatches(func);
  21319. }
  21320. return thisArg === undefined
  21321. ? property(func)
  21322. : baseMatchesProperty(func, thisArg);
  21323. }
  21324. module.exports = baseCallback;
  21325. },{"126":126,"127":127,"137":137,"185":185,"186":186}],108:[function(_dereq_,module,exports){
  21326. /**
  21327. * Copies properties of `source` to `object`.
  21328. *
  21329. * @private
  21330. * @param {Object} source The object to copy properties from.
  21331. * @param {Array} props The property names to copy.
  21332. * @param {Object} [object={}] The object to copy properties to.
  21333. * @returns {Object} Returns `object`.
  21334. */
  21335. function baseCopy(source, props, object) {
  21336. object || (object = {});
  21337. var index = -1,
  21338. length = props.length;
  21339. while (++index < length) {
  21340. var key = props[index];
  21341. object[key] = source[key];
  21342. }
  21343. return object;
  21344. }
  21345. module.exports = baseCopy;
  21346. },{}],109:[function(_dereq_,module,exports){
  21347. /** Used as the `TypeError` message for "Functions" methods. */
  21348. var FUNC_ERROR_TEXT = 'Expected a function';
  21349. /**
  21350. * The base implementation of `_.delay` and `_.defer` which accepts an index
  21351. * of where to slice the arguments to provide to `func`.
  21352. *
  21353. * @private
  21354. * @param {Function} func The function to delay.
  21355. * @param {number} wait The number of milliseconds to delay invocation.
  21356. * @param {Object} args The arguments provide to `func`.
  21357. * @returns {number} Returns the timer id.
  21358. */
  21359. function baseDelay(func, wait, args) {
  21360. if (typeof func != 'function') {
  21361. throw new TypeError(FUNC_ERROR_TEXT);
  21362. }
  21363. return setTimeout(function() { func.apply(undefined, args); }, wait);
  21364. }
  21365. module.exports = baseDelay;
  21366. },{}],110:[function(_dereq_,module,exports){
  21367. var baseIndexOf = _dereq_(121),
  21368. cacheIndexOf = _dereq_(138),
  21369. createCache = _dereq_(144);
  21370. /** Used as the size to enable large array optimizations. */
  21371. var LARGE_ARRAY_SIZE = 200;
  21372. /**
  21373. * The base implementation of `_.difference` which accepts a single array
  21374. * of values to exclude.
  21375. *
  21376. * @private
  21377. * @param {Array} array The array to inspect.
  21378. * @param {Array} values The values to exclude.
  21379. * @returns {Array} Returns the new array of filtered values.
  21380. */
  21381. function baseDifference(array, values) {
  21382. var length = array ? array.length : 0,
  21383. result = [];
  21384. if (!length) {
  21385. return result;
  21386. }
  21387. var index = -1,
  21388. indexOf = baseIndexOf,
  21389. isCommon = true,
  21390. cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : null,
  21391. valuesLength = values.length;
  21392. if (cache) {
  21393. indexOf = cacheIndexOf;
  21394. isCommon = false;
  21395. values = cache;
  21396. }
  21397. outer:
  21398. while (++index < length) {
  21399. var value = array[index];
  21400. if (isCommon && value === value) {
  21401. var valuesIndex = valuesLength;
  21402. while (valuesIndex--) {
  21403. if (values[valuesIndex] === value) {
  21404. continue outer;
  21405. }
  21406. }
  21407. result.push(value);
  21408. }
  21409. else if (indexOf(values, value, 0) < 0) {
  21410. result.push(value);
  21411. }
  21412. }
  21413. return result;
  21414. }
  21415. module.exports = baseDifference;
  21416. },{"121":121,"138":138,"144":144}],111:[function(_dereq_,module,exports){
  21417. var baseForOwn = _dereq_(119),
  21418. createBaseEach = _dereq_(142);
  21419. /**
  21420. * The base implementation of `_.forEach` without support for callback
  21421. * shorthands and `this` binding.
  21422. *
  21423. * @private
  21424. * @param {Array|Object|string} collection The collection to iterate over.
  21425. * @param {Function} iteratee The function invoked per iteration.
  21426. * @returns {Array|Object|string} Returns `collection`.
  21427. */
  21428. var baseEach = createBaseEach(baseForOwn);
  21429. module.exports = baseEach;
  21430. },{"119":119,"142":142}],112:[function(_dereq_,module,exports){
  21431. var baseEach = _dereq_(111);
  21432. /**
  21433. * The base implementation of `_.every` without support for callback
  21434. * shorthands and `this` binding.
  21435. *
  21436. * @private
  21437. * @param {Array|Object|string} collection The collection to iterate over.
  21438. * @param {Function} predicate The function invoked per iteration.
  21439. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  21440. * else `false`
  21441. */
  21442. function baseEvery(collection, predicate) {
  21443. var result = true;
  21444. baseEach(collection, function(value, index, collection) {
  21445. result = !!predicate(value, index, collection);
  21446. return result;
  21447. });
  21448. return result;
  21449. }
  21450. module.exports = baseEvery;
  21451. },{"111":111}],113:[function(_dereq_,module,exports){
  21452. var baseEach = _dereq_(111);
  21453. /**
  21454. * The base implementation of `_.filter` without support for callback
  21455. * shorthands and `this` binding.
  21456. *
  21457. * @private
  21458. * @param {Array|Object|string} collection The collection to iterate over.
  21459. * @param {Function} predicate The function invoked per iteration.
  21460. * @returns {Array} Returns the new filtered array.
  21461. */
  21462. function baseFilter(collection, predicate) {
  21463. var result = [];
  21464. baseEach(collection, function(value, index, collection) {
  21465. if (predicate(value, index, collection)) {
  21466. result.push(value);
  21467. }
  21468. });
  21469. return result;
  21470. }
  21471. module.exports = baseFilter;
  21472. },{"111":111}],114:[function(_dereq_,module,exports){
  21473. /**
  21474. * The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`,
  21475. * without support for callback shorthands and `this` binding, which iterates
  21476. * over `collection` using the provided `eachFunc`.
  21477. *
  21478. * @private
  21479. * @param {Array|Object|string} collection The collection to search.
  21480. * @param {Function} predicate The function invoked per iteration.
  21481. * @param {Function} eachFunc The function to iterate over `collection`.
  21482. * @param {boolean} [retKey] Specify returning the key of the found element
  21483. * instead of the element itself.
  21484. * @returns {*} Returns the found element or its key, else `undefined`.
  21485. */
  21486. function baseFind(collection, predicate, eachFunc, retKey) {
  21487. var result;
  21488. eachFunc(collection, function(value, key, collection) {
  21489. if (predicate(value, key, collection)) {
  21490. result = retKey ? key : value;
  21491. return false;
  21492. }
  21493. });
  21494. return result;
  21495. }
  21496. module.exports = baseFind;
  21497. },{}],115:[function(_dereq_,module,exports){
  21498. /**
  21499. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  21500. * support for callback shorthands and `this` binding.
  21501. *
  21502. * @private
  21503. * @param {Array} array The array to search.
  21504. * @param {Function} predicate The function invoked per iteration.
  21505. * @param {boolean} [fromRight] Specify iterating from right to left.
  21506. * @returns {number} Returns the index of the matched value, else `-1`.
  21507. */
  21508. function baseFindIndex(array, predicate, fromRight) {
  21509. var length = array.length,
  21510. index = fromRight ? length : -1;
  21511. while ((fromRight ? index-- : ++index < length)) {
  21512. if (predicate(array[index], index, array)) {
  21513. return index;
  21514. }
  21515. }
  21516. return -1;
  21517. }
  21518. module.exports = baseFindIndex;
  21519. },{}],116:[function(_dereq_,module,exports){
  21520. var arrayPush = _dereq_(102),
  21521. isArguments = _dereq_(167),
  21522. isArray = _dereq_(168),
  21523. isArrayLike = _dereq_(155),
  21524. isObjectLike = _dereq_(160);
  21525. /**
  21526. * The base implementation of `_.flatten` with added support for restricting
  21527. * flattening and specifying the start index.
  21528. *
  21529. * @private
  21530. * @param {Array} array The array to flatten.
  21531. * @param {boolean} [isDeep] Specify a deep flatten.
  21532. * @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
  21533. * @param {Array} [result=[]] The initial result value.
  21534. * @returns {Array} Returns the new flattened array.
  21535. */
  21536. function baseFlatten(array, isDeep, isStrict, result) {
  21537. result || (result = []);
  21538. var index = -1,
  21539. length = array.length;
  21540. while (++index < length) {
  21541. var value = array[index];
  21542. if (isObjectLike(value) && isArrayLike(value) &&
  21543. (isStrict || isArray(value) || isArguments(value))) {
  21544. if (isDeep) {
  21545. // Recursively flatten arrays (susceptible to call stack limits).
  21546. baseFlatten(value, isDeep, isStrict, result);
  21547. } else {
  21548. arrayPush(result, value);
  21549. }
  21550. } else if (!isStrict) {
  21551. result[result.length] = value;
  21552. }
  21553. }
  21554. return result;
  21555. }
  21556. module.exports = baseFlatten;
  21557. },{"102":102,"155":155,"160":160,"167":167,"168":168}],117:[function(_dereq_,module,exports){
  21558. var createBaseFor = _dereq_(143);
  21559. /**
  21560. * The base implementation of `baseForIn` and `baseForOwn` which iterates
  21561. * over `object` properties returned by `keysFunc` invoking `iteratee` for
  21562. * each property. Iteratee functions may exit iteration early by explicitly
  21563. * returning `false`.
  21564. *
  21565. * @private
  21566. * @param {Object} object The object to iterate over.
  21567. * @param {Function} iteratee The function invoked per iteration.
  21568. * @param {Function} keysFunc The function to get the keys of `object`.
  21569. * @returns {Object} Returns `object`.
  21570. */
  21571. var baseFor = createBaseFor();
  21572. module.exports = baseFor;
  21573. },{"143":143}],118:[function(_dereq_,module,exports){
  21574. var baseFor = _dereq_(117),
  21575. keysIn = _dereq_(179);
  21576. /**
  21577. * The base implementation of `_.forIn` without support for callback
  21578. * shorthands and `this` binding.
  21579. *
  21580. * @private
  21581. * @param {Object} object The object to iterate over.
  21582. * @param {Function} iteratee The function invoked per iteration.
  21583. * @returns {Object} Returns `object`.
  21584. */
  21585. function baseForIn(object, iteratee) {
  21586. return baseFor(object, iteratee, keysIn);
  21587. }
  21588. module.exports = baseForIn;
  21589. },{"117":117,"179":179}],119:[function(_dereq_,module,exports){
  21590. var baseFor = _dereq_(117),
  21591. keys = _dereq_(178);
  21592. /**
  21593. * The base implementation of `_.forOwn` without support for callback
  21594. * shorthands and `this` binding.
  21595. *
  21596. * @private
  21597. * @param {Object} object The object to iterate over.
  21598. * @param {Function} iteratee The function invoked per iteration.
  21599. * @returns {Object} Returns `object`.
  21600. */
  21601. function baseForOwn(object, iteratee) {
  21602. return baseFor(object, iteratee, keys);
  21603. }
  21604. module.exports = baseForOwn;
  21605. },{"117":117,"178":178}],120:[function(_dereq_,module,exports){
  21606. var toObject = _dereq_(165);
  21607. /**
  21608. * The base implementation of `get` without support for string paths
  21609. * and default values.
  21610. *
  21611. * @private
  21612. * @param {Object} object The object to query.
  21613. * @param {Array} path The path of the property to get.
  21614. * @param {string} [pathKey] The key representation of path.
  21615. * @returns {*} Returns the resolved value.
  21616. */
  21617. function baseGet(object, path, pathKey) {
  21618. if (object == null) {
  21619. return;
  21620. }
  21621. if (pathKey !== undefined && pathKey in toObject(object)) {
  21622. path = [pathKey];
  21623. }
  21624. var index = 0,
  21625. length = path.length;
  21626. while (object != null && index < length) {
  21627. object = object[path[index++]];
  21628. }
  21629. return (index && index == length) ? object : undefined;
  21630. }
  21631. module.exports = baseGet;
  21632. },{"165":165}],121:[function(_dereq_,module,exports){
  21633. var indexOfNaN = _dereq_(154);
  21634. /**
  21635. * The base implementation of `_.indexOf` without support for binary searches.
  21636. *
  21637. * @private
  21638. * @param {Array} array The array to search.
  21639. * @param {*} value The value to search for.
  21640. * @param {number} fromIndex The index to search from.
  21641. * @returns {number} Returns the index of the matched value, else `-1`.
  21642. */
  21643. function baseIndexOf(array, value, fromIndex) {
  21644. if (value !== value) {
  21645. return indexOfNaN(array, fromIndex);
  21646. }
  21647. var index = fromIndex - 1,
  21648. length = array.length;
  21649. while (++index < length) {
  21650. if (array[index] === value) {
  21651. return index;
  21652. }
  21653. }
  21654. return -1;
  21655. }
  21656. module.exports = baseIndexOf;
  21657. },{"154":154}],122:[function(_dereq_,module,exports){
  21658. var baseIsEqualDeep = _dereq_(123),
  21659. isObject = _dereq_(172),
  21660. isObjectLike = _dereq_(160);
  21661. /**
  21662. * The base implementation of `_.isEqual` without support for `this` binding
  21663. * `customizer` functions.
  21664. *
  21665. * @private
  21666. * @param {*} value The value to compare.
  21667. * @param {*} other The other value to compare.
  21668. * @param {Function} [customizer] The function to customize comparing values.
  21669. * @param {boolean} [isLoose] Specify performing partial comparisons.
  21670. * @param {Array} [stackA] Tracks traversed `value` objects.
  21671. * @param {Array} [stackB] Tracks traversed `other` objects.
  21672. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  21673. */
  21674. function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
  21675. if (value === other) {
  21676. return true;
  21677. }
  21678. if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
  21679. return value !== value && other !== other;
  21680. }
  21681. return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
  21682. }
  21683. module.exports = baseIsEqual;
  21684. },{"123":123,"160":160,"172":172}],123:[function(_dereq_,module,exports){
  21685. var equalArrays = _dereq_(148),
  21686. equalByTag = _dereq_(149),
  21687. equalObjects = _dereq_(150),
  21688. isArray = _dereq_(168),
  21689. isTypedArray = _dereq_(175);
  21690. /** `Object#toString` result references. */
  21691. var argsTag = '[object Arguments]',
  21692. arrayTag = '[object Array]',
  21693. objectTag = '[object Object]';
  21694. /** Used for native method references. */
  21695. var objectProto = Object.prototype;
  21696. /** Used to check objects for own properties. */
  21697. var hasOwnProperty = objectProto.hasOwnProperty;
  21698. /**
  21699. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  21700. * of values.
  21701. */
  21702. var objToString = objectProto.toString;
  21703. /**
  21704. * A specialized version of `baseIsEqual` for arrays and objects which performs
  21705. * deep comparisons and tracks traversed objects enabling objects with circular
  21706. * references to be compared.
  21707. *
  21708. * @private
  21709. * @param {Object} object The object to compare.
  21710. * @param {Object} other The other object to compare.
  21711. * @param {Function} equalFunc The function to determine equivalents of values.
  21712. * @param {Function} [customizer] The function to customize comparing objects.
  21713. * @param {boolean} [isLoose] Specify performing partial comparisons.
  21714. * @param {Array} [stackA=[]] Tracks traversed `value` objects.
  21715. * @param {Array} [stackB=[]] Tracks traversed `other` objects.
  21716. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  21717. */
  21718. function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  21719. var objIsArr = isArray(object),
  21720. othIsArr = isArray(other),
  21721. objTag = arrayTag,
  21722. othTag = arrayTag;
  21723. if (!objIsArr) {
  21724. objTag = objToString.call(object);
  21725. if (objTag == argsTag) {
  21726. objTag = objectTag;
  21727. } else if (objTag != objectTag) {
  21728. objIsArr = isTypedArray(object);
  21729. }
  21730. }
  21731. if (!othIsArr) {
  21732. othTag = objToString.call(other);
  21733. if (othTag == argsTag) {
  21734. othTag = objectTag;
  21735. } else if (othTag != objectTag) {
  21736. othIsArr = isTypedArray(other);
  21737. }
  21738. }
  21739. var objIsObj = objTag == objectTag,
  21740. othIsObj = othTag == objectTag,
  21741. isSameTag = objTag == othTag;
  21742. if (isSameTag && !(objIsArr || objIsObj)) {
  21743. return equalByTag(object, other, objTag);
  21744. }
  21745. if (!isLoose) {
  21746. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  21747. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  21748. if (objIsWrapped || othIsWrapped) {
  21749. return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
  21750. }
  21751. }
  21752. if (!isSameTag) {
  21753. return false;
  21754. }
  21755. // Assume cyclic values are equal.
  21756. // For more information on detecting circular references see https://es5.github.io/#JO.
  21757. stackA || (stackA = []);
  21758. stackB || (stackB = []);
  21759. var length = stackA.length;
  21760. while (length--) {
  21761. if (stackA[length] == object) {
  21762. return stackB[length] == other;
  21763. }
  21764. }
  21765. // Add `object` and `other` to the stack of traversed objects.
  21766. stackA.push(object);
  21767. stackB.push(other);
  21768. var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
  21769. stackA.pop();
  21770. stackB.pop();
  21771. return result;
  21772. }
  21773. module.exports = baseIsEqualDeep;
  21774. },{"148":148,"149":149,"150":150,"168":168,"175":175}],124:[function(_dereq_,module,exports){
  21775. var baseIsEqual = _dereq_(122),
  21776. toObject = _dereq_(165);
  21777. /**
  21778. * The base implementation of `_.isMatch` without support for callback
  21779. * shorthands and `this` binding.
  21780. *
  21781. * @private
  21782. * @param {Object} object The object to inspect.
  21783. * @param {Array} matchData The propery names, values, and compare flags to match.
  21784. * @param {Function} [customizer] The function to customize comparing objects.
  21785. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  21786. */
  21787. function baseIsMatch(object, matchData, customizer) {
  21788. var index = matchData.length,
  21789. length = index,
  21790. noCustomizer = !customizer;
  21791. if (object == null) {
  21792. return !length;
  21793. }
  21794. object = toObject(object);
  21795. while (index--) {
  21796. var data = matchData[index];
  21797. if ((noCustomizer && data[2])
  21798. ? data[1] !== object[data[0]]
  21799. : !(data[0] in object)
  21800. ) {
  21801. return false;
  21802. }
  21803. }
  21804. while (++index < length) {
  21805. data = matchData[index];
  21806. var key = data[0],
  21807. objValue = object[key],
  21808. srcValue = data[1];
  21809. if (noCustomizer && data[2]) {
  21810. if (objValue === undefined && !(key in object)) {
  21811. return false;
  21812. }
  21813. } else {
  21814. var result = customizer ? customizer(objValue, srcValue, key) : undefined;
  21815. if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) {
  21816. return false;
  21817. }
  21818. }
  21819. }
  21820. return true;
  21821. }
  21822. module.exports = baseIsMatch;
  21823. },{"122":122,"165":165}],125:[function(_dereq_,module,exports){
  21824. var baseEach = _dereq_(111),
  21825. isArrayLike = _dereq_(155);
  21826. /**
  21827. * The base implementation of `_.map` without support for callback shorthands
  21828. * and `this` binding.
  21829. *
  21830. * @private
  21831. * @param {Array|Object|string} collection The collection to iterate over.
  21832. * @param {Function} iteratee The function invoked per iteration.
  21833. * @returns {Array} Returns the new mapped array.
  21834. */
  21835. function baseMap(collection, iteratee) {
  21836. var index = -1,
  21837. result = isArrayLike(collection) ? Array(collection.length) : [];
  21838. baseEach(collection, function(value, key, collection) {
  21839. result[++index] = iteratee(value, key, collection);
  21840. });
  21841. return result;
  21842. }
  21843. module.exports = baseMap;
  21844. },{"111":111,"155":155}],126:[function(_dereq_,module,exports){
  21845. var baseIsMatch = _dereq_(124),
  21846. getMatchData = _dereq_(152),
  21847. toObject = _dereq_(165);
  21848. /**
  21849. * The base implementation of `_.matches` which does not clone `source`.
  21850. *
  21851. * @private
  21852. * @param {Object} source The object of property values to match.
  21853. * @returns {Function} Returns the new function.
  21854. */
  21855. function baseMatches(source) {
  21856. var matchData = getMatchData(source);
  21857. if (matchData.length == 1 && matchData[0][2]) {
  21858. var key = matchData[0][0],
  21859. value = matchData[0][1];
  21860. return function(object) {
  21861. if (object == null) {
  21862. return false;
  21863. }
  21864. return object[key] === value && (value !== undefined || (key in toObject(object)));
  21865. };
  21866. }
  21867. return function(object) {
  21868. return baseIsMatch(object, matchData);
  21869. };
  21870. }
  21871. module.exports = baseMatches;
  21872. },{"124":124,"152":152,"165":165}],127:[function(_dereq_,module,exports){
  21873. var baseGet = _dereq_(120),
  21874. baseIsEqual = _dereq_(122),
  21875. baseSlice = _dereq_(133),
  21876. isArray = _dereq_(168),
  21877. isKey = _dereq_(158),
  21878. isStrictComparable = _dereq_(161),
  21879. last = _dereq_(82),
  21880. toObject = _dereq_(165),
  21881. toPath = _dereq_(166);
  21882. /**
  21883. * The base implementation of `_.matchesProperty` which does not clone `srcValue`.
  21884. *
  21885. * @private
  21886. * @param {string} path The path of the property to get.
  21887. * @param {*} srcValue The value to compare.
  21888. * @returns {Function} Returns the new function.
  21889. */
  21890. function baseMatchesProperty(path, srcValue) {
  21891. var isArr = isArray(path),
  21892. isCommon = isKey(path) && isStrictComparable(srcValue),
  21893. pathKey = (path + '');
  21894. path = toPath(path);
  21895. return function(object) {
  21896. if (object == null) {
  21897. return false;
  21898. }
  21899. var key = pathKey;
  21900. object = toObject(object);
  21901. if ((isArr || !isCommon) && !(key in object)) {
  21902. object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  21903. if (object == null) {
  21904. return false;
  21905. }
  21906. key = last(path);
  21907. object = toObject(object);
  21908. }
  21909. return object[key] === srcValue
  21910. ? (srcValue !== undefined || (key in object))
  21911. : baseIsEqual(srcValue, object[key], undefined, true);
  21912. };
  21913. }
  21914. module.exports = baseMatchesProperty;
  21915. },{"120":120,"122":122,"133":133,"158":158,"161":161,"165":165,"166":166,"168":168,"82":82}],128:[function(_dereq_,module,exports){
  21916. var arrayEach = _dereq_(98),
  21917. baseMergeDeep = _dereq_(129),
  21918. isArray = _dereq_(168),
  21919. isArrayLike = _dereq_(155),
  21920. isObject = _dereq_(172),
  21921. isObjectLike = _dereq_(160),
  21922. isTypedArray = _dereq_(175),
  21923. keys = _dereq_(178);
  21924. /**
  21925. * The base implementation of `_.merge` without support for argument juggling,
  21926. * multiple sources, and `this` binding `customizer` functions.
  21927. *
  21928. * @private
  21929. * @param {Object} object The destination object.
  21930. * @param {Object} source The source object.
  21931. * @param {Function} [customizer] The function to customize merged values.
  21932. * @param {Array} [stackA=[]] Tracks traversed source objects.
  21933. * @param {Array} [stackB=[]] Associates values with source counterparts.
  21934. * @returns {Object} Returns `object`.
  21935. */
  21936. function baseMerge(object, source, customizer, stackA, stackB) {
  21937. if (!isObject(object)) {
  21938. return object;
  21939. }
  21940. var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),
  21941. props = isSrcArr ? undefined : keys(source);
  21942. arrayEach(props || source, function(srcValue, key) {
  21943. if (props) {
  21944. key = srcValue;
  21945. srcValue = source[key];
  21946. }
  21947. if (isObjectLike(srcValue)) {
  21948. stackA || (stackA = []);
  21949. stackB || (stackB = []);
  21950. baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
  21951. }
  21952. else {
  21953. var value = object[key],
  21954. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  21955. isCommon = result === undefined;
  21956. if (isCommon) {
  21957. result = srcValue;
  21958. }
  21959. if ((result !== undefined || (isSrcArr && !(key in object))) &&
  21960. (isCommon || (result === result ? (result !== value) : (value === value)))) {
  21961. object[key] = result;
  21962. }
  21963. }
  21964. });
  21965. return object;
  21966. }
  21967. module.exports = baseMerge;
  21968. },{"129":129,"155":155,"160":160,"168":168,"172":172,"175":175,"178":178,"98":98}],129:[function(_dereq_,module,exports){
  21969. var arrayCopy = _dereq_(97),
  21970. isArguments = _dereq_(167),
  21971. isArray = _dereq_(168),
  21972. isArrayLike = _dereq_(155),
  21973. isPlainObject = _dereq_(173),
  21974. isTypedArray = _dereq_(175),
  21975. toPlainObject = _dereq_(176);
  21976. /**
  21977. * A specialized version of `baseMerge` for arrays and objects which performs
  21978. * deep merges and tracks traversed objects enabling objects with circular
  21979. * references to be merged.
  21980. *
  21981. * @private
  21982. * @param {Object} object The destination object.
  21983. * @param {Object} source The source object.
  21984. * @param {string} key The key of the value to merge.
  21985. * @param {Function} mergeFunc The function to merge values.
  21986. * @param {Function} [customizer] The function to customize merged values.
  21987. * @param {Array} [stackA=[]] Tracks traversed source objects.
  21988. * @param {Array} [stackB=[]] Associates values with source counterparts.
  21989. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  21990. */
  21991. function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
  21992. var length = stackA.length,
  21993. srcValue = source[key];
  21994. while (length--) {
  21995. if (stackA[length] == srcValue) {
  21996. object[key] = stackB[length];
  21997. return;
  21998. }
  21999. }
  22000. var value = object[key],
  22001. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  22002. isCommon = result === undefined;
  22003. if (isCommon) {
  22004. result = srcValue;
  22005. if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {
  22006. result = isArray(value)
  22007. ? value
  22008. : (isArrayLike(value) ? arrayCopy(value) : []);
  22009. }
  22010. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  22011. result = isArguments(value)
  22012. ? toPlainObject(value)
  22013. : (isPlainObject(value) ? value : {});
  22014. }
  22015. else {
  22016. isCommon = false;
  22017. }
  22018. }
  22019. // Add the source value to the stack of traversed objects and associate
  22020. // it with its merged value.
  22021. stackA.push(srcValue);
  22022. stackB.push(result);
  22023. if (isCommon) {
  22024. // Recursively merge objects and arrays (susceptible to call stack limits).
  22025. object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
  22026. } else if (result === result ? (result !== value) : (value === value)) {
  22027. object[key] = result;
  22028. }
  22029. }
  22030. module.exports = baseMergeDeep;
  22031. },{"155":155,"167":167,"168":168,"173":173,"175":175,"176":176,"97":97}],130:[function(_dereq_,module,exports){
  22032. /**
  22033. * The base implementation of `_.property` without support for deep paths.
  22034. *
  22035. * @private
  22036. * @param {string} key The key of the property to get.
  22037. * @returns {Function} Returns the new function.
  22038. */
  22039. function baseProperty(key) {
  22040. return function(object) {
  22041. return object == null ? undefined : object[key];
  22042. };
  22043. }
  22044. module.exports = baseProperty;
  22045. },{}],131:[function(_dereq_,module,exports){
  22046. var baseGet = _dereq_(120),
  22047. toPath = _dereq_(166);
  22048. /**
  22049. * A specialized version of `baseProperty` which supports deep paths.
  22050. *
  22051. * @private
  22052. * @param {Array|string} path The path of the property to get.
  22053. * @returns {Function} Returns the new function.
  22054. */
  22055. function basePropertyDeep(path) {
  22056. var pathKey = (path + '');
  22057. path = toPath(path);
  22058. return function(object) {
  22059. return baseGet(object, path, pathKey);
  22060. };
  22061. }
  22062. module.exports = basePropertyDeep;
  22063. },{"120":120,"166":166}],132:[function(_dereq_,module,exports){
  22064. /**
  22065. * The base implementation of `_.reduce` and `_.reduceRight` without support
  22066. * for callback shorthands and `this` binding, which iterates over `collection`
  22067. * using the provided `eachFunc`.
  22068. *
  22069. * @private
  22070. * @param {Array|Object|string} collection The collection to iterate over.
  22071. * @param {Function} iteratee The function invoked per iteration.
  22072. * @param {*} accumulator The initial value.
  22073. * @param {boolean} initFromCollection Specify using the first or last element
  22074. * of `collection` as the initial value.
  22075. * @param {Function} eachFunc The function to iterate over `collection`.
  22076. * @returns {*} Returns the accumulated value.
  22077. */
  22078. function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) {
  22079. eachFunc(collection, function(value, index, collection) {
  22080. accumulator = initFromCollection
  22081. ? (initFromCollection = false, value)
  22082. : iteratee(accumulator, value, index, collection);
  22083. });
  22084. return accumulator;
  22085. }
  22086. module.exports = baseReduce;
  22087. },{}],133:[function(_dereq_,module,exports){
  22088. /**
  22089. * The base implementation of `_.slice` without an iteratee call guard.
  22090. *
  22091. * @private
  22092. * @param {Array} array The array to slice.
  22093. * @param {number} [start=0] The start position.
  22094. * @param {number} [end=array.length] The end position.
  22095. * @returns {Array} Returns the slice of `array`.
  22096. */
  22097. function baseSlice(array, start, end) {
  22098. var index = -1,
  22099. length = array.length;
  22100. start = start == null ? 0 : (+start || 0);
  22101. if (start < 0) {
  22102. start = -start > length ? 0 : (length + start);
  22103. }
  22104. end = (end === undefined || end > length) ? length : (+end || 0);
  22105. if (end < 0) {
  22106. end += length;
  22107. }
  22108. length = start > end ? 0 : ((end - start) >>> 0);
  22109. start >>>= 0;
  22110. var result = Array(length);
  22111. while (++index < length) {
  22112. result[index] = array[index + start];
  22113. }
  22114. return result;
  22115. }
  22116. module.exports = baseSlice;
  22117. },{}],134:[function(_dereq_,module,exports){
  22118. var baseEach = _dereq_(111);
  22119. /**
  22120. * The base implementation of `_.some` without support for callback shorthands
  22121. * and `this` binding.
  22122. *
  22123. * @private
  22124. * @param {Array|Object|string} collection The collection to iterate over.
  22125. * @param {Function} predicate The function invoked per iteration.
  22126. * @returns {boolean} Returns `true` if any element passes the predicate check,
  22127. * else `false`.
  22128. */
  22129. function baseSome(collection, predicate) {
  22130. var result;
  22131. baseEach(collection, function(value, index, collection) {
  22132. result = predicate(value, index, collection);
  22133. return !result;
  22134. });
  22135. return !!result;
  22136. }
  22137. module.exports = baseSome;
  22138. },{"111":111}],135:[function(_dereq_,module,exports){
  22139. /**
  22140. * Converts `value` to a string if it's not one. An empty string is returned
  22141. * for `null` or `undefined` values.
  22142. *
  22143. * @private
  22144. * @param {*} value The value to process.
  22145. * @returns {string} Returns the string.
  22146. */
  22147. function baseToString(value) {
  22148. return value == null ? '' : (value + '');
  22149. }
  22150. module.exports = baseToString;
  22151. },{}],136:[function(_dereq_,module,exports){
  22152. /**
  22153. * The base implementation of `_.values` and `_.valuesIn` which creates an
  22154. * array of `object` property values corresponding to the property names
  22155. * of `props`.
  22156. *
  22157. * @private
  22158. * @param {Object} object The object to query.
  22159. * @param {Array} props The property names to get values for.
  22160. * @returns {Object} Returns the array of property values.
  22161. */
  22162. function baseValues(object, props) {
  22163. var index = -1,
  22164. length = props.length,
  22165. result = Array(length);
  22166. while (++index < length) {
  22167. result[index] = object[props[index]];
  22168. }
  22169. return result;
  22170. }
  22171. module.exports = baseValues;
  22172. },{}],137:[function(_dereq_,module,exports){
  22173. var identity = _dereq_(185);
  22174. /**
  22175. * A specialized version of `baseCallback` which only supports `this` binding
  22176. * and specifying the number of arguments to provide to `func`.
  22177. *
  22178. * @private
  22179. * @param {Function} func The function to bind.
  22180. * @param {*} thisArg The `this` binding of `func`.
  22181. * @param {number} [argCount] The number of arguments to provide to `func`.
  22182. * @returns {Function} Returns the callback.
  22183. */
  22184. function bindCallback(func, thisArg, argCount) {
  22185. if (typeof func != 'function') {
  22186. return identity;
  22187. }
  22188. if (thisArg === undefined) {
  22189. return func;
  22190. }
  22191. switch (argCount) {
  22192. case 1: return function(value) {
  22193. return func.call(thisArg, value);
  22194. };
  22195. case 3: return function(value, index, collection) {
  22196. return func.call(thisArg, value, index, collection);
  22197. };
  22198. case 4: return function(accumulator, value, index, collection) {
  22199. return func.call(thisArg, accumulator, value, index, collection);
  22200. };
  22201. case 5: return function(value, other, key, object, source) {
  22202. return func.call(thisArg, value, other, key, object, source);
  22203. };
  22204. }
  22205. return function() {
  22206. return func.apply(thisArg, arguments);
  22207. };
  22208. }
  22209. module.exports = bindCallback;
  22210. },{"185":185}],138:[function(_dereq_,module,exports){
  22211. var isObject = _dereq_(172);
  22212. /**
  22213. * Checks if `value` is in `cache` mimicking the return signature of
  22214. * `_.indexOf` by returning `0` if the value is found, else `-1`.
  22215. *
  22216. * @private
  22217. * @param {Object} cache The cache to search.
  22218. * @param {*} value The value to search for.
  22219. * @returns {number} Returns `0` if `value` is found, else `-1`.
  22220. */
  22221. function cacheIndexOf(cache, value) {
  22222. var data = cache.data,
  22223. result = (typeof value == 'string' || isObject(value)) ? data.set.has(value) : data.hash[value];
  22224. return result ? 0 : -1;
  22225. }
  22226. module.exports = cacheIndexOf;
  22227. },{"172":172}],139:[function(_dereq_,module,exports){
  22228. var isObject = _dereq_(172);
  22229. /**
  22230. * Adds `value` to the cache.
  22231. *
  22232. * @private
  22233. * @name push
  22234. * @memberOf SetCache
  22235. * @param {*} value The value to cache.
  22236. */
  22237. function cachePush(value) {
  22238. var data = this.data;
  22239. if (typeof value == 'string' || isObject(value)) {
  22240. data.set.add(value);
  22241. } else {
  22242. data.hash[value] = true;
  22243. }
  22244. }
  22245. module.exports = cachePush;
  22246. },{"172":172}],140:[function(_dereq_,module,exports){
  22247. var baseCallback = _dereq_(107),
  22248. baseEach = _dereq_(111),
  22249. isArray = _dereq_(168);
  22250. /**
  22251. * Creates a `_.countBy`, `_.groupBy`, `_.indexBy`, or `_.partition` function.
  22252. *
  22253. * @private
  22254. * @param {Function} setter The function to set keys and values of the accumulator object.
  22255. * @param {Function} [initializer] The function to initialize the accumulator object.
  22256. * @returns {Function} Returns the new aggregator function.
  22257. */
  22258. function createAggregator(setter, initializer) {
  22259. return function(collection, iteratee, thisArg) {
  22260. var result = initializer ? initializer() : {};
  22261. iteratee = baseCallback(iteratee, thisArg, 3);
  22262. if (isArray(collection)) {
  22263. var index = -1,
  22264. length = collection.length;
  22265. while (++index < length) {
  22266. var value = collection[index];
  22267. setter(result, value, iteratee(value, index, collection), collection);
  22268. }
  22269. } else {
  22270. baseEach(collection, function(value, key, collection) {
  22271. setter(result, value, iteratee(value, key, collection), collection);
  22272. });
  22273. }
  22274. return result;
  22275. };
  22276. }
  22277. module.exports = createAggregator;
  22278. },{"107":107,"111":111,"168":168}],141:[function(_dereq_,module,exports){
  22279. var bindCallback = _dereq_(137),
  22280. isIterateeCall = _dereq_(157),
  22281. restParam = _dereq_(95);
  22282. /**
  22283. * Creates a `_.assign`, `_.defaults`, or `_.merge` function.
  22284. *
  22285. * @private
  22286. * @param {Function} assigner The function to assign values.
  22287. * @returns {Function} Returns the new assigner function.
  22288. */
  22289. function createAssigner(assigner) {
  22290. return restParam(function(object, sources) {
  22291. var index = -1,
  22292. length = object == null ? 0 : sources.length,
  22293. customizer = length > 2 ? sources[length - 2] : undefined,
  22294. guard = length > 2 ? sources[2] : undefined,
  22295. thisArg = length > 1 ? sources[length - 1] : undefined;
  22296. if (typeof customizer == 'function') {
  22297. customizer = bindCallback(customizer, thisArg, 5);
  22298. length -= 2;
  22299. } else {
  22300. customizer = typeof thisArg == 'function' ? thisArg : undefined;
  22301. length -= (customizer ? 1 : 0);
  22302. }
  22303. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  22304. customizer = length < 3 ? undefined : customizer;
  22305. length = 1;
  22306. }
  22307. while (++index < length) {
  22308. var source = sources[index];
  22309. if (source) {
  22310. assigner(object, source, customizer);
  22311. }
  22312. }
  22313. return object;
  22314. });
  22315. }
  22316. module.exports = createAssigner;
  22317. },{"137":137,"157":157,"95":95}],142:[function(_dereq_,module,exports){
  22318. var getLength = _dereq_(151),
  22319. isLength = _dereq_(159),
  22320. toObject = _dereq_(165);
  22321. /**
  22322. * Creates a `baseEach` or `baseEachRight` function.
  22323. *
  22324. * @private
  22325. * @param {Function} eachFunc The function to iterate over a collection.
  22326. * @param {boolean} [fromRight] Specify iterating from right to left.
  22327. * @returns {Function} Returns the new base function.
  22328. */
  22329. function createBaseEach(eachFunc, fromRight) {
  22330. return function(collection, iteratee) {
  22331. var length = collection ? getLength(collection) : 0;
  22332. if (!isLength(length)) {
  22333. return eachFunc(collection, iteratee);
  22334. }
  22335. var index = fromRight ? length : -1,
  22336. iterable = toObject(collection);
  22337. while ((fromRight ? index-- : ++index < length)) {
  22338. if (iteratee(iterable[index], index, iterable) === false) {
  22339. break;
  22340. }
  22341. }
  22342. return collection;
  22343. };
  22344. }
  22345. module.exports = createBaseEach;
  22346. },{"151":151,"159":159,"165":165}],143:[function(_dereq_,module,exports){
  22347. var toObject = _dereq_(165);
  22348. /**
  22349. * Creates a base function for `_.forIn` or `_.forInRight`.
  22350. *
  22351. * @private
  22352. * @param {boolean} [fromRight] Specify iterating from right to left.
  22353. * @returns {Function} Returns the new base function.
  22354. */
  22355. function createBaseFor(fromRight) {
  22356. return function(object, iteratee, keysFunc) {
  22357. var iterable = toObject(object),
  22358. props = keysFunc(object),
  22359. length = props.length,
  22360. index = fromRight ? length : -1;
  22361. while ((fromRight ? index-- : ++index < length)) {
  22362. var key = props[index];
  22363. if (iteratee(iterable[key], key, iterable) === false) {
  22364. break;
  22365. }
  22366. }
  22367. return object;
  22368. };
  22369. }
  22370. module.exports = createBaseFor;
  22371. },{"165":165}],144:[function(_dereq_,module,exports){
  22372. (function (global){
  22373. var SetCache = _dereq_(96),
  22374. getNative = _dereq_(153);
  22375. /** Native method references. */
  22376. var Set = getNative(global, 'Set');
  22377. /* Native method references for those with the same name as other `lodash` methods. */
  22378. var nativeCreate = getNative(Object, 'create');
  22379. /**
  22380. * Creates a `Set` cache object to optimize linear searches of large arrays.
  22381. *
  22382. * @private
  22383. * @param {Array} [values] The values to cache.
  22384. * @returns {null|Object} Returns the new cache object if `Set` is supported, else `null`.
  22385. */
  22386. function createCache(values) {
  22387. return (nativeCreate && Set) ? new SetCache(values) : null;
  22388. }
  22389. module.exports = createCache;
  22390. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  22391. //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaW50ZXJuYWwvY3JlYXRlQ2FjaGUuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwiZmlsZSI6ImdlbmVyYXRlZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgU2V0Q2FjaGUgPSByZXF1aXJlKCcuL1NldENhY2hlJyksXG4gICAgZ2V0TmF0aXZlID0gcmVxdWlyZSgnLi9nZXROYXRpdmUnKTtcblxuLyoqIE5hdGl2ZSBtZXRob2QgcmVmZXJlbmNlcy4gKi9cbnZhciBTZXQgPSBnZXROYXRpdmUoZ2xvYmFsLCAnU2V0Jyk7XG5cbi8qIE5hdGl2ZSBtZXRob2QgcmVmZXJlbmNlcyBmb3IgdGhvc2Ugd2l0aCB0aGUgc2FtZSBuYW1lIGFzIG90aGVyIGBsb2Rhc2hgIG1ldGhvZHMuICovXG52YXIgbmF0aXZlQ3JlYXRlID0gZ2V0TmF0aXZlKE9iamVjdCwgJ2NyZWF0ZScpO1xuXG4vKipcbiAqIENyZWF0ZXMgYSBgU2V0YCBjYWNoZSBvYmplY3QgdG8gb3B0aW1pemUgbGluZWFyIHNlYXJjaGVzIG9mIGxhcmdlIGFycmF5cy5cbiAqXG4gKiBAcHJpdmF0ZVxuICogQHBhcmFtIHtBcnJheX0gW3ZhbHVlc10gVGhlIHZhbHVlcyB0byBjYWNoZS5cbiAqIEByZXR1cm5zIHtudWxsfE9iamVjdH0gUmV0dXJucyB0aGUgbmV3IGNhY2hlIG9iamVjdCBpZiBgU2V0YCBpcyBzdXBwb3J0ZWQsIGVsc2UgYG51bGxgLlxuICovXG5mdW5jdGlvbiBjcmVhdGVDYWNoZSh2YWx1ZXMpIHtcbiAgcmV0dXJuIChuYXRpdmVDcmVhdGUgJiYgU2V0KSA/IG5ldyBTZXRDYWNoZSh2YWx1ZXMpIDogbnVsbDtcbn1cblxubW9kdWxlLmV4cG9ydHMgPSBjcmVhdGVDYWNoZTtcbiJdfQ==
  22392. },{"153":153,"96":96}],145:[function(_dereq_,module,exports){
  22393. var baseCallback = _dereq_(107),
  22394. baseFind = _dereq_(114),
  22395. baseFindIndex = _dereq_(115),
  22396. isArray = _dereq_(168);
  22397. /**
  22398. * Creates a `_.find` or `_.findLast` function.
  22399. *
  22400. * @private
  22401. * @param {Function} eachFunc The function to iterate over a collection.
  22402. * @param {boolean} [fromRight] Specify iterating from right to left.
  22403. * @returns {Function} Returns the new find function.
  22404. */
  22405. function createFind(eachFunc, fromRight) {
  22406. return function(collection, predicate, thisArg) {
  22407. predicate = baseCallback(predicate, thisArg, 3);
  22408. if (isArray(collection)) {
  22409. var index = baseFindIndex(collection, predicate, fromRight);
  22410. return index > -1 ? collection[index] : undefined;
  22411. }
  22412. return baseFind(collection, predicate, eachFunc);
  22413. };
  22414. }
  22415. module.exports = createFind;
  22416. },{"107":107,"114":114,"115":115,"168":168}],146:[function(_dereq_,module,exports){
  22417. var bindCallback = _dereq_(137),
  22418. isArray = _dereq_(168);
  22419. /**
  22420. * Creates a function for `_.forEach` or `_.forEachRight`.
  22421. *
  22422. * @private
  22423. * @param {Function} arrayFunc The function to iterate over an array.
  22424. * @param {Function} eachFunc The function to iterate over a collection.
  22425. * @returns {Function} Returns the new each function.
  22426. */
  22427. function createForEach(arrayFunc, eachFunc) {
  22428. return function(collection, iteratee, thisArg) {
  22429. return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
  22430. ? arrayFunc(collection, iteratee)
  22431. : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
  22432. };
  22433. }
  22434. module.exports = createForEach;
  22435. },{"137":137,"168":168}],147:[function(_dereq_,module,exports){
  22436. var baseCallback = _dereq_(107),
  22437. baseReduce = _dereq_(132),
  22438. isArray = _dereq_(168);
  22439. /**
  22440. * Creates a function for `_.reduce` or `_.reduceRight`.
  22441. *
  22442. * @private
  22443. * @param {Function} arrayFunc The function to iterate over an array.
  22444. * @param {Function} eachFunc The function to iterate over a collection.
  22445. * @returns {Function} Returns the new each function.
  22446. */
  22447. function createReduce(arrayFunc, eachFunc) {
  22448. return function(collection, iteratee, accumulator, thisArg) {
  22449. var initFromArray = arguments.length < 3;
  22450. return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
  22451. ? arrayFunc(collection, iteratee, accumulator, initFromArray)
  22452. : baseReduce(collection, baseCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc);
  22453. };
  22454. }
  22455. module.exports = createReduce;
  22456. },{"107":107,"132":132,"168":168}],148:[function(_dereq_,module,exports){
  22457. var arraySome = _dereq_(104);
  22458. /**
  22459. * A specialized version of `baseIsEqualDeep` for arrays with support for
  22460. * partial deep comparisons.
  22461. *
  22462. * @private
  22463. * @param {Array} array The array to compare.
  22464. * @param {Array} other The other array to compare.
  22465. * @param {Function} equalFunc The function to determine equivalents of values.
  22466. * @param {Function} [customizer] The function to customize comparing arrays.
  22467. * @param {boolean} [isLoose] Specify performing partial comparisons.
  22468. * @param {Array} [stackA] Tracks traversed `value` objects.
  22469. * @param {Array} [stackB] Tracks traversed `other` objects.
  22470. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  22471. */
  22472. function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
  22473. var index = -1,
  22474. arrLength = array.length,
  22475. othLength = other.length;
  22476. if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
  22477. return false;
  22478. }
  22479. // Ignore non-index properties.
  22480. while (++index < arrLength) {
  22481. var arrValue = array[index],
  22482. othValue = other[index],
  22483. result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;
  22484. if (result !== undefined) {
  22485. if (result) {
  22486. continue;
  22487. }
  22488. return false;
  22489. }
  22490. // Recursively compare arrays (susceptible to call stack limits).
  22491. if (isLoose) {
  22492. if (!arraySome(other, function(othValue) {
  22493. return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  22494. })) {
  22495. return false;
  22496. }
  22497. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) {
  22498. return false;
  22499. }
  22500. }
  22501. return true;
  22502. }
  22503. module.exports = equalArrays;
  22504. },{"104":104}],149:[function(_dereq_,module,exports){
  22505. /** `Object#toString` result references. */
  22506. var boolTag = '[object Boolean]',
  22507. dateTag = '[object Date]',
  22508. errorTag = '[object Error]',
  22509. numberTag = '[object Number]',
  22510. regexpTag = '[object RegExp]',
  22511. stringTag = '[object String]';
  22512. /**
  22513. * A specialized version of `baseIsEqualDeep` for comparing objects of
  22514. * the same `toStringTag`.
  22515. *
  22516. * **Note:** This function only supports comparing values with tags of
  22517. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  22518. *
  22519. * @private
  22520. * @param {Object} object The object to compare.
  22521. * @param {Object} other The other object to compare.
  22522. * @param {string} tag The `toStringTag` of the objects to compare.
  22523. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22524. */
  22525. function equalByTag(object, other, tag) {
  22526. switch (tag) {
  22527. case boolTag:
  22528. case dateTag:
  22529. // Coerce dates and booleans to numbers, dates to milliseconds and booleans
  22530. // to `1` or `0` treating invalid dates coerced to `NaN` as not equal.
  22531. return +object == +other;
  22532. case errorTag:
  22533. return object.name == other.name && object.message == other.message;
  22534. case numberTag:
  22535. // Treat `NaN` vs. `NaN` as equal.
  22536. return (object != +object)
  22537. ? other != +other
  22538. : object == +other;
  22539. case regexpTag:
  22540. case stringTag:
  22541. // Coerce regexes to strings and treat strings primitives and string
  22542. // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
  22543. return object == (other + '');
  22544. }
  22545. return false;
  22546. }
  22547. module.exports = equalByTag;
  22548. },{}],150:[function(_dereq_,module,exports){
  22549. var keys = _dereq_(178);
  22550. /** Used for native method references. */
  22551. var objectProto = Object.prototype;
  22552. /** Used to check objects for own properties. */
  22553. var hasOwnProperty = objectProto.hasOwnProperty;
  22554. /**
  22555. * A specialized version of `baseIsEqualDeep` for objects with support for
  22556. * partial deep comparisons.
  22557. *
  22558. * @private
  22559. * @param {Object} object The object to compare.
  22560. * @param {Object} other The other object to compare.
  22561. * @param {Function} equalFunc The function to determine equivalents of values.
  22562. * @param {Function} [customizer] The function to customize comparing values.
  22563. * @param {boolean} [isLoose] Specify performing partial comparisons.
  22564. * @param {Array} [stackA] Tracks traversed `value` objects.
  22565. * @param {Array} [stackB] Tracks traversed `other` objects.
  22566. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22567. */
  22568. function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  22569. var objProps = keys(object),
  22570. objLength = objProps.length,
  22571. othProps = keys(other),
  22572. othLength = othProps.length;
  22573. if (objLength != othLength && !isLoose) {
  22574. return false;
  22575. }
  22576. var index = objLength;
  22577. while (index--) {
  22578. var key = objProps[index];
  22579. if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {
  22580. return false;
  22581. }
  22582. }
  22583. var skipCtor = isLoose;
  22584. while (++index < objLength) {
  22585. key = objProps[index];
  22586. var objValue = object[key],
  22587. othValue = other[key],
  22588. result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined;
  22589. // Recursively compare objects (susceptible to call stack limits).
  22590. if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) {
  22591. return false;
  22592. }
  22593. skipCtor || (skipCtor = key == 'constructor');
  22594. }
  22595. if (!skipCtor) {
  22596. var objCtor = object.constructor,
  22597. othCtor = other.constructor;
  22598. // Non `Object` object instances with different constructors are not equal.
  22599. if (objCtor != othCtor &&
  22600. ('constructor' in object && 'constructor' in other) &&
  22601. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  22602. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  22603. return false;
  22604. }
  22605. }
  22606. return true;
  22607. }
  22608. module.exports = equalObjects;
  22609. },{"178":178}],151:[function(_dereq_,module,exports){
  22610. var baseProperty = _dereq_(130);
  22611. /**
  22612. * Gets the "length" property value of `object`.
  22613. *
  22614. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  22615. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  22616. *
  22617. * @private
  22618. * @param {Object} object The object to query.
  22619. * @returns {*} Returns the "length" value.
  22620. */
  22621. var getLength = baseProperty('length');
  22622. module.exports = getLength;
  22623. },{"130":130}],152:[function(_dereq_,module,exports){
  22624. var isStrictComparable = _dereq_(161),
  22625. pairs = _dereq_(182);
  22626. /**
  22627. * Gets the propery names, values, and compare flags of `object`.
  22628. *
  22629. * @private
  22630. * @param {Object} object The object to query.
  22631. * @returns {Array} Returns the match data of `object`.
  22632. */
  22633. function getMatchData(object) {
  22634. var result = pairs(object),
  22635. length = result.length;
  22636. while (length--) {
  22637. result[length][2] = isStrictComparable(result[length][1]);
  22638. }
  22639. return result;
  22640. }
  22641. module.exports = getMatchData;
  22642. },{"161":161,"182":182}],153:[function(_dereq_,module,exports){
  22643. var isNative = _dereq_(170);
  22644. /**
  22645. * Gets the native function at `key` of `object`.
  22646. *
  22647. * @private
  22648. * @param {Object} object The object to query.
  22649. * @param {string} key The key of the method to get.
  22650. * @returns {*} Returns the function if it's native, else `undefined`.
  22651. */
  22652. function getNative(object, key) {
  22653. var value = object == null ? undefined : object[key];
  22654. return isNative(value) ? value : undefined;
  22655. }
  22656. module.exports = getNative;
  22657. },{"170":170}],154:[function(_dereq_,module,exports){
  22658. /**
  22659. * Gets the index at which the first occurrence of `NaN` is found in `array`.
  22660. *
  22661. * @private
  22662. * @param {Array} array The array to search.
  22663. * @param {number} fromIndex The index to search from.
  22664. * @param {boolean} [fromRight] Specify iterating from right to left.
  22665. * @returns {number} Returns the index of the matched `NaN`, else `-1`.
  22666. */
  22667. function indexOfNaN(array, fromIndex, fromRight) {
  22668. var length = array.length,
  22669. index = fromIndex + (fromRight ? 0 : -1);
  22670. while ((fromRight ? index-- : ++index < length)) {
  22671. var other = array[index];
  22672. if (other !== other) {
  22673. return index;
  22674. }
  22675. }
  22676. return -1;
  22677. }
  22678. module.exports = indexOfNaN;
  22679. },{}],155:[function(_dereq_,module,exports){
  22680. var getLength = _dereq_(151),
  22681. isLength = _dereq_(159);
  22682. /**
  22683. * Checks if `value` is array-like.
  22684. *
  22685. * @private
  22686. * @param {*} value The value to check.
  22687. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  22688. */
  22689. function isArrayLike(value) {
  22690. return value != null && isLength(getLength(value));
  22691. }
  22692. module.exports = isArrayLike;
  22693. },{"151":151,"159":159}],156:[function(_dereq_,module,exports){
  22694. /** Used to detect unsigned integer values. */
  22695. var reIsUint = /^\d+$/;
  22696. /**
  22697. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  22698. * of an array-like value.
  22699. */
  22700. var MAX_SAFE_INTEGER = 9007199254740991;
  22701. /**
  22702. * Checks if `value` is a valid array-like index.
  22703. *
  22704. * @private
  22705. * @param {*} value The value to check.
  22706. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  22707. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  22708. */
  22709. function isIndex(value, length) {
  22710. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  22711. length = length == null ? MAX_SAFE_INTEGER : length;
  22712. return value > -1 && value % 1 == 0 && value < length;
  22713. }
  22714. module.exports = isIndex;
  22715. },{}],157:[function(_dereq_,module,exports){
  22716. var isArrayLike = _dereq_(155),
  22717. isIndex = _dereq_(156),
  22718. isObject = _dereq_(172);
  22719. /**
  22720. * Checks if the provided arguments are from an iteratee call.
  22721. *
  22722. * @private
  22723. * @param {*} value The potential iteratee value argument.
  22724. * @param {*} index The potential iteratee index or key argument.
  22725. * @param {*} object The potential iteratee object argument.
  22726. * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
  22727. */
  22728. function isIterateeCall(value, index, object) {
  22729. if (!isObject(object)) {
  22730. return false;
  22731. }
  22732. var type = typeof index;
  22733. if (type == 'number'
  22734. ? (isArrayLike(object) && isIndex(index, object.length))
  22735. : (type == 'string' && index in object)) {
  22736. var other = object[index];
  22737. return value === value ? (value === other) : (other !== other);
  22738. }
  22739. return false;
  22740. }
  22741. module.exports = isIterateeCall;
  22742. },{"155":155,"156":156,"172":172}],158:[function(_dereq_,module,exports){
  22743. var isArray = _dereq_(168),
  22744. toObject = _dereq_(165);
  22745. /** Used to match property names within property paths. */
  22746. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,
  22747. reIsPlainProp = /^\w*$/;
  22748. /**
  22749. * Checks if `value` is a property name and not a property path.
  22750. *
  22751. * @private
  22752. * @param {*} value The value to check.
  22753. * @param {Object} [object] The object to query keys on.
  22754. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  22755. */
  22756. function isKey(value, object) {
  22757. var type = typeof value;
  22758. if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {
  22759. return true;
  22760. }
  22761. if (isArray(value)) {
  22762. return false;
  22763. }
  22764. var result = !reIsDeepProp.test(value);
  22765. return result || (object != null && value in toObject(object));
  22766. }
  22767. module.exports = isKey;
  22768. },{"165":165,"168":168}],159:[function(_dereq_,module,exports){
  22769. /**
  22770. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  22771. * of an array-like value.
  22772. */
  22773. var MAX_SAFE_INTEGER = 9007199254740991;
  22774. /**
  22775. * Checks if `value` is a valid array-like length.
  22776. *
  22777. * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  22778. *
  22779. * @private
  22780. * @param {*} value The value to check.
  22781. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  22782. */
  22783. function isLength(value) {
  22784. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  22785. }
  22786. module.exports = isLength;
  22787. },{}],160:[function(_dereq_,module,exports){
  22788. /**
  22789. * Checks if `value` is object-like.
  22790. *
  22791. * @private
  22792. * @param {*} value The value to check.
  22793. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  22794. */
  22795. function isObjectLike(value) {
  22796. return !!value && typeof value == 'object';
  22797. }
  22798. module.exports = isObjectLike;
  22799. },{}],161:[function(_dereq_,module,exports){
  22800. var isObject = _dereq_(172);
  22801. /**
  22802. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  22803. *
  22804. * @private
  22805. * @param {*} value The value to check.
  22806. * @returns {boolean} Returns `true` if `value` if suitable for strict
  22807. * equality comparisons, else `false`.
  22808. */
  22809. function isStrictComparable(value) {
  22810. return value === value && !isObject(value);
  22811. }
  22812. module.exports = isStrictComparable;
  22813. },{"172":172}],162:[function(_dereq_,module,exports){
  22814. var toObject = _dereq_(165);
  22815. /**
  22816. * A specialized version of `_.pick` which picks `object` properties specified
  22817. * by `props`.
  22818. *
  22819. * @private
  22820. * @param {Object} object The source object.
  22821. * @param {string[]} props The property names to pick.
  22822. * @returns {Object} Returns the new object.
  22823. */
  22824. function pickByArray(object, props) {
  22825. object = toObject(object);
  22826. var index = -1,
  22827. length = props.length,
  22828. result = {};
  22829. while (++index < length) {
  22830. var key = props[index];
  22831. if (key in object) {
  22832. result[key] = object[key];
  22833. }
  22834. }
  22835. return result;
  22836. }
  22837. module.exports = pickByArray;
  22838. },{"165":165}],163:[function(_dereq_,module,exports){
  22839. var baseForIn = _dereq_(118);
  22840. /**
  22841. * A specialized version of `_.pick` which picks `object` properties `predicate`
  22842. * returns truthy for.
  22843. *
  22844. * @private
  22845. * @param {Object} object The source object.
  22846. * @param {Function} predicate The function invoked per iteration.
  22847. * @returns {Object} Returns the new object.
  22848. */
  22849. function pickByCallback(object, predicate) {
  22850. var result = {};
  22851. baseForIn(object, function(value, key, object) {
  22852. if (predicate(value, key, object)) {
  22853. result[key] = value;
  22854. }
  22855. });
  22856. return result;
  22857. }
  22858. module.exports = pickByCallback;
  22859. },{"118":118}],164:[function(_dereq_,module,exports){
  22860. var isArguments = _dereq_(167),
  22861. isArray = _dereq_(168),
  22862. isIndex = _dereq_(156),
  22863. isLength = _dereq_(159),
  22864. keysIn = _dereq_(179);
  22865. /** Used for native method references. */
  22866. var objectProto = Object.prototype;
  22867. /** Used to check objects for own properties. */
  22868. var hasOwnProperty = objectProto.hasOwnProperty;
  22869. /**
  22870. * A fallback implementation of `Object.keys` which creates an array of the
  22871. * own enumerable property names of `object`.
  22872. *
  22873. * @private
  22874. * @param {Object} object The object to query.
  22875. * @returns {Array} Returns the array of property names.
  22876. */
  22877. function shimKeys(object) {
  22878. var props = keysIn(object),
  22879. propsLength = props.length,
  22880. length = propsLength && object.length;
  22881. var allowIndexes = !!length && isLength(length) &&
  22882. (isArray(object) || isArguments(object));
  22883. var index = -1,
  22884. result = [];
  22885. while (++index < propsLength) {
  22886. var key = props[index];
  22887. if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
  22888. result.push(key);
  22889. }
  22890. }
  22891. return result;
  22892. }
  22893. module.exports = shimKeys;
  22894. },{"156":156,"159":159,"167":167,"168":168,"179":179}],165:[function(_dereq_,module,exports){
  22895. var isObject = _dereq_(172);
  22896. /**
  22897. * Converts `value` to an object if it's not one.
  22898. *
  22899. * @private
  22900. * @param {*} value The value to process.
  22901. * @returns {Object} Returns the object.
  22902. */
  22903. function toObject(value) {
  22904. return isObject(value) ? value : Object(value);
  22905. }
  22906. module.exports = toObject;
  22907. },{"172":172}],166:[function(_dereq_,module,exports){
  22908. var baseToString = _dereq_(135),
  22909. isArray = _dereq_(168);
  22910. /** Used to match property names within property paths. */
  22911. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
  22912. /** Used to match backslashes in property paths. */
  22913. var reEscapeChar = /\\(\\)?/g;
  22914. /**
  22915. * Converts `value` to property path array if it's not one.
  22916. *
  22917. * @private
  22918. * @param {*} value The value to process.
  22919. * @returns {Array} Returns the property path array.
  22920. */
  22921. function toPath(value) {
  22922. if (isArray(value)) {
  22923. return value;
  22924. }
  22925. var result = [];
  22926. baseToString(value).replace(rePropName, function(match, number, quote, string) {
  22927. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  22928. });
  22929. return result;
  22930. }
  22931. module.exports = toPath;
  22932. },{"135":135,"168":168}],167:[function(_dereq_,module,exports){
  22933. var isArrayLike = _dereq_(155),
  22934. isObjectLike = _dereq_(160);
  22935. /** Used for native method references. */
  22936. var objectProto = Object.prototype;
  22937. /** Used to check objects for own properties. */
  22938. var hasOwnProperty = objectProto.hasOwnProperty;
  22939. /** Native method references. */
  22940. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  22941. /**
  22942. * Checks if `value` is classified as an `arguments` object.
  22943. *
  22944. * @static
  22945. * @memberOf _
  22946. * @category Lang
  22947. * @param {*} value The value to check.
  22948. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  22949. * @example
  22950. *
  22951. * _.isArguments(function() { return arguments; }());
  22952. * // => true
  22953. *
  22954. * _.isArguments([1, 2, 3]);
  22955. * // => false
  22956. */
  22957. function isArguments(value) {
  22958. return isObjectLike(value) && isArrayLike(value) &&
  22959. hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
  22960. }
  22961. module.exports = isArguments;
  22962. },{"155":155,"160":160}],168:[function(_dereq_,module,exports){
  22963. var getNative = _dereq_(153),
  22964. isLength = _dereq_(159),
  22965. isObjectLike = _dereq_(160);
  22966. /** `Object#toString` result references. */
  22967. var arrayTag = '[object Array]';
  22968. /** Used for native method references. */
  22969. var objectProto = Object.prototype;
  22970. /**
  22971. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  22972. * of values.
  22973. */
  22974. var objToString = objectProto.toString;
  22975. /* Native method references for those with the same name as other `lodash` methods. */
  22976. var nativeIsArray = getNative(Array, 'isArray');
  22977. /**
  22978. * Checks if `value` is classified as an `Array` object.
  22979. *
  22980. * @static
  22981. * @memberOf _
  22982. * @category Lang
  22983. * @param {*} value The value to check.
  22984. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  22985. * @example
  22986. *
  22987. * _.isArray([1, 2, 3]);
  22988. * // => true
  22989. *
  22990. * _.isArray(function() { return arguments; }());
  22991. * // => false
  22992. */
  22993. var isArray = nativeIsArray || function(value) {
  22994. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
  22995. };
  22996. module.exports = isArray;
  22997. },{"153":153,"159":159,"160":160}],169:[function(_dereq_,module,exports){
  22998. var isObject = _dereq_(172);
  22999. /** `Object#toString` result references. */
  23000. var funcTag = '[object Function]';
  23001. /** Used for native method references. */
  23002. var objectProto = Object.prototype;
  23003. /**
  23004. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  23005. * of values.
  23006. */
  23007. var objToString = objectProto.toString;
  23008. /**
  23009. * Checks if `value` is classified as a `Function` object.
  23010. *
  23011. * @static
  23012. * @memberOf _
  23013. * @category Lang
  23014. * @param {*} value The value to check.
  23015. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  23016. * @example
  23017. *
  23018. * _.isFunction(_);
  23019. * // => true
  23020. *
  23021. * _.isFunction(/abc/);
  23022. * // => false
  23023. */
  23024. function isFunction(value) {
  23025. // The use of `Object#toString` avoids issues with the `typeof` operator
  23026. // in older versions of Chrome and Safari which return 'function' for regexes
  23027. // and Safari 8 which returns 'object' for typed array constructors.
  23028. return isObject(value) && objToString.call(value) == funcTag;
  23029. }
  23030. module.exports = isFunction;
  23031. },{"172":172}],170:[function(_dereq_,module,exports){
  23032. var isFunction = _dereq_(169),
  23033. isObjectLike = _dereq_(160);
  23034. /** Used to detect host constructors (Safari > 5). */
  23035. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  23036. /** Used for native method references. */
  23037. var objectProto = Object.prototype;
  23038. /** Used to resolve the decompiled source of functions. */
  23039. var fnToString = Function.prototype.toString;
  23040. /** Used to check objects for own properties. */
  23041. var hasOwnProperty = objectProto.hasOwnProperty;
  23042. /** Used to detect if a method is native. */
  23043. var reIsNative = RegExp('^' +
  23044. fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
  23045. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  23046. );
  23047. /**
  23048. * Checks if `value` is a native function.
  23049. *
  23050. * @static
  23051. * @memberOf _
  23052. * @category Lang
  23053. * @param {*} value The value to check.
  23054. * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
  23055. * @example
  23056. *
  23057. * _.isNative(Array.prototype.push);
  23058. * // => true
  23059. *
  23060. * _.isNative(_);
  23061. * // => false
  23062. */
  23063. function isNative(value) {
  23064. if (value == null) {
  23065. return false;
  23066. }
  23067. if (isFunction(value)) {
  23068. return reIsNative.test(fnToString.call(value));
  23069. }
  23070. return isObjectLike(value) && reIsHostCtor.test(value);
  23071. }
  23072. module.exports = isNative;
  23073. },{"160":160,"169":169}],171:[function(_dereq_,module,exports){
  23074. var isObjectLike = _dereq_(160);
  23075. /** `Object#toString` result references. */
  23076. var numberTag = '[object Number]';
  23077. /** Used for native method references. */
  23078. var objectProto = Object.prototype;
  23079. /**
  23080. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  23081. * of values.
  23082. */
  23083. var objToString = objectProto.toString;
  23084. /**
  23085. * Checks if `value` is classified as a `Number` primitive or object.
  23086. *
  23087. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified
  23088. * as numbers, use the `_.isFinite` method.
  23089. *
  23090. * @static
  23091. * @memberOf _
  23092. * @category Lang
  23093. * @param {*} value The value to check.
  23094. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  23095. * @example
  23096. *
  23097. * _.isNumber(8.4);
  23098. * // => true
  23099. *
  23100. * _.isNumber(NaN);
  23101. * // => true
  23102. *
  23103. * _.isNumber('8.4');
  23104. * // => false
  23105. */
  23106. function isNumber(value) {
  23107. return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);
  23108. }
  23109. module.exports = isNumber;
  23110. },{"160":160}],172:[function(_dereq_,module,exports){
  23111. /**
  23112. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  23113. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  23114. *
  23115. * @static
  23116. * @memberOf _
  23117. * @category Lang
  23118. * @param {*} value The value to check.
  23119. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  23120. * @example
  23121. *
  23122. * _.isObject({});
  23123. * // => true
  23124. *
  23125. * _.isObject([1, 2, 3]);
  23126. * // => true
  23127. *
  23128. * _.isObject(1);
  23129. * // => false
  23130. */
  23131. function isObject(value) {
  23132. // Avoid a V8 JIT bug in Chrome 19-20.
  23133. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  23134. var type = typeof value;
  23135. return !!value && (type == 'object' || type == 'function');
  23136. }
  23137. module.exports = isObject;
  23138. },{}],173:[function(_dereq_,module,exports){
  23139. var baseForIn = _dereq_(118),
  23140. isArguments = _dereq_(167),
  23141. isObjectLike = _dereq_(160);
  23142. /** `Object#toString` result references. */
  23143. var objectTag = '[object Object]';
  23144. /** Used for native method references. */
  23145. var objectProto = Object.prototype;
  23146. /** Used to check objects for own properties. */
  23147. var hasOwnProperty = objectProto.hasOwnProperty;
  23148. /**
  23149. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  23150. * of values.
  23151. */
  23152. var objToString = objectProto.toString;
  23153. /**
  23154. * Checks if `value` is a plain object, that is, an object created by the
  23155. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  23156. *
  23157. * **Note:** This method assumes objects created by the `Object` constructor
  23158. * have no inherited enumerable properties.
  23159. *
  23160. * @static
  23161. * @memberOf _
  23162. * @category Lang
  23163. * @param {*} value The value to check.
  23164. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  23165. * @example
  23166. *
  23167. * function Foo() {
  23168. * this.a = 1;
  23169. * }
  23170. *
  23171. * _.isPlainObject(new Foo);
  23172. * // => false
  23173. *
  23174. * _.isPlainObject([1, 2, 3]);
  23175. * // => false
  23176. *
  23177. * _.isPlainObject({ 'x': 0, 'y': 0 });
  23178. * // => true
  23179. *
  23180. * _.isPlainObject(Object.create(null));
  23181. * // => true
  23182. */
  23183. function isPlainObject(value) {
  23184. var Ctor;
  23185. // Exit early for non `Object` objects.
  23186. if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) ||
  23187. (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
  23188. return false;
  23189. }
  23190. // IE < 9 iterates inherited properties before own properties. If the first
  23191. // iterated property is an object's own property then there are no inherited
  23192. // enumerable properties.
  23193. var result;
  23194. // In most environments an object's own properties are iterated before
  23195. // its inherited properties. If the last iterated property is an object's
  23196. // own property then there are no inherited enumerable properties.
  23197. baseForIn(value, function(subValue, key) {
  23198. result = key;
  23199. });
  23200. return result === undefined || hasOwnProperty.call(value, result);
  23201. }
  23202. module.exports = isPlainObject;
  23203. },{"118":118,"160":160,"167":167}],174:[function(_dereq_,module,exports){
  23204. var isObjectLike = _dereq_(160);
  23205. /** `Object#toString` result references. */
  23206. var stringTag = '[object String]';
  23207. /** Used for native method references. */
  23208. var objectProto = Object.prototype;
  23209. /**
  23210. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  23211. * of values.
  23212. */
  23213. var objToString = objectProto.toString;
  23214. /**
  23215. * Checks if `value` is classified as a `String` primitive or object.
  23216. *
  23217. * @static
  23218. * @memberOf _
  23219. * @category Lang
  23220. * @param {*} value The value to check.
  23221. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  23222. * @example
  23223. *
  23224. * _.isString('abc');
  23225. * // => true
  23226. *
  23227. * _.isString(1);
  23228. * // => false
  23229. */
  23230. function isString(value) {
  23231. return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
  23232. }
  23233. module.exports = isString;
  23234. },{"160":160}],175:[function(_dereq_,module,exports){
  23235. var isLength = _dereq_(159),
  23236. isObjectLike = _dereq_(160);
  23237. /** `Object#toString` result references. */
  23238. var argsTag = '[object Arguments]',
  23239. arrayTag = '[object Array]',
  23240. boolTag = '[object Boolean]',
  23241. dateTag = '[object Date]',
  23242. errorTag = '[object Error]',
  23243. funcTag = '[object Function]',
  23244. mapTag = '[object Map]',
  23245. numberTag = '[object Number]',
  23246. objectTag = '[object Object]',
  23247. regexpTag = '[object RegExp]',
  23248. setTag = '[object Set]',
  23249. stringTag = '[object String]',
  23250. weakMapTag = '[object WeakMap]';
  23251. var arrayBufferTag = '[object ArrayBuffer]',
  23252. float32Tag = '[object Float32Array]',
  23253. float64Tag = '[object Float64Array]',
  23254. int8Tag = '[object Int8Array]',
  23255. int16Tag = '[object Int16Array]',
  23256. int32Tag = '[object Int32Array]',
  23257. uint8Tag = '[object Uint8Array]',
  23258. uint8ClampedTag = '[object Uint8ClampedArray]',
  23259. uint16Tag = '[object Uint16Array]',
  23260. uint32Tag = '[object Uint32Array]';
  23261. /** Used to identify `toStringTag` values of typed arrays. */
  23262. var typedArrayTags = {};
  23263. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  23264. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  23265. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  23266. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  23267. typedArrayTags[uint32Tag] = true;
  23268. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  23269. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  23270. typedArrayTags[dateTag] = typedArrayTags[errorTag] =
  23271. typedArrayTags[funcTag] = typedArrayTags[mapTag] =
  23272. typedArrayTags[numberTag] = typedArrayTags[objectTag] =
  23273. typedArrayTags[regexpTag] = typedArrayTags[setTag] =
  23274. typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  23275. /** Used for native method references. */
  23276. var objectProto = Object.prototype;
  23277. /**
  23278. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  23279. * of values.
  23280. */
  23281. var objToString = objectProto.toString;
  23282. /**
  23283. * Checks if `value` is classified as a typed array.
  23284. *
  23285. * @static
  23286. * @memberOf _
  23287. * @category Lang
  23288. * @param {*} value The value to check.
  23289. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  23290. * @example
  23291. *
  23292. * _.isTypedArray(new Uint8Array);
  23293. * // => true
  23294. *
  23295. * _.isTypedArray([]);
  23296. * // => false
  23297. */
  23298. function isTypedArray(value) {
  23299. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
  23300. }
  23301. module.exports = isTypedArray;
  23302. },{"159":159,"160":160}],176:[function(_dereq_,module,exports){
  23303. var baseCopy = _dereq_(108),
  23304. keysIn = _dereq_(179);
  23305. /**
  23306. * Converts `value` to a plain object flattening inherited enumerable
  23307. * properties of `value` to own properties of the plain object.
  23308. *
  23309. * @static
  23310. * @memberOf _
  23311. * @category Lang
  23312. * @param {*} value The value to convert.
  23313. * @returns {Object} Returns the converted plain object.
  23314. * @example
  23315. *
  23316. * function Foo() {
  23317. * this.b = 2;
  23318. * }
  23319. *
  23320. * Foo.prototype.c = 3;
  23321. *
  23322. * _.assign({ 'a': 1 }, new Foo);
  23323. * // => { 'a': 1, 'b': 2 }
  23324. *
  23325. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  23326. * // => { 'a': 1, 'b': 2, 'c': 3 }
  23327. */
  23328. function toPlainObject(value) {
  23329. return baseCopy(value, keysIn(value));
  23330. }
  23331. module.exports = toPlainObject;
  23332. },{"108":108,"179":179}],177:[function(_dereq_,module,exports){
  23333. var assignWith = _dereq_(105),
  23334. baseAssign = _dereq_(106),
  23335. createAssigner = _dereq_(141);
  23336. /**
  23337. * Assigns own enumerable properties of source object(s) to the destination
  23338. * object. Subsequent sources overwrite property assignments of previous sources.
  23339. * If `customizer` is provided it's invoked to produce the assigned values.
  23340. * The `customizer` is bound to `thisArg` and invoked with five arguments:
  23341. * (objectValue, sourceValue, key, object, source).
  23342. *
  23343. * **Note:** This method mutates `object` and is based on
  23344. * [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign).
  23345. *
  23346. * @static
  23347. * @memberOf _
  23348. * @alias extend
  23349. * @category Object
  23350. * @param {Object} object The destination object.
  23351. * @param {...Object} [sources] The source objects.
  23352. * @param {Function} [customizer] The function to customize assigned values.
  23353. * @param {*} [thisArg] The `this` binding of `customizer`.
  23354. * @returns {Object} Returns `object`.
  23355. * @example
  23356. *
  23357. * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' });
  23358. * // => { 'user': 'fred', 'age': 40 }
  23359. *
  23360. * // using a customizer callback
  23361. * var defaults = _.partialRight(_.assign, function(value, other) {
  23362. * return _.isUndefined(value) ? other : value;
  23363. * });
  23364. *
  23365. * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
  23366. * // => { 'user': 'barney', 'age': 36 }
  23367. */
  23368. var assign = createAssigner(function(object, source, customizer) {
  23369. return customizer
  23370. ? assignWith(object, source, customizer)
  23371. : baseAssign(object, source);
  23372. });
  23373. module.exports = assign;
  23374. },{"105":105,"106":106,"141":141}],178:[function(_dereq_,module,exports){
  23375. var getNative = _dereq_(153),
  23376. isArrayLike = _dereq_(155),
  23377. isObject = _dereq_(172),
  23378. shimKeys = _dereq_(164);
  23379. /* Native method references for those with the same name as other `lodash` methods. */
  23380. var nativeKeys = getNative(Object, 'keys');
  23381. /**
  23382. * Creates an array of the own enumerable property names of `object`.
  23383. *
  23384. * **Note:** Non-object values are coerced to objects. See the
  23385. * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
  23386. * for more details.
  23387. *
  23388. * @static
  23389. * @memberOf _
  23390. * @category Object
  23391. * @param {Object} object The object to query.
  23392. * @returns {Array} Returns the array of property names.
  23393. * @example
  23394. *
  23395. * function Foo() {
  23396. * this.a = 1;
  23397. * this.b = 2;
  23398. * }
  23399. *
  23400. * Foo.prototype.c = 3;
  23401. *
  23402. * _.keys(new Foo);
  23403. * // => ['a', 'b'] (iteration order is not guaranteed)
  23404. *
  23405. * _.keys('hi');
  23406. * // => ['0', '1']
  23407. */
  23408. var keys = !nativeKeys ? shimKeys : function(object) {
  23409. var Ctor = object == null ? undefined : object.constructor;
  23410. if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
  23411. (typeof object != 'function' && isArrayLike(object))) {
  23412. return shimKeys(object);
  23413. }
  23414. return isObject(object) ? nativeKeys(object) : [];
  23415. };
  23416. module.exports = keys;
  23417. },{"153":153,"155":155,"164":164,"172":172}],179:[function(_dereq_,module,exports){
  23418. var isArguments = _dereq_(167),
  23419. isArray = _dereq_(168),
  23420. isIndex = _dereq_(156),
  23421. isLength = _dereq_(159),
  23422. isObject = _dereq_(172);
  23423. /** Used for native method references. */
  23424. var objectProto = Object.prototype;
  23425. /** Used to check objects for own properties. */
  23426. var hasOwnProperty = objectProto.hasOwnProperty;
  23427. /**
  23428. * Creates an array of the own and inherited enumerable property names of `object`.
  23429. *
  23430. * **Note:** Non-object values are coerced to objects.
  23431. *
  23432. * @static
  23433. * @memberOf _
  23434. * @category Object
  23435. * @param {Object} object The object to query.
  23436. * @returns {Array} Returns the array of property names.
  23437. * @example
  23438. *
  23439. * function Foo() {
  23440. * this.a = 1;
  23441. * this.b = 2;
  23442. * }
  23443. *
  23444. * Foo.prototype.c = 3;
  23445. *
  23446. * _.keysIn(new Foo);
  23447. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  23448. */
  23449. function keysIn(object) {
  23450. if (object == null) {
  23451. return [];
  23452. }
  23453. if (!isObject(object)) {
  23454. object = Object(object);
  23455. }
  23456. var length = object.length;
  23457. length = (length && isLength(length) &&
  23458. (isArray(object) || isArguments(object)) && length) || 0;
  23459. var Ctor = object.constructor,
  23460. index = -1,
  23461. isProto = typeof Ctor == 'function' && Ctor.prototype === object,
  23462. result = Array(length),
  23463. skipIndexes = length > 0;
  23464. while (++index < length) {
  23465. result[index] = (index + '');
  23466. }
  23467. for (var key in object) {
  23468. if (!(skipIndexes && isIndex(key, length)) &&
  23469. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  23470. result.push(key);
  23471. }
  23472. }
  23473. return result;
  23474. }
  23475. module.exports = keysIn;
  23476. },{"156":156,"159":159,"167":167,"168":168,"172":172}],180:[function(_dereq_,module,exports){
  23477. var baseMerge = _dereq_(128),
  23478. createAssigner = _dereq_(141);
  23479. /**
  23480. * Recursively merges own enumerable properties of the source object(s), that
  23481. * don't resolve to `undefined` into the destination object. Subsequent sources
  23482. * overwrite property assignments of previous sources. If `customizer` is
  23483. * provided it's invoked to produce the merged values of the destination and
  23484. * source properties. If `customizer` returns `undefined` merging is handled
  23485. * by the method instead. The `customizer` is bound to `thisArg` and invoked
  23486. * with five arguments: (objectValue, sourceValue, key, object, source).
  23487. *
  23488. * @static
  23489. * @memberOf _
  23490. * @category Object
  23491. * @param {Object} object The destination object.
  23492. * @param {...Object} [sources] The source objects.
  23493. * @param {Function} [customizer] The function to customize assigned values.
  23494. * @param {*} [thisArg] The `this` binding of `customizer`.
  23495. * @returns {Object} Returns `object`.
  23496. * @example
  23497. *
  23498. * var users = {
  23499. * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
  23500. * };
  23501. *
  23502. * var ages = {
  23503. * 'data': [{ 'age': 36 }, { 'age': 40 }]
  23504. * };
  23505. *
  23506. * _.merge(users, ages);
  23507. * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
  23508. *
  23509. * // using a customizer callback
  23510. * var object = {
  23511. * 'fruits': ['apple'],
  23512. * 'vegetables': ['beet']
  23513. * };
  23514. *
  23515. * var other = {
  23516. * 'fruits': ['banana'],
  23517. * 'vegetables': ['carrot']
  23518. * };
  23519. *
  23520. * _.merge(object, other, function(a, b) {
  23521. * if (_.isArray(a)) {
  23522. * return a.concat(b);
  23523. * }
  23524. * });
  23525. * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
  23526. */
  23527. var merge = createAssigner(baseMerge);
  23528. module.exports = merge;
  23529. },{"128":128,"141":141}],181:[function(_dereq_,module,exports){
  23530. var arrayMap = _dereq_(101),
  23531. baseDifference = _dereq_(110),
  23532. baseFlatten = _dereq_(116),
  23533. bindCallback = _dereq_(137),
  23534. keysIn = _dereq_(179),
  23535. pickByArray = _dereq_(162),
  23536. pickByCallback = _dereq_(163),
  23537. restParam = _dereq_(95);
  23538. /**
  23539. * The opposite of `_.pick`; this method creates an object composed of the
  23540. * own and inherited enumerable properties of `object` that are not omitted.
  23541. *
  23542. * @static
  23543. * @memberOf _
  23544. * @category Object
  23545. * @param {Object} object The source object.
  23546. * @param {Function|...(string|string[])} [predicate] The function invoked per
  23547. * iteration or property names to omit, specified as individual property
  23548. * names or arrays of property names.
  23549. * @param {*} [thisArg] The `this` binding of `predicate`.
  23550. * @returns {Object} Returns the new object.
  23551. * @example
  23552. *
  23553. * var object = { 'user': 'fred', 'age': 40 };
  23554. *
  23555. * _.omit(object, 'age');
  23556. * // => { 'user': 'fred' }
  23557. *
  23558. * _.omit(object, _.isNumber);
  23559. * // => { 'user': 'fred' }
  23560. */
  23561. var omit = restParam(function(object, props) {
  23562. if (object == null) {
  23563. return {};
  23564. }
  23565. if (typeof props[0] != 'function') {
  23566. var props = arrayMap(baseFlatten(props), String);
  23567. return pickByArray(object, baseDifference(keysIn(object), props));
  23568. }
  23569. var predicate = bindCallback(props[0], props[1], 3);
  23570. return pickByCallback(object, function(value, key, object) {
  23571. return !predicate(value, key, object);
  23572. });
  23573. });
  23574. module.exports = omit;
  23575. },{"101":101,"110":110,"116":116,"137":137,"162":162,"163":163,"179":179,"95":95}],182:[function(_dereq_,module,exports){
  23576. var keys = _dereq_(178),
  23577. toObject = _dereq_(165);
  23578. /**
  23579. * Creates a two dimensional array of the key-value pairs for `object`,
  23580. * e.g. `[[key1, value1], [key2, value2]]`.
  23581. *
  23582. * @static
  23583. * @memberOf _
  23584. * @category Object
  23585. * @param {Object} object The object to query.
  23586. * @returns {Array} Returns the new array of key-value pairs.
  23587. * @example
  23588. *
  23589. * _.pairs({ 'barney': 36, 'fred': 40 });
  23590. * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)
  23591. */
  23592. function pairs(object) {
  23593. object = toObject(object);
  23594. var index = -1,
  23595. props = keys(object),
  23596. length = props.length,
  23597. result = Array(length);
  23598. while (++index < length) {
  23599. var key = props[index];
  23600. result[index] = [key, object[key]];
  23601. }
  23602. return result;
  23603. }
  23604. module.exports = pairs;
  23605. },{"165":165,"178":178}],183:[function(_dereq_,module,exports){
  23606. var baseFlatten = _dereq_(116),
  23607. bindCallback = _dereq_(137),
  23608. pickByArray = _dereq_(162),
  23609. pickByCallback = _dereq_(163),
  23610. restParam = _dereq_(95);
  23611. /**
  23612. * Creates an object composed of the picked `object` properties. Property
  23613. * names may be specified as individual arguments or as arrays of property
  23614. * names. If `predicate` is provided it's invoked for each property of `object`
  23615. * picking the properties `predicate` returns truthy for. The predicate is
  23616. * bound to `thisArg` and invoked with three arguments: (value, key, object).
  23617. *
  23618. * @static
  23619. * @memberOf _
  23620. * @category Object
  23621. * @param {Object} object The source object.
  23622. * @param {Function|...(string|string[])} [predicate] The function invoked per
  23623. * iteration or property names to pick, specified as individual property
  23624. * names or arrays of property names.
  23625. * @param {*} [thisArg] The `this` binding of `predicate`.
  23626. * @returns {Object} Returns the new object.
  23627. * @example
  23628. *
  23629. * var object = { 'user': 'fred', 'age': 40 };
  23630. *
  23631. * _.pick(object, 'user');
  23632. * // => { 'user': 'fred' }
  23633. *
  23634. * _.pick(object, _.isString);
  23635. * // => { 'user': 'fred' }
  23636. */
  23637. var pick = restParam(function(object, props) {
  23638. if (object == null) {
  23639. return {};
  23640. }
  23641. return typeof props[0] == 'function'
  23642. ? pickByCallback(object, bindCallback(props[0], props[1], 3))
  23643. : pickByArray(object, baseFlatten(props));
  23644. });
  23645. module.exports = pick;
  23646. },{"116":116,"137":137,"162":162,"163":163,"95":95}],184:[function(_dereq_,module,exports){
  23647. var baseValues = _dereq_(136),
  23648. keys = _dereq_(178);
  23649. /**
  23650. * Creates an array of the own enumerable property values of `object`.
  23651. *
  23652. * **Note:** Non-object values are coerced to objects.
  23653. *
  23654. * @static
  23655. * @memberOf _
  23656. * @category Object
  23657. * @param {Object} object The object to query.
  23658. * @returns {Array} Returns the array of property values.
  23659. * @example
  23660. *
  23661. * function Foo() {
  23662. * this.a = 1;
  23663. * this.b = 2;
  23664. * }
  23665. *
  23666. * Foo.prototype.c = 3;
  23667. *
  23668. * _.values(new Foo);
  23669. * // => [1, 2] (iteration order is not guaranteed)
  23670. *
  23671. * _.values('hi');
  23672. * // => ['h', 'i']
  23673. */
  23674. function values(object) {
  23675. return baseValues(object, keys(object));
  23676. }
  23677. module.exports = values;
  23678. },{"136":136,"178":178}],185:[function(_dereq_,module,exports){
  23679. /**
  23680. * This method returns the first argument provided to it.
  23681. *
  23682. * @static
  23683. * @memberOf _
  23684. * @category Utility
  23685. * @param {*} value Any value.
  23686. * @returns {*} Returns `value`.
  23687. * @example
  23688. *
  23689. * var object = { 'user': 'fred' };
  23690. *
  23691. * _.identity(object) === object;
  23692. * // => true
  23693. */
  23694. function identity(value) {
  23695. return value;
  23696. }
  23697. module.exports = identity;
  23698. },{}],186:[function(_dereq_,module,exports){
  23699. var baseProperty = _dereq_(130),
  23700. basePropertyDeep = _dereq_(131),
  23701. isKey = _dereq_(158);
  23702. /**
  23703. * Creates a function that returns the property value at `path` on a
  23704. * given object.
  23705. *
  23706. * @static
  23707. * @memberOf _
  23708. * @category Utility
  23709. * @param {Array|string} path The path of the property to get.
  23710. * @returns {Function} Returns the new function.
  23711. * @example
  23712. *
  23713. * var objects = [
  23714. * { 'a': { 'b': { 'c': 2 } } },
  23715. * { 'a': { 'b': { 'c': 1 } } }
  23716. * ];
  23717. *
  23718. * _.map(objects, _.property('a.b.c'));
  23719. * // => [2, 1]
  23720. *
  23721. * _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');
  23722. * // => [1, 2]
  23723. */
  23724. function property(path) {
  23725. return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
  23726. }
  23727. module.exports = property;
  23728. },{"130":130,"131":131,"158":158}],187:[function(_dereq_,module,exports){
  23729. module.exports = _dereq_(194);
  23730. },{"194":194}],188:[function(_dereq_,module,exports){
  23731. module.exports = function(el) {
  23732. var c;
  23733. while (el.childNodes.length) {
  23734. c = el.childNodes[0];
  23735. el.removeChild(c);
  23736. }
  23737. return el;
  23738. };
  23739. },{}],189:[function(_dereq_,module,exports){
  23740. module.exports = _dereq_(197);
  23741. },{"197":197}],190:[function(_dereq_,module,exports){
  23742. module.exports = _dereq_(201);
  23743. },{"201":201}],191:[function(_dereq_,module,exports){
  23744. module.exports = _dereq_(198);
  23745. },{"198":198}],192:[function(_dereq_,module,exports){
  23746. module.exports = _dereq_(200);
  23747. },{"200":200}],193:[function(_dereq_,module,exports){
  23748. module.exports = function(el) {
  23749. el.parentNode && el.parentNode.removeChild(el);
  23750. };
  23751. },{}],194:[function(_dereq_,module,exports){
  23752. /**
  23753. * Module dependencies.
  23754. */
  23755. var index = _dereq_(195);
  23756. /**
  23757. * Whitespace regexp.
  23758. */
  23759. var re = /\s+/;
  23760. /**
  23761. * toString reference.
  23762. */
  23763. var toString = Object.prototype.toString;
  23764. /**
  23765. * Wrap `el` in a `ClassList`.
  23766. *
  23767. * @param {Element} el
  23768. * @return {ClassList}
  23769. * @api public
  23770. */
  23771. module.exports = function(el){
  23772. return new ClassList(el);
  23773. };
  23774. /**
  23775. * Initialize a new ClassList for `el`.
  23776. *
  23777. * @param {Element} el
  23778. * @api private
  23779. */
  23780. function ClassList(el) {
  23781. if (!el || !el.nodeType) {
  23782. throw new Error('A DOM element reference is required');
  23783. }
  23784. this.el = el;
  23785. this.list = el.classList;
  23786. }
  23787. /**
  23788. * Add class `name` if not already present.
  23789. *
  23790. * @param {String} name
  23791. * @return {ClassList}
  23792. * @api public
  23793. */
  23794. ClassList.prototype.add = function(name){
  23795. // classList
  23796. if (this.list) {
  23797. this.list.add(name);
  23798. return this;
  23799. }
  23800. // fallback
  23801. var arr = this.array();
  23802. var i = index(arr, name);
  23803. if (!~i) arr.push(name);
  23804. this.el.className = arr.join(' ');
  23805. return this;
  23806. };
  23807. /**
  23808. * Remove class `name` when present, or
  23809. * pass a regular expression to remove
  23810. * any which match.
  23811. *
  23812. * @param {String|RegExp} name
  23813. * @return {ClassList}
  23814. * @api public
  23815. */
  23816. ClassList.prototype.remove = function(name){
  23817. if ('[object RegExp]' == toString.call(name)) {
  23818. return this.removeMatching(name);
  23819. }
  23820. // classList
  23821. if (this.list) {
  23822. this.list.remove(name);
  23823. return this;
  23824. }
  23825. // fallback
  23826. var arr = this.array();
  23827. var i = index(arr, name);
  23828. if (~i) arr.splice(i, 1);
  23829. this.el.className = arr.join(' ');
  23830. return this;
  23831. };
  23832. /**
  23833. * Remove all classes matching `re`.
  23834. *
  23835. * @param {RegExp} re
  23836. * @return {ClassList}
  23837. * @api private
  23838. */
  23839. ClassList.prototype.removeMatching = function(re){
  23840. var arr = this.array();
  23841. for (var i = 0; i < arr.length; i++) {
  23842. if (re.test(arr[i])) {
  23843. this.remove(arr[i]);
  23844. }
  23845. }
  23846. return this;
  23847. };
  23848. /**
  23849. * Toggle class `name`, can force state via `force`.
  23850. *
  23851. * For browsers that support classList, but do not support `force` yet,
  23852. * the mistake will be detected and corrected.
  23853. *
  23854. * @param {String} name
  23855. * @param {Boolean} force
  23856. * @return {ClassList}
  23857. * @api public
  23858. */
  23859. ClassList.prototype.toggle = function(name, force){
  23860. // classList
  23861. if (this.list) {
  23862. if ("undefined" !== typeof force) {
  23863. if (force !== this.list.toggle(name, force)) {
  23864. this.list.toggle(name); // toggle again to correct
  23865. }
  23866. } else {
  23867. this.list.toggle(name);
  23868. }
  23869. return this;
  23870. }
  23871. // fallback
  23872. if ("undefined" !== typeof force) {
  23873. if (!force) {
  23874. this.remove(name);
  23875. } else {
  23876. this.add(name);
  23877. }
  23878. } else {
  23879. if (this.has(name)) {
  23880. this.remove(name);
  23881. } else {
  23882. this.add(name);
  23883. }
  23884. }
  23885. return this;
  23886. };
  23887. /**
  23888. * Return an array of classes.
  23889. *
  23890. * @return {Array}
  23891. * @api public
  23892. */
  23893. ClassList.prototype.array = function(){
  23894. var className = this.el.getAttribute('class') || '';
  23895. var str = className.replace(/^\s+|\s+$/g, '');
  23896. var arr = str.split(re);
  23897. if ('' === arr[0]) arr.shift();
  23898. return arr;
  23899. };
  23900. /**
  23901. * Check if class `name` is present.
  23902. *
  23903. * @param {String} name
  23904. * @return {ClassList}
  23905. * @api public
  23906. */
  23907. ClassList.prototype.has =
  23908. ClassList.prototype.contains = function(name){
  23909. return this.list
  23910. ? this.list.contains(name)
  23911. : !! ~index(this.array(), name);
  23912. };
  23913. },{"195":195}],195:[function(_dereq_,module,exports){
  23914. module.exports = function(arr, obj){
  23915. if (arr.indexOf) return arr.indexOf(obj);
  23916. for (var i = 0; i < arr.length; ++i) {
  23917. if (arr[i] === obj) return i;
  23918. }
  23919. return -1;
  23920. };
  23921. },{}],196:[function(_dereq_,module,exports){
  23922. var matches = _dereq_(199)
  23923. module.exports = function (element, selector, checkYoSelf, root) {
  23924. element = checkYoSelf ? {parentNode: element} : element
  23925. root = root || document
  23926. // Make sure `element !== document` and `element != null`
  23927. // otherwise we get an illegal invocation
  23928. while ((element = element.parentNode) && element !== document) {
  23929. if (matches(element, selector))
  23930. return element
  23931. // After `matches` on the edge case that
  23932. // the selector matches the root
  23933. // (when the root is not the document)
  23934. if (element === root)
  23935. return
  23936. }
  23937. }
  23938. },{"199":199}],197:[function(_dereq_,module,exports){
  23939. /**
  23940. * Module dependencies.
  23941. */
  23942. var closest = _dereq_(196)
  23943. , event = _dereq_(198);
  23944. /**
  23945. * Delegate event `type` to `selector`
  23946. * and invoke `fn(e)`. A callback function
  23947. * is returned which may be passed to `.unbind()`.
  23948. *
  23949. * @param {Element} el
  23950. * @param {String} selector
  23951. * @param {String} type
  23952. * @param {Function} fn
  23953. * @param {Boolean} capture
  23954. * @return {Function}
  23955. * @api public
  23956. */
  23957. exports.bind = function(el, selector, type, fn, capture){
  23958. return event.bind(el, type, function(e){
  23959. var target = e.target || e.srcElement;
  23960. e.delegateTarget = closest(target, selector, true, el);
  23961. if (e.delegateTarget) fn.call(el, e);
  23962. }, capture);
  23963. };
  23964. /**
  23965. * Unbind event `type`'s callback `fn`.
  23966. *
  23967. * @param {Element} el
  23968. * @param {String} type
  23969. * @param {Function} fn
  23970. * @param {Boolean} capture
  23971. * @api public
  23972. */
  23973. exports.unbind = function(el, type, fn, capture){
  23974. event.unbind(el, type, fn, capture);
  23975. };
  23976. },{"196":196,"198":198}],198:[function(_dereq_,module,exports){
  23977. var bind = window.addEventListener ? 'addEventListener' : 'attachEvent',
  23978. unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
  23979. prefix = bind !== 'addEventListener' ? 'on' : '';
  23980. /**
  23981. * Bind `el` event `type` to `fn`.
  23982. *
  23983. * @param {Element} el
  23984. * @param {String} type
  23985. * @param {Function} fn
  23986. * @param {Boolean} capture
  23987. * @return {Function}
  23988. * @api public
  23989. */
  23990. exports.bind = function(el, type, fn, capture){
  23991. el[bind](prefix + type, fn, capture || false);
  23992. return fn;
  23993. };
  23994. /**
  23995. * Unbind `el` event `type`'s callback `fn`.
  23996. *
  23997. * @param {Element} el
  23998. * @param {String} type
  23999. * @param {Function} fn
  24000. * @param {Boolean} capture
  24001. * @return {Function}
  24002. * @api public
  24003. */
  24004. exports.unbind = function(el, type, fn, capture){
  24005. el[unbind](prefix + type, fn, capture || false);
  24006. return fn;
  24007. };
  24008. },{}],199:[function(_dereq_,module,exports){
  24009. /**
  24010. * Module dependencies.
  24011. */
  24012. var query = _dereq_(200);
  24013. /**
  24014. * Element prototype.
  24015. */
  24016. var proto = Element.prototype;
  24017. /**
  24018. * Vendor function.
  24019. */
  24020. var vendor = proto.matches
  24021. || proto.webkitMatchesSelector
  24022. || proto.mozMatchesSelector
  24023. || proto.msMatchesSelector
  24024. || proto.oMatchesSelector;
  24025. /**
  24026. * Expose `match()`.
  24027. */
  24028. module.exports = match;
  24029. /**
  24030. * Match `el` to `selector`.
  24031. *
  24032. * @param {Element} el
  24033. * @param {String} selector
  24034. * @return {Boolean}
  24035. * @api public
  24036. */
  24037. function match(el, selector) {
  24038. if (!el || el.nodeType !== 1) return false;
  24039. if (vendor) return vendor.call(el, selector);
  24040. var nodes = query.all(selector, el.parentNode);
  24041. for (var i = 0; i < nodes.length; ++i) {
  24042. if (nodes[i] == el) return true;
  24043. }
  24044. return false;
  24045. }
  24046. },{"200":200}],200:[function(_dereq_,module,exports){
  24047. function one(selector, el) {
  24048. return el.querySelector(selector);
  24049. }
  24050. exports = module.exports = function(selector, el){
  24051. el = el || document;
  24052. return one(selector, el);
  24053. };
  24054. exports.all = function(selector, el){
  24055. el = el || document;
  24056. return el.querySelectorAll(selector);
  24057. };
  24058. exports.engine = function(obj){
  24059. if (!obj.one) throw new Error('.one callback required');
  24060. if (!obj.all) throw new Error('.all callback required');
  24061. one = obj.one;
  24062. exports.all = obj.all;
  24063. return exports;
  24064. };
  24065. },{}],201:[function(_dereq_,module,exports){
  24066. /**
  24067. * Expose `parse`.
  24068. */
  24069. module.exports = parse;
  24070. /**
  24071. * Tests for browser support.
  24072. */
  24073. var div = document.createElement('div');
  24074. // Setup
  24075. div.innerHTML = ' <link/><table></table><a href="/a">a</a><input type="checkbox"/>';
  24076. // Make sure that link elements get serialized correctly by innerHTML
  24077. // This requires a wrapper element in IE
  24078. var innerHTMLBug = !div.getElementsByTagName('link').length;
  24079. div = undefined;
  24080. /**
  24081. * Wrap map from jquery.
  24082. */
  24083. var map = {
  24084. legend: [1, '<fieldset>', '</fieldset>'],
  24085. tr: [2, '<table><tbody>', '</tbody></table>'],
  24086. col: [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
  24087. // for script/link/style tags to work in IE6-8, you have to wrap
  24088. // in a div with a non-whitespace character in front, ha!
  24089. _default: innerHTMLBug ? [1, 'X<div>', '</div>'] : [0, '', '']
  24090. };
  24091. map.td =
  24092. map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
  24093. map.option =
  24094. map.optgroup = [1, '<select multiple="multiple">', '</select>'];
  24095. map.thead =
  24096. map.tbody =
  24097. map.colgroup =
  24098. map.caption =
  24099. map.tfoot = [1, '<table>', '</table>'];
  24100. map.polyline =
  24101. map.ellipse =
  24102. map.polygon =
  24103. map.circle =
  24104. map.text =
  24105. map.line =
  24106. map.path =
  24107. map.rect =
  24108. map.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>'];
  24109. /**
  24110. * Parse `html` and return a DOM Node instance, which could be a TextNode,
  24111. * HTML DOM Node of some kind (<div> for example), or a DocumentFragment
  24112. * instance, depending on the contents of the `html` string.
  24113. *
  24114. * @param {String} html - HTML string to "domify"
  24115. * @param {Document} doc - The `document` instance to create the Node for
  24116. * @return {DOMNode} the TextNode, DOM Node, or DocumentFragment instance
  24117. * @api private
  24118. */
  24119. function parse(html, doc) {
  24120. if ('string' != typeof html) throw new TypeError('String expected');
  24121. // default to the global `document` object
  24122. if (!doc) doc = document;
  24123. // tag name
  24124. var m = /<([\w:]+)/.exec(html);
  24125. if (!m) return doc.createTextNode(html);
  24126. html = html.replace(/^\s+|\s+$/g, ''); // Remove leading/trailing whitespace
  24127. var tag = m[1];
  24128. // body support
  24129. if (tag == 'body') {
  24130. var el = doc.createElement('html');
  24131. el.innerHTML = html;
  24132. return el.removeChild(el.lastChild);
  24133. }
  24134. // wrap map
  24135. var wrap = map[tag] || map._default;
  24136. var depth = wrap[0];
  24137. var prefix = wrap[1];
  24138. var suffix = wrap[2];
  24139. var el = doc.createElement('div');
  24140. el.innerHTML = prefix + html + suffix;
  24141. while (depth--) el = el.lastChild;
  24142. // one element
  24143. if (el.firstChild == el.lastChild) {
  24144. return el.removeChild(el.firstChild);
  24145. }
  24146. // several elements
  24147. var fragment = doc.createDocumentFragment();
  24148. while (el.firstChild) {
  24149. fragment.appendChild(el.removeChild(el.firstChild));
  24150. }
  24151. return fragment;
  24152. }
  24153. },{}],202:[function(_dereq_,module,exports){
  24154. module.exports = _dereq_(204);
  24155. module.exports.Collection = _dereq_(203);
  24156. },{"203":203,"204":204}],203:[function(_dereq_,module,exports){
  24157. 'use strict';
  24158. /**
  24159. * An empty collection stub. Use {@link RefsCollection.extend} to extend a
  24160. * collection with ref semantics.
  24161. *
  24162. * @classdesc A change and inverse-reference aware collection with set semantics.
  24163. *
  24164. * @class RefsCollection
  24165. */
  24166. function RefsCollection() { }
  24167. /**
  24168. * Extends a collection with {@link Refs} aware methods
  24169. *
  24170. * @memberof RefsCollection
  24171. * @static
  24172. *
  24173. * @param {Array<Object>} collection
  24174. * @param {Refs} refs instance
  24175. * @param {Object} property represented by the collection
  24176. * @param {Object} target object the collection is attached to
  24177. *
  24178. * @return {RefsCollection<Object>} the extended array
  24179. */
  24180. function extend(collection, refs, property, target) {
  24181. var inverseProperty = property.inverse;
  24182. /**
  24183. * Removes the given element from the array and returns it.
  24184. *
  24185. * @method RefsCollection#remove
  24186. *
  24187. * @param {Object} element the element to remove
  24188. */
  24189. collection.remove = function(element) {
  24190. var idx = this.indexOf(element);
  24191. if (idx !== -1) {
  24192. this.splice(idx, 1);
  24193. // unset inverse
  24194. refs.unset(element, inverseProperty, target);
  24195. }
  24196. return element;
  24197. };
  24198. /**
  24199. * Returns true if the collection contains the given element
  24200. *
  24201. * @method RefsCollection#contains
  24202. *
  24203. * @param {Object} element the element to check for
  24204. */
  24205. collection.contains = function(element) {
  24206. return this.indexOf(element) !== -1;
  24207. };
  24208. /**
  24209. * Adds an element to the array, unless it exists already (set semantics).
  24210. *
  24211. * @method RefsCollection#add
  24212. *
  24213. * @param {Object} element the element to add
  24214. */
  24215. collection.add = function(element) {
  24216. if (!this.contains(element)) {
  24217. this.push(element);
  24218. // set inverse
  24219. refs.set(element, inverseProperty, target);
  24220. }
  24221. };
  24222. return collection;
  24223. }
  24224. module.exports.extend = extend;
  24225. },{}],204:[function(_dereq_,module,exports){
  24226. 'use strict';
  24227. var Collection = _dereq_(203);
  24228. function hasOwnProperty(e, property) {
  24229. return Object.prototype.hasOwnProperty.call(e, property.name || property);
  24230. }
  24231. function defineCollectionProperty(ref, property, target) {
  24232. Object.defineProperty(target, property.name, {
  24233. enumerable: property.enumerable,
  24234. value: Collection.extend(target[property.name] || [], ref, property, target)
  24235. });
  24236. }
  24237. function defineProperty(ref, property, target) {
  24238. var inverseProperty = property.inverse;
  24239. var _value = target[property.name];
  24240. Object.defineProperty(target, property.name, {
  24241. enumerable: property.enumerable,
  24242. get: function() {
  24243. return _value;
  24244. },
  24245. set: function(value) {
  24246. // return if we already performed all changes
  24247. if (value === _value) {
  24248. return;
  24249. }
  24250. var old = _value;
  24251. // temporary set null
  24252. _value = null;
  24253. if (old) {
  24254. ref.unset(old, inverseProperty, target);
  24255. }
  24256. // set new value
  24257. _value = value;
  24258. // set inverse value
  24259. ref.set(_value, inverseProperty, target);
  24260. }
  24261. });
  24262. }
  24263. /**
  24264. * Creates a new references object defining two inversly related
  24265. * attribute descriptors a and b.
  24266. *
  24267. * <p>
  24268. * When bound to an object using {@link Refs#bind} the references
  24269. * get activated and ensure that add and remove operations are applied
  24270. * reversely, too.
  24271. * </p>
  24272. *
  24273. * <p>
  24274. * For attributes represented as collections {@link Refs} provides the
  24275. * {@link RefsCollection#add}, {@link RefsCollection#remove} and {@link RefsCollection#contains} extensions
  24276. * that must be used to properly hook into the inverse change mechanism.
  24277. * </p>
  24278. *
  24279. * @class Refs
  24280. *
  24281. * @classdesc A bi-directional reference between two attributes.
  24282. *
  24283. * @param {Refs.AttributeDescriptor} a property descriptor
  24284. * @param {Refs.AttributeDescriptor} b property descriptor
  24285. *
  24286. * @example
  24287. *
  24288. * var refs = Refs({ name: 'wheels', collection: true, enumerable: true }, { name: 'car' });
  24289. *
  24290. * var car = { name: 'toyota' };
  24291. * var wheels = [{ pos: 'front-left' }, { pos: 'front-right' }];
  24292. *
  24293. * refs.bind(car, 'wheels');
  24294. *
  24295. * car.wheels // []
  24296. * car.wheels.add(wheels[0]);
  24297. * car.wheels.add(wheels[1]);
  24298. *
  24299. * car.wheels // [{ pos: 'front-left' }, { pos: 'front-right' }]
  24300. *
  24301. * wheels[0].car // { name: 'toyota' };
  24302. * car.wheels.remove(wheels[0]);
  24303. *
  24304. * wheels[0].car // undefined
  24305. */
  24306. function Refs(a, b) {
  24307. if (!(this instanceof Refs)) {
  24308. return new Refs(a, b);
  24309. }
  24310. // link
  24311. a.inverse = b;
  24312. b.inverse = a;
  24313. this.props = {};
  24314. this.props[a.name] = a;
  24315. this.props[b.name] = b;
  24316. }
  24317. /**
  24318. * Binds one side of a bi-directional reference to a
  24319. * target object.
  24320. *
  24321. * @memberOf Refs
  24322. *
  24323. * @param {Object} target
  24324. * @param {String} property
  24325. */
  24326. Refs.prototype.bind = function(target, property) {
  24327. if (typeof property === 'string') {
  24328. if (!this.props[property]) {
  24329. throw new Error('no property <' + property + '> in ref');
  24330. }
  24331. property = this.props[property];
  24332. }
  24333. if (property.collection) {
  24334. defineCollectionProperty(this, property, target);
  24335. } else {
  24336. defineProperty(this, property, target);
  24337. }
  24338. };
  24339. Refs.prototype.ensureBound = function(target, property) {
  24340. if (!hasOwnProperty(target, property)) {
  24341. this.bind(target, property);
  24342. }
  24343. };
  24344. Refs.prototype.unset = function(target, property, value) {
  24345. if (target) {
  24346. this.ensureBound(target, property);
  24347. if (property.collection) {
  24348. target[property.name].remove(value);
  24349. } else {
  24350. target[property.name] = undefined;
  24351. }
  24352. }
  24353. };
  24354. Refs.prototype.set = function(target, property, value) {
  24355. if (target) {
  24356. this.ensureBound(target, property);
  24357. if (property.collection) {
  24358. target[property.name].add(value);
  24359. } else {
  24360. target[property.name] = value;
  24361. }
  24362. }
  24363. };
  24364. module.exports = Refs;
  24365. /**
  24366. * An attribute descriptor to be used specify an attribute in a {@link Refs} instance
  24367. *
  24368. * @typedef {Object} Refs.AttributeDescriptor
  24369. * @property {String} name
  24370. * @property {boolean} [collection=false]
  24371. * @property {boolean} [enumerable=false]
  24372. */
  24373. },{"203":203}]},{},[1])(1)
  24374. });
  24375. //# sourceMappingURL=bpmn-navigated-viewer.js.map