bpmn-viewer.js 783 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010
  1. /*!
  2. * bpmn-js - bpmn-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 assign = _dereq_(168),
  15. omit = _dereq_(172),
  16. isString = _dereq_(165),
  17. isNumber = _dereq_(162);
  18. var domify = _dereq_(181),
  19. domQuery = _dereq_(182),
  20. domRemove = _dereq_(183);
  21. var Diagram = _dereq_(35),
  22. BpmnModdle = _dereq_(14);
  23. var Importer = _dereq_(8);
  24. function initListeners(diagram, listeners) {
  25. var events = diagram.get('eventBus');
  26. listeners.forEach(function(l) {
  27. events.on(l.event, l.handler);
  28. });
  29. }
  30. function checkValidationError(err) {
  31. // check if we can help the user by indicating wrong BPMN 2.0 xml
  32. // (in case he or the exporting tool did not get that right)
  33. var pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/;
  34. var match = pattern.exec(err.message);
  35. if (match) {
  36. err.message =
  37. 'unparsable content <' + match[1] + '> detected; ' +
  38. 'this may indicate an invalid BPMN 2.0 diagram file' + match[2];
  39. }
  40. return err;
  41. }
  42. var DEFAULT_OPTIONS = {
  43. width: '100%',
  44. height: '100%',
  45. position: 'relative',
  46. container: 'body'
  47. };
  48. /**
  49. * Ensure the passed argument is a proper unit (defaulting to px)
  50. */
  51. function ensureUnit(val) {
  52. return val + (isNumber(val) ? 'px' : '');
  53. }
  54. /**
  55. * A viewer for BPMN 2.0 diagrams.
  56. *
  57. * Have a look at {@link NavigatedViewer} or {@link Modeler} for bundles that include
  58. * additional features.
  59. *
  60. *
  61. * ## Extending the Viewer
  62. *
  63. * In order to extend the viewer pass extension modules to bootstrap via the
  64. * `additionalModules` option. An extension module is an object that exposes
  65. * named services.
  66. *
  67. * The following example depicts the integration of a simple
  68. * logging component that integrates with interaction events:
  69. *
  70. *
  71. * ```javascript
  72. *
  73. * // logging component
  74. * function InteractionLogger(eventBus) {
  75. * eventBus.on('element.hover', function(event) {
  76. * console.log()
  77. * })
  78. * }
  79. *
  80. * InteractionLogger.$inject = [ 'eventBus' ]; // minification save
  81. *
  82. * // extension module
  83. * var extensionModule = {
  84. * __init__: [ 'interactionLogger' ],
  85. * interactionLogger: [ 'type', InteractionLogger ]
  86. * };
  87. *
  88. * // extend the viewer
  89. * var bpmnViewer = new Viewer({ additionalModules: [ extensionModule ] });
  90. * bpmnViewer.importXML(...);
  91. * ```
  92. *
  93. * @param {Object} [options] configuration options to pass to the viewer
  94. * @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
  95. * @param {String|Number} [options.width] the width of the viewer
  96. * @param {String|Number} [options.height] the height of the viewer
  97. * @param {Object} [options.moddleExtensions] extension packages to provide
  98. * @param {Array<didi.Module>} [options.modules] a list of modules to override the default modules
  99. * @param {Array<didi.Module>} [options.additionalModules] a list of modules to use with the default modules
  100. */
  101. function Viewer(options) {
  102. this.options = options = assign({}, DEFAULT_OPTIONS, options || {});
  103. var parent = options.container;
  104. // support jquery element
  105. // unwrap it if passed
  106. if (parent.get) {
  107. parent = parent.get(0);
  108. }
  109. // support selector
  110. if (isString(parent)) {
  111. parent = domQuery(parent);
  112. }
  113. var container = this.container = domify('<div class="bjs-container"></div>');
  114. parent.appendChild(container);
  115. assign(container.style, {
  116. width: ensureUnit(options.width),
  117. height: ensureUnit(options.height),
  118. position: options.position
  119. });
  120. /**
  121. * The code in the <project-logo></project-logo> area
  122. * must not be changed, see http://bpmn.io/license for more information
  123. *
  124. * <project-logo>
  125. */
  126. /* jshint -W101 */
  127. // inlined ../resources/bpmnjs.png
  128. var logoData = 'iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAMAAADypuvZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADBQTFRFiMte9PrwldFwfcZPqtqN0+zEyOe1XLgjvuKncsJAZ70y6fXh3vDT////UrQV////G2zN+AAAABB0Uk5T////////////////////AOAjXRkAAAHDSURBVHjavJZJkoUgDEBJmAX8979tM8u3E6x20VlYJfFFMoL4vBDxATxZcakIOJTWSmxvKWVIkJ8jHvlRv1F2LFrVISCZI+tCtQx+XfewgVTfyY3plPiQEAzI3zWy+kR6NBhFBYeBuscJLOUuA2WVLpCjVIaFzrNQZArxAZKUQm6gsj37L9Cb7dnIBUKxENaaMJQqMpDXvSL+ktxdGRm2IsKgJGGPg7atwUG5CcFUEuSv+CwQqizTrvDTNXdMU2bMiDWZd8d7QIySWVRsb2vBBioxOFt4OinPBapL+neAb5KL5IJ8szOza2/DYoipUCx+CjO0Bpsv0V6mktNZ+k8rlABlWG0FrOpKYVo8DT3dBeLEjUBAj7moDogVii7nSS9QzZnFcOVBp1g2PyBQ3Vr5aIapN91VJy33HTJLC1iX2FY6F8gRdaAeIEfVONgtFCzZTmoLEdOjBDfsIOA6128gw3eu1shAajdZNAORxuQDJN5A5PbEG6gNIu24QJD5iNyRMZIr6bsHbCtCU/OaOaSvgkUyDMdDa1BXGf5HJ1To+/Ym6mCKT02Y+/Sa126ZKyd3jxhzpc1r8zVL6YM1Qy/kR4ABAFJ6iQUnivhAAAAAAElFTkSuQmCC';
  129. /* jshint +W101 */
  130. var linkMarkup =
  131. '<a href="http://bpmn.io" ' +
  132. 'target="_blank" ' +
  133. 'class="bjs-powered-by" ' +
  134. 'title="Powered by bpmn.io" ' +
  135. 'style="position: absolute; bottom: 15px; right: 15px; z-index: 100">' +
  136. '<img src="data:image/png;base64,' + logoData + '">' +
  137. '</a>';
  138. container.appendChild(domify(linkMarkup));
  139. /* </project-logo> */
  140. }
  141. Viewer.prototype.importXML = function(xml, done) {
  142. var self = this;
  143. this.moddle = this.createModdle();
  144. this.moddle.fromXML(xml, 'bpmn:Definitions', function(err, definitions, context) {
  145. if (err) {
  146. err = checkValidationError(err);
  147. return done(err);
  148. }
  149. var parseWarnings = context.warnings;
  150. self.importDefinitions(definitions, function(err, importWarnings) {
  151. if (err) {
  152. return done(err);
  153. }
  154. done(null, parseWarnings.concat(importWarnings || []));
  155. });
  156. });
  157. };
  158. Viewer.prototype.saveXML = function(options, done) {
  159. if (!done) {
  160. done = options;
  161. options = {};
  162. }
  163. var definitions = this.definitions;
  164. if (!definitions) {
  165. return done(new Error('no definitions loaded'));
  166. }
  167. this.moddle.toXML(definitions, options, done);
  168. };
  169. Viewer.prototype.createModdle = function() {
  170. return new BpmnModdle(this.options.moddleExtensions);
  171. };
  172. Viewer.prototype.saveSVG = function(options, done) {
  173. if (!done) {
  174. done = options;
  175. options = {};
  176. }
  177. var canvas = this.get('canvas');
  178. var contentNode = canvas.getDefaultLayer(),
  179. defsNode = canvas._svg.select('defs');
  180. var contents = contentNode.innerSVG(),
  181. defs = (defsNode && defsNode.outerSVG()) || '';
  182. var bbox = contentNode.getBBox();
  183. var svg =
  184. '<?xml version="1.0" encoding="utf-8"?>\n' +
  185. '<!-- created with bpmn-js / http://bpmn.io -->\n' +
  186. '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
  187. '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
  188. 'width="' + bbox.width + '" height="' + bbox.height + '" ' +
  189. 'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' +
  190. defs + contents +
  191. '</svg>';
  192. done(null, svg);
  193. };
  194. Viewer.prototype.get = function(name) {
  195. if (!this.diagram) {
  196. throw new Error('no diagram loaded');
  197. }
  198. return this.diagram.get(name);
  199. };
  200. Viewer.prototype.invoke = function(fn) {
  201. if (!this.diagram) {
  202. throw new Error('no diagram loaded');
  203. }
  204. return this.diagram.invoke(fn);
  205. };
  206. Viewer.prototype.importDefinitions = function(definitions, done) {
  207. // use try/catch to not swallow synchronous exceptions
  208. // that may be raised during model parsing
  209. try {
  210. if (this.diagram) {
  211. this.clear();
  212. }
  213. this.definitions = definitions;
  214. var diagram = this.diagram = this._createDiagram(this.options);
  215. this._init(diagram);
  216. Importer.importBpmnDiagram(diagram, definitions, done);
  217. } catch (e) {
  218. done(e);
  219. }
  220. };
  221. Viewer.prototype._init = function(diagram) {
  222. initListeners(diagram, this.__listeners || []);
  223. };
  224. Viewer.prototype._createDiagram = function(options) {
  225. var modules = [].concat(options.modules || this.getModules(), options.additionalModules || []);
  226. // add self as an available service
  227. modules.unshift({
  228. bpmnjs: [ 'value', this ],
  229. moddle: [ 'value', this.moddle ]
  230. });
  231. options = omit(options, 'additionalModules');
  232. options = assign(options, {
  233. canvas: { container: this.container },
  234. modules: modules
  235. });
  236. return new Diagram(options);
  237. };
  238. Viewer.prototype.getModules = function() {
  239. return this._modules;
  240. };
  241. /**
  242. * Remove all drawn elements from the viewer.
  243. *
  244. * After calling this method the viewer can still
  245. * be reused for opening another diagram.
  246. */
  247. Viewer.prototype.clear = function() {
  248. var diagram = this.diagram;
  249. if (diagram) {
  250. diagram.destroy();
  251. }
  252. };
  253. /**
  254. * Destroy the viewer instance and remove all its remainders
  255. * from the document tree.
  256. */
  257. Viewer.prototype.destroy = function() {
  258. // clear underlying diagram
  259. this.clear();
  260. // remove container
  261. domRemove(this.container);
  262. };
  263. /**
  264. * Register an event listener on the viewer
  265. *
  266. * @param {String} event
  267. * @param {Function} handler
  268. */
  269. Viewer.prototype.on = function(event, handler) {
  270. var diagram = this.diagram,
  271. listeners = this.__listeners = this.__listeners || [];
  272. listeners.push({ event: event, handler: handler });
  273. if (diagram) {
  274. diagram.get('eventBus').on(event, handler);
  275. }
  276. };
  277. // modules the viewer is composed of
  278. Viewer.prototype._modules = [
  279. _dereq_(2),
  280. _dereq_(55),
  281. _dereq_(51)
  282. ];
  283. module.exports = Viewer;
  284. },{"14":14,"162":162,"165":165,"168":168,"172":172,"181":181,"182":182,"183":183,"2":2,"35":35,"51":51,"55":55,"8":8}],2:[function(_dereq_,module,exports){
  285. module.exports = {
  286. __depends__: [
  287. _dereq_(5),
  288. _dereq_(10)
  289. ]
  290. };
  291. },{"10":10,"5":5}],3:[function(_dereq_,module,exports){
  292. 'use strict';
  293. var inherits = _dereq_(72),
  294. isArray = _dereq_(159),
  295. isObject = _dereq_(163),
  296. assign = _dereq_(168),
  297. forEach = _dereq_(77),
  298. every = _dereq_(74),
  299. includes = _dereq_(79),
  300. some = _dereq_(82);
  301. var DefaultRenderer = _dereq_(43),
  302. TextUtil = _dereq_(64),
  303. DiUtil = _dereq_(11);
  304. var createLine = DefaultRenderer.createLine;
  305. function BpmnRenderer(events, styles, pathMap) {
  306. DefaultRenderer.call(this, styles);
  307. var TASK_BORDER_RADIUS = 10;
  308. var INNER_OUTER_DIST = 3;
  309. var LABEL_STYLE = {
  310. fontFamily: 'Arial, sans-serif',
  311. fontSize: '12px'
  312. };
  313. var textUtil = new TextUtil({
  314. style: LABEL_STYLE,
  315. size: { width: 100 }
  316. });
  317. var markers = {};
  318. function addMarker(id, element) {
  319. markers[id] = element;
  320. }
  321. function marker(id) {
  322. return markers[id];
  323. }
  324. function initMarkers(svg) {
  325. function createMarker(id, options) {
  326. var attrs = assign({
  327. fill: 'black',
  328. strokeWidth: 1,
  329. strokeLinecap: 'round',
  330. strokeDasharray: 'none'
  331. }, options.attrs);
  332. var ref = options.ref || { x: 0, y: 0 };
  333. var scale = options.scale || 1;
  334. // fix for safari / chrome / firefox bug not correctly
  335. // resetting stroke dash array
  336. if (attrs.strokeDasharray === 'none') {
  337. attrs.strokeDasharray = [10000, 1];
  338. }
  339. var marker = options.element
  340. .attr(attrs)
  341. .marker(0, 0, 20, 20, ref.x, ref.y)
  342. .attr({
  343. markerWidth: 20 * scale,
  344. markerHeight: 20 * scale
  345. });
  346. return addMarker(id, marker);
  347. }
  348. createMarker('sequenceflow-end', {
  349. element: svg.path('M 1 5 L 11 10 L 1 15 Z'),
  350. ref: { x: 11, y: 10 },
  351. scale: 0.5
  352. });
  353. createMarker('messageflow-start', {
  354. element: svg.circle(6, 6, 3.5),
  355. attrs: {
  356. fill: 'white',
  357. stroke: 'black'
  358. },
  359. ref: { x: 6, y: 6 }
  360. });
  361. createMarker('messageflow-end', {
  362. element: svg.path('m 1 5 l 0 -3 l 7 3 l -7 3 z'),
  363. attrs: {
  364. fill: 'white',
  365. stroke: 'black',
  366. strokeLinecap: 'butt'
  367. },
  368. ref: { x: 8.5, y: 5 }
  369. });
  370. createMarker('data-association-end', {
  371. element: svg.path('M 1 5 L 11 10 L 1 15'),
  372. attrs: {
  373. fill: 'white',
  374. stroke: 'black'
  375. },
  376. ref: { x: 11, y: 10 },
  377. scale: 0.5
  378. });
  379. createMarker('conditional-flow-marker', {
  380. element: svg.path('M 0 10 L 8 6 L 16 10 L 8 14 Z'),
  381. attrs: {
  382. fill: 'white',
  383. stroke: 'black'
  384. },
  385. ref: { x: -1, y: 10 },
  386. scale: 0.5
  387. });
  388. createMarker('conditional-default-flow-marker', {
  389. element: svg.path('M 1 4 L 5 16'),
  390. attrs: {
  391. stroke: 'black'
  392. },
  393. ref: { x: -5, y: 10 },
  394. scale: 0.5
  395. });
  396. }
  397. function computeStyle(custom, traits, defaultStyles) {
  398. if (!isArray(traits)) {
  399. defaultStyles = traits;
  400. traits = [];
  401. }
  402. return styles.style(traits || [], assign(defaultStyles, custom || {}));
  403. }
  404. function drawCircle(p, width, height, offset, attrs) {
  405. if (isObject(offset)) {
  406. attrs = offset;
  407. offset = 0;
  408. }
  409. offset = offset || 0;
  410. attrs = computeStyle(attrs, {
  411. stroke: 'black',
  412. strokeWidth: 2,
  413. fill: 'white'
  414. });
  415. var cx = width / 2,
  416. cy = height / 2;
  417. return p.circle(cx, cy, Math.round((width + height) / 4 - offset)).attr(attrs);
  418. }
  419. function drawRect(p, width, height, r, offset, attrs) {
  420. if (isObject(offset)) {
  421. attrs = offset;
  422. offset = 0;
  423. }
  424. offset = offset || 0;
  425. attrs = computeStyle(attrs, {
  426. stroke: 'black',
  427. strokeWidth: 2,
  428. fill: 'white'
  429. });
  430. return p.rect(offset, offset, width - offset * 2, height - offset * 2, r).attr(attrs);
  431. }
  432. function drawDiamond(p, width, height, attrs) {
  433. var x_2 = width / 2;
  434. var y_2 = height / 2;
  435. var points = [x_2, 0, width, y_2, x_2, height, 0, y_2 ];
  436. attrs = computeStyle(attrs, {
  437. stroke: 'black',
  438. strokeWidth: 2,
  439. fill: 'white'
  440. });
  441. return p.polygon(points).attr(attrs);
  442. }
  443. function drawLine(p, waypoints, attrs) {
  444. attrs = computeStyle(attrs, [ 'no-fill' ], {
  445. stroke: 'black',
  446. strokeWidth: 2,
  447. fill: 'none'
  448. });
  449. return createLine(waypoints, attrs).appendTo(p);
  450. }
  451. function drawPath(p, d, attrs) {
  452. attrs = computeStyle(attrs, [ 'no-fill' ], {
  453. strokeWidth: 2,
  454. stroke: 'black'
  455. });
  456. return p.path(d).attr(attrs);
  457. }
  458. function as(type) {
  459. return function(p, element) {
  460. return handlers[type](p, element);
  461. };
  462. }
  463. function renderer(type) {
  464. return handlers[type];
  465. }
  466. function renderEventContent(element, p) {
  467. var event = getSemantic(element);
  468. var isThrowing = isThrowEvent(event);
  469. if (isTypedEvent(event, 'bpmn:MessageEventDefinition')) {
  470. return renderer('bpmn:MessageEventDefinition')(p, element, isThrowing);
  471. }
  472. if (isTypedEvent(event, 'bpmn:TimerEventDefinition')) {
  473. return renderer('bpmn:TimerEventDefinition')(p, element, isThrowing);
  474. }
  475. if (isTypedEvent(event, 'bpmn:ConditionalEventDefinition')) {
  476. return renderer('bpmn:ConditionalEventDefinition')(p, element);
  477. }
  478. if (isTypedEvent(event, 'bpmn:SignalEventDefinition')) {
  479. return renderer('bpmn:SignalEventDefinition')(p, element, isThrowing);
  480. }
  481. if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
  482. isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: false })) {
  483. return renderer('bpmn:MultipleEventDefinition')(p, element, isThrowing);
  484. }
  485. if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
  486. isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: true })) {
  487. return renderer('bpmn:ParallelMultipleEventDefinition')(p, element, isThrowing);
  488. }
  489. if (isTypedEvent(event, 'bpmn:EscalationEventDefinition')) {
  490. return renderer('bpmn:EscalationEventDefinition')(p, element, isThrowing);
  491. }
  492. if (isTypedEvent(event, 'bpmn:LinkEventDefinition')) {
  493. return renderer('bpmn:LinkEventDefinition')(p, element, isThrowing);
  494. }
  495. if (isTypedEvent(event, 'bpmn:ErrorEventDefinition')) {
  496. return renderer('bpmn:ErrorEventDefinition')(p, element, isThrowing);
  497. }
  498. if (isTypedEvent(event, 'bpmn:CancelEventDefinition')) {
  499. return renderer('bpmn:CancelEventDefinition')(p, element, isThrowing);
  500. }
  501. if (isTypedEvent(event, 'bpmn:CompensateEventDefinition')) {
  502. return renderer('bpmn:CompensateEventDefinition')(p, element, isThrowing);
  503. }
  504. if (isTypedEvent(event, 'bpmn:TerminateEventDefinition')) {
  505. return renderer('bpmn:TerminateEventDefinition')(p, element, isThrowing);
  506. }
  507. return null;
  508. }
  509. function renderLabel(p, label, options) {
  510. return textUtil.createText(p, label || '', options).addClass('djs-label');
  511. }
  512. function renderEmbeddedLabel(p, element, align) {
  513. var semantic = getSemantic(element);
  514. return renderLabel(p, semantic.name, { box: element, align: align, padding: 5 });
  515. }
  516. function renderExternalLabel(p, element, align) {
  517. var semantic = getSemantic(element);
  518. if (!semantic.name) {
  519. element.hidden = true;
  520. }
  521. return renderLabel(p, semantic.name, { box: element, align: align, style: { fontSize: '11px' } });
  522. }
  523. function renderLaneLabel(p, text, element) {
  524. var textBox = renderLabel(p, text, {
  525. box: { height: 30, width: element.height },
  526. align: 'center-middle'
  527. });
  528. var top = -1 * element.height;
  529. textBox.transform(
  530. 'rotate(270) ' +
  531. 'translate(' + top + ',' + 0 + ')'
  532. );
  533. }
  534. function createPathFromConnection(connection) {
  535. var waypoints = connection.waypoints;
  536. var pathData = 'm ' + waypoints[0].x + ',' + waypoints[0].y;
  537. for (var i = 1; i < waypoints.length; i++) {
  538. pathData += 'L' + waypoints[i].x + ',' + waypoints[i].y + ' ';
  539. }
  540. return pathData;
  541. }
  542. var handlers = {
  543. 'bpmn:Event': function(p, element, attrs) {
  544. return drawCircle(p, element.width, element.height, attrs);
  545. },
  546. 'bpmn:StartEvent': function(p, element) {
  547. var attrs = {};
  548. var semantic = getSemantic(element);
  549. if (!semantic.isInterrupting) {
  550. attrs = {
  551. strokeDasharray: '6',
  552. strokeLinecap: 'round'
  553. };
  554. }
  555. var circle = renderer('bpmn:Event')(p, element, attrs);
  556. renderEventContent(element, p);
  557. return circle;
  558. },
  559. 'bpmn:MessageEventDefinition': function(p, element, isThrowing) {
  560. var pathData = pathMap.getScaledPath('EVENT_MESSAGE', {
  561. xScaleFactor: 0.9,
  562. yScaleFactor: 0.9,
  563. containerWidth: element.width,
  564. containerHeight: element.height,
  565. position: {
  566. mx: 0.235,
  567. my: 0.315
  568. }
  569. });
  570. var fill = isThrowing ? 'black' : 'white';
  571. var stroke = isThrowing ? 'white' : 'black';
  572. var messagePath = drawPath(p, pathData, {
  573. strokeWidth: 1,
  574. fill: fill,
  575. stroke: stroke
  576. });
  577. return messagePath;
  578. },
  579. 'bpmn:TimerEventDefinition': function(p, element) {
  580. var circle = drawCircle(p, element.width, element.height, 0.2 * element.height, {
  581. strokeWidth: 2
  582. });
  583. var pathData = pathMap.getScaledPath('EVENT_TIMER_WH', {
  584. xScaleFactor: 0.75,
  585. yScaleFactor: 0.75,
  586. containerWidth: element.width,
  587. containerHeight: element.height,
  588. position: {
  589. mx: 0.5,
  590. my: 0.5
  591. }
  592. });
  593. drawPath(p, pathData, {
  594. strokeWidth: 2,
  595. strokeLinecap: 'square'
  596. });
  597. for(var i = 0;i < 12;i++) {
  598. var linePathData = pathMap.getScaledPath('EVENT_TIMER_LINE', {
  599. xScaleFactor: 0.75,
  600. yScaleFactor: 0.75,
  601. containerWidth: element.width,
  602. containerHeight: element.height,
  603. position: {
  604. mx: 0.5,
  605. my: 0.5
  606. }
  607. });
  608. var width = element.width / 2;
  609. var height = element.height / 2;
  610. drawPath(p, linePathData, {
  611. strokeWidth: 1,
  612. strokeLinecap: 'square',
  613. transform: 'rotate(' + (i * 30) + ',' + height + ',' + width + ')'
  614. });
  615. }
  616. return circle;
  617. },
  618. 'bpmn:EscalationEventDefinition': function(p, event, isThrowing) {
  619. var pathData = pathMap.getScaledPath('EVENT_ESCALATION', {
  620. xScaleFactor: 1,
  621. yScaleFactor: 1,
  622. containerWidth: event.width,
  623. containerHeight: event.height,
  624. position: {
  625. mx: 0.5,
  626. my: 0.555
  627. }
  628. });
  629. var fill = isThrowing ? 'black' : 'none';
  630. return drawPath(p, pathData, {
  631. strokeWidth: 1,
  632. fill: fill
  633. });
  634. },
  635. 'bpmn:ConditionalEventDefinition': function(p, event) {
  636. var pathData = pathMap.getScaledPath('EVENT_CONDITIONAL', {
  637. xScaleFactor: 1,
  638. yScaleFactor: 1,
  639. containerWidth: event.width,
  640. containerHeight: event.height,
  641. position: {
  642. mx: 0.5,
  643. my: 0.222
  644. }
  645. });
  646. return drawPath(p, pathData, {
  647. strokeWidth: 1
  648. });
  649. },
  650. 'bpmn:LinkEventDefinition': function(p, event, isThrowing) {
  651. var pathData = pathMap.getScaledPath('EVENT_LINK', {
  652. xScaleFactor: 1,
  653. yScaleFactor: 1,
  654. containerWidth: event.width,
  655. containerHeight: event.height,
  656. position: {
  657. mx: 0.57,
  658. my: 0.263
  659. }
  660. });
  661. var fill = isThrowing ? 'black' : 'none';
  662. return drawPath(p, pathData, {
  663. strokeWidth: 1,
  664. fill: fill
  665. });
  666. },
  667. 'bpmn:ErrorEventDefinition': function(p, event, isThrowing) {
  668. var pathData = pathMap.getScaledPath('EVENT_ERROR', {
  669. xScaleFactor: 1.1,
  670. yScaleFactor: 1.1,
  671. containerWidth: event.width,
  672. containerHeight: event.height,
  673. position: {
  674. mx: 0.2,
  675. my: 0.722
  676. }
  677. });
  678. var fill = isThrowing ? 'black' : 'none';
  679. return drawPath(p, pathData, {
  680. strokeWidth: 1,
  681. fill: fill
  682. });
  683. },
  684. 'bpmn:CancelEventDefinition': function(p, event, isThrowing) {
  685. var pathData = pathMap.getScaledPath('EVENT_CANCEL_45', {
  686. xScaleFactor: 1.0,
  687. yScaleFactor: 1.0,
  688. containerWidth: event.width,
  689. containerHeight: event.height,
  690. position: {
  691. mx: 0.638,
  692. my: -0.055
  693. }
  694. });
  695. var fill = isThrowing ? 'black' : 'none';
  696. return drawPath(p, pathData, {
  697. strokeWidth: 1,
  698. fill: fill
  699. }).transform('rotate(45)');
  700. },
  701. 'bpmn:CompensateEventDefinition': function(p, event, isThrowing) {
  702. var pathData = pathMap.getScaledPath('EVENT_COMPENSATION', {
  703. xScaleFactor: 1,
  704. yScaleFactor: 1,
  705. containerWidth: event.width,
  706. containerHeight: event.height,
  707. position: {
  708. mx: 0.201,
  709. my: 0.472
  710. }
  711. });
  712. var fill = isThrowing ? 'black' : 'none';
  713. return drawPath(p, pathData, {
  714. strokeWidth: 1,
  715. fill: fill
  716. });
  717. },
  718. 'bpmn:SignalEventDefinition': function(p, event, isThrowing) {
  719. var pathData = pathMap.getScaledPath('EVENT_SIGNAL', {
  720. xScaleFactor: 0.9,
  721. yScaleFactor: 0.9,
  722. containerWidth: event.width,
  723. containerHeight: event.height,
  724. position: {
  725. mx: 0.5,
  726. my: 0.2
  727. }
  728. });
  729. var fill = isThrowing ? 'black' : 'none';
  730. return drawPath(p, pathData, {
  731. strokeWidth: 1,
  732. fill: fill
  733. });
  734. },
  735. 'bpmn:MultipleEventDefinition': function(p, event, isThrowing) {
  736. var pathData = pathMap.getScaledPath('EVENT_MULTIPLE', {
  737. xScaleFactor: 1.1,
  738. yScaleFactor: 1.1,
  739. containerWidth: event.width,
  740. containerHeight: event.height,
  741. position: {
  742. mx: 0.222,
  743. my: 0.36
  744. }
  745. });
  746. var fill = isThrowing ? 'black' : 'none';
  747. return drawPath(p, pathData, {
  748. strokeWidth: 1,
  749. fill: fill
  750. });
  751. },
  752. 'bpmn:ParallelMultipleEventDefinition': function(p, event) {
  753. var pathData = pathMap.getScaledPath('EVENT_PARALLEL_MULTIPLE', {
  754. xScaleFactor: 1.2,
  755. yScaleFactor: 1.2,
  756. containerWidth: event.width,
  757. containerHeight: event.height,
  758. position: {
  759. mx: 0.458,
  760. my: 0.194
  761. }
  762. });
  763. return drawPath(p, pathData, {
  764. strokeWidth: 1
  765. });
  766. },
  767. 'bpmn:EndEvent': function(p, element) {
  768. var circle = renderer('bpmn:Event')(p, element, {
  769. strokeWidth: 4
  770. });
  771. renderEventContent(element, p, true);
  772. return circle;
  773. },
  774. 'bpmn:TerminateEventDefinition': function(p, element) {
  775. var circle = drawCircle(p, element.width, element.height, 8, {
  776. strokeWidth: 4,
  777. fill: 'black'
  778. });
  779. return circle;
  780. },
  781. 'bpmn:IntermediateEvent': function(p, element) {
  782. var outer = renderer('bpmn:Event')(p, element, { strokeWidth: 1 });
  783. /* inner */ drawCircle(p, element.width, element.height, INNER_OUTER_DIST, { strokeWidth: 1, fill: 'none' });
  784. renderEventContent(element, p);
  785. return outer;
  786. },
  787. 'bpmn:IntermediateCatchEvent': as('bpmn:IntermediateEvent'),
  788. 'bpmn:IntermediateThrowEvent': as('bpmn:IntermediateEvent'),
  789. 'bpmn:Activity': function(p, element, attrs) {
  790. return drawRect(p, element.width, element.height, TASK_BORDER_RADIUS, attrs);
  791. },
  792. 'bpmn:Task': function(p, element, attrs) {
  793. var rect = renderer('bpmn:Activity')(p, element, attrs);
  794. renderEmbeddedLabel(p, element, 'center-middle');
  795. attachTaskMarkers(p, element);
  796. return rect;
  797. },
  798. 'bpmn:ServiceTask': function(p, element) {
  799. var task = renderer('bpmn:Task')(p, element);
  800. var pathDataBG = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
  801. abspos: {
  802. x: 12,
  803. y: 18
  804. }
  805. });
  806. /* service bg */ drawPath(p, pathDataBG, {
  807. strokeWidth: 1,
  808. fill: 'none'
  809. });
  810. var fillPathData = pathMap.getScaledPath('TASK_TYPE_SERVICE_FILL', {
  811. abspos: {
  812. x: 17.2,
  813. y: 18
  814. }
  815. });
  816. /* service fill */ drawPath(p, fillPathData, {
  817. strokeWidth: 0,
  818. stroke: 'none',
  819. fill: 'white'
  820. });
  821. var pathData = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
  822. abspos: {
  823. x: 17,
  824. y: 22
  825. }
  826. });
  827. /* service */ drawPath(p, pathData, {
  828. strokeWidth: 1,
  829. fill: 'white'
  830. });
  831. return task;
  832. },
  833. 'bpmn:UserTask': function(p, element) {
  834. var task = renderer('bpmn:Task')(p, element);
  835. var x = 15;
  836. var y = 12;
  837. var pathData = pathMap.getScaledPath('TASK_TYPE_USER_1', {
  838. abspos: {
  839. x: x,
  840. y: y
  841. }
  842. });
  843. /* user path */ drawPath(p, pathData, {
  844. strokeWidth: 0.5,
  845. fill: 'none'
  846. });
  847. var pathData2 = pathMap.getScaledPath('TASK_TYPE_USER_2', {
  848. abspos: {
  849. x: x,
  850. y: y
  851. }
  852. });
  853. /* user2 path */ drawPath(p, pathData2, {
  854. strokeWidth: 0.5,
  855. fill: 'none'
  856. });
  857. var pathData3 = pathMap.getScaledPath('TASK_TYPE_USER_3', {
  858. abspos: {
  859. x: x,
  860. y: y
  861. }
  862. });
  863. /* user3 path */ drawPath(p, pathData3, {
  864. strokeWidth: 0.5,
  865. fill: 'black'
  866. });
  867. return task;
  868. },
  869. 'bpmn:ManualTask': function(p, element) {
  870. var task = renderer('bpmn:Task')(p, element);
  871. var pathData = pathMap.getScaledPath('TASK_TYPE_MANUAL', {
  872. abspos: {
  873. x: 17,
  874. y: 15
  875. }
  876. });
  877. /* manual path */ drawPath(p, pathData, {
  878. strokeWidth: 0.25,
  879. fill: 'white',
  880. stroke: 'black'
  881. });
  882. return task;
  883. },
  884. 'bpmn:SendTask': function(p, element) {
  885. var task = renderer('bpmn:Task')(p, element);
  886. var pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
  887. xScaleFactor: 1,
  888. yScaleFactor: 1,
  889. containerWidth: 21,
  890. containerHeight: 14,
  891. position: {
  892. mx: 0.285,
  893. my: 0.357
  894. }
  895. });
  896. /* send path */ drawPath(p, pathData, {
  897. strokeWidth: 1,
  898. fill: 'black',
  899. stroke: 'white'
  900. });
  901. return task;
  902. },
  903. 'bpmn:ReceiveTask' : function(p, element) {
  904. var semantic = getSemantic(element);
  905. var task = renderer('bpmn:Task')(p, element);
  906. var pathData;
  907. if (semantic.instantiate) {
  908. drawCircle(p, 28, 28, 20 * 0.22, { strokeWidth: 1 });
  909. pathData = pathMap.getScaledPath('TASK_TYPE_INSTANTIATING_SEND', {
  910. abspos: {
  911. x: 7.77,
  912. y: 9.52
  913. }
  914. });
  915. } else {
  916. pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
  917. xScaleFactor: 0.9,
  918. yScaleFactor: 0.9,
  919. containerWidth: 21,
  920. containerHeight: 14,
  921. position: {
  922. mx: 0.3,
  923. my: 0.4
  924. }
  925. });
  926. }
  927. /* receive path */ drawPath(p, pathData, {
  928. strokeWidth: 1
  929. });
  930. return task;
  931. },
  932. 'bpmn:ScriptTask': function(p, element) {
  933. var task = renderer('bpmn:Task')(p, element);
  934. var pathData = pathMap.getScaledPath('TASK_TYPE_SCRIPT', {
  935. abspos: {
  936. x: 15,
  937. y: 20
  938. }
  939. });
  940. /* script path */ drawPath(p, pathData, {
  941. strokeWidth: 1
  942. });
  943. return task;
  944. },
  945. 'bpmn:BusinessRuleTask': function(p, element) {
  946. var task = renderer('bpmn:Task')(p, element);
  947. var headerPathData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_HEADER', {
  948. abspos: {
  949. x: 8,
  950. y: 8
  951. }
  952. });
  953. var businessHeaderPath = drawPath(p, headerPathData);
  954. businessHeaderPath.attr({
  955. strokeWidth: 1,
  956. fill: 'AAA'
  957. });
  958. var headerData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_MAIN', {
  959. abspos: {
  960. x: 8,
  961. y: 8
  962. }
  963. });
  964. var businessPath = drawPath(p, headerData);
  965. businessPath.attr({
  966. strokeWidth: 1
  967. });
  968. return task;
  969. },
  970. 'bpmn:SubProcess': function(p, element, attrs) {
  971. var rect = renderer('bpmn:Activity')(p, element, attrs);
  972. var semantic = getSemantic(element);
  973. var expanded = DiUtil.isExpanded(semantic);
  974. var isEventSubProcess = !!semantic.triggeredByEvent;
  975. if (isEventSubProcess) {
  976. rect.attr({
  977. strokeDasharray: '1,2'
  978. });
  979. }
  980. renderEmbeddedLabel(p, element, expanded ? 'center-top' : 'center-middle');
  981. if (expanded) {
  982. attachTaskMarkers(p, element);
  983. } else {
  984. attachTaskMarkers(p, element, ['SubProcessMarker']);
  985. }
  986. return rect;
  987. },
  988. 'bpmn:AdHocSubProcess': function(p, element) {
  989. return renderer('bpmn:SubProcess')(p, element);
  990. },
  991. 'bpmn:Transaction': function(p, element) {
  992. var outer = renderer('bpmn:SubProcess')(p, element);
  993. var innerAttrs = styles.style([ 'no-fill', 'no-events' ]);
  994. /* inner path */ drawRect(p, element.width, element.height, TASK_BORDER_RADIUS - 2, INNER_OUTER_DIST, innerAttrs);
  995. return outer;
  996. },
  997. 'bpmn:CallActivity': function(p, element) {
  998. return renderer('bpmn:Task')(p, element, {
  999. strokeWidth: 5
  1000. });
  1001. },
  1002. 'bpmn:Participant': function(p, element) {
  1003. var lane = renderer('bpmn:Lane')(p, element, {
  1004. fill: 'White'
  1005. });
  1006. var expandedPool = DiUtil.isExpanded(element);
  1007. if (expandedPool) {
  1008. drawLine(p, [
  1009. { x: 30, y: 0 },
  1010. { x: 30, y: element.height }
  1011. ]);
  1012. var text = getSemantic(element).name;
  1013. renderLaneLabel(p, text, element);
  1014. } else {
  1015. // Collapsed pool draw text inline
  1016. var text2 = getSemantic(element).name;
  1017. renderLabel(p, text2, { box: element, align: 'center-middle' });
  1018. }
  1019. var participantMultiplicity = !!(getSemantic(element).participantMultiplicity);
  1020. if(participantMultiplicity) {
  1021. renderer('ParticipantMultiplicityMarker')(p, element);
  1022. }
  1023. return lane;
  1024. },
  1025. 'bpmn:Lane': function(p, element, attrs) {
  1026. var rect = drawRect(p, element.width, element.height, 0, attrs || {
  1027. fill: 'none'
  1028. });
  1029. var semantic = getSemantic(element);
  1030. if (semantic.$type === 'bpmn:Lane') {
  1031. var text = semantic.name;
  1032. renderLaneLabel(p, text, element);
  1033. }
  1034. return rect;
  1035. },
  1036. 'bpmn:InclusiveGateway': function(p, element) {
  1037. var diamond = drawDiamond(p, element.width, element.height);
  1038. /* circle path */
  1039. drawCircle(p, element.width, element.height, element.height * 0.24, {
  1040. strokeWidth: 2.5,
  1041. fill: 'none'
  1042. });
  1043. return diamond;
  1044. },
  1045. 'bpmn:ExclusiveGateway': function(p, element) {
  1046. var diamond = drawDiamond(p, element.width, element.height);
  1047. var pathData = pathMap.getScaledPath('GATEWAY_EXCLUSIVE', {
  1048. xScaleFactor: 0.4,
  1049. yScaleFactor: 0.4,
  1050. containerWidth: element.width,
  1051. containerHeight: element.height,
  1052. position: {
  1053. mx: 0.32,
  1054. my: 0.3
  1055. }
  1056. });
  1057. if (!!(getDi(element).isMarkerVisible)) {
  1058. drawPath(p, pathData, {
  1059. strokeWidth: 1,
  1060. fill: 'black'
  1061. });
  1062. }
  1063. return diamond;
  1064. },
  1065. 'bpmn:ComplexGateway': function(p, element) {
  1066. var diamond = drawDiamond(p, element.width, element.height);
  1067. var pathData = pathMap.getScaledPath('GATEWAY_COMPLEX', {
  1068. xScaleFactor: 0.5,
  1069. yScaleFactor:0.5,
  1070. containerWidth: element.width,
  1071. containerHeight: element.height,
  1072. position: {
  1073. mx: 0.46,
  1074. my: 0.26
  1075. }
  1076. });
  1077. /* complex path */ drawPath(p, pathData, {
  1078. strokeWidth: 1,
  1079. fill: 'black'
  1080. });
  1081. return diamond;
  1082. },
  1083. 'bpmn:ParallelGateway': function(p, element) {
  1084. var diamond = drawDiamond(p, element.width, element.height);
  1085. var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
  1086. xScaleFactor: 0.6,
  1087. yScaleFactor:0.6,
  1088. containerWidth: element.width,
  1089. containerHeight: element.height,
  1090. position: {
  1091. mx: 0.46,
  1092. my: 0.2
  1093. }
  1094. });
  1095. /* parallel path */ drawPath(p, pathData, {
  1096. strokeWidth: 1,
  1097. fill: 'black'
  1098. });
  1099. return diamond;
  1100. },
  1101. 'bpmn:EventBasedGateway': function(p, element) {
  1102. var semantic = getSemantic(element);
  1103. var diamond = drawDiamond(p, element.width, element.height);
  1104. /* outer circle path */ drawCircle(p, element.width, element.height, element.height * 0.20, {
  1105. strokeWidth: 1,
  1106. fill: 'none'
  1107. });
  1108. var type = semantic.eventGatewayType;
  1109. var instantiate = !!semantic.instantiate;
  1110. function drawEvent() {
  1111. var pathData = pathMap.getScaledPath('GATEWAY_EVENT_BASED', {
  1112. xScaleFactor: 0.18,
  1113. yScaleFactor: 0.18,
  1114. containerWidth: element.width,
  1115. containerHeight: element.height,
  1116. position: {
  1117. mx: 0.36,
  1118. my: 0.44
  1119. }
  1120. });
  1121. /* event path */ drawPath(p, pathData, {
  1122. strokeWidth: 2,
  1123. fill: 'none'
  1124. });
  1125. }
  1126. if (type === 'Parallel') {
  1127. var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
  1128. xScaleFactor: 0.4,
  1129. yScaleFactor:0.4,
  1130. containerWidth: element.width,
  1131. containerHeight: element.height,
  1132. position: {
  1133. mx: 0.474,
  1134. my: 0.296
  1135. }
  1136. });
  1137. var parallelPath = drawPath(p, pathData);
  1138. parallelPath.attr({
  1139. strokeWidth: 1,
  1140. fill: 'none'
  1141. });
  1142. } else if (type === 'Exclusive') {
  1143. if (!instantiate) {
  1144. var innerCircle = drawCircle(p, element.width, element.height, element.height * 0.26);
  1145. innerCircle.attr({
  1146. strokeWidth: 1,
  1147. fill: 'none'
  1148. });
  1149. }
  1150. drawEvent();
  1151. }
  1152. return diamond;
  1153. },
  1154. 'bpmn:Gateway': function(p, element) {
  1155. return drawDiamond(p, element.width, element.height);
  1156. },
  1157. 'bpmn:SequenceFlow': function(p, element) {
  1158. var pathData = createPathFromConnection(element);
  1159. var path = drawPath(p, pathData, {
  1160. strokeLinejoin: 'round',
  1161. markerEnd: marker('sequenceflow-end')
  1162. });
  1163. var sequenceFlow = getSemantic(element);
  1164. var source = element.source.businessObject;
  1165. // conditional flow marker
  1166. if (sequenceFlow.conditionExpression && source.$instanceOf('bpmn:Task')) {
  1167. path.attr({
  1168. markerStart: marker('conditional-flow-marker')
  1169. });
  1170. }
  1171. // default marker
  1172. if (source.default && source.$instanceOf('bpmn:Gateway') && source.default === sequenceFlow) {
  1173. path.attr({
  1174. markerStart: marker('conditional-default-flow-marker')
  1175. });
  1176. }
  1177. return path;
  1178. },
  1179. 'bpmn:Association': function(p, element, attrs) {
  1180. attrs = assign({
  1181. strokeDasharray: '1,6',
  1182. strokeLinecap: 'round',
  1183. strokeLinejoin: 'round'
  1184. }, attrs || {});
  1185. // TODO(nre): style according to directed state
  1186. return drawLine(p, element.waypoints, attrs);
  1187. },
  1188. 'bpmn:DataInputAssociation': function(p, element) {
  1189. return renderer('bpmn:Association')(p, element, {
  1190. markerEnd: marker('data-association-end')
  1191. });
  1192. },
  1193. 'bpmn:DataOutputAssociation': function(p, element) {
  1194. return renderer('bpmn:Association')(p, element, {
  1195. markerEnd: marker('data-association-end')
  1196. });
  1197. },
  1198. 'bpmn:MessageFlow': function(p, element) {
  1199. var semantic = getSemantic(element),
  1200. di = getDi(element);
  1201. var pathData = createPathFromConnection(element);
  1202. var path = drawPath(p, pathData, {
  1203. markerEnd: marker('messageflow-end'),
  1204. markerStart: marker('messageflow-start'),
  1205. strokeDasharray: '10, 12',
  1206. strokeLinecap: 'round',
  1207. strokeLinejoin: 'round',
  1208. strokeWidth: '1.5px'
  1209. });
  1210. if (semantic.messageRef) {
  1211. var midPoint = path.getPointAtLength(path.getTotalLength() / 2);
  1212. var markerPathData = pathMap.getScaledPath('MESSAGE_FLOW_MARKER', {
  1213. abspos: {
  1214. x: midPoint.x,
  1215. y: midPoint.y
  1216. }
  1217. });
  1218. var messageAttrs = { strokeWidth: 1 };
  1219. if (di.messageVisibleKind === 'initiating') {
  1220. messageAttrs.fill = 'white';
  1221. messageAttrs.stroke = 'black';
  1222. } else {
  1223. messageAttrs.fill = '#888';
  1224. messageAttrs.stroke = 'white';
  1225. }
  1226. drawPath(p, markerPathData, messageAttrs);
  1227. }
  1228. return path;
  1229. },
  1230. 'bpmn:DataObject': function(p, element) {
  1231. var pathData = pathMap.getScaledPath('DATA_OBJECT_PATH', {
  1232. xScaleFactor: 1,
  1233. yScaleFactor: 1,
  1234. containerWidth: element.width,
  1235. containerHeight: element.height,
  1236. position: {
  1237. mx: 0.474,
  1238. my: 0.296
  1239. }
  1240. });
  1241. var elementObject = drawPath(p, pathData, { fill: 'white' });
  1242. var semantic = getSemantic(element);
  1243. if (isCollection(semantic)) {
  1244. renderDataItemCollection(p, element);
  1245. }
  1246. return elementObject;
  1247. },
  1248. 'bpmn:DataObjectReference': as('bpmn:DataObject'),
  1249. 'bpmn:DataInput': function(p, element) {
  1250. var arrowPathData = pathMap.getRawPath('DATA_ARROW');
  1251. // page
  1252. var elementObject = renderer('bpmn:DataObject')(p, element);
  1253. /* input arrow path */ drawPath(p, arrowPathData, { strokeWidth: 1 });
  1254. return elementObject;
  1255. },
  1256. 'bpmn:DataOutput': function(p, element) {
  1257. var arrowPathData = pathMap.getRawPath('DATA_ARROW');
  1258. // page
  1259. var elementObject = renderer('bpmn:DataObject')(p, element);
  1260. /* output arrow path */ drawPath(p, arrowPathData, {
  1261. strokeWidth: 1,
  1262. fill: 'black'
  1263. });
  1264. return elementObject;
  1265. },
  1266. 'bpmn:DataStoreReference': function(p, element) {
  1267. var DATA_STORE_PATH = pathMap.getScaledPath('DATA_STORE', {
  1268. xScaleFactor: 1,
  1269. yScaleFactor: 1,
  1270. containerWidth: element.width,
  1271. containerHeight: element.height,
  1272. position: {
  1273. mx: 0,
  1274. my: 0.133
  1275. }
  1276. });
  1277. var elementStore = drawPath(p, DATA_STORE_PATH, {
  1278. strokeWidth: 2,
  1279. fill: 'white'
  1280. });
  1281. return elementStore;
  1282. },
  1283. 'bpmn:BoundaryEvent': function(p, element) {
  1284. var semantic = getSemantic(element),
  1285. cancel = semantic.cancelActivity;
  1286. var attrs = {
  1287. strokeWidth: 1
  1288. };
  1289. if (!cancel) {
  1290. attrs.strokeDasharray = '6';
  1291. attrs.strokeLinecap = 'round';
  1292. }
  1293. var outer = renderer('bpmn:Event')(p, element, attrs);
  1294. /* inner path */ drawCircle(p, element.width, element.height, INNER_OUTER_DIST, assign(attrs, { fill: 'none' }));
  1295. renderEventContent(element, p);
  1296. return outer;
  1297. },
  1298. 'bpmn:Group': function(p, element) {
  1299. return drawRect(p, element.width, element.height, TASK_BORDER_RADIUS, {
  1300. strokeWidth: 1,
  1301. strokeDasharray: '8,3,1,3',
  1302. fill: 'none',
  1303. pointerEvents: 'none'
  1304. });
  1305. },
  1306. 'label': function(p, element) {
  1307. return renderExternalLabel(p, element, '');
  1308. },
  1309. 'bpmn:TextAnnotation': function(p, element) {
  1310. var style = {
  1311. 'fill': 'none',
  1312. 'stroke': 'none'
  1313. };
  1314. var textElement = drawRect(p, element.width, element.height, 0, 0, style);
  1315. var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', {
  1316. xScaleFactor: 1,
  1317. yScaleFactor: 1,
  1318. containerWidth: element.width,
  1319. containerHeight: element.height,
  1320. position: {
  1321. mx: 0.0,
  1322. my: 0.0
  1323. }
  1324. });
  1325. drawPath(p, textPathData);
  1326. var text = getSemantic(element).text || '';
  1327. renderLabel(p, text, { box: element, align: 'left-middle', padding: 5 });
  1328. return textElement;
  1329. },
  1330. 'ParticipantMultiplicityMarker': function(p, element) {
  1331. var subProcessPath = pathMap.getScaledPath('MARKER_PARALLEL', {
  1332. xScaleFactor: 1,
  1333. yScaleFactor: 1,
  1334. containerWidth: element.width,
  1335. containerHeight: element.height,
  1336. position: {
  1337. mx: ((element.width / 2) / element.width),
  1338. my: (element.height - 15) / element.height
  1339. }
  1340. });
  1341. drawPath(p, subProcessPath);
  1342. },
  1343. 'SubProcessMarker': function(p, element) {
  1344. var markerRect = drawRect(p, 14, 14, 0, {
  1345. strokeWidth: 1
  1346. });
  1347. // Process marker is placed in the middle of the box
  1348. // therefore fixed values can be used here
  1349. markerRect.transform('translate(' + (element.width / 2 - 7.5) + ',' + (element.height - 20) + ')');
  1350. var subProcessPath = pathMap.getScaledPath('MARKER_SUB_PROCESS', {
  1351. xScaleFactor: 1.5,
  1352. yScaleFactor: 1.5,
  1353. containerWidth: element.width,
  1354. containerHeight: element.height,
  1355. position: {
  1356. mx: (element.width / 2 - 7.5) / element.width,
  1357. my: (element.height - 20) / element.height
  1358. }
  1359. });
  1360. drawPath(p, subProcessPath);
  1361. },
  1362. 'ParallelMarker': function(p, element, position) {
  1363. var subProcessPath = pathMap.getScaledPath('MARKER_PARALLEL', {
  1364. xScaleFactor: 1,
  1365. yScaleFactor: 1,
  1366. containerWidth: element.width,
  1367. containerHeight: element.height,
  1368. position: {
  1369. mx: ((element.width / 2 + position.parallel) / element.width),
  1370. my: (element.height - 20) / element.height
  1371. }
  1372. });
  1373. drawPath(p, subProcessPath);
  1374. },
  1375. 'SequentialMarker': function(p, element, position) {
  1376. var sequentialPath = pathMap.getScaledPath('MARKER_SEQUENTIAL', {
  1377. xScaleFactor: 1,
  1378. yScaleFactor: 1,
  1379. containerWidth: element.width,
  1380. containerHeight: element.height,
  1381. position: {
  1382. mx: ((element.width / 2 + position.seq) / element.width),
  1383. my: (element.height - 19) / element.height
  1384. }
  1385. });
  1386. drawPath(p, sequentialPath);
  1387. },
  1388. 'CompensationMarker': function(p, element, position) {
  1389. var compensationPath = pathMap.getScaledPath('MARKER_COMPENSATION', {
  1390. xScaleFactor: 1,
  1391. yScaleFactor: 1,
  1392. containerWidth: element.width,
  1393. containerHeight: element.height,
  1394. position: {
  1395. mx: ((element.width / 2 + position.compensation) / element.width),
  1396. my: (element.height - 13) / element.height
  1397. }
  1398. });
  1399. drawPath(p, compensationPath, { strokeWidth: 1 });
  1400. },
  1401. 'LoopMarker': function(p, element, position) {
  1402. var loopPath = pathMap.getScaledPath('MARKER_LOOP', {
  1403. xScaleFactor: 1,
  1404. yScaleFactor: 1,
  1405. containerWidth: element.width,
  1406. containerHeight: element.height,
  1407. position: {
  1408. mx: ((element.width / 2 + position.loop) / element.width),
  1409. my: (element.height - 7) / element.height
  1410. }
  1411. });
  1412. drawPath(p, loopPath, {
  1413. strokeWidth: 1,
  1414. fill: 'none',
  1415. strokeLinecap: 'round',
  1416. strokeMiterlimit: 0.5
  1417. });
  1418. },
  1419. 'AdhocMarker': function(p, element, position) {
  1420. var loopPath = pathMap.getScaledPath('MARKER_ADHOC', {
  1421. xScaleFactor: 1,
  1422. yScaleFactor: 1,
  1423. containerWidth: element.width,
  1424. containerHeight: element.height,
  1425. position: {
  1426. mx: ((element.width / 2 + position.adhoc) / element.width),
  1427. my: (element.height - 15) / element.height
  1428. }
  1429. });
  1430. drawPath(p, loopPath, {
  1431. strokeWidth: 1,
  1432. fill: 'black'
  1433. });
  1434. }
  1435. };
  1436. function attachTaskMarkers(p, element, taskMarkers) {
  1437. var obj = getSemantic(element);
  1438. var subprocess = includes(taskMarkers, 'SubProcessMarker');
  1439. var position;
  1440. if (subprocess) {
  1441. position = {
  1442. seq: -21,
  1443. parallel: -22,
  1444. compensation: -42,
  1445. loop: -18,
  1446. adhoc: 10
  1447. };
  1448. } else {
  1449. position = {
  1450. seq: -3,
  1451. parallel: -6,
  1452. compensation: -27,
  1453. loop: 0,
  1454. adhoc: 10
  1455. };
  1456. }
  1457. forEach(taskMarkers, function(marker) {
  1458. renderer(marker)(p, element, position);
  1459. });
  1460. if (obj.$type === 'bpmn:AdHocSubProcess') {
  1461. renderer('AdhocMarker')(p, element, position);
  1462. }
  1463. if (obj.loopCharacteristics && obj.loopCharacteristics.isSequential === undefined) {
  1464. renderer('LoopMarker')(p, element, position);
  1465. return;
  1466. }
  1467. if (obj.loopCharacteristics &&
  1468. obj.loopCharacteristics.isSequential !== undefined &&
  1469. !obj.loopCharacteristics.isSequential) {
  1470. renderer('ParallelMarker')(p, element, position);
  1471. }
  1472. if (obj.loopCharacteristics && !!obj.loopCharacteristics.isSequential) {
  1473. renderer('SequentialMarker')(p, element, position);
  1474. }
  1475. if (!!obj.isForCompensation) {
  1476. renderer('CompensationMarker')(p, element, position);
  1477. }
  1478. }
  1479. function drawShape(parent, element) {
  1480. var type = element.type;
  1481. var h = handlers[type];
  1482. /* jshint -W040 */
  1483. if (!h) {
  1484. return DefaultRenderer.prototype.drawShape.apply(this, [ parent, element ]);
  1485. } else {
  1486. return h(parent, element);
  1487. }
  1488. }
  1489. function drawConnection(parent, element) {
  1490. var type = element.type;
  1491. var h = handlers[type];
  1492. /* jshint -W040 */
  1493. if (!h) {
  1494. return DefaultRenderer.prototype.drawConnection.apply(this, [ parent, element ]);
  1495. } else {
  1496. return h(parent, element);
  1497. }
  1498. }
  1499. function renderDataItemCollection(p, element) {
  1500. var yPosition = (element.height - 16) / element.height;
  1501. var pathData = pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH', {
  1502. xScaleFactor: 1,
  1503. yScaleFactor: 1,
  1504. containerWidth: element.width,
  1505. containerHeight: element.height,
  1506. position: {
  1507. mx: 0.451,
  1508. my: yPosition
  1509. }
  1510. });
  1511. /* collection path */ drawPath(p, pathData, {
  1512. strokeWidth: 2
  1513. });
  1514. }
  1515. function isCollection(element, filter) {
  1516. return element.isCollection ||
  1517. (element.elementObjectRef && element.elementObjectRef.isCollection);
  1518. }
  1519. function getDi(element) {
  1520. return element.businessObject.di;
  1521. }
  1522. function getSemantic(element) {
  1523. return element.businessObject;
  1524. }
  1525. /**
  1526. * Checks if eventDefinition of the given element matches with semantic type.
  1527. *
  1528. * @return {boolean} true if element is of the given semantic type
  1529. */
  1530. function isTypedEvent(event, eventDefinitionType, filter) {
  1531. function matches(definition, filter) {
  1532. return every(filter, function(val, key) {
  1533. // we want a == conversion here, to be able to catch
  1534. // undefined == false and friends
  1535. /* jshint -W116 */
  1536. return definition[key] == val;
  1537. });
  1538. }
  1539. return some(event.eventDefinitions, function(definition) {
  1540. return definition.$type === eventDefinitionType && matches(event, filter);
  1541. });
  1542. }
  1543. function isThrowEvent(event) {
  1544. return (event.$type === 'bpmn:IntermediateThrowEvent') || (event.$type === 'bpmn:EndEvent');
  1545. }
  1546. /////// cropping path customizations /////////////////////////
  1547. function componentsToPath(elements) {
  1548. return elements.join(',').replace(/,?([A-z]),?/g, '$1');
  1549. }
  1550. function getCirclePath(shape) {
  1551. var cx = shape.x + shape.width / 2,
  1552. cy = shape.y + shape.height / 2,
  1553. radius = shape.width / 2;
  1554. var circlePath = [
  1555. ['M', cx, cy],
  1556. ['m', 0, -radius],
  1557. ['a', radius, radius, 0, 1, 1, 0, 2 * radius],
  1558. ['a', radius, radius, 0, 1, 1, 0, -2 * radius],
  1559. ['z']
  1560. ];
  1561. return componentsToPath(circlePath);
  1562. }
  1563. function getRoundRectPath(shape) {
  1564. var radius = TASK_BORDER_RADIUS,
  1565. x = shape.x,
  1566. y = shape.y,
  1567. width = shape.width,
  1568. height = shape.height;
  1569. var roundRectPath = [
  1570. ['M', x + radius, y],
  1571. ['l', width - radius * 2, 0],
  1572. ['a', radius, radius, 0, 0, 1, radius, radius],
  1573. ['l', 0, height - radius * 2],
  1574. ['a', radius, radius, 0, 0, 1, -radius, radius],
  1575. ['l', radius * 2 - width, 0],
  1576. ['a', radius, radius, 0, 0, 1, -radius, -radius],
  1577. ['l', 0, radius * 2 - height],
  1578. ['a', radius, radius, 0, 0, 1, radius, -radius],
  1579. ['z']
  1580. ];
  1581. return componentsToPath(roundRectPath);
  1582. }
  1583. function getDiamondPath(shape) {
  1584. var width = shape.width,
  1585. height = shape.height,
  1586. x = shape.x,
  1587. y = shape.y,
  1588. halfWidth = width / 2,
  1589. halfHeight = height / 2;
  1590. var diamondPath = [
  1591. ['M', x + halfWidth, y],
  1592. ['l', halfWidth, halfHeight],
  1593. ['l', -halfWidth, halfHeight],
  1594. ['l', -halfWidth, -halfHeight],
  1595. ['z']
  1596. ];
  1597. return componentsToPath(diamondPath);
  1598. }
  1599. function getRectPath(shape) {
  1600. var x = shape.x,
  1601. y = shape.y,
  1602. width = shape.width,
  1603. height = shape.height;
  1604. var rectPath = [
  1605. ['M', x, y],
  1606. ['l', width, 0],
  1607. ['l', 0, height],
  1608. ['l', -width, 0],
  1609. ['z']
  1610. ];
  1611. return componentsToPath(rectPath);
  1612. }
  1613. function getShapePath(element) {
  1614. var obj = getSemantic(element);
  1615. if (obj.$instanceOf('bpmn:Event')) {
  1616. return getCirclePath(element);
  1617. }
  1618. if (obj.$instanceOf('bpmn:Activity')) {
  1619. return getRoundRectPath(element);
  1620. }
  1621. if (obj.$instanceOf('bpmn:Gateway')) {
  1622. return getDiamondPath(element);
  1623. }
  1624. return getRectPath(element);
  1625. }
  1626. // hook onto canvas init event to initialize
  1627. // connection start/end markers on svg
  1628. events.on('canvas.init', function(event) {
  1629. initMarkers(event.svg);
  1630. });
  1631. this.drawShape = drawShape;
  1632. this.drawConnection = drawConnection;
  1633. this.getShapePath = getShapePath;
  1634. }
  1635. inherits(BpmnRenderer, DefaultRenderer);
  1636. BpmnRenderer.$inject = [ 'eventBus', 'styles', 'pathMap' ];
  1637. module.exports = BpmnRenderer;
  1638. },{"11":11,"159":159,"163":163,"168":168,"43":43,"64":64,"72":72,"74":74,"77":77,"79":79,"82":82}],4:[function(_dereq_,module,exports){
  1639. 'use strict';
  1640. var Snap = _dereq_(67);
  1641. /**
  1642. * Map containing SVG paths needed by BpmnRenderer.
  1643. */
  1644. function PathMap() {
  1645. /**
  1646. * Contains a map of path elements
  1647. *
  1648. * <h1>Path definition</h1>
  1649. * A parameterized path is defined like this:
  1650. * <pre>
  1651. * 'GATEWAY_PARALLEL': {
  1652. * d: 'm {mx},{my} {e.x0},0 0,{e.x1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} ' +
  1653. '-{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z',
  1654. * height: 17.5,
  1655. * width: 17.5,
  1656. * heightElements: [2.5, 7.5],
  1657. * widthElements: [2.5, 7.5]
  1658. * }
  1659. * </pre>
  1660. * <p>It's important to specify a correct <b>height and width</b> for the path as the scaling
  1661. * is based on the ratio between the specified height and width in this object and the
  1662. * height and width that is set as scale target (Note x,y coordinates will be scaled with
  1663. * individual ratios).</p>
  1664. * <p>The '<b>heightElements</b>' and '<b>widthElements</b>' array must contain the values that will be scaled.
  1665. * The scaling is based on the computed ratios.
  1666. * Coordinates on the y axis should be in the <b>heightElement</b>'s array, they will be scaled using
  1667. * the computed ratio coefficient.
  1668. * In the parameterized path the scaled values can be accessed through the 'e' object in {} brackets.
  1669. * <ul>
  1670. * <li>The values for the y axis can be accessed in the path string using {e.y0}, {e.y1}, ....</li>
  1671. * <li>The values for the x axis can be accessed in the path string using {e.x0}, {e.x1}, ....</li>
  1672. * </ul>
  1673. * The numbers x0, x1 respectively y0, y1, ... map to the corresponding array index.
  1674. * </p>
  1675. */
  1676. this.pathMap = {
  1677. 'EVENT_MESSAGE': {
  1678. 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}',
  1679. height: 36,
  1680. width: 36,
  1681. heightElements: [6, 14],
  1682. widthElements: [10.5, 21]
  1683. },
  1684. 'EVENT_SIGNAL': {
  1685. d: 'M {mx},{my} l {e.x0},{e.y0} l -{e.x1},0 Z',
  1686. height: 36,
  1687. width: 36,
  1688. heightElements: [18],
  1689. widthElements: [10, 20]
  1690. },
  1691. 'EVENT_ESCALATION': {
  1692. 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} ' +
  1693. '{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',
  1694. height: 36,
  1695. width: 36,
  1696. heightElements: [2.382, 4.764, 4.926, 6.589333, 7.146, 13.178667, 19.768],
  1697. widthElements: [2.463, 2.808, 4.926, 5.616, 7.389, 8.424]
  1698. },
  1699. 'EVENT_CONDITIONAL': {
  1700. d: 'M {e.x0},{e.y0} l {e.x1},0 l 0,{e.y2} l -{e.x1},0 Z ' +
  1701. 'M {e.x2},{e.y3} l {e.x0},0 ' +
  1702. 'M {e.x2},{e.y4} l {e.x0},0 ' +
  1703. 'M {e.x2},{e.y5} l {e.x0},0 ' +
  1704. 'M {e.x2},{e.y6} l {e.x0},0 ' +
  1705. 'M {e.x2},{e.y7} l {e.x0},0 ' +
  1706. 'M {e.x2},{e.y8} l {e.x0},0 ',
  1707. height: 36,
  1708. width: 36,
  1709. heightElements: [8.5, 14.5, 18, 11.5, 14.5, 17.5, 20.5, 23.5, 26.5],
  1710. widthElements: [10.5, 14.5, 12.5]
  1711. },
  1712. 'EVENT_LINK': {
  1713. 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',
  1714. height: 36,
  1715. width: 36,
  1716. heightElements: [4.4375, 6.75, 7.8125],
  1717. widthElements: [9.84375, 13.5]
  1718. },
  1719. 'EVENT_ERROR': {
  1720. 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',
  1721. height: 36,
  1722. width: 36,
  1723. heightElements: [0.023, 8.737, 8.151, 16.564, 10.591, 8.714],
  1724. widthElements: [0.085, 6.672, 6.97, 4.273, 5.337, 6.636]
  1725. },
  1726. 'EVENT_CANCEL_45': {
  1727. d: 'm {mx},{my} -{e.x1},0 0,{e.x0} {e.x1},0 0,{e.y1} {e.x0},0 ' +
  1728. '0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z',
  1729. height: 36,
  1730. width: 36,
  1731. heightElements: [4.75, 8.5],
  1732. widthElements: [4.75, 8.5]
  1733. },
  1734. 'EVENT_COMPENSATION': {
  1735. d: 'm {mx},{my} {e.x0},-{e.y0} 0,{e.y1} z m {e.x0},0 {e.x0},-{e.y0} 0,{e.y1} z',
  1736. height: 36,
  1737. width: 36,
  1738. heightElements: [5, 10],
  1739. widthElements: [10]
  1740. },
  1741. 'EVENT_TIMER_WH': {
  1742. d: 'M {mx},{my} l {e.x0},-{e.y0} m -{e.x0},{e.y0} l {e.x1},{e.y1} ',
  1743. height: 36,
  1744. width: 36,
  1745. heightElements: [10, 2],
  1746. widthElements: [3, 7]
  1747. },
  1748. 'EVENT_TIMER_LINE': {
  1749. d: 'M {mx},{my} ' +
  1750. 'm {e.x0},{e.y0} l -{e.x1},{e.y1} ',
  1751. height: 36,
  1752. width: 36,
  1753. heightElements: [10, 3],
  1754. widthElements: [0, 0]
  1755. },
  1756. 'EVENT_MULTIPLE': {
  1757. d:'m {mx},{my} {e.x1},-{e.y0} {e.x1},{e.y0} -{e.x0},{e.y1} -{e.x2},0 z',
  1758. height: 36,
  1759. width: 36,
  1760. heightElements: [6.28099, 12.56199],
  1761. widthElements: [3.1405, 9.42149, 12.56198]
  1762. },
  1763. 'EVENT_PARALLEL_MULTIPLE': {
  1764. d:'m {mx},{my} {e.x0},0 0,{e.y1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} ' +
  1765. '-{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z',
  1766. height: 36,
  1767. width: 36,
  1768. heightElements: [2.56228, 7.68683],
  1769. widthElements: [2.56228, 7.68683]
  1770. },
  1771. 'GATEWAY_EXCLUSIVE': {
  1772. d:'m {mx},{my} {e.x0},{e.y0} {e.x1},{e.y0} {e.x2},0 {e.x4},{e.y2} ' +
  1773. '{e.x4},{e.y1} {e.x2},0 {e.x1},{e.y3} {e.x0},{e.y3} ' +
  1774. '{e.x3},0 {e.x5},{e.y1} {e.x5},{e.y2} {e.x3},0 z',
  1775. height: 17.5,
  1776. width: 17.5,
  1777. heightElements: [8.5, 6.5312, -6.5312, -8.5],
  1778. widthElements: [6.5, -6.5, 3, -3, 5, -5]
  1779. },
  1780. 'GATEWAY_PARALLEL': {
  1781. d:'m {mx},{my} 0,{e.y1} -{e.x1},0 0,{e.y0} {e.x1},0 0,{e.y1} {e.x0},0 ' +
  1782. '0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z',
  1783. height: 30,
  1784. width: 30,
  1785. heightElements: [5, 12.5],
  1786. widthElements: [5, 12.5]
  1787. },
  1788. 'GATEWAY_EVENT_BASED': {
  1789. d:'m {mx},{my} {e.x0},{e.y0} {e.x0},{e.y1} {e.x1},{e.y2} {e.x2},0 z',
  1790. height: 11,
  1791. width: 11,
  1792. heightElements: [-6, 6, 12, -12],
  1793. widthElements: [9, -3, -12]
  1794. },
  1795. 'GATEWAY_COMPLEX': {
  1796. 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} ' +
  1797. '{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} ' +
  1798. '{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} ' +
  1799. '-{e.x0},{e.y1} 0,-{e.y0} -{e.x3},0 z',
  1800. height: 17.125,
  1801. width: 17.125,
  1802. heightElements: [4.875, 3.4375, 2.125, 3],
  1803. widthElements: [3.4375, 2.125, 4.875, 3]
  1804. },
  1805. 'DATA_OBJECT_PATH': {
  1806. 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',
  1807. height: 61,
  1808. width: 51,
  1809. heightElements: [10, 50, 60],
  1810. widthElements: [10, 40, 50, 60]
  1811. },
  1812. 'DATA_OBJECT_COLLECTION_PATH': {
  1813. d:'m {mx}, {my} ' +
  1814. 'm 0 15 l 0 -15 ' +
  1815. 'm 4 15 l 0 -15 ' +
  1816. 'm 4 15 l 0 -15 ',
  1817. height: 61,
  1818. width: 51,
  1819. heightElements: [12],
  1820. widthElements: [1, 6, 12, 15]
  1821. },
  1822. 'DATA_ARROW': {
  1823. d:'m 5,9 9,0 0,-3 5,5 -5,5 0,-3 -9,0 z',
  1824. height: 61,
  1825. width: 51,
  1826. heightElements: [],
  1827. widthElements: []
  1828. },
  1829. 'DATA_STORE': {
  1830. d:'m {mx},{my} ' +
  1831. 'l 0,{e.y2} ' +
  1832. 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 ' +
  1833. 'l 0,-{e.y2} ' +
  1834. 'c -{e.x0},-{e.y1} -{e.x1},-{e.y1} -{e.x2},0' +
  1835. 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 ' +
  1836. 'm -{e.x2},{e.y0}' +
  1837. 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0' +
  1838. 'm -{e.x2},{e.y0}' +
  1839. 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0',
  1840. height: 61,
  1841. width: 61,
  1842. heightElements: [7, 10, 45],
  1843. widthElements: [2, 58, 60]
  1844. },
  1845. 'TEXT_ANNOTATION': {
  1846. d: 'm {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0',
  1847. height: 30,
  1848. width: 10,
  1849. heightElements: [30],
  1850. widthElements: [10]
  1851. },
  1852. 'MARKER_SUB_PROCESS': {
  1853. d: 'm{mx},{my} m 7,2 l 0,10 m -5,-5 l 10,0',
  1854. height: 10,
  1855. width: 10,
  1856. heightElements: [],
  1857. widthElements: []
  1858. },
  1859. 'MARKER_PARALLEL': {
  1860. d: 'm{mx},{my} m 3,2 l 0,10 m 3,-10 l 0,10 m 3,-10 l 0,10',
  1861. height: 10,
  1862. width: 10,
  1863. heightElements: [],
  1864. widthElements: []
  1865. },
  1866. 'MARKER_SEQUENTIAL': {
  1867. d: 'm{mx},{my} m 0,3 l 10,0 m -10,3 l 10,0 m -10,3 l 10,0',
  1868. height: 10,
  1869. width: 10,
  1870. heightElements: [],
  1871. widthElements: []
  1872. },
  1873. 'MARKER_COMPENSATION': {
  1874. d: 'm {mx},{my} 8,-5 0,10 z m 9,0 8,-5 0,10 z',
  1875. height: 10,
  1876. width: 21,
  1877. heightElements: [],
  1878. widthElements: []
  1879. },
  1880. 'MARKER_LOOP': {
  1881. d: 'm {mx},{my} c 3.526979,0 6.386161,-2.829858 6.386161,-6.320661 0,-3.490806 -2.859182,-6.320661 ' +
  1882. '-6.386161,-6.320661 -3.526978,0 -6.38616,2.829855 -6.38616,6.320661 0,1.745402 ' +
  1883. '0.714797,3.325567 1.870463,4.469381 0.577834,0.571908 1.265885,1.034728 2.029916,1.35457 ' +
  1884. 'l -0.718163,-3.909793 m 0.718163,3.909793 -3.885211,0.802902',
  1885. height: 13.9,
  1886. width: 13.7,
  1887. heightElements: [],
  1888. widthElements: []
  1889. },
  1890. 'MARKER_ADHOC': {
  1891. 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 ' +
  1892. '3.85579,1.15803 5.76082,1.79107 1.06385,0.34139996 2.24454,0.1438 3.18759,-0.43767 0.61743,-0.33642 ' +
  1893. '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 ' +
  1894. '-3.6918,1.66181996 -1.24459,0.0927 -2.46671,-0.2491 -3.59505,-0.74812 -1.35789,-0.55965 ' +
  1895. '-2.75133,-1.33436996 -4.27027,-1.18121996 -1.37741,0.14601 -2.41842,1.13685996 -3.44288,1.96782996 z',
  1896. height: 4,
  1897. width: 15,
  1898. heightElements: [],
  1899. widthElements: []
  1900. },
  1901. 'TASK_TYPE_SEND': {
  1902. 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}',
  1903. height: 14,
  1904. width: 21,
  1905. heightElements: [6, 14],
  1906. widthElements: [10.5, 21]
  1907. },
  1908. 'TASK_TYPE_SCRIPT': {
  1909. d: 'm {mx},{my} c 9.966553,-6.27276 -8.000926,-7.91932 2.968968,-14.938 l -8.802728,0 ' +
  1910. 'c -10.969894,7.01868 6.997585,8.66524 -2.968967,14.938 z ' +
  1911. 'm -7,-12 l 5,0 ' +
  1912. 'm -4.5,3 l 4.5,0 ' +
  1913. 'm -3,3 l 5,0' +
  1914. 'm -4,3 l 5,0',
  1915. height: 15,
  1916. width: 12.6,
  1917. heightElements: [6, 14],
  1918. widthElements: [10.5, 21]
  1919. },
  1920. 'TASK_TYPE_USER_1': {
  1921. d: 'm {mx},{my} c 0.909,-0.845 1.594,-2.049 1.594,-3.385 0,-2.554 -1.805,-4.62199999 ' +
  1922. '-4.357,-4.62199999 -2.55199998,0 -4.28799998,2.06799999 -4.28799998,4.62199999 0,1.348 ' +
  1923. '0.974,2.562 1.89599998,3.405 -0.52899998,0.187 -5.669,2.097 -5.794,4.7560005 v 6.718 ' +
  1924. 'h 17 v -6.718 c 0,-2.2980005 -5.5279996,-4.5950005 -6.0509996,-4.7760005 z' +
  1925. 'm -8,6 l 0,5.5 m 11,0 l 0,-5'
  1926. },
  1927. 'TASK_TYPE_USER_2': {
  1928. d: 'm {mx},{my} m 2.162,1.009 c 0,2.4470005 -2.158,4.4310005 -4.821,4.4310005 ' +
  1929. '-2.66499998,0 -4.822,-1.981 -4.822,-4.4310005 '
  1930. },
  1931. 'TASK_TYPE_USER_3': {
  1932. 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 ' +
  1933. '4.124,0.965 -0.098,-0.57 -0.117,-3.79099999 -4.191,-4.13599999 -3.57499998,0.001 ' +
  1934. '-4.20799998,3.36699999 -4.20699998,4.34799999 z'
  1935. },
  1936. 'TASK_TYPE_MANUAL': {
  1937. 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 ' +
  1938. '-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 ' +
  1939. '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 ' +
  1940. '-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 ' +
  1941. '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 ' +
  1942. '-10.86,-0.003 -11.0829995,-0.003 -0.022,-0.047 -0.045,-0.094 -0.069,-0.139 0.3939995,-0.319 ' +
  1943. '2.0409995,-1.626 2.4149995,-2.017 0.469,-0.4870005 0.519,-1.1650005 0.162,-1.6040005 -0.414,-0.511 ' +
  1944. '-0.973,-0.5 -1.48,-0.236 -1.4609995,0.764 -6.5999995,3.6430005 -7.7329995,4.2710005 -0.9,0.499 ' +
  1945. '-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 ' +
  1946. '-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 ' +
  1947. '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 ' +
  1948. '-5.824,-0.004 -6.04,-0.004 10e-4,-0.084 0.003,-0.586 10e-4,-0.67 z'
  1949. },
  1950. 'TASK_TYPE_INSTANTIATING_SEND': {
  1951. 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'
  1952. },
  1953. 'TASK_TYPE_SERVICE': {
  1954. d: 'm {mx},{my} v -1.71335 c 0.352326,-0.0705 0.703932,-0.17838 1.047628,-0.32133 ' +
  1955. '0.344416,-0.14465 0.665822,-0.32133 0.966377,-0.52145 l 1.19431,1.18005 1.567487,-1.57688 ' +
  1956. '-1.195028,-1.18014 c 0.403376,-0.61394 0.683079,-1.29908 0.825447,-2.01824 l 1.622133,-0.01 ' +
  1957. 'v -2.2196 l -1.636514,0.01 c -0.07333,-0.35153 -0.178319,-0.70024 -0.323564,-1.04372 ' +
  1958. '-0.145244,-0.34406 -0.321407,-0.6644 -0.522735,-0.96217 l 1.131035,-1.13631 -1.583305,-1.56293 ' +
  1959. '-1.129598,1.13589 c -0.614052,-0.40108 -1.302883,-0.68093 -2.022633,-0.82247 l 0.0093,-1.61852 ' +
  1960. '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 ' +
  1961. '-0.665102,0.32092 -0.9635006,0.52046 l -1.1698628,-1.15823 -1.5667691,1.5792 1.1684265,1.15669 ' +
  1962. 'c -0.4026573,0.61283 -0.68308,1.29797 -0.8247287,2.01713 l -1.6588041,0.003 v 2.22174 ' +
  1963. 'l 1.6724648,-0.006 c 0.073327,0.35077 0.1797598,0.70243 0.3242851,1.04472 0.1452428,0.34448 ' +
  1964. '0.3214064,0.6644 0.5227339,0.96066 l -1.1993431,1.19723 1.5840256,1.56011 1.1964668,-1.19348 ' +
  1965. 'c 0.6140517,0.40346 1.3028827,0.68232 2.0233517,0.82331 l 7.19e-4,1.69892 h 2.226848 z ' +
  1966. 'm 0.221462,-3.9957 c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 ' +
  1967. '0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 ' +
  1968. '0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z'
  1969. },
  1970. 'TASK_TYPE_SERVICE_FILL': {
  1971. d: 'm {mx},{my} c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 ' +
  1972. '0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 ' +
  1973. '0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z'
  1974. },
  1975. 'TASK_TYPE_BUSINESS_RULE_HEADER': {
  1976. d: 'm {mx},{my} 0,4 20,0 0,-4 z'
  1977. },
  1978. 'TASK_TYPE_BUSINESS_RULE_MAIN': {
  1979. d: 'm {mx},{my} 0,12 20,0 0,-12 z' +
  1980. 'm 0,8 l 20,0 ' +
  1981. 'm -13,-4 l 0,8'
  1982. },
  1983. 'MESSAGE_FLOW_MARKER': {
  1984. 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'
  1985. }
  1986. };
  1987. this.getRawPath = function getRawPath(pathId) {
  1988. return this.pathMap[pathId].d;
  1989. };
  1990. /**
  1991. * Scales the path to the given height and width.
  1992. * <h1>Use case</h1>
  1993. * <p>Use case is to scale the content of elements (event, gateways) based
  1994. * on the element bounding box's size.
  1995. * </p>
  1996. * <h1>Why not transform</h1>
  1997. * <p>Scaling a path with transform() will also scale the stroke and IE does not support
  1998. * the option 'non-scaling-stroke' to prevent this.
  1999. * Also there are use cases where only some parts of a path should be
  2000. * scaled.</p>
  2001. *
  2002. * @param {String} pathId The ID of the path.
  2003. * @param {Object} param <p>
  2004. * Example param object scales the path to 60% size of the container (data.width, data.height).
  2005. * <pre>
  2006. * {
  2007. * xScaleFactor: 0.6,
  2008. * yScaleFactor:0.6,
  2009. * containerWidth: data.width,
  2010. * containerHeight: data.height,
  2011. * position: {
  2012. * mx: 0.46,
  2013. * my: 0.2,
  2014. * }
  2015. * }
  2016. * </pre>
  2017. * <ul>
  2018. * <li>targetpathwidth = xScaleFactor * containerWidth</li>
  2019. * <li>targetpathheight = yScaleFactor * containerHeight</li>
  2020. * <li>Position is used to set the starting coordinate of the path. M is computed:
  2021. * <ul>
  2022. * <li>position.x * containerWidth</li>
  2023. * <li>position.y * containerHeight</li>
  2024. * </ul>
  2025. * Center of the container <pre> position: {
  2026. * mx: 0.5,
  2027. * my: 0.5,
  2028. * }</pre>
  2029. * Upper left corner of the container
  2030. * <pre> position: {
  2031. * mx: 0.0,
  2032. * my: 0.0,
  2033. * }</pre>
  2034. * </li>
  2035. * </ul>
  2036. * </p>
  2037. *
  2038. */
  2039. this.getScaledPath = function getScaledPath(pathId, param) {
  2040. var rawPath = this.pathMap[pathId];
  2041. // positioning
  2042. // compute the start point of the path
  2043. var mx, my;
  2044. if(!!param.abspos) {
  2045. mx = param.abspos.x;
  2046. my = param.abspos.y;
  2047. } else {
  2048. mx = param.containerWidth * param.position.mx;
  2049. my = param.containerHeight * param.position.my;
  2050. }
  2051. var coordinates = {}; //map for the scaled coordinates
  2052. if(param.position) {
  2053. // path
  2054. var heightRatio = (param.containerHeight / rawPath.height) * param.yScaleFactor;
  2055. var widthRatio = (param.containerWidth / rawPath.width) * param.xScaleFactor;
  2056. //Apply height ratio
  2057. for (var heightIndex = 0; heightIndex < rawPath.heightElements.length; heightIndex++) {
  2058. coordinates['y' + heightIndex] = rawPath.heightElements[heightIndex] * heightRatio;
  2059. }
  2060. //Apply width ratio
  2061. for (var widthIndex = 0; widthIndex < rawPath.widthElements.length; widthIndex++) {
  2062. coordinates['x' + widthIndex] = rawPath.widthElements[widthIndex] * widthRatio;
  2063. }
  2064. }
  2065. //Apply value to raw path
  2066. var path = Snap.format(
  2067. rawPath.d, {
  2068. mx: mx,
  2069. my: my,
  2070. e: coordinates
  2071. }
  2072. );
  2073. return path;
  2074. };
  2075. }
  2076. module.exports = PathMap;
  2077. },{"67":67}],5:[function(_dereq_,module,exports){
  2078. module.exports = {
  2079. renderer: [ 'type', _dereq_(3) ],
  2080. pathMap: [ 'type', _dereq_(4) ]
  2081. };
  2082. },{"3":3,"4":4}],6:[function(_dereq_,module,exports){
  2083. 'use strict';
  2084. var assign = _dereq_(168),
  2085. map = _dereq_(80);
  2086. var LabelUtil = _dereq_(12);
  2087. var is = _dereq_(13).is;
  2088. var hasExternalLabel = LabelUtil.hasExternalLabel,
  2089. getExternalLabelBounds = LabelUtil.getExternalLabelBounds,
  2090. isExpanded = _dereq_(11).isExpanded,
  2091. elementToString = _dereq_(9).elementToString;
  2092. function elementData(semantic, attrs) {
  2093. return assign({
  2094. id: semantic.id,
  2095. type: semantic.$type,
  2096. businessObject: semantic
  2097. }, attrs);
  2098. }
  2099. function collectWaypoints(waypoints) {
  2100. return map(waypoints, function(p) {
  2101. return { x: p.x, y: p.y };
  2102. });
  2103. }
  2104. function notYetDrawn(semantic, refSemantic, property) {
  2105. return new Error(
  2106. 'element ' + elementToString(refSemantic) + ' referenced by ' +
  2107. elementToString(semantic) + '#' + property + ' not yet drawn');
  2108. }
  2109. /**
  2110. * An importer that adds bpmn elements to the canvas
  2111. *
  2112. * @param {EventBus} eventBus
  2113. * @param {Canvas} canvas
  2114. * @param {ElementFactory} elementFactory
  2115. * @param {ElementRegistry} elementRegistry
  2116. */
  2117. function BpmnImporter(eventBus, canvas, elementFactory, elementRegistry) {
  2118. this._eventBus = eventBus;
  2119. this._canvas = canvas;
  2120. this._elementFactory = elementFactory;
  2121. this._elementRegistry = elementRegistry;
  2122. }
  2123. BpmnImporter.$inject = [ 'eventBus', 'canvas', 'elementFactory', 'elementRegistry' ];
  2124. module.exports = BpmnImporter;
  2125. /**
  2126. * Add bpmn element (semantic) to the canvas onto the
  2127. * specified parent shape.
  2128. */
  2129. BpmnImporter.prototype.add = function(semantic, parentElement) {
  2130. var di = semantic.di,
  2131. element;
  2132. // ROOT ELEMENT
  2133. // handle the special case that we deal with a
  2134. // invisible root element (process or collaboration)
  2135. if (di.$instanceOf('bpmndi:BPMNPlane')) {
  2136. // add a virtual element (not being drawn)
  2137. element = this._elementFactory.createRoot(elementData(semantic));
  2138. this._canvas.setRootElement(element);
  2139. }
  2140. // SHAPE
  2141. else if (di.$instanceOf('bpmndi:BPMNShape')) {
  2142. var collapsed = !isExpanded(semantic);
  2143. var hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
  2144. var bounds = semantic.di.bounds;
  2145. element = this._elementFactory.createShape(elementData(semantic, {
  2146. collapsed: collapsed,
  2147. hidden: hidden,
  2148. x: Math.round(bounds.x),
  2149. y: Math.round(bounds.y),
  2150. width: Math.round(bounds.width),
  2151. height: Math.round(bounds.height)
  2152. }));
  2153. if (is(semantic, 'bpmn:BoundaryEvent')) {
  2154. this._attachBoundary(semantic, element);
  2155. }
  2156. this._canvas.addShape(element, parentElement);
  2157. }
  2158. // CONNECTION
  2159. else if (di.$instanceOf('bpmndi:BPMNEdge')) {
  2160. var source = this._getSource(semantic),
  2161. target = this._getTarget(semantic);
  2162. element = this._elementFactory.createConnection(elementData(semantic, {
  2163. source: source,
  2164. target: target,
  2165. waypoints: collectWaypoints(semantic.di.waypoint)
  2166. }));
  2167. this._canvas.addConnection(element, parentElement);
  2168. } else {
  2169. throw new Error('unknown di ' + elementToString(di) + ' for element ' + elementToString(semantic));
  2170. }
  2171. // (optional) LABEL
  2172. if (hasExternalLabel(semantic)) {
  2173. this.addLabel(semantic, element);
  2174. }
  2175. this._eventBus.fire('bpmnElement.added', { element: element });
  2176. return element;
  2177. };
  2178. /**
  2179. * Attach the boundary element to the given host
  2180. *
  2181. * @param {ModdleElement} boundarySemantic
  2182. * @param {djs.model.Base} boundaryElement
  2183. */
  2184. BpmnImporter.prototype._attachBoundary = function(boundarySemantic, boundaryElement) {
  2185. var hostSemantic = boundarySemantic.attachedToRef;
  2186. if (!hostSemantic) {
  2187. throw new Error('missing ' + elementToString(boundarySemantic) + '#attachedToRef');
  2188. }
  2189. var host = this._elementRegistry.get(hostSemantic.id),
  2190. attachers = host && host.attachers;
  2191. if (!host) {
  2192. throw notYetDrawn(boundarySemantic, hostSemantic, 'attachedToRef');
  2193. }
  2194. // wire element.host <> host.attachers
  2195. boundaryElement.host = host;
  2196. if (!attachers) {
  2197. host.attachers = attachers = [];
  2198. }
  2199. if (attachers.indexOf(boundaryElement) === -1) {
  2200. attachers.push(boundaryElement);
  2201. }
  2202. };
  2203. /**
  2204. * add label for an element
  2205. */
  2206. BpmnImporter.prototype.addLabel = function(semantic, element) {
  2207. var bounds = getExternalLabelBounds(semantic, element);
  2208. var label = this._elementFactory.createLabel(elementData(semantic, {
  2209. id: semantic.id + '_label',
  2210. labelTarget: element,
  2211. type: 'label',
  2212. hidden: element.hidden,
  2213. x: Math.round(bounds.x),
  2214. y: Math.round(bounds.y),
  2215. width: Math.round(bounds.width),
  2216. height: Math.round(bounds.height)
  2217. }));
  2218. return this._canvas.addShape(label, element.parent);
  2219. };
  2220. /**
  2221. * Return the drawn connection end based on the given side.
  2222. *
  2223. * @throws {Error} if the end is not yet drawn
  2224. */
  2225. BpmnImporter.prototype._getEnd = function(semantic, side) {
  2226. var element,
  2227. refSemantic,
  2228. type = semantic.$type;
  2229. refSemantic = semantic[side + 'Ref'];
  2230. // handle mysterious isMany DataAssociation#sourceRef
  2231. if (side === 'source' && type === 'bpmn:DataInputAssociation') {
  2232. refSemantic = refSemantic && refSemantic[0];
  2233. }
  2234. // fix source / target for DataInputAssociation / DataOutputAssociation
  2235. if (side === 'source' && type === 'bpmn:DataOutputAssociation' ||
  2236. side === 'target' && type === 'bpmn:DataInputAssociation') {
  2237. refSemantic = semantic.$parent;
  2238. }
  2239. element = refSemantic && this._getElement(refSemantic);
  2240. if (element) {
  2241. return element;
  2242. }
  2243. if (refSemantic) {
  2244. throw notYetDrawn(semantic, refSemantic, side + 'Ref');
  2245. } else {
  2246. throw new Error(elementToString(semantic) + '#' + side + 'Ref not specified');
  2247. }
  2248. };
  2249. BpmnImporter.prototype._getSource = function(semantic) {
  2250. return this._getEnd(semantic, 'source');
  2251. };
  2252. BpmnImporter.prototype._getTarget = function(semantic) {
  2253. return this._getEnd(semantic, 'target');
  2254. };
  2255. BpmnImporter.prototype._getElement = function(semantic) {
  2256. return this._elementRegistry.get(semantic.id);
  2257. };
  2258. },{"11":11,"12":12,"13":13,"168":168,"80":80,"9":9}],7:[function(_dereq_,module,exports){
  2259. 'use strict';
  2260. var filter = _dereq_(75),
  2261. find = _dereq_(76),
  2262. forEach = _dereq_(77);
  2263. var Refs = _dereq_(192);
  2264. var elementToString = _dereq_(9).elementToString;
  2265. var diRefs = new Refs({ name: 'bpmnElement', enumerable: true }, { name: 'di' });
  2266. /**
  2267. * Returns true if an element has the given meta-model type
  2268. *
  2269. * @param {ModdleElement} element
  2270. * @param {String} type
  2271. *
  2272. * @return {Boolean}
  2273. */
  2274. function is(element, type) {
  2275. return element.$instanceOf(type);
  2276. }
  2277. /**
  2278. * Find a suitable display candidate for definitions where the DI does not
  2279. * correctly specify one.
  2280. */
  2281. function findDisplayCandidate(definitions) {
  2282. return find(definitions.rootElements, function(e) {
  2283. return is(e, 'bpmn:Process') || is(e, 'bpmn:Collaboration');
  2284. });
  2285. }
  2286. function BpmnTreeWalker(handler) {
  2287. // list of containers already walked
  2288. var handledProcesses = [];
  2289. // list of elements to handle deferred to ensure
  2290. // prerequisites are drawn
  2291. var deferred = [];
  2292. ///// Helpers /////////////////////////////////
  2293. function contextual(fn, ctx) {
  2294. return function(e) {
  2295. fn(e, ctx);
  2296. };
  2297. }
  2298. function visit(element, ctx) {
  2299. var gfx = element.gfx;
  2300. // avoid multiple rendering of elements
  2301. if (gfx) {
  2302. throw new Error('already rendered ' + elementToString(element));
  2303. }
  2304. // call handler
  2305. return handler.element(element, ctx);
  2306. }
  2307. function visitRoot(element, diagram) {
  2308. return handler.root(element, diagram);
  2309. }
  2310. function visitIfDi(element, ctx) {
  2311. try {
  2312. return element.di && visit(element, ctx);
  2313. } catch (e) {
  2314. logError(e.message, { element: element, error: e });
  2315. console.error('failed to import ' + elementToString(element));
  2316. console.error(e);
  2317. }
  2318. }
  2319. function logError(message, context) {
  2320. handler.error(message, context);
  2321. }
  2322. ////// DI handling ////////////////////////////
  2323. function registerDi(di) {
  2324. var bpmnElement = di.bpmnElement;
  2325. if (bpmnElement) {
  2326. if (bpmnElement.di) {
  2327. logError('multiple DI elements defined for ' + elementToString(bpmnElement), { element: bpmnElement });
  2328. } else {
  2329. diRefs.bind(bpmnElement, 'di');
  2330. bpmnElement.di = di;
  2331. }
  2332. } else {
  2333. logError('no bpmnElement referenced in ' + elementToString(di), { element: di });
  2334. }
  2335. }
  2336. function handleDiagram(diagram) {
  2337. handlePlane(diagram.plane);
  2338. }
  2339. function handlePlane(plane) {
  2340. registerDi(plane);
  2341. forEach(plane.planeElement, handlePlaneElement);
  2342. }
  2343. function handlePlaneElement(planeElement) {
  2344. registerDi(planeElement);
  2345. }
  2346. ////// Semantic handling //////////////////////
  2347. function handleDefinitions(definitions, diagram) {
  2348. // make sure we walk the correct bpmnElement
  2349. var diagrams = definitions.diagrams;
  2350. if (diagram && diagrams.indexOf(diagram) === -1) {
  2351. throw new Error('diagram not part of bpmn:Definitions');
  2352. }
  2353. if (!diagram && diagrams && diagrams.length) {
  2354. diagram = diagrams[0];
  2355. }
  2356. // no diagram -> nothing to import
  2357. if (!diagram) {
  2358. return;
  2359. }
  2360. // load DI from selected diagram only
  2361. handleDiagram(diagram);
  2362. var plane = diagram.plane;
  2363. if (!plane) {
  2364. throw new Error('no plane for ' + elementToString(diagram));
  2365. }
  2366. var rootElement = plane.bpmnElement;
  2367. // ensure we default to a suitable display candidate (process or collaboration),
  2368. // even if non is specified in DI
  2369. if (!rootElement) {
  2370. rootElement = findDisplayCandidate(definitions);
  2371. if (!rootElement) {
  2372. return logError('no process or collaboration present to display');
  2373. } else {
  2374. logError('correcting missing bpmnElement on ' + elementToString(plane) + ' to ' + elementToString(rootElement));
  2375. // correct DI on the fly
  2376. plane.bpmnElement = rootElement;
  2377. registerDi(plane);
  2378. }
  2379. }
  2380. var ctx = visitRoot(rootElement, plane);
  2381. if (is(rootElement, 'bpmn:Process')) {
  2382. handleProcess(rootElement, ctx);
  2383. } else if (is(rootElement, 'bpmn:Collaboration')) {
  2384. handleCollaboration(rootElement, ctx);
  2385. // force drawing of everything not yet drawn that is part of the target DI
  2386. handleUnhandledProcesses(definitions.rootElements, ctx);
  2387. } else {
  2388. throw new Error('unsupported bpmnElement for ' + elementToString(plane) + ' : ' + elementToString(rootElement));
  2389. }
  2390. // handle all deferred elements
  2391. handleDeferred(deferred);
  2392. }
  2393. function handleDeferred(deferred) {
  2394. forEach(deferred, function(d) { d(); });
  2395. }
  2396. function handleProcess(process, context) {
  2397. handleFlowElementsContainer(process, context);
  2398. handleIoSpecification(process.ioSpecification, context);
  2399. handleArtifacts(process.artifacts, context);
  2400. // log process handled
  2401. handledProcesses.push(process);
  2402. }
  2403. function handleUnhandledProcesses(rootElements) {
  2404. // walk through all processes that have not yet been drawn and draw them
  2405. // if they contain lanes with DI information.
  2406. // we do this to pass the free-floating lane test cases in the MIWG test suite
  2407. var processes = filter(rootElements, function(e) {
  2408. return is(e, 'bpmn:Process') && e.laneSets && handledProcesses.indexOf(e) === -1;
  2409. });
  2410. processes.forEach(contextual(handleProcess));
  2411. }
  2412. function handleMessageFlow(messageFlow, context) {
  2413. visitIfDi(messageFlow, context);
  2414. }
  2415. function handleMessageFlows(messageFlows, context) {
  2416. forEach(messageFlows, contextual(handleMessageFlow, context));
  2417. }
  2418. function handleDataAssociation(association, context) {
  2419. visitIfDi(association, context);
  2420. }
  2421. function handleDataInput(dataInput, context) {
  2422. visitIfDi(dataInput, context);
  2423. }
  2424. function handleDataOutput(dataOutput, context) {
  2425. visitIfDi(dataOutput, context);
  2426. }
  2427. function handleArtifact(artifact, context) {
  2428. // bpmn:TextAnnotation
  2429. // bpmn:Group
  2430. // bpmn:Association
  2431. visitIfDi(artifact, context);
  2432. }
  2433. function handleArtifacts(artifacts, context) {
  2434. forEach(artifacts, function(e) {
  2435. if (is(e, 'bpmn:Association')) {
  2436. deferred.push(function() {
  2437. handleArtifact(e, context);
  2438. });
  2439. } else {
  2440. handleArtifact(e, context);
  2441. }
  2442. });
  2443. }
  2444. function handleIoSpecification(ioSpecification, context) {
  2445. if (!ioSpecification) {
  2446. return;
  2447. }
  2448. forEach(ioSpecification.dataInputs, contextual(handleDataInput, context));
  2449. forEach(ioSpecification.dataOutputs, contextual(handleDataOutput, context));
  2450. }
  2451. function handleSubProcess(subProcess, context) {
  2452. handleFlowElementsContainer(subProcess, context);
  2453. handleArtifacts(subProcess.artifacts, context);
  2454. }
  2455. function handleFlowNode(flowNode, context) {
  2456. var childCtx = visitIfDi(flowNode, context);
  2457. if (is(flowNode, 'bpmn:SubProcess')) {
  2458. handleSubProcess(flowNode, childCtx || context);
  2459. }
  2460. }
  2461. function handleSequenceFlow(sequenceFlow, context) {
  2462. visitIfDi(sequenceFlow, context);
  2463. }
  2464. function handleDataElement(dataObject, context) {
  2465. visitIfDi(dataObject, context);
  2466. }
  2467. function handleBoundaryEvent(dataObject, context) {
  2468. visitIfDi(dataObject, context);
  2469. }
  2470. function handleLane(lane, context) {
  2471. var newContext = visitIfDi(lane, context);
  2472. if (lane.childLaneSet) {
  2473. handleLaneSet(lane.childLaneSet, newContext || context);
  2474. } else {
  2475. var filterList = filter(lane.flowNodeRef, function(e) {
  2476. return e.$type !== 'bpmn:BoundaryEvent';
  2477. });
  2478. handleFlowElements(filterList, newContext || context);
  2479. }
  2480. }
  2481. function handleLaneSet(laneSet, context) {
  2482. forEach(laneSet.lanes, contextual(handleLane, context));
  2483. }
  2484. function handleLaneSets(laneSets, context) {
  2485. forEach(laneSets, contextual(handleLaneSet, context));
  2486. }
  2487. function handleFlowElementsContainer(container, context) {
  2488. if (container.laneSets) {
  2489. handleLaneSets(container.laneSets, context);
  2490. handleNonFlowNodes(container.flowElements);
  2491. } else {
  2492. handleFlowElements(container.flowElements, context);
  2493. }
  2494. }
  2495. function handleNonFlowNodes(flowElements, context) {
  2496. forEach(flowElements, function(e) {
  2497. if (is(e, 'bpmn:SequenceFlow')) {
  2498. deferred.push(function() {
  2499. handleSequenceFlow(e, context);
  2500. });
  2501. } else if (is(e, 'bpmn:BoundaryEvent')) {
  2502. deferred.unshift(function() {
  2503. handleBoundaryEvent(e, context);
  2504. });
  2505. } else if (is(e, 'bpmn:DataObject')) {
  2506. // SKIP (assume correct referencing via DataObjectReference)
  2507. } else if (is(e, 'bpmn:DataStoreReference')) {
  2508. handleDataElement(e, context);
  2509. } else if (is(e, 'bpmn:DataObjectReference')) {
  2510. handleDataElement(e, context);
  2511. }
  2512. });
  2513. }
  2514. function handleFlowElements(flowElements, context) {
  2515. forEach(flowElements, function(e) {
  2516. if (is(e, 'bpmn:SequenceFlow')) {
  2517. deferred.push(function() {
  2518. handleSequenceFlow(e, context);
  2519. });
  2520. } else if (is(e, 'bpmn:BoundaryEvent')) {
  2521. deferred.unshift(function() {
  2522. handleBoundaryEvent(e, context);
  2523. });
  2524. } else if (is(e, 'bpmn:FlowNode')) {
  2525. handleFlowNode(e, context);
  2526. if (is(e, 'bpmn:Activity')) {
  2527. handleIoSpecification(e.ioSpecification, context);
  2528. // defer handling of associations
  2529. deferred.push(function() {
  2530. forEach(e.dataInputAssociations, contextual(handleDataAssociation, context));
  2531. forEach(e.dataOutputAssociations, contextual(handleDataAssociation, context));
  2532. });
  2533. }
  2534. } else if (is(e, 'bpmn:DataObject')) {
  2535. // SKIP (assume correct referencing via DataObjectReference)
  2536. } else if (is(e, 'bpmn:DataStoreReference')) {
  2537. handleDataElement(e, context);
  2538. } else if (is(e, 'bpmn:DataObjectReference')) {
  2539. handleDataElement(e, context);
  2540. } else {
  2541. logError(
  2542. 'unrecognized flowElement ' + elementToString(e) + ' in context ' +
  2543. (context ? elementToString(context.businessObject) : null),
  2544. { element: e, context: context });
  2545. }
  2546. });
  2547. }
  2548. function handleParticipant(participant, context) {
  2549. var newCtx = visitIfDi(participant, context);
  2550. var process = participant.processRef;
  2551. if (process) {
  2552. handleProcess(process, newCtx || context);
  2553. }
  2554. }
  2555. function handleCollaboration(collaboration) {
  2556. forEach(collaboration.participants, contextual(handleParticipant));
  2557. handleArtifacts(collaboration.artifacts);
  2558. // handle message flows latest in the process
  2559. deferred.push(function() {
  2560. handleMessageFlows(collaboration.messageFlows);
  2561. });
  2562. }
  2563. ///// API ////////////////////////////////
  2564. return {
  2565. handleDefinitions: handleDefinitions
  2566. };
  2567. }
  2568. module.exports = BpmnTreeWalker;
  2569. },{"192":192,"75":75,"76":76,"77":77,"9":9}],8:[function(_dereq_,module,exports){
  2570. 'use strict';
  2571. var BpmnTreeWalker = _dereq_(7);
  2572. /**
  2573. * Import the definitions into a diagram.
  2574. *
  2575. * Errors and warnings are reported through the specified callback.
  2576. *
  2577. * @param {Diagram} diagram
  2578. * @param {ModdleElement} definitions
  2579. * @param {Function} done the callback, invoked with (err, [ warning ]) once the import is done
  2580. */
  2581. function importBpmnDiagram(diagram, definitions, done) {
  2582. var importer = diagram.get('bpmnImporter'),
  2583. eventBus = diagram.get('eventBus');
  2584. var error,
  2585. warnings = [];
  2586. function parse(definitions) {
  2587. var visitor = {
  2588. root: function(element) {
  2589. return importer.add(element);
  2590. },
  2591. element: function(element, parentShape) {
  2592. return importer.add(element, parentShape);
  2593. },
  2594. error: function(message, context) {
  2595. warnings.push({ message: message, context: context });
  2596. }
  2597. };
  2598. var walker = new BpmnTreeWalker(visitor);
  2599. // import
  2600. walker.handleDefinitions(definitions);
  2601. }
  2602. eventBus.fire('import.start');
  2603. try {
  2604. parse(definitions);
  2605. } catch (e) {
  2606. error = e;
  2607. }
  2608. eventBus.fire(error ? 'import.error' : 'import.success', { error: error, warnings: warnings });
  2609. done(error, warnings);
  2610. }
  2611. module.exports.importBpmnDiagram = importBpmnDiagram;
  2612. },{"7":7}],9:[function(_dereq_,module,exports){
  2613. 'use strict';
  2614. module.exports.elementToString = function(e) {
  2615. if (!e) {
  2616. return '<null>';
  2617. }
  2618. return '<' + e.$type + (e.id ? ' id="' + e.id : '') + '" />';
  2619. };
  2620. },{}],10:[function(_dereq_,module,exports){
  2621. module.exports = {
  2622. bpmnImporter: [ 'type', _dereq_(6) ]
  2623. };
  2624. },{"6":6}],11:[function(_dereq_,module,exports){
  2625. 'use strict';
  2626. var is = _dereq_(13).is,
  2627. getBusinessObject = _dereq_(13).getBusinessObject;
  2628. module.exports.isExpanded = function(element) {
  2629. if (is(element, 'bpmn:CallActivity')) {
  2630. return false;
  2631. }
  2632. if (is(element, 'bpmn:SubProcess')) {
  2633. return getBusinessObject(element).di.isExpanded;
  2634. }
  2635. if (is(element, 'bpmn:Participant')) {
  2636. return !!getBusinessObject(element).processRef;
  2637. }
  2638. return true;
  2639. };
  2640. },{"13":13}],12:[function(_dereq_,module,exports){
  2641. 'use strict';
  2642. var assign = _dereq_(168);
  2643. var DEFAULT_LABEL_SIZE = module.exports.DEFAULT_LABEL_SIZE = {
  2644. width: 90,
  2645. height: 20
  2646. };
  2647. /**
  2648. * Returns true if the given semantic has an external label
  2649. *
  2650. * @param {BpmnElement} semantic
  2651. * @return {Boolean} true if has label
  2652. */
  2653. module.exports.hasExternalLabel = function(semantic) {
  2654. return semantic.$instanceOf('bpmn:Event') ||
  2655. semantic.$instanceOf('bpmn:Gateway') ||
  2656. semantic.$instanceOf('bpmn:DataStoreReference') ||
  2657. semantic.$instanceOf('bpmn:DataObjectReference') ||
  2658. semantic.$instanceOf('bpmn:SequenceFlow') ||
  2659. semantic.$instanceOf('bpmn:MessageFlow');
  2660. };
  2661. /**
  2662. * Get the middle of a number of waypoints
  2663. *
  2664. * @param {Array<Point>} waypoints
  2665. * @return {Point} the mid point
  2666. */
  2667. var getWaypointsMid = module.exports.getWaypointsMid = function(waypoints) {
  2668. var mid = waypoints.length / 2 - 1;
  2669. var first = waypoints[Math.floor(mid)];
  2670. var second = waypoints[Math.ceil(mid + 0.01)];
  2671. return {
  2672. x: first.x + (second.x - first.x) / 2,
  2673. y: first.y + (second.y - first.y) / 2
  2674. };
  2675. };
  2676. var getExternalLabelMid = module.exports.getExternalLabelMid = function(element) {
  2677. if (element.waypoints) {
  2678. return getWaypointsMid(element.waypoints);
  2679. } else {
  2680. return {
  2681. x: element.x + element.width / 2,
  2682. y: element.y + element.height + DEFAULT_LABEL_SIZE.height / 2
  2683. };
  2684. }
  2685. };
  2686. /**
  2687. * Returns the bounds of an elements label, parsed from the elements DI or
  2688. * generated from its bounds.
  2689. *
  2690. * @param {BpmnElement} semantic
  2691. * @param {djs.model.Base} element
  2692. */
  2693. module.exports.getExternalLabelBounds = function(semantic, element) {
  2694. var mid,
  2695. size,
  2696. bounds,
  2697. di = semantic.di,
  2698. label = di.label;
  2699. if (label && label.bounds) {
  2700. bounds = label.bounds;
  2701. size = {
  2702. width: Math.max(DEFAULT_LABEL_SIZE.width, bounds.width),
  2703. height: bounds.height
  2704. };
  2705. mid = {
  2706. x: bounds.x + bounds.width / 2,
  2707. y: bounds.y + bounds.height / 2
  2708. };
  2709. } else {
  2710. mid = getExternalLabelMid(element);
  2711. size = DEFAULT_LABEL_SIZE;
  2712. }
  2713. return assign({
  2714. x: mid.x - size.width / 2,
  2715. y: mid.y - size.height / 2
  2716. }, size);
  2717. };
  2718. },{"168":168}],13:[function(_dereq_,module,exports){
  2719. 'use strict';
  2720. /**
  2721. * Is an element of the given BPMN type?
  2722. *
  2723. * @param {djs.model.Base|ModdleElement} element
  2724. * @param {String} type
  2725. *
  2726. * @return {Boolean}
  2727. */
  2728. function is(element, type) {
  2729. var bo = getBusinessObject(element);
  2730. return bo && bo.$instanceOf(type);
  2731. }
  2732. module.exports.is = is;
  2733. /**
  2734. * Return the business object for a given element.
  2735. *
  2736. * @param {djs.model.Base|ModdleElement} element
  2737. *
  2738. * @return {ModdleElement}
  2739. */
  2740. function getBusinessObject(element) {
  2741. return (element && element.businessObject) || element;
  2742. }
  2743. module.exports.getBusinessObject = getBusinessObject;
  2744. },{}],14:[function(_dereq_,module,exports){
  2745. module.exports = _dereq_(16);
  2746. },{"16":16}],15:[function(_dereq_,module,exports){
  2747. 'use strict';
  2748. var isString = _dereq_(165),
  2749. isFunction = _dereq_(160),
  2750. assign = _dereq_(168);
  2751. var Moddle = _dereq_(22),
  2752. XmlReader = _dereq_(18),
  2753. XmlWriter = _dereq_(19);
  2754. /**
  2755. * A sub class of {@link Moddle} with support for import and export of BPMN 2.0 xml files.
  2756. *
  2757. * @class BpmnModdle
  2758. * @extends Moddle
  2759. *
  2760. * @param {Object|Array} packages to use for instantiating the model
  2761. * @param {Object} [options] additional options to pass over
  2762. */
  2763. function BpmnModdle(packages, options) {
  2764. Moddle.call(this, packages, options);
  2765. }
  2766. BpmnModdle.prototype = Object.create(Moddle.prototype);
  2767. module.exports = BpmnModdle;
  2768. /**
  2769. * Instantiates a BPMN model tree from a given xml string.
  2770. *
  2771. * @param {String} xmlStr
  2772. * @param {String} [typeName='bpmn:Definitions'] name of the root element
  2773. * @param {Object} [options] options to pass to the underlying reader
  2774. * @param {Function} done callback that is invoked with (err, result, parseContext)
  2775. * once the import completes
  2776. */
  2777. BpmnModdle.prototype.fromXML = function(xmlStr, typeName, options, done) {
  2778. if (!isString(typeName)) {
  2779. done = options;
  2780. options = typeName;
  2781. typeName = 'bpmn:Definitions';
  2782. }
  2783. if (isFunction(options)) {
  2784. done = options;
  2785. options = {};
  2786. }
  2787. var reader = new XmlReader(assign({ model: this, lax: true }, options));
  2788. var rootHandler = reader.handler(typeName);
  2789. reader.fromXML(xmlStr, rootHandler, done);
  2790. };
  2791. /**
  2792. * Serializes a BPMN 2.0 object tree to XML.
  2793. *
  2794. * @param {String} element the root element, typically an instance of `bpmn:Definitions`
  2795. * @param {Object} [options] to pass to the underlying writer
  2796. * @param {Function} done callback invoked with (err, xmlStr) once the import completes
  2797. */
  2798. BpmnModdle.prototype.toXML = function(element, options, done) {
  2799. if (isFunction(options)) {
  2800. done = options;
  2801. options = {};
  2802. }
  2803. var writer = new XmlWriter(options);
  2804. try {
  2805. var result = writer.toXML(element);
  2806. done(null, result);
  2807. } catch (e) {
  2808. done(e);
  2809. }
  2810. };
  2811. },{"160":160,"165":165,"168":168,"18":18,"19":19,"22":22}],16:[function(_dereq_,module,exports){
  2812. 'use strict';
  2813. var assign = _dereq_(168);
  2814. var BpmnModdle = _dereq_(15);
  2815. var packages = {
  2816. bpmn: _dereq_(31),
  2817. bpmndi: _dereq_(32),
  2818. dc: _dereq_(33),
  2819. di: _dereq_(34)
  2820. };
  2821. module.exports = function(additionalPackages, options) {
  2822. return new BpmnModdle(assign({}, packages, additionalPackages), options);
  2823. };
  2824. },{"15":15,"168":168,"31":31,"32":32,"33":33,"34":34}],17:[function(_dereq_,module,exports){
  2825. 'use strict';
  2826. function capitalize(string) {
  2827. return string.charAt(0).toUpperCase() + string.slice(1);
  2828. }
  2829. function lower(string) {
  2830. return string.charAt(0).toLowerCase() + string.slice(1);
  2831. }
  2832. function hasLowerCaseAlias(pkg) {
  2833. return pkg.xml && pkg.xml.tagAlias === 'lowerCase';
  2834. }
  2835. module.exports.aliasToName = function(alias, pkg) {
  2836. if (hasLowerCaseAlias(pkg)) {
  2837. return capitalize(alias);
  2838. } else {
  2839. return alias;
  2840. }
  2841. };
  2842. module.exports.nameToAlias = function(name, pkg) {
  2843. if (hasLowerCaseAlias(pkg)) {
  2844. return lower(name);
  2845. } else {
  2846. return name;
  2847. }
  2848. };
  2849. module.exports.DEFAULT_NS_MAP = {
  2850. 'xsi': 'http://www.w3.org/2001/XMLSchema-instance'
  2851. };
  2852. var XSI_TYPE = module.exports.XSI_TYPE = 'xsi:type';
  2853. function serializeFormat(element) {
  2854. return element.xml && element.xml.serialize;
  2855. }
  2856. module.exports.serializeAsType = function(element) {
  2857. return serializeFormat(element) === XSI_TYPE;
  2858. };
  2859. module.exports.serializeAsProperty = function(element) {
  2860. return serializeFormat(element) === 'property';
  2861. };
  2862. },{}],18:[function(_dereq_,module,exports){
  2863. 'use strict';
  2864. var reduce = _dereq_(81),
  2865. forEach = _dereq_(77),
  2866. find = _dereq_(76),
  2867. assign = _dereq_(168),
  2868. defer = _dereq_(85);
  2869. var Stack = _dereq_(21),
  2870. SaxParser = _dereq_(20).parser,
  2871. Moddle = _dereq_(22),
  2872. parseNameNs = _dereq_(27).parseName,
  2873. Types = _dereq_(30),
  2874. coerceType = Types.coerceType,
  2875. isSimpleType = Types.isSimple,
  2876. common = _dereq_(17),
  2877. XSI_TYPE = common.XSI_TYPE,
  2878. XSI_URI = common.DEFAULT_NS_MAP.xsi,
  2879. serializeAsType = common.serializeAsType,
  2880. aliasToName = common.aliasToName;
  2881. function parseNodeAttributes(node) {
  2882. var nodeAttrs = node.attributes;
  2883. return reduce(nodeAttrs, function(result, v, k) {
  2884. var name, ns;
  2885. if (!v.local) {
  2886. name = v.prefix;
  2887. } else {
  2888. ns = parseNameNs(v.name, v.prefix);
  2889. name = ns.name;
  2890. }
  2891. result[name] = v.value;
  2892. return result;
  2893. }, {});
  2894. }
  2895. function normalizeType(node, attr, model) {
  2896. var nameNs = parseNameNs(attr.value);
  2897. var uri = node.ns[nameNs.prefix || ''],
  2898. localName = nameNs.localName,
  2899. pkg = uri && model.getPackage(uri),
  2900. typePrefix;
  2901. if (pkg) {
  2902. typePrefix = pkg.xml && pkg.xml.typePrefix;
  2903. if (typePrefix && localName.indexOf(typePrefix) === 0) {
  2904. localName = localName.slice(typePrefix.length);
  2905. }
  2906. attr.value = pkg.prefix + ':' + localName;
  2907. }
  2908. }
  2909. /**
  2910. * Normalizes namespaces for a node given an optional default namespace and a
  2911. * number of mappings from uris to default prefixes.
  2912. *
  2913. * @param {XmlNode} node
  2914. * @param {Model} model the model containing all registered namespaces
  2915. * @param {Uri} defaultNsUri
  2916. */
  2917. function normalizeNamespaces(node, model, defaultNsUri) {
  2918. var uri, prefix;
  2919. uri = node.uri || defaultNsUri;
  2920. if (uri) {
  2921. var pkg = model.getPackage(uri);
  2922. if (pkg) {
  2923. prefix = pkg.prefix;
  2924. } else {
  2925. prefix = node.prefix;
  2926. }
  2927. node.prefix = prefix;
  2928. node.uri = uri;
  2929. }
  2930. forEach(node.attributes, function(attr) {
  2931. // normalize xsi:type attributes because the
  2932. // assigned type may or may not be namespace prefixed
  2933. if (attr.uri === XSI_URI && attr.local === 'type') {
  2934. normalizeType(node, attr, model);
  2935. }
  2936. normalizeNamespaces(attr, model, null);
  2937. });
  2938. }
  2939. /**
  2940. * A parse context.
  2941. *
  2942. * @class
  2943. *
  2944. * @param {Object} options
  2945. * @param {ElementHandler} options.parseRoot the root handler for parsing a document
  2946. * @param {boolean} [options.lax=false] whether or not to ignore invalid elements
  2947. */
  2948. function Context(options) {
  2949. /**
  2950. * @property {ElementHandler} parseRoot
  2951. */
  2952. /**
  2953. * @property {Boolean} lax
  2954. */
  2955. assign(this, options);
  2956. var elementsById = this.elementsById = {};
  2957. var references = this.references = [];
  2958. var warnings = this.warnings = [];
  2959. this.addReference = function(reference) {
  2960. references.push(reference);
  2961. };
  2962. this.addElement = function(id, element) {
  2963. if (!id || !element) {
  2964. throw new Error('[xml-reader] id or ctx must not be null');
  2965. }
  2966. elementsById[id] = element;
  2967. };
  2968. this.addWarning = function (w) {
  2969. warnings.push(w);
  2970. };
  2971. }
  2972. function BaseHandler() {}
  2973. BaseHandler.prototype.handleEnd = function() {};
  2974. BaseHandler.prototype.handleText = function() {};
  2975. BaseHandler.prototype.handleNode = function() {};
  2976. /**
  2977. * A simple pass through handler that does nothing except for
  2978. * ignoring all input it receives.
  2979. *
  2980. * This is used to ignore unknown elements and
  2981. * attributes.
  2982. */
  2983. function NoopHandler() { }
  2984. NoopHandler.prototype = new BaseHandler();
  2985. NoopHandler.prototype.handleNode = function() {
  2986. return this;
  2987. };
  2988. function BodyHandler() {}
  2989. BodyHandler.prototype = new BaseHandler();
  2990. BodyHandler.prototype.handleText = function(text) {
  2991. this.body = (this.body || '') + text;
  2992. };
  2993. function ReferenceHandler(property, context) {
  2994. this.property = property;
  2995. this.context = context;
  2996. }
  2997. ReferenceHandler.prototype = new BodyHandler();
  2998. ReferenceHandler.prototype.handleNode = function(node) {
  2999. if (this.element) {
  3000. throw new Error('expected no sub nodes');
  3001. } else {
  3002. this.element = this.createReference(node);
  3003. }
  3004. return this;
  3005. };
  3006. ReferenceHandler.prototype.handleEnd = function() {
  3007. this.element.id = this.body;
  3008. };
  3009. ReferenceHandler.prototype.createReference = function() {
  3010. return {
  3011. property: this.property.ns.name,
  3012. id: ''
  3013. };
  3014. };
  3015. function ValueHandler(propertyDesc, element) {
  3016. this.element = element;
  3017. this.propertyDesc = propertyDesc;
  3018. }
  3019. ValueHandler.prototype = new BodyHandler();
  3020. ValueHandler.prototype.handleEnd = function() {
  3021. var value = this.body,
  3022. element = this.element,
  3023. propertyDesc = this.propertyDesc;
  3024. value = coerceType(propertyDesc.type, value);
  3025. if (propertyDesc.isMany) {
  3026. element.get(propertyDesc.name).push(value);
  3027. } else {
  3028. element.set(propertyDesc.name, value);
  3029. }
  3030. };
  3031. function BaseElementHandler() {}
  3032. BaseElementHandler.prototype = Object.create(BodyHandler.prototype);
  3033. BaseElementHandler.prototype.handleNode = function(node) {
  3034. var parser = this,
  3035. element = this.element,
  3036. id;
  3037. if (!element) {
  3038. element = this.element = this.createElement(node);
  3039. id = element.id;
  3040. if (id) {
  3041. this.context.addElement(id, element);
  3042. }
  3043. } else {
  3044. parser = this.handleChild(node);
  3045. }
  3046. return parser;
  3047. };
  3048. /**
  3049. * @class XMLReader.ElementHandler
  3050. *
  3051. */
  3052. function ElementHandler(model, type, context) {
  3053. this.model = model;
  3054. this.type = model.getType(type);
  3055. this.context = context;
  3056. }
  3057. ElementHandler.prototype = new BaseElementHandler();
  3058. ElementHandler.prototype.addReference = function(reference) {
  3059. this.context.addReference(reference);
  3060. };
  3061. ElementHandler.prototype.handleEnd = function() {
  3062. var value = this.body,
  3063. element = this.element,
  3064. descriptor = element.$descriptor,
  3065. bodyProperty = descriptor.bodyProperty;
  3066. if (bodyProperty && value !== undefined) {
  3067. value = coerceType(bodyProperty.type, value);
  3068. element.set(bodyProperty.name, value);
  3069. }
  3070. };
  3071. /**
  3072. * Create an instance of the model from the given node.
  3073. *
  3074. * @param {Element} node the xml node
  3075. */
  3076. ElementHandler.prototype.createElement = function(node) {
  3077. var attributes = parseNodeAttributes(node),
  3078. Type = this.type,
  3079. descriptor = Type.$descriptor,
  3080. context = this.context,
  3081. instance = new Type({});
  3082. forEach(attributes, function(value, name) {
  3083. var prop = descriptor.propertiesByName[name];
  3084. if (prop && prop.isReference) {
  3085. context.addReference({
  3086. element: instance,
  3087. property: prop.ns.name,
  3088. id: value
  3089. });
  3090. } else {
  3091. if (prop) {
  3092. value = coerceType(prop.type, value);
  3093. }
  3094. instance.set(name, value);
  3095. }
  3096. });
  3097. return instance;
  3098. };
  3099. ElementHandler.prototype.getPropertyForNode = function(node) {
  3100. var nameNs = parseNameNs(node.local, node.prefix);
  3101. var type = this.type,
  3102. model = this.model,
  3103. descriptor = type.$descriptor;
  3104. var propertyName = nameNs.name,
  3105. property = descriptor.propertiesByName[propertyName],
  3106. elementTypeName,
  3107. elementType,
  3108. typeAnnotation;
  3109. // search for properties by name first
  3110. if (property) {
  3111. if (serializeAsType(property)) {
  3112. typeAnnotation = node.attributes[XSI_TYPE];
  3113. // xsi type is optional, if it does not exists the
  3114. // default type is assumed
  3115. if (typeAnnotation) {
  3116. elementTypeName = typeAnnotation.value;
  3117. // TODO: extract real name from attribute
  3118. elementType = model.getType(elementTypeName);
  3119. return assign({}, property, { effectiveType: elementType.$descriptor.name });
  3120. }
  3121. }
  3122. // search for properties by name first
  3123. return property;
  3124. }
  3125. var pkg = model.getPackage(nameNs.prefix);
  3126. if (pkg) {
  3127. elementTypeName = nameNs.prefix + ':' + aliasToName(nameNs.localName, descriptor.$pkg);
  3128. elementType = model.getType(elementTypeName);
  3129. // search for collection members later
  3130. property = find(descriptor.properties, function(p) {
  3131. return !p.isVirtual && !p.isReference && !p.isAttribute && elementType.hasType(p.type);
  3132. });
  3133. if (property) {
  3134. return assign({}, property, { effectiveType: elementType.$descriptor.name });
  3135. }
  3136. } else {
  3137. // parse unknown element (maybe extension)
  3138. property = find(descriptor.properties, function(p) {
  3139. return !p.isReference && !p.isAttribute && p.type === 'Element';
  3140. });
  3141. if (property) {
  3142. return property;
  3143. }
  3144. }
  3145. throw new Error('unrecognized element <' + nameNs.name + '>');
  3146. };
  3147. ElementHandler.prototype.toString = function() {
  3148. return 'ElementDescriptor[' + this.type.$descriptor.name + ']';
  3149. };
  3150. ElementHandler.prototype.valueHandler = function(propertyDesc, element) {
  3151. return new ValueHandler(propertyDesc, element);
  3152. };
  3153. ElementHandler.prototype.referenceHandler = function(propertyDesc) {
  3154. return new ReferenceHandler(propertyDesc, this.context);
  3155. };
  3156. ElementHandler.prototype.handler = function(type) {
  3157. if (type === 'Element') {
  3158. return new GenericElementHandler(this.model, type, this.context);
  3159. } else {
  3160. return new ElementHandler(this.model, type, this.context);
  3161. }
  3162. };
  3163. /**
  3164. * Handle the child element parsing
  3165. *
  3166. * @param {Element} node the xml node
  3167. */
  3168. ElementHandler.prototype.handleChild = function(node) {
  3169. var propertyDesc, type, element, childHandler;
  3170. propertyDesc = this.getPropertyForNode(node);
  3171. element = this.element;
  3172. type = propertyDesc.effectiveType || propertyDesc.type;
  3173. if (isSimpleType(type)) {
  3174. return this.valueHandler(propertyDesc, element);
  3175. }
  3176. if (propertyDesc.isReference) {
  3177. childHandler = this.referenceHandler(propertyDesc).handleNode(node);
  3178. } else {
  3179. childHandler = this.handler(type).handleNode(node);
  3180. }
  3181. var newElement = childHandler.element;
  3182. // child handles may decide to skip elements
  3183. // by not returning anything
  3184. if (newElement !== undefined) {
  3185. if (propertyDesc.isMany) {
  3186. element.get(propertyDesc.name).push(newElement);
  3187. } else {
  3188. element.set(propertyDesc.name, newElement);
  3189. }
  3190. if (propertyDesc.isReference) {
  3191. assign(newElement, {
  3192. element: element
  3193. });
  3194. this.context.addReference(newElement);
  3195. } else {
  3196. // establish child -> parent relationship
  3197. newElement.$parent = element;
  3198. }
  3199. }
  3200. return childHandler;
  3201. };
  3202. function GenericElementHandler(model, type, context) {
  3203. this.model = model;
  3204. this.context = context;
  3205. }
  3206. GenericElementHandler.prototype = Object.create(BaseElementHandler.prototype);
  3207. GenericElementHandler.prototype.createElement = function(node) {
  3208. var name = node.name,
  3209. prefix = node.prefix,
  3210. uri = node.ns[prefix],
  3211. attributes = node.attributes;
  3212. return this.model.createAny(name, uri, attributes);
  3213. };
  3214. GenericElementHandler.prototype.handleChild = function(node) {
  3215. var handler = new GenericElementHandler(this.model, 'Element', this.context).handleNode(node),
  3216. element = this.element;
  3217. var newElement = handler.element,
  3218. children;
  3219. if (newElement !== undefined) {
  3220. children = element.$children = element.$children || [];
  3221. children.push(newElement);
  3222. // establish child -> parent relationship
  3223. newElement.$parent = element;
  3224. }
  3225. return handler;
  3226. };
  3227. GenericElementHandler.prototype.handleText = function(text) {
  3228. this.body = this.body || '' + text;
  3229. };
  3230. GenericElementHandler.prototype.handleEnd = function() {
  3231. if (this.body) {
  3232. this.element.$body = this.body;
  3233. }
  3234. };
  3235. /**
  3236. * A reader for a meta-model
  3237. *
  3238. * @param {Object} options
  3239. * @param {Model} options.model used to read xml files
  3240. * @param {Boolean} options.lax whether to make parse errors warnings
  3241. */
  3242. function XMLReader(options) {
  3243. if (options instanceof Moddle) {
  3244. options = {
  3245. model: options
  3246. };
  3247. }
  3248. assign(this, { lax: false }, options);
  3249. }
  3250. XMLReader.prototype.fromXML = function(xml, rootHandler, done) {
  3251. var model = this.model,
  3252. lax = this.lax,
  3253. context = new Context({
  3254. parseRoot: rootHandler
  3255. });
  3256. var parser = new SaxParser(true, { xmlns: true, trim: true }),
  3257. stack = new Stack();
  3258. rootHandler.context = context;
  3259. // push root handler
  3260. stack.push(rootHandler);
  3261. function resolveReferences() {
  3262. var elementsById = context.elementsById;
  3263. var references = context.references;
  3264. var i, r;
  3265. for (i = 0; !!(r = references[i]); i++) {
  3266. var element = r.element;
  3267. var reference = elementsById[r.id];
  3268. var property = element.$descriptor.propertiesByName[r.property];
  3269. if (!reference) {
  3270. context.addWarning({
  3271. message: 'unresolved reference <' + r.id + '>',
  3272. element: r.element,
  3273. property: r.property,
  3274. value: r.id
  3275. });
  3276. }
  3277. if (property.isMany) {
  3278. var collection = element.get(property.name),
  3279. idx = collection.indexOf(r);
  3280. if (!reference) {
  3281. // remove unresolvable reference
  3282. collection.splice(idx, 1);
  3283. } else {
  3284. // update reference
  3285. collection[idx] = reference;
  3286. }
  3287. } else {
  3288. element.set(property.name, reference);
  3289. }
  3290. }
  3291. }
  3292. function handleClose(tagName) {
  3293. stack.pop().handleEnd();
  3294. }
  3295. function handleOpen(node) {
  3296. var handler = stack.peek();
  3297. normalizeNamespaces(node, model);
  3298. try {
  3299. stack.push(handler.handleNode(node));
  3300. } catch (e) {
  3301. var line = this.line,
  3302. column = this.column;
  3303. var message =
  3304. 'unparsable content <' + node.name + '> detected\n\t' +
  3305. 'line: ' + line + '\n\t' +
  3306. 'column: ' + column + '\n\t' +
  3307. 'nested error: ' + e.message;
  3308. if (lax) {
  3309. context.addWarning({
  3310. message: message,
  3311. error: e
  3312. });
  3313. console.warn('could not parse node');
  3314. console.warn(e);
  3315. stack.push(new NoopHandler());
  3316. } else {
  3317. console.error('could not parse document');
  3318. console.error(e);
  3319. throw new Error(message);
  3320. }
  3321. }
  3322. }
  3323. function handleText(text) {
  3324. stack.peek().handleText(text);
  3325. }
  3326. parser.onopentag = handleOpen;
  3327. parser.oncdata = parser.ontext = handleText;
  3328. parser.onclosetag = handleClose;
  3329. parser.onend = resolveReferences;
  3330. // deferred parse XML to make loading really ascnchronous
  3331. // this ensures the execution environment (node or browser)
  3332. // is kept responsive and that certain optimization strategies
  3333. // can kick in
  3334. defer(function() {
  3335. var error;
  3336. try {
  3337. parser.write(xml).close();
  3338. } catch (e) {
  3339. error = e;
  3340. }
  3341. done(error, error ? undefined : rootHandler.element, context);
  3342. });
  3343. };
  3344. XMLReader.prototype.handler = function(name) {
  3345. return new ElementHandler(this.model, name);
  3346. };
  3347. module.exports = XMLReader;
  3348. module.exports.ElementHandler = ElementHandler;
  3349. },{"168":168,"17":17,"20":20,"21":21,"22":22,"27":27,"30":30,"76":76,"77":77,"81":81,"85":85}],19:[function(_dereq_,module,exports){
  3350. 'use strict';
  3351. var map = _dereq_(80),
  3352. forEach = _dereq_(77),
  3353. isString = _dereq_(165),
  3354. filter = _dereq_(75),
  3355. assign = _dereq_(168);
  3356. var Types = _dereq_(30),
  3357. parseNameNs = _dereq_(27).parseName,
  3358. common = _dereq_(17),
  3359. nameToAlias = common.nameToAlias,
  3360. serializeAsType = common.serializeAsType,
  3361. serializeAsProperty = common.serializeAsProperty;
  3362. var XML_PREAMBLE = '<?xml version="1.0" encoding="UTF-8"?>\n',
  3363. ESCAPE_CHARS = /(<|>|'|"|&|\n\r|\n)/g,
  3364. DEFAULT_NS_MAP = common.DEFAULT_NS_MAP,
  3365. XSI_TYPE = common.XSI_TYPE;
  3366. function nsName(ns) {
  3367. if (isString(ns)) {
  3368. return ns;
  3369. } else {
  3370. return (ns.prefix ? ns.prefix + ':' : '') + ns.localName;
  3371. }
  3372. }
  3373. function getElementNs(ns, descriptor) {
  3374. if (descriptor.isGeneric) {
  3375. return descriptor.name;
  3376. } else {
  3377. return assign({ localName: nameToAlias(descriptor.ns.localName, descriptor.$pkg) }, ns);
  3378. }
  3379. }
  3380. function getPropertyNs(ns, descriptor) {
  3381. return assign({ localName: descriptor.ns.localName }, ns);
  3382. }
  3383. function getSerializableProperties(element) {
  3384. var descriptor = element.$descriptor;
  3385. return filter(descriptor.properties, function(p) {
  3386. var name = p.name;
  3387. // do not serialize defaults
  3388. if (!element.hasOwnProperty(name)) {
  3389. return false;
  3390. }
  3391. var value = element[name];
  3392. // do not serialize default equals
  3393. if (value === p.default) {
  3394. return false;
  3395. }
  3396. return p.isMany ? value.length : true;
  3397. });
  3398. }
  3399. var ESCAPE_MAP = {
  3400. '\n': '10',
  3401. '\n\r': '10',
  3402. '"': '34',
  3403. '\'': '39',
  3404. '<': '60',
  3405. '>': '62',
  3406. '&': '38'
  3407. };
  3408. /**
  3409. * Escape a string attribute to not contain any bad values (line breaks, '"', ...)
  3410. *
  3411. * @param {String} str the string to escape
  3412. * @return {String} the escaped string
  3413. */
  3414. function escapeAttr(str) {
  3415. // ensure we are handling strings here
  3416. str = isString(str) ? str : '' + str;
  3417. return str.replace(ESCAPE_CHARS, function(str) {
  3418. return '&#' + ESCAPE_MAP[str] + ';';
  3419. });
  3420. }
  3421. function filterAttributes(props) {
  3422. return filter(props, function(p) { return p.isAttr; });
  3423. }
  3424. function filterContained(props) {
  3425. return filter(props, function(p) { return !p.isAttr; });
  3426. }
  3427. function ReferenceSerializer(parent, ns) {
  3428. this.ns = ns;
  3429. }
  3430. ReferenceSerializer.prototype.build = function(element) {
  3431. this.element = element;
  3432. return this;
  3433. };
  3434. ReferenceSerializer.prototype.serializeTo = function(writer) {
  3435. writer
  3436. .appendIndent()
  3437. .append('<' + nsName(this.ns) + '>' + this.element.id + '</' + nsName(this.ns) + '>')
  3438. .appendNewLine();
  3439. };
  3440. function BodySerializer() {}
  3441. BodySerializer.prototype.serializeValue = BodySerializer.prototype.serializeTo = function(writer) {
  3442. var escape = this.escape;
  3443. if (escape) {
  3444. writer.append('<![CDATA[');
  3445. }
  3446. writer.append(this.value);
  3447. if (escape) {
  3448. writer.append(']]>');
  3449. }
  3450. };
  3451. BodySerializer.prototype.build = function(prop, value) {
  3452. this.value = value;
  3453. if (prop.type === 'String' && ESCAPE_CHARS.test(value)) {
  3454. this.escape = true;
  3455. }
  3456. return this;
  3457. };
  3458. function ValueSerializer(ns) {
  3459. this.ns = ns;
  3460. }
  3461. ValueSerializer.prototype = new BodySerializer();
  3462. ValueSerializer.prototype.serializeTo = function(writer) {
  3463. writer
  3464. .appendIndent()
  3465. .append('<' + nsName(this.ns) + '>');
  3466. this.serializeValue(writer);
  3467. writer
  3468. .append( '</' + nsName(this.ns) + '>')
  3469. .appendNewLine();
  3470. };
  3471. function ElementSerializer(parent, ns) {
  3472. this.body = [];
  3473. this.attrs = [];
  3474. this.parent = parent;
  3475. this.ns = ns;
  3476. }
  3477. ElementSerializer.prototype.build = function(element) {
  3478. this.element = element;
  3479. var otherAttrs = this.parseNsAttributes(element);
  3480. if (!this.ns) {
  3481. this.ns = this.nsTagName(element.$descriptor);
  3482. }
  3483. if (element.$descriptor.isGeneric) {
  3484. this.parseGeneric(element);
  3485. } else {
  3486. var properties = getSerializableProperties(element);
  3487. this.parseAttributes(filterAttributes(properties));
  3488. this.parseContainments(filterContained(properties));
  3489. this.parseGenericAttributes(element, otherAttrs);
  3490. }
  3491. return this;
  3492. };
  3493. ElementSerializer.prototype.nsTagName = function(descriptor) {
  3494. var effectiveNs = this.logNamespaceUsed(descriptor.ns);
  3495. return getElementNs(effectiveNs, descriptor);
  3496. };
  3497. ElementSerializer.prototype.nsPropertyTagName = function(descriptor) {
  3498. var effectiveNs = this.logNamespaceUsed(descriptor.ns);
  3499. return getPropertyNs(effectiveNs, descriptor);
  3500. };
  3501. ElementSerializer.prototype.isLocalNs = function(ns) {
  3502. return ns.uri === this.ns.uri;
  3503. };
  3504. ElementSerializer.prototype.nsAttributeName = function(element) {
  3505. var ns;
  3506. if (isString(element)) {
  3507. ns = parseNameNs(element);
  3508. } else
  3509. if (element.ns) {
  3510. ns = element.ns;
  3511. }
  3512. var effectiveNs = this.logNamespaceUsed(ns);
  3513. // strip prefix if same namespace like parent
  3514. if (this.isLocalNs(effectiveNs)) {
  3515. return { localName: ns.localName };
  3516. } else {
  3517. return assign({ localName: ns.localName }, effectiveNs);
  3518. }
  3519. };
  3520. ElementSerializer.prototype.parseGeneric = function(element) {
  3521. var self = this,
  3522. body = this.body,
  3523. attrs = this.attrs;
  3524. forEach(element, function(val, key) {
  3525. if (key === '$body') {
  3526. body.push(new BodySerializer().build({ type: 'String' }, val));
  3527. } else
  3528. if (key === '$children') {
  3529. forEach(val, function(child) {
  3530. body.push(new ElementSerializer(self).build(child));
  3531. });
  3532. } else
  3533. if (key.indexOf('$') !== 0) {
  3534. attrs.push({ name: key, value: escapeAttr(val) });
  3535. }
  3536. });
  3537. };
  3538. /**
  3539. * Parse namespaces and return a list of left over generic attributes
  3540. *
  3541. * @param {Object} element
  3542. * @return {Array<Object>}
  3543. */
  3544. ElementSerializer.prototype.parseNsAttributes = function(element) {
  3545. var self = this;
  3546. var genericAttrs = element.$attrs;
  3547. var attributes = [];
  3548. // parse namespace attributes first
  3549. // and log them. push non namespace attributes to a list
  3550. // and process them later
  3551. forEach(genericAttrs, function(value, name) {
  3552. var nameNs = parseNameNs(name);
  3553. if (nameNs.prefix === 'xmlns') {
  3554. self.logNamespace({ prefix: nameNs.localName, uri: value });
  3555. } else
  3556. if (!nameNs.prefix && nameNs.localName === 'xmlns') {
  3557. self.logNamespace({ uri: value });
  3558. } else {
  3559. attributes.push({ name: name, value: value });
  3560. }
  3561. });
  3562. return attributes;
  3563. };
  3564. ElementSerializer.prototype.parseGenericAttributes = function(element, attributes) {
  3565. var self = this;
  3566. forEach(attributes, function(attr) {
  3567. // do not serialize xsi:type attribute
  3568. // it is set manually based on the actual implementation type
  3569. if (attr.name === XSI_TYPE) {
  3570. return;
  3571. }
  3572. try {
  3573. self.addAttribute(self.nsAttributeName(attr.name), attr.value);
  3574. } catch (e) {
  3575. console.warn('[writer] missing namespace information for ', attr.name, '=', attr.value, 'on', element, e);
  3576. }
  3577. });
  3578. };
  3579. ElementSerializer.prototype.parseContainments = function(properties) {
  3580. var self = this,
  3581. body = this.body,
  3582. element = this.element;
  3583. forEach(properties, function(p) {
  3584. var value = element.get(p.name),
  3585. isReference = p.isReference,
  3586. isMany = p.isMany;
  3587. var ns = self.nsPropertyTagName(p);
  3588. if (!isMany) {
  3589. value = [ value ];
  3590. }
  3591. if (p.isBody) {
  3592. body.push(new BodySerializer().build(p, value[0]));
  3593. } else
  3594. if (Types.isSimple(p.type)) {
  3595. forEach(value, function(v) {
  3596. body.push(new ValueSerializer(ns).build(p, v));
  3597. });
  3598. } else
  3599. if (isReference) {
  3600. forEach(value, function(v) {
  3601. body.push(new ReferenceSerializer(self, ns).build(v));
  3602. });
  3603. } else {
  3604. // allow serialization via type
  3605. // rather than element name
  3606. var asType = serializeAsType(p),
  3607. asProperty = serializeAsProperty(p);
  3608. forEach(value, function(v) {
  3609. var serializer;
  3610. if (asType) {
  3611. serializer = new TypeSerializer(self, ns);
  3612. } else
  3613. if (asProperty) {
  3614. serializer = new ElementSerializer(self, ns);
  3615. } else {
  3616. serializer = new ElementSerializer(self);
  3617. }
  3618. body.push(serializer.build(v));
  3619. });
  3620. }
  3621. });
  3622. };
  3623. ElementSerializer.prototype.getNamespaces = function() {
  3624. if (!this.parent) {
  3625. if (!this.namespaces) {
  3626. this.namespaces = {
  3627. prefixMap: {},
  3628. uriMap: {},
  3629. used: {}
  3630. };
  3631. }
  3632. } else {
  3633. this.namespaces = this.parent.getNamespaces();
  3634. }
  3635. return this.namespaces;
  3636. };
  3637. ElementSerializer.prototype.logNamespace = function(ns) {
  3638. var namespaces = this.getNamespaces();
  3639. var existing = namespaces.uriMap[ns.uri];
  3640. if (!existing) {
  3641. namespaces.uriMap[ns.uri] = ns;
  3642. }
  3643. namespaces.prefixMap[ns.prefix] = ns.uri;
  3644. return ns;
  3645. };
  3646. ElementSerializer.prototype.logNamespaceUsed = function(ns) {
  3647. var element = this.element,
  3648. model = element.$model,
  3649. namespaces = this.getNamespaces();
  3650. // ns may be
  3651. //
  3652. // * prefix only
  3653. // * prefix:uri
  3654. var prefix = ns.prefix;
  3655. var uri = ns.uri || DEFAULT_NS_MAP[prefix] ||
  3656. namespaces.prefixMap[prefix] || (model ? (model.getPackage(prefix) || {}).uri : null);
  3657. if (!uri) {
  3658. throw new Error('no namespace uri given for prefix <' + ns.prefix + '>');
  3659. }
  3660. ns = namespaces.uriMap[uri];
  3661. if (!ns) {
  3662. ns = this.logNamespace({ prefix: prefix, uri: uri });
  3663. }
  3664. if (!namespaces.used[ns.uri]) {
  3665. namespaces.used[ns.uri] = ns;
  3666. }
  3667. return ns;
  3668. };
  3669. ElementSerializer.prototype.parseAttributes = function(properties) {
  3670. var self = this,
  3671. element = this.element;
  3672. forEach(properties, function(p) {
  3673. self.logNamespaceUsed(p.ns);
  3674. var value = element.get(p.name);
  3675. if (p.isReference) {
  3676. value = value.id;
  3677. }
  3678. self.addAttribute(self.nsAttributeName(p), value);
  3679. });
  3680. };
  3681. ElementSerializer.prototype.addAttribute = function(name, value) {
  3682. var attrs = this.attrs;
  3683. if (isString(value)) {
  3684. value = escapeAttr(value);
  3685. }
  3686. attrs.push({ name: name, value: value });
  3687. };
  3688. ElementSerializer.prototype.serializeAttributes = function(writer) {
  3689. var attrs = this.attrs,
  3690. root = !this.parent,
  3691. namespaces = this.namespaces;
  3692. function collectNsAttrs() {
  3693. return map(namespaces.used, function(ns) {
  3694. var name = 'xmlns' + (ns.prefix ? ':' + ns.prefix : '');
  3695. return { name: name, value: ns.uri };
  3696. });
  3697. }
  3698. if (root) {
  3699. attrs = collectNsAttrs().concat(attrs);
  3700. }
  3701. forEach(attrs, function(a) {
  3702. writer
  3703. .append(' ')
  3704. .append(nsName(a.name)).append('="').append(a.value).append('"');
  3705. });
  3706. };
  3707. ElementSerializer.prototype.serializeTo = function(writer) {
  3708. var hasBody = this.body.length,
  3709. indent = !(this.body.length === 1 && this.body[0] instanceof BodySerializer);
  3710. writer
  3711. .appendIndent()
  3712. .append('<' + nsName(this.ns));
  3713. this.serializeAttributes(writer);
  3714. writer.append(hasBody ? '>' : ' />');
  3715. if (hasBody) {
  3716. if (indent) {
  3717. writer
  3718. .appendNewLine()
  3719. .indent();
  3720. }
  3721. forEach(this.body, function(b) {
  3722. b.serializeTo(writer);
  3723. });
  3724. if (indent) {
  3725. writer
  3726. .unindent()
  3727. .appendIndent();
  3728. }
  3729. writer.append('</' + nsName(this.ns) + '>');
  3730. }
  3731. writer.appendNewLine();
  3732. };
  3733. /**
  3734. * A serializer for types that handles serialization of data types
  3735. */
  3736. function TypeSerializer(parent, ns) {
  3737. ElementSerializer.call(this, parent, ns);
  3738. }
  3739. TypeSerializer.prototype = new ElementSerializer();
  3740. TypeSerializer.prototype.build = function(element) {
  3741. var descriptor = element.$descriptor;
  3742. this.element = element;
  3743. this.typeNs = this.nsTagName(descriptor);
  3744. // add xsi:type attribute to represent the elements
  3745. // actual type
  3746. var typeNs = this.typeNs,
  3747. pkg = element.$model.getPackage(typeNs.uri),
  3748. typePrefix = (pkg.xml && pkg.xml.typePrefix) || '';
  3749. this.addAttribute(this.nsAttributeName(XSI_TYPE),
  3750. (typeNs.prefix ? typeNs.prefix + ':' : '') +
  3751. typePrefix + descriptor.ns.localName);
  3752. // do the usual stuff
  3753. return ElementSerializer.prototype.build.call(this, element);
  3754. };
  3755. TypeSerializer.prototype.isLocalNs = function(ns) {
  3756. return ns.uri === this.typeNs.uri;
  3757. };
  3758. function SavingWriter() {
  3759. this.value = '';
  3760. this.write = function(str) {
  3761. this.value += str;
  3762. };
  3763. }
  3764. function FormatingWriter(out, format) {
  3765. var indent = [''];
  3766. this.append = function(str) {
  3767. out.write(str);
  3768. return this;
  3769. };
  3770. this.appendNewLine = function() {
  3771. if (format) {
  3772. out.write('\n');
  3773. }
  3774. return this;
  3775. };
  3776. this.appendIndent = function() {
  3777. if (format) {
  3778. out.write(indent.join(' '));
  3779. }
  3780. return this;
  3781. };
  3782. this.indent = function() {
  3783. indent.push('');
  3784. return this;
  3785. };
  3786. this.unindent = function() {
  3787. indent.pop();
  3788. return this;
  3789. };
  3790. }
  3791. /**
  3792. * A writer for meta-model backed document trees
  3793. *
  3794. * @param {Object} options output options to pass into the writer
  3795. */
  3796. function XMLWriter(options) {
  3797. options = assign({ format: false, preamble: true }, options || {});
  3798. function toXML(tree, writer) {
  3799. var internalWriter = writer || new SavingWriter();
  3800. var formatingWriter = new FormatingWriter(internalWriter, options.format);
  3801. if (options.preamble) {
  3802. formatingWriter.append(XML_PREAMBLE);
  3803. }
  3804. new ElementSerializer().build(tree).serializeTo(formatingWriter);
  3805. if (!writer) {
  3806. return internalWriter.value;
  3807. }
  3808. }
  3809. return {
  3810. toXML: toXML
  3811. };
  3812. }
  3813. module.exports = XMLWriter;
  3814. },{"165":165,"168":168,"17":17,"27":27,"30":30,"75":75,"77":77,"80":80}],20:[function(_dereq_,module,exports){
  3815. (function (Buffer){
  3816. // wrapper for non-node envs
  3817. ;(function (sax) {
  3818. sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }
  3819. sax.SAXParser = SAXParser
  3820. sax.SAXStream = SAXStream
  3821. sax.createStream = createStream
  3822. // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
  3823. // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
  3824. // since that's the earliest that a buffer overrun could occur. This way, checks are
  3825. // as rare as required, but as often as necessary to ensure never crossing this bound.
  3826. // Furthermore, buffers are only tested at most once per write(), so passing a very
  3827. // large string into write() might have undesirable effects, but this is manageable by
  3828. // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
  3829. // edge case, result in creating at most one complete copy of the string passed in.
  3830. // Set to Infinity to have unlimited buffers.
  3831. sax.MAX_BUFFER_LENGTH = 64 * 1024
  3832. var buffers = [
  3833. "comment", "sgmlDecl", "textNode", "tagName", "doctype",
  3834. "procInstName", "procInstBody", "entity", "attribName",
  3835. "attribValue", "cdata", "script"
  3836. ]
  3837. sax.EVENTS = // for discoverability.
  3838. [ "text"
  3839. , "processinginstruction"
  3840. , "sgmldeclaration"
  3841. , "doctype"
  3842. , "comment"
  3843. , "attribute"
  3844. , "opentag"
  3845. , "closetag"
  3846. , "opencdata"
  3847. , "cdata"
  3848. , "closecdata"
  3849. , "error"
  3850. , "end"
  3851. , "ready"
  3852. , "script"
  3853. , "opennamespace"
  3854. , "closenamespace"
  3855. ]
  3856. function SAXParser (strict, opt) {
  3857. if (!(this instanceof SAXParser)) return new SAXParser(strict, opt)
  3858. var parser = this
  3859. clearBuffers(parser)
  3860. parser.q = parser.c = ""
  3861. parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH
  3862. parser.opt = opt || {}
  3863. parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags
  3864. parser.looseCase = parser.opt.lowercase ? "toLowerCase" : "toUpperCase"
  3865. parser.tags = []
  3866. parser.closed = parser.closedRoot = parser.sawRoot = false
  3867. parser.tag = parser.error = null
  3868. parser.strict = !!strict
  3869. parser.noscript = !!(strict || parser.opt.noscript)
  3870. parser.state = S.BEGIN
  3871. parser.ENTITIES = Object.create(sax.ENTITIES)
  3872. parser.attribList = []
  3873. // namespaces form a prototype chain.
  3874. // it always points at the current tag,
  3875. // which protos to its parent tag.
  3876. if (parser.opt.xmlns) parser.ns = Object.create(rootNS)
  3877. // mostly just for error reporting
  3878. parser.trackPosition = parser.opt.position !== false
  3879. if (parser.trackPosition) {
  3880. parser.position = parser.line = parser.column = 0
  3881. }
  3882. emit(parser, "onready")
  3883. }
  3884. if (!Object.create) Object.create = function (o) {
  3885. function f () { this.__proto__ = o }
  3886. f.prototype = o
  3887. return new f
  3888. }
  3889. if (!Object.getPrototypeOf) Object.getPrototypeOf = function (o) {
  3890. return o.__proto__
  3891. }
  3892. if (!Object.keys) Object.keys = function (o) {
  3893. var a = []
  3894. for (var i in o) if (o.hasOwnProperty(i)) a.push(i)
  3895. return a
  3896. }
  3897. function checkBufferLength (parser) {
  3898. var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)
  3899. , maxActual = 0
  3900. for (var i = 0, l = buffers.length; i < l; i ++) {
  3901. var len = parser[buffers[i]].length
  3902. if (len > maxAllowed) {
  3903. // Text/cdata nodes can get big, and since they're buffered,
  3904. // we can get here under normal conditions.
  3905. // Avoid issues by emitting the text node now,
  3906. // so at least it won't get any bigger.
  3907. switch (buffers[i]) {
  3908. case "textNode":
  3909. closeText(parser)
  3910. break
  3911. case "cdata":
  3912. emitNode(parser, "oncdata", parser.cdata)
  3913. parser.cdata = ""
  3914. break
  3915. case "script":
  3916. emitNode(parser, "onscript", parser.script)
  3917. parser.script = ""
  3918. break
  3919. default:
  3920. error(parser, "Max buffer length exceeded: "+buffers[i])
  3921. }
  3922. }
  3923. maxActual = Math.max(maxActual, len)
  3924. }
  3925. // schedule the next check for the earliest possible buffer overrun.
  3926. parser.bufferCheckPosition = (sax.MAX_BUFFER_LENGTH - maxActual)
  3927. + parser.position
  3928. }
  3929. function clearBuffers (parser) {
  3930. for (var i = 0, l = buffers.length; i < l; i ++) {
  3931. parser[buffers[i]] = ""
  3932. }
  3933. }
  3934. function flushBuffers (parser) {
  3935. closeText(parser)
  3936. if (parser.cdata !== "") {
  3937. emitNode(parser, "oncdata", parser.cdata)
  3938. parser.cdata = ""
  3939. }
  3940. if (parser.script !== "") {
  3941. emitNode(parser, "onscript", parser.script)
  3942. parser.script = ""
  3943. }
  3944. }
  3945. SAXParser.prototype =
  3946. { end: function () { end(this) }
  3947. , write: write
  3948. , resume: function () { this.error = null; return this }
  3949. , close: function () { return this.write(null) }
  3950. , flush: function () { flushBuffers(this) }
  3951. }
  3952. try {
  3953. var Stream = _dereq_("stream").Stream
  3954. } catch (ex) {
  3955. var Stream = function () {}
  3956. }
  3957. var streamWraps = sax.EVENTS.filter(function (ev) {
  3958. return ev !== "error" && ev !== "end"
  3959. })
  3960. function createStream (strict, opt) {
  3961. return new SAXStream(strict, opt)
  3962. }
  3963. function SAXStream (strict, opt) {
  3964. if (!(this instanceof SAXStream)) return new SAXStream(strict, opt)
  3965. Stream.apply(this)
  3966. this._parser = new SAXParser(strict, opt)
  3967. this.writable = true
  3968. this.readable = true
  3969. var me = this
  3970. this._parser.onend = function () {
  3971. me.emit("end")
  3972. }
  3973. this._parser.onerror = function (er) {
  3974. me.emit("error", er)
  3975. // if didn't throw, then means error was handled.
  3976. // go ahead and clear error, so we can write again.
  3977. me._parser.error = null
  3978. }
  3979. this._decoder = null;
  3980. streamWraps.forEach(function (ev) {
  3981. Object.defineProperty(me, "on" + ev, {
  3982. get: function () { return me._parser["on" + ev] },
  3983. set: function (h) {
  3984. if (!h) {
  3985. me.removeAllListeners(ev)
  3986. return me._parser["on"+ev] = h
  3987. }
  3988. me.on(ev, h)
  3989. },
  3990. enumerable: true,
  3991. configurable: false
  3992. })
  3993. })
  3994. }
  3995. SAXStream.prototype = Object.create(Stream.prototype,
  3996. { constructor: { value: SAXStream } })
  3997. SAXStream.prototype.write = function (data) {
  3998. if (typeof Buffer === 'function' &&
  3999. typeof Buffer.isBuffer === 'function' &&
  4000. Buffer.isBuffer(data)) {
  4001. if (!this._decoder) {
  4002. var SD = _dereq_('string_decoder').StringDecoder
  4003. this._decoder = new SD('utf8')
  4004. }
  4005. data = this._decoder.write(data);
  4006. }
  4007. this._parser.write(data.toString())
  4008. this.emit("data", data)
  4009. return true
  4010. }
  4011. SAXStream.prototype.end = function (chunk) {
  4012. if (chunk && chunk.length) this.write(chunk)
  4013. this._parser.end()
  4014. return true
  4015. }
  4016. SAXStream.prototype.on = function (ev, handler) {
  4017. var me = this
  4018. if (!me._parser["on"+ev] && streamWraps.indexOf(ev) !== -1) {
  4019. me._parser["on"+ev] = function () {
  4020. var args = arguments.length === 1 ? [arguments[0]]
  4021. : Array.apply(null, arguments)
  4022. args.splice(0, 0, ev)
  4023. me.emit.apply(me, args)
  4024. }
  4025. }
  4026. return Stream.prototype.on.call(me, ev, handler)
  4027. }
  4028. // character classes and tokens
  4029. var whitespace = "\r\n\t "
  4030. // this really needs to be replaced with character classes.
  4031. // XML allows all manner of ridiculous numbers and digits.
  4032. , number = "0124356789"
  4033. , letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  4034. // (Letter | "_" | ":")
  4035. , quote = "'\""
  4036. , entity = number+letter+"#"
  4037. , attribEnd = whitespace + ">"
  4038. , CDATA = "[CDATA["
  4039. , DOCTYPE = "DOCTYPE"
  4040. , XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace"
  4041. , XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/"
  4042. , rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }
  4043. // turn all the string character sets into character class objects.
  4044. whitespace = charClass(whitespace)
  4045. number = charClass(number)
  4046. letter = charClass(letter)
  4047. // http://www.w3.org/TR/REC-xml/#NT-NameStartChar
  4048. // This implementation works on strings, a single character at a time
  4049. // as such, it cannot ever support astral-plane characters (10000-EFFFF)
  4050. // without a significant breaking change to either this parser, or the
  4051. // JavaScript language. Implementation of an emoji-capable xml parser
  4052. // is left as an exercise for the reader.
  4053. 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]/
  4054. 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-]/
  4055. quote = charClass(quote)
  4056. entity = charClass(entity)
  4057. attribEnd = charClass(attribEnd)
  4058. function charClass (str) {
  4059. return str.split("").reduce(function (s, c) {
  4060. s[c] = true
  4061. return s
  4062. }, {})
  4063. }
  4064. function isRegExp (c) {
  4065. return Object.prototype.toString.call(c) === '[object RegExp]'
  4066. }
  4067. function is (charclass, c) {
  4068. return isRegExp(charclass) ? !!c.match(charclass) : charclass[c]
  4069. }
  4070. function not (charclass, c) {
  4071. return !is(charclass, c)
  4072. }
  4073. var S = 0
  4074. sax.STATE =
  4075. { BEGIN : S++
  4076. , TEXT : S++ // general stuff
  4077. , TEXT_ENTITY : S++ // &amp and such.
  4078. , OPEN_WAKA : S++ // <
  4079. , SGML_DECL : S++ // <!BLARG
  4080. , SGML_DECL_QUOTED : S++ // <!BLARG foo "bar
  4081. , DOCTYPE : S++ // <!DOCTYPE
  4082. , DOCTYPE_QUOTED : S++ // <!DOCTYPE "//blah
  4083. , DOCTYPE_DTD : S++ // <!DOCTYPE "//blah" [ ...
  4084. , DOCTYPE_DTD_QUOTED : S++ // <!DOCTYPE "//blah" [ "foo
  4085. , COMMENT_STARTING : S++ // <!-
  4086. , COMMENT : S++ // <!--
  4087. , COMMENT_ENDING : S++ // <!-- blah -
  4088. , COMMENT_ENDED : S++ // <!-- blah --
  4089. , CDATA : S++ // <![CDATA[ something
  4090. , CDATA_ENDING : S++ // ]
  4091. , CDATA_ENDING_2 : S++ // ]]
  4092. , PROC_INST : S++ // <?hi
  4093. , PROC_INST_BODY : S++ // <?hi there
  4094. , PROC_INST_ENDING : S++ // <?hi "there" ?
  4095. , OPEN_TAG : S++ // <strong
  4096. , OPEN_TAG_SLASH : S++ // <strong /
  4097. , ATTRIB : S++ // <a
  4098. , ATTRIB_NAME : S++ // <a foo
  4099. , ATTRIB_NAME_SAW_WHITE : S++ // <a foo _
  4100. , ATTRIB_VALUE : S++ // <a foo=
  4101. , ATTRIB_VALUE_QUOTED : S++ // <a foo="bar
  4102. , ATTRIB_VALUE_CLOSED : S++ // <a foo="bar"
  4103. , ATTRIB_VALUE_UNQUOTED : S++ // <a foo=bar
  4104. , ATTRIB_VALUE_ENTITY_Q : S++ // <foo bar="&quot;"
  4105. , ATTRIB_VALUE_ENTITY_U : S++ // <foo bar=&quot;
  4106. , CLOSE_TAG : S++ // </a
  4107. , CLOSE_TAG_SAW_WHITE : S++ // </a >
  4108. , SCRIPT : S++ // <script> ...
  4109. , SCRIPT_ENDING : S++ // <script> ... <
  4110. }
  4111. sax.ENTITIES =
  4112. { "amp" : "&"
  4113. , "gt" : ">"
  4114. , "lt" : "<"
  4115. , "quot" : "\""
  4116. , "apos" : "'"
  4117. , "AElig" : 198
  4118. , "Aacute" : 193
  4119. , "Acirc" : 194
  4120. , "Agrave" : 192
  4121. , "Aring" : 197
  4122. , "Atilde" : 195
  4123. , "Auml" : 196
  4124. , "Ccedil" : 199
  4125. , "ETH" : 208
  4126. , "Eacute" : 201
  4127. , "Ecirc" : 202
  4128. , "Egrave" : 200
  4129. , "Euml" : 203
  4130. , "Iacute" : 205
  4131. , "Icirc" : 206
  4132. , "Igrave" : 204
  4133. , "Iuml" : 207
  4134. , "Ntilde" : 209
  4135. , "Oacute" : 211
  4136. , "Ocirc" : 212
  4137. , "Ograve" : 210
  4138. , "Oslash" : 216
  4139. , "Otilde" : 213
  4140. , "Ouml" : 214
  4141. , "THORN" : 222
  4142. , "Uacute" : 218
  4143. , "Ucirc" : 219
  4144. , "Ugrave" : 217
  4145. , "Uuml" : 220
  4146. , "Yacute" : 221
  4147. , "aacute" : 225
  4148. , "acirc" : 226
  4149. , "aelig" : 230
  4150. , "agrave" : 224
  4151. , "aring" : 229
  4152. , "atilde" : 227
  4153. , "auml" : 228
  4154. , "ccedil" : 231
  4155. , "eacute" : 233
  4156. , "ecirc" : 234
  4157. , "egrave" : 232
  4158. , "eth" : 240
  4159. , "euml" : 235
  4160. , "iacute" : 237
  4161. , "icirc" : 238
  4162. , "igrave" : 236
  4163. , "iuml" : 239
  4164. , "ntilde" : 241
  4165. , "oacute" : 243
  4166. , "ocirc" : 244
  4167. , "ograve" : 242
  4168. , "oslash" : 248
  4169. , "otilde" : 245
  4170. , "ouml" : 246
  4171. , "szlig" : 223
  4172. , "thorn" : 254
  4173. , "uacute" : 250
  4174. , "ucirc" : 251
  4175. , "ugrave" : 249
  4176. , "uuml" : 252
  4177. , "yacute" : 253
  4178. , "yuml" : 255
  4179. , "copy" : 169
  4180. , "reg" : 174
  4181. , "nbsp" : 160
  4182. , "iexcl" : 161
  4183. , "cent" : 162
  4184. , "pound" : 163
  4185. , "curren" : 164
  4186. , "yen" : 165
  4187. , "brvbar" : 166
  4188. , "sect" : 167
  4189. , "uml" : 168
  4190. , "ordf" : 170
  4191. , "laquo" : 171
  4192. , "not" : 172
  4193. , "shy" : 173
  4194. , "macr" : 175
  4195. , "deg" : 176
  4196. , "plusmn" : 177
  4197. , "sup1" : 185
  4198. , "sup2" : 178
  4199. , "sup3" : 179
  4200. , "acute" : 180
  4201. , "micro" : 181
  4202. , "para" : 182
  4203. , "middot" : 183
  4204. , "cedil" : 184
  4205. , "ordm" : 186
  4206. , "raquo" : 187
  4207. , "frac14" : 188
  4208. , "frac12" : 189
  4209. , "frac34" : 190
  4210. , "iquest" : 191
  4211. , "times" : 215
  4212. , "divide" : 247
  4213. , "OElig" : 338
  4214. , "oelig" : 339
  4215. , "Scaron" : 352
  4216. , "scaron" : 353
  4217. , "Yuml" : 376
  4218. , "fnof" : 402
  4219. , "circ" : 710
  4220. , "tilde" : 732
  4221. , "Alpha" : 913
  4222. , "Beta" : 914
  4223. , "Gamma" : 915
  4224. , "Delta" : 916
  4225. , "Epsilon" : 917
  4226. , "Zeta" : 918
  4227. , "Eta" : 919
  4228. , "Theta" : 920
  4229. , "Iota" : 921
  4230. , "Kappa" : 922
  4231. , "Lambda" : 923
  4232. , "Mu" : 924
  4233. , "Nu" : 925
  4234. , "Xi" : 926
  4235. , "Omicron" : 927
  4236. , "Pi" : 928
  4237. , "Rho" : 929
  4238. , "Sigma" : 931
  4239. , "Tau" : 932
  4240. , "Upsilon" : 933
  4241. , "Phi" : 934
  4242. , "Chi" : 935
  4243. , "Psi" : 936
  4244. , "Omega" : 937
  4245. , "alpha" : 945
  4246. , "beta" : 946
  4247. , "gamma" : 947
  4248. , "delta" : 948
  4249. , "epsilon" : 949
  4250. , "zeta" : 950
  4251. , "eta" : 951
  4252. , "theta" : 952
  4253. , "iota" : 953
  4254. , "kappa" : 954
  4255. , "lambda" : 955
  4256. , "mu" : 956
  4257. , "nu" : 957
  4258. , "xi" : 958
  4259. , "omicron" : 959
  4260. , "pi" : 960
  4261. , "rho" : 961
  4262. , "sigmaf" : 962
  4263. , "sigma" : 963
  4264. , "tau" : 964
  4265. , "upsilon" : 965
  4266. , "phi" : 966
  4267. , "chi" : 967
  4268. , "psi" : 968
  4269. , "omega" : 969
  4270. , "thetasym" : 977
  4271. , "upsih" : 978
  4272. , "piv" : 982
  4273. , "ensp" : 8194
  4274. , "emsp" : 8195
  4275. , "thinsp" : 8201
  4276. , "zwnj" : 8204
  4277. , "zwj" : 8205
  4278. , "lrm" : 8206
  4279. , "rlm" : 8207
  4280. , "ndash" : 8211
  4281. , "mdash" : 8212
  4282. , "lsquo" : 8216
  4283. , "rsquo" : 8217
  4284. , "sbquo" : 8218
  4285. , "ldquo" : 8220
  4286. , "rdquo" : 8221
  4287. , "bdquo" : 8222
  4288. , "dagger" : 8224
  4289. , "Dagger" : 8225
  4290. , "bull" : 8226
  4291. , "hellip" : 8230
  4292. , "permil" : 8240
  4293. , "prime" : 8242
  4294. , "Prime" : 8243
  4295. , "lsaquo" : 8249
  4296. , "rsaquo" : 8250
  4297. , "oline" : 8254
  4298. , "frasl" : 8260
  4299. , "euro" : 8364
  4300. , "image" : 8465
  4301. , "weierp" : 8472
  4302. , "real" : 8476
  4303. , "trade" : 8482
  4304. , "alefsym" : 8501
  4305. , "larr" : 8592
  4306. , "uarr" : 8593
  4307. , "rarr" : 8594
  4308. , "darr" : 8595
  4309. , "harr" : 8596
  4310. , "crarr" : 8629
  4311. , "lArr" : 8656
  4312. , "uArr" : 8657
  4313. , "rArr" : 8658
  4314. , "dArr" : 8659
  4315. , "hArr" : 8660
  4316. , "forall" : 8704
  4317. , "part" : 8706
  4318. , "exist" : 8707
  4319. , "empty" : 8709
  4320. , "nabla" : 8711
  4321. , "isin" : 8712
  4322. , "notin" : 8713
  4323. , "ni" : 8715
  4324. , "prod" : 8719
  4325. , "sum" : 8721
  4326. , "minus" : 8722
  4327. , "lowast" : 8727
  4328. , "radic" : 8730
  4329. , "prop" : 8733
  4330. , "infin" : 8734
  4331. , "ang" : 8736
  4332. , "and" : 8743
  4333. , "or" : 8744
  4334. , "cap" : 8745
  4335. , "cup" : 8746
  4336. , "int" : 8747
  4337. , "there4" : 8756
  4338. , "sim" : 8764
  4339. , "cong" : 8773
  4340. , "asymp" : 8776
  4341. , "ne" : 8800
  4342. , "equiv" : 8801
  4343. , "le" : 8804
  4344. , "ge" : 8805
  4345. , "sub" : 8834
  4346. , "sup" : 8835
  4347. , "nsub" : 8836
  4348. , "sube" : 8838
  4349. , "supe" : 8839
  4350. , "oplus" : 8853
  4351. , "otimes" : 8855
  4352. , "perp" : 8869
  4353. , "sdot" : 8901
  4354. , "lceil" : 8968
  4355. , "rceil" : 8969
  4356. , "lfloor" : 8970
  4357. , "rfloor" : 8971
  4358. , "lang" : 9001
  4359. , "rang" : 9002
  4360. , "loz" : 9674
  4361. , "spades" : 9824
  4362. , "clubs" : 9827
  4363. , "hearts" : 9829
  4364. , "diams" : 9830
  4365. }
  4366. Object.keys(sax.ENTITIES).forEach(function (key) {
  4367. var e = sax.ENTITIES[key]
  4368. var s = typeof e === 'number' ? String.fromCharCode(e) : e
  4369. sax.ENTITIES[key] = s
  4370. })
  4371. for (var S in sax.STATE) sax.STATE[sax.STATE[S]] = S
  4372. // shorthand
  4373. S = sax.STATE
  4374. function emit (parser, event, data) {
  4375. parser[event] && parser[event](data)
  4376. }
  4377. function emitNode (parser, nodeType, data) {
  4378. if (parser.textNode) closeText(parser)
  4379. emit(parser, nodeType, data)
  4380. }
  4381. function closeText (parser) {
  4382. parser.textNode = textopts(parser.opt, parser.textNode)
  4383. if (parser.textNode) emit(parser, "ontext", parser.textNode)
  4384. parser.textNode = ""
  4385. }
  4386. function textopts (opt, text) {
  4387. if (opt.trim) text = text.trim()
  4388. if (opt.normalize) text = text.replace(/\s+/g, " ")
  4389. return text
  4390. }
  4391. function error (parser, er) {
  4392. closeText(parser)
  4393. if (parser.trackPosition) {
  4394. er += "\nLine: "+parser.line+
  4395. "\nColumn: "+parser.column+
  4396. "\nChar: "+parser.c
  4397. }
  4398. er = new Error(er)
  4399. parser.error = er
  4400. emit(parser, "onerror", er)
  4401. return parser
  4402. }
  4403. function end (parser) {
  4404. if (!parser.closedRoot) strictFail(parser, "Unclosed root tag")
  4405. if ((parser.state !== S.BEGIN) && (parser.state !== S.TEXT)) error(parser, "Unexpected end")
  4406. closeText(parser)
  4407. parser.c = ""
  4408. parser.closed = true
  4409. emit(parser, "onend")
  4410. SAXParser.call(parser, parser.strict, parser.opt)
  4411. return parser
  4412. }
  4413. function strictFail (parser, message) {
  4414. if (typeof parser !== 'object' || !(parser instanceof SAXParser))
  4415. throw new Error('bad call to strictFail');
  4416. if (parser.strict) error(parser, message)
  4417. }
  4418. function newTag (parser) {
  4419. if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]()
  4420. var parent = parser.tags[parser.tags.length - 1] || parser
  4421. , tag = parser.tag = { name : parser.tagName, attributes : {} }
  4422. // will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
  4423. if (parser.opt.xmlns) tag.ns = parent.ns
  4424. parser.attribList.length = 0
  4425. }
  4426. function qname (name, attribute) {
  4427. var i = name.indexOf(":")
  4428. , qualName = i < 0 ? [ "", name ] : name.split(":")
  4429. , prefix = qualName[0]
  4430. , local = qualName[1]
  4431. // <x "xmlns"="http://foo">
  4432. if (attribute && name === "xmlns") {
  4433. prefix = "xmlns"
  4434. local = ""
  4435. }
  4436. return { prefix: prefix, local: local }
  4437. }
  4438. function attrib (parser) {
  4439. if (!parser.strict) parser.attribName = parser.attribName[parser.looseCase]()
  4440. if (parser.attribList.indexOf(parser.attribName) !== -1 ||
  4441. parser.tag.attributes.hasOwnProperty(parser.attribName)) {
  4442. return parser.attribName = parser.attribValue = ""
  4443. }
  4444. if (parser.opt.xmlns) {
  4445. var qn = qname(parser.attribName, true)
  4446. , prefix = qn.prefix
  4447. , local = qn.local
  4448. if (prefix === "xmlns") {
  4449. // namespace binding attribute; push the binding into scope
  4450. if (local === "xml" && parser.attribValue !== XML_NAMESPACE) {
  4451. strictFail( parser
  4452. , "xml: prefix must be bound to " + XML_NAMESPACE + "\n"
  4453. + "Actual: " + parser.attribValue )
  4454. } else if (local === "xmlns" && parser.attribValue !== XMLNS_NAMESPACE) {
  4455. strictFail( parser
  4456. , "xmlns: prefix must be bound to " + XMLNS_NAMESPACE + "\n"
  4457. + "Actual: " + parser.attribValue )
  4458. } else {
  4459. var tag = parser.tag
  4460. , parent = parser.tags[parser.tags.length - 1] || parser
  4461. if (tag.ns === parent.ns) {
  4462. tag.ns = Object.create(parent.ns)
  4463. }
  4464. tag.ns[local] = parser.attribValue
  4465. }
  4466. }
  4467. // defer onattribute events until all attributes have been seen
  4468. // so any new bindings can take effect; preserve attribute order
  4469. // so deferred events can be emitted in document order
  4470. parser.attribList.push([parser.attribName, parser.attribValue])
  4471. } else {
  4472. // in non-xmlns mode, we can emit the event right away
  4473. parser.tag.attributes[parser.attribName] = parser.attribValue
  4474. emitNode( parser
  4475. , "onattribute"
  4476. , { name: parser.attribName
  4477. , value: parser.attribValue } )
  4478. }
  4479. parser.attribName = parser.attribValue = ""
  4480. }
  4481. function openTag (parser, selfClosing) {
  4482. if (parser.opt.xmlns) {
  4483. // emit namespace binding events
  4484. var tag = parser.tag
  4485. // add namespace info to tag
  4486. var qn = qname(parser.tagName)
  4487. tag.prefix = qn.prefix
  4488. tag.local = qn.local
  4489. tag.uri = tag.ns[qn.prefix] || ""
  4490. if (tag.prefix && !tag.uri) {
  4491. strictFail(parser, "Unbound namespace prefix: "
  4492. + JSON.stringify(parser.tagName))
  4493. tag.uri = qn.prefix
  4494. }
  4495. var parent = parser.tags[parser.tags.length - 1] || parser
  4496. if (tag.ns && parent.ns !== tag.ns) {
  4497. Object.keys(tag.ns).forEach(function (p) {
  4498. emitNode( parser
  4499. , "onopennamespace"
  4500. , { prefix: p , uri: tag.ns[p] } )
  4501. })
  4502. }
  4503. // handle deferred onattribute events
  4504. // Note: do not apply default ns to attributes:
  4505. // http://www.w3.org/TR/REC-xml-names/#defaulting
  4506. for (var i = 0, l = parser.attribList.length; i < l; i ++) {
  4507. var nv = parser.attribList[i]
  4508. var name = nv[0]
  4509. , value = nv[1]
  4510. , qualName = qname(name, true)
  4511. , prefix = qualName.prefix
  4512. , local = qualName.local
  4513. , uri = prefix == "" ? "" : (tag.ns[prefix] || "")
  4514. , a = { name: name
  4515. , value: value
  4516. , prefix: prefix
  4517. , local: local
  4518. , uri: uri
  4519. }
  4520. // if there's any attributes with an undefined namespace,
  4521. // then fail on them now.
  4522. if (prefix && prefix != "xmlns" && !uri) {
  4523. strictFail(parser, "Unbound namespace prefix: "
  4524. + JSON.stringify(prefix))
  4525. a.uri = prefix
  4526. }
  4527. parser.tag.attributes[name] = a
  4528. emitNode(parser, "onattribute", a)
  4529. }
  4530. parser.attribList.length = 0
  4531. }
  4532. parser.tag.isSelfClosing = !!selfClosing
  4533. // process the tag
  4534. parser.sawRoot = true
  4535. parser.tags.push(parser.tag)
  4536. emitNode(parser, "onopentag", parser.tag)
  4537. if (!selfClosing) {
  4538. // special case for <script> in non-strict mode.
  4539. if (!parser.noscript && parser.tagName.toLowerCase() === "script") {
  4540. parser.state = S.SCRIPT
  4541. } else {
  4542. parser.state = S.TEXT
  4543. }
  4544. parser.tag = null
  4545. parser.tagName = ""
  4546. }
  4547. parser.attribName = parser.attribValue = ""
  4548. parser.attribList.length = 0
  4549. }
  4550. function closeTag (parser) {
  4551. if (!parser.tagName) {
  4552. strictFail(parser, "Weird empty close tag.")
  4553. parser.textNode += "</>"
  4554. parser.state = S.TEXT
  4555. return
  4556. }
  4557. if (parser.script) {
  4558. if (parser.tagName !== "script") {
  4559. parser.script += "</" + parser.tagName + ">"
  4560. parser.tagName = ""
  4561. parser.state = S.SCRIPT
  4562. return
  4563. }
  4564. emitNode(parser, "onscript", parser.script)
  4565. parser.script = ""
  4566. }
  4567. // first make sure that the closing tag actually exists.
  4568. // <a><b></c></b></a> will close everything, otherwise.
  4569. var t = parser.tags.length
  4570. var tagName = parser.tagName
  4571. if (!parser.strict) tagName = tagName[parser.looseCase]()
  4572. var closeTo = tagName
  4573. while (t --) {
  4574. var close = parser.tags[t]
  4575. if (close.name !== closeTo) {
  4576. // fail the first time in strict mode
  4577. strictFail(parser, "Unexpected close tag")
  4578. } else break
  4579. }
  4580. // didn't find it. we already failed for strict, so just abort.
  4581. if (t < 0) {
  4582. strictFail(parser, "Unmatched closing tag: "+parser.tagName)
  4583. parser.textNode += "</" + parser.tagName + ">"
  4584. parser.state = S.TEXT
  4585. return
  4586. }
  4587. parser.tagName = tagName
  4588. var s = parser.tags.length
  4589. while (s --> t) {
  4590. var tag = parser.tag = parser.tags.pop()
  4591. parser.tagName = parser.tag.name
  4592. emitNode(parser, "onclosetag", parser.tagName)
  4593. var x = {}
  4594. for (var i in tag.ns) x[i] = tag.ns[i]
  4595. var parent = parser.tags[parser.tags.length - 1] || parser
  4596. if (parser.opt.xmlns && tag.ns !== parent.ns) {
  4597. // remove namespace bindings introduced by tag
  4598. Object.keys(tag.ns).forEach(function (p) {
  4599. var n = tag.ns[p]
  4600. emitNode(parser, "onclosenamespace", { prefix: p, uri: n })
  4601. })
  4602. }
  4603. }
  4604. if (t === 0) parser.closedRoot = true
  4605. parser.tagName = parser.attribValue = parser.attribName = ""
  4606. parser.attribList.length = 0
  4607. parser.state = S.TEXT
  4608. }
  4609. function parseEntity (parser) {
  4610. var entity = parser.entity
  4611. , entityLC = entity.toLowerCase()
  4612. , num
  4613. , numStr = ""
  4614. if (parser.ENTITIES[entity])
  4615. return parser.ENTITIES[entity]
  4616. if (parser.ENTITIES[entityLC])
  4617. return parser.ENTITIES[entityLC]
  4618. entity = entityLC
  4619. if (entity.charAt(0) === "#") {
  4620. if (entity.charAt(1) === "x") {
  4621. entity = entity.slice(2)
  4622. num = parseInt(entity, 16)
  4623. numStr = num.toString(16)
  4624. } else {
  4625. entity = entity.slice(1)
  4626. num = parseInt(entity, 10)
  4627. numStr = num.toString(10)
  4628. }
  4629. }
  4630. entity = entity.replace(/^0+/, "")
  4631. if (numStr.toLowerCase() !== entity) {
  4632. strictFail(parser, "Invalid character entity")
  4633. return "&"+parser.entity + ";"
  4634. }
  4635. return String.fromCodePoint(num)
  4636. }
  4637. function write (chunk) {
  4638. var parser = this
  4639. if (this.error) throw this.error
  4640. if (parser.closed) return error(parser,
  4641. "Cannot write after close. Assign an onready handler.")
  4642. if (chunk === null) return end(parser)
  4643. var i = 0, c = ""
  4644. while (parser.c = c = chunk.charAt(i++)) {
  4645. if (parser.trackPosition) {
  4646. parser.position ++
  4647. if (c === "\n") {
  4648. parser.line ++
  4649. parser.column = 0
  4650. } else parser.column ++
  4651. }
  4652. switch (parser.state) {
  4653. case S.BEGIN:
  4654. if (c === "<") {
  4655. parser.state = S.OPEN_WAKA
  4656. parser.startTagPosition = parser.position
  4657. } else if (not(whitespace,c)) {
  4658. // have to process this as a text node.
  4659. // weird, but happens.
  4660. strictFail(parser, "Non-whitespace before first tag.")
  4661. parser.textNode = c
  4662. parser.state = S.TEXT
  4663. }
  4664. continue
  4665. case S.TEXT:
  4666. if (parser.sawRoot && !parser.closedRoot) {
  4667. var starti = i-1
  4668. while (c && c!=="<" && c!=="&") {
  4669. c = chunk.charAt(i++)
  4670. if (c && parser.trackPosition) {
  4671. parser.position ++
  4672. if (c === "\n") {
  4673. parser.line ++
  4674. parser.column = 0
  4675. } else parser.column ++
  4676. }
  4677. }
  4678. parser.textNode += chunk.substring(starti, i-1)
  4679. }
  4680. if (c === "<") {
  4681. parser.state = S.OPEN_WAKA
  4682. parser.startTagPosition = parser.position
  4683. } else {
  4684. if (not(whitespace, c) && (!parser.sawRoot || parser.closedRoot))
  4685. strictFail(parser, "Text data outside of root node.")
  4686. if (c === "&") parser.state = S.TEXT_ENTITY
  4687. else parser.textNode += c
  4688. }
  4689. continue
  4690. case S.SCRIPT:
  4691. // only non-strict
  4692. if (c === "<") {
  4693. parser.state = S.SCRIPT_ENDING
  4694. } else parser.script += c
  4695. continue
  4696. case S.SCRIPT_ENDING:
  4697. if (c === "/") {
  4698. parser.state = S.CLOSE_TAG
  4699. } else {
  4700. parser.script += "<" + c
  4701. parser.state = S.SCRIPT
  4702. }
  4703. continue
  4704. case S.OPEN_WAKA:
  4705. // either a /, ?, !, or text is coming next.
  4706. if (c === "!") {
  4707. parser.state = S.SGML_DECL
  4708. parser.sgmlDecl = ""
  4709. } else if (is(whitespace, c)) {
  4710. // wait for it...
  4711. } else if (is(nameStart,c)) {
  4712. parser.state = S.OPEN_TAG
  4713. parser.tagName = c
  4714. } else if (c === "/") {
  4715. parser.state = S.CLOSE_TAG
  4716. parser.tagName = ""
  4717. } else if (c === "?") {
  4718. parser.state = S.PROC_INST
  4719. parser.procInstName = parser.procInstBody = ""
  4720. } else {
  4721. strictFail(parser, "Unencoded <")
  4722. // if there was some whitespace, then add that in.
  4723. if (parser.startTagPosition + 1 < parser.position) {
  4724. var pad = parser.position - parser.startTagPosition
  4725. c = new Array(pad).join(" ") + c
  4726. }
  4727. parser.textNode += "<" + c
  4728. parser.state = S.TEXT
  4729. }
  4730. continue
  4731. case S.SGML_DECL:
  4732. if ((parser.sgmlDecl+c).toUpperCase() === CDATA) {
  4733. emitNode(parser, "onopencdata")
  4734. parser.state = S.CDATA
  4735. parser.sgmlDecl = ""
  4736. parser.cdata = ""
  4737. } else if (parser.sgmlDecl+c === "--") {
  4738. parser.state = S.COMMENT
  4739. parser.comment = ""
  4740. parser.sgmlDecl = ""
  4741. } else if ((parser.sgmlDecl+c).toUpperCase() === DOCTYPE) {
  4742. parser.state = S.DOCTYPE
  4743. if (parser.doctype || parser.sawRoot) strictFail(parser,
  4744. "Inappropriately located doctype declaration")
  4745. parser.doctype = ""
  4746. parser.sgmlDecl = ""
  4747. } else if (c === ">") {
  4748. emitNode(parser, "onsgmldeclaration", parser.sgmlDecl)
  4749. parser.sgmlDecl = ""
  4750. parser.state = S.TEXT
  4751. } else if (is(quote, c)) {
  4752. parser.state = S.SGML_DECL_QUOTED
  4753. parser.sgmlDecl += c
  4754. } else parser.sgmlDecl += c
  4755. continue
  4756. case S.SGML_DECL_QUOTED:
  4757. if (c === parser.q) {
  4758. parser.state = S.SGML_DECL
  4759. parser.q = ""
  4760. }
  4761. parser.sgmlDecl += c
  4762. continue
  4763. case S.DOCTYPE:
  4764. if (c === ">") {
  4765. parser.state = S.TEXT
  4766. emitNode(parser, "ondoctype", parser.doctype)
  4767. parser.doctype = true // just remember that we saw it.
  4768. } else {
  4769. parser.doctype += c
  4770. if (c === "[") parser.state = S.DOCTYPE_DTD
  4771. else if (is(quote, c)) {
  4772. parser.state = S.DOCTYPE_QUOTED
  4773. parser.q = c
  4774. }
  4775. }
  4776. continue
  4777. case S.DOCTYPE_QUOTED:
  4778. parser.doctype += c
  4779. if (c === parser.q) {
  4780. parser.q = ""
  4781. parser.state = S.DOCTYPE
  4782. }
  4783. continue
  4784. case S.DOCTYPE_DTD:
  4785. parser.doctype += c
  4786. if (c === "]") parser.state = S.DOCTYPE
  4787. else if (is(quote,c)) {
  4788. parser.state = S.DOCTYPE_DTD_QUOTED
  4789. parser.q = c
  4790. }
  4791. continue
  4792. case S.DOCTYPE_DTD_QUOTED:
  4793. parser.doctype += c
  4794. if (c === parser.q) {
  4795. parser.state = S.DOCTYPE_DTD
  4796. parser.q = ""
  4797. }
  4798. continue
  4799. case S.COMMENT:
  4800. if (c === "-") parser.state = S.COMMENT_ENDING
  4801. else parser.comment += c
  4802. continue
  4803. case S.COMMENT_ENDING:
  4804. if (c === "-") {
  4805. parser.state = S.COMMENT_ENDED
  4806. parser.comment = textopts(parser.opt, parser.comment)
  4807. if (parser.comment) emitNode(parser, "oncomment", parser.comment)
  4808. parser.comment = ""
  4809. } else {
  4810. parser.comment += "-" + c
  4811. parser.state = S.COMMENT
  4812. }
  4813. continue
  4814. case S.COMMENT_ENDED:
  4815. if (c !== ">") {
  4816. strictFail(parser, "Malformed comment")
  4817. // allow <!-- blah -- bloo --> in non-strict mode,
  4818. // which is a comment of " blah -- bloo "
  4819. parser.comment += "--" + c
  4820. parser.state = S.COMMENT
  4821. } else parser.state = S.TEXT
  4822. continue
  4823. case S.CDATA:
  4824. if (c === "]") parser.state = S.CDATA_ENDING
  4825. else parser.cdata += c
  4826. continue
  4827. case S.CDATA_ENDING:
  4828. if (c === "]") parser.state = S.CDATA_ENDING_2
  4829. else {
  4830. parser.cdata += "]" + c
  4831. parser.state = S.CDATA
  4832. }
  4833. continue
  4834. case S.CDATA_ENDING_2:
  4835. if (c === ">") {
  4836. if (parser.cdata) emitNode(parser, "oncdata", parser.cdata)
  4837. emitNode(parser, "onclosecdata")
  4838. parser.cdata = ""
  4839. parser.state = S.TEXT
  4840. } else if (c === "]") {
  4841. parser.cdata += "]"
  4842. } else {
  4843. parser.cdata += "]]" + c
  4844. parser.state = S.CDATA
  4845. }
  4846. continue
  4847. case S.PROC_INST:
  4848. if (c === "?") parser.state = S.PROC_INST_ENDING
  4849. else if (is(whitespace, c)) parser.state = S.PROC_INST_BODY
  4850. else parser.procInstName += c
  4851. continue
  4852. case S.PROC_INST_BODY:
  4853. if (!parser.procInstBody && is(whitespace, c)) continue
  4854. else if (c === "?") parser.state = S.PROC_INST_ENDING
  4855. else parser.procInstBody += c
  4856. continue
  4857. case S.PROC_INST_ENDING:
  4858. if (c === ">") {
  4859. emitNode(parser, "onprocessinginstruction", {
  4860. name : parser.procInstName,
  4861. body : parser.procInstBody
  4862. })
  4863. parser.procInstName = parser.procInstBody = ""
  4864. parser.state = S.TEXT
  4865. } else {
  4866. parser.procInstBody += "?" + c
  4867. parser.state = S.PROC_INST_BODY
  4868. }
  4869. continue
  4870. case S.OPEN_TAG:
  4871. if (is(nameBody, c)) parser.tagName += c
  4872. else {
  4873. newTag(parser)
  4874. if (c === ">") openTag(parser)
  4875. else if (c === "/") parser.state = S.OPEN_TAG_SLASH
  4876. else {
  4877. if (not(whitespace, c)) strictFail(
  4878. parser, "Invalid character in tag name")
  4879. parser.state = S.ATTRIB
  4880. }
  4881. }
  4882. continue
  4883. case S.OPEN_TAG_SLASH:
  4884. if (c === ">") {
  4885. openTag(parser, true)
  4886. closeTag(parser)
  4887. } else {
  4888. strictFail(parser, "Forward-slash in opening tag not followed by >")
  4889. parser.state = S.ATTRIB
  4890. }
  4891. continue
  4892. case S.ATTRIB:
  4893. // haven't read the attribute name yet.
  4894. if (is(whitespace, c)) continue
  4895. else if (c === ">") openTag(parser)
  4896. else if (c === "/") parser.state = S.OPEN_TAG_SLASH
  4897. else if (is(nameStart, c)) {
  4898. parser.attribName = c
  4899. parser.attribValue = ""
  4900. parser.state = S.ATTRIB_NAME
  4901. } else strictFail(parser, "Invalid attribute name")
  4902. continue
  4903. case S.ATTRIB_NAME:
  4904. if (c === "=") parser.state = S.ATTRIB_VALUE
  4905. else if (c === ">") {
  4906. strictFail(parser, "Attribute without value")
  4907. parser.attribValue = parser.attribName
  4908. attrib(parser)
  4909. openTag(parser)
  4910. }
  4911. else if (is(whitespace, c)) parser.state = S.ATTRIB_NAME_SAW_WHITE
  4912. else if (is(nameBody, c)) parser.attribName += c
  4913. else strictFail(parser, "Invalid attribute name")
  4914. continue
  4915. case S.ATTRIB_NAME_SAW_WHITE:
  4916. if (c === "=") parser.state = S.ATTRIB_VALUE
  4917. else if (is(whitespace, c)) continue
  4918. else {
  4919. strictFail(parser, "Attribute without value")
  4920. parser.tag.attributes[parser.attribName] = ""
  4921. parser.attribValue = ""
  4922. emitNode(parser, "onattribute",
  4923. { name : parser.attribName, value : "" })
  4924. parser.attribName = ""
  4925. if (c === ">") openTag(parser)
  4926. else if (is(nameStart, c)) {
  4927. parser.attribName = c
  4928. parser.state = S.ATTRIB_NAME
  4929. } else {
  4930. strictFail(parser, "Invalid attribute name")
  4931. parser.state = S.ATTRIB
  4932. }
  4933. }
  4934. continue
  4935. case S.ATTRIB_VALUE:
  4936. if (is(whitespace, c)) continue
  4937. else if (is(quote, c)) {
  4938. parser.q = c
  4939. parser.state = S.ATTRIB_VALUE_QUOTED
  4940. } else {
  4941. strictFail(parser, "Unquoted attribute value")
  4942. parser.state = S.ATTRIB_VALUE_UNQUOTED
  4943. parser.attribValue = c
  4944. }
  4945. continue
  4946. case S.ATTRIB_VALUE_QUOTED:
  4947. if (c !== parser.q) {
  4948. if (c === "&") parser.state = S.ATTRIB_VALUE_ENTITY_Q
  4949. else parser.attribValue += c
  4950. continue
  4951. }
  4952. attrib(parser)
  4953. parser.q = ""
  4954. parser.state = S.ATTRIB_VALUE_CLOSED
  4955. continue
  4956. case S.ATTRIB_VALUE_CLOSED:
  4957. if (is(whitespace, c)) {
  4958. parser.state = S.ATTRIB
  4959. } else if (c === ">") openTag(parser)
  4960. else if (c === "/") parser.state = S.OPEN_TAG_SLASH
  4961. else if (is(nameStart, c)) {
  4962. strictFail(parser, "No whitespace between attributes")
  4963. parser.attribName = c
  4964. parser.attribValue = ""
  4965. parser.state = S.ATTRIB_NAME
  4966. } else strictFail(parser, "Invalid attribute name")
  4967. continue
  4968. case S.ATTRIB_VALUE_UNQUOTED:
  4969. if (not(attribEnd,c)) {
  4970. if (c === "&") parser.state = S.ATTRIB_VALUE_ENTITY_U
  4971. else parser.attribValue += c
  4972. continue
  4973. }
  4974. attrib(parser)
  4975. if (c === ">") openTag(parser)
  4976. else parser.state = S.ATTRIB
  4977. continue
  4978. case S.CLOSE_TAG:
  4979. if (!parser.tagName) {
  4980. if (is(whitespace, c)) continue
  4981. else if (not(nameStart, c)) {
  4982. if (parser.script) {
  4983. parser.script += "</" + c
  4984. parser.state = S.SCRIPT
  4985. } else {
  4986. strictFail(parser, "Invalid tagname in closing tag.")
  4987. }
  4988. } else parser.tagName = c
  4989. }
  4990. else if (c === ">") closeTag(parser)
  4991. else if (is(nameBody, c)) parser.tagName += c
  4992. else if (parser.script) {
  4993. parser.script += "</" + parser.tagName
  4994. parser.tagName = ""
  4995. parser.state = S.SCRIPT
  4996. } else {
  4997. if (not(whitespace, c)) strictFail(parser,
  4998. "Invalid tagname in closing tag")
  4999. parser.state = S.CLOSE_TAG_SAW_WHITE
  5000. }
  5001. continue
  5002. case S.CLOSE_TAG_SAW_WHITE:
  5003. if (is(whitespace, c)) continue
  5004. if (c === ">") closeTag(parser)
  5005. else strictFail(parser, "Invalid characters in closing tag")
  5006. continue
  5007. case S.TEXT_ENTITY:
  5008. case S.ATTRIB_VALUE_ENTITY_Q:
  5009. case S.ATTRIB_VALUE_ENTITY_U:
  5010. switch(parser.state) {
  5011. case S.TEXT_ENTITY:
  5012. var returnState = S.TEXT, buffer = "textNode"
  5013. break
  5014. case S.ATTRIB_VALUE_ENTITY_Q:
  5015. var returnState = S.ATTRIB_VALUE_QUOTED, buffer = "attribValue"
  5016. break
  5017. case S.ATTRIB_VALUE_ENTITY_U:
  5018. var returnState = S.ATTRIB_VALUE_UNQUOTED, buffer = "attribValue"
  5019. break
  5020. }
  5021. if (c === ";") {
  5022. parser[buffer] += parseEntity(parser)
  5023. parser.entity = ""
  5024. parser.state = returnState
  5025. }
  5026. else if (is(entity, c)) parser.entity += c
  5027. else {
  5028. strictFail(parser, "Invalid character entity")
  5029. parser[buffer] += "&" + parser.entity + c
  5030. parser.entity = ""
  5031. parser.state = returnState
  5032. }
  5033. continue
  5034. default:
  5035. throw new Error(parser, "Unknown state: " + parser.state)
  5036. }
  5037. } // while
  5038. // cdata blocks can get very big under normal conditions. emit and move on.
  5039. // if (parser.state === S.CDATA && parser.cdata) {
  5040. // emitNode(parser, "oncdata", parser.cdata)
  5041. // parser.cdata = ""
  5042. // }
  5043. if (parser.position >= parser.bufferCheckPosition) checkBufferLength(parser)
  5044. return parser
  5045. }
  5046. /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
  5047. if (!String.fromCodePoint) {
  5048. (function() {
  5049. var stringFromCharCode = String.fromCharCode;
  5050. var floor = Math.floor;
  5051. var fromCodePoint = function() {
  5052. var MAX_SIZE = 0x4000;
  5053. var codeUnits = [];
  5054. var highSurrogate;
  5055. var lowSurrogate;
  5056. var index = -1;
  5057. var length = arguments.length;
  5058. if (!length) {
  5059. return '';
  5060. }
  5061. var result = '';
  5062. while (++index < length) {
  5063. var codePoint = Number(arguments[index]);
  5064. if (
  5065. !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
  5066. codePoint < 0 || // not a valid Unicode code point
  5067. codePoint > 0x10FFFF || // not a valid Unicode code point
  5068. floor(codePoint) != codePoint // not an integer
  5069. ) {
  5070. throw RangeError('Invalid code point: ' + codePoint);
  5071. }
  5072. if (codePoint <= 0xFFFF) { // BMP code point
  5073. codeUnits.push(codePoint);
  5074. } else { // Astral code point; split in surrogate halves
  5075. // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  5076. codePoint -= 0x10000;
  5077. highSurrogate = (codePoint >> 10) + 0xD800;
  5078. lowSurrogate = (codePoint % 0x400) + 0xDC00;
  5079. codeUnits.push(highSurrogate, lowSurrogate);
  5080. }
  5081. if (index + 1 == length || codeUnits.length > MAX_SIZE) {
  5082. result += stringFromCharCode.apply(null, codeUnits);
  5083. codeUnits.length = 0;
  5084. }
  5085. }
  5086. return result;
  5087. };
  5088. if (Object.defineProperty) {
  5089. Object.defineProperty(String, 'fromCodePoint', {
  5090. 'value': fromCodePoint,
  5091. 'configurable': true,
  5092. 'writable': true
  5093. });
  5094. } else {
  5095. String.fromCodePoint = fromCodePoint;
  5096. }
  5097. }());
  5098. }
  5099. })(typeof exports === "undefined" ? sax = {} : exports);
  5100. }).call(this,undefined)
  5101. //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icG1uLW1vZGRsZS9ub2RlX21vZHVsZXMvbW9kZGxlLXhtbC9ub2RlX21vZHVsZXMvc2F4L2xpYi9zYXguanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtB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A6IFMrK1xuLCBURVhUICAgICAgICAgICAgICAgICAgICAgIDogUysrIC8vIGdlbmVyYWwgc3R1ZmZcbiwgVEVYVF9FTlRJVFkgICAgICAgICAgICAgICA6IFMrKyAvLyAmYW1wIGFuZCBzdWNoLlxuLCBPUEVOX1dBS0EgICAgICAgICAgICAgICAgIDogUysrIC8vIDxcbiwgU0dNTF9ERUNMICAgICAgICAgICAgICAgICA6IFMrKyAvLyA8IUJMQVJHXG4sIFNHTUxfREVDTF9RVU9URUQgICAgICAgICAgOiBTKysgLy8gPCFCTEFSRyBmb28gXCJiYXJcbiwgRE9DVFlQRSAgICAgICAgICAgICAgICAgICA6IFMrKyAvLyA8IURPQ1RZUEVcbiwgRE9DVFlQRV9RVU9URUQgICAgICAgICAgICA6IFMrKyAvLyA8IURPQ1RZUEUgXCIvL2JsYWhcbiwgRE9DVFlQRV9EVEQgICAgICAgICAgICAgICA6IFMrKyAvLyA8IURPQ1RZUEUgXCIvL2JsYWhcIiBbIC4uLlxuLCBET0NUWVBFX0RURF9RVU9URUQgICAgICAgIDogUysrIC8vIDwhRE9DVFlQRSBcIi8vYmxhaFwiIFsgXCJmb29cbiwgQ09NTUVOVF9TVEFSVElORyAgICAgICAgICA6IFMrKyAvLyA8IS1cbiwgQ09NTUVOVCAgICAgICAgICAgICAgICAgICA6IFMrKyAvLyA8IS0tXG4sIENPTU1FTlRfRU5ESU5HICAgICAgICAgICAgOiBTKysgLy8gPCEtLSBibGFoIC1cbiwgQ09NTUVOVF9FTkRFRCAgICAgICAgICAgICA6IFMrKyAvLyA8IS0tIGJsYWggLS1cbiwgQ0RBVEEgICAgICAgICAgICAgICAgICAgICA6IFMrKyAvLyA8IVtDREFUQVsgc29tZXRoaW5nXG4sIENEQVRBX0VORElORyAgICAgICAgICAgICAgOiBTKysgLy8gXVxuLCBDREFUQV9FTkRJTkdfMiAgICAgICAgICAgIDogUysrIC8vIF1dXG4sIFBST0NfSU5TVCAgICAgICAgICAgICAgICAgOiBTKysgL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T1cIiZcIikge1xuICAgICAgICAgICAgYyA9IGNodW5rLmNoYXJBdChpKyspXG4gICAgICAgICAgICBpZiAoYyAmJiBwYXJzZXIudHJhY2tQb3NpdGlvbikge1xuICAgICAgICAgICAgICBwYXJzZXIucG9zaXRpb24gKytcbiAgICAgICAgICAgICAgaWYgKGMgPT09IFwiXFxuXCIpIHtcbiAgICAgICAgICAgICAgICBwYXJzZXIubGluZSArK1xuICAgICAgICAgICAgICAgIHBhcnNlci5jb2x1bW4gPSAwXG4gICAgICAgICAgICAgIH0gZWxzZSBwYXJzZXIuY29sdW1uICsrXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIHBhcnNlci50ZXh0Tm9kZSArPSBjaHVuay5zdWJzdHJpbmcoc3RhcnRpLCBpLTEpXG4gICAgICAgIH1cbiAgICAgICAgaWYgKGMgPT09IFwiPFwiKSB7XG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5PUEVOX1dBS0FcbiAgICAgICAgICBwYXJzZXIuc3RhcnRUYWdQb3NpdGlvbiA9IHBhcnNlci5wb3NpdGlvblxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGlmIChub3Qod2hpdGVzcGFjZSwgYykgJiYgKCFwYXJzZXIuc2F3Um9vdCB8fCBwYXJzZXIuY2xvc2VkUm9vdCkpXG4gICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgXCJUZXh0IGRhdGEgb3V0c2lkZSBvZiByb290IG5vZGUuXCIpXG4gICAgICAgICAgaWYgKGMgPT09IFwiJlwiKSBwYXJzZXIuc3RhdGUgPSBTLlRFWFRfRU5USVRZXG4gICAgICAgICAgZWxzZSBwYXJzZXIudGV4dE5vZGUgKz0gY1xuICAgICAgICB9XG4gICAgICBjb250aW51ZVxuXG4gICAgICBjYXNlIFMuU0NSSVBUOlxuICAgICAgICAvLyBvbmx5IG5vbi1zdHJpY3RcbiAgICAgICAgaWYgKGMgPT09IFwiPFwiKSB7XG4gICAgICA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FREX1FVT1RFRFxuICAgICAgICAgIHBhcnNlci5xID0gY1xuICAgICAgICB9XG4gICAgICBjb250aW51ZVxuXG4gICAgICBjYXNlIFMuRE9DVFlQRV9EVERfUVVPVEVEOlxuICAgICAgICBwYXJzZXIuZG9jdHlwZSArPSBjXG4gICAgICAgIGlmIChjID09PSBwYXJzZXIucSkge1xuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRV9EVERcbiAgICAgICAgICBwYXJzZXIucSA9IFwiXCJcbiAgICAgICAgfVxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLkNPTU1FTlQ6XG4gICAgICAgIGlmIChjID09PSBcIi1cIikgcGFyc2VyLnN0YXRlID0gUy5DT01NRU5UX0VORElOR1xuICAgICAgICBlbHNlIHBhcnNlci5jb21tZW50ICs9IGNcbiAgICAgIGNvbnRpbnVlXG5cbiAgICAgIGNhc2UgUy5DT01NRU5UX0VORElORzpcbiAgICAgICAgaWYgKGMgPT09IFwiLVwiKSB7XG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DT01NRU5UX0VOREVEXG4gICAgICAgICAgcGFyc2VyLmNvbW1lbnQgPSB0ZXh0b3B0cyhwYXJzZXIub3B0LCBwYXJzZXIuY29tbWVudClcbiAgICAgICAgICBpZiAocGFyc2VyLmNvbW1lbnQpIGVtaXROb2RlKHBhcnNlciwgXCJvbmNvbW1lbnRcIiwgcGFyc2VyLmNvbW1lbnQpXG4gICAgICAgICAgcGFyc2VyLmNvbW1lbnQgPSBcIlwiXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgcGFyc2VyLmNvbW1lbnQgKz0gXCItXCIgKyBjXG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DT01NRU5UXG4gICAgICAgIH1cbiAgICAgIGNvbnRpbnVlXG5cbiAgICAgIGNhc2UgUy5DT01NRU5UX0VOREVEOlxuICAgICAgICBpZiAoYyAhPT0gXCI+XCIpIHtcbiAgICAgICAgICB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ICAgICAgICAgfSlcbiAgICAgICAgICBwYXJzZXIucHJvY0luc3ROYW1lID0gcGFyc2VyLnByb2NJbnN0Qm9keSA9IFwiXCJcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlRFWFRcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBwYXJzZXIucHJvY0luc3RCb2R5ICs9IFwiP1wiICsgY1xuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuUFJPQ19JTlNUX0JPRFlcbiAgICAgICAgfVxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLk9QRU5fVEFHOlxuICAgICAgICBpZiAoaXMobmFtZUJvZHksIGMpKSBwYXJzZXIudGFnTmFtZSArPSBjXG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgIG5ld1RhZyhwYXJzZXIpXG4gICAgICAgICAgaWYgKGMgPT09IFwiPlwiKSBvcGVuVGFnKHBhcnNlcilcbiAgICAgICAgICBlbHNlIGlmIChjID09PSBcIi9cIikgcGFyc2VyLnN0YXRlID0gUy5PUEVOX1RBR19TTEFTSFxuICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgaWYgKG5vdCh3aGl0ZXNwYWNlLCBjKSkgc3RyaWN0RmFpbChcbiAgICAgICAgICAgICAgcGFyc2VyLCBcIkludmFsaWQgY2hhcmFjdGVyIGluIHRhZyBuYW1lXCIpXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQlxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLk9QRU5fVEFHX1NMQVNIOlxuICAgICAgICBpZiAoYyA9PT0gXCI+XCIpIHtcbiAgICAgICAgICBvcGVuVGFnKHBhcnNlciwgdHJ1ZSlcbiAgICAgICAgICBjbG9zZVRhZyhwYXJzZXIpXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsIFwiRm9yd2FyZC1zbGF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iAgcmV0dXJuIHBhcnNlclxufVxuXG4vKiEgaHR0cDovL210aHMuYmUvZnJvbWNvZGVwb2ludCB2MC4xLjAgYnkgQG1hdGhpYXMgKi9cbmlmICghU3RyaW5nLmZyb21Db2RlUG9pbnQpIHtcbiAgICAgICAgKGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIHZhciBzdHJpbmdGcm9tQ2hhckNvZGUgPSBTdHJpbmcuZnJvbUNoYXJDb2RlO1xuICAgICAgICAgICAgICAgIHZhciBmbG9vciA9IE1hdGguZmxvb3I7XG4gICAgICAgICAgICAgICAgdmFyIGZyb21Db2RlUG9pbnQgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBNQVhfU0laRSA9IDB4NDAwMDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBjb2RlVW5pdHMgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBoaWdoU3Vycm9nYXRlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGxvd1N1cnJvZ2F0ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbmRleCA9IC0xO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGxlbmd0aCA9IGFyZ3VtZW50cy5sZW5ndGg7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJyc7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gJyc7XG4gICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoKytpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgY29kZVBvaW50ID0gTnVtYmVyKGFyZ3VtZW50c1tpbmRleF0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIWlzRmluaXRlKGNvZGVQb2ludCkgfHwgLy8gYE5hTmAsIGArSW5maW5pdHlgLCBvciBgLUluZmluaXR5YFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvZGVQb2ludCA8IDAgfHwgLy8gbm90IGEgdmFsaWQgVW5pY29kZSBjb2RlIHBvaW50XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29kZVBvaW50ID4gMHgxMEZGRkYgfHwgLy8gbm90IGEgdmFsaWQgVW5pY29kZSBjb2RlIHBvaW50XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmxvb3IoY29kZVBvaW50KSAhPSBjb2RlUG9pbnQgLy8gbm90IGFuIGludGVnZXJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgUmFuZ2VFcnJvcignSW52YWxpZCBjb2RlIHBvaW50OiAnICsgY29kZVBvaW50KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29kZVBvaW50IDw9IDB4RkZGRikgeyAvLyBCTVAgY29kZSBwb2ludFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvZGVVbml0cy5wdXNoKGNvZGVQb2ludCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7IC8vIEFzdHJhbCBjb2RlIHBvaW50OyBzcGxpdCBpbiBzdXJyb2dhdGUgaGFsdmVzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaHR0cDovL21hdGhpYXNieW5lbnMuYmUvbm90ZXMvamF2YXNjcmlwdC1lbmNvZGluZyNzdXJyb2dhdGUtZm9ybXVsYWVcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2RlUG9pbnQgLT0gMHgxMDAwMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWdoU3Vycm9nYXRlID0gKGNvZGVQb2ludCA+PiAxMCkgKyAweEQ4MDA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG93U3Vycm9nYXRlID0gKGNvZGVQb2ludCAlIDB4NDAwKSArIDB4REMwMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2RlVW5pdHMucHVzaChoaWdoU3Vycm9nYXRlLCBsb3dTdXJyb2dhdGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCArIDEgPT0gbGVuZ3RoIHx8IGNvZGVVbml0cy5sZW5ndGggPiBNQVhfU0laRSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSBzdHJpbmdGcm9tQ2hhckNvZGUuYXBwbHkobnVsbCwgY29kZVVuaXRzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2RlVW5pdHMubGVuZ3RoID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIGlmIChPYmplY3QuZGVmaW5lUHJvcGVydHkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShTdHJpbmcsICdmcm9tQ29kZVBvaW50Jywge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAndmFsdWUnOiBmcm9tQ29kZVBvaW50LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAnY29uZmlndXJhYmxlJzogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJ3dyaXRhYmxlJzogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZy5mcm9tQ29kZVBvaW50ID0gZnJvbUNvZGVQb2ludDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgIH0oKSk7XG59XG5cbn0pKHR5cGVvZiBleHBvcnRzID09PSBcInVuZGVmaW5lZFwiID8gc2F4ID0ge30gOiBleHBvcnRzKTtcbiJdfQ==
  5102. },{"undefined":undefined}],21:[function(_dereq_,module,exports){
  5103. /**
  5104. * Tiny stack for browser or server
  5105. *
  5106. * @author Jason Mulligan <jason.mulligan@avoidwork.com>
  5107. * @copyright 2014 Jason Mulligan
  5108. * @license BSD-3 <https://raw.github.com/avoidwork/tiny-stack/master/LICENSE>
  5109. * @link http://avoidwork.github.io/tiny-stack
  5110. * @module tiny-stack
  5111. * @version 0.1.0
  5112. */
  5113. ( function ( global ) {
  5114. "use strict";
  5115. /**
  5116. * TinyStack
  5117. *
  5118. * @constructor
  5119. */
  5120. function TinyStack () {
  5121. this.data = [null];
  5122. this.top = 0;
  5123. }
  5124. /**
  5125. * Clears the stack
  5126. *
  5127. * @method clear
  5128. * @memberOf TinyStack
  5129. * @return {Object} {@link TinyStack}
  5130. */
  5131. TinyStack.prototype.clear = function clear () {
  5132. this.data = [null];
  5133. this.top = 0;
  5134. return this;
  5135. };
  5136. /**
  5137. * Gets the size of the stack
  5138. *
  5139. * @method length
  5140. * @memberOf TinyStack
  5141. * @return {Number} Size of stack
  5142. */
  5143. TinyStack.prototype.length = function length () {
  5144. return this.top;
  5145. };
  5146. /**
  5147. * Gets the item at the top of the stack
  5148. *
  5149. * @method peek
  5150. * @memberOf TinyStack
  5151. * @return {Mixed} Item at the top of the stack
  5152. */
  5153. TinyStack.prototype.peek = function peek () {
  5154. return this.data[this.top];
  5155. };
  5156. /**
  5157. * Gets & removes the item at the top of the stack
  5158. *
  5159. * @method pop
  5160. * @memberOf TinyStack
  5161. * @return {Mixed} Item at the top of the stack
  5162. */
  5163. TinyStack.prototype.pop = function pop () {
  5164. if ( this.top > 0 ) {
  5165. this.top--;
  5166. return this.data.pop();
  5167. }
  5168. else {
  5169. return undefined;
  5170. }
  5171. };
  5172. /**
  5173. * Pushes an item onto the stack
  5174. *
  5175. * @method push
  5176. * @memberOf TinyStack
  5177. * @return {Object} {@link TinyStack}
  5178. */
  5179. TinyStack.prototype.push = function push ( arg ) {
  5180. this.data[++this.top] = arg;
  5181. return this;
  5182. };
  5183. /**
  5184. * TinyStack factory
  5185. *
  5186. * @method factory
  5187. * @return {Object} {@link TinyStack}
  5188. */
  5189. function factory () {
  5190. return new TinyStack();
  5191. }
  5192. // Node, AMD & window supported
  5193. if ( typeof exports != "undefined" ) {
  5194. module.exports = factory;
  5195. }
  5196. else if ( typeof define == "function" ) {
  5197. define( function () {
  5198. return factory;
  5199. } );
  5200. }
  5201. else {
  5202. global.stack = factory;
  5203. }
  5204. } )( this );
  5205. },{}],22:[function(_dereq_,module,exports){
  5206. module.exports = _dereq_(26);
  5207. },{"26":26}],23:[function(_dereq_,module,exports){
  5208. 'use strict';
  5209. function Base() { }
  5210. Base.prototype.get = function(name) {
  5211. return this.$model.properties.get(this, name);
  5212. };
  5213. Base.prototype.set = function(name, value) {
  5214. this.$model.properties.set(this, name, value);
  5215. };
  5216. module.exports = Base;
  5217. },{}],24:[function(_dereq_,module,exports){
  5218. 'use strict';
  5219. var pick = _dereq_(174),
  5220. assign = _dereq_(168),
  5221. forEach = _dereq_(77);
  5222. var parseNameNs = _dereq_(27).parseName;
  5223. function DescriptorBuilder(nameNs) {
  5224. this.ns = nameNs;
  5225. this.name = nameNs.name;
  5226. this.allTypes = [];
  5227. this.properties = [];
  5228. this.propertiesByName = {};
  5229. }
  5230. module.exports = DescriptorBuilder;
  5231. DescriptorBuilder.prototype.build = function() {
  5232. return pick(this, [ 'ns', 'name', 'allTypes', 'properties', 'propertiesByName', 'bodyProperty' ]);
  5233. };
  5234. DescriptorBuilder.prototype.addProperty = function(p, idx) {
  5235. this.addNamedProperty(p, true);
  5236. var properties = this.properties;
  5237. if (idx !== undefined) {
  5238. properties.splice(idx, 0, p);
  5239. } else {
  5240. properties.push(p);
  5241. }
  5242. };
  5243. DescriptorBuilder.prototype.replaceProperty = function(oldProperty, newProperty) {
  5244. var oldNameNs = oldProperty.ns;
  5245. var props = this.properties,
  5246. propertiesByName = this.propertiesByName,
  5247. rename = oldProperty.name !== newProperty.name;
  5248. if (oldProperty.isBody) {
  5249. if (!newProperty.isBody) {
  5250. throw new Error(
  5251. 'property <' + newProperty.ns.name + '> must be body property ' +
  5252. 'to refine <' + oldProperty.ns.name + '>');
  5253. }
  5254. // TODO: Check compatibility
  5255. this.setBodyProperty(newProperty, false);
  5256. }
  5257. // replacing the named property is intentional
  5258. // thus, validate only if this is a "rename" operation
  5259. this.addNamedProperty(newProperty, rename);
  5260. // replace old property at index with new one
  5261. var idx = props.indexOf(oldProperty);
  5262. if (idx === -1) {
  5263. throw new Error('property <' + oldNameNs.name + '> not found in property list');
  5264. }
  5265. props[idx] = newProperty;
  5266. // replace propertiesByName entry with new property
  5267. propertiesByName[oldNameNs.name] = propertiesByName[oldNameNs.localName] = newProperty;
  5268. };
  5269. DescriptorBuilder.prototype.redefineProperty = function(p) {
  5270. var nsPrefix = p.ns.prefix;
  5271. var parts = p.redefines.split('#');
  5272. var name = parseNameNs(parts[0], nsPrefix);
  5273. var attrName = parseNameNs(parts[1], name.prefix).name;
  5274. var redefinedProperty = this.propertiesByName[attrName];
  5275. if (!redefinedProperty) {
  5276. throw new Error('refined property <' + attrName + '> not found');
  5277. } else {
  5278. this.replaceProperty(redefinedProperty, p);
  5279. }
  5280. delete p.redefines;
  5281. };
  5282. DescriptorBuilder.prototype.addNamedProperty = function(p, validate) {
  5283. var ns = p.ns,
  5284. propsByName = this.propertiesByName;
  5285. if (validate) {
  5286. this.assertNotDefined(p, ns.name);
  5287. this.assertNotDefined(p, ns.localName);
  5288. }
  5289. propsByName[ns.name] = propsByName[ns.localName] = p;
  5290. };
  5291. DescriptorBuilder.prototype.removeNamedProperty = function(p) {
  5292. var ns = p.ns,
  5293. propsByName = this.propertiesByName;
  5294. delete propsByName[ns.name];
  5295. delete propsByName[ns.localName];
  5296. };
  5297. DescriptorBuilder.prototype.setBodyProperty = function(p, validate) {
  5298. if (validate && this.bodyProperty) {
  5299. throw new Error(
  5300. 'body property defined multiple times ' +
  5301. '(<' + this.bodyProperty.ns.name + '>, <' + p.ns.name + '>)');
  5302. }
  5303. this.bodyProperty = p;
  5304. };
  5305. DescriptorBuilder.prototype.addIdProperty = function(name) {
  5306. var nameNs = parseNameNs(name, this.ns.prefix);
  5307. var p = {
  5308. name: nameNs.localName,
  5309. type: 'String',
  5310. isAttr: true,
  5311. ns: nameNs
  5312. };
  5313. // ensure that id is always the first attribute (if present)
  5314. this.addProperty(p, 0);
  5315. };
  5316. DescriptorBuilder.prototype.assertNotDefined = function(p, name) {
  5317. var propertyName = p.name,
  5318. definedProperty = this.propertiesByName[propertyName];
  5319. if (definedProperty) {
  5320. throw new Error(
  5321. 'property <' + propertyName + '> already defined; ' +
  5322. 'override of <' + definedProperty.definedBy.ns.name + '#' + definedProperty.ns.name + '> by ' +
  5323. '<' + p.definedBy.ns.name + '#' + p.ns.name + '> not allowed without redefines');
  5324. }
  5325. };
  5326. DescriptorBuilder.prototype.hasProperty = function(name) {
  5327. return this.propertiesByName[name];
  5328. };
  5329. DescriptorBuilder.prototype.addTrait = function(t) {
  5330. var allTypes = this.allTypes;
  5331. if (allTypes.indexOf(t) !== -1) {
  5332. return;
  5333. }
  5334. forEach(t.properties, function(p) {
  5335. // clone property to allow extensions
  5336. p = assign({}, p, {
  5337. name: p.ns.localName
  5338. });
  5339. Object.defineProperty(p, 'definedBy', {
  5340. value: t
  5341. });
  5342. // add redefine support
  5343. if (p.redefines) {
  5344. this.redefineProperty(p);
  5345. } else {
  5346. if (p.isBody) {
  5347. this.setBodyProperty(p);
  5348. }
  5349. this.addProperty(p);
  5350. }
  5351. }, this);
  5352. allTypes.push(t);
  5353. };
  5354. },{"168":168,"174":174,"27":27,"77":77}],25:[function(_dereq_,module,exports){
  5355. 'use strict';
  5356. var forEach = _dereq_(77);
  5357. var Base = _dereq_(23);
  5358. function Factory(model, properties) {
  5359. this.model = model;
  5360. this.properties = properties;
  5361. }
  5362. module.exports = Factory;
  5363. Factory.prototype.createType = function(descriptor) {
  5364. var model = this.model;
  5365. var props = this.properties,
  5366. prototype = Object.create(Base.prototype);
  5367. // initialize default values
  5368. forEach(descriptor.properties, function(p) {
  5369. if (!p.isMany && p.default !== undefined) {
  5370. prototype[p.name] = p.default;
  5371. }
  5372. });
  5373. props.defineModel(prototype, model);
  5374. props.defineDescriptor(prototype, descriptor);
  5375. var name = descriptor.ns.name;
  5376. /**
  5377. * The new type constructor
  5378. */
  5379. function ModdleElement(attrs) {
  5380. props.define(this, '$type', { value: name, enumerable: true });
  5381. props.define(this, '$attrs', { value: {} });
  5382. props.define(this, '$parent', { writable: true });
  5383. forEach(attrs, function(val, key) {
  5384. this.set(key, val);
  5385. }, this);
  5386. }
  5387. ModdleElement.prototype = prototype;
  5388. ModdleElement.hasType = prototype.$instanceOf = this.model.hasType;
  5389. // static links
  5390. props.defineModel(ModdleElement, model);
  5391. props.defineDescriptor(ModdleElement, descriptor);
  5392. return ModdleElement;
  5393. };
  5394. },{"23":23,"77":77}],26:[function(_dereq_,module,exports){
  5395. 'use strict';
  5396. var isString = _dereq_(165),
  5397. isObject = _dereq_(163),
  5398. forEach = _dereq_(77),
  5399. find = _dereq_(76);
  5400. var Factory = _dereq_(25),
  5401. Registry = _dereq_(29),
  5402. Properties = _dereq_(28);
  5403. var parseNameNs = _dereq_(27).parseName;
  5404. //// Moddle implementation /////////////////////////////////////////////////
  5405. /**
  5406. * @class Moddle
  5407. *
  5408. * A model that can be used to create elements of a specific type.
  5409. *
  5410. * @example
  5411. *
  5412. * var Moddle = require('moddle');
  5413. *
  5414. * var pkg = {
  5415. * name: 'mypackage',
  5416. * prefix: 'my',
  5417. * types: [
  5418. * { name: 'Root' }
  5419. * ]
  5420. * };
  5421. *
  5422. * var moddle = new Moddle([pkg]);
  5423. *
  5424. * @param {Array<Package>} packages the packages to contain
  5425. * @param {Object} options additional options to pass to the model
  5426. */
  5427. function Moddle(packages, options) {
  5428. options = options || {};
  5429. this.properties = new Properties(this);
  5430. this.factory = new Factory(this, this.properties);
  5431. this.registry = new Registry(packages, this.properties, options);
  5432. this.typeCache = {};
  5433. }
  5434. module.exports = Moddle;
  5435. /**
  5436. * Create an instance of the specified type.
  5437. *
  5438. * @method Moddle#create
  5439. *
  5440. * @example
  5441. *
  5442. * var foo = moddle.create('my:Foo');
  5443. * var bar = moddle.create('my:Bar', { id: 'BAR_1' });
  5444. *
  5445. * @param {String|Object} descriptor the type descriptor or name know to the model
  5446. * @param {Object} attrs a number of attributes to initialize the model instance with
  5447. * @return {Object} model instance
  5448. */
  5449. Moddle.prototype.create = function(descriptor, attrs) {
  5450. var Type = this.getType(descriptor);
  5451. if (!Type) {
  5452. throw new Error('unknown type <' + descriptor + '>');
  5453. }
  5454. return new Type(attrs);
  5455. };
  5456. /**
  5457. * Returns the type representing a given descriptor
  5458. *
  5459. * @method Moddle#getType
  5460. *
  5461. * @example
  5462. *
  5463. * var Foo = moddle.getType('my:Foo');
  5464. * var foo = new Foo({ 'id' : 'FOO_1' });
  5465. *
  5466. * @param {String|Object} descriptor the type descriptor or name know to the model
  5467. * @return {Object} the type representing the descriptor
  5468. */
  5469. Moddle.prototype.getType = function(descriptor) {
  5470. var cache = this.typeCache;
  5471. var name = isString(descriptor) ? descriptor : descriptor.ns.name;
  5472. var type = cache[name];
  5473. if (!type) {
  5474. descriptor = this.registry.getEffectiveDescriptor(name);
  5475. type = cache[name] = this.factory.createType(descriptor);
  5476. }
  5477. return type;
  5478. };
  5479. /**
  5480. * Creates an any-element type to be used within model instances.
  5481. *
  5482. * This can be used to create custom elements that lie outside the meta-model.
  5483. * The created element contains all the meta-data required to serialize it
  5484. * as part of meta-model elements.
  5485. *
  5486. * @method Moddle#createAny
  5487. *
  5488. * @example
  5489. *
  5490. * var foo = moddle.createAny('vendor:Foo', 'http://vendor', {
  5491. * value: 'bar'
  5492. * });
  5493. *
  5494. * var container = moddle.create('my:Container', 'http://my', {
  5495. * any: [ foo ]
  5496. * });
  5497. *
  5498. * // go ahead and serialize the stuff
  5499. *
  5500. *
  5501. * @param {String} name the name of the element
  5502. * @param {String} nsUri the namespace uri of the element
  5503. * @param {Object} [properties] a map of properties to initialize the instance with
  5504. * @return {Object} the any type instance
  5505. */
  5506. Moddle.prototype.createAny = function(name, nsUri, properties) {
  5507. var nameNs = parseNameNs(name);
  5508. var element = {
  5509. $type: name
  5510. };
  5511. var descriptor = {
  5512. name: name,
  5513. isGeneric: true,
  5514. ns: {
  5515. prefix: nameNs.prefix,
  5516. localName: nameNs.localName,
  5517. uri: nsUri
  5518. }
  5519. };
  5520. this.properties.defineDescriptor(element, descriptor);
  5521. this.properties.defineModel(element, this);
  5522. this.properties.define(element, '$parent', { enumerable: false, writable: true });
  5523. forEach(properties, function(a, key) {
  5524. if (isObject(a) && a.value !== undefined) {
  5525. element[a.name] = a.value;
  5526. } else {
  5527. element[key] = a;
  5528. }
  5529. });
  5530. return element;
  5531. };
  5532. /**
  5533. * Returns a registered package by uri or prefix
  5534. *
  5535. * @return {Object} the package
  5536. */
  5537. Moddle.prototype.getPackage = function(uriOrPrefix) {
  5538. return this.registry.getPackage(uriOrPrefix);
  5539. };
  5540. /**
  5541. * Returns a snapshot of all known packages
  5542. *
  5543. * @return {Object} the package
  5544. */
  5545. Moddle.prototype.getPackages = function() {
  5546. return this.registry.getPackages();
  5547. };
  5548. /**
  5549. * Returns the descriptor for an element
  5550. */
  5551. Moddle.prototype.getElementDescriptor = function(element) {
  5552. return element.$descriptor;
  5553. };
  5554. /**
  5555. * Returns true if the given descriptor or instance
  5556. * represents the given type.
  5557. *
  5558. * May be applied to this, if element is omitted.
  5559. */
  5560. Moddle.prototype.hasType = function(element, type) {
  5561. if (type === undefined) {
  5562. type = element;
  5563. element = this;
  5564. }
  5565. var descriptor = element.$model.getElementDescriptor(element);
  5566. return !!find(descriptor.allTypes, function(t) {
  5567. return t.name === type;
  5568. });
  5569. };
  5570. /**
  5571. * Returns the descriptor of an elements named property
  5572. */
  5573. Moddle.prototype.getPropertyDescriptor = function(element, property) {
  5574. return this.getElementDescriptor(element).propertiesByName[property];
  5575. };
  5576. },{"163":163,"165":165,"25":25,"27":27,"28":28,"29":29,"76":76,"77":77}],27:[function(_dereq_,module,exports){
  5577. 'use strict';
  5578. /**
  5579. * Parses a namespaced attribute name of the form (ns:)localName to an object,
  5580. * given a default prefix to assume in case no explicit namespace is given.
  5581. *
  5582. * @param {String} name
  5583. * @param {String} [defaultPrefix] the default prefix to take, if none is present.
  5584. *
  5585. * @return {Object} the parsed name
  5586. */
  5587. module.exports.parseName = function(name, defaultPrefix) {
  5588. var parts = name.split(/:/),
  5589. localName, prefix;
  5590. // no prefix (i.e. only local name)
  5591. if (parts.length === 1) {
  5592. localName = name;
  5593. prefix = defaultPrefix;
  5594. } else
  5595. // prefix + local name
  5596. if (parts.length === 2) {
  5597. localName = parts[1];
  5598. prefix = parts[0];
  5599. } else {
  5600. throw new Error('expected <prefix:localName> or <localName>, got ' + name);
  5601. }
  5602. name = (prefix ? prefix + ':' : '') + localName;
  5603. return {
  5604. name: name,
  5605. prefix: prefix,
  5606. localName: localName
  5607. };
  5608. };
  5609. },{}],28:[function(_dereq_,module,exports){
  5610. 'use strict';
  5611. /**
  5612. * A utility that gets and sets properties of model elements.
  5613. *
  5614. * @param {Model} model
  5615. */
  5616. function Properties(model) {
  5617. this.model = model;
  5618. }
  5619. module.exports = Properties;
  5620. /**
  5621. * Sets a named property on the target element
  5622. *
  5623. * @param {Object} target
  5624. * @param {String} name
  5625. * @param {Object} value
  5626. */
  5627. Properties.prototype.set = function(target, name, value) {
  5628. var property = this.model.getPropertyDescriptor(target, name);
  5629. if (!property) {
  5630. target.$attrs[name] = value;
  5631. } else {
  5632. Object.defineProperty(target, property.name, {
  5633. enumerable: !property.isReference,
  5634. writable: true,
  5635. value: value
  5636. });
  5637. }
  5638. };
  5639. /**
  5640. * Returns the named property of the given element
  5641. *
  5642. * @param {Object} target
  5643. * @param {String} name
  5644. *
  5645. * @return {Object}
  5646. */
  5647. Properties.prototype.get = function(target, name) {
  5648. var property = this.model.getPropertyDescriptor(target, name);
  5649. if (!property) {
  5650. return target.$attrs[name];
  5651. }
  5652. var propertyName = property.name;
  5653. // check if access to collection property and lazily initialize it
  5654. if (!target[propertyName] && property.isMany) {
  5655. Object.defineProperty(target, propertyName, {
  5656. enumerable: !property.isReference,
  5657. writable: true,
  5658. value: []
  5659. });
  5660. }
  5661. return target[propertyName];
  5662. };
  5663. /**
  5664. * Define a property on the target element
  5665. *
  5666. * @param {Object} target
  5667. * @param {String} name
  5668. * @param {Object} options
  5669. */
  5670. Properties.prototype.define = function(target, name, options) {
  5671. Object.defineProperty(target, name, options);
  5672. };
  5673. /**
  5674. * Define the descriptor for an element
  5675. */
  5676. Properties.prototype.defineDescriptor = function(target, descriptor) {
  5677. this.define(target, '$descriptor', { value: descriptor });
  5678. };
  5679. /**
  5680. * Define the model for an element
  5681. */
  5682. Properties.prototype.defineModel = function(target, model) {
  5683. this.define(target, '$model', { value: model });
  5684. };
  5685. },{}],29:[function(_dereq_,module,exports){
  5686. 'use strict';
  5687. var assign = _dereq_(168),
  5688. forEach = _dereq_(77);
  5689. var Types = _dereq_(30),
  5690. DescriptorBuilder = _dereq_(24);
  5691. var parseNameNs = _dereq_(27).parseName,
  5692. isBuiltInType = Types.isBuiltIn;
  5693. function Registry(packages, properties, options) {
  5694. this.options = assign({ generateId: 'id' }, options || {});
  5695. this.packageMap = {};
  5696. this.typeMap = {};
  5697. this.packages = [];
  5698. this.properties = properties;
  5699. forEach(packages, this.registerPackage, this);
  5700. }
  5701. module.exports = Registry;
  5702. Registry.prototype.getPackage = function(uriOrPrefix) {
  5703. return this.packageMap[uriOrPrefix];
  5704. };
  5705. Registry.prototype.getPackages = function() {
  5706. return this.packages;
  5707. };
  5708. Registry.prototype.registerPackage = function(pkg) {
  5709. // copy package
  5710. pkg = assign({}, pkg);
  5711. // register types
  5712. forEach(pkg.types, function(descriptor) {
  5713. this.registerType(descriptor, pkg);
  5714. }, this);
  5715. this.packageMap[pkg.uri] = this.packageMap[pkg.prefix] = pkg;
  5716. this.packages.push(pkg);
  5717. };
  5718. /**
  5719. * Register a type from a specific package with us
  5720. */
  5721. Registry.prototype.registerType = function(type, pkg) {
  5722. type = assign({}, type, {
  5723. superClass: (type.superClass || []).slice(),
  5724. extends: (type.extends || []).slice(),
  5725. properties: (type.properties || []).slice()
  5726. });
  5727. var ns = parseNameNs(type.name, pkg.prefix),
  5728. name = ns.name,
  5729. propertiesByName = {};
  5730. // parse properties
  5731. forEach(type.properties, function(p) {
  5732. // namespace property names
  5733. var propertyNs = parseNameNs(p.name, ns.prefix),
  5734. propertyName = propertyNs.name;
  5735. // namespace property types
  5736. if (!isBuiltInType(p.type)) {
  5737. p.type = parseNameNs(p.type, propertyNs.prefix).name;
  5738. }
  5739. assign(p, {
  5740. ns: propertyNs,
  5741. name: propertyName
  5742. });
  5743. propertiesByName[propertyName] = p;
  5744. });
  5745. // update ns + name
  5746. assign(type, {
  5747. ns: ns,
  5748. name: name,
  5749. propertiesByName: propertiesByName
  5750. });
  5751. forEach(type.extends, function(extendsName) {
  5752. var extended = this.typeMap[extendsName];
  5753. extended.traits = extended.traits || [];
  5754. extended.traits.push(name);
  5755. }, this);
  5756. // link to package
  5757. this.definePackage(type, pkg);
  5758. // register
  5759. this.typeMap[name] = type;
  5760. };
  5761. /**
  5762. * Traverse the type hierarchy from bottom to top.
  5763. */
  5764. Registry.prototype.mapTypes = function(nsName, iterator) {
  5765. var type = isBuiltInType(nsName.name) ? { name: nsName.name } : this.typeMap[nsName.name];
  5766. var self = this;
  5767. /**
  5768. * Traverse the selected super type or trait
  5769. *
  5770. * @param {String} cls
  5771. */
  5772. function traverseSuper(cls) {
  5773. var parentNs = parseNameNs(cls, isBuiltInType(cls) ? '' : nsName.prefix);
  5774. self.mapTypes(parentNs, iterator);
  5775. }
  5776. if (!type) {
  5777. throw new Error('unknown type <' + nsName.name + '>');
  5778. }
  5779. forEach(type.superClass, traverseSuper);
  5780. iterator(type);
  5781. forEach(type.traits, traverseSuper);
  5782. };
  5783. /**
  5784. * Returns the effective descriptor for a type.
  5785. *
  5786. * @param {String} type the namespaced name (ns:localName) of the type
  5787. *
  5788. * @return {Descriptor} the resulting effective descriptor
  5789. */
  5790. Registry.prototype.getEffectiveDescriptor = function(name) {
  5791. var nsName = parseNameNs(name);
  5792. var builder = new DescriptorBuilder(nsName);
  5793. this.mapTypes(nsName, function(type) {
  5794. builder.addTrait(type);
  5795. });
  5796. // check we have an id assigned
  5797. var id = this.options.generateId;
  5798. if (id && !builder.hasProperty(id)) {
  5799. builder.addIdProperty(id);
  5800. }
  5801. var descriptor = builder.build();
  5802. // define package link
  5803. this.definePackage(descriptor, descriptor.allTypes[descriptor.allTypes.length - 1].$pkg);
  5804. return descriptor;
  5805. };
  5806. Registry.prototype.definePackage = function(target, pkg) {
  5807. this.properties.define(target, '$pkg', { value: pkg });
  5808. };
  5809. },{"168":168,"24":24,"27":27,"30":30,"77":77}],30:[function(_dereq_,module,exports){
  5810. 'use strict';
  5811. /**
  5812. * Built-in moddle types
  5813. */
  5814. var BUILTINS = {
  5815. String: true,
  5816. Boolean: true,
  5817. Integer: true,
  5818. Real: true,
  5819. Element: true
  5820. };
  5821. /**
  5822. * Converters for built in types from string representations
  5823. */
  5824. var TYPE_CONVERTERS = {
  5825. String: function(s) { return s; },
  5826. Boolean: function(s) { return s === 'true'; },
  5827. Integer: function(s) { return parseInt(s, 10); },
  5828. Real: function(s) { return parseFloat(s, 10); }
  5829. };
  5830. /**
  5831. * Convert a type to its real representation
  5832. */
  5833. module.exports.coerceType = function(type, value) {
  5834. var converter = TYPE_CONVERTERS[type];
  5835. if (converter) {
  5836. return converter(value);
  5837. } else {
  5838. return value;
  5839. }
  5840. };
  5841. /**
  5842. * Return whether the given type is built-in
  5843. */
  5844. module.exports.isBuiltIn = function(type) {
  5845. return !!BUILTINS[type];
  5846. };
  5847. /**
  5848. * Return whether the given type is simple
  5849. */
  5850. module.exports.isSimple = function(type) {
  5851. return !!TYPE_CONVERTERS[type];
  5852. };
  5853. },{}],31:[function(_dereq_,module,exports){
  5854. module.exports={
  5855. "name": "BPMN20",
  5856. "uri": "http://www.omg.org/spec/BPMN/20100524/MODEL",
  5857. "associations": [],
  5858. "types": [
  5859. {
  5860. "name": "Interface",
  5861. "superClass": [
  5862. "RootElement"
  5863. ],
  5864. "properties": [
  5865. {
  5866. "name": "name",
  5867. "isAttr": true,
  5868. "type": "String"
  5869. },
  5870. {
  5871. "name": "operations",
  5872. "type": "Operation",
  5873. "isMany": true
  5874. },
  5875. {
  5876. "name": "implementationRef",
  5877. "type": "String",
  5878. "isAttr": true
  5879. }
  5880. ]
  5881. },
  5882. {
  5883. "name": "Operation",
  5884. "superClass": [
  5885. "BaseElement"
  5886. ],
  5887. "properties": [
  5888. {
  5889. "name": "name",
  5890. "isAttr": true,
  5891. "type": "String"
  5892. },
  5893. {
  5894. "name": "inMessageRef",
  5895. "type": "Message",
  5896. "isAttr": true,
  5897. "isReference": true
  5898. },
  5899. {
  5900. "name": "outMessageRef",
  5901. "type": "Message",
  5902. "isAttr": true,
  5903. "isReference": true
  5904. },
  5905. {
  5906. "name": "errorRefs",
  5907. "type": "Error",
  5908. "isMany": true,
  5909. "isReference": true
  5910. },
  5911. {
  5912. "name": "implementationRef",
  5913. "type": "String",
  5914. "isAttr": true
  5915. }
  5916. ]
  5917. },
  5918. {
  5919. "name": "EndPoint",
  5920. "superClass": [
  5921. "RootElement"
  5922. ]
  5923. },
  5924. {
  5925. "name": "Auditing",
  5926. "superClass": [
  5927. "BaseElement"
  5928. ]
  5929. },
  5930. {
  5931. "name": "GlobalTask",
  5932. "superClass": [
  5933. "CallableElement"
  5934. ],
  5935. "properties": [
  5936. {
  5937. "name": "resources",
  5938. "type": "ResourceRole",
  5939. "isMany": true
  5940. }
  5941. ]
  5942. },
  5943. {
  5944. "name": "Monitoring",
  5945. "superClass": [
  5946. "BaseElement"
  5947. ]
  5948. },
  5949. {
  5950. "name": "Performer",
  5951. "superClass": [
  5952. "ResourceRole"
  5953. ]
  5954. },
  5955. {
  5956. "name": "Process",
  5957. "superClass": [
  5958. "FlowElementsContainer",
  5959. "CallableElement"
  5960. ],
  5961. "properties": [
  5962. {
  5963. "name": "processType",
  5964. "type": "ProcessType",
  5965. "isAttr": true
  5966. },
  5967. {
  5968. "name": "isClosed",
  5969. "isAttr": true,
  5970. "type": "Boolean"
  5971. },
  5972. {
  5973. "name": "auditing",
  5974. "type": "Auditing"
  5975. },
  5976. {
  5977. "name": "monitoring",
  5978. "type": "Monitoring"
  5979. },
  5980. {
  5981. "name": "properties",
  5982. "type": "Property",
  5983. "isMany": true
  5984. },
  5985. {
  5986. "name": "artifacts",
  5987. "type": "Artifact",
  5988. "isMany": true
  5989. },
  5990. {
  5991. "name": "resources",
  5992. "type": "ResourceRole",
  5993. "isMany": true
  5994. },
  5995. {
  5996. "name": "correlationSubscriptions",
  5997. "type": "CorrelationSubscription",
  5998. "isMany": true
  5999. },
  6000. {
  6001. "name": "supports",
  6002. "type": "Process",
  6003. "isMany": true,
  6004. "isReference": true
  6005. },
  6006. {
  6007. "name": "definitionalCollaborationRef",
  6008. "type": "Collaboration",
  6009. "isAttr": true,
  6010. "isReference": true
  6011. },
  6012. {
  6013. "name": "isExecutable",
  6014. "isAttr": true,
  6015. "type": "Boolean"
  6016. }
  6017. ]
  6018. },
  6019. {
  6020. "name": "LaneSet",
  6021. "superClass": [
  6022. "BaseElement"
  6023. ],
  6024. "properties": [
  6025. {
  6026. "name": "lanes",
  6027. "type": "Lane",
  6028. "isMany": true
  6029. },
  6030. {
  6031. "name": "name",
  6032. "isAttr": true,
  6033. "type": "String"
  6034. }
  6035. ]
  6036. },
  6037. {
  6038. "name": "Lane",
  6039. "superClass": [
  6040. "BaseElement"
  6041. ],
  6042. "properties": [
  6043. {
  6044. "name": "name",
  6045. "isAttr": true,
  6046. "type": "String"
  6047. },
  6048. {
  6049. "name": "childLaneSet",
  6050. "type": "LaneSet",
  6051. "xml": {
  6052. "serialize": "xsi:type"
  6053. }
  6054. },
  6055. {
  6056. "name": "partitionElementRef",
  6057. "type": "BaseElement",
  6058. "isAttr": true,
  6059. "isReference": true
  6060. },
  6061. {
  6062. "name": "flowNodeRef",
  6063. "type": "FlowNode",
  6064. "isMany": true,
  6065. "isReference": true
  6066. },
  6067. {
  6068. "name": "partitionElement",
  6069. "type": "BaseElement"
  6070. }
  6071. ]
  6072. },
  6073. {
  6074. "name": "GlobalManualTask",
  6075. "superClass": [
  6076. "GlobalTask"
  6077. ]
  6078. },
  6079. {
  6080. "name": "ManualTask",
  6081. "superClass": [
  6082. "Task"
  6083. ]
  6084. },
  6085. {
  6086. "name": "UserTask",
  6087. "superClass": [
  6088. "Task"
  6089. ],
  6090. "properties": [
  6091. {
  6092. "name": "renderings",
  6093. "type": "Rendering",
  6094. "isMany": true
  6095. },
  6096. {
  6097. "name": "implementation",
  6098. "isAttr": true,
  6099. "type": "String"
  6100. }
  6101. ]
  6102. },
  6103. {
  6104. "name": "Rendering",
  6105. "superClass": [
  6106. "BaseElement"
  6107. ]
  6108. },
  6109. {
  6110. "name": "HumanPerformer",
  6111. "superClass": [
  6112. "Performer"
  6113. ]
  6114. },
  6115. {
  6116. "name": "PotentialOwner",
  6117. "superClass": [
  6118. "HumanPerformer"
  6119. ]
  6120. },
  6121. {
  6122. "name": "GlobalUserTask",
  6123. "superClass": [
  6124. "GlobalTask"
  6125. ],
  6126. "properties": [
  6127. {
  6128. "name": "implementation",
  6129. "isAttr": true,
  6130. "type": "String"
  6131. },
  6132. {
  6133. "name": "renderings",
  6134. "type": "Rendering",
  6135. "isMany": true
  6136. }
  6137. ]
  6138. },
  6139. {
  6140. "name": "Gateway",
  6141. "isAbstract": true,
  6142. "superClass": [
  6143. "FlowNode"
  6144. ],
  6145. "properties": [
  6146. {
  6147. "name": "gatewayDirection",
  6148. "type": "GatewayDirection",
  6149. "default": "Unspecified",
  6150. "isAttr": true
  6151. }
  6152. ]
  6153. },
  6154. {
  6155. "name": "EventBasedGateway",
  6156. "superClass": [
  6157. "Gateway"
  6158. ],
  6159. "properties": [
  6160. {
  6161. "name": "instantiate",
  6162. "default": false,
  6163. "isAttr": true,
  6164. "type": "Boolean"
  6165. },
  6166. {
  6167. "name": "eventGatewayType",
  6168. "type": "EventBasedGatewayType",
  6169. "isAttr": true,
  6170. "default": "Exclusive"
  6171. }
  6172. ]
  6173. },
  6174. {
  6175. "name": "ComplexGateway",
  6176. "superClass": [
  6177. "Gateway"
  6178. ],
  6179. "properties": [
  6180. {
  6181. "name": "activationCondition",
  6182. "type": "Expression",
  6183. "xml": {
  6184. "serialize": "xsi:type"
  6185. }
  6186. },
  6187. {
  6188. "name": "default",
  6189. "type": "SequenceFlow",
  6190. "isAttr": true,
  6191. "isReference": true
  6192. }
  6193. ]
  6194. },
  6195. {
  6196. "name": "ExclusiveGateway",
  6197. "superClass": [
  6198. "Gateway"
  6199. ],
  6200. "properties": [
  6201. {
  6202. "name": "default",
  6203. "type": "SequenceFlow",
  6204. "isAttr": true,
  6205. "isReference": true
  6206. }
  6207. ]
  6208. },
  6209. {
  6210. "name": "InclusiveGateway",
  6211. "superClass": [
  6212. "Gateway"
  6213. ],
  6214. "properties": [
  6215. {
  6216. "name": "default",
  6217. "type": "SequenceFlow",
  6218. "isAttr": true,
  6219. "isReference": true
  6220. }
  6221. ]
  6222. },
  6223. {
  6224. "name": "ParallelGateway",
  6225. "superClass": [
  6226. "Gateway"
  6227. ]
  6228. },
  6229. {
  6230. "name": "RootElement",
  6231. "isAbstract": true,
  6232. "superClass": [
  6233. "BaseElement"
  6234. ]
  6235. },
  6236. {
  6237. "name": "Relationship",
  6238. "superClass": [
  6239. "BaseElement"
  6240. ],
  6241. "properties": [
  6242. {
  6243. "name": "type",
  6244. "isAttr": true,
  6245. "type": "String"
  6246. },
  6247. {
  6248. "name": "direction",
  6249. "type": "RelationshipDirection",
  6250. "isAttr": true
  6251. },
  6252. {
  6253. "name": "source",
  6254. "isMany": true,
  6255. "isReference": true,
  6256. "type": "Element"
  6257. },
  6258. {
  6259. "name": "target",
  6260. "isMany": true,
  6261. "isReference": true,
  6262. "type": "Element"
  6263. }
  6264. ]
  6265. },
  6266. {
  6267. "name": "BaseElement",
  6268. "isAbstract": true,
  6269. "properties": [
  6270. {
  6271. "name": "id",
  6272. "isAttr": true,
  6273. "type": "String"
  6274. },
  6275. {
  6276. "name": "documentation",
  6277. "type": "Documentation",
  6278. "isMany": true
  6279. },
  6280. {
  6281. "name": "extensionDefinitions",
  6282. "type": "ExtensionDefinition",
  6283. "isMany": true,
  6284. "isReference": true
  6285. },
  6286. {
  6287. "name": "extensionElements",
  6288. "type": "ExtensionElements"
  6289. }
  6290. ]
  6291. },
  6292. {
  6293. "name": "Extension",
  6294. "properties": [
  6295. {
  6296. "name": "mustUnderstand",
  6297. "default": false,
  6298. "isAttr": true,
  6299. "type": "Boolean"
  6300. },
  6301. {
  6302. "name": "definition",
  6303. "type": "ExtensionDefinition"
  6304. }
  6305. ]
  6306. },
  6307. {
  6308. "name": "ExtensionDefinition",
  6309. "properties": [
  6310. {
  6311. "name": "name",
  6312. "isAttr": true,
  6313. "type": "String"
  6314. },
  6315. {
  6316. "name": "extensionAttributeDefinitions",
  6317. "type": "ExtensionAttributeDefinition",
  6318. "isMany": true
  6319. }
  6320. ]
  6321. },
  6322. {
  6323. "name": "ExtensionAttributeDefinition",
  6324. "properties": [
  6325. {
  6326. "name": "name",
  6327. "isAttr": true,
  6328. "type": "String"
  6329. },
  6330. {
  6331. "name": "type",
  6332. "isAttr": true,
  6333. "type": "String"
  6334. },
  6335. {
  6336. "name": "isReference",
  6337. "default": false,
  6338. "isAttr": true,
  6339. "type": "Boolean"
  6340. },
  6341. {
  6342. "name": "extensionDefinition",
  6343. "type": "ExtensionDefinition",
  6344. "isAttr": true,
  6345. "isReference": true
  6346. }
  6347. ]
  6348. },
  6349. {
  6350. "name": "ExtensionElements",
  6351. "properties": [
  6352. {
  6353. "name": "valueRef",
  6354. "isAttr": true,
  6355. "isReference": true,
  6356. "type": "Element"
  6357. },
  6358. {
  6359. "name": "values",
  6360. "type": "Element",
  6361. "isMany": true
  6362. },
  6363. {
  6364. "name": "extensionAttributeDefinition",
  6365. "type": "ExtensionAttributeDefinition",
  6366. "isAttr": true,
  6367. "isReference": true
  6368. }
  6369. ]
  6370. },
  6371. {
  6372. "name": "Documentation",
  6373. "superClass": [
  6374. "BaseElement"
  6375. ],
  6376. "properties": [
  6377. {
  6378. "name": "text",
  6379. "type": "String",
  6380. "isBody": true
  6381. },
  6382. {
  6383. "name": "textFormat",
  6384. "default": "text/plain",
  6385. "isAttr": true,
  6386. "type": "String"
  6387. }
  6388. ]
  6389. },
  6390. {
  6391. "name": "Event",
  6392. "isAbstract": true,
  6393. "superClass": [
  6394. "FlowNode",
  6395. "InteractionNode"
  6396. ],
  6397. "properties": [
  6398. {
  6399. "name": "properties",
  6400. "type": "Property",
  6401. "isMany": true
  6402. }
  6403. ]
  6404. },
  6405. {
  6406. "name": "IntermediateCatchEvent",
  6407. "superClass": [
  6408. "CatchEvent"
  6409. ]
  6410. },
  6411. {
  6412. "name": "IntermediateThrowEvent",
  6413. "superClass": [
  6414. "ThrowEvent"
  6415. ]
  6416. },
  6417. {
  6418. "name": "EndEvent",
  6419. "superClass": [
  6420. "ThrowEvent"
  6421. ]
  6422. },
  6423. {
  6424. "name": "StartEvent",
  6425. "superClass": [
  6426. "CatchEvent"
  6427. ],
  6428. "properties": [
  6429. {
  6430. "name": "isInterrupting",
  6431. "default": true,
  6432. "isAttr": true,
  6433. "type": "Boolean"
  6434. }
  6435. ]
  6436. },
  6437. {
  6438. "name": "ThrowEvent",
  6439. "isAbstract": true,
  6440. "superClass": [
  6441. "Event"
  6442. ],
  6443. "properties": [
  6444. {
  6445. "name": "inputSet",
  6446. "type": "InputSet"
  6447. },
  6448. {
  6449. "name": "eventDefinitionRefs",
  6450. "type": "EventDefinition",
  6451. "isMany": true,
  6452. "isReference": true
  6453. },
  6454. {
  6455. "name": "dataInputAssociation",
  6456. "type": "DataInputAssociation",
  6457. "isMany": true
  6458. },
  6459. {
  6460. "name": "dataInputs",
  6461. "type": "DataInput",
  6462. "isMany": true
  6463. },
  6464. {
  6465. "name": "eventDefinitions",
  6466. "type": "EventDefinition",
  6467. "isMany": true
  6468. }
  6469. ]
  6470. },
  6471. {
  6472. "name": "CatchEvent",
  6473. "isAbstract": true,
  6474. "superClass": [
  6475. "Event"
  6476. ],
  6477. "properties": [
  6478. {
  6479. "name": "parallelMultiple",
  6480. "isAttr": true,
  6481. "type": "Boolean",
  6482. "default": false
  6483. },
  6484. {
  6485. "name": "outputSet",
  6486. "type": "OutputSet"
  6487. },
  6488. {
  6489. "name": "eventDefinitionRefs",
  6490. "type": "EventDefinition",
  6491. "isMany": true,
  6492. "isReference": true
  6493. },
  6494. {
  6495. "name": "dataOutputAssociation",
  6496. "type": "DataOutputAssociation",
  6497. "isMany": true
  6498. },
  6499. {
  6500. "name": "dataOutputs",
  6501. "type": "DataOutput",
  6502. "isMany": true
  6503. },
  6504. {
  6505. "name": "eventDefinitions",
  6506. "type": "EventDefinition",
  6507. "isMany": true
  6508. }
  6509. ]
  6510. },
  6511. {
  6512. "name": "BoundaryEvent",
  6513. "superClass": [
  6514. "CatchEvent"
  6515. ],
  6516. "properties": [
  6517. {
  6518. "name": "cancelActivity",
  6519. "default": true,
  6520. "isAttr": true,
  6521. "type": "Boolean"
  6522. },
  6523. {
  6524. "name": "attachedToRef",
  6525. "type": "Activity",
  6526. "isAttr": true,
  6527. "isReference": true
  6528. }
  6529. ]
  6530. },
  6531. {
  6532. "name": "EventDefinition",
  6533. "isAbstract": true,
  6534. "superClass": [
  6535. "RootElement"
  6536. ]
  6537. },
  6538. {
  6539. "name": "CancelEventDefinition",
  6540. "superClass": [
  6541. "EventDefinition"
  6542. ]
  6543. },
  6544. {
  6545. "name": "ErrorEventDefinition",
  6546. "superClass": [
  6547. "EventDefinition"
  6548. ],
  6549. "properties": [
  6550. {
  6551. "name": "errorRef",
  6552. "type": "Error",
  6553. "isAttr": true,
  6554. "isReference": true
  6555. }
  6556. ]
  6557. },
  6558. {
  6559. "name": "TerminateEventDefinition",
  6560. "superClass": [
  6561. "EventDefinition"
  6562. ]
  6563. },
  6564. {
  6565. "name": "EscalationEventDefinition",
  6566. "superClass": [
  6567. "EventDefinition"
  6568. ],
  6569. "properties": [
  6570. {
  6571. "name": "escalationRef",
  6572. "type": "Escalation",
  6573. "isAttr": true,
  6574. "isReference": true
  6575. }
  6576. ]
  6577. },
  6578. {
  6579. "name": "Escalation",
  6580. "properties": [
  6581. {
  6582. "name": "structureRef",
  6583. "type": "ItemDefinition",
  6584. "isAttr": true,
  6585. "isReference": true
  6586. },
  6587. {
  6588. "name": "name",
  6589. "isAttr": true,
  6590. "type": "String"
  6591. },
  6592. {
  6593. "name": "escalationCode",
  6594. "isAttr": true,
  6595. "type": "String"
  6596. }
  6597. ],
  6598. "superClass": [
  6599. "RootElement"
  6600. ]
  6601. },
  6602. {
  6603. "name": "CompensateEventDefinition",
  6604. "superClass": [
  6605. "EventDefinition"
  6606. ],
  6607. "properties": [
  6608. {
  6609. "name": "waitForCompletion",
  6610. "isAttr": true,
  6611. "type": "Boolean"
  6612. },
  6613. {
  6614. "name": "activityRef",
  6615. "type": "Activity",
  6616. "isAttr": true,
  6617. "isReference": true
  6618. }
  6619. ]
  6620. },
  6621. {
  6622. "name": "TimerEventDefinition",
  6623. "superClass": [
  6624. "EventDefinition"
  6625. ],
  6626. "properties": [
  6627. {
  6628. "name": "timeDate",
  6629. "type": "Expression",
  6630. "xml": {
  6631. "serialize": "xsi:type"
  6632. }
  6633. },
  6634. {
  6635. "name": "timeCycle",
  6636. "type": "Expression",
  6637. "xml": {
  6638. "serialize": "xsi:type"
  6639. }
  6640. },
  6641. {
  6642. "name": "timeDuration",
  6643. "type": "Expression",
  6644. "xml": {
  6645. "serialize": "xsi:type"
  6646. }
  6647. }
  6648. ]
  6649. },
  6650. {
  6651. "name": "LinkEventDefinition",
  6652. "superClass": [
  6653. "EventDefinition"
  6654. ],
  6655. "properties": [
  6656. {
  6657. "name": "name",
  6658. "isAttr": true,
  6659. "type": "String"
  6660. },
  6661. {
  6662. "name": "target",
  6663. "type": "LinkEventDefinition",
  6664. "isAttr": true,
  6665. "isReference": true
  6666. },
  6667. {
  6668. "name": "source",
  6669. "type": "LinkEventDefinition",
  6670. "isMany": true,
  6671. "isReference": true
  6672. }
  6673. ]
  6674. },
  6675. {
  6676. "name": "MessageEventDefinition",
  6677. "superClass": [
  6678. "EventDefinition"
  6679. ],
  6680. "properties": [
  6681. {
  6682. "name": "messageRef",
  6683. "type": "Message",
  6684. "isAttr": true,
  6685. "isReference": true
  6686. },
  6687. {
  6688. "name": "operationRef",
  6689. "type": "Operation",
  6690. "isAttr": true,
  6691. "isReference": true
  6692. }
  6693. ]
  6694. },
  6695. {
  6696. "name": "ConditionalEventDefinition",
  6697. "superClass": [
  6698. "EventDefinition"
  6699. ],
  6700. "properties": [
  6701. {
  6702. "name": "condition",
  6703. "type": "Expression",
  6704. "xml": {
  6705. "serialize": "xsi:type"
  6706. }
  6707. }
  6708. ]
  6709. },
  6710. {
  6711. "name": "SignalEventDefinition",
  6712. "superClass": [
  6713. "EventDefinition"
  6714. ],
  6715. "properties": [
  6716. {
  6717. "name": "signalRef",
  6718. "type": "Signal",
  6719. "isAttr": true,
  6720. "isReference": true
  6721. }
  6722. ]
  6723. },
  6724. {
  6725. "name": "Signal",
  6726. "superClass": [
  6727. "RootElement"
  6728. ],
  6729. "properties": [
  6730. {
  6731. "name": "structureRef",
  6732. "type": "ItemDefinition",
  6733. "isAttr": true,
  6734. "isReference": true
  6735. },
  6736. {
  6737. "name": "name",
  6738. "isAttr": true,
  6739. "type": "String"
  6740. }
  6741. ]
  6742. },
  6743. {
  6744. "name": "ImplicitThrowEvent",
  6745. "superClass": [
  6746. "ThrowEvent"
  6747. ]
  6748. },
  6749. {
  6750. "name": "DataState",
  6751. "superClass": [
  6752. "BaseElement"
  6753. ],
  6754. "properties": [
  6755. {
  6756. "name": "name",
  6757. "isAttr": true,
  6758. "type": "String"
  6759. }
  6760. ]
  6761. },
  6762. {
  6763. "name": "ItemAwareElement",
  6764. "superClass": [
  6765. "BaseElement"
  6766. ],
  6767. "properties": [
  6768. {
  6769. "name": "itemSubjectRef",
  6770. "type": "ItemDefinition",
  6771. "isAttr": true,
  6772. "isReference": true
  6773. },
  6774. {
  6775. "name": "dataState",
  6776. "type": "DataState"
  6777. }
  6778. ]
  6779. },
  6780. {
  6781. "name": "DataAssociation",
  6782. "superClass": [
  6783. "BaseElement"
  6784. ],
  6785. "properties": [
  6786. {
  6787. "name": "transformation",
  6788. "type": "FormalExpression"
  6789. },
  6790. {
  6791. "name": "assignment",
  6792. "type": "Assignment",
  6793. "isMany": true
  6794. },
  6795. {
  6796. "name": "sourceRef",
  6797. "type": "ItemAwareElement",
  6798. "isMany": true,
  6799. "isReference": true
  6800. },
  6801. {
  6802. "name": "targetRef",
  6803. "type": "ItemAwareElement",
  6804. "isReference": true
  6805. }
  6806. ]
  6807. },
  6808. {
  6809. "name": "DataInput",
  6810. "superClass": [
  6811. "ItemAwareElement"
  6812. ],
  6813. "properties": [
  6814. {
  6815. "name": "name",
  6816. "isAttr": true,
  6817. "type": "String"
  6818. },
  6819. {
  6820. "name": "isCollection",
  6821. "default": false,
  6822. "isAttr": true,
  6823. "type": "Boolean"
  6824. },
  6825. {
  6826. "name": "inputSetRefs",
  6827. "type": "InputSet",
  6828. "isVirtual": true,
  6829. "isMany": true,
  6830. "isReference": true
  6831. },
  6832. {
  6833. "name": "inputSetWithOptional",
  6834. "type": "InputSet",
  6835. "isVirtual": true,
  6836. "isMany": true,
  6837. "isReference": true
  6838. },
  6839. {
  6840. "name": "inputSetWithWhileExecuting",
  6841. "type": "InputSet",
  6842. "isVirtual": true,
  6843. "isMany": true,
  6844. "isReference": true
  6845. }
  6846. ]
  6847. },
  6848. {
  6849. "name": "DataOutput",
  6850. "superClass": [
  6851. "ItemAwareElement"
  6852. ],
  6853. "properties": [
  6854. {
  6855. "name": "name",
  6856. "isAttr": true,
  6857. "type": "String"
  6858. },
  6859. {
  6860. "name": "isCollection",
  6861. "default": false,
  6862. "isAttr": true,
  6863. "type": "Boolean"
  6864. },
  6865. {
  6866. "name": "outputSetRefs",
  6867. "type": "OutputSet",
  6868. "isVirtual": true,
  6869. "isMany": true,
  6870. "isReference": true
  6871. },
  6872. {
  6873. "name": "outputSetWithOptional",
  6874. "type": "OutputSet",
  6875. "isVirtual": true,
  6876. "isMany": true,
  6877. "isReference": true
  6878. },
  6879. {
  6880. "name": "outputSetWithWhileExecuting",
  6881. "type": "OutputSet",
  6882. "isVirtual": true,
  6883. "isMany": true,
  6884. "isReference": true
  6885. }
  6886. ]
  6887. },
  6888. {
  6889. "name": "InputSet",
  6890. "superClass": [
  6891. "BaseElement"
  6892. ],
  6893. "properties": [
  6894. {
  6895. "name": "name",
  6896. "isAttr": true,
  6897. "type": "String"
  6898. },
  6899. {
  6900. "name": "dataInputRefs",
  6901. "type": "DataInput",
  6902. "isMany": true,
  6903. "isReference": true
  6904. },
  6905. {
  6906. "name": "optionalInputRefs",
  6907. "type": "DataInput",
  6908. "isMany": true,
  6909. "isReference": true
  6910. },
  6911. {
  6912. "name": "whileExecutingInputRefs",
  6913. "type": "DataInput",
  6914. "isMany": true,
  6915. "isReference": true
  6916. },
  6917. {
  6918. "name": "outputSetRefs",
  6919. "type": "OutputSet",
  6920. "isMany": true,
  6921. "isReference": true
  6922. }
  6923. ]
  6924. },
  6925. {
  6926. "name": "OutputSet",
  6927. "superClass": [
  6928. "BaseElement"
  6929. ],
  6930. "properties": [
  6931. {
  6932. "name": "dataOutputRefs",
  6933. "type": "DataOutput",
  6934. "isMany": true,
  6935. "isReference": true
  6936. },
  6937. {
  6938. "name": "name",
  6939. "isAttr": true,
  6940. "type": "String"
  6941. },
  6942. {
  6943. "name": "inputSetRefs",
  6944. "type": "InputSet",
  6945. "isMany": true,
  6946. "isReference": true
  6947. },
  6948. {
  6949. "name": "optionalOutputRefs",
  6950. "type": "DataOutput",
  6951. "isMany": true,
  6952. "isReference": true
  6953. },
  6954. {
  6955. "name": "whileExecutingOutputRefs",
  6956. "type": "DataOutput",
  6957. "isMany": true,
  6958. "isReference": true
  6959. }
  6960. ]
  6961. },
  6962. {
  6963. "name": "Property",
  6964. "superClass": [
  6965. "ItemAwareElement"
  6966. ],
  6967. "properties": [
  6968. {
  6969. "name": "name",
  6970. "isAttr": true,
  6971. "type": "String"
  6972. }
  6973. ]
  6974. },
  6975. {
  6976. "name": "DataInputAssociation",
  6977. "superClass": [
  6978. "DataAssociation"
  6979. ]
  6980. },
  6981. {
  6982. "name": "DataOutputAssociation",
  6983. "superClass": [
  6984. "DataAssociation"
  6985. ]
  6986. },
  6987. {
  6988. "name": "InputOutputSpecification",
  6989. "superClass": [
  6990. "BaseElement"
  6991. ],
  6992. "properties": [
  6993. {
  6994. "name": "dataInputs",
  6995. "type": "DataInput",
  6996. "isMany": true
  6997. },
  6998. {
  6999. "name": "dataOutputs",
  7000. "type": "DataOutput",
  7001. "isMany": true
  7002. },
  7003. {
  7004. "name": "inputSets",
  7005. "type": "InputSet",
  7006. "isMany": true
  7007. },
  7008. {
  7009. "name": "outputSets",
  7010. "type": "OutputSet",
  7011. "isMany": true
  7012. }
  7013. ]
  7014. },
  7015. {
  7016. "name": "DataObject",
  7017. "superClass": [
  7018. "FlowElement",
  7019. "ItemAwareElement"
  7020. ],
  7021. "properties": [
  7022. {
  7023. "name": "isCollection",
  7024. "default": false,
  7025. "isAttr": true,
  7026. "type": "Boolean"
  7027. }
  7028. ]
  7029. },
  7030. {
  7031. "name": "InputOutputBinding",
  7032. "properties": [
  7033. {
  7034. "name": "inputDataRef",
  7035. "type": "InputSet",
  7036. "isAttr": true,
  7037. "isReference": true
  7038. },
  7039. {
  7040. "name": "outputDataRef",
  7041. "type": "OutputSet",
  7042. "isAttr": true,
  7043. "isReference": true
  7044. },
  7045. {
  7046. "name": "operationRef",
  7047. "type": "Operation",
  7048. "isAttr": true,
  7049. "isReference": true
  7050. }
  7051. ]
  7052. },
  7053. {
  7054. "name": "Assignment",
  7055. "superClass": [
  7056. "BaseElement"
  7057. ],
  7058. "properties": [
  7059. {
  7060. "name": "from",
  7061. "type": "Expression",
  7062. "xml": {
  7063. "serialize": "xsi:type"
  7064. }
  7065. },
  7066. {
  7067. "name": "to",
  7068. "type": "Expression",
  7069. "xml": {
  7070. "serialize": "xsi:type"
  7071. }
  7072. }
  7073. ]
  7074. },
  7075. {
  7076. "name": "DataStore",
  7077. "superClass": [
  7078. "RootElement",
  7079. "ItemAwareElement"
  7080. ],
  7081. "properties": [
  7082. {
  7083. "name": "name",
  7084. "isAttr": true,
  7085. "type": "String"
  7086. },
  7087. {
  7088. "name": "capacity",
  7089. "isAttr": true,
  7090. "type": "Integer"
  7091. },
  7092. {
  7093. "name": "isUnlimited",
  7094. "default": true,
  7095. "isAttr": true,
  7096. "type": "Boolean"
  7097. }
  7098. ]
  7099. },
  7100. {
  7101. "name": "DataStoreReference",
  7102. "superClass": [
  7103. "ItemAwareElement",
  7104. "FlowElement"
  7105. ],
  7106. "properties": [
  7107. {
  7108. "name": "dataStoreRef",
  7109. "type": "DataStore",
  7110. "isAttr": true,
  7111. "isReference": true
  7112. }
  7113. ]
  7114. },
  7115. {
  7116. "name": "DataObjectReference",
  7117. "superClass": [
  7118. "ItemAwareElement",
  7119. "FlowElement"
  7120. ],
  7121. "properties": [
  7122. {
  7123. "name": "dataObjectRef",
  7124. "type": "DataObject",
  7125. "isAttr": true,
  7126. "isReference": true
  7127. }
  7128. ]
  7129. },
  7130. {
  7131. "name": "ConversationLink",
  7132. "superClass": [
  7133. "BaseElement"
  7134. ],
  7135. "properties": [
  7136. {
  7137. "name": "sourceRef",
  7138. "type": "InteractionNode",
  7139. "isAttr": true,
  7140. "isReference": true
  7141. },
  7142. {
  7143. "name": "targetRef",
  7144. "type": "InteractionNode",
  7145. "isAttr": true,
  7146. "isReference": true
  7147. },
  7148. {
  7149. "name": "name",
  7150. "isAttr": true,
  7151. "type": "String"
  7152. }
  7153. ]
  7154. },
  7155. {
  7156. "name": "ConversationAssociation",
  7157. "superClass": [
  7158. "BaseElement"
  7159. ],
  7160. "properties": [
  7161. {
  7162. "name": "innerConversationNodeRef",
  7163. "type": "ConversationNode",
  7164. "isAttr": true,
  7165. "isReference": true
  7166. },
  7167. {
  7168. "name": "outerConversationNodeRef",
  7169. "type": "ConversationNode",
  7170. "isAttr": true,
  7171. "isReference": true
  7172. }
  7173. ]
  7174. },
  7175. {
  7176. "name": "CallConversation",
  7177. "superClass": [
  7178. "ConversationNode"
  7179. ],
  7180. "properties": [
  7181. {
  7182. "name": "calledCollaborationRef",
  7183. "type": "Collaboration",
  7184. "isAttr": true,
  7185. "isReference": true
  7186. },
  7187. {
  7188. "name": "participantAssociations",
  7189. "type": "ParticipantAssociation",
  7190. "isMany": true
  7191. }
  7192. ]
  7193. },
  7194. {
  7195. "name": "Conversation",
  7196. "superClass": [
  7197. "ConversationNode"
  7198. ]
  7199. },
  7200. {
  7201. "name": "SubConversation",
  7202. "superClass": [
  7203. "ConversationNode"
  7204. ],
  7205. "properties": [
  7206. {
  7207. "name": "conversationNodes",
  7208. "type": "ConversationNode",
  7209. "isMany": true
  7210. }
  7211. ]
  7212. },
  7213. {
  7214. "name": "ConversationNode",
  7215. "isAbstract": true,
  7216. "superClass": [
  7217. "InteractionNode",
  7218. "BaseElement"
  7219. ],
  7220. "properties": [
  7221. {
  7222. "name": "name",
  7223. "isAttr": true,
  7224. "type": "String"
  7225. },
  7226. {
  7227. "name": "participantRefs",
  7228. "type": "Participant",
  7229. "isMany": true,
  7230. "isReference": true
  7231. },
  7232. {
  7233. "name": "messageFlowRefs",
  7234. "type": "MessageFlow",
  7235. "isMany": true,
  7236. "isReference": true
  7237. },
  7238. {
  7239. "name": "correlationKeys",
  7240. "type": "CorrelationKey",
  7241. "isMany": true
  7242. }
  7243. ]
  7244. },
  7245. {
  7246. "name": "GlobalConversation",
  7247. "superClass": [
  7248. "Collaboration"
  7249. ]
  7250. },
  7251. {
  7252. "name": "PartnerEntity",
  7253. "superClass": [
  7254. "RootElement"
  7255. ],
  7256. "properties": [
  7257. {
  7258. "name": "name",
  7259. "isAttr": true,
  7260. "type": "String"
  7261. },
  7262. {
  7263. "name": "participantRef",
  7264. "type": "Participant",
  7265. "isMany": true,
  7266. "isReference": true
  7267. }
  7268. ]
  7269. },
  7270. {
  7271. "name": "PartnerRole",
  7272. "superClass": [
  7273. "RootElement"
  7274. ],
  7275. "properties": [
  7276. {
  7277. "name": "name",
  7278. "isAttr": true,
  7279. "type": "String"
  7280. },
  7281. {
  7282. "name": "participantRef",
  7283. "type": "Participant",
  7284. "isMany": true,
  7285. "isReference": true
  7286. }
  7287. ]
  7288. },
  7289. {
  7290. "name": "CorrelationProperty",
  7291. "superClass": [
  7292. "RootElement"
  7293. ],
  7294. "properties": [
  7295. {
  7296. "name": "correlationPropertyRetrievalExpression",
  7297. "type": "CorrelationPropertyRetrievalExpression",
  7298. "isMany": true
  7299. },
  7300. {
  7301. "name": "name",
  7302. "isAttr": true,
  7303. "type": "String"
  7304. },
  7305. {
  7306. "name": "type",
  7307. "type": "ItemDefinition",
  7308. "isAttr": true,
  7309. "isReference": true
  7310. }
  7311. ]
  7312. },
  7313. {
  7314. "name": "Error",
  7315. "superClass": [
  7316. "RootElement"
  7317. ],
  7318. "properties": [
  7319. {
  7320. "name": "structureRef",
  7321. "type": "ItemDefinition",
  7322. "isAttr": true,
  7323. "isReference": true
  7324. },
  7325. {
  7326. "name": "name",
  7327. "isAttr": true,
  7328. "type": "String"
  7329. },
  7330. {
  7331. "name": "errorCode",
  7332. "isAttr": true,
  7333. "type": "String"
  7334. }
  7335. ]
  7336. },
  7337. {
  7338. "name": "CorrelationKey",
  7339. "superClass": [
  7340. "BaseElement"
  7341. ],
  7342. "properties": [
  7343. {
  7344. "name": "correlationPropertyRef",
  7345. "type": "CorrelationProperty",
  7346. "isMany": true,
  7347. "isReference": true
  7348. },
  7349. {
  7350. "name": "name",
  7351. "isAttr": true,
  7352. "type": "String"
  7353. }
  7354. ]
  7355. },
  7356. {
  7357. "name": "Expression",
  7358. "superClass": [
  7359. "BaseElement"
  7360. ],
  7361. "isAbstract": true
  7362. },
  7363. {
  7364. "name": "FormalExpression",
  7365. "superClass": [
  7366. "Expression"
  7367. ],
  7368. "properties": [
  7369. {
  7370. "name": "language",
  7371. "isAttr": true,
  7372. "type": "String"
  7373. },
  7374. {
  7375. "name": "body",
  7376. "type": "String",
  7377. "isBody": true
  7378. },
  7379. {
  7380. "name": "evaluatesToTypeRef",
  7381. "type": "ItemDefinition",
  7382. "isAttr": true,
  7383. "isReference": true
  7384. }
  7385. ]
  7386. },
  7387. {
  7388. "name": "Message",
  7389. "superClass": [
  7390. "RootElement"
  7391. ],
  7392. "properties": [
  7393. {
  7394. "name": "name",
  7395. "isAttr": true,
  7396. "type": "String"
  7397. },
  7398. {
  7399. "name": "itemRef",
  7400. "type": "ItemDefinition",
  7401. "isAttr": true,
  7402. "isReference": true
  7403. }
  7404. ]
  7405. },
  7406. {
  7407. "name": "ItemDefinition",
  7408. "superClass": [
  7409. "RootElement"
  7410. ],
  7411. "properties": [
  7412. {
  7413. "name": "itemKind",
  7414. "type": "ItemKind",
  7415. "isAttr": true
  7416. },
  7417. {
  7418. "name": "structureRef",
  7419. "type": "String",
  7420. "isAttr": true
  7421. },
  7422. {
  7423. "name": "isCollection",
  7424. "default": false,
  7425. "isAttr": true,
  7426. "type": "Boolean"
  7427. },
  7428. {
  7429. "name": "import",
  7430. "type": "Import",
  7431. "isAttr": true,
  7432. "isReference": true
  7433. }
  7434. ]
  7435. },
  7436. {
  7437. "name": "FlowElement",
  7438. "isAbstract": true,
  7439. "superClass": [
  7440. "BaseElement"
  7441. ],
  7442. "properties": [
  7443. {
  7444. "name": "name",
  7445. "isAttr": true,
  7446. "type": "String"
  7447. },
  7448. {
  7449. "name": "auditing",
  7450. "type": "Auditing"
  7451. },
  7452. {
  7453. "name": "monitoring",
  7454. "type": "Monitoring"
  7455. },
  7456. {
  7457. "name": "categoryValueRef",
  7458. "type": "CategoryValue",
  7459. "isMany": true,
  7460. "isReference": true
  7461. }
  7462. ]
  7463. },
  7464. {
  7465. "name": "SequenceFlow",
  7466. "superClass": [
  7467. "FlowElement"
  7468. ],
  7469. "properties": [
  7470. {
  7471. "name": "isImmediate",
  7472. "isAttr": true,
  7473. "type": "Boolean"
  7474. },
  7475. {
  7476. "name": "conditionExpression",
  7477. "type": "Expression",
  7478. "xml": {
  7479. "serialize": "xsi:type"
  7480. }
  7481. },
  7482. {
  7483. "name": "sourceRef",
  7484. "type": "FlowNode",
  7485. "isAttr": true,
  7486. "isReference": true
  7487. },
  7488. {
  7489. "name": "targetRef",
  7490. "type": "FlowNode",
  7491. "isAttr": true,
  7492. "isReference": true
  7493. }
  7494. ]
  7495. },
  7496. {
  7497. "name": "FlowElementsContainer",
  7498. "isAbstract": true,
  7499. "superClass": [
  7500. "BaseElement"
  7501. ],
  7502. "properties": [
  7503. {
  7504. "name": "laneSets",
  7505. "type": "LaneSet",
  7506. "isMany": true
  7507. },
  7508. {
  7509. "name": "flowElements",
  7510. "type": "FlowElement",
  7511. "isMany": true
  7512. }
  7513. ]
  7514. },
  7515. {
  7516. "name": "CallableElement",
  7517. "isAbstract": true,
  7518. "superClass": [
  7519. "RootElement"
  7520. ],
  7521. "properties": [
  7522. {
  7523. "name": "name",
  7524. "isAttr": true,
  7525. "type": "String"
  7526. },
  7527. {
  7528. "name": "ioSpecification",
  7529. "type": "InputOutputSpecification",
  7530. "xml": {
  7531. "serialize": "property"
  7532. }
  7533. },
  7534. {
  7535. "name": "supportedInterfaceRefs",
  7536. "type": "Interface",
  7537. "isMany": true,
  7538. "isReference": true
  7539. },
  7540. {
  7541. "name": "ioBinding",
  7542. "type": "InputOutputBinding",
  7543. "isMany": true,
  7544. "xml": {
  7545. "serialize": "property"
  7546. }
  7547. }
  7548. ]
  7549. },
  7550. {
  7551. "name": "FlowNode",
  7552. "isAbstract": true,
  7553. "superClass": [
  7554. "FlowElement"
  7555. ],
  7556. "properties": [
  7557. {
  7558. "name": "incoming",
  7559. "type": "SequenceFlow",
  7560. "isMany": true,
  7561. "isReference": true
  7562. },
  7563. {
  7564. "name": "outgoing",
  7565. "type": "SequenceFlow",
  7566. "isMany": true,
  7567. "isReference": true
  7568. },
  7569. {
  7570. "name": "lanes",
  7571. "type": "Lane",
  7572. "isVirtual": true,
  7573. "isMany": true,
  7574. "isReference": true
  7575. }
  7576. ]
  7577. },
  7578. {
  7579. "name": "CorrelationPropertyRetrievalExpression",
  7580. "superClass": [
  7581. "BaseElement"
  7582. ],
  7583. "properties": [
  7584. {
  7585. "name": "messagePath",
  7586. "type": "FormalExpression"
  7587. },
  7588. {
  7589. "name": "messageRef",
  7590. "type": "Message",
  7591. "isAttr": true,
  7592. "isReference": true
  7593. }
  7594. ]
  7595. },
  7596. {
  7597. "name": "CorrelationPropertyBinding",
  7598. "superClass": [
  7599. "BaseElement"
  7600. ],
  7601. "properties": [
  7602. {
  7603. "name": "dataPath",
  7604. "type": "FormalExpression"
  7605. },
  7606. {
  7607. "name": "correlationPropertyRef",
  7608. "type": "CorrelationProperty",
  7609. "isAttr": true,
  7610. "isReference": true
  7611. }
  7612. ]
  7613. },
  7614. {
  7615. "name": "Resource",
  7616. "superClass": [
  7617. "RootElement"
  7618. ],
  7619. "properties": [
  7620. {
  7621. "name": "name",
  7622. "isAttr": true,
  7623. "type": "String"
  7624. },
  7625. {
  7626. "name": "resourceParameters",
  7627. "type": "ResourceParameter",
  7628. "isMany": true
  7629. }
  7630. ]
  7631. },
  7632. {
  7633. "name": "ResourceParameter",
  7634. "superClass": [
  7635. "BaseElement"
  7636. ],
  7637. "properties": [
  7638. {
  7639. "name": "name",
  7640. "isAttr": true,
  7641. "type": "String"
  7642. },
  7643. {
  7644. "name": "isRequired",
  7645. "isAttr": true,
  7646. "type": "Boolean"
  7647. },
  7648. {
  7649. "name": "type",
  7650. "type": "ItemDefinition",
  7651. "isAttr": true,
  7652. "isReference": true
  7653. }
  7654. ]
  7655. },
  7656. {
  7657. "name": "CorrelationSubscription",
  7658. "superClass": [
  7659. "BaseElement"
  7660. ],
  7661. "properties": [
  7662. {
  7663. "name": "correlationKeyRef",
  7664. "type": "CorrelationKey",
  7665. "isAttr": true,
  7666. "isReference": true
  7667. },
  7668. {
  7669. "name": "correlationPropertyBinding",
  7670. "type": "CorrelationPropertyBinding",
  7671. "isMany": true
  7672. }
  7673. ]
  7674. },
  7675. {
  7676. "name": "MessageFlow",
  7677. "superClass": [
  7678. "BaseElement"
  7679. ],
  7680. "properties": [
  7681. {
  7682. "name": "name",
  7683. "isAttr": true,
  7684. "type": "String"
  7685. },
  7686. {
  7687. "name": "sourceRef",
  7688. "type": "InteractionNode",
  7689. "isAttr": true,
  7690. "isReference": true
  7691. },
  7692. {
  7693. "name": "targetRef",
  7694. "type": "InteractionNode",
  7695. "isAttr": true,
  7696. "isReference": true
  7697. },
  7698. {
  7699. "name": "messageRef",
  7700. "type": "Message",
  7701. "isAttr": true,
  7702. "isReference": true
  7703. }
  7704. ]
  7705. },
  7706. {
  7707. "name": "MessageFlowAssociation",
  7708. "superClass": [
  7709. "BaseElement"
  7710. ],
  7711. "properties": [
  7712. {
  7713. "name": "innerMessageFlowRef",
  7714. "type": "MessageFlow",
  7715. "isAttr": true,
  7716. "isReference": true
  7717. },
  7718. {
  7719. "name": "outerMessageFlowRef",
  7720. "type": "MessageFlow",
  7721. "isAttr": true,
  7722. "isReference": true
  7723. }
  7724. ]
  7725. },
  7726. {
  7727. "name": "InteractionNode",
  7728. "isAbstract": true,
  7729. "properties": [
  7730. {
  7731. "name": "incomingConversationLinks",
  7732. "type": "ConversationLink",
  7733. "isVirtual": true,
  7734. "isMany": true,
  7735. "isReference": true
  7736. },
  7737. {
  7738. "name": "outgoingConversationLinks",
  7739. "type": "ConversationLink",
  7740. "isVirtual": true,
  7741. "isMany": true,
  7742. "isReference": true
  7743. }
  7744. ]
  7745. },
  7746. {
  7747. "name": "Participant",
  7748. "superClass": [
  7749. "InteractionNode",
  7750. "BaseElement"
  7751. ],
  7752. "properties": [
  7753. {
  7754. "name": "name",
  7755. "isAttr": true,
  7756. "type": "String"
  7757. },
  7758. {
  7759. "name": "interfaceRefs",
  7760. "type": "Interface",
  7761. "isMany": true,
  7762. "isReference": true
  7763. },
  7764. {
  7765. "name": "participantMultiplicity",
  7766. "type": "ParticipantMultiplicity"
  7767. },
  7768. {
  7769. "name": "endPointRefs",
  7770. "type": "EndPoint",
  7771. "isMany": true,
  7772. "isReference": true
  7773. },
  7774. {
  7775. "name": "processRef",
  7776. "type": "Process",
  7777. "isAttr": true,
  7778. "isReference": true
  7779. }
  7780. ]
  7781. },
  7782. {
  7783. "name": "ParticipantAssociation",
  7784. "superClass": [
  7785. "BaseElement"
  7786. ],
  7787. "properties": [
  7788. {
  7789. "name": "innerParticipantRef",
  7790. "type": "Participant",
  7791. "isAttr": true,
  7792. "isReference": true
  7793. },
  7794. {
  7795. "name": "outerParticipantRef",
  7796. "type": "Participant",
  7797. "isAttr": true,
  7798. "isReference": true
  7799. }
  7800. ]
  7801. },
  7802. {
  7803. "name": "ParticipantMultiplicity",
  7804. "properties": [
  7805. {
  7806. "name": "minimum",
  7807. "default": 0,
  7808. "isAttr": true,
  7809. "type": "Integer"
  7810. },
  7811. {
  7812. "name": "maximum",
  7813. "default": 1,
  7814. "isAttr": true,
  7815. "type": "Integer"
  7816. }
  7817. ]
  7818. },
  7819. {
  7820. "name": "Collaboration",
  7821. "superClass": [
  7822. "RootElement"
  7823. ],
  7824. "properties": [
  7825. {
  7826. "name": "name",
  7827. "isAttr": true,
  7828. "type": "String"
  7829. },
  7830. {
  7831. "name": "isClosed",
  7832. "isAttr": true,
  7833. "type": "Boolean"
  7834. },
  7835. {
  7836. "name": "choreographyRef",
  7837. "type": "Choreography",
  7838. "isMany": true,
  7839. "isReference": true
  7840. },
  7841. {
  7842. "name": "artifacts",
  7843. "type": "Artifact",
  7844. "isMany": true
  7845. },
  7846. {
  7847. "name": "participantAssociations",
  7848. "type": "ParticipantAssociation",
  7849. "isMany": true
  7850. },
  7851. {
  7852. "name": "messageFlowAssociations",
  7853. "type": "MessageFlowAssociation",
  7854. "isMany": true
  7855. },
  7856. {
  7857. "name": "conversationAssociations",
  7858. "type": "ConversationAssociation"
  7859. },
  7860. {
  7861. "name": "participants",
  7862. "type": "Participant",
  7863. "isMany": true
  7864. },
  7865. {
  7866. "name": "messageFlows",
  7867. "type": "MessageFlow",
  7868. "isMany": true
  7869. },
  7870. {
  7871. "name": "correlationKeys",
  7872. "type": "CorrelationKey",
  7873. "isMany": true
  7874. },
  7875. {
  7876. "name": "conversations",
  7877. "type": "ConversationNode",
  7878. "isMany": true
  7879. },
  7880. {
  7881. "name": "conversationLinks",
  7882. "type": "ConversationLink",
  7883. "isMany": true
  7884. }
  7885. ]
  7886. },
  7887. {
  7888. "name": "ChoreographyActivity",
  7889. "isAbstract": true,
  7890. "superClass": [
  7891. "FlowNode"
  7892. ],
  7893. "properties": [
  7894. {
  7895. "name": "participantRefs",
  7896. "type": "Participant",
  7897. "isMany": true,
  7898. "isReference": true
  7899. },
  7900. {
  7901. "name": "initiatingParticipantRef",
  7902. "type": "Participant",
  7903. "isAttr": true,
  7904. "isReference": true
  7905. },
  7906. {
  7907. "name": "correlationKeys",
  7908. "type": "CorrelationKey",
  7909. "isMany": true
  7910. },
  7911. {
  7912. "name": "loopType",
  7913. "type": "ChoreographyLoopType",
  7914. "default": "None",
  7915. "isAttr": true
  7916. }
  7917. ]
  7918. },
  7919. {
  7920. "name": "CallChoreography",
  7921. "superClass": [
  7922. "ChoreographyActivity"
  7923. ],
  7924. "properties": [
  7925. {
  7926. "name": "calledChoreographyRef",
  7927. "type": "Choreography",
  7928. "isAttr": true,
  7929. "isReference": true
  7930. },
  7931. {
  7932. "name": "participantAssociations",
  7933. "type": "ParticipantAssociation",
  7934. "isMany": true
  7935. }
  7936. ]
  7937. },
  7938. {
  7939. "name": "SubChoreography",
  7940. "superClass": [
  7941. "ChoreographyActivity",
  7942. "FlowElementsContainer"
  7943. ],
  7944. "properties": [
  7945. {
  7946. "name": "artifacts",
  7947. "type": "Artifact",
  7948. "isMany": true
  7949. }
  7950. ]
  7951. },
  7952. {
  7953. "name": "ChoreographyTask",
  7954. "superClass": [
  7955. "ChoreographyActivity"
  7956. ],
  7957. "properties": [
  7958. {
  7959. "name": "messageFlowRef",
  7960. "type": "MessageFlow",
  7961. "isMany": true,
  7962. "isReference": true
  7963. }
  7964. ]
  7965. },
  7966. {
  7967. "name": "Choreography",
  7968. "superClass": [
  7969. "FlowElementsContainer",
  7970. "Collaboration"
  7971. ]
  7972. },
  7973. {
  7974. "name": "GlobalChoreographyTask",
  7975. "superClass": [
  7976. "Choreography"
  7977. ],
  7978. "properties": [
  7979. {
  7980. "name": "initiatingParticipantRef",
  7981. "type": "Participant",
  7982. "isAttr": true,
  7983. "isReference": true
  7984. }
  7985. ]
  7986. },
  7987. {
  7988. "name": "TextAnnotation",
  7989. "superClass": [
  7990. "Artifact"
  7991. ],
  7992. "properties": [
  7993. {
  7994. "name": "text",
  7995. "type": "String"
  7996. },
  7997. {
  7998. "name": "textFormat",
  7999. "default": "text/plain",
  8000. "isAttr": true,
  8001. "type": "String"
  8002. }
  8003. ]
  8004. },
  8005. {
  8006. "name": "Group",
  8007. "superClass": [
  8008. "Artifact"
  8009. ],
  8010. "properties": [
  8011. {
  8012. "name": "categoryValueRef",
  8013. "type": "CategoryValue",
  8014. "isAttr": true,
  8015. "isReference": true
  8016. }
  8017. ]
  8018. },
  8019. {
  8020. "name": "Association",
  8021. "superClass": [
  8022. "Artifact"
  8023. ],
  8024. "properties": [
  8025. {
  8026. "name": "associationDirection",
  8027. "type": "AssociationDirection",
  8028. "isAttr": true
  8029. },
  8030. {
  8031. "name": "sourceRef",
  8032. "type": "BaseElement",
  8033. "isAttr": true,
  8034. "isReference": true
  8035. },
  8036. {
  8037. "name": "targetRef",
  8038. "type": "BaseElement",
  8039. "isAttr": true,
  8040. "isReference": true
  8041. }
  8042. ]
  8043. },
  8044. {
  8045. "name": "Category",
  8046. "superClass": [
  8047. "RootElement"
  8048. ],
  8049. "properties": [
  8050. {
  8051. "name": "categoryValue",
  8052. "type": "CategoryValue",
  8053. "isMany": true
  8054. },
  8055. {
  8056. "name": "name",
  8057. "isAttr": true,
  8058. "type": "String"
  8059. }
  8060. ]
  8061. },
  8062. {
  8063. "name": "Artifact",
  8064. "isAbstract": true,
  8065. "superClass": [
  8066. "BaseElement"
  8067. ]
  8068. },
  8069. {
  8070. "name": "CategoryValue",
  8071. "superClass": [
  8072. "BaseElement"
  8073. ],
  8074. "properties": [
  8075. {
  8076. "name": "categorizedFlowElements",
  8077. "type": "FlowElement",
  8078. "isVirtual": true,
  8079. "isMany": true,
  8080. "isReference": true
  8081. },
  8082. {
  8083. "name": "value",
  8084. "isAttr": true,
  8085. "type": "String"
  8086. }
  8087. ]
  8088. },
  8089. {
  8090. "name": "Activity",
  8091. "isAbstract": true,
  8092. "superClass": [
  8093. "FlowNode"
  8094. ],
  8095. "properties": [
  8096. {
  8097. "name": "isForCompensation",
  8098. "default": false,
  8099. "isAttr": true,
  8100. "type": "Boolean"
  8101. },
  8102. {
  8103. "name": "default",
  8104. "type": "SequenceFlow",
  8105. "isAttr": true,
  8106. "isReference": true
  8107. },
  8108. {
  8109. "name": "ioSpecification",
  8110. "type": "InputOutputSpecification",
  8111. "xml": {
  8112. "serialize": "property"
  8113. }
  8114. },
  8115. {
  8116. "name": "boundaryEventRefs",
  8117. "type": "BoundaryEvent",
  8118. "isMany": true,
  8119. "isReference": true
  8120. },
  8121. {
  8122. "name": "properties",
  8123. "type": "Property",
  8124. "isMany": true
  8125. },
  8126. {
  8127. "name": "dataInputAssociations",
  8128. "type": "DataInputAssociation",
  8129. "isMany": true
  8130. },
  8131. {
  8132. "name": "dataOutputAssociations",
  8133. "type": "DataOutputAssociation",
  8134. "isMany": true
  8135. },
  8136. {
  8137. "name": "startQuantity",
  8138. "default": 1,
  8139. "isAttr": true,
  8140. "type": "Integer"
  8141. },
  8142. {
  8143. "name": "resources",
  8144. "type": "ResourceRole",
  8145. "isMany": true
  8146. },
  8147. {
  8148. "name": "completionQuantity",
  8149. "default": 1,
  8150. "isAttr": true,
  8151. "type": "Integer"
  8152. },
  8153. {
  8154. "name": "loopCharacteristics",
  8155. "type": "LoopCharacteristics"
  8156. }
  8157. ]
  8158. },
  8159. {
  8160. "name": "ServiceTask",
  8161. "superClass": [
  8162. "Task"
  8163. ],
  8164. "properties": [
  8165. {
  8166. "name": "implementation",
  8167. "isAttr": true,
  8168. "type": "String"
  8169. },
  8170. {
  8171. "name": "operationRef",
  8172. "type": "Operation",
  8173. "isAttr": true,
  8174. "isReference": true
  8175. }
  8176. ]
  8177. },
  8178. {
  8179. "name": "SubProcess",
  8180. "superClass": [
  8181. "Activity",
  8182. "FlowElementsContainer",
  8183. "InteractionNode"
  8184. ],
  8185. "properties": [
  8186. {
  8187. "name": "triggeredByEvent",
  8188. "default": false,
  8189. "isAttr": true,
  8190. "type": "Boolean"
  8191. },
  8192. {
  8193. "name": "artifacts",
  8194. "type": "Artifact",
  8195. "isMany": true
  8196. }
  8197. ]
  8198. },
  8199. {
  8200. "name": "LoopCharacteristics",
  8201. "isAbstract": true,
  8202. "superClass": [
  8203. "BaseElement"
  8204. ]
  8205. },
  8206. {
  8207. "name": "MultiInstanceLoopCharacteristics",
  8208. "superClass": [
  8209. "LoopCharacteristics"
  8210. ],
  8211. "properties": [
  8212. {
  8213. "name": "isSequential",
  8214. "default": false,
  8215. "isAttr": true,
  8216. "type": "Boolean"
  8217. },
  8218. {
  8219. "name": "behavior",
  8220. "type": "MultiInstanceBehavior",
  8221. "default": "All",
  8222. "isAttr": true
  8223. },
  8224. {
  8225. "name": "loopCardinality",
  8226. "type": "Expression",
  8227. "xml": {
  8228. "serialize": "xsi:type"
  8229. }
  8230. },
  8231. {
  8232. "name": "loopDataInputRef",
  8233. "type": "ItemAwareElement",
  8234. "isAttr": true,
  8235. "isReference": true
  8236. },
  8237. {
  8238. "name": "loopDataOutputRef",
  8239. "type": "ItemAwareElement",
  8240. "isAttr": true,
  8241. "isReference": true
  8242. },
  8243. {
  8244. "name": "inputDataItem",
  8245. "type": "DataInput"
  8246. },
  8247. {
  8248. "name": "outputDataItem",
  8249. "type": "DataOutput"
  8250. },
  8251. {
  8252. "name": "completionCondition",
  8253. "type": "Expression",
  8254. "xml": {
  8255. "serialize": "xsi:type"
  8256. }
  8257. },
  8258. {
  8259. "name": "complexBehaviorDefinition",
  8260. "type": "ComplexBehaviorDefinition",
  8261. "isMany": true
  8262. },
  8263. {
  8264. "name": "oneBehaviorEventRef",
  8265. "type": "EventDefinition",
  8266. "isAttr": true,
  8267. "isReference": true
  8268. },
  8269. {
  8270. "name": "noneBehaviorEventRef",
  8271. "type": "EventDefinition",
  8272. "isAttr": true,
  8273. "isReference": true
  8274. }
  8275. ]
  8276. },
  8277. {
  8278. "name": "StandardLoopCharacteristics",
  8279. "superClass": [
  8280. "LoopCharacteristics"
  8281. ],
  8282. "properties": [
  8283. {
  8284. "name": "testBefore",
  8285. "default": false,
  8286. "isAttr": true,
  8287. "type": "Boolean"
  8288. },
  8289. {
  8290. "name": "loopCondition",
  8291. "type": "Expression",
  8292. "xml": {
  8293. "serialize": "xsi:type"
  8294. }
  8295. },
  8296. {
  8297. "name": "loopMaximum",
  8298. "type": "Expression",
  8299. "xml": {
  8300. "serialize": "xsi:type"
  8301. }
  8302. }
  8303. ]
  8304. },
  8305. {
  8306. "name": "CallActivity",
  8307. "superClass": [
  8308. "Activity"
  8309. ],
  8310. "properties": [
  8311. {
  8312. "name": "calledElement",
  8313. "type": "String",
  8314. "isAttr": true
  8315. }
  8316. ]
  8317. },
  8318. {
  8319. "name": "Task",
  8320. "superClass": [
  8321. "Activity",
  8322. "InteractionNode"
  8323. ]
  8324. },
  8325. {
  8326. "name": "SendTask",
  8327. "superClass": [
  8328. "Task"
  8329. ],
  8330. "properties": [
  8331. {
  8332. "name": "implementation",
  8333. "isAttr": true,
  8334. "type": "String"
  8335. },
  8336. {
  8337. "name": "operationRef",
  8338. "type": "Operation",
  8339. "isAttr": true,
  8340. "isReference": true
  8341. },
  8342. {
  8343. "name": "messageRef",
  8344. "type": "Message",
  8345. "isAttr": true,
  8346. "isReference": true
  8347. }
  8348. ]
  8349. },
  8350. {
  8351. "name": "ReceiveTask",
  8352. "superClass": [
  8353. "Task"
  8354. ],
  8355. "properties": [
  8356. {
  8357. "name": "implementation",
  8358. "isAttr": true,
  8359. "type": "String"
  8360. },
  8361. {
  8362. "name": "instantiate",
  8363. "default": false,
  8364. "isAttr": true,
  8365. "type": "Boolean"
  8366. },
  8367. {
  8368. "name": "operationRef",
  8369. "type": "Operation",
  8370. "isAttr": true,
  8371. "isReference": true
  8372. },
  8373. {
  8374. "name": "messageRef",
  8375. "type": "Message",
  8376. "isAttr": true,
  8377. "isReference": true
  8378. }
  8379. ]
  8380. },
  8381. {
  8382. "name": "ScriptTask",
  8383. "superClass": [
  8384. "Task"
  8385. ],
  8386. "properties": [
  8387. {
  8388. "name": "scriptFormat",
  8389. "isAttr": true,
  8390. "type": "String"
  8391. },
  8392. {
  8393. "name": "script",
  8394. "type": "String"
  8395. }
  8396. ]
  8397. },
  8398. {
  8399. "name": "BusinessRuleTask",
  8400. "superClass": [
  8401. "Task"
  8402. ],
  8403. "properties": [
  8404. {
  8405. "name": "implementation",
  8406. "isAttr": true,
  8407. "type": "String"
  8408. }
  8409. ]
  8410. },
  8411. {
  8412. "name": "AdHocSubProcess",
  8413. "superClass": [
  8414. "SubProcess"
  8415. ],
  8416. "properties": [
  8417. {
  8418. "name": "completionCondition",
  8419. "type": "Expression",
  8420. "xml": {
  8421. "serialize": "xsi:type"
  8422. }
  8423. },
  8424. {
  8425. "name": "ordering",
  8426. "type": "AdHocOrdering",
  8427. "isAttr": true
  8428. },
  8429. {
  8430. "name": "cancelRemainingInstances",
  8431. "default": true,
  8432. "isAttr": true,
  8433. "type": "Boolean"
  8434. }
  8435. ]
  8436. },
  8437. {
  8438. "name": "Transaction",
  8439. "superClass": [
  8440. "SubProcess"
  8441. ],
  8442. "properties": [
  8443. {
  8444. "name": "protocol",
  8445. "isAttr": true,
  8446. "type": "String"
  8447. },
  8448. {
  8449. "name": "method",
  8450. "isAttr": true,
  8451. "type": "String"
  8452. }
  8453. ]
  8454. },
  8455. {
  8456. "name": "GlobalScriptTask",
  8457. "superClass": [
  8458. "GlobalTask"
  8459. ],
  8460. "properties": [
  8461. {
  8462. "name": "scriptLanguage",
  8463. "isAttr": true,
  8464. "type": "String"
  8465. },
  8466. {
  8467. "name": "script",
  8468. "isAttr": true,
  8469. "type": "String"
  8470. }
  8471. ]
  8472. },
  8473. {
  8474. "name": "GlobalBusinessRuleTask",
  8475. "superClass": [
  8476. "GlobalTask"
  8477. ],
  8478. "properties": [
  8479. {
  8480. "name": "implementation",
  8481. "isAttr": true,
  8482. "type": "String"
  8483. }
  8484. ]
  8485. },
  8486. {
  8487. "name": "ComplexBehaviorDefinition",
  8488. "superClass": [
  8489. "BaseElement"
  8490. ],
  8491. "properties": [
  8492. {
  8493. "name": "condition",
  8494. "type": "FormalExpression"
  8495. },
  8496. {
  8497. "name": "event",
  8498. "type": "ImplicitThrowEvent"
  8499. }
  8500. ]
  8501. },
  8502. {
  8503. "name": "ResourceRole",
  8504. "superClass": [
  8505. "BaseElement"
  8506. ],
  8507. "properties": [
  8508. {
  8509. "name": "resourceRef",
  8510. "type": "Resource",
  8511. "isReference": true
  8512. },
  8513. {
  8514. "name": "resourceParameterBindings",
  8515. "type": "ResourceParameterBinding",
  8516. "isMany": true
  8517. },
  8518. {
  8519. "name": "resourceAssignmentExpression",
  8520. "type": "ResourceAssignmentExpression"
  8521. },
  8522. {
  8523. "name": "name",
  8524. "isAttr": true,
  8525. "type": "String"
  8526. }
  8527. ]
  8528. },
  8529. {
  8530. "name": "ResourceParameterBinding",
  8531. "properties": [
  8532. {
  8533. "name": "expression",
  8534. "type": "Expression",
  8535. "xml": {
  8536. "serialize": "xsi:type"
  8537. }
  8538. },
  8539. {
  8540. "name": "parameterRef",
  8541. "type": "ResourceParameter",
  8542. "isAttr": true,
  8543. "isReference": true
  8544. }
  8545. ]
  8546. },
  8547. {
  8548. "name": "ResourceAssignmentExpression",
  8549. "properties": [
  8550. {
  8551. "name": "expression",
  8552. "type": "Expression",
  8553. "xml": {
  8554. "serialize": "xsi:type"
  8555. }
  8556. }
  8557. ]
  8558. },
  8559. {
  8560. "name": "Import",
  8561. "properties": [
  8562. {
  8563. "name": "importType",
  8564. "isAttr": true,
  8565. "type": "String"
  8566. },
  8567. {
  8568. "name": "location",
  8569. "isAttr": true,
  8570. "type": "String"
  8571. },
  8572. {
  8573. "name": "namespace",
  8574. "isAttr": true,
  8575. "type": "String"
  8576. }
  8577. ]
  8578. },
  8579. {
  8580. "name": "Definitions",
  8581. "superClass": [
  8582. "BaseElement"
  8583. ],
  8584. "properties": [
  8585. {
  8586. "name": "name",
  8587. "isAttr": true,
  8588. "type": "String"
  8589. },
  8590. {
  8591. "name": "targetNamespace",
  8592. "isAttr": true,
  8593. "type": "String"
  8594. },
  8595. {
  8596. "name": "expressionLanguage",
  8597. "default": "http://www.w3.org/1999/XPath",
  8598. "isAttr": true,
  8599. "type": "String"
  8600. },
  8601. {
  8602. "name": "typeLanguage",
  8603. "default": "http://www.w3.org/2001/XMLSchema",
  8604. "isAttr": true,
  8605. "type": "String"
  8606. },
  8607. {
  8608. "name": "imports",
  8609. "type": "Import",
  8610. "isMany": true
  8611. },
  8612. {
  8613. "name": "extensions",
  8614. "type": "Extension",
  8615. "isMany": true
  8616. },
  8617. {
  8618. "name": "rootElements",
  8619. "type": "RootElement",
  8620. "isMany": true
  8621. },
  8622. {
  8623. "name": "diagrams",
  8624. "isMany": true,
  8625. "type": "bpmndi:BPMNDiagram"
  8626. },
  8627. {
  8628. "name": "exporter",
  8629. "isAttr": true,
  8630. "type": "String"
  8631. },
  8632. {
  8633. "name": "relationships",
  8634. "type": "Relationship",
  8635. "isMany": true
  8636. },
  8637. {
  8638. "name": "exporterVersion",
  8639. "isAttr": true,
  8640. "type": "String"
  8641. }
  8642. ]
  8643. }
  8644. ],
  8645. "emumerations": [
  8646. {
  8647. "name": "ProcessType",
  8648. "literalValues": [
  8649. {
  8650. "name": "None"
  8651. },
  8652. {
  8653. "name": "Public"
  8654. },
  8655. {
  8656. "name": "Private"
  8657. }
  8658. ]
  8659. },
  8660. {
  8661. "name": "GatewayDirection",
  8662. "literalValues": [
  8663. {
  8664. "name": "Unspecified"
  8665. },
  8666. {
  8667. "name": "Converging"
  8668. },
  8669. {
  8670. "name": "Diverging"
  8671. },
  8672. {
  8673. "name": "Mixed"
  8674. }
  8675. ]
  8676. },
  8677. {
  8678. "name": "EventBasedGatewayType",
  8679. "literalValues": [
  8680. {
  8681. "name": "Parallel"
  8682. },
  8683. {
  8684. "name": "Exclusive"
  8685. }
  8686. ]
  8687. },
  8688. {
  8689. "name": "RelationshipDirection",
  8690. "literalValues": [
  8691. {
  8692. "name": "None"
  8693. },
  8694. {
  8695. "name": "Forward"
  8696. },
  8697. {
  8698. "name": "Backward"
  8699. },
  8700. {
  8701. "name": "Both"
  8702. }
  8703. ]
  8704. },
  8705. {
  8706. "name": "ItemKind",
  8707. "literalValues": [
  8708. {
  8709. "name": "Physical"
  8710. },
  8711. {
  8712. "name": "Information"
  8713. }
  8714. ]
  8715. },
  8716. {
  8717. "name": "ChoreographyLoopType",
  8718. "literalValues": [
  8719. {
  8720. "name": "None"
  8721. },
  8722. {
  8723. "name": "Standard"
  8724. },
  8725. {
  8726. "name": "MultiInstanceSequential"
  8727. },
  8728. {
  8729. "name": "MultiInstanceParallel"
  8730. }
  8731. ]
  8732. },
  8733. {
  8734. "name": "AssociationDirection",
  8735. "literalValues": [
  8736. {
  8737. "name": "None"
  8738. },
  8739. {
  8740. "name": "One"
  8741. },
  8742. {
  8743. "name": "Both"
  8744. }
  8745. ]
  8746. },
  8747. {
  8748. "name": "MultiInstanceBehavior",
  8749. "literalValues": [
  8750. {
  8751. "name": "None"
  8752. },
  8753. {
  8754. "name": "One"
  8755. },
  8756. {
  8757. "name": "All"
  8758. },
  8759. {
  8760. "name": "Complex"
  8761. }
  8762. ]
  8763. },
  8764. {
  8765. "name": "AdHocOrdering",
  8766. "literalValues": [
  8767. {
  8768. "name": "Parallel"
  8769. },
  8770. {
  8771. "name": "Sequential"
  8772. }
  8773. ]
  8774. }
  8775. ],
  8776. "prefix": "bpmn",
  8777. "xml": {
  8778. "tagAlias": "lowerCase",
  8779. "typePrefix": "t"
  8780. }
  8781. }
  8782. },{}],32:[function(_dereq_,module,exports){
  8783. module.exports={
  8784. "name": "BPMNDI",
  8785. "uri": "http://www.omg.org/spec/BPMN/20100524/DI",
  8786. "types": [
  8787. {
  8788. "name": "BPMNDiagram",
  8789. "properties": [
  8790. {
  8791. "name": "plane",
  8792. "type": "BPMNPlane",
  8793. "redefines": "di:Diagram#rootElement"
  8794. },
  8795. {
  8796. "name": "labelStyle",
  8797. "type": "BPMNLabelStyle",
  8798. "isMany": true
  8799. }
  8800. ],
  8801. "superClass": [
  8802. "di:Diagram"
  8803. ]
  8804. },
  8805. {
  8806. "name": "BPMNPlane",
  8807. "properties": [
  8808. {
  8809. "name": "bpmnElement",
  8810. "isAttr": true,
  8811. "isReference": true,
  8812. "type": "bpmn:BaseElement",
  8813. "redefines": "di:DiagramElement#modelElement"
  8814. }
  8815. ],
  8816. "superClass": [
  8817. "di:Plane"
  8818. ]
  8819. },
  8820. {
  8821. "name": "BPMNShape",
  8822. "properties": [
  8823. {
  8824. "name": "bpmnElement",
  8825. "isAttr": true,
  8826. "isReference": true,
  8827. "type": "bpmn:BaseElement",
  8828. "redefines": "di:DiagramElement#modelElement"
  8829. },
  8830. {
  8831. "name": "isHorizontal",
  8832. "isAttr": true,
  8833. "type": "Boolean"
  8834. },
  8835. {
  8836. "name": "isExpanded",
  8837. "isAttr": true,
  8838. "type": "Boolean"
  8839. },
  8840. {
  8841. "name": "isMarkerVisible",
  8842. "isAttr": true,
  8843. "type": "Boolean"
  8844. },
  8845. {
  8846. "name": "label",
  8847. "type": "BPMNLabel"
  8848. },
  8849. {
  8850. "name": "isMessageVisible",
  8851. "isAttr": true,
  8852. "type": "Boolean"
  8853. },
  8854. {
  8855. "name": "participantBandKind",
  8856. "type": "ParticipantBandKind",
  8857. "isAttr": true
  8858. },
  8859. {
  8860. "name": "choreographyActivityShape",
  8861. "type": "BPMNShape",
  8862. "isAttr": true,
  8863. "isReference": true
  8864. }
  8865. ],
  8866. "superClass": [
  8867. "di:LabeledShape"
  8868. ]
  8869. },
  8870. {
  8871. "name": "BPMNEdge",
  8872. "properties": [
  8873. {
  8874. "name": "label",
  8875. "type": "BPMNLabel"
  8876. },
  8877. {
  8878. "name": "bpmnElement",
  8879. "isAttr": true,
  8880. "isReference": true,
  8881. "type": "bpmn:BaseElement",
  8882. "redefines": "di:DiagramElement#modelElement"
  8883. },
  8884. {
  8885. "name": "sourceElement",
  8886. "isAttr": true,
  8887. "isReference": true,
  8888. "type": "di:DiagramElement",
  8889. "redefines": "di:Edge#source"
  8890. },
  8891. {
  8892. "name": "targetElement",
  8893. "isAttr": true,
  8894. "isReference": true,
  8895. "type": "di:DiagramElement",
  8896. "redefines": "di:Edge#target"
  8897. },
  8898. {
  8899. "name": "messageVisibleKind",
  8900. "type": "MessageVisibleKind",
  8901. "isAttr": true,
  8902. "default": "initiating"
  8903. }
  8904. ],
  8905. "superClass": [
  8906. "di:LabeledEdge"
  8907. ]
  8908. },
  8909. {
  8910. "name": "BPMNLabel",
  8911. "properties": [
  8912. {
  8913. "name": "labelStyle",
  8914. "type": "BPMNLabelStyle",
  8915. "isAttr": true,
  8916. "isReference": true,
  8917. "redefines": "di:DiagramElement#style"
  8918. }
  8919. ],
  8920. "superClass": [
  8921. "di:Label"
  8922. ]
  8923. },
  8924. {
  8925. "name": "BPMNLabelStyle",
  8926. "properties": [
  8927. {
  8928. "name": "font",
  8929. "type": "dc:Font"
  8930. }
  8931. ],
  8932. "superClass": [
  8933. "di:Style"
  8934. ]
  8935. }
  8936. ],
  8937. "emumerations": [
  8938. {
  8939. "name": "ParticipantBandKind",
  8940. "literalValues": [
  8941. {
  8942. "name": "top_initiating"
  8943. },
  8944. {
  8945. "name": "middle_initiating"
  8946. },
  8947. {
  8948. "name": "bottom_initiating"
  8949. },
  8950. {
  8951. "name": "top_non_initiating"
  8952. },
  8953. {
  8954. "name": "middle_non_initiating"
  8955. },
  8956. {
  8957. "name": "bottom_non_initiating"
  8958. }
  8959. ]
  8960. },
  8961. {
  8962. "name": "MessageVisibleKind",
  8963. "literalValues": [
  8964. {
  8965. "name": "initiating"
  8966. },
  8967. {
  8968. "name": "non_initiating"
  8969. }
  8970. ]
  8971. }
  8972. ],
  8973. "associations": [],
  8974. "prefix": "bpmndi"
  8975. }
  8976. },{}],33:[function(_dereq_,module,exports){
  8977. module.exports={
  8978. "name": "DC",
  8979. "uri": "http://www.omg.org/spec/DD/20100524/DC",
  8980. "types": [
  8981. {
  8982. "name": "Boolean"
  8983. },
  8984. {
  8985. "name": "Integer"
  8986. },
  8987. {
  8988. "name": "Real"
  8989. },
  8990. {
  8991. "name": "String"
  8992. },
  8993. {
  8994. "name": "Font",
  8995. "properties": [
  8996. {
  8997. "name": "name",
  8998. "type": "String",
  8999. "isAttr": true
  9000. },
  9001. {
  9002. "name": "size",
  9003. "type": "Real",
  9004. "isAttr": true
  9005. },
  9006. {
  9007. "name": "isBold",
  9008. "type": "Boolean",
  9009. "isAttr": true
  9010. },
  9011. {
  9012. "name": "isItalic",
  9013. "type": "Boolean",
  9014. "isAttr": true
  9015. },
  9016. {
  9017. "name": "isUnderline",
  9018. "type": "Boolean",
  9019. "isAttr": true
  9020. },
  9021. {
  9022. "name": "isStrikeThrough",
  9023. "type": "Boolean",
  9024. "isAttr": true
  9025. }
  9026. ]
  9027. },
  9028. {
  9029. "name": "Point",
  9030. "properties": [
  9031. {
  9032. "name": "x",
  9033. "type": "Real",
  9034. "default": "0",
  9035. "isAttr": true
  9036. },
  9037. {
  9038. "name": "y",
  9039. "type": "Real",
  9040. "default": "0",
  9041. "isAttr": true
  9042. }
  9043. ]
  9044. },
  9045. {
  9046. "name": "Bounds",
  9047. "properties": [
  9048. {
  9049. "name": "x",
  9050. "type": "Real",
  9051. "default": "0",
  9052. "isAttr": true
  9053. },
  9054. {
  9055. "name": "y",
  9056. "type": "Real",
  9057. "default": "0",
  9058. "isAttr": true
  9059. },
  9060. {
  9061. "name": "width",
  9062. "type": "Real",
  9063. "isAttr": true
  9064. },
  9065. {
  9066. "name": "height",
  9067. "type": "Real",
  9068. "isAttr": true
  9069. }
  9070. ]
  9071. }
  9072. ],
  9073. "prefix": "dc",
  9074. "associations": []
  9075. }
  9076. },{}],34:[function(_dereq_,module,exports){
  9077. module.exports={
  9078. "name": "DI",
  9079. "uri": "http://www.omg.org/spec/DD/20100524/DI",
  9080. "types": [
  9081. {
  9082. "name": "DiagramElement",
  9083. "isAbstract": true,
  9084. "properties": [
  9085. {
  9086. "name": "extension",
  9087. "type": "Extension"
  9088. },
  9089. {
  9090. "name": "owningDiagram",
  9091. "type": "Diagram",
  9092. "isReadOnly": true,
  9093. "isVirtual": true,
  9094. "isReference": true
  9095. },
  9096. {
  9097. "name": "owningElement",
  9098. "type": "DiagramElement",
  9099. "isReadOnly": true,
  9100. "isVirtual": true,
  9101. "isReference": true
  9102. },
  9103. {
  9104. "name": "modelElement",
  9105. "isReadOnly": true,
  9106. "isVirtual": true,
  9107. "isReference": true,
  9108. "type": "Element"
  9109. },
  9110. {
  9111. "name": "style",
  9112. "type": "Style",
  9113. "isReadOnly": true,
  9114. "isVirtual": true,
  9115. "isReference": true
  9116. },
  9117. {
  9118. "name": "ownedElement",
  9119. "type": "DiagramElement",
  9120. "isReadOnly": true,
  9121. "isVirtual": true,
  9122. "isMany": true
  9123. }
  9124. ]
  9125. },
  9126. {
  9127. "name": "Node",
  9128. "isAbstract": true,
  9129. "superClass": [
  9130. "DiagramElement"
  9131. ]
  9132. },
  9133. {
  9134. "name": "Edge",
  9135. "isAbstract": true,
  9136. "superClass": [
  9137. "DiagramElement"
  9138. ],
  9139. "properties": [
  9140. {
  9141. "name": "source",
  9142. "type": "DiagramElement",
  9143. "isReadOnly": true,
  9144. "isVirtual": true,
  9145. "isReference": true
  9146. },
  9147. {
  9148. "name": "target",
  9149. "type": "DiagramElement",
  9150. "isReadOnly": true,
  9151. "isVirtual": true,
  9152. "isReference": true
  9153. },
  9154. {
  9155. "name": "waypoint",
  9156. "isUnique": false,
  9157. "isMany": true,
  9158. "type": "dc:Point",
  9159. "xml": {
  9160. "serialize": "xsi:type"
  9161. }
  9162. }
  9163. ]
  9164. },
  9165. {
  9166. "name": "Diagram",
  9167. "isAbstract": true,
  9168. "properties": [
  9169. {
  9170. "name": "rootElement",
  9171. "type": "DiagramElement",
  9172. "isReadOnly": true,
  9173. "isVirtual": true
  9174. },
  9175. {
  9176. "name": "name",
  9177. "isAttr": true,
  9178. "type": "String"
  9179. },
  9180. {
  9181. "name": "documentation",
  9182. "isAttr": true,
  9183. "type": "String"
  9184. },
  9185. {
  9186. "name": "resolution",
  9187. "isAttr": true,
  9188. "type": "Real"
  9189. },
  9190. {
  9191. "name": "ownedStyle",
  9192. "type": "Style",
  9193. "isReadOnly": true,
  9194. "isVirtual": true,
  9195. "isMany": true
  9196. }
  9197. ]
  9198. },
  9199. {
  9200. "name": "Shape",
  9201. "isAbstract": true,
  9202. "superClass": [
  9203. "Node"
  9204. ],
  9205. "properties": [
  9206. {
  9207. "name": "bounds",
  9208. "type": "dc:Bounds"
  9209. }
  9210. ]
  9211. },
  9212. {
  9213. "name": "Plane",
  9214. "isAbstract": true,
  9215. "superClass": [
  9216. "Node"
  9217. ],
  9218. "properties": [
  9219. {
  9220. "name": "planeElement",
  9221. "type": "DiagramElement",
  9222. "subsettedProperty": "DiagramElement-ownedElement",
  9223. "isMany": true
  9224. }
  9225. ]
  9226. },
  9227. {
  9228. "name": "LabeledEdge",
  9229. "isAbstract": true,
  9230. "superClass": [
  9231. "Edge"
  9232. ],
  9233. "properties": [
  9234. {
  9235. "name": "ownedLabel",
  9236. "type": "Label",
  9237. "isReadOnly": true,
  9238. "subsettedProperty": "DiagramElement-ownedElement",
  9239. "isVirtual": true,
  9240. "isMany": true
  9241. }
  9242. ]
  9243. },
  9244. {
  9245. "name": "LabeledShape",
  9246. "isAbstract": true,
  9247. "superClass": [
  9248. "Shape"
  9249. ],
  9250. "properties": [
  9251. {
  9252. "name": "ownedLabel",
  9253. "type": "Label",
  9254. "isReadOnly": true,
  9255. "subsettedProperty": "DiagramElement-ownedElement",
  9256. "isVirtual": true,
  9257. "isMany": true
  9258. }
  9259. ]
  9260. },
  9261. {
  9262. "name": "Label",
  9263. "isAbstract": true,
  9264. "superClass": [
  9265. "Node"
  9266. ],
  9267. "properties": [
  9268. {
  9269. "name": "bounds",
  9270. "type": "dc:Bounds"
  9271. }
  9272. ]
  9273. },
  9274. {
  9275. "name": "Style",
  9276. "isAbstract": true
  9277. },
  9278. {
  9279. "name": "Extension",
  9280. "properties": [
  9281. {
  9282. "name": "values",
  9283. "type": "Element",
  9284. "isMany": true
  9285. }
  9286. ]
  9287. }
  9288. ],
  9289. "associations": [],
  9290. "prefix": "di",
  9291. "xml": {
  9292. "tagAlias": "lowerCase"
  9293. }
  9294. }
  9295. },{}],35:[function(_dereq_,module,exports){
  9296. module.exports = _dereq_(36);
  9297. },{"36":36}],36:[function(_dereq_,module,exports){
  9298. 'use strict';
  9299. var di = _dereq_(69);
  9300. /**
  9301. * Bootstrap an injector from a list of modules, instantiating a number of default components
  9302. *
  9303. * @ignore
  9304. * @param {Array<didi.Module>} bootstrapModules
  9305. *
  9306. * @return {didi.Injector} a injector to use to access the components
  9307. */
  9308. function bootstrap(bootstrapModules) {
  9309. var modules = [],
  9310. components = [];
  9311. function hasModule(m) {
  9312. return modules.indexOf(m) >= 0;
  9313. }
  9314. function addModule(m) {
  9315. modules.push(m);
  9316. }
  9317. function visit(m) {
  9318. if (hasModule(m)) {
  9319. return;
  9320. }
  9321. (m.__depends__ || []).forEach(visit);
  9322. if (hasModule(m)) {
  9323. return;
  9324. }
  9325. addModule(m);
  9326. (m.__init__ || []).forEach(function(c) {
  9327. components.push(c);
  9328. });
  9329. }
  9330. bootstrapModules.forEach(visit);
  9331. var injector = new di.Injector(modules);
  9332. components.forEach(function(c) {
  9333. try {
  9334. // eagerly resolve component (fn or string)
  9335. injector[typeof c === 'string' ? 'get' : 'invoke'](c);
  9336. } catch (e) {
  9337. console.error('Failed to instantiate component');
  9338. console.error(e.stack);
  9339. throw e;
  9340. }
  9341. });
  9342. return injector;
  9343. }
  9344. /**
  9345. * Creates an injector from passed options.
  9346. *
  9347. * @ignore
  9348. * @param {Object} options
  9349. * @return {didi.Injector}
  9350. */
  9351. function createInjector(options) {
  9352. options = options || {};
  9353. var configModule = {
  9354. 'config': ['value', options]
  9355. };
  9356. var coreModule = _dereq_(42);
  9357. var modules = [ configModule, coreModule ].concat(options.modules || []);
  9358. return bootstrap(modules);
  9359. }
  9360. /**
  9361. * The main diagram-js entry point that bootstraps the diagram with the given
  9362. * configuration.
  9363. *
  9364. * To register extensions with the diagram, pass them as Array<didi.Module> to the constructor.
  9365. *
  9366. * @class djs.Diagram
  9367. * @memberOf djs
  9368. * @constructor
  9369. *
  9370. * @example
  9371. *
  9372. * <caption>Creating a plug-in that logs whenever a shape is added to the canvas.</caption>
  9373. *
  9374. * // plug-in implemenentation
  9375. * function MyLoggingPlugin(eventBus) {
  9376. * eventBus.on('shape.added', function(event) {
  9377. * console.log('shape ', event.shape, ' was added to the diagram');
  9378. * });
  9379. * }
  9380. *
  9381. * // export as module
  9382. * module.exports = {
  9383. * __init__: [ 'myLoggingPlugin' ],
  9384. * myLoggingPlugin: [ 'type', MyLoggingPlugin ]
  9385. * };
  9386. *
  9387. *
  9388. * // instantiate the diagram with the new plug-in
  9389. *
  9390. * var diagram = new Diagram({ modules: [ require('path-to-my-logging-plugin') ] });
  9391. *
  9392. * diagram.invoke([ 'canvas', function(canvas) {
  9393. * // add shape to drawing canvas
  9394. * canvas.addShape({ x: 10, y: 10 });
  9395. * });
  9396. *
  9397. * // 'shape ... was added to the diagram' logged to console
  9398. *
  9399. * @param {Object} options
  9400. * @param {Array<didi.Module>} [options.modules] external modules to instantiate with the diagram
  9401. * @param {didi.Injector} [injector] an (optional) injector to bootstrap the diagram with
  9402. */
  9403. function Diagram(options, injector) {
  9404. // create injector unless explicitly specified
  9405. this.injector = injector = injector || createInjector(options);
  9406. // API
  9407. /**
  9408. * Resolves a diagram service
  9409. *
  9410. * @method Diagram#get
  9411. *
  9412. * @param {String} name the name of the diagram service to be retrieved
  9413. * @param {Object} [locals] a number of locals to use to resolve certain dependencies
  9414. */
  9415. this.get = injector.get;
  9416. /**
  9417. * Executes a function into which diagram services are injected
  9418. *
  9419. * @method Diagram#invoke
  9420. *
  9421. * @param {Function|Object[]} fn the function to resolve
  9422. * @param {Object} locals a number of locals to use to resolve certain dependencies
  9423. */
  9424. this.invoke = injector.invoke;
  9425. // init
  9426. // indicate via event
  9427. /**
  9428. * An event indicating that all plug-ins are loaded.
  9429. *
  9430. * Use this event to fire other events to interested plug-ins
  9431. *
  9432. * @memberOf Diagram
  9433. *
  9434. * @event diagram.init
  9435. *
  9436. * @example
  9437. *
  9438. * eventBus.on('diagram.init', function() {
  9439. * eventBus.fire('my-custom-event', { foo: 'BAR' });
  9440. * });
  9441. *
  9442. * @type {Object}
  9443. */
  9444. this.get('eventBus').fire('diagram.init');
  9445. }
  9446. module.exports = Diagram;
  9447. /**
  9448. * Destroys the diagram
  9449. *
  9450. * @method Diagram#destroy
  9451. */
  9452. Diagram.prototype.destroy = function() {
  9453. this.get('eventBus').fire('diagram.destroy');
  9454. };
  9455. },{"42":42,"69":69}],37:[function(_dereq_,module,exports){
  9456. 'use strict';
  9457. var isNumber = _dereq_(162),
  9458. assign = _dereq_(168),
  9459. forEach = _dereq_(77),
  9460. every = _dereq_(74);
  9461. var Collections = _dereq_(57);
  9462. var Snap = _dereq_(67);
  9463. function round(number, resolution) {
  9464. return Math.round(number * resolution) / resolution;
  9465. }
  9466. function ensurePx(number) {
  9467. return isNumber(number) ? number + 'px' : number;
  9468. }
  9469. /**
  9470. * Creates a HTML container element for a SVG element with
  9471. * the given configuration
  9472. *
  9473. * @param {Object} options
  9474. * @return {HTMLElement} the container element
  9475. */
  9476. function createContainer(options) {
  9477. options = assign({}, { width: '100%', height: '100%' }, options);
  9478. var container = options.container || document.body;
  9479. // create a <div> around the svg element with the respective size
  9480. // this way we can always get the correct container size
  9481. // (this is impossible for <svg> elements at the moment)
  9482. var parent = document.createElement('div');
  9483. parent.setAttribute('class', 'djs-container');
  9484. assign(parent.style, {
  9485. position: 'relative',
  9486. overflow: 'hidden',
  9487. width: ensurePx(options.width),
  9488. height: ensurePx(options.height)
  9489. });
  9490. container.appendChild(parent);
  9491. return parent;
  9492. }
  9493. function createGroup(parent, cls) {
  9494. return parent.group().attr({ 'class' : cls });
  9495. }
  9496. var BASE_LAYER = 'base';
  9497. var REQUIRED_MODEL_ATTRS = {
  9498. shape: [ 'x', 'y', 'width', 'height' ],
  9499. connection: [ 'waypoints' ]
  9500. };
  9501. /**
  9502. * The main drawing canvas.
  9503. *
  9504. * @class
  9505. * @constructor
  9506. *
  9507. * @emits Canvas#canvas.init
  9508. *
  9509. * @param {Object} config
  9510. * @param {EventBus} eventBus
  9511. * @param {GraphicsFactory} graphicsFactory
  9512. * @param {ElementRegistry} elementRegistry
  9513. */
  9514. function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
  9515. this._eventBus = eventBus;
  9516. this._elementRegistry = elementRegistry;
  9517. this._graphicsFactory = graphicsFactory;
  9518. this._init(config || {});
  9519. }
  9520. Canvas.$inject = [ 'config.canvas', 'eventBus', 'graphicsFactory', 'elementRegistry' ];
  9521. module.exports = Canvas;
  9522. Canvas.prototype._init = function(config) {
  9523. // Creates a <svg> element that is wrapped into a <div>.
  9524. // This way we are always able to correctly figure out the size of the svg element
  9525. // by querying the parent node.
  9526. //
  9527. // (It is not possible to get the size of a svg element cross browser @ 2014-04-01)
  9528. //
  9529. // <div class="djs-container" style="width: {desired-width}, height: {desired-height}">
  9530. // <svg width="100%" height="100%">
  9531. // ...
  9532. // </svg>
  9533. // </div>
  9534. // html container
  9535. var eventBus = this._eventBus,
  9536. container = createContainer(config),
  9537. svg = Snap.createSnapAt('100%', '100%', container),
  9538. viewport = createGroup(svg, 'viewport'),
  9539. self = this;
  9540. this._container = container;
  9541. this._svg = svg;
  9542. this._viewport = viewport;
  9543. this._layers = {};
  9544. eventBus.on('diagram.init', function(event) {
  9545. /**
  9546. * An event indicating that the canvas is ready to be drawn on.
  9547. *
  9548. * @memberOf Canvas
  9549. *
  9550. * @event canvas.init
  9551. *
  9552. * @type {Object}
  9553. * @property {Snap<SVGSVGElement>} svg the created svg element
  9554. * @property {Snap<SVGGroup>} viewport the direct parent of diagram elements and shapes
  9555. */
  9556. eventBus.fire('canvas.init', { svg: svg, viewport: viewport });
  9557. });
  9558. eventBus.on('diagram.destroy', function() {
  9559. var parent = self._container.parentNode;
  9560. if (parent) {
  9561. parent.removeChild(container);
  9562. }
  9563. eventBus.fire('canvas.destroy', { svg: self._svg, viewport: self._viewport });
  9564. self._svg.remove();
  9565. self._svg = self._container = self._layers = self._viewport = null;
  9566. });
  9567. };
  9568. /**
  9569. * Returns the default layer on which
  9570. * all elements are drawn.
  9571. *
  9572. * @returns {Snap<SVGGroup>}
  9573. */
  9574. Canvas.prototype.getDefaultLayer = function() {
  9575. return this.getLayer(BASE_LAYER);
  9576. };
  9577. /**
  9578. * Returns a layer that is used to draw elements
  9579. * or annotations on it.
  9580. *
  9581. * @param {String} name
  9582. *
  9583. * @returns {Snap<SVGGroup>}
  9584. */
  9585. Canvas.prototype.getLayer = function(name) {
  9586. if (!name) {
  9587. throw new Error('must specify a name');
  9588. }
  9589. var layer = this._layers[name];
  9590. if (!layer) {
  9591. layer = this._layers[name] = createGroup(this._viewport, 'layer-' + name);
  9592. }
  9593. return layer;
  9594. };
  9595. /**
  9596. * Returns the html element that encloses the
  9597. * drawing canvas.
  9598. *
  9599. * @return {DOMNode}
  9600. */
  9601. Canvas.prototype.getContainer = function() {
  9602. return this._container;
  9603. };
  9604. /////////////// markers ///////////////////////////////////
  9605. Canvas.prototype._updateMarker = function(element, marker, add) {
  9606. var container;
  9607. if (!element.id) {
  9608. element = this._elementRegistry.get(element);
  9609. }
  9610. // we need to access all
  9611. container = this._elementRegistry._elements[element.id];
  9612. if (!container) {
  9613. return;
  9614. }
  9615. forEach([ container.gfx, container.secondaryGfx ], function(gfx) {
  9616. if (gfx) {
  9617. // invoke either addClass or removeClass based on mode
  9618. gfx[add ? 'addClass' : 'removeClass'](marker);
  9619. }
  9620. });
  9621. /**
  9622. * An event indicating that a marker has been updated for an element
  9623. *
  9624. * @event element.marker.update
  9625. * @type {Object}
  9626. * @property {djs.model.Element} element the shape
  9627. * @property {Object} gfx the graphical representation of the shape
  9628. * @property {String} marker
  9629. * @property {Boolean} add true if the marker was added, false if it got removed
  9630. */
  9631. this._eventBus.fire('element.marker.update', { element: element, gfx: container.gfx, marker: marker, add: !!add });
  9632. };
  9633. /**
  9634. * Adds a marker to an element (basically a css class).
  9635. *
  9636. * Fires the element.marker.update event, making it possible to
  9637. * integrate extension into the marker life-cycle, too.
  9638. *
  9639. * @example
  9640. * canvas.addMarker('foo', 'some-marker');
  9641. *
  9642. * var fooGfx = canvas.getGraphics('foo');
  9643. *
  9644. * fooGfx; // <g class="... some-marker"> ... </g>
  9645. *
  9646. * @param {String|djs.model.Base} element
  9647. * @param {String} marker
  9648. */
  9649. Canvas.prototype.addMarker = function(element, marker) {
  9650. this._updateMarker(element, marker, true);
  9651. };
  9652. /**
  9653. * Remove a marker from an element.
  9654. *
  9655. * Fires the element.marker.update event, making it possible to
  9656. * integrate extension into the marker life-cycle, too.
  9657. *
  9658. * @param {String|djs.model.Base} element
  9659. * @param {String} marker
  9660. */
  9661. Canvas.prototype.removeMarker = function(element, marker) {
  9662. this._updateMarker(element, marker, false);
  9663. };
  9664. /**
  9665. * Check the existence of a marker on element.
  9666. *
  9667. * @param {String|djs.model.Base} element
  9668. * @param {String} marker
  9669. */
  9670. Canvas.prototype.hasMarker = function(element, marker) {
  9671. if (!element.id) {
  9672. element = this._elementRegistry.get(element);
  9673. }
  9674. var gfx = this.getGraphics(element);
  9675. return gfx && gfx.hasClass(marker);
  9676. };
  9677. /**
  9678. * Toggles a marker on an element.
  9679. *
  9680. * Fires the element.marker.update event, making it possible to
  9681. * integrate extension into the marker life-cycle, too.
  9682. *
  9683. * @param {String|djs.model.Base} element
  9684. * @param {String} marker
  9685. */
  9686. Canvas.prototype.toggleMarker = function(element, marker) {
  9687. if(this.hasMarker(element, marker)) {
  9688. this.removeMarker(element, marker);
  9689. } else {
  9690. this.addMarker(element, marker);
  9691. }
  9692. };
  9693. Canvas.prototype.getRootElement = function() {
  9694. if (!this._rootElement) {
  9695. this.setRootElement({ id: '__implicitroot' });
  9696. }
  9697. return this._rootElement;
  9698. };
  9699. //////////////// root element handling ///////////////////////////
  9700. /**
  9701. * Sets a given element as the new root element for the canvas
  9702. * and returns the new root element.
  9703. *
  9704. * @param {Object|djs.model.Root} element
  9705. * @param {Boolean} [override] whether to override the current root element, if any
  9706. *
  9707. * @return {Object|djs.model.Root} new root element
  9708. */
  9709. Canvas.prototype.setRootElement = function(element, override) {
  9710. this._ensureValid('root', element);
  9711. var oldRoot = this._rootElement,
  9712. elementRegistry = this._elementRegistry,
  9713. eventBus = this._eventBus;
  9714. if (oldRoot) {
  9715. if (!override) {
  9716. throw new Error('rootElement already set, need to specify override');
  9717. }
  9718. // simulate element remove event sequence
  9719. eventBus.fire('root.remove', { element: oldRoot });
  9720. eventBus.fire('root.removed', { element: oldRoot });
  9721. elementRegistry.remove(oldRoot);
  9722. }
  9723. var gfx = this.getDefaultLayer();
  9724. // resemble element add event sequence
  9725. eventBus.fire('root.add', { element: element });
  9726. elementRegistry.add(element, gfx, this._svg);
  9727. eventBus.fire('root.added', { element: element, gfx: gfx });
  9728. this._rootElement = element;
  9729. return element;
  9730. };
  9731. ///////////// add functionality ///////////////////////////////
  9732. Canvas.prototype._ensureValid = function(type, element) {
  9733. if (!element.id) {
  9734. throw new Error('element must have an id');
  9735. }
  9736. if (this._elementRegistry.get(element.id)) {
  9737. throw new Error('element with id ' + element.id + ' already exists');
  9738. }
  9739. var requiredAttrs = REQUIRED_MODEL_ATTRS[type];
  9740. var valid = every(requiredAttrs, function(attr) {
  9741. return typeof element[attr] !== 'undefined';
  9742. });
  9743. if (!valid) {
  9744. throw new Error(
  9745. 'must supply { ' + requiredAttrs.join(', ') + ' } with ' + type);
  9746. }
  9747. };
  9748. Canvas.prototype._setParent = function(element, parent, idx) {
  9749. Collections.add(parent.children, element, idx);
  9750. element.parent = parent;
  9751. };
  9752. /**
  9753. * Adds an element to the canvas.
  9754. *
  9755. * This wires the parent <-> child relationship between the element and
  9756. * a explicitly specified parent or an implicit root element.
  9757. *
  9758. * During add it emits the events
  9759. *
  9760. * * <{type}.add> (element, parent)
  9761. * * <{type}.added> (element, gfx)
  9762. *
  9763. * Extensions may hook into these events to perform their magic.
  9764. *
  9765. * @param {String} type
  9766. * @param {Object|djs.model.Base} element
  9767. * @param {Object|djs.model.Base} [parent]
  9768. *
  9769. * @return {Object|djs.model.Base} the added element
  9770. */
  9771. Canvas.prototype._addElement = function(type, element, parent) {
  9772. parent = parent || this.getRootElement();
  9773. var eventBus = this._eventBus,
  9774. graphicsFactory = this._graphicsFactory,
  9775. idx;
  9776. this._ensureValid(type, element);
  9777. eventBus.fire(type + '.add', { element: element, parent: parent });
  9778. this._setParent(element, parent, idx);
  9779. // create graphics
  9780. var gfx = graphicsFactory.create(type, element);
  9781. this._elementRegistry.add(element, gfx);
  9782. // update its visual
  9783. graphicsFactory.update(type, element, gfx);
  9784. eventBus.fire(type + '.added', { element: element, gfx: gfx });
  9785. return element;
  9786. };
  9787. /**
  9788. * Adds a shape to the canvas
  9789. *
  9790. * @param {Object|djs.model.Shape} shape to add to the diagram
  9791. * @param {djs.model.Base} [parent]
  9792. *
  9793. * @return {djs.model.Shape} the added shape
  9794. */
  9795. Canvas.prototype.addShape = function(shape, parent) {
  9796. return this._addElement('shape', shape, parent);
  9797. };
  9798. /**
  9799. * Adds a connection to the canvas
  9800. *
  9801. * @param {Object|djs.model.Connection} connection to add to the diagram
  9802. * @param {djs.model.Base} [parent]
  9803. *
  9804. * @return {djs.model.Connection} the added connection
  9805. */
  9806. Canvas.prototype.addConnection = function(connection, parent) {
  9807. return this._addElement('connection', connection, parent);
  9808. };
  9809. /**
  9810. * Internal remove element
  9811. */
  9812. Canvas.prototype._removeElement = function(element, type) {
  9813. var elementRegistry = this._elementRegistry,
  9814. graphicsFactory = this._graphicsFactory,
  9815. eventBus = this._eventBus;
  9816. element = elementRegistry.get(element.id || element);
  9817. if (!element) {
  9818. // element was removed already
  9819. return;
  9820. }
  9821. eventBus.fire(type + '.remove', { element: element });
  9822. graphicsFactory.remove(element);
  9823. // unset parent <-> child relationship
  9824. Collections.remove(element.parent && element.parent.children, element);
  9825. element.parent = null;
  9826. eventBus.fire(type + '.removed', { element: element });
  9827. elementRegistry.remove(element);
  9828. return element;
  9829. };
  9830. /**
  9831. * Removes a shape from the canvas
  9832. *
  9833. * @param {String|djs.model.Shape} shape or shape id to be removed
  9834. *
  9835. * @return {djs.model.Shape} the removed shape
  9836. */
  9837. Canvas.prototype.removeShape = function(shape) {
  9838. /**
  9839. * An event indicating that a shape is about to be removed from the canvas.
  9840. *
  9841. * @memberOf Canvas
  9842. *
  9843. * @event shape.remove
  9844. * @type {Object}
  9845. * @property {djs.model.Shape} element the shape descriptor
  9846. * @property {Object} gfx the graphical representation of the shape
  9847. */
  9848. /**
  9849. * An event indicating that a shape has been removed from the canvas.
  9850. *
  9851. * @memberOf Canvas
  9852. *
  9853. * @event shape.removed
  9854. * @type {Object}
  9855. * @property {djs.model.Shape} element the shape descriptor
  9856. * @property {Object} gfx the graphical representation of the shape
  9857. */
  9858. return this._removeElement(shape, 'shape');
  9859. };
  9860. /**
  9861. * Removes a connection from the canvas
  9862. *
  9863. * @param {String|djs.model.Connection} connection or connection id to be removed
  9864. *
  9865. * @return {djs.model.Connection} the removed connection
  9866. */
  9867. Canvas.prototype.removeConnection = function(connection) {
  9868. /**
  9869. * An event indicating that a connection is about to be removed from the canvas.
  9870. *
  9871. * @memberOf Canvas
  9872. *
  9873. * @event connection.remove
  9874. * @type {Object}
  9875. * @property {djs.model.Connection} element the connection descriptor
  9876. * @property {Object} gfx the graphical representation of the connection
  9877. */
  9878. /**
  9879. * An event indicating that a connection has been removed from the canvas.
  9880. *
  9881. * @memberOf Canvas
  9882. *
  9883. * @event connection.removed
  9884. * @type {Object}
  9885. * @property {djs.model.Connection} element the connection descriptor
  9886. * @property {Object} gfx the graphical representation of the connection
  9887. */
  9888. return this._removeElement(connection, 'connection');
  9889. };
  9890. /**
  9891. * Sends a shape to the front.
  9892. *
  9893. * This method takes parent / child relationships between shapes into account
  9894. * and makes sure that children are properly handled, too.
  9895. *
  9896. * @param {djs.model.Shape} shape descriptor of the shape to be sent to front
  9897. * @param {boolean} [bubble=true] whether to send parent shapes to front, too
  9898. */
  9899. Canvas.prototype.sendToFront = function(shape, bubble) {
  9900. if (bubble !== false) {
  9901. bubble = true;
  9902. }
  9903. if (bubble && shape.parent) {
  9904. this.sendToFront(shape.parent);
  9905. }
  9906. forEach(shape.children, function(child) {
  9907. this.sendToFront(child, false);
  9908. }, this);
  9909. var gfx = this.getGraphics(shape),
  9910. gfxParent = gfx.parent();
  9911. gfx.remove().appendTo(gfxParent);
  9912. };
  9913. /**
  9914. * Return the graphical object underlaying a certain diagram element
  9915. *
  9916. * @param {String|djs.model.Base} element descriptor of the element
  9917. * @param {Boolean} [secondary=false] whether to return the secondary connected element
  9918. *
  9919. * @return {SVGElement}
  9920. */
  9921. Canvas.prototype.getGraphics = function(element, secondary) {
  9922. return this._elementRegistry.getGraphics(element, secondary);
  9923. };
  9924. Canvas.prototype._fireViewboxChange = function() {
  9925. this._eventBus.fire('canvas.viewbox.changed', { viewbox: this.viewbox(false) });
  9926. };
  9927. /**
  9928. * Gets or sets the view box of the canvas, i.e. the area that is currently displayed
  9929. *
  9930. * @param {Object} [box] the new view box to set
  9931. * @param {Number} box.x the top left X coordinate of the canvas visible in view box
  9932. * @param {Number} box.y the top left Y coordinate of the canvas visible in view box
  9933. * @param {Number} box.width the visible width
  9934. * @param {Number} box.height
  9935. *
  9936. * @example
  9937. *
  9938. * canvas.viewbox({ x: 100, y: 100, width: 500, height: 500 })
  9939. *
  9940. * // sets the visible area of the diagram to (100|100) -> (600|100)
  9941. * // and and scales it according to the diagram width
  9942. *
  9943. * @return {Object} the current view box
  9944. */
  9945. Canvas.prototype.viewbox = function(box) {
  9946. if (box === undefined && this._cachedViewbox) {
  9947. return this._cachedViewbox;
  9948. }
  9949. var viewport = this._viewport,
  9950. innerBox,
  9951. outerBox = this.getSize(),
  9952. matrix,
  9953. scale,
  9954. x, y;
  9955. if (!box) {
  9956. // compute the inner box based on the
  9957. // diagrams default layer. This allows us to exclude
  9958. // external components, such as overlays
  9959. innerBox = this.getDefaultLayer().getBBox(true);
  9960. matrix = viewport.transform().localMatrix;
  9961. scale = round(matrix.a, 1000);
  9962. x = round(-matrix.e || 0, 1000);
  9963. y = round(-matrix.f || 0, 1000);
  9964. box = this._cachedViewbox = {
  9965. x: x ? x / scale : 0,
  9966. y: y ? y / scale : 0,
  9967. width: outerBox.width / scale,
  9968. height: outerBox.height / scale,
  9969. scale: scale,
  9970. inner: {
  9971. width: innerBox.width,
  9972. height: innerBox.height,
  9973. x: innerBox.x,
  9974. y: innerBox.y
  9975. },
  9976. outer: outerBox
  9977. };
  9978. return box;
  9979. } else {
  9980. scale = Math.min(outerBox.width / box.width, outerBox.height / box.height);
  9981. matrix = new Snap.Matrix().scale(scale).translate(-box.x, -box.y);
  9982. viewport.transform(matrix);
  9983. this._fireViewboxChange();
  9984. }
  9985. return box;
  9986. };
  9987. /**
  9988. * Gets or sets the scroll of the canvas.
  9989. *
  9990. * @param {Object} [delta] the new scroll to apply.
  9991. *
  9992. * @param {Number} [delta.dx]
  9993. * @param {Number} [delta.dy]
  9994. */
  9995. Canvas.prototype.scroll = function(delta) {
  9996. var node = this._viewport.node;
  9997. var matrix = node.getCTM();
  9998. if (delta) {
  9999. delta = assign({ dx: 0, dy: 0 }, delta || {});
  10000. matrix = this._svg.node.createSVGMatrix().translate(delta.dx, delta.dy).multiply(matrix);
  10001. setCTM(node, matrix);
  10002. this._fireViewboxChange();
  10003. }
  10004. return { x: matrix.e, y: matrix.f };
  10005. };
  10006. /**
  10007. * Gets or sets the current zoom of the canvas, optionally zooming to the specified position.
  10008. *
  10009. * @param {String|Number} [newScale] the new zoom level, either a number, i.e. 0.9,
  10010. * or `fit-viewport` to adjust the size to fit the current viewport
  10011. * @param {String|Point} [center] the reference point { x: .., y: ..} to zoom to, 'auto' to zoom into mid or null
  10012. *
  10013. * @return {Number} the current scale
  10014. */
  10015. Canvas.prototype.zoom = function(newScale, center) {
  10016. if (newScale === 'fit-viewport') {
  10017. return this._fitViewport(center);
  10018. }
  10019. var vbox = this.viewbox(),
  10020. outer,
  10021. matrix;
  10022. if (newScale === undefined) {
  10023. return vbox.scale;
  10024. }
  10025. if (typeof center !== 'object') {
  10026. outer = vbox.outer;
  10027. center = {
  10028. x: outer.width / 2,
  10029. y: outer.height / 2
  10030. };
  10031. }
  10032. matrix = this._setZoom(newScale, center);
  10033. this._fireViewboxChange();
  10034. return round(matrix.a, 1000);
  10035. };
  10036. function setCTM(node, m) {
  10037. var mstr = 'matrix(' + m.a + ',' + m.b + ',' + m.c + ',' + m.d + ',' + m.e + ',' + m.f + ')';
  10038. node.setAttribute('transform', mstr);
  10039. }
  10040. Canvas.prototype._fitViewport = function(center) {
  10041. var vbox = this.viewbox(),
  10042. outer = vbox.outer,
  10043. inner = vbox.inner,
  10044. newScale,
  10045. newViewbox;
  10046. // display the complete diagram without zooming in.
  10047. // instead of relying on internal zoom, we perform a
  10048. // hard reset on the canvas viewbox to realize this
  10049. //
  10050. // if diagram does not need to be zoomed in, we focus it around
  10051. // the diagram origin instead
  10052. if (inner.x >= 0 &&
  10053. inner.y >= 0 &&
  10054. inner.x + inner.width <= outer.width &&
  10055. inner.y + inner.height <= outer.height &&
  10056. !center) {
  10057. newViewbox = {
  10058. x: 0,
  10059. y: 0,
  10060. width: Math.max(inner.width + inner.x, outer.width),
  10061. height: Math.max(inner.height + inner.y, outer.height)
  10062. };
  10063. } else {
  10064. newScale = Math.min(1, outer.width / inner.width, outer.height / inner.height);
  10065. newViewbox = {
  10066. x: inner.x + (center ? inner.width / 2 - outer.width / newScale / 2 : 0),
  10067. y: inner.y + (center ? inner.height / 2 - outer.height / newScale / 2 : 0),
  10068. width: outer.width / newScale,
  10069. height: outer.height / newScale
  10070. };
  10071. }
  10072. this.viewbox(newViewbox);
  10073. return this.viewbox().scale;
  10074. };
  10075. Canvas.prototype._setZoom = function(scale, center) {
  10076. var svg = this._svg.node,
  10077. viewport = this._viewport.node;
  10078. var matrix = svg.createSVGMatrix();
  10079. var point = svg.createSVGPoint();
  10080. var centerPoint,
  10081. originalPoint,
  10082. currentMatrix,
  10083. scaleMatrix,
  10084. newMatrix;
  10085. currentMatrix = viewport.getCTM();
  10086. var currentScale = currentMatrix.a;
  10087. if (center) {
  10088. centerPoint = assign(point, center);
  10089. // revert applied viewport transformations
  10090. originalPoint = centerPoint.matrixTransform(currentMatrix.inverse());
  10091. // create scale matrix
  10092. scaleMatrix = matrix
  10093. .translate(originalPoint.x, originalPoint.y)
  10094. .scale(1 / currentScale * scale)
  10095. .translate(-originalPoint.x, -originalPoint.y);
  10096. newMatrix = currentMatrix.multiply(scaleMatrix);
  10097. } else {
  10098. newMatrix = matrix.scale(scale);
  10099. }
  10100. setCTM(this._viewport.node, newMatrix);
  10101. return newMatrix;
  10102. };
  10103. /**
  10104. * Returns the size of the canvas
  10105. *
  10106. * @return {Dimensions}
  10107. */
  10108. Canvas.prototype.getSize = function () {
  10109. return {
  10110. width: this._container.clientWidth,
  10111. height: this._container.clientHeight
  10112. };
  10113. };
  10114. /**
  10115. * Return the absolute bounding box for the given element
  10116. *
  10117. * The absolute bounding box may be used to display overlays in the
  10118. * callers (browser) coordinate system rather than the zoomed in/out
  10119. * canvas coordinates.
  10120. *
  10121. * @param {ElementDescriptor} element
  10122. * @return {Bounds} the absolute bounding box
  10123. */
  10124. Canvas.prototype.getAbsoluteBBox = function(element) {
  10125. var vbox = this.viewbox();
  10126. var bbox;
  10127. // connection
  10128. // use svg bbox
  10129. if (element.waypoints) {
  10130. var gfx = this.getGraphics(element);
  10131. var transformBBox = gfx.getBBox(true);
  10132. bbox = gfx.getBBox();
  10133. bbox.x -= transformBBox.x;
  10134. bbox.y -= transformBBox.y;
  10135. bbox.width += 2 * transformBBox.x;
  10136. bbox.height += 2 * transformBBox.y;
  10137. }
  10138. // shapes
  10139. // use data
  10140. else {
  10141. bbox = element;
  10142. }
  10143. var x = bbox.x * vbox.scale - vbox.x * vbox.scale;
  10144. var y = bbox.y * vbox.scale - vbox.y * vbox.scale;
  10145. var width = bbox.width * vbox.scale;
  10146. var height = bbox.height * vbox.scale;
  10147. return {
  10148. x: x,
  10149. y: y,
  10150. width: width,
  10151. height: height
  10152. };
  10153. };
  10154. },{"162":162,"168":168,"57":57,"67":67,"74":74,"77":77}],38:[function(_dereq_,module,exports){
  10155. 'use strict';
  10156. var Model = _dereq_(56);
  10157. /**
  10158. * A factory for diagram-js shapes
  10159. */
  10160. function ElementFactory() {
  10161. this._uid = 12;
  10162. }
  10163. module.exports = ElementFactory;
  10164. ElementFactory.prototype.createRoot = function(attrs) {
  10165. return this.create('root', attrs);
  10166. };
  10167. ElementFactory.prototype.createLabel = function(attrs) {
  10168. return this.create('label', attrs);
  10169. };
  10170. ElementFactory.prototype.createShape = function(attrs) {
  10171. return this.create('shape', attrs);
  10172. };
  10173. ElementFactory.prototype.createConnection = function(attrs) {
  10174. return this.create('connection', attrs);
  10175. };
  10176. /**
  10177. * Create a model element with the given type and
  10178. * a number of pre-set attributes.
  10179. *
  10180. * @param {String} type
  10181. * @param {Object} attrs
  10182. * @return {djs.model.Base} the newly created model instance
  10183. */
  10184. ElementFactory.prototype.create = function(type, attrs) {
  10185. attrs = attrs || {};
  10186. if (!attrs.id) {
  10187. attrs.id = type + '_' + (this._uid++);
  10188. }
  10189. return Model.create(type, attrs);
  10190. };
  10191. },{"56":56}],39:[function(_dereq_,module,exports){
  10192. 'use strict';
  10193. var ELEMENT_ID = 'data-element-id';
  10194. /**
  10195. * @class
  10196. *
  10197. * A registry that keeps track of all shapes in the diagram.
  10198. */
  10199. function ElementRegistry() {
  10200. this._elements = {};
  10201. }
  10202. module.exports = ElementRegistry;
  10203. /**
  10204. * Register a pair of (element, gfx, (secondaryGfx)).
  10205. *
  10206. * @param {djs.model.Base} element
  10207. * @param {Snap<SVGElement>} gfx
  10208. * @param {Snap<SVGElement>} [secondaryGfx] optional other element to register, too
  10209. */
  10210. ElementRegistry.prototype.add = function(element, gfx, secondaryGfx) {
  10211. var id = element.id;
  10212. this._validateId(id);
  10213. // associate dom node with element
  10214. gfx.attr(ELEMENT_ID, id);
  10215. if (secondaryGfx) {
  10216. secondaryGfx.attr(ELEMENT_ID, id);
  10217. }
  10218. this._elements[id] = { element: element, gfx: gfx, secondaryGfx: secondaryGfx };
  10219. };
  10220. /**
  10221. * Removes an element from the registry.
  10222. *
  10223. * @param {djs.model.Base} element
  10224. */
  10225. ElementRegistry.prototype.remove = function(element) {
  10226. var elements = this._elements,
  10227. id = element.id || element,
  10228. container = id && elements[id];
  10229. if (container) {
  10230. // unset element id on gfx
  10231. container.gfx.attr(ELEMENT_ID, null);
  10232. if (container.secondaryGfx) {
  10233. container.secondaryGfx.attr(ELEMENT_ID, null);
  10234. }
  10235. delete elements[id];
  10236. }
  10237. };
  10238. /**
  10239. * Update the id of an element
  10240. *
  10241. * @param {djs.model.Base} element
  10242. * @param {String} newId
  10243. */
  10244. ElementRegistry.prototype.updateId = function(element, newId) {
  10245. this._validateId(newId);
  10246. if (typeof element === 'string') {
  10247. element = this.get(element);
  10248. }
  10249. var gfx = this.getGraphics(element),
  10250. secondaryGfx = this.getGraphics(element, true);
  10251. this.remove(element);
  10252. element.id = newId;
  10253. this.add(element, gfx, secondaryGfx);
  10254. };
  10255. /**
  10256. * Return the model element for a given id or graphics.
  10257. *
  10258. * @example
  10259. *
  10260. * elementRegistry.get('SomeElementId_1');
  10261. * elementRegistry.get(gfx);
  10262. *
  10263. *
  10264. * @param {String|SVGElement} filter for selecting the element
  10265. *
  10266. * @return {djs.model.Base}
  10267. */
  10268. ElementRegistry.prototype.get = function(filter) {
  10269. var id;
  10270. if (typeof filter === 'string') {
  10271. id = filter;
  10272. } else {
  10273. id = filter && filter.attr(ELEMENT_ID);
  10274. }
  10275. var container = this._elements[id];
  10276. return container && container.element;
  10277. };
  10278. /**
  10279. * Return all elements that match a given filter function.
  10280. *
  10281. * @param {Function} fn
  10282. *
  10283. * @return {Array<djs.model.Base>}
  10284. */
  10285. ElementRegistry.prototype.filter = function(fn) {
  10286. var filtered = [];
  10287. this.forEach(function(element, gfx) {
  10288. if(fn(element, gfx)) {
  10289. filtered.push(element);
  10290. }
  10291. });
  10292. return filtered;
  10293. };
  10294. /**
  10295. * Return all rendered model elements.
  10296. *
  10297. * @return {Array<djs.model.Base>}
  10298. */
  10299. ElementRegistry.prototype.getAll = function() {
  10300. return this.filter(function(e) { return e; });
  10301. };
  10302. /**
  10303. * Iterate over all diagram elements.
  10304. *
  10305. * @param {Function} fn
  10306. */
  10307. ElementRegistry.prototype.forEach = function(fn) {
  10308. var map = this._elements;
  10309. Object.keys(map).forEach(function(id) {
  10310. var container = map[id],
  10311. element = container.element,
  10312. gfx = container.gfx;
  10313. return fn(element, gfx);
  10314. });
  10315. };
  10316. /**
  10317. * Return the graphical representation of an element or its id.
  10318. *
  10319. * @example
  10320. * elementRegistry.getGraphics('SomeElementId_1');
  10321. * elementRegistry.getGraphics(rootElement); // <g ...>
  10322. *
  10323. * elementRegistry.getGraphics(rootElement, true); // <svg ...>
  10324. *
  10325. *
  10326. * @param {String|djs.model.Base} filter
  10327. * @param {Boolean} [secondary=false] whether to return the secondary connected element
  10328. *
  10329. * @return {SVGElement}
  10330. */
  10331. ElementRegistry.prototype.getGraphics = function(filter, secondary) {
  10332. var id = filter.id || filter;
  10333. var container = this._elements[id];
  10334. return container && (secondary ? container.secondaryGfx : container.gfx);
  10335. };
  10336. /**
  10337. * Validate the suitability of the given id and signals a problem
  10338. * with an exception.
  10339. *
  10340. * @param {String} id
  10341. *
  10342. * @throws {Error} if id is empty or already assigned
  10343. */
  10344. ElementRegistry.prototype._validateId = function(id) {
  10345. if (!id) {
  10346. throw new Error('element must have an id');
  10347. }
  10348. if (this._elements[id]) {
  10349. throw new Error('element with id ' + id + ' already added');
  10350. }
  10351. };
  10352. },{}],40:[function(_dereq_,module,exports){
  10353. 'use strict';
  10354. var isFunction = _dereq_(160),
  10355. isArray = _dereq_(159),
  10356. isNumber = _dereq_(162),
  10357. assign = _dereq_(168);
  10358. var DEFAULT_PRIORITY = 1000;
  10359. /**
  10360. * A general purpose event bus.
  10361. *
  10362. * This component is used to communicate across a diagram instance.
  10363. * Other parts of a diagram can use it to listen to and broadcast events.
  10364. *
  10365. *
  10366. * ## Registering for Events
  10367. *
  10368. * The event bus provides the {@link EventBus#on} and {@link EventBus#once}
  10369. * methods to register for events. {@link EventBus#off} can be used to
  10370. * remove event registrations. Listeners receive an instance of {@link Event}
  10371. * as the first argument. It allows them to hook into the event execution.
  10372. *
  10373. * ```javascript
  10374. *
  10375. * // listen for event
  10376. * eventBus.on('foo', function(event) {
  10377. *
  10378. * // access event type
  10379. * event.type; // 'foo'
  10380. *
  10381. * // stop propagation to other listeners
  10382. * event.stopPropagation();
  10383. *
  10384. * // prevent event default
  10385. * event.preventDefault();
  10386. * });
  10387. *
  10388. * // listen for event with custom payload
  10389. * eventBus.on('bar', function(event, payload) {
  10390. * console.log(payload);
  10391. * });
  10392. *
  10393. * // listen for event returning value
  10394. * eventBus.on('foobar', function(event) {
  10395. *
  10396. * // stop event propagation + prevent default
  10397. * return false;
  10398. *
  10399. * // stop event propagation + return custom result
  10400. * return {
  10401. * complex: 'listening result'
  10402. * };
  10403. * });
  10404. *
  10405. *
  10406. * // listen with custom priority (default=1000, higher is better)
  10407. * eventBus.on('priorityfoo', 1500, function(event) {
  10408. * console.log('invoked first!');
  10409. * });
  10410. * ```
  10411. *
  10412. *
  10413. * ## Emitting Events
  10414. *
  10415. * Events can be emitted via the event bus using {@link EventBus#fire}.
  10416. *
  10417. * ```javascript
  10418. *
  10419. * // false indicates that the default action
  10420. * // was prevented by listeners
  10421. * if (eventBus.fire('foo') === false) {
  10422. * console.log('default has been prevented!');
  10423. * };
  10424. *
  10425. *
  10426. * // custom args + return value listener
  10427. * eventBus.on('sum', function(event, a, b) {
  10428. * return a + b;
  10429. * });
  10430. *
  10431. * // you can pass custom arguments + retrieve result values.
  10432. * var sum = eventBus.fire('sum', 1, 2);
  10433. * console.log(sum); // 3
  10434. * ```
  10435. */
  10436. function EventBus() {
  10437. this._listeners = {};
  10438. // cleanup on destroy
  10439. var self = this;
  10440. // destroy on lowest priority to allow
  10441. // message passing until the bitter end
  10442. this.on('diagram.destroy', 1, function() {
  10443. self._listeners = null;
  10444. });
  10445. }
  10446. module.exports = EventBus;
  10447. /**
  10448. * Register an event listener for events with the given name.
  10449. *
  10450. * The callback will be invoked with `event, ...additionalArguments`
  10451. * that have been passed to {@link EventBus#fire}.
  10452. *
  10453. * Returning false from a listener will prevent the events default action
  10454. * (if any is specified). To stop an event from being processed further in
  10455. * other listeners execute {@link Event#stopPropagation}.
  10456. *
  10457. * Returning anything but `undefined` from a listener will stop the listener propagation.
  10458. *
  10459. * @param {String|Array<String>} events
  10460. * @param {Number} [priority=1000] the priority in which this listener is called, larger is higher
  10461. * @param {Function} callback
  10462. */
  10463. EventBus.prototype.on = function(events, priority, callback) {
  10464. events = isArray(events) ? events : [ events ];
  10465. if (isFunction(priority)) {
  10466. callback = priority;
  10467. priority = DEFAULT_PRIORITY;
  10468. }
  10469. if (!isNumber(priority)) {
  10470. throw new Error('priority must be a number');
  10471. }
  10472. var self = this,
  10473. listener = { priority: priority, callback: callback };
  10474. events.forEach(function(e) {
  10475. self._addListener(e, listener);
  10476. });
  10477. };
  10478. /**
  10479. * Register an event listener that is executed only once.
  10480. *
  10481. * @param {String} event the event name to register for
  10482. * @param {Function} callback the callback to execute
  10483. */
  10484. EventBus.prototype.once = function(event, callback) {
  10485. var self = this;
  10486. function wrappedCallback() {
  10487. callback.apply(self, arguments);
  10488. self.off(event, wrappedCallback);
  10489. }
  10490. this.on(event, wrappedCallback);
  10491. };
  10492. /**
  10493. * Removes event listeners by event and callback.
  10494. *
  10495. * If no callback is given, all listeners for a given event name are being removed.
  10496. *
  10497. * @param {String} event
  10498. * @param {Function} [callback]
  10499. */
  10500. EventBus.prototype.off = function(event, callback) {
  10501. var listeners = this._getListeners(event),
  10502. listener, idx;
  10503. if (callback) {
  10504. // move through listeners from back to front
  10505. // and remove matching listeners
  10506. for (idx = listeners.length - 1; !!(listener = listeners[idx]); idx--) {
  10507. if (listener.callback === callback) {
  10508. listeners.splice(idx, 1);
  10509. }
  10510. }
  10511. } else {
  10512. // clear listeners
  10513. listeners.length = 0;
  10514. }
  10515. };
  10516. /**
  10517. * Fires a named event.
  10518. *
  10519. * @example
  10520. *
  10521. * // fire event by name
  10522. * events.fire('foo');
  10523. *
  10524. * // fire event object with nested type
  10525. * var event = { type: 'foo' };
  10526. * events.fire(event);
  10527. *
  10528. * // fire event with explicit type
  10529. * var event = { x: 10, y: 20 };
  10530. * events.fire('element.moved', event);
  10531. *
  10532. * // pass additional arguments to the event
  10533. * events.on('foo', function(event, bar) {
  10534. * alert(bar);
  10535. * });
  10536. *
  10537. * events.fire({ type: 'foo' }, 'I am bar!');
  10538. *
  10539. * @param {String} [name] the optional event name
  10540. * @param {Object} [event] the event object
  10541. * @param {...Object} additional arguments to be passed to the callback functions
  10542. *
  10543. * @return {Boolean} the events return value, if specified or false if the
  10544. * default action was prevented by listeners
  10545. */
  10546. EventBus.prototype.fire = function(type, data) {
  10547. var event,
  10548. originalType,
  10549. listeners, idx, listener,
  10550. returnValue,
  10551. args;
  10552. args = Array.prototype.slice.call(arguments);
  10553. if (typeof type === 'object') {
  10554. event = type;
  10555. type = event.type;
  10556. }
  10557. if (!type) {
  10558. throw new Error('no event type specified');
  10559. }
  10560. listeners = this._listeners[type];
  10561. if (!listeners) {
  10562. return;
  10563. }
  10564. // we make sure we fire instances of our home made
  10565. // events here. We wrap them only once, though
  10566. if (data instanceof Event) {
  10567. // we are fine, we alread have an event
  10568. event = data;
  10569. } else {
  10570. event = new Event();
  10571. event.init(data);
  10572. }
  10573. // ensure we pass the event as the first parameter
  10574. args[0] = event;
  10575. // original event type (in case we delegate)
  10576. originalType = event.type;
  10577. try {
  10578. // update event type before delegation
  10579. if (type !== originalType) {
  10580. event.type = type;
  10581. }
  10582. for (idx = 0; !!(listener = listeners[idx]); idx++) {
  10583. // handle stopped propagation
  10584. if (event.cancelBubble) {
  10585. break;
  10586. }
  10587. try {
  10588. // returning false prevents the default action
  10589. returnValue = event.returnValue = listener.callback.apply(null, args);
  10590. // stop propagation on return value
  10591. if (returnValue !== undefined) {
  10592. event.stopPropagation();
  10593. }
  10594. // prevent default on return false
  10595. if (returnValue === false) {
  10596. event.preventDefault();
  10597. }
  10598. } catch (e) {
  10599. if (!this.handleError(e)) {
  10600. console.error('unhandled error in event listener');
  10601. console.error(e.stack);
  10602. throw e;
  10603. }
  10604. }
  10605. }
  10606. } finally {
  10607. // reset event type after delegation
  10608. if (type !== originalType) {
  10609. event.type = originalType;
  10610. }
  10611. }
  10612. // set the return value to false if the event default
  10613. // got prevented and no other return value exists
  10614. if (returnValue === undefined && event.defaultPrevented) {
  10615. returnValue = false;
  10616. }
  10617. return returnValue;
  10618. };
  10619. EventBus.prototype.handleError = function(error) {
  10620. return this.fire('error', { error: error }) === false;
  10621. };
  10622. /*
  10623. * Add new listener with a certain priority to the list
  10624. * of listeners (for the given event).
  10625. *
  10626. * The semantics of listener registration / listener execution are
  10627. * first register, first serve: New listeners will always be inserted
  10628. * after existing listeners with the same priority.
  10629. *
  10630. * Example: Inserting two listeners with priority 1000 and 1300
  10631. *
  10632. * * before: [ 1500, 1500, 1000, 1000 ]
  10633. * * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
  10634. *
  10635. * @param {String} event
  10636. * @param {Object} listener { priority, callback }
  10637. */
  10638. EventBus.prototype._addListener = function(event, newListener) {
  10639. var listeners = this._getListeners(event),
  10640. existingListener,
  10641. idx;
  10642. // ensure we order listeners by priority from
  10643. // 0 (high) to n > 0 (low)
  10644. for (idx = 0; !!(existingListener = listeners[idx]); idx++) {
  10645. if (existingListener.priority < newListener.priority) {
  10646. // prepend newListener at before existingListener
  10647. listeners.splice(idx, 0, newListener);
  10648. return;
  10649. }
  10650. }
  10651. listeners.push(newListener);
  10652. };
  10653. EventBus.prototype._getListeners = function(name) {
  10654. var listeners = this._listeners[name];
  10655. if (!listeners) {
  10656. this._listeners[name] = listeners = [];
  10657. }
  10658. return listeners;
  10659. };
  10660. /**
  10661. * A event that is emitted via the event bus.
  10662. */
  10663. function Event() { }
  10664. module.exports.Event = Event;
  10665. Event.prototype.stopPropagation = function() {
  10666. this.cancelBubble = true;
  10667. };
  10668. Event.prototype.preventDefault = function() {
  10669. this.defaultPrevented = true;
  10670. };
  10671. Event.prototype.init = function(data) {
  10672. assign(this, data || {});
  10673. };
  10674. },{"159":159,"160":160,"162":162,"168":168}],41:[function(_dereq_,module,exports){
  10675. 'use strict';
  10676. var forEach = _dereq_(77),
  10677. reduce = _dereq_(81);
  10678. var GraphicsUtil = _dereq_(60),
  10679. domClear = _dereq_(179);
  10680. /**
  10681. * A factory that creates graphical elements
  10682. *
  10683. * @param {Renderer} renderer
  10684. */
  10685. function GraphicsFactory(renderer, elementRegistry) {
  10686. this._renderer = renderer;
  10687. this._elementRegistry = elementRegistry;
  10688. }
  10689. GraphicsFactory.$inject = [ 'renderer', 'elementRegistry' ];
  10690. module.exports = GraphicsFactory;
  10691. GraphicsFactory.prototype._getChildren = function(element) {
  10692. var gfx = this._elementRegistry.getGraphics(element);
  10693. var childrenGfx;
  10694. // root element
  10695. if (!element.parent) {
  10696. childrenGfx = gfx;
  10697. } else {
  10698. childrenGfx = GraphicsUtil.getChildren(gfx);
  10699. if (!childrenGfx) {
  10700. childrenGfx = gfx.parent().group().attr('class', 'djs-children');
  10701. }
  10702. }
  10703. return childrenGfx;
  10704. };
  10705. /**
  10706. * Clears the graphical representation of the element and returns the
  10707. * cleared visual (the <g class="djs-visual" /> element).
  10708. */
  10709. GraphicsFactory.prototype._clear = function(gfx) {
  10710. var visual = GraphicsUtil.getVisual(gfx);
  10711. domClear(visual.node);
  10712. return visual;
  10713. };
  10714. /**
  10715. * Creates a gfx container for shapes and connections
  10716. *
  10717. * The layout is as follows:
  10718. *
  10719. * <g class="djs-group">
  10720. *
  10721. * <!-- the gfx -->
  10722. * <g class="djs-element djs-(shape|connection)">
  10723. * <g class="djs-visual">
  10724. * <!-- the renderer draws in here -->
  10725. * </g>
  10726. *
  10727. * <!-- extensions (overlays, click box, ...) goes here
  10728. * </g>
  10729. *
  10730. * <!-- the gfx child nodes -->
  10731. * <g class="djs-children"></g>
  10732. * </g>
  10733. *
  10734. * @param {Object} parent
  10735. * @param {String} type the type of the element, i.e. shape | connection
  10736. */
  10737. GraphicsFactory.prototype._createContainer = function(type, parentGfx) {
  10738. var outerGfx = parentGfx.group().attr('class', 'djs-group'),
  10739. gfx = outerGfx.group().attr('class', 'djs-element djs-' + type);
  10740. // create visual
  10741. gfx.group().attr('class', 'djs-visual');
  10742. return gfx;
  10743. };
  10744. GraphicsFactory.prototype.create = function(type, element) {
  10745. var childrenGfx = this._getChildren(element.parent);
  10746. return this._createContainer(type, childrenGfx);
  10747. };
  10748. GraphicsFactory.prototype.updateContainments = function(elements) {
  10749. var self = this,
  10750. elementRegistry = this._elementRegistry,
  10751. parents;
  10752. parents = reduce(elements, function(map, e) {
  10753. if (e.parent) {
  10754. map[e.parent.id] = e.parent;
  10755. }
  10756. return map;
  10757. }, {});
  10758. // update all parents of changed and reorganized their children
  10759. // in the correct order (as indicated in our model)
  10760. forEach(parents, function(parent) {
  10761. var childGfx = self._getChildren(parent),
  10762. children = parent.children;
  10763. if (!children) {
  10764. return;
  10765. }
  10766. forEach(children.slice().reverse(), function(c) {
  10767. var gfx = elementRegistry.getGraphics(c);
  10768. gfx.parent().prependTo(childGfx);
  10769. });
  10770. });
  10771. };
  10772. GraphicsFactory.prototype.update = function(type, element, gfx) {
  10773. // Do not update root element
  10774. if (!element.parent) {
  10775. return;
  10776. }
  10777. var visual = this._clear(gfx);
  10778. // redraw
  10779. if (type === 'shape') {
  10780. this._renderer.drawShape(visual, element);
  10781. // update positioning
  10782. gfx.translate(element.x, element.y);
  10783. } else
  10784. if (type === 'connection') {
  10785. this._renderer.drawConnection(visual, element);
  10786. } else {
  10787. throw new Error('unknown type: ' + type);
  10788. }
  10789. gfx.attr('display', element.hidden ? 'none' : 'block');
  10790. };
  10791. GraphicsFactory.prototype.remove = function(element) {
  10792. var gfx = this._elementRegistry.getGraphics(element);
  10793. // remove
  10794. gfx.parent().remove();
  10795. };
  10796. },{"179":179,"60":60,"77":77,"81":81}],42:[function(_dereq_,module,exports){
  10797. module.exports = {
  10798. __depends__: [ _dereq_(45) ],
  10799. __init__: [ 'canvas' ],
  10800. canvas: [ 'type', _dereq_(37) ],
  10801. elementRegistry: [ 'type', _dereq_(39) ],
  10802. elementFactory: [ 'type', _dereq_(38) ],
  10803. eventBus: [ 'type', _dereq_(40) ],
  10804. graphicsFactory: [ 'type', _dereq_(41) ]
  10805. };
  10806. },{"37":37,"38":38,"39":39,"40":40,"41":41,"45":45}],43:[function(_dereq_,module,exports){
  10807. 'use strict';
  10808. var Snap = _dereq_(67);
  10809. /**
  10810. * The default renderer used for shapes and connections.
  10811. *
  10812. * @param {Styles} styles
  10813. */
  10814. function Renderer(styles) {
  10815. this.CONNECTION_STYLE = styles.style([ 'no-fill' ], { strokeWidth: 5, stroke: 'fuchsia' });
  10816. this.SHAPE_STYLE = styles.style({ fill: 'white', stroke: 'fuchsia', strokeWidth: 2 });
  10817. }
  10818. module.exports = Renderer;
  10819. Renderer.$inject = ['styles'];
  10820. Renderer.prototype.drawShape = function drawShape(gfxGroup, data) {
  10821. return gfxGroup.rect(0, 0, data.width || 0, data.height || 0).attr(this.SHAPE_STYLE);
  10822. };
  10823. Renderer.prototype.drawConnection = function drawConnection(gfxGroup, data) {
  10824. return createLine(data.waypoints, this.CONNECTION_STYLE).appendTo(gfxGroup);
  10825. };
  10826. function componentsToPath(components) {
  10827. return components.join(',').replace(/,?([A-z]),?/g, '$1');
  10828. }
  10829. /**
  10830. * Gets the default SVG path of a shape that represents it's visual bounds.
  10831. *
  10832. * @param {djs.model.Shape} shape
  10833. * @return {string} svg path
  10834. */
  10835. Renderer.prototype.getShapePath = function getShapePath(shape) {
  10836. var x = shape.x,
  10837. y = shape.y,
  10838. width = shape.width,
  10839. height = shape.height;
  10840. var shapePath = [
  10841. ['M', x, y],
  10842. ['l', width, 0],
  10843. ['l', 0, height],
  10844. ['l', -width, 0],
  10845. ['z']
  10846. ];
  10847. return componentsToPath(shapePath);
  10848. };
  10849. /**
  10850. * Gets the default SVG path of a connection that represents it's visual bounds.
  10851. *
  10852. * @param {djs.model.Connection} connection
  10853. * @return {string} svg path
  10854. */
  10855. Renderer.prototype.getConnectionPath = function getConnectionPath(connection) {
  10856. var waypoints = connection.waypoints;
  10857. var idx, point, connectionPath = [];
  10858. for (idx = 0; !!(point = waypoints[idx]); idx++) {
  10859. // take invisible docking into account
  10860. // when creating the path
  10861. point = point.original || point;
  10862. connectionPath.push([ idx === 0 ? 'M' : 'L', point.x, point.y ]);
  10863. }
  10864. return componentsToPath(connectionPath);
  10865. };
  10866. function toSVGPoints(points) {
  10867. var result = '';
  10868. for (var i = 0, p; !!(p = points[i]); i++) {
  10869. result += p.x + ',' + p.y + ' ';
  10870. }
  10871. return result;
  10872. }
  10873. function createLine(points, attrs) {
  10874. return Snap.create('polyline', { points: toSVGPoints(points) }).attr(attrs || {});
  10875. }
  10876. function updateLine(gfx, points) {
  10877. return gfx.attr({ points: toSVGPoints(points) });
  10878. }
  10879. module.exports.createLine = createLine;
  10880. module.exports.updateLine = updateLine;
  10881. },{"67":67}],44:[function(_dereq_,module,exports){
  10882. 'use strict';
  10883. var isArray = _dereq_(159),
  10884. assign = _dereq_(168),
  10885. reduce = _dereq_(81);
  10886. /**
  10887. * A component that manages shape styles
  10888. */
  10889. function Styles() {
  10890. var defaultTraits = {
  10891. 'no-fill': {
  10892. fill: 'none'
  10893. },
  10894. 'no-border': {
  10895. strokeOpacity: 0.0
  10896. },
  10897. 'no-events': {
  10898. pointerEvents: 'none'
  10899. }
  10900. };
  10901. /**
  10902. * Builds a style definition from a className, a list of traits and an object of additional attributes.
  10903. *
  10904. * @param {String} className
  10905. * @param {Array<String>} traits
  10906. * @param {Object} additionalAttrs
  10907. *
  10908. * @return {Object} the style defintion
  10909. */
  10910. this.cls = function(className, traits, additionalAttrs) {
  10911. var attrs = this.style(traits, additionalAttrs);
  10912. return assign(attrs, { 'class': className });
  10913. };
  10914. /**
  10915. * Builds a style definition from a list of traits and an object of additional attributes.
  10916. *
  10917. * @param {Array<String>} traits
  10918. * @param {Object} additionalAttrs
  10919. *
  10920. * @return {Object} the style defintion
  10921. */
  10922. this.style = function(traits, additionalAttrs) {
  10923. if (!isArray(traits) && !additionalAttrs) {
  10924. additionalAttrs = traits;
  10925. traits = [];
  10926. }
  10927. var attrs = reduce(traits, function(attrs, t) {
  10928. return assign(attrs, defaultTraits[t] || {});
  10929. }, {});
  10930. return additionalAttrs ? assign(attrs, additionalAttrs) : attrs;
  10931. };
  10932. }
  10933. module.exports = Styles;
  10934. },{"159":159,"168":168,"81":81}],45:[function(_dereq_,module,exports){
  10935. module.exports = {
  10936. renderer: [ 'type', _dereq_(43) ],
  10937. styles: [ 'type', _dereq_(44) ]
  10938. };
  10939. },{"43":43,"44":44}],46:[function(_dereq_,module,exports){
  10940. 'use strict';
  10941. var forEach = _dereq_(77),
  10942. domDelegate = _dereq_(180),
  10943. Renderer = _dereq_(43),
  10944. createLine = Renderer.createLine,
  10945. updateLine = Renderer.updateLine;
  10946. var isPrimaryButton = _dereq_(62).isPrimaryButton;
  10947. var Snap = _dereq_(67);
  10948. /**
  10949. * A plugin that provides interaction events for diagram elements.
  10950. *
  10951. * It emits the following events:
  10952. *
  10953. * * element.hover
  10954. * * element.out
  10955. * * element.click
  10956. * * element.dblclick
  10957. * * element.mousedown
  10958. *
  10959. * Each event is a tuple { element, gfx, originalEvent }.
  10960. *
  10961. * Canceling the event via Event#preventDefault() prevents the original DOM operation.
  10962. *
  10963. * @param {EventBus} eventBus
  10964. */
  10965. function InteractionEvents(eventBus, elementRegistry, styles) {
  10966. var HIT_STYLE = styles.cls('djs-hit', [ 'no-fill', 'no-border' ], {
  10967. stroke: 'white',
  10968. strokeWidth: 15
  10969. });
  10970. function fire(type, event) {
  10971. var target = event.delegateTarget || event.target,
  10972. gfx = target && new Snap(target),
  10973. element = elementRegistry.get(gfx),
  10974. returnValue;
  10975. if (!gfx || !element) {
  10976. return;
  10977. }
  10978. returnValue = eventBus.fire(type, { element: element, gfx: gfx, originalEvent: event });
  10979. if (returnValue === false) {
  10980. event.stopPropagation();
  10981. event.preventDefault();
  10982. }
  10983. }
  10984. var handlers = {};
  10985. function mouseHandler(type) {
  10986. var fn = handlers[type];
  10987. if (!fn) {
  10988. fn = handlers[type] = function(event) {
  10989. // only indicate left mouse button interactions
  10990. if (isPrimaryButton(event)) {
  10991. fire(type, event);
  10992. }
  10993. };
  10994. }
  10995. return fn;
  10996. }
  10997. var bindings = {
  10998. mouseover: 'element.hover',
  10999. mouseout: 'element.out',
  11000. click: 'element.click',
  11001. dblclick: 'element.dblclick',
  11002. mousedown: 'element.mousedown',
  11003. mouseup: 'element.mouseup'
  11004. };
  11005. var elementSelector = 'svg, .djs-element';
  11006. ///// event registration
  11007. function registerEvent(node, event, localEvent) {
  11008. var handler = mouseHandler(localEvent);
  11009. handler.$delegate = domDelegate.bind(node, elementSelector, event, handler);
  11010. }
  11011. function unregisterEvent(node, event, localEvent) {
  11012. domDelegate.unbind(node, event, mouseHandler(localEvent).$delegate);
  11013. }
  11014. function registerEvents(svg) {
  11015. forEach(bindings, function(val, key) {
  11016. registerEvent(svg.node, key, val);
  11017. });
  11018. }
  11019. function unregisterEvents(svg) {
  11020. forEach(bindings, function(val, key) {
  11021. unregisterEvent(svg.node, key, val);
  11022. });
  11023. }
  11024. eventBus.on('canvas.destroy', function(event) {
  11025. unregisterEvents(event.svg);
  11026. });
  11027. eventBus.on('canvas.init', function(event) {
  11028. registerEvents(event.svg);
  11029. });
  11030. eventBus.on([ 'shape.added', 'connection.added' ], function(event) {
  11031. var element = event.element,
  11032. gfx = event.gfx,
  11033. hit,
  11034. type;
  11035. if (element.waypoints) {
  11036. hit = createLine(element.waypoints);
  11037. type = 'connection';
  11038. } else {
  11039. hit = Snap.create('rect', { x: 0, y: 0, width: element.width, height: element.height });
  11040. type = 'shape';
  11041. }
  11042. hit.attr(HIT_STYLE).appendTo(gfx.node);
  11043. });
  11044. // update djs-hit on change
  11045. eventBus.on('shape.changed', function(event) {
  11046. var element = event.element,
  11047. gfx = event.gfx,
  11048. hit = gfx.select('.djs-hit');
  11049. hit.attr({
  11050. width: element.width,
  11051. height: element.height
  11052. });
  11053. });
  11054. eventBus.on('connection.changed', function(event) {
  11055. var element = event.element,
  11056. gfx = event.gfx,
  11057. hit = gfx.select('.djs-hit');
  11058. updateLine(hit, element.waypoints);
  11059. });
  11060. // API
  11061. this.fire = fire;
  11062. this.mouseHandler = mouseHandler;
  11063. this.registerEvent = registerEvent;
  11064. this.unregisterEvent = unregisterEvent;
  11065. }
  11066. InteractionEvents.$inject = [ 'eventBus', 'elementRegistry', 'styles' ];
  11067. module.exports = InteractionEvents;
  11068. /**
  11069. * An event indicating that the mouse hovered over an element
  11070. *
  11071. * @event element.hover
  11072. *
  11073. * @type {Object}
  11074. * @property {djs.model.Base} element
  11075. * @property {Snap<Element>} gfx
  11076. * @property {Event} originalEvent
  11077. */
  11078. /**
  11079. * An event indicating that the mouse has left an element
  11080. *
  11081. * @event element.out
  11082. *
  11083. * @type {Object}
  11084. * @property {djs.model.Base} element
  11085. * @property {Snap<Element>} gfx
  11086. * @property {Event} originalEvent
  11087. */
  11088. /**
  11089. * An event indicating that the mouse has clicked an element
  11090. *
  11091. * @event element.click
  11092. *
  11093. * @type {Object}
  11094. * @property {djs.model.Base} element
  11095. * @property {Snap<Element>} gfx
  11096. * @property {Event} originalEvent
  11097. */
  11098. /**
  11099. * An event indicating that the mouse has double clicked an element
  11100. *
  11101. * @event element.dblclick
  11102. *
  11103. * @type {Object}
  11104. * @property {djs.model.Base} element
  11105. * @property {Snap<Element>} gfx
  11106. * @property {Event} originalEvent
  11107. */
  11108. /**
  11109. * An event indicating that the mouse has gone down on an element.
  11110. *
  11111. * @event element.mousedown
  11112. *
  11113. * @type {Object}
  11114. * @property {djs.model.Base} element
  11115. * @property {Snap<Element>} gfx
  11116. * @property {Event} originalEvent
  11117. */
  11118. /**
  11119. * An event indicating that the mouse has gone up on an element.
  11120. *
  11121. * @event element.mouseup
  11122. *
  11123. * @type {Object}
  11124. * @property {djs.model.Base} element
  11125. * @property {Snap<Element>} gfx
  11126. * @property {Event} originalEvent
  11127. */
  11128. },{"180":180,"43":43,"62":62,"67":67,"77":77}],47:[function(_dereq_,module,exports){
  11129. module.exports = {
  11130. __init__: [ 'interactionEvents' ],
  11131. interactionEvents: [ 'type', _dereq_(46) ]
  11132. };
  11133. },{"46":46}],48:[function(_dereq_,module,exports){
  11134. 'use strict';
  11135. var getBBox = _dereq_(58).getBBox;
  11136. /**
  11137. * @class
  11138. *
  11139. * A plugin that adds an outline to shapes and connections that may be activated and styled
  11140. * via CSS classes.
  11141. *
  11142. * @param {EventBus} events the event bus
  11143. */
  11144. function Outline(eventBus, styles, elementRegistry) {
  11145. var OUTLINE_OFFSET = 6;
  11146. var OUTLINE_STYLE = styles.cls('djs-outline', [ 'no-fill' ]);
  11147. function createOutline(gfx, bounds) {
  11148. return gfx.rect(10, 10, 0, 0).attr(OUTLINE_STYLE);
  11149. }
  11150. function updateShapeOutline(outline, bounds) {
  11151. outline.attr({
  11152. x: -OUTLINE_OFFSET,
  11153. y: -OUTLINE_OFFSET,
  11154. width: bounds.width + OUTLINE_OFFSET * 2,
  11155. height: bounds.height + OUTLINE_OFFSET * 2
  11156. });
  11157. }
  11158. function updateConnectionOutline(outline, connection) {
  11159. var bbox = getBBox(connection);
  11160. outline.attr({
  11161. x: bbox.x - OUTLINE_OFFSET,
  11162. y: bbox.y - OUTLINE_OFFSET,
  11163. width: bbox.width + OUTLINE_OFFSET * 2,
  11164. height: bbox.height + OUTLINE_OFFSET * 2
  11165. });
  11166. }
  11167. eventBus.on([ 'shape.added', 'shape.changed' ], function(event) {
  11168. var element = event.element,
  11169. gfx = event.gfx;
  11170. var outline = gfx.select('.djs-outline');
  11171. if (!outline) {
  11172. outline = createOutline(gfx, element);
  11173. }
  11174. updateShapeOutline(outline, element);
  11175. });
  11176. eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
  11177. var element = event.element,
  11178. gfx = event.gfx;
  11179. var outline = gfx.select('.djs-outline');
  11180. if (!outline) {
  11181. outline = createOutline(gfx, element);
  11182. }
  11183. updateConnectionOutline(outline, element);
  11184. });
  11185. }
  11186. Outline.$inject = ['eventBus', 'styles', 'elementRegistry'];
  11187. module.exports = Outline;
  11188. },{"58":58}],49:[function(_dereq_,module,exports){
  11189. 'use strict';
  11190. module.exports = {
  11191. __init__: [ 'outline' ],
  11192. outline: [ 'type', _dereq_(48) ]
  11193. };
  11194. },{"48":48}],50:[function(_dereq_,module,exports){
  11195. 'use strict';
  11196. var isArray = _dereq_(159),
  11197. isString = _dereq_(165),
  11198. isObject = _dereq_(163),
  11199. assign = _dereq_(168),
  11200. forEach = _dereq_(77),
  11201. filter = _dereq_(75),
  11202. debounce = _dereq_(84);
  11203. var domify = _dereq_(181),
  11204. domClasses = _dereq_(178),
  11205. domRemove = _dereq_(183);
  11206. var getBBox = _dereq_(58).getBBox;
  11207. // document wide unique overlay ids
  11208. var ids = new (_dereq_(61))('ov');
  11209. function createRoot(parent) {
  11210. var root = domify('<div class="djs-overlay-container" style="position: absolute; width: 0; height: 0;" />');
  11211. parent.insertBefore(root, parent.firstChild);
  11212. return root;
  11213. }
  11214. function setPosition(el, x, y) {
  11215. assign(el.style, { left: x + 'px', top: y + 'px' });
  11216. }
  11217. function setVisible(el, visible) {
  11218. el.style.display = visible === false ? 'none' : '';
  11219. }
  11220. /**
  11221. * A service that allows users to attach overlays to diagram elements.
  11222. *
  11223. * The overlay service will take care of overlay positioning during updates.
  11224. *
  11225. * @example
  11226. *
  11227. * // add a pink badge on the top left of the shape
  11228. * overlays.add(someShape, {
  11229. * position: {
  11230. * top: -5,
  11231. * left: -5
  11232. * },
  11233. * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
  11234. * });
  11235. *
  11236. * // or add via shape id
  11237. *
  11238. * overlays.add('some-element-id', {
  11239. * position: {
  11240. * top: -5,
  11241. * left: -5
  11242. * }
  11243. * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
  11244. * });
  11245. *
  11246. * // or add with optional type
  11247. *
  11248. * overlays.add(someShape, 'badge', {
  11249. * position: {
  11250. * top: -5,
  11251. * left: -5
  11252. * }
  11253. * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
  11254. * });
  11255. *
  11256. *
  11257. * // remove an overlay
  11258. *
  11259. * var id = overlays.add(...);
  11260. * overlays.remove(id);
  11261. *
  11262. * @param {EventBus} eventBus
  11263. * @param {Canvas} canvas
  11264. * @param {ElementRegistry} elementRegistry
  11265. */
  11266. function Overlays(config, eventBus, canvas, elementRegistry) {
  11267. this._eventBus = eventBus;
  11268. this._canvas = canvas;
  11269. this._elementRegistry = elementRegistry;
  11270. this._ids = ids;
  11271. this._overlayDefaults = {
  11272. show: {
  11273. minZoom: 0.7,
  11274. maxZoom: 5.0
  11275. }
  11276. };
  11277. /**
  11278. * Mapping overlayId -> overlay
  11279. */
  11280. this._overlays = {};
  11281. /**
  11282. * Mapping elementId -> overlay container
  11283. */
  11284. this._overlayContainers = {};
  11285. // root html element for all overlays
  11286. this._overlayRoot = createRoot(canvas.getContainer());
  11287. this._init(config);
  11288. }
  11289. Overlays.$inject = [ 'config.overlays', 'eventBus', 'canvas', 'elementRegistry' ];
  11290. module.exports = Overlays;
  11291. /**
  11292. * Returns the overlay with the specified id or a list of overlays
  11293. * for an element with a given type.
  11294. *
  11295. * @example
  11296. *
  11297. * // return the single overlay with the given id
  11298. * overlays.get('some-id');
  11299. *
  11300. * // return all overlays for the shape
  11301. * overlays.get({ element: someShape });
  11302. *
  11303. * // return all overlays on shape with type 'badge'
  11304. * overlays.get({ element: someShape, type: 'badge' });
  11305. *
  11306. * // shape can also be specified as id
  11307. * overlays.get({ element: 'element-id', type: 'badge' });
  11308. *
  11309. *
  11310. * @param {Object} search
  11311. * @param {String} [search.id]
  11312. * @param {String|djs.model.Base} [search.element]
  11313. * @param {String} [search.type]
  11314. *
  11315. * @return {Object|Array<Object>} the overlay(s)
  11316. */
  11317. Overlays.prototype.get = function(search) {
  11318. if (isString(search)) {
  11319. search = { id: search };
  11320. }
  11321. if (search.element) {
  11322. var container = this._getOverlayContainer(search.element, true);
  11323. // return a list of overlays when searching by element (+type)
  11324. if (container) {
  11325. return search.type ? filter(container.overlays, { type: search.type }) : container.overlays.slice();
  11326. } else {
  11327. return [];
  11328. }
  11329. } else
  11330. if (search.type) {
  11331. return filter(this._overlays, { type: search.type });
  11332. } else {
  11333. // return single element when searching by id
  11334. return search.id ? this._overlays[search.id] : null;
  11335. }
  11336. };
  11337. /**
  11338. * Adds a HTML overlay to an element.
  11339. *
  11340. * @param {String|djs.model.Base} element attach overlay to this shape
  11341. * @param {String} [type] optional type to assign to the overlay
  11342. * @param {Object} overlay the overlay configuration
  11343. *
  11344. * @param {String|DOMElement} overlay.html html element to use as an overlay
  11345. * @param {Object} [overlay.show] show configuration
  11346. * @param {Number} [overlay.show.minZoom] minimal zoom level to show the overlay
  11347. * @param {Number} [overlay.show.maxZoom] maximum zoom level to show the overlay
  11348. * @param {Object} overlay.position where to attach the overlay
  11349. * @param {Number} [overlay.position.left] relative to element bbox left attachment
  11350. * @param {Number} [overlay.position.top] relative to element bbox top attachment
  11351. * @param {Number} [overlay.position.bottom] relative to element bbox bottom attachment
  11352. * @param {Number} [overlay.position.right] relative to element bbox right attachment
  11353. *
  11354. * @return {String} id that may be used to reference the overlay for update or removal
  11355. */
  11356. Overlays.prototype.add = function(element, type, overlay) {
  11357. if (isObject(type)) {
  11358. overlay = type;
  11359. type = null;
  11360. }
  11361. if (!element.id) {
  11362. element = this._elementRegistry.get(element);
  11363. }
  11364. if (!overlay.position) {
  11365. throw new Error('must specifiy overlay position');
  11366. }
  11367. if (!overlay.html) {
  11368. throw new Error('must specifiy overlay html');
  11369. }
  11370. if (!element) {
  11371. throw new Error('invalid element specified');
  11372. }
  11373. var id = this._ids.next();
  11374. overlay = assign({}, this._overlayDefaults, overlay, {
  11375. id: id,
  11376. type: type,
  11377. element: element,
  11378. html: overlay.html
  11379. });
  11380. this._addOverlay(overlay);
  11381. return id;
  11382. };
  11383. /**
  11384. * Remove an overlay with the given id or all overlays matching the given filter.
  11385. *
  11386. * @see Overlays#get for filter options.
  11387. *
  11388. * @param {String} [id]
  11389. * @param {Object} [filter]
  11390. */
  11391. Overlays.prototype.remove = function(filter) {
  11392. var overlays = this.get(filter) || [];
  11393. if (!isArray(overlays)) {
  11394. overlays = [ overlays ];
  11395. }
  11396. var self = this;
  11397. forEach(overlays, function(overlay) {
  11398. var container = self._getOverlayContainer(overlay.element, true);
  11399. if (overlay) {
  11400. domRemove(overlay.html);
  11401. domRemove(overlay.htmlContainer);
  11402. delete overlay.htmlContainer;
  11403. delete overlay.element;
  11404. delete self._overlays[overlay.id];
  11405. }
  11406. if (container) {
  11407. var idx = container.overlays.indexOf(overlay);
  11408. if (idx !== -1) {
  11409. container.overlays.splice(idx, 1);
  11410. }
  11411. }
  11412. });
  11413. };
  11414. Overlays.prototype.show = function() {
  11415. setVisible(this._overlayRoot);
  11416. };
  11417. Overlays.prototype.hide = function() {
  11418. setVisible(this._overlayRoot, false);
  11419. };
  11420. Overlays.prototype._updateOverlayContainer = function(container) {
  11421. var element = container.element,
  11422. html = container.html;
  11423. // update container left,top according to the elements x,y coordinates
  11424. // this ensures we can attach child elements relative to this container
  11425. var x = element.x,
  11426. y = element.y;
  11427. if (element.waypoints) {
  11428. var bbox = getBBox(element);
  11429. x = bbox.x;
  11430. y = bbox.y;
  11431. }
  11432. setPosition(html, x, y);
  11433. };
  11434. Overlays.prototype._updateOverlay = function(overlay) {
  11435. var position = overlay.position,
  11436. htmlContainer = overlay.htmlContainer,
  11437. element = overlay.element;
  11438. // update overlay html relative to shape because
  11439. // it is already positioned on the element
  11440. // update relative
  11441. var left = position.left,
  11442. top = position.top;
  11443. if (position.right !== undefined) {
  11444. var width;
  11445. if (element.waypoints) {
  11446. width = getBBox(element).width;
  11447. } else {
  11448. width = element.width;
  11449. }
  11450. left = position.right * -1 + width;
  11451. }
  11452. if (position.bottom !== undefined) {
  11453. var height;
  11454. if (element.waypoints) {
  11455. height = getBBox(element).height;
  11456. } else {
  11457. height = element.height;
  11458. }
  11459. top = position.bottom * -1 + height;
  11460. }
  11461. setPosition(htmlContainer, left || 0, top || 0);
  11462. };
  11463. Overlays.prototype._createOverlayContainer = function(element) {
  11464. var html = domify('<div class="djs-overlays djs-overlays-' + element.id + '" style="position: absolute" />');
  11465. this._overlayRoot.appendChild(html);
  11466. var container = {
  11467. html: html,
  11468. element: element,
  11469. overlays: []
  11470. };
  11471. this._updateOverlayContainer(container);
  11472. return container;
  11473. };
  11474. Overlays.prototype._updateRoot = function(viewbox) {
  11475. var a = viewbox.scale || 1;
  11476. var d = viewbox.scale || 1;
  11477. var matrix = 'matrix(' + a + ',0,0,' + d + ',' + (-1 * viewbox.x * a) + ',' + (-1 * viewbox.y * d) + ')';
  11478. this._overlayRoot.style.transform = matrix;
  11479. this._overlayRoot.style['-ms-transform'] = matrix;
  11480. };
  11481. Overlays.prototype._getOverlayContainer = function(element, raw) {
  11482. var id = (element && element.id) || element;
  11483. var container = this._overlayContainers[id];
  11484. if (!container && !raw) {
  11485. container = this._overlayContainers[id] = this._createOverlayContainer(element);
  11486. }
  11487. return container;
  11488. };
  11489. Overlays.prototype._addOverlay = function(overlay) {
  11490. var id = overlay.id,
  11491. element = overlay.element,
  11492. html = overlay.html,
  11493. htmlContainer,
  11494. overlayContainer;
  11495. // unwrap jquery (for those who need it)
  11496. if (html.get) {
  11497. html = html.get(0);
  11498. }
  11499. // create proper html elements from
  11500. // overlay HTML strings
  11501. if (isString(html)) {
  11502. html = domify(html);
  11503. }
  11504. overlayContainer = this._getOverlayContainer(element);
  11505. htmlContainer = domify('<div class="djs-overlay" data-overlay-id="' + id + '" style="position: absolute">');
  11506. htmlContainer.appendChild(html);
  11507. if (overlay.type) {
  11508. domClasses(htmlContainer).add('djs-overlay-' + overlay.type);
  11509. }
  11510. overlay.htmlContainer = htmlContainer;
  11511. overlayContainer.overlays.push(overlay);
  11512. overlayContainer.html.appendChild(htmlContainer);
  11513. this._overlays[id] = overlay;
  11514. this._updateOverlay(overlay);
  11515. };
  11516. Overlays.prototype._updateOverlayVisibilty = function(viewbox) {
  11517. forEach(this._overlays, function(overlay) {
  11518. var show = overlay.show,
  11519. htmlContainer = overlay.htmlContainer,
  11520. visible = true;
  11521. if (show) {
  11522. if (show.minZoom > viewbox.scale ||
  11523. show.maxZoom < viewbox.scale) {
  11524. visible = false;
  11525. }
  11526. setVisible(htmlContainer, visible);
  11527. }
  11528. });
  11529. };
  11530. Overlays.prototype._init = function(config) {
  11531. var eventBus = this._eventBus;
  11532. var self = this;
  11533. // scroll/zoom integration
  11534. var updateViewbox = function(viewbox) {
  11535. self._updateRoot(viewbox);
  11536. self._updateOverlayVisibilty(viewbox);
  11537. self.show();
  11538. };
  11539. if (!config || config.deferUpdate !== false) {
  11540. updateViewbox = debounce(updateViewbox, 300);
  11541. }
  11542. eventBus.on('canvas.viewbox.changed', function(event) {
  11543. self.hide();
  11544. updateViewbox(event.viewbox);
  11545. });
  11546. // remove integration
  11547. eventBus.on([ 'shape.remove', 'connection.remove' ], function(e) {
  11548. var overlays = self.get({ element: e.element });
  11549. forEach(overlays, function(o) {
  11550. self.remove(o.id);
  11551. });
  11552. });
  11553. // move integration
  11554. eventBus.on([
  11555. 'element.changed'
  11556. ], function(e) {
  11557. var element = e.element;
  11558. var container = self._getOverlayContainer(element, true);
  11559. if (container) {
  11560. forEach(container.overlays, function(overlay) {
  11561. self._updateOverlay(overlay);
  11562. });
  11563. self._updateOverlayContainer(container);
  11564. }
  11565. });
  11566. // marker integration, simply add them on the overlays as classes, too.
  11567. eventBus.on('element.marker.update', function(e) {
  11568. var container = self._getOverlayContainer(e.element, true);
  11569. if (container) {
  11570. domClasses(container.html)[e.add ? 'add' : 'remove'](e.marker);
  11571. }
  11572. });
  11573. };
  11574. },{"159":159,"163":163,"165":165,"168":168,"178":178,"181":181,"183":183,"58":58,"61":61,"75":75,"77":77,"84":84}],51:[function(_dereq_,module,exports){
  11575. module.exports = {
  11576. __init__: [ 'overlays' ],
  11577. overlays: [ 'type', _dereq_(50) ]
  11578. };
  11579. },{"50":50}],52:[function(_dereq_,module,exports){
  11580. 'use strict';
  11581. var isArray = _dereq_(159),
  11582. forEach = _dereq_(77);
  11583. /**
  11584. * A service that offers the current selection in a diagram.
  11585. * Offers the api to control the selection, too.
  11586. *
  11587. * @class
  11588. *
  11589. * @param {EventBus} eventBus the event bus
  11590. */
  11591. function Selection(eventBus) {
  11592. this._eventBus = eventBus;
  11593. this._selectedElements = [];
  11594. var self = this;
  11595. eventBus.on([ 'shape.remove', 'connection.remove' ], function(e) {
  11596. var element = e.element;
  11597. self.deselect(element);
  11598. });
  11599. }
  11600. Selection.$inject = [ 'eventBus' ];
  11601. module.exports = Selection;
  11602. Selection.prototype.deselect = function(element) {
  11603. var selectedElements = this._selectedElements;
  11604. var idx = selectedElements.indexOf(element);
  11605. if (idx !== -1) {
  11606. var oldSelection = selectedElements.slice();
  11607. selectedElements.splice(idx, 1);
  11608. this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
  11609. }
  11610. };
  11611. Selection.prototype.get = function() {
  11612. return this._selectedElements;
  11613. };
  11614. Selection.prototype.isSelected = function(element) {
  11615. return this._selectedElements.indexOf(element) !== -1;
  11616. };
  11617. /**
  11618. * This method selects one or more elements on the diagram.
  11619. *
  11620. * By passing an additional add parameter you can decide whether or not the element(s)
  11621. * should be added to the already existing selection or not.
  11622. *
  11623. * @method Selection#select
  11624. *
  11625. * @param {Object|Object[]} elements element or array of elements to be selected
  11626. * @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
  11627. */
  11628. Selection.prototype.select = function(elements, add) {
  11629. var selectedElements = this._selectedElements,
  11630. oldSelection = selectedElements.slice();
  11631. if (!isArray(elements)) {
  11632. elements = elements ? [ elements ] : [];
  11633. }
  11634. // selection may be cleared by passing an empty array or null
  11635. // to the method
  11636. if (add) {
  11637. forEach(elements, function(element) {
  11638. if (selectedElements.indexOf(element) !== -1) {
  11639. // already selected
  11640. return;
  11641. } else {
  11642. selectedElements.push(element);
  11643. }
  11644. });
  11645. } else {
  11646. this._selectedElements = selectedElements = elements.slice();
  11647. }
  11648. this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
  11649. };
  11650. },{"159":159,"77":77}],53:[function(_dereq_,module,exports){
  11651. 'use strict';
  11652. var hasPrimaryModifier = _dereq_(62).hasPrimaryModifier;
  11653. function SelectionBehavior(eventBus, selection, canvas) {
  11654. eventBus.on('create.end', 500, function(e) {
  11655. // select the created shape after a
  11656. // successful create operation
  11657. if (e.context.canExecute) {
  11658. selection.select(e.context.shape);
  11659. }
  11660. });
  11661. eventBus.on('connect.end', 500, function(e) {
  11662. // select the connect end target
  11663. // after a connect operation
  11664. if (e.context.canExecute && e.context.target) {
  11665. selection.select(e.context.target);
  11666. }
  11667. });
  11668. eventBus.on('shape.move.end', 500, function(e) {
  11669. var previousSelection = e.previousSelection || [];
  11670. var shape = e.context.shape;
  11671. // make sure at least the main moved element is being
  11672. // selected after a move operation
  11673. if (previousSelection.indexOf(shape) === -1) {
  11674. selection.select(shape);
  11675. }
  11676. });
  11677. // Shift + click selection
  11678. eventBus.on('element.click', function(event) {
  11679. var element = event.element;
  11680. // do not select the root element
  11681. // or connections
  11682. if (element === canvas.getRootElement()) {
  11683. element = null;
  11684. }
  11685. var isSelected = selection.isSelected(element),
  11686. isMultiSelect = selection.get().length > 1;
  11687. // mouse-event: SELECTION_KEY
  11688. var add = hasPrimaryModifier(event);
  11689. // select OR deselect element in multi selection
  11690. if (isSelected && isMultiSelect) {
  11691. if (add) {
  11692. return selection.deselect(element);
  11693. } else {
  11694. return selection.select(element);
  11695. }
  11696. } else
  11697. if (!isSelected) {
  11698. selection.select(element, add);
  11699. } else {
  11700. selection.deselect(element);
  11701. }
  11702. });
  11703. }
  11704. SelectionBehavior.$inject = [ 'eventBus', 'selection', 'canvas' ];
  11705. module.exports = SelectionBehavior;
  11706. },{"62":62}],54:[function(_dereq_,module,exports){
  11707. 'use strict';
  11708. var forEach = _dereq_(77);
  11709. var MARKER_HOVER = 'hover',
  11710. MARKER_SELECTED = 'selected';
  11711. /**
  11712. * A plugin that adds a visible selection UI to shapes and connections
  11713. * by appending the <code>hover</code> and <code>selected</code> classes to them.
  11714. *
  11715. * @class
  11716. *
  11717. * Makes elements selectable, too.
  11718. *
  11719. * @param {EventBus} events
  11720. * @param {SelectionService} selection
  11721. * @param {Canvas} canvas
  11722. */
  11723. function SelectionVisuals(events, canvas, selection, graphicsFactory, styles) {
  11724. this._multiSelectionBox = null;
  11725. function addMarker(e, cls) {
  11726. canvas.addMarker(e, cls);
  11727. }
  11728. function removeMarker(e, cls) {
  11729. canvas.removeMarker(e, cls);
  11730. }
  11731. events.on('element.hover', function(event) {
  11732. addMarker(event.element, MARKER_HOVER);
  11733. });
  11734. events.on('element.out', function(event) {
  11735. removeMarker(event.element, MARKER_HOVER);
  11736. });
  11737. events.on('selection.changed', function(event) {
  11738. function deselect(s) {
  11739. removeMarker(s, MARKER_SELECTED);
  11740. }
  11741. function select(s) {
  11742. addMarker(s, MARKER_SELECTED);
  11743. }
  11744. var oldSelection = event.oldSelection,
  11745. newSelection = event.newSelection;
  11746. forEach(oldSelection, function(e) {
  11747. if (newSelection.indexOf(e) === -1) {
  11748. deselect(e);
  11749. }
  11750. });
  11751. forEach(newSelection, function(e) {
  11752. if (oldSelection.indexOf(e) === -1) {
  11753. select(e);
  11754. }
  11755. });
  11756. });
  11757. }
  11758. SelectionVisuals.$inject = [
  11759. 'eventBus',
  11760. 'canvas',
  11761. 'selection',
  11762. 'graphicsFactory',
  11763. 'styles'
  11764. ];
  11765. module.exports = SelectionVisuals;
  11766. },{"77":77}],55:[function(_dereq_,module,exports){
  11767. module.exports = {
  11768. __init__: [ 'selectionVisuals', 'selectionBehavior' ],
  11769. __depends__: [
  11770. _dereq_(47),
  11771. _dereq_(49)
  11772. ],
  11773. selection: [ 'type', _dereq_(52) ],
  11774. selectionVisuals: [ 'type', _dereq_(54) ],
  11775. selectionBehavior: [ 'type', _dereq_(53) ]
  11776. };
  11777. },{"47":47,"49":49,"52":52,"53":53,"54":54}],56:[function(_dereq_,module,exports){
  11778. 'use strict';
  11779. var assign = _dereq_(168),
  11780. inherits = _dereq_(72);
  11781. var Refs = _dereq_(192);
  11782. var parentRefs = new Refs({ name: 'children', enumerable: true, collection: true }, { name: 'parent' }),
  11783. labelRefs = new Refs({ name: 'label', enumerable: true }, { name: 'labelTarget' }),
  11784. attacherRefs = new Refs({ name: 'attachers', collection: true }, { name: 'host' }),
  11785. outgoingRefs = new Refs({ name: 'outgoing', collection: true }, { name: 'source' }),
  11786. incomingRefs = new Refs({ name: 'incoming', collection: true }, { name: 'target' });
  11787. /**
  11788. * @namespace djs.model
  11789. */
  11790. /**
  11791. * @memberOf djs.model
  11792. */
  11793. /**
  11794. * The basic graphical representation
  11795. *
  11796. * @class
  11797. *
  11798. * @abstract
  11799. */
  11800. function Base() {
  11801. /**
  11802. * The object that backs up the shape
  11803. *
  11804. * @name Base#businessObject
  11805. * @type Object
  11806. */
  11807. Object.defineProperty(this, 'businessObject', {
  11808. writable: true
  11809. });
  11810. /**
  11811. * The parent shape
  11812. *
  11813. * @name Base#parent
  11814. * @type Shape
  11815. */
  11816. parentRefs.bind(this, 'parent');
  11817. /**
  11818. * @name Base#label
  11819. * @type Label
  11820. */
  11821. labelRefs.bind(this, 'label');
  11822. /**
  11823. * The list of outgoing connections
  11824. *
  11825. * @name Base#outgoing
  11826. * @type Array<Connection>
  11827. */
  11828. outgoingRefs.bind(this, 'outgoing');
  11829. /**
  11830. * The list of outgoing connections
  11831. *
  11832. * @name Base#incoming
  11833. * @type Array<Connection>
  11834. */
  11835. incomingRefs.bind(this, 'incoming');
  11836. }
  11837. /**
  11838. * A graphical object
  11839. *
  11840. * @class
  11841. * @constructor
  11842. *
  11843. * @extends Base
  11844. */
  11845. function Shape() {
  11846. Base.call(this);
  11847. /**
  11848. * The list of children
  11849. *
  11850. * @name Shape#children
  11851. * @type Array<Base>
  11852. */
  11853. parentRefs.bind(this, 'children');
  11854. /**
  11855. * @name Shape#host
  11856. * @type Shape
  11857. */
  11858. attacherRefs.bind(this, 'host');
  11859. /**
  11860. * @name Shape#attachers
  11861. * @type Shape
  11862. */
  11863. attacherRefs.bind(this, 'attachers');
  11864. }
  11865. inherits(Shape, Base);
  11866. /**
  11867. * A root graphical object
  11868. *
  11869. * @class
  11870. * @constructor
  11871. *
  11872. * @extends Shape
  11873. */
  11874. function Root() {
  11875. Shape.call(this);
  11876. }
  11877. inherits(Root, Shape);
  11878. /**
  11879. * A label for an element
  11880. *
  11881. * @class
  11882. * @constructor
  11883. *
  11884. * @extends Shape
  11885. */
  11886. function Label() {
  11887. Shape.call(this);
  11888. /**
  11889. * The labeled element
  11890. *
  11891. * @name Label#labelTarget
  11892. * @type Base
  11893. */
  11894. labelRefs.bind(this, 'labelTarget');
  11895. }
  11896. inherits(Label, Shape);
  11897. /**
  11898. * A connection between two elements
  11899. *
  11900. * @class
  11901. * @constructor
  11902. *
  11903. * @extends Base
  11904. */
  11905. function Connection() {
  11906. Base.call(this);
  11907. /**
  11908. * The element this connection originates from
  11909. *
  11910. * @name Connection#source
  11911. * @type Base
  11912. */
  11913. outgoingRefs.bind(this, 'source');
  11914. /**
  11915. * The element this connection points to
  11916. *
  11917. * @name Connection#target
  11918. * @type Base
  11919. */
  11920. incomingRefs.bind(this, 'target');
  11921. }
  11922. inherits(Connection, Base);
  11923. var types = {
  11924. connection: Connection,
  11925. shape: Shape,
  11926. label: Label,
  11927. root: Root
  11928. };
  11929. /**
  11930. * Creates a new model element of the specified type
  11931. *
  11932. * @method create
  11933. *
  11934. * @example
  11935. *
  11936. * var shape1 = Model.create('shape', { x: 10, y: 10, width: 100, height: 100 });
  11937. * var shape2 = Model.create('shape', { x: 210, y: 210, width: 100, height: 100 });
  11938. *
  11939. * var connection = Model.create('connection', { waypoints: [ { x: 110, y: 55 }, {x: 210, y: 55 } ] });
  11940. *
  11941. * @param {String} type lower-cased model name
  11942. * @param {Object} attrs attributes to initialize the new model instance with
  11943. *
  11944. * @return {Base} the new model instance
  11945. */
  11946. module.exports.create = function(type, attrs) {
  11947. var Type = types[type];
  11948. if (!Type) {
  11949. throw new Error('unknown type: <' + type + '>');
  11950. }
  11951. return assign(new Type(), attrs);
  11952. };
  11953. module.exports.Base = Base;
  11954. module.exports.Root = Root;
  11955. module.exports.Shape = Shape;
  11956. module.exports.Connection = Connection;
  11957. module.exports.Label = Label;
  11958. },{"168":168,"192":192,"72":72}],57:[function(_dereq_,module,exports){
  11959. 'use strict';
  11960. /**
  11961. * Failsafe remove an element from a collection
  11962. *
  11963. * @param {Array<Object>} [collection]
  11964. * @param {Object} [element]
  11965. *
  11966. * @return {Object} the element that got removed or undefined
  11967. */
  11968. module.exports.remove = function(collection, element) {
  11969. if (!collection || !element) {
  11970. return;
  11971. }
  11972. var idx = collection.indexOf(element);
  11973. if (idx === -1) {
  11974. return;
  11975. }
  11976. collection.splice(idx, 1);
  11977. return element;
  11978. };
  11979. /**
  11980. * Fail save add an element to the given connection, ensuring
  11981. * it does not yet exist.
  11982. *
  11983. * @param {Array<Object>} collection
  11984. * @param {Object} element
  11985. * @param {Number} idx
  11986. */
  11987. module.exports.add = function(collection, element, idx) {
  11988. if (!collection || !element) {
  11989. return;
  11990. }
  11991. if (isNaN(idx)) {
  11992. idx = -1;
  11993. }
  11994. var currentIdx = collection.indexOf(element);
  11995. if (currentIdx !== -1) {
  11996. if (currentIdx === idx) {
  11997. // nothing to do, position has not changed
  11998. return;
  11999. } else {
  12000. if (idx !== -1) {
  12001. // remove from current position
  12002. collection.splice(currentIdx, 1);
  12003. } else {
  12004. // already exists in collection
  12005. return;
  12006. }
  12007. }
  12008. }
  12009. if (idx !== -1) {
  12010. // insert at specified position
  12011. collection.splice(idx, 0, element);
  12012. } else {
  12013. // push to end
  12014. collection.push(element);
  12015. }
  12016. };
  12017. /**
  12018. * Fail get the index of an element in a collection.
  12019. *
  12020. * @param {Array<Object>} collection
  12021. * @param {Object} element
  12022. *
  12023. * @return {Number} the index or -1 if collection or element do
  12024. * not exist or the element is not contained.
  12025. */
  12026. module.exports.indexOf = function(collection, element) {
  12027. if (!collection || !element) {
  12028. return -1;
  12029. }
  12030. return collection.indexOf(element);
  12031. };
  12032. },{}],58:[function(_dereq_,module,exports){
  12033. 'use strict';
  12034. var isArray = _dereq_(159),
  12035. isNumber = _dereq_(162),
  12036. groupBy = _dereq_(78),
  12037. forEach = _dereq_(77);
  12038. /**
  12039. * Adds an element to a collection and returns true if the
  12040. * element was added.
  12041. *
  12042. * @param {Array<Object>} elements
  12043. * @param {Object} e
  12044. * @param {Boolean} unique
  12045. */
  12046. function add(elements, e, unique) {
  12047. var canAdd = !unique || elements.indexOf(e) === -1;
  12048. if (canAdd) {
  12049. elements.push(e);
  12050. }
  12051. return canAdd;
  12052. }
  12053. function eachElement(elements, fn, depth) {
  12054. depth = depth || 0;
  12055. forEach(elements, function(s, i) {
  12056. var filter = fn(s, i, depth);
  12057. if (isArray(filter) && filter.length) {
  12058. eachElement(filter, fn, depth + 1);
  12059. }
  12060. });
  12061. }
  12062. /**
  12063. * Collects self + child elements up to a given depth from a list of elements.
  12064. *
  12065. * @param {Array<djs.model.Base>} elements the elements to select the children from
  12066. * @param {Boolean} unique whether to return a unique result set (no duplicates)
  12067. * @param {Number} maxDepth the depth to search through or -1 for infinite
  12068. *
  12069. * @return {Array<djs.model.Base>} found elements
  12070. */
  12071. function selfAndChildren(elements, unique, maxDepth) {
  12072. var result = [],
  12073. processedChildren = [];
  12074. eachElement(elements, function(element, i, depth) {
  12075. add(result, element, unique);
  12076. var children = element.children;
  12077. // max traversal depth not reached yet
  12078. if (maxDepth === -1 || depth < maxDepth) {
  12079. // children exist && children not yet processed
  12080. if (children && add(processedChildren, children, unique)) {
  12081. return children;
  12082. }
  12083. }
  12084. });
  12085. return result;
  12086. }
  12087. /**
  12088. * Return self + direct children for a number of elements
  12089. *
  12090. * @param {Array<djs.model.Base>} elements to query
  12091. * @param {Boolean} allowDuplicates to allow duplicates in the result set
  12092. *
  12093. * @return {Array<djs.model.Base>} the collected elements
  12094. */
  12095. function selfAndDirectChildren(elements, allowDuplicates) {
  12096. return selfAndChildren(elements, !allowDuplicates, 1);
  12097. }
  12098. /**
  12099. * Return self + ALL children for a number of elements
  12100. *
  12101. * @param {Array<djs.model.Base>} elements to query
  12102. * @param {Boolean} allowDuplicates to allow duplicates in the result set
  12103. *
  12104. * @return {Array<djs.model.Base>} the collected elements
  12105. */
  12106. function selfAndAllChildren(elements, allowDuplicates) {
  12107. return selfAndChildren(elements, !allowDuplicates, -1);
  12108. }
  12109. /**
  12110. * Gets the the closure fo all selected elements,
  12111. * their connections and
  12112. *
  12113. * @param {Array<djs.model.Base>} elements
  12114. * @return {Object} enclosure
  12115. */
  12116. function getClosure(elements) {
  12117. // original elements passed to this function
  12118. var topLevel = groupBy(elements, function(e) { return e.id; });
  12119. var allShapes = {},
  12120. allConnections = {},
  12121. enclosedElements = {},
  12122. enclosedConnections = {};
  12123. function handleConnection(c) {
  12124. if (topLevel[c.source.id] && topLevel[c.target.id]) {
  12125. topLevel[c.id] = c;
  12126. }
  12127. // not enclosed as a child, but maybe logically
  12128. // (connecting two moved elements?)
  12129. if (allShapes[c.source.id] && allShapes[c.target.id]) {
  12130. enclosedConnections[c.id] = enclosedElements[c.id] = c;
  12131. }
  12132. allConnections[c.id] = c;
  12133. }
  12134. function handleElement(element) {
  12135. enclosedElements[element.id] = element;
  12136. if (element.waypoints) {
  12137. // remember connection
  12138. enclosedConnections[element.id] = allConnections[element.id] = element;
  12139. } else {
  12140. // remember shape
  12141. allShapes[element.id] = element;
  12142. // remember all connections
  12143. forEach(element.incoming, handleConnection);
  12144. forEach(element.outgoing, handleConnection);
  12145. // recurse into children
  12146. return element.children;
  12147. }
  12148. }
  12149. eachElement(elements, handleElement);
  12150. return {
  12151. allShapes: allShapes,
  12152. allConnections: allConnections,
  12153. topLevel: topLevel,
  12154. enclosedConnections: enclosedConnections,
  12155. enclosedElements: enclosedElements
  12156. };
  12157. }
  12158. /**
  12159. * Returns the surrounding bbox for all elements in the array or the element primitive.
  12160. */
  12161. function getBBox(elements, stopRecursion) {
  12162. stopRecursion = !!stopRecursion;
  12163. if (!isArray(elements)) {
  12164. elements = [elements];
  12165. }
  12166. var minX,
  12167. minY,
  12168. maxX,
  12169. maxY;
  12170. forEach(elements, function(element) {
  12171. // If element is a connection the bbox must be computed first
  12172. var bbox = element;
  12173. if (element.waypoints && !stopRecursion) {
  12174. bbox = getBBox(element.waypoints, true);
  12175. }
  12176. var x = bbox.x,
  12177. y = bbox.y,
  12178. height = bbox.height || 0,
  12179. width = bbox.width || 0;
  12180. if (x < minX || minX === undefined) {
  12181. minX = x;
  12182. }
  12183. if (y < minY || minY === undefined) {
  12184. minY = y;
  12185. }
  12186. if ((x + width) > maxX || maxX === undefined) {
  12187. maxX = x + width;
  12188. }
  12189. if ((y + height) > maxY || maxY === undefined) {
  12190. maxY = y + height;
  12191. }
  12192. });
  12193. return {
  12194. x: minX,
  12195. y: minY,
  12196. height: maxY - minY,
  12197. width: maxX - minX
  12198. };
  12199. }
  12200. /**
  12201. * Returns all elements that are enclosed from the bounding box.
  12202. *
  12203. * @param {Array<Object>} elements List of Elements to search through
  12204. * @param {Object} bbox the enclosing bbox.
  12205. * <ul>
  12206. * <li>If bbox.(width|height) is not specified
  12207. * the method returns all elements with element.x/y &gt; bbox.x/y
  12208. * </li>
  12209. * <li>If only bbox.x or bbox.y is specified, method return all elements with
  12210. * e.x &gt; bbox.x or e.y &gt; bbox.y.</li>
  12211. * </ul>
  12212. *
  12213. */
  12214. function getEnclosedElements(elements, bbox) {
  12215. var filteredElements = {};
  12216. forEach(elements, function(element) {
  12217. var e = element;
  12218. if (e.waypoints) {
  12219. e = getBBox(e);
  12220. }
  12221. if (!isNumber(bbox.y) && (e.x > bbox.x)) {
  12222. filteredElements[element.id] = element;
  12223. }
  12224. if (!isNumber(bbox.x) && (e.y > bbox.y)) {
  12225. filteredElements[element.id] = element;
  12226. }
  12227. if (e.x > bbox.x && e.y > bbox.y) {
  12228. if (isNumber(bbox.width) && isNumber(bbox.height) &&
  12229. e.width + e.x < bbox.width + bbox.x &&
  12230. e.height + e.y < bbox.height + bbox.y) {
  12231. filteredElements[element.id] = element;
  12232. } else if (!isNumber(bbox.width) || !isNumber(bbox.height)) {
  12233. filteredElements[element.id] = element;
  12234. }
  12235. }
  12236. });
  12237. return filteredElements;
  12238. }
  12239. module.exports.eachElement = eachElement;
  12240. module.exports.selfAndDirectChildren = selfAndDirectChildren;
  12241. module.exports.selfAndAllChildren = selfAndAllChildren;
  12242. module.exports.getBBox = getBBox;
  12243. module.exports.getEnclosedElements = getEnclosedElements;
  12244. module.exports.getClosure = getClosure;
  12245. },{"159":159,"162":162,"77":77,"78":78}],59:[function(_dereq_,module,exports){
  12246. 'use strict';
  12247. function __preventDefault(event) {
  12248. return event && event.preventDefault();
  12249. }
  12250. function __stopPropagation(event, immediate) {
  12251. if (!event) {
  12252. return;
  12253. }
  12254. if (event.stopPropagation) {
  12255. event.stopPropagation();
  12256. }
  12257. if (immediate && event.stopImmediatePropagation) {
  12258. event.stopImmediatePropagation();
  12259. }
  12260. }
  12261. function getOriginal(event) {
  12262. return event.originalEvent || event.srcEvent;
  12263. }
  12264. module.exports.getOriginal = getOriginal;
  12265. function stopEvent(event, immediate) {
  12266. stopPropagation(event, immediate);
  12267. preventDefault(event);
  12268. }
  12269. module.exports.stopEvent = stopEvent;
  12270. function preventDefault(event) {
  12271. __preventDefault(event);
  12272. __preventDefault(getOriginal(event));
  12273. }
  12274. module.exports.preventDefault = preventDefault;
  12275. function stopPropagation(event, immediate) {
  12276. __stopPropagation(event, immediate);
  12277. __stopPropagation(getOriginal(event), immediate);
  12278. }
  12279. module.exports.stopPropagation = stopPropagation;
  12280. function toPoint(event) {
  12281. if (event.pointers && event.pointers.length) {
  12282. event = event.pointers[0];
  12283. }
  12284. if (event.touches && event.touches.length) {
  12285. event = event.touches[0];
  12286. }
  12287. return event ? {
  12288. x: event.clientX,
  12289. y: event.clientY
  12290. } : null;
  12291. }
  12292. module.exports.toPoint = toPoint;
  12293. },{}],60:[function(_dereq_,module,exports){
  12294. 'use strict';
  12295. /**
  12296. * SVGs for elements are generated by the {@link GraphicsFactory}.
  12297. *
  12298. * This utility gives quick access to the important semantic
  12299. * parts of an element.
  12300. */
  12301. /**
  12302. * Returns the visual part of a diagram element
  12303. *
  12304. * @param {Snap<SVGElement>} gfx
  12305. *
  12306. * @return {Snap<SVGElement>}
  12307. */
  12308. function getVisual(gfx) {
  12309. return gfx.select('.djs-visual');
  12310. }
  12311. /**
  12312. * Returns the children for a given diagram element.
  12313. *
  12314. * @param {Snap<SVGElement>} gfx
  12315. * @return {Snap<SVGElement>}
  12316. */
  12317. function getChildren(gfx) {
  12318. return gfx.parent().children()[1];
  12319. }
  12320. /**
  12321. * Returns the visual bbox of an element
  12322. *
  12323. * @param {Snap<SVGElement>} gfx
  12324. *
  12325. * @return {Bounds}
  12326. */
  12327. function getBBox(gfx) {
  12328. return getVisual(gfx).select('*').getBBox();
  12329. }
  12330. module.exports.getVisual = getVisual;
  12331. module.exports.getChildren = getChildren;
  12332. module.exports.getBBox = getBBox;
  12333. },{}],61:[function(_dereq_,module,exports){
  12334. 'use strict';
  12335. /**
  12336. * Util that provides unique IDs.
  12337. *
  12338. * @class djs.util.IdGenerator
  12339. * @constructor
  12340. * @memberOf djs.util
  12341. *
  12342. * The ids can be customized via a given prefix and contain a random value to avoid collisions.
  12343. *
  12344. * @param {String} prefix a prefix to prepend to generated ids (for better readability)
  12345. */
  12346. function IdGenerator(prefix) {
  12347. this._counter = 0;
  12348. this._prefix = (prefix ? prefix + '-' : '') + Math.floor(Math.random() * 1000000000) + '-';
  12349. }
  12350. module.exports = IdGenerator;
  12351. /**
  12352. * Returns a next unique ID.
  12353. *
  12354. * @method djs.util.IdGenerator#next
  12355. *
  12356. * @returns {String} the id
  12357. */
  12358. IdGenerator.prototype.next = function() {
  12359. return this._prefix + (++this._counter);
  12360. };
  12361. },{}],62:[function(_dereq_,module,exports){
  12362. 'use strict';
  12363. var getOriginalEvent = _dereq_(59).getOriginal;
  12364. var isMac = _dereq_(63).isMac;
  12365. function isPrimaryButton(event) {
  12366. // button === 0 -> left áka primary mouse button
  12367. return !(getOriginalEvent(event) || event).button;
  12368. }
  12369. module.exports.isPrimaryButton = isPrimaryButton;
  12370. module.exports.isMac = isMac;
  12371. module.exports.hasPrimaryModifier = function(event) {
  12372. var originalEvent = getOriginalEvent(event) || event;
  12373. if (!isPrimaryButton(event)) {
  12374. return false;
  12375. }
  12376. // Use alt as primary modifier key for mac OS
  12377. if (isMac()) {
  12378. return originalEvent.altKey;
  12379. } else {
  12380. return originalEvent.ctrlKey;
  12381. }
  12382. };
  12383. module.exports.hasSecondaryModifier = function(event) {
  12384. var originalEvent = getOriginalEvent(event) || event;
  12385. return isPrimaryButton(event) && originalEvent.shiftKey;
  12386. };
  12387. },{"59":59,"63":63}],63:[function(_dereq_,module,exports){
  12388. 'use strict';
  12389. module.exports.isMac = function isMac() {
  12390. return (/mac/i).test(navigator.platform);
  12391. };
  12392. },{}],64:[function(_dereq_,module,exports){
  12393. 'use strict';
  12394. var isObject = _dereq_(163),
  12395. assign = _dereq_(168),
  12396. pick = _dereq_(174),
  12397. forEach = _dereq_(77),
  12398. reduce = _dereq_(81),
  12399. merge = _dereq_(171);
  12400. var Snap = _dereq_(67);
  12401. var DEFAULT_BOX_PADDING = 0;
  12402. var DEFAULT_LABEL_SIZE = {
  12403. width: 150,
  12404. height: 50
  12405. };
  12406. function parseAlign(align) {
  12407. var parts = align.split('-');
  12408. return {
  12409. horizontal: parts[0] || 'center',
  12410. vertical: parts[1] || 'top'
  12411. };
  12412. }
  12413. function parsePadding(padding) {
  12414. if (isObject(padding)) {
  12415. return assign({ top: 0, left: 0, right: 0, bottom: 0 }, padding);
  12416. } else {
  12417. return {
  12418. top: padding,
  12419. left: padding,
  12420. right: padding,
  12421. bottom: padding
  12422. };
  12423. }
  12424. }
  12425. function getTextBBox(text, fakeText) {
  12426. fakeText.textContent = text;
  12427. return pick(fakeText.getBBox(), [ 'width', 'height' ]);
  12428. }
  12429. /**
  12430. * Layout the next line and return the layouted element.
  12431. *
  12432. * Alters the lines passed.
  12433. *
  12434. * @param {Array<String>} lines
  12435. * @return {Object} the line descriptor, an object { width, height, text }
  12436. */
  12437. function layoutNext(lines, maxWidth, fakeText) {
  12438. var originalLine = lines.shift(),
  12439. fitLine = originalLine;
  12440. var textBBox;
  12441. while (true) {
  12442. textBBox = getTextBBox(fitLine, fakeText);
  12443. textBBox.width = fitLine ? textBBox.width : 0;
  12444. // try to fit
  12445. if (fitLine === ' ' || fitLine === '' || textBBox.width < Math.round(maxWidth) || fitLine.length < 4) {
  12446. return fit(lines, fitLine, originalLine, textBBox);
  12447. }
  12448. fitLine = shortenLine(fitLine, textBBox.width, maxWidth);
  12449. }
  12450. }
  12451. function fit(lines, fitLine, originalLine, textBBox) {
  12452. if (fitLine.length < originalLine.length) {
  12453. var nextLine = lines[0] || '',
  12454. remainder = originalLine.slice(fitLine.length).trim();
  12455. if (/-\s*$/.test(remainder)) {
  12456. nextLine = remainder.replace(/-\s*$/, '') + nextLine.replace(/^\s+/, '');
  12457. } else {
  12458. nextLine = remainder + ' ' + nextLine;
  12459. }
  12460. lines[0] = nextLine;
  12461. }
  12462. return { width: textBBox.width, height: textBBox.height, text: fitLine };
  12463. }
  12464. /**
  12465. * Shortens a line based on spacing and hyphens.
  12466. * Returns the shortened result on success.
  12467. *
  12468. * @param {String} line
  12469. * @param {Number} maxLength the maximum characters of the string
  12470. * @return {String} the shortened string
  12471. */
  12472. function semanticShorten(line, maxLength) {
  12473. var parts = line.split(/(\s|-)/g),
  12474. part,
  12475. shortenedParts = [],
  12476. length = 0;
  12477. // try to shorten via spaces + hyphens
  12478. if (parts.length > 1) {
  12479. while ((part = parts.shift())) {
  12480. if (part.length + length < maxLength) {
  12481. shortenedParts.push(part);
  12482. length += part.length;
  12483. } else {
  12484. // remove previous part, too if hyphen does not fit anymore
  12485. if (part === '-') {
  12486. shortenedParts.pop();
  12487. }
  12488. break;
  12489. }
  12490. }
  12491. }
  12492. return shortenedParts.join('');
  12493. }
  12494. function shortenLine(line, width, maxWidth) {
  12495. var length = Math.max(line.length * (maxWidth / width), 1);
  12496. // try to shorten semantically (i.e. based on spaces and hyphens)
  12497. var shortenedLine = semanticShorten(line, length);
  12498. if (!shortenedLine) {
  12499. // force shorten by cutting the long word
  12500. shortenedLine = line.slice(0, Math.max(Math.round(length - 1), 1));
  12501. }
  12502. return shortenedLine;
  12503. }
  12504. /**
  12505. * Creates a new label utility
  12506. *
  12507. * @param {Object} config
  12508. * @param {Dimensions} config.size
  12509. * @param {Number} config.padding
  12510. * @param {Object} config.style
  12511. * @param {String} config.align
  12512. */
  12513. function Text(config) {
  12514. this._config = assign({}, {
  12515. size: DEFAULT_LABEL_SIZE,
  12516. padding: DEFAULT_BOX_PADDING,
  12517. style: {},
  12518. align: 'center-top'
  12519. }, config || {});
  12520. }
  12521. /**
  12522. * Create a label in the parent node.
  12523. *
  12524. * @method Text#createText
  12525. *
  12526. * @param {SVGElement} parent the parent to draw the label on
  12527. * @param {String} text the text to render on the label
  12528. * @param {Object} options
  12529. * @param {String} options.align how to align in the bounding box.
  12530. * Any of { 'center-middle', 'center-top' }, defaults to 'center-top'.
  12531. * @param {String} options.style style to be applied to the text
  12532. *
  12533. * @return {SVGText} the text element created
  12534. */
  12535. Text.prototype.createText = function(parent, text, options) {
  12536. var box = merge({}, this._config.size, options.box || {}),
  12537. style = merge({}, this._config.style, options.style || {}),
  12538. align = parseAlign(options.align || this._config.align),
  12539. padding = parsePadding(options.padding !== undefined ? options.padding : this._config.padding);
  12540. var lines = text.split(/\r?\n/g),
  12541. layouted = [];
  12542. var maxWidth = box.width - padding.left - padding.right;
  12543. // FF regression: ensure text is shown during rendering
  12544. // by attaching it directly to the body
  12545. var fakeText = parent.paper.text(0, 0, '').attr(style).node;
  12546. while (lines.length) {
  12547. layouted.push(layoutNext(lines, maxWidth, fakeText));
  12548. }
  12549. var totalHeight = reduce(layouted, function(sum, line, idx) {
  12550. return sum + line.height;
  12551. }, 0);
  12552. // the y position of the next line
  12553. var y, x;
  12554. switch (align.vertical) {
  12555. case 'middle':
  12556. y = (box.height - totalHeight) / 2 - layouted[0].height / 4;
  12557. break;
  12558. default:
  12559. y = padding.top;
  12560. }
  12561. var textElement = parent.text().attr(style);
  12562. forEach(layouted, function(line) {
  12563. y += line.height;
  12564. switch (align.horizontal) {
  12565. case 'left':
  12566. x = padding.left;
  12567. break;
  12568. case 'right':
  12569. x = (maxWidth - padding.right - line.width);
  12570. break;
  12571. default:
  12572. // aka center
  12573. x = Math.max(((maxWidth - line.width) / 2 + padding.left), 0);
  12574. }
  12575. var tspan = Snap.create('tspan', { x: x, y: y }).node;
  12576. tspan.textContent = line.text;
  12577. textElement.append(tspan);
  12578. });
  12579. // remove fake text
  12580. fakeText.parentNode.removeChild(fakeText);
  12581. return textElement;
  12582. };
  12583. module.exports = Text;
  12584. },{"163":163,"168":168,"171":171,"174":174,"67":67,"77":77,"81":81}],65:[function(_dereq_,module,exports){
  12585. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  12586. //
  12587. // Licensed under the Apache License, Version 2.0 (the "License");
  12588. // you may not use this file except in compliance with the License.
  12589. // You may obtain a copy of the License at
  12590. //
  12591. // http://www.apache.org/licenses/LICENSE-2.0
  12592. //
  12593. // Unless required by applicable law or agreed to in writing, software
  12594. // distributed under the License is distributed on an "AS IS" BASIS,
  12595. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12596. // See the License for the specific language governing permissions and
  12597. // limitations under the License.
  12598. // ┌────────────────────────────────────────────────────────────┐ \\
  12599. // │ Eve 0.4.2 - JavaScript Events Library │ \\
  12600. // ├────────────────────────────────────────────────────────────┤ \\
  12601. // │ Author Dmitry Baranovskiy (http://dmitry.baranovskiy.com/) │ \\
  12602. // └────────────────────────────────────────────────────────────┘ \\
  12603. (function (glob) {
  12604. var version = "0.4.2",
  12605. has = "hasOwnProperty",
  12606. separator = /[\.\/]/,
  12607. comaseparator = /\s*,\s*/,
  12608. wildcard = "*",
  12609. fun = function () {},
  12610. numsort = function (a, b) {
  12611. return a - b;
  12612. },
  12613. current_event,
  12614. stop,
  12615. events = {n: {}},
  12616. firstDefined = function () {
  12617. for (var i = 0, ii = this.length; i < ii; i++) {
  12618. if (typeof this[i] != "undefined") {
  12619. return this[i];
  12620. }
  12621. }
  12622. },
  12623. lastDefined = function () {
  12624. var i = this.length;
  12625. while (--i) {
  12626. if (typeof this[i] != "undefined") {
  12627. return this[i];
  12628. }
  12629. }
  12630. },
  12631. /*\
  12632. * eve
  12633. [ method ]
  12634. * Fires event with given `name`, given scope and other parameters.
  12635. > Arguments
  12636. - name (string) name of the *event*, dot (`.`) or slash (`/`) separated
  12637. - scope (object) context for the event handlers
  12638. - varargs (...) the rest of arguments will be sent to event handlers
  12639. = (object) array of returned values from the listeners. Array has two methods `.firstDefined()` and `.lastDefined()` to get first or last not `undefined` value.
  12640. \*/
  12641. eve = function (name, scope) {
  12642. name = String(name);
  12643. var e = events,
  12644. oldstop = stop,
  12645. args = Array.prototype.slice.call(arguments, 2),
  12646. listeners = eve.listeners(name),
  12647. z = 0,
  12648. f = false,
  12649. l,
  12650. indexed = [],
  12651. queue = {},
  12652. out = [],
  12653. ce = current_event,
  12654. errors = [];
  12655. out.firstDefined = firstDefined;
  12656. out.lastDefined = lastDefined;
  12657. current_event = name;
  12658. stop = 0;
  12659. for (var i = 0, ii = listeners.length; i < ii; i++) if ("zIndex" in listeners[i]) {
  12660. indexed.push(listeners[i].zIndex);
  12661. if (listeners[i].zIndex < 0) {
  12662. queue[listeners[i].zIndex] = listeners[i];
  12663. }
  12664. }
  12665. indexed.sort(numsort);
  12666. while (indexed[z] < 0) {
  12667. l = queue[indexed[z++]];
  12668. out.push(l.apply(scope, args));
  12669. if (stop) {
  12670. stop = oldstop;
  12671. return out;
  12672. }
  12673. }
  12674. for (i = 0; i < ii; i++) {
  12675. l = listeners[i];
  12676. if ("zIndex" in l) {
  12677. if (l.zIndex == indexed[z]) {
  12678. out.push(l.apply(scope, args));
  12679. if (stop) {
  12680. break;
  12681. }
  12682. do {
  12683. z++;
  12684. l = queue[indexed[z]];
  12685. l && out.push(l.apply(scope, args));
  12686. if (stop) {
  12687. break;
  12688. }
  12689. } while (l)
  12690. } else {
  12691. queue[l.zIndex] = l;
  12692. }
  12693. } else {
  12694. out.push(l.apply(scope, args));
  12695. if (stop) {
  12696. break;
  12697. }
  12698. }
  12699. }
  12700. stop = oldstop;
  12701. current_event = ce;
  12702. return out;
  12703. };
  12704. // Undocumented. Debug only.
  12705. eve._events = events;
  12706. /*\
  12707. * eve.listeners
  12708. [ method ]
  12709. * Internal method which gives you array of all event handlers that will be triggered by the given `name`.
  12710. > Arguments
  12711. - name (string) name of the event, dot (`.`) or slash (`/`) separated
  12712. = (array) array of event handlers
  12713. \*/
  12714. eve.listeners = function (name) {
  12715. var names = name.split(separator),
  12716. e = events,
  12717. item,
  12718. items,
  12719. k,
  12720. i,
  12721. ii,
  12722. j,
  12723. jj,
  12724. nes,
  12725. es = [e],
  12726. out = [];
  12727. for (i = 0, ii = names.length; i < ii; i++) {
  12728. nes = [];
  12729. for (j = 0, jj = es.length; j < jj; j++) {
  12730. e = es[j].n;
  12731. items = [e[names[i]], e[wildcard]];
  12732. k = 2;
  12733. while (k--) {
  12734. item = items[k];
  12735. if (item) {
  12736. nes.push(item);
  12737. out = out.concat(item.f || []);
  12738. }
  12739. }
  12740. }
  12741. es = nes;
  12742. }
  12743. return out;
  12744. };
  12745. /*\
  12746. * eve.on
  12747. [ method ]
  12748. **
  12749. * Binds given event handler with a given name. You can use wildcards “`*`” for the names:
  12750. | eve.on("*.under.*", f);
  12751. | eve("mouse.under.floor"); // triggers f
  12752. * Use @eve to trigger the listener.
  12753. **
  12754. > Arguments
  12755. **
  12756. - name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards
  12757. - f (function) event handler function
  12758. **
  12759. = (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.
  12760. > Example:
  12761. | eve.on("mouse", eatIt)(2);
  12762. | eve.on("mouse", scream);
  12763. | eve.on("mouse", catchIt)(1);
  12764. * This will ensure that `catchIt` function will be called before `eatIt`.
  12765. *
  12766. * If you want to put your handler before non-indexed handlers, specify a negative value.
  12767. * 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”.
  12768. \*/
  12769. eve.on = function (name, f) {
  12770. name = String(name);
  12771. if (typeof f != "function") {
  12772. return function () {};
  12773. }
  12774. var names = name.split(comaseparator);
  12775. for (var i = 0, ii = names.length; i < ii; i++) {
  12776. (function (name) {
  12777. var names = name.split(separator),
  12778. e = events,
  12779. exist;
  12780. for (var i = 0, ii = names.length; i < ii; i++) {
  12781. e = e.n;
  12782. e = e.hasOwnProperty(names[i]) && e[names[i]] || (e[names[i]] = {n: {}});
  12783. }
  12784. e.f = e.f || [];
  12785. for (i = 0, ii = e.f.length; i < ii; i++) if (e.f[i] == f) {
  12786. exist = true;
  12787. break;
  12788. }
  12789. !exist && e.f.push(f);
  12790. }(names[i]));
  12791. }
  12792. return function (zIndex) {
  12793. if (+zIndex == +zIndex) {
  12794. f.zIndex = +zIndex;
  12795. }
  12796. };
  12797. };
  12798. /*\
  12799. * eve.f
  12800. [ method ]
  12801. **
  12802. * Returns function that will fire given event with optional arguments.
  12803. * Arguments that will be passed to the result function will be also
  12804. * concated to the list of final arguments.
  12805. | el.onclick = eve.f("click", 1, 2);
  12806. | eve.on("click", function (a, b, c) {
  12807. | console.log(a, b, c); // 1, 2, [event object]
  12808. | });
  12809. > Arguments
  12810. - event (string) event name
  12811. - varargs (…) and any other arguments
  12812. = (function) possible event handler function
  12813. \*/
  12814. eve.f = function (event) {
  12815. var attrs = [].slice.call(arguments, 1);
  12816. return function () {
  12817. eve.apply(null, [event, null].concat(attrs).concat([].slice.call(arguments, 0)));
  12818. };
  12819. };
  12820. /*\
  12821. * eve.stop
  12822. [ method ]
  12823. **
  12824. * Is used inside an event handler to stop the event, preventing any subsequent listeners from firing.
  12825. \*/
  12826. eve.stop = function () {
  12827. stop = 1;
  12828. };
  12829. /*\
  12830. * eve.nt
  12831. [ method ]
  12832. **
  12833. * Could be used inside event handler to figure out actual name of the event.
  12834. **
  12835. > Arguments
  12836. **
  12837. - subname (string) #optional subname of the event
  12838. **
  12839. = (string) name of the event, if `subname` is not specified
  12840. * or
  12841. = (boolean) `true`, if current event’s name contains `subname`
  12842. \*/
  12843. eve.nt = function (subname) {
  12844. if (subname) {
  12845. return new RegExp("(?:\\.|\\/|^)" + subname + "(?:\\.|\\/|$)").test(current_event);
  12846. }
  12847. return current_event;
  12848. };
  12849. /*\
  12850. * eve.nts
  12851. [ method ]
  12852. **
  12853. * Could be used inside event handler to figure out actual name of the event.
  12854. **
  12855. **
  12856. = (array) names of the event
  12857. \*/
  12858. eve.nts = function () {
  12859. return current_event.split(separator);
  12860. };
  12861. /*\
  12862. * eve.off
  12863. [ method ]
  12864. **
  12865. * Removes given function from the list of event listeners assigned to given name.
  12866. * If no arguments specified all the events will be cleared.
  12867. **
  12868. > Arguments
  12869. **
  12870. - name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards
  12871. - f (function) event handler function
  12872. \*/
  12873. /*\
  12874. * eve.unbind
  12875. [ method ]
  12876. **
  12877. * See @eve.off
  12878. \*/
  12879. eve.off = eve.unbind = function (name, f) {
  12880. if (!name) {
  12881. eve._events = events = {n: {}};
  12882. return;
  12883. }
  12884. var names = name.split(comaseparator);
  12885. if (names.length > 1) {
  12886. for (var i = 0, ii = names.length; i < ii; i++) {
  12887. eve.off(names[i], f);
  12888. }
  12889. return;
  12890. }
  12891. names = name.split(separator);
  12892. var e,
  12893. key,
  12894. splice,
  12895. i, ii, j, jj,
  12896. cur = [events];
  12897. for (i = 0, ii = names.length; i < ii; i++) {
  12898. for (j = 0; j < cur.length; j += splice.length - 2) {
  12899. splice = [j, 1];
  12900. e = cur[j].n;
  12901. if (names[i] != wildcard) {
  12902. if (e[names[i]]) {
  12903. splice.push(e[names[i]]);
  12904. }
  12905. } else {
  12906. for (key in e) if (e[has](key)) {
  12907. splice.push(e[key]);
  12908. }
  12909. }
  12910. cur.splice.apply(cur, splice);
  12911. }
  12912. }
  12913. for (i = 0, ii = cur.length; i < ii; i++) {
  12914. e = cur[i];
  12915. while (e.n) {
  12916. if (f) {
  12917. if (e.f) {
  12918. for (j = 0, jj = e.f.length; j < jj; j++) if (e.f[j] == f) {
  12919. e.f.splice(j, 1);
  12920. break;
  12921. }
  12922. !e.f.length && delete e.f;
  12923. }
  12924. for (key in e.n) if (e.n[has](key) && e.n[key].f) {
  12925. var funcs = e.n[key].f;
  12926. for (j = 0, jj = funcs.length; j < jj; j++) if (funcs[j] == f) {
  12927. funcs.splice(j, 1);
  12928. break;
  12929. }
  12930. !funcs.length && delete e.n[key].f;
  12931. }
  12932. } else {
  12933. delete e.f;
  12934. for (key in e.n) if (e.n[has](key) && e.n[key].f) {
  12935. delete e.n[key].f;
  12936. }
  12937. }
  12938. e = e.n;
  12939. }
  12940. }
  12941. };
  12942. /*\
  12943. * eve.once
  12944. [ method ]
  12945. **
  12946. * Binds given event handler with a given name to only run once then unbind itself.
  12947. | eve.once("login", f);
  12948. | eve("login"); // triggers f
  12949. | eve("login"); // no listeners
  12950. * Use @eve to trigger the listener.
  12951. **
  12952. > Arguments
  12953. **
  12954. - name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards
  12955. - f (function) event handler function
  12956. **
  12957. = (function) same return function as @eve.on
  12958. \*/
  12959. eve.once = function (name, f) {
  12960. var f2 = function () {
  12961. eve.unbind(name, f2);
  12962. return f.apply(this, arguments);
  12963. };
  12964. return eve.on(name, f2);
  12965. };
  12966. /*\
  12967. * eve.version
  12968. [ property (string) ]
  12969. **
  12970. * Current version of the library.
  12971. \*/
  12972. eve.version = version;
  12973. eve.toString = function () {
  12974. return "You are running Eve " + version;
  12975. };
  12976. (typeof module != "undefined" && module.exports) ? (module.exports = eve) : (typeof define === "function" && define.amd ? (define("eve", [], function() { return eve; })) : (glob.eve = eve));
  12977. })(this);
  12978. },{}],66:[function(_dereq_,module,exports){
  12979. // Snap.svg 0.3.0
  12980. //
  12981. // Copyright (c) 2013 – 2014 Adobe Systems Incorporated. All rights reserved.
  12982. //
  12983. // Licensed under the Apache License, Version 2.0 (the "License");
  12984. // you may not use this file except in compliance with the License.
  12985. // You may obtain a copy of the License at
  12986. //
  12987. // http://www.apache.org/licenses/LICENSE-2.0
  12988. //
  12989. // Unless required by applicable law or agreed to in writing, software
  12990. // distributed under the License is distributed on an "AS IS" BASIS,
  12991. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12992. // See the License for the specific language governing permissions and
  12993. // limitations under the License.
  12994. //
  12995. // build: 2014-09-08
  12996. (function (glob, factory) {
  12997. // AMD support
  12998. if (typeof define === "function" && define.amd) {
  12999. // Define as an anonymous module
  13000. define(["eve"], function( eve ) {
  13001. return factory(glob, eve);
  13002. });
  13003. } else if (typeof exports !== 'undefined') {
  13004. // Next for Node.js or CommonJS
  13005. var eve = _dereq_(65);
  13006. module.exports = factory(glob, eve);
  13007. } else {
  13008. // Browser globals (glob is window)
  13009. // Snap adds itself to window
  13010. factory(glob, glob.eve);
  13011. }
  13012. }(window || this, function (window, eve) {
  13013. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  13014. //
  13015. // Licensed under the Apache License, Version 2.0 (the "License");
  13016. // you may not use this file except in compliance with the License.
  13017. // You may obtain a copy of the License at
  13018. //
  13019. // http://www.apache.org/licenses/LICENSE-2.0
  13020. //
  13021. // Unless required by applicable law or agreed to in writing, software
  13022. // distributed under the License is distributed on an "AS IS" BASIS,
  13023. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13024. // See the License for the specific language governing permissions and
  13025. // limitations under the License.
  13026. var mina = (function (eve) {
  13027. var animations = {},
  13028. requestAnimFrame = window.requestAnimationFrame ||
  13029. window.webkitRequestAnimationFrame ||
  13030. window.mozRequestAnimationFrame ||
  13031. window.oRequestAnimationFrame ||
  13032. window.msRequestAnimationFrame ||
  13033. function (callback) {
  13034. setTimeout(callback, 16);
  13035. },
  13036. isArray = Array.isArray || function (a) {
  13037. return a instanceof Array ||
  13038. Object.prototype.toString.call(a) == "[object Array]";
  13039. },
  13040. idgen = 0,
  13041. idprefix = "M" + (+new Date).toString(36),
  13042. ID = function () {
  13043. return idprefix + (idgen++).toString(36);
  13044. },
  13045. diff = function (a, b, A, B) {
  13046. if (isArray(a)) {
  13047. res = [];
  13048. for (var i = 0, ii = a.length; i < ii; i++) {
  13049. res[i] = diff(a[i], b, A[i], B);
  13050. }
  13051. return res;
  13052. }
  13053. var dif = (A - a) / (B - b);
  13054. return function (bb) {
  13055. return a + dif * (bb - b);
  13056. };
  13057. },
  13058. timer = Date.now || function () {
  13059. return +new Date;
  13060. },
  13061. sta = function (val) {
  13062. var a = this;
  13063. if (val == null) {
  13064. return a.s;
  13065. }
  13066. var ds = a.s - val;
  13067. a.b += a.dur * ds;
  13068. a.B += a.dur * ds;
  13069. a.s = val;
  13070. },
  13071. speed = function (val) {
  13072. var a = this;
  13073. if (val == null) {
  13074. return a.spd;
  13075. }
  13076. a.spd = val;
  13077. },
  13078. duration = function (val) {
  13079. var a = this;
  13080. if (val == null) {
  13081. return a.dur;
  13082. }
  13083. a.s = a.s * val / a.dur;
  13084. a.dur = val;
  13085. },
  13086. stopit = function () {
  13087. var a = this;
  13088. delete animations[a.id];
  13089. a.update();
  13090. eve("mina.stop." + a.id, a);
  13091. },
  13092. pause = function () {
  13093. var a = this;
  13094. if (a.pdif) {
  13095. return;
  13096. }
  13097. delete animations[a.id];
  13098. a.update();
  13099. a.pdif = a.get() - a.b;
  13100. },
  13101. resume = function () {
  13102. var a = this;
  13103. if (!a.pdif) {
  13104. return;
  13105. }
  13106. a.b = a.get() - a.pdif;
  13107. delete a.pdif;
  13108. animations[a.id] = a;
  13109. },
  13110. update = function () {
  13111. var a = this,
  13112. res;
  13113. if (isArray(a.start)) {
  13114. res = [];
  13115. for (var j = 0, jj = a.start.length; j < jj; j++) {
  13116. res[j] = +a.start[j] +
  13117. (a.end[j] - a.start[j]) * a.easing(a.s);
  13118. }
  13119. } else {
  13120. res = +a.start + (a.end - a.start) * a.easing(a.s);
  13121. }
  13122. a.set(res);
  13123. },
  13124. frame = function () {
  13125. var len = 0;
  13126. for (var i in animations) if (animations.hasOwnProperty(i)) {
  13127. var a = animations[i],
  13128. b = a.get(),
  13129. res;
  13130. len++;
  13131. a.s = (b - a.b) / (a.dur / a.spd);
  13132. if (a.s >= 1) {
  13133. delete animations[i];
  13134. a.s = 1;
  13135. len--;
  13136. (function (a) {
  13137. setTimeout(function () {
  13138. eve("mina.finish." + a.id, a);
  13139. });
  13140. }(a));
  13141. }
  13142. a.update();
  13143. }
  13144. len && requestAnimFrame(frame);
  13145. },
  13146. /*\
  13147. * mina
  13148. [ method ]
  13149. **
  13150. * Generic animation of numbers
  13151. **
  13152. - a (number) start _slave_ number
  13153. - A (number) end _slave_ number
  13154. - b (number) start _master_ number (start time in general case)
  13155. - B (number) end _master_ number (end time in gereal case)
  13156. - get (function) getter of _master_ number (see @mina.time)
  13157. - set (function) setter of _slave_ number
  13158. - easing (function) #optional easing function, default is @mina.linear
  13159. = (object) animation descriptor
  13160. o {
  13161. o id (string) animation id,
  13162. o start (number) start _slave_ number,
  13163. o end (number) end _slave_ number,
  13164. o b (number) start _master_ number,
  13165. o s (number) animation status (0..1),
  13166. o dur (number) animation duration,
  13167. o spd (number) animation speed,
  13168. o get (function) getter of _master_ number (see @mina.time),
  13169. o set (function) setter of _slave_ number,
  13170. o easing (function) easing function, default is @mina.linear,
  13171. o status (function) status getter/setter,
  13172. o speed (function) speed getter/setter,
  13173. o duration (function) duration getter/setter,
  13174. o stop (function) animation stopper
  13175. o pause (function) pauses the animation
  13176. o resume (function) resumes the animation
  13177. o update (function) calles setter with the right value of the animation
  13178. o }
  13179. \*/
  13180. mina = function (a, A, b, B, get, set, easing) {
  13181. var anim = {
  13182. id: ID(),
  13183. start: a,
  13184. end: A,
  13185. b: b,
  13186. s: 0,
  13187. dur: B - b,
  13188. spd: 1,
  13189. get: get,
  13190. set: set,
  13191. easing: easing || mina.linear,
  13192. status: sta,
  13193. speed: speed,
  13194. duration: duration,
  13195. stop: stopit,
  13196. pause: pause,
  13197. resume: resume,
  13198. update: update
  13199. };
  13200. animations[anim.id] = anim;
  13201. var len = 0, i;
  13202. for (i in animations) if (animations.hasOwnProperty(i)) {
  13203. len++;
  13204. if (len == 2) {
  13205. break;
  13206. }
  13207. }
  13208. len == 1 && requestAnimFrame(frame);
  13209. return anim;
  13210. };
  13211. /*\
  13212. * mina.time
  13213. [ method ]
  13214. **
  13215. * Returns the current time. Equivalent to:
  13216. | function () {
  13217. | return (new Date).getTime();
  13218. | }
  13219. \*/
  13220. mina.time = timer;
  13221. /*\
  13222. * mina.getById
  13223. [ method ]
  13224. **
  13225. * Returns an animation by its id
  13226. - id (string) animation's id
  13227. = (object) See @mina
  13228. \*/
  13229. mina.getById = function (id) {
  13230. return animations[id] || null;
  13231. };
  13232. /*\
  13233. * mina.linear
  13234. [ method ]
  13235. **
  13236. * Default linear easing
  13237. - n (number) input 0..1
  13238. = (number) output 0..1
  13239. \*/
  13240. mina.linear = function (n) {
  13241. return n;
  13242. };
  13243. /*\
  13244. * mina.easeout
  13245. [ method ]
  13246. **
  13247. * Easeout easing
  13248. - n (number) input 0..1
  13249. = (number) output 0..1
  13250. \*/
  13251. mina.easeout = function (n) {
  13252. return Math.pow(n, 1.7);
  13253. };
  13254. /*\
  13255. * mina.easein
  13256. [ method ]
  13257. **
  13258. * Easein easing
  13259. - n (number) input 0..1
  13260. = (number) output 0..1
  13261. \*/
  13262. mina.easein = function (n) {
  13263. return Math.pow(n, .48);
  13264. };
  13265. /*\
  13266. * mina.easeinout
  13267. [ method ]
  13268. **
  13269. * Easeinout easing
  13270. - n (number) input 0..1
  13271. = (number) output 0..1
  13272. \*/
  13273. mina.easeinout = function (n) {
  13274. if (n == 1) {
  13275. return 1;
  13276. }
  13277. if (n == 0) {
  13278. return 0;
  13279. }
  13280. var q = .48 - n / 1.04,
  13281. Q = Math.sqrt(.1734 + q * q),
  13282. x = Q - q,
  13283. X = Math.pow(Math.abs(x), 1 / 3) * (x < 0 ? -1 : 1),
  13284. y = -Q - q,
  13285. Y = Math.pow(Math.abs(y), 1 / 3) * (y < 0 ? -1 : 1),
  13286. t = X + Y + .5;
  13287. return (1 - t) * 3 * t * t + t * t * t;
  13288. };
  13289. /*\
  13290. * mina.backin
  13291. [ method ]
  13292. **
  13293. * Backin easing
  13294. - n (number) input 0..1
  13295. = (number) output 0..1
  13296. \*/
  13297. mina.backin = function (n) {
  13298. if (n == 1) {
  13299. return 1;
  13300. }
  13301. var s = 1.70158;
  13302. return n * n * ((s + 1) * n - s);
  13303. };
  13304. /*\
  13305. * mina.backout
  13306. [ method ]
  13307. **
  13308. * Backout easing
  13309. - n (number) input 0..1
  13310. = (number) output 0..1
  13311. \*/
  13312. mina.backout = function (n) {
  13313. if (n == 0) {
  13314. return 0;
  13315. }
  13316. n = n - 1;
  13317. var s = 1.70158;
  13318. return n * n * ((s + 1) * n + s) + 1;
  13319. };
  13320. /*\
  13321. * mina.elastic
  13322. [ method ]
  13323. **
  13324. * Elastic easing
  13325. - n (number) input 0..1
  13326. = (number) output 0..1
  13327. \*/
  13328. mina.elastic = function (n) {
  13329. if (n == !!n) {
  13330. return n;
  13331. }
  13332. return Math.pow(2, -10 * n) * Math.sin((n - .075) *
  13333. (2 * Math.PI) / .3) + 1;
  13334. };
  13335. /*\
  13336. * mina.bounce
  13337. [ method ]
  13338. **
  13339. * Bounce easing
  13340. - n (number) input 0..1
  13341. = (number) output 0..1
  13342. \*/
  13343. mina.bounce = function (n) {
  13344. var s = 7.5625,
  13345. p = 2.75,
  13346. l;
  13347. if (n < (1 / p)) {
  13348. l = s * n * n;
  13349. } else {
  13350. if (n < (2 / p)) {
  13351. n -= (1.5 / p);
  13352. l = s * n * n + .75;
  13353. } else {
  13354. if (n < (2.5 / p)) {
  13355. n -= (2.25 / p);
  13356. l = s * n * n + .9375;
  13357. } else {
  13358. n -= (2.625 / p);
  13359. l = s * n * n + .984375;
  13360. }
  13361. }
  13362. }
  13363. return l;
  13364. };
  13365. window.mina = mina;
  13366. return mina;
  13367. })(typeof eve == "undefined" ? function () {} : eve);
  13368. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  13369. //
  13370. // Licensed under the Apache License, Version 2.0 (the "License");
  13371. // you may not use this file except in compliance with the License.
  13372. // You may obtain a copy of the License at
  13373. //
  13374. // http://www.apache.org/licenses/LICENSE-2.0
  13375. //
  13376. // Unless required by applicable law or agreed to in writing, software
  13377. // distributed under the License is distributed on an "AS IS" BASIS,
  13378. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13379. // See the License for the specific language governing permissions and
  13380. // limitations under the License.
  13381. var Snap = (function(root) {
  13382. Snap.version = "0.3.0";
  13383. /*\
  13384. * Snap
  13385. [ method ]
  13386. **
  13387. * Creates a drawing surface or wraps existing SVG element.
  13388. **
  13389. - width (number|string) width of surface
  13390. - height (number|string) height of surface
  13391. * or
  13392. - DOM (SVGElement) element to be wrapped into Snap structure
  13393. * or
  13394. - array (array) array of elements (will return set of elements)
  13395. * or
  13396. - query (string) CSS query selector
  13397. = (object) @Element
  13398. \*/
  13399. function Snap(w, h) {
  13400. if (w) {
  13401. if (w.tagName) {
  13402. return wrap(w);
  13403. }
  13404. if (is(w, "array") && Snap.set) {
  13405. return Snap.set.apply(Snap, w);
  13406. }
  13407. if (w instanceof Element) {
  13408. return w;
  13409. }
  13410. if (h == null) {
  13411. w = glob.doc.querySelector(w);
  13412. return wrap(w);
  13413. }
  13414. }
  13415. w = w == null ? "100%" : w;
  13416. h = h == null ? "100%" : h;
  13417. return new Paper(w, h);
  13418. }
  13419. Snap.toString = function () {
  13420. return "Snap v" + this.version;
  13421. };
  13422. Snap._ = {};
  13423. var glob = {
  13424. win: root.window,
  13425. doc: root.window.document
  13426. };
  13427. Snap._.glob = glob;
  13428. var has = "hasOwnProperty",
  13429. Str = String,
  13430. toFloat = parseFloat,
  13431. toInt = parseInt,
  13432. math = Math,
  13433. mmax = math.max,
  13434. mmin = math.min,
  13435. abs = math.abs,
  13436. pow = math.pow,
  13437. PI = math.PI,
  13438. round = math.round,
  13439. E = "",
  13440. S = " ",
  13441. objectToString = Object.prototype.toString,
  13442. ISURL = /^url\(['"]?([^\)]+?)['"]?\)$/i,
  13443. 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,
  13444. bezierrg = /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,
  13445. reURLValue = /^url\(#?([^)]+)\)$/,
  13446. separator = Snap._.separator = /[,\s]+/,
  13447. whitespace = /[\s]/g,
  13448. commaSpaces = /[\s]*,[\s]*/,
  13449. hsrg = {hs: 1, rg: 1},
  13450. pathCommand = /([a-z])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\s]*,?[\s]*)+)/ig,
  13451. tCommand = /([rstm])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\s]*,?[\s]*)+)/ig,
  13452. pathValues = /(-?\d*\.?\d*(?:e[\-+]?\\d+)?)[\s]*,?[\s]*/ig,
  13453. idgen = 0,
  13454. idprefix = "S" + (+new Date).toString(36),
  13455. ID = function (el) {
  13456. return (el && el.type ? el.type : E) + idprefix + (idgen++).toString(36);
  13457. },
  13458. xlink = "http://www.w3.org/1999/xlink",
  13459. xmlns = "http://www.w3.org/2000/svg",
  13460. hub = {},
  13461. URL = Snap.url = function (url) {
  13462. return "url('#" + url + "')";
  13463. };
  13464. function $(el, attr) {
  13465. if (attr) {
  13466. if (el == "#text") {
  13467. el = glob.doc.createTextNode(attr.text || "");
  13468. }
  13469. if (typeof el == "string") {
  13470. el = $(el);
  13471. }
  13472. if (typeof attr == "string") {
  13473. if (attr.substring(0, 6) == "xlink:") {
  13474. return el.getAttributeNS(xlink, attr.substring(6));
  13475. }
  13476. if (attr.substring(0, 4) == "xml:") {
  13477. return el.getAttributeNS(xmlns, attr.substring(4));
  13478. }
  13479. return el.getAttribute(attr);
  13480. }
  13481. for (var key in attr) if (attr[has](key)) {
  13482. var val = Str(attr[key]);
  13483. if (val) {
  13484. if (key.substring(0, 6) == "xlink:") {
  13485. el.setAttributeNS(xlink, key.substring(6), val);
  13486. } else if (key.substring(0, 4) == "xml:") {
  13487. el.setAttributeNS(xmlns, key.substring(4), val);
  13488. } else {
  13489. el.setAttribute(key, val);
  13490. }
  13491. } else {
  13492. el.removeAttribute(key);
  13493. }
  13494. }
  13495. } else {
  13496. el = glob.doc.createElementNS(xmlns, el);
  13497. }
  13498. return el;
  13499. }
  13500. Snap._.$ = $;
  13501. Snap._.id = ID;
  13502. function getAttrs(el) {
  13503. var attrs = el.attributes,
  13504. name,
  13505. out = {};
  13506. for (var i = 0; i < attrs.length; i++) {
  13507. if (attrs[i].namespaceURI == xlink) {
  13508. name = "xlink:";
  13509. } else {
  13510. name = "";
  13511. }
  13512. name += attrs[i].name;
  13513. out[name] = attrs[i].textContent;
  13514. }
  13515. return out;
  13516. }
  13517. function is(o, type) {
  13518. type = Str.prototype.toLowerCase.call(type);
  13519. if (type == "finite") {
  13520. return isFinite(o);
  13521. }
  13522. if (type == "array" &&
  13523. (o instanceof Array || Array.isArray && Array.isArray(o))) {
  13524. return true;
  13525. }
  13526. return (type == "null" && o === null) ||
  13527. (type == typeof o && o !== null) ||
  13528. (type == "object" && o === Object(o)) ||
  13529. objectToString.call(o).slice(8, -1).toLowerCase() == type;
  13530. }
  13531. /*\
  13532. * Snap.format
  13533. [ method ]
  13534. **
  13535. * Replaces construction of type `{<name>}` to the corresponding argument
  13536. **
  13537. - token (string) string to format
  13538. - json (object) object which properties are used as a replacement
  13539. = (string) formatted string
  13540. > Usage
  13541. | // this draws a rectangular shape equivalent to "M10,20h40v50h-40z"
  13542. | paper.path(Snap.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width']}z", {
  13543. | x: 10,
  13544. | y: 20,
  13545. | dim: {
  13546. | width: 40,
  13547. | height: 50,
  13548. | "negative width": -40
  13549. | }
  13550. | }));
  13551. \*/
  13552. Snap.format = (function () {
  13553. var tokenRegex = /\{([^\}]+)\}/g,
  13554. objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, // matches .xxxxx or ["xxxxx"] to run over object properties
  13555. replacer = function (all, key, obj) {
  13556. var res = obj;
  13557. key.replace(objNotationRegex, function (all, name, quote, quotedName, isFunc) {
  13558. name = name || quotedName;
  13559. if (res) {
  13560. if (name in res) {
  13561. res = res[name];
  13562. }
  13563. typeof res == "function" && isFunc && (res = res());
  13564. }
  13565. });
  13566. res = (res == null || res == obj ? all : res) + "";
  13567. return res;
  13568. };
  13569. return function (str, obj) {
  13570. return Str(str).replace(tokenRegex, function (all, key) {
  13571. return replacer(all, key, obj);
  13572. });
  13573. };
  13574. })();
  13575. function clone(obj) {
  13576. if (typeof obj == "function" || Object(obj) !== obj) {
  13577. return obj;
  13578. }
  13579. var res = new obj.constructor;
  13580. for (var key in obj) if (obj[has](key)) {
  13581. res[key] = clone(obj[key]);
  13582. }
  13583. return res;
  13584. }
  13585. Snap._.clone = clone;
  13586. function repush(array, item) {
  13587. for (var i = 0, ii = array.length; i < ii; i++) if (array[i] === item) {
  13588. return array.push(array.splice(i, 1)[0]);
  13589. }
  13590. }
  13591. function cacher(f, scope, postprocessor) {
  13592. function newf() {
  13593. var arg = Array.prototype.slice.call(arguments, 0),
  13594. args = arg.join("\u2400"),
  13595. cache = newf.cache = newf.cache || {},
  13596. count = newf.count = newf.count || [];
  13597. if (cache[has](args)) {
  13598. repush(count, args);
  13599. return postprocessor ? postprocessor(cache[args]) : cache[args];
  13600. }
  13601. count.length >= 1e3 && delete cache[count.shift()];
  13602. count.push(args);
  13603. cache[args] = f.apply(scope, arg);
  13604. return postprocessor ? postprocessor(cache[args]) : cache[args];
  13605. }
  13606. return newf;
  13607. }
  13608. Snap._.cacher = cacher;
  13609. function angle(x1, y1, x2, y2, x3, y3) {
  13610. if (x3 == null) {
  13611. var x = x1 - x2,
  13612. y = y1 - y2;
  13613. if (!x && !y) {
  13614. return 0;
  13615. }
  13616. return (180 + math.atan2(-y, -x) * 180 / PI + 360) % 360;
  13617. } else {
  13618. return angle(x1, y1, x3, y3) - angle(x2, y2, x3, y3);
  13619. }
  13620. }
  13621. function rad(deg) {
  13622. return deg % 360 * PI / 180;
  13623. }
  13624. function deg(rad) {
  13625. return rad * 180 / PI % 360;
  13626. }
  13627. function x_y() {
  13628. return this.x + S + this.y;
  13629. }
  13630. function x_y_w_h() {
  13631. return this.x + S + this.y + S + this.width + " \xd7 " + this.height;
  13632. }
  13633. /*\
  13634. * Snap.rad
  13635. [ method ]
  13636. **
  13637. * Transform angle to radians
  13638. - deg (number) angle in degrees
  13639. = (number) angle in radians
  13640. \*/
  13641. Snap.rad = rad;
  13642. /*\
  13643. * Snap.deg
  13644. [ method ]
  13645. **
  13646. * Transform angle to degrees
  13647. - rad (number) angle in radians
  13648. = (number) angle in degrees
  13649. \*/
  13650. Snap.deg = deg;
  13651. /*\
  13652. * Snap.angle
  13653. [ method ]
  13654. **
  13655. * Returns an angle between two or three points
  13656. > Parameters
  13657. - x1 (number) x coord of first point
  13658. - y1 (number) y coord of first point
  13659. - x2 (number) x coord of second point
  13660. - y2 (number) y coord of second point
  13661. - x3 (number) #optional x coord of third point
  13662. - y3 (number) #optional y coord of third point
  13663. = (number) angle in degrees
  13664. \*/
  13665. Snap.angle = angle;
  13666. /*\
  13667. * Snap.is
  13668. [ method ]
  13669. **
  13670. * Handy replacement for the `typeof` operator
  13671. - o (…) any object or primitive
  13672. - type (string) name of the type, e.g., `string`, `function`, `number`, etc.
  13673. = (boolean) `true` if given value is of given type
  13674. \*/
  13675. Snap.is = is;
  13676. /*\
  13677. * Snap.snapTo
  13678. [ method ]
  13679. **
  13680. * Snaps given value to given grid
  13681. - values (array|number) given array of values or step of the grid
  13682. - value (number) value to adjust
  13683. - tolerance (number) #optional maximum distance to the target value that would trigger the snap. Default is `10`.
  13684. = (number) adjusted value
  13685. \*/
  13686. Snap.snapTo = function (values, value, tolerance) {
  13687. tolerance = is(tolerance, "finite") ? tolerance : 10;
  13688. if (is(values, "array")) {
  13689. var i = values.length;
  13690. while (i--) if (abs(values[i] - value) <= tolerance) {
  13691. return values[i];
  13692. }
  13693. } else {
  13694. values = +values;
  13695. var rem = value % values;
  13696. if (rem < tolerance) {
  13697. return value - rem;
  13698. }
  13699. if (rem > values - tolerance) {
  13700. return value - rem + values;
  13701. }
  13702. }
  13703. return value;
  13704. };
  13705. // Colour
  13706. /*\
  13707. * Snap.getRGB
  13708. [ method ]
  13709. **
  13710. * Parses color string as RGB object
  13711. - color (string) color string in one of the following formats:
  13712. # <ul>
  13713. # <li>Color name (<code>red</code>, <code>green</code>, <code>cornflowerblue</code>, etc)</li>
  13714. # <li>#••• — shortened HTML color: (<code>#000</code>, <code>#fc0</code>, etc.)</li>
  13715. # <li>#•••••• — full length HTML color: (<code>#000000</code>, <code>#bd2300</code>)</li>
  13716. # <li>rgb(•••, •••, •••) — red, green and blue channels values: (<code>rgb(200,&nbsp;100,&nbsp;0)</code>)</li>
  13717. # <li>rgba(•••, •••, •••, •••) — also with opacity</li>
  13718. # <li>rgb(•••%, •••%, •••%) — same as above, but in %: (<code>rgb(100%,&nbsp;175%,&nbsp;0%)</code>)</li>
  13719. # <li>rgba(•••%, •••%, •••%, •••%) — also with opacity</li>
  13720. # <li>hsb(•••, •••, •••) — hue, saturation and brightness values: (<code>hsb(0.5,&nbsp;0.25,&nbsp;1)</code>)</li>
  13721. # <li>hsba(•••, •••, •••, •••) — also with opacity</li>
  13722. # <li>hsb(•••%, •••%, •••%) — same as above, but in %</li>
  13723. # <li>hsba(•••%, •••%, •••%, •••%) — also with opacity</li>
  13724. # <li>hsl(•••, •••, •••) — hue, saturation and luminosity values: (<code>hsb(0.5,&nbsp;0.25,&nbsp;0.5)</code>)</li>
  13725. # <li>hsla(•••, •••, •••, •••) — also with opacity</li>
  13726. # <li>hsl(•••%, •••%, •••%) — same as above, but in %</li>
  13727. # <li>hsla(•••%, •••%, •••%, •••%) — also with opacity</li>
  13728. # </ul>
  13729. * Note that `%` can be used any time: `rgb(20%, 255, 50%)`.
  13730. = (object) RGB object in the following format:
  13731. o {
  13732. o r (number) red,
  13733. o g (number) green,
  13734. o b (number) blue,
  13735. o hex (string) color in HTML/CSS format: #••••••,
  13736. o error (boolean) true if string can't be parsed
  13737. o }
  13738. \*/
  13739. Snap.getRGB = cacher(function (colour) {
  13740. if (!colour || !!((colour = Str(colour)).indexOf("-") + 1)) {
  13741. return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: rgbtoString};
  13742. }
  13743. if (colour == "none") {
  13744. return {r: -1, g: -1, b: -1, hex: "none", toString: rgbtoString};
  13745. }
  13746. !(hsrg[has](colour.toLowerCase().substring(0, 2)) || colour.charAt() == "#") && (colour = toHex(colour));
  13747. if (!colour) {
  13748. return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: rgbtoString};
  13749. }
  13750. var res,
  13751. red,
  13752. green,
  13753. blue,
  13754. opacity,
  13755. t,
  13756. values,
  13757. rgb = colour.match(colourRegExp);
  13758. if (rgb) {
  13759. if (rgb[2]) {
  13760. blue = toInt(rgb[2].substring(5), 16);
  13761. green = toInt(rgb[2].substring(3, 5), 16);
  13762. red = toInt(rgb[2].substring(1, 3), 16);
  13763. }
  13764. if (rgb[3]) {
  13765. blue = toInt((t = rgb[3].charAt(3)) + t, 16);
  13766. green = toInt((t = rgb[3].charAt(2)) + t, 16);
  13767. red = toInt((t = rgb[3].charAt(1)) + t, 16);
  13768. }
  13769. if (rgb[4]) {
  13770. values = rgb[4].split(commaSpaces);
  13771. red = toFloat(values[0]);
  13772. values[0].slice(-1) == "%" && (red *= 2.55);
  13773. green = toFloat(values[1]);
  13774. values[1].slice(-1) == "%" && (green *= 2.55);
  13775. blue = toFloat(values[2]);
  13776. values[2].slice(-1) == "%" && (blue *= 2.55);
  13777. rgb[1].toLowerCase().slice(0, 4) == "rgba" && (opacity = toFloat(values[3]));
  13778. values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
  13779. }
  13780. if (rgb[5]) {
  13781. values = rgb[5].split(commaSpaces);
  13782. red = toFloat(values[0]);
  13783. values[0].slice(-1) == "%" && (red /= 100);
  13784. green = toFloat(values[1]);
  13785. values[1].slice(-1) == "%" && (green /= 100);
  13786. blue = toFloat(values[2]);
  13787. values[2].slice(-1) == "%" && (blue /= 100);
  13788. (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);
  13789. rgb[1].toLowerCase().slice(0, 4) == "hsba" && (opacity = toFloat(values[3]));
  13790. values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
  13791. return Snap.hsb2rgb(red, green, blue, opacity);
  13792. }
  13793. if (rgb[6]) {
  13794. values = rgb[6].split(commaSpaces);
  13795. red = toFloat(values[0]);
  13796. values[0].slice(-1) == "%" && (red /= 100);
  13797. green = toFloat(values[1]);
  13798. values[1].slice(-1) == "%" && (green /= 100);
  13799. blue = toFloat(values[2]);
  13800. values[2].slice(-1) == "%" && (blue /= 100);
  13801. (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);
  13802. rgb[1].toLowerCase().slice(0, 4) == "hsla" && (opacity = toFloat(values[3]));
  13803. values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
  13804. return Snap.hsl2rgb(red, green, blue, opacity);
  13805. }
  13806. red = mmin(math.round(red), 255);
  13807. green = mmin(math.round(green), 255);
  13808. blue = mmin(math.round(blue), 255);
  13809. opacity = mmin(mmax(opacity, 0), 1);
  13810. rgb = {r: red, g: green, b: blue, toString: rgbtoString};
  13811. rgb.hex = "#" + (16777216 | blue | (green << 8) | (red << 16)).toString(16).slice(1);
  13812. rgb.opacity = is(opacity, "finite") ? opacity : 1;
  13813. return rgb;
  13814. }
  13815. return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: rgbtoString};
  13816. }, Snap);
  13817. // SIERRA It seems odd that the following 3 conversion methods are not expressed as .this2that(), like the others.
  13818. /*\
  13819. * Snap.hsb
  13820. [ method ]
  13821. **
  13822. * Converts HSB values to a hex representation of the color
  13823. - h (number) hue
  13824. - s (number) saturation
  13825. - b (number) value or brightness
  13826. = (string) hex representation of the color
  13827. \*/
  13828. Snap.hsb = cacher(function (h, s, b) {
  13829. return Snap.hsb2rgb(h, s, b).hex;
  13830. });
  13831. /*\
  13832. * Snap.hsl
  13833. [ method ]
  13834. **
  13835. * Converts HSL values to a hex representation of the color
  13836. - h (number) hue
  13837. - s (number) saturation
  13838. - l (number) luminosity
  13839. = (string) hex representation of the color
  13840. \*/
  13841. Snap.hsl = cacher(function (h, s, l) {
  13842. return Snap.hsl2rgb(h, s, l).hex;
  13843. });
  13844. /*\
  13845. * Snap.rgb
  13846. [ method ]
  13847. **
  13848. * Converts RGB values to a hex representation of the color
  13849. - r (number) red
  13850. - g (number) green
  13851. - b (number) blue
  13852. = (string) hex representation of the color
  13853. \*/
  13854. Snap.rgb = cacher(function (r, g, b, o) {
  13855. if (is(o, "finite")) {
  13856. var round = math.round;
  13857. return "rgba(" + [round(r), round(g), round(b), +o.toFixed(2)] + ")";
  13858. }
  13859. return "#" + (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1);
  13860. });
  13861. var toHex = function (color) {
  13862. var i = glob.doc.getElementsByTagName("head")[0] || glob.doc.getElementsByTagName("svg")[0],
  13863. red = "rgb(255, 0, 0)";
  13864. toHex = cacher(function (color) {
  13865. if (color.toLowerCase() == "red") {
  13866. return red;
  13867. }
  13868. i.style.color = red;
  13869. i.style.color = color;
  13870. var out = glob.doc.defaultView.getComputedStyle(i, E).getPropertyValue("color");
  13871. return out == red ? null : out;
  13872. });
  13873. return toHex(color);
  13874. },
  13875. hsbtoString = function () {
  13876. return "hsb(" + [this.h, this.s, this.b] + ")";
  13877. },
  13878. hsltoString = function () {
  13879. return "hsl(" + [this.h, this.s, this.l] + ")";
  13880. },
  13881. rgbtoString = function () {
  13882. return this.opacity == 1 || this.opacity == null ?
  13883. this.hex :
  13884. "rgba(" + [this.r, this.g, this.b, this.opacity] + ")";
  13885. },
  13886. prepareRGB = function (r, g, b) {
  13887. if (g == null && is(r, "object") && "r" in r && "g" in r && "b" in r) {
  13888. b = r.b;
  13889. g = r.g;
  13890. r = r.r;
  13891. }
  13892. if (g == null && is(r, string)) {
  13893. var clr = Snap.getRGB(r);
  13894. r = clr.r;
  13895. g = clr.g;
  13896. b = clr.b;
  13897. }
  13898. if (r > 1 || g > 1 || b > 1) {
  13899. r /= 255;
  13900. g /= 255;
  13901. b /= 255;
  13902. }
  13903. return [r, g, b];
  13904. },
  13905. packageRGB = function (r, g, b, o) {
  13906. r = math.round(r * 255);
  13907. g = math.round(g * 255);
  13908. b = math.round(b * 255);
  13909. var rgb = {
  13910. r: r,
  13911. g: g,
  13912. b: b,
  13913. opacity: is(o, "finite") ? o : 1,
  13914. hex: Snap.rgb(r, g, b),
  13915. toString: rgbtoString
  13916. };
  13917. is(o, "finite") && (rgb.opacity = o);
  13918. return rgb;
  13919. };
  13920. // SIERRA Clarify if Snap does not support consolidated HSLA/RGBA colors. E.g., can you specify a semi-transparent value for Snap.filter.shadow()?
  13921. /*\
  13922. * Snap.color
  13923. [ method ]
  13924. **
  13925. * Parses the color string and returns an object featuring the color's component values
  13926. - clr (string) color string in one of the supported formats (see @Snap.getRGB)
  13927. = (object) Combined RGB/HSB object in the following format:
  13928. o {
  13929. o r (number) red,
  13930. o g (number) green,
  13931. o b (number) blue,
  13932. o hex (string) color in HTML/CSS format: #••••••,
  13933. o error (boolean) `true` if string can't be parsed,
  13934. o h (number) hue,
  13935. o s (number) saturation,
  13936. o v (number) value (brightness),
  13937. o l (number) lightness
  13938. o }
  13939. \*/
  13940. Snap.color = function (clr) {
  13941. var rgb;
  13942. if (is(clr, "object") && "h" in clr && "s" in clr && "b" in clr) {
  13943. rgb = Snap.hsb2rgb(clr);
  13944. clr.r = rgb.r;
  13945. clr.g = rgb.g;
  13946. clr.b = rgb.b;
  13947. clr.opacity = 1;
  13948. clr.hex = rgb.hex;
  13949. } else if (is(clr, "object") && "h" in clr && "s" in clr && "l" in clr) {
  13950. rgb = Snap.hsl2rgb(clr);
  13951. clr.r = rgb.r;
  13952. clr.g = rgb.g;
  13953. clr.b = rgb.b;
  13954. clr.opacity = 1;
  13955. clr.hex = rgb.hex;
  13956. } else {
  13957. if (is(clr, "string")) {
  13958. clr = Snap.getRGB(clr);
  13959. }
  13960. if (is(clr, "object") && "r" in clr && "g" in clr && "b" in clr && !("error" in clr)) {
  13961. rgb = Snap.rgb2hsl(clr);
  13962. clr.h = rgb.h;
  13963. clr.s = rgb.s;
  13964. clr.l = rgb.l;
  13965. rgb = Snap.rgb2hsb(clr);
  13966. clr.v = rgb.b;
  13967. } else {
  13968. clr = {hex: "none"};
  13969. clr.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1;
  13970. clr.error = 1;
  13971. }
  13972. }
  13973. clr.toString = rgbtoString;
  13974. return clr;
  13975. };
  13976. /*\
  13977. * Snap.hsb2rgb
  13978. [ method ]
  13979. **
  13980. * Converts HSB values to an RGB object
  13981. - h (number) hue
  13982. - s (number) saturation
  13983. - v (number) value or brightness
  13984. = (object) RGB object in the following format:
  13985. o {
  13986. o r (number) red,
  13987. o g (number) green,
  13988. o b (number) blue,
  13989. o hex (string) color in HTML/CSS format: #••••••
  13990. o }
  13991. \*/
  13992. Snap.hsb2rgb = function (h, s, v, o) {
  13993. if (is(h, "object") && "h" in h && "s" in h && "b" in h) {
  13994. v = h.b;
  13995. s = h.s;
  13996. h = h.h;
  13997. o = h.o;
  13998. }
  13999. h *= 360;
  14000. var R, G, B, X, C;
  14001. h = (h % 360) / 60;
  14002. C = v * s;
  14003. X = C * (1 - abs(h % 2 - 1));
  14004. R = G = B = v - C;
  14005. h = ~~h;
  14006. R += [C, X, 0, 0, X, C][h];
  14007. G += [X, C, C, X, 0, 0][h];
  14008. B += [0, 0, X, C, C, X][h];
  14009. return packageRGB(R, G, B, o);
  14010. };
  14011. /*\
  14012. * Snap.hsl2rgb
  14013. [ method ]
  14014. **
  14015. * Converts HSL values to an RGB object
  14016. - h (number) hue
  14017. - s (number) saturation
  14018. - l (number) luminosity
  14019. = (object) RGB object in the following format:
  14020. o {
  14021. o r (number) red,
  14022. o g (number) green,
  14023. o b (number) blue,
  14024. o hex (string) color in HTML/CSS format: #••••••
  14025. o }
  14026. \*/
  14027. Snap.hsl2rgb = function (h, s, l, o) {
  14028. if (is(h, "object") && "h" in h && "s" in h && "l" in h) {
  14029. l = h.l;
  14030. s = h.s;
  14031. h = h.h;
  14032. }
  14033. if (h > 1 || s > 1 || l > 1) {
  14034. h /= 360;
  14035. s /= 100;
  14036. l /= 100;
  14037. }
  14038. h *= 360;
  14039. var R, G, B, X, C;
  14040. h = (h % 360) / 60;
  14041. C = 2 * s * (l < .5 ? l : 1 - l);
  14042. X = C * (1 - abs(h % 2 - 1));
  14043. R = G = B = l - C / 2;
  14044. h = ~~h;
  14045. R += [C, X, 0, 0, X, C][h];
  14046. G += [X, C, C, X, 0, 0][h];
  14047. B += [0, 0, X, C, C, X][h];
  14048. return packageRGB(R, G, B, o);
  14049. };
  14050. /*\
  14051. * Snap.rgb2hsb
  14052. [ method ]
  14053. **
  14054. * Converts RGB values to an HSB object
  14055. - r (number) red
  14056. - g (number) green
  14057. - b (number) blue
  14058. = (object) HSB object in the following format:
  14059. o {
  14060. o h (number) hue,
  14061. o s (number) saturation,
  14062. o b (number) brightness
  14063. o }
  14064. \*/
  14065. Snap.rgb2hsb = function (r, g, b) {
  14066. b = prepareRGB(r, g, b);
  14067. r = b[0];
  14068. g = b[1];
  14069. b = b[2];
  14070. var H, S, V, C;
  14071. V = mmax(r, g, b);
  14072. C = V - mmin(r, g, b);
  14073. H = (C == 0 ? null :
  14074. V == r ? (g - b) / C :
  14075. V == g ? (b - r) / C + 2 :
  14076. (r - g) / C + 4
  14077. );
  14078. H = ((H + 360) % 6) * 60 / 360;
  14079. S = C == 0 ? 0 : C / V;
  14080. return {h: H, s: S, b: V, toString: hsbtoString};
  14081. };
  14082. /*\
  14083. * Snap.rgb2hsl
  14084. [ method ]
  14085. **
  14086. * Converts RGB values to an HSL object
  14087. - r (number) red
  14088. - g (number) green
  14089. - b (number) blue
  14090. = (object) HSL object in the following format:
  14091. o {
  14092. o h (number) hue,
  14093. o s (number) saturation,
  14094. o l (number) luminosity
  14095. o }
  14096. \*/
  14097. Snap.rgb2hsl = function (r, g, b) {
  14098. b = prepareRGB(r, g, b);
  14099. r = b[0];
  14100. g = b[1];
  14101. b = b[2];
  14102. var H, S, L, M, m, C;
  14103. M = mmax(r, g, b);
  14104. m = mmin(r, g, b);
  14105. C = M - m;
  14106. H = (C == 0 ? null :
  14107. M == r ? (g - b) / C :
  14108. M == g ? (b - r) / C + 2 :
  14109. (r - g) / C + 4);
  14110. H = ((H + 360) % 6) * 60 / 360;
  14111. L = (M + m) / 2;
  14112. S = (C == 0 ? 0 :
  14113. L < .5 ? C / (2 * L) :
  14114. C / (2 - 2 * L));
  14115. return {h: H, s: S, l: L, toString: hsltoString};
  14116. };
  14117. // Transformations
  14118. // 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?
  14119. /*\
  14120. * Snap.parsePathString
  14121. [ method ]
  14122. **
  14123. * Utility method
  14124. **
  14125. * Parses given path string into an array of arrays of path segments
  14126. - pathString (string|array) path string or array of segments (in the last case it is returned straight away)
  14127. = (array) array of segments
  14128. \*/
  14129. Snap.parsePathString = function (pathString) {
  14130. if (!pathString) {
  14131. return null;
  14132. }
  14133. var pth = Snap.path(pathString);
  14134. if (pth.arr) {
  14135. return Snap.path.clone(pth.arr);
  14136. }
  14137. 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},
  14138. data = [];
  14139. if (is(pathString, "array") && is(pathString[0], "array")) { // rough assumption
  14140. data = Snap.path.clone(pathString);
  14141. }
  14142. if (!data.length) {
  14143. Str(pathString).replace(pathCommand, function (a, b, c) {
  14144. var params = [],
  14145. name = b.toLowerCase();
  14146. c.replace(pathValues, function (a, b) {
  14147. b && params.push(+b);
  14148. });
  14149. if (name == "m" && params.length > 2) {
  14150. data.push([b].concat(params.splice(0, 2)));
  14151. name = "l";
  14152. b = b == "m" ? "l" : "L";
  14153. }
  14154. if (name == "o" && params.length == 1) {
  14155. data.push([b, params[0]]);
  14156. }
  14157. if (name == "r") {
  14158. data.push([b].concat(params));
  14159. } else while (params.length >= paramCounts[name]) {
  14160. data.push([b].concat(params.splice(0, paramCounts[name])));
  14161. if (!paramCounts[name]) {
  14162. break;
  14163. }
  14164. }
  14165. });
  14166. }
  14167. data.toString = Snap.path.toString;
  14168. pth.arr = Snap.path.clone(data);
  14169. return data;
  14170. };
  14171. /*\
  14172. * Snap.parseTransformString
  14173. [ method ]
  14174. **
  14175. * Utility method
  14176. **
  14177. * Parses given transform string into an array of transformations
  14178. - TString (string|array) transform string or array of transformations (in the last case it is returned straight away)
  14179. = (array) array of transformations
  14180. \*/
  14181. var parseTransformString = Snap.parseTransformString = function (TString) {
  14182. if (!TString) {
  14183. return null;
  14184. }
  14185. var paramCounts = {r: 3, s: 4, t: 2, m: 6},
  14186. data = [];
  14187. if (is(TString, "array") && is(TString[0], "array")) { // rough assumption
  14188. data = Snap.path.clone(TString);
  14189. }
  14190. if (!data.length) {
  14191. Str(TString).replace(tCommand, function (a, b, c) {
  14192. var params = [],
  14193. name = b.toLowerCase();
  14194. c.replace(pathValues, function (a, b) {
  14195. b && params.push(+b);
  14196. });
  14197. data.push([b].concat(params));
  14198. });
  14199. }
  14200. data.toString = Snap.path.toString;
  14201. return data;
  14202. };
  14203. function svgTransform2string(tstr) {
  14204. var res = [];
  14205. tstr = tstr.replace(/(?:^|\s)(\w+)\(([^)]+)\)/g, function (all, name, params) {
  14206. params = params.split(/\s*,\s*|\s+/);
  14207. if (name == "rotate" && params.length == 1) {
  14208. params.push(0, 0);
  14209. }
  14210. if (name == "scale") {
  14211. if (params.length > 2) {
  14212. params = params.slice(0, 2);
  14213. } else if (params.length == 2) {
  14214. params.push(0, 0);
  14215. }
  14216. if (params.length == 1) {
  14217. params.push(params[0], 0, 0);
  14218. }
  14219. }
  14220. if (name == "skewX") {
  14221. res.push(["m", 1, 0, math.tan(rad(params[0])), 1, 0, 0]);
  14222. } else if (name == "skewY") {
  14223. res.push(["m", 1, math.tan(rad(params[0])), 0, 1, 0, 0]);
  14224. } else {
  14225. res.push([name.charAt(0)].concat(params));
  14226. }
  14227. return all;
  14228. });
  14229. return res;
  14230. }
  14231. Snap._.svgTransform2string = svgTransform2string;
  14232. Snap._.rgTransform = /^[a-z][\s]*-?\.?\d/i;
  14233. function transform2matrix(tstr, bbox) {
  14234. var tdata = parseTransformString(tstr),
  14235. m = new Snap.Matrix;
  14236. if (tdata) {
  14237. for (var i = 0, ii = tdata.length; i < ii; i++) {
  14238. var t = tdata[i],
  14239. tlen = t.length,
  14240. command = Str(t[0]).toLowerCase(),
  14241. absolute = t[0] != command,
  14242. inver = absolute ? m.invert() : 0,
  14243. x1,
  14244. y1,
  14245. x2,
  14246. y2,
  14247. bb;
  14248. if (command == "t" && tlen == 2){
  14249. m.translate(t[1], 0);
  14250. } else if (command == "t" && tlen == 3) {
  14251. if (absolute) {
  14252. x1 = inver.x(0, 0);
  14253. y1 = inver.y(0, 0);
  14254. x2 = inver.x(t[1], t[2]);
  14255. y2 = inver.y(t[1], t[2]);
  14256. m.translate(x2 - x1, y2 - y1);
  14257. } else {
  14258. m.translate(t[1], t[2]);
  14259. }
  14260. } else if (command == "r") {
  14261. if (tlen == 2) {
  14262. bb = bb || bbox;
  14263. m.rotate(t[1], bb.x + bb.width / 2, bb.y + bb.height / 2);
  14264. } else if (tlen == 4) {
  14265. if (absolute) {
  14266. x2 = inver.x(t[2], t[3]);
  14267. y2 = inver.y(t[2], t[3]);
  14268. m.rotate(t[1], x2, y2);
  14269. } else {
  14270. m.rotate(t[1], t[2], t[3]);
  14271. }
  14272. }
  14273. } else if (command == "s") {
  14274. if (tlen == 2 || tlen == 3) {
  14275. bb = bb || bbox;
  14276. m.scale(t[1], t[tlen - 1], bb.x + bb.width / 2, bb.y + bb.height / 2);
  14277. } else if (tlen == 4) {
  14278. if (absolute) {
  14279. x2 = inver.x(t[2], t[3]);
  14280. y2 = inver.y(t[2], t[3]);
  14281. m.scale(t[1], t[1], x2, y2);
  14282. } else {
  14283. m.scale(t[1], t[1], t[2], t[3]);
  14284. }
  14285. } else if (tlen == 5) {
  14286. if (absolute) {
  14287. x2 = inver.x(t[3], t[4]);
  14288. y2 = inver.y(t[3], t[4]);
  14289. m.scale(t[1], t[2], x2, y2);
  14290. } else {
  14291. m.scale(t[1], t[2], t[3], t[4]);
  14292. }
  14293. }
  14294. } else if (command == "m" && tlen == 7) {
  14295. m.add(t[1], t[2], t[3], t[4], t[5], t[6]);
  14296. }
  14297. }
  14298. }
  14299. return m;
  14300. }
  14301. Snap._.transform2matrix = transform2matrix;
  14302. Snap._unit2px = unit2px;
  14303. var contains = glob.doc.contains || glob.doc.compareDocumentPosition ?
  14304. function (a, b) {
  14305. var adown = a.nodeType == 9 ? a.documentElement : a,
  14306. bup = b && b.parentNode;
  14307. return a == bup || !!(bup && bup.nodeType == 1 && (
  14308. adown.contains ?
  14309. adown.contains(bup) :
  14310. a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16
  14311. ));
  14312. } :
  14313. function (a, b) {
  14314. if (b) {
  14315. while (b) {
  14316. b = b.parentNode;
  14317. if (b == a) {
  14318. return true;
  14319. }
  14320. }
  14321. }
  14322. return false;
  14323. };
  14324. function getSomeDefs(el) {
  14325. var p = (el.node.ownerSVGElement && wrap(el.node.ownerSVGElement)) ||
  14326. (el.node.parentNode && wrap(el.node.parentNode)) ||
  14327. Snap.select("svg") ||
  14328. Snap(0, 0),
  14329. pdefs = p.select("defs"),
  14330. defs = pdefs == null ? false : pdefs.node;
  14331. if (!defs) {
  14332. defs = make("defs", p.node).node;
  14333. }
  14334. return defs;
  14335. }
  14336. function getSomeSVG(el) {
  14337. return el.node.ownerSVGElement && wrap(el.node.ownerSVGElement) || Snap.select("svg");
  14338. }
  14339. Snap._.getSomeDefs = getSomeDefs;
  14340. Snap._.getSomeSVG = getSomeSVG;
  14341. function unit2px(el, name, value) {
  14342. var svg = getSomeSVG(el).node,
  14343. out = {},
  14344. mgr = svg.querySelector(".svg---mgr");
  14345. if (!mgr) {
  14346. mgr = $("rect");
  14347. $(mgr, {x: -9e9, y: -9e9, width: 10, height: 10, "class": "svg---mgr", fill: "none"});
  14348. svg.appendChild(mgr);
  14349. }
  14350. function getW(val) {
  14351. if (val == null) {
  14352. return E;
  14353. }
  14354. if (val == +val) {
  14355. return val;
  14356. }
  14357. $(mgr, {width: val});
  14358. try {
  14359. return mgr.getBBox().width;
  14360. } catch (e) {
  14361. return 0;
  14362. }
  14363. }
  14364. function getH(val) {
  14365. if (val == null) {
  14366. return E;
  14367. }
  14368. if (val == +val) {
  14369. return val;
  14370. }
  14371. $(mgr, {height: val});
  14372. try {
  14373. return mgr.getBBox().height;
  14374. } catch (e) {
  14375. return 0;
  14376. }
  14377. }
  14378. function set(nam, f) {
  14379. if (name == null) {
  14380. out[nam] = f(el.attr(nam) || 0);
  14381. } else if (nam == name) {
  14382. out = f(value == null ? el.attr(nam) || 0 : value);
  14383. }
  14384. }
  14385. switch (el.type) {
  14386. case "rect":
  14387. set("rx", getW);
  14388. set("ry", getH);
  14389. case "image":
  14390. set("width", getW);
  14391. set("height", getH);
  14392. case "text":
  14393. set("x", getW);
  14394. set("y", getH);
  14395. break;
  14396. case "circle":
  14397. set("cx", getW);
  14398. set("cy", getH);
  14399. set("r", getW);
  14400. break;
  14401. case "ellipse":
  14402. set("cx", getW);
  14403. set("cy", getH);
  14404. set("rx", getW);
  14405. set("ry", getH);
  14406. break;
  14407. case "line":
  14408. set("x1", getW);
  14409. set("x2", getW);
  14410. set("y1", getH);
  14411. set("y2", getH);
  14412. break;
  14413. case "marker":
  14414. set("refX", getW);
  14415. set("markerWidth", getW);
  14416. set("refY", getH);
  14417. set("markerHeight", getH);
  14418. break;
  14419. case "radialGradient":
  14420. set("fx", getW);
  14421. set("fy", getH);
  14422. break;
  14423. case "tspan":
  14424. set("dx", getW);
  14425. set("dy", getH);
  14426. break;
  14427. default:
  14428. set(name, getW);
  14429. }
  14430. svg.removeChild(mgr);
  14431. return out;
  14432. }
  14433. /*\
  14434. * Snap.select
  14435. [ method ]
  14436. **
  14437. * Wraps a DOM element specified by CSS selector as @Element
  14438. - query (string) CSS selector of the element
  14439. = (Element) the current element
  14440. \*/
  14441. Snap.select = function (query) {
  14442. query = Str(query).replace(/([^\\]):/g, "$1\\:");
  14443. return wrap(glob.doc.querySelector(query));
  14444. };
  14445. /*\
  14446. * Snap.selectAll
  14447. [ method ]
  14448. **
  14449. * Wraps DOM elements specified by CSS selector as set or array of @Element
  14450. - query (string) CSS selector of the element
  14451. = (Element) the current element
  14452. \*/
  14453. Snap.selectAll = function (query) {
  14454. var nodelist = glob.doc.querySelectorAll(query),
  14455. set = (Snap.set || Array)();
  14456. for (var i = 0; i < nodelist.length; i++) {
  14457. set.push(wrap(nodelist[i]));
  14458. }
  14459. return set;
  14460. };
  14461. function add2group(list) {
  14462. if (!is(list, "array")) {
  14463. list = Array.prototype.slice.call(arguments, 0);
  14464. }
  14465. var i = 0,
  14466. j = 0,
  14467. node = this.node;
  14468. while (this[i]) delete this[i++];
  14469. for (i = 0; i < list.length; i++) {
  14470. if (list[i].type == "set") {
  14471. list[i].forEach(function (el) {
  14472. node.appendChild(el.node);
  14473. });
  14474. } else {
  14475. node.appendChild(list[i].node);
  14476. }
  14477. }
  14478. var children = node.childNodes;
  14479. for (i = 0; i < children.length; i++) {
  14480. this[j++] = wrap(children[i]);
  14481. }
  14482. return this;
  14483. }
  14484. // Hub garbage collector every 10s
  14485. setInterval(function () {
  14486. for (var key in hub) if (hub[has](key)) {
  14487. var el = hub[key],
  14488. node = el.node;
  14489. if (el.type != "svg" && !node.ownerSVGElement || el.type == "svg" && (!node.parentNode || "ownerSVGElement" in node.parentNode && !node.ownerSVGElement)) {
  14490. delete hub[key];
  14491. }
  14492. }
  14493. }, 1e4);
  14494. function Element(el) {
  14495. if (el.snap in hub) {
  14496. return hub[el.snap];
  14497. }
  14498. var svg;
  14499. try {
  14500. svg = el.ownerSVGElement;
  14501. } catch(e) {}
  14502. /*\
  14503. * Element.node
  14504. [ property (object) ]
  14505. **
  14506. * Gives you a reference to the DOM object, so you can assign event handlers or just mess around.
  14507. > Usage
  14508. | // draw a circle at coordinate 10,10 with radius of 10
  14509. | var c = paper.circle(10, 10, 10);
  14510. | c.node.onclick = function () {
  14511. | c.attr("fill", "red");
  14512. | };
  14513. \*/
  14514. this.node = el;
  14515. if (svg) {
  14516. this.paper = new Paper(svg);
  14517. }
  14518. /*\
  14519. * Element.type
  14520. [ property (string) ]
  14521. **
  14522. * SVG tag name of the given element.
  14523. \*/
  14524. this.type = el.tagName;
  14525. var id = this.id = ID(this);
  14526. this.anims = {};
  14527. this._ = {
  14528. transform: []
  14529. };
  14530. el.snap = id;
  14531. hub[id] = this;
  14532. if (this.type == "g") {
  14533. this.add = add2group;
  14534. }
  14535. if (this.type in {g: 1, mask: 1, pattern: 1, symbol: 1}) {
  14536. for (var method in Paper.prototype) if (Paper.prototype[has](method)) {
  14537. this[method] = Paper.prototype[method];
  14538. }
  14539. }
  14540. }
  14541. /*\
  14542. * Element.attr
  14543. [ method ]
  14544. **
  14545. * Gets or sets given attributes of the element.
  14546. **
  14547. - params (object) contains key-value pairs of attributes you want to set
  14548. * or
  14549. - param (string) name of the attribute
  14550. = (Element) the current element
  14551. * or
  14552. = (string) value of attribute
  14553. > Usage
  14554. | el.attr({
  14555. | fill: "#fc0",
  14556. | stroke: "#000",
  14557. | strokeWidth: 2, // CamelCase...
  14558. | "fill-opacity": 0.5, // or dash-separated names
  14559. | width: "*=2" // prefixed values
  14560. | });
  14561. | console.log(el.attr("fill")); // #fc0
  14562. * Prefixed values in format `"+=10"` supported. All four operations
  14563. * (`+`, `-`, `*` and `/`) could be used. Optionally you can use units for `+`
  14564. * and `-`: `"+=2em"`.
  14565. \*/
  14566. Element.prototype.attr = function (params, value) {
  14567. var el = this,
  14568. node = el.node;
  14569. if (!params) {
  14570. return el;
  14571. }
  14572. if (is(params, "string")) {
  14573. if (arguments.length > 1) {
  14574. var json = {};
  14575. json[params] = value;
  14576. params = json;
  14577. } else {
  14578. return eve("snap.util.getattr." + params, el).firstDefined();
  14579. }
  14580. }
  14581. for (var att in params) {
  14582. if (params[has](att)) {
  14583. eve("snap.util.attr." + att, el, params[att]);
  14584. }
  14585. }
  14586. return el;
  14587. };
  14588. /*\
  14589. * Snap.parse
  14590. [ method ]
  14591. **
  14592. * Parses SVG fragment and converts it into a @Fragment
  14593. **
  14594. - svg (string) SVG string
  14595. = (Fragment) the @Fragment
  14596. \*/
  14597. Snap.parse = function (svg) {
  14598. var f = glob.doc.createDocumentFragment(),
  14599. full = true,
  14600. div = glob.doc.createElement("div");
  14601. svg = Str(svg);
  14602. if (!svg.match(/^\s*<\s*svg(?:\s|>)/)) {
  14603. svg = "<svg>" + svg + "</svg>";
  14604. full = false;
  14605. }
  14606. div.innerHTML = svg;
  14607. svg = div.getElementsByTagName("svg")[0];
  14608. if (svg) {
  14609. if (full) {
  14610. f = svg;
  14611. } else {
  14612. while (svg.firstChild) {
  14613. f.appendChild(svg.firstChild);
  14614. }
  14615. div.innerHTML = E;
  14616. }
  14617. }
  14618. return new Fragment(f);
  14619. };
  14620. function Fragment(frag) {
  14621. this.node = frag;
  14622. }
  14623. // SIERRA Snap.fragment() could especially use a code example
  14624. /*\
  14625. * Snap.fragment
  14626. [ method ]
  14627. **
  14628. * Creates a DOM fragment from a given list of elements or strings
  14629. **
  14630. - varargs (…) SVG string
  14631. = (Fragment) the @Fragment
  14632. \*/
  14633. Snap.fragment = function () {
  14634. var args = Array.prototype.slice.call(arguments, 0),
  14635. f = glob.doc.createDocumentFragment();
  14636. for (var i = 0, ii = args.length; i < ii; i++) {
  14637. var item = args[i];
  14638. if (item.node && item.node.nodeType) {
  14639. f.appendChild(item.node);
  14640. }
  14641. if (item.nodeType) {
  14642. f.appendChild(item);
  14643. }
  14644. if (typeof item == "string") {
  14645. f.appendChild(Snap.parse(item).node);
  14646. }
  14647. }
  14648. return new Fragment(f);
  14649. };
  14650. function make(name, parent) {
  14651. var res = $(name);
  14652. parent.appendChild(res);
  14653. var el = wrap(res);
  14654. return el;
  14655. }
  14656. function Paper(w, h) {
  14657. var res,
  14658. desc,
  14659. defs,
  14660. proto = Paper.prototype;
  14661. if (w && w.tagName == "svg") {
  14662. if (w.snap in hub) {
  14663. return hub[w.snap];
  14664. }
  14665. var doc = w.ownerDocument;
  14666. res = new Element(w);
  14667. desc = w.getElementsByTagName("desc")[0];
  14668. defs = w.getElementsByTagName("defs")[0];
  14669. if (!desc) {
  14670. desc = $("desc");
  14671. desc.appendChild(doc.createTextNode("Created with Snap"));
  14672. res.node.appendChild(desc);
  14673. }
  14674. if (!defs) {
  14675. defs = $("defs");
  14676. res.node.appendChild(defs);
  14677. }
  14678. res.defs = defs;
  14679. for (var key in proto) if (proto[has](key)) {
  14680. res[key] = proto[key];
  14681. }
  14682. res.paper = res.root = res;
  14683. } else {
  14684. res = make("svg", glob.doc.body);
  14685. $(res.node, {
  14686. height: h,
  14687. version: 1.1,
  14688. width: w,
  14689. xmlns: xmlns
  14690. });
  14691. }
  14692. return res;
  14693. }
  14694. function wrap(dom) {
  14695. if (!dom) {
  14696. return dom;
  14697. }
  14698. if (dom instanceof Element || dom instanceof Fragment) {
  14699. return dom;
  14700. }
  14701. if (dom.tagName && dom.tagName.toLowerCase() == "svg") {
  14702. return new Paper(dom);
  14703. }
  14704. if (dom.tagName && dom.tagName.toLowerCase() == "object" && dom.type == "image/svg+xml") {
  14705. return new Paper(dom.contentDocument.getElementsByTagName("svg")[0]);
  14706. }
  14707. return new Element(dom);
  14708. }
  14709. Snap._.make = make;
  14710. Snap._.wrap = wrap;
  14711. /*\
  14712. * Paper.el
  14713. [ method ]
  14714. **
  14715. * Creates an element on paper with a given name and no attributes
  14716. **
  14717. - name (string) tag name
  14718. - attr (object) attributes
  14719. = (Element) the current element
  14720. > Usage
  14721. | var c = paper.circle(10, 10, 10); // is the same as...
  14722. | var c = paper.el("circle").attr({
  14723. | cx: 10,
  14724. | cy: 10,
  14725. | r: 10
  14726. | });
  14727. | // and the same as
  14728. | var c = paper.el("circle", {
  14729. | cx: 10,
  14730. | cy: 10,
  14731. | r: 10
  14732. | });
  14733. \*/
  14734. Paper.prototype.el = function (name, attr) {
  14735. var el = make(name, this.node);
  14736. attr && el.attr(attr);
  14737. return el;
  14738. };
  14739. // default
  14740. eve.on("snap.util.getattr", function () {
  14741. var att = eve.nt();
  14742. att = att.substring(att.lastIndexOf(".") + 1);
  14743. var css = att.replace(/[A-Z]/g, function (letter) {
  14744. return "-" + letter.toLowerCase();
  14745. });
  14746. if (cssAttr[has](css)) {
  14747. return this.node.ownerDocument.defaultView.getComputedStyle(this.node, null).getPropertyValue(css);
  14748. } else {
  14749. return $(this.node, att);
  14750. }
  14751. });
  14752. var cssAttr = {
  14753. "alignment-baseline": 0,
  14754. "baseline-shift": 0,
  14755. "clip": 0,
  14756. "clip-path": 0,
  14757. "clip-rule": 0,
  14758. "color": 0,
  14759. "color-interpolation": 0,
  14760. "color-interpolation-filters": 0,
  14761. "color-profile": 0,
  14762. "color-rendering": 0,
  14763. "cursor": 0,
  14764. "direction": 0,
  14765. "display": 0,
  14766. "dominant-baseline": 0,
  14767. "enable-background": 0,
  14768. "fill": 0,
  14769. "fill-opacity": 0,
  14770. "fill-rule": 0,
  14771. "filter": 0,
  14772. "flood-color": 0,
  14773. "flood-opacity": 0,
  14774. "font": 0,
  14775. "font-family": 0,
  14776. "font-size": 0,
  14777. "font-size-adjust": 0,
  14778. "font-stretch": 0,
  14779. "font-style": 0,
  14780. "font-variant": 0,
  14781. "font-weight": 0,
  14782. "glyph-orientation-horizontal": 0,
  14783. "glyph-orientation-vertical": 0,
  14784. "image-rendering": 0,
  14785. "kerning": 0,
  14786. "letter-spacing": 0,
  14787. "lighting-color": 0,
  14788. "marker": 0,
  14789. "marker-end": 0,
  14790. "marker-mid": 0,
  14791. "marker-start": 0,
  14792. "mask": 0,
  14793. "opacity": 0,
  14794. "overflow": 0,
  14795. "pointer-events": 0,
  14796. "shape-rendering": 0,
  14797. "stop-color": 0,
  14798. "stop-opacity": 0,
  14799. "stroke": 0,
  14800. "stroke-dasharray": 0,
  14801. "stroke-dashoffset": 0,
  14802. "stroke-linecap": 0,
  14803. "stroke-linejoin": 0,
  14804. "stroke-miterlimit": 0,
  14805. "stroke-opacity": 0,
  14806. "stroke-width": 0,
  14807. "text-anchor": 0,
  14808. "text-decoration": 0,
  14809. "text-rendering": 0,
  14810. "unicode-bidi": 0,
  14811. "visibility": 0,
  14812. "word-spacing": 0,
  14813. "writing-mode": 0
  14814. };
  14815. eve.on("snap.util.attr", function (value) {
  14816. var att = eve.nt(),
  14817. attr = {};
  14818. att = att.substring(att.lastIndexOf(".") + 1);
  14819. attr[att] = value;
  14820. var style = att.replace(/-(\w)/gi, function (all, letter) {
  14821. return letter.toUpperCase();
  14822. }),
  14823. css = att.replace(/[A-Z]/g, function (letter) {
  14824. return "-" + letter.toLowerCase();
  14825. });
  14826. if (cssAttr[has](css)) {
  14827. this.node.style[style] = value == null ? E : value;
  14828. } else {
  14829. $(this.node, attr);
  14830. }
  14831. });
  14832. (function (proto) {}(Paper.prototype));
  14833. // simple ajax
  14834. /*\
  14835. * Snap.ajax
  14836. [ method ]
  14837. **
  14838. * Simple implementation of Ajax
  14839. **
  14840. - url (string) URL
  14841. - postData (object|string) data for post request
  14842. - callback (function) callback
  14843. - scope (object) #optional scope of callback
  14844. * or
  14845. - url (string) URL
  14846. - callback (function) callback
  14847. - scope (object) #optional scope of callback
  14848. = (XMLHttpRequest) the XMLHttpRequest object, just in case
  14849. \*/
  14850. Snap.ajax = function (url, postData, callback, scope){
  14851. var req = new XMLHttpRequest,
  14852. id = ID();
  14853. if (req) {
  14854. if (is(postData, "function")) {
  14855. scope = callback;
  14856. callback = postData;
  14857. postData = null;
  14858. } else if (is(postData, "object")) {
  14859. var pd = [];
  14860. for (var key in postData) if (postData.hasOwnProperty(key)) {
  14861. pd.push(encodeURIComponent(key) + "=" + encodeURIComponent(postData[key]));
  14862. }
  14863. postData = pd.join("&");
  14864. }
  14865. req.open((postData ? "POST" : "GET"), url, true);
  14866. if (postData) {
  14867. req.setRequestHeader("X-Requested-With", "XMLHttpRequest");
  14868. req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  14869. }
  14870. if (callback) {
  14871. eve.once("snap.ajax." + id + ".0", callback);
  14872. eve.once("snap.ajax." + id + ".200", callback);
  14873. eve.once("snap.ajax." + id + ".304", callback);
  14874. }
  14875. req.onreadystatechange = function() {
  14876. if (req.readyState != 4) return;
  14877. eve("snap.ajax." + id + "." + req.status, scope, req);
  14878. };
  14879. if (req.readyState == 4) {
  14880. return req;
  14881. }
  14882. req.send(postData);
  14883. return req;
  14884. }
  14885. };
  14886. /*\
  14887. * Snap.load
  14888. [ method ]
  14889. **
  14890. * Loads external SVG file as a @Fragment (see @Snap.ajax for more advanced AJAX)
  14891. **
  14892. - url (string) URL
  14893. - callback (function) callback
  14894. - scope (object) #optional scope of callback
  14895. \*/
  14896. Snap.load = function (url, callback, scope) {
  14897. Snap.ajax(url, function (req) {
  14898. var f = Snap.parse(req.responseText);
  14899. scope ? callback.call(scope, f) : callback(f);
  14900. });
  14901. };
  14902. var getOffset = function (elem) {
  14903. var box = elem.getBoundingClientRect(),
  14904. doc = elem.ownerDocument,
  14905. body = doc.body,
  14906. docElem = doc.documentElement,
  14907. clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
  14908. top = box.top + (g.win.pageYOffset || docElem.scrollTop || body.scrollTop ) - clientTop,
  14909. left = box.left + (g.win.pageXOffset || docElem.scrollLeft || body.scrollLeft) - clientLeft;
  14910. return {
  14911. y: top,
  14912. x: left
  14913. };
  14914. };
  14915. /*\
  14916. * Snap.getElementByPoint
  14917. [ method ]
  14918. **
  14919. * Returns you topmost element under given point.
  14920. **
  14921. = (object) Snap element object
  14922. - x (number) x coordinate from the top left corner of the window
  14923. - y (number) y coordinate from the top left corner of the window
  14924. > Usage
  14925. | Snap.getElementByPoint(mouseX, mouseY).attr({stroke: "#f00"});
  14926. \*/
  14927. Snap.getElementByPoint = function (x, y) {
  14928. var paper = this,
  14929. svg = paper.canvas,
  14930. target = glob.doc.elementFromPoint(x, y);
  14931. if (glob.win.opera && target.tagName == "svg") {
  14932. var so = getOffset(target),
  14933. sr = target.createSVGRect();
  14934. sr.x = x - so.x;
  14935. sr.y = y - so.y;
  14936. sr.width = sr.height = 1;
  14937. var hits = target.getIntersectionList(sr, null);
  14938. if (hits.length) {
  14939. target = hits[hits.length - 1];
  14940. }
  14941. }
  14942. if (!target) {
  14943. return null;
  14944. }
  14945. return wrap(target);
  14946. };
  14947. /*\
  14948. * Snap.plugin
  14949. [ method ]
  14950. **
  14951. * Let you write plugins. You pass in a function with four arguments, like this:
  14952. | Snap.plugin(function (Snap, Element, Paper, global, Fragment) {
  14953. | Snap.newmethod = function () {};
  14954. | Element.prototype.newmethod = function () {};
  14955. | Paper.prototype.newmethod = function () {};
  14956. | });
  14957. * Inside the function you have access to all main objects (and their
  14958. * prototypes). This allow you to extend anything you want.
  14959. **
  14960. - f (function) your plugin body
  14961. \*/
  14962. Snap.plugin = function (f) {
  14963. f(Snap, Element, Paper, glob, Fragment);
  14964. };
  14965. glob.win.Snap = Snap;
  14966. return Snap;
  14967. }(window || this));
  14968. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  14969. //
  14970. // Licensed under the Apache License, Version 2.0 (the "License");
  14971. // you may not use this file except in compliance with the License.
  14972. // You may obtain a copy of the License at
  14973. //
  14974. // http://www.apache.org/licenses/LICENSE-2.0
  14975. //
  14976. // Unless required by applicable law or agreed to in writing, software
  14977. // distributed under the License is distributed on an "AS IS" BASIS,
  14978. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14979. // See the License for the specific language governing permissions and
  14980. // limitations under the License.
  14981. Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
  14982. var elproto = Element.prototype,
  14983. is = Snap.is,
  14984. Str = String,
  14985. unit2px = Snap._unit2px,
  14986. $ = Snap._.$,
  14987. make = Snap._.make,
  14988. getSomeDefs = Snap._.getSomeDefs,
  14989. has = "hasOwnProperty",
  14990. wrap = Snap._.wrap;
  14991. /*\
  14992. * Element.getBBox
  14993. [ method ]
  14994. **
  14995. * Returns the bounding box descriptor for the given element
  14996. **
  14997. = (object) bounding box descriptor:
  14998. o {
  14999. o cx: (number) x of the center,
  15000. o cy: (number) x of the center,
  15001. o h: (number) height,
  15002. o height: (number) height,
  15003. o path: (string) path command for the box,
  15004. o r0: (number) radius of a circle that fully encloses the box,
  15005. o r1: (number) radius of the smallest circle that can be enclosed,
  15006. o r2: (number) radius of the largest circle that can be enclosed,
  15007. o vb: (string) box as a viewbox command,
  15008. o w: (number) width,
  15009. o width: (number) width,
  15010. o x2: (number) x of the right side,
  15011. o x: (number) x of the left side,
  15012. o y2: (number) y of the bottom edge,
  15013. o y: (number) y of the top edge
  15014. o }
  15015. \*/
  15016. elproto.getBBox = function (isWithoutTransform) {
  15017. if (!Snap.Matrix || !Snap.path) {
  15018. return this.node.getBBox();
  15019. }
  15020. var el = this,
  15021. m = new Snap.Matrix;
  15022. if (el.removed) {
  15023. return Snap._.box();
  15024. }
  15025. while (el.type == "use") {
  15026. if (!isWithoutTransform) {
  15027. m = m.add(el.transform().localMatrix.translate(el.attr("x") || 0, el.attr("y") || 0));
  15028. }
  15029. if (el.original) {
  15030. el = el.original;
  15031. } else {
  15032. var href = el.attr("xlink:href");
  15033. el = el.original = el.node.ownerDocument.getElementById(href.substring(href.indexOf("#") + 1));
  15034. }
  15035. }
  15036. var _ = el._,
  15037. pathfinder = Snap.path.get[el.type] || Snap.path.get.deflt;
  15038. try {
  15039. if (isWithoutTransform) {
  15040. _.bboxwt = pathfinder ? Snap.path.getBBox(el.realPath = pathfinder(el)) : Snap._.box(el.node.getBBox());
  15041. return Snap._.box(_.bboxwt);
  15042. } else {
  15043. el.realPath = pathfinder(el);
  15044. el.matrix = el.transform().localMatrix;
  15045. _.bbox = Snap.path.getBBox(Snap.path.map(el.realPath, m.add(el.matrix)));
  15046. return Snap._.box(_.bbox);
  15047. }
  15048. } catch (e) {
  15049. // Firefox doesn’t give you bbox of hidden element
  15050. return Snap._.box();
  15051. }
  15052. };
  15053. var propString = function () {
  15054. return this.string;
  15055. };
  15056. function extractTransform(el, tstr) {
  15057. if (tstr == null) {
  15058. var doReturn = true;
  15059. if (el.type == "linearGradient" || el.type == "radialGradient") {
  15060. tstr = el.node.getAttribute("gradientTransform");
  15061. } else if (el.type == "pattern") {
  15062. tstr = el.node.getAttribute("patternTransform");
  15063. } else {
  15064. tstr = el.node.getAttribute("transform");
  15065. }
  15066. if (!tstr) {
  15067. return new Snap.Matrix;
  15068. }
  15069. tstr = Snap._.svgTransform2string(tstr);
  15070. } else {
  15071. if (!Snap._.rgTransform.test(tstr)) {
  15072. tstr = Snap._.svgTransform2string(tstr);
  15073. } else {
  15074. tstr = Str(tstr).replace(/\.{3}|\u2026/g, el._.transform || E);
  15075. }
  15076. if (is(tstr, "array")) {
  15077. tstr = Snap.path ? Snap.path.toString.call(tstr) : Str(tstr);
  15078. }
  15079. el._.transform = tstr;
  15080. }
  15081. var m = Snap._.transform2matrix(tstr, el.getBBox(1));
  15082. if (doReturn) {
  15083. return m;
  15084. } else {
  15085. el.matrix = m;
  15086. }
  15087. }
  15088. /*\
  15089. * Element.transform
  15090. [ method ]
  15091. **
  15092. * Gets or sets transformation of the element
  15093. **
  15094. - tstr (string) transform string in Snap or SVG format
  15095. = (Element) the current element
  15096. * or
  15097. = (object) transformation descriptor:
  15098. o {
  15099. o string (string) transform string,
  15100. o globalMatrix (Matrix) matrix of all transformations applied to element or its parents,
  15101. o localMatrix (Matrix) matrix of transformations applied only to the element,
  15102. o diffMatrix (Matrix) matrix of difference between global and local transformations,
  15103. o global (string) global transformation as string,
  15104. o local (string) local transformation as string,
  15105. o toString (function) returns `string` property
  15106. o }
  15107. \*/
  15108. elproto.transform = function (tstr) {
  15109. var _ = this._;
  15110. if (tstr == null) {
  15111. var papa = this,
  15112. global = new Snap.Matrix(this.node.getCTM()),
  15113. local = extractTransform(this),
  15114. ms = [local],
  15115. m = new Snap.Matrix,
  15116. i,
  15117. localString = local.toTransformString(),
  15118. string = Str(local) == Str(this.matrix) ?
  15119. Str(_.transform) : localString;
  15120. while (papa.type != "svg" && (papa = papa.parent())) {
  15121. ms.push(extractTransform(papa));
  15122. }
  15123. i = ms.length;
  15124. while (i--) {
  15125. m.add(ms[i]);
  15126. }
  15127. return {
  15128. string: string,
  15129. globalMatrix: global,
  15130. totalMatrix: m,
  15131. localMatrix: local,
  15132. diffMatrix: global.clone().add(local.invert()),
  15133. global: global.toTransformString(),
  15134. total: m.toTransformString(),
  15135. local: localString,
  15136. toString: propString
  15137. };
  15138. }
  15139. if (tstr instanceof Snap.Matrix) {
  15140. this.matrix = tstr;
  15141. this._.transform = tstr.toTransformString();
  15142. } else {
  15143. extractTransform(this, tstr);
  15144. }
  15145. if (this.node) {
  15146. if (this.type == "linearGradient" || this.type == "radialGradient") {
  15147. $(this.node, {gradientTransform: this.matrix});
  15148. } else if (this.type == "pattern") {
  15149. $(this.node, {patternTransform: this.matrix});
  15150. } else {
  15151. $(this.node, {transform: this.matrix});
  15152. }
  15153. }
  15154. return this;
  15155. };
  15156. /*\
  15157. * Element.parent
  15158. [ method ]
  15159. **
  15160. * Returns the element's parent
  15161. **
  15162. = (Element) the parent element
  15163. \*/
  15164. elproto.parent = function () {
  15165. return wrap(this.node.parentNode);
  15166. };
  15167. /*\
  15168. * Element.append
  15169. [ method ]
  15170. **
  15171. * Appends the given element to current one
  15172. **
  15173. - el (Element|Set) element to append
  15174. = (Element) the parent element
  15175. \*/
  15176. /*\
  15177. * Element.add
  15178. [ method ]
  15179. **
  15180. * See @Element.append
  15181. \*/
  15182. elproto.append = elproto.add = function (el) {
  15183. if (el) {
  15184. if (el.type == "set") {
  15185. var it = this;
  15186. el.forEach(function (el) {
  15187. it.add(el);
  15188. });
  15189. return this;
  15190. }
  15191. el = wrap(el);
  15192. this.node.appendChild(el.node);
  15193. el.paper = this.paper;
  15194. }
  15195. return this;
  15196. };
  15197. /*\
  15198. * Element.appendTo
  15199. [ method ]
  15200. **
  15201. * Appends the current element to the given one
  15202. **
  15203. - el (Element) parent element to append to
  15204. = (Element) the child element
  15205. \*/
  15206. elproto.appendTo = function (el) {
  15207. if (el) {
  15208. el = wrap(el);
  15209. el.append(this);
  15210. }
  15211. return this;
  15212. };
  15213. /*\
  15214. * Element.prepend
  15215. [ method ]
  15216. **
  15217. * Prepends the given element to the current one
  15218. **
  15219. - el (Element) element to prepend
  15220. = (Element) the parent element
  15221. \*/
  15222. elproto.prepend = function (el) {
  15223. if (el) {
  15224. if (el.type == "set") {
  15225. var it = this,
  15226. first;
  15227. el.forEach(function (el) {
  15228. if (first) {
  15229. first.after(el);
  15230. } else {
  15231. it.prepend(el);
  15232. }
  15233. first = el;
  15234. });
  15235. return this;
  15236. }
  15237. el = wrap(el);
  15238. var parent = el.parent();
  15239. this.node.insertBefore(el.node, this.node.firstChild);
  15240. this.add && this.add();
  15241. el.paper = this.paper;
  15242. this.parent() && this.parent().add();
  15243. parent && parent.add();
  15244. }
  15245. return this;
  15246. };
  15247. /*\
  15248. * Element.prependTo
  15249. [ method ]
  15250. **
  15251. * Prepends the current element to the given one
  15252. **
  15253. - el (Element) parent element to prepend to
  15254. = (Element) the child element
  15255. \*/
  15256. elproto.prependTo = function (el) {
  15257. el = wrap(el);
  15258. el.prepend(this);
  15259. return this;
  15260. };
  15261. /*\
  15262. * Element.before
  15263. [ method ]
  15264. **
  15265. * Inserts given element before the current one
  15266. **
  15267. - el (Element) element to insert
  15268. = (Element) the parent element
  15269. \*/
  15270. elproto.before = function (el) {
  15271. if (el.type == "set") {
  15272. var it = this;
  15273. el.forEach(function (el) {
  15274. var parent = el.parent();
  15275. it.node.parentNode.insertBefore(el.node, it.node);
  15276. parent && parent.add();
  15277. });
  15278. this.parent().add();
  15279. return this;
  15280. }
  15281. el = wrap(el);
  15282. var parent = el.parent();
  15283. this.node.parentNode.insertBefore(el.node, this.node);
  15284. this.parent() && this.parent().add();
  15285. parent && parent.add();
  15286. el.paper = this.paper;
  15287. return this;
  15288. };
  15289. /*\
  15290. * Element.after
  15291. [ method ]
  15292. **
  15293. * Inserts given element after the current one
  15294. **
  15295. - el (Element) element to insert
  15296. = (Element) the parent element
  15297. \*/
  15298. elproto.after = function (el) {
  15299. el = wrap(el);
  15300. var parent = el.parent();
  15301. if (this.node.nextSibling) {
  15302. this.node.parentNode.insertBefore(el.node, this.node.nextSibling);
  15303. } else {
  15304. this.node.parentNode.appendChild(el.node);
  15305. }
  15306. this.parent() && this.parent().add();
  15307. parent && parent.add();
  15308. el.paper = this.paper;
  15309. return this;
  15310. };
  15311. /*\
  15312. * Element.insertBefore
  15313. [ method ]
  15314. **
  15315. * Inserts the element after the given one
  15316. **
  15317. - el (Element) element next to whom insert to
  15318. = (Element) the parent element
  15319. \*/
  15320. elproto.insertBefore = function (el) {
  15321. el = wrap(el);
  15322. var parent = this.parent();
  15323. el.node.parentNode.insertBefore(this.node, el.node);
  15324. this.paper = el.paper;
  15325. parent && parent.add();
  15326. el.parent() && el.parent().add();
  15327. return this;
  15328. };
  15329. /*\
  15330. * Element.insertAfter
  15331. [ method ]
  15332. **
  15333. * Inserts the element after the given one
  15334. **
  15335. - el (Element) element next to whom insert to
  15336. = (Element) the parent element
  15337. \*/
  15338. elproto.insertAfter = function (el) {
  15339. el = wrap(el);
  15340. var parent = this.parent();
  15341. el.node.parentNode.insertBefore(this.node, el.node.nextSibling);
  15342. this.paper = el.paper;
  15343. parent && parent.add();
  15344. el.parent() && el.parent().add();
  15345. return this;
  15346. };
  15347. /*\
  15348. * Element.remove
  15349. [ method ]
  15350. **
  15351. * Removes element from the DOM
  15352. = (Element) the detached element
  15353. \*/
  15354. elproto.remove = function () {
  15355. var parent = this.parent();
  15356. this.node.parentNode && this.node.parentNode.removeChild(this.node);
  15357. delete this.paper;
  15358. this.removed = true;
  15359. parent && parent.add();
  15360. return this;
  15361. };
  15362. /*\
  15363. * Element.select
  15364. [ method ]
  15365. **
  15366. * Gathers the nested @Element matching the given set of CSS selectors
  15367. **
  15368. - query (string) CSS selector
  15369. = (Element) result of query selection
  15370. \*/
  15371. elproto.select = function (query) {
  15372. query = Str(query).replace(/([^\\]):/g, "$1\\:");
  15373. return wrap(this.node.querySelector(query));
  15374. };
  15375. /*\
  15376. * Element.selectAll
  15377. [ method ]
  15378. **
  15379. * Gathers nested @Element objects matching the given set of CSS selectors
  15380. **
  15381. - query (string) CSS selector
  15382. = (Set|array) result of query selection
  15383. \*/
  15384. elproto.selectAll = function (query) {
  15385. var nodelist = this.node.querySelectorAll(query),
  15386. set = (Snap.set || Array)();
  15387. for (var i = 0; i < nodelist.length; i++) {
  15388. set.push(wrap(nodelist[i]));
  15389. }
  15390. return set;
  15391. };
  15392. /*\
  15393. * Element.asPX
  15394. [ method ]
  15395. **
  15396. * Returns given attribute of the element as a `px` value (not %, em, etc.)
  15397. **
  15398. - attr (string) attribute name
  15399. - value (string) #optional attribute value
  15400. = (Element) result of query selection
  15401. \*/
  15402. elproto.asPX = function (attr, value) {
  15403. if (value == null) {
  15404. value = this.attr(attr);
  15405. }
  15406. return +unit2px(this, attr, value);
  15407. };
  15408. // 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.
  15409. /*\
  15410. * Element.use
  15411. [ method ]
  15412. **
  15413. * Creates a `<use>` element linked to the current element
  15414. **
  15415. = (Element) the `<use>` element
  15416. \*/
  15417. elproto.use = function () {
  15418. var use,
  15419. id = this.node.id;
  15420. if (!id) {
  15421. id = this.id;
  15422. $(this.node, {
  15423. id: id
  15424. });
  15425. }
  15426. if (this.type == "linearGradient" || this.type == "radialGradient" ||
  15427. this.type == "pattern") {
  15428. use = make(this.type, this.node.parentNode);
  15429. } else {
  15430. use = make("use", this.node.parentNode);
  15431. }
  15432. $(use.node, {
  15433. "xlink:href": "#" + id
  15434. });
  15435. use.original = this;
  15436. return use;
  15437. };
  15438. function fixids(el) {
  15439. var els = el.selectAll("*"),
  15440. it,
  15441. url = /^\s*url\(("|'|)(.*)\1\)\s*$/,
  15442. ids = [],
  15443. uses = {};
  15444. function urltest(it, name) {
  15445. var val = $(it.node, name);
  15446. val = val && val.match(url);
  15447. val = val && val[2];
  15448. if (val && val.charAt() == "#") {
  15449. val = val.substring(1);
  15450. } else {
  15451. return;
  15452. }
  15453. if (val) {
  15454. uses[val] = (uses[val] || []).concat(function (id) {
  15455. var attr = {};
  15456. attr[name] = URL(id);
  15457. $(it.node, attr);
  15458. });
  15459. }
  15460. }
  15461. function linktest(it) {
  15462. var val = $(it.node, "xlink:href");
  15463. if (val && val.charAt() == "#") {
  15464. val = val.substring(1);
  15465. } else {
  15466. return;
  15467. }
  15468. if (val) {
  15469. uses[val] = (uses[val] || []).concat(function (id) {
  15470. it.attr("xlink:href", "#" + id);
  15471. });
  15472. }
  15473. }
  15474. for (var i = 0, ii = els.length; i < ii; i++) {
  15475. it = els[i];
  15476. urltest(it, "fill");
  15477. urltest(it, "stroke");
  15478. urltest(it, "filter");
  15479. urltest(it, "mask");
  15480. urltest(it, "clip-path");
  15481. linktest(it);
  15482. var oldid = $(it.node, "id");
  15483. if (oldid) {
  15484. $(it.node, {id: it.id});
  15485. ids.push({
  15486. old: oldid,
  15487. id: it.id
  15488. });
  15489. }
  15490. }
  15491. for (i = 0, ii = ids.length; i < ii; i++) {
  15492. var fs = uses[ids[i].old];
  15493. if (fs) {
  15494. for (var j = 0, jj = fs.length; j < jj; j++) {
  15495. fs[j](ids[i].id);
  15496. }
  15497. }
  15498. }
  15499. }
  15500. /*\
  15501. * Element.clone
  15502. [ method ]
  15503. **
  15504. * Creates a clone of the element and inserts it after the element
  15505. **
  15506. = (Element) the clone
  15507. \*/
  15508. elproto.clone = function () {
  15509. var clone = wrap(this.node.cloneNode(true));
  15510. if ($(clone.node, "id")) {
  15511. $(clone.node, {id: clone.id});
  15512. }
  15513. fixids(clone);
  15514. clone.insertAfter(this);
  15515. return clone;
  15516. };
  15517. /*\
  15518. * Element.toDefs
  15519. [ method ]
  15520. **
  15521. * Moves element to the shared `<defs>` area
  15522. **
  15523. = (Element) the element
  15524. \*/
  15525. elproto.toDefs = function () {
  15526. var defs = getSomeDefs(this);
  15527. defs.appendChild(this.node);
  15528. return this;
  15529. };
  15530. /*\
  15531. * Element.toPattern
  15532. [ method ]
  15533. **
  15534. * Creates a `<pattern>` element from the current element
  15535. **
  15536. * To create a pattern you have to specify the pattern rect:
  15537. - x (string|number)
  15538. - y (string|number)
  15539. - width (string|number)
  15540. - height (string|number)
  15541. = (Element) the `<pattern>` element
  15542. * You can use pattern later on as an argument for `fill` attribute:
  15543. | var p = paper.path("M10-5-10,15M15,0,0,15M0-5-20,15").attr({
  15544. | fill: "none",
  15545. | stroke: "#bada55",
  15546. | strokeWidth: 5
  15547. | }).pattern(0, 0, 10, 10),
  15548. | c = paper.circle(200, 200, 100);
  15549. | c.attr({
  15550. | fill: p
  15551. | });
  15552. \*/
  15553. elproto.pattern = elproto.toPattern = function (x, y, width, height) {
  15554. var p = make("pattern", getSomeDefs(this));
  15555. if (x == null) {
  15556. x = this.getBBox();
  15557. }
  15558. if (is(x, "object") && "x" in x) {
  15559. y = x.y;
  15560. width = x.width;
  15561. height = x.height;
  15562. x = x.x;
  15563. }
  15564. $(p.node, {
  15565. x: x,
  15566. y: y,
  15567. width: width,
  15568. height: height,
  15569. patternUnits: "userSpaceOnUse",
  15570. id: p.id,
  15571. viewBox: [x, y, width, height].join(" ")
  15572. });
  15573. p.node.appendChild(this.node);
  15574. return p;
  15575. };
  15576. // 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.
  15577. // 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?
  15578. /*\
  15579. * Element.marker
  15580. [ method ]
  15581. **
  15582. * Creates a `<marker>` element from the current element
  15583. **
  15584. * To create a marker you have to specify the bounding rect and reference point:
  15585. - x (number)
  15586. - y (number)
  15587. - width (number)
  15588. - height (number)
  15589. - refX (number)
  15590. - refY (number)
  15591. = (Element) the `<marker>` element
  15592. * 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.
  15593. \*/
  15594. // TODO add usage for markers
  15595. elproto.marker = function (x, y, width, height, refX, refY) {
  15596. var p = make("marker", getSomeDefs(this));
  15597. if (x == null) {
  15598. x = this.getBBox();
  15599. }
  15600. if (is(x, "object") && "x" in x) {
  15601. y = x.y;
  15602. width = x.width;
  15603. height = x.height;
  15604. refX = x.refX || x.cx;
  15605. refY = x.refY || x.cy;
  15606. x = x.x;
  15607. }
  15608. $(p.node, {
  15609. viewBox: [x, y, width, height].join(" "),
  15610. markerWidth: width,
  15611. markerHeight: height,
  15612. orient: "auto",
  15613. refX: refX || 0,
  15614. refY: refY || 0,
  15615. id: p.id
  15616. });
  15617. p.node.appendChild(this.node);
  15618. return p;
  15619. };
  15620. // animation
  15621. function slice(from, to, f) {
  15622. return function (arr) {
  15623. var res = arr.slice(from, to);
  15624. if (res.length == 1) {
  15625. res = res[0];
  15626. }
  15627. return f ? f(res) : res;
  15628. };
  15629. }
  15630. var Animation = function (attr, ms, easing, callback) {
  15631. if (typeof easing == "function" && !easing.length) {
  15632. callback = easing;
  15633. easing = mina.linear;
  15634. }
  15635. this.attr = attr;
  15636. this.dur = ms;
  15637. easing && (this.easing = easing);
  15638. callback && (this.callback = callback);
  15639. };
  15640. Snap._.Animation = Animation;
  15641. /*\
  15642. * Snap.animation
  15643. [ method ]
  15644. **
  15645. * Creates an animation object
  15646. **
  15647. - attr (object) attributes of final destination
  15648. - duration (number) duration of the animation, in milliseconds
  15649. - easing (function) #optional one of easing functions of @mina or custom one
  15650. - callback (function) #optional callback function that fires when animation ends
  15651. = (object) animation object
  15652. \*/
  15653. Snap.animation = function (attr, ms, easing, callback) {
  15654. return new Animation(attr, ms, easing, callback);
  15655. };
  15656. /*\
  15657. * Element.inAnim
  15658. [ method ]
  15659. **
  15660. * Returns a set of animations that may be able to manipulate the current element
  15661. **
  15662. = (object) in format:
  15663. o {
  15664. o anim (object) animation object,
  15665. o mina (object) @mina object,
  15666. o curStatus (number) 0..1 — status of the animation: 0 — just started, 1 — just finished,
  15667. o status (function) gets or sets the status of the animation,
  15668. o stop (function) stops the animation
  15669. o }
  15670. \*/
  15671. elproto.inAnim = function () {
  15672. var el = this,
  15673. res = [];
  15674. for (var id in el.anims) if (el.anims[has](id)) {
  15675. (function (a) {
  15676. res.push({
  15677. anim: new Animation(a._attrs, a.dur, a.easing, a._callback),
  15678. mina: a,
  15679. curStatus: a.status(),
  15680. status: function (val) {
  15681. return a.status(val);
  15682. },
  15683. stop: function () {
  15684. a.stop();
  15685. }
  15686. });
  15687. }(el.anims[id]));
  15688. }
  15689. return res;
  15690. };
  15691. /*\
  15692. * Snap.animate
  15693. [ method ]
  15694. **
  15695. * Runs generic animation of one number into another with a caring function
  15696. **
  15697. - from (number|array) number or array of numbers
  15698. - to (number|array) number or array of numbers
  15699. - setter (function) caring function that accepts one number argument
  15700. - duration (number) duration, in milliseconds
  15701. - easing (function) #optional easing function from @mina or custom
  15702. - callback (function) #optional callback function to execute when animation ends
  15703. = (object) animation object in @mina format
  15704. o {
  15705. o id (string) animation id, consider it read-only,
  15706. o duration (function) gets or sets the duration of the animation,
  15707. o easing (function) easing,
  15708. o speed (function) gets or sets the speed of the animation,
  15709. o status (function) gets or sets the status of the animation,
  15710. o stop (function) stops the animation
  15711. o }
  15712. | var rect = Snap().rect(0, 0, 10, 10);
  15713. | Snap.animate(0, 10, function (val) {
  15714. | rect.attr({
  15715. | x: val
  15716. | });
  15717. | }, 1000);
  15718. | // in given context is equivalent to
  15719. | rect.animate({x: 10}, 1000);
  15720. \*/
  15721. Snap.animate = function (from, to, setter, ms, easing, callback) {
  15722. if (typeof easing == "function" && !easing.length) {
  15723. callback = easing;
  15724. easing = mina.linear;
  15725. }
  15726. var now = mina.time(),
  15727. anim = mina(from, to, now, now + ms, mina.time, setter, easing);
  15728. callback && eve.once("mina.finish." + anim.id, callback);
  15729. return anim;
  15730. };
  15731. /*\
  15732. * Element.stop
  15733. [ method ]
  15734. **
  15735. * Stops all the animations for the current element
  15736. **
  15737. = (Element) the current element
  15738. \*/
  15739. elproto.stop = function () {
  15740. var anims = this.inAnim();
  15741. for (var i = 0, ii = anims.length; i < ii; i++) {
  15742. anims[i].stop();
  15743. }
  15744. return this;
  15745. };
  15746. /*\
  15747. * Element.animate
  15748. [ method ]
  15749. **
  15750. * Animates the given attributes of the element
  15751. **
  15752. - attrs (object) key-value pairs of destination attributes
  15753. - duration (number) duration of the animation in milliseconds
  15754. - easing (function) #optional easing function from @mina or custom
  15755. - callback (function) #optional callback function that executes when the animation ends
  15756. = (Element) the current element
  15757. \*/
  15758. elproto.animate = function (attrs, ms, easing, callback) {
  15759. if (typeof easing == "function" && !easing.length) {
  15760. callback = easing;
  15761. easing = mina.linear;
  15762. }
  15763. if (attrs instanceof Animation) {
  15764. callback = attrs.callback;
  15765. easing = attrs.easing;
  15766. ms = easing.dur;
  15767. attrs = attrs.attr;
  15768. }
  15769. var fkeys = [], tkeys = [], keys = {}, from, to, f, eq,
  15770. el = this;
  15771. for (var key in attrs) if (attrs[has](key)) {
  15772. if (el.equal) {
  15773. eq = el.equal(key, Str(attrs[key]));
  15774. from = eq.from;
  15775. to = eq.to;
  15776. f = eq.f;
  15777. } else {
  15778. from = +el.attr(key);
  15779. to = +attrs[key];
  15780. }
  15781. var len = is(from, "array") ? from.length : 1;
  15782. keys[key] = slice(fkeys.length, fkeys.length + len, f);
  15783. fkeys = fkeys.concat(from);
  15784. tkeys = tkeys.concat(to);
  15785. }
  15786. var now = mina.time(),
  15787. anim = mina(fkeys, tkeys, now, now + ms, mina.time, function (val) {
  15788. var attr = {};
  15789. for (var key in keys) if (keys[has](key)) {
  15790. attr[key] = keys[key](val);
  15791. }
  15792. el.attr(attr);
  15793. }, easing);
  15794. el.anims[anim.id] = anim;
  15795. anim._attrs = attrs;
  15796. anim._callback = callback;
  15797. eve("snap.animcreated." + el.id, anim);
  15798. eve.once("mina.finish." + anim.id, function () {
  15799. delete el.anims[anim.id];
  15800. callback && callback.call(el);
  15801. });
  15802. eve.once("mina.stop." + anim.id, function () {
  15803. delete el.anims[anim.id];
  15804. });
  15805. return el;
  15806. };
  15807. var eldata = {};
  15808. /*\
  15809. * Element.data
  15810. [ method ]
  15811. **
  15812. * Adds or retrieves given value associated with given key. (Don’t confuse
  15813. * with `data-` attributes)
  15814. *
  15815. * See also @Element.removeData
  15816. - key (string) key to store data
  15817. - value (any) #optional value to store
  15818. = (object) @Element
  15819. * or, if value is not specified:
  15820. = (any) value
  15821. > Usage
  15822. | for (var i = 0, i < 5, i++) {
  15823. | paper.circle(10 + 15 * i, 10, 10)
  15824. | .attr({fill: "#000"})
  15825. | .data("i", i)
  15826. | .click(function () {
  15827. | alert(this.data("i"));
  15828. | });
  15829. | }
  15830. \*/
  15831. elproto.data = function (key, value) {
  15832. var data = eldata[this.id] = eldata[this.id] || {};
  15833. if (arguments.length == 0){
  15834. eve("snap.data.get." + this.id, this, data, null);
  15835. return data;
  15836. }
  15837. if (arguments.length == 1) {
  15838. if (Snap.is(key, "object")) {
  15839. for (var i in key) if (key[has](i)) {
  15840. this.data(i, key[i]);
  15841. }
  15842. return this;
  15843. }
  15844. eve("snap.data.get." + this.id, this, data[key], key);
  15845. return data[key];
  15846. }
  15847. data[key] = value;
  15848. eve("snap.data.set." + this.id, this, value, key);
  15849. return this;
  15850. };
  15851. /*\
  15852. * Element.removeData
  15853. [ method ]
  15854. **
  15855. * Removes value associated with an element by given key.
  15856. * If key is not provided, removes all the data of the element.
  15857. - key (string) #optional key
  15858. = (object) @Element
  15859. \*/
  15860. elproto.removeData = function (key) {
  15861. if (key == null) {
  15862. eldata[this.id] = {};
  15863. } else {
  15864. eldata[this.id] && delete eldata[this.id][key];
  15865. }
  15866. return this;
  15867. };
  15868. /*\
  15869. * Element.outerSVG
  15870. [ method ]
  15871. **
  15872. * Returns SVG code for the element, equivalent to HTML's `outerHTML`.
  15873. *
  15874. * See also @Element.innerSVG
  15875. = (string) SVG code for the element
  15876. \*/
  15877. /*\
  15878. * Element.toString
  15879. [ method ]
  15880. **
  15881. * See @Element.outerSVG
  15882. \*/
  15883. elproto.outerSVG = elproto.toString = toString(1);
  15884. /*\
  15885. * Element.innerSVG
  15886. [ method ]
  15887. **
  15888. * Returns SVG code for the element's contents, equivalent to HTML's `innerHTML`
  15889. = (string) SVG code for the element
  15890. \*/
  15891. elproto.innerSVG = toString();
  15892. function toString(type) {
  15893. return function () {
  15894. var res = type ? "<" + this.type : "",
  15895. attr = this.node.attributes,
  15896. chld = this.node.childNodes;
  15897. if (type) {
  15898. for (var i = 0, ii = attr.length; i < ii; i++) {
  15899. res += " " + attr[i].name + '="' +
  15900. attr[i].value.replace(/"/g, '\\"') + '"';
  15901. }
  15902. }
  15903. if (chld.length) {
  15904. type && (res += ">");
  15905. for (i = 0, ii = chld.length; i < ii; i++) {
  15906. if (chld[i].nodeType == 3) {
  15907. res += chld[i].nodeValue;
  15908. } else if (chld[i].nodeType == 1) {
  15909. res += wrap(chld[i]).toString();
  15910. }
  15911. }
  15912. type && (res += "</" + this.type + ">");
  15913. } else {
  15914. type && (res += "/>");
  15915. }
  15916. return res;
  15917. };
  15918. }
  15919. elproto.toDataURL = function () {
  15920. if (window && window.btoa) {
  15921. var bb = this.getBBox(),
  15922. 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>', {
  15923. x: +bb.x.toFixed(3),
  15924. y: +bb.y.toFixed(3),
  15925. width: +bb.width.toFixed(3),
  15926. height: +bb.height.toFixed(3),
  15927. contents: this.outerSVG()
  15928. });
  15929. return "data:image/svg+xml;base64," + btoa(unescape(encodeURIComponent(svg)));
  15930. }
  15931. };
  15932. /*\
  15933. * Fragment.select
  15934. [ method ]
  15935. **
  15936. * See @Element.select
  15937. \*/
  15938. Fragment.prototype.select = elproto.select;
  15939. /*\
  15940. * Fragment.selectAll
  15941. [ method ]
  15942. **
  15943. * See @Element.selectAll
  15944. \*/
  15945. Fragment.prototype.selectAll = elproto.selectAll;
  15946. });
  15947. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  15948. //
  15949. // Licensed under the Apache License, Version 2.0 (the "License");
  15950. // you may not use this file except in compliance with the License.
  15951. // You may obtain a copy of the License at
  15952. //
  15953. // http://www.apache.org/licenses/LICENSE-2.0
  15954. //
  15955. // Unless required by applicable law or agreed to in writing, software
  15956. // distributed under the License is distributed on an "AS IS" BASIS,
  15957. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15958. // See the License for the specific language governing permissions and
  15959. // limitations under the License.
  15960. Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
  15961. var objectToString = Object.prototype.toString,
  15962. Str = String,
  15963. math = Math,
  15964. E = "";
  15965. function Matrix(a, b, c, d, e, f) {
  15966. if (b == null && objectToString.call(a) == "[object SVGMatrix]") {
  15967. this.a = a.a;
  15968. this.b = a.b;
  15969. this.c = a.c;
  15970. this.d = a.d;
  15971. this.e = a.e;
  15972. this.f = a.f;
  15973. return;
  15974. }
  15975. if (a != null) {
  15976. this.a = +a;
  15977. this.b = +b;
  15978. this.c = +c;
  15979. this.d = +d;
  15980. this.e = +e;
  15981. this.f = +f;
  15982. } else {
  15983. this.a = 1;
  15984. this.b = 0;
  15985. this.c = 0;
  15986. this.d = 1;
  15987. this.e = 0;
  15988. this.f = 0;
  15989. }
  15990. }
  15991. (function (matrixproto) {
  15992. /*\
  15993. * Matrix.add
  15994. [ method ]
  15995. **
  15996. * Adds the given matrix to existing one
  15997. - a (number)
  15998. - b (number)
  15999. - c (number)
  16000. - d (number)
  16001. - e (number)
  16002. - f (number)
  16003. * or
  16004. - matrix (object) @Matrix
  16005. \*/
  16006. matrixproto.add = function (a, b, c, d, e, f) {
  16007. var out = [[], [], []],
  16008. m = [[this.a, this.c, this.e], [this.b, this.d, this.f], [0, 0, 1]],
  16009. matrix = [[a, c, e], [b, d, f], [0, 0, 1]],
  16010. x, y, z, res;
  16011. if (a && a instanceof Matrix) {
  16012. matrix = [[a.a, a.c, a.e], [a.b, a.d, a.f], [0, 0, 1]];
  16013. }
  16014. for (x = 0; x < 3; x++) {
  16015. for (y = 0; y < 3; y++) {
  16016. res = 0;
  16017. for (z = 0; z < 3; z++) {
  16018. res += m[x][z] * matrix[z][y];
  16019. }
  16020. out[x][y] = res;
  16021. }
  16022. }
  16023. this.a = out[0][0];
  16024. this.b = out[1][0];
  16025. this.c = out[0][1];
  16026. this.d = out[1][1];
  16027. this.e = out[0][2];
  16028. this.f = out[1][2];
  16029. return this;
  16030. };
  16031. /*\
  16032. * Matrix.invert
  16033. [ method ]
  16034. **
  16035. * Returns an inverted version of the matrix
  16036. = (object) @Matrix
  16037. \*/
  16038. matrixproto.invert = function () {
  16039. var me = this,
  16040. x = me.a * me.d - me.b * me.c;
  16041. 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);
  16042. };
  16043. /*\
  16044. * Matrix.clone
  16045. [ method ]
  16046. **
  16047. * Returns a copy of the matrix
  16048. = (object) @Matrix
  16049. \*/
  16050. matrixproto.clone = function () {
  16051. return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f);
  16052. };
  16053. /*\
  16054. * Matrix.translate
  16055. [ method ]
  16056. **
  16057. * Translate the matrix
  16058. - x (number) horizontal offset distance
  16059. - y (number) vertical offset distance
  16060. \*/
  16061. matrixproto.translate = function (x, y) {
  16062. return this.add(1, 0, 0, 1, x, y);
  16063. };
  16064. /*\
  16065. * Matrix.scale
  16066. [ method ]
  16067. **
  16068. * Scales the matrix
  16069. - x (number) amount to be scaled, with `1` resulting in no change
  16070. - y (number) #optional amount to scale along the vertical axis. (Otherwise `x` applies to both axes.)
  16071. - cx (number) #optional horizontal origin point from which to scale
  16072. - cy (number) #optional vertical origin point from which to scale
  16073. * Default cx, cy is the middle point of the element.
  16074. \*/
  16075. matrixproto.scale = function (x, y, cx, cy) {
  16076. y == null && (y = x);
  16077. (cx || cy) && this.add(1, 0, 0, 1, cx, cy);
  16078. this.add(x, 0, 0, y, 0, 0);
  16079. (cx || cy) && this.add(1, 0, 0, 1, -cx, -cy);
  16080. return this;
  16081. };
  16082. /*\
  16083. * Matrix.rotate
  16084. [ method ]
  16085. **
  16086. * Rotates the matrix
  16087. - a (number) angle of rotation, in degrees
  16088. - x (number) horizontal origin point from which to rotate
  16089. - y (number) vertical origin point from which to rotate
  16090. \*/
  16091. matrixproto.rotate = function (a, x, y) {
  16092. a = Snap.rad(a);
  16093. x = x || 0;
  16094. y = y || 0;
  16095. var cos = +math.cos(a).toFixed(9),
  16096. sin = +math.sin(a).toFixed(9);
  16097. this.add(cos, sin, -sin, cos, x, y);
  16098. return this.add(1, 0, 0, 1, -x, -y);
  16099. };
  16100. /*\
  16101. * Matrix.x
  16102. [ method ]
  16103. **
  16104. * Returns x coordinate for given point after transformation described by the matrix. See also @Matrix.y
  16105. - x (number)
  16106. - y (number)
  16107. = (number) x
  16108. \*/
  16109. matrixproto.x = function (x, y) {
  16110. return x * this.a + y * this.c + this.e;
  16111. };
  16112. /*\
  16113. * Matrix.y
  16114. [ method ]
  16115. **
  16116. * Returns y coordinate for given point after transformation described by the matrix. See also @Matrix.x
  16117. - x (number)
  16118. - y (number)
  16119. = (number) y
  16120. \*/
  16121. matrixproto.y = function (x, y) {
  16122. return x * this.b + y * this.d + this.f;
  16123. };
  16124. matrixproto.get = function (i) {
  16125. return +this[Str.fromCharCode(97 + i)].toFixed(4);
  16126. };
  16127. matrixproto.toString = function () {
  16128. return "matrix(" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)].join() + ")";
  16129. };
  16130. matrixproto.offset = function () {
  16131. return [this.e.toFixed(4), this.f.toFixed(4)];
  16132. };
  16133. function norm(a) {
  16134. return a[0] * a[0] + a[1] * a[1];
  16135. }
  16136. function normalize(a) {
  16137. var mag = math.sqrt(norm(a));
  16138. a[0] && (a[0] /= mag);
  16139. a[1] && (a[1] /= mag);
  16140. }
  16141. /*\
  16142. * Matrix.determinant
  16143. [ method ]
  16144. **
  16145. * Finds determinant of the given matrix.
  16146. = (number) determinant
  16147. \*/
  16148. matrixproto.determinant = function () {
  16149. return this.a * this.d - this.b * this.c;
  16150. };
  16151. /*\
  16152. * Matrix.split
  16153. [ method ]
  16154. **
  16155. * Splits matrix into primitive transformations
  16156. = (object) in format:
  16157. o dx (number) translation by x
  16158. o dy (number) translation by y
  16159. o scalex (number) scale by x
  16160. o scaley (number) scale by y
  16161. o shear (number) shear
  16162. o rotate (number) rotation in deg
  16163. o isSimple (boolean) could it be represented via simple transformations
  16164. \*/
  16165. matrixproto.split = function () {
  16166. var out = {};
  16167. // translation
  16168. out.dx = this.e;
  16169. out.dy = this.f;
  16170. // scale and shear
  16171. var row = [[this.a, this.c], [this.b, this.d]];
  16172. out.scalex = math.sqrt(norm(row[0]));
  16173. normalize(row[0]);
  16174. out.shear = row[0][0] * row[1][0] + row[0][1] * row[1][1];
  16175. row[1] = [row[1][0] - row[0][0] * out.shear, row[1][1] - row[0][1] * out.shear];
  16176. out.scaley = math.sqrt(norm(row[1]));
  16177. normalize(row[1]);
  16178. out.shear /= out.scaley;
  16179. if (this.determinant() < 0) {
  16180. out.scalex = -out.scalex;
  16181. }
  16182. // rotation
  16183. var sin = -row[0][1],
  16184. cos = row[1][1];
  16185. if (cos < 0) {
  16186. out.rotate = Snap.deg(math.acos(cos));
  16187. if (sin < 0) {
  16188. out.rotate = 360 - out.rotate;
  16189. }
  16190. } else {
  16191. out.rotate = Snap.deg(math.asin(sin));
  16192. }
  16193. out.isSimple = !+out.shear.toFixed(9) && (out.scalex.toFixed(9) == out.scaley.toFixed(9) || !out.rotate);
  16194. out.isSuperSimple = !+out.shear.toFixed(9) && out.scalex.toFixed(9) == out.scaley.toFixed(9) && !out.rotate;
  16195. out.noRotation = !+out.shear.toFixed(9) && !out.rotate;
  16196. return out;
  16197. };
  16198. /*\
  16199. * Matrix.toTransformString
  16200. [ method ]
  16201. **
  16202. * Returns transform string that represents given matrix
  16203. = (string) transform string
  16204. \*/
  16205. matrixproto.toTransformString = function (shorter) {
  16206. var s = shorter || this.split();
  16207. if (!+s.shear.toFixed(9)) {
  16208. s.scalex = +s.scalex.toFixed(4);
  16209. s.scaley = +s.scaley.toFixed(4);
  16210. s.rotate = +s.rotate.toFixed(4);
  16211. return (s.dx || s.dy ? "t" + [+s.dx.toFixed(4), +s.dy.toFixed(4)] : E) +
  16212. (s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) +
  16213. (s.rotate ? "r" + [+s.rotate.toFixed(4), 0, 0] : E);
  16214. } else {
  16215. return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)];
  16216. }
  16217. };
  16218. })(Matrix.prototype);
  16219. /*\
  16220. * Snap.Matrix
  16221. [ method ]
  16222. **
  16223. * Matrix constructor, extend on your own risk.
  16224. * To create matrices use @Snap.matrix.
  16225. \*/
  16226. Snap.Matrix = Matrix;
  16227. /*\
  16228. * Snap.matrix
  16229. [ method ]
  16230. **
  16231. * Utility method
  16232. **
  16233. * Returns a matrix based on the given parameters
  16234. - a (number)
  16235. - b (number)
  16236. - c (number)
  16237. - d (number)
  16238. - e (number)
  16239. - f (number)
  16240. * or
  16241. - svgMatrix (SVGMatrix)
  16242. = (object) @Matrix
  16243. \*/
  16244. Snap.matrix = function (a, b, c, d, e, f) {
  16245. return new Matrix(a, b, c, d, e, f);
  16246. };
  16247. });
  16248. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  16249. //
  16250. // Licensed under the Apache License, Version 2.0 (the "License");
  16251. // you may not use this file except in compliance with the License.
  16252. // You may obtain a copy of the License at
  16253. //
  16254. // http://www.apache.org/licenses/LICENSE-2.0
  16255. //
  16256. // Unless required by applicable law or agreed to in writing, software
  16257. // distributed under the License is distributed on an "AS IS" BASIS,
  16258. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16259. // See the License for the specific language governing permissions and
  16260. // limitations under the License.
  16261. Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
  16262. var has = "hasOwnProperty",
  16263. make = Snap._.make,
  16264. wrap = Snap._.wrap,
  16265. is = Snap.is,
  16266. getSomeDefs = Snap._.getSomeDefs,
  16267. reURLValue = /^url\(#?([^)]+)\)$/,
  16268. $ = Snap._.$,
  16269. URL = Snap.url,
  16270. Str = String,
  16271. separator = Snap._.separator,
  16272. E = "";
  16273. // Attributes event handlers
  16274. eve.on("snap.util.attr.mask", function (value) {
  16275. if (value instanceof Element || value instanceof Fragment) {
  16276. eve.stop();
  16277. if (value instanceof Fragment && value.node.childNodes.length == 1) {
  16278. value = value.node.firstChild;
  16279. getSomeDefs(this).appendChild(value);
  16280. value = wrap(value);
  16281. }
  16282. if (value.type == "mask") {
  16283. var mask = value;
  16284. } else {
  16285. mask = make("mask", getSomeDefs(this));
  16286. mask.node.appendChild(value.node);
  16287. }
  16288. !mask.node.id && $(mask.node, {
  16289. id: mask.id
  16290. });
  16291. $(this.node, {
  16292. mask: URL(mask.id)
  16293. });
  16294. }
  16295. });
  16296. (function (clipIt) {
  16297. eve.on("snap.util.attr.clip", clipIt);
  16298. eve.on("snap.util.attr.clip-path", clipIt);
  16299. eve.on("snap.util.attr.clipPath", clipIt);
  16300. }(function (value) {
  16301. if (value instanceof Element || value instanceof Fragment) {
  16302. eve.stop();
  16303. if (value.type == "clipPath") {
  16304. var clip = value;
  16305. } else {
  16306. clip = make("clipPath", getSomeDefs(this));
  16307. clip.node.appendChild(value.node);
  16308. !clip.node.id && $(clip.node, {
  16309. id: clip.id
  16310. });
  16311. }
  16312. $(this.node, {
  16313. "clip-path": URL(clip.node.id || clip.id)
  16314. });
  16315. }
  16316. }));
  16317. function fillStroke(name) {
  16318. return function (value) {
  16319. eve.stop();
  16320. if (value instanceof Fragment && value.node.childNodes.length == 1 &&
  16321. (value.node.firstChild.tagName == "radialGradient" ||
  16322. value.node.firstChild.tagName == "linearGradient" ||
  16323. value.node.firstChild.tagName == "pattern")) {
  16324. value = value.node.firstChild;
  16325. getSomeDefs(this).appendChild(value);
  16326. value = wrap(value);
  16327. }
  16328. if (value instanceof Element) {
  16329. if (value.type == "radialGradient" || value.type == "linearGradient"
  16330. || value.type == "pattern") {
  16331. if (!value.node.id) {
  16332. $(value.node, {
  16333. id: value.id
  16334. });
  16335. }
  16336. var fill = URL(value.node.id);
  16337. } else {
  16338. fill = value.attr(name);
  16339. }
  16340. } else {
  16341. fill = Snap.color(value);
  16342. if (fill.error) {
  16343. var grad = Snap(getSomeDefs(this).ownerSVGElement).gradient(value);
  16344. if (grad) {
  16345. if (!grad.node.id) {
  16346. $(grad.node, {
  16347. id: grad.id
  16348. });
  16349. }
  16350. fill = URL(grad.node.id);
  16351. } else {
  16352. fill = value;
  16353. }
  16354. } else {
  16355. fill = Str(fill);
  16356. }
  16357. }
  16358. var attrs = {};
  16359. attrs[name] = fill;
  16360. $(this.node, attrs);
  16361. this.node.style[name] = E;
  16362. };
  16363. }
  16364. eve.on("snap.util.attr.fill", fillStroke("fill"));
  16365. eve.on("snap.util.attr.stroke", fillStroke("stroke"));
  16366. var gradrg = /^([lr])(?:\(([^)]*)\))?(.*)$/i;
  16367. eve.on("snap.util.grad.parse", function parseGrad(string) {
  16368. string = Str(string);
  16369. var tokens = string.match(gradrg);
  16370. if (!tokens) {
  16371. return null;
  16372. }
  16373. var type = tokens[1],
  16374. params = tokens[2],
  16375. stops = tokens[3];
  16376. params = params.split(/\s*,\s*/).map(function (el) {
  16377. return +el == el ? +el : el;
  16378. });
  16379. if (params.length == 1 && params[0] == 0) {
  16380. params = [];
  16381. }
  16382. stops = stops.split("-");
  16383. stops = stops.map(function (el) {
  16384. el = el.split(":");
  16385. var out = {
  16386. color: el[0]
  16387. };
  16388. if (el[1]) {
  16389. out.offset = parseFloat(el[1]);
  16390. }
  16391. return out;
  16392. });
  16393. return {
  16394. type: type,
  16395. params: params,
  16396. stops: stops
  16397. };
  16398. });
  16399. eve.on("snap.util.attr.d", function (value) {
  16400. eve.stop();
  16401. if (is(value, "array") && is(value[0], "array")) {
  16402. value = Snap.path.toString.call(value);
  16403. }
  16404. value = Str(value);
  16405. if (value.match(/[ruo]/i)) {
  16406. value = Snap.path.toAbsolute(value);
  16407. }
  16408. $(this.node, {d: value});
  16409. })(-1);
  16410. eve.on("snap.util.attr.#text", function (value) {
  16411. eve.stop();
  16412. value = Str(value);
  16413. var txt = glob.doc.createTextNode(value);
  16414. while (this.node.firstChild) {
  16415. this.node.removeChild(this.node.firstChild);
  16416. }
  16417. this.node.appendChild(txt);
  16418. })(-1);
  16419. eve.on("snap.util.attr.path", function (value) {
  16420. eve.stop();
  16421. this.attr({d: value});
  16422. })(-1);
  16423. eve.on("snap.util.attr.class", function (value) {
  16424. eve.stop();
  16425. this.node.className.baseVal = value;
  16426. })(-1);
  16427. eve.on("snap.util.attr.viewBox", function (value) {
  16428. var vb;
  16429. if (is(value, "object") && "x" in value) {
  16430. vb = [value.x, value.y, value.width, value.height].join(" ");
  16431. } else if (is(value, "array")) {
  16432. vb = value.join(" ");
  16433. } else {
  16434. vb = value;
  16435. }
  16436. $(this.node, {
  16437. viewBox: vb
  16438. });
  16439. eve.stop();
  16440. })(-1);
  16441. eve.on("snap.util.attr.transform", function (value) {
  16442. this.transform(value);
  16443. eve.stop();
  16444. })(-1);
  16445. eve.on("snap.util.attr.r", function (value) {
  16446. if (this.type == "rect") {
  16447. eve.stop();
  16448. $(this.node, {
  16449. rx: value,
  16450. ry: value
  16451. });
  16452. }
  16453. })(-1);
  16454. eve.on("snap.util.attr.textpath", function (value) {
  16455. eve.stop();
  16456. if (this.type == "text") {
  16457. var id, tp, node;
  16458. if (!value && this.textPath) {
  16459. tp = this.textPath;
  16460. while (tp.node.firstChild) {
  16461. this.node.appendChild(tp.node.firstChild);
  16462. }
  16463. tp.remove();
  16464. delete this.textPath;
  16465. return;
  16466. }
  16467. if (is(value, "string")) {
  16468. var defs = getSomeDefs(this),
  16469. path = wrap(defs.parentNode).path(value);
  16470. defs.appendChild(path.node);
  16471. id = path.id;
  16472. path.attr({id: id});
  16473. } else {
  16474. value = wrap(value);
  16475. if (value instanceof Element) {
  16476. id = value.attr("id");
  16477. if (!id) {
  16478. id = value.id;
  16479. value.attr({id: id});
  16480. }
  16481. }
  16482. }
  16483. if (id) {
  16484. tp = this.textPath;
  16485. node = this.node;
  16486. if (tp) {
  16487. tp.attr({"xlink:href": "#" + id});
  16488. } else {
  16489. tp = $("textPath", {
  16490. "xlink:href": "#" + id
  16491. });
  16492. while (node.firstChild) {
  16493. tp.appendChild(node.firstChild);
  16494. }
  16495. node.appendChild(tp);
  16496. this.textPath = wrap(tp);
  16497. }
  16498. }
  16499. }
  16500. })(-1);
  16501. eve.on("snap.util.attr.text", function (value) {
  16502. if (this.type == "text") {
  16503. var i = 0,
  16504. node = this.node,
  16505. tuner = function (chunk) {
  16506. var out = $("tspan");
  16507. if (is(chunk, "array")) {
  16508. for (var i = 0; i < chunk.length; i++) {
  16509. out.appendChild(tuner(chunk[i]));
  16510. }
  16511. } else {
  16512. out.appendChild(glob.doc.createTextNode(chunk));
  16513. }
  16514. out.normalize && out.normalize();
  16515. return out;
  16516. };
  16517. while (node.firstChild) {
  16518. node.removeChild(node.firstChild);
  16519. }
  16520. var tuned = tuner(value);
  16521. while (tuned.firstChild) {
  16522. node.appendChild(tuned.firstChild);
  16523. }
  16524. }
  16525. eve.stop();
  16526. })(-1);
  16527. function setFontSize(value) {
  16528. eve.stop();
  16529. if (value == +value) {
  16530. value += "px";
  16531. }
  16532. this.node.style.fontSize = value;
  16533. }
  16534. eve.on("snap.util.attr.fontSize", setFontSize)(-1);
  16535. eve.on("snap.util.attr.font-size", setFontSize)(-1);
  16536. eve.on("snap.util.getattr.transform", function () {
  16537. eve.stop();
  16538. return this.transform();
  16539. })(-1);
  16540. eve.on("snap.util.getattr.textpath", function () {
  16541. eve.stop();
  16542. return this.textPath;
  16543. })(-1);
  16544. // Markers
  16545. (function () {
  16546. function getter(end) {
  16547. return function () {
  16548. eve.stop();
  16549. var style = glob.doc.defaultView.getComputedStyle(this.node, null).getPropertyValue("marker-" + end);
  16550. if (style == "none") {
  16551. return style;
  16552. } else {
  16553. return Snap(glob.doc.getElementById(style.match(reURLValue)[1]));
  16554. }
  16555. };
  16556. }
  16557. function setter(end) {
  16558. return function (value) {
  16559. eve.stop();
  16560. var name = "marker" + end.charAt(0).toUpperCase() + end.substring(1);
  16561. if (value == "" || !value) {
  16562. this.node.style[name] = "none";
  16563. return;
  16564. }
  16565. if (value.type == "marker") {
  16566. var id = value.node.id;
  16567. if (!id) {
  16568. $(value.node, {id: value.id});
  16569. }
  16570. this.node.style[name] = URL(id);
  16571. return;
  16572. }
  16573. };
  16574. }
  16575. eve.on("snap.util.getattr.marker-end", getter("end"))(-1);
  16576. eve.on("snap.util.getattr.markerEnd", getter("end"))(-1);
  16577. eve.on("snap.util.getattr.marker-start", getter("start"))(-1);
  16578. eve.on("snap.util.getattr.markerStart", getter("start"))(-1);
  16579. eve.on("snap.util.getattr.marker-mid", getter("mid"))(-1);
  16580. eve.on("snap.util.getattr.markerMid", getter("mid"))(-1);
  16581. eve.on("snap.util.attr.marker-end", setter("end"))(-1);
  16582. eve.on("snap.util.attr.markerEnd", setter("end"))(-1);
  16583. eve.on("snap.util.attr.marker-start", setter("start"))(-1);
  16584. eve.on("snap.util.attr.markerStart", setter("start"))(-1);
  16585. eve.on("snap.util.attr.marker-mid", setter("mid"))(-1);
  16586. eve.on("snap.util.attr.markerMid", setter("mid"))(-1);
  16587. }());
  16588. eve.on("snap.util.getattr.r", function () {
  16589. if (this.type == "rect" && $(this.node, "rx") == $(this.node, "ry")) {
  16590. eve.stop();
  16591. return $(this.node, "rx");
  16592. }
  16593. })(-1);
  16594. function textExtract(node) {
  16595. var out = [];
  16596. var children = node.childNodes;
  16597. for (var i = 0, ii = children.length; i < ii; i++) {
  16598. var chi = children[i];
  16599. if (chi.nodeType == 3) {
  16600. out.push(chi.nodeValue);
  16601. }
  16602. if (chi.tagName == "tspan") {
  16603. if (chi.childNodes.length == 1 && chi.firstChild.nodeType == 3) {
  16604. out.push(chi.firstChild.nodeValue);
  16605. } else {
  16606. out.push(textExtract(chi));
  16607. }
  16608. }
  16609. }
  16610. return out;
  16611. }
  16612. eve.on("snap.util.getattr.text", function () {
  16613. if (this.type == "text" || this.type == "tspan") {
  16614. eve.stop();
  16615. var out = textExtract(this.node);
  16616. return out.length == 1 ? out[0] : out;
  16617. }
  16618. })(-1);
  16619. eve.on("snap.util.getattr.#text", function () {
  16620. return this.node.textContent;
  16621. })(-1);
  16622. eve.on("snap.util.getattr.viewBox", function () {
  16623. eve.stop();
  16624. var vb = $(this.node, "viewBox");
  16625. if (vb) {
  16626. vb = vb.split(separator);
  16627. return Snap._.box(+vb[0], +vb[1], +vb[2], +vb[3]);
  16628. } else {
  16629. return;
  16630. }
  16631. })(-1);
  16632. eve.on("snap.util.getattr.points", function () {
  16633. var p = $(this.node, "points");
  16634. eve.stop();
  16635. if (p) {
  16636. return p.split(separator);
  16637. } else {
  16638. return;
  16639. }
  16640. })(-1);
  16641. eve.on("snap.util.getattr.path", function () {
  16642. var p = $(this.node, "d");
  16643. eve.stop();
  16644. return p;
  16645. })(-1);
  16646. eve.on("snap.util.getattr.class", function () {
  16647. return this.node.className.baseVal;
  16648. })(-1);
  16649. function getFontSize() {
  16650. eve.stop();
  16651. return this.node.style.fontSize;
  16652. }
  16653. eve.on("snap.util.getattr.fontSize", getFontSize)(-1);
  16654. eve.on("snap.util.getattr.font-size", getFontSize)(-1);
  16655. });
  16656. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  16657. //
  16658. // Licensed under the Apache License, Version 2.0 (the "License");
  16659. // you may not use this file except in compliance with the License.
  16660. // You may obtain a copy of the License at
  16661. //
  16662. // http://www.apache.org/licenses/LICENSE-2.0
  16663. //
  16664. // Unless required by applicable law or agreed to in writing, software
  16665. // distributed under the License is distributed on an "AS IS" BASIS,
  16666. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16667. // See the License for the specific language governing permissions and
  16668. // limitations under the License.
  16669. Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
  16670. var proto = Paper.prototype,
  16671. is = Snap.is;
  16672. /*\
  16673. * Paper.rect
  16674. [ method ]
  16675. *
  16676. * Draws a rectangle
  16677. **
  16678. - x (number) x coordinate of the top left corner
  16679. - y (number) y coordinate of the top left corner
  16680. - width (number) width
  16681. - height (number) height
  16682. - rx (number) #optional horizontal radius for rounded corners, default is 0
  16683. - ry (number) #optional vertical radius for rounded corners, default is rx or 0
  16684. = (object) the `rect` element
  16685. **
  16686. > Usage
  16687. | // regular rectangle
  16688. | var c = paper.rect(10, 10, 50, 50);
  16689. | // rectangle with rounded corners
  16690. | var c = paper.rect(40, 40, 50, 50, 10);
  16691. \*/
  16692. proto.rect = function (x, y, w, h, rx, ry) {
  16693. var attr;
  16694. if (ry == null) {
  16695. ry = rx;
  16696. }
  16697. if (is(x, "object") && x == "[object Object]") {
  16698. attr = x;
  16699. } else if (x != null) {
  16700. attr = {
  16701. x: x,
  16702. y: y,
  16703. width: w,
  16704. height: h
  16705. };
  16706. if (rx != null) {
  16707. attr.rx = rx;
  16708. attr.ry = ry;
  16709. }
  16710. }
  16711. return this.el("rect", attr);
  16712. };
  16713. /*\
  16714. * Paper.circle
  16715. [ method ]
  16716. **
  16717. * Draws a circle
  16718. **
  16719. - x (number) x coordinate of the centre
  16720. - y (number) y coordinate of the centre
  16721. - r (number) radius
  16722. = (object) the `circle` element
  16723. **
  16724. > Usage
  16725. | var c = paper.circle(50, 50, 40);
  16726. \*/
  16727. proto.circle = function (cx, cy, r) {
  16728. var attr;
  16729. if (is(cx, "object") && cx == "[object Object]") {
  16730. attr = cx;
  16731. } else if (cx != null) {
  16732. attr = {
  16733. cx: cx,
  16734. cy: cy,
  16735. r: r
  16736. };
  16737. }
  16738. return this.el("circle", attr);
  16739. };
  16740. var preload = (function () {
  16741. function onerror() {
  16742. this.parentNode.removeChild(this);
  16743. }
  16744. return function (src, f) {
  16745. var img = glob.doc.createElement("img"),
  16746. body = glob.doc.body;
  16747. img.style.cssText = "position:absolute;left:-9999em;top:-9999em";
  16748. img.onload = function () {
  16749. f.call(img);
  16750. img.onload = img.onerror = null;
  16751. body.removeChild(img);
  16752. };
  16753. img.onerror = onerror;
  16754. body.appendChild(img);
  16755. img.src = src;
  16756. };
  16757. }());
  16758. /*\
  16759. * Paper.image
  16760. [ method ]
  16761. **
  16762. * Places an image on the surface
  16763. **
  16764. - src (string) URI of the source image
  16765. - x (number) x offset position
  16766. - y (number) y offset position
  16767. - width (number) width of the image
  16768. - height (number) height of the image
  16769. = (object) the `image` element
  16770. * or
  16771. = (object) Snap element object with type `image`
  16772. **
  16773. > Usage
  16774. | var c = paper.image("apple.png", 10, 10, 80, 80);
  16775. \*/
  16776. proto.image = function (src, x, y, width, height) {
  16777. var el = this.el("image");
  16778. if (is(src, "object") && "src" in src) {
  16779. el.attr(src);
  16780. } else if (src != null) {
  16781. var set = {
  16782. "xlink:href": src,
  16783. preserveAspectRatio: "none"
  16784. };
  16785. if (x != null && y != null) {
  16786. set.x = x;
  16787. set.y = y;
  16788. }
  16789. if (width != null && height != null) {
  16790. set.width = width;
  16791. set.height = height;
  16792. } else {
  16793. preload(src, function () {
  16794. Snap._.$(el.node, {
  16795. width: this.offsetWidth,
  16796. height: this.offsetHeight
  16797. });
  16798. });
  16799. }
  16800. Snap._.$(el.node, set);
  16801. }
  16802. return el;
  16803. };
  16804. /*\
  16805. * Paper.ellipse
  16806. [ method ]
  16807. **
  16808. * Draws an ellipse
  16809. **
  16810. - x (number) x coordinate of the centre
  16811. - y (number) y coordinate of the centre
  16812. - rx (number) horizontal radius
  16813. - ry (number) vertical radius
  16814. = (object) the `ellipse` element
  16815. **
  16816. > Usage
  16817. | var c = paper.ellipse(50, 50, 40, 20);
  16818. \*/
  16819. proto.ellipse = function (cx, cy, rx, ry) {
  16820. var attr;
  16821. if (is(cx, "object") && cx == "[object Object]") {
  16822. attr = cx;
  16823. } else if (cx != null) {
  16824. attr ={
  16825. cx: cx,
  16826. cy: cy,
  16827. rx: rx,
  16828. ry: ry
  16829. };
  16830. }
  16831. return this.el("ellipse", attr);
  16832. };
  16833. // SIERRA Paper.path(): Unclear from the link what a Catmull-Rom curveto is, and why it would make life any easier.
  16834. /*\
  16835. * Paper.path
  16836. [ method ]
  16837. **
  16838. * Creates a `<path>` element using the given string as the path's definition
  16839. - pathString (string) #optional path string in SVG format
  16840. * Path string consists of one-letter commands, followed by comma seprarated arguments in numerical form. Example:
  16841. | "M10,20L30,40"
  16842. * 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.
  16843. *
  16844. # <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>
  16845. # <table><thead><tr><th>Command</th><th>Name</th><th>Parameters</th></tr></thead><tbody>
  16846. # <tr><td>M</td><td>moveto</td><td>(x y)+</td></tr>
  16847. # <tr><td>Z</td><td>closepath</td><td>(none)</td></tr>
  16848. # <tr><td>L</td><td>lineto</td><td>(x y)+</td></tr>
  16849. # <tr><td>H</td><td>horizontal lineto</td><td>x+</td></tr>
  16850. # <tr><td>V</td><td>vertical lineto</td><td>y+</td></tr>
  16851. # <tr><td>C</td><td>curveto</td><td>(x1 y1 x2 y2 x y)+</td></tr>
  16852. # <tr><td>S</td><td>smooth curveto</td><td>(x2 y2 x y)+</td></tr>
  16853. # <tr><td>Q</td><td>quadratic Bézier curveto</td><td>(x1 y1 x y)+</td></tr>
  16854. # <tr><td>T</td><td>smooth quadratic Bézier curveto</td><td>(x y)+</td></tr>
  16855. # <tr><td>A</td><td>elliptical arc</td><td>(rx ry x-axis-rotation large-arc-flag sweep-flag x y)+</td></tr>
  16856. # <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>
  16857. * * _Catmull-Rom curveto_ is a not standard SVG command and added to make life easier.
  16858. * 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.
  16859. > Usage
  16860. | var c = paper.path("M10 10L90 90");
  16861. | // draw a diagonal line:
  16862. | // move to 10,10, line to 90,90
  16863. \*/
  16864. proto.path = function (d) {
  16865. var attr;
  16866. if (is(d, "object") && !is(d, "array")) {
  16867. attr = d;
  16868. } else if (d) {
  16869. attr = {d: d};
  16870. }
  16871. return this.el("path", attr);
  16872. };
  16873. /*\
  16874. * Paper.g
  16875. [ method ]
  16876. **
  16877. * Creates a group element
  16878. **
  16879. - varargs (…) #optional elements to nest within the group
  16880. = (object) the `g` element
  16881. **
  16882. > Usage
  16883. | var c1 = paper.circle(),
  16884. | c2 = paper.rect(),
  16885. | g = paper.g(c2, c1); // note that the order of elements is different
  16886. * or
  16887. | var c1 = paper.circle(),
  16888. | c2 = paper.rect(),
  16889. | g = paper.g();
  16890. | g.add(c2, c1);
  16891. \*/
  16892. /*\
  16893. * Paper.group
  16894. [ method ]
  16895. **
  16896. * See @Paper.g
  16897. \*/
  16898. proto.group = proto.g = function (first) {
  16899. var attr,
  16900. el = this.el("g");
  16901. if (arguments.length == 1 && first && !first.type) {
  16902. el.attr(first);
  16903. } else if (arguments.length) {
  16904. el.add(Array.prototype.slice.call(arguments, 0));
  16905. }
  16906. return el;
  16907. };
  16908. /*\
  16909. * Paper.svg
  16910. [ method ]
  16911. **
  16912. * Creates a nested SVG element.
  16913. - x (number) @optional X of the element
  16914. - y (number) @optional Y of the element
  16915. - width (number) @optional width of the element
  16916. - height (number) @optional height of the element
  16917. - vbx (number) @optional viewbox X
  16918. - vby (number) @optional viewbox Y
  16919. - vbw (number) @optional viewbox width
  16920. - vbh (number) @optional viewbox height
  16921. **
  16922. = (object) the `svg` element
  16923. **
  16924. \*/
  16925. proto.svg = function (x, y, width, height, vbx, vby, vbw, vbh) {
  16926. var attrs = {};
  16927. if (is(x, "object") && y == null) {
  16928. attrs = x;
  16929. } else {
  16930. if (x != null) {
  16931. attrs.x = x;
  16932. }
  16933. if (y != null) {
  16934. attrs.y = y;
  16935. }
  16936. if (width != null) {
  16937. attrs.width = width;
  16938. }
  16939. if (height != null) {
  16940. attrs.height = height;
  16941. }
  16942. if (vbx != null && vby != null && vbw != null && vbh != null) {
  16943. attrs.viewBox = [vbx, vby, vbw, vbh];
  16944. }
  16945. }
  16946. return this.el("svg", attrs);
  16947. };
  16948. /*\
  16949. * Paper.mask
  16950. [ method ]
  16951. **
  16952. * Equivalent in behaviour to @Paper.g, except it’s a mask.
  16953. **
  16954. = (object) the `mask` element
  16955. **
  16956. \*/
  16957. proto.mask = function (first) {
  16958. var attr,
  16959. el = this.el("mask");
  16960. if (arguments.length == 1 && first && !first.type) {
  16961. el.attr(first);
  16962. } else if (arguments.length) {
  16963. el.add(Array.prototype.slice.call(arguments, 0));
  16964. }
  16965. return el;
  16966. };
  16967. /*\
  16968. * Paper.ptrn
  16969. [ method ]
  16970. **
  16971. * Equivalent in behaviour to @Paper.g, except it’s a pattern.
  16972. - x (number) @optional X of the element
  16973. - y (number) @optional Y of the element
  16974. - width (number) @optional width of the element
  16975. - height (number) @optional height of the element
  16976. - vbx (number) @optional viewbox X
  16977. - vby (number) @optional viewbox Y
  16978. - vbw (number) @optional viewbox width
  16979. - vbh (number) @optional viewbox height
  16980. **
  16981. = (object) the `pattern` element
  16982. **
  16983. \*/
  16984. proto.ptrn = function (x, y, width, height, vx, vy, vw, vh) {
  16985. if (is(x, "object")) {
  16986. var attr = x;
  16987. } else {
  16988. attr = {patternUnits: "userSpaceOnUse"};
  16989. if (x) {
  16990. attr.x = x;
  16991. }
  16992. if (y) {
  16993. attr.y = y;
  16994. }
  16995. if (width != null) {
  16996. attr.width = width;
  16997. }
  16998. if (height != null) {
  16999. attr.height = height;
  17000. }
  17001. if (vx != null && vy != null && vw != null && vh != null) {
  17002. attr.viewBox = [vx, vy, vw, vh];
  17003. }
  17004. }
  17005. return this.el("pattern", attr);
  17006. };
  17007. /*\
  17008. * Paper.use
  17009. [ method ]
  17010. **
  17011. * Creates a <use> element.
  17012. - id (string) @optional id of element to link
  17013. * or
  17014. - id (Element) @optional element to link
  17015. **
  17016. = (object) the `use` element
  17017. **
  17018. \*/
  17019. proto.use = function (id) {
  17020. if (id != null) {
  17021. if (id instanceof Element) {
  17022. if (!id.attr("id")) {
  17023. id.attr({id: Snap._.id(id)});
  17024. }
  17025. id = id.attr("id");
  17026. }
  17027. if (String(id).charAt() == "#") {
  17028. id = id.substring(1);
  17029. }
  17030. return this.el("use", {"xlink:href": "#" + id});
  17031. } else {
  17032. return Element.prototype.use.call(this);
  17033. }
  17034. };
  17035. /*\
  17036. * Paper.symbol
  17037. [ method ]
  17038. **
  17039. * Creates a <symbol> element.
  17040. - vbx (number) @optional viewbox X
  17041. - vby (number) @optional viewbox Y
  17042. - vbw (number) @optional viewbox width
  17043. - vbh (number) @optional viewbox height
  17044. = (object) the `symbol` element
  17045. **
  17046. \*/
  17047. proto.symbol = function (vx, vy, vw, vh) {
  17048. var attr = {};
  17049. if (vx != null && vy != null && vw != null && vh != null) {
  17050. attr.viewBox = [vx, vy, vw, vh];
  17051. }
  17052. return this.el("symbol", attr);
  17053. };
  17054. /*\
  17055. * Paper.text
  17056. [ method ]
  17057. **
  17058. * Draws a text string
  17059. **
  17060. - x (number) x coordinate position
  17061. - y (number) y coordinate position
  17062. - text (string|array) The text string to draw or array of strings to nest within separate `<tspan>` elements
  17063. = (object) the `text` element
  17064. **
  17065. > Usage
  17066. | var t1 = paper.text(50, 50, "Snap");
  17067. | var t2 = paper.text(50, 50, ["S","n","a","p"]);
  17068. | // Text path usage
  17069. | t1.attr({textpath: "M10,10L100,100"});
  17070. | // or
  17071. | var pth = paper.path("M10,10L100,100");
  17072. | t1.attr({textpath: pth});
  17073. \*/
  17074. proto.text = function (x, y, text) {
  17075. var attr = {};
  17076. if (is(x, "object")) {
  17077. attr = x;
  17078. } else if (x != null) {
  17079. attr = {
  17080. x: x,
  17081. y: y,
  17082. text: text || ""
  17083. };
  17084. }
  17085. return this.el("text", attr);
  17086. };
  17087. /*\
  17088. * Paper.line
  17089. [ method ]
  17090. **
  17091. * Draws a line
  17092. **
  17093. - x1 (number) x coordinate position of the start
  17094. - y1 (number) y coordinate position of the start
  17095. - x2 (number) x coordinate position of the end
  17096. - y2 (number) y coordinate position of the end
  17097. = (object) the `line` element
  17098. **
  17099. > Usage
  17100. | var t1 = paper.line(50, 50, 100, 100);
  17101. \*/
  17102. proto.line = function (x1, y1, x2, y2) {
  17103. var attr = {};
  17104. if (is(x1, "object")) {
  17105. attr = x1;
  17106. } else if (x1 != null) {
  17107. attr = {
  17108. x1: x1,
  17109. x2: x2,
  17110. y1: y1,
  17111. y2: y2
  17112. };
  17113. }
  17114. return this.el("line", attr);
  17115. };
  17116. /*\
  17117. * Paper.polyline
  17118. [ method ]
  17119. **
  17120. * Draws a polyline
  17121. **
  17122. - points (array) array of points
  17123. * or
  17124. - varargs (…) points
  17125. = (object) the `polyline` element
  17126. **
  17127. > Usage
  17128. | var p1 = paper.polyline([10, 10, 100, 100]);
  17129. | var p2 = paper.polyline(10, 10, 100, 100);
  17130. \*/
  17131. proto.polyline = function (points) {
  17132. if (arguments.length > 1) {
  17133. points = Array.prototype.slice.call(arguments, 0);
  17134. }
  17135. var attr = {};
  17136. if (is(points, "object") && !is(points, "array")) {
  17137. attr = points;
  17138. } else if (points != null) {
  17139. attr = {points: points};
  17140. }
  17141. return this.el("polyline", attr);
  17142. };
  17143. /*\
  17144. * Paper.polygon
  17145. [ method ]
  17146. **
  17147. * Draws a polygon. See @Paper.polyline
  17148. \*/
  17149. proto.polygon = function (points) {
  17150. if (arguments.length > 1) {
  17151. points = Array.prototype.slice.call(arguments, 0);
  17152. }
  17153. var attr = {};
  17154. if (is(points, "object") && !is(points, "array")) {
  17155. attr = points;
  17156. } else if (points != null) {
  17157. attr = {points: points};
  17158. }
  17159. return this.el("polygon", attr);
  17160. };
  17161. // gradients
  17162. (function () {
  17163. var $ = Snap._.$;
  17164. // gradients' helpers
  17165. function Gstops() {
  17166. return this.selectAll("stop");
  17167. }
  17168. function GaddStop(color, offset) {
  17169. var stop = $("stop"),
  17170. attr = {
  17171. offset: +offset + "%"
  17172. };
  17173. color = Snap.color(color);
  17174. attr["stop-color"] = color.hex;
  17175. if (color.opacity < 1) {
  17176. attr["stop-opacity"] = color.opacity;
  17177. }
  17178. $(stop, attr);
  17179. this.node.appendChild(stop);
  17180. return this;
  17181. }
  17182. function GgetBBox() {
  17183. if (this.type == "linearGradient") {
  17184. var x1 = $(this.node, "x1") || 0,
  17185. x2 = $(this.node, "x2") || 1,
  17186. y1 = $(this.node, "y1") || 0,
  17187. y2 = $(this.node, "y2") || 0;
  17188. return Snap._.box(x1, y1, math.abs(x2 - x1), math.abs(y2 - y1));
  17189. } else {
  17190. var cx = this.node.cx || .5,
  17191. cy = this.node.cy || .5,
  17192. r = this.node.r || 0;
  17193. return Snap._.box(cx - r, cy - r, r * 2, r * 2);
  17194. }
  17195. }
  17196. function gradient(defs, str) {
  17197. var grad = eve("snap.util.grad.parse", null, str).firstDefined(),
  17198. el;
  17199. if (!grad) {
  17200. return null;
  17201. }
  17202. grad.params.unshift(defs);
  17203. if (grad.type.toLowerCase() == "l") {
  17204. el = gradientLinear.apply(0, grad.params);
  17205. } else {
  17206. el = gradientRadial.apply(0, grad.params);
  17207. }
  17208. if (grad.type != grad.type.toLowerCase()) {
  17209. $(el.node, {
  17210. gradientUnits: "userSpaceOnUse"
  17211. });
  17212. }
  17213. var stops = grad.stops,
  17214. len = stops.length,
  17215. start = 0,
  17216. j = 0;
  17217. function seed(i, end) {
  17218. var step = (end - start) / (i - j);
  17219. for (var k = j; k < i; k++) {
  17220. stops[k].offset = +(+start + step * (k - j)).toFixed(2);
  17221. }
  17222. j = i;
  17223. start = end;
  17224. }
  17225. len--;
  17226. for (var i = 0; i < len; i++) if ("offset" in stops[i]) {
  17227. seed(i, stops[i].offset);
  17228. }
  17229. stops[len].offset = stops[len].offset || 100;
  17230. seed(len, stops[len].offset);
  17231. for (i = 0; i <= len; i++) {
  17232. var stop = stops[i];
  17233. el.addStop(stop.color, stop.offset);
  17234. }
  17235. return el;
  17236. }
  17237. function gradientLinear(defs, x1, y1, x2, y2) {
  17238. var el = Snap._.make("linearGradient", defs);
  17239. el.stops = Gstops;
  17240. el.addStop = GaddStop;
  17241. el.getBBox = GgetBBox;
  17242. if (x1 != null) {
  17243. $(el.node, {
  17244. x1: x1,
  17245. y1: y1,
  17246. x2: x2,
  17247. y2: y2
  17248. });
  17249. }
  17250. return el;
  17251. }
  17252. function gradientRadial(defs, cx, cy, r, fx, fy) {
  17253. var el = Snap._.make("radialGradient", defs);
  17254. el.stops = Gstops;
  17255. el.addStop = GaddStop;
  17256. el.getBBox = GgetBBox;
  17257. if (cx != null) {
  17258. $(el.node, {
  17259. cx: cx,
  17260. cy: cy,
  17261. r: r
  17262. });
  17263. }
  17264. if (fx != null && fy != null) {
  17265. $(el.node, {
  17266. fx: fx,
  17267. fy: fy
  17268. });
  17269. }
  17270. return el;
  17271. }
  17272. /*\
  17273. * Paper.gradient
  17274. [ method ]
  17275. **
  17276. * Creates a gradient element
  17277. **
  17278. - gradient (string) gradient descriptor
  17279. > Gradient Descriptor
  17280. * The gradient descriptor is an expression formatted as
  17281. * follows: `<type>(<coords>)<colors>`. The `<type>` can be
  17282. * either linear or radial. The uppercase `L` or `R` letters
  17283. * indicate absolute coordinates offset from the SVG surface.
  17284. * Lowercase `l` or `r` letters indicate coordinates
  17285. * calculated relative to the element to which the gradient is
  17286. * applied. Coordinates specify a linear gradient vector as
  17287. * `x1`, `y1`, `x2`, `y2`, or a radial gradient as `cx`, `cy`,
  17288. * `r` and optional `fx`, `fy` specifying a focal point away
  17289. * from the center of the circle. Specify `<colors>` as a list
  17290. * of dash-separated CSS color values. Each color may be
  17291. * followed by a custom offset value, separated with a colon
  17292. * character.
  17293. > Examples
  17294. * Linear gradient, relative from top-left corner to bottom-right
  17295. * corner, from black through red to white:
  17296. | var g = paper.gradient("l(0, 0, 1, 1)#000-#f00-#fff");
  17297. * Linear gradient, absolute from (0, 0) to (100, 100), from black
  17298. * through red at 25% to white:
  17299. | var g = paper.gradient("L(0, 0, 100, 100)#000-#f00:25-#fff");
  17300. * Radial gradient, relative from the center of the element with radius
  17301. * half the width, from black to white:
  17302. | var g = paper.gradient("r(0.5, 0.5, 0.5)#000-#fff");
  17303. * To apply the gradient:
  17304. | paper.circle(50, 50, 40).attr({
  17305. | fill: g
  17306. | });
  17307. = (object) the `gradient` element
  17308. \*/
  17309. proto.gradient = function (str) {
  17310. return gradient(this.defs, str);
  17311. };
  17312. proto.gradientLinear = function (x1, y1, x2, y2) {
  17313. return gradientLinear(this.defs, x1, y1, x2, y2);
  17314. };
  17315. proto.gradientRadial = function (cx, cy, r, fx, fy) {
  17316. return gradientRadial(this.defs, cx, cy, r, fx, fy);
  17317. };
  17318. /*\
  17319. * Paper.toString
  17320. [ method ]
  17321. **
  17322. * Returns SVG code for the @Paper
  17323. = (string) SVG code for the @Paper
  17324. \*/
  17325. proto.toString = function () {
  17326. var doc = this.node.ownerDocument,
  17327. f = doc.createDocumentFragment(),
  17328. d = doc.createElement("div"),
  17329. svg = this.node.cloneNode(true),
  17330. res;
  17331. f.appendChild(d);
  17332. d.appendChild(svg);
  17333. Snap._.$(svg, {xmlns: "http://www.w3.org/2000/svg"});
  17334. res = d.innerHTML;
  17335. f.removeChild(f.firstChild);
  17336. return res;
  17337. };
  17338. /*\
  17339. * Paper.toDataURL
  17340. [ method ]
  17341. **
  17342. * Returns SVG code for the @Paper as Data URI string.
  17343. = (string) Data URI string
  17344. \*/
  17345. proto.toDataURL = function () {
  17346. if (window && window.btoa) {
  17347. return "data:image/svg+xml;base64," + btoa(unescape(encodeURIComponent(this)));
  17348. }
  17349. };
  17350. /*\
  17351. * Paper.clear
  17352. [ method ]
  17353. **
  17354. * Removes all child nodes of the paper, except <defs>.
  17355. \*/
  17356. proto.clear = function () {
  17357. var node = this.node.firstChild,
  17358. next;
  17359. while (node) {
  17360. next = node.nextSibling;
  17361. if (node.tagName != "defs") {
  17362. node.parentNode.removeChild(node);
  17363. } else {
  17364. proto.clear.call({node: node});
  17365. }
  17366. node = next;
  17367. }
  17368. };
  17369. }());
  17370. });
  17371. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  17372. //
  17373. // Licensed under the Apache License, Version 2.0 (the "License");
  17374. // you may not use this file except in compliance with the License.
  17375. // You may obtain a copy of the License at
  17376. //
  17377. // http://www.apache.org/licenses/LICENSE-2.0
  17378. //
  17379. // Unless required by applicable law or agreed to in writing, software
  17380. // distributed under the License is distributed on an "AS IS" BASIS,
  17381. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17382. // See the License for the specific language governing permissions and
  17383. // limitations under the License.
  17384. Snap.plugin(function (Snap, Element, Paper, glob) {
  17385. var elproto = Element.prototype,
  17386. is = Snap.is,
  17387. clone = Snap._.clone,
  17388. has = "hasOwnProperty",
  17389. p2s = /,?([a-z]),?/gi,
  17390. toFloat = parseFloat,
  17391. math = Math,
  17392. PI = math.PI,
  17393. mmin = math.min,
  17394. mmax = math.max,
  17395. pow = math.pow,
  17396. abs = math.abs;
  17397. function paths(ps) {
  17398. var p = paths.ps = paths.ps || {};
  17399. if (p[ps]) {
  17400. p[ps].sleep = 100;
  17401. } else {
  17402. p[ps] = {
  17403. sleep: 100
  17404. };
  17405. }
  17406. setTimeout(function () {
  17407. for (var key in p) if (p[has](key) && key != ps) {
  17408. p[key].sleep--;
  17409. !p[key].sleep && delete p[key];
  17410. }
  17411. });
  17412. return p[ps];
  17413. }
  17414. function box(x, y, width, height) {
  17415. if (x == null) {
  17416. x = y = width = height = 0;
  17417. }
  17418. if (y == null) {
  17419. y = x.y;
  17420. width = x.width;
  17421. height = x.height;
  17422. x = x.x;
  17423. }
  17424. return {
  17425. x: x,
  17426. y: y,
  17427. width: width,
  17428. w: width,
  17429. height: height,
  17430. h: height,
  17431. x2: x + width,
  17432. y2: y + height,
  17433. cx: x + width / 2,
  17434. cy: y + height / 2,
  17435. r1: math.min(width, height) / 2,
  17436. r2: math.max(width, height) / 2,
  17437. r0: math.sqrt(width * width + height * height) / 2,
  17438. path: rectPath(x, y, width, height),
  17439. vb: [x, y, width, height].join(" ")
  17440. };
  17441. }
  17442. function toString() {
  17443. return this.join(",").replace(p2s, "$1");
  17444. }
  17445. function pathClone(pathArray) {
  17446. var res = clone(pathArray);
  17447. res.toString = toString;
  17448. return res;
  17449. }
  17450. function getPointAtSegmentLength(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) {
  17451. if (length == null) {
  17452. return bezlen(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y);
  17453. } else {
  17454. return findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y,
  17455. getTotLen(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length));
  17456. }
  17457. }
  17458. function getLengthFactory(istotal, subpath) {
  17459. function O(val) {
  17460. return +(+val).toFixed(3);
  17461. }
  17462. return Snap._.cacher(function (path, length, onlystart) {
  17463. if (path instanceof Element) {
  17464. path = path.attr("d");
  17465. }
  17466. path = path2curve(path);
  17467. var x, y, p, l, sp = "", subpaths = {}, point,
  17468. len = 0;
  17469. for (var i = 0, ii = path.length; i < ii; i++) {
  17470. p = path[i];
  17471. if (p[0] == "M") {
  17472. x = +p[1];
  17473. y = +p[2];
  17474. } else {
  17475. l = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
  17476. if (len + l > length) {
  17477. if (subpath && !subpaths.start) {
  17478. point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);
  17479. sp += [
  17480. "C" + O(point.start.x),
  17481. O(point.start.y),
  17482. O(point.m.x),
  17483. O(point.m.y),
  17484. O(point.x),
  17485. O(point.y)
  17486. ];
  17487. if (onlystart) {return sp;}
  17488. subpaths.start = sp;
  17489. sp = [
  17490. "M" + O(point.x),
  17491. O(point.y) + "C" + O(point.n.x),
  17492. O(point.n.y),
  17493. O(point.end.x),
  17494. O(point.end.y),
  17495. O(p[5]),
  17496. O(p[6])
  17497. ].join();
  17498. len += l;
  17499. x = +p[5];
  17500. y = +p[6];
  17501. continue;
  17502. }
  17503. if (!istotal && !subpath) {
  17504. point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);
  17505. return point;
  17506. }
  17507. }
  17508. len += l;
  17509. x = +p[5];
  17510. y = +p[6];
  17511. }
  17512. sp += p.shift() + p;
  17513. }
  17514. subpaths.end = sp;
  17515. point = istotal ? len : subpath ? subpaths : findDotsAtSegment(x, y, p[0], p[1], p[2], p[3], p[4], p[5], 1);
  17516. return point;
  17517. }, null, Snap._.clone);
  17518. }
  17519. var getTotalLength = getLengthFactory(1),
  17520. getPointAtLength = getLengthFactory(),
  17521. getSubpathsAtLength = getLengthFactory(0, 1);
  17522. function findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
  17523. var t1 = 1 - t,
  17524. t13 = pow(t1, 3),
  17525. t12 = pow(t1, 2),
  17526. t2 = t * t,
  17527. t3 = t2 * t,
  17528. x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x,
  17529. y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y,
  17530. mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x),
  17531. my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y),
  17532. nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x),
  17533. ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y),
  17534. ax = t1 * p1x + t * c1x,
  17535. ay = t1 * p1y + t * c1y,
  17536. cx = t1 * c2x + t * p2x,
  17537. cy = t1 * c2y + t * p2y,
  17538. alpha = (90 - math.atan2(mx - nx, my - ny) * 180 / PI);
  17539. // (mx > nx || my < ny) && (alpha += 180);
  17540. return {
  17541. x: x,
  17542. y: y,
  17543. m: {x: mx, y: my},
  17544. n: {x: nx, y: ny},
  17545. start: {x: ax, y: ay},
  17546. end: {x: cx, y: cy},
  17547. alpha: alpha
  17548. };
  17549. }
  17550. function bezierBBox(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
  17551. if (!Snap.is(p1x, "array")) {
  17552. p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];
  17553. }
  17554. var bbox = curveDim.apply(null, p1x);
  17555. return box(
  17556. bbox.min.x,
  17557. bbox.min.y,
  17558. bbox.max.x - bbox.min.x,
  17559. bbox.max.y - bbox.min.y
  17560. );
  17561. }
  17562. function isPointInsideBBox(bbox, x, y) {
  17563. return x >= bbox.x &&
  17564. x <= bbox.x + bbox.width &&
  17565. y >= bbox.y &&
  17566. y <= bbox.y + bbox.height;
  17567. }
  17568. function isBBoxIntersect(bbox1, bbox2) {
  17569. bbox1 = box(bbox1);
  17570. bbox2 = box(bbox2);
  17571. return isPointInsideBBox(bbox2, bbox1.x, bbox1.y)
  17572. || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y)
  17573. || isPointInsideBBox(bbox2, bbox1.x, bbox1.y2)
  17574. || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y2)
  17575. || isPointInsideBBox(bbox1, bbox2.x, bbox2.y)
  17576. || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y)
  17577. || isPointInsideBBox(bbox1, bbox2.x, bbox2.y2)
  17578. || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y2)
  17579. || (bbox1.x < bbox2.x2 && bbox1.x > bbox2.x
  17580. || bbox2.x < bbox1.x2 && bbox2.x > bbox1.x)
  17581. && (bbox1.y < bbox2.y2 && bbox1.y > bbox2.y
  17582. || bbox2.y < bbox1.y2 && bbox2.y > bbox1.y);
  17583. }
  17584. function base3(t, p1, p2, p3, p4) {
  17585. var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4,
  17586. t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
  17587. return t * t2 - 3 * p1 + 3 * p2;
  17588. }
  17589. function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
  17590. if (z == null) {
  17591. z = 1;
  17592. }
  17593. z = z > 1 ? 1 : z < 0 ? 0 : z;
  17594. var z2 = z / 2,
  17595. n = 12,
  17596. Tvalues = [-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],
  17597. 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],
  17598. sum = 0;
  17599. for (var i = 0; i < n; i++) {
  17600. var ct = z2 * Tvalues[i] + z2,
  17601. xbase = base3(ct, x1, x2, x3, x4),
  17602. ybase = base3(ct, y1, y2, y3, y4),
  17603. comb = xbase * xbase + ybase * ybase;
  17604. sum += Cvalues[i] * math.sqrt(comb);
  17605. }
  17606. return z2 * sum;
  17607. }
  17608. function getTotLen(x1, y1, x2, y2, x3, y3, x4, y4, ll) {
  17609. if (ll < 0 || bezlen(x1, y1, x2, y2, x3, y3, x4, y4) < ll) {
  17610. return;
  17611. }
  17612. var t = 1,
  17613. step = t / 2,
  17614. t2 = t - step,
  17615. l,
  17616. e = .01;
  17617. l = bezlen(x1, y1, x2, y2, x3, y3, x4, y4, t2);
  17618. while (abs(l - ll) > e) {
  17619. step /= 2;
  17620. t2 += (l < ll ? 1 : -1) * step;
  17621. l = bezlen(x1, y1, x2, y2, x3, y3, x4, y4, t2);
  17622. }
  17623. return t2;
  17624. }
  17625. function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {
  17626. if (
  17627. mmax(x1, x2) < mmin(x3, x4) ||
  17628. mmin(x1, x2) > mmax(x3, x4) ||
  17629. mmax(y1, y2) < mmin(y3, y4) ||
  17630. mmin(y1, y2) > mmax(y3, y4)
  17631. ) {
  17632. return;
  17633. }
  17634. var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4),
  17635. ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4),
  17636. denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
  17637. if (!denominator) {
  17638. return;
  17639. }
  17640. var px = nx / denominator,
  17641. py = ny / denominator,
  17642. px2 = +px.toFixed(2),
  17643. py2 = +py.toFixed(2);
  17644. if (
  17645. px2 < +mmin(x1, x2).toFixed(2) ||
  17646. px2 > +mmax(x1, x2).toFixed(2) ||
  17647. px2 < +mmin(x3, x4).toFixed(2) ||
  17648. px2 > +mmax(x3, x4).toFixed(2) ||
  17649. py2 < +mmin(y1, y2).toFixed(2) ||
  17650. py2 > +mmax(y1, y2).toFixed(2) ||
  17651. py2 < +mmin(y3, y4).toFixed(2) ||
  17652. py2 > +mmax(y3, y4).toFixed(2)
  17653. ) {
  17654. return;
  17655. }
  17656. return {x: px, y: py};
  17657. }
  17658. function inter(bez1, bez2) {
  17659. return interHelper(bez1, bez2);
  17660. }
  17661. function interCount(bez1, bez2) {
  17662. return interHelper(bez1, bez2, 1);
  17663. }
  17664. function interHelper(bez1, bez2, justCount) {
  17665. var bbox1 = bezierBBox(bez1),
  17666. bbox2 = bezierBBox(bez2);
  17667. if (!isBBoxIntersect(bbox1, bbox2)) {
  17668. return justCount ? 0 : [];
  17669. }
  17670. var l1 = bezlen.apply(0, bez1),
  17671. l2 = bezlen.apply(0, bez2),
  17672. n1 = ~~(l1 / 8),
  17673. n2 = ~~(l2 / 8),
  17674. dots1 = [],
  17675. dots2 = [],
  17676. xy = {},
  17677. res = justCount ? 0 : [];
  17678. for (var i = 0; i < n1 + 1; i++) {
  17679. var p = findDotsAtSegment.apply(0, bez1.concat(i / n1));
  17680. dots1.push({x: p.x, y: p.y, t: i / n1});
  17681. }
  17682. for (i = 0; i < n2 + 1; i++) {
  17683. p = findDotsAtSegment.apply(0, bez2.concat(i / n2));
  17684. dots2.push({x: p.x, y: p.y, t: i / n2});
  17685. }
  17686. for (i = 0; i < n1; i++) {
  17687. for (var j = 0; j < n2; j++) {
  17688. var di = dots1[i],
  17689. di1 = dots1[i + 1],
  17690. dj = dots2[j],
  17691. dj1 = dots2[j + 1],
  17692. ci = abs(di1.x - di.x) < .001 ? "y" : "x",
  17693. cj = abs(dj1.x - dj.x) < .001 ? "y" : "x",
  17694. is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);
  17695. if (is) {
  17696. if (xy[is.x.toFixed(4)] == is.y.toFixed(4)) {
  17697. continue;
  17698. }
  17699. xy[is.x.toFixed(4)] = is.y.toFixed(4);
  17700. var t1 = di.t + abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t),
  17701. t2 = dj.t + abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);
  17702. if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {
  17703. if (justCount) {
  17704. res++;
  17705. } else {
  17706. res.push({
  17707. x: is.x,
  17708. y: is.y,
  17709. t1: t1,
  17710. t2: t2
  17711. });
  17712. }
  17713. }
  17714. }
  17715. }
  17716. }
  17717. return res;
  17718. }
  17719. function pathIntersection(path1, path2) {
  17720. return interPathHelper(path1, path2);
  17721. }
  17722. function pathIntersectionNumber(path1, path2) {
  17723. return interPathHelper(path1, path2, 1);
  17724. }
  17725. function interPathHelper(path1, path2, justCount) {
  17726. path1 = path2curve(path1);
  17727. path2 = path2curve(path2);
  17728. var x1, y1, x2, y2, x1m, y1m, x2m, y2m, bez1, bez2,
  17729. res = justCount ? 0 : [];
  17730. for (var i = 0, ii = path1.length; i < ii; i++) {
  17731. var pi = path1[i];
  17732. if (pi[0] == "M") {
  17733. x1 = x1m = pi[1];
  17734. y1 = y1m = pi[2];
  17735. } else {
  17736. if (pi[0] == "C") {
  17737. bez1 = [x1, y1].concat(pi.slice(1));
  17738. x1 = bez1[6];
  17739. y1 = bez1[7];
  17740. } else {
  17741. bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];
  17742. x1 = x1m;
  17743. y1 = y1m;
  17744. }
  17745. for (var j = 0, jj = path2.length; j < jj; j++) {
  17746. var pj = path2[j];
  17747. if (pj[0] == "M") {
  17748. x2 = x2m = pj[1];
  17749. y2 = y2m = pj[2];
  17750. } else {
  17751. if (pj[0] == "C") {
  17752. bez2 = [x2, y2].concat(pj.slice(1));
  17753. x2 = bez2[6];
  17754. y2 = bez2[7];
  17755. } else {
  17756. bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];
  17757. x2 = x2m;
  17758. y2 = y2m;
  17759. }
  17760. var intr = interHelper(bez1, bez2, justCount);
  17761. if (justCount) {
  17762. res += intr;
  17763. } else {
  17764. for (var k = 0, kk = intr.length; k < kk; k++) {
  17765. intr[k].segment1 = i;
  17766. intr[k].segment2 = j;
  17767. intr[k].bez1 = bez1;
  17768. intr[k].bez2 = bez2;
  17769. }
  17770. res = res.concat(intr);
  17771. }
  17772. }
  17773. }
  17774. }
  17775. }
  17776. return res;
  17777. }
  17778. function isPointInsidePath(path, x, y) {
  17779. var bbox = pathBBox(path);
  17780. return isPointInsideBBox(bbox, x, y) &&
  17781. interPathHelper(path, [["M", x, y], ["H", bbox.x2 + 10]], 1) % 2 == 1;
  17782. }
  17783. function pathBBox(path) {
  17784. var pth = paths(path);
  17785. if (pth.bbox) {
  17786. return clone(pth.bbox);
  17787. }
  17788. if (!path) {
  17789. return box();
  17790. }
  17791. path = path2curve(path);
  17792. var x = 0,
  17793. y = 0,
  17794. X = [],
  17795. Y = [],
  17796. p;
  17797. for (var i = 0, ii = path.length; i < ii; i++) {
  17798. p = path[i];
  17799. if (p[0] == "M") {
  17800. x = p[1];
  17801. y = p[2];
  17802. X.push(x);
  17803. Y.push(y);
  17804. } else {
  17805. var dim = curveDim(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
  17806. X = X.concat(dim.min.x, dim.max.x);
  17807. Y = Y.concat(dim.min.y, dim.max.y);
  17808. x = p[5];
  17809. y = p[6];
  17810. }
  17811. }
  17812. var xmin = mmin.apply(0, X),
  17813. ymin = mmin.apply(0, Y),
  17814. xmax = mmax.apply(0, X),
  17815. ymax = mmax.apply(0, Y),
  17816. bb = box(xmin, ymin, xmax - xmin, ymax - ymin);
  17817. pth.bbox = clone(bb);
  17818. return bb;
  17819. }
  17820. function rectPath(x, y, w, h, r) {
  17821. if (r) {
  17822. return [
  17823. ["M", +x + (+r), y],
  17824. ["l", w - r * 2, 0],
  17825. ["a", r, r, 0, 0, 1, r, r],
  17826. ["l", 0, h - r * 2],
  17827. ["a", r, r, 0, 0, 1, -r, r],
  17828. ["l", r * 2 - w, 0],
  17829. ["a", r, r, 0, 0, 1, -r, -r],
  17830. ["l", 0, r * 2 - h],
  17831. ["a", r, r, 0, 0, 1, r, -r],
  17832. ["z"]
  17833. ];
  17834. }
  17835. var res = [["M", x, y], ["l", w, 0], ["l", 0, h], ["l", -w, 0], ["z"]];
  17836. res.toString = toString;
  17837. return res;
  17838. }
  17839. function ellipsePath(x, y, rx, ry, a) {
  17840. if (a == null && ry == null) {
  17841. ry = rx;
  17842. }
  17843. x = +x;
  17844. y = +y;
  17845. rx = +rx;
  17846. ry = +ry;
  17847. if (a != null) {
  17848. var rad = Math.PI / 180,
  17849. x1 = x + rx * Math.cos(-ry * rad),
  17850. x2 = x + rx * Math.cos(-a * rad),
  17851. y1 = y + rx * Math.sin(-ry * rad),
  17852. y2 = y + rx * Math.sin(-a * rad),
  17853. res = [["M", x1, y1], ["A", rx, rx, 0, +(a - ry > 180), 0, x2, y2]];
  17854. } else {
  17855. res = [
  17856. ["M", x, y],
  17857. ["m", 0, -ry],
  17858. ["a", rx, ry, 0, 1, 1, 0, 2 * ry],
  17859. ["a", rx, ry, 0, 1, 1, 0, -2 * ry],
  17860. ["z"]
  17861. ];
  17862. }
  17863. res.toString = toString;
  17864. return res;
  17865. }
  17866. var unit2px = Snap._unit2px,
  17867. getPath = {
  17868. path: function (el) {
  17869. return el.attr("path");
  17870. },
  17871. circle: function (el) {
  17872. var attr = unit2px(el);
  17873. return ellipsePath(attr.cx, attr.cy, attr.r);
  17874. },
  17875. ellipse: function (el) {
  17876. var attr = unit2px(el);
  17877. return ellipsePath(attr.cx || 0, attr.cy || 0, attr.rx, attr.ry);
  17878. },
  17879. rect: function (el) {
  17880. var attr = unit2px(el);
  17881. return rectPath(attr.x || 0, attr.y || 0, attr.width, attr.height, attr.rx, attr.ry);
  17882. },
  17883. image: function (el) {
  17884. var attr = unit2px(el);
  17885. return rectPath(attr.x || 0, attr.y || 0, attr.width, attr.height);
  17886. },
  17887. line: function (el) {
  17888. return "M" + [el.attr("x1") || 0, el.attr("y1") || 0, el.attr("x2"), el.attr("y2")];
  17889. },
  17890. polyline: function (el) {
  17891. return "M" + el.attr("points");
  17892. },
  17893. polygon: function (el) {
  17894. return "M" + el.attr("points") + "z";
  17895. },
  17896. deflt: function (el) {
  17897. var bbox = el.node.getBBox();
  17898. return rectPath(bbox.x, bbox.y, bbox.width, bbox.height);
  17899. }
  17900. };
  17901. function pathToRelative(pathArray) {
  17902. var pth = paths(pathArray),
  17903. lowerCase = String.prototype.toLowerCase;
  17904. if (pth.rel) {
  17905. return pathClone(pth.rel);
  17906. }
  17907. if (!Snap.is(pathArray, "array") || !Snap.is(pathArray && pathArray[0], "array")) {
  17908. pathArray = Snap.parsePathString(pathArray);
  17909. }
  17910. var res = [],
  17911. x = 0,
  17912. y = 0,
  17913. mx = 0,
  17914. my = 0,
  17915. start = 0;
  17916. if (pathArray[0][0] == "M") {
  17917. x = pathArray[0][1];
  17918. y = pathArray[0][2];
  17919. mx = x;
  17920. my = y;
  17921. start++;
  17922. res.push(["M", x, y]);
  17923. }
  17924. for (var i = start, ii = pathArray.length; i < ii; i++) {
  17925. var r = res[i] = [],
  17926. pa = pathArray[i];
  17927. if (pa[0] != lowerCase.call(pa[0])) {
  17928. r[0] = lowerCase.call(pa[0]);
  17929. switch (r[0]) {
  17930. case "a":
  17931. r[1] = pa[1];
  17932. r[2] = pa[2];
  17933. r[3] = pa[3];
  17934. r[4] = pa[4];
  17935. r[5] = pa[5];
  17936. r[6] = +(pa[6] - x).toFixed(3);
  17937. r[7] = +(pa[7] - y).toFixed(3);
  17938. break;
  17939. case "v":
  17940. r[1] = +(pa[1] - y).toFixed(3);
  17941. break;
  17942. case "m":
  17943. mx = pa[1];
  17944. my = pa[2];
  17945. default:
  17946. for (var j = 1, jj = pa.length; j < jj; j++) {
  17947. r[j] = +(pa[j] - ((j % 2) ? x : y)).toFixed(3);
  17948. }
  17949. }
  17950. } else {
  17951. r = res[i] = [];
  17952. if (pa[0] == "m") {
  17953. mx = pa[1] + x;
  17954. my = pa[2] + y;
  17955. }
  17956. for (var k = 0, kk = pa.length; k < kk; k++) {
  17957. res[i][k] = pa[k];
  17958. }
  17959. }
  17960. var len = res[i].length;
  17961. switch (res[i][0]) {
  17962. case "z":
  17963. x = mx;
  17964. y = my;
  17965. break;
  17966. case "h":
  17967. x += +res[i][len - 1];
  17968. break;
  17969. case "v":
  17970. y += +res[i][len - 1];
  17971. break;
  17972. default:
  17973. x += +res[i][len - 2];
  17974. y += +res[i][len - 1];
  17975. }
  17976. }
  17977. res.toString = toString;
  17978. pth.rel = pathClone(res);
  17979. return res;
  17980. }
  17981. function pathToAbsolute(pathArray) {
  17982. var pth = paths(pathArray);
  17983. if (pth.abs) {
  17984. return pathClone(pth.abs);
  17985. }
  17986. if (!is(pathArray, "array") || !is(pathArray && pathArray[0], "array")) { // rough assumption
  17987. pathArray = Snap.parsePathString(pathArray);
  17988. }
  17989. if (!pathArray || !pathArray.length) {
  17990. return [["M", 0, 0]];
  17991. }
  17992. var res = [],
  17993. x = 0,
  17994. y = 0,
  17995. mx = 0,
  17996. my = 0,
  17997. start = 0,
  17998. pa0;
  17999. if (pathArray[0][0] == "M") {
  18000. x = +pathArray[0][1];
  18001. y = +pathArray[0][2];
  18002. mx = x;
  18003. my = y;
  18004. start++;
  18005. res[0] = ["M", x, y];
  18006. }
  18007. var crz = pathArray.length == 3 &&
  18008. pathArray[0][0] == "M" &&
  18009. pathArray[1][0].toUpperCase() == "R" &&
  18010. pathArray[2][0].toUpperCase() == "Z";
  18011. for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {
  18012. res.push(r = []);
  18013. pa = pathArray[i];
  18014. pa0 = pa[0];
  18015. if (pa0 != pa0.toUpperCase()) {
  18016. r[0] = pa0.toUpperCase();
  18017. switch (r[0]) {
  18018. case "A":
  18019. r[1] = pa[1];
  18020. r[2] = pa[2];
  18021. r[3] = pa[3];
  18022. r[4] = pa[4];
  18023. r[5] = pa[5];
  18024. r[6] = +pa[6] + x;
  18025. r[7] = +pa[7] + y;
  18026. break;
  18027. case "V":
  18028. r[1] = +pa[1] + y;
  18029. break;
  18030. case "H":
  18031. r[1] = +pa[1] + x;
  18032. break;
  18033. case "R":
  18034. var dots = [x, y].concat(pa.slice(1));
  18035. for (var j = 2, jj = dots.length; j < jj; j++) {
  18036. dots[j] = +dots[j] + x;
  18037. dots[++j] = +dots[j] + y;
  18038. }
  18039. res.pop();
  18040. res = res.concat(catmullRom2bezier(dots, crz));
  18041. break;
  18042. case "O":
  18043. res.pop();
  18044. dots = ellipsePath(x, y, pa[1], pa[2]);
  18045. dots.push(dots[0]);
  18046. res = res.concat(dots);
  18047. break;
  18048. case "U":
  18049. res.pop();
  18050. res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
  18051. r = ["U"].concat(res[res.length - 1].slice(-2));
  18052. break;
  18053. case "M":
  18054. mx = +pa[1] + x;
  18055. my = +pa[2] + y;
  18056. default:
  18057. for (j = 1, jj = pa.length; j < jj; j++) {
  18058. r[j] = +pa[j] + ((j % 2) ? x : y);
  18059. }
  18060. }
  18061. } else if (pa0 == "R") {
  18062. dots = [x, y].concat(pa.slice(1));
  18063. res.pop();
  18064. res = res.concat(catmullRom2bezier(dots, crz));
  18065. r = ["R"].concat(pa.slice(-2));
  18066. } else if (pa0 == "O") {
  18067. res.pop();
  18068. dots = ellipsePath(x, y, pa[1], pa[2]);
  18069. dots.push(dots[0]);
  18070. res = res.concat(dots);
  18071. } else if (pa0 == "U") {
  18072. res.pop();
  18073. res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
  18074. r = ["U"].concat(res[res.length - 1].slice(-2));
  18075. } else {
  18076. for (var k = 0, kk = pa.length; k < kk; k++) {
  18077. r[k] = pa[k];
  18078. }
  18079. }
  18080. pa0 = pa0.toUpperCase();
  18081. if (pa0 != "O") {
  18082. switch (r[0]) {
  18083. case "Z":
  18084. x = +mx;
  18085. y = +my;
  18086. break;
  18087. case "H":
  18088. x = r[1];
  18089. break;
  18090. case "V":
  18091. y = r[1];
  18092. break;
  18093. case "M":
  18094. mx = r[r.length - 2];
  18095. my = r[r.length - 1];
  18096. default:
  18097. x = r[r.length - 2];
  18098. y = r[r.length - 1];
  18099. }
  18100. }
  18101. }
  18102. res.toString = toString;
  18103. pth.abs = pathClone(res);
  18104. return res;
  18105. }
  18106. function l2c(x1, y1, x2, y2) {
  18107. return [x1, y1, x2, y2, x2, y2];
  18108. }
  18109. function q2c(x1, y1, ax, ay, x2, y2) {
  18110. var _13 = 1 / 3,
  18111. _23 = 2 / 3;
  18112. return [
  18113. _13 * x1 + _23 * ax,
  18114. _13 * y1 + _23 * ay,
  18115. _13 * x2 + _23 * ax,
  18116. _13 * y2 + _23 * ay,
  18117. x2,
  18118. y2
  18119. ];
  18120. }
  18121. function a2c(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
  18122. // for more information of where this math came from visit:
  18123. // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
  18124. var _120 = PI * 120 / 180,
  18125. rad = PI / 180 * (+angle || 0),
  18126. res = [],
  18127. xy,
  18128. rotate = Snap._.cacher(function (x, y, rad) {
  18129. var X = x * math.cos(rad) - y * math.sin(rad),
  18130. Y = x * math.sin(rad) + y * math.cos(rad);
  18131. return {x: X, y: Y};
  18132. });
  18133. if (!recursive) {
  18134. xy = rotate(x1, y1, -rad);
  18135. x1 = xy.x;
  18136. y1 = xy.y;
  18137. xy = rotate(x2, y2, -rad);
  18138. x2 = xy.x;
  18139. y2 = xy.y;
  18140. var cos = math.cos(PI / 180 * angle),
  18141. sin = math.sin(PI / 180 * angle),
  18142. x = (x1 - x2) / 2,
  18143. y = (y1 - y2) / 2;
  18144. var h = (x * x) / (rx * rx) + (y * y) / (ry * ry);
  18145. if (h > 1) {
  18146. h = math.sqrt(h);
  18147. rx = h * rx;
  18148. ry = h * ry;
  18149. }
  18150. var rx2 = rx * rx,
  18151. ry2 = ry * ry,
  18152. k = (large_arc_flag == sweep_flag ? -1 : 1) *
  18153. math.sqrt(abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x))),
  18154. cx = k * rx * y / ry + (x1 + x2) / 2,
  18155. cy = k * -ry * x / rx + (y1 + y2) / 2,
  18156. f1 = math.asin(((y1 - cy) / ry).toFixed(9)),
  18157. f2 = math.asin(((y2 - cy) / ry).toFixed(9));
  18158. f1 = x1 < cx ? PI - f1 : f1;
  18159. f2 = x2 < cx ? PI - f2 : f2;
  18160. f1 < 0 && (f1 = PI * 2 + f1);
  18161. f2 < 0 && (f2 = PI * 2 + f2);
  18162. if (sweep_flag && f1 > f2) {
  18163. f1 = f1 - PI * 2;
  18164. }
  18165. if (!sweep_flag && f2 > f1) {
  18166. f2 = f2 - PI * 2;
  18167. }
  18168. } else {
  18169. f1 = recursive[0];
  18170. f2 = recursive[1];
  18171. cx = recursive[2];
  18172. cy = recursive[3];
  18173. }
  18174. var df = f2 - f1;
  18175. if (abs(df) > _120) {
  18176. var f2old = f2,
  18177. x2old = x2,
  18178. y2old = y2;
  18179. f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
  18180. x2 = cx + rx * math.cos(f2);
  18181. y2 = cy + ry * math.sin(f2);
  18182. res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
  18183. }
  18184. df = f2 - f1;
  18185. var c1 = math.cos(f1),
  18186. s1 = math.sin(f1),
  18187. c2 = math.cos(f2),
  18188. s2 = math.sin(f2),
  18189. t = math.tan(df / 4),
  18190. hx = 4 / 3 * rx * t,
  18191. hy = 4 / 3 * ry * t,
  18192. m1 = [x1, y1],
  18193. m2 = [x1 + hx * s1, y1 - hy * c1],
  18194. m3 = [x2 + hx * s2, y2 - hy * c2],
  18195. m4 = [x2, y2];
  18196. m2[0] = 2 * m1[0] - m2[0];
  18197. m2[1] = 2 * m1[1] - m2[1];
  18198. if (recursive) {
  18199. return [m2, m3, m4].concat(res);
  18200. } else {
  18201. res = [m2, m3, m4].concat(res).join().split(",");
  18202. var newres = [];
  18203. for (var i = 0, ii = res.length; i < ii; i++) {
  18204. newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
  18205. }
  18206. return newres;
  18207. }
  18208. }
  18209. function findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
  18210. var t1 = 1 - t;
  18211. return {
  18212. x: pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + pow(t, 3) * p2x,
  18213. y: pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + pow(t, 3) * p2y
  18214. };
  18215. }
  18216. // Returns bounding box of cubic bezier curve.
  18217. // Source: http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
  18218. // Original version: NISHIO Hirokazu
  18219. // Modifications: https://github.com/timo22345
  18220. function curveDim(x0, y0, x1, y1, x2, y2, x3, y3) {
  18221. var tvalues = [],
  18222. bounds = [[], []],
  18223. a, b, c, t, t1, t2, b2ac, sqrtb2ac;
  18224. for (var i = 0; i < 2; ++i) {
  18225. if (i == 0) {
  18226. b = 6 * x0 - 12 * x1 + 6 * x2;
  18227. a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
  18228. c = 3 * x1 - 3 * x0;
  18229. } else {
  18230. b = 6 * y0 - 12 * y1 + 6 * y2;
  18231. a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
  18232. c = 3 * y1 - 3 * y0;
  18233. }
  18234. if (abs(a) < 1e-12) {
  18235. if (abs(b) < 1e-12) {
  18236. continue;
  18237. }
  18238. t = -c / b;
  18239. if (0 < t && t < 1) {
  18240. tvalues.push(t);
  18241. }
  18242. continue;
  18243. }
  18244. b2ac = b * b - 4 * c * a;
  18245. sqrtb2ac = math.sqrt(b2ac);
  18246. if (b2ac < 0) {
  18247. continue;
  18248. }
  18249. t1 = (-b + sqrtb2ac) / (2 * a);
  18250. if (0 < t1 && t1 < 1) {
  18251. tvalues.push(t1);
  18252. }
  18253. t2 = (-b - sqrtb2ac) / (2 * a);
  18254. if (0 < t2 && t2 < 1) {
  18255. tvalues.push(t2);
  18256. }
  18257. }
  18258. var x, y, j = tvalues.length,
  18259. jlen = j,
  18260. mt;
  18261. while (j--) {
  18262. t = tvalues[j];
  18263. mt = 1 - t;
  18264. bounds[0][j] = (mt * mt * mt * x0) + (3 * mt * mt * t * x1) + (3 * mt * t * t * x2) + (t * t * t * x3);
  18265. bounds[1][j] = (mt * mt * mt * y0) + (3 * mt * mt * t * y1) + (3 * mt * t * t * y2) + (t * t * t * y3);
  18266. }
  18267. bounds[0][jlen] = x0;
  18268. bounds[1][jlen] = y0;
  18269. bounds[0][jlen + 1] = x3;
  18270. bounds[1][jlen + 1] = y3;
  18271. bounds[0].length = bounds[1].length = jlen + 2;
  18272. return {
  18273. min: {x: mmin.apply(0, bounds[0]), y: mmin.apply(0, bounds[1])},
  18274. max: {x: mmax.apply(0, bounds[0]), y: mmax.apply(0, bounds[1])}
  18275. };
  18276. }
  18277. function path2curve(path, path2) {
  18278. var pth = !path2 && paths(path);
  18279. if (!path2 && pth.curve) {
  18280. return pathClone(pth.curve);
  18281. }
  18282. var p = pathToAbsolute(path),
  18283. p2 = path2 && pathToAbsolute(path2),
  18284. attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
  18285. attrs2 = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
  18286. processPath = function (path, d, pcom) {
  18287. var nx, ny;
  18288. if (!path) {
  18289. return ["C", d.x, d.y, d.x, d.y, d.x, d.y];
  18290. }
  18291. !(path[0] in {T: 1, Q: 1}) && (d.qx = d.qy = null);
  18292. switch (path[0]) {
  18293. case "M":
  18294. d.X = path[1];
  18295. d.Y = path[2];
  18296. break;
  18297. case "A":
  18298. path = ["C"].concat(a2c.apply(0, [d.x, d.y].concat(path.slice(1))));
  18299. break;
  18300. case "S":
  18301. if (pcom == "C" || pcom == "S") { // In "S" case we have to take into account, if the previous command is C/S.
  18302. nx = d.x * 2 - d.bx; // And reflect the previous
  18303. ny = d.y * 2 - d.by; // command's control point relative to the current point.
  18304. }
  18305. else { // or some else or nothing
  18306. nx = d.x;
  18307. ny = d.y;
  18308. }
  18309. path = ["C", nx, ny].concat(path.slice(1));
  18310. break;
  18311. case "T":
  18312. if (pcom == "Q" || pcom == "T") { // In "T" case we have to take into account, if the previous command is Q/T.
  18313. d.qx = d.x * 2 - d.qx; // And make a reflection similar
  18314. d.qy = d.y * 2 - d.qy; // to case "S".
  18315. }
  18316. else { // or something else or nothing
  18317. d.qx = d.x;
  18318. d.qy = d.y;
  18319. }
  18320. path = ["C"].concat(q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
  18321. break;
  18322. case "Q":
  18323. d.qx = path[1];
  18324. d.qy = path[2];
  18325. path = ["C"].concat(q2c(d.x, d.y, path[1], path[2], path[3], path[4]));
  18326. break;
  18327. case "L":
  18328. path = ["C"].concat(l2c(d.x, d.y, path[1], path[2]));
  18329. break;
  18330. case "H":
  18331. path = ["C"].concat(l2c(d.x, d.y, path[1], d.y));
  18332. break;
  18333. case "V":
  18334. path = ["C"].concat(l2c(d.x, d.y, d.x, path[1]));
  18335. break;
  18336. case "Z":
  18337. path = ["C"].concat(l2c(d.x, d.y, d.X, d.Y));
  18338. break;
  18339. }
  18340. return path;
  18341. },
  18342. fixArc = function (pp, i) {
  18343. if (pp[i].length > 7) {
  18344. pp[i].shift();
  18345. var pi = pp[i];
  18346. while (pi.length) {
  18347. pcoms1[i] = "A"; // if created multiple C:s, their original seg is saved
  18348. p2 && (pcoms2[i] = "A"); // the same as above
  18349. pp.splice(i++, 0, ["C"].concat(pi.splice(0, 6)));
  18350. }
  18351. pp.splice(i, 1);
  18352. ii = mmax(p.length, p2 && p2.length || 0);
  18353. }
  18354. },
  18355. fixM = function (path1, path2, a1, a2, i) {
  18356. if (path1 && path2 && path1[i][0] == "M" && path2[i][0] != "M") {
  18357. path2.splice(i, 0, ["M", a2.x, a2.y]);
  18358. a1.bx = 0;
  18359. a1.by = 0;
  18360. a1.x = path1[i][1];
  18361. a1.y = path1[i][2];
  18362. ii = mmax(p.length, p2 && p2.length || 0);
  18363. }
  18364. },
  18365. pcoms1 = [], // path commands of original path p
  18366. pcoms2 = [], // path commands of original path p2
  18367. pfirst = "", // temporary holder for original path command
  18368. pcom = ""; // holder for previous path command of original path
  18369. for (var i = 0, ii = mmax(p.length, p2 && p2.length || 0); i < ii; i++) {
  18370. p[i] && (pfirst = p[i][0]); // save current path command
  18371. if (pfirst != "C") // C is not saved yet, because it may be result of conversion
  18372. {
  18373. pcoms1[i] = pfirst; // Save current path command
  18374. i && ( pcom = pcoms1[i - 1]); // Get previous path command pcom
  18375. }
  18376. p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath
  18377. if (pcoms1[i] != "A" && pfirst == "C") pcoms1[i] = "C"; // A is the only command
  18378. // which may produce multiple C:s
  18379. // so we have to make sure that C is also C in original path
  18380. fixArc(p, i); // fixArc adds also the right amount of A:s to pcoms1
  18381. if (p2) { // the same procedures is done to p2
  18382. p2[i] && (pfirst = p2[i][0]);
  18383. if (pfirst != "C") {
  18384. pcoms2[i] = pfirst;
  18385. i && (pcom = pcoms2[i - 1]);
  18386. }
  18387. p2[i] = processPath(p2[i], attrs2, pcom);
  18388. if (pcoms2[i] != "A" && pfirst == "C") {
  18389. pcoms2[i] = "C";
  18390. }
  18391. fixArc(p2, i);
  18392. }
  18393. fixM(p, p2, attrs, attrs2, i);
  18394. fixM(p2, p, attrs2, attrs, i);
  18395. var seg = p[i],
  18396. seg2 = p2 && p2[i],
  18397. seglen = seg.length,
  18398. seg2len = p2 && seg2.length;
  18399. attrs.x = seg[seglen - 2];
  18400. attrs.y = seg[seglen - 1];
  18401. attrs.bx = toFloat(seg[seglen - 4]) || attrs.x;
  18402. attrs.by = toFloat(seg[seglen - 3]) || attrs.y;
  18403. attrs2.bx = p2 && (toFloat(seg2[seg2len - 4]) || attrs2.x);
  18404. attrs2.by = p2 && (toFloat(seg2[seg2len - 3]) || attrs2.y);
  18405. attrs2.x = p2 && seg2[seg2len - 2];
  18406. attrs2.y = p2 && seg2[seg2len - 1];
  18407. }
  18408. if (!p2) {
  18409. pth.curve = pathClone(p);
  18410. }
  18411. return p2 ? [p, p2] : p;
  18412. }
  18413. function mapPath(path, matrix) {
  18414. if (!matrix) {
  18415. return path;
  18416. }
  18417. var x, y, i, j, ii, jj, pathi;
  18418. path = path2curve(path);
  18419. for (i = 0, ii = path.length; i < ii; i++) {
  18420. pathi = path[i];
  18421. for (j = 1, jj = pathi.length; j < jj; j += 2) {
  18422. x = matrix.x(pathi[j], pathi[j + 1]);
  18423. y = matrix.y(pathi[j], pathi[j + 1]);
  18424. pathi[j] = x;
  18425. pathi[j + 1] = y;
  18426. }
  18427. }
  18428. return path;
  18429. }
  18430. // http://schepers.cc/getting-to-the-point
  18431. function catmullRom2bezier(crp, z) {
  18432. var d = [];
  18433. for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {
  18434. var p = [
  18435. {x: +crp[i - 2], y: +crp[i - 1]},
  18436. {x: +crp[i], y: +crp[i + 1]},
  18437. {x: +crp[i + 2], y: +crp[i + 3]},
  18438. {x: +crp[i + 4], y: +crp[i + 5]}
  18439. ];
  18440. if (z) {
  18441. if (!i) {
  18442. p[0] = {x: +crp[iLen - 2], y: +crp[iLen - 1]};
  18443. } else if (iLen - 4 == i) {
  18444. p[3] = {x: +crp[0], y: +crp[1]};
  18445. } else if (iLen - 2 == i) {
  18446. p[2] = {x: +crp[0], y: +crp[1]};
  18447. p[3] = {x: +crp[2], y: +crp[3]};
  18448. }
  18449. } else {
  18450. if (iLen - 4 == i) {
  18451. p[3] = p[2];
  18452. } else if (!i) {
  18453. p[0] = {x: +crp[i], y: +crp[i + 1]};
  18454. }
  18455. }
  18456. d.push(["C",
  18457. (-p[0].x + 6 * p[1].x + p[2].x) / 6,
  18458. (-p[0].y + 6 * p[1].y + p[2].y) / 6,
  18459. (p[1].x + 6 * p[2].x - p[3].x) / 6,
  18460. (p[1].y + 6*p[2].y - p[3].y) / 6,
  18461. p[2].x,
  18462. p[2].y
  18463. ]);
  18464. }
  18465. return d;
  18466. }
  18467. // export
  18468. Snap.path = paths;
  18469. /*\
  18470. * Snap.path.getTotalLength
  18471. [ method ]
  18472. **
  18473. * Returns the length of the given path in pixels
  18474. **
  18475. - path (string) SVG path string
  18476. **
  18477. = (number) length
  18478. \*/
  18479. Snap.path.getTotalLength = getTotalLength;
  18480. /*\
  18481. * Snap.path.getPointAtLength
  18482. [ method ]
  18483. **
  18484. * Returns the coordinates of the point located at the given length along the given path
  18485. **
  18486. - path (string) SVG path string
  18487. - length (number) length, in pixels, from the start of the path, excluding non-rendering jumps
  18488. **
  18489. = (object) representation of the point:
  18490. o {
  18491. o x: (number) x coordinate,
  18492. o y: (number) y coordinate,
  18493. o alpha: (number) angle of derivative
  18494. o }
  18495. \*/
  18496. Snap.path.getPointAtLength = getPointAtLength;
  18497. /*\
  18498. * Snap.path.getSubpath
  18499. [ method ]
  18500. **
  18501. * Returns the subpath of a given path between given start and end lengths
  18502. **
  18503. - path (string) SVG path string
  18504. - from (number) length, in pixels, from the start of the path to the start of the segment
  18505. - to (number) length, in pixels, from the start of the path to the end of the segment
  18506. **
  18507. = (string) path string definition for the segment
  18508. \*/
  18509. Snap.path.getSubpath = function (path, from, to) {
  18510. if (this.getTotalLength(path) - to < 1e-6) {
  18511. return getSubpathsAtLength(path, from).end;
  18512. }
  18513. var a = getSubpathsAtLength(path, to, 1);
  18514. return from ? getSubpathsAtLength(a, from).end : a;
  18515. };
  18516. /*\
  18517. * Element.getTotalLength
  18518. [ method ]
  18519. **
  18520. * Returns the length of the path in pixels (only works for `path` elements)
  18521. = (number) length
  18522. \*/
  18523. elproto.getTotalLength = function () {
  18524. if (this.node.getTotalLength) {
  18525. return this.node.getTotalLength();
  18526. }
  18527. };
  18528. // 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?
  18529. /*\
  18530. * Element.getPointAtLength
  18531. [ method ]
  18532. **
  18533. * Returns coordinates of the point located at the given length on the given path (only works for `path` elements)
  18534. **
  18535. - length (number) length, in pixels, from the start of the path, excluding non-rendering jumps
  18536. **
  18537. = (object) representation of the point:
  18538. o {
  18539. o x: (number) x coordinate,
  18540. o y: (number) y coordinate,
  18541. o alpha: (number) angle of derivative
  18542. o }
  18543. \*/
  18544. elproto.getPointAtLength = function (length) {
  18545. return getPointAtLength(this.attr("d"), length);
  18546. };
  18547. // 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.
  18548. /*\
  18549. * Element.getSubpath
  18550. [ method ]
  18551. **
  18552. * Returns subpath of a given element from given start and end lengths (only works for `path` elements)
  18553. **
  18554. - from (number) length, in pixels, from the start of the path to the start of the segment
  18555. - to (number) length, in pixels, from the start of the path to the end of the segment
  18556. **
  18557. = (string) path string definition for the segment
  18558. \*/
  18559. elproto.getSubpath = function (from, to) {
  18560. return Snap.path.getSubpath(this.attr("d"), from, to);
  18561. };
  18562. Snap._.box = box;
  18563. /*\
  18564. * Snap.path.findDotsAtSegment
  18565. [ method ]
  18566. **
  18567. * Utility method
  18568. **
  18569. * Finds dot coordinates on the given cubic beziér curve at the given t
  18570. - p1x (number) x of the first point of the curve
  18571. - p1y (number) y of the first point of the curve
  18572. - c1x (number) x of the first anchor of the curve
  18573. - c1y (number) y of the first anchor of the curve
  18574. - c2x (number) x of the second anchor of the curve
  18575. - c2y (number) y of the second anchor of the curve
  18576. - p2x (number) x of the second point of the curve
  18577. - p2y (number) y of the second point of the curve
  18578. - t (number) position on the curve (0..1)
  18579. = (object) point information in format:
  18580. o {
  18581. o x: (number) x coordinate of the point,
  18582. o y: (number) y coordinate of the point,
  18583. o m: {
  18584. o x: (number) x coordinate of the left anchor,
  18585. o y: (number) y coordinate of the left anchor
  18586. o },
  18587. o n: {
  18588. o x: (number) x coordinate of the right anchor,
  18589. o y: (number) y coordinate of the right anchor
  18590. o },
  18591. o start: {
  18592. o x: (number) x coordinate of the start of the curve,
  18593. o y: (number) y coordinate of the start of the curve
  18594. o },
  18595. o end: {
  18596. o x: (number) x coordinate of the end of the curve,
  18597. o y: (number) y coordinate of the end of the curve
  18598. o },
  18599. o alpha: (number) angle of the curve derivative at the point
  18600. o }
  18601. \*/
  18602. Snap.path.findDotsAtSegment = findDotsAtSegment;
  18603. /*\
  18604. * Snap.path.bezierBBox
  18605. [ method ]
  18606. **
  18607. * Utility method
  18608. **
  18609. * Returns the bounding box of a given cubic beziér curve
  18610. - p1x (number) x of the first point of the curve
  18611. - p1y (number) y of the first point of the curve
  18612. - c1x (number) x of the first anchor of the curve
  18613. - c1y (number) y of the first anchor of the curve
  18614. - c2x (number) x of the second anchor of the curve
  18615. - c2y (number) y of the second anchor of the curve
  18616. - p2x (number) x of the second point of the curve
  18617. - p2y (number) y of the second point of the curve
  18618. * or
  18619. - bez (array) array of six points for beziér curve
  18620. = (object) bounding box
  18621. o {
  18622. o x: (number) x coordinate of the left top point of the box,
  18623. o y: (number) y coordinate of the left top point of the box,
  18624. o x2: (number) x coordinate of the right bottom point of the box,
  18625. o y2: (number) y coordinate of the right bottom point of the box,
  18626. o width: (number) width of the box,
  18627. o height: (number) height of the box
  18628. o }
  18629. \*/
  18630. Snap.path.bezierBBox = bezierBBox;
  18631. /*\
  18632. * Snap.path.isPointInsideBBox
  18633. [ method ]
  18634. **
  18635. * Utility method
  18636. **
  18637. * Returns `true` if given point is inside bounding box
  18638. - bbox (string) bounding box
  18639. - x (string) x coordinate of the point
  18640. - y (string) y coordinate of the point
  18641. = (boolean) `true` if point is inside
  18642. \*/
  18643. Snap.path.isPointInsideBBox = isPointInsideBBox;
  18644. /*\
  18645. * Snap.path.isBBoxIntersect
  18646. [ method ]
  18647. **
  18648. * Utility method
  18649. **
  18650. * Returns `true` if two bounding boxes intersect
  18651. - bbox1 (string) first bounding box
  18652. - bbox2 (string) second bounding box
  18653. = (boolean) `true` if bounding boxes intersect
  18654. \*/
  18655. Snap.path.isBBoxIntersect = isBBoxIntersect;
  18656. /*\
  18657. * Snap.path.intersection
  18658. [ method ]
  18659. **
  18660. * Utility method
  18661. **
  18662. * Finds intersections of two paths
  18663. - path1 (string) path string
  18664. - path2 (string) path string
  18665. = (array) dots of intersection
  18666. o [
  18667. o {
  18668. o x: (number) x coordinate of the point,
  18669. o y: (number) y coordinate of the point,
  18670. o t1: (number) t value for segment of path1,
  18671. o t2: (number) t value for segment of path2,
  18672. o segment1: (number) order number for segment of path1,
  18673. o segment2: (number) order number for segment of path2,
  18674. o bez1: (array) eight coordinates representing beziér curve for the segment of path1,
  18675. o bez2: (array) eight coordinates representing beziér curve for the segment of path2
  18676. o }
  18677. o ]
  18678. \*/
  18679. Snap.path.intersection = pathIntersection;
  18680. Snap.path.intersectionNumber = pathIntersectionNumber;
  18681. /*\
  18682. * Snap.path.isPointInside
  18683. [ method ]
  18684. **
  18685. * Utility method
  18686. **
  18687. * Returns `true` if given point is inside a given closed path.
  18688. *
  18689. * Note: fill mode doesn’t affect the result of this method.
  18690. - path (string) path string
  18691. - x (number) x of the point
  18692. - y (number) y of the point
  18693. = (boolean) `true` if point is inside the path
  18694. \*/
  18695. Snap.path.isPointInside = isPointInsidePath;
  18696. /*\
  18697. * Snap.path.getBBox
  18698. [ method ]
  18699. **
  18700. * Utility method
  18701. **
  18702. * Returns the bounding box of a given path
  18703. - path (string) path string
  18704. = (object) bounding box
  18705. o {
  18706. o x: (number) x coordinate of the left top point of the box,
  18707. o y: (number) y coordinate of the left top point of the box,
  18708. o x2: (number) x coordinate of the right bottom point of the box,
  18709. o y2: (number) y coordinate of the right bottom point of the box,
  18710. o width: (number) width of the box,
  18711. o height: (number) height of the box
  18712. o }
  18713. \*/
  18714. Snap.path.getBBox = pathBBox;
  18715. Snap.path.get = getPath;
  18716. /*\
  18717. * Snap.path.toRelative
  18718. [ method ]
  18719. **
  18720. * Utility method
  18721. **
  18722. * Converts path coordinates into relative values
  18723. - path (string) path string
  18724. = (array) path string
  18725. \*/
  18726. Snap.path.toRelative = pathToRelative;
  18727. /*\
  18728. * Snap.path.toAbsolute
  18729. [ method ]
  18730. **
  18731. * Utility method
  18732. **
  18733. * Converts path coordinates into absolute values
  18734. - path (string) path string
  18735. = (array) path string
  18736. \*/
  18737. Snap.path.toAbsolute = pathToAbsolute;
  18738. /*\
  18739. * Snap.path.toCubic
  18740. [ method ]
  18741. **
  18742. * Utility method
  18743. **
  18744. * Converts path to a new path where all segments are cubic beziér curves
  18745. - pathString (string|array) path string or array of segments
  18746. = (array) array of segments
  18747. \*/
  18748. Snap.path.toCubic = path2curve;
  18749. /*\
  18750. * Snap.path.map
  18751. [ method ]
  18752. **
  18753. * Transform the path string with the given matrix
  18754. - path (string) path string
  18755. - matrix (object) see @Matrix
  18756. = (string) transformed path string
  18757. \*/
  18758. Snap.path.map = mapPath;
  18759. Snap.path.toString = toString;
  18760. Snap.path.clone = pathClone;
  18761. });
  18762. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  18763. //
  18764. // Licensed under the Apache License, Version 2.0 (the "License");
  18765. // you may not use this file except in compliance with the License.
  18766. // You may obtain a copy of the License at
  18767. //
  18768. // http://www.apache.org/licenses/LICENSE-2.0
  18769. //
  18770. // Unless required by applicable law or agreed to in writing, software
  18771. // distributed under the License is distributed on an "AS IS" BASIS,
  18772. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18773. // See the License for the specific language governing permissions and
  18774. // limitations under the License.
  18775. Snap.plugin(function (Snap, Element, Paper, glob) {
  18776. var elproto = Element.prototype,
  18777. has = "hasOwnProperty",
  18778. supportsTouch = "createTouch" in glob.doc,
  18779. events = [
  18780. "click", "dblclick", "mousedown", "mousemove", "mouseout",
  18781. "mouseover", "mouseup", "touchstart", "touchmove", "touchend",
  18782. "touchcancel"
  18783. ],
  18784. touchMap = {
  18785. mousedown: "touchstart",
  18786. mousemove: "touchmove",
  18787. mouseup: "touchend"
  18788. },
  18789. getScroll = function (xy, el) {
  18790. var name = xy == "y" ? "scrollTop" : "scrollLeft",
  18791. doc = el && el.node ? el.node.ownerDocument : glob.doc;
  18792. return doc[name in doc.documentElement ? "documentElement" : "body"][name];
  18793. },
  18794. preventDefault = function () {
  18795. this.returnValue = false;
  18796. },
  18797. preventTouch = function () {
  18798. return this.originalEvent.preventDefault();
  18799. },
  18800. stopPropagation = function () {
  18801. this.cancelBubble = true;
  18802. },
  18803. stopTouch = function () {
  18804. return this.originalEvent.stopPropagation();
  18805. },
  18806. addEvent = (function () {
  18807. if (glob.doc.addEventListener) {
  18808. return function (obj, type, fn, element) {
  18809. var realName = supportsTouch && touchMap[type] ? touchMap[type] : type,
  18810. f = function (e) {
  18811. var scrollY = getScroll("y", element),
  18812. scrollX = getScroll("x", element);
  18813. if (supportsTouch && touchMap[has](type)) {
  18814. for (var i = 0, ii = e.targetTouches && e.targetTouches.length; i < ii; i++) {
  18815. if (e.targetTouches[i].target == obj || obj.contains(e.targetTouches[i].target)) {
  18816. var olde = e;
  18817. e = e.targetTouches[i];
  18818. e.originalEvent = olde;
  18819. e.preventDefault = preventTouch;
  18820. e.stopPropagation = stopTouch;
  18821. break;
  18822. }
  18823. }
  18824. }
  18825. var x = e.clientX + scrollX,
  18826. y = e.clientY + scrollY;
  18827. return fn.call(element, e, x, y);
  18828. };
  18829. if (type !== realName) {
  18830. obj.addEventListener(type, f, false);
  18831. }
  18832. obj.addEventListener(realName, f, false);
  18833. return function () {
  18834. if (type !== realName) {
  18835. obj.removeEventListener(type, f, false);
  18836. }
  18837. obj.removeEventListener(realName, f, false);
  18838. return true;
  18839. };
  18840. };
  18841. } else if (glob.doc.attachEvent) {
  18842. return function (obj, type, fn, element) {
  18843. var f = function (e) {
  18844. e = e || element.node.ownerDocument.window.event;
  18845. var scrollY = getScroll("y", element),
  18846. scrollX = getScroll("x", element),
  18847. x = e.clientX + scrollX,
  18848. y = e.clientY + scrollY;
  18849. e.preventDefault = e.preventDefault || preventDefault;
  18850. e.stopPropagation = e.stopPropagation || stopPropagation;
  18851. return fn.call(element, e, x, y);
  18852. };
  18853. obj.attachEvent("on" + type, f);
  18854. var detacher = function () {
  18855. obj.detachEvent("on" + type, f);
  18856. return true;
  18857. };
  18858. return detacher;
  18859. };
  18860. }
  18861. })(),
  18862. drag = [],
  18863. dragMove = function (e) {
  18864. var x = e.clientX,
  18865. y = e.clientY,
  18866. scrollY = getScroll("y"),
  18867. scrollX = getScroll("x"),
  18868. dragi,
  18869. j = drag.length;
  18870. while (j--) {
  18871. dragi = drag[j];
  18872. if (supportsTouch) {
  18873. var i = e.touches && e.touches.length,
  18874. touch;
  18875. while (i--) {
  18876. touch = e.touches[i];
  18877. if (touch.identifier == dragi.el._drag.id || dragi.el.node.contains(touch.target)) {
  18878. x = touch.clientX;
  18879. y = touch.clientY;
  18880. (e.originalEvent ? e.originalEvent : e).preventDefault();
  18881. break;
  18882. }
  18883. }
  18884. } else {
  18885. e.preventDefault();
  18886. }
  18887. var node = dragi.el.node,
  18888. o,
  18889. next = node.nextSibling,
  18890. parent = node.parentNode,
  18891. display = node.style.display;
  18892. // glob.win.opera && parent.removeChild(node);
  18893. // node.style.display = "none";
  18894. // o = dragi.el.paper.getElementByPoint(x, y);
  18895. // node.style.display = display;
  18896. // glob.win.opera && (next ? parent.insertBefore(node, next) : parent.appendChild(node));
  18897. // o && eve("snap.drag.over." + dragi.el.id, dragi.el, o);
  18898. x += scrollX;
  18899. y += scrollY;
  18900. 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);
  18901. }
  18902. },
  18903. dragUp = function (e) {
  18904. Snap.unmousemove(dragMove).unmouseup(dragUp);
  18905. var i = drag.length,
  18906. dragi;
  18907. while (i--) {
  18908. dragi = drag[i];
  18909. dragi.el._drag = {};
  18910. eve("snap.drag.end." + dragi.el.id, dragi.end_scope || dragi.start_scope || dragi.move_scope || dragi.el, e);
  18911. }
  18912. drag = [];
  18913. };
  18914. /*\
  18915. * Element.click
  18916. [ method ]
  18917. **
  18918. * Adds a click event handler to the element
  18919. - handler (function) handler for the event
  18920. = (object) @Element
  18921. \*/
  18922. /*\
  18923. * Element.unclick
  18924. [ method ]
  18925. **
  18926. * Removes a click event handler from the element
  18927. - handler (function) handler for the event
  18928. = (object) @Element
  18929. \*/
  18930. /*\
  18931. * Element.dblclick
  18932. [ method ]
  18933. **
  18934. * Adds a double click event handler to the element
  18935. - handler (function) handler for the event
  18936. = (object) @Element
  18937. \*/
  18938. /*\
  18939. * Element.undblclick
  18940. [ method ]
  18941. **
  18942. * Removes a double click event handler from the element
  18943. - handler (function) handler for the event
  18944. = (object) @Element
  18945. \*/
  18946. /*\
  18947. * Element.mousedown
  18948. [ method ]
  18949. **
  18950. * Adds a mousedown event handler to the element
  18951. - handler (function) handler for the event
  18952. = (object) @Element
  18953. \*/
  18954. /*\
  18955. * Element.unmousedown
  18956. [ method ]
  18957. **
  18958. * Removes a mousedown event handler from the element
  18959. - handler (function) handler for the event
  18960. = (object) @Element
  18961. \*/
  18962. /*\
  18963. * Element.mousemove
  18964. [ method ]
  18965. **
  18966. * Adds a mousemove event handler to the element
  18967. - handler (function) handler for the event
  18968. = (object) @Element
  18969. \*/
  18970. /*\
  18971. * Element.unmousemove
  18972. [ method ]
  18973. **
  18974. * Removes a mousemove event handler from the element
  18975. - handler (function) handler for the event
  18976. = (object) @Element
  18977. \*/
  18978. /*\
  18979. * Element.mouseout
  18980. [ method ]
  18981. **
  18982. * Adds a mouseout event handler to the element
  18983. - handler (function) handler for the event
  18984. = (object) @Element
  18985. \*/
  18986. /*\
  18987. * Element.unmouseout
  18988. [ method ]
  18989. **
  18990. * Removes a mouseout event handler from the element
  18991. - handler (function) handler for the event
  18992. = (object) @Element
  18993. \*/
  18994. /*\
  18995. * Element.mouseover
  18996. [ method ]
  18997. **
  18998. * Adds a mouseover event handler to the element
  18999. - handler (function) handler for the event
  19000. = (object) @Element
  19001. \*/
  19002. /*\
  19003. * Element.unmouseover
  19004. [ method ]
  19005. **
  19006. * Removes a mouseover event handler from the element
  19007. - handler (function) handler for the event
  19008. = (object) @Element
  19009. \*/
  19010. /*\
  19011. * Element.mouseup
  19012. [ method ]
  19013. **
  19014. * Adds a mouseup event handler to the element
  19015. - handler (function) handler for the event
  19016. = (object) @Element
  19017. \*/
  19018. /*\
  19019. * Element.unmouseup
  19020. [ method ]
  19021. **
  19022. * Removes a mouseup event handler from the element
  19023. - handler (function) handler for the event
  19024. = (object) @Element
  19025. \*/
  19026. /*\
  19027. * Element.touchstart
  19028. [ method ]
  19029. **
  19030. * Adds a touchstart event handler to the element
  19031. - handler (function) handler for the event
  19032. = (object) @Element
  19033. \*/
  19034. /*\
  19035. * Element.untouchstart
  19036. [ method ]
  19037. **
  19038. * Removes a touchstart event handler from the element
  19039. - handler (function) handler for the event
  19040. = (object) @Element
  19041. \*/
  19042. /*\
  19043. * Element.touchmove
  19044. [ method ]
  19045. **
  19046. * Adds a touchmove event handler to the element
  19047. - handler (function) handler for the event
  19048. = (object) @Element
  19049. \*/
  19050. /*\
  19051. * Element.untouchmove
  19052. [ method ]
  19053. **
  19054. * Removes a touchmove event handler from the element
  19055. - handler (function) handler for the event
  19056. = (object) @Element
  19057. \*/
  19058. /*\
  19059. * Element.touchend
  19060. [ method ]
  19061. **
  19062. * Adds a touchend event handler to the element
  19063. - handler (function) handler for the event
  19064. = (object) @Element
  19065. \*/
  19066. /*\
  19067. * Element.untouchend
  19068. [ method ]
  19069. **
  19070. * Removes a touchend event handler from the element
  19071. - handler (function) handler for the event
  19072. = (object) @Element
  19073. \*/
  19074. /*\
  19075. * Element.touchcancel
  19076. [ method ]
  19077. **
  19078. * Adds a touchcancel event handler to the element
  19079. - handler (function) handler for the event
  19080. = (object) @Element
  19081. \*/
  19082. /*\
  19083. * Element.untouchcancel
  19084. [ method ]
  19085. **
  19086. * Removes a touchcancel event handler from the element
  19087. - handler (function) handler for the event
  19088. = (object) @Element
  19089. \*/
  19090. for (var i = events.length; i--;) {
  19091. (function (eventName) {
  19092. Snap[eventName] = elproto[eventName] = function (fn, scope) {
  19093. if (Snap.is(fn, "function")) {
  19094. this.events = this.events || [];
  19095. this.events.push({
  19096. name: eventName,
  19097. f: fn,
  19098. unbind: addEvent(this.node || document, eventName, fn, scope || this)
  19099. });
  19100. }
  19101. return this;
  19102. };
  19103. Snap["un" + eventName] =
  19104. elproto["un" + eventName] = function (fn) {
  19105. var events = this.events || [],
  19106. l = events.length;
  19107. while (l--) if (events[l].name == eventName &&
  19108. (events[l].f == fn || !fn)) {
  19109. events[l].unbind();
  19110. events.splice(l, 1);
  19111. !events.length && delete this.events;
  19112. return this;
  19113. }
  19114. return this;
  19115. };
  19116. })(events[i]);
  19117. }
  19118. /*\
  19119. * Element.hover
  19120. [ method ]
  19121. **
  19122. * Adds hover event handlers to the element
  19123. - f_in (function) handler for hover in
  19124. - f_out (function) handler for hover out
  19125. - icontext (object) #optional context for hover in handler
  19126. - ocontext (object) #optional context for hover out handler
  19127. = (object) @Element
  19128. \*/
  19129. elproto.hover = function (f_in, f_out, scope_in, scope_out) {
  19130. return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out || scope_in);
  19131. };
  19132. /*\
  19133. * Element.unhover
  19134. [ method ]
  19135. **
  19136. * Removes hover event handlers from the element
  19137. - f_in (function) handler for hover in
  19138. - f_out (function) handler for hover out
  19139. = (object) @Element
  19140. \*/
  19141. elproto.unhover = function (f_in, f_out) {
  19142. return this.unmouseover(f_in).unmouseout(f_out);
  19143. };
  19144. var draggable = [];
  19145. // SIERRA unclear what _context_ refers to for starting, ending, moving the drag gesture.
  19146. // SIERRA Element.drag(): _x position of the mouse_: Where are the x/y values offset from?
  19147. // SIERRA Element.drag(): much of this member's doc appears to be duplicated for some reason.
  19148. // 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?
  19149. /*\
  19150. * Element.drag
  19151. [ method ]
  19152. **
  19153. * Adds event handlers for an element's drag gesture
  19154. **
  19155. - onmove (function) handler for moving
  19156. - onstart (function) handler for drag start
  19157. - onend (function) handler for drag end
  19158. - mcontext (object) #optional context for moving handler
  19159. - scontext (object) #optional context for drag start handler
  19160. - econtext (object) #optional context for drag end handler
  19161. * Additionaly following `drag` events are triggered: `drag.start.<id>` on start,
  19162. * `drag.end.<id>` on end and `drag.move.<id>` on every move. When element is dragged over another element
  19163. * `drag.over.<id>` fires as well.
  19164. *
  19165. * Start event and start handler are called in specified context or in context of the element with following parameters:
  19166. o x (number) x position of the mouse
  19167. o y (number) y position of the mouse
  19168. o event (object) DOM event object
  19169. * Move event and move handler are called in specified context or in context of the element with following parameters:
  19170. o dx (number) shift by x from the start point
  19171. o dy (number) shift by y from the start point
  19172. o x (number) x position of the mouse
  19173. o y (number) y position of the mouse
  19174. o event (object) DOM event object
  19175. * End event and end handler are called in specified context or in context of the element with following parameters:
  19176. o event (object) DOM event object
  19177. = (object) @Element
  19178. \*/
  19179. elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) {
  19180. if (!arguments.length) {
  19181. var origTransform;
  19182. return this.drag(function (dx, dy) {
  19183. this.attr({
  19184. transform: origTransform + (origTransform ? "T" : "t") + [dx, dy]
  19185. });
  19186. }, function () {
  19187. origTransform = this.transform().local;
  19188. });
  19189. }
  19190. function start(e, x, y) {
  19191. (e.originalEvent || e).preventDefault();
  19192. this._drag.x = x;
  19193. this._drag.y = y;
  19194. this._drag.id = e.identifier;
  19195. !drag.length && Snap.mousemove(dragMove).mouseup(dragUp);
  19196. drag.push({el: this, move_scope: move_scope, start_scope: start_scope, end_scope: end_scope});
  19197. onstart && eve.on("snap.drag.start." + this.id, onstart);
  19198. onmove && eve.on("snap.drag.move." + this.id, onmove);
  19199. onend && eve.on("snap.drag.end." + this.id, onend);
  19200. eve("snap.drag.start." + this.id, start_scope || move_scope || this, x, y, e);
  19201. }
  19202. this._drag = {};
  19203. draggable.push({el: this, start: start});
  19204. this.mousedown(start);
  19205. return this;
  19206. };
  19207. /*
  19208. * Element.onDragOver
  19209. [ method ]
  19210. **
  19211. * Shortcut to assign event handler for `drag.over.<id>` event, where `id` is the element's `id` (see @Element.id)
  19212. - f (function) handler for event, first argument would be the element you are dragging over
  19213. \*/
  19214. // elproto.onDragOver = function (f) {
  19215. // f ? eve.on("snap.drag.over." + this.id, f) : eve.unbind("snap.drag.over." + this.id);
  19216. // };
  19217. /*\
  19218. * Element.undrag
  19219. [ method ]
  19220. **
  19221. * Removes all drag event handlers from the given element
  19222. \*/
  19223. elproto.undrag = function () {
  19224. var i = draggable.length;
  19225. while (i--) if (draggable[i].el == this) {
  19226. this.unmousedown(draggable[i].start);
  19227. draggable.splice(i, 1);
  19228. eve.unbind("snap.drag.*." + this.id);
  19229. }
  19230. !draggable.length && Snap.unmousemove(dragMove).unmouseup(dragUp);
  19231. return this;
  19232. };
  19233. });
  19234. // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
  19235. //
  19236. // Licensed under the Apache License, Version 2.0 (the "License");
  19237. // you may not use this file except in compliance with the License.
  19238. // You may obtain a copy of the License at
  19239. //
  19240. // http://www.apache.org/licenses/LICENSE-2.0
  19241. //
  19242. // Unless required by applicable law or agreed to in writing, software
  19243. // distributed under the License is distributed on an "AS IS" BASIS,
  19244. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19245. // See the License for the specific language governing permissions and
  19246. // limitations under the License.
  19247. Snap.plugin(function (Snap, Element, Paper, glob) {
  19248. var elproto = Element.prototype,
  19249. pproto = Paper.prototype,
  19250. rgurl = /^\s*url\((.+)\)/,
  19251. Str = String,
  19252. $ = Snap._.$;
  19253. Snap.filter = {};
  19254. /*\
  19255. * Paper.filter
  19256. [ method ]
  19257. **
  19258. * Creates a `<filter>` element
  19259. **
  19260. - filstr (string) SVG fragment of filter provided as a string
  19261. = (object) @Element
  19262. * Note: It is recommended to use filters embedded into the page inside an empty SVG element.
  19263. > Usage
  19264. | var f = paper.filter('<feGaussianBlur stdDeviation="2"/>'),
  19265. | c = paper.circle(10, 10, 10).attr({
  19266. | filter: f
  19267. | });
  19268. \*/
  19269. pproto.filter = function (filstr) {
  19270. var paper = this;
  19271. if (paper.type != "svg") {
  19272. paper = paper.paper;
  19273. }
  19274. var f = Snap.parse(Str(filstr)),
  19275. id = Snap._.id(),
  19276. width = paper.node.offsetWidth,
  19277. height = paper.node.offsetHeight,
  19278. filter = $("filter");
  19279. $(filter, {
  19280. id: id,
  19281. filterUnits: "userSpaceOnUse"
  19282. });
  19283. filter.appendChild(f.node);
  19284. paper.defs.appendChild(filter);
  19285. return new Element(filter);
  19286. };
  19287. eve.on("snap.util.getattr.filter", function () {
  19288. eve.stop();
  19289. var p = $(this.node, "filter");
  19290. if (p) {
  19291. var match = Str(p).match(rgurl);
  19292. return match && Snap.select(match[1]);
  19293. }
  19294. });
  19295. eve.on("snap.util.attr.filter", function (value) {
  19296. if (value instanceof Element && value.type == "filter") {
  19297. eve.stop();
  19298. var id = value.node.id;
  19299. if (!id) {
  19300. $(value.node, {id: value.id});
  19301. id = value.id;
  19302. }
  19303. $(this.node, {
  19304. filter: Snap.url(id)
  19305. });
  19306. }
  19307. if (!value || value == "none") {
  19308. eve.stop();
  19309. this.node.removeAttribute("filter");
  19310. }
  19311. });
  19312. /*\
  19313. * Snap.filter.blur
  19314. [ method ]
  19315. **
  19316. * Returns an SVG markup string for the blur filter
  19317. **
  19318. - x (number) amount of horizontal blur, in pixels
  19319. - y (number) #optional amount of vertical blur, in pixels
  19320. = (string) filter representation
  19321. > Usage
  19322. | var f = paper.filter(Snap.filter.blur(5, 10)),
  19323. | c = paper.circle(10, 10, 10).attr({
  19324. | filter: f
  19325. | });
  19326. \*/
  19327. Snap.filter.blur = function (x, y) {
  19328. if (x == null) {
  19329. x = 2;
  19330. }
  19331. var def = y == null ? x : [x, y];
  19332. return Snap.format('\<feGaussianBlur stdDeviation="{def}"/>', {
  19333. def: def
  19334. });
  19335. };
  19336. Snap.filter.blur.toString = function () {
  19337. return this();
  19338. };
  19339. /*\
  19340. * Snap.filter.shadow
  19341. [ method ]
  19342. **
  19343. * Returns an SVG markup string for the shadow filter
  19344. **
  19345. - dx (number) #optional horizontal shift of the shadow, in pixels
  19346. - dy (number) #optional vertical shift of the shadow, in pixels
  19347. - blur (number) #optional amount of blur
  19348. - color (string) #optional color of the shadow
  19349. - opacity (number) #optional `0..1` opacity of the shadow
  19350. * or
  19351. - dx (number) #optional horizontal shift of the shadow, in pixels
  19352. - dy (number) #optional vertical shift of the shadow, in pixels
  19353. - color (string) #optional color of the shadow
  19354. - opacity (number) #optional `0..1` opacity of the shadow
  19355. * which makes blur default to `4`. Or
  19356. - dx (number) #optional horizontal shift of the shadow, in pixels
  19357. - dy (number) #optional vertical shift of the shadow, in pixels
  19358. - opacity (number) #optional `0..1` opacity of the shadow
  19359. = (string) filter representation
  19360. > Usage
  19361. | var f = paper.filter(Snap.filter.shadow(0, 2, 3)),
  19362. | c = paper.circle(10, 10, 10).attr({
  19363. | filter: f
  19364. | });
  19365. \*/
  19366. Snap.filter.shadow = function (dx, dy, blur, color, opacity) {
  19367. if (typeof blur == "string") {
  19368. color = blur;
  19369. opacity = color;
  19370. blur = 4;
  19371. }
  19372. if (typeof color != "string") {
  19373. opacity = color;
  19374. color = "#000";
  19375. }
  19376. color = color || "#000";
  19377. if (blur == null) {
  19378. blur = 4;
  19379. }
  19380. if (opacity == null) {
  19381. opacity = 1;
  19382. }
  19383. if (dx == null) {
  19384. dx = 0;
  19385. dy = 2;
  19386. }
  19387. if (dy == null) {
  19388. dy = dx;
  19389. }
  19390. color = Snap.color(color);
  19391. 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>', {
  19392. color: color,
  19393. dx: dx,
  19394. dy: dy,
  19395. blur: blur,
  19396. opacity: opacity
  19397. });
  19398. };
  19399. Snap.filter.shadow.toString = function () {
  19400. return this();
  19401. };
  19402. /*\
  19403. * Snap.filter.grayscale
  19404. [ method ]
  19405. **
  19406. * Returns an SVG markup string for the grayscale filter
  19407. **
  19408. - amount (number) amount of filter (`0..1`)
  19409. = (string) filter representation
  19410. \*/
  19411. Snap.filter.grayscale = function (amount) {
  19412. if (amount == null) {
  19413. amount = 1;
  19414. }
  19415. 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"/>', {
  19416. a: 0.2126 + 0.7874 * (1 - amount),
  19417. b: 0.7152 - 0.7152 * (1 - amount),
  19418. c: 0.0722 - 0.0722 * (1 - amount),
  19419. d: 0.2126 - 0.2126 * (1 - amount),
  19420. e: 0.7152 + 0.2848 * (1 - amount),
  19421. f: 0.0722 - 0.0722 * (1 - amount),
  19422. g: 0.2126 - 0.2126 * (1 - amount),
  19423. h: 0.0722 + 0.9278 * (1 - amount)
  19424. });
  19425. };
  19426. Snap.filter.grayscale.toString = function () {
  19427. return this();
  19428. };
  19429. /*\
  19430. * Snap.filter.sepia
  19431. [ method ]
  19432. **
  19433. * Returns an SVG markup string for the sepia filter
  19434. **
  19435. - amount (number) amount of filter (`0..1`)
  19436. = (string) filter representation
  19437. \*/
  19438. Snap.filter.sepia = function (amount) {
  19439. if (amount == null) {
  19440. amount = 1;
  19441. }
  19442. 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"/>', {
  19443. a: 0.393 + 0.607 * (1 - amount),
  19444. b: 0.769 - 0.769 * (1 - amount),
  19445. c: 0.189 - 0.189 * (1 - amount),
  19446. d: 0.349 - 0.349 * (1 - amount),
  19447. e: 0.686 + 0.314 * (1 - amount),
  19448. f: 0.168 - 0.168 * (1 - amount),
  19449. g: 0.272 - 0.272 * (1 - amount),
  19450. h: 0.534 - 0.534 * (1 - amount),
  19451. i: 0.131 + 0.869 * (1 - amount)
  19452. });
  19453. };
  19454. Snap.filter.sepia.toString = function () {
  19455. return this();
  19456. };
  19457. /*\
  19458. * Snap.filter.saturate
  19459. [ method ]
  19460. **
  19461. * Returns an SVG markup string for the saturate filter
  19462. **
  19463. - amount (number) amount of filter (`0..1`)
  19464. = (string) filter representation
  19465. \*/
  19466. Snap.filter.saturate = function (amount) {
  19467. if (amount == null) {
  19468. amount = 1;
  19469. }
  19470. return Snap.format('<feColorMatrix type="saturate" values="{amount}"/>', {
  19471. amount: 1 - amount
  19472. });
  19473. };
  19474. Snap.filter.saturate.toString = function () {
  19475. return this();
  19476. };
  19477. /*\
  19478. * Snap.filter.hueRotate
  19479. [ method ]
  19480. **
  19481. * Returns an SVG markup string for the hue-rotate filter
  19482. **
  19483. - angle (number) angle of rotation
  19484. = (string) filter representation
  19485. \*/
  19486. Snap.filter.hueRotate = function (angle) {
  19487. angle = angle || 0;
  19488. return Snap.format('<feColorMatrix type="hueRotate" values="{angle}"/>', {
  19489. angle: angle
  19490. });
  19491. };
  19492. Snap.filter.hueRotate.toString = function () {
  19493. return this();
  19494. };
  19495. /*\
  19496. * Snap.filter.invert
  19497. [ method ]
  19498. **
  19499. * Returns an SVG markup string for the invert filter
  19500. **
  19501. - amount (number) amount of filter (`0..1`)
  19502. = (string) filter representation
  19503. \*/
  19504. Snap.filter.invert = function (amount) {
  19505. if (amount == null) {
  19506. amount = 1;
  19507. }
  19508. return Snap.format('<feComponentTransfer><feFuncR type="table" tableValues="{amount} {amount2}"/><feFuncG type="table" tableValues="{amount} {amount2}"/><feFuncB type="table" tableValues="{amount} {amount2}"/></feComponentTransfer>', {
  19509. amount: amount,
  19510. amount2: 1 - amount
  19511. });
  19512. };
  19513. Snap.filter.invert.toString = function () {
  19514. return this();
  19515. };
  19516. /*\
  19517. * Snap.filter.brightness
  19518. [ method ]
  19519. **
  19520. * Returns an SVG markup string for the brightness filter
  19521. **
  19522. - amount (number) amount of filter (`0..1`)
  19523. = (string) filter representation
  19524. \*/
  19525. Snap.filter.brightness = function (amount) {
  19526. if (amount == null) {
  19527. amount = 1;
  19528. }
  19529. return Snap.format('<feComponentTransfer><feFuncR type="linear" slope="{amount}"/><feFuncG type="linear" slope="{amount}"/><feFuncB type="linear" slope="{amount}"/></feComponentTransfer>', {
  19530. amount: amount
  19531. });
  19532. };
  19533. Snap.filter.brightness.toString = function () {
  19534. return this();
  19535. };
  19536. /*\
  19537. * Snap.filter.contrast
  19538. [ method ]
  19539. **
  19540. * Returns an SVG markup string for the contrast filter
  19541. **
  19542. - amount (number) amount of filter (`0..1`)
  19543. = (string) filter representation
  19544. \*/
  19545. Snap.filter.contrast = function (amount) {
  19546. if (amount == null) {
  19547. amount = 1;
  19548. }
  19549. 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>', {
  19550. amount: amount,
  19551. amount2: .5 - amount / 2
  19552. });
  19553. };
  19554. Snap.filter.contrast.toString = function () {
  19555. return this();
  19556. };
  19557. });
  19558. return Snap;
  19559. }));
  19560. },{"65":65}],67:[function(_dereq_,module,exports){
  19561. 'use strict';
  19562. var snapsvg = module.exports = _dereq_(66);
  19563. snapsvg.plugin(function(Snap, Element) {
  19564. /*\
  19565. * Element.children
  19566. [ method ]
  19567. **
  19568. * Returns array of all the children of the element.
  19569. = (array) array of Elements
  19570. \*/
  19571. Element.prototype.children = function () {
  19572. var out = [],
  19573. ch = this.node.childNodes;
  19574. for (var i = 0, ii = ch.length; i < ii; i++) {
  19575. out[i] = new Snap(ch[i]);
  19576. }
  19577. return out;
  19578. };
  19579. });
  19580. /**
  19581. * @class ClassPlugin
  19582. *
  19583. * Extends snapsvg with methods to add and remove classes
  19584. */
  19585. snapsvg.plugin(function (Snap, Element, Paper, global) {
  19586. function split(str) {
  19587. return str.split(/\s+/);
  19588. }
  19589. function join(array) {
  19590. return array.join(' ');
  19591. }
  19592. function getClasses(e) {
  19593. return split(e.attr('class') || '');
  19594. }
  19595. function setClasses(e, classes) {
  19596. e.attr('class', join(classes));
  19597. }
  19598. /**
  19599. * @method snapsvg.Element#addClass
  19600. *
  19601. * @example
  19602. *
  19603. * e.attr('class', 'selector');
  19604. *
  19605. * e.addClass('foo bar'); // adds classes foo and bar
  19606. * e.attr('class'); // -> 'selector foo bar'
  19607. *
  19608. * e.addClass('fooBar');
  19609. * e.attr('class'); // -> 'selector foo bar fooBar'
  19610. *
  19611. * @param {String} cls classes to be added to the element
  19612. *
  19613. * @return {snapsvg.Element} the element (this)
  19614. */
  19615. Element.prototype.addClass = function(cls) {
  19616. var current = getClasses(this),
  19617. add = split(cls),
  19618. i, e;
  19619. for (i = 0, e; !!(e = add[i]); i++) {
  19620. if (current.indexOf(e) === -1) {
  19621. current.push(e);
  19622. }
  19623. }
  19624. setClasses(this, current);
  19625. return this;
  19626. };
  19627. /**
  19628. * @method snapsvg.Element#hasClass
  19629. *
  19630. * @param {String} cls the class to query for
  19631. * @return {Boolean} returns true if the element has the given class
  19632. */
  19633. Element.prototype.hasClass = function(cls) {
  19634. if (!cls) {
  19635. throw new Error('[snapsvg] syntax: hasClass(clsStr)');
  19636. }
  19637. return getClasses(this).indexOf(cls) !== -1;
  19638. };
  19639. /**
  19640. * @method snapsvg.Element#removeClass
  19641. *
  19642. * @example
  19643. *
  19644. * e.attr('class', 'foo bar');
  19645. *
  19646. * e.removeClass('foo');
  19647. * e.attr('class'); // -> 'bar'
  19648. *
  19649. * e.removeClass('foo bar'); // removes classes foo and bar
  19650. * e.attr('class'); // -> ''
  19651. *
  19652. * @param {String} cls classes to be removed from element
  19653. *
  19654. * @return {snapsvg.Element} the element (this)
  19655. */
  19656. Element.prototype.removeClass = function(cls) {
  19657. var current = getClasses(this),
  19658. remove = split(cls),
  19659. i, e, idx;
  19660. for (i = 0, e; !!(e = remove[i]); i++) {
  19661. idx = current.indexOf(e);
  19662. if (idx !== -1) {
  19663. // remove element from array
  19664. current.splice(idx, 1);
  19665. }
  19666. }
  19667. setClasses(this, current);
  19668. return this;
  19669. };
  19670. });
  19671. /**
  19672. * @class TranslatePlugin
  19673. *
  19674. * Extends snapsvg with methods to translate elements
  19675. */
  19676. snapsvg.plugin(function (Snap, Element, Paper, global) {
  19677. /*
  19678. * @method snapsvg.Element#translate
  19679. *
  19680. * @example
  19681. *
  19682. * e.translate(10, 20);
  19683. *
  19684. * // sets transform matrix to translate(10, 20)
  19685. *
  19686. * @param {Number} x translation
  19687. * @param {Number} y translation
  19688. *
  19689. * @return {snapsvg.Element} the element (this)
  19690. */
  19691. Element.prototype.translate = function(x, y) {
  19692. var matrix = new Snap.Matrix();
  19693. matrix.translate(x, y);
  19694. return this.transform(matrix);
  19695. };
  19696. });
  19697. /**
  19698. * @class CreatePlugin
  19699. *
  19700. * Create an svg element without attaching it to the dom
  19701. */
  19702. snapsvg.plugin(function(Snap) {
  19703. Snap.create = function(name, attrs) {
  19704. return Snap._.wrap(Snap._.$(name, attrs));
  19705. };
  19706. });
  19707. /**
  19708. * @class CreatSnapAtPlugin
  19709. *
  19710. * Extends snap.svg with a method to create a SVG element
  19711. * at a specific position in the DOM.
  19712. */
  19713. snapsvg.plugin(function(Snap, Element, Paper, global) {
  19714. /*
  19715. * @method snapsvg.createSnapAt
  19716. *
  19717. * @example
  19718. *
  19719. * snapsvg.createSnapAt(parentNode, 200, 200);
  19720. *
  19721. * @param {Number} width of svg
  19722. * @param {Number} height of svg
  19723. * @param {Object} parentNode svg Element will be child of this
  19724. *
  19725. * @return {snapsvg.Element} the newly created wrapped SVG element instance
  19726. */
  19727. Snap.createSnapAt = function(width, height, parentNode) {
  19728. var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
  19729. svg.setAttribute('width', width);
  19730. svg.setAttribute('height', height);
  19731. if (!parentNode) {
  19732. parentNode = document.body;
  19733. }
  19734. parentNode.appendChild(svg);
  19735. return new Snap(svg);
  19736. };
  19737. });
  19738. },{"66":66}],68:[function(_dereq_,module,exports){
  19739. var isArray = function(obj) {
  19740. return Object.prototype.toString.call(obj) === '[object Array]';
  19741. };
  19742. var annotate = function() {
  19743. var args = Array.prototype.slice.call(arguments);
  19744. if (args.length === 1 && isArray(args[0])) {
  19745. args = args[0];
  19746. }
  19747. var fn = args.pop();
  19748. fn.$inject = args;
  19749. return fn;
  19750. };
  19751. // Current limitations:
  19752. // - can't put into "function arg" comments
  19753. // function /* (no parenthesis like this) */ (){}
  19754. // function abc( /* xx (no parenthesis like this) */ a, b) {}
  19755. //
  19756. // Just put the comment before function or inside:
  19757. // /* (((this is fine))) */ function(a, b) {}
  19758. // function abc(a) { /* (((this is fine))) */}
  19759. var FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
  19760. var FN_ARG = /\/\*([^\*]*)\*\//m;
  19761. var parse = function(fn) {
  19762. if (typeof fn !== 'function') {
  19763. throw new Error('Cannot annotate "' + fn + '". Expected a function!');
  19764. }
  19765. var match = fn.toString().match(FN_ARGS);
  19766. return match[1] && match[1].split(',').map(function(arg) {
  19767. match = arg.match(FN_ARG);
  19768. return match ? match[1].trim() : arg.trim();
  19769. }) || [];
  19770. };
  19771. exports.annotate = annotate;
  19772. exports.parse = parse;
  19773. exports.isArray = isArray;
  19774. },{}],69:[function(_dereq_,module,exports){
  19775. module.exports = {
  19776. annotate: _dereq_(68).annotate,
  19777. Module: _dereq_(71),
  19778. Injector: _dereq_(70)
  19779. };
  19780. },{"68":68,"70":70,"71":71}],70:[function(_dereq_,module,exports){
  19781. var Module = _dereq_(71);
  19782. var autoAnnotate = _dereq_(68).parse;
  19783. var annotate = _dereq_(68).annotate;
  19784. var isArray = _dereq_(68).isArray;
  19785. var Injector = function(modules, parent) {
  19786. parent = parent || {
  19787. get: function(name) {
  19788. currentlyResolving.push(name);
  19789. throw error('No provider for "' + name + '"!');
  19790. }
  19791. };
  19792. var currentlyResolving = [];
  19793. var providers = this._providers = Object.create(parent._providers || null);
  19794. var instances = this._instances = Object.create(null);
  19795. var self = instances.injector = this;
  19796. var error = function(msg) {
  19797. var stack = currentlyResolving.join(' -> ');
  19798. currentlyResolving.length = 0;
  19799. return new Error(stack ? msg + ' (Resolving: ' + stack + ')' : msg);
  19800. };
  19801. var get = function(name) {
  19802. if (!providers[name] && name.indexOf('.') !== -1) {
  19803. var parts = name.split('.');
  19804. var pivot = get(parts.shift());
  19805. while(parts.length) {
  19806. pivot = pivot[parts.shift()];
  19807. }
  19808. return pivot;
  19809. }
  19810. if (Object.hasOwnProperty.call(instances, name)) {
  19811. return instances[name];
  19812. }
  19813. if (Object.hasOwnProperty.call(providers, name)) {
  19814. if (currentlyResolving.indexOf(name) !== -1) {
  19815. currentlyResolving.push(name);
  19816. throw error('Cannot resolve circular dependency!');
  19817. }
  19818. currentlyResolving.push(name);
  19819. instances[name] = providers[name][0](providers[name][1]);
  19820. currentlyResolving.pop();
  19821. return instances[name];
  19822. }
  19823. return parent.get(name);
  19824. };
  19825. var instantiate = function(Type) {
  19826. var instance = Object.create(Type.prototype);
  19827. var returned = invoke(Type, instance);
  19828. return typeof returned === 'object' ? returned : instance;
  19829. };
  19830. var invoke = function(fn, context) {
  19831. if (typeof fn !== 'function') {
  19832. if (isArray(fn)) {
  19833. fn = annotate(fn.slice());
  19834. } else {
  19835. throw new Error('Cannot invoke "' + fn + '". Expected a function!');
  19836. }
  19837. }
  19838. var inject = fn.$inject && fn.$inject || autoAnnotate(fn);
  19839. var dependencies = inject.map(function(dep) {
  19840. return get(dep);
  19841. });
  19842. // TODO(vojta): optimize without apply
  19843. return fn.apply(context, dependencies);
  19844. };
  19845. var createPrivateInjectorFactory = function(privateChildInjector) {
  19846. return annotate(function(key) {
  19847. return privateChildInjector.get(key);
  19848. });
  19849. };
  19850. var createChild = function(modules, forceNewInstances) {
  19851. if (forceNewInstances && forceNewInstances.length) {
  19852. var fromParentModule = Object.create(null);
  19853. var matchedScopes = Object.create(null);
  19854. var privateInjectorsCache = [];
  19855. var privateChildInjectors = [];
  19856. var privateChildFactories = [];
  19857. var provider;
  19858. var cacheIdx;
  19859. var privateChildInjector;
  19860. var privateChildInjectorFactory;
  19861. for (var name in providers) {
  19862. provider = providers[name];
  19863. if (forceNewInstances.indexOf(name) !== -1) {
  19864. if (provider[2] === 'private') {
  19865. cacheIdx = privateInjectorsCache.indexOf(provider[3]);
  19866. if (cacheIdx === -1) {
  19867. privateChildInjector = provider[3].createChild([], forceNewInstances);
  19868. privateChildInjectorFactory = createPrivateInjectorFactory(privateChildInjector);
  19869. privateInjectorsCache.push(provider[3]);
  19870. privateChildInjectors.push(privateChildInjector);
  19871. privateChildFactories.push(privateChildInjectorFactory);
  19872. fromParentModule[name] = [privateChildInjectorFactory, name, 'private', privateChildInjector];
  19873. } else {
  19874. fromParentModule[name] = [privateChildFactories[cacheIdx], name, 'private', privateChildInjectors[cacheIdx]];
  19875. }
  19876. } else {
  19877. fromParentModule[name] = [provider[2], provider[1]];
  19878. }
  19879. matchedScopes[name] = true;
  19880. }
  19881. if ((provider[2] === 'factory' || provider[2] === 'type') && provider[1].$scope) {
  19882. forceNewInstances.forEach(function(scope) {
  19883. if (provider[1].$scope.indexOf(scope) !== -1) {
  19884. fromParentModule[name] = [provider[2], provider[1]];
  19885. matchedScopes[scope] = true;
  19886. }
  19887. });
  19888. }
  19889. }
  19890. forceNewInstances.forEach(function(scope) {
  19891. if (!matchedScopes[scope]) {
  19892. throw new Error('No provider for "' + scope + '". Cannot use provider from the parent!');
  19893. }
  19894. });
  19895. modules.unshift(fromParentModule);
  19896. }
  19897. return new Injector(modules, self);
  19898. };
  19899. var factoryMap = {
  19900. factory: invoke,
  19901. type: instantiate,
  19902. value: function(value) {
  19903. return value;
  19904. }
  19905. };
  19906. modules.forEach(function(module) {
  19907. function arrayUnwrap(type, value) {
  19908. if (type !== 'value' && isArray(value)) {
  19909. value = annotate(value.slice());
  19910. }
  19911. return value;
  19912. }
  19913. // TODO(vojta): handle wrong inputs (modules)
  19914. if (module instanceof Module) {
  19915. module.forEach(function(provider) {
  19916. var name = provider[0];
  19917. var type = provider[1];
  19918. var value = provider[2];
  19919. providers[name] = [factoryMap[type], arrayUnwrap(type, value), type];
  19920. });
  19921. } else if (typeof module === 'object') {
  19922. if (module.__exports__) {
  19923. var clonedModule = Object.keys(module).reduce(function(m, key) {
  19924. if (key.substring(0, 2) !== '__') {
  19925. m[key] = module[key];
  19926. }
  19927. return m;
  19928. }, Object.create(null));
  19929. var privateInjector = new Injector((module.__modules__ || []).concat([clonedModule]), self);
  19930. var getFromPrivateInjector = annotate(function(key) {
  19931. return privateInjector.get(key);
  19932. });
  19933. module.__exports__.forEach(function(key) {
  19934. providers[key] = [getFromPrivateInjector, key, 'private', privateInjector];
  19935. });
  19936. } else {
  19937. Object.keys(module).forEach(function(name) {
  19938. if (module[name][2] === 'private') {
  19939. providers[name] = module[name];
  19940. return;
  19941. }
  19942. var type = module[name][0];
  19943. var value = module[name][1];
  19944. providers[name] = [factoryMap[type], arrayUnwrap(type, value), type];
  19945. });
  19946. }
  19947. }
  19948. });
  19949. // public API
  19950. this.get = get;
  19951. this.invoke = invoke;
  19952. this.instantiate = instantiate;
  19953. this.createChild = createChild;
  19954. };
  19955. module.exports = Injector;
  19956. },{"68":68,"71":71}],71:[function(_dereq_,module,exports){
  19957. var Module = function() {
  19958. var providers = [];
  19959. this.factory = function(name, factory) {
  19960. providers.push([name, 'factory', factory]);
  19961. return this;
  19962. };
  19963. this.value = function(name, value) {
  19964. providers.push([name, 'value', value]);
  19965. return this;
  19966. };
  19967. this.type = function(name, type) {
  19968. providers.push([name, 'type', type]);
  19969. return this;
  19970. };
  19971. this.forEach = function(iterator) {
  19972. providers.forEach(iterator);
  19973. };
  19974. };
  19975. module.exports = Module;
  19976. },{}],72:[function(_dereq_,module,exports){
  19977. if (typeof Object.create === 'function') {
  19978. // implementation from standard node.js 'util' module
  19979. module.exports = function inherits(ctor, superCtor) {
  19980. ctor.super_ = superCtor
  19981. ctor.prototype = Object.create(superCtor.prototype, {
  19982. constructor: {
  19983. value: ctor,
  19984. enumerable: false,
  19985. writable: true,
  19986. configurable: true
  19987. }
  19988. });
  19989. };
  19990. } else {
  19991. // old school shim for old browsers
  19992. module.exports = function inherits(ctor, superCtor) {
  19993. ctor.super_ = superCtor
  19994. var TempCtor = function () {}
  19995. TempCtor.prototype = superCtor.prototype
  19996. ctor.prototype = new TempCtor()
  19997. ctor.prototype.constructor = ctor
  19998. }
  19999. }
  20000. },{}],73:[function(_dereq_,module,exports){
  20001. /**
  20002. * Gets the last element of `array`.
  20003. *
  20004. * @static
  20005. * @memberOf _
  20006. * @category Array
  20007. * @param {Array} array The array to query.
  20008. * @returns {*} Returns the last element of `array`.
  20009. * @example
  20010. *
  20011. * _.last([1, 2, 3]);
  20012. * // => 3
  20013. */
  20014. function last(array) {
  20015. var length = array ? array.length : 0;
  20016. return length ? array[length - 1] : undefined;
  20017. }
  20018. module.exports = last;
  20019. },{}],74:[function(_dereq_,module,exports){
  20020. var arrayEvery = _dereq_(90),
  20021. baseCallback = _dereq_(98),
  20022. baseEvery = _dereq_(103),
  20023. isArray = _dereq_(159),
  20024. isIterateeCall = _dereq_(148);
  20025. /**
  20026. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  20027. * The predicate is bound to `thisArg` and invoked with three arguments:
  20028. * (value, index|key, collection).
  20029. *
  20030. * If a property name is provided for `predicate` the created `_.property`
  20031. * style callback returns the property value of the given element.
  20032. *
  20033. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  20034. * style callback returns `true` for elements that have a matching property
  20035. * value, else `false`.
  20036. *
  20037. * If an object is provided for `predicate` the created `_.matches` style
  20038. * callback returns `true` for elements that have the properties of the given
  20039. * object, else `false`.
  20040. *
  20041. * @static
  20042. * @memberOf _
  20043. * @alias all
  20044. * @category Collection
  20045. * @param {Array|Object|string} collection The collection to iterate over.
  20046. * @param {Function|Object|string} [predicate=_.identity] The function invoked
  20047. * per iteration.
  20048. * @param {*} [thisArg] The `this` binding of `predicate`.
  20049. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  20050. * else `false`.
  20051. * @example
  20052. *
  20053. * _.every([true, 1, null, 'yes'], Boolean);
  20054. * // => false
  20055. *
  20056. * var users = [
  20057. * { 'user': 'barney', 'active': false },
  20058. * { 'user': 'fred', 'active': false }
  20059. * ];
  20060. *
  20061. * // using the `_.matches` callback shorthand
  20062. * _.every(users, { 'user': 'barney', 'active': false });
  20063. * // => false
  20064. *
  20065. * // using the `_.matchesProperty` callback shorthand
  20066. * _.every(users, 'active', false);
  20067. * // => true
  20068. *
  20069. * // using the `_.property` callback shorthand
  20070. * _.every(users, 'active');
  20071. * // => false
  20072. */
  20073. function every(collection, predicate, thisArg) {
  20074. var func = isArray(collection) ? arrayEvery : baseEvery;
  20075. if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
  20076. predicate = undefined;
  20077. }
  20078. if (typeof predicate != 'function' || thisArg !== undefined) {
  20079. predicate = baseCallback(predicate, thisArg, 3);
  20080. }
  20081. return func(collection, predicate);
  20082. }
  20083. module.exports = every;
  20084. },{"103":103,"148":148,"159":159,"90":90,"98":98}],75:[function(_dereq_,module,exports){
  20085. var arrayFilter = _dereq_(91),
  20086. baseCallback = _dereq_(98),
  20087. baseFilter = _dereq_(104),
  20088. isArray = _dereq_(159);
  20089. /**
  20090. * Iterates over elements of `collection`, returning an array of all elements
  20091. * `predicate` returns truthy for. The predicate is bound to `thisArg` and
  20092. * invoked with three arguments: (value, index|key, collection).
  20093. *
  20094. * If a property name is provided for `predicate` the created `_.property`
  20095. * style callback returns the property value of the given element.
  20096. *
  20097. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  20098. * style callback returns `true` for elements that have a matching property
  20099. * value, else `false`.
  20100. *
  20101. * If an object is provided for `predicate` the created `_.matches` style
  20102. * callback returns `true` for elements that have the properties of the given
  20103. * object, else `false`.
  20104. *
  20105. * @static
  20106. * @memberOf _
  20107. * @alias select
  20108. * @category Collection
  20109. * @param {Array|Object|string} collection The collection to iterate over.
  20110. * @param {Function|Object|string} [predicate=_.identity] The function invoked
  20111. * per iteration.
  20112. * @param {*} [thisArg] The `this` binding of `predicate`.
  20113. * @returns {Array} Returns the new filtered array.
  20114. * @example
  20115. *
  20116. * _.filter([4, 5, 6], function(n) {
  20117. * return n % 2 == 0;
  20118. * });
  20119. * // => [4, 6]
  20120. *
  20121. * var users = [
  20122. * { 'user': 'barney', 'age': 36, 'active': true },
  20123. * { 'user': 'fred', 'age': 40, 'active': false }
  20124. * ];
  20125. *
  20126. * // using the `_.matches` callback shorthand
  20127. * _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user');
  20128. * // => ['barney']
  20129. *
  20130. * // using the `_.matchesProperty` callback shorthand
  20131. * _.pluck(_.filter(users, 'active', false), 'user');
  20132. * // => ['fred']
  20133. *
  20134. * // using the `_.property` callback shorthand
  20135. * _.pluck(_.filter(users, 'active'), 'user');
  20136. * // => ['barney']
  20137. */
  20138. function filter(collection, predicate, thisArg) {
  20139. var func = isArray(collection) ? arrayFilter : baseFilter;
  20140. predicate = baseCallback(predicate, thisArg, 3);
  20141. return func(collection, predicate);
  20142. }
  20143. module.exports = filter;
  20144. },{"104":104,"159":159,"91":91,"98":98}],76:[function(_dereq_,module,exports){
  20145. var baseEach = _dereq_(102),
  20146. createFind = _dereq_(136);
  20147. /**
  20148. * Iterates over elements of `collection`, returning the first element
  20149. * `predicate` returns truthy for. The predicate is bound to `thisArg` and
  20150. * invoked with three arguments: (value, index|key, collection).
  20151. *
  20152. * If a property name is provided for `predicate` the created `_.property`
  20153. * style callback returns the property value of the given element.
  20154. *
  20155. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  20156. * style callback returns `true` for elements that have a matching property
  20157. * value, else `false`.
  20158. *
  20159. * If an object is provided for `predicate` the created `_.matches` style
  20160. * callback returns `true` for elements that have the properties of the given
  20161. * object, else `false`.
  20162. *
  20163. * @static
  20164. * @memberOf _
  20165. * @alias detect
  20166. * @category Collection
  20167. * @param {Array|Object|string} collection The collection to search.
  20168. * @param {Function|Object|string} [predicate=_.identity] The function invoked
  20169. * per iteration.
  20170. * @param {*} [thisArg] The `this` binding of `predicate`.
  20171. * @returns {*} Returns the matched element, else `undefined`.
  20172. * @example
  20173. *
  20174. * var users = [
  20175. * { 'user': 'barney', 'age': 36, 'active': true },
  20176. * { 'user': 'fred', 'age': 40, 'active': false },
  20177. * { 'user': 'pebbles', 'age': 1, 'active': true }
  20178. * ];
  20179. *
  20180. * _.result(_.find(users, function(chr) {
  20181. * return chr.age < 40;
  20182. * }), 'user');
  20183. * // => 'barney'
  20184. *
  20185. * // using the `_.matches` callback shorthand
  20186. * _.result(_.find(users, { 'age': 1, 'active': true }), 'user');
  20187. * // => 'pebbles'
  20188. *
  20189. * // using the `_.matchesProperty` callback shorthand
  20190. * _.result(_.find(users, 'active', false), 'user');
  20191. * // => 'fred'
  20192. *
  20193. * // using the `_.property` callback shorthand
  20194. * _.result(_.find(users, 'active'), 'user');
  20195. * // => 'barney'
  20196. */
  20197. var find = createFind(baseEach);
  20198. module.exports = find;
  20199. },{"102":102,"136":136}],77:[function(_dereq_,module,exports){
  20200. var arrayEach = _dereq_(89),
  20201. baseEach = _dereq_(102),
  20202. createForEach = _dereq_(137);
  20203. /**
  20204. * Iterates over elements of `collection` invoking `iteratee` for each element.
  20205. * The `iteratee` is bound to `thisArg` and invoked with three arguments:
  20206. * (value, index|key, collection). Iteratee functions may exit iteration early
  20207. * by explicitly returning `false`.
  20208. *
  20209. * **Note:** As with other "Collections" methods, objects with a "length" property
  20210. * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`
  20211. * may be used for object iteration.
  20212. *
  20213. * @static
  20214. * @memberOf _
  20215. * @alias each
  20216. * @category Collection
  20217. * @param {Array|Object|string} collection The collection to iterate over.
  20218. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  20219. * @param {*} [thisArg] The `this` binding of `iteratee`.
  20220. * @returns {Array|Object|string} Returns `collection`.
  20221. * @example
  20222. *
  20223. * _([1, 2]).forEach(function(n) {
  20224. * console.log(n);
  20225. * }).value();
  20226. * // => logs each value from left to right and returns the array
  20227. *
  20228. * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) {
  20229. * console.log(n, key);
  20230. * });
  20231. * // => logs each value-key pair and returns the object (iteration order is not guaranteed)
  20232. */
  20233. var forEach = createForEach(arrayEach, baseEach);
  20234. module.exports = forEach;
  20235. },{"102":102,"137":137,"89":89}],78:[function(_dereq_,module,exports){
  20236. var createAggregator = _dereq_(131);
  20237. /** Used for native method references. */
  20238. var objectProto = Object.prototype;
  20239. /** Used to check objects for own properties. */
  20240. var hasOwnProperty = objectProto.hasOwnProperty;
  20241. /**
  20242. * Creates an object composed of keys generated from the results of running
  20243. * each element of `collection` through `iteratee`. The corresponding value
  20244. * of each key is an array of the elements responsible for generating the key.
  20245. * The `iteratee` is bound to `thisArg` and invoked with three arguments:
  20246. * (value, index|key, collection).
  20247. *
  20248. * If a property name is provided for `iteratee` the created `_.property`
  20249. * style callback returns the property value of the given element.
  20250. *
  20251. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  20252. * style callback returns `true` for elements that have a matching property
  20253. * value, else `false`.
  20254. *
  20255. * If an object is provided for `iteratee` the created `_.matches` style
  20256. * callback returns `true` for elements that have the properties of the given
  20257. * object, else `false`.
  20258. *
  20259. * @static
  20260. * @memberOf _
  20261. * @category Collection
  20262. * @param {Array|Object|string} collection The collection to iterate over.
  20263. * @param {Function|Object|string} [iteratee=_.identity] The function invoked
  20264. * per iteration.
  20265. * @param {*} [thisArg] The `this` binding of `iteratee`.
  20266. * @returns {Object} Returns the composed aggregate object.
  20267. * @example
  20268. *
  20269. * _.groupBy([4.2, 6.1, 6.4], function(n) {
  20270. * return Math.floor(n);
  20271. * });
  20272. * // => { '4': [4.2], '6': [6.1, 6.4] }
  20273. *
  20274. * _.groupBy([4.2, 6.1, 6.4], function(n) {
  20275. * return this.floor(n);
  20276. * }, Math);
  20277. * // => { '4': [4.2], '6': [6.1, 6.4] }
  20278. *
  20279. * // using the `_.property` callback shorthand
  20280. * _.groupBy(['one', 'two', 'three'], 'length');
  20281. * // => { '3': ['one', 'two'], '5': ['three'] }
  20282. */
  20283. var groupBy = createAggregator(function(result, value, key) {
  20284. if (hasOwnProperty.call(result, key)) {
  20285. result[key].push(value);
  20286. } else {
  20287. result[key] = [value];
  20288. }
  20289. });
  20290. module.exports = groupBy;
  20291. },{"131":131}],79:[function(_dereq_,module,exports){
  20292. var baseIndexOf = _dereq_(112),
  20293. getLength = _dereq_(142),
  20294. isArray = _dereq_(159),
  20295. isIterateeCall = _dereq_(148),
  20296. isLength = _dereq_(150),
  20297. isString = _dereq_(165),
  20298. values = _dereq_(175);
  20299. /* Native method references for those with the same name as other `lodash` methods. */
  20300. var nativeMax = Math.max;
  20301. /**
  20302. * Checks if `target` is in `collection` using
  20303. * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
  20304. * for equality comparisons. If `fromIndex` is negative, it's used as the offset
  20305. * from the end of `collection`.
  20306. *
  20307. * @static
  20308. * @memberOf _
  20309. * @alias contains, include
  20310. * @category Collection
  20311. * @param {Array|Object|string} collection The collection to search.
  20312. * @param {*} target The value to search for.
  20313. * @param {number} [fromIndex=0] The index to search from.
  20314. * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
  20315. * @returns {boolean} Returns `true` if a matching element is found, else `false`.
  20316. * @example
  20317. *
  20318. * _.includes([1, 2, 3], 1);
  20319. * // => true
  20320. *
  20321. * _.includes([1, 2, 3], 1, 2);
  20322. * // => false
  20323. *
  20324. * _.includes({ 'user': 'fred', 'age': 40 }, 'fred');
  20325. * // => true
  20326. *
  20327. * _.includes('pebbles', 'eb');
  20328. * // => true
  20329. */
  20330. function includes(collection, target, fromIndex, guard) {
  20331. var length = collection ? getLength(collection) : 0;
  20332. if (!isLength(length)) {
  20333. collection = values(collection);
  20334. length = collection.length;
  20335. }
  20336. if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
  20337. fromIndex = 0;
  20338. } else {
  20339. fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
  20340. }
  20341. return (typeof collection == 'string' || !isArray(collection) && isString(collection))
  20342. ? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1)
  20343. : (!!length && baseIndexOf(collection, target, fromIndex) > -1);
  20344. }
  20345. module.exports = includes;
  20346. },{"112":112,"142":142,"148":148,"150":150,"159":159,"165":165,"175":175}],80:[function(_dereq_,module,exports){
  20347. var arrayMap = _dereq_(92),
  20348. baseCallback = _dereq_(98),
  20349. baseMap = _dereq_(116),
  20350. isArray = _dereq_(159);
  20351. /**
  20352. * Creates an array of values by running each element in `collection` through
  20353. * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three
  20354. * arguments: (value, index|key, collection).
  20355. *
  20356. * If a property name is provided for `iteratee` the created `_.property`
  20357. * style callback returns the property value of the given element.
  20358. *
  20359. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  20360. * style callback returns `true` for elements that have a matching property
  20361. * value, else `false`.
  20362. *
  20363. * If an object is provided for `iteratee` the created `_.matches` style
  20364. * callback returns `true` for elements that have the properties of the given
  20365. * object, else `false`.
  20366. *
  20367. * Many lodash methods are guarded to work as iteratees for methods like
  20368. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  20369. *
  20370. * The guarded methods are:
  20371. * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`,
  20372. * `drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`,
  20373. * `parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`,
  20374. * `trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`,
  20375. * `sum`, `uniq`, and `words`
  20376. *
  20377. * @static
  20378. * @memberOf _
  20379. * @alias collect
  20380. * @category Collection
  20381. * @param {Array|Object|string} collection The collection to iterate over.
  20382. * @param {Function|Object|string} [iteratee=_.identity] The function invoked
  20383. * per iteration.
  20384. * @param {*} [thisArg] The `this` binding of `iteratee`.
  20385. * @returns {Array} Returns the new mapped array.
  20386. * @example
  20387. *
  20388. * function timesThree(n) {
  20389. * return n * 3;
  20390. * }
  20391. *
  20392. * _.map([1, 2], timesThree);
  20393. * // => [3, 6]
  20394. *
  20395. * _.map({ 'a': 1, 'b': 2 }, timesThree);
  20396. * // => [3, 6] (iteration order is not guaranteed)
  20397. *
  20398. * var users = [
  20399. * { 'user': 'barney' },
  20400. * { 'user': 'fred' }
  20401. * ];
  20402. *
  20403. * // using the `_.property` callback shorthand
  20404. * _.map(users, 'user');
  20405. * // => ['barney', 'fred']
  20406. */
  20407. function map(collection, iteratee, thisArg) {
  20408. var func = isArray(collection) ? arrayMap : baseMap;
  20409. iteratee = baseCallback(iteratee, thisArg, 3);
  20410. return func(collection, iteratee);
  20411. }
  20412. module.exports = map;
  20413. },{"116":116,"159":159,"92":92,"98":98}],81:[function(_dereq_,module,exports){
  20414. var arrayReduce = _dereq_(94),
  20415. baseEach = _dereq_(102),
  20416. createReduce = _dereq_(138);
  20417. /**
  20418. * Reduces `collection` to a value which is the accumulated result of running
  20419. * each element in `collection` through `iteratee`, where each successive
  20420. * invocation is supplied the return value of the previous. If `accumulator`
  20421. * is not provided the first element of `collection` is used as the initial
  20422. * value. The `iteratee` is bound to `thisArg` and invoked with four arguments:
  20423. * (accumulator, value, index|key, collection).
  20424. *
  20425. * Many lodash methods are guarded to work as iteratees for methods like
  20426. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  20427. *
  20428. * The guarded methods are:
  20429. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `sortByAll`,
  20430. * and `sortByOrder`
  20431. *
  20432. * @static
  20433. * @memberOf _
  20434. * @alias foldl, inject
  20435. * @category Collection
  20436. * @param {Array|Object|string} collection The collection to iterate over.
  20437. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  20438. * @param {*} [accumulator] The initial value.
  20439. * @param {*} [thisArg] The `this` binding of `iteratee`.
  20440. * @returns {*} Returns the accumulated value.
  20441. * @example
  20442. *
  20443. * _.reduce([1, 2], function(total, n) {
  20444. * return total + n;
  20445. * });
  20446. * // => 3
  20447. *
  20448. * _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) {
  20449. * result[key] = n * 3;
  20450. * return result;
  20451. * }, {});
  20452. * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed)
  20453. */
  20454. var reduce = createReduce(arrayReduce, baseEach);
  20455. module.exports = reduce;
  20456. },{"102":102,"138":138,"94":94}],82:[function(_dereq_,module,exports){
  20457. var arraySome = _dereq_(95),
  20458. baseCallback = _dereq_(98),
  20459. baseSome = _dereq_(125),
  20460. isArray = _dereq_(159),
  20461. isIterateeCall = _dereq_(148);
  20462. /**
  20463. * Checks if `predicate` returns truthy for **any** element of `collection`.
  20464. * The function returns as soon as it finds a passing value and does not iterate
  20465. * over the entire collection. The predicate is bound to `thisArg` and invoked
  20466. * with three arguments: (value, index|key, collection).
  20467. *
  20468. * If a property name is provided for `predicate` the created `_.property`
  20469. * style callback returns the property value of the given element.
  20470. *
  20471. * If a value is also provided for `thisArg` the created `_.matchesProperty`
  20472. * style callback returns `true` for elements that have a matching property
  20473. * value, else `false`.
  20474. *
  20475. * If an object is provided for `predicate` the created `_.matches` style
  20476. * callback returns `true` for elements that have the properties of the given
  20477. * object, else `false`.
  20478. *
  20479. * @static
  20480. * @memberOf _
  20481. * @alias any
  20482. * @category Collection
  20483. * @param {Array|Object|string} collection The collection to iterate over.
  20484. * @param {Function|Object|string} [predicate=_.identity] The function invoked
  20485. * per iteration.
  20486. * @param {*} [thisArg] The `this` binding of `predicate`.
  20487. * @returns {boolean} Returns `true` if any element passes the predicate check,
  20488. * else `false`.
  20489. * @example
  20490. *
  20491. * _.some([null, 0, 'yes', false], Boolean);
  20492. * // => true
  20493. *
  20494. * var users = [
  20495. * { 'user': 'barney', 'active': true },
  20496. * { 'user': 'fred', 'active': false }
  20497. * ];
  20498. *
  20499. * // using the `_.matches` callback shorthand
  20500. * _.some(users, { 'user': 'barney', 'active': false });
  20501. * // => false
  20502. *
  20503. * // using the `_.matchesProperty` callback shorthand
  20504. * _.some(users, 'active', false);
  20505. * // => true
  20506. *
  20507. * // using the `_.property` callback shorthand
  20508. * _.some(users, 'active');
  20509. * // => true
  20510. */
  20511. function some(collection, predicate, thisArg) {
  20512. var func = isArray(collection) ? arraySome : baseSome;
  20513. if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
  20514. predicate = undefined;
  20515. }
  20516. if (typeof predicate != 'function' || thisArg !== undefined) {
  20517. predicate = baseCallback(predicate, thisArg, 3);
  20518. }
  20519. return func(collection, predicate);
  20520. }
  20521. module.exports = some;
  20522. },{"125":125,"148":148,"159":159,"95":95,"98":98}],83:[function(_dereq_,module,exports){
  20523. var getNative = _dereq_(144);
  20524. /* Native method references for those with the same name as other `lodash` methods. */
  20525. var nativeNow = getNative(Date, 'now');
  20526. /**
  20527. * Gets the number of milliseconds that have elapsed since the Unix epoch
  20528. * (1 January 1970 00:00:00 UTC).
  20529. *
  20530. * @static
  20531. * @memberOf _
  20532. * @category Date
  20533. * @example
  20534. *
  20535. * _.defer(function(stamp) {
  20536. * console.log(_.now() - stamp);
  20537. * }, _.now());
  20538. * // => logs the number of milliseconds it took for the deferred function to be invoked
  20539. */
  20540. var now = nativeNow || function() {
  20541. return new Date().getTime();
  20542. };
  20543. module.exports = now;
  20544. },{"144":144}],84:[function(_dereq_,module,exports){
  20545. var isObject = _dereq_(163),
  20546. now = _dereq_(83);
  20547. /** Used as the `TypeError` message for "Functions" methods. */
  20548. var FUNC_ERROR_TEXT = 'Expected a function';
  20549. /* Native method references for those with the same name as other `lodash` methods. */
  20550. var nativeMax = Math.max;
  20551. /**
  20552. * Creates a debounced function that delays invoking `func` until after `wait`
  20553. * milliseconds have elapsed since the last time the debounced function was
  20554. * invoked. The debounced function comes with a `cancel` method to cancel
  20555. * delayed invocations. Provide an options object to indicate that `func`
  20556. * should be invoked on the leading and/or trailing edge of the `wait` timeout.
  20557. * Subsequent calls to the debounced function return the result of the last
  20558. * `func` invocation.
  20559. *
  20560. * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
  20561. * on the trailing edge of the timeout only if the the debounced function is
  20562. * invoked more than once during the `wait` timeout.
  20563. *
  20564. * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
  20565. * for details over the differences between `_.debounce` and `_.throttle`.
  20566. *
  20567. * @static
  20568. * @memberOf _
  20569. * @category Function
  20570. * @param {Function} func The function to debounce.
  20571. * @param {number} [wait=0] The number of milliseconds to delay.
  20572. * @param {Object} [options] The options object.
  20573. * @param {boolean} [options.leading=false] Specify invoking on the leading
  20574. * edge of the timeout.
  20575. * @param {number} [options.maxWait] The maximum time `func` is allowed to be
  20576. * delayed before it's invoked.
  20577. * @param {boolean} [options.trailing=true] Specify invoking on the trailing
  20578. * edge of the timeout.
  20579. * @returns {Function} Returns the new debounced function.
  20580. * @example
  20581. *
  20582. * // avoid costly calculations while the window size is in flux
  20583. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  20584. *
  20585. * // invoke `sendMail` when the click event is fired, debouncing subsequent calls
  20586. * jQuery('#postbox').on('click', _.debounce(sendMail, 300, {
  20587. * 'leading': true,
  20588. * 'trailing': false
  20589. * }));
  20590. *
  20591. * // ensure `batchLog` is invoked once after 1 second of debounced calls
  20592. * var source = new EventSource('/stream');
  20593. * jQuery(source).on('message', _.debounce(batchLog, 250, {
  20594. * 'maxWait': 1000
  20595. * }));
  20596. *
  20597. * // cancel a debounced call
  20598. * var todoChanges = _.debounce(batchLog, 1000);
  20599. * Object.observe(models.todo, todoChanges);
  20600. *
  20601. * Object.observe(models, function(changes) {
  20602. * if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) {
  20603. * todoChanges.cancel();
  20604. * }
  20605. * }, ['delete']);
  20606. *
  20607. * // ...at some point `models.todo` is changed
  20608. * models.todo.completed = true;
  20609. *
  20610. * // ...before 1 second has passed `models.todo` is deleted
  20611. * // which cancels the debounced `todoChanges` call
  20612. * delete models.todo;
  20613. */
  20614. function debounce(func, wait, options) {
  20615. var args,
  20616. maxTimeoutId,
  20617. result,
  20618. stamp,
  20619. thisArg,
  20620. timeoutId,
  20621. trailingCall,
  20622. lastCalled = 0,
  20623. maxWait = false,
  20624. trailing = true;
  20625. if (typeof func != 'function') {
  20626. throw new TypeError(FUNC_ERROR_TEXT);
  20627. }
  20628. wait = wait < 0 ? 0 : (+wait || 0);
  20629. if (options === true) {
  20630. var leading = true;
  20631. trailing = false;
  20632. } else if (isObject(options)) {
  20633. leading = !!options.leading;
  20634. maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait);
  20635. trailing = 'trailing' in options ? !!options.trailing : trailing;
  20636. }
  20637. function cancel() {
  20638. if (timeoutId) {
  20639. clearTimeout(timeoutId);
  20640. }
  20641. if (maxTimeoutId) {
  20642. clearTimeout(maxTimeoutId);
  20643. }
  20644. lastCalled = 0;
  20645. maxTimeoutId = timeoutId = trailingCall = undefined;
  20646. }
  20647. function complete(isCalled, id) {
  20648. if (id) {
  20649. clearTimeout(id);
  20650. }
  20651. maxTimeoutId = timeoutId = trailingCall = undefined;
  20652. if (isCalled) {
  20653. lastCalled = now();
  20654. result = func.apply(thisArg, args);
  20655. if (!timeoutId && !maxTimeoutId) {
  20656. args = thisArg = undefined;
  20657. }
  20658. }
  20659. }
  20660. function delayed() {
  20661. var remaining = wait - (now() - stamp);
  20662. if (remaining <= 0 || remaining > wait) {
  20663. complete(trailingCall, maxTimeoutId);
  20664. } else {
  20665. timeoutId = setTimeout(delayed, remaining);
  20666. }
  20667. }
  20668. function maxDelayed() {
  20669. complete(trailing, timeoutId);
  20670. }
  20671. function debounced() {
  20672. args = arguments;
  20673. stamp = now();
  20674. thisArg = this;
  20675. trailingCall = trailing && (timeoutId || !leading);
  20676. if (maxWait === false) {
  20677. var leadingCall = leading && !timeoutId;
  20678. } else {
  20679. if (!maxTimeoutId && !leading) {
  20680. lastCalled = stamp;
  20681. }
  20682. var remaining = maxWait - (stamp - lastCalled),
  20683. isCalled = remaining <= 0 || remaining > maxWait;
  20684. if (isCalled) {
  20685. if (maxTimeoutId) {
  20686. maxTimeoutId = clearTimeout(maxTimeoutId);
  20687. }
  20688. lastCalled = stamp;
  20689. result = func.apply(thisArg, args);
  20690. }
  20691. else if (!maxTimeoutId) {
  20692. maxTimeoutId = setTimeout(maxDelayed, remaining);
  20693. }
  20694. }
  20695. if (isCalled && timeoutId) {
  20696. timeoutId = clearTimeout(timeoutId);
  20697. }
  20698. else if (!timeoutId && wait !== maxWait) {
  20699. timeoutId = setTimeout(delayed, wait);
  20700. }
  20701. if (leadingCall) {
  20702. isCalled = true;
  20703. result = func.apply(thisArg, args);
  20704. }
  20705. if (isCalled && !timeoutId && !maxTimeoutId) {
  20706. args = thisArg = undefined;
  20707. }
  20708. return result;
  20709. }
  20710. debounced.cancel = cancel;
  20711. return debounced;
  20712. }
  20713. module.exports = debounce;
  20714. },{"163":163,"83":83}],85:[function(_dereq_,module,exports){
  20715. var baseDelay = _dereq_(100),
  20716. restParam = _dereq_(86);
  20717. /**
  20718. * Defers invoking the `func` until the current call stack has cleared. Any
  20719. * additional arguments are provided to `func` when it's invoked.
  20720. *
  20721. * @static
  20722. * @memberOf _
  20723. * @category Function
  20724. * @param {Function} func The function to defer.
  20725. * @param {...*} [args] The arguments to invoke the function with.
  20726. * @returns {number} Returns the timer id.
  20727. * @example
  20728. *
  20729. * _.defer(function(text) {
  20730. * console.log(text);
  20731. * }, 'deferred');
  20732. * // logs 'deferred' after one or more milliseconds
  20733. */
  20734. var defer = restParam(function(func, args) {
  20735. return baseDelay(func, 1, args);
  20736. });
  20737. module.exports = defer;
  20738. },{"100":100,"86":86}],86:[function(_dereq_,module,exports){
  20739. /** Used as the `TypeError` message for "Functions" methods. */
  20740. var FUNC_ERROR_TEXT = 'Expected a function';
  20741. /* Native method references for those with the same name as other `lodash` methods. */
  20742. var nativeMax = Math.max;
  20743. /**
  20744. * Creates a function that invokes `func` with the `this` binding of the
  20745. * created function and arguments from `start` and beyond provided as an array.
  20746. *
  20747. * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters).
  20748. *
  20749. * @static
  20750. * @memberOf _
  20751. * @category Function
  20752. * @param {Function} func The function to apply a rest parameter to.
  20753. * @param {number} [start=func.length-1] The start position of the rest parameter.
  20754. * @returns {Function} Returns the new function.
  20755. * @example
  20756. *
  20757. * var say = _.restParam(function(what, names) {
  20758. * return what + ' ' + _.initial(names).join(', ') +
  20759. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  20760. * });
  20761. *
  20762. * say('hello', 'fred', 'barney', 'pebbles');
  20763. * // => 'hello fred, barney, & pebbles'
  20764. */
  20765. function restParam(func, start) {
  20766. if (typeof func != 'function') {
  20767. throw new TypeError(FUNC_ERROR_TEXT);
  20768. }
  20769. start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
  20770. return function() {
  20771. var args = arguments,
  20772. index = -1,
  20773. length = nativeMax(args.length - start, 0),
  20774. rest = Array(length);
  20775. while (++index < length) {
  20776. rest[index] = args[start + index];
  20777. }
  20778. switch (start) {
  20779. case 0: return func.call(this, rest);
  20780. case 1: return func.call(this, args[0], rest);
  20781. case 2: return func.call(this, args[0], args[1], rest);
  20782. }
  20783. var otherArgs = Array(start + 1);
  20784. index = -1;
  20785. while (++index < start) {
  20786. otherArgs[index] = args[index];
  20787. }
  20788. otherArgs[start] = rest;
  20789. return func.apply(this, otherArgs);
  20790. };
  20791. }
  20792. module.exports = restParam;
  20793. },{}],87:[function(_dereq_,module,exports){
  20794. (function (global){
  20795. var cachePush = _dereq_(130),
  20796. getNative = _dereq_(144);
  20797. /** Native method references. */
  20798. var Set = getNative(global, 'Set');
  20799. /* Native method references for those with the same name as other `lodash` methods. */
  20800. var nativeCreate = getNative(Object, 'create');
  20801. /**
  20802. *
  20803. * Creates a cache object to store unique values.
  20804. *
  20805. * @private
  20806. * @param {Array} [values] The values to cache.
  20807. */
  20808. function SetCache(values) {
  20809. var length = values ? values.length : 0;
  20810. this.data = { 'hash': nativeCreate(null), 'set': new Set };
  20811. while (length--) {
  20812. this.push(values[length]);
  20813. }
  20814. }
  20815. // Add functions to the `Set` cache.
  20816. SetCache.prototype.push = cachePush;
  20817. module.exports = SetCache;
  20818. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  20819. //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaW50ZXJuYWwvU2V0Q2FjaGUuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsImZpbGUiOiJnZW5lcmF0ZWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc0NvbnRlbnQiOlsidmFyIGNhY2hlUHVzaCA9IHJlcXVpcmUoJy4vY2FjaGVQdXNoJyksXG4gICAgZ2V0TmF0aXZlID0gcmVxdWlyZSgnLi9nZXROYXRpdmUnKTtcblxuLyoqIE5hdGl2ZSBtZXRob2QgcmVmZXJlbmNlcy4gKi9cbnZhciBTZXQgPSBnZXROYXRpdmUoZ2xvYmFsLCAnU2V0Jyk7XG5cbi8qIE5hdGl2ZSBtZXRob2QgcmVmZXJlbmNlcyBmb3IgdGhvc2Ugd2l0aCB0aGUgc2FtZSBuYW1lIGFzIG90aGVyIGBsb2Rhc2hgIG1ldGhvZHMuICovXG52YXIgbmF0aXZlQ3JlYXRlID0gZ2V0TmF0aXZlKE9iamVjdCwgJ2NyZWF0ZScpO1xuXG4vKipcbiAqXG4gKiBDcmVhdGVzIGEgY2FjaGUgb2JqZWN0IHRvIHN0b3JlIHVuaXF1ZSB2YWx1ZXMuXG4gKlxuICogQHByaXZhdGVcbiAqIEBwYXJhbSB7QXJyYXl9IFt2YWx1ZXNdIFRoZSB2YWx1ZXMgdG8gY2FjaGUuXG4gKi9cbmZ1bmN0aW9uIFNldENhY2hlKHZhbHVlcykge1xuICB2YXIgbGVuZ3RoID0gdmFsdWVzID8gdmFsdWVzLmxlbmd0aCA6IDA7XG5cbiAgdGhpcy5kYXRhID0geyAnaGFzaCc6IG5hdGl2ZUNyZWF0ZShudWxsKSwgJ3NldCc6IG5ldyBTZXQgfTtcbiAgd2hpbGUgKGxlbmd0aC0tKSB7XG4gICAgdGhpcy5wdXNoKHZhbHVlc1tsZW5ndGhdKTtcbiAgfVxufVxuXG4vLyBBZGQgZnVuY3Rpb25zIHRvIHRoZSBgU2V0YCBjYWNoZS5cblNldENhY2hlLnByb3RvdHlwZS5wdXNoID0gY2FjaGVQdXNoO1xuXG5tb2R1bGUuZXhwb3J0cyA9IFNldENhY2hlO1xuIl19
  20820. },{"130":130,"144":144}],88:[function(_dereq_,module,exports){
  20821. /**
  20822. * Copies the values of `source` to `array`.
  20823. *
  20824. * @private
  20825. * @param {Array} source The array to copy values from.
  20826. * @param {Array} [array=[]] The array to copy values to.
  20827. * @returns {Array} Returns `array`.
  20828. */
  20829. function arrayCopy(source, array) {
  20830. var index = -1,
  20831. length = source.length;
  20832. array || (array = Array(length));
  20833. while (++index < length) {
  20834. array[index] = source[index];
  20835. }
  20836. return array;
  20837. }
  20838. module.exports = arrayCopy;
  20839. },{}],89:[function(_dereq_,module,exports){
  20840. /**
  20841. * A specialized version of `_.forEach` for arrays without support for callback
  20842. * shorthands and `this` binding.
  20843. *
  20844. * @private
  20845. * @param {Array} array The array to iterate over.
  20846. * @param {Function} iteratee The function invoked per iteration.
  20847. * @returns {Array} Returns `array`.
  20848. */
  20849. function arrayEach(array, iteratee) {
  20850. var index = -1,
  20851. length = array.length;
  20852. while (++index < length) {
  20853. if (iteratee(array[index], index, array) === false) {
  20854. break;
  20855. }
  20856. }
  20857. return array;
  20858. }
  20859. module.exports = arrayEach;
  20860. },{}],90:[function(_dereq_,module,exports){
  20861. /**
  20862. * A specialized version of `_.every` for arrays without support for callback
  20863. * shorthands and `this` binding.
  20864. *
  20865. * @private
  20866. * @param {Array} array The array to iterate over.
  20867. * @param {Function} predicate The function invoked per iteration.
  20868. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  20869. * else `false`.
  20870. */
  20871. function arrayEvery(array, predicate) {
  20872. var index = -1,
  20873. length = array.length;
  20874. while (++index < length) {
  20875. if (!predicate(array[index], index, array)) {
  20876. return false;
  20877. }
  20878. }
  20879. return true;
  20880. }
  20881. module.exports = arrayEvery;
  20882. },{}],91:[function(_dereq_,module,exports){
  20883. /**
  20884. * A specialized version of `_.filter` for arrays without support for callback
  20885. * shorthands and `this` binding.
  20886. *
  20887. * @private
  20888. * @param {Array} array The array to iterate over.
  20889. * @param {Function} predicate The function invoked per iteration.
  20890. * @returns {Array} Returns the new filtered array.
  20891. */
  20892. function arrayFilter(array, predicate) {
  20893. var index = -1,
  20894. length = array.length,
  20895. resIndex = -1,
  20896. result = [];
  20897. while (++index < length) {
  20898. var value = array[index];
  20899. if (predicate(value, index, array)) {
  20900. result[++resIndex] = value;
  20901. }
  20902. }
  20903. return result;
  20904. }
  20905. module.exports = arrayFilter;
  20906. },{}],92:[function(_dereq_,module,exports){
  20907. /**
  20908. * A specialized version of `_.map` for arrays without support for callback
  20909. * shorthands and `this` binding.
  20910. *
  20911. * @private
  20912. * @param {Array} array The array to iterate over.
  20913. * @param {Function} iteratee The function invoked per iteration.
  20914. * @returns {Array} Returns the new mapped array.
  20915. */
  20916. function arrayMap(array, iteratee) {
  20917. var index = -1,
  20918. length = array.length,
  20919. result = Array(length);
  20920. while (++index < length) {
  20921. result[index] = iteratee(array[index], index, array);
  20922. }
  20923. return result;
  20924. }
  20925. module.exports = arrayMap;
  20926. },{}],93:[function(_dereq_,module,exports){
  20927. /**
  20928. * Appends the elements of `values` to `array`.
  20929. *
  20930. * @private
  20931. * @param {Array} array The array to modify.
  20932. * @param {Array} values The values to append.
  20933. * @returns {Array} Returns `array`.
  20934. */
  20935. function arrayPush(array, values) {
  20936. var index = -1,
  20937. length = values.length,
  20938. offset = array.length;
  20939. while (++index < length) {
  20940. array[offset + index] = values[index];
  20941. }
  20942. return array;
  20943. }
  20944. module.exports = arrayPush;
  20945. },{}],94:[function(_dereq_,module,exports){
  20946. /**
  20947. * A specialized version of `_.reduce` for arrays without support for callback
  20948. * shorthands and `this` binding.
  20949. *
  20950. * @private
  20951. * @param {Array} array The array to iterate over.
  20952. * @param {Function} iteratee The function invoked per iteration.
  20953. * @param {*} [accumulator] The initial value.
  20954. * @param {boolean} [initFromArray] Specify using the first element of `array`
  20955. * as the initial value.
  20956. * @returns {*} Returns the accumulated value.
  20957. */
  20958. function arrayReduce(array, iteratee, accumulator, initFromArray) {
  20959. var index = -1,
  20960. length = array.length;
  20961. if (initFromArray && length) {
  20962. accumulator = array[++index];
  20963. }
  20964. while (++index < length) {
  20965. accumulator = iteratee(accumulator, array[index], index, array);
  20966. }
  20967. return accumulator;
  20968. }
  20969. module.exports = arrayReduce;
  20970. },{}],95:[function(_dereq_,module,exports){
  20971. /**
  20972. * A specialized version of `_.some` for arrays without support for callback
  20973. * shorthands and `this` binding.
  20974. *
  20975. * @private
  20976. * @param {Array} array The array to iterate over.
  20977. * @param {Function} predicate The function invoked per iteration.
  20978. * @returns {boolean} Returns `true` if any element passes the predicate check,
  20979. * else `false`.
  20980. */
  20981. function arraySome(array, predicate) {
  20982. var index = -1,
  20983. length = array.length;
  20984. while (++index < length) {
  20985. if (predicate(array[index], index, array)) {
  20986. return true;
  20987. }
  20988. }
  20989. return false;
  20990. }
  20991. module.exports = arraySome;
  20992. },{}],96:[function(_dereq_,module,exports){
  20993. var keys = _dereq_(169);
  20994. /**
  20995. * A specialized version of `_.assign` for customizing assigned values without
  20996. * support for argument juggling, multiple sources, and `this` binding `customizer`
  20997. * functions.
  20998. *
  20999. * @private
  21000. * @param {Object} object The destination object.
  21001. * @param {Object} source The source object.
  21002. * @param {Function} customizer The function to customize assigned values.
  21003. * @returns {Object} Returns `object`.
  21004. */
  21005. function assignWith(object, source, customizer) {
  21006. var index = -1,
  21007. props = keys(source),
  21008. length = props.length;
  21009. while (++index < length) {
  21010. var key = props[index],
  21011. value = object[key],
  21012. result = customizer(value, source[key], key, object, source);
  21013. if ((result === result ? (result !== value) : (value === value)) ||
  21014. (value === undefined && !(key in object))) {
  21015. object[key] = result;
  21016. }
  21017. }
  21018. return object;
  21019. }
  21020. module.exports = assignWith;
  21021. },{"169":169}],97:[function(_dereq_,module,exports){
  21022. var baseCopy = _dereq_(99),
  21023. keys = _dereq_(169);
  21024. /**
  21025. * The base implementation of `_.assign` without support for argument juggling,
  21026. * multiple sources, and `customizer` functions.
  21027. *
  21028. * @private
  21029. * @param {Object} object The destination object.
  21030. * @param {Object} source The source object.
  21031. * @returns {Object} Returns `object`.
  21032. */
  21033. function baseAssign(object, source) {
  21034. return source == null
  21035. ? object
  21036. : baseCopy(source, keys(source), object);
  21037. }
  21038. module.exports = baseAssign;
  21039. },{"169":169,"99":99}],98:[function(_dereq_,module,exports){
  21040. var baseMatches = _dereq_(117),
  21041. baseMatchesProperty = _dereq_(118),
  21042. bindCallback = _dereq_(128),
  21043. identity = _dereq_(176),
  21044. property = _dereq_(177);
  21045. /**
  21046. * The base implementation of `_.callback` which supports specifying the
  21047. * number of arguments to provide to `func`.
  21048. *
  21049. * @private
  21050. * @param {*} [func=_.identity] The value to convert to a callback.
  21051. * @param {*} [thisArg] The `this` binding of `func`.
  21052. * @param {number} [argCount] The number of arguments to provide to `func`.
  21053. * @returns {Function} Returns the callback.
  21054. */
  21055. function baseCallback(func, thisArg, argCount) {
  21056. var type = typeof func;
  21057. if (type == 'function') {
  21058. return thisArg === undefined
  21059. ? func
  21060. : bindCallback(func, thisArg, argCount);
  21061. }
  21062. if (func == null) {
  21063. return identity;
  21064. }
  21065. if (type == 'object') {
  21066. return baseMatches(func);
  21067. }
  21068. return thisArg === undefined
  21069. ? property(func)
  21070. : baseMatchesProperty(func, thisArg);
  21071. }
  21072. module.exports = baseCallback;
  21073. },{"117":117,"118":118,"128":128,"176":176,"177":177}],99:[function(_dereq_,module,exports){
  21074. /**
  21075. * Copies properties of `source` to `object`.
  21076. *
  21077. * @private
  21078. * @param {Object} source The object to copy properties from.
  21079. * @param {Array} props The property names to copy.
  21080. * @param {Object} [object={}] The object to copy properties to.
  21081. * @returns {Object} Returns `object`.
  21082. */
  21083. function baseCopy(source, props, object) {
  21084. object || (object = {});
  21085. var index = -1,
  21086. length = props.length;
  21087. while (++index < length) {
  21088. var key = props[index];
  21089. object[key] = source[key];
  21090. }
  21091. return object;
  21092. }
  21093. module.exports = baseCopy;
  21094. },{}],100:[function(_dereq_,module,exports){
  21095. /** Used as the `TypeError` message for "Functions" methods. */
  21096. var FUNC_ERROR_TEXT = 'Expected a function';
  21097. /**
  21098. * The base implementation of `_.delay` and `_.defer` which accepts an index
  21099. * of where to slice the arguments to provide to `func`.
  21100. *
  21101. * @private
  21102. * @param {Function} func The function to delay.
  21103. * @param {number} wait The number of milliseconds to delay invocation.
  21104. * @param {Object} args The arguments provide to `func`.
  21105. * @returns {number} Returns the timer id.
  21106. */
  21107. function baseDelay(func, wait, args) {
  21108. if (typeof func != 'function') {
  21109. throw new TypeError(FUNC_ERROR_TEXT);
  21110. }
  21111. return setTimeout(function() { func.apply(undefined, args); }, wait);
  21112. }
  21113. module.exports = baseDelay;
  21114. },{}],101:[function(_dereq_,module,exports){
  21115. var baseIndexOf = _dereq_(112),
  21116. cacheIndexOf = _dereq_(129),
  21117. createCache = _dereq_(135);
  21118. /** Used as the size to enable large array optimizations. */
  21119. var LARGE_ARRAY_SIZE = 200;
  21120. /**
  21121. * The base implementation of `_.difference` which accepts a single array
  21122. * of values to exclude.
  21123. *
  21124. * @private
  21125. * @param {Array} array The array to inspect.
  21126. * @param {Array} values The values to exclude.
  21127. * @returns {Array} Returns the new array of filtered values.
  21128. */
  21129. function baseDifference(array, values) {
  21130. var length = array ? array.length : 0,
  21131. result = [];
  21132. if (!length) {
  21133. return result;
  21134. }
  21135. var index = -1,
  21136. indexOf = baseIndexOf,
  21137. isCommon = true,
  21138. cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : null,
  21139. valuesLength = values.length;
  21140. if (cache) {
  21141. indexOf = cacheIndexOf;
  21142. isCommon = false;
  21143. values = cache;
  21144. }
  21145. outer:
  21146. while (++index < length) {
  21147. var value = array[index];
  21148. if (isCommon && value === value) {
  21149. var valuesIndex = valuesLength;
  21150. while (valuesIndex--) {
  21151. if (values[valuesIndex] === value) {
  21152. continue outer;
  21153. }
  21154. }
  21155. result.push(value);
  21156. }
  21157. else if (indexOf(values, value, 0) < 0) {
  21158. result.push(value);
  21159. }
  21160. }
  21161. return result;
  21162. }
  21163. module.exports = baseDifference;
  21164. },{"112":112,"129":129,"135":135}],102:[function(_dereq_,module,exports){
  21165. var baseForOwn = _dereq_(110),
  21166. createBaseEach = _dereq_(133);
  21167. /**
  21168. * The base implementation of `_.forEach` without support for callback
  21169. * shorthands and `this` binding.
  21170. *
  21171. * @private
  21172. * @param {Array|Object|string} collection The collection to iterate over.
  21173. * @param {Function} iteratee The function invoked per iteration.
  21174. * @returns {Array|Object|string} Returns `collection`.
  21175. */
  21176. var baseEach = createBaseEach(baseForOwn);
  21177. module.exports = baseEach;
  21178. },{"110":110,"133":133}],103:[function(_dereq_,module,exports){
  21179. var baseEach = _dereq_(102);
  21180. /**
  21181. * The base implementation of `_.every` without support for callback
  21182. * shorthands and `this` binding.
  21183. *
  21184. * @private
  21185. * @param {Array|Object|string} collection The collection to iterate over.
  21186. * @param {Function} predicate The function invoked per iteration.
  21187. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  21188. * else `false`
  21189. */
  21190. function baseEvery(collection, predicate) {
  21191. var result = true;
  21192. baseEach(collection, function(value, index, collection) {
  21193. result = !!predicate(value, index, collection);
  21194. return result;
  21195. });
  21196. return result;
  21197. }
  21198. module.exports = baseEvery;
  21199. },{"102":102}],104:[function(_dereq_,module,exports){
  21200. var baseEach = _dereq_(102);
  21201. /**
  21202. * The base implementation of `_.filter` without support for callback
  21203. * shorthands and `this` binding.
  21204. *
  21205. * @private
  21206. * @param {Array|Object|string} collection The collection to iterate over.
  21207. * @param {Function} predicate The function invoked per iteration.
  21208. * @returns {Array} Returns the new filtered array.
  21209. */
  21210. function baseFilter(collection, predicate) {
  21211. var result = [];
  21212. baseEach(collection, function(value, index, collection) {
  21213. if (predicate(value, index, collection)) {
  21214. result.push(value);
  21215. }
  21216. });
  21217. return result;
  21218. }
  21219. module.exports = baseFilter;
  21220. },{"102":102}],105:[function(_dereq_,module,exports){
  21221. /**
  21222. * The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`,
  21223. * without support for callback shorthands and `this` binding, which iterates
  21224. * over `collection` using the provided `eachFunc`.
  21225. *
  21226. * @private
  21227. * @param {Array|Object|string} collection The collection to search.
  21228. * @param {Function} predicate The function invoked per iteration.
  21229. * @param {Function} eachFunc The function to iterate over `collection`.
  21230. * @param {boolean} [retKey] Specify returning the key of the found element
  21231. * instead of the element itself.
  21232. * @returns {*} Returns the found element or its key, else `undefined`.
  21233. */
  21234. function baseFind(collection, predicate, eachFunc, retKey) {
  21235. var result;
  21236. eachFunc(collection, function(value, key, collection) {
  21237. if (predicate(value, key, collection)) {
  21238. result = retKey ? key : value;
  21239. return false;
  21240. }
  21241. });
  21242. return result;
  21243. }
  21244. module.exports = baseFind;
  21245. },{}],106:[function(_dereq_,module,exports){
  21246. /**
  21247. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  21248. * support for callback shorthands and `this` binding.
  21249. *
  21250. * @private
  21251. * @param {Array} array The array to search.
  21252. * @param {Function} predicate The function invoked per iteration.
  21253. * @param {boolean} [fromRight] Specify iterating from right to left.
  21254. * @returns {number} Returns the index of the matched value, else `-1`.
  21255. */
  21256. function baseFindIndex(array, predicate, fromRight) {
  21257. var length = array.length,
  21258. index = fromRight ? length : -1;
  21259. while ((fromRight ? index-- : ++index < length)) {
  21260. if (predicate(array[index], index, array)) {
  21261. return index;
  21262. }
  21263. }
  21264. return -1;
  21265. }
  21266. module.exports = baseFindIndex;
  21267. },{}],107:[function(_dereq_,module,exports){
  21268. var arrayPush = _dereq_(93),
  21269. isArguments = _dereq_(158),
  21270. isArray = _dereq_(159),
  21271. isArrayLike = _dereq_(146),
  21272. isObjectLike = _dereq_(151);
  21273. /**
  21274. * The base implementation of `_.flatten` with added support for restricting
  21275. * flattening and specifying the start index.
  21276. *
  21277. * @private
  21278. * @param {Array} array The array to flatten.
  21279. * @param {boolean} [isDeep] Specify a deep flatten.
  21280. * @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
  21281. * @param {Array} [result=[]] The initial result value.
  21282. * @returns {Array} Returns the new flattened array.
  21283. */
  21284. function baseFlatten(array, isDeep, isStrict, result) {
  21285. result || (result = []);
  21286. var index = -1,
  21287. length = array.length;
  21288. while (++index < length) {
  21289. var value = array[index];
  21290. if (isObjectLike(value) && isArrayLike(value) &&
  21291. (isStrict || isArray(value) || isArguments(value))) {
  21292. if (isDeep) {
  21293. // Recursively flatten arrays (susceptible to call stack limits).
  21294. baseFlatten(value, isDeep, isStrict, result);
  21295. } else {
  21296. arrayPush(result, value);
  21297. }
  21298. } else if (!isStrict) {
  21299. result[result.length] = value;
  21300. }
  21301. }
  21302. return result;
  21303. }
  21304. module.exports = baseFlatten;
  21305. },{"146":146,"151":151,"158":158,"159":159,"93":93}],108:[function(_dereq_,module,exports){
  21306. var createBaseFor = _dereq_(134);
  21307. /**
  21308. * The base implementation of `baseForIn` and `baseForOwn` which iterates
  21309. * over `object` properties returned by `keysFunc` invoking `iteratee` for
  21310. * each property. Iteratee functions may exit iteration early by explicitly
  21311. * returning `false`.
  21312. *
  21313. * @private
  21314. * @param {Object} object The object to iterate over.
  21315. * @param {Function} iteratee The function invoked per iteration.
  21316. * @param {Function} keysFunc The function to get the keys of `object`.
  21317. * @returns {Object} Returns `object`.
  21318. */
  21319. var baseFor = createBaseFor();
  21320. module.exports = baseFor;
  21321. },{"134":134}],109:[function(_dereq_,module,exports){
  21322. var baseFor = _dereq_(108),
  21323. keysIn = _dereq_(170);
  21324. /**
  21325. * The base implementation of `_.forIn` without support for callback
  21326. * shorthands and `this` binding.
  21327. *
  21328. * @private
  21329. * @param {Object} object The object to iterate over.
  21330. * @param {Function} iteratee The function invoked per iteration.
  21331. * @returns {Object} Returns `object`.
  21332. */
  21333. function baseForIn(object, iteratee) {
  21334. return baseFor(object, iteratee, keysIn);
  21335. }
  21336. module.exports = baseForIn;
  21337. },{"108":108,"170":170}],110:[function(_dereq_,module,exports){
  21338. var baseFor = _dereq_(108),
  21339. keys = _dereq_(169);
  21340. /**
  21341. * The base implementation of `_.forOwn` without support for callback
  21342. * shorthands and `this` binding.
  21343. *
  21344. * @private
  21345. * @param {Object} object The object to iterate over.
  21346. * @param {Function} iteratee The function invoked per iteration.
  21347. * @returns {Object} Returns `object`.
  21348. */
  21349. function baseForOwn(object, iteratee) {
  21350. return baseFor(object, iteratee, keys);
  21351. }
  21352. module.exports = baseForOwn;
  21353. },{"108":108,"169":169}],111:[function(_dereq_,module,exports){
  21354. var toObject = _dereq_(156);
  21355. /**
  21356. * The base implementation of `get` without support for string paths
  21357. * and default values.
  21358. *
  21359. * @private
  21360. * @param {Object} object The object to query.
  21361. * @param {Array} path The path of the property to get.
  21362. * @param {string} [pathKey] The key representation of path.
  21363. * @returns {*} Returns the resolved value.
  21364. */
  21365. function baseGet(object, path, pathKey) {
  21366. if (object == null) {
  21367. return;
  21368. }
  21369. if (pathKey !== undefined && pathKey in toObject(object)) {
  21370. path = [pathKey];
  21371. }
  21372. var index = 0,
  21373. length = path.length;
  21374. while (object != null && index < length) {
  21375. object = object[path[index++]];
  21376. }
  21377. return (index && index == length) ? object : undefined;
  21378. }
  21379. module.exports = baseGet;
  21380. },{"156":156}],112:[function(_dereq_,module,exports){
  21381. var indexOfNaN = _dereq_(145);
  21382. /**
  21383. * The base implementation of `_.indexOf` without support for binary searches.
  21384. *
  21385. * @private
  21386. * @param {Array} array The array to search.
  21387. * @param {*} value The value to search for.
  21388. * @param {number} fromIndex The index to search from.
  21389. * @returns {number} Returns the index of the matched value, else `-1`.
  21390. */
  21391. function baseIndexOf(array, value, fromIndex) {
  21392. if (value !== value) {
  21393. return indexOfNaN(array, fromIndex);
  21394. }
  21395. var index = fromIndex - 1,
  21396. length = array.length;
  21397. while (++index < length) {
  21398. if (array[index] === value) {
  21399. return index;
  21400. }
  21401. }
  21402. return -1;
  21403. }
  21404. module.exports = baseIndexOf;
  21405. },{"145":145}],113:[function(_dereq_,module,exports){
  21406. var baseIsEqualDeep = _dereq_(114),
  21407. isObject = _dereq_(163),
  21408. isObjectLike = _dereq_(151);
  21409. /**
  21410. * The base implementation of `_.isEqual` without support for `this` binding
  21411. * `customizer` functions.
  21412. *
  21413. * @private
  21414. * @param {*} value The value to compare.
  21415. * @param {*} other The other value to compare.
  21416. * @param {Function} [customizer] The function to customize comparing values.
  21417. * @param {boolean} [isLoose] Specify performing partial comparisons.
  21418. * @param {Array} [stackA] Tracks traversed `value` objects.
  21419. * @param {Array} [stackB] Tracks traversed `other` objects.
  21420. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  21421. */
  21422. function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
  21423. if (value === other) {
  21424. return true;
  21425. }
  21426. if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
  21427. return value !== value && other !== other;
  21428. }
  21429. return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
  21430. }
  21431. module.exports = baseIsEqual;
  21432. },{"114":114,"151":151,"163":163}],114:[function(_dereq_,module,exports){
  21433. var equalArrays = _dereq_(139),
  21434. equalByTag = _dereq_(140),
  21435. equalObjects = _dereq_(141),
  21436. isArray = _dereq_(159),
  21437. isTypedArray = _dereq_(166);
  21438. /** `Object#toString` result references. */
  21439. var argsTag = '[object Arguments]',
  21440. arrayTag = '[object Array]',
  21441. objectTag = '[object Object]';
  21442. /** Used for native method references. */
  21443. var objectProto = Object.prototype;
  21444. /** Used to check objects for own properties. */
  21445. var hasOwnProperty = objectProto.hasOwnProperty;
  21446. /**
  21447. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  21448. * of values.
  21449. */
  21450. var objToString = objectProto.toString;
  21451. /**
  21452. * A specialized version of `baseIsEqual` for arrays and objects which performs
  21453. * deep comparisons and tracks traversed objects enabling objects with circular
  21454. * references to be compared.
  21455. *
  21456. * @private
  21457. * @param {Object} object The object to compare.
  21458. * @param {Object} other The other object to compare.
  21459. * @param {Function} equalFunc The function to determine equivalents of values.
  21460. * @param {Function} [customizer] The function to customize comparing objects.
  21461. * @param {boolean} [isLoose] Specify performing partial comparisons.
  21462. * @param {Array} [stackA=[]] Tracks traversed `value` objects.
  21463. * @param {Array} [stackB=[]] Tracks traversed `other` objects.
  21464. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  21465. */
  21466. function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  21467. var objIsArr = isArray(object),
  21468. othIsArr = isArray(other),
  21469. objTag = arrayTag,
  21470. othTag = arrayTag;
  21471. if (!objIsArr) {
  21472. objTag = objToString.call(object);
  21473. if (objTag == argsTag) {
  21474. objTag = objectTag;
  21475. } else if (objTag != objectTag) {
  21476. objIsArr = isTypedArray(object);
  21477. }
  21478. }
  21479. if (!othIsArr) {
  21480. othTag = objToString.call(other);
  21481. if (othTag == argsTag) {
  21482. othTag = objectTag;
  21483. } else if (othTag != objectTag) {
  21484. othIsArr = isTypedArray(other);
  21485. }
  21486. }
  21487. var objIsObj = objTag == objectTag,
  21488. othIsObj = othTag == objectTag,
  21489. isSameTag = objTag == othTag;
  21490. if (isSameTag && !(objIsArr || objIsObj)) {
  21491. return equalByTag(object, other, objTag);
  21492. }
  21493. if (!isLoose) {
  21494. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  21495. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  21496. if (objIsWrapped || othIsWrapped) {
  21497. return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
  21498. }
  21499. }
  21500. if (!isSameTag) {
  21501. return false;
  21502. }
  21503. // Assume cyclic values are equal.
  21504. // For more information on detecting circular references see https://es5.github.io/#JO.
  21505. stackA || (stackA = []);
  21506. stackB || (stackB = []);
  21507. var length = stackA.length;
  21508. while (length--) {
  21509. if (stackA[length] == object) {
  21510. return stackB[length] == other;
  21511. }
  21512. }
  21513. // Add `object` and `other` to the stack of traversed objects.
  21514. stackA.push(object);
  21515. stackB.push(other);
  21516. var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
  21517. stackA.pop();
  21518. stackB.pop();
  21519. return result;
  21520. }
  21521. module.exports = baseIsEqualDeep;
  21522. },{"139":139,"140":140,"141":141,"159":159,"166":166}],115:[function(_dereq_,module,exports){
  21523. var baseIsEqual = _dereq_(113),
  21524. toObject = _dereq_(156);
  21525. /**
  21526. * The base implementation of `_.isMatch` without support for callback
  21527. * shorthands and `this` binding.
  21528. *
  21529. * @private
  21530. * @param {Object} object The object to inspect.
  21531. * @param {Array} matchData The propery names, values, and compare flags to match.
  21532. * @param {Function} [customizer] The function to customize comparing objects.
  21533. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  21534. */
  21535. function baseIsMatch(object, matchData, customizer) {
  21536. var index = matchData.length,
  21537. length = index,
  21538. noCustomizer = !customizer;
  21539. if (object == null) {
  21540. return !length;
  21541. }
  21542. object = toObject(object);
  21543. while (index--) {
  21544. var data = matchData[index];
  21545. if ((noCustomizer && data[2])
  21546. ? data[1] !== object[data[0]]
  21547. : !(data[0] in object)
  21548. ) {
  21549. return false;
  21550. }
  21551. }
  21552. while (++index < length) {
  21553. data = matchData[index];
  21554. var key = data[0],
  21555. objValue = object[key],
  21556. srcValue = data[1];
  21557. if (noCustomizer && data[2]) {
  21558. if (objValue === undefined && !(key in object)) {
  21559. return false;
  21560. }
  21561. } else {
  21562. var result = customizer ? customizer(objValue, srcValue, key) : undefined;
  21563. if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) {
  21564. return false;
  21565. }
  21566. }
  21567. }
  21568. return true;
  21569. }
  21570. module.exports = baseIsMatch;
  21571. },{"113":113,"156":156}],116:[function(_dereq_,module,exports){
  21572. var baseEach = _dereq_(102),
  21573. isArrayLike = _dereq_(146);
  21574. /**
  21575. * The base implementation of `_.map` without support for callback shorthands
  21576. * and `this` binding.
  21577. *
  21578. * @private
  21579. * @param {Array|Object|string} collection The collection to iterate over.
  21580. * @param {Function} iteratee The function invoked per iteration.
  21581. * @returns {Array} Returns the new mapped array.
  21582. */
  21583. function baseMap(collection, iteratee) {
  21584. var index = -1,
  21585. result = isArrayLike(collection) ? Array(collection.length) : [];
  21586. baseEach(collection, function(value, key, collection) {
  21587. result[++index] = iteratee(value, key, collection);
  21588. });
  21589. return result;
  21590. }
  21591. module.exports = baseMap;
  21592. },{"102":102,"146":146}],117:[function(_dereq_,module,exports){
  21593. var baseIsMatch = _dereq_(115),
  21594. getMatchData = _dereq_(143),
  21595. toObject = _dereq_(156);
  21596. /**
  21597. * The base implementation of `_.matches` which does not clone `source`.
  21598. *
  21599. * @private
  21600. * @param {Object} source The object of property values to match.
  21601. * @returns {Function} Returns the new function.
  21602. */
  21603. function baseMatches(source) {
  21604. var matchData = getMatchData(source);
  21605. if (matchData.length == 1 && matchData[0][2]) {
  21606. var key = matchData[0][0],
  21607. value = matchData[0][1];
  21608. return function(object) {
  21609. if (object == null) {
  21610. return false;
  21611. }
  21612. return object[key] === value && (value !== undefined || (key in toObject(object)));
  21613. };
  21614. }
  21615. return function(object) {
  21616. return baseIsMatch(object, matchData);
  21617. };
  21618. }
  21619. module.exports = baseMatches;
  21620. },{"115":115,"143":143,"156":156}],118:[function(_dereq_,module,exports){
  21621. var baseGet = _dereq_(111),
  21622. baseIsEqual = _dereq_(113),
  21623. baseSlice = _dereq_(124),
  21624. isArray = _dereq_(159),
  21625. isKey = _dereq_(149),
  21626. isStrictComparable = _dereq_(152),
  21627. last = _dereq_(73),
  21628. toObject = _dereq_(156),
  21629. toPath = _dereq_(157);
  21630. /**
  21631. * The base implementation of `_.matchesProperty` which does not clone `srcValue`.
  21632. *
  21633. * @private
  21634. * @param {string} path The path of the property to get.
  21635. * @param {*} srcValue The value to compare.
  21636. * @returns {Function} Returns the new function.
  21637. */
  21638. function baseMatchesProperty(path, srcValue) {
  21639. var isArr = isArray(path),
  21640. isCommon = isKey(path) && isStrictComparable(srcValue),
  21641. pathKey = (path + '');
  21642. path = toPath(path);
  21643. return function(object) {
  21644. if (object == null) {
  21645. return false;
  21646. }
  21647. var key = pathKey;
  21648. object = toObject(object);
  21649. if ((isArr || !isCommon) && !(key in object)) {
  21650. object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  21651. if (object == null) {
  21652. return false;
  21653. }
  21654. key = last(path);
  21655. object = toObject(object);
  21656. }
  21657. return object[key] === srcValue
  21658. ? (srcValue !== undefined || (key in object))
  21659. : baseIsEqual(srcValue, object[key], undefined, true);
  21660. };
  21661. }
  21662. module.exports = baseMatchesProperty;
  21663. },{"111":111,"113":113,"124":124,"149":149,"152":152,"156":156,"157":157,"159":159,"73":73}],119:[function(_dereq_,module,exports){
  21664. var arrayEach = _dereq_(89),
  21665. baseMergeDeep = _dereq_(120),
  21666. isArray = _dereq_(159),
  21667. isArrayLike = _dereq_(146),
  21668. isObject = _dereq_(163),
  21669. isObjectLike = _dereq_(151),
  21670. isTypedArray = _dereq_(166),
  21671. keys = _dereq_(169);
  21672. /**
  21673. * The base implementation of `_.merge` without support for argument juggling,
  21674. * multiple sources, and `this` binding `customizer` functions.
  21675. *
  21676. * @private
  21677. * @param {Object} object The destination object.
  21678. * @param {Object} source The source object.
  21679. * @param {Function} [customizer] The function to customize merged values.
  21680. * @param {Array} [stackA=[]] Tracks traversed source objects.
  21681. * @param {Array} [stackB=[]] Associates values with source counterparts.
  21682. * @returns {Object} Returns `object`.
  21683. */
  21684. function baseMerge(object, source, customizer, stackA, stackB) {
  21685. if (!isObject(object)) {
  21686. return object;
  21687. }
  21688. var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),
  21689. props = isSrcArr ? undefined : keys(source);
  21690. arrayEach(props || source, function(srcValue, key) {
  21691. if (props) {
  21692. key = srcValue;
  21693. srcValue = source[key];
  21694. }
  21695. if (isObjectLike(srcValue)) {
  21696. stackA || (stackA = []);
  21697. stackB || (stackB = []);
  21698. baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
  21699. }
  21700. else {
  21701. var value = object[key],
  21702. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  21703. isCommon = result === undefined;
  21704. if (isCommon) {
  21705. result = srcValue;
  21706. }
  21707. if ((result !== undefined || (isSrcArr && !(key in object))) &&
  21708. (isCommon || (result === result ? (result !== value) : (value === value)))) {
  21709. object[key] = result;
  21710. }
  21711. }
  21712. });
  21713. return object;
  21714. }
  21715. module.exports = baseMerge;
  21716. },{"120":120,"146":146,"151":151,"159":159,"163":163,"166":166,"169":169,"89":89}],120:[function(_dereq_,module,exports){
  21717. var arrayCopy = _dereq_(88),
  21718. isArguments = _dereq_(158),
  21719. isArray = _dereq_(159),
  21720. isArrayLike = _dereq_(146),
  21721. isPlainObject = _dereq_(164),
  21722. isTypedArray = _dereq_(166),
  21723. toPlainObject = _dereq_(167);
  21724. /**
  21725. * A specialized version of `baseMerge` for arrays and objects which performs
  21726. * deep merges and tracks traversed objects enabling objects with circular
  21727. * references to be merged.
  21728. *
  21729. * @private
  21730. * @param {Object} object The destination object.
  21731. * @param {Object} source The source object.
  21732. * @param {string} key The key of the value to merge.
  21733. * @param {Function} mergeFunc The function to merge values.
  21734. * @param {Function} [customizer] The function to customize merged values.
  21735. * @param {Array} [stackA=[]] Tracks traversed source objects.
  21736. * @param {Array} [stackB=[]] Associates values with source counterparts.
  21737. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  21738. */
  21739. function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
  21740. var length = stackA.length,
  21741. srcValue = source[key];
  21742. while (length--) {
  21743. if (stackA[length] == srcValue) {
  21744. object[key] = stackB[length];
  21745. return;
  21746. }
  21747. }
  21748. var value = object[key],
  21749. result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
  21750. isCommon = result === undefined;
  21751. if (isCommon) {
  21752. result = srcValue;
  21753. if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {
  21754. result = isArray(value)
  21755. ? value
  21756. : (isArrayLike(value) ? arrayCopy(value) : []);
  21757. }
  21758. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  21759. result = isArguments(value)
  21760. ? toPlainObject(value)
  21761. : (isPlainObject(value) ? value : {});
  21762. }
  21763. else {
  21764. isCommon = false;
  21765. }
  21766. }
  21767. // Add the source value to the stack of traversed objects and associate
  21768. // it with its merged value.
  21769. stackA.push(srcValue);
  21770. stackB.push(result);
  21771. if (isCommon) {
  21772. // Recursively merge objects and arrays (susceptible to call stack limits).
  21773. object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
  21774. } else if (result === result ? (result !== value) : (value === value)) {
  21775. object[key] = result;
  21776. }
  21777. }
  21778. module.exports = baseMergeDeep;
  21779. },{"146":146,"158":158,"159":159,"164":164,"166":166,"167":167,"88":88}],121:[function(_dereq_,module,exports){
  21780. /**
  21781. * The base implementation of `_.property` without support for deep paths.
  21782. *
  21783. * @private
  21784. * @param {string} key The key of the property to get.
  21785. * @returns {Function} Returns the new function.
  21786. */
  21787. function baseProperty(key) {
  21788. return function(object) {
  21789. return object == null ? undefined : object[key];
  21790. };
  21791. }
  21792. module.exports = baseProperty;
  21793. },{}],122:[function(_dereq_,module,exports){
  21794. var baseGet = _dereq_(111),
  21795. toPath = _dereq_(157);
  21796. /**
  21797. * A specialized version of `baseProperty` which supports deep paths.
  21798. *
  21799. * @private
  21800. * @param {Array|string} path The path of the property to get.
  21801. * @returns {Function} Returns the new function.
  21802. */
  21803. function basePropertyDeep(path) {
  21804. var pathKey = (path + '');
  21805. path = toPath(path);
  21806. return function(object) {
  21807. return baseGet(object, path, pathKey);
  21808. };
  21809. }
  21810. module.exports = basePropertyDeep;
  21811. },{"111":111,"157":157}],123:[function(_dereq_,module,exports){
  21812. /**
  21813. * The base implementation of `_.reduce` and `_.reduceRight` without support
  21814. * for callback shorthands and `this` binding, which iterates over `collection`
  21815. * using the provided `eachFunc`.
  21816. *
  21817. * @private
  21818. * @param {Array|Object|string} collection The collection to iterate over.
  21819. * @param {Function} iteratee The function invoked per iteration.
  21820. * @param {*} accumulator The initial value.
  21821. * @param {boolean} initFromCollection Specify using the first or last element
  21822. * of `collection` as the initial value.
  21823. * @param {Function} eachFunc The function to iterate over `collection`.
  21824. * @returns {*} Returns the accumulated value.
  21825. */
  21826. function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) {
  21827. eachFunc(collection, function(value, index, collection) {
  21828. accumulator = initFromCollection
  21829. ? (initFromCollection = false, value)
  21830. : iteratee(accumulator, value, index, collection);
  21831. });
  21832. return accumulator;
  21833. }
  21834. module.exports = baseReduce;
  21835. },{}],124:[function(_dereq_,module,exports){
  21836. /**
  21837. * The base implementation of `_.slice` without an iteratee call guard.
  21838. *
  21839. * @private
  21840. * @param {Array} array The array to slice.
  21841. * @param {number} [start=0] The start position.
  21842. * @param {number} [end=array.length] The end position.
  21843. * @returns {Array} Returns the slice of `array`.
  21844. */
  21845. function baseSlice(array, start, end) {
  21846. var index = -1,
  21847. length = array.length;
  21848. start = start == null ? 0 : (+start || 0);
  21849. if (start < 0) {
  21850. start = -start > length ? 0 : (length + start);
  21851. }
  21852. end = (end === undefined || end > length) ? length : (+end || 0);
  21853. if (end < 0) {
  21854. end += length;
  21855. }
  21856. length = start > end ? 0 : ((end - start) >>> 0);
  21857. start >>>= 0;
  21858. var result = Array(length);
  21859. while (++index < length) {
  21860. result[index] = array[index + start];
  21861. }
  21862. return result;
  21863. }
  21864. module.exports = baseSlice;
  21865. },{}],125:[function(_dereq_,module,exports){
  21866. var baseEach = _dereq_(102);
  21867. /**
  21868. * The base implementation of `_.some` without support for callback shorthands
  21869. * and `this` binding.
  21870. *
  21871. * @private
  21872. * @param {Array|Object|string} collection The collection to iterate over.
  21873. * @param {Function} predicate The function invoked per iteration.
  21874. * @returns {boolean} Returns `true` if any element passes the predicate check,
  21875. * else `false`.
  21876. */
  21877. function baseSome(collection, predicate) {
  21878. var result;
  21879. baseEach(collection, function(value, index, collection) {
  21880. result = predicate(value, index, collection);
  21881. return !result;
  21882. });
  21883. return !!result;
  21884. }
  21885. module.exports = baseSome;
  21886. },{"102":102}],126:[function(_dereq_,module,exports){
  21887. /**
  21888. * Converts `value` to a string if it's not one. An empty string is returned
  21889. * for `null` or `undefined` values.
  21890. *
  21891. * @private
  21892. * @param {*} value The value to process.
  21893. * @returns {string} Returns the string.
  21894. */
  21895. function baseToString(value) {
  21896. return value == null ? '' : (value + '');
  21897. }
  21898. module.exports = baseToString;
  21899. },{}],127:[function(_dereq_,module,exports){
  21900. /**
  21901. * The base implementation of `_.values` and `_.valuesIn` which creates an
  21902. * array of `object` property values corresponding to the property names
  21903. * of `props`.
  21904. *
  21905. * @private
  21906. * @param {Object} object The object to query.
  21907. * @param {Array} props The property names to get values for.
  21908. * @returns {Object} Returns the array of property values.
  21909. */
  21910. function baseValues(object, props) {
  21911. var index = -1,
  21912. length = props.length,
  21913. result = Array(length);
  21914. while (++index < length) {
  21915. result[index] = object[props[index]];
  21916. }
  21917. return result;
  21918. }
  21919. module.exports = baseValues;
  21920. },{}],128:[function(_dereq_,module,exports){
  21921. var identity = _dereq_(176);
  21922. /**
  21923. * A specialized version of `baseCallback` which only supports `this` binding
  21924. * and specifying the number of arguments to provide to `func`.
  21925. *
  21926. * @private
  21927. * @param {Function} func The function to bind.
  21928. * @param {*} thisArg The `this` binding of `func`.
  21929. * @param {number} [argCount] The number of arguments to provide to `func`.
  21930. * @returns {Function} Returns the callback.
  21931. */
  21932. function bindCallback(func, thisArg, argCount) {
  21933. if (typeof func != 'function') {
  21934. return identity;
  21935. }
  21936. if (thisArg === undefined) {
  21937. return func;
  21938. }
  21939. switch (argCount) {
  21940. case 1: return function(value) {
  21941. return func.call(thisArg, value);
  21942. };
  21943. case 3: return function(value, index, collection) {
  21944. return func.call(thisArg, value, index, collection);
  21945. };
  21946. case 4: return function(accumulator, value, index, collection) {
  21947. return func.call(thisArg, accumulator, value, index, collection);
  21948. };
  21949. case 5: return function(value, other, key, object, source) {
  21950. return func.call(thisArg, value, other, key, object, source);
  21951. };
  21952. }
  21953. return function() {
  21954. return func.apply(thisArg, arguments);
  21955. };
  21956. }
  21957. module.exports = bindCallback;
  21958. },{"176":176}],129:[function(_dereq_,module,exports){
  21959. var isObject = _dereq_(163);
  21960. /**
  21961. * Checks if `value` is in `cache` mimicking the return signature of
  21962. * `_.indexOf` by returning `0` if the value is found, else `-1`.
  21963. *
  21964. * @private
  21965. * @param {Object} cache The cache to search.
  21966. * @param {*} value The value to search for.
  21967. * @returns {number} Returns `0` if `value` is found, else `-1`.
  21968. */
  21969. function cacheIndexOf(cache, value) {
  21970. var data = cache.data,
  21971. result = (typeof value == 'string' || isObject(value)) ? data.set.has(value) : data.hash[value];
  21972. return result ? 0 : -1;
  21973. }
  21974. module.exports = cacheIndexOf;
  21975. },{"163":163}],130:[function(_dereq_,module,exports){
  21976. var isObject = _dereq_(163);
  21977. /**
  21978. * Adds `value` to the cache.
  21979. *
  21980. * @private
  21981. * @name push
  21982. * @memberOf SetCache
  21983. * @param {*} value The value to cache.
  21984. */
  21985. function cachePush(value) {
  21986. var data = this.data;
  21987. if (typeof value == 'string' || isObject(value)) {
  21988. data.set.add(value);
  21989. } else {
  21990. data.hash[value] = true;
  21991. }
  21992. }
  21993. module.exports = cachePush;
  21994. },{"163":163}],131:[function(_dereq_,module,exports){
  21995. var baseCallback = _dereq_(98),
  21996. baseEach = _dereq_(102),
  21997. isArray = _dereq_(159);
  21998. /**
  21999. * Creates a `_.countBy`, `_.groupBy`, `_.indexBy`, or `_.partition` function.
  22000. *
  22001. * @private
  22002. * @param {Function} setter The function to set keys and values of the accumulator object.
  22003. * @param {Function} [initializer] The function to initialize the accumulator object.
  22004. * @returns {Function} Returns the new aggregator function.
  22005. */
  22006. function createAggregator(setter, initializer) {
  22007. return function(collection, iteratee, thisArg) {
  22008. var result = initializer ? initializer() : {};
  22009. iteratee = baseCallback(iteratee, thisArg, 3);
  22010. if (isArray(collection)) {
  22011. var index = -1,
  22012. length = collection.length;
  22013. while (++index < length) {
  22014. var value = collection[index];
  22015. setter(result, value, iteratee(value, index, collection), collection);
  22016. }
  22017. } else {
  22018. baseEach(collection, function(value, key, collection) {
  22019. setter(result, value, iteratee(value, key, collection), collection);
  22020. });
  22021. }
  22022. return result;
  22023. };
  22024. }
  22025. module.exports = createAggregator;
  22026. },{"102":102,"159":159,"98":98}],132:[function(_dereq_,module,exports){
  22027. var bindCallback = _dereq_(128),
  22028. isIterateeCall = _dereq_(148),
  22029. restParam = _dereq_(86);
  22030. /**
  22031. * Creates a `_.assign`, `_.defaults`, or `_.merge` function.
  22032. *
  22033. * @private
  22034. * @param {Function} assigner The function to assign values.
  22035. * @returns {Function} Returns the new assigner function.
  22036. */
  22037. function createAssigner(assigner) {
  22038. return restParam(function(object, sources) {
  22039. var index = -1,
  22040. length = object == null ? 0 : sources.length,
  22041. customizer = length > 2 ? sources[length - 2] : undefined,
  22042. guard = length > 2 ? sources[2] : undefined,
  22043. thisArg = length > 1 ? sources[length - 1] : undefined;
  22044. if (typeof customizer == 'function') {
  22045. customizer = bindCallback(customizer, thisArg, 5);
  22046. length -= 2;
  22047. } else {
  22048. customizer = typeof thisArg == 'function' ? thisArg : undefined;
  22049. length -= (customizer ? 1 : 0);
  22050. }
  22051. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  22052. customizer = length < 3 ? undefined : customizer;
  22053. length = 1;
  22054. }
  22055. while (++index < length) {
  22056. var source = sources[index];
  22057. if (source) {
  22058. assigner(object, source, customizer);
  22059. }
  22060. }
  22061. return object;
  22062. });
  22063. }
  22064. module.exports = createAssigner;
  22065. },{"128":128,"148":148,"86":86}],133:[function(_dereq_,module,exports){
  22066. var getLength = _dereq_(142),
  22067. isLength = _dereq_(150),
  22068. toObject = _dereq_(156);
  22069. /**
  22070. * Creates a `baseEach` or `baseEachRight` function.
  22071. *
  22072. * @private
  22073. * @param {Function} eachFunc The function to iterate over a collection.
  22074. * @param {boolean} [fromRight] Specify iterating from right to left.
  22075. * @returns {Function} Returns the new base function.
  22076. */
  22077. function createBaseEach(eachFunc, fromRight) {
  22078. return function(collection, iteratee) {
  22079. var length = collection ? getLength(collection) : 0;
  22080. if (!isLength(length)) {
  22081. return eachFunc(collection, iteratee);
  22082. }
  22083. var index = fromRight ? length : -1,
  22084. iterable = toObject(collection);
  22085. while ((fromRight ? index-- : ++index < length)) {
  22086. if (iteratee(iterable[index], index, iterable) === false) {
  22087. break;
  22088. }
  22089. }
  22090. return collection;
  22091. };
  22092. }
  22093. module.exports = createBaseEach;
  22094. },{"142":142,"150":150,"156":156}],134:[function(_dereq_,module,exports){
  22095. var toObject = _dereq_(156);
  22096. /**
  22097. * Creates a base function for `_.forIn` or `_.forInRight`.
  22098. *
  22099. * @private
  22100. * @param {boolean} [fromRight] Specify iterating from right to left.
  22101. * @returns {Function} Returns the new base function.
  22102. */
  22103. function createBaseFor(fromRight) {
  22104. return function(object, iteratee, keysFunc) {
  22105. var iterable = toObject(object),
  22106. props = keysFunc(object),
  22107. length = props.length,
  22108. index = fromRight ? length : -1;
  22109. while ((fromRight ? index-- : ++index < length)) {
  22110. var key = props[index];
  22111. if (iteratee(iterable[key], key, iterable) === false) {
  22112. break;
  22113. }
  22114. }
  22115. return object;
  22116. };
  22117. }
  22118. module.exports = createBaseFor;
  22119. },{"156":156}],135:[function(_dereq_,module,exports){
  22120. (function (global){
  22121. var SetCache = _dereq_(87),
  22122. getNative = _dereq_(144);
  22123. /** Native method references. */
  22124. var Set = getNative(global, 'Set');
  22125. /* Native method references for those with the same name as other `lodash` methods. */
  22126. var nativeCreate = getNative(Object, 'create');
  22127. /**
  22128. * Creates a `Set` cache object to optimize linear searches of large arrays.
  22129. *
  22130. * @private
  22131. * @param {Array} [values] The values to cache.
  22132. * @returns {null|Object} Returns the new cache object if `Set` is supported, else `null`.
  22133. */
  22134. function createCache(values) {
  22135. return (nativeCreate && Set) ? new SetCache(values) : null;
  22136. }
  22137. module.exports = createCache;
  22138. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  22139. //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaW50ZXJuYWwvY3JlYXRlQ2FjaGUuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwiZ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143. baseFindIndex = _dereq_(106),
  22144. isArray = _dereq_(159);
  22145. /**
  22146. * Creates a `_.find` or `_.findLast` function.
  22147. *
  22148. * @private
  22149. * @param {Function} eachFunc The function to iterate over a collection.
  22150. * @param {boolean} [fromRight] Specify iterating from right to left.
  22151. * @returns {Function} Returns the new find function.
  22152. */
  22153. function createFind(eachFunc, fromRight) {
  22154. return function(collection, predicate, thisArg) {
  22155. predicate = baseCallback(predicate, thisArg, 3);
  22156. if (isArray(collection)) {
  22157. var index = baseFindIndex(collection, predicate, fromRight);
  22158. return index > -1 ? collection[index] : undefined;
  22159. }
  22160. return baseFind(collection, predicate, eachFunc);
  22161. };
  22162. }
  22163. module.exports = createFind;
  22164. },{"105":105,"106":106,"159":159,"98":98}],137:[function(_dereq_,module,exports){
  22165. var bindCallback = _dereq_(128),
  22166. isArray = _dereq_(159);
  22167. /**
  22168. * Creates a function for `_.forEach` or `_.forEachRight`.
  22169. *
  22170. * @private
  22171. * @param {Function} arrayFunc The function to iterate over an array.
  22172. * @param {Function} eachFunc The function to iterate over a collection.
  22173. * @returns {Function} Returns the new each function.
  22174. */
  22175. function createForEach(arrayFunc, eachFunc) {
  22176. return function(collection, iteratee, thisArg) {
  22177. return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
  22178. ? arrayFunc(collection, iteratee)
  22179. : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
  22180. };
  22181. }
  22182. module.exports = createForEach;
  22183. },{"128":128,"159":159}],138:[function(_dereq_,module,exports){
  22184. var baseCallback = _dereq_(98),
  22185. baseReduce = _dereq_(123),
  22186. isArray = _dereq_(159);
  22187. /**
  22188. * Creates a function for `_.reduce` or `_.reduceRight`.
  22189. *
  22190. * @private
  22191. * @param {Function} arrayFunc The function to iterate over an array.
  22192. * @param {Function} eachFunc The function to iterate over a collection.
  22193. * @returns {Function} Returns the new each function.
  22194. */
  22195. function createReduce(arrayFunc, eachFunc) {
  22196. return function(collection, iteratee, accumulator, thisArg) {
  22197. var initFromArray = arguments.length < 3;
  22198. return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
  22199. ? arrayFunc(collection, iteratee, accumulator, initFromArray)
  22200. : baseReduce(collection, baseCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc);
  22201. };
  22202. }
  22203. module.exports = createReduce;
  22204. },{"123":123,"159":159,"98":98}],139:[function(_dereq_,module,exports){
  22205. var arraySome = _dereq_(95);
  22206. /**
  22207. * A specialized version of `baseIsEqualDeep` for arrays with support for
  22208. * partial deep comparisons.
  22209. *
  22210. * @private
  22211. * @param {Array} array The array to compare.
  22212. * @param {Array} other The other array to compare.
  22213. * @param {Function} equalFunc The function to determine equivalents of values.
  22214. * @param {Function} [customizer] The function to customize comparing arrays.
  22215. * @param {boolean} [isLoose] Specify performing partial comparisons.
  22216. * @param {Array} [stackA] Tracks traversed `value` objects.
  22217. * @param {Array} [stackB] Tracks traversed `other` objects.
  22218. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  22219. */
  22220. function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
  22221. var index = -1,
  22222. arrLength = array.length,
  22223. othLength = other.length;
  22224. if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
  22225. return false;
  22226. }
  22227. // Ignore non-index properties.
  22228. while (++index < arrLength) {
  22229. var arrValue = array[index],
  22230. othValue = other[index],
  22231. result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;
  22232. if (result !== undefined) {
  22233. if (result) {
  22234. continue;
  22235. }
  22236. return false;
  22237. }
  22238. // Recursively compare arrays (susceptible to call stack limits).
  22239. if (isLoose) {
  22240. if (!arraySome(other, function(othValue) {
  22241. return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
  22242. })) {
  22243. return false;
  22244. }
  22245. } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) {
  22246. return false;
  22247. }
  22248. }
  22249. return true;
  22250. }
  22251. module.exports = equalArrays;
  22252. },{"95":95}],140:[function(_dereq_,module,exports){
  22253. /** `Object#toString` result references. */
  22254. var boolTag = '[object Boolean]',
  22255. dateTag = '[object Date]',
  22256. errorTag = '[object Error]',
  22257. numberTag = '[object Number]',
  22258. regexpTag = '[object RegExp]',
  22259. stringTag = '[object String]';
  22260. /**
  22261. * A specialized version of `baseIsEqualDeep` for comparing objects of
  22262. * the same `toStringTag`.
  22263. *
  22264. * **Note:** This function only supports comparing values with tags of
  22265. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  22266. *
  22267. * @private
  22268. * @param {Object} object The object to compare.
  22269. * @param {Object} other The other object to compare.
  22270. * @param {string} tag The `toStringTag` of the objects to compare.
  22271. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22272. */
  22273. function equalByTag(object, other, tag) {
  22274. switch (tag) {
  22275. case boolTag:
  22276. case dateTag:
  22277. // Coerce dates and booleans to numbers, dates to milliseconds and booleans
  22278. // to `1` or `0` treating invalid dates coerced to `NaN` as not equal.
  22279. return +object == +other;
  22280. case errorTag:
  22281. return object.name == other.name && object.message == other.message;
  22282. case numberTag:
  22283. // Treat `NaN` vs. `NaN` as equal.
  22284. return (object != +object)
  22285. ? other != +other
  22286. : object == +other;
  22287. case regexpTag:
  22288. case stringTag:
  22289. // Coerce regexes to strings and treat strings primitives and string
  22290. // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
  22291. return object == (other + '');
  22292. }
  22293. return false;
  22294. }
  22295. module.exports = equalByTag;
  22296. },{}],141:[function(_dereq_,module,exports){
  22297. var keys = _dereq_(169);
  22298. /** Used for native method references. */
  22299. var objectProto = Object.prototype;
  22300. /** Used to check objects for own properties. */
  22301. var hasOwnProperty = objectProto.hasOwnProperty;
  22302. /**
  22303. * A specialized version of `baseIsEqualDeep` for objects with support for
  22304. * partial deep comparisons.
  22305. *
  22306. * @private
  22307. * @param {Object} object The object to compare.
  22308. * @param {Object} other The other object to compare.
  22309. * @param {Function} equalFunc The function to determine equivalents of values.
  22310. * @param {Function} [customizer] The function to customize comparing values.
  22311. * @param {boolean} [isLoose] Specify performing partial comparisons.
  22312. * @param {Array} [stackA] Tracks traversed `value` objects.
  22313. * @param {Array} [stackB] Tracks traversed `other` objects.
  22314. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22315. */
  22316. function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
  22317. var objProps = keys(object),
  22318. objLength = objProps.length,
  22319. othProps = keys(other),
  22320. othLength = othProps.length;
  22321. if (objLength != othLength && !isLoose) {
  22322. return false;
  22323. }
  22324. var index = objLength;
  22325. while (index--) {
  22326. var key = objProps[index];
  22327. if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {
  22328. return false;
  22329. }
  22330. }
  22331. var skipCtor = isLoose;
  22332. while (++index < objLength) {
  22333. key = objProps[index];
  22334. var objValue = object[key],
  22335. othValue = other[key],
  22336. result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined;
  22337. // Recursively compare objects (susceptible to call stack limits).
  22338. if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) {
  22339. return false;
  22340. }
  22341. skipCtor || (skipCtor = key == 'constructor');
  22342. }
  22343. if (!skipCtor) {
  22344. var objCtor = object.constructor,
  22345. othCtor = other.constructor;
  22346. // Non `Object` object instances with different constructors are not equal.
  22347. if (objCtor != othCtor &&
  22348. ('constructor' in object && 'constructor' in other) &&
  22349. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  22350. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  22351. return false;
  22352. }
  22353. }
  22354. return true;
  22355. }
  22356. module.exports = equalObjects;
  22357. },{"169":169}],142:[function(_dereq_,module,exports){
  22358. var baseProperty = _dereq_(121);
  22359. /**
  22360. * Gets the "length" property value of `object`.
  22361. *
  22362. * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
  22363. * that affects Safari on at least iOS 8.1-8.3 ARM64.
  22364. *
  22365. * @private
  22366. * @param {Object} object The object to query.
  22367. * @returns {*} Returns the "length" value.
  22368. */
  22369. var getLength = baseProperty('length');
  22370. module.exports = getLength;
  22371. },{"121":121}],143:[function(_dereq_,module,exports){
  22372. var isStrictComparable = _dereq_(152),
  22373. pairs = _dereq_(173);
  22374. /**
  22375. * Gets the propery names, values, and compare flags of `object`.
  22376. *
  22377. * @private
  22378. * @param {Object} object The object to query.
  22379. * @returns {Array} Returns the match data of `object`.
  22380. */
  22381. function getMatchData(object) {
  22382. var result = pairs(object),
  22383. length = result.length;
  22384. while (length--) {
  22385. result[length][2] = isStrictComparable(result[length][1]);
  22386. }
  22387. return result;
  22388. }
  22389. module.exports = getMatchData;
  22390. },{"152":152,"173":173}],144:[function(_dereq_,module,exports){
  22391. var isNative = _dereq_(161);
  22392. /**
  22393. * Gets the native function at `key` of `object`.
  22394. *
  22395. * @private
  22396. * @param {Object} object The object to query.
  22397. * @param {string} key The key of the method to get.
  22398. * @returns {*} Returns the function if it's native, else `undefined`.
  22399. */
  22400. function getNative(object, key) {
  22401. var value = object == null ? undefined : object[key];
  22402. return isNative(value) ? value : undefined;
  22403. }
  22404. module.exports = getNative;
  22405. },{"161":161}],145:[function(_dereq_,module,exports){
  22406. /**
  22407. * Gets the index at which the first occurrence of `NaN` is found in `array`.
  22408. *
  22409. * @private
  22410. * @param {Array} array The array to search.
  22411. * @param {number} fromIndex The index to search from.
  22412. * @param {boolean} [fromRight] Specify iterating from right to left.
  22413. * @returns {number} Returns the index of the matched `NaN`, else `-1`.
  22414. */
  22415. function indexOfNaN(array, fromIndex, fromRight) {
  22416. var length = array.length,
  22417. index = fromIndex + (fromRight ? 0 : -1);
  22418. while ((fromRight ? index-- : ++index < length)) {
  22419. var other = array[index];
  22420. if (other !== other) {
  22421. return index;
  22422. }
  22423. }
  22424. return -1;
  22425. }
  22426. module.exports = indexOfNaN;
  22427. },{}],146:[function(_dereq_,module,exports){
  22428. var getLength = _dereq_(142),
  22429. isLength = _dereq_(150);
  22430. /**
  22431. * Checks if `value` is array-like.
  22432. *
  22433. * @private
  22434. * @param {*} value The value to check.
  22435. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  22436. */
  22437. function isArrayLike(value) {
  22438. return value != null && isLength(getLength(value));
  22439. }
  22440. module.exports = isArrayLike;
  22441. },{"142":142,"150":150}],147:[function(_dereq_,module,exports){
  22442. /** Used to detect unsigned integer values. */
  22443. var reIsUint = /^\d+$/;
  22444. /**
  22445. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  22446. * of an array-like value.
  22447. */
  22448. var MAX_SAFE_INTEGER = 9007199254740991;
  22449. /**
  22450. * Checks if `value` is a valid array-like index.
  22451. *
  22452. * @private
  22453. * @param {*} value The value to check.
  22454. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  22455. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  22456. */
  22457. function isIndex(value, length) {
  22458. value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
  22459. length = length == null ? MAX_SAFE_INTEGER : length;
  22460. return value > -1 && value % 1 == 0 && value < length;
  22461. }
  22462. module.exports = isIndex;
  22463. },{}],148:[function(_dereq_,module,exports){
  22464. var isArrayLike = _dereq_(146),
  22465. isIndex = _dereq_(147),
  22466. isObject = _dereq_(163);
  22467. /**
  22468. * Checks if the provided arguments are from an iteratee call.
  22469. *
  22470. * @private
  22471. * @param {*} value The potential iteratee value argument.
  22472. * @param {*} index The potential iteratee index or key argument.
  22473. * @param {*} object The potential iteratee object argument.
  22474. * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
  22475. */
  22476. function isIterateeCall(value, index, object) {
  22477. if (!isObject(object)) {
  22478. return false;
  22479. }
  22480. var type = typeof index;
  22481. if (type == 'number'
  22482. ? (isArrayLike(object) && isIndex(index, object.length))
  22483. : (type == 'string' && index in object)) {
  22484. var other = object[index];
  22485. return value === value ? (value === other) : (other !== other);
  22486. }
  22487. return false;
  22488. }
  22489. module.exports = isIterateeCall;
  22490. },{"146":146,"147":147,"163":163}],149:[function(_dereq_,module,exports){
  22491. var isArray = _dereq_(159),
  22492. toObject = _dereq_(156);
  22493. /** Used to match property names within property paths. */
  22494. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,
  22495. reIsPlainProp = /^\w*$/;
  22496. /**
  22497. * Checks if `value` is a property name and not a property path.
  22498. *
  22499. * @private
  22500. * @param {*} value The value to check.
  22501. * @param {Object} [object] The object to query keys on.
  22502. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  22503. */
  22504. function isKey(value, object) {
  22505. var type = typeof value;
  22506. if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {
  22507. return true;
  22508. }
  22509. if (isArray(value)) {
  22510. return false;
  22511. }
  22512. var result = !reIsDeepProp.test(value);
  22513. return result || (object != null && value in toObject(object));
  22514. }
  22515. module.exports = isKey;
  22516. },{"156":156,"159":159}],150:[function(_dereq_,module,exports){
  22517. /**
  22518. * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
  22519. * of an array-like value.
  22520. */
  22521. var MAX_SAFE_INTEGER = 9007199254740991;
  22522. /**
  22523. * Checks if `value` is a valid array-like length.
  22524. *
  22525. * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
  22526. *
  22527. * @private
  22528. * @param {*} value The value to check.
  22529. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  22530. */
  22531. function isLength(value) {
  22532. return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  22533. }
  22534. module.exports = isLength;
  22535. },{}],151:[function(_dereq_,module,exports){
  22536. /**
  22537. * Checks if `value` is object-like.
  22538. *
  22539. * @private
  22540. * @param {*} value The value to check.
  22541. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  22542. */
  22543. function isObjectLike(value) {
  22544. return !!value && typeof value == 'object';
  22545. }
  22546. module.exports = isObjectLike;
  22547. },{}],152:[function(_dereq_,module,exports){
  22548. var isObject = _dereq_(163);
  22549. /**
  22550. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  22551. *
  22552. * @private
  22553. * @param {*} value The value to check.
  22554. * @returns {boolean} Returns `true` if `value` if suitable for strict
  22555. * equality comparisons, else `false`.
  22556. */
  22557. function isStrictComparable(value) {
  22558. return value === value && !isObject(value);
  22559. }
  22560. module.exports = isStrictComparable;
  22561. },{"163":163}],153:[function(_dereq_,module,exports){
  22562. var toObject = _dereq_(156);
  22563. /**
  22564. * A specialized version of `_.pick` which picks `object` properties specified
  22565. * by `props`.
  22566. *
  22567. * @private
  22568. * @param {Object} object The source object.
  22569. * @param {string[]} props The property names to pick.
  22570. * @returns {Object} Returns the new object.
  22571. */
  22572. function pickByArray(object, props) {
  22573. object = toObject(object);
  22574. var index = -1,
  22575. length = props.length,
  22576. result = {};
  22577. while (++index < length) {
  22578. var key = props[index];
  22579. if (key in object) {
  22580. result[key] = object[key];
  22581. }
  22582. }
  22583. return result;
  22584. }
  22585. module.exports = pickByArray;
  22586. },{"156":156}],154:[function(_dereq_,module,exports){
  22587. var baseForIn = _dereq_(109);
  22588. /**
  22589. * A specialized version of `_.pick` which picks `object` properties `predicate`
  22590. * returns truthy for.
  22591. *
  22592. * @private
  22593. * @param {Object} object The source object.
  22594. * @param {Function} predicate The function invoked per iteration.
  22595. * @returns {Object} Returns the new object.
  22596. */
  22597. function pickByCallback(object, predicate) {
  22598. var result = {};
  22599. baseForIn(object, function(value, key, object) {
  22600. if (predicate(value, key, object)) {
  22601. result[key] = value;
  22602. }
  22603. });
  22604. return result;
  22605. }
  22606. module.exports = pickByCallback;
  22607. },{"109":109}],155:[function(_dereq_,module,exports){
  22608. var isArguments = _dereq_(158),
  22609. isArray = _dereq_(159),
  22610. isIndex = _dereq_(147),
  22611. isLength = _dereq_(150),
  22612. keysIn = _dereq_(170);
  22613. /** Used for native method references. */
  22614. var objectProto = Object.prototype;
  22615. /** Used to check objects for own properties. */
  22616. var hasOwnProperty = objectProto.hasOwnProperty;
  22617. /**
  22618. * A fallback implementation of `Object.keys` which creates an array of the
  22619. * own enumerable property names of `object`.
  22620. *
  22621. * @private
  22622. * @param {Object} object The object to query.
  22623. * @returns {Array} Returns the array of property names.
  22624. */
  22625. function shimKeys(object) {
  22626. var props = keysIn(object),
  22627. propsLength = props.length,
  22628. length = propsLength && object.length;
  22629. var allowIndexes = !!length && isLength(length) &&
  22630. (isArray(object) || isArguments(object));
  22631. var index = -1,
  22632. result = [];
  22633. while (++index < propsLength) {
  22634. var key = props[index];
  22635. if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
  22636. result.push(key);
  22637. }
  22638. }
  22639. return result;
  22640. }
  22641. module.exports = shimKeys;
  22642. },{"147":147,"150":150,"158":158,"159":159,"170":170}],156:[function(_dereq_,module,exports){
  22643. var isObject = _dereq_(163);
  22644. /**
  22645. * Converts `value` to an object if it's not one.
  22646. *
  22647. * @private
  22648. * @param {*} value The value to process.
  22649. * @returns {Object} Returns the object.
  22650. */
  22651. function toObject(value) {
  22652. return isObject(value) ? value : Object(value);
  22653. }
  22654. module.exports = toObject;
  22655. },{"163":163}],157:[function(_dereq_,module,exports){
  22656. var baseToString = _dereq_(126),
  22657. isArray = _dereq_(159);
  22658. /** Used to match property names within property paths. */
  22659. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
  22660. /** Used to match backslashes in property paths. */
  22661. var reEscapeChar = /\\(\\)?/g;
  22662. /**
  22663. * Converts `value` to property path array if it's not one.
  22664. *
  22665. * @private
  22666. * @param {*} value The value to process.
  22667. * @returns {Array} Returns the property path array.
  22668. */
  22669. function toPath(value) {
  22670. if (isArray(value)) {
  22671. return value;
  22672. }
  22673. var result = [];
  22674. baseToString(value).replace(rePropName, function(match, number, quote, string) {
  22675. result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
  22676. });
  22677. return result;
  22678. }
  22679. module.exports = toPath;
  22680. },{"126":126,"159":159}],158:[function(_dereq_,module,exports){
  22681. var isArrayLike = _dereq_(146),
  22682. isObjectLike = _dereq_(151);
  22683. /** Used for native method references. */
  22684. var objectProto = Object.prototype;
  22685. /** Used to check objects for own properties. */
  22686. var hasOwnProperty = objectProto.hasOwnProperty;
  22687. /** Native method references. */
  22688. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  22689. /**
  22690. * Checks if `value` is classified as an `arguments` object.
  22691. *
  22692. * @static
  22693. * @memberOf _
  22694. * @category Lang
  22695. * @param {*} value The value to check.
  22696. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  22697. * @example
  22698. *
  22699. * _.isArguments(function() { return arguments; }());
  22700. * // => true
  22701. *
  22702. * _.isArguments([1, 2, 3]);
  22703. * // => false
  22704. */
  22705. function isArguments(value) {
  22706. return isObjectLike(value) && isArrayLike(value) &&
  22707. hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
  22708. }
  22709. module.exports = isArguments;
  22710. },{"146":146,"151":151}],159:[function(_dereq_,module,exports){
  22711. var getNative = _dereq_(144),
  22712. isLength = _dereq_(150),
  22713. isObjectLike = _dereq_(151);
  22714. /** `Object#toString` result references. */
  22715. var arrayTag = '[object Array]';
  22716. /** Used for native method references. */
  22717. var objectProto = Object.prototype;
  22718. /**
  22719. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  22720. * of values.
  22721. */
  22722. var objToString = objectProto.toString;
  22723. /* Native method references for those with the same name as other `lodash` methods. */
  22724. var nativeIsArray = getNative(Array, 'isArray');
  22725. /**
  22726. * Checks if `value` is classified as an `Array` object.
  22727. *
  22728. * @static
  22729. * @memberOf _
  22730. * @category Lang
  22731. * @param {*} value The value to check.
  22732. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  22733. * @example
  22734. *
  22735. * _.isArray([1, 2, 3]);
  22736. * // => true
  22737. *
  22738. * _.isArray(function() { return arguments; }());
  22739. * // => false
  22740. */
  22741. var isArray = nativeIsArray || function(value) {
  22742. return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
  22743. };
  22744. module.exports = isArray;
  22745. },{"144":144,"150":150,"151":151}],160:[function(_dereq_,module,exports){
  22746. var isObject = _dereq_(163);
  22747. /** `Object#toString` result references. */
  22748. var funcTag = '[object Function]';
  22749. /** Used for native method references. */
  22750. var objectProto = Object.prototype;
  22751. /**
  22752. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  22753. * of values.
  22754. */
  22755. var objToString = objectProto.toString;
  22756. /**
  22757. * Checks if `value` is classified as a `Function` object.
  22758. *
  22759. * @static
  22760. * @memberOf _
  22761. * @category Lang
  22762. * @param {*} value The value to check.
  22763. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  22764. * @example
  22765. *
  22766. * _.isFunction(_);
  22767. * // => true
  22768. *
  22769. * _.isFunction(/abc/);
  22770. * // => false
  22771. */
  22772. function isFunction(value) {
  22773. // The use of `Object#toString` avoids issues with the `typeof` operator
  22774. // in older versions of Chrome and Safari which return 'function' for regexes
  22775. // and Safari 8 which returns 'object' for typed array constructors.
  22776. return isObject(value) && objToString.call(value) == funcTag;
  22777. }
  22778. module.exports = isFunction;
  22779. },{"163":163}],161:[function(_dereq_,module,exports){
  22780. var isFunction = _dereq_(160),
  22781. isObjectLike = _dereq_(151);
  22782. /** Used to detect host constructors (Safari > 5). */
  22783. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  22784. /** Used for native method references. */
  22785. var objectProto = Object.prototype;
  22786. /** Used to resolve the decompiled source of functions. */
  22787. var fnToString = Function.prototype.toString;
  22788. /** Used to check objects for own properties. */
  22789. var hasOwnProperty = objectProto.hasOwnProperty;
  22790. /** Used to detect if a method is native. */
  22791. var reIsNative = RegExp('^' +
  22792. fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
  22793. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  22794. );
  22795. /**
  22796. * Checks if `value` is a native function.
  22797. *
  22798. * @static
  22799. * @memberOf _
  22800. * @category Lang
  22801. * @param {*} value The value to check.
  22802. * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
  22803. * @example
  22804. *
  22805. * _.isNative(Array.prototype.push);
  22806. * // => true
  22807. *
  22808. * _.isNative(_);
  22809. * // => false
  22810. */
  22811. function isNative(value) {
  22812. if (value == null) {
  22813. return false;
  22814. }
  22815. if (isFunction(value)) {
  22816. return reIsNative.test(fnToString.call(value));
  22817. }
  22818. return isObjectLike(value) && reIsHostCtor.test(value);
  22819. }
  22820. module.exports = isNative;
  22821. },{"151":151,"160":160}],162:[function(_dereq_,module,exports){
  22822. var isObjectLike = _dereq_(151);
  22823. /** `Object#toString` result references. */
  22824. var numberTag = '[object Number]';
  22825. /** Used for native method references. */
  22826. var objectProto = Object.prototype;
  22827. /**
  22828. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  22829. * of values.
  22830. */
  22831. var objToString = objectProto.toString;
  22832. /**
  22833. * Checks if `value` is classified as a `Number` primitive or object.
  22834. *
  22835. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified
  22836. * as numbers, use the `_.isFinite` method.
  22837. *
  22838. * @static
  22839. * @memberOf _
  22840. * @category Lang
  22841. * @param {*} value The value to check.
  22842. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  22843. * @example
  22844. *
  22845. * _.isNumber(8.4);
  22846. * // => true
  22847. *
  22848. * _.isNumber(NaN);
  22849. * // => true
  22850. *
  22851. * _.isNumber('8.4');
  22852. * // => false
  22853. */
  22854. function isNumber(value) {
  22855. return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);
  22856. }
  22857. module.exports = isNumber;
  22858. },{"151":151}],163:[function(_dereq_,module,exports){
  22859. /**
  22860. * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
  22861. * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  22862. *
  22863. * @static
  22864. * @memberOf _
  22865. * @category Lang
  22866. * @param {*} value The value to check.
  22867. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  22868. * @example
  22869. *
  22870. * _.isObject({});
  22871. * // => true
  22872. *
  22873. * _.isObject([1, 2, 3]);
  22874. * // => true
  22875. *
  22876. * _.isObject(1);
  22877. * // => false
  22878. */
  22879. function isObject(value) {
  22880. // Avoid a V8 JIT bug in Chrome 19-20.
  22881. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  22882. var type = typeof value;
  22883. return !!value && (type == 'object' || type == 'function');
  22884. }
  22885. module.exports = isObject;
  22886. },{}],164:[function(_dereq_,module,exports){
  22887. var baseForIn = _dereq_(109),
  22888. isArguments = _dereq_(158),
  22889. isObjectLike = _dereq_(151);
  22890. /** `Object#toString` result references. */
  22891. var objectTag = '[object Object]';
  22892. /** Used for native method references. */
  22893. var objectProto = Object.prototype;
  22894. /** Used to check objects for own properties. */
  22895. var hasOwnProperty = objectProto.hasOwnProperty;
  22896. /**
  22897. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  22898. * of values.
  22899. */
  22900. var objToString = objectProto.toString;
  22901. /**
  22902. * Checks if `value` is a plain object, that is, an object created by the
  22903. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  22904. *
  22905. * **Note:** This method assumes objects created by the `Object` constructor
  22906. * have no inherited enumerable properties.
  22907. *
  22908. * @static
  22909. * @memberOf _
  22910. * @category Lang
  22911. * @param {*} value The value to check.
  22912. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  22913. * @example
  22914. *
  22915. * function Foo() {
  22916. * this.a = 1;
  22917. * }
  22918. *
  22919. * _.isPlainObject(new Foo);
  22920. * // => false
  22921. *
  22922. * _.isPlainObject([1, 2, 3]);
  22923. * // => false
  22924. *
  22925. * _.isPlainObject({ 'x': 0, 'y': 0 });
  22926. * // => true
  22927. *
  22928. * _.isPlainObject(Object.create(null));
  22929. * // => true
  22930. */
  22931. function isPlainObject(value) {
  22932. var Ctor;
  22933. // Exit early for non `Object` objects.
  22934. if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) ||
  22935. (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
  22936. return false;
  22937. }
  22938. // IE < 9 iterates inherited properties before own properties. If the first
  22939. // iterated property is an object's own property then there are no inherited
  22940. // enumerable properties.
  22941. var result;
  22942. // In most environments an object's own properties are iterated before
  22943. // its inherited properties. If the last iterated property is an object's
  22944. // own property then there are no inherited enumerable properties.
  22945. baseForIn(value, function(subValue, key) {
  22946. result = key;
  22947. });
  22948. return result === undefined || hasOwnProperty.call(value, result);
  22949. }
  22950. module.exports = isPlainObject;
  22951. },{"109":109,"151":151,"158":158}],165:[function(_dereq_,module,exports){
  22952. var isObjectLike = _dereq_(151);
  22953. /** `Object#toString` result references. */
  22954. var stringTag = '[object String]';
  22955. /** Used for native method references. */
  22956. var objectProto = Object.prototype;
  22957. /**
  22958. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  22959. * of values.
  22960. */
  22961. var objToString = objectProto.toString;
  22962. /**
  22963. * Checks if `value` is classified as a `String` primitive or object.
  22964. *
  22965. * @static
  22966. * @memberOf _
  22967. * @category Lang
  22968. * @param {*} value The value to check.
  22969. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  22970. * @example
  22971. *
  22972. * _.isString('abc');
  22973. * // => true
  22974. *
  22975. * _.isString(1);
  22976. * // => false
  22977. */
  22978. function isString(value) {
  22979. return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
  22980. }
  22981. module.exports = isString;
  22982. },{"151":151}],166:[function(_dereq_,module,exports){
  22983. var isLength = _dereq_(150),
  22984. isObjectLike = _dereq_(151);
  22985. /** `Object#toString` result references. */
  22986. var argsTag = '[object Arguments]',
  22987. arrayTag = '[object Array]',
  22988. boolTag = '[object Boolean]',
  22989. dateTag = '[object Date]',
  22990. errorTag = '[object Error]',
  22991. funcTag = '[object Function]',
  22992. mapTag = '[object Map]',
  22993. numberTag = '[object Number]',
  22994. objectTag = '[object Object]',
  22995. regexpTag = '[object RegExp]',
  22996. setTag = '[object Set]',
  22997. stringTag = '[object String]',
  22998. weakMapTag = '[object WeakMap]';
  22999. var arrayBufferTag = '[object ArrayBuffer]',
  23000. float32Tag = '[object Float32Array]',
  23001. float64Tag = '[object Float64Array]',
  23002. int8Tag = '[object Int8Array]',
  23003. int16Tag = '[object Int16Array]',
  23004. int32Tag = '[object Int32Array]',
  23005. uint8Tag = '[object Uint8Array]',
  23006. uint8ClampedTag = '[object Uint8ClampedArray]',
  23007. uint16Tag = '[object Uint16Array]',
  23008. uint32Tag = '[object Uint32Array]';
  23009. /** Used to identify `toStringTag` values of typed arrays. */
  23010. var typedArrayTags = {};
  23011. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  23012. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  23013. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  23014. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  23015. typedArrayTags[uint32Tag] = true;
  23016. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  23017. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  23018. typedArrayTags[dateTag] = typedArrayTags[errorTag] =
  23019. typedArrayTags[funcTag] = typedArrayTags[mapTag] =
  23020. typedArrayTags[numberTag] = typedArrayTags[objectTag] =
  23021. typedArrayTags[regexpTag] = typedArrayTags[setTag] =
  23022. typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
  23023. /** Used for native method references. */
  23024. var objectProto = Object.prototype;
  23025. /**
  23026. * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  23027. * of values.
  23028. */
  23029. var objToString = objectProto.toString;
  23030. /**
  23031. * Checks if `value` is classified as a typed array.
  23032. *
  23033. * @static
  23034. * @memberOf _
  23035. * @category Lang
  23036. * @param {*} value The value to check.
  23037. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  23038. * @example
  23039. *
  23040. * _.isTypedArray(new Uint8Array);
  23041. * // => true
  23042. *
  23043. * _.isTypedArray([]);
  23044. * // => false
  23045. */
  23046. function isTypedArray(value) {
  23047. return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
  23048. }
  23049. module.exports = isTypedArray;
  23050. },{"150":150,"151":151}],167:[function(_dereq_,module,exports){
  23051. var baseCopy = _dereq_(99),
  23052. keysIn = _dereq_(170);
  23053. /**
  23054. * Converts `value` to a plain object flattening inherited enumerable
  23055. * properties of `value` to own properties of the plain object.
  23056. *
  23057. * @static
  23058. * @memberOf _
  23059. * @category Lang
  23060. * @param {*} value The value to convert.
  23061. * @returns {Object} Returns the converted plain object.
  23062. * @example
  23063. *
  23064. * function Foo() {
  23065. * this.b = 2;
  23066. * }
  23067. *
  23068. * Foo.prototype.c = 3;
  23069. *
  23070. * _.assign({ 'a': 1 }, new Foo);
  23071. * // => { 'a': 1, 'b': 2 }
  23072. *
  23073. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  23074. * // => { 'a': 1, 'b': 2, 'c': 3 }
  23075. */
  23076. function toPlainObject(value) {
  23077. return baseCopy(value, keysIn(value));
  23078. }
  23079. module.exports = toPlainObject;
  23080. },{"170":170,"99":99}],168:[function(_dereq_,module,exports){
  23081. var assignWith = _dereq_(96),
  23082. baseAssign = _dereq_(97),
  23083. createAssigner = _dereq_(132);
  23084. /**
  23085. * Assigns own enumerable properties of source object(s) to the destination
  23086. * object. Subsequent sources overwrite property assignments of previous sources.
  23087. * If `customizer` is provided it's invoked to produce the assigned values.
  23088. * The `customizer` is bound to `thisArg` and invoked with five arguments:
  23089. * (objectValue, sourceValue, key, object, source).
  23090. *
  23091. * **Note:** This method mutates `object` and is based on
  23092. * [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign).
  23093. *
  23094. * @static
  23095. * @memberOf _
  23096. * @alias extend
  23097. * @category Object
  23098. * @param {Object} object The destination object.
  23099. * @param {...Object} [sources] The source objects.
  23100. * @param {Function} [customizer] The function to customize assigned values.
  23101. * @param {*} [thisArg] The `this` binding of `customizer`.
  23102. * @returns {Object} Returns `object`.
  23103. * @example
  23104. *
  23105. * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' });
  23106. * // => { 'user': 'fred', 'age': 40 }
  23107. *
  23108. * // using a customizer callback
  23109. * var defaults = _.partialRight(_.assign, function(value, other) {
  23110. * return _.isUndefined(value) ? other : value;
  23111. * });
  23112. *
  23113. * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
  23114. * // => { 'user': 'barney', 'age': 36 }
  23115. */
  23116. var assign = createAssigner(function(object, source, customizer) {
  23117. return customizer
  23118. ? assignWith(object, source, customizer)
  23119. : baseAssign(object, source);
  23120. });
  23121. module.exports = assign;
  23122. },{"132":132,"96":96,"97":97}],169:[function(_dereq_,module,exports){
  23123. var getNative = _dereq_(144),
  23124. isArrayLike = _dereq_(146),
  23125. isObject = _dereq_(163),
  23126. shimKeys = _dereq_(155);
  23127. /* Native method references for those with the same name as other `lodash` methods. */
  23128. var nativeKeys = getNative(Object, 'keys');
  23129. /**
  23130. * Creates an array of the own enumerable property names of `object`.
  23131. *
  23132. * **Note:** Non-object values are coerced to objects. See the
  23133. * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
  23134. * for more details.
  23135. *
  23136. * @static
  23137. * @memberOf _
  23138. * @category Object
  23139. * @param {Object} object The object to query.
  23140. * @returns {Array} Returns the array of property names.
  23141. * @example
  23142. *
  23143. * function Foo() {
  23144. * this.a = 1;
  23145. * this.b = 2;
  23146. * }
  23147. *
  23148. * Foo.prototype.c = 3;
  23149. *
  23150. * _.keys(new Foo);
  23151. * // => ['a', 'b'] (iteration order is not guaranteed)
  23152. *
  23153. * _.keys('hi');
  23154. * // => ['0', '1']
  23155. */
  23156. var keys = !nativeKeys ? shimKeys : function(object) {
  23157. var Ctor = object == null ? undefined : object.constructor;
  23158. if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
  23159. (typeof object != 'function' && isArrayLike(object))) {
  23160. return shimKeys(object);
  23161. }
  23162. return isObject(object) ? nativeKeys(object) : [];
  23163. };
  23164. module.exports = keys;
  23165. },{"144":144,"146":146,"155":155,"163":163}],170:[function(_dereq_,module,exports){
  23166. var isArguments = _dereq_(158),
  23167. isArray = _dereq_(159),
  23168. isIndex = _dereq_(147),
  23169. isLength = _dereq_(150),
  23170. isObject = _dereq_(163);
  23171. /** Used for native method references. */
  23172. var objectProto = Object.prototype;
  23173. /** Used to check objects for own properties. */
  23174. var hasOwnProperty = objectProto.hasOwnProperty;
  23175. /**
  23176. * Creates an array of the own and inherited enumerable property names of `object`.
  23177. *
  23178. * **Note:** Non-object values are coerced to objects.
  23179. *
  23180. * @static
  23181. * @memberOf _
  23182. * @category Object
  23183. * @param {Object} object The object to query.
  23184. * @returns {Array} Returns the array of property names.
  23185. * @example
  23186. *
  23187. * function Foo() {
  23188. * this.a = 1;
  23189. * this.b = 2;
  23190. * }
  23191. *
  23192. * Foo.prototype.c = 3;
  23193. *
  23194. * _.keysIn(new Foo);
  23195. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  23196. */
  23197. function keysIn(object) {
  23198. if (object == null) {
  23199. return [];
  23200. }
  23201. if (!isObject(object)) {
  23202. object = Object(object);
  23203. }
  23204. var length = object.length;
  23205. length = (length && isLength(length) &&
  23206. (isArray(object) || isArguments(object)) && length) || 0;
  23207. var Ctor = object.constructor,
  23208. index = -1,
  23209. isProto = typeof Ctor == 'function' && Ctor.prototype === object,
  23210. result = Array(length),
  23211. skipIndexes = length > 0;
  23212. while (++index < length) {
  23213. result[index] = (index + '');
  23214. }
  23215. for (var key in object) {
  23216. if (!(skipIndexes && isIndex(key, length)) &&
  23217. !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  23218. result.push(key);
  23219. }
  23220. }
  23221. return result;
  23222. }
  23223. module.exports = keysIn;
  23224. },{"147":147,"150":150,"158":158,"159":159,"163":163}],171:[function(_dereq_,module,exports){
  23225. var baseMerge = _dereq_(119),
  23226. createAssigner = _dereq_(132);
  23227. /**
  23228. * Recursively merges own enumerable properties of the source object(s), that
  23229. * don't resolve to `undefined` into the destination object. Subsequent sources
  23230. * overwrite property assignments of previous sources. If `customizer` is
  23231. * provided it's invoked to produce the merged values of the destination and
  23232. * source properties. If `customizer` returns `undefined` merging is handled
  23233. * by the method instead. The `customizer` is bound to `thisArg` and invoked
  23234. * with five arguments: (objectValue, sourceValue, key, object, source).
  23235. *
  23236. * @static
  23237. * @memberOf _
  23238. * @category Object
  23239. * @param {Object} object The destination object.
  23240. * @param {...Object} [sources] The source objects.
  23241. * @param {Function} [customizer] The function to customize assigned values.
  23242. * @param {*} [thisArg] The `this` binding of `customizer`.
  23243. * @returns {Object} Returns `object`.
  23244. * @example
  23245. *
  23246. * var users = {
  23247. * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
  23248. * };
  23249. *
  23250. * var ages = {
  23251. * 'data': [{ 'age': 36 }, { 'age': 40 }]
  23252. * };
  23253. *
  23254. * _.merge(users, ages);
  23255. * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
  23256. *
  23257. * // using a customizer callback
  23258. * var object = {
  23259. * 'fruits': ['apple'],
  23260. * 'vegetables': ['beet']
  23261. * };
  23262. *
  23263. * var other = {
  23264. * 'fruits': ['banana'],
  23265. * 'vegetables': ['carrot']
  23266. * };
  23267. *
  23268. * _.merge(object, other, function(a, b) {
  23269. * if (_.isArray(a)) {
  23270. * return a.concat(b);
  23271. * }
  23272. * });
  23273. * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
  23274. */
  23275. var merge = createAssigner(baseMerge);
  23276. module.exports = merge;
  23277. },{"119":119,"132":132}],172:[function(_dereq_,module,exports){
  23278. var arrayMap = _dereq_(92),
  23279. baseDifference = _dereq_(101),
  23280. baseFlatten = _dereq_(107),
  23281. bindCallback = _dereq_(128),
  23282. keysIn = _dereq_(170),
  23283. pickByArray = _dereq_(153),
  23284. pickByCallback = _dereq_(154),
  23285. restParam = _dereq_(86);
  23286. /**
  23287. * The opposite of `_.pick`; this method creates an object composed of the
  23288. * own and inherited enumerable properties of `object` that are not omitted.
  23289. *
  23290. * @static
  23291. * @memberOf _
  23292. * @category Object
  23293. * @param {Object} object The source object.
  23294. * @param {Function|...(string|string[])} [predicate] The function invoked per
  23295. * iteration or property names to omit, specified as individual property
  23296. * names or arrays of property names.
  23297. * @param {*} [thisArg] The `this` binding of `predicate`.
  23298. * @returns {Object} Returns the new object.
  23299. * @example
  23300. *
  23301. * var object = { 'user': 'fred', 'age': 40 };
  23302. *
  23303. * _.omit(object, 'age');
  23304. * // => { 'user': 'fred' }
  23305. *
  23306. * _.omit(object, _.isNumber);
  23307. * // => { 'user': 'fred' }
  23308. */
  23309. var omit = restParam(function(object, props) {
  23310. if (object == null) {
  23311. return {};
  23312. }
  23313. if (typeof props[0] != 'function') {
  23314. var props = arrayMap(baseFlatten(props), String);
  23315. return pickByArray(object, baseDifference(keysIn(object), props));
  23316. }
  23317. var predicate = bindCallback(props[0], props[1], 3);
  23318. return pickByCallback(object, function(value, key, object) {
  23319. return !predicate(value, key, object);
  23320. });
  23321. });
  23322. module.exports = omit;
  23323. },{"101":101,"107":107,"128":128,"153":153,"154":154,"170":170,"86":86,"92":92}],173:[function(_dereq_,module,exports){
  23324. var keys = _dereq_(169),
  23325. toObject = _dereq_(156);
  23326. /**
  23327. * Creates a two dimensional array of the key-value pairs for `object`,
  23328. * e.g. `[[key1, value1], [key2, value2]]`.
  23329. *
  23330. * @static
  23331. * @memberOf _
  23332. * @category Object
  23333. * @param {Object} object The object to query.
  23334. * @returns {Array} Returns the new array of key-value pairs.
  23335. * @example
  23336. *
  23337. * _.pairs({ 'barney': 36, 'fred': 40 });
  23338. * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)
  23339. */
  23340. function pairs(object) {
  23341. object = toObject(object);
  23342. var index = -1,
  23343. props = keys(object),
  23344. length = props.length,
  23345. result = Array(length);
  23346. while (++index < length) {
  23347. var key = props[index];
  23348. result[index] = [key, object[key]];
  23349. }
  23350. return result;
  23351. }
  23352. module.exports = pairs;
  23353. },{"156":156,"169":169}],174:[function(_dereq_,module,exports){
  23354. var baseFlatten = _dereq_(107),
  23355. bindCallback = _dereq_(128),
  23356. pickByArray = _dereq_(153),
  23357. pickByCallback = _dereq_(154),
  23358. restParam = _dereq_(86);
  23359. /**
  23360. * Creates an object composed of the picked `object` properties. Property
  23361. * names may be specified as individual arguments or as arrays of property
  23362. * names. If `predicate` is provided it's invoked for each property of `object`
  23363. * picking the properties `predicate` returns truthy for. The predicate is
  23364. * bound to `thisArg` and invoked with three arguments: (value, key, object).
  23365. *
  23366. * @static
  23367. * @memberOf _
  23368. * @category Object
  23369. * @param {Object} object The source object.
  23370. * @param {Function|...(string|string[])} [predicate] The function invoked per
  23371. * iteration or property names to pick, specified as individual property
  23372. * names or arrays of property names.
  23373. * @param {*} [thisArg] The `this` binding of `predicate`.
  23374. * @returns {Object} Returns the new object.
  23375. * @example
  23376. *
  23377. * var object = { 'user': 'fred', 'age': 40 };
  23378. *
  23379. * _.pick(object, 'user');
  23380. * // => { 'user': 'fred' }
  23381. *
  23382. * _.pick(object, _.isString);
  23383. * // => { 'user': 'fred' }
  23384. */
  23385. var pick = restParam(function(object, props) {
  23386. if (object == null) {
  23387. return {};
  23388. }
  23389. return typeof props[0] == 'function'
  23390. ? pickByCallback(object, bindCallback(props[0], props[1], 3))
  23391. : pickByArray(object, baseFlatten(props));
  23392. });
  23393. module.exports = pick;
  23394. },{"107":107,"128":128,"153":153,"154":154,"86":86}],175:[function(_dereq_,module,exports){
  23395. var baseValues = _dereq_(127),
  23396. keys = _dereq_(169);
  23397. /**
  23398. * Creates an array of the own enumerable property values of `object`.
  23399. *
  23400. * **Note:** Non-object values are coerced to objects.
  23401. *
  23402. * @static
  23403. * @memberOf _
  23404. * @category Object
  23405. * @param {Object} object The object to query.
  23406. * @returns {Array} Returns the array of property values.
  23407. * @example
  23408. *
  23409. * function Foo() {
  23410. * this.a = 1;
  23411. * this.b = 2;
  23412. * }
  23413. *
  23414. * Foo.prototype.c = 3;
  23415. *
  23416. * _.values(new Foo);
  23417. * // => [1, 2] (iteration order is not guaranteed)
  23418. *
  23419. * _.values('hi');
  23420. * // => ['h', 'i']
  23421. */
  23422. function values(object) {
  23423. return baseValues(object, keys(object));
  23424. }
  23425. module.exports = values;
  23426. },{"127":127,"169":169}],176:[function(_dereq_,module,exports){
  23427. /**
  23428. * This method returns the first argument provided to it.
  23429. *
  23430. * @static
  23431. * @memberOf _
  23432. * @category Utility
  23433. * @param {*} value Any value.
  23434. * @returns {*} Returns `value`.
  23435. * @example
  23436. *
  23437. * var object = { 'user': 'fred' };
  23438. *
  23439. * _.identity(object) === object;
  23440. * // => true
  23441. */
  23442. function identity(value) {
  23443. return value;
  23444. }
  23445. module.exports = identity;
  23446. },{}],177:[function(_dereq_,module,exports){
  23447. var baseProperty = _dereq_(121),
  23448. basePropertyDeep = _dereq_(122),
  23449. isKey = _dereq_(149);
  23450. /**
  23451. * Creates a function that returns the property value at `path` on a
  23452. * given object.
  23453. *
  23454. * @static
  23455. * @memberOf _
  23456. * @category Utility
  23457. * @param {Array|string} path The path of the property to get.
  23458. * @returns {Function} Returns the new function.
  23459. * @example
  23460. *
  23461. * var objects = [
  23462. * { 'a': { 'b': { 'c': 2 } } },
  23463. * { 'a': { 'b': { 'c': 1 } } }
  23464. * ];
  23465. *
  23466. * _.map(objects, _.property('a.b.c'));
  23467. * // => [2, 1]
  23468. *
  23469. * _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');
  23470. * // => [1, 2]
  23471. */
  23472. function property(path) {
  23473. return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
  23474. }
  23475. module.exports = property;
  23476. },{"121":121,"122":122,"149":149}],178:[function(_dereq_,module,exports){
  23477. module.exports = _dereq_(184);
  23478. },{"184":184}],179:[function(_dereq_,module,exports){
  23479. module.exports = function(el) {
  23480. var c;
  23481. while (el.childNodes.length) {
  23482. c = el.childNodes[0];
  23483. el.removeChild(c);
  23484. }
  23485. return el;
  23486. };
  23487. },{}],180:[function(_dereq_,module,exports){
  23488. module.exports = _dereq_(187);
  23489. },{"187":187}],181:[function(_dereq_,module,exports){
  23490. module.exports = _dereq_(191);
  23491. },{"191":191}],182:[function(_dereq_,module,exports){
  23492. module.exports = _dereq_(190);
  23493. },{"190":190}],183:[function(_dereq_,module,exports){
  23494. module.exports = function(el) {
  23495. el.parentNode && el.parentNode.removeChild(el);
  23496. };
  23497. },{}],184:[function(_dereq_,module,exports){
  23498. /**
  23499. * Module dependencies.
  23500. */
  23501. var index = _dereq_(185);
  23502. /**
  23503. * Whitespace regexp.
  23504. */
  23505. var re = /\s+/;
  23506. /**
  23507. * toString reference.
  23508. */
  23509. var toString = Object.prototype.toString;
  23510. /**
  23511. * Wrap `el` in a `ClassList`.
  23512. *
  23513. * @param {Element} el
  23514. * @return {ClassList}
  23515. * @api public
  23516. */
  23517. module.exports = function(el){
  23518. return new ClassList(el);
  23519. };
  23520. /**
  23521. * Initialize a new ClassList for `el`.
  23522. *
  23523. * @param {Element} el
  23524. * @api private
  23525. */
  23526. function ClassList(el) {
  23527. if (!el || !el.nodeType) {
  23528. throw new Error('A DOM element reference is required');
  23529. }
  23530. this.el = el;
  23531. this.list = el.classList;
  23532. }
  23533. /**
  23534. * Add class `name` if not already present.
  23535. *
  23536. * @param {String} name
  23537. * @return {ClassList}
  23538. * @api public
  23539. */
  23540. ClassList.prototype.add = function(name){
  23541. // classList
  23542. if (this.list) {
  23543. this.list.add(name);
  23544. return this;
  23545. }
  23546. // fallback
  23547. var arr = this.array();
  23548. var i = index(arr, name);
  23549. if (!~i) arr.push(name);
  23550. this.el.className = arr.join(' ');
  23551. return this;
  23552. };
  23553. /**
  23554. * Remove class `name` when present, or
  23555. * pass a regular expression to remove
  23556. * any which match.
  23557. *
  23558. * @param {String|RegExp} name
  23559. * @return {ClassList}
  23560. * @api public
  23561. */
  23562. ClassList.prototype.remove = function(name){
  23563. if ('[object RegExp]' == toString.call(name)) {
  23564. return this.removeMatching(name);
  23565. }
  23566. // classList
  23567. if (this.list) {
  23568. this.list.remove(name);
  23569. return this;
  23570. }
  23571. // fallback
  23572. var arr = this.array();
  23573. var i = index(arr, name);
  23574. if (~i) arr.splice(i, 1);
  23575. this.el.className = arr.join(' ');
  23576. return this;
  23577. };
  23578. /**
  23579. * Remove all classes matching `re`.
  23580. *
  23581. * @param {RegExp} re
  23582. * @return {ClassList}
  23583. * @api private
  23584. */
  23585. ClassList.prototype.removeMatching = function(re){
  23586. var arr = this.array();
  23587. for (var i = 0; i < arr.length; i++) {
  23588. if (re.test(arr[i])) {
  23589. this.remove(arr[i]);
  23590. }
  23591. }
  23592. return this;
  23593. };
  23594. /**
  23595. * Toggle class `name`, can force state via `force`.
  23596. *
  23597. * For browsers that support classList, but do not support `force` yet,
  23598. * the mistake will be detected and corrected.
  23599. *
  23600. * @param {String} name
  23601. * @param {Boolean} force
  23602. * @return {ClassList}
  23603. * @api public
  23604. */
  23605. ClassList.prototype.toggle = function(name, force){
  23606. // classList
  23607. if (this.list) {
  23608. if ("undefined" !== typeof force) {
  23609. if (force !== this.list.toggle(name, force)) {
  23610. this.list.toggle(name); // toggle again to correct
  23611. }
  23612. } else {
  23613. this.list.toggle(name);
  23614. }
  23615. return this;
  23616. }
  23617. // fallback
  23618. if ("undefined" !== typeof force) {
  23619. if (!force) {
  23620. this.remove(name);
  23621. } else {
  23622. this.add(name);
  23623. }
  23624. } else {
  23625. if (this.has(name)) {
  23626. this.remove(name);
  23627. } else {
  23628. this.add(name);
  23629. }
  23630. }
  23631. return this;
  23632. };
  23633. /**
  23634. * Return an array of classes.
  23635. *
  23636. * @return {Array}
  23637. * @api public
  23638. */
  23639. ClassList.prototype.array = function(){
  23640. var className = this.el.getAttribute('class') || '';
  23641. var str = className.replace(/^\s+|\s+$/g, '');
  23642. var arr = str.split(re);
  23643. if ('' === arr[0]) arr.shift();
  23644. return arr;
  23645. };
  23646. /**
  23647. * Check if class `name` is present.
  23648. *
  23649. * @param {String} name
  23650. * @return {ClassList}
  23651. * @api public
  23652. */
  23653. ClassList.prototype.has =
  23654. ClassList.prototype.contains = function(name){
  23655. return this.list
  23656. ? this.list.contains(name)
  23657. : !! ~index(this.array(), name);
  23658. };
  23659. },{"185":185}],185:[function(_dereq_,module,exports){
  23660. module.exports = function(arr, obj){
  23661. if (arr.indexOf) return arr.indexOf(obj);
  23662. for (var i = 0; i < arr.length; ++i) {
  23663. if (arr[i] === obj) return i;
  23664. }
  23665. return -1;
  23666. };
  23667. },{}],186:[function(_dereq_,module,exports){
  23668. var matches = _dereq_(189)
  23669. module.exports = function (element, selector, checkYoSelf, root) {
  23670. element = checkYoSelf ? {parentNode: element} : element
  23671. root = root || document
  23672. // Make sure `element !== document` and `element != null`
  23673. // otherwise we get an illegal invocation
  23674. while ((element = element.parentNode) && element !== document) {
  23675. if (matches(element, selector))
  23676. return element
  23677. // After `matches` on the edge case that
  23678. // the selector matches the root
  23679. // (when the root is not the document)
  23680. if (element === root)
  23681. return
  23682. }
  23683. }
  23684. },{"189":189}],187:[function(_dereq_,module,exports){
  23685. /**
  23686. * Module dependencies.
  23687. */
  23688. var closest = _dereq_(186)
  23689. , event = _dereq_(188);
  23690. /**
  23691. * Delegate event `type` to `selector`
  23692. * and invoke `fn(e)`. A callback function
  23693. * is returned which may be passed to `.unbind()`.
  23694. *
  23695. * @param {Element} el
  23696. * @param {String} selector
  23697. * @param {String} type
  23698. * @param {Function} fn
  23699. * @param {Boolean} capture
  23700. * @return {Function}
  23701. * @api public
  23702. */
  23703. exports.bind = function(el, selector, type, fn, capture){
  23704. return event.bind(el, type, function(e){
  23705. var target = e.target || e.srcElement;
  23706. e.delegateTarget = closest(target, selector, true, el);
  23707. if (e.delegateTarget) fn.call(el, e);
  23708. }, capture);
  23709. };
  23710. /**
  23711. * Unbind event `type`'s callback `fn`.
  23712. *
  23713. * @param {Element} el
  23714. * @param {String} type
  23715. * @param {Function} fn
  23716. * @param {Boolean} capture
  23717. * @api public
  23718. */
  23719. exports.unbind = function(el, type, fn, capture){
  23720. event.unbind(el, type, fn, capture);
  23721. };
  23722. },{"186":186,"188":188}],188:[function(_dereq_,module,exports){
  23723. var bind = window.addEventListener ? 'addEventListener' : 'attachEvent',
  23724. unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
  23725. prefix = bind !== 'addEventListener' ? 'on' : '';
  23726. /**
  23727. * Bind `el` event `type` to `fn`.
  23728. *
  23729. * @param {Element} el
  23730. * @param {String} type
  23731. * @param {Function} fn
  23732. * @param {Boolean} capture
  23733. * @return {Function}
  23734. * @api public
  23735. */
  23736. exports.bind = function(el, type, fn, capture){
  23737. el[bind](prefix + type, fn, capture || false);
  23738. return fn;
  23739. };
  23740. /**
  23741. * Unbind `el` event `type`'s callback `fn`.
  23742. *
  23743. * @param {Element} el
  23744. * @param {String} type
  23745. * @param {Function} fn
  23746. * @param {Boolean} capture
  23747. * @return {Function}
  23748. * @api public
  23749. */
  23750. exports.unbind = function(el, type, fn, capture){
  23751. el[unbind](prefix + type, fn, capture || false);
  23752. return fn;
  23753. };
  23754. },{}],189:[function(_dereq_,module,exports){
  23755. /**
  23756. * Module dependencies.
  23757. */
  23758. var query = _dereq_(190);
  23759. /**
  23760. * Element prototype.
  23761. */
  23762. var proto = Element.prototype;
  23763. /**
  23764. * Vendor function.
  23765. */
  23766. var vendor = proto.matches
  23767. || proto.webkitMatchesSelector
  23768. || proto.mozMatchesSelector
  23769. || proto.msMatchesSelector
  23770. || proto.oMatchesSelector;
  23771. /**
  23772. * Expose `match()`.
  23773. */
  23774. module.exports = match;
  23775. /**
  23776. * Match `el` to `selector`.
  23777. *
  23778. * @param {Element} el
  23779. * @param {String} selector
  23780. * @return {Boolean}
  23781. * @api public
  23782. */
  23783. function match(el, selector) {
  23784. if (!el || el.nodeType !== 1) return false;
  23785. if (vendor) return vendor.call(el, selector);
  23786. var nodes = query.all(selector, el.parentNode);
  23787. for (var i = 0; i < nodes.length; ++i) {
  23788. if (nodes[i] == el) return true;
  23789. }
  23790. return false;
  23791. }
  23792. },{"190":190}],190:[function(_dereq_,module,exports){
  23793. function one(selector, el) {
  23794. return el.querySelector(selector);
  23795. }
  23796. exports = module.exports = function(selector, el){
  23797. el = el || document;
  23798. return one(selector, el);
  23799. };
  23800. exports.all = function(selector, el){
  23801. el = el || document;
  23802. return el.querySelectorAll(selector);
  23803. };
  23804. exports.engine = function(obj){
  23805. if (!obj.one) throw new Error('.one callback required');
  23806. if (!obj.all) throw new Error('.all callback required');
  23807. one = obj.one;
  23808. exports.all = obj.all;
  23809. return exports;
  23810. };
  23811. },{}],191:[function(_dereq_,module,exports){
  23812. /**
  23813. * Expose `parse`.
  23814. */
  23815. module.exports = parse;
  23816. /**
  23817. * Tests for browser support.
  23818. */
  23819. var div = document.createElement('div');
  23820. // Setup
  23821. div.innerHTML = ' <link/><table></table><a href="/a">a</a><input type="checkbox"/>';
  23822. // Make sure that link elements get serialized correctly by innerHTML
  23823. // This requires a wrapper element in IE
  23824. var innerHTMLBug = !div.getElementsByTagName('link').length;
  23825. div = undefined;
  23826. /**
  23827. * Wrap map from jquery.
  23828. */
  23829. var map = {
  23830. legend: [1, '<fieldset>', '</fieldset>'],
  23831. tr: [2, '<table><tbody>', '</tbody></table>'],
  23832. col: [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
  23833. // for script/link/style tags to work in IE6-8, you have to wrap
  23834. // in a div with a non-whitespace character in front, ha!
  23835. _default: innerHTMLBug ? [1, 'X<div>', '</div>'] : [0, '', '']
  23836. };
  23837. map.td =
  23838. map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
  23839. map.option =
  23840. map.optgroup = [1, '<select multiple="multiple">', '</select>'];
  23841. map.thead =
  23842. map.tbody =
  23843. map.colgroup =
  23844. map.caption =
  23845. map.tfoot = [1, '<table>', '</table>'];
  23846. map.polyline =
  23847. map.ellipse =
  23848. map.polygon =
  23849. map.circle =
  23850. map.text =
  23851. map.line =
  23852. map.path =
  23853. map.rect =
  23854. map.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>'];
  23855. /**
  23856. * Parse `html` and return a DOM Node instance, which could be a TextNode,
  23857. * HTML DOM Node of some kind (<div> for example), or a DocumentFragment
  23858. * instance, depending on the contents of the `html` string.
  23859. *
  23860. * @param {String} html - HTML string to "domify"
  23861. * @param {Document} doc - The `document` instance to create the Node for
  23862. * @return {DOMNode} the TextNode, DOM Node, or DocumentFragment instance
  23863. * @api private
  23864. */
  23865. function parse(html, doc) {
  23866. if ('string' != typeof html) throw new TypeError('String expected');
  23867. // default to the global `document` object
  23868. if (!doc) doc = document;
  23869. // tag name
  23870. var m = /<([\w:]+)/.exec(html);
  23871. if (!m) return doc.createTextNode(html);
  23872. html = html.replace(/^\s+|\s+$/g, ''); // Remove leading/trailing whitespace
  23873. var tag = m[1];
  23874. // body support
  23875. if (tag == 'body') {
  23876. var el = doc.createElement('html');
  23877. el.innerHTML = html;
  23878. return el.removeChild(el.lastChild);
  23879. }
  23880. // wrap map
  23881. var wrap = map[tag] || map._default;
  23882. var depth = wrap[0];
  23883. var prefix = wrap[1];
  23884. var suffix = wrap[2];
  23885. var el = doc.createElement('div');
  23886. el.innerHTML = prefix + html + suffix;
  23887. while (depth--) el = el.lastChild;
  23888. // one element
  23889. if (el.firstChild == el.lastChild) {
  23890. return el.removeChild(el.firstChild);
  23891. }
  23892. // several elements
  23893. var fragment = doc.createDocumentFragment();
  23894. while (el.firstChild) {
  23895. fragment.appendChild(el.removeChild(el.firstChild));
  23896. }
  23897. return fragment;
  23898. }
  23899. },{}],192:[function(_dereq_,module,exports){
  23900. module.exports = _dereq_(194);
  23901. module.exports.Collection = _dereq_(193);
  23902. },{"193":193,"194":194}],193:[function(_dereq_,module,exports){
  23903. 'use strict';
  23904. /**
  23905. * An empty collection stub. Use {@link RefsCollection.extend} to extend a
  23906. * collection with ref semantics.
  23907. *
  23908. * @classdesc A change and inverse-reference aware collection with set semantics.
  23909. *
  23910. * @class RefsCollection
  23911. */
  23912. function RefsCollection() { }
  23913. /**
  23914. * Extends a collection with {@link Refs} aware methods
  23915. *
  23916. * @memberof RefsCollection
  23917. * @static
  23918. *
  23919. * @param {Array<Object>} collection
  23920. * @param {Refs} refs instance
  23921. * @param {Object} property represented by the collection
  23922. * @param {Object} target object the collection is attached to
  23923. *
  23924. * @return {RefsCollection<Object>} the extended array
  23925. */
  23926. function extend(collection, refs, property, target) {
  23927. var inverseProperty = property.inverse;
  23928. /**
  23929. * Removes the given element from the array and returns it.
  23930. *
  23931. * @method RefsCollection#remove
  23932. *
  23933. * @param {Object} element the element to remove
  23934. */
  23935. collection.remove = function(element) {
  23936. var idx = this.indexOf(element);
  23937. if (idx !== -1) {
  23938. this.splice(idx, 1);
  23939. // unset inverse
  23940. refs.unset(element, inverseProperty, target);
  23941. }
  23942. return element;
  23943. };
  23944. /**
  23945. * Returns true if the collection contains the given element
  23946. *
  23947. * @method RefsCollection#contains
  23948. *
  23949. * @param {Object} element the element to check for
  23950. */
  23951. collection.contains = function(element) {
  23952. return this.indexOf(element) !== -1;
  23953. };
  23954. /**
  23955. * Adds an element to the array, unless it exists already (set semantics).
  23956. *
  23957. * @method RefsCollection#add
  23958. *
  23959. * @param {Object} element the element to add
  23960. */
  23961. collection.add = function(element) {
  23962. if (!this.contains(element)) {
  23963. this.push(element);
  23964. // set inverse
  23965. refs.set(element, inverseProperty, target);
  23966. }
  23967. };
  23968. return collection;
  23969. }
  23970. module.exports.extend = extend;
  23971. },{}],194:[function(_dereq_,module,exports){
  23972. 'use strict';
  23973. var Collection = _dereq_(193);
  23974. function hasOwnProperty(e, property) {
  23975. return Object.prototype.hasOwnProperty.call(e, property.name || property);
  23976. }
  23977. function defineCollectionProperty(ref, property, target) {
  23978. Object.defineProperty(target, property.name, {
  23979. enumerable: property.enumerable,
  23980. value: Collection.extend(target[property.name] || [], ref, property, target)
  23981. });
  23982. }
  23983. function defineProperty(ref, property, target) {
  23984. var inverseProperty = property.inverse;
  23985. var _value = target[property.name];
  23986. Object.defineProperty(target, property.name, {
  23987. enumerable: property.enumerable,
  23988. get: function() {
  23989. return _value;
  23990. },
  23991. set: function(value) {
  23992. // return if we already performed all changes
  23993. if (value === _value) {
  23994. return;
  23995. }
  23996. var old = _value;
  23997. // temporary set null
  23998. _value = null;
  23999. if (old) {
  24000. ref.unset(old, inverseProperty, target);
  24001. }
  24002. // set new value
  24003. _value = value;
  24004. // set inverse value
  24005. ref.set(_value, inverseProperty, target);
  24006. }
  24007. });
  24008. }
  24009. /**
  24010. * Creates a new references object defining two inversly related
  24011. * attribute descriptors a and b.
  24012. *
  24013. * <p>
  24014. * When bound to an object using {@link Refs#bind} the references
  24015. * get activated and ensure that add and remove operations are applied
  24016. * reversely, too.
  24017. * </p>
  24018. *
  24019. * <p>
  24020. * For attributes represented as collections {@link Refs} provides the
  24021. * {@link RefsCollection#add}, {@link RefsCollection#remove} and {@link RefsCollection#contains} extensions
  24022. * that must be used to properly hook into the inverse change mechanism.
  24023. * </p>
  24024. *
  24025. * @class Refs
  24026. *
  24027. * @classdesc A bi-directional reference between two attributes.
  24028. *
  24029. * @param {Refs.AttributeDescriptor} a property descriptor
  24030. * @param {Refs.AttributeDescriptor} b property descriptor
  24031. *
  24032. * @example
  24033. *
  24034. * var refs = Refs({ name: 'wheels', collection: true, enumerable: true }, { name: 'car' });
  24035. *
  24036. * var car = { name: 'toyota' };
  24037. * var wheels = [{ pos: 'front-left' }, { pos: 'front-right' }];
  24038. *
  24039. * refs.bind(car, 'wheels');
  24040. *
  24041. * car.wheels // []
  24042. * car.wheels.add(wheels[0]);
  24043. * car.wheels.add(wheels[1]);
  24044. *
  24045. * car.wheels // [{ pos: 'front-left' }, { pos: 'front-right' }]
  24046. *
  24047. * wheels[0].car // { name: 'toyota' };
  24048. * car.wheels.remove(wheels[0]);
  24049. *
  24050. * wheels[0].car // undefined
  24051. */
  24052. function Refs(a, b) {
  24053. if (!(this instanceof Refs)) {
  24054. return new Refs(a, b);
  24055. }
  24056. // link
  24057. a.inverse = b;
  24058. b.inverse = a;
  24059. this.props = {};
  24060. this.props[a.name] = a;
  24061. this.props[b.name] = b;
  24062. }
  24063. /**
  24064. * Binds one side of a bi-directional reference to a
  24065. * target object.
  24066. *
  24067. * @memberOf Refs
  24068. *
  24069. * @param {Object} target
  24070. * @param {String} property
  24071. */
  24072. Refs.prototype.bind = function(target, property) {
  24073. if (typeof property === 'string') {
  24074. if (!this.props[property]) {
  24075. throw new Error('no property <' + property + '> in ref');
  24076. }
  24077. property = this.props[property];
  24078. }
  24079. if (property.collection) {
  24080. defineCollectionProperty(this, property, target);
  24081. } else {
  24082. defineProperty(this, property, target);
  24083. }
  24084. };
  24085. Refs.prototype.ensureBound = function(target, property) {
  24086. if (!hasOwnProperty(target, property)) {
  24087. this.bind(target, property);
  24088. }
  24089. };
  24090. Refs.prototype.unset = function(target, property, value) {
  24091. if (target) {
  24092. this.ensureBound(target, property);
  24093. if (property.collection) {
  24094. target[property.name].remove(value);
  24095. } else {
  24096. target[property.name] = undefined;
  24097. }
  24098. }
  24099. };
  24100. Refs.prototype.set = function(target, property, value) {
  24101. if (target) {
  24102. this.ensureBound(target, property);
  24103. if (property.collection) {
  24104. target[property.name].add(value);
  24105. } else {
  24106. target[property.name] = value;
  24107. }
  24108. }
  24109. };
  24110. module.exports = Refs;
  24111. /**
  24112. * An attribute descriptor to be used specify an attribute in a {@link Refs} instance
  24113. *
  24114. * @typedef {Object} Refs.AttributeDescriptor
  24115. * @property {String} name
  24116. * @property {boolean} [collection=false]
  24117. * @property {boolean} [enumerable=false]
  24118. */
  24119. },{"193":193}]},{},[1])(1)
  24120. });
  24121. //# sourceMappingURL=bpmn-viewer.js.map